@schukai/monster 3.79.0 → 3.80.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.json +1 -1
  3. package/source/components/content/copy.mjs +314 -312
  4. package/source/components/content/stylesheet/copy.mjs +13 -6
  5. package/source/components/form/field-set.mjs +1 -2
  6. package/source/components/form/select.mjs +1945 -1957
  7. package/source/components/form/stylesheet/field-set.mjs +13 -6
  8. package/source/components/form/toggle-switch.mjs +319 -319
  9. package/source/components/layout/collapse.mjs +351 -351
  10. package/source/components/layout/details.mjs +1 -1
  11. package/source/components/layout/iframe.mjs +1 -1
  12. package/source/components/layout/width-toggle.mjs +2 -3
  13. package/source/components/state/log.mjs +151 -152
  14. package/source/components/state/state.mjs +1 -1
  15. package/source/components/stylesheet/form.mjs +13 -6
  16. package/source/components/tree-menu/dragable-tree-menu.mjs +664 -664
  17. package/source/components/tree-menu/tree-menu.mjs +3 -27
  18. package/source/dom/customelement.mjs +18 -1
  19. package/source/monster.mjs +1 -1
  20. package/source/types/base.mjs +1 -3
  21. package/source/types/nodelist.mjs +0 -1
  22. package/source/types/proxyobserver.mjs +0 -2
  23. package/source/types/queue.mjs +0 -2
  24. package/source/types/randomid.mjs +0 -1
  25. package/source/types/regex.mjs +0 -1
  26. package/source/types/stack.mjs +1 -2
  27. package/source/types/tokenlist.mjs +0 -2
  28. package/source/types/typeof.mjs +0 -2
  29. package/source/types/uniquequeue.mjs +0 -1
  30. package/source/types/uuid.mjs +1 -2
  31. package/source/types/version.mjs +3 -6
  32. package/test/cases/monster.mjs +1 -1
  33. package/test/util/jsdom.mjs +0 -2
  34. package/test/web/test.html +2 -2
  35. package/test/web/tests.js +7455 -8361
@@ -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
@@ -91,205 +91,205 @@ const nameSymbol = Symbol("name");
91
91
  * @summary A simple collapse component.
92
92
  */
