@schukai/monster 4.46.8 → 4.47.1

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.47.1] - 2025-11-25
6
+
7
+ ### Bug Fixes
8
+
9
+ - rollback updater [#343](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/343)
10
+ - **select:** return if selection no array
11
+
12
+
13
+
14
+ ## [4.47.0] - 2025-11-25
15
+
16
+ ### Add Features
17
+
18
+ - add loglevel to save-button
19
+
20
+
21
+
5
22
  ## [4.46.8] - 2025-11-23
6
23
 
7
24
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.46.8"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.47.1"}
@@ -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,273 @@ 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 (
207
+ self.getOption("logLevel") === "debug" ||
208
+ location.search.includes("logLevel=debug")
209
+ ) {
210
+ console.groupCollapsed("SaveButton");
211
+ console.log(
212
+ "originValues",
213
+ JSON.parse(JSON.stringify(currentValues)),
214
+ );
215
+ console.log("result of diff", result);
216
+ console.log("ignoreChanges", ignoreChanges);
217
+
218
+ if (isArray(result) && result.length > 0) {
219
+ const formattedDiff = result.map((change) => ({
220
+ Operator: change?.operator,
221
+ Path: change?.path?.join("."),
222
+ "First Value": change?.first?.value,
223
+ "First Type": change?.first?.type,
224
+ "Second Value": change?.second?.value,
225
+ "Second Type": change?.second?.type,
226
+ }));
227
+
228
+ console.table(formattedDiff);
229
+ } else {
230
+ console.log("There are no changes to save");
231
+ }
232
+ console.groupEnd();
233
+ }
234
+
235
+ if (isArray(ignoreChanges) && ignoreChanges.length > 0) {
236
+ const itemsToRemove = [];
237
+ for (const item of result) {
238
+ for (const ignorePattern of ignoreChanges) {
239
+ const p = new RegExp(ignorePattern);
240
+
241
+ let matchPath = item.path;
242
+ if (isArray(item.path)) {
243
+ matchPath = item.path.join(".");
244
+ }
245
+
246
+ if (p.test(matchPath)) {
247
+ itemsToRemove.push(item);
248
+ break;
249
+ }
250
+ }
251
+ }
252
+
253
+ for (const itemToRemove of itemsToRemove) {
254
+ const index = result.indexOf(itemToRemove);
255
+ if (index > -1) {
256
+ result.splice(index, 1);
257
+ }
258
+ }
259
+ }
260
+
261
+ if (isArray(result) && result.length > 0) {
262
+ self[stateButtonElementSymbol].setState("changed");
263
+ self[stateButtonElementSymbol].setOption("disabled", false);
264
+ self.setOption("changes", result.length);
265
+ self.setOption(
266
+ "classes.badge",
267
+ new TokenList(self.getOption("classes.badge"))
268
+ .remove("hidden")
269
+ .toString(),
270
+ );
271
+ } else {
272
+ self[stateButtonElementSymbol].removeState();
273
+ self[stateButtonElementSymbol].setOption("disabled", true);
274
+ self.setOption("changes", 0);
275
+ self.setOption(
276
+ "classes.badge",
277
+ new TokenList(self.getOption("classes.badge"))
278
+ .add("hidden")
279
+ .toString(),
280
+ );
281
+ }
282
+ }),
283
+ );
284
+ }
285
+
286
+ this.attachObserver(
287
+ new Observer(() => {
288
+ handleDataSourceChanges.call(this);
289
+ }),
290
+ );
291
+ }
292
+
293
+ /**
294
+ *
295
+ * @return [CSSStyleSheet]
296
+ */
297
+ static getCSSStyleSheet() {
298
+ return [SaveButtonStyleSheet, BadgeStyleSheet];
299
+ }
297
300
  }
298
301
 
299
302
  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
- }
303
+ const locale = getLocaleOfDocument();
304
+ switch (locale.language) {
305
+ case "de":
306
+ return {
307
+ button: "Speichern",
308
+ };
309
+ case "fr":
310
+ return {
311
+ button: "Enregistrer",
312
+ };
313
+ case "sp":
314
+ return {
315
+ button: "Guardar",
316
+ };
317
+ case "it":
318
+ return {
319
+ button: "Salva",
320
+ };
321
+ case "pl":
322
+ return {
323
+ button: "Zapisz",
324
+ };
325
+ case "no":
326
+ return {
327
+ button: "Lagre",
328
+ };
329
+ case "dk":
330
+ return {
331
+ button: "Gem",
332
+ };
333
+ case "sw":
334
+ return {
335
+ button: "Spara",
336
+ };
337
+ default:
338
+ case "en":
339
+ return {
340
+ button: "Save",
341
+ };
342
+ }
340
343
  }
341
344
 
342
345
  /**
@@ -350,71 +353,71 @@ function getTranslations() {
350
353
  * @throws {Error} the selector must match exactly one element
351
354
  */
352
355
  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;
