@bazza-ui/react 0.0.0 → 0.1.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ListboxStore-BtcTXpzi.d.cts +351 -0
- package/dist/ListboxStore-DPqpLlAL.d.ts +351 -0
- package/dist/adapters/index.cjs +2 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.cts +363 -0
- package/dist/adapters/index.d.ts +363 -0
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/chunk-4C666HHU.js +2 -0
- package/dist/chunk-4C666HHU.js.map +1 -0
- package/dist/chunk-AVZ64JQ3.js +2 -0
- package/dist/chunk-AVZ64JQ3.js.map +1 -0
- package/dist/chunk-BGJJC6GX.cjs +2 -0
- package/dist/chunk-BGJJC6GX.cjs.map +1 -0
- package/dist/chunk-FWWOE2SW.cjs +2 -0
- package/dist/chunk-FWWOE2SW.cjs.map +1 -0
- package/dist/chunk-JSPKF52O.cjs +2 -0
- package/dist/chunk-JSPKF52O.cjs.map +1 -0
- package/dist/chunk-KWGD24VS.js +2 -0
- package/dist/chunk-KWGD24VS.js.map +1 -0
- package/dist/chunk-M4G6J7DP.cjs +2 -0
- package/dist/chunk-M4G6J7DP.cjs.map +1 -0
- package/dist/chunk-WKAPAKUL.js +2 -0
- package/dist/chunk-WKAPAKUL.js.map +1 -0
- package/dist/combobox/index.cjs +2 -0
- package/dist/combobox/index.cjs.map +1 -0
- package/dist/combobox/index.d.cts +1039 -0
- package/dist/combobox/index.d.ts +1039 -0
- package/dist/combobox/index.js +2 -0
- package/dist/combobox/index.js.map +1 -0
- package/dist/command-score-Dgo3ZS3Z.d.ts +36 -0
- package/dist/command-score-YjNr3ZWi.d.cts +36 -0
- package/dist/context-menu/index.cjs +2 -0
- package/dist/context-menu/index.cjs.map +1 -0
- package/dist/context-menu/index.d.cts +658 -0
- package/dist/context-menu/index.d.ts +658 -0
- package/dist/context-menu/index.js +2 -0
- package/dist/context-menu/index.js.map +1 -0
- package/dist/data-surface-B-eIGTBi.d.cts +678 -0
- package/dist/data-surface-D1OilMDu.d.ts +678 -0
- package/dist/dropdown-menu/index.cjs +2 -0
- package/dist/dropdown-menu/index.cjs.map +1 -0
- package/dist/dropdown-menu/index.d.cts +700 -0
- package/dist/dropdown-menu/index.d.ts +700 -0
- package/dist/dropdown-menu/index.js +2 -0
- package/dist/dropdown-menu/index.js.map +1 -0
- package/dist/events-BPr8sRGH.d.cts +166 -0
- package/dist/events-BPr8sRGH.d.ts +166 -0
- package/dist/input-BoIK003I.d.cts +41 -0
- package/dist/input-DF7D8YzW.d.ts +41 -0
- package/dist/internal/listbox/index.cjs +2 -0
- package/dist/internal/listbox/index.cjs.map +1 -0
- package/dist/internal/listbox/index.d.cts +269 -0
- package/dist/internal/listbox/index.d.ts +269 -0
- package/dist/internal/listbox/index.js +2 -0
- package/dist/internal/listbox/index.js.map +1 -0
- package/dist/internal/popup-menu/index.cjs +2 -0
- package/dist/internal/popup-menu/index.cjs.map +1 -0
- package/dist/internal/popup-menu/index.d.cts +846 -0
- package/dist/internal/popup-menu/index.d.ts +846 -0
- package/dist/internal/popup-menu/index.js +2 -0
- package/dist/internal/popup-menu/index.js.map +1 -0
- package/dist/item-equality-B6TbXlBT.d.cts +7 -0
- package/dist/item-equality-B6TbXlBT.d.ts +7 -0
- package/dist/loading-DphSt8MY.d.cts +27 -0
- package/dist/loading-TsgH6v92.d.ts +27 -0
- package/dist/select/index.cjs +2 -0
- package/dist/select/index.cjs.map +1 -0
- package/dist/select/index.d.cts +927 -0
- package/dist/select/index.d.ts +927 -0
- package/dist/select/index.js +2 -0
- package/dist/select/index.js.map +1 -0
- package/dist/separator-B4Ot84B0.d.ts +748 -0
- package/dist/separator-BmbUeeaT.d.cts +748 -0
- package/dist/types-9vS1uLIK.d.cts +1557 -0
- package/dist/types-lQCIvWW8.d.ts +1557 -0
- package/dist/use-listbox-item-BIi4eRPI.d.cts +182 -0
- package/dist/use-listbox-item-BIi4eRPI.d.ts +182 -0
- package/package.json +50 -12
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { a2 as NodeDef, Z as InitialQueryBehavior, a1 as LoaderComponentProps, a4 as QueryDependentLoaderConfig, ah as StaticLoaderConfig, t as AsyncLoaderResult } from '../types-lQCIvWW8.js';
|
|
3
|
+
import '../events-BPr8sRGH.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SWR result shape (subset of SWRResponse).
|
|
7
|
+
* This allows the adapter to work without requiring `swr` as a dependency.
|
|
8
|
+
*/
|
|
9
|
+
interface SWRResult<TData, TError = Error> {
|
|
10
|
+
data: TData | undefined;
|
|
11
|
+
error: TError | undefined;
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
isValidating: boolean;
|
|
14
|
+
isPaused?: boolean;
|
|
15
|
+
mutate: (...args: unknown[]) => unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Converts an SWR result to an AsyncLoaderResult.
|
|
19
|
+
*/
|
|
20
|
+
declare function toAsyncLoaderResultFromSWR<TData, TError = Error>(result: SWRResult<TData, TError>): AsyncLoaderResult<TData, SWRResult<TData, TError>>;
|
|
21
|
+
/**
|
|
22
|
+
* Props for creating a static SWR loader component.
|
|
23
|
+
*/
|
|
24
|
+
interface CreateSWRStaticLoaderProps {
|
|
25
|
+
/** Hook that returns an SWR result. */
|
|
26
|
+
useSWR: () => SWRResult<NodeDef[]>;
|
|
27
|
+
/**
|
|
28
|
+
* When to trigger the loader:
|
|
29
|
+
* - 'eager': Load when root menu opens
|
|
30
|
+
* - 'lazy': Load when submenu opens (default)
|
|
31
|
+
*/
|
|
32
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a static loader configuration backed by SWR.
|
|
36
|
+
*/
|
|
37
|
+
declare function createSWRStaticLoader(props: CreateSWRStaticLoaderProps): StaticLoaderConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Props for creating a query-dependent SWR loader component.
|
|
40
|
+
*/
|
|
41
|
+
interface CreateSWRQueryLoaderProps {
|
|
42
|
+
/**
|
|
43
|
+
* Hook that returns an SWR result based on the search query.
|
|
44
|
+
* `options.enabled` can be used to derive a `null` key and disable fetching.
|
|
45
|
+
*/
|
|
46
|
+
useSWR: (query: string, options?: {
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
}) => SWRResult<NodeDef[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Minimum query length before fetching.
|
|
51
|
+
* @default 1
|
|
52
|
+
*/
|
|
53
|
+
minQueryLength?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Initial query behavior before user input reaches minQueryLength.
|
|
56
|
+
* Defaults to fetching with an empty query.
|
|
57
|
+
*/
|
|
58
|
+
initialQueryBehavior?: InitialQueryBehavior | false;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Use `initialQueryBehavior` instead.
|
|
61
|
+
*/
|
|
62
|
+
initialQuery?: string;
|
|
63
|
+
/**
|
|
64
|
+
* When to trigger the loader:
|
|
65
|
+
* - 'eager': Load when root menu opens (good for deep search)
|
|
66
|
+
* - 'lazy': Load when submenu opens (default)
|
|
67
|
+
* @default 'lazy'
|
|
68
|
+
*/
|
|
69
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
70
|
+
/**
|
|
71
|
+
* What to show when query is below minQueryLength.
|
|
72
|
+
* @default 'empty'
|
|
73
|
+
*/
|
|
74
|
+
belowMinBehavior?: 'empty' | 'placeholder';
|
|
75
|
+
/**
|
|
76
|
+
* Placeholder nodes shown when query is below minQueryLength.
|
|
77
|
+
*/
|
|
78
|
+
placeholderNodes?: NodeDef[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a query-dependent loader configuration backed by SWR.
|
|
82
|
+
*/
|
|
83
|
+
declare function createSWRQueryLoader(props: CreateSWRQueryLoaderProps): QueryDependentLoaderConfig;
|
|
84
|
+
/**
|
|
85
|
+
* Creates a loader component that wraps an SWR hook.
|
|
86
|
+
*/
|
|
87
|
+
declare function createSWRLoaderComponent(useSWRFn: (query: string) => SWRResult<NodeDef[]>): React.FC<LoaderComponentProps>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* TanStack Query result shape (subset of UseQueryResult).
|
|
91
|
+
* This allows the adapter to work without requiring @tanstack/react-query as a dependency.
|
|
92
|
+
*/
|
|
93
|
+
interface TanStackQueryResult<TData, TError = Error> {
|
|
94
|
+
/** TanStack status (`pending` | `error` | `success`) */
|
|
95
|
+
status?: 'pending' | 'error' | 'success';
|
|
96
|
+
/** TanStack fetch status (`fetching` | `paused` | `idle`) */
|
|
97
|
+
fetchStatus?: 'fetching' | 'paused' | 'idle';
|
|
98
|
+
data: TData | undefined;
|
|
99
|
+
error: TError | null | undefined;
|
|
100
|
+
/** v5: true when first fetch is in-flight */
|
|
101
|
+
isLoading?: boolean;
|
|
102
|
+
/** v5: true when status is pending */
|
|
103
|
+
isPending?: boolean;
|
|
104
|
+
/** true when status is success */
|
|
105
|
+
isSuccess?: boolean;
|
|
106
|
+
/** true when status is error */
|
|
107
|
+
isError?: boolean;
|
|
108
|
+
/** true while any fetch is in-flight */
|
|
109
|
+
isFetching?: boolean;
|
|
110
|
+
/** true while background refetch is in-flight */
|
|
111
|
+
isRefetching?: boolean;
|
|
112
|
+
/** true when fetch is paused */
|
|
113
|
+
isPaused?: boolean;
|
|
114
|
+
/** true once query has fetched at least once */
|
|
115
|
+
isFetched?: boolean;
|
|
116
|
+
refetch: () => unknown;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Converts a TanStack Query result to an AsyncLoaderResult.
|
|
120
|
+
* Use this to wrap your useQuery hook result.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* function MyLoader({ query, children }) {
|
|
125
|
+
* const result = useQuery({
|
|
126
|
+
* queryKey: ['items', query],
|
|
127
|
+
* queryFn: () => fetchItems(query),
|
|
128
|
+
* })
|
|
129
|
+
* return children(toAsyncLoaderResult(result))
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
declare function toAsyncLoaderResult<TData, TError = Error>(result: TanStackQueryResult<TData, TError>): AsyncLoaderResult<TData, TanStackQueryResult<TData, TError>>;
|
|
134
|
+
/**
|
|
135
|
+
* Props for creating a static loader component.
|
|
136
|
+
*/
|
|
137
|
+
interface CreateStaticLoaderProps {
|
|
138
|
+
/**
|
|
139
|
+
* Hook that returns a TanStack Query result.
|
|
140
|
+
* This hook will be called inside the loader component.
|
|
141
|
+
*/
|
|
142
|
+
useQuery: () => TanStackQueryResult<NodeDef[]>;
|
|
143
|
+
/**
|
|
144
|
+
* When to trigger the loader:
|
|
145
|
+
* - 'eager': Load when root menu opens
|
|
146
|
+
* - 'lazy': Load when submenu opens (default)
|
|
147
|
+
*/
|
|
148
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Creates a static loader configuration for use with async menus.
|
|
152
|
+
* The hook is called inside a component, so it follows React's rules of hooks.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* const recentFilesLoader = createStaticLoader({
|
|
157
|
+
* useQuery: () => useQuery({
|
|
158
|
+
* queryKey: ['recent-files'],
|
|
159
|
+
* queryFn: fetchRecentFiles,
|
|
160
|
+
* staleTime: 5 * 60 * 1000,
|
|
161
|
+
* }),
|
|
162
|
+
* })
|
|
163
|
+
*
|
|
164
|
+
* // Use in submenu
|
|
165
|
+
* {
|
|
166
|
+
* kind: 'submenu',
|
|
167
|
+
* value: 'Recent Files',
|
|
168
|
+
* asyncNodes: {
|
|
169
|
+
* ...recentFilesLoader,
|
|
170
|
+
* loadStrategy: 'eager',
|
|
171
|
+
* },
|
|
172
|
+
* render: ...
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
declare function createStaticLoader(props: CreateStaticLoaderProps): StaticLoaderConfig;
|
|
177
|
+
/**
|
|
178
|
+
* Props for creating a query-dependent loader component.
|
|
179
|
+
*/
|
|
180
|
+
interface CreateQueryLoaderProps {
|
|
181
|
+
/**
|
|
182
|
+
* Hook that returns a TanStack Query result based on the search query.
|
|
183
|
+
* This hook will be called inside the loader component with the current query.
|
|
184
|
+
*/
|
|
185
|
+
useQuery: (query: string, options?: {
|
|
186
|
+
enabled: boolean;
|
|
187
|
+
}) => TanStackQueryResult<NodeDef[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Minimum query length before fetching.
|
|
190
|
+
* @default 1
|
|
191
|
+
*/
|
|
192
|
+
minQueryLength?: number;
|
|
193
|
+
/**
|
|
194
|
+
* Initial query behavior before user input reaches minQueryLength.
|
|
195
|
+
* Defaults to fetching with an empty query.
|
|
196
|
+
*/
|
|
197
|
+
initialQueryBehavior?: InitialQueryBehavior | false;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated Use `initialQueryBehavior` instead.
|
|
200
|
+
*/
|
|
201
|
+
initialQuery?: string;
|
|
202
|
+
/**
|
|
203
|
+
* When to trigger the loader:
|
|
204
|
+
* - 'eager': Load when root menu opens (good for deep search)
|
|
205
|
+
* - 'lazy': Load when submenu opens (default)
|
|
206
|
+
* @default 'lazy'
|
|
207
|
+
*/
|
|
208
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
209
|
+
/**
|
|
210
|
+
* What to show when query is below minQueryLength.
|
|
211
|
+
* @default 'empty'
|
|
212
|
+
*/
|
|
213
|
+
belowMinBehavior?: 'empty' | 'placeholder';
|
|
214
|
+
/**
|
|
215
|
+
* Placeholder nodes shown when query is below minQueryLength.
|
|
216
|
+
*/
|
|
217
|
+
placeholderNodes?: NodeDef[];
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Creates a query-dependent loader configuration for use with async menus.
|
|
221
|
+
* The loader will re-fetch when the search query changes.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```tsx
|
|
225
|
+
* const searchLoader = createQueryLoader({
|
|
226
|
+
* useQuery: (query, options) => useQuery({
|
|
227
|
+
* queryKey: ['search', query],
|
|
228
|
+
* queryFn: () => searchItems(query),
|
|
229
|
+
* enabled: options?.enabled,
|
|
230
|
+
* }),
|
|
231
|
+
* minQueryLength: 2,
|
|
232
|
+
* })
|
|
233
|
+
*
|
|
234
|
+
* // Use in submenu
|
|
235
|
+
* {
|
|
236
|
+
* kind: 'submenu',
|
|
237
|
+
* value: 'Search',
|
|
238
|
+
* includeInDeepSearch: true,
|
|
239
|
+
* asyncNodes: searchLoader,
|
|
240
|
+
* render: ...
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
declare function createQueryLoader(props: CreateQueryLoaderProps): QueryDependentLoaderConfig;
|
|
245
|
+
/**
|
|
246
|
+
* Creates a loader component that wraps a TanStack Query hook.
|
|
247
|
+
* This is a lower-level utility for custom loader implementations.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```tsx
|
|
251
|
+
* const MyLoader = createLoaderComponent((query) =>
|
|
252
|
+
* useQuery({
|
|
253
|
+
* queryKey: ['items', query],
|
|
254
|
+
* queryFn: () => fetchItems(query),
|
|
255
|
+
* })
|
|
256
|
+
* )
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
declare function createLoaderComponent(useQueryFn: (query: string) => TanStackQueryResult<NodeDef[]>): React.FC<LoaderComponentProps>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Props for creating a static loader with vanilla fetch.
|
|
263
|
+
*/
|
|
264
|
+
interface CreateVanillaStaticLoaderProps {
|
|
265
|
+
/**
|
|
266
|
+
* Async function that fetches the menu items.
|
|
267
|
+
*/
|
|
268
|
+
fetcher: () => Promise<NodeDef[]>;
|
|
269
|
+
/**
|
|
270
|
+
* When to trigger the loader:
|
|
271
|
+
* - 'eager': Load when root menu opens
|
|
272
|
+
* - 'lazy': Load when submenu opens (default)
|
|
273
|
+
*/
|
|
274
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Creates a static loader configuration using plain fetch/promises.
|
|
278
|
+
* No external data library required.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```tsx
|
|
282
|
+
* const recentFilesLoader = createVanillaStaticLoader({
|
|
283
|
+
* fetcher: async () => {
|
|
284
|
+
* const res = await fetch('/api/recent-files')
|
|
285
|
+
* const data = await res.json()
|
|
286
|
+
* return data.map(file => ({
|
|
287
|
+
* kind: 'item',
|
|
288
|
+
* value: file.name,
|
|
289
|
+
* render: ...
|
|
290
|
+
* }))
|
|
291
|
+
* },
|
|
292
|
+
* })
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
declare function createVanillaStaticLoader(props: CreateVanillaStaticLoaderProps): StaticLoaderConfig;
|
|
296
|
+
/**
|
|
297
|
+
* Props for creating a query-dependent loader with vanilla fetch.
|
|
298
|
+
*/
|
|
299
|
+
interface CreateVanillaQueryLoaderProps {
|
|
300
|
+
/**
|
|
301
|
+
* Async function that fetches menu items based on the search query.
|
|
302
|
+
* Receives an optional `signal` that is aborted when a newer query is issued,
|
|
303
|
+
* allowing you to cancel in-flight requests (e.g. pass it to `fetch()`).
|
|
304
|
+
*/
|
|
305
|
+
fetcher: (query: string, options?: {
|
|
306
|
+
signal?: AbortSignal;
|
|
307
|
+
}) => Promise<NodeDef[]>;
|
|
308
|
+
/**
|
|
309
|
+
* Minimum query length before fetching.
|
|
310
|
+
* @default 1
|
|
311
|
+
*/
|
|
312
|
+
minQueryLength?: number;
|
|
313
|
+
/**
|
|
314
|
+
* Initial query behavior before user input reaches minQueryLength.
|
|
315
|
+
* Defaults to fetching with an empty query.
|
|
316
|
+
*/
|
|
317
|
+
initialQueryBehavior?: InitialQueryBehavior | false;
|
|
318
|
+
/**
|
|
319
|
+
* @deprecated Use `initialQueryBehavior` instead.
|
|
320
|
+
*/
|
|
321
|
+
initialQuery?: string;
|
|
322
|
+
/**
|
|
323
|
+
* When to trigger the loader:
|
|
324
|
+
* - 'eager': Load when root menu opens (good for deep search)
|
|
325
|
+
* - 'lazy': Load when submenu opens (default)
|
|
326
|
+
* @default 'lazy'
|
|
327
|
+
*/
|
|
328
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
329
|
+
/**
|
|
330
|
+
* What to show when query is below minQueryLength.
|
|
331
|
+
* @default 'empty'
|
|
332
|
+
*/
|
|
333
|
+
belowMinBehavior?: 'empty' | 'placeholder';
|
|
334
|
+
/**
|
|
335
|
+
* Placeholder nodes shown when query is below minQueryLength.
|
|
336
|
+
*/
|
|
337
|
+
placeholderNodes?: NodeDef[];
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Creates a query-dependent loader configuration using plain fetch/promises.
|
|
341
|
+
* No external data library required.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```tsx
|
|
345
|
+
* const searchLoader = createVanillaQueryLoader({
|
|
346
|
+
* fetcher: async (query, options) => {
|
|
347
|
+
* const res = await fetch(`/api/search?q=${encodeURIComponent(query)}`, {
|
|
348
|
+
* signal: options?.signal, // aborts when a newer query is issued
|
|
349
|
+
* })
|
|
350
|
+
* const data = await res.json()
|
|
351
|
+
* return data.map(item => ({
|
|
352
|
+
* kind: 'item',
|
|
353
|
+
* value: item.name,
|
|
354
|
+
* render: ...
|
|
355
|
+
* }))
|
|
356
|
+
* },
|
|
357
|
+
* minQueryLength: 2,
|
|
358
|
+
* })
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare function createVanillaQueryLoader(props: CreateVanillaQueryLoaderProps): QueryDependentLoaderConfig;
|
|
362
|
+
|
|
363
|
+
export { type CreateQueryLoaderProps, type CreateSWRQueryLoaderProps, type CreateSWRStaticLoaderProps, type CreateStaticLoaderProps, type CreateVanillaQueryLoaderProps, type CreateVanillaStaticLoaderProps, type SWRResult, type TanStackQueryResult, createLoaderComponent, createQueryLoader, createSWRLoaderComponent, createSWRQueryLoader, createSWRStaticLoader, createStaticLoader, createVanillaQueryLoader, createVanillaStaticLoader, toAsyncLoaderResult, toAsyncLoaderResultFromSWR };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-4C666HHU.js";import{Fragment as S,jsx as R}from"react/jsx-runtime";function D(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function g(e){let o=D(e.error),a=e.data!==void 0,n=e.isPaused?"paused":e.isValidating?"fetching":"idle",r=n==="fetching",t=e.isLoading??(r&&!a&&o==null),c=r&&!t,s=o?"error":a?"success":t||r?"pending":"idle",i=t?"initial":c?"background":"none";return{data:e.data,raw:e,source:"swr",error:o,status:s,fetchStatus:n,loadingPhase:i,isLoading:t,isFetching:r,isInitialLoading:t,isRefetching:c,isPending:s==="pending",isSuccess:s==="success",isError:s==="error",isPaused:n==="paused",hasData:a,hasFetched:a||o!=null||t||c,refetch:()=>e.mutate()}}function A(e){let{useSWR:o,loadStrategy:a}=e;return{type:"static",Loader:({children:r})=>{let t=o();return R(S,{children:r(g(t))})},loadStrategy:a}}function T(e){let{useSWR:o,minQueryLength:a=1,initialQueryBehavior:n,initialQuery:r,loadStrategy:t,belowMinBehavior:c="empty",placeholderNodes:s}=e,i=n!==void 0?n:r!==void 0?{value:r,loadWhen:"needed"}:{value:"",loadWhen:"needed"};return{type:"query",Loader:({query:l,enabled:h,children:f})=>{let y=h??(l.length>=a||i!==!1),p=o(l,{enabled:y});return R(S,{children:f(g(p))})},minQueryLength:a,initialQueryBehavior:i,initialQuery:r,loadStrategy:t,belowMinBehavior:c,placeholderNodes:s}}function E(e){return function({query:a,children:n}){let r=e(a);return R(S,{children:n(g(r))})}}import{Fragment as Q,jsx as F}from"react/jsx-runtime";function v(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function L(e){let o=e.data!==void 0,a=e.fetchStatus?e.fetchStatus:e.isPaused?"paused":e.isFetching||e.isLoading?"fetching":"idle",n=a==="fetching",r=e.status?e.status:e.isError?"error":e.isSuccess||o?"success":e.isPending||e.isLoading||n?"pending":"idle",t=e.isPending??r==="pending",c=e.isSuccess??r==="success",s=e.isError??r==="error",i=e.isLoading??(t&&n),u=e.isRefetching??(n&&!i),l=e.isPaused??a==="paused",h=e.isFetched??(c||s||i||u),f=i?"initial":u?"background":"none";return{data:e.data,raw:e,source:"tanstack-query",error:v(e.error),status:r,fetchStatus:a,loadingPhase:f,isLoading:i,isFetching:n,isInitialLoading:i,isRefetching:u,isPending:t,isSuccess:c,isError:s,isPaused:l,hasData:o,hasFetched:h,refetch:e.refetch}}function W(e){let{useQuery:o,loadStrategy:a}=e;return{type:"static",Loader:({children:r})=>{let t=o();return F(Q,{children:r(L(t))})},loadStrategy:a}}function B(e){let{useQuery:o,minQueryLength:a=1,initialQueryBehavior:n,initialQuery:r,loadStrategy:t,belowMinBehavior:c="empty",placeholderNodes:s}=e,i=n!==void 0?n:r!==void 0?{value:r,loadWhen:"needed"}:{value:"",loadWhen:"needed"};return{type:"query",Loader:({query:l,enabled:h,children:f})=>{let y=h??(l.length>=a||i!==!1),p=o(l,{enabled:y});return F(Q,{children:f(L(p))})},minQueryLength:a,initialQueryBehavior:i,initialQuery:r,loadStrategy:t,belowMinBehavior:c,placeholderNodes:s}}function N(e){return function({query:a,children:n}){let r=e(a);return F(Q,{children:n(L(r))})}}import*as d from"react";import{Fragment as P,jsx as b}from"react/jsx-runtime";function m(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function k(e){return e.error?"error":e.data!==void 0?"success":e.isFetching?"pending":"idle"}function C(e,o){let a=k(e),n=e.isFetching?"fetching":"idle",r=e.isFetching&&!e.hasFetched,t=e.isFetching&&e.hasFetched,c=r?"initial":t?"background":"none";return{data:e.data,source:"vanilla",error:e.error,status:a,fetchStatus:n,loadingPhase:c,isLoading:r,isFetching:e.isFetching,isInitialLoading:r,isRefetching:t,isPending:a==="pending",isSuccess:a==="success",isError:a==="error",isPaused:!1,hasData:e.data!==void 0,hasFetched:e.hasFetched,refetch:o}}function w(e,o){let{enabled:a=!0}=o??{},[n,r]=d.useState(()=>({data:void 0,error:null,isFetching:a,hasFetched:!1})),t=d.useRef(e);t.current=e;let c=d.useCallback(()=>{r(s=>({...s,isFetching:!0,error:null})),t.current().then(s=>{r({data:s,error:null,isFetching:!1,hasFetched:!0})}).catch(s=>{r(i=>({...i,error:m(s),isFetching:!1,hasFetched:!0}))})},[]);return d.useEffect(()=>{if(a){c();return}r(s=>({...s,isFetching:!1}))},[a,c]),d.useMemo(()=>C(n,c),[n,c])}function I(e,o,a){let{enabled:n=!0}=a??{},[r,t]=d.useState(()=>({data:void 0,error:null,isFetching:n,hasFetched:!1})),c=d.useRef(e);c.current=e,d.useEffect(()=>{if(!n){t({data:void 0,error:null,isFetching:!1,hasFetched:!1});return}let i=new AbortController;return t({data:void 0,error:null,isFetching:!0,hasFetched:!1}),c.current(o,{signal:i.signal}).then(u=>{i.signal.aborted||t({data:u,error:null,isFetching:!1,hasFetched:!0})}).catch(u=>{i.signal.aborted||t({data:void 0,error:m(u),isFetching:!1,hasFetched:!0})}),()=>{i.abort()}},[n,o]);let s=d.useCallback(()=>{t(i=>({...i,isFetching:!0,error:null})),c.current(o).then(i=>{t({data:i,error:null,isFetching:!1,hasFetched:!0})}).catch(i=>{t(u=>({...u,error:m(i),isFetching:!1,hasFetched:!0}))})},[o]);return d.useMemo(()=>C(r,s),[r,s])}function V(e){let{fetcher:o,loadStrategy:a}=e;return{type:"static",Loader:({children:r})=>{let t=w(o);return b(P,{children:r(t)})},loadStrategy:a}}function x(e){let{fetcher:o,minQueryLength:a=1,initialQueryBehavior:n,initialQuery:r,loadStrategy:t,belowMinBehavior:c="empty",placeholderNodes:s}=e,i=n!==void 0?n:r!==void 0?{value:r,loadWhen:"needed"}:{value:"",loadWhen:"needed"};return{type:"query",Loader:({query:l,enabled:h,children:f})=>{let y=h??(l.length>=a||i!==!1),p=I(o,l,{enabled:y});return b(P,{children:f(p)})},minQueryLength:a,initialQueryBehavior:i,initialQuery:r,loadStrategy:t,belowMinBehavior:c,placeholderNodes:s}}export{N as createLoaderComponent,B as createQueryLoader,E as createSWRLoaderComponent,T as createSWRQueryLoader,A as createSWRStaticLoader,W as createStaticLoader,x as createVanillaQueryLoader,V as createVanillaStaticLoader,L as toAsyncLoaderResult,g as toAsyncLoaderResultFromSWR};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/swr.tsx","../../src/adapters/tanstack-query.tsx","../../src/adapters/vanilla.tsx"],"sourcesContent":["'use client'\n\nimport type * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/types.js'\n\n// ============================================================================\n// SWR Adapter\n// ============================================================================\n\n/**\n * SWR result shape (subset of SWRResponse).\n * This allows the adapter to work without requiring `swr` as a dependency.\n */\nexport interface SWRResult<TData, TError = Error> {\n data: TData | undefined\n error: TError | undefined\n isLoading?: boolean\n isValidating: boolean\n isPaused?: boolean\n mutate: (...args: unknown[]) => unknown\n}\n\nfunction toError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\n/**\n * Converts an SWR result to an AsyncLoaderResult.\n */\nexport function toAsyncLoaderResultFromSWR<TData, TError = Error>(\n result: SWRResult<TData, TError>,\n): AsyncLoaderResult<TData, SWRResult<TData, TError>> {\n const normalizedError = toError(result.error)\n const hasData = result.data !== undefined\n\n const fetchStatus: AsyncLoaderFetchStatus = result.isPaused\n ? 'paused'\n : result.isValidating\n ? 'fetching'\n : 'idle'\n\n const isFetching = fetchStatus === 'fetching'\n const isInitialLoading =\n result.isLoading ?? (isFetching && !hasData && normalizedError == null)\n const isRefetching = isFetching && !isInitialLoading\n\n const status: AsyncLoaderStatus = normalizedError\n ? 'error'\n : hasData\n ? 'success'\n : isInitialLoading || isFetching\n ? 'pending'\n : 'idle'\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: result.data,\n raw: result,\n source: 'swr',\n error: normalizedError,\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching,\n isInitialLoading,\n isRefetching,\n isPending: status === 'pending',\n isSuccess: status === 'success',\n isError: status === 'error',\n isPaused: fetchStatus === 'paused',\n hasData,\n hasFetched:\n hasData || normalizedError != null || isInitialLoading || isRefetching,\n refetch: () => result.mutate(),\n }\n}\n\n/**\n * Props for creating a static SWR loader component.\n */\nexport interface CreateSWRStaticLoaderProps {\n /** Hook that returns an SWR result. */\n useSWR: () => SWRResult<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration backed by SWR.\n */\nexport function createSWRStaticLoader(\n props: CreateSWRStaticLoaderProps,\n): StaticLoaderConfig {\n const { useSWR, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useSWR()\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query-dependent SWR loader component.\n */\nexport interface CreateSWRQueryLoaderProps {\n /**\n * Hook that returns an SWR result based on the search query.\n * `options.enabled` can be used to derive a `null` key and disable fetching.\n */\n useSWR: (\n query: string,\n options?: { enabled: boolean },\n ) => SWRResult<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query-dependent loader configuration backed by SWR.\n */\nexport function createSWRQueryLoader(\n props: CreateSWRQueryLoaderProps,\n): QueryDependentLoaderConfig {\n const {\n useSWR,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useSWR(query, { enabled: isEnabled })\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n\n/**\n * Creates a loader component that wraps an SWR hook.\n */\nexport function createSWRLoaderComponent(\n useSWRFn: (query: string) => SWRResult<NodeDef[]>,\n): React.FC<LoaderComponentProps> {\n return function SWRLoader({ query, children }) {\n const result = useSWRFn(query)\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n}\n","'use client'\n\nimport type * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/types.js'\n\n// ============================================================================\n// TanStack Query Adapter\n// ============================================================================\n\n/**\n * TanStack Query result shape (subset of UseQueryResult).\n * This allows the adapter to work without requiring @tanstack/react-query as a dependency.\n */\nexport interface TanStackQueryResult<TData, TError = Error> {\n /** TanStack status (`pending` | `error` | `success`) */\n status?: 'pending' | 'error' | 'success'\n\n /** TanStack fetch status (`fetching` | `paused` | `idle`) */\n fetchStatus?: 'fetching' | 'paused' | 'idle'\n\n data: TData | undefined\n error: TError | null | undefined\n\n /** v5: true when first fetch is in-flight */\n isLoading?: boolean\n\n /** v5: true when status is pending */\n isPending?: boolean\n\n /** true when status is success */\n isSuccess?: boolean\n\n /** true when status is error */\n isError?: boolean\n\n /** true while any fetch is in-flight */\n isFetching?: boolean\n\n /** true while background refetch is in-flight */\n isRefetching?: boolean\n\n /** true when fetch is paused */\n isPaused?: boolean\n\n /** true once query has fetched at least once */\n isFetched?: boolean\n\n refetch: () => unknown\n}\n\nfunction toError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\n/**\n * Converts a TanStack Query result to an AsyncLoaderResult.\n * Use this to wrap your useQuery hook result.\n *\n * @example\n * ```tsx\n * function MyLoader({ query, children }) {\n * const result = useQuery({\n * queryKey: ['items', query],\n * queryFn: () => fetchItems(query),\n * })\n * return children(toAsyncLoaderResult(result))\n * }\n * ```\n */\nexport function toAsyncLoaderResult<TData, TError = Error>(\n result: TanStackQueryResult<TData, TError>,\n): AsyncLoaderResult<TData, TanStackQueryResult<TData, TError>> {\n const hasData = result.data !== undefined\n\n const fetchStatus: AsyncLoaderFetchStatus = result.fetchStatus\n ? result.fetchStatus\n : result.isPaused\n ? 'paused'\n : result.isFetching || result.isLoading\n ? 'fetching'\n : 'idle'\n\n const isFetching = fetchStatus === 'fetching'\n\n const status: AsyncLoaderStatus = result.status\n ? result.status\n : result.isError\n ? 'error'\n : result.isSuccess || hasData\n ? 'success'\n : result.isPending || result.isLoading || isFetching\n ? 'pending'\n : 'idle'\n\n const isPending = result.isPending ?? status === 'pending'\n const isSuccess = result.isSuccess ?? status === 'success'\n const isError = result.isError ?? status === 'error'\n const isInitialLoading = result.isLoading ?? (isPending && isFetching)\n const isRefetching = result.isRefetching ?? (isFetching && !isInitialLoading)\n const isPaused = result.isPaused ?? fetchStatus === 'paused'\n const hasFetched =\n result.isFetched ??\n (isSuccess || isError || isInitialLoading || isRefetching)\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: result.data,\n raw: result,\n source: 'tanstack-query',\n error: toError(result.error),\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching,\n isInitialLoading,\n isRefetching,\n isPending,\n isSuccess,\n isError,\n isPaused,\n hasData,\n hasFetched,\n refetch: result.refetch,\n }\n}\n\n/**\n * Props for creating a static loader component.\n */\nexport interface CreateStaticLoaderProps {\n /**\n * Hook that returns a TanStack Query result.\n * This hook will be called inside the loader component.\n */\n useQuery: () => TanStackQueryResult<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration for use with async menus.\n * The hook is called inside a component, so it follows React's rules of hooks.\n *\n * @example\n * ```tsx\n * const recentFilesLoader = createStaticLoader({\n * useQuery: () => useQuery({\n * queryKey: ['recent-files'],\n * queryFn: fetchRecentFiles,\n * staleTime: 5 * 60 * 1000,\n * }),\n * })\n *\n * // Use in submenu\n * {\n * kind: 'submenu',\n * value: 'Recent Files',\n * asyncNodes: {\n * ...recentFilesLoader,\n * loadStrategy: 'eager',\n * },\n * render: ...\n * }\n * ```\n */\nexport function createStaticLoader(\n props: CreateStaticLoaderProps,\n): StaticLoaderConfig {\n const { useQuery, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useQuery()\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query-dependent loader component.\n */\nexport interface CreateQueryLoaderProps {\n /**\n * Hook that returns a TanStack Query result based on the search query.\n * This hook will be called inside the loader component with the current query.\n */\n useQuery: (\n query: string,\n options?: { enabled: boolean },\n ) => TanStackQueryResult<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query-dependent loader configuration for use with async menus.\n * The loader will re-fetch when the search query changes.\n *\n * @example\n * ```tsx\n * const searchLoader = createQueryLoader({\n * useQuery: (query, options) => useQuery({\n * queryKey: ['search', query],\n * queryFn: () => searchItems(query),\n * enabled: options?.enabled,\n * }),\n * minQueryLength: 2,\n * })\n *\n * // Use in submenu\n * {\n * kind: 'submenu',\n * value: 'Search',\n * includeInDeepSearch: true,\n * asyncNodes: searchLoader,\n * render: ...\n * }\n * ```\n */\nexport function createQueryLoader(\n props: CreateQueryLoaderProps,\n): QueryDependentLoaderConfig {\n const {\n useQuery,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useQuery(query, { enabled: isEnabled })\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n\n/**\n * Creates a loader component that wraps a TanStack Query hook.\n * This is a lower-level utility for custom loader implementations.\n *\n * @example\n * ```tsx\n * const MyLoader = createLoaderComponent((query) =>\n * useQuery({\n * queryKey: ['items', query],\n * queryFn: () => fetchItems(query),\n * })\n * )\n * ```\n */\nexport function createLoaderComponent(\n useQueryFn: (query: string) => TanStackQueryResult<NodeDef[]>,\n): React.FC<LoaderComponentProps> {\n return function TanStackLoader({ query, children }) {\n const result = useQueryFn(query)\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n}\n","'use client'\n\nimport * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/types.js'\n\n// ============================================================================\n// Vanilla Async Adapter (no external dependencies)\n// ============================================================================\n\ninterface VanillaAsyncInternalState<TData> {\n data: TData | undefined\n error: Error | null\n isFetching: boolean\n hasFetched: boolean\n}\n\nfunction normalizeError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\nfunction getVanillaStatus<TData>(\n state: VanillaAsyncInternalState<TData>,\n): AsyncLoaderStatus {\n if (state.error) {\n return 'error'\n }\n\n if (state.data !== undefined) {\n return 'success'\n }\n\n if (state.isFetching) {\n return 'pending'\n }\n\n return 'idle'\n}\n\nfunction toVanillaAsyncLoaderResult<TData>(\n state: VanillaAsyncInternalState<TData>,\n refetch: () => unknown,\n): AsyncLoaderResult<TData> {\n const status = getVanillaStatus(state)\n const fetchStatus: AsyncLoaderFetchStatus = state.isFetching\n ? 'fetching'\n : 'idle'\n\n const isInitialLoading = state.isFetching && !state.hasFetched\n const isRefetching = state.isFetching && state.hasFetched\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: state.data,\n source: 'vanilla',\n error: state.error,\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching: state.isFetching,\n isInitialLoading,\n isRefetching,\n isPending: status === 'pending',\n isSuccess: status === 'success',\n isError: status === 'error',\n isPaused: false,\n hasData: state.data !== undefined,\n hasFetched: state.hasFetched,\n refetch,\n }\n}\n\n/**\n * Internal hook for managing async state with plain promises.\n * Use this when you don't have TanStack Query or SWR.\n */\nfunction useAsyncState<T>(\n fetcher: () => Promise<T>,\n options?: { enabled?: boolean },\n): AsyncLoaderResult<T> {\n const { enabled = true } = options ?? {}\n const [state, setState] = React.useState<VanillaAsyncInternalState<T>>(\n () => ({\n data: undefined,\n error: null,\n isFetching: enabled,\n hasFetched: false,\n }),\n )\n\n const fetcherRef = React.useRef(fetcher)\n fetcherRef.current = fetcher\n\n const refetch = React.useCallback(() => {\n setState((s) => ({ ...s, isFetching: true, error: null }))\n fetcherRef\n .current()\n .then((data) => {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n })\n .catch((error) => {\n setState((s) => ({\n ...s,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n }))\n })\n }, [])\n\n React.useEffect(() => {\n if (enabled) {\n refetch()\n return\n }\n\n setState((s) => ({\n ...s,\n isFetching: false,\n }))\n }, [enabled, refetch])\n\n return React.useMemo(\n () => toVanillaAsyncLoaderResult(state, refetch),\n [state, refetch],\n )\n}\n\n/**\n * Internal hook for managing query-dependent async state with plain promises.\n * Unlike `useAsyncState`, this hook re-fetches whenever the query changes.\n * Aborts in-flight requests when a new query is issued or the component unmounts.\n */\nfunction useAsyncQueryState(\n fetcher: (\n query: string,\n options?: { signal?: AbortSignal },\n ) => Promise<NodeDef[]>,\n query: string,\n options?: { enabled?: boolean },\n): AsyncLoaderResult<NodeDef[]> {\n const { enabled = true } = options ?? {}\n const [state, setState] = React.useState<\n VanillaAsyncInternalState<NodeDef[]>\n >(() => ({\n data: undefined,\n error: null,\n isFetching: enabled,\n hasFetched: false,\n }))\n\n const fetcherRef = React.useRef(fetcher)\n fetcherRef.current = fetcher\n\n React.useEffect(() => {\n if (!enabled) {\n setState({\n data: undefined,\n error: null,\n isFetching: false,\n hasFetched: false,\n })\n return\n }\n\n const controller = new AbortController()\n\n setState({\n data: undefined,\n error: null,\n isFetching: true,\n hasFetched: false,\n })\n\n fetcherRef\n .current(query, { signal: controller.signal })\n .then((data) => {\n if (!controller.signal.aborted) {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n }\n })\n .catch((error) => {\n if (!controller.signal.aborted) {\n setState({\n data: undefined,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n })\n }\n })\n\n return () => {\n controller.abort()\n }\n }, [enabled, query])\n\n const refetch = React.useCallback(() => {\n // Trigger re-run by toggling a state-based effect isn't ideal here,\n // so we do a manual fetch that respects the current query/enabled state.\n setState((s) => ({\n ...s,\n isFetching: true,\n error: null,\n }))\n fetcherRef\n .current(query)\n .then((data) => {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n })\n .catch((error) => {\n setState((s) => ({\n ...s,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n }))\n })\n }, [query])\n\n return React.useMemo(\n () => toVanillaAsyncLoaderResult(state, refetch),\n [state, refetch],\n )\n}\n\n/**\n * Props for creating a static loader with vanilla fetch.\n */\nexport interface CreateVanillaStaticLoaderProps {\n /**\n * Async function that fetches the menu items.\n */\n fetcher: () => Promise<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration using plain fetch/promises.\n * No external data library required.\n *\n * @example\n * ```tsx\n * const recentFilesLoader = createVanillaStaticLoader({\n * fetcher: async () => {\n * const res = await fetch('/api/recent-files')\n * const data = await res.json()\n * return data.map(file => ({\n * kind: 'item',\n * value: file.name,\n * render: ...\n * }))\n * },\n * })\n * ```\n */\nexport function createVanillaStaticLoader(\n props: CreateVanillaStaticLoaderProps,\n): StaticLoaderConfig {\n const { fetcher, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useAsyncState(fetcher)\n return <>{children(result)}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query-dependent loader with vanilla fetch.\n */\nexport interface CreateVanillaQueryLoaderProps {\n /**\n * Async function that fetches menu items based on the search query.\n * Receives an optional `signal` that is aborted when a newer query is issued,\n * allowing you to cancel in-flight requests (e.g. pass it to `fetch()`).\n */\n fetcher: (\n query: string,\n options?: { signal?: AbortSignal },\n ) => Promise<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query-dependent loader configuration using plain fetch/promises.\n * No external data library required.\n *\n * @example\n * ```tsx\n * const searchLoader = createVanillaQueryLoader({\n * fetcher: async (query, options) => {\n * const res = await fetch(`/api/search?q=${encodeURIComponent(query)}`, {\n * signal: options?.signal, // aborts when a newer query is issued\n * })\n * const data = await res.json()\n * return data.map(item => ({\n * kind: 'item',\n * value: item.name,\n * render: ...\n * }))\n * },\n * minQueryLength: 2,\n * })\n * ```\n */\nexport function createVanillaQueryLoader(\n props: CreateVanillaQueryLoaderProps,\n): QueryDependentLoaderConfig {\n const {\n fetcher,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useAsyncQueryState(fetcher, query, { enabled: isEnabled })\n return <>{children(result)}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n"],"mappings":"6BA8HW,mBAAAA,EAAA,OA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,aAAAN,EACA,iBAAAO,EAAmB,QACnB,iBAAAC,CACF,EAAIT,EAEEU,EACJJ,IAAyB,OACrBA,EACAC,IAAiB,OACf,CAAE,MAAOA,EAAc,SAAU,QAAS,EAC1C,CAAE,MAAO,GAAI,SAAU,QAAS,EAcxC,MAAO,CACL,KAAM,QACN,OAd6C,CAAC,CAC9C,MAAAV,EACA,QAAAN,EACA,SAAAW,CACF,IAAM,CACJ,IAAMS,EACJpB,IACCM,EAAM,QAAUQ,GAAkBK,IAAiC,IAChEP,EAASP,EAAmBP,EAASQ,EAAO,CAAE,QAASc,CAAU,CAAC,EACxE,OAAOnC,EAAAD,EAAA,CAAG,SAAA2B,EAASC,CAAM,EAAE,CAC7B,EAKE,eAAAE,EACA,qBAAsBK,EACtB,aAAAH,EACA,aAAAN,EACA,iBAAAO,EACA,iBAAAC,CACF,CACF","names":["Fragment","jsx","toError","error","toAsyncLoaderResultFromSWR","result","normalizedError","hasData","fetchStatus","isFetching","isInitialLoading","isRefetching","status","loadingPhase","createSWRStaticLoader","props","useSWR","loadStrategy","children","createSWRQueryLoader","minQueryLength","initialQueryBehavior","initialQuery","belowMinBehavior","placeholderNodes","resolvedInitialQueryBehavior","query","enabled","isEnabled","createSWRLoaderComponent","useSWRFn","Fragment","jsx","toError","error","toAsyncLoaderResult","result","hasData","fetchStatus","isFetching","status","isPending","isSuccess","isError","isInitialLoading","isRefetching","isPaused","hasFetched","loadingPhase","createStaticLoader","props","useQuery","loadStrategy","children","createQueryLoader","minQueryLength","initialQueryBehavior","initialQuery","belowMinBehavior","placeholderNodes","resolvedInitialQueryBehavior","query","enabled","isEnabled","createLoaderComponent","useQueryFn","React","Fragment","jsx","normalizeError","error","getVanillaStatus","state","toVanillaAsyncLoaderResult","refetch","status","fetchStatus","isInitialLoading","isRefetching","loadingPhase","useAsyncState","fetcher","options","enabled","setState","fetcherRef","data","s","useAsyncQueryState","query","controller","createVanillaStaticLoader","props","loadStrategy","children","result","createVanillaQueryLoader","minQueryLength","initialQueryBehavior","initialQuery","belowMinBehavior","placeholderNodes","resolvedInitialQueryBehavior","isEnabled"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var l=(e,u)=>Object.is(e,u);function n(e,u,r){return e==null||u==null?Object.is(e,u):r(e,u)}function t(e,u,r){return!e||e.length===0?!1:e.some(a=>a===void 0?!1:n(a,u,r))}function o(e,u,r){return e.filter(a=>!n(a,u,r))}export{l as a,n as b,t as c,o as d};
|
|
2
|
+
//# sourceMappingURL=chunk-AVZ64JQ3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/item-equality.ts"],"sourcesContent":["/**\n * Type for custom item equality comparison functions.\n * Used to compare object values in Select and Combobox components.\n */\nexport type ItemEqualityComparer<Value = unknown> = (\n itemValue: Value,\n value: Value,\n) => boolean\n\n/**\n * Default equality comparer using Object.is.\n * Handles primitives and object reference equality.\n */\nexport const defaultItemEquality: ItemEqualityComparer = (item, value) =>\n Object.is(item, value)\n\n/**\n * Compare two items for equality using a custom comparer.\n * Handles null/undefined values separately using Object.is.\n */\nexport function compareItemEquality<Value>(\n item: Value,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n // Handle null/undefined with Object.is for consistent behavior\n if (item == null || value == null) {\n return Object.is(item, value)\n }\n return comparer(item, value)\n}\n\n/**\n * Check if a collection includes a specific value using custom equality.\n */\nexport function itemIncludes<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n if (!collection || collection.length === 0) {\n return false\n }\n return collection.some((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Find the index of a value in a collection using custom equality.\n * Returns -1 if not found.\n */\nexport function findItemIndex<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): number {\n if (!collection || collection.length === 0) {\n return -1\n }\n return collection.findIndex((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Remove a value from a collection using custom equality.\n * Returns a new array without the matching item.\n */\nexport function removeItem<Value>(\n collection: readonly Value[],\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): Value[] {\n return collection.filter(\n (item) => !compareItemEquality(item, value, comparer),\n )\n}\n"],"mappings":"AAaO,IAAMA,EAA4C,CAACC,EAAMC,IAC9D,OAAO,GAAGD,EAAMC,CAAK,EAMhB,SAASC,EACdF,EACAC,EACAE,EACS,CAET,OAAIH,GAAQ,MAAQC,GAAS,KACpB,OAAO,GAAGD,EAAMC,CAAK,EAEvBE,EAASH,EAAMC,CAAK,CAC7B,CAKO,SAASG,EACdC,EACAJ,EACAE,EACS,CACT,MAAI,CAACE,GAAcA,EAAW,SAAW,EAChC,GAEFA,EAAW,KAAML,GAClBA,IAAS,OACJ,GAEFE,EAAoBF,EAAMC,EAAOE,CAAQ,CACjD,CACH,CA0BO,SAASG,EACdC,EACAC,EACAC,EACS,CACT,OAAOF,EAAW,OACfG,GAAS,CAACC,EAAoBD,EAAMF,EAAOC,CAAQ,CACtD,CACF","names":["defaultItemEquality","item","value","compareItemEquality","comparer","itemIncludes","collection","removeItem","collection","value","comparer","item","compareItemEquality"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var l=(e,u)=>Object.is(e,u);function n(e,u,r){return e==null||u==null?Object.is(e,u):r(e,u)}function t(e,u,r){return!e||e.length===0?!1:e.some(a=>a===void 0?!1:n(a,u,r))}function o(e,u,r){return e.filter(a=>!n(a,u,r))}exports.a = l; exports.b = n; exports.c = t; exports.d = o;
|
|
2
|
+
//# sourceMappingURL=chunk-BGJJC6GX.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/item-equality.ts"],"names":["defaultItemEquality","item","value","compareItemEquality","comparer","itemIncludes","collection","removeItem"],"mappings":"AAaO,6EAAMA,CAAAA,CAA4C,CAACC,CAAAA,CAAMC,CAAAA,CAAAA,EAC9D,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAMhB,SAASC,CAAAA,CACdF,CAAAA,CACAC,CAAAA,CACAE,CAAAA,CACS,CAET,OAAIH,CAAAA,EAAQ,IAAA,EAAQC,CAAAA,EAAS,IAAA,CACpB,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAEvBE,CAAAA,CAASH,CAAAA,CAAMC,CAAK,CAC7B,CAKO,SAASG,CAAAA,CACdC,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,MAAI,CAACE,CAAAA,EAAcA,CAAAA,CAAW,MAAA,GAAW,CAAA,CAChC,CAAA,CAAA,CAEFA,CAAAA,CAAW,IAAA,CAAML,CAAAA,EAClBA,CAAAA,GAAS,KAAA,CAAA,CACJ,CAAA,CAAA,CAEFE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACjD,CACH,CA0BO,SAASG,CAAAA,CACdD,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,OAAOE,CAAAA,CAAW,MAAA,CACfL,CAAAA,EAAS,CAACE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACtD,CACF,CAAA,2DAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-BGJJC6GX.cjs","sourcesContent":["/**\n * Type for custom item equality comparison functions.\n * Used to compare object values in Select and Combobox components.\n */\nexport type ItemEqualityComparer<Value = unknown> = (\n itemValue: Value,\n value: Value,\n) => boolean\n\n/**\n * Default equality comparer using Object.is.\n * Handles primitives and object reference equality.\n */\nexport const defaultItemEquality: ItemEqualityComparer = (item, value) =>\n Object.is(item, value)\n\n/**\n * Compare two items for equality using a custom comparer.\n * Handles null/undefined values separately using Object.is.\n */\nexport function compareItemEquality<Value>(\n item: Value,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n // Handle null/undefined with Object.is for consistent behavior\n if (item == null || value == null) {\n return Object.is(item, value)\n }\n return comparer(item, value)\n}\n\n/**\n * Check if a collection includes a specific value using custom equality.\n */\nexport function itemIncludes<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n if (!collection || collection.length === 0) {\n return false\n }\n return collection.some((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Find the index of a value in a collection using custom equality.\n * Returns -1 if not found.\n */\nexport function findItemIndex<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): number {\n if (!collection || collection.length === 0) {\n return -1\n }\n return collection.findIndex((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Remove a value from a collection using custom equality.\n * Returns a new array without the matching item.\n */\nexport function removeItem<Value>(\n collection: readonly Value[],\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): Value[] {\n return collection.filter(\n (item) => !compareItemEquality(item, value, comparer),\n )\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkM4G6J7DPcjs = require('./chunk-M4G6J7DP.cjs');var _react = require('react'); var z = _interopRequireWildcard(_react); var k = _interopRequireWildcard(_react); var H = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var N = _interopRequireWildcard(_react); var b = _interopRequireWildcard(_react); var ne = _interopRequireWildcard(_react); var R = _interopRequireWildcard(_react);var te=z.createContext(null);function K(){return z.useContext(te)}var U=k.createContext(null);function be(){let n=k.useContext(U);if(!n)throw new Error("Item child components must be used within an Item");return n}function Se(){return k.useContext(U)}var G=H.createContext(null);function j(){let n=H.useContext(G);if(!n)throw new Error("Listbox components must be used within a Listbox provider");return n}function Ie(){return H.useContext(G)}var W=T.createContext(null);process.env.NODE_ENV!=="production"&&(W.displayName="RowWidthContext");function Re(){let n=T.useContext(W);if(!n)throw new Error("useRowWidthContext must be used within a List with measureRowWidth enabled");return n}function B(){return T.useContext(W)}var q=N.createContext(null);function Y(){let n=N.useContext(q);if(!n)throw new Error("Listbox components must be used within a Surface provider");return n}function Ce(){return N.useContext(q)}function A(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]), () => (""))}function ve(n){return n?n.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""):""}function Ee(n){let{id:e,value:t,keywords:s,disabled:o=!1,forceMount:r=!1,shortcut:a,forceOrder:l,forceScore:d,isSubmenuTrigger:c=!1,onSelect:g,closeOnClick:f=!0,onAfterSelect:I,children:S,aimGuard:p}=n,{store:u}=Y(),i=K(),{depth:x}=j(),h=b.useRef(null),[v,O]=b.useState("");b.useLayoutEffect(()=>{if(e===void 0&&t===void 0&&h.current){let E=_nullishCoalesce(_optionalChain([h, 'access', _4 => _4.current, 'access', _5 => _5.textContent, 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]), () => (""));O(E)}},[e,t,S]);let m=_nullishCoalesce(e, () => ((A(t)||v))),w=b.useId(),M=_nullishCoalesce(e, () => (`item-${w}`)),L=_optionalChain([s, 'optionalAccess', _8 => _8.map, 'call', _9 => _9(E=>A(E)), 'access', _10 => _10.filter, 'call', _11 => _11(Boolean)]),D=L?JSON.stringify(L):void 0;b.useEffect(()=>!m&&!r?void 0:u.registerItem(m,{value:m,keywords:L,groupId:_optionalChain([i, 'optionalAccess', _12 => _12.groupId]),disabled:o,isSubmenuTrigger:c,shortcut:a,forceOrder:l,forceScore:d,closeOnClick:f}),[m,D,_optionalChain([i, 'optionalAccess', _13 => _13.groupId]),o,c,a,l,d,f,u,r]),b.useEffect(()=>{if(m)return u.registerItemRef(m,h)},[m,u]);let _=B();b.useLayoutEffect(()=>{_&&h.current&&m&&_.queueMeasurement(h.current,m)},[_,m]),b.useEffect(()=>{if(!(!g||!m))return u.registerItemSelect(m,g)},[m,g,u]);let le=u.useState("normalizedSearch"),F=u.useState("isHighlighted",m),ce=u.useState("getItemScore",m),ue=u.isFilterDisabled(),he=le.length>0,de=r||ue||!he||ce>0,X=b.useCallback(E=>{if(E.defaultPrevented||o||!m)return;E.preventDefault(),_optionalChain([u, 'access', _14 => _14.context, 'access', _15 => _15.itemSelects, 'access', _16 => _16.get, 'call', _17 => _17(m), 'optionalCall', _18 => _18()]),_optionalChain([I, 'optionalCall', _19 => _19(m)])},[o,u,m,I]),Q=b.useCallback(E=>{E.preventDefault()},[]),Z=b.useCallback(E=>{if(!E.defaultPrevented&&!o&&m){if(p){let{aimGuardActiveRef:ee,guardedDepthRef:pe}=p;if(ee.current&&pe.current===x)return}u.shouldAllowPointerHighlight(E.clientX,E.clientY)&&u.setHighlightedId(m)}},[o,p,x,u,m]),ge=b.useMemo(()=>({id:M,highlighted:F,disabled:o,shortcut:a}),[M,F,o,a]),fe=b.useCallback(E=>m?u.registerItemSelect(m,E):()=>{},[u,m]),me=b.useMemo(()=>({onClick:X,onPointerMove:Z,onPointerDown:Q}),[X,Z,Q]);return{id:M,storeId:m,ref:h,isHighlighted:F,isVisible:de,contextValue:ge,handlers:me,registerSelect:fe}}function ye(n){let{store:e,surfaceId:t,enabled:s,onKeyDown:o,onSelect:r,closeAll:a,focusOwner:l,depth:d=0,submenuContext:c,subpageContext:g,enableTypeToSearch:f=!1,skipFocusOwnerCheck:I=!1}=n,S=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _20 => _20.useState, 'call', _21 => _21("isOwner",t)]), () => (!0)),p=I?!0:S;return{handleKeyDown:ne.useCallback(i=>{if(_optionalChain([o, 'optionalCall', _22 => _22(i)]),!i.defaultPrevented&&s&&p&&!(i.nativeEvent.isComposing||i.keyCode===229)){if(f){let x=e.context.hideUntilActive,h=e.state.inputActive;if(x&&!h&&i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey){let O=e.context.shortcuts.get(i.key.toLowerCase());if(O&&e.selectByShortcut(i.key)){i.preventDefault();let m=e.context.items.get(O);_optionalChain([r, 'optionalCall', _23 => _23({itemId:O,closeOnClick:_nullishCoalesce(_optionalChain([m, 'optionalAccess', _24 => _24.closeOnClick]), () => (!0))})]);return}i.preventDefault(),e.setPendingSearch(i.key),e.setInputActive(!0);return}}switch(i.key){case"ArrowDown":{i.preventDefault(),e.highlightNext();break}case"ArrowUp":{i.preventDefault(),e.highlightPrev();break}case"n":{i.ctrlKey&&(i.preventDefault(),e.highlightNext());break}case"p":{i.ctrlKey&&(i.preventDefault(),e.highlightPrev());break}case"ArrowRight":{e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"l":{i.ctrlKey&&e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"ArrowLeft":{if(_optionalChain([g, 'optionalAccess', _25 => _25.goBack, 'call', _26 => _26()])){i.preventDefault(),l&&g.parentSurfaceId&&l.setOwnerId(g.parentSurfaceId);break}d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"h":{if(i.ctrlKey&&_optionalChain([g, 'optionalAccess', _27 => _27.goBack, 'call', _28 => _28()])){i.preventDefault(),l&&g.parentSurfaceId&&l.setOwnerId(g.parentSurfaceId);break}i.ctrlKey&&d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"Enter":{i.preventDefault();let x=e.state.highlightedId,h=e.getHighlightedItem();e.selectHighlighted(),_optionalChain([r, 'optionalCall', _29 => _29({itemId:x,closeOnClick:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _30 => _30.closeOnClick]), () => (!0))})]);break}case"Home":{i.preventDefault(),e.setHighlightedId(null),e.highlightNext();break}case"End":{i.preventDefault(),e.setHighlightedId(null),e.highlightPrev();break}case"Escape":{if(g){i.preventDefault(),i.stopPropagation(),g.closeRootOnEsc?a():g.goBack()&&l&&g.parentSurfaceId?l.setOwnerId(g.parentSurfaceId):d>0&&c&&(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}if(d===0)break;i.preventDefault(),i.stopPropagation(),_optionalChain([c, 'optionalAccess', _31 => _31.closeRootOnEsc])!==!1?a():(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}default:{let x=e.state.normalizedSearch.length>0;if(i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&!x){let v=e.context.shortcuts.get(i.key.toLowerCase());if(v&&e.selectByShortcut(i.key)){i.preventDefault();let O=e.context.items.get(v);_optionalChain([r, 'optionalCall', _32 => _32({itemId:v,closeOnClick:_nullishCoalesce(_optionalChain([O, 'optionalAccess', _33 => _33.closeOnClick]), () => (!0))})])}}break}}}},[o,s,p,f,e,d,c,g,l,r,a])}}var Oe=!1,we=!1;function y(...n){Oe&&console.log("[useStickyRowWidth]",...n)}function ie(n){return`${Math.ceil(n)}px`}function Pe(n){let e=Number.parseFloat(n);return Number.isFinite(e)?e:null}function Me(n){let{listRef:e,targetRef:t,maxWidth:s,enabled:o=!0}=n,r=R.useCallback(()=>_nullishCoalesce(_optionalChain([t, 'optionalAccess', _34 => _34.current]), () => (e.current)),[t,e]),a=R.useRef(0);R.useLayoutEffect(()=>{if(!o)return;let u=r();if(!u)return;let i=Pe(u.style.getPropertyValue("--row-width").trim());!i||i<=a.current||(a.current=i,y("Hydrated max width from existing --row-width:",{hydratedWidth:i}))},[o,r]);let l=R.useRef([]),d=R.useRef([]),c=R.useRef(!1),g=R.useRef(new Set),f=R.useCallback(u=>{let i=r();if(!i)return;let x=s!==void 0?Math.min(u,s):u;y("--row-width updated:",{rawWidth:u,cappedWidth:x,cssValue:ie(x),maxWidthCap:s,targetElement:i.tagName+(i.className?`.${i.className.split(" ").join(".")}`:"")}),i.style.setProperty("--row-width",ie(x))},[r,s]),I=R.useCallback(()=>{c.current||(c.current=!0,requestAnimationFrame(()=>{let u=l.current,i=a.current,x=!1;if(u.length>0){y("Measuring batch of",u.length,"rows");for(let{element:h,id:v}of u){if(g.current.has(v))continue;if(!h.isConnected){y("Row skipped (unmounted):",{id:v});continue}let O=h.style.width,m=h.style.maxWidth;h.setAttribute("data-measuring",""),h.style.maxWidth="none",h.style.width="max-content";let w=Math.max(h.scrollWidth,h.offsetWidth)+1,M=getComputedStyle(h);if(y("Row measurement details:",{id:v,measuredWidth:w,scrollWidth:h.scrollWidth,offsetWidth:h.offsetWidth,computedWidth:M.width,computedMaxWidth:M.maxWidth,inlineMaxWidth:m,textContent:_optionalChain([h, 'access', _35 => _35.textContent, 'optionalAccess', _36 => _36.slice, 'call', _37 => _37(0,50)])}),we||(h.style.width=O,h.style.maxWidth=m,h.removeAttribute("data-measuring")),w<=1){let L=h.getBoundingClientRect(),D=getComputedStyle(h);y("Row skipped (0-width, will retry):",{id:v,width:w,scrollWidth:h.scrollWidth,offsetWidth:h.offsetWidth,boundingRect:{width:L.width,height:L.height},display:D.display,visibility:D.visibility,innerHTML:h.innerHTML.slice(0,100),isConnected:h.isConnected,parentElement:_optionalChain([h, 'access', _38 => _38.parentElement, 'optionalAccess', _39 => _39.tagName])});continue}y("Row measured:",{id:v,width:w,currentMax:i,isNewMax:w>i}),w>i&&(i=w,x=!0),g.current.add(v)}l.current=[]}x&&(y("New max width found:",{previousMax:a.current,newMax:i,totalMeasured:g.current.size}),a.current=i,d.current.push(()=>f(i)));for(let h of d.current)h();d.current=[],c.current=!1}))},[f]),S=R.useCallback((u,i)=>{if(!o){y("queueMeasurement skipped (disabled):",i);return}if(g.current.has(i)){y("queueMeasurement skipped (already measured):",i);return}y("queueMeasurement:",{id:i,queueSize:l.current.length+1,element:u.tagName}),l.current.push({element:u,id:i}),I()},[o,I]),p=R.useCallback(()=>{let u=a.current,i=g.current.size;g.current.clear(),a.current=0;let x=r();x&&x.style.removeProperty("--row-width"),y("Measurements reset:",{previousMaxWidth:u,previousMeasuredCount:i,targetElement:_optionalChain([x, 'optionalAccess', _40 => _40.tagName])})},[r]);return R.useEffect(()=>{if(!o)return;let u=r();if(!u||typeof ResizeObserver>"u")return;let i=null,x=new ResizeObserver(h=>{i!==null&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>{i=null,a.current>0&&(y("ResizeObserver triggered re-apply:",{currentMax:a.current,containerSize:_optionalChain([h, 'access', _41 => _41[0], 'optionalAccess', _42 => _42.contentRect])}),f(a.current))})});return x.observe(u),()=>{i!==null&&cancelAnimationFrame(i),x.disconnect()}},[r,o,f]),{queueMeasurement:S,resetMeasurements:p}}var _store = require('@base-ui/utils/store');var _useRefWithInit = require('@base-ui/utils/useRefWithInit');var P={};_chunkM4G6J7DPcjs.a.call(void 0, P,{auto:()=>Ye,clearPress:()=>Ke,closePress:()=>We,escapeKey:()=>Te,focusOut:()=>Ve,imperativeAction:()=>$e,inputChange:()=>_e,inputClear:()=>Fe,itemKeyboardSelect:()=>ze,itemPress:()=>De,keyboard:()=>qe,listNavigation:()=>Ue,none:()=>Je,outsidePress:()=>Ne,pointer:()=>Be,siblingOpen:()=>je,submenuTrigger:()=>Ge,triggerContextMenu:()=>He,triggerFocus:()=>ke,triggerHover:()=>Ae,triggerPress:()=>Le});var Le="trigger-press",Ae="trigger-hover",ke="trigger-focus",He="trigger-context-menu",Te="escape-key",Ne="outside-press",Ve="focus-out",De="item-press",ze="item-keyboard-select",We="close-press",_e="input-change",Fe="input-clear",Ke="clear-press",Ue="list-navigation",Ge="submenu-trigger",je="sibling-open",Be="pointer",qe="keyboard",Ye="auto",$e="imperative-action",Je="none";function se(n,e,t,s){let o=!1,r=!1;return{reason:n,event:_nullishCoalesce(e, () => (new Event("ui-event"))),cancel(){o=!0},allowPropagation(){r=!0},get isCanceled(){return o},get isPropagationAllowed(){return r},trigger:t,...s}}function re(n,e,t){return{reason:n,event:_nullishCoalesce(e, () => (new Event("ui-event"))),...t}}var Xe=/[\\/_+.#"@[({&]/,Qe=/[\\/_+.#"@[({&]/g,Ze=/[\s-]/,ae=/[\s-]/g;function $(n,e,t,s,o,r,a){if(r===e.length)return o===n.length?1:.99;let l=`${o},${r}`;if(a[l]!==void 0)return a[l];let d=s.charAt(r),c=t.indexOf(d,o),g=0,f,I,S,p;for(;c>=0;)f=$(n,e,t,s,c+1,r+1,a),f>g&&(c===o?f*=1:Xe.test(n.charAt(c-1))?(f*=.8,S=n.slice(o,c-1).match(Qe),S&&o>0&&(f*=.999**S.length)):Ze.test(n.charAt(c-1))?(f*=.9,p=n.slice(o,c-1).match(ae),p&&o>0&&(f*=.999**p.length)):(f*=.17,o>0&&(f*=.999**(c-o))),n.charAt(c)!==e.charAt(r)&&(f*=.9999)),(f<.1&&t.charAt(c-1)===s.charAt(r+1)||s.charAt(r+1)===s.charAt(r)&&t.charAt(c-1)!==s.charAt(r))&&(I=$(n,e,t,s,c+1,r+2,a),I*.1>f&&(f=I*.1)),f>g&&(g=f),c=t.indexOf(d,c+1);return a[l]=g,g}function oe(n){return n.toLowerCase().replace(ae," ")}function V(n,e,t){if(!e)return 1;if(!n)return 0;let s=t&&t.length>0?`${n} ${t.join(" ")}`:n;return $(s,e,oe(s),oe(e),0,0,{})}var et=V;var it={open:_store.createSelector.call(void 0, n=>n.open),search:_store.createSelector.call(void 0, n=>n.search),normalizedSearch:_store.createSelector.call(void 0, n=>n.normalizedSearch),highlightedId:_store.createSelector.call(void 0, n=>n.highlightedId),highlightSource:_store.createSelector.call(void 0, n=>n.highlightSource),hasInput:_store.createSelector.call(void 0, n=>n.hasInput),inputActive:_store.createSelector.call(void 0, n=>n.inputActive),pendingSearch:_store.createSelector.call(void 0, n=>n.pendingSearch),filteredCount:_store.createSelector.call(void 0, n=>n.filteredCount),filteredItems:_store.createSelector.call(void 0, n=>n.filteredItems),visibleGroups:_store.createSelector.call(void 0, n=>n.visibleGroups),virtualized:_store.createSelector.call(void 0, n=>n.virtualized),isHighlighted:_store.createSelector.call(void 0, (n,e)=>n.highlightedId===e),isGroupVisible:_store.createSelector.call(void 0, (n,e)=>n.normalizedSearch.length===0||n.visibleGroups.has(e)),getItemScore:_store.createSelector.call(void 0, (n,e)=>n.normalizedSearch.length===0?1:_nullishCoalesce(n.filteredItems.get(e), () => (0))),hasSearchWithNoResults:_store.createSelector.call(void 0, n=>n.normalizedSearch.length===0?!1:n.virtualized&&n.virtualItemsCount>=0?n.virtualItemsCount===0:n.filteredCount===0)},st=n=>A(n),J= exports.x =class n extends _store.ReactStore{constructor(e,t){let o={...{filter:V,normalizeSearch:st,loop:!0,autoHighlightFirst:!0,clearSearchOnClose:!0,hideUntilActive:!1,listId:"",inputId:"",items:new Map,groups:new Map,itemSelects:new Map,submenuOpens:new Map,submenuCloses:new Map,shortcuts:new Map,onOpenChange:()=>{},onSearchChange:void 0,virtualItems:[],orderedItems:[],onHighlightChange:void 0,refs:{listRef:{current:null},itemRefs:new Map},onCloseComplete:void 0,onPopupCloseComplete:void 0,lastPointerPosition:null},...t},r={...rt(),...e};r.normalizedSearch=o.normalizeSearch(r.search),super(r,o,it),this.observe("open",a=>{if(a)this.resetPointerPosition(),this.context.autoHighlightFirst===!0&&this.highlightFirstItem();else{this.context.clearSearchOnClose===!0&&this.setSearch("");let l=this.context.clearSearchOnClose==="after-exit";this.update({highlightedId:null,highlightSource:null,inputActive:l?this.state.inputActive:!1,pendingSearch:""})}}),this.observe("search",(a,l)=>{if(a===l)return;let d=this.context.normalizeSearch(a);d!==this.state.normalizedSearch&&this.set("normalizedSearch",d)}),this.observe("normalizedSearch",(a,l)=>{a!==l&&(this.resetPointerPosition(),this.recomputeFilteredItems(l))})}setOpen(e,t=P.none,s){let o=se(t,s);this.context.onOpenChange(e,o),!o.isCanceled&&this.set("open",e)}setSearch(e){this.update({search:e,normalizedSearch:this.context.normalizeSearch(e)}),_optionalChain([this, 'access', _43 => _43.context, 'access', _44 => _44.onSearchChange, 'optionalCall', _45 => _45(e)])}setSearchNormalizer(e){this.context.normalizeSearch=e;let t=e(this.state.search);t!==this.state.normalizedSearch&&this.set("normalizedSearch",t)}setHighlightedId(e,t="pointer"){this.state.highlightedId!==e&&(this.closeSiblingSubmenus(e),this.update({highlightedId:e,highlightSource:t}),this.notifyHighlightChange(e,t),t==="keyboard"&&e!==null&&this.scrollItemIntoView(e))}notifyHighlightChange(e,t){let{onHighlightChange:s}=this.context;if(!s)return;let o=t==="keyboard"?P.keyboard:t==="pointer"?P.pointer:P.auto,r=e===null?-1:this.state.virtualized?this.getVirtualItemIndex(e):this.getVisibleItemIndex(e),a=re(o,void 0,{index:r});s(e,r,a)}scrollItemIntoView(e){let{refs:t}=this.context,s=t.listRef.current,r=_optionalChain([t, 'access', _46 => _46.itemRefs, 'access', _47 => _47.get, 'call', _48 => _48(e), 'optionalAccess', _49 => _49.current]);if(r&&s)try{s.contains(r)&&r.scrollIntoView({block:"nearest"})}catch (e2){}}setHasInput(e){this.set("hasInput",e)}setInputActive(e){this.set("inputActive",e)}setPendingSearch(e){this.set("pendingSearch",e)}setHideUntilActive(e){this.context.hideUntilActive=e,e&&this.state.normalizedSearch.length>0&&this.setInputActive(!0)}setVirtualized(e){this.set("virtualized",e)}setVirtualItems(e){let t=this.context.virtualItems;if(this.context.virtualItems=e,this.set("virtualItemsCount",e.length),this.preRegisterVirtualItems(),e===t)return;if(t.length===e.length){let a=!0;for(let l=0;l<t.length;l++){let d=t[l],c=e[l];if(!d||!c||d.value!==c.value||d.disabled!==c.disabled){a=!1;break}}if(a)return}if(!this.state.virtualized||!this.state.open||e.length===0)return;let s=t.find(a=>!a.disabled),o=e.find(a=>!a.disabled),r=s!==void 0&&_optionalChain([o, 'optionalAccess', _50 => _50.value])!==s.value;this.validateHighlight({forceFirst:r})}setOrderedItems(e,t){let s=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _51 => _51.reason]), () => ("replace")),o=this.context.orderedItems;if(this.context.orderedItems=e,e!==o&&this.state.open){if(s==="append"&&this.state.highlightedId!==null){let r=this.state.highlightedId,a=this.context.items.get(r),l=e.includes(r),d=a?!a.disabled:!1;if(l&&d)return}if(e.length>0){let r=e.find(a=>this.context.items.has(a));r!==void 0?this.setHighlightedId(r,"auto"):this.setHighlightedId(null)}else this.setHighlightedId(null)}}maybeAutoHighlightOnRegister(e){if(this.context.filter!==!1||!this.state.open||this.state.highlightedId!==null||!this.context.autoHighlightFirst)return;let t=this.context.orderedItems;if(t.length===0)return;t.find(o=>this.context.items.has(o))===e&&this.setHighlightedId(e,"auto")}setOnHighlightChange(e){this.context.onHighlightChange=e}setListRef(e){this.context.refs.listRef=e}registerItemRef(e,t){return this.context.refs.itemRefs.set(e,t),()=>{this.context.refs.itemRefs.delete(e)}}shouldAllowPointerHighlight(e,t){let s=this.context.lastPointerPosition;if(s===null)return this.context.lastPointerPosition={x:e,y:t},!0;let o=Math.abs(e-s.x),r=Math.abs(t-s.y);return o>1||r>1?(this.context.lastPointerPosition={x:e,y:t},!0):!1}resetPointerPosition(){this.context.lastPointerPosition=null}preRegisterVirtualItems(){let e=this.context.virtualItems;if(e.length!==0){for(let t of e)this.context.items.has(t.value)||this.context.items.set(t.value,{value:t.value,keywords:t.keywords,disabled:t.disabled});this.recomputeFilteredItems()}}registerItem(e,t){let s=this.context.items.get(e);if(s&&s.value===t.value&&s.disabled===t.disabled&&s.forceOrder===t.forceOrder&&s.forceScore===t.forceScore&&s.groupId===t.groupId&&s.shortcut===t.shortcut)return()=>{this.context.items.get(e)===s&&(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId&&_optionalChain([this, 'access', _52 => _52.context, 'access', _53 => _53.groups, 'access', _54 => _54.get, 'call', _55 => _55(t.groupId), 'optionalAccess', _56 => _56.delete, 'call', _57 => _57(e)]),t.shortcut&&this.context.shortcuts.delete(t.shortcut.toLowerCase()),this.recomputeFilteredItems())};if(this.context.items.set(e,t),t.groupId){let r=this.context.groups.get(t.groupId);r&&r.add(e)}if(t.shortcut){let r=t.shortcut.toLowerCase();this.context.shortcuts.set(r,e)}return this.recomputeFilteredItems(),this.maybeAutoHighlightOnRegister(e),()=>{if(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId){let r=this.context.groups.get(t.groupId);r&&r.delete(e)}if(t.shortcut){let r=t.shortcut.toLowerCase();this.context.shortcuts.delete(r)}this.recomputeFilteredItems()}}registerGroup(e){return this.context.groups.set(e,new Set),()=>{this.context.groups.delete(e)}}registerItemSelect(e,t){return t&&this.context.itemSelects.set(e,t),()=>{this.context.itemSelects.delete(e)}}registerSubmenuOpen(e,t){return t&&this.context.submenuOpens.set(e,t),()=>{this.context.submenuOpens.delete(e)}}registerSubmenuClose(e,t){return t&&this.context.submenuCloses.set(e,t),()=>{this.context.submenuCloses.delete(e)}}closeSiblingSubmenus(e){for(let[t,s]of this.context.submenuCloses)if(t!==e)try{s()}catch (e3){}}highlightNext(){let e=this.getVisibleItemIds();if(e.length===0)return;let s=(this.state.highlightedId?e.indexOf(this.state.highlightedId):-1)+1;s>=e.length&&(s=this.context.loop?0:e.length-1);let o=e[s];o&&this.setHighlightedId(o,"keyboard")}highlightPrev(){let e=this.getVisibleItemIds();if(e.length===0)return;let s=(this.state.highlightedId?e.indexOf(this.state.highlightedId):e.length)-1;s<0&&(s=this.context.loop?e.length-1:0);let o=e[s];o&&this.setHighlightedId(o,"keyboard")}selectHighlighted(){this.state.highlightedId&&_optionalChain([this, 'access', _58 => _58.context, 'access', _59 => _59.itemSelects, 'access', _60 => _60.get, 'call', _61 => _61(this.state.highlightedId), 'optionalCall', _62 => _62()])}selectByShortcut(e){let t=this.context.shortcuts.get(e.toLowerCase());if(!t)return!1;let s=this.context.items.get(t);if(!s||s.disabled)return!1;let o=_nullishCoalesce(this.state.filteredItems.get(t), () => (0));return this.state.normalizedSearch.length===0||o>0?(_optionalChain([this, 'access', _63 => _63.context, 'access', _64 => _64.itemSelects, 'access', _65 => _65.get, 'call', _66 => _66(t), 'optionalCall', _67 => _67()]),!0):!1}openSubmenuForHighlighted(){this.state.highlightedId&&_optionalChain([this, 'access', _68 => _68.context, 'access', _69 => _69.submenuOpens, 'access', _70 => _70.get, 'call', _71 => _71(this.state.highlightedId), 'optionalCall', _72 => _72()])}isHighlightedSubmenuTrigger(){return this.state.highlightedId?_nullishCoalesce(_optionalChain([this, 'access', _73 => _73.context, 'access', _74 => _74.items, 'access', _75 => _75.get, 'call', _76 => _76(this.state.highlightedId), 'optionalAccess', _77 => _77.isSubmenuTrigger]), () => (!1)):!1}getHighlightedItem(){if(this.state.highlightedId)return this.context.items.get(this.state.highlightedId)}clearSearch(){this.setSearch("")}highlightFirstItem(){let e=this.getVisibleItemIds();e.length>0&&e[0]?this.update({highlightedId:e[0],highlightSource:null}):this.update({highlightedId:null,highlightSource:null})}applyAutoHighlight(){if(!this.state.open)return;let e=this.context.autoHighlightFirst;e===!0?this.highlightFirstItem():typeof e=="string"&&this.highlightItemByValue(e)}highlightItemByValue(e){let t=this.getVisibleItemIds(),s=null;t.includes(e)?s=e:t.length>0&&t[0]&&(s=t[0]),this.update({highlightedId:s,highlightSource:null}),s&&requestAnimationFrame(()=>{this.scrollItemIntoView(s)})}isFilterDisabled(){return this.context.filter===!1}getVisibleItemIds(){let e=[],t=this.state.normalizedSearch,s=this.state.filteredItems,o=this.context.virtualItems,r=this.context.orderedItems;if(this.state.virtualized&&o.length>0){for(let a of o){let l=_nullishCoalesce(s.get(a.value), () => (0));(t.length===0||l>0)&&!a.disabled&&e.push(a.value)}return e}if(this.context.filter===!1&&r.length>0){let a=[];for(let l of r){let d=this.context.items.get(l);d&&!d.disabled?e.push(l):d||a.push(l)}if(process.env.NODE_ENV!=="production"&&a.length>0&&e.length>0)for(let l of a)console.warn(`[ListboxStore] Item "${l}" is in orderedItems but not registered. This may cause keyboard navigation to skip this item. Make sure the render function passes the \`id\` prop: <Item {...props}>...</Item>`);return e}return this.context.items.forEach((a,l)=>{let d=_nullishCoalesce(s.get(l), () => (0));(t.length===0||d>0)&&!a.disabled&&e.push(l)}),e}getVisibleItemIndex(e){return this.getVisibleItemIds().indexOf(e)}getVirtualItemIndex(e){return this.state.virtualized?this.context.virtualItems.findIndex(t=>t.value===e):-1}validateHighlight(e={}){let{forceFirst:t=!1,filteredItems:s=this.state.filteredItems,newSearch:o,prevSearch:r}=e,a=r!==void 0?r:this.state.normalizedSearch,l=o!==void 0?o:a,d=o!==void 0&&o!==a;if(!this.state.open||!this.context.autoHighlightFirst)return this.state.highlightedId;let c=this.state.highlightedId,{filter:g}=this.context,f=t||d,I=!1;if(c&&!f){let p=_nullishCoalesce(s.get(c), () => (0)),u=l.length===0||g===!1||p>0,i=this.context.items.get(c),x=this.context.virtualItems.find(m=>m.value===c),h=_nullishCoalesce(_nullishCoalesce(_optionalChain([i, 'optionalAccess', _78 => _78.disabled]), () => (_optionalChain([x, 'optionalAccess', _79 => _79.disabled]))), () => (!1)),v=this.state.virtualized||i!==void 0,O=!this.state.virtualized||this.context.virtualItems.length===0||x!==void 0;I=u&&!h&&v&&O}if(I)return c;let S=null;if(this.state.virtualized&&this.context.virtualItems.length>0)for(let p of this.context.virtualItems){let u=_nullishCoalesce(s.get(p.value), () => (0));if((l.length===0||g===!1||u>0)&&!p.disabled){S=p.value;break}}else if(g===!1&&this.context.orderedItems.length>0)for(let p of this.context.orderedItems){let u=this.context.items.get(p);if(u&&!u.disabled){S=p;break}}else for(let[p,u]of this.context.items){let i=_nullishCoalesce(s.get(p), () => (0));if((l.length===0||i>0)&&!u.disabled){S=p;break}}return S!==c&&this.update({highlightedId:S,highlightSource:null}),S}recomputeFilteredItems(e){let{filter:t}=this.context,s=this.state.normalizedSearch,o=this.context.items,r=this.context.groups,a=new Map,l=new Set,d=0;if(!s||t===!1){if(this.state.virtualized&&this.context.virtualItems.length>0)for(let g of this.context.virtualItems)a.set(g.value,1),d++;else o.forEach((g,f)=>{a.set(f,1),d++});r.forEach((g,f)=>{l.add(f)})}else{let g=t||V;o.forEach((f,I)=>{let S=g(f.value,s,f.keywords),p=_nullishCoalesce(f.forceScore, () => (S));a.set(I,p),p>0&&(d++,f.groupId&&l.add(f.groupId))})}if(t===!1){this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1});return}let c=this.validateHighlight({filteredItems:a,newSearch:s,prevSearch:e});this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1,highlightedId:c,highlightSource:null})}static useStore(e,t,s){return _useRefWithInit.useRefWithInit.call(void 0, ()=>_nullishCoalesce(e, () => (new n(t,s)))).current}};function rt(){return{open:!1,search:"",normalizedSearch:"",highlightedId:null,highlightSource:null,hasInput:!1,inputActive:!1,pendingSearch:"",filteredItems:new Map,visibleGroups:new Set,filteredCount:0,filterTrigger:0,virtualized:!1,virtualItemsCount:0}}exports.a = P; exports.b = se; exports.c = te; exports.d = K; exports.e = U; exports.f = be; exports.g = Se; exports.h = G; exports.i = j; exports.j = Ie; exports.k = W; exports.l = Re; exports.m = B; exports.n = q; exports.o = Y; exports.p = Ce; exports.q = A; exports.r = ve; exports.s = Ee; exports.t = ye; exports.u = Me; exports.v = V; exports.w = et; exports.x = J;
|
|
2
|
+
//# sourceMappingURL=chunk-FWWOE2SW.cjs.map
|