@honed/table 0.2.0 → 0.3.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 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 { FilterRefiner } from '@honed/refine';
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,12 +13,18 @@ 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';
22
19
  import { VisitOptions } from '@inertiajs/core';
23
20
 
21
+ export declare type AsRecord<RecordType extends Record<string, any>> = {
22
+ [K in keyof RecordType]: {
23
+ value: RecordType[K];
24
+ extra: Record<string, any>;
25
+ };
26
+ };
27
+
24
28
  export declare interface CollectionPaginator {
25
29
  empty: boolean;
26
30
  }
@@ -28,13 +32,12 @@ export declare interface CollectionPaginator {
28
32
  export declare interface Column<T extends Record<string, any>> {
29
33
  name: keyof T;
30
34
  label: string;
31
- type: "text" | "number" | "date" | "boolean" | string;
35
+ type: "text" | "number" | "date" | "boolean" | "hidden" | "key" | string;
32
36
  hidden: boolean;
33
37
  active: boolean;
34
38
  toggleable: boolean;
35
39
  icon?: string;
36
40
  class?: string;
37
- meta?: Record<string, any>;
38
41
  sort?: {
39
42
  active: boolean;
40
43
  direction: Direction;
@@ -42,7 +45,7 @@ export declare interface Column<T extends Record<string, any>> {
42
45
  };
43
46
  }
44
47
 
45
- declare interface Config extends Config_2 {
48
+ export declare interface Config extends Config_2 {
46
49
  endpoint: string;
47
50
  record: string;
48
51
  records: string;
@@ -67,7 +70,7 @@ export declare interface LengthAwarePaginator extends SimplePaginator {
67
70
  links: PaginatorLink[];
68
71
  }
69
72
 
70
- declare type PaginatorKind = "cursor" | "length-aware" | "simple" | "collection";
73
+ export declare type PaginatorKind = "cursor" | "length-aware" | "simple" | "collection";
71
74
 
72
75
  export declare interface PaginatorLink {
73
76
  url: string | null;
@@ -84,55 +87,53 @@ export declare interface SimplePaginator extends CursorPaginator {
84
87
  currentPage: number;
85
88
  }
86
89
 
87
- export declare interface Table<T extends Record<string, any> = any, U extends PaginatorKind = "length-aware"> extends Refine {
90
+ export declare interface Table<RecordType extends Record<string, any> = any, Paginator extends PaginatorKind = "length-aware"> extends Refine {
91
+ config: Config;
88
92
  id: string;
89
- records: T[] & {
93
+ records: Array<AsRecord<RecordType> & {
90
94
  actions: InlineAction[];
91
- };
92
- paginator: U extends "length-aware" ? LengthAwarePaginator : U extends "simple" ? SimplePaginator : U extends "cursor" ? CursorPaginator : CollectionPaginator;
93
- columns?: Column<T>[];
94
- recordsPerPage: PerPageRecord[];
95
+ }>;
96
+ paginator: Paginator extends "length-aware" ? LengthAwarePaginator : Paginator extends "simple" ? SimplePaginator : Paginator extends "cursor" ? CursorPaginator : CollectionPaginator;
97
+ columns?: Column<RecordType>[];
98
+ recordsPerPage?: PerPageRecord[];
95
99
  toggleable: boolean;
96
100
  actions: {
97
101
  hasInline: boolean;
98
102
  bulk: BulkAction[];
99
103
  page: PageAction[];
100
104
  };
101
- config: Config;
102
105
  meta: Record<string, any>;
103
106
  }
104
107
 
105
- export declare interface TableOptions<T extends Record<string, any>> {
108
+ export declare interface TableOptions<RecordType extends Record<string, any>> {
106
109
  /**
107
110
  * Actions to be applied on a record in JavaScript.
108
111
  */
109
- recordActions?: Record<string, (record: T) => void>;
112
+ recordActions?: Record<string, (record: AsRecord<RecordType>) => void>;
110
113
  }
111
114
 
112
- 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: ({
114
- apply: (value: T, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
115
+ export declare interface TableRecord<RecordType extends Record<string, any>> {
116
+ record: RecordType;
117
+ default: (options: VisitOptions) => void;
118
+ actions: InlineAction[];
119
+ select: () => void;
120
+ deselect: () => void;
121
+ toggle: () => void;
122
+ selected: boolean;
123
+ bind: () => Record<string, any>;
124
+ value: (column: Column<RecordType> | string) => any;
125
+ extra: (column: Column<RecordType> | string) => any;
126
+ }
127
+
128
+ export declare function useTable<Props extends object, Key extends Props[keyof Props] extends Refine ? keyof Props : never, RecordType extends Record<string, any> = any, Paginator extends PaginatorKind = "length-aware">(props: Props, key: Key, tableOptions?: TableOptions<RecordType>, defaultOptions?: VisitOptions): {
129
+ filters: {
130
+ apply: (value: Props, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
115
131
  clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
116
132
  bind: () => {
117
133
  "onUpdate:modelValue": PromisifyFn<(value: any) => void>;
118
134
  modelValue: unknown;
119
- value: unknown;
120
135
  } | undefined;
121
136
  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
137
  multiple: boolean;
137
138
  options: Option_2[];
138
139
  value: FilterValue;
@@ -140,35 +141,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
140
141
  label: string;
141
142
  active: boolean;
142
143
  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
- })[];
144
+ }[];
172
145
  sorts: {
173
146
  apply: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
174
147
  clear: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
@@ -179,7 +152,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
179
152
  direction: Direction;
180
153
  next: string | null;
181
154
  name: string;
182
- label: string; /** The actions available for the record */
155
+ label: string;
183
156
  active: boolean;
184
157
  meta: Record<string, any>;
185
158
  }[];
@@ -189,61 +162,57 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
189
162
  bind: () => {
190
163
  "onUpdate:modelValue": PromisifyFn<(value: any) => void>;
191
164
  modelValue: boolean;
192
- value: boolean;
193
- } | undefined; /** Deselects this record */
165
+ } | undefined;
194
166
  name: string;
195
167
  label: string;
196
168
  type: string;
197
169
  active: boolean;
198
170
  meta: Record<string, any>;
199
171
  }[] | undefined;
200
- getFilter: (name: string) => (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner) | undefined;
172
+ getFilter: (name: string) => Filter | undefined;
201
173
  getSort: (name: string, direction?: Direction | undefined) => Sort | undefined;
202
174
  getSearch: (name: string) => Search | undefined;
203
- currentFilters: () => FilterRefiner[];
175
+ currentFilters: () => Filter[];
204
176
  currentSort: () => Sort | undefined;
205
177
  currentSearches: () => Search[];
206
- isFiltering: (name?: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner) | undefined) => boolean;
178
+ isFiltering: (name?: string | Filter | undefined) => boolean;
207
179
  isSorting: (name?: string | Sort | undefined) => boolean;
208
180
  isSearching: (name?: string | Search | undefined) => boolean;
209
181
  apply: (values: Record<string, any>, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
210
- applyFilter: (filter: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner), value: any, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
182
+ applyFilter: (filter: string | Filter, value: any, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
211
183
  applySort: (sort: string | Sort, direction?: Direction | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
212
184
  applySearch: (value: string | null | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
213
185
  applyMatch: (value: string | Search, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
214
- clearFilter: (filter: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner), options?: Partial<Visit & VisitCallbacks> | undefined) => void;
186
+ clearFilter: (filter: string | Filter, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
215
187
  clearSort: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
216
188
  clearSearch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
217
189
  clearMatch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
218
190
  reset: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
219
- bindFilter: <T_1 extends unknown>(filter: string | (SetFilterRefiner | FilterRefiner | DateFilterRefiner | BooleanFilterRefiner), options?: BindingOptions | undefined) => {
191
+ bindFilter: <T_1 extends unknown>(filter: string | Filter, options?: BindingOptions | undefined) => {
220
192
  "onUpdate:modelValue": PromisifyFn<(value: any) => void>;
221
193
  modelValue: T_1;
222
- value: T_1;
223
194
  } | undefined;
224
195
  bindSort: (sort: string | Sort, options?: BindingOptions | undefined) => {
225
196
  onClick: PromisifyFn<() => void>;
226
197
  } | undefined;
227
198
  bindSearch: (options?: BindingOptions | undefined) => {
228
- "onUpdate:modelValue": PromisifyFn<(value: any) => void>;
199
+ "onUpdate:modelValue": PromisifyFn<(value: string | null | undefined) => void>;
229
200
  modelValue: string;
230
- value: string;
231
201
  };
232
202
  bindMatch: (match: string | Search, options?: BindingOptions | undefined) => {
233
203
  "onUpdate:modelValue": PromisifyFn<(value: any) => void>;
234
204
  modelValue: boolean;
235
- value: boolean;
236
205
  } | undefined;
237
206
  stringValue: (value: any) => any;
238
207
  omitValue: (value: any) => any;
239
208
  toggleValue: (value: any, values: any) => any;
240
209
  delimitArray: (value: any) => any;
241
- getRecordKey: (record: U) => Identifier;
210
+ getRecordKey: (record: AsRecord<RecordType>) => Identifier;
242
211
  meta: Record<string, any>;
243
212
  headings: {
244
213
  isSorting: boolean | undefined;
245
214
  toggleSort: (options?: VisitOptions) => void;
246
- name: keyof U;
215
+ name: keyof RecordType;
247
216
  label: string;
248
217
  type: string;
249
218
  hidden: boolean;
@@ -251,7 +220,6 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
251
220
  toggleable: boolean;
252
221
  icon?: string | undefined;
253
222
  class?: string | undefined;
254
- meta?: Record<string, any> | undefined;
255
223
  sort?: {
256
224
  active: boolean;
257
225
  direction: Direction;
@@ -260,7 +228,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
260
228
  }[];
261
229
  columns: {
262
230
  toggle: (options?: VisitOptions) => void;
263
- name: keyof U;
231
+ name: keyof RecordType;
264
232
  label: string;
265
233
  type: string;
266
234
  hidden: boolean;
@@ -268,18 +236,32 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
268
236
  toggleable: boolean;
269
237
  icon?: string | undefined;
270
238
  class?: string | undefined;
271
- meta?: Record<string, any> | undefined;
272
239
  sort?: {
273
240
  active: boolean;
274
241
  direction: Direction;
275
242
  next: string | null;
276
243
  } | undefined;
277
244
  }[];
278
- records: (U & {
245
+ records: {
246
+ record: Omit<AsRecord<RecordType> & {
247
+ actions: InlineAction[];
248
+ }, "actions">;
279
249
  /** Perform this action when the record is clicked */
280
250
  default: (options?: VisitOptions) => void;
281
251
  /** The actions available for the record */
282
- actions: any;
252
+ actions: {
253
+ /** Executes this action */
254
+ execute: (options?: VisitOptions) => void;
255
+ type: "inline";
256
+ default: boolean;
257
+ name: string;
258
+ label: string;
259
+ icon?: string | undefined;
260
+ extra?: Record<string, unknown> | undefined;
261
+ action?: boolean | undefined;
262
+ confirm?: Confirm | undefined;
263
+ route?: Route | undefined;
264
+ }[];
283
265
  /** Selects this record */
284
266
  select: () => void;
285
267
  /** Deselects this record */
@@ -290,14 +272,15 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
290
272
  selected: boolean;
291
273
  /** Bind the record to a checkbox */
292
274
  bind: () => {
293
- /**
294
- * Actions to be applied on a record in JavaScript.
295
- */
296
275
  "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
297
276
  modelValue: boolean;
298
- value: any;
277
+ value: Identifier;
299
278
  };
300
- })[];
279
+ /** Get the value of the record for the column */
280
+ value: (column: Column<RecordType> | string) => RecordType[string] | RecordType[number] | RecordType[symbol];
281
+ /** Get the extra data of the record for the column */
282
+ extra: (column: Column<RecordType> | string) => Record<string, any>;
283
+ }[];
301
284
  bulkActions: {
302
285
  /** Executes this bulk action */
303
286
  execute: (options?: VisitOptions) => void;
@@ -305,9 +288,9 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
305
288
  keepSelected: boolean;
306
289
  name: string;
307
290
  label: string;
308
- action?: boolean | undefined;
309
- extra?: Record<string, unknown> | undefined;
310
291
  icon?: string | undefined;
292
+ extra?: Record<string, unknown> | undefined;
293
+ action?: boolean | undefined;
311
294
  confirm?: Confirm | undefined;
312
295
  route?: Route | undefined;
313
296
  }[];
@@ -317,9 +300,9 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
317
300
  type: "page";
318
301
  name: string;
319
302
  label: string;
320
- action?: boolean | undefined;
321
- extra?: Record<string, unknown> | undefined;
322
303
  icon?: string | undefined;
304
+ extra?: Record<string, unknown> | undefined;
305
+ action?: boolean | undefined;
323
306
  confirm?: Confirm | undefined;
324
307
  route?: Route | undefined;
325
308
  }[];
@@ -330,7 +313,7 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
330
313
  active: boolean;
331
314
  }[];
332
315
  currentPage: PerPageRecord | undefined;
333
- paginator: (V extends "length-aware" ? LengthAwarePaginator : V extends "simple" ? SimplePaginator : V extends "cursor" ? CursorPaginator : CollectionPaginator) & {
316
+ paginator: (Paginator extends "length-aware" ? LengthAwarePaginator : Paginator extends "simple" ? SimplePaginator : Paginator extends "cursor" ? CursorPaginator : CollectionPaginator) & {
334
317
  links?: {
335
318
  navigate: (options?: VisitOptions) => void | "" | null;
336
319
  url: string | null;
@@ -342,28 +325,25 @@ export declare function useTable<T extends object, K extends T[keyof T] extends
342
325
  first: (options?: VisitOptions) => void;
343
326
  last: (options?: VisitOptions) => void;
344
327
  };
345
- executeInlineAction: (action: InlineAction, record: U, options?: VisitOptions) => void;
328
+ executeInlineAction: (action: InlineAction, record: AsRecord<RecordType>, options?: VisitOptions) => void;
346
329
  executeBulkAction: (action: BulkAction, options?: VisitOptions) => void;
347
330
  executePageAction: (action: PageAction, options?: VisitOptions) => void;
348
331
  applyPage: (page: PerPageRecord, options?: VisitOptions) => void;
349
- selection: BulkSelection<any>;
350
- select: (record: U) => void;
351
- deselect: (record: U) => void;
332
+ selection: BulkSelection<Identifier>;
333
+ select: (record: AsRecord<RecordType>) => void;
334
+ deselect: (record: AsRecord<RecordType>) => void;
352
335
  selectPage: () => void;
353
336
  deselectPage: () => void;
354
- toggle: (record: U) => void;
355
- selected: (record: U) => boolean;
337
+ toggle: (record: AsRecord<RecordType>) => void;
338
+ selected: (record: AsRecord<RecordType>) => boolean;
356
339
  selectAll: () => void;
357
340
  deselectAll: () => void;
358
341
  isPageSelected: boolean;
359
342
  hasSelected: boolean;
360
- bindCheckbox: (record: U) => {
361
- /**
362
- * Actions to be applied on a record in JavaScript.
363
- */
343
+ bindCheckbox: (record: AsRecord<RecordType>) => {
364
344
  "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
365
345
  modelValue: boolean;
366
- value: any;
346
+ value: Identifier;
367
347
  };
368
348
  bindPage: () => {
369
349
  "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ref as _, computed as h, toValue as N, reactive as Q } from "vue";
1
+ import { ref as _, computed as h, toValue as J, reactive as Q } from "vue";
2
2
  import { router as S } from "@inertiajs/vue3";
3
3
  function X() {
4
4
  const o = _({
@@ -6,22 +6,22 @@ function X() {
6
6
  only: /* @__PURE__ */ new Set(),
7
7
  except: /* @__PURE__ */ new Set()
8
8
  });
9
- function f() {
9
+ function m() {
10
10
  o.value.all = !0, o.value.only.clear(), o.value.except.clear();
11
11
  }
12
12
  function v() {
13
13
  o.value.all = !1, o.value.only.clear(), o.value.except.clear();
14
14
  }
15
15
  function l(...s) {
16
- s.forEach((m) => o.value.except.delete(m)), s.forEach((m) => o.value.only.add(m));
16
+ s.forEach((p) => o.value.except.delete(p)), s.forEach((p) => o.value.only.add(p));
17
17
  }
18
18
  function i(...s) {
19
- s.forEach((m) => o.value.except.add(m)), s.forEach((m) => o.value.only.delete(m));
19
+ s.forEach((p) => o.value.except.add(p)), s.forEach((p) => o.value.only.delete(p));
20
20
  }
21
- function u(s, m) {
22
- if (b(s) || m === !1)
21
+ function u(s, p) {
22
+ if (b(s) || p === !1)
23
23
  return i(s);
24
- if (!b(s) || m === !0)
24
+ if (!b(s) || p === !0)
25
25
  return l(s);
26
26
  }
27
27
  function b(s) {
@@ -30,8 +30,8 @@ function X() {
30
30
  const d = h(() => o.value.all && o.value.except.size === 0), A = h(() => o.value.only.size > 0 || d.value);
31
31
  function x(s) {
32
32
  return {
33
- "onUpdate:modelValue": (m) => {
34
- m ? l(s) : i(s);
33
+ "onUpdate:modelValue": (p) => {
34
+ p ? l(s) : i(s);
35
35
  },
36
36
  modelValue: b(s),
37
37
  value: s
@@ -40,7 +40,7 @@ function X() {
40
40
  function k() {
41
41
  return {
42
42
  "onUpdate:modelValue": (s) => {
43
- s ? f() : v();
43
+ s ? m() : v();
44
44
  },
45
45
  modelValue: d.value,
46
46
  value: d.value
@@ -50,7 +50,7 @@ function X() {
50
50
  allSelected: d,
51
51
  selection: o,
52
52
  hasSelected: A,
53
- selectAll: f,
53
+ selectAll: m,
54
54
  deselectAll: v,
55
55
  select: l,
56
56
  deselect: i,
@@ -60,12 +60,12 @@ function X() {
60
60
  bindAll: k
61
61
  };
62
62
  }
63
- function J(o, f, v = {}, l = {}) {
63
+ function I(o, m, v = {}, l = {}) {
64
64
  return o.route ? (S.visit(o.route.href, {
65
65
  ...l,
66
66
  method: o.route.method
67
- }), !0) : o.action && f ? (S.post(
68
- f,
67
+ }), !0) : o.action && m ? (S.post(
68
+ m,
69
69
  {
70
70
  ...v,
71
71
  name: o.name,
@@ -77,24 +77,24 @@ function J(o, f, v = {}, l = {}) {
77
77
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
78
78
  const Y = () => {
79
79
  };
80
- function Z(o, f) {
80
+ function Z(o, m) {
81
81
  function v(...l) {
82
82
  return new Promise((i, u) => {
83
- Promise.resolve(o(() => f.apply(this, l), { fn: f, thisArg: this, args: l })).then(i).catch(u);
83
+ Promise.resolve(o(() => m.apply(this, l), { fn: m, thisArg: this, args: l })).then(i).catch(u);
84
84
  });
85
85
  }
86
86
  return v;
87
87
  }
88
- function O(o, f = {}) {
88
+ function O(o, m = {}) {
89
89
  let v, l, i = Y;
90
90
  const u = (d) => {
91
91
  clearTimeout(d), i(), i = Y;
92
92
  };
93
93
  let b;
94
94
  return (d) => {
95
- const A = N(o), x = N(f.maxWait);
95
+ const A = J(o), x = J(m.maxWait);
96
96
  return v && u(v), A <= 0 || x !== void 0 && x <= 0 ? (l && (u(l), l = null), Promise.resolve(d())) : new Promise((k, s) => {
97
- i = f.rejectOnCancel ? s : k, b = d, x && !l && (l = setTimeout(() => {
97
+ i = m.rejectOnCancel ? s : k, b = d, x && !l && (l = setTimeout(() => {
98
98
  v && u(v), l = null, k(b());
99
99
  }, x)), v = setTimeout(() => {
100
100
  l && u(l), l = null, k(d());
@@ -102,21 +102,21 @@ function O(o, f = {}) {
102
102
  });
103
103
  };
104
104
  }
105
- function D(o, f = 200, v = {}) {
105
+ function q(o, m = 200, v = {}) {
106
106
  return Z(
107
- O(f, v),
107
+ O(m, v),
108
108
  o
109
109
  );
110
110
  }
111
- function ee(o, f, v = {}) {
112
- const l = h(() => o[f]), i = h(
111
+ function ee(o, m, v = {}) {
112
+ const l = h(() => o[m]), i = h(
113
113
  () => {
114
114
  var e;
115
115
  return ((e = l.value.filters) == null ? void 0 : e.map((n) => ({
116
116
  ...n,
117
- apply: (a, c = {}) => F(n, a, c),
118
- clear: (a = {}) => G(n, a),
119
- bind: () => g(n.name)
117
+ apply: (r, c = {}) => L(n, r, c),
118
+ clear: (r = {}) => N(n, r),
119
+ bind: () => a(n.name)
120
120
  }))) ?? [];
121
121
  }
122
122
  ), u = h(
@@ -124,9 +124,9 @@ function ee(o, f, v = {}) {
124
124
  var e;
125
125
  return ((e = l.value.sorts) == null ? void 0 : e.map((n) => ({
126
126
  ...n,
127
- apply: (a = {}) => M(n, n.direction, a),
128
- clear: (a = {}) => B(a),
129
- bind: () => P(n)
127
+ apply: (r = {}) => M(n, n.direction, r),
128
+ clear: (r = {}) => W(r),
129
+ bind: () => f(n)
130
130
  }))) ?? [];
131
131
  }
132
132
  ), b = h(
@@ -134,9 +134,9 @@ 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 = {}) => $(n, a),
138
- clear: (a = {}) => $(n, a),
139
- bind: () => K(n)
137
+ apply: (r = {}) => U(n, r),
138
+ clear: (r = {}) => U(n, r),
139
+ bind: () => F(n)
140
140
  }));
141
141
  }
142
142
  );
@@ -152,91 +152,91 @@ function ee(o, f, v = {}) {
152
152
  }
153
153
  function k(e) {
154
154
  return [d, A, x].reduce(
155
- (n, a) => a(n),
155
+ (n, r) => r(n),
156
156
  e
157
157
  );
158
158
  }
159
159
  function s(e, n) {
160
- return n = Array.isArray(n) ? n : [n], n.includes(e) ? n.filter((a) => a !== e) : [...n, e];
160
+ return n = Array.isArray(n) ? n : [n], n.includes(e) ? n.filter((r) => r !== e) : [...n, e];
161
161
  }
162
- function m(e) {
162
+ function p(e) {
163
163
  var n;
164
- return (n = l.value.filters) == null ? void 0 : n.find((a) => a.name === e);
164
+ return (n = l.value.filters) == null ? void 0 : n.find((r) => r.name === e);
165
165
  }
166
- function U(e, n = null) {
167
- var a;
168
- return (a = l.value.sorts) == null ? void 0 : a.find(
166
+ function j(e, n = null) {
167
+ var r;
168
+ return (r = l.value.sorts) == null ? void 0 : r.find(
169
169
  (c) => c.name === e && c.direction === n
170
170
  );
171
171
  }
172
172
  function C(e) {
173
173
  var n;
174
- return (n = l.value.searches) == null ? void 0 : n.find((a) => a.name === e);
174
+ return (n = l.value.searches) == null ? void 0 : n.find((r) => r.name === e);
175
175
  }
176
- function W() {
176
+ function z() {
177
177
  var e;
178
178
  return ((e = l.value.filters) == null ? void 0 : e.filter(({ active: n }) => n)) ?? [];
179
179
  }
180
- function p() {
180
+ function g() {
181
181
  var e;
182
182
  return (e = l.value.sorts) == null ? void 0 : e.find(({ active: n }) => n);
183
183
  }
184
- function V() {
184
+ function w() {
185
185
  var e;
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" ? W().some((n) => n.name === e) : e.active : !!W().length;
189
+ return e ? typeof e == "string" ? z().some((n) => n.name === e) : e.active : !!z().length;
190
190
  }
191
- function w(e) {
191
+ function K(e) {
192
192
  var n;
193
- return e ? typeof e == "string" ? ((n = p()) == null ? void 0 : n.name) === e : e.active : !!p();
193
+ return e ? typeof e == "string" ? ((n = g()) == null ? void 0 : n.name) === e : e.active : !!g();
194
194
  }
195
- function L(e) {
196
- var n, a;
197
- return e ? typeof e == "string" ? (a = V()) == null ? void 0 : a.some((c) => c.name === e) : e.active : !!((n = V()) != null && n.length);
195
+ function P(e) {
196
+ var n, r;
197
+ return e ? typeof e == "string" ? (r = w()) == null ? void 0 : r.some((c) => c.name === e) : e.active : !!((n = w()) != null && n.length);
198
198
  }
199
- function q(e, n = {}) {
200
- const a = Object.fromEntries(
199
+ function G(e, n = {}) {
200
+ const r = Object.fromEntries(
201
201
  Object.entries(e).map(([c, E]) => [c, k(E)])
202
202
  );
203
203
  S.reload({
204
204
  ...v,
205
205
  ...n,
206
- data: a
206
+ data: r
207
207
  });
208
208
  }
209
- function F(e, n, a = {}) {
210
- const c = typeof e == "string" ? m(e) : e;
209
+ function L(e, n, r = {}) {
210
+ const c = typeof e == "string" ? p(e) : e;
211
211
  if (!c) {
212
212
  console.warn(`Filter [${e}] does not exist.`);
213
213
  return;
214
214
  }
215
215
  "multiple" in c && c.multiple && (n = s(n, c.value)), S.reload({
216
216
  ...v,
217
- ...a,
217
+ ...r,
218
218
  data: {
219
219
  [c.name]: k(n)
220
220
  }
221
221
  });
222
222
  }
223
- function M(e, n = null, a = {}) {
224
- const c = typeof e == "string" ? U(e, n) : e;
223
+ function M(e, n = null, r = {}) {
224
+ const c = typeof e == "string" ? j(e, n) : e;
225
225
  if (!c) {
226
226
  console.warn(`Sort [${e}] does not exist.`);
227
227
  return;
228
228
  }
229
229
  S.reload({
230
230
  ...v,
231
- ...a,
231
+ ...r,
232
232
  data: {
233
233
  [l.value.config.sorts]: x(c.next)
234
234
  }
235
235
  });
236
236
  }
237
- function z(e, n = {}) {
237
+ function T(e, n = {}) {
238
238
  e = [A, x].reduce(
239
- (a, c) => c(a),
239
+ (r, c) => c(r),
240
240
  e
241
241
  ), S.reload({
242
242
  ...v,
@@ -246,7 +246,7 @@ function ee(o, f, v = {}) {
246
246
  }
247
247
  });
248
248
  }
249
- function $(e, n = {}) {
249
+ function U(e, n = {}) {
250
250
  if (!l.value.config.matches) {
251
251
  console.warn("Matches key is not set.");
252
252
  return;
@@ -255,22 +255,22 @@ function ee(o, f, v = {}) {
255
255
  console.warn(`Match [${e}] does not exist.`);
256
256
  return;
257
257
  }
258
- const a = s(
258
+ const r = s(
259
259
  e,
260
- V().filter(({ active: c }) => c).map(({ name: c }) => c)
260
+ w().filter(({ active: c }) => c).map(({ name: c }) => c)
261
261
  );
262
262
  S.reload({
263
263
  ...v,
264
264
  ...n,
265
265
  data: {
266
- [l.value.config.matches]: d(a)
266
+ [l.value.config.matches]: d(r)
267
267
  }
268
268
  });
269
269
  }
270
- function G(e, n = {}) {
271
- F(e, void 0, n);
270
+ function N(e, n = {}) {
271
+ L(e, void 0, n);
272
272
  }
273
- function B(e = {}) {
273
+ function W(e = {}) {
274
274
  S.reload({
275
275
  ...v,
276
276
  ...e,
@@ -279,10 +279,10 @@ function ee(o, f, v = {}) {
279
279
  }
280
280
  });
281
281
  }
282
- function H(e = {}) {
283
- z(void 0, e);
282
+ function R(e = {}) {
283
+ T(void 0, e);
284
284
  }
285
- function t(e = {}) {
285
+ function D(e = {}) {
286
286
  if (!l.value.config.matches) {
287
287
  console.warn("Matches key is not set.");
288
288
  return;
@@ -295,7 +295,7 @@ function ee(o, f, v = {}) {
295
295
  }
296
296
  });
297
297
  }
298
- function r(e = {}) {
298
+ function t(e = {}) {
299
299
  var n;
300
300
  S.reload({
301
301
  ...v,
@@ -304,8 +304,8 @@ function ee(o, f, v = {}) {
304
304
  [l.value.config.searches]: void 0,
305
305
  [l.value.config.sorts]: void 0,
306
306
  ...Object.fromEntries(
307
- ((n = l.value.filters) == null ? void 0 : n.map((a) => [
308
- a.name,
307
+ ((n = l.value.filters) == null ? void 0 : n.map((r) => [
308
+ r.name,
309
309
  void 0
310
310
  ])) ?? []
311
311
  ),
@@ -313,137 +313,139 @@ function ee(o, f, v = {}) {
313
313
  }
314
314
  });
315
315
  }
316
- function g(e, n = {}) {
317
- const a = typeof e == "string" ? m(e) : e;
318
- if (!a) {
316
+ function a(e, n = {}) {
317
+ const r = typeof e == "string" ? p(e) : e;
318
+ if (!r) {
319
319
  console.warn(`Filter [${e}] does not exist.`);
320
320
  return;
321
321
  }
322
- const c = a.value, {
322
+ const c = r.value, {
323
323
  debounce: E = 250,
324
- transform: R = (I) => I,
325
- ...T
324
+ transform: B = (H) => H,
325
+ ...$
326
326
  } = n;
327
327
  return {
328
- "onUpdate:modelValue": D((I) => {
329
- F(a, R(I), T);
328
+ "onUpdate:modelValue": q((H) => {
329
+ L(r, B(H), $);
330
330
  }, E),
331
- modelValue: c,
332
- value: c
331
+ modelValue: c
333
332
  };
334
333
  }
335
- function P(e, n = {}) {
336
- const a = typeof e == "string" ? U(e) : e;
337
- if (!a) {
334
+ function f(e, n = {}) {
335
+ const r = typeof e == "string" ? j(e) : e;
336
+ if (!r) {
338
337
  console.warn(`Sort [${e}] does not exist.`);
339
338
  return;
340
339
  }
341
- const { debounce: c = 0, transform: E, ...R } = n;
340
+ const { debounce: c = 0, transform: E, ...B } = n;
342
341
  return {
343
- onClick: D(() => {
344
- var T;
345
- M(a, (T = p()) == null ? void 0 : T.direction, R);
342
+ onClick: q(() => {
343
+ var $;
344
+ M(r, ($ = g()) == null ? void 0 : $.direction, B);
346
345
  }, c)
347
346
  };
348
347
  }
349
- function j(e = {}) {
350
- const { debounce: n = 700, transform: a, ...c } = e;
348
+ function V(e = {}) {
349
+ const { debounce: n = 700, transform: r, ...c } = e;
351
350
  return {
352
- "onUpdate:modelValue": D((E) => {
353
- z(E, c);
354
- }, n),
355
- modelValue: l.value.config.search ?? "",
356
- value: l.value.config.search ?? ""
351
+ "onUpdate:modelValue": q(
352
+ (E) => {
353
+ T(E, c);
354
+ },
355
+ n
356
+ ),
357
+ modelValue: l.value.config.search ?? ""
357
358
  };
358
359
  }
359
- function K(e, n = {}) {
360
- const a = typeof e == "string" ? C(e) : e;
361
- if (!a) {
360
+ function F(e, n = {}) {
361
+ const r = typeof e == "string" ? C(e) : e;
362
+ if (!r) {
362
363
  console.warn(`Match [${e}] does not exist.`);
363
364
  return;
364
365
  }
365
- const { debounce: c = 0, transform: E, ...R } = n;
366
+ const { debounce: c = 0, transform: E, ...B } = n;
366
367
  return {
367
- "onUpdate:modelValue": D((T) => {
368
- $(T, R);
368
+ "onUpdate:modelValue": q(($) => {
369
+ U($, B);
369
370
  }, c),
370
- modelValue: L(a),
371
- value: L(a)
371
+ modelValue: P(r)
372
372
  };
373
373
  }
374
374
  return {
375
375
  filters: i,
376
376
  sorts: u,
377
377
  searches: b,
378
- getFilter: m,
379
- getSort: U,
378
+ getFilter: p,
379
+ getSort: j,
380
380
  getSearch: C,
381
- currentFilters: W,
382
- currentSort: p,
383
- currentSearches: V,
381
+ currentFilters: z,
382
+ currentSort: g,
383
+ currentSearches: w,
384
384
  isFiltering: y,
385
- isSorting: w,
386
- isSearching: L,
387
- apply: q,
388
- applyFilter: F,
385
+ isSorting: K,
386
+ isSearching: P,
387
+ apply: G,
388
+ applyFilter: L,
389
389
  applySort: M,
390
- applySearch: z,
391
- applyMatch: $,
392
- clearFilter: G,
393
- clearSort: B,
394
- clearSearch: H,
395
- clearMatch: t,
396
- reset: r,
397
- bindFilter: g,
398
- bindSort: P,
399
- bindSearch: j,
400
- bindMatch: K,
390
+ applySearch: T,
391
+ applyMatch: U,
392
+ clearFilter: N,
393
+ clearSort: W,
394
+ clearSearch: R,
395
+ clearMatch: D,
396
+ reset: t,
397
+ bindFilter: a,
398
+ bindSort: f,
399
+ bindSearch: V,
400
+ bindMatch: F,
401
401
  stringValue: A,
402
402
  omitValue: x,
403
403
  toggleValue: s,
404
404
  delimitArray: d
405
405
  };
406
406
  }
407
- function le(o, f, v = {}, l = {}) {
407
+ function le(o, m, v = {}, l = {}) {
408
+ if (!o || !m || !o[m])
409
+ throw new Error("Table has not been provided with valid props and key.");
408
410
  l = {
409
411
  ...l,
410
- only: [...l.only ?? [], f.toString()]
412
+ only: [...l.only ?? [], m.toString()]
411
413
  };
412
- const i = h(() => o[f]), u = X(), b = ee(o, f, l), d = h(() => i.value.config), A = h(() => i.value.meta), x = h(
414
+ const i = h(() => o[m]), u = X(), b = ee(o, m, l), d = h(() => i.value.config), A = h(() => i.value.meta), x = h(
413
415
  () => {
414
416
  var t;
415
- return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: r, hidden: g }) => r && !g).map((r) => {
416
- var g;
417
+ return ((t = i.value.columns) == null ? void 0 : t.filter(({ active: a, hidden: f }) => a && !f).map((a) => {
418
+ var f;
417
419
  return {
418
- ...r,
419
- isSorting: (g = r.sort) == null ? void 0 : g.active,
420
- toggleSort: (P = {}) => z(r, P)
420
+ ...a,
421
+ isSorting: (f = a.sort) == null ? void 0 : f.active,
422
+ toggleSort: (V = {}) => U(a, V)
421
423
  };
422
424
  })) ?? [];
423
425
  }
424
426
  ), k = h(
425
427
  () => {
426
428
  var t;
427
- return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: r }) => !r).map((r) => ({
428
- ...r,
429
- toggle: (g = {}) => $(r, g)
429
+ return ((t = i.value.columns) == null ? void 0 : t.filter(({ hidden: a }) => !a).map((a) => ({
430
+ ...a,
431
+ toggle: (f = {}) => N(a, f)
430
432
  }))) ?? [];
431
433
  }
432
434
  ), s = h(
433
435
  () => i.value.records.map((t) => ({
434
- ...t,
436
+ record: (({ actions: a, ...f }) => f)(t),
435
437
  /** Perform this action when the record is clicked */
436
- default: (r = {}) => {
437
- const g = t.actions.find(
438
- (P) => P.default
438
+ default: (a = {}) => {
439
+ const f = t.actions.find(
440
+ (V) => V.default
439
441
  );
440
- g && L(g, t, r);
442
+ f && G(f, t, a);
441
443
  },
442
444
  /** The actions available for the record */
443
- actions: t.actions.map((r) => ({
444
- ...r,
445
+ actions: t.actions.map((a) => ({
446
+ ...a,
445
447
  /** Executes this action */
446
- execute: (g = {}) => L(r, t, g)
448
+ execute: (f = {}) => G(a, t, f)
447
449
  })),
448
450
  /** Selects this record */
449
451
  select: () => u.select(y(t)),
@@ -454,79 +456,92 @@ function le(o, f, v = {}, l = {}) {
454
456
  /** Determine if the record is selected */
455
457
  selected: u.selected(y(t)),
456
458
  /** Bind the record to a checkbox */
457
- bind: () => u.bind(y(t))
459
+ bind: () => u.bind(y(t)),
460
+ /** Get the value of the record for the column */
461
+ value: (a) => t[K(a)].value,
462
+ /** Get the extra data of the record for the column */
463
+ extra: (a) => t[K(a)].extra
458
464
  }))
459
- ), m = h(
465
+ ), p = h(
460
466
  () => i.value.actions.bulk.map((t) => ({
461
467
  ...t,
462
468
  /** Executes this bulk action */
463
- execute: (r = {}) => q(t, r)
469
+ execute: (a = {}) => L(t, a)
464
470
  }))
465
- ), U = h(
471
+ ), j = h(
466
472
  () => i.value.actions.page.map((t) => ({
467
473
  ...t,
468
474
  /** Executes this page action */
469
- execute: (r = {}) => F(t, r)
475
+ execute: (a = {}) => M(t, a)
470
476
  }))
471
477
  ), C = h(
472
- () => i.value.recordsPerPage.map((t) => ({
473
- ...t,
474
- /** Changes the number of records to display per page */
475
- apply: (r = {}) => M(t, r)
476
- }))
477
- ), W = h(
478
- () => i.value.recordsPerPage.find(({ active: t }) => t)
479
- ), p = h(() => ({
478
+ () => {
479
+ var t;
480
+ return ((t = i.value.recordsPerPage) == null ? void 0 : t.map((a) => ({
481
+ ...a,
482
+ /** Changes the number of records to display per page */
483
+ apply: (f = {}) => T(a, f)
484
+ }))) ?? [];
485
+ }
486
+ ), z = h(
487
+ () => {
488
+ var t;
489
+ return (t = i.value.recordsPerPage) == null ? void 0 : t.find(({ active: a }) => a);
490
+ }
491
+ ), g = h(() => ({
480
492
  ...i.value.paginator,
481
493
  next: (t = {}) => {
482
- "nextLink" in p.value && p.value.nextLink && w(p.value.nextLink, t);
494
+ "nextLink" in g.value && g.value.nextLink && P(g.value.nextLink, t);
483
495
  },
484
496
  previous: (t = {}) => {
485
- "prevLink" in p.value && p.value.prevLink && w(p.value.prevLink, t);
497
+ "prevLink" in g.value && g.value.prevLink && P(g.value.prevLink, t);
486
498
  },
487
499
  first: (t = {}) => {
488
- "firstLink" in p.value && p.value.firstLink && w(p.value.firstLink, t);
500
+ "firstLink" in g.value && g.value.firstLink && P(g.value.firstLink, t);
489
501
  },
490
502
  last: (t = {}) => {
491
- "lastLink" in p.value && p.value.lastLink && w(p.value.lastLink, t);
503
+ "lastLink" in g.value && g.value.lastLink && P(g.value.lastLink, t);
492
504
  },
493
505
  ..."links" in i.value.paginator && i.value.paginator.links ? {
494
506
  links: i.value.paginator.links.map((t) => ({
495
507
  ...t,
496
- navigate: (r = {}) => t.url && w(t.url, r)
508
+ navigate: (a = {}) => t.url && P(t.url, a)
497
509
  }))
498
510
  } : {}
499
- })), V = h(
511
+ })), w = h(
500
512
  () => i.value.records.length > 0 && i.value.records.every(
501
513
  (t) => u.selected(y(t))
502
514
  )
503
515
  );
504
516
  function y(t) {
505
- return t[d.value.record];
517
+ return t[d.value.record].value;
506
518
  }
507
- function w(t, r = {}) {
519
+ function K(t) {
520
+ return typeof t == "string" ? t : t.name;
521
+ }
522
+ function P(t, a = {}) {
508
523
  S.visit(t, {
509
524
  preserveScroll: !0,
510
525
  preserveState: !0,
511
526
  ...l,
512
- ...r,
527
+ ...a,
513
528
  method: "get"
514
529
  });
515
530
  }
516
- function L(t, r, g = {}) {
517
- var j, K;
518
- J(
531
+ function G(t, a, f = {}) {
532
+ var F, e;
533
+ I(
519
534
  t,
520
535
  d.value.endpoint,
521
536
  {
522
537
  table: i.value.id,
523
- id: y(r)
538
+ id: y(a)
524
539
  },
525
- g
526
- ) || (K = (j = v.recordActions) == null ? void 0 : j[t.name]) == null || K.call(j, r);
540
+ f
541
+ ) || (e = (F = v.recordActions) == null ? void 0 : F[t.name]) == null || e.call(F, a);
527
542
  }
528
- function q(t, r = {}) {
529
- J(
543
+ function L(t, a = {}) {
544
+ I(
530
545
  t,
531
546
  d.value.endpoint,
532
547
  {
@@ -535,67 +550,71 @@ function le(o, f, v = {}, l = {}) {
535
550
  only: Array.from(u.selection.value.only),
536
551
  except: Array.from(u.selection.value.except)
537
552
  },
538
- r
553
+ a
539
554
  );
540
555
  }
541
- function F(t, r = {}) {
542
- J(
556
+ function M(t, a = {}) {
557
+ I(
543
558
  t,
544
559
  d.value.endpoint,
545
560
  {
546
561
  table: i.value.id
547
562
  },
548
- r
563
+ a
549
564
  );
550
565
  }
551
- function M(t, r = {}) {
566
+ function T(t, a = {}) {
552
567
  S.reload({
553
568
  ...l,
554
- ...r,
569
+ ...a,
555
570
  data: {
556
571
  [d.value.records]: t.value,
557
572
  [d.value.pages]: void 0
558
573
  }
559
574
  });
560
575
  }
561
- function z(t, r = {}) {
576
+ function U(t, a = {}) {
562
577
  t.sort && S.reload({
563
578
  ...l,
564
- ...r,
579
+ ...a,
565
580
  data: {
566
581
  [d.value.sorts]: b.omitValue(t.sort.next)
567
582
  }
568
583
  });
569
584
  }
570
- function $(t, r = {}) {
571
- const g = b.toggleValue(
585
+ function N(t, a = {}) {
586
+ const f = b.toggleValue(
572
587
  t.name,
573
- x.value.map(({ name: P }) => P)
588
+ x.value.map(({ name: V }) => V)
574
589
  );
575
590
  S.reload({
576
591
  ...l,
577
- ...r,
592
+ ...a,
578
593
  data: {
579
- [d.value.columns]: b.delimitArray(g)
594
+ [d.value.columns]: b.delimitArray(f)
580
595
  }
581
596
  });
582
597
  }
583
- function G() {
598
+ function W() {
584
599
  u.select(
585
- ...i.value.records.map((t) => y(t))
600
+ ...i.value.records.map(
601
+ (t) => y(t)
602
+ )
586
603
  );
587
604
  }
588
- function B() {
605
+ function R() {
589
606
  u.deselect(
590
- ...i.value.records.map((t) => y(t))
607
+ ...i.value.records.map(
608
+ (t) => y(t)
609
+ )
591
610
  );
592
611
  }
593
- function H() {
612
+ function D() {
594
613
  return {
595
614
  "onUpdate:modelValue": (t) => {
596
- t ? G() : B();
615
+ t ? W() : R();
597
616
  },
598
- modelValue: V.value
617
+ modelValue: w.value
599
618
  };
600
619
  }
601
620
  return Q({
@@ -610,23 +629,23 @@ function le(o, f, v = {}, l = {}) {
610
629
  /** The records of the table */
611
630
  records: s,
612
631
  /** The available bulk actions */
613
- bulkActions: m,
632
+ bulkActions: p,
614
633
  /** The available page actions */
615
- pageActions: U,
634
+ pageActions: j,
616
635
  /** The available number of records to display per page */
617
636
  rowsPerPage: C,
618
637
  /** The current record per page item */
619
- currentPage: W,
638
+ currentPage: z,
620
639
  /** The pagination metadata */
621
- paginator: p,
640
+ paginator: g,
622
641
  /** Execute an inline action */
623
- executeInlineAction: L,
642
+ executeInlineAction: G,
624
643
  /** Execute a bulk action */
625
- executeBulkAction: q,
644
+ executeBulkAction: L,
626
645
  /** Execute a page action */
627
- executePageAction: F,
646
+ executePageAction: M,
628
647
  /** Apply a new page by changing the number of records to display */
629
- applyPage: M,
648
+ applyPage: T,
630
649
  /** The current selection of records */
631
650
  selection: u.selection,
632
651
  /** Select the given records */
@@ -634,9 +653,9 @@ function le(o, f, v = {}, l = {}) {
634
653
  /** Deselect the given records */
635
654
  deselect: (t) => u.deselect(y(t)),
636
655
  /** Select records on the current page */
637
- selectPage: G,
656
+ selectPage: W,
638
657
  /** Deselect records on the current page */
639
- deselectPage: B,
658
+ deselectPage: R,
640
659
  /** Toggle the selection of the given records */
641
660
  toggle: (t) => u.toggle(y(t)),
642
661
  /** Determine if the given record is selected */
@@ -646,13 +665,13 @@ function le(o, f, v = {}, l = {}) {
646
665
  /** Deselect all records */
647
666
  deselectAll: u.deselectAll,
648
667
  /** Whether all records on the current page are selected */
649
- isPageSelected: V,
668
+ isPageSelected: w,
650
669
  /** Determine if any records are selected */
651
670
  hasSelected: u.hasSelected,
652
671
  /** Bind the given record to a checkbox */
653
672
  bindCheckbox: (t) => u.bind(y(t)),
654
673
  /** Bind the select all checkbox to the current page */
655
- bindPage: H,
674
+ bindPage: D,
656
675
  /** Bind select all records to the checkbox */
657
676
  bindAll: u.bindAll,
658
677
  /** Include the sorts, filters, and search query */
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 r=d.ref({all:!1,only:new Set,except:new Set});function p(){r.value.all=!0,r.value.only.clear(),r.value.except.clear()}function f(){r.value.all=!1,r.value.only.clear(),r.value.except.clear()}function l(...s){s.forEach(m=>r.value.except.delete(m)),s.forEach(m=>r.value.only.add(m))}function i(...s){s.forEach(m=>r.value.except.add(m)),s.forEach(m=>r.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 r.value.all?!r.value.except.has(s):r.value.only.has(s)}const v=d.computed(()=>r.value.all&&r.value.except.size===0),A=d.computed(()=>r.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:r,hasSelected:A,selectAll:p,deselectAll:f,select:l,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function H(r,p,f={},l={}){return r.route?(b.router.visit(r.route.href,{...l,method:r.route.method}),!0):r.action&&p?(b.router.post(p,{...f,name:r.name,type:r.type},l),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(r,p){function f(...l){return new Promise((i,u)=>{Promise.resolve(r(()=>p.apply(this,l),{fn:p,thisArg:this,args:l})).then(i).catch(u)})}return f}function X(r,p={}){let f,l,i=Y;const u=v=>{clearTimeout(v),i(),i=Y};let x;return v=>{const A=d.toValue(r),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(r,p=200,f={}){return Q(X(p,f),r)}function Z(r,p,f={}){const l=d.computed(()=>r[p]),i=d.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(o,c={})=>T(n,o,c),clear:(o={})=>G(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 W(e){var n;return(n=l.value.searches)==null?void 0:n.find(o=>o.name===e)}function q(){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"?q().some(n=>n.name===e):e.active:!!q().length}function L(e){var n;return e?typeof e=="string"?((n=g())==null?void 0:n.name)===e:e.active:!!g()}function j(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,F])=>[c,k(F)]));b.router.reload({...f,...n,data:o})}function T(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 z(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"?W(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 G(e,n={}){T(e,void 0,n)}function B(e={}){b.router.reload({...f,...e,data:{[l.value.config.sorts]:null}})}function J(e={}){z(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 a(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:F=250,transform:K=N=>N,...U}=n;return{"onUpdate:modelValue":R(N=>{T(o,K(N),U)},F),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:F,...K}=n;return{onClick:R(()=>{var U;M(o,(U=g())==null?void 0:U.direction,K)},c)}}function $(e={}){const{debounce:n=700,transform:o,...c}=e;return{"onUpdate:modelValue":R(F=>{z(F,c)},n),modelValue:l.value.config.search??"",value:l.value.config.search??""}}function I(e,n={}){const o=typeof e=="string"?W(e):e;if(!o){console.warn(`Match [${e}] does not exist.`);return}const{debounce:c=0,transform:F,...K}=n;return{"onUpdate:modelValue":R(U=>{E(U,K)},c),modelValue:j(o),value:j(o)}}return{filters:i,sorts:u,searches:x,getFilter:m,getSort:C,getSearch:W,currentFilters:q,currentSort:g,currentSearches:w,isFiltering:y,isSorting:L,isSearching:j,apply:D,applyFilter:T,applySort:M,applySearch:z,applyMatch:E,clearFilter:G,clearSort:B,clearSearch:J,clearMatch:t,reset:a,bindFilter:h,bindSort:V,bindSearch:$,bindMatch:I,stringValue:A,omitValue:S,toggleValue:s,delimitArray:v}}function O(r,p,f={},l={}){l={...l,only:[...l.only??[],p.toString()]};const i=d.computed(()=>r[p]),u=_(),x=Z(r,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:a,hidden:h})=>a&&!h).map(a=>{var h;return{...a,isSorting:(h=a.sort)==null?void 0:h.active,toggleSort:(V={})=>z(a,V)}}))??[]}),k=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:a})=>!a).map(a=>({...a,toggle:(h={})=>E(a,h)})))??[]}),s=d.computed(()=>i.value.records.map(t=>({...t,default:(a={})=>{const h=t.actions.find(V=>V.default);h&&j(h,t,a)},actions:t.actions.map(a=>({...a,execute:(h={})=>j(a,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:(a={})=>D(t,a)}))),C=d.computed(()=>i.value.actions.page.map(t=>({...t,execute:(a={})=>T(t,a)}))),W=d.computed(()=>i.value.recordsPerPage.map(t=>({...t,apply:(a={})=>M(t,a)}))),q=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:(a={})=>t.url&&L(t.url,a)}))}:{}})),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,a={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...a,method:"get"})}function j(t,a,h={}){var $,I;H(t,v.value.endpoint,{table:i.value.id,id:y(a)},h)||(I=($=f.recordActions)==null?void 0:$[t.name])==null||I.call($,a)}function D(t,a={}){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)},a)}function T(t,a={}){H(t,v.value.endpoint,{table:i.value.id},a)}function M(t,a={}){b.router.reload({...l,...a,data:{[v.value.records]:t.value,[v.value.pages]:void 0}})}function z(t,a={}){t.sort&&b.router.reload({...l,...a,data:{[v.value.sorts]:x.omitValue(t.sort.next)}})}function E(t,a={}){const h=x.toggleValue(t.name,S.value.map(({name:V})=>V));b.router.reload({...l,...a,data:{[v.value.columns]:x.delimitArray(h)}})}function G(){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?G():B()},modelValue:w.value}}return d.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:m,pageActions:C,rowsPerPage:W,currentPage:q,paginator:g,executeInlineAction:j,executeBulkAction:D,executePageAction:T,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:G,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"})});
1
+ (function(V,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):(V=typeof globalThis<"u"?globalThis:V||self,d(V["@honed/table"]={},V.Vue,V.Inertia))})(this,function(V,d,b){"use strict";function _(){const r=d.ref({all:!1,only:new Set,except:new Set});function m(){r.value.all=!0,r.value.only.clear(),r.value.except.clear()}function f(){r.value.all=!1,r.value.only.clear(),r.value.except.clear()}function l(...s){s.forEach(g=>r.value.except.delete(g)),s.forEach(g=>r.value.only.add(g))}function i(...s){s.forEach(g=>r.value.except.add(g)),s.forEach(g=>r.value.only.delete(g))}function u(s,g){if(x(s)||g===!1)return i(s);if(!x(s)||g===!0)return l(s)}function x(s){return r.value.all?!r.value.except.has(s):r.value.only.has(s)}const v=d.computed(()=>r.value.all&&r.value.except.size===0),A=d.computed(()=>r.value.only.size>0||v.value);function S(s){return{"onUpdate:modelValue":g=>{g?l(s):i(s)},modelValue:x(s),value:s}}function k(){return{"onUpdate:modelValue":s=>{s?m():f()},modelValue:v.value,value:v.value}}return{allSelected:v,selection:r,hasSelected:A,selectAll:m,deselectAll:f,select:l,deselect:i,toggle:u,selected:x,bind:S,bindAll:k}}function D(r,m,f={},l={}){return r.route?(b.router.visit(r.route.href,{...l,method:r.route.method}),!0):r.action&&m?(b.router.post(m,{...f,name:r.name,type:r.type},l),!0):!1}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=()=>{};function Q(r,m){function f(...l){return new Promise((i,u)=>{Promise.resolve(r(()=>m.apply(this,l),{fn:m,thisArg:this,args:l})).then(i).catch(u)})}return f}function X(r,m={}){let f,l,i=Y;const u=v=>{clearTimeout(v),i(),i=Y};let x;return v=>{const A=d.toValue(r),S=d.toValue(m.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=m.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 I(r,m=200,f={}){return Q(X(m,f),r)}function Z(r,m,f={}){const l=d.computed(()=>r[m]),i=d.computed(()=>{var e;return((e=l.value.filters)==null?void 0:e.map(n=>({...n,apply:(o,c={})=>T(n,o,c),clear:(o={})=>N(n,o),bind:()=>a(n.name)})))??[]}),u=d.computed(()=>{var e;return((e=l.value.sorts)==null?void 0:e.map(n=>({...n,apply:(o={})=>E(n,n.direction,o),clear:(o={})=>W(o),bind:()=>p(n)})))??[]}),x=d.computed(()=>{var e;return(e=l.value.searches)==null?void 0:e.map(n=>({...n,apply:(o={})=>U(n,o),clear:(o={})=>U(n,o),bind:()=>j(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 g(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 h(){var e;return(e=l.value.sorts)==null?void 0:e.find(({active:n})=>n)}function L(){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 K(e){var n;return e?typeof e=="string"?((n=h())==null?void 0:n.name)===e:e.active:!!h()}function P(e){var n,o;return e?typeof e=="string"?(o=L())==null?void 0:o.some(c=>c.name===e):e.active:!!((n=L())!=null&&n.length)}function G(e,n={}){const o=Object.fromEntries(Object.entries(e).map(([c,F])=>[c,k(F)]));b.router.reload({...f,...n,data:o})}function T(e,n,o={}){const c=typeof e=="string"?g(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 E(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 M(e,n={}){e=[A,S].reduce((o,c)=>c(o),e),b.router.reload({...f,...n,data:{[l.value.config.searches]:e}})}function U(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,L().filter(({active:c})=>c).map(({name:c})=>c));b.router.reload({...f,...n,data:{[l.value.config.matches]:v(o)}})}function N(e,n={}){T(e,void 0,n)}function W(e={}){b.router.reload({...f,...e,data:{[l.value.config.sorts]:null}})}function R(e={}){M(void 0,e)}function H(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 t(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 a(e,n={}){const o=typeof e=="string"?g(e):e;if(!o){console.warn(`Filter [${e}] does not exist.`);return}const c=o.value,{debounce:F=250,transform:B=J=>J,...$}=n;return{"onUpdate:modelValue":I(J=>{T(o,B(J),$)},F),modelValue:c}}function p(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:F,...B}=n;return{onClick:I(()=>{var $;E(o,($=h())==null?void 0:$.direction,B)},c)}}function w(e={}){const{debounce:n=700,transform:o,...c}=e;return{"onUpdate:modelValue":I(F=>{M(F,c)},n),modelValue:l.value.config.search??""}}function j(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:F,...B}=n;return{"onUpdate:modelValue":I($=>{U($,B)},c),modelValue:P(o)}}return{filters:i,sorts:u,searches:x,getFilter:g,getSort:C,getSearch:q,currentFilters:z,currentSort:h,currentSearches:L,isFiltering:y,isSorting:K,isSearching:P,apply:G,applyFilter:T,applySort:E,applySearch:M,applyMatch:U,clearFilter:N,clearSort:W,clearSearch:R,clearMatch:H,reset:t,bindFilter:a,bindSort:p,bindSearch:w,bindMatch:j,stringValue:A,omitValue:S,toggleValue:s,delimitArray:v}}function O(r,m,f={},l={}){if(!r||!m||!r[m])throw new Error("Table has not been provided with valid props and key.");l={...l,only:[...l.only??[],m.toString()]};const i=d.computed(()=>r[m]),u=_(),x=Z(r,m,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:a,hidden:p})=>a&&!p).map(a=>{var p;return{...a,isSorting:(p=a.sort)==null?void 0:p.active,toggleSort:(w={})=>U(a,w)}}))??[]}),k=d.computed(()=>{var t;return((t=i.value.columns)==null?void 0:t.filter(({hidden:a})=>!a).map(a=>({...a,toggle:(p={})=>N(a,p)})))??[]}),s=d.computed(()=>i.value.records.map(t=>({record:(({actions:a,...p})=>p)(t),default:(a={})=>{const p=t.actions.find(w=>w.default);p&&G(p,t,a)},actions:t.actions.map(a=>({...a,execute:(p={})=>G(a,t,p)})),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)),value:a=>t[K(a)].value,extra:a=>t[K(a)].extra}))),g=d.computed(()=>i.value.actions.bulk.map(t=>({...t,execute:(a={})=>T(t,a)}))),C=d.computed(()=>i.value.actions.page.map(t=>({...t,execute:(a={})=>E(t,a)}))),q=d.computed(()=>{var t;return((t=i.value.recordsPerPage)==null?void 0:t.map(a=>({...a,apply:(p={})=>M(a,p)})))??[]}),z=d.computed(()=>{var t;return(t=i.value.recordsPerPage)==null?void 0:t.find(({active:a})=>a)}),h=d.computed(()=>({...i.value.paginator,next:(t={})=>{"nextLink"in h.value&&h.value.nextLink&&P(h.value.nextLink,t)},previous:(t={})=>{"prevLink"in h.value&&h.value.prevLink&&P(h.value.prevLink,t)},first:(t={})=>{"firstLink"in h.value&&h.value.firstLink&&P(h.value.firstLink,t)},last:(t={})=>{"lastLink"in h.value&&h.value.lastLink&&P(h.value.lastLink,t)},..."links"in i.value.paginator&&i.value.paginator.links?{links:i.value.paginator.links.map(t=>({...t,navigate:(a={})=>t.url&&P(t.url,a)}))}:{}})),L=d.computed(()=>i.value.records.length>0&&i.value.records.every(t=>u.selected(y(t))));function y(t){return t[v.value.record].value}function K(t){return typeof t=="string"?t:t.name}function P(t,a={}){b.router.visit(t,{preserveScroll:!0,preserveState:!0,...l,...a,method:"get"})}function G(t,a,p={}){var j,e;D(t,v.value.endpoint,{table:i.value.id,id:y(a)},p)||(e=(j=f.recordActions)==null?void 0:j[t.name])==null||e.call(j,a)}function T(t,a={}){D(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)},a)}function E(t,a={}){D(t,v.value.endpoint,{table:i.value.id},a)}function M(t,a={}){b.router.reload({...l,...a,data:{[v.value.records]:t.value,[v.value.pages]:void 0}})}function U(t,a={}){t.sort&&b.router.reload({...l,...a,data:{[v.value.sorts]:x.omitValue(t.sort.next)}})}function N(t,a={}){const p=x.toggleValue(t.name,S.value.map(({name:w})=>w));b.router.reload({...l,...a,data:{[v.value.columns]:x.delimitArray(p)}})}function W(){u.select(...i.value.records.map(t=>y(t)))}function R(){u.deselect(...i.value.records.map(t=>y(t)))}function H(){return{"onUpdate:modelValue":t=>{t?W():R()},modelValue:L.value}}return d.reactive({getRecordKey:y,meta:A,headings:S,columns:k,records:s,bulkActions:g,pageActions:C,rowsPerPage:q,currentPage:z,paginator:h,executeInlineAction:G,executeBulkAction:T,executePageAction:E,applyPage:M,selection:u.selection,select:t=>u.select(y(t)),deselect:t=>u.deselect(y(t)),selectPage:W,deselectPage:R,toggle:t=>u.toggle(y(t)),selected:t=>u.selected(y(t)),selectAll:u.selectAll,deselectAll:u.deselectAll,isPageSelected:L,hasSelected:u.hasSelected,bindCheckbox:t=>u.bind(y(t)),bindPage:H,bindAll:u.bindAll,...x})}V.useTable=O,Object.defineProperty(V,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.0",
4
+ "version": "0.3.0",
5
5
  "license": "MIT",
6
6
  "description": "-",
7
7
  "keywords": [
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
32
- "url": "https://github.com/honedlabs/table.git"
32
+ "url": "https://github.com/honedlabs/honed.git"
33
33
  },
34
- "homepage": "https://github.com/honedlabs/table#readme",
34
+ "homepage": "https://github.com/honedlabs/honed/tree/main/packages/vue/table#readme",
35
35
  "files": [
36
36
  "dist"
37
37
  ],
@@ -42,14 +42,23 @@
42
42
  "exports": {
43
43
  ".": {
44
44
  "types": "./dist/index.d.ts",
45
- "import": "./dist/index.es.js",
46
- "require": "./dist/index.umd.js",
47
- "default": "./dist/index.es.js"
45
+ "import": {
46
+ "types": "./dist/index.d.ts",
47
+ "default": "./dist/index.es.js"
48
+ },
49
+ "require": {
50
+ "types": "./dist/index.d.ts",
51
+ "default": "./dist/index.umd.js"
52
+ },
53
+ "default": {
54
+ "types": "./dist/index.d.ts",
55
+ "default": "./dist/index.es.js"
56
+ }
48
57
  }
49
58
  },
50
59
  "peerDependencies": {
51
- "@honed/action": "^0.2.0",
52
- "@honed/refine": "^0.2.1",
60
+ "@honed/action": "^0.3.2",
61
+ "@honed/refine": "^0.3.0",
53
62
  "@inertiajs/vue3": "^1.2.0||^2.0.0",
54
63
  "@vueuse/core": "^11.0.0||^12.0.0",
55
64
  "axios": "^1.2.0",