@react-stately/table 3.14.4 → 3.15.0
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 +2 -2
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -2
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/useTableState.main.js +14 -0
- package/dist/useTableState.main.js.map +1 -1
- package/dist/useTableState.mjs +14 -1
- package/dist/useTableState.module.js +14 -1
- package/dist/useTableState.module.js.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +1 -1
- package/src/useTableState.ts +15 -0
package/dist/import.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {useTableColumnResizeState as $292bc4e09cd0eb62$export$cb895dcf85db1319} from "./useTableColumnResizeState.mjs";
|
|
2
|
-
import {useTableState as $4a0dd036d492cee4$export$907bcc6c48325fd6} from "./useTableState.mjs";
|
|
2
|
+
import {UNSTABLE_useFilteredTableState as $4a0dd036d492cee4$export$31447e17397b15c2, useTableState as $4a0dd036d492cee4$export$907bcc6c48325fd6} from "./useTableState.mjs";
|
|
3
3
|
import {TableHeader as $312ae3b56a94a86e$export$f850895b287ef28e} from "./TableHeader.mjs";
|
|
4
4
|
import {TableBody as $4ae5314bf50db1a3$export$76ccd210b9029917} from "./TableBody.mjs";
|
|
5
5
|
import {Column as $1cd244557c2f97d5$export$816b5d811295e6bc} from "./Column.mjs";
|
|
@@ -33,5 +33,5 @@ import {Section as $6555104ff085bef4$re_export$Section} from "@react-stately/col
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
export {$292bc4e09cd0eb62$export$cb895dcf85db1319 as useTableColumnResizeState, $4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState, $312ae3b56a94a86e$export$f850895b287ef28e as TableHeader, $4ae5314bf50db1a3$export$76ccd210b9029917 as TableBody, $1cd244557c2f97d5$export$816b5d811295e6bc as Column, $70d70eb16ea48428$export$b59bdbef9ce70de2 as Row, $941d1d9a6a28982a$export$f6f0c3fe4ec306ea as Cell, $6555104ff085bef4$re_export$Section as Section, $788781baa30117fa$export$596e1b2e2cf93690 as TableCollection, $788781baa30117fa$export$7c127db850d4e81e as buildHeaderRows, $a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout, $ee65a0057fd99531$export$34dfa8a1622185a4 as UNSTABLE_useTreeGridState};
|
|
36
|
+
export {$292bc4e09cd0eb62$export$cb895dcf85db1319 as useTableColumnResizeState, $4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState, $4a0dd036d492cee4$export$31447e17397b15c2 as UNSTABLE_useFilteredTableState, $312ae3b56a94a86e$export$f850895b287ef28e as TableHeader, $4ae5314bf50db1a3$export$76ccd210b9029917 as TableBody, $1cd244557c2f97d5$export$816b5d811295e6bc as Column, $70d70eb16ea48428$export$b59bdbef9ce70de2 as Row, $941d1d9a6a28982a$export$f6f0c3fe4ec306ea as Cell, $6555104ff085bef4$re_export$Section as Section, $788781baa30117fa$export$596e1b2e2cf93690 as TableCollection, $788781baa30117fa$export$7c127db850d4e81e as buildHeaderRows, $a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout, $ee65a0057fd99531$export$34dfa8a1622185a4 as UNSTABLE_useTreeGridState};
|
|
37
37
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -17,6 +17,7 @@ function $parcel$export(e, n, v, s) {
|
|
|
17
17
|
|
|
18
18
|
$parcel$export(module.exports, "useTableColumnResizeState", () => $7aa22d80cd4ca621$exports.useTableColumnResizeState);
|
|
19
19
|
$parcel$export(module.exports, "useTableState", () => $e3f7784147dde23d$exports.useTableState);
|
|
20
|
+
$parcel$export(module.exports, "UNSTABLE_useFilteredTableState", () => $e3f7784147dde23d$exports.UNSTABLE_useFilteredTableState);
|
|
20
21
|
$parcel$export(module.exports, "TableHeader", () => $f45775f5d6f744fa$exports.TableHeader);
|
|
21
22
|
$parcel$export(module.exports, "TableBody", () => $6ec527db6a3a5692$exports.TableBody);
|
|
22
23
|
$parcel$export(module.exports, "Column", () => $714483d9f6ca4c55$exports.Column);
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/table/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {TableColumnResizeState, TableColumnResizeStateProps} from './useTableColumnResizeState';\nexport type {TableState, CollectionBuilderContext, TableStateProps} from './useTableState';\nexport type {TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps} from '@react-types/table';\nexport type {TreeGridState, TreeGridStateProps} from './useTreeGridState';\n\nexport {useTableColumnResizeState} from './useTableColumnResizeState';\nexport {useTableState, UNSTABLE_useFilteredTableState} from './useTableState';\nexport {TableHeader} from './TableHeader';\nexport {TableBody} from './TableBody';\nexport {Column} from './Column';\nexport {Row} from './Row';\nexport {Cell} from './Cell';\nexport {Section} from '@react-stately/collections';\nexport {TableCollection, buildHeaderRows} from './TableCollection';\nexport {TableColumnLayout} from './TableColumnLayout';\nexport {UNSTABLE_useTreeGridState} from './useTreeGridState';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {useTableColumnResizeState as $292bc4e09cd0eb62$export$cb895dcf85db1319} from "./useTableColumnResizeState.module.js";
|
|
2
|
-
import {useTableState as $4a0dd036d492cee4$export$907bcc6c48325fd6} from "./useTableState.module.js";
|
|
2
|
+
import {UNSTABLE_useFilteredTableState as $4a0dd036d492cee4$export$31447e17397b15c2, useTableState as $4a0dd036d492cee4$export$907bcc6c48325fd6} from "./useTableState.module.js";
|
|
3
3
|
import {TableHeader as $312ae3b56a94a86e$export$f850895b287ef28e} from "./TableHeader.module.js";
|
|
4
4
|
import {TableBody as $4ae5314bf50db1a3$export$76ccd210b9029917} from "./TableBody.module.js";
|
|
5
5
|
import {Column as $1cd244557c2f97d5$export$816b5d811295e6bc} from "./Column.module.js";
|
|
@@ -33,5 +33,5 @@ import {Section as $6555104ff085bef4$re_export$Section} from "@react-stately/col
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
export {$292bc4e09cd0eb62$export$cb895dcf85db1319 as useTableColumnResizeState, $4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState, $312ae3b56a94a86e$export$f850895b287ef28e as TableHeader, $4ae5314bf50db1a3$export$76ccd210b9029917 as TableBody, $1cd244557c2f97d5$export$816b5d811295e6bc as Column, $70d70eb16ea48428$export$b59bdbef9ce70de2 as Row, $941d1d9a6a28982a$export$f6f0c3fe4ec306ea as Cell, $6555104ff085bef4$re_export$Section as Section, $788781baa30117fa$export$596e1b2e2cf93690 as TableCollection, $788781baa30117fa$export$7c127db850d4e81e as buildHeaderRows, $a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout, $ee65a0057fd99531$export$34dfa8a1622185a4 as UNSTABLE_useTreeGridState};
|
|
36
|
+
export {$292bc4e09cd0eb62$export$cb895dcf85db1319 as useTableColumnResizeState, $4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState, $4a0dd036d492cee4$export$31447e17397b15c2 as UNSTABLE_useFilteredTableState, $312ae3b56a94a86e$export$f850895b287ef28e as TableHeader, $4ae5314bf50db1a3$export$76ccd210b9029917 as TableBody, $1cd244557c2f97d5$export$816b5d811295e6bc as Column, $70d70eb16ea48428$export$b59bdbef9ce70de2 as Row, $941d1d9a6a28982a$export$f6f0c3fe4ec306ea as Cell, $6555104ff085bef4$re_export$Section as Section, $788781baa30117fa$export$596e1b2e2cf93690 as TableCollection, $788781baa30117fa$export$7c127db850d4e81e as buildHeaderRows, $a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout, $ee65a0057fd99531$export$34dfa8a1622185a4 as UNSTABLE_useTreeGridState};
|
|
37
37
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/table/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {TableColumnResizeState, TableColumnResizeStateProps} from './useTableColumnResizeState';\nexport type {TableState, CollectionBuilderContext, TableStateProps} from './useTableState';\nexport type {TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps} from '@react-types/table';\nexport type {TreeGridState, TreeGridStateProps} from './useTreeGridState';\n\nexport {useTableColumnResizeState} from './useTableColumnResizeState';\nexport {useTableState} from './useTableState';\nexport {TableHeader} from './TableHeader';\nexport {TableBody} from './TableBody';\nexport {Column} from './Column';\nexport {Row} from './Row';\nexport {Cell} from './Cell';\nexport {Section} from '@react-stately/collections';\nexport {TableCollection, buildHeaderRows} from './TableCollection';\nexport {TableColumnLayout} from './TableColumnLayout';\nexport {UNSTABLE_useTreeGridState} from './useTreeGridState';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/table/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {TableColumnResizeState, TableColumnResizeStateProps} from './useTableColumnResizeState';\nexport type {TableState, CollectionBuilderContext, TableStateProps} from './useTableState';\nexport type {TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps} from '@react-types/table';\nexport type {TreeGridState, TreeGridStateProps} from './useTreeGridState';\n\nexport {useTableColumnResizeState} from './useTableColumnResizeState';\nexport {useTableState, UNSTABLE_useFilteredTableState} from './useTableState';\nexport {TableHeader} from './TableHeader';\nexport {TableBody} from './TableBody';\nexport {Column} from './Column';\nexport {Row} from './Row';\nexport {Cell} from './Cell';\nexport {Section} from '@react-stately/collections';\nexport {TableCollection, buildHeaderRows} from './TableCollection';\nexport {TableColumnLayout} from './TableColumnLayout';\nexport {UNSTABLE_useTreeGridState} from './useTreeGridState';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -93,6 +93,10 @@ export interface TableStateProps<T> extends MultipleSelectionStateProps, Sortabl
|
|
|
93
93
|
* of columns and rows from props. In addition, it tracks row selection and manages sort order changes.
|
|
94
94
|
*/
|
|
95
95
|
export function useTableState<T extends object>(props: TableStateProps<T>): TableState<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Filters a collection using the provided filter function and returns a new TableState.
|
|
98
|
+
*/
|
|
99
|
+
export function UNSTABLE_useFilteredTableState<T extends object>(state: TableState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): TableState<T>;
|
|
96
100
|
export interface TableColumnResizeStateProps<T> {
|
|
97
101
|
/**
|
|
98
102
|
* Current width of the table or table viewport that the columns
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;ACqBA,mCAA0C,CAAC;IACzC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,KAAK,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;IACzE,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,KAAK,UAAU,GAAG,IAAI,GAAG,SAAS,CAAA;CAC5E;AAED,+BAA+B,CAAC;IAC9B,eAAe,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,KAAK,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;IACxE,kBAAkB,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,KAAK,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3E,YAAY,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAa;IAC3C,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAa;IAC9C,eAAe,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAa;gBAElC,OAAO,EAAE,yBAAyB,CAAC,CAAC;IAKhD,2HAA2H;IAC3H,yCAAyC,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAWtH,iFAAiF;IACjF,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,GAAG,CAAC,GAAG,EAA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AC,EAAE,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9C,kEAAkE;IAClE,4BAA4B,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrD,mEAAmE;IACnE,yBAAyB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;CACpD;AAED;;;GAGG;AACH,0CAA0C,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAmD1G;AC5CD;;;GAGG;AAEH,OAAA,IAAI,aAA8B,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC;ACHjF;;;GAGG;AAEH,OAAA,IAAI,WAA0B,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC;ACgB3E;;;;GAIG;AAEH,OAAA,IAAI,QAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC;ACgClE;;;;GAIG;AAEH,OAAA,IAAI,KAAc,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC;ACrFzD;;GAEG;AAEH,OAAA,IAAI,MAAgB,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,OAAO,CAAC;ACxBtD,YAAY,EAAC,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAU3G,OAAO,EAAC,OAAO,EAAC,MAAM,4BAA4B,CAAC","sources":["packages/@react-stately/table/src/packages/@react-stately/table/src/TableUtils.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/TableColumnLayout.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/TableCollection.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/useTableState.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/useTableColumnResizeState.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/useTreeGridState.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/TableHeader.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/TableBody.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/Column.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/Row.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/Cell.ts","packages/@react-stately/table/src/packages/@react-stately/table/src/index.ts","packages/@react-stately/table/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {TableColumnResizeState, TableColumnResizeStateProps} from './useTableColumnResizeState';\nexport type {TableState, CollectionBuilderContext, TableStateProps} from './useTableState';\nexport type {TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps} from '@react-types/table';\nexport type {TreeGridState, TreeGridStateProps} from './useTreeGridState';\n\nexport {useTableColumnResizeState} from './useTableColumnResizeState';\nexport {useTableState, UNSTABLE_useFilteredTableState} from './useTableState';\nexport {TableHeader} from './TableHeader';\nexport {TableBody} from './TableBody';\nexport {Column} from './Column';\nexport {Row} from './Row';\nexport {Cell} from './Cell';\nexport {Section} from '@react-stately/collections';\nexport {TableCollection, buildHeaderRows} from './TableCollection';\nexport {TableColumnLayout} from './TableColumnLayout';\nexport {UNSTABLE_useTreeGridState} from './useTreeGridState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -9,6 +9,7 @@ function $parcel$export(e, n, v, s) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
$parcel$export(module.exports, "useTableState", () => $e3f7784147dde23d$export$907bcc6c48325fd6);
|
|
12
|
+
$parcel$export(module.exports, "UNSTABLE_useFilteredTableState", () => $e3f7784147dde23d$export$31447e17397b15c2);
|
|
12
13
|
/*
|
|
13
14
|
* Copyright 2020 Adobe. All rights reserved.
|
|
14
15
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -67,6 +68,19 @@ function $e3f7784147dde23d$export$907bcc6c48325fd6(props) {
|
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
}
|
|
71
|
+
function $e3f7784147dde23d$export$31447e17397b15c2(state, filterFn) {
|
|
72
|
+
let collection = (0, $hkaUn$react.useMemo)(()=>filterFn ? state.collection.filter(filterFn) : state.collection, [
|
|
73
|
+
state.collection,
|
|
74
|
+
filterFn
|
|
75
|
+
]);
|
|
76
|
+
let selectionManager = state.selectionManager.withCollection(collection);
|
|
77
|
+
// TODO: handle focus key reset? That logic is in useGridState
|
|
78
|
+
return {
|
|
79
|
+
...state,
|
|
80
|
+
collection: collection,
|
|
81
|
+
selectionManager: selectionManager
|
|
82
|
+
};
|
|
83
|
+
}
|
|
70
84
|
|
|
71
85
|
|
|
72
86
|
//# sourceMappingURL=useTableState.main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiDD,MAAM,gDAA0B;IAC9B,WAAW;IACX,YAAY;AACd;AAMO,SAAS,0CAAgC,KAAyB;IACvE,IAAI,CAAC,8BAA8B,8BAA8B,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC7E,IAAI,iBAAC,gBAAgB,iCAAQ,uBAAuB,mBAAE,eAAe,EAAC,GAAG;IAEzE,IAAI,UAAU,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;YAC3B,yBAAyB,2B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yright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridState, useGridState} from '@react-stately/grid';\nimport {TableCollection as ITableCollection, TableBodyProps, TableHeaderProps} from '@react-types/table';\nimport {Key, Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared';\nimport {MultipleSelectionState, MultipleSelectionStateProps} from '@react-stately/selection';\nimport {ReactElement, useCallback, useMemo, useState} from 'react';\nimport {TableCollection} from './TableCollection';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface TableState<T> extends GridState<T, ITableCollection<T>> {\n /** A collection of rows and columns in the table. */\n collection: ITableCollection<T>,\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes: boolean,\n /** The current sorted column and direction. */\n sortDescriptor: SortDescriptor | null,\n /** Calls the provided onSortChange handler with the provided column key and sort direction. */\n sort(columnKey: Key, direction?: 'ascending' | 'descending'): void,\n /** Whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */\n isKeyboardNavigationDisabled: boolean,\n /** Set whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */\n setKeyboardNavigationDisabled: (val: boolean) => void\n}\n\nexport interface CollectionBuilderContext<T> {\n showSelectionCheckboxes: boolean,\n showDragButtons: boolean,\n selectionMode: SelectionMode,\n columns: Node<T>[]\n}\n\nexport interface TableStateProps<T> extends MultipleSelectionStateProps, Sortable {\n /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */\n children?: [ReactElement<TableHeaderProps<T>>, ReactElement<TableBodyProps<T>>],\n /** A list of row keys to disable. */\n disabledKeys?: Iterable<Key>,\n /** A pre-constructed collection to use instead of building one from items and children. */\n collection?: ITableCollection<T>,\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes?: boolean,\n /** Whether the row drag button should be displayed.\n * @private\n */\n showDragButtons?: boolean,\n /** @private - do not use unless you know what you're doing. */\n UNSAFE_selectionState?: MultipleSelectionState\n}\n\nconst OPPOSITE_SORT_DIRECTION = {\n ascending: 'descending' as SortDirection,\n descending: 'ascending' as SortDirection\n};\n\n/**\n * Provides state management for a table component. Handles building a collection\n * of columns and rows from props. In addition, it tracks row selection and manages sort order changes.\n */\nexport function useTableState<T extends object>(props: TableStateProps<T>): TableState<T> {\n let [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = useState(false);\n let {selectionMode = 'none', showSelectionCheckboxes, showDragButtons} = props;\n\n let context = useMemo(() => ({\n showSelectionCheckboxes: showSelectionCheckboxes && selectionMode !== 'none',\n showDragButtons: showDragButtons,\n selectionMode,\n columns: []\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [props.children, showSelectionCheckboxes, selectionMode, showDragButtons]);\n\n let collection = useCollection<T, ITableCollection<T>>(\n props,\n useCallback((nodes) => new TableCollection(nodes, null, context), [context]),\n context\n );\n let {disabledKeys, selectionManager} = useGridState({\n ...props,\n collection,\n disabledBehavior: props.disabledBehavior || 'selection'\n });\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n showSelectionCheckboxes: props.showSelectionCheckboxes || false,\n sortDescriptor: props.sortDescriptor ?? null,\n isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled,\n setKeyboardNavigationDisabled,\n sort(columnKey: Key, direction?: 'ascending' | 'descending') {\n props.onSortChange?.({\n column: columnKey,\n direction: direction ?? (props.sortDescriptor?.column === columnKey\n ? OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction]\n : 'ascending')\n });\n }\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new TableState.\n */\nexport function UNSTABLE_useFilteredTableState<T extends object>(state: TableState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): TableState<T> {\n let collection = useMemo(() => filterFn ? state.collection.filter!(filterFn) : state.collection, [state.collection, filterFn]) as ITableCollection<T>;\n let selectionManager = state.selectionManager.withCollection(collection);\n // TODO: handle focus key reset? That logic is in useGridState\n\n return {\n ...state,\n collection,\n selectionManager\n };\n}\n"],"names":[],"version":3,"file":"useTableState.main.js.map"}
|
package/dist/useTableState.mjs
CHANGED
|
@@ -61,7 +61,20 @@ function $4a0dd036d492cee4$export$907bcc6c48325fd6(props) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
function $4a0dd036d492cee4$export$31447e17397b15c2(state, filterFn) {
|
|
65
|
+
let collection = (0, $1YSEb$useMemo)(()=>filterFn ? state.collection.filter(filterFn) : state.collection, [
|
|
66
|
+
state.collection,
|
|
67
|
+
filterFn
|
|
68
|
+
]);
|
|
69
|
+
let selectionManager = state.selectionManager.withCollection(collection);
|
|
70
|
+
// TODO: handle focus key reset? That logic is in useGridState
|
|
71
|
+
return {
|
|
72
|
+
...state,
|
|
73
|
+
collection: collection,
|
|
74
|
+
selectionManager: selectionManager
|
|
75
|
+
};
|
|
76
|
+
}
|
|
64
77
|
|
|
65
78
|
|
|
66
|
-
export {$4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState};
|
|
79
|
+
export {$4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState, $4a0dd036d492cee4$export$31447e17397b15c2 as UNSTABLE_useFilteredTableState};
|
|
67
80
|
//# sourceMappingURL=useTableState.module.js.map
|
|
@@ -61,7 +61,20 @@ function $4a0dd036d492cee4$export$907bcc6c48325fd6(props) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
function $4a0dd036d492cee4$export$31447e17397b15c2(state, filterFn) {
|
|
65
|
+
let collection = (0, $1YSEb$useMemo)(()=>filterFn ? state.collection.filter(filterFn) : state.collection, [
|
|
66
|
+
state.collection,
|
|
67
|
+
filterFn
|
|
68
|
+
]);
|
|
69
|
+
let selectionManager = state.selectionManager.withCollection(collection);
|
|
70
|
+
// TODO: handle focus key reset? That logic is in useGridState
|
|
71
|
+
return {
|
|
72
|
+
...state,
|
|
73
|
+
collection: collection,
|
|
74
|
+
selectionManager: selectionManager
|
|
75
|
+
};
|
|
76
|
+
}
|
|
64
77
|
|
|
65
78
|
|
|
66
|
-
export {$4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState};
|
|
79
|
+
export {$4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState, $4a0dd036d492cee4$export$31447e17397b15c2 as UNSTABLE_useFilteredTableState};
|
|
67
80
|
//# sourceMappingURL=useTableState.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAiDD,MAAM,gDAA0B;IAC9B,WAAW;IACX,YAAY;AACd;AAMO,SAAS,0CAAgC,KAAyB;IACvE,IAAI,CAAC,8BAA8B,8BAA8B,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7E,IAAI,iBAAC,gBAAgB,iCAAQ,uBAAuB,mBAAE,eAAe,EAAC,GAAG;IAEzE,IAAI,UAAU,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YAC3B,yBAAyB,2BAA2B,kBAAkB;YACtE,iBAAiB;2BACjB;YACA,SAAS,EAAE;QAEb,CAAA,GAAI;QAAC,MAAM,QAAQ;QAAE;QAAyB;QAAe;KAAgB;IAE7E,IAAI,aAAa,CAAA,GAAA,oBAAY,EAC3B,OACA,CAAA,GAAA,kBAAU,EAAE,CAAC,QAAU,IAAI,CAAA,GAAA,yCAAc,EAAE,OAAO,MAAM,UAAU;QAAC;KAAQ,GAC3E;IAEF,IAAI,gBAAC,YAAY,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE;QAClD,GAAG,KAAK;oBACR;QACA,kBAAkB,MAAM,gBAAgB,IAAI;IAC9C;QAOkB;IALlB,OAAO;oBACL;sBACA;0BACA;QACA,yBAAyB,MAAM,uBAAuB,IAAI;QAC1D,gBAAgB,CAAA,wBAAA,MAAM,cAAc,cAApB,mCAAA,wBAAwB;QACxC,8BAA8B,WAAW,IAAI,KAAK,KAAK;uCACvD;QACA,MAAK,SAAc,EAAE,SAAsC;gBAG9B,uBAF3B;aAAA,sBAAA,MAAM,YAAY,cAAlB,0CAAA,yBAAA,OAAqB;gBACnB,QAAQ;gBACR,WAAW,sBAAA,uBAAA,YAAc,EAAA,wBAAA,MAAM,cAAc,cAApB,4CAAA,sBAAsB,MAAM,MAAK,YACtD,6CAAuB,CAAC,MAAM,cAAc,CAAC,SAAS,CAAC,GACvD;YACN;QACF;IACF;AACF","sources":["packages/@react-stately/table/src/useTableState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridState, useGridState} from '@react-stately/grid';\nimport {TableCollection as ITableCollection, TableBodyProps, TableHeaderProps} from '@react-types/table';\nimport {Key, Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared';\nimport {MultipleSelectionState, MultipleSelectionStateProps} from '@react-stately/selection';\nimport {ReactElement, useCallback, useMemo, useState} from 'react';\nimport {TableCollection} from './TableCollection';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface TableState<T> extends GridState<T, ITableCollection<T>> {\n /** A collection of rows and columns in the table. */\n collection: ITableCollection<T>,\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes: boolean,\n /** The current sorted column and direction. */\n sortDescriptor: SortDescriptor | null,\n /** Calls the provided onSortChange handler with the provided column key and sort direction. */\n sort(columnKey: Key, direction?: 'ascending' | 'descending'): void,\n /** Whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */\n isKeyboardNavigationDisabled: boolean,\n /** Set whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */\n setKeyboardNavigationDisabled: (val: boolean) => void\n}\n\nexport interface CollectionBuilderContext<T> {\n showSelectionCheckboxes: boolean,\n showDragButtons: boolean,\n selectionMode: SelectionMode,\n columns: Node<T>[]\n}\n\nexport interface TableStateProps<T> extends MultipleSelectionStateProps, Sortable {\n /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */\n children?: [ReactElement<TableHeaderProps<T>>, ReactElement<TableBodyProps<T>>],\n /** A list of row keys to disable. */\n disabledKeys?: Iterable<Key>,\n /** A pre-constructed collection to use instead of building one from items and children. */\n collection?: ITableCollection<T>,\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes?: boolean,\n /** Whether the row drag button should be displayed.\n * @private\n */\n showDragButtons?: boolean,\n /** @private - do not use unless you know what you're doing. */\n UNSAFE_selectionState?: MultipleSelectionState\n}\n\nconst OPPOSITE_SORT_DIRECTION = {\n ascending: 'descending' as SortDirection,\n descending: 'ascending' as SortDirection\n};\n\n/**\n * Provides state management for a table component. Handles building a collection\n * of columns and rows from props. In addition, it tracks row selection and manages sort order changes.\n */\nexport function useTableState<T extends object>(props: TableStateProps<T>): TableState<T> {\n let [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = useState(false);\n let {selectionMode = 'none', showSelectionCheckboxes, showDragButtons} = props;\n\n let context = useMemo(() => ({\n showSelectionCheckboxes: showSelectionCheckboxes && selectionMode !== 'none',\n showDragButtons: showDragButtons,\n selectionMode,\n columns: []\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [props.children, showSelectionCheckboxes, selectionMode, showDragButtons]);\n\n let collection = useCollection<T, ITableCollection<T>>(\n props,\n useCallback((nodes) => new TableCollection(nodes, null, context), [context]),\n context\n );\n let {disabledKeys, selectionManager} = useGridState({\n ...props,\n collection,\n disabledBehavior: props.disabledBehavior || 'selection'\n });\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n showSelectionCheckboxes: props.showSelectionCheckboxes || false,\n sortDescriptor: props.sortDescriptor ?? null,\n isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled,\n setKeyboardNavigationDisabled,\n sort(columnKey: Key, direction?: 'ascending' | 'descending') {\n props.onSortChange?.({\n column: columnKey,\n direction: direction ?? (props.sortDescriptor?.column === columnKey\n ? OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction]\n : 'ascending')\n });\n }\n };\n}\n"],"names":[],"version":3,"file":"useTableState.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAiDD,MAAM,gDAA0B;IAC9B,WAAW;IACX,YAAY;AACd;AAMO,SAAS,0CAAgC,KAAyB;IACvE,IAAI,CAAC,8BAA8B,8BAA8B,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7E,IAAI,iBAAC,gBAAgB,iCAAQ,uBAAuB,mBAAE,eAAe,EAAC,GAAG;IAEzE,IAAI,UAAU,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YAC3B,yBAAyB,2BAA2B,kBAAkB;YACtE,iBAAiB;2BACjB;YACA,SAAS,EAAE;QAEb,CAAA,GAAI;QAAC,MAAM,QAAQ;QAAE;QAAyB;QAAe;KAAgB;IAE7E,IAAI,aAAa,CAAA,GAAA,oBAAY,EAC3B,OACA,CAAA,GAAA,kBAAU,EAAE,CAAC,QAAU,IAAI,CAAA,GAAA,yCAAc,EAAE,OAAO,MAAM,UAAU;QAAC;KAAQ,GAC3E;IAEF,IAAI,gBAAC,YAAY,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE;QAClD,GAAG,KAAK;oBACR;QACA,kBAAkB,MAAM,gBAAgB,IAAI;IAC9C;QAOkB;IALlB,OAAO;oBACL;sBACA;0BACA;QACA,yBAAyB,MAAM,uBAAuB,IAAI;QAC1D,gBAAgB,CAAA,wBAAA,MAAM,cAAc,cAApB,mCAAA,wBAAwB;QACxC,8BAA8B,WAAW,IAAI,KAAK,KAAK;uCACvD;QACA,MAAK,SAAc,EAAE,SAAsC;gBAG9B,uBAF3B;aAAA,sBAAA,MAAM,YAAY,cAAlB,0CAAA,yBAAA,OAAqB;gBACnB,QAAQ;gBACR,WAAW,sBAAA,uBAAA,YAAc,EAAA,wBAAA,MAAM,cAAc,cAApB,4CAAA,sBAAsB,MAAM,MAAK,YACtD,6CAAuB,CAAC,MAAM,cAAc,CAAC,SAAS,CAAC,GACvD;YACN;QACF;IACF;AACF;AAKO,SAAS,0CAAiD,KAAoB,EAAE,QAA4E;IACjK,IAAI,aAAa,CAAA,GAAA,cAAM,EAAE,IAAM,WAAW,MAAM,UAAU,CAAC,MAAM,CAAE,YAAY,MAAM,UAAU,EAAE;QAAC,MAAM,UAAU;QAAE;KAAS;IAC7H,IAAI,mBAAmB,MAAM,gBAAgB,CAAC,cAAc,CAAC;IAC7D,8DAA8D;IAE9D,OAAO;QACL,GAAG,KAAK;oBACR;0BACA;IACF;AACF","sources":["packages/@react-stately/table/src/useTableState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {GridState, useGridState} from '@react-stately/grid';\nimport {TableCollection as ITableCollection, TableBodyProps, TableHeaderProps} from '@react-types/table';\nimport {Key, Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared';\nimport {MultipleSelectionState, MultipleSelectionStateProps} from '@react-stately/selection';\nimport {ReactElement, useCallback, useMemo, useState} from 'react';\nimport {TableCollection} from './TableCollection';\nimport {useCollection} from '@react-stately/collections';\n\nexport interface TableState<T> extends GridState<T, ITableCollection<T>> {\n /** A collection of rows and columns in the table. */\n collection: ITableCollection<T>,\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes: boolean,\n /** The current sorted column and direction. */\n sortDescriptor: SortDescriptor | null,\n /** Calls the provided onSortChange handler with the provided column key and sort direction. */\n sort(columnKey: Key, direction?: 'ascending' | 'descending'): void,\n /** Whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */\n isKeyboardNavigationDisabled: boolean,\n /** Set whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */\n setKeyboardNavigationDisabled: (val: boolean) => void\n}\n\nexport interface CollectionBuilderContext<T> {\n showSelectionCheckboxes: boolean,\n showDragButtons: boolean,\n selectionMode: SelectionMode,\n columns: Node<T>[]\n}\n\nexport interface TableStateProps<T> extends MultipleSelectionStateProps, Sortable {\n /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */\n children?: [ReactElement<TableHeaderProps<T>>, ReactElement<TableBodyProps<T>>],\n /** A list of row keys to disable. */\n disabledKeys?: Iterable<Key>,\n /** A pre-constructed collection to use instead of building one from items and children. */\n collection?: ITableCollection<T>,\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes?: boolean,\n /** Whether the row drag button should be displayed.\n * @private\n */\n showDragButtons?: boolean,\n /** @private - do not use unless you know what you're doing. */\n UNSAFE_selectionState?: MultipleSelectionState\n}\n\nconst OPPOSITE_SORT_DIRECTION = {\n ascending: 'descending' as SortDirection,\n descending: 'ascending' as SortDirection\n};\n\n/**\n * Provides state management for a table component. Handles building a collection\n * of columns and rows from props. In addition, it tracks row selection and manages sort order changes.\n */\nexport function useTableState<T extends object>(props: TableStateProps<T>): TableState<T> {\n let [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = useState(false);\n let {selectionMode = 'none', showSelectionCheckboxes, showDragButtons} = props;\n\n let context = useMemo(() => ({\n showSelectionCheckboxes: showSelectionCheckboxes && selectionMode !== 'none',\n showDragButtons: showDragButtons,\n selectionMode,\n columns: []\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [props.children, showSelectionCheckboxes, selectionMode, showDragButtons]);\n\n let collection = useCollection<T, ITableCollection<T>>(\n props,\n useCallback((nodes) => new TableCollection(nodes, null, context), [context]),\n context\n );\n let {disabledKeys, selectionManager} = useGridState({\n ...props,\n collection,\n disabledBehavior: props.disabledBehavior || 'selection'\n });\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n showSelectionCheckboxes: props.showSelectionCheckboxes || false,\n sortDescriptor: props.sortDescriptor ?? null,\n isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled,\n setKeyboardNavigationDisabled,\n sort(columnKey: Key, direction?: 'ascending' | 'descending') {\n props.onSortChange?.({\n column: columnKey,\n direction: direction ?? (props.sortDescriptor?.column === columnKey\n ? OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction]\n : 'ascending')\n });\n }\n };\n}\n\n/**\n * Filters a collection using the provided filter function and returns a new TableState.\n */\nexport function UNSTABLE_useFilteredTableState<T extends object>(state: TableState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): TableState<T> {\n let collection = useMemo(() => filterFn ? state.collection.filter!(filterFn) : state.collection, [state.collection, filterFn]) as ITableCollection<T>;\n let selectionManager = state.selectionManager.withCollection(collection);\n // TODO: handle focus key reset? That logic is in useGridState\n\n return {\n ...state,\n collection,\n selectionManager\n };\n}\n"],"names":[],"version":3,"file":"useTableState.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/table",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@react-stately/collections": "^3.12.
|
|
29
|
+
"@react-stately/collections": "^3.12.7",
|
|
30
30
|
"@react-stately/flags": "^3.1.2",
|
|
31
|
-
"@react-stately/grid": "^3.11.
|
|
32
|
-
"@react-stately/selection": "^3.20.
|
|
31
|
+
"@react-stately/grid": "^3.11.5",
|
|
32
|
+
"@react-stately/selection": "^3.20.5",
|
|
33
33
|
"@react-stately/utils": "^3.10.8",
|
|
34
|
-
"@react-types/grid": "^3.3.
|
|
35
|
-
"@react-types/shared": "^3.
|
|
36
|
-
"@react-types/table": "^3.13.
|
|
34
|
+
"@react-types/grid": "^3.3.5",
|
|
35
|
+
"@react-types/shared": "^3.32.0",
|
|
36
|
+
"@react-types/table": "^3.13.3",
|
|
37
37
|
"@swc/helpers": "^0.5.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2c58ed3ddd9be9100af9b1d0cfd137fcdc95ba2d"
|
|
46
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type {TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps}
|
|
|
16
16
|
export type {TreeGridState, TreeGridStateProps} from './useTreeGridState';
|
|
17
17
|
|
|
18
18
|
export {useTableColumnResizeState} from './useTableColumnResizeState';
|
|
19
|
-
export {useTableState} from './useTableState';
|
|
19
|
+
export {useTableState, UNSTABLE_useFilteredTableState} from './useTableState';
|
|
20
20
|
export {TableHeader} from './TableHeader';
|
|
21
21
|
export {TableBody} from './TableBody';
|
|
22
22
|
export {Column} from './Column';
|
package/src/useTableState.ts
CHANGED
|
@@ -107,3 +107,18 @@ export function useTableState<T extends object>(props: TableStateProps<T>): Tabl
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Filters a collection using the provided filter function and returns a new TableState.
|
|
113
|
+
*/
|
|
114
|
+
export function UNSTABLE_useFilteredTableState<T extends object>(state: TableState<T>, filterFn: ((nodeValue: string, node: Node<T>) => boolean) | null | undefined): TableState<T> {
|
|
115
|
+
let collection = useMemo(() => filterFn ? state.collection.filter!(filterFn) : state.collection, [state.collection, filterFn]) as ITableCollection<T>;
|
|
116
|
+
let selectionManager = state.selectionManager.withCollection(collection);
|
|
117
|
+
// TODO: handle focus key reset? That logic is in useGridState
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
...state,
|
|
121
|
+
collection,
|
|
122
|
+
selectionManager
|
|
123
|
+
};
|
|
124
|
+
}
|