@schukai/monster 3.55.0 → 3.55.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/source/components/datatable/datasource/rest.mjs +313 -326
  4. package/source/components/datatable/datatable/header.mjs +1 -1
  5. package/source/components/datatable/datatable.mjs +586 -591
  6. package/source/components/datatable/embedded-pagination.mjs +42 -49
  7. package/source/components/datatable/filter/util.mjs +115 -99
  8. package/source/components/datatable/filter.mjs +901 -842
  9. package/source/components/datatable/pagination.mjs +333 -334
  10. package/source/components/datatable/status.mjs +134 -156
  11. package/source/components/datatable/stylesheet/column-bar.mjs +14 -8
  12. package/source/components/datatable/stylesheet/dataset.mjs +14 -8
  13. package/source/components/datatable/stylesheet/datasource.mjs +14 -8
  14. package/source/components/datatable/stylesheet/datatable.mjs +14 -8
  15. package/source/components/datatable/stylesheet/embedded-pagination.mjs +14 -8
  16. package/source/components/datatable/stylesheet/filter-button.mjs +14 -8
  17. package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +14 -8
  18. package/source/components/datatable/stylesheet/filter-date-range.mjs +14 -8
  19. package/source/components/datatable/stylesheet/filter-range.mjs +14 -8
  20. package/source/components/datatable/stylesheet/filter.mjs +14 -8
  21. package/source/components/datatable/stylesheet/pagination.mjs +14 -8
  22. package/source/components/datatable/stylesheet/select-filter.mjs +14 -8
  23. package/source/components/datatable/stylesheet/status.mjs +14 -8
  24. package/source/components/form/action-button.mjs +3 -1
  25. package/source/components/form/confirm-button.mjs +3 -1
  26. package/source/components/form/context-error.mjs +161 -164
  27. package/source/components/form/context-help.mjs +3 -1
  28. package/source/components/form/form.mjs +3 -1
  29. package/source/components/form/message-state-button.mjs +3 -1
  30. package/source/components/form/popper-button.mjs +6 -4
  31. package/source/components/form/popper.mjs +310 -310
  32. package/source/components/form/select.mjs +2 -2
  33. package/source/components/form/state-button.mjs +3 -1
  34. package/source/components/form/stylesheet/action-button.mjs +14 -8
  35. package/source/components/form/stylesheet/api-button.mjs +14 -8
  36. package/source/components/form/stylesheet/button-bar.mjs +14 -8
  37. package/source/components/form/stylesheet/button.mjs +14 -8
  38. package/source/components/form/stylesheet/confirm-button.mjs +14 -8
  39. package/source/components/form/stylesheet/context-error.mjs +14 -8
  40. package/source/components/form/stylesheet/context-help.mjs +14 -8
  41. package/source/components/form/stylesheet/form.mjs +14 -8
  42. package/source/components/form/stylesheet/message-state-button.mjs +14 -8
  43. package/source/components/form/stylesheet/popper-button.mjs +14 -8
  44. package/source/components/form/stylesheet/popper.mjs +14 -8
  45. package/source/components/form/stylesheet/select.mjs +14 -8
  46. package/source/components/form/stylesheet/state-button.mjs +14 -8
  47. package/source/components/form/stylesheet/tabs.mjs +14 -8
  48. package/source/components/form/stylesheet/tree-select.mjs +14 -8
  49. package/source/components/form/tabs.mjs +754 -758
  50. package/source/components/host/collapse.mjs +2 -4
  51. package/source/components/host/config-manager.mjs +11 -9
  52. package/source/components/host/stylesheet/call-button.mjs +14 -8
  53. package/source/components/host/stylesheet/collapse.mjs +14 -8
  54. package/source/components/host/stylesheet/config-manager.mjs +14 -8
  55. package/source/components/host/stylesheet/details.mjs +14 -8
  56. package/source/components/host/stylesheet/host.mjs +14 -8
  57. package/source/components/host/stylesheet/overlay.mjs +14 -8
  58. package/source/components/host/stylesheet/toggle-button.mjs +14 -8
  59. package/source/components/host/stylesheet/viewer.mjs +14 -8
  60. package/source/components/host/util.mjs +2 -2
  61. package/source/components/notify/stylesheet/message.mjs +14 -8
  62. package/source/components/notify/stylesheet/notify.mjs +14 -8
  63. package/source/components/state/stylesheet/log.mjs +14 -8
  64. package/source/components/state/stylesheet/state.mjs +14 -8
  65. package/source/components/stylesheet/badge.mjs +14 -8
  66. package/source/components/stylesheet/border.mjs +14 -8
  67. package/source/components/stylesheet/button.mjs +14 -8
  68. package/source/components/stylesheet/card.mjs +14 -8
  69. package/source/components/stylesheet/color.mjs +14 -8
  70. package/source/components/stylesheet/common.mjs +14 -8
  71. package/source/components/stylesheet/control.mjs +14 -8
  72. package/source/components/stylesheet/data-grid.mjs +14 -8
  73. package/source/components/stylesheet/display.mjs +14 -8
  74. package/source/components/stylesheet/floating-ui.mjs +14 -8
  75. package/source/components/stylesheet/form.mjs +14 -8
  76. package/source/components/stylesheet/host.mjs +14 -8
  77. package/source/components/stylesheet/icons.mjs +14 -8
  78. package/source/components/stylesheet/link.mjs +14 -8
  79. package/source/components/stylesheet/normalize.mjs +14 -8
  80. package/source/components/stylesheet/popper.mjs +14 -8
  81. package/source/components/stylesheet/property.mjs +14 -8
  82. package/source/components/stylesheet/ripple.mjs +14 -8
  83. package/source/components/stylesheet/skeleton.mjs +14 -8
  84. package/source/components/stylesheet/space.mjs +14 -8
  85. package/source/components/stylesheet/spinner.mjs +14 -8
  86. package/source/components/stylesheet/table.mjs +14 -8
  87. package/source/components/stylesheet/theme.mjs +14 -8
  88. package/source/components/stylesheet/typography.mjs +14 -8
  89. package/source/components/tree-menu/stylesheet/tree-menu.mjs +14 -8
  90. package/source/data/transformer.mjs +6 -8
  91. package/source/dom/attributes.mjs +5 -5
  92. package/source/dom/customelement.mjs +1 -1
  93. package/source/dom/updater.mjs +697 -700
  94. package/source/dom/util.mjs +2 -2
  95. package/source/monster.mjs +0 -1
  96. package/source/types/noderecursiveiterator.mjs +9 -7
  97. package/source/types/version.mjs +1 -1
  98. package/source/util/sleep.mjs +3 -4
  99. package/test/cases/monster.mjs +1 -1
@@ -4,52 +4,55 @@
4
4
  * This file is licensed under the AGPLv3 License.
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
- import {instanceSymbol} from "../../constants.mjs";
8
- import {createPopper} from "@popperjs/core";
9
- import {extend} from "../../data/extend.mjs";
10
- import {Pathfinder} from "../../data/pathfinder.mjs";
7
+ import { instanceSymbol } from "../../constants.mjs";
8
+ import { createPopper } from "@popperjs/core";
9
+ import { extend } from "../../data/extend.mjs";
10
+ import { Pathfinder } from "../../data/pathfinder.mjs";
11
11
  import {
12
- addAttributeToken,
13
- addToObjectLink,
14
- hasObjectLink,
12
+ addAttributeToken,
13
+ addToObjectLink,
14
+ hasObjectLink,
15
15
  } from "../../dom/attributes.mjs";
16
16
  import {
17
- ATTRIBUTE_ERRORMESSAGE,
18
- ATTRIBUTE_PREFIX,
19
- ATTRIBUTE_ROLE,
17
+ ATTRIBUTE_ERRORMESSAGE,
18
+ ATTRIBUTE_PREFIX,
19
+ ATTRIBUTE_ROLE,
20
20
  } from "../../dom/constants.mjs";
