@schukai/monster 4.38.3 → 4.38.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,9 +17,9 @@ import { diff } from "../../data/diff.mjs";
17
17
  import { addAttributeToken } from "../../dom/attributes.mjs";
18
18
  import { ATTRIBUTE_ERRORMESSAGE } from "../../dom/constants.mjs";
19
19
  import {
20
- assembleMethodSymbol,
21
- CustomElement,
22
- registerCustomElement,
20
+ assembleMethodSymbol,
21
+ CustomElement,
22
+ registerCustomElement,
23
23
  } from "../../dom/customelement.mjs";
24
24
  import { findElementWithSelectorUpwards } from "../../dom/util.mjs";
25
25
  import { isString, isArray } from "../../types/is.mjs";
@@ -35,8 +35,8 @@ import { SaveButtonStyleSheet } from "./stylesheet/save-button.mjs";
35
35
  import "../form/state-button.mjs";
36
36
 
37
37
  import {
38
- handleDataSourceChanges,
39
- datasourceLinkedElementSymbol,
38
+ handleDataSourceChanges,
39
+ datasourceLinkedElementSymbol,
40
40
  } from "./util.mjs";
41
41
  import { getLocaleOfDocument } from "../../dom/locale.mjs";
42
42
 
@@ -73,270 +73,270 @@ const badgeElementSymbol = Symbol("badgeElement");
73
73
  * @summary This is a save button component that can be used to save changes to a datasource.
74
74
  */
