@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.
- package/CHANGELOG.md +21 -8
- package/package.json +1 -1
- package/source/components/layout/collapse.mjs +361 -395
- package/source/components/layout/details.mjs +10 -40
- package/source/components/layout/iframe.mjs +358 -0
- package/source/components/layout/panel.mjs +10 -25
- package/source/components/layout/slider.mjs +11 -11
- package/source/components/layout/split-panel.mjs +7 -39
- package/source/components/layout/style/iframe.pcss +39 -0
- package/source/components/layout/style/panel.pcss +10 -3
- package/source/components/layout/style/split-panel.pcss +2 -0
- package/source/components/layout/stylesheet/iframe.mjs +38 -0
- package/source/components/layout/stylesheet/panel.mjs +1 -1
- package/source/components/layout/tabs.mjs +6 -35
- package/source/components/layout/width-toggle.mjs +10 -31
- package/source/components/tree-menu/tree-menu.mjs +16 -12
- package/source/math/random.mjs +2 -3
- package/source/monster.mjs +2 -1
- package/test/cases/components/form/button.mjs +2 -1
- package/test/cases/components/form/confirm-button.mjs +1 -1
- package/test/cases/components/form/form.mjs +1 -1
- package/test/cases/components/form/reload.mjs +1 -1
- package/test/cases/components/form/select.mjs +1 -1
- package/test/cases/components/form/state-button.mjs +1 -1
- package/test/cases/components/form/template.mjs +1 -1
- package/test/cases/components/form/toggle-switch.mjs +1 -1
- package/test/cases/components/form/tree-select.mjs +1 -1
- package/test/cases/components/host/details.mjs +1 -1
- package/test/cases/components/host/host.mjs +1 -1
- package/test/cases/components/host/overlay.mjs +1 -1
- package/test/cases/components/layout/panel.mjs +1 -1
- package/test/cases/components/layout/slit-panel.mjs +1 -1
- package/test/cases/components/layout/tabs.mjs +1 -1
- package/test/cases/components/notify/message.mjs +1 -1
- package/test/cases/components/notify/notify.mjs +1 -1
- package/test/cases/dom/customcontrol.mjs +1 -1
- package/test/cases/dom/customelement-initfromscripthost.mjs +1 -1
- package/test/cases/dom/customelement.mjs +1 -1
- package/test/cases/dom/resource/data.mjs +1 -1
- package/test/cases/dom/resource/link/stylesheet.mjs +1 -1
- package/test/cases/dom/resource/link.mjs +1 -1
- package/test/cases/dom/resource/script.mjs +1 -1
- package/test/cases/dom/updater.mjs +1 -1
|
@@ -13,22 +13,22 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
assembleMethodSymbol,
|
|
17
|
+
CustomElement,
|
|
18
|
+
getSlottedElements,
|
|
19
|
+
registerCustomElement,
|
|
20
20
|
} from "../../dom/customelement.mjs";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
export {
|
|
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
|
-
*
|
|
83
|
+
* A Collapse component
|
|
84
84
|
*
|
|
85
|
-
*
|
|
85
|
+
* @fragments /fragments/components/layout/collapse/
|
|
86
86
|
*
|
|
87
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
343
|
+
this[resizeObserverSymbol].disconnect();
|
|
378
344
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
345
|
+
const slottedNodes = getSlottedElements.call(this);
|
|
346
|
+
slottedNodes.forEach((node) => {
|
|
347
|
+
this[resizeObserverSymbol].observe(node);
|
|
348
|
+
});
|
|
383
349
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
350
|
+
if (this[detailsContainerElementSymbol]) {
|
|
351
|
+
this[resizeObserverSymbol].observe(this[detailsContainerElementSymbol]);
|
|
352
|
+
}
|
|
387
353
|
|
|
388
|
-
|
|
354
|
+
this.adjustHeight();
|
|
389
355
|
}
|
|
390
356
|
|
|
391
357
|
/**
|
|
392
358
|
* @private
|
|
393
359
|
*/
|
|
394
360
|
function initEventHandler() {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
361
|
+
if (!this.shadowRoot) {
|
|
362
|
+
throw new Error("no shadow-root is defined");
|
|
363
|
+
}
|
|
398
364
|
|
|
399
|
-
|
|
400
|
-
|
|
365
|
+
initSlotChangedHandler.call(this);
|
|
366
|
+
return this;
|
|
401
367
|
}
|
|
402
368
|
|
|
403
369
|
function initSlotChangedHandler() {
|
|
404
|
-
|
|
405
|
-
|
|
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
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
405
|
+
return generateUniqueConfigKey(this[nameSymbol], this.id, "state");
|
|
440
406
|
}
|
|
441
407
|
|
|
442
408
|
/**
|
|
443
409
|
* @private
|
|
444
410
|
*/
|
|
445
411
|
function updateStateConfig() {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
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
|
-
|
|
531
|
-
|
|
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"
|