@schukai/monster 3.75.0 → 3.76.0

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 (43) hide show
  1. package/CHANGELOG.md +21 -8
  2. package/package.json +1 -1
  3. package/source/components/layout/collapse.mjs +361 -395
  4. package/source/components/layout/details.mjs +10 -40
  5. package/source/components/layout/iframe.mjs +358 -0
  6. package/source/components/layout/panel.mjs +10 -25
  7. package/source/components/layout/slider.mjs +11 -11
  8. package/source/components/layout/split-panel.mjs +7 -39
  9. package/source/components/layout/style/iframe.pcss +39 -0
  10. package/source/components/layout/style/panel.pcss +10 -3
  11. package/source/components/layout/style/split-panel.pcss +2 -0
  12. package/source/components/layout/stylesheet/iframe.mjs +38 -0
  13. package/source/components/layout/stylesheet/panel.mjs +1 -1
  14. package/source/components/layout/tabs.mjs +6 -35
  15. package/source/components/layout/width-toggle.mjs +10 -31
  16. package/source/components/tree-menu/tree-menu.mjs +16 -12
  17. package/source/math/random.mjs +2 -3
  18. package/source/monster.mjs +2 -1
  19. package/test/cases/components/form/button.mjs +2 -1
  20. package/test/cases/components/form/confirm-button.mjs +1 -1
  21. package/test/cases/components/form/form.mjs +1 -1
  22. package/test/cases/components/form/reload.mjs +1 -1
  23. package/test/cases/components/form/select.mjs +1 -1
  24. package/test/cases/components/form/state-button.mjs +1 -1
  25. package/test/cases/components/form/template.mjs +1 -1
  26. package/test/cases/components/form/toggle-switch.mjs +1 -1
  27. package/test/cases/components/form/tree-select.mjs +1 -1
  28. package/test/cases/components/host/details.mjs +1 -1
  29. package/test/cases/components/host/host.mjs +1 -1
  30. package/test/cases/components/host/overlay.mjs +1 -1
  31. package/test/cases/components/layout/panel.mjs +1 -1
  32. package/test/cases/components/layout/slit-panel.mjs +1 -1
  33. package/test/cases/components/layout/tabs.mjs +1 -1
  34. package/test/cases/components/notify/message.mjs +1 -1
  35. package/test/cases/components/notify/notify.mjs +1 -1
  36. package/test/cases/dom/customcontrol.mjs +1 -1
  37. package/test/cases/dom/customelement-initfromscripthost.mjs +1 -1
  38. package/test/cases/dom/customelement.mjs +1 -1
  39. package/test/cases/dom/resource/data.mjs +1 -1
  40. package/test/cases/dom/resource/link/stylesheet.mjs +1 -1
  41. package/test/cases/dom/resource/link.mjs +1 -1
  42. package/test/cases/dom/resource/script.mjs +1 -1
  43. package/test/cases/dom/updater.mjs +1 -1
@@ -13,22 +13,22 @@
13
13
  */
14
14
 
15
15
  import {
16
- assembleMethodSymbol,
17
- CustomElement,
18
- getSlottedElements,
19
- registerCustomElement,
16
+ assembleMethodSymbol,
17
+ CustomElement,
18
+ getSlottedElements,
19
+ registerCustomElement,
20
20
  } from "../../dom/customelement.mjs";
21
- import { CollapseStyleSheet } from "./stylesheet/collapse.mjs";
22
- import { fireCustomEvent } from "../../dom/events.mjs";
23
- import { getDocument } from "../../dom/util.mjs";
24
- import { addAttributeToken } from "../../dom/attributes.mjs";
25
- import { ATTRIBUTE_ERRORMESSAGE } from "../../dom/constants.mjs";
26
- import { Host } from "../host/host.mjs";
27
- import { generateUniqueConfigKey } from "../host/util.mjs";
28
- import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
29
- import { instanceSymbol } from "../../constants.mjs";
30
-
31
- export { Collapse, nameSymbol };
21
+ import {CollapseStyleSheet} from "./stylesheet/collapse.mjs";
22
+ import {fireCustomEvent} from "../../dom/events.mjs";
23
+ import {getDocument} from "../../dom/util.mjs";
24
+ import {addAttributeToken} from "../../dom/attributes.mjs";
25
+ import {ATTRIBUTE_ERRORMESSAGE} from "../../dom/constants.mjs";
26
+ import {Host} from "../host/host.mjs";
27
+ import {generateUniqueConfigKey} from "../host/util.mjs";
28
+ import {DeadMansSwitch} from "../../util/deadmansswitch.mjs";
29
+ import {instanceSymbol} from "../../constants.mjs";
30
+
31
+ export {Collapse, nameSymbol};
32
32
 