75
75
  class SaveButton extends CustomElement {
76
- /**
77
- * This method is called by the `instanceof` operator.
78
- * @return {symbol}
79
- */
80
- static get [instanceSymbol]() {
81
- return Symbol.for(
82
- "@schukai/monster/components/datatable/save-button@@instance",
83
- );
84
- }
85
-
86
- /**
87
- * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
88
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
89
- *
90
- * The individual configuration values can be found in the table.
91
- *
92
- * @property {Object} templates Template definitions
93
- * @property {string} templates.main Main template
94
- * @property {object} datasource The datasource
95
- * @property {string} datasource.selector The selector of the datasource
96
- * @property {string} labels.button The button label
97
- * @property {Object} classes The classes
98
- * @property {string} classes.bar The bar class
99
- * @property {string} classes.badge The badge class
100
- * @property {Array} ignoreChanges The ignore changes (regex)
101
- * @property {Array} data The data
102
- * @property {boolean} disabled The disabled state
103
- * @property {string} logLevel The log level (off, debug)
104
- * @return {Object}
105
- */
106
- get defaults() {
107
- const obj = Object.assign({}, super.defaults, {
108
- templates: {
109
- main: getTemplate(),
110
- },
111
-
112
- labels: getTranslations(),
113
-
114
- classes: {
115
- bar: "monster-button-primary",
116
- badge: "monster-badge-secondary hidden",
117
- },
118
-
119
- datasource: {
120
- selector: null,
121
- },
122
-
123
- changes: "0",
124
-
125
- ignoreChanges: [],
126
-
127
- data: {},
128
-
129
- disabled: false,
130
-
131
- logLevel: "off",
132
- });
133
-
134
- updateOptionsFromArguments.call(this, obj);
135
- return obj;
136
- }
137
-
138
- /**
139
- *
140
- * @return {string}
141
- */
142
- static getTag() {
143
- return "monster-datasource-save-button";
144
- }
145
-
146
- /**
147
- * This method is responsible for assembling the component.
148
- *
149
- * It calls the parent's assemble method first, then initializes control references and event handlers.
150
- * If the `datasource.selector` option is provided and is a string, it searches for the corresponding
151
- * element in the DOM using that selector.
152
- *
153
- * If the selector matches exactly one element, it checks if the element is an instance of the `Datasource` class.
154
- *
155
- * If it is, the component's `datasourceLinkedElementSymbol` property is set to the element, and the component
156
- * attaches an observer to the datasource's changes.
157
- *
158
- * The observer is a function that calls the `handleDataSourceChanges` method in the context of the component.
159
- * Additionally, the component attaches an observer to itself, which also calls the `handleDataSourceChanges`
160
- * method in the component's context.
161
- */
162
- [assembleMethodSymbol]() {
163
- super[assembleMethodSymbol]();
164
- const self = this;
165
-
166
- initControlReferences.call(this);
167
- initEventHandler.call(this);
168
-
169
- const selector = this.getOption("datasource.selector");
170
-
171
- if (isString(selector)) {
172
- const element = findElementWithSelectorUpwards(this, selector);
173
- if (element === null) {
174
- throw new Error("the selector must match exactly one element");
175
- }
176
-
177
- if (!(element instanceof Datasource)) {
178
- throw new TypeError("the element must be a datasource");
179
- }
180
-
181
- if (element instanceof RestDatasource) {
182
- element.addEventListener("monster-datasource-fetch", (event) => {
183
- self[originValuesSymbol] = null;
184
- });
185
- }
186
-
187
- this[datasourceLinkedElementSymbol] = element;
188
- element.datasource.attachObserver(
189
- new Observer(handleDataSourceChanges.bind(this)),
190
- );
191
-
192
- self[originValuesSymbol] = null;
193
-
194
- element.datasource.attachObserver(
195
- new Observer(function () {
196
- if (!self[originValuesSymbol]) {
197
- self[originValuesSymbol] = clone(
198
- self[datasourceLinkedElementSymbol].data,
199
- );
200
- }
201
-
202
- const currentValues = this.getRealSubject();
203
- const ignoreChanges = self.getOption("ignoreChanges");
204
-
205
- const result = diff(self[originValuesSymbol], currentValues);
206
- if (self.getOption("logLevel") === "debug") {
207
- console.groupCollapsed("SaveButton");
208
- console.log(
209
- "originValues",
210
- JSON.parse(JSON.stringify(currentValues)),
211
- );
212
- console.log("result of diff", result);
213
- console.log("ignoreChanges", ignoreChanges);
214
-
215
- if (isArray(result) && result.length > 0) {
216
- const formattedDiff = result.map((change) => ({
217
- Operator: change?.operator,
218
- Path: change?.path?.join("."),
219
- "First Value": change?.first?.value,
220
- "First Type": change?.first?.type,
221
- "Second Value": change?.second?.value,
222
- "Second Type": change?.second?.type,
223
- }));
224
-
225
- console.table(formattedDiff);
226
- } else {
227
- console.log("There are no changes to save");
228
- }
229
- console.groupEnd();
230
- }
231
-
232
- if (isArray(ignoreChanges) && ignoreChanges.length > 0) {
233
- const itemsToRemove = [];
234
- for (const item of result) {
235
- for (const ignorePattern of ignoreChanges) {
236
- const p = new RegExp(ignorePattern);
237
-
238
- let matchPath = item.path;
239
- if (isArray(item.path)) {
240
- matchPath = item.path.join(".");
241
- }
242
-
243
- if (p.test(matchPath)) {
244
- itemsToRemove.push(item);
245
- break;
246
- }
247
- }
248
- }
249
-
250
- for (const itemToRemove of itemsToRemove) {
251
- const index = result.indexOf(itemToRemove);
252
- if (index > -1) {
253
- result.splice(index, 1);
254
- }
255
- }
256
- }
257
-
258
- if (isArray(result) && result.length > 0) {
259
- self[stateButtonElementSymbol].setState("changed");
260
- self[stateButtonElementSymbol].setOption("disabled", false);
261
- self.setOption("changes", result.length);
262
- self.setOption(
263
- "classes.badge",
264
- new TokenList(self.getOption("classes.badge"))
265
- .remove("hidden")
266
- .toString(),
267
- );
268
- } else {
269
- self[stateButtonElementSymbol].removeState();
270
- self[stateButtonElementSymbol].setOption("disabled", true);
271
- self.setOption("changes", 0);
272
- self.setOption(
273
- "classes.badge",
274
- new TokenList(self.getOption("classes.badge"))
275
- .add("hidden")
276
- .toString(),
277
- );
278
- }
279
- }),
280
- );
281
- }
282
-
283
- this.attachObserver(
284
- new Observer(() => {
285
- handleDataSourceChanges.call(this);
286
- }),
287
- );
288
- }
289
-
290
- /**
291
- *
292
- * @return [CSSStyleSheet]
293
- */
294
- static getCSSStyleSheet() {
295
- return [SaveButtonStyleSheet, BadgeStyleSheet];
296
- }
76
+ /**
77
+ * This method is called by the `instanceof` operator.
78
+ * @return {symbol}
79
+ */
80
+ static get [instanceSymbol]() {
81
+ return Symbol.for(
82
+ "@schukai/monster/components/datatable/save-button@@instance",
83
+ );
84
+ }
85
+
86
+ /**
87
+ * To set the options via the HTML tag, the attribute `data-monster-options` must be used.
88
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
89
+ *
90
+ * The individual configuration values can be found in the table.
91
+ *
92
+ * @property {Object} templates Template definitions
93
+ * @property {string} templates.main Main template
94
+ * @property {object} datasource The datasource
95
+ * @property {string} datasource.selector The selector of the datasource
96
+ * @property {string} labels.button The button label
97
+ * @property {Object} classes The classes
98
+ * @property {string} classes.bar The bar class
99
+ * @property {string} classes.badge The badge class
100
+ * @property {Array} ignoreChanges The ignore changes (regex)
101
+ * @property {Array} data The data
102
+ * @property {boolean} disabled The disabled state
103
+ * @property {string} logLevel The log level (off, debug)
104
+ * @return {Object}
105
+ */
106
+ get defaults() {
107
+ const obj = Object.assign({}, super.defaults, {
108
+ templates: {
109
+ main: getTemplate(),
110
+ },
111
+
112
+ labels: getTranslations(),
113
+
114
+ classes: {
115
+ bar: "monster-button-primary",
116
+ badge: "monster-badge-secondary hidden",
117
+ },
118
+
119
+ datasource: {
120
+ selector: null,
121
+ },
122
+
123
+ changes: "0",
124
+
125
+ ignoreChanges: [],
126
+
127
+ data: {},
128
+
129
+ disabled: false,
130
+
131
+ logLevel: "off",
132
+ });
133
+
134
+ updateOptionsFromArguments.call(this, obj);
135
+ return obj;
136
+ }
137
+
138
+ /**
139
+ *
140
+ * @return {string}
141
+ */
142
+ static getTag() {
143
+ return "monster-datasource-save-button";
144
+ }
145
+
146
+ /**
147
+ * This method is responsible for assembling the component.
148
+ *
149
+ * It calls the parent's assemble method first, then initializes control references and event handlers.
150
+ * If the `datasource.selector` option is provided and is a string, it searches for the corresponding
151
+ * element in the DOM using that selector.
152
+ *
153
+ * If the selector matches exactly one element, it checks if the element is an instance of the `Datasource` class.
154
+ *
155
+ * If it is, the component's `datasourceLinkedElementSymbol` property is set to the element, and the component
156
+ * attaches an observer to the datasource's changes.
157
+ *
158
+ * The observer is a function that calls the `handleDataSourceChanges` method in the context of the component.
159
+ * Additionally, the component attaches an observer to itself, which also calls the `handleDataSourceChanges`
160
+ * method in the component's context.
161
+ */
162
+ [assembleMethodSymbol]() {
163
+ super[assembleMethodSymbol]();
164
+ const self = this;
165
+
166
+ initControlReferences.call(this);
167
+ initEventHandler.call(this);
168
+
169
+ const selector = this.getOption("datasource.selector");
170
+
171
+ if (isString(selector)) {
172
+ const element = findElementWithSelectorUpwards(this, selector);
173
+ if (element === null) {
174
+ throw new Error("the selector must match exactly one element");
175
+ }
176
+
177
+ if (!(element instanceof Datasource)) {
178
+ throw new TypeError("the element must be a datasource");
179
+ }
180
+
181
+ if (element instanceof RestDatasource) {
182
+ element.addEventListener("monster-datasource-fetch", (event) => {
183
+ self[originValuesSymbol] = null;
184
+ });
185
+ }
186
+
187
+ this[datasourceLinkedElementSymbol] = element;
188
+ element.datasource.attachObserver(
189
+ new Observer(handleDataSourceChanges.bind(this)),
190
+ );
191
+
192
+ self[originValuesSymbol] = null;
193
+
194
+ element.datasource.attachObserver(
195
+ new Observer(function () {
196
+ if (!self[originValuesSymbol]) {
197
+ self[originValuesSymbol] = clone(
198
+ self[datasourceLinkedElementSymbol].data,
199
+ );
200
+ }
201
+
202
+ const currentValues = this.getRealSubject();
203
+ const ignoreChanges = self.getOption("ignoreChanges");
204
+
205
+ const result = diff(self[originValuesSymbol], currentValues);
206
+ if (self.getOption("logLevel") === "debug") {
207
+ console.groupCollapsed("SaveButton");
208
+ console.log(
209
+ "originValues",
210
+ JSON.parse(JSON.stringify(currentValues)),
211
+ );
212
+ console.log("result of diff", result);
213
+ console.log("ignoreChanges", ignoreChanges);
214
+
215
+ if (isArray(result) && result.length > 0) {
216
+ const formattedDiff = result.map((change) => ({
217
+ Operator: change?.operator,
218
+ Path: change?.path?.join("."),
219
+ "First Value": change?.first?.value,
220
+ "First Type": change?.first?.type,
221
+ "Second Value": change?.second?.value,
222
+ "Second Type": change?.second?.type,
223
+ }));
224
+
225
+ console.table(formattedDiff);
226
+ } else {
227
+ console.log("There are no changes to save");
228
+ }
229
+ console.groupEnd();
230
+ }
231
+
232
+ if (isArray(ignoreChanges) && ignoreChanges.length > 0) {
233
+ const itemsToRemove = [];
234
+ for (const item of result) {
235
+ for (const ignorePattern of ignoreChanges) {
236
+ const p = new RegExp(ignorePattern);
237
+
238
+ let matchPath = item.path;
239
+ if (isArray(item.path)) {
240
+ matchPath = item.path.join(".");
241
+ }
242
+
243
+ if (p.test(matchPath)) {
244
+ itemsToRemove.push(item);
245
+ break;
246
+ }
247
+ }
248
+ }
249
+
250
+ for (const itemToRemove of itemsToRemove) {
251
+ const index = result.indexOf(itemToRemove);
252
+ if (index > -1) {
253
+ result.splice(index, 1);
254
+ }
255
+ }
256
+ }
257
+
258
+ if (isArray(result) && result.length > 0) {
259
+ self[stateButtonElementSymbol].setState("changed");
260
+ self[stateButtonElementSymbol].setOption("disabled", false);
261
+ self.setOption("changes", result.length);
262
+ self.setOption(
263
+ "classes.badge",
264
+ new TokenList(self.getOption("classes.badge"))
265
+ .remove("hidden")
266
+ .toString(),
267
+ );
268
+ } else {
269
+ self[stateButtonElementSymbol].removeState();
270
+ self[stateButtonElementSymbol].setOption("disabled", true);
271
+ self.setOption("changes", 0);
272
+ self.setOption(
273
+ "classes.badge",
274
+ new TokenList(self.getOption("classes.badge"))
275
+ .add("hidden")
276
+ .toString(),
277
+ );
278
+ }
279
+ }),
280
+ );
281
+ }
282
+
283
+ this.attachObserver(
284
+ new Observer(() => {
285
+ handleDataSourceChanges.call(this);
286
+ }),
287
+ );
288
+ }
289
+
290
+ /**
291
+ *
292
+ * @return [CSSStyleSheet]
293
+ */
294
+ static getCSSStyleSheet() {
295
+ return [SaveButtonStyleSheet, BadgeStyleSheet];
296
+ }
297
297
  }
