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