@bazza-ui/react 0.1.0-canary.16 → 0.1.0-canary.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/combobox/index.cjs +1 -1
- package/dist/combobox/index.cjs.map +1 -1
- package/dist/combobox/index.d.ts +842 -834
- package/dist/combobox/index.js +1 -1
- package/dist/combobox/index.js.map +1 -1
- package/dist/command-menu/index.cjs +1 -1
- package/dist/command-menu/index.cjs.map +1 -1
- package/dist/command-menu/index.d.ts +123 -96
- package/dist/command-menu/index.js +1 -1
- package/dist/command-menu/index.js.map +1 -1
- package/dist/context-menu/index.cjs +1 -1
- package/dist/context-menu/index.cjs.map +1 -1
- package/dist/context-menu/index.d.ts +701 -658
- package/dist/context-menu/index.js +1 -1
- package/dist/context-menu/index.js.map +1 -1
- package/dist/dropdown-menu/index.cjs +1 -1
- package/dist/dropdown-menu/index.cjs.map +1 -1
- package/dist/dropdown-menu/index.d.ts +723 -680
- package/dist/dropdown-menu/index.js +1 -1
- package/dist/dropdown-menu/index.js.map +1 -1
- package/dist/events-DDOsDu4X.d.ts +2091 -0
- package/dist/index-Cabqj7qI.d.ts +2003 -0
- package/dist/index-D8OrKThQ.d.ts +977 -0
- package/dist/internal/listbox/index.cjs +1 -2
- package/dist/internal/listbox/index.d.ts +2 -272
- package/dist/internal/listbox/index.js +1 -2
- package/dist/internal/popup-menu/index.cjs +1 -2
- package/dist/internal/popup-menu/index.d.ts +4 -238
- package/dist/internal/popup-menu/index.js +1 -2
- package/dist/items-CD2hw6-3.js +2 -0
- package/dist/items-CD2hw6-3.js.map +1 -0
- package/dist/items-DYDljwnt.cjs +2 -0
- package/dist/items-DYDljwnt.cjs.map +1 -0
- package/dist/{items-B6HeFO_8.d.cts → items-ceX--VIv.d.ts} +21 -19
- package/dist/kbd/index.cjs +1 -1
- package/dist/kbd/index.cjs.map +1 -1
- package/dist/kbd/index.d.ts +35 -35
- package/dist/kbd/index.js +1 -1
- package/dist/kbd/index.js.map +1 -1
- package/dist/listbox-CnwUlLZA.js +2 -0
- package/dist/listbox-CnwUlLZA.js.map +1 -0
- package/dist/listbox-DYvJTiF6.cjs +2 -0
- package/dist/listbox-DYvJTiF6.cjs.map +1 -0
- package/dist/loaders/index.cjs +1 -1
- package/dist/loaders/index.cjs.map +1 -1
- package/dist/loaders/index.d.ts +218 -188
- package/dist/loaders/index.js +1 -1
- package/dist/loaders/index.js.map +1 -1
- package/dist/merge-element-props-0mpNO7ZH.cjs +2 -0
- package/dist/merge-element-props-0mpNO7ZH.cjs.map +1 -0
- package/dist/merge-element-props-PxUvRHax.js +2 -0
- package/dist/merge-element-props-PxUvRHax.js.map +1 -0
- package/dist/platform-C-sxBTRa.cjs +2 -0
- package/dist/platform-C-sxBTRa.cjs.map +1 -0
- package/dist/platform-C4_cGUkS.js +2 -0
- package/dist/platform-C4_cGUkS.js.map +1 -0
- package/dist/popup-menu-BBAzAXIe.cjs +2 -0
- package/dist/popup-menu-BBAzAXIe.cjs.map +1 -0
- package/dist/popup-menu-HmBMJEZc.js +2 -0
- package/dist/popup-menu-HmBMJEZc.js.map +1 -0
- package/dist/resolve-state-props-C-zbhdXd.cjs +2 -0
- package/dist/resolve-state-props-C-zbhdXd.cjs.map +1 -0
- package/dist/resolve-state-props-D31kizRZ.js +2 -0
- package/dist/resolve-state-props-D31kizRZ.js.map +1 -0
- package/dist/rolldown-runtime-5lHFv1cW.cjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.js +1 -0
- package/dist/select/index.cjs +1 -1
- package/dist/select/index.cjs.map +1 -1
- package/dist/select/index.d.ts +835 -828
- package/dist/select/index.js +1 -1
- package/dist/select/index.js.map +1 -1
- package/dist/suggestion-menu/index.cjs +4 -0
- package/dist/suggestion-menu/index.cjs.map +1 -0
- package/dist/suggestion-menu/index.d.ts +359 -0
- package/dist/suggestion-menu/index.js +4 -0
- package/dist/suggestion-menu/index.js.map +1 -0
- package/dist/types-BbN28E3_.d.ts +50 -0
- package/dist/video-player/index.cjs +2 -2
- package/dist/video-player/index.cjs.map +1 -1
- package/dist/video-player/index.d.ts +964 -1000
- package/dist/video-player/index.js +2 -2
- package/dist/video-player/index.js.map +1 -1
- package/package.json +14 -5
- package/dist/ListboxStore-B8oTpM57.d.cts +0 -453
- package/dist/ListboxStore-CV5vPUUc.d.ts +0 -453
- package/dist/chunk-3HMQLMSF.js +0 -2
- package/dist/chunk-3HMQLMSF.js.map +0 -1
- package/dist/chunk-4C666HHU.js +0 -2
- package/dist/chunk-4C666HHU.js.map +0 -1
- package/dist/chunk-5T5B5SPR.cjs +0 -2
- package/dist/chunk-5T5B5SPR.cjs.map +0 -1
- package/dist/chunk-A4Z5BY7H.js +0 -2
- package/dist/chunk-A4Z5BY7H.js.map +0 -1
- package/dist/chunk-IT372NHF.js +0 -2
- package/dist/chunk-IT372NHF.js.map +0 -1
- package/dist/chunk-JFEVUUPC.cjs +0 -2
- package/dist/chunk-JFEVUUPC.cjs.map +0 -1
- package/dist/chunk-KO3DXT3Y.js +0 -2
- package/dist/chunk-KO3DXT3Y.js.map +0 -1
- package/dist/chunk-LXXK4S4Q.js +0 -2
- package/dist/chunk-LXXK4S4Q.js.map +0 -1
- package/dist/chunk-M4G6J7DP.cjs +0 -2
- package/dist/chunk-M4G6J7DP.cjs.map +0 -1
- package/dist/chunk-MPPIEWSL.js +0 -2
- package/dist/chunk-MPPIEWSL.js.map +0 -1
- package/dist/chunk-PCNHYMD6.cjs +0 -2
- package/dist/chunk-PCNHYMD6.cjs.map +0 -1
- package/dist/chunk-RTG6U56O.cjs +0 -2
- package/dist/chunk-RTG6U56O.cjs.map +0 -1
- package/dist/chunk-SCDHQZFI.cjs +0 -2
- package/dist/chunk-SCDHQZFI.cjs.map +0 -1
- package/dist/chunk-XMZZ62VJ.cjs +0 -2
- package/dist/chunk-XMZZ62VJ.cjs.map +0 -1
- package/dist/combobox/index.d.cts +0 -1066
- package/dist/command-menu/index.d.cts +0 -154
- package/dist/command-score-CTJ9NV6n.d.cts +0 -23
- package/dist/command-score-CTJ9NV6n.d.ts +0 -23
- package/dist/context-menu/index.d.cts +0 -696
- package/dist/dropdown-menu/index.d.cts +0 -723
- package/dist/events-BTHQ2OoH.d.ts +0 -1860
- package/dist/events-DVcrtGe3.d.cts +0 -1860
- package/dist/input-C95v6jB0.d.cts +0 -46
- package/dist/input-CYweYB_i.d.ts +0 -46
- package/dist/internal/listbox/index.cjs.map +0 -1
- package/dist/internal/listbox/index.d.cts +0 -272
- package/dist/internal/listbox/index.js.map +0 -1
- package/dist/internal/popup-menu/index.cjs.map +0 -1
- package/dist/internal/popup-menu/index.d.cts +0 -238
- package/dist/internal/popup-menu/index.js.map +0 -1
- package/dist/items-B6HeFO_8.d.ts +0 -37
- package/dist/kbd/index.d.cts +0 -61
- package/dist/loaders/index.d.cts +0 -363
- package/dist/loading-C6WZGUc3.d.cts +0 -29
- package/dist/loading-CC4n55sR.d.ts +0 -29
- package/dist/resolve-B-j0eW24.d.cts +0 -406
- package/dist/resolve-B1F-a3P1.d.ts +0 -406
- package/dist/scroll-arrow-BBoKckL_.d.cts +0 -544
- package/dist/scroll-arrow-fl3B5sVO.d.ts +0 -544
- package/dist/select/index.d.cts +0 -1005
- package/dist/separator-Dn15rte3.d.ts +0 -275
- package/dist/separator-NjsBVzek.d.cts +0 -275
- package/dist/surface-context-CGLDpMej.d.ts +0 -14
- package/dist/surface-context-CN4Lb_6F.d.cts +0 -14
- package/dist/type-guards-BHHzjRvZ.d.cts +0 -351
- package/dist/type-guards-C0e_GpeY.d.ts +0 -351
- package/dist/types-DT4FOOa2.d.cts +0 -51
- package/dist/types-DT4FOOa2.d.ts +0 -51
- package/dist/use-listbox-item-NzZuY34-.d.cts +0 -212
- package/dist/use-listbox-item-NzZuY34-.d.ts +0 -212
- package/dist/video-player/index.d.cts +0 -1391
package/dist/loaders/index.d.ts
CHANGED
|
@@ -1,119 +1,126 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { J as InitialQueryBehavior, h as AsyncLoaderResult, it as QueryLoaderConfig, nt as NodeDef, tt as LoaderComponentProps, vt as StaticLoaderConfig } from "../events-DDOsDu4X.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/loaders/swr.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* SWR result shape (subset of SWRResponse).
|
|
7
6
|
* This allows the adapter to work without requiring `swr` as a dependency.
|
|
8
7
|
*/
|
|
9
8
|
interface SWRResult<TData, TError = Error> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
data: TData | undefined;
|
|
10
|
+
error: TError | undefined;
|
|
11
|
+
isLoading?: boolean;
|
|
12
|
+
isValidating: boolean;
|
|
13
|
+
isPaused?: boolean;
|
|
14
|
+
mutate: (...args: unknown[]) => unknown;
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
17
|
* Converts an SWR result to an AsyncLoaderResult.
|
|
19
18
|
*/
|
|
20
|
-
declare function toAsyncLoaderResultFromSWR<TData, TError = Error>(result: SWRResult<TData, TError>): AsyncLoaderResult<TData, SWRResult<TData, TError>>;
|
|
19
|
+
export declare function toAsyncLoaderResultFromSWR<TData, TError = Error>(result: SWRResult<TData, TError>): AsyncLoaderResult<TData, SWRResult<TData, TError>>;
|
|
21
20
|
/**
|
|
22
21
|
* Props for creating a static SWR loader component.
|
|
23
22
|
*/
|
|
24
23
|
interface CreateSWRStaticLoaderProps {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
/** Hook that returns an SWR result. */
|
|
25
|
+
useSWR: () => SWRResult<NodeDef[]>;
|
|
26
|
+
/**
|
|
27
|
+
* When to trigger the loader:
|
|
28
|
+
* - 'eager': Load when root menu opens
|
|
29
|
+
* - 'lazy': Load when submenu opens (default)
|
|
30
|
+
*/
|
|
31
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
35
34
|
* Creates a static loader configuration backed by SWR.
|
|
36
35
|
*/
|
|
37
|
-
declare function createSWRStaticLoader(props: CreateSWRStaticLoaderProps): StaticLoaderConfig;
|
|
36
|
+
export declare function createSWRStaticLoader(props: CreateSWRStaticLoaderProps): StaticLoaderConfig;
|
|
38
37
|
/**
|
|
39
38
|
* Props for creating a query SWR loader component.
|
|
40
39
|
*/
|
|
41
40
|
interface CreateSWRQueryLoaderProps {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Hook that returns an SWR result based on the search query.
|
|
43
|
+
* `options.enabled` can be used to derive a `null` key and disable fetching.
|
|
44
|
+
*/
|
|
45
|
+
useSWR: (query: string, options?: {
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
}) => SWRResult<NodeDef[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Minimum query length before fetching.
|
|
50
|
+
* @default 1
|
|
51
|
+
*/
|
|
52
|
+
minQueryLength?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Initial query behavior before user input reaches minQueryLength.
|
|
55
|
+
* Defaults to fetching with an empty query.
|
|
56
|
+
*/
|
|
57
|
+
initialQueryBehavior?: InitialQueryBehavior | false;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Use `initialQueryBehavior` instead.
|
|
60
|
+
*/
|
|
61
|
+
initialQuery?: string;
|
|
62
|
+
/**
|
|
63
|
+
* When to trigger the loader:
|
|
64
|
+
* - 'eager': Load when root menu opens (good for deep search)
|
|
65
|
+
* - 'lazy': Load when submenu opens (default)
|
|
66
|
+
* @default 'lazy'
|
|
67
|
+
*/
|
|
68
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
69
|
+
/**
|
|
70
|
+
* What to show when query is below minQueryLength.
|
|
71
|
+
* @default 'empty'
|
|
72
|
+
*/
|
|
73
|
+
belowMinBehavior?: 'empty' | 'placeholder';
|
|
74
|
+
/**
|
|
75
|
+
* Placeholder nodes shown when query is below minQueryLength.
|
|
76
|
+
*/
|
|
77
|
+
placeholderNodes?: NodeDef[];
|
|
78
|
+
/**
|
|
79
|
+
* Milliseconds to wait after the search stops changing before passing it to
|
|
80
|
+
* the loader. While waiting, the loader counts as fetching, so the menu
|
|
81
|
+
* doesn't show "no results" or treat the search as finished too early.
|
|
82
|
+
* @default 0
|
|
83
|
+
*/
|
|
84
|
+
debounce?: number;
|
|
79
85
|
}
|
|
80
86
|
/**
|
|
81
87
|
* Creates a query loader configuration backed by SWR.
|
|
82
88
|
*/
|
|
83
|
-
declare function createSWRQueryLoader(props: CreateSWRQueryLoaderProps): QueryLoaderConfig;
|
|
89
|
+
export declare function createSWRQueryLoader(props: CreateSWRQueryLoaderProps): QueryLoaderConfig;
|
|
84
90
|
/**
|
|
85
91
|
* Creates a loader component that wraps an SWR hook.
|
|
86
92
|
*/
|
|
87
|
-
declare function createSWRLoaderComponent(useSWRFn: (query: string) => SWRResult<NodeDef[]>): React.FC<LoaderComponentProps>;
|
|
88
|
-
|
|
93
|
+
export declare function createSWRLoaderComponent(useSWRFn: (query: string) => SWRResult<NodeDef[]>): React.FC<LoaderComponentProps>;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/loaders/tanstack-query.d.ts
|
|
89
96
|
/**
|
|
90
97
|
* TanStack Query result shape (subset of UseQueryResult).
|
|
91
98
|
* This allows the adapter to work without requiring @tanstack/react-query as a dependency.
|
|
92
99
|
*/
|
|
93
100
|
interface TanStackQueryResult<TData, TError = Error> {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
/** TanStack status (`pending` | `error` | `success`) */
|
|
102
|
+
status?: 'pending' | 'error' | 'success';
|
|
103
|
+
/** TanStack fetch status (`fetching` | `paused` | `idle`) */
|
|
104
|
+
fetchStatus?: 'fetching' | 'paused' | 'idle';
|
|
105
|
+
data: TData | undefined;
|
|
106
|
+
error: TError | null | undefined;
|
|
107
|
+
/** v5: true when first fetch is in-flight */
|
|
108
|
+
isLoading?: boolean;
|
|
109
|
+
/** v5: true when status is pending */
|
|
110
|
+
isPending?: boolean;
|
|
111
|
+
/** true when status is success */
|
|
112
|
+
isSuccess?: boolean;
|
|
113
|
+
/** true when status is error */
|
|
114
|
+
isError?: boolean;
|
|
115
|
+
/** true while any fetch is in-flight */
|
|
116
|
+
isFetching?: boolean;
|
|
117
|
+
/** true while background refetch is in-flight */
|
|
118
|
+
isRefetching?: boolean;
|
|
119
|
+
/** true when fetch is paused */
|
|
120
|
+
isPaused?: boolean;
|
|
121
|
+
/** true once query has fetched at least once */
|
|
122
|
+
isFetched?: boolean;
|
|
123
|
+
refetch: () => unknown;
|
|
117
124
|
}
|
|
118
125
|
/**
|
|
119
126
|
* Converts a TanStack Query result to an AsyncLoaderResult.
|
|
@@ -130,22 +137,22 @@ interface TanStackQueryResult<TData, TError = Error> {
|
|
|
130
137
|
* }
|
|
131
138
|
* ```
|
|
132
139
|
*/
|
|
133
|
-
declare function toAsyncLoaderResult<TData, TError = Error>(result: TanStackQueryResult<TData, TError>): AsyncLoaderResult<TData, TanStackQueryResult<TData, TError>>;
|
|
140
|
+
export declare function toAsyncLoaderResult<TData, TError = Error>(result: TanStackQueryResult<TData, TError>): AsyncLoaderResult<TData, TanStackQueryResult<TData, TError>>;
|
|
134
141
|
/**
|
|
135
142
|
* Props for creating a static loader component.
|
|
136
143
|
*/
|
|
137
144
|
interface CreateStaticLoaderProps {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Hook that returns a TanStack Query result.
|
|
147
|
+
* This hook will be called inside the loader component.
|
|
148
|
+
*/
|
|
149
|
+
useQuery: () => TanStackQueryResult<NodeDef[]>;
|
|
150
|
+
/**
|
|
151
|
+
* When to trigger the loader:
|
|
152
|
+
* - 'eager': Load when root menu opens
|
|
153
|
+
* - 'lazy': Load when submenu opens (default)
|
|
154
|
+
*/
|
|
155
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
149
156
|
}
|
|
150
157
|
/**
|
|
151
158
|
* Creates a static loader configuration for use with async menus.
|
|
@@ -173,48 +180,55 @@ interface CreateStaticLoaderProps {
|
|
|
173
180
|
* }
|
|
174
181
|
* ```
|
|
175
182
|
*/
|
|
176
|
-
declare function createStaticLoader(props: CreateStaticLoaderProps): StaticLoaderConfig;
|
|
183
|
+
export declare function createStaticLoader(props: CreateStaticLoaderProps): StaticLoaderConfig;
|
|
177
184
|
/**
|
|
178
185
|
* Props for creating a query loader component.
|
|
179
186
|
*/
|
|
180
187
|
interface CreateQueryLoaderProps {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Hook that returns a TanStack Query result based on the search query.
|
|
190
|
+
* This hook will be called inside the loader component with the current query.
|
|
191
|
+
*/
|
|
192
|
+
useQuery: (query: string, options?: {
|
|
193
|
+
enabled: boolean;
|
|
194
|
+
}) => TanStackQueryResult<NodeDef[]>;
|
|
195
|
+
/**
|
|
196
|
+
* Minimum query length before fetching.
|
|
197
|
+
* @default 1
|
|
198
|
+
*/
|
|
199
|
+
minQueryLength?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Initial query behavior before user input reaches minQueryLength.
|
|
202
|
+
* Defaults to fetching with an empty query.
|
|
203
|
+
*/
|
|
204
|
+
initialQueryBehavior?: InitialQueryBehavior | false;
|
|
205
|
+
/**
|
|
206
|
+
* @deprecated Use `initialQueryBehavior` instead.
|
|
207
|
+
*/
|
|
208
|
+
initialQuery?: string;
|
|
209
|
+
/**
|
|
210
|
+
* When to trigger the loader:
|
|
211
|
+
* - 'eager': Load when root menu opens (good for deep search)
|
|
212
|
+
* - 'lazy': Load when submenu opens (default)
|
|
213
|
+
* @default 'lazy'
|
|
214
|
+
*/
|
|
215
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
216
|
+
/**
|
|
217
|
+
* What to show when query is below minQueryLength.
|
|
218
|
+
* @default 'empty'
|
|
219
|
+
*/
|
|
220
|
+
belowMinBehavior?: 'empty' | 'placeholder';
|
|
221
|
+
/**
|
|
222
|
+
* Placeholder nodes shown when query is below minQueryLength.
|
|
223
|
+
*/
|
|
224
|
+
placeholderNodes?: NodeDef[];
|
|
225
|
+
/**
|
|
226
|
+
* Milliseconds to wait after the search stops changing before passing it to
|
|
227
|
+
* the loader. While waiting, the loader counts as fetching, so the menu
|
|
228
|
+
* doesn't show "no results" or treat the search as finished too early.
|
|
229
|
+
* @default 0
|
|
230
|
+
*/
|
|
231
|
+
debounce?: number;
|
|
218
232
|
}
|
|
219
233
|
/**
|
|
220
234
|
* Creates a query loader configuration for use with async menus.
|
|
@@ -241,7 +255,7 @@ interface CreateQueryLoaderProps {
|
|
|
241
255
|
* }
|
|
242
256
|
* ```
|
|
243
257
|
*/
|
|
244
|
-
declare function createQueryLoader(props: CreateQueryLoaderProps): QueryLoaderConfig;
|
|
258
|
+
export declare function createQueryLoader(props: CreateQueryLoaderProps): QueryLoaderConfig;
|
|
245
259
|
/**
|
|
246
260
|
* Creates a loader component that wraps a TanStack Query hook.
|
|
247
261
|
* This is a lower-level utility for custom loader implementations.
|
|
@@ -256,22 +270,23 @@ declare function createQueryLoader(props: CreateQueryLoaderProps): QueryLoaderCo
|
|
|
256
270
|
* )
|
|
257
271
|
* ```
|
|
258
272
|
*/
|
|
259
|
-
declare function createLoaderComponent(useQueryFn: (query: string) => TanStackQueryResult<NodeDef[]>): React.FC<LoaderComponentProps>;
|
|
260
|
-
|
|
273
|
+
export declare function createLoaderComponent(useQueryFn: (query: string) => TanStackQueryResult<NodeDef[]>): React.FC<LoaderComponentProps>;
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/loaders/vanilla.d.ts
|
|
261
276
|
/**
|
|
262
277
|
* Props for creating a static loader with vanilla fetch.
|
|
263
278
|
*/
|
|
264
279
|
interface CreateVanillaStaticLoaderProps {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Async function that fetches the menu items.
|
|
282
|
+
*/
|
|
283
|
+
fetcher: () => Promise<NodeDef[]>;
|
|
284
|
+
/**
|
|
285
|
+
* When to trigger the loader:
|
|
286
|
+
* - 'eager': Load when root menu opens
|
|
287
|
+
* - 'lazy': Load when submenu opens (default)
|
|
288
|
+
*/
|
|
289
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
275
290
|
}
|
|
276
291
|
/**
|
|
277
292
|
* Creates a static loader configuration using plain fetch/promises.
|
|
@@ -292,49 +307,63 @@ interface CreateVanillaStaticLoaderProps {
|
|
|
292
307
|
* })
|
|
293
308
|
* ```
|
|
294
309
|
*/
|
|
295
|
-
declare function createVanillaStaticLoader(props: CreateVanillaStaticLoaderProps): StaticLoaderConfig;
|
|
310
|
+
export declare function createVanillaStaticLoader(props: CreateVanillaStaticLoaderProps): StaticLoaderConfig;
|
|
296
311
|
/**
|
|
297
312
|
* Props for creating a query loader with vanilla fetch.
|
|
298
313
|
*/
|
|
299
314
|
interface CreateVanillaQueryLoaderProps {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
315
|
+
/**
|
|
316
|
+
* Async function that fetches menu items based on the search query.
|
|
317
|
+
* Receives an optional `signal` that is aborted when a newer query is issued,
|
|
318
|
+
* allowing you to cancel in-flight requests (e.g. pass it to `fetch()`).
|
|
319
|
+
*/
|
|
320
|
+
fetcher: (query: string, options?: {
|
|
321
|
+
signal?: AbortSignal;
|
|
322
|
+
}) => Promise<NodeDef[]>;
|
|
323
|
+
/**
|
|
324
|
+
* Minimum query length before fetching.
|
|
325
|
+
* @default 1
|
|
326
|
+
*/
|
|
327
|
+
minQueryLength?: number;
|
|
328
|
+
/**
|
|
329
|
+
* Initial query behavior before user input reaches minQueryLength.
|
|
330
|
+
* Defaults to fetching with an empty query.
|
|
331
|
+
*/
|
|
332
|
+
initialQueryBehavior?: InitialQueryBehavior | false;
|
|
333
|
+
/**
|
|
334
|
+
* @deprecated Use `initialQueryBehavior` instead.
|
|
335
|
+
*/
|
|
336
|
+
initialQuery?: string;
|
|
337
|
+
/**
|
|
338
|
+
* When to trigger the loader:
|
|
339
|
+
* - 'eager': Load when root menu opens (good for deep search)
|
|
340
|
+
* - 'lazy': Load when submenu opens (default)
|
|
341
|
+
* @default 'lazy'
|
|
342
|
+
*/
|
|
343
|
+
loadStrategy?: 'eager' | 'lazy';
|
|
344
|
+
/**
|
|
345
|
+
* What to show when query is below minQueryLength.
|
|
346
|
+
* @default 'empty'
|
|
347
|
+
*/
|
|
348
|
+
belowMinBehavior?: 'empty' | 'placeholder';
|
|
349
|
+
/**
|
|
350
|
+
* Placeholder nodes shown when query is below minQueryLength.
|
|
351
|
+
*/
|
|
352
|
+
placeholderNodes?: NodeDef[];
|
|
353
|
+
/**
|
|
354
|
+
* Milliseconds to wait after the search stops changing before passing it to
|
|
355
|
+
* the loader. While waiting, the loader counts as fetching, so the menu
|
|
356
|
+
* doesn't show "no results" or treat the search as finished too early.
|
|
357
|
+
* @default 0
|
|
358
|
+
*/
|
|
359
|
+
debounce?: number;
|
|
360
|
+
/**
|
|
361
|
+
* Keep showing the last results while the next search loads, instead of
|
|
362
|
+
* clearing them on every change of the search. The refetch is reported as a
|
|
363
|
+
* background load, so `Loading` doesn't flash. Named after SWR's option.
|
|
364
|
+
* @default false
|
|
365
|
+
*/
|
|
366
|
+
keepPreviousData?: boolean;
|
|
338
367
|
}
|
|
339
368
|
/**
|
|
340
369
|
* Creates a query loader configuration using plain fetch/promises.
|
|
@@ -358,6 +387,7 @@ interface CreateVanillaQueryLoaderProps {
|
|
|
358
387
|
* })
|
|
359
388
|
* ```
|
|
360
389
|
*/
|
|
361
|
-
declare function createVanillaQueryLoader(props: CreateVanillaQueryLoaderProps): QueryLoaderConfig;
|
|
362
|
-
|
|
363
|
-
export {
|
|
390
|
+
export declare function createVanillaQueryLoader(props: CreateVanillaQueryLoaderProps): QueryLoaderConfig;
|
|
391
|
+
//#endregion
|
|
392
|
+
export type { CreateQueryLoaderProps, CreateSWRQueryLoaderProps, CreateSWRStaticLoaderProps, CreateStaticLoaderProps, CreateVanillaQueryLoaderProps, CreateVanillaStaticLoaderProps, SWRResult, TanStackQueryResult };
|
|
393
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/loaders/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"
|
|
1
|
+
import*as e from"react";import{Fragment as t,jsx as n}from"react/jsx-runtime";function r(e){return e==null?null:e instanceof Error?e:Error(String(e))}function i(e){let t=r(e.error),n=e.data!==void 0,i=e.isPaused?`paused`:e.isValidating?`fetching`:`idle`,a=i===`fetching`,o=e.isLoading??(a&&!n&&t==null),s=a&&!o,c=t?`error`:n?`success`:o||a?`pending`:`idle`,l=o?`initial`:s?`background`:`none`;return{data:e.data,raw:e,source:`swr`,error:t,status:c,fetchStatus:i,loadingPhase:l,isLoading:o,isFetching:a,isInitialLoading:o,isRefetching:s,isPending:c===`pending`,isSuccess:c===`success`,isError:c===`error`,isPaused:i===`paused`,hasData:n,hasFetched:n||t!=null||o||s,refetch:()=>e.mutate()}}function a(e){let{useSWR:r,loadStrategy:a}=e;return{type:`static`,Loader:({children:e})=>{let a=r();return/* @__PURE__ */ n(t,{children:e(i(a))})},loadStrategy:a}}function o(e){let{useSWR:r,minQueryLength:a=1,initialQueryBehavior:o,initialQuery:s,loadStrategy:c,belowMinBehavior:l=`empty`,placeholderNodes:u,debounce:d}=e,f=o===void 0?s===void 0?{value:``,loadWhen:`needed`}:{value:s,loadWhen:`needed`}:o;return{type:`query`,Loader:({query:e,enabled:o,children:s})=>{let c=o??(e.length>=a||f!==!1),l=r(e,{enabled:c});return/* @__PURE__ */ n(t,{children:s(i(l))})},minQueryLength:a,initialQueryBehavior:f,initialQuery:s,loadStrategy:c,belowMinBehavior:l,placeholderNodes:u,debounce:d}}function s(e){return function({query:r,children:a}){let o=e(r);return/* @__PURE__ */ n(t,{children:a(i(o))})}}function c(e){return e==null?null:e instanceof Error?e:Error(String(e))}function l(e){let t=e.data!==void 0,n=e.fetchStatus?e.fetchStatus:e.isPaused?`paused`:e.isFetching||e.isLoading?`fetching`:`idle`,r=n===`fetching`,i=e.status?e.status:e.isError?`error`:e.isSuccess||t?`success`:e.isPending||e.isLoading||r?`pending`:`idle`,a=e.isPending??i===`pending`,o=e.isSuccess??i===`success`,s=e.isError??i===`error`,l=e.isLoading??(a&&r),u=e.isRefetching??(r&&!l),d=e.isPaused??n===`paused`,f=e.isFetched??(o||s||l||u),p=l?`initial`:u?`background`:`none`;return{data:e.data,raw:e,source:`tanstack-query`,error:c(e.error),status:i,fetchStatus:n,loadingPhase:p,isLoading:l,isFetching:r,isInitialLoading:l,isRefetching:u,isPending:a,isSuccess:o,isError:s,isPaused:d,hasData:t,hasFetched:f,refetch:e.refetch}}function u(e){let{useQuery:r,loadStrategy:i}=e;return{type:`static`,Loader:({children:e})=>{let i=r();return/* @__PURE__ */ n(t,{children:e(l(i))})},loadStrategy:i}}function d(e){let{useQuery:r,minQueryLength:i=1,initialQueryBehavior:a,initialQuery:o,loadStrategy:s,belowMinBehavior:c=`empty`,placeholderNodes:u,debounce:d}=e,f=a===void 0?o===void 0?{value:``,loadWhen:`needed`}:{value:o,loadWhen:`needed`}:a;return{type:`query`,Loader:({query:e,enabled:a,children:o})=>{let s=a??(e.length>=i||f!==!1),c=r(e,{enabled:s});return/* @__PURE__ */ n(t,{children:o(l(c))})},minQueryLength:i,initialQueryBehavior:f,initialQuery:o,loadStrategy:s,belowMinBehavior:c,placeholderNodes:u,debounce:d}}function f(e){return function({query:r,children:i}){let a=e(r);return/* @__PURE__ */ n(t,{children:i(l(a))})}}function p(e){return e==null?null:e instanceof Error?e:Error(String(e))}function m(e){return e.error?`error`:e.data===void 0?e.isFetching?`pending`:`idle`:`success`}function h(e,t){let n=m(e),r=e.isFetching?`fetching`:`idle`,i=e.isFetching&&!e.hasFetched,a=e.isFetching&&e.hasFetched,o=i?`initial`:a?`background`:`none`;return{data:e.data,source:`vanilla`,error:e.error,status:n,fetchStatus:r,loadingPhase:o,isLoading:i,isFetching:e.isFetching,isInitialLoading:i,isRefetching:a,isPending:n===`pending`,isSuccess:n===`success`,isError:n===`error`,isPaused:!1,hasData:e.data!==void 0,hasFetched:e.hasFetched,refetch:t}}function g(t,n){let{enabled:r=!0}=n??{},[i,a]=e.useState(()=>({data:void 0,error:null,isFetching:r,hasFetched:!1})),o=e.useRef(t);o.current=t;let s=e.useCallback(()=>{a(e=>({...e,isFetching:!0,error:null})),o.current().then(e=>{a({data:e,error:null,isFetching:!1,hasFetched:!0})}).catch(e=>{a(t=>({...t,error:p(e),isFetching:!1,hasFetched:!0}))})},[]);return e.useEffect(()=>{if(r){s();return}a(e=>({...e,isFetching:!1}))},[r,s]),e.useMemo(()=>h(i,s),[i,s])}function _(t,n,r){let{enabled:i=!0,keepPreviousData:a=!1}=r??{},[o,s]=e.useState(()=>({data:void 0,error:null,isFetching:i,hasFetched:!1,query:n})),c=e.useRef(t);c.current=t;let l=e.useRef(n);l.current=n,e.useEffect(()=>{if(!i){s({data:void 0,error:null,isFetching:!1,hasFetched:!1,query:n});return}let e=new AbortController;return s(e=>a&&e.data!==void 0?{...e,error:null,isFetching:!0,query:n}:{data:void 0,error:null,isFetching:!0,hasFetched:!1,query:n}),c.current(n,{signal:e.signal}).then(t=>{e.signal.aborted||s({data:t,error:null,isFetching:!1,hasFetched:!0,query:n})}).catch(t=>{e.signal.aborted||s({data:void 0,error:p(t),isFetching:!1,hasFetched:!0,query:n})}),()=>{e.abort()}},[i,n,a]);let u=e.useCallback(()=>{s(e=>({...e,isFetching:!0,error:null})),c.current(n).then(e=>{l.current===n&&s({data:e,error:null,isFetching:!1,hasFetched:!0,query:n})}).catch(e=>{l.current===n&&s(t=>({...t,error:p(e),isFetching:!1,hasFetched:!0,query:n}))})},[n]),d=e.useMemo(()=>!i||o.query===n?o:a&&o.data!==void 0?{...o,error:null,isFetching:!0}:{data:void 0,error:null,isFetching:!0,hasFetched:!1},[o,i,n,a]);return e.useMemo(()=>h(d,u),[d,u])}function v(e){let{fetcher:r,loadStrategy:i}=e;return{type:`static`,Loader:({children:e})=>{let i=g(r);return/* @__PURE__ */ n(t,{children:e(i)})},loadStrategy:i}}function y(e){let{fetcher:r,minQueryLength:i=1,initialQueryBehavior:a,initialQuery:o,loadStrategy:s,belowMinBehavior:c=`empty`,placeholderNodes:l,debounce:u,keepPreviousData:d=!1}=e,f=a===void 0?o===void 0?{value:``,loadWhen:`needed`}:{value:o,loadWhen:`needed`}:a;return{type:`query`,Loader:({query:e,enabled:a,children:o})=>{let s=a??(e.length>=i||f!==!1),c=_(r,e,{enabled:s,keepPreviousData:d});return/* @__PURE__ */ n(t,{children:o(c)})},minQueryLength:i,initialQueryBehavior:f,initialQuery:o,loadStrategy:s,belowMinBehavior:c,placeholderNodes:l,debounce:u}}export{f as createLoaderComponent,d as createQueryLoader,s as createSWRLoaderComponent,o as createSWRQueryLoader,a as createSWRStaticLoader,u as createStaticLoader,y as createVanillaQueryLoader,v as createVanillaStaticLoader,l as toAsyncLoaderResult,i as toAsyncLoaderResultFromSWR};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|