298
298
 
299
299
  function getTranslations() {
300
- const locale = getLocaleOfDocument();
301
- switch (locale.language) {
302
- case "de":
303
- return {
304
- button: "Speichern",
305
- };
306
- case "fr":
307
- return {
308
- button: "Enregistrer",
309
- };
310
- case "sp":
311
- return {
312
- button: "Guardar",
313
- };
314
- case "it":
315
- return {
316
- button: "Salva",
317
- };
318
- case "pl":
319
- return {
320
- button: "Zapisz",
321
- };
322
- case "no":
323
- return {
324
- button: "Lagre",
325
- };
326
- case "dk":
327
- return {
328
- button: "Gem",
329
- };
330
- case "sw":
331
- return {
332
- button: "Spara",
333
- };
334
- default:
335
- case "en":
336
- return {
337
- button: "Save",
338
- };
339
- }
300
+ const locale = getLocaleOfDocument();
301
+ switch (locale.language) {
302
+ case "de":
303
+ return {
304
+ button: "Speichern",
305
+ };
306
+ case "fr":
307
+ return {
308
+ button: "Enregistrer",
309
+ };
310
+ case "sp":
311
+ return {
312
+ button: "Guardar",
313
+ };
314
+ case "it":
315
+ return {
316
+ button: "Salva",
317
+ };
318
+ case "pl":
319
+ return {
320
+ button: "Zapisz",
321
+ };
322
+ case "no":
323
+ return {
324
+ button: "Lagre",
325
+ };
326
+ case "dk":
327
+ return {
328
+ button: "Gem",
329
+ };
330
+ case "sw":
331
+ return {
332
+ button: "Spara",
333
+ };
334
+ default:
335
+ case "en":
336
+ return {
337
+ button: "Save",
338
+ };
339
+ }
340
340
  }
