@honed/table 0.2.0 → 0.2.1
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 +11 -59
- package/dist/index.es.js +60 -62
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { BindingOptions } from '@honed/refine';
|
|
2
|
-
import { BooleanFilterRefiner } from '@honed/refine';
|
|
3
2
|
import { BulkAction } from '@honed/action';
|
|
4
3
|
import { BulkSelection } from '@honed/action';
|
|
5
4
|
import { Config as Config_2 } from '@honed/refine';
|
|
6
5
|
import { Confirm } from '@honed/action';
|
|
7
|
-
import { DateFilterRefiner } from '@honed/refine';
|
|
8
6
|
import { Direction } from '@honed/refine';
|
|
9
|
-
import {
|
|
7
|
+
import { Filter } from '@honed/refine';
|
|
10
8
|
import { FilterValue } from '@honed/refine';
|
|
11
9
|
import { InlineAction } from '@honed/action';
|
|
12
10
|
import { Option as Option_2 } from '@honed/refine';
|
|
@@ -15,7 +13,6 @@ import { PromisifyFn } from '@vueuse/shared';
|
|
|
15
13
|
import { Refine } from '@honed/refine';
|
|
16
14
|
import { Route } from '@honed/action';
|
|
17
15
|
import { Search } from '@honed/refine';
|
|
18
|
-
import { SetFilterRefiner } from '@honed/refine';
|
|
19
16
|
import { Sort } from '@honed/refine';
|
|
20
17
|
import { Visit } from '@inertiajs/core';
|
|
21
18
|
import { VisitCallbacks } from '@inertiajs/core';
|
|
@@ -110,7 +107,7 @@ export declare interface TableOptions<T extends Record<string, any>> {
|
|
|
110
107
|
}
|
|
111
108
|
|
|
112
109
|
export declare function useTable<T extends object, K extends T[keyof T] extends Refine ? keyof T : never, U extends Record<string, any> = any, V extends "cursor" | "length-aware" | "simple" | "collection" = "length-aware">(props: T, key: K, tableOptions?: TableOptions<U>, defaultOptions?: VisitOptions): {
|
|
113
|
-
filters:
|
|
110
|
+
filters: {
|
|
114
111
|
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
115
112
|
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
116
113
|
bind: () => {
|
|
@@ -119,20 +116,6 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
119
116
|
value: unknown;
|
|
120
117
|
} | undefined;
|
|
121
118
|
type: string;
|
|
122
|
-
value: FilterValue;
|
|
123
|
-
name: string;
|
|
124
|
-
label: string;
|
|
125
|
-
active: boolean;
|
|
126
|
-
meta: Record<string, any>;
|
|
127
|
-
} | {
|
|
128
|
-
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
129
|
-
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
130
|
-
bind: () => {
|
|
131
|
-
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
132
|
-
modelValue: unknown;
|
|
133
|
-
value: unknown;
|
|
134
|
-
} | undefined;
|
|
135
|
-
type: "set";
|
|
136
119
|
multiple: boolean;
|
|
137
120
|
options: Option_2[];
|
|
138
121
|
value: FilterValue;
|
|
@@ -140,35 +123,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
140
123
|
label: string;
|
|
141
124
|
active: boolean;
|
|
142
125
|
meta: Record<string, any>;
|
|
143
|
-
}
|
|
144
|
-
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
145
|
-
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
146
|
-
bind: () => {
|
|
147
|
-
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
148
|
-
modelValue: unknown;
|
|
149
|
-
value: unknown;
|
|
150
|
-
} | undefined;
|
|
151
|
-
type: "date";
|
|
152
|
-
value: string;
|
|
153
|
-
name: string;
|
|
154
|
-
label: string;
|
|
155
|
-
active: boolean;
|
|
156
|
-
meta: Record<string, any>;
|
|
157
|
-
} | {
|
|
158
|
-
apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
159
|
-
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
160
|
-
bind: () => {
|
|
161
|
-
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
162
|
-
modelValue: unknown;
|
|
163
|
-
value: unknown;
|
|
164
|
-
} | undefined;
|
|
165
|
-
type: "boolean";
|
|
166
|
-
value: boolean;
|
|
167
|
-
name: string;
|
|
168
|
-
label: string;
|
|
169
|
-
active: boolean;
|
|
170
|
-
meta: Record<string, any>;
|
|
171
|
-
})[];
|
|
126
|
+
}[];
|
|
172
127
|
sorts: {
|
|
173
128
|
apply: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
174
129
|
clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
@@ -179,7 +134,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
179
134
|
direction: Direction;
|
|
180
135
|
next: string | null;
|
|
181
136
|
name: string;
|
|
182
|
-
label: string;
|
|
137
|
+
label: string;
|
|
183
138
|
active: boolean;
|
|
184
139
|
meta: Record<string, any>;
|
|
185
140
|
}[];
|
|
@@ -189,34 +144,33 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
189
144
|
bind: () => {
|
|
190
145
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
191
146
|
modelValue: boolean;
|
|
192
|
-
|
|
193
|
-
} | undefined; /** Deselects this record */
|
|
147
|
+
} | undefined;
|
|
194
148
|
name: string;
|
|
195
149
|
label: string;
|
|
196
150
|
type: string;
|
|
197
151
|
active: boolean;
|
|
198
152
|
meta: Record<string, any>;
|
|
199
153
|
}[] | undefined;
|
|
200
|
-
getFilter: (name: string) =>
|
|
154
|
+
getFilter: (name: string) => Filter | undefined;
|
|
201
155
|
getSort: (name: string, direction?: Direction | undefined) => Sort | undefined;
|
|
202
156
|
getSearch: (name: string) => Search | undefined;
|
|
203
|
-
currentFilters: () =>
|
|
157
|
+
currentFilters: () => Filter[];
|
|
204
158
|
currentSort: () => Sort | undefined;
|
|
205
159
|
currentSearches: () => Search[];
|
|
206
|
-
isFiltering: (name?: string |
|
|
160
|
+
isFiltering: (name?: string | Filter | undefined) => boolean;
|
|
207
161
|
isSorting: (name?: string | Sort | undefined) => boolean;
|
|
208
162
|
isSearching: (name?: string | Search | undefined) => boolean;
|
|
209
163
|
apply: (values: Record<string, any>, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
210
|
-
applyFilter: (filter: string |
|
|
164
|
+
applyFilter: (filter: string | Filter, value: any, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
211
165
|
applySort: (sort: string | Sort, direction?: Direction | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
212
166
|
applySearch: (value: string | null | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
213
167
|
applyMatch: (value: string | Search, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
214
|
-
clearFilter: (filter: string |
|
|
168
|
+
clearFilter: (filter: string | Filter, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
215
169
|
clearSort: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
216
170
|
clearSearch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
217
171
|
clearMatch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
218
172
|
reset: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
|
|
219
|
-
bindFilter: <T_1 extends unknown>(filter: string |
|
|
173
|
+
bindFilter: <T_1 extends unknown>(filter: string | Filter, options?: BindingOptions | undefined) => {
|
|
220
174
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
221
175
|
modelValue: T_1;
|
|
222
176
|
value: T_1;
|
|
@@ -227,12 +181,10 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
|
|
|
227
181
|
bindSearch: (options?: BindingOptions | undefined) => {
|
|
228
182
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
229
183
|
modelValue: string;
|
|
230
|
-
value: string;
|
|
231
184
|
};
|
|
232
185
|
bindMatch: (match: string | Search, options?: BindingOptions | undefined) => {
|
|
233
186
|
"onUpdate:modelValue": PromisifyFn<(value: any) => void>;
|
|
234
187
|
modelValue: boolean;
|
|
235
|
-
value: boolean;
|
|
236
188
|
} | undefined;
|
|
237
189
|
stringValue: (value: any) => any;
|
|
238
190
|
omitValue: (value: any) => any;
|
package/dist/index.es.js
CHANGED
|
@@ -114,8 +114,8 @@ function ee(o, f, v = {}) {
|
|
|
114
114
|
var e;
|
|
115
115
|
return ((e = l.value.filters) == null ? void 0 : e.map((n) => ({
|
|
116
116
|
...n,
|
|
117
|
-
apply: (a, c = {}) =>
|
|
118
|
-
clear: (a = {}) =>
|
|
117
|
+
apply: (a, c = {}) => L(n, a, c),
|
|
118
|
+
clear: (a = {}) => W(n, a),
|
|
119
119
|
bind: () => g(n.name)
|
|
120
120
|
}))) ?? [];
|
|
121
121
|
}
|
|
@@ -134,8 +134,8 @@ function ee(o, f, v = {}) {
|
|
|
134
134
|
var e;
|
|
135
135
|
return (e = l.value.searches) == null ? void 0 : e.map((n) => ({
|
|
136
136
|
...n,
|
|
137
|
-
apply: (a = {}) =>
|
|
138
|
-
clear: (a = {}) =>
|
|
137
|
+
apply: (a = {}) => U(n, a),
|
|
138
|
+
clear: (a = {}) => U(n, a),
|
|
139
139
|
bind: () => K(n)
|
|
140
140
|
}));
|
|
141
141
|
}
|
|
@@ -163,7 +163,7 @@ function ee(o, f, v = {}) {
|
|
|
163
163
|
var n;
|
|
164
164
|
return (n = l.value.filters) == null ? void 0 : n.find((a) => a.name === e);
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function T(e, n = null) {
|
|
167
167
|
var a;
|
|
168
168
|
return (a = l.value.sorts) == null ? void 0 : a.find(
|
|
169
169
|
(c) => c.name === e && c.direction === n
|
|
@@ -173,7 +173,7 @@ function ee(o, f, v = {}) {
|
|
|
173
173
|
var n;
|
|
174
174
|
return (n = l.value.searches) == null ? void 0 : n.find((a) => a.name === e);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function z() {
|
|
177
177
|
var e;
|
|
178
178
|
return ((e = l.value.filters) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
|
|
179
179
|
}
|
|
@@ -186,19 +186,19 @@ function ee(o, f, v = {}) {
|
|
|
186
186
|
return ((e = l.value.searches) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
|
|
187
187
|
}
|
|
188
188
|
function y(e) {
|
|
189
|
-
return e ? typeof e == "string" ?
|
|
189
|
+
return e ? typeof e == "string" ? z().some((n) => n.name === e) : e.active : !!z().length;
|
|
190
190
|
}
|
|
191
191
|
function w(e) {
|
|
192
192
|
var n;
|
|
193
193
|
return e ? typeof e == "string" ? ((n = p()) == null ? void 0 : n.name) === e : e.active : !!p();
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function E(e) {
|
|
196
196
|
var n, a;
|
|
197
197
|
return e ? typeof e == "string" ? (a = V()) == null ? void 0 : a.some((c) => c.name === e) : e.active : !!((n = V()) != null && n.length);
|
|
198
198
|
}
|
|
199
199
|
function q(e, n = {}) {
|
|
200
200
|
const a = Object.fromEntries(
|
|
201
|
-
Object.entries(e).map(([c,
|
|
201
|
+
Object.entries(e).map(([c, F]) => [c, k(F)])
|
|
202
202
|
);
|
|
203
203
|
S.reload({
|
|
204
204
|
...v,
|
|
@@ -206,7 +206,7 @@ function ee(o, f, v = {}) {
|
|
|
206
206
|
data: a
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function L(e, n, a = {}) {
|
|
210
210
|
const c = typeof e == "string" ? m(e) : e;
|
|
211
211
|
if (!c) {
|
|
212
212
|
console.warn(`Filter [${e}] does not exist.`);
|
|
@@ -221,7 +221,7 @@ function ee(o, f, v = {}) {
|
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
function M(e, n = null, a = {}) {
|
|
224
|
-
const c = typeof e == "string" ?
|
|
224
|
+
const c = typeof e == "string" ? T(e, n) : e;
|
|
225
225
|
if (!c) {
|
|
226
226
|
console.warn(`Sort [${e}] does not exist.`);
|
|
227
227
|
return;
|
|
@@ -234,7 +234,7 @@ function ee(o, f, v = {}) {
|
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function G(e, n = {}) {
|
|
238
238
|
e = [A, x].reduce(
|
|
239
239
|
(a, c) => c(a),
|
|
240
240
|
e
|
|
@@ -246,7 +246,7 @@ function ee(o, f, v = {}) {
|
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function U(e, n = {}) {
|
|
250
250
|
if (!l.value.config.matches) {
|
|
251
251
|
console.warn("Matches key is not set.");
|
|
252
252
|
return;
|
|
@@ -267,8 +267,8 @@ function ee(o, f, v = {}) {
|
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
|
|
270
|
+
function W(e, n = {}) {
|
|
271
|
+
L(e, void 0, n);
|
|
272
272
|
}
|
|
273
273
|
function B(e = {}) {
|
|
274
274
|
S.reload({
|
|
@@ -280,7 +280,7 @@ function ee(o, f, v = {}) {
|
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
function H(e = {}) {
|
|
283
|
-
|
|
283
|
+
G(void 0, e);
|
|
284
284
|
}
|
|
285
285
|
function t(e = {}) {
|
|
286
286
|
if (!l.value.config.matches) {
|
|
@@ -320,40 +320,39 @@ function ee(o, f, v = {}) {
|
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
const c = a.value, {
|
|
323
|
-
debounce:
|
|
323
|
+
debounce: F = 250,
|
|
324
324
|
transform: R = (I) => I,
|
|
325
|
-
...
|
|
325
|
+
...j
|
|
326
326
|
} = n;
|
|
327
327
|
return {
|
|
328
328
|
"onUpdate:modelValue": D((I) => {
|
|
329
|
-
|
|
330
|
-
},
|
|
329
|
+
L(a, R(I), j);
|
|
330
|
+
}, F),
|
|
331
331
|
modelValue: c,
|
|
332
332
|
value: c
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
335
|
function P(e, n = {}) {
|
|
336
|
-
const a = typeof e == "string" ?
|
|
336
|
+
const a = typeof e == "string" ? T(e) : e;
|
|
337
337
|
if (!a) {
|
|
338
338
|
console.warn(`Sort [${e}] does not exist.`);
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
|
-
const { debounce: c = 0, transform:
|
|
341
|
+
const { debounce: c = 0, transform: F, ...R } = n;
|
|
342
342
|
return {
|
|
343
343
|
onClick: D(() => {
|
|
344
|
-
var
|
|
345
|
-
M(a, (
|
|
344
|
+
var j;
|
|
345
|
+
M(a, (j = p()) == null ? void 0 : j.direction, R);
|
|
346
346
|
}, c)
|
|
347
347
|
};
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function $(e = {}) {
|
|
350
350
|
const { debounce: n = 700, transform: a, ...c } = e;
|
|
351
351
|
return {
|
|
352
|
-
"onUpdate:modelValue": D((
|
|
353
|
-
|
|
352
|
+
"onUpdate:modelValue": D((F) => {
|
|
353
|
+
G(F, c);
|
|
354
354
|
}, n),
|
|
355
|
-
modelValue: l.value.config.search ?? ""
|
|
356
|
-
value: l.value.config.search ?? ""
|
|
355
|
+
modelValue: l.value.config.search ?? ""
|
|
357
356
|
};
|
|
358
357
|
}
|
|
359
358
|
function K(e, n = {}) {
|
|
@@ -362,13 +361,12 @@ function ee(o, f, v = {}) {
|
|
|
362
361
|
console.warn(`Match [${e}] does not exist.`);
|
|
363
362
|
return;
|
|
364
363
|
}
|
|
365
|
-
const { debounce: c = 0, transform:
|
|
364
|
+
const { debounce: c = 0, transform: F, ...R } = n;
|
|
366
365
|
return {
|
|
367
|
-
"onUpdate:modelValue": D((
|
|
368
|
-
|
|
366
|
+
"onUpdate:modelValue": D((j) => {
|
|
367
|
+
U(j, R);
|
|
369
368
|
}, c),
|
|
370
|
-
modelValue:
|
|
371
|
-
value: L(a)
|
|
369
|
+
modelValue: E(a)
|
|
372
370
|
};
|
|
373
371
|
}
|
|
374
372
|
return {
|
|
@@ -376,27 +374,27 @@ function ee(o, f, v = {}) {
|
|
|
376
374
|
sorts: u,
|
|
377
375
|
searches: b,
|
|
378
376
|
getFilter: m,
|
|
379
|
-
getSort:
|
|
377
|
+
getSort: T,
|
|
380
378
|
getSearch: C,
|
|
381
|
-
currentFilters:
|
|
379
|
+
currentFilters: z,
|
|
382
380
|
currentSort: p,
|
|
383
381
|
currentSearches: V,
|
|
384
382
|
isFiltering: y,
|
|
385
383
|
isSorting: w,
|
|
386
|
-
isSearching:
|
|
384
|
+
isSearching: E,
|
|
387
385
|
apply: q,
|
|
388
|
-
applyFilter:
|
|
386
|
+
applyFilter: L,
|
|
389
387
|
applySort: M,
|
|
390
|
-
applySearch:
|
|
391
|
-
applyMatch:
|
|
392
|
-
clearFilter:
|
|
388
|
+
applySearch: G,
|
|
389
|
+
applyMatch: U,
|
|
390
|
+
clearFilter: W,
|
|
393
391
|
clearSort: B,
|
|
394
392
|
clearSearch: H,
|
|
395
393
|
clearMatch: t,
|
|
396
394
|
reset: r,
|
|
397
395
|
bindFilter: g,
|
|
398
396
|
bindSort: P,
|
|
399
|
-
bindSearch:
|
|
397
|
+
bindSearch: $,
|
|
400
398
|
bindMatch: K,
|
|
401
399
|
stringValue: A,
|
|
402
400
|
omitValue: x,
|
|
@@ -417,7 +415,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
417
415
|
return {
|
|
418
416
|
...r,
|
|
419
417
|
isSorting: (g = r.sort) == null ? void 0 : g.active,
|
|
420
|
-
toggleSort: (P = {}) =>
|
|
418
|
+
toggleSort: (P = {}) => G(r, P)
|
|
421
419
|
};
|
|
422
420
|
})) ?? [];
|
|
423
421
|
}
|
|
@@ -426,7 +424,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
426
424
|
var t;
|
|
427
425
|
return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: r }) => !r).map((r) => ({
|
|
428
426
|
...r,
|
|
429
|
-
toggle: (g = {}) =>
|
|
427
|
+
toggle: (g = {}) => U(r, g)
|
|
430
428
|
}))) ?? [];
|
|
431
429
|
}
|
|
432
430
|
), s = h(
|
|
@@ -437,13 +435,13 @@ function le(o, f, v = {}, l = {}) {
|
|
|
437
435
|
const g = t.actions.find(
|
|
438
436
|
(P) => P.default
|
|
439
437
|
);
|
|
440
|
-
g &&
|
|
438
|
+
g && E(g, t, r);
|
|
441
439
|
},
|
|
442
440
|
/** The actions available for the record */
|
|
443
441
|
actions: t.actions.map((r) => ({
|
|
444
442
|
...r,
|
|
445
443
|
/** Executes this action */
|
|
446
|
-
execute: (g = {}) =>
|
|
444
|
+
execute: (g = {}) => E(r, t, g)
|
|
447
445
|
})),
|
|
448
446
|
/** Selects this record */
|
|
449
447
|
select: () => u.select(y(t)),
|
|
@@ -462,11 +460,11 @@ function le(o, f, v = {}, l = {}) {
|
|
|
462
460
|
/** Executes this bulk action */
|
|
463
461
|
execute: (r = {}) => q(t, r)
|
|
464
462
|
}))
|
|
465
|
-
),
|
|
463
|
+
), T = h(
|
|
466
464
|
() => i.value.actions.page.map((t) => ({
|
|
467
465
|
...t,
|
|
468
466
|
/** Executes this page action */
|
|
469
|
-
execute: (r = {}) =>
|
|
467
|
+
execute: (r = {}) => L(t, r)
|
|
470
468
|
}))
|
|
471
469
|
), C = h(
|
|
472
470
|
() => i.value.recordsPerPage.map((t) => ({
|
|
@@ -474,7 +472,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
474
472
|
/** Changes the number of records to display per page */
|
|
475
473
|
apply: (r = {}) => M(t, r)
|
|
476
474
|
}))
|
|
477
|
-
),
|
|
475
|
+
), z = h(
|
|
478
476
|
() => i.value.recordsPerPage.find(({ active: t }) => t)
|
|
479
477
|
), p = h(() => ({
|
|
480
478
|
...i.value.paginator,
|
|
@@ -513,8 +511,8 @@ function le(o, f, v = {}, l = {}) {
|
|
|
513
511
|
method: "get"
|
|
514
512
|
});
|
|
515
513
|
}
|
|
516
|
-
function
|
|
517
|
-
var
|
|
514
|
+
function E(t, r, g = {}) {
|
|
515
|
+
var $, K;
|
|
518
516
|
J(
|
|
519
517
|
t,
|
|
520
518
|
d.value.endpoint,
|
|
@@ -523,7 +521,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
523
521
|
id: y(r)
|
|
524
522
|
},
|
|
525
523
|
g
|
|
526
|
-
) || (K = (
|
|
524
|
+
) || (K = ($ = v.recordActions) == null ? void 0 : $[t.name]) == null || K.call($, r);
|
|
527
525
|
}
|
|
528
526
|
function q(t, r = {}) {
|
|
529
527
|
J(
|
|
@@ -538,7 +536,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
538
536
|
r
|
|
539
537
|
);
|
|
540
538
|
}
|
|
541
|
-
function
|
|
539
|
+
function L(t, r = {}) {
|
|
542
540
|
J(
|
|
543
541
|
t,
|
|
544
542
|
d.value.endpoint,
|
|
@@ -558,7 +556,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
558
556
|
}
|
|
559
557
|
});
|
|
560
558
|
}
|
|
561
|
-
function
|
|
559
|
+
function G(t, r = {}) {
|
|
562
560
|
t.sort && S.reload({
|
|
563
561
|
...l,
|
|
564
562
|
...r,
|
|
@@ -567,7 +565,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
567
565
|
}
|
|
568
566
|
});
|
|
569
567
|
}
|
|
570
|
-
function
|
|
568
|
+
function U(t, r = {}) {
|
|
571
569
|
const g = b.toggleValue(
|
|
572
570
|
t.name,
|
|
573
571
|
x.value.map(({ name: P }) => P)
|
|
@@ -580,7 +578,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
580
578
|
}
|
|
581
579
|
});
|
|
582
580
|
}
|
|
583
|
-
function
|
|
581
|
+
function W() {
|
|
584
582
|
u.select(
|
|
585
583
|
...i.value.records.map((t) => y(t))
|
|
586
584
|
);
|
|
@@ -593,7 +591,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
593
591
|
function H() {
|
|
594
592
|
return {
|
|
595
593
|
"onUpdate:modelValue": (t) => {
|
|
596
|
-
t ?
|
|
594
|
+
t ? W() : B();
|
|
597
595
|
},
|
|
598
596
|
modelValue: V.value
|
|
599
597
|
};
|
|
@@ -612,19 +610,19 @@ function le(o, f, v = {}, l = {}) {
|
|
|
612
610
|
/** The available bulk actions */
|
|
613
611
|
bulkActions: m,
|
|
614
612
|
/** The available page actions */
|
|
615
|
-
pageActions:
|
|
613
|
+
pageActions: T,
|
|
616
614
|
/** The available number of records to display per page */
|
|
617
615
|
rowsPerPage: C,
|
|
618
616
|
/** The current record per page item */
|
|
619
|
-
currentPage:
|
|
617
|
+
currentPage: z,
|
|
620
618
|
/** The pagination metadata */
|
|
621
619
|
paginator: p,
|
|
622
620
|
/** Execute an inline action */
|
|
623
|
-
executeInlineAction:
|
|
621
|
+
executeInlineAction: E,
|
|
624
622
|
/** Execute a bulk action */
|
|
625
623
|
executeBulkAction: q,
|
|
626
624
|
/** Execute a page action */
|
|
627
|
-
executePageAction:
|
|
625
|
+
executePageAction: L,
|
|
628
626
|
/** Apply a new page by changing the number of records to display */
|
|
629
627
|
applyPage: M,
|
|
630
628
|
/** The current selection of records */
|
|
@@ -634,7 +632,7 @@ function le(o, f, v = {}, l = {}) {
|
|
|
634
632
|
/** Deselect the given records */
|
|
635
633
|
deselect: (t) => u.deselect(y(t)),
|
|
636
634
|
/** Select records on the current page */
|
|
637
|
-
selectPage:
|
|
635
|
+
selectPage: W,
|
|
638
636
|
/** Deselect records on the current page */
|
|
639
637
|
deselectPage: B,
|
|
640
638
|
/** Toggle the selection of the given records */
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(P,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],d):(P=typeof globalThis<"u"?globalThis:P||self,d(P["@honed/table"]={},P.Vue,P.Inertia))})(this,function(P,d,b){"use strict";function _(){const
|
|
1
|
+
(function(P,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],d):(P=typeof globalThis<"u"?globalThis:P||self,d(P["@honed/table"]={},P.Vue,P.Inertia))})(this,function(P,d,b){"use strict";function _(){const a=d.ref({all:!1,only:new Set,except:new Set});function p(){a.value.all=!0,a.value.only.clear(),a.value.except.clear()}function f(){a.value.all=!1,a.value.only.clear(),a.value.except.clear()}function l(...s){s.forEach(m=>a.value.except.delete(m)),s.forEach(m=>a.value.only.add(m))}function i(...s){s.forEach(m=>a.value.except.add(m)),s.forEach(m=>a.value.only.delete(m))}function u(s,m){if(x(s)||m===!1)return i(s);if(!x(s)||m===!0)return l(s)}function x(s){return a.value.all?!a.value.except.has(s):a.value.only.has(s)}const v=d.computed(()=>a.value.all&&a.value.except.size===0),A=d.computed(()=>a.value.only.size>0||v.value);function S(s){return{"onUpdate:modelValue":m=>{m?l(s):i(s)},modelValue:x(s),value:s}}function k(){return{"onUpdate:modelValue":s=>{s?p():f()},modelValue:v.value,value:v.value}}return{allSelected:v,selection:a,hasSelected:A,selectAll:p,deselectAll:f,select:l,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function H(a,p,f={},l={}){return a.route?(b.router.visit(a.route.href,{...l,method:a.route.method}),!0):a.action&&p?(b.router.post(p,{...f,name:a.name,type:a.type},l),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(a,p){function f(...l){return new Promise((i,u)=>{Promise.resolve(a(()=>p.apply(this,l),{fn:p,thisArg:this,args:l})).then(i).catch(u)})}return f}function X(a,p={}){let f,l,i=Y;const u=v=>{clearTimeout(v),i(),i=Y};let x;return v=>{const A=d.toValue(a),S=d.toValue(p.maxWait);return f&&u(f),A<=0||S!==void 0&&S<=0?(l&&(u(l),l=null),Promise.resolve(v())):new Promise((k,s)=>{i=p.rejectOnCancel?s:k,x=v,S&&!l&&(l=setTimeout(()=>{f&&u(f),l=null,k(x())},S)),f=setTimeout(()=>{l&&u(l),l=null,k(v())},A)})}}function R(a,p=200,f={}){return Q(X(p,f),a)}function Z(a,p,f={}){const l=d.computed(()=>a[p]),i=d.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(o,c={})=>j(n,o,c),clear:(o={})=>W(n,o),bind:()=>h(n.name)})))??[]}),u=d.computed(()=>{var e;return((e=l.value.sorts)==null?void 0:e.map(n=>({...n,apply:(o={})=>M(n,n.direction,o),clear:(o={})=>B(o),bind:()=>V(n)})))??[]}),x=d.computed(()=>{var e;return(e=l.value.searches)==null?void 0:e.map(n=>({...n,apply:(o={})=>E(n,o),clear:(o={})=>E(n,o),bind:()=>I(n)}))});function v(e){return Array.isArray(e)?e.join(l.value.config.delimiter):e}function A(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function S(e){if(!["",null,void 0,[]].includes(e))return e}function k(e){return[v,A,S].reduce((n,o)=>o(n),e)}function s(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(o=>o!==e):[...n,e]}function m(e){var n;return(n=l.value.filters)==null?void 0:n.find(o=>o.name===e)}function C(e,n=null){var o;return(o=l.value.sorts)==null?void 0:o.find(c=>c.name===e&&c.direction===n)}function q(e){var n;return(n=l.value.searches)==null?void 0:n.find(o=>o.name===e)}function z(){var e;return((e=l.value.filters)==null?void 0:e.filter(({active:n})=>n))??[]}function g(){var e;return(e=l.value.sorts)==null?void 0:e.find(({active:n})=>n)}function w(){var e;return((e=l.value.searches)==null?void 0:e.filter(({active:n})=>n))??[]}function y(e){return e?typeof e=="string"?z().some(n=>n.name===e):e.active:!!z().length}function L(e){var n;return e?typeof e=="string"?((n=g())==null?void 0:n.name)===e:e.active:!!g()}function F(e){var n,o;return e?typeof e=="string"?(o=w())==null?void 0:o.some(c=>c.name===e):e.active:!!((n=w())!=null&&n.length)}function D(e,n={}){const o=Object.fromEntries(Object.entries(e).map(([c,T])=>[c,k(T)]));b.router.reload({...f,...n,data:o})}function j(e,n,o={}){const c=typeof e=="string"?m(e):e;if(!c){console.warn(`Filter [${e}] does not exist.`);return}"multiple"in c&&c.multiple&&(n=s(n,c.value)),b.router.reload({...f,...o,data:{[c.name]:k(n)}})}function M(e,n=null,o={}){const c=typeof e=="string"?C(e,n):e;if(!c){console.warn(`Sort [${e}] does not exist.`);return}b.router.reload({...f,...o,data:{[l.value.config.sorts]:S(c.next)}})}function G(e,n={}){e=[A,S].reduce((o,c)=>c(o),e),b.router.reload({...f,...n,data:{[l.value.config.searches]:e}})}function E(e,n={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}if(!(typeof e=="string"?q(e):e)){console.warn(`Match [${e}] does not exist.`);return}const o=s(e,w().filter(({active:c})=>c).map(({name:c})=>c));b.router.reload({...f,...n,data:{[l.value.config.matches]:v(o)}})}function W(e,n={}){j(e,void 0,n)}function B(e={}){b.router.reload({...f,...e,data:{[l.value.config.sorts]:null}})}function J(e={}){G(void 0,e)}function t(e={}){if(!l.value.config.matches){console.warn("Matches key is not set.");return}b.router.reload({...f,...e,data:{[l.value.config.matches]:null}})}function r(e={}){var n;b.router.reload({...f,...e,data:{[l.value.config.searches]:void 0,[l.value.config.sorts]:void 0,...Object.fromEntries(((n=l.value.filters)==null?void 0:n.map(o=>[o.name,void 0]))??[]),...l.value.config.matches?{[l.value.config.matches]:void 0}:{}}})}function h(e,n={}){const o=typeof e=="string"?m(e):e;if(!o){console.warn(`Filter [${e}] does not exist.`);return}const c=o.value,{debounce:T=250,transform:K=N=>N,...$}=n;return{"onUpdate:modelValue":R(N=>{j(o,K(N),$)},T),modelValue:c,value:c}}function V(e,n={}){const o=typeof e=="string"?C(e):e;if(!o){console.warn(`Sort [${e}] does not exist.`);return}const{debounce:c=0,transform:T,...K}=n;return{onClick:R(()=>{var $;M(o,($=g())==null?void 0:$.direction,K)},c)}}function U(e={}){const{debounce:n=700,transform:o,...c}=e;return{"onUpdate:modelValue":R(T=>{G(T,c)},n),modelValue:l.value.config.search??""}}function I(e,n={}){const o=typeof e=="string"?q(e):e;if(!o){console.warn(`Match [${e}] does not exist.`);return}const{debounce:c=0,transform:T,...K}=n;return{"onUpdate:modelValue":R($=>{E($,K)},c),modelValue:F(o)}}return{filters:i,sorts:u,searches:x,getFilter:m,getSort:C,getSearch:q,currentFilters:z,currentSort:g,currentSearches:w,isFiltering:y,isSorting:L,isSearching:F,apply:D,applyFilter:j,applySort:M,applySearch:G,applyMatch:E,clearFilter:W,clearSort:B,clearSearch:J,clearMatch:t,reset:r,bindFilter:h,bindSort:V,bindSearch:U,bindMatch:I,stringValue:A,omitValue:S,toggleValue:s,delimitArray:v}}function O(a,p,f={},l={}){l={...l,only:[...l.only??[],p.toString()]};const i=d.computed(()=>a[p]),u=_(),x=Z(a,p,l),v=d.computed(()=>i.value.config),A=d.computed(()=>i.value.meta),S=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({active:r,hidden:h})=>r&&!h).map(r=>{var h;return{...r,isSorting:(h=r.sort)==null?void 0:h.active,toggleSort:(V={})=>G(r,V)}}))??[]}),k=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:r})=>!r).map(r=>({...r,toggle:(h={})=>E(r,h)})))??[]}),s=d.computed(()=>i.value.records.map(t=>({...t,default:(r={})=>{const h=t.actions.find(V=>V.default);h&&F(h,t,r)},actions:t.actions.map(r=>({...r,execute:(h={})=>F(r,t,h)})),select:()=>u.select(y(t)),deselect:()=>u.deselect(y(t)),toggle:()=>u.toggle(y(t)),selected:u.selected(y(t)),bind:()=>u.bind(y(t))}))),m=d.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(r={})=>D(t,r)}))),C=d.computed(()=>i.value.actions.page.map(t=>({...t,execute:(r={})=>j(t,r)}))),q=d.computed(()=>i.value.recordsPerPage.map(t=>({...t,apply:(r={})=>M(t,r)}))),z=d.computed(()=>i.value.recordsPerPage.find(({active:t})=>t)),g=d.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in g.value&&g.value.nextLink&&L(g.value.nextLink,t)},previous:(t={})=>{"prevLink"in g.value&&g.value.prevLink&&L(g.value.prevLink,t)},first:(t={})=>{"firstLink"in g.value&&g.value.firstLink&&L(g.value.firstLink,t)},last:(t={})=>{"lastLink"in g.value&&g.value.lastLink&&L(g.value.lastLink,t)},..."links"in i.value.paginator&&i.value.paginator.links?{links:i.value.paginator.links.map(t=>({...t,navigate:(r={})=>t.url&&L(t.url,r)}))}:{}})),w=d.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[v.value.record]}function L(t,r={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...r,method:"get"})}function F(t,r,h={}){var U,I;H(t,v.value.endpoint,{table:i.value.id,id:y(r)},h)||(I=(U=f.recordActions)==null?void 0:U[t.name])==null||I.call(U,r)}function D(t,r={}){H(t,v.value.endpoint,{table:i.value.id,all:u.selection.value.all,only:Array.from(u.selection.value.only),except:Array.from(u.selection.value.except)},r)}function j(t,r={}){H(t,v.value.endpoint,{table:i.value.id},r)}function M(t,r={}){b.router.reload({...l,...r,data:{[v.value.records]:t.value,[v.value.pages]:void 0}})}function G(t,r={}){t.sort&&b.router.reload({...l,...r,data:{[v.value.sorts]:x.omitValue(t.sort.next)}})}function E(t,r={}){const h=x.toggleValue(t.name,S.value.map(({name:V})=>V));b.router.reload({...l,...r,data:{[v.value.columns]:x.delimitArray(h)}})}function W(){u.select(...i.value.records.map(t=>y(t)))}function B(){u.deselect(...i.value.records.map(t=>y(t)))}function J(){return{"onUpdate:modelValue":t=>{t?W():B()},modelValue:w.value}}return d.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:m,pageActions:C,rowsPerPage:q,currentPage:z,paginator:g,executeInlineAction:F,executeBulkAction:D,executePageAction:j,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:W,deselectPage:B,toggle:t=>u.toggle(y(t)),selected:t=>u.selected(y(t)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:w,hasSelected:u.hasSelected,bindCheckbox:t=>u.bind(y(t)),bindPage:J,bindAll:u.bindAll,...x})}P.useTable=O,Object.defineProperty(P,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.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "-",
|
|
7
7
|
"keywords": [
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@honed/action": "^0.2.0",
|
|
52
|
-
"@honed/refine": "^0.2.
|
|
52
|
+
"@honed/refine": "^0.2.2",
|
|
53
53
|
"@inertiajs/vue3": "^1.2.0||^2.0.0",
|
|
54
54
|
"@vueuse/core": "^11.0.0||^12.0.0",
|
|
55
55
|
"axios": "^1.2.0",
|