@honed/table 0.8.1 → 0.9.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 +79 -120
- package/dist/index.es.js +384 -394
- package/dist/index.umd.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { BindingOptions } from '@honed/refine';
|
|
2
2
|
import { BulkOperation } from '@honed/action';
|
|
3
3
|
import { BulkSelection } from '@honed/action';
|
|
4
|
+
import { ComputedRef } from 'vue';
|
|
4
5
|
import { Direction } from '@honed/refine';
|
|
6
|
+
import { Executable } from '@honed/action';
|
|
5
7
|
import { Filter } from '@honed/refine';
|
|
8
|
+
import { FilterBinding } from '@honed/refine';
|
|
6
9
|
import { FilterValue } from '@honed/refine';
|
|
10
|
+
import { HonedFilter } from '@honed/refine';
|
|
11
|
+
import { HonedRefine } from '@honed/refine';
|
|
12
|
+
import { HonedSearch } from '@honed/refine';
|
|
13
|
+
import { HonedSort } from '@honed/refine';
|
|
7
14
|
import { InlineOperation } from '@honed/action';
|
|
15
|
+
import { MatchBinding } from '@honed/refine';
|
|
8
16
|
import { MaybeEndpoint } from '@honed/action';
|
|
9
17
|
import { MaybeId } from '@honed/action';
|
|
10
|
-
import { Option as Option_2 } from '@honed/refine';
|
|
11
18
|
import { PageOperation } from '@honed/action';
|
|
12
19
|
import { PageOperationData } from '@honed/action';
|
|
13
|
-
import {
|
|
20
|
+
import { Ref } from 'vue';
|
|
14
21
|
import { Refine } from '@honed/refine';
|
|
15
22
|
import { Search } from '@honed/refine';
|
|
23
|
+
import { SearchBinding } from '@honed/refine';
|
|
16
24
|
import { Sort } from '@honed/refine';
|
|
25
|
+
import { SortBinding } from '@honed/refine';
|
|
17
26
|
import { Visit } from '@inertiajs/core';
|
|
18
27
|
import { VisitCallbacks } from '@inertiajs/core';
|
|
19
28
|
import { VisitOptions } from '@inertiajs/core';
|
|
@@ -60,6 +69,40 @@ export declare interface Heading<T extends Record<string, any> = Record<string,
|
|
|
60
69
|
toggleSort: (options: VisitOptions) => void;
|
|
61
70
|
}
|
|
62
71
|
|
|
72
|
+
export declare interface HonedTable<T extends Record<string, any> = Record<string, any>, K extends Paginate = "length-aware"> extends HonedRefine {
|
|
73
|
+
meta: ComputedRef<Record<string, any> | null>;
|
|
74
|
+
isPageable: ComputedRef<boolean>;
|
|
75
|
+
isToggleable: ComputedRef<boolean>;
|
|
76
|
+
getRecordKey: (record: TableEntry<T>) => Identifier;
|
|
77
|
+
headings: ComputedRef<Heading<T>[]>;
|
|
78
|
+
columns: ComputedRef<Column<T>[]>;
|
|
79
|
+
records: ComputedRef<TableRecord<T>[]>;
|
|
80
|
+
inline: ComputedRef<boolean>;
|
|
81
|
+
bulk: ComputedRef<Executable<BulkOperation>[]>;
|
|
82
|
+
page: ComputedRef<Executable<PageOperation>[]>;
|
|
83
|
+
pages: ComputedRef<PageOption[]>;
|
|
84
|
+
currentPage: ComputedRef<PageOption | undefined>;
|
|
85
|
+
paginator: ComputedRef<PaginateMap[K]>;
|
|
86
|
+
executeInline: (operation: InlineOperation, data: TableEntry<T>, options?: VisitOptions) => void;
|
|
87
|
+
executeBulk: (operation: BulkOperation, options?: VisitOptions) => void;
|
|
88
|
+
executePage: (operation: PageOperation, data?: PageOperationData, options?: VisitOptions) => void;
|
|
89
|
+
applyPage: (page: PageOption, options?: VisitOptions) => void;
|
|
90
|
+
selection: Ref<BulkSelection<Identifier>, BulkSelection<Identifier>>;
|
|
91
|
+
select: (record: TableEntry<T>) => void;
|
|
92
|
+
deselect: (record: TableEntry<T>) => void;
|
|
93
|
+
toggle: (record: TableEntry<T>) => void;
|
|
94
|
+
selectPage: () => void;
|
|
95
|
+
deselectPage: () => void;
|
|
96
|
+
selected: (record: TableEntry<T>) => boolean;
|
|
97
|
+
selectAll: () => void;
|
|
98
|
+
deselectAll: () => void;
|
|
99
|
+
isPageSelected: ComputedRef<boolean>;
|
|
100
|
+
hasSelected: ComputedRef<boolean>;
|
|
101
|
+
bindCheckbox: (record: TableEntry<T>) => void;
|
|
102
|
+
bindPage: () => void;
|
|
103
|
+
bindAll: () => void;
|
|
104
|
+
}
|
|
105
|
+
|
|
63
106
|
export declare type Identifier = string | number;
|
|
64
107
|
|
|
65
108
|
export declare function is(column: Column | string | null | undefined, type: ColumnType): boolean;
|
|
@@ -73,6 +116,11 @@ export declare interface LengthAwarePaginate extends SimplePaginate {
|
|
|
73
116
|
links: PaginatorLink[];
|
|
74
117
|
}
|
|
75
118
|
|
|
119
|
+
export declare interface PageBinding {
|
|
120
|
+
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
121
|
+
modelValue: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
76
124
|
export declare interface PageOption {
|
|
77
125
|
value: number;
|
|
78
126
|
active: boolean;
|
|
@@ -121,84 +169,44 @@ export declare interface Table<T extends Record<string, any> = Record<string, an
|
|
|
121
169
|
meta: Record<string, any>;
|
|
122
170
|
}
|
|
123
171
|
|
|
124
|
-
export declare type TableEntry<
|
|
125
|
-
[K in keyof
|
|
126
|
-
v:
|
|
172
|
+
export declare type TableEntry<T extends Record<string, any> = any> = {
|
|
173
|
+
[K in keyof T]: {
|
|
174
|
+
v: T[K];
|
|
127
175
|
e: any;
|
|
128
176
|
c: string | null;
|
|
129
177
|
f: boolean;
|
|
130
178
|
};
|
|
131
179
|
};
|
|
132
180
|
|
|
133
|
-
export declare interface TableOptions<
|
|
181
|
+
export declare interface TableOptions<T extends Record<string, any> = Record<string, any>> extends VisitOptions {
|
|
134
182
|
/**
|
|
135
183
|
* Mappings of operations to be applied on a record in JavaScript.
|
|
136
184
|
*/
|
|
137
|
-
recordOperations?: Record<string, (record: TableEntry<
|
|
185
|
+
recordOperations?: Record<string, (record: TableEntry<T>) => void>;
|
|
138
186
|
}
|
|
139
187
|
|
|
140
|
-
export declare interface TableRecord<
|
|
141
|
-
|
|
188
|
+
export declare interface TableRecord<T extends Record<string, any> = Record<string, any>> {
|
|
189
|
+
operations: Executable<InlineOperation>[];
|
|
142
190
|
default: (options?: VisitOptions) => void;
|
|
143
|
-
operations: InlineOperation[];
|
|
144
191
|
select: () => void;
|
|
145
192
|
deselect: () => void;
|
|
146
193
|
toggle: () => void;
|
|
147
194
|
selected: boolean;
|
|
148
|
-
bind: () =>
|
|
149
|
-
|
|
150
|
-
|
|
195
|
+
bind: () => any;
|
|
196
|
+
entry: (column: Column<T> | string) => TableEntry<T>[keyof T] | null;
|
|
197
|
+
value: (column: Column<T> | string) => TableEntry<T>[keyof T]["v"] | null;
|
|
198
|
+
extra: (column: Column<T> | string) => TableEntry<T>[keyof T]["e"] | null;
|
|
151
199
|
}
|
|
152
200
|
|
|
153
201
|
export declare type UseTable = typeof useTable;
|
|
154
202
|
|
|
155
203
|
export declare function useTable<T extends Record<string, Table>, K extends Record<string, any> = Record<string, any>, U extends Paginate = "length-aware">(props: T, key: keyof T, defaults?: TableOptions): {
|
|
156
|
-
filters:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
type: string;
|
|
164
|
-
value: FilterValue;
|
|
165
|
-
options: Option_2[];
|
|
166
|
-
name: string;
|
|
167
|
-
label: string;
|
|
168
|
-
active: boolean;
|
|
169
|
-
meta: Record<string, any>;
|
|
170
|
-
}[];
|
|
171
|
-
sorts: {
|
|
172
|
-
apply: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
173
|
-
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
174
|
-
bind: () => void | {
|
|
175
|
-
onClick: PromisifyFn<() => void>;
|
|
176
|
-
};
|
|
177
|
-
type: string;
|
|
178
|
-
direction: Direction;
|
|
179
|
-
next: string | null;
|
|
180
|
-
name: string;
|
|
181
|
-
label: string;
|
|
182
|
-
active: boolean;
|
|
183
|
-
meta: Record<string, any>;
|
|
184
|
-
}[];
|
|
185
|
-
searches: {
|
|
186
|
-
apply: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
187
|
-
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
188
|
-
bind: () => void | {
|
|
189
|
-
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
190
|
-
modelValue: boolean;
|
|
191
|
-
value: string;
|
|
192
|
-
};
|
|
193
|
-
type: string;
|
|
194
|
-
name: string;
|
|
195
|
-
label: string;
|
|
196
|
-
active: boolean;
|
|
197
|
-
meta: Record<string, any>;
|
|
198
|
-
}[];
|
|
199
|
-
currentFilters: Filter[];
|
|
200
|
-
currentSort: Sort | undefined;
|
|
201
|
-
currentSearches: Search[];
|
|
204
|
+
filters: HonedFilter[];
|
|
205
|
+
sorts: HonedSort[];
|
|
206
|
+
searches: HonedSearch[];
|
|
207
|
+
currentFilters: HonedFilter[];
|
|
208
|
+
currentSort: HonedSort | undefined;
|
|
209
|
+
currentSearches: HonedSearch[];
|
|
202
210
|
isSortable: boolean;
|
|
203
211
|
isSearchable: boolean;
|
|
204
212
|
isMatchable: boolean;
|
|
@@ -218,74 +226,25 @@ export declare function useTable<T extends Record<string, Table>, K extends Reco
|
|
|
218
226
|
clearSearch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
219
227
|
clearMatch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
220
228
|
reset: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
221
|
-
bindFilter: (filter: string | Filter, options?: BindingOptions | undefined) => void |
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
bindSort: (sort: string | Sort, options?: BindingOptions | undefined) => void | {
|
|
226
|
-
onClick: PromisifyFn<() => void>;
|
|
227
|
-
};
|
|
228
|
-
bindSearch: (options?: BindingOptions | undefined) => {
|
|
229
|
-
"onUpdate:modelValue": PromisifyFn<(value: string | null | undefined) => void>;
|
|
230
|
-
modelValue: string;
|
|
231
|
-
};
|
|
232
|
-
bindMatch: (match: string | Search, options?: BindingOptions | undefined) => void | {
|
|
233
|
-
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
234
|
-
/**
|
|
235
|
-
* Create operations with execute methods
|
|
236
|
-
*/
|
|
237
|
-
modelValue: boolean;
|
|
238
|
-
value: string;
|
|
239
|
-
};
|
|
229
|
+
bindFilter: (filter: string | Filter, options?: BindingOptions | undefined) => void | FilterBinding;
|
|
230
|
+
bindSort: (sort: string | Sort, options?: BindingOptions | undefined) => void | SortBinding;
|
|
231
|
+
bindSearch: (options?: BindingOptions | undefined) => void | SearchBinding;
|
|
232
|
+
bindMatch: (match: string | Search, options?: BindingOptions | undefined) => void | MatchBinding;
|
|
240
233
|
stringValue: (value: any) => any;
|
|
241
234
|
omitValue: (value: any) => any;
|
|
242
235
|
toggleValue: (value: any, values: any) => any;
|
|
243
|
-
delimitArray: (value: any) =>
|
|
244
|
-
table: Table<K, U>;
|
|
245
|
-
getRecordKey: (record: TableEntry<K>) => Identifier;
|
|
236
|
+
delimitArray: (value: any) => string;
|
|
246
237
|
meta: Record<string, any>;
|
|
238
|
+
isPageable: boolean;
|
|
239
|
+
isToggleable: boolean;
|
|
240
|
+
getRecordKey: (record: TableEntry<K>) => Identifier;
|
|
247
241
|
headings: Heading<K>[];
|
|
248
242
|
columns: Column<K>[];
|
|
249
|
-
records:
|
|
250
|
-
record: Omit<TableEntry<K> & {
|
|
251
|
-
operations: InlineOperation[];
|
|
252
|
-
}, "operations">;
|
|
253
|
-
/** The operations available for the record */
|
|
254
|
-
operations: (InlineOperation & {
|
|
255
|
-
execute: (data?: any, options?: Partial<Visit & VisitCallbacks> | undefined) => boolean;
|
|
256
|
-
})[];
|
|
257
|
-
/** Perform this operation when the record is clicked */
|
|
258
|
-
default: (options?: VisitOptions) => void;
|
|
259
|
-
/** Selects this record */
|
|
260
|
-
select: () => void;
|
|
261
|
-
/** Deselects this record */
|
|
262
|
-
deselect: () => void;
|
|
263
|
-
/** Toggles the selection of this record */
|
|
264
|
-
toggle: () => void;
|
|
265
|
-
/** Determine if the record is selected */
|
|
266
|
-
selected: boolean;
|
|
267
|
-
/** Bind the record to a checkbox */
|
|
268
|
-
bind: () => {
|
|
269
|
-
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
270
|
-
modelValue: boolean;
|
|
271
|
-
value: Identifier;
|
|
272
|
-
};
|
|
273
|
-
/** Get the value of the record for the column */
|
|
274
|
-
value: (column: Column<K> | string) => K[string] | K[number] | K[symbol] | null;
|
|
275
|
-
/** Get the extra data of the record for the column */
|
|
276
|
-
extra: (column: Column<K> | string) => any;
|
|
277
|
-
}[];
|
|
243
|
+
records: TableRecord<K>[];
|
|
278
244
|
inline: boolean;
|
|
279
|
-
bulk:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
page: (PageOperation & {
|
|
283
|
-
execute: (data?: any, options?: Partial<Visit & VisitCallbacks> | undefined) => boolean;
|
|
284
|
-
})[];
|
|
285
|
-
pages: {
|
|
286
|
-
value: number;
|
|
287
|
-
active: boolean;
|
|
288
|
-
}[];
|
|
245
|
+
bulk: Executable<BulkOperation>[];
|
|
246
|
+
page: Executable<PageOperation>[];
|
|
247
|
+
pages: PageOption[];
|
|
289
248
|
currentPage: PageOption | undefined;
|
|
290
249
|
paginator: PaginateMap[U] & {
|
|
291
250
|
links?: {
|