@react-stately/table 3.0.0-beta.0 → 3.0.0-nightly-641446f65-240905

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 (76) hide show
  1. package/dist/Cell.main.js +38 -0
  2. package/dist/Cell.main.js.map +1 -0
  3. package/dist/Cell.mjs +33 -0
  4. package/dist/Cell.module.js +33 -0
  5. package/dist/Cell.module.js.map +1 -0
  6. package/dist/Column.main.js +75 -0
  7. package/dist/Column.main.js.map +1 -0
  8. package/dist/Column.mjs +66 -0
  9. package/dist/Column.module.js +66 -0
  10. package/dist/Column.module.js.map +1 -0
  11. package/dist/Row.main.js +97 -0
  12. package/dist/Row.main.js.map +1 -0
  13. package/dist/Row.mjs +88 -0
  14. package/dist/Row.module.js +88 -0
  15. package/dist/Row.module.js.map +1 -0
  16. package/dist/TableBody.main.js +61 -0
  17. package/dist/TableBody.main.js.map +1 -0
  18. package/dist/TableBody.mjs +52 -0
  19. package/dist/TableBody.module.js +52 -0
  20. package/dist/TableBody.module.js.map +1 -0
  21. package/dist/TableCollection.main.js +288 -0
  22. package/dist/TableCollection.main.js.map +1 -0
  23. package/dist/TableCollection.mjs +282 -0
  24. package/dist/TableCollection.module.js +282 -0
  25. package/dist/TableCollection.module.js.map +1 -0
  26. package/dist/TableColumnLayout.main.js +113 -0
  27. package/dist/TableColumnLayout.main.js.map +1 -0
  28. package/dist/TableColumnLayout.mjs +108 -0
  29. package/dist/TableColumnLayout.module.js +108 -0
  30. package/dist/TableColumnLayout.module.js.map +1 -0
  31. package/dist/TableHeader.main.js +56 -0
  32. package/dist/TableHeader.main.js.map +1 -0
  33. package/dist/TableHeader.mjs +47 -0
  34. package/dist/TableHeader.module.js +47 -0
  35. package/dist/TableHeader.module.js.map +1 -0
  36. package/dist/TableUtils.main.js +182 -0
  37. package/dist/TableUtils.main.js.map +1 -0
  38. package/dist/TableUtils.mjs +175 -0
  39. package/dist/TableUtils.module.js +175 -0
  40. package/dist/TableUtils.module.js.map +1 -0
  41. package/dist/import.mjs +37 -0
  42. package/dist/main.js +39 -593
  43. package/dist/main.js.map +1 -1
  44. package/dist/module.js +22 -564
  45. package/dist/module.js.map +1 -1
  46. package/dist/types.d.ts +163 -9
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/useTableColumnResizeState.main.js +109 -0
  49. package/dist/useTableColumnResizeState.main.js.map +1 -0
  50. package/dist/useTableColumnResizeState.mjs +104 -0
  51. package/dist/useTableColumnResizeState.module.js +104 -0
  52. package/dist/useTableColumnResizeState.module.js.map +1 -0
  53. package/dist/useTableState.main.js +71 -0
  54. package/dist/useTableState.main.js.map +1 -0
  55. package/dist/useTableState.mjs +66 -0
  56. package/dist/useTableState.module.js +66 -0
  57. package/dist/useTableState.module.js.map +1 -0
  58. package/dist/useTreeGridState.main.js +207 -0
  59. package/dist/useTreeGridState.main.js.map +1 -0
  60. package/dist/useTreeGridState.mjs +202 -0
  61. package/dist/useTreeGridState.module.js +202 -0
  62. package/dist/useTreeGridState.module.js.map +1 -0
  63. package/package.json +18 -10
  64. package/src/Cell.ts +4 -1
  65. package/src/Column.ts +12 -2
  66. package/src/Row.ts +50 -10
  67. package/src/TableBody.ts +6 -2
  68. package/src/TableCollection.ts +99 -15
  69. package/src/TableColumnLayout.ts +127 -0
  70. package/src/TableHeader.ts +11 -2
  71. package/src/TableUtils.ts +253 -0
  72. package/src/index.ts +15 -6
  73. package/src/useTableColumnResizeState.ts +147 -0
  74. package/src/useTableState.ts +43 -16
  75. package/src/useTreeGridState.ts +277 -0
  76. package/LICENSE +0 -201
