@honed/table 0.1.0 → 0.2.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/index.d.ts +378 -0
- package/dist/index.es.js +434 -305
- package/dist/index.umd.js +1 -1
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,379 @@
|
|
|
1
|
+
import { BindingOptions } from '@honed/refine';
|
|
2
|
+
import { BooleanFilterRefiner } from '@honed/refine';
|
|
3
|
+
import { BulkAction } from '@honed/action';
|
|
4
|
+
import { BulkSelection } from '@honed/action';
|
|
5
|
+
import { Config as Config_2 } from '@honed/refine';
|
|
6
|
+
import { Confirm } from '@honed/action';
|
|
7
|
+
import { DateFilterRefiner } from '@honed/refine';
|
|
8
|
+
import { Direction } from '@honed/refine';
|
|
9
|
+
import { FilterRefiner } from '@honed/refine';
|
|
10
|
+
import { FilterValue } from '@honed/refine';
|
|
11
|
+
import { InlineAction } from '@honed/action';
|
|
12
|
+
import { Option as Option_2 } from '@honed/refine';
|
|
13
|
+
import { PageAction } from '@honed/action';
|
|
14
|
+
import { PromisifyFn } from '@vueuse/shared';
|
|
15
|
+
import { Refine } from '@honed/refine';
|
|
16
|
+
import { Route } from '@honed/action';
|
|
17
|
+
import { Search } from '@honed/refine';
|
|
18
|
+
import { SetFilterRefiner } from '@honed/refine';
|
|
19
|
+
import { Sort } from '@honed/refine';
|
|
20
|
+
import { Visit } from '@inertiajs/core';
|
|
21
|
+
import { VisitCallbacks } from '@inertiajs/core';
|
|
22
|
+
import { VisitOptions } from '@inertiajs/core';
|
|
23
|
+
|
|
24
|
+
export declare interface CollectionPaginator {
|
|
25
|
+
empty: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare interface Column<T extends Record<string, any>> {
|
|
29
|
+
name: keyof T;
|
|
30
|
+
label: string;
|
|
31
|
+
type: "text" | "number" | "date" | "boolean" | string;
|
|
32
|
+
hidden: boolean;
|
|
33
|
+
active: boolean;
|
|
34
|
+
toggleable: boolean;
|
|
35
|
+
icon?: string;
|
|
36
|
+
class?: string;
|
|
37
|
+
meta?: Record<string, any>;
|
|
38
|
+
sort?: {
|
|
39
|
+
active: boolean;
|
|
40
|
+
direction: Direction;
|
|
41
|
+
next: string | null;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare interface Config extends Config_2 {
|
|
46
|
+
endpoint: string;
|
|
47
|
+
record: string;
|
|
48
|
+
records: string;
|
|
49
|
+
columns: string;
|
|
50
|
+
pages: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare interface CursorPaginator extends CollectionPaginator {
|
|
54
|
+
prevLink: string | null;
|
|
55
|
+
nextLink: string | null;
|
|
56
|
+
perPage: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare type Identifier = string | number;
|
|
60
|
+
|
|
61
|
+
export declare interface LengthAwarePaginator extends SimplePaginator {
|
|
62
|
+
total: number;
|
|
63
|
+
from: number;
|
|
64
|
+
to: number;
|
|
65
|
+
firstLink: string | null;
|
|
66
|
+
lastLink: string | null;
|
|
67
|
+
links: PaginatorLink[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare type PaginatorKind = "cursor" | "length-aware" | "simple" | "collection";
|
|
71
|
+
|
|
72
|
+
export declare interface PaginatorLink {
|
|
73
|
+
url: string | null;
|
|
74
|
+
label: string;
|
|
75
|
+
active: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export declare interface PerPageRecord {
|
|
79
|
+
value: number;
|
|
80
|
+
active: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export declare interface SimplePaginator extends CursorPaginator {
|
|
84
|
+
currentPage: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare interface Table<T extends Record<string, any> = any, U extends PaginatorKind = "length-aware"> extends Refine {
|
|
88
|
+
id: string;
|
|
89
|
+
records: T[] & {
|
|
90
|
+
actions: InlineAction[];
|
|
91
|
+
};
|
|
92
|
+
paginator: U extends "length-aware" ? LengthAwarePaginator : U extends "simple" ? SimplePaginator : U extends "cursor" ? CursorPaginator : CollectionPaginator;
|
|
93
|
+
columns?: Column<T>[];
|
|
94
|
+
recordsPerPage: PerPageRecord[];
|
|
95
|
+
toggleable: boolean;
|
|
96
|
+
actions: {
|
|
97
|
+
hasInline: boolean;
|
|
98
|
+
bulk: BulkAction[];
|
|
99
|
+
page: PageAction[];
|
|
100
|
+
};
|
|
101
|
+
config: Config;
|
|
102
|
+
meta: Record<string, any>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export declare interface TableOptions<T extends Record<string, any>> {
|
|
106
|
+
/**
|
|
107
|
+
* Actions to be applied on a record in JavaScript.
|
|
108
|
+
*/
|
|
109
|
+
recordActions?: Record<string, (record: T) => void>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export declare function useTable<T extends object, K extends T[keyof T] extends Refine ? keyof T : never, U extends Record<string, any> = any, V extends "cursor" | "length-aware" | "simple" | "collection" = "length-aware">(props: T, key: K, tableOptions?: TableOptions<U>, defaultOptions?: VisitOptions): {
|
|
113
|
+
filters: ({
|
|
114
|
+
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
115
|
+
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
116
|
+
bind: () => {
|
|
117
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
118
|
+
modelValue: unknown;
|
|
119
|
+
value: unknown;
|
|
120
|
+
} | undefined;
|
|
121
|
+
type: string;
|
|
122
|
+
value: FilterValue;
|
|
123
|
+
name: string;
|
|
124
|
+
label: string;
|
|
125
|
+
active: boolean;
|
|
126
|
+
meta: Record<string, any>;
|
|
127
|
+
} | {
|
|
128
|
+
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
129
|
+
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
130
|
+
bind: () => {
|
|
131
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
132
|
+
modelValue: unknown;
|
|
133
|
+
value: unknown;
|
|
134
|
+
} | undefined;
|
|
135
|
+
type: "set";
|
|
136
|
+
multiple: boolean;
|
|
137
|
+
options: Option_2[];
|
|
138
|
+
value: FilterValue;
|
|
139
|
+
name: string;
|
|
140
|
+
label: string;
|
|
141
|
+
active: boolean;
|
|
142
|
+
meta: Record<string, any>;
|
|
143
|
+
} | {
|
|
144
|
+
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
145
|
+
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
146
|
+
bind: () => {
|
|
147
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
148
|
+
modelValue: unknown;
|
|
149
|
+
value: unknown;
|
|
150
|
+
} | undefined;
|
|
151
|
+
type: "date";
|
|
152
|
+
value: string;
|
|
153
|
+
name: string;
|
|
154
|
+
label: string;
|
|
155
|
+
active: boolean;
|
|
156
|
+
meta: Record<string, any>;
|
|
157
|
+
} | {
|
|
158
|
+
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
159
|
+
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
160
|
+
bind: () => {
|
|
161
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
162
|
+
modelValue: unknown;
|
|
163
|
+
value: unknown;
|
|
164
|
+
} | undefined;
|
|
165
|
+
type: "boolean";
|
|
166
|
+
value: boolean;
|
|
167
|
+
name: string;
|
|
168
|
+
label: string;
|
|
169
|
+
active: boolean;
|
|
170
|
+
meta: Record<string, any>;
|
|
171
|
+
})[];
|
|
172
|
+
sorts: {
|
|
173
|
+
apply: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
174
|
+
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
175
|
+
bind: () => {
|
|
176
|
+
onClick: PromisifyFn<() => void>;
|
|
177
|
+
} | undefined;
|
|
178
|
+
type: string;
|
|
179
|
+
direction: Direction;
|
|
180
|
+
next: string | null;
|
|
181
|
+
name: string;
|
|
182
|
+
label: string; /** The actions available for the record */
|
|
183
|
+
active: boolean;
|
|
184
|
+
meta: Record<string, any>;
|
|
185
|
+
}[];
|
|
186
|
+
searches: {
|
|
187
|
+
apply: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
188
|
+
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
189
|
+
bind: () => {
|
|
190
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
191
|
+
modelValue: boolean;
|
|
192
|
+
value: boolean;
|
|
193
|
+
} | undefined; /** Deselects this record */
|
|
194
|
+
name: string;
|
|
195
|
+
label: string;
|
|
196
|
+
type: string;
|
|
197
|
+
active: boolean;
|
|
198
|
+
meta: Record<string, any>;
|
|
199
|
+
}[] | undefined;
|
|
200
|
+
getFilter: (name: string) => (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner) | undefined;
|
|
201
|
+
getSort: (name: string, direction?: Direction | undefined) => Sort | undefined;
|
|
202
|
+
getSearch: (name: string) => Search | undefined;
|
|
203
|
+
currentFilters: () => FilterRefiner[];
|
|
204
|
+
currentSort: () => Sort | undefined;
|
|
205
|
+
currentSearches: () => Search[];
|
|
206
|
+
isFiltering: (name?: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner) | undefined) => boolean;
|
|
207
|
+
isSorting: (name?: string | Sort | undefined) => boolean;
|
|
208
|
+
isSearching: (name?: string | Search | undefined) => boolean;
|
|
209
|
+
apply: (values: Record<string, any>, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
210
|
+
applyFilter: (filter: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner), value: any, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
211
|
+
applySort: (sort: string | Sort, direction?: Direction | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
212
|
+
applySearch: (value: string | null | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
213
|
+
applyMatch: (value: string | Search, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
214
|
+
clearFilter: (filter: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner), options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
215
|
+
clearSort: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
216
|
+
clearSearch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
217
|
+
clearMatch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
218
|
+
reset: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
219
|
+
bindFilter: <T_1 extends unknown>(filter: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner), options?: BindingOptions | undefined) => {
|
|
220
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
221
|
+
modelValue: T_1;
|
|
222
|
+
value: T_1;
|
|
223
|
+
} | undefined;
|
|
224
|
+
bindSort: (sort: string | Sort, options?: BindingOptions | undefined) => {
|
|
225
|
+
onClick: PromisifyFn<() => void>;
|
|
226
|
+
} | undefined;
|
|
227
|
+
bindSearch: (options?: BindingOptions | undefined) => {
|
|
228
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
229
|
+
modelValue: string;
|
|
230
|
+
value: string;
|
|
231
|
+
};
|
|
232
|
+
bindMatch: (match: string | Search, options?: BindingOptions | undefined) => {
|
|
233
|
+
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
234
|
+
modelValue: boolean;
|
|
235
|
+
value: boolean;
|
|
236
|
+
} | undefined;
|
|
237
|
+
stringValue: (value: any) => any;
|
|
238
|
+
omitValue: (value: any) => any;
|
|
239
|
+
toggleValue: (value: any, values: any) => any;
|
|
240
|
+
delimitArray: (value: any) => any;
|
|
241
|
+
getRecordKey: (record: U) => Identifier;
|
|
242
|
+
meta: Record<string, any>;
|
|
243
|
+
headings: {
|
|
244
|
+
isSorting: boolean | undefined;
|
|
245
|
+
toggleSort: (options?: VisitOptions) => void;
|
|
246
|
+
name: keyof U;
|
|
247
|
+
label: string;
|
|
248
|
+
type: string;
|
|
249
|
+
hidden: boolean;
|
|
250
|
+
active: boolean;
|
|
251
|
+
toggleable: boolean;
|
|
252
|
+
icon?: string | undefined;
|
|
253
|
+
class?: string | undefined;
|
|
254
|
+
meta?: Record<string, any> | undefined;
|
|
255
|
+
sort?: {
|
|
256
|
+
active: boolean;
|
|
257
|
+
direction: Direction;
|
|
258
|
+
next: string | null;
|
|
259
|
+
} | undefined;
|
|
260
|
+
}[];
|
|
261
|
+
columns: {
|
|
262
|
+
toggle: (options?: VisitOptions) => void;
|
|
263
|
+
name: keyof U;
|
|
264
|
+
label: string;
|
|
265
|
+
type: string;
|
|
266
|
+
hidden: boolean;
|
|
267
|
+
active: boolean;
|
|
268
|
+
toggleable: boolean;
|
|
269
|
+
icon?: string | undefined;
|
|
270
|
+
class?: string | undefined;
|
|
271
|
+
meta?: Record<string, any> | undefined;
|
|
272
|
+
sort?: {
|
|
273
|
+
active: boolean;
|
|
274
|
+
direction: Direction;
|
|
275
|
+
next: string | null;
|
|
276
|
+
} | undefined;
|
|
277
|
+
}[];
|
|
278
|
+
records: (U & {
|
|
279
|
+
/** Perform this action when the record is clicked */
|
|
280
|
+
default: (options?: VisitOptions) => void;
|
|
281
|
+
/** The actions available for the record */
|
|
282
|
+
actions: any;
|
|
283
|
+
/** Selects this record */
|
|
284
|
+
select: () => void;
|
|
285
|
+
/** Deselects this record */
|
|
286
|
+
deselect: () => void;
|
|
287
|
+
/** Toggles the selection of this record */
|
|
288
|
+
toggle: () => void;
|
|
289
|
+
/** Determine if the record is selected */
|
|
290
|
+
selected: boolean;
|
|
291
|
+
/** Bind the record to a checkbox */
|
|
292
|
+
bind: () => {
|
|
293
|
+
/**
|
|
294
|
+
* Actions to be applied on a record in JavaScript.
|
|
295
|
+
*/
|
|
296
|
+
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
297
|
+
modelValue: boolean;
|
|
298
|
+
value: any;
|
|
299
|
+
};
|
|
300
|
+
})[];
|
|
301
|
+
bulkActions: {
|
|
302
|
+
/** Executes this bulk action */
|
|
303
|
+
execute: (options?: VisitOptions) => void;
|
|
304
|
+
type: "bulk";
|
|
305
|
+
keepSelected: boolean;
|
|
306
|
+
name: string;
|
|
307
|
+
label: string;
|
|
308
|
+
action?: boolean | undefined;
|
|
309
|
+
extra?: Record<string, unknown> | undefined;
|
|
310
|
+
icon?: string | undefined;
|
|
311
|
+
confirm?: Confirm | undefined;
|
|
312
|
+
route?: Route | undefined;
|
|
313
|
+
}[];
|
|
314
|
+
pageActions: {
|
|
315
|
+
/** Executes this page action */
|
|
316
|
+
execute: (options?: VisitOptions) => void;
|
|
317
|
+
type: "page";
|
|
318
|
+
name: string;
|
|
319
|
+
label: string;
|
|
320
|
+
action?: boolean | undefined;
|
|
321
|
+
extra?: Record<string, unknown> | undefined;
|
|
322
|
+
icon?: string | undefined;
|
|
323
|
+
confirm?: Confirm | undefined;
|
|
324
|
+
route?: Route | undefined;
|
|
325
|
+
}[];
|
|
326
|
+
rowsPerPage: {
|
|
327
|
+
/** Changes the number of records to display per page */
|
|
328
|
+
apply: (options?: VisitOptions) => void;
|
|
329
|
+
value: number;
|
|
330
|
+
active: boolean;
|
|
331
|
+
}[];
|
|
332
|
+
currentPage: PerPageRecord | undefined;
|
|
333
|
+
paginator: (V extends "length-aware" ? LengthAwarePaginator : V extends "simple" ? SimplePaginator : V extends "cursor" ? CursorPaginator : CollectionPaginator) & {
|
|
334
|
+
links?: {
|
|
335
|
+
navigate: (options?: VisitOptions) => void | "" | null;
|
|
336
|
+
url: string | null;
|
|
337
|
+
label: string;
|
|
338
|
+
active: boolean;
|
|
339
|
+
}[] | undefined;
|
|
340
|
+
next: (options?: VisitOptions) => void;
|
|
341
|
+
previous: (options?: VisitOptions) => void;
|
|
342
|
+
first: (options?: VisitOptions) => void;
|
|
343
|
+
last: (options?: VisitOptions) => void;
|
|
344
|
+
};
|
|
345
|
+
executeInlineAction: (action: InlineAction, record: U, options?: VisitOptions) => void;
|
|
346
|
+
executeBulkAction: (action: BulkAction, options?: VisitOptions) => void;
|
|
347
|
+
executePageAction: (action: PageAction, options?: VisitOptions) => void;
|
|
348
|
+
applyPage: (page: PerPageRecord, options?: VisitOptions) => void;
|
|
349
|
+
selection: BulkSelection<any>;
|
|
350
|
+
select: (record: U) => void;
|
|
351
|
+
deselect: (record: U) => void;
|
|
352
|
+
selectPage: () => void;
|
|
353
|
+
deselectPage: () => void;
|
|
354
|
+
toggle: (record: U) => void;
|
|
355
|
+
selected: (record: U) => boolean;
|
|
356
|
+
selectAll: () => void;
|
|
357
|
+
deselectAll: () => void;
|
|
358
|
+
isPageSelected: boolean;
|
|
359
|
+
hasSelected: boolean;
|
|
360
|
+
bindCheckbox: (record: U) => {
|
|
361
|
+
/**
|
|
362
|
+
* Actions to be applied on a record in JavaScript.
|
|
363
|
+
*/
|
|
364
|
+
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
365
|
+
modelValue: boolean;
|
|
366
|
+
value: any;
|
|
367
|
+
};
|
|
368
|
+
bindPage: () => {
|
|
369
|
+
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
370
|
+
modelValue: boolean;
|
|
371
|
+
};
|
|
372
|
+
bindAll: () => {
|
|
373
|
+
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
374
|
+
modelValue: boolean;
|
|
375
|
+
value: boolean;
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
|
|
1
379
|
export { }
|