@honed/table 0.4.0 → 0.4.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 +3 -5
- package/dist/index.es.js +108 -107
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -173,9 +173,7 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
|
|
|
173
173
|
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
174
174
|
bind: () => {
|
|
175
175
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
176
|
-
modelValue: boolean;
|
|
177
|
-
* The available bulk actions.
|
|
178
|
-
*/
|
|
176
|
+
modelValue: boolean;
|
|
179
177
|
value: string;
|
|
180
178
|
} | undefined;
|
|
181
179
|
type: string;
|
|
@@ -293,9 +291,9 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
|
|
|
293
291
|
value: Identifier;
|
|
294
292
|
};
|
|
295
293
|
/** Get the value of the record for the column */
|
|
296
|
-
value: (column: Column<RecordType> | string) => RecordType[string] | RecordType[number] | RecordType[symbol];
|
|
294
|
+
value: (column: Column<RecordType> | string) => RecordType[string] | RecordType[number] | RecordType[symbol] | null;
|
|
297
295
|
/** Get the extra data of the record for the column */
|
|
298
|
-
extra: (column: Column<RecordType> | string) =>
|
|
296
|
+
extra: (column: Column<RecordType> | string) => any;
|
|
299
297
|
}[];
|
|
300
298
|
bulkActions: {
|
|
301
299
|
/** Executes this bulk action */
|
package/dist/index.es.js
CHANGED
|
@@ -12,7 +12,7 @@ function X() {
|
|
|
12
12
|
function d() {
|
|
13
13
|
o.value.all = !1, o.value.only.clear(), o.value.except.clear();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function l(...c) {
|
|
16
16
|
c.forEach((g) => o.value.except.delete(g)), c.forEach((g) => o.value.only.add(g));
|
|
17
17
|
}
|
|
18
18
|
function i(...c) {
|
|
@@ -22,7 +22,7 @@ function X() {
|
|
|
22
22
|
if (b(c) || g === !1)
|
|
23
23
|
return i(c);
|
|
24
24
|
if (!b(c) || g === !0)
|
|
25
|
-
return
|
|
25
|
+
return l(c);
|
|
26
26
|
}
|
|
27
27
|
function b(c) {
|
|
28
28
|
return o.value.all ? !o.value.except.has(c) : o.value.only.has(c);
|
|
@@ -31,7 +31,7 @@ function X() {
|
|
|
31
31
|
function S(c) {
|
|
32
32
|
return {
|
|
33
33
|
"onUpdate:modelValue": (g) => {
|
|
34
|
-
g ?
|
|
34
|
+
g ? l(c) : i(c);
|
|
35
35
|
},
|
|
36
36
|
modelValue: b(c),
|
|
37
37
|
value: c
|
|
@@ -52,7 +52,7 @@ function X() {
|
|
|
52
52
|
hasSelected: A,
|
|
53
53
|
selectAll: m,
|
|
54
54
|
deselectAll: d,
|
|
55
|
-
select:
|
|
55
|
+
select: l,
|
|
56
56
|
deselect: i,
|
|
57
57
|
toggle: u,
|
|
58
58
|
selected: b,
|
|
@@ -60,9 +60,9 @@ function X() {
|
|
|
60
60
|
bindAll: k
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
function I(o, m, d = {},
|
|
63
|
+
function I(o, m, d = {}, l = {}) {
|
|
64
64
|
return o.route ? (x.visit(o.route.href, {
|
|
65
|
-
...
|
|
65
|
+
...l,
|
|
66
66
|
method: o.route.method
|
|
67
67
|
}), !0) : o.action && m ? (x.post(
|
|
68
68
|
m,
|
|
@@ -71,33 +71,33 @@ function I(o, m, d = {}, a = {}) {
|
|
|
71
71
|
name: o.name,
|
|
72
72
|
type: o.type
|
|
73
73
|
},
|
|
74
|
-
|
|
74
|
+
l
|
|
75
75
|
), !0) : !1;
|
|
76
76
|
}
|
|
77
77
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
78
78
|
const Y = () => {
|
|
79
79
|
};
|
|
80
80
|
function Z(o, m) {
|
|
81
|
-
function d(...
|
|
81
|
+
function d(...l) {
|
|
82
82
|
return new Promise((i, u) => {
|
|
83
|
-
Promise.resolve(o(() => m.apply(this,
|
|
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 d;
|
|
87
87
|
}
|
|
88
88
|
function O(o, m = {}) {
|
|
89
|
-
let d,
|
|
89
|
+
let d, l, i = Y;
|
|
90
90
|
const u = (f) => {
|
|
91
91
|
clearTimeout(f), i(), i = Y;
|
|
92
92
|
};
|
|
93
93
|
let b;
|
|
94
94
|
return (f) => {
|
|
95
95
|
const A = J(o), S = J(m.maxWait);
|
|
96
|
-
return d && u(d), A <= 0 || S !== void 0 && S <= 0 ? (
|
|
97
|
-
i = m.rejectOnCancel ? c : k, b = f, S && !
|
|
98
|
-
d && u(d),
|
|
96
|
+
return d && u(d), A <= 0 || S !== void 0 && S <= 0 ? (l && (u(l), l = null), Promise.resolve(f())) : new Promise((k, c) => {
|
|
97
|
+
i = m.rejectOnCancel ? c : k, b = f, S && !l && (l = setTimeout(() => {
|
|
98
|
+
d && u(d), l = null, k(b());
|
|
99
99
|
}, S)), d = setTimeout(() => {
|
|
100
|
-
|
|
100
|
+
l && u(l), l = null, k(f());
|
|
101
101
|
}, A);
|
|
102
102
|
});
|
|
103
103
|
};
|
|
@@ -109,20 +109,20 @@ function q(o, m = 200, d = {}) {
|
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
function ee(o, m, d = {}) {
|
|
112
|
-
const
|
|
112
|
+
const l = p(() => o[m]), i = p(
|
|
113
113
|
() => {
|
|
114
114
|
var e;
|
|
115
|
-
return ((e =
|
|
115
|
+
return ((e = l.value.filters) == null ? void 0 : e.map((n) => ({
|
|
116
116
|
...n,
|
|
117
117
|
apply: (r, v = {}) => L(n, r, v),
|
|
118
118
|
clear: (r = {}) => N(n, r),
|
|
119
|
-
bind: () =>
|
|
119
|
+
bind: () => a(n.name)
|
|
120
120
|
}))) ?? [];
|
|
121
121
|
}
|
|
122
122
|
), u = p(
|
|
123
123
|
() => {
|
|
124
124
|
var e;
|
|
125
|
-
return ((e =
|
|
125
|
+
return ((e = l.value.sorts) == null ? void 0 : e.map((n) => ({
|
|
126
126
|
...n,
|
|
127
127
|
apply: (r = {}) => M(n, n.direction, r),
|
|
128
128
|
clear: (r = {}) => z(r),
|
|
@@ -132,7 +132,7 @@ function ee(o, m, d = {}) {
|
|
|
132
132
|
), b = p(
|
|
133
133
|
() => {
|
|
134
134
|
var e;
|
|
135
|
-
return (e =
|
|
135
|
+
return (e = l.value.searches) == null ? void 0 : e.map((n) => ({
|
|
136
136
|
...n,
|
|
137
137
|
apply: (r = {}) => U(n, r),
|
|
138
138
|
clear: (r = {}) => U(n, r),
|
|
@@ -142,21 +142,21 @@ function ee(o, m, d = {}) {
|
|
|
142
142
|
), f = p(
|
|
143
143
|
() => {
|
|
144
144
|
var e;
|
|
145
|
-
return ((e =
|
|
145
|
+
return ((e = l.value.filters) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
|
|
146
146
|
}
|
|
147
147
|
), A = p(
|
|
148
148
|
() => {
|
|
149
149
|
var e;
|
|
150
|
-
return (e =
|
|
150
|
+
return (e = l.value.sorts) == null ? void 0 : e.find(({ active: n }) => n);
|
|
151
151
|
}
|
|
152
152
|
), S = p(
|
|
153
153
|
() => {
|
|
154
154
|
var e;
|
|
155
|
-
return ((e =
|
|
155
|
+
return ((e = l.value.searches) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
|
|
156
156
|
}
|
|
157
157
|
);
|
|
158
158
|
function k(e) {
|
|
159
|
-
return Array.isArray(e) ? e.join(
|
|
159
|
+
return Array.isArray(e) ? e.join(l.value.config.delimiter) : e;
|
|
160
160
|
}
|
|
161
161
|
function c(e) {
|
|
162
162
|
return typeof e != "string" ? e : e.trim().replace(/\s+/g, "+");
|
|
@@ -176,17 +176,17 @@ function ee(o, m, d = {}) {
|
|
|
176
176
|
}
|
|
177
177
|
function C(e) {
|
|
178
178
|
var n;
|
|
179
|
-
return (n =
|
|
179
|
+
return (n = l.value.filters) == null ? void 0 : n.find((r) => r.name === e);
|
|
180
180
|
}
|
|
181
181
|
function h(e, n = null) {
|
|
182
182
|
var r;
|
|
183
|
-
return (r =
|
|
183
|
+
return (r = l.value.sorts) == null ? void 0 : r.find(
|
|
184
184
|
(v) => v.name === e && v.direction === n
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
function E(e) {
|
|
188
188
|
var n;
|
|
189
|
-
return (n =
|
|
189
|
+
return (n = l.value.searches) == null ? void 0 : n.find((r) => r.name === e);
|
|
190
190
|
}
|
|
191
191
|
function y(e) {
|
|
192
192
|
return e ? typeof e == "string" ? f.value.some((n) => n.name === e) : e.active : !!f.value.length;
|
|
@@ -195,13 +195,13 @@ function ee(o, m, d = {}) {
|
|
|
195
195
|
var n;
|
|
196
196
|
return e ? typeof e == "string" ? ((n = A.value) == null ? void 0 : n.name) === e : e.active : !!A.value;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function w(e) {
|
|
199
199
|
var n;
|
|
200
|
-
return e ? typeof e == "string" ? (n = S.value) == null ? void 0 : n.some((r) => r.name === e) : e.active : !!
|
|
200
|
+
return e ? typeof e == "string" ? (n = S.value) == null ? void 0 : n.some((r) => r.name === e) : e.active : !!l.value.config.search;
|
|
201
201
|
}
|
|
202
202
|
function W(e, n = {}) {
|
|
203
203
|
const r = Object.fromEntries(
|
|
204
|
-
Object.entries(e).map(([v,
|
|
204
|
+
Object.entries(e).map(([v, P]) => [v, B(P)])
|
|
205
205
|
);
|
|
206
206
|
x.reload({
|
|
207
207
|
...d,
|
|
@@ -233,7 +233,7 @@ function ee(o, m, d = {}) {
|
|
|
233
233
|
...d,
|
|
234
234
|
...r,
|
|
235
235
|
data: {
|
|
236
|
-
[
|
|
236
|
+
[l.value.config.sorts]: g(v.next)
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
}
|
|
@@ -245,12 +245,12 @@ function ee(o, m, d = {}) {
|
|
|
245
245
|
...d,
|
|
246
246
|
...n,
|
|
247
247
|
data: {
|
|
248
|
-
[
|
|
248
|
+
[l.value.config.searches]: e
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
function U(e, n = {}) {
|
|
253
|
-
if (!
|
|
253
|
+
if (!l.value.config.matches) {
|
|
254
254
|
console.warn("Matches key is not set.");
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
@@ -261,13 +261,13 @@ function ee(o, m, d = {}) {
|
|
|
261
261
|
}
|
|
262
262
|
const v = j(
|
|
263
263
|
r.name,
|
|
264
|
-
S.value.map(({ name:
|
|
264
|
+
S.value.map(({ name: P }) => P)
|
|
265
265
|
);
|
|
266
266
|
x.reload({
|
|
267
267
|
...d,
|
|
268
268
|
...n,
|
|
269
269
|
data: {
|
|
270
|
-
[
|
|
270
|
+
[l.value.config.matches]: k(v)
|
|
271
271
|
}
|
|
272
272
|
});
|
|
273
273
|
}
|
|
@@ -279,7 +279,7 @@ function ee(o, m, d = {}) {
|
|
|
279
279
|
...d,
|
|
280
280
|
...e,
|
|
281
281
|
data: {
|
|
282
|
-
[
|
|
282
|
+
[l.value.config.sorts]: void 0
|
|
283
283
|
}
|
|
284
284
|
});
|
|
285
285
|
}
|
|
@@ -287,7 +287,7 @@ function ee(o, m, d = {}) {
|
|
|
287
287
|
T(void 0, e);
|
|
288
288
|
}
|
|
289
289
|
function D(e = {}) {
|
|
290
|
-
if (!
|
|
290
|
+
if (!l.value.config.matches) {
|
|
291
291
|
console.warn("Matches key is not set.");
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
@@ -295,7 +295,7 @@ function ee(o, m, d = {}) {
|
|
|
295
295
|
...d,
|
|
296
296
|
...e,
|
|
297
297
|
data: {
|
|
298
|
-
[
|
|
298
|
+
[l.value.config.matches]: void 0
|
|
299
299
|
}
|
|
300
300
|
});
|
|
301
301
|
}
|
|
@@ -305,11 +305,11 @@ function ee(o, m, d = {}) {
|
|
|
305
305
|
...d,
|
|
306
306
|
...e,
|
|
307
307
|
data: {
|
|
308
|
-
[
|
|
309
|
-
[
|
|
310
|
-
[
|
|
308
|
+
[l.value.config.searches]: void 0,
|
|
309
|
+
[l.value.config.sorts]: void 0,
|
|
310
|
+
[l.value.config.matches]: void 0,
|
|
311
311
|
...Object.fromEntries(
|
|
312
|
-
((n =
|
|
312
|
+
((n = l.value.filters) == null ? void 0 : n.map((r) => [
|
|
313
313
|
r.name,
|
|
314
314
|
void 0
|
|
315
315
|
])) ?? []
|
|
@@ -317,21 +317,21 @@ function ee(o, m, d = {}) {
|
|
|
317
317
|
}
|
|
318
318
|
});
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function a(e, n = {}) {
|
|
321
321
|
const r = typeof e == "string" ? C(e) : e;
|
|
322
322
|
if (!r) {
|
|
323
323
|
console.warn(`Filter [${e}] does not exist.`);
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
326
|
const v = r.value, {
|
|
327
|
-
debounce:
|
|
327
|
+
debounce: P = 250,
|
|
328
328
|
transform: G = (H) => H,
|
|
329
329
|
...$
|
|
330
330
|
} = n;
|
|
331
331
|
return {
|
|
332
332
|
"onUpdate:modelValue": q((H) => {
|
|
333
333
|
L(r, G(H), $);
|
|
334
|
-
},
|
|
334
|
+
}, P),
|
|
335
335
|
modelValue: v
|
|
336
336
|
};
|
|
337
337
|
}
|
|
@@ -341,7 +341,7 @@ function ee(o, m, d = {}) {
|
|
|
341
341
|
console.warn(`Sort [${e}] does not exist.`);
|
|
342
342
|
return;
|
|
343
343
|
}
|
|
344
|
-
const { debounce: v = 0, transform:
|
|
344
|
+
const { debounce: v = 0, transform: P, ...G } = n;
|
|
345
345
|
return {
|
|
346
346
|
onClick: q(() => {
|
|
347
347
|
var $;
|
|
@@ -349,16 +349,16 @@ function ee(o, m, d = {}) {
|
|
|
349
349
|
}, v)
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function V(e = {}) {
|
|
353
353
|
const { debounce: n = 700, transform: r, ...v } = e;
|
|
354
354
|
return {
|
|
355
355
|
"onUpdate:modelValue": q(
|
|
356
|
-
(
|
|
357
|
-
T(
|
|
356
|
+
(P) => {
|
|
357
|
+
T(P, v);
|
|
358
358
|
},
|
|
359
359
|
n
|
|
360
360
|
),
|
|
361
|
-
modelValue:
|
|
361
|
+
modelValue: l.value.config.search ?? ""
|
|
362
362
|
};
|
|
363
363
|
}
|
|
364
364
|
function F(e, n = {}) {
|
|
@@ -367,12 +367,12 @@ function ee(o, m, d = {}) {
|
|
|
367
367
|
console.warn(`Match [${e}] does not exist.`);
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
|
-
const { debounce: v = 0, transform:
|
|
370
|
+
const { debounce: v = 0, transform: P, ...G } = n;
|
|
371
371
|
return {
|
|
372
372
|
"onUpdate:modelValue": q(($) => {
|
|
373
373
|
U($, G);
|
|
374
374
|
}, v),
|
|
375
|
-
modelValue:
|
|
375
|
+
modelValue: w(r),
|
|
376
376
|
value: r.name
|
|
377
377
|
};
|
|
378
378
|
}
|
|
@@ -388,7 +388,7 @@ function ee(o, m, d = {}) {
|
|
|
388
388
|
currentSearches: S,
|
|
389
389
|
isFiltering: y,
|
|
390
390
|
isSorting: K,
|
|
391
|
-
isSearching:
|
|
391
|
+
isSearching: w,
|
|
392
392
|
apply: W,
|
|
393
393
|
applyFilter: L,
|
|
394
394
|
applySort: M,
|
|
@@ -399,9 +399,9 @@ function ee(o, m, d = {}) {
|
|
|
399
399
|
clearSearch: R,
|
|
400
400
|
clearMatch: D,
|
|
401
401
|
reset: t,
|
|
402
|
-
bindFilter:
|
|
402
|
+
bindFilter: a,
|
|
403
403
|
bindSort: s,
|
|
404
|
-
bindSearch:
|
|
404
|
+
bindSearch: V,
|
|
405
405
|
bindMatch: F,
|
|
406
406
|
stringValue: c,
|
|
407
407
|
omitValue: g,
|
|
@@ -409,48 +409,48 @@ function ee(o, m, d = {}) {
|
|
|
409
409
|
delimitArray: k
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function le(o, m, d = {}, l = {}) {
|
|
413
413
|
if (!o || !m || !o[m])
|
|
414
414
|
throw new Error("Table has not been provided with valid props and key.");
|
|
415
|
-
|
|
416
|
-
...
|
|
417
|
-
only: [...
|
|
415
|
+
l = {
|
|
416
|
+
...l,
|
|
417
|
+
only: [...l.only ?? [], m.toString()]
|
|
418
418
|
};
|
|
419
|
-
const i = p(() => o[m]), u = X(), b = ee(o, m,
|
|
419
|
+
const i = p(() => o[m]), u = X(), b = ee(o, m, l), f = p(() => i.value.config), A = p(() => i.value.meta), S = p(
|
|
420
420
|
() => {
|
|
421
421
|
var t;
|
|
422
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active:
|
|
422
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: a, hidden: s }) => a && !s).map((a) => {
|
|
423
423
|
var s;
|
|
424
424
|
return {
|
|
425
|
-
...
|
|
426
|
-
isSorting: (s =
|
|
427
|
-
toggleSort: (
|
|
425
|
+
...a,
|
|
426
|
+
isSorting: (s = a.sort) == null ? void 0 : s.active,
|
|
427
|
+
toggleSort: (V = {}) => U(a, V)
|
|
428
428
|
};
|
|
429
429
|
})) ?? [];
|
|
430
430
|
}
|
|
431
431
|
), k = p(
|
|
432
432
|
() => {
|
|
433
433
|
var t;
|
|
434
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden:
|
|
435
|
-
...
|
|
436
|
-
toggle: (s = {}) => N(
|
|
434
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: a }) => !a).map((a) => ({
|
|
435
|
+
...a,
|
|
436
|
+
toggle: (s = {}) => N(a, s)
|
|
437
437
|
}))) ?? [];
|
|
438
438
|
}
|
|
439
439
|
), c = p(
|
|
440
440
|
() => i.value.records.map((t) => ({
|
|
441
|
-
record: (({ actions:
|
|
441
|
+
record: (({ actions: a, ...s }) => s)(t),
|
|
442
442
|
/** Perform this action when the record is clicked */
|
|
443
|
-
default: (
|
|
443
|
+
default: (a = {}) => {
|
|
444
444
|
const s = t.actions.find(
|
|
445
|
-
(
|
|
445
|
+
(V) => V.default
|
|
446
446
|
);
|
|
447
|
-
s && W(s, t,
|
|
447
|
+
s && W(s, t, a);
|
|
448
448
|
},
|
|
449
449
|
/** The actions available for the record */
|
|
450
|
-
actions: t.actions.map((
|
|
451
|
-
...
|
|
450
|
+
actions: t.actions.map((a) => ({
|
|
451
|
+
...a,
|
|
452
452
|
/** Executes this action */
|
|
453
|
-
execute: (s = {}) => W(
|
|
453
|
+
execute: (s = {}) => W(a, t, s)
|
|
454
454
|
})),
|
|
455
455
|
/** Selects this record */
|
|
456
456
|
select: () => u.select(y(t)),
|
|
@@ -463,60 +463,61 @@ function ae(o, m, d = {}, a = {}) {
|
|
|
463
463
|
/** Bind the record to a checkbox */
|
|
464
464
|
bind: () => u.bind(y(t)),
|
|
465
465
|
/** Get the value of the record for the column */
|
|
466
|
-
value: (
|
|
467
|
-
|
|
468
|
-
return
|
|
466
|
+
value: (a) => {
|
|
467
|
+
const s = t[K(a)];
|
|
468
|
+
return s ? s.value : null;
|
|
469
469
|
},
|
|
470
470
|
/** Get the extra data of the record for the column */
|
|
471
|
-
extra: (
|
|
472
|
-
var
|
|
473
|
-
|
|
471
|
+
extra: (a) => {
|
|
472
|
+
var V;
|
|
473
|
+
const s = (V = t[K(a)]) == null ? void 0 : V.extra;
|
|
474
|
+
return s ? s.value : null;
|
|
474
475
|
}
|
|
475
476
|
}))
|
|
476
477
|
), g = p(
|
|
477
478
|
() => i.value.actions.bulk.map((t) => ({
|
|
478
479
|
...t,
|
|
479
480
|
/** Executes this bulk action */
|
|
480
|
-
execute: (
|
|
481
|
+
execute: (a = {}) => L(t, a)
|
|
481
482
|
}))
|
|
482
483
|
), B = p(
|
|
483
484
|
() => i.value.actions.page.map((t) => ({
|
|
484
485
|
...t,
|
|
485
486
|
/** Executes this page action */
|
|
486
|
-
execute: (
|
|
487
|
+
execute: (a = {}) => M(t, a)
|
|
487
488
|
}))
|
|
488
489
|
), j = p(
|
|
489
490
|
() => {
|
|
490
491
|
var t;
|
|
491
|
-
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((
|
|
492
|
-
...
|
|
492
|
+
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((a) => ({
|
|
493
|
+
...a,
|
|
493
494
|
/** Changes the number of records to display per page */
|
|
494
|
-
apply: (s = {}) => T(
|
|
495
|
+
apply: (s = {}) => T(a, s)
|
|
495
496
|
}))) ?? [];
|
|
496
497
|
}
|
|
497
498
|
), C = p(
|
|
498
499
|
() => {
|
|
499
500
|
var t;
|
|
500
|
-
return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active:
|
|
501
|
+
return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: a }) => a);
|
|
501
502
|
}
|
|
502
503
|
), h = p(() => ({
|
|
503
504
|
...i.value.paginator,
|
|
504
505
|
next: (t = {}) => {
|
|
505
|
-
"nextLink" in h.value && h.value.nextLink &&
|
|
506
|
+
"nextLink" in h.value && h.value.nextLink && w(h.value.nextLink, t);
|
|
506
507
|
},
|
|
507
508
|
previous: (t = {}) => {
|
|
508
|
-
"prevLink" in h.value && h.value.prevLink &&
|
|
509
|
+
"prevLink" in h.value && h.value.prevLink && w(h.value.prevLink, t);
|
|
509
510
|
},
|
|
510
511
|
first: (t = {}) => {
|
|
511
|
-
"firstLink" in h.value && h.value.firstLink &&
|
|
512
|
+
"firstLink" in h.value && h.value.firstLink && w(h.value.firstLink, t);
|
|
512
513
|
},
|
|
513
514
|
last: (t = {}) => {
|
|
514
|
-
"lastLink" in h.value && h.value.lastLink &&
|
|
515
|
+
"lastLink" in h.value && h.value.lastLink && w(h.value.lastLink, t);
|
|
515
516
|
},
|
|
516
517
|
..."links" in i.value.paginator && i.value.paginator.links ? {
|
|
517
518
|
links: i.value.paginator.links.map((t) => ({
|
|
518
519
|
...t,
|
|
519
|
-
navigate: (
|
|
520
|
+
navigate: (a = {}) => t.url && w(t.url, a)
|
|
520
521
|
}))
|
|
521
522
|
} : {}
|
|
522
523
|
})), E = p(
|
|
@@ -530,28 +531,28 @@ function ae(o, m, d = {}, a = {}) {
|
|
|
530
531
|
function K(t) {
|
|
531
532
|
return typeof t == "string" ? t : t.name;
|
|
532
533
|
}
|
|
533
|
-
function
|
|
534
|
+
function w(t, a = {}) {
|
|
534
535
|
x.visit(t, {
|
|
535
536
|
preserveScroll: !0,
|
|
536
537
|
preserveState: !0,
|
|
537
|
-
...a,
|
|
538
538
|
...l,
|
|
539
|
+
...a,
|
|
539
540
|
method: "get"
|
|
540
541
|
});
|
|
541
542
|
}
|
|
542
|
-
function W(t,
|
|
543
|
+
function W(t, a, s = {}) {
|
|
543
544
|
var F, e;
|
|
544
545
|
I(
|
|
545
546
|
t,
|
|
546
547
|
f.value.endpoint,
|
|
547
548
|
{
|
|
548
549
|
table: i.value.id,
|
|
549
|
-
id: y(
|
|
550
|
+
id: y(a)
|
|
550
551
|
},
|
|
551
552
|
s
|
|
552
|
-
) || (e = (F = d.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F,
|
|
553
|
+
) || (e = (F = d.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F, a);
|
|
553
554
|
}
|
|
554
|
-
function L(t,
|
|
555
|
+
function L(t, a = {}) {
|
|
555
556
|
I(
|
|
556
557
|
t,
|
|
557
558
|
f.value.endpoint,
|
|
@@ -561,46 +562,46 @@ function ae(o, m, d = {}, a = {}) {
|
|
|
561
562
|
only: Array.from(u.selection.value.only),
|
|
562
563
|
except: Array.from(u.selection.value.except)
|
|
563
564
|
},
|
|
564
|
-
|
|
565
|
+
a
|
|
565
566
|
);
|
|
566
567
|
}
|
|
567
|
-
function M(t,
|
|
568
|
+
function M(t, a = {}) {
|
|
568
569
|
I(
|
|
569
570
|
t,
|
|
570
571
|
f.value.endpoint,
|
|
571
572
|
{
|
|
572
573
|
table: i.value.id
|
|
573
574
|
},
|
|
574
|
-
|
|
575
|
+
a
|
|
575
576
|
);
|
|
576
577
|
}
|
|
577
|
-
function T(t,
|
|
578
|
+
function T(t, a = {}) {
|
|
578
579
|
x.reload({
|
|
579
|
-
...a,
|
|
580
580
|
...l,
|
|
581
|
+
...a,
|
|
581
582
|
data: {
|
|
582
583
|
[f.value.records]: t.value,
|
|
583
584
|
[f.value.pages]: void 0
|
|
584
585
|
}
|
|
585
586
|
});
|
|
586
587
|
}
|
|
587
|
-
function U(t,
|
|
588
|
+
function U(t, a = {}) {
|
|
588
589
|
t.sort && x.reload({
|
|
589
|
-
...a,
|
|
590
590
|
...l,
|
|
591
|
+
...a,
|
|
591
592
|
data: {
|
|
592
593
|
[f.value.sorts]: b.omitValue(t.sort.next)
|
|
593
594
|
}
|
|
594
595
|
});
|
|
595
596
|
}
|
|
596
|
-
function N(t,
|
|
597
|
+
function N(t, a = {}) {
|
|
597
598
|
const s = b.toggleValue(
|
|
598
599
|
t.name,
|
|
599
|
-
S.value.map(({ name:
|
|
600
|
+
S.value.map(({ name: V }) => V)
|
|
600
601
|
);
|
|
601
602
|
x.reload({
|
|
602
|
-
...a,
|
|
603
603
|
...l,
|
|
604
|
+
...a,
|
|
604
605
|
data: {
|
|
605
606
|
[f.value.columns]: b.delimitArray(s)
|
|
606
607
|
}
|
|
@@ -690,5 +691,5 @@ function ae(o, m, d = {}, a = {}) {
|
|
|
690
691
|
});
|
|
691
692
|
}
|
|
692
693
|
export {
|
|
693
|
-
|
|
694
|
+
le as useTable
|
|
694
695
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(P,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],c):(P=typeof globalThis<"u"?globalThis:P||self,c(P["@honed/table"]={},P.Vue,P.Inertia))})(this,function(P,c,b){"use strict";function _(){const r=c.ref({all:!1,only:new Set,except:new Set});function p(){r.value.all=!0,r.value.only.clear(),r.value.except.clear()}function v(){r.value.all=!1,r.value.only.clear(),r.value.except.clear()}function a(...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 a(s)}function x(s){return r.value.all?!r.value.except.has(s):r.value.only.has(s)}const m=c.computed(()=>r.value.all&&r.value.except.size===0),A=c.computed(()=>r.value.only.size>0||m.value);function S(s){return{"onUpdate:modelValue":g=>{g?a(s):i(s)},modelValue:x(s),value:s}}function k(){return{"onUpdate:modelValue":s=>{s?p():v()},modelValue:m.value,value:m.value}}return{allSelected:m,selection:r,hasSelected:A,selectAll:p,deselectAll:v,select:a,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function D(r,p,v={},a={}){return r.route?(b.router.visit(r.route.href,{...a,method:r.route.method}),!0):r.action&&p?(b.router.post(p,{...v,name:r.name,type:r.type},a),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(r,p){function v(...a){return new Promise((i,u)=>{Promise.resolve(r(()=>p.apply(this,a),{fn:p,thisArg:this,args:a})).then(i).catch(u)})}return v}function X(r,p={}){let v,a,i=Y;const u=m=>{clearTimeout(m),i(),i=Y};let x;return m=>{const A=c.toValue(r),S=c.toValue(p.maxWait);return v&&u(v),A<=0||S!==void 0&&S<=0?(a&&(u(a),a=null),Promise.resolve(m())):new Promise((k,s)=>{i=p.rejectOnCancel?s:k,x=m,S&&!a&&(a=setTimeout(()=>{v&&u(v),a=null,k(x())},S)),v=setTimeout(()=>{a&&u(a),a=null,k(m())},A)})}}function B(r,p=200,v={}){return Q(X(p,v),r)}function Z(r,p,v={}){const a=c.computed(()=>r[p]),i=c.computed(()=>{var e;return((e=a.value.filters)==null?void 0:e.map(n=>({...n,apply:(o,f={})=>T(n,o,f),clear:(o={})=>N(n,o),bind:()=>l(n.name)})))??[]}),u=c.computed(()=>{var e;return((e=a.value.sorts)==null?void 0:e.map(n=>({...n,apply:(o={})=>M(n,n.direction,o),clear:(o={})=>z(o),bind:()=>d(n)})))??[]}),x=c.computed(()=>{var e;return(e=a.value.searches)==null?void 0:e.map(n=>({...n,apply:(o={})=>U(n,o),clear:(o={})=>U(n,o),bind:()=>j(n)}))}),m=c.computed(()=>{var e;return((e=a.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}),A=c.computed(()=>{var e;return(e=a.value.sorts)==null?void 0:e.find(({active:n})=>n)}),S=c.computed(()=>{var e;return((e=a.value.searches)==null?void 0:e.filter(({active:n})=>n))??[]});function k(e){return Array.isArray(e)?e.join(a.value.config.delimiter):e}function s(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function g(e){if(!["",null,void 0,[]].includes(e))return e}function I(e){return[k,s,g].reduce((n,o)=>o(n),e)}function C(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(o=>o!==e):[...n,e]}function W(e){var n;return(n=a.value.filters)==null?void 0:n.find(o=>o.name===e)}function h(e,n=null){var o;return(o=a.value.sorts)==null?void 0:o.find(f=>f.name===e&&f.direction===n)}function F(e){var n;return(n=a.value.searches)==null?void 0:n.find(o=>o.name===e)}function y(e){return e?typeof e=="string"?m.value.some(n=>n.name===e):e.active:!!m.value.length}function K(e){var n;return e?typeof e=="string"?((n=A.value)==null?void 0:n.name)===e:e.active:!!A.value}function w(e){var n;return e?typeof e=="string"?(n=S.value)==null?void 0:n.some(o=>o.name===e):e.active:!!a.value.config.search}function q(e,n={}){const o=Object.fromEntries(Object.entries(e).map(([f,V])=>[f,I(V)]));b.router.reload({...v,...n,data:o})}function T(e,n,o={}){const f=typeof e=="string"?W(e):e;if(!f){console.warn(`Filter [${e}] does not exist.`);return}"multiple"in f&&f.multiple&&n!==void 0&&(n=C(n,f.value)),b.router.reload({...v,...o,data:{[f.name]:I(n)}})}function M(e,n=null,o={}){const f=typeof e=="string"?h(e,n):e;if(!f){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...v,...o,data:{[a.value.config.sorts]:g(f.next)}})}function E(e,n={}){e=[s,g].reduce((o,f)=>f(o),e),b.router.reload({...v,...n,data:{[a.value.config.searches]:e}})}function U(e,n={}){if(!a.value.config.matches){console.warn("Matches key is not set.");return}const o=typeof e=="string"?F(e):e;if(!o){console.warn(`Match [${e}] does not exist.`);return}const f=C(o.name,S.value.map(({name:V})=>V));b.router.reload({...v,...n,data:{[a.value.config.matches]:k(f)}})}function N(e,n={}){T(e,void 0,n)}function z(e={}){b.router.reload({...v,...e,data:{[a.value.config.sorts]:void 0}})}function R(e={}){E(void 0,e)}function H(e={}){if(!a.value.config.matches){console.warn("Matches key is not set.");return}b.router.reload({...v,...e,data:{[a.value.config.matches]:void 0}})}function t(e={}){var n;b.router.reload({...v,...e,data:{[a.value.config.searches]:void 0,[a.value.config.sorts]:void 0,[a.value.config.matches]:void 0,...Object.fromEntries(((n=a.value.filters)==null?void 0:n.map(o=>[o.name,void 0]))??[])}})}function l(e,n={}){const o=typeof e=="string"?W(e):e;if(!o){console.warn(`Filter [${e}] does not exist.`);return}const f=o.value,{debounce:V=250,transform:G=J=>J,...$}=n;return{"onUpdate:modelValue":B(J=>{T(o,G(J),$)},V),modelValue:f}}function d(e,n={}){const o=typeof e=="string"?h(e):e;if(!o){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:f=0,transform:V,...G}=n;return{onClick:B(()=>{var $;M(o,($=A.value)==null?void 0:$.direction,G)},f)}}function L(e={}){const{debounce:n=700,transform:o,...f}=e;return{"onUpdate:modelValue":B(V=>{E(V,f)},n),modelValue:a.value.config.search??""}}function j(e,n={}){const o=typeof e=="string"?F(e):e;if(!o){console.warn(`Match [${e}] does not exist.`);return}const{debounce:f=0,transform:V,...G}=n;return{"onUpdate:modelValue":B($=>{U($,G)},f),modelValue:w(o),value:o.name}}return{filters:i,sorts:u,searches:x,getFilter:W,getSort:h,getSearch:F,currentFilters:m,currentSort:A,currentSearches:S,isFiltering:y,isSorting:K,isSearching:w,apply:q,applyFilter:T,applySort:M,applySearch:E,applyMatch:U,clearFilter:N,clearSort:z,clearSearch:R,clearMatch:H,reset:t,bindFilter:l,bindSort:d,bindSearch:L,bindMatch:j,stringValue:s,omitValue:g,toggleValue:C,delimitArray:k}}function O(r,p,v={},a={}){if(!r||!p||!r[p])throw new Error("Table has not been provided with valid props and key.");a={...a,only:[...a.only??[],p.toString()]};const i=c.computed(()=>r[p]),u=_(),x=Z(r,p,a),m=c.computed(()=>i.value.config),A=c.computed(()=>i.value.meta),S=c.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:l,hidden:d})=>l&&!d).map(l=>{var d;return{...l,isSorting:(d=l.sort)==null?void 0:d.active,toggleSort:(L={})=>U(l,L)}}))??[]}),k=c.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:l})=>!l).map(l=>({...l,toggle:(d={})=>N(l,d)})))??[]}),s=c.computed(()=>i.value.records.map(t=>({record:(({actions:l,...d})=>d)(t),default:(l={})=>{const d=t.actions.find(L=>L.default);d&&q(d,t,l)},actions:t.actions.map(l=>({...l,execute:(d={})=>q(l,t,d)})),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:l=>{var d;return(d=t[K(l)])==null?void 0:d.value},extra:l=>{var d;return(d=t[K(l)])==null?void 0:d.extra}}))),g=c.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(l={})=>T(t,l)}))),I=c.computed(()=>i.value.actions.page.map(t=>({...t,execute:(l={})=>M(t,l)}))),C=c.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(l=>({...l,apply:(d={})=>E(l,d)})))??[]}),W=c.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:l})=>l)}),h=c.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in h.value&&h.value.nextLink&&w(h.value.nextLink,t)},previous:(t={})=>{"prevLink"in h.value&&h.value.prevLink&&w(h.value.prevLink,t)},first:(t={})=>{"firstLink"in h.value&&h.value.firstLink&&w(h.value.firstLink,t)},last:(t={})=>{"lastLink"in h.value&&h.value.lastLink&&w(h.value.lastLink,t)},..."links"in i.value.paginator&&i.value.paginator.links?{links:i.value.paginator.links.map(t=>({...t,navigate:(l={})=>t.url&&w(t.url,l)}))}:{}})),F=c.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[m.value.record].value}function K(t){return typeof t=="string"?t:t.name}function w(t,l={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...a,...l,method:"get"})}function q(t,l,d={}){var j,e;D(t,m.value.endpoint,{table:i.value.id,id:y(l)},d)||(e=(j=v.recordActions)==null?void 0:j[t.name])==null||e.call(j,l)}function T(t,l={}){D(t,m.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)},l)}function M(t,l={}){D(t,m.value.endpoint,{table:i.value.id},l)}function E(t,l={}){b.router.reload({...a,...l,data:{[m.value.records]:t.value,[m.value.pages]:void 0}})}function U(t,l={}){t.sort&&b.router.reload({...a,...l,data:{[m.value.sorts]:x.omitValue(t.sort.next)}})}function N(t,l={}){const d=x.toggleValue(t.name,S.value.map(({name:L})=>L));b.router.reload({...a,...l,data:{[m.value.columns]:x.delimitArray(d)}})}function z(){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?z():R()},modelValue:F.value}}return c.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:g,pageActions:I,rowsPerPage:C,currentPage:W,paginator:h,executeInlineAction:q,executeBulkAction:T,executePageAction:M,applyPage:E,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:z,deselectPage:R,toggle:t=>u.toggle(y(t)),selected:t=>u.selected(y(t)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:F,hasSelected:u.hasSelected,bindCheckbox:t=>u.bind(y(t)),bindPage:H,bindAll:u.bindAll,...x})}P.useTable=O,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(w,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],c):(w=typeof globalThis<"u"?globalThis:w||self,c(w["@honed/table"]={},w.Vue,w.Inertia))})(this,function(w,c,b){"use strict";function _(){const o=c.ref({all:!1,only:new Set,except:new Set});function p(){o.value.all=!0,o.value.only.clear(),o.value.except.clear()}function v(){o.value.all=!1,o.value.only.clear(),o.value.except.clear()}function l(...s){s.forEach(g=>o.value.except.delete(g)),s.forEach(g=>o.value.only.add(g))}function i(...s){s.forEach(g=>o.value.except.add(g)),s.forEach(g=>o.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 o.value.all?!o.value.except.has(s):o.value.only.has(s)}const m=c.computed(()=>o.value.all&&o.value.except.size===0),A=c.computed(()=>o.value.only.size>0||m.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?p():v()},modelValue:m.value,value:m.value}}return{allSelected:m,selection:o,hasSelected:A,selectAll:p,deselectAll:v,select:l,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function D(o,p,v={},l={}){return o.route?(b.router.visit(o.route.href,{...l,method:o.route.method}),!0):o.action&&p?(b.router.post(p,{...v,name:o.name,type:o.type},l),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(o,p){function v(...l){return new Promise((i,u)=>{Promise.resolve(o(()=>p.apply(this,l),{fn:p,thisArg:this,args:l})).then(i).catch(u)})}return v}function X(o,p={}){let v,l,i=Y;const u=m=>{clearTimeout(m),i(),i=Y};let x;return m=>{const A=c.toValue(o),S=c.toValue(p.maxWait);return v&&u(v),A<=0||S!==void 0&&S<=0?(l&&(u(l),l=null),Promise.resolve(m())):new Promise((k,s)=>{i=p.rejectOnCancel?s:k,x=m,S&&!l&&(l=setTimeout(()=>{v&&u(v),l=null,k(x())},S)),v=setTimeout(()=>{l&&u(l),l=null,k(m())},A)})}}function B(o,p=200,v={}){return Q(X(p,v),o)}function Z(o,p,v={}){const l=c.computed(()=>o[p]),i=c.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(r,f={})=>T(n,r,f),clear:(r={})=>N(n,r),bind:()=>a(n.name)})))??[]}),u=c.computed(()=>{var e;return((e=l.value.sorts)==null?void 0:e.map(n=>({...n,apply:(r={})=>M(n,n.direction,r),clear:(r={})=>z(r),bind:()=>d(n)})))??[]}),x=c.computed(()=>{var e;return(e=l.value.searches)==null?void 0:e.map(n=>({...n,apply:(r={})=>U(n,r),clear:(r={})=>U(n,r),bind:()=>j(n)}))}),m=c.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}),A=c.computed(()=>{var e;return(e=l.value.sorts)==null?void 0:e.find(({active:n})=>n)}),S=c.computed(()=>{var e;return((e=l.value.searches)==null?void 0:e.filter(({active:n})=>n))??[]});function k(e){return Array.isArray(e)?e.join(l.value.config.delimiter):e}function s(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function g(e){if(!["",null,void 0,[]].includes(e))return e}function I(e){return[k,s,g].reduce((n,r)=>r(n),e)}function C(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(r=>r!==e):[...n,e]}function W(e){var n;return(n=l.value.filters)==null?void 0:n.find(r=>r.name===e)}function h(e,n=null){var r;return(r=l.value.sorts)==null?void 0:r.find(f=>f.name===e&&f.direction===n)}function F(e){var n;return(n=l.value.searches)==null?void 0:n.find(r=>r.name===e)}function y(e){return e?typeof e=="string"?m.value.some(n=>n.name===e):e.active:!!m.value.length}function K(e){var n;return e?typeof e=="string"?((n=A.value)==null?void 0:n.name)===e:e.active:!!A.value}function L(e){var n;return e?typeof e=="string"?(n=S.value)==null?void 0:n.some(r=>r.name===e):e.active:!!l.value.config.search}function q(e,n={}){const r=Object.fromEntries(Object.entries(e).map(([f,P])=>[f,I(P)]));b.router.reload({...v,...n,data:r})}function T(e,n,r={}){const f=typeof e=="string"?W(e):e;if(!f){console.warn(`Filter [${e}] does not exist.`);return}"multiple"in f&&f.multiple&&n!==void 0&&(n=C(n,f.value)),b.router.reload({...v,...r,data:{[f.name]:I(n)}})}function M(e,n=null,r={}){const f=typeof e=="string"?h(e,n):e;if(!f){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...v,...r,data:{[l.value.config.sorts]:g(f.next)}})}function E(e,n={}){e=[s,g].reduce((r,f)=>f(r),e),b.router.reload({...v,...n,data:{[l.value.config.searches]:e}})}function U(e,n={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}const r=typeof e=="string"?F(e):e;if(!r){console.warn(`Match [${e}] does not exist.`);return}const f=C(r.name,S.value.map(({name:P})=>P));b.router.reload({...v,...n,data:{[l.value.config.matches]:k(f)}})}function N(e,n={}){T(e,void 0,n)}function z(e={}){b.router.reload({...v,...e,data:{[l.value.config.sorts]:void 0}})}function R(e={}){E(void 0,e)}function H(e={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}b.router.reload({...v,...e,data:{[l.value.config.matches]:void 0}})}function t(e={}){var n;b.router.reload({...v,...e,data:{[l.value.config.searches]:void 0,[l.value.config.sorts]:void 0,[l.value.config.matches]:void 0,...Object.fromEntries(((n=l.value.filters)==null?void 0:n.map(r=>[r.name,void 0]))??[])}})}function a(e,n={}){const r=typeof e=="string"?W(e):e;if(!r){console.warn(`Filter [${e}] does not exist.`);return}const f=r.value,{debounce:P=250,transform:G=J=>J,...$}=n;return{"onUpdate:modelValue":B(J=>{T(r,G(J),$)},P),modelValue:f}}function d(e,n={}){const r=typeof e=="string"?h(e):e;if(!r){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:f=0,transform:P,...G}=n;return{onClick:B(()=>{var $;M(r,($=A.value)==null?void 0:$.direction,G)},f)}}function V(e={}){const{debounce:n=700,transform:r,...f}=e;return{"onUpdate:modelValue":B(P=>{E(P,f)},n),modelValue:l.value.config.search??""}}function j(e,n={}){const r=typeof e=="string"?F(e):e;if(!r){console.warn(`Match [${e}] does not exist.`);return}const{debounce:f=0,transform:P,...G}=n;return{"onUpdate:modelValue":B($=>{U($,G)},f),modelValue:L(r),value:r.name}}return{filters:i,sorts:u,searches:x,getFilter:W,getSort:h,getSearch:F,currentFilters:m,currentSort:A,currentSearches:S,isFiltering:y,isSorting:K,isSearching:L,apply:q,applyFilter:T,applySort:M,applySearch:E,applyMatch:U,clearFilter:N,clearSort:z,clearSearch:R,clearMatch:H,reset:t,bindFilter:a,bindSort:d,bindSearch:V,bindMatch:j,stringValue:s,omitValue:g,toggleValue:C,delimitArray:k}}function O(o,p,v={},l={}){if(!o||!p||!o[p])throw new Error("Table has not been provided with valid props and key.");l={...l,only:[...l.only??[],p.toString()]};const i=c.computed(()=>o[p]),u=_(),x=Z(o,p,l),m=c.computed(()=>i.value.config),A=c.computed(()=>i.value.meta),S=c.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:a,hidden:d})=>a&&!d).map(a=>{var d;return{...a,isSorting:(d=a.sort)==null?void 0:d.active,toggleSort:(V={})=>U(a,V)}}))??[]}),k=c.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:a})=>!a).map(a=>({...a,toggle:(d={})=>N(a,d)})))??[]}),s=c.computed(()=>i.value.records.map(t=>({record:(({actions:a,...d})=>d)(t),default:(a={})=>{const d=t.actions.find(V=>V.default);d&&q(d,t,a)},actions:t.actions.map(a=>({...a,execute:(d={})=>q(a,t,d)})),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=>{const d=t[K(a)];return d?d.value:null},extra:a=>{var V;const d=(V=t[K(a)])==null?void 0:V.extra;return d?d.value:null}}))),g=c.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(a={})=>T(t,a)}))),I=c.computed(()=>i.value.actions.page.map(t=>({...t,execute:(a={})=>M(t,a)}))),C=c.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(a=>({...a,apply:(d={})=>E(a,d)})))??[]}),W=c.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:a})=>a)}),h=c.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in h.value&&h.value.nextLink&&L(h.value.nextLink,t)},previous:(t={})=>{"prevLink"in h.value&&h.value.prevLink&&L(h.value.prevLink,t)},first:(t={})=>{"firstLink"in h.value&&h.value.firstLink&&L(h.value.firstLink,t)},last:(t={})=>{"lastLink"in h.value&&h.value.lastLink&&L(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&&L(t.url,a)}))}:{}})),F=c.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[m.value.record].value}function K(t){return typeof t=="string"?t:t.name}function L(t,a={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...a,method:"get"})}function q(t,a,d={}){var j,e;D(t,m.value.endpoint,{table:i.value.id,id:y(a)},d)||(e=(j=v.recordActions)==null?void 0:j[t.name])==null||e.call(j,a)}function T(t,a={}){D(t,m.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 M(t,a={}){D(t,m.value.endpoint,{table:i.value.id},a)}function E(t,a={}){b.router.reload({...l,...a,data:{[m.value.records]:t.value,[m.value.pages]:void 0}})}function U(t,a={}){t.sort&&b.router.reload({...l,...a,data:{[m.value.sorts]:x.omitValue(t.sort.next)}})}function N(t,a={}){const d=x.toggleValue(t.name,S.value.map(({name:V})=>V));b.router.reload({...l,...a,data:{[m.value.columns]:x.delimitArray(d)}})}function z(){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?z():R()},modelValue:F.value}}return c.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:g,pageActions:I,rowsPerPage:C,currentPage:W,paginator:h,executeInlineAction:q,executeBulkAction:T,executePageAction:M,applyPage:E,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:z,deselectPage:R,toggle:t=>u.toggle(y(t)),selected:t=>u.selected(y(t)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:F,hasSelected:u.hasSelected,bindCheckbox:t=>u.bind(y(t)),bindPage:H,bindAll:u.bindAll,...x})}w.useTable=O,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|