341
341
 
342
342
  /**
@@ -350,71 +350,71 @@ function getTranslations() {
350
350
  * @throws {Error} the selector must match exactly one element
351
351
  */
352
352
  function initControlReferences() {
353
- if (!this.shadowRoot) {
354
- throw new Error("no shadow-root is defined");
355
- }
356
-
357
- this[stateButtonElementSymbol] = this.shadowRoot.querySelector(
358
- "[data-monster-role=state-button]",
359
- );
360
-
361
- this[badgeElementSymbol] = this.shadowRoot.querySelector(
362
- "[data-monster-role=badge]",
363
- );
364
-
365
- if (this[stateButtonElementSymbol]) {
366
- queueMicrotask(() => {
367
- const states = {
368
- changed: new State(
369
- "changed",
370
- '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-arrow-up" viewBox="0 0 16 16">' +
371
- '<path fill-rule="evenodd" d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708z"/>' +
372
- '<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"/>' +
373
- "</svg>",
374
- ),
375
- };
376
-
377
- this[stateButtonElementSymbol].removeState();
378
- this[stateButtonElementSymbol].setOption("disabled", "disabled");
379
- this[stateButtonElementSymbol].setOption("states", states);
380
- this[stateButtonElementSymbol].setOption(
381
- "labels.button",
382
- this.getOption("labels.button"),
383
- );
384
- });
385
- }
386
-
387
- return this;
353
+ if (!this.shadowRoot) {
354
+ throw new Error("no shadow-root is defined");
355
+ }
356
+
357
+ this[stateButtonElementSymbol] = this.shadowRoot.querySelector(
358
+ "[data-monster-role=state-button]",
359
+ );
360
+
361
+ this[badgeElementSymbol] = this.shadowRoot.querySelector(
362
+ "[data-monster-role=badge]",
363
+ );
364
+
365
+ if (this[stateButtonElementSymbol]) {
366
+ queueMicrotask(() => {
367
+ const states = {
368
+ changed: new State(
369
+ "changed",
370
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-arrow-up" viewBox="0 0 16 16">' +
371
+ '<path fill-rule="evenodd" d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708z"/>' +
372
+ '<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"/>' +
373
+ "</svg>",
374
+ ),
375
+ };
376
+
377
+ this[stateButtonElementSymbol].removeState();
378
+ this[stateButtonElementSymbol].setOption("disabled", "disabled");
379
+ this[stateButtonElementSymbol].setOption("states", states);
380
+ this[stateButtonElementSymbol].setOption(
381
+ "labels.button",
382
+ this.getOption("labels.button"),
383
+ );
384
+ });
385
+ }
386
+
387
+ return this;
388
388
  }
