@schukai/monster 3.64.1 → 3.65.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/example/components/form/button.mjs +1 -1
  3. package/example/components/form/field-set.mjs +4 -0
  4. package/example/components/form/select.mjs +1 -1
  5. package/package.json +2 -1
  6. package/source/components/datatable/datatable/header.mjs +228 -221
  7. package/source/components/datatable/style/dataset.pcss +1 -0
  8. package/source/components/datatable/style/datatable.pcss +1 -0
  9. package/source/components/datatable/stylesheet/dataset.mjs +1 -1
  10. package/source/components/datatable/stylesheet/datatable.mjs +1 -1
  11. package/source/components/form/button.mjs +263 -281
  12. package/source/components/form/field-set.mjs +300 -0
  13. package/source/components/form/popper.mjs +13 -480
  14. package/source/components/form/style/field-set.pcss +13 -0
  15. package/source/components/form/stylesheet/button-bar.mjs +1 -1
  16. package/source/components/form/stylesheet/confirm-button.mjs +1 -1
  17. package/source/components/form/stylesheet/field-set.mjs +31 -0
  18. package/source/components/form/stylesheet/form.mjs +1 -1
  19. package/source/components/host/collapse.mjs +14 -516
  20. package/source/components/host/config-manager.mjs +9 -2
  21. package/source/components/host/constants.mjs +9 -4
  22. package/source/components/host/details.mjs +14 -253
  23. package/source/components/host/stylesheet/host.mjs +1 -1
  24. package/source/components/host/stylesheet/overlay.mjs +1 -1
  25. package/source/components/layout/collapse.mjs +542 -0
  26. package/source/components/layout/details.mjs +271 -0
  27. package/source/components/layout/popper.mjs +476 -0
  28. package/source/components/layout/tabs.mjs +3 -3
  29. package/source/components/layout/width-toggle.mjs +3 -3
  30. package/source/components/navigation/style/table-of-content.pcss +84 -0
  31. package/source/components/navigation/stylesheet/table-of-content.mjs +31 -0
  32. package/source/components/navigation/table-of-content.mjs +418 -0
  33. package/source/components/state/stylesheet/state.mjs +1 -1
  34. package/source/components/style/link.pcss +0 -1
  35. package/source/components/style/mixin/typography.pcss +7 -7
  36. package/source/components/style/typography.pcss +1 -1
  37. package/source/components/stylesheet/typography.mjs +1 -1
  38. package/source/dom/ready.mjs +10 -4
  39. package/source/monster.mjs +5 -84
  40. package/source/types/proxyobserver.mjs +4 -2
  41. package/source/types/version.mjs +1 -1
  42. package/test/cases/monster.mjs +1 -1
  43. package/test/web/tests.js +4 -4
  44. package/source/components/form/form-field.mjs +0 -341
  45. package/source/components/form/style/form-field.pcss +0 -4
  46. package/source/components/form/stylesheet/form-field.mjs +0 -31
  47. /package/source/components/{host → layout}/style/collapse.pcss +0 -0
  48. /package/source/components/{host → layout}/style/details.pcss +0 -0
  49. /package/source/components/{form → layout}/style/popper.pcss +0 -0
  50. /package/source/components/{host → layout}/stylesheet/collapse.mjs +0 -0
  51. /package/source/components/{host → layout}/stylesheet/details.mjs +0 -0
  52. /package/source/components/{form → layout}/stylesheet/popper.mjs +0 -0
