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