@schukai/monster 3.73.5 → 3.73.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,6 @@ import {
32
32
  assembleMethodSymbol,
33
33
  getSlottedElements,
34
34
  registerCustomElement,
35
- updaterTransformerMethodsSymbol,
36
35
  } from "../../dom/customelement.mjs";
37
36
  import {
38
37
  findTargetElementFromEvent,
@@ -84,120 +83,120 @@ const clickToLoadOptionsMessage = "Click to load options.";
84
83
 
85
84
  /**
86
85
  * @private
87
- * @type {symbol}
86
+ * @type {Symbol}
88
87
  */
89
88
  const timerCallbackSymbol = Symbol("timerCallback");
90
89
 
91
90
  /**
92
91
  * @private
93
- * @type {symbol}
92
+ * @type {Symbol}
94
93
  */
95
94
  const keyFilterEventSymbol = Symbol("keyFilterEvent");
96
95
 
97
96
  /**
98
97
  * @private
99
- * @type {symbol}
98
+ * @type {Symbol}
100
99
  */
101
100
  const lazyLoadDoneSymbol = Symbol("lazyLoadDone");
102
101
 
103
102
  /**
104
103
  * @private
105
- * @type {symbol}
104
+ * @type {Symbol}
106
105
  */
107
106
  const isLoadingSymbol = Symbol("isLoading");
108
107
 
109
108
  /**
110
109
  * local symbol
111
110
  * @private
112
- * @type {symbol}
111
+ * @type {Symbol}
113
112
  */
114
113
  const closeEventHandler = Symbol("closeEventHandler");
115
114
 
116
115
  /**
117
116
  * local symbol
118
117
  * @private
119
- * @type {symbol}
118
+ * @type {Symbol}
120
119
  */
121
120
  const clearOptionEventHandler = Symbol("clearOptionEventHandler");
122
121
 
123
122
  /**
124
123
  * local symbol
125
124
  * @private
126
- * @type {symbol}
125
+ * @type {Symbol}
127
126
  */
128
127
  const resizeObserverSymbol = Symbol("resizeObserver");
129
128
 
130
129
  /**
131
130
  * local symbol
132
131
  * @private
133
- * @type {symbol}
132
+ * @type {Symbol}
134
133
  */
135
134
  const keyEventHandler = Symbol("keyEventHandler");
136
135
 
137
136
  /**
138
137
  * local symbol
139
138
  * @private
140
- * @type {symbol}
139
+ * @type {Symbol}
141
140
  */
142
141
  const lastFetchedDataSymbol = Symbol("lastFetchedData");
143
142
  /**
144
143
  * local symbol
145
144
  * @private
146
- * @type {symbol}
145
+ * @type {Symbol}
147
146
  */
148
147
  const inputEventHandler = Symbol("inputEventHandler");
149
148
 
150
149
  /**
151
150
  * local symbol
152
151
  * @private
153
- * @type {symbol}
152
+ * @type {Symbol}
154
153
  */
155
154
  const changeEventHandler = Symbol("changeEventHandler");
156
155
 
157
156
  /**
158
157
  * local symbol
159
158
  * @private
160
- * @type {symbol}
159
+ * @type {Symbol}
161
160
  */
162
161
  const controlElementSymbol = Symbol("controlElement");
163
162
 
164
163
  /**
165
164
  * local symbol
166
165
  * @private
167
- * @type {symbol}
166
+ * @type {Symbol}
168
167
  */
169
168
  const selectionElementSymbol = Symbol("selectionElement");
170
169
 
171
170
  /**
172
171
  * local symbol
173
172
  * @private
174
- * @type {symbol}
173
+ * @type {Symbol}
175
174
  */
176
175
  const containerElementSymbol = Symbol("containerElement");
177
176
 
178
177
  /**
179
178
  * local symbol
180
179
  * @private
181
- * @type {symbol}
180
+ * @type {Symbol}
182
181
  */
183
182
  const popperElementSymbol = Symbol("popperElement");
184
183
 
185
184
  /**
186
185
  * local symbol
187
186
  * @private
188
- * @type {symbol}
187
+ * @type {Symbol}
189
188
  */
190
189
  const inlineFilterElementSymbol = Symbol("inlineFilterElement");
191
190
  /**
192
191
  * local symbol
193
192
  * @private
194
- * @type {symbol}
193
+ * @type {Symbol}
195
194
  */
196
195
  const popperFilterElementSymbol = Symbol("popperFilterElement");
197
196
  /**
198
197
  * local symbol
199
198
  * @private
200
- * @type {symbol}
199
+ * @type {Symbol}
201
200
  */
202
201
  const popperFilterContainerElementSymbol = Symbol(
203
202
  "popperFilterContainerElement",
@@ -206,27 +205,27 @@ const popperFilterContainerElementSymbol = Symbol(
206
205
  /**
207
206
  * local symbol
208
207
  * @private
209
- * @type {symbol}
208
+ * @type {Symbol}
210
209
  */
211
210
  const optionsElementSymbol = Symbol("optionsElement");
212
211
 
213
212
  /**
214
213
  * local symbol
215
214
  * @private
216
- * @type {symbol}
215
+ * @type {Symbol}
217
216
  */
218
217
  const noOptionsAvailableElementSymbol = Symbol("noOptionsAvailableElement");
219
218
 
220
219
  /**
221
220
  * local symbol
222
221
  * @private
223
- * @type {symbol}
222
+ * @type {Symbol}
224
223
  */
225
224
  const statusOrRemoveBadgesElementSymbol = Symbol("statusOrRemoveBadgesElement");
226
225
 
227
226
  /**
228
227
  * @private
229
- * @type {symbol}
228
+ * @type {Symbol}
230
229
  */
231
230
  const areOptionsAvailableAndInitSymbol = Symbol("@@areOptionsAvailableAndInit");
232
231
 
@@ -271,69 +270,20 @@ const FILTER_POSITION_POPPER = "popper";
271
270
  const FILTER_POSITION_INLINE = "inline";
272
271
 
273
272
  /**
274
- * @typedef {Object} Selection
275
- * @property {*} value
276
- * @property {String} label
277
- * @memberOf Monster.Components.Form
278
- * @since 1.2.0
279
- */
280
-
281
- /**
282
- * This CustomControl creates a select element with a variety of options.
283
- * It supports filtering, local and remote, multiple selection and has a
284
- * template system for displaying the options.
285
- *
286
- * <img src="./images/select.png">
273
+ * A select control that can be used to select one or more options from a list.
287
274
  *
288
- * Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library
289
- * as well as [pooperjs](https://popper.js.org/docs/v2/).
275
+ * @fragments /fragments/components/form/select/
290
276
  *
291
- * You can create this control either by specifying the HTML tag `<monster-select />` directly in the HTML or using
292
- * Javascript via the `document.createElement('monster-select');` method.
293
- *
294
- * ```html
295
- * <monster-select></monster-select>
296
- * ```
297
- *
298
- * Or you can create this CustomControl directly in Javascript:
299
- *
300
- * ```js
301
- * import {Select} from '@schukai/component-form/source/select.js';
302
- * document.createElement('monster-select');
303
- * ```
304
- *
305
- * ## Events
306
- *
307
- * The event `monster-change` is sent as soon as someone has clicked on a input control.
308
- * `monster-changed` is sent as soon as the control has processed this input.
309
- * The `monster-changed` event is sent when setting a selection. If the options have been set, the `monster-options-set` event is sent.
310
- *
311
- * The CustomEvent has the property [`detail`](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail).
312
- *
313
- * ```
314
- * node.addEventListener('monster-change',(e)=>console.log(e.detail))
315
- * node.addEventListener('monster-changed',(e)=>console.log(e.detail))
316
- * node.addEventListener('monster-selected',(e)=>console.log(e.detail))
317
- * node.addEventListener('monster-options-set',(e)=>console.log(e.detail))
318
- * ```
319
- *
320
- * @externalExample ../../../example/components/form/select.mjs
321
- * @startuml select.png
322
- * skinparam monochrome true
323
- * skinparam shadowing false
324
- * HTMLElement <|-- CustomElement
325
- * CustomElement <|-- CustomControl
326
- * CustomControl <|-- Select
327
- * @enduml
277
+ * @example /examples/components/form/select-simple
278
+ * @example /examples/components/form/select-with-options
328
279
  *
329
280
  * @since 1.0.0
330
281
  * @copyright schukai GmbH
331
- * @memberOf Monster.Components.Form
332
- * @summary A highly configurable select control
333
- * @fires Monster.Components.Form.event:monster-options-set
334
- * @fires Monster.Components.Form.event:monster-selected
335
- * @fires Monster.Components.Form.event:monster-change
336
- * @fires Monster.Components.Form.event:monster-changed
282
+ * @summary A beautiful select control that can make your life easier and also looks good.
283
+ * @fires monster-options-set
284
+ * @fires monster-selected
285
+ * @fires monster-change
286
+ * @fires monster-changed
337
287
  */
338
288
  class Select extends CustomControl {
339
289
  /**
@@ -346,7 +296,7 @@ class Select extends CustomControl {
346
296
 
347
297
  /**
348
298
  * This method is called by the `instanceof` operator.
349
- * @returns {symbol}
299
+ * @returns {Symbol}
350
300
  * @since 2.1.0
351
301
  */
352
302
  static get [instanceSymbol]() {
@@ -540,7 +490,7 @@ class Select extends CustomControl {
540
490
  }
541
491
 
542
492
  /**
543
- * @return {Monster.Components.Form.Select}
493
+ * @return {Select}
544
494
  */
545
495
  [assembleMethodSymbol]() {
546
496
  const self = this;
@@ -431,7 +431,7 @@ function initEventHandler() {
431
431
  }
432
432
 
433
433
  return this;
434
- }
434
+ }
435
435
 
436
436
  /**
437
437
  * @private
@@ -469,6 +469,7 @@ function importEntries() {
469
469
  });
470
470
  } catch (error) {
471
471
  addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
472
+ return this;
472
473
  }
473
474
 
474
475
  const options = [];
@@ -500,7 +501,6 @@ function importEntries() {
500
501
  }
501
502
 
502
503
  this.setOption("entries", options);
503
-
504
504
  return this;
505
505
  }
506
506
 
@@ -12,13 +12,14 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
- import { isArray, isObject } from "../types/is.mjs";
16
- import { Node } from "../types/node.mjs";
17
- import { NodeList } from "../types/nodelist.mjs";
18
- import { assembleParts } from "./buildmap.mjs";
19
- import { extend } from "./extend.mjs";
15
+ import {isArray, isObject} from "../types/is.mjs";
16
+ import {Node} from "../types/node.mjs";
17
+ import {NodeList} from "../types/nodelist.mjs";
18
+ import {clone} from "../util/clone.mjs";
19
+ import {assembleParts} from "./buildmap.mjs";
20
+ import {extend} from "./extend.mjs";
20
21
 
21
- export { buildTree };
22
+ export {buildTree};
22
23
 
23
24
  /**
24
25
  * @private
@@ -139,63 +140,69 @@ const rootSymbol = Symbol("root");
139
140
  * @since 1.26.0
140
141
  */
141
142
  function buildTree(subject, selector, idKey, parentIDKey, options) {
142
- const nodes = new Map();
143
-
144
- if (!isObject(options)) {
145
- options = {};
146
- }
147
-
148
- options = extend(
149
- {},
150
- {
151
- rootReferences: [null, undefined],
152
- filter: undefined,
153
- },
154
- options,
155
- );
156
-
157
- const filter = options?.filter;
158
- let rootReferences = options.rootReferences;
159
- if (!isArray(rootReferences)) {
160
- rootReferences = [rootReferences];
161
- }
162
-
163
- const childMap = assembleParts(subject, selector, filter, function (o, k, m) {
164
- const key = o?.[idKey];
165
- let ref = o?.[parentIDKey];
166
- if (rootReferences.indexOf(ref) !== -1) ref = rootSymbol;
167
-
168
- if (key === undefined) {
169
- throw new Error("the object has no value for the specified id");
170
- }
171
-
172
- o[parentSymbol] = ref;
173
-
174
- const node = new Node(o);
175
- this.has(ref)
176
- ? this.get(ref).add(node)
177
- : this.set(ref, new NodeList().add(node));
178
- nodes.set(key, node);
179
- });
180
-
181
- nodes.forEach((node) => {
143
+ const nodes = new Map();
144
+
145
+ const maxDepth = 100;
146
+
147
+ if (!isObject(options)) {
148
+ options = {};
149
+ }
150
+
151
+ options = extend(
152
+ {},
153
+ {
154
+ rootReferences: [null, undefined],
155
+ filter: undefined,
156
+ },
157
+ options,
158
+ );
159
+
160
+ const filter = options?.filter;
161
+ let rootReferences = options.rootReferences;
162
+ if (!isArray(rootReferences)) {
163
+ rootReferences = [rootReferences];
164
+ }
165
+
166
+ const childMap = assembleParts(subject, selector, filter, function (o, k, m) {
167
+ const key = o?.[idKey];
168
+ let ref = o?.[parentIDKey];
169
+ if (rootReferences.indexOf(ref) !== -1) ref = rootSymbol;
170
+
171
+ if (key === undefined) {
172
+ throw new Error("the object has no value for the specified id");
173
+ }
174
+
175
+ o[parentSymbol] = ref;
176
+
177
+ const node = new Node(o);
178
+ this.has(ref)
179
+ ? this.get(ref).add(node)
180
+ : this.set(ref, new NodeList().add(node));
181
+ nodes.set(key, node);
182
+ });
183
+
184
+ nodes.forEach((node) => {
182
185
  const id = node?.["value"]?.[idKey];
183
186
 
187
+ if (id === undefined) {
188
+ throw new Error("the object has no value for the specified id");
189
+ }
190
+
184
191
  if (childMap.has(id)) {
185
- node.childNodes = childMap.get(id);
186
- childMap.delete(id);
192
+ node.childNodes = childMap.get(id);
193
+ childMap.delete(id);
187
194
  }
188
195
  });
189
196
 
190
- const list = new NodeList();
197
+ const list = new NodeList();
191
198
 
192
- childMap.forEach((s) => {
193
- if (s instanceof Set) {
194
- s.forEach((n) => {
195
- list.add(n);
196
- });
197
- }
198
- });
199
+ childMap.forEach((s) => {
200
+ if (s instanceof Set) {
201
+ s.forEach((n) => {
202
+ list.add(n);
203
+ });
204
+ }
205
+ });
199
206
 
200
- return list;
207
+ return list;
201
208
  }