@honed/table 0.19.0 → 0.21.0

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.es.js CHANGED
@@ -1,17 +1,17 @@
1
- import { ref as re, computed as f, toValue as te, reactive as oe } from "vue";
1
+ import { ref as re, computed as v, toValue as te, reactive as oe } from "vue";
2
2
  import { router as x } from "@inertiajs/vue3";
3
3
  import le from "axios";
4
- function ne(r, p = {}, m = {}) {
4
+ function ne(r, h = {}, p = {}) {
5
5
  if (!r.href || !r.method)
6
6
  return !1;
7
7
  if (r.type === "inertia")
8
- r.method === "delete" ? x.delete(r.href, m) : x[r.method](r.href, p, m);
8
+ r.method === "delete" ? x.delete(r.href, p) : x[r.method](r.href, h, p);
9
9
  else {
10
10
  const d = (c) => {
11
11
  var o;
12
- return (o = m.onError) == null ? void 0 : o.call(m, c);
12
+ return (o = p.onError) == null ? void 0 : o.call(p, c);
13
13
  };
14
- r.method === "get" ? window.location.href = r.href : r.method === "delete" ? le.delete(r.href).catch(d) : le[r.method](r.href, p).catch(d);
14
+ r.method === "get" ? window.location.href = r.href : r.method === "delete" ? le.delete(r.href).catch(d) : le[r.method](r.href, h).catch(d);
15
15
  }
16
16
  return !0;
17
17
  }
@@ -21,39 +21,39 @@ function ue() {
21
21
  only: /* @__PURE__ */ new Set(),
22
22
  except: /* @__PURE__ */ new Set()
23
23
  });
