@honed/table 0.11.1 → 0.13.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,11 +1,8 @@
1
1
  import { Binding } from '@honed/action';
2
2
  import { BulkOperation } from '@honed/action';
3
3
  import { BulkSelection } from '@honed/action';
4
- import { Executable } from '@honed/action';
5
4
  import { HonedRefine } from '@honed/refine';
6
5
  import { InlineOperation } from '@honed/action';
7
- import { MaybeEndpoint } from '@honed/action';
8
- import { MaybeId } from '@honed/action';
9
6
  import { PageOperation } from '@honed/action';
10
7
  import { PageOperationData } from '@honed/action';
11
8
  import { RecordBinding } from '@honed/action';
@@ -55,7 +52,6 @@ export declare interface HonedColumn<T extends Record<string, any> = Record<stri
55
52
  }
56
53
 
57
54
  export declare interface HonedTable<T extends Record<string, any> = Record<string, any>, K extends Paginate = "length-aware"> extends HonedRefine {
58
- id: Exclude<MaybeId, undefined>;
59
55
  meta: Record<string, any> | null;
60
56
  emptyState: EmptyState | null;
61
57
  views: View[];
@@ -63,7 +59,7 @@ export declare interface HonedTable<T extends Record<string, any> = Record<strin
63
59
  isEmpty: boolean;
64
60
  isPageable: boolean;
65
61
  isToggleable: boolean;
66
- getRecordKey: (record: TableEntry<T>) => Identifier;
62
+ getRecordKey: (record: TableEntry<T> | TableRecord<T>) => Identifier;
67
63
  getEntry: (record: TableEntry<T>, column: Column<T> | string) => {
68
64
  v: any;
69
65
  e: any;
@@ -76,8 +72,12 @@ export declare interface HonedTable<T extends Record<string, any> = Record<strin
76
72
  columns: HonedColumn<T>[];
77
73
  records: TableRecord<T>[];
78
74
  inline: boolean;
79
- bulk: Executable<BulkOperation>[];
80
- page: Executable<PageOperation>[];
75
+ bulk: (BulkOperation & {
76
+ execute: (options?: VisitOptions) => void;
77
+ })[];
78
+ page: (PageOperation & {
79
+ execute: (options?: VisitOptions) => void;
80
+ })[];
81
81
  pages: PageOption[];
82
82
  currentPage: PageOption | undefined;
83
83
  paginator: PaginateMap[K];
@@ -103,6 +103,9 @@ export declare interface HonedTable<T extends Record<string, any> = Record<strin
103
103
 
104
104
  export declare type Identifier = string | number;
105
105
 
106
+ /**
107
+ * Check if a column is of a given type.
108
+ */
106
109
  export declare function is(column: Column | string | null | undefined, type: ColumnType): boolean;
107
110
 
108
111
  export declare interface LengthAwarePaginate extends SimplePaginate {
@@ -139,25 +142,22 @@ export declare interface SimplePaginate extends CursorPaginate {
139
142
  }
140
143
 
141
144
  export declare interface Table<T extends Record<string, any> = Record<string, any>, K extends Paginate = "length-aware"> extends Refine {
142
- id: MaybeId;
143
- endpoint: MaybeEndpoint;
144
- key: string;
145
- column?: string;
146
- record?: string;
147
- page?: string;
145
+ _column_key?: string;
146
+ _record_key?: string;
147
+ _page_key?: string;
148
+ toggleable: boolean;
148
149
  records: Array<TableEntry<T> & {
149
150
  operations: InlineOperation[];
150
151
  }>;
151
152
  paginate: PaginateMap[K];
152
153
  columns: Column<T>[];
153
154
  pages: PageOption[];
154
- toggleable: boolean;
155
155
  operations: {
156
156
  inline: boolean;
157
157
  bulk: BulkOperation[];
158
158
  page: PageOperation[];
159
159
  };
160
- emptyState?: EmptyState;
160
+ state?: EmptyState;
161
161
  views?: View[];
162
162
  meta: Record<string, any>;
163
163
  }
@@ -170,6 +170,7 @@ export declare type TableEntry<T extends Record<string, any> = Record<string, an
170
170
  f: boolean;
171
171
  };
172
172
  } & {
173
+ _key: Identifier;
173
174
  class: string | null;
174
175
  };
175
176
 
@@ -180,19 +181,20 @@ export declare interface TableOptions<T extends Record<string, any> = Record<str
180
181
  recordOperations?: Record<string, (record: TableEntry<T>) => void>;
181
182
  }
182
183
 
183
- export declare interface TableRecord<T extends Record<string, any> = Record<string, any>> {
184
- operations: Executable<InlineOperation>[];
185
- class: string | null;
184
+ export declare type TableRecord<T extends Record<string, any> = Record<string, any>> = TableEntry<T> & {
185
+ operations: (InlineOperation & {
186
+ execute: (options?: VisitOptions) => void;
187
+ })[];
188
+ selected: boolean;
186
189
  default: (options?: VisitOptions) => void;
187
190
  select: () => void;
188
191
  deselect: () => void;
189
192
  toggle: () => void;
190
- selected: boolean;
191
193
  bind: () => RecordBinding<Identifier>;
192
- entry: (column: HonedColumn<T> | string) => TableEntry<T>[keyof T] | null;
193
- value: (column: HonedColumn<T> | string) => TableEntry<T>[keyof T]["v"] | null;
194
- extra: (column: HonedColumn<T> | string) => TableEntry<T>[keyof T]["e"] | null;
195
- }
194
+ entry: (column: Column<T> | string) => TableEntry<T>[keyof T] | null;
195
+ value: (column: Column<T> | string) => TableEntry<T>[keyof T]["v"] | null;
196
+ extra: (column: Column<T> | string) => TableEntry<T>[keyof T]["e"] | null;
197
+ };
196
198
 
197
199
  export declare type UseTable = typeof useTable;
198
200