@vuu-ui/vuu-table-types 0.9.1 → 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 +28 -27
  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,6 @@ import type {
28
27
  MouseEvent,
29
28
  ReactElement,
30
29
  } from "react";
31
- import { CellPos } from "@vuu-ui/vuu-table/src/table-dom-utils";
32
30
 
33
31
  export declare type GroupToggleTarget = "toggle-icon" | "group-column";
34
32
 
@@ -43,11 +41,22 @@ export declare type TableHeadings = TableHeading[][];
43
41
 
44
42
  export declare type ValueFormatter = (value: unknown) => string;
45
43
 
46
- export declare type DataCellEditHandler = (
47
- row: DataSourceRow,
48
- columnName: string,
49
- value: VuuRowDataItemType,
50
- ) => 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;
51
60
 
52
61
  export interface TableCellProps {
53
62
  className?: string;
@@ -60,9 +69,12 @@ export interface TableCellProps {
60
69
 
61
70
  export declare type CommitResponse = Promise<true | string>;
62
71
 
63
- export declare type DataItemCommitHandler<
64
- T extends VuuRowDataItemType = VuuRowDataItemType,
65
- > = (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;
66
78
 
67
79
  export declare type TableRowSelectHandler = (
68
80
  row: DataSourceRowObject | null,
@@ -88,7 +100,7 @@ export declare type TableRowClickHandlerInternal = (
88
100
 
89
101
  export interface TableCellRendererProps
90
102
  extends Omit<TableCellProps, "onDataEdited"> {
91
- onCommit?: DataItemCommitHandler;
103
+ onEdit?: DataItemEditHandler;
92
104
  }
93
105
 
94
106
  /**
@@ -267,6 +279,7 @@ export interface ColumnDescriptorCustomRenderer
267
279
  * definitin with internal state values. */
268
280
  export interface RuntimeColumnDescriptor extends ColumnDescriptor {
269
281
  align?: "left" | "right";
282
+ ariaColIndex: number;
270
283
  CellRenderer?: FunctionComponent<TableCellRendererProps>;
271
284
  HeaderCellLabelRenderer?: FunctionComponent<HeaderCellProps>;
272
285
  HeaderCellContentRenderer?: FunctionComponent<HeaderCellProps>;
@@ -277,8 +290,6 @@ export interface RuntimeColumnDescriptor extends ColumnDescriptor {
277
290
  filter?: Filter;
278
291
  flex?: number;
279
292
  heading?: [...string[]];
280
- /** A 1 based index for aria-colindex */
281
- index?: number;
282
293
  isGroup?: boolean;
283
294
  isSystemColumn?: boolean;
284
295
  label: string;
@@ -395,6 +406,7 @@ export interface RowProps extends BaseRowProps {
395
406
  groupToggleTarget?: GroupToggleTarget;
396
407
  highlighted?: boolean;
397
408
  offset: number;
409
+ onCellEdit?: CellEditHandler;
398
410
  onClick?: TableRowClickHandlerInternal;
399
411
  onDataEdited?: DataCellEditHandler;
400
412
  onToggleGroup?: (row: DataSourceRow, column: RuntimeColumnDescriptor) => void;
@@ -423,14 +435,3 @@ export declare type CustomHeader = CustomHeaderComponent | CustomHeaderElement;
423
435
  * [rowIndex, colIndex]
424
436
  */
425
437
  export declare type CellPos = [number, number];
426
-
427
- /**
428
- * Used to track the Table cell (if any) with focus.
429
- */
430
- export declare type CellFocusState = {
431
- el: HTMLElement | null;
432
- outsideViewport: "above" | "below" | false;
433
- placeholderEl: HTMLDivElement | null;
434
- pos: { top: number } | undefined;
435
- cellPos: CellPos | undefined;
436
- };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@vuu-ui/vuu-table-types",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "devDependencies": {
5
- "@vuu-ui/vuu-data-types": "0.9.1",
6
- "@vuu-ui/vuu-filter-types": "0.9.1",
7
- "@vuu-ui/vuu-protocol-types": "0.9.1"
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",