21
21
  import {
22
- assembleMethodSymbol,
23
- CustomElement,
24
- getSlottedElements,
25
- registerCustomElement,
22
+ assembleMethodSymbol,
23
+ CustomElement,
24
+ getSlottedElements,
25
+ registerCustomElement,
26
26
  } from "../../dom/customelement.mjs";
27
- import {findTargetElementFromEvent, fireCustomEvent} from "../../dom/events.mjs";
28
- import {getDocument} from "../../dom/util.mjs";
29
- import {random} from "../../math/random.mjs";
30
- import {getGlobal} from "../../types/global.mjs";
31
- import {ID} from "../../types/id.mjs";
32
- import {isArray, isString} from "../../types/is.mjs";
33
- import {TokenList} from "../../types/tokenlist.mjs";
34
- import {clone} from "../../util/clone.mjs";
35
- import {DeadMansSwitch} from "../../util/deadmansswitch.mjs";
36
- import {Processing} from "../../util/processing.mjs";
37
27
  import {
38
- ATTRIBUTE_BUTTON_LABEL,
39
- ATTRIBUTE_FORM_RELOAD,
40
- ATTRIBUTE_FORM_URL,
41
- STYLE_DISPLAY_MODE_BLOCK,
28
+ findTargetElementFromEvent,
29
+ fireCustomEvent,
30
+ } from "../../dom/events.mjs";
31
+ import { getDocument } from "../../dom/util.mjs";
32
+ import { random } from "../../math/random.mjs";
33
+ import { getGlobal } from "../../types/global.mjs";
34
+ import { ID } from "../../types/id.mjs";
35
+ import { isArray, isString } from "../../types/is.mjs";
36
+ import { TokenList } from "../../types/tokenlist.mjs";
37
+ import { clone } from "../../util/clone.mjs";
38
+ import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
39
+ import { Processing } from "../../util/processing.mjs";
40
+ import {
41
+ ATTRIBUTE_BUTTON_LABEL,
42
+ ATTRIBUTE_FORM_RELOAD,
43
+ ATTRIBUTE_FORM_URL,
44
+ STYLE_DISPLAY_MODE_BLOCK,
42
45
  } from "./constants.mjs";
43
46
 
44
- import {TabsStyleSheet} from "./stylesheet/tabs.mjs";
45
- import {loadAndAssignContent} from "./util/fetch.mjs";
46
- import {ThemeStyleSheet} from "../stylesheet/theme.mjs";
47
+ import { TabsStyleSheet } from "./stylesheet/tabs.mjs";
48
+ import { loadAndAssignContent } from "./util/fetch.mjs";
49
+ import { ThemeStyleSheet } from "../stylesheet/theme.mjs";
47
50
  import {
48
- popperInstanceSymbol,
49
- setEventListenersModifiers,
51
+ popperInstanceSymbol,
52
+ setEventListenersModifiers,
50
53
  } from "./util/popper.mjs";
51
54
 
52
- export {Tabs};
55
+ export { Tabs };
53
56
 
54
57
  /**
55
58
  * @private
@@ -169,289 +172,288 @@ const resizeObserverSymbol = Symbol("resizeObserver");
169
172
  * @fires Monster.Components.Form.event:monster-fetched
170
173
  */
171
174
  class Tabs extends CustomElement {
172
- /**
173
- * This method is called by the `instanceof` operator.
174
- * @returns {symbol}
175
- * @since 2.1.0
176
- */
177
- static get [instanceSymbol]() {
178
- return Symbol.for("@schukai/monster/components/form/tabs");
179
- }
180
-
181
- /**
182
- * To set the options via the html tag the attribute `data-monster-options` must be used.
183
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
184
- *
185
- * The individual configuration values can be found in the table.
186
- *
187
- * @property {Object} templates Template definitions
188
- * @property {string} templates.main Main template
189
- * @property {Object} labels
190
- * @property {string} labels.new-tab-label="New Tab"
191
- * @property {Object} fetch Fetch [see Using Fetch mozilla.org](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
192
- * @property {String} fetch.redirect=error
193
- * @property {String} fetch.method=GET
194
- * @property {String} fetch.mode=same-origin
195
- * @property {String} fetch.credentials=same-origin
196
- * @property {Object} fetch.headers={"accept":"text/html"}}
197
- * @property {Object} popper [PopperJS Options](https://popper.js.org/docs/v2/)
198
- * @property {string} popper.placement=bottom PopperJS placement
199
- * @property {Object[]} modifiers={name:offset} PopperJS placement
200
- */
201
- get defaults() {
202
- return Object.assign({}, super.defaults, {
203
- templates: {
204
- main: getTemplate(),
205
- },
206
- labels: {
207
- "new-tab-label": "New Tab",
208
- },
209
- buttons: {
210
- standard: [],
211
- popper: [],
212
- },
213
- fetch: {
214
- redirect: "error",
215
- method: "GET",
216
- mode: "same-origin",
217
- credentials: "same-origin",
218
- headers: {
219
- accept: "text/html",
220
- },
221
- },
222
-
223
- classes: {
224
- button: "monster-theme-primary-1",
225
- },
226
-
227
- popper: {
228
- placement: "bottom",
229
- modifiers: [
230
- {
231
- name: "offset",
232
- options: {
233
- offset: [0, 2],
234
- },
235
- },
236
-
237
- {
238
- name: "eventListeners",
239
- enabled: false,
240
- },
241
- ],
242
- },
243
- });
244
- }
245
-
246
- /**
247
- * This method is called internal and should not be called directly.
248
- */
249
- [assembleMethodSymbol]() {
250
- super[assembleMethodSymbol]();
251
-
252
- initControlReferences.call(this);
253
-
254
- this[dimensionsSymbol] = new Pathfinder({data: {}});
255
-
256
- initEventHandler.call(this);
257
-
258
- // setup structure
259
- initTabButtons.call(this).then(() => {
260
- initPopperSwitch.call(this);
261
- initPopper.call(this);
262
- attachResizeObserver.call(this);
263
- attachTabChangeObserver.call(this);
264
- });
265
- }
266
-
267
- /**
268
- * This method is called internal and should not be called directly.
269
- *
270
- * @return {CSSStyleSheet[]}
271
- */
272
- static getCSSStyleSheet() {
273
- return [TabsStyleSheet, ThemeStyleSheet];
274
- }
275
-
276
- /**
277
- * This method is called internal and should not be called directly.
278
- *
279
- * @return {string}
280
- */
281
- static getTag() {
282
- return "monster-tabs";
283
- }
284
-
285
- /**
286
- * This method is called by the dom and should not be called directly.
287
- *
288
- * @return {void}
289
- */
290
- connectedCallback() {
291
- super.connectedCallback();
292
-
293
- const document = getDocument();
294
-
295
- for (const [, type] of Object.entries(["click", "touch"])) {
296
- // close on outside ui-events
297
- document.addEventListener(type, this[closeEventHandler]);
298
- }
299
- }
300
-
301
- /**
302
- * This method is called by the dom and should not be called directly.
303
- *
304
- * @return {void}
305
- */
306
- disconnectedCallback() {
307
- super.disconnectedCallback();
308
-
309
- const document = getDocument();
310
-
311
- // close on outside ui-events
312
- for (const [, type] of Object.entries(["click", "touch"])) {
313
- document.removeEventListener(type, this[closeEventHandler]);
314
- }
315
- }
175
+ /**
176
+ * This method is called by the `instanceof` operator.
177
+ * @returns {symbol}
178
+ * @since 2.1.0
179
+ */
180
+ static get [instanceSymbol]() {
181
+ return Symbol.for("@schukai/monster/components/form/tabs");
182
+ }
183
+
184
+ /**
185
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
186
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
187
+ *
188
+ * The individual configuration values can be found in the table.
189
+ *
190
+ * @property {Object} templates Template definitions
191
+ * @property {string} templates.main Main template
192
+ * @property {Object} labels
193
+ * @property {string} labels.new-tab-label="New Tab"
194
+ * @property {Object} fetch Fetch [see Using Fetch mozilla.org](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
195
+ * @property {String} fetch.redirect=error
196
+ * @property {String} fetch.method=GET
197
+ * @property {String} fetch.mode=same-origin
198
+ * @property {String} fetch.credentials=same-origin
199
+ * @property {Object} fetch.headers={"accept":"text/html"}}
200
+ * @property {Object} popper [PopperJS Options](https://popper.js.org/docs/v2/)
201
+ * @property {string} popper.placement=bottom PopperJS placement
202
+ * @property {Object[]} modifiers={name:offset} PopperJS placement
203
+ */
204
+ get defaults() {
205
+ return Object.assign({}, super.defaults, {
206
+ templates: {
207
+ main: getTemplate(),
208
+ },
209
+ labels: {
210
+ "new-tab-label": "New Tab",
211
+ },
212
+ buttons: {
213
+ standard: [],
214
+ popper: [],
215
+ },
216
+ fetch: {
217
+ redirect: "error",
218
+ method: "GET",
219
+ mode: "same-origin",
220
+ credentials: "same-origin",
221
+ headers: {
222
+ accept: "text/html",
223
+ },
224
+ },
225
+
226
+ classes: {
227
+ button: "monster-theme-primary-1",
228
+ },
229
+
230
+ popper: {
231
+ placement: "bottom",
232
+ modifiers: [
233
+ {
234
+ name: "offset",
235
+ options: {
236
+ offset: [0, 2],
237
+ },
238
+ },
239
+
240
+ {
241
+ name: "eventListeners",
242
+ enabled: false,
243
+ },
244
+ ],
245
+ },
246
+ });
247
+ }
248
+
249
+ /**
250
+ * This method is called internal and should not be called directly.
251
+ */
252
+ [assembleMethodSymbol]() {
253
+ super[assembleMethodSymbol]();
254
+
255
+ initControlReferences.call(this);
256
+
257
+ this[dimensionsSymbol] = new Pathfinder({ data: {} });
258
+
259
+ initEventHandler.call(this);
260
+
261
+ // setup structure
262
+ initTabButtons.call(this).then(() => {
263
+ initPopperSwitch.call(this);
264
+ initPopper.call(this);
265
+ attachResizeObserver.call(this);
266
+ attachTabChangeObserver.call(this);
267
+ });
268
+ }
269
+
270
+ /**
271
+ * This method is called internal and should not be called directly.
272
+ *
273
+ * @return {CSSStyleSheet[]}
274
+ */
275
+ static getCSSStyleSheet() {
276
+ return [TabsStyleSheet, ThemeStyleSheet];
277
+ }
278
+
279
+ /**
280
+ * This method is called internal and should not be called directly.
281
+ *
282
+ * @return {string}
283
+ */
284
+ static getTag() {
285
+ return "monster-tabs";
286
+ }
287
+
288
+ /**
289
+ * This method is called by the dom and should not be called directly.
290
+ *
291
+ * @return {void}
292
+ */
293
+ connectedCallback() {
294
+ super.connectedCallback();
295
+
296
+ const document = getDocument();
297
+
298
+ for (const [, type] of Object.entries(["click", "touch"])) {
299
+ // close on outside ui-events
300
+ document.addEventListener(type, this[closeEventHandler]);
301
+ }
302
+ }
303
+
304
+ /**
305
+ * This method is called by the dom and should not be called directly.
306
+ *
307
+ * @return {void}
308
+ */
309
+ disconnectedCallback() {
310
+ super.disconnectedCallback();
311
+
312
+ const document = getDocument();
313
+
314
+ // close on outside ui-events
315
+ for (const [, type] of Object.entries(["click", "touch"])) {
316
+ document.removeEventListener(type, this[closeEventHandler]);
317
+ }
318
+ }
316
319
  }
