@honed/table 0.2.1 → 0.3.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 +74 -46
- package/dist/index.es.js +216 -195
- 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,39 +87,51 @@ 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>;
|
|
113
|
+
}
|
|
114
|
+
|
|
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;
|
|
107
126
|
}
|
|
108
127
|
|
|
109
|
-
export declare function useTable<
|
|
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
137
|
multiple: boolean;
|
|
@@ -173,13 +191,12 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
173
191
|
bindFilter: <T_1 extends unknown>(filter: string | Filter, options?: BindingOptions | undefined) => {
|
|
174
192
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
175
193
|
modelValue: T_1;
|
|
176
|
-
value: T_1;
|
|
177
194
|
} | undefined;
|
|
178
195
|
bindSort: (sort: string | Sort, options?: BindingOptions | undefined) => {
|
|
179
196
|
onClick: PromisifyFn<() => void>;
|
|
180
197
|
} | undefined;
|
|
181
198
|
bindSearch: (options?: BindingOptions | undefined) => {
|
|
182
|
-
"onUpdate:modelValue": PromisifyFn<(value:
|
|
199
|
+
"onUpdate:modelValue": PromisifyFn<(value: string | null | undefined) => void>;
|
|
183
200
|
modelValue: string;
|
|
184
201
|
};
|
|
185
202
|
bindMatch: (match: string | Search, options?: BindingOptions | undefined) => {
|
|
@@ -190,12 +207,12 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
190
207
|
omitValue: (value: any) => any;
|
|
191
208
|
toggleValue: (value: any, values: any) => any;
|
|
192
209
|
delimitArray: (value: any) => any;
|
|
193
|
-
getRecordKey: (record:
|
|
210
|
+
getRecordKey: (record: AsRecord<RecordType>) => Identifier;
|
|
194
211
|
meta: Record<string, any>;
|
|
195
212
|
headings: {
|
|
196
213
|
isSorting: boolean | undefined;
|
|
197
214
|
toggleSort: (options?: VisitOptions) => void;
|
|
198
|
-
name: keyof
|
|
215
|
+
name: keyof RecordType;
|
|
199
216
|
label: string;
|
|
200
217
|
type: string;
|
|
201
218
|
hidden: boolean;
|
|
@@ -203,7 +220,6 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
203
220
|
toggleable: boolean;
|
|
204
221
|
icon?: string | undefined;
|
|
205
222
|
class?: string | undefined;
|
|
206
|
-
meta?: Record<string, any> | undefined;
|
|
207
223
|
sort?: {
|
|
208
224
|
active: boolean;
|
|
209
225
|
direction: Direction;
|
|
@@ -212,7 +228,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
212
228
|
}[];
|
|
213
229
|
columns: {
|
|
214
230
|
toggle: (options?: VisitOptions) => void;
|
|
215
|
-
name: keyof
|
|
231
|
+
name: keyof RecordType;
|
|
216
232
|
label: string;
|
|
217
233
|
type: string;
|
|
218
234
|
hidden: boolean;
|
|
@@ -220,18 +236,32 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
220
236
|
toggleable: boolean;
|
|
221
237
|
icon?: string | undefined;
|
|
222
238
|
class?: string | undefined;
|
|
223
|
-
meta?: Record<string, any> | undefined;
|
|
224
239
|
sort?: {
|
|
225
240
|
active: boolean;
|
|
226
241
|
direction: Direction;
|
|
227
242
|
next: string | null;
|
|
228
243
|
} | undefined;
|
|
229
244
|
}[];
|
|
230
|
-
records:
|
|
245
|
+
records: {
|
|
246
|
+
record: Omit<AsRecord<RecordType> & {
|
|
247
|
+
actions: InlineAction[];
|
|
248
|
+
}, "actions">;
|
|
231
249
|
/** Perform this action when the record is clicked */
|
|
232
250
|
default: (options?: VisitOptions) => void;
|
|
233
251
|
/** The actions available for the record */
|
|
234
|
-
actions:
|
|
252
|
+
actions: {
|
|
253
|
+
/** Executes this action */
|
|
254
|
+
execute: (options?: VisitOptions) => void;
|
|
255
|
+
type: "inline";
|
|
256
|
+
default: boolean;
|
|
257
|
+
name: string;
|
|
258
|
+
label: string;
|
|
259
|
+
icon?: string | undefined;
|
|
260
|
+
extra?: Record<string, unknown> | undefined;
|
|
261
|
+
action?: boolean | undefined;
|
|
262
|
+
confirm?: Confirm | undefined;
|
|
263
|
+
route?: Route | undefined;
|
|
264
|
+
}[];
|
|
235
265
|
/** Selects this record */
|
|
236
266
|
select: () => void;
|
|
237
267
|
/** Deselects this record */
|
|
@@ -242,14 +272,15 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
242
272
|
selected: boolean;
|
|
243
273
|
/** Bind the record to a checkbox */
|
|
244
274
|
bind: () => {
|
|
245
|
-
/**
|
|
246
|
-
* Actions to be applied on a record in JavaScript.
|
|
247
|
-
*/
|
|
248
275
|
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
249
276
|
modelValue: boolean;
|
|
250
|
-
value:
|
|
277
|
+
value: Identifier;
|
|
251
278
|
};
|
|
252
|
-
|
|
279
|
+
/** Get the value of the record for the column */
|
|
280
|
+
value: (column: Column<RecordType> | string) => RecordType[string] | RecordType[number] | RecordType[symbol];
|
|
281
|
+
/** Get the extra data of the record for the column */
|
|
282
|
+
extra: (column: Column<RecordType> | string) => Record<string, any>;
|
|
283
|
+
}[];
|
|
253
284
|
bulkActions: {
|
|
254
285
|
/** Executes this bulk action */
|
|
255
286
|
execute: (options?: VisitOptions) => void;
|
|
@@ -257,9 +288,9 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
257
288
|
keepSelected: boolean;
|
|
258
289
|
name: string;
|
|
259
290
|
label: string;
|
|
260
|
-
action?: boolean | undefined;
|
|
261
|
-
extra?: Record<string, unknown> | undefined;
|
|
262
291
|
icon?: string | undefined;
|
|
292
|
+
extra?: Record<string, unknown> | undefined;
|
|
293
|
+
action?: boolean | undefined;
|
|
263
294
|
confirm?: Confirm | undefined;
|
|
264
295
|
route?: Route | undefined;
|
|
265
296
|
}[];
|
|
@@ -269,9 +300,9 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
269
300
|
type: "page";
|
|
270
301
|
name: string;
|
|
271
302
|
label: string;
|
|
272
|
-
action?: boolean | undefined;
|
|
273
|
-
extra?: Record<string, unknown> | undefined;
|
|
274
303
|
icon?: string | undefined;
|
|
304
|
+
extra?: Record<string, unknown> | undefined;
|
|
305
|
+
action?: boolean | undefined;
|
|
275
306
|
confirm?: Confirm | undefined;
|
|
276
307
|
route?: Route | undefined;
|
|
277
308
|
}[];
|
|
@@ -282,7 +313,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
282
313
|
active: boolean;
|
|
283
314
|
}[];
|
|
284
315
|
currentPage: PerPageRecord | undefined;
|
|
285
|
-
paginator: (
|
|
316
|
+
paginator: (Paginator extends "length-aware" ? LengthAwarePaginator : Paginator extends "simple" ? SimplePaginator : Paginator extends "cursor" ? CursorPaginator : CollectionPaginator) & {
|
|
286
317
|
links?: {
|
|
287
318
|
navigate: (options?: VisitOptions) => void | "" | null;
|
|
288
319
|
url: string | null;
|
|
@@ -294,28 +325,25 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
294
325
|
first: (options?: VisitOptions) => void;
|
|
295
326
|
last: (options?: VisitOptions) => void;
|
|
296
327
|
};
|
|
297
|
-
executeInlineAction: (action: InlineAction, record:
|
|
328
|
+
executeInlineAction: (action: InlineAction, record: AsRecord<RecordType>, options?: VisitOptions) => void;
|
|
298
329
|
executeBulkAction: (action: BulkAction, options?: VisitOptions) => void;
|
|
299
330
|
executePageAction: (action: PageAction, options?: VisitOptions) => void;
|
|
300
331
|
applyPage: (page: PerPageRecord, options?: VisitOptions) => void;
|
|
301
|
-
selection: BulkSelection<
|
|
302
|
-
select: (record:
|
|
303
|
-
deselect: (record:
|
|
332
|
+
selection: BulkSelection<Identifier>;
|
|
333
|
+
select: (record: AsRecord<RecordType>) => void;
|
|
334
|
+
deselect: (record: AsRecord<RecordType>) => void;
|
|
304
335
|
selectPage: () => void;
|
|
305
336
|
deselectPage: () => void;
|
|
306
|
-
toggle: (record:
|
|
307
|
-
selected: (record:
|
|
337
|
+
toggle: (record: AsRecord<RecordType>) => void;
|
|
338
|
+
selected: (record: AsRecord<RecordType>) => boolean;
|
|
308
339
|
selectAll: () => void;
|
|
309
340
|
deselectAll: () => void;
|
|
310
341
|
isPageSelected: boolean;
|
|
311
342
|
hasSelected: boolean;
|
|
312
|
-
bindCheckbox: (record:
|
|
313
|
-
/**
|
|
314
|
-
* Actions to be applied on a record in JavaScript.
|
|
315
|
-
*/
|
|
343
|
+
bindCheckbox: (record: AsRecord<RecordType>) => {
|
|
316
344
|
"onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
|
|
317
345
|
modelValue: boolean;
|
|
318
|
-
value:
|
|
346
|
+
value: Identifier;
|
|
319
347
|
};
|
|
320
348
|
bindPage: () => {
|
|
321
349
|
"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
215
|
"multiple" in c && c.multiple && (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;
|
|
@@ -295,7 +295,7 @@ function ee(o, f, v = {}) {
|
|
|
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,139 @@ 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)
|
|
370
372
|
};
|
|
371
373
|
}
|
|
372
374
|
return {
|
|
373
375
|
filters: i,
|
|
374
376
|
sorts: u,
|
|
375
377
|
searches: b,
|
|
376
|
-
getFilter:
|
|
377
|
-
getSort:
|
|
378
|
+
getFilter: p,
|
|
379
|
+
getSort: j,
|
|
378
380
|
getSearch: C,
|
|
379
381
|
currentFilters: z,
|
|
380
|
-
currentSort:
|
|
381
|
-
currentSearches:
|
|
382
|
+
currentSort: g,
|
|
383
|
+
currentSearches: w,
|
|
382
384
|
isFiltering: y,
|
|
383
|
-
isSorting:
|
|
384
|
-
isSearching:
|
|
385
|
-
apply:
|
|
385
|
+
isSorting: K,
|
|
386
|
+
isSearching: P,
|
|
387
|
+
apply: G,
|
|
386
388
|
applyFilter: L,
|
|
387
389
|
applySort: M,
|
|
388
|
-
applySearch:
|
|
390
|
+
applySearch: T,
|
|
389
391
|
applyMatch: U,
|
|
390
|
-
clearFilter:
|
|
391
|
-
clearSort:
|
|
392
|
-
clearSearch:
|
|
393
|
-
clearMatch:
|
|
394
|
-
reset:
|
|
395
|
-
bindFilter:
|
|
396
|
-
bindSort:
|
|
397
|
-
bindSearch:
|
|
398
|
-
bindMatch:
|
|
392
|
+
clearFilter: N,
|
|
393
|
+
clearSort: W,
|
|
394
|
+
clearSearch: R,
|
|
395
|
+
clearMatch: D,
|
|
396
|
+
reset: t,
|
|
397
|
+
bindFilter: a,
|
|
398
|
+
bindSort: f,
|
|
399
|
+
bindSearch: V,
|
|
400
|
+
bindMatch: F,
|
|
399
401
|
stringValue: A,
|
|
400
402
|
omitValue: x,
|
|
401
403
|
toggleValue: s,
|
|
402
404
|
delimitArray: d
|
|
403
405
|
};
|
|
404
406
|
}
|
|
405
|
-
function le(o,
|
|
407
|
+
function le(o, m, v = {}, l = {}) {
|
|
408
|
+
if (!o || !m || !o[m])
|
|
409
|
+
throw new Error("Table has not been provided with valid props and key.");
|
|
406
410
|
l = {
|
|
407
411
|
...l,
|
|
408
|
-
only: [...l.only ?? [],
|
|
412
|
+
only: [...l.only ?? [], m.toString()]
|
|
409
413
|
};
|
|
410
|
-
const i = h(() => o[
|
|
414
|
+
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
415
|
() => {
|
|
412
416
|
var t;
|
|
413
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active:
|
|
414
|
-
var
|
|
417
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: a, hidden: f }) => a && !f).map((a) => {
|
|
418
|
+
var f;
|
|
415
419
|
return {
|
|
416
|
-
...
|
|
417
|
-
isSorting: (
|
|
418
|
-
toggleSort: (
|
|
420
|
+
...a,
|
|
421
|
+
isSorting: (f = a.sort) == null ? void 0 : f.active,
|
|
422
|
+
toggleSort: (V = {}) => U(a, V)
|
|
419
423
|
};
|
|
420
424
|
})) ?? [];
|
|
421
425
|
}
|
|
422
426
|
), k = h(
|
|
423
427
|
() => {
|
|
424
428
|
var t;
|
|
425
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden:
|
|
426
|
-
...
|
|
427
|
-
toggle: (
|
|
429
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: a }) => !a).map((a) => ({
|
|
430
|
+
...a,
|
|
431
|
+
toggle: (f = {}) => N(a, f)
|
|
428
432
|
}))) ?? [];
|
|
429
433
|
}
|
|
430
434
|
), s = h(
|
|
431
435
|
() => i.value.records.map((t) => ({
|
|
432
|
-
...t,
|
|
436
|
+
record: (({ actions: a, ...f }) => f)(t),
|
|
433
437
|
/** Perform this action when the record is clicked */
|
|
434
|
-
default: (
|
|
435
|
-
const
|
|
436
|
-
(
|
|
438
|
+
default: (a = {}) => {
|
|
439
|
+
const f = t.actions.find(
|
|
440
|
+
(V) => V.default
|
|
437
441
|
);
|
|
438
|
-
|
|
442
|
+
f && G(f, t, a);
|
|
439
443
|
},
|
|
440
444
|
/** The actions available for the record */
|
|
441
|
-
actions: t.actions.map((
|
|
442
|
-
...
|
|
445
|
+
actions: t.actions.map((a) => ({
|
|
446
|
+
...a,
|
|
443
447
|
/** Executes this action */
|
|
444
|
-
execute: (
|
|
448
|
+
execute: (f = {}) => G(a, t, f)
|
|
445
449
|
})),
|
|
446
450
|
/** Selects this record */
|
|
447
451
|
select: () => u.select(y(t)),
|
|
@@ -452,79 +456,92 @@ function le(o, f, v = {}, l = {}) {
|
|
|
452
456
|
/** Determine if the record is selected */
|
|
453
457
|
selected: u.selected(y(t)),
|
|
454
458
|
/** Bind the record to a checkbox */
|
|
455
|
-
bind: () => u.bind(y(t))
|
|
459
|
+
bind: () => u.bind(y(t)),
|
|
460
|
+
/** Get the value of the record for the column */
|
|
461
|
+
value: (a) => t[K(a)].value,
|
|
462
|
+
/** Get the extra data of the record for the column */
|
|
463
|
+
extra: (a) => t[K(a)].extra
|
|
456
464
|
}))
|
|
457
|
-
),
|
|
465
|
+
), p = h(
|
|
458
466
|
() => i.value.actions.bulk.map((t) => ({
|
|
459
467
|
...t,
|
|
460
468
|
/** Executes this bulk action */
|
|
461
|
-
execute: (
|
|
469
|
+
execute: (a = {}) => L(t, a)
|
|
462
470
|
}))
|
|
463
|
-
),
|
|
471
|
+
), j = h(
|
|
464
472
|
() => i.value.actions.page.map((t) => ({
|
|
465
473
|
...t,
|
|
466
474
|
/** Executes this page action */
|
|
467
|
-
execute: (
|
|
475
|
+
execute: (a = {}) => M(t, a)
|
|
468
476
|
}))
|
|
469
477
|
), C = h(
|
|
470
|
-
() =>
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
478
|
+
() => {
|
|
479
|
+
var t;
|
|
480
|
+
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((a) => ({
|
|
481
|
+
...a,
|
|
482
|
+
/** Changes the number of records to display per page */
|
|
483
|
+
apply: (f = {}) => T(a, f)
|
|
484
|
+
}))) ?? [];
|
|
485
|
+
}
|
|
475
486
|
), z = h(
|
|
476
|
-
() =>
|
|
477
|
-
|
|
487
|
+
() => {
|
|
488
|
+
var t;
|
|
489
|
+
return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: a }) => a);
|
|
490
|
+
}
|
|
491
|
+
), g = h(() => ({
|
|
478
492
|
...i.value.paginator,
|
|
479
493
|
next: (t = {}) => {
|
|
480
|
-
"nextLink" in
|
|
494
|
+
"nextLink" in g.value && g.value.nextLink && P(g.value.nextLink, t);
|
|
481
495
|
},
|
|
482
496
|
previous: (t = {}) => {
|
|
483
|
-
"prevLink" in
|
|
497
|
+
"prevLink" in g.value && g.value.prevLink && P(g.value.prevLink, t);
|
|
484
498
|
},
|
|
485
499
|
first: (t = {}) => {
|
|
486
|
-
"firstLink" in
|
|
500
|
+
"firstLink" in g.value && g.value.firstLink && P(g.value.firstLink, t);
|
|
487
501
|
},
|
|
488
502
|
last: (t = {}) => {
|
|
489
|
-
"lastLink" in
|
|
503
|
+
"lastLink" in g.value && g.value.lastLink && P(g.value.lastLink, t);
|
|
490
504
|
},
|
|
491
505
|
..."links" in i.value.paginator && i.value.paginator.links ? {
|
|
492
506
|
links: i.value.paginator.links.map((t) => ({
|
|
493
507
|
...t,
|
|
494
|
-
navigate: (
|
|
508
|
+
navigate: (a = {}) => t.url && P(t.url, a)
|
|
495
509
|
}))
|
|
496
510
|
} : {}
|
|
497
|
-
})),
|
|
511
|
+
})), w = h(
|
|
498
512
|
() => i.value.records.length > 0 && i.value.records.every(
|
|
499
513
|
(t) => u.selected(y(t))
|
|
500
514
|
)
|
|
501
515
|
);
|
|
502
516
|
function y(t) {
|
|
503
|
-
return t[d.value.record];
|
|
517
|
+
return t[d.value.record].value;
|
|
504
518
|
}
|
|
505
|
-
function
|
|
519
|
+
function K(t) {
|
|
520
|
+
return typeof t == "string" ? t : t.name;
|
|
521
|
+
}
|
|
522
|
+
function P(t, a = {}) {
|
|
506
523
|
S.visit(t, {
|
|
507
524
|
preserveScroll: !0,
|
|
508
525
|
preserveState: !0,
|
|
509
526
|
...l,
|
|
510
|
-
...
|
|
527
|
+
...a,
|
|
511
528
|
method: "get"
|
|
512
529
|
});
|
|
513
530
|
}
|
|
514
|
-
function
|
|
515
|
-
var
|
|
516
|
-
|
|
531
|
+
function G(t, a, f = {}) {
|
|
532
|
+
var F, e;
|
|
533
|
+
I(
|
|
517
534
|
t,
|
|
518
535
|
d.value.endpoint,
|
|
519
536
|
{
|
|
520
537
|
table: i.value.id,
|
|
521
|
-
id: y(
|
|
538
|
+
id: y(a)
|
|
522
539
|
},
|
|
523
|
-
|
|
524
|
-
) || (
|
|
540
|
+
f
|
|
541
|
+
) || (e = (F = v.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F, a);
|
|
525
542
|
}
|
|
526
|
-
function
|
|
527
|
-
|
|
543
|
+
function L(t, a = {}) {
|
|
544
|
+
I(
|
|
528
545
|
t,
|
|
529
546
|
d.value.endpoint,
|
|
530
547
|
{
|
|
@@ -533,67 +550,71 @@ function le(o, f, v = {}, l = {}) {
|
|
|
533
550
|
only: Array.from(u.selection.value.only),
|
|
534
551
|
except: Array.from(u.selection.value.except)
|
|
535
552
|
},
|
|
536
|
-
|
|
553
|
+
a
|
|
537
554
|
);
|
|
538
555
|
}
|
|
539
|
-
function
|
|
540
|
-
|
|
556
|
+
function M(t, a = {}) {
|
|
557
|
+
I(
|
|
541
558
|
t,
|
|
542
559
|
d.value.endpoint,
|
|
543
560
|
{
|
|
544
561
|
table: i.value.id
|
|
545
562
|
},
|
|
546
|
-
|
|
563
|
+
a
|
|
547
564
|
);
|
|
548
565
|
}
|
|
549
|
-
function
|
|
566
|
+
function T(t, a = {}) {
|
|
550
567
|
S.reload({
|
|
551
568
|
...l,
|
|
552
|
-
...
|
|
569
|
+
...a,
|
|
553
570
|
data: {
|
|
554
571
|
[d.value.records]: t.value,
|
|
555
572
|
[d.value.pages]: void 0
|
|
556
573
|
}
|
|
557
574
|
});
|
|
558
575
|
}
|
|
559
|
-
function
|
|
576
|
+
function U(t, a = {}) {
|
|
560
577
|
t.sort && S.reload({
|
|
561
578
|
...l,
|
|
562
|
-
...
|
|
579
|
+
...a,
|
|
563
580
|
data: {
|
|
564
581
|
[d.value.sorts]: b.omitValue(t.sort.next)
|
|
565
582
|
}
|
|
566
583
|
});
|
|
567
584
|
}
|
|
568
|
-
function
|
|
569
|
-
const
|
|
585
|
+
function N(t, a = {}) {
|
|
586
|
+
const f = b.toggleValue(
|
|
570
587
|
t.name,
|
|
571
|
-
x.value.map(({ name:
|
|
588
|
+
x.value.map(({ name: V }) => V)
|
|
572
589
|
);
|
|
573
590
|
S.reload({
|
|
574
591
|
...l,
|
|
575
|
-
...
|
|
592
|
+
...a,
|
|
576
593
|
data: {
|
|
577
|
-
[d.value.columns]: b.delimitArray(
|
|
594
|
+
[d.value.columns]: b.delimitArray(f)
|
|
578
595
|
}
|
|
579
596
|
});
|
|
580
597
|
}
|
|
581
598
|
function W() {
|
|
582
599
|
u.select(
|
|
583
|
-
...i.value.records.map(
|
|
600
|
+
...i.value.records.map(
|
|
601
|
+
(t) => y(t)
|
|
602
|
+
)
|
|
584
603
|
);
|
|
585
604
|
}
|
|
586
|
-
function
|
|
605
|
+
function R() {
|
|
587
606
|
u.deselect(
|
|
588
|
-
...i.value.records.map(
|
|
607
|
+
...i.value.records.map(
|
|
608
|
+
(t) => y(t)
|
|
609
|
+
)
|
|
589
610
|
);
|
|
590
611
|
}
|
|
591
|
-
function
|
|
612
|
+
function D() {
|
|
592
613
|
return {
|
|
593
614
|
"onUpdate:modelValue": (t) => {
|
|
594
|
-
t ? W() :
|
|
615
|
+
t ? W() : R();
|
|
595
616
|
},
|
|
596
|
-
modelValue:
|
|
617
|
+
modelValue: w.value
|
|
597
618
|
};
|
|
598
619
|
}
|
|
599
620
|
return Q({
|
|
@@ -608,23 +629,23 @@ function le(o, f, v = {}, l = {}) {
|
|
|
608
629
|
/** The records of the table */
|
|
609
630
|
records: s,
|
|
610
631
|
/** The available bulk actions */
|
|
611
|
-
bulkActions:
|
|
632
|
+
bulkActions: p,
|
|
612
633
|
/** The available page actions */
|
|
613
|
-
pageActions:
|
|
634
|
+
pageActions: j,
|
|
614
635
|
/** The available number of records to display per page */
|
|
615
636
|
rowsPerPage: C,
|
|
616
637
|
/** The current record per page item */
|
|
617
638
|
currentPage: z,
|
|
618
639
|
/** The pagination metadata */
|
|
619
|
-
paginator:
|
|
640
|
+
paginator: g,
|
|
620
641
|
/** Execute an inline action */
|
|
621
|
-
executeInlineAction:
|
|
642
|
+
executeInlineAction: G,
|
|
622
643
|
/** Execute a bulk action */
|
|
623
|
-
executeBulkAction:
|
|
644
|
+
executeBulkAction: L,
|
|
624
645
|
/** Execute a page action */
|
|
625
|
-
executePageAction:
|
|
646
|
+
executePageAction: M,
|
|
626
647
|
/** Apply a new page by changing the number of records to display */
|
|
627
|
-
applyPage:
|
|
648
|
+
applyPage: T,
|
|
628
649
|
/** The current selection of records */
|
|
629
650
|
selection: u.selection,
|
|
630
651
|
/** Select the given records */
|
|
@@ -634,7 +655,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
634
655
|
/** Select records on the current page */
|
|
635
656
|
selectPage: W,
|
|
636
657
|
/** Deselect records on the current page */
|
|
637
|
-
deselectPage:
|
|
658
|
+
deselectPage: R,
|
|
638
659
|
/** Toggle the selection of the given records */
|
|
639
660
|
toggle: (t) => u.toggle(y(t)),
|
|
640
661
|
/** Determine if the given record is selected */
|
|
@@ -644,13 +665,13 @@ function le(o, f, v = {}, l = {}) {
|
|
|
644
665
|
/** Deselect all records */
|
|
645
666
|
deselectAll: u.deselectAll,
|
|
646
667
|
/** Whether all records on the current page are selected */
|
|
647
|
-
isPageSelected:
|
|
668
|
+
isPageSelected: w,
|
|
648
669
|
/** Determine if any records are selected */
|
|
649
670
|
hasSelected: u.hasSelected,
|
|
650
671
|
/** Bind the given record to a checkbox */
|
|
651
672
|
bindCheckbox: (t) => u.bind(y(t)),
|
|
652
673
|
/** Bind the select all checkbox to the current page */
|
|
653
|
-
bindPage:
|
|
674
|
+
bindPage: D,
|
|
654
675
|
/** Bind select all records to the checkbox */
|
|
655
676
|
bindAll: u.bindAll,
|
|
656
677
|
/** 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=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]:null}})}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)}}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.0",
|
|
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.0",
|
|
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",
|