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