33
33
  /**
34
34
  * @private
@@ -80,330 +80,296 @@ const detailsDecoElementSymbol = Symbol("detailsDecoElement");
80
80
  const nameSymbol = Symbol("name");
81
81
 
82
82
  /**
83
- * The Collapse component is used to show the details.
83
+ * A Collapse component
84
84
  *
85
- * <img src="./images/collapse.png">
85
+ * @fragments /fragments/components/layout/collapse/
86
86
  *
87
- * Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library
88
- *
89
- * You can create this control either by specifying the HTML tag <monster-collapse />` directly in the HTML or using
90
- * Javascript via the `document.createElement('monster-collapse');` method.
91
- *
92
- * ```html
93
- * <monster-collapse></monster-collapse>
94
- * ```
95
- *
96
- * Or you can create this CustomControl directly in Javascript:
97
- *
98
- * ```js
99
- * import '@schukai/monster/source/components/host/collapse.mjs';
100
- * document.createElement('monster-collapse');
101
- * ```
102
- *
103
- * The Body should have a class "hidden" to ensure that the styles are applied correctly.
104
- *
105
- * ```css
106
- * body.hidden {
107
- * visibility: hidden;
108
- * }
109
- * ```
110
- *
111
- * @startuml collapse.png
112
- * skinparam monochrome true
113
- * skinparam shadowing false
114
- * HTMLElement <|-- CustomElement
115
- * CustomElement <|-- Collapse
116
- * @enduml
87
+ * @example /examples/components/layout/collapse-simple
117
88
  *
89
+ * @since 3.74.0
118
90
  * @copyright schukai GmbH
119
- * @memberOf Monster.Components.Host
120
- * @summary A simple collapse component
121
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-before-open
122
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-open
123
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-before-close
124
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-closed
125
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-adjust-height
91
+ * @summary A simple collapse component.
126
92
  */
