@react-types/table 3.3.4-nightly.3606 → 3.3.4-nightly.3611

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/package.json +4 -4
  2. package/src/index.d.ts +20 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/table",
3
- "version": "3.3.4-nightly.3606+5c1920e50",
3
+ "version": "3.3.4-nightly.3611+e6808d1b5",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "types": "src/index.d.ts",
@@ -9,8 +9,8 @@
9
9
  "url": "https://github.com/adobe/react-spectrum"
10
10
  },
11
11
  "dependencies": {
12
- "@react-types/grid": "3.1.6-nightly.3606+5c1920e50",
13
- "@react-types/shared": "3.0.0-nightly.1906+5c1920e50"
12
+ "@react-types/grid": "3.1.6-nightly.3611+e6808d1b5",
13
+ "@react-types/shared": "3.0.0-nightly.1911+e6808d1b5"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -18,5 +18,5 @@
18
18
  "publishConfig": {
19
19
  "access": "public"
20
20
  },
21
- "gitHead": "5c1920e50d4b2b80c826ca91aff55c97350bf9f9"
21
+ "gitHead": "e6808d1b5e80cef7af7e63974f658043593b2e1e"
22
22
  }
package/src/index.d.ts CHANGED
@@ -14,6 +14,13 @@ import {AriaLabelingProps, AsyncLoadable, CollectionChildren, DOMProps, LoadingS
14
14
  import {GridCollection, GridNode} from '@react-types/grid';
15
15
  import {Key, ReactElement, ReactNode} from 'react';
16
16
 
17
+ /** Widths that result in a constant pixel value for the same Table width. */
18
+ export type ColumnStaticSize = number | `${number}` | `${number}%`; // match regex: /^(\d+)(?=%$)/
19
+ /** Widths that change size in relation to the remaining space and in ratio to other dynamic columns. */
20
+ export type ColumnDynamicSize = `${number}fr`; // match regex: /^(\d+)(?=fr$)/
21
+ /** All possible sizes a column can be assigned. */
22
+ export type ColumnSize = ColumnStaticSize | ColumnDynamicSize;
23
+
17
24
  export interface TableProps<T> extends MultipleSelection, Sortable {
18
25
  /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */
19
26
  children: [ReactElement<TableHeaderProps<T>>, ReactElement<TableBodyProps<T>>],
@@ -40,14 +47,15 @@ export interface SpectrumTableProps<T> extends TableProps<T>, SpectrumSelectionP
40
47
  onAction?: (key: Key) => void,
41
48
  /**
42
49
  * Handler that is called when a user performs a column resize.
43
- * @private
50
+ * Can be used with the width property on columns to put the column widths into
51
+ * a controlled state.
44
52
  */
45
- onColumnResize?: (affectedColumns: {key: Key, width: number}[]) => void,
53
+ onResize?: (widths: Map<Key, ColumnSize>) => void,
46
54
  /**
47
- * Handler that is called when a column resize ends.
48
- * @private
55
+ * Handler that is called after a user performs a column resize.
56
+ * Can be used to store the widths of columns for another future session.
49
57
  */
50
- onColumnResizeEnd?: (affectedColumns: {key: Key, width: number}[]) => void
58
+ onResizeEnd?: (widths: Map<Key, ColumnSize>) => void
51
59
  }
52
60
 
53
61
  export interface TableHeaderProps<T> {
@@ -67,20 +75,14 @@ export interface ColumnProps<T> {
67
75
  /** A list of child columns used when dynamically rendering nested child columns. */
68
76
  childColumns?: T[],
69
77
  /** The width of the column. */
70
- width?: number | string,
78
+ width?: ColumnSize | null,
71
79
  /** The minimum width of the column. */
72
- minWidth?: number | string,
80
+ minWidth?: ColumnStaticSize | null,
73
81
  /** The maximum width of the column. */
74
- maxWidth?: number | string,
75
- /**
76
- * The default width of the column.
77
- * @private
78
- */
79
- defaultWidth?: number | string,
80
- /**
81
- * Whether the column allows resizing.
82
- * @private
83
- */
82
+ maxWidth?: ColumnStaticSize | null,
83
+ /** The default width of the column. */
84
+ defaultWidth?: ColumnSize | null,
85
+ /** Whether the column allows resizing. */
84
86
  allowsResizing?: boolean,
85
87
  /** Whether the column allows sorting. */
86
88
  allowsSorting?: boolean,
@@ -141,7 +143,7 @@ export type CellElement = ReactElement<CellProps>;
141
143
  export type CellRenderer = (columnKey: Key) => CellElement;
142
144
 
143
145
  export interface TableCollection<T> extends GridCollection<T> {
144
- // TODO perhaps elaborate on this? maybe not clear enought, essentially returns the table header rows (e.g. in a tiered headers table, will return the nodes containing the top tier column, next tier, etc)
146
+ // TODO perhaps elaborate on this? maybe not clear enough, essentially returns the table header rows (e.g. in a tiered headers table, will return the nodes containing the top tier column, next tier, etc)
145
147
  /** A list of header row nodes in the table. */
146
148
  headerRows: GridNode<T>[],
147
149
  /** A list of column nodes in the table. */