@honed/table 0.4.1 → 0.4.3

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 CHANGED
@@ -180,6 +180,9 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
180
180
  name: string;
181
181
  label: string;
182
182
  active: boolean;
183
+ /**
184
+ * The available bulk actions.
185
+ */
183
186
  meta: Record<string, any>;
184
187
  }[] | undefined;
185
188
  getFilter: (name: string) => Filter | undefined;
@@ -293,7 +296,7 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
293
296
  /** Get the value of the record for the column */
294
297
  value: (column: Column<RecordType> | string) => RecordType[string] | RecordType[number] | RecordType[symbol] | null;
295
298
  /** Get the extra data of the record for the column */
296
- extra: (column: Column<RecordType> | string) => any;
299
+ extra: (column: Column<RecordType> | string) => Record<string, any> | null;
297
300
  }[];
298
301
  bulkActions: {
299
302
  /** 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 l(...c) {
15
+ function a(...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 l(c);
25
+ return a(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 ? l(c) : i(c);
34
+ g ? a(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: l,
55
+ select: a,
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 = {}, l = {}) {
63
+ function I(o, m, d = {}, a = {}) {
64
64
  return o.route ? (x.visit(o.route.href, {
65
- ...l,
65
+ ...a,
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 = {}, l = {}) {
71
71
  name: o.name,
72
72
  type: o.type
73
73
  },
74
- l
74
+ a
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(...l) {
81
+ function d(...a) {
82
82
  return new Promise((i, u) => {
83
- Promise.resolve(o(() => m.apply(this, l), { fn: m, thisArg: this, args: l })).then(i).catch(u);
83
+ Promise.resolve(o(() => m.apply(this, a), { fn: m, thisArg: this, args: a })).then(i).catch(u);
84
84
  });
85
85
  }
86
86
  return d;
87
87
  }
88
88
  function O(o, m = {}) {
89
- let d, l, i = Y;
89
+ let d, a, 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 ? (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());
96
+ return d && u(d), A <= 0 || S !== void 0 && S <= 0 ? (a && (u(a), a = null), Promise.resolve(f())) : new Promise((k, c) => {
97
+ i = m.rejectOnCancel ? c : k, b = f, S && !a && (a = setTimeout(() => {
98
+ d && u(d), a = null, k(b());
99
99
  }, S)), d = setTimeout(() => {
100
- l && u(l), l = null, k(f());
100
+ a && u(a), a = 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 l = p(() => o[m]), i = p(
112
+ const a = p(() => o[m]), i = p(
113
113
  () => {
114
114
  var e;
115
- return ((e = l.value.filters) == null ? void 0 : e.map((n) => ({
115
+ return ((e = a.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: () => a(n.name)
119
+ bind: () => l(n.name)
120
120
  }))) ?? [];
121
121
  }
122
122
  ), u = p(
123
123
  () => {
124
124
  var e;
125
- return ((e = l.value.sorts) == null ? void 0 : e.map((n) => ({
125
+ return ((e = a.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 = l.value.searches) == null ? void 0 : e.map((n) => ({
135
+ return (e = a.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 = l.value.filters) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
145
+ return ((e = a.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 = l.value.sorts) == null ? void 0 : e.find(({ active: n }) => n);
150
+ return (e = a.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 = l.value.searches) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
155
+ return ((e = a.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(l.value.config.delimiter) : e;
159
+ return Array.isArray(e) ? e.join(a.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 = l.value.filters) == null ? void 0 : n.find((r) => r.name === e);
179
+ return (n = a.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 = l.value.sorts) == null ? void 0 : r.find(
183
+ return (r = a.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 = l.value.searches) == null ? void 0 : n.find((r) => r.name === e);
189
+ return (n = a.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 w(e) {
198
+ function P(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 : !!l.value.config.search;
200
+ return e ? typeof e == "string" ? (n = S.value) == null ? void 0 : n.some((r) => r.name === e) : e.active : !!a.value.config.search;
201
201
  }
202
202
  function W(e, n = {}) {
203
203
  const r = Object.fromEntries(
204
- Object.entries(e).map(([v, P]) => [v, B(P)])
204
+ Object.entries(e).map(([v, V]) => [v, B(V)])
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
- [l.value.config.sorts]: g(v.next)
236
+ [a.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
- [l.value.config.searches]: e
248
+ [a.value.config.searches]: e
249
249
  }
250
250
  });
251
251
  }
252
252
  function U(e, n = {}) {
253
- if (!l.value.config.matches) {
253
+ if (!a.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: P }) => P)
264
+ S.value.map(({ name: V }) => V)
265
265
  );
266
266
  x.reload({
267
267
  ...d,
268
268
  ...n,
269
269
  data: {
270
- [l.value.config.matches]: k(v)
270
+ [a.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
- [l.value.config.sorts]: void 0
282
+ [a.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 (!l.value.config.matches) {
290
+ if (!a.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
- [l.value.config.matches]: void 0
298
+ [a.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
- [l.value.config.searches]: void 0,
309
- [l.value.config.sorts]: void 0,
310
- [l.value.config.matches]: void 0,
308
+ [a.value.config.searches]: void 0,
309
+ [a.value.config.sorts]: void 0,
310
+ [a.value.config.matches]: void 0,
311
311
  ...Object.fromEntries(
312
- ((n = l.value.filters) == null ? void 0 : n.map((r) => [
312
+ ((n = a.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 a(e, n = {}) {
320
+ function l(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: P = 250,
327
+ debounce: V = 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
- }, P),
334
+ }, V),
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: P, ...G } = n;
344
+ const { debounce: v = 0, transform: V, ...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 V(e = {}) {
352
+ function w(e = {}) {
353
353
  const { debounce: n = 700, transform: r, ...v } = e;
354
354
  return {
355
355
  "onUpdate:modelValue": q(
356
- (P) => {
357
- T(P, v);
356
+ (V) => {
357
+ T(V, v);
358
358
  },
359
359
  n
360
360
  ),
361
- modelValue: l.value.config.search ?? ""
361
+ modelValue: a.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: P, ...G } = n;
370
+ const { debounce: v = 0, transform: V, ...G } = n;
371
371
  return {
372
372
  "onUpdate:modelValue": q(($) => {
373
373
  U($, G);
374
374
  }, v),
375
- modelValue: w(r),
375
+ modelValue: P(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: w,
391
+ isSearching: P,
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: a,
402
+ bindFilter: l,
403
403
  bindSort: s,
404
- bindSearch: V,
404
+ bindSearch: w,
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 le(o, m, d = {}, l = {}) {
412
+ function ae(o, m, d = {}, a = {}) {
413
413
  if (!o || !m || !o[m])
414
414
  throw new Error("Table has not been provided with valid props and key.");
415
- l = {
416
- ...l,
417
- only: [...l.only ?? [], m.toString()]
415
+ a = {
416
+ ...a,
417
+ only: [...a.only ?? [], m.toString()]
418
418
  };
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(
419
+ const i = p(() => o[m]), u = X(), b = ee(o, m, a), 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: a, hidden: s }) => a && !s).map((a) => {
422
+ return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: l, hidden: s }) => l && !s).map((l) => {
423
423
  var s;
424
424
  return {
425
- ...a,
426
- isSorting: (s = a.sort) == null ? void 0 : s.active,
427
- toggleSort: (V = {}) => U(a, V)
425
+ ...l,
426
+ isSorting: (s = l.sort) == null ? void 0 : s.active,
427
+ toggleSort: (w = {}) => U(l, w)
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: a }) => !a).map((a) => ({
435
- ...a,
436
- toggle: (s = {}) => N(a, s)
434
+ return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: l }) => !l).map((l) => ({
435
+ ...l,
436
+ toggle: (s = {}) => N(l, s)
437
437
  }))) ?? [];
438
438
  }
439
439
  ), c = p(
440
440
  () => i.value.records.map((t) => ({
441
- record: (({ actions: a, ...s }) => s)(t),
441
+ record: (({ actions: l, ...s }) => s)(t),
442
442
  /** Perform this action when the record is clicked */
443
- default: (a = {}) => {
443
+ default: (l = {}) => {
444
444
  const s = t.actions.find(
445
- (V) => V.default
445
+ (w) => w.default
446
446
  );
447
- s && W(s, t, a);
447
+ s && W(s, t, l);
448
448
  },
449
449
  /** The actions available for the record */
450
- actions: t.actions.map((a) => ({
451
- ...a,
450
+ actions: t.actions.map((l) => ({
451
+ ...l,
452
452
  /** Executes this action */
453
- execute: (s = {}) => W(a, t, s)
453
+ execute: (s = {}) => W(l, t, s)
454
454
  })),
455
455
  /** Selects this record */
456
456
  select: () => u.select(y(t)),
@@ -463,61 +463,60 @@ function le(o, m, d = {}, l = {}) {
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: (a) => {
467
- const s = t[K(a)];
468
- return s ? s.value : null;
466
+ value: (l) => {
467
+ const s = K(l);
468
+ return s in t ? t[s].value : null;
469
469
  },
470
470
  /** Get the extra data of the record for the column */
471
- extra: (a) => {
472
- var V;
473
- const s = (V = t[K(a)]) == null ? void 0 : V.extra;
474
- return s ? s.value : null;
471
+ extra: (l) => {
472
+ const s = K(l);
473
+ return s in t ? t[s].extra : null;
475
474
  }
476
475
  }))
477
476
  ), g = p(
478
477
  () => i.value.actions.bulk.map((t) => ({
479
478
  ...t,
480
479
  /** Executes this bulk action */
481
- execute: (a = {}) => L(t, a)
480
+ execute: (l = {}) => L(t, l)
482
481
  }))
483
482
  ), B = p(
484
483
  () => i.value.actions.page.map((t) => ({
485
484
  ...t,
486
485
  /** Executes this page action */
487
- execute: (a = {}) => M(t, a)
486
+ execute: (l = {}) => M(t, l)
488
487
  }))
489
488
  ), j = p(
490
489
  () => {
491
490
  var t;
492
- return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((a) => ({
493
- ...a,
491
+ return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((l) => ({
492
+ ...l,
494
493
  /** Changes the number of records to display per page */
495
- apply: (s = {}) => T(a, s)
494
+ apply: (s = {}) => T(l, s)
496
495
  }))) ?? [];
497
496
  }
498
497
  ), C = p(
499
498
  () => {
500
499
  var t;
501
- return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: a }) => a);
500
+ return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: l }) => l);
502
501
  }
503
502
  ), h = p(() => ({
504
503
  ...i.value.paginator,
505
504
  next: (t = {}) => {
506
- "nextLink" in h.value && h.value.nextLink && w(h.value.nextLink, t);
505
+ "nextLink" in h.value && h.value.nextLink && P(h.value.nextLink, t);
507
506
  },
508
507
  previous: (t = {}) => {
509
- "prevLink" in h.value && h.value.prevLink && w(h.value.prevLink, t);
508
+ "prevLink" in h.value && h.value.prevLink && P(h.value.prevLink, t);
510
509
  },
511
510
  first: (t = {}) => {
512
- "firstLink" in h.value && h.value.firstLink && w(h.value.firstLink, t);
511
+ "firstLink" in h.value && h.value.firstLink && P(h.value.firstLink, t);
513
512
  },
514
513
  last: (t = {}) => {
515
- "lastLink" in h.value && h.value.lastLink && w(h.value.lastLink, t);
514
+ "lastLink" in h.value && h.value.lastLink && P(h.value.lastLink, t);
516
515
  },
517
516
  ..."links" in i.value.paginator && i.value.paginator.links ? {
518
517
  links: i.value.paginator.links.map((t) => ({
519
518
  ...t,
520
- navigate: (a = {}) => t.url && w(t.url, a)
519
+ navigate: (l = {}) => t.url && P(t.url, l)
521
520
  }))
522
521
  } : {}
523
522
  })), E = p(
@@ -531,28 +530,28 @@ function le(o, m, d = {}, l = {}) {
531
530
  function K(t) {
532
531
  return typeof t == "string" ? t : t.name;
533
532
  }
534
- function w(t, a = {}) {
533
+ function P(t, l = {}) {
535
534
  x.visit(t, {
536
535
  preserveScroll: !0,
537
536
  preserveState: !0,
538
- ...l,
539
537
  ...a,
538
+ ...l,
540
539
  method: "get"
541
540
  });
542
541
  }
543
- function W(t, a, s = {}) {
542
+ function W(t, l, s = {}) {
544
543
  var F, e;
545
544
  I(
546
545
  t,
547
546
  f.value.endpoint,
548
547
  {
549
548
  table: i.value.id,
550
- id: y(a)
549
+ id: y(l)
551
550
  },
552
551
  s
553
- ) || (e = (F = d.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F, a);
552
+ ) || (e = (F = d.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F, l);
554
553
  }
555
- function L(t, a = {}) {
554
+ function L(t, l = {}) {
556
555
  I(
557
556
  t,
558
557
  f.value.endpoint,
@@ -562,46 +561,46 @@ function le(o, m, d = {}, l = {}) {
562
561
  only: Array.from(u.selection.value.only),
563
562
  except: Array.from(u.selection.value.except)
564
563
  },
565
- a
564
+ l
566
565
  );
567
566
  }
568
- function M(t, a = {}) {
567
+ function M(t, l = {}) {
569
568
  I(
570
569
  t,
571
570
  f.value.endpoint,
572
571
  {
573
572
  table: i.value.id
574
573
  },
575
- a
574
+ l
576
575
  );
577
576
  }
578
- function T(t, a = {}) {
577
+ function T(t, l = {}) {
579
578
  x.reload({
580
- ...l,
581
579
  ...a,
580
+ ...l,
582
581
  data: {
583
582
  [f.value.records]: t.value,
584
583
  [f.value.pages]: void 0
585
584
  }
586
585
  });
587
586
  }
588
- function U(t, a = {}) {
587
+ function U(t, l = {}) {
589
588
  t.sort && x.reload({
590
- ...l,
591
589
  ...a,
590
+ ...l,
592
591
  data: {
593
592
  [f.value.sorts]: b.omitValue(t.sort.next)
594
593
  }
595
594
  });
596
595
  }
597
- function N(t, a = {}) {
596
+ function N(t, l = {}) {
598
597
  const s = b.toggleValue(
599
598
  t.name,
600
- S.value.map(({ name: V }) => V)
599
+ S.value.map(({ name: w }) => w)
601
600
  );
602
601
  x.reload({
603
- ...l,
604
602
  ...a,
603
+ ...l,
605
604
  data: {
606
605
  [f.value.columns]: b.delimitArray(s)
607
606
  }
@@ -691,5 +690,5 @@ function le(o, m, d = {}, l = {}) {
691
690
  });
692
691
  }
693
692
  export {
694
- le as useTable
693
+ ae as useTable
695
694
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
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"})});
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=>{const d=K(l);return d in t?t[d].value:null},extra:l=>{const d=K(l);return d in t?t[d].extra:null}}))),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"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@honed/table",
3
3
  "private": false,
4
- "version": "0.4.1",
4
+ "version": "0.4.3",
5
5
  "license": "MIT",
6
6
  "description": "-",
7
7
  "keywords": [