127
93
  class Collapse extends CustomElement {
128
- /**
129
- * This method is called by the `instanceof` operator.
130
- * @returns {symbol}
131
- */
132
- static get [instanceSymbol]() {
133
- return Symbol.for("@schukai/monster/components/layout/collapse@@instance");
134
- }
135
-
136
- /**
137
- *
138
- */
139
- constructor() {
140
- super();
141
- // the name is only used for the host config and the event name
142
- this[nameSymbol] = "collapse";
143
- }
144
-
145
- /**
146
- * To set the options via the html tag the attribute `data-monster-options` must be used.
147
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
148
- *
149
- * The individual configuration values can be found in the table.
150
- *
151
- * @property {Object} templates Template definitions
152
- * @property {string} templates.main Main template
153
- * @property {Object} classes CSS classes
154
- * @property {string} classes.container CSS class for the container
155
- * @property {Object} features Feature configuration
156
- * @property {boolean} features.accordion Enable accordion mode
157
- * @property {boolean} features.persistState Enable persist state (Host and Config-Manager required)
158
- * @property {boolean} features.useScrollValues Use scroll values (scrollHeight) instead of clientHeight for the height calculation
159
- * @property {boolean} openByDefault Open the details by default
160
- */
161
- get defaults() {
162
- return Object.assign({}, super.defaults, {
163
- templates: {
164
- main: getTemplate(),
165
- },
166
- classes: {
167
- container: "padding",
168
- },
169
- features: {
170
- accordion: true,
171
- persistState: true,
172
- useScrollValues: false,
173
- },
174
- openByDefault: false,
175
- });
176
- }
177
-
178
- /**
179
- *
180
- * @returns {Monster.Components.Host.Collapse}
181
- */
182
- [assembleMethodSymbol]() {
183
- super[assembleMethodSymbol]();
184
- initControlReferences.call(this);
185
- initStateFromHostConfig.call(this);
186
- initResizeObserver.call(this);
187
- initEventHandler.call(this);
188
-
189
- if (this.getOption("openByDefault")) {
190
- this.open();
191
- }
192
- }
193
-
194
- /**
195
- *
196
- */
197
- connectedCallback() {
198
- super.connectedCallback();
199
- updateResizeObserverObservation.call(this);
200
- // this[resizeObserverSymbol].observe(getDocument().body);
201
- }
202
-
203
- /**
204
- *
205
- */
206
- disconnectedCallback() {
207
- super.disconnectedCallback();
208
- //this[resizeObserverSymbol].disconnect();
209
- }
210
-
211
- /**
212
- *
213
- * @returns {Monster.Components.Host.Collapse}
214
- */
215
- toggle() {
216
- if (this[detailsElementSymbol].classList.contains("active")) {
217
- this.close();
218
- } else {
219
- this.open();
220
- }
221
- return this;
222
- }
223
-
224
- /**
225
- *
226
- * @returns {boolean}
227
- */
228
- isClosed() {
229
- return !this[detailsElementSymbol].classList.contains("active");
230
- }
231
-
232
- /**
233
- *
234
- * @returns {boolean}
235
- */
236
- isOpen() {
237
- return !this.isClosed();
238
- }
239
-
240
- /**
241
- *
242
- * @returns {Monster.Components.Host.Collapse}
243
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-before-open
244
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-open
245
- */
246
- open() {
247
- let node;
248
- if (this[detailsElementSymbol].classList.contains("active")) {
249
- return this;
250
- }
251
-
252
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-open", {});
253
-
254
- adjustHeight.call(this);
255
- this[detailsElementSymbol].classList.add("active");
256
-
257
- if (this.getOption("features.accordion") === true) {
258
- node = this;
259
- while (node.nextElementSibling instanceof Collapse) {
260
- node = node.nextElementSibling;
261
- node.close();
262
- }
263
-
264
- node = this;
265
- while (node.previousElementSibling instanceof Collapse) {
266
- node = node.previousElementSibling;
267
- node.close();
268
- }
269
- }
270
-
271
- setTimeout(() => {
272
- setTimeout(() => {
273
- updateStateConfig.call(this);
274
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-open", {});
275
- setTimeout(() => {
276
- this[controlElementSymbol].classList.remove("overflow-hidden");
277
- }, 500);
278
- }, 0);
279
- }, 0);
280
-
281
- return this;
282
- }
283
-
284
- /**
285
- *
286
- * @returns {Monster.Components.Host.Collapse}
287
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-before-close
288
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-closed
289
- */
290
- close() {
291
- if (!this[detailsElementSymbol].classList.contains("active")) {
292
- return this;
293
- }
294
-
295
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-close", {});
296
- this[controlElementSymbol].classList.add("overflow-hidden");
297
-
298
- setTimeout(() => {
299
- this[detailsElementSymbol].classList.remove("active");
300
- setTimeout(() => {
301
- updateStateConfig.call(this);
302
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-closed", {});
303
- }, 0);
304
- }, 0);
305
-
306
- return this;
307
- }
308
-
309
- /**
310
- *
311
- * @return {string}
312
- */
313
- static getTag() {
314
- return "monster-collapse";
315
- }
316
-
317
- /**
318
- * @return {Array<CSSStyleSheet>}
319
- */
320
- static getCSSStyleSheet() {
321
- return [CollapseStyleSheet];
322
- }
323
-
324
- /**
325
- * This method is called when the element is inserted into a document, including into a shadow tree.
326
- * @return {Monster.Components.Host.Collapse}
327
- * @fires Monster.Components.Host.Collapse.event:monster-collapse-adjust-height
328
- */
329
- adjustHeight() {
330
- adjustHeight.call(this);
331
- return this;
332
- }
94
+ /**
95
+ * This method is called by the `instanceof` operator.
96
+ * @returns {symbol}
97
+ */
98
+ static get [instanceSymbol]() {
99
+ return Symbol.for("@schukai/monster/components/layout/collapse@@instance");
100
+ }
101
+
102
+ /**
103
+ *
104
+ */
105
+ constructor() {
106
+ super();
107
+ // the name is only used for the host config and the event name
108
+ this[nameSymbol] = "collapse";
109
+ }
110
+
111
+ /**
112
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
113
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
114
+ *
115
+ * The individual configuration values can be found in the table.
116
+ *
117
+ * @property {Object} templates Template definitions
118
+ * @property {string} templates.main Main template
119
+ * @property {Object} classes CSS classes
120
+ * @property {string} classes.container CSS class for the container
121
+ * @property {Object} features Feature configuration
122
+ * @property {boolean} features.accordion Enable accordion mode
123
+ * @property {boolean} features.persistState Enable persist state (Host and Config-Manager required)
124
+ * @property {boolean} features.useScrollValues Use scroll values (scrollHeight) instead of clientHeight for the height calculation
125
+ * @property {boolean} openByDefault Open the details by default
126
+ */
127
+ get defaults() {
128
+ return Object.assign({}, super.defaults, {
129
+ templates: {
130
+ main: getTemplate(),
131
+ },
132
+ classes: {
133
+ container: "padding",
134
+ },
135
+ features: {
136
+ accordion: true,
137
+ persistState: true,
138
+ useScrollValues: false,
139
+ },
140
+ openByDefault: false,
141
+ });
142
+ }
143
+
144
+ /**
145
+ *
146
+ * @returns {Monster.Components.Host.Collapse}
147
+ */
148
+ [assembleMethodSymbol]() {
149
+ super[assembleMethodSymbol]();
150
+ initControlReferences.call(this);
151
+ initStateFromHostConfig.call(this);
152
+ initResizeObserver.call(this);
153
+ initEventHandler.call(this);
154
+
155
+ if (this.getOption("openByDefault")) {
156
+ this.open();
157
+ }
158
+ }
159
+
160
+ /**
161
+ *
162
+ */
163
+ connectedCallback() {
164
+ super.connectedCallback();
165
+ updateResizeObserverObservation.call(this);
166
+ // this[resizeObserverSymbol].observe(getDocument().body);
167
+ }
168
+
169
+ /**
170
+ *
171
+ */
172
+ disconnectedCallback() {
173
+ super.disconnectedCallback();
174
+ //this[resizeObserverSymbol].disconnect();
175
+ }
176
+
177
+ /**
178
+ *
179
+ * @returns {Monster.Components.Host.Collapse}
180
+ */
181
+ toggle() {
182
+ if (this[detailsElementSymbol].classList.contains("active")) {
183
+ this.close();
184
+ } else {
185
+ this.open();
186
+ }
187
+ return this;
188
+ }
189
+
190
+ /**
191
+ *
192
+ * @returns {boolean}
193
+ */
194
+ isClosed() {
195
+ return !this[detailsElementSymbol].classList.contains("active");
196
+ }
197
+
198
+ /**
199
+ *
200
+ * @returns {boolean}
201
+ */
202
+ isOpen() {
203
+ return !this.isClosed();
204
+ }
205
+
206
+ /**
207
+ *
208
+ * @returns {Monster.Components.Host.Collapse}
209
+ * @fires Monster.Components.Host.Collapse.event:monster-collapse-before-open
210
+ * @fires Monster.Components.Host.Collapse.event:monster-collapse-open
211
+ */
212
+ open() {
213
+ let node;
214
+ if (this[detailsElementSymbol].classList.contains("active")) {
215
+ return this;
216
+ }
217
+
218
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-open", {});
219
+
220
+ adjustHeight.call(this);
221
+ this[detailsElementSymbol].classList.add("active");
222
+
223
+ if (this.getOption("features.accordion") === true) {
224
+ node = this;
225
+ while (node.nextElementSibling instanceof Collapse) {
226
+ node = node.nextElementSibling;
227
+ node.close();
228
+ }
229
+
230
+ node = this;
231
+ while (node.previousElementSibling instanceof Collapse) {
232
+ node = node.previousElementSibling;
233
+ node.close();
234
+ }
235
+ }
236
+
237
+ setTimeout(() => {
238
+ setTimeout(() => {
239
+ updateStateConfig.call(this);
240
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-open", {});
241
+ setTimeout(() => {
242
+ this[controlElementSymbol].classList.remove("overflow-hidden");
243
+ }, 500);
244
+ }, 0);
245
+ }, 0);
246
+
247
+ return this;
248
+ }
249
+
250
+ /**
251
+ *
252
+ * @returns {Monster.Components.Host.Collapse}
253
+ * @fires Monster.Components.Host.Collapse.event:monster-collapse-before-close
254
+ * @fires Monster.Components.Host.Collapse.event:monster-collapse-closed
255
+ */
256
+ close() {
257
+ if (!this[detailsElementSymbol].classList.contains("active")) {
258
+ return this;
259
+ }
260
+
261
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-close", {});
262
+ this[controlElementSymbol].classList.add("overflow-hidden");
263
+
264
+ setTimeout(() => {
265
+ this[detailsElementSymbol].classList.remove("active");
266
+ setTimeout(() => {
267
+ updateStateConfig.call(this);
268
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-closed", {});
269
+ }, 0);
270
+ }, 0);
271
+
272
+ return this;
273
+ }
274
+
275
+ /**
276
+ *
277
+ * @return {string}
278
+ */
279
+ static getTag() {
280
+ return "monster-collapse";
281
+ }
282
+
283
+ /**
284
+ * @return {Array<CSSStyleSheet>}
285
+ */
286
+ static getCSSStyleSheet() {
287
+ return [CollapseStyleSheet];
288
+ }
289
+
290
+ /**
291
+ * This method is called when the element is inserted into a document, including into a shadow tree.
292
+ * @return {Monster.Components.Host.Collapse}
293
+ * @fires Monster.Components.Host.Collapse.event:monster-collapse-adjust-height
294
+ */
295
+ adjustHeight() {
296
+ adjustHeight.call(this);
297
+ return this;
298
+ }
333
299
  }
