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