@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.
- package/CHANGELOG.md +19 -0
- package/example/components/form/button.mjs +1 -1
- package/example/components/form/field-set.mjs +4 -0
- package/example/components/form/select.mjs +1 -1
- package/package.json +2 -1
- package/source/components/datatable/datatable/header.mjs +228 -221
- package/source/components/datatable/style/dataset.pcss +1 -0
- package/source/components/datatable/style/datatable.pcss +1 -0
- package/source/components/datatable/stylesheet/dataset.mjs +1 -1
- package/source/components/datatable/stylesheet/datatable.mjs +1 -1
- package/source/components/form/button.mjs +263 -281
- package/source/components/form/field-set.mjs +300 -0
- package/source/components/form/popper.mjs +13 -480
- package/source/components/form/style/field-set.pcss +13 -0
- package/source/components/form/stylesheet/button-bar.mjs +1 -1
- package/source/components/form/stylesheet/confirm-button.mjs +1 -1
- package/source/components/form/stylesheet/field-set.mjs +31 -0
- package/source/components/form/stylesheet/form.mjs +1 -1
- package/source/components/host/collapse.mjs +14 -516
- package/source/components/host/config-manager.mjs +9 -2
- package/source/components/host/constants.mjs +9 -4
- package/source/components/host/details.mjs +14 -253
- package/source/components/host/stylesheet/host.mjs +1 -1
- package/source/components/host/stylesheet/overlay.mjs +1 -1
- package/source/components/layout/collapse.mjs +542 -0
- package/source/components/layout/details.mjs +271 -0
- package/source/components/layout/popper.mjs +476 -0
- package/source/components/layout/tabs.mjs +3 -3
- package/source/components/layout/width-toggle.mjs +3 -3
- package/source/components/navigation/style/table-of-content.pcss +84 -0
- package/source/components/navigation/stylesheet/table-of-content.mjs +31 -0
- package/source/components/navigation/table-of-content.mjs +418 -0
- package/source/components/state/stylesheet/state.mjs +1 -1
- package/source/components/style/link.pcss +0 -1
- package/source/components/style/mixin/typography.pcss +7 -7
- package/source/components/style/typography.pcss +1 -1
- package/source/components/stylesheet/typography.mjs +1 -1
- package/source/dom/ready.mjs +10 -4
- package/source/monster.mjs +5 -84
- package/source/types/proxyobserver.mjs +4 -2
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/tests.js +4 -4
- package/source/components/form/form-field.mjs +0 -341
- package/source/components/form/style/form-field.pcss +0 -4
- package/source/components/form/stylesheet/form-field.mjs +0 -31
- /package/source/components/{host → layout}/style/collapse.pcss +0 -0
- /package/source/components/{host → layout}/style/details.pcss +0 -0
- /package/source/components/{form → layout}/style/popper.pcss +0 -0
- /package/source/components/{host → layout}/stylesheet/collapse.mjs +0 -0
- /package/source/components/{host → layout}/stylesheet/details.mjs +0 -0
- /package/source/components/{form → layout}/stylesheet/popper.mjs +0 -0
@@ -0,0 +1,300 @@
|
|
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 { instanceSymbol } from "../../constants.mjs";
|
14
|
+
import { addAttributeToken } from "../../dom/attributes.mjs";
|
15
|
+
import {
|
16
|
+
ATTRIBUTE_ERRORMESSAGE,
|
17
|
+
ATTRIBUTE_ROLE,
|
18
|
+
} from "../../dom/constants.mjs";
|
19
|
+
import { CustomControl } from "../../dom/customcontrol.mjs";
|
20
|
+
import {
|
21
|
+
assembleMethodSymbol,
|
22
|
+
registerCustomElement,
|
23
|
+
} from "../../dom/customelement.mjs";
|
24
|
+
import { findTargetElementFromEvent } from "../../dom/events.mjs";
|
25
|
+
import { isFunction } from "../../types/is.mjs";
|
26
|
+
import { FieldSetStyleSheet } from "./stylesheet/field-set.mjs";
|
27
|
+
import { fireCustomEvent } from "../../dom/events.mjs";
|
28
|
+
import "../layout/collapse.mjs";
|
29
|
+
|
30
|
+
export { FieldSet };
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @private
|
34
|
+
* @type {symbol}
|
35
|
+
*/
|
36
|
+
export const fieldSetElementSymbol = Symbol("fieldSetElement");
|
37
|
+
|
38
|
+
/**
|
39
|
+
* This CustomControl creates a FieldSet element with a variety of options.
|
40
|
+
*
|
41
|
+
* <img src="./images/field-set.png">
|
42
|
+
*
|
43
|
+
* You can create this control either by specifying the HTML tag <monster-field-set />` directly in the HTML or using
|
44
|
+
* Javascript via the `document.createElement('monster-field-set');` method.
|
45
|
+
*
|
46
|
+
* ```html
|
47
|
+
* <monster-field-set></monster-field-set>
|
48
|
+
* ```
|
49
|
+
*
|
50
|
+
* Or you can create this CustomControl directly in Javascript:
|
51
|
+
*
|
52
|
+
* ```js
|
53
|
+
* import {FieldSet} from '@schukai/monster/source/components/form/field-set.mjs';
|
54
|
+
* document.createElement('monster-field-set');
|
55
|
+
* ```
|
56
|
+
*
|
57
|
+
* @externalExample ../..../example/components/form/field-set.mjs
|
58
|
+
* @startuml field-set.png
|
59
|
+
* skinparam monochrome true
|
60
|
+
* skinparam shadowing false
|
61
|
+
* HTMLElement <|-- CustomElement
|
62
|
+
* CustomElement <|-- CustomControl
|
63
|
+
* CustomControl <|-- FieldSet
|
64
|
+
* @enduml
|
65
|
+
*
|
66
|
+
* @since 3.65.0
|
67
|
+
* @copyright schukai GmbH
|
68
|
+
* @memberOf Monster.Components.Form
|
69
|
+
* @summary A simple FieldSet
|
70
|
+
*/
|
71
|
+
class FieldSet extends CustomControl {
|
72
|
+
/**
|
73
|
+
* This method is called by the `instanceof` operator.
|
74
|
+
* @returns {symbol}
|
75
|
+
*/
|
76
|
+
static get [instanceSymbol]() {
|
77
|
+
return Symbol.for("@schukai/monster/components/form/fieldset@@instance");
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
*
|
82
|
+
* @return {Components.Form.FieldSet
|
83
|
+
*/
|
84
|
+
[assembleMethodSymbol]() {
|
85
|
+
super[assembleMethodSymbol]();
|
86
|
+
initControlReferences.call(this);
|
87
|
+
initEventHandler.call(this);
|
88
|
+
return this;
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
93
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
94
|
+
*
|
95
|
+
* The individual configuration values can be found in the table.
|
96
|
+
*
|
97
|
+
* @property {Object} templates Template definitions
|
98
|
+
* @property {string} templates.main Main template
|
99
|
+
* @property {Object} labels Label definitions
|
100
|
+
* @property {Object} actions Callbacks
|
101
|
+
* @property {string} actions.click="throw Error" Callback when clicked
|
102
|
+
* @property {Object} features Features
|
103
|
+
* @property {Object} classes CSS classes
|
104
|
+
* @property {boolean} disabled=false Disabled state
|
105
|
+
*/
|
106
|
+
get defaults() {
|
107
|
+
return Object.assign({}, super.defaults, {
|
108
|
+
templates: {
|
109
|
+
main: getTemplate(),
|
110
|
+
},
|
111
|
+
labels: {
|
112
|
+
},
|
113
|
+
classes: {
|
114
|
+
},
|
115
|
+
disabled: false,
|
116
|
+
features: {
|
117
|
+
},
|
118
|
+
actions: {
|
119
|
+
click: () => {
|
120
|
+
throw new Error("the click action is not defined");
|
121
|
+
},
|
122
|
+
},
|
123
|
+
value: null
|
124
|
+
});
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
*
|
129
|
+
* @return {string}
|
130
|
+
*/
|
131
|
+
static getTag() {
|
132
|
+
return "monster-field-set";
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
*
|
137
|
+
* @return {Array<CSSStyleSheet>}
|
138
|
+
*/
|
139
|
+
static getCSSStyleSheet() {
|
140
|
+
return [FieldSetStyleSheet];
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
/**
|
145
|
+
* The FieldSet.click() method simulates a click on the internal element.
|
146
|
+
*
|
147
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click}
|
148
|
+
*/
|
149
|
+
click() {
|
150
|
+
if (this.getOption("disabled") === true) {
|
151
|
+
return;
|
152
|
+
}
|
153
|
+
|
154
|
+
if (
|
155
|
+
this[fieldSetElementSymbol] &&
|
156
|
+
isFunction(this[fieldSetElementSymbol].click)
|
157
|
+
) {
|
158
|
+
this[fieldSetElementSymbol].click();
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
/**
|
163
|
+
* The Button.focus() method sets focus on the internal element.
|
164
|
+
*
|
165
|
+
* @param {Object} options
|
166
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus}
|
167
|
+
*/
|
168
|
+
focus(options) {
|
169
|
+
if (this.getOption("disabled") === true) {
|
170
|
+
return;
|
171
|
+
}
|
172
|
+
|
173
|
+
if (
|
174
|
+
this[fieldSetElementSymbol] &&
|
175
|
+
isFunction(this[fieldSetElementSymbol].focus)
|
176
|
+
) {
|
177
|
+
this[fieldSetElementSymbol].focus(options);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
/**
|
182
|
+
* The Button.blur() method removes focus from the internal element.
|
183
|
+
*/
|
184
|
+
blur() {
|
185
|
+
if (
|
186
|
+
this[fieldSetElementSymbol] &&
|
187
|
+
isFunction(this[fieldSetElementSymbol].blur)
|
188
|
+
) {
|
189
|
+
this[fieldSetElementSymbol].blur();
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
/**
|
194
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
|
195
|
+
* @return {boolean}
|
196
|
+
*/
|
197
|
+
static get formAssociated() {
|
198
|
+
return true;
|
199
|
+
}
|
200
|
+
|
201
|
+
/**
|
202
|
+
* The current value of the form control.
|
203
|
+
*
|
204
|
+
* ```js
|
205
|
+
* e = document.querySelector('monster-field-set');
|
206
|
+
* console.log(e.value)
|
207
|
+
* ```
|
208
|
+
*
|
209
|
+
* @property {string}
|
210
|
+
*/
|
211
|
+
get value() {
|
212
|
+
return this.getOption("value");
|
213
|
+
}
|
214
|
+
|
215
|
+
/**
|
216
|
+
* Set value of the form control.
|
217
|
+
*
|
218
|
+
* ```
|
219
|
+
* e = document.querySelector('monster-field-set');
|
220
|
+
* e.value=1
|
221
|
+
* ```
|
222
|
+
*
|
223
|
+
* @property {string} value
|
224
|
+
* @throws {Error} unsupported type
|
225
|
+
*/
|
226
|
+
set value(value) {
|
227
|
+
this.setOption("value", value);
|
228
|
+
try {
|
229
|
+
this?.setFormValue(this.value);
|
230
|
+
} catch (e) {
|
231
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
}
|
237
|
+
|
238
|
+
/**
|
239
|
+
* @private
|
240
|
+
* @return {initEventHandler}
|
241
|
+
* @fires Monster.Components.Form.event:monster-field-set-clicked
|
242
|
+
*/
|
243
|
+
function initEventHandler() {
|
244
|
+
const self = this;
|
245
|
+
const element = this[fieldSetElementSymbol];
|
246
|
+
|
247
|
+
const type = "click";
|
248
|
+
|
249
|
+
element.addEventListener(type, function (event) {
|
250
|
+
const callback = self.getOption("actions.click");
|
251
|
+
|
252
|
+
fireCustomEvent(self, "monster-field-set-clicked", {
|
253
|
+
element: self,
|
254
|
+
});
|
255
|
+
|
256
|
+
if (!isFunction(callback)) {
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
|
260
|
+
const element = findTargetElementFromEvent(
|
261
|
+
event,
|
262
|
+
ATTRIBUTE_ROLE,
|
263
|
+
"control",
|
264
|
+
);
|
265
|
+
|
266
|
+
if (!(element instanceof Node && self.hasNode(element))) {
|
267
|
+
return;
|
268
|
+
}
|
269
|
+
|
270
|
+
callback.call(self, event);
|
271
|
+
});
|
272
|
+
|
273
|
+
return this;
|
274
|
+
}
|
275
|
+
|
276
|
+
/**
|
277
|
+
* @private
|
278
|
+
*/
|
279
|
+
function initControlReferences() {
|
280
|
+
this[fieldSetElementSymbol] = this.shadowRoot.querySelector(
|
281
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
282
|
+
);
|
283
|
+
}
|
284
|
+
|
285
|
+
/**
|
286
|
+
* @private
|
287
|
+
* @return {string}
|
288
|
+
*/
|
289
|
+
function getTemplate() {
|
290
|
+
// language=HTML
|
291
|
+
return `
|
292
|
+
<div data-monster-role="control" part="control">
|
293
|
+
<monster-collapse>
|
294
|
+
<slot></slot>
|
295
|
+
</monster-collapse>
|
296
|
+
</div>`;
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
registerCustomElement(FieldSet);
|