@vuu-ui/vuu-table-types 0.8.13-debug

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.
Files changed (2) hide show
  1. package/index.d.ts +278 -0
  2. package/package.json +15 -0
package/index.d.ts ADDED
@@ -0,0 +1,278 @@
1
+ import type { Filter } from "@vuu-ui/vuu-filter-types";
2
+ import type {
3
+ VuuAggType,
4
+ VuuColumnDataType,
5
+ VuuRowDataItemType,
6
+ VuuSortType,
7
+ VuuTable,
8
+ } from "@vuu-ui/vuu-protocol-types";
9
+ import { VuuDataRow } from "@vuu-ui/vuu-protocol-types";
10
+ import type { ValueFormatter } from "@vuu-ui/vuu-table";
11
+ import type { ClientSideValidationChecker } from "@vuu-ui/vuu-ui-controls";
12
+ import type { ColumnMap } from "@vuu-ui/vuu-utils";
13
+ import type { FunctionComponent, MouseEvent } from "react";
14
+
15
+ export type TableSelectionModel = "none" | "single" | "checkbox" | "extended";
16
+
17
+ export type RangeTuple = [from: number, to: number];
18
+ export type SelectionItem = number | RangeTuple;
19
+ export type Selection = SelectionItem[];
20
+ export type SelectionChangeHandler = (selection: Selection) => void;
21
+
22
+ export type TableHeading = { label: string; width: number };
23
+ export type TableHeadings = TableHeading[][];
24
+
25
+ export type DataCellEditHandler = (
26
+ row: DataSourceRow,
27
+ columnName: string,
28
+ value: VuuRowDataItemType
29
+ ) => Promise<string | true>;
30
+
31
+ export interface TableCellProps {
32
+ className?: string;
33
+ column: RuntimeColumnDescriptor;
34
+ columnMap: ColumnMap;
35
+ onClick?: (event: MouseEvent, column: RuntimeColumnDescriptor) => void;
36
+ onDataEdited?: DataCellEditHandler;
37
+ row: DataSourceRow;
38
+ }
39
+
40
+ export type CommitResponse = Promise<true | string>;
41
+
42
+ export type DataItemCommitHandler<
43
+ T extends VuuRowDataItemType = VuuRowDataItemType
44
+ > = (value: T) => CommitResponse;
45
+
46
+ export type TableRowClickHandler = (row: VuuDataRow) => void;
47
+
48
+ export type RowClickHandler = (
49
+ row: DataSourceRow,
50
+ rangeSelect: boolean,
51
+ keepExistingSelection: boolean
52
+ ) => void;
53
+
54
+ export interface TableCellRendererProps
55
+ extends Omit<TableCellProps, "onDataEdited"> {
56
+ onCommit?: DataItemCommitHandler;
57
+ }
58
+
59
+ export interface TableAttributes {
60
+ columnDefaultWidth?: number;
61
+ columnFormatHeader?: "capitalize" | "uppercase";
62
+ columnSeparators?: boolean;
63
+ // showHighlightedRow?: boolean;
64
+ rowSeparators?: boolean;
65
+ zebraStripes?: boolean;
66
+ }
67
+
68
+ /**
69
+ * TableConfig describes the configuration used to render a Table. It is
70
+ * a required prop for Table and provided initially by user. It can be
71
+ * edited using Settings Editors (Table and Column) and can be persisted
72
+ * across sessions.
73
+ */
74
+ export interface TableConfig extends TableAttributes {
75
+ columns: ColumnDescriptor[];
76
+ }
77
+ export interface GridConfig extends TableConfig {
78
+ headings: TableHeadings;
79
+ selectionBookendWidth?: number;
80
+ }
81
+
82
+ export declare type ColumnTypeFormatting = {
83
+ alignOnDecimals?: boolean;
84
+ decimals?: number;
85
+ pattern?: string;
86
+ zeroPad?: boolean;
87
+ };
88
+
89
+ export type ColumnTypeValueMap = { [key: string]: string };
90
+
91
+ export interface EditValidationRule {
92
+ name: string;
93
+ message?: string;
94
+ value?: string;
95
+ }
96
+
97
+ export type ListOption = {
98
+ label: string;
99
+ value: number | string;
100
+ };
101
+
102
+ /**
103
+ * Descibes a custom cell renderer for a Table column
104
+ */
105
+ export interface ColumnTypeRendering {
106
+ associatedField?: string;
107
+ // specific to Background renderer
108
+ flashStyle?: "bg-only" | "arrow-bg" | "arrow";
109
+ name: string;
110
+ rules?: EditValidationRule[];
111
+ }
112
+ export interface MappedValueTypeRenderer {
113
+ map: ColumnTypeValueMap;
114
+ }
115
+
116
+ export type LookupTableDetails = {
117
+ labelColumn: string;
118
+ table: VuuTable;
119
+ valueColumn: string;
120
+ };
121
+ /**
122
+ * This describes a serverside lookup table which will be bound to the edit control
123
+ * for this column. The lookup table will typically have two columns, mapping a
124
+ * numeric value to a User friendly display string.
125
+ */
126
+ export interface LookupRenderer {
127
+ name: string;
128
+ lookup: LookupTableDetails;
129
+ }
130
+
131
+ export interface ValueListRenderer {
132
+ name: string;
133
+ values: string[];
134
+ }
135
+
136
+ export declare type ColumnTypeSimple =
137
+ | "string"
138
+ | "number"
139
+ | "boolean"
140
+ | "json"
141
+ | "date"
142
+ | "time"
143
+ | "checkbox";
144
+
145
+ export declare type ColumnTypeDescriptor = {
146
+ formatting?: ColumnTypeFormatting;
147
+ name: ColumnTypeSimple;
148
+ renderer?:
149
+ | ColumnTypeRendering
150
+ | LookupRenderer
151
+ | MappedValueTypeRenderer
152
+ | ValueListRenderer;
153
+ };
154
+
155
+ export declare type ColumnTypeDescriptorCustomRenderer = {
156
+ formatting?: ColumnTypeFormatting;
157
+ name: ColumnTypeSimple;
158
+ renderer: ColumnTypeRendering;
159
+ };
160
+
161
+ export interface ColumnTypeRendererWithValidationRules
162
+ extends ColumnTypeRendering {
163
+ rules: EditValidationRule[];
164
+ }
165
+
166
+ export interface ColumnTypeWithValidationRules extends ColumnTypeDescriptor {
167
+ renderer: ColumnTypeRendererWithValidationRules;
168
+ }
169
+
170
+ export declare type ColumnType = ColumnTypeSimple | ColumnTypeDescriptor;
171
+
172
+ export type ColumnSort = VuuSortType | number;
173
+
174
+ export type PinLocation = "left" | "right" | "floating";
175
+
176
+ export type ColumnAlignment = "left" | "right";
177
+
178
+ /** This is a public description of a Column, defining all the
179
+ * column attributes that can be defined by client. */
180
+ export interface ColumnDescriptor {
181
+ aggregate?: VuuAggType;
182
+ align?: ColumnAlignment;
183
+ className?: string;
184
+ colHeaderContentRenderer?: string;
185
+ colHeaderLabelRenderer?: string;
186
+ editable?: boolean;
187
+ flex?: number;
188
+ /**
189
+ Optional additional level(s) of heading to display above label.
190
+ May span multiple columns, if multiple adjacent columns declare
191
+ same heading at same level.
192
+ */
193
+ heading?: string[];
194
+ hidden?: boolean;
195
+ isSystemColumn?: boolean;
196
+ /** The Label to display on column in Table */
197
+ label?: string;
198
+ locked?: boolean;
199
+ minWidth?: number;
200
+ name: string;
201
+ pin?: PinLocation;
202
+ resizeable?: boolean;
203
+ serverDataType?: VuuColumnDataType;
204
+ sortable?: boolean;
205
+ type?: ColumnType;
206
+ width?: number;
207
+ }
208
+
209
+ export interface ColumnDescriptorCustomRenderer
210
+ extends Omit<ColumnDescriptor, "type"> {
211
+ type: ColumnTypeDescriptorCustomRenderer;
212
+ }
213
+
214
+ /** This is an internal description of a Column that extends the public
215
+ * definitin with internal state values. */
216
+ export interface RuntimeColumnDescriptor extends ColumnDescriptor {
217
+ align?: "left" | "right";
218
+ CellRenderer?: FunctionComponent<TableCellRendererProps>;
219
+ HeaderCellLabelRenderer?: FunctionComponent<HeaderCellProps>;
220
+ HeaderCellContentRenderer?: FunctionComponent<HeaderCellProps>;
221
+ className?: string;
222
+ clientSideEditValidationCheck?: ClientSideValidationChecker;
223
+ endPin?: true | undefined;
224
+ filter?: Filter;
225
+ flex?: number;
226
+ heading?: [...string[]];
227
+ isGroup?: boolean;
228
+ isSystemColumn?: boolean;
229
+ key: number;
230
+ label: string;
231
+ locked?: boolean;
232
+ marginLeft?: number;
233
+ moving?: boolean;
234
+ /** used only when column is a child of GroupColumn */
235
+ originalIdx?: number;
236
+ pinnedOffset?: number;
237
+ resizeable?: boolean;
238
+ resizing?: boolean;
239
+ sortable?: boolean;
240
+ sorted?: ColumnSort;
241
+ type?: ColumnType;
242
+ valueFormatter: ValueFormatter;
243
+ width: number;
244
+ }
245
+
246
+ export interface GroupColumnDescriptor extends RuntimeColumnDescriptor {
247
+ columns: RuntimeColumnDescriptor[];
248
+ groupConfirmed: boolean;
249
+ }
250
+
251
+ export interface Heading {
252
+ collapsed?: boolean;
253
+ key: string;
254
+ hidden?: boolean;
255
+ isHeading: true;
256
+ label: string;
257
+ name: string;
258
+ resizeable?: boolean;
259
+ resizing?: boolean;
260
+ width: number;
261
+ }
262
+
263
+ // These are the actions that eventually get routed to the DataSource itself
264
+ export type DataSourceAction =
265
+ | GridActionCloseTreeNode
266
+ | GridActionGroup
267
+ | GridActionOpenTreeNode
268
+ | GridActionSort;
269
+
270
+ export type ScrollAction =
271
+ | GridActionScrollEndHorizontal
272
+ | GridActionScrollStartHorizontal;
273
+
274
+ export type GridAction =
275
+ | DataSourceAction
276
+ | ScrollAction
277
+ | GridActionResizeCol
278
+ | GridActionSelection;
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@vuu-ui/vuu-table-types",
3
+ "version": "0.8.13-debug",
4
+ "devDependencies": {
5
+ "@vuu-ui/vuu-protocol-types": "0.8.13-debug"
6
+ },
7
+ "author": "heswell",
8
+ "license": "Apache-2.0",
9
+ "dependencies": {},
10
+ "peerDependencies": {},
11
+ "files": [
12
+ "index.d.ts"
13
+ ],
14
+ "types": "index.d.ts"
15
+ }