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