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