@honed/table 0.3.1 → 0.3.2
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 +1 -1
- package/dist/index.es.js +110 -109
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -183,7 +183,7 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
|
|
|
183
183
|
applyFilter: (filter: string | Filter, value: any, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
184
184
|
applySort: (sort: string | Sort, direction?: Direction | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
185
185
|
applySearch: (value: string | null | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
186
|
-
applyMatch: (
|
|
186
|
+
applyMatch: (search: string | Search, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
187
187
|
clearFilter: (filter: string | Filter, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
188
188
|
clearSort: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
189
189
|
clearSearch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
package/dist/index.es.js
CHANGED
|
@@ -114,9 +114,9 @@ function ee(o, m, v = {}) {
|
|
|
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: (a, c = {}) => F(n, a, c),
|
|
118
|
+
clear: (a = {}) => N(n, a),
|
|
119
|
+
bind: () => r(n.name)
|
|
120
120
|
}))) ?? [];
|
|
121
121
|
}
|
|
122
122
|
), u = h(
|
|
@@ -124,8 +124,8 @@ function ee(o, m, 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: (
|
|
127
|
+
apply: (a = {}) => M(n, n.direction, a),
|
|
128
|
+
clear: (a = {}) => W(a),
|
|
129
129
|
bind: () => f(n)
|
|
130
130
|
}))) ?? [];
|
|
131
131
|
}
|
|
@@ -134,9 +134,9 @@ function ee(o, m, 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: (a = {}) => U(n, a),
|
|
138
|
+
clear: (a = {}) => U(n, a),
|
|
139
|
+
bind: () => E(n)
|
|
140
140
|
}));
|
|
141
141
|
}
|
|
142
142
|
);
|
|
@@ -152,26 +152,26 @@ function ee(o, m, v = {}) {
|
|
|
152
152
|
}
|
|
153
153
|
function k(e) {
|
|
154
154
|
return [d, A, x].reduce(
|
|
155
|
-
(n,
|
|
155
|
+
(n, a) => a(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((a) => a !== e) : [...n, e];
|
|
161
161
|
}
|
|
162
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((a) => a.name === e);
|
|
165
165
|
}
|
|
166
166
|
function j(e, n = null) {
|
|
167
|
-
var
|
|
168
|
-
return (
|
|
167
|
+
var a;
|
|
168
|
+
return (a = l.value.sorts) == null ? void 0 : a.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((a) => a.name === e);
|
|
175
175
|
}
|
|
176
176
|
function z() {
|
|
177
177
|
var e;
|
|
@@ -181,7 +181,7 @@ function ee(o, m, v = {}) {
|
|
|
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 L() {
|
|
185
185
|
var e;
|
|
186
186
|
return ((e = l.value.searches) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
|
|
187
187
|
}
|
|
@@ -192,21 +192,21 @@ function ee(o, m, v = {}) {
|
|
|
192
192
|
var n;
|
|
193
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 V(e) {
|
|
196
|
+
var n, a;
|
|
197
|
+
return e ? typeof e == "string" ? (a = L()) == null ? void 0 : a.some((c) => c.name === e) : e.active : !!((n = L()) != null && n.length);
|
|
198
198
|
}
|
|
199
199
|
function G(e, n = {}) {
|
|
200
|
-
const
|
|
201
|
-
Object.entries(e).map(([c,
|
|
200
|
+
const a = Object.fromEntries(
|
|
201
|
+
Object.entries(e).map(([c, P]) => [c, k(P)])
|
|
202
202
|
);
|
|
203
203
|
S.reload({
|
|
204
204
|
...v,
|
|
205
205
|
...n,
|
|
206
|
-
data:
|
|
206
|
+
data: a
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function F(e, n, a = {}) {
|
|
210
210
|
const c = typeof e == "string" ? p(e) : e;
|
|
211
211
|
if (!c) {
|
|
212
212
|
console.warn(`Filter [${e}] does not exist.`);
|
|
@@ -214,13 +214,13 @@ function ee(o, m, v = {}) {
|
|
|
214
214
|
}
|
|
215
215
|
"multiple" in c && c.multiple && n !== void 0 && (n = s(n, c.value)), S.reload({
|
|
216
216
|
...v,
|
|
217
|
-
...
|
|
217
|
+
...a,
|
|
218
218
|
data: {
|
|
219
219
|
[c.name]: k(n)
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
|
-
function M(e, n = null,
|
|
223
|
+
function M(e, n = null, a = {}) {
|
|
224
224
|
const c = typeof e == "string" ? j(e, n) : e;
|
|
225
225
|
if (!c) {
|
|
226
226
|
console.warn(`Sort [${e}] does not exist.`);
|
|
@@ -228,7 +228,7 @@ function ee(o, m, v = {}) {
|
|
|
228
228
|
}
|
|
229
229
|
S.reload({
|
|
230
230
|
...v,
|
|
231
|
-
...
|
|
231
|
+
...a,
|
|
232
232
|
data: {
|
|
233
233
|
[l.value.config.sorts]: x(c.next)
|
|
234
234
|
}
|
|
@@ -236,7 +236,7 @@ function ee(o, m, v = {}) {
|
|
|
236
236
|
}
|
|
237
237
|
function T(e, n = {}) {
|
|
238
238
|
e = [A, x].reduce(
|
|
239
|
-
(
|
|
239
|
+
(a, c) => c(a),
|
|
240
240
|
e
|
|
241
241
|
), S.reload({
|
|
242
242
|
...v,
|
|
@@ -251,24 +251,25 @@ function ee(o, m, v = {}) {
|
|
|
251
251
|
console.warn("Matches key is not set.");
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
const a = typeof e == "string" ? C(e) : e;
|
|
255
|
+
if (!a) {
|
|
255
256
|
console.warn(`Match [${e}] does not exist.`);
|
|
256
257
|
return;
|
|
257
258
|
}
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
const c = s(
|
|
260
|
+
a.name,
|
|
261
|
+
L().map(({ name: P }) => P)
|
|
261
262
|
);
|
|
262
263
|
S.reload({
|
|
263
264
|
...v,
|
|
264
265
|
...n,
|
|
265
266
|
data: {
|
|
266
|
-
[l.value.config.matches]: d(
|
|
267
|
+
[l.value.config.matches]: d(c)
|
|
267
268
|
}
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
function N(e, n = {}) {
|
|
271
|
-
|
|
272
|
+
F(e, void 0, n);
|
|
272
273
|
}
|
|
273
274
|
function W(e = {}) {
|
|
274
275
|
S.reload({
|
|
@@ -304,8 +305,8 @@ function ee(o, m, v = {}) {
|
|
|
304
305
|
[l.value.config.searches]: void 0,
|
|
305
306
|
[l.value.config.sorts]: void 0,
|
|
306
307
|
...Object.fromEntries(
|
|
307
|
-
((n = l.value.filters) == null ? void 0 : n.map((
|
|
308
|
-
|
|
308
|
+
((n = l.value.filters) == null ? void 0 : n.map((a) => [
|
|
309
|
+
a.name,
|
|
309
310
|
void 0
|
|
310
311
|
])) ?? []
|
|
311
312
|
),
|
|
@@ -313,63 +314,63 @@ function ee(o, m, v = {}) {
|
|
|
313
314
|
}
|
|
314
315
|
});
|
|
315
316
|
}
|
|
316
|
-
function
|
|
317
|
-
const
|
|
318
|
-
if (!
|
|
317
|
+
function r(e, n = {}) {
|
|
318
|
+
const a = typeof e == "string" ? p(e) : e;
|
|
319
|
+
if (!a) {
|
|
319
320
|
console.warn(`Filter [${e}] does not exist.`);
|
|
320
321
|
return;
|
|
321
322
|
}
|
|
322
|
-
const c =
|
|
323
|
-
debounce:
|
|
323
|
+
const c = a.value, {
|
|
324
|
+
debounce: P = 250,
|
|
324
325
|
transform: B = (H) => H,
|
|
325
326
|
...$
|
|
326
327
|
} = n;
|
|
327
328
|
return {
|
|
328
329
|
"onUpdate:modelValue": q((H) => {
|
|
329
|
-
|
|
330
|
-
},
|
|
330
|
+
F(a, B(H), $);
|
|
331
|
+
}, P),
|
|
331
332
|
modelValue: c
|
|
332
333
|
};
|
|
333
334
|
}
|
|
334
335
|
function f(e, n = {}) {
|
|
335
|
-
const
|
|
336
|
-
if (!
|
|
336
|
+
const a = typeof e == "string" ? j(e) : e;
|
|
337
|
+
if (!a) {
|
|
337
338
|
console.warn(`Sort [${e}] does not exist.`);
|
|
338
339
|
return;
|
|
339
340
|
}
|
|
340
|
-
const { debounce: c = 0, transform:
|
|
341
|
+
const { debounce: c = 0, transform: P, ...B } = n;
|
|
341
342
|
return {
|
|
342
343
|
onClick: q(() => {
|
|
343
344
|
var $;
|
|
344
|
-
M(
|
|
345
|
+
M(a, ($ = g()) == null ? void 0 : $.direction, B);
|
|
345
346
|
}, c)
|
|
346
347
|
};
|
|
347
348
|
}
|
|
348
|
-
function
|
|
349
|
-
const { debounce: n = 700, transform:
|
|
349
|
+
function w(e = {}) {
|
|
350
|
+
const { debounce: n = 700, transform: a, ...c } = e;
|
|
350
351
|
return {
|
|
351
352
|
"onUpdate:modelValue": q(
|
|
352
|
-
(
|
|
353
|
-
T(
|
|
353
|
+
(P) => {
|
|
354
|
+
T(P, c);
|
|
354
355
|
},
|
|
355
356
|
n
|
|
356
357
|
),
|
|
357
358
|
modelValue: l.value.config.search ?? ""
|
|
358
359
|
};
|
|
359
360
|
}
|
|
360
|
-
function
|
|
361
|
-
const
|
|
362
|
-
if (!
|
|
361
|
+
function E(e, n = {}) {
|
|
362
|
+
const a = typeof e == "string" ? C(e) : e;
|
|
363
|
+
if (!a) {
|
|
363
364
|
console.warn(`Match [${e}] does not exist.`);
|
|
364
365
|
return;
|
|
365
366
|
}
|
|
366
|
-
const { debounce: c = 0, transform:
|
|
367
|
+
const { debounce: c = 0, transform: P, ...B } = n;
|
|
367
368
|
return {
|
|
368
369
|
"onUpdate:modelValue": q(($) => {
|
|
369
370
|
U($, B);
|
|
370
371
|
}, c),
|
|
371
|
-
modelValue:
|
|
372
|
-
value:
|
|
372
|
+
modelValue: V(a),
|
|
373
|
+
value: a.name
|
|
373
374
|
};
|
|
374
375
|
}
|
|
375
376
|
return {
|
|
@@ -381,12 +382,12 @@ function ee(o, m, v = {}) {
|
|
|
381
382
|
getSearch: C,
|
|
382
383
|
currentFilters: z,
|
|
383
384
|
currentSort: g,
|
|
384
|
-
currentSearches:
|
|
385
|
+
currentSearches: L,
|
|
385
386
|
isFiltering: y,
|
|
386
387
|
isSorting: K,
|
|
387
|
-
isSearching:
|
|
388
|
+
isSearching: V,
|
|
388
389
|
apply: G,
|
|
389
|
-
applyFilter:
|
|
390
|
+
applyFilter: F,
|
|
390
391
|
applySort: M,
|
|
391
392
|
applySearch: T,
|
|
392
393
|
applyMatch: U,
|
|
@@ -395,10 +396,10 @@ function ee(o, m, v = {}) {
|
|
|
395
396
|
clearSearch: R,
|
|
396
397
|
clearMatch: D,
|
|
397
398
|
reset: t,
|
|
398
|
-
bindFilter:
|
|
399
|
+
bindFilter: r,
|
|
399
400
|
bindSort: f,
|
|
400
|
-
bindSearch:
|
|
401
|
-
bindMatch:
|
|
401
|
+
bindSearch: w,
|
|
402
|
+
bindMatch: E,
|
|
402
403
|
stringValue: A,
|
|
403
404
|
omitValue: x,
|
|
404
405
|
toggleValue: s,
|
|
@@ -415,38 +416,38 @@ function le(o, m, v = {}, l = {}) {
|
|
|
415
416
|
const i = h(() => o[m]), u = X(), b = ee(o, m, l), d = h(() => i.value.config), A = h(() => i.value.meta), x = h(
|
|
416
417
|
() => {
|
|
417
418
|
var t;
|
|
418
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active:
|
|
419
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: r, hidden: f }) => r && !f).map((r) => {
|
|
419
420
|
var f;
|
|
420
421
|
return {
|
|
421
|
-
...
|
|
422
|
-
isSorting: (f =
|
|
423
|
-
toggleSort: (
|
|
422
|
+
...r,
|
|
423
|
+
isSorting: (f = r.sort) == null ? void 0 : f.active,
|
|
424
|
+
toggleSort: (w = {}) => U(r, w)
|
|
424
425
|
};
|
|
425
426
|
})) ?? [];
|
|
426
427
|
}
|
|
427
428
|
), k = h(
|
|
428
429
|
() => {
|
|
429
430
|
var t;
|
|
430
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden:
|
|
431
|
-
...
|
|
432
|
-
toggle: (f = {}) => N(
|
|
431
|
+
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: r }) => !r).map((r) => ({
|
|
432
|
+
...r,
|
|
433
|
+
toggle: (f = {}) => N(r, f)
|
|
433
434
|
}))) ?? [];
|
|
434
435
|
}
|
|
435
436
|
), s = h(
|
|
436
437
|
() => i.value.records.map((t) => ({
|
|
437
|
-
record: (({ actions:
|
|
438
|
+
record: (({ actions: r, ...f }) => f)(t),
|
|
438
439
|
/** Perform this action when the record is clicked */
|
|
439
|
-
default: (
|
|
440
|
+
default: (r = {}) => {
|
|
440
441
|
const f = t.actions.find(
|
|
441
|
-
(
|
|
442
|
+
(w) => w.default
|
|
442
443
|
);
|
|
443
|
-
f && G(f, t,
|
|
444
|
+
f && G(f, t, r);
|
|
444
445
|
},
|
|
445
446
|
/** The actions available for the record */
|
|
446
|
-
actions: t.actions.map((
|
|
447
|
-
...
|
|
447
|
+
actions: t.actions.map((r) => ({
|
|
448
|
+
...r,
|
|
448
449
|
/** Executes this action */
|
|
449
|
-
execute: (f = {}) => G(
|
|
450
|
+
execute: (f = {}) => G(r, t, f)
|
|
450
451
|
})),
|
|
451
452
|
/** Selects this record */
|
|
452
453
|
select: () => u.select(y(t)),
|
|
@@ -459,57 +460,57 @@ function le(o, m, v = {}, l = {}) {
|
|
|
459
460
|
/** Bind the record to a checkbox */
|
|
460
461
|
bind: () => u.bind(y(t)),
|
|
461
462
|
/** Get the value of the record for the column */
|
|
462
|
-
value: (
|
|
463
|
+
value: (r) => t[K(r)].value,
|
|
463
464
|
/** Get the extra data of the record for the column */
|
|
464
|
-
extra: (
|
|
465
|
+
extra: (r) => t[K(r)].extra
|
|
465
466
|
}))
|
|
466
467
|
), p = h(
|
|
467
468
|
() => i.value.actions.bulk.map((t) => ({
|
|
468
469
|
...t,
|
|
469
470
|
/** Executes this bulk action */
|
|
470
|
-
execute: (
|
|
471
|
+
execute: (r = {}) => F(t, r)
|
|
471
472
|
}))
|
|
472
473
|
), j = h(
|
|
473
474
|
() => i.value.actions.page.map((t) => ({
|
|
474
475
|
...t,
|
|
475
476
|
/** Executes this page action */
|
|
476
|
-
execute: (
|
|
477
|
+
execute: (r = {}) => M(t, r)
|
|
477
478
|
}))
|
|
478
479
|
), C = h(
|
|
479
480
|
() => {
|
|
480
481
|
var t;
|
|
481
|
-
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((
|
|
482
|
-
...
|
|
482
|
+
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((r) => ({
|
|
483
|
+
...r,
|
|
483
484
|
/** Changes the number of records to display per page */
|
|
484
|
-
apply: (f = {}) => T(
|
|
485
|
+
apply: (f = {}) => T(r, f)
|
|
485
486
|
}))) ?? [];
|
|
486
487
|
}
|
|
487
488
|
), z = h(
|
|
488
489
|
() => {
|
|
489
490
|
var t;
|
|
490
|
-
return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active:
|
|
491
|
+
return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: r }) => r);
|
|
491
492
|
}
|
|
492
493
|
), g = h(() => ({
|
|
493
494
|
...i.value.paginator,
|
|
494
495
|
next: (t = {}) => {
|
|
495
|
-
"nextLink" in g.value && g.value.nextLink &&
|
|
496
|
+
"nextLink" in g.value && g.value.nextLink && V(g.value.nextLink, t);
|
|
496
497
|
},
|
|
497
498
|
previous: (t = {}) => {
|
|
498
|
-
"prevLink" in g.value && g.value.prevLink &&
|
|
499
|
+
"prevLink" in g.value && g.value.prevLink && V(g.value.prevLink, t);
|
|
499
500
|
},
|
|
500
501
|
first: (t = {}) => {
|
|
501
|
-
"firstLink" in g.value && g.value.firstLink &&
|
|
502
|
+
"firstLink" in g.value && g.value.firstLink && V(g.value.firstLink, t);
|
|
502
503
|
},
|
|
503
504
|
last: (t = {}) => {
|
|
504
|
-
"lastLink" in g.value && g.value.lastLink &&
|
|
505
|
+
"lastLink" in g.value && g.value.lastLink && V(g.value.lastLink, t);
|
|
505
506
|
},
|
|
506
507
|
..."links" in i.value.paginator && i.value.paginator.links ? {
|
|
507
508
|
links: i.value.paginator.links.map((t) => ({
|
|
508
509
|
...t,
|
|
509
|
-
navigate: (
|
|
510
|
+
navigate: (r = {}) => t.url && V(t.url, r)
|
|
510
511
|
}))
|
|
511
512
|
} : {}
|
|
512
|
-
})),
|
|
513
|
+
})), L = h(
|
|
513
514
|
() => i.value.records.length > 0 && i.value.records.every(
|
|
514
515
|
(t) => u.selected(y(t))
|
|
515
516
|
)
|
|
@@ -520,28 +521,28 @@ function le(o, m, v = {}, l = {}) {
|
|
|
520
521
|
function K(t) {
|
|
521
522
|
return typeof t == "string" ? t : t.name;
|
|
522
523
|
}
|
|
523
|
-
function
|
|
524
|
+
function V(t, r = {}) {
|
|
524
525
|
S.visit(t, {
|
|
525
526
|
preserveScroll: !0,
|
|
526
527
|
preserveState: !0,
|
|
527
528
|
...l,
|
|
528
|
-
...
|
|
529
|
+
...r,
|
|
529
530
|
method: "get"
|
|
530
531
|
});
|
|
531
532
|
}
|
|
532
|
-
function G(t,
|
|
533
|
-
var
|
|
533
|
+
function G(t, r, f = {}) {
|
|
534
|
+
var E, e;
|
|
534
535
|
I(
|
|
535
536
|
t,
|
|
536
537
|
d.value.endpoint,
|
|
537
538
|
{
|
|
538
539
|
table: i.value.id,
|
|
539
|
-
id: y(
|
|
540
|
+
id: y(r)
|
|
540
541
|
},
|
|
541
542
|
f
|
|
542
|
-
) || (e = (
|
|
543
|
+
) || (e = (E = v.recordActions) == null ? void 0 : E[t.name]) == null || e.call(E, r);
|
|
543
544
|
}
|
|
544
|
-
function
|
|
545
|
+
function F(t, r = {}) {
|
|
545
546
|
I(
|
|
546
547
|
t,
|
|
547
548
|
d.value.endpoint,
|
|
@@ -551,46 +552,46 @@ function le(o, m, v = {}, l = {}) {
|
|
|
551
552
|
only: Array.from(u.selection.value.only),
|
|
552
553
|
except: Array.from(u.selection.value.except)
|
|
553
554
|
},
|
|
554
|
-
|
|
555
|
+
r
|
|
555
556
|
);
|
|
556
557
|
}
|
|
557
|
-
function M(t,
|
|
558
|
+
function M(t, r = {}) {
|
|
558
559
|
I(
|
|
559
560
|
t,
|
|
560
561
|
d.value.endpoint,
|
|
561
562
|
{
|
|
562
563
|
table: i.value.id
|
|
563
564
|
},
|
|
564
|
-
|
|
565
|
+
r
|
|
565
566
|
);
|
|
566
567
|
}
|
|
567
|
-
function T(t,
|
|
568
|
+
function T(t, r = {}) {
|
|
568
569
|
S.reload({
|
|
569
570
|
...l,
|
|
570
|
-
...
|
|
571
|
+
...r,
|
|
571
572
|
data: {
|
|
572
573
|
[d.value.records]: t.value,
|
|
573
574
|
[d.value.pages]: void 0
|
|
574
575
|
}
|
|
575
576
|
});
|
|
576
577
|
}
|
|
577
|
-
function U(t,
|
|
578
|
+
function U(t, r = {}) {
|
|
578
579
|
t.sort && S.reload({
|
|
579
580
|
...l,
|
|
580
|
-
...
|
|
581
|
+
...r,
|
|
581
582
|
data: {
|
|
582
583
|
[d.value.sorts]: b.omitValue(t.sort.next)
|
|
583
584
|
}
|
|
584
585
|
});
|
|
585
586
|
}
|
|
586
|
-
function N(t,
|
|
587
|
+
function N(t, r = {}) {
|
|
587
588
|
const f = b.toggleValue(
|
|
588
589
|
t.name,
|
|
589
|
-
x.value.map(({ name:
|
|
590
|
+
x.value.map(({ name: w }) => w)
|
|
590
591
|
);
|
|
591
592
|
S.reload({
|
|
592
593
|
...l,
|
|
593
|
-
...
|
|
594
|
+
...r,
|
|
594
595
|
data: {
|
|
595
596
|
[d.value.columns]: b.delimitArray(f)
|
|
596
597
|
}
|
|
@@ -615,7 +616,7 @@ function le(o, m, v = {}, l = {}) {
|
|
|
615
616
|
"onUpdate:modelValue": (t) => {
|
|
616
617
|
t ? W() : R();
|
|
617
618
|
},
|
|
618
|
-
modelValue:
|
|
619
|
+
modelValue: L.value
|
|
619
620
|
};
|
|
620
621
|
}
|
|
621
622
|
return Q({
|
|
@@ -642,7 +643,7 @@ function le(o, m, v = {}, l = {}) {
|
|
|
642
643
|
/** Execute an inline action */
|
|
643
644
|
executeInlineAction: G,
|
|
644
645
|
/** Execute a bulk action */
|
|
645
|
-
executeBulkAction:
|
|
646
|
+
executeBulkAction: F,
|
|
646
647
|
/** Execute a page action */
|
|
647
648
|
executePageAction: M,
|
|
648
649
|
/** Apply a new page by changing the number of records to display */
|
|
@@ -666,7 +667,7 @@ function le(o, m, v = {}, l = {}) {
|
|
|
666
667
|
/** Deselect all records */
|
|
667
668
|
deselectAll: u.deselectAll,
|
|
668
669
|
/** Whether all records on the current page are selected */
|
|
669
|
-
isPageSelected:
|
|
670
|
+
isPageSelected: L,
|
|
670
671
|
/** Determine if any records are selected */
|
|
671
672
|
hasSelected: u.hasSelected,
|
|
672
673
|
/** Bind the given record to a checkbox */
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(V,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],d):(V=typeof globalThis<"u"?globalThis:V||self,d(V["@honed/table"]={},V.Vue,V.Inertia))})(this,function(V,d,b){"use strict";function _(){const r=d.ref({all:!1,only:new Set,except:new Set});function m(){r.value.all=!0,r.value.only.clear(),r.value.except.clear()}function f(){r.value.all=!1,r.value.only.clear(),r.value.except.clear()}function l(...s){s.forEach(g=>r.value.except.delete(g)),s.forEach(g=>r.value.only.add(g))}function i(...s){s.forEach(g=>r.value.except.add(g)),s.forEach(g=>r.value.only.delete(g))}function u(s,g){if(x(s)||g===!1)return i(s);if(!x(s)||g===!0)return l(s)}function x(s){return r.value.all?!r.value.except.has(s):r.value.only.has(s)}const v=d.computed(()=>r.value.all&&r.value.except.size===0),A=d.computed(()=>r.value.only.size>0||v.value);function S(s){return{"onUpdate:modelValue":g=>{g?l(s):i(s)},modelValue:x(s),value:s}}function k(){return{"onUpdate:modelValue":s=>{s?m():f()},modelValue:v.value,value:v.value}}return{allSelected:v,selection:r,hasSelected:A,selectAll:m,deselectAll:f,select:l,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function D(r,m,f={},l={}){return r.route?(b.router.visit(r.route.href,{...l,method:r.route.method}),!0):r.action&&m?(b.router.post(m,{...f,name:r.name,type:r.type},l),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(r,m){function f(...l){return new Promise((i,u)=>{Promise.resolve(r(()=>m.apply(this,l),{fn:m,thisArg:this,args:l})).then(i).catch(u)})}return f}function X(r,m={}){let f,l,i=Y;const u=v=>{clearTimeout(v),i(),i=Y};let x;return v=>{const A=d.toValue(r),S=d.toValue(m.maxWait);return f&&u(f),A<=0||S!==void 0&&S<=0?(l&&(u(l),l=null),Promise.resolve(v())):new Promise((k,s)=>{i=m.rejectOnCancel?s:k,x=v,S&&!l&&(l=setTimeout(()=>{f&&u(f),l=null,k(x())},S)),f=setTimeout(()=>{l&&u(l),l=null,k(v())},A)})}}function I(r,m=200,f={}){return Q(X(m,f),r)}function Z(r,m,f={}){const l=d.computed(()=>r[m]),i=d.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(o,c={})=>T(n,o,c),clear:(o={})=>N(n,o),bind:()=>a(n.name)})))??[]}),u=d.computed(()=>{var e;return((e=l.value.sorts)==null?void 0:e.map(n=>({...n,apply:(o={})=>E(n,n.direction,o),clear:(o={})=>W(o),bind:()=>p(n)})))??[]}),x=d.computed(()=>{var e;return(e=l.value.searches)==null?void 0:e.map(n=>({...n,apply:(o={})=>U(n,o),clear:(o={})=>U(n,o),bind:()=>j(n)}))});function v(e){return Array.isArray(e)?e.join(l.value.config.delimiter):e}function A(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function S(e){if(!["",null,void 0,[]].includes(e))return e}function k(e){return[v,A,S].reduce((n,o)=>o(n),e)}function s(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(o=>o!==e):[...n,e]}function g(e){var n;return(n=l.value.filters)==null?void 0:n.find(o=>o.name===e)}function C(e,n=null){var o;return(o=l.value.sorts)==null?void 0:o.find(c=>c.name===e&&c.direction===n)}function q(e){var n;return(n=l.value.searches)==null?void 0:n.find(o=>o.name===e)}function z(){var e;return((e=l.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}function h(){var e;return(e=l.value.sorts)==null?void 0:e.find(({active:n})=>n)}function L(){var e;return((e=l.value.searches)==null?void 0:e.filter(({active:n})=>n))??[]}function y(e){return e?typeof e=="string"?z().some(n=>n.name===e):e.active:!!z().length}function K(e){var n;return e?typeof e=="string"?((n=h())==null?void 0:n.name)===e:e.active:!!h()}function P(e){var n,o;return e?typeof e=="string"?(o=L())==null?void 0:o.some(c=>c.name===e):e.active:!!((n=L())!=null&&n.length)}function G(e,n={}){const o=Object.fromEntries(Object.entries(e).map(([c,F])=>[c,k(F)]));b.router.reload({...f,...n,data:o})}function T(e,n,o={}){const c=typeof e=="string"?g(e):e;if(!c){console.warn(`Filter [${e}] does not exist.`);return}"multiple"in c&&c.multiple&&n!==void 0&&(n=s(n,c.value)),b.router.reload({...f,...o,data:{[c.name]:k(n)}})}function E(e,n=null,o={}){const c=typeof e=="string"?C(e,n):e;if(!c){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...f,...o,data:{[l.value.config.sorts]:S(c.next)}})}function M(e,n={}){e=[A,S].reduce((o,c)=>c(o),e),b.router.reload({...f,...n,data:{[l.value.config.searches]:e}})}function U(e,n={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}if(!(typeof e=="string"?q(e):e)){console.warn(`Match [${e}] does not exist.`);return}const o=s(e,L().filter(({active:c})=>c).map(({name:c})=>c));b.router.reload({...f,...n,data:{[l.value.config.matches]:v(o)}})}function N(e,n={}){T(e,void 0,n)}function W(e={}){b.router.reload({...f,...e,data:{[l.value.config.sorts]:null}})}function R(e={}){M(void 0,e)}function H(e={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}b.router.reload({...f,...e,data:{[l.value.config.matches]:void 0}})}function t(e={}){var n;b.router.reload({...f,...e,data:{[l.value.config.searches]:void 0,[l.value.config.sorts]:void 0,...Object.fromEntries(((n=l.value.filters)==null?void 0:n.map(o=>[o.name,void 0]))??[]),...l.value.config.matches?{[l.value.config.matches]:void 0}:{}}})}function a(e,n={}){const o=typeof e=="string"?g(e):e;if(!o){console.warn(`Filter [${e}] does not exist.`);return}const c=o.value,{debounce:F=250,transform:B=J=>J,...$}=n;return{"onUpdate:modelValue":I(J=>{T(o,B(J),$)},F),modelValue:c}}function p(e,n={}){const o=typeof e=="string"?C(e):e;if(!o){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:c=0,transform:F,...B}=n;return{onClick:I(()=>{var $;E(o,($=h())==null?void 0:$.direction,B)},c)}}function w(e={}){const{debounce:n=700,transform:o,...c}=e;return{"onUpdate:modelValue":I(F=>{M(F,c)},n),modelValue:l.value.config.search??""}}function j(e,n={}){const o=typeof e=="string"?q(e):e;if(!o){console.warn(`Match [${e}] does not exist.`);return}const{debounce:c=0,transform:F,...B}=n;return{"onUpdate:modelValue":I($=>{U($,B)},c),modelValue:P(o),value:o.name}}return{filters:i,sorts:u,searches:x,getFilter:g,getSort:C,getSearch:q,currentFilters:z,currentSort:h,currentSearches:L,isFiltering:y,isSorting:K,isSearching:P,apply:G,applyFilter:T,applySort:E,applySearch:M,applyMatch:U,clearFilter:N,clearSort:W,clearSearch:R,clearMatch:H,reset:t,bindFilter:a,bindSort:p,bindSearch:w,bindMatch:j,stringValue:A,omitValue:S,toggleValue:s,delimitArray:v}}function O(r,m,f={},l={}){if(!r||!m||!r[m])throw new Error("Table has not been provided with valid props and key.");l={...l,only:[...l.only??[],m.toString()]};const i=d.computed(()=>r[m]),u=_(),x=Z(r,m,l),v=d.computed(()=>i.value.config),A=d.computed(()=>i.value.meta),S=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:a,hidden:p})=>a&&!p).map(a=>{var p;return{...a,isSorting:(p=a.sort)==null?void 0:p.active,toggleSort:(w={})=>U(a,w)}}))??[]}),k=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:a})=>!a).map(a=>({...a,toggle:(p={})=>N(a,p)})))??[]}),s=d.computed(()=>i.value.records.map(t=>({record:(({actions:a,...p})=>p)(t),default:(a={})=>{const p=t.actions.find(w=>w.default);p&&G(p,t,a)},actions:t.actions.map(a=>({...a,execute:(p={})=>G(a,t,p)})),select:()=>u.select(y(t)),deselect:()=>u.deselect(y(t)),toggle:()=>u.toggle(y(t)),selected:u.selected(y(t)),bind:()=>u.bind(y(t)),value:a=>t[K(a)].value,extra:a=>t[K(a)].extra}))),g=d.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(a={})=>T(t,a)}))),C=d.computed(()=>i.value.actions.page.map(t=>({...t,execute:(a={})=>E(t,a)}))),q=d.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(a=>({...a,apply:(p={})=>M(a,p)})))??[]}),z=d.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:a})=>a)}),h=d.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in h.value&&h.value.nextLink&&P(h.value.nextLink,t)},previous:(t={})=>{"prevLink"in h.value&&h.value.prevLink&&P(h.value.prevLink,t)},first:(t={})=>{"firstLink"in h.value&&h.value.firstLink&&P(h.value.firstLink,t)},last:(t={})=>{"lastLink"in h.value&&h.value.lastLink&&P(h.value.lastLink,t)},..."links"in i.value.paginator&&i.value.paginator.links?{links:i.value.paginator.links.map(t=>({...t,navigate:(a={})=>t.url&&P(t.url,a)}))}:{}})),L=d.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[v.value.record].value}function K(t){return typeof t=="string"?t:t.name}function P(t,a={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...a,method:"get"})}function G(t,a,p={}){var j,e;D(t,v.value.endpoint,{table:i.value.id,id:y(a)},p)||(e=(j=f.recordActions)==null?void 0:j[t.name])==null||e.call(j,a)}function T(t,a={}){D(t,v.value.endpoint,{table:i.value.id,all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)},a)}function E(t,a={}){D(t,v.value.endpoint,{table:i.value.id},a)}function M(t,a={}){b.router.reload({...l,...a,data:{[v.value.records]:t.value,[v.value.pages]:void 0}})}function U(t,a={}){t.sort&&b.router.reload({...l,...a,data:{[v.value.sorts]:x.omitValue(t.sort.next)}})}function N(t,a={}){const p=x.toggleValue(t.name,S.value.map(({name:w})=>w));b.router.reload({...l,...a,data:{[v.value.columns]:x.delimitArray(p)}})}function W(){u.select(...i.value.records.map(t=>y(t)))}function R(){u.deselect(...i.value.records.map(t=>y(t)))}function H(){return{"onUpdate:modelValue":t=>{t?W():R()},modelValue:L.value}}return d.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:g,pageActions:C,rowsPerPage:q,currentPage:z,paginator:h,executeInlineAction:G,executeBulkAction:T,executePageAction:E,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:W,deselectPage:R,toggle:t=>u.toggle(y(t)),selected:t=>u.selected(y(t)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:L,hasSelected:u.hasSelected,bindCheckbox:t=>u.bind(y(t)),bindPage:H,bindAll:u.bindAll,...x})}V.useTable=O,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|
|
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 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 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 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?a(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:a,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function D(r,m,f={},a={}){return r.route?(b.router.visit(r.route.href,{...a,method:r.route.method}),!0):r.action&&m?(b.router.post(m,{...f,name:r.name,type:r.type},a),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(r,m){function f(...a){return new Promise((i,u)=>{Promise.resolve(r(()=>m.apply(this,a),{fn:m,thisArg:this,args:a})).then(i).catch(u)})}return f}function X(r,m={}){let f,a,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?(a&&(u(a),a=null),Promise.resolve(v())):new Promise((k,s)=>{i=m.rejectOnCancel?s:k,x=v,S&&!a&&(a=setTimeout(()=>{f&&u(f),a=null,k(x())},S)),f=setTimeout(()=>{a&&u(a),a=null,k(v())},A)})}}function I(r,m=200,f={}){return Q(X(m,f),r)}function Z(r,m,f={}){const a=d.computed(()=>r[m]),i=d.computed(()=>{var e;return((e=a.value.filters)==null?void 0:e.map(n=>({...n,apply:(l,c={})=>j(n,l,c),clear:(l={})=>N(n,l),bind:()=>o(n.name)})))??[]}),u=d.computed(()=>{var e;return((e=a.value.sorts)==null?void 0:e.map(n=>({...n,apply:(l={})=>E(n,n.direction,l),clear:(l={})=>W(l),bind:()=>p(n)})))??[]}),x=d.computed(()=>{var e;return(e=a.value.searches)==null?void 0:e.map(n=>({...n,apply:(l={})=>U(n,l),clear:(l={})=>U(n,l),bind:()=>F(n)}))});function v(e){return Array.isArray(e)?e.join(a.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,l)=>l(n),e)}function s(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(l=>l!==e):[...n,e]}function g(e){var n;return(n=a.value.filters)==null?void 0:n.find(l=>l.name===e)}function C(e,n=null){var l;return(l=a.value.sorts)==null?void 0:l.find(c=>c.name===e&&c.direction===n)}function q(e){var n;return(n=a.value.searches)==null?void 0:n.find(l=>l.name===e)}function z(){var e;return((e=a.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}function h(){var e;return(e=a.value.sorts)==null?void 0:e.find(({active:n})=>n)}function T(){var e;return((e=a.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 w(e){var n,l;return e?typeof e=="string"?(l=T())==null?void 0:l.some(c=>c.name===e):e.active:!!((n=T())!=null&&n.length)}function G(e,n={}){const l=Object.fromEntries(Object.entries(e).map(([c,V])=>[c,k(V)]));b.router.reload({...f,...n,data:l})}function j(e,n,l={}){const c=typeof e=="string"?g(e):e;if(!c){console.warn(`Filter [${e}] does not exist.`);return}"multiple"in c&&c.multiple&&n!==void 0&&(n=s(n,c.value)),b.router.reload({...f,...l,data:{[c.name]:k(n)}})}function E(e,n=null,l={}){const c=typeof e=="string"?C(e,n):e;if(!c){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...f,...l,data:{[a.value.config.sorts]:S(c.next)}})}function M(e,n={}){e=[A,S].reduce((l,c)=>c(l),e),b.router.reload({...f,...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 l=typeof e=="string"?q(e):e;if(!l){console.warn(`Match [${e}] does not exist.`);return}const c=s(l.name,T().map(({name:V})=>V));b.router.reload({...f,...n,data:{[a.value.config.matches]:v(c)}})}function N(e,n={}){j(e,void 0,n)}function W(e={}){b.router.reload({...f,...e,data:{[a.value.config.sorts]:null}})}function R(e={}){M(void 0,e)}function H(e={}){if(!a.value.config.matches){console.warn("Matches key is not set.");return}b.router.reload({...f,...e,data:{[a.value.config.matches]:void 0}})}function t(e={}){var n;b.router.reload({...f,...e,data:{[a.value.config.searches]:void 0,[a.value.config.sorts]:void 0,...Object.fromEntries(((n=a.value.filters)==null?void 0:n.map(l=>[l.name,void 0]))??[]),...a.value.config.matches?{[a.value.config.matches]:void 0}:{}}})}function o(e,n={}){const l=typeof e=="string"?g(e):e;if(!l){console.warn(`Filter [${e}] does not exist.`);return}const c=l.value,{debounce:V=250,transform:B=J=>J,...$}=n;return{"onUpdate:modelValue":I(J=>{j(l,B(J),$)},V),modelValue:c}}function p(e,n={}){const l=typeof e=="string"?C(e):e;if(!l){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:c=0,transform:V,...B}=n;return{onClick:I(()=>{var $;E(l,($=h())==null?void 0:$.direction,B)},c)}}function L(e={}){const{debounce:n=700,transform:l,...c}=e;return{"onUpdate:modelValue":I(V=>{M(V,c)},n),modelValue:a.value.config.search??""}}function F(e,n={}){const l=typeof e=="string"?q(e):e;if(!l){console.warn(`Match [${e}] does not exist.`);return}const{debounce:c=0,transform:V,...B}=n;return{"onUpdate:modelValue":I($=>{U($,B)},c),modelValue:w(l),value:l.name}}return{filters:i,sorts:u,searches:x,getFilter:g,getSort:C,getSearch:q,currentFilters:z,currentSort:h,currentSearches:T,isFiltering:y,isSorting:K,isSearching:w,apply:G,applyFilter:j,applySort:E,applySearch:M,applyMatch:U,clearFilter:N,clearSort:W,clearSearch:R,clearMatch:H,reset:t,bindFilter:o,bindSort:p,bindSearch:L,bindMatch:F,stringValue:A,omitValue:S,toggleValue:s,delimitArray:v}}function O(r,m,f={},a={}){if(!r||!m||!r[m])throw new Error("Table has not been provided with valid props and key.");a={...a,only:[...a.only??[],m.toString()]};const i=d.computed(()=>r[m]),u=_(),x=Z(r,m,a),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:o,hidden:p})=>o&&!p).map(o=>{var p;return{...o,isSorting:(p=o.sort)==null?void 0:p.active,toggleSort:(L={})=>U(o,L)}}))??[]}),k=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:o})=>!o).map(o=>({...o,toggle:(p={})=>N(o,p)})))??[]}),s=d.computed(()=>i.value.records.map(t=>({record:(({actions:o,...p})=>p)(t),default:(o={})=>{const p=t.actions.find(L=>L.default);p&&G(p,t,o)},actions:t.actions.map(o=>({...o,execute:(p={})=>G(o,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:o=>t[K(o)].value,extra:o=>t[K(o)].extra}))),g=d.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(o={})=>j(t,o)}))),C=d.computed(()=>i.value.actions.page.map(t=>({...t,execute:(o={})=>E(t,o)}))),q=d.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(o=>({...o,apply:(p={})=>M(o,p)})))??[]}),z=d.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:o})=>o)}),h=d.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:(o={})=>t.url&&w(t.url,o)}))}:{}})),T=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 w(t,o={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...a,...o,method:"get"})}function G(t,o,p={}){var F,e;D(t,v.value.endpoint,{table:i.value.id,id:y(o)},p)||(e=(F=f.recordActions)==null?void 0:F[t.name])==null||e.call(F,o)}function j(t,o={}){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)},o)}function E(t,o={}){D(t,v.value.endpoint,{table:i.value.id},o)}function M(t,o={}){b.router.reload({...a,...o,data:{[v.value.records]:t.value,[v.value.pages]:void 0}})}function U(t,o={}){t.sort&&b.router.reload({...a,...o,data:{[v.value.sorts]:x.omitValue(t.sort.next)}})}function N(t,o={}){const p=x.toggleValue(t.name,S.value.map(({name:L})=>L));b.router.reload({...a,...o,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:T.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:j,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:T,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"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honed/table",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "-",
|
|
7
7
|
"keywords": [
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@honed/action": "^0.3.2",
|
|
61
|
-
"@honed/refine": "^0.3.
|
|
61
|
+
"@honed/refine": "^0.3.2",
|
|
62
62
|
"@inertiajs/vue3": "^1.2.0||^2.0.0",
|
|
63
63
|
"@vueuse/core": "^11.0.0||^12.0.0",
|
|
64
64
|
"axios": "^1.2.0",
|