334
300
 
335
301
  function adjustHeight() {
336
- let height = 0;
337
-
338
- if (this[detailsContainerElementSymbol]) {
339
- if (this.getOption("features.useScrollValues")) {
340
- height += this[detailsContainerElementSymbol].scrollHeight;
341
- } else {
342
- height += this[detailsContainerElementSymbol].clientHeight;
343
- }
344
- }
345
-
346
- if (this[detailsDecoElementSymbol]) {
347
- if (this.getOption("features.useScrollValues")) {
348
- height += this[detailsDecoElementSymbol].scrollHeight;
349
- } else {
350
- height += this[detailsDecoElementSymbol].clientHeight + 1;
351
- }
352
- }
353
-
354
- if (height === 0) {
355
- if (this.getOption("features.useScrollValues")) {
356
- height = this[detailsElementSymbol].scrollHeight;
357
- } else {
358
- height = this[detailsElementSymbol].clientHeight;
359
- }
360
-
361
- if (height === 0) {
362
- height = "auto";
363
- }
364
- } else {
365
- height += "px";
366
- }
367
-
368
- this[detailsElementSymbol].style.setProperty(
369
- "--monster-height",
370
- height,
371
- "important",
372
- );
373
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-adjust-height", {});
302
+ let height = 0;
303
+
304
+ if (this[detailsContainerElementSymbol]) {
305
+ if (this.getOption("features.useScrollValues")) {
306
+ height += this[detailsContainerElementSymbol].scrollHeight;
307
+ } else {
308
+ height += this[detailsContainerElementSymbol].clientHeight;
309
+ }
310
+ }
311
+
312
+ if (this[detailsDecoElementSymbol]) {
313
+ if (this.getOption("features.useScrollValues")) {
314
+ height += this[detailsDecoElementSymbol].scrollHeight;
315
+ } else {
316
+ height += this[detailsDecoElementSymbol].clientHeight + 1;
317
+ }
318
+ }
319
+
320
+ if (height === 0) {
321
+ if (this.getOption("features.useScrollValues")) {
322
+ height = this[detailsElementSymbol].scrollHeight;
323
+ } else {
324
+ height = this[detailsElementSymbol].clientHeight;
325
+ }
326
+
327
+ if (height === 0) {
328
+ height = "auto";
329
+ }
330
+ } else {
331
+ height += "px";
332
+ }
333
+
334
+ this[detailsElementSymbol].style.setProperty(
335
+ "--monster-height",
336
+ height,
337
+ "important",
338
+ );
339
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-adjust-height", {});
374
340
  }
