@react-stately/table 3.11.3-nightly.4252 → 3.11.3-nightly.4266
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.
- package/dist/import.mjs +11 -2
- package/dist/main.js +11 -2
- package/dist/main.js.map +1 -1
- package/dist/module.js +11 -2
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +7 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/Cell.ts +2 -2
- package/src/Column.ts +1 -1
- package/src/Row.ts +1 -1
- package/src/TableBody.ts +1 -1
- package/src/TableCollection.ts +2 -1
- package/src/TableColumnLayout.ts +1 -1
- package/src/TableHeader.ts +1 -1
- package/src/TableUtils.ts +1 -1
- package/src/useTableColumnResizeState.ts +16 -1
- package/src/useTableState.ts +2 -2
- package/src/useTreeGridState.ts +2 -1
package/src/TableCollection.ts
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
+
|
|
12
13
|
import {getFirstItem, getLastItem} from '@react-stately/collections';
|
|
13
14
|
import {GridCollection} from '@react-stately/grid';
|
|
14
15
|
import {GridNode} from '@react-types/grid';
|
|
15
16
|
import {TableCollection as ITableCollection} from '@react-types/table';
|
|
16
|
-
import {Key} from 'react';
|
|
17
|
+
import {Key} from '@react-types/shared';
|
|
17
18
|
|
|
18
19
|
interface GridCollectionOptions {
|
|
19
20
|
showSelectionCheckboxes?: boolean,
|
package/src/TableColumnLayout.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from './TableUtils';
|
|
20
20
|
import {ColumnSize, TableCollection} from '@react-types/table';
|
|
21
21
|
import {GridNode} from '@react-types/grid';
|
|
22
|
-
import {Key} from 'react';
|
|
22
|
+
import {Key} from '@react-types/shared';
|
|
23
23
|
|
|
24
24
|
export interface TableColumnLayoutOptions<T> {
|
|
25
25
|
getDefaultWidth?: (column: GridNode<T>) => ColumnSize | null | undefined,
|
package/src/TableHeader.ts
CHANGED
|
@@ -55,5 +55,5 @@ TableHeader.getCollectionNode = function* getCollectionNode<T>(props: TableHeade
|
|
|
55
55
|
* as children, or generated dynamically using a function based on the data passed to the `columns` prop.
|
|
56
56
|
*/
|
|
57
57
|
// We don't want getCollectionNode to show up in the type definition
|
|
58
|
-
let _TableHeader = TableHeader as <T>(props: TableHeaderProps<T>) => JSX.Element;
|
|
58
|
+
let _TableHeader = TableHeader as <T>(props: TableHeaderProps<T>) => React.JSX.Element;
|
|
59
59
|
export {_TableHeader as TableHeader};
|
package/src/TableUtils.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {ColumnSize} from '@react-types/table';
|
|
14
|
-
import {Key} from 'react';
|
|
14
|
+
import {Key} from '@react-types/shared';
|
|
15
15
|
|
|
16
16
|
// numbers and percents are considered static. *fr units or a lack of units are considered dynamic.
|
|
17
17
|
export function isStatic(width: number | string): boolean {
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
import {ColumnSize} from '@react-types/table';
|
|
14
14
|
import {GridNode} from '@react-types/grid';
|
|
15
|
-
import {Key
|
|
15
|
+
import {Key} from '@react-types/shared';
|
|
16
16
|
import {TableColumnLayout} from './TableColumnLayout';
|
|
17
17
|
import {TableState} from './useTableState';
|
|
18
|
+
import {useCallback, useMemo, useState} from 'react';
|
|
18
19
|
|
|
19
20
|
export interface TableColumnResizeStateProps<T> {
|
|
20
21
|
/**
|
|
@@ -80,6 +81,20 @@ export function useTableColumnResizeState<T>(props: TableColumnResizeStateProps<
|
|
|
80
81
|
let [uncontrolledWidths, setUncontrolledWidths] = useState(() =>
|
|
81
82
|
columnLayout.getInitialUncontrolledWidths(uncontrolledColumns)
|
|
82
83
|
);
|
|
84
|
+
|
|
85
|
+
// Update uncontrolled widths if the columns changed.
|
|
86
|
+
let [lastColumns, setLastColumns] = useState(state.collection.columns);
|
|
87
|
+
if (state.collection.columns !== lastColumns) {
|
|
88
|
+
if (
|
|
89
|
+
state.collection.columns.length !== lastColumns.length ||
|
|
90
|
+
state.collection.columns.some((c, i) => c.key !== lastColumns[i].key)
|
|
91
|
+
) {
|
|
92
|
+
let newUncontrolledWidths = columnLayout.getInitialUncontrolledWidths(uncontrolledColumns);
|
|
93
|
+
setUncontrolledWidths(newUncontrolledWidths);
|
|
94
|
+
}
|
|
95
|
+
setLastColumns(state.collection.columns);
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
// combine columns back into one map that maintains same order as the columns
|
|
84
99
|
let colWidths = useMemo(() =>
|
|
85
100
|
columnLayout.recombineColumns(state.collection.columns, uncontrolledWidths, uncontrolledColumns, controlledColumns)
|
package/src/useTableState.ts
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
import {GridState, useGridState} from '@react-stately/grid';
|
|
14
14
|
import {TableCollection as ITableCollection, TableBodyProps, TableHeaderProps} from '@react-types/table';
|
|
15
|
-
import {Key,
|
|
15
|
+
import {Key, Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared';
|
|
16
16
|
import {MultipleSelectionStateProps} from '@react-stately/selection';
|
|
17
|
-
import {
|
|
17
|
+
import {ReactElement, useCallback, useMemo, useState} from 'react';
|
|
18
18
|
import {TableCollection} from './TableCollection';
|
|
19
19
|
import {useCollection} from '@react-stately/collections';
|
|
20
20
|
|
package/src/useTreeGridState.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import {CollectionBuilder} from '@react-stately/collections';
|
|
14
14
|
import {GridNode} from '@react-types/grid';
|
|
15
|
-
import {Key
|
|
15
|
+
import {Key} from '@react-types/shared';
|
|
16
|
+
import {ReactElement, useMemo} from 'react';
|
|
16
17
|
import {TableCollection} from './TableCollection';
|
|
17
18
|
import {tableNestedRows} from '@react-stately/flags';
|
|
18
19
|
import {TableState, TableStateProps, useTableState} from './useTableState';
|