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