@schukai/monster 3.67.0 → 3.68.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -2,34 +2,41 @@
2
2
 
3
3
 
4
4
 
5
+ ## [3.68.0] - 2024-06-23
6
+
7
+ ### Add Features
8
+
9
+ - add on/off action to toggle switch [#207](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/207)
10
+ ### Bug Fixes
11
+
12
+ - gitlab pipeline
13
+ ### Changes
14
+
15
+ - repair toggle test
16
+ - update changelog + mattermost info call
17
+
5
18
  ## [3.67.0] - 2024-06-22
6
19
 
7
20
  ### Add Features
8
21
 
9
- - new options to define the markers that are used for the label template. [#203](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/203) See merge request oss/libraries/javascript/monster[!53](https://gitlab.schukai.com/oss/libraries/javascript/monster/merge_requests/53)
10
22
  - new options to define the markers that are used for the label template [#203](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/203)
11
23
 
12
- ## 2024-06-22
13
- - new options to define the markers that are used for the label template [#203](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/203)
14
-
15
24
  ## [3.66.0] - 2024-06-21
16
25
 
17
26
  ### Add Features
18
27
 
19
28
  - new flag feature.useStrictValueComparison [#206](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/206)
20
29
  - new flag features.storeFetchedData and function Select::getLastFetchedData [#204](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/204)
30
+
21
31
  ### Bug Fixes
22
32
 
23
- - [#200](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/200)
24
- - [#200](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/200) changes
25
- - [#201](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/201)
26
- - slight color adjustments
33
+ - Reloading options in a select does not work [#200](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/200)
34
+
27
35
  ### Changes
28
36
 
29
37
  - tidy project files
30
- - [#200](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/200) move to close
31
- - [#200](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/200) move to close
32
-
38
+ - call Button use findElementWithSelectorUpwards [#201](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/201)
39
+ - slight color adjustments
33
40
 
34
41
 
35
42
  ## [3.65.21] - 2024-06-20
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.5","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.67.0"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.5","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.68.0"}
@@ -12,30 +12,49 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
- import { instanceSymbol } from "../../constants.mjs";
16
- import { addAttributeToken } from "../../dom/attributes.mjs";
15
+ import {instanceSymbol} from "../../constants.mjs";
16
+ import {addAttributeToken} from "../../dom/attributes.mjs";
17
17
  import {
18
- ATTRIBUTE_ERRORMESSAGE,
19
- ATTRIBUTE_ROLE,
18
+ ATTRIBUTE_ERRORMESSAGE,
19
+ ATTRIBUTE_ROLE,
20
20
  } from "../../dom/constants.mjs";
21
- import { CustomControl } from "../../dom/customcontrol.mjs";
21
+ import {CustomControl} from "../../dom/customcontrol.mjs";
22
22
  import {
23
- assembleMethodSymbol,
24
- registerCustomElement,
23
+ assembleMethodSymbol,
24
+ registerCustomElement,
25
25
  } from "../../dom/customelement.mjs";
26
- import { findTargetElementFromEvent } from "../../dom/events.mjs";
27
- import { isFunction } from "../../types/is.mjs";
28
- import { FieldSetStyleSheet } from "./stylesheet/field-set.mjs";
29
- import { fireCustomEvent } from "../../dom/events.mjs";
26
+ import {findTargetElementFromEvent} from "../../dom/events.mjs";
27
+ import {isFunction} from "../../types/is.mjs";
28
+ import {FieldSetStyleSheet} from "./stylesheet/field-set.mjs";
29
+ import {fireCustomEvent} from "../../dom/events.mjs";
30
30
  import "../layout/collapse.mjs";
31
+ import {ToggleSwitch} from "./toggle-switch.mjs";
31
32
 
32
- export { FieldSet };
33
+ export {FieldSet};
33
34
 
34
35
  /**
35
36
  * @private
36
37
  * @type {symbol}
37
38
  */
38
- export const fieldSetElementSymbol = Symbol("fieldSetElement");
39
+ const fieldSetElementSymbol = Symbol("fieldSetElement");
40
+
41
+ /**
42
+ * @private
43
+ * @type {symbol}
44
+ */
45
+ const collapseElementSymbol = Symbol("collapseElement");
46
+
47
+ /**
48
+ * @private
49
+ * @type {symbol}
50
+ */
51
+ const toggleSwitchElementSymbol = Symbol("toggleSwitchElement");
52
+
53
+ /**
54
+ * @private
55
+ * @type {symbol}
56
+ */
57
+ const extendedSwitchElementSymbol = Symbol("extendedSwitchElement");
39
58
 
40
59
  /**
41
60
  * This CustomControl creates a FieldSet element with a variety of options.
@@ -71,164 +90,174 @@ export const fieldSetElementSymbol = Symbol("fieldSetElement");
71
90
  * @summary A simple FieldSet
72
91
  */
73
92
  class FieldSet extends CustomControl {
74
- /**
75
- * This method is called by the `instanceof` operator.
76
- * @returns {symbol}
77
- */
78
- static get [instanceSymbol]() {
79
- return Symbol.for("@schukai/monster/components/form/fieldset@@instance");
80
- }
81
-
82
- /**
83
- *
84
- * @return {Components.Form.FieldSet
85
- */
86
- [assembleMethodSymbol]() {
87
- super[assembleMethodSymbol]();
88
- initControlReferences.call(this);
89
- initEventHandler.call(this);
90
- return this;
91
- }
92
-
93
- /**
94
- * To set the options via the html tag the attribute `data-monster-options` must be used.
95
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
96
- *
97
- * The individual configuration values can be found in the table.
98
- *
99
- * @property {Object} templates Template definitions
100
- * @property {string} templates.main Main template
101
- * @property {Object} labels Label definitions
102
- * @property {Object} actions Callbacks
103
- * @property {string} actions.click="throw Error" Callback when clicked
104
- * @property {Object} features Features
105
- * @property {Object} classes CSS classes
106
- * @property {boolean} disabled=false Disabled state
107
- */
108
- get defaults() {
109
- return Object.assign({}, super.defaults, {
110
- templates: {
111
- main: getTemplate(),
112
- },
113
- labels: {},
114
- classes: {},
115
- disabled: false,
116
- features: {},
117
- actions: {
118
- click: () => {
119
- throw new Error("the click action is not defined");
120
- },
121
- },
122
- value: null,
123
- });
124
- }
125
-
126
- /**
127
- *
128
- * @return {string}
129
- */
130
- static getTag() {
131
- return "monster-field-set";
132
- }
133
-
134
- /**
135
- *
136
- * @return {Array<CSSStyleSheet>}
137
- */
138
- static getCSSStyleSheet() {
139
- return [FieldSetStyleSheet];
140
- }
141
-
142
- /**
143
- * The FieldSet.click() method simulates a click on the internal element.
144
- *
145
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click}
146
- */
147
- click() {
148
- if (this.getOption("disabled") === true) {
149
- return;
150
- }
151
-
152
- if (
153
- this[fieldSetElementSymbol] &&
154
- isFunction(this[fieldSetElementSymbol].click)
155
- ) {
156
- this[fieldSetElementSymbol].click();
157
- }
158
- }
159
-
160
- /**
161
- * The Button.focus() method sets focus on the internal element.
162
- *
163
- * @param {Object} options
164
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus}
165
- */
166
- focus(options) {
167
- if (this.getOption("disabled") === true) {
168
- return;
169
- }
170
-
171
- if (
172
- this[fieldSetElementSymbol] &&
173
- isFunction(this[fieldSetElementSymbol].focus)
174
- ) {
175
- this[fieldSetElementSymbol].focus(options);
176
- }
177
- }
178
-
179
- /**
180
- * The Button.blur() method removes focus from the internal element.
181
- */
182
- blur() {
183
- if (
184
- this[fieldSetElementSymbol] &&
185
- isFunction(this[fieldSetElementSymbol].blur)
186
- ) {
187
- this[fieldSetElementSymbol].blur();
188
- }
189
- }
190
-
191
- /**
192
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
193
- * @return {boolean}
194
- */
195
- static get formAssociated() {
196
- return true;
197
- }
198
-
199
- /**
200
- * The current value of the form control.
201
- *
202
- * ```js
203
- * e = document.querySelector('monster-field-set');
204
- * console.log(e.value)
205
- * ```
206
- *
207
- * @property {string}
208
- */
209
- get value() {
210
- return this.getOption("value");
211
- }
212
-
213
- /**
214
- * Set value of the form control.
215
- *
216
- * ```
217
- * e = document.querySelector('monster-field-set');
218
- * e.value=1
219
- * ```
220
- *
221
- * @property {string} value
222
- * @throws {Error} unsupported type
223
- */
224
- set value(value) {
225
- this.setOption("value", value);
226
- try {
227
- this?.setFormValue(this.value);
228
- } catch (e) {
229
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
230
- }
231
- }
93
+ /**
94
+ * This method is called by the `instanceof` operator.
95
+ * @returns {symbol}
96
+ */
97
+ static get [instanceSymbol]() {
98
+ return Symbol.for("@schukai/monster/components/form/fieldset@@instance");
99
+ }
100
+
101
+ /**
102
+ *
103
+ * @return {Components.Form.FieldSet
104
+ */
105
+ [assembleMethodSymbol]() {
106
+ super[assembleMethodSymbol]();
107
+ initControlReferences.call(this);
108
+ initEventHandler.call(this);
109
+ updateExtendedFields.call(this);
110
+ return this;
111
+ }
112
+
113
+ /**
114
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
115
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
116
+ *
117
+ * The individual configuration values can be found in the table.
118
+ *
119
+ * @property {Object} templates Template definitions
120
+ * @property {string} templates.main Main template
121
+ * @property {Object} labels Label definitions
122
+ * @property {Object} actions Callbacks
123
+ * @property {string} actions.click="throw Error" Callback when clicked
124
+ * @property {Object} features Features
125
+ * @property {Object} classes CSS classes
126
+ * @property {boolean} disabled=false Disabled state
127
+ */
128
+ get defaults() {
129
+ return Object.assign({}, super.defaults, {
130
+ templates: {
131
+ main: getTemplate(),
132
+ },
133
+ labels: {},
134
+ classes: {},
135
+ disabled: false,
136
+ features: {},
137
+ actions: {
138
+ click: () => {
139
+ throw new Error("the click action is not defined");
140
+ },
141
+ },
142
+ value: null,
143
+ });
144
+ }
145
+
146
+ /**
147
+ *
148
+ * @return {string}
149
+ */
150
+ static getTag() {
151
+ return "monster-field-set";
152
+ }
153
+
154
+ /**
155
+ *
156
+ * @return {CSSStyleSheet[]}
157
+ */
158
+ static getCSSStyleSheet() {
159
+ return [FieldSetStyleSheet];
160
+ }
161
+
162
+ /**
163
+ * The FieldSet.click() method simulates a click on the internal element.
164
+ *
165
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click}
166
+ */
167
+ click() {
168
+ if (this.getOption("disabled") === true) {
169
+ return;
170
+ }
171
+
172
+ if (
173
+ this[fieldSetElementSymbol] &&
174
+ isFunction(this[fieldSetElementSymbol].click)
175
+ ) {
176
+ this[fieldSetElementSymbol].click();
177
+ }
178
+ }
179
+
180
+ /**
181
+ * The Button.focus() method sets focus on the internal element.
182
+ *
183
+ * @param {Object} options
184
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus}
185
+ */
186
+ focus(options) {
187
+ if (this.getOption("disabled") === true) {
188
+ return;
189
+ }
190
+
191
+ if (
192
+ this[fieldSetElementSymbol] &&
193
+ isFunction(this[fieldSetElementSymbol].focus)
194
+ ) {
195
+ this[fieldSetElementSymbol].focus(options);
196
+ }
197
+ }
198
+
199
+ /**
200
+ * The Button.blur() method removes focus from the internal element.
201
+ */
202
+ blur() {
203
+ if (
204
+ this[fieldSetElementSymbol] &&
205
+ isFunction(this[fieldSetElementSymbol].blur)
206
+ ) {
207
+ this[fieldSetElementSymbol].blur();
208
+ }
209
+ }
210
+
211
+ /**
212
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
213
+ * @return {boolean}
214
+ */
215
+ static get formAssociated() {
216
+ return true;
217
+ }
218
+
219
+ /**
220
+ * The current value of the form control.
221
+ *
222
+ * ```js
223
+ * e = document.querySelector('monster-field-set');
224
+ * console.log(e.value)
225
+ * ```
226
+ *
227
+ * @property {string}
228
+ */
229
+ get value() {
230
+ return this.getOption("value");
231
+ }
232
+
233
+ /**
234
+ * Set value of the form control.
235
+ *
236
+ * ```
237
+ * e = document.querySelector('monster-field-set');
238
+ * e.value=1
239
+ * ```
240
+ *
241
+ * @property {string} value
242
+ * @throws {Error} unsupported type
243
+ */
244
+ set value(value) {
245
+ this.setOption("value", value);
246
+ try {
247
+ this?.setFormValue(this.value);
248
+ } catch (e) {
249
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, e.message);
250
+ }
251
+ }
252
+ }
253
+
254
+ function updateExtendedFields() {
255
+ // check if slot has extended fields
256
+ getSlottedElements.call(this, "", "extended").forEach((node) => {
257
+ if (node.hasAttribute(ATTRIBUTE_EXTENDED)) {
258
+ this.hasExtended = true;
259
+ }
260
+ })
232
261
  }
233
262
 
234
263
  /**
@@ -237,45 +266,78 @@ class FieldSet extends CustomControl {
237
266
  * @fires Monster.Components.Form.event:monster-field-set-clicked
238
267
  */
239
268
  function initEventHandler() {
240
- const self = this;
241
- const element = this[fieldSetElementSymbol];
242
-
243
- const type = "click";
244
-
245
- element.addEventListener(type, function (event) {
246
- const callback = self.getOption("actions.click");
269
+ // const self = this;
270
+ // const element = this[fieldSetElementSymbol];
271
+ //
272
+ // const type = "click";
247
273
 
248
- fireCustomEvent(self, "monster-field-set-clicked", {
249
- element: self,
250
- });
274
+ // element.addEventListener(type, function (event) {
275
+ // const callback = self.getOption("actions.click");
276
+ //
277
+ // fireCustomEvent(self, "monster-field-set-clicked", {
278
+ // element: self,
279
+ // });
280
+ //
281
+ // if (!isFunction(callback)) {
282
+ // return;
283
+ // }
284
+ //
285
+ // const element = findTargetElementFromEvent(
286
+ // event,
287
+ // ATTRIBUTE_ROLE,
288
+ // "control",
289
+ // );
290
+ //
291
+ // if (!(element instanceof Node && self.hasNode(element))) {
292
+ // return;
293
+ // }
294
+ //
295
+ // callback.call(self, event);
296
+ // });
251
297
 
252
- if (!isFunction(callback)) {
253
- return;
254
- }
255
298
 
256
- const element = findTargetElementFromEvent(
257
- event,
258
- ATTRIBUTE_ROLE,
259
- "control",
260
- );
299
+ this[toggleSwitchElementSymbol].setOption("actions.on", () => {
300
+ console.log( this[collapseElementSymbol],"!!!")
301
+ this[collapseElementSymbol].open();
302
+ });
261
303
 
262
- if (!(element instanceof Node && self.hasNode(element))) {
263
- return;
264
- }
304
+ this[toggleSwitchElementSymbol].setOption("actions.off", () => {
305
+ this[collapseElementSymbol].close();
306
+ });
307
+
308
+ // this[extendedSwitchElementSymbol].addEventListener(type, function (event) {
309
+ // const element = findTargetElementFromEvent(
310
+ // event,
311
+ // ATTRIBUTE_ROLE,
312
+ // "extended-switch",
313
+ // );
314
+ //
315
+ //
316
+ //
317
+ // })
265
318
 
266
- callback.call(self, event);
267
- });
268
-
269
- return this;
319
+ return this;
270
320
  }
271
321
 
272
322
  /**
273
323
  * @private
274
324
  */
275
325
  function initControlReferences() {
276
- this[fieldSetElementSymbol] = this.shadowRoot.querySelector(
277
- `[${ATTRIBUTE_ROLE}="control"]`,
278
- );
326
+ this[fieldSetElementSymbol] = this.shadowRoot.querySelector(
327
+ `[${ATTRIBUTE_ROLE}="control"]`,
328
+ );
329
+
330
+ this[extendedSwitchElementSymbol] = this.shadowRoot.querySelector(
331
+ `[${ATTRIBUTE_ROLE}="extended-switch"]`,
332
+ );
333
+
334
+ this[collapseElementSymbol] = this.shadowRoot.querySelector(
335
+ `[${ATTRIBUTE_ROLE}="collapse"]`,
336
+ );
337
+
338
+ this[toggleSwitchElementSymbol] = this.shadowRoot.querySelector(
339
+ `monster-toggle-switch`,
340
+ );
279
341
  }
280
342
 
281
343
  /**
@@ -283,12 +345,20 @@ function initControlReferences() {
283
345
  * @return {string}
284
346
  */
285
347
  function getTemplate() {
286
- // language=HTML
287
- return `
348
+ // language=HTML
349
+ return `
288
350
  <div data-monster-role="control" part="control">
289
- <monster-collapse>
290
- <slot></slot>
291
- </monster-collapse>
351
+ <div data-monster-role="header">
352
+ <monster-toggle-switch class="hidden"></monster-toggle-switch>
353
+ </div>
354
+ <div>
355
+ <slot></slot>
356
+ <monster-collapse data-monster-role="collapse">
357
+ <slot name="extended"></slot>
358
+ </monster-collapse>
359
+ </div>
360
+
361
+
292
362
  </div>`;
293
363
  }
294
364
 
@@ -9,5 +9,12 @@
9
9
  @import "../../style/floating-ui.pcss";
10
10
 
11
11
  [data-monster-role=control] {
12
- border: 1px solid red;
13
- }
12
+
13
+ }
14
+
15
+
16
+ [data-monster-role=header] {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: flex-end;
20
+ }
@@ -10,24 +10,21 @@
10
10
  margin: 0;
11
11
  outline: none;
12
12
  box-sizing: border-box;
13
-
13
+
14
14
  &:focus {
15
15
  outline: 1px dashed var(--monster-color-selection-3);
16
16
  outline-offset: 2px;
17
17
  }
18
18
 
19
-
20
19
  & .switch {
21
20
  position: relative;
22
- height: 2.5em;
23
- border-width: thin;
21
+ border-width: var(--monster-border-width);
24
22
  border-style: var(--monster-border-style);
25
23
  transition: background-color 0.2s;
26
24
  display: inline-grid;
27
25
  grid-template-columns: 1fr 1fr;
28
26
  box-sizing: border-box;
29
27
  width: 100%;
30
-
31
28
  }
32
29
 
33
30
  & .label {
@@ -35,10 +32,8 @@
35
32
  white-space: nowrap;
36
33
  overflow: hidden;
37
34
  text-overflow: ellipsis;
38
- height: 2.5em;
39
35
  display: block;
40
36
  text-align: center;
41
- line-height: 2.5em;
42
37
  user-select: none;
43
38
  padding: 0 0.2em;
44
39
  }
@@ -69,7 +64,6 @@
69
64
  visibility: hidden;
70
65
  }
71
66
 
72
-
73
67
  & .switch[data-monster-state="on"] .switch-slider {
74
68
  transform: translateX(100%);
75
69