356
+ if (!this.shadowRoot) {
357
+ throw new Error("no shadow-root is defined");
358
+ }
359
+
360
+ this[stateButtonElementSymbol] = this.shadowRoot.querySelector(
361
+ "[data-monster-role=state-button]",
362
+ );
363
+
364
+ this[badgeElementSymbol] = this.shadowRoot.querySelector(
365
+ "[data-monster-role=badge]",
366
+ );
367
+
368
+ if (this[stateButtonElementSymbol]) {
369
+ queueMicrotask(() => {
370
+ const states = {
371
+ changed: new State(
372
+ "changed",
373
+ '<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">' +
374
+ '<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"/>' +
375
+ '<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"/>' +
376
+ "</svg>",
377
+ ),
378
+ };
379
+
380
+ this[stateButtonElementSymbol].removeState();
381
+ this[stateButtonElementSymbol].setOption("disabled", "disabled");
382
+ this[stateButtonElementSymbol].setOption("states", states);
383
+ this[stateButtonElementSymbol].setOption(
384
+ "labels.button",
385
+ this.getOption("labels.button"),
386
+ );
387
+ });
388
+ }
389
+
390
+ return this;
388
391
  }
389
392
 
390
393
  /**
391
394
  * @private
392
395
  */
393
396
  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
- });
397
+ queueMicrotask(() => {
398
+ this[stateButtonElementSymbol].setOption("actions.click", () => {
399
+ this[datasourceLinkedElementSymbol]
400
+ .write()
401
+ .then(() => {
402
+ this[originValuesSymbol] = null;
403
+ this[originValuesSymbol] = clone(
404
+ this[datasourceLinkedElementSymbol].data,
405
+ );
406
+ this[stateButtonElementSymbol].removeState();
407
+ this[stateButtonElementSymbol].setOption("disabled", true);
408
+ this.setOption("changes", 0);
409
+ this.setOption(
410
+ "classes.badge",
411
+ new TokenList(this.getOption("classes.badge"))
412
+ .add("hidden")
413
+ .toString(),
414
+ );
415
+ })
416
+ .catch((error) => {
417
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
418
+ });
419
+ });
420
+ });
418
421
  }
419
422
 
420
423
  /**
@@ -422,10 +425,10 @@ function initEventHandler() {
422
425
  * @deprecated 2024-12-31
423
426
  */
424
427
  function updateOptionsFromArguments(options) {
425
- const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
426
- if (selector) {
427
- options.datasource.selector = selector;
428
- }
428
+ const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
429
+ if (selector) {
430
+ options.datasource.selector = selector;
431
+ }
429
432
  }
430
433
 
431
434
  /**
@@ -433,8 +436,8 @@ function updateOptionsFromArguments(options) {
433
436
  * @return {string}
434
437
  */