317
320
 
318
321
  /**
319
322
  * @private
320
323
  */
321
324
  function initPopperSwitch() {
322
- const nodes = getSlottedElements.call(this, `[${ATTRIBUTE_ROLE}="switch"]`); // null ↦ only unnamed slots
323
- let switchButton;
324
- if (nodes.size === 0) {
325
- switchButton = document.createElement("button");
326
- switchButton.setAttribute(ATTRIBUTE_ROLE, "switch");
327
- switchButton.setAttribute("part", "switch");
328
- switchButton.classList.add("hidden");
329
- switchButton.innerHTML =
330
- '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/></svg>';
331
- this[navElementSymbol].prepend(switchButton);
332
- } else {
333
- switchButton = nodes.next();
334
- }
335
-
336
- /**
337
- * @param {Event} event
338
- */
339
- this[popperSwitchEventHandler] = (event) => {
340
- const element = findTargetElementFromEvent(event, ATTRIBUTE_ROLE, "switch");
341
-
342
- if (element instanceof HTMLButtonElement) {
343
- togglePopper.call(this);
344
- }
345
- };
346
-
347
- for (const type of ["click", "touch"]) {
348
- switchButton.addEventListener(type, this[popperSwitchEventHandler]);
349
- }
350
-
351
- this[switchElementSymbol] = switchButton;
325
+ const nodes = getSlottedElements.call(this, `[${ATTRIBUTE_ROLE}="switch"]`); // null ↦ only unnamed slots
326
+ let switchButton;
327
+ if (nodes.size === 0) {
328
+ switchButton = document.createElement("button");
329
+ switchButton.setAttribute(ATTRIBUTE_ROLE, "switch");
330
+ switchButton.setAttribute("part", "switch");
331
+ switchButton.classList.add("hidden");
332
+ switchButton.innerHTML =
333
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/></svg>';
334
+ this[navElementSymbol].prepend(switchButton);
335
+ } else {
336
+ switchButton = nodes.next();
337
+ }
338
+
339
+ /**
340
+ * @param {Event} event
341
+ */
342
+ this[popperSwitchEventHandler] = (event) => {
343
+ const element = findTargetElementFromEvent(event, ATTRIBUTE_ROLE, "switch");
344
+
345
+ if (element instanceof HTMLButtonElement) {
346
+ togglePopper.call(this);
347
+ }
348
+ };
349
+
350
+ for (const type of ["click", "touch"]) {
351
+ switchButton.addEventListener(type, this[popperSwitchEventHandler]);
352
+ }
353
+
354
+ this[switchElementSymbol] = switchButton;
352
355
  }
353
356
 
354
357
  /**
355
358
  * @private
356
359
  */
357
360
  function hidePopper() {
358
- if (!this[popperInstanceSymbol]) {
359
- return;
360
- }
361
+ if (!this[popperInstanceSymbol]) {
362
+ return;
363
+ }
361
364
 
362
- this[popperElementSymbol].style.display = "none";
363
- // performance https://popper.js.org/docs/v2/tutorial/#performance
364
- setEventListenersModifiers.call(this, false);
365
+ this[popperElementSymbol].style.display = "none";
366
+ // performance https://popper.js.org/docs/v2/tutorial/#performance
367
+ setEventListenersModifiers.call(this, false);
365
368
  }
366
369
 
367
370
  /**
368
371
  * @private
369
372
  */
370
373
  function showPopper() {
371
- if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
372
- return;
373
- }
374
-
375
- this[popperElementSymbol].style.visibility = "hidden";
376
- this[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
377
- // performance https://popper.js.org/docs/v2/tutorial/#performance
378
- setEventListenersModifiers.call(this, true);
379
-
380
- this[popperInstanceSymbol].update();
381
-
382
- new Processing(() => {
383
- this[popperElementSymbol].style.removeProperty("visibility");
384
- })
385
- .run(undefined)
386
- .then(() => {
387
- })
388
- .catch((e) => {
389
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
390
- });
374
+ if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
375
+ return;
376
+ }
377
+
378
+ this[popperElementSymbol].style.visibility = "hidden";
379
+ this[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
380
+ // performance https://popper.js.org/docs/v2/tutorial/#performance
381
+ setEventListenersModifiers.call(this, true);
382
+
383
+ this[popperInstanceSymbol].update();
384
+
385
+ new Processing(() => {
386
+ this[popperElementSymbol].style.removeProperty("visibility");
387
+ })
388
+ .run(undefined)
389
+ .then(() => {})
390
+ .catch((e) => {
391
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
392
+ });
391
393
  }
