@honed/table 0.8.0 → 0.9.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,685 +1,677 @@
1
- import { ref as q, computed as p, toValue as Q, reactive as Z } from "vue";
1
+ import { ref as Y, computed as d, toValue as J, reactive as Z } from "vue";
2
2
  import { router as S } from "@inertiajs/vue3";
3
- function ee(r, v, c, l = {}) {
4
- return r.route ? (S.visit(r.route.url, {
5
- ...l,
6
- method: r.route.method
7
- }), !0) : r.action && v ? (S.post(
3
+ function _(l, v, c, a = {}) {
4
+ return l.route ? (S.visit(l.route.url, {
5
+ ...a,
6
+ method: l.route.method
7
+ }), !0) : l.action && v ? (S.post(
8
8
  v,
9
- {
10
- ...c,
11
- name: r.name,
12
- type: r.type
13
- },
14
- l
9
+ { ...c, name: l.name, type: l.type },
10
+ a
15
11
  ), !0) : !1;
16
12
  }
17
- function Y(r, v, c, l = {}, f = {}) {
18
- return ee(
19
- r,
13
+ function X(l, v, c, a = {}, m = {}) {
14
+ return _(
15
+ l,
20
16
  v,
21
- {
22
- ...l,
23
- id: c ?? void 0
24
- },
25
- {
26
- ...f
27
- }
17
+ { ...a, id: c ?? void 0 },
18
+ m
28
19
  );
29
20
  }
30
- function ne(r, v, c, l = {}) {
31
- return r.map((f) => ({
32
- ...f,
33
- execute: (o = {}, u = {}) => Y(f, v, c, o, { ...l, ...u })
21
+ function ee(l, v, c, a = {}) {
22
+ return l.map((m) => ({
23
+ ...m,
24
+ execute: (o = {}, i = {}) => X(m, v, c, o, { ...a, ...i })
34
25
  }));
35
26
  }
36
27
  function te() {
37
- const r = q({
28
+ const l = Y({
38
29
  all: !1,
39
30
  only: /* @__PURE__ */ new Set(),
40
31
  except: /* @__PURE__ */ new Set()
41
32
  });
42
33
  function v() {
43
- r.value.all = !0, r.value.only.clear(), r.value.except.clear();
34
+ l.value.all = !0, l.value.only.clear(), l.value.except.clear();
44
35
  }
45
36
  function c() {
46
- r.value.all = !1, r.value.only.clear(), r.value.except.clear();
37
+ l.value.all = !1, l.value.only.clear(), l.value.except.clear();
47
38
  }
48
- function l(...s) {
49
- s.forEach((g) => r.value.except.delete(g)), s.forEach((g) => r.value.only.add(g));
39
+ function a(...s) {
40
+ s.forEach((h) => l.value.except.delete(h)), s.forEach((h) => l.value.only.add(h));
50
41
  }
51
- function f(...s) {
52
- s.forEach((g) => r.value.except.add(g)), s.forEach((g) => r.value.only.delete(g));
42
+ function m(...s) {
43
+ s.forEach((h) => l.value.except.add(h)), s.forEach((h) => l.value.only.delete(h));
53
44
  }
54
- function o(s, g) {
55
- if (u(s) || g === !1) return f(s);
56
- if (!u(s) || g === !0) return l(s);
45
+ function o(s, h) {
46
+ if (i(s) || h === !1) return m(s);
47
+ if (!i(s) || h === !0) return a(s);
57
48
  }
58
- function u(s) {
59
- return r.value.all ? !r.value.except.has(s) : r.value.only.has(s);
49
+ function i(s) {
50
+ return l.value.all ? !l.value.except.has(s) : l.value.only.has(s);
60
51
  }
61
- const b = p(() => r.value.all && r.value.except.size === 0), V = p(() => r.value.only.size > 0 || b.value);
62
- function w(s) {
52
+ const g = d(() => l.value.all && l.value.except.size === 0), k = d(() => l.value.only.size > 0 || g.value);
53
+ function x(s) {
63
54
  return {
64
- "onUpdate:modelValue": (g) => {
65
- g ? l(s) : f(s);
55
+ "onUpdate:modelValue": (h) => {
56
+ h ? a(s) : m(s);
66
57
  },
67
- modelValue: u(s),
58
+ modelValue: i(s),
68
59
  value: s
69
60
  };
70
61
  }
71
- function x() {
62
+ function w() {
72
63
  return {
73
64
  "onUpdate:modelValue": (s) => {
74
65
  s ? v() : c();
75
66
  },
76
- modelValue: b.value
67
+ modelValue: g.value
77
68
  };
78
69
  }
79
70
  return {
80
- allSelected: b,
81
- selection: r,
82
- hasSelected: V,
71
+ allSelected: g,
72
+ selection: l,
73
+ hasSelected: k,
83
74
  selectAll: v,
84
75
  deselectAll: c,
85
- select: l,
86
- deselect: f,
76
+ select: a,
77
+ deselect: m,
87
78
  toggle: o,
88
- selected: u,
89
- bind: w,
90
- bindAll: x
79
+ selected: i,
80
+ bind: x,
81
+ bindAll: w
91
82
  };
92
83
  }
93
84
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
94
- const X = () => {
85
+ const Q = () => {
95
86
  };
96
- function le(r, v) {
97
- function c(...l) {
98
- return new Promise((f, o) => {
99
- Promise.resolve(r(() => v.apply(this, l), { fn: v, thisArg: this, args: l })).then(f).catch(o);
87
+ function ne(l, v) {
88
+ function c(...a) {
89
+ return new Promise((m, o) => {
90
+ Promise.resolve(l(() => v.apply(this, a), { fn: v, thisArg: this, args: a })).then(m).catch(o);
100
91
  });
101
92
  }
102
93
  return c;
103
94
  }
104
- function ae(r, v = {}) {
105
- let c, l, f = X;
106
- const o = (b) => {
107
- clearTimeout(b), f(), f = X;
95
+ function le(l, v = {}) {
96
+ let c, a, m = Q;
97
+ const o = (g) => {
98
+ clearTimeout(g), m(), m = Q;
108
99
  };
109
- let u;
110
- return (b) => {
111
- const V = Q(r), w = Q(v.maxWait);
112
- return c && o(c), V <= 0 || w !== void 0 && w <= 0 ? (l && (o(l), l = null), Promise.resolve(b())) : new Promise((x, s) => {
113
- f = v.rejectOnCancel ? s : x, u = b, w && !l && (l = setTimeout(() => {
114
- c && o(c), l = null, x(u());
115
- }, w)), c = setTimeout(() => {
116
- l && o(l), l = null, x(b());
117
- }, V);
100
+ let i;
101
+ return (g) => {
102
+ const k = J(l), x = J(v.maxWait);
103
+ return c && o(c), k <= 0 || x !== void 0 && x <= 0 ? (a && (o(a), a = null), Promise.resolve(g())) : new Promise((w, s) => {
104
+ m = v.rejectOnCancel ? s : w, i = g, x && !a && (a = setTimeout(() => {
105
+ c && o(c), a = null, w(i());
106
+ }, x)), c = setTimeout(() => {
107
+ a && o(a), a = null, w(g());
108
+ }, k);
118
109
  });
119
110
  };
120
111
  }
121
- function N(r, v = 200, c = {}) {
122
- return le(
123
- ae(v, c),
124
- r
112
+ function D(l, v = 200, c = {}) {
113
+ return ne(
114
+ le(v, c),
115
+ l
125
116
  );
126
117
  }
127
- function re(r, v, c = {}) {
128
- const l = p(() => r[v]), f = p(() => !!l.value.sort), o = p(() => !!l.value.search), u = p(() => !!l.value.match), b = p(
118
+ function ae(l, v, c = {}) {
119
+ if (!(l != null && l[v]))
120
+ throw new Error("The refine must be provided with valid props and key.");
121
+ const a = d(() => l[v]), m = d(() => !!a.value.sort), o = d(() => !!a.value.search), i = d(() => !!a.value.match), g = d(
129
122
  () => {
130
123
  var e;
131
- return (e = l.value.filters) == null ? void 0 : e.map((t) => ({
132
- ...t,
133
- apply: (a, m = {}) => M(t, a, m),
134
- clear: (a = {}) => K(t, a),
135
- bind: () => $(t.name)
124
+ return (e = a.value.filters) == null ? void 0 : e.map((n) => ({
125
+ ...n,
126
+ apply: (r, p = {}) => P(n, r, p),
127
+ clear: (r = {}) => B(n, r),
128
+ bind: () => q(n.name)
136
129
  }));
137
130
  }
138
- ), V = p(
131
+ ), k = d(
139
132
  () => {
140
133
  var e;
141
- return (e = l.value.sorts) == null ? void 0 : e.map((t) => ({
142
- ...t,
143
- apply: (a = {}) => z(t, t.direction, a),
144
- clear: (a = {}) => n(a),
145
- bind: () => H(t)
134
+ return (e = a.value.sorts) == null ? void 0 : e.map((n) => ({
135
+ ...n,
136
+ apply: (r = {}) => A(n, n.direction, r),
137
+ clear: (r = {}) => I(r),
138
+ bind: () => t(n)
146
139
  }));
147
140
  }
148
- ), w = p(
141
+ ), x = d(
149
142
  () => {
150
143
  var e;
151
- return (e = l.value.searches) == null ? void 0 : e.map((t) => ({
152
- ...t,
153
- apply: (a = {}) => j(t, a),
154
- clear: (a = {}) => j(t, a),
155
- bind: () => J(t)
144
+ return (e = a.value.searches) == null ? void 0 : e.map((n) => ({
145
+ ...n,
146
+ apply: (r = {}) => $(n, r),
147
+ clear: (r = {}) => $(n, r),
148
+ bind: () => f(n)
156
149
  }));
157
150
  }
151
+ ), w = d(
152
+ () => g.value.filter(({ active: e }) => e)
153
+ ), s = d(
154
+ () => k.value.find(({ active: e }) => e)
155
+ ), h = d(
156
+ () => x.value.filter(({ active: e }) => e)
158
157
  );
159
- function x(e) {
160
- return e.filter(({ active: t }) => t);
158
+ function M(e) {
159
+ return Array.isArray(e) ? e.join(a.value.delimiter) : e;
161
160
  }
162
- const s = p(
163
- () => x(l.value.filters)
164
- ), g = p(
165
- () => {
166
- var e;
167
- return (e = x(l.value.sorts)) == null ? void 0 : e[0];
168
- }
169
- ), R = p(
170
- () => x(l.value.searches)
171
- );
172
- function U(e) {
173
- return Array.isArray(e) ? e.join(l.value.delimiter) : e;
174
- }
175
- function C(e) {
161
+ function R(e) {
176
162
  return typeof e != "string" ? e : e.trim().replace(/\s+/g, "+");
177
163
  }
178
- function h(e) {
164
+ function E(e) {
179
165
  if (!["", null, void 0, []].includes(e))
180
166
  return e;
181
167
  }
182
168
  function W(e) {
183
- return [U, C, h].reduce(
184
- (t, a) => a(t),
169
+ return [M, R, E].reduce(
170
+ (n, r) => r(n),
185
171
  e
186
172
  );
187
173
  }
188
- function y(e, t) {
189
- return t = Array.isArray(t) ? t : [t], t.includes(e) ? t.filter((a) => a !== e) : [...t, e];
174
+ function z(e, n) {
175
+ return n = Array.isArray(n) ? n : [n], n.includes(e) ? n.filter((r) => r !== e) : [...n, e];
190
176
  }
191
- function L(e) {
192
- var t;
193
- return typeof e != "string" ? e : (t = l.value.filters) == null ? void 0 : t.find(({ name: a }) => a === e);
177
+ function U(e) {
178
+ return typeof e != "string" ? e : g.value.find(({ name: n }) => n === e);
194
179
  }
195
- function T(e, t = null) {
196
- var a;
197
- return typeof e != "string" ? e : (a = l.value.sorts) == null ? void 0 : a.find(
198
- ({ name: m, direction: k }) => m === e && k === t
180
+ function y(e, n = null) {
181
+ return typeof e != "string" ? e : k.value.find(
182
+ ({ name: r, direction: p }) => r === e && p === n
199
183
  );
200
184
  }
201
- function E(e) {
202
- var t;
203
- return typeof e != "string" ? e : (t = l.value.searches) == null ? void 0 : t.find(({ name: a }) => a === e);
185
+ function T(e) {
186
+ return typeof e != "string" ? e : x.value.find(({ name: n }) => n === e);
204
187
  }
205
- function F(e) {
206
- return e ? typeof e == "string" ? s.value.some((t) => t.name === e) : e.active : !!s.value.length;
188
+ function b(e) {
189
+ return e ? typeof e == "string" ? w.value.some((n) => n.name === e) : e.active : !!w.value.length;
207
190
  }
208
- function B(e) {
209
- var t;
210
- return e ? typeof e == "string" ? ((t = g.value) == null ? void 0 : t.name) === e : e.active : !!g.value;
191
+ function G(e) {
192
+ var n;
193
+ return e ? typeof e == "string" ? ((n = s.value) == null ? void 0 : n.name) === e : e.active : !!s.value;
211
194
  }
212
- function I(e) {
213
- var t;
214
- return e ? typeof e == "string" ? (t = R.value) == null ? void 0 : t.some((a) => a.name === e) : e.active : !!l.value.term;
195
+ function F(e) {
196
+ var n;
197
+ return e ? typeof e == "string" ? (n = h.value) == null ? void 0 : n.some((r) => r.name === e) : e.active : !!a.value.term;
215
198
  }
216
- function D(e, t = {}) {
217
- const a = Object.fromEntries(
218
- Object.entries(e).map(([m, k]) => [m, W(k)])
199
+ function C(e, n = {}) {
200
+ const r = Object.fromEntries(
201
+ Object.entries(e).map(([p, V]) => [p, W(V)])
219
202
  );
220
203
  S.reload({
221
204
  ...c,
222
- ...t,
223
- data: a
205
+ ...n,
206
+ data: r
224
207
  });
225
208
  }
226
- function M(e, t, a = {}) {
227
- const m = L(e);
228
- if (!m) return console.warn(`Filter [${e}] does not exist.`);
209
+ function P(e, n, r = {}) {
210
+ const p = U(e);
211
+ if (!p) return console.warn(`Filter [${e}] does not exist.`);
229
212
  S.reload({
230
213
  ...c,
231
- ...a,
214
+ ...r,
232
215
  data: {
233
- [m.name]: W(t)
216
+ [p.name]: W(n)
234
217
  }
235
218
  });
236
219
  }
237
- function z(e, t = null, a = {}) {
238
- const m = T(e, t);
239
- if (!m) return console.warn(`Sort [${e}] does not exist.`);
240
- if (!f.value)
220
+ function A(e, n = null, r = {}) {
221
+ if (!m.value)
241
222
  return console.warn("Refine cannot perform sorting.");
223
+ const p = y(e, n);
224
+ if (!p) return console.warn(`Sort [${e}] does not exist.`);
242
225
  S.reload({
243
226
  ...c,
244
- ...a,
227
+ ...r,
245
228
  data: {
246
- [l.value.sort]: h(m.next)
229
+ [a.value.sort]: E(p.next)
247
230
  }
248
231
  });
249
232
  }
250
- function O(e, t = {}) {
251
- if (e = [C, h].reduce(
252
- (a, m) => m(a),
253
- e
254
- ), !o.value)
233
+ function j(e, n = {}) {
234
+ if (!o.value)
255
235
  return console.warn("Refine cannot perform searching.");
256
- S.reload({
236
+ e = [R, E].reduce(
237
+ (r, p) => p(r),
238
+ e
239
+ ), S.reload({
257
240
  ...c,
258
- ...t,
241
+ ...n,
259
242
  data: {
260
- [l.value.search]: e
243
+ [a.value.search]: e
261
244
  }
262
245
  });
263
246
  }
264
- function j(e, t = {}) {
265
- const a = E(e);
266
- if (!a) return console.warn(`Match [${e}] does not exist.`);
267
- if (!u.value || !o.value)
247
+ function $(e, n = {}) {
248
+ if (!i.value || !o.value)
268
249
  return console.warn("Refine cannot perform matching.");
269
- const m = y(
270
- a.name,
271
- R.value.map(({ name: k }) => k)
250
+ const r = T(e);
251
+ if (!r) return console.warn(`Match [${e}] does not exist.`);
252
+ const p = z(
253
+ r.name,
254
+ h.value.map(({ name: V }) => V)
272
255
  );
273
256
  S.reload({
274
257
  ...c,
275
- ...t,
258
+ ...n,
276
259
  data: {
277
- [l.value.match]: U(m)
260
+ [a.value.match]: M(p)
278
261
  }
279
262
  });
280
263
  }
281
- function K(e, t = {}) {
282
- if (e) return M(e, null, t);
264
+ function B(e, n = {}) {
265
+ if (e) return P(e, null, n);
283
266
  S.reload({
284
267
  ...c,
285
- ...t,
268
+ ...n,
286
269
  data: Object.fromEntries(
287
- s.value.map(({ name: a }) => [a, null])
270
+ w.value.map(({ name: r }) => [r, null])
288
271
  )
289
272
  });
290
273
  }
291
- function n(e = {}) {
292
- if (!f.value)
274
+ function I(e = {}) {
275
+ if (!m.value)
293
276
  return console.warn("Refine cannot perform sorting.");
294
277
  S.reload({
295
278
  ...c,
296
279
  ...e,
297
280
  data: {
298
- [l.value.sort]: null
281
+ [a.value.sort]: null
299
282
  }
300
283
  });
301
284
  }
302
- function i(e = {}) {
303
- O(null, e);
285
+ function H(e = {}) {
286
+ j(null, e);
304
287
  }
305
- function d(e = {}) {
306
- if (!u.value)
288
+ function K(e = {}) {
289
+ if (!i.value)
307
290
  return console.warn("Refine cannot perform matching.");
308
291
  S.reload({
309
292
  ...c,
310
293
  ...e,
311
294
  data: {
312
- [l.value.match]: null
295
+ [a.value.match]: null
313
296
  }
314
297
  });
315
298
  }
316
- function A(e = {}) {
317
- var t;
299
+ function N(e = {}) {
300
+ var n;
318
301
  S.reload({
319
302
  ...c,
320
303
  ...e,
321
304
  data: {
322
- [l.value.search ?? ""]: void 0,
323
- [l.value.sort ?? ""]: void 0,
324
- [l.value.match ?? ""]: void 0,
305
+ [a.value.search ?? ""]: void 0,
306
+ [a.value.sort ?? ""]: void 0,
307
+ [a.value.match ?? ""]: void 0,
325
308
  ...Object.fromEntries(
326
- ((t = l.value.filters) == null ? void 0 : t.map((a) => [
327
- a.name,
309
+ ((n = a.value.filters) == null ? void 0 : n.map((r) => [
310
+ r.name,
328
311
  void 0
329
312
  ])) ?? []
330
313
  )
331
314
  }
332
315
  });
333
316
  }
334
- function $(e, t = {}) {
335
- const a = L(e);
336
- if (!a) return console.warn(`Filter [${e}] does not exist.`);
317
+ function q(e, n = {}) {
318
+ const r = U(e);
319
+ if (!r) return console.warn(`Filter [${e}] does not exist.`);
337
320
  const {
338
- debounce: m = 250,
339
- transform: k = (P) => P,
340
- ...G
341
- } = t;
321
+ debounce: p = 250,
322
+ transform: V = (L) => L,
323
+ ...O
324
+ } = n;
342
325
  return {
343
- "onUpdate:modelValue": N((P) => {
344
- M(a, k(P), G);
345
- }, m),
346
- modelValue: a.value
326
+ "onUpdate:modelValue": D((L) => {
327
+ P(r, V(L), O);
328
+ }, p),
329
+ modelValue: r.value
347
330
  };
348
331
  }
349
- function H(e, t = {}) {
350
- const a = T(e);
351
- if (!a) return console.warn(`Sort [${e}] does not exist.`);
352
- const { debounce: m = 0, transform: k, ...G } = t;
332
+ function t(e, n = {}) {
333
+ const r = y(e);
334
+ if (!r) return console.warn(`Sort [${e}] does not exist.`);
335
+ const { debounce: p = 0, transform: V, ...O } = n;
353
336
  return {
354
- onClick: N(() => {
355
- var P;
356
- z(a, (P = g.value) == null ? void 0 : P.direction, G);
357
- }, m)
337
+ onClick: D(() => {
338
+ var L;
339
+ A(r, (L = s.value) == null ? void 0 : L.direction, O);
340
+ }, p)
358
341
  };
359
342
  }
360
- function _(e = {}) {
361
- const { debounce: t = 700, transform: a, ...m } = e;
343
+ function u(e = {}) {
344
+ const { debounce: n = 700, transform: r, ...p } = e;
362
345
  return {
363
- "onUpdate:modelValue": N(
364
- (k) => {
365
- O(k, m);
346
+ "onUpdate:modelValue": D(
347
+ (V) => {
348
+ j(V, p);
366
349
  },
367
- t
350
+ n
368
351
  ),
369
- modelValue: l.value.term ?? ""
352
+ modelValue: a.value.term ?? ""
370
353
  };
371
354
  }
372
- function J(e, t = {}) {
373
- const a = E(e);
374
- if (!a) return console.warn(`Match [${e}] does not exist.`);
375
- const { debounce: m = 0, transform: k, ...G } = t;
355
+ function f(e, n = {}) {
356
+ const r = T(e);
357
+ if (!r) return console.warn(`Match [${e}] does not exist.`);
358
+ const { debounce: p = 0, transform: V, ...O } = n;
376
359
  return {
377
- "onUpdate:modelValue": N((P) => {
378
- j(P, G);
379
- }, m),
380
- modelValue: I(a),
381
- value: a.name
360
+ "onUpdate:modelValue": D((L) => {
361
+ $(L, O);
362
+ }, p),
363
+ modelValue: F(r),
364
+ value: r.name
382
365
  };
383
366
  }
384
367
  return {
385
- filters: b,
386
- sorts: V,
387
- searches: w,
388
- currentFilters: s,
389
- currentSort: g,
390
- currentSearches: R,
391
- isSortable: f,
368
+ filters: g,
369
+ sorts: k,
370
+ searches: x,
371
+ currentFilters: w,
372
+ currentSort: s,
373
+ currentSearches: h,
374
+ isSortable: m,
392
375
  isSearchable: o,
393
- isMatchable: u,
394
- isFiltering: F,
395
- isSorting: B,
396
- isSearching: I,
397
- getFilter: L,
398
- getSort: T,
399
- getSearch: E,
400
- apply: D,
401
- applyFilter: M,
402
- applySort: z,
403
- applySearch: O,
404
- applyMatch: j,
405
- clearFilter: K,
406
- clearSort: n,
407
- clearSearch: i,
408
- clearMatch: d,
409
- reset: A,
410
- bindFilter: $,
411
- bindSort: H,
412
- bindSearch: _,
413
- bindMatch: J,
414
- stringValue: C,
415
- omitValue: h,
416
- toggleValue: y,
417
- delimitArray: U
376
+ isMatchable: i,
377
+ isFiltering: b,
378
+ isSorting: G,
379
+ isSearching: F,
380
+ getFilter: U,
381
+ getSort: y,
382
+ getSearch: T,
383
+ apply: C,
384
+ applyFilter: P,
385
+ applySort: A,
386
+ applySearch: j,
387
+ applyMatch: $,
388
+ clearFilter: B,
389
+ clearSort: I,
390
+ clearSearch: H,
391
+ clearMatch: K,
392
+ reset: N,
393
+ bindFilter: q,
394
+ bindSort: t,
395
+ bindSearch: u,
396
+ bindMatch: f,
397
+ stringValue: R,
398
+ omitValue: E,
399
+ toggleValue: z,
400
+ delimitArray: M
418
401
  };
419
402
  }
420
- function ie(r, v, c = {}) {
421
- if (!(r != null && r[v]))
403
+ function ue(l, v, c = {}) {
404
+ if (!(l != null && l[v]))
422
405
  throw new Error("The table must be provided with valid props and key.");
423
- const { recordActions: l = {}, ...f } = {
406
+ const { recordOperations: a = {}, ...m } = {
424
407
  only: [...c.only ?? [], v.toString()],
425
408
  ...c
426
- }, o = p(() => r[v]), u = te(), b = re(r, v, f), V = p(() => !!o.value.page && !!o.value.record), w = p(() => !!o.value.column), x = p(
427
- () => o.value.columns.filter(({ active: n, hidden: i }) => n && !i).map((n) => {
428
- var i;
409
+ }, o = d(() => l[v]), i = te(), g = ae(l, v, m), k = d(() => o.value.meta), x = d(() => !!o.value.page && !!o.value.record), w = d(() => !!o.value.column), s = d(
410
+ () => o.value.columns.filter(({ active: t, hidden: u }) => t && !u).map((t) => {
411
+ var u;
429
412
  return {
430
- ...n,
431
- isSorting: !!((i = n.sort) != null && i.active),
432
- toggleSort: (d = {}) => b.applySort(n.sort, null, d)
413
+ ...t,
414
+ isSorting: !!((u = t.sort) != null && u.active),
415
+ toggleSort: (f = {}) => g.applySort(t.sort, null, f)
433
416
  };
434
417
  })
435
- ), s = p(
436
- () => o.value.columns.filter(({ hidden: n }) => !n).map((n) => ({
437
- ...n,
438
- toggle: (i = {}) => z(n.name, i)
418
+ ), h = d(
419
+ () => o.value.columns.filter(({ hidden: t }) => !t).map((t) => ({
420
+ ...t,
421
+ toggle: (u = {}) => H(t.name, u)
439
422
  }))
440
- ), g = p(
441
- () => o.value.records.map((n) => ({
442
- record: (({ actions: i, ...d }) => d)(n),
443
- /** The actions available for the record */
444
- actions: E(n.actions),
445
- /** Perform this action when the record is clicked */
446
- default: (i = {}) => {
447
- const d = n.actions.find(({ default: A }) => A);
448
- d && B(d, n, i);
423
+ ), M = d(
424
+ () => o.value.records.map((t) => ({
425
+ /** The operations available for the record */
426
+ operations: P(t.operations),
427
+ /** Perform this operation when the record is clicked */
428
+ default: (u = {}) => {
429
+ const f = t.operations.find(
430
+ ({ default: e }) => e
431
+ );
432
+ f && j(f, t, u);
449
433
  },
450
434
  /** Selects this record */
451
- select: () => u.select(y(n)),
435
+ select: () => i.select(b(t)),
452
436
  /** Deselects this record */
453
- deselect: () => u.deselect(y(n)),
437
+ deselect: () => i.deselect(b(t)),
454
438
  /** Toggles the selection of this record */
455
- toggle: () => u.toggle(y(n)),
439
+ toggle: () => i.toggle(b(t)),
456
440
  /** Determine if the record is selected */
457
- selected: u.selected(y(n)),
441
+ selected: i.selected(b(t)),
458
442
  /** Bind the record to a checkbox */
459
- bind: () => u.bind(y(n)),
443
+ bind: () => i.bind(b(t)),
444
+ /** Get the entry of the record for the column */
445
+ entry: (u) => F(t, u),
460
446
  /** Get the value of the record for the column */
461
- value: (i) => {
462
- const d = L(i);
463
- return d in n ? n[d].v : null;
447
+ value: (u) => {
448
+ var f;
449
+ return ((f = F(t, u)) == null ? void 0 : f.v) ?? null;
464
450
  },
465
451
  /** Get the extra data of the record for the column */
466
- extra: (i) => {
467
- const d = L(i);
468
- return d in n ? n[d].e : null;
452
+ extra: (u) => {
453
+ var f;
454
+ return ((f = F(t, u)) == null ? void 0 : f.e) ?? null;
469
455
  }
470
456
  }))
471
- ), R = p(() => E(o.value.operations.bulk)), U = p(() => E(o.value.operations.page)), C = p(
472
- () => o.value.pages.find(({ active: n }) => n)
473
- ), h = p(() => ({
457
+ ), R = d(() => !!o.value.operations.inline), E = d(() => P(o.value.operations.bulk)), W = d(() => P(o.value.operations.page)), z = d(
458
+ () => o.value.pages.find(({ active: t }) => t)
459
+ ), U = d(() => o.value.pages), y = d(() => ({
474
460
  ...o.value.paginate,
475
- next: (n = {}) => {
476
- "nextLink" in h.value && h.value.nextLink && F(h.value.nextLink, n);
461
+ next: (t = {}) => {
462
+ "nextLink" in y.value && y.value.nextLink && A(y.value.nextLink, t);
477
463
  },
478
- previous: (n = {}) => {
479
- "prevLink" in h.value && h.value.prevLink && F(h.value.prevLink, n);
464
+ previous: (t = {}) => {
465
+ "prevLink" in y.value && y.value.prevLink && A(y.value.prevLink, t);
480
466
  },
481
- first: (n = {}) => {
482
- "firstLink" in h.value && h.value.firstLink && F(h.value.firstLink, n);
467
+ first: (t = {}) => {
468
+ "firstLink" in y.value && y.value.firstLink && A(y.value.firstLink, t);
483
469
  },
484
- last: (n = {}) => {
485
- "lastLink" in h.value && h.value.lastLink && F(h.value.lastLink, n);
470
+ last: (t = {}) => {
471
+ "lastLink" in y.value && y.value.lastLink && A(y.value.lastLink, t);
486
472
  },
487
473
  ..."links" in o.value.paginate && o.value.paginate.links ? {
488
- links: o.value.paginate.links.map((n) => ({
489
- ...n,
490
- navigate: (i = {}) => n.url && F(n.url, i)
474
+ links: o.value.paginate.links.map((t) => ({
475
+ ...t,
476
+ navigate: (u = {}) => t.url && A(t.url, u)
491
477
  }))
492
478
  } : {}
493
- })), W = p(
479
+ })), T = d(
494
480
  () => o.value.records.length > 0 && o.value.records.every(
495
- (n) => u.selected(y(n))
481
+ (t) => i.selected(b(t))
496
482
  )
497
483
  );
498
- function y(n) {
499
- return n[o.value.key].v;
484
+ function b(t) {
485
+ return t[o.value.key].v;
486
+ }
487
+ function G(t) {
488
+ return typeof t == "string" ? t : t.name;
500
489
  }
501
- function L(n) {
502
- return typeof n == "string" ? n : n.name;
490
+ function F(t, u) {
491
+ const f = G(u);
492
+ return f in t ? t[f] : null;
503
493
  }
504
- function T(n, i = {}, d = {}) {
505
- return Y(
506
- n,
494
+ function C(t, u = {}, f = {}) {
495
+ return X(
496
+ t,
507
497
  o.value.endpoint,
508
498
  o.value.id,
509
- i,
499
+ u,
510
500
  {
511
- ...f,
512
- ...d
501
+ ...m,
502
+ ...f
513
503
  }
514
504
  );
515
505
  }
516
- function E(n) {
517
- return ne(
518
- n,
506
+ function P(t) {
507
+ return ee(
508
+ t,
519
509
  o.value.endpoint,
520
510
  o.value.id,
521
- f
511
+ m
522
512
  );
523
513
  }
524
- function F(n, i = {}) {
525
- S.visit(n, {
514
+ function A(t, u = {}) {
515
+ S.visit(t, {
526
516
  preserveScroll: !0,
527
517
  preserveState: !0,
528
- ...f,
529
- ...i,
518
+ ...m,
519
+ ...u,
530
520
  method: "get"
531
521
  });
532
522
  }
533
- function B(n, i, d = {}) {
534
- var $;
535
- T(
536
- n,
523
+ function j(t, u, f = {}) {
524
+ var n;
525
+ C(
526
+ t,
537
527
  {
538
- record: y(i)
528
+ record: b(u)
539
529
  },
540
- d
541
- ) || ($ = l == null ? void 0 : l[n.name]) == null || $.call(l, i);
530
+ f
531
+ ) || (n = a == null ? void 0 : a[t.name]) == null || n.call(a, u);
542
532
  }
543
- function I(n, i = {}) {
544
- T(
545
- n,
533
+ function $(t, u = {}) {
534
+ C(
535
+ t,
546
536
  {
547
- all: u.selection.value.all,
548
- only: Array.from(u.selection.value.only),
549
- except: Array.from(u.selection.value.except)
537
+ all: i.selection.value.all,
538
+ only: Array.from(i.selection.value.only),
539
+ except: Array.from(i.selection.value.except)
550
540
  },
551
541
  {
552
- ...i,
553
- onSuccess: (d) => {
554
- var A;
555
- (A = i.onSuccess) == null || A.call(i, d), n.keepSelected || u.deselectAll();
542
+ ...u,
543
+ onSuccess: (f) => {
544
+ var e;
545
+ (e = u.onSuccess) == null || e.call(u, f), t.keepSelected || i.deselectAll();
556
546
  }
557
547
  }
558
548
  );
559
549
  }
560
- function D(n, i = {}, d = {}) {
561
- return T(n, i, d);
550
+ function B(t, u = {}, f = {}) {
551
+ return C(t, u, f);
562
552
  }
563
- function M(n, i = {}) {
564
- if (!V.value)
553
+ function I(t, u = {}) {
554
+ if (!x.value)
565
555
  return console.warn("The table does not support pagination changes.");
566
556
  S.reload({
567
- ...f,
568
- ...i,
557
+ ...m,
558
+ ...u,
569
559
  data: {
570
- [o.value.record]: n.value,
560
+ [o.value.record]: t.value,
571
561
  [o.value.page]: void 0
572
562
  }
573
563
  });
574
564
  }
575
- function z(n, i = {}) {
565
+ function H(t, u = {}) {
576
566
  if (!w.value)
577
567
  return console.warn("The table does not support column toggling.");
578
- const d = L(n);
579
- if (!d) return console.log(`Column [${n}] does not exist.`);
580
- const A = b.toggleValue(
581
- d,
582
- x.value.map(({ name: $ }) => $)
568
+ const f = G(t);
569
+ if (!f) return console.log(`Column [${t}] does not exist.`);
570
+ const e = g.toggleValue(
571
+ f,
572
+ s.value.map(({ name: n }) => n)
583
573
  );
584
574
  S.reload({
585
- ...f,
586
- ...i,
575
+ ...m,
576
+ ...u,
587
577
  data: {
588
- [o.value.column]: b.delimitArray(A)
578
+ [o.value.column]: g.delimitArray(e)
589
579
  }
590
580
  });
591
581
  }
592
- function O() {
593
- u.select(
582
+ function K() {
583
+ i.select(
594
584
  ...o.value.records.map(
595
- (n) => y(n)
585
+ (t) => b(t)
596
586
  )
597
587
  );
598
588
  }
599
- function j() {
600
- u.deselect(
589
+ function N() {
590
+ i.deselect(
601
591
  ...o.value.records.map(
602
- (n) => y(n)
592
+ (t) => b(t)
603
593
  )
604
594
  );
605
595
  }
606
- function K() {
596
+ function q() {
607
597
  return {
608
- "onUpdate:modelValue": (n) => {
609
- n ? O() : j();
598
+ "onUpdate:modelValue": (t) => {
599
+ t ? K() : N();
610
600
  },
611
- modelValue: W.value
601
+ modelValue: T.value
612
602
  };
613
603
  }
614
604
  return Z({
615
- /** The table's configuration */
616
- table: o,
617
- /** Retrieve a record's identifier */
618
- getRecordKey: y,
619
605
  /** Table-specific metadata */
620
- meta: o.value.meta,
606
+ meta: k,
607
+ /** Whether the table supports changing the number of records to display per page */
608
+ isPageable: x,
609
+ /** Whether the table supports toggling columns */
610
+ isToggleable: w,
611
+ /** Retrieve a record's identifier */
612
+ getRecordKey: b,
621
613
  /** The heading columns for the table */
622
- headings: x,
614
+ headings: s,
623
615
  /** All of the table's columns */
624
- columns: s,
616
+ columns: h,
625
617
  /** The records of the table */
626
- records: g,
627
- /** Whether the table has record actions */
628
- inline: o.value.operations.inline,
629
- /** The available bulk actions */
630
- bulk: R,
631
- /** The available page actions */
632
- page: U,
618
+ records: M,
619
+ /** Whether the table has record operations */
620
+ inline: R,
621
+ /** The available bulk operations */
622
+ bulk: E,
623
+ /** The available page operations */
624
+ page: W,
633
625
  /** The available number of records to display per page */
634
- pages: o.value.pages,
626
+ pages: U,
635
627
  /** The current record per page item */
636
- currentPage: C,
628
+ currentPage: z,
637
629
  /** The pagination metadata */
638
- paginator: h,
639
- /** Execute an inline action */
640
- executeInline: B,
641
- /** Execute a bulk action */
642
- executeBulk: I,
643
- /** Execute a page action */
644
- executePage: D,
630
+ paginator: y,
631
+ /** Execute an inline operation */
632
+ executeInline: j,
633
+ /** Execute a bulk operation */
634
+ executeBulk: $,
635
+ /** Execute a page operation */
636
+ executePage: B,
645
637
  /** Apply a new page by changing the number of records to display */
646
- applyPage: M,
638
+ applyPage: I,
647
639
  /** The current selection of records */
648
- selection: u.selection,
640
+ selection: i.selection,
649
641
  /** Select the given records */
650
- select: (n) => u.select(y(n)),
642
+ select: (t) => i.select(b(t)),
651
643
  /** Deselect the given records */
652
- deselect: (n) => u.deselect(y(n)),
644
+ deselect: (t) => i.deselect(b(t)),
653
645
  /** Select records on the current page */
654
- selectPage: O,
646
+ selectPage: K,
655
647
  /** Deselect records on the current page */
656
- deselectPage: j,
648
+ deselectPage: N,
657
649
  /** Toggle the selection of the given records */
658
- toggle: (n) => u.toggle(y(n)),
650
+ toggle: (t) => i.toggle(b(t)),
659
651
  /** Determine if the given record is selected */
660
- selected: (n) => u.selected(y(n)),
652
+ selected: (t) => i.selected(b(t)),
661
653
  /** Select all records */
662
- selectAll: u.selectAll,
654
+ selectAll: i.selectAll,
663
655
  /** Deselect all records */
664
- deselectAll: u.deselectAll,
656
+ deselectAll: i.deselectAll,
665
657
  /** Whether all records on the current page are selected */
666
- isPageSelected: W,
658
+ isPageSelected: T,
667
659
  /** Determine if any records are selected */
668
- hasSelected: u.hasSelected,
660
+ hasSelected: i.hasSelected,
669
661
  /** Bind the given record to a checkbox */
670
- bindCheckbox: (n) => u.bind(y(n)),
662
+ bindCheckbox: (t) => i.bind(b(t)),
671
663
  /** Bind the select all checkbox to the current page */
672
- bindPage: K,
664
+ bindPage: q,
673
665
  /** Bind select all records to the checkbox */
674
- bindAll: u.bindAll,
666
+ bindAll: i.bindAll,
675
667
  /** Include the sorts, filters, and search query */
676
- ...b
668
+ ...g
677
669
  });
678
670
  }
679
- function ce(r, v) {
680
- return r ? typeof r == "object" ? r.type === v : r === v : !1;
671
+ function ie(l, v) {
672
+ return l ? typeof l == "object" ? l.type === v : l === v : !1;
681
673
  }
682
674
  export {
683
- ce as is,
684
- ie as useTable
675
+ ie as is,
676
+ ue as useTable
685
677
  };