435
438
  function getTemplate() {
436
- // language=HTML
437
- return `
439
+ // language=HTML
440
+ return `
438
441
  <div data-monster-role="control" part="control"
439
442
  data-monster-attributes="disabled path:disabled | if:true">
440
443
  <monster-state-button data-monster-role="state-button"></monster-state-button>
@@ -3056,11 +3056,8 @@ function setSelection(selection) {
3056
3056
  }
3057
3057
 
3058
3058
  if (!isArray(selection)) {
3059
- console.warn(
3060
- "selection is not an array, resetting to empty array",
3061
- selection,
3062
- );
3063
- selection = [];
3059
+ addErrorAttribute(this, "selection is not an array");
3060
+ return Promise.reject(new Error("selection is not an array"));
3064
3061
  }
3065
3062
 
3066
3063
  let resultSelection = [];
@@ -10,10 +10,10 @@
10
10
  * For more information about purchasing a commercial license, please contact schukai GmbH.
11
11
  */
12
12
 
13
- import { addAttributeToken } from "../../../dom/attributes.mjs";
14
- import { ATTRIBUTE_ERRORMESSAGE } from "../../../dom/constants.mjs";
13
+ import {addAttributeToken} from "../../../dom/attributes.mjs";
14
+ import {ATTRIBUTE_ERRORMESSAGE} from "../../../dom/constants.mjs";
15
15
 
16
- export { SelectStyleSheet };
16
+ export {SelectStyleSheet}
17
17
 
18
18
  /**
19
19
  * @private
@@ -22,17 +22,10 @@ export { SelectStyleSheet };
22
22
  const SelectStyleSheet = new CSSStyleSheet();
23
23
 
24
24
  try {
25
- SelectStyleSheet.insertRule(
26
- `
25
+ SelectStyleSheet.insertRule(`
27
26
  @layer select {
28
27
  .block{display:block}.inline{display:inline}.inline-block{display:inline-block}.grid{display:grid}.inline-grid{display:inline-grid}.flex{display:flex}.inline-flex{display:inline-flex}.hidden,.hide,.none{display:none}.visible{visibility:visible}.invisible{visibility:hidden}.monster-border-primary-1,.monster-border-primary-2,.monster-border-primary-3,.monster-border-primary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-0{border-radius:0;border-style:none;border-width:0}.monster-border-primary-1{border-color:var(--monster-bg-color-primary-1)}.monster-border-primary-2{border-color:var(--monster-bg-color-primary-2)}.monster-border-primary-3{border-color:var(--monster-bg-color-primary-3)}.monster-border-primary-4{border-color:var(--monster-bg-color-primary-4)}.monster-border-secondary-1,.monster-border-secondary-2,.monster-border-secondary-3,.monster-border-secondary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-secondary-1{border-color:var(--monster-bg-color-secondary-1)}.monster-border-secondary-2{border-color:var(--monster-bg-color-secondary-2)}.monster-border-secondary-3{border-color:var(--monster-bg-color-secondary-3)}.monster-border-secondary-4{border-color:var(--monster-bg-color-secondary-4)}.monster-border-tertiary-1,.monster-border-tertiary-2,.monster-border-tertiary-3,.monster-border-tertiary-4{border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width)}.monster-border-tertiary-1{border-color:var(--monster-bg-color-tertiary-1)}.monster-border-tertiary-2{border-color:var(--monster-bg-color-tertiary-2)}.monster-border-tertiary-3{border-color:var(--monster-bg-color-tertiary-3)}.monster-border-tertiary-4{border-color:var(--monster-bg-color-tertiary-4)}[data-monster-role=control]{width:100%}[data-monster-role=control].flex{align-items:center;display:flex;flex-direction:row}:host{box-sizing:border-box;display:block}.monster-badge-primary{padding:.25em .4em}.monster-badge-primary,.monster-badge-primary-pill{background-color:var(--monster-bg-color-primary-4);border-radius:.25rem;color:var(--monster-color-primary-4);display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;text-decoration:none;vertical-align:baseline;white-space:nowrap}.monster-badge-primary-pill{border-radius:10rem;padding:.25em .6em}.monster-badge-secondary{padding:.25em .4em}.monster-badge-secondary,.monster-badge-secondary-pill{background-color:var(--monster-bg-color-secondary-3);border-radius:.25rem;color:var(--monster-color-secondary-3);display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;text-decoration:none;vertical-align:baseline;white-space:nowrap}.monster-badge-secondary-pill{border-radius:10rem;padding:.25em .6em}.monster-badge-tertiary{padding:.25em .4em}.monster-badge-tertiary,.monster-badge-tertiary-pill{background-color:var(--monster-bg-color-tertiary-3);border-radius:.25rem;color:var(--monster-color-tertiary-3);display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;text-decoration:none;vertical-align:baseline;white-space:nowrap}.monster-badge-tertiary-pill{border-radius:10rem;padding:.25em .6em}.monster-badge-destructive{padding:.25em .4em}.monster-badge-destructive,.monster-badge-destructive-pill{background-color:var(--monster-bg-color-destructive-1);border-radius:.25rem;color:var(--monster-color-destructive-1);display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;text-decoration:none;vertical-align:baseline;white-space:nowrap}.monster-badge-destructive-pill{border-radius:10rem;padding:.25em .6em}.monster-badge-success{padding:.25em .4em}.monster-badge-success,.monster-badge-success-pill{background-color:var(--monster-bg-color-success-1);border-radius:.25rem;color:var(--monster-color-success-1);display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;text-decoration:none;vertical-align:baseline;white-space:nowrap}.monster-badge-success-pill{border-radius:10rem;padding:.25em .6em}.monster-badge-warning{padding:.25em .4em}.monster-badge-warning,.monster-badge-warning-pill{background-color:var(--monster-bg-color-warning-1);border-radius:.25rem;color:var(--monster-color-warning-1);display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;text-decoration:none;vertical-align:baseline;white-space:nowrap}.monster-badge-warning-pill{border-radius:10rem;padding:.25em .6em}.monster-badge-error{padding:.25em .4em}.monster-badge-error,.monster-badge-error-pill{background-color:var(--monster-bg-color-error-1);border-radius:.25rem;color:var(--monster-color-error-1);display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;text-decoration:none;vertical-align:baseline;white-space:nowrap}.monster-badge-error-pill{border-radius:10rem;padding:.25em .6em}.monster-margin-0{margin:var(--monster-space-0)}.monster-margin-top-0{margin-top:var(--monster-space-0)}.monster-margin-end-0{margin-right:var(--monster-space-0)}.monster-margin-bottom-0{margin-bottom:var(--monster-space-0)}.monster-margin-start-0{margin-left:var(--monster-space-0)}.monster-padding-0{padding:var(--monster-space-0)}.monster-padding-top-0{padding-top:var(--monster-space-0)}.monster-padding-end-0{padding-right:var(--monster-space-0)}.monster-padding-bottom-0{padding-bottom:var(--monster-space-0)}.monster-padding-start-0{padding-left:var(--monster-space-0)}.monster-margin-1{margin:var(--monster-space-1)}.monster-margin-top-1{margin-top:var(--monster-space-1)}.monster-margin-end-1{margin-right:var(--monster-space-1)}.monster-margin-bottom-1{margin-bottom:var(--monster-space-1)}.monster-margin-start-1{margin-left:var(--monster-space-1)}.monster-padding-1{padding:var(--monster-space-1)}.monster-padding-top-1{padding-top:var(--monster-space-1)}.monster-padding-end-1{padding-right:var(--monster-space-1)}.monster-padding-bottom-1{padding-bottom:var(--monster-space-1)}.monster-padding-start-1{padding-left:var(--monster-space-1)}.monster-margin-2{margin:var(--monster-space-2)}.monster-margin-top-2{margin-top:var(--monster-space-2)}.monster-margin-end-2{margin-right:var(--monster-space-2)}.monster-margin-bottom-2{margin-bottom:var(--monster-space-2)}.monster-margin-start-2{margin-left:var(--monster-space-2)}.monster-padding-2{padding:var(--monster-space-2)}.monster-padding-top-2{padding-top:var(--monster-space-2)}.monster-padding-end-2{padding-right:var(--monster-space-2)}.monster-padding-bottom-2{padding-bottom:var(--monster-space-2)}.monster-padding-start-2{padding-left:var(--monster-space-2)}.monster-margin-3{margin:var(--monster-space-3)}.monster-margin-top-3{margin-top:var(--monster-space-3)}.monster-margin-end-3{margin-right:var(--monster-space-3)}.monster-margin-bottom-3{margin-bottom:var(--monster-space-3)}.monster-margin-start-3{margin-left:var(--monster-space-3)}.monster-padding-3{padding:var(--monster-space-3)}.monster-padding-top-3{padding-top:var(--monster-space-3)}.monster-padding-end-3{padding-right:var(--monster-space-3)}.monster-padding-bottom-3{padding-bottom:var(--monster-space-3)}.monster-padding-start-3{padding-left:var(--monster-space-3)}.monster-margin-4{margin:var(--monster-space-4)}.monster-margin-top-4{margin-top:var(--monster-space-4)}.monster-margin-end-4{margin-right:var(--monster-space-4)}.monster-margin-bottom-4{margin-bottom:var(--monster-space-4)}.monster-margin-start-4{margin-left:var(--monster-space-4)}.monster-padding-4{padding:var(--monster-space-4)}.monster-padding-top-4{padding-top:var(--monster-space-4)}.monster-padding-end-4{padding-right:var(--monster-space-4)}.monster-padding-bottom-4{padding-bottom:var(--monster-space-4)}.monster-padding-start-4{padding-left:var(--monster-space-4)}.monster-margin-5{margin:var(--monster-space-5)}.monster-margin-top-5{margin-top:var(--monster-space-5)}.monster-margin-end-5{margin-right:var(--monster-space-5)}.monster-margin-bottom-5{margin-bottom:var(--monster-space-5)}.monster-margin-start-5{margin-left:var(--monster-space-5)}.monster-padding-5{padding:var(--monster-space-5)}.monster-padding-top-5{padding-top:var(--monster-space-5)}.monster-padding-end-5{padding-right:var(--monster-space-5)}.monster-padding-bottom-5{padding-bottom:var(--monster-space-5)}.monster-padding-start-5{padding-left:var(--monster-space-5)}.monster-margin-6{margin:var(--monster-space-6)}.monster-margin-top-6{margin-top:var(--monster-space-6)}.monster-margin-end-6{margin-right:var(--monster-space-6)}.monster-margin-bottom-6{margin-bottom:var(--monster-space-6)}.monster-margin-start-6{margin-left:var(--monster-space-6)}.monster-padding-6{padding:var(--monster-space-6)}.monster-padding-top-6{padding-top:var(--monster-space-6)}.monster-padding-end-6{padding-right:var(--monster-space-6)}.monster-padding-bottom-6{padding-bottom:var(--monster-space-6)}.monster-padding-start-6{padding-left:var(--monster-space-6)}.monster-margin-7{margin:var(--monster-space-7)}.monster-margin-top-7{margin-top:var(--monster-space-7)}.monster-margin-end-7{margin-right:var(--monster-space-7)}.monster-margin-bottom-7{margin-bottom:var(--monster-space-7)}.monster-margin-start-7{margin-left:var(--monster-space-7)}.monster-padding-7{padding:var(--monster-space-7)}.monster-padding-top-7{padding-top:var(--monster-space-7)}.monster-padding-end-7{padding-right:var(--monster-space-7)}.monster-padding-bottom-7{padding-bottom:var(--monster-space-7)}.monster-padding-start-7{padding-left:var(--monster-space-7)}div[data-monster-role=popper]{align-content:center;background:var(--monster-bg-color-primary-1);border-color:var(--monster-bg-color-primary-4);border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width);box-shadow:var(--monster-box-shadow-1);box-sizing:border-box;color:var(--monster-color-primary-1);display:none;justify-content:space-between;left:0;padding:1.1em;position:absolute;top:0;width:-moz-max-content;width:max-content;z-index:var(--monster-z-index-modal)}div[data-monster-role=popper] div[data-monster-role=arrow]{background:var(--monster-bg-color-primary-1);height:calc(max(var(--monster-popper-witharrrow-distance), -1 * var(--monster-popper-witharrrow-distance))*2);pointer-events:none;position:absolute;width:calc(max(var(--monster-popper-witharrrow-distance), -1 * var(--monster-popper-witharrrow-distance))*2);z-index:-1}[data-monster-role=container]{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:4 0 90%;min-height:1.4em;overflow:auto;scrollbar-color:var(--monster-color-primary-1) var(--monster-bg-color-primary-1);scrollbar-width:thin;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;width:100%}.d-none{display:none!important}div[data-monster-role=no-options] span,div[data-monster-role=remote-info] span{text-wrap:balance}div[data-monster-role=control]{display:flex;height:100%;position:relative}[data-monster-role=container].open{-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708z'/%3E%3C/svg%3E\")}[data-monster-role=container].clear,[data-monster-role=container].open{background-color:var(--monster-bg-color-primary-2);-webkit-mask-position:center center;mask-position:center center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:.8em;mask-size:.8em}[data-monster-role=container].clear{-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\")}[data-monster-role=control]{accent-color:var(--monster-color-secondary-2);background-color:var(--monster-bg-color-primary-1);border-color:var(--monster-theme-control-border-color);-o-border-image:initial;border-image:initial;border-radius:var(--monster-theme-control-border-radius);border-style:var(--monster-theme-control-border-style);border-width:var(--monster-theme-control-border-width);box-sizing:border-box;color:var(--monster-color-primary-1);display:flex;font-family:inherit;font-size:100%;margin:0;outline:none;padding:.4rem .6rem;width:-webkit-fill-available;width:-moz-available;width:fill-available}@media (prefers-color-scheme:light){[data-monster-role=control]{background-color:var(--monster-bg-color-primary-1);border-color:var(--monster-bg-color-primary-3);color:var(--monster-color-primary-1)}[data-monster-role=control]:focus{outline:1px dashed var(--monster-color-selection-4);outline-offset:2px}}[data-monster-role=control]:hover{box-shadow:var(--monster-box-shadow-2);transition:background .8s,color .25s .0833333333s}div[data-monster-role=selection]{align-items:center;display:flex;flex-direction:row;flex-wrap:wrap;gap:5px;justify-content:flex-start;margin:5px}[data-monster-role=option-control]{margin-right:8px}[data-monster-role=badge]{display:inline-flex}[data-monster-role=badge-label]{align-content:center;align-items:center;display:flex;flex-direction:row;gap:7px;justify-content:space-between}[data-monster-role=filter],[data-monster-role=popper-filter]{display:flex;flex-grow:200;order:99999999;visibility:hidden}[data-monster-role=filter].active{background-color:var(--monster-bg-color-primary-2);border:0;border-color:var(--monster-bg-color-primary-3);border-bottom:1px solid var(--monster-bg-color-primary-3);color:var(--monster-color-primary-2);min-width:40%;outline:none;visibility:visible}.active[data-monster-role=filter][name=popper-filter]{height:1.5em;margin:2.5em;padding:2px;width:calc(100% - var(--monster-border-width)*2)}.option-filter-control{align-items:center;background-color:var(--monster-bg-color-primary-2);display:flex;height:2.5em;margin:-1.1em -1.1em .3em}[data-monster-role=remove-badge]{background-color:var(--monster-bg-color-primary-2);height:16px;margin-left:5px;-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\");order:2}[data-monster-role=remove-badge],[data-monster-role=status-or-remove-badges]{-webkit-mask-position:center center;mask-position:center center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:.8em;mask-size:.8em;min-height:16px;width:16px}[data-monster-role=status-or-remove-badges]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--monster-bg-color-primary-4);-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\")}.open[data-monster-role=status-or-remove-badges]{background-color:var(--monster-bg-color-primary-4);-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708z'/%3E%3C/svg%3E\")}.empty[data-monster-role=status-or-remove-badges]{background-color:var(--monster-bg-color-primary-4);-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-dash-circle' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16'/%3E%3Cpath d='M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-dash-circle' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16'/%3E%3Cpath d='M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8'/%3E%3C/svg%3E\")}.clear[data-monster-role=status-or-remove-badges]{background-color:var(--monster-bg-color-primary-4);-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E\")}.error[data-monster-role=status-or-remove-badges]{background-color:var(--monster-bg-color-error-1);-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z'/%3E%3C/svg%3E\")}@media (prefers-color-scheme:dark){.error[data-monster-role=status-or-remove-badges]{background-color:var(--monster-color-error-4);-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0M7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0z'/%3E%3C/svg%3E\")}}.loading[data-monster-role=status-or-remove-badges]{animation-duration:1s;animation-iteration-count:infinite;animation-name:activity;animation-timing-function:cubic-bezier(0,0,.2,1);background-color:var(--monster-bg-color-primary-4);-webkit-mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='activity' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8'/%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='activity' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8'/%3E%3C/svg%3E\")}@keyframes activity{0%{transform:scale(1)}50%{transform:scale(.1)}to{transform:scale(1)}}[data-monster-role=options]{box-sizing:border-box;display:flex;flex-direction:column;flex-grow:1;scrollbar-color:var(--monster-color-primary-1) var(--monster-bg-color-primary-1);scrollbar-width:thin;transition:height .3s ease}[data-monster-role=option]{align-items:center;box-sizing:border-box;display:flex;padding:6px 5px}[data-monster-role=option] label{align-items:center;display:flex;flex-direction:row;justify-content:flex-start;width:100%}[data-monster-role=option] label>div{align-items:center;display:flex;flex-direction:row;justify-content:space-between;outline:none;width:100%}.selected{background-color:var(--monster-bg-color-primary-2);color:var(--monster-color-primary-2)}[data-monster-role=option][data-monster-filtered=true],[data-monster-role=option][data-monster-visibility=hidden]{display:none}[data-monster-role=option][data-monster-focused=true]{outline:1px dashed var(--monster-color-selection-2);outline-offset:-2px}@media (prefers-color-scheme:dark){[data-monster-role=option][data-monster-focused=true]{outline:1px dashed var(--monster-color-selection-4)}}[data-monster-role=filter]::-moz-placeholder{background-color:var(--monster-bg-color-primary-2);color:var(--monster-color-primary-2)}[data-monster-role=filter]::placeholder{background-color:var(--monster-bg-color-primary-2);color:var(--monster-color-primary-2)}[data-monster-role=option]>input:focus,[data-monster-role=option]>label:focus{outline:none}[data-monster-role=selection-messages]:empty:before,[data-monster-role=summary-messages]:empty:before{content:\"\u00A0\"}.in-button-bar{border-color:var(--monster-bg-color-primary-4)!important;border-style:var(--monster-border-style)!important;border-width:var(--monster-border-width)!important}[data-monster-role=pagination]::part(nav){justify-content:flex-start}[data-monster-role=pagination]::part(list){margin-bottom:0;margin-top:0}
29
- }`,
30
- 0,
31
- );
28
+ }`, 0);
32
29
  } catch (e) {
33
- addAttributeToken(
34
- document.getRootNode().querySelector("html"),
35
- ATTRIBUTE_ERRORMESSAGE,
36
- e + "",
37
- );
30
+ addAttributeToken(document.getRootNode().querySelector('html'), ATTRIBUTE_ERRORMESSAGE, e + "");
38
31
  }
@@ -72,24 +72,6 @@ const pendingDiffsSymbol = Symbol("pendingDiffs");
72
72
  */
73
73
  const processingSymbol = Symbol("processing");
74
74
 
75
- /**
76
- * @private
77
- * @type {symbol}
78
- */
79
- const pipeCacheSymbol = Symbol("pipeCache");
80
-
81
- /**
82
- * @private
83
- * @type {symbol}
84
- */
85
- const processingScheduledSymbol = Symbol("processingScheduled");
86
-
87
- /**
88
- * @private
89
- * Performance optimization: static Set for boolean checks
90
- */
91
- const TRUE_VALUES = new Set(["true", "1", "on"]);
92
-
93
75
  /**
94
76
  * The updater class connects an object with the DOM. In this way, structures and contents in the DOM can be
95
77
  * programmatically adapted via attributes.
@@ -149,9 +131,6 @@ class Updater extends Base {
149
131
 
150
132
  this[pendingDiffsSymbol] = [];
151
133
  this[processingSymbol] = false;
152
- this[processingScheduledSymbol] = false;
153
- this[pipeCacheSymbol] = new Map();
154
- this[timerElementEventHandlerSymbol] = new WeakMap();
155
134
 
156
135
  this[internalSymbol].subject.attachObserver(
157
136
  new Observer(() => {
@@ -159,19 +138,7 @@ class Updater extends Base {
159
138
  const diffResult = diff(this[internalSymbol].last, real);
160
139
  this[internalSymbol].last = clone(real);
161
140
  this[pendingDiffsSymbol].push(diffResult);
162
-
163
- if (!this[processingScheduledSymbol]) {
164
- this[processingScheduledSymbol] = true;
165
-
166
- return new Promise((resolve) => {
167
- queueMicrotask(() => {
168
- this[processingScheduledSymbol] = false;
169
- this.#processQueue().finally(resolve);
170
- });
171
- });
172
- }
173
-
174
- return Promise.resolve();
141
+ return this.#processQueue();
175
142
  }),
176
143
  );
177
144
  }
@@ -227,7 +194,7 @@ class Updater extends Base {
227
194
  *
228
195
  * ```js
229
196
  * updater.run().then(() => {
230
- * updater.enableEventProcessing();
197
+ * updater.enableEventProcessing();
231
198
  * });
232
199
  * ```
233
200
  *
@@ -276,7 +243,7 @@ class Updater extends Base {
276
243
  *
277
244
  * ```js
278
245
  * updater.run().then(() => {
279
- * updater.enableEventProcessing();
246
+ * updater.enableEventProcessing();
280
247
  * });
281
248
  * ```
282
249
  *
@@ -328,20 +295,6 @@ class Updater extends Base {
328
295
  this[internalSymbol].callbacks.set(name, callback);
329
296
  return this;
330
297
  }
331
-
332
- /**
333
- * @private
334
- * @param {string} cmd
335
- * @returns {Pipe}
336
- */
337
- getPipe(cmd) {
338
- let pipe = this[pipeCacheSymbol].get(cmd);
339
- if (!pipe) {
340
- pipe = new Pipe(cmd);
341
- this[pipeCacheSymbol].set(cmd, pipe);
342
- }
343
- return pipe;
344
- }
345
298
  }
