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