392
394
 
393
395
  /**
394
396
  * @private
395
397
  */
396
398
  function togglePopper() {
397
- if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
398
- hidePopper.call(this);
399
- } else {
400
- showPopper.call(this);
401
- }
399
+ if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
400
+ hidePopper.call(this);
401
+ } else {
402
+ showPopper.call(this);
403
+ }
402
404
  }
403
405
 
404
406
  /**
405
407
  * @private
406
408
  */
407
409
  function attachResizeObserver() {
408
- // against flickering
409
- this[resizeObserverSymbol] = new ResizeObserver((entries) => {
410
- if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
411
- try {
412
- this[timerCallbackSymbol].touch();
413
- return;
414
- } catch (e) {
415
- delete this[timerCallbackSymbol];
416
- }
417
- }
418
-
419
- this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
420
- this[dimensionsSymbol].setVia("data.calculated", false);
421
- checkAndRearrangeButtons.call(this);
422
- });
423
- });
424
-
425
- this[resizeObserverSymbol].observe(this[navElementSymbol]);
410
+ // against flickering
411
+ this[resizeObserverSymbol] = new ResizeObserver((entries) => {
412
+ if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
413
+ try {
414
+ this[timerCallbackSymbol].touch();
415
+ return;
416
+ } catch (e) {
417
+ delete this[timerCallbackSymbol];
418
+ }
419
+ }
420
+
421
+ this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
422
+ this[dimensionsSymbol].setVia("data.calculated", false);
423
+ checkAndRearrangeButtons.call(this);
424
+ });
425
+ });
426
+
427
+ this[resizeObserverSymbol].observe(this[navElementSymbol]);
426
428
  }
427
429
 
428
430
  /**
429
431
  * @private
430
432
  */
431
433
  function attachTabChangeObserver() {
432
- // against flickering
433
- new MutationObserver((mutations) => {
434
- let runUpdate = false;
435
-
436
- for (const mutation of mutations) {
437
- if (mutation.type === "childList") {
438
- if (
439
- mutation.addedNodes.length > 0 ||
440
- mutation.removedNodes.length > 0
441
- ) {
442
- runUpdate = true;
443
- break;
444
- }
445
- }
446
- }
447
-
448
- if (runUpdate === true) {
449
- this[dimensionsSymbol].setVia("data.calculated", false);
450
- initTabButtons.call(this);
451
- }
452
- }).observe(this, {
453
- childList: true,
454
- });
434
+ // against flickering
435
+ new MutationObserver((mutations) => {
436
+ let runUpdate = false;
437
+
438
+ for (const mutation of mutations) {
439
+ if (mutation.type === "childList") {
440
+ if (
441
+ mutation.addedNodes.length > 0 ||
442
+ mutation.removedNodes.length > 0
443
+ ) {
444
+ runUpdate = true;
445
+ break;
446
+ }
447
+ }
448
+ }
449
+
450
+ if (runUpdate === true) {
451
+ this[dimensionsSymbol].setVia("data.calculated", false);
452
+ initTabButtons.call(this);
453
+ }
454
+ }).observe(this, {
455
+ childList: true,
456
+ });
455
457
  }
456
458
 
457
459
  /**
@@ -461,216 +463,211 @@ function attachTabChangeObserver() {
461
463
  * @see {@link Plugins}
462
464
  */
463
465
  function initPopper() {
464
- const self = this;
465
-
466
- const options = extend({}, self.getOption("popper"));
467
-
468
- self[popperInstanceSymbol] = createPopper(
469
- self[switchElementSymbol],
470
- self[popperElementSymbol],
471
- options,
472
- );
473
-
474
- const observer1 = new MutationObserver(function (mutations) {
475
- let runUpdate = false;
476
-
477
- for (const mutation of mutations) {
478
- if (mutation.type === "childList") {
479
- if (
480
- mutation.addedNodes.length > 0 ||
481
- mutation.removedNodes.length > 0
482
- ) {
483
- runUpdate = true;
484
- break;
485
- }
486
- }
487
- }
488
-
489
- if (runUpdate === true) {
490
- self[popperInstanceSymbol].update();
491
- }
492
- });
493
-
494
- observer1.observe(self[popperNavElementSymbol], {
495
- childList: true,
496
- subtree: true,
497
- });
498
-
499
- return self;
466
+ const self = this;
467
+
468
+ const options = extend({}, self.getOption("popper"));
469
+
470
+ self[popperInstanceSymbol] = createPopper(
471
+ self[switchElementSymbol],
472
+ self[popperElementSymbol],
473
+ options,
474
+ );
475
+
476
+ const observer1 = new MutationObserver(function (mutations) {
477
+ let runUpdate = false;
478
+
479
+ for (const mutation of mutations) {
480
+ if (mutation.type === "childList") {
481
+ if (
482
+ mutation.addedNodes.length > 0 ||
483
+ mutation.removedNodes.length > 0
484
+ ) {
485
+ runUpdate = true;
486
+ break;
487
+ }
488
+ }
489
+ }
490
+
491
+ if (runUpdate === true) {
492
+ self[popperInstanceSymbol].update();
493
+ }
494
+ });
495
+
496
+ observer1.observe(self[popperNavElementSymbol], {
497
+ childList: true,
498
+ subtree: true,
499
+ });
500
+
501
+ return self;
500
502
  }
501
503
 
502
504
  /**
503
505
  * @private
504
506
  * @param {HTMLElement} element
505
507
  */