375
341
 
376
342
  function updateResizeObserverObservation() {
377
- this[resizeObserverSymbol].disconnect();
343
+ this[resizeObserverSymbol].disconnect();
378
344
 
379
- const slottedNodes = getSlottedElements.call(this);
380
- slottedNodes.forEach((node) => {
381
- this[resizeObserverSymbol].observe(node);
382
- });
345
+ const slottedNodes = getSlottedElements.call(this);
346
+ slottedNodes.forEach((node) => {
347
+ this[resizeObserverSymbol].observe(node);
348
+ });
383
349
 
384
- if (this[detailsContainerElementSymbol]) {
385
- this[resizeObserverSymbol].observe(this[detailsContainerElementSymbol]);
386
- }
350
+ if (this[detailsContainerElementSymbol]) {
351
+ this[resizeObserverSymbol].observe(this[detailsContainerElementSymbol]);
352
+ }
387
353
 
388
- this.adjustHeight();
354
+ this.adjustHeight();
389
355
  }
390
356
 
391
357
  /**
392
358
  * @private
393
359
  */
394
360
  function initEventHandler() {
395
- if (!this.shadowRoot) {
396
- throw new Error("no shadow-root is defined");
397
- }
361
+ if (!this.shadowRoot) {
362
+ throw new Error("no shadow-root is defined");
363
+ }
398
364
 
399
- initSlotChangedHandler.call(this);
400
- return this;
365
+ initSlotChangedHandler.call(this);
366
+ return this;
401
367
  }
