@honed/table 0.2.1 → 0.3.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 +79 -49
- package/dist/index.es.js +219 -197
- package/dist/index.umd.js +1 -1
- package/package.json +17 -8
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,13 @@ import { Visit } from '@inertiajs/core';
|
|
|
18
18
|
import { VisitCallbacks } from '@inertiajs/core';
|
|
19
19
|
import { VisitOptions } from '@inertiajs/core';
|
|
20
20
|
|
|
21
|
+
export declare type AsRecord<RecordType extends Record<string, any>> = {
|
|
22
|
+
[K in keyof RecordType]: {
|
|
23
|
+
value: RecordType[K];
|
|
24
|
+
extra: Record<string, any>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
export declare interface CollectionPaginator {
|
|
22
29
|
empty: boolean;
|
|
23
30
|
}
|
|
@@ -25,13 +32,12 @@ export declare interface CollectionPaginator {
|
|
|
25
32
|
export declare interface Column<T extends Record<string, any>> {
|
|
26
33
|
name: keyof T;
|
|
27
34
|
label: string;
|
|
28
|
-
type: "text" | "number" | "date" | "boolean" | string;
|
|
35
|
+
type: "text" | "number" | "date" | "boolean" | "hidden" | "key" | string;
|
|
29
36
|
hidden: boolean;
|
|
30
37
|
active: boolean;
|
|
31
38
|
toggleable: boolean;
|
|
32
39
|
icon?: string;
|
|
33
40
|
class?: string;
|
|
34
|
-
meta?: Record<string, any>;
|
|
35
41
|
sort?: {
|
|
36
42
|
active: boolean;
|
|
37
43
|
direction: Direction;
|
|
@@ -39,7 +45,7 @@ export declare interface Column<T extends Record<string, any>> {
|
|
|
39
45
|
};
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
declare interface Config extends Config_2 {
|
|
48
|
+
export declare interface Config extends Config_2 {
|
|
43
49
|
endpoint: string;
|
|
44
50
|
record: string;
|
|
45
51
|
records: string;
|
|
@@ -64,7 +70,7 @@ export declare interface LengthAwarePaginator extends SimplePaginator {
|
|
|
64
70
|
links: PaginatorLink[];
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
declare type PaginatorKind = "cursor" | "length-aware" | "simple" | "collection";
|
|
73
|
+
export declare type PaginatorKind = "cursor" | "length-aware" | "simple" | "collection";
|
|
68
74
|
|
|
69
75
|
export declare interface PaginatorLink {
|
|
70
76
|
url: string | null;
|
|
@@ -81,44 +87,56 @@ export declare interface SimplePaginator extends CursorPaginator {
|
|
|
81
87
|
currentPage: number;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
export declare interface Table<
|
|
90
|
+
export declare interface Table<RecordType extends Record<string, any> = any, Paginator extends PaginatorKind = "length-aware"> extends Refine {
|
|
91
|
+
config: Config;
|
|
85
92
|
id: string;
|
|
86
|
-
records:
|
|
93
|
+
records: Array<AsRecord<RecordType> & {
|
|
87
94
|
actions: InlineAction[];
|
|
88
|
-
}
|
|
89
|
-
paginator:
|
|
90
|
-
columns?: Column<
|
|
91
|
-
recordsPerPage
|
|
95
|
+
}>;
|
|
96
|
+
paginator: Paginator extends "length-aware" ? LengthAwarePaginator : Paginator extends "simple" ? SimplePaginator : Paginator extends "cursor" ? CursorPaginator : CollectionPaginator;
|
|
97
|
+
columns?: Column<RecordType>[];
|
|
98
|
+
recordsPerPage?: PerPageRecord[];
|
|
92
99
|
toggleable: boolean;
|
|
93
100
|
actions: {
|
|
94
101
|
hasInline: boolean;
|
|
95
102
|
bulk: BulkAction[];
|
|
96
103
|
page: PageAction[];
|
|
97
104
|
};
|
|
98
|
-
config: Config;
|
|
99
105
|
meta: Record<string, any>;
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
export declare interface TableOptions<
|
|
108
|
+
export declare interface TableOptions<RecordType extends Record<string, any>> {
|
|
103
109
|
/**
|
|
104
110
|
* Actions to be applied on a record in JavaScript.
|
|
105
111
|
*/
|
|
106
|
-
recordActions?: Record<string, (record:
|
|
112
|
+
recordActions?: Record<string, (record: AsRecord<RecordType>) => void>;
|
|
107
113
|
}
|
|
108
114
|
|
|
109
|
-
export declare
|
|
115
|
+
export declare interface TableRecord<RecordType extends Record<string, any>> {
|
|
116
|
+
record: RecordType;
|
|
117
|
+
default: (options: VisitOptions) => void;
|
|
118
|
+
actions: InlineAction[];
|
|
119
|
+
select: () => void;
|
|
120
|
+
deselect: () => void;
|
|
121
|
+
toggle: () => void;
|
|
122
|
+
selected: boolean;
|
|
123
|
+
bind: () => Record<string, any>;
|
|
124
|
+
value: (column: Column<RecordType> | string) => any;
|
|
125
|
+
extra: (column: Column<RecordType> | string) => any;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare function useTable<Props extends object, Key extends Props[keyof Props] extends Refine ? keyof Props : never, RecordType extends Record<string, any> = any, Paginator extends PaginatorKind = "length-aware">(props: Props, key: Key, tableOptions?: TableOptions<RecordType>, defaultOptions?: VisitOptions): {
|
|
110
129
|
filters: {
|
|
111
|
-
apply: (value:
|
|
130
|
+
apply: (value: Props, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
112
131
|
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
113
132
|
bind: () => {
|
|
114
133
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
115
134
|
modelValue: unknown;
|
|
116
|
-
value: unknown;
|
|
117
135
|
} | undefined;
|
|
118
136
|
type: string;
|
|
119
|
-
multiple: boolean;
|
|
120
|
-
options: Option_2[];
|
|
121
137
|
value: FilterValue;
|
|
138
|
+
options: Option_2[];
|
|
139
|
+
multiple: boolean;
|
|
122
140
|
name: string;
|
|
123
141
|
label: string;
|
|
124
142
|
active: boolean;
|
|
@@ -144,10 +162,11 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
144
162
|
bind: () => {
|
|
145
163
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
146
164
|
modelValue: boolean;
|
|
165
|
+
value: string;
|
|
147
166
|
} | undefined;
|
|
167
|
+
type: string;
|
|
148
168
|
name: string;
|
|
149
169
|
label: string;
|
|
150
|
-
type: string;
|
|
151
170
|
active: boolean;
|
|
152
171
|
meta: Record<string, any>;
|
|
153
172
|
}[] | undefined;
|
|
@@ -173,29 +192,29 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
173
192
|
bindFilter: <T_1 extends unknown>(filter: string | Filter, options?: BindingOptions | undefined) => {
|
|
174
193
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
175
194
|
modelValue: T_1;
|
|
176
|
-
value: T_1;
|
|
177
195
|
} | undefined;
|
|
178
196
|
bindSort: (sort: string | Sort, options?: BindingOptions | undefined) => {
|
|
179
197
|
onClick: PromisifyFn<() => void>;
|
|
180
198
|
} | undefined;
|
|
181
199
|
bindSearch: (options?: BindingOptions | undefined) => {
|
|
182
|
-
"onUpdate:modelValue": PromisifyFn<(value:
|
|
200
|
+
"onUpdate:modelValue": PromisifyFn<(value: string | null | undefined) => void>;
|
|
183
201
|
modelValue: string;
|
|
184
202
|
};
|
|
185
203
|
bindMatch: (match: string | Search, options?: BindingOptions | undefined) => {
|
|
186
204
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
187
205
|
modelValue: boolean;
|
|
206
|
+
value: string;
|
|
188
207
|
} | undefined;
|
|
189
208
|
stringValue: (value: any) => any;
|
|
190
209
|
omitValue: (value: any) => any;
|
|
191
210
|
toggleValue: (value: any, values: any) => any;
|
|
192
211
|
delimitArray: (value: any) => any;
|
|
193
|
-
getRecordKey: (record:
|
|
212
|
+
getRecordKey: (record: AsRecord<RecordType>) => Identifier;
|
|
194
213
|
meta: Record<string, any>;
|
|
195
214
|
headings: {
|
|
196
215
|
isSorting: boolean | undefined;
|
|
197
216
|
toggleSort: (options?: VisitOptions) => void;
|
|
198
|
-
name: keyof
|
|
217
|
+
name: keyof RecordType;
|
|
199
218
|
label: string;
|
|
200
219
|
type: string;
|
|
201
220
|
hidden: boolean;
|
|
@@ -203,7 +222,6 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
203
222
|
toggleable: boolean;
|
|
204
223
|
icon?: string | undefined;
|
|
205
224
|
class?: string | undefined;
|
|
206
|
-
meta?: Record<string, any> | undefined;
|
|
207
225
|
sort?: {
|
|
208
226
|
active: boolean;
|
|
209
227
|
direction: Direction;
|
|
@@ -212,7 +230,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
212
230
|
}[];
|
|
213
231
|
columns: {
|
|
214
232
|
toggle: (options?: VisitOptions) => void;
|
|
215
|
-
name: keyof
|
|
233
|
+
name: keyof RecordType;
|
|
216
234
|
label: string;
|
|
217
235
|
type: string;
|
|
218
236
|
hidden: boolean;
|
|
@@ -220,18 +238,32 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
220
238
|
toggleable: boolean;
|
|
221
239
|
icon?: string | undefined;
|
|
222
240
|
class?: string | undefined;
|
|
223
|
-
meta?: Record<string, any> | undefined;
|
|
224
241
|
sort?: {
|
|
225
242
|
active: boolean;
|
|
226
243
|
direction: Direction;
|
|
227
244
|
next: string | null;
|
|
228
245
|
} | undefined;
|
|
229
246
|
}[];
|
|
230
|
-
records:
|
|
247
|
+
records: {
|
|
248
|
+
record: Omit<AsRecord<RecordType> & {
|
|
249
|
+
actions: InlineAction[];
|
|
250
|
+
}, "actions">;
|
|
231
251
|
/** Perform this action when the record is clicked */
|
|
232
252
|
default: (options?: VisitOptions) => void;
|
|
233
253
|
/** The actions available for the record */
|
|
234
|
-
actions:
|
|
254
|
+
actions: {
|
|
255
|
+
/** Executes this action */
|
|
256
|
+
execute: (options?: VisitOptions) => void;
|
|
257
|
+
type: "inline";
|
|
258
|
+
default: boolean;
|
|
259
|
+
name: string;
|
|
260
|
+
label: string;
|
|
261
|
+
icon?: string | undefined;
|
|
262
|
+
extra?: Record<string, unknown> | undefined;
|
|
263
|
+
action?: boolean | undefined;
|
|
264
|
+
confirm?: Confirm | undefined;
|
|
265
|
+
route?: Route | undefined;
|
|
266
|
+
}[];
|
|
235
267
|
/** Selects this record */
|
|
236
268
|
select: () => void;
|
|
237
269
|
/** Deselects this record */
|
|
@@ -242,14 +274,15 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
242
274
|
selected: boolean;
|
|
243
275
|
/** Bind the record to a checkbox */
|
|
244
276
|
bind: () => {
|
|
245
|
-
/**
|
|
246
|
-
* Actions to be applied on a record in JavaScript.
|
|
247
|
-
*/
|
|
248
277
|
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
249
278
|
modelValue: boolean;
|
|
250
|
-
value:
|
|
279
|
+
value: Identifier;
|
|
251
280
|
};
|
|
252
|
-
|
|
281
|
+
/** Get the value of the record for the column */
|
|
282
|
+
value: (column: Column<RecordType> | string) => RecordType[string] | RecordType[number] | RecordType[symbol];
|
|
283
|
+
/** Get the extra data of the record for the column */
|
|
284
|
+
extra: (column: Column<RecordType> | string) => Record<string, any>;
|
|
285
|
+
}[];
|
|
253
286
|
bulkActions: {
|
|
254
287
|
/** Executes this bulk action */
|
|
255
288
|
execute: (options?: VisitOptions) => void;
|
|
@@ -257,9 +290,9 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
257
290
|
keepSelected: boolean;
|
|
258
291
|
name: string;
|
|
259
292
|
label: string;
|
|
260
|
-
action?: boolean | undefined;
|
|
261
|
-
extra?: Record<string, unknown> | undefined;
|
|
262
293
|
icon?: string | undefined;
|
|
294
|
+
extra?: Record<string, unknown> | undefined;
|
|
295
|
+
action?: boolean | undefined;
|
|
263
296
|
confirm?: Confirm | undefined;
|
|
264
297
|
route?: Route | undefined;
|
|
265
298
|
}[];
|
|
@@ -269,9 +302,9 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
269
302
|
type: "page";
|
|
270
303
|
name: string;
|
|
271
304
|
label: string;
|
|
272
|
-
action?: boolean | undefined;
|
|
273
|
-
extra?: Record<string, unknown> | undefined;
|
|
274
305
|
icon?: string | undefined;
|
|
306
|
+
extra?: Record<string, unknown> | undefined;
|
|
307
|
+
action?: boolean | undefined;
|
|
275
308
|
confirm?: Confirm | undefined;
|
|
276
309
|
route?: Route | undefined;
|
|
277
310
|
}[];
|
|
@@ -282,7 +315,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
282
315
|
active: boolean;
|
|
283
316
|
}[];
|
|
284
317
|
currentPage: PerPageRecord | undefined;
|
|
285
|
-
paginator: (
|
|
318
|
+
paginator: (Paginator extends "length-aware" ? LengthAwarePaginator : Paginator extends "simple" ? SimplePaginator : Paginator extends "cursor" ? CursorPaginator : CollectionPaginator) & {
|
|
286
319
|
links?: {
|
|
287
320
|
navigate: (options?: VisitOptions) => void | "" | null;
|
|
288
321
|
url: string | null;
|
|
@@ -294,28 +327,25 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
294
327
|
first: (options?: VisitOptions) => void;
|
|
295
328
|
last: (options?: VisitOptions) => void;
|
|
296
329
|
};
|
|
297
|
-
executeInlineAction: (action: InlineAction, record:
|
|
330
|
+
executeInlineAction: (action: InlineAction, record: AsRecord<RecordType>, options?: VisitOptions) => void;
|
|
298
331
|
executeBulkAction: (action: BulkAction, options?: VisitOptions) => void;
|
|
299
332
|
executePageAction: (action: PageAction, options?: VisitOptions) => void;
|
|
300
333
|
applyPage: (page: PerPageRecord, options?: VisitOptions) => void;
|
|
301
|
-
selection: BulkSelection<
|
|
302
|
-
select: (record:
|
|
303
|
-
deselect: (record:
|
|
334
|
+
selection: BulkSelection<Identifier>;
|
|
335
|
+
select: (record: AsRecord<RecordType>) => void;
|
|
336
|
+
deselect: (record: AsRecord<RecordType>) => void;
|
|
304
337
|
selectPage: () => void;
|
|
305
338
|
deselectPage: () => void;
|
|
306
|
-
toggle: (record:
|
|
307
|
-
selected: (record:
|
|
339
|
+
toggle: (record: AsRecord<RecordType>) => void;
|
|
340
|
+
selected: (record: AsRecord<RecordType>) => boolean;
|
|
308
341
|
selectAll: () => void;
|
|
309
342
|
deselectAll: () => void;
|
|
310
343
|
isPageSelected: boolean;
|
|
311
344
|
hasSelected: boolean;
|
|
312
|
-
bindCheckbox: (record:
|
|
313
|
-
/**
|
|
314
|
-
* Actions to be applied on a record in JavaScript.
|
|
315
|
-
*/
|
|
345
|
+
bindCheckbox: (record: AsRecord<RecordType>) => {
|
|
316
346
|
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
317
347
|
modelValue: boolean;
|
|
318
|
-
value:
|
|
348
|
+
value: Identifier;
|
|
319
349
|
};
|
|
320
350
|
bindPage: () => {
|
|
321
351
|
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as _, computed as h, toValue as
|
|
1
|
+
import { ref as _, computed as h, toValue as J, reactive as Q } from "vue";
|
|
2
2
|
import { router as S } from "@inertiajs/vue3";
|
|
3
3
|
function X() {
|
|
4
4
|
const o = _({
|
|
@@ -6,22 +6,22 @@ function X() {
|
|
|
6
6
|
only: /* @__PURE__ */ new Set(),
|
|
7
7
|
except: /* @__PURE__ */ new Set()
|
|
8
8
|
});
|
|
9
|
-
function
|
|
9
|
+
function m() {
|
|
10
10
|
o.value.all = !0, o.value.only.clear(), o.value.except.clear();
|
|
11
11
|
}
|
|
12
12
|
function v() {
|
|
13
13
|
o.value.all = !1, o.value.only.clear(), o.value.except.clear();
|
|
14
14
|
}
|
|
15
15
|
function l(...s) {
|
|
16
|
-
s.forEach((
|
|
16
|
+
s.forEach((p) => o.value.except.delete(p)), s.forEach((p) => o.value.only.add(p));
|
|
17
17
|
}
|
|
18
18
|
function i(...s) {
|
|
19
|
-
s.forEach((
|
|
19
|
+
s.forEach((p) => o.value.except.add(p)), s.forEach((p) => o.value.only.delete(p));
|
|
20
20
|
}
|
|
21
|
-
function u(s,
|
|
22
|
-
if (b(s) ||
|
|
21
|
+
function u(s, p) {
|
|
22
|
+
if (b(s) || p === !1)
|
|
23
23
|
return i(s);
|
|
24
|
-
if (!b(s) ||
|
|
24
|
+
if (!b(s) || p === !0)
|
|
25
25
|
return l(s);
|
|
26
26
|
}
|
|
27
27
|
function b(s) {
|
|
@@ -30,8 +30,8 @@ function X() {
|
|
|
30
30
|
const d = h(() => o.value.all && o.value.except.size === 0), A = h(() => o.value.only.size > 0 || d.value);
|
|
31
31
|
function x(s) {
|
|
32
32
|
return {
|
|
33
|
-
"onUpdate:modelValue": (
|
|
34
|
-
|
|
33
|
+
"onUpdate:modelValue": (p) => {
|
|
34
|
+
p ? l(s) : i(s);
|
|
35
35
|
},
|
|
36
36
|
modelValue: b(s),
|
|
37
37
|
value: s
|
|
@@ -40,7 +40,7 @@ function X() {
|
|
|
40
40
|
function k() {
|
|
41
41
|
return {
|
|
42
42
|
"onUpdate:modelValue": (s) => {
|
|
43
|
-
s ?
|
|
43
|
+
s ? m() : v();
|
|
44
44
|
},
|
|
45
45
|
modelValue: d.value,
|
|
46
46
|
value: d.value
|
|
@@ -50,7 +50,7 @@ function X() {
|
|
|
50
50
|
allSelected: d,
|
|
51
51
|
selection: o,
|
|
52
52
|
hasSelected: A,
|
|
53
|
-
selectAll:
|
|
53
|
+
selectAll: m,
|
|
54
54
|
deselectAll: v,
|
|
55
55
|
select: l,
|
|
56
56
|
deselect: i,
|
|
@@ -60,12 +60,12 @@ function X() {
|
|
|
60
60
|
bindAll: k
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function I(o, m, v = {}, l = {}) {
|
|
64
64
|
return o.route ? (S.visit(o.route.href, {
|
|
65
65
|
...l,
|
|
66
66
|
method: o.route.method
|
|
67
|
-
}), !0) : o.action &&
|
|
68
|
-
|
|
67
|
+
}), !0) : o.action && m ? (S.post(
|
|
68
|
+
m,
|
|
69
69
|
{
|
|
70
70
|
...v,
|
|
71
71
|
name: o.name,
|
|
@@ -77,24 +77,24 @@ function J(o, f, v = {}, l = {}) {
|
|
|
77
77
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
78
78
|
const Y = () => {
|
|
79
79
|
};
|
|
80
|
-
function Z(o,
|
|
80
|
+
function Z(o, m) {
|
|
81
81
|
function v(...l) {
|
|
82
82
|
return new Promise((i, u) => {
|
|
83
|
-
Promise.resolve(o(() =>
|
|
83
|
+
Promise.resolve(o(() => m.apply(this, l), { fn: m, thisArg: this, args: l })).then(i).catch(u);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
return v;
|
|
87
87
|
}
|
|
88
|
-
function O(o,
|
|
88
|
+
function O(o, m = {}) {
|
|
89
89
|
let v, l, i = Y;
|
|
90
90
|
const u = (d) => {
|
|
91
91
|
clearTimeout(d), i(), i = Y;
|
|
92
92
|
};
|
|
93
93
|
let b;
|
|
94
94
|
return (d) => {
|
|
95
|
-
const A =
|
|
95
|
+
const A = J(o), x = J(m.maxWait);
|
|
96
96
|
return v && u(v), A <= 0 || x !== void 0 && x <= 0 ? (l && (u(l), l = null), Promise.resolve(d())) : new Promise((k, s) => {
|
|
97
|
-
i =
|
|
97
|
+
i = m.rejectOnCancel ? s : k, b = d, x && !l && (l = setTimeout(() => {
|
|
98
98
|
v && u(v), l = null, k(b());
|
|
99
99
|
}, x)), v = setTimeout(() => {
|
|
100
100
|
l && u(l), l = null, k(d());
|
|
@@ -102,21 +102,21 @@ function O(o, f = {}) {
|
|
|
102
102
|
});
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function q(o, m = 200, v = {}) {
|
|
106
106
|
return Z(
|
|
107
|
-
O(
|
|
107
|
+
O(m, v),
|
|
108
108
|
o
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
|
-
function ee(o,
|
|
112
|
-
const l = h(() => o[
|
|
111
|
+
function ee(o, m, v = {}) {
|
|
112
|
+
const l = h(() => o[m]), i = h(
|
|
113
113
|
() => {
|
|
114
114
|
var e;
|
|
115
115
|
return ((e = l.value.filters) == null ? void 0 : e.map((n) => ({
|
|
116
116
|
...n,
|
|
117
|
-
apply: (
|
|
118
|
-
clear: (
|
|
119
|
-
bind: () =>
|
|
117
|
+
apply: (r, c = {}) => L(n, r, c),
|
|
118
|
+
clear: (r = {}) => N(n, r),
|
|
119
|
+
bind: () => a(n.name)
|
|
120
120
|
}))) ?? [];
|
|
121
121
|
}
|
|
122
122
|
), u = h(
|
|
@@ -124,9 +124,9 @@ function ee(o, f, v = {}) {
|
|
|
124
124
|
var e;
|
|
125
125
|
return ((e = l.value.sorts) == null ? void 0 : e.map((n) => ({
|
|
126
126
|
...n,
|
|
127
|
-
apply: (
|
|
128
|
-
clear: (
|
|
129
|
-
bind: () =>
|
|
127
|
+
apply: (r = {}) => M(n, n.direction, r),
|
|
128
|
+
clear: (r = {}) => W(r),
|
|
129
|
+
bind: () => f(n)
|
|
130
130
|
}))) ?? [];
|
|
131
131
|
}
|
|
132
132
|
), b = h(
|
|
@@ -134,9 +134,9 @@ function ee(o, f, v = {}) {
|
|
|
134
134
|
var e;
|
|
135
135
|
return (e = l.value.searches) == null ? void 0 : e.map((n) => ({
|
|
136
136
|
...n,
|
|
137
|
-
apply: (
|
|
138
|
-
clear: (
|
|
139
|
-
bind: () =>
|
|
137
|
+
apply: (r = {}) => U(n, r),
|
|
138
|
+
clear: (r = {}) => U(n, r),
|
|
139
|
+
bind: () => F(n)
|
|
140
140
|
}));
|
|
141
141
|
}
|
|
142
142
|
);
|
|
@@ -152,91 +152,91 @@ function ee(o, f, v = {}) {
|
|
|
152
152
|
}
|
|
153
153
|
function k(e) {
|
|
154
154
|
return [d, A, x].reduce(
|
|
155
|
-
(n,
|
|
155
|
+
(n, r) => r(n),
|
|
156
156
|
e
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
function s(e, n) {
|
|
160
|
-
return n = Array.isArray(n) ? n : [n], n.includes(e) ? n.filter((
|
|
160
|
+
return n = Array.isArray(n) ? n : [n], n.includes(e) ? n.filter((r) => r !== e) : [...n, e];
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function p(e) {
|
|
163
163
|
var n;
|
|
164
|
-
return (n = l.value.filters) == null ? void 0 : n.find((
|
|
164
|
+
return (n = l.value.filters) == null ? void 0 : n.find((r) => r.name === e);
|
|
165
165
|
}
|
|
166
|
-
function
|
|
167
|
-
var
|
|
168
|
-
return (
|
|
166
|
+
function j(e, n = null) {
|
|
167
|
+
var r;
|
|
168
|
+
return (r = l.value.sorts) == null ? void 0 : r.find(
|
|
169
169
|
(c) => c.name === e && c.direction === n
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
function C(e) {
|
|
173
173
|
var n;
|
|
174
|
-
return (n = l.value.searches) == null ? void 0 : n.find((
|
|
174
|
+
return (n = l.value.searches) == null ? void 0 : n.find((r) => r.name === e);
|
|
175
175
|
}
|
|
176
176
|
function z() {
|
|
177
177
|
var e;
|
|
178
178
|
return ((e = l.value.filters) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function g() {
|
|
181
181
|
var e;
|
|
182
182
|
return (e = l.value.sorts) == null ? void 0 : e.find(({ active: n }) => n);
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function w() {
|
|
185
185
|
var e;
|
|
186
186
|
return ((e = l.value.searches) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
|
|
187
187
|
}
|
|
188
188
|
function y(e) {
|
|
189
189
|
return e ? typeof e == "string" ? z().some((n) => n.name === e) : e.active : !!z().length;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function K(e) {
|
|
192
192
|
var n;
|
|
193
|
-
return e ? typeof e == "string" ? ((n =
|
|
193
|
+
return e ? typeof e == "string" ? ((n = g()) == null ? void 0 : n.name) === e : e.active : !!g();
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
var n,
|
|
197
|
-
return e ? typeof e == "string" ? (
|
|
195
|
+
function P(e) {
|
|
196
|
+
var n, r;
|
|
197
|
+
return e ? typeof e == "string" ? (r = w()) == null ? void 0 : r.some((c) => c.name === e) : e.active : !!((n = w()) != null && n.length);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
const
|
|
201
|
-
Object.entries(e).map(([c,
|
|
199
|
+
function G(e, n = {}) {
|
|
200
|
+
const r = Object.fromEntries(
|
|
201
|
+
Object.entries(e).map(([c, E]) => [c, k(E)])
|
|
202
202
|
);
|
|
203
203
|
S.reload({
|
|
204
204
|
...v,
|
|
205
205
|
...n,
|
|
206
|
-
data:
|
|
206
|
+
data: r
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
function L(e, n,
|
|
210
|
-
const c = typeof e == "string" ?
|
|
209
|
+
function L(e, n, r = {}) {
|
|
210
|
+
const c = typeof e == "string" ? p(e) : e;
|
|
211
211
|
if (!c) {
|
|
212
212
|
console.warn(`Filter [${e}] does not exist.`);
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
|
-
"multiple" in c && c.multiple && (n = s(n, c.value)), S.reload({
|
|
215
|
+
"multiple" in c && c.multiple && n !== void 0 && (n = s(n, c.value)), S.reload({
|
|
216
216
|
...v,
|
|
217
|
-
...
|
|
217
|
+
...r,
|
|
218
218
|
data: {
|
|
219
219
|
[c.name]: k(n)
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
|
-
function M(e, n = null,
|
|
224
|
-
const c = typeof e == "string" ?
|
|
223
|
+
function M(e, n = null, r = {}) {
|
|
224
|
+
const c = typeof e == "string" ? j(e, n) : e;
|
|
225
225
|
if (!c) {
|
|
226
226
|
console.warn(`Sort [${e}] does not exist.`);
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
229
|
S.reload({
|
|
230
230
|
...v,
|
|
231
|
-
...
|
|
231
|
+
...r,
|
|
232
232
|
data: {
|
|
233
233
|
[l.value.config.sorts]: x(c.next)
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function T(e, n = {}) {
|
|
238
238
|
e = [A, x].reduce(
|
|
239
|
-
(
|
|
239
|
+
(r, c) => c(r),
|
|
240
240
|
e
|
|
241
241
|
), S.reload({
|
|
242
242
|
...v,
|
|
@@ -255,22 +255,22 @@ function ee(o, f, v = {}) {
|
|
|
255
255
|
console.warn(`Match [${e}] does not exist.`);
|
|
256
256
|
return;
|
|
257
257
|
}
|
|
258
|
-
const
|
|
258
|
+
const r = s(
|
|
259
259
|
e,
|
|
260
|
-
|
|
260
|
+
w().filter(({ active: c }) => c).map(({ name: c }) => c)
|
|
261
261
|
);
|
|
262
262
|
S.reload({
|
|
263
263
|
...v,
|
|
264
264
|
...n,
|
|
265
265
|
data: {
|
|
266
|
-
[l.value.config.matches]: d(
|
|
266
|
+
[l.value.config.matches]: d(r)
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function N(e, n = {}) {
|
|
271
271
|
L(e, void 0, n);
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function W(e = {}) {
|
|
274
274
|
S.reload({
|
|
275
275
|
...v,
|
|
276
276
|
...e,
|
|
@@ -279,10 +279,10 @@ function ee(o, f, v = {}) {
|
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
|
|
282
|
+
function R(e = {}) {
|
|
283
|
+
T(void 0, e);
|
|
284
284
|
}
|
|
285
|
-
function
|
|
285
|
+
function D(e = {}) {
|
|
286
286
|
if (!l.value.config.matches) {
|
|
287
287
|
console.warn("Matches key is not set.");
|
|
288
288
|
return;
|
|
@@ -291,11 +291,11 @@ function ee(o, f, v = {}) {
|
|
|
291
291
|
...v,
|
|
292
292
|
...e,
|
|
293
293
|
data: {
|
|
294
|
-
[l.value.config.matches]:
|
|
294
|
+
[l.value.config.matches]: void 0
|
|
295
295
|
}
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function t(e = {}) {
|
|
299
299
|
var n;
|
|
300
300
|
S.reload({
|
|
301
301
|
...v,
|
|
@@ -304,8 +304,8 @@ function ee(o, f, v = {}) {
|
|
|
304
304
|
[l.value.config.searches]: void 0,
|
|
305
305
|
[l.value.config.sorts]: void 0,
|
|
306
306
|
...Object.fromEntries(
|
|
307
|
-
((n = l.value.filters) == null ? void 0 : n.map((
|
|
308
|
-
|
|
307
|
+
((n = l.value.filters) == null ? void 0 : n.map((r) => [
|
|
308
|
+
r.name,
|
|
309
309
|
void 0
|
|
310
310
|
])) ?? []
|
|
311
311
|
),
|
|
@@ -313,135 +313,140 @@ function ee(o, f, v = {}) {
|
|
|
313
313
|
}
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
const
|
|
318
|
-
if (!
|
|
316
|
+
function a(e, n = {}) {
|
|
317
|
+
const r = typeof e == "string" ? p(e) : e;
|
|
318
|
+
if (!r) {
|
|
319
319
|
console.warn(`Filter [${e}] does not exist.`);
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
const c =
|
|
323
|
-
debounce:
|
|
324
|
-
transform:
|
|
325
|
-
|
|
322
|
+
const c = r.value, {
|
|
323
|
+
debounce: E = 250,
|
|
324
|
+
transform: B = (H) => H,
|
|
325
|
+
...$
|
|
326
326
|
} = n;
|
|
327
327
|
return {
|
|
328
|
-
"onUpdate:modelValue":
|
|
329
|
-
L(
|
|
330
|
-
},
|
|
331
|
-
modelValue: c
|
|
332
|
-
value: c
|
|
328
|
+
"onUpdate:modelValue": q((H) => {
|
|
329
|
+
L(r, B(H), $);
|
|
330
|
+
}, E),
|
|
331
|
+
modelValue: c
|
|
333
332
|
};
|
|
334
333
|
}
|
|
335
|
-
function
|
|
336
|
-
const
|
|
337
|
-
if (!
|
|
334
|
+
function f(e, n = {}) {
|
|
335
|
+
const r = typeof e == "string" ? j(e) : e;
|
|
336
|
+
if (!r) {
|
|
338
337
|
console.warn(`Sort [${e}] does not exist.`);
|
|
339
338
|
return;
|
|
340
339
|
}
|
|
341
|
-
const { debounce: c = 0, transform:
|
|
340
|
+
const { debounce: c = 0, transform: E, ...B } = n;
|
|
342
341
|
return {
|
|
343
|
-
onClick:
|
|
344
|
-
var
|
|
345
|
-
M(
|
|
342
|
+
onClick: q(() => {
|
|
343
|
+
var $;
|
|
344
|
+
M(r, ($ = g()) == null ? void 0 : $.direction, B);
|
|
346
345
|
}, c)
|
|
347
346
|
};
|
|
348
347
|
}
|
|
349
|
-
function
|
|
350
|
-
const { debounce: n = 700, transform:
|
|
348
|
+
function V(e = {}) {
|
|
349
|
+
const { debounce: n = 700, transform: r, ...c } = e;
|
|
351
350
|
return {
|
|
352
|
-
"onUpdate:modelValue":
|
|
353
|
-
|
|
354
|
-
|
|
351
|
+
"onUpdate:modelValue": q(
|
|
352
|
+
(E) => {
|
|
353
|
+
T(E, c);
|
|
354
|
+
},
|
|
355
|
+
n
|
|
356
|
+
),
|
|
355
357
|
modelValue: l.value.config.search ?? ""
|
|
356
358
|
};
|
|
357
359
|
}
|
|
358
|
-
function
|
|
359
|
-
const
|
|
360
|
-
if (!
|
|
360
|
+
function F(e, n = {}) {
|
|
361
|
+
const r = typeof e == "string" ? C(e) : e;
|
|
362
|
+
if (!r) {
|
|
361
363
|
console.warn(`Match [${e}] does not exist.`);
|
|
362
364
|
return;
|
|
363
365
|
}
|
|
364
|
-
const { debounce: c = 0, transform:
|
|
366
|
+
const { debounce: c = 0, transform: E, ...B } = n;
|
|
365
367
|
return {
|
|
366
|
-
"onUpdate:modelValue":
|
|
367
|
-
U(
|
|
368
|
+
"onUpdate:modelValue": q(($) => {
|
|
369
|
+
U($, B);
|
|
368
370
|
}, c),
|
|
369
|
-
modelValue:
|
|
371
|
+
modelValue: P(r),
|
|
372
|
+
value: r.name
|
|
370
373
|
};
|
|
371
374
|
}
|
|
372
375
|
return {
|
|
373
376
|
filters: i,
|
|
374
377
|
sorts: u,
|
|
375
378
|
searches: b,
|
|
376
|
-
getFilter:
|
|
377
|
-
getSort:
|
|
379
|
+
getFilter: p,
|
|
380
|
+
getSort: j,
|
|
378
381
|
getSearch: C,
|
|
379
382
|
currentFilters: z,
|
|
380
|
-
currentSort:
|
|
381
|
-
currentSearches:
|
|
383
|
+
currentSort: g,
|
|
384
|
+
currentSearches: w,
|
|
382
385
|
isFiltering: y,
|
|
383
|
-
isSorting:
|
|
384
|
-
isSearching:
|
|
385
|
-
apply:
|
|
386
|
+
isSorting: K,
|
|
387
|
+
isSearching: P,
|
|
388
|
+
apply: G,
|
|
386
389
|
applyFilter: L,
|
|
387
390
|
applySort: M,
|
|
388
|
-
applySearch:
|
|
391
|
+
applySearch: T,
|
|
389
392
|
applyMatch: U,
|
|
390
|
-
clearFilter:
|
|
391
|
-
clearSort:
|
|
392
|
-
clearSearch:
|
|
393
|
-
clearMatch:
|
|
394
|
-
reset:
|
|
395
|
-
bindFilter:
|
|
396
|
-
bindSort:
|
|
397
|
-
bindSearch:
|
|
398
|
-
bindMatch:
|
|
393
|
+
clearFilter: N,
|
|
394
|
+
clearSort: W,
|
|
395
|
+
clearSearch: R,
|
|
396
|
+
clearMatch: D,
|
|
397
|
+
reset: t,
|
|
398
|
+
bindFilter: a,
|
|
399
|
+
bindSort: f,
|
|
400
|
+
bindSearch: V,
|
|
401
|
+
bindMatch: F,
|
|
399
402
|
stringValue: A,
|
|
400
403
|
omitValue: x,
|
|
401
404
|
toggleValue: s,
|
|
402
405
|
delimitArray: d
|
|
403
406
|
};
|
|
404
407
|
}
|
|
405
|
-
function le(o,
|
|
408
|
+
function le(o, m, v = {}, l = {}) {
|
|
409
|
+
if (!o || !m || !o[m])
|
|
410
|
+
throw new Error("Table has not been provided with valid props and key.");
|
|
406
411
|
l = {
|
|
407
412
|
...l,
|
|
408
|
-
only: [...l.only ?? [],
|
|
413
|
+
only: [...l.only ?? [], m.toString()]
|
|
409
414
|
};
|
|
410
|
-
const i = h(() => o[
|
|
415
|
+
const i = h(() => o[m]), u = X(), b = ee(o, m, l), d = h(() => i.value.config), A = h(() => i.value.meta), x = h(
|
|
411
416
|
() => {
|
|
412
417
|
var t;
|
|
413
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active:
|
|
414
|
-
var
|
|
418
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: a, hidden: f }) => a && !f).map((a) => {
|
|
419
|
+
var f;
|
|
415
420
|
return {
|
|
416
|
-
...
|
|
417
|
-
isSorting: (
|
|
418
|
-
toggleSort: (
|
|
421
|
+
...a,
|
|
422
|
+
isSorting: (f = a.sort) == null ? void 0 : f.active,
|
|
423
|
+
toggleSort: (V = {}) => U(a, V)
|
|
419
424
|
};
|
|
420
425
|
})) ?? [];
|
|
421
426
|
}
|
|
422
427
|
), k = h(
|
|
423
428
|
() => {
|
|
424
429
|
var t;
|
|
425
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden:
|
|
426
|
-
...
|
|
427
|
-
toggle: (
|
|
430
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: a }) => !a).map((a) => ({
|
|
431
|
+
...a,
|
|
432
|
+
toggle: (f = {}) => N(a, f)
|
|
428
433
|
}))) ?? [];
|
|
429
434
|
}
|
|
430
435
|
), s = h(
|
|
431
436
|
() => i.value.records.map((t) => ({
|
|
432
|
-
...t,
|
|
437
|
+
record: (({ actions: a, ...f }) => f)(t),
|
|
433
438
|
/** Perform this action when the record is clicked */
|
|
434
|
-
default: (
|
|
435
|
-
const
|
|
436
|
-
(
|
|
439
|
+
default: (a = {}) => {
|
|
440
|
+
const f = t.actions.find(
|
|
441
|
+
(V) => V.default
|
|
437
442
|
);
|
|
438
|
-
|
|
443
|
+
f && G(f, t, a);
|
|
439
444
|
},
|
|
440
445
|
/** The actions available for the record */
|
|
441
|
-
actions: t.actions.map((
|
|
442
|
-
...
|
|
446
|
+
actions: t.actions.map((a) => ({
|
|
447
|
+
...a,
|
|
443
448
|
/** Executes this action */
|
|
444
|
-
execute: (
|
|
449
|
+
execute: (f = {}) => G(a, t, f)
|
|
445
450
|
})),
|
|
446
451
|
/** Selects this record */
|
|
447
452
|
select: () => u.select(y(t)),
|
|
@@ -452,79 +457,92 @@ function le(o, f, v = {}, l = {}) {
|
|
|
452
457
|
/** Determine if the record is selected */
|
|
453
458
|
selected: u.selected(y(t)),
|
|
454
459
|
/** Bind the record to a checkbox */
|
|
455
|
-
bind: () => u.bind(y(t))
|
|
460
|
+
bind: () => u.bind(y(t)),
|
|
461
|
+
/** Get the value of the record for the column */
|
|
462
|
+
value: (a) => t[K(a)].value,
|
|
463
|
+
/** Get the extra data of the record for the column */
|
|
464
|
+
extra: (a) => t[K(a)].extra
|
|
456
465
|
}))
|
|
457
|
-
),
|
|
466
|
+
), p = h(
|
|
458
467
|
() => i.value.actions.bulk.map((t) => ({
|
|
459
468
|
...t,
|
|
460
469
|
/** Executes this bulk action */
|
|
461
|
-
execute: (
|
|
470
|
+
execute: (a = {}) => L(t, a)
|
|
462
471
|
}))
|
|
463
|
-
),
|
|
472
|
+
), j = h(
|
|
464
473
|
() => i.value.actions.page.map((t) => ({
|
|
465
474
|
...t,
|
|
466
475
|
/** Executes this page action */
|
|
467
|
-
execute: (
|
|
476
|
+
execute: (a = {}) => M(t, a)
|
|
468
477
|
}))
|
|
469
478
|
), C = h(
|
|
470
|
-
() =>
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
479
|
+
() => {
|
|
480
|
+
var t;
|
|
481
|
+
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((a) => ({
|
|
482
|
+
...a,
|
|
483
|
+
/** Changes the number of records to display per page */
|
|
484
|
+
apply: (f = {}) => T(a, f)
|
|
485
|
+
}))) ?? [];
|
|
486
|
+
}
|
|
475
487
|
), z = h(
|
|
476
|
-
() =>
|
|
477
|
-
|
|
488
|
+
() => {
|
|
489
|
+
var t;
|
|
490
|
+
return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: a }) => a);
|
|
491
|
+
}
|
|
492
|
+
), g = h(() => ({
|
|
478
493
|
...i.value.paginator,
|
|
479
494
|
next: (t = {}) => {
|
|
480
|
-
"nextLink" in
|
|
495
|
+
"nextLink" in g.value && g.value.nextLink && P(g.value.nextLink, t);
|
|
481
496
|
},
|
|
482
497
|
previous: (t = {}) => {
|
|
483
|
-
"prevLink" in
|
|
498
|
+
"prevLink" in g.value && g.value.prevLink && P(g.value.prevLink, t);
|
|
484
499
|
},
|
|
485
500
|
first: (t = {}) => {
|
|
486
|
-
"firstLink" in
|
|
501
|
+
"firstLink" in g.value && g.value.firstLink && P(g.value.firstLink, t);
|
|
487
502
|
},
|
|
488
503
|
last: (t = {}) => {
|
|
489
|
-
"lastLink" in
|
|
504
|
+
"lastLink" in g.value && g.value.lastLink && P(g.value.lastLink, t);
|
|
490
505
|
},
|
|
491
506
|
..."links" in i.value.paginator && i.value.paginator.links ? {
|
|
492
507
|
links: i.value.paginator.links.map((t) => ({
|
|
493
508
|
...t,
|
|
494
|
-
navigate: (
|
|
509
|
+
navigate: (a = {}) => t.url && P(t.url, a)
|
|
495
510
|
}))
|
|
496
511
|
} : {}
|
|
497
|
-
})),
|
|
512
|
+
})), w = h(
|
|
498
513
|
() => i.value.records.length > 0 && i.value.records.every(
|
|
499
514
|
(t) => u.selected(y(t))
|
|
500
515
|
)
|
|
501
516
|
);
|
|
502
517
|
function y(t) {
|
|
503
|
-
return t[d.value.record];
|
|
518
|
+
return t[d.value.record].value;
|
|
504
519
|
}
|
|
505
|
-
function
|
|
520
|
+
function K(t) {
|
|
521
|
+
return typeof t == "string" ? t : t.name;
|
|
522
|
+
}
|
|
523
|
+
function P(t, a = {}) {
|
|
506
524
|
S.visit(t, {
|
|
507
525
|
preserveScroll: !0,
|
|
508
526
|
preserveState: !0,
|
|
509
527
|
...l,
|
|
510
|
-
...
|
|
528
|
+
...a,
|
|
511
529
|
method: "get"
|
|
512
530
|
});
|
|
513
531
|
}
|
|
514
|
-
function
|
|
515
|
-
var
|
|
516
|
-
|
|
532
|
+
function G(t, a, f = {}) {
|
|
533
|
+
var F, e;
|
|
534
|
+
I(
|
|
517
535
|
t,
|
|
518
536
|
d.value.endpoint,
|
|
519
537
|
{
|
|
520
538
|
table: i.value.id,
|
|
521
|
-
id: y(
|
|
539
|
+
id: y(a)
|
|
522
540
|
},
|
|
523
|
-
|
|
524
|
-
) || (
|
|
541
|
+
f
|
|
542
|
+
) || (e = (F = v.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F, a);
|
|
525
543
|
}
|
|
526
|
-
function
|
|
527
|
-
|
|
544
|
+
function L(t, a = {}) {
|
|
545
|
+
I(
|
|
528
546
|
t,
|
|
529
547
|
d.value.endpoint,
|
|
530
548
|
{
|
|
@@ -533,67 +551,71 @@ function le(o, f, v = {}, l = {}) {
|
|
|
533
551
|
only: Array.from(u.selection.value.only),
|
|
534
552
|
except: Array.from(u.selection.value.except)
|
|
535
553
|
},
|
|
536
|
-
|
|
554
|
+
a
|
|
537
555
|
);
|
|
538
556
|
}
|
|
539
|
-
function
|
|
540
|
-
|
|
557
|
+
function M(t, a = {}) {
|
|
558
|
+
I(
|
|
541
559
|
t,
|
|
542
560
|
d.value.endpoint,
|
|
543
561
|
{
|
|
544
562
|
table: i.value.id
|
|
545
563
|
},
|
|
546
|
-
|
|
564
|
+
a
|
|
547
565
|
);
|
|
548
566
|
}
|
|
549
|
-
function
|
|
567
|
+
function T(t, a = {}) {
|
|
550
568
|
S.reload({
|
|
551
569
|
...l,
|
|
552
|
-
...
|
|
570
|
+
...a,
|
|
553
571
|
data: {
|
|
554
572
|
[d.value.records]: t.value,
|
|
555
573
|
[d.value.pages]: void 0
|
|
556
574
|
}
|
|
557
575
|
});
|
|
558
576
|
}
|
|
559
|
-
function
|
|
577
|
+
function U(t, a = {}) {
|
|
560
578
|
t.sort && S.reload({
|
|
561
579
|
...l,
|
|
562
|
-
...
|
|
580
|
+
...a,
|
|
563
581
|
data: {
|
|
564
582
|
[d.value.sorts]: b.omitValue(t.sort.next)
|
|
565
583
|
}
|
|
566
584
|
});
|
|
567
585
|
}
|
|
568
|
-
function
|
|
569
|
-
const
|
|
586
|
+
function N(t, a = {}) {
|
|
587
|
+
const f = b.toggleValue(
|
|
570
588
|
t.name,
|
|
571
|
-
x.value.map(({ name:
|
|
589
|
+
x.value.map(({ name: V }) => V)
|
|
572
590
|
);
|
|
573
591
|
S.reload({
|
|
574
592
|
...l,
|
|
575
|
-
...
|
|
593
|
+
...a,
|
|
576
594
|
data: {
|
|
577
|
-
[d.value.columns]: b.delimitArray(
|
|
595
|
+
[d.value.columns]: b.delimitArray(f)
|
|
578
596
|
}
|
|
579
597
|
});
|
|
580
598
|
}
|
|
581
599
|
function W() {
|
|
582
600
|
u.select(
|
|
583
|
-
...i.value.records.map(
|
|
601
|
+
...i.value.records.map(
|
|
602
|
+
(t) => y(t)
|
|
603
|
+
)
|
|
584
604
|
);
|
|
585
605
|
}
|
|
586
|
-
function
|
|
606
|
+
function R() {
|
|
587
607
|
u.deselect(
|
|
588
|
-
...i.value.records.map(
|
|
608
|
+
...i.value.records.map(
|
|
609
|
+
(t) => y(t)
|
|
610
|
+
)
|
|
589
611
|
);
|
|
590
612
|
}
|
|
591
|
-
function
|
|
613
|
+
function D() {
|
|
592
614
|
return {
|
|
593
615
|
"onUpdate:modelValue": (t) => {
|
|
594
|
-
t ? W() :
|
|
616
|
+
t ? W() : R();
|
|
595
617
|
},
|
|
596
|
-
modelValue:
|
|
618
|
+
modelValue: w.value
|
|
597
619
|
};
|
|
598
620
|
}
|
|
599
621
|
return Q({
|
|
@@ -608,23 +630,23 @@ function le(o, f, v = {}, l = {}) {
|
|
|
608
630
|
/** The records of the table */
|
|
609
631
|
records: s,
|
|
610
632
|
/** The available bulk actions */
|
|
611
|
-
bulkActions:
|
|
633
|
+
bulkActions: p,
|
|
612
634
|
/** The available page actions */
|
|
613
|
-
pageActions:
|
|
635
|
+
pageActions: j,
|
|
614
636
|
/** The available number of records to display per page */
|
|
615
637
|
rowsPerPage: C,
|
|
616
638
|
/** The current record per page item */
|
|
617
639
|
currentPage: z,
|
|
618
640
|
/** The pagination metadata */
|
|
619
|
-
paginator:
|
|
641
|
+
paginator: g,
|
|
620
642
|
/** Execute an inline action */
|
|
621
|
-
executeInlineAction:
|
|
643
|
+
executeInlineAction: G,
|
|
622
644
|
/** Execute a bulk action */
|
|
623
|
-
executeBulkAction:
|
|
645
|
+
executeBulkAction: L,
|
|
624
646
|
/** Execute a page action */
|
|
625
|
-
executePageAction:
|
|
647
|
+
executePageAction: M,
|
|
626
648
|
/** Apply a new page by changing the number of records to display */
|
|
627
|
-
applyPage:
|
|
649
|
+
applyPage: T,
|
|
628
650
|
/** The current selection of records */
|
|
629
651
|
selection: u.selection,
|
|
630
652
|
/** Select the given records */
|
|
@@ -634,7 +656,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
634
656
|
/** Select records on the current page */
|
|
635
657
|
selectPage: W,
|
|
636
658
|
/** Deselect records on the current page */
|
|
637
|
-
deselectPage:
|
|
659
|
+
deselectPage: R,
|
|
638
660
|
/** Toggle the selection of the given records */
|
|
639
661
|
toggle: (t) => u.toggle(y(t)),
|
|
640
662
|
/** Determine if the given record is selected */
|
|
@@ -644,13 +666,13 @@ function le(o, f, v = {}, l = {}) {
|
|
|
644
666
|
/** Deselect all records */
|
|
645
667
|
deselectAll: u.deselectAll,
|
|
646
668
|
/** Whether all records on the current page are selected */
|
|
647
|
-
isPageSelected:
|
|
669
|
+
isPageSelected: w,
|
|
648
670
|
/** Determine if any records are selected */
|
|
649
671
|
hasSelected: u.hasSelected,
|
|
650
672
|
/** Bind the given record to a checkbox */
|
|
651
673
|
bindCheckbox: (t) => u.bind(y(t)),
|
|
652
674
|
/** Bind the select all checkbox to the current page */
|
|
653
|
-
bindPage:
|
|
675
|
+
bindPage: D,
|
|
654
676
|
/** Bind select all records to the checkbox */
|
|
655
677
|
bindAll: u.bindAll,
|
|
656
678
|
/** Include the sorts, filters, and search query */
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(P,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],d):(P=typeof globalThis<"u"?globalThis:P||self,d(P["@honed/table"]={},P.Vue,P.Inertia))})(this,function(P,d,b){"use strict";function _(){const a=d.ref({all:!1,only:new Set,except:new Set});function p(){a.value.all=!0,a.value.only.clear(),a.value.except.clear()}function f(){a.value.all=!1,a.value.only.clear(),a.value.except.clear()}function l(...s){s.forEach(m=>a.value.except.delete(m)),s.forEach(m=>a.value.only.add(m))}function i(...s){s.forEach(m=>a.value.except.add(m)),s.forEach(m=>a.value.only.delete(m))}function u(s,m){if(x(s)||m===!1)return i(s);if(!x(s)||m===!0)return l(s)}function x(s){return a.value.all?!a.value.except.has(s):a.value.only.has(s)}const v=d.computed(()=>a.value.all&&a.value.except.size===0),A=d.computed(()=>a.value.only.size>0||v.value);function S(s){return{"onUpdate:modelValue":m=>{m?l(s):i(s)},modelValue:x(s),value:s}}function k(){return{"onUpdate:modelValue":s=>{s?p():f()},modelValue:v.value,value:v.value}}return{allSelected:v,selection:a,hasSelected:A,selectAll:p,deselectAll:f,select:l,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function H(a,p,f={},l={}){return a.route?(b.router.visit(a.route.href,{...l,method:a.route.method}),!0):a.action&&p?(b.router.post(p,{...f,name:a.name,type:a.type},l),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(a,p){function f(...l){return new Promise((i,u)=>{Promise.resolve(a(()=>p.apply(this,l),{fn:p,thisArg:this,args:l})).then(i).catch(u)})}return f}function X(a,p={}){let f,l,i=Y;const u=v=>{clearTimeout(v),i(),i=Y};let x;return v=>{const A=d.toValue(a),S=d.toValue(p.maxWait);return f&&u(f),A<=0||S!==void 0&&S<=0?(l&&(u(l),l=null),Promise.resolve(v())):new Promise((k,s)=>{i=p.rejectOnCancel?s:k,x=v,S&&!l&&(l=setTimeout(()=>{f&&u(f),l=null,k(x())},S)),f=setTimeout(()=>{l&&u(l),l=null,k(v())},A)})}}function R(a,p=200,f={}){return Q(X(p,f),a)}function Z(a,p,f={}){const l=d.computed(()=>a[p]),i=d.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(o,c={})=>j(n,o,c),clear:(o={})=>W(n,o),bind:()=>h(n.name)})))??[]}),u=d.computed(()=>{var e;return((e=l.value.sorts)==null?void 0:e.map(n=>({...n,apply:(o={})=>M(n,n.direction,o),clear:(o={})=>B(o),bind:()=>V(n)})))??[]}),x=d.computed(()=>{var e;return(e=l.value.searches)==null?void 0:e.map(n=>({...n,apply:(o={})=>E(n,o),clear:(o={})=>E(n,o),bind:()=>I(n)}))});function v(e){return Array.isArray(e)?e.join(l.value.config.delimiter):e}function A(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function S(e){if(!["",null,void 0,[]].includes(e))return e}function k(e){return[v,A,S].reduce((n,o)=>o(n),e)}function s(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(o=>o!==e):[...n,e]}function m(e){var n;return(n=l.value.filters)==null?void 0:n.find(o=>o.name===e)}function C(e,n=null){var o;return(o=l.value.sorts)==null?void 0:o.find(c=>c.name===e&&c.direction===n)}function q(e){var n;return(n=l.value.searches)==null?void 0:n.find(o=>o.name===e)}function z(){var e;return((e=l.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}function g(){var e;return(e=l.value.sorts)==null?void 0:e.find(({active:n})=>n)}function w(){var e;return((e=l.value.searches)==null?void 0:e.filter(({active:n})=>n))??[]}function y(e){return e?typeof e=="string"?z().some(n=>n.name===e):e.active:!!z().length}function L(e){var n;return e?typeof e=="string"?((n=g())==null?void 0:n.name)===e:e.active:!!g()}function F(e){var n,o;return e?typeof e=="string"?(o=w())==null?void 0:o.some(c=>c.name===e):e.active:!!((n=w())!=null&&n.length)}function D(e,n={}){const o=Object.fromEntries(Object.entries(e).map(([c,T])=>[c,k(T)]));b.router.reload({...f,...n,data:o})}function j(e,n,o={}){const c=typeof e=="string"?m(e):e;if(!c){console.warn(`Filter [${e}] does not exist.`);return}"multiple"in c&&c.multiple&&(n=s(n,c.value)),b.router.reload({...f,...o,data:{[c.name]:k(n)}})}function M(e,n=null,o={}){const c=typeof e=="string"?C(e,n):e;if(!c){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...f,...o,data:{[l.value.config.sorts]:S(c.next)}})}function G(e,n={}){e=[A,S].reduce((o,c)=>c(o),e),b.router.reload({...f,...n,data:{[l.value.config.searches]:e}})}function E(e,n={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}if(!(typeof e=="string"?q(e):e)){console.warn(`Match [${e}] does not exist.`);return}const o=s(e,w().filter(({active:c})=>c).map(({name:c})=>c));b.router.reload({...f,...n,data:{[l.value.config.matches]:v(o)}})}function W(e,n={}){j(e,void 0,n)}function B(e={}){b.router.reload({...f,...e,data:{[l.value.config.sorts]:null}})}function J(e={}){G(void 0,e)}function t(e={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}b.router.reload({...f,...e,data:{[l.value.config.matches]:null}})}function r(e={}){var n;b.router.reload({...f,...e,data:{[l.value.config.searches]:void 0,[l.value.config.sorts]:void 0,...Object.fromEntries(((n=l.value.filters)==null?void 0:n.map(o=>[o.name,void 0]))??[]),...l.value.config.matches?{[l.value.config.matches]:void 0}:{}}})}function h(e,n={}){const o=typeof e=="string"?m(e):e;if(!o){console.warn(`Filter [${e}] does not exist.`);return}const c=o.value,{debounce:T=250,transform:K=N=>N,...$}=n;return{"onUpdate:modelValue":R(N=>{j(o,K(N),$)},T),modelValue:c,value:c}}function V(e,n={}){const o=typeof e=="string"?C(e):e;if(!o){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:c=0,transform:T,...K}=n;return{onClick:R(()=>{var $;M(o,($=g())==null?void 0:$.direction,K)},c)}}function U(e={}){const{debounce:n=700,transform:o,...c}=e;return{"onUpdate:modelValue":R(T=>{G(T,c)},n),modelValue:l.value.config.search??""}}function I(e,n={}){const o=typeof e=="string"?q(e):e;if(!o){console.warn(`Match [${e}] does not exist.`);return}const{debounce:c=0,transform:T,...K}=n;return{"onUpdate:modelValue":R($=>{E($,K)},c),modelValue:F(o)}}return{filters:i,sorts:u,searches:x,getFilter:m,getSort:C,getSearch:q,currentFilters:z,currentSort:g,currentSearches:w,isFiltering:y,isSorting:L,isSearching:F,apply:D,applyFilter:j,applySort:M,applySearch:G,applyMatch:E,clearFilter:W,clearSort:B,clearSearch:J,clearMatch:t,reset:r,bindFilter:h,bindSort:V,bindSearch:U,bindMatch:I,stringValue:A,omitValue:S,toggleValue:s,delimitArray:v}}function O(a,p,f={},l={}){l={...l,only:[...l.only??[],p.toString()]};const i=d.computed(()=>a[p]),u=_(),x=Z(a,p,l),v=d.computed(()=>i.value.config),A=d.computed(()=>i.value.meta),S=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:r,hidden:h})=>r&&!h).map(r=>{var h;return{...r,isSorting:(h=r.sort)==null?void 0:h.active,toggleSort:(V={})=>G(r,V)}}))??[]}),k=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:r})=>!r).map(r=>({...r,toggle:(h={})=>E(r,h)})))??[]}),s=d.computed(()=>i.value.records.map(t=>({...t,default:(r={})=>{const h=t.actions.find(V=>V.default);h&&F(h,t,r)},actions:t.actions.map(r=>({...r,execute:(h={})=>F(r,t,h)})),select:()=>u.select(y(t)),deselect:()=>u.deselect(y(t)),toggle:()=>u.toggle(y(t)),selected:u.selected(y(t)),bind:()=>u.bind(y(t))}))),m=d.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(r={})=>D(t,r)}))),C=d.computed(()=>i.value.actions.page.map(t=>({...t,execute:(r={})=>j(t,r)}))),q=d.computed(()=>i.value.recordsPerPage.map(t=>({...t,apply:(r={})=>M(t,r)}))),z=d.computed(()=>i.value.recordsPerPage.find(({active:t})=>t)),g=d.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in g.value&&g.value.nextLink&&L(g.value.nextLink,t)},previous:(t={})=>{"prevLink"in g.value&&g.value.prevLink&&L(g.value.prevLink,t)},first:(t={})=>{"firstLink"in g.value&&g.value.firstLink&&L(g.value.firstLink,t)},last:(t={})=>{"lastLink"in g.value&&g.value.lastLink&&L(g.value.lastLink,t)},..."links"in i.value.paginator&&i.value.paginator.links?{links:i.value.paginator.links.map(t=>({...t,navigate:(r={})=>t.url&&L(t.url,r)}))}:{}})),w=d.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[v.value.record]}function L(t,r={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...r,method:"get"})}function F(t,r,h={}){var U,I;H(t,v.value.endpoint,{table:i.value.id,id:y(r)},h)||(I=(U=f.recordActions)==null?void 0:U[t.name])==null||I.call(U,r)}function D(t,r={}){H(t,v.value.endpoint,{table:i.value.id,all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)},r)}function j(t,r={}){H(t,v.value.endpoint,{table:i.value.id},r)}function M(t,r={}){b.router.reload({...l,...r,data:{[v.value.records]:t.value,[v.value.pages]:void 0}})}function G(t,r={}){t.sort&&b.router.reload({...l,...r,data:{[v.value.sorts]:x.omitValue(t.sort.next)}})}function E(t,r={}){const h=x.toggleValue(t.name,S.value.map(({name:V})=>V));b.router.reload({...l,...r,data:{[v.value.columns]:x.delimitArray(h)}})}function W(){u.select(...i.value.records.map(t=>y(t)))}function B(){u.deselect(...i.value.records.map(t=>y(t)))}function J(){return{"onUpdate:modelValue":t=>{t?W():B()},modelValue:w.value}}return d.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:m,pageActions:C,rowsPerPage:q,currentPage:z,paginator:g,executeInlineAction:F,executeBulkAction:D,executePageAction:j,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:W,deselectPage:B,toggle:t=>u.toggle(y(t)),selected:t=>u.selected(y(t)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:w,hasSelected:u.hasSelected,bindCheckbox:t=>u.bind(y(t)),bindPage:J,bindAll:u.bindAll,...x})}P.useTable=O,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(V,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],d):(V=typeof globalThis<"u"?globalThis:V||self,d(V["@honed/table"]={},V.Vue,V.Inertia))})(this,function(V,d,b){"use strict";function _(){const r=d.ref({all:!1,only:new Set,except:new Set});function m(){r.value.all=!0,r.value.only.clear(),r.value.except.clear()}function f(){r.value.all=!1,r.value.only.clear(),r.value.except.clear()}function l(...s){s.forEach(g=>r.value.except.delete(g)),s.forEach(g=>r.value.only.add(g))}function i(...s){s.forEach(g=>r.value.except.add(g)),s.forEach(g=>r.value.only.delete(g))}function u(s,g){if(x(s)||g===!1)return i(s);if(!x(s)||g===!0)return l(s)}function x(s){return r.value.all?!r.value.except.has(s):r.value.only.has(s)}const v=d.computed(()=>r.value.all&&r.value.except.size===0),A=d.computed(()=>r.value.only.size>0||v.value);function S(s){return{"onUpdate:modelValue":g=>{g?l(s):i(s)},modelValue:x(s),value:s}}function k(){return{"onUpdate:modelValue":s=>{s?m():f()},modelValue:v.value,value:v.value}}return{allSelected:v,selection:r,hasSelected:A,selectAll:m,deselectAll:f,select:l,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function D(r,m,f={},l={}){return r.route?(b.router.visit(r.route.href,{...l,method:r.route.method}),!0):r.action&&m?(b.router.post(m,{...f,name:r.name,type:r.type},l),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(r,m){function f(...l){return new Promise((i,u)=>{Promise.resolve(r(()=>m.apply(this,l),{fn:m,thisArg:this,args:l})).then(i).catch(u)})}return f}function X(r,m={}){let f,l,i=Y;const u=v=>{clearTimeout(v),i(),i=Y};let x;return v=>{const A=d.toValue(r),S=d.toValue(m.maxWait);return f&&u(f),A<=0||S!==void 0&&S<=0?(l&&(u(l),l=null),Promise.resolve(v())):new Promise((k,s)=>{i=m.rejectOnCancel?s:k,x=v,S&&!l&&(l=setTimeout(()=>{f&&u(f),l=null,k(x())},S)),f=setTimeout(()=>{l&&u(l),l=null,k(v())},A)})}}function I(r,m=200,f={}){return Q(X(m,f),r)}function Z(r,m,f={}){const l=d.computed(()=>r[m]),i=d.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(o,c={})=>T(n,o,c),clear:(o={})=>N(n,o),bind:()=>a(n.name)})))??[]}),u=d.computed(()=>{var e;return((e=l.value.sorts)==null?void 0:e.map(n=>({...n,apply:(o={})=>E(n,n.direction,o),clear:(o={})=>W(o),bind:()=>p(n)})))??[]}),x=d.computed(()=>{var e;return(e=l.value.searches)==null?void 0:e.map(n=>({...n,apply:(o={})=>U(n,o),clear:(o={})=>U(n,o),bind:()=>j(n)}))});function v(e){return Array.isArray(e)?e.join(l.value.config.delimiter):e}function A(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function S(e){if(!["",null,void 0,[]].includes(e))return e}function k(e){return[v,A,S].reduce((n,o)=>o(n),e)}function s(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(o=>o!==e):[...n,e]}function g(e){var n;return(n=l.value.filters)==null?void 0:n.find(o=>o.name===e)}function C(e,n=null){var o;return(o=l.value.sorts)==null?void 0:o.find(c=>c.name===e&&c.direction===n)}function q(e){var n;return(n=l.value.searches)==null?void 0:n.find(o=>o.name===e)}function z(){var e;return((e=l.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}function h(){var e;return(e=l.value.sorts)==null?void 0:e.find(({active:n})=>n)}function L(){var e;return((e=l.value.searches)==null?void 0:e.filter(({active:n})=>n))??[]}function y(e){return e?typeof e=="string"?z().some(n=>n.name===e):e.active:!!z().length}function K(e){var n;return e?typeof e=="string"?((n=h())==null?void 0:n.name)===e:e.active:!!h()}function P(e){var n,o;return e?typeof e=="string"?(o=L())==null?void 0:o.some(c=>c.name===e):e.active:!!((n=L())!=null&&n.length)}function G(e,n={}){const o=Object.fromEntries(Object.entries(e).map(([c,F])=>[c,k(F)]));b.router.reload({...f,...n,data:o})}function T(e,n,o={}){const c=typeof e=="string"?g(e):e;if(!c){console.warn(`Filter [${e}] does not exist.`);return}"multiple"in c&&c.multiple&&n!==void 0&&(n=s(n,c.value)),b.router.reload({...f,...o,data:{[c.name]:k(n)}})}function E(e,n=null,o={}){const c=typeof e=="string"?C(e,n):e;if(!c){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...f,...o,data:{[l.value.config.sorts]:S(c.next)}})}function M(e,n={}){e=[A,S].reduce((o,c)=>c(o),e),b.router.reload({...f,...n,data:{[l.value.config.searches]:e}})}function U(e,n={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}if(!(typeof e=="string"?q(e):e)){console.warn(`Match [${e}] does not exist.`);return}const o=s(e,L().filter(({active:c})=>c).map(({name:c})=>c));b.router.reload({...f,...n,data:{[l.value.config.matches]:v(o)}})}function N(e,n={}){T(e,void 0,n)}function W(e={}){b.router.reload({...f,...e,data:{[l.value.config.sorts]:null}})}function R(e={}){M(void 0,e)}function H(e={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}b.router.reload({...f,...e,data:{[l.value.config.matches]:void 0}})}function t(e={}){var n;b.router.reload({...f,...e,data:{[l.value.config.searches]:void 0,[l.value.config.sorts]:void 0,...Object.fromEntries(((n=l.value.filters)==null?void 0:n.map(o=>[o.name,void 0]))??[]),...l.value.config.matches?{[l.value.config.matches]:void 0}:{}}})}function a(e,n={}){const o=typeof e=="string"?g(e):e;if(!o){console.warn(`Filter [${e}] does not exist.`);return}const c=o.value,{debounce:F=250,transform:B=J=>J,...$}=n;return{"onUpdate:modelValue":I(J=>{T(o,B(J),$)},F),modelValue:c}}function p(e,n={}){const o=typeof e=="string"?C(e):e;if(!o){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:c=0,transform:F,...B}=n;return{onClick:I(()=>{var $;E(o,($=h())==null?void 0:$.direction,B)},c)}}function w(e={}){const{debounce:n=700,transform:o,...c}=e;return{"onUpdate:modelValue":I(F=>{M(F,c)},n),modelValue:l.value.config.search??""}}function j(e,n={}){const o=typeof e=="string"?q(e):e;if(!o){console.warn(`Match [${e}] does not exist.`);return}const{debounce:c=0,transform:F,...B}=n;return{"onUpdate:modelValue":I($=>{U($,B)},c),modelValue:P(o),value:o.name}}return{filters:i,sorts:u,searches:x,getFilter:g,getSort:C,getSearch:q,currentFilters:z,currentSort:h,currentSearches:L,isFiltering:y,isSorting:K,isSearching:P,apply:G,applyFilter:T,applySort:E,applySearch:M,applyMatch:U,clearFilter:N,clearSort:W,clearSearch:R,clearMatch:H,reset:t,bindFilter:a,bindSort:p,bindSearch:w,bindMatch:j,stringValue:A,omitValue:S,toggleValue:s,delimitArray:v}}function O(r,m,f={},l={}){if(!r||!m||!r[m])throw new Error("Table has not been provided with valid props and key.");l={...l,only:[...l.only??[],m.toString()]};const i=d.computed(()=>r[m]),u=_(),x=Z(r,m,l),v=d.computed(()=>i.value.config),A=d.computed(()=>i.value.meta),S=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:a,hidden:p})=>a&&!p).map(a=>{var p;return{...a,isSorting:(p=a.sort)==null?void 0:p.active,toggleSort:(w={})=>U(a,w)}}))??[]}),k=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:a})=>!a).map(a=>({...a,toggle:(p={})=>N(a,p)})))??[]}),s=d.computed(()=>i.value.records.map(t=>({record:(({actions:a,...p})=>p)(t),default:(a={})=>{const p=t.actions.find(w=>w.default);p&&G(p,t,a)},actions:t.actions.map(a=>({...a,execute:(p={})=>G(a,t,p)})),select:()=>u.select(y(t)),deselect:()=>u.deselect(y(t)),toggle:()=>u.toggle(y(t)),selected:u.selected(y(t)),bind:()=>u.bind(y(t)),value:a=>t[K(a)].value,extra:a=>t[K(a)].extra}))),g=d.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(a={})=>T(t,a)}))),C=d.computed(()=>i.value.actions.page.map(t=>({...t,execute:(a={})=>E(t,a)}))),q=d.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(a=>({...a,apply:(p={})=>M(a,p)})))??[]}),z=d.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:a})=>a)}),h=d.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in h.value&&h.value.nextLink&&P(h.value.nextLink,t)},previous:(t={})=>{"prevLink"in h.value&&h.value.prevLink&&P(h.value.prevLink,t)},first:(t={})=>{"firstLink"in h.value&&h.value.firstLink&&P(h.value.firstLink,t)},last:(t={})=>{"lastLink"in h.value&&h.value.lastLink&&P(h.value.lastLink,t)},..."links"in i.value.paginator&&i.value.paginator.links?{links:i.value.paginator.links.map(t=>({...t,navigate:(a={})=>t.url&&P(t.url,a)}))}:{}})),L=d.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[v.value.record].value}function K(t){return typeof t=="string"?t:t.name}function P(t,a={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...a,method:"get"})}function G(t,a,p={}){var j,e;D(t,v.value.endpoint,{table:i.value.id,id:y(a)},p)||(e=(j=f.recordActions)==null?void 0:j[t.name])==null||e.call(j,a)}function T(t,a={}){D(t,v.value.endpoint,{table:i.value.id,all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)},a)}function E(t,a={}){D(t,v.value.endpoint,{table:i.value.id},a)}function M(t,a={}){b.router.reload({...l,...a,data:{[v.value.records]:t.value,[v.value.pages]:void 0}})}function U(t,a={}){t.sort&&b.router.reload({...l,...a,data:{[v.value.sorts]:x.omitValue(t.sort.next)}})}function N(t,a={}){const p=x.toggleValue(t.name,S.value.map(({name:w})=>w));b.router.reload({...l,...a,data:{[v.value.columns]:x.delimitArray(p)}})}function W(){u.select(...i.value.records.map(t=>y(t)))}function R(){u.deselect(...i.value.records.map(t=>y(t)))}function H(){return{"onUpdate:modelValue":t=>{t?W():R()},modelValue:L.value}}return d.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:g,pageActions:C,rowsPerPage:q,currentPage:z,paginator:h,executeInlineAction:G,executeBulkAction:T,executePageAction:E,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:W,deselectPage:R,toggle:t=>u.toggle(y(t)),selected:t=>u.selected(y(t)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:L,hasSelected:u.hasSelected,bindCheckbox:t=>u.bind(y(t)),bindPage:H,bindAll:u.bindAll,...x})}V.useTable=O,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honed/table",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "-",
|
|
7
7
|
"keywords": [
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "https://github.com/honedlabs/
|
|
32
|
+
"url": "https://github.com/honedlabs/honed.git"
|
|
33
33
|
},
|
|
34
|
-
"homepage": "https://github.com/honedlabs/table#readme",
|
|
34
|
+
"homepage": "https://github.com/honedlabs/honed/tree/main/packages/vue/table#readme",
|
|
35
35
|
"files": [
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
@@ -42,14 +42,23 @@
|
|
|
42
42
|
"exports": {
|
|
43
43
|
".": {
|
|
44
44
|
"types": "./dist/index.d.ts",
|
|
45
|
-
"import":
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"default": "./dist/index.es.js"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"default": "./dist/index.umd.js"
|
|
52
|
+
},
|
|
53
|
+
"default": {
|
|
54
|
+
"types": "./dist/index.d.ts",
|
|
55
|
+
"default": "./dist/index.es.js"
|
|
56
|
+
}
|
|
48
57
|
}
|
|
49
58
|
},
|
|
50
59
|
"peerDependencies": {
|
|
51
|
-
"@honed/action": "^0.2
|
|
52
|
-
"@honed/refine": "^0.
|
|
60
|
+
"@honed/action": "^0.3.2",
|
|
61
|
+
"@honed/refine": "^0.3.1",
|
|
53
62
|
"@inertiajs/vue3": "^1.2.0||^2.0.0",
|
|
54
63
|
"@vueuse/core": "^11.0.0||^12.0.0",
|
|
55
64
|
"axios": "^1.2.0",
|