@lmvz-ds/components 0.36.1 → 0.38.0
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/CHANGELOG.md +12 -0
- package/cjs/{aria-validation-controller-Do0uEK4t.js → aria-validation-controller-DKNXjnQr.js} +1 -1
- package/cjs/checkmark-CuKDPAcx.js +5 -0
- package/cjs/{index-BgvZ4y-3.js → index-DWy4nuyZ.js} +41 -0
- package/cjs/lmvz-action-list.cjs.entry.js +3 -3
- package/cjs/lmvz-action.cjs.entry.js +1 -1
- package/cjs/lmvz-button-group.cjs.entry.js +1 -1
- package/cjs/lmvz-button_2.cjs.entry.js +3 -3
- package/cjs/lmvz-card.cjs.entry.js +2 -2
- package/cjs/lmvz-checkbox.cjs.entry.js +4 -5
- package/cjs/lmvz-chip.cjs.entry.js +5 -5
- package/cjs/lmvz-components.cjs.js +2 -2
- package/cjs/lmvz-datepicker.cjs.entry.js +1 -1
- package/cjs/lmvz-header_2.cjs.entry.js +2 -2
- package/cjs/lmvz-input.cjs.entry.js +4 -7
- package/cjs/lmvz-link.cjs.entry.js +1 -1
- package/cjs/lmvz-menuitem.cjs.entry.js +2 -2
- package/cjs/lmvz-message.cjs.entry.js +2 -2
- package/cjs/lmvz-modal.cjs.entry.js +3 -3
- package/cjs/lmvz-popover.cjs.entry.js +4 -13
- package/cjs/lmvz-radio.cjs.entry.js +2 -2
- package/cjs/lmvz-select.cjs.entry.js +110 -15
- package/cjs/lmvz-snackbar.cjs.entry.js +1 -1
- package/cjs/lmvz-spinner.cjs.entry.js +1 -1
- package/cjs/lmvz-tab.cjs.entry.js +2 -2
- package/cjs/lmvz-tabs.cjs.entry.js +2 -2
- package/cjs/lmvz-toggle.cjs.entry.js +2 -2
- package/cjs/loader.cjs.js +2 -2
- package/collection/components/lmvz-action-list/lmvz-action-list.css +11 -0
- package/collection/components/lmvz-button/lmvz-button.css +11 -0
- package/collection/components/lmvz-card/lmvz-card.css +11 -0
- package/collection/components/lmvz-chip/lmvz-chip.css +1 -1
- package/collection/components/lmvz-chip/lmvz-chip.js +2 -2
- package/collection/components/lmvz-input/lmvz-input.js +2 -5
- package/collection/components/lmvz-message/lmvz-message.css +1 -1
- package/collection/components/lmvz-modal/lmvz-modal.css +11 -0
- package/collection/components/lmvz-popover/lmvz-popover.css +1 -1
- package/collection/components/lmvz-popover/lmvz-popover.js +2 -11
- package/collection/components/lmvz-select/lmvz-select.css +46 -12
- package/collection/components/lmvz-select/lmvz-select.js +151 -17
- package/collection/components/lmvz-tab/lmvz-tab.css +11 -0
- package/collection/components/lmvz-tabs/lmvz-tabs.css +11 -0
- package/components/index.js +1 -1
- package/components/lmvz-action-list.js +1 -1
- package/components/lmvz-action.js +1 -1
- package/components/lmvz-button-group.js +1 -1
- package/components/lmvz-button.js +1 -1
- package/components/lmvz-card.js +1 -1
- package/components/lmvz-checkbox.js +1 -1
- package/components/lmvz-chip.js +1 -1
- package/components/lmvz-datepicker.js +1 -1
- package/components/lmvz-header.js +1 -1
- package/components/lmvz-icon.js +1 -1
- package/components/lmvz-input.js +1 -1
- package/components/lmvz-link.js +1 -1
- package/components/lmvz-menuitem.js +1 -1
- package/components/lmvz-message.js +1 -1
- package/components/lmvz-modal.js +1 -1
- package/components/lmvz-popover.js +1 -1
- package/components/lmvz-radio.js +1 -1
- package/components/lmvz-select.js +1 -1
- package/components/lmvz-snackbar.js +1 -1
- package/components/lmvz-spinner.js +1 -1
- package/components/lmvz-tab.js +1 -1
- package/components/lmvz-tabs.js +1 -1
- package/components/lmvz-toggle.js +1 -1
- package/components/p-B6bUOPCG.js +1 -0
- package/components/{p-BLMXiDE0.js → p-CcP_sfo8.js} +1 -1
- package/components/{p--FDdvoIg.js → p-CgGqXTxQ.js} +1 -1
- package/components/p-D3wobLRi.js +1 -0
- package/components/p-DAikapVO.js +1 -0
- package/components/{p-diOze8wI.js → p-DXFoXTse.js} +1 -1
- package/components/p-D_mff3n7.js +1 -0
- package/components/p-DbBJxuBm.js +1 -0
- package/components/{p-CrQCHVKL.js → p-DfFdoFeH.js} +1 -1
- package/components/{p-DqdrUt_G.js → p-GJaYKpHS.js} +1 -1
- package/components/p-SnHLBAbf.js +1 -0
- package/{lmvz-components/p-BeY96W7m.js → components/p-sACbyedu.js} +1 -1
- package/esm/{aria-validation-controller-Cp6pofER.js → aria-validation-controller-Dwv7n0rk.js} +1 -1
- package/esm/checkmark-DAikapVO.js +3 -0
- package/esm/{index-BOXP1Vx0.js → index-DVab4vzV.js} +41 -1
- package/esm/lmvz-action-list.entry.js +3 -3
- package/esm/lmvz-action.entry.js +1 -1
- package/esm/lmvz-button-group.entry.js +1 -1
- package/esm/lmvz-button_2.entry.js +3 -3
- package/esm/lmvz-card.entry.js +2 -2
- package/esm/lmvz-checkbox.entry.js +3 -4
- package/esm/lmvz-chip.entry.js +5 -5
- package/esm/lmvz-components.js +3 -3
- package/esm/lmvz-datepicker.entry.js +1 -1
- package/esm/lmvz-header_2.entry.js +2 -2
- package/esm/lmvz-input.entry.js +4 -7
- package/esm/lmvz-link.entry.js +1 -1
- package/esm/lmvz-menuitem.entry.js +2 -2
- package/esm/lmvz-message.entry.js +2 -2
- package/esm/lmvz-modal.entry.js +3 -3
- package/esm/lmvz-popover.entry.js +4 -13
- package/esm/lmvz-radio.entry.js +2 -2
- package/esm/lmvz-select.entry.js +110 -15
- package/esm/lmvz-snackbar.entry.js +1 -1
- package/esm/lmvz-spinner.entry.js +1 -1
- package/esm/lmvz-tab.entry.js +2 -2
- package/esm/lmvz-tabs.entry.js +2 -2
- package/esm/lmvz-toggle.entry.js +2 -2
- package/esm/loader.js +3 -3
- package/hydrate/index.js +165 -43
- package/hydrate/index.mjs +165 -43
- package/lmvz-components/lmvz-components.esm.js +1 -1
- package/lmvz-components/p-1e1dea53.entry.js +1 -0
- package/lmvz-components/{p-0f65d001.entry.js → p-27e8b4fa.entry.js} +1 -1
- package/lmvz-components/{p-3d5867df.entry.js → p-335b3867.entry.js} +1 -1
- package/lmvz-components/p-3b7203a3.entry.js +1 -0
- package/lmvz-components/{p-70f1e31a.entry.js → p-3fc6c3f6.entry.js} +1 -1
- package/lmvz-components/p-6aae1df9.entry.js +1 -0
- package/lmvz-components/p-743616c0.entry.js +1 -0
- package/lmvz-components/{p-26dd9684.entry.js → p-773e9d95.entry.js} +1 -1
- package/lmvz-components/{p-a6fe9b61.entry.js → p-7cbfbc88.entry.js} +1 -1
- package/lmvz-components/p-87f21ac9.entry.js +1 -0
- package/lmvz-components/{p-a680a7b2.entry.js → p-8ba6ec19.entry.js} +1 -1
- package/lmvz-components/p-9813a7d2.entry.js +1 -0
- package/lmvz-components/p-DAikapVO.js +1 -0
- package/lmvz-components/p-DVab4vzV.js +2 -0
- package/{components/p-BAj4FkUt.js → lmvz-components/p-Wi9d2-w9.js} +1 -1
- package/lmvz-components/{p-f16a19fc.entry.js → p-b5a5eb9a.entry.js} +1 -1
- package/lmvz-components/p-cadd88e5.entry.js +1 -0
- package/lmvz-components/p-cebaddb0.entry.js +1 -0
- package/lmvz-components/p-d53e69de.entry.js +1 -0
- package/lmvz-components/{p-36f44108.entry.js → p-d73bb7fd.entry.js} +1 -1
- package/lmvz-components/{p-398b5cf4.entry.js → p-db75e362.entry.js} +1 -1
- package/lmvz-components/{p-137b1fe1.entry.js → p-e35f49a1.entry.js} +1 -1
- package/lmvz-components/{p-0af0211a.entry.js → p-eb741e1f.entry.js} +1 -1
- package/lmvz-components/{p-88661c50.entry.js → p-efd9d50e.entry.js} +1 -1
- package/lmvz-components/p-f24f5207.entry.js +1 -0
- package/manifest.json +75 -13
- package/package.json +1 -1
- package/types/components/lmvz-input/lmvz-input.d.ts +0 -2
- package/types/components/lmvz-popover/lmvz-popover.d.ts +0 -1
- package/types/components/lmvz-select/lmvz-select.d.ts +12 -2
- package/types/components.d.ts +39 -8
- package/components/p-BApwCp0R.js +0 -1
- package/components/p-BPYBmylI.js +0 -1
- package/components/p-Bnri3fEI.js +0 -1
- package/components/p-C5gRiLRR.js +0 -1
- package/lmvz-components/p-3a396fc8.entry.js +0 -1
- package/lmvz-components/p-40716828.entry.js +0 -1
- package/lmvz-components/p-492adf21.entry.js +0 -1
- package/lmvz-components/p-4fa6e72f.entry.js +0 -1
- package/lmvz-components/p-71d06d1d.entry.js +0 -1
- package/lmvz-components/p-7a7aa922.entry.js +0 -1
- package/lmvz-components/p-91eb71bb.entry.js +0 -1
- package/lmvz-components/p-BOXP1Vx0.js +0 -2
- package/lmvz-components/p-a99acb02.entry.js +0 -1
- package/lmvz-components/p-f3f0ed49.entry.js +0 -1
- package/lmvz-components/p-f516a949.entry.js +0 -1
|
@@ -187,9 +187,6 @@ export class LmvzInput extends ReactiveControllerHost {
|
|
|
187
187
|
return;
|
|
188
188
|
this.updateNativeError('input');
|
|
189
189
|
};
|
|
190
|
-
handleChange = (event) => {
|
|
191
|
-
};
|
|
192
|
-
handleFocus = () => { };
|
|
193
190
|
handleInvalid = () => this.updateNativeError('invalid');
|
|
194
191
|
handleBlur = () => {
|
|
195
192
|
this.inputValidityActive = true;
|
|
@@ -207,9 +204,9 @@ export class LmvzInput extends ReactiveControllerHost {
|
|
|
207
204
|
render() {
|
|
208
205
|
const hasValue = Boolean(this.value);
|
|
209
206
|
const shouldFloatLabel = hasValue || Boolean(this.placeholder);
|
|
210
|
-
return (h("div", { key: '
|
|
207
|
+
return (h("div", { key: '85f498773efdad53d309e8b1eb5b85ea0601277e', class: classNames('input-container', {
|
|
211
208
|
'interaction-filled': hasValue,
|
|
212
|
-
}) }, h("div", { key: '
|
|
209
|
+
}) }, h("div", { key: 'eb74bdd8170014c2a17c6046878b0f4d61fece25', class: "input-wrapper" }, h("slot", { key: 'ceb3acb5dcb641900caf9a22f43295d1c407ad2e', name: "before-input" }), h("div", { key: 'a7f626addd83cbf79b435989bec94f777818794e', class: "label-input-group" }, h("label", { key: '391e2d1f873f9aef9bd9e7f14b006d898a699abe', htmlFor: this.inputId, class: classNames({ floating: shouldFloatLabel }) }, this.label, this.required && (h("span", { key: '691251a0efb1a60fd5e53447a6204c13008545a1', class: "required-indicator", "aria-hidden": "true" }, ' ', "*"))), h("input", { key: 'f37d3d7d5076636638b2da59cca91c1cedc7504a', id: this.inputId, ref: (el) => (this.nativeInputElement = el), type: this.type, min: this.min, max: this.max, step: this.step, value: this.value, name: this.name, placeholder: this.placeholder, disabled: this.disabled, readonly: this.readonly, required: this.required, form: this.form, autocomplete: this.autocomplete, inputmode: this.inputmode, autocorrect: this.autocorrect, autocapitalize: this.autocapitalize, spellcheck: this.spellcheck, autofocus: this.autofocus, minlength: this.minlength, maxlength: this.maxlength, pattern: this.pattern, "aria-invalid": this.error ? 'true' : 'false', "aria-required": this.required ? 'true' : 'false', "aria-describedby": this.describedBy, "aria-errormessage": this.errorId, onInput: this.handleInput, onBlur: this.handleBlur, onInvalid: this.handleInvalid })), h("slot", { key: '22b2be3072fc274bbeff4d92f25dccc5ea50c4d0', name: "after-input" })), h("div", { key: '95f28aad61a5d7ea45fb4479801097036652b08f', id: this.helperId, role: "status" }, this.helperText || null), h("div", { key: '9ea8420b336b33a0fd3b7e53cc4efa44983cbdc3', id: this.errorId, role: "alert" }, (this.showErrorMessage && this.errorMessage) || null)));
|
|
213
210
|
}
|
|
214
211
|
static get is() { return "lmvz-input"; }
|
|
215
212
|
static get encapsulation() { return "scoped"; }
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
:host([type='neutral']) {
|
|
21
21
|
background-color: var(--lmvz-semantic-color-status-active, #f6fbfe);
|
|
22
|
-
border-color: var(--lmvz-semantic-color-status-on-active-subtle, #
|
|
22
|
+
border-color: var(--lmvz-semantic-color-status-on-active-subtle, #7fccf5);
|
|
23
23
|
color: var(--lmvz-semantic-color-status-on-active, #0e7ab4);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -62,6 +62,17 @@ hr {
|
|
|
62
62
|
border-top: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-border-subtle, #f0f0f0);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
fieldset {
|
|
66
|
+
border: none;
|
|
67
|
+
margin: 0;
|
|
68
|
+
padding: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
legend {
|
|
72
|
+
padding: 0;
|
|
73
|
+
display: block;
|
|
74
|
+
}
|
|
75
|
+
|
|
65
76
|
}
|
|
66
77
|
:host {
|
|
67
78
|
display: contents;
|
|
@@ -39,7 +39,6 @@ export class LmvzPopover {
|
|
|
39
39
|
}
|
|
40
40
|
componentDidLoad() {
|
|
41
41
|
autoAssignId(this.el);
|
|
42
|
-
this.syncContainerId();
|
|
43
42
|
}
|
|
44
43
|
handleOpenChange(isOpen) {
|
|
45
44
|
if (isOpen) {
|
|
@@ -66,23 +65,16 @@ export class LmvzPopover {
|
|
|
66
65
|
this.removeCloseHandlers();
|
|
67
66
|
this.extEventController.abort();
|
|
68
67
|
}
|
|
69
|
-
syncContainerId() {
|
|
70
|
-
const hostId = this.el.getAttribute('id');
|
|
71
|
-
if (!hostId || !this.containerEl)
|
|
72
|
-
return;
|
|
73
|
-
this.containerEl.id = hostId;
|
|
74
|
-
}
|
|
75
68
|
setupAnchorEl() {
|
|
76
69
|
const { anchorEl } = this;
|
|
77
70
|
if (!anchorEl) {
|
|
78
71
|
console.warn('no anchor element set for', this);
|
|
79
72
|
return;
|
|
80
73
|
}
|
|
81
|
-
this.syncContainerId();
|
|
82
74
|
if (!anchorEl.hasAttribute('aria-haspopup')) {
|
|
83
75
|
anchorEl.setAttribute('aria-haspopup', this.containerRole === 'dialog' ? 'dialog' : this.containerRole);
|
|
84
76
|
}
|
|
85
|
-
anchorEl.setAttribute('aria-controls', this.
|
|
77
|
+
anchorEl.setAttribute('aria-controls', this.el.getAttribute('id'));
|
|
86
78
|
if (!anchorEl.hasAttribute('aria-expanded')) {
|
|
87
79
|
anchorEl.setAttribute('aria-expanded', this.open ? 'true' : 'false');
|
|
88
80
|
}
|
|
@@ -110,7 +102,6 @@ export class LmvzPopover {
|
|
|
110
102
|
await waitFrame();
|
|
111
103
|
await this.updatePosition();
|
|
112
104
|
autoAssignId(this.el);
|
|
113
|
-
this.syncContainerId();
|
|
114
105
|
this.applyAnchorAriaOpen();
|
|
115
106
|
this.lmvzOpen.emit();
|
|
116
107
|
await waitFrame();
|
|
@@ -189,7 +180,7 @@ export class LmvzPopover {
|
|
|
189
180
|
this.closureController?.abort();
|
|
190
181
|
}
|
|
191
182
|
render() {
|
|
192
|
-
return (h(Host, { key: '
|
|
183
|
+
return (h(Host, { key: '83529aeac05cdc706193fa8bbbcc8f8672756111', role: this.containerRole, "aria-label": this.label || undefined }, h("div", { key: '97c255e788806c0dec2f4ed04c6fc815150912a2', part: "container", class: `container lmvz-wrapper-card-${this.size}`, ref: (el) => (this.containerEl = el) }, h("slot", { key: 'e4ea69d179557e7d34f1475c07c9284ea8d10a67', ref: (el) => (this.slotEl = el) }))));
|
|
193
184
|
}
|
|
194
185
|
static get is() { return "lmvz-popover"; }
|
|
195
186
|
static get encapsulation() { return "shadow"; }
|
|
@@ -60,6 +60,8 @@
|
|
|
60
60
|
--lmvz-select-helper-color: var(--lmvz-semantic-color-on-surface-input-secondary, #545454);
|
|
61
61
|
--lmvz-select-focus-color: var(--lmvz-semantic-color-status-on-active, #0e7ab4);
|
|
62
62
|
--lmvz-select-error-color: var(--lmvz-semantic-color-status-on-danger, #a31419);
|
|
63
|
+
/* Sizes the trailing chevron icon, shared by single- and multiselect modes. */
|
|
64
|
+
--lmvz-select-chevron-size: var(--lmvz-component-icon-size-2xs, clamp(0.63rem, 0.59rem + 0.13vw, 0.75rem));
|
|
63
65
|
|
|
64
66
|
padding-top: var(--lmvz-internal-select-floating-label-top-offset);
|
|
65
67
|
}
|
|
@@ -160,17 +162,29 @@ label > span[aria-hidden='true'],
|
|
|
160
162
|
:host(:not([highlighted])) .select-wrapper.has-value .select-trigger > span:first-child {
|
|
161
163
|
color: var(--lmvz-semantic-color-int-on-secondary-active, #000000);
|
|
162
164
|
}
|
|
163
|
-
|
|
165
|
+
/* Trailing chevron child span, shared by single- and multiselect modes. Scoped with the
|
|
166
|
+
adjacent-sibling combinator (rather than :last-child) so it never matches the leading text/chip
|
|
167
|
+
span. */
|
|
168
|
+
.select-trigger > span:first-child + span {
|
|
164
169
|
flex-shrink: 0;
|
|
165
170
|
display: flex;
|
|
166
171
|
align-items: center;
|
|
167
172
|
justify-content: center;
|
|
168
173
|
}
|
|
169
174
|
.select-trigger svg {
|
|
170
|
-
width: var(--lmvz-
|
|
171
|
-
height: var(--lmvz-
|
|
175
|
+
width: var(--lmvz-select-chevron-size);
|
|
176
|
+
height: var(--lmvz-select-chevron-size);
|
|
172
177
|
flex-shrink: 0;
|
|
173
178
|
}
|
|
179
|
+
/* Chip row — rendered inline inside the trigger's leading text span (.select-trigger >
|
|
180
|
+
span:first-child), reusing that span's flex/overflow/ellipsis truncation contract instead of
|
|
181
|
+
duplicating it. Single-line: overflowing chips are truncated with an ellipsis, never wrapped. */
|
|
182
|
+
.select-trigger > span:first-child lmvz-chip {
|
|
183
|
+
vertical-align: middle;
|
|
184
|
+
}
|
|
185
|
+
.select-trigger > span:first-child lmvz-chip + lmvz-chip {
|
|
186
|
+
margin-inline-start: var(--lmvz-select-gap);
|
|
187
|
+
}
|
|
174
188
|
/* Native <option>/<optgroup> markup is only a data source for the internal listbox; never shown. */
|
|
175
189
|
.lmvz-select-native-options {
|
|
176
190
|
display: none;
|
|
@@ -199,27 +213,21 @@ label > span[aria-hidden='true'],
|
|
|
199
213
|
--lmvz-select-padding-x: var(--lmvz-component-input-padding-sm, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
|
|
200
214
|
--lmvz-select-gap: var(--lmvz-component-input-gap-sm, clamp(0.38rem, 0.31rem + 0.26vw, 0.63rem));
|
|
201
215
|
--lmvz-select-label-font-size: var(--lmvz-component-body-2xs-font-size, clamp(0.5rem, 0.47rem + 0.13vw, 0.63rem));
|
|
216
|
+
--lmvz-select-chevron-size: var(--lmvz-component-icon-size-4xs, clamp(0.5rem, 0.47rem + 0.13vw, 0.63rem));
|
|
202
217
|
}
|
|
203
218
|
:host([size='small']) .select-trigger > span:first-child {
|
|
204
219
|
font-size: var(--lmvz-component-body-sm-font-size, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
|
|
205
220
|
}
|
|
206
|
-
:host([size='small']) .select-trigger svg {
|
|
207
|
-
width: var(--lmvz-component-icon-size-4xs, clamp(0.5rem, 0.47rem + 0.13vw, 0.63rem));
|
|
208
|
-
height: var(--lmvz-component-icon-size-4xs, clamp(0.5rem, 0.47rem + 0.13vw, 0.63rem));
|
|
209
|
-
}
|
|
210
221
|
:host([size='large']) {
|
|
211
222
|
--lmvz-select-height: var(--lmvz-component-input-size-lg, clamp(2.75rem, 2.69rem + 0.26vw, 3rem));
|
|
212
223
|
--lmvz-select-padding-x: var(--lmvz-component-input-padding-lg, clamp(1rem, 0.94rem + 0.26vw, 1.25rem));
|
|
213
224
|
--lmvz-select-gap: var(--lmvz-component-input-gap-lg, clamp(0.75rem, 0.69rem + 0.26vw, 1rem));
|
|
214
225
|
--lmvz-select-label-font-size: var(--lmvz-component-body-sm-font-size, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
|
|
226
|
+
--lmvz-select-chevron-size: var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
|
|
215
227
|
}
|
|
216
228
|
:host([size='large']) .select-trigger > span:first-child {
|
|
217
229
|
font-size: var(--lmvz-component-body-lg-font-size, clamp(1rem, 0.97rem + 0.13vw, 1.13rem));
|
|
218
230
|
}
|
|
219
|
-
:host([size='large']) .select-trigger svg {
|
|
220
|
-
width: var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
|
|
221
|
-
height: var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem));
|
|
222
|
-
}
|
|
223
231
|
/*
|
|
224
232
|
* Option-list item styling for the `role="option"` elements rendered inside the
|
|
225
233
|
* `lmvz-popover` (containerRole="listbox") popup. The token set mirrors the states
|
|
@@ -273,7 +281,7 @@ label > span[aria-hidden='true'],
|
|
|
273
281
|
--lmvz-select-option-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0);
|
|
274
282
|
--lmvz-select-option-color: var(--lmvz-semantic-color-int-on-tertiary-hover, #000000);
|
|
275
283
|
}
|
|
276
|
-
.lmvz-select-option[aria-selected='true'] {
|
|
284
|
+
:host(:not([multiple])) .lmvz-select-option[aria-selected='true'] {
|
|
277
285
|
--lmvz-select-option-background: var(--lmvz-semantic-color-status-active-alternate, #0f8acc);
|
|
278
286
|
--lmvz-select-option-color: var(--lmvz-semantic-color-status-on-active-alternate, #ffffff);
|
|
279
287
|
}
|
|
@@ -282,3 +290,29 @@ label > span[aria-hidden='true'],
|
|
|
282
290
|
pointer-events: none;
|
|
283
291
|
opacity: var(--lmvz-component-input-disabled-opacity, 40%);
|
|
284
292
|
}
|
|
293
|
+
/*
|
|
294
|
+
* Decorative, aria-hidden checkbox-style indicator shown per option in multiselect mode.
|
|
295
|
+
* Mirrors lmvz-checkbox's box/indicator sizing tokens for visual consistency across the DS.
|
|
296
|
+
* `aria-selected` on the option (above) remains the real, sole selection semantic; this is
|
|
297
|
+
* purely a visual affordance.
|
|
298
|
+
*/
|
|
299
|
+
.lmvz-select-option-checkbox {
|
|
300
|
+
display: flex;
|
|
301
|
+
align-items: center;
|
|
302
|
+
justify-content: center;
|
|
303
|
+
width: var(--lmvz-global-s18, 18px);
|
|
304
|
+
height: var(--lmvz-global-s18, 18px);
|
|
305
|
+
border: var(--lmvz-semantic-border-width-default, 1px) solid currentcolor;
|
|
306
|
+
border-radius: var(--lmvz-global-s4, 4px);
|
|
307
|
+
flex-shrink: 0;
|
|
308
|
+
}
|
|
309
|
+
.lmvz-select-option-checkbox-indicator {
|
|
310
|
+
display: flex;
|
|
311
|
+
align-items: center;
|
|
312
|
+
justify-content: center;
|
|
313
|
+
line-height: 0;
|
|
314
|
+
}
|
|
315
|
+
.lmvz-select-option-checkbox-indicator svg {
|
|
316
|
+
width: 100%;
|
|
317
|
+
height: 100%;
|
|
318
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import checkmark from "@lmvz-ds/icons/assets/checkmark.svg";
|
|
2
|
+
import { toValidSvgStringWithFallback } from "@lmvz-ds/lib-ts/validation/svg.js";
|
|
3
|
+
import { Fragment, h, Host } from "@stencil/core";
|
|
2
4
|
import { AriaValidationController } from "../../utils/aria/aria-validation-controller";
|
|
3
5
|
import { ListboxController } from "../../utils/aria/listbox-controller";
|
|
4
6
|
import { ReactiveControllerHost } from "../../utils/stencil/reactive-controller-host";
|
|
5
7
|
let selectIdCounter = 0;
|
|
8
|
+
const CHECKMARK_SVG = toValidSvgStringWithFallback(checkmark);
|
|
6
9
|
export class LmvzSelect extends ReactiveControllerHost {
|
|
7
10
|
el;
|
|
8
11
|
get validationEl() {
|
|
@@ -17,6 +20,8 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
17
20
|
optionsMutationObserver;
|
|
18
21
|
initialValue;
|
|
19
22
|
initialValueCaptured = false;
|
|
23
|
+
initialValues;
|
|
24
|
+
initialValuesCaptured = false;
|
|
20
25
|
flatOptions = [];
|
|
21
26
|
optionsById = new Map();
|
|
22
27
|
listboxController = new ListboxController({
|
|
@@ -50,6 +55,8 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
50
55
|
}
|
|
51
56
|
lmvzChange;
|
|
52
57
|
value;
|
|
58
|
+
multiple = false;
|
|
59
|
+
values;
|
|
53
60
|
label;
|
|
54
61
|
helperText;
|
|
55
62
|
nativeError = false;
|
|
@@ -72,7 +79,17 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
72
79
|
isOpen = false;
|
|
73
80
|
optionGroups = [];
|
|
74
81
|
get hasValue() {
|
|
75
|
-
return Boolean(this.value);
|
|
82
|
+
return this.multiple ? Boolean(this.values && this.values.length > 0) : Boolean(this.value);
|
|
83
|
+
}
|
|
84
|
+
get triggerAriaLabel() {
|
|
85
|
+
if (this.multiple) {
|
|
86
|
+
const count = this.values?.length ?? 0;
|
|
87
|
+
return count > 0 ? `${this.label}, ${count} selected` : this.label;
|
|
88
|
+
}
|
|
89
|
+
return this.hasValue ? `${this.label}, ${this.selectedLabel}` : this.label;
|
|
90
|
+
}
|
|
91
|
+
get chipSize() {
|
|
92
|
+
return this.size === 'small' ? 'small' : 'default';
|
|
76
93
|
}
|
|
77
94
|
componentWillLoad() {
|
|
78
95
|
this.updateValidity();
|
|
@@ -119,17 +136,28 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
119
136
|
formAssociatedCallback(form) {
|
|
120
137
|
if (!form)
|
|
121
138
|
return;
|
|
122
|
-
this.
|
|
139
|
+
this.syncFormValue();
|
|
123
140
|
}
|
|
124
141
|
formResetCallback() {
|
|
125
142
|
this.internals.setValidity?.({});
|
|
126
|
-
this.
|
|
143
|
+
if (this.multiple) {
|
|
144
|
+
this.values = this.initialValues ? [...this.initialValues] : [];
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this.value = this.initialValue;
|
|
148
|
+
}
|
|
127
149
|
this.updateValidity();
|
|
128
150
|
}
|
|
129
151
|
formStateRestoreCallback(state) {
|
|
152
|
+
if (this.multiple) {
|
|
153
|
+
this.values = state instanceof FormData && this.name ? state.getAll(this.name).map(String) : [];
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
130
156
|
this.value = state;
|
|
131
157
|
}
|
|
132
158
|
handleValueChange(newValue) {
|
|
159
|
+
if (this.multiple)
|
|
160
|
+
return;
|
|
133
161
|
this.applySelectionFromValue();
|
|
134
162
|
if (this.selectedId && !this.isOpen) {
|
|
135
163
|
this.listboxController.setActiveId(this.selectedId);
|
|
@@ -137,6 +165,12 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
137
165
|
this.internals.setFormValue?.(newValue ?? '');
|
|
138
166
|
this.updateValidity();
|
|
139
167
|
}
|
|
168
|
+
handleValuesChange() {
|
|
169
|
+
if (!this.multiple)
|
|
170
|
+
return;
|
|
171
|
+
this.syncFormValue();
|
|
172
|
+
this.updateValidity();
|
|
173
|
+
}
|
|
140
174
|
handleRequiredChange() {
|
|
141
175
|
this.updateValidity();
|
|
142
176
|
}
|
|
@@ -154,15 +188,31 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
154
188
|
this.flatOptions = flat;
|
|
155
189
|
this.optionsById = new Map(flat.map((option) => [option.id, option]));
|
|
156
190
|
this.optionGroups = groups;
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
191
|
+
if (this.multiple) {
|
|
192
|
+
if (!this.values) {
|
|
193
|
+
const preselected = flat.filter((option) => option.selected && !option.disabled).map((option) => option.value);
|
|
194
|
+
if (preselected.length > 0) {
|
|
195
|
+
this.values = preselected;
|
|
196
|
+
}
|
|
161
197
|
}
|
|
162
198
|
}
|
|
163
|
-
|
|
199
|
+
else {
|
|
200
|
+
if (!this.value) {
|
|
201
|
+
const preselected = flat.find((option) => option.selected && !option.disabled);
|
|
202
|
+
if (preselected) {
|
|
203
|
+
this.value = preselected.value;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
this.applySelectionFromValue();
|
|
207
|
+
}
|
|
164
208
|
this.listboxController.setOptions(flat.map(({ id, label, disabled }) => ({ id, label, disabled })));
|
|
165
|
-
if (
|
|
209
|
+
if (this.multiple) {
|
|
210
|
+
if (!this.initialValuesCaptured) {
|
|
211
|
+
this.initialValues = this.values ? [...this.values] : [];
|
|
212
|
+
this.initialValuesCaptured = true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else if (!this.initialValueCaptured) {
|
|
166
216
|
this.initialValue = this.value;
|
|
167
217
|
this.initialValueCaptured = true;
|
|
168
218
|
}
|
|
@@ -173,8 +223,28 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
173
223
|
this.selectedLabel = match?.label ?? '';
|
|
174
224
|
this.listboxController.setSelectedId(match?.id);
|
|
175
225
|
}
|
|
226
|
+
isOptionSelected(option) {
|
|
227
|
+
if (this.multiple) {
|
|
228
|
+
return (this.values ?? []).includes(option.value);
|
|
229
|
+
}
|
|
230
|
+
return option.id === this.selectedId;
|
|
231
|
+
}
|
|
232
|
+
syncFormValue() {
|
|
233
|
+
if (this.multiple) {
|
|
234
|
+
const formData = new FormData();
|
|
235
|
+
if (this.name) {
|
|
236
|
+
for (const value of this.values ?? []) {
|
|
237
|
+
formData.append(this.name, value);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
this.internals.setFormValue?.(formData);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
this.internals.setFormValue?.(this.value ?? '');
|
|
244
|
+
}
|
|
176
245
|
updateValidity() {
|
|
177
|
-
|
|
246
|
+
const missing = this.multiple ? !(this.values && this.values.length > 0) : !this.value;
|
|
247
|
+
if (this.required && missing) {
|
|
178
248
|
this.internals.setValidity?.({ valueMissing: true }, 'Please select a value.', this.triggerEl);
|
|
179
249
|
return;
|
|
180
250
|
}
|
|
@@ -188,6 +258,13 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
188
258
|
const option = this.optionsById.get(id);
|
|
189
259
|
if (!option)
|
|
190
260
|
return;
|
|
261
|
+
if (this.multiple) {
|
|
262
|
+
const current = this.values ?? [];
|
|
263
|
+
const updated = current.includes(option.value) ? current.filter((value) => value !== option.value) : [...current, option.value];
|
|
264
|
+
this.values = updated;
|
|
265
|
+
this.lmvzChange.emit(updated);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
191
268
|
const isNewValue = option.value !== this.value;
|
|
192
269
|
this.value = option.value;
|
|
193
270
|
if (isNewValue) {
|
|
@@ -250,12 +327,26 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
250
327
|
return this.optionGroups.map((group, groupIndex) => group.label ? (h("div", { role: "group", "aria-label": group.label, key: `lmvz-select-group-${groupIndex}` }, group.options.map((option) => this.renderOption(option)))) : (group.options.map((option) => this.renderOption(option))));
|
|
251
328
|
}
|
|
252
329
|
renderOption(option) {
|
|
253
|
-
|
|
330
|
+
const selected = this.isOptionSelected(option);
|
|
331
|
+
return (h("div", { id: option.id, key: option.id, role: "option", class: "lmvz-select-option", "aria-selected": selected ? 'true' : 'false', "aria-disabled": option.disabled ? 'true' : undefined, "data-active": option.id === this.activeId ? 'true' : undefined, onMouseDown: (event) => event.preventDefault(), onClick: () => this.handleOptionClick(option) }, this.multiple && (h("span", { class: "lmvz-select-option-checkbox", "aria-hidden": "true" }, selected && h("span", { class: "lmvz-select-option-checkbox-indicator", innerHTML: CHECKMARK_SVG }))), option.label));
|
|
332
|
+
}
|
|
333
|
+
renderChips() {
|
|
334
|
+
const values = this.values ?? [];
|
|
335
|
+
const occurrenceCounts = new Map();
|
|
336
|
+
return (h(Fragment, null, values.map((value) => {
|
|
337
|
+
const occurrence = occurrenceCounts.get(value) ?? 0;
|
|
338
|
+
occurrenceCounts.set(value, occurrence + 1);
|
|
339
|
+
const chipKey = occurrence === 0 ? value : `${value}-dup-${occurrence}`;
|
|
340
|
+
const option = this.flatOptions.find((candidate) => candidate.value === value);
|
|
341
|
+
const chipLabel = option?.label ?? value;
|
|
342
|
+
return (h("lmvz-chip", { key: chipKey, size: this.chipSize }, chipLabel));
|
|
343
|
+
})));
|
|
254
344
|
}
|
|
255
345
|
render() {
|
|
256
346
|
const hasValue = this.hasValue;
|
|
257
347
|
const shouldShowLabel = hasValue;
|
|
258
|
-
|
|
348
|
+
const showChips = this.multiple && hasValue;
|
|
349
|
+
return (h(Host, { key: 'aece4095568891e34afc978c6a0aa9e638e7e207', "data-highlighted": String(this.highlighted) }, h("div", { key: '7c0e2a71a2b3b0bee46009c3498062b86f6eca72', class: hasValue ? 'select-wrapper has-value' : 'select-wrapper' }, h("label", { key: 'f473d3a012cbd43c691de1782ead4a5d5e59cd32', htmlFor: this.triggerId, class: shouldShowLabel ? 'floating-label' : 'assistive-label', onMouseDown: (event) => event.preventDefault(), onClick: this.handleLabelClick }, this.label, this.required && shouldShowLabel && h("span", { key: '50a2d3999af0310fcf1af62fdf72109fc25f76ee', "aria-hidden": "true" }, " *")), h("div", { key: 'd09b26c4e8d9e4ae8ab503c4abb2b22f7e0d905c', id: this.triggerId, ref: (el) => (this.triggerEl = el), class: "select-trigger", role: "combobox", tabIndex: this.disabled ? -1 : 0, "aria-haspopup": "listbox", "aria-expanded": String(this.isOpen), "aria-controls": this.popoverId, "aria-activedescendant": this.isOpen ? this.activeId : undefined, "aria-label": this.triggerAriaLabel, "aria-disabled": this.disabled ? 'true' : undefined, "aria-required": this.required ? 'true' : 'false', "aria-invalid": this.error ? 'true' : 'false', "aria-errormessage": this.showErrorMessage ? this.errorId : undefined, "aria-describedby": this.describedBy, onClick: this.handleTriggerClick, onKeyDown: this.handleTriggerKeydown, onBlur: this.handleTriggerBlur }, h("span", { key: '99fbb4a7a2ce16e63bf30b2c25a0c413533d60f5' }, showChips ? this.renderChips() : hasValue ? this.selectedLabel : this.label, this.required && !hasValue && h("span", { key: '3f6473f7f064e98bcdf936e2b9a5978f20e00772', "aria-hidden": "true" }, " *")), h("span", { key: 'cfb75d279c2c101d7724c596a4f2cd34ce13d7c0', "aria-hidden": "true" }, h("svg", { key: '51e30ae88d4355e0513cce076c97dd335b6a1d7e', width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '0b1fb9c3d6809daa93abc404fbb82469d9f4a1cc', d: "M20.3334 8.66663L12.0001 17L3.66675 8.66663", stroke: "currentColor", "stroke-width": "1.75", "stroke-linecap": "round", "stroke-linejoin": "round" })))), h("lmvz-popover", { key: '02b3524eed3eb4da9899f2acb85eba2cc3f09d78', id: this.popoverId, anchor: this.triggerId, open: this.isOpen, containerRole: "listbox", autoFocus: false, label: this.label, "aria-multiselectable": this.multiple ? 'true' : undefined, onLmvzClose: this.handlePopoverClose, size: "sm" }, this.renderOptionGroups()), h("div", { key: '84cbf09b5d47eeebba9ed55f21aa715257faf1f1', class: "lmvz-select-native-options", hidden: true, "aria-hidden": "true", ref: (el) => (this.optionsSourceEl = el) }, h("slot", { key: '928aa417eca972d4d85592f569c3fc95419dd9b3', onSlotchange: this.handleSlotChange }))), this.helperText && (h("div", { key: '5c0dac612458ba3564c3ac445f396c9e95832fe6', id: this.helperId, role: "status" }, this.helperText)), this.showErrorMessage && (h("div", { key: '4c5c0a3826239fd2d5b52ad9118937dc5494c632', id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
259
350
|
}
|
|
260
351
|
static get is() { return "lmvz-select"; }
|
|
261
352
|
static get encapsulation() { return "scoped"; }
|
|
@@ -284,13 +375,53 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
284
375
|
"optional": true,
|
|
285
376
|
"docs": {
|
|
286
377
|
"tags": [],
|
|
287
|
-
"text": "Currently selected value."
|
|
378
|
+
"text": "Currently selected value. Ignored (not read or written) when `multiple` is `true` \u2014 use\n`values` instead."
|
|
288
379
|
},
|
|
289
380
|
"getter": false,
|
|
290
381
|
"setter": false,
|
|
291
382
|
"reflect": false,
|
|
292
383
|
"attribute": "value"
|
|
293
384
|
},
|
|
385
|
+
"multiple": {
|
|
386
|
+
"type": "boolean",
|
|
387
|
+
"mutable": false,
|
|
388
|
+
"complexType": {
|
|
389
|
+
"original": "boolean",
|
|
390
|
+
"resolved": "boolean",
|
|
391
|
+
"references": {}
|
|
392
|
+
},
|
|
393
|
+
"required": false,
|
|
394
|
+
"optional": false,
|
|
395
|
+
"docs": {
|
|
396
|
+
"tags": [{
|
|
397
|
+
"name": "default",
|
|
398
|
+
"text": "false"
|
|
399
|
+
}],
|
|
400
|
+
"text": "Enables multiselect mode. When `true`, `values` becomes the sole selection source (`value`\nis not read or written by the component), options toggle membership on selection instead of\nreplacing a single value, the popup stays open after selecting/deselecting an option, and the\nclosed trigger renders one `lmvz-chip` per selected value for display only. Removing a value\nis done by reselecting it in the open listbox (via `handleOptionSelect`'s toggle-off path),\nnot from a control on the chip itself."
|
|
401
|
+
},
|
|
402
|
+
"getter": false,
|
|
403
|
+
"setter": false,
|
|
404
|
+
"reflect": true,
|
|
405
|
+
"attribute": "multiple",
|
|
406
|
+
"defaultValue": "false"
|
|
407
|
+
},
|
|
408
|
+
"values": {
|
|
409
|
+
"type": "unknown",
|
|
410
|
+
"mutable": true,
|
|
411
|
+
"complexType": {
|
|
412
|
+
"original": "string[]",
|
|
413
|
+
"resolved": "string[] | undefined",
|
|
414
|
+
"references": {}
|
|
415
|
+
},
|
|
416
|
+
"required": false,
|
|
417
|
+
"optional": true,
|
|
418
|
+
"docs": {
|
|
419
|
+
"tags": [],
|
|
420
|
+
"text": "Currently selected values in multiselect mode (`multiple` true). Not attribute-reflected;\nset/read as a JS property. Preselection collects every enabled `<option selected>` (not just\nthe first) into the initial value when unset."
|
|
421
|
+
},
|
|
422
|
+
"getter": false,
|
|
423
|
+
"setter": false
|
|
424
|
+
},
|
|
294
425
|
"label": {
|
|
295
426
|
"type": "string",
|
|
296
427
|
"mutable": false,
|
|
@@ -506,11 +637,11 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
506
637
|
"composed": true,
|
|
507
638
|
"docs": {
|
|
508
639
|
"tags": [],
|
|
509
|
-
"text": "Emitted when the user
|
|
640
|
+
"text": "Emitted when the user changes the selection. Detail contains the new value:\na `string` in single-select mode (`multiple` false/unset \u2014 same shape as before), or the\nfull updated `string[]` of selected values in multiselect mode (`multiple` true)."
|
|
510
641
|
},
|
|
511
642
|
"complexType": {
|
|
512
|
-
"original": "string",
|
|
513
|
-
"resolved": "string",
|
|
643
|
+
"original": "string | string[]",
|
|
644
|
+
"resolved": "string | string[]",
|
|
514
645
|
"references": {}
|
|
515
646
|
}
|
|
516
647
|
}];
|
|
@@ -609,6 +740,9 @@ export class LmvzSelect extends ReactiveControllerHost {
|
|
|
609
740
|
return [{
|
|
610
741
|
"propName": "value",
|
|
611
742
|
"methodName": "handleValueChange"
|
|
743
|
+
}, {
|
|
744
|
+
"propName": "values",
|
|
745
|
+
"methodName": "handleValuesChange"
|
|
612
746
|
}, {
|
|
613
747
|
"propName": "required",
|
|
614
748
|
"methodName": "handleRequiredChange"
|
|
@@ -29,6 +29,17 @@ hr {
|
|
|
29
29
|
border-top: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-border-subtle, #f0f0f0);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
fieldset {
|
|
33
|
+
border: none;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
legend {
|
|
39
|
+
padding: 0;
|
|
40
|
+
display: block;
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
}
|
|
33
44
|
:host {
|
|
34
45
|
display: inline-block;
|
|
@@ -29,6 +29,17 @@ hr {
|
|
|
29
29
|
border-top: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-border-subtle, #f0f0f0);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
fieldset {
|
|
33
|
+
border: none;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
legend {
|
|
39
|
+
padding: 0;
|
|
40
|
+
display: block;
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
}
|
|
33
44
|
:host {
|
|
34
45
|
display: inline-block;
|
package/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-
|
|
1
|
+
export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-DbBJxuBm.js";export{A as ARIA_VALIDATION_RUNTIME_CHANGED_EVENT,d as disableAriaValidation,e as enableAriaValidation,i as isAriaValidationEnabled,q as queueValidation,u as useVerboseLogging}from"./p-BDonpCG8.js";export{g as chipSizes,f as chipTypes,d as iconSizes,e as iconWeights,b as inputSizes,i as inputTypes,l as linkTypes,m as messageTypes,p as popoverPlacements,n as popoverSizes,s as scaleValues,c as selectSizes,a as sizes,k as snackbarDismissReasons,j as snackbarPriorities,h as snackbarStatuses,t as textSizes,v as variants}from"./p-0ctLESas.js";export{g as getRegisteredIconProvider,r as registerIconProvider,t as typedIconFromSet}from"./p-CgGqXTxQ.js";export{LmvzAction,defineCustomElement as defineCustomElementLmvzAction}from"./lmvz-action.js";export{LmvzActionList,defineCustomElement as defineCustomElementLmvzActionList}from"./lmvz-action-list.js";export{LmvzButton,defineCustomElement as defineCustomElementLmvzButton}from"./lmvz-button.js";export{LmvzButtonGroup,defineCustomElement as defineCustomElementLmvzButtonGroup}from"./lmvz-button-group.js";export{LmvzCard,defineCustomElement as defineCustomElementLmvzCard}from"./lmvz-card.js";export{LmvzCheckbox,defineCustomElement as defineCustomElementLmvzCheckbox}from"./lmvz-checkbox.js";export{LmvzChip,defineCustomElement as defineCustomElementLmvzChip}from"./lmvz-chip.js";export{LmvzDatepicker,defineCustomElement as defineCustomElementLmvzDatepicker}from"./lmvz-datepicker.js";export{LmvzHeader,defineCustomElement as defineCustomElementLmvzHeader}from"./lmvz-header.js";export{LmvzIcon,defineCustomElement as defineCustomElementLmvzIcon}from"./lmvz-icon.js";export{LmvzInput,defineCustomElement as defineCustomElementLmvzInput}from"./lmvz-input.js";export{LmvzLink,defineCustomElement as defineCustomElementLmvzLink}from"./lmvz-link.js";export{LmvzMenuitem,defineCustomElement as defineCustomElementLmvzMenuitem}from"./lmvz-menuitem.js";export{LmvzMessage,defineCustomElement as defineCustomElementLmvzMessage}from"./lmvz-message.js";export{LmvzModal,defineCustomElement as defineCustomElementLmvzModal}from"./lmvz-modal.js";export{LmvzPopover,defineCustomElement as defineCustomElementLmvzPopover}from"./lmvz-popover.js";export{LmvzRadio,defineCustomElement as defineCustomElementLmvzRadio}from"./lmvz-radio.js";export{LmvzSelect,defineCustomElement as defineCustomElementLmvzSelect}from"./lmvz-select.js";export{LmvzSnackbar,defineCustomElement as defineCustomElementLmvzSnackbar}from"./lmvz-snackbar.js";export{LmvzSpinner,defineCustomElement as defineCustomElementLmvzSpinner}from"./lmvz-spinner.js";export{LmvzTab,defineCustomElement as defineCustomElementLmvzTab}from"./lmvz-tab.js";export{LmvzTabs,defineCustomElement as defineCustomElementLmvzTabs}from"./lmvz-tabs.js";export{LmvzToggle,defineCustomElement as defineCustomElementLmvzToggle}from"./lmvz-toggle.js";const o={low:0,normal:1,high:2},z={success:5e3,warning:5e3,error:8e3};let C=0;function E(){return C+=1,"snackbar-"+C}class L{hostEl=void 0;active=void 0;getHost(){return void 0===this.hostEl||this.hostEl.isConnected||(this.hostEl=void 0),void 0===this.hostEl&&(this.hostEl=function(){if("undefined"==typeof document)return;const e=document.querySelector("[data-snackbar-host]");if(e)return e;const s=document.createElement("lmvz-snackbar");return s.setAttribute("data-snackbar-host",""),document.body.appendChild(s),s}()),this.hostEl}clearTimer(e){void 0!==e.timerId&&(clearTimeout(e.timerId),e.timerId=void 0)}scheduleTimer(e,s){s<=0||(e.timerStartedAt=Date.now(),e.timerId=setTimeout((()=>{void 0!==this.active&&this.active.id===e.id&&this.dismissActive(e,"timeout")}),s))}dismissActive(e,s){this.clearTimer(e);const t=e.hostEl;t.removeEventListener("pointerenter",e.onPointerEnter),t.removeEventListener("pointerleave",e.onPointerLeave),t.removeEventListener("focusin",e.onFocusIn),t.removeEventListener("focusout",e.onFocusOut),e.onActionListener&&t.removeEventListener("lmvzAction",e.onActionListener),t.hide?.(),this.active?.id===e.id&&(this.active=void 0),"action"!==s&&t.dispatchEvent(new CustomEvent("lmvzClose",{detail:{reason:s},bubbles:!0,composed:!0})),e.resolve({reason:s})}pauseTimer(e){if(e.pauseCount+=1,e.pauseCount>1||void 0===e.timerId)return;const s=void 0!==e.timerStartedAt?Date.now()-e.timerStartedAt:0;e.remaining=Math.max(0,e.remaining-s),e.timerStartedAt=void 0,this.clearTimer(e)}resumeTimer(e){e.pauseCount>0&&(e.pauseCount-=1),e.pauseCount>0||e.remaining>0&&this.scheduleTimer(e,e.remaining)}applyToHost(e,s){e.setAttribute("status",s.status??"success"),void 0!==s.actionLabel?e.setAttribute("action-label",s.actionLabel):e.removeAttribute("action-label")}open(e){const s=o[e.priority??"normal"];if(void 0!==this.active&&s<this.active.priority){let e;const s=new Promise((s=>{e=s}));return e({reason:"swallowed"}),{id:E(),closed:s,dismiss(){}}}void 0!==this.active&&this.dismissActive(this.active,"overridden");const t=this.getHost();if(void 0===t){const e=E();let s;const t=new Promise((e=>{s=e}));return s({reason:"swallowed"}),{id:e,closed:t,dismiss(){}}}const m=E(),i=0===e.duration?0:e.duration??z[e.status??"success"];let n;const a=new Promise((e=>{n=e})),r={id:m,priority:s,resolve:n,timerId:void 0,remaining:i,timerStartedAt:void 0,pauseCount:0,hostEl:t,onPointerEnter:()=>this.pauseTimer(r),onPointerLeave:()=>this.resumeTimer(r),onFocusIn:()=>this.pauseTimer(r),onFocusOut:()=>this.resumeTimer(r)};this.active=r,t.addEventListener("pointerenter",r.onPointerEnter),t.addEventListener("pointerleave",r.onPointerLeave),t.addEventListener("focusin",r.onFocusIn),t.addEventListener("focusout",r.onFocusOut),this.applyToHost(t,e);const l=()=>{void 0!==this.active&&this.active.id===m&&(e.onAction?.(),this.dismissActive(r,"action"))};return r.onActionListener=l,t.addEventListener("lmvzAction",l,{once:!0}),t.show?.(),queueMicrotask((()=>t.setAttribute("message",e.message))),i>0&&this.scheduleTimer(r,i),{id:m,closed:a,dismiss:()=>{this.active?.id===m&&this.dismissActive(r,"manual")}}}dismiss(e){this.active&&(e&&this.active.id!==e||this.dismissActive(this.active,"manual"))}}export{L as SnackbarController}
|