@react-stately/table 3.2.0 → 3.2.1-nightly.3287

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.
@@ -10,12 +10,12 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- // import {AffectedColumnWidths} from './useTableColumnResizeState';
13
+ import {AffectedColumnWidths, useTableColumnResizeState} from './useTableColumnResizeState';
14
14
  import {CollectionBase, Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared';
15
- // import {GridNode} from '@react-types/grid';
15
+ import {GridNode} from '@react-types/grid';
16
16
  import {GridState, useGridState} from '@react-stately/grid';
17
17
  import {TableCollection as ITableCollection} from '@react-types/table';
18
- import {Key, useMemo} from 'react';
18
+ import {Key, MutableRefObject, useMemo} from 'react';
19
19
  import {MultipleSelectionStateProps} from '@react-stately/selection';
20
20
  import {TableCollection} from './TableCollection';
21
21
  import {useCollection} from '@react-stately/collections';
@@ -28,25 +28,25 @@ export interface TableState<T> extends GridState<T, ITableCollection<T>> {
28
28
  /** The current sorted column and direction. */
29
29
  sortDescriptor: SortDescriptor,
30
30
  /** Calls the provided onSortChange handler with the provided column key and sort direction. */
31
- sort(columnKey: Key, direction?: 'ascending' | 'descending'): void
32
- // /** A map of all the column widths by key. */
33
- // columnWidths: MutableRefObject<Map<Key, number>>,
34
- // /** Boolean for if a column is being resized. */
35
- // isResizingColumn: boolean,
36
- // /** Getter for column width. */
37
- // getColumnWidth(key: Key): number,
38
- // /** Getter for column min width. */
39
- // getColumnMinWidth(key: Key): number,
40
- // /** Getter for column max widths. */
41
- // getColumnMaxWidth(key: Key): number,
42
- // /** Trigger a resize and recalc. */
43
- // onColumnResize: (column: GridNode<T>, width: number) => void,
44
- // /** Runs at the start of resizing. */
45
- // onColumnResizeStart: () => void,
46
- // /** Triggers the onColumnResizeEnd prop. */
47
- // onColumnResizeEnd: () => void,
48
- // /** Need to be able to set the table width so that it can be used to calculate the column widths, this will trigger a recalc. */
49
- // setTableWidth: (width: number) => void
31
+ sort(columnKey: Key, direction?: 'ascending' | 'descending'): void,
32
+ /** A map of all the column widths by key. */
33
+ columnWidths: MutableRefObject<Map<Key, number>>,
34
+ /** Boolean for if a column is being resized. */
35
+ isResizingColumn: boolean,
36
+ /** Getter for column width. */
37
+ getColumnWidth(key: Key): number,
38
+ /** Getter for column min width. */
39
+ getColumnMinWidth(key: Key): number,
40
+ /** Getter for column max widths. */
41
+ getColumnMaxWidth(key: Key): number,
42
+ /** Trigger a resize and recalc. */
43
+ onColumnResize: (column: GridNode<T>, width: number) => void,
44
+ /** Runs at the start of resizing. */
45
+ onColumnResizeStart: () => void,
46
+ /** Triggers the onColumnResizeEnd prop. */
47
+ onColumnResizeEnd: () => void,
48
+ /** Need to be able to set the table width so that it can be used to calculate the column widths, this will trigger a recalc. */
49
+ setTableWidth: (width: number) => void
50
50
  }
51
51
 
52
52
  export interface CollectionBuilderContext<T> {
@@ -57,13 +57,13 @@ export interface CollectionBuilderContext<T> {
57
57
 
58
58
  export interface TableStateProps<T> extends CollectionBase<T>, MultipleSelectionStateProps, Sortable {
59
59
  /** Whether the row selection checkboxes should be displayed. */
60
- showSelectionCheckboxes?: boolean
61
- // /** Function for determining the default width of columns. */
62
- // getDefaultWidth?: (props) => string | number,
63
- // /** Callback that is invoked during the entirety of the resize event. */
64
- // onColumnResize?: (affectedColumnWidths: AffectedColumnWidths) => void,
65
- // /** Callback that is invoked when the resize event is ended. */
66
- // onColumnResizeEnd?: (affectedColumnWidths: AffectedColumnWidths) => void
60
+ showSelectionCheckboxes?: boolean,
61
+ /** Function for determining the default width of columns. */
62
+ getDefaultWidth?: (props) => string | number,
63
+ /** Callback that is invoked during the entirety of the resize event. */
64
+ onColumnResize?: (affectedColumnWidths: AffectedColumnWidths) => void,
65
+ /** Callback that is invoked when the resize event is ended. */
66
+ onColumnResizeEnd?: (affectedColumnWidths: AffectedColumnWidths) => void
67
67
  }
68
68
 
69
69
  const OPPOSITE_SORT_DIRECTION = {
@@ -90,8 +90,8 @@ export function useTableState<T extends object>(props: TableStateProps<T>): Tabl
90
90
  context
91
91
  );
92
92
  let {disabledKeys, selectionManager} = useGridState({...props, collection});
93
-
94
- // const tableColumnResizeState = useTableColumnResizeState({columns: collection.columns, getDefaultWidth: props.getDefaultWidth, onColumnResize: props.onColumnResize, onColumnResizeEnd: props.onColumnResizeEnd});
93
+
94
+ const tableColumnResizeState = useTableColumnResizeState({columns: collection.columns, getDefaultWidth: props.getDefaultWidth, onColumnResize: props.onColumnResize, onColumnResizeEnd: props.onColumnResizeEnd});
95
95
 
96
96
 
97
97
  return {
@@ -107,7 +107,7 @@ export function useTableState<T extends object>(props: TableStateProps<T>): Tabl
107
107
  ? OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction]
108
108
  : 'ascending')
109
109
  });
110
- }
111
- // ...tableColumnResizeState
110
+ },
111
+ ...tableColumnResizeState
112
112
  };
113
113
  }