@schukai/monster 3.73.6 → 3.73.8
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +19 -2
- package/package.json +1 -1
- package/source/components/datatable/datatable.mjs +1 -1
- package/source/components/datatable/filter/input.mjs +2 -1
- package/source/components/datatable/filter/select.mjs +4 -3
- package/source/components/datatable/style/datatable.pcss +8 -0
- package/source/components/datatable/style/{select-filter.pcss → filter-select.pcss} +8 -0
- package/source/components/datatable/style/filter.pcss +1 -1
- package/source/components/datatable/stylesheet/datatable.mjs +7 -14
- package/source/components/datatable/stylesheet/{select-filter.mjs → filter-select.mjs} +9 -16
- package/source/components/datatable/stylesheet/filter.mjs +7 -14
- package/source/components/layout/popper.mjs +317 -318
- package/source/components/navigation/style/table-of-content.pcss +5 -0
- package/source/components/navigation/stylesheet/table-of-content.mjs +7 -14
- package/source/components/navigation/table-of-content.mjs +31 -18
- package/source/components/style/color.pcss +10 -1
- package/source/components/style/mixin/property.pcss +4 -4
- package/source/components/stylesheet/color.mjs +7 -14
- package/source/components/stylesheet/mixin/property.mjs +6 -13
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +4 -5
@@ -12,27 +12,26 @@
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
13
13
|
*/
|
14
14
|
|
15
|
-
import {
|
15
|
+
import {instanceSymbol} from "../../constants.mjs";
|
16
16
|
import {
|
17
|
-
|
18
|
-
|
17
|
+
addAttributeToken,
|
18
|
+
removeAttributeToken,
|
19
19
|
} from "../../dom/attributes.mjs";
|
20
|
-
import {
|
20
|
+
import {ATTRIBUTE_ROLE} from "../../dom/constants.mjs";
|
21
21
|
import {
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
assembleMethodSymbol,
|
23
|
+
CustomElement,
|
24
|
+
registerCustomElement,
|
25
25
|
} from "../../dom/customelement.mjs";
|
26
|
-
import {
|
27
|
-
import {
|
28
|
-
import {
|
29
|
-
import {
|
30
|
-
import {
|
31
|
-
import {
|
32
|
-
import {
|
33
|
-
import { isArray } from "../../types/is.mjs";
|
26
|
+
import {fireCustomEvent} from "../../dom/events.mjs";
|
27
|
+
import {getDocument} from "../../dom/util.mjs";
|
28
|
+
import {DeadMansSwitch} from "../../util/deadmansswitch.mjs";
|
29
|
+
import {STYLE_DISPLAY_MODE_BLOCK} from "../form/constants.mjs";
|
30
|
+
import {positionPopper} from "../form/util/floating-ui.mjs";
|
31
|
+
import {PopperStyleSheet} from "./stylesheet/popper.mjs";
|
32
|
+
import {isArray} from "../../types/is.mjs";
|
34
33
|
|
35
|
-
export {
|
34
|
+
export {Popper};
|
36
35
|
|
37
36
|
/**
|
38
37
|
* @private
|
@@ -97,144 +96,144 @@ const arrowElementSymbol = Symbol("arrowElement");
|
|
97
96
|
* @fires monster-popper-opened fired when the popper is opened.
|
98
97
|
*/
|
99
98
|
class Popper extends CustomElement {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
99
|
+
/**
|
100
|
+
* This method is called by the `instanceof` operator.
|
101
|
+
* @returns {symbol}
|
102
|
+
*/
|
103
|
+
static get [instanceSymbol]() {
|
104
|
+
return Symbol.for("@schukai/monster/components/layout/popper@@instance");
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
109
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
110
|
+
*
|
111
|
+
* The individual configuration values can be found in the table.
|
112
|
+
*
|
113
|
+
* @property {Object} templates The templates for the control.
|
114
|
+
* @property {string} templates.main The main template.
|
115
|
+
* @property {string} mode The mode of the popper. Possible values are `click`, `enter`, `manual`, `focus`, "auto" or a combination of them.
|
116
|
+
* @property {string} content The content of the popper.
|
117
|
+
* @property {object} popper The popper options.
|
118
|
+
* @property {string} popper.placement The placement of the popper. Possible values are `top`, `bottom`, `left` and `right`.
|
119
|
+
* @property {function[]} popper.middleware The middleware functions of the popper.
|
120
|
+
* @property {Object} features The features of the popper.
|
121
|
+
* @property {boolean} features.preventOpenEventSent Prevents the open event from being sent.
|
122
|
+
*/
|
123
|
+
get defaults() {
|
124
|
+
return Object.assign({}, super.defaults, {
|
125
|
+
templates: {
|
126
|
+
main: getTemplate(),
|
127
|
+
},
|
128
|
+
mode: "auto focus",
|
129
|
+
content: "<slot></slot>",
|
130
|
+
popper: {
|
131
|
+
placement: "top",
|
132
|
+
middleware: ["autoPlacement", "shift", "offset:15", "arrow"],
|
133
|
+
},
|
134
|
+
features: {
|
135
|
+
preventOpenEventSent: false,
|
136
|
+
},
|
137
|
+
});
|
138
|
+
}
|
139
|
+
|
140
|
+
/**
|
141
|
+
* This method is called by the `connectedCallback` method on the first call.
|
142
|
+
*
|
143
|
+
* @return {Void}
|
144
|
+
*/
|
145
|
+
[assembleMethodSymbol]() {
|
146
|
+
super[assembleMethodSymbol]();
|
147
|
+
initControlReferences.call(this);
|
148
|
+
initEventHandler.call(this);
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* This method returns the tag name of the element.
|
153
|
+
*
|
154
|
+
* @return {string}
|
155
|
+
*/
|
156
|
+
static getTag() {
|
157
|
+
return "monster-popper";
|
158
|
+
}
|
159
|
+
|
160
|
+
/**
|
161
|
+
* This method returns the css styles of the element.
|
162
|
+
*
|
163
|
+
* @return {CSSStyleSheet[]}
|
164
|
+
*/
|
165
|
+
static getCSSStyleSheet() {
|
166
|
+
return [PopperStyleSheet];
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* This method is called when the element is connected to the dom.
|
171
|
+
*
|
172
|
+
* @return {void}
|
173
|
+
*/
|
174
|
+
connectedCallback() {
|
175
|
+
super.connectedCallback();
|
176
|
+
|
177
|
+
const document = getDocument();
|
178
|
+
|
179
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
180
|
+
// close on outside ui-events
|
181
|
+
document.addEventListener(type, this[closeEventHandler]);
|
182
|
+
}
|
183
|
+
|
184
|
+
updatePopper.call(this);
|
185
|
+
attachResizeObserver.call(this);
|
186
|
+
}
|
187
|
+
|
188
|
+
/**
|
189
|
+
* This method is called when the element is disconnected from the dom.
|
190
|
+
*
|
191
|
+
* @return {void}
|
192
|
+
*/
|
193
|
+
disconnectedCallback() {
|
194
|
+
super.disconnectedCallback();
|
195
|
+
|
196
|
+
// close on outside ui-events
|
197
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
198
|
+
document.removeEventListener(type, this[closeEventHandler]);
|
199
|
+
}
|
200
|
+
|
201
|
+
disconnectResizeObserver.call(this);
|
202
|
+
}
|
203
|
+
|
204
|
+
/**
|
205
|
+
* With this method you can show the popper.
|
206
|
+
*
|
207
|
+
* @return {Popper}
|
208
|
+
*/
|
209
|
+
showDialog() {
|
210
|
+
show.call(this);
|
211
|
+
return this;
|
212
|
+
}
|
213
|
+
|
214
|
+
/**
|
215
|
+
* With this method you can hide the popper.
|
216
|
+
*
|
217
|
+
* @return {Popper}
|
218
|
+
*/
|
219
|
+
hideDialog() {
|
220
|
+
hide.call(this);
|
221
|
+
return this;
|
222
|
+
}
|
223
|
+
|
224
|
+
/**
|
225
|
+
* With this method you can toggle the popper.
|
226
|
+
*
|
227
|
+
* @return {Popper}
|
228
|
+
*/
|
229
|
+
toggleDialog() {
|
230
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
231
|
+
this.hideDialog();
|
232
|
+
} else {
|
233
|
+
this.showDialog();
|
234
|
+
}
|
235
|
+
return this;
|
236
|
+
}
|
238
237
|
}
|
239
238
|
|
240
239
|
/**
|
@@ -242,38 +241,38 @@ class Popper extends CustomElement {
|
|
242
241
|
* @return {Popper}
|
243
242
|
*/
|
244
243
|
function initEventHandler() {
|
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
|
-
|
244
|
+
this[closeEventHandler] = (event) => {
|
245
|
+
const path = event.composedPath();
|
246
|
+
|
247
|
+
for (const [, element] of Object.entries(path)) {
|
248
|
+
if (element === this) {
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
hide.call(this);
|
253
|
+
};
|
254
|
+
|
255
|
+
let modes = null;
|
256
|
+
const modeOption = this.getOption("mode");
|
257
|
+
|
258
|
+
if (typeof modeOption === "string") {
|
259
|
+
modes = modeOption.split(" ");
|
260
|
+
}
|
261
|
+
|
262
|
+
if (
|
263
|
+
modes === null ||
|
264
|
+
modes === undefined ||
|
265
|
+
isArray(modes) === false ||
|
266
|
+
modes.length === 0
|
267
|
+
) {
|
268
|
+
modes = ["manual"];
|
269
|
+
}
|
270
|
+
|
271
|
+
for (const [, mode] of Object.entries(modes)) {
|
272
|
+
initEventHandlerByMode.call(this, mode);
|
273
|
+
}
|
274
|
+
|
275
|
+
return this;
|
277
276
|
}
|
278
277
|
|
279
278
|
/**
|
@@ -283,159 +282,159 @@ function initEventHandler() {
|
|
283
282
|
* @throws Error
|
284
283
|
*/
|
285
284
|
function initEventHandlerByMode(mode) {
|
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
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
285
|
+
switch (mode) {
|
286
|
+
case "manual":
|
287
|
+
break;
|
288
|
+
|
289
|
+
case "focus":
|
290
|
+
this[buttonElementSymbol].addEventListener("focus", (event) => {
|
291
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
292
|
+
event.preventDefault();
|
293
|
+
}
|
294
|
+
this.showDialog();
|
295
|
+
});
|
296
|
+
this[buttonElementSymbol].addEventListener("blur", (event) => {
|
297
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
298
|
+
event.preventDefault();
|
299
|
+
}
|
300
|
+
this.hideDialog();
|
301
|
+
});
|
302
|
+
break;
|
303
|
+
|
304
|
+
case "click":
|
305
|
+
this[buttonElementSymbol].addEventListener("click", (event) => {
|
306
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
307
|
+
event.preventDefault();
|
308
|
+
}
|
309
|
+
this.toggleDialog();
|
310
|
+
});
|
311
|
+
break;
|
312
|
+
case "enter":
|
313
|
+
this[buttonElementSymbol].addEventListener("mouseenter", (event) => {
|
314
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
315
|
+
event.preventDefault();
|
316
|
+
}
|
317
|
+
this.showDialog();
|
318
|
+
});
|
319
|
+
break;
|
320
|
+
|
321
|
+
case "auto": // is hover
|
322
|
+
this[buttonElementSymbol].addEventListener("mouseenter", (event) => {
|
323
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
324
|
+
event.preventDefault();
|
325
|
+
}
|
326
|
+
this.showDialog();
|
327
|
+
});
|
328
|
+
this[buttonElementSymbol].addEventListener("mouseleave", (event) => {
|
329
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
330
|
+
event.preventDefault();
|
331
|
+
}
|
332
|
+
this.hideDialog();
|
333
|
+
});
|
334
|
+
break;
|
335
|
+
default:
|
336
|
+
throw new Error(`Unknown mode ${mode}`);
|
337
|
+
}
|
339
338
|
}
|
340
339
|
|
341
340
|
/**
|
342
341
|
* @private
|
343
342
|
*/
|
344
343
|
function attachResizeObserver() {
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
344
|
+
// against flickering
|
345
|
+
this[resizeObserverSymbol] = new ResizeObserver((entries) => {
|
346
|
+
if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
|
347
|
+
try {
|
348
|
+
this[timerCallbackSymbol].touch();
|
349
|
+
return;
|
350
|
+
} catch (e) {
|
351
|
+
delete this[timerCallbackSymbol];
|
352
|
+
}
|
353
|
+
}
|
354
|
+
|
355
|
+
this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
|
356
|
+
updatePopper.call(this);
|
357
|
+
});
|
358
|
+
});
|
359
|
+
|
360
|
+
this[resizeObserverSymbol].observe(this.parentElement);
|
362
361
|
}
|
363
362
|
|
364
363
|
function disconnectResizeObserver() {
|
365
|
-
|
366
|
-
|
367
|
-
|
364
|
+
if (this[resizeObserverSymbol] instanceof ResizeObserver) {
|
365
|
+
this[resizeObserverSymbol].disconnect();
|
366
|
+
}
|
368
367
|
}
|
369
368
|
|
370
369
|
/**
|
371
370
|
* @private
|
372
371
|
*/
|
373
372
|
function hide() {
|
374
|
-
|
373
|
+
const self = this;
|
375
374
|
|
376
|
-
|
377
|
-
|
378
|
-
|
375
|
+
fireCustomEvent(self, "monster-popper-hide", {
|
376
|
+
self,
|
377
|
+
});
|
379
378
|
|
380
|
-
|
381
|
-
|
379
|
+
self[popperElementSymbol].style.display = "none";
|
380
|
+
removeAttributeToken(self[controlElementSymbol], "class", "open");
|
382
381
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
382
|
+
setTimeout(() => {
|
383
|
+
fireCustomEvent(self, "monster-popper-hidden", {
|
384
|
+
self,
|
385
|
+
});
|
386
|
+
}, 0);
|
388
387
|
}
|
389
388
|
|
390
389
|
/**
|
391
390
|
* @private
|
392
391
|
*/
|
393
392
|
function show() {
|
394
|
-
|
393
|
+
const self = this;
|
395
394
|
|
396
|
-
|
397
|
-
|
398
|
-
|
395
|
+
if (self.getOption("disabled", false) === true) {
|
396
|
+
return;
|
397
|
+
}
|
399
398
|
|
400
|
-
|
401
|
-
|
402
|
-
|
399
|
+
if (self[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
400
|
+
return;
|
401
|
+
}
|
403
402
|
|
404
|
-
|
405
|
-
|
406
|
-
|
403
|
+
fireCustomEvent(self, "monster-popper-open", {
|
404
|
+
self,
|
405
|
+
});
|
407
406
|
|
408
|
-
|
409
|
-
|
407
|
+
self[popperElementSymbol].style.visibility = "hidden";
|
408
|
+
self[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
|
410
409
|
|
411
|
-
|
412
|
-
|
410
|
+
addAttributeToken(self[controlElementSymbol], "class", "open");
|
411
|
+
updatePopper.call(self);
|
413
412
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
413
|
+
setTimeout(() => {
|
414
|
+
fireCustomEvent(self, "monster-popper-opened", {
|
415
|
+
self,
|
416
|
+
});
|
417
|
+
}, 0);
|
419
418
|
}
|
420
419
|
|
421
420
|
/**
|
422
421
|
* @private
|
423
422
|
*/
|
424
423
|
function updatePopper() {
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
424
|
+
if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
|
425
|
+
return;
|
426
|
+
}
|
427
|
+
|
428
|
+
if (this.getOption("disabled", false) === true) {
|
429
|
+
return;
|
430
|
+
}
|
431
|
+
|
432
|
+
positionPopper.call(
|
433
|
+
this,
|
434
|
+
this[controlElementSymbol],
|
435
|
+
this[popperElementSymbol],
|
436
|
+
this.getOption("popper", {}),
|
437
|
+
);
|
439
438
|
}
|
440
439
|
|
441
440
|
/**
|
@@ -443,19 +442,19 @@ function updatePopper() {
|
|
443
442
|
* @return {Popper}
|
444
443
|
*/
|
445
444
|
function initControlReferences() {
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
445
|
+
this[controlElementSymbol] = this.shadowRoot.querySelector(
|
446
|
+
`[${ATTRIBUTE_ROLE}=control]`,
|
447
|
+
);
|
448
|
+
this[buttonElementSymbol] = this.shadowRoot.querySelector(
|
449
|
+
`[${ATTRIBUTE_ROLE}=button]`,
|
450
|
+
);
|
451
|
+
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
452
|
+
`[${ATTRIBUTE_ROLE}=popper]`,
|
453
|
+
);
|
454
|
+
this[arrowElementSymbol] = this.shadowRoot.querySelector(
|
455
|
+
`[${ATTRIBUTE_ROLE}=arrow]`,
|
456
|
+
);
|
457
|
+
return this;
|
459
458
|
}
|
460
459
|
|
461
460
|
/**
|
@@ -463,8 +462,8 @@ function initControlReferences() {
|
|
463
462
|
* @return {string}
|
464
463
|
*/
|
465
464
|
function getTemplate() {
|
466
|
-
|
467
|
-
|
465
|
+
// language=HTML
|
466
|
+
return `
|
468
467
|
<div data-monster-role="control" part="control">
|
469
468
|
<slot name="button" data-monster-role="button"></slot>
|
470
469
|
|