1 | /**
|
2 | * @license
|
3 | * Copyright 2017 Google Inc.
|
4 | *
|
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 | * of this software and associated documentation files (the "Software"), to deal
|
7 | * in the Software without restriction, including without limitation the rights
|
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 | * copies of the Software, and to permit persons to whom the Software is
|
10 | * furnished to do so, subject to the following conditions:
|
11 | *
|
12 | * The above copyright notice and this permission notice shall be included in
|
13 | * all copies or substantial portions of the Software.
|
14 | *
|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 | * THE SOFTWARE.
|
22 | */
|
23 | import { __extends } from "tslib";
|
24 | import { MDCComponent } from '@material/base/component';
|
25 | import { MDCFormFieldFoundation } from './foundation';
|
26 | var MDCFormField = /** @class */ (function (_super) {
|
27 | __extends(MDCFormField, _super);
|
28 | function MDCFormField() {
|
29 | return _super !== null && _super.apply(this, arguments) || this;
|
30 | }
|
31 | MDCFormField.attachTo = function (root) {
|
32 | return new MDCFormField(root);
|
33 | };
|
34 | MDCFormField.prototype.labelEl = function () {
|
35 | var LABEL_SELECTOR = MDCFormFieldFoundation.strings.LABEL_SELECTOR;
|
36 | return this.root.querySelector(LABEL_SELECTOR);
|
37 | };
|
38 | MDCFormField.prototype.getDefaultFoundation = function () {
|
39 | var _this = this;
|
40 | // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
|
41 | // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
|
42 | var adapter = {
|
43 | activateInputRipple: function () {
|
44 | if (_this.input && _this.input.ripple) {
|
45 | _this.input.ripple.activate();
|
46 | }
|
47 | },
|
48 | deactivateInputRipple: function () {
|
49 | if (_this.input && _this.input.ripple) {
|
50 | _this.input.ripple.deactivate();
|
51 | }
|
52 | },
|
53 | deregisterInteractionHandler: function (evtType, handler) {
|
54 | var labelEl = _this.labelEl();
|
55 | if (labelEl) {
|
56 | labelEl.removeEventListener(evtType, handler);
|
57 | }
|
58 | },
|
59 | registerInteractionHandler: function (evtType, handler) {
|
60 | var labelEl = _this.labelEl();
|
61 | if (labelEl) {
|
62 | labelEl.addEventListener(evtType, handler);
|
63 | }
|
64 | },
|
65 | };
|
66 | return new MDCFormFieldFoundation(adapter);
|
67 | };
|
68 | return MDCFormField;
|
69 | }(MDCComponent));
|
70 | export { MDCFormField };
|
71 | //# sourceMappingURL=component.js.map |
\ | No newline at end of file |