@luzmo/lucero 0.0.18 → 0.0.19
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/components/action-menu/index.cjs +1 -1
- package/components/action-menu/index.js +1 -1
- package/components/index.cjs +1 -1
- package/components/index.js +107 -105
- package/components/multi-picker/index.cjs +127 -0
- package/components/multi-picker/index.d.ts +7 -0
- package/components/multi-picker/index.js +502 -0
- package/components/multi-picker/multi-picker.d.ts +158 -0
- package/components/picker/index.cjs +1 -1
- package/components/picker/index.js +2 -2
- package/components/picker-dwg8oHVQ.cjs +123 -0
- package/components/picker-h9eY75xS.js +460 -0
- package/components/{picker-BxEG2NdV.js → strategies-CzfvQU_H.js} +75 -511
- package/components/strategies-D_cIzAJE.cjs +18 -0
- package/custom-elements.json +1 -1
- package/index.d.ts +1 -0
- package/package.json +6 -1
- package/components/picker-DROquiIZ.cjs +0 -123
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
/*! * Lucero - The design system for Luzmo.
|
|
2
|
+
*
|
|
3
|
+
* Copyright © 2025 Luzmo
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
|
|
6
|
+
* This license allows users with a current active Luzmo account to use Lucero.
|
|
7
|
+
* This license terminates automatically if a user no longer has an active Luzmo account.
|
|
8
|
+
* Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
|
|
9
|
+
*
|
|
10
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
* SOFTWARE.
|
|
17
|
+
* */
|
|
18
|
+
import { x as u, E as c, B as S, r as $, n as a } from "../base-CawdqE7p.js";
|
|
19
|
+
import { r as m } from "../state-CYxk12SV.js";
|
|
20
|
+
import { e as f } from "../query-D_KR_GUc.js";
|
|
21
|
+
import { e as M } from "../class-map-CJko4aXp.js";
|
|
22
|
+
import { o as p } from "../if-defined-BSAr_4u4.js";
|
|
23
|
+
import { o as I } from "../style-map-Ct2LiEds.js";
|
|
24
|
+
import { F as C } from "../focusable-cj2QhwDT.js";
|
|
25
|
+
import { D as E } from "../dependency-manger-CEXvGQUV.js";
|
|
26
|
+
import { M as L, I as k, s as v, p as A } from "../strategies-CzfvQU_H.js";
|
|
27
|
+
import { P as D } from "../pending-state-TJj1x9xn.js";
|
|
28
|
+
import { S as F } from "../sized-mixin-BxMraZLS.js";
|
|
29
|
+
import { luzmoIcon as g, luzmoAngleDown as _, luzmoAlert as B } from "@luzmo/icons";
|
|
30
|
+
import "../menu/index.js";
|
|
31
|
+
import "../overlay/index.js";
|
|
32
|
+
import "../progress-circle/index.js";
|
|
33
|
+
import "../tooltip/index.js";
|
|
34
|
+
const w = () => {
|
|
35
|
+
if (typeof document < "u" && !document.querySelector("style[data-luzmo-vars]")) {
|
|
36
|
+
const h = document.createElement("style");
|
|
37
|
+
h.setAttribute("data-luzmo-vars", ""), h.textContent = 'html{--luzmo-animation-duration: 0.15s;--luzmo-border-color: rgba(var(--luzmo-border-color-rgb), 0.1);--luzmo-border-color-hover: rgba(var(--luzmo-border-color-rgb), 0.15);--luzmo-border-color-down: rgba(var(--luzmo-border-color-rgb), 0.3);--luzmo-border-color-focus: rgba(var(--luzmo-border-color-rgb), 0.15);--luzmo-border-color-rgb: 0, 0, 0;--luzmo-border-color-full: rgb(180, 180, 180);--luzmo-border-color-full-hover: rgb(140, 140, 140);--luzmo-border-color-full-down: rgb(110, 110, 110);--luzmo-border-color-full-focus: rgb(140, 140, 140);--luzmo-border-color-disabled: #dddddd;--luzmo-border-radius: 6px;--luzmo-border-radius-s: 4px;--luzmo-border-radius-l: 8px;--luzmo-border-radius-xl: 12px;--luzmo-border-radius-full: 999rem;--luzmo-background-color: #ffffff;--luzmo-background-color-rgb: 255, 255, 255;--luzmo-background-color-disabled: #eeeeee;--luzmo-background-color-hover: #f0f0fc;--luzmo-background-color-down: #f1f1ff;--luzmo-background-color-focus: #f0f0fc;--luzmo-background-color-highlight: rgb(240, 240, 240);--luzmo-background-color-highlight-disabled: rgb(245, 245, 245);--luzmo-background-color-highlight-hover: rgb(225, 225, 225);--luzmo-background-color-highlight-down: rgb(215, 215, 215);--luzmo-background-color-highlight-focus: rgb(225, 225, 225);--luzmo-border-width: 1px;--luzmo-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;--luzmo-font-size-xs: 10px;--luzmo-font-size-s: 12px;--luzmo-font-size-m: 14px;--luzmo-font-size: 14px;--luzmo-font-size-l: 16px;--luzmo-font-size-xl: 18px;--luzmo-font-size-xxl: 20px;--luzmo-font-style: normal;--luzmo-line-height: normal;--luzmo-font-weight: 400;--luzmo-font-weight-semibold: 500;--luzmo-font-weight-bold: 600;--luzmo-font-color: #333;--luzmo-font-color-hard: #000;--luzmo-font-color-disabled: var(--luzmo-disabled-color);--luzmo-font-color-extra-dimmed: #888;--luzmo-font-color-hover: #333;--luzmo-font-color-down: #111;--luzmo-font-color-focus: #333;--luzmo-primary: #4434ff;--luzmo-primary-hover: #4234e4;--luzmo-primary-down: #392cc7;--luzmo-primary-focus: #4234e4;--luzmo-primary-inverse-color: #ffffff;--luzmo-primary-rgb: 68, 52, 255;--luzmo-secondary: #ff00ff;--luzmo-secondary-hover: #e309e3;--luzmo-secondary-down: #c711c7;--luzmo-secondary-focus: #e309e3;--luzmo-secondary-inverse-color: #ffffff;--luzmo-secondary-rgb: 255, 0, 255;--luzmo-negative-color: #ca221c;--luzmo-negative-color-hover: #b3241f;--luzmo-negative-color-down: #9f231f;--luzmo-negative-color-focus: #b3241f;--luzmo-negative-color-rgb: 202, 34, 28;--luzmo-positive-color: rgb(20, 150, 101);--luzmo-positive-color-hover: rgb(17, 128, 86);--luzmo-positive-color-down: rgb(16, 105, 71);--luzmo-positive-color-focus: rgb(17, 128, 86);--luzmo-positive-color-rgb: 20, 150, 101;--luzmo-selected-color: rgb(110, 110, 110);--luzmo-selected-color-hover: rgb(70, 70, 70);--luzmo-selected-color-down: rgb(40, 40, 40);--luzmo-selected-color-focus: rgb(70, 70, 70);--luzmo-selected-color-hard: #1e1e1e;--luzmo-selected-color-hard-hover: rgb(0, 0, 0);--luzmo-selected-color-hard-down: rgb(0, 0, 0);--luzmo-selected-color-hard-focus: rgb(0, 0, 0);--luzmo-informative-color: #1a77e9;--luzmo-informative-color-rgb: 26, 119, 233;--luzmo-disabled-color: #aaaaaa;--luzmo-spacing-1: 2px;--luzmo-spacing-2: 4px;--luzmo-spacing-3: 8px;--luzmo-spacing-4: 12px;--luzmo-spacing-5: 16px;--luzmo-indicator-gap: 2px;--luzmo-indicator-width: 1px;--luzmo-indicator-color: var(--luzmo-primary);--luzmo-component-height-xxs: 20px;--luzmo-component-height-xs: 24px;--luzmo-component-height-s: 28px;--luzmo-component-height: 32px;--luzmo-component-height-l: 40px;--luzmo-component-height-xl: 48px;--luzmo-component-height-xxl: 64px;--luzmo-icon-size-xxs: 12px;--luzmo-icon-size-xs: 14px;--luzmo-icon-size-s: 16px;--luzmo-icon-size-m: 18px;--luzmo-icon-size-l: 20px;--luzmo-icon-size-xl: 22px;--luzmo-icon-size-xxl: 32px}', document.head.appendChild(h);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
w();
|
|
41
|
+
var O = Object.defineProperty, P = Object.getOwnPropertyDescriptor, l = (h, e, t, o) => {
|
|
42
|
+
for (var i = o > 1 ? void 0 : o ? P(e, t) : e, r = h.length - 1, n; r >= 0; r--)
|
|
43
|
+
(n = h[r]) && (i = (o ? n(e, t, i) : n(i)) || i);
|
|
44
|
+
return o && i && O(e, t, i), i;
|
|
45
|
+
};
|
|
46
|
+
const R = () => u`
|
|
47
|
+
<div class="disclosure-icon icon">
|
|
48
|
+
${g(_, { className: "indicator" })}
|
|
49
|
+
</div>
|
|
50
|
+
`, q = () => u`
|
|
51
|
+
<div class="icon-container validation-icon icon">
|
|
52
|
+
${g(B)}
|
|
53
|
+
</div>
|
|
54
|
+
`, x = "option-picker";
|
|
55
|
+
class s extends F(C, {
|
|
56
|
+
noDefaultSize: !0
|
|
57
|
+
}) {
|
|
58
|
+
/**
|
|
59
|
+
* Initializes the `PendingStateController` for the Picker component.
|
|
60
|
+
* The `PendingStateController` manages the pending state of the Picker.
|
|
61
|
+
*/
|
|
62
|
+
constructor() {
|
|
63
|
+
super(), this.disabled = !1, this.focused = !1, this.variant = "checkmarks", this.invalid = !1, this.pending = !1, this.pendingLabel = "Pending", this.multiItemLabel = "items selected", this.open = !1, this.readonly = !1, this.placement = "bottom-start", this.quiet = !1, this.value = "", this.values = [], this.selects = "multiple", this.dependencyManager = new E(this), this.isMobile = new L(this, k), this.listRole = "listbox", this.itemRole = "option", this.hasRenderedOverlay = !1, this._selfManageFocusElement = !1, this.deprecatedMenu = null, this.selectionPromise = Promise.resolve(), this.willManageSelection = !1, this.recentlyConnected = !1, this.enterKeydownOn = null, this.handleSlottableRequest = (e) => {
|
|
64
|
+
}, this.applyFocusElementLabel = (e, t) => {
|
|
65
|
+
this.appliedLabel = e, this.labelAlignment = t.sideAligned ? "inline" : void 0;
|
|
66
|
+
}, this.handleKeydown = (e) => {
|
|
67
|
+
this.focused = !0, !(e.code !== "ArrowDown" && e.code !== "ArrowUp") && (e.stopPropagation(), e.preventDefault(), this.toggle(!0));
|
|
68
|
+
}, this.renderAngleIcon = () => R(), this.renderAlertIcon = () => q(), this.handleEnterKeydown = (e) => {
|
|
69
|
+
if (e.code === "Enter") {
|
|
70
|
+
if (this.enterKeydownOn) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.enterKeydownOn = e.target, this.addEventListener(
|
|
75
|
+
"keyup",
|
|
76
|
+
(t) => {
|
|
77
|
+
t.code === "Enter" && (this.enterKeydownOn = null);
|
|
78
|
+
},
|
|
79
|
+
{ once: !0 }
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}, this.pendingStateController = new D(this);
|
|
83
|
+
}
|
|
84
|
+
get selectedItems() {
|
|
85
|
+
return this._selectedItems;
|
|
86
|
+
}
|
|
87
|
+
get buttonLabelContent() {
|
|
88
|
+
return this._buttonLabelContent || { icon: [], content: [] };
|
|
89
|
+
}
|
|
90
|
+
get selfManageFocusElement() {
|
|
91
|
+
return this._selfManageFocusElement;
|
|
92
|
+
}
|
|
93
|
+
get menuItems() {
|
|
94
|
+
return this.optionsMenu.childItems;
|
|
95
|
+
}
|
|
96
|
+
set selectedItems(e) {
|
|
97
|
+
var i, r, n;
|
|
98
|
+
const t = (i = e == null ? void 0 : e[0]) == null ? void 0 : i.querySelector('[slot="icon"]');
|
|
99
|
+
this.buttonLabelContent = ((r = e ?? []) == null ? void 0 : r.length) > 1 ? {
|
|
100
|
+
icon: null,
|
|
101
|
+
content: [
|
|
102
|
+
u`<span class="count">${e == null ? void 0 : e.length}</span>
|
|
103
|
+
<span class="label">${this.multiItemLabel}</span>`
|
|
104
|
+
]
|
|
105
|
+
} : (n = e == null ? void 0 : e[0]) == null ? void 0 : n.itemChildren;
|
|
106
|
+
const o = this.selectedItems;
|
|
107
|
+
this._selectedItems = e, this._selectedItemIcon = (t == null ? void 0 : t.icon) ?? void 0, this.requestUpdate("selectedItems", o);
|
|
108
|
+
}
|
|
109
|
+
get focusElement() {
|
|
110
|
+
return this.open ? this.optionsMenu : this.button;
|
|
111
|
+
}
|
|
112
|
+
forceFocusVisible() {
|
|
113
|
+
this.disabled || (this.focused = !0);
|
|
114
|
+
}
|
|
115
|
+
click() {
|
|
116
|
+
this.disabled || this.toggle();
|
|
117
|
+
}
|
|
118
|
+
handleButtonBlur() {
|
|
119
|
+
this.focused = !1;
|
|
120
|
+
}
|
|
121
|
+
focus(e) {
|
|
122
|
+
super.focus(e), !this.disabled && this.focusElement && (this.focused = this.hasVisibleFocusInTree());
|
|
123
|
+
}
|
|
124
|
+
handleHelperFocus() {
|
|
125
|
+
this.focused = !0, this.button.focus();
|
|
126
|
+
}
|
|
127
|
+
handleChange(e) {
|
|
128
|
+
this.strategy && (this.strategy.preventNextToggle = "no");
|
|
129
|
+
const t = e.target;
|
|
130
|
+
e.stopPropagation(), e.cancelable ? this.setValuesFromItems(t.selectedItems, e) : (this.open = !1, this.strategy && (this.strategy.open = !1));
|
|
131
|
+
}
|
|
132
|
+
handleButtonFocus(e) {
|
|
133
|
+
var t;
|
|
134
|
+
(t = this.strategy) == null || t.handleButtonFocus(e);
|
|
135
|
+
}
|
|
136
|
+
toggle(e) {
|
|
137
|
+
this.readonly || this.pending || (this.open = e === void 0 ? !this.open : e, this.strategy && (this.strategy.open = this.open), this._selfManageFocusElement = this.open);
|
|
138
|
+
}
|
|
139
|
+
close() {
|
|
140
|
+
this.readonly || this.strategy && (this.open = !1, this.strategy.open = !1);
|
|
141
|
+
}
|
|
142
|
+
bindEvents() {
|
|
143
|
+
var e;
|
|
144
|
+
(e = this.strategy) == null || e.abort(), this.strategy = this.isMobile.matches ? new v.mobile(this.button, this) : new v.desktop(this.button, this);
|
|
145
|
+
}
|
|
146
|
+
connectedCallback() {
|
|
147
|
+
super.connectedCallback(), this.recentlyConnected = this.hasUpdated;
|
|
148
|
+
}
|
|
149
|
+
disconnectedCallback() {
|
|
150
|
+
var e;
|
|
151
|
+
this.close(), (e = this.strategy) == null || e.releaseDescription(), super.disconnectedCallback();
|
|
152
|
+
}
|
|
153
|
+
async setValuesFromItems(e, t) {
|
|
154
|
+
this.selects === "single" && (this.open = !1, this.strategy && (this.strategy.open = !1));
|
|
155
|
+
const o = this.selectedItems, i = this.values;
|
|
156
|
+
if (this.selectedItems = e, this.values = e.map((n) => n.value), await this.updateComplete, !this.dispatchEvent(
|
|
157
|
+
new CustomEvent("change", {
|
|
158
|
+
bubbles: !0,
|
|
159
|
+
// Allow it to be prevented.
|
|
160
|
+
cancelable: !0,
|
|
161
|
+
composed: !0,
|
|
162
|
+
detail: this.values
|
|
163
|
+
})
|
|
164
|
+
) && this.selects) {
|
|
165
|
+
t && t.preventDefault(), this.selectedItems.forEach((n) => {
|
|
166
|
+
this.setMenuItemSelected(n, !1);
|
|
167
|
+
}), o && o.forEach((n) => {
|
|
168
|
+
this.setMenuItemSelected(n, !0);
|
|
169
|
+
}), this.selectedItems = o, this.values = i, this.open = !0, this.strategy && (this.strategy.open = !0);
|
|
170
|
+
return;
|
|
171
|
+
} else if (!this.selects) {
|
|
172
|
+
this.selectedItems = o, this.values = i;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
o == null || o.forEach((n) => {
|
|
176
|
+
this.setMenuItemSelected(n, !1);
|
|
177
|
+
}), e.forEach((n) => {
|
|
178
|
+
this.setMenuItemSelected(n, !!this.selects);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
setMenuItemSelected(e, t) {
|
|
182
|
+
this.selects != null && (e.selected = t);
|
|
183
|
+
}
|
|
184
|
+
get containerStyles() {
|
|
185
|
+
return this.isMobile.matches ? {
|
|
186
|
+
"--swc-menu-width": "100%"
|
|
187
|
+
} : {};
|
|
188
|
+
}
|
|
189
|
+
set buttonLabelContent(e) {
|
|
190
|
+
if (e === this.buttonLabelContent)
|
|
191
|
+
return;
|
|
192
|
+
const t = this.buttonLabelContent;
|
|
193
|
+
this._buttonLabelContent = e, this.requestUpdate("buttonLabelContent", t);
|
|
194
|
+
}
|
|
195
|
+
handleTooltipSlotchange(e) {
|
|
196
|
+
this.tooltipEl = e.target.assignedElements()[0];
|
|
197
|
+
}
|
|
198
|
+
renderLabelContent(e) {
|
|
199
|
+
var t, o;
|
|
200
|
+
return (t = this.values) != null && t.length && ((o = this.selectedItems) != null && o.length) ? e : u`
|
|
201
|
+
<slot name="label" id="label">
|
|
202
|
+
<span aria-hidden=${p(this.appliedLabel ? void 0 : "true")}>
|
|
203
|
+
${this.label}
|
|
204
|
+
</span>
|
|
205
|
+
</slot>
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
get buttonContent() {
|
|
209
|
+
var i, r, n, d, b, y, z;
|
|
210
|
+
const e = {
|
|
211
|
+
"visually-hidden": this.icons === "only" && ((i = this.values) == null ? void 0 : i.length) > 0,
|
|
212
|
+
placeholder: !((r = this.values) != null && r.length),
|
|
213
|
+
label: !0
|
|
214
|
+
}, t = this.appliedLabel || this.label, o = u` <div
|
|
215
|
+
id="icon"
|
|
216
|
+
?hidden=${this.icons === "none" || ((n = this.values) == null ? void 0 : n.length) > 1}
|
|
217
|
+
>
|
|
218
|
+
${this._selectedItemIcon ? g(this._selectedItemIcon) : c}
|
|
219
|
+
</div>`;
|
|
220
|
+
return [
|
|
221
|
+
u`
|
|
222
|
+
${this._selectedItemIcon ? o : c}
|
|
223
|
+
<div
|
|
224
|
+
id=${p(
|
|
225
|
+
(d = this.values) != null && d.length && ((b = this.selectedItems) != null && b.length) ? "label" : void 0
|
|
226
|
+
)}
|
|
227
|
+
class=${M(e)}
|
|
228
|
+
>
|
|
229
|
+
${this.renderLabelContent(this.buttonLabelContent.content)}
|
|
230
|
+
</div>
|
|
231
|
+
${(y = this.values) != null && y.length && ((z = this.selectedItems) != null && z.length) ? u`
|
|
232
|
+
<div
|
|
233
|
+
aria-hidden="true"
|
|
234
|
+
class="visually-hidden"
|
|
235
|
+
id="applied-label"
|
|
236
|
+
>
|
|
237
|
+
${t}
|
|
238
|
+
<slot name="label"></slot>
|
|
239
|
+
</div>
|
|
240
|
+
` : u` <span hidden id="applied-label">${t}</span> `}
|
|
241
|
+
${this.invalid && !this.pending ? u` ${this.renderAlertIcon()} ` : c}
|
|
242
|
+
${this.pendingStateController.renderPendingState()}
|
|
243
|
+
${this.readonly ? c : this.renderAngleIcon()}
|
|
244
|
+
<slot
|
|
245
|
+
aria-hidden="true"
|
|
246
|
+
name="tooltip"
|
|
247
|
+
id="tooltip"
|
|
248
|
+
@slotchange=${this.handleTooltipSlotchange}
|
|
249
|
+
></slot>
|
|
250
|
+
`
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
renderOverlay(e) {
|
|
254
|
+
var o, i, r;
|
|
255
|
+
if (((o = this.strategy) == null ? void 0 : o.overlay) === void 0)
|
|
256
|
+
return e;
|
|
257
|
+
const t = this.renderContainer(e);
|
|
258
|
+
return S(t, (i = this.strategy) == null ? void 0 : i.overlay, {
|
|
259
|
+
host: this
|
|
260
|
+
}), (r = this.strategy) == null ? void 0 : r.overlay;
|
|
261
|
+
}
|
|
262
|
+
get renderDescriptionSlot() {
|
|
263
|
+
return u`
|
|
264
|
+
<div id=${x}>
|
|
265
|
+
<slot name="description"></slot>
|
|
266
|
+
</div>
|
|
267
|
+
`;
|
|
268
|
+
}
|
|
269
|
+
// a helper to throw focus to the button is needed because Safari
|
|
270
|
+
// won't include buttons in the tab order even with tabindex="0"
|
|
271
|
+
render() {
|
|
272
|
+
return this.tooltipEl && (this.tooltipEl.disabled = this.open), u`
|
|
273
|
+
<span
|
|
274
|
+
id="focus-helper"
|
|
275
|
+
tabindex=${this.focused || this.open ? "-1" : "0"}
|
|
276
|
+
@focus=${this.handleHelperFocus}
|
|
277
|
+
aria-describedby=${x}
|
|
278
|
+
></span>
|
|
279
|
+
<button
|
|
280
|
+
aria-controls=${p(this.open ? "menu" : void 0)}
|
|
281
|
+
aria-describedby="tooltip"
|
|
282
|
+
aria-expanded=${this.open ? "true" : "false"}
|
|
283
|
+
aria-haspopup="true"
|
|
284
|
+
aria-labelledby="loader icon label applied-label"
|
|
285
|
+
id="button"
|
|
286
|
+
class=${p(
|
|
287
|
+
this.labelAlignment ? `label-${this.labelAlignment}` : void 0
|
|
288
|
+
)}
|
|
289
|
+
@blur=${this.handleButtonBlur}
|
|
290
|
+
@keydown=${{
|
|
291
|
+
handleEvent: this.handleEnterKeydown,
|
|
292
|
+
capture: !0
|
|
293
|
+
}}
|
|
294
|
+
?disabled=${this.disabled}
|
|
295
|
+
tabindex="-1"
|
|
296
|
+
>
|
|
297
|
+
${this.buttonContent}
|
|
298
|
+
</button>
|
|
299
|
+
${this.renderMenu} ${this.renderDescriptionSlot}
|
|
300
|
+
`;
|
|
301
|
+
}
|
|
302
|
+
update(e) {
|
|
303
|
+
var t, o;
|
|
304
|
+
e.has("disabled") && this.disabled && this.strategy && (this.open = !1, this.strategy.open = !1), e.has("pending") && this.pending && this.strategy && (this.open = !1, this.strategy.open = !1), e.has("values") && this.shouldScheduleManageSelection(), this.hasUpdated || (this.deprecatedMenu = this.querySelector(":scope > luzmo-menu"), (t = this.deprecatedMenu) == null || t.toggleAttribute("ignore", !0), (o = this.deprecatedMenu) == null || o.setAttribute("selects", "inherit")), super.update(e);
|
|
305
|
+
}
|
|
306
|
+
bindButtonKeydownListener() {
|
|
307
|
+
this.button.addEventListener("keydown", this.handleKeydown);
|
|
308
|
+
}
|
|
309
|
+
updated(e) {
|
|
310
|
+
super.updated(e), e.has("open") && (this.strategy.open = this.open);
|
|
311
|
+
}
|
|
312
|
+
firstUpdated(e) {
|
|
313
|
+
super.firstUpdated(e), this.bindButtonKeydownListener(), this.bindEvents();
|
|
314
|
+
}
|
|
315
|
+
get dismissHelper() {
|
|
316
|
+
return u`
|
|
317
|
+
<div class="visually-hidden">
|
|
318
|
+
<button
|
|
319
|
+
tabindex="-1"
|
|
320
|
+
aria-label="Dismiss"
|
|
321
|
+
@click=${this.close}
|
|
322
|
+
></button>
|
|
323
|
+
</div>
|
|
324
|
+
`;
|
|
325
|
+
}
|
|
326
|
+
renderContainer(e) {
|
|
327
|
+
const t = u`
|
|
328
|
+
${this.dismissHelper} ${e} ${this.dismissHelper}
|
|
329
|
+
`;
|
|
330
|
+
return this.dependencyManager.add("luzmo-popover"), import("../popover/index.js"), u`
|
|
331
|
+
<luzmo-popover
|
|
332
|
+
id="popover"
|
|
333
|
+
size=${this.size}
|
|
334
|
+
role="presentation"
|
|
335
|
+
style=${I(this.containerStyles)}
|
|
336
|
+
placement=${this.placement}
|
|
337
|
+
>
|
|
338
|
+
${t}
|
|
339
|
+
</luzmo-popover>
|
|
340
|
+
`;
|
|
341
|
+
}
|
|
342
|
+
get renderMenu() {
|
|
343
|
+
const e = u`
|
|
344
|
+
<luzmo-menu
|
|
345
|
+
aria-labelledby="applied-label"
|
|
346
|
+
@change=${this.handleChange}
|
|
347
|
+
id="menu"
|
|
348
|
+
@keydown=${{
|
|
349
|
+
handleEvent: this.handleEnterKeydown,
|
|
350
|
+
capture: !0
|
|
351
|
+
}}
|
|
352
|
+
@scroll=${this.onScroll}
|
|
353
|
+
role=${this.listRole}
|
|
354
|
+
.selects=${this.selects}
|
|
355
|
+
.selected=${this.values ?? []}
|
|
356
|
+
size=${this.size}
|
|
357
|
+
@luzmo-menu-item-added-or-updated=${this.shouldManageSelection}
|
|
358
|
+
>
|
|
359
|
+
<slot @slotchange=${this.shouldScheduleManageSelection}></slot>
|
|
360
|
+
</luzmo-menu>
|
|
361
|
+
`;
|
|
362
|
+
return this.hasRenderedOverlay = this.hasRenderedOverlay || this.focused || this.open || !!this.deprecatedMenu, this.hasRenderedOverlay ? (this.dependencyManager.loaded && this.dependencyManager.add("luzmo-overlay"), this.renderOverlay(e)) : e;
|
|
363
|
+
}
|
|
364
|
+
shouldScheduleManageSelection(e) {
|
|
365
|
+
!this.willManageSelection && (!e || e.target.getRootNode().host === this) && (this.willManageSelection = !0, requestAnimationFrame(() => {
|
|
366
|
+
requestAnimationFrame(() => {
|
|
367
|
+
this.manageSelection();
|
|
368
|
+
});
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
371
|
+
shouldManageSelection() {
|
|
372
|
+
this.willManageSelection || (this.willManageSelection = !0, this.manageSelection());
|
|
373
|
+
}
|
|
374
|
+
async manageSelection() {
|
|
375
|
+
if (this.selects == null)
|
|
376
|
+
return;
|
|
377
|
+
this.selectionPromise = new Promise(
|
|
378
|
+
(t) => this.selectionResolver = t
|
|
379
|
+
);
|
|
380
|
+
const e = [];
|
|
381
|
+
await this.optionsMenu.updateComplete, this.recentlyConnected && (await new Promise((t) => requestAnimationFrame(() => t(!0))), this.recentlyConnected = !1), this.menuItems.forEach((t) => {
|
|
382
|
+
this.values.includes(t.value) && !t.disabled ? e == null || e.push(t) : t.selected = !1;
|
|
383
|
+
}), e && (e.forEach((t) => {
|
|
384
|
+
t.selected = !!this.selects;
|
|
385
|
+
}), this.selectedItems = e), this.open && (await this.optionsMenu.updateComplete, this.optionsMenu.updateSelectedItemIndex()), this.selectionResolver(), this.willManageSelection = !1;
|
|
386
|
+
}
|
|
387
|
+
async getUpdateComplete() {
|
|
388
|
+
const e = await super.getUpdateComplete();
|
|
389
|
+
return await this.selectionPromise, e;
|
|
390
|
+
}
|
|
391
|
+
onScroll() {
|
|
392
|
+
this.dispatchEvent(
|
|
393
|
+
new Event("scroll", {
|
|
394
|
+
cancelable: !0,
|
|
395
|
+
composed: !0
|
|
396
|
+
})
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
l([
|
|
401
|
+
m()
|
|
402
|
+
], s.prototype, "appliedLabel", 2);
|
|
403
|
+
l([
|
|
404
|
+
f("#button")
|
|
405
|
+
], s.prototype, "button", 2);
|
|
406
|
+
l([
|
|
407
|
+
a({ type: Boolean, reflect: !0 })
|
|
408
|
+
], s.prototype, "disabled", 2);
|
|
409
|
+
l([
|
|
410
|
+
a({ type: Boolean, reflect: !0 })
|
|
411
|
+
], s.prototype, "focused", 2);
|
|
412
|
+
l([
|
|
413
|
+
a({ type: String, reflect: !0 })
|
|
414
|
+
], s.prototype, "icons", 2);
|
|
415
|
+
l([
|
|
416
|
+
a({ type: String, reflect: !0 })
|
|
417
|
+
], s.prototype, "variant", 2);
|
|
418
|
+
l([
|
|
419
|
+
a({ type: Boolean, reflect: !0 })
|
|
420
|
+
], s.prototype, "invalid", 2);
|
|
421
|
+
l([
|
|
422
|
+
a({ type: Boolean, reflect: !0 })
|
|
423
|
+
], s.prototype, "pending", 2);
|
|
424
|
+
l([
|
|
425
|
+
a({ type: String, attribute: "pending-label" })
|
|
426
|
+
], s.prototype, "pendingLabel", 2);
|
|
427
|
+
l([
|
|
428
|
+
a({ type: String, attribute: "multi-item-label", reflect: !0 })
|
|
429
|
+
], s.prototype, "multiItemLabel", 2);
|
|
430
|
+
l([
|
|
431
|
+
a()
|
|
432
|
+
], s.prototype, "label", 2);
|
|
433
|
+
l([
|
|
434
|
+
a({ type: Boolean, reflect: !0 })
|
|
435
|
+
], s.prototype, "open", 2);
|
|
436
|
+
l([
|
|
437
|
+
a({ type: Boolean, reflect: !0 })
|
|
438
|
+
], s.prototype, "readonly", 2);
|
|
439
|
+
l([
|
|
440
|
+
m()
|
|
441
|
+
], s.prototype, "labelAlignment", 2);
|
|
442
|
+
l([
|
|
443
|
+
f("luzmo-menu")
|
|
444
|
+
], s.prototype, "optionsMenu", 2);
|
|
445
|
+
l([
|
|
446
|
+
f("luzmo-overlay")
|
|
447
|
+
], s.prototype, "overlayElement", 2);
|
|
448
|
+
l([
|
|
449
|
+
a()
|
|
450
|
+
], s.prototype, "placement", 2);
|
|
451
|
+
l([
|
|
452
|
+
a({ type: Boolean, reflect: !0 })
|
|
453
|
+
], s.prototype, "quiet", 2);
|
|
454
|
+
l([
|
|
455
|
+
a({ type: String })
|
|
456
|
+
], s.prototype, "value", 2);
|
|
457
|
+
l([
|
|
458
|
+
a({ type: Array })
|
|
459
|
+
], s.prototype, "values", 2);
|
|
460
|
+
l([
|
|
461
|
+
a({ attribute: !1 })
|
|
462
|
+
], s.prototype, "selectedItems", 1);
|
|
463
|
+
l([
|
|
464
|
+
m()
|
|
465
|
+
], s.prototype, "buttonLabelContent", 1);
|
|
466
|
+
l([
|
|
467
|
+
a({ type: String, reflect: !0 })
|
|
468
|
+
], s.prototype, "selects", 2);
|
|
469
|
+
class K extends s {
|
|
470
|
+
constructor() {
|
|
471
|
+
super(...arguments), this.handleKeydown = (e) => {
|
|
472
|
+
var o, i;
|
|
473
|
+
const { code: t } = e;
|
|
474
|
+
if (this.focused = !0, !(!t.startsWith("Arrow") || this.readonly || this.pending)) {
|
|
475
|
+
if (t === "ArrowUp" || t === "ArrowDown") {
|
|
476
|
+
this.toggle(!0), e.preventDefault();
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (e.preventDefault(), this.selects === "single") {
|
|
480
|
+
const r = (o = this.selectedItems) != null && o.length ? this.menuItems.indexOf(this.selectedItems[0]) : -1, n = r < 0 || t === "ArrowRight" ? 1 : -1;
|
|
481
|
+
let d = r + n;
|
|
482
|
+
for (; this.menuItems[d] && this.menuItems[d].disabled; )
|
|
483
|
+
d += n;
|
|
484
|
+
if (!this.menuItems[d] || this.menuItems[d].disabled)
|
|
485
|
+
return;
|
|
486
|
+
(!((i = this.values) != null && i.length) || d !== r) && this.setValuesFromItems([this.menuItems[d]]);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
static get styles() {
|
|
492
|
+
return [$(A)];
|
|
493
|
+
}
|
|
494
|
+
get containerStyles() {
|
|
495
|
+
const e = super.containerStyles;
|
|
496
|
+
return this.quiet || (e["min-width"] = `${this.offsetWidth}px`), e;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
customElements.get("luzmo-multi-picker") || customElements.define("luzmo-multi-picker", K);
|
|
500
|
+
export {
|
|
501
|
+
K as LuzmoMultiPicker
|
|
502
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { CSSResultArray, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { StyleInfo } from 'lit/directives/style-map.js';
|
|
3
|
+
import { Focusable } from '../../utils/focusable';
|
|
4
|
+
import { DependencyManagerController } from '../../utils/reactive-controllers/dependency-manger';
|
|
5
|
+
import { MatchMediaController } from '../../utils/reactive-controllers/match-media';
|
|
6
|
+
import { PendingStateController } from '../../utils/reactive-controllers/pending-state';
|
|
7
|
+
import '../menu';
|
|
8
|
+
import { LuzmoMenu } from '../menu/menu';
|
|
9
|
+
import { LuzmoMenuItem, MenuItemChildren } from '../menu/menu-item';
|
|
10
|
+
import '../overlay';
|
|
11
|
+
import { LuzmoOverlay } from '../overlay/overlay';
|
|
12
|
+
import { Placement } from '../overlay/overlay-types';
|
|
13
|
+
import { SlottableRequestEvent } from '../overlay/slottable-request-event';
|
|
14
|
+
import '../progress-circle';
|
|
15
|
+
import '../tooltip';
|
|
16
|
+
import { LuzmoTooltip } from '../tooltip/tooltip';
|
|
17
|
+
import { DesktopController } from './../picker/desktop-controller';
|
|
18
|
+
import { MobileController } from './../picker/mobile-controller';
|
|
19
|
+
export declare const DESCRIPTION_ID = "option-picker";
|
|
20
|
+
declare const LuzmoMultiPickerBase_base: typeof Focusable & {
|
|
21
|
+
new (...args: any[]): import("../..").SizedElementInterface;
|
|
22
|
+
prototype: import("../..").SizedElementInterface;
|
|
23
|
+
};
|
|
24
|
+
export declare class LuzmoMultiPickerBase extends LuzmoMultiPickerBase_base {
|
|
25
|
+
appliedLabel?: string;
|
|
26
|
+
button: HTMLButtonElement;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the Picker is disabled.
|
|
29
|
+
*/
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
focused: boolean;
|
|
32
|
+
icons?: 'only' | 'none';
|
|
33
|
+
/**
|
|
34
|
+
* Type of dropdown
|
|
35
|
+
*/
|
|
36
|
+
variant?: 'checkmarks' | 'highlight';
|
|
37
|
+
/**
|
|
38
|
+
* Whether the value is invalid.
|
|
39
|
+
*/
|
|
40
|
+
invalid: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the items are currently loading.
|
|
43
|
+
*/
|
|
44
|
+
pending: boolean;
|
|
45
|
+
/** Defines a string value that labels the Picker while it is in pending state. */
|
|
46
|
+
pendingLabel: string;
|
|
47
|
+
/** Defines a string value that labels the Picker when multiple items are selected. */
|
|
48
|
+
multiItemLabel: string;
|
|
49
|
+
label?: string;
|
|
50
|
+
open: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Readonly value
|
|
53
|
+
*/
|
|
54
|
+
readonly: boolean;
|
|
55
|
+
labelAlignment?: 'inline';
|
|
56
|
+
optionsMenu: LuzmoMenu;
|
|
57
|
+
overlayElement: LuzmoOverlay;
|
|
58
|
+
/**
|
|
59
|
+
* @type {"top" | "top-start" | "top-end" | "right" | "right-start" | "right-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end"}
|
|
60
|
+
* @attr
|
|
61
|
+
*/
|
|
62
|
+
placement: Placement;
|
|
63
|
+
/**
|
|
64
|
+
* Display as a quiet picker
|
|
65
|
+
*/
|
|
66
|
+
quiet: boolean;
|
|
67
|
+
value: string;
|
|
68
|
+
values: string[];
|
|
69
|
+
get selectedItems(): LuzmoMenuItem[] | undefined;
|
|
70
|
+
protected get buttonLabelContent(): MenuItemChildren;
|
|
71
|
+
get selfManageFocusElement(): boolean;
|
|
72
|
+
protected get menuItems(): LuzmoMenuItem[];
|
|
73
|
+
selects: undefined | 'single' | 'multiple';
|
|
74
|
+
dependencyManager: DependencyManagerController;
|
|
75
|
+
isMobile: MatchMediaController;
|
|
76
|
+
strategy: DesktopController | MobileController;
|
|
77
|
+
pendingStateController: PendingStateController<this>;
|
|
78
|
+
private _selectedItemIcon?;
|
|
79
|
+
private _selectedItems?;
|
|
80
|
+
private _buttonLabelContent?;
|
|
81
|
+
protected listRole: 'listbox' | 'menu';
|
|
82
|
+
protected itemRole: string;
|
|
83
|
+
protected tooltipEl?: LuzmoTooltip;
|
|
84
|
+
protected hasRenderedOverlay: boolean;
|
|
85
|
+
private _selfManageFocusElement;
|
|
86
|
+
private deprecatedMenu;
|
|
87
|
+
private selectionPromise;
|
|
88
|
+
private selectionResolver;
|
|
89
|
+
private willManageSelection;
|
|
90
|
+
private recentlyConnected;
|
|
91
|
+
private enterKeydownOn;
|
|
92
|
+
/**
|
|
93
|
+
* Initializes the `PendingStateController` for the Picker component.
|
|
94
|
+
* The `PendingStateController` manages the pending state of the Picker.
|
|
95
|
+
*/
|
|
96
|
+
constructor();
|
|
97
|
+
set selectedItems(selectedItems: LuzmoMenuItem[] | undefined);
|
|
98
|
+
get focusElement(): HTMLElement;
|
|
99
|
+
forceFocusVisible(): void;
|
|
100
|
+
click(): void;
|
|
101
|
+
handleButtonBlur(): void;
|
|
102
|
+
focus(options?: FocusOptions): void;
|
|
103
|
+
handleHelperFocus(): void;
|
|
104
|
+
handleChange(event: Event): void;
|
|
105
|
+
handleButtonFocus(event: FocusEvent): void;
|
|
106
|
+
toggle(target?: boolean): void;
|
|
107
|
+
close(): void;
|
|
108
|
+
handleSlottableRequest: (_event: SlottableRequestEvent) => void;
|
|
109
|
+
bindEvents(): void;
|
|
110
|
+
connectedCallback(): void;
|
|
111
|
+
disconnectedCallback(): void;
|
|
112
|
+
applyFocusElementLabel: (value: string, labelElement: any) => void;
|
|
113
|
+
protected handleKeydown: (event: KeyboardEvent) => void;
|
|
114
|
+
protected setValuesFromItems(items: LuzmoMenuItem[], menuChangeEvent?: Event): Promise<void>;
|
|
115
|
+
protected setMenuItemSelected(item: LuzmoMenuItem, value: boolean): void;
|
|
116
|
+
protected get containerStyles(): StyleInfo;
|
|
117
|
+
protected set buttonLabelContent(buttonLabelContent: any);
|
|
118
|
+
protected handleTooltipSlotchange(event: Event & {
|
|
119
|
+
target: HTMLSlotElement;
|
|
120
|
+
}): void;
|
|
121
|
+
protected renderLabelContent(content: Node[]): TemplateResult | Node[];
|
|
122
|
+
protected renderAngleIcon: () => TemplateResult;
|
|
123
|
+
protected renderAlertIcon: () => TemplateResult;
|
|
124
|
+
protected get buttonContent(): TemplateResult[];
|
|
125
|
+
protected renderOverlay(menu: TemplateResult): TemplateResult;
|
|
126
|
+
protected get renderDescriptionSlot(): TemplateResult;
|
|
127
|
+
protected render(): TemplateResult;
|
|
128
|
+
protected update(changes: PropertyValues<this>): void;
|
|
129
|
+
protected bindButtonKeydownListener(): void;
|
|
130
|
+
protected updated(changes: PropertyValues<this>): void;
|
|
131
|
+
protected firstUpdated(changes: PropertyValues<this>): void;
|
|
132
|
+
protected get dismissHelper(): TemplateResult;
|
|
133
|
+
protected renderContainer(menu: TemplateResult): TemplateResult;
|
|
134
|
+
protected get renderMenu(): TemplateResult;
|
|
135
|
+
protected shouldScheduleManageSelection(event?: Event): void;
|
|
136
|
+
protected shouldManageSelection(): void;
|
|
137
|
+
protected manageSelection(): Promise<void>;
|
|
138
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
139
|
+
protected handleEnterKeydown: (event: KeyboardEvent) => void;
|
|
140
|
+
private onScroll;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @element luzmo-multi-picker
|
|
144
|
+
*
|
|
145
|
+
* @slot label - The placeholder content for the Picker
|
|
146
|
+
* @slot description - The description content for the Picker
|
|
147
|
+
* @slot tooltip - Tooltip to to be applied to the the Picker Button
|
|
148
|
+
* @slot - menu items to be listed in the Picker
|
|
149
|
+
* @fires change - Announces that the `value` of the element has changed
|
|
150
|
+
* @fires luzmo-opened - Announces that the overlay has been opened
|
|
151
|
+
* @fires luzmo-closed - Announces that the overlay has been closed
|
|
152
|
+
*/
|
|
153
|
+
export declare class LuzmoMultiPicker extends LuzmoMultiPickerBase {
|
|
154
|
+
static get styles(): CSSResultArray;
|
|
155
|
+
protected get containerStyles(): StyleInfo;
|
|
156
|
+
protected handleKeydown: (event: KeyboardEvent) => void;
|
|
157
|
+
}
|
|
158
|
+
export {};
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
16
|
* SOFTWARE.
|
|
17
17
|
* */
|
|
18
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../picker-
|
|
18
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../picker-dwg8oHVQ.cjs");customElements.get("luzmo-picker")||customElements.define("luzmo-picker",e.LuzmoPicker);exports.DESCRIPTION_ID=e.DESCRIPTION_ID;exports.LuzmoPicker=e.LuzmoPicker;exports.LuzmoPickerBase=e.LuzmoPickerBase;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
16
|
* SOFTWARE.
|
|
17
17
|
* */
|
|
18
|
-
import { a as r } from "../picker-
|
|
19
|
-
import { D as c, L as z } from "../picker-
|
|
18
|
+
import { a as r } from "../picker-h9eY75xS.js";
|
|
19
|
+
import { D as c, L as z } from "../picker-h9eY75xS.js";
|
|
20
20
|
const l = () => {
|
|
21
21
|
if (typeof document < "u" && !document.querySelector("style[data-luzmo-vars]")) {
|
|
22
22
|
const o = document.createElement("style");
|