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