next-data-kit 9.2.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +2957 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +60 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2913 -7
- package/dist/client.js.map +1 -1
- package/dist/index-CzDzNX62.d.cts +558 -0
- package/dist/index-CzDzNX62.d.ts +558 -0
- package/dist/index.d.cts +5 -557
- package/dist/index.d.ts +5 -557
- package/dist/types/index.js +2 -6
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/components/data-kit-infinity.js +0 -86
- package/dist/client/components/data-kit-infinity.js.map +0 -1
- package/dist/client/components/data-kit-table.js +0 -190
- package/dist/client/components/data-kit-table.js.map +0 -1
- package/dist/client/components/data-kit.js +0 -79
- package/dist/client/components/data-kit.js.map +0 -1
- package/dist/client/components/index.js +0 -4
- package/dist/client/components/index.js.map +0 -1
- package/dist/client/components/ui/button.js +0 -36
- package/dist/client/components/ui/button.js.map +0 -1
- package/dist/client/components/ui/checkbox.js +0 -10
- package/dist/client/components/ui/checkbox.js.map +0 -1
- package/dist/client/components/ui/dropdown-menu.js +0 -52
- package/dist/client/components/ui/dropdown-menu.js.map +0 -1
- package/dist/client/components/ui/index.js +0 -8
- package/dist/client/components/ui/index.js.map +0 -1
- package/dist/client/components/ui/pagination.js +0 -31
- package/dist/client/components/ui/pagination.js.map +0 -1
- package/dist/client/components/ui/popover.js +0 -18
- package/dist/client/components/ui/popover.js.map +0 -1
- package/dist/client/components/ui/select.js +0 -39
- package/dist/client/components/ui/select.js.map +0 -1
- package/dist/client/components/ui/table.js +0 -29
- package/dist/client/components/ui/table.js.map +0 -1
- package/dist/client/context/index.js +0 -28
- package/dist/client/context/index.js.map +0 -1
- package/dist/client/hooks/index.js +0 -7
- package/dist/client/hooks/index.js.map +0 -1
- package/dist/client/hooks/useDataKit.js +0 -308
- package/dist/client/hooks/useDataKit.js.map +0 -1
- package/dist/client/hooks/usePagination.js +0 -51
- package/dist/client/hooks/usePagination.js.map +0 -1
- package/dist/client/hooks/useSelection.js +0 -93
- package/dist/client/hooks/useSelection.js.map +0 -1
- package/dist/client/index.js +0 -15
- package/dist/client/index.js.map +0 -1
- package/dist/client/utils/cn.js +0 -22
- package/dist/client/utils/cn.js.map +0 -1
- package/dist/client/utils/index.js +0 -133
- package/dist/client/utils/index.js.map +0 -1
- package/dist/server/utils.js +0 -117
- package/dist/server/utils.js.map +0 -1
- package/dist/types/client/component.js +0 -7
- package/dist/types/client/component.js.map +0 -1
- package/dist/types/client/hook.js +0 -7
- package/dist/types/client/hook.js.map +0 -1
- package/dist/types/client/selectable.js +0 -7
- package/dist/types/client/selectable.js.map +0 -1
- package/dist/types/next-data-kit.js +0 -7
- package/dist/types/next-data-kit.js.map +0 -1
- package/dist/types/server/action.js +0 -7
- package/dist/types/server/action.js.map +0 -1
- package/dist/types/server/database/mongo.js +0 -7
- package/dist/types/server/database/mongo.js.map +0 -1
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* next-data-kit - Database Types (Mongo)
|
|
7
|
+
*
|
|
8
|
+
* MongoDB-specific types for filters and queries.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Sort order for database queries
|
|
12
|
+
*/
|
|
13
|
+
type TSortOrder = 1 | -1 | 'asc' | 'desc' | 'ascending' | 'descending';
|
|
14
|
+
/**
|
|
15
|
+
* Filter operators for individual fields (Mongo subset)
|
|
16
|
+
*/
|
|
17
|
+
type TMongoFilterOperators<T> = {
|
|
18
|
+
$eq?: T;
|
|
19
|
+
$ne?: T;
|
|
20
|
+
$gt?: T;
|
|
21
|
+
$gte?: T;
|
|
22
|
+
$lt?: T;
|
|
23
|
+
$lte?: T;
|
|
24
|
+
$in?: T[];
|
|
25
|
+
$nin?: T[];
|
|
26
|
+
$exists?: boolean;
|
|
27
|
+
$regex?: string | RegExp;
|
|
28
|
+
$options?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Mongo root operators.
|
|
32
|
+
*/
|
|
33
|
+
type TMongoRootFilterOperators<T> = {
|
|
34
|
+
$and?: TMongoFilterQuery<T>[];
|
|
35
|
+
$or?: TMongoFilterQuery<T>[];
|
|
36
|
+
$nor?: TMongoFilterQuery<T>[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Mongo filter query type.
|
|
40
|
+
*/
|
|
41
|
+
type TMongoFilterQuery<T> = {
|
|
42
|
+
[P in keyof T]?: T[P] | TMongoFilterOperators<T[P]>;
|
|
43
|
+
} & TMongoRootFilterOperators<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Minimal Mongoose Model interface for the adapter.
|
|
46
|
+
*/
|
|
47
|
+
type TMongoModel<T = unknown> = {
|
|
48
|
+
countDocuments(filter?: TMongoFilterQuery<T>): Promise<number>;
|
|
49
|
+
find(filter?: TMongoFilterQuery<T>, projection?: unknown, options?: unknown): TMongoQuery<T>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Mongoose Query interface.
|
|
53
|
+
*/
|
|
54
|
+
type TMongoQuery<T> = {
|
|
55
|
+
sort(sort: Record<string, TSortOrder>): TMongoQuery<T>;
|
|
56
|
+
limit(limit: number): TMongoQuery<T>;
|
|
57
|
+
skip(skip: number): TMongoQuery<T>;
|
|
58
|
+
then<TResult1 = T[], TResult2 = never>(onfulfilled?: ((value: T[]) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* next-data-kit - React Data Kit Types
|
|
63
|
+
*
|
|
64
|
+
* Core types for the next-data-kit server action and components.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sort options type that references keys from the item type
|
|
69
|
+
*/
|
|
70
|
+
type TSortOptions<T> = {
|
|
71
|
+
[K in keyof T]?: TSortOrder;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Sort entry for array-based sorting
|
|
75
|
+
*/
|
|
76
|
+
type TSortEntry = {
|
|
77
|
+
path: string;
|
|
78
|
+
value: 1 | -1;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Filter configuration item
|
|
82
|
+
*/
|
|
83
|
+
type TFilterConfiguration = {
|
|
84
|
+
type: 'REGEX' | 'EXACT';
|
|
85
|
+
field?: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Filter configuration for automatic filtering
|
|
89
|
+
*/
|
|
90
|
+
type TFilterConfig = {
|
|
91
|
+
[key: string]: TFilterConfiguration;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Custom filter configuration
|
|
95
|
+
* Allows defining custom filter functions for specific filter keys
|
|
96
|
+
*/
|
|
97
|
+
type TFilterCustomConfig<T = unknown> = {
|
|
98
|
+
[id: string]: (data: unknown) => TMongoFilterQuery<T>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Variant of TFilterCustomConfig that allows customizing the returned filter shape.
|
|
102
|
+
* Useful for Mongo (operator-based) vs. other ORMs (where clauses) in the future.
|
|
103
|
+
*/
|
|
104
|
+
type TFilterCustomConfigWithFilter<TDoc = unknown, TFilter = TMongoFilterQuery<TDoc>> = {
|
|
105
|
+
[id: string]: (data: unknown) => TFilter;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* React Data Kit server action input
|
|
109
|
+
*/
|
|
110
|
+
type TDataKitInput<T = unknown> = {
|
|
111
|
+
action?: 'FETCH';
|
|
112
|
+
page?: number;
|
|
113
|
+
limit?: number;
|
|
114
|
+
sort?: TSortOptions<T>;
|
|
115
|
+
sorts?: TSortEntry[];
|
|
116
|
+
query?: Record<string, string | number | boolean>;
|
|
117
|
+
filter?: Record<string, string | number | boolean | null>;
|
|
118
|
+
filterConfig?: TFilterConfig;
|
|
119
|
+
filterCustom?: TFilterCustomConfig<T>;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* React Data Kit server action result
|
|
123
|
+
*/
|
|
124
|
+
type TDataKitResult<R> = {
|
|
125
|
+
type: 'ITEMS';
|
|
126
|
+
items: R[];
|
|
127
|
+
documentTotal: number;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Pagination info for client-side use
|
|
131
|
+
*/
|
|
132
|
+
type TPaginationInfo = {
|
|
133
|
+
currentPage: number;
|
|
134
|
+
totalPages: number;
|
|
135
|
+
totalItems: number;
|
|
136
|
+
itemsPerPage: number;
|
|
137
|
+
hasNextPage: boolean;
|
|
138
|
+
hasPrevPage: boolean;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* React Data Kit Adapter Interface
|
|
142
|
+
* Defines the contract for a database adapter.
|
|
143
|
+
*/
|
|
144
|
+
type TDataKitAdapter<T> = (params: Readonly<{
|
|
145
|
+
filter: Record<string, unknown>;
|
|
146
|
+
sorts: TSortEntry[];
|
|
147
|
+
limit: number;
|
|
148
|
+
page: number;
|
|
149
|
+
skip: number;
|
|
150
|
+
input: TDataKitInput<T>;
|
|
151
|
+
}>) => Promise<{
|
|
152
|
+
items: T[];
|
|
153
|
+
total: number;
|
|
154
|
+
}>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* next-data-kit - Hook Types
|
|
158
|
+
*
|
|
159
|
+
* Types for the next-data-kit hooks and state management.
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* React Data Kit controller state
|
|
164
|
+
*/
|
|
165
|
+
type TDataKitState<T = unknown> = {
|
|
166
|
+
page: number;
|
|
167
|
+
limit: number;
|
|
168
|
+
sorts: TSortEntry[];
|
|
169
|
+
filter: Record<string, unknown>;
|
|
170
|
+
filterConfig?: TFilterConfig;
|
|
171
|
+
query?: Record<string, unknown>;
|
|
172
|
+
isLoading: boolean;
|
|
173
|
+
error: Error | null;
|
|
174
|
+
items: T[];
|
|
175
|
+
total: number;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* React Data Kit controller actions
|
|
179
|
+
*/
|
|
180
|
+
type TDataKitActions<T = unknown, R = unknown> = {
|
|
181
|
+
setPage: (page: number) => void;
|
|
182
|
+
setLimit: (limit: number) => void;
|
|
183
|
+
setSort: (path: string, value: 1 | -1 | null, append?: boolean) => void;
|
|
184
|
+
setSorts: (sorts: TSortEntry[]) => void;
|
|
185
|
+
setFilter: (key: string, value: unknown) => void;
|
|
186
|
+
setFilters: (filters: Record<string, unknown>) => void;
|
|
187
|
+
clearFilters: () => void;
|
|
188
|
+
setQuery: (key: string, value: unknown) => void;
|
|
189
|
+
refresh: () => Promise<void>;
|
|
190
|
+
reset: () => void;
|
|
191
|
+
getInput: () => TDataKitInput<T>;
|
|
192
|
+
setItems: (items: R[]) => void;
|
|
193
|
+
setItemAt: (index: number, item: R) => void;
|
|
194
|
+
itemUpdate: (props: {
|
|
195
|
+
index: number;
|
|
196
|
+
data: Partial<R>;
|
|
197
|
+
} | {
|
|
198
|
+
id: string | number;
|
|
199
|
+
data: Partial<R>;
|
|
200
|
+
}) => void;
|
|
201
|
+
deleteItemAt: (index: number) => void;
|
|
202
|
+
itemDelete: (props: {
|
|
203
|
+
index: number;
|
|
204
|
+
} | {
|
|
205
|
+
id: string | number;
|
|
206
|
+
}) => void;
|
|
207
|
+
itemPush: (item: R, position?: 0 | 1) => void;
|
|
208
|
+
deleteBulk: (items: R[]) => void;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Combined next-data-kit controller return type
|
|
212
|
+
*/
|
|
213
|
+
type TUseDataKitReturn<T = unknown, R = unknown> = {
|
|
214
|
+
page: number;
|
|
215
|
+
limit: number;
|
|
216
|
+
sorts: TSortEntry[];
|
|
217
|
+
filter: Record<string, unknown>;
|
|
218
|
+
filterConfig?: TFilterConfig;
|
|
219
|
+
query?: Record<string, unknown>;
|
|
220
|
+
items: R[];
|
|
221
|
+
total: number;
|
|
222
|
+
state: {
|
|
223
|
+
isLoading: boolean;
|
|
224
|
+
error: Error | null;
|
|
225
|
+
hasNextPage: boolean;
|
|
226
|
+
};
|
|
227
|
+
actions: TDataKitActions<T, R>;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Options for the useDataKit hook
|
|
231
|
+
*/
|
|
232
|
+
type TUseDataKitOptions<T = unknown, R = unknown> = {
|
|
233
|
+
initial?: {
|
|
234
|
+
page?: number;
|
|
235
|
+
limit?: number;
|
|
236
|
+
sorts?: TSortEntry[];
|
|
237
|
+
filter?: Record<string, unknown>;
|
|
238
|
+
query?: Record<string, unknown>;
|
|
239
|
+
};
|
|
240
|
+
memory?: 'memory' | 'search-params';
|
|
241
|
+
filters?: {
|
|
242
|
+
id: string;
|
|
243
|
+
configuration?: TFilterConfiguration;
|
|
244
|
+
}[];
|
|
245
|
+
action: (input: TDataKitInput<T>) => Promise<TDataKitResult<R>>;
|
|
246
|
+
onSuccess?: (result: TDataKitResult<R>) => void;
|
|
247
|
+
onError?: (error: Error) => void;
|
|
248
|
+
autoFetch?: boolean;
|
|
249
|
+
debounce?: number;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Column definition for next-data-kit (headless)
|
|
253
|
+
*/
|
|
254
|
+
type TDataKitColumn<T = unknown> = {
|
|
255
|
+
id: string;
|
|
256
|
+
header: string;
|
|
257
|
+
accessor: keyof T | ((item: T) => unknown);
|
|
258
|
+
sortable?: boolean;
|
|
259
|
+
sortPath?: string;
|
|
260
|
+
filterable?: boolean;
|
|
261
|
+
filterKey?: string;
|
|
262
|
+
width?: string | number;
|
|
263
|
+
minWidth?: string | number;
|
|
264
|
+
maxWidth?: string | number;
|
|
265
|
+
align?: 'left' | 'center' | 'right';
|
|
266
|
+
cell?: (value: unknown, item: T, index: number) => React.ReactNode;
|
|
267
|
+
headerCell?: (column: TDataKitColumn<T>) => React.ReactNode;
|
|
268
|
+
hidden?: boolean;
|
|
269
|
+
sticky?: 'left' | 'right';
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* next-data-kit - Selectable Types
|
|
274
|
+
*
|
|
275
|
+
* Types for selectable/multi-select functionality in tables.
|
|
276
|
+
*/
|
|
277
|
+
/**
|
|
278
|
+
* Selection state for a table
|
|
279
|
+
*/
|
|
280
|
+
type TSelectionState<T = string> = {
|
|
281
|
+
selectedIds: Set<T>;
|
|
282
|
+
isAllSelected: boolean;
|
|
283
|
+
isIndeterminate: boolean;
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Selection actions for a table
|
|
287
|
+
*/
|
|
288
|
+
type TSelectionActions<T = string> = {
|
|
289
|
+
select: (id: T) => void;
|
|
290
|
+
deselect: (id: T) => void;
|
|
291
|
+
toggle: (id: T) => void;
|
|
292
|
+
selectAll: (ids: T[]) => void;
|
|
293
|
+
deselectAll: () => void;
|
|
294
|
+
toggleAll: (ids: T[]) => void;
|
|
295
|
+
isSelected: (id: T) => boolean;
|
|
296
|
+
getSelectedArray: () => T[];
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Combined selection hook return type
|
|
300
|
+
*/
|
|
301
|
+
type TUseSelectionReturn<T = string> = TSelectionState<T> & TSelectionActions<T>;
|
|
302
|
+
/**
|
|
303
|
+
* Selection mode for tables
|
|
304
|
+
*/
|
|
305
|
+
type TSelectionMode = 'single' | 'multiple' | 'none';
|
|
306
|
+
/**
|
|
307
|
+
* Selectable item type
|
|
308
|
+
*/
|
|
309
|
+
type TSelectable = {
|
|
310
|
+
id: string;
|
|
311
|
+
selected?: boolean;
|
|
312
|
+
disabled?: boolean;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* next-data-kit - Component Types
|
|
317
|
+
*
|
|
318
|
+
* Types for the React Data Kit component and related UI elements.
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Extract the item type from a TDataKitResult
|
|
323
|
+
*/
|
|
324
|
+
type TExtractDataKitItemFromResult<R> = R extends TDataKitResult<infer I> ? I : R extends {
|
|
325
|
+
items: (infer I)[];
|
|
326
|
+
} ? I : R extends [true, infer Ok] ? (Ok extends {
|
|
327
|
+
items: (infer I)[];
|
|
328
|
+
} ? I : never) : never;
|
|
329
|
+
/**
|
|
330
|
+
* Extract the item type from an action function's return type
|
|
331
|
+
*/
|
|
332
|
+
type TExtractDataKitItemType<T> = T extends (input: TDataKitInput<unknown>) => infer R ? TExtractDataKitItemFromResult<Awaited<R>> : never;
|
|
333
|
+
/**
|
|
334
|
+
* Column definition for React Data Kit component
|
|
335
|
+
*/
|
|
336
|
+
type TDataKitComponentColumn<TItem, TRowState = unknown> = {
|
|
337
|
+
head: React.ReactNode;
|
|
338
|
+
body: (props: Readonly<{
|
|
339
|
+
item: TItem;
|
|
340
|
+
index: number;
|
|
341
|
+
state: TRowState;
|
|
342
|
+
setState: React.Dispatch<React.SetStateAction<TRowState>>;
|
|
343
|
+
setItem: (item: TItem) => void;
|
|
344
|
+
deleteItem: () => void;
|
|
345
|
+
}>) => React.ReactNode;
|
|
346
|
+
sortable?: {
|
|
347
|
+
path: string;
|
|
348
|
+
default: 1 | -1 | 0;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Base filter item properties
|
|
353
|
+
*/
|
|
354
|
+
type TDataKitFilterItemBase = {
|
|
355
|
+
id: string;
|
|
356
|
+
label: string;
|
|
357
|
+
placeholder?: string;
|
|
358
|
+
configuration?: TFilterConfiguration;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Text filter item
|
|
362
|
+
*/
|
|
363
|
+
type TDataKitFilterItemText = TDataKitFilterItemBase & {
|
|
364
|
+
type: 'TEXT';
|
|
365
|
+
defaultValue?: string;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Select filter item - dataset is required
|
|
369
|
+
*/
|
|
370
|
+
type TDataKitFilterItemSelect = TDataKitFilterItemBase & {
|
|
371
|
+
type: 'SELECT';
|
|
372
|
+
dataset: {
|
|
373
|
+
id: string;
|
|
374
|
+
name: string;
|
|
375
|
+
label: string;
|
|
376
|
+
}[];
|
|
377
|
+
defaultValue?: string;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Boolean filter item
|
|
381
|
+
*/
|
|
382
|
+
type TDataKitFilterItemBoolean = TDataKitFilterItemBase & {
|
|
383
|
+
type: 'BOOLEAN';
|
|
384
|
+
defaultValue?: boolean;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Filter item configuration - discriminated union for type safety
|
|
388
|
+
*/
|
|
389
|
+
type TDataKitFilterItem = TDataKitFilterItemText | TDataKitFilterItemSelect | TDataKitFilterItemBoolean;
|
|
390
|
+
/**
|
|
391
|
+
* Bulk action definition for selectable tables
|
|
392
|
+
*/
|
|
393
|
+
type TDataKitBulkAction<TItem> = {
|
|
394
|
+
type: 'SEPARATOR';
|
|
395
|
+
} | {
|
|
396
|
+
type?: 'MENU';
|
|
397
|
+
name: string;
|
|
398
|
+
icon?: React.ReactNode;
|
|
399
|
+
function: (selectedItems: TItem[]) => Promise<[boolean, {
|
|
400
|
+
deselectAll?: boolean;
|
|
401
|
+
updatedItems?: TItem[];
|
|
402
|
+
} | string]>;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Controller ref for external DataKitTable manipulation
|
|
406
|
+
*/
|
|
407
|
+
type TDataKitController<TItem> = {
|
|
408
|
+
itemPush: (item: TItem, position?: 0 | 1) => void;
|
|
409
|
+
itemUpdate: (props: {
|
|
410
|
+
index: number;
|
|
411
|
+
data: Partial<TItem>;
|
|
412
|
+
} | {
|
|
413
|
+
id: string | number;
|
|
414
|
+
data: Partial<TItem>;
|
|
415
|
+
}) => void;
|
|
416
|
+
itemDelete: (props: {
|
|
417
|
+
index: number;
|
|
418
|
+
} | {
|
|
419
|
+
id: string | number;
|
|
420
|
+
}) => void;
|
|
421
|
+
refetchData: () => void;
|
|
422
|
+
deleteBulk: (items: TItem[]) => void;
|
|
423
|
+
getSelectedItems: () => TItem[];
|
|
424
|
+
clearSelection: () => void;
|
|
425
|
+
};
|
|
426
|
+
/**
|
|
427
|
+
* Item with ID for selection purposes
|
|
428
|
+
*/
|
|
429
|
+
type TDataKitSelectableItem = {
|
|
430
|
+
id: string | number;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Memory persistence mode
|
|
434
|
+
*/
|
|
435
|
+
type TDataKitMemoryMode = 'memory' | 'search-params';
|
|
436
|
+
/**
|
|
437
|
+
* DataKit Component Ref Type
|
|
438
|
+
* Exposes the internal state and actions of the DataKit component.
|
|
439
|
+
*/
|
|
440
|
+
type TDataKitRef<T = unknown, R = unknown> = TUseDataKitReturn<T, R>;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* next-data-kit - useDataKit Hook
|
|
444
|
+
*
|
|
445
|
+
* React hook for managing next-data-kit state and actions.
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
declare const useDataKit: <T = unknown, R = unknown>(props: Readonly<TUseDataKitOptions<T, R>>) => TUseDataKitReturn<T, R>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* next-data-kit - useSelection Hook
|
|
452
|
+
*
|
|
453
|
+
* React hook for managing table row selection.
|
|
454
|
+
*/
|
|
455
|
+
|
|
456
|
+
declare const useSelection: <T = string>(initialSelected?: T[]) => TUseSelectionReturn<T>;
|
|
457
|
+
declare const useSelectionWithTotal: <T = string>(totalItems: T[], initialSelected?: T[]) => Omit<TUseSelectionReturn<T>, "toggleAll"> & {
|
|
458
|
+
isAllSelected: boolean;
|
|
459
|
+
isIndeterminate: boolean;
|
|
460
|
+
toggleAll: () => void;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* next-data-kit - usePagination Hook
|
|
465
|
+
*
|
|
466
|
+
* React hook for calculating pagination state.
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
type TUsePaginationReturn = TPaginationInfo & {
|
|
470
|
+
pages: (number | 'ellipsis')[];
|
|
471
|
+
firstPage: number;
|
|
472
|
+
lastPage: number;
|
|
473
|
+
};
|
|
474
|
+
declare const usePagination: (props: Readonly<{
|
|
475
|
+
page: number;
|
|
476
|
+
limit: number;
|
|
477
|
+
total: number;
|
|
478
|
+
siblingCount?: number;
|
|
479
|
+
}>) => TUsePaginationReturn;
|
|
480
|
+
|
|
481
|
+
type TDataKitContextValue<T = unknown, R = unknown> = TUseDataKitReturn<T, R>;
|
|
482
|
+
declare const createDataKitContext: <T = unknown, R = unknown>() => {
|
|
483
|
+
DataKitProvider: (props: Readonly<{
|
|
484
|
+
value: TDataKitContextValue<T, R>;
|
|
485
|
+
children: ReactNode;
|
|
486
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
487
|
+
useDataKitContext: () => TDataKitContextValue<T, R>;
|
|
488
|
+
Context: React$1.Context<TDataKitContextValue<T, R> | null>;
|
|
489
|
+
};
|
|
490
|
+
declare const DefaultDataKitProvider: (props: Readonly<{
|
|
491
|
+
value: TDataKitContextValue<unknown, unknown>;
|
|
492
|
+
children: ReactNode;
|
|
493
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
494
|
+
declare const useDefaultDataKitContext: () => TDataKitContextValue<unknown, unknown>;
|
|
495
|
+
declare const DefaultDataKitContext: React$1.Context<TDataKitContextValue<unknown, unknown> | null>;
|
|
496
|
+
|
|
497
|
+
declare const DataKit: <TAction extends (input: TDataKitInput<unknown>) => Promise<TDataKitResult<TDataKitSelectableItem>>>(props: Readonly<{
|
|
498
|
+
action: TAction;
|
|
499
|
+
query?: Record<string, unknown>;
|
|
500
|
+
filters?: TDataKitFilterItem[];
|
|
501
|
+
limit?: {
|
|
502
|
+
default: number;
|
|
503
|
+
};
|
|
504
|
+
defaultSort?: {
|
|
505
|
+
path: string;
|
|
506
|
+
value: 1 | -1;
|
|
507
|
+
}[];
|
|
508
|
+
className?: string;
|
|
509
|
+
autoFetch?: boolean;
|
|
510
|
+
debounce?: number;
|
|
511
|
+
refetchInterval?: number;
|
|
512
|
+
memory?: TDataKitMemoryMode;
|
|
513
|
+
manual?: boolean;
|
|
514
|
+
pagination?: "SIMPLE" | "NUMBER";
|
|
515
|
+
children: (dataKit: TUseDataKitReturn<unknown, TExtractDataKitItemType<TAction>>) => React__default.ReactNode;
|
|
516
|
+
ref?: React__default.Ref<TDataKitRef<unknown, TExtractDataKitItemType<TAction>>>;
|
|
517
|
+
}>) => React__default.ReactElement;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* next-data-kit - Utility Functions
|
|
521
|
+
*
|
|
522
|
+
* Helper utilities for client-side operations.
|
|
523
|
+
*/
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Get the value from an item using a column accessor
|
|
527
|
+
*/
|
|
528
|
+
declare const getColumnValue: <T>(item: T, column: TDataKitColumn<T>) => unknown;
|
|
529
|
+
/**
|
|
530
|
+
* Get the sort value for a column
|
|
531
|
+
*/
|
|
532
|
+
declare const getSortValue: (sorts: TSortEntry[], path: string) => 1 | -1 | null;
|
|
533
|
+
/**
|
|
534
|
+
* Get the next sort value in the cycle: null -> 1 -> -1 -> null
|
|
535
|
+
*/
|
|
536
|
+
declare const getNextSortValue: (current: 1 | -1 | null) => 1 | -1 | null;
|
|
537
|
+
/**
|
|
538
|
+
* Format a number with commas
|
|
539
|
+
*/
|
|
540
|
+
declare const formatNumber: (num: number) => string;
|
|
541
|
+
/**
|
|
542
|
+
* Debounce a function
|
|
543
|
+
*/
|
|
544
|
+
declare const debounce: <T extends (...args: unknown[]) => unknown>(fn: T, delay: number) => ((...args: Parameters<T>) => void);
|
|
545
|
+
/**
|
|
546
|
+
* Throttle a function
|
|
547
|
+
*/
|
|
548
|
+
declare const throttle: <T extends (...args: unknown[]) => unknown>(fn: T, limit: number) => ((...args: Parameters<T>) => void);
|
|
549
|
+
/**
|
|
550
|
+
* Create a stable object key from sort entries
|
|
551
|
+
*/
|
|
552
|
+
declare const sortEntriesToKey: (sorts: TSortEntry[]) => string;
|
|
553
|
+
/**
|
|
554
|
+
* Parse a sort key back to sort entries
|
|
555
|
+
*/
|
|
556
|
+
declare const keyToSortEntries: (key: string) => TSortEntry[];
|
|
557
|
+
|
|
558
|
+
export { type TSortOrder as A, type TMongoFilterOperators as B, type TMongoRootFilterOperators as C, DefaultDataKitProvider as D, type TSortEntry as E, type TFilterConfig as F, type TFilterCustomConfig as G, type TDataKitState as H, type TDataKitActions as I, type TUseDataKitReturn as J, type TDataKitColumn as K, type TSelectionState as L, type TSelectionActions as M, type TUseSelectionReturn as N, type TSelectionMode as O, type TSelectable as P, type TExtractDataKitItemType as Q, type TDataKitComponentColumn as R, type TDataKitFilterItem as S, type TDataKitInput as T, type TDataKitBulkAction as U, type TDataKitController as V, type TDataKitSelectableItem as W, type TDataKitMemoryMode as X, type TDataKitRef as Y, type TMongoFilterQuery as a, type TFilterCustomConfigWithFilter as b, type TSortOptions as c, type TDataKitAdapter as d, type TDataKitResult as e, type TMongoModel as f, type TPaginationInfo as g, useSelection as h, useSelectionWithTotal as i, usePagination as j, createDataKitContext as k, useDefaultDataKitContext as l, DefaultDataKitContext as m, DataKit as n, getColumnValue as o, getSortValue as p, getNextSortValue as q, formatNumber as r, debounce as s, throttle as t, useDataKit as u, sortEntriesToKey as v, keyToSortEntries as w, type TUseDataKitOptions as x, type TUsePaginationReturn as y, type TDataKitContextValue as z };
|