24
- function p() {
24
+ function h() {
25
25
  r.value.all = !0, r.value.only.clear(), r.value.except.clear();
26
26
  }
27
- function m() {
27
+ function p() {
28
28
  r.value.all = !1, r.value.only.clear(), r.value.except.clear();
29
29
  }
30
- function d(...v) {
31
- v.forEach((b) => r.value.except.delete(b)), v.forEach((b) => r.value.only.add(b));
30
+ function d(...f) {
31
+ f.forEach((b) => r.value.except.delete(b)), f.forEach((b) => r.value.only.add(b));
32
32
  }
33
- function c(...v) {
34
- v.forEach((b) => r.value.except.add(b)), v.forEach((b) => r.value.only.delete(b));
33
+ function c(...f) {
34
+ f.forEach((b) => r.value.except.add(b)), f.forEach((b) => r.value.only.delete(b));
35
35
  }
36
- function o(v, b) {
37
- if (h(v) || b === !1) return c(v);
38
- if (!h(v) || b === !0) return d(v);
36
+ function o(f, b) {
37
+ if (m(f) || b === !1) return c(f);
38
+ if (!m(f) || b === !0) return d(f);
39
39
  }
40
- function h(v) {
41
- return r.value.all ? !r.value.except.has(v) : r.value.only.has(v);
40
+ function m(f) {
41
+ return r.value.all ? !r.value.except.has(f) : r.value.only.has(f);
42
42
  }
43
- const u = f(() => r.value.all && r.value.except.size === 0), _ = f(() => r.value.only.size > 0 || u.value);
44
- function k(v) {
43
+ const u = v(() => r.value.all && r.value.except.size === 0), k = v(() => r.value.only.size > 0 || u.value);
44
+ function _(f) {
45
45
  return {
46
46
  "onUpdate:modelValue": (b) => {
47
- b ? d(v) : c(v);
47
+ b ? d(f) : c(f);
48
48
  },
49
- modelValue: h(v),
50
- value: v
49
+ modelValue: m(f),
50
+ value: f
51
51
  };
52
52
  }
53
53
  function g() {
54
54
  return {
55
- "onUpdate:modelValue": (v) => {
56
- v ? p() : m();
55
+ "onUpdate:modelValue": (f) => {
56
+ f ? h() : p();
57
57
  },
58
58
  modelValue: u.value
59
59
  };
@@ -61,89 +61,89 @@ function ue() {
61
61
  return {
62
62
  allSelected: u,
63
63
  selection: r,
64
- hasSelected: _,
65
- selectAll: p,
66
- deselectAll: m,
64
+ hasSelected: k,
65
+ selectAll: h,
66
+ deselectAll: p,
67
67
  select: d,
68
68
  deselect: c,
69
69
  toggle: o,
70
- selected: h,
71
- bind: k,
70
+ selected: m,
71
+ bind: _,
72
72
  bindAll: g
73
73
  };
74
74
  }
75
75
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
76
76
  const ae = () => {
77
77
  };
78
- function ie(r, p) {
79
- function m(...d) {
78
+ function ie(r, h) {
79
+ function p(...d) {
80
80
  return new Promise((c, o) => {
81
- Promise.resolve(r(() => p.apply(this, d), { fn: p, thisArg: this, args: d })).then(c).catch(o);
81
+ Promise.resolve(r(() => h.apply(this, d), { fn: h, thisArg: this, args: d })).then(c).catch(o);
82
82
  });
83
83
  }
84
- return m;
84
+ return p;
85
85
  }
86
- function se(r, p = {}) {
87
- let m, d, c = ae;
86
+ function se(r, h = {}) {
87
+ let p, d, c = ae;
88
88
  const o = (u) => {
89
89
  clearTimeout(u), c(), c = ae;
90
90
  };
91
- let h;
91
+ let m;
92
92
  return (u) => {
93
- const _ = te(r), k = te(p.maxWait);
94
- return m && o(m), _ <= 0 || k !== void 0 && k <= 0 ? (d && (o(d), d = null), Promise.resolve(u())) : new Promise((g, v) => {
95
- c = p.rejectOnCancel ? v : g, h = u, k && !d && (d = setTimeout(() => {
96
- m && o(m), d = null, g(h());
97
- }, k)), m = setTimeout(() => {
93
+ const k = te(r), _ = te(h.maxWait);
94
+ return p && o(p), k <= 0 || _ !== void 0 && _ <= 0 ? (d && (o(d), d = null), Promise.resolve(u())) : new Promise((g, f) => {
95
+ c = h.rejectOnCancel ? f : g, m = u, _ && !d && (d = setTimeout(() => {
96
+ p && o(p), d = null, g(m());
97
+ }, _)), p = setTimeout(() => {
98
98
  d && o(d), d = null, g(u());
99
- }, _);
99
+ }, k);
100
100
  });
101
101
  };
102
102
  }
103
- function Y(r, p = 200, m = {}) {
103
+ function Y(r, h = 200, p = {}) {
104
104
  return ie(
105
- se(p, m),
105
+ se(h, p),
106
106
  r
107
107
  );
108
108
  }
109
- function ce(r, p, m = {}, d = {}) {
110
- if (!(r != null && r[p]))
109
+ function ce(r, h, p = {}, d = {}) {
110
+ if (!(r != null && r[h]))
111
111
  throw new Error("The refine must be provided with valid props and key.");
112
- const { onFinish: c, ...o } = m, h = re(!1), u = f(() => r[p]), _ = f(() => u.value.term), k = f(() => !!u.value._sort_key), g = f(() => !!u.value._search_key), v = f(() => !!u.value._match_key), b = f(
112
+ const { onFinish: c, ...o } = p, m = re(!1), u = v(() => r[h]), k = v(() => u.value.term), _ = v(() => !!u.value._sort_key), g = v(() => !!u.value._search_key), f = v(() => !!u.value._match_key), b = v(
113
113
  () => {
114
114
  var n;
115
115
  return (n = u.value.filters) == null ? void 0 : n.map((l) => ({
116
116
  ...l,
117
117
  apply: (e, t = {}) => y(l, e, t),
118
118
  clear: (e = {}) => D(l, e),
119
- bind: () => I(l.name)
119
+ bind: (e = {}) => I(l.name, e)
120
120
  }));
121
121
  }
122
- ), M = f(
122
+ ), M = v(
123
123
  () => {
124
124
  var n;
125
125
  return (n = u.value.sorts) == null ? void 0 : n.map((l) => ({
126
126
  ...l,
127
127
  apply: (e = {}) => F(l, l.direction, e),
128
128
  clear: (e = {}) => G(e),
129
- bind: () => Q(l)
129
+ bind: (e = {}) => Q(l, e)
130
130
  }));
131
131
  }
132
- ), U = f(
132
+ ), U = v(
133
133
  () => {
134
134
  var n;
135
135
  return (n = u.value.searches) == null ? void 0 : n.map((l) => ({
136
136
  ...l,
137
137
  apply: (e = {}) => A(l, e),
138
138
  clear: (e = {}) => A(l, e),
139
- bind: () => K(l)
139
+ bind: (e = {}) => K(l, e)
140
140
  }));
141
141
  }
142
- ), E = f(
142
+ ), E = v(
143
143
  () => b.value.filter(({ active: n }) => n)
144
- ), P = f(
144
+ ), P = v(
145
145
  () => M.value.find(({ active: n }) => n)
146
- ), L = f(
146
+ ), L = v(
147
147
  () => U.value.filter(({ active: n }) => n)
148
148
  );
149
149
  function T(n) {
@@ -185,18 +185,18 @@ function ce(r, p, m = {}, d = {}) {
185
185
  }
186
186
  function B(n) {
187
187
  var l;
188
- return n ? typeof n == "string" ? (l = L.value) == null ? void 0 : l.some((e) => e.name === n) : n.active : !!_.value;
188
+ return n ? typeof n == "string" ? (l = L.value) == null ? void 0 : l.some((e) => e.name === n) : n.active : !!k.value;
189
189
  }
190
190
  function J(n, l = {}) {
191
191
  const e = Object.fromEntries(
192
192
  Object.entries(n).map(([i, s]) => [i, q(s)])
193
193
  ), { onFinish: t, ...a } = l;
194
- h.value = !0, x.reload({
194
+ m.value = !0, x.reload({
195
195
  ...o,
196
196
  ...a,
197
197
  data: e,
198
198
  onFinish: (i) => {
199
- h.value = !1, t == null || t(i), c == null || c(i);
199
+ m.value = !1, t == null || t(i), c == null || c(i);
200
200
  }
201
201
  });
202
202
  }
@@ -204,11 +204,11 @@ function ce(r, p, m = {}, d = {}) {
204
204
  const t = C(n);
205
205
  if (!t) return console.warn(`Filter [${n}] does not exist.`);
206
206
  const { parameters: a, onFinish: i, ...s } = e;
207
- h.value = !0, x.reload({
207
+ m.value = !0, x.reload({
208
208
  ...o,
209
209
  ...s,
210
210
  onFinish: (w) => {
211
- h.value = !1, i == null || i(w), c == null || c(w);
211
+ m.value = !1, i == null || i(w), c == null || c(w);
212
212
  },
213
213
  data: {
214
214
  [t.name]: q(l),
@@ -218,16 +218,16 @@ function ce(r, p, m = {}, d = {}) {
218
218
  });
219
219
  }
220
220
  function F(n, l = null, e = {}) {
221
- if (!k.value)
221
+ if (!_.value)
222
222
  return console.warn("Refine cannot perform sorting.");
223
223
  const t = W(n, l);
224
224
  if (!t) return console.warn(`Sort [${n}] does not exist.`);
225
225
  const { parameters: a, onFinish: i, ...s } = e;
226
- x.reload({
226
+ m.value = !0, x.reload({
227
227
  ...o,
228
228
  ...s,
229
229
  onFinish: (w) => {
230
- h.value = !1, i == null || i(w), c == null || c(w);
230
+ m.value = !1, i == null || i(w), c == null || c(w);
231
231
  },
232
232
  data: {
233
233
  [u.value._sort_key]: R(t.next),
@@ -243,11 +243,11 @@ function ce(r, p, m = {}, d = {}) {
243
243
  n
244
244
  );
245
245
  const { parameters: e, onFinish: t, ...a } = l;
246
- x.reload({
246
+ m.value = !0, x.reload({
247
247
  ...o,
248
248
  ...a,
249
249
  onFinish: (i) => {
250
- h.value = !1, t == null || t(i), c == null || c(i);
250
+ m.value = !1, t == null || t(i), c == null || c(i);
251
251
  },
252
252
  data: {
253
253
  [u.value._search_key]: n,
@@ -257,7 +257,7 @@ function ce(r, p, m = {}, d = {}) {
257
257
  });
258
258
  }
259
259
  function A(n, l = {}) {
260
- if (!v.value || !g.value)
260
+ if (!f.value || !g.value)
261
261
  return console.warn("Refine cannot perform matching.");
262
262
  const e = z(n);
263
263
  if (!e) return console.warn(`Match [${n}] does not exist.`);
@@ -265,11 +265,11 @@ function ce(r, p, m = {}, d = {}) {
265
265
  e.name,
266
266
  L.value.map(({ name: w }) => w)
267
267
  ), { parameters: a, onFinish: i, ...s } = l;
268
- x.reload({
268
+ m.value = !0, x.reload({
269
269
  ...o,
270
270
  ...s,
271
271
  onFinish: (w) => {
272
- h.value = !1, i == null || i(w), c == null || c(w);
272
+ m.value = !1, i == null || i(w), c == null || c(w);
273
273
  },
274
274
  data: {
275
275
  [u.value._match_key]: T(t),
@@ -281,11 +281,11 @@ function ce(r, p, m = {}, d = {}) {
281
281
  function D(n, l = {}) {
282
282
  if (n) return y(n, null, l);
283
283
  const { parameters: e, onFinish: t, ...a } = l;
284
- x.reload({
284
+ m.value = !0, x.reload({
285
285
  ...o,
286
286
  ...a,
287
287
  onFinish: (i) => {
288
- h.value = !1, t == null || t(i), c == null || c(i);
288
+ m.value = !1, t == null || t(i), c == null || c(i);
289
289
  },
290
290
  data: {
291
291
  ...Object.fromEntries(
@@ -296,14 +296,14 @@ function ce(r, p, m = {}, d = {}) {
296
296
  });
297
297
  }
298
298
  function G(n = {}) {
299
- if (!k.value)
299
+ if (!_.value)
300
300
  return console.warn("Refine cannot perform sorting.");
301
301
  const { parameters: l, onFinish: e, ...t } = n;
302
- x.reload({
302
+ m.value = !0, x.reload({
303
303
  ...o,
304
304
  ...t,
305
305
  onFinish: (a) => {
306
- h.value = !1, e == null || e(a), c == null || c(a);
306
+ m.value = !1, e == null || e(a), c == null || c(a);
307
307
  },
308
308
  data: {
309
309
  [u.value._sort_key]: null,
@@ -315,14 +315,14 @@ function ce(r, p, m = {}, d = {}) {
315
315
  $(null, n);
316
316
  }
317
317
  function O(n = {}) {
318
- if (!v.value)
318
+ if (!f.value)
319
319
  return console.warn("Refine cannot perform matching.");
320
320
  const { parameters: l, onFinish: e, ...t } = n;
321
- x.reload({
321
+ m.value = !0, x.reload({
322
322
  ...o,
323
323
  ...t,
324
324
  onFinish: (a) => {
325
- h.value = !1, e == null || e(a), c == null || c(a);
325
+ m.value = !1, e == null || e(a), c == null || c(a);
326
326
  },
327
327
  data: {
328
328
  [u.value._match_key]: null,
@@ -333,11 +333,11 @@ function ce(r, p, m = {}, d = {}) {
333
333
  function N(n = {}) {
334
334
  var l;
335
335
  const { parameters: e, onFinish: t, ...a } = n;
336
- x.reload({
336
+ m.value = !0, x.reload({
337
337
  ...o,
338
338
  ...a,
339
339
  onFinish: (i) => {
340
- h.value = !1, t == null || t(i), c == null || c(i);
340
+ m.value = !1, t == null || t(i), c == null || c(i);
341
341
  },
342
342
  data: {
343
343
  [u.value._search_key ?? ""]: void 0,
@@ -369,7 +369,7 @@ function ce(r, p, m = {}, d = {}) {
369
369
  };
370
370
  }
371
371
  function Q(n, l = {}) {
372
- if (!k.value)
372
+ if (!_.value)
373
373
  return console.warn("Refine cannot perform sorting.");
374
374
  const e = W(n);
375
375
  if (!e) return console.warn(`Sort [${n}] does not exist.`);
@@ -384,7 +384,7 @@ function ce(r, p, m = {}, d = {}) {
384
384
  function ee(n = {}) {
385
385
  if (!g.value)
386
386
  return console.warn("Refine cannot perform searching.");
387
- const { debounce: l = 700, transform: e, ...t } = n;
387
+ const { debounce: l = 750, transform: e, ...t } = n;
388
388
  return {
389
389
  "onUpdate:modelValue": Y(
390
390
  (a) => {
@@ -392,11 +392,11 @@ function ce(r, p, m = {}, d = {}) {
392
392
  },
393
393
  l
394
394
  ),
395
- modelValue: _.value ?? ""
395
+ modelValue: k.value ?? ""
396
396
  };
397
397
  }
398
398
  function K(n, l = {}) {
399
- if (!v.value)
399
+ if (!f.value)
400
400
  return console.warn("Refine cannot perform matching.");
401
401
  const e = z(n);
402
402
  if (!e) return console.warn(`Match [${n}] does not exist.`);
@@ -410,17 +410,17 @@ function ce(r, p, m = {}, d = {}) {
410
410
  };
411
411
  }
412
412
  return {
413
- processing: h,
413
+ processing: m,
414
414
  filters: b,
415
415
  sorts: M,
416
416
  searches: U,
417
417
  currentFilters: E,
418
418
  currentSort: P,
419
419
  currentSearches: L,
420
- searchTerm: _,
421
- isSortable: k,
420
+ searchTerm: k,
421
+ isSortable: _,
422
422
  isSearchable: g,
423
- isMatchable: v,
423
+ isMatchable: f,
424
424
  isFiltering: Z,
425
425
  isSorting: S,
426
426
  isSearching: B,
@@ -447,31 +447,31 @@ function ce(r, p, m = {}, d = {}) {
447
447
  delimitArray: T
448
448
  };
449
449
  }
450
- function me(r, p, m = {}) {
451
- if (!(r != null && r[p]))
450
+ function me(r, h, p = {}) {
451
+ if (!(r != null && r[h]))
452
452
  throw new Error("The table must be provided with valid props and key.");
453
453
  const { recordOperations: d = {}, ...c } = {
454
- only: [...m.only ?? [], p.toString()],
455
- ...m
456
- }, o = f(() => r[p]), h = f(() => o.value._id), u = ue(), { processing: _, ...k } = ce(r, p, c, {
454
+ only: [...p.only ?? [], h.toString()],
455
+ ...p
456
+ }, o = v(() => r[h]), m = v(() => o.value._id), u = ue(), { processing: k, ..._ } = ce(r, h, c, {
457
457
  [o.value._page_key]: void 0
458
- }), { onFinish: g, ...v } = c, b = f(() => o.value.meta), M = f(() => o.value.views ?? []), U = f(() => o.value.state ?? null), E = f(() => o.value.placeholder ?? null), P = f(() => !!o.value.state), L = f(
458
+ }), { onFinish: g, ...f } = c, b = v(() => o.value.meta), M = v(() => o.value.views ?? []), U = v(() => o.value.state ?? null), E = v(() => o.value.placeholder ?? null), P = v(() => !!o.value.state), L = v(
459
459
  () => !!o.value._page_key && !!o.value._record_key
460
- ), T = f(() => !!o.value._column_key), j = f(
460
+ ), T = v(() => !!o.value._column_key), j = v(
461
461
  () => o.value.columns.filter(({ active: e, hidden: t }) => e && !t).map((e) => {
462
462
  var t;
463
463
  return {
464
464
  ...e,
465
465
  isSorting: !!((t = e.sort) != null && t.active),
466
- toggleSort: (a = {}) => k.applySort(e.sort, null, a)
466
+ toggleSort: (a = {}) => _.applySort(e.sort, null, a)
467
467
  };
468
468
  })
469
- ), R = f(
469
+ ), R = v(
470
470
  () => o.value.columns.filter(({ hidden: e }) => !e).map((e) => ({
471
471
  ...e,
472
472
  toggle: (t = {}) => ee(e.name, t)
473
473
  }))
474
- ), q = f(
474
+ ), q = v(
475
475
  () => o.value.records.map((e) => ({
476
476
  ...e,
477
477
  /** The operations available for the record */
@@ -503,19 +503,19 @@ function me(r, p, m = {}) {
503
503
  /** Get the extra data of the record for the column */
504
504
  extra: (t) => A(e, t)
505
505
  }))
506
- ), H = f(() => !!o.value.operations.inline), C = f(
506
+ ), H = v(() => !!o.value.operations.inline), C = v(
507
507
  () => o.value.operations.bulk.map((e) => ({
508
508
  ...e,
509
509
  execute: (t = {}) => N(e, t)
510
510
  }))
511
- ), W = f(
511
+ ), W = v(
512
512
  () => o.value.operations.page.map((e) => ({
513
513
  ...e,
514
514
  execute: (t = {}) => I(e, t)
515
515
  }))
516
- ), z = f(
516
+ ), z = v(
517
517
  () => o.value.pages.find(({ active: e }) => e)
518
- ), Z = f(() => o.value.pages), S = f(() => ({
518
+ ), Z = v(() => o.value.pages), S = v(() => ({
519
519
  ...o.value.paginate,
520
520
  next: (e = {}) => {
521
521
  "nextLink" in S.value && S.value.nextLink && V(S.value.nextLink, e);
@@ -535,7 +535,7 @@ function me(r, p, m = {}) {
535
535
  navigate: (t = {}) => e.url && V(e.url, t)
536
536
  }))
537
537
  } : {}
538
- })), B = f(
538
+ })), B = v(
539
539
  () => o.value.records.length > 0 && o.value.records.every(
540
540
  (e) => u.selected(y(e))
541
541
  )
@@ -569,15 +569,15 @@ function me(r, p, m = {}) {
569
569
  };
570
570
  }
571
571
  function V(e, t = {}) {
572
- _.value = !0;
572
+ k.value = !0;
573
573
  const { onFinish: a, ...i } = t;
574
574
  x.visit(e, {
575
575
  preserveScroll: !0,
576
576
  preserveState: !0,
577
- ...v,
577
+ ...f,
578
578
  ...i,
579
579
  onFinish: (s) => {
580
- _.value = !1, g == null || g(s), a == null || a(s);
580
+ k.value = !1, g == null || g(s), a == null || a(s);
581
581
  },
582
582
  method: "get"
583
583
  });
@@ -585,33 +585,32 @@ function me(r, p, m = {}) {
585
585
  function O(e, t, a = {}) {
586
586
  var s;
587
587
  ne(e, D(t), {
588
- ...m,
588
+ ...p,
589
589
  ...a
590
590
  }) || (s = d == null ? void 0 : d[e.name]) == null || s.call(d, t);
591
591
  }
592
592
  function N(e, t = {}) {
593
593
  return ne(e, G(), {
594
- ...m,
594
+ ...p,
595
595
  ...t,
596
596
  onSuccess: (a) => {
597
597
  var i, s;
598
- (i = t.onSuccess) == null || i.call(t, a), (s = m.onSuccess) == null || s.call(m, a), console.log("onSuccess"), e.keep || u.deselectAll();
598
+ (i = t.onSuccess) == null || i.call(t, a), (s = p.onSuccess) == null || s.call(p, a), console.log("onSuccess"), e.keep || u.deselectAll();
599
599
  }
600
600
  });
601
601
  }
602
602
  function I(e, t = {}, a = {}) {
603
- return ne(e, t, { ...m, ...a });
603
+ return ne(e, t, { ...p, ...a });
604
604
  }
605
605
  function Q(e, t = {}) {
606
606
  if (!L.value)
607
607
  return console.warn("The table does not support pagination changes.");
608
- _.value = !0;
609
608
  const { onFinish: a, ...i } = t;
610
- x.reload({
611
- ...v,
609
+ k.value = !0, x.reload({
610
+ ...f,
612
611
  ...i,
613
612
  onFinish: (s) => {
614
- _.value = !1, g == null || g(s), a == null || a(s);
613
+ k.value = !1, g == null || g(s), a == null || a(s);
615
614
  },
616
615
  data: {
617
616
  [o.value._record_key]: e.value,
@@ -624,18 +623,18 @@ function me(r, p, m = {}) {
624
623
  return console.warn("The table does not support column toggling.");
625
624
  const a = J(e);
626
625
  if (!a) return console.log(`Column [${e}] does not exist.`);
627
- const i = k.toggleValue(
626
+ const i = _.toggleValue(
628
627
  a,
629
628
  j.value.map(({ name: X }) => X)
630
629
  ), { onFinish: s, ...w } = t;
631
- x.reload({
632
- ...v,
630
+ k.value = !0, x.reload({
631
+ ...f,
633
632
  ...w,
634
633
  onFinish: (X) => {
635
- _.value = !1, g == null || g(X), s == null || s(X);
634
+ k.value = !1, g == null || g(X), s == null || s(X);
636
635
  },
637
636
  data: {
638
- [o.value._column_key]: k.delimitArray(i)
637
+ [o.value._column_key]: _.delimitArray(i)
639
638
  }
640
639
  });
641
640
  }
@@ -663,7 +662,7 @@ function me(r, p, m = {}) {
663
662
  }
664
663
  return oe({
665
664
  /** The identifier of the table */
666
- id: h,
665
+ id: m,
667
666
  /** Table-specific metadata */
668
667
  meta: b,
669
668
  /** The views for the table */
@@ -745,13 +744,13 @@ function me(r, p, m = {}) {
745
744
  /** Bind select all records to the checkbox */
746
745
  bindAll: u.bindAll,
747
746
  /** The processing status */
748
- processing: _,
747
+ processing: k,
749
748
  /** The refine instance */
750
- ...k
749
+ ..._
751
750
  });
752
751
  }
753
- function pe(r, p) {
754
- return r ? typeof r == "object" ? r.type === p : r === p : !1;
752
+ function pe(r, h) {
753
+ return r ? typeof r == "object" ? r.type === h : r === h : !1;
755
754
  }
756
755
  export {
757
756
  pe as is,
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(F,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue"),require("@inertiajs/vue3"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3","axios"],c):(F=typeof globalThis<"u"?globalThis:F||self,c(F["@honed/table"]={},F.Vue,F.Inertia,F.axios))})(this,function(F,c,x,le){"use strict";function ee(r,p={},v={}){if(!r.href||!r.method)return!1;if(r.type==="inertia")r.method==="delete"?x.router.delete(r.href,v):x.router[r.method](r.href,p,v);else{const m=f=>{var o;return(o=v.onError)==null?void 0:o.call(v,f)};r.method==="get"?window.location.href=r.href:r.method==="delete"?le.delete(r.href).catch(m):le[r.method](r.href,p).catch(m)}return!0}function re(){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 m(...d){d.forEach(b=>r.value.except.delete(b)),d.forEach(b=>r.value.only.add(b))}function f(...d){d.forEach(b=>r.value.except.add(b)),d.forEach(b=>r.value.only.delete(b))}function o(d,b){if(h(d)||b===!1)return f(d);if(!h(d)||b===!0)return m(d)}function h(d){return r.value.all?!r.value.except.has(d):r.value.only.has(d)}const u=c.computed(()=>r.value.all&&r.value.except.size===0),S=c.computed(()=>r.value.only.size>0||u.value);function k(d){return{"onUpdate:modelValue":b=>{b?m(d):f(d)},modelValue:h(d),value:d}}function g(){return{"onUpdate:modelValue":d=>{d?p():v()},modelValue:u.value}}return{allSelected:u,selection:r,hasSelected:S,selectAll:p,deselectAll:v,select:m,deselect:f,toggle:o,selected:h,bind:k,bindAll:g}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const ae=()=>{};function oe(r,p){function v(...m){return new Promise((f,o)=>{Promise.resolve(r(()=>p.apply(this,m),{fn:p,thisArg:this,args:m})).then(f).catch(o)})}return v}function ue(r,p={}){let v,m,f=ae;const o=u=>{clearTimeout(u),f(),f=ae};let h;return u=>{const S=c.toValue(r),k=c.toValue(p.maxWait);return v&&o(v),S<=0||k!==void 0&&k<=0?(m&&(o(m),m=null),Promise.resolve(u())):new Promise((g,d)=>{f=p.rejectOnCancel?d:g,h=u,k&&!m&&(m=setTimeout(()=>{v&&o(v),m=null,g(h())},k)),v=setTimeout(()=>{m&&o(m),m=null,g(u())},S)})}}function H(r,p=200,v={}){return oe(ue(p,v),r)}function ie(r,p,v={},m={}){if(!(r!=null&&r[p]))throw new Error("The refine must be provided with valid props and key.");const{onFinish:f,...o}=v,h=c.ref(!1),u=c.computed(()=>r[p]),S=c.computed(()=>u.value.term),k=c.computed(()=>!!u.value._sort_key),g=c.computed(()=>!!u.value._search_key),d=c.computed(()=>!!u.value._match_key),b=c.computed(()=>{var t;return(t=u.value.filters)==null?void 0:t.map(l=>({...l,apply:(e,n={})=>y(l,e,n),clear:(e={})=>B(l,e),bind:()=>I(l.name)}))}),U=c.computed(()=>{var t;return(t=u.value.sorts)==null?void 0:t.map(l=>({...l,apply:(e={})=>V(l,l.direction,e),clear:(e={})=>D(e),bind:()=>Y(l)}))}),C=c.computed(()=>{var t;return(t=u.value.searches)==null?void 0:t.map(l=>({...l,apply:(e={})=>A(l,e),clear:(e={})=>A(l,e),bind:()=>K(l)}))}),P=c.computed(()=>b.value.filter(({active:t})=>t)),E=c.computed(()=>U.value.find(({active:t})=>t)),j=c.computed(()=>C.value.filter(({active:t})=>t));function L(t){return Array.isArray(t)?t.join(u.value._delimiter):t}function M(t){return typeof t!="string"?t:t.trim().replace(/\s+/g,"+")}function R(t){if(!["",null,void 0,[]].includes(t))return t}function J(t){return[L,M,R].reduce((l,e)=>e(l),t)}function N(t,l){return l=Array.isArray(l)?l:[l],l.includes(t)?l.filter(e=>e!==t):[...l,t]}function q(t){return typeof t!="string"?t:b.value.find(({name:l})=>l===t)}function O(t,l=null){return typeof t!="string"?t:U.value.find(({name:e,direction:n})=>e===t&&n===l)}function W(t){return typeof t!="string"?t:C.value.find(({name:l})=>l===t)}function te(t){return t?typeof t=="string"?P.value.some(l=>l.name===t):t.active:!!P.value.length}function _(t){var l;return t?typeof t=="string"?((l=E.value)==null?void 0:l.name)===t:t.active:!!E.value}function z(t){var l;return t?typeof t=="string"?(l=j.value)==null?void 0:l.some(e=>e.name===t):t.active:!!S.value}function Q(t,l={}){const e=Object.fromEntries(Object.entries(t).map(([i,s])=>[i,J(s)])),{onFinish:n,...a}=l;h.value=!0,x.router.reload({...o,...a,data:e,onFinish:i=>{h.value=!1,n==null||n(i),f==null||f(i)}})}function y(t,l,e={}){const n=q(t);if(!n)return console.warn(`Filter [${t}] does not exist.`);const{parameters:a,onFinish:i,...s}=e;h.value=!0,x.router.reload({...o,...s,onFinish:w=>{h.value=!1,i==null||i(w),f==null||f(w)},data:{[n.name]:J(l),...a,...m}})}function V(t,l=null,e={}){if(!k.value)return console.warn("Refine cannot perform sorting.");const n=O(t,l);if(!n)return console.warn(`Sort [${t}] does not exist.`);const{parameters:a,onFinish:i,...s}=e;x.router.reload({...o,...s,onFinish:w=>{h.value=!1,i==null||i(w),f==null||f(w)},data:{[u.value._sort_key]:R(n.next),...a}})}function $(t,l={}){if(!g.value)return console.warn("Refine cannot perform searching.");t=[M,R].reduce((i,s)=>s(i),t);const{parameters:e,onFinish:n,...a}=l;x.router.reload({...o,...a,onFinish:i=>{h.value=!1,n==null||n(i),f==null||f(i)},data:{[u.value._search_key]:t,...e,...m}})}function A(t,l={}){if(!d.value||!g.value)return console.warn("Refine cannot perform matching.");const e=W(t);if(!e)return console.warn(`Match [${t}] does not exist.`);const n=N(e.name,j.value.map(({name:w})=>w)),{parameters:a,onFinish:i,...s}=l;x.router.reload({...o,...s,onFinish:w=>{h.value=!1,i==null||i(w),f==null||f(w)},data:{[u.value._match_key]:L(n),...a,...m}})}function B(t,l={}){if(t)return y(t,null,l);const{parameters:e,onFinish:n,...a}=l;x.router.reload({...o,...a,onFinish:i=>{h.value=!1,n==null||n(i),f==null||f(i)},data:{...Object.fromEntries(P.value.map(({name:i})=>[i,null])),...e}})}function D(t={}){if(!k.value)return console.warn("Refine cannot perform sorting.");const{parameters:l,onFinish:e,...n}=t;x.router.reload({...o,...n,onFinish:a=>{h.value=!1,e==null||e(a),f==null||f(a)},data:{[u.value._sort_key]:null,...l}})}function T(t={}){$(null,t)}function G(t={}){if(!d.value)return console.warn("Refine cannot perform matching.");const{parameters:l,onFinish:e,...n}=t;x.router.reload({...o,...n,onFinish:a=>{h.value=!1,e==null||e(a),f==null||f(a)},data:{[u.value._match_key]:null,...l}})}function X(t={}){var l;const{parameters:e,onFinish:n,...a}=t;x.router.reload({...o,...a,onFinish:i=>{h.value=!1,n==null||n(i),f==null||f(i)},data:{[u.value._search_key??""]:void 0,[u.value._sort_key??""]:void 0,[u.value._match_key??""]:void 0,...Object.fromEntries(((l=u.value.filters)==null?void 0:l.map(i=>[i.name,void 0]))??[]),...e}})}function I(t,l={}){const e=q(t);if(!e)return console.warn(`Filter [${t}] does not exist.`);const{debounce:n=150,transform:a=s=>s,...i}=l;return{"onUpdate:modelValue":H(s=>{y(e,a(s),i)},n),modelValue:e.value}}function Y(t,l={}){if(!k.value)return console.warn("Refine cannot perform sorting.");const e=O(t);if(!e)return console.warn(`Sort [${t}] does not exist.`);const{debounce:n=0,transform:a,...i}=l;return{onClick:H(()=>{var s;V(e,(s=E.value)==null?void 0:s.direction,i)},n)}}function ne(t={}){if(!g.value)return console.warn("Refine cannot perform searching.");const{debounce:l=700,transform:e,...n}=t;return{"onUpdate:modelValue":H(a=>{$(a,n)},l),modelValue:S.value??""}}function K(t,l={}){if(!d.value)return console.warn("Refine cannot perform matching.");const e=W(t);if(!e)return console.warn(`Match [${t}] does not exist.`);const{debounce:n=0,transform:a,...i}=l;return{"onUpdate:modelValue":H(s=>{A(s,i)},n),modelValue:z(e),value:e.name}}return{processing:h,filters:b,sorts:U,searches:C,currentFilters:P,currentSort:E,currentSearches:j,searchTerm:S,isSortable:k,isSearchable:g,isMatchable:d,isFiltering:te,isSorting:_,isSearching:z,getFilter:q,getSort:O,getSearch:W,apply:Q,applyFilter:y,applySort:V,applySearch:$,applyMatch:A,clearFilter:B,clearSort:D,clearSearch:T,clearMatch:G,reset:X,bindFilter:I,bindSort:Y,bindSearch:ne,bindMatch:K,stringValue:M,omitValue:R,toggleValue:N,delimitArray:L}}function ce(r,p,v={}){if(!(r!=null&&r[p]))throw new Error("The table must be provided with valid props and key.");const{recordOperations:m={},...f}={only:[...v.only??[],p.toString()],...v},o=c.computed(()=>r[p]),h=c.computed(()=>o.value._id),u=re(),{processing:S,...k}=ie(r,p,f,{[o.value._page_key]:void 0}),{onFinish:g,...d}=f,b=c.computed(()=>o.value.meta),U=c.computed(()=>o.value.views??[]),C=c.computed(()=>o.value.state??null),P=c.computed(()=>o.value.placeholder??null),E=c.computed(()=>!!o.value.state),j=c.computed(()=>!!o.value._page_key&&!!o.value._record_key),L=c.computed(()=>!!o.value._column_key),M=c.computed(()=>o.value.columns.filter(({active:e,hidden:n})=>e&&!n).map(e=>{var n;return{...e,isSorting:!!((n=e.sort)!=null&&n.active),toggleSort:(a={})=>k.applySort(e.sort,null,a)}})),R=c.computed(()=>o.value.columns.filter(({hidden:e})=>!e).map(e=>({...e,toggle:(n={})=>ne(e.name,n)}))),J=c.computed(()=>o.value.records.map(e=>({...e,operations:e.operations.map(n=>({...n,execute:(a={})=>G(n,e,a)})),selected:u.selected(y(e)),default:(n={})=>{const a=e.operations.find(({default:i})=>i);a&&G(a,e,n)},select:()=>u.select(y(e)),deselect:()=>u.deselect(y(e)),toggle:()=>u.toggle(y(e)),bind:()=>u.bind(y(e)),entry:n=>V(e,n),value:n=>$(e,n),extra:n=>A(e,n)}))),N=c.computed(()=>!!o.value.operations.inline),q=c.computed(()=>o.value.operations.bulk.map(e=>({...e,execute:(n={})=>X(e,n)}))),O=c.computed(()=>o.value.operations.page.map(e=>({...e,execute:(n={})=>I(e,n)}))),W=c.computed(()=>o.value.pages.find(({active:e})=>e)),te=c.computed(()=>o.value.pages),_=c.computed(()=>({...o.value.paginate,next:(e={})=>{"nextLink"in _.value&&_.value.nextLink&&T(_.value.nextLink,e)},previous:(e={})=>{"prevLink"in _.value&&_.value.prevLink&&T(_.value.prevLink,e)},first:(e={})=>{"firstLink"in _.value&&_.value.firstLink&&T(_.value.firstLink,e)},last:(e={})=>{"lastLink"in _.value&&_.value.lastLink&&T(_.value.lastLink,e)},..."links"in o.value.paginate&&o.value.paginate.links?{links:o.value.paginate.links.map(e=>({...e,navigate:(n={})=>e.url&&T(e.url,n)}))}:{}})),z=c.computed(()=>o.value.records.length>0&&o.value.records.every(e=>u.selected(y(e))));function Q(e){return typeof e=="string"?e:e.name}function y(e){return e._key}function V(e,n){const a=Q(n);return e[a]}function $(e,n){var a;return((a=V(e,n))==null?void 0:a.v)??null}function A(e,n){var a;return(a=V(e,n))==null?void 0:a.e}function B(e){return{id:y(e)}}function D(){return{all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)}}function T(e,n={}){S.value=!0;const{onFinish:a,...i}=n;x.router.visit(e,{preserveScroll:!0,preserveState:!0,...d,...i,onFinish:s=>{S.value=!1,g==null||g(s),a==null||a(s)},method:"get"})}function G(e,n,a={}){var s;ee(e,B(n),{...v,...a})||(s=m==null?void 0:m[e.name])==null||s.call(m,n)}function X(e,n={}){return ee(e,D(),{...v,...n,onSuccess:a=>{var i,s;(i=n.onSuccess)==null||i.call(n,a),(s=v.onSuccess)==null||s.call(v,a),console.log("onSuccess"),e.keep||u.deselectAll()}})}function I(e,n={},a={}){return ee(e,n,{...v,...a})}function Y(e,n={}){if(!j.value)return console.warn("The table does not support pagination changes.");S.value=!0;const{onFinish:a,...i}=n;x.router.reload({...d,...i,onFinish:s=>{S.value=!1,g==null||g(s),a==null||a(s)},data:{[o.value._record_key]:e.value,[o.value._page_key]:void 0}})}function ne(e,n={}){if(!L.value)return console.warn("The table does not support column toggling.");const a=Q(e);if(!a)return console.log(`Column [${e}] does not exist.`);const i=k.toggleValue(a,M.value.map(({name:Z})=>Z)),{onFinish:s,...w}=n;x.router.reload({...d,...w,onFinish:Z=>{S.value=!1,g==null||g(Z),s==null||s(Z)},data:{[o.value._column_key]:k.delimitArray(i)}})}function K(){u.select(...o.value.records.map(e=>y(e)))}function t(){u.deselect(...o.value.records.map(e=>y(e)))}function l(){return{"onUpdate:modelValue":e=>{e?K():t()},modelValue:z.value}}return c.reactive({id:h,meta:b,views:U,emptyState:C,placeholder:P,isEmpty:E,isPageable:j,isToggleable:L,getEntry:V,getValue:$,getExtra:A,getRecordKey:y,headings:M,columns:R,records:J,inline:N,bulk:q,page:O,pages:te,currentPage:W,paginator:_,executeInline:G,executeBulk:X,executePage:I,getBulkData:D,getRecordData:B,applyPage:Y,selection:u.selection,select:e=>u.select(y(e)),deselect:e=>u.deselect(y(e)),selectPage:K,deselectPage:t,toggle:e=>u.toggle(y(e)),selected:e=>u.selected(y(e)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:z,hasSelected:u.hasSelected,bindCheckbox:e=>u.bind(y(e)),bindPage:l,bindAll:u.bindAll,processing:S,...k})}function se(r,p){return r?typeof r=="object"?r.type===p:r===p:!1}F.is=se,F.useTable=ce,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
1
+ (function(F,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue"),require("@inertiajs/vue3"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3","axios"],c):(F=typeof globalThis<"u"?globalThis:F||self,c(F["@honed/table"]={},F.Vue,F.Inertia,F.axios))})(this,function(F,c,x,le){"use strict";function ee(r,h={},p={}){if(!r.href||!r.method)return!1;if(r.type==="inertia")r.method==="delete"?x.router.delete(r.href,p):x.router[r.method](r.href,h,p);else{const m=d=>{var o;return(o=p.onError)==null?void 0:o.call(p,d)};r.method==="get"?window.location.href=r.href:r.method==="delete"?le.delete(r.href).catch(m):le[r.method](r.href,h).catch(m)}return!0}function re(){const r=c.ref({all:!1,only:new Set,except:new Set});function h(){r.value.all=!0,r.value.only.clear(),r.value.except.clear()}function p(){r.value.all=!1,r.value.only.clear(),r.value.except.clear()}function m(...f){f.forEach(b=>r.value.except.delete(b)),f.forEach(b=>r.value.only.add(b))}function d(...f){f.forEach(b=>r.value.except.add(b)),f.forEach(b=>r.value.only.delete(b))}function o(f,b){if(v(f)||b===!1)return d(f);if(!v(f)||b===!0)return m(f)}function v(f){return r.value.all?!r.value.except.has(f):r.value.only.has(f)}const u=c.computed(()=>r.value.all&&r.value.except.size===0),k=c.computed(()=>r.value.only.size>0||u.value);function S(f){return{"onUpdate:modelValue":b=>{b?m(f):d(f)},modelValue:v(f),value:f}}function g(){return{"onUpdate:modelValue":f=>{f?h():p()},modelValue:u.value}}return{allSelected:u,selection:r,hasSelected:k,selectAll:h,deselectAll:p,select:m,deselect:d,toggle:o,selected:v,bind:S,bindAll:g}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const ae=()=>{};function oe(r,h){function p(...m){return new Promise((d,o)=>{Promise.resolve(r(()=>h.apply(this,m),{fn:h,thisArg:this,args:m})).then(d).catch(o)})}return p}function ue(r,h={}){let p,m,d=ae;const o=u=>{clearTimeout(u),d(),d=ae};let v;return u=>{const k=c.toValue(r),S=c.toValue(h.maxWait);return p&&o(p),k<=0||S!==void 0&&S<=0?(m&&(o(m),m=null),Promise.resolve(u())):new Promise((g,f)=>{d=h.rejectOnCancel?f:g,v=u,S&&!m&&(m=setTimeout(()=>{p&&o(p),m=null,g(v())},S)),p=setTimeout(()=>{m&&o(m),m=null,g(u())},k)})}}function H(r,h=200,p={}){return oe(ue(h,p),r)}function ie(r,h,p={},m={}){if(!(r!=null&&r[h]))throw new Error("The refine must be provided with valid props and key.");const{onFinish:d,...o}=p,v=c.ref(!1),u=c.computed(()=>r[h]),k=c.computed(()=>u.value.term),S=c.computed(()=>!!u.value._sort_key),g=c.computed(()=>!!u.value._search_key),f=c.computed(()=>!!u.value._match_key),b=c.computed(()=>{var t;return(t=u.value.filters)==null?void 0:t.map(l=>({...l,apply:(e,n={})=>y(l,e,n),clear:(e={})=>B(l,e),bind:(e={})=>I(l.name,e)}))}),U=c.computed(()=>{var t;return(t=u.value.sorts)==null?void 0:t.map(l=>({...l,apply:(e={})=>V(l,l.direction,e),clear:(e={})=>D(e),bind:(e={})=>Y(l,e)}))}),C=c.computed(()=>{var t;return(t=u.value.searches)==null?void 0:t.map(l=>({...l,apply:(e={})=>A(l,e),clear:(e={})=>A(l,e),bind:(e={})=>K(l,e)}))}),P=c.computed(()=>b.value.filter(({active:t})=>t)),E=c.computed(()=>U.value.find(({active:t})=>t)),j=c.computed(()=>C.value.filter(({active:t})=>t));function L(t){return Array.isArray(t)?t.join(u.value._delimiter):t}function M(t){return typeof t!="string"?t:t.trim().replace(/\s+/g,"+")}function R(t){if(!["",null,void 0,[]].includes(t))return t}function J(t){return[L,M,R].reduce((l,e)=>e(l),t)}function N(t,l){return l=Array.isArray(l)?l:[l],l.includes(t)?l.filter(e=>e!==t):[...l,t]}function q(t){return typeof t!="string"?t:b.value.find(({name:l})=>l===t)}function O(t,l=null){return typeof t!="string"?t:U.value.find(({name:e,direction:n})=>e===t&&n===l)}function W(t){return typeof t!="string"?t:C.value.find(({name:l})=>l===t)}function te(t){return t?typeof t=="string"?P.value.some(l=>l.name===t):t.active:!!P.value.length}function _(t){var l;return t?typeof t=="string"?((l=E.value)==null?void 0:l.name)===t:t.active:!!E.value}function z(t){var l;return t?typeof t=="string"?(l=j.value)==null?void 0:l.some(e=>e.name===t):t.active:!!k.value}function Q(t,l={}){const e=Object.fromEntries(Object.entries(t).map(([i,s])=>[i,J(s)])),{onFinish:n,...a}=l;v.value=!0,x.router.reload({...o,...a,data:e,onFinish:i=>{v.value=!1,n==null||n(i),d==null||d(i)}})}function y(t,l,e={}){const n=q(t);if(!n)return console.warn(`Filter [${t}] does not exist.`);const{parameters:a,onFinish:i,...s}=e;v.value=!0,x.router.reload({...o,...s,onFinish:w=>{v.value=!1,i==null||i(w),d==null||d(w)},data:{[n.name]:J(l),...a,...m}})}function V(t,l=null,e={}){if(!S.value)return console.warn("Refine cannot perform sorting.");const n=O(t,l);if(!n)return console.warn(`Sort [${t}] does not exist.`);const{parameters:a,onFinish:i,...s}=e;v.value=!0,x.router.reload({...o,...s,onFinish:w=>{v.value=!1,i==null||i(w),d==null||d(w)},data:{[u.value._sort_key]:R(n.next),...a}})}function $(t,l={}){if(!g.value)return console.warn("Refine cannot perform searching.");t=[M,R].reduce((i,s)=>s(i),t);const{parameters:e,onFinish:n,...a}=l;v.value=!0,x.router.reload({...o,...a,onFinish:i=>{v.value=!1,n==null||n(i),d==null||d(i)},data:{[u.value._search_key]:t,...e,...m}})}function A(t,l={}){if(!f.value||!g.value)return console.warn("Refine cannot perform matching.");const e=W(t);if(!e)return console.warn(`Match [${t}] does not exist.`);const n=N(e.name,j.value.map(({name:w})=>w)),{parameters:a,onFinish:i,...s}=l;v.value=!0,x.router.reload({...o,...s,onFinish:w=>{v.value=!1,i==null||i(w),d==null||d(w)},data:{[u.value._match_key]:L(n),...a,...m}})}function B(t,l={}){if(t)return y(t,null,l);const{parameters:e,onFinish:n,...a}=l;v.value=!0,x.router.reload({...o,...a,onFinish:i=>{v.value=!1,n==null||n(i),d==null||d(i)},data:{...Object.fromEntries(P.value.map(({name:i})=>[i,null])),...e}})}function D(t={}){if(!S.value)return console.warn("Refine cannot perform sorting.");const{parameters:l,onFinish:e,...n}=t;v.value=!0,x.router.reload({...o,...n,onFinish:a=>{v.value=!1,e==null||e(a),d==null||d(a)},data:{[u.value._sort_key]:null,...l}})}function T(t={}){$(null,t)}function G(t={}){if(!f.value)return console.warn("Refine cannot perform matching.");const{parameters:l,onFinish:e,...n}=t;v.value=!0,x.router.reload({...o,...n,onFinish:a=>{v.value=!1,e==null||e(a),d==null||d(a)},data:{[u.value._match_key]:null,...l}})}function X(t={}){var l;const{parameters:e,onFinish:n,...a}=t;v.value=!0,x.router.reload({...o,...a,onFinish:i=>{v.value=!1,n==null||n(i),d==null||d(i)},data:{[u.value._search_key??""]:void 0,[u.value._sort_key??""]:void 0,[u.value._match_key??""]:void 0,...Object.fromEntries(((l=u.value.filters)==null?void 0:l.map(i=>[i.name,void 0]))??[]),...e}})}function I(t,l={}){const e=q(t);if(!e)return console.warn(`Filter [${t}] does not exist.`);const{debounce:n=150,transform:a=s=>s,...i}=l;return{"onUpdate:modelValue":H(s=>{y(e,a(s),i)},n),modelValue:e.value}}function Y(t,l={}){if(!S.value)return console.warn("Refine cannot perform sorting.");const e=O(t);if(!e)return console.warn(`Sort [${t}] does not exist.`);const{debounce:n=0,transform:a,...i}=l;return{onClick:H(()=>{var s;V(e,(s=E.value)==null?void 0:s.direction,i)},n)}}function ne(t={}){if(!g.value)return console.warn("Refine cannot perform searching.");const{debounce:l=750,transform:e,...n}=t;return{"onUpdate:modelValue":H(a=>{$(a,n)},l),modelValue:k.value??""}}function K(t,l={}){if(!f.value)return console.warn("Refine cannot perform matching.");const e=W(t);if(!e)return console.warn(`Match [${t}] does not exist.`);const{debounce:n=0,transform:a,...i}=l;return{"onUpdate:modelValue":H(s=>{A(s,i)},n),modelValue:z(e),value:e.name}}return{processing:v,filters:b,sorts:U,searches:C,currentFilters:P,currentSort:E,currentSearches:j,searchTerm:k,isSortable:S,isSearchable:g,isMatchable:f,isFiltering:te,isSorting:_,isSearching:z,getFilter:q,getSort:O,getSearch:W,apply:Q,applyFilter:y,applySort:V,applySearch:$,applyMatch:A,clearFilter:B,clearSort:D,clearSearch:T,clearMatch:G,reset:X,bindFilter:I,bindSort:Y,bindSearch:ne,bindMatch:K,stringValue:M,omitValue:R,toggleValue:N,delimitArray:L}}function ce(r,h,p={}){if(!(r!=null&&r[h]))throw new Error("The table must be provided with valid props and key.");const{recordOperations:m={},...d}={only:[...p.only??[],h.toString()],...p},o=c.computed(()=>r[h]),v=c.computed(()=>o.value._id),u=re(),{processing:k,...S}=ie(r,h,d,{[o.value._page_key]:void 0}),{onFinish:g,...f}=d,b=c.computed(()=>o.value.meta),U=c.computed(()=>o.value.views??[]),C=c.computed(()=>o.value.state??null),P=c.computed(()=>o.value.placeholder??null),E=c.computed(()=>!!o.value.state),j=c.computed(()=>!!o.value._page_key&&!!o.value._record_key),L=c.computed(()=>!!o.value._column_key),M=c.computed(()=>o.value.columns.filter(({active:e,hidden:n})=>e&&!n).map(e=>{var n;return{...e,isSorting:!!((n=e.sort)!=null&&n.active),toggleSort:(a={})=>S.applySort(e.sort,null,a)}})),R=c.computed(()=>o.value.columns.filter(({hidden:e})=>!e).map(e=>({...e,toggle:(n={})=>ne(e.name,n)}))),J=c.computed(()=>o.value.records.map(e=>({...e,operations:e.operations.map(n=>({...n,execute:(a={})=>G(n,e,a)})),selected:u.selected(y(e)),default:(n={})=>{const a=e.operations.find(({default:i})=>i);a&&G(a,e,n)},select:()=>u.select(y(e)),deselect:()=>u.deselect(y(e)),toggle:()=>u.toggle(y(e)),bind:()=>u.bind(y(e)),entry:n=>V(e,n),value:n=>$(e,n),extra:n=>A(e,n)}))),N=c.computed(()=>!!o.value.operations.inline),q=c.computed(()=>o.value.operations.bulk.map(e=>({...e,execute:(n={})=>X(e,n)}))),O=c.computed(()=>o.value.operations.page.map(e=>({...e,execute:(n={})=>I(e,n)}))),W=c.computed(()=>o.value.pages.find(({active:e})=>e)),te=c.computed(()=>o.value.pages),_=c.computed(()=>({...o.value.paginate,next:(e={})=>{"nextLink"in _.value&&_.value.nextLink&&T(_.value.nextLink,e)},previous:(e={})=>{"prevLink"in _.value&&_.value.prevLink&&T(_.value.prevLink,e)},first:(e={})=>{"firstLink"in _.value&&_.value.firstLink&&T(_.value.firstLink,e)},last:(e={})=>{"lastLink"in _.value&&_.value.lastLink&&T(_.value.lastLink,e)},..."links"in o.value.paginate&&o.value.paginate.links?{links:o.value.paginate.links.map(e=>({...e,navigate:(n={})=>e.url&&T(e.url,n)}))}:{}})),z=c.computed(()=>o.value.records.length>0&&o.value.records.every(e=>u.selected(y(e))));function Q(e){return typeof e=="string"?e:e.name}function y(e){return e._key}function V(e,n){const a=Q(n);return e[a]}function $(e,n){var a;return((a=V(e,n))==null?void 0:a.v)??null}function A(e,n){var a;return(a=V(e,n))==null?void 0:a.e}function B(e){return{id:y(e)}}function D(){return{all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)}}function T(e,n={}){k.value=!0;const{onFinish:a,...i}=n;x.router.visit(e,{preserveScroll:!0,preserveState:!0,...f,...i,onFinish:s=>{k.value=!1,g==null||g(s),a==null||a(s)},method:"get"})}function G(e,n,a={}){var s;ee(e,B(n),{...p,...a})||(s=m==null?void 0:m[e.name])==null||s.call(m,n)}function X(e,n={}){return ee(e,D(),{...p,...n,onSuccess:a=>{var i,s;(i=n.onSuccess)==null||i.call(n,a),(s=p.onSuccess)==null||s.call(p,a),console.log("onSuccess"),e.keep||u.deselectAll()}})}function I(e,n={},a={}){return ee(e,n,{...p,...a})}function Y(e,n={}){if(!j.value)return console.warn("The table does not support pagination changes.");const{onFinish:a,...i}=n;k.value=!0,x.router.reload({...f,...i,onFinish:s=>{k.value=!1,g==null||g(s),a==null||a(s)},data:{[o.value._record_key]:e.value,[o.value._page_key]:void 0}})}function ne(e,n={}){if(!L.value)return console.warn("The table does not support column toggling.");const a=Q(e);if(!a)return console.log(`Column [${e}] does not exist.`);const i=S.toggleValue(a,M.value.map(({name:Z})=>Z)),{onFinish:s,...w}=n;k.value=!0,x.router.reload({...f,...w,onFinish:Z=>{k.value=!1,g==null||g(Z),s==null||s(Z)},data:{[o.value._column_key]:S.delimitArray(i)}})}function K(){u.select(...o.value.records.map(e=>y(e)))}function t(){u.deselect(...o.value.records.map(e=>y(e)))}function l(){return{"onUpdate:modelValue":e=>{e?K():t()},modelValue:z.value}}return c.reactive({id:v,meta:b,views:U,emptyState:C,placeholder:P,isEmpty:E,isPageable:j,isToggleable:L,getEntry:V,getValue:$,getExtra:A,getRecordKey:y,headings:M,columns:R,records:J,inline:N,bulk:q,page:O,pages:te,currentPage:W,paginator:_,executeInline:G,executeBulk:X,executePage:I,getBulkData:D,getRecordData:B,applyPage:Y,selection:u.selection,select:e=>u.select(y(e)),deselect:e=>u.deselect(y(e)),selectPage:K,deselectPage:t,toggle:e=>u.toggle(y(e)),selected:e=>u.selected(y(e)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:z,hasSelected:u.hasSelected,bindCheckbox:e=>u.bind(y(e)),bindPage:l,bindAll:u.bindAll,processing:k,...S})}function se(r,h){return r?typeof r=="object"?r.type===h:r===h:!1}F.is=se,F.useTable=ce,Object.defineProperty(F,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.19.0",
4
+ "version": "0.21.0",
5
5
  "license": "MIT",
6
6
  "description": "-",
7
7
  "keywords": [
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@honed/action": "^0.14.0",
61
- "@honed/refine": "^0.14.0",
61
+ "@honed/refine": "^0.16.0",
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",