93
93
  class Collapse extends CustomElement {
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 {void}
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
- * @returns {void}
162
- */
163
- connectedCallback() {
164
- super.connectedCallback();
165
- updateResizeObserverObservation.call(this);
166
- }
167
-
168
- /**
169
- * @returns {void}
170
- */
171
- disconnectedCallback() {
172
- super.disconnectedCallback();
173
- }
174
-
175
- /**
176
- * @returns {Collapse}
177
- */
178
- toggle() {
179
- if (this[detailsElementSymbol].classList.contains("active")) {
180
- this.close();
181
- } else {
182
- this.open();
183
- }
184
- return this;
185
- }
186
-
187
- /**
188
- * @returns {boolean}
189
- */
190
- isClosed() {
191
- return !this[detailsElementSymbol].classList.contains("active");
192
- }
193
-
194
- /**
195
- * @returns {boolean}
196
- */
197
- isOpen() {
198
- return !this.isClosed();
199
- }
200
-
201
- /**
202
- * Open the collapse
203
- * @returns {Collapse}
204
- * @fires event:monster-collapse-before-open
205
- * @fires event:monster-collapse-open
206
- */
207
- open() {
208
- let node;
209
- if (this[detailsElementSymbol].classList.contains("active")) {
210
- return this;
211
- }
212
-
213
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-open", {});
214
-
215
- adjustHeight.call(this);
216
- this[detailsElementSymbol].classList.add("active");
217
-
218
- if (this.getOption("features.accordion") === true) {
219
- node = this;
220
- while (node.nextElementSibling instanceof Collapse) {
221
- node = node.nextElementSibling;
222
- node.close();
223
- }
224
-
225
- node = this;
226
- while (node.previousElementSibling instanceof Collapse) {
227
- node = node.previousElementSibling;
228
- node.close();
229
- }
230
- }
231
-
232
- setTimeout(() => {
233
- setTimeout(() => {
234
- updateStateConfig.call(this);
235
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-open", {});
236
- setTimeout(() => {
237
- this[controlElementSymbol].classList.remove("overflow-hidden");
238
- }, 500);
239
- }, 0);
240
- }, 0);
241
-
242
- return this;
243
- }
244
-
245
- /**
246
- * Close the collapse
247
- * @returns {Collapse}
248
- * @fires event:monster-collapse-before-close
249
- * @fires event:monster-collapse-closed
250
- */
251
- close() {
252
- if (!this[detailsElementSymbol].classList.contains("active")) {
253
- return this;
254
- }
255
-
256
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-close", {});
257
- this[controlElementSymbol].classList.add("overflow-hidden");
258
-
259
- setTimeout(() => {
260
- this[detailsElementSymbol].classList.remove("active");
261
- setTimeout(() => {
262
- updateStateConfig.call(this);
263
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-closed", {});
264
- }, 0);
265
- }, 0);
266
-
267
- return this;
268
- }
269
-
270
- /**
271
- * @return {string}
272
- */
273
- static getTag() {
274
- return "monster-collapse";
275
- }
276
-
277
- /**
278
- * @return {Array<CSSStyleSheet>}
279
- */
280
- static getCSSStyleSheet() {
281
- return [CollapseStyleSheet];
282
- }
283
-
284
- /**
285
- * This method is called when the element is inserted into a document, including into a shadow tree.
286
- * @return {Collapse}
287
- * @fires event:monster-collapse-adjust-height
288
- */
289
- adjustHeight() {
290
- adjustHeight.call(this);
291
- return this;
292
- }
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 {void}
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
+ * @returns {void}
162
+ */
163
+ connectedCallback() {
164
+ super.connectedCallback();
165
+ updateResizeObserverObservation.call(this);
166
+ }
167
+
168
+ /**
169
+ * @returns {void}
170
+ */
171
+ disconnectedCallback() {
172
+ super.disconnectedCallback();
173
+ }
174
+
175
+ /**
176
+ * @returns {Collapse}
177
+ */
178
+ toggle() {
179
+ if (this[detailsElementSymbol].classList.contains("active")) {
180
+ this.close();
181
+ } else {
182
+ this.open();
183
+ }
184
+ return this;
185
+ }
186
+
187
+ /**
188
+ * @returns {boolean}
189
+ */
190
+ isClosed() {
191
+ return !this[detailsElementSymbol].classList.contains("active");
192
+ }
193
+
194
+ /**
195
+ * @returns {boolean}
196
+ */
197
+ isOpen() {
198
+ return !this.isClosed();
199
+ }
200
+
201
+ /**
202
+ * Open the collapse
203
+ * @returns {Collapse}
204
+ * @fires event:monster-collapse-before-open
205
+ * @fires event:monster-collapse-open
206
+ */
207
+ open() {
208
+ let node;
209
+ if (this[detailsElementSymbol].classList.contains("active")) {
210
+ return this;
211
+ }
212
+
213
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-open", {});
214
+
215
+ adjustHeight.call(this);
216
+ this[detailsElementSymbol].classList.add("active");
217
+
218
+ if (this.getOption("features.accordion") === true) {
219
+ node = this;
220
+ while (node.nextElementSibling instanceof Collapse) {
221
+ node = node.nextElementSibling;
222
+ node.close();
223
+ }
224
+
225
+ node = this;
226
+ while (node.previousElementSibling instanceof Collapse) {
227
+ node = node.previousElementSibling;
228
+ node.close();
229
+ }
230
+ }
231
+
232
+ setTimeout(() => {
233
+ setTimeout(() => {
234
+ updateStateConfig.call(this);
235
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-open", {});
236
+ setTimeout(() => {
237
+ this[controlElementSymbol].classList.remove("overflow-hidden");
238
+ }, 500);
239
+ }, 0);
240
+ }, 0);
241
+
242
+ return this;
243
+ }
244
+
245
+ /**
246
+ * Close the collapse
247
+ * @returns {Collapse}
248
+ * @fires event:monster-collapse-before-close
249
+ * @fires event:monster-collapse-closed
250
+ */
251
+ close() {
252
+ if (!this[detailsElementSymbol].classList.contains("active")) {
253
+ return this;
254
+ }
255
+
256
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-before-close", {});
257
+ this[controlElementSymbol].classList.add("overflow-hidden");
258
+
259
+ setTimeout(() => {
260
+ this[detailsElementSymbol].classList.remove("active");
261
+ setTimeout(() => {
262
+ updateStateConfig.call(this);
263
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-closed", {});
264
+ }, 0);
265
+ }, 0);
266
+
267
+ return this;
268
+ }
269
+
270
+ /**
271
+ * @return {string}
272
+ */
273
+ static getTag() {
274
+ return "monster-collapse";
275
+ }
276
+
277
+ /**
278
+ * @return {Array<CSSStyleSheet>}
279
+ */
280
+ static getCSSStyleSheet() {
281
+ return [CollapseStyleSheet];
282
+ }
283
+
284
+ /**
285
+ * This method is called when the element is inserted into a document, including into a shadow tree.
286
+ * @return {Collapse}
287
+ * @fires event:monster-collapse-adjust-height
288
+ */
289
+ adjustHeight() {
290
+ adjustHeight.call(this);
291
+ return this;
292
+ }
293
293
  }
