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