@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,29 +1,35 @@
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
4
+ *
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
7
+ *
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.
6
11
  */
7
- import { instanceSymbol } from "../../constants.mjs";
8
- import { addAttributeToken } from "../../dom/attributes.mjs";
12
+
13
+ import {instanceSymbol} from "../../constants.mjs";
14
+ import {addAttributeToken} from "../../dom/attributes.mjs";
9
15
  import {
10
- ATTRIBUTE_ERRORMESSAGE,
11
- ATTRIBUTE_ROLE,
16
+ ATTRIBUTE_ERRORMESSAGE,
17
+ ATTRIBUTE_ROLE,
12
18
  } from "../../dom/constants.mjs";
13
- import { CustomControl } from "../../dom/customcontrol.mjs";
19
+ import {CustomControl} from "../../dom/customcontrol.mjs";
14
20
  import {
15
- assembleMethodSymbol,
16
- attributeObserverSymbol,
17
- registerCustomElement,
21
+ assembleMethodSymbol,
22
+ attributeObserverSymbol,
23
+ registerCustomElement,
18
24
  } from "../../dom/customelement.mjs";
19
- import { findTargetElementFromEvent } from "../../dom/events.mjs";
20
- import { isFunction } from "../../types/is.mjs";
21
- import { ATTRIBUTE_BUTTON_CLASS } from "./constants.mjs";
22
- import { ButtonStyleSheet } from "./stylesheet/button.mjs";
23
- import { RippleStyleSheet } from "../stylesheet/ripple.mjs";
24
- import { fireCustomEvent } from "../../dom/events.mjs";
25
+ import {findTargetElementFromEvent} from "../../dom/events.mjs";
26
+ import {isFunction} from "../../types/is.mjs";
27
+ import {ATTRIBUTE_BUTTON_CLASS} from "./constants.mjs";
28
+ import {ButtonStyleSheet} from "./stylesheet/button.mjs";
29
+ import {RippleStyleSheet} from "../stylesheet/ripple.mjs";
30
+ import {fireCustomEvent} from "../../dom/events.mjs";
25
31
 
26
- export { Button };
32
+ export {Button};
27
33
 
28
34
  /**
29
35
  * @private
@@ -32,281 +38,257 @@ export { Button };
32
38
  export const buttonElementSymbol = Symbol("buttonElement");
33
39
 
34
40
  /**
35
- * This CustomControl creates a button element with a variety of options.
36
- *
37
- * <img src="./images/button.png">
38
- *
39
- * You can create this control either by specifying the HTML tag <monster-button />` directly in the HTML or using
40
- * Javascript via the `document.createElement('monster-button');` method.
41
- *
42
- * ```html
43
- * <monster-button></monster-button>
44
- * ```
45
- *
46
- * Or you can create this CustomControl directly in Javascript:
47
- *
48
- * ```js
49
- * import {Button} from '@schukai/monster/components/form/button.mjs';
50
- * document.createElement('monster-button');
51
- * ```
52
- *
53
- * The `data-monster-button-class` attribute can be used to change the CSS class of the button.
54
- *
55
- * @externalExample ../../../example/components/form/button.mjs
56
- * @startuml button.png
57
- * skinparam monochrome true
58
- * skinparam shadowing false
59
- * HTMLElement <|-- CustomElement
60
- * CustomElement <|-- CustomControl
61
- * CustomControl <|-- Button
62
- * @enduml
63
- *
41
+ * A button
42
+ *
43
+ * @fragments /fragments/components/form/button/
44
+ *
45
+ * @example /examples/components/form/button-simple
46
+ * @example /examples/components/form/button-with-click-event
47
+ *
64
48
  * @since 1.5.0
65
49
  * @copyright schukai GmbH
66
- * @memberOf Monster.Components.Form
67
- * @summary A simple button
50
+ * @summary A beautiful button that can make your life easier and also looks good.
51
+ * @fires monster-button-clicked this event is triggered when the button is clicked. It contains the field {button} with the button instance.
52
+ *
68
53
  */