@@ -1,491 +1,24 @@
1
1
  /**
2
- * Copyright schukai GmbH and contributors 2023. All Rights Reserved.
2
+ * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved.
3
3
  * Node module: @schukai/monster
4
- * This file is licensed under the AGPLv3 License.
5
- * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
- */
7
- import { instanceSymbol } from "../../constants.mjs";
8
- import {
9
- addAttributeToken,
10
- removeAttributeToken,
11
- } from "../../dom/attributes.mjs";
12
- import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
13
- import {
14
- assembleMethodSymbol,
15
- registerCustomElement,
16
- } from "../../dom/customelement.mjs";
17
- import { fireCustomEvent } from "../../dom/events.mjs";
18
- import { getDocument } from "../../dom/util.mjs";
19
- import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
20
- import { Button } from "./button.mjs";
21
- import { STYLE_DISPLAY_MODE_BLOCK } from "./constants.mjs";
22
- import { positionPopper } from "./util/floating-ui.mjs";
23
- import { CustomControl } from "../../dom/customcontrol.mjs";
24
- import { PopperStyleSheet } from "./stylesheet/popper.mjs";
25
- import { isArray } from "../../types/is.mjs";
26
-
27
- export { Popper };
28
-
29
- /**
30
- * @private
31
- * @type {symbol}
32
- */
33
- const timerCallbackSymbol = Symbol("timerCallback");
34
-
35
- /**
36
- * local symbol
37
- * @private
38
- * @type {symbol}
39
- */
40
- const resizeObserverSymbol = Symbol("resizeObserver");
41
-
42
- /**
43
- * local symbol
44
- * @private
45
- * @type {symbol}
46
- */
47
- const closeEventHandler = Symbol("closeEventHandler");
48
-
49
- /**
50
- * @private
51
- * @type {symbol}
52
- */
53
- const controlElementSymbol = Symbol("controlElement");
54
-
55
- /**
56
- * @private
57
- * @type {symbol}
58
- */
59
- const buttonElementSymbol = Symbol("buttonElement");
60
-
61
- /**
62
- * local symbol
63
- * @private
64
- * @type {symbol}
65
- */
66
- const popperElementSymbol = Symbol("popperElement");
67
-
68
- /**
69
- * local symbol
70
- * @private
71
- * @type {symbol}
72
- */
73
- const arrowElementSymbol = Symbol("arrowElement");
74
-
75
- /**
76
- * This action callback executes the actions when a button is clicked.
77
- *
78
- * @callback Monster.Components.Form~exampleActionCallback
79
- * @param {Event} e Event
80
- * @memberOf Monster.Components.Form
81
- * @this {CustomControl}
82
- */
83
-
84
- /**
85
- * The Popper ist an element that can be used to display a popper.
86
- *
87
- * <img src="./images/popper.png">
88
4
  *
89
- * Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library
90
- * as well as [pooperjs](https://popper.js.org/docs/v2/).
5
+ * This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
6
+ * The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
91
7
  *
92
- * You can create this control either by specifying the HTML tag <monster-popper-button />` directly in the HTML or using
93
- * Javascript via the `document.createElement('monster-popper');` method.
94
- *
95
- * ```html
96
- * <monster-popper></monster-popper>
97
- * ```
98
- *
99
- * Or you can create this CustomControl directly in Javascript:
100
- *
101
- * ```js
102
- * import {Popper} from '@schukai/component-form/source/popper.js';
103
- * document.createElement('monster-popper');
104
- * ```
105
- *
106
- * @startuml popper.png
107
- * skinparam monochrome true
108
- * skinparam shadowing false
109
- * HTMLElement <|-- CustomElement
110
- * CustomElement <|-- CustomControl
111
- * CustomControl <|-- Popper
112
- * @enduml
113
- *
114
- * @copyright schukai GmbH
115
- * @memberOf Monster.Components.Form
116
- * @summary A popper button
117
- */
118
- class Popper extends CustomControl {
119
- /**
120
- * This method is called by the `instanceof` operator.
121
- * @returns {symbol}
122
- */
123
- static get [instanceSymbol]() {
124
- return Symbol.for("@schukai/monster/components/form/popper@@instance");
125
- }
126
-
127
- /**
128
- * To set the options via the html tag the attribute `data-monster-options` must be used.
129
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
130
- *
131
- * The individual configuration values can be found in the table.
132
- *
133
- * @property {Object} templates - The templates for the control.
134
- * @property {string} templates.main - The main template.
135
- * @property {string} mode - The mode of the popper. Possible values are `click`, `enter` `hover`, `manual`, `focus`, "auto" or a combination of them.
136
- * @property {string} content - The content of the popper.
137
- * @property {object} popper - The popper options.
138
- * @property {string} popper.placement - The placement of the popper. Possible values are `top`, `bottom`, `left` and `right`.
139
- * @property {Array<function>} popper.middleware - The middleware functions of the popper.
140
- * @property {Array<function>} popper.middlewareInit - The middleware init functions of the popper.
141
- * @property {Object} features - The features of the popper.
142
- * @property {boolean} features.preventPropagateOpenEvents - Prevents the open event from being sent.
143
- * @extends {Button}
144
- */
145
- get defaults() {
146
- return Object.assign({}, super.defaults, {
147
- templates: {
148
- main: getTemplate(),
149
- },
150
- mode: "hover focus",
151
- content: "<slot>Should I Stay or Should I Go?</slot>",
152
- popper: {
153
- placement: "top",
154
- middleware: ["autoPlacement", "offset:10", "arrow"],
155
- },
156
- features: {
157
- preventOpenEventSent: false,
158
- },
159
- });
160
- }
161
-
162
- /**
163
- *
164
- * @return {Monster.Components.Form.Popper}
165
- */
166
- [assembleMethodSymbol]() {
167
- super[assembleMethodSymbol]();
168
- initControlReferences.call(this);
169
- initEventHandler.call(this);
170
-
171
- return this;
172
- }
173
-
174
- /**
175
- * @return {string}
176
- */
177
- static getTag() {
178
- return "monster-popper";
179
- }
180
-
181
- /**
182
- * @return {Array<CSSStyleSheet>}
183
- */
184
- static getCSSStyleSheet() {
185
- return [PopperStyleSheet];
186
- }
187
-
188
- /**
189
- * @return {void}
190
- */
191
- connectedCallback() {
192
- super.connectedCallback();
193
-
194
- const document = getDocument();
195
-
196
- for (const [, type] of Object.entries(["click", "touch"])) {
197
- // close on outside ui-events
198
- document.addEventListener(type, this[closeEventHandler]);
199
- }
200
-
201
- updatePopper.call(this);
202
- attachResizeObserver.call(this);
203
- }
204
-
205
- /**
206
- * @return {void}
207
- */
208
- disconnectedCallback() {
209
- super.disconnectedCallback();
210
-
211
- // close on outside ui-events
212
- for (const [, type] of Object.entries(["click", "touch"])) {
213
- document.removeEventListener(type, this[closeEventHandler]);
214
- }
215
-
216
- disconnectResizeObserver.call(this);
217
- }
218
-
219
- /**
220
- *
221
- * @return {Monster.Components.Form.Popper}
222
- */
223
- showDialog() {
224
- show.call(this);
225
- return this;
226
- }
227
-
228
- /**
229
- *
230
- * @return {Monster.Components.Form.Popper}
231
- */
232
- hideDialog() {
233
- hide.call(this);
234
- return this;
235
- }
236
-
237
- /**
238
- *
239
- * @return {Monster.Components.Form.Popper}
240
- */
241
- toggleDialog() {
242
- if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
243
- this.hideDialog();
244
- } else {
245
- this.showDialog();
246
- }
247
- return this;
248
- }
249
- }
250
-
251
- /**
252
- * @private
253
- * @return {Monster.Components.Form.Popper}
254
- */
255
- function initEventHandler() {
256
- this[closeEventHandler] = (event) => {
257
- const path = event.composedPath();
258
-
259
- for (const [, element] of Object.entries(path)) {
260
- if (element === this) {
261
- return;
262
- }
263
- }
264
- hide.call(this);
265
- };
266
-
267
- let modes = null;
268
- const modeOption = this.getOption("mode");
269
- if (typeof modeOption === "string") {
270
- modes = modeOption.split(" ");
271
- }
272
-
273
- if (
274
- modes === null ||
275
- modes === undefined ||
276
- isArray(modes) === false ||
277
- modes.length === 0
278
- ) {
279
- modes = ["manual"];
280
- }
281
-
282
- for (const [, mode] of Object.entries(modes)) {
283
- initEventHandlerByMode.call(this, mode);
284
- }
285
-
286
- return this;
287
- }
288
-
289
- /**
290
- * @private
291
- * @param mode
292
- * @return {Monster.Components.Form.Popper}
293
- * @throws Error
294
- */
295
- function initEventHandlerByMode(mode) {
296
- switch (mode) {
297
- case "manual":
298
- break;
299
-
300
- case "focus":
301
- this[buttonElementSymbol].addEventListener("focus", (event) => {
302
- if (this.getOption("features.preventOpenEventSent") === true) {
303
- event.preventDefault();
304
- }
305
- this.showDialog();
306
- });
307
- this[buttonElementSymbol].addEventListener("blur", (event) => {
308
- if (this.getOption("features.preventOpenEventSent") === true) {
309
- event.preventDefault();
310
- }
311
- this.hideDialog();
312
- });
313
- break;
314
-
315
- case "click":
316
- this[buttonElementSymbol].addEventListener("click", (event) => {
317
- if (this.getOption("features.preventOpenEventSent") === true) {
318
- event.preventDefault();
319
- }
320
- this.toggleDialog();
321
- });
322
- break;
323
- case "enter":
324
- this[buttonElementSymbol].addEventListener("mouseenter", (event) => {
325
- if (this.getOption("features.preventOpenEventSent") === true) {
326
- event.preventDefault();
327
- }
328
- this.showDialog();
329
- });
330
- break;
331
-
332
- case "auto": // is hover
333
- this[buttonElementSymbol].addEventListener("mouseenter", (event) => {
334
- if (this.getOption("features.preventOpenEventSent") === true) {
335
- event.preventDefault();
336
- }
337
- this.showDialog();
338
- });
339
- this[buttonElementSymbol].addEventListener("mouseleave", (event) => {
340
- if (this.getOption("features.preventOpenEventSent") === true) {
341
- event.preventDefault();
342
- }
343
- this.hideDialog();
344
- });
345
- break;
346
- default:
347
- throw new Error(`Unknown mode ${mode}`);
348
- }
349
- }
350
-
351
- /**
352
- * @private
8
+ * For those who do not wish to adhere to the AGPLv3, a commercial license is available.
9
+ * Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
10
+ * For more information about purchasing a commercial license, please contact schukai GmbH.
353
11
  */