389
389
 
390
390
  /**
391
391
  * @private
392
392
  */
393
393
  function initEventHandler() {
394
- queueMicrotask(() => {
395
- this[stateButtonElementSymbol].setOption("actions.click", () => {
396
- this[datasourceLinkedElementSymbol]
397
- .write()
398
- .then(() => {
399
- this[originValuesSymbol] = null;
400
- this[originValuesSymbol] = clone(
401
- this[datasourceLinkedElementSymbol].data,
402
- );
403
- this[stateButtonElementSymbol].removeState();
404
- this[stateButtonElementSymbol].setOption("disabled", true);
405
- this.setOption("changes", 0);
406
- this.setOption(
407
- "classes.badge",
408
- new TokenList(this.getOption("classes.badge"))
409
- .add("hidden")
410
- .toString(),
411
- );
412
- })
413
- .catch((error) => {
414
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
415
- });
416
- });
417
- });
394
+ queueMicrotask(() => {
395
+ this[stateButtonElementSymbol].setOption("actions.click", () => {
396
+ this[datasourceLinkedElementSymbol]
397
+ .write()
398
+ .then(() => {
399
+ this[originValuesSymbol] = null;
400
+ this[originValuesSymbol] = clone(
401
+ this[datasourceLinkedElementSymbol].data,
402
+ );
403
+ this[stateButtonElementSymbol].removeState();
404
+ this[stateButtonElementSymbol].setOption("disabled", true);
405
+ this.setOption("changes", 0);
406
+ this.setOption(
407
+ "classes.badge",
408
+ new TokenList(this.getOption("classes.badge"))
409
+ .add("hidden")
410
+ .toString(),
411
+ );
412
+ })
413
+ .catch((error) => {
414
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
415
+ });
416
+ });
417
+ });
418
418
  }
419
419
 
420
420
  /**
@@ -422,10 +422,10 @@ function initEventHandler() {
422
422
  * @deprecated 2024-12-31
423
423
  */
424
424
  function updateOptionsFromArguments(options) {
425
- const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
426
- if (selector) {
427
- options.datasource.selector = selector;
428
- }
425
+ const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
426
+ if (selector) {
427
+ options.datasource.selector = selector;
428
+ }
429
429
  }
430
430
 
431
431
  /**
@@ -433,8 +433,8 @@ function updateOptionsFromArguments(options) {
433
433
  * @return {string}
434
434
  */
435
435
  function getTemplate() {
436
- // language=HTML
437
- return `
436
+ // language=HTML
437
+ return `
438
438
  <div data-monster-role="control" part="control"
439
439
  data-monster-attributes="disabled path:disabled | if:true">
440
440
  <monster-state-button data-monster-role="state-button"></monster-state-button>