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