@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.
- package/dist/Cell.main.js +38 -0
- package/dist/Cell.main.js.map +1 -0
- package/dist/Cell.mjs +33 -0
- package/dist/Cell.module.js +33 -0
- package/dist/Cell.module.js.map +1 -0
- package/dist/Column.main.js +75 -0
- package/dist/Column.main.js.map +1 -0
- package/dist/Column.mjs +66 -0
- package/dist/Column.module.js +66 -0
- package/dist/Column.module.js.map +1 -0
- package/dist/Row.main.js +97 -0
- package/dist/Row.main.js.map +1 -0
- package/dist/Row.mjs +88 -0
- package/dist/Row.module.js +88 -0
- package/dist/Row.module.js.map +1 -0
- package/dist/TableBody.main.js +61 -0
- package/dist/TableBody.main.js.map +1 -0
- package/dist/TableBody.mjs +52 -0
- package/dist/TableBody.module.js +52 -0
- package/dist/TableBody.module.js.map +1 -0
- package/dist/TableCollection.main.js +288 -0
- package/dist/TableCollection.main.js.map +1 -0
- package/dist/TableCollection.mjs +282 -0
- package/dist/TableCollection.module.js +282 -0
- package/dist/TableCollection.module.js.map +1 -0
- package/dist/TableColumnLayout.main.js +113 -0
- package/dist/TableColumnLayout.main.js.map +1 -0
- package/dist/TableColumnLayout.mjs +108 -0
- package/dist/TableColumnLayout.module.js +108 -0
- package/dist/TableColumnLayout.module.js.map +1 -0
- package/dist/TableHeader.main.js +56 -0
- package/dist/TableHeader.main.js.map +1 -0
- package/dist/TableHeader.mjs +47 -0
- package/dist/TableHeader.module.js +47 -0
- package/dist/TableHeader.module.js.map +1 -0
- package/dist/TableUtils.main.js +182 -0
- package/dist/TableUtils.main.js.map +1 -0
- package/dist/TableUtils.mjs +175 -0
- package/dist/TableUtils.module.js +175 -0
- package/dist/TableUtils.module.js.map +1 -0
- package/dist/import.mjs +37 -0
- package/dist/main.js +39 -593
- package/dist/main.js.map +1 -1
- package/dist/module.js +22 -564
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +163 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/useTableColumnResizeState.main.js +109 -0
- package/dist/useTableColumnResizeState.main.js.map +1 -0
- package/dist/useTableColumnResizeState.mjs +104 -0
- package/dist/useTableColumnResizeState.module.js +104 -0
- package/dist/useTableColumnResizeState.module.js.map +1 -0
- package/dist/useTableState.main.js +71 -0
- package/dist/useTableState.main.js.map +1 -0
- package/dist/useTableState.mjs +66 -0
- package/dist/useTableState.module.js +66 -0
- package/dist/useTableState.module.js.map +1 -0
- package/dist/useTreeGridState.main.js +207 -0
- package/dist/useTreeGridState.main.js.map +1 -0
- package/dist/useTreeGridState.mjs +202 -0
- package/dist/useTreeGridState.module.js +202 -0
- package/dist/useTreeGridState.module.js.map +1 -0
- package/package.json +18 -10
- package/src/Cell.ts +4 -1
- package/src/Column.ts +12 -2
- package/src/Row.ts +50 -10
- package/src/TableBody.ts +6 -2
- package/src/TableCollection.ts +99 -15
- package/src/TableColumnLayout.ts +127 -0
- package/src/TableHeader.ts +11 -2
- package/src/TableUtils.ts +253 -0
- package/src/index.ts +15 -6
- package/src/useTableColumnResizeState.ts +147 -0
- package/src/useTableState.ts +43 -16
- package/src/useTreeGridState.ts +277 -0
- package/LICENSE +0 -201
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAmBA,MAAMA,yDAAqB,GAAG,uBAAuBC,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAjC,CAArD;;AAEA,SAASC,mDAAT,CAA4BC,MAA5B,EAA2DC,WAA3D,EAAsG;AACpG,MAAIC,OAAO,GAAG,EAAd;AACA,MAAIC,IAAI,GAAG,IAAIC,GAAJ,EAAX;;AACA,OAAK,IAAIC,MAAT,IAAmBJ,WAAnB,EAAgC;AAC9B,QAAIK,SAAS,GAAGD,MAAM,CAACC,SAAvB;AACA,QAAIC,GAAG,GAAG,CAACF,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R,CAAgBY,CAAhB,EAAmBmB,GAA/D,CADK,IAEL8E,UAAU,CAAC1D,uBAAX,KAAuC6B,OAAO,CAAC7B,uBAF1C,IAGL0D,UAAU,CAAC9B,aAAX,KAA6BC,OAAO,CAACD,aAHvC;AAID;;AAhDG,GAAN;AAkDD,CArDD,C,CAuDA;;;OACA,IAAIqC,GAAI,GAAGJ,uCAAX;;AC7EA;;;;;;;;;;;AAgBA,SAASK,yCAAT,CAAchE,KAAd,EAA8C;AAAE;AAC9C,SAAO,IAAP;AACD;;AAEDgE,yCAAI,CAACvB,iBAAL,GAAyB,UAAUA,iBAAV,CAA+BzC,KAA/B,EAA4E;AACnG,MAAI;AAAC6B,IAAAA;AAAD,MAAa7B,KAAjB;AAEA,MAAIhB,SAAS,GAAGgB,KAAK,CAAChB,SAAN,KAAoB,OAAO6C,QAAP,KAAoB,QAApB,GAA+BA,QAA/B,GAA0C,EAA9D,KAAqE7B,KAAK,CAAC,YAAD,CAA1E,IAA4F,EAA5G;AACA,QAAM;AACJvB,IAAAA,IAAI,EAAE,MADF;AAEJuB,IAAAA,KAAK,EAAEA,KAFH;AAGJpB,IAAAA,QAAQ,EAAEiD,QAHN;AAIJ7C,IAAAA,SAJI;AAKJ,kBAAcgB,KAAK,CAAC,YAAD,CALf;AAMJlB,IAAAA,aAAa,EAAE;AANX,GAAN;AAQD,CAZD,C,CAcA;;;OACA,IAAImF,IAAK,GAAGD,yCAAZ","sources":["./packages/@react-stately/table/src/TableCollection.ts","./packages/@react-stately/table/src/useTableState.ts","./packages/@react-stately/table/src/TableHeader.ts","./packages/@react-stately/table/src/TableBody.ts","./packages/@react-stately/table/src/Column.ts","./packages/@react-stately/table/src/Row.ts","./packages/@react-stately/table/src/Cell.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 */\nimport {GridCollection} from '@react-stately/grid';\nimport {GridNode} from '@react-types/grid';\nimport {Key} from 'react';\n\ninterface GridCollectionOptions {\n showSelectionCheckboxes?: boolean\n}\n\nconst ROW_HEADER_COLUMN_KEY = 'row-header-column-' + Math.random().toString(36).slice(2);\n\nfunction buildHeaderRows<T>(keyMap: Map<Key, GridNode<T>>, columnNodes: GridNode<T>[]): GridNode<T>[] {\n let columns = [];\n let seen = new Map();\n for (let column of columnNodes) {\n let parentKey = column.parentKey;\n let col = [column];\n\n while (parentKey) {\n let parent: GridNode<T> = keyMap.get(parentKey);\n\n // If we've already seen this parent, than it is shared\n // with a previous column. If the current column is taller\n // than the previous column, than we need to shift the parent\n // in the previous column so it's level with the current column.\n if (seen.has(parent)) {\n parent.colspan++;\n\n let {column, index} = seen.get(parent);\n if (index > col.length) {\n break;\n }\n\n for (let i = index; i < col.length; i++) {\n column.splice(i, 0, null);\n }\n\n // Adjust shifted indices\n for (let i = col.length; i < column.length; i++) {\n if (column[i] && seen.has(column[i])) {\n seen.get(column[i]).index = i;\n }\n }\n } else {\n parent.colspan = 1;\n col.push(parent);\n seen.set(parent, {column: col, index: col.length - 1});\n }\n\n parentKey = parent.parentKey;\n }\n\n columns.push(col);\n column.index = columns.length - 1;\n }\n\n let maxLength = Math.max(...columns.map(c => c.length));\n let headerRows = Array(maxLength).fill(0).map(() => []);\n\n // Convert columns into rows.\n let colIndex = 0;\n for (let column of columns) {\n let i = maxLength - 1;\n for (let item of column) {\n if (item) {\n // Fill the space up until the current column with a placeholder\n let row = headerRows[i];\n let rowLength = row.reduce((p, c) => p + c.colspan, 0);\n if (rowLength < colIndex) {\n let placeholder: GridNode<T> = {\n type: 'placeholder',\n key: 'placeholder-' + item.key,\n colspan: colIndex - rowLength,\n index: rowLength,\n value: null,\n rendered: null,\n level: i,\n hasChildNodes: false,\n childNodes: [],\n textValue: null\n };\n\n if (row.length > 0) {\n row[row.length - 1].nextKey = placeholder.key;\n placeholder.prevKey = row[row.length - 1].key;\n }\n\n row.push(placeholder);\n }\n\n if (row.length > 0) {\n row[row.length - 1].nextKey = item.key;\n item.prevKey = row[row.length - 1].key;\n }\n\n item.level = i;\n item.index = colIndex;\n row.push(item);\n }\n\n i--;\n }\n\n colIndex++;\n }\n\n // Add placeholders at the end of each row that is shorter than the maximum\n let i = 0;\n for (let row of headerRows) {\n let rowLength = row.reduce((p, c) => p + c.colspan, 0);\n if (rowLength < columnNodes.length) {\n let placeholder: GridNode<T> = {\n type: 'placeholder',\n key: 'placeholder-' + row[row.length - 1].key,\n colspan: columnNodes.length - rowLength,\n index: rowLength,\n value: null,\n rendered: null,\n level: i,\n hasChildNodes: false,\n childNodes: [],\n textValue: null,\n prevKey: row[row.length - 1].key\n };\n\n row.push(placeholder);\n }\n\n i++;\n }\n\n return headerRows.map((childNodes, index) => {\n let row: GridNode<T> = {\n type: 'headerrow',\n key: 'headerrow-' + index,\n index,\n value: null,\n rendered: null,\n level: 0,\n hasChildNodes: true,\n childNodes,\n textValue: null\n };\n\n return row;\n });\n}\n\nexport class TableCollection<T> extends GridCollection<T> {\n headerRows: GridNode<T>[];\n columns: GridNode<T>[];\n rowHeaderColumnKeys: Set<Key>;\n body: GridNode<T>;\n\n constructor(nodes: Iterable<GridNode<T>>, prev?: TableCollection<T>, opts?: GridCollectionOptions) {\n let rowHeaderColumnKeys: Set<Key> = new Set();\n let body: GridNode<T>;\n let columns = [];\n\n // Add cell for selection checkboxes if needed.\n if (opts?.showSelectionCheckboxes) {\n let rowHeaderColumn: GridNode<T> = {\n type: 'column',\n key: ROW_HEADER_COLUMN_KEY,\n value: null,\n textValue: '',\n level: 0,\n index: 0,\n hasChildNodes: false,\n rendered: null,\n childNodes: [],\n props: {\n isSelectionCell: true\n }\n };\n\n columns.unshift(rowHeaderColumn);\n }\n\n let rows = [];\n let columnKeyMap = new Map();\n let visit = (node: GridNode<T>) => {\n switch (node.type) {\n case 'body':\n body = node;\n break;\n case 'column':\n columnKeyMap.set(node.key, node);\n if (!node.hasChildNodes) {\n columns.push(node);\n\n if (node.props.isRowHeader) {\n rowHeaderColumnKeys.add(node.key);\n }\n }\n break;\n case 'item':\n rows.push(node);\n return; // do not go into childNodes\n }\n for (let child of node.childNodes) {\n visit(child);\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n let headerRows = buildHeaderRows(columnKeyMap, columns) as GridNode<T>[];\n headerRows.forEach((row, i) => rows.splice(i, 0, row));\n\n super({\n columnCount: columns.length,\n items: rows,\n visitNode: node => {\n node.column = columns[node.index];\n return node;\n }\n });\n this.columns = columns;\n this.rowHeaderColumnKeys = rowHeaderColumnKeys;\n this.body = body;\n this.headerRows = headerRows;\n\n // Default row header column to the first one.\n if (this.rowHeaderColumnKeys.size === 0) {\n this.rowHeaderColumnKeys.add(this.columns[opts?.showSelectionCheckboxes ? 1 : 0].key);\n }\n }\n\n *[Symbol.iterator]() {\n yield* this.body.childNodes;\n }\n\n get size() {\n return [...this.body.childNodes].length;\n }\n\n getKeys() {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.prevKey : null;\n }\n\n getKeyAfter(key: Key) {\n let node = this.keyMap.get(key);\n return node ? node.nextKey : null;\n }\n\n getFirstKey() {\n return [...this.body.childNodes][0]?.key;\n }\n\n getLastKey() {\n let rows = [...this.body.childNodes];\n return rows[rows.length - 1]?.key;\n }\n\n getItem(key: Key) {\n return this.keyMap.get(key);\n }\n}\n","/*\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 {CollectionBase, MultipleSelection, Node, SelectionMode, Sortable, SortDescriptor, SortDirection} from '@react-types/shared';\nimport {GridState, useGridState} from '@react-stately/grid';\nimport {TableCollection as ITableCollection} from '@react-types/table';\nimport {Key, useMemo} 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): void\n}\n\nexport interface CollectionBuilderContext<T> {\n showSelectionCheckboxes: boolean,\n selectionMode: SelectionMode,\n columns: Node<T>[]\n}\n\nexport interface TableStateProps<T> extends CollectionBase<T>, MultipleSelection, Sortable {\n /** Whether the row selection checkboxes should be displayed. */\n showSelectionCheckboxes?: boolean\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 {selectionMode = 'none'} = props;\n\n let context = useMemo(() => ({\n showSelectionCheckboxes: props.showSelectionCheckboxes && selectionMode !== 'none',\n selectionMode,\n columns: []\n }), [props.children, props.showSelectionCheckboxes, selectionMode]);\n\n let collection = useCollection<T, TableCollection<T>>(\n props,\n (nodes, prev) => new TableCollection(nodes, prev, context),\n context\n );\n let {disabledKeys, selectionManager} = useGridState({...props, collection});\n\n return {\n collection,\n disabledKeys,\n selectionManager,\n showSelectionCheckboxes: props.showSelectionCheckboxes || false,\n sortDescriptor: props.sortDescriptor,\n sort(columnKey: Key) {\n props.onSortChange({\n column: columnKey,\n direction: props.sortDescriptor?.column === columnKey\n ? OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction]\n : 'ascending'\n });\n }\n };\n}\n","/*\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 {PartialNode} from '@react-stately/collections';\nimport React, {ReactElement} from 'react';\nimport {TableHeaderProps} from '@react-types/table';\n\nfunction TableHeader<T>(props: TableHeaderProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nTableHeader.getCollectionNode = function* getCollectionNode<T>(props: TableHeaderProps<T>): Generator<PartialNode<T>, void, any> {\n let {children, columns} = props;\n if (typeof children === 'function') {\n if (!columns) {\n throw new Error('props.children was a function but props.columns is missing');\n }\n\n for (let column of columns) {\n yield {\n type: 'column',\n value: column,\n renderer: children\n };\n }\n } else {\n let columns: PartialNode<T>[] = [];\n React.Children.forEach(children, column => {\n columns.push({\n type: 'column',\n element: column\n });\n });\n\n yield* columns;\n }\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _TableHeader = TableHeader as <T>(props: TableHeaderProps<T>) => JSX.Element;\nexport {_TableHeader as TableHeader};\n","/*\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 {PartialNode} from '@react-stately/collections';\nimport React, {ReactElement} from 'react';\nimport {TableBodyProps} from '@react-types/table';\n\nfunction TableBody<T>(props: TableBodyProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nTableBody.getCollectionNode = function* getCollectionNode<T>(props: TableBodyProps<T>): Generator<PartialNode<T>> {\n let {children, items} = props;\n yield {\n type: 'body',\n hasChildNodes: true,\n props,\n *childNodes() {\n if (typeof children === 'function') {\n if (!items) {\n throw new Error('props.children was a function but props.items is missing');\n }\n \n for (let item of items) {\n yield {\n type: 'item',\n value: item,\n renderer: children\n };\n }\n } else {\n let items: PartialNode<T>[] = [];\n React.Children.forEach(children, item => {\n items.push({\n type: 'item',\n element: item\n });\n });\n\n yield* items;\n }\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _TableBody = TableBody as <T>(props: TableBodyProps<T>) => JSX.Element;\nexport {_TableBody as TableBody};\n","/*\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 {CollectionBuilderContext} from './useTableState';\nimport {ColumnProps} from '@react-types/table';\nimport {GridNode} from '@react-types/grid';\nimport {PartialNode} from '@react-stately/collections';\nimport React, {ReactElement} from 'react';\n\nfunction Column<T>(props: ColumnProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nColumn.getCollectionNode = function* getCollectionNode<T>(props: ColumnProps<T>, context: CollectionBuilderContext<T>): Generator<PartialNode<T>, void, GridNode<T>[]> {\n let {title, children, childColumns} = props;\n let fullNodes = yield {\n type: 'column',\n hasChildNodes: !!childColumns || (title && React.Children.count(children) > 0),\n rendered: title || children,\n props,\n *childNodes() {\n if (childColumns) {\n for (let child of childColumns) {\n yield {\n type: 'column',\n value: child\n };\n }\n } else if (title) {\n let childColumns: PartialNode<T>[] = [];\n React.Children.forEach(children, child => {\n childColumns.push({\n type: 'column',\n element: child as ReactElement<ColumnProps<T>>\n });\n });\n\n yield* childColumns;\n }\n },\n shouldInvalidate(newContext: CollectionBuilderContext<T>) {\n // This is a bit of a hack, but it works.\n // If this method is called, then there's a cached version of this node available.\n // But, we need to keep the list of columns in the new context up to date.\n updateContext(newContext);\n return false;\n }\n };\n\n let updateContext = (context: CollectionBuilderContext<T>) => {\n // register leaf columns on the context so that <Row> can access them\n for (let node of fullNodes) {\n if (!node.hasChildNodes) {\n context.columns.push(node);\n }\n }\n };\n\n updateContext(context);\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Column = Column as <T>(props: ColumnProps<T>) => JSX.Element;\nexport {_Column as Column};\n","/*\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 {CollectionBuilderContext} from './useTableState';\nimport {PartialNode} from '@react-stately/collections';\nimport React, {ReactElement} from 'react';\nimport {RowProps} from '@react-types/table';\n\nfunction Row(props: RowProps): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nRow.getCollectionNode = function* getCollectionNode<T>(props: RowProps, context: CollectionBuilderContext<T>): Generator<PartialNode<T>> {\n let {children, textValue} = props;\n\n yield {\n type: 'item',\n props: props,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: true,\n *childNodes() {\n // Process cells first\n if (context.showSelectionCheckboxes && context.selectionMode !== 'none') {\n yield {\n type: 'cell',\n key: 'header', // this is combined with the row key by CollectionBuilder\n props: {\n isSelectionCell: true\n }\n };\n }\n\n if (typeof children === 'function') {\n for (let column of context.columns) {\n yield {\n type: 'cell',\n element: children(column.key),\n key: column.key // this is combined with the row key by CollectionBuilder\n };\n }\n } else {\n let cells: PartialNode<T>[] = [];\n React.Children.forEach(children, cell => {\n cells.push({\n type: 'cell',\n element: cell\n });\n });\n\n if (cells.length !== context.columns.length) {\n throw new Error(`Cell count must match column count. Found ${cells.length} cells and ${context.columns.length} columns.`);\n }\n\n yield* cells;\n }\n },\n shouldInvalidate(newContext: CollectionBuilderContext<T>) {\n // Invalidate all rows if the columns changed.\n return newContext.columns.length !== context.columns.length ||\n newContext.columns.some((c, i) => c.key !== context.columns[i].key) ||\n newContext.showSelectionCheckboxes !== context.showSelectionCheckboxes ||\n newContext.selectionMode !== context.selectionMode;\n }\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Row = Row as (props: RowProps) => JSX.Element;\nexport {_Row as Row};\n","/*\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 {CellProps} from '@react-types/table';\nimport {PartialNode} from '@react-stately/collections';\nimport {ReactElement} from 'react';\n\nfunction Cell(props: CellProps): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n return null;\n}\n\nCell.getCollectionNode = function* getCollectionNode<T>(props: CellProps): Generator<PartialNode<T>> {\n let {children} = props;\n\n let textValue = props.textValue || (typeof children === 'string' ? children : '') || props['aria-label'] || '';\n yield {\n type: 'cell',\n props: props,\n rendered: children,\n textValue,\n 'aria-label': props['aria-label'],\n hasChildNodes: false\n };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Cell = Cell as (props: CellProps) => JSX.Element;\nexport {_Cell as Cell};\n"],"names":["ROW_HEADER_COLUMN_KEY","Math","random","toString","slice","buildHeaderRows","keyMap","columnNodes","columns","seen","Map","column","parentKey","col","parent","get","has","colspan","index","length","i","splice","push","set","maxLength","max","map","c","headerRows","Array","fill","colIndex","item","row","rowLength","reduce","p","placeholder","type","key","value","rendered","level","hasChildNodes","childNodes","textValue","nextKey","prevKey","Symbol","iterator","TableCollection","GridCollection","constructor","nodes","prev","opts","rowHeaderColumnKeys","Set","body","showSelectionCheckboxes","rowHeaderColumn","props","isSelectionCell","unshift","rows","columnKeyMap","visit","node","isRowHeader","add","child","forEach","columnCount","items","visitNode","size","getKeys","keys","getKeyBefore","getKeyAfter","getFirstKey","getLastKey","getItem","OPPOSITE_SORT_DIRECTION","ascending","descending","useTableState","selectionMode","context","useMemo","children","collection","useCollection","disabledKeys","selectionManager","useGridState","sortDescriptor","sort","columnKey","onSortChange","direction","TableHeader","getCollectionNode","Error","renderer","React","Children","element","_TableHeader","TableBody","_TableBody","Column","title","childColumns","fullNodes","count","shouldInvalidate","newContext","updateContext","_Column","Row","cells","cell","some","_Row","Cell","_Cell"],"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} 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
|
@@ -1,36 +1,190 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { ColumnSize, TableCollection as _TableCollection1, TableBodyProps, TableHeaderProps, ColumnProps, RowProps, CellProps } from "@react-types/table";
|
|
2
|
+
import { GridNode } from "@react-types/grid";
|
|
3
|
+
import { Key, Node, SelectionMode, Sortable, SortDescriptor } from "@react-types/shared";
|
|
4
|
+
import { GridCollection, GridState } from "@react-stately/grid";
|
|
5
|
+
import { MultipleSelectionState, MultipleSelectionStateProps } from "@react-stately/selection";
|
|
6
|
+
import { ReactElement, JSX } from "react";
|
|
7
|
+
interface TableColumnLayoutOptions<T> {
|
|
8
|
+
getDefaultWidth?: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
9
|
+
getDefaultMinWidth?: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
10
|
+
}
|
|
11
|
+
export class TableColumnLayout<T> {
|
|
12
|
+
getDefaultWidth: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
13
|
+
getDefaultMinWidth: (column: GridNode<T>) => ColumnSize | null | undefined;
|
|
14
|
+
columnWidths: Map<Key, number>;
|
|
15
|
+
columnMinWidths: Map<Key, number>;
|
|
16
|
+
columnMaxWidths: Map<Key, number>;
|
|
17
|
+
constructor(options: TableColumnLayoutOptions<T>);
|
|
18
|
+
/** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */
|
|
19
|
+
splitColumnsIntoControlledAndUncontrolled(columns: Array<GridNode<T>>): [Map<Key, GridNode<T>>, Map<Key, GridNode<T>>];
|
|
20
|
+
/** Takes uncontrolled and controlled widths and joins them into a single Map. */
|
|
21
|
+
recombineColumns(columns: Array<GridNode<T>>, uncontrolledWidths: Map<Key, ColumnSize>, uncontrolledColumns: Map<Key, GridNode<T>>, controlledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize>;
|
|
22
|
+
/** Used to make an initial Map of the uncontrolled widths based on default widths. */
|
|
23
|
+
getInitialUncontrolledWidths(uncontrolledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize>;
|
|
24
|
+
getColumnWidth(key: Key): number;
|
|
25
|
+
getColumnMinWidth(key: Key): number;
|
|
26
|
+
getColumnMaxWidth(key: Key): number;
|
|
27
|
+
resizeColumnWidth(collection: _TableCollection1<T>, uncontrolledWidths: Map<Key, ColumnSize>, col: Key, width: number): Map<Key, ColumnSize>;
|
|
28
|
+
buildColumnWidths(tableWidth: number, collection: _TableCollection1<T>, widths: Map<Key, ColumnSize>): Map<Key, number>;
|
|
29
|
+
}
|
|
30
|
+
interface GridCollectionOptions {
|
|
31
|
+
showSelectionCheckboxes?: boolean;
|
|
32
|
+
showDragButtons?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** @private */
|
|
35
|
+
export function buildHeaderRows<T>(keyMap: Map<Key, GridNode<T>>, columnNodes: GridNode<T>[]): GridNode<T>[];
|
|
36
|
+
export class TableCollection<T> extends GridCollection<T> implements _TableCollection1<T> {
|
|
37
|
+
headerRows: GridNode<T>[];
|
|
38
|
+
columns: GridNode<T>[];
|
|
39
|
+
rowHeaderColumnKeys: Set<Key>;
|
|
40
|
+
body: GridNode<T>;
|
|
41
|
+
_size: number;
|
|
42
|
+
constructor(nodes: Iterable<GridNode<T>>, prev?: _TableCollection1<T>, opts?: GridCollectionOptions);
|
|
43
|
+
[Symbol.iterator](): Generator<Node<T>, void, undefined>;
|
|
44
|
+
get size(): number;
|
|
45
|
+
getKeys(): IterableIterator<Key>;
|
|
46
|
+
getKeyBefore(key: Key): Key;
|
|
47
|
+
getKeyAfter(key: Key): Key;
|
|
48
|
+
getFirstKey(): Key;
|
|
49
|
+
getLastKey(): Key;
|
|
50
|
+
getItem(key: Key): GridNode<T>;
|
|
51
|
+
at(idx: number): GridNode<T>;
|
|
52
|
+
getChildren(key: Key): Iterable<GridNode<T>>;
|
|
53
|
+
getTextValue(key: Key): string;
|
|
54
|
+
}
|
|
55
|
+
export interface TableState<T> extends GridState<T, _TableCollection1<T>> {
|
|
6
56
|
/** A collection of rows and columns in the table. */
|
|
7
|
-
collection:
|
|
57
|
+
collection: _TableCollection1<T>;
|
|
8
58
|
/** Whether the row selection checkboxes should be displayed. */
|
|
9
59
|
showSelectionCheckboxes: boolean;
|
|
10
60
|
/** The current sorted column and direction. */
|
|
11
61
|
sortDescriptor: SortDescriptor;
|
|
12
62
|
/** Calls the provided onSortChange handler with the provided column key and sort direction. */
|
|
13
|
-
sort(columnKey: Key): void;
|
|
63
|
+
sort(columnKey: Key, direction?: 'ascending' | 'descending'): void;
|
|
64
|
+
/** Whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */
|
|
65
|
+
isKeyboardNavigationDisabled: boolean;
|
|
66
|
+
/** Set whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */
|
|
67
|
+
setKeyboardNavigationDisabled: (val: boolean) => void;
|
|
14
68
|
}
|
|
15
69
|
export interface CollectionBuilderContext<T> {
|
|
16
70
|
showSelectionCheckboxes: boolean;
|
|
71
|
+
showDragButtons: boolean;
|
|
17
72
|
selectionMode: SelectionMode;
|
|
18
73
|
columns: Node<T>[];
|
|
19
74
|
}
|
|
20
|
-
export interface TableStateProps<T> extends
|
|
75
|
+
export interface TableStateProps<T> extends MultipleSelectionStateProps, Sortable {
|
|
76
|
+
/** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */
|
|
77
|
+
children?: [ReactElement<TableHeaderProps<T>>, ReactElement<TableBodyProps<T>>];
|
|
78
|
+
/** A list of row keys to disable. */
|
|
79
|
+
disabledKeys?: Iterable<Key>;
|
|
80
|
+
/** A pre-constructed collection to use instead of building one from items and children. */
|
|
81
|
+
collection?: _TableCollection1<T>;
|
|
21
82
|
/** Whether the row selection checkboxes should be displayed. */
|
|
22
83
|
showSelectionCheckboxes?: boolean;
|
|
84
|
+
/** Whether the row drag button should be displayed.
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
showDragButtons?: boolean;
|
|
88
|
+
/** @private - do not use unless you know what you're doing. */
|
|
89
|
+
UNSAFE_selectionState?: MultipleSelectionState;
|
|
23
90
|
}
|
|
24
91
|
/**
|
|
25
92
|
* Provides state management for a table component. Handles building a collection
|
|
26
93
|
* of columns and rows from props. In addition, it tracks row selection and manages sort order changes.
|
|
27
94
|
*/
|
|
28
95
|
export function useTableState<T extends object>(props: TableStateProps<T>): TableState<T>;
|
|
96
|
+
export interface TableColumnResizeStateProps<T> {
|
|
97
|
+
/**
|
|
98
|
+
* Current width of the table or table viewport that the columns
|
|
99
|
+
* should be calculated against.
|
|
100
|
+
*/
|
|
101
|
+
tableWidth: number;
|
|
102
|
+
/** A function that is called to find the default width for a given column. */
|
|
103
|
+
getDefaultWidth?: (node: GridNode<T>) => ColumnSize | null | undefined;
|
|
104
|
+
/** A function that is called to find the default minWidth for a given column. */
|
|
105
|
+
getDefaultMinWidth?: (node: GridNode<T>) => ColumnSize | null | undefined;
|
|
106
|
+
}
|
|
107
|
+
export interface TableColumnResizeState<T> {
|
|
108
|
+
/**
|
|
109
|
+
* Called to update the state that a resize event has occurred.
|
|
110
|
+
* Returns the new widths for all columns based on the resized column.
|
|
111
|
+
*/
|
|
112
|
+
updateResizedColumns: (key: Key, width: number) => Map<Key, ColumnSize>;
|
|
113
|
+
/** Callback for when onColumnResize has started. */
|
|
114
|
+
startResize: (key: Key) => void;
|
|
115
|
+
/** Callback for when onColumnResize has ended. */
|
|
116
|
+
endResize: () => void;
|
|
117
|
+
/** Gets the current width for the specified column. */
|
|
118
|
+
getColumnWidth: (key: Key) => number;
|
|
119
|
+
/** Gets the current minWidth for the specified column. */
|
|
120
|
+
getColumnMinWidth: (key: Key) => number;
|
|
121
|
+
/** Gets the current maxWidth for the specified column. */
|
|
122
|
+
getColumnMaxWidth: (key: Key) => number;
|
|
123
|
+
/** Key of the currently resizing column. */
|
|
124
|
+
resizingColumn: Key | null;
|
|
125
|
+
/** A reference to the table state. */
|
|
126
|
+
tableState: TableState<T>;
|
|
127
|
+
/** A map of the current column widths. */
|
|
128
|
+
columnWidths: Map<Key, number>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Provides column width state management for a table component with column resizing support. Handles building
|
|
132
|
+
* a map of column widths calculated from the table's width and any provided column width information from the collection.
|
|
133
|
+
* In addition, it tracks the currently resizing column and provides callbacks for updating the widths upon resize operations.
|
|
134
|
+
* @param props - Props for the table.
|
|
135
|
+
* @param state - State for the table, as returned by `useTableState`.
|
|
136
|
+
*/
|
|
137
|
+
export function useTableColumnResizeState<T>(props: TableColumnResizeStateProps<T>, state: TableState<T>): TableColumnResizeState<T>;
|
|
138
|
+
export interface TreeGridState<T> extends TableState<T> {
|
|
139
|
+
/** A set of keys for items that are expanded. */
|
|
140
|
+
expandedKeys: 'all' | Set<Key>;
|
|
141
|
+
/** Toggles the expanded state for a row by its key. */
|
|
142
|
+
toggleKey(key: Key): void;
|
|
143
|
+
/** The key map containing nodes representing the collection's tree grid structure. */
|
|
144
|
+
keyMap: Map<Key, GridNode<T>>;
|
|
145
|
+
/** The number of leaf columns provided by the user. */
|
|
146
|
+
userColumnCount: number;
|
|
147
|
+
}
|
|
148
|
+
export interface TreeGridStateProps<T> extends Omit<TableStateProps<T>, 'collection'> {
|
|
149
|
+
/** The currently expanded keys in the collection (controlled). */
|
|
150
|
+
UNSTABLE_expandedKeys?: 'all' | Iterable<Key>;
|
|
151
|
+
/** The initial expanded keys in the collection (uncontrolled). */
|
|
152
|
+
UNSTABLE_defaultExpandedKeys?: 'all' | Iterable<Key>;
|
|
153
|
+
/** Handler that is called when items are expanded or collapsed. */
|
|
154
|
+
UNSTABLE_onExpandedChange?: (keys: Set<Key>) => any;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Provides state management for a tree grid component. Handles building a collection
|
|
158
|
+
* of columns and rows from props. In addition, it tracks and manages expanded rows, row selection, and sort order changes.
|
|
159
|
+
*/
|
|
160
|
+
export function UNSTABLE_useTreeGridState<T extends object>(props: TreeGridStateProps<T>): TreeGridState<T>;
|
|
161
|
+
/**
|
|
162
|
+
* A TableHeader is a container for the Column elements in a Table. Columns can be statically defined
|
|
163
|
+
* as children, or generated dynamically using a function based on the data passed to the `columns` prop.
|
|
164
|
+
*/
|
|
29
165
|
export let TableHeader: <T>(props: TableHeaderProps<T>) => JSX.Element;
|
|
166
|
+
/**
|
|
167
|
+
* A TableBody is a container for the Row elements of a Table. Rows can be statically defined
|
|
168
|
+
* as children, or generated dynamically using a function based on the data passed to the `items` prop.
|
|
169
|
+
*/
|
|
30
170
|
export let TableBody: <T>(props: TableBodyProps<T>) => JSX.Element;
|
|
171
|
+
/**
|
|
172
|
+
* A Column represents a field of each item within a Table. Columns may also contain nested
|
|
173
|
+
* Column elements to represent column groups. Nested columns can be statically defined as
|
|
174
|
+
* children, or dynamically generated using a function based on the `childColumns` prop.
|
|
175
|
+
*/
|
|
31
176
|
export let Column: <T>(props: ColumnProps<T>) => JSX.Element;
|
|
32
|
-
|
|
177
|
+
/**
|
|
178
|
+
* A Row represents a single item in a Table and contains Cell elements for each column.
|
|
179
|
+
* Cells can be statically defined as children, or generated dynamically using a function
|
|
180
|
+
* based on the columns defined in the TableHeader.
|
|
181
|
+
*/
|
|
182
|
+
export let Row: <T>(props: RowProps<T>) => JSX.Element;
|
|
183
|
+
/**
|
|
184
|
+
* A Cell represents the value of a single Column within a Table Row.
|
|
185
|
+
*/
|
|
33
186
|
export let Cell: (props: CellProps) => JSX.Element;
|
|
187
|
+
export type { TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps } from '@react-types/table';
|
|
34
188
|
export { Section } from '@react-stately/collections';
|
|
35
189
|
|
|
36
190
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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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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} 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"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var $2240a72410c17d51$exports = require("./TableColumnLayout.main.js");
|
|
2
|
+
var $cVZrS$react = require("react");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useTableColumnResizeState", () => $7aa22d80cd4ca621$export$cb895dcf85db1319);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function $7aa22d80cd4ca621$export$cb895dcf85db1319(props, state) {
|
|
23
|
+
let { getDefaultWidth: getDefaultWidth, getDefaultMinWidth: getDefaultMinWidth, tableWidth: tableWidth = 0 } = props;
|
|
24
|
+
let [resizingColumn, setResizingColumn] = (0, $cVZrS$react.useState)(null);
|
|
25
|
+
let columnLayout = (0, $cVZrS$react.useMemo)(()=>new (0, $2240a72410c17d51$exports.TableColumnLayout)({
|
|
26
|
+
getDefaultWidth: getDefaultWidth,
|
|
27
|
+
getDefaultMinWidth: getDefaultMinWidth
|
|
28
|
+
}), [
|
|
29
|
+
getDefaultWidth,
|
|
30
|
+
getDefaultMinWidth
|
|
31
|
+
]);
|
|
32
|
+
let [controlledColumns, uncontrolledColumns] = (0, $cVZrS$react.useMemo)(()=>columnLayout.splitColumnsIntoControlledAndUncontrolled(state.collection.columns), [
|
|
33
|
+
state.collection.columns,
|
|
34
|
+
columnLayout
|
|
35
|
+
]);
|
|
36
|
+
// uncontrolled column widths
|
|
37
|
+
let [uncontrolledWidths, setUncontrolledWidths] = (0, $cVZrS$react.useState)(()=>columnLayout.getInitialUncontrolledWidths(uncontrolledColumns));
|
|
38
|
+
// Update uncontrolled widths if the columns changed.
|
|
39
|
+
let [lastColumns, setLastColumns] = (0, $cVZrS$react.useState)(state.collection.columns);
|
|
40
|
+
if (state.collection.columns !== lastColumns) {
|
|
41
|
+
if (state.collection.columns.length !== lastColumns.length || state.collection.columns.some((c, i)=>c.key !== lastColumns[i].key)) {
|
|
42
|
+
let newUncontrolledWidths = columnLayout.getInitialUncontrolledWidths(uncontrolledColumns);
|
|
43
|
+
setUncontrolledWidths(newUncontrolledWidths);
|
|
44
|
+
}
|
|
45
|
+
setLastColumns(state.collection.columns);
|
|
46
|
+
}
|
|
47
|
+
// combine columns back into one map that maintains same order as the columns
|
|
48
|
+
let colWidths = (0, $cVZrS$react.useMemo)(()=>columnLayout.recombineColumns(state.collection.columns, uncontrolledWidths, uncontrolledColumns, controlledColumns), [
|
|
49
|
+
state.collection.columns,
|
|
50
|
+
uncontrolledWidths,
|
|
51
|
+
uncontrolledColumns,
|
|
52
|
+
controlledColumns,
|
|
53
|
+
columnLayout
|
|
54
|
+
]);
|
|
55
|
+
let startResize = (0, $cVZrS$react.useCallback)((key)=>{
|
|
56
|
+
setResizingColumn(key);
|
|
57
|
+
}, [
|
|
58
|
+
setResizingColumn
|
|
59
|
+
]);
|
|
60
|
+
let updateResizedColumns = (0, $cVZrS$react.useCallback)((key, width)=>{
|
|
61
|
+
let newSizes = columnLayout.resizeColumnWidth(state.collection, uncontrolledWidths, key, width);
|
|
62
|
+
let map = new Map(Array.from(uncontrolledColumns).map(([key])=>[
|
|
63
|
+
key,
|
|
64
|
+
newSizes.get(key)
|
|
65
|
+
]));
|
|
66
|
+
map.set(key, width);
|
|
67
|
+
setUncontrolledWidths(map);
|
|
68
|
+
return newSizes;
|
|
69
|
+
}, [
|
|
70
|
+
uncontrolledColumns,
|
|
71
|
+
setUncontrolledWidths,
|
|
72
|
+
columnLayout,
|
|
73
|
+
state.collection,
|
|
74
|
+
uncontrolledWidths
|
|
75
|
+
]);
|
|
76
|
+
let endResize = (0, $cVZrS$react.useCallback)(()=>{
|
|
77
|
+
setResizingColumn(null);
|
|
78
|
+
}, [
|
|
79
|
+
setResizingColumn
|
|
80
|
+
]);
|
|
81
|
+
let columnWidths = (0, $cVZrS$react.useMemo)(()=>columnLayout.buildColumnWidths(tableWidth, state.collection, colWidths), [
|
|
82
|
+
tableWidth,
|
|
83
|
+
state.collection,
|
|
84
|
+
colWidths,
|
|
85
|
+
columnLayout
|
|
86
|
+
]);
|
|
87
|
+
return (0, $cVZrS$react.useMemo)(()=>({
|
|
88
|
+
resizingColumn: resizingColumn,
|
|
89
|
+
updateResizedColumns: updateResizedColumns,
|
|
90
|
+
startResize: startResize,
|
|
91
|
+
endResize: endResize,
|
|
92
|
+
getColumnWidth: (key)=>columnLayout.getColumnWidth(key),
|
|
93
|
+
getColumnMinWidth: (key)=>columnLayout.getColumnMinWidth(key),
|
|
94
|
+
getColumnMaxWidth: (key)=>columnLayout.getColumnMaxWidth(key),
|
|
95
|
+
tableState: state,
|
|
96
|
+
columnWidths: columnWidths
|
|
97
|
+
}), [
|
|
98
|
+
columnLayout,
|
|
99
|
+
columnWidths,
|
|
100
|
+
resizingColumn,
|
|
101
|
+
updateResizedColumns,
|
|
102
|
+
startResize,
|
|
103
|
+
endResize,
|
|
104
|
+
state
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=useTableColumnResiz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oBACnG;QAAC,MAAM,UAAU,CAAC,OAAO;QAAE;QAAoB;QAAqB;QAAmB;KAAa;IAEtG,IAAI,cAAc,CAAA,GAAA,wBAAU,EAAE,CAAC;QAC7B,kBAAkB;IACpB,GAAG;QAAC;KAAkB;IAEtB,IAAI,uBAAuB,CAAA,GAAA,wBAAU,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,wBAAU,EAAE;QAC1B,kBAAkB;IACpB,GAAG;QAAC;KAAkB;IAEtB,IAAI,eAAe,CAAA,GAAA,oBAAM,EAAE,IACzB,aAAa,iBAAiB,CAAC,YAAY,MAAM,UAAU,EAAE,YAC7D;QAAC;QAAY,MAAM,UAAU;QAAE;QAAW;KAAa;IAEzD,OAAO,CAAA,GAAA,oBAAM,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.main.js.map"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {TableColumnLayout as $a9e7ae544a4e41dd$export$7ff77a162970b30e} from "./TableColumnLayout.mjs";
|
|
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
|
+
//# sourceMappingURL=useTableColumnResizeState.module.js.map
|