346
299
 
347
300
  /**
@@ -355,9 +308,8 @@ function getCheckStateCallback() {
355
308
  return function (current) {
356
309
  // this is a reference to the current object (therefore no array function here)
357
310
  if (this instanceof HTMLInputElement) {
358
- if (["radio", "checkbox"].includes(this.type)) {
359
- if (current == null) return undefined;
360
- return String(this.value) === String(current) ? "true" : undefined;
311
+ if (["radio", "checkbox"].indexOf(this.type) !== -1) {
312
+ return `${this.value}` === `${current}` ? "true" : undefined;
361
313
  }
362
314
  } else if (this instanceof HTMLOptionElement) {
363
315
  if (isArray(current) && current.indexOf(this.value) !== -1) {
@@ -397,26 +349,22 @@ function getControlEventHandler() {
397
349
  return;
398
350
  }
399
351
 
400
- const switches = this[timerElementEventHandlerSymbol];
401
- let dms = switches.get(element);
402
-
403
- if (dms instanceof DeadMansSwitch) {
352
+ if (this[timerElementEventHandlerSymbol] instanceof DeadMansSwitch) {
404
353
  try {
405
- dms.touch();
354
+ this[timerElementEventHandlerSymbol].touch();
406
355
  return;
407
356
  } catch (e) {
408
- switches.delete(element);
357
+ delete this[timerElementEventHandlerSymbol];
409
358
  }
410
359
  }
411
360
 
412
- dms = new DeadMansSwitch(50, () => {
361
+ this[timerElementEventHandlerSymbol] = new DeadMansSwitch(50, () => {
413
362
  try {
414
363
  retrieveAndSetValue.call(this, element);
415
364
  } catch (e) {
416
365
  addErrorAttribute(element, e);
417
366
  }
418
367
  });
419
- switches.set(element, dms);
420
368
  };
421
369
 
422
370
  return this[symbol];
@@ -499,21 +447,18 @@ function retrieveAndSetValue(element) {
499
447
  case "int":
500
448
  case "float":
501
449
  case "integer":
502
- const num = Number(value);
503
- if (value === "" || value === null || value === undefined) {
504
- value = undefined;
505
- } else if (Number.isNaN(num)) {
506
- value = undefined;
507
- } else {
508
- value = num;
450
+ value = Number(value);
451
+ if (isNaN(value)) {
452
+ value = 0;
509
453
  }
510
454
  break;
511
455
  case "boolean":
512
456
  case "bool":
513
457
  case "checkbox":
514
- // Use static set (Performance fix)
515
- value = TRUE_VALUES.has(String(value).toLowerCase()) || value === true;
458
+ value =
459
+ value === "true" || value === "1" || value === "on" || value === true;
516
460
  break;
461
+
517
462
  case "string[]":
518
463
  case "[]string":
519
464
  if (isString(value)) {
@@ -564,14 +509,11 @@ function retrieveAndSetValue(element) {
564
509
  case "object":
565
510
  case "json":
566
511
  if (isString(value)) {
567
- try {
568
- value = JSON.parse(value);
569
- } catch (e) {
570
- throw new Error("unsupported value for object");
571
- }
512
+ value = JSON.parse(value);
572
513
  } else {
573
514
  throw new Error("unsupported value for object");
574
515
  }
516
+
575
517
  break;
576
518
  default:
577
519
  break;
@@ -593,11 +535,21 @@ function retrieveAndSetValue(element) {
593
535
  * @private
594
536
  */