69
54
  class Button extends CustomControl {
70
- /**
71
- * This method is called by the `instanceof` operator.
72
- * @returns {symbol}
73
- * @since 2.1.0
74
- */
75
- static get [instanceSymbol]() {
76
- return Symbol.for("@schukai/monster/components/form/button@@instance");
77
- }
78
-
79
- /**
80
- *
81
- * @return {Monster.Components.Form.Button}
82
- */
83
- [assembleMethodSymbol]() {
84
- super[assembleMethodSymbol]();
85
- initControlReferences.call(this);
86
- initEventHandler.call(this);
87
- return this;
88
- }
89
-
90
- /**
91
- * The Button.click() method simulates a click on the internal button element.
92
- *
93
- * @since 3.27.0
94
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click}
95
- */
96
- click() {
97
- if (this.getOption("disabled") === true) {
98
- return;
99
- }
100
-
101
- if (
102
- this[buttonElementSymbol] &&
103
- isFunction(this[buttonElementSymbol].click)
104
- ) {
105
- this[buttonElementSymbol].click();
106
- }
107
- }
108
-
109
- /**
110
- * The Button.focus() method sets focus on the internal button element.
111
- *
112
- * @since 3.27.0
113
- * @param {Object} options
114
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus}
115
- */
116
- focus(options) {
117
- if (this.getOption("disabled") === true) {
118
- return;
119
- }
120
-
121
- if (
122
- this[buttonElementSymbol] &&
123
- isFunction(this[buttonElementSymbol].focus)
124
- ) {
125
- this[buttonElementSymbol].focus(options);
126
- }
127
- }
128
-
129
- /**
130
- * The Button.blur() method removes focus from the internal button element.
131
- */
132
- blur() {
133
- if (
134
- this[buttonElementSymbol] &&
135
- isFunction(this[buttonElementSymbol].blur)
136
- ) {
137
- this[buttonElementSymbol].blur();
138
- }
139
- }
140
-
141
- /**
142
- * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
143
- *
144
- * @return {string[]}
145
- */
146
- static get observedAttributes() {
147
- const attributes = super.observedAttributes;
148
- attributes.push(ATTRIBUTE_BUTTON_CLASS);
149
- return attributes;
150
- }
151
-
152
- /**
153
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
154
- * @return {boolean}
155
- */
156
- static get formAssociated() {
157
- return true;
158
- }
159
-
160
- /**
161
- * The current selection of the Select
162
- *
163
- * ```
164
- * e = document.querySelector('monster-select');
165
- * console.log(e.value)
166
- * // ↦ 1
167
- * // ↦ ['1','2']
168
- * ```
169
- *
170
- * @property {string|array}
171
- */
172
- get value() {
173
- return this.getOption("value");
174
- }
175
-
176
- /**
177
- * Set selection
178
- *
179
- * ```
180
- * e = document.querySelector('monster-select');
181
- * e.value=1
182
- * ```
183
- *
184
- * @property {string|array} value
185
- * @since 1.2.0
186
- * @throws {Error} unsupported type
187
- */
188
- set value(value) {
189
- this.setOption("value", value);
190
- try {
191
- this?.setFormValue(this.value);
192
- } catch (e) {
193
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
194
- }
195
- }
196
-
197
- /**
198
- * To set the options via the html tag the attribute `data-monster-options` must be used.
199
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
200
- *
201
- * The individual configuration values can be found in the table.
202
- *
203
- * @property {Object} templates Template definitions
204
- * @property {string} templates.main Main template
205
- * @property {Object} labels Labels
206
- * @property {string} labels.button=<slot></slot> Button label
207
- * @property {Object} actions Callbacks
208
- * @property {string} actions.click="throw Error" Callback when clicked
209
- * @property {Object} classes CSS classes
210
- * @property {string} classes.button="monster-button-primary" CSS class for the button
211
- * @property {boolean} disabled=false Disabled state
212
- * @property {Object} effects Effects
213
- * @property {boolean} effects.ripple=true Ripple effect
214
- */
215
- get defaults() {
216
- return Object.assign({}, super.defaults, {
217
- templates: {
218
- main: getTemplate(),
219
- },
220
- labels: {
221
- button: "<slot></slot>",
222
- },
223
- classes: {
224
- button: "monster-button-primary",
225
- },
226
- disabled: false,
227
- actions: {
228
- click: () => {
229
- throw new Error("the click action is not defined");
230
- },
231
- },
232
- effects: {
233
- ripple: true,
234
- },
235
- value: null,
236
- });
237
- }
238
-
239
- /**
240
- *
241
- * @return {string}
242
- */
243
- static getTag() {
244
- return "monster-button";
245
- }
246
-
247
- /**
248
- *
249
- * @return {Array<CSSStyleSheet>}
250
- */
251
- static getCSSStyleSheet() {
252
- return [RippleStyleSheet, ButtonStyleSheet];
253
- }
55
+ /**
56
+ * This method is called by the <code>instanceof</code> operator.
57
+ * @return {symbol}
58
+ * @since 2.1.0
59
+ */
60
+ static get [instanceSymbol]() {
61
+ return Symbol.for("@schukai/monster/components/form/button@@instance");
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @return {Button}
67
+ */
68
+ [assembleMethodSymbol]() {
69
+ super[assembleMethodSymbol]();
70
+ initControlReferences.call(this);
71
+ initEventHandler.call(this);
72
+ return this;
73
+ }
74
+
75
+ /**
76
+ * The <code>Button.click()</code> method simulates a click on the internal button element.
77
+ *
78
+ * @since 3.27.0
79
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click}
80
+ */
81
+ click() {
82
+ if (this.getOption("disabled") === true) {
83
+ return;
84
+ }
85
+
86
+ if (
87
+ this[buttonElementSymbol] &&
88
+ isFunction(this[buttonElementSymbol].click)
89
+ ) {
90
+ this[buttonElementSymbol].click();
91
+ }
92
+ }
93
+
94
+ /**
95
+ * The Button.focus() method sets focus on the internal button element.
96
+ *
97
+ * @since 3.27.0
98
+ * @param {Object} options
99
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus}
100
+ */
101
+ focus(options) {
102
+ if (this.getOption("disabled") === true) {
103
+ return;
104
+ }
105
+
106
+ if (
107
+ this[buttonElementSymbol] &&
108
+ isFunction(this[buttonElementSymbol].focus)
109
+ ) {
110
+ this[buttonElementSymbol].focus(options);
111
+ }
112
+ }
113
+
114
+ /**
115
+ * The Button.blur() method removes focus from the internal button element.
116
+ */
117
+ blur() {
118
+ if (
119
+ this[buttonElementSymbol] &&
120
+ isFunction(this[buttonElementSymbol].blur)
121
+ ) {
122
+ this[buttonElementSymbol].blur();
123
+ }
124
+ }
125
+
126
+ /**
127
+ * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
128
+ *
129
+ * @return {string[]}
130
+ */
131
+ static get observedAttributes() {
132
+ const attributes = super.observedAttributes;
133
+ attributes.push(ATTRIBUTE_BUTTON_CLASS);
134
+ return attributes;
135
+ }
136
+
137
+ /**
138
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
139
+ * @return {boolean}
140
+ */
141
+ static get formAssociated() {
142
+ return true;
143
+ }
144
+
145
+ /**
146
+ * The current value of the button.
147
+ *
148
+ * ```javascript
149
+ * e = document.querySelector('monster-button');
150
+ * console.log(e.value)
151
+ * ```
152
+ *
153
+ * @return {string} The value of the button
154
+ */
155
+ get value() {
156
+ return this.getOption("value");
157
+ }
158
+
159
+ /**
160
+ * Set the value of the button.
161
+ *
162
+ * ```javascript
163
+ * e = document.querySelector('monster-button');
164
+ * e.value=1
165
+ * ```
166
+ *
167
+ * @param {string} value
168
+ * @return {void}
169
+ * @throws {Error} unsupported type
170
+ */
171
+ set value(value) {
172
+ this.setOption("value", value);
173
+ try {
174
+ this?.setFormValue(this.value);
175
+ } catch (e) {
176
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
182
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
183
+ *
184
+ * The individual configuration values can be found in the table.
185
+ *
186
+ * @property {Object} templates Template definitions
187
+ * @property {string} templates.main Main template
188
+ * @property {Object} labels Labels
189
+ * @property {string} labels.button="<slot></slot>" Button label
190
+ * @property {Object} actions Callbacks
191
+ * @property {string} actions.click="throw Error" Callback when clicked
192
+ * @property {Object} classes CSS classes
193
+ * @property {string} classes.button="monster-button-primary" CSS class for the button
194
+ * @property {boolean} disabled=false Disabled state
195
+ * @property {Object} effects Effects
196
+ * @property {boolean} effects.ripple=true Ripple effect
197
+ */
198
+ get defaults() {
199
+ return Object.assign({}, super.defaults, {
200
+ templates: {
201
+ main: getTemplate(),
202
+ },
203
+ labels: {
204
+ button: "<slot></slot>",
205
+ },
206
+ classes: {
207
+ button: "monster-button-primary",
208
+ },
209
+ disabled: false,
210
+ actions: {
211
+ click: () => {
212
+ throw new Error("the click action is not defined");
213
+ },
214
+ },
215
+ effects: {
216
+ ripple: true,
217
+ },
218
+ value: null,
219
+ });
220
+ }
221
+
222
+ /**
223
+ *
224
+ * @return {string}
225
+ */
226
+ static getTag() {
227
+ return "monster-button";
228
+ }
229
+
230
+ /**
231
+ *
232
+ * @return {CSSStyleSheet[]}
233
+ */
234
+ static getCSSStyleSheet() {
235
+ return [RippleStyleSheet, ButtonStyleSheet];
236
+ }
254
237
  }
255
238
 
256
239
  /**
257
240
  * @private
258
241
  * @return {initEventHandler}
259
- * @fires Monster.Components.Form.event:monster-button-clicked
260
242
  */
261
243
  function initEventHandler() {
262
- const self = this;
263
- const button = this[buttonElementSymbol];
244
+ const self = this;
245
+ const button = this[buttonElementSymbol];
264
246
 
265
- const type = "click";
247
+ const type = "click";
266
248
 
267
- button.addEventListener(type, function (event) {
268
- const callback = self.getOption("actions.click");
249
+ button.addEventListener(type, function (event) {
250
+ const callback = self.getOption("actions.click");
269
251
 
270
- fireCustomEvent(self, "monster-button-clicked", {
271
- button: self,
272
- });
252
+ fireCustomEvent(self, "monster-button-clicked", {
253
+ button: self,
254
+ });
273
255
 
274
- if (!isFunction(callback)) {
275
- return;
276
- }
256
+ if (!isFunction(callback)) {
257
+ return;
258
+ }
277
259
 
278
- const element = findTargetElementFromEvent(
279
- event,
280
- ATTRIBUTE_ROLE,
281
- "control",
282
- );
260
+ const element = findTargetElementFromEvent(
261
+ event,
262
+ ATTRIBUTE_ROLE,
263
+ "control",
264
+ );
283
265
 
284
- if (!(element instanceof Node && self.hasNode(element))) {
285
- return;
286
- }
266
+ if (!(element instanceof Node && self.hasNode(element))) {
267
+ return;
268
+ }
287
269
 
288
- callback.call(self, event);
289
- });
270
+ callback.call(self, event);
271
+ });
290
272
 
291
- if (self.getOption("effects.ripple")) {
292
- button.addEventListener("click", createRipple.bind(self));
293
- }
273
+ if (self.getOption("effects.ripple")) {
274
+ button.addEventListener("click", createRipple.bind(self));
275
+ }
294
276
 
295
- // data-monster-options
296
- self[attributeObserverSymbol][ATTRIBUTE_BUTTON_CLASS] = function (value) {
297
- self.setOption("classes.button", value);
298
- };
277
+ // data-monster-options
278
+ self[attributeObserverSymbol][ATTRIBUTE_BUTTON_CLASS] = function (value) {
279
+ self.setOption("classes.button", value);
280
+ };
299
281
 
300
- return this;
282
+ return this;
301
283
  }
302
284
 
303
285
  /**
304
286
  * @private
305
287
  */
306
288
  function initControlReferences() {
307
- this[buttonElementSymbol] = this.shadowRoot.querySelector(
308
- `[${ATTRIBUTE_ROLE}=button]`,
309
- );
289
+ this[buttonElementSymbol] = this.shadowRoot.querySelector(
290
+ `[${ATTRIBUTE_ROLE}=button]`,
291
+ );
310
292
  }
311
293
 
312
294
  /**
@@ -314,8 +296,8 @@ function initControlReferences() {
314
296
  * @return {string}
315
297
  */
316
298
  function getTemplate() {
317
- // language=HTML
318
- return `
299
+ // language=HTML
300
+ return `
319
301
  <div data-monster-role="control" part="control">
320
302
  <button data-monster-attributes="disabled path:disabled | if:true, class path:classes.button"
321
303
  data-monster-role="button"
@@ -325,23 +307,23 @@ function getTemplate() {
325
307
  }
326
308
 
327
309
  function createRipple(event) {
328
- const button = this[buttonElementSymbol];
310
+ const button = this[buttonElementSymbol];
329
311
 
330
- const circle = document.createElement("span");
331
- const diameter = Math.max(button.clientWidth, button.clientHeight);
332
- const radius = diameter / 2;
312
+ const circle = document.createElement("span");
313
+ const diameter = Math.max(button.clientWidth, button.clientHeight);
314
+ const radius = diameter / 2;
333
315
 
334
- circle.style.width = circle.style.height = `${diameter}px`;
335
- circle.style.left = `${event.clientX - button.offsetLeft - radius}px`;
336
- circle.style.top = `${event.clientY - button.offsetTop - radius}px`;
337
- circle.classList.add("monster-fx-ripple");
316
+ circle.style.width = circle.style.height = `${diameter}px`;
317
+ circle.style.left = `${event.clientX - button.offsetLeft - radius}px`;
318
+ circle.style.top = `${event.clientY - button.offsetTop - radius}px`;
319
+ circle.classList.add("monster-fx-ripple");
338
320
 
339
- const ripples = button.getElementsByClassName("monster-fx-ripple");
340
- for (const ripple of ripples) {
341
- ripple.remove();
342
- }
321
+ const ripples = button.getElementsByClassName("monster-fx-ripple");
322
+ for (const ripple of ripples) {
323
+ ripple.remove();
324
+ }
343
325
 
344
- button.appendChild(circle);
326
+ button.appendChild(circle);
345
327
  }
346
328
 
347
329
  registerCustomElement(Button);