@honed/table 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -169,9 +169,6 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
169
169
  searches: {
170
170
  apply: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
171
171
  clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
172
- /**
173
- * Get the bulk actions.
174
- */
175
172
  bind: () => {
176
173
  "onUpdate:modelValue": PromisifyFn<(value: any) => void>;
177
174
  modelValue: boolean;
@@ -181,9 +178,6 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
181
178
  name: string;
182
179
  label: string;
183
180
  active: boolean;
184
- /**
185
- * Get page actions.
186
- */
187
181
  meta: Record<string, any>;
188
182
  }[] | undefined;
189
183
  getFilter: (name: string) => Filter | undefined;
@@ -231,6 +225,9 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
231
225
  isSorting: boolean | undefined;
232
226
  toggleSort: (options?: VisitOptions) => void;
233
227
  name: keyof RecordType;
228
+ /**
229
+ * The heading columns for the table.
230
+ */
234
231
  label: string;
235
232
  type: string;
236
233
  hidden: boolean;
@@ -247,6 +244,9 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
247
244
  columns: {
248
245
  toggle: (options?: VisitOptions) => void;
249
246
  name: keyof RecordType;
247
+ /**
248
+ * The heading columns for the table.
249
+ */
250
250
  label: string;
251
251
  type: string;
252
252
  hidden: boolean;
@@ -290,9 +290,7 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
290
290
  selected: boolean;
291
291
  /** Bind the record to a checkbox */
292
292
  bind: () => {
293
- "onUpdate:modelValue": (checked: boolean | "indeterminate") => void; /**
294
- * The current number of records to display per page.
295
- */
293
+ "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
296
294
  modelValue: boolean;
297
295
  value: Identifier;
298
296
  };
@@ -359,9 +357,7 @@ export declare function useTable<Props extends object, Key extends Props[keyof P
359
357
  isPageSelected: boolean;
360
358
  hasSelected: boolean;
361
359
  bindCheckbox: (record: AsRecord<RecordType>) => {
362
- "onUpdate:modelValue": (checked: boolean | "indeterminate") => void; /**
363
- * The current number of records to display per page.
364
- */
360
+ "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
365
361
  modelValue: boolean;
366
362
  value: Identifier;
367
363
  };
package/dist/index.es.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { ref as _, computed as g, toValue as J, reactive as Q } from "vue";
2
- import { router as S } from "@inertiajs/vue3";
3
- function I(o, m, v = {}, l = {}) {
4
- return o.route ? (S.visit(o.route.url, {
5
- ...l,
2
+ import { router as x } from "@inertiajs/vue3";
3
+ function I(o, m, v = {}, a = {}) {
4
+ return o.route ? (x.visit(o.route.url, {
5
+ ...a,
6
6
  method: o.route.method
7
- }), !0) : o.action && m ? (S.post(
7
+ }), !0) : o.action && m ? (x.post(
8
8
  m,
9
9
  {
10
10
  ...v,
11
11
  name: o.name,
12
12
  type: o.type
13
13
  },
14
- l
14
+ a
15
15
  ), !0) : !1;
16
16
  }
17
17
  function X() {
@@ -26,7 +26,7 @@ function X() {
26
26
  function v() {
27
27
  o.value.all = !1, o.value.only.clear(), o.value.except.clear();
28
28
  }
29
- function l(...s) {
29
+ function a(...s) {
30
30
  s.forEach((p) => o.value.except.delete(p)), s.forEach((p) => o.value.only.add(p));
31
31
  }
32
32
  function i(...s) {
@@ -36,16 +36,16 @@ function X() {
36
36
  if (b(s) || p === !1)
37
37
  return i(s);
38
38
  if (!b(s) || p === !0)
39
- return l(s);
39
+ return a(s);
40
40
  }
41
41
  function b(s) {
42
42
  return o.value.all ? !o.value.except.has(s) : o.value.only.has(s);
43
43
  }
44
44
  const f = g(() => o.value.all && o.value.except.size === 0), A = g(() => o.value.only.size > 0 || f.value);
45
- function x(s) {
45
+ function S(s) {
46
46
  return {
47
47
  "onUpdate:modelValue": (p) => {
48
- p ? l(s) : i(s);
48
+ p ? a(s) : i(s);
49
49
  },
50
50
  modelValue: b(s),
51
51
  value: s
@@ -66,11 +66,11 @@ function X() {
66
66
  hasSelected: A,
67
67
  selectAll: m,
68
68
  deselectAll: v,
69
- select: l,
69
+ select: a,
70
70
  deselect: i,
71
71
  toggle: u,
72
72
  selected: b,
73
- bind: x,
73
+ bind: S,
74
74
  bindAll: k
75
75
  };
76
76
  }
@@ -78,26 +78,26 @@ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
78
78
  const Y = () => {
79
79
  };
80
80
  function Z(o, m) {
81
- function v(...l) {
81
+ function v(...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 v;
87
87
  }
88
88
  function O(o, m = {}) {
89
- let v, l, i = Y;
89
+ let v, 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
- const A = J(o), x = J(m.maxWait);
96
- return v && u(v), A <= 0 || x !== void 0 && x <= 0 ? (l && (u(l), l = null), Promise.resolve(f())) : new Promise((k, s) => {
97
- i = m.rejectOnCancel ? s : k, b = f, x && !l && (l = setTimeout(() => {
98
- v && u(v), l = null, k(b());
99
- }, x)), v = setTimeout(() => {
100
- l && u(l), l = null, k(f());
95
+ const A = J(o), S = J(m.maxWait);
96
+ return v && u(v), A <= 0 || S !== void 0 && S <= 0 ? (a && (u(a), a = null), Promise.resolve(f())) : new Promise((k, s) => {
97
+ i = m.rejectOnCancel ? s : k, b = f, S && !a && (a = setTimeout(() => {
98
+ v && u(v), a = null, k(b());
99
+ }, S)), v = setTimeout(() => {
100
+ a && u(a), a = null, k(f());
101
101
  }, A);
102
102
  });
103
103
  };
@@ -109,20 +109,20 @@ function q(o, m = 200, v = {}) {
109
109
  );
110
110
  }
111
111
  function ee(o, m, v = {}) {
112
- const l = g(() => o[m]), i = g(
112
+ const a = g(() => o[m]), i = g(
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
- apply: (r, d = {}) => F(n, r, d),
117
+ apply: (r, d = {}) => L(n, r, d),
118
118
  clear: (r = {}) => N(n, r),
119
- bind: () => a(n.name)
119
+ bind: () => l(n.name)
120
120
  }))) ?? [];
121
121
  }
122
122
  ), u = g(
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 = {}) => W(r),
@@ -132,31 +132,31 @@ function ee(o, m, v = {}) {
132
132
  ), b = g(
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),
139
- bind: () => P(n)
139
+ bind: () => F(n)
140
140
  }));
141
141
  }
142
142
  ), f = g(
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 = g(
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
- ), x = g(
152
+ ), S = g(
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 s(e) {
162
162
  return typeof e != "string" ? e : e.trim().replace(/\s+/g, "+");
@@ -176,17 +176,17 @@ function ee(o, m, v = {}) {
176
176
  }
177
177
  function j(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
  (d) => d.name === e && d.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,27 +195,27 @@ function ee(o, m, v = {}) {
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 L(e) {
198
+ function w(e) {
199
199
  var n;
200
- return e ? typeof e == "string" ? (n = x.value) == null ? void 0 : n.some((r) => r.name === e) : e.active : !!l.value.config.term;
200
+ return e ? typeof e == "string" ? (n = S.value) == null ? void 0 : n.some((r) => r.name === e) : e.active : !!a.value.config.term;
201
201
  }
202
202
  function C(e, n = {}) {
203
203
  const r = Object.fromEntries(
204
- Object.entries(e).map(([d, w]) => [d, G(w)])
204
+ Object.entries(e).map(([d, P]) => [d, G(P)])
205
205
  );
206
- S.reload({
206
+ x.reload({
207
207
  ...v,
208
208
  ...n,
209
209
  data: r
210
210
  });
211
211
  }
212
- function F(e, n, r = {}) {
212
+ function L(e, n, r = {}) {
213
213
  const d = typeof e == "string" ? j(e) : e;
214
214
  if (!d) {
215
215
  console.warn(`Filter [${e}] does not exist.`);
216
216
  return;
217
217
  }
218
- S.reload({
218
+ x.reload({
219
219
  ...v,
220
220
  ...r,
221
221
  data: {
@@ -229,11 +229,11 @@ function ee(o, m, v = {}) {
229
229
  console.warn(`Sort [${e}] does not exist.`);
230
230
  return;
231
231
  }
232
- S.reload({
232
+ x.reload({
233
233
  ...v,
234
234
  ...r,
235
235
  data: {
236
- [l.value.config.sort]: p(d.next)
236
+ [a.value.config.sort]: p(d.next)
237
237
  }
238
238
  });
239
239
  }
@@ -241,11 +241,11 @@ function ee(o, m, v = {}) {
241
241
  e = [s, p].reduce(
242
242
  (r, d) => d(r),
243
243
  e
244
- ), S.reload({
244
+ ), x.reload({
245
245
  ...v,
246
246
  ...n,
247
247
  data: {
248
- [l.value.config.search]: e
248
+ [a.value.config.search]: e
249
249
  }
250
250
  });
251
251
  }
@@ -257,25 +257,25 @@ function ee(o, m, v = {}) {
257
257
  }
258
258
  const d = B(
259
259
  r.name,
260
- x.value.map(({ name: w }) => w)
260
+ S.value.map(({ name: P }) => P)
261
261
  );
262
- S.reload({
262
+ x.reload({
263
263
  ...v,
264
264
  ...n,
265
265
  data: {
266
- [l.value.config.match]: k(d)
266
+ [a.value.config.match]: k(d)
267
267
  }
268
268
  });
269
269
  }
270
270
  function N(e, n = {}) {
271
- F(e, void 0, n);
271
+ L(e, void 0, n);
272
272
  }
273
273
  function W(e = {}) {
274
- S.reload({
274
+ x.reload({
275
275
  ...v,
276
276
  ...e,
277
277
  data: {
278
- [l.value.config.sort]: void 0
278
+ [a.value.config.sort]: void 0
279
279
  }
280
280
  });
281
281
  }
@@ -283,29 +283,29 @@ function ee(o, m, v = {}) {
283
283
  T(void 0, e);
284
284
  }
285
285
  function D(e = {}) {
286
- if (!l.value.config.match) {
286
+ if (!a.value.config.match) {
287
287
  console.warn("Matches key is not set.");
288
288
  return;
289
289
  }
290
- S.reload({
290
+ x.reload({
291
291
  ...v,
292
292
  ...e,
293
293
  data: {
294
- [l.value.config.match]: void 0
294
+ [a.value.config.match]: void 0
295
295
  }
296
296
  });
297
297
  }
298
298
  function t(e = {}) {
299
299
  var n;
300
- S.reload({
300
+ x.reload({
301
301
  ...v,
302
302
  ...e,
303
303
  data: {
304
- [l.value.config.search]: void 0,
305
- [l.value.config.sort]: void 0,
306
- [l.value.config.match]: void 0,
304
+ [a.value.config.search]: void 0,
305
+ [a.value.config.sort]: void 0,
306
+ [a.value.config.match]: void 0,
307
307
  ...Object.fromEntries(
308
- ((n = l.value.filters) == null ? void 0 : n.map((r) => [
308
+ ((n = a.value.filters) == null ? void 0 : n.map((r) => [
309
309
  r.name,
310
310
  void 0
311
311
  ])) ?? []
@@ -313,21 +313,21 @@ function ee(o, m, v = {}) {
313
313
  }
314
314
  });
315
315
  }
316
- function a(e, n = {}) {
316
+ function l(e, n = {}) {
317
317
  const r = typeof e == "string" ? j(e) : e;
318
318
  if (!r) {
319
319
  console.warn(`Filter [${e}] does not exist.`);
320
320
  return;
321
321
  }
322
322
  const d = r.value, {
323
- debounce: w = 250,
323
+ debounce: P = 250,
324
324
  transform: z = (H) => H,
325
325
  ...$
326
326
  } = n;
327
327
  return {
328
328
  "onUpdate:modelValue": q((H) => {
329
- F(r, z(H), $);
330
- }, w),
329
+ L(r, z(H), $);
330
+ }, P),
331
331
  modelValue: d
332
332
  };
333
333
  }
@@ -337,7 +337,7 @@ function ee(o, m, v = {}) {
337
337
  console.warn(`Sort [${e}] does not exist.`);
338
338
  return;
339
339
  }
340
- const { debounce: d = 0, transform: w, ...z } = n;
340
+ const { debounce: d = 0, transform: P, ...z } = n;
341
341
  return {
342
342
  onClick: q(() => {
343
343
  var $;
@@ -349,26 +349,26 @@ function ee(o, m, v = {}) {
349
349
  const { debounce: n = 700, transform: r, ...d } = e;
350
350
  return {
351
351
  "onUpdate:modelValue": q(
352
- (w) => {
353
- T(w, d);
352
+ (P) => {
353
+ T(P, d);
354
354
  },
355
355
  n
356
356
  ),
357
- modelValue: l.value.config.term ?? ""
357
+ modelValue: a.value.config.term ?? ""
358
358
  };
359
359
  }
360
- function P(e, n = {}) {
360
+ function F(e, n = {}) {
361
361
  const r = typeof e == "string" ? E(e) : e;
362
362
  if (!r) {
363
363
  console.warn(`Match [${e}] does not exist.`);
364
364
  return;
365
365
  }
366
- const { debounce: d = 0, transform: w, ...z } = n;
366
+ const { debounce: d = 0, transform: P, ...z } = n;
367
367
  return {
368
368
  "onUpdate:modelValue": q(($) => {
369
369
  U($, z);
370
370
  }, d),
371
- modelValue: L(r),
371
+ modelValue: w(r),
372
372
  value: r.name
373
373
  };
374
374
  }
@@ -381,12 +381,12 @@ function ee(o, m, v = {}) {
381
381
  getSearch: E,
382
382
  currentFilters: f,
383
383
  currentSort: A,
384
- currentSearches: x,
384
+ currentSearches: S,
385
385
  isFiltering: y,
386
386
  isSorting: K,
387
- isSearching: L,
387
+ isSearching: w,
388
388
  apply: C,
389
- applyFilter: F,
389
+ applyFilter: L,
390
390
  applySort: M,
391
391
  applySearch: T,
392
392
  applyMatch: U,
@@ -395,60 +395,58 @@ function ee(o, m, v = {}) {
395
395
  clearSearch: R,
396
396
  clearMatch: D,
397
397
  reset: t,
398
- bindFilter: a,
398
+ bindFilter: l,
399
399
  bindSort: c,
400
400
  bindSearch: V,
401
- bindMatch: P,
401
+ bindMatch: F,
402
402
  stringValue: s,
403
403
  omitValue: p,
404
404
  toggleValue: B,
405
405
  delimitArray: k
406
406
  };
407
407
  }
408
- function le(o, m, v = {}, l = {}) {
408
+ function le(o, m, v = {}, a = {}) {
409
409
  if (!o || !m || !o[m])
410
- throw new Error(
411
- "The table has not been provided with valid props and key."
412
- );
413
- l = {
414
- ...l,
415
- only: [...l.only ?? [], m.toString()]
410
+ throw new Error("Table has not been provided with valid props and key.");
411
+ a = {
412
+ ...a,
413
+ only: [...a.only ?? [], m.toString()]
416
414
  };
417
- const i = g(() => o[m]), u = X(), b = ee(o, m, l), f = g(() => i.value.config), A = g(() => i.value.meta), x = g(
415
+ const i = g(() => o[m]), u = X(), b = ee(o, m, a), f = g(() => i.value.config), A = g(() => i.value.meta), S = g(
418
416
  () => {
419
417
  var t;
420
- return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: a, hidden: c }) => a && !c).map((a) => {
418
+ return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: l, hidden: c }) => l && !c).map((l) => {
421
419
  var c;
422
420
  return {
423
- ...a,
424
- isSorting: (c = a.sort) == null ? void 0 : c.active,
425
- toggleSort: (V = {}) => U(a, V)
421
+ ...l,
422
+ isSorting: (c = l.sort) == null ? void 0 : c.active,
423
+ toggleSort: (V = {}) => U(l, V)
426
424
  };
427
425
  })) ?? [];
428
426
  }
429
427
  ), k = g(
430
428
  () => {
431
429
  var t;
432
- return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: a }) => !a).map((a) => ({
433
- ...a,
434
- toggle: (c = {}) => N(a, c)
430
+ return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: l }) => !l).map((l) => ({
431
+ ...l,
432
+ toggle: (c = {}) => N(l, c)
435
433
  }))) ?? [];
436
434
  }
437
435
  ), s = g(
438
436
  () => i.value.records.map((t) => ({
439
- record: (({ actions: a, ...c }) => c)(t),
437
+ record: (({ actions: l, ...c }) => c)(t),
440
438
  /** The actions available for the record */
441
- actions: t.actions.map((a) => ({
442
- ...a,
439
+ actions: t.actions.map((l) => ({
440
+ ...l,
443
441
  /** Executes this action */
444
- execute: (c = {}) => C(a, t, c)
442
+ execute: (c = {}) => C(l, t, c)
445
443
  })),
446
444
  /** Perform this action when the record is clicked */
447
- default: (a = {}) => {
445
+ default: (l = {}) => {
448
446
  const c = t.actions.find(
449
447
  (V) => V.default
450
448
  );
451
- c && C(c, t, a);
449
+ c && C(c, t, l);
452
450
  },
453
451
  /** Selects this record */
454
452
  select: () => u.select(y(t)),
@@ -461,57 +459,57 @@ function le(o, m, v = {}, l = {}) {
461
459
  /** Bind the record to a checkbox */
462
460
  bind: () => u.bind(y(t)),
463
461
  /** Get the value of the record for the column */
464
- value: (a) => {
465
- const c = K(a);
462
+ value: (l) => {
463
+ const c = K(l);
466
464
  return c in t ? t[c].value : null;
467
465
  },
468
466
  /** Get the extra data of the record for the column */
469
- extra: (a) => {
470
- const c = K(a);
467
+ extra: (l) => {
468
+ const c = K(l);
471
469
  return c in t ? t[c].extra : null;
472
470
  }
473
471
  }))
474
472
  ), p = g(
475
473
  () => i.value.actions.bulk.map((t) => ({
476
474
  ...t,
477
- execute: (a = {}) => F(t, a)
475
+ execute: (l = {}) => L(t, l)
478
476
  }))
479
477
  ), G = g(
480
478
  () => i.value.actions.page.map((t) => ({
481
479
  ...t,
482
- execute: (a = {}) => M(t, a)
480
+ execute: (l = {}) => M(t, l)
483
481
  }))
484
482
  ), B = g(
485
483
  () => {
486
484
  var t;
487
- return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((a) => ({
488
- ...a,
489
- apply: (c = {}) => T(a, c)
485
+ return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((l) => ({
486
+ ...l,
487
+ apply: (c = {}) => T(l, c)
490
488
  }))) ?? [];
491
489
  }
492
490
  ), j = g(
493
491
  () => {
494
492
  var t;
495
- return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: a }) => a);
493
+ return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: l }) => l);
496
494
  }
497
495
  ), h = g(() => ({
498
496
  ...i.value.paginator,
499
497
  next: (t = {}) => {
500
- "nextLink" in h.value && h.value.nextLink && L(h.value.nextLink, t);
498
+ "nextLink" in h.value && h.value.nextLink && w(h.value.nextLink, t);
501
499
  },
502
500
  previous: (t = {}) => {
503
- "prevLink" in h.value && h.value.prevLink && L(h.value.prevLink, t);
501
+ "prevLink" in h.value && h.value.prevLink && w(h.value.prevLink, t);
504
502
  },
505
503
  first: (t = {}) => {
506
- "firstLink" in h.value && h.value.firstLink && L(h.value.firstLink, t);
504
+ "firstLink" in h.value && h.value.firstLink && w(h.value.firstLink, t);
507
505
  },
508
506
  last: (t = {}) => {
509
- "lastLink" in h.value && h.value.lastLink && L(h.value.lastLink, t);
507
+ "lastLink" in h.value && h.value.lastLink && w(h.value.lastLink, t);
510
508
  },
511
509
  ..."links" in i.value.paginator && i.value.paginator.links ? {
512
510
  links: i.value.paginator.links.map((t) => ({
513
511
  ...t,
514
- navigate: (a = {}) => t.url && L(t.url, a)
512
+ navigate: (l = {}) => t.url && w(t.url, l)
515
513
  }))
516
514
  } : {}
517
515
  })), E = g(
@@ -525,31 +523,28 @@ function le(o, m, v = {}, l = {}) {
525
523
  function K(t) {
526
524
  return typeof t == "string" ? t : t.name;
527
525
  }
528
- function L(t, a = {}) {
529
- S.visit(t, {
526
+ function w(t, l = {}) {
527
+ x.visit(t, {
530
528
  preserveScroll: !0,
531
529
  preserveState: !0,
532
- ...l,
533
530
  ...a,
531
+ ...l,
534
532
  method: "get"
535
533
  });
536
534
  }
537
- function C(t, a, c = {}) {
538
- var P, e;
535
+ function C(t, l, c = {}) {
536
+ var F, e;
539
537
  I(
540
538
  t,
541
539
  f.value.endpoint,
542
540
  {
543
541
  id: i.value.id,
544
- record: y(a)
542
+ record: y(l)
545
543
  },
546
- {
547
- ...l,
548
- ...c
549
- }
550
- ) || (e = (P = v.recordActions) == null ? void 0 : P[t.name]) == null || e.call(P, a);
544
+ c
545
+ ) || (e = (F = v.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F, l);
551
546
  }
552
- function F(t, a = {}) {
547
+ function L(t, l = {}) {
553
548
  I(
554
549
  t,
555
550
  f.value.endpoint,
@@ -561,54 +556,50 @@ function le(o, m, v = {}, l = {}) {
561
556
  },
562
557
  {
563
558
  ...l,
564
- ...a,
565
559
  onSuccess: (c) => {
566
- var V, P;
567
- (V = l.onSuccess) == null || V.call(l, c), (P = a.onSuccess) == null || P.call(a, c), t.keepSelected || u.deselectAll();
560
+ var V;
561
+ (V = l.onSuccess) == null || V.call(l, c), t.keepSelected || u.deselectAll();
568
562
  }
569
563
  }
570
564
  );
571
565
  }
572
- function M(t, a = {}) {
566
+ function M(t, l = {}) {
573
567
  I(
574
568
  t,
575
569
  f.value.endpoint,
576
570
  {
577
571
  id: i.value.id
578
572
  },
579
- {
580
- ...l,
581
- ...a
582
- }
573
+ l
583
574
  );
584
575
  }
585
- function T(t, a = {}) {
586
- S.reload({
587
- ...l,
576
+ function T(t, l = {}) {
577
+ x.reload({
588
578
  ...a,
579
+ ...l,
589
580
  data: {
590
581
  [f.value.record]: t.value,
591
582
  [f.value.page]: void 0
592
583
  }
593
584
  });
594
585
  }
595
- function U(t, a = {}) {
596
- t.sort && S.reload({
597
- ...l,
586
+ function U(t, l = {}) {
587
+ t.sort && x.reload({
598
588
  ...a,
589
+ ...l,
599
590
  data: {
600
591
  [f.value.sort]: b.omitValue(t.sort.next)
601
592
  }
602
593
  });
603
594
  }
604
- function N(t, a = {}) {
595
+ function N(t, l = {}) {
605
596
  const c = b.toggleValue(
606
597
  t.name,
607
- x.value.map(({ name: V }) => V)
598
+ S.value.map(({ name: V }) => V)
608
599
  );
609
- S.reload({
610
- ...l,
600
+ x.reload({
611
601
  ...a,
602
+ ...l,
612
603
  data: {
613
604
  [f.value.column]: b.delimitArray(c)
614
605
  }
@@ -642,7 +633,7 @@ function le(o, m, v = {}, l = {}) {
642
633
  /** Table-specific metadata */
643
634
  meta: A,
644
635
  /** The heading columns for the table */
645
- headings: x,
636
+ headings: S,
646
637
  /** All of the table's columns */
647
638
  columns: k,
648
639
  /** The records of the table */
@@ -662,7 +653,7 @@ function le(o, m, v = {}, l = {}) {
662
653
  /** Execute an inline action */
663
654
  executeInlineAction: C,
664
655
  /** Execute a bulk action */
665
- executeBulkAction: F,
656
+ executeBulkAction: L,
666
657
  /** Execute a page action */
667
658
  executePageAction: M,
668
659
  /** Apply a new page by changing the number of records to display */
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(L,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],s):(L=typeof globalThis<"u"?globalThis:L||self,s(L["@honed/table"]={},L.Vue,L.Inertia))})(this,function(L,s,b){"use strict";function D(o,p,f={},l={}){return o.route?(b.router.visit(o.route.url,{...l,method:o.route.method}),!0):o.action&&p?(b.router.post(p,{...f,name:o.name,type:o.type},l),!0):!1}function _(){const o=s.ref({all:!1,only:new Set,except:new Set});function p(){o.value.all=!0,o.value.only.clear(),o.value.except.clear()}function f(){o.value.all=!1,o.value.only.clear(),o.value.except.clear()}function l(...d){d.forEach(g=>o.value.except.delete(g)),d.forEach(g=>o.value.only.add(g))}function i(...d){d.forEach(g=>o.value.except.add(g)),d.forEach(g=>o.value.only.delete(g))}function u(d,g){if(S(d)||g===!1)return i(d);if(!S(d)||g===!0)return l(d)}function S(d){return o.value.all?!o.value.except.has(d):o.value.only.has(d)}const m=s.computed(()=>o.value.all&&o.value.except.size===0),A=s.computed(()=>o.value.only.size>0||m.value);function x(d){return{"onUpdate:modelValue":g=>{g?l(d):i(d)},modelValue:S(d),value:d}}function k(){return{"onUpdate:modelValue":d=>{d?p():f()},modelValue:m.value,value:m.value}}return{allSelected:m,selection:o,hasSelected:A,selectAll:p,deselectAll:f,select:l,deselect:i,toggle:u,selected:S,bind:x,bindAll:k}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(o,p){function f(...l){return new Promise((i,u)=>{Promise.resolve(o(()=>p.apply(this,l),{fn:p,thisArg:this,args:l})).then(i).catch(u)})}return f}function X(o,p={}){let f,l,i=Y;const u=m=>{clearTimeout(m),i(),i=Y};let S;return m=>{const A=s.toValue(o),x=s.toValue(p.maxWait);return f&&u(f),A<=0||x!==void 0&&x<=0?(l&&(u(l),l=null),Promise.resolve(m())):new Promise((k,d)=>{i=p.rejectOnCancel?d:k,S=m,x&&!l&&(l=setTimeout(()=>{f&&u(f),l=null,k(S())},x)),f=setTimeout(()=>{l&&u(l),l=null,k(m())},A)})}}function G(o,p=200,f={}){return Q(X(p,f),o)}function Z(o,p,f={}){const l=s.computed(()=>o[p]),i=s.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(r,v={})=>j(n,r,v),clear:(r={})=>N(n,r),bind:()=>a(n.name)})))??[]}),u=s.computed(()=>{var e;return((e=l.value.sorts)==null?void 0:e.map(n=>({...n,apply:(r={})=>E(n,n.direction,r),clear:(r={})=>q(r),bind:()=>c(n)})))??[]}),S=s.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:()=>P(n)}))}),m=s.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}),A=s.computed(()=>{var e;return(e=l.value.sorts)==null?void 0:e.find(({active:n})=>n)}),x=s.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 d(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function g(e){if(!["",null,void 0,[]].includes(e))return e}function B(e){return[k,d,g].reduce((n,r)=>r(n),e)}function I(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(r=>r!==e):[...n,e]}function C(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(v=>v.name===e&&v.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 T(e){var n;return e?typeof e=="string"?(n=x.value)==null?void 0:n.some(r=>r.name===e):e.active:!!l.value.config.term}function W(e,n={}){const r=Object.fromEntries(Object.entries(e).map(([v,w])=>[v,B(w)]));b.router.reload({...f,...n,data:r})}function j(e,n,r={}){const v=typeof e=="string"?C(e):e;if(!v){console.warn(`Filter [${e}] does not exist.`);return}b.router.reload({...f,...r,data:{[v.name]:B(n)}})}function E(e,n=null,r={}){const v=typeof e=="string"?h(e,n):e;if(!v){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...f,...r,data:{[l.value.config.sort]:g(v.next)}})}function M(e,n={}){e=[d,g].reduce((r,v)=>v(r),e),b.router.reload({...f,...n,data:{[l.value.config.search]:e}})}function U(e,n={}){const r=typeof e=="string"?F(e):e;if(!r){console.warn(`Match [${e}] does not exist.`);return}const v=I(r.name,x.value.map(({name:w})=>w));b.router.reload({...f,...n,data:{[l.value.config.match]:k(v)}})}function N(e,n={}){j(e,void 0,n)}function q(e={}){b.router.reload({...f,...e,data:{[l.value.config.sort]:void 0}})}function R(e={}){M(void 0,e)}function H(e={}){if(!l.value.config.match){console.warn("Matches key is not set.");return}b.router.reload({...f,...e,data:{[l.value.config.match]:void 0}})}function t(e={}){var n;b.router.reload({...f,...e,data:{[l.value.config.search]:void 0,[l.value.config.sort]:void 0,[l.value.config.match]: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"?C(e):e;if(!r){console.warn(`Filter [${e}] does not exist.`);return}const v=r.value,{debounce:w=250,transform:z=J=>J,...$}=n;return{"onUpdate:modelValue":G(J=>{j(r,z(J),$)},w),modelValue:v}}function c(e,n={}){const r=typeof e=="string"?h(e):e;if(!r){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:v=0,transform:w,...z}=n;return{onClick:G(()=>{var $;E(r,($=A.value)==null?void 0:$.direction,z)},v)}}function V(e={}){const{debounce:n=700,transform:r,...v}=e;return{"onUpdate:modelValue":G(w=>{M(w,v)},n),modelValue:l.value.config.term??""}}function P(e,n={}){const r=typeof e=="string"?F(e):e;if(!r){console.warn(`Match [${e}] does not exist.`);return}const{debounce:v=0,transform:w,...z}=n;return{"onUpdate:modelValue":G($=>{U($,z)},v),modelValue:T(r),value:r.name}}return{filters:i,sorts:u,searches:S,getFilter:C,getSort:h,getSearch:F,currentFilters:m,currentSort:A,currentSearches:x,isFiltering:y,isSorting:K,isSearching:T,apply:W,applyFilter:j,applySort:E,applySearch:M,applyMatch:U,clearFilter:N,clearSort:q,clearSearch:R,clearMatch:H,reset:t,bindFilter:a,bindSort:c,bindSearch:V,bindMatch:P,stringValue:d,omitValue:g,toggleValue:I,delimitArray:k}}function O(o,p,f={},l={}){if(!o||!p||!o[p])throw new Error("The table has not been provided with valid props and key.");l={...l,only:[...l.only??[],p.toString()]};const i=s.computed(()=>o[p]),u=_(),S=Z(o,p,l),m=s.computed(()=>i.value.config),A=s.computed(()=>i.value.meta),x=s.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:a,hidden:c})=>a&&!c).map(a=>{var c;return{...a,isSorting:(c=a.sort)==null?void 0:c.active,toggleSort:(V={})=>U(a,V)}}))??[]}),k=s.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:a})=>!a).map(a=>({...a,toggle:(c={})=>N(a,c)})))??[]}),d=s.computed(()=>i.value.records.map(t=>({record:(({actions:a,...c})=>c)(t),actions:t.actions.map(a=>({...a,execute:(c={})=>W(a,t,c)})),default:(a={})=>{const c=t.actions.find(V=>V.default);c&&W(c,t,a)},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 c=K(a);return c in t?t[c].value:null},extra:a=>{const c=K(a);return c in t?t[c].extra:null}}))),g=s.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(a={})=>j(t,a)}))),B=s.computed(()=>i.value.actions.page.map(t=>({...t,execute:(a={})=>E(t,a)}))),I=s.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(a=>({...a,apply:(c={})=>M(a,c)})))??[]}),C=s.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:a})=>a)}),h=s.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in h.value&&h.value.nextLink&&T(h.value.nextLink,t)},previous:(t={})=>{"prevLink"in h.value&&h.value.prevLink&&T(h.value.prevLink,t)},first:(t={})=>{"firstLink"in h.value&&h.value.firstLink&&T(h.value.firstLink,t)},last:(t={})=>{"lastLink"in h.value&&h.value.lastLink&&T(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&&T(t.url,a)}))}:{}})),F=s.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[m.value.key].value}function K(t){return typeof t=="string"?t:t.name}function T(t,a={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...a,method:"get"})}function W(t,a,c={}){var P,e;D(t,m.value.endpoint,{id:i.value.id,record:y(a)},{...l,...c})||(e=(P=f.recordActions)==null?void 0:P[t.name])==null||e.call(P,a)}function j(t,a={}){D(t,m.value.endpoint,{id:i.value.id,all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)},{...l,...a,onSuccess:c=>{var V,P;(V=l.onSuccess)==null||V.call(l,c),(P=a.onSuccess)==null||P.call(a,c),t.keepSelected||u.deselectAll()}})}function E(t,a={}){D(t,m.value.endpoint,{id:i.value.id},{...l,...a})}function M(t,a={}){b.router.reload({...l,...a,data:{[m.value.record]:t.value,[m.value.page]:void 0}})}function U(t,a={}){t.sort&&b.router.reload({...l,...a,data:{[m.value.sort]:S.omitValue(t.sort.next)}})}function N(t,a={}){const c=S.toggleValue(t.name,x.value.map(({name:V})=>V));b.router.reload({...l,...a,data:{[m.value.column]:S.delimitArray(c)}})}function q(){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?q():R()},modelValue:F.value}}return s.reactive({getRecordKey:y,meta:A,headings:x,columns:k,records:d,inline:i.value.actions.inline,bulkActions:g,pageActions:B,rowsPerPage:I,currentPage:C,paginator:h,executeInlineAction:W,executeBulkAction:j,executePageAction:E,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:q,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,...S})}L.useTable=O,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
1
+ (function(w,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],s):(w=typeof globalThis<"u"?globalThis:w||self,s(w["@honed/table"]={},w.Vue,w.Inertia))})(this,function(w,s,b){"use strict";function D(o,p,f={},a={}){return o.route?(b.router.visit(o.route.url,{...a,method:o.route.method}),!0):o.action&&p?(b.router.post(p,{...f,name:o.name,type:o.type},a),!0):!1}function _(){const o=s.ref({all:!1,only:new Set,except:new Set});function p(){o.value.all=!0,o.value.only.clear(),o.value.except.clear()}function f(){o.value.all=!1,o.value.only.clear(),o.value.except.clear()}function a(...d){d.forEach(g=>o.value.except.delete(g)),d.forEach(g=>o.value.only.add(g))}function i(...d){d.forEach(g=>o.value.except.add(g)),d.forEach(g=>o.value.only.delete(g))}function u(d,g){if(S(d)||g===!1)return i(d);if(!S(d)||g===!0)return a(d)}function S(d){return o.value.all?!o.value.except.has(d):o.value.only.has(d)}const m=s.computed(()=>o.value.all&&o.value.except.size===0),A=s.computed(()=>o.value.only.size>0||m.value);function x(d){return{"onUpdate:modelValue":g=>{g?a(d):i(d)},modelValue:S(d),value:d}}function k(){return{"onUpdate:modelValue":d=>{d?p():f()},modelValue:m.value,value:m.value}}return{allSelected:m,selection:o,hasSelected:A,selectAll:p,deselectAll:f,select:a,deselect:i,toggle:u,selected:S,bind:x,bindAll:k}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(o,p){function f(...a){return new Promise((i,u)=>{Promise.resolve(o(()=>p.apply(this,a),{fn:p,thisArg:this,args:a})).then(i).catch(u)})}return f}function X(o,p={}){let f,a,i=Y;const u=m=>{clearTimeout(m),i(),i=Y};let S;return m=>{const A=s.toValue(o),x=s.toValue(p.maxWait);return f&&u(f),A<=0||x!==void 0&&x<=0?(a&&(u(a),a=null),Promise.resolve(m())):new Promise((k,d)=>{i=p.rejectOnCancel?d:k,S=m,x&&!a&&(a=setTimeout(()=>{f&&u(f),a=null,k(S())},x)),f=setTimeout(()=>{a&&u(a),a=null,k(m())},A)})}}function G(o,p=200,f={}){return Q(X(p,f),o)}function Z(o,p,f={}){const a=s.computed(()=>o[p]),i=s.computed(()=>{var e;return((e=a.value.filters)==null?void 0:e.map(n=>({...n,apply:(r,v={})=>T(n,r,v),clear:(r={})=>N(n,r),bind:()=>l(n.name)})))??[]}),u=s.computed(()=>{var e;return((e=a.value.sorts)==null?void 0:e.map(n=>({...n,apply:(r={})=>E(n,n.direction,r),clear:(r={})=>q(r),bind:()=>c(n)})))??[]}),S=s.computed(()=>{var e;return(e=a.value.searches)==null?void 0:e.map(n=>({...n,apply:(r={})=>U(n,r),clear:(r={})=>U(n,r),bind:()=>j(n)}))}),m=s.computed(()=>{var e;return((e=a.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}),A=s.computed(()=>{var e;return(e=a.value.sorts)==null?void 0:e.find(({active:n})=>n)}),x=s.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 d(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function g(e){if(!["",null,void 0,[]].includes(e))return e}function B(e){return[k,d,g].reduce((n,r)=>r(n),e)}function I(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(r=>r!==e):[...n,e]}function C(e){var n;return(n=a.value.filters)==null?void 0:n.find(r=>r.name===e)}function h(e,n=null){var r;return(r=a.value.sorts)==null?void 0:r.find(v=>v.name===e&&v.direction===n)}function F(e){var n;return(n=a.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=x.value)==null?void 0:n.some(r=>r.name===e):e.active:!!a.value.config.term}function W(e,n={}){const r=Object.fromEntries(Object.entries(e).map(([v,P])=>[v,B(P)]));b.router.reload({...f,...n,data:r})}function T(e,n,r={}){const v=typeof e=="string"?C(e):e;if(!v){console.warn(`Filter [${e}] does not exist.`);return}b.router.reload({...f,...r,data:{[v.name]:B(n)}})}function E(e,n=null,r={}){const v=typeof e=="string"?h(e,n):e;if(!v){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...f,...r,data:{[a.value.config.sort]:g(v.next)}})}function M(e,n={}){e=[d,g].reduce((r,v)=>v(r),e),b.router.reload({...f,...n,data:{[a.value.config.search]:e}})}function U(e,n={}){const r=typeof e=="string"?F(e):e;if(!r){console.warn(`Match [${e}] does not exist.`);return}const v=I(r.name,x.value.map(({name:P})=>P));b.router.reload({...f,...n,data:{[a.value.config.match]:k(v)}})}function N(e,n={}){T(e,void 0,n)}function q(e={}){b.router.reload({...f,...e,data:{[a.value.config.sort]:void 0}})}function R(e={}){M(void 0,e)}function H(e={}){if(!a.value.config.match){console.warn("Matches key is not set.");return}b.router.reload({...f,...e,data:{[a.value.config.match]:void 0}})}function t(e={}){var n;b.router.reload({...f,...e,data:{[a.value.config.search]:void 0,[a.value.config.sort]:void 0,[a.value.config.match]:void 0,...Object.fromEntries(((n=a.value.filters)==null?void 0:n.map(r=>[r.name,void 0]))??[])}})}function l(e,n={}){const r=typeof e=="string"?C(e):e;if(!r){console.warn(`Filter [${e}] does not exist.`);return}const v=r.value,{debounce:P=250,transform:z=J=>J,...$}=n;return{"onUpdate:modelValue":G(J=>{T(r,z(J),$)},P),modelValue:v}}function c(e,n={}){const r=typeof e=="string"?h(e):e;if(!r){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:v=0,transform:P,...z}=n;return{onClick:G(()=>{var $;E(r,($=A.value)==null?void 0:$.direction,z)},v)}}function V(e={}){const{debounce:n=700,transform:r,...v}=e;return{"onUpdate:modelValue":G(P=>{M(P,v)},n),modelValue:a.value.config.term??""}}function j(e,n={}){const r=typeof e=="string"?F(e):e;if(!r){console.warn(`Match [${e}] does not exist.`);return}const{debounce:v=0,transform:P,...z}=n;return{"onUpdate:modelValue":G($=>{U($,z)},v),modelValue:L(r),value:r.name}}return{filters:i,sorts:u,searches:S,getFilter:C,getSort:h,getSearch:F,currentFilters:m,currentSort:A,currentSearches:x,isFiltering:y,isSorting:K,isSearching:L,apply:W,applyFilter:T,applySort:E,applySearch:M,applyMatch:U,clearFilter:N,clearSort:q,clearSearch:R,clearMatch:H,reset:t,bindFilter:l,bindSort:c,bindSearch:V,bindMatch:j,stringValue:d,omitValue:g,toggleValue:I,delimitArray:k}}function O(o,p,f={},a={}){if(!o||!p||!o[p])throw new Error("Table has not been provided with valid props and key.");a={...a,only:[...a.only??[],p.toString()]};const i=s.computed(()=>o[p]),u=_(),S=Z(o,p,a),m=s.computed(()=>i.value.config),A=s.computed(()=>i.value.meta),x=s.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:l,hidden:c})=>l&&!c).map(l=>{var c;return{...l,isSorting:(c=l.sort)==null?void 0:c.active,toggleSort:(V={})=>U(l,V)}}))??[]}),k=s.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:l})=>!l).map(l=>({...l,toggle:(c={})=>N(l,c)})))??[]}),d=s.computed(()=>i.value.records.map(t=>({record:(({actions:l,...c})=>c)(t),actions:t.actions.map(l=>({...l,execute:(c={})=>W(l,t,c)})),default:(l={})=>{const c=t.actions.find(V=>V.default);c&&W(c,t,l)},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 c=K(l);return c in t?t[c].value:null},extra:l=>{const c=K(l);return c in t?t[c].extra:null}}))),g=s.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(l={})=>T(t,l)}))),B=s.computed(()=>i.value.actions.page.map(t=>({...t,execute:(l={})=>E(t,l)}))),I=s.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(l=>({...l,apply:(c={})=>M(l,c)})))??[]}),C=s.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:l})=>l)}),h=s.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:(l={})=>t.url&&L(t.url,l)}))}:{}})),F=s.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[m.value.key].value}function K(t){return typeof t=="string"?t:t.name}function L(t,l={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...a,...l,method:"get"})}function W(t,l,c={}){var j,e;D(t,m.value.endpoint,{id:i.value.id,record:y(l)},c)||(e=(j=f.recordActions)==null?void 0:j[t.name])==null||e.call(j,l)}function T(t,l={}){D(t,m.value.endpoint,{id:i.value.id,all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)},{...l,onSuccess:c=>{var V;(V=l.onSuccess)==null||V.call(l,c),t.keepSelected||u.deselectAll()}})}function E(t,l={}){D(t,m.value.endpoint,{id:i.value.id},l)}function M(t,l={}){b.router.reload({...a,...l,data:{[m.value.record]:t.value,[m.value.page]:void 0}})}function U(t,l={}){t.sort&&b.router.reload({...a,...l,data:{[m.value.sort]:S.omitValue(t.sort.next)}})}function N(t,l={}){const c=S.toggleValue(t.name,x.value.map(({name:V})=>V));b.router.reload({...a,...l,data:{[m.value.column]:S.delimitArray(c)}})}function q(){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?q():R()},modelValue:F.value}}return s.reactive({getRecordKey:y,meta:A,headings:x,columns:k,records:d,inline:i.value.actions.inline,bulkActions:g,pageActions:B,rowsPerPage:I,currentPage:C,paginator:h,executeInlineAction:W,executeBulkAction:T,executePageAction:E,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:q,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,...S})}w.useTable=O,Object.defineProperty(w,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.7.0",
4
+ "version": "0.7.1",
5
5
  "license": "MIT",
6
6
  "description": "-",
7
7
  "keywords": [