wj-elements 0.1.129 → 0.1.130
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.
- package/README.md +8 -4
- package/dist/assets/tags.json +3252 -22012
- package/dist/dark.css +213 -210
- package/dist/{infinite-scroll.element-R3y_ZQj6.js → infinite-scroll.element-BmojLp3Z.js} +16 -34
- package/dist/light.css +511 -501
- package/dist/{list.element-syl98NWS.js → list.element-Ce1vIm1O.js} +2 -11
- package/dist/localize.js +1 -2
- package/dist/{popup.element-C0a1z1y2.js → popup.element-4DNn6DjX.js} +102 -224
- package/dist/{router-links-I2vcmVCs.js → router-links-CJnOdbas.js} +30 -77
- package/dist/styles.css +485 -473
- package/dist/wje-accordion-item.js +12 -10
- package/dist/wje-accordion.js +51 -14
- package/dist/wje-animation.js +9 -13
- package/dist/wje-aside.js +6 -11
- package/dist/wje-avatar.js +7 -10
- package/dist/wje-badge.js +23 -18
- package/dist/wje-breadcrumb.js +30 -48
- package/dist/wje-breadcrumbs.js +80 -23
- package/dist/wje-button-group.js +15 -21
- package/dist/wje-button.js +64 -71
- package/dist/wje-card-content.js +9 -12
- package/dist/wje-card-controls.js +9 -12
- package/dist/wje-card-header.js +4 -8
- package/dist/wje-card-subtitle.js +4 -7
- package/dist/wje-card-title.js +4 -7
- package/dist/wje-card.js +13 -14
- package/dist/wje-carousel-item.js +25 -0
- package/dist/wje-carousel.js +140 -23
- package/dist/wje-checkbox.js +294 -48
- package/dist/wje-chip.js +30 -11
- package/dist/wje-col.js +7 -17
- package/dist/wje-color-picker.js +32 -34
- package/dist/wje-container.js +5 -9
- package/dist/wje-copy-button.js +11 -15
- package/dist/wje-dialog.js +12 -17
- package/dist/wje-divider.js +1 -4
- package/dist/wje-dropdown.js +41 -23
- package/dist/wje-element.js +214 -196
- package/dist/wje-file-upload-item.js +11 -21
- package/dist/wje-file-upload.js +64 -59
- package/dist/wje-footer.js +2 -9
- package/dist/wje-form.js +22 -0
- package/dist/wje-format-digital.js +4 -12
- package/dist/wje-grid.js +23 -2
- package/dist/wje-header.js +2 -9
- package/dist/wje-icon-picker.js +14 -33
- package/dist/wje-icon.js +9 -12
- package/dist/wje-img-comparer.js +7 -15
- package/dist/wje-img.js +3 -12
- package/dist/wje-infinite-scroll.js +1 -1
- package/dist/wje-input-file.js +19 -19
- package/dist/wje-input.js +50 -66
- package/dist/wje-item.js +11 -15
- package/dist/wje-kanban.js +22 -23
- package/dist/wje-label.js +3 -11
- package/dist/wje-list.js +1 -1
- package/dist/wje-main.js +3 -10
- package/dist/wje-masonry.js +16 -21
- package/dist/wje-master.js +197 -236
- package/dist/wje-menu-button.js +4 -15
- package/dist/wje-menu-item.js +209 -37
- package/dist/wje-menu-label.js +3 -10
- package/dist/wje-menu.js +5 -17
- package/dist/wje-option.js +18 -29
- package/dist/wje-options.js +141 -55
- package/dist/wje-orgchart-group.js +8 -15
- package/dist/wje-orgchart-item.js +10 -157
- package/dist/wje-orgchart.js +3 -9
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +11 -25
- package/dist/wje-qr-code.js +27 -11
- package/dist/wje-radio-group.js +20 -45
- package/dist/wje-radio.js +45 -7
- package/dist/wje-rate.js +35 -58
- package/dist/wje-relative-time.js +19 -29
- package/dist/wje-reorder-dropzone.js +20 -2
- package/dist/wje-reorder-handle.js +62 -3
- package/dist/wje-reorder-item.js +20 -2
- package/dist/wje-reorder.js +43 -49
- package/dist/wje-route.js +2 -8
- package/dist/wje-router-link.js +9 -12
- package/dist/wje-router-outlet.js +35 -37
- package/dist/wje-routerx.js +231 -340
- package/dist/wje-row.js +7 -9
- package/dist/wje-select.js +72 -99
- package/dist/wje-slider.js +13 -32
- package/dist/wje-sliding-container.js +3 -7
- package/dist/wje-split-view.js +8 -22
- package/dist/wje-status.js +8 -12
- package/dist/wje-step.js +18 -0
- package/dist/wje-stepper.js +41 -4823
- package/dist/wje-store.js +178 -74
- package/dist/wje-tab-group.js +7 -19
- package/dist/wje-tab-panel.js +3 -12
- package/dist/wje-tab.js +5 -16
- package/dist/wje-textarea.js +127 -47
- package/dist/wje-thumbnail.js +9 -14
- package/dist/wje-toast.js +27 -64
- package/dist/wje-toggle.js +21 -32
- package/dist/wje-toolbar-action.js +10 -14
- package/dist/wje-toolbar.js +10 -15
- package/dist/wje-tooltip.js +33 -25
- package/dist/wje-visually-hidden.js +9 -13
- package/package.json +15 -8
package/dist/wje-row.js
CHANGED
|
@@ -6,16 +6,18 @@ const styles = "/*\n[ Row ]\n*/\n:host {\n display: flex;\n flex-wrap: wrap;\n
|
|
|
6
6
|
class Row extends WJElement {
|
|
7
7
|
/**
|
|
8
8
|
* Creates an instance of Row.
|
|
9
|
-
*
|
|
10
|
-
* @constructor
|
|
9
|
+
* @class
|
|
11
10
|
*/
|
|
12
11
|
constructor() {
|
|
13
12
|
super();
|
|
13
|
+
/**
|
|
14
|
+
* The class name for the component.
|
|
15
|
+
* @type {string}
|
|
16
|
+
*/
|
|
14
17
|
__publicField(this, "className", "Row");
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Returns the CSS styles for the component.
|
|
18
|
-
*
|
|
19
21
|
* @static
|
|
20
22
|
* @returns {CSSStyleSheet}
|
|
21
23
|
*/
|
|
@@ -29,16 +31,12 @@ class Row extends WJElement {
|
|
|
29
31
|
this.isShadowRoot = "open";
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
* Draws the component.
|
|
33
|
-
* @param {Object} context - The context for drawing.
|
|
34
|
-
* @param {Object} store - The store for drawing.
|
|
35
|
-
* @param {Object} params - The parameters for drawing.
|
|
34
|
+
* Draws the component for the row.
|
|
36
35
|
* @returns {DocumentFragment}
|
|
37
36
|
*/
|
|
38
37
|
draw() {
|
|
39
38
|
let fragment = document.createDocumentFragment();
|
|
40
|
-
if (this.hasAttribute("wrap"))
|
|
41
|
-
this.classList.add("wje-wrap");
|
|
39
|
+
if (this.hasAttribute("wrap")) this.classList.add("wje-wrap");
|
|
42
40
|
let element = document.createElement("slot");
|
|
43
41
|
fragment.appendChild(element);
|
|
44
42
|
return fragment;
|
package/dist/wje-select.js
CHANGED
|
@@ -10,13 +10,11 @@ import Chip from "./wje-chip.js";
|
|
|
10
10
|
import Input from "./wje-input.js";
|
|
11
11
|
import Option from "./wje-option.js";
|
|
12
12
|
import Options from "./wje-options.js";
|
|
13
|
-
import { P as Popup } from "./popup.element-
|
|
14
|
-
const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n
|
|
13
|
+
import { P as Popup } from "./popup.element-4DNn6DjX.js";
|
|
14
|
+
const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n --wje-select-border-width: 1px;\n --wje-select-border-style: solid;\n --wje-select-border-color: var(--wje-border-color);\n\n --wje-select-options-border-width: 1px;\n --wje-select-options-border-style: var(--wje-border-style);\n --wje-select-options-border-color: var(--wje-border-color);\n\n --wje-select-background: var(--wje-background);\n --wje-select-line-height: 20px;\n --wje-select-color: var(--wje-color);\n --wje-select-border-radius: var(--wje-border-radius-medium);\n\n --wje-select-margin-bottom: 0.5rem;\n margin-bottom: var(--wje-select-margin-bottom);\n\n width: 100%;\n display: block;\n [slot='arrow'] {\n transform: rotate(0deg);\n transition: all 0.2s ease-in;\n }\n}\n\n.native-select {\n &.default {\n .wrapper {\n display: block;\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n padding-inline: 0.5rem;\n padding-top: 0.125rem;\n padding-bottom: 0.125rem;\n }\n .input-wrapper {\n padding: 0;\n min-height: 28px;\n margin-top: -4px;\n }\n &.focused {\n wje-label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n wje-label {\n margin: 0;\n display: block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease 0s;\n line-height: var(--wje-select-line-height);\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n }\n &.standard {\n .wrapper {\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n }\n .input-wrapper {\n background: transparent;\n width: 100%;\n }\n }\n}\n\n.wrapper {\n display: flex;\n width: 100%;\n}\n\n.input-wrapper {\n display: grid;\n grid-template-columns: auto 1fr auto auto auto;\n align-items: center;\n background-color: var(--wje-select-background);\n min-height: 28px;\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n appearance: none;\n padding: 2px 0.5rem;\n font-size: 14px !important;\n font-weight: normal;\n vertical-align: middle;\n}\n\ninput {\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n font-size: 14px !important;\n font-weight: 400;\n letter-spacing: 0.01em;\n border: medium;\n height: 25px;\n min-height: 25px;\n padding: 0;\n background: none;\n box-shadow: none;\n width: 100%;\n outline: 0;\n font-size: 14px !important;\n}\n\n::placeholder {\n opacity: 1;\n}\n\n:host [active] {\n .wrapper {\n border-radius: var(--wje-select-border-radius) var(--wje-select-border-radius) 0 0;\n }\n [slot='arrow'] {\n transform: rotate(180deg);\n transition: all 0.2s ease-in;\n }\n}\n\n.options-wrapper {\n border-width: var(--wje-select-options-border-width);\n border-style: var(--wje-select-options-border-style);\n border-color: var(--wje-select-options-border-color);\n border-radius: 0 0 var(--wje-select-border-radius) var(--wje-select-border-radius);\n margin-top: calc(0px - var(--wje-select-border-width));\n background: var(--wje-select-background);\n overflow: hidden;\n}\n\n.find {\n --wje-input-border-radius: 0;\n --wje-input-border-width: 0 0 1px 0;\n}\n\n.list {\n overflow: auto;\n height: 100%;\n}\n\n.options-wrapper:has(.find) .list {\n height: calc(100% - 32px - 0.5rem);\n}\n\n:host([multiple]) input {\n position: absolute;\n z-index: -1;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n opacity: 0;\n}\n\n:host([multiple]) .chips {\n display: flex;\n flex: 1;\n align-items: center;\n flex-wrap: wrap;\n}\n\n:host([disabled]) .input-wrapper {\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n}\n\n.counter {\n padding-inline: 0.5rem;\n}\n\nwje-chip {\n --wje-chip-margin: 0 0.25rem 0 0;\n}\n\nwje-button {\n --wje-padding-top: 0.25rem;\n --wje-padding-start: 0.25rem;\n --wje-padding-end: 0.25rem;\n --wje-padding-bottom: 0.25rem;\n --wje-button-margin-inline: 0 0.25rem;\n}\n\n.slot-start,\n.slot-end {\n &:not(:empty) {\n margin-right: 0.5rem;\n }\n}\n";
|
|
15
15
|
class Select extends WJElement {
|
|
16
16
|
/**
|
|
17
17
|
* Creates an instance of Select.
|
|
18
|
-
*
|
|
19
|
-
* @constructor
|
|
20
18
|
*/
|
|
21
19
|
constructor() {
|
|
22
20
|
super();
|
|
@@ -33,8 +31,7 @@ class Select extends WJElement {
|
|
|
33
31
|
__publicField(this, "className", "Select");
|
|
34
32
|
/**
|
|
35
33
|
* Handles the option change event.
|
|
36
|
-
*
|
|
37
|
-
* @param {Event} e - The event.
|
|
34
|
+
* @param {Event} e The event.
|
|
38
35
|
*/
|
|
39
36
|
__publicField(this, "optionChange", (e) => {
|
|
40
37
|
let allOptions = this.getAllOptions();
|
|
@@ -50,8 +47,7 @@ class Select extends WJElement {
|
|
|
50
47
|
});
|
|
51
48
|
/**
|
|
52
49
|
* Handles the chip remove event.
|
|
53
|
-
*
|
|
54
|
-
* @param {Event} e - The event.
|
|
50
|
+
* @param {Event} e The event.
|
|
55
51
|
*/
|
|
56
52
|
__publicField(this, "removeChip", (e) => {
|
|
57
53
|
let option = e.target.option;
|
|
@@ -66,7 +62,7 @@ class Select extends WJElement {
|
|
|
66
62
|
}
|
|
67
63
|
/**
|
|
68
64
|
* Setter for the value attribute.
|
|
69
|
-
* @param {string} value
|
|
65
|
+
* @param {string} value The value to set.
|
|
70
66
|
*/
|
|
71
67
|
set value(value) {
|
|
72
68
|
if (Array.isArray(value)) {
|
|
@@ -105,13 +101,11 @@ class Select extends WJElement {
|
|
|
105
101
|
}
|
|
106
102
|
/**
|
|
107
103
|
* Setter for the invalid attribute.
|
|
108
|
-
* @param {boolean} isInvalid
|
|
104
|
+
* @param {boolean} isInvalid Whether the input is invalid.
|
|
109
105
|
*/
|
|
110
106
|
set invalid(isInvalid) {
|
|
111
|
-
if (isInvalid)
|
|
112
|
-
|
|
113
|
-
else
|
|
114
|
-
this.removeAttribute("invalid");
|
|
107
|
+
if (isInvalid) this.setAttribute("invalid", "");
|
|
108
|
+
else this.removeAttribute("invalid");
|
|
115
109
|
}
|
|
116
110
|
/**
|
|
117
111
|
* Getter for the form attribute.
|
|
@@ -169,22 +163,20 @@ class Select extends WJElement {
|
|
|
169
163
|
* @summary Setter for the defaultValue attribute.
|
|
170
164
|
* This method sets the 'value' attribute of the custom input element to the provided value.
|
|
171
165
|
* The 'value' attribute represents the default value of the input element.
|
|
172
|
-
* @param {string} value
|
|
166
|
+
* @param {string} value The value to set as the default value.
|
|
173
167
|
*/
|
|
174
168
|
set defaultValue(value) {
|
|
175
169
|
this.setAttribute("value", value);
|
|
176
170
|
}
|
|
177
171
|
/**
|
|
178
|
-
* Sets the
|
|
179
|
-
*
|
|
180
|
-
* @param {Array} value - The selected value.
|
|
172
|
+
* Sets the label value.
|
|
173
|
+
* @param {Array} value The selected value to set.
|
|
181
174
|
*/
|
|
182
175
|
set selected(value) {
|
|
183
176
|
this._selected = value;
|
|
184
177
|
}
|
|
185
178
|
/**
|
|
186
179
|
* Returns the selected value.
|
|
187
|
-
*
|
|
188
180
|
* @returns {Array} The selected value.
|
|
189
181
|
*/
|
|
190
182
|
get selected() {
|
|
@@ -192,15 +184,13 @@ class Select extends WJElement {
|
|
|
192
184
|
}
|
|
193
185
|
/**
|
|
194
186
|
* Sets the trigger value.
|
|
195
|
-
*
|
|
196
|
-
* @param {string} value - The trigger value.
|
|
187
|
+
* @param {string} value The trigger value to set.
|
|
197
188
|
*/
|
|
198
189
|
set trigger(value) {
|
|
199
190
|
this.setAttribute("trigger", value);
|
|
200
191
|
}
|
|
201
192
|
/**
|
|
202
193
|
* Returns the trigger value.
|
|
203
|
-
*
|
|
204
194
|
* @returns {string} The trigger value.
|
|
205
195
|
*/
|
|
206
196
|
get trigger() {
|
|
@@ -208,7 +198,6 @@ class Select extends WJElement {
|
|
|
208
198
|
}
|
|
209
199
|
/**
|
|
210
200
|
* Returns the CSS styles for the component.
|
|
211
|
-
*
|
|
212
201
|
* @static
|
|
213
202
|
* @returns {CSSStyleSheet}
|
|
214
203
|
*/
|
|
@@ -217,7 +206,6 @@ class Select extends WJElement {
|
|
|
217
206
|
}
|
|
218
207
|
/**
|
|
219
208
|
* Returns the list of attributes to observe for changes.
|
|
220
|
-
*
|
|
221
209
|
* @static
|
|
222
210
|
* @returns {Array<string>}
|
|
223
211
|
*/
|
|
@@ -231,16 +219,12 @@ class Select extends WJElement {
|
|
|
231
219
|
this.isShadowRoot = "open";
|
|
232
220
|
}
|
|
233
221
|
/**
|
|
234
|
-
* Draws the component.
|
|
235
|
-
*
|
|
236
|
-
* @param {Object} context - The context for drawing.
|
|
237
|
-
* @param {Object} store - The store for drawing.
|
|
238
|
-
* @param {Object} params - The parameters for drawing.
|
|
222
|
+
* Draws the component for the select.
|
|
239
223
|
* @returns {DocumentFragment}
|
|
240
224
|
*/
|
|
241
225
|
draw() {
|
|
242
226
|
let fragment = document.createDocumentFragment();
|
|
243
|
-
this.classList.add("wje-placement", "wje-" + this.placement
|
|
227
|
+
this.classList.add("wje-placement", this.placement ? "wje-" + this.placement : "wje-start");
|
|
244
228
|
let native = document.createElement("div");
|
|
245
229
|
native.setAttribute("part", "native");
|
|
246
230
|
native.classList.add("native-select", this.variant || "default");
|
|
@@ -285,20 +269,16 @@ class Select extends WJElement {
|
|
|
285
269
|
popup.setAttribute("placement", "bottom-start");
|
|
286
270
|
popup.setAttribute("manual", "");
|
|
287
271
|
popup.setAttribute("size", "");
|
|
288
|
-
if (this.hasAttribute("disabled"))
|
|
289
|
-
popup.setAttribute("disabled", "");
|
|
272
|
+
if (this.hasAttribute("disabled")) popup.setAttribute("disabled", "");
|
|
290
273
|
if (this.variant === "standard") {
|
|
291
|
-
if (this.hasAttribute("label"))
|
|
292
|
-
native.appendChild(label);
|
|
274
|
+
if (this.hasAttribute("label")) native.appendChild(label);
|
|
293
275
|
} else {
|
|
294
276
|
wrapper.appendChild(label);
|
|
295
277
|
}
|
|
296
278
|
inputWrapper.appendChild(slotStart);
|
|
297
279
|
inputWrapper.appendChild(input);
|
|
298
|
-
if (this.hasAttribute("multiple"))
|
|
299
|
-
|
|
300
|
-
if (this.hasAttribute("clearable"))
|
|
301
|
-
inputWrapper.appendChild(clear);
|
|
280
|
+
if (this.hasAttribute("multiple")) inputWrapper.appendChild(chips);
|
|
281
|
+
if (this.hasAttribute("clearable")) inputWrapper.appendChild(clear);
|
|
302
282
|
inputWrapper.appendChild(slotEnd);
|
|
303
283
|
inputWrapper.appendChild(arrow);
|
|
304
284
|
list.appendChild(slot);
|
|
@@ -314,8 +294,7 @@ class Select extends WJElement {
|
|
|
314
294
|
wrapper.appendChild(inputWrapper);
|
|
315
295
|
popup.appendChild(wrapper);
|
|
316
296
|
popup.appendChild(optionsWrapper);
|
|
317
|
-
if (this.trigger === "click")
|
|
318
|
-
popup.setAttribute("manual", "");
|
|
297
|
+
if (this.trigger === "click") popup.setAttribute("manual", "");
|
|
319
298
|
native.appendChild(popup);
|
|
320
299
|
this.native = native;
|
|
321
300
|
this.popup = popup;
|
|
@@ -332,9 +311,6 @@ class Select extends WJElement {
|
|
|
332
311
|
}
|
|
333
312
|
/**
|
|
334
313
|
* Sets up the event listeners after the component is drawn.
|
|
335
|
-
* @param {Object} context - The context for drawing.
|
|
336
|
-
* @param {Object} store - The store for drawing.
|
|
337
|
-
* @param {Object} params - The parameters for drawing.
|
|
338
314
|
*/
|
|
339
315
|
afterDraw() {
|
|
340
316
|
this.input.addEventListener("focus", (e) => {
|
|
@@ -343,8 +319,7 @@ class Select extends WJElement {
|
|
|
343
319
|
});
|
|
344
320
|
this.input.addEventListener("blur", (e) => {
|
|
345
321
|
this.native.classList.remove("focused");
|
|
346
|
-
if (!e.target.value)
|
|
347
|
-
this.labelElement.classList.remove("fade");
|
|
322
|
+
if (!e.target.value) this.labelElement.classList.remove("fade");
|
|
348
323
|
});
|
|
349
324
|
this.addEventListener("wje-option:change", this.optionChange);
|
|
350
325
|
this.clear.addEventListener("wje-button:click", (e) => {
|
|
@@ -367,10 +342,8 @@ class Select extends WJElement {
|
|
|
367
342
|
} else {
|
|
368
343
|
let value = e.target.value.trim().toLowerCase();
|
|
369
344
|
this.getAllOptions().forEach((option) => {
|
|
370
|
-
if (option.textContent.trim().toLowerCase().includes(value))
|
|
371
|
-
|
|
372
|
-
else
|
|
373
|
-
option.style.display = "none";
|
|
345
|
+
if (option.textContent.trim().toLowerCase().includes(value)) option.style.display = "block";
|
|
346
|
+
else option.style.display = "none";
|
|
374
347
|
});
|
|
375
348
|
}
|
|
376
349
|
});
|
|
@@ -378,24 +351,20 @@ class Select extends WJElement {
|
|
|
378
351
|
}
|
|
379
352
|
/**
|
|
380
353
|
* Returns all the options as HTML.
|
|
381
|
-
*
|
|
382
|
-
* @returns {NodeList} The options.
|
|
354
|
+
* @returns {NodeList} The options as HTML.
|
|
383
355
|
*/
|
|
384
356
|
getAllOptions() {
|
|
385
357
|
return this.querySelectorAll("wje-option");
|
|
386
358
|
}
|
|
387
359
|
/**
|
|
388
360
|
* Returns the selected options as HTML.
|
|
389
|
-
*
|
|
390
|
-
* @returns {NodeList} The selected options.
|
|
361
|
+
* @returns {NodeList} The selected options as HTML.
|
|
391
362
|
*/
|
|
392
363
|
getSelectedOptions() {
|
|
393
364
|
return this.querySelectorAll("wje-option[selected]");
|
|
394
365
|
}
|
|
395
366
|
/**
|
|
396
367
|
* Returns the selected options.
|
|
397
|
-
*
|
|
398
|
-
* @param {Element} option - The option to get.
|
|
399
368
|
* @returns {Array} The selected options.
|
|
400
369
|
*/
|
|
401
370
|
getSelected() {
|
|
@@ -411,9 +380,8 @@ class Select extends WJElement {
|
|
|
411
380
|
}
|
|
412
381
|
/**
|
|
413
382
|
* Handles the selection change.
|
|
414
|
-
*
|
|
415
|
-
* @param {
|
|
416
|
-
* @param {number} length - The length of the selected options.
|
|
383
|
+
* @param {Element} option The option that changed.
|
|
384
|
+
* @param {number} length The length of the selected options.
|
|
417
385
|
*/
|
|
418
386
|
selectionChanged(option = null, length = 0) {
|
|
419
387
|
var _a, _b;
|
|
@@ -426,8 +394,7 @@ class Select extends WJElement {
|
|
|
426
394
|
if (this.counterEl instanceof HTMLElement || length > +this.maxOptions) {
|
|
427
395
|
this.counter();
|
|
428
396
|
} else {
|
|
429
|
-
if (option !== null)
|
|
430
|
-
this.chips.appendChild(this.getChip(option));
|
|
397
|
+
if (option !== null) this.chips.appendChild(this.getChip(option));
|
|
431
398
|
}
|
|
432
399
|
}
|
|
433
400
|
} else {
|
|
@@ -447,9 +414,21 @@ class Select extends WJElement {
|
|
|
447
414
|
}
|
|
448
415
|
}
|
|
449
416
|
/**
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
* @
|
|
417
|
+
* Updates the selected options and their corresponding chips.
|
|
418
|
+
* @param {boolean} [silence] Determines whether to suppress the "wje-select:change" event.
|
|
419
|
+
* @returns {void}
|
|
420
|
+
* @description
|
|
421
|
+
* This method fetches the currently selected options and updates the `selectedOptions` array.
|
|
422
|
+
* It clears and rebuilds the chips representing the selected items in the UI.
|
|
423
|
+
* If the number of selected options reaches the maximum allowed (`maxOptions`), it stops updating the counter.
|
|
424
|
+
* Optionally, it dispatches a custom event when the selection changes unless `silence` is set to `true`.
|
|
425
|
+
* //@fires wje-select:change - Dispatched when the selection changes, unless `silence` is `true`.
|
|
426
|
+
* @example
|
|
427
|
+
* // Call the method and allow event dispatch
|
|
428
|
+
* selections();
|
|
429
|
+
* @example
|
|
430
|
+
* // Call the method without dispatching the event
|
|
431
|
+
* selections(true);
|
|
453
432
|
*/
|
|
454
433
|
selections(silence = false) {
|
|
455
434
|
let options = this.getSelectedOptions();
|
|
@@ -457,7 +436,9 @@ class Select extends WJElement {
|
|
|
457
436
|
if (this.selectedOptions.length >= +this.maxOptions) {
|
|
458
437
|
this.counterEl = null;
|
|
459
438
|
}
|
|
460
|
-
this.chips
|
|
439
|
+
if (this.chips) {
|
|
440
|
+
this.chips.innerHTML = "";
|
|
441
|
+
}
|
|
461
442
|
if (this.selectedOptions.length > 0) {
|
|
462
443
|
this.selectedOptions.forEach((option, index) => {
|
|
463
444
|
this.selectionChanged(option, ++index);
|
|
@@ -469,7 +450,9 @@ class Select extends WJElement {
|
|
|
469
450
|
event.dispatchCustomEvent(this, "wje-select:change");
|
|
470
451
|
}
|
|
471
452
|
/**
|
|
472
|
-
*
|
|
453
|
+
* Manages the display of a counter element to indicate the number of items exceeding the maximum allowed options.
|
|
454
|
+
* - If the number of selected items equals the maximum allowed, the counter element is removed.
|
|
455
|
+
* - If the counter element doesn't exist and the number of items exceeds the maximum, it is created and updated.
|
|
473
456
|
*/
|
|
474
457
|
counter() {
|
|
475
458
|
if (this.counterEl && this.value.length === +this.maxOptions) {
|
|
@@ -486,8 +469,7 @@ class Select extends WJElement {
|
|
|
486
469
|
}
|
|
487
470
|
/**
|
|
488
471
|
* Returns a chip element.
|
|
489
|
-
*
|
|
490
|
-
* @param {Element} option - The option to get the chip for.
|
|
472
|
+
* @param {Element} option The option to get the chip for.
|
|
491
473
|
* @returns {Element} The chip element.
|
|
492
474
|
*/
|
|
493
475
|
getChip(option) {
|
|
@@ -502,11 +484,10 @@ class Select extends WJElement {
|
|
|
502
484
|
}
|
|
503
485
|
/**
|
|
504
486
|
* Generates an HTML option element based on the provided item and mapping.
|
|
505
|
-
*
|
|
506
|
-
* @param {
|
|
507
|
-
* @param {
|
|
508
|
-
* @param {string} [map.
|
|
509
|
-
* @param {string} [map.text="text"] - The property of the item to use for the option's text.
|
|
487
|
+
* @param {object} item The item to generate the option for.
|
|
488
|
+
* @param {object} [map] The mapping object that specifies the properties of the item to use for the option's value and text.
|
|
489
|
+
* @param {string} [map.value] The property of the item to use for the option's value.
|
|
490
|
+
* @param {string} [map.text] The property of the item to use for the option's text.
|
|
510
491
|
* @returns {HTMLElement} The generated HTML option element.
|
|
511
492
|
*/
|
|
512
493
|
htmlOption(item, map = { value: "value", text: "text" }) {
|
|
@@ -523,10 +504,9 @@ class Select extends WJElement {
|
|
|
523
504
|
}
|
|
524
505
|
/**
|
|
525
506
|
* Adds an option to the select element.
|
|
526
|
-
*
|
|
527
|
-
* @param {
|
|
528
|
-
* @param {
|
|
529
|
-
* @param {object} [map={ value: "value", text: "text" }] - The mapping object specifying the properties of the option data to be used for the value and text of the option.
|
|
507
|
+
* @param {any} optionData The data for the option to be added.
|
|
508
|
+
* @param {boolean} [silent] Whether to suppress any events triggered by the addition of the option.
|
|
509
|
+
* @param {object} [map] The mapping object specifying the properties of the option data to be used for the value and text of the option.
|
|
530
510
|
*/
|
|
531
511
|
addOption(optionData, silent = false, map = { value: "value", text: "text" }) {
|
|
532
512
|
if (!optionData) return;
|
|
@@ -540,10 +520,9 @@ class Select extends WJElement {
|
|
|
540
520
|
}
|
|
541
521
|
/**
|
|
542
522
|
* Adds options to the select element.
|
|
543
|
-
*
|
|
544
|
-
* @param {
|
|
545
|
-
* @param {
|
|
546
|
-
* @param {Object} [map] - The mapping object that specifies the properties of the options data object. Default is { value: "value", text: "text" }.
|
|
523
|
+
* @param {Array | object} optionsData The options data to be added. Can be an array of objects or a single object.
|
|
524
|
+
* @param {boolean} [silent] Indicates whether to trigger events when adding options. Default is false.
|
|
525
|
+
* @param {object} [map] The mapping object that specifies the properties of the options data object. Default is { value: "value", text: "text" }.
|
|
547
526
|
*/
|
|
548
527
|
addOptions(optionsData, silent = false, map = { value: "value", text: "text" }) {
|
|
549
528
|
if (!Array.isArray(optionsData)) {
|
|
@@ -561,9 +540,8 @@ class Select extends WJElement {
|
|
|
561
540
|
}
|
|
562
541
|
/**
|
|
563
542
|
* Selects an option with the specified value.
|
|
564
|
-
*
|
|
565
|
-
* @param {
|
|
566
|
-
* @param {boolean} [silent=false] - Whether to suppress firing events.
|
|
543
|
+
* @param {string} value The value of the option to be selected.
|
|
544
|
+
* @param {boolean} [silent] Whether to suppress firing events.
|
|
567
545
|
*/
|
|
568
546
|
selectOption(value, silent = false) {
|
|
569
547
|
if (!value) return;
|
|
@@ -571,13 +549,12 @@ class Select extends WJElement {
|
|
|
571
549
|
if (option) {
|
|
572
550
|
option.selected = true;
|
|
573
551
|
}
|
|
574
|
-
this.selections(silent);
|
|
552
|
+
if (this.drawingStatus > this.drawingStatuses.START) this.selections(silent);
|
|
575
553
|
}
|
|
576
554
|
/**
|
|
577
555
|
* Selects one or multiple options in the select element.
|
|
578
|
-
*
|
|
579
|
-
* @param {
|
|
580
|
-
* @param {boolean} [silent=false] - Whether to trigger the change event or not.
|
|
556
|
+
* @param {Array|any} values The value(s) of the option(s) to be selected.
|
|
557
|
+
* @param {boolean} [silent] Whether to trigger the change event or not.
|
|
581
558
|
*/
|
|
582
559
|
selectOptions(values, silent = false) {
|
|
583
560
|
if (!Array.isArray(values)) {
|
|
@@ -591,7 +568,7 @@ class Select extends WJElement {
|
|
|
591
568
|
/**
|
|
592
569
|
* @summary Callback function that is called when the custom element is associated with a form.
|
|
593
570
|
* This function adds an event listener to the form's submit event, which validates the input and propagates the validation.
|
|
594
|
-
* @param {HTMLFormElement} form
|
|
571
|
+
* @param {HTMLFormElement} form The form the custom element is associated with.
|
|
595
572
|
*/
|
|
596
573
|
formAssociatedCallback(form) {
|
|
597
574
|
form == null ? void 0 : form.addEventListener("submit", () => {
|
|
@@ -601,8 +578,7 @@ class Select extends WJElement {
|
|
|
601
578
|
* The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
|
|
602
579
|
* This method is responsible for resetting the value of the custom input element to its default value.
|
|
603
580
|
* It also resets the form value and validity state in the form internals.
|
|
604
|
-
*
|
|
605
|
-
* @method
|
|
581
|
+
* @function
|
|
606
582
|
*/
|
|
607
583
|
formResetCallback() {
|
|
608
584
|
this.value = this.defaultValue;
|
|
@@ -613,9 +589,8 @@ class Select extends WJElement {
|
|
|
613
589
|
* The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.
|
|
614
590
|
* This method is responsible for restoring the value of the custom input element to its saved state.
|
|
615
591
|
* It also restores the form value and validity state in the form internals to their saved states.
|
|
616
|
-
*
|
|
617
|
-
* @
|
|
618
|
-
* @method
|
|
592
|
+
* @param {object} state The saved state of the custom input element.
|
|
593
|
+
* @function
|
|
619
594
|
*/
|
|
620
595
|
formStateRestoreCallback(state) {
|
|
621
596
|
this.value = state.value;
|
|
@@ -625,9 +600,8 @@ class Select extends WJElement {
|
|
|
625
600
|
/**
|
|
626
601
|
* The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.
|
|
627
602
|
* This method is responsible for saving the value of the custom input element.
|
|
628
|
-
*
|
|
629
|
-
* @
|
|
630
|
-
* @method
|
|
603
|
+
* @returns {object} The saved state of the custom input element.
|
|
604
|
+
* @function
|
|
631
605
|
*/
|
|
632
606
|
formStateSaveCallback() {
|
|
633
607
|
return {
|
|
@@ -637,9 +611,8 @@ class Select extends WJElement {
|
|
|
637
611
|
/**
|
|
638
612
|
* The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.
|
|
639
613
|
* This method is not implemented yet.
|
|
640
|
-
*
|
|
641
|
-
* @
|
|
642
|
-
* @method
|
|
614
|
+
* @param {boolean} disabled The new disabled state of the custom input element.
|
|
615
|
+
* @function
|
|
643
616
|
*/
|
|
644
617
|
formDisabledCallback(disabled) {
|
|
645
618
|
console.warn("formDisabledCallback not implemented yet");
|