@mintplayer/web-components 2.20.0 → 3.0.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 (41) hide show
  1. package/chunks/{datatable-qkYf-N0c.mjs → datatable-CrK1ZNq-.mjs} +132 -130
  2. package/chunks/{pagination-Bcz1TwlS.mjs → pagination-DgDp3v3u.mjs} +1 -1
  3. package/custom-elements.json +3119 -3416
  4. package/datatable/index.mjs +1 -1
  5. package/datatable/src/components/mp-datatable.d.ts +4 -0
  6. package/datatable/src/types/tree.d.ts +7 -0
  7. package/dropdown-menu/index.mjs +16 -23
  8. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +5 -8
  9. package/dropdown-menu/src/index.d.ts +1 -1
  10. package/dropdown-menu/src/types/dropdown.d.ts +0 -2
  11. package/dropdown-menu/src/types/index.d.ts +1 -1
  12. package/file-manager/index.mjs +1 -1
  13. package/light-dom/index.mjs +61 -121
  14. package/light-dom/src/install-light-styles.d.ts +10 -22
  15. package/light-dom/src/scoped-html.d.ts +0 -6
  16. package/machine/index.d.ts +1 -0
  17. package/machine/index.mjs +47 -0
  18. package/machine/src/index.d.ts +2 -0
  19. package/machine/src/machine-controller.d.ts +25 -0
  20. package/machine/src/props-directive.d.ts +21 -0
  21. package/package.json +10 -1
  22. package/pagination/index.mjs +1 -1
  23. package/tile-manager/index.mjs +150 -731
  24. package/tile-manager/src/components/index.d.ts +1 -2
  25. package/tile-manager/src/components/mp-tile-manager.d.ts +107 -0
  26. package/tile-manager/src/index.d.ts +2 -3
  27. package/tree-select/index.mjs +63 -55
  28. package/tree-select/src/components/mp-tree-select.d.ts +16 -5
  29. package/typeahead/index.d.ts +1 -0
  30. package/typeahead/index.mjs +220 -0
  31. package/typeahead/src/components/mp-typeahead.d.ts +67 -0
  32. package/typeahead/src/index.d.ts +3 -0
  33. package/tile-manager/src/components/mint-tile-manager.element.d.ts +0 -212
  34. package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +0 -2
  35. package/tile-manager/src/types/grid-rect.d.ts +0 -12
  36. package/tile-manager/src/types/index.d.ts +0 -3
  37. package/tile-manager/src/types/tile-layout-snapshot.d.ts +0 -15
  38. package/tile-manager/src/types/tile-position.d.ts +0 -10
  39. package/tile-manager/src/utils/grid-geometry.d.ts +0 -49
  40. package/tile-manager/src/utils/index.d.ts +0 -1
  41. package/tile-manager/src/utils/pack.d.ts +0 -24
@@ -1,2 +1 @@
1
- export { MintTileManagerElement } from './mint-tile-manager.element';
2
- export type { MintTile, TileDragMode, TileResizeMode } from './mint-tile-manager.element';
1
+ export { MintTileManagerElement } from './mp-tile-manager';
@@ -0,0 +1,107 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
+ import { TileManagerMachine, MintTile, TileBreakpoint, TileDragMode, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TileResizeMode } from '@mintplayer/ui-core/tile-manager';
3
+ /**
4
+ * `<mp-tile-manager>`: the Lit front of `TileManagerMachine` (#440). Every decision (layout per
5
+ * column count, gestures, keyboard, ARIA) is the machine's; this element measures the grid,
6
+ * renders `connect()`'s bags, owns pointer capture and the FLIP animation, and re-dispatches the
7
+ * machine's events (`layoutchange`, `layoutpreview`, `columncountchange`, `gestureblocked`).
8
+ *
9
+ * Keeps its shadow root: tile content arrives only through the named slots `${id}-header` and
10
+ * `${id}-content`, so it is never starved of page CSS (light-tier admission rule). The scoped
11
+ * sheet is adopted into the shadow root.
12
+ *
13
+ * No-JS: Tier 2. Before the first measure the tiles render as named groups with no tab stop,
14
+ * grips or instructions.
15
+ */
16
+ export declare class MintTileManagerElement extends LitElement {
17
+ #private;
18
+ static styles: import('lit').CSSResult;
19
+ static properties: {
20
+ tiles: {
21
+ attribute: boolean;
22
+ };
23
+ layouts: {
24
+ attribute: boolean;
25
+ };
26
+ breakpoints: {
27
+ attribute: boolean;
28
+ };
29
+ stackBelow: {
30
+ type: NumberConstructor;
31
+ attribute: string;
32
+ };
33
+ maxColumns: {
34
+ type: NumberConstructor;
35
+ attribute: string;
36
+ };
37
+ minColumnWidth: {
38
+ type: NumberConstructor;
39
+ attribute: string;
40
+ };
41
+ minRowHeight: {
42
+ type: StringConstructor;
43
+ attribute: string;
44
+ };
45
+ gap: {
46
+ type: NumberConstructor;
47
+ };
48
+ dragMode: {
49
+ type: StringConstructor;
50
+ attribute: string;
51
+ reflect: boolean;
52
+ };
53
+ resizeMode: {
54
+ type: StringConstructor;
55
+ attribute: string;
56
+ reflect: boolean;
57
+ };
58
+ animateReflow: {
59
+ type: BooleanConstructor;
60
+ attribute: string;
61
+ };
62
+ label: {
63
+ type: StringConstructor;
64
+ };
65
+ messages: {
66
+ attribute: boolean;
67
+ };
68
+ };
69
+ tiles: readonly MintTile[];
70
+ /** Per column count; two-way through `layoutchange`'s `layouts`. */
71
+ layouts: TileLayouts;
72
+ breakpoints: readonly TileBreakpoint[] | null;
73
+ stackBelow: number | null;
74
+ maxColumns: number;
75
+ /** px */
76
+ minColumnWidth: number;
77
+ minRowHeight: string;
78
+ /** px */
79
+ gap: number;
80
+ dragMode: TileDragMode;
81
+ resizeMode: TileResizeMode;
82
+ animateReflow: boolean;
83
+ label: string | null;
84
+ messages: Partial<TileManagerMessages>;
85
+ readonly machine: TileManagerMachine;
86
+ constructor();
87
+ /** What is rendered: the resolved column count and its layout (the preview while editing). */
88
+ captureLayout(): {
89
+ columnCount: number;
90
+ layout: TileLayoutSnapshot;
91
+ };
92
+ /** Drops `layouts[count]` and commits, so that count derives again (D15). */
93
+ resetLayout(count: number): void;
94
+ /** True while a pointer drag or resize is in flight. */
95
+ get isGestureActive(): boolean;
96
+ connectedCallback(): void;
97
+ disconnectedCallback(): void;
98
+ protected willUpdate(changed: PropertyValues<this>): void;
99
+ protected firstUpdated(): void;
100
+ protected updated(): void;
101
+ render(): TemplateResult;
102
+ }
103
+ declare global {
104
+ interface HTMLElementTagNameMap {
105
+ 'mp-tile-manager': MintTileManagerElement;
106
+ }
107
+ }
@@ -1,4 +1,3 @@
1
1
  export { MintTileManagerElement } from './components';