@@ -0,0 +1,104 @@
1
+ import {TableColumnLayout as $a9e7ae544a4e41dd$export$7ff77a162970b30e} from "./TableColumnLayout.module.js";
2
+ import {useState as $cPT3l$useState, useMemo as $cPT3l$useMemo, useCallback as $cPT3l$useCallback} from "react";
3
+
4
+ /*
5
+ * Copyright 2022 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $292bc4e09cd0eb62$export$cb895dcf85db1319(props, state) {
17
+ let { getDefaultWidth: getDefaultWidth, getDefaultMinWidth: getDefaultMinWidth, tableWidth: tableWidth = 0 } = props;
18
+ let [resizingColumn, setResizingColumn] = (0, $cPT3l$useState)(null);
19
+ let columnLayout = (0, $cPT3l$useMemo)(()=>new (0, $a9e7ae544a4e41dd$export$7ff77a162970b30e)({
20
+ getDefaultWidth: getDefaultWidth,
21
+ getDefaultMinWidth: getDefaultMinWidth
22
+ }), [
23
+ getDefaultWidth,
24
+ getDefaultMinWidth
25
+ ]);
26
+ let [controlledColumns, uncontrolledColumns] = (0, $cPT3l$useMemo)(()=>columnLayout.splitColumnsIntoControlledAndUncontrolled(state.collection.columns), [
27
+ state.collection.columns,
28
+ columnLayout
29
+ ]);
30
+ // uncontrolled column widths
31
+ let [uncontrolledWidths, setUncontrolledWidths] = (0, $cPT3l$useState)(()=>columnLayout.getInitialUncontrolledWidths(uncontrolledColumns));
32
+ // Update uncontrolled widths if the columns changed.
33
+ let [lastColumns, setLastColumns] = (0, $cPT3l$useState)(state.collection.columns);
34
+ if (state.collection.columns !== lastColumns) {
35
+ if (state.collection.columns.length !== lastColumns.length || state.collection.columns.some((c, i)=>c.key !== lastColumns[i].key)) {
36
+ let newUncontrolledWidths = columnLayout.getInitialUncontrolledWidths(uncontrolledColumns);
37
+ setUncontrolledWidths(newUncontrolledWidths);
38
+ }
39
+ setLastColumns(state.collection.columns);
40
+ }
41
+ // combine columns back into one map that maintains same order as the columns
42
+ let colWidths = (0, $cPT3l$useMemo)(()=>columnLayout.recombineColumns(state.collection.columns, uncontrolledWidths, uncontrolledColumns, controlledColumns), [
43
+ state.collection.columns,
44
+ uncontrolledWidths,
45
+ uncontrolledColumns,
46
+ controlledColumns,
47
+ columnLayout
48
+ ]);
49
+ let startResize = (0, $cPT3l$useCallback)((key)=>{
50
+ setResizingColumn(key);
51
+ }, [
52
+ setResizingColumn
53
+ ]);
54
+ let updateResizedColumns = (0, $cPT3l$useCallback)((key, width)=>{
55
+ let newSizes = columnLayout.resizeColumnWidth(state.collection, uncontrolledWidths, key, width);
56
+ let map = new Map(Array.from(uncontrolledColumns).map(([key])=>[
57
+ key,
58
+ newSizes.get(key)
59
+ ]));
60
+ map.set(key, width);
61
+ setUncontrolledWidths(map);
62
+ return newSizes;
63
+ }, [
64
+ uncontrolledColumns,
65
+ setUncontrolledWidths,
66
+ columnLayout,
67
+ state.collection,
68
+ uncontrolledWidths
69
+ ]);
70
+ let endResize = (0, $cPT3l$useCallback)(()=>{
71
+ setResizingColumn(null);
72
+ }, [
73
+ setResizingColumn
74
+ ]);
75
+ let columnWidths = (0, $cPT3l$useMemo)(()=>columnLayout.buildColumnWidths(tableWidth, state.collection, colWidths), [
76
+ tableWidth,
77
+ state.collection,
78
+ colWidths,
79
+ columnLayout
80
+ ]);
81
+ return (0, $cPT3l$useMemo)(()=>({
82
+ resizingColumn: resizingColumn,
83
+ updateResizedColumns: updateResizedColumns,
84
+ startResize: startResize,
85
+ endResize: endResize,
86
+ getColumnWidth: (key)=>columnLayout.getColumnWidth(key),
87
+ getColumnMinWidth: (key)=>columnLayout.getColumnMinWidth(key),
88
+ getColumnMaxWidth: (key)=>columnLayout.getColumnMaxWidth(key),
89
+ tableState: state,
90
+ columnWidths: columnWidths
91
+ }), [
92
+ columnLayout,
93
+ columnWidths,
94
+ resizingColumn,
95
+ updateResizedColumns,
96
+ startResize,
97
+ endResize,
98
+ state
99
+ ]);
100
+ }
101
+
102
+
103
+ export {$292bc4e09cd0eb62$export$cb895dcf85db1319 as useTableColumnResizeState};
104
+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;QAAC,MAAM,UAAU,CAAC,OAAO;QAAE;QAAoB;QAAqB;QAAmB;KAAa;IAEtG,IAAI,cAAc,CAAA,GAAA,kBAAU,EAAE,CAAC;QAC7B,kBAAkB;IACpB,GAAG;QAAC;KAAkB;IAEtB,IAAI,uBAAuB,CAAA,GAAA,kBAAU,EAAE,CAAC,KAAU;QAChD,IAAI,WAAW,aAAa,iBAAiB,CAAC,MAAM,UAAU,EAAE,oBAAoB,KAAK;QACzF,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,IAAI,GAAK;gBAAC;gBAAK,SAAS,GAAG,CAAC;aAAK;QACzF,IAAI,GAAG,CAAC,KAAK;QACb,sBAAsB;QACtB,OAAO;IACT,GAAG;QAAC;QAAqB;QAAuB;QAAc,MAAM,UAAU;QAAE;KAAmB;IAEnG,IAAI,YAAY,CAAA,GAAA,kBAAU,EAAE;QAC1B,kBAAkB;IACpB,GAAG;QAAC;KAAkB;IAEtB,IAAI,eAAe,CAAA,GAAA,cAAM,EAAE,IACzB,aAAa,iBAAiB,CAAC,YAAY,MAAM,UAAU,EAAE,YAC7D;QAAC;QAAY,MAAM,UAAU;QAAE;QAAW;KAAa;IAEzD,OAAO,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;4BACpB;kCACA;yBACA;uBACA;YACA,gBAAgB,CAAC,MACf,aAAa,cAAc,CAAC;YAC9B,mBAAmB,CAAC,MAClB,aAAa,iBAAiB,CAAC;YACjC,mBAAmB,CAAC,MAClB,aAAa,iBAAiB,CAAC;YACjC,YAAY;0BACZ;QACF,CAAA,GAAI;QACF;QACA;QACA;QACA;QACA;QACA;QACA;KACD;AACH","sources":["packages/@react-stately/table/src/useTableColumnResizeState.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {ColumnSize} from '@react-types/table';\nimport {GridNode} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\nimport {TableColumnLayout} from './TableColumnLayout';\nimport {TableState} from './useTableState';\nimport {useCallback, useMemo, useState} from 'react';\n\nexport interface TableColumnResizeStateProps<T> {\n /**\n * Current width of the table or table viewport that the columns\n * should be calculated against.\n */\n tableWidth: number,\n /** A function that is called to find the default width for a given column. */\n getDefaultWidth?: (node: GridNode<T>) => ColumnSize | null | undefined,\n /** A function that is called to find the default minWidth for a given column. */\n getDefaultMinWidth?: (node: GridNode<T>) => ColumnSize | null | undefined\n}\nexport interface TableColumnResizeState<T> {\n /**\n * Called to update the state that a resize event has occurred.\n * Returns the new widths for all columns based on the resized column.\n */\n updateResizedColumns: (key: Key, width: number) => Map<Key, ColumnSize>,\n /** Callback for when onColumnResize has started. */\n startResize: (key: Key) => void,\n /** Callback for when onColumnResize has ended. */\n endResize: () => void,\n /** Gets the current width for the specified column. */\n getColumnWidth: (key: Key) => number,\n /** Gets the current minWidth for the specified column. */\n getColumnMinWidth: (key: Key) => number,\n /** Gets the current maxWidth for the specified column. */\n getColumnMaxWidth: (key: Key) => number,\n /** Key of the currently resizing column. */\n resizingColumn: Key | null,\n /** A reference to the table state. */\n tableState: TableState<T>,\n /** A map of the current column widths. */\n columnWidths: Map<Key, number>\n}\n\n/**\n * Provides column width state management for a table component with column resizing support. Handles building\n * a map of column widths calculated from the table's width and any provided column width information from the collection.\n * In addition, it tracks the currently resizing column and provides callbacks for updating the widths upon resize operations.\n * @param props - Props for the table.\n * @param state - State for the table, as returned by `useTableState`.\n */\nexport function useTableColumnResizeState<T>(props: TableColumnResizeStateProps<T>, state: TableState<T>): TableColumnResizeState<T> {\n let {\n getDefaultWidth,\n getDefaultMinWidth,\n tableWidth = 0\n } = props;\n\n let [resizingColumn, setResizingColumn] = useState<Key | null>(null);\n let columnLayout = useMemo(\n () => new TableColumnLayout({\n getDefaultWidth,\n getDefaultMinWidth\n }),\n [getDefaultWidth, getDefaultMinWidth]\n );\n\n let [controlledColumns, uncontrolledColumns] = useMemo(() =>\n columnLayout.splitColumnsIntoControlledAndUncontrolled(state.collection.columns)\n , [state.collection.columns, columnLayout]);\n\n // uncontrolled column widths\n let [uncontrolledWidths, setUncontrolledWidths] = useState(() =>\n columnLayout.getInitialUncontrolledWidths(uncontrolledColumns)\n );\n\n // Update uncontrolled widths if the columns changed.\n let [lastColumns, setLastColumns] = useState(state.collection.columns);\n if (state.collection.columns !== lastColumns) {\n if (\n state.collection.columns.length !== lastColumns.length ||\n state.collection.columns.some((c, i) => c.key !== lastColumns[i].key)\n ) {\n let newUncontrolledWidths = columnLayout.getInitialUncontrolledWidths(uncontrolledColumns);\n setUncontrolledWidths(newUncontrolledWidths);\n }\n setLastColumns(state.collection.columns);\n }\n\n // combine columns back into one map that maintains same order as the columns\n let colWidths = useMemo(() =>\n columnLayout.recombineColumns(state.collection.columns, uncontrolledWidths, uncontrolledColumns, controlledColumns)\n , [state.collection.columns, uncontrolledWidths, uncontrolledColumns, controlledColumns, columnLayout]);\n\n let startResize = useCallback((key: Key) => {\n setResizingColumn(key);\n }, [setResizingColumn]);\n\n let updateResizedColumns = useCallback((key: Key, width: number): Map<Key, ColumnSize> => {\n let newSizes = columnLayout.resizeColumnWidth(state.collection, uncontrolledWidths, key, width);\n let map = new Map(Array.from(uncontrolledColumns).map(([key]) => [key, newSizes.get(key)]));\n map.set(key, width);\n setUncontrolledWidths(map);\n return newSizes;\n }, [uncontrolledColumns, setUncontrolledWidths, columnLayout, state.collection, uncontrolledWidths]);\n\n let endResize = useCallback(() => {\n setResizingColumn(null);\n }, [setResizingColumn]);\n\n let columnWidths = useMemo(() =>\n columnLayout.buildColumnWidths(tableWidth, state.collection, colWidths)\n , [tableWidth, state.collection, colWidths, columnLayout]);\n\n return useMemo(() => ({\n resizingColumn,\n updateResizedColumns,\n startResize,\n endResize,\n getColumnWidth: (key: Key) =>\n columnLayout.getColumnWidth(key),\n getColumnMinWidth: (key: Key) =>\n columnLayout.getColumnMinWidth(key),\n getColumnMaxWidth: (key: Key) =>\n columnLayout.getColumnMaxWidth(key),\n tableState: state,\n columnWidths\n }), [\n columnLayout,\n columnWidths,\n resizingColumn,\n updateResizedColumns,\n startResize,\n endResize,\n state\n ]);\n}\n"],"names":[],"version":3,"file":"useTableColumnResizeState.module.js.map"}
@@ -0,0 +1,71 @@
1
+ var $7f5a58334d8866a5$exports = require("./TableCollection.main.js");
2
+ var $hkaUn$reactstatelygrid = require("@react-stately/grid");
3
+ var $hkaUn$react = require("react");
4
+ var $hkaUn$reactstatelycollections = require("@react-stately/collections");
5
+
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+
11
+ $parcel$export(module.exports, "useTableState", () => $e3f7784147dde23d$export$907bcc6c48325fd6);
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */
23
+
24
+
25
+
26
+ const $e3f7784147dde23d$var$OPPOSITE_SORT_DIRECTION = {
27
+ ascending: 'descending',
28
+ descending: 'ascending'
29
+ };
30
+ function $e3f7784147dde23d$export$907bcc6c48325fd6(props) {
31
+ let [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = (0, $hkaUn$react.useState)(false);
32
+ let { selectionMode: selectionMode = 'none', showSelectionCheckboxes: showSelectionCheckboxes, showDragButtons: showDragButtons } = props;
33
+ let context = (0, $hkaUn$react.useMemo)(()=>({
34
+ showSelectionCheckboxes: showSelectionCheckboxes && selectionMode !== 'none',
35
+ showDragButtons: showDragButtons,
36
+ selectionMode: selectionMode,
37
+ columns: []
38
+ }), [
39
+ props.children,
40
+ showSelectionCheckboxes,
41
+ selectionMode,
42
+ showDragButtons
43
+ ]);
44
+ let collection = (0, $hkaUn$reactstatelycollections.useCollection)(props, (0, $hkaUn$react.useCallback)((nodes)=>new (0, $7f5a58334d8866a5$exports.TableCollection)(nodes, null, context), [
45
+ context
46
+ ]), context);
47
+ let { disabledKeys: disabledKeys, selectionManager: selectionManager } = (0, $hkaUn$reactstatelygrid.useGridState)({
48
+ ...props,
49
+ collection: collection,
50
+ disabledBehavior: props.disabledBehavior || 'selection'
51
+ });
52
+ return {
53
+ collection: collection,
54
+ disabledKeys: disabledKeys,
55
+ selectionManager: selectionManager,
56
+ showSelectionCheckboxes: props.showSelectionCheckboxes || false,
57
+ sortDescriptor: props.sortDescriptor,
58
+ isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled,
59
+ setKeyboardNavigationDisabled: setKeyboardNavigationDisabled,
60
+ sort (columnKey, direction) {
61
+ var _props_sortDescriptor;
62
+ props.onSortChange({
63
+ column: columnKey,
64
+ direction: direction !== null && direction !== void 0 ? direction : ((_props_sortDescriptor = props.sortDescriptor) === null || _props_sortDescriptor === void 0 ? void 0 : _props_sortDescriptor.column) === columnKey ? $e3f7784147dde23d$var$OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction] : 'ascending'
65
+ });
66
+ }
67
+ };
68
+ }
69
+
70
+
71
+ //# sourceMappingURL=useTableState.main.js.map
@@ -0,0 +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,qBAAO,EAAE;IAC7E,IAAI,iBAAC,gBAAgB,iCAAQ,uBAAuB,mBAAE,eAAe,EAAC,GAAG;IAEzE,IAAI,UAAU,CAAA,GAAA,oBAAM,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,4CAAY,EAC3B,OACA,CAAA,GAAA,wBAAU,EAAE,CAAC,QAAU,IAAI,CAAA,GAAA,yCAAc,EAAE,OAAO,MAAM,UAAU;QAAC;KAAQ,GAC3E;IAEF,IAAI,gBAAC,YAAY,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,oCAAW,EAAE;QAClD,GAAG,KAAK;oBACR;QACA,kBAAkB,MAAM,gBAAgB,IAAI;IAC9C;IAEA,OAAO;oBACL;sBACA;0BACA;QACA,yBAAyB,MAAM,uBAAuB,IAAI;QAC1D,gBAAgB,MAAM,cAAc;QACpC,8BAA8B,WAAW,IAAI,KAAK,KAAK;uCACvD;QACA,MAAK,SAAc,EAAE,SAAsC;gBAG9B;YAF3B,MAAM,YAAY,CAAC;gBACjB,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,\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,\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.main.js.map"}
@@ -0,0 +1,66 @@
1
+ import {TableCollection as $788781baa30117fa$export$596e1b2e2cf93690} from "./TableCollection.mjs";
2
+ import {useGridState as $1YSEb$useGridState} from "@react-stately/grid";
3
+ import {useState as $1YSEb$useState, useMemo as $1YSEb$useMemo, useCallback as $1YSEb$useCallback} from "react";
4
+ import {useCollection as $1YSEb$useCollection} from "@react-stately/collections";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ const $4a0dd036d492cee4$var$OPPOSITE_SORT_DIRECTION = {
21
+ ascending: 'descending',
22
+ descending: 'ascending'
23
+ };
24
+ function $4a0dd036d492cee4$export$907bcc6c48325fd6(props) {
25
+ let [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = (0, $1YSEb$useState)(false);
26
+ let { selectionMode: selectionMode = 'none', showSelectionCheckboxes: showSelectionCheckboxes, showDragButtons: showDragButtons } = props;
27
+ let context = (0, $1YSEb$useMemo)(()=>({
28
+ showSelectionCheckboxes: showSelectionCheckboxes && selectionMode !== 'none',
29
+ showDragButtons: showDragButtons,
30
+ selectionMode: selectionMode,
31
+ columns: []
32
+ }), [
33
+ props.children,
34
+ showSelectionCheckboxes,
35
+ selectionMode,
36
+ showDragButtons
37
+ ]);
38
+ let collection = (0, $1YSEb$useCollection)(props, (0, $1YSEb$useCallback)((nodes)=>new (0, $788781baa30117fa$export$596e1b2e2cf93690)(nodes, null, context), [
39
+ context
40
+ ]), context);
41
+ let { disabledKeys: disabledKeys, selectionManager: selectionManager } = (0, $1YSEb$useGridState)({
42
+ ...props,
43
+ collection: collection,
44
+ disabledBehavior: props.disabledBehavior || 'selection'
45
+ });
46
+ return {
47
+ collection: collection,
48
+ disabledKeys: disabledKeys,
49
+ selectionManager: selectionManager,
50
+ showSelectionCheckboxes: props.showSelectionCheckboxes || false,
51
+ sortDescriptor: props.sortDescriptor,
52
+ isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled,
53
+ setKeyboardNavigationDisabled: setKeyboardNavigationDisabled,
54
+ sort (columnKey, direction) {
55
+ var _props_sortDescriptor;
56
+ props.onSortChange({
57
+ column: columnKey,
58
+ direction: direction !== null && direction !== void 0 ? direction : ((_props_sortDescriptor = props.sortDescriptor) === null || _props_sortDescriptor === void 0 ? void 0 : _props_sortDescriptor.column) === columnKey ? $4a0dd036d492cee4$var$OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction] : 'ascending'
59
+ });
60
+ }
61
+ };
62
+ }
63
+
64
+
65
+ export {$4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState};
66
+ //# sourceMappingURL=useTableState.module.js.map
@@ -0,0 +1,66 @@
1
+ import {TableCollection as $788781baa30117fa$export$596e1b2e2cf93690} from "./TableCollection.module.js";
2
+ import {useGridState as $1YSEb$useGridState} from "@react-stately/grid";
3
+ import {useState as $1YSEb$useState, useMemo as $1YSEb$useMemo, useCallback as $1YSEb$useCallback} from "react";
4
+ import {useCollection as $1YSEb$useCollection} from "@react-stately/collections";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ const $4a0dd036d492cee4$var$OPPOSITE_SORT_DIRECTION = {
21
+ ascending: 'descending',
22
+ descending: 'ascending'
23
+ };
24
+ function $4a0dd036d492cee4$export$907bcc6c48325fd6(props) {
25
+ let [isKeyboardNavigationDisabled, setKeyboardNavigationDisabled] = (0, $1YSEb$useState)(false);
26
+ let { selectionMode: selectionMode = 'none', showSelectionCheckboxes: showSelectionCheckboxes, showDragButtons: showDragButtons } = props;
27
+ let context = (0, $1YSEb$useMemo)(()=>({
28
+ showSelectionCheckboxes: showSelectionCheckboxes && selectionMode !== 'none',
29
+ showDragButtons: showDragButtons,
30
+ selectionMode: selectionMode,
31
+ columns: []
32
+ }), [
33
+ props.children,
34
+ showSelectionCheckboxes,
35
+ selectionMode,
36
+ showDragButtons
37
+ ]);
38
+ let collection = (0, $1YSEb$useCollection)(props, (0, $1YSEb$useCallback)((nodes)=>new (0, $788781baa30117fa$export$596e1b2e2cf93690)(nodes, null, context), [
39
+ context
40
+ ]), context);
41
+ let { disabledKeys: disabledKeys, selectionManager: selectionManager } = (0, $1YSEb$useGridState)({
42
+ ...props,
43
+ collection: collection,
44
+ disabledBehavior: props.disabledBehavior || 'selection'
45
+ });
46
+ return {
47
+ collection: collection,
48
+ disabledKeys: disabledKeys,
49
+ selectionManager: selectionManager,
50
+ showSelectionCheckboxes: props.showSelectionCheckboxes || false,
51
+ sortDescriptor: props.sortDescriptor,
52
+ isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled,
53
+ setKeyboardNavigationDisabled: setKeyboardNavigationDisabled,
54
+ sort (columnKey, direction) {
55
+ var _props_sortDescriptor;
56
+ props.onSortChange({
57
+ column: columnKey,
58
+ direction: direction !== null && direction !== void 0 ? direction : ((_props_sortDescriptor = props.sortDescriptor) === null || _props_sortDescriptor === void 0 ? void 0 : _props_sortDescriptor.column) === columnKey ? $4a0dd036d492cee4$var$OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction] : 'ascending'
59
+ });
60
+ }
61
+ };
62
+ }
63
+
64
+
65
+ export {$4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState};
66
+ //# sourceMappingURL=useTableState.module.js.map
@@ -0,0 +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;IAEA,OAAO;oBACL;sBACA;0BACA;QACA,yBAAyB,MAAM,uBAAuB,IAAI;QAC1D,gBAAgB,MAAM,cAAc;QACpC,8BAA8B,WAAW,IAAI,KAAK,KAAK;uCACvD;QACA,MAAK,SAAc,EAAE,SAAsC;gBAG9B;YAF3B,MAAM,YAAY,CAAC;gBACjB,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,\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,\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"}
@@ -0,0 +1,207 @@
1
+ var $7f5a58334d8866a5$exports = require("./TableCollection.main.js");
2
+ var $e3f7784147dde23d$exports = require("./useTableState.main.js");
3
+ var $5Qo8l$reactstatelycollections = require("@react-stately/collections");
4
+ var $5Qo8l$react = require("react");
5
+ var $5Qo8l$reactstatelyflags = require("@react-stately/flags");
6
+ var $5Qo8l$reactstatelyutils = require("@react-stately/utils");
7
+
8
+
9
+ function $parcel$export(e, n, v, s) {
10
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
+ }
12
+
13
+ $parcel$export(module.exports, "UNSTABLE_useTreeGridState", () => $ed4e0b68b470dcfd$export$34dfa8a1622185a4);
14
+ /*
15
+ * Copyright 2023 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+
27
+
28
+
29
+
30
+ function $ed4e0b68b470dcfd$export$34dfa8a1622185a4(props) {
31
+ let { selectionMode: selectionMode = 'none', showSelectionCheckboxes: showSelectionCheckboxes, showDragButtons: showDragButtons, UNSTABLE_expandedKeys: propExpandedKeys, UNSTABLE_defaultExpandedKeys: propDefaultExpandedKeys, UNSTABLE_onExpandedChange: UNSTABLE_onExpandedChange, children: children } = props;
32
+ if (!(0, $5Qo8l$reactstatelyflags.tableNestedRows)()) throw new Error('Feature flag for table nested rows must be enabled to use useTreeGridState.');
33
+ let [expandedKeys, setExpandedKeys] = (0, $5Qo8l$reactstatelyutils.useControlledState)(propExpandedKeys ? $ed4e0b68b470dcfd$var$convertExpanded(propExpandedKeys) : undefined, propDefaultExpandedKeys ? $ed4e0b68b470dcfd$var$convertExpanded(propDefaultExpandedKeys) : new Set(), UNSTABLE_onExpandedChange);
34
+ let context = (0, $5Qo8l$react.useMemo)(()=>({
35
+ showSelectionCheckboxes: showSelectionCheckboxes && selectionMode !== 'none',
36
+ showDragButtons: showDragButtons,
37
+ selectionMode: selectionMode,
38
+ columns: []
39
+ }), [
40
+ children,
41
+ showSelectionCheckboxes,
42
+ selectionMode,
43
+ showDragButtons
44
+ ]);
45
+ let builder = (0, $5Qo8l$react.useMemo)(()=>new (0, $5Qo8l$reactstatelycollections.CollectionBuilder)(), []);
46
+ let nodes = (0, $5Qo8l$react.useMemo)(()=>builder.build({
47
+ children: children
48
+ }, context), [
49
+ builder,
50
+ children,
51
+ context
52
+ ]);
53
+ let treeGridCollection = (0, $5Qo8l$react.useMemo)(()=>{
54
+ return $ed4e0b68b470dcfd$var$generateTreeGridCollection(nodes, {
55
+ showSelectionCheckboxes: showSelectionCheckboxes,
56
+ showDragButtons: showDragButtons,
57
+ expandedKeys: expandedKeys
58
+ });
59
+ }, [
60
+ nodes,
61
+ showSelectionCheckboxes,
62
+ showDragButtons,
63
+ expandedKeys
64
+ ]);
65
+ let onToggle = (key)=>{
66
+ setExpandedKeys($ed4e0b68b470dcfd$var$toggleKey(expandedKeys, key, treeGridCollection));
67
+ };
68
+ let collection = (0, $5Qo8l$react.useMemo)(()=>{
69
+ return new (0, $7f5a58334d8866a5$exports.TableCollection)(treeGridCollection.tableNodes, null, context);
70
+ }, [
71
+ context,
72
+ treeGridCollection.tableNodes
73
+ ]);
74
+ let tableState = (0, $e3f7784147dde23d$exports.useTableState)({
75
+ ...props,
76
+ collection: collection
77
+ });
78
+ return {
79
+ ...tableState,
80
+ keyMap: treeGridCollection.keyMap,
81
+ userColumnCount: treeGridCollection.userColumnCount,
82
+ expandedKeys: expandedKeys,
83
+ toggleKey: onToggle
84
+ };
85
+ }
86
+ function $ed4e0b68b470dcfd$var$toggleKey(currentExpandedKeys, key, collection) {
87
+ let updatedExpandedKeys;
88
+ if (currentExpandedKeys === 'all') {
89
+ updatedExpandedKeys = new Set(collection.flattenedRows.filter((row)=>row.props.UNSTABLE_childItems || row.props.children.length > collection.userColumnCount).map((row)=>row.key));
90
+ updatedExpandedKeys.delete(key);
91
+ } else {
92
+ updatedExpandedKeys = new Set(currentExpandedKeys);
93
+ if (updatedExpandedKeys.has(key)) updatedExpandedKeys.delete(key);
94
+ else updatedExpandedKeys.add(key);
95
+ }
96
+ return updatedExpandedKeys;
97
+ }
98
+ function $ed4e0b68b470dcfd$var$convertExpanded(expanded) {
99
+ if (!expanded) return new Set();
100
+ return expanded === 'all' ? 'all' : new Set(expanded);
101
+ }
102
+ function $ed4e0b68b470dcfd$var$generateTreeGridCollection(nodes, opts) {
103
+ let { expandedKeys: expandedKeys = new Set() } = opts;
104
+ let body;
105
+ let flattenedRows = [];
106
+ let columnCount = 0;
107
+ let userColumnCount = 0;
108
+ let originalColumns = [];
109
+ let keyMap = new Map();
110
+ if (opts === null || opts === void 0 ? void 0 : opts.showSelectionCheckboxes) columnCount++;
111
+ if (opts === null || opts === void 0 ? void 0 : opts.showDragButtons) columnCount++;
112
+ let topLevelRows = [];
113
+ let visit = (node)=>{
114
+ switch(node.type){
115
+ case 'body':
116
+ body = node;
117
+ keyMap.set(body.key, body);
118
+ break;
119
+ case 'column':
120
+ if (!node.hasChildNodes) userColumnCount++;
121
+ break;
122
+ case 'item':
123
+ topLevelRows.push(node);
124
+ return;
125
+ }
126
+ for (let child of node.childNodes)visit(child);
127
+ };
128
+ for (let node of nodes){
129
+ if (node.type === 'column') originalColumns.push(node);
130
+ visit(node);
131
+ }
132
+ columnCount += userColumnCount;
133
+ // Update each grid node in the treegrid table with values specific to a treegrid structure. Also store a set of flattened row nodes for TableCollection to consume
134
+ let globalRowCount = 0;
135
+ let visitNode = (node, i)=>{
136
+ // Clone row node and its children so modifications to the node for treegrid specific values aren't applied on the nodes provided
137
+ // to TableCollection. Index, level, and parent keys are all changed to reflect a flattened row structure rather than the treegrid structure
138
+ // values automatically calculated via CollectionBuilder
139
+ if (node.type === 'item') {
140
+ let childNodes = [];
141
+ for (let child of node.childNodes)if (child.type === 'cell') {
142
+ let cellClone = {
143
+ ...child
144
+ };
145
+ if (cellClone.index + 1 === columnCount) cellClone.nextKey = null;
146
+ childNodes.push({
147
+ ...cellClone
148
+ });
149
+ }
150
+ let clone = {
151
+ ...node,
152
+ childNodes: childNodes,
153
+ parentKey: body.key,
154
+ level: 1,
155
+ index: globalRowCount++
156
+ };
157
+ flattenedRows.push(clone);
158
+ }
159
+ let newProps = {};
160
+ // Assign indexOfType to cells and rows for aria-posinset
161
+ if (node.type !== 'placeholder' && node.type !== 'column') newProps['indexOfType'] = i;
162
+ // Use Object.assign instead of spread to preserve object reference for keyMap. Also ensures retrieving nodes
163
+ // via .childNodes returns the same object as the one found via keyMap look up
164
+ Object.assign(node, newProps);
165
+ keyMap.set(node.key, node);
166
+ let lastNode;
167
+ let rowIndex = 0;
168
+ for (let child of node.childNodes)if (!(child.type === 'item' && expandedKeys !== 'all' && !expandedKeys.has(node.key))) {
169
+ if (child.parentKey == null) // if child is a cell/expanded row/column and the parent key isn't already established by the collection, match child node to parent row
170
+ child.parentKey = node.key;
171
+ if (lastNode) {
172
+ lastNode.nextKey = child.key;
173
+ child.prevKey = lastNode.key;
174
+ } else child.prevKey = null;
175
+ if (child.type === 'item') visitNode(child, rowIndex++);
176
+ else // We enforce that the cells come before rows so can just reuse cell index
177
+ visitNode(child, child.index);
178
+ lastNode = child;
179
+ }
180
+ if (lastNode) lastNode.nextKey = null;
181
+ };
182
+ let last;
183
+ topLevelRows.forEach((node, i)=>{
184
+ visitNode(node, i);
185
+ if (last) {
186
+ last.nextKey = node.key;
187
+ node.prevKey = last.key;
188
+ } else node.prevKey = null;
189
+ last = node;
190
+ });
191
+ if (last) last.nextKey = null;
192
+ return {
193
+ keyMap: keyMap,
194
+ userColumnCount: userColumnCount,
195
+ flattenedRows: flattenedRows,
196
+ tableNodes: [
197
+ ...originalColumns,
198
+ {
199
+ ...body,
200
+ childNodes: flattenedRows
201
+ }
202
+ ]
203
+ };
204
+ }
205
+
206
+
207
+ //# sourceMappingURL=useTreeGridState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;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GAAG;YAG5B,IAAI,UAAU;gBACZ,SAAS,OAAO,GAAG,MAAM,GAAG;gBAC5B,MAAM,OAAO,GAAG,SAAS,GAAG;YAC9B,OACE,MAAM,OAAO,GAAG;YAGlB,IAAI,MAAM,IAAI,KAAK,QACjB,UAAU,OAAO;iBAEjB,0EAA0E;YAC1E,UAAU,OAAO,MAAM,KAAK;YAG9B,WAAW;QACb;QAGF,IAAI,UACF,SAAS,OAAO,GAAG;IAEvB;IAEA,IAAI;IACJ,aAAa,OAAO,CAAC,CAAC,MAAmB;QACvC,UAAU,MAAqB;QAE/B,IAAI,MAAM;YACR,KAAK,OAAO,GAAG,KAAK,GAAG;YACvB,KAAK,OAAO,GAAG,KAAK,GAAG;QACzB,OACE,KAAK,OAAO,GAAG;QAGjB,OAAO;IACT;IAEA,IAAI,MACF,KAAK,OAAO,GAAG;IAGjB,OAAO;gBACL;yBACA;uBACA;QACA,YAAY;eAAI;YAAiB;gBAAC,GAAG,IAAI;gBAAE,YAAY;YAAa;SAAE;IACxE;AACF","sources":["packages/@react-stately/table/src/useTreeGridState.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {CollectionBuilder} from '@react-stately/collections';\nimport {GridNode} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\nimport {ReactElement, useMemo} from 'react';\nimport {TableCollection} from './TableCollection';\nimport {tableNestedRows} from '@react-stately/flags';\nimport {TableState, TableStateProps, useTableState} from './useTableState';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface TreeGridState<T> extends TableState<T> {\n /** A set of keys for items that are expanded. */\n expandedKeys: 'all' | Set<Key>,\n /** Toggles the expanded state for a row by its key. */\n toggleKey(key: Key): void,\n /** The key map containing nodes representing the collection's tree grid structure. */\n keyMap: Map<Key, GridNode<T>>,\n /** The number of leaf columns provided by the user. */\n userColumnCount: number\n}\n\nexport interface TreeGridStateProps<T> extends Omit<TableStateProps<T>, 'collection'> {\n /** The currently expanded keys in the collection (controlled). */\n UNSTABLE_expandedKeys?: 'all' | Iterable<Key>,\n /** The initial expanded keys in the collection (uncontrolled). */\n UNSTABLE_defaultExpandedKeys?: 'all' | Iterable<Key>,\n /** Handler that is called when items are expanded or collapsed. */\n UNSTABLE_onExpandedChange?: (keys: Set<Key>) => any\n}\n\n/**\n * Provides state management for a tree grid component. Handles building a collection\n * of columns and rows from props. In addition, it tracks and manages expanded rows, row selection, and sort order changes.\n */\nexport function UNSTABLE_useTreeGridState<T extends object>(props: TreeGridStateProps<T>): TreeGridState<T> {\n let {\n selectionMode = 'none',\n showSelectionCheckboxes,\n showDragButtons,\n UNSTABLE_expandedKeys: propExpandedKeys,\n UNSTABLE_defaultExpandedKeys: propDefaultExpandedKeys,\n UNSTABLE_onExpandedChange,\n children\n } = props;\n\n if (!tableNestedRows()) {\n throw new Error('Feature flag for table nested rows must be enabled to use useTreeGridState.');\n }\n\n let [expandedKeys, setExpandedKeys] = useControlledState(\n propExpandedKeys ? convertExpanded(propExpandedKeys) : undefined,\n propDefaultExpandedKeys ? convertExpanded(propDefaultExpandedKeys) : new Set(),\n UNSTABLE_onExpandedChange\n );\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 }), [children, showSelectionCheckboxes, selectionMode, showDragButtons]);\n\n let builder = useMemo(() => new CollectionBuilder<T>(), []);\n let nodes = useMemo(() => builder.build({children: children as ReactElement<any>[]}, context), [builder, children, context]);\n let treeGridCollection = useMemo(() => {\n return generateTreeGridCollection<T>(nodes, {showSelectionCheckboxes, showDragButtons, expandedKeys});\n }, [nodes, showSelectionCheckboxes, showDragButtons, expandedKeys]);\n\n let onToggle = (key: Key) => {\n setExpandedKeys(toggleKey(expandedKeys, key, treeGridCollection));\n };\n\n let collection = useMemo(() => {\n return new TableCollection(treeGridCollection.tableNodes, null, context);\n }, [context, treeGridCollection.tableNodes]);\n\n let tableState = useTableState({...props, collection});\n return {\n ...tableState,\n keyMap: treeGridCollection.keyMap,\n userColumnCount: treeGridCollection.userColumnCount,\n expandedKeys,\n toggleKey: onToggle\n };\n}\n\nfunction toggleKey<T>(currentExpandedKeys: 'all' | Set<Key>, key: Key, collection: TreeGridCollection<T>): Set<Key> {\n let updatedExpandedKeys: Set<Key>;\n if (currentExpandedKeys === 'all') {\n updatedExpandedKeys = new Set(collection.flattenedRows.filter(row => row.props.UNSTABLE_childItems || row.props.children.length > collection.userColumnCount).map(row => row.key));\n updatedExpandedKeys.delete(key);\n } else {\n updatedExpandedKeys = new Set(currentExpandedKeys);\n if (updatedExpandedKeys.has(key)) {\n updatedExpandedKeys.delete(key);\n } else {\n updatedExpandedKeys.add(key);\n }\n }\n\n return updatedExpandedKeys;\n}\n\nfunction convertExpanded(expanded: 'all' | Iterable<Key>): 'all' | Set<Key> {\n if (!expanded) {\n return new Set<Key>();\n }\n\n return expanded === 'all'\n ? 'all'\n : new Set(expanded);\n}\n\ninterface TreeGridCollectionOptions {\n showSelectionCheckboxes?: boolean,\n showDragButtons?: boolean,\n expandedKeys: 'all' | Set<Key>\n}\n\ninterface TreeGridCollection<T> {\n keyMap: Map<Key, GridNode<T>>,\n tableNodes: GridNode<T>[],\n flattenedRows: GridNode<T>[],\n userColumnCount: number\n}\nfunction generateTreeGridCollection<T>(nodes, opts: TreeGridCollectionOptions): TreeGridCollection<T> {\n let {\n expandedKeys = new Set()\n } = opts;\n\n let body: GridNode<T>;\n let flattenedRows = [];\n let columnCount = 0;\n let userColumnCount = 0;\n let originalColumns = [];\n let keyMap = new Map();\n\n if (opts?.showSelectionCheckboxes) {\n columnCount++;\n }\n\n if (opts?.showDragButtons) {\n columnCount++;\n }\n\n let topLevelRows = [];\n let visit = (node: GridNode<T>) => {\n switch (node.type) {\n case 'body':\n body = node;\n keyMap.set(body.key, body);\n break;\n case 'column':\n if (!node.hasChildNodes) {\n userColumnCount++;\n }\n break;\n case 'item':\n topLevelRows.push(node);\n return;\n }\n\n for (let child of node.childNodes) {\n visit(child);\n }\n };\n\n for (let node of nodes) {\n if (node.type === 'column') {\n originalColumns.push(node);\n }\n visit(node);\n }\n columnCount += userColumnCount;\n\n // Update each grid node in the treegrid table with values specific to a treegrid structure. Also store a set of flattened row nodes for TableCollection to consume\n let globalRowCount = 0;\n let visitNode = (node: GridNode<T>, i?: number) => {\n // Clone row node and its children so modifications to the node for treegrid specific values aren't applied on the nodes provided\n // to TableCollection. Index, level, and parent keys are all changed to reflect a flattened row structure rather than the treegrid structure\n // values automatically calculated via CollectionBuilder\n if (node.type === 'item') {\n let childNodes = [];\n for (let child of node.childNodes) {\n if (child.type === 'cell') {\n let cellClone = {...child};\n if (cellClone.index + 1 === columnCount) {\n cellClone.nextKey = null;\n }\n childNodes.push({...cellClone});\n }\n }\n let clone = {...node, childNodes: childNodes, parentKey: body.key, level: 1, index: globalRowCount++};\n flattenedRows.push(clone);\n }\n\n let newProps = {};\n\n // Assign indexOfType to cells and rows for aria-posinset\n if (node.type !== 'placeholder' && node.type !== 'column') {\n newProps['indexOfType'] = i;\n }\n\n // Use Object.assign instead of spread to preserve object reference for keyMap. Also ensures retrieving nodes\n // via .childNodes returns the same object as the one found via keyMap look up\n Object.assign(node, newProps);\n keyMap.set(node.key, node);\n\n let lastNode: GridNode<T>;\n let rowIndex = 0;\n for (let child of node.childNodes) {\n if (!(child.type === 'item' && expandedKeys !== 'all' && !expandedKeys.has(node.key))) {\n if (child.parentKey == null) {\n // if child is a cell/expanded row/column and the parent key isn't already established by the collection, match child node to parent row\n child.parentKey = node.key;\n }\n\n if (lastNode) {\n lastNode.nextKey = child.key;\n child.prevKey = lastNode.key;\n } else {\n child.prevKey = null;\n }\n\n if (child.type === 'item') {\n visitNode(child, rowIndex++);\n } else {\n // We enforce that the cells come before rows so can just reuse cell index\n visitNode(child, child.index);\n }\n\n lastNode = child;\n }\n }\n\n if (lastNode) {\n lastNode.nextKey = null;\n }\n };\n\n let last: GridNode<T>;\n topLevelRows.forEach((node: GridNode<T>, i) => {\n visitNode(node as GridNode<T>, i);\n\n if (last) {\n last.nextKey = node.key;\n node.prevKey = last.key;\n } else {\n node.prevKey = null;\n }\n\n last = node;\n });\n\n if (last) {\n last.nextKey = null;\n }\n\n return {\n keyMap,\n userColumnCount,\n flattenedRows,\n tableNodes: [...originalColumns, {...body, childNodes: flattenedRows}]\n };\n}\n"],"names":[],"version":3,"file":"useTreeGridState.main.js.map"}