@schukai/monster 3.57.0 → 3.58.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +22 -1
- package/package.json +1 -1
- package/source/components/datatable/change-button.mjs +8 -4
- package/source/components/datatable/dataset.mjs +1 -1
- package/source/components/datatable/filter.mjs +0 -1
- package/source/components/form/select.mjs +1781 -1769
- package/source/components/form/style/button-bar.pcss +2 -0
- package/source/components/form/style/button.pcss +2 -0
- package/source/components/form/style/toggle-switch.pcss +67 -58
- package/source/components/form/stylesheet/button-bar.mjs +1 -1
- package/source/components/form/stylesheet/button.mjs +1 -1
- package/source/components/form/stylesheet/select.mjs +1 -1
- package/source/components/form/stylesheet/toggle-switch.mjs +1 -1
- package/source/components/form/tabs.mjs +0 -1
- package/source/components/form/toggle-switch.mjs +282 -280
- package/source/data/transformer.mjs +4 -6
- package/source/dom/customelement.mjs +897 -904
- package/source/dom/events.mjs +3 -3
- package/source/dom/updater.mjs +754 -749
- package/source/dom/util/set-option-from-attribute.mjs +1 -2
- package/source/i18n/translations.mjs +1 -1
- package/source/monster.mjs +2 -0
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/import.js +1 -0
- package/test/web/test.html +2 -2
- package/test/web/tests.js +990 -460
@@ -12,17 +12,15 @@ import { ProxyObserver } from "../../types/proxyobserver.mjs";
|
|
12
12
|
|
13
13
|
import { addAttributeToken } from "../../dom/attributes.mjs";
|
14
14
|
import {
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
assembleMethodSymbol,
|
16
|
+
registerCustomElement,
|
17
|
+
updaterTransformerMethodsSymbol,
|
18
18
|
} from "../../dom/customelement.mjs";
|
19
|
-
import {
|
20
|
-
isObject
|
21
|
-
} from "../../types/is.mjs";
|
19
|
+
import { isObject } from "../../types/is.mjs";
|
22
20
|
import { ToggleSwitchStyleSheet } from "./stylesheet/toggle-switch.mjs";
|
23
21
|
import {
|
24
|
-
|
25
|
-
|
22
|
+
ATTRIBUTE_ERRORMESSAGE,
|
23
|
+
ATTRIBUTE_ROLE,
|
26
24
|
} from "../../dom/constants.mjs";
|
27
25
|
export { ToggleSwitch };
|
28
26
|
|
@@ -47,18 +45,18 @@ const switchElementSymbolOff = Symbol("switchElementOff");
|
|
47
45
|
/**
|
48
46
|
* @type {string}
|
49
47
|
*/
|
50
|
-
export const STATE_ON =
|
48
|
+
export const STATE_ON = "on";
|
51
49
|
|
52
50
|
/**
|
53
51
|
* @type {string}
|
54
52
|
*/
|
55
|
-
export const STATE_OFF =
|
53
|
+
export const STATE_OFF = "off";
|
56
54
|
|
57
55
|
/**
|
58
56
|
* This CustomControl creates a ToggleSwitch element
|
59
57
|
*
|
60
58
|
* <img src="./images/switch.png">
|
61
|
-
*
|
59
|
+
*
|
62
60
|
*
|
63
61
|
* @startuml toggleswitch.png
|
64
62
|
* skinparam monochrome true
|
@@ -67,215 +65,217 @@ export const STATE_OFF = 'off';
|
|
67
65
|
* CustomElement <|-- CustomControl
|
68
66
|
* CustomControl <|-- ToggleSwitch
|
69
67
|
* @enduml
|
70
|
-
*
|
71
|
-
* @since 3.57.0
|
68
|
+
*
|
69
|
+
* @since 3.57.0
|
72
70
|
* @copyright schukai GmbH
|
73
71
|
* @memberOf Monster.Components.Form
|
74
72
|
* @summary A simple Switch
|
75
73
|
*/
|
76
74
|
class ToggleSwitch extends CustomControl {
|
75
|
+
/**
|
76
|
+
* This method is called by the `instanceof` operator.
|
77
|
+
* @returns {symbol}
|
78
|
+
* @since 2.1.0
|
79
|
+
*/
|
80
|
+
static get [instanceSymbol]() {
|
81
|
+
return Symbol.for(
|
82
|
+
"@schukai/monster/components/form/toggle-switch@@instance",
|
83
|
+
);
|
84
|
+
}
|
85
|
+
|
86
|
+
static getTag() {
|
87
|
+
return "monster-toggle-switch";
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
92
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
93
|
+
*
|
94
|
+
* The individual configuration values can be found in the table.
|
95
|
+
*
|
96
|
+
* @property {string} value=current value of the element
|
97
|
+
* @property {Boolean} disabled=disabled=false Disabled state
|
98
|
+
* @property {Object} classes
|
99
|
+
* @property {string} classes.on=specifies the class for the on state.
|
100
|
+
* @property {string} classes.off=specifies the class for the off state.
|
101
|
+
* @property {Object} values
|
102
|
+
* @property {string} values.off=specifies the value of the element if it is not selected
|
103
|
+
* @property {Object} labels
|
104
|
+
* @property {string} labels.on=specifies the label for the on state.
|
105
|
+
* @property {string} labels.off=specifies the label for the off state.
|
106
|
+
* @property {Object} templates
|
107
|
+
* @property {string} templates.main=specifies the main template used by the control.
|
108
|
+
*
|
109
|
+
* @since 3.57.0
|
110
|
+
*/
|
111
|
+
get defaults() {
|
112
|
+
return Object.assign({}, super.defaults, {
|
113
|
+
value: null,
|
114
|
+
disabled: false,
|
115
|
+
classes: {
|
116
|
+
on: "monster-theme-primary-3",
|
117
|
+
off: "monster-theme-primary-2",
|
118
|
+
},
|
119
|
+
values: {
|
120
|
+
on: "on",
|
121
|
+
off: "off",
|
122
|
+
},
|
123
|
+
labels: {
|
124
|
+
"toggle-switch-on": "ON",
|
125
|
+
"toggle-switch-off": "OFF",
|
126
|
+
},
|
127
|
+
templates: {
|
128
|
+
main: getTemplate(),
|
129
|
+
},
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
*
|
135
|
+
* @return {Monster.Components.Form.ToggleSwitch}
|
136
|
+
*/
|
137
|
+
[assembleMethodSymbol]() {
|
138
|
+
const self = this;
|
139
|
+
super[assembleMethodSymbol]();
|
140
|
+
initControlReferences.call(this);
|
141
|
+
initEventHandler.call(this);
|
142
|
+
|
143
|
+
/**
|
144
|
+
* init value to off
|
145
|
+
* if the value was not defined before inserting it into the HTML
|
146
|
+
*/
|
147
|
+
if (self.getOption("value") === null) {
|
148
|
+
self.setOption("value", self.getOption("values.off"));
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* value from attribute
|
153
|
+
*/
|
154
|
+
if (self.hasAttribute("value")) {
|
155
|
+
self.setOption("value", self.getAttribute("value"));
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* validate value
|
160
|
+
*/
|
161
|
+
validateAndSetValue.call(self);
|
162
|
+
|
163
|
+
if (this.state === STATE_ON) {
|
164
|
+
toggleClassOn.call(self);
|
165
|
+
} else {
|
166
|
+
toggleClassOff.call(self);
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* is called when options changed
|
171
|
+
*/
|
172
|
+
self[internalSymbol].attachObserver(
|
173
|
+
new Observer(function () {
|
174
|
+
if (isObject(this) && this instanceof ProxyObserver) {
|
175
|
+
validateAndSetValue.call(self);
|
176
|
+
toggleClass.call(self);
|
177
|
+
}
|
178
|
+
}),
|
179
|
+
);
|
180
|
+
|
181
|
+
return this;
|
182
|
+
}
|
183
|
+
|
184
|
+
/**
|
185
|
+
* updater transformer methods for pipe
|
186
|
+
*
|
187
|
+
* @return {function}
|
188
|
+
*/
|
189
|
+
[updaterTransformerMethodsSymbol]() {
|
190
|
+
return {
|
191
|
+
"state-callback": (Wert) => {
|
192
|
+
return this.state;
|
193
|
+
},
|
194
|
+
};
|
195
|
+
}
|
196
|
+
|
197
|
+
/**
|
198
|
+
* @return [CSSStyleSheet]
|
199
|
+
*/
|
200
|
+
static getCSSStyleSheet() {
|
201
|
+
return [ToggleSwitchStyleSheet];
|
202
|
+
}
|
77
203
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
*/
|
83
|
-
static get [instanceSymbol]() {
|
84
|
-
return Symbol.for("@schukai/monster/components/form/toggle-switch@@instance");
|
85
|
-
}
|
86
|
-
|
87
|
-
static getTag() {
|
88
|
-
return "monster-toggle-switch";
|
89
|
-
}
|
90
|
-
|
91
|
-
/**
|
92
|
-
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
93
|
-
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
94
|
-
*
|
95
|
-
* The individual configuration values can be found in the table.
|
96
|
-
*
|
97
|
-
* @property {string} value=current value of the element
|
98
|
-
* @property {Boolean} disabled=disabled=false Disabled state
|
99
|
-
* @property {Object} classes
|
100
|
-
* @property {string} classes.on=specifies the class for the on state.
|
101
|
-
* @property {string} classes.off=specifies the class for the off state.
|
102
|
-
* @property {Object} values
|
103
|
-
* @property {string} values.off=specifies the value of the element if it is not selected
|
104
|
-
* @property {Object} labels
|
105
|
-
* @property {string} labels.on=specifies the label for the on state.
|
106
|
-
* @property {string} labels.off=specifies the label for the off state.
|
107
|
-
* @property {Object} templates
|
108
|
-
* @property {string} templates.main=specifies the main template used by the control.
|
109
|
-
*
|
110
|
-
* @since 3.57.0
|
111
|
-
*/
|
112
|
-
get defaults() {
|
113
|
-
return Object.assign({}, super.defaults, {
|
114
|
-
value: null,
|
115
|
-
disabled: false,
|
116
|
-
classes: {
|
117
|
-
"on": "monster-theme-primary-3",
|
118
|
-
"off": "monster-theme-primary-2"
|
119
|
-
},
|
120
|
-
values: {
|
121
|
-
on: "on",
|
122
|
-
off: "off"
|
123
|
-
},
|
124
|
-
labels: {
|
125
|
-
"toggle-switch-on": "ON",
|
126
|
-
"toggle-switch-off": "OFF",
|
127
|
-
},
|
128
|
-
templates: {
|
129
|
-
main: getTemplate()
|
130
|
-
}
|
131
|
-
})
|
132
|
-
}
|
133
|
-
|
134
|
-
/**
|
135
|
-
*
|
136
|
-
* @return {Monster.Components.Form.Button}
|
137
|
-
*/
|
138
|
-
[assembleMethodSymbol]() {
|
139
|
-
const self = this;
|
140
|
-
super[assembleMethodSymbol]();
|
141
|
-
initControlReferences.call(this);
|
142
|
-
initEventHandler.call(this);
|
143
|
-
|
144
|
-
/**
|
145
|
-
* init value to off
|
146
|
-
* if the value was not defined before inserting it into the HTML
|
147
|
-
*/
|
148
|
-
if (self.getOption("value") === null) {
|
149
|
-
self.setOption('value', self.getOption("values.off"));
|
150
|
-
}
|
151
|
-
|
152
|
-
/**
|
153
|
-
* value from attribute
|
154
|
-
*/
|
155
|
-
if (self.hasAttribute("value")) {
|
156
|
-
self.setOption('value', self.getAttribute("value"));
|
157
|
-
}
|
158
|
-
|
159
|
-
/**
|
160
|
-
* validate value
|
161
|
-
*/
|
162
|
-
validateAndSetValue.call(self);
|
163
|
-
|
164
|
-
if(this.state === STATE_ON) {
|
165
|
-
toggleClassOn.call(self);
|
166
|
-
}else{
|
167
|
-
toggleClassOff.call(self);
|
168
|
-
}
|
169
|
-
|
170
|
-
/**
|
171
|
-
* is called when options changed
|
172
|
-
*/
|
173
|
-
self[internalSymbol].attachObserver(
|
174
|
-
new Observer(function () {
|
175
|
-
if (isObject(this) && this instanceof ProxyObserver) {
|
176
|
-
validateAndSetValue.call(self);
|
177
|
-
toggleClass.call(self);
|
178
|
-
}
|
179
|
-
}),
|
180
|
-
);
|
181
|
-
|
182
|
-
return this;
|
183
|
-
}
|
184
|
-
|
185
|
-
/**
|
186
|
-
* updater transformer methods for pipe
|
187
|
-
*
|
188
|
-
* @return {function}
|
189
|
-
*/
|
190
|
-
[updaterTransformerMethodsSymbol]() {
|
191
|
-
const self = this;
|
192
|
-
return {
|
193
|
-
"state-callback": (Wert) => {
|
194
|
-
return self.state;
|
195
|
-
}
|
196
|
-
}
|
197
|
-
}
|
198
|
-
|
199
|
-
/**
|
200
|
-
* @return [SwitchStyleSheet]
|
201
|
-
*/
|
202
|
-
static getCSSStyleSheet() {
|
203
|
-
return [ToggleSwitchStyleSheet];
|
204
|
-
}
|
205
|
-
|
206
|
-
/**
|
207
|
-
* toggle switch
|
208
|
-
*
|
209
|
-
* ```
|
204
|
+
/**
|
205
|
+
* toggle switch
|
206
|
+
*
|
207
|
+
* ```
|
210
208
|
* e = document.querySelector('monster-toggle-switch');
|
211
209
|
* e.click()
|
212
210
|
* ```
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
211
|
+
*/
|
212
|
+
click() {
|
213
|
+
toggleValues.call(this);
|
214
|
+
}
|
215
|
+
|
216
|
+
/**
|
217
|
+
* toggle switch on/off
|
218
|
+
*
|
219
|
+
* ```
|
222
220
|
* e = document.querySelector('monster-toggle-switch');
|
223
221
|
* e.toggle()
|
224
222
|
* ```
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
223
|
+
*
|
224
|
+
* @return {ToggleSwitch}
|
225
|
+
*/
|
226
|
+
toggle() {
|
227
|
+
this.click();
|
228
|
+
return this;
|
229
|
+
}
|
230
|
+
|
231
|
+
/**
|
232
|
+
* toggle switch on
|
233
|
+
*
|
234
|
+
* ```
|
237
235
|
* e = document.querySelector('monster-toggle-switch');
|
238
236
|
* e.toggleOn()
|
239
237
|
* ```
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
238
|
+
*
|
239
|
+
* @return {ToggleSwitch}
|
240
|
+
*/
|
241
|
+
toggleOn() {
|
242
|
+
this.setOption("value", this.getOption("values.on"));
|
243
|
+
return this;
|
244
|
+
}
|
245
|
+
|
246
|
+
/**
|
247
|
+
* toggle switch off
|
248
|
+
*
|
249
|
+
* ```
|
252
250
|
* e = document.querySelector('monster-toggle-switch');
|
253
251
|
* e.toggleOff()
|
254
252
|
* ```
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
253
|
+
*
|
254
|
+
* @return {ToggleSwitch}
|
255
|
+
*/
|
256
|
+
toggleOff() {
|
257
|
+
this.setOption("value", this.getOption("values.off"));
|
258
|
+
return this;
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* returns the status of the element
|
263
|
+
*
|
264
|
+
* ```
|
267
265
|
* e = document.querySelector('monster-toggle-switch');
|
268
266
|
* console.log(e.state)
|
269
267
|
* // ↦ off
|
270
268
|
* ```
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
269
|
+
*
|
270
|
+
* @return {string}
|
271
|
+
*/
|
272
|
+
get state() {
|
273
|
+
return this.getOption("value") === this.getOption("values.on")
|
274
|
+
? STATE_ON
|
275
|
+
: STATE_OFF;
|
276
|
+
}
|
277
|
+
|
278
|
+
/**
|
279
279
|
* The current value of the Switch
|
280
280
|
*
|
281
281
|
* ```
|
@@ -286,11 +286,13 @@ class ToggleSwitch extends CustomControl {
|
|
286
286
|
*
|
287
287
|
* @return {string}
|
288
288
|
*/
|
289
|
-
|
290
|
-
|
291
|
-
|
289
|
+
get value() {
|
290
|
+
return this.state === STATE_ON
|
291
|
+
? this.getOption("values.on")
|
292
|
+
: this.getOption("values.off");
|
293
|
+
}
|
292
294
|
|
293
|
-
|
295
|
+
/**
|
294
296
|
* Set value
|
295
297
|
*
|
296
298
|
* ```
|
@@ -300,93 +302,94 @@ class ToggleSwitch extends CustomControl {
|
|
300
302
|
*
|
301
303
|
* @property {string} value
|
302
304
|
*/
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
305
|
+
set value(value) {
|
306
|
+
this.setOption("value", value);
|
307
|
+
}
|
307
308
|
}
|
308
309
|
|
309
310
|
/**
|
310
311
|
* @private
|
311
312
|
*/
|
312
313
|
function initControlReferences() {
|
313
|
-
|
314
|
-
|
315
|
-
|
314
|
+
this[switchElementSymbol] = this.shadowRoot.querySelector(
|
315
|
+
`[${ATTRIBUTE_ROLE}=switch]`,
|
316
|
+
);
|
316
317
|
}
|
317
318
|
|
318
319
|
/**
|
319
|
-
* @private
|
320
|
-
*/
|
320
|
+
* @private
|
321
|
+
*/
|
321
322
|
function toggleClassOn() {
|
322
|
-
|
323
|
-
|
323
|
+
this[switchElementSymbol].classList.remove(this.getOption("classes.off")); // change color
|
324
|
+
this[switchElementSymbol].classList.add(this.getOption("classes.on")); // change color
|
324
325
|
}
|
325
326
|
|
326
327
|
/**
|
327
|
-
* @private
|
328
|
-
*/
|
328
|
+
* @private
|
329
|
+
*/
|
329
330
|
function toggleClassOff() {
|
330
|
-
|
331
|
-
|
331
|
+
this[switchElementSymbol].classList.remove(this.getOption("classes.on")); // change color
|
332
|
+
this[switchElementSymbol].classList.add(this.getOption("classes.off")); // change color
|
332
333
|
}
|
333
334
|
|
334
335
|
/**
|
335
|
-
* @private
|
336
|
-
*/
|
337
|
-
function toggleClass() {
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
}
|
336
|
+
* @private
|
337
|
+
*/
|
338
|
+
function toggleClass() {;
|
339
|
+
if (this.getOption("value") === this.getOption("values.on")) {
|
340
|
+
toggleClassOn.call(this);
|
341
|
+
} else {
|
342
|
+
toggleClassOff.call(this);
|
343
|
+
}
|
344
344
|
}
|
345
345
|
|
346
346
|
/**
|
347
347
|
* @private
|
348
348
|
*/
|
349
|
-
function toggleValues() {
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
self.setOption('state', self.state);
|
349
|
+
function toggleValues() {;
|
350
|
+
|
351
|
+
if (this.getOption("disabled") === true) {
|
352
|
+
return;
|
353
|
+
}
|
354
|
+
|
355
|
+
if (this.getOption("value") === this.getOption("values.on")) {
|
356
|
+
this.setOption("value", this.getOption("values.off"));
|
357
|
+
this?.setFormValue(this.getOption("value")); // set form value
|
358
|
+
} else {
|
359
|
+
this.setOption("value", this.getOption("values.on"));
|
360
|
+
this?.setFormValue(this.getOption("values.off")); // set form value
|
361
|
+
}
|
362
|
+
|
363
|
+
this.setOption("state", this.state);
|
365
364
|
}
|
366
365
|
|
367
366
|
/**
|
368
|
-
* @private
|
369
|
-
*/
|
370
|
-
function validateAndSetValue() {
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
367
|
+
* @private
|
368
|
+
*/
|
369
|
+
function validateAndSetValue() {;
|
370
|
+
const value = this.getOption("value");
|
371
|
+
|
372
|
+
const validatedValues = [];
|
373
|
+
validatedValues.push(this.getOption("values.on"));
|
374
|
+
validatedValues.push(this.getOption("values.off"));
|
375
|
+
|
376
|
+
if (validatedValues.includes(value) === false) {
|
377
|
+
addAttributeToken(
|
378
|
+
this,
|
379
|
+
ATTRIBUTE_ERRORMESSAGE,
|
380
|
+
'The value "' +
|
381
|
+
value +
|
382
|
+
'" must be "' +
|
383
|
+
this.getOption("values.on") +
|
384
|
+
'" or "' +
|
385
|
+
this.getOption("values.off"),
|
386
|
+
);
|
387
|
+
this.setOption("disabled", true);
|
388
|
+
this.formDisabledCallback(true);
|
389
|
+
} else {
|
390
|
+
this.setOption("disabled", false);
|
391
|
+
this.formDisabledCallback(false);
|
392
|
+
}
|
390
393
|
}
|
391
394
|
|
392
395
|
/**
|
@@ -394,16 +397,16 @@ function validateAndSetValue() {
|
|
394
397
|
* @return {initEventHandler}
|
395
398
|
*/
|
396
399
|
function initEventHandler() {
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
400
|
+
const self = this;
|
401
|
+
self.addEventListener("keyup", function (event) {
|
402
|
+
if (event.code === "Space") {
|
403
|
+
self[switchElementSymbol].click();
|
404
|
+
}
|
405
|
+
});
|
406
|
+
self.addEventListener("click", function (event) {
|
407
|
+
toggleValues.call(self);
|
408
|
+
});
|
409
|
+
return this;
|
407
410
|
}
|
408
411
|
|
409
412
|
/**
|
@@ -411,17 +414,16 @@ function initEventHandler() {
|
|
411
414
|
* @return {string}
|
412
415
|
*/
|
413
416
|
function getTemplate() {
|
414
|
-
|
415
|
-
|
417
|
+
// language=HTML
|
418
|
+
return `
|
416
419
|
<div data-monster-role="control" part="control" tabindex="0">
|
417
|
-
|
418
|
-
|
420
|
+
<div class="switch" data-monster-role="switch"
|
421
|
+
data-monster-attributes="data-monster-state path:value | call:state-callback">
|
419
422
|
<div class="label on" data-monster-replace="path:labels.toggle-switch-on"></div>
|
420
423
|
<div class="label off" data-monster-replace="path:labels.toggle-switch-off"></div>
|
421
424
|
<div class="switch-slider"></div>
|
422
425
|
</div>
|
423
|
-
|
424
426
|
</div>`;
|
425
427
|
}
|
426
428
|
|
427
|
-
registerCustomElement(ToggleSwitch);
|
429
|
+
registerCustomElement(ToggleSwitch);
|