wj-elements 0.1.190 → 0.1.191

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.
@@ -9,8 +9,8 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _addedOptions, _htmlOptions, _Select_instances, htmlSelectedItem_fn, getSelected_fn, getSelectedOptions_fn, _applySearchFilter;
13
- import { F as FormAssociatedElement } from "./form-associated-element-CaIxmEod.js";
12
+ var _addedOptions, _htmlOptions, _Select_instances, htmlSelectedItem_fn, getSelectedOptions_fn, _applySearchFilter;
13
+ import { F as FormAssociatedElement } from "./form-associated-element-o0UjvdUp.js";
14
14
  import { event } from "./event.js";
15
15
  import Button from "./wje-button.js";
16
16
  import "./wje-popup.js";
@@ -22,7 +22,7 @@ import Option from "./wje-option.js";
22
22
  import Options from "./wje-options.js";
23
23
  import Checkbox from "./wje-checkbox.js";
24
24
  import { P as Popup } from "./popup.element-ZX3dWrG0.js";
25
- const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n margin-bottom: var(--wje-select-margin-bottom);\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 position: relative;\n &.default {\n .wrapper {\n display: block;\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 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 slot[name='error'] {\n position: static;\n\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n line-height: normal;\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 input[readonly] {\n pointer-events: none;\n caret-color: transparent;\n }\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);\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: var(--wje-select-options-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 margin-block: var(--wje-select-find-margin-block);\n margin-inline: var(--wje-select-find-margin-inline);\n width: var(--wje-select-find-width);\n}\n\n.list {\n overflow: auto;\n height: 100%;\n}\n\n.options-wrapper:has(.find) .list {\n height: calc(100% - 32px - 2 * var(--wje-select-find-margin-block));\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 gap: var(--wje-spacing-3x-small);\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\nslot[name='error'] {\n display: none;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\nslot[name='error'] {\n display: none;\n position: absolute;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n background: black;\n padding: 0.25rem 0.5rem;\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n color: white;\n font-size: var(--wje-font-size-small);\n width: max-content;\n line-height: normal;\n}\n\n.input-hidden{\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n z-index: -1;\n}";
25
+ const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n margin-bottom: var(--wje-select-margin-bottom);\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 position: relative;\n &.default {\n .wrapper {\n display: block;\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 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 wje-label {\n line-height: var(--wje-line-height-normal);\n }\n .input-wrapper {\n background: transparent;\n width: 100%;\n }\n slot[name='error'] {\n position: static;\n\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n line-height: normal;\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 input[readonly] {\n pointer-events: none;\n caret-color: transparent;\n }\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);\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: var(--wje-select-options-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 margin-block: var(--wje-select-find-margin-block);\n margin-inline: var(--wje-select-find-margin-inline);\n width: var(--wje-select-find-width);\n}\n\n.list {\n overflow: auto;\n height: 100%;\n}\n\n.options-wrapper:has(.find) .list {\n height: calc(100% - 32px - 2 * var(--wje-select-find-margin-block));\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 gap: var(--wje-spacing-3x-small);\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\nslot[name='error'] {\n display: none;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\nslot[name='error'] {\n display: none;\n position: absolute;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n background: black;\n padding: 0.25rem 0.5rem;\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n color: white;\n font-size: var(--wje-font-size-small);\n width: max-content;\n line-height: normal;\n}\n\n.input-hidden{\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n z-index: -1;\n}\n\n:host([required]) .wrapper::after {\n color: var(--wje-input-color-invalid);\n content: var(--wje-input-required-symbol);\n font-size: 24px;\n position: absolute;\n right: 12px;\n top: 0;\n}\n\n:host([required]) .standard .input-wrapper::after {\n right: 13px;\n top: -20px;\n}";
26
26
  class Select extends FormAssociatedElement {
27
27
  constructor() {
28
28
  super();
@@ -56,8 +56,22 @@ class Select extends FormAssociatedElement {
56
56
  });
57
57
  __publicField(this, "className", "Select");
58
58
  /**
59
- * Handles the option change event.
60
- * @param {Event} e The event.
59
+ * Handles the change event for an option element within a select-like component.
60
+ * This method processes user interactions with options and updates the state of the component,
61
+ * including selection management, validation, and UI updates. Behavior differs based on
62
+ * whether the component supports multiple selections.
63
+ * Key functionality:
64
+ * - Prevents the default behavior, event propagation, and immediate propagation of the event.
65
+ * - Retrieves all options within the component.
66
+ * - If the component doesn't support multiple selection:
67
+ * - Marks only the clicked option as selected and deselects others.
68
+ * - Hides the option popup.
69
+ * - If the component supports multiple selection:
70
+ * - Processes the clicked option without deselecting others.
71
+ * - Updates the selected options and triggers validation.
72
+ * - Marks the form state as non-pristine.
73
+ * - Propagates the validation state to other relevant parts of the component or system.
74
+ * @param {Event} e The event object representing the option change interaction.
61
75
  */
62
76
  __publicField(this, "optionChange", (e) => {
63
77
  e.preventDefault();
@@ -82,42 +96,37 @@ class Select extends FormAssociatedElement {
82
96
  this.propagateValidation();
83
97
  });
84
98
  /**
85
- * Handles the selection and deselection of an option element.
86
- * @param {HTMLElement} option The option element that was clicked.
87
- * @param {boolean} [multiple] Indicates whether multiple selection is allowed.
99
+ * Handles the logic for processing the selection state of a clicked option element.
100
+ * @function processClickedOption
101
+ * @param {Element} option The option element that is clicked.
102
+ * @param {boolean} [multiple] A Boolean indicating whether multiple options can be selected. Defaults to false.
103
+ * Changes the selected state of the passed option and updates the selected options list.
104
+ * Checks if the option already has a "selected" attribute, toggles its state,
105
+ * and updates the internal selected options.
88
106
  */
89
107
  __publicField(this, "processClickedOption", (option, multiple = false) => {
90
108
  const isSelected = option.hasAttribute("selected");
91
109
  option.selected = !isSelected;
92
- if (isSelected) {
93
- this.filterOutOption(option);
94
- } else {
95
- this.selectedOptions = multiple ? [...this.selectedOptions, option] : [option];
96
- }
97
- });
98
- /**
99
- * Filters out a specified option from the `selectedOptions` array.
100
- * This function removes an option from the `selectedOptions` array if its value
101
- * matches the value of the option provided as an argument. It allows for dynamically
102
- * updating the selected options by excluding the specified option.
103
- * @param {object} option The option to be removed from the `selectedOptions` array.
104
- * Should be an object containing a `value` property that is compared to the
105
- * `value` property of objects in the `selectedOptions` array.
106
- */
107
- __publicField(this, "filterOutOption", (option) => {
108
- this.selectedOptions = this.selectedOptions.filter((sOption) => {
109
- return sOption.value !== option.value;
110
- });
110
+ this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
111
111
  });
112
112
  /**
113
- * Handles the chip remove event.
114
- * @param {Event} e The event.
113
+ * Handles the removal of a chip element from the DOM and updates the related state.
114
+ * @param {Event} e The event object triggered by the chip removal action.
115
+ * The target of the event is expected to be the chip element itself.
115
116
  */
116
117
  __publicField(this, "removeChip", (e) => {
117
118
  e.target.parentNode.removeChild(e.target);
118
119
  this.processClickedOption(e.target.option, true);
119
120
  this.selections();
120
121
  });
122
+ /**
123
+ * Filters option elements based on the search input value.
124
+ * This function applies a search filter to a list of options. If a `wj-options` element exists and has
125
+ * the `lazy` attribute, the search value is passed to the `wj-options` element, enabling infinite scroll
126
+ * functionality to handle the filtering. If the `lazy` attribute is not present, it performs a local
127
+ * search to show or hide options depending on whether their text content matches the search input.
128
+ * @param {Event} e The input event containing the search input value from the user.
129
+ */
121
130
  __privateAdd(this, _applySearchFilter, (e) => {
122
131
  const optionsElement = this.querySelector("wje-options");
123
132
  if (optionsElement && optionsElement.hasAttribute("lazy")) {
@@ -141,12 +150,10 @@ class Select extends FormAssociatedElement {
141
150
  this.slotStart = null;
142
151
  this.slotEnd = null;
143
152
  this.input = null;
144
- this.optionsWrapper = null;
145
153
  this.chips = null;
146
154
  this.clear = null;
147
155
  this.list = null;
148
156
  this._value = [];
149
- this._selected = [];
150
157
  this._selectedOptions = [];
151
158
  }
152
159
  /**
@@ -157,22 +164,23 @@ class Select extends FormAssociatedElement {
157
164
  * split into an array by spaces) or an array of values.
158
165
  */
159
166
  set value(value) {
167
+ const formData = new FormData();
160
168
  if (value) {
161
169
  let data = value;
162
170
  if (!Array.isArray(data)) {
163
171
  data = data.split(" ");
164
172
  }
165
- const formData = new FormData();
166
173
  data.forEach((v) => {
167
174
  formData.append(this.name, v);
168
175
  });
169
176
  value = formData;
170
177
  this._value = data;
171
- this.selected = data;
172
- this.internals.setFormValue(value);
173
178
  } else {
179
+ formData.delete(this.name);
180
+ value = formData;
174
181
  this._value = [];
175
182
  }
183
+ this.internals.setFormValue(value);
176
184
  }
177
185
  /**
178
186
  * Retrieves the current value.
@@ -181,24 +189,6 @@ class Select extends FormAssociatedElement {
181
189
  get value() {
182
190
  return this._value;
183
191
  }
184
- /**
185
- * Sets the `validate-on-change` attribute on the element. When the attribute is present, it typically indicates that validation should occur when the value of the input changes.
186
- * @param {boolean} value A boolean indicating whether to enable or disable the `validate-on-change` attribute.
187
- */
188
- set validateOnChange(value) {
189
- if (value) {
190
- this.setAttribute("validate-on-change", "");
191
- } else {
192
- this.removeAttribute("validate-on-change");
193
- }
194
- }
195
- /**
196
- * Getter for the validateOnChange attribute.
197
- * @returns {boolean} Whether the attribute is present.
198
- */
199
- get validateOnChange() {
200
- return this.hasAttribute("validate-on-change");
201
- }
202
192
  /**
203
193
  * Sets the maximum number of options allowed.
204
194
  * @param { number | object} value The value to set as the maximum number of options.
@@ -268,20 +258,6 @@ class Select extends FormAssociatedElement {
268
258
  get offset() {
269
259
  return this.getAttribute("offset") || "5";
270
260
  }
271
- /**
272
- * Sets the label value.
273
- * @param {Array} value The selected value to set.
274
- */
275
- set selected(value) {
276
- this._selected = value;
277
- }
278
- /**
279
- * Returns the selected value.
280
- * @returns {Array} The selected value.
281
- */
282
- get selected() {
283
- return this._selected;
284
- }
285
261
  /**
286
262
  * Sets the selected options for the object.
287
263
  * @param {Array|object} value The new value for the selected options. It can be an array or object containing the selected options.
@@ -497,22 +473,21 @@ class Select extends FormAssociatedElement {
497
473
  this.slotStart = slotStart;
498
474
  this.slotEnd = slotEnd;
499
475
  this.input = input;
500
- this.display = display;
501
- this.optionsWrapper = optionsWrapper;
476
+ this.displayInput = display;
502
477
  this.chips = chips;
503
478
  this.clear = clear;
504
479
  this.list = list;
505
480
  return fragment;
506
481
  }
507
482
  /**
508
- * Performs actions and binds events after the component's markup and state are initialized.
509
- * Actions include setting up event listeners, managing option elements, handling focus and blur behaviors,
510
- * synchronizing the selected options, and managing a find functionality for filtering options.
511
- * @returns {void} Does not return a value. The method operates by updating the state and behavior of the component.
483
+ * Executes post-render logic for the custom element.
484
+ * This includes validation, event listener registration, managing custom attributes, and
485
+ * handling options initialization for the component.
486
+ * @returns {void} This method does not return any value.
512
487
  */
513
488
  afterDraw() {
514
489
  var _a, _b;
515
- this.validate(this.selectedOptions);
490
+ this.validate();
516
491
  if (this.hasAttribute("invalid")) {
517
492
  this.showInvalidMessage();
518
493
  }
@@ -521,8 +496,6 @@ class Select extends FormAssociatedElement {
521
496
  });
522
497
  this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
523
498
  this.selectOptions(this.value);
524
- this.selected = __privateMethod(this, _Select_instances, getSelected_fn).call(this);
525
- this.selections(true);
526
499
  if (this.lazy) {
527
500
  event.addListener(this.popup, "wje-popup:show", null, (e) => {
528
501
  if (this._wasOppened) return;
@@ -589,16 +562,17 @@ class Select extends FormAssociatedElement {
589
562
  return this.querySelectorAll("wje-option");
590
563
  }
591
564
  /**
592
- * Handles the selection change.
593
- * @param {Element[]} options The option that changed.
594
- * @param {number} length The length of the selected options.
565
+ * Handles changes in the selection for a component, updating internal values, input fields,
566
+ * and visual presentation (like chips or slots) as per the given selection options.
567
+ * @param {Array|null} options The collection of selected option elements. If null, no options are selected.
568
+ * @param {number} length The total number of selected options.
569
+ * @returns {void}
595
570
  */
596
571
  selectionChanged(options = null, length = 0) {
597
- var _a, _b, _c, _d, _e;
598
- this.selected = __privateMethod(this, _Select_instances, getSelected_fn).call(this);
572
+ var _a, _b, _c;
599
573
  if (this.hasAttribute("multiple")) {
600
- this.value = this.selectedOptions.map((el) => el.value).reverse();
601
- this.input.value = this.selected.map((a) => a.value).join(" ").trim();
574
+ this.value = options.map((el) => el.value).reverse();
575
+ this.input.value = this.value.map((a) => a).join(" ").trim();
602
576
  if (this.placeholder && length === 0) {
603
577
  this.chips.innerHTML = this.placeholder;
604
578
  } else {
@@ -609,39 +583,32 @@ class Select extends FormAssociatedElement {
609
583
  }
610
584
  } else {
611
585
  const option = options == null ? void 0 : options.at(0);
612
- this.value = (_b = (_a = this.selectedOptions) == null ? void 0 : _a.map((el) => el.value)) == null ? void 0 : _b.at(0);
613
- this.input.value = ((_c = this.selected[0]) == null ? void 0 : _c.value) || "";
614
- this.display.value = ((_e = (_d = this.selectedOptions[0]) == null ? void 0 : _d.textContent) == null ? void 0 : _e.trim()) || "";
586
+ this.value = ((_a = options == null ? void 0 : options.map((el) => el.value)) == null ? void 0 : _a.at(0)) || "";
587
+ this.input.value = this.value[0] || "";
588
+ this.displayInput.value = ((_c = (_b = options[0]) == null ? void 0 : _b.textContent) == null ? void 0 : _c.trim()) || "";
589
+ this.slotStart.innerHTML = "";
590
+ this.slotEnd.innerHTML = "";
615
591
  if (option && option instanceof HTMLElement) {
616
- this.slotStart.innerHTML = "";
617
592
  let optionSlotStart = option == null ? void 0 : option.querySelector("wje-option > [slot=start]");
618
593
  if (optionSlotStart) {
619
- this.slotStart.appendChild(optionSlotStart.cloneNode(true));
594
+ setTimeout(() => {
595
+ this.slotStart.append(optionSlotStart.cloneNode(true));
596
+ }, 0);
620
597
  }
621
- this.slotEnd.innerHTML = "";
622
598
  let optionSlotEnd = option == null ? void 0 : option.querySelector("wje-option > [slot=end]");
623
599
  if (optionSlotEnd) {
624
- this.slotEnd.appendChild(optionSlotEnd.cloneNode(true));
600
+ setTimeout(() => {
601
+ this.slotEnd.append(optionSlotEnd.cloneNode(true));
602
+ }, 0);
625
603
  }
626
604
  }
627
605
  }
628
606
  }
629
607
  /**
630
- * Updates the selected options and their corresponding chips.
631
- * @param {boolean} [silence] Determines whether to suppress the "wje-select:change" event.
632
- * @returns {void}
633
- * @description
634
- * This method fetches the currently selected options and updates the `selectedOptions` array.
635
- * It clears and rebuilds the chips representing the selected items in the UI.
636
- * If the number of selected options reaches the maximum allowed (`maxOptions`), it stops updating the counter.
637
- * Optionally, it dispatches a custom event when the selection changes unless `silence` is set to `true`.
638
- * //@fires wje-select:change - Dispatched when the selection changes, unless `silence` is `true`.
639
- * @example
640
- * // Call the method and allow event dispatch
641
- * selections();
642
- * @example
643
- * // Call the method without dispatching the event
644
- * selections(true);
608
+ * Handles the logic for updating selections based on the current selected options,
609
+ * updating chips content, and dispatching change events if necessary.
610
+ * @param {boolean} [silence] If true, suppresses the dispatch of a custom change event.
611
+ * @returns {void} This method does not return a value.
645
612
  */
646
613
  selections(silence = false) {
647
614
  if (this.selectedOptions.length >= +this.maxOptions) {
@@ -659,9 +626,9 @@ class Select extends FormAssociatedElement {
659
626
  event.dispatchCustomEvent(this, "wje-select:change");
660
627
  }
661
628
  /**
662
- * Manages the display of a counter element to indicate the number of items exceeding the maximum allowed options.
663
- * - If the number of selected items equals the maximum allowed, the counter element is removed.
664
- * - If the counter element doesn't exist and the number of items exceeds the maximum, it is created and updated.
629
+ * Updates the counter element to reflect the current state of selected values relative to the maximum allowed options.
630
+ * If the maximum options are selected, the counter element is removed. If it does not already exist and needs to be displayed, it is created.
631
+ * @returns {void} Does not return a value.
665
632
  */
666
633
  counter() {
667
634
  if (this.counterEl && this.value.length === +this.maxOptions) {
@@ -677,9 +644,9 @@ class Select extends FormAssociatedElement {
677
644
  this.counterEl.innerText = `+${this.value.length - +this.maxOptions}`;
678
645
  }
679
646
  /**
680
- * Returns a chip element.
681
- * @param {Element} option The option to get the chip for.
682
- * @returns {Element} The chip element.
647
+ * Creates and returns a chip element with specified properties and a label.
648
+ * @param {object} option The configuration object for the chip. Typically includes properties such as value and textContent to set up the chip's label and data.
649
+ * @returns {HTMLElement} The newly created chip element with a label and default properties.
683
650
  */
684
651
  getChip(option) {
685
652
  let chip = document.createElement("wje-chip");
@@ -723,10 +690,13 @@ class Select extends FormAssociatedElement {
723
690
  return item;
724
691
  }
725
692
  /**
726
- * Adds an option to the select element.
727
- * @param {any} optionData The data for the option to be added.
728
- * @param {boolean} [silent] Whether to suppress any events triggered by the addition of the option.
729
- * @param {object} [map] The mapping object specifying the properties of the option data to be used for the value and text of the option.
693
+ * Adds a new option to the component.
694
+ * @param {object} optionData The data used to create the new option.
695
+ * @param {boolean} [silent] Whether the addition should trigger events or not.
696
+ * @param {object} [map] Mapping of keys to identify value and text in the optionData.
697
+ * @param {string} [map.value] The key in optionData that represents the value of the option.
698
+ * @param {string} [map.text] The key in optionData that represents the text of the option.
699
+ * @returns {void}
730
700
  */
731
701
  addOption(optionData, silent = false, map = { value: "value", text: "text" }) {
732
702
  if (!optionData) return;
@@ -739,10 +709,14 @@ class Select extends FormAssociatedElement {
739
709
  this.appendChild(option);
740
710
  }
741
711
  /**
742
- * Adds options to the select element.
743
- * @param {Array | object} optionsData The options data to be added. Can be an array of objects or a single object.
744
- * @param {boolean} [silent] Indicates whether to trigger events when adding options. Default is false.
745
- * @param {object} [map] The mapping object that specifies the properties of the options data object. Default is { value: "value", text: "text" }.
712
+ * Adds one or more options to a collection. If the input is an array, it adds each option within the array.
713
+ * Otherwise, it adds a single option.
714
+ * @param {Array | object} optionsData The data representing the options to be added. It can be a single object or an array of objects.
715
+ * @param {boolean} [silent] Optional flag to determine if events or notifications should be suppressed while adding options.
716
+ * @param {object} [map] An optional mapping object specifying how to map data properties to value and text for the options.
717
+ * @param {string} [map.value] The property in the optionsData that represents the value of the option.
718
+ * @param {string} [map.text] The property in the optionsData that represents the text of the option.
719
+ * @returns {void}
746
720
  */
747
721
  addOptions(optionsData, silent = false, map = { value: "value", text: "text" }) {
748
722
  if (!Array.isArray(optionsData)) {
@@ -754,9 +728,10 @@ class Select extends FormAssociatedElement {
754
728
  }
755
729
  }
756
730
  /**
757
- * Selects an option with the specified value.
731
+ * Selects an option from the available options within the component.
758
732
  * @param {string} value The value of the option to be selected.
759
- * @param {boolean} [silent] Whether to suppress firing events.
733
+ * @param {boolean} [silent] Determines whether the selection should trigger notification or updates. Defaults to false.
734
+ * @returns {void} Does not return a value.
760
735
  */
761
736
  selectOption(value, silent = false) {
762
737
  if (!value) return;
@@ -767,9 +742,11 @@ class Select extends FormAssociatedElement {
767
742
  if (this.drawingStatus > this.drawingStatuses.START) this.selections(silent);
768
743
  }
769
744
  /**
770
- * Selects one or multiple options in the select element.
771
- * @param {Array|any} values The value(s) of the option(s) to be selected.
772
- * @param {boolean} [silent] Whether to trigger the change event or not.
745
+ * Selects multiple options based on the provided values. If a single value is provided, it selects that option.
746
+ * If an array of values is provided, it iterates through the array and selects each option.
747
+ * @param {any|any[]} values A single value or an array of values to be selected.
748
+ * @param {boolean} [silent] Determines whether the selection action should occur silently without triggering other side effects or events.
749
+ * @returns {void} This method does not return a value.
773
750
  */
774
751
  selectOptions(values, silent = false) {
775
752
  if (!Array.isArray(values)) {
@@ -781,9 +758,9 @@ class Select extends FormAssociatedElement {
781
758
  }
782
759
  }
783
760
  /**
784
- * Clones and appends an icon from a template with slot "check" to the given option element.
785
- * @param {HTMLElement} option The target option element where the "check" icon will be added.
786
- * @returns {void}
761
+ * Clones and appends an icon with the "check" slot to the specified option element.
762
+ * @param {HTMLElement} option The target HTML element to which the cloned "check" icon will be appended.
763
+ * @returns {void} This method does not return a value, but it modifies the DOM by appending a cloned "check" icon to the provided option element.
787
764
  */
788
765
  optionCheckSlot(option) {
789
766
  var _a;
@@ -796,35 +773,31 @@ class Select extends FormAssociatedElement {
796
773
  option.append(iconClone);
797
774
  }
798
775
  /**
799
- * Checks if all elements in the `elements` array are present in the `options` array based on their `option` property.
800
- * @param {Array} elements The array of elements to check. Each element should have an `option` property.
801
- * @param {Array} options The array of options to verify against.
802
- * @returns {boolean} Returns true if all elements in the `elements` array are found within the `options` array, otherwise returns false.
776
+ * Clears all selected options and resets selections.
777
+ * The method ensures that all options are deselected, updates the internal state, validates the selections,
778
+ * propagates the validation status, and indicates invalid state if necessary.
779
+ * @returns {void} No value is returned by this method.
803
780
  */
804
- areAllElementsInOptions(elements, options) {
805
- if (elements.length === 0) return false;
806
- return elements.every(
807
- (el) => options.some((opt) => JSON.stringify(opt) === JSON.stringify(el.option))
808
- );
809
- }
810
781
  clearSelections() {
811
- this.selected = [];
812
782
  this.selectedOptions = [];
813
783
  this.getAllOptions().forEach((option) => {
814
784
  option.selected = false;
815
785
  });
816
786
  this.selections();
787
+ this.validate();
788
+ this.propagateValidation();
789
+ if (this.hasAttribute("invalid")) {
790
+ this.showInvalidMessage();
791
+ }
817
792
  }
818
793
  }
819
794
  _addedOptions = new WeakMap();
820
795
  _htmlOptions = new WeakMap();
821
796
  _Select_instances = new WeakSet();
822
797
  /**
823
- * Processes the provided item to retrieve its corresponding value and text
824
- * based on the configuration of `wje-options`, then updates and returns
825
- * the selected item's HTML representation.
826
- * @param {any} item The input item for which the value and text are determined.
827
- * @returns {string} The HTML representation of the selected item's value.
798
+ * Processes the given item and retrieves the corresponding value from the selected options.
799
+ * @param {string} item The key to search for in the selected options.
800
+ * @returns {string} The text content associated with the selected item, or an empty string if not found.
828
801
  */
829
802
  htmlSelectedItem_fn = function(item) {
830
803
  var _a;
@@ -834,21 +807,8 @@ htmlSelectedItem_fn = function(item) {
834
807
  return this.htmlSelectedItem(value);
835
808
  };
836
809
  /**
837
- * Returns the selected options.
838
- * @returns {Array} The selected options.
839
- */
840
- getSelected_fn = function() {
841
- return this.selectedOptions.map((option) => {
842
- return {
843
- value: option.value,
844
- text: __privateMethod(this, _Select_instances, htmlSelectedItem_fn).call(this, option.value)
845
- // option.textContent.trim(),
846
- };
847
- });
848
- };
849
- /**
850
- * Returns the selected options as HTML.
851
- * @returns {NodeList} The selected options as HTML.
810
+ * Retrieves the list of selected options within the component.
811
+ * @returns {Array<Element>} An array of elements representing the options that are currently selected.
852
812
  */
853
813
  getSelectedOptions_fn = function() {
854
814
  return Array.from(this.querySelectorAll("wje-option[selected]"));