next-data-kit 9.4.0 → 9.5.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/chunk-5WNOUBGK.js +358 -0
- package/dist/chunk-5WNOUBGK.js.map +1 -0
- package/dist/chunk-CGB4WIAS.cjs +2657 -0
- package/dist/chunk-CGB4WIAS.cjs.map +1 -0
- package/dist/chunk-FDSJZI3C.cjs +369 -0
- package/dist/chunk-FDSJZI3C.cjs.map +1 -0
- package/dist/chunk-WYWJGLGD.js +2613 -0
- package/dist/chunk-WYWJGLGD.js.map +1 -0
- package/dist/client/components/data-kit-infinity.d.ts +1 -0
- package/dist/client/components/data-kit-infinity.d.ts.map +1 -1
- package/dist/client/components/data-kit-table.d.ts +1 -0
- package/dist/client/components/data-kit-table.d.ts.map +1 -1
- package/dist/client/components/data-kit.d.ts +1 -0
- package/dist/client/components/data-kit.d.ts.map +1 -1
- package/dist/client.cjs +75 -2941
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +4 -2
- package/dist/client.d.ts +0 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -2906
- package/dist/client.js.map +1 -1
- package/dist/index-DUVfK8q6.d.ts +284 -0
- package/dist/index-qXbjvUTB.d.cts +284 -0
- package/dist/index.cjs +97 -2898
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -2841
- package/dist/index.js.map +1 -1
- package/dist/internal/hooks.cjs +12 -0
- package/dist/internal/hooks.cjs.map +1 -0
- package/dist/internal/hooks.d.cts +1 -0
- package/dist/internal/hooks.d.ts +1 -0
- package/dist/internal/hooks.js +3 -0
- package/dist/internal/hooks.js.map +1 -0
- package/dist/useDataKit-XFp3_mUc.d.cts +276 -0
- package/dist/useDataKit-XFp3_mUc.d.ts +276 -0
- package/package.json +4 -1
- package/dist/index-CzDzNX62.d.cts +0 -558
- package/dist/index-CzDzNX62.d.ts +0 -558
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { s as TFilterConfiguration, T as TDataKitInput, e as TDataKitResult, q as TUseDataKitReturn, g as TPaginationInfo, r as TDataKitColumn, l as TSortEntry } from './useDataKit-XFp3_mUc.js';
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import React__default, { ReactNode } from 'react';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* next-data-kit - Selectable Types
|
|
8
|
+
*
|
|
9
|
+
* Types for selectable/multi-select functionality in tables.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Selection state for a table
|
|
13
|
+
*/
|
|
14
|
+
type TSelectionState<T = string> = {
|
|
15
|
+
selectedIds: Set<T>;
|
|
16
|
+
isAllSelected: boolean;
|
|
17
|
+
isIndeterminate: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Selection actions for a table
|
|
21
|
+
*/
|
|
22
|
+
type TSelectionActions<T = string> = {
|
|
23
|
+
select: (id: T) => void;
|
|
24
|
+
deselect: (id: T) => void;
|
|
25
|
+
toggle: (id: T) => void;
|
|
26
|
+
selectAll: (ids: T[]) => void;
|
|
27
|
+
deselectAll: () => void;
|
|
28
|
+
toggleAll: (ids: T[]) => void;
|
|
29
|
+
isSelected: (id: T) => boolean;
|
|
30
|
+
getSelectedArray: () => T[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Combined selection hook return type
|
|
34
|
+
*/
|
|
35
|
+
type TUseSelectionReturn<T = string> = TSelectionState<T> & TSelectionActions<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Selection mode for tables
|
|
38
|
+
*/
|
|
39
|
+
type TSelectionMode = 'single' | 'multiple' | 'none';
|
|
40
|
+
/**
|
|
41
|
+
* Selectable item type
|
|
42
|
+
*/
|
|
43
|
+
type TSelectable = {
|
|
44
|
+
id: string;
|
|
45
|
+
selected?: boolean;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* next-data-kit - Component Types
|
|
51
|
+
*
|
|
52
|
+
* Types for the React Data Kit component and related UI elements.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Extract the item type from a TDataKitResult
|
|
57
|
+
*/
|
|
58
|
+
type TExtractDataKitItemFromResult<R> = R extends TDataKitResult<infer I> ? I : R extends {
|
|
59
|
+
items: (infer I)[];
|
|
60
|
+
} ? I : R extends [true, infer Ok] ? (Ok extends {
|
|
61
|
+
items: (infer I)[];
|
|
62
|
+
} ? I : never) : never;
|
|
63
|
+
/**
|
|
64
|
+
* Extract the item type from an action function's return type
|
|
65
|
+
*/
|
|
66
|
+
type TExtractDataKitItemType<T> = T extends (input: TDataKitInput<unknown>) => infer R ? TExtractDataKitItemFromResult<Awaited<R>> : never;
|
|
67
|
+
/**
|
|
68
|
+
* Column definition for React Data Kit component
|
|
69
|
+
*/
|
|
70
|
+
type TDataKitComponentColumn<TItem, TRowState = unknown> = {
|
|
71
|
+
head: React.ReactNode;
|
|
72
|
+
body: (props: Readonly<{
|
|
73
|
+
item: TItem;
|
|
74
|
+
index: number;
|
|
75
|
+
state: TRowState;
|
|
76
|
+
setState: React.Dispatch<React.SetStateAction<TRowState>>;
|
|
77
|
+
setItem: (item: TItem) => void;
|
|
78
|
+
deleteItem: () => void;
|
|
79
|
+
}>) => React.ReactNode;
|
|
80
|
+
sortable?: {
|
|
81
|
+
path: string;
|
|
82
|
+
default: 1 | -1 | 0;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Base filter item properties
|
|
87
|
+
*/
|
|
88
|
+
type TDataKitFilterItemBase = {
|
|
89
|
+
id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
placeholder?: string;
|
|
92
|
+
configuration?: TFilterConfiguration;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Text filter item
|
|
96
|
+
*/
|
|
97
|
+
type TDataKitFilterItemText = TDataKitFilterItemBase & {
|
|
98
|
+
type: 'TEXT';
|
|
99
|
+
defaultValue?: string;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Select filter item - dataset is required
|
|
103
|
+
*/
|
|
104
|
+
type TDataKitFilterItemSelect = TDataKitFilterItemBase & {
|
|
105
|
+
type: 'SELECT';
|
|
106
|
+
dataset: {
|
|
107
|
+
id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
label: string;
|
|
110
|
+
}[];
|
|
111
|
+
defaultValue?: string;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Boolean filter item
|
|
115
|
+
*/
|
|
116
|
+
type TDataKitFilterItemBoolean = TDataKitFilterItemBase & {
|
|
117
|
+
type: 'BOOLEAN';
|
|
118
|
+
defaultValue?: boolean;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Filter item configuration - discriminated union for type safety
|
|
122
|
+
*/
|
|
123
|
+
type TDataKitFilterItem = TDataKitFilterItemText | TDataKitFilterItemSelect | TDataKitFilterItemBoolean;
|
|
124
|
+
/**
|
|
125
|
+
* Bulk action definition for selectable tables
|
|
126
|
+
*/
|
|
127
|
+
type TDataKitBulkAction<TItem> = {
|
|
128
|
+
type: 'SEPARATOR';
|
|
129
|
+
} | {
|
|
130
|
+
type?: 'MENU';
|
|
131
|
+
name: string;
|
|
132
|
+
icon?: React.ReactNode;
|
|
133
|
+
function: (selectedItems: TItem[]) => Promise<[boolean, {
|
|
134
|
+
deselectAll?: boolean;
|
|
135
|
+
updatedItems?: TItem[];
|
|
136
|
+
} | string]>;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Controller ref for external DataKitTable manipulation
|
|
140
|
+
*/
|
|
141
|
+
type TDataKitController<TItem> = {
|
|
142
|
+
itemPush: (item: TItem, position?: 0 | 1) => void;
|
|
143
|
+
itemUpdate: (props: {
|
|
144
|
+
index: number;
|
|
145
|
+
data: Partial<TItem>;
|
|
146
|
+
} | {
|
|
147
|
+
id: string | number;
|
|
148
|
+
data: Partial<TItem>;
|
|
149
|
+
}) => void;
|
|
150
|
+
itemDelete: (props: {
|
|
151
|
+
index: number;
|
|
152
|
+
} | {
|
|
153
|
+
id: string | number;
|
|
154
|
+
}) => void;
|
|
155
|
+
refetchData: () => void;
|
|
156
|
+
deleteBulk: (items: TItem[]) => void;
|
|
157
|
+
getSelectedItems: () => TItem[];
|
|
158
|
+
clearSelection: () => void;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Item with ID for selection purposes
|
|
162
|
+
*/
|
|
163
|
+
type TDataKitSelectableItem = {
|
|
164
|
+
id: string | number;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Memory persistence mode
|
|
168
|
+
*/
|
|
169
|
+
type TDataKitMemoryMode = 'memory' | 'search-params';
|
|
170
|
+
/**
|
|
171
|
+
* DataKit Component Ref Type
|
|
172
|
+
* Exposes the internal state and actions of the DataKit component.
|
|
173
|
+
*/
|
|
174
|
+
type TDataKitRef<T = unknown, R = unknown> = TUseDataKitReturn<T, R>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* next-data-kit - useSelection Hook
|
|
178
|
+
*
|
|
179
|
+
* React hook for managing table row selection.
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
declare const useSelection: <T = string>(initialSelected?: T[]) => TUseSelectionReturn<T>;
|
|
183
|
+
declare const useSelectionWithTotal: <T = string>(totalItems: T[], initialSelected?: T[]) => Omit<TUseSelectionReturn<T>, "toggleAll"> & {
|
|
184
|
+
isAllSelected: boolean;
|
|
185
|
+
isIndeterminate: boolean;
|
|
186
|
+
toggleAll: () => void;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* next-data-kit - usePagination Hook
|
|
191
|
+
*
|
|
192
|
+
* React hook for calculating pagination state.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
type TUsePaginationReturn = TPaginationInfo & {
|
|
196
|
+
pages: (number | 'ellipsis')[];
|
|
197
|
+
firstPage: number;
|
|
198
|
+
lastPage: number;
|
|
199
|
+
};
|
|
200
|
+
declare const usePagination: (props: Readonly<{
|
|
201
|
+
page: number;
|
|
202
|
+
limit: number;
|
|
203
|
+
total: number;
|
|
204
|
+
siblingCount?: number;
|
|
205
|
+
}>) => TUsePaginationReturn;
|
|
206
|
+
|
|
207
|
+
type TDataKitContextValue<T = unknown, R = unknown> = TUseDataKitReturn<T, R>;
|
|
208
|
+
declare const createDataKitContext: <T = unknown, R = unknown>() => {
|
|
209
|
+
DataKitProvider: (props: Readonly<{
|
|
210
|
+
value: TDataKitContextValue<T, R>;
|
|
211
|
+
children: ReactNode;
|
|
212
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
213
|
+
useDataKitContext: () => TDataKitContextValue<T, R>;
|
|
214
|
+
Context: React$1.Context<TDataKitContextValue<T, R> | null>;
|
|
215
|
+
};
|
|
216
|
+
declare const DefaultDataKitProvider: (props: Readonly<{
|
|
217
|
+
value: TDataKitContextValue<unknown, unknown>;
|
|
218
|
+
children: ReactNode;
|
|
219
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
220
|
+
declare const useDefaultDataKitContext: () => TDataKitContextValue<unknown, unknown>;
|
|
221
|
+
declare const DefaultDataKitContext: React$1.Context<TDataKitContextValue<unknown, unknown> | null>;
|
|
222
|
+
|
|
223
|
+
declare const DataKit: <TAction extends (input: TDataKitInput<unknown>) => Promise<TDataKitResult<TDataKitSelectableItem>>>(props: Readonly<{
|
|
224
|
+
action: TAction;
|
|
225
|
+
query?: Record<string, unknown>;
|
|
226
|
+
filters?: TDataKitFilterItem[];
|
|
227
|
+
limit?: {
|
|
228
|
+
default: number;
|
|
229
|
+
};
|
|
230
|
+
defaultSort?: {
|
|
231
|
+
path: string;
|
|
232
|
+
value: 1 | -1;
|
|
233
|
+
}[];
|
|
234
|
+
className?: string;
|
|
235
|
+
autoFetch?: boolean;
|
|
236
|
+
debounce?: number;
|
|
237
|
+
refetchInterval?: number;
|
|
238
|
+
memory?: TDataKitMemoryMode;
|
|
239
|
+
manual?: boolean;
|
|
240
|
+
pagination?: "SIMPLE" | "NUMBER";
|
|
241
|
+
children: (dataKit: TUseDataKitReturn<unknown, TExtractDataKitItemType<TAction>>) => React__default.ReactNode;
|
|
242
|
+
ref?: React__default.Ref<TDataKitRef<unknown, TExtractDataKitItemType<TAction>>>;
|
|
243
|
+
}>) => React__default.ReactElement;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* next-data-kit - Utility Functions
|
|
247
|
+
*
|
|
248
|
+
* Helper utilities for client-side operations.
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Get the value from an item using a column accessor
|
|
253
|
+
*/
|
|
254
|
+
declare const getColumnValue: <T>(item: T, column: TDataKitColumn<T>) => unknown;
|
|
255
|
+
/**
|
|
256
|
+
* Get the sort value for a column
|
|
257
|
+
*/
|
|
258
|
+
declare const getSortValue: (sorts: TSortEntry[], path: string) => 1 | -1 | null;
|
|
259
|
+
/**
|
|
260
|
+
* Get the next sort value in the cycle: null -> 1 -> -1 -> null
|
|
261
|
+
*/
|
|
262
|
+
declare const getNextSortValue: (current: 1 | -1 | null) => 1 | -1 | null;
|
|
263
|
+
/**
|
|
264
|
+
* Format a number with commas
|
|
265
|
+
*/
|
|
266
|
+
declare const formatNumber: (num: number) => string;
|
|
267
|
+
/**
|
|
268
|
+
* Debounce a function
|
|
269
|
+
*/
|
|
270
|
+
declare const debounce: <T extends (...args: unknown[]) => unknown>(fn: T, delay: number) => ((...args: Parameters<T>) => void);
|
|
271
|
+
/**
|
|
272
|
+
* Throttle a function
|
|
273
|
+
*/
|
|
274
|
+
declare const throttle: <T extends (...args: unknown[]) => unknown>(fn: T, limit: number) => ((...args: Parameters<T>) => void);
|
|
275
|
+
/**
|
|
276
|
+
* Create a stable object key from sort entries
|
|
277
|
+
*/
|
|
278
|
+
declare const sortEntriesToKey: (sorts: TSortEntry[]) => string;
|
|
279
|
+
/**
|
|
280
|
+
* Parse a sort key back to sort entries
|
|
281
|
+
*/
|
|
282
|
+
declare const keyToSortEntries: (key: string) => TSortEntry[];
|
|
283
|
+
|
|
284
|
+
export { type TDataKitSelectableItem as A, type TDataKitMemoryMode as B, type TDataKitRef as C, DefaultDataKitProvider as D, type TUsePaginationReturn as T, useSelectionWithTotal as a, usePagination as b, createDataKitContext as c, useDefaultDataKitContext as d, DefaultDataKitContext as e, DataKit as f, getColumnValue as g, getSortValue as h, getNextSortValue as i, formatNumber as j, debounce as k, keyToSortEntries as l, type TDataKitContextValue as m, type TSelectionState as n, type TSelectionActions as o, type TUseSelectionReturn as p, type TSelectionMode as q, type TSelectable as r, sortEntriesToKey as s, throttle as t, useSelection as u, type TExtractDataKitItemType as v, type TDataKitComponentColumn as w, type TDataKitFilterItem as x, type TDataKitBulkAction as y, type TDataKitController as z };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { s as TFilterConfiguration, T as TDataKitInput, e as TDataKitResult, q as TUseDataKitReturn, g as TPaginationInfo, r as TDataKitColumn, l as TSortEntry } from './useDataKit-XFp3_mUc.cjs';
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import React__default, { ReactNode } from 'react';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* next-data-kit - Selectable Types
|
|
8
|
+
*
|
|
9
|
+
* Types for selectable/multi-select functionality in tables.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Selection state for a table
|
|
13
|
+
*/
|
|
14
|
+
type TSelectionState<T = string> = {
|
|
15
|
+
selectedIds: Set<T>;
|
|
16
|
+
isAllSelected: boolean;
|
|
17
|
+
isIndeterminate: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Selection actions for a table
|
|
21
|
+
*/
|
|
22
|
+
type TSelectionActions<T = string> = {
|
|
23
|
+
select: (id: T) => void;
|
|
24
|
+
deselect: (id: T) => void;
|
|
25
|
+
toggle: (id: T) => void;
|
|
26
|
+
selectAll: (ids: T[]) => void;
|
|
27
|
+
deselectAll: () => void;
|
|
28
|
+
toggleAll: (ids: T[]) => void;
|
|
29
|
+
isSelected: (id: T) => boolean;
|
|
30
|
+
getSelectedArray: () => T[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Combined selection hook return type
|
|
34
|
+
*/
|
|
35
|
+
type TUseSelectionReturn<T = string> = TSelectionState<T> & TSelectionActions<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Selection mode for tables
|
|
38
|
+
*/
|
|
39
|
+
type TSelectionMode = 'single' | 'multiple' | 'none';
|
|
40
|
+
/**
|
|
41
|
+
* Selectable item type
|
|
42
|
+
*/
|
|
43
|
+
type TSelectable = {
|
|
44
|
+
id: string;
|
|
45
|
+
selected?: boolean;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* next-data-kit - Component Types
|
|
51
|
+
*
|
|
52
|
+
* Types for the React Data Kit component and related UI elements.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Extract the item type from a TDataKitResult
|
|
57
|
+
*/
|
|
58
|
+
type TExtractDataKitItemFromResult<R> = R extends TDataKitResult<infer I> ? I : R extends {
|
|
59
|
+
items: (infer I)[];
|
|
60
|
+
} ? I : R extends [true, infer Ok] ? (Ok extends {
|
|
61
|
+
items: (infer I)[];
|
|
62
|
+
} ? I : never) : never;
|
|
63
|
+
/**
|
|
64
|
+
* Extract the item type from an action function's return type
|
|
65
|
+
*/
|
|
66
|
+
type TExtractDataKitItemType<T> = T extends (input: TDataKitInput<unknown>) => infer R ? TExtractDataKitItemFromResult<Awaited<R>> : never;
|
|
67
|
+
/**
|
|
68
|
+
* Column definition for React Data Kit component
|
|
69
|
+
*/
|
|
70
|
+
type TDataKitComponentColumn<TItem, TRowState = unknown> = {
|
|
71
|
+
head: React.ReactNode;
|
|
72
|
+
body: (props: Readonly<{
|
|
73
|
+
item: TItem;
|
|
74
|
+
index: number;
|
|
75
|
+
state: TRowState;
|
|
76
|
+
setState: React.Dispatch<React.SetStateAction<TRowState>>;
|
|
77
|
+
setItem: (item: TItem) => void;
|
|
78
|
+
deleteItem: () => void;
|
|
79
|
+
}>) => React.ReactNode;
|
|
80
|
+
sortable?: {
|
|
81
|
+
path: string;
|
|
82
|
+
default: 1 | -1 | 0;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Base filter item properties
|
|
87
|
+
*/
|
|
88
|
+
type TDataKitFilterItemBase = {
|
|
89
|
+
id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
placeholder?: string;
|
|
92
|
+
configuration?: TFilterConfiguration;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Text filter item
|
|
96
|
+
*/
|
|
97
|
+
type TDataKitFilterItemText = TDataKitFilterItemBase & {
|
|
98
|
+
type: 'TEXT';
|
|
99
|
+
defaultValue?: string;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Select filter item - dataset is required
|
|
103
|
+
*/
|
|
104
|
+
type TDataKitFilterItemSelect = TDataKitFilterItemBase & {
|
|
105
|
+
type: 'SELECT';
|
|
106
|
+
dataset: {
|
|
107
|
+
id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
label: string;
|
|
110
|
+
}[];
|
|
111
|
+
defaultValue?: string;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Boolean filter item
|
|
115
|
+
*/
|
|
116
|
+
type TDataKitFilterItemBoolean = TDataKitFilterItemBase & {
|
|
117
|
+
type: 'BOOLEAN';
|
|
118
|
+
defaultValue?: boolean;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Filter item configuration - discriminated union for type safety
|
|
122
|
+
*/
|
|
123
|
+
type TDataKitFilterItem = TDataKitFilterItemText | TDataKitFilterItemSelect | TDataKitFilterItemBoolean;
|
|
124
|
+
/**
|
|
125
|
+
* Bulk action definition for selectable tables
|
|
126
|
+
*/
|
|
127
|
+
type TDataKitBulkAction<TItem> = {
|
|
128
|
+
type: 'SEPARATOR';
|
|
129
|
+
} | {
|
|
130
|
+
type?: 'MENU';
|
|
131
|
+
name: string;
|
|
132
|
+
icon?: React.ReactNode;
|
|
133
|
+
function: (selectedItems: TItem[]) => Promise<[boolean, {
|
|
134
|
+
deselectAll?: boolean;
|
|
135
|
+
updatedItems?: TItem[];
|
|
136
|
+
} | string]>;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Controller ref for external DataKitTable manipulation
|
|
140
|
+
*/
|
|
141
|
+
type TDataKitController<TItem> = {
|
|
142
|
+
itemPush: (item: TItem, position?: 0 | 1) => void;
|
|
143
|
+
itemUpdate: (props: {
|
|
144
|
+
index: number;
|
|
145
|
+
data: Partial<TItem>;
|
|
146
|
+
} | {
|
|
147
|
+
id: string | number;
|
|
148
|
+
data: Partial<TItem>;
|
|
149
|
+
}) => void;
|
|
150
|
+
itemDelete: (props: {
|
|
151
|
+
index: number;
|
|
152
|
+
} | {
|
|
153
|
+
id: string | number;
|
|
154
|
+
}) => void;
|
|
155
|
+
refetchData: () => void;
|
|
156
|
+
deleteBulk: (items: TItem[]) => void;
|
|
157
|
+
getSelectedItems: () => TItem[];
|
|
158
|
+
clearSelection: () => void;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Item with ID for selection purposes
|
|
162
|
+
*/
|
|
163
|
+
type TDataKitSelectableItem = {
|
|
164
|
+
id: string | number;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Memory persistence mode
|
|
168
|
+
*/
|
|
169
|
+
type TDataKitMemoryMode = 'memory' | 'search-params';
|
|
170
|
+
/**
|
|
171
|
+
* DataKit Component Ref Type
|
|
172
|
+
* Exposes the internal state and actions of the DataKit component.
|
|
173
|
+
*/
|
|
174
|
+
type TDataKitRef<T = unknown, R = unknown> = TUseDataKitReturn<T, R>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* next-data-kit - useSelection Hook
|
|
178
|
+
*
|
|
179
|
+
* React hook for managing table row selection.
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
declare const useSelection: <T = string>(initialSelected?: T[]) => TUseSelectionReturn<T>;
|
|
183
|
+
declare const useSelectionWithTotal: <T = string>(totalItems: T[], initialSelected?: T[]) => Omit<TUseSelectionReturn<T>, "toggleAll"> & {
|
|
184
|
+
isAllSelected: boolean;
|
|
185
|
+
isIndeterminate: boolean;
|
|
186
|
+
toggleAll: () => void;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* next-data-kit - usePagination Hook
|
|
191
|
+
*
|
|
192
|
+
* React hook for calculating pagination state.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
type TUsePaginationReturn = TPaginationInfo & {
|
|
196
|
+
pages: (number | 'ellipsis')[];
|
|
197
|
+
firstPage: number;
|
|
198
|
+
lastPage: number;
|
|
199
|
+
};
|
|
200
|
+
declare const usePagination: (props: Readonly<{
|
|
201
|
+
page: number;
|
|
202
|
+
limit: number;
|
|
203
|
+
total: number;
|
|
204
|
+
siblingCount?: number;
|
|
205
|
+
}>) => TUsePaginationReturn;
|
|
206
|
+
|
|
207
|
+
type TDataKitContextValue<T = unknown, R = unknown> = TUseDataKitReturn<T, R>;
|
|
208
|
+
declare const createDataKitContext: <T = unknown, R = unknown>() => {
|
|
209
|
+
DataKitProvider: (props: Readonly<{
|
|
210
|
+
value: TDataKitContextValue<T, R>;
|
|
211
|
+
children: ReactNode;
|
|
212
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
213
|
+
useDataKitContext: () => TDataKitContextValue<T, R>;
|
|
214
|
+
Context: React$1.Context<TDataKitContextValue<T, R> | null>;
|
|
215
|
+
};
|
|
216
|
+
declare const DefaultDataKitProvider: (props: Readonly<{
|
|
217
|
+
value: TDataKitContextValue<unknown, unknown>;
|
|
218
|
+
children: ReactNode;
|
|
219
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
220
|
+
declare const useDefaultDataKitContext: () => TDataKitContextValue<unknown, unknown>;
|
|
221
|
+
declare const DefaultDataKitContext: React$1.Context<TDataKitContextValue<unknown, unknown> | null>;
|
|
222
|
+
|
|
223
|
+
declare const DataKit: <TAction extends (input: TDataKitInput<unknown>) => Promise<TDataKitResult<TDataKitSelectableItem>>>(props: Readonly<{
|
|
224
|
+
action: TAction;
|
|
225
|
+
query?: Record<string, unknown>;
|
|
226
|
+
filters?: TDataKitFilterItem[];
|
|
227
|
+
limit?: {
|
|
228
|
+
default: number;
|
|
229
|
+
};
|
|
230
|
+
defaultSort?: {
|
|
231
|
+
path: string;
|
|
232
|
+
value: 1 | -1;
|
|
233
|
+
}[];
|
|
234
|
+
className?: string;
|
|
235
|
+
autoFetch?: boolean;
|
|
236
|
+
debounce?: number;
|
|
237
|
+
refetchInterval?: number;
|
|
238
|
+
memory?: TDataKitMemoryMode;
|
|
239
|
+
manual?: boolean;
|
|
240
|
+
pagination?: "SIMPLE" | "NUMBER";
|
|
241
|
+
children: (dataKit: TUseDataKitReturn<unknown, TExtractDataKitItemType<TAction>>) => React__default.ReactNode;
|
|
242
|
+
ref?: React__default.Ref<TDataKitRef<unknown, TExtractDataKitItemType<TAction>>>;
|
|
243
|
+
}>) => React__default.ReactElement;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* next-data-kit - Utility Functions
|
|
247
|
+
*
|
|
248
|
+
* Helper utilities for client-side operations.
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Get the value from an item using a column accessor
|
|
253
|
+
*/
|
|
254
|
+
declare const getColumnValue: <T>(item: T, column: TDataKitColumn<T>) => unknown;
|
|
255
|
+
/**
|
|
256
|
+
* Get the sort value for a column
|
|
257
|
+
*/
|
|
258
|
+
declare const getSortValue: (sorts: TSortEntry[], path: string) => 1 | -1 | null;
|
|
259
|
+
/**
|
|
260
|
+
* Get the next sort value in the cycle: null -> 1 -> -1 -> null
|
|
261
|
+
*/
|
|
262
|
+
declare const getNextSortValue: (current: 1 | -1 | null) => 1 | -1 | null;
|
|
263
|
+
/**
|
|
264
|
+
* Format a number with commas
|
|
265
|
+
*/
|
|
266
|
+
declare const formatNumber: (num: number) => string;
|
|
267
|
+
/**
|
|
268
|
+
* Debounce a function
|
|
269
|
+
*/
|
|
270
|
+
declare const debounce: <T extends (...args: unknown[]) => unknown>(fn: T, delay: number) => ((...args: Parameters<T>) => void);
|
|
271
|
+
/**
|
|
272
|
+
* Throttle a function
|
|
273
|
+
*/
|
|
274
|
+
declare const throttle: <T extends (...args: unknown[]) => unknown>(fn: T, limit: number) => ((...args: Parameters<T>) => void);
|
|
275
|
+
/**
|
|
276
|
+
* Create a stable object key from sort entries
|
|
277
|
+
*/
|
|
278
|
+
declare const sortEntriesToKey: (sorts: TSortEntry[]) => string;
|
|
279
|
+
/**
|
|
280
|
+
* Parse a sort key back to sort entries
|
|
281
|
+
*/
|
|
282
|
+
declare const keyToSortEntries: (key: string) => TSortEntry[];
|
|
283
|
+
|
|
284
|
+
export { type TDataKitSelectableItem as A, type TDataKitMemoryMode as B, type TDataKitRef as C, DefaultDataKitProvider as D, type TUsePaginationReturn as T, useSelectionWithTotal as a, usePagination as b, createDataKitContext as c, useDefaultDataKitContext as d, DefaultDataKitContext as e, DataKit as f, getColumnValue as g, getSortValue as h, getNextSortValue as i, formatNumber as j, debounce as k, keyToSortEntries as l, type TDataKitContextValue as m, type TSelectionState as n, type TSelectionActions as o, type TUseSelectionReturn as p, type TSelectionMode as q, type TSelectable as r, sortEntriesToKey as s, throttle as t, useSelection as u, type TExtractDataKitItemType as v, type TDataKitComponentColumn as w, type TDataKitFilterItem as x, type TDataKitBulkAction as y, type TDataKitController as z };
|