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