@f-ewald/components 1.46.1 → 1.47.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.
Files changed (49) hide show
  1. package/README.md +1 -0
  2. package/custom-elements.json +4520 -2463
  3. package/dist/address-autocomplete.d.ts +9 -44
  4. package/dist/address-autocomplete.d.ts.map +1 -1
  5. package/dist/address-autocomplete.js +16 -597
  6. package/dist/address-autocomplete.js.map +1 -1
  7. package/dist/app-shell.d.ts.map +1 -1
  8. package/dist/app-shell.js +8 -5
  9. package/dist/app-shell.js.map +1 -1
  10. package/dist/autocomplete-base.d.ts +79 -0
  11. package/dist/autocomplete-base.d.ts.map +1 -0
  12. package/dist/autocomplete-base.js +679 -0
  13. package/dist/autocomplete-base.js.map +1 -0
  14. package/dist/autocomplete-input.d.ts +9 -44
  15. package/dist/autocomplete-input.d.ts.map +1 -1
  16. package/dist/autocomplete-input.js +18 -647
  17. package/dist/autocomplete-input.js.map +1 -1
  18. package/dist/calendar-month.d.ts +3 -2
  19. package/dist/calendar-month.d.ts.map +1 -1
  20. package/dist/calendar-month.js +5 -3
  21. package/dist/calendar-month.js.map +1 -1
  22. package/dist/calendar-timeline-base.d.ts +3 -2
  23. package/dist/calendar-timeline-base.d.ts.map +1 -1
  24. package/dist/calendar-timeline-base.js +5 -3
  25. package/dist/calendar-timeline-base.js.map +1 -1
  26. package/dist/drop-zone.d.ts +78 -0
  27. package/dist/drop-zone.d.ts.map +1 -0
  28. package/dist/drop-zone.js +479 -0
  29. package/dist/drop-zone.js.map +1 -0
  30. package/dist/icons.d.ts +2 -0
  31. package/dist/icons.d.ts.map +1 -1
  32. package/dist/icons.js +2 -0
  33. package/dist/icons.js.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/mcp-server.js +13 -10
  39. package/dist/mcp-server.js.map +1 -1
  40. package/dist/utils/calendar.d.ts +5 -0
  41. package/dist/utils/calendar.d.ts.map +1 -1
  42. package/dist/utils/calendar.js +17 -0
  43. package/dist/utils/calendar.js.map +1 -1
  44. package/docs/address-autocomplete.md +7 -7
  45. package/docs/autocomplete-input.md +5 -5
  46. package/docs/drop-zone.md +87 -0
  47. package/docs/icons.md +1 -0
  48. package/llms.txt +42 -2
  49. package/package.json +1 -1
