@vuu-ui/vuu-table-types 0.9.0 → 0.9.2

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 +38 -28
  2. package/package.json +4 -4
package/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import type {
2
+ DataSourceRow,
2
3
  DataSourceRowObject,
3
4
  DataValueDescriptor,
4
5
  DataValueTypeSimple,
5
- EditValidationRule,
6
- } from "@vuu-ui/vuu-data-types";
7
- import type {
8
6
  DataValueValidationChecker,
9
- DataSourceRow,
7
+ EditValidationRule,
10
8
  } from "@vuu-ui/vuu-data-types";
11
9
  import type { Filter } from "@vuu-ui/vuu-filter-types";
12
10
  import type {
@@ -16,6 +14,7 @@ import type {
16
14
  VuuSortType,
17
15
  VuuTable,
18
16
  } from "@vuu-ui/vuu-protocol-types";
17
+ import { CellPos } from "@vuu-ui/vuu-table/src/table-dom-utils";
19
18
  import type {
20
19
  ColumnMap,
21
20
  DateTimePattern,
@@ -28,7 +27,8 @@ import type {
28
27
  MouseEvent,
29
28
  ReactElement,
30
29
  } from "react";
31
- import { CellPos } from "@vuu-ui/vuu-table/src/table-dom-utils";
30
+
31
+ export declare type GroupToggleTarget = "toggle-icon" | "group-column";
32
32
 
33
33
  export declare type TableSelectionModel =
34
34
  | "none"
@@ -41,11 +41,22 @@ export declare type TableHeadings = TableHeading[][];
41
41
 
42
42
  export declare type ValueFormatter = (value: unknown) => string;
43
43
 
44
- export declare type DataCellEditHandler = (
45
- row: DataSourceRow,
46
- columnName: string,
47
- value: VuuRowDataItemType,
48
- ) => Promise<string | true>;
44
+ export interface EditEventState {
45
+ editType?: EditType;
46
+ isValid?: boolean;
47
+ // value: unknown;
48
+ previousValue?: VuuRowDataItemType;
49
+ value: VuuRowDataItemType;
50
+ }
51
+
52
+ export interface DataCellEditEvent extends EditEventState {
53
+ row: DataSourceRow;
54
+ columnName: string;
55
+ }
56
+
57
+ export declare type DataCellEditNotification = (
58
+ editEvent: DataCellEditEvent,
59
+ ) => void;
49
60
 
50
61
  export interface TableCellProps {
51
62
  className?: string;
@@ -58,9 +69,12 @@ export interface TableCellProps {
58
69
 
59
70
  export declare type CommitResponse = Promise<true | string>;
60
71
 
61
- export declare type DataItemCommitHandler<
62
- T extends VuuRowDataItemType = VuuRowDataItemType,
63
- > = (value: T) => CommitResponse;
72
+ export declare type EditType = "commit" | "change" | "cancel";
73
+
74
+ declare type DataItemEditHandler<T extends EditType = EditType> = (
75
+ editState: EditEventState,
76
+ editPhase: T,
77
+ ) => T extends "commit" ? Promise<string | true> : void;
64
78
 
65
79
  export declare type TableRowSelectHandler = (
66
80
  row: DataSourceRowObject | null,
@@ -86,7 +100,7 @@ export declare type TableRowClickHandlerInternal = (
86
100
 
87
101
  export interface TableCellRendererProps
88
102
  extends Omit<TableCellProps, "onDataEdited"> {
89
- onCommit?: DataItemCommitHandler;
103
+ onEdit?: DataItemEditHandler;
90
104
  }
91
105
 
92
106
  /**
@@ -234,6 +248,11 @@ export interface ColumnDescriptor extends DataValueDescriptor {
234
248
  colHeaderContentRenderer?: string;
235
249
  colHeaderLabelRenderer?: string;
236
250
  flex?: number;
251
+ /**
252
+ * Only used when the column is included in a grouby clause.
253
+ * The icon will be displayed alongside the group label
254
+ */
255
+ getIcon?: (row: DataSourceRow) => string | undefined;
237
256
  /**
238
257
  Optional additional level(s) of heading to display above label.
239
258
  May span multiple columns, if multiple adjacent columns declare
@@ -260,6 +279,7 @@ export interface ColumnDescriptorCustomRenderer
260
279
  * definitin with internal state values. */
261
280
  export interface RuntimeColumnDescriptor extends ColumnDescriptor {
262
281
  align?: "left" | "right";
282
+ ariaColIndex: number;
263
283
  CellRenderer?: FunctionComponent<TableCellRendererProps>;
264
284
  HeaderCellLabelRenderer?: FunctionComponent<HeaderCellProps>;
265
285
  HeaderCellContentRenderer?: FunctionComponent<HeaderCellProps>;
@@ -270,8 +290,6 @@ export interface RuntimeColumnDescriptor extends ColumnDescriptor {
270
290
  filter?: Filter;
271
291
  flex?: number;
272
292
  heading?: [...string[]];
273
- /** A 1 based index for aria-colindex */
274
- index?: number;
275
293
  isGroup?: boolean;
276
294
  isSystemColumn?: boolean;
277
295
  label: string;
@@ -385,12 +403,15 @@ export interface BaseRowProps {
385
403
  export interface RowProps extends BaseRowProps {
386
404
  classNameGenerator?: RowClassNameGenerator;
387
405
  columnMap: ColumnMap;
406
+ groupToggleTarget?: GroupToggleTarget;
388
407
  highlighted?: boolean;
389
- row: DataSourceRow;
390
408
  offset: number;
409
+ onCellEdit?: CellEditHandler;
391
410
  onClick?: TableRowClickHandlerInternal;
392
411
  onDataEdited?: DataCellEditHandler;
393
412
  onToggleGroup?: (row: DataSourceRow, column: RuntimeColumnDescriptor) => void;
413
+ row: DataSourceRow;
414
+ showBookends?: boolean;
394
415
  zebraStripes?: boolean;
395
416
  }
396
417
 
@@ -414,14 +435,3 @@ export declare type CustomHeader = CustomHeaderComponent | CustomHeaderElement;
414
435
  * [rowIndex, colIndex]
415
436
  */
416
437
  export declare type CellPos = [number, number];
417
-
418
- /**
419
- * Used to track the Table cell (if any) with focus.
420
- */
421
- export declare type CellFocusState = {
422
- el: HTMLElement | null;
423
- outsideViewport: "above" | "below" | false;
424
- placeholderEl: HTMLDivElement | null;
425
- pos: { top: number } | undefined;
426
- cellPos: CellPos | undefined;
427
- };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@vuu-ui/vuu-table-types",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "devDependencies": {
5
- "@vuu-ui/vuu-data-types": "0.9.0",
6
- "@vuu-ui/vuu-filter-types": "0.9.0",
7
- "@vuu-ui/vuu-protocol-types": "0.9.0"
5
+ "@vuu-ui/vuu-data-types": "0.9.2",
6
+ "@vuu-ui/vuu-filter-types": "0.9.2",
7
+ "@vuu-ui/vuu-protocol-types": "0.9.2"
8
8
  },
9
9
  "author": "heswell",
10
10
  "license": "Apache-2.0",