1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | import { __assign, __extends } from "tslib";
|
24 | import { MDCComponent } from '@material/base/component';
|
25 | import { applyPassive } from '@material/dom/events';
|
26 | import { MDCRipple } from '@material/ripple/component';
|
27 | import { MDCRippleFoundation } from '@material/ripple/foundation';
|
28 | import { MDCRadioFoundation } from './foundation';
|
29 | var MDCRadio = (function (_super) {
|
30 | __extends(MDCRadio, _super);
|
31 | function MDCRadio() {
|
32 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
33 | _this.rippleSurface = _this.createRipple();
|
34 | return _this;
|
35 | }
|
36 | MDCRadio.attachTo = function (root) {
|
37 | return new MDCRadio(root);
|
38 | };
|
39 | Object.defineProperty(MDCRadio.prototype, "checked", {
|
40 | get: function () {
|
41 | return this.nativeControl.checked;
|
42 | },
|
43 | set: function (checked) {
|
44 | this.nativeControl.checked = checked;
|
45 | },
|
46 | enumerable: false,
|
47 | configurable: true
|
48 | });
|
49 | Object.defineProperty(MDCRadio.prototype, "disabled", {
|
50 | get: function () {
|
51 | return this.nativeControl.disabled;
|
52 | },
|
53 | set: function (disabled) {
|
54 | this.foundation.setDisabled(disabled);
|
55 | },
|
56 | enumerable: false,
|
57 | configurable: true
|
58 | });
|
59 | Object.defineProperty(MDCRadio.prototype, "value", {
|
60 | get: function () {
|
61 | return this.nativeControl.value;
|
62 | },
|
63 | set: function (value) {
|
64 | this.nativeControl.value = value;
|
65 | },
|
66 | enumerable: false,
|
67 | configurable: true
|
68 | });
|
69 | Object.defineProperty(MDCRadio.prototype, "ripple", {
|
70 | get: function () {
|
71 | return this.rippleSurface;
|
72 | },
|
73 | enumerable: false,
|
74 | configurable: true
|
75 | });
|
76 | MDCRadio.prototype.destroy = function () {
|
77 | this.rippleSurface.destroy();
|
78 | _super.prototype.destroy.call(this);
|
79 | };
|
80 | MDCRadio.prototype.getDefaultFoundation = function () {
|
81 | var _this = this;
|
82 |
|
83 |
|
84 | var adapter = {
|
85 | addClass: function (className) { return _this.root.classList.add(className); },
|
86 | removeClass: function (className) { return _this.root.classList.remove(className); },
|
87 | setNativeControlDisabled: function (disabled) { return _this.nativeControl.disabled =
|
88 | disabled; },
|
89 | };
|
90 | return new MDCRadioFoundation(adapter);
|
91 | };
|
92 | MDCRadio.prototype.createRipple = function () {
|
93 | var _this = this;
|
94 |
|
95 |
|
96 |
|
97 | var adapter = __assign(__assign({}, MDCRipple.createAdapter(this)), { registerInteractionHandler: function (evtType, handler) {
|
98 | _this.nativeControl.addEventListener(evtType, handler, applyPassive());
|
99 | }, deregisterInteractionHandler: function (evtType, handler) {
|
100 | _this.nativeControl.removeEventListener(evtType, handler, applyPassive());
|
101 | },
|
102 |
|
103 |
|
104 | isSurfaceActive: function () { return false; }, isUnbounded: function () { return true; } });
|
105 |
|
106 | return new MDCRipple(this.root, new MDCRippleFoundation(adapter));
|
107 | };
|
108 | Object.defineProperty(MDCRadio.prototype, "nativeControl", {
|
109 | get: function () {
|
110 | var NATIVE_CONTROL_SELECTOR = MDCRadioFoundation.strings.NATIVE_CONTROL_SELECTOR;
|
111 | var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR);
|
112 | if (!el) {
|
113 | throw new Error("Radio component requires a " + NATIVE_CONTROL_SELECTOR + " element");
|
114 | }
|
115 | return el;
|
116 | },
|
117 | enumerable: false,
|
118 | configurable: true
|
119 | });
|
120 | return MDCRadio;
|
121 | }(MDCComponent));
|
122 | export { MDCRadio };
|
123 |
|
\ | No newline at end of file |