@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
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. 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 {
14
+ assembleMethodSymbol,
15
+ registerCustomElement,
16
+ } from "../../dom/customelement.mjs";
17
+ import { DetailsStyleSheet } from "./stylesheet/details.mjs";
18
+ import { ATTRIBUTE_BUTTON_LABEL } from "../host/constants.mjs";
19
+ import { isString } from "../../types/is.mjs";
20
+ import { generateUniqueConfigKey } from "../host/util.mjs";
21
+ import { Collapse, nameSymbol } from "./collapse.mjs";
22
+ import { instanceSymbol } from "../../constants.mjs";
23
+
24
+ export { Details };
25
+
26
+ /**
27
+ * @private
28
+ * @type {symbol}
29
+ */
30
+ const buttonElementSymbol = Symbol("buttonElement");
31
+
32
+ /**
33
+ * @private
34
+ * @type {symbol}
35
+ */
36
+ const buttonEventHandlerSymbol = Symbol("buttonEventHandler");
37
+
38
+ /**
39
+ * The Details component is used to show a details.
40
+ *
41
+ * <img src="./images/details.png">
42
+ *
43
+ * Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library
44
+ *
45
+ * You can create this control either by specifying the HTML tag <monster-details />` directly in the HTML or using
46
+ * Javascript via the `document.createElement('monster-details');` method.
47
+ *
48
+ * ```html
49
+ * <monster-details></monster-details>
50
+ * ```
51
+ *
52
+ * Or you can create this CustomControl directly in Javascript:
53
+ *
54
+ * ```js
55
+ * import '@schukai/component-state/source/details.mjs';
56
+ * document.createElement('monster-details');
57
+ * ```
58
+ *
59
+ * The Body should have a class "hidden" to ensure that the styles are applied correctly.
60
+ *
61
+ * ```css
62
+ * body.hidden {
63
+ * visibility: hidden;
64
+ * }
65
+ * ```
66
+ *
67
+ * @startuml details.png
68
+ * skinparam monochrome true
69
+ * skinparam shadowing false
70
+ * HTMLElement <|-- CustomElement
71
+ * CustomElement <|-- Collapse
72
+ * Collapse <|-- Details
73
+ * @enduml
74
+ *
75
+ * @copyright schukai GmbH
76
+ * @memberOf Monster.Components.Layout
77
+ * @summary A simple details component
78
+ * @fires Monster.Components.Layout.Details.event:monster-details-before-open
79
+ * @fires Monster.Components.Layout.Details.event:monster-details-open
80
+ * @fires Monster.Components.Layout.Details.event:monster-details-before-close
81
+ * @fires Monster.Components.Layout.Details.event:monster-details-closed
82
+ */
83
+ class Details extends Collapse {
84
+ /**
85
+ * This method is called by the `instanceof` operator.
86
+ * @returns {symbol}
87
+ */
88
+ static get [instanceSymbol]() {
89
+ return Symbol.for("@schukai/monster/components/layout/details@@instance");
90
+ }
91
+
92
+ /**
93
+ *
94
+ */
95
+ constructor() {
96
+ super();
97
+ // the name is only used for the host config and the event name
98
+ this[nameSymbol] = "details";
99
+ }
100
+
101
+ /**
102
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
103
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
104
+ *
105
+ * The individual configuration values can be found in the table.
106
+ *
107
+ * @property {Object} templates Template definitions
108
+ * @property {string} templates.main Main template
109
+ * @property {Object} classes CSS classes
110
+ * @property {string} classes.button CSS class for the button
111
+ * @property {Object} button Button configuration
112
+ * @property {string} button.label Button label
113
+ * @property {Object} features Feature configuration
114
+ * @property {boolean} features.accordion Enable accordion mode
115
+ * @property {boolean} features.persistState Persist the state in the host configuration
116
+ */
117
+ get defaults() {
118
+ return Object.assign({}, super.defaults, {
119
+ templates: {
120
+ main: getTemplate(),
121
+ },
122
+ labels: {
123
+ button: "Details",
124
+ },
125
+ });
126
+ }
127
+
128
+ /**
129
+ *
130
+ * @returns {Monster.Components.Layout.Details}
131
+ */
132
+ [assembleMethodSymbol]() {
133
+ super[assembleMethodSymbol]();
134
+
135
+ initButtonLabel.call(this);
136
+ initControlReferences.call(this);
137
+ initEventHandler.call(this);
138
+ }
139
+
140
+ connectedCallback() {
141
+ super.connectedCallback();
142
+
143
+ const containDocument = this.shadowRoot;
144
+
145
+ if (containDocument !== null) {
146
+ const previousElement = this.previousElementSibling;
147
+ if (previousElement && previousElement.tagName === "MONSTER-DETAILS") {
148
+ this[buttonElementSymbol].style.borderTop = "0";
149
+ }
150
+ }
151
+ }
152
+
153
+ /**
154
+ *
155
+ * @return {string}
156
+ */
157
+ static getTag() {
158
+ return "monster-details";
159
+ }
160
+
161
+ /**
162
+ * @return {Array<CSSStyleSheet>}
163
+ */
164
+ static getCSSStyleSheet() {
165
+ const css = super.getCSSStyleSheet();
166
+ css.push(DetailsStyleSheet);
167
+ return css;
168
+ }
169
+ }
170
+
171
+ /**
172
+ * @private
173
+ * @return {Select}
174
+ * @throws {Error} no shadow-root is defined
175
+ */
176
+ function initControlReferences() {
177
+ if (!this.shadowRoot) {
178
+ throw new Error("no shadow-root is defined");
179
+ }
180
+
181
+ this[buttonElementSymbol] = this.shadowRoot.querySelector(
182
+ "[data-monster-role=button]",
183
+ );
184
+ }
185
+
186
+ /**
187
+ * @private
188
+ */
189
+ function initEventHandler() {
190
+ if (!this.shadowRoot) {
191
+ throw new Error("no shadow-root is defined");
192
+ }
193
+
194
+ this[buttonEventHandlerSymbol] = (event) => {
195
+ this.toggle();
196
+ };
197
+
198
+ this[buttonElementSymbol].addEventListener(
199
+ "click",
200
+ this[buttonEventHandlerSymbol],
201
+ );
202
+
203
+ return this;
204
+ }
205
+
206
+ /**
207
+ * @private
208
+ * @return {string}
209
+ */
210
+ function initButtonLabel() {
211
+ let label;
212
+ const setLabel = false;
213
+ if (this.hasAttribute(ATTRIBUTE_BUTTON_LABEL)) {
214
+ label = this.getAttribute(ATTRIBUTE_BUTTON_LABEL);
215
+ } else {
216
+ label = this.innerText;
217
+ }
218
+
219
+ if (!isString(label)) {
220
+ label = "";
221
+ }
222
+
223
+ label = label.trim();
224
+
225
+ if (label === "") {
226
+ label = this.getOption("labels.button", "Details");
227
+ }
228
+
229
+ if (label.length > 100) {
230
+ label = `${label.substring(0, 99)}…`;
231
+ }
232
+
233
+ this.setAttribute(ATTRIBUTE_BUTTON_LABEL, label);
234
+ this.setOption("labels.button", label);
235
+
236
+ return label;
237
+ }
238
+
239
+ /**
240
+ * @private
241
+ * @returns {string}
242
+ */
243
+ function getConfigKey() {
244
+ return generateUniqueConfigKey("details", this.id, "state");
245
+ }
246
+
247
+ /**
248
+ * @private
249
+ * @return {string}
250
+ */
251
+ function getTemplate() {
252
+ // language=HTML
253
+ return `
254
+ <div data-monster-role="control" part="control" class="overflow-hidden">
255
+ <div data-monster-role="summary" part="summary">
256
+ <button part="button" data-monster-attributes="class path:classes.button"
257
+ data-monster-role="button"
258
+ data-monster-replace="path:labels.button | default:click me">click me
259
+ </button>
260
+ </div>
261
+ <div data-monster-role="detail">
262
+ <div data-monster-attributes="class path:classes.container" part="container"
263
+ data-monster-role="container">
264
+ <slot></slot>
265
+ </div>
266
+ <div class="deco-line" data-monster-role="deco"></div>
267
+ </div>
268
+ </div>`;
269
+ }
270
+
271
+ registerCustomElement(Details);