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