402
368
 
403
369
  function initSlotChangedHandler() {
404
- this[detailsSlotElementSymbol].addEventListener("slotchange", () => {
405
- updateResizeObserverObservation.call(this);
406
- });
370
+ this[detailsSlotElementSymbol].addEventListener("slotchange", () => {
371
+ updateResizeObserverObservation.call(this);
372
+ });
407
373
  }
408
374
 
409
375
  /**
@@ -412,23 +378,23 @@ function initSlotChangedHandler() {
412
378
  * @throws {Error} no shadow-root is defined
413
379
  */
414
380
  function initControlReferences() {
415
- if (!this.shadowRoot) {
416
- throw new Error("no shadow-root is defined");
417
- }
418
-
419
- this[controlElementSymbol] = this.shadowRoot.querySelector(
420
- "[data-monster-role=control]",
421
- );
422
- this[detailsElementSymbol] = this.shadowRoot.querySelector(
423
- "[data-monster-role=detail]",
424
- );
425
- this[detailsSlotElementSymbol] = this.shadowRoot.querySelector("slot");
426
- this[detailsContainerElementSymbol] = this.shadowRoot.querySelector(
427
- "[data-monster-role=container]",
428
- );
429
- this[detailsDecoElementSymbol] = this.shadowRoot.querySelector(
430
- "[data-monster-role=deco]",
431
- );
381
+ if (!this.shadowRoot) {
382
+ throw new Error("no shadow-root is defined");
383
+ }
384
+
385
+ this[controlElementSymbol] = this.shadowRoot.querySelector(
386
+ "[data-monster-role=control]",
387
+ );
388
+ this[detailsElementSymbol] = this.shadowRoot.querySelector(
389
+ "[data-monster-role=detail]",
390
+ );
391
+ this[detailsSlotElementSymbol] = this.shadowRoot.querySelector("slot");
392
+ this[detailsContainerElementSymbol] = this.shadowRoot.querySelector(
393
+ "[data-monster-role=container]",
394
+ );
395
+ this[detailsDecoElementSymbol] = this.shadowRoot.querySelector(
396
+ "[data-monster-role=deco]",
397
+ );
432
398
  }
433
399
 
434
400
  /**
@@ -436,34 +402,34 @@ function initControlReferences() {
436
402
  * @returns {string}
437
403
  */
438
404
  function getConfigKey() {
439
- return generateUniqueConfigKey(this[nameSymbol], this.id, "state");
405
+ return generateUniqueConfigKey(this[nameSymbol], this.id, "state");
440
406
  }
441
407
 
442
408
  /**
443
409
  * @private
444
410
  */