2
- export type { MintTile, TileDragMode, TileResizeMode } from './components';
3
- export * from './types';
4
- export * from './utils';
2
+ export { withoutNarrowerLayouts } from '@mintplayer/ui-core/tile-manager';
3
+ export type { MintTile, TileBreakpoint, TileDragMode, TileGestureBlocked, TileLayoutChange, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TilePosition, TileResizeMode, TileSize, } from '@mintplayer/ui-core/tile-manager';
@@ -4,10 +4,11 @@ import { t as o } from "../chunks/overlay-kT0nfzL-.mjs";
4
4
  import "../chunks/treeview-BuznGbcj.mjs";
5
5
  import { LitElement as s, nothing as c, unsafeCSS as l } from "lit";
6
6
  import { repeat as u } from "lit/directives/repeat.js";
7
+ import { SupersedingRequest as d } from "@mintplayer/ui-core/async";
7
8
  //#region libs/mintplayer-web-components/tree-select/src/styles/tree-select.light.styles.ts
8
- var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n position: relative;\n font-family: inherit;\n font-size: 1rem;\n color: var(--bs-body-color, #212529);\n --ts-border: var(--bs-border-color, #dee2e6);\n --ts-primary: var(--bs-primary, #0d6efd);\n --ts-radius: var(--bs-border-radius, 0.375rem);\n --ts-muted: var(--bs-secondary-color, #6c757d);\n}\n\nmp-tree-select[disabled] {\n opacity: 0.65;\n pointer-events: none;\n}\n\n[data-mps=tree-select] {\n box-sizing: border-box;\n}\n\nbutton[data-mps=tree-select] {\n font-family: inherit;\n font-size: inherit;\n}\n\n.ts-control[data-mps=tree-select] {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 0.25rem;\n width: 100%;\n min-height: calc(1.5em + 0.75rem + 2px);\n padding: 0.25rem 0.5rem;\n background: var(--bs-body-bg, #fff);\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n cursor: text;\n}\n\n.ts-control:focus-within[data-mps=tree-select] {\n border-color: var(--ts-primary);\n box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);\n}\n\n.ts-button[data-mps=tree-select] {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n width: 100%;\n min-height: calc(1.5em + 0.75rem + 2px);\n padding: 0.375rem 0.75rem;\n background: var(--bs-body-bg, #fff);\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n cursor: pointer;\n text-align: start;\n}\n\n.ts-button:focus-visible[data-mps=tree-select] {\n outline: none;\n border-color: var(--ts-primary);\n box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);\n}\n\n.ts-button-body[data-mps=tree-select] {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 0.25rem;\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.ts-placeholder[data-mps=tree-select] {\n color: var(--ts-muted);\n}\n\n.ts-single-value[data-mps=tree-select] {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ts-search[data-mps=tree-select] {\n flex: 1 1 4rem;\n min-width: 4rem;\n border: 0;\n outline: 0;\n padding: 0.125rem;\n background: transparent;\n color: inherit;\n font: inherit;\n}\n\n.ts-search.panel-search[data-mps=tree-select] {\n flex: 1 1 auto;\n width: 100%;\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n padding: 0.375rem 0.5rem;\n}\n\n.ts-chip[data-mps=tree-select] {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n flex: 0 0 auto;\n max-width: 100%;\n padding: 0.125rem 0.375rem;\n background: var(--bs-secondary-bg, #e9ecef);\n border-radius: var(--ts-radius);\n font-size: 0.875em;\n line-height: 1.2;\n}\n\n.ts-chip-label[data-mps=tree-select] {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ts-chip-remove[data-mps=tree-select],\n.ts-clear[data-mps=tree-select] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n background: transparent;\n color: inherit;\n cursor: pointer;\n padding: 0;\n line-height: 1;\n font-size: 1em;\n opacity: 0.7;\n}\n\n.ts-chip-remove:hover[data-mps=tree-select],\n.ts-clear:hover[data-mps=tree-select] {\n opacity: 1;\n}\n\n.ts-clear[data-mps=tree-select] {\n flex: 0 0 auto;\n margin-inline-start: auto;\n font-size: 1.1em;\n}\n\n.ts-caret[data-mps=tree-select] {\n flex: 0 0 auto;\n display: inline-flex;\n width: 0.8em;\n height: 0.8em;\n color: var(--ts-muted);\n transition: transform 0.15s ease;\n}\n\n.ts-caret-icon[data-mps=tree-select] {\n display: inline-flex;\n width: 100%;\n height: 100%;\n}\n\nmp-tree-select[data-menu-open] .ts-caret[data-mps=tree-select] {\n transform: rotate(180deg);\n}\n\n.ts-panel[data-mps=tree-select] {\n position: fixed;\n z-index: 1056;\n display: none;\n flex-direction: column;\n background: var(--bs-body-bg, #fff);\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);\n overflow: hidden;\n}\n\nmp-tree-select[data-menu-open] .ts-panel[data-mps=tree-select] {\n display: flex;\n}\n\n.ts-panel-header[data-mps=tree-select],\n.ts-panel-footer[data-mps=tree-select] {\n flex: 0 0 auto;\n padding: 0.5rem;\n border-bottom: 1px solid var(--ts-border);\n}\n\n.ts-panel-footer[data-mps=tree-select] {\n border-bottom: 0;\n border-top: 1px solid var(--ts-border);\n}\n\n.ts-panel-body[data-mps=tree-select] {\n flex: 1 1 auto;\n overflow: auto;\n max-height: var(--mp-tree-select-panel-max-height, 300px);\n}\n\n.ts-state[data-mps=tree-select] {\n padding: 0.75rem;\n color: var(--ts-muted);\n text-align: center;\n}\n\n.ts-load-more[data-mps=tree-select] {\n display: block;\n width: 100%;\n padding: 0.375rem;\n border: 0;\n border-top: 1px solid var(--ts-border);\n background: transparent;\n color: var(--ts-primary);\n cursor: pointer;\n font: inherit;\n}\n\n.ts-load-more:hover[data-mps=tree-select] {\n background: var(--bs-secondary-bg, #e9ecef);\n}\n\n.ts-spinner[data-mps=tree-select] {\n display: inline-block;\n width: 1rem;\n height: 1rem;\n border: 0.15em solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: ts-spin 0.75s linear infinite;\n vertical-align: -0.125em;\n}\n\n@keyframes ts-spin {\n to {\n transform: rotate(360deg);\n }\n}\n.ts-node[data-mps=tree-select] {\n display: inline-flex;\n align-items: center;\n gap: 0.4rem;\n}\n\n.ts-node-check[data-mps=tree-select] {\n flex: 0 0 auto;\n margin: 0;\n cursor: pointer;\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-mps=tree-select] {\n transition-duration: 0.01ms !important;\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n }\n}"), f = i("tree-select"), p = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\" width=\"100%\" height=\"100%\"><path d=\"M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z\"/></svg>", m = class extends s {
9
+ var f = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n position: relative;\n font-family: inherit;\n font-size: 1rem;\n color: var(--bs-body-color, #212529);\n --ts-border: var(--bs-border-color, #dee2e6);\n --ts-primary: var(--bs-primary, #0d6efd);\n --ts-radius: var(--bs-border-radius, 0.375rem);\n --ts-muted: var(--bs-secondary-color, #6c757d);\n}\n\nmp-tree-select[disabled] {\n opacity: 0.65;\n pointer-events: none;\n}\n\n[data-mps=tree-select] {\n box-sizing: border-box;\n}\n\nbutton[data-mps=tree-select] {\n font-family: inherit;\n font-size: inherit;\n}\n\n.ts-control[data-mps=tree-select] {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 0.25rem;\n width: 100%;\n min-height: calc(1.5em + 0.75rem + 2px);\n padding: 0.25rem 0.5rem;\n background: var(--bs-body-bg, #fff);\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n cursor: text;\n}\n\n.ts-control:focus-within[data-mps=tree-select] {\n border-color: var(--ts-primary);\n box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);\n}\n\n.ts-button[data-mps=tree-select] {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n width: 100%;\n min-height: calc(1.5em + 0.75rem + 2px);\n padding: 0.375rem 0.75rem;\n background: var(--bs-body-bg, #fff);\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n cursor: pointer;\n text-align: start;\n}\n\n.ts-button:focus-visible[data-mps=tree-select] {\n outline: none;\n border-color: var(--ts-primary);\n box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);\n}\n\n.ts-button-body[data-mps=tree-select] {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 0.25rem;\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.ts-placeholder[data-mps=tree-select] {\n color: var(--ts-muted);\n}\n\n.ts-single-value[data-mps=tree-select] {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ts-search[data-mps=tree-select] {\n flex: 1 1 4rem;\n min-width: 4rem;\n border: 0;\n outline: 0;\n padding: 0.125rem;\n background: transparent;\n color: inherit;\n font: inherit;\n}\n\n.ts-search.panel-search[data-mps=tree-select] {\n flex: 1 1 auto;\n width: 100%;\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n padding: 0.375rem 0.5rem;\n}\n\n.ts-chip[data-mps=tree-select] {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n flex: 0 0 auto;\n max-width: 100%;\n padding: 0.125rem 0.375rem;\n background: var(--bs-secondary-bg, #e9ecef);\n border-radius: var(--ts-radius);\n font-size: 0.875em;\n line-height: 1.2;\n}\n\n.ts-chip-label[data-mps=tree-select] {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ts-chip-remove[data-mps=tree-select],\n.ts-clear[data-mps=tree-select] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n background: transparent;\n color: inherit;\n cursor: pointer;\n padding: 0;\n line-height: 1;\n font-size: 1em;\n opacity: 0.7;\n}\n\n.ts-chip-remove:hover[data-mps=tree-select],\n.ts-clear:hover[data-mps=tree-select] {\n opacity: 1;\n}\n\n.ts-clear[data-mps=tree-select] {\n flex: 0 0 auto;\n margin-inline-start: auto;\n font-size: 1.1em;\n}\n\n.ts-caret[data-mps=tree-select] {\n flex: 0 0 auto;\n display: inline-flex;\n width: 0.8em;\n height: 0.8em;\n color: var(--ts-muted);\n transition: transform 0.15s ease;\n}\n\n.ts-caret-icon[data-mps=tree-select] {\n display: inline-flex;\n width: 100%;\n height: 100%;\n}\n\nmp-tree-select[data-menu-open] .ts-caret[data-mps=tree-select] {\n transform: rotate(180deg);\n}\n\n.ts-panel[data-mps=tree-select] {\n position: fixed;\n z-index: 1056;\n display: none;\n flex-direction: column;\n background: var(--bs-body-bg, #fff);\n border: 1px solid var(--ts-border);\n border-radius: var(--ts-radius);\n box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);\n overflow: hidden;\n}\n\nmp-tree-select[data-menu-open] .ts-panel[data-mps=tree-select] {\n display: flex;\n}\n\n.ts-panel-header[data-mps=tree-select],\n.ts-panel-footer[data-mps=tree-select] {\n flex: 0 0 auto;\n padding: 0.5rem;\n border-bottom: 1px solid var(--ts-border);\n}\n\n.ts-panel-footer[data-mps=tree-select] {\n border-bottom: 0;\n border-top: 1px solid var(--ts-border);\n}\n\n.ts-panel-body[data-mps=tree-select] {\n flex: 1 1 auto;\n overflow: auto;\n max-height: var(--mp-tree-select-panel-max-height, 300px);\n}\n\n.ts-state[data-mps=tree-select] {\n padding: 0.75rem;\n color: var(--ts-muted);\n text-align: center;\n}\n\n.ts-load-more[data-mps=tree-select] {\n display: block;\n width: 100%;\n padding: 0.375rem;\n border: 0;\n border-top: 1px solid var(--ts-border);\n background: transparent;\n color: var(--ts-primary);\n cursor: pointer;\n font: inherit;\n}\n\n.ts-load-more:hover[data-mps=tree-select] {\n background: var(--bs-secondary-bg, #e9ecef);\n}\n\n.ts-spinner[data-mps=tree-select] {\n display: inline-block;\n width: 1rem;\n height: 1rem;\n border: 0.15em solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: ts-spin 0.75s linear infinite;\n vertical-align: -0.125em;\n}\n\n@keyframes ts-spin {\n to {\n transform: rotate(360deg);\n }\n}\n.ts-node[data-mps=tree-select] {\n display: inline-flex;\n align-items: center;\n gap: 0.4rem;\n}\n\n.ts-node-check[data-mps=tree-select] {\n flex: 0 0 auto;\n margin: 0;\n cursor: pointer;\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-mps=tree-select] {\n transition-duration: 0.01ms !important;\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n }\n}"), p = i("tree-select"), m = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\" width=\"100%\" height=\"100%\"><path d=\"M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z\"/></svg>", h = class extends s {
9
10
  constructor(...t) {
10
- super(...t), this._mode = "single", this._variant = "textbox", this._cascadeSelect = !1, this._placeholder = "", this._showClear = !1, this._scrollHeight = "300px", this._inputLabel = null, this._searchLabel = null, this._clearLabel = "Clear", this.removeLabel = (e) => `Remove ${e}`, this.hostAria = new e(this, { referenceTarget: () => this.renderRoot?.querySelector("input.ts-search") ?? null }), this._disabled = !1, this._searchDebounceMs = 200, this._nodes = [], this._searchResults = null, this.liveAnnouncer = new n(this), this._query = "", this._loading = !1, this._rootsLoaded = !1, this._rootsHasMore = !1, this._searchHasMore = !1, this._byId = /* @__PURE__ */ new Map(), this._parentById = /* @__PURE__ */ new Map(), this._selected = /* @__PURE__ */ new Map(), this._indeterminate = /* @__PURE__ */ new Set(), this._debounceTimer = 0, this.overlay = new o(this, {
11
+ super(...t), this._mode = "single", this._variant = "textbox", this._cascadeSelect = !1, this._placeholder = "", this._showClear = !1, this._scrollHeight = "300px", this._inputLabel = null, this._searchLabel = null, this._clearLabel = "Clear", this.removeLabel = (e) => `Remove ${e}`, this.hostAria = new e(this, { referenceTarget: () => this.renderRoot?.querySelector("input.ts-search") ?? null }), this._disabled = !1, this._searchDebounceMs = 200, this._nodes = [], this._searchResults = null, this.liveAnnouncer = new n(this), this._query = "", this._loading = !1, this._rootsLoaded = !1, this._rootsHasMore = !1, this._searchHasMore = !1, this._byId = /* @__PURE__ */ new Map(), this._parentById = /* @__PURE__ */ new Map(), this._selected = /* @__PURE__ */ new Map(), this._indeterminate = /* @__PURE__ */ new Set(), this._runner = this.createRunner(200), this.overlay = new o(this, {
11
12
  anchor: () => this.renderRoot.querySelector(".ts-anchor"),
12
13
  panel: () => this.renderRoot.querySelector(".ts-panel"),
13
14
  panelWidth: "anchor-min",
@@ -129,7 +130,20 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
129
130
  return this._searchDebounceMs;
130
131
  }
131
132
  set searchDebounceMs(e) {
132
- this._searchDebounceMs = Math.max(0, Number(e) || 0);
133
+ let t = Math.max(0, Number(e) || 0);
134
+ t !== this._searchDebounceMs && (this._searchDebounceMs = t, this._runner.dispose(), this._runner = this.createRunner(t));
135
+ }
136
+ createRunner(e) {
137
+ return new d({
138
+ debounceMs: e,
139
+ onError: (e) => {
140
+ this._loading = !1, this.dispatchEvent(new CustomEvent("load-error", {
141
+ detail: { error: e },
142
+ bubbles: !0,
143
+ composed: !0
144
+ })), this.requestUpdate();
145
+ }
146
+ });
133
147
  }
134
148
  attributeChangedCallback(e, t, n) {
135
149
  switch (super.attributeChangedCallback(e, t, n), e) {
@@ -193,7 +207,7 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
193
207
  this.hostAria.syncReferences();
194
208
  }
195
209
  disconnectedCallback() {
196
- super.disconnectedCallback(), this._abort?.abort(), this._debounceTimer && clearTimeout(this._debounceTimer);
210
+ super.disconnectedCallback(), this._runner.cancel();
197
211
  }
198
212
  indexNodes(e, t) {
199
213
  for (let n of e) this._byId.set(n.id, n), this._parentById.set(n.id, t), n.children?.length && this.indexNodes(n.children, n);
@@ -212,48 +226,42 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
212
226
  }));
213
227
  n && (this._nodes = e ? [...this._nodes, ...n.nodes] : n.nodes, this._rootsHasMore = !!n.hasMore, this._rootsLoaded = !0, this.reindexActive(), this.requestUpdate());
214
228
  }
215
- async runSearch(e) {
229
+ async runSearch(e, t = !1) {
216
230
  if (!this._provider) return;
217
- let t = this._query, n = e ? this._searchResults?.length ?? 0 : 0, r = await this.runRequest((e) => this._provider.search(t, {
218
- offset: n,
231
+ let n = this._query, r = e ? this._searchResults?.length ?? 0 : 0, i = await this.runRequest((e) => this._provider.search(n, {
232
+ offset: r,
219
233
  signal: e
220
- }));
221
- if (r) {
222
- if (this._searchResults = e ? [...this._searchResults ?? [], ...r.nodes] : r.nodes, !e) {
234
+ }), {
235
+ debounced: t,
236
+ onStart: () => this.dispatchSearchEvent()
237
+ });
238
+ if (i) {
239
+ if (this._searchResults = e ? [...this._searchResults ?? [], ...i.nodes] : i.nodes, !e) {
223
240
  let e = this._searchResults.length;
224
241
  this.liveAnnouncer.announce(e === 1 ? "1 result." : `${e} results.`);
225
242
  }
226
- this._searchHasMore = !!r.hasMore, this.reindexActive(), this.requestUpdate();
243
+ this._searchHasMore = !!i.hasMore, this.reindexActive(), this.requestUpdate();
227
244
  }
228
245
  }
229
- async runRequest(e) {
230
- this._abort?.abort();
231
- let t = new AbortController();
232
- this._abort = t, this._loading = !0, this.requestUpdate();
233
- try {
234
- let n = await e(t.signal);
235
- return t.signal.aborted ? null : (this._loading = !1, this.requestUpdate(), n);
236
- } catch (e) {
237
- return t.signal.aborted || e?.name === "AbortError" || (this._loading = !1, this.dispatchEvent(new CustomEvent("load-error", {
238
- detail: { error: e },
239
- bubbles: !0,
240
- composed: !0
241
- })), this.requestUpdate()), null;
242
- }
246
+ async runRequest(e, t = {}) {
247
+ this._loading = !0, this.requestUpdate();
248
+ let n = await this._runner.run(({ signal: n }) => (t.onStart?.(), e(n)), { debounceMs: t.debounced ? void 0 : 0 });
249
+ return n.aborted ? null : (this._loading = !1, this.requestUpdate(), n.value);
250
+ }
251
+ dispatchSearchEvent() {
252
+ this.dispatchEvent(new CustomEvent("search", {
253
+ detail: { query: this._query },
254
+ bubbles: !0,
255
+ composed: !0
256
+ }));
243
257
  }
244
258
  onLoadMore() {
245
259
  this._query ? this.runSearch(!0) : this.loadRoots(!0);
246
260
  }
247
261
  onSearchInput(e) {
248
- this._query = e.target.value, this.overlay.isOpen || this.open(), this._debounceTimer && clearTimeout(this._debounceTimer);
249
- let t = () => {
250
- this._query.trim() ? this.runSearch(!1) : (this._abort?.abort(), this._searchResults = null, this._loading = !1, this.reindexActive(), this.requestUpdate()), this.dispatchEvent(new CustomEvent("search", {
251
- detail: { query: this._query },
252
- bubbles: !0,
253
- composed: !0
254
- }));
255
- };
256
- this._searchDebounceMs > 0 ? this._debounceTimer = window.setTimeout(t, this._searchDebounceMs) : t();
262
+ this._query = e.target.value, this.overlay.isOpen || this.open(), this._query.trim() ? this.runSearch(!1, !0) : this._runner.run(async () => {
263
+ this._searchResults = null, this._loading = !1, this.reindexActive(), this.requestUpdate(), this.dispatchSearchEvent();
264
+ }).then(() => void 0);
257
265
  }
258
266
  async open() {
259
267
  !this._disabled && this._provider && (await this.ensureRoots(), await this.overlay.open(), this.dispatchEvent(new CustomEvent("open", {
@@ -265,7 +273,7 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
265
273
  this.overlay.close();
266
274
  }
267
275
  onPanelClosed() {
268
- (this._query || this._searchResults) && (this._abort?.abort(), this._query = "", this._searchResults = null, this._loading = !1, this.reindexActive(), this.requestUpdate()), this.dispatchEvent(new CustomEvent("close", {
276
+ (this._query || this._searchResults) && (this._runner.cancel(), this._query = "", this._searchResults = null, this._loading = !1, this.reindexActive(), this.requestUpdate()), this.dispatchEvent(new CustomEvent("close", {
269
277
  bubbles: !0,
270
278
  composed: !0
271
279
  }));
@@ -361,7 +369,7 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
361
369
  }), this._nodeRendererFn;
362
370
  }
363
371
  render() {
364
- return f`
372
+ return p`
365
373
  ${this.liveAnnouncer.template()}${this.renderTrigger()}${this.renderPanel()}`;
366
374
  }
367
375
  get hasSelection() {
@@ -371,7 +379,7 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
371
379
  return this._variant === "button" ? this.renderButtonTrigger() : this.renderTextboxTrigger();
372
380
  }
373
381
  renderButtonTrigger() {
374
- return f`
382
+ return p`
375
383
  <button
376
384
  class="ts-button ts-anchor"
377
385
  type="button"
@@ -388,10 +396,10 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
388
396
  }
389
397
  renderTextboxTrigger() {
390
398
  let e = this._mode === "single" && this.hasSelection && !this._query;
391
- return f`
399
+ return p`
392
400
  <div class="ts-control ts-anchor" @click=${() => this.focusSearchAndOpen()}>
393
401
  ${this.renderChips()}
394
- ${e ? f`<span class="ts-single-value">${this.renderSelectedLabel()}</span>` : c}
402
+ ${e ? p`<span class="ts-single-value">${this.renderSelectedLabel()}</span>` : c}
395
403
  <input
396
404
  class="ts-search"
397
405
  type="text"
@@ -413,14 +421,14 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
413
421
  `;
414
422
  }
415
423
  renderTriggerBody() {
416
- return this.buttonTemplate ? this.buttonTemplate(this.value) : this.hasSelection ? this._mode === "single" ? this.renderSelectedLabel() : this.renderChips() : f`<span class="ts-placeholder">${this._placeholder}</span>`;
424
+ return this.buttonTemplate ? this.buttonTemplate(this.value) : this.hasSelection ? this._mode === "single" ? this.renderSelectedLabel() : this.renderChips() : p`<span class="ts-placeholder">${this._placeholder}</span>`;
417
425
  }
418
426
  renderSelectedLabel() {
419
427
  let e = this._selected.values().next().value;
420
428
  return e ? this.itemTemplate ? this.itemTemplate(e, this._query) : e.label : c;
421
429
  }
422
430
  renderChips() {
423
- return this._mode === "single" || !this.hasSelection ? c : u([...this._selected.values()], (e) => e.id, (e) => f`
431
+ return this._mode === "single" || !this.hasSelection ? c : u([...this._selected.values()], (e) => e.id, (e) => p`
424
432
  <span class="ts-chip">
425
433
  <span class="ts-chip-label"
426
434
  >${this.itemTemplate ? this.itemTemplate(e, this._query) : e.label}</span
@@ -439,7 +447,7 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
439
447
  `);
440
448
  }
441
449
  renderClear() {
442
- return !this._showClear || !this.hasSelection ? c : f`<button
450
+ return !this._showClear || !this.hasSelection ? c : p`<button
443
451
  class="ts-clear"
444
452
  type="button"
445
453
  aria-label=${this._clearLabel}
@@ -450,13 +458,13 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
450
458
  }
451
459
  renderCaret() {
452
460
  let e = document.createElement("span");
453
- return e.className = "ts-caret-icon", e.innerHTML = p, a(e, "tree-select"), e;
461
+ return e.className = "ts-caret-icon", e.innerHTML = m, a(e, "tree-select"), e;
454
462
  }
455
463
  renderPanel() {
456
- return f`
464
+ return p`
457
465
  <div class="ts-panel" role="dialog" aria-busy=${this._loading ? "true" : c}>
458
- ${this.headerTemplate ? f`<div class="ts-panel-header">${this.headerTemplate()}</div>` : c}
459
- ${this._variant === "button" ? f`<div class="ts-panel-header">
466
+ ${this.headerTemplate ? p`<div class="ts-panel-header">${this.headerTemplate()}</div>` : c}
467
+ ${this._variant === "button" ? p`<div class="ts-panel-header">
460
468
  <input
461
469
  class="ts-search panel-search"
462
470
  type="text"
@@ -468,17 +476,17 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
468
476
  </div>` : c}
469
477
  <div class="ts-panel-body">${this.renderBody()}</div>
470
478
  ${this.renderLoadMore()}
471
- ${this.footerTemplate ? f`<div class="ts-panel-footer">${this.footerTemplate()}</div>` : c}
479
+ ${this.footerTemplate ? p`<div class="ts-panel-footer">${this.footerTemplate()}</div>` : c}
472
480
  </div>
473
481
  `;
474
482
  }
475
483
  renderBody() {
476
- if (!this._provider) return f`<div class="ts-state">No data provider</div>`;
484
+ if (!this._provider) return p`<div class="ts-state">No data provider</div>`;
477
485
  let e = !!this._query.trim();
478
- return this._loading && (e ? this._searchResults === null : !this._rootsLoaded) ? f`<div class="ts-state"><span class="ts-spinner"></span></div>` : e ? this._searchResults?.length ? this.renderTreeview(this._searchResults) : f`<div class="ts-state">${this.noResultsTemplate ? this.noResultsTemplate() : "No results"}</div>` : this._nodes.length ? this.renderTreeview(this._nodes) : f`<div class="ts-state">${this.enterSearchTermTemplate ? this.enterSearchTermTemplate() : "No items"}</div>`;
486
+ return this._loading && (e ? this._searchResults === null : !this._rootsLoaded) ? p`<div class="ts-state"><span class="ts-spinner"></span></div>` : e ? this._searchResults?.length ? this.renderTreeview(this._searchResults) : p`<div class="ts-state">${this.noResultsTemplate ? this.noResultsTemplate() : "No results"}</div>` : this._nodes.length ? this.renderTreeview(this._nodes) : p`<div class="ts-state">${this.enterSearchTermTemplate ? this.enterSearchTermTemplate() : "No items"}</div>`;
479
487
  }
480
488
  renderTreeview(e) {
481
- return f`
489
+ return p`
482
490
  <mp-treeview
483
491
  hide-borders
484
492
  .items=${e}
@@ -491,15 +499,15 @@ var d = l("mp-tree-select {\n display: inline-block;\n width: 100%;\n positio
491
499
  `;
492
500
  }
493
501
  renderLoadMore() {
494
- return (this._query ? this._searchHasMore : this._rootsHasMore) ? f`<button class="ts-load-more" type="button" @click=${() => this.onLoadMore()}>
495
- ${this._loading ? f`<span class="ts-spinner"></span>` : "Load more"}
502
+ return (this._query ? this._searchHasMore : this._rootsHasMore) ? p`<button class="ts-load-more" type="button" @click=${() => this.onLoadMore()}>
503
+ ${this._loading ? p`<span class="ts-spinner"></span>` : "Load more"}
496
504
  </button>` : c;
497
505
  }
498
506
  };
499
- r("tree-select", d), typeof customElements < "u" && !customElements.get("mp-tree-select") && customElements.define("mp-tree-select", m);
507
+ r("tree-select", f), typeof customElements < "u" && !customElements.get("mp-tree-select") && customElements.define("mp-tree-select", h);
500
508
  //#endregion
501
509
  //#region libs/mintplayer-web-components/tree-select/src/providers/in-memory-provider.ts
502
- var h = class {
510
+ var g = class {
503
511
  constructor(e, t = {}) {
504
512
  this.tree = e, this.byId = /* @__PURE__ */ new Map(), this.flat = [], this.pageSize = t.pageSize ?? 50, this.delayMs = t.delayMs ?? 0;
505
513
  let n = (e) => {
@@ -538,4 +546,4 @@ var h = class {
538
546
  }
539
547
  };
540
548
  //#endregion
541
- export { h as InMemoryTreeSelectProvider, m as MpTreeSelect, d as treeSelectLightStyles };
549
+ export { g as InMemoryTreeSelectProvider, h as MpTreeSelect, f as treeSelectLightStyles };
@@ -58,8 +58,12 @@ export declare class MpTreeSelect extends LitElement {
58
58
  private readonly _parentById;
59
59
  private _selected;
60
60
  private readonly _indeterminate;
61
- private _abort?;
62
- private _debounceTimer;
61
+ /**
62
+ * One request lifecycle for roots, search and load-more: the newest call
63
+ * aborts the previous one and a late answer never lands. Shared with the
64
+ * typeahead and the datatable (`@mintplayer/ui-core/async`, #436 D4).
65
+ */
66
+ private _runner;
63
67
  private readonly overlay;
64
68
  get provider(): TreeSelectProvider | undefined;
65
69
  set provider(value: TreeSelectProvider | undefined);
@@ -81,6 +85,7 @@ export declare class MpTreeSelect extends LitElement {
81
85
  set disabled(value: boolean);
82
86
  get searchDebounceMs(): number;
83
87
  set searchDebounceMs(value: number);
88
+ private createRunner;
84
89
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
85
90
  /**
86
91
  * Optional accessible name for the control (the main search input). Without
@@ -108,8 +113,14 @@ export declare class MpTreeSelect extends LitElement {
108
113
  private ensureRoots;
109
114
  private loadRoots;
110
115
  private runSearch;
111
- /** Run a provider call with abort + loading bookkeeping. Returns null on abort/error. */
116
+ /**
117
+ * Run a provider call through the shared runner with loading bookkeeping.
118
+ * Returns null on abort or error (the runner has already dispatched
119
+ * `load-error` for an error). `debounced` waits out `searchDebounceMs`;
120
+ * `onStart` fires when the call actually begins (after the wait).
121
+ */
112
122
  private runRequest;
123
+ private dispatchSearchEvent;
113
124
  /** Lazy children loader wired into the embedded `mp-treeview`. */
114
125
  private readonly treeviewLoadChildren;
115
126
  private onLoadMore;
@@ -119,8 +130,8 @@ export declare class MpTreeSelect extends LitElement {
119
130
  private onPanelClosed;
120
131
  private onTriggerClick;
121
132
  /**
122
- * The BsComboboxDirective contract, inside the shadow root where the
123
- * directive cannot reach: ArrowDown opens the popup (and a second ArrowDown
133
+ * The combobox keyboard contract (the same keys the typeahead core owns):
134
+ * ArrowDown opens the popup (and a second ArrowDown
124
135
  * hands focus to the tree, whose own roving model takes over); Escape closes
125
136
  * unconditionally and keeps focus in the input. aria-expanded re-renders with
126
137
  * the overlay state, so it is live rather than a first-render snapshot.
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,220 @@
1
+ import { i as e, t } from "../chunks/a11y-C6aX-lsZ.mjs";
2
+ import { installLightStyles as n, scopedHtml as r } from "../light-dom/index.mjs";
3
+ import { MachineController as i, props as a } from "../machine/index.mjs";
4
+ import { LitElement as o, nothing as s } from "lit";
5
+ import { repeat as c } from "lit/directives/repeat.js";
6
+ import { live as l } from "lit/directives/live.js";
7
+ import { TYPEAHEAD_SCOPE as u, TypeaheadMachine as d, connect as f, inMemoryTypeaheadProvider as p, typeaheadScopedStyles as m, typeaheadScopedStyles as h } from "@mintplayer/ui-core/typeahead";
8
+ //#region libs/mintplayer-web-components/typeahead/src/components/mp-typeahead.ts
9
+ var g = r(u), _ = 0, v = [
10
+ "value",
11
+ "name",
12
+ "disabled",
13
+ "debounce-ms",
14
+ "min-length",
15
+ "input-label",
16
+ "loading-label",
17
+ "no-results-label",
18
+ "error-text",
19
+ "aria-label"
20
+ ], y = class extends t(o) {
21
+ static get observedAttributes() {
22
+ return [...super.observedAttributes ?? [], ...v];
23
+ }
24
+ createRenderRoot() {
25
+ return this;
26
+ }
27
+ #e = `mp-typeahead-${++_}`;
28
+ #t = new i(this, new d({
29
+ id: this.#e,
30
+ onChange: (e) => this.#u("value-change", { value: e }),
31
+ onSelect: (e, t) => this.#u("select", {
32
+ item: e,
33
+ value: t
34
+ }),
35
+ onSubmit: (e) => this.#u("submit", { value: e }),
36
+ onOpen: () => this.#u("open"),
37
+ onClose: () => this.#u("close"),
38
+ onSearch: (e) => this.#u("search", { term: e }),
39
+ onError: (e) => this.#u("load-error", { error: e })
40
+ }));
41
+ #n = new e(this, { referenceTarget: () => this.querySelector(`input[data-mps=${u}]`) });
42
+ #r = null;
43
+ #i = !1;
44
+ #a = "";
45
+ #o = null;
46
+ #s = null;
47
+ get machine() {
48
+ return this.#t.machine;
49
+ }
50
+ get value() {
51
+ return this.machine.snapshot.term;
52
+ }
53
+ set value(e) {
54
+ this.machine.setValue(e);
55
+ }
56
+ get selectedItem() {
57
+ return this.machine.snapshot.selectedItem;
58
+ }
59
+ get provider() {
60
+ return this.machine.provider;
61
+ }
62
+ set provider(e) {
63
+ this.machine.provider = e;
64
+ }
65
+ get debounceMs() {
66
+ return this.machine.debounceMs;
67
+ }
68
+ set debounceMs(e) {
69
+ this.machine.debounceMs = e;
70
+ }
71
+ get minLength() {
72
+ return this.machine.minLength;
73
+ }
74
+ set minLength(e) {
75
+ this.machine.minLength = e;
76
+ }
77
+ set itemText(e) {
78
+ this.machine.itemText = e, this.requestUpdate();
79
+ }
80
+ set itemKey(e) {
81
+ this.machine.itemKey = e, this.requestUpdate();
82
+ }
83
+ get itemRenderer() {
84
+ return this.#s;
85
+ }
86
+ set itemRenderer(e) {
87
+ this.#s = e, this.requestUpdate();
88
+ }
89
+ set resultsLabel(e) {
90
+ e && this.machine.setLabels({ results: e });
91
+ }
92
+ get name() {
93
+ return this.#r;
94
+ }
95
+ set name(e) {
96
+ this.#r = e ?? null, this.requestUpdate();
97
+ }
98
+ get disabled() {
99
+ return this.#i;
100
+ }
101
+ set disabled(e) {
102
+ let t = !!e;
103
+ t !== this.#i && (this.#i = t, this.toggleAttribute("disabled", t), this.requestUpdate());
104
+ }
105
+ get errorText() {
106
+ return this.machine.snapshot.errorText;
107
+ }
108
+ set errorText(e) {
109
+ this.machine.setErrorText(e);
110
+ }
111
+ attributeChangedCallback(e, t, n) {
112
+ switch (super.attributeChangedCallback(e, t, n), e) {
113
+ case "value":
114
+ this.#a = n ?? "", this.machine.setValue(n ?? "");
115
+ break;
116
+ case "name":
117
+ this.name = n;
118
+ break;
119
+ case "disabled":
120
+ this.#i = n !== null, this.requestUpdate();
121
+ break;
122
+ case "debounce-ms": {
123
+ let e = n === null ? NaN : Number(n);
124
+ this.machine.debounceMs = Number.isFinite(e) ? e : void 0;
125
+ break;
126
+ }
127
+ case "min-length": {
128
+ let e = n === null ? NaN : Number(n);
129
+ this.machine.minLength = Number.isFinite(e) ? e : void 0;
130
+ break;
131
+ }
132
+ case "input-label":
133
+ this.#o = n, this.#c();
134
+ break;
135
+ case "aria-label":
136
+ this.#c();
137
+ break;
138
+ case "loading-label":
139
+ case "no-results-label": {
140
+ let t = e === "loading-label" ? "loading" : "noResults";
141
+ n !== null && this.machine.setLabels({ [t]: n });
142
+ break;
143
+ }
144
+ case "error-text": this.machine.setErrorText(n);
145
+ }
146
+ }
147
+ #c() {
148
+ this.machine.setLabels({ input: this.getAttribute("aria-label") ?? this.#o });
149
+ }
150
+ formValue() {
151
+ return this.#r === null ? null : this.machine.snapshot.term;
152
+ }
153
+ formReset() {
154
+ this.machine.setValue(this.#a);
155
+ }
156
+ formRestore(e) {
157
+ typeof e == "string" && this.machine.setValue(e);
158
+ }
159
+ formValidityAnchor() {
160
+ return this.querySelector("input");
161
+ }
162
+ willUpdate(e) {
163
+ super.willUpdate(e), this.machine.setDisabled(this.effectiveDisabled || this.#i);
164
+ }
165
+ updated(e) {
166
+ super.updated(e), this.#n.syncReferences(), this.syncFormValue();
167
+ }
168
+ disconnectedCallback() {
169
+ super.disconnectedCallback(), queueMicrotask(() => {
170
+ this.isConnected || this.machine.close();
171
+ });
172
+ }
173
+ focus(e) {
174
+ this.querySelector("input")?.focus(e);
175
+ }
176
+ render() {
177
+ let e = this.#t.state, t = f(e, this.#e, { name: null }), { value: n, ...r } = t.input, i = this.machine;
178
+ return g`
179
+ <div class="mp-typeahead" ${a(t.root)}>
180
+ <input
181
+ class="form-control"
182
+ type="text"
183
+ ${a(r)}
184
+ .value=${l(e.term)}
185
+ @input=${(e) => i.setTerm(e.target.value)}
186
+ @keydown=${(e) => {
187
+ i.keydown(e.key, e) && e.preventDefault();
188
+ }}
189
+ @blur=${() => i.blur()}
190
+ />
191
+ <ul class="dropdown-menu" ${a(t.listbox)}>
192
+ ${t.status ? g`<li class="ta-status" ${a(t.status.attrs)}>${t.status.text}</li>` : s}
193
+ ${c(e.items, (e, t) => i.itemKeyOf(e) ?? t, (n, r) => g`
194
+ <li
195
+ class="dropdown-item"
196
+ ${a(t.option(r))}
197
+ @mousedown=${(e) => e.preventDefault()}
198
+ @click=${() => i.pick(r)}
199
+ >${this.#l(n, e.term)}</li>
200
+ `)}
201
+ </ul>
202
+ <span class="visually-hidden" ${a(t.live.attrs)}>${t.live.text}</span>
203
+ ${t.error ? g`<div class="ta-error" ${a(t.error.attrs)}>${t.error.text}</div>` : s}
204
+ </div>
205
+ `;
206
+ }
207
+ #l(e, t) {
208
+ return this.#s?.(e, t) ?? this.machine.itemTextOf(e);
209
+ }
210
+ #u(e, t) {
211
+ this.isConnected && this.dispatchEvent(new CustomEvent(e, {
212
+ detail: t,
213
+ bubbles: !0,
214
+ composed: !0
215
+ }));
216
+ }
217
+ };
218
+ n(u, h), typeof customElements < "u" && !customElements.get("mp-typeahead") && customElements.define("mp-typeahead", y);
219
+ //#endregion
220
+ export { y as MpTypeahead, p as inMemoryTypeaheadProvider, m as typeaheadScopedStyles };