595
537
  function parseIntArray(val) {
596
- if (val === undefined || val === null) return [];
597
-
598
- const list = isArray(val) ? val : String(val).split(",");
599
-
600
- return list.map((v) => parseInt(v, 10)).filter((v) => !Number.isNaN(v));
538
+ if (isString(val)) {
539
+ return val.trim() === ""
540
+ ? []
541
+ : val
542
+ .split(",")
543
+ .map((v) => parseInt(v, 10))
544
+ .filter((v) => !isNaN(v));
545
+ } else if (isInteger(val)) {
546
+ return [val];
547
+ } else if (val === undefined || val === null) {
548
+ return [];
549
+ } else if (isArray(val)) {
550
+ return val.map((v) => parseInt(v, 10)).filter((v) => !isNaN(v));
551
+ }
552
+ throw new Error("unsupported value for int array");
601
553
  }
602
554
 
603
555
  /**
@@ -698,7 +650,7 @@ function insertElement(change) {
698
650
  throw new Error("pipes are not allowed when cloning a node.");
699
651
  }
700
652
 
701
- const pipe = this.getPipe(cmd);
653
+ const pipe = new Pipe(cmd);
702
654
  this[internalSymbol].callbacks.forEach((f, n) => {
703
655
  pipe.setCallback(n, f);
704
656
  });
@@ -878,18 +830,25 @@ function runUpdateContent(container, parts, subject) {
878
830
 
879
831
  // Unfortunately, static data is always changed as well, since it is not possible to react to changes here.
880
832
  const query = `[${ATTRIBUTE_UPDATER_REPLACE}^="path:${current}"], [${ATTRIBUTE_UPDATER_REPLACE}^="static:"], [${ATTRIBUTE_UPDATER_REPLACE}^="i18n:"]`;
833
+ const e = container.querySelectorAll(`${query}`);
881
834
 
882
- // Performance optimization: avoid new Set([...NodeList])
883
- const elements = container.querySelectorAll(`${query}`);
835
+ const iterator = new Set([...e]);
884
836
 
885
- const process = (element) => {
837
+ if (container.matches(query)) {
838
+ iterator.add(container);
839
+ }
840
+
841
+ /**
842
+ * @type {HTMLElement}
843
+ */
844
+ for (const [element] of iterator.entries()) {
886
845
  if (mem.has(element)) return;
887
846
  mem.add(element);
888
847
 
889
848
  const attributes = element.getAttribute(ATTRIBUTE_UPDATER_REPLACE);
890
849
  const cmd = trimSpaces(attributes);
891
850
 
892
- const pipe = this.getPipe(cmd);
851
+ const pipe = new Pipe(cmd);
893
852
  this[internalSymbol].callbacks.forEach((f, n) => {
894
853
  pipe.setCallback(n, f);
895
854
  });
@@ -915,16 +874,6 @@ function runUpdateContent(container, parts, subject) {
915
874
  } else {
916
875
  element.innerHTML = value;
917
876
  }
918
- };
919
-
920
- // Iterate NodeList directly
921
- for (const element of elements) {
922
- process(element);
923
- }
924
-
925
- // Check container
926
- if (container.matches(query)) {
927
- process(container);
928
877
  }