354
- function attachResizeObserver() {
355
- // against flickering
356
- this[resizeObserverSymbol] = new ResizeObserver((entries) => {
357
- if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
358
- try {
359
- this[timerCallbackSymbol].touch();
360
- return;
361
- } catch (e) {
362
- delete this[timerCallbackSymbol];
363
- }
364
- }
365
12
 
366
- this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
367
- updatePopper.call(this);
368
- });
369
- });
13
+ import {Popper as NewPopper} from "../layout/popper.mjs";
370
14
 
371
- this[resizeObserverSymbol].observe(this.parentElement);
372
- }
373
-
374
- function disconnectResizeObserver() {
375
- if (this[resizeObserverSymbol] instanceof ResizeObserver) {
376
- this[resizeObserverSymbol].disconnect();
377
- }
378
- }
15
+ export {Popper};
379
16
 
380
17
  /**
381
- * @private
382
- */
383
- function hide() {
384
- const self = this;
385
-
386
- fireCustomEvent(self, "monster-popper-hide", {
387
- self,
388
- });
389
-
390
- self[popperElementSymbol].style.display = "none";
391
- removeAttributeToken(self[controlElementSymbol], "class", "open");
392
-
393
- setTimeout(() => {
394
- fireCustomEvent(self, "monster-popper-hidden", {
395
- self,
396
- });
397
- }, 0);
398
- }
399
-
400
- /**
401
- * @private
402
- * @this PopperButton
403
- */
404
- function show() {
405
- const self = this;
406
-
407
- if (self.getOption("disabled", false) === true) {
408
- return;
409
- }
410
-
411
- if (self[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
412
- return;
413
- }
414
-
415
- fireCustomEvent(self, "monster-popper-open", {
416
- self,
417
- });
418
-
419
- self[popperElementSymbol].style.visibility = "hidden";
420
- self[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
421
-
422
- addAttributeToken(self[controlElementSymbol], "class", "open");
423
- updatePopper.call(self);
424
-
425
- setTimeout(() => {
426
- fireCustomEvent(self, "monster-popper-opened", {
427
- self,
428
- });
429
- }, 0);
430
- }
431
-
432
- /**
433
- * @private
434
- */
435
- function updatePopper() {
436
- if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
437
- return;
438
- }
439
-
440
- if (this.getOption("disabled", false) === true) {
441
- return;
442
- }
443
-
444
- positionPopper.call(
445
- this,
446
- this[controlElementSymbol],
447
- this[popperElementSymbol],
448
- this.getOption("popper", {}),
449
- );
450
- }
451
-
452
- /**
453
- * @private
454
- * @return {Monster.Components.Form.Popper}
455
- */
456
- function initControlReferences() {
457
- this[controlElementSymbol] = this.shadowRoot.querySelector(
458
- `[${ATTRIBUTE_ROLE}=control]`,
459
- );
460
- this[buttonElementSymbol] = this.shadowRoot.querySelector(
461
- `[${ATTRIBUTE_ROLE}=button]`,
462
- );
463
- this[popperElementSymbol] = this.shadowRoot.querySelector(
464
- `[${ATTRIBUTE_ROLE}=popper]`,
465
- );
466
- this[arrowElementSymbol] = this.shadowRoot.querySelector(
467
- `[${ATTRIBUTE_ROLE}=arrow]`,
468
- );
469
- return this;
470
- }
471
-
472
- /**
473
- * @private
474
- * @return {string}
18
+ * @since 1.10.0
19
+ * @copyright schukai GmbH
20
+ * @deprecated since 3.66.0 use {@link Monster.Components.Layout.Popper}
475
21
  */
476
- function getTemplate() {
477
- // language=HTML
478
- return `
479
- <div data-monster-role="control" part="control">
480
- <slot name="button" data-monster-role="button"></slot>
481
-
482
- <div data-monster-role="popper" part="popper" tabindex="-1" class="monster-color-primary-1">
483
- <div data-monster-role="arrow"></div>
484
- <div part="content" class="flex" data-monster-replace="path:content">
485
- </div>
486
- </div>
487
- </div>
488
- `;
489
- }
22
+ class Popper extends NewPopper {
490
23
 
491
- registerCustomElement(Popper);
24
+ }
@@ -0,0 +1,13 @@
1
+ @import "../../style/display.pcss";
2
+ @import "../../style/border.pcss";
3
+ @import "../../style/control.pcss";
4
+ @import "../../style/badge.pcss";
5
+ @import '../../style/mixin/typography.pcss';
6
+ @import '../../style/mixin/hover.pcss';
7
+
8
+ @import "../../style/control.pcss";
9
+ @import "../../style/floating-ui.pcss";
10
+
11
+ [data-monster-role=control] {
12
+ border: 1px solid red;
13
+ }