wj-elements 0.4.0 → 0.4.2
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/dist/custom-elements.json +21140 -0
- package/dist/dark.css +9 -0
- package/dist/light.css +9 -0
- package/dist/packages/wje-dropdown/dropdown.element.d.ts +29 -1
- package/dist/packages/wje-input/input.element.d.ts +2 -0
- package/dist/packages/wje-option/option.element.d.ts +3 -0
- package/dist/packages/wje-select/select.element.d.ts +17 -0
- package/dist/packages/wje-textarea/textarea.element.d.ts +2 -0
- package/dist/packages/wje-toast/toast.element.d.ts +80 -10
- package/dist/styles.css +58 -5
- package/dist/web-types.json +3842 -0
- package/dist/wje-animation.js +1 -1
- package/dist/wje-dropdown.js +66 -1
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-input.js +14 -3
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-option.js +8 -2
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-select.js +175 -27
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-textarea.js +1 -1
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-toast.js +383 -11
- package/dist/wje-toast.js.map +1 -1
- package/package.json +1 -1
package/dist/wje-select.js
CHANGED
|
@@ -9,7 +9,7 @@ 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, getSelectedOptions_fn, hasVisibleOptions_fn, updateEmptyState_fn, _applySearchFilter, _onMenuItemClickCapture, syncOptionCheckbox_fn;
|
|
12
|
+
var _addedOptions, _htmlOptions, _portaledOptionRecords, _Select_instances, htmlSelectedItem_fn, getSelectedOptions_fn, hasVisibleOptions_fn, updateEmptyState_fn, _applySearchFilter, _handleOptionsLoad, _onMenuItemClickCapture, _syncPortalStyles, copyPortalCustomProperties_fn, syncOptionOwners_fn, portalOptions_fn, _restorePortaledOptions, syncOptionCheckbox_fn;
|
|
13
13
|
import { F as FormAssociatedElement } from "./form-associated-element-DEQ4y-jn.js";
|
|
14
14
|
import { event } from "./event.js";
|
|
15
15
|
import { Localizer } from "./localize.js";
|
|
@@ -23,13 +23,14 @@ import Option from "./wje-option.js";
|
|
|
23
23
|
import Options from "./wje-options.js";
|
|
24
24
|
import Checkbox from "./wje-checkbox.js";
|
|
25
25
|
import { P as Popup } from "./popup.element-DklicGea.js";
|
|
26
|
-
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 label {\n margin: var(--wje-select-label-margin);\n padding: var(--wje-select-label-padding);\n display: var(--wje-select-label-display);\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-select-label-line-height);\n font-size: var(--wje-select-label-font-size);\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 label {\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n }\n &.standard {\n .wrapper {\n height: var(--wje-select-height);\n box-sizing: border-box;\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-color: var(--wje-select-options-background-color);\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 position: relative;\n}\n\n.list:has(.empty:not([hidden])) {\n min-height: 44px;\n}\n\n.empty {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--wje-spacing-small);\n color: var(--wje-select-color);\n text-align: center;\n background-color: var(--wje-select-options-background-color);\n pointer-events: none;\n}\n\n.empty[hidden] {\n display: none;\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:
|
|
26
|
+
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 label {\n margin: var(--wje-select-label-margin);\n padding: var(--wje-select-label-padding);\n display: var(--wje-select-label-display);\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-select-label-line-height);\n font-size: var(--wje-select-label-font-size);\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 label {\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n }\n &.standard {\n .wrapper {\n height: var(--wje-select-height);\n box-sizing: border-box;\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-color: var(--wje-select-options-background-color);\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 position: relative;\n}\n\n.list:has(.empty:not([hidden])) {\n min-height: 44px;\n}\n\n.empty {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--wje-spacing-small);\n color: var(--wje-select-color);\n text-align: center;\n background-color: var(--wje-select-options-background-color);\n pointer-events: none;\n}\n\n.empty[hidden] {\n display: none;\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-color: var(--wje-select-error-background-color, var(--wje-tooltip-background));\n padding: 0.25rem 0.5rem;\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n color: var(--wje-select-error-color, var(--wje-tooltip-color));\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}\n";
|
|
27
27
|
const _Select = class _Select extends FormAssociatedElement {
|
|
28
28
|
constructor() {
|
|
29
29
|
super();
|
|
30
30
|
__privateAdd(this, _Select_instances);
|
|
31
31
|
__privateAdd(this, _addedOptions, []);
|
|
32
32
|
__privateAdd(this, _htmlOptions, []);
|
|
33
|
+
__privateAdd(this, _portaledOptionRecords, []);
|
|
33
34
|
/**
|
|
34
35
|
* An object representing component dependencies with their respective classes.
|
|
35
36
|
* Each property in the object maps a custom component name (as a string key)
|
|
@@ -146,6 +147,30 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
146
147
|
__privateMethod(this, _Select_instances, updateEmptyState_fn).call(this);
|
|
147
148
|
}
|
|
148
149
|
});
|
|
150
|
+
__privateAdd(this, _handleOptionsLoad, (e) => {
|
|
151
|
+
var _a;
|
|
152
|
+
this.selectedOptions.forEach((option) => {
|
|
153
|
+
this.getAllOptions().forEach((el) => {
|
|
154
|
+
if (el.value === option.value) {
|
|
155
|
+
el.selected = true;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
const attrValue = ((_a = this.getAttribute("value")) == null ? void 0 : _a.split(" ")) || [];
|
|
160
|
+
attrValue.forEach((val) => {
|
|
161
|
+
const existingOption = Array.from(this.getAllOptions()).find((el) => el.value === val);
|
|
162
|
+
if (existingOption) {
|
|
163
|
+
existingOption.selected = true;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
|
|
167
|
+
this.selections(true);
|
|
168
|
+
__privateMethod(this, _Select_instances, updateEmptyState_fn).call(this);
|
|
169
|
+
__privateMethod(this, _Select_instances, syncOptionOwners_fn).call(this);
|
|
170
|
+
__privateMethod(this, _Select_instances, portalOptions_fn).call(this);
|
|
171
|
+
this.list.scrollTo(0, 0);
|
|
172
|
+
event.dispatchCustomEvent(this.popup, "wje-popup:content-ready");
|
|
173
|
+
});
|
|
149
174
|
/**
|
|
150
175
|
* Prevent closing the parent <wje-select>'s popup when a nested <wje-dropdown>
|
|
151
176
|
* menu item is clicked. Closes only the dropdown that owns the clicked item.
|
|
@@ -163,6 +188,31 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
163
188
|
}
|
|
164
189
|
e.stopPropagation();
|
|
165
190
|
});
|
|
191
|
+
__privateAdd(this, _syncPortalStyles, (e) => {
|
|
192
|
+
var _a;
|
|
193
|
+
const container = (_a = e.detail) == null ? void 0 : _a.container;
|
|
194
|
+
if (!(container instanceof HTMLElement)) return;
|
|
195
|
+
container.setAttribute("data-wje-select-portal", "");
|
|
196
|
+
__privateMethod(this, _Select_instances, copyPortalCustomProperties_fn).call(this, container);
|
|
197
|
+
__privateMethod(this, _Select_instances, portalOptions_fn).call(this, container);
|
|
198
|
+
if (container.querySelector("style[data-wje-select-portal-style]")) return;
|
|
199
|
+
const style = document.createElement("style");
|
|
200
|
+
style.setAttribute("data-wje-select-portal-style", "");
|
|
201
|
+
style.textContent = _Select.portalStyles;
|
|
202
|
+
container.prepend(style);
|
|
203
|
+
});
|
|
204
|
+
__privateAdd(this, _restorePortaledOptions, () => {
|
|
205
|
+
if (__privateGet(this, _portaledOptionRecords).length === 0) return;
|
|
206
|
+
__privateGet(this, _portaledOptionRecords).forEach(({ option, placeholder }) => {
|
|
207
|
+
option.removeEventListener("wje-option:change", this.optionChange);
|
|
208
|
+
option.removeAttribute("data-wje-select-portaled-option");
|
|
209
|
+
if (placeholder.parentNode) {
|
|
210
|
+
placeholder.parentNode.insertBefore(option, placeholder);
|
|
211
|
+
placeholder.remove();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
__privateSet(this, _portaledOptionRecords, []);
|
|
215
|
+
});
|
|
166
216
|
this.localizer = new Localizer(this);
|
|
167
217
|
this.counterEl = null;
|
|
168
218
|
this._wasOppened = false;
|
|
@@ -258,6 +308,32 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
258
308
|
get defaultValue() {
|
|
259
309
|
return this.getAttribute("value") ?? "";
|
|
260
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Sets or removes the `portaled` attribute on the select.
|
|
313
|
+
* Mirrors the dropdown API so popup content can be rendered in a portal root.
|
|
314
|
+
* @param {boolean|string} value Determines whether and where the popup should be portaled.
|
|
315
|
+
*/
|
|
316
|
+
set portaled(value) {
|
|
317
|
+
if (value) {
|
|
318
|
+
this.setAttribute("portaled", value);
|
|
319
|
+
} else {
|
|
320
|
+
this.removeAttribute("portaled");
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Getter for the `portaled` attribute value.
|
|
325
|
+
* @returns {string} The configured portal target or an empty string for the default body portal.
|
|
326
|
+
*/
|
|
327
|
+
get portaled() {
|
|
328
|
+
return this.getAttribute("portaled") || "";
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Checks whether popup content should be portaled.
|
|
332
|
+
* @returns {boolean} True when the `portaled` attribute is present.
|
|
333
|
+
*/
|
|
334
|
+
get isPortaled() {
|
|
335
|
+
return this.hasAttribute("portaled");
|
|
336
|
+
}
|
|
261
337
|
/**
|
|
262
338
|
* Sets the trigger value.
|
|
263
339
|
* @param {string} value The trigger value to set.
|
|
@@ -452,7 +528,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
452
528
|
* @returns {Array<string>}
|
|
453
529
|
*/
|
|
454
530
|
static get observedAttributes() {
|
|
455
|
-
return ["active", "disabled", "readonly"];
|
|
531
|
+
return ["active", "disabled", "readonly", "portaled"];
|
|
456
532
|
}
|
|
457
533
|
/**
|
|
458
534
|
* Sets up the attributes for the component.
|
|
@@ -558,6 +634,9 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
558
634
|
popup.setAttribute("size", "");
|
|
559
635
|
popup.setAttribute("part", "popup");
|
|
560
636
|
popup.setAttribute("offset", this.offset);
|
|
637
|
+
if (this.isPortaled) {
|
|
638
|
+
popup.setAttribute("portal", this.portaled);
|
|
639
|
+
}
|
|
561
640
|
if ((this.lazy || this.querySelector("wje-options")) && !this._wasOppened) {
|
|
562
641
|
popup.setAttribute("loader", "");
|
|
563
642
|
} else {
|
|
@@ -634,8 +713,11 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
634
713
|
}
|
|
635
714
|
this.syncAria();
|
|
636
715
|
(_a = this.getAllOptions()) == null ? void 0 : _a.forEach((option) => {
|
|
716
|
+
option.ownerSelect = this;
|
|
637
717
|
this.optionCheckSlot(option);
|
|
638
718
|
});
|
|
719
|
+
event.addListener(this.popup, "wje-router:rebind", null, __privateGet(this, _syncPortalStyles));
|
|
720
|
+
event.addListener(this.popup, "wje-portal:restored", null, __privateGet(this, _restorePortaledOptions));
|
|
639
721
|
this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
|
|
640
722
|
this.selectOptions(this.value, true);
|
|
641
723
|
if (this.lazy) {
|
|
@@ -700,28 +782,8 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
700
782
|
e.stopPropagation();
|
|
701
783
|
this.clearSelections();
|
|
702
784
|
});
|
|
703
|
-
this.list.addEventListener("wje-options:load", (
|
|
704
|
-
|
|
705
|
-
this.selectedOptions.forEach((option) => {
|
|
706
|
-
this.getAllOptions().forEach((el) => {
|
|
707
|
-
if (el.value === option.value) {
|
|
708
|
-
el.selected = true;
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
const attrValue = ((_a2 = this.getAttribute("value")) == null ? void 0 : _a2.split(" ")) || [];
|
|
713
|
-
attrValue.forEach((val) => {
|
|
714
|
-
const existingOption = Array.from(this.getAllOptions()).find((el) => el.value === val);
|
|
715
|
-
if (existingOption) {
|
|
716
|
-
existingOption.selected = true;
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
this.selectedOptions = __privateMethod(this, _Select_instances, getSelectedOptions_fn).call(this);
|
|
720
|
-
this.selections(true);
|
|
721
|
-
__privateMethod(this, _Select_instances, updateEmptyState_fn).call(this);
|
|
722
|
-
this.list.scrollTo(0, 0);
|
|
723
|
-
event.dispatchCustomEvent(this.popup, "wje-popup:content-ready");
|
|
724
|
-
});
|
|
785
|
+
this.list.addEventListener("wje-options:load", __privateGet(this, _handleOptionsLoad));
|
|
786
|
+
this.addEventListener("wje-options:load", __privateGet(this, _handleOptionsLoad));
|
|
725
787
|
if (this.hasAttribute("find") && this.findEl instanceof HTMLElement) {
|
|
726
788
|
event.addListener(this.findEl, "keyup", "", __privateGet(this, _applySearchFilter));
|
|
727
789
|
event.addListener(this.findEl, "wje-input:clear", "", __privateGet(this, _applySearchFilter));
|
|
@@ -733,7 +795,9 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
733
795
|
* @returns {NodeList} The options as HTML.
|
|
734
796
|
*/
|
|
735
797
|
getAllOptions() {
|
|
736
|
-
|
|
798
|
+
const localOptions = Array.from(this.querySelectorAll("wje-option"));
|
|
799
|
+
const portaledOptions = __privateGet(this, _portaledOptionRecords).map(({ option }) => option);
|
|
800
|
+
return Array.from(/* @__PURE__ */ new Set([...localOptions, ...portaledOptions]));
|
|
737
801
|
}
|
|
738
802
|
/**
|
|
739
803
|
* Handles changes in the selection for a component, updating internal values, input fields,
|
|
@@ -993,6 +1057,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
993
1057
|
}
|
|
994
1058
|
}
|
|
995
1059
|
disconnectedCallback() {
|
|
1060
|
+
__privateGet(this, _restorePortaledOptions).call(this);
|
|
996
1061
|
document.removeEventListener("mousedown", __privateGet(this, _onMenuItemClickCapture), true);
|
|
997
1062
|
}
|
|
998
1063
|
/**
|
|
@@ -1014,6 +1079,7 @@ const _Select = class _Select extends FormAssociatedElement {
|
|
|
1014
1079
|
};
|
|
1015
1080
|
_addedOptions = new WeakMap();
|
|
1016
1081
|
_htmlOptions = new WeakMap();
|
|
1082
|
+
_portaledOptionRecords = new WeakMap();
|
|
1017
1083
|
_Select_instances = new WeakSet();
|
|
1018
1084
|
/**
|
|
1019
1085
|
* Processes the given item and retrieves the corresponding value from the selected options.
|
|
@@ -1032,7 +1098,7 @@ htmlSelectedItem_fn = function(item) {
|
|
|
1032
1098
|
* @returns {Array<Element>} An array of elements representing the options that are currently selected.
|
|
1033
1099
|
*/
|
|
1034
1100
|
getSelectedOptions_fn = function() {
|
|
1035
|
-
return
|
|
1101
|
+
return this.getAllOptions().filter((option) => option.hasAttribute("selected"));
|
|
1036
1102
|
};
|
|
1037
1103
|
/**
|
|
1038
1104
|
* Determines whether the select currently contains at least one visible option.
|
|
@@ -1055,7 +1121,41 @@ updateEmptyState_fn = function() {
|
|
|
1055
1121
|
this.emptyState.hidden = __privateMethod(this, _Select_instances, hasVisibleOptions_fn).call(this);
|
|
1056
1122
|
};
|
|
1057
1123
|
_applySearchFilter = new WeakMap();
|
|
1124
|
+
_handleOptionsLoad = new WeakMap();
|
|
1058
1125
|
_onMenuItemClickCapture = new WeakMap();
|
|
1126
|
+
_syncPortalStyles = new WeakMap();
|
|
1127
|
+
copyPortalCustomProperties_fn = function(container) {
|
|
1128
|
+
const style = getComputedStyle(this);
|
|
1129
|
+
for (let i = 0; i < style.length; i++) {
|
|
1130
|
+
const prop = style[i];
|
|
1131
|
+
if (prop.startsWith("--")) {
|
|
1132
|
+
container.style.setProperty(prop, style.getPropertyValue(prop));
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
syncOptionOwners_fn = function() {
|
|
1137
|
+
this.getAllOptions().forEach((option) => {
|
|
1138
|
+
option.ownerSelect = this;
|
|
1139
|
+
});
|
|
1140
|
+
};
|
|
1141
|
+
portalOptions_fn = function(container = ((_a) => (_a = this.popup) == null ? void 0 : _a._portalContainer)()) {
|
|
1142
|
+
if (!(container instanceof HTMLElement)) return;
|
|
1143
|
+
const list = container.querySelector(".list");
|
|
1144
|
+
if (!(list instanceof HTMLElement)) return;
|
|
1145
|
+
const options = this.getAllOptions();
|
|
1146
|
+
options.forEach((option) => {
|
|
1147
|
+
if (__privateGet(this, _portaledOptionRecords).some((record) => record.option === option)) return;
|
|
1148
|
+
if (!option.parentNode) return;
|
|
1149
|
+
const placeholder = document.createComment("wje-select-portaled-option");
|
|
1150
|
+
option.parentNode.insertBefore(placeholder, option);
|
|
1151
|
+
option.ownerSelect = this;
|
|
1152
|
+
option.setAttribute("data-wje-select-portaled-option", "");
|
|
1153
|
+
option.addEventListener("wje-option:change", this.optionChange);
|
|
1154
|
+
__privateGet(this, _portaledOptionRecords).push({ option, placeholder });
|
|
1155
|
+
list.insertBefore(option, this.emptyState);
|
|
1156
|
+
});
|
|
1157
|
+
};
|
|
1158
|
+
_restorePortaledOptions = new WeakMap();
|
|
1059
1159
|
syncOptionCheckbox_fn = function(option) {
|
|
1060
1160
|
const checkbox = option.querySelector('wje-checkbox[slot="check"]');
|
|
1061
1161
|
if (!checkbox) return;
|
|
@@ -1068,6 +1168,54 @@ syncOptionCheckbox_fn = function(option) {
|
|
|
1068
1168
|
}
|
|
1069
1169
|
};
|
|
1070
1170
|
__publicField(_Select, "_instanceId", 0);
|
|
1171
|
+
__publicField(_Select, "portalStyles", `
|
|
1172
|
+
[data-wje-select-portal] .options-wrapper {
|
|
1173
|
+
border-width: var(--wje-select-options-border-width, 1px);
|
|
1174
|
+
border-style: var(--wje-select-options-border-style, solid);
|
|
1175
|
+
border-color: var(--wje-select-options-border-color, var(--wje-border-color, #dcdfe3));
|
|
1176
|
+
border-radius: var(--wje-select-options-border-radius, var(--wje-border-radius, 4px));
|
|
1177
|
+
margin-top: calc(0px - var(--wje-select-border-width, 1px));
|
|
1178
|
+
background-color: var(--wje-select-options-background-color, var(--wje-color-contrast-0, #fff));
|
|
1179
|
+
overflow: hidden;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
[data-wje-select-portal] .find {
|
|
1183
|
+
margin-block: var(--wje-select-find-margin-block, .5rem);
|
|
1184
|
+
margin-inline: var(--wje-select-find-margin-inline, .5rem);
|
|
1185
|
+
width: var(--wje-select-find-width, calc(100% - 1rem));
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
[data-wje-select-portal] .list {
|
|
1189
|
+
overflow: auto;
|
|
1190
|
+
height: 100%;
|
|
1191
|
+
position: relative;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
[data-wje-select-portal] .list:has(.empty:not([hidden])) {
|
|
1195
|
+
min-height: 44px;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
[data-wje-select-portal] .empty {
|
|
1199
|
+
position: absolute;
|
|
1200
|
+
inset: 0;
|
|
1201
|
+
display: flex;
|
|
1202
|
+
align-items: center;
|
|
1203
|
+
justify-content: center;
|
|
1204
|
+
padding: var(--wje-spacing-small, 1rem);
|
|
1205
|
+
color: var(--wje-select-color, inherit);
|
|
1206
|
+
text-align: center;
|
|
1207
|
+
background-color: var(--wje-select-options-background-color, var(--wje-color-contrast-0, #fff));
|
|
1208
|
+
pointer-events: none;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
[data-wje-select-portal] .empty[hidden] {
|
|
1212
|
+
display: none;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
[data-wje-select-portal] .options-wrapper:has(.find) .list {
|
|
1216
|
+
height: calc(100% - 32px - 2 * var(--wje-select-find-margin-block, .5rem));
|
|
1217
|
+
}
|
|
1218
|
+
`);
|
|
1071
1219
|
let Select = _Select;
|
|
1072
1220
|
Select.define("wje-select", Select);
|
|
1073
1221
|
export {
|