@honed/table 0.9.1 → 0.10.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,33 +1,27 @@
1
- import { BindingOptions } from '@honed/refine';
1
+ import { Binding } from '@honed/action';
2
2
  import { BulkOperation } from '@honed/action';
3
3
  import { BulkSelection } from '@honed/action';
4
- import { ComputedRef } from 'vue';
5
- import { Direction } from '@honed/refine';
6
4
  import { Executable } from '@honed/action';
7
- import { Filter } from '@honed/refine';
8
- import { FilterBinding } from '@honed/refine';
9
- import { FilterValue } from '@honed/refine';
10
- import { HonedFilter } from '@honed/refine';
11
5
  import { HonedRefine } from '@honed/refine';
12
- import { HonedSearch } from '@honed/refine';
13
- import { HonedSort } from '@honed/refine';
14
6
  import { InlineOperation } from '@honed/action';
15
- import { MatchBinding } from '@honed/refine';
16
7
  import { MaybeEndpoint } from '@honed/action';
17
8
  import { MaybeId } from '@honed/action';
18
9
  import { PageOperation } from '@honed/action';
19
10
  import { PageOperationData } from '@honed/action';
20
- import { Ref } from 'vue';
11
+ import { RecordBinding } from '@honed/action';
21
12
  import { Refine } from '@honed/refine';
22
- import { Search } from '@honed/refine';
23
- import { SearchBinding } from '@honed/refine';
24
13
  import { Sort } from '@honed/refine';
25
- import { SortBinding } from '@honed/refine';
26
- import { Visit } from '@inertiajs/core';
27
- import { VisitCallbacks } from '@inertiajs/core';
28
14
  import { VisitOptions } from '@inertiajs/core';
29
15
 