294
294
 
295
295
  /**
@@ -298,78 +298,78 @@ class Collapse extends CustomElement {
298
298
  * @fires event:monster-collapse-adjust-height
299
299
  */
300
300
  function adjustHeight() {
301
- let height = 0;
302
-
303
- if (this[detailsContainerElementSymbol]) {
304
- if (this.getOption("features.useScrollValues")) {
305
- height += this[detailsContainerElementSymbol].scrollHeight;
306
- } else {
307
- height += this[detailsContainerElementSymbol].clientHeight;
308
- }
309
- }
310
-
311
- if (this[detailsDecoElementSymbol]) {
312
- if (this.getOption("features.useScrollValues")) {
313
- height += this[detailsDecoElementSymbol].scrollHeight;
314
- } else {
315
- height += this[detailsDecoElementSymbol].clientHeight + 1;
316
- }
317
- }
318
-
319
- if (height === 0) {
320
- if (this.getOption("features.useScrollValues")) {
321
- height = this[detailsElementSymbol].scrollHeight;
322
- } else {
323
- height = this[detailsElementSymbol].clientHeight;
324
- }
325
-
326
- if (height === 0) {
327
- height = "auto";
328
- }
329
- } else {
330
- height += "px";
331
- }
332
-
333
- this[detailsElementSymbol].style.setProperty(
334
- "--monster-height",
335
- height,
336
- "important",
337
- );
338
-
339
- fireCustomEvent(this, "monster-" + this[nameSymbol] + "-adjust-height", {});
301
+ let height = 0;
302
+
303
+ if (this[detailsContainerElementSymbol]) {
304
+ if (this.getOption("features.useScrollValues")) {
305
+ height += this[detailsContainerElementSymbol].scrollHeight;
306
+ } else {
307
+ height += this[detailsContainerElementSymbol].clientHeight;
308
+ }
309
+ }
310
+
311
+ if (this[detailsDecoElementSymbol]) {
312
+ if (this.getOption("features.useScrollValues")) {
313
+ height += this[detailsDecoElementSymbol].scrollHeight;
314
+ } else {
315
+ height += this[detailsDecoElementSymbol].clientHeight + 1;
316
+ }
317
+ }
318
+
319
+ if (height === 0) {
320
+ if (this.getOption("features.useScrollValues")) {
321
+ height = this[detailsElementSymbol].scrollHeight;
322
+ } else {
323
+ height = this[detailsElementSymbol].clientHeight;
324
+ }
325
+
326
+ if (height === 0) {
327
+ height = "auto";
328
+ }
329
+ } else {
330
+ height += "px";
331
+ }
332
+
333
+ this[detailsElementSymbol].style.setProperty(
334
+ "--monster-height",
335
+ height,
336
+ "important",
337
+ );
338
+
339
+ fireCustomEvent(this, "monster-" + this[nameSymbol] + "-adjust-height", {});
340
340
  }
