@honed/table 0.3.0 → 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 +6 -4
- package/dist/index.es.js +112 -110
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -134,9 +134,9 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
|
|
|
134
134
|
modelValue: unknown;
|
|
135
135
|
} | undefined;
|
|
136
136
|
type: string;
|
|
137
|
-
multiple: boolean;
|
|
138
|
-
options: Option_2[];
|
|
139
137
|
value: FilterValue;
|
|
138
|
+
options: Option_2[];
|
|
139
|
+
multiple: boolean;
|
|
140
140
|
name: string;
|
|
141
141
|
label: string;
|
|
142
142
|
active: boolean;
|
|
@@ -162,10 +162,11 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
|
|
|
162
162
|
bind: () => {
|
|
163
163
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
164
164
|
modelValue: boolean;
|
|
165
|
+
value: string;
|
|
165
166
|
} | undefined;
|
|
167
|
+
type: string;
|
|
166
168
|
name: string;
|
|
167
169
|
label: string;
|
|
168
|
-
type: string;
|
|
169
170
|
active: boolean;
|
|
170
171
|
meta: Record<string, any>;
|
|
171
172
|
}[] | undefined;
|
|
@@ -182,7 +183,7 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
|
|
|
182
183
|
applyFilter: (filter: string | Filter, value: any, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
183
184
|
applySort: (sort: string | Sort, direction?: Direction | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
184
185
|
applySearch: (value: string | null | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
185
|
-
applyMatch: (
|
|
186
|
+
applyMatch: (search: string | Search, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
186
187
|
clearFilter: (filter: string | Filter, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
187
188
|
clearSort: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
188
189
|
clearSearch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
@@ -202,6 +203,7 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
|
|
|
202
203
|
bindMatch: (match: string | Search, options?: BindingOptions | undefined) => {
|
|
203
204
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
204
205
|
modelValue: boolean;
|
|
206
|
+
value: string;
|
|
205
207
|
} | undefined;
|
|
206
208
|
stringValue: (value: any) => any;
|
|
207
209
|
omitValue: (value: any) => any;
|
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,35 +192,35 @@ 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.`);
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
|
-
"multiple" in c && c.multiple && (n = s(n, c.value)), S.reload({
|
|
215
|
+
"multiple" in c && c.multiple && n !== void 0 && (n = s(n, c.value)), S.reload({
|
|
216
216
|
...v,
|
|
217
|
-
...
|
|
217
|
+
...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({
|
|
@@ -291,7 +292,7 @@ function ee(o, m, v = {}) {
|
|
|
291
292
|
...v,
|
|
292
293
|
...e,
|
|
293
294
|
data: {
|
|
294
|
-
[l.value.config.matches]:
|
|
295
|
+
[l.value.config.matches]: void 0
|
|
295
296
|
}
|
|
296
297
|
});
|
|
297
298
|
}
|
|
@@ -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,62 +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
|
+
modelValue: V(a),
|
|
373
|
+
value: a.name
|
|
372
374
|
};
|
|
373
375
|
}
|
|
374
376
|
return {
|
|
@@ -380,12 +382,12 @@ function ee(o, m, v = {}) {
|
|
|
380
382
|
getSearch: C,
|
|
381
383
|
currentFilters: z,
|
|
382
384
|
currentSort: g,
|
|
383
|
-
currentSearches:
|
|
385
|
+
currentSearches: L,
|
|
384
386
|
isFiltering: y,
|
|
385
387
|
isSorting: K,
|
|
386
|
-
isSearching:
|
|
388
|
+
isSearching: V,
|
|
387
389
|
apply: G,
|
|
388
|
-
applyFilter:
|
|
390
|
+
applyFilter: F,
|
|
389
391
|
applySort: M,
|
|
390
392
|
applySearch: T,
|
|
391
393
|
applyMatch: U,
|
|
@@ -394,10 +396,10 @@ function ee(o, m, v = {}) {
|
|
|
394
396
|
clearSearch: R,
|
|
395
397
|
clearMatch: D,
|
|
396
398
|
reset: t,
|
|
397
|
-
bindFilter:
|
|
399
|
+
bindFilter: r,
|
|
398
400
|
bindSort: f,
|
|
399
|
-
bindSearch:
|
|
400
|
-
bindMatch:
|
|
401
|
+
bindSearch: w,
|
|
402
|
+
bindMatch: E,
|
|
401
403
|
stringValue: A,
|
|
402
404
|
omitValue: x,
|
|
403
405
|
toggleValue: s,
|
|
@@ -414,38 +416,38 @@ function le(o, m, v = {}, l = {}) {
|
|
|
414
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(
|
|
415
417
|
() => {
|
|
416
418
|
var t;
|
|
417
|
-
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) => {
|
|
418
420
|
var f;
|
|
419
421
|
return {
|
|
420
|
-
...
|
|
421
|
-
isSorting: (f =
|
|
422
|
-
toggleSort: (
|
|
422
|
+
...r,
|
|
423
|
+
isSorting: (f = r.sort) == null ? void 0 : f.active,
|
|
424
|
+
toggleSort: (w = {}) => U(r, w)
|
|
423
425
|
};
|
|
424
426
|
})) ?? [];
|
|
425
427
|
}
|
|
426
428
|
), k = h(
|
|
427
429
|
() => {
|
|
428
430
|
var t;
|
|
429
|
-
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden:
|
|
430
|
-
...
|
|
431
|
-
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)
|
|
432
434
|
}))) ?? [];
|
|
433
435
|
}
|
|
434
436
|
), s = h(
|
|
435
437
|
() => i.value.records.map((t) => ({
|
|
436
|
-
record: (({ actions:
|
|
438
|
+
record: (({ actions: r, ...f }) => f)(t),
|
|
437
439
|
/** Perform this action when the record is clicked */
|
|
438
|
-
default: (
|
|
440
|
+
default: (r = {}) => {
|
|
439
441
|
const f = t.actions.find(
|
|
440
|
-
(
|
|
442
|
+
(w) => w.default
|
|
441
443
|
);
|
|
442
|
-
f && G(f, t,
|
|
444
|
+
f && G(f, t, r);
|
|
443
445
|
},
|
|
444
446
|
/** The actions available for the record */
|
|
445
|
-
actions: t.actions.map((
|
|
446
|
-
...
|
|
447
|
+
actions: t.actions.map((r) => ({
|
|
448
|
+
...r,
|
|
447
449
|
/** Executes this action */
|
|
448
|
-
execute: (f = {}) => G(
|
|
450
|
+
execute: (f = {}) => G(r, t, f)
|
|
449
451
|
})),
|
|
450
452
|
/** Selects this record */
|
|
451
453
|
select: () => u.select(y(t)),
|
|
@@ -458,57 +460,57 @@ function le(o, m, v = {}, l = {}) {
|
|
|
458
460
|
/** Bind the record to a checkbox */
|
|
459
461
|
bind: () => u.bind(y(t)),
|
|
460
462
|
/** Get the value of the record for the column */
|
|
461
|
-
value: (
|
|
463
|
+
value: (r) => t[K(r)].value,
|
|
462
464
|
/** Get the extra data of the record for the column */
|
|
463
|
-
extra: (
|
|
465
|
+
extra: (r) => t[K(r)].extra
|
|
464
466
|
}))
|
|
465
467
|
), p = h(
|
|
466
468
|
() => i.value.actions.bulk.map((t) => ({
|
|
467
469
|
...t,
|
|
468
470
|
/** Executes this bulk action */
|
|
469
|
-
execute: (
|
|
471
|
+
execute: (r = {}) => F(t, r)
|
|
470
472
|
}))
|
|
471
473
|
), j = h(
|
|
472
474
|
() => i.value.actions.page.map((t) => ({
|
|
473
475
|
...t,
|
|
474
476
|
/** Executes this page action */
|
|
475
|
-
execute: (
|
|
477
|
+
execute: (r = {}) => M(t, r)
|
|
476
478
|
}))
|
|
477
479
|
), C = h(
|
|
478
480
|
() => {
|
|
479
481
|
var t;
|
|
480
|
-
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((
|
|
481
|
-
...
|
|
482
|
+
return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((r) => ({
|
|
483
|
+
...r,
|
|
482
484
|
/** Changes the number of records to display per page */
|
|
483
|
-
apply: (f = {}) => T(
|
|
485
|
+
apply: (f = {}) => T(r, f)
|
|
484
486
|
}))) ?? [];
|
|
485
487
|
}
|
|
486
488
|
), z = h(
|
|
487
489
|
() => {
|
|
488
490
|
var t;
|
|
489
|
-
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);
|
|
490
492
|
}
|
|
491
493
|
), g = h(() => ({
|
|
492
494
|
...i.value.paginator,
|
|
493
495
|
next: (t = {}) => {
|
|
494
|
-
"nextLink" in g.value && g.value.nextLink &&
|
|
496
|
+
"nextLink" in g.value && g.value.nextLink && V(g.value.nextLink, t);
|
|
495
497
|
},
|
|
496
498
|
previous: (t = {}) => {
|
|
497
|
-
"prevLink" in g.value && g.value.prevLink &&
|
|
499
|
+
"prevLink" in g.value && g.value.prevLink && V(g.value.prevLink, t);
|
|
498
500
|
},
|
|
499
501
|
first: (t = {}) => {
|
|
500
|
-
"firstLink" in g.value && g.value.firstLink &&
|
|
502
|
+
"firstLink" in g.value && g.value.firstLink && V(g.value.firstLink, t);
|
|
501
503
|
},
|
|
502
504
|
last: (t = {}) => {
|
|
503
|
-
"lastLink" in g.value && g.value.lastLink &&
|
|
505
|
+
"lastLink" in g.value && g.value.lastLink && V(g.value.lastLink, t);
|
|
504
506
|
},
|
|
505
507
|
..."links" in i.value.paginator && i.value.paginator.links ? {
|
|
506
508
|
links: i.value.paginator.links.map((t) => ({
|
|
507
509
|
...t,
|
|
508
|
-
navigate: (
|
|
510
|
+
navigate: (r = {}) => t.url && V(t.url, r)
|
|
509
511
|
}))
|
|
510
512
|
} : {}
|
|
511
|
-
})),
|
|
513
|
+
})), L = h(
|
|
512
514
|
() => i.value.records.length > 0 && i.value.records.every(
|
|
513
515
|
(t) => u.selected(y(t))
|
|
514
516
|
)
|
|
@@ -519,28 +521,28 @@ function le(o, m, v = {}, l = {}) {
|
|
|
519
521
|
function K(t) {
|
|
520
522
|
return typeof t == "string" ? t : t.name;
|
|
521
523
|
}
|
|
522
|
-
function
|
|
524
|
+
function V(t, r = {}) {
|
|
523
525
|
S.visit(t, {
|
|
524
526
|
preserveScroll: !0,
|
|
525
527
|
preserveState: !0,
|
|
526
528
|
...l,
|
|
527
|
-
...
|
|
529
|
+
...r,
|
|
528
530
|
method: "get"
|
|
529
531
|
});
|
|
530
532
|
}
|
|
531
|
-
function G(t,
|
|
532
|
-
var
|
|
533
|
+
function G(t, r, f = {}) {
|
|
534
|
+
var E, e;
|
|
533
535
|
I(
|
|
534
536
|
t,
|
|
535
537
|
d.value.endpoint,
|
|
536
538
|
{
|
|
537
539
|
table: i.value.id,
|
|
538
|
-
id: y(
|
|
540
|
+
id: y(r)
|
|
539
541
|
},
|
|
540
542
|
f
|
|
541
|
-
) || (e = (
|
|
543
|
+
) || (e = (E = v.recordActions) == null ? void 0 : E[t.name]) == null || e.call(E, r);
|
|
542
544
|
}
|
|
543
|
-
function
|
|
545
|
+
function F(t, r = {}) {
|
|
544
546
|
I(
|
|
545
547
|
t,
|
|
546
548
|
d.value.endpoint,
|
|
@@ -550,46 +552,46 @@ function le(o, m, v = {}, l = {}) {
|
|
|
550
552
|
only: Array.from(u.selection.value.only),
|
|
551
553
|
except: Array.from(u.selection.value.except)
|
|
552
554
|
},
|
|
553
|
-
|
|
555
|
+
r
|
|
554
556
|
);
|
|
555
557
|
}
|
|
556
|
-
function M(t,
|
|
558
|
+
function M(t, r = {}) {
|
|
557
559
|
I(
|
|
558
560
|
t,
|
|
559
561
|
d.value.endpoint,
|
|
560
562
|
{
|
|
561
563
|
table: i.value.id
|
|
562
564
|
},
|
|
563
|
-
|
|
565
|
+
r
|
|
564
566
|
);
|
|
565
567
|
}
|
|
566
|
-
function T(t,
|
|
568
|
+
function T(t, r = {}) {
|
|
567
569
|
S.reload({
|
|
568
570
|
...l,
|
|
569
|
-
...
|
|
571
|
+
...r,
|
|
570
572
|
data: {
|
|
571
573
|
[d.value.records]: t.value,
|
|
572
574
|
[d.value.pages]: void 0
|
|
573
575
|
}
|
|
574
576
|
});
|
|
575
577
|
}
|
|
576
|
-
function U(t,
|
|
578
|
+
function U(t, r = {}) {
|
|
577
579
|
t.sort && S.reload({
|
|
578
580
|
...l,
|
|
579
|
-
...
|
|
581
|
+
...r,
|
|
580
582
|
data: {
|
|
581
583
|
[d.value.sorts]: b.omitValue(t.sort.next)
|
|
582
584
|
}
|
|
583
585
|
});
|
|
584
586
|
}
|
|
585
|
-
function N(t,
|
|
587
|
+
function N(t, r = {}) {
|
|
586
588
|
const f = b.toggleValue(
|
|
587
589
|
t.name,
|
|
588
|
-
x.value.map(({ name:
|
|
590
|
+
x.value.map(({ name: w }) => w)
|
|
589
591
|
);
|
|
590
592
|
S.reload({
|
|
591
593
|
...l,
|
|
592
|
-
...
|
|
594
|
+
...r,
|
|
593
595
|
data: {
|
|
594
596
|
[d.value.columns]: b.delimitArray(f)
|
|
595
597
|
}
|
|
@@ -614,7 +616,7 @@ function le(o, m, v = {}, l = {}) {
|
|
|
614
616
|
"onUpdate:modelValue": (t) => {
|
|
615
617
|
t ? W() : R();
|
|
616
618
|
},
|
|
617
|
-
modelValue:
|
|
619
|
+
modelValue: L.value
|
|
618
620
|
};
|
|
619
621
|
}
|
|
620
622
|
return Q({
|
|
@@ -641,7 +643,7 @@ function le(o, m, v = {}, l = {}) {
|
|
|
641
643
|
/** Execute an inline action */
|
|
642
644
|
executeInlineAction: G,
|
|
643
645
|
/** Execute a bulk action */
|
|
644
|
-
executeBulkAction:
|
|
646
|
+
executeBulkAction: F,
|
|
645
647
|
/** Execute a page action */
|
|
646
648
|
executePageAction: M,
|
|
647
649
|
/** Apply a new page by changing the number of records to display */
|
|
@@ -665,7 +667,7 @@ function le(o, m, v = {}, l = {}) {
|
|
|
665
667
|
/** Deselect all records */
|
|
666
668
|
deselectAll: u.deselectAll,
|
|
667
669
|
/** Whether all records on the current page are selected */
|
|
668
|
-
isPageSelected:
|
|
670
|
+
isPageSelected: L,
|
|
669
671
|
/** Determine if any records are selected */
|
|
670
672
|
hasSelected: u.hasSelected,
|
|
671
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=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"})});
|
|
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",
|