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