@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.
Files changed (81) hide show
  1. package/dist/ListboxStore-BtcTXpzi.d.cts +351 -0
  2. package/dist/ListboxStore-DPqpLlAL.d.ts +351 -0
  3. package/dist/adapters/index.cjs +2 -0
  4. package/dist/adapters/index.cjs.map +1 -0
  5. package/dist/adapters/index.d.cts +363 -0
  6. package/dist/adapters/index.d.ts +363 -0
  7. package/dist/adapters/index.js +2 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/chunk-4C666HHU.js +2 -0
  10. package/dist/chunk-4C666HHU.js.map +1 -0
  11. package/dist/chunk-AVZ64JQ3.js +2 -0
  12. package/dist/chunk-AVZ64JQ3.js.map +1 -0
  13. package/dist/chunk-BGJJC6GX.cjs +2 -0
  14. package/dist/chunk-BGJJC6GX.cjs.map +1 -0
  15. package/dist/chunk-FWWOE2SW.cjs +2 -0
  16. package/dist/chunk-FWWOE2SW.cjs.map +1 -0
  17. package/dist/chunk-JSPKF52O.cjs +2 -0
  18. package/dist/chunk-JSPKF52O.cjs.map +1 -0
  19. package/dist/chunk-KWGD24VS.js +2 -0
  20. package/dist/chunk-KWGD24VS.js.map +1 -0
  21. package/dist/chunk-M4G6J7DP.cjs +2 -0
  22. package/dist/chunk-M4G6J7DP.cjs.map +1 -0
  23. package/dist/chunk-WKAPAKUL.js +2 -0
  24. package/dist/chunk-WKAPAKUL.js.map +1 -0
  25. package/dist/combobox/index.cjs +2 -0
  26. package/dist/combobox/index.cjs.map +1 -0
  27. package/dist/combobox/index.d.cts +1039 -0
  28. package/dist/combobox/index.d.ts +1039 -0
  29. package/dist/combobox/index.js +2 -0
  30. package/dist/combobox/index.js.map +1 -0
  31. package/dist/command-score-Dgo3ZS3Z.d.ts +36 -0
  32. package/dist/command-score-YjNr3ZWi.d.cts +36 -0
  33. package/dist/context-menu/index.cjs +2 -0
  34. package/dist/context-menu/index.cjs.map +1 -0
  35. package/dist/context-menu/index.d.cts +658 -0
  36. package/dist/context-menu/index.d.ts +658 -0
  37. package/dist/context-menu/index.js +2 -0
  38. package/dist/context-menu/index.js.map +1 -0
  39. package/dist/data-surface-B-eIGTBi.d.cts +678 -0
  40. package/dist/data-surface-D1OilMDu.d.ts +678 -0
  41. package/dist/dropdown-menu/index.cjs +2 -0
  42. package/dist/dropdown-menu/index.cjs.map +1 -0
  43. package/dist/dropdown-menu/index.d.cts +700 -0
  44. package/dist/dropdown-menu/index.d.ts +700 -0
  45. package/dist/dropdown-menu/index.js +2 -0
  46. package/dist/dropdown-menu/index.js.map +1 -0
  47. package/dist/events-BPr8sRGH.d.cts +166 -0
  48. package/dist/events-BPr8sRGH.d.ts +166 -0
  49. package/dist/input-BoIK003I.d.cts +41 -0
  50. package/dist/input-DF7D8YzW.d.ts +41 -0
  51. package/dist/internal/listbox/index.cjs +2 -0
  52. package/dist/internal/listbox/index.cjs.map +1 -0
  53. package/dist/internal/listbox/index.d.cts +269 -0
  54. package/dist/internal/listbox/index.d.ts +269 -0
  55. package/dist/internal/listbox/index.js +2 -0
  56. package/dist/internal/listbox/index.js.map +1 -0
  57. package/dist/internal/popup-menu/index.cjs +2 -0
  58. package/dist/internal/popup-menu/index.cjs.map +1 -0
  59. package/dist/internal/popup-menu/index.d.cts +846 -0
  60. package/dist/internal/popup-menu/index.d.ts +846 -0
  61. package/dist/internal/popup-menu/index.js +2 -0
  62. package/dist/internal/popup-menu/index.js.map +1 -0
  63. package/dist/item-equality-B6TbXlBT.d.cts +7 -0
  64. package/dist/item-equality-B6TbXlBT.d.ts +7 -0
  65. package/dist/loading-DphSt8MY.d.cts +27 -0
  66. package/dist/loading-TsgH6v92.d.ts +27 -0
  67. package/dist/select/index.cjs +2 -0
  68. package/dist/select/index.cjs.map +1 -0
  69. package/dist/select/index.d.cts +927 -0
  70. package/dist/select/index.d.ts +927 -0
  71. package/dist/select/index.js +2 -0
  72. package/dist/select/index.js.map +1 -0
  73. package/dist/separator-B4Ot84B0.d.ts +748 -0
  74. package/dist/separator-BmbUeeaT.d.cts +748 -0
  75. package/dist/types-9vS1uLIK.d.cts +1557 -0
  76. package/dist/types-lQCIvWW8.d.ts +1557 -0
  77. package/dist/use-listbox-item-BIi4eRPI.d.cts +182 -0
  78. package/dist/use-listbox-item-BIi4eRPI.d.ts +182 -0
  79. package/package.json +50 -12
  80. package/dist/index.d.ts +0 -2
  81. 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-9vS1uLIK.cjs';
3
+ import '../events-BPr8sRGH.cjs';
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 };