@krollins/blueprint 0.1.11 → 0.1.13
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/components/accordion.js +393 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.js +213 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.js +237 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.js +144 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.js +481 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button.js +192 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/card.js +223 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/checkbox.js +337 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/color-picker.js +1660 -0
- package/dist/components/color-picker.js.map +1 -0
- package/dist/components/combobox.js +595 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/date-picker.js +726 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/divider.js +214 -0
- package/dist/components/divider.js.map +1 -0
- package/dist/components/drawer.js +568 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown.js +377 -0
- package/dist/components/dropdown.js.map +1 -0
- package/dist/components/file-upload.js +669 -0
- package/dist/components/file-upload.js.map +1 -0
- package/dist/components/heading.js +161 -0
- package/dist/components/heading.js.map +1 -0
- package/dist/components/icon.js +599 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/input.js +363 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/link.js +178 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/menu.js +331 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/modal.js +317 -0
- package/dist/components/modal.js.map +1 -0
- package/dist/components/multi-select.js +642 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/notification.js +429 -0
- package/dist/components/notification.js.map +1 -0
- package/dist/components/number-input.js +556 -0
- package/dist/components/number-input.js.map +1 -0
- package/dist/components/pagination.js +320 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.js +597 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.js +219 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio.js +321 -0
- package/dist/components/radio.js.map +1 -0
- package/dist/components/select.js +498 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/skeleton.js +240 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.js +9 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/spinner.js +133 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stepper.js +812 -0
- package/dist/components/stepper.js.map +1 -0
- package/dist/components/switch.js +380 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +642 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.js +547 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/tag.js +291 -0
- package/dist/components/tag.js.map +1 -0
- package/dist/components/text.js +278 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/textarea.js +380 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/time-picker.js +457 -0
- package/dist/components/time-picker.js.map +1 -0
- package/dist/components/tooltip.js +239 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/tree.js +582 -0
- package/dist/components/tree.js.map +1 -0
- package/dist/index.js +93 -17799
- package/dist/index.js.map +1 -1
- package/dist/shared/boolean-converter-XDGfS9LC.js +12 -0
- package/dist/shared/boolean-converter-XDGfS9LC.js.map +1 -0
- package/dist/shared/debounce-BckY30Sf.js +23 -0
- package/dist/shared/debounce-BckY30Sf.js.map +1 -0
- package/dist/shared/memoize-DlOFy-92.js +16 -0
- package/dist/shared/memoize-DlOFy-92.js.map +1 -0
- package/dist/shared/slider-BNt5TITl.js +484 -0
- package/dist/shared/slider-BNt5TITl.js.map +1 -0
- package/package.json +49 -3
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import { css as h, LitElement as u, html as c, nothing as m } from "lit";
|
|
2
|
+
import { property as n, state as l, query as x, customElement as v } from "lit/decorators.js";
|
|
3
|
+
import { classMap as d } from "lit/directives/class-map.js";
|
|
4
|
+
import { repeat as f } from "lit/directives/repeat.js";
|
|
5
|
+
import { d as _ } from "../shared/debounce-BckY30Sf.js";
|
|
6
|
+
import { m as g } from "../shared/memoize-DlOFy-92.js";
|
|
7
|
+
const y = h`
|
|
8
|
+
/* Base styles */
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
font-family: var(--bp-font-family);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.combobox {
|
|
15
|
+
position: relative;
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.combobox__control {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
position: relative;
|
|
23
|
+
background-color: var(--bp-color-surface);
|
|
24
|
+
border: var(--bp-border-width) solid var(--bp-color-border);
|
|
25
|
+
border-radius: var(--bp-border-radius-md);
|
|
26
|
+
transition: border-color var(--bp-transition-fast);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.combobox__control:hover:not(.combobox--disabled .combobox__control) {
|
|
30
|
+
border-color: var(--bp-color-primary);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.combobox__control:focus-within {
|
|
34
|
+
outline: var(--bp-focus-width) solid var(--bp-color-focus);
|
|
35
|
+
outline-offset: var(--bp-focus-width);
|
|
36
|
+
border-color: var(--bp-color-focus);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.combobox__input {
|
|
40
|
+
flex: 1;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
padding: var(--bp-spacing-sm) var(--bp-spacing-md);
|
|
43
|
+
background: transparent;
|
|
44
|
+
border: none;
|
|
45
|
+
outline: none;
|
|
46
|
+
color: var(--bp-color-text);
|
|
47
|
+
font-family: var(--bp-font-family);
|
|
48
|
+
font-size: var(--bp-font-size-base);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.combobox__input::placeholder {
|
|
52
|
+
color: var(--bp-color-text-muted);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.combobox__input:disabled {
|
|
56
|
+
cursor: not-allowed;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.combobox__indicators {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: var(--bp-spacing-xs);
|
|
63
|
+
padding-right: var(--bp-spacing-sm);
|
|
64
|
+
flex-shrink: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.combobox__clear {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
width: var(--bp-spacing-6);
|
|
72
|
+
height: var(--bp-spacing-6);
|
|
73
|
+
padding: 0;
|
|
74
|
+
background: transparent;
|
|
75
|
+
border: none;
|
|
76
|
+
border-radius: var(--bp-border-radius-sm);
|
|
77
|
+
color: var(--bp-color-text-muted);
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
font-size: var(--bp-font-size-xl);
|
|
80
|
+
line-height: 1;
|
|
81
|
+
transition: all var(--bp-transition-fast);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.combobox__clear:hover {
|
|
85
|
+
color: var(--bp-color-primary);
|
|
86
|
+
background-color: color-mix(
|
|
87
|
+
in srgb,
|
|
88
|
+
var(--bp-color-primary) 8%,
|
|
89
|
+
transparent
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.combobox__clear:disabled {
|
|
94
|
+
cursor: not-allowed;
|
|
95
|
+
opacity: 0.5;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.combobox__dropdown-indicator {
|
|
99
|
+
color: var(--bp-color-text-muted);
|
|
100
|
+
font-size: var(--bp-font-size-xs);
|
|
101
|
+
transition: transform var(--bp-transition-fast);
|
|
102
|
+
user-select: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.combobox--open .combobox__dropdown-indicator {
|
|
106
|
+
transform: rotate(180deg);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.combobox__dropdown {
|
|
110
|
+
position: absolute;
|
|
111
|
+
top: calc(100% + var(--bp-spacing-xs));
|
|
112
|
+
left: 0;
|
|
113
|
+
right: 0;
|
|
114
|
+
z-index: var(--bp-z-dropdown);
|
|
115
|
+
background-color: var(--bp-color-surface);
|
|
116
|
+
border: var(--bp-border-width) solid var(--bp-color-border);
|
|
117
|
+
border-top: calc(var(--bp-border-width) * 2) solid var(--bp-color-primary);
|
|
118
|
+
border-radius: var(--bp-border-radius-md);
|
|
119
|
+
box-shadow: var(--bp-shadow-md);
|
|
120
|
+
max-height: calc(var(--bp-spacing-10) * 6);
|
|
121
|
+
overflow-y: auto;
|
|
122
|
+
opacity: 0;
|
|
123
|
+
visibility: hidden;
|
|
124
|
+
transform: translateY(calc(-1 * var(--bp-spacing-md)));
|
|
125
|
+
transition:
|
|
126
|
+
opacity var(--bp-transition-fast),
|
|
127
|
+
transform var(--bp-transition-fast),
|
|
128
|
+
visibility var(--bp-transition-fast);
|
|
129
|
+
contain: layout style paint;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.combobox--open .combobox__dropdown {
|
|
133
|
+
opacity: 1;
|
|
134
|
+
visibility: visible;
|
|
135
|
+
transform: translateY(0);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.combobox__options {
|
|
139
|
+
list-style: none;
|
|
140
|
+
margin: 0;
|
|
141
|
+
padding: var(--bp-spacing-2xs);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.combobox__option {
|
|
145
|
+
padding: var(--bp-spacing-sm) var(--bp-spacing-md);
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
border-radius: var(--bp-border-radius-md);
|
|
148
|
+
transition:
|
|
149
|
+
background-color var(--bp-transition-fast),
|
|
150
|
+
color var(--bp-transition-fast);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.combobox__option:hover {
|
|
154
|
+
background-color: color-mix(
|
|
155
|
+
in srgb,
|
|
156
|
+
var(--bp-color-primary) 8%,
|
|
157
|
+
transparent
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.combobox__option--focused {
|
|
162
|
+
background-color: color-mix(
|
|
163
|
+
in srgb,
|
|
164
|
+
var(--bp-color-primary) 8%,
|
|
165
|
+
transparent
|
|
166
|
+
);
|
|
167
|
+
outline: var(--bp-focus-width) solid var(--bp-color-primary);
|
|
168
|
+
outline-offset: calc(-1 * var(--bp-focus-width));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.combobox__option--selected {
|
|
172
|
+
background-color: color-mix(
|
|
173
|
+
in srgb,
|
|
174
|
+
var(--bp-color-primary) 8%,
|
|
175
|
+
transparent
|
|
176
|
+
);
|
|
177
|
+
color: var(--bp-color-primary);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.combobox__option--selected:hover,
|
|
181
|
+
.combobox__option--selected.combobox__option--focused {
|
|
182
|
+
background-color: color-mix(
|
|
183
|
+
in srgb,
|
|
184
|
+
var(--bp-color-primary) 12%,
|
|
185
|
+
transparent
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.combobox__option--empty {
|
|
190
|
+
color: var(--bp-color-text-muted);
|
|
191
|
+
cursor: default;
|
|
192
|
+
text-align: center;
|
|
193
|
+
padding: var(--bp-spacing-lg) var(--bp-spacing-md);
|
|
194
|
+
font-style: italic;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.combobox__option--empty:hover {
|
|
198
|
+
background-color: transparent;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/* Sizes */
|
|
202
|
+
.combobox--sm .combobox__input {
|
|
203
|
+
padding: var(--bp-spacing-2xs) var(--bp-spacing-xs);
|
|
204
|
+
font-size: var(--bp-font-size-sm);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.combobox--sm .combobox__indicators {
|
|
208
|
+
padding-right: var(--bp-spacing-xs);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.combobox--lg .combobox__input {
|
|
212
|
+
padding: var(--bp-spacing-md) var(--bp-spacing-lg);
|
|
213
|
+
font-size: var(--bp-font-size-lg);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.combobox--lg .combobox__indicators {
|
|
217
|
+
padding-right: var(--bp-spacing-md);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* Variants */
|
|
221
|
+
.combobox--default .combobox__control {
|
|
222
|
+
border-color: var(--bp-color-border);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.combobox--success .combobox__control {
|
|
226
|
+
border-color: var(--bp-color-success);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.combobox--error .combobox__control {
|
|
230
|
+
border-color: var(--bp-color-error);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.combobox--warning .combobox__control {
|
|
234
|
+
border-color: var(--bp-color-warning);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.combobox--info .combobox__control {
|
|
238
|
+
border-color: var(--bp-color-info);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.combobox--success
|
|
242
|
+
.combobox__control:hover:not(.combobox--disabled .combobox__control) {
|
|
243
|
+
border-color: var(--bp-color-success);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.combobox--error
|
|
247
|
+
.combobox__control:hover:not(.combobox--disabled .combobox__control) {
|
|
248
|
+
border-color: var(--bp-color-error);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.combobox--warning
|
|
252
|
+
.combobox__control:hover:not(.combobox--disabled .combobox__control) {
|
|
253
|
+
border-color: var(--bp-color-warning);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.combobox--info
|
|
257
|
+
.combobox__control:hover:not(.combobox--disabled .combobox__control) {
|
|
258
|
+
border-color: var(--bp-color-info);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* States */
|
|
262
|
+
.combobox--disabled .combobox__control {
|
|
263
|
+
background-color: var(--bp-color-surface-subdued);
|
|
264
|
+
cursor: not-allowed;
|
|
265
|
+
opacity: 0.6;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.combobox--disabled .combobox__input {
|
|
269
|
+
color: var(--bp-color-text-muted);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* Hide slot */
|
|
273
|
+
slot {
|
|
274
|
+
display: none;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* Hide hidden inputs */
|
|
278
|
+
input[type='hidden'] {
|
|
279
|
+
display: none;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* iOS zoom prevention: ensure 16px minimum on touch devices */
|
|
283
|
+
@media (max-width: 768px) {
|
|
284
|
+
.combobox--sm .combobox__input {
|
|
285
|
+
font-size: 16px;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
`;
|
|
289
|
+
var O = Object.defineProperty, w = Object.getOwnPropertyDescriptor, s = (o, t, e, r) => {
|
|
290
|
+
for (var a = r > 1 ? void 0 : r ? w(t, e) : t, b = o.length - 1, p; b >= 0; b--)
|
|
291
|
+
(p = o[b]) && (a = (r ? p(t, e, a) : p(a)) || a);
|
|
292
|
+
return r && a && O(t, e, a), a;
|
|
293
|
+
};
|
|
294
|
+
let i = class extends u {
|
|
295
|
+
constructor() {
|
|
296
|
+
super(), this.isOpen = !1, this.searchText = "", this.focusedIndex = -1, this.cachedFilteredOptions = [], this.cachedOptions = [], this.debouncedFilter = _(() => {
|
|
297
|
+
this.cachedFilteredOptions = this.filterOptions(
|
|
298
|
+
this.cachedOptions,
|
|
299
|
+
this.searchText
|
|
300
|
+
);
|
|
301
|
+
}, 150), this.filterOptions = g(
|
|
302
|
+
(o, t) => {
|
|
303
|
+
if (!t.trim())
|
|
304
|
+
return o;
|
|
305
|
+
const e = t.toLowerCase();
|
|
306
|
+
return o.filter(
|
|
307
|
+
(r) => r.label.toLowerCase().includes(e)
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
), this.handleDocumentClick = (o) => {
|
|
311
|
+
this.contains(o.target) || this.closeDropdown();
|
|
312
|
+
}, this.handleSlotChange = () => {
|
|
313
|
+
this.cachedOptions = this.getOptions(), this.cachedFilteredOptions = this.filterOptions(
|
|
314
|
+
this.cachedOptions,
|
|
315
|
+
this.searchText
|
|
316
|
+
);
|
|
317
|
+
}, this.handleInputFocus = () => {
|
|
318
|
+
this.disabled || (this.isOpen = !0, this.focusedIndex = -1);
|
|
319
|
+
}, this.handleInputClick = (o) => {
|
|
320
|
+
o.stopPropagation(), !this.disabled && (this.isOpen = !0);
|
|
321
|
+
}, this.handleInputChange = (o) => {
|
|
322
|
+
const t = o.target;
|
|
323
|
+
if (this.searchText = t.value, this.isOpen = !0, this.focusedIndex = -1, this.debouncedFilter(), this.allowCustomValue) {
|
|
324
|
+
const e = this.value;
|
|
325
|
+
this.value = this.searchText, this.dispatchEvent(
|
|
326
|
+
new CustomEvent("bp-change", {
|
|
327
|
+
detail: {
|
|
328
|
+
value: this.value,
|
|
329
|
+
previousValue: e
|
|
330
|
+
},
|
|
331
|
+
bubbles: !0,
|
|
332
|
+
composed: !0
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}, this.handleOptionClick = (o) => {
|
|
337
|
+
if (this.disabled) return;
|
|
338
|
+
const t = this.value;
|
|
339
|
+
this.value = o.value, this.searchText = o.label, this.isOpen = !1, this.focusedIndex = -1, this.debouncedFilter.cancel(), this.cachedFilteredOptions = this.filterOptions(
|
|
340
|
+
this.cachedOptions,
|
|
341
|
+
this.searchText
|
|
342
|
+
), this.dispatchEvent(
|
|
343
|
+
new CustomEvent("bp-change", {
|
|
344
|
+
detail: {
|
|
345
|
+
value: this.value,
|
|
346
|
+
label: o.label,
|
|
347
|
+
previousValue: t
|
|
348
|
+
},
|
|
349
|
+
bubbles: !0,
|
|
350
|
+
composed: !0
|
|
351
|
+
})
|
|
352
|
+
);
|
|
353
|
+
const e = this.shadowRoot?.querySelector('input[type="hidden"]');
|
|
354
|
+
e && (e.value = this.value), this.inputElement?.focus();
|
|
355
|
+
}, this.handleInputKeyDown = (o) => {
|
|
356
|
+
if (this.disabled) return;
|
|
357
|
+
const t = this.getFilteredOptions();
|
|
358
|
+
switch (o.key) {
|
|
359
|
+
case "ArrowDown":
|
|
360
|
+
o.preventDefault(), this.isOpen ? this.focusedIndex = Math.min(
|
|
361
|
+
this.focusedIndex + 1,
|
|
362
|
+
t.length - 1
|
|
363
|
+
) : (this.isOpen = !0, this.focusedIndex = 0);
|
|
364
|
+
break;
|
|
365
|
+
case "ArrowUp":
|
|
366
|
+
o.preventDefault(), this.isOpen ? this.focusedIndex = Math.max(this.focusedIndex - 1, 0) : (this.isOpen = !0, this.focusedIndex = t.length - 1);
|
|
367
|
+
break;
|
|
368
|
+
case "Enter":
|
|
369
|
+
if (o.preventDefault(), this.isOpen && this.focusedIndex >= 0) {
|
|
370
|
+
const e = t[this.focusedIndex];
|
|
371
|
+
e && this.handleOptionClick(e);
|
|
372
|
+
} else this.isOpen || (this.isOpen = !0);
|
|
373
|
+
break;
|
|
374
|
+
case "Escape":
|
|
375
|
+
o.preventDefault(), this.closeDropdown();
|
|
376
|
+
break;
|
|
377
|
+
case "Tab":
|
|
378
|
+
this.closeDropdown();
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}, this.handleClear = (o) => {
|
|
382
|
+
if (o.stopPropagation(), this.disabled) return;
|
|
383
|
+
const t = this.value;
|
|
384
|
+
this.value = "", this.searchText = "", this.debouncedFilter.cancel(), this.cachedFilteredOptions = this.filterOptions(
|
|
385
|
+
this.cachedOptions,
|
|
386
|
+
this.searchText
|
|
387
|
+
), this.dispatchEvent(
|
|
388
|
+
new CustomEvent("bp-change", {
|
|
389
|
+
detail: {
|
|
390
|
+
value: "",
|
|
391
|
+
previousValue: t
|
|
392
|
+
},
|
|
393
|
+
bubbles: !0,
|
|
394
|
+
composed: !0
|
|
395
|
+
})
|
|
396
|
+
), this.inputElement?.focus();
|
|
397
|
+
}, this.value = "", this.name = "", this.placeholder = "Search or select...", this.disabled = !1, this.required = !1, this.size = "md", this.variant = "default", this.allowCustomValue = !1;
|
|
398
|
+
}
|
|
399
|
+
connectedCallback() {
|
|
400
|
+
super.connectedCallback(), document.addEventListener("click", this.handleDocumentClick, {
|
|
401
|
+
passive: !0
|
|
402
|
+
}), this.updateComplete.then(() => {
|
|
403
|
+
this.cachedOptions = this.getOptions(), this.updateSearchText(), this.cachedFilteredOptions = this.filterOptions(
|
|
404
|
+
this.cachedOptions,
|
|
405
|
+
this.searchText
|
|
406
|
+
);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
disconnectedCallback() {
|
|
410
|
+
super.disconnectedCallback(), document.removeEventListener("click", this.handleDocumentClick, {
|
|
411
|
+
passive: !0
|
|
412
|
+
}), this.debouncedFilter.cancel();
|
|
413
|
+
}
|
|
414
|
+
updateSearchText() {
|
|
415
|
+
if (!this.value) {
|
|
416
|
+
this.searchText = "";
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const t = (this.cachedOptions.length > 0 ? this.cachedOptions : this.getOptions()).find((e) => e.value === this.value);
|
|
420
|
+
t && (this.searchText = t.label);
|
|
421
|
+
}
|
|
422
|
+
closeDropdown() {
|
|
423
|
+
this.isOpen = !1, this.focusedIndex = -1, this.debouncedFilter.cancel(), this.updateSearchText(), this.cachedFilteredOptions = this.filterOptions(
|
|
424
|
+
this.cachedOptions,
|
|
425
|
+
this.searchText
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
getOptions() {
|
|
429
|
+
return (this.shadowRoot?.querySelector("slot")?.assignedElements() || []).filter(
|
|
430
|
+
(r) => r.tagName === "OPTION"
|
|
431
|
+
).map((r) => ({
|
|
432
|
+
value: r.value || r.textContent || "",
|
|
433
|
+
label: r.textContent || ""
|
|
434
|
+
}));
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Returns the cached filtered options for rendering and keyboard navigation.
|
|
438
|
+
*/
|
|
439
|
+
getFilteredOptions() {
|
|
440
|
+
return this.cachedFilteredOptions;
|
|
441
|
+
}
|
|
442
|
+
renderDropdown() {
|
|
443
|
+
const o = this.getFilteredOptions();
|
|
444
|
+
return c`
|
|
445
|
+
<div class="combobox__dropdown" id="listbox" part="dropdown">
|
|
446
|
+
<ul class="combobox__options" role="listbox">
|
|
447
|
+
${o.length === 0 ? c`<li
|
|
448
|
+
class="combobox__option combobox__option--empty"
|
|
449
|
+
role="option"
|
|
450
|
+
>
|
|
451
|
+
No results found
|
|
452
|
+
</li>` : f(
|
|
453
|
+
o,
|
|
454
|
+
(t) => t.value,
|
|
455
|
+
(t, e) => {
|
|
456
|
+
const r = t.value === this.value, a = e === this.focusedIndex;
|
|
457
|
+
return c`
|
|
458
|
+
<li
|
|
459
|
+
class=${d({
|
|
460
|
+
combobox__option: !0,
|
|
461
|
+
"combobox__option--selected": r,
|
|
462
|
+
"combobox__option--focused": a
|
|
463
|
+
})}
|
|
464
|
+
role="option"
|
|
465
|
+
aria-selected=${r}
|
|
466
|
+
@click=${() => this.handleOptionClick(t)}
|
|
467
|
+
part="option ${r ? "option-selected" : ""}"
|
|
468
|
+
>
|
|
469
|
+
${t.label}
|
|
470
|
+
</li>
|
|
471
|
+
`;
|
|
472
|
+
}
|
|
473
|
+
)}
|
|
474
|
+
</ul>
|
|
475
|
+
</div>
|
|
476
|
+
`;
|
|
477
|
+
}
|
|
478
|
+
render() {
|
|
479
|
+
const o = !!(this.value || this.searchText);
|
|
480
|
+
return c`
|
|
481
|
+
<div
|
|
482
|
+
class=${d({
|
|
483
|
+
combobox: !0,
|
|
484
|
+
"combobox--open": this.isOpen,
|
|
485
|
+
"combobox--disabled": this.disabled,
|
|
486
|
+
[`combobox--${this.size}`]: !0,
|
|
487
|
+
[`combobox--${this.variant}`]: !0
|
|
488
|
+
})}
|
|
489
|
+
>
|
|
490
|
+
<div class="combobox__control" part="control">
|
|
491
|
+
<input
|
|
492
|
+
type="text"
|
|
493
|
+
class="combobox__input"
|
|
494
|
+
.value=${this.searchText}
|
|
495
|
+
placeholder=${this.placeholder}
|
|
496
|
+
?disabled=${this.disabled}
|
|
497
|
+
?required=${this.required}
|
|
498
|
+
@focus=${this.handleInputFocus}
|
|
499
|
+
@click=${this.handleInputClick}
|
|
500
|
+
@input=${this.handleInputChange}
|
|
501
|
+
@keydown=${this.handleInputKeyDown}
|
|
502
|
+
role="combobox"
|
|
503
|
+
aria-haspopup="listbox"
|
|
504
|
+
aria-expanded=${this.isOpen}
|
|
505
|
+
aria-autocomplete="list"
|
|
506
|
+
aria-controls="listbox"
|
|
507
|
+
aria-disabled=${this.disabled}
|
|
508
|
+
part="input"
|
|
509
|
+
/>
|
|
510
|
+
|
|
511
|
+
<div class="combobox__indicators">
|
|
512
|
+
${o ? c`
|
|
513
|
+
<button
|
|
514
|
+
type="button"
|
|
515
|
+
class="combobox__clear"
|
|
516
|
+
@click=${this.handleClear}
|
|
517
|
+
aria-label="Clear selection"
|
|
518
|
+
tabindex="-1"
|
|
519
|
+
?disabled=${this.disabled}
|
|
520
|
+
part="clear-button"
|
|
521
|
+
>
|
|
522
|
+
×
|
|
523
|
+
</button>
|
|
524
|
+
` : ""}
|
|
525
|
+
<span class="combobox__dropdown-indicator" part="indicator">
|
|
526
|
+
▼
|
|
527
|
+
</span>
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
${this.isOpen ? this.renderDropdown() : m}
|
|
532
|
+
|
|
533
|
+
<!-- Hidden slot for options -->
|
|
534
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
535
|
+
|
|
536
|
+
<!-- Hidden input for form submission -->
|
|
537
|
+
${this.name ? c`<input
|
|
538
|
+
type="hidden"
|
|
539
|
+
name="${this.name}"
|
|
540
|
+
.value=${this.value}
|
|
541
|
+
/>` : ""}
|
|
542
|
+
</div>
|
|
543
|
+
`;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
i.styles = [y];
|
|
547
|
+
s([
|
|
548
|
+
n({ type: String, reflect: !0 })
|
|
549
|
+
], i.prototype, "value", 2);
|
|
550
|
+
s([
|
|
551
|
+
n({ type: String })
|
|
552
|
+
], i.prototype, "name", 2);
|
|
553
|
+
s([
|
|
554
|
+
n({ type: String })
|
|
555
|
+
], i.prototype, "placeholder", 2);
|
|
556
|
+
s([
|
|
557
|
+
n({ type: Boolean, reflect: !0 })
|
|
558
|
+
], i.prototype, "disabled", 2);
|
|
559
|
+
s([
|
|
560
|
+
n({ type: Boolean, reflect: !0 })
|
|
561
|
+
], i.prototype, "required", 2);
|
|
562
|
+
s([
|
|
563
|
+
n({ type: String, reflect: !0 })
|
|
564
|
+
], i.prototype, "size", 2);
|
|
565
|
+
s([
|
|
566
|
+
n({ type: String, reflect: !0 })
|
|
567
|
+
], i.prototype, "variant", 2);
|
|
568
|
+
s([
|
|
569
|
+
n({ type: Boolean })
|
|
570
|
+
], i.prototype, "allowCustomValue", 2);
|
|
571
|
+
s([
|
|
572
|
+
l()
|
|
573
|
+
], i.prototype, "isOpen", 2);
|
|
574
|
+
s([
|
|
575
|
+
l()
|
|
576
|
+
], i.prototype, "searchText", 2);
|
|
577
|
+
s([
|
|
578
|
+
l()
|
|
579
|
+
], i.prototype, "focusedIndex", 2);
|
|
580
|
+
s([
|
|
581
|
+
l()
|
|
582
|
+
], i.prototype, "cachedFilteredOptions", 2);
|
|
583
|
+
s([
|
|
584
|
+
l()
|
|
585
|
+
], i.prototype, "cachedOptions", 2);
|
|
586
|
+
s([
|
|
587
|
+
x('input[type="text"]')
|
|
588
|
+
], i.prototype, "inputElement", 2);
|
|
589
|
+
i = s([
|
|
590
|
+
v("bp-combobox")
|
|
591
|
+
], i);
|
|
592
|
+
export {
|
|
593
|
+
i as BpCombobox
|
|
594
|
+
};
|
|
595
|
+
//# sourceMappingURL=combobox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox.js","sources":["../../source/components/combobox/combobox.style.ts","../../source/components/combobox/combobox.ts"],"sourcesContent":["import { css } from 'lit';\n\nexport const comboboxStyles = css`\n /* Base styles */\n :host {\n display: block;\n font-family: var(--bp-font-family);\n }\n\n .combobox {\n position: relative;\n width: 100%;\n }\n\n .combobox__control {\n display: flex;\n align-items: center;\n position: relative;\n background-color: var(--bp-color-surface);\n border: var(--bp-border-width) solid var(--bp-color-border);\n border-radius: var(--bp-border-radius-md);\n transition: border-color var(--bp-transition-fast);\n }\n\n .combobox__control:hover:not(.combobox--disabled .combobox__control) {\n border-color: var(--bp-color-primary);\n }\n\n .combobox__control:focus-within {\n outline: var(--bp-focus-width) solid var(--bp-color-focus);\n outline-offset: var(--bp-focus-width);\n border-color: var(--bp-color-focus);\n }\n\n .combobox__input {\n flex: 1;\n min-width: 0;\n padding: var(--bp-spacing-sm) var(--bp-spacing-md);\n background: transparent;\n border: none;\n outline: none;\n color: var(--bp-color-text);\n font-family: var(--bp-font-family);\n font-size: var(--bp-font-size-base);\n }\n\n .combobox__input::placeholder {\n color: var(--bp-color-text-muted);\n }\n\n .combobox__input:disabled {\n cursor: not-allowed;\n }\n\n .combobox__indicators {\n display: flex;\n align-items: center;\n gap: var(--bp-spacing-xs);\n padding-right: var(--bp-spacing-sm);\n flex-shrink: 0;\n }\n\n .combobox__clear {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--bp-spacing-6);\n height: var(--bp-spacing-6);\n padding: 0;\n background: transparent;\n border: none;\n border-radius: var(--bp-border-radius-sm);\n color: var(--bp-color-text-muted);\n cursor: pointer;\n font-size: var(--bp-font-size-xl);\n line-height: 1;\n transition: all var(--bp-transition-fast);\n }\n\n .combobox__clear:hover {\n color: var(--bp-color-primary);\n background-color: color-mix(\n in srgb,\n var(--bp-color-primary) 8%,\n transparent\n );\n }\n\n .combobox__clear:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .combobox__dropdown-indicator {\n color: var(--bp-color-text-muted);\n font-size: var(--bp-font-size-xs);\n transition: transform var(--bp-transition-fast);\n user-select: none;\n }\n\n .combobox--open .combobox__dropdown-indicator {\n transform: rotate(180deg);\n }\n\n .combobox__dropdown {\n position: absolute;\n top: calc(100% + var(--bp-spacing-xs));\n left: 0;\n right: 0;\n z-index: var(--bp-z-dropdown);\n background-color: var(--bp-color-surface);\n border: var(--bp-border-width) solid var(--bp-color-border);\n border-top: calc(var(--bp-border-width) * 2) solid var(--bp-color-primary);\n border-radius: var(--bp-border-radius-md);\n box-shadow: var(--bp-shadow-md);\n max-height: calc(var(--bp-spacing-10) * 6);\n overflow-y: auto;\n opacity: 0;\n visibility: hidden;\n transform: translateY(calc(-1 * var(--bp-spacing-md)));\n transition:\n opacity var(--bp-transition-fast),\n transform var(--bp-transition-fast),\n visibility var(--bp-transition-fast);\n contain: layout style paint;\n }\n\n .combobox--open .combobox__dropdown {\n opacity: 1;\n visibility: visible;\n transform: translateY(0);\n }\n\n .combobox__options {\n list-style: none;\n margin: 0;\n padding: var(--bp-spacing-2xs);\n }\n\n .combobox__option {\n padding: var(--bp-spacing-sm) var(--bp-spacing-md);\n cursor: pointer;\n border-radius: var(--bp-border-radius-md);\n transition:\n background-color var(--bp-transition-fast),\n color var(--bp-transition-fast);\n }\n\n .combobox__option:hover {\n background-color: color-mix(\n in srgb,\n var(--bp-color-primary) 8%,\n transparent\n );\n }\n\n .combobox__option--focused {\n background-color: color-mix(\n in srgb,\n var(--bp-color-primary) 8%,\n transparent\n );\n outline: var(--bp-focus-width) solid var(--bp-color-primary);\n outline-offset: calc(-1 * var(--bp-focus-width));\n }\n\n .combobox__option--selected {\n background-color: color-mix(\n in srgb,\n var(--bp-color-primary) 8%,\n transparent\n );\n color: var(--bp-color-primary);\n }\n\n .combobox__option--selected:hover,\n .combobox__option--selected.combobox__option--focused {\n background-color: color-mix(\n in srgb,\n var(--bp-color-primary) 12%,\n transparent\n );\n }\n\n .combobox__option--empty {\n color: var(--bp-color-text-muted);\n cursor: default;\n text-align: center;\n padding: var(--bp-spacing-lg) var(--bp-spacing-md);\n font-style: italic;\n }\n\n .combobox__option--empty:hover {\n background-color: transparent;\n }\n\n /* Sizes */\n .combobox--sm .combobox__input {\n padding: var(--bp-spacing-2xs) var(--bp-spacing-xs);\n font-size: var(--bp-font-size-sm);\n }\n\n .combobox--sm .combobox__indicators {\n padding-right: var(--bp-spacing-xs);\n }\n\n .combobox--lg .combobox__input {\n padding: var(--bp-spacing-md) var(--bp-spacing-lg);\n font-size: var(--bp-font-size-lg);\n }\n\n .combobox--lg .combobox__indicators {\n padding-right: var(--bp-spacing-md);\n }\n\n /* Variants */\n .combobox--default .combobox__control {\n border-color: var(--bp-color-border);\n }\n\n .combobox--success .combobox__control {\n border-color: var(--bp-color-success);\n }\n\n .combobox--error .combobox__control {\n border-color: var(--bp-color-error);\n }\n\n .combobox--warning .combobox__control {\n border-color: var(--bp-color-warning);\n }\n\n .combobox--info .combobox__control {\n border-color: var(--bp-color-info);\n }\n\n .combobox--success\n .combobox__control:hover:not(.combobox--disabled .combobox__control) {\n border-color: var(--bp-color-success);\n }\n\n .combobox--error\n .combobox__control:hover:not(.combobox--disabled .combobox__control) {\n border-color: var(--bp-color-error);\n }\n\n .combobox--warning\n .combobox__control:hover:not(.combobox--disabled .combobox__control) {\n border-color: var(--bp-color-warning);\n }\n\n .combobox--info\n .combobox__control:hover:not(.combobox--disabled .combobox__control) {\n border-color: var(--bp-color-info);\n }\n\n /* States */\n .combobox--disabled .combobox__control {\n background-color: var(--bp-color-surface-subdued);\n cursor: not-allowed;\n opacity: 0.6;\n }\n\n .combobox--disabled .combobox__input {\n color: var(--bp-color-text-muted);\n }\n\n /* Hide slot */\n slot {\n display: none;\n }\n\n /* Hide hidden inputs */\n input[type='hidden'] {\n display: none;\n }\n\n /* iOS zoom prevention: ensure 16px minimum on touch devices */\n @media (max-width: 768px) {\n .combobox--sm .combobox__input {\n font-size: 16px;\n }\n }\n`;\n","import { LitElement, html, nothing } from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { comboboxStyles } from './combobox.style.js';\nimport { debounce } from '../../utilities/debounce.js';\nimport { memoizeOne } from '../../utilities/memoize.js';\n\nexport type ComboboxSize = 'sm' | 'md' | 'lg';\nexport type ComboboxVariant =\n | 'default'\n | 'success'\n | 'error'\n | 'warning'\n | 'info';\n\nexport interface ComboboxOption {\n value: string;\n label: string;\n}\n\n@customElement('bp-combobox')\nexport class BpCombobox extends LitElement {\n /** The current value of the combobox */\n @property({ type: String, reflect: true }) declare value: string;\n\n /** Name attribute for form submission */\n @property({ type: String }) declare name: string;\n\n /** Placeholder text when no value is selected */\n @property({ type: String }) declare placeholder: string;\n\n /** Whether the combobox is disabled */\n @property({ type: Boolean, reflect: true }) declare disabled: boolean;\n\n /** Whether the combobox is required */\n @property({ type: Boolean, reflect: true }) declare required: boolean;\n\n /** Size variant of the combobox */\n @property({ type: String, reflect: true }) declare size: ComboboxSize;\n\n /** Visual variant for validation states */\n @property({ type: String, reflect: true }) declare variant: ComboboxVariant;\n\n /** Whether to allow free-form input (not just from the options list) */\n @property({ type: Boolean }) declare allowCustomValue: boolean;\n\n /** Whether the dropdown is currently open */\n @state() private isOpen = false;\n\n /** Current search/filter text */\n @state() private searchText = '';\n\n /** Index of the focused option for keyboard navigation */\n @state() private focusedIndex = -1;\n\n /** Cached filtered options to avoid recomputation on every render */\n @state() private cachedFilteredOptions: ComboboxOption[] = [];\n\n /** Cached options from slotted elements */\n @state() private cachedOptions: ComboboxOption[] = [];\n\n /** Reference to the input element */\n @query('input[type=\"text\"]') private inputElement!: HTMLInputElement;\n\n /** Debounced filter computation for search input */\n private debouncedFilter = debounce(() => {\n this.cachedFilteredOptions = this.filterOptions(\n this.cachedOptions,\n this.searchText\n );\n }, 150);\n\n /**\n * Memoized filter computation.\n * Returns cached result when options array and searchText are the same references.\n */\n private filterOptions = memoizeOne(\n (options: ComboboxOption[], searchText: string): ComboboxOption[] => {\n if (!searchText.trim()) {\n return options;\n }\n\n const searchLower = searchText.toLowerCase();\n return options.filter((option) =>\n option.label.toLowerCase().includes(searchLower)\n );\n }\n );\n\n static styles = [comboboxStyles];\n\n constructor() {\n super();\n this.value = '';\n this.name = '';\n this.placeholder = 'Search or select...';\n this.disabled = false;\n this.required = false;\n this.size = 'md';\n this.variant = 'default';\n this.allowCustomValue = false;\n }\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener('click', this.handleDocumentClick, {\n passive: true,\n });\n // Initialize search text with selected label and populate cached filtered options\n this.updateComplete.then(() => {\n this.cachedOptions = this.getOptions();\n this.updateSearchText();\n this.cachedFilteredOptions = this.filterOptions(\n this.cachedOptions,\n this.searchText\n );\n });\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n document.removeEventListener('click', this.handleDocumentClick, {\n passive: true,\n } as EventListenerOptions);\n this.debouncedFilter.cancel();\n }\n\n private updateSearchText() {\n if (!this.value) {\n this.searchText = '';\n return;\n }\n\n const options =\n this.cachedOptions.length > 0 ? this.cachedOptions : this.getOptions();\n const selectedOption = options.find((opt) => opt.value === this.value);\n if (selectedOption) {\n this.searchText = selectedOption.label;\n }\n }\n\n private handleDocumentClick = (event: MouseEvent) => {\n if (!this.contains(event.target as globalThis.Node)) {\n this.closeDropdown();\n }\n };\n\n private closeDropdown() {\n this.isOpen = false;\n this.focusedIndex = -1;\n this.debouncedFilter.cancel();\n this.updateSearchText();\n this.cachedFilteredOptions = this.filterOptions(\n this.cachedOptions,\n this.searchText\n );\n }\n\n private getOptions(): ComboboxOption[] {\n const slot = this.shadowRoot?.querySelector('slot');\n const assignedElements = slot?.assignedElements() || [];\n const options = assignedElements.filter(\n (el): el is globalThis.HTMLOptionElement => el.tagName === 'OPTION'\n );\n\n return options.map((option) => ({\n value: option.value || option.textContent || '',\n label: option.textContent || '',\n }));\n }\n\n /**\n * Returns the cached filtered options for rendering and keyboard navigation.\n */\n private getFilteredOptions(): ComboboxOption[] {\n return this.cachedFilteredOptions;\n }\n\n /**\n * Handle slot changes by refreshing the cached options.\n */\n private handleSlotChange = () => {\n this.cachedOptions = this.getOptions();\n this.cachedFilteredOptions = this.filterOptions(\n this.cachedOptions,\n this.searchText\n );\n };\n\n private handleInputFocus = () => {\n if (this.disabled) return;\n this.isOpen = true;\n this.focusedIndex = -1;\n };\n\n private handleInputClick = (event: MouseEvent) => {\n event.stopPropagation();\n if (this.disabled) return;\n this.isOpen = true;\n };\n\n private handleInputChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.searchText = target.value;\n this.isOpen = true;\n this.focusedIndex = -1;\n\n // Debounce the filter computation for search input\n this.debouncedFilter();\n\n // If allowCustomValue is true, update value immediately\n if (this.allowCustomValue) {\n const previousValue = this.value;\n this.value = this.searchText;\n\n this.dispatchEvent(\n new CustomEvent('bp-change', {\n detail: {\n value: this.value,\n previousValue,\n },\n bubbles: true,\n composed: true,\n })\n );\n }\n };\n\n private handleOptionClick = (option: ComboboxOption) => {\n if (this.disabled) return;\n\n const previousValue = this.value;\n this.value = option.value;\n this.searchText = option.label;\n this.isOpen = false;\n this.focusedIndex = -1;\n this.debouncedFilter.cancel();\n this.cachedFilteredOptions = this.filterOptions(\n this.cachedOptions,\n this.searchText\n );\n\n // Dispatch change event\n this.dispatchEvent(\n new CustomEvent('bp-change', {\n detail: {\n value: this.value,\n label: option.label,\n previousValue,\n },\n bubbles: true,\n composed: true,\n })\n );\n\n // Update hidden input for form submission\n const hiddenInput = this.shadowRoot?.querySelector('input[type=\"hidden\"]');\n if (hiddenInput) {\n (hiddenInput as HTMLInputElement).value = this.value;\n }\n\n // Return focus to input\n this.inputElement?.focus();\n };\n\n private handleInputKeyDown = (event: globalThis.KeyboardEvent) => {\n if (this.disabled) return;\n\n const filteredOptions = this.getFilteredOptions();\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n if (!this.isOpen) {\n this.isOpen = true;\n this.focusedIndex = 0;\n } else {\n this.focusedIndex = Math.min(\n this.focusedIndex + 1,\n filteredOptions.length - 1\n );\n }\n break;\n\n case 'ArrowUp':\n event.preventDefault();\n if (!this.isOpen) {\n this.isOpen = true;\n this.focusedIndex = filteredOptions.length - 1;\n } else {\n this.focusedIndex = Math.max(this.focusedIndex - 1, 0);\n }\n break;\n\n case 'Enter':\n event.preventDefault();\n if (this.isOpen && this.focusedIndex >= 0) {\n const option = filteredOptions[this.focusedIndex];\n if (option) {\n this.handleOptionClick(option);\n }\n } else if (!this.isOpen) {\n this.isOpen = true;\n }\n break;\n\n case 'Escape':\n event.preventDefault();\n this.closeDropdown();\n break;\n\n case 'Tab':\n // Allow tab to close dropdown\n this.closeDropdown();\n break;\n }\n };\n\n private handleClear = (event: MouseEvent) => {\n event.stopPropagation();\n if (this.disabled) return;\n\n const previousValue = this.value;\n this.value = '';\n this.searchText = '';\n this.debouncedFilter.cancel();\n this.cachedFilteredOptions = this.filterOptions(\n this.cachedOptions,\n this.searchText\n );\n\n this.dispatchEvent(\n new CustomEvent('bp-change', {\n detail: {\n value: '',\n previousValue,\n },\n bubbles: true,\n composed: true,\n })\n );\n\n this.inputElement?.focus();\n };\n\n private renderDropdown() {\n const filteredOptions = this.getFilteredOptions();\n\n return html`\n <div class=\"combobox__dropdown\" id=\"listbox\" part=\"dropdown\">\n <ul class=\"combobox__options\" role=\"listbox\">\n ${filteredOptions.length === 0\n ? html`<li\n class=\"combobox__option combobox__option--empty\"\n role=\"option\"\n >\n No results found\n </li>`\n : repeat(\n filteredOptions,\n (opt) => opt.value,\n (opt, index) => {\n const isSelected = opt.value === this.value;\n const isFocused = index === this.focusedIndex;\n return html`\n <li\n class=${classMap({\n combobox__option: true,\n 'combobox__option--selected': isSelected,\n 'combobox__option--focused': isFocused,\n })}\n role=\"option\"\n aria-selected=${isSelected}\n @click=${() => this.handleOptionClick(opt)}\n part=\"option ${isSelected ? 'option-selected' : ''}\"\n >\n ${opt.label}\n </li>\n `;\n }\n )}\n </ul>\n </div>\n `;\n }\n\n render() {\n const hasValue = Boolean(this.value || this.searchText);\n\n return html`\n <div\n class=${classMap({\n combobox: true,\n 'combobox--open': this.isOpen,\n 'combobox--disabled': this.disabled,\n [`combobox--${this.size}`]: true,\n [`combobox--${this.variant}`]: true,\n })}\n >\n <div class=\"combobox__control\" part=\"control\">\n <input\n type=\"text\"\n class=\"combobox__input\"\n .value=${this.searchText}\n placeholder=${this.placeholder}\n ?disabled=${this.disabled}\n ?required=${this.required}\n @focus=${this.handleInputFocus}\n @click=${this.handleInputClick}\n @input=${this.handleInputChange}\n @keydown=${this.handleInputKeyDown}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded=${this.isOpen}\n aria-autocomplete=\"list\"\n aria-controls=\"listbox\"\n aria-disabled=${this.disabled}\n part=\"input\"\n />\n\n <div class=\"combobox__indicators\">\n ${hasValue\n ? html`\n <button\n type=\"button\"\n class=\"combobox__clear\"\n @click=${this.handleClear}\n aria-label=\"Clear selection\"\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n part=\"clear-button\"\n >\n ×\n </button>\n `\n : ''}\n <span class=\"combobox__dropdown-indicator\" part=\"indicator\">\n ▼\n </span>\n </div>\n </div>\n\n ${this.isOpen ? this.renderDropdown() : nothing}\n\n <!-- Hidden slot for options -->\n <slot @slotchange=${this.handleSlotChange}></slot>\n\n <!-- Hidden input for form submission -->\n ${this.name\n ? html`<input\n type=\"hidden\"\n name=\"${this.name}\"\n .value=${this.value}\n />`\n : ''}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'bp-combobox': BpCombobox;\n }\n}\n"],"names":["comboboxStyles","css","BpCombobox","LitElement","debounce","memoizeOne","options","searchText","searchLower","option","event","target","previousValue","hiddenInput","filteredOptions","selectedOption","opt","el","html","repeat","index","isS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