506
- function show(element) {
507
- const self = this;
508
- if (!this.shadowRoot) {
509
- throw new Error("no shadow-root is defined");
510
- }
511
-
512
- const reference = element.getAttribute(`${ATTRIBUTE_PREFIX}tab-reference`);
513
-
514
-
515
-
516
-
517
- const nodes = getSlottedElements.call(this);
518
- for (const node of nodes) {
519
- const id = node.getAttribute("id");
520
-
521
- if (id === reference) {
522
- node.classList.add("active");
523
-
524
- // get all data- from button and filter out data-monster-attributes and data-monster-insert
525
- const data = {};
526
- const mask = ["data-monster-attributes",
527
- "data-monster-insert-reference",
528
- "data-monster-state",
529
- "data-monster-button-label",
530
- "data-monster-objectlink",
531
- "data-monster-role"];
532
-
533
- for (const [, attr] of Object.entries(node.attributes)) {
534
- if (attr.name.startsWith("data-") && mask.indexOf(attr.name) === -1) {
535
- data[attr.name] = attr.value;
536
- }
537
- }
538
-
539
- if (node.hasAttribute(ATTRIBUTE_FORM_URL)) {
540
- const url = node.getAttribute(ATTRIBUTE_FORM_URL);
541
-
542
- if (
543
- !node.hasAttribute(ATTRIBUTE_FORM_RELOAD) ||
544
- node.getAttribute(ATTRIBUTE_FORM_RELOAD).toLowerCase() === "onshow"
545
- ) {
546
- node.removeAttribute(ATTRIBUTE_FORM_URL);
547
- }
548
-
549
- const options = this.getOption("fetch", {});
550
- const filter = undefined;
551
- loadAndAssignContent(node, url, options, filter)
552
- .then(() => {
553
- fireCustomEvent(self, "monster-tab-changed", {
554
- reference,
555
- });
556
- })
557
- .catch((e) => {
558
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
559
- });
560
- } else {
561
- fireCustomEvent(self, "monster-tab-changed", {
562
- reference,
563
- data
564
- });
565
- }
566
- } else {
567
- node.classList.remove("active");
568
- }
569
- }
570
-
571
- const standardButtons = this.getOption("buttons.standard");
572
- for (const index in standardButtons) {
573
- const button = standardButtons[index];
574
- const state = button["reference"] === reference ? "active" : "inactive";
575
- this.setOption(`buttons.standard.${index}.state`, state);
576
- }
577
-
578
- const popperButton = this.getOption("buttons.popper");
579
- for (const index in popperButton) {
580
- const button = popperButton[index];
581
- const state = button["reference"] === reference ? "active" : "inactive";
582
- this.setOption(`buttons.popper.${index}.state`, state);
583
- }
584
-
585
- hidePopper.call(this);
508
+ function show(element) {;
509
+ if (!this.shadowRoot) {
510
+ throw new Error("no shadow-root is defined");
511
+ }
512
+
513
+ const reference = element.getAttribute(`${ATTRIBUTE_PREFIX}tab-reference`);
514
+
515
+ const nodes = getSlottedElements.call(this);
516
+ for (const node of nodes) {
517
+ const id = node.getAttribute("id");
518
+
519
+ if (id === reference) {
520
+ node.classList.add("active");
521
+
522
+ // get all data- from button and filter out data-monster-attributes and data-monster-insert
523
+ const data = {};
524
+ const mask = [
525
+ "data-monster-attributes",
526
+ "data-monster-insert-reference",
527
+ "data-monster-state",
528
+ "data-monster-button-label",
529
+ "data-monster-objectlink",
530
+ "data-monster-role",
531
+ ];
532
+
533
+ for (const [, attr] of Object.entries(node.attributes)) {
534
+ if (attr.name.startsWith("data-") && mask.indexOf(attr.name) === -1) {
535
+ data[attr.name] = attr.value;
536
+ }
537
+ }
538
+
539
+ if (node.hasAttribute(ATTRIBUTE_FORM_URL)) {
540
+ const url = node.getAttribute(ATTRIBUTE_FORM_URL);
541
+
542
+ if (
543
+ !node.hasAttribute(ATTRIBUTE_FORM_RELOAD) ||
544
+ node.getAttribute(ATTRIBUTE_FORM_RELOAD).toLowerCase() === "onshow"
545
+ ) {
546
+ node.removeAttribute(ATTRIBUTE_FORM_URL);
547
+ }
548
+
549
+ const options = this.getOption("fetch", {});
550
+ const filter = undefined;
551
+ loadAndAssignContent(node, url, options, filter)
552
+ .then(() => {
553
+ fireCustomEvent(this, "monster-tab-changed", {
554
+ reference,
555
+ });
556
+ })
557
+ .catch((e) => {
558
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
559
+ });
560
+ } else {
561
+ fireCustomEvent(this, "monster-tab-changed", {
562
+ reference,
563
+ data,
564
+ });
565
+ }
566
+ } else {
567
+ node.classList.remove("active");
568
+ }
569
+ }
570
+
571
+ const standardButtons = this.getOption("buttons.standard");
572
+ for (const index in standardButtons) {
573
+ const button = standardButtons[index];
574
+ const state = button["reference"] === reference ? "active" : "inactive";
575
+ this.setOption(`buttons.standard.${index}.state`, state);
576
+ }
577
+
578
+ const popperButton = this.getOption("buttons.popper");
579
+ for (const index in popperButton) {
580
+ const button = popperButton[index];
581
+ const state = button["reference"] === reference ? "active" : "inactive";
582
+ this.setOption(`buttons.popper.${index}.state`, state);
583
+ }
584
+
585
+ hidePopper.call(this);
586
586
  }
587
587
 
588
588
  /**
589
589
  * @private
590
590
  */
591
- function initEventHandler() {
592
-
593
- const self=this;
594
-
595
- if (!this.shadowRoot) {
596
- throw new Error("no shadow-root is defined");
597
- }
598
-
599
- /**
600
- * @param {Event} event
601
- */
602
- this[changeTabEventHandler] = (event) => {
603
- const element = findTargetElementFromEvent(event, ATTRIBUTE_ROLE, "button");
604
-
605
- if (element instanceof HTMLButtonElement && element.disabled !== true) {
606
- show.call(this, element);
607
- }
608
- };
609
-
610
- /**
611
- * event:monster-tab-remove
612
- * @event Monster.Components.Form.event:monster-tab-remove
613
- */
614
-
615
- /**
616
- * @param {Event} event
617
- * @fires Monster.Components.Form.event:monster-tab-remove
618
- */
619
- this[removeTabEventHandler] = (event) => {
620
-
621
- const element = findTargetElementFromEvent(
622
- event,
623
- ATTRIBUTE_ROLE,
624
- "remove-tab",
625
- );
626
-
627
- if (element instanceof HTMLElement) {
628
- const button = findTargetElementFromEvent(
629
- event,
630
- ATTRIBUTE_ROLE,
631
- "button",
632
- );
633
-
634
- if (button instanceof HTMLButtonElement && button.disabled !== true) {
635
- const reference = button.getAttribute(
636
- `${ATTRIBUTE_PREFIX}tab-reference`,
637
- );
638
- if (reference) {
639
- const container = this.querySelector(`[id=${reference}]`);
640
- if (container instanceof HTMLElement) {
641
- container.remove();
642
- initTabButtons.call(this);
643
- fireCustomEvent(self, "monster-tab-remove", {
644
- reference,
645
- });
646
- }
647
- }
648
- }
649
- }
650
- };
651
-
652
- this[navElementSymbol].addEventListener("touch", this[changeTabEventHandler]);
653
- this[navElementSymbol].addEventListener("click", this[changeTabEventHandler]);
654
-
655
- this[navElementSymbol].addEventListener("touch", this[removeTabEventHandler]);
656
- this[navElementSymbol].addEventListener("click", this[removeTabEventHandler]);
657
-
658
- /**
659
- * @param {Event} event
660
- */
661
- this[closeEventHandler] = (event) => {
662
- const path = event.composedPath();
663
-
664
- for (const [, element] of Object.entries(path)) {
665
- if (element === this) {
666
- return;
667
- }
668
- }
669
-
670
- hidePopper.call(this);
671
- };
672
-
673
- return this;
591
+ function initEventHandler() {;
592
+
593
+ if (!this.shadowRoot) {
594
+ throw new Error("no shadow-root is defined");
595
+ }
596
+
597
+ /**
598
+ * @param {Event} event
599
+ */
600
+ this[changeTabEventHandler] = (event) => {
601
+ const element = findTargetElementFromEvent(event, ATTRIBUTE_ROLE, "button");
602
+
603
+ if (element instanceof HTMLButtonElement && element.disabled !== true) {
604
+ show.call(this, element);
605
+ }
606
+ };
607
+
608
+ /**
609
+ * event:monster-tab-remove
610
+ * @event Monster.Components.Form.event:monster-tab-remove
611
+ */
612
+
613
+ /**
614
+ * @param {Event} event
615
+ * @fires Monster.Components.Form.event:monster-tab-remove
616
+ */
617
+ this[removeTabEventHandler] = (event) => {
618
+ const element = findTargetElementFromEvent(
619
+ event,
620
+ ATTRIBUTE_ROLE,
621
+ "remove-tab",
622
+ );
623
+
624
+ if (element instanceof HTMLElement) {
625
+ const button = findTargetElementFromEvent(
626
+ event,
627
+ ATTRIBUTE_ROLE,
628
+ "button",
629
+ );
630
+
631
+ if (button instanceof HTMLButtonElement && button.disabled !== true) {
632
+ const reference = button.getAttribute(
633
+ `${ATTRIBUTE_PREFIX}tab-reference`,
634
+ );
635
+ if (reference) {
636
+ const container = this.querySelector(`[id=${reference}]`);
637
+ if (container instanceof HTMLElement) {
638
+ container.remove();
639
+ initTabButtons.call(this);
640
+ fireCustomEvent(this, "monster-tab-remove", {
641
+ reference,
642
+ });
643
+ }
644
+ }
645
+ }
646
+ }
647
+ };
648
+
649
+ this[navElementSymbol].addEventListener("touch", this[changeTabEventHandler]);
650
+ this[navElementSymbol].addEventListener("click", this[changeTabEventHandler]);
651
+
652
+ this[navElementSymbol].addEventListener("touch", this[removeTabEventHandler]);
653
+ this[navElementSymbol].addEventListener("click", this[removeTabEventHandler]);
654
+
655
+ /**
656
+ * @param {Event} event
657
+ */
658
+ this[closeEventHandler] = (event) => {
659
+ const path = event.composedPath();
660
+
661
+ for (const [, element] of Object.entries(path)) {
662
+ if (element === this) {
663
+ return;
664
+ }
665
+ }
666
+
667
+ hidePopper.call(this);
668
+ };
669
+
670
+ return this;
674
671
  }
675
672
 
676
673
  /**
@@ -678,37 +675,37 @@ function initEventHandler() {
678
675
  * @param observedNode
679
676
  */
680
677
  function attachTabMutationObserver(observedNode) {
681
- const self = this;
682
-
683
- if (hasObjectLink(observedNode, mutationObserverSymbol)) {
684
- return;
685
- }
686
-
687
- /**
688
- * this construct monitors a node whether it is disabled or modified
689
- * @type {MutationObserver}
690
- */
691
- const observer = new MutationObserver(function (mutations) {
692
- if (isArray(mutations)) {
693
- const mutation = mutations.pop();
694
- if (mutation instanceof MutationRecord) {
695
- initTabButtons.call(self);
696
- }
697
- }
698
- });
699
-
700
- observer.observe(observedNode, {
701
- childList: false,
702
- attributes: true,
703
- subtree: false,
704
- attributeFilter: [
705
- "disabled",
706
- ATTRIBUTE_BUTTON_LABEL,
707
- `${ATTRIBUTE_PREFIX}button-icon`,
708
- ],
709
- });
710
-
711
- addToObjectLink(observedNode, mutationObserverSymbol, observer);
678
+ const self = this;
679
+
680
+ if (hasObjectLink(observedNode, mutationObserverSymbol)) {
681
+ return;
682
+ }
683
+
684
+ /**
685
+ * this construct monitors a node whether it is disabled or modified
686
+ * @type {MutationObserver}
687
+ */
688
+ const observer = new MutationObserver(function (mutations) {
689
+ if (isArray(mutations)) {
690
+ const mutation = mutations.pop();
691
+ if (mutation instanceof MutationRecord) {
692
+ initTabButtons.call(self);
693
+ }
694
+ }
695
+ });
696
+
697
+ observer.observe(observedNode, {
698
+ childList: false,
699
+ attributes: true,
700
+ subtree: false,
701
+ attributeFilter: [
702
+ "disabled",
703
+ ATTRIBUTE_BUTTON_LABEL,
704
+ `${ATTRIBUTE_PREFIX}button-icon`,
705
+ ],
706
+ });
707
+
708
+ addToObjectLink(observedNode, mutationObserverSymbol, observer);
712
709
  }
713
710
 
714
711
  /**
@@ -717,22 +714,22 @@ function attachTabMutationObserver(observedNode) {
717
714
  * @throws {Error} no shadow-root is defined
718
715
  */
719
716
  function initControlReferences() {
720
- if (!this.shadowRoot) {
721
- throw new Error("no shadow-root is defined");
722
- }
723
-
724
- this[controlElementSymbol] = this.shadowRoot.querySelector(
725
- `[${ATTRIBUTE_ROLE}=control]`,
726
- );
727
- this[navElementSymbol] = this.shadowRoot.querySelector(
728
- `nav[${ATTRIBUTE_ROLE}=nav]`,
729
- );
730
- this[popperElementSymbol] = this.shadowRoot.querySelector(
731
- `[${ATTRIBUTE_ROLE}=popper]`,
732
- );
733
- this[popperNavElementSymbol] = this.shadowRoot.querySelector(
734
- `[${ATTRIBUTE_ROLE}=popper-nav]`,
735
- );
717
+ if (!this.shadowRoot) {
718
+ throw new Error("no shadow-root is defined");
719
+ }
720
+
721
+ this[controlElementSymbol] = this.shadowRoot.querySelector(
722
+ `[${ATTRIBUTE_ROLE}=control]`,
723
+ );
724
+ this[navElementSymbol] = this.shadowRoot.querySelector(
725
+ `nav[${ATTRIBUTE_ROLE}=nav]`,
726
+ );
727
+ this[popperElementSymbol] = this.shadowRoot.querySelector(
728
+ `[${ATTRIBUTE_ROLE}=popper]`,
729
+ );
730
+ this[popperNavElementSymbol] = this.shadowRoot.querySelector(
731
+ `[${ATTRIBUTE_ROLE}=popper-nav]`,
732
+ );
736
733
  }
737
734
 
738
735
  /**
@@ -742,102 +739,101 @@ function initControlReferences() {
742
739
  *
743
740
  */
744
741
  function initTabButtons() {
745
- if (!this.shadowRoot) {
746
- throw new Error("no shadow-root is defined");
747
- }
748
-
749
- let activeReference;
750
-
751
- const dimensionsCalculated = this[dimensionsSymbol].getVia(
752
- "data.calculated",
753
- false,
754
- );
755
-
756
- const buttons = [];
757
- const nodes = getSlottedElements.call(this, undefined, null); // null ↦ only unnamed slots
758
-
759
- for (const node of nodes) {
760
- if (!(node instanceof HTMLElement)) continue;
761
- let label = getButtonLabel.call(this, node);
762
-
763
- let reference;
764
- if (node.hasAttribute("id")) {
765
- reference = node.getAttribute("id");
766
- }
767
-
768
- let disabled;
769
- if (node.hasAttribute("disabled") || node.disabled === true) {
770
- disabled = true;
771
- }
772
-
773
- if (!reference) {
774
- reference = new ID("tab").toString();
775
- node.setAttribute("id", reference);
776
- }
777
-
778
- if (node.hasAttribute(`${ATTRIBUTE_PREFIX}button-icon`)) {
779
- label = `<span part="label">${label}</span><img part="icon" src="${node.getAttribute(
780
- `${ATTRIBUTE_PREFIX}button-icon`,
781
- )}">`;
782
- }
783
-
784
- let remove = false;
785
- if (node.hasAttribute(`${ATTRIBUTE_PREFIX}removable`)) {
786
- remove = true;
787
- }
788
-
789
- if (node.matches(".active") === true && disabled !== true) {
790
- node.classList.remove("active");
791
- activeReference = reference;
792
- }
793
-
794
- const state = "";
795
- const classes = dimensionsCalculated ? "" : "invisible";
796
-
797
- buttons.push({
798
- reference,
799
- label,
800
- state,
801
- class: classes,
802
- disabled,
803
- remove,
804
- });
805
-
806
- attachTabMutationObserver.call(this, node);
807
- }
808
-
809
- this.setOption("buttons.standard", clone(buttons));
810
- this.setOption("buttons.popper", []);
811
- this.setOption("marker", random());
812
-
813
- return adjustButtonVisibility.call(this).then(() => {
814
- if (activeReference) {
815
- return new Processing(() => {
816
- const button = this.shadowRoot.querySelector(
817
- `[${ATTRIBUTE_PREFIX}tab-reference="${activeReference}"]`,
818
- );
819
- if (button instanceof HTMLButtonElement && button.disabled !== true) {
820
- show.call(this, button);
821
- }
822
- })
823
- .run(undefined)
824
- .then(() => {
825
- })
826
- .catch((e) => {
827
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
828
- });
829
- }
830
-
831
- return Promise.resolve();
832
- });
742
+ if (!this.shadowRoot) {
743
+ throw new Error("no shadow-root is defined");
744
+ }
745
+
746
+ let activeReference;
747
+
748
+ const dimensionsCalculated = this[dimensionsSymbol].getVia(
749
+ "data.calculated",
750
+ false,
751
+ );
752
+
753
+ const buttons = [];
754
+ const nodes = getSlottedElements.call(this, undefined, null); // null ↦ only unnamed slots
755
+
756
+ for (const node of nodes) {
757
+ if (!(node instanceof HTMLElement)) continue;
758
+ let label = getButtonLabel.call(this, node);
759
+
760
+ let reference;
761
+ if (node.hasAttribute("id")) {
762
+ reference = node.getAttribute("id");
763
+ }
764
+
765
+ let disabled;
766
+ if (node.hasAttribute("disabled") || node.disabled === true) {
767
+ disabled = true;
768
+ }
769
+
770
+ if (!reference) {
771
+ reference = new ID("tab").toString();
772
+ node.setAttribute("id", reference);
773
+ }
774
+
775
+ if (node.hasAttribute(`${ATTRIBUTE_PREFIX}button-icon`)) {
776
+ label = `<span part="label">${label}</span><img part="icon" src="${node.getAttribute(
777
+ `${ATTRIBUTE_PREFIX}button-icon`,
778
+ )}">`;
779
+ }
780
+
781
+ let remove = false;
782
+ if (node.hasAttribute(`${ATTRIBUTE_PREFIX}removable`)) {
783
+ remove = true;
784
+ }
785
+
786
+ if (node.matches(".active") === true && disabled !== true) {
787
+ node.classList.remove("active");
788
+ activeReference = reference;
789
+ }
790
+
791
+ const state = "";
792
+ const classes = dimensionsCalculated ? "" : "invisible";
793
+
794
+ buttons.push({
795
+ reference,
796
+ label,
797
+ state,
798
+ class: classes,
799
+ disabled,
800
+ remove,
801
+ });
802
+
803
+ attachTabMutationObserver.call(this, node);
804
+ }
805
+
806
+ this.setOption("buttons.standard", clone(buttons));
807
+ this.setOption("buttons.popper", []);
808
+ this.setOption("marker", random());
809
+
810
+ return adjustButtonVisibility.call(this).then(() => {
811
+ if (activeReference) {
812
+ return new Processing(() => {
813
+ const button = this.shadowRoot.querySelector(
814
+ `[${ATTRIBUTE_PREFIX}tab-reference="${activeReference}"]`,
815
+ );
816
+ if (button instanceof HTMLButtonElement && button.disabled !== true) {
817
+ show.call(this, button);
818
+ }
819
+ })
820
+ .run(undefined)
821
+ .then(() => {})
822
+ .catch((e) => {
823
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
824
+ });
825
+ }
826
+
827
+ return Promise.resolve();
828
+ });
833
829
  }
834
830
 
835
831
  function checkAndRearrangeButtons() {
836
- if (this[dimensionsSymbol].getVia("data.calculated", false) !== true) {
837
- calculateNavigationButtonsDimensions.call(this);
838
- }
832
+ if (this[dimensionsSymbol].getVia("data.calculated", false) !== true) {
833
+ calculateNavigationButtonsDimensions.call(this);
834
+ }
839
835
 
840
- rearrangeButtons.call(this);
836
+ rearrangeButtons.call(this);
841
837
  }
842
838
 
843
839
  /**
@@ -845,29 +841,29 @@ function checkAndRearrangeButtons() {
845
841
  * @return {Promise<unknown>}
846
842
  */
847
843
  function adjustButtonVisibility() {
848
- const self = this;
844
+ const self = this;
849
845
 
850
- return new Promise((resolve) => {
851
- const observer = new MutationObserver(function (mutations) {
852
- const defCount = self.getOption("buttons.standard").length;
853
- const domCount = self[navElementSymbol].querySelectorAll(
854
- 'button[data-monster-role="button"]',
855
- ).length;
846
+ return new Promise((resolve) => {
847
+ const observer = new MutationObserver(function (mutations) {
848
+ const defCount = self.getOption("buttons.standard").length;
849
+ const domCount = self[navElementSymbol].querySelectorAll(
850
+ 'button[data-monster-role="button"]',
851
+ ).length;
856
852
 
857
- // in drawing
858
- if (defCount !== domCount) return;
853
+ // in drawing
854
+ if (defCount !== domCount) return;
859
855
 
860
- observer.disconnect();
856
+ observer.disconnect();
861
857
 
862
- checkAndRearrangeButtons.call(self);
858
+ checkAndRearrangeButtons.call(self);
863
859
 
864
- resolve();
865
- });
860
+ resolve();
861
+ });
866
862
 
867
- observer.observe(self[navElementSymbol], {
868
- attributes: true,
869
- });
870
- });
863
+ observer.observe(self[navElementSymbol], {
864
+ attributes: true,
865
+ });
866
+ });
871
867
  }
872
868
 
873
869
  /**
@@ -876,17 +872,17 @@ function adjustButtonVisibility() {
876
872
  * @return {number}
877
873
  */
878
874
  function getDimValue(value) {
879
- if ([undefined, null].indexOf(value) !== -1) {
880
- return 0;
881
- }
875
+ if ([undefined, null].indexOf(value) !== -1) {
876
+ return 0;
877
+ }
882
878
 
883
- const valueAsInt = parseInt(value, 10);
879
+ const valueAsInt = parseInt(value, 10);
884
880
 
885
- if (isNaN(valueAsInt)) {
886
- return 0;
887
- }
881
+ if (isNaN(valueAsInt)) {
882
+ return 0;
883
+ }
888
884
 
889
- return valueAsInt;
885
+ return valueAsInt;
890
886
  }
891
887
 
892
888
  /**
@@ -895,18 +891,18 @@ function getDimValue(value) {
895
891
  * @return {number}
896
892
  */
897
893
  function calcBoxWidth(node) {
898
- const dim = getGlobal("window").getComputedStyle(node);
899
- const bounding = node.getBoundingClientRect();
900
-
901
- return (
902
- getDimValue(dim["border-left-width"]) +
903
- getDimValue(dim["padding-left"]) +
904
- getDimValue(dim["margin-left"]) +
905
- getDimValue(bounding["width"]) +
906
- getDimValue(dim["border-right-width"]) +
907
- getDimValue(dim["margin-right"]) +
908
- getDimValue(dim["padding-left"])
909
- );
894
+ const dim = getGlobal("window").getComputedStyle(node);
895
+ const bounding = node.getBoundingClientRect();
896
+
897
+ return (
898
+ getDimValue(dim["border-left-width"]) +
899
+ getDimValue(dim["padding-left"]) +
900
+ getDimValue(dim["margin-left"]) +
901
+ getDimValue(bounding["width"]) +
902
+ getDimValue(dim["border-right-width"]) +
903
+ getDimValue(dim["margin-right"]) +
904
+ getDimValue(dim["padding-left"])
905
+ );
910
906
  }
911
907
 
912
908
  /**
@@ -914,35 +910,35 @@ function calcBoxWidth(node) {
914
910
  * @return {Object}
915
911
  */
916
912
  function rearrangeButtons() {
917
- const standardButtons = [];
918
- const popperButtons = [];
919
-
920
- let sum = 0;
921
- const space = this[dimensionsSymbol].getVia("data.space");
922
-
923
- const buttons = this.getOption("buttons.standard");
924
- for (const [, button] of buttons.entries()) {
925
- const ref = button?.reference;
926
-
927
- sum += this[dimensionsSymbol].getVia(`data.button.${ref}`);
928
-
929
- if (sum > space) {
930
- popperButtons.push(clone(button));
931
- } else {
932
- standardButtons.push(clone(button));
933
- }
934
- }
935
-
936
- this.setOption("buttons.standard", standardButtons);
937
- this.setOption("buttons.popper", popperButtons);
938
-
939
- if (this[switchElementSymbol]) {
940
- if (popperButtons.length > 0) {
941
- this[switchElementSymbol].classList.remove("hidden");
942
- } else {
943
- this[switchElementSymbol].classList.add("hidden");
944
- }
945
- }
913
+ const standardButtons = [];
914
+ const popperButtons = [];
915
+
916
+ let sum = 0;
917
+ const space = this[dimensionsSymbol].getVia("data.space");
918
+
919
+ const buttons = this.getOption("buttons.standard");
920
+ for (const [, button] of buttons.entries()) {
921
+ const ref = button?.reference;
922
+
923
+ sum += this[dimensionsSymbol].getVia(`data.button.${ref}`);
924
+
925
+ if (sum > space) {
926
+ popperButtons.push(clone(button));
927
+ } else {
928
+ standardButtons.push(clone(button));
929
+ }
930
+ }
931
+
932
+ this.setOption("buttons.standard", standardButtons);
933
+ this.setOption("buttons.popper", popperButtons);
934
+
935
+ if (this[switchElementSymbol]) {
936
+ if (popperButtons.length > 0) {
937
+ this[switchElementSymbol].classList.remove("hidden");
938
+ } else {
939
+ this[switchElementSymbol].classList.add("hidden");
940
+ }
941
+ }
946
942
  }
947
943
 
948
944
  /**
@@ -950,50 +946,50 @@ function rearrangeButtons() {
950
946
  * @return {Object}
951
947
  */
952
948
  function calculateNavigationButtonsDimensions() {
953
- const width = this[navElementSymbol].getBoundingClientRect().width;
954
-
955
- let startEndWidth = 0;
956
-
957
- getSlottedElements.call(this, undefined, "start").forEach((node) => {
958
- startEndWidth += calcBoxWidth.call(this, node);
959
- });
960
-
961
- getSlottedElements.call(this, undefined, "end").forEach((node) => {
962
- startEndWidth += calcBoxWidth.call(this, node);
963
- });
964
-
965
- this[dimensionsSymbol].setVia("data.space", width - startEndWidth - 2);
966
- this[dimensionsSymbol].setVia("data.visible", !(width === 0));
967
-
968
- const buttons = this.getOption("buttons.standard").concat(
969
- this.getOption("buttons.popper"),
970
- );
971
-
972
- for (const [i, button] of buttons.entries()) {
973
- const ref = button?.reference;
974
- const element = this[navElementSymbol].querySelector(
975
- `:scope > [${ATTRIBUTE_PREFIX}tab-reference="${ref}"]`,
976
- );
977
- if (!(element instanceof HTMLButtonElement)) continue;
978
-
979
- this[dimensionsSymbol].setVia(
980
- `data.button.${ref}`,
981
- calcBoxWidth.call(this, element),
982
- );
983
- button["class"] = new TokenList(button["class"])
984
- .remove("invisible")
985
- .toString();
986
- }
987
-
988
- const slots = this[controlElementSymbol].querySelectorAll(
989
- `nav[${ATTRIBUTE_PREFIX}role=nav] > slot.invisible, slot[${ATTRIBUTE_PREFIX}role=slot].invisible`,
990
- );
991
- for (const [, slot] of slots.entries()) {
992
- slot.classList.remove("invisible");
993
- }
994
-
995
- this[dimensionsSymbol].setVia("data.calculated", true);
996
- this.setOption("buttons.standard", clone(buttons));
949
+ const width = this[navElementSymbol].getBoundingClientRect().width;
950
+
951
+ let startEndWidth = 0;
952
+
953
+ getSlottedElements.call(this, undefined, "start").forEach((node) => {
954
+ startEndWidth += calcBoxWidth.call(this, node);
955
+ });
956
+
957
+ getSlottedElements.call(this, undefined, "end").forEach((node) => {
958
+ startEndWidth += calcBoxWidth.call(this, node);
959
+ });
960
+
961
+ this[dimensionsSymbol].setVia("data.space", width - startEndWidth - 2);
962
+ this[dimensionsSymbol].setVia("data.visible", !(width === 0));
963
+
964
+ const buttons = this.getOption("buttons.standard").concat(
965
+ this.getOption("buttons.popper"),
966
+ );
967
+
968
+ for (const [i, button] of buttons.entries()) {
969
+ const ref = button?.reference;
970
+ const element = this[navElementSymbol].querySelector(
971
+ `:scope > [${ATTRIBUTE_PREFIX}tab-reference="${ref}"]`,
972
+ );
973
+ if (!(element instanceof HTMLButtonElement)) continue;
974
+
975
+ this[dimensionsSymbol].setVia(
976
+ `data.button.${ref}`,
977
+ calcBoxWidth.call(this, element),
978
+ );
979
+ button["class"] = new TokenList(button["class"])
980
+ .remove("invisible")
981
+ .toString();
982
+ }
983
+
984
+ const slots = this[controlElementSymbol].querySelectorAll(
985
+ `nav[${ATTRIBUTE_PREFIX}role=nav] > slot.invisible, slot[${ATTRIBUTE_PREFIX}role=slot].invisible`,
986
+ );
987
+ for (const [, slot] of slots.entries()) {
988
+ slot.classList.remove("invisible");
989
+ }
990
+
991
+ this[dimensionsSymbol].setVia("data.calculated", true);
992
+ this.setOption("buttons.standard", clone(buttons));
997
993
  }
998
994
 
999
995
  /**
@@ -1002,34 +998,34 @@ function calculateNavigationButtonsDimensions() {
1002
998
  * @return {string}
1003
999
  */
1004
1000
  function getButtonLabel(node) {
1005
- let label;
1006
- let setLabel = false;
1007
- if (node.hasAttribute(ATTRIBUTE_BUTTON_LABEL)) {
1008
- label = node.getAttribute(ATTRIBUTE_BUTTON_LABEL);
1009
- } else {
1010
- label = node.innerText;
1011
- setLabel = true;
1012
- }
1013
-
1014
- if (!isString(label)) {
1015
- label = "";
1016
- }
1017
-
1018
- label = label.trim();
1019
-
1020
- if (label === "") {
1021
- label = this.getOption("labels.new-tab-label", "New Tab");
1022
- }
1023
-
1024
- if (label.length > 100) {
1025
- label = `${label.substring(0, 99)}…`;
1026
- }
1027
-
1028
- if (setLabel === true) {
1029
- node.setAttribute(ATTRIBUTE_BUTTON_LABEL, label);
1030
- }
1031
-
1032
- return label;
1001
+ let label;
1002
+ let setLabel = false;
1003
+ if (node.hasAttribute(ATTRIBUTE_BUTTON_LABEL)) {
1004
+ label = node.getAttribute(ATTRIBUTE_BUTTON_LABEL);
1005
+ } else {
1006
+ label = node.innerText;
1007
+ setLabel = true;
1008
+ }
1009
+
1010
+ if (!isString(label)) {
1011
+ label = "";
1012
+ }
1013
+
1014
+ label = label.trim();
1015
+
1016
+ if (label === "") {
1017
+ label = this.getOption("labels.new-tab-label", "New Tab");
1018
+ }
1019
+
1020
+ if (label.length > 100) {
1021
+ label = `${label.substring(0, 99)}…`;
1022
+ }
1023
+
1024
+ if (setLabel === true) {
1025
+ node.setAttribute(ATTRIBUTE_BUTTON_LABEL, label);
1026
+ }
1027
+
1028
+ return label;
1033
1029
  }
1034
1030
 
1035
1031
  /**
@@ -1037,8 +1033,8 @@ function getButtonLabel(node) {
1037
1033
  * @return {string}
1038
1034
  */
1039
1035
  function getTemplate() {
1040
- // language=HTML
1041
- return `
1036
+ // language=HTML
1037
+ return `
1042
1038
  <template id="buttons">
1043
1039
  <button part="button"
1044
1040
  data-monster-role="button"