@vuu-ui/vuu-table-types 0.9.1 → 0.9.3

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 +40 -30
  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,19 +14,20 @@ 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,
22
21
  RowClassNameGenerator,
23
22
  } from "@vuu-ui/vuu-utils";
24
23
  import type {
24
+ ComponentType,
25
25
  CSSProperties,
26
26
  FunctionComponent,
27
+ FunctionComponentElement,
27
28
  HTMLAttributes,
28
29
  MouseEvent,
29
- ReactElement,
30
30
  } from "react";
31
- import { CellPos } from "@vuu-ui/vuu-table/src/table-dom-utils";
32
31
 
33
32
  export declare type GroupToggleTarget = "toggle-icon" | "group-column";
34
33
 
@@ -43,11 +42,22 @@ export declare type TableHeadings = TableHeading[][];
43
42
 
44
43
  export declare type ValueFormatter = (value: unknown) => string;
45
44
 
46
- export declare type DataCellEditHandler = (
47
- row: DataSourceRow,
48
- columnName: string,
49
- value: VuuRowDataItemType,
50
- ) => Promise<string | true>;
45
+ export interface EditEventState {
46
+ editType?: EditType;
47
+ isValid?: boolean;
48
+ // value: unknown;
49
+ previousValue?: VuuRowDataItemType;
50
+ value: VuuRowDataItemType;
51
+ }
52
+
53
+ export interface DataCellEditEvent extends EditEventState {
54
+ row: DataSourceRow;
55
+ columnName: string;
56
+ }
57
+
58
+ export declare type DataCellEditNotification = (
59
+ editEvent: DataCellEditEvent,
60
+ ) => void;
51
61
 
52
62
  export interface TableCellProps {
53
63
  className?: string;
@@ -60,9 +70,12 @@ export interface TableCellProps {
60
70
 
61
71
  export declare type CommitResponse = Promise<true | string>;
62
72
 
63
- export declare type DataItemCommitHandler<
64
- T extends VuuRowDataItemType = VuuRowDataItemType,
65
- > = (value: T) => CommitResponse;
73
+ export declare type EditType = "commit" | "change" | "cancel";
74
+
75
+ declare type DataItemEditHandler<T extends EditType = EditType> = (
76
+ editState: EditEventState,
77
+ editPhase: T,
78
+ ) => T extends "commit" ? Promise<string | true> : void;
66
79
 
67
80
  export declare type TableRowSelectHandler = (
68
81
  row: DataSourceRowObject | null,
@@ -88,7 +101,7 @@ export declare type TableRowClickHandlerInternal = (
88
101
 
89
102
  export interface TableCellRendererProps
90
103
  extends Omit<TableCellProps, "onDataEdited"> {
91
- onCommit?: DataItemCommitHandler;
104
+ onEdit?: DataItemEditHandler;
92
105
  }
93
106
 
94
107
  /**
@@ -255,6 +268,13 @@ export interface ColumnDescriptor extends DataValueDescriptor {
255
268
  pin?: PinLocation;
256
269
  resizeable?: boolean;
257
270
  sortable?: boolean;
271
+ /**
272
+ * 'client' columns will not receive data from dataSource.
273
+ * They can be used with a custom renderer, e.g to render
274
+ * action buttons.
275
+ * default is 'server'
276
+ */
277
+ source?: "client" | "server";
258
278
  width?: number;
259
279
  }
260
280
 
@@ -267,6 +287,7 @@ export interface ColumnDescriptorCustomRenderer
267
287
  * definitin with internal state values. */
268
288
  export interface RuntimeColumnDescriptor extends ColumnDescriptor {
269
289
  align?: "left" | "right";
290
+ ariaColIndex: number;
270
291
  CellRenderer?: FunctionComponent<TableCellRendererProps>;
271
292
  HeaderCellLabelRenderer?: FunctionComponent<HeaderCellProps>;
272
293
  HeaderCellContentRenderer?: FunctionComponent<HeaderCellProps>;
@@ -277,8 +298,6 @@ export interface RuntimeColumnDescriptor extends ColumnDescriptor {
277
298
  filter?: Filter;
278
299
  flex?: number;
279
300
  heading?: [...string[]];
280
- /** A 1 based index for aria-colindex */
281
- index?: number;
282
301
  isGroup?: boolean;
283
302
  isSystemColumn?: boolean;
284
303
  label: string;
@@ -395,6 +414,7 @@ export interface RowProps extends BaseRowProps {
395
414
  groupToggleTarget?: GroupToggleTarget;
396
415
  highlighted?: boolean;
397
416
  offset: number;
417
+ onCellEdit?: CellEditHandler;
398
418
  onClick?: TableRowClickHandlerInternal;
399
419
  onDataEdited?: DataCellEditHandler;
400
420
  onToggleGroup?: (row: DataSourceRow, column: RuntimeColumnDescriptor) => void;
@@ -414,8 +434,9 @@ export interface HeaderCellProps
414
434
 
415
435
  export declare type TableConfigChangeHandler = (config: TableConfig) => void;
416
436
 
417
- export declare type CustomHeaderComponent = FC<BaseRowProps>;
418
- export declare type CustomHeaderElement = ReactElement;
437
+ export declare type CustomHeaderComponent = ComponentType<BaseRowProps>;
438
+ export declare type CustomHeaderElement =
439
+ FunctionComponentElement<BaseRowProps>;
419
440
  export declare type CustomHeader = CustomHeaderComponent | CustomHeaderElement;
420
441
 
421
442
  /**
@@ -423,14 +444,3 @@ export declare type CustomHeader = CustomHeaderComponent | CustomHeaderElement;
423
444
  * [rowIndex, colIndex]
424
445
  */
425
446
  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.3",
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.3",
6
+ "@vuu-ui/vuu-filter-types": "0.9.3",
7
+ "@vuu-ui/vuu-protocol-types": "0.9.3"
8
8
  },
9
9
  "author": "heswell",
10
10
  "license": "Apache-2.0",