341
341
 
342
342
  function updateResizeObserverObservation() {
343
- this[resizeObserverSymbol].disconnect();
343
+ this[resizeObserverSymbol].disconnect();
344
344
 
345
- const slottedNodes = getSlottedElements.call(this);
346
- slottedNodes.forEach((node) => {
347
- this[resizeObserverSymbol].observe(node);
348
- });
345
+ const slottedNodes = getSlottedElements.call(this);
346
+ slottedNodes.forEach((node) => {
347
+ this[resizeObserverSymbol].observe(node);
348
+ });
349
349
 
350
- if (this[detailsContainerElementSymbol]) {
351
- this[resizeObserverSymbol].observe(this[detailsContainerElementSymbol]);
352
- }
350
+ if (this[detailsContainerElementSymbol]) {
351
+ this[resizeObserverSymbol].observe(this[detailsContainerElementSymbol]);
352
+ }
353
353
 
354
- this.adjustHeight();
354
+ this.adjustHeight();
355
355
  }
356
356
 
357
357
  /**
358
358
  * @private
359
359
  */
360
360
  function initEventHandler() {
361
- if (!this.shadowRoot) {
362
- throw new Error("no shadow-root is defined");
363
- }
361
+ if (!this.shadowRoot) {
362
+ throw new Error("no shadow-root is defined");
363
+ }
364
364
 
365
- initSlotChangedHandler.call(this);
366
- return this;
365
+ initSlotChangedHandler.call(this);
366
+ return this;
367
367
  }
368
368
 
369
369
  function initSlotChangedHandler() {
370
- this[detailsSlotElementSymbol].addEventListener("slotchange", () => {
371
- updateResizeObserverObservation.call(this);
372
- });
370
+ this[detailsSlotElementSymbol].addEventListener("slotchange", () => {
371
+ updateResizeObserverObservation.call(this);
372
+ });
373
373
  }
374
374
 
375
375
  /**
@@ -378,23 +378,23 @@ function initSlotChangedHandler() {
378
378
  * @throws {Error} no shadow-root is defined
379
379
  */
380
380
  function initControlReferences() {
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
- );
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
+ );
398
398
  }
399
399
 
400
400
  /**
@@ -402,34 +402,34 @@ function initControlReferences() {
402
402
  * @returns {string}
403
403
  */
404
404
  function getConfigKey() {
405
- return generateUniqueConfigKey(this[nameSymbol], this.id, "state");
405
+ return generateUniqueConfigKey(this[nameSymbol], this.id, "state");
406
406
  }
407
407
 
408
408
  /**
409
409
  * @private
410
410
  */
411
411
  function updateStateConfig() {
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
- }
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
+ }
433
433
  }
434
434
 
435
435
  /**
@@ -437,55 +437,55 @@ function updateStateConfig() {
437
437
  * @returns {Promise}
438
438
  */
439
439
  function initStateFromHostConfig() {
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
- });
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
+ });
464
464
  }
465
465
 
466
466
  /**
467
467
  * @private
468
468
  */
469
469
  function initResizeObserver() {
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
- });
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
+ });
485
485
  }
486
486
 
487
487
  function checkAndRearrangeContent() {
488
- this.adjustHeight();
488
+ this.adjustHeight();
489
489
  }
490
490
 
491
491
  /**
@@ -493,8 +493,8 @@ function checkAndRearrangeContent() {
493
493
  * @return {string}
494
494
  */
495
495
  function getTemplate() {
496
- // language=HTML
497
- return `
496
+ // language=HTML
497
+ return `
498
498
  <div data-monster-role="control" part="control" class="overflow-hidden">
499
499
  <div data-monster-role="detail">
500
500
  <div data-monster-attributes="class path:classes.container" part="container"