30
- export declare interface BaseColumn<T extends Record<string, any> = Record<string, any>> {
16
+ export declare interface Classes {
17
+ classes?: string;
18
+ }
19
+
20
+ export declare interface CollectionPaginate {
21
+ empty: boolean;
22
+ }
23
+
24
+ export declare interface Column<T extends Record<string, any> = Record<string, any>> {
31
25
  name: keyof T;
32
26
  label: string;
33
27
  type?: ColumnType;
@@ -36,19 +30,10 @@ export declare interface BaseColumn<T extends Record<string, any> = Record<strin
36
30
  badge?: boolean;
37
31
  toggleable: boolean;
38
32
  class?: string;
39
- record_class?: string;
40
33
  icon?: string;
41
34
  sort?: Pick<Sort, "active" | "direction" | "next">;
42
35
  }
43
36
 
44
- export declare interface CollectionPaginate {
45
- empty: boolean;
46
- }
47
-
48
- export declare interface Column<T extends Record<string, any> = Record<string, any>> extends BaseColumn<T> {
49
- toggle: (options: VisitOptions) => void;
50
- }
51
-
52
37
  export declare type ColumnType = "array" | "badge" | "boolean" | "color" | "date" | "datetime" | "icon" | "image" | "numeric" | "text" | "time" | string;
53
38
 
54
39
  export declare interface CursorPaginate extends CollectionPaginate {
@@ -64,31 +49,47 @@ export declare interface EmptyState {
64
49
  operations: PageOperation[];
65
50
  }
66
51
 
67
- export declare interface Heading<T extends Record<string, any> = Record<string, any>> extends BaseColumn<T> {
52
+ export declare interface Heading<T extends Record<string, any> = Record<string, any>> extends Column<T> {
68
53
  isSorting: boolean;
69
- toggleSort: (options: VisitOptions) => void;
54
+ toggleSort: (options?: VisitOptions) => void;
55
+ }
56
+
57
+ export declare interface HonedColumn<T extends Record<string, any> = Record<string, any>> extends Column<T> {
58
+ toggle: (options: VisitOptions) => void;
70
59
  }
71
60
 
72
61
  export declare interface HonedTable<T extends Record<string, any> = Record<string, any>, K extends Paginate = "length-aware"> extends HonedRefine {
73
- meta: ComputedRef<Record<string, any> | null>;
74
- isEmpty: ComputedRef<boolean>;
75
- isPageable: ComputedRef<boolean>;
76
- isToggleable: ComputedRef<boolean>;
62
+ id: Exclude<MaybeId, undefined>;
63
+ meta: Record<string, any> | null;
64
+ emptyState: EmptyState | null;
65
+ views: View[];
66
+ placeholder: string | null;
67
+ isEmpty: boolean;
68
+ isPageable: boolean;
69
+ isToggleable: boolean;
77
70
  getRecordKey: (record: TableEntry<T>) => Identifier;
78
- headings: ComputedRef<Heading<T>[]>;
79
- columns: ComputedRef<Column<T>[]>;
80
- records: ComputedRef<TableRecord<T>[]>;
81
- inline: ComputedRef<boolean>;
82
- bulk: ComputedRef<Executable<BulkOperation>[]>;
83
- page: ComputedRef<Executable<PageOperation>[]>;
84
- pages: ComputedRef<PageOption[]>;
85
- currentPage: ComputedRef<PageOption | undefined>;
86
- paginator: ComputedRef<PaginateMap[K]>;
71
+ getEntry: (record: TableEntry<T>, column: Column<T> | string) => {
72
+ v: any;
73
+ e: any;
74
+ c: string | null;
75
+ f: boolean;
76
+ } | null;
77
+ getValue: (record: TableEntry<T>, column: Column<T> | string) => any;
78
+ getExtra: (record: TableEntry<T>, column: Column<T> | string) => any;
79
+ headings: Heading<T>[];
80
+ columns: HonedColumn<T>[];
81
+ records: TableRecord<T>[];
82
+ inline: boolean;
83
+ bulk: Executable<BulkOperation>[];
84
+ page: Executable<PageOperation>[];
85
+ pages: PageOption[];
86
+ currentPage: PageOption | undefined;
87
+ paginator: PaginateMap[K];
87
88
  executeInline: (operation: InlineOperation, data: TableEntry<T>, options?: VisitOptions) => void;
88
89
  executeBulk: (operation: BulkOperation, options?: VisitOptions) => void;
89
90
  executePage: (operation: PageOperation, data?: PageOperationData, options?: VisitOptions) => void;
90
91
  applyPage: (page: PageOption, options?: VisitOptions) => void;
91
- selection: Ref<BulkSelection<Identifier>, BulkSelection<Identifier>>;
92
+ selection: BulkSelection<Identifier>;
92
93
  select: (record: TableEntry<T>) => void;
93
94
  deselect: (record: TableEntry<T>) => void;
94
95
  toggle: (record: TableEntry<T>) => void;
@@ -97,11 +98,11 @@ export declare interface HonedTable<T extends Record<string, any> = Record<strin
97
98
  selected: (record: TableEntry<T>) => boolean;
98
99
  selectAll: () => void;
99
100
  deselectAll: () => void;
100
- isPageSelected: ComputedRef<boolean>;
101
- hasSelected: ComputedRef<boolean>;
102
- bindCheckbox: (record: TableEntry<T>) => void;
103
- bindPage: () => void;
104
- bindAll: () => void;
101
+ isPageSelected: boolean;
102
+ hasSelected: boolean;
103
+ bindCheckbox: (record: TableEntry<T>) => RecordBinding<Identifier>;
104
+ bindPage: () => Binding;
105
+ bindAll: () => Binding;
105
106
  }
106
107
 
107
108
  export declare type Identifier = string | number;
@@ -117,11 +118,6 @@ export declare interface LengthAwarePaginate extends SimplePaginate {
117
118
  links: PaginatorLink[];
118
119
  }
119
120
 
120
- export declare interface PageBinding {
121
- "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
122
- modelValue: boolean;
123
- }
124
-
125
121
  export declare interface PageOption {
126
122
  value: number;
127
123
  active: boolean;
@@ -157,7 +153,7 @@ export declare interface Table<T extends Record<string, any> = Record<string, an
157
153
  operations: InlineOperation[];
158
154
  }>;
159
155
  paginate: PaginateMap[K];
160
- columns: BaseColumn<T>[];
156
+ columns: Column<T>[];
161
157
  pages: PageOption[];
162
158
  toggleable: boolean;
163
159
  operations: {
@@ -170,14 +166,14 @@ export declare interface Table<T extends Record<string, any> = Record<string, an
170
166
  meta: Record<string, any>;
171
167
  }
172
168
 
173
- export declare type TableEntry<T extends Record<string, any> = any> = {
169
+ export declare type TableEntry<T extends Record<string, any> = Record<string, any>> = {
174
170
  [K in keyof T]: {
175
171
  v: T[K];
176
172
  e: any;
177
173
  c: string | null;
178
174
  f: boolean;
179
175
  };
180
- };
176
+ } & Classes;
181
177
 
182
178
  export declare interface TableOptions<T extends Record<string, any> = Record<string, any>> extends VisitOptions {
183
179
  /**
@@ -188,107 +184,21 @@ export declare interface TableOptions<T extends Record<string, any> = Record<str
188
184
 
189
185
  export declare interface TableRecord<T extends Record<string, any> = Record<string, any>> {
190
186
  operations: Executable<InlineOperation>[];
187
+ classes: string | null;
191
188
  default: (options?: VisitOptions) => void;
192
189
  select: () => void;
193
190
  deselect: () => void;
194
191
  toggle: () => void;
195
192
  selected: boolean;
196
- bind: () => any;
197
- entry: (column: Column<T> | string) => TableEntry<T>[keyof T] | null;
198
- value: (column: Column<T> | string) => TableEntry<T>[keyof T]["v"] | null;
199
- extra: (column: Column<T> | string) => TableEntry<T>[keyof T]["e"] | null;
193
+ bind: () => RecordBinding<Identifier>;
194
+ entry: (column: HonedColumn<T> | string) => TableEntry<T>[keyof T] | null;
195
+ value: (column: HonedColumn<T> | string) => TableEntry<T>[keyof T]["v"] | null;
196
+ extra: (column: HonedColumn<T> | string) => TableEntry<T>[keyof T]["e"] | null;
200
197
  }
201
198
 
202
199
  export declare type UseTable = typeof useTable;
203
200
 
204
- export declare function useTable<T extends Record<string, Table>, K extends Record<string, any> = Record<string, any>, U extends Paginate = "length-aware">(props: T, key: keyof T, defaults?: TableOptions): {
205
- filters: HonedFilter[];
206
- sorts: HonedSort[];
207
- searches: HonedSearch[];
208
- currentFilters: HonedFilter[];
209
- currentSort: HonedSort | undefined;
210
- currentSearches: HonedSearch[];
211
- isSortable: boolean;
212
- isSearchable: boolean;
213
- isMatchable: boolean;
214
- isFiltering: (name?: string | Filter | undefined) => boolean;
215
- isSorting: (name?: string | Sort | undefined) => boolean;
216
- isSearching: (name?: string | Search | undefined) => boolean;
217
- getFilter: (filter: string | Filter) => Filter | undefined;
218
- getSort: (sort: string | Sort, dir?: Direction | undefined) => Sort | undefined;
219
- getSearch: (search: string | Search) => Search | undefined;
220
- apply: (values: Record<string, FilterValue>, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
221
- applyFilter: (filter: string | Filter, value: any, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
222
- applySort: (sort: string | Sort, direction?: Direction | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
223
- applySearch: (value: string | null | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
224
- applyMatch: (search: string | Search, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
225
- clearFilter: (filter?: string | Filter | undefined, options?: Partial<Visit & VisitCallbacks> | undefined) => void;
226
- clearSort: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
227
- clearSearch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
228
- clearMatch: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
229
- reset: (options?: Partial<Visit & VisitCallbacks> | undefined) => void;
230
- bindFilter: (filter: string | Filter, options?: BindingOptions | undefined) => void | FilterBinding;
231
- bindSort: (sort: string | Sort, options?: BindingOptions | undefined) => void | SortBinding;
232
- bindSearch: (options?: BindingOptions | undefined) => void | SearchBinding;
233
- bindMatch: (match: string | Search, options?: BindingOptions | undefined) => void | MatchBinding;
234
- stringValue: (value: any) => any;
235
- omitValue: (value: any) => any;
236
- toggleValue: (value: any, values: any) => any;
237
- delimitArray: (value: any) => string;
238
- meta: Record<string, any>;
239
- isEmpty: boolean;
240
- isPageable: boolean;
241
- isToggleable: boolean;
242
- getRecordKey: (record: TableEntry<K>) => Identifier;
243
- headings: Heading<K>[];
244
- columns: Column<K>[];
245
- records: TableRecord<K>[];
246
- inline: boolean;
247
- bulk: Executable<BulkOperation>[];
248
- page: Executable<PageOperation>[];
249
- pages: PageOption[];
250
- currentPage: PageOption | undefined;
251
- paginator: PaginateMap[U] & {
252
- links?: {
253
- navigate: (options?: VisitOptions) => void | "" | null;
254
- url: string | null;
255
- label: string;
256
- active: boolean;
257
- }[] | undefined;
258
- next: (options?: VisitOptions) => void;
259
- previous: (options?: VisitOptions) => void;
260
- first: (options?: VisitOptions) => void;
261
- last: (options?: VisitOptions) => void;
262
- };
263
- executeInline: (operation: InlineOperation, data: TableEntry<K>, options?: VisitOptions) => void;
264
- executeBulk: (operation: BulkOperation, options?: VisitOptions) => void;
265
- executePage: (operation: PageOperation, data?: PageOperationData, options?: VisitOptions) => boolean;
266
- applyPage: (page: PageOption, options?: VisitOptions) => void;
267
- selection: BulkSelection<Identifier>;
268
- select: (record: TableEntry<K>) => void;
269
- deselect: (record: TableEntry<K>) => void;
270
- selectPage: () => void;
271
- deselectPage: () => void;
272
- toggle: (record: TableEntry<K>) => void;
273
- selected: (record: TableEntry<K>) => boolean;
274
- selectAll: () => void;
275
- deselectAll: () => void;
276
- isPageSelected: boolean;
277
- hasSelected: boolean;
278
- bindCheckbox: (record: TableEntry<K>) => {
279
- "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
280
- modelValue: boolean;
281
- value: Identifier;
282
- };
283
- bindPage: () => {
284
- "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
285
- modelValue: boolean;
286
- };
287
- bindAll: () => {
288
- "onUpdate:modelValue": (checked: boolean | "indeterminate") => void;
289
- modelValue: boolean;
290
- };
291
- };
201
+ export declare function useTable<T extends Record<string, Table>, K extends Record<string, any> = Record<string, any>, U extends Paginate = "length-aware">(props: T, key: keyof T, defaults?: TableOptions): HonedTable<K, U>;
292
202
 
293
203
  export declare interface View {
294
204
  id: number;