@@ -0,0 +1,679 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, css, html, nothing } from "lit";
8
+ import { property, query, state } from "lit/decorators.js";
9
+ import { iconX } from "./icons.js";
10
+ import { formFieldControl, } from "./utils/form-field-control.js";
11
+ import { submitWithDefaultButton } from "./utils/form.js";
12
+ let instanceCount = 0;
13
+ /** Shared styles for every `AutocompleteBase` subclass; use as `[tokens, autocompleteStyles]`. */
14
+ export const autocompleteStyles = css `
15
+ :host {
16
+ display: block;
17
+ position: relative;
18
+ }
19
+ .field-shell {
20
+ position: relative;
21
+ }
22
+ input {
23
+ font-family: var(
24
+ --ui-font,
25
+ ui-sans-serif,
26
+ system-ui,
27
+ sans-serif,
28
+ "Apple Color Emoji",
29
+ "Segoe UI Emoji",
30
+ "Segoe UI Symbol",
31
+ "Noto Color Emoji"
32
+ );
33
+ font-size: var(--ui-font-size, 0.875rem);
34
+ line-height: var(--ui-line-height-tight, 1.25);
35
+ color: var(--ui-text, #0f172a);
36
+ background: var(--ui-surface, #ffffff);
37
+ padding: 0.5rem 0.75rem;
38
+ border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
39
+ border-radius: var(--ui-radius-sm, 0.25rem);
40
+ width: 100%;
41
+ height: 2rem;
42
+ box-sizing: border-box;
43
+ }
44
+ .field-shell.clearable input {
45
+ padding-right: 2rem;
46
+ }
47
+ .field-shell.has-icon input {
48
+ padding-left: 2rem;
49
+ }
50
+ .field-icon {
51
+ position: absolute;
52
+ top: 50%;
53
+ left: 0.75rem;
54
+ display: inline-flex;
55
+ line-height: 0;
56
+ transform: translateY(-50%);
57
+ color: var(--ui-text-muted, #64748b);
58
+ pointer-events: none;
59
+ }
60
+ .clear-button {
61
+ position: absolute;
62
+ top: 0;
63
+ right: 0;
64
+ display: inline-flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+ box-sizing: border-box;
68
+ width: 2rem;
69
+ height: 2rem;
70
+ /* Insets the hover/focus background by the input's 1px border so it
71
+ stays fully inside the field instead of painting over the border. */
72
+ padding: 1px;
73
+ background-clip: content-box;
74
+ border: 0;
75
+ border-radius: var(--ui-radius-sm, 0.25rem);
76
+ color: var(--ui-text-muted, #64748b);
77
+ background-color: transparent;
78
+ cursor: pointer;
79
+ line-height: 0;
80
+ }
81
+ .clear-button:hover {
82
+ color: var(--ui-text, #0f172a);
83
+ background-color: var(--ui-surface-muted, #f8fafc);
84
+ }
85
+ .clear-button:focus-visible {
86
+ outline: none;
87
+ box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
88
+ }
89
+ .floating-label {
90
+ position: absolute;
91
+ top: 50%;
92
+ left: 0.75rem;
93
+ right: 0.75rem;
94
+ z-index: 1;
95
+ display: flex;
96
+ align-items: baseline;
97
+ gap: 0.25rem;
98
+ overflow: hidden;
99
+ transform: translateY(-50%);
100
+ color: var(--ui-text-muted, #64748b);
101
+ font-family: var(
102
+ --ui-font,
103
+ ui-sans-serif,
104
+ system-ui,
105
+ sans-serif,
106
+ "Apple Color Emoji",
107
+ "Segoe UI Emoji",
108
+ "Segoe UI Symbol",
109
+ "Noto Color Emoji"
110
+ );
111
+ font-size: var(--ui-font-size-sm, 0.75rem);
112
+ font-weight: var(--ui-font-weight-regular, 400);
113
+ line-height: var(--ui-line-height-tight, 1.25);
114
+ white-space: nowrap;
115
+ text-overflow: ellipsis;
116
+ cursor: text;
117
+ transition:
118
+ top 150ms ease,
119
+ transform 150ms ease,
120
+ font-size 150ms ease;
121
+ }
122
+ .field-shell.clearable .floating-label {
123
+ right: 2rem;
124
+ }
125
+ .field-shell.floating input {
126
+ height: 3rem;
127
+ padding-top: 1.25rem;
128
+ padding-bottom: 0.25rem;
129
+ }
130
+ .field-shell.floating .clear-button {
131
+ top: 0.5rem;
132
+ }
133
+ .field-shell.floating .field-icon {
134
+ top: 2rem;
135
+ }
136
+ .field-shell.has-icon .floating-label {
137
+ left: 2rem;
138
+ }
139
+ .field-shell.floating.has-value .floating-label,
140
+ .field-shell.floating:focus-within .floating-label {
141
+ top: 0.25rem;
142
+ transform: none;
143
+ font-size: var(--ui-font-size-xs, 0.6875rem);
144
+ }
145
+ .field-shell.floating:not(.has-value):not(:focus-within) input::placeholder {
146
+ opacity: 0;
147
+ }
148
+ .field-shell.disabled .floating-label {
149
+ cursor: not-allowed;
150
+ opacity: 0.6;
151
+ }
152
+ .required-mark {
153
+ flex: 0 0 auto;
154
+ color: var(--ui-danger, #dc2626);
155
+ }
156
+ .sr-only {
157
+ position: absolute;
158
+ width: 1px;
159
+ height: 1px;
160
+ margin: -1px;
161
+ padding: 0;
162
+ overflow: hidden;
163
+ clip: rect(0 0 0 0);
164
+ clip-path: inset(50%);
165
+ white-space: nowrap;
166
+ border: 0;
167
+ }
168
+ input:disabled {
169
+ cursor: not-allowed;
170
+ opacity: 0.6;
171
+ }
172
+ input:focus-visible {
173
+ outline: none;
174
+ border-color: var(--ui-primary, #4f46e5);
175
+ box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
176
+ }
177
+ .suggestions {
178
+ position: absolute;
179
+ top: 100%;
180
+ left: 0;
181
+ right: 0;
182
+ z-index: 10;
183
+ max-height: 40vh;
184
+ overflow-y: auto;
185
+ margin: 0.25rem 0 0;
186
+ padding: 0.25rem 0;
187
+ list-style: none;
188
+ background: var(--ui-surface, #ffffff);
189
+ border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
190
+ border-radius: var(--ui-radius-sm, 0.25rem);
191
+ box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
192
+ }
193
+ .suggestion {
194
+ display: flex;
195
+ align-items: flex-start;
196
+ gap: 0.5rem;
197
+ padding: 0.5rem 0.75rem;
198
+ font-size: var(--ui-font-size-sm, 0.75rem);
199
+ cursor: pointer;
200
+ }
201
+ .suggestion-icon {
202
+ display: inline-flex;
203
+ flex: 0 0 auto;
204
+ align-items: center;
205
+ /* Centers the icon on the value's first line rather than the whole row. */
206
+ min-height: calc(1em * var(--ui-line-height-tight, 1.25));
207
+ color: var(--ui-text-muted, #64748b);
208
+ }
209
+ .suggestion-text {
210
+ display: flex;
211
+ min-width: 0;
212
+ flex-direction: column;
213
+ line-height: var(--ui-line-height-tight, 1.25);
214
+ }
215
+ .suggestion-description {
216
+ color: var(--ui-text-muted, #64748b);
217
+ font-size: var(--ui-font-size-xs, 0.6875rem);
218
+ }
219
+ .suggestion.active,
220
+ .suggestion:hover {
221
+ background: var(--ui-surface-muted, #f8fafc);
222
+ }
223
+ .no-suggestions {
224
+ padding: 0.5rem 0.75rem;
225
+ color: var(--ui-text-muted, #64748b);
226
+ font-size: var(--ui-font-size-sm, 0.75rem);
227
+ font-style: italic;
228
+ }
229
+ @media (forced-colors: active) {
230
+ input:focus-visible {
231
+ outline: 2px solid CanvasText;
232
+ outline-offset: 2px;
233
+ box-shadow: none;
234
+ }
235
+ input:disabled {
236
+ color: GrayText;
237
+ opacity: 1;
238
+ }
239
+ .clear-button:focus-visible {
240
+ outline: 2px solid CanvasText;
241
+ outline-offset: -2px;
242
+ box-shadow: none;
243
+ }
244
+ .field-shell.disabled .floating-label {
245
+ color: GrayText;
246
+ opacity: 1;
247
+ }
248
+ .suggestion.active,
249
+ .suggestion:hover {
250
+ color: HighlightText;
251
+ background: Highlight;
252
+ }
253
+ .suggestion.active :is(.suggestion-icon, .suggestion-description),
254
+ .suggestion:hover :is(.suggestion-icon, .suggestion-description) {
255
+ color: HighlightText;
256
+ }
257
+ }
258
+ @media (prefers-reduced-motion: reduce) {
259
+ .floating-label {
260
+ transition: none;
261
+ }
262
+ }
263
+ `;
264
+ /**
265
+ * Shared form-associated combobox behind `autocomplete-input` and
266
+ * `address-autocomplete` — not a registered custom element itself. Owns the
267
+ * input, debounced local filtering or fetching, keyboard and IME handling,
268
+ * the clear action, and the form contract. Subclasses supply the item type
269
+ * `T` and how to filter, fetch, show, and announce it.
270
+ */
271
+ export class AutocompleteBase extends LitElement {
272
+ constructor() {
273
+ super(...arguments);
274
+ /** Current input value; also the form-associated value submitted with the form. */
275
+ this.value = "";
276
+ /** Placeholder text shown when the input is empty. */
277
+ this.placeholder = "";
278
+ /** Marks the input as required for native form validation. */
279
+ this.required = false;
280
+ /** Disables the input and closes its suggestion popup. */
281
+ this.disabled = false;
282
+ /** Shows an in-field clear action while the control has a value. */
283
+ this.clearable = false;
284
+ /** Debounce delay (ms) before firing a request/filter after typing. */
285
+ this.debounce = 300;
286
+ /** Minimum query length before suggestions are shown. */
287
+ this.minLength = 3;
288
+ this._suggestions = [];
289
+ this._open = false;
290
+ this._activeIndex = -1;
291
+ this._formDisabled = false;
292
+ this._formFieldConfig = null;
293
+ /** Accessible name of the suggestion list. */
294
+ this.listboxLabel = "Suggestions";
295
+ /** Accessible name and tooltip of the clear action. */
296
+ this.clearLabel = "Clear input";
297
+ /** The last item picked from the list; cleared on reset and clear. */
298
+ this.lastPicked = null;
299
+ this.#internals = this.attachInternals();
300
+ this.#debounceTimer = null;
301
+ this.#abortController = null;
302
+ this.#isComposing = false;
303
+ this.#compositionJustEnded = false;
304
+ this.#compositionEndTimer = null;
305
+ this.#inputId = `${this.localName}-field-${++instanceCount}`;
306
+ this.#listboxId = `${this.localName}-listbox-${instanceCount}`;
307
+ }
308
+ static { this.formAssociated = true; }
309
+ #internals;
310
+ #debounceTimer;
311
+ #abortController;
312
+ #isComposing;
313
+ #compositionJustEnded;
314
+ #compositionEndTimer;
315
+ #inputId;
316
+ #listboxId;
317
+ /** Icon shown inside the field, if any. */
318
+ fieldIcon() {
319
+ return undefined;
320
+ }
321
+ /** Whether the host or an ancestor fieldset currently disables the control. */
322
+ get #isDisabled() {
323
+ return this.disabled || this._formDisabled;
324
+ }
325
+ /**
326
+ * Applies or clears label configuration supplied by a wrapping `form-field`.
327
+ * @private
328
+ */
329
+ [formFieldControl](config) {
330
+ this._formFieldConfig = config;
331
+ }
332
+ willUpdate(changed) {
333
+ if (changed.has("disabled") && this.#isDisabled) {
334
+ if (this.#debounceTimer)
335
+ clearTimeout(this.#debounceTimer);
336
+ this.#resetComposition();
337
+ this.#abortController?.abort();
338
+ this._open = false;
339
+ this._activeIndex = -1;
340
+ }
341
+ }
342
+ updated(changed) {
343
+ if (changed.has("value"))
344
+ this.#internals.setFormValue(this.value);
345
+ }
346
+ disconnectedCallback() {
347
+ super.disconnectedCallback();
348
+ if (this.#debounceTimer)
349
+ clearTimeout(this.#debounceTimer);
350
+ this.#resetComposition();
351
+ this.#abortController?.abort();
352
+ }
353
+ /** Resets to empty on `form.reset()`, per the form-associated custom element contract. */
354
+ formResetCallback() {
355
+ this.value = "";
356
+ this._suggestions = [];
357
+ this._open = false;
358
+ this.lastPicked = null;
359
+ }
360
+ /** Mirrors ancestor fieldset disabled state onto the native input. */
361
+ formDisabledCallback(disabled) {
362
+ this._formDisabled = disabled;
363
+ if (!disabled)
364
+ return;
365
+ if (this.#debounceTimer)
366
+ clearTimeout(this.#debounceTimer);
367
+ this.#resetComposition();
368
+ this.#abortController?.abort();
369
+ this._open = false;
370
+ this._activeIndex = -1;
371
+ }
372
+ onInput(e) {
373
+ if (this.#isDisabled)
374
+ return;
375
+ this.value = e.target.value;
376
+ this.lastPicked = null;
377
+ this.#scheduleFetch(this.value);
378
+ }
379
+ #scheduleFetch(query) {
380
+ if (this.#isDisabled)
381
+ return;
382
+ if (this.#debounceTimer)
383
+ clearTimeout(this.#debounceTimer);
384
+ // Any response still in flight is for older text now.
385
+ this.#abortController?.abort();
386
+ this.#abortController = null;
387
+ if (query.trim().length < this.minLength) {
388
+ this._suggestions = [];
389
+ this._open = false;
390
+ this._activeIndex = -1;
391
+ return;
392
+ }
393
+ if (this.localItems()) {
394
+ // Local mode: filtering is synchronous and cheap, but keep the same
395
+ // debounce as the API mode so the UX doesn't shift between sources.
396
+ this.#debounceTimer = setTimeout(() => this.#filterLocalItems(query), this.debounce);
397
+ return;
398
+ }
399
+ this.#debounceTimer = setTimeout(() => void this.#fetchItems(query), this.debounce);
400
+ }
401
+ /** Filters the local candidate list for `query`, case-insensitively. */
402
+ #filterLocalItems(query) {
403
+ const needle = query.trim().toLowerCase();
404
+ this._suggestions = (this.localItems() ?? [])
405
+ .filter((item) => this.view(item).text.toLowerCase().includes(needle))
406
+ .slice(0, 5);
407
+ this._activeIndex = -1;
408
+ this._open = !this.#isDisabled;
409
+ }
410
+ /** Fetches candidates for `query`, cancelling any request still in flight. */
411
+ async #fetchItems(query) {
412
+ this.#abortController?.abort();
413
+ const controller = new AbortController();
414
+ this.#abortController = controller;
415
+ try {
416
+ const res = await fetch(this.requestUrl(query), { signal: controller.signal });
417
+ if (!res.ok)
418
+ throw new Error(`autocomplete request failed: ${res.status}`);
419
+ const body = await res.json();
420
+ if (controller.signal.aborted || this.#isDisabled)
421
+ return;
422
+ this._suggestions = this.parseItems(body).slice(0, 5);
423
+ this._activeIndex = -1;
424
+ this._open = true;
425
+ }
426
+ catch {
427
+ // Aborted (superseded by newer keystroke) or a network failure while
428
+ // typing — fail silently and just close the list.
429
+ if (!controller.signal.aborted) {
430
+ this._suggestions = [];
431
+ this._open = false;
432
+ }
433
+ }
434
+ }
435
+ onKeydown(e) {
436
+ if (this.#isDisabled)
437
+ return;
438
+ if (e.isComposing || e.keyCode === 229 || this.#isComposing || this.#compositionJustEnded) {
439
+ return;
440
+ }
441
+ if (e.key === "ArrowDown")
442
+ this.#moveActive(1, e);
443
+ else if (e.key === "ArrowUp")
444
+ this.#moveActive(-1, e);
445
+ else if (e.key === "Enter")
446
+ this.#handleEnter(e);
447
+ else if (e.key === "Escape")
448
+ this.#handleEscape(e);
449
+ }
450
+ #moveActive(delta, e) {
451
+ if (!this._open || this._suggestions.length === 0)
452
+ return;
453
+ e.preventDefault();
454
+ const n = this._suggestions.length;
455
+ this._activeIndex = (this._activeIndex + delta + n) % n;
456
+ }
457
+ #handleEnter(e) {
458
+ const pick = this._suggestions[this._activeIndex] ?? this._suggestions[0];
459
+ if (this._open && pick) {
460
+ e.preventDefault();
461
+ this.#select(pick);
462
+ return;
463
+ }
464
+ if (this.#internals.form) {
465
+ const form = this.#internals.form;
466
+ window.setTimeout(() => {
467
+ if (!e.defaultPrevented && form.isConnected)
468
+ submitWithDefaultButton(form);
469
+ });
470
+ }
471
+ }
472
+ #handleEscape(e) {
473
+ if (!this._open)
474
+ return;
475
+ e.preventDefault();
476
+ this._open = false;
477
+ }
478
+ onBlur() {
479
+ this._open = false;
480
+ }
481
+ onCompositionStart() {
482
+ if (this.#compositionEndTimer)
483
+ clearTimeout(this.#compositionEndTimer);
484
+ this.#compositionEndTimer = null;
485
+ this.#compositionJustEnded = false;
486
+ this.#isComposing = true;
487
+ }
488
+ onCompositionEnd() {
489
+ this.#isComposing = false;
490
+ this.#compositionJustEnded = true;
491
+ if (this.#compositionEndTimer)
492
+ clearTimeout(this.#compositionEndTimer);
493
+ this.#compositionEndTimer = setTimeout(() => {
494
+ this.#compositionJustEnded = false;
495
+ this.#compositionEndTimer = null;
496
+ });
497
+ }
498
+ /** Clears composition state when the control can no longer receive keys. */
499
+ #resetComposition() {
500
+ if (this.#compositionEndTimer)
501
+ clearTimeout(this.#compositionEndTimer);
502
+ this.#compositionEndTimer = null;
503
+ this.#isComposing = false;
504
+ this.#compositionJustEnded = false;
505
+ }
506
+ #select(item) {
507
+ this.value = this.view(item).text;
508
+ this.lastPicked = item;
509
+ this._open = false;
510
+ this._suggestions = [];
511
+ this.onSelect(item);
512
+ }
513
+ /** Clears the field and all pending autocomplete state, then restores input focus. */
514
+ #clear() {
515
+ if (this.#isDisabled || !this.value)
516
+ return;
517
+ if (this.#debounceTimer)
518
+ clearTimeout(this.#debounceTimer);
519
+ this.#debounceTimer = null;
520
+ this.#abortController?.abort();
521
+ this.#abortController = null;
522
+ this.#resetComposition();
523
+ this.value = "";
524
+ this.lastPicked = null;
525
+ this._suggestions = [];
526
+ this._activeIndex = -1;
527
+ this._open = false;
528
+ this.#internals.setFormValue("");
529
+ this.dispatchEvent(new InputEvent("input", {
530
+ bubbles: true,
531
+ composed: true,
532
+ inputType: "deleteContentBackward",
533
+ }));
534
+ this._input?.focus({ preventScroll: true });
535
+ }
536
+ /** Selects on mousedown (not click) so it wins over the input's blur, which closes the list. */
537
+ #onSuggestionMousedown(e, item) {
538
+ e.preventDefault();
539
+ this.#select(item);
540
+ }
541
+ renderSuggestions() {
542
+ if (!this._open || this.#isDisabled)
543
+ return nothing;
544
+ return html `
545
+ <ul id=${this.#listboxId} class="suggestions" role="listbox" aria-label=${this.listboxLabel}>
546
+ ${this._suggestions.map((item, i) => {
547
+ const { text, icon, description } = this.view(item);
548
+ return html `
549
+ <li
550
+ id=${`${this.#listboxId}-option-${i}`}
551
+ role="option"
552
+ aria-selected=${i === this._activeIndex}
553
+ class="suggestion ${i === this._activeIndex ? "active" : ""}"
554
+ @mousedown=${(e) => this.#onSuggestionMousedown(e, item)}
555
+ >
556
+ ${icon ? html `<span class="suggestion-icon" aria-hidden="true">${icon}</span>` : nothing}
557
+ <span class="suggestion-text">
558
+ <span class="suggestion-value">${text}</span>
559
+ ${description ? html `<span class="suggestion-description">${description}</span>` : nothing}
560
+ </span>
561
+ </li>
562
+ `;
563
+ })}
564
+ ${this._suggestions.length === 0
565
+ ? html `<li class="no-suggestions" role="presentation">
566
+ <span role="status">No suggestions found</span>
567
+ </li>`
568
+ : nothing}
569
+ </ul>
570
+ `;
571
+ }
572
+ render() {
573
+ const activeDescendant = this._open && !this.#isDisabled && this._activeIndex >= 0
574
+ ? `${this.#listboxId}-option-${this._activeIndex}`
575
+ : nothing;
576
+ const expanded = this._open && !this.#isDisabled;
577
+ const floating = Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);
578
+ const showClear = this.clearable && Boolean(this.value) && !this.#isDisabled;
579
+ const icon = this.fieldIcon();
580
+ return html `
581
+ <div
582
+ class="field-shell ${this.clearable ? "clearable" : ""} ${floating
583
+ ? "floating"
584
+ : ""} ${this.value ? "has-value" : ""} ${this.#isDisabled ? "disabled" : ""} ${icon
585
+ ? "has-icon"
586
+ : ""}"
587
+ >
588
+ ${icon ? html `<span class="field-icon" aria-hidden="true">${icon}</span>` : nothing}
589
+ ${floating
590
+ ? html `
591
+ <label class="floating-label" for=${this.#inputId}>
592
+ <span>${this._formFieldConfig.label}</span>
593
+ ${this._formFieldConfig.required
594
+ ? html `
595
+ <span class="required-mark" aria-hidden="true">*</span>
596
+ <span class="sr-only"> (required)</span>
597
+ `
598
+ : nothing}
599
+ </label>
600
+ `
601
+ : nothing}
602
+ <input
603
+ id=${this.#inputId}
604
+ type="text"
605
+ role="combobox"
606
+ aria-autocomplete="list"
607
+ aria-expanded=${expanded}
608
+ aria-controls=${this.#listboxId}
609
+ aria-activedescendant=${activeDescendant}
610
+ .value=${this.value}
611
+ placeholder=${this.placeholder}
612
+ ?required=${this.required}
613
+ ?disabled=${this.#isDisabled}
614
+ autocomplete="off"
615
+ @input=${this.onInput}
616
+ @compositionstart=${this.onCompositionStart}
617
+ @compositionend=${this.onCompositionEnd}
618
+ @keydown=${this.onKeydown}
619
+ @blur=${this.onBlur}
620
+ />
621
+ ${showClear
622
+ ? html `
623
+ <button
624
+ type="button"
625
+ class="clear-button"
626
+ aria-label=${this.clearLabel}
627
+ title=${this.clearLabel}
628
+ @mousedown=${(event) => event.preventDefault()}
629
+ @click=${() => this.#clear()}
630
+ >
631
+ ${iconX(18)}
632
+ </button>
633
+ `
634
+ : nothing}
635
+ ${this.renderSuggestions()}
636
+ </div>
637
+ `;
638
+ }
639
+ }
640
+ __decorate([
641
+ property()
642
+ ], AutocompleteBase.prototype, "value", void 0);
643
+ __decorate([
644
+ property()
645
+ ], AutocompleteBase.prototype, "placeholder", void 0);
646
+ __decorate([
647
+ property({ type: Boolean })
648
+ ], AutocompleteBase.prototype, "required", void 0);
649
+ __decorate([
650
+ property({ type: Boolean, reflect: true })
651
+ ], AutocompleteBase.prototype, "disabled", void 0);
652
+ __decorate([
653
+ property({ type: Boolean, reflect: true })
654
+ ], AutocompleteBase.prototype, "clearable", void 0);
655
+ __decorate([
656
+ property({ type: Number })
657
+ ], AutocompleteBase.prototype, "debounce", void 0);
658
+ __decorate([
659
+ property({ type: Number, attribute: "min-length" })
660
+ ], AutocompleteBase.prototype, "minLength", void 0);
661
+ __decorate([
662
+ state()
663
+ ], AutocompleteBase.prototype, "_suggestions", void 0);
664
+ __decorate([
665
+ state()
666
+ ], AutocompleteBase.prototype, "_open", void 0);
667
+ __decorate([
668
+ state()
669
+ ], AutocompleteBase.prototype, "_activeIndex", void 0);
670
+ __decorate([
671
+ state()
672
+ ], AutocompleteBase.prototype, "_formDisabled", void 0);
673
+ __decorate([
674
+ state()
675
+ ], AutocompleteBase.prototype, "_formFieldConfig", void 0);
676
+ __decorate([
677
+ query("input")
678
+ ], AutocompleteBase.prototype, "_input", void 0);
679
+ //# sourceMappingURL=autocomplete-base.js.map