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