929
878
  }
930
879
  }
@@ -959,18 +908,27 @@ function runUpdateAttributes(container, parts, subject) {
959
908
  const current = parts.join(".");
960
909
  parts.pop();
961
910
 
911
+ let iterator = new Set();
912
+
962
913
  const query = `[${ATTRIBUTE_UPDATER_SELECT_THIS}][${ATTRIBUTE_UPDATER_ATTRIBUTES}], [${ATTRIBUTE_UPDATER_ATTRIBUTES}*="path:${current}"], [${ATTRIBUTE_UPDATER_ATTRIBUTES}^="static:"], [${ATTRIBUTE_UPDATER_ATTRIBUTES}^="i18n:"]`;
963
914
 
964
- // Performance optimization: avoid new Set([...NodeList])
965
- const elements = container.querySelectorAll(query);
915
+ const e = container.querySelectorAll(query);
916
+
917
+ if (e.length > 0) {
918
+ iterator = new Set([...e]);
919
+ }
966
920
 
967
- const process = (element) => {
921
+ if (container.matches(query)) {
922
+ iterator.add(container);
923
+ }
924
+
925
+ for (const [element] of iterator.entries()) {
968
926
  if (mem.has(element)) return;
969
927
  mem.add(element);
970
928
 
971
929
  // this case occurs when the ATTRIBUTE_UPDATER_SELECT_THIS attribute is set
972
930
  if (!element.hasAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES)) {
973
- return;
931
+ continue;
974
932
  }
975
933
 
976
934
  const attributes = element.getAttribute(ATTRIBUTE_UPDATER_ATTRIBUTES);
@@ -981,7 +939,7 @@ function runUpdateAttributes(container, parts, subject) {
981
939
  const name = trimSpaces(def.substr(0, i));
982
940
  const cmd = trimSpaces(def.substr(i));
983
941
 
984
- const pipe = this.getPipe(cmd);
942
+ const pipe = new Pipe(cmd);
985
943
 
986
944
  this[internalSymbol].callbacks.forEach((f, n) => {
987
945
  pipe.setCallback(n, f, element);
@@ -995,30 +953,14 @@ function runUpdateAttributes(container, parts, subject) {
995
953
  addErrorAttribute(element, e);
996
954
  }
997
955
 
998
- const shouldRemove =
999
- value === undefined || value === null || Number.isNaN(value);
1000
-
1001
- if (shouldRemove) {
956
+ if (value === undefined) {
1002
957
  element.removeAttribute(name);
1003
- } else {
1004
- const strValue = String(value);
1005
-
1006
- if (element.getAttribute(name) !== strValue) {
1007
- element.setAttribute(name, strValue);
1008
- }
958
+ } else if (element.getAttribute(name) !== value) {
959
+ element.setAttribute(name, value);
1009
960
  }
961
+
1010
962
  handleInputControlAttributeUpdate.call(this, element, name, value);
1011
963
  }
1012
- };
1013
-
1014
- // Iterate NodeList directly
1015
- for (const element of elements) {
1016
- process(element);
1017
- }
1018
-
1019
- // Check container
1020
- if (container.matches(query)) {
1021
- process(container);
1022
964
  }
1023
965
  }
1024
966
  }
@@ -1031,59 +973,52 @@ function runUpdateAttributes(container, parts, subject) {
1031
973
  * @return {void}
1032
974
  * @this Updater
1033
975
  */
1034
- function handleInputControlAttributeUpdate(element, name, value) {
1035
- // Prevent NaN warnings by normalizing invalid numbers to undefined
1036
- if (typeof value === "number" && isNaN(value)) {
1037
- value = undefined;
1038
- }
1039
976
 
977
+ function handleInputControlAttributeUpdate(element, name, value) {
1040
978
  if (element instanceof HTMLSelectElement) {
1041
979
  switch (element.type) {
1042
980
  case "select-multiple":
1043
- // Ensure value is an array before calling indexOf to avoid errors
1044
- if (Array.isArray(value) || typeof value === "string") {
1045
- for (const [index, opt] of Object.entries(element.options)) {
1046
- opt.selected = value.indexOf(opt.value) !== -1;
1047
- }
981
+ for (const [index, opt] of Object.entries(element.options)) {
982
+ opt.selected = value.indexOf(opt.value) !== -1;
1048
983
  }
984
+
1049
985
  break;
1050
986
  case "select-one":
1051
987
  // Only one value may be selected
988
+
1052
989
  for (const [index, opt] of Object.entries(element.options)) {
1053
- if (opt.value == value) {
1054
- // Loose equality to match string numbers
990
+ if (opt.value === value) {
1055
991
  element.selectedIndex = index;
1056
992
  break;
1057
993
  }
1058
994
  }
995
+
1059
996
  break;
1060
997
  }
1061
998
  } else if (element instanceof HTMLInputElement) {
1062
999
  switch (element.type) {
1063
1000
  case "radio":
1064
1001
  if (name === "checked") {
1065
- element.checked = value !== undefined && value !== null;
1002
+ element.checked = value !== undefined;
1066
1003
  }
1067
1004
  break;
1068
1005
 
1069
1006
  case "checkbox":
1070
1007
  if (name === "checked") {
1071
- element.checked = value !== undefined && value !== null;
1008
+ element.checked = value !== undefined;
1072
1009
  }
1073
1010
  break;
1074
1011
 
1075
1012
  case "text":
1076
1013
  default:
1077
1014
  if (name === "value") {
1078
- // Check for undefined, null, or NaN
1079
- element.value = value === undefined || value === null ? "" : value;
1015
+ element.value = value === undefined ? "" : value;
1080
1016
  }
1081
1017
  break;
1082
1018
  }
1083
1019
  } else if (element instanceof HTMLTextAreaElement) {
1084
1020
  if (name === "value") {
1085
- // Check for undefined, null, or NaN
1086
- element.value = value === undefined || value === null ? "" : value;
1021
+ element.value = value === undefined ? "" : value;
1087
1022
  }
1088
1023
  }
1089
1024
  }