445
411
  function updateStateConfig() {
446
- if (!this.getOption("features.persistState")) {
447
- return;
448
- }
449
-
450
- if (!this[detailsElementSymbol]) {
451
- return;
452
- }
453
-
454
- const document = getDocument();
455
- const host = document.querySelector("monster-host");
456
- if (!(host && this.id)) {
457
- return;
458
- }
459
-
460
- const configKey = getConfigKey.call(this);
461
-
462
- try {
463
- host.setConfig(configKey, this.isOpen());
464
- } catch (error) {
465
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
466
- }
412
+ if (!this.getOption("features.persistState")) {
413
+ return;
414
+ }
415
+
416
+ if (!this[detailsElementSymbol]) {
417
+ return;
418
+ }
419
+
420
+ const document = getDocument();
421
+ const host = document.querySelector("monster-host");
422
+ if (!(host && this.id)) {
423
+ return;
424
+ }
425
+
426
+ const configKey = getConfigKey.call(this);
427
+
428
+ try {
429
+ host.setConfig(configKey, this.isOpen());
430
+ } catch (error) {
431
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
432
+ }
467
433
  }
468
434
 
469
435
  /**
@@ -471,55 +437,55 @@ function updateStateConfig() {
471
437
  * @returns {Promise}
472
438
  */
473
439
  function initStateFromHostConfig() {
474
- if (!this.getOption("features.persistState")) {
475
- return Promise.resolve({});
476
- }
477
-
478
- const document = getDocument();
479
- const host = document.querySelector("monster-host");
480
-
481
- if (!(host && this.id)) {
482
- return Promise.resolve({});
483
- }
484
-
485
- const configKey = getConfigKey.call(this);
486
- return host
487
- .getConfig(configKey)
488
- .then((state) => {
489
- if (state === true) {
490
- this.open();
491
- } else {
492
- this.close();
493
- }
494
- })
495
- .catch((error) => {
496
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
497
- });
440
+ if (!this.getOption("features.persistState")) {
441
+ return Promise.resolve({});
442
+ }
443
+
444
+ const document = getDocument();
445
+ const host = document.querySelector("monster-host");
446
+
447
+ if (!(host && this.id)) {
448
+ return Promise.resolve({});
449
+ }
450
+
451
+ const configKey = getConfigKey.call(this);
452
+ return host
453
+ .getConfig(configKey)
454
+ .then((state) => {
455
+ if (state === true) {
456
+ this.open();
457
+ } else {
458
+ this.close();
459
+ }
460
+ })
461
+ .catch((error) => {
462
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
463
+ });
498
464
  }
499
465
 
500
466
  /**
501
467
  * @private
502
468
  */
503
469
  function initResizeObserver() {
504
- // against flickering
505
- this[resizeObserverSymbol] = new ResizeObserver((entries) => {
506
- if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
507
- try {
508
- this[timerCallbackSymbol].touch();
509
- return;
510
- } catch (e) {
511
- delete this[timerCallbackSymbol];
512
- }
513
- }
514
-
515
- this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
516
- checkAndRearrangeContent.call(this);
517
- });
518
- });
470
+ // against flickering
471
+ this[resizeObserverSymbol] = new ResizeObserver((entries) => {
472
+ if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
473
+ try {
474
+ this[timerCallbackSymbol].touch();
475
+ return;
476
+ } catch (e) {
477
+ delete this[timerCallbackSymbol];
478
+ }
479
+ }
480
+
481
+ this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
482
+ checkAndRearrangeContent.call(this);
483
+ });
484
+ });
519
485
  }
520
486
 
521
487
  function checkAndRearrangeContent() {
522
- this.adjustHeight();
488
+ this.adjustHeight();
523
489
  }
524
490
 
525
491
  /**
@@ -527,8 +493,8 @@ function checkAndRearrangeContent() {
527
493
  * @return {string}
528
494
  */
529
495
  function getTemplate() {
530
- // language=HTML
531
- return `
496
+ // language=HTML
497
+ return `
532
498
  <div data-monster-role="control" part="control" class="overflow-hidden">
533
499
  <div data-monster-role="detail">
534
500
  <div data-monster-attributes="class path:classes.container" part="container"