@bazza-ui/react 0.1.0-canary.16 → 0.1.0-canary.17

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 (150) hide show
  1. package/dist/combobox/index.cjs +1 -1
  2. package/dist/combobox/index.cjs.map +1 -1
  3. package/dist/combobox/index.d.ts +842 -834
  4. package/dist/combobox/index.js +1 -1
  5. package/dist/combobox/index.js.map +1 -1
  6. package/dist/command-menu/index.cjs +1 -1
  7. package/dist/command-menu/index.cjs.map +1 -1
  8. package/dist/command-menu/index.d.ts +123 -96
  9. package/dist/command-menu/index.js +1 -1
  10. package/dist/command-menu/index.js.map +1 -1
  11. package/dist/context-menu/index.cjs +1 -1
  12. package/dist/context-menu/index.cjs.map +1 -1
  13. package/dist/context-menu/index.d.ts +701 -658
  14. package/dist/context-menu/index.js +1 -1
  15. package/dist/context-menu/index.js.map +1 -1
  16. package/dist/dropdown-menu/index.cjs +1 -1
  17. package/dist/dropdown-menu/index.cjs.map +1 -1
  18. package/dist/dropdown-menu/index.d.ts +723 -680
  19. package/dist/dropdown-menu/index.js +1 -1
  20. package/dist/dropdown-menu/index.js.map +1 -1
  21. package/dist/events-DDOsDu4X.d.ts +2091 -0
  22. package/dist/index-Cabqj7qI.d.ts +2003 -0
  23. package/dist/index-D8OrKThQ.d.ts +977 -0
  24. package/dist/internal/listbox/index.cjs +1 -2
  25. package/dist/internal/listbox/index.d.ts +2 -272
  26. package/dist/internal/listbox/index.js +1 -2
  27. package/dist/internal/popup-menu/index.cjs +1 -2
  28. package/dist/internal/popup-menu/index.d.ts +4 -238
  29. package/dist/internal/popup-menu/index.js +1 -2
  30. package/dist/items-CD2hw6-3.js +2 -0
  31. package/dist/items-CD2hw6-3.js.map +1 -0
  32. package/dist/items-DYDljwnt.cjs +2 -0
  33. package/dist/items-DYDljwnt.cjs.map +1 -0
  34. package/dist/{items-B6HeFO_8.d.cts → items-ceX--VIv.d.ts} +21 -19
  35. package/dist/kbd/index.cjs +1 -1
  36. package/dist/kbd/index.cjs.map +1 -1
  37. package/dist/kbd/index.d.ts +35 -35
  38. package/dist/kbd/index.js +1 -1
  39. package/dist/kbd/index.js.map +1 -1
  40. package/dist/listbox-CnwUlLZA.js +2 -0
  41. package/dist/listbox-CnwUlLZA.js.map +1 -0
  42. package/dist/listbox-DYvJTiF6.cjs +2 -0
  43. package/dist/listbox-DYvJTiF6.cjs.map +1 -0
  44. package/dist/loaders/index.cjs +1 -1
  45. package/dist/loaders/index.cjs.map +1 -1
  46. package/dist/loaders/index.d.ts +218 -188
  47. package/dist/loaders/index.js +1 -1
  48. package/dist/loaders/index.js.map +1 -1
  49. package/dist/merge-element-props-0mpNO7ZH.cjs +2 -0
  50. package/dist/merge-element-props-0mpNO7ZH.cjs.map +1 -0
  51. package/dist/merge-element-props-PxUvRHax.js +2 -0
  52. package/dist/merge-element-props-PxUvRHax.js.map +1 -0
  53. package/dist/platform-C-sxBTRa.cjs +2 -0
  54. package/dist/platform-C-sxBTRa.cjs.map +1 -0
  55. package/dist/platform-C4_cGUkS.js +2 -0
  56. package/dist/platform-C4_cGUkS.js.map +1 -0
  57. package/dist/popup-menu-BBAzAXIe.cjs +2 -0
  58. package/dist/popup-menu-BBAzAXIe.cjs.map +1 -0
  59. package/dist/popup-menu-HmBMJEZc.js +2 -0
  60. package/dist/popup-menu-HmBMJEZc.js.map +1 -0
  61. package/dist/resolve-state-props-C-zbhdXd.cjs +2 -0
  62. package/dist/resolve-state-props-C-zbhdXd.cjs.map +1 -0
  63. package/dist/resolve-state-props-D31kizRZ.js +2 -0
  64. package/dist/resolve-state-props-D31kizRZ.js.map +1 -0
  65. package/dist/rolldown-runtime-5lHFv1cW.cjs +1 -0
  66. package/dist/rolldown-runtime-DK3Fl9T5.js +1 -0
  67. package/dist/select/index.cjs +1 -1
  68. package/dist/select/index.cjs.map +1 -1
  69. package/dist/select/index.d.ts +835 -828
  70. package/dist/select/index.js +1 -1
  71. package/dist/select/index.js.map +1 -1
  72. package/dist/suggestion-menu/index.cjs +4 -0
  73. package/dist/suggestion-menu/index.cjs.map +1 -0
  74. package/dist/suggestion-menu/index.d.ts +359 -0
  75. package/dist/suggestion-menu/index.js +4 -0
  76. package/dist/suggestion-menu/index.js.map +1 -0
  77. package/dist/types-BbN28E3_.d.ts +50 -0
  78. package/dist/video-player/index.cjs +2 -2
  79. package/dist/video-player/index.cjs.map +1 -1
  80. package/dist/video-player/index.d.ts +964 -1000
  81. package/dist/video-player/index.js +2 -2
  82. package/dist/video-player/index.js.map +1 -1
  83. package/package.json +14 -5
  84. package/dist/ListboxStore-B8oTpM57.d.cts +0 -453
  85. package/dist/ListboxStore-CV5vPUUc.d.ts +0 -453
  86. package/dist/chunk-3HMQLMSF.js +0 -2
  87. package/dist/chunk-3HMQLMSF.js.map +0 -1
  88. package/dist/chunk-4C666HHU.js +0 -2
  89. package/dist/chunk-4C666HHU.js.map +0 -1
  90. package/dist/chunk-5T5B5SPR.cjs +0 -2
  91. package/dist/chunk-5T5B5SPR.cjs.map +0 -1
  92. package/dist/chunk-A4Z5BY7H.js +0 -2
  93. package/dist/chunk-A4Z5BY7H.js.map +0 -1
  94. package/dist/chunk-IT372NHF.js +0 -2
  95. package/dist/chunk-IT372NHF.js.map +0 -1
  96. package/dist/chunk-JFEVUUPC.cjs +0 -2
  97. package/dist/chunk-JFEVUUPC.cjs.map +0 -1
  98. package/dist/chunk-KO3DXT3Y.js +0 -2
  99. package/dist/chunk-KO3DXT3Y.js.map +0 -1
  100. package/dist/chunk-LXXK4S4Q.js +0 -2
  101. package/dist/chunk-LXXK4S4Q.js.map +0 -1
  102. package/dist/chunk-M4G6J7DP.cjs +0 -2
  103. package/dist/chunk-M4G6J7DP.cjs.map +0 -1
  104. package/dist/chunk-MPPIEWSL.js +0 -2
  105. package/dist/chunk-MPPIEWSL.js.map +0 -1
  106. package/dist/chunk-PCNHYMD6.cjs +0 -2
  107. package/dist/chunk-PCNHYMD6.cjs.map +0 -1
  108. package/dist/chunk-RTG6U56O.cjs +0 -2
  109. package/dist/chunk-RTG6U56O.cjs.map +0 -1
  110. package/dist/chunk-SCDHQZFI.cjs +0 -2
  111. package/dist/chunk-SCDHQZFI.cjs.map +0 -1
  112. package/dist/chunk-XMZZ62VJ.cjs +0 -2
  113. package/dist/chunk-XMZZ62VJ.cjs.map +0 -1
  114. package/dist/combobox/index.d.cts +0 -1066
  115. package/dist/command-menu/index.d.cts +0 -154
  116. package/dist/command-score-CTJ9NV6n.d.cts +0 -23
  117. package/dist/command-score-CTJ9NV6n.d.ts +0 -23
  118. package/dist/context-menu/index.d.cts +0 -696
  119. package/dist/dropdown-menu/index.d.cts +0 -723
  120. package/dist/events-BTHQ2OoH.d.ts +0 -1860
  121. package/dist/events-DVcrtGe3.d.cts +0 -1860
  122. package/dist/input-C95v6jB0.d.cts +0 -46
  123. package/dist/input-CYweYB_i.d.ts +0 -46
  124. package/dist/internal/listbox/index.cjs.map +0 -1
  125. package/dist/internal/listbox/index.d.cts +0 -272
  126. package/dist/internal/listbox/index.js.map +0 -1
  127. package/dist/internal/popup-menu/index.cjs.map +0 -1
  128. package/dist/internal/popup-menu/index.d.cts +0 -238
  129. package/dist/internal/popup-menu/index.js.map +0 -1
  130. package/dist/items-B6HeFO_8.d.ts +0 -37
  131. package/dist/kbd/index.d.cts +0 -61
  132. package/dist/loaders/index.d.cts +0 -363
  133. package/dist/loading-C6WZGUc3.d.cts +0 -29
  134. package/dist/loading-CC4n55sR.d.ts +0 -29
  135. package/dist/resolve-B-j0eW24.d.cts +0 -406
  136. package/dist/resolve-B1F-a3P1.d.ts +0 -406
  137. package/dist/scroll-arrow-BBoKckL_.d.cts +0 -544
  138. package/dist/scroll-arrow-fl3B5sVO.d.ts +0 -544
  139. package/dist/select/index.d.cts +0 -1005
  140. package/dist/separator-Dn15rte3.d.ts +0 -275
  141. package/dist/separator-NjsBVzek.d.cts +0 -275
  142. package/dist/surface-context-CGLDpMej.d.ts +0 -14
  143. package/dist/surface-context-CN4Lb_6F.d.cts +0 -14
  144. package/dist/type-guards-BHHzjRvZ.d.cts +0 -351
  145. package/dist/type-guards-C0e_GpeY.d.ts +0 -351
  146. package/dist/types-DT4FOOa2.d.cts +0 -51
  147. package/dist/types-DT4FOOa2.d.ts +0 -51
  148. package/dist/use-listbox-item-NzZuY34-.d.cts +0 -212
  149. package/dist/use-listbox-item-NzZuY34-.d.ts +0 -212
  150. package/dist/video-player/index.d.cts +0 -1391
@@ -0,0 +1,359 @@
1
+ import { B as VirtualItem } from "../index-D8OrKThQ.js";
2
+ import { $t as PopupMenuItemState, Et as TreeItemDef, Jt as PopupMenuLinkItem, Q as LinkItemDef, Qt as PopupMenuItemProps, U as GroupDef, Y as ItemDef, Yt as PopupMenuLinkItemProps, Zt as PopupMenuItem, _n as noResults, b as AsyncResultBehavior, bn as pointer, c as PopupMenuIdScope, d as AsyncContentMode, dn as imperativeAction, f as AsyncLoaderConfig, h as AsyncLoaderResult, hn as keyboard, ht as SeparatorDef, it as QueryLoaderConfig, l as PopupMenuNode, ln as escapeKey, mn as itemPress, nt as NodeDef, on as ChangeEventDetails, r as PopupMenuHighlightChangeHandler, s as GetResolvedIdFn, sn as GenericEventDetails, tt as LoaderComponentProps, un as focusOut, vn as none, vt as StaticLoaderConfig, xn as reason_parts_d_exports, yn as outsidePress } from "../events-DDOsDu4X.js";
3
+ import { A as PopupMenuTreeItem, B as PopupMenuHeaderProps, Ct as PopupMenuList, Ft as PopupMenuIconProps, G as PopupMenuGroupValue, H as PopupMenuGroupLabel, I as PopupMenuSeparator, K as PopupMenuGroup, Kt as PopupMenuPositioner, L as PopupMenuSeparatorProps, M as PopupMenuTree, Mt as PopupMenuEmptyProps, Nt as PopupMenuEmptyState, Pt as PopupMenuIcon, Qt as PopupMenuPopup, U as PopupMenuGroupLabelProps, X as PopupMenuFooterProps, Xt as PopupMenuPortal, Y as PopupMenuFooter, Zt as PopupMenuPortalProps, an as PopupMenuArrowProps, bt as PopupMenuLoading, ft as PopupMenuSurfaceProps, gt as PopupMenuScrollDownArrow, h as useAsyncMenuCoordinator, in as PopupMenuArrow, j as PopupMenuTreeConnector, jt as PopupMenuEmpty, m as AsyncMenuCoordinatorValue, q as PopupMenuGroupProps, u as useDataList, vt as PopupMenuScrollUpArrow, xt as PopupMenuLoadingProps, z as PopupMenuHeader } from "../index-Cabqj7qI.js";
4
+ import * as React from "react";
5
+ import { PopoverRootProps } from "@base-ui/react/popover";
6
+ //#region src/suggestion-menu/events.d.ts
7
+ /**
8
+ * Reasons why the suggestion menu's open state changed.
9
+ * - `imperative-action`: the handle's `update()` or `close()`, or the host
10
+ * input was detached or replaced
11
+ * - `item-press`: a row was chosen (click or Enter)
12
+ * - `escape-key`: Escape was pressed in the host input
13
+ * - `outside-press`: a press outside the popup and the host input
14
+ * - `focus-out`: the host input lost focus
15
+ * - `no-results`: with `noResults: 'close'`, the results settled empty
16
+ */
17
+ type SuggestionMenuOpenChangeReason = typeof imperativeAction | typeof itemPress | typeof escapeKey | typeof outsidePress | typeof focusOut | typeof noResults | typeof none;
18
+ /**
19
+ * Event details passed to the `onOpenChange` callback.
20
+ */
21
+ type SuggestionMenuOpenChangeEventDetails = ChangeEventDetails<SuggestionMenuOpenChangeReason>;
22
+ /**
23
+ * Reasons why the highlight changed.
24
+ */
25
+ type SuggestionMenuHighlightChangeReason = typeof pointer | typeof keyboard | typeof none;
26
+ /**
27
+ * Event details passed to the `onHighlightChange` callback.
28
+ */
29
+ type SuggestionMenuHighlightChangeEventDetails = GenericEventDetails<SuggestionMenuHighlightChangeReason, {
30
+ index: number;
31
+ }>;
32
+ //#endregion
33
+ //#region src/suggestion-menu/handle.d.ts
34
+ /** Where the popup is anchored: usually the trigger character's rect. */
35
+ type SuggestionMenuAnchor = () => DOMRect | null;
36
+ /** What the host input tells the menu when a trigger is typed or updated. */
37
+ interface SuggestionMenuUpdate<Payload = unknown> {
38
+ /** The text typed after the trigger. */
39
+ query?: string;
40
+ /** Measures where the popup is anchored. */
41
+ anchor?: SuggestionMenuAnchor;
42
+ /** Data for the Root's `children` function, e.g. which trigger was typed. */
43
+ payload?: Payload;
44
+ }
45
+ /** The handle's state, read by the Root. */
46
+ interface SuggestionMenuHandleState<Payload = unknown> {
47
+ query: string;
48
+ anchor: SuggestionMenuAnchor | null;
49
+ payload: Payload | undefined;
50
+ /** The attached host input, if any. */
51
+ host: Element | null;
52
+ /** Fields last set through `update()`, for the Root's precedence warnings. */
53
+ updated: {
54
+ query: boolean;
55
+ anchor: boolean;
56
+ };
57
+ }
58
+ /** @internal How a mounted Root serves the handle. */
59
+ interface SuggestionMenuConnection {
60
+ isOpen: () => boolean;
61
+ requestOpenChange: (open: boolean, reason: SuggestionMenuOpenChangeReason, event?: Event) => void;
62
+ handleKeyDown: (event: KeyboardEvent | React.KeyboardEvent) => boolean;
63
+ attachHost: (host: Element | null, previous: Element | null) => void;
64
+ }
65
+ /**
66
+ * Connects a suggestion menu's Root to its host input: an `<input>`, a
67
+ * `<textarea>` or a contenteditable editor that owns DOM focus and the typed
68
+ * text. Created outside React, so non-React editor code (a ProseMirror plugin,
69
+ * a CodeMirror extension) can drive the menu. One host input is attached at a
70
+ * time.
71
+ */
72
+ export declare class SuggestionMenuHandle<Payload = unknown> {
73
+ #private;
74
+ /** The attached host input, if any. */
75
+ get host(): Element | null;
76
+ /** The query from the last `update()`. */
77
+ get query(): string;
78
+ /**
79
+ * The payload from the last `update()`, e.g. the text-field match to
80
+ * replace when a row is chosen.
81
+ */
82
+ get payload(): Payload | undefined;
83
+ /** Whether the menu is open. `false` while no Root is connected. */
84
+ get isOpen(): boolean;
85
+ /** @internal */
86
+ subscribe: (listener: () => void) => (() => void);
87
+ /** @internal */
88
+ getState: () => SuggestionMenuHandleState<Payload>;
89
+ /**
90
+ * Attaches the host input. Attaching another element detaches the previous
91
+ * one and closes the menu if it was open for it. Returns a function that
92
+ * detaches this element.
93
+ */
94
+ attach(element: Element): () => void;
95
+ /** Opens the menu, or updates its query, anchor and payload while open. */
96
+ update(next: SuggestionMenuUpdate<Payload>): void;
97
+ /**
98
+ * Closes the menu. Call it whenever the trigger ends (deleted, or the caret
99
+ * left it), even if the menu is already closed: it also resets what the
100
+ * menu remembers about the trigger, such as a query that had no results.
101
+ */
102
+ close(): void;
103
+ /**
104
+ * Passes a key press from the host input to the menu. Returns `true` when
105
+ * the menu used the key and prevented its default action; `false` means the
106
+ * key keeps its normal meaning in the host.
107
+ */
108
+ handleKeyDown(event: KeyboardEvent | React.KeyboardEvent): boolean;
109
+ /**
110
+ * @internal Called when the menu actually opens or closes (not for requests
111
+ * that were cancelled or refused), with the reason. Returns an unsubscribe.
112
+ */
113
+ subscribeOpenChange: (listener: (open: boolean, reason: SuggestionMenuOpenChangeReason) => void) => (() => void);
114
+ /** @internal The Root reports a change that happened. */
115
+ notifyOpenChange(open: boolean, reason: SuggestionMenuOpenChangeReason): void;
116
+ /** @internal Connects a mounted Root. Returns a disconnect function. */
117
+ connect(connection: SuggestionMenuConnection): () => void;
118
+ }
119
+ /** Creates a handle that connects a suggestion menu to its host input. */
120
+ export declare function createSuggestionMenuHandle<Payload = unknown>(): SuggestionMenuHandle<Payload>;
121
+ //#endregion
122
+ //#region src/suggestion-menu/list/list.d.ts
123
+ interface SuggestionMenuListProps extends PopupMenuList.Props {
124
+ /**
125
+ * Accessible label for the listbox.
126
+ * @default 'Suggestions'
127
+ */
128
+ label?: string;
129
+ }
130
+ /**
131
+ * The listbox of suggestions. Keyboard handling comes from the host input,
132
+ * so the list never takes focus.
133
+ * Renders a `<div>` element with `role="listbox"`.
134
+ */
135
+ declare const SuggestionMenuList: React.ForwardRefExoticComponent<Omit<SuggestionMenuListProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
136
+ declare namespace SuggestionMenuList {
137
+ type Props = SuggestionMenuListProps;
138
+ }
139
+ //#endregion
140
+ //#region src/suggestion-menu/popup/popup.d.ts
141
+ interface SuggestionMenuPopupProps extends PopupMenuPopup.Props {}
142
+ /**
143
+ * The popup that holds the suggestions. It isn't a dialog: focus never enters
144
+ * it, and the listbox inside is what the host input points at.
145
+ * Renders a `<div>` element.
146
+ */
147
+ declare const SuggestionMenuPopup: React.ForwardRefExoticComponent<Omit<SuggestionMenuPopupProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
148
+ declare namespace SuggestionMenuPopup {
149
+ type Props = SuggestionMenuPopupProps;
150
+ }
151
+ //#endregion
152
+ //#region src/suggestion-menu/positioner/positioner.d.ts
153
+ type Side = NonNullable<PopupMenuPositioner.Props['side']>;
154
+ interface SuggestionMenuPositionerProps extends PopupMenuPositioner.Props {
155
+ /**
156
+ * Which side of the anchor to place the popup on. If there's no room, it
157
+ * opens on the other side, and stays there until it closes.
158
+ * @default 'bottom'
159
+ */
160
+ side?: Side;
161
+ /**
162
+ * How to align the popup against the anchor.
163
+ * @default 'start'
164
+ */
165
+ align?: PopupMenuPositioner.Props['align'];
166
+ }
167
+ /**
168
+ * Positions the popup against the host's text. The side is chosen when the
169
+ * menu opens and held until it closes: the popup may shift along the line,
170
+ * but never flips between above and below while it's open.
171
+ * Renders a `<div>` element.
172
+ */
173
+ declare const SuggestionMenuPositioner: React.ForwardRefExoticComponent<Omit<SuggestionMenuPositionerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
174
+ declare namespace SuggestionMenuPositioner {
175
+ type Props = SuggestionMenuPositionerProps;
176
+ }
177
+ //#endregion
178
+ //#region src/suggestion-menu/root/results-status.d.ts
179
+ /**
180
+ * Formats the result summary.
181
+ * @param count The number of results.
182
+ * @param label The text of the row Enter would choose, or `null` if none.
183
+ */
184
+ type GetAriaResultsText = (count: number, label: string | null) => string;
185
+ //#endregion
186
+ //#region src/suggestion-menu/root/root.d.ts
187
+ /** What the Root's `children` function receives. */
188
+ interface SuggestionMenuRootRenderState<Payload = unknown> {
189
+ /** The payload from the last `update()`. */
190
+ payload: Payload | undefined;
191
+ /** The current query. */
192
+ query: string;
193
+ }
194
+ interface SuggestionMenuRootProps<Payload = unknown> extends Omit<PopoverRootProps, 'open' | 'onOpenChange' | 'defaultOpen' | 'actionsRef' | 'modal' | 'handle' | 'triggerId' | 'children'> {
195
+ /** Connects the menu to its host input. Create it with `SuggestionMenu.createHandle()`. */
196
+ handle: SuggestionMenuHandle<Payload>;
197
+ /**
198
+ * Whether the menu is open, for controlled use. When set, `update()`,
199
+ * `close()` and the menu's own dismissals become `onOpenChange` requests.
200
+ */
201
+ open?: boolean;
202
+ /**
203
+ * Whether the menu is initially open, for uncontrolled use.
204
+ * @default false
205
+ */
206
+ defaultOpen?: boolean;
207
+ /** Called when the menu asks to open or close, with the reason. */
208
+ onOpenChange?: (open: boolean, eventDetails: SuggestionMenuOpenChangeEventDetails) => void;
209
+ /**
210
+ * The query, for controlled use. When set, it wins over the handle's
211
+ * `update({ query })`. The menu never changes the query itself.
212
+ */
213
+ query?: string;
214
+ /**
215
+ * Measures where the popup is anchored, for controlled use. When set, it
216
+ * wins over the handle's `update({ anchor })`.
217
+ */
218
+ anchor?: SuggestionMenuAnchor;
219
+ /**
220
+ * Whether virtualization mode is enabled. Wire your virtualizer to
221
+ * `onHighlightChange` so it scrolls to the highlighted row.
222
+ * @default false
223
+ */
224
+ virtualized?: boolean;
225
+ /** Pre-registered items for virtualization. */
226
+ items?: VirtualItem[];
227
+ /** Called when the highlighted row changes. */
228
+ onHighlightChange?: PopupMenuHighlightChangeHandler<SuggestionMenuHighlightChangeEventDetails>;
229
+ /**
230
+ * Computes canonical Resolved IDs for data-first content. Read once when the
231
+ * menu mounts.
232
+ */
233
+ getResolvedId?: GetResolvedIdFn;
234
+ /**
235
+ * Definition Key uniqueness scope. Read once when the menu mounts.
236
+ * @default 'surface'
237
+ */
238
+ idScope?: PopupMenuIdScope;
239
+ /**
240
+ * Formats the result summary announced to screen readers once results
241
+ * settle, for localisation. Receives the number of results and the text of
242
+ * the row Enter would choose.
243
+ * @default (count, label) => count === 0 ? 'No results' : `${count} results, first: ${label}`
244
+ */
245
+ getAriaResultsText?: GetAriaResultsText;
246
+ /**
247
+ * What happens when nothing matches the query, once every search for it has
248
+ * finished.
249
+ * - `'empty'`: the menu stays open and shows `Empty`; Enter reaches the host.
250
+ * - `'close'`: the menu closes (reason `'no-results'`). An `update()` with
251
+ * the same query leaves it closed; one with any other query searches
252
+ * again.
253
+ * @default 'empty'
254
+ */
255
+ noResults?: 'empty' | 'close';
256
+ /** The menu's parts, or a function of the payload and query that returns them. */
257
+ children: React.ReactNode | ((state: SuggestionMenuRootRenderState<Payload>) => React.ReactNode);
258
+ }
259
+ /**
260
+ * Groups all parts of the suggestion menu and connects them to the host input
261
+ * through its handle. Never modal: DOM focus stays in the host input.
262
+ * Doesn't render its own HTML element.
263
+ */
264
+ declare function SuggestionMenuRoot<Payload = unknown>(props: SuggestionMenuRootProps<Payload>): React.JSX.Element;
265
+ declare namespace SuggestionMenuRoot {
266
+ type Props<Payload = unknown> = SuggestionMenuRootProps<Payload>;
267
+ type RenderState<Payload = unknown> = SuggestionMenuRootRenderState<Payload>;
268
+ type ChangeEventDetails = SuggestionMenuOpenChangeEventDetails;
269
+ }
270
+ //#endregion
271
+ //#region src/suggestion-menu/surface/surface.d.ts
272
+ interface SuggestionMenuSurfaceProps extends Omit<PopupMenuSurfaceProps, 'search' | 'onSearchChange' | 'defaultSearch' | 'skipAutoFocus'> {
273
+ /**
274
+ * How rows from `asyncContent` combine with `content`.
275
+ * @default 'append'
276
+ */
277
+ asyncContentMode?: PopupMenuSurfaceProps['asyncContentMode'];
278
+ }
279
+ /**
280
+ * One pane of suggestions: its content, loaders, list and empty/loading
281
+ * states. The query comes from the host input (through the Root), never from
282
+ * an input inside the popup. Submenu and subpage definitions in `content` are
283
+ * skipped with a development warning; rows from `asyncContent` are shown as
284
+ * returned, so loaders shouldn't return them.
285
+ * Renders a `<div>` element.
286
+ */
287
+ declare const SuggestionMenuSurface: React.ForwardRefExoticComponent<Omit<SuggestionMenuSurfaceProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
288
+ declare namespace SuggestionMenuSurface {
289
+ type Props = SuggestionMenuSurfaceProps;
290
+ }
291
+ //#endregion
292
+ //#region src/suggestion-menu/text-trigger/match.d.ts
293
+ /** A character that opens the suggestion menu when typed in a text field. */
294
+ interface SuggestionMenuTextTrigger {
295
+ /** The trigger, e.g. `'@'`, `'/'` or `':'`. */
296
+ char: string;
297
+ /**
298
+ * Whether the query may contain spaces, e.g. `@Alice Smith`. A line break
299
+ * always ends it.
300
+ * @default false
301
+ */
302
+ allowSpaces?: boolean;
303
+ /**
304
+ * Whether the trigger only counts at the start of a line.
305
+ * @default false
306
+ */
307
+ startOfLine?: boolean;
308
+ /**
309
+ * How many characters must follow the trigger before the menu opens.
310
+ * @default 0
311
+ */
312
+ minLength?: number;
313
+ }
314
+ /** A trigger typed in a text field: the menu's payload. */
315
+ interface SuggestionMenuTextTriggerMatch {
316
+ /** The trigger that matched. */
317
+ trigger: SuggestionMenuTextTrigger;
318
+ /** The text typed after the trigger. */
319
+ query: string;
320
+ /** Where the trigger character starts in the field's value. */
321
+ from: number;
322
+ /**
323
+ * Where the typed query ends: the caret, or further if the caret was moved
324
+ * back inside it. Replace `from`–`to` to insert a choice.
325
+ */
326
+ to: number;
327
+ }
328
+ //#endregion
329
+ //#region src/suggestion-menu/text-trigger/attach-text-trigger.d.ts
330
+ /** What the binding needs from a handle. */
331
+ type SuggestionMenuTextTriggerHandle = Pick<SuggestionMenuHandle<SuggestionMenuTextTriggerMatch>, 'attach' | 'update' | 'close' | 'handleKeyDown' | 'host' | 'subscribeOpenChange'>;
332
+ interface AttachTextTriggerOptions {
333
+ /** The characters that open the menu. */
334
+ triggers: readonly SuggestionMenuTextTrigger[];
335
+ }
336
+ /**
337
+ * Makes an `<input>` or `<textarea>` the suggestion menu's host. Typing a
338
+ * trigger opens the menu with the text after it as the query, anchored at the
339
+ * trigger character; the payload (`menu.payload`) is the match, with the
340
+ * range to replace. Keys the menu uses are forwarded to it and go no further.
341
+ * After Escape, or once a row is chosen, the menu stays closed until the
342
+ * trigger is typed again. A handle shared by several fields follows the one
343
+ * the user is typing in. Returns a function that detaches the field.
344
+ */
345
+ declare function attachTextTrigger(menu: SuggestionMenuTextTriggerHandle, field: HTMLInputElement | HTMLTextAreaElement, options: AttachTextTriggerOptions): () => void;
346
+ //#endregion
347
+ //#region src/suggestion-menu/text-trigger/use-text-trigger.d.ts
348
+ /**
349
+ * React wrapper for `attachTextTrigger`. Returns a stable ref for the
350
+ * `<input>` or `<textarea>`; pass it directly (the attached field is
351
+ * `menu.host`). The latest `triggers` are used on every keystroke.
352
+ */
353
+ declare function useTextTrigger(menu: SuggestionMenuTextTriggerHandle, options: AttachTextTriggerOptions): (field: HTMLInputElement | HTMLTextAreaElement | null) => void;
354
+ declare namespace index_parts_d_exports {
355
+ export { PopupMenuArrow as Arrow, PopupMenuEmpty as Empty, PopupMenuFooter as Footer, PopupMenuGroup as Group, PopupMenuGroupLabel as GroupLabel, PopupMenuGroupValue as GroupValue, SuggestionMenuHandle as Handle, PopupMenuHeader as Header, PopupMenuIcon as Icon, PopupMenuItem as Item, PopupMenuLinkItem as LinkItem, SuggestionMenuList as List, PopupMenuLoading as Loading, PopupMenuNode as Node, NodeDef, SuggestionMenuPopup as Popup, PopupMenuPortal as Portal, SuggestionMenuPositioner as Positioner, SuggestionMenuRoot as Root, PopupMenuScrollDownArrow as ScrollDownArrow, PopupMenuScrollUpArrow as ScrollUpArrow, PopupMenuSeparator as Separator, SuggestionMenuSurface as Surface, SuggestionMenuTextTrigger as TextTrigger, SuggestionMenuTextTriggerMatch as TextTriggerMatch, PopupMenuTree as Tree, PopupMenuTreeConnector as TreeConnector, PopupMenuTreeItem as TreeItem, attachTextTrigger, createSuggestionMenuHandle as createHandle, useAsyncMenuCoordinator, useDataList, useTextTrigger };
356
+ }
357
+ //#endregion
358
+ export { type AsyncContentMode, type AsyncLoaderConfig, type AsyncLoaderResult, type AsyncMenuCoordinatorValue, type AsyncResultBehavior, type GroupDef, type ItemDef, type LinkItemDef, type LoaderComponentProps, type NodeDef, type PopupMenuNode, type QueryLoaderConfig, type SeparatorDef, type StaticLoaderConfig, index_parts_d_exports as SuggestionMenu, type SuggestionMenuAnchor, type PopupMenuArrowProps as SuggestionMenuArrowProps, type AttachTextTriggerOptions as SuggestionMenuAttachTextTriggerOptions, type PopupMenuEmptyProps as SuggestionMenuEmptyProps, type PopupMenuEmptyState as SuggestionMenuEmptyState, type PopupMenuFooterProps as SuggestionMenuFooterProps, type GetAriaResultsText as SuggestionMenuGetAriaResultsText, type PopupMenuGroupLabelProps as SuggestionMenuGroupLabelProps, type PopupMenuGroupProps as SuggestionMenuGroupProps, type PopupMenuHeaderProps as SuggestionMenuHeaderProps, type SuggestionMenuHighlightChangeEventDetails, type SuggestionMenuHighlightChangeReason, type PopupMenuIconProps as SuggestionMenuIconProps, type PopupMenuItemProps as SuggestionMenuItemProps, type PopupMenuItemState as SuggestionMenuItemState, type PopupMenuLinkItemProps as SuggestionMenuLinkItemProps, type SuggestionMenuList, type SuggestionMenuListProps, type PopupMenuLoadingProps as SuggestionMenuLoadingProps, type SuggestionMenuOpenChangeEventDetails, type SuggestionMenuOpenChangeReason, type SuggestionMenuPopup, type SuggestionMenuPopupProps, type PopupMenuPortalProps as SuggestionMenuPortalProps, type SuggestionMenuPositioner, type SuggestionMenuPositionerProps, type SuggestionMenuRoot, type SuggestionMenuRootProps, type SuggestionMenuRootRenderState, type PopupMenuSeparatorProps as SuggestionMenuSeparatorProps, type SuggestionMenuSurface, type SuggestionMenuSurfaceProps, type SuggestionMenuTextTrigger, type SuggestionMenuTextTriggerHandle, type SuggestionMenuTextTriggerMatch, type SuggestionMenuUpdate, type TreeItemDef, useAsyncMenuCoordinator, useDataList };
359
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import{t as e}from"../rolldown-runtime-DK3Fl9T5.js";import{A as t,C as n,D as r,It as i,M as a,O as o,Q as s,Rt as c,S as l,St as u,U as d,V as f,W as p,Y as m,Z as h,at as g,bt as _,c as v,dt as y,et as b,f as x,g as S,h as C,j as ee,k as w,l as T,m as te,ot as ne,p as E,tt as D,u as O,wt as k}from"../popup-menu-HmBMJEZc.js";import{A as re,D as ie,E as ae,O as A,g as j,j as oe}from"../listbox-CnwUlLZA.js";import*as M from"react";import{Popover as se}from"@base-ui/react/popover";import{jsx as N,jsxs as ce}from"react/jsx-runtime";var P=class{#e={query:``,anchor:null,payload:void 0,host:null,updated:{query:!1,anchor:!1}};#t=/* @__PURE__ */ new Set;#n=/* @__PURE__ */ new Set;#r=null;#i=null;get host(){return this.#e.host}get query(){return this.#e.query}get payload(){return this.#e.payload}get isOpen(){return this.#r?.isOpen()??!1}subscribe=e=>(this.#t.add(e),()=>{this.#t.delete(e)});getState=()=>this.#e;#a(e){this.#e={...this.#e,...e};for(let e of this.#t)e()}#o(e){this.#r?this.#r.requestOpenChange(e,A):this.#i=e}attach(e){let t=this.#e.host;return t!==e&&(t&&this.isOpen&&this.#o(!1),this.#a({host:e}),this.#r?.attachHost(e,t)),()=>{this.#e.host===e&&(this.isOpen&&this.#o(!1),this.#a({host:null}),this.#r?.attachHost(null,e))}}update(e){let t={updated:{query:this.#e.updated.query||e.query!==void 0,anchor:this.#e.updated.anchor||e.anchor!==void 0}};e.query!==void 0&&(t.query=e.query),e.anchor!==void 0&&(t.anchor=e.anchor),`payload`in e&&(t.payload=e.payload),this.#a(t),this.isOpen||this.#o(!0)}close(){this.#o(!1)}handleKeyDown(e){return this.#r?.handleKeyDown(e)??!1}subscribeOpenChange=e=>(this.#n.add(e),()=>{this.#n.delete(e)});notifyOpenChange(e,t){for(let n of this.#n)n(e,t)}connect(e){let t=this.#r;if(t&&t!==e&&(process.env.NODE_ENV!==`production`&&console.warn(`[SuggestionMenu] A handle serves one Root at a time; the Root mounted last takes it over.`),t.attachHost(null,this.#e.host)),this.#r=e,e.attachHost(this.#e.host,null),this.#i!==null){let t=this.#i;this.#i=null,e.requestOpenChange(t,A)}return()=>{this.#r===e&&(e.attachHost(null,this.#e.host),this.#r=null)}}};function F(){return new P}const I=M.createContext(null);function L(){let e=M.useContext(I);if(!e)throw Error(`SuggestionMenu parts must be used within a SuggestionMenu.Root.`);return e}const R=M.forwardRef(function(e,t){let{label:n=`Suggestions`,...r}=e,{syncHostAria:i}=L(),o=M.useRef(null),s=M.useCallback(e=>{if(o.current?.disconnect(),o.current=null,e){e.id&&i(e.id);let t=new MutationObserver(()=>{e.id&&i(e.id)});t.observe(e,{attributeFilter:[`id`]}),o.current=t}typeof t==`function`?t(e):t&&(t.current=e)},[t,i]);return/* @__PURE__ */ N(a,{ref:s,label:n,...r})}),z=M.forwardRef(function(e,t){return/* @__PURE__ */ N(D,{ref:t,role:`presentation`,...e})}),B=M.forwardRef(function(e,t){let{side:n=`bottom`,align:r=`start`,collisionAvoidance:a,...o}=e,{store:c}=i(),{query:l,anchorReady:u}=L(),d=c.useState(`open`),f=M.useRef(null),[p,m]=M.useState(null),h=M.useCallback(()=>{let e=f.current?.getAttribute(`data-side`);m(t=>t??(e||n))},[n]);M.useLayoutEffect(()=>{if(!d){m(null);return}if(!u)return;let e=requestAnimationFrame(h);return()=>cancelAnimationFrame(e)},[d,u,h]);let g=M.useRef(null);M.useLayoutEffect(()=>{if(!d||!u){g.current=null;return}if(g.current===null){g.current=l;return}l!==g.current&&h()},[d,l,u,h]);let _=a??{side:`flip`,align:`shift`,fallbackAxisSide:`none`},v=p===null?_:{...typeof _==`object`?_:{},side:`none`},y=M.useCallback(e=>{f.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]);return/* @__PURE__ */ N(s,{ref:y,...o,side:p??n,align:r,collisionAvoidance:v})}),V=[`aria-controls`,`aria-activedescendant`,`aria-autocomplete`,`aria-haspopup`],H=[`role`,`aria-expanded`];function U(e){return e instanceof HTMLInputElement?[...H,...V]:V}function W(e,t,n){let r={"aria-controls":t,"aria-activedescendant":n,"aria-autocomplete":`list`,"aria-haspopup":`listbox`};return e instanceof HTMLInputElement?{role:`combobox`,"aria-expanded":`true`,...r}:r}function le(e){let{store:t,host:n,open:r,activeDescendant:i}=e,a=M.useRef(null),o=M.useRef(!1);M.useLayoutEffect(()=>{if(!n||!r)return;let e=U(n).map(e=>[e,n.getAttribute(e)]);return o.current=!0,()=>{o.current=!1;for(let[t,r]of e)r===null?n.removeAttribute(t):n.setAttribute(t,r)}},[n,r]);let s=M.useRef({store:t,host:n,open:r,activeDescendant:i});s.current={store:t,host:n,open:r,activeDescendant:i};let c=M.useCallback(e=>{e&&(a.current=e);let t=s.current;if(!t.host||!t.open||!o.current)return;let n=t.store.context.refs.listRef.current?.id||a.current||t.store.context.listId||null,r=W(t.host,n,t.activeDescendant);for(let e of U(t.host)){let n=r[e]??null;n===null?t.host.hasAttribute(e)&&t.host.removeAttribute(e):t.host.getAttribute(e)!==n&&t.host.setAttribute(e,n)}},[]);return M.useLayoutEffect(c),c}function G(e,t){if(!t)return!1;let n=e.composedPath()[0]??e.target;return n instanceof Node&&t.contains(n)}function ue(e,t){let n=e.ownerDocument,r,i=null,a=i=>{if(!t.isOpen())return;let a=i.relatedTarget,o=t.getPopup();a instanceof Node&&o?.contains(a)||(clearTimeout(r),r=setTimeout(()=>{t.isOpen()&&n.hasFocus()&&e.getRootNode().activeElement!==e&&t.onFocusOut(i)}))},o=e=>{if(!t.isOpen()||!G(e,t.getPopup()))return;let n=e.composedPath()[0];n instanceof Element&&n.closest(`input, textarea, select, [contenteditable]`)||e.preventDefault()},s=e=>{if(!t.isOpen()||!G(e,t.getPopup())||i)return;t.onSelectionStart();let r=n.defaultView,a=t=>{t===e&&o()},o=()=>{i===o&&(i=null,r?.removeEventListener(`click`,a),clearTimeout(s),t.onSelectionEnd())};i=o,r?.addEventListener(`click`,a);let s=setTimeout(o)};return e.addEventListener(`focusout`,a),n.addEventListener(`mousedown`,o,!0),n.addEventListener(`click`,s,!0),()=>{i?.(),clearTimeout(r),e.removeEventListener(`focusout`,a),n.removeEventListener(`mousedown`,o,!0),n.removeEventListener(`click`,s,!0)}}const de=/* @__PURE__ */ new Set([`ArrowDown`,`ArrowUp`,`Home`,`End`,`Enter`]);function fe(e,t){if((`nativeEvent`in e?e.nativeEvent:e).isComposing||e.keyCode===229||e.defaultPrevented||!t.isOpen())return!1;let{key:n,ctrlKey:r,metaKey:i,altKey:a,shiftKey:o}=e;return i||a||o?!1:r?n!==`n`&&n!==`p`?!1:t.forward(e):n===`Escape`?(e.preventDefault(),e.stopPropagation(),t.dismiss(e),!0):de.has(n)?t.forward(e):!1}const pe=(e,t)=>{if(e===0)return`No results`;let n=`${e} ${e===1?`result`:`results`}`;return t?`${n}, first: ${t}`:n};function me(e){return/* @__PURE__ */ N(o,{announcement:e.announcement,element:`span`})}function K(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function he(e,t,n){let r=M.useRef(e);r.current=e;let i=M.useRef(null),a=M.useRef(!1);e||(a.current=!1);let o=M.useRef(null),s=o.current;if(s&&s.anchor===e&&s.host===t&&s.measureKey===n)return{virtualAnchor:s.value,ready:a.current};let c=s?.value,l=e?.()??null;l&&(a.current=!0);let u=c!==void 0&&c.contextElement!==(t??void 0);return l&&(!i.current||!K(l,i.current))&&(i.current=l,c=void 0),e&&(c===void 0||u)&&i.current&&(c={getBoundingClientRect:()=>{let e=r.current?.()??null;return e&&(i.current=e),i.current??new DOMRect},contextElement:t??void 0}),o.current={anchor:e,host:t,measureKey:n,value:c},{virtualAnchor:c,ready:a.current}}function ge(e){let{store:t,closeAll:n}=i(),r=c(),a=t.useState(`open`),o=m({store:t,surfaceId:`suggestion-menu-host`,focusOwnerStore:r,depth:0,submenuContext:null,subpageContext:null,enabled:a,closeAll:n});return e.forwardKeyDownRef.current=o,null}const q=/* @__PURE__ */ new Set;function _e(e,t){process.env.NODE_ENV===`production`||q.has(e)||(q.add(e),console.warn(t))}function ve(e){let{handle:t,open:n,defaultOpen:r=!1,onOpenChange:i,query:a,anchor:o,virtualized:s=!1,items:c,onHighlightChange:l,onOpenChangeComplete:d,getResolvedId:f,idScope:p=`surface`,getAriaResultsText:m=pe,noResults:g=`empty`,children:_,...v}=e,y=M.useSyncExternalStore(t.subscribe,t.getState,t.getState),b=M.useRef(null),x=M.useRef(null),S=M.useRef(null),{store:C,focusOwnerStore:ee,openChainStore:w,registerSurface:T,closeAll:te,virtualization:ne,handleOpenChange:E,disabled:D,menuTreeResolver:O}=u({onOpenChange:((e,t)=>{let n=S.current;if(b.current?.select(`open`)!==e&&(!n||n.open!==e||!n.thisTask)){let n={open:e,reason:t.reason,thisTask:!0};S.current=n,queueMicrotask(()=>{n.thisTask=!1})}if((x.current??b.current?.select(`open`))===e)return;let r=x.current;x.current=e,queueMicrotask(()=>{x.current=null}),i?.(e,t),t.isCanceled&&(x.current=r,S.current=null)}),defaultOpen:r,virtualized:s,items:c,onHighlightChange:l,closeOnOutsidePress:`pointerdown`,getDismissExemptElements:()=>[t.host],getResolvedId:f,idScope:p});b.current=C,C.useControlledProp(`openProp`,n);let k=C.useState(`open`),j=M.useRef(k);M.useLayoutEffect(()=>{if(j.current===k)return;j.current=k;let e=S.current;S.current=null,t.notifyOpenChange(k,e?.open===k?e.reason:oe)},[k,t]);let P=M.useRef(E);P.current=E;let F=M.useRef(null),L=M.useRef(null),R=M.useRef(null),z=M.useRef(g);z.current=g;let B=M.useRef(a);B.current=a;let V=M.useRef(!1),[H,U]=M.useState(null),W=M.useRef(``);M.useLayoutEffect(()=>{let e=()=>C.select(`open`),n=(e,n,r)=>{if(n===`imperative-action`){let n=R.current;if(e&&n!==null){let e=B.current;if(e===n){V.current=!0;return}if(e===void 0&&t.getState().query===n)return}R.current=null,V.current=!1}P.current(e,n,r)},r=0,i=null,a=()=>{r+=1},o=()=>{if(--r,r>0||!i)return;let{event:e}=i;i=null,n(!1,A,e)},s=(e,t,a)=>{if(!e&&t===`imperative-action`&&r>0){i={event:a};return}n(e,t,a)};return t.connect({isOpen:e,requestOpenChange:s,handleKeyDown:t=>((t.key===`ArrowLeft`||t.key===`ArrowRight`)&&U(null),fe(t,{isOpen:e,forward:e=>{let t=e.key===`Enter`;t&&a();try{let n=F.current?.(e)??!1;return n&&!t&&U(W.current),n}finally{t&&o()}},dismiss:e=>s(!1,ae,`nativeEvent`in e?e.nativeEvent:e)})),attachHost:t=>{R.current=null,V.current=!1,L.current?.(),L.current=t?ue(t,{isOpen:e,getPopup:()=>C.context.refs.popupRef.current,onFocusOut:e=>s(!1,ie,e),onSelectionStart:a,onSelectionEnd:o}):null}})},[t,C]),a!==void 0&&y.updated.query&&_e(`query`,"[SuggestionMenu] Both the `query` prop and `handle.update({ query })` set the query; the prop wins."),o!==void 0&&y.updated.anchor&&_e(`anchor`,"[SuggestionMenu] Both the `anchor` prop and `handle.update({ anchor })` set the anchor; the prop wins.");let G=a??y.query;M.useLayoutEffect(()=>{V.current&&G!==R.current&&(V.current=!1,R.current=null,P.current(!0,A))},[G]);let de=o??y.anchor,K=y.payload,q=y.host;W.current=G;let ve=C.useState(`highlightedId`),J=C.useState(`highlightSource`),ye=k&&J===`keyboard`&&H===G?ve:null;M.useEffect(()=>{J!==`keyboard`&&U(null)},[J]),M.useLayoutEffect(()=>{U(null)},[G]);let Y=le({store:C,host:q,open:k,activeDescendant:ye}),[be,X]=M.useState(null),Z=M.useRef(m);Z.current=m;let Q=M.useCallback((e,t)=>{if(e===0&&z.current===`close`){R.current=W.current,P.current(!1,re);return}let n=Z.current(e,t);X(e=>({text:n,key:(e?.key??0)+1}))},[]);M.useEffect(()=>{k||(U(null),X(null))},[k]);let xe=M.useMemo(()=>({}),[y,G,k]),{virtualAnchor:Se,ready:$}=he(k?de:void 0,q,xe),Ce=M.useCallback(e=>{e||(C.clearHighlight(),C.context.onCloseComplete?.(),C.context.onPopupCloseComplete?.()),d?.(e)},[C,d]),we=M.useCallback((e,t)=>{E(e,t.reason,t.event)},[E]),Te=M.useMemo(()=>({handle:t,query:G,payload:K,reportResults:Q,syncHostAria:Y,anchorReady:$}),[t,G,K,Q,Y,$]);return/* @__PURE__ */ ce(h,{store:C,menuTreeResolver:O,focusOwnerStore:ee,openChainStore:w,disabled:D,depth:0,closeAll:te,registerSurface:T,virtualization:ne,virtualAnchor:Se,menuType:`context`,externalFocus:!0,closeOnOutsidePress:`pointerdown`,componentName:`suggestion-menu`,children:[/* @__PURE__ */ N(ge,{forwardKeyDownRef:F}),/* @__PURE__ */ N(me,{announcement:be}),/* @__PURE__ */ N(I.Provider,{value:Te,children:/* @__PURE__ */ N(se.Root,{...v,open:k,onOpenChange:we,onOpenChangeComplete:Ce,modal:!1,children:typeof _==`function`?_({payload:K,query:G}):_})})]})}function J(e){let{virtualized:t,virtualItemsCount:n,filteredCount:r}=e.state;return t?n:r}function ye(e,t){let n=e.context.refs.listRef.current,r=e.context.refs.itemRefs.get(t)?.current??[...n?.querySelectorAll(`[id]`)??[]].find(e=>e.id===t);return(r?.getAttribute(`aria-label`)??r?.textContent?.trim())||e.context.items.get(t)?.value||null}function Y(){let{store:e}=j(),t=ne(),{query:n,reportResults:r}=L(),i=e.useState(`open`),a=e.useState(`highlightedId`),o=e.useState(`highlightSource`),s=t?.rootReveal.settled??!0,c=M.useRef(null);o!==`keyboard`&&o!==`pointer`&&(c.current=a);let l=c.current;return M.useLayoutEffect(()=>{if(!i||!s)return;let t=!1;return queueMicrotask(()=>{if(t)return;let n=e.getVisibleItemIds(),i=e.state.highlightedId,a=i!==null&&n.includes(i)?i:null;r(J(e),a?ye(e,a):null)}),()=>{t=!0}},[i,s,n,l,e,r]),null}const be=/* @__PURE__ */ new Set([`submenu`,`subpage`]);let X=!1;function Z(){process.env.NODE_ENV===`production`||X||(X=!0,console.warn(`[SuggestionMenu] Submenu and subpage definitions are not supported and were skipped.`))}function Q(e){let t=!1,n=e=>e.flatMap(e=>{let r=k(e)?e.def:e;if(be.has(r.kind))return t=!0,[];if(k(e))return[e];let i=`nodes`in r?r.nodes:void 0;if(Array.isArray(i)){let t=n(i);return t.length!==i.length||t.some((e,t)=>e!==i[t])?[{...r,nodes:t}]:[e]}return[e]}),r=n(e);return t&&Z(),t?r:e}const xe=M.forwardRef(function(e,t){let{content:n,asyncContentMode:i=`append`,children:a,...o}=e,{query:s}=L(),{store:c}=j();M.useLayoutEffect(()=>(c.setHasInput(!0),()=>c.setHasInput(!1)),[c]);let l=M.useMemo(()=>n&&Q(n),[n]);return/* @__PURE__ */ ce(r,{ref:t,...o,content:l,asyncContentMode:i,search:s,skipAutoFocus:!0,children:[a,/* @__PURE__ */ N(Y,{})]})}),Se=/* @__PURE__ */ `borderTopWidth.borderRightWidth.borderBottomWidth.borderLeftWidth.borderStyle.paddingTop.paddingRight.paddingBottom.paddingLeft.fontStyle.fontVariant.fontWeight.fontStretch.fontSize.fontSizeAdjust.lineHeight.fontFamily.fontFeatureSettings.fontKerning.textAlign.textTransform.textIndent.textDecoration.letterSpacing.wordSpacing.tabSize.direction.whiteSpace.wordBreak.overflowWrap.hyphens.fontVariationSettings`.split(`.`);function $(e,t){let n=e.ownerDocument,r=n.defaultView;if(!r||!e.isConnected)return null;let i=r.getComputedStyle(e),a=n.createElement(`div`),o=a.style;for(let e of Se)o[e]=i[e];let s=e instanceof HTMLInputElement;o.position=`absolute`,o.visibility=`hidden`,o.top=`0`,o.left=`-9999px`,o.overflow=`hidden`;let c=Number.parseFloat(i.borderLeftWidth)+Number.parseFloat(i.borderRightWidth),l=e=>Number.parseFloat(e)||0,u=i.boxSizing===`border-box`?l(i.width):l(i.width)+l(i.paddingLeft)+l(i.paddingRight)+c,d=e.offsetWidth-e.clientWidth-c;o.boxSizing=`border-box`,o.width=`${u-d}px`,s&&(o.whiteSpace=`pre`,o.lineHeight=`${e.clientHeight-Number.parseFloat(i.paddingTop)-Number.parseFloat(i.paddingBottom)}px`);let f=e.value;a.textContent=f.slice(0,t);let p=n.createElement(`span`);p.textContent=f.slice(t,t+1)||`​`,a.append(p),a.append(f.slice(t+1)),n.body.append(a);try{let t=e.getBoundingClientRect(),n=a.getBoundingClientRect(),r=p.getBoundingClientRect();return new DOMRect(t.left+(r.left-n.left)-e.scrollLeft,t.top+(r.top-n.top)-e.scrollTop,r.width,r.height)}finally{a.remove()}}function Ce(e,t,n){let r=e.slice(0,t),i=null;for(let e of n){if(!e.char)continue;let n=r.lastIndexOf(e.char);if(n<0||i&&n<=i.from)continue;let a=r.slice(n+e.char.length);if(a.includes(`
2
+ `)||!e.allowSpaces&&/\s/.test(a)||a.length<(e.minLength??0))continue;let o=n===0?``:r.charAt(n-1),s=n===0||o===`
3
+ `;(e.startOfLine?!s:!(s||/\s/.test(o)))||(i={trigger:e,query:a,from:n,to:t})}return i}const we=/* @__PURE__ */ new Set([`insertText`,`insertFromPaste`,`insertLineBreak`,`insertParagraph`]),Te=/* @__PURE__ */ new Set([`escape-key`,`item-press`]);function Ee(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=0;for(;i<n-r&&e[e.length-1-i]===t[t.length-1-i];)i++;return{start:r,end:e.length-i}}function De(e,t,n){return n<e.start?n:n>=e.end?n+t:null}function Oe(e,t,n){let r=t.ownerDocument,i=()=>t.getRootNode(),a=()=>i().activeElement===t,o=null,s=()=>{e.host!==t&&(o=e.attach(t))};(e.host===null||a())&&s();let c=t.value,l=null,u=null,d=null,f=[],p=()=>{let n=t.value,r=l;if(l=null,n===c)return;let i=c;c=n;let a=r&&i.slice(0,r.start)===n.slice(0,r.start)&&n.endsWith(i.slice(r.end))?r:Ee(i,n),o=n.length-i.length,s=e=>De(a,o,e);if(f=f.flatMap(e=>{let t=s(e.from);return t===null?[]:[{...e,from:t}]}),u){let t=s(u.from);t===null?(u=null,e.close()):u={...u,from:t,end:s(u.end)??t}}if(d){let e=s(d.from);d=e===null?null:{...d,from:e}}},m=()=>{u&&(d={char:u.char,from:u.from},u=null,e.close())},h=()=>{if(e.host!==t)return;p();let r=t.selectionStart,i=r!==null&&r===t.selectionEnd?Ce(t.value,r,n.triggers):null,a=i!==null&&f.some(e=>e.from===i.from&&e.char===i.trigger.char);if(!i||a)return m();let o=u?.char===i.trigger.char&&u.from===i.from&&u?u.end:i.to;u={char:i.trigger.char,from:i.from,end:o},d=null;let s=i.from;e.update({query:i.query,payload:{...i,to:o},anchor:()=>$(t,s)})},g=e.subscribeOpenChange((n,r)=>{if(n||e.host!==t)return;p();let i=u??d;d=null,i&&Te.has(r)&&f.push({char:i.char,from:i.from})}),_=()=>{s(),h()},v=e=>{let{inputType:n}=e,r=t.selectionStart,i=t.selectionEnd;r!==null&&i!==null&&(we.has(n)||r!==i&&n.startsWith(`delete`))&&(p(),l={start:r,end:i})},y=()=>{a()&&s(),h()},b=n=>{e.host===t&&e.handleKeyDown(n)&&n.stopPropagation()},x=()=>{a()&&h()},S=()=>{u&&h()},C=t;return C.addEventListener(`beforeinput`,v),C.addEventListener(`input`,y),C.addEventListener(`focus`,_),C.addEventListener(`keydown`,b),C.addEventListener(`scroll`,S),r.addEventListener(`selectionchange`,x),()=>{g(),C.removeEventListener(`beforeinput`,v),C.removeEventListener(`input`,y),C.removeEventListener(`focus`,_),C.removeEventListener(`keydown`,b),C.removeEventListener(`scroll`,S),r.removeEventListener(`selectionchange`,x),e.host===t&&m(),o?.()}}function ke(e,t){let n=M.useRef(t);n.current=t;let r=M.useRef(null);return M.useCallback(t=>{r.current?.(),r.current=t?Oe(e,t,{get triggers(){return n.current.triggers}}):null},[e])}var Ae=/* @__PURE__ */ e({Arrow:()=>_,Empty:()=>d,Footer:()=>S,Group:()=>C,GroupLabel:()=>f,GroupValue:()=>te,Handle:()=>P,Header:()=>E,Icon:()=>p,Item:()=>n,LinkItem:()=>l,List:()=>R,Loading:()=>ee,Popup:()=>z,Portal:()=>b,Positioner:()=>B,Root:()=>ve,ScrollDownArrow:()=>w,ScrollUpArrow:()=>t,Separator:()=>x,Surface:()=>xe,Tree:()=>O,TreeConnector:()=>T,TreeItem:()=>v,attachTextTrigger:()=>Oe,createHandle:()=>F,useAsyncMenuCoordinator:()=>g,useDataList:()=>y,useTextTrigger:()=>ke});export{Ae as SuggestionMenu,P as SuggestionMenuHandle,F as createSuggestionMenuHandle,g as useAsyncMenuCoordinator,y as useDataList};
4
+ //# sourceMappingURL=index.js.map