@react-stately/table
Advanced tools
Comparing version 3.0.0-nightly-d57bd8d90-240927 to 3.0.0-nightly-d87cc4422-250109
@@ -33,3 +33,3 @@ var $kykIu$react = require("react"); | ||
type: 'column', | ||
hasChildNodes: !!childColumns || title && (0, ($parcel$interopDefault($kykIu$react))).Children.count(children) > 0, | ||
hasChildNodes: !!childColumns || !!title && (0, ($parcel$interopDefault($kykIu$react))).Children.count(children) > 0, | ||
rendered: rendered, | ||
@@ -36,0 +36,0 @@ textValue: textValue, |
@@ -23,3 +23,3 @@ import $kIQ5E$react from "react"; | ||
type: 'column', | ||
hasChildNodes: !!childColumns || title && (0, $kIQ5E$react).Children.count(children) > 0, | ||
hasChildNodes: !!childColumns || !!title && (0, $kIQ5E$react).Children.count(children) > 0, | ||
rendered: rendered, | ||
@@ -26,0 +26,0 @@ textValue: textValue, |
@@ -43,2 +43,5 @@ var $bkA0E$reactstatelycollections = require("@react-stately/collections"); | ||
if (seen.has(parent)) { | ||
var _parent; | ||
var _colspan; | ||
(_colspan = (_parent = parent).colspan) !== null && _colspan !== void 0 ? _colspan : _parent.colspan = 0; | ||
parent.colspan++; | ||
@@ -74,3 +77,6 @@ let { column: column, index: index } = seen.get(parent); | ||
let row = headerRows[i]; | ||
let rowLength = row.reduce((p, c)=>p + c.colspan, 0); | ||
let rowLength = row.reduce((p, c)=>{ | ||
var _c_colspan; | ||
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1); | ||
}, 0); | ||
if (rowLength < colIndex) { | ||
@@ -87,3 +93,3 @@ let placeholder = { | ||
childNodes: [], | ||
textValue: null | ||
textValue: '' | ||
}; | ||
@@ -112,3 +118,6 @@ // eslint-disable-next-line max-depth | ||
for (let row of headerRows){ | ||
let rowLength = row.reduce((p, c)=>p + c.colspan, 0); | ||
let rowLength = row.reduce((p, c)=>{ | ||
var _c_colspan; | ||
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1); | ||
}, 0); | ||
if (rowLength < columnNodes.length) { | ||
@@ -125,3 +134,3 @@ let placeholder = { | ||
childNodes: [], | ||
textValue: null, | ||
textValue: '', | ||
prevKey: row[row.length - 1].key | ||
@@ -143,3 +152,3 @@ }; | ||
childNodes: childNodes, | ||
textValue: null | ||
textValue: '' | ||
}; | ||
@@ -161,18 +170,23 @@ return row; | ||
let node = this.keyMap.get(key); | ||
return node ? node.prevKey : null; | ||
var _node_prevKey; | ||
return (_node_prevKey = node === null || node === void 0 ? void 0 : node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null; | ||
} | ||
getKeyAfter(key) { | ||
let node = this.keyMap.get(key); | ||
return node ? node.nextKey : null; | ||
var _node_nextKey; | ||
return (_node_nextKey = node === null || node === void 0 ? void 0 : node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null; | ||
} | ||
getFirstKey() { | ||
var _getFirstItem; | ||
return (_getFirstItem = (0, $bkA0E$reactstatelycollections.getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key; | ||
var _getFirstItem_key; | ||
return (_getFirstItem_key = (_getFirstItem = (0, $bkA0E$reactstatelycollections.getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null; | ||
} | ||
getLastKey() { | ||
var _getLastItem; | ||
return (_getLastItem = (0, $bkA0E$reactstatelycollections.getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key; | ||
var _getLastItem_key; | ||
return (_getLastItem_key = (_getLastItem = (0, $bkA0E$reactstatelycollections.getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null; | ||
} | ||
getItem(key) { | ||
return this.keyMap.get(key); | ||
var _this_keyMap_get; | ||
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null; | ||
} | ||
@@ -209,3 +223,3 @@ at(idx) { | ||
let rowHeaderColumnKeys = new Set(); | ||
let body; | ||
let body = null; | ||
let columns = []; | ||
@@ -278,4 +292,3 @@ // Add cell for selection checkboxes if needed. | ||
} | ||
}); | ||
this._size = 0; | ||
}), this._size = 0; | ||
this.columns = columns; | ||
@@ -289,6 +302,9 @@ this.rowHeaderColumnKeys = rowHeaderColumnKeys; | ||
// Default row header column to the first one. | ||
if (this.rowHeaderColumnKeys.size === 0) this.rowHeaderColumnKeys.add(this.columns.find((column)=>{ | ||
var _column_props, _column_props1; | ||
return !((_column_props = column.props) === null || _column_props === void 0 ? void 0 : _column_props.isDragButtonCell) && !((_column_props1 = column.props) === null || _column_props1 === void 0 ? void 0 : _column_props1.isSelectionCell); | ||
}).key); | ||
if (this.rowHeaderColumnKeys.size === 0) { | ||
let col = this.columns.find((column)=>{ | ||
var _column_props, _column_props1; | ||
return !((_column_props = column.props) === null || _column_props === void 0 ? void 0 : _column_props.isDragButtonCell) && !((_column_props1 = column.props) === null || _column_props1 === void 0 ? void 0 : _column_props1.isSelectionCell); | ||
}); | ||
if (col) this.rowHeaderColumnKeys.add(col.key); | ||
} | ||
} | ||
@@ -295,0 +311,0 @@ } |
@@ -36,2 +36,5 @@ import {getFirstItem as $iLnZt$getFirstItem, getLastItem as $iLnZt$getLastItem} from "@react-stately/collections"; | ||
if (seen.has(parent)) { | ||
var _parent; | ||
var _colspan; | ||
(_colspan = (_parent = parent).colspan) !== null && _colspan !== void 0 ? _colspan : _parent.colspan = 0; | ||
parent.colspan++; | ||
@@ -67,3 +70,6 @@ let { column: column, index: index } = seen.get(parent); | ||
let row = headerRows[i]; | ||
let rowLength = row.reduce((p, c)=>p + c.colspan, 0); | ||
let rowLength = row.reduce((p, c)=>{ | ||
var _c_colspan; | ||
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1); | ||
}, 0); | ||
if (rowLength < colIndex) { | ||
@@ -80,3 +86,3 @@ let placeholder = { | ||
childNodes: [], | ||
textValue: null | ||
textValue: '' | ||
}; | ||
@@ -105,3 +111,6 @@ // eslint-disable-next-line max-depth | ||
for (let row of headerRows){ | ||
let rowLength = row.reduce((p, c)=>p + c.colspan, 0); | ||
let rowLength = row.reduce((p, c)=>{ | ||
var _c_colspan; | ||
return p + ((_c_colspan = c.colspan) !== null && _c_colspan !== void 0 ? _c_colspan : 1); | ||
}, 0); | ||
if (rowLength < columnNodes.length) { | ||
@@ -118,3 +127,3 @@ let placeholder = { | ||
childNodes: [], | ||
textValue: null, | ||
textValue: '', | ||
prevKey: row[row.length - 1].key | ||
@@ -136,3 +145,3 @@ }; | ||
childNodes: childNodes, | ||
textValue: null | ||
textValue: '' | ||
}; | ||
@@ -154,18 +163,23 @@ return row; | ||
let node = this.keyMap.get(key); | ||
return node ? node.prevKey : null; | ||
var _node_prevKey; | ||
return (_node_prevKey = node === null || node === void 0 ? void 0 : node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null; | ||
} | ||
getKeyAfter(key) { | ||
let node = this.keyMap.get(key); | ||
return node ? node.nextKey : null; | ||
var _node_nextKey; | ||
return (_node_nextKey = node === null || node === void 0 ? void 0 : node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null; | ||
} | ||
getFirstKey() { | ||
var _getFirstItem; | ||
return (_getFirstItem = (0, $iLnZt$getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key; | ||
var _getFirstItem_key; | ||
return (_getFirstItem_key = (_getFirstItem = (0, $iLnZt$getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null; | ||
} | ||
getLastKey() { | ||
var _getLastItem; | ||
return (_getLastItem = (0, $iLnZt$getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key; | ||
var _getLastItem_key; | ||
return (_getLastItem_key = (_getLastItem = (0, $iLnZt$getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null; | ||
} | ||
getItem(key) { | ||
return this.keyMap.get(key); | ||
var _this_keyMap_get; | ||
return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null; | ||
} | ||
@@ -202,3 +216,3 @@ at(idx) { | ||
let rowHeaderColumnKeys = new Set(); | ||
let body; | ||
let body = null; | ||
let columns = []; | ||
@@ -271,4 +285,3 @@ // Add cell for selection checkboxes if needed. | ||
} | ||
}); | ||
this._size = 0; | ||
}), this._size = 0; | ||
this.columns = columns; | ||
@@ -282,6 +295,9 @@ this.rowHeaderColumnKeys = rowHeaderColumnKeys; | ||
// Default row header column to the first one. | ||
if (this.rowHeaderColumnKeys.size === 0) this.rowHeaderColumnKeys.add(this.columns.find((column)=>{ | ||
var _column_props, _column_props1; | ||
return !((_column_props = column.props) === null || _column_props === void 0 ? void 0 : _column_props.isDragButtonCell) && !((_column_props1 = column.props) === null || _column_props1 === void 0 ? void 0 : _column_props1.isSelectionCell); | ||
}).key); | ||
if (this.rowHeaderColumnKeys.size === 0) { | ||
let col = this.columns.find((column)=>{ | ||
var _column_props, _column_props1; | ||
return !((_column_props = column.props) === null || _column_props === void 0 ? void 0 : _column_props.isDragButtonCell) && !((_column_props1 = column.props) === null || _column_props1 === void 0 ? void 0 : _column_props1.isSelectionCell); | ||
}); | ||
if (col) this.rowHeaderColumnKeys.add(col.key); | ||
} | ||
} | ||
@@ -288,0 +304,0 @@ } |
@@ -71,3 +71,3 @@ var $9e5f6a0caf75716e$exports = require("./TableUtils.main.js"); | ||
collection.columns.forEach((column)=>{ | ||
var _column_props_width; | ||
var _prevColumnWidths_get, _column_props_width; | ||
if (column.key === col) { | ||
@@ -77,3 +77,3 @@ newWidths.set(column.key, width); | ||
} else if (freeze) // freeze columns to the left to their previous pixel value | ||
newWidths.set(column.key, prevColumnWidths.get(column.key)); | ||
newWidths.set(column.key, (_prevColumnWidths_get = prevColumnWidths.get(column.key)) !== null && _prevColumnWidths_get !== void 0 ? _prevColumnWidths_get : 0); | ||
else newWidths.set(column.key, (_column_props_width = column.props.width) !== null && _column_props_width !== void 0 ? _column_props_width : uncontrolledWidths.get(column.key)); | ||
@@ -80,0 +80,0 @@ }); |
@@ -65,3 +65,3 @@ import {calculateColumnSizes as $6818b1c4fc67028d$export$55d50dc687385491, getMaxWidth as $6818b1c4fc67028d$export$59185c62a7544aa0, getMinWidth as $6818b1c4fc67028d$export$f556054ce4358701} from "./TableUtils.module.js"; | ||
collection.columns.forEach((column)=>{ | ||
var _column_props_width; | ||
var _prevColumnWidths_get, _column_props_width; | ||
if (column.key === col) { | ||
@@ -71,3 +71,3 @@ newWidths.set(column.key, width); | ||
} else if (freeze) // freeze columns to the left to their previous pixel value | ||
newWidths.set(column.key, prevColumnWidths.get(column.key)); | ||
newWidths.set(column.key, (_prevColumnWidths_get = prevColumnWidths.get(column.key)) !== null && _prevColumnWidths_get !== void 0 ? _prevColumnWidths_get : 0); | ||
else newWidths.set(column.key, (_column_props_width = column.props.width) !== null && _column_props_width !== void 0 ? _column_props_width : uncontrolledWidths.get(column.key)); | ||
@@ -74,0 +74,0 @@ }); |
@@ -54,3 +54,3 @@ | ||
let flex = 0; | ||
let targetMainSize = null; | ||
let targetMainSize = 0; | ||
if ($9e5f6a0caf75716e$export$1994a077b98ee0d5(width)) { | ||
@@ -57,0 +57,0 @@ baseSize = $9e5f6a0caf75716e$export$7bbad27896f7ae9f(width, availableWidth); |
@@ -46,3 +46,3 @@ /* | ||
let flex = 0; | ||
let targetMainSize = null; | ||
let targetMainSize = 0; | ||
if ($6818b1c4fc67028d$export$1994a077b98ee0d5(width)) { | ||
@@ -49,0 +49,0 @@ baseSize = $6818b1c4fc67028d$export$7bbad27896f7ae9f(width, availableWidth); |
@@ -42,12 +42,12 @@ import { ColumnSize, TableCollection as _TableCollection1, TableBodyProps, TableHeaderProps, ColumnProps, RowProps, CellProps } from "@react-types/table"; | ||
_size: number; | ||
constructor(nodes: Iterable<GridNode<T>>, prev?: _TableCollection1<T>, opts?: GridCollectionOptions); | ||
constructor(nodes: Iterable<GridNode<T>>, prev?: _TableCollection1<T> | null, opts?: GridCollectionOptions); | ||
[Symbol.iterator](): Generator<Node<T>, void, undefined>; | ||
get size(): number; | ||
getKeys(): IterableIterator<Key>; | ||
getKeyBefore(key: Key): Key; | ||
getKeyAfter(key: Key): Key; | ||
getFirstKey(): Key; | ||
getLastKey(): Key; | ||
getItem(key: Key): GridNode<T>; | ||
at(idx: number): GridNode<T>; | ||
getKeyBefore(key: Key): Key | null; | ||
getKeyAfter(key: Key): Key | null; | ||
getFirstKey(): Key | null; | ||
getLastKey(): Key | null; | ||
getItem(key: Key): GridNode<T> | null; | ||
at(idx: number): GridNode<T> | null; | ||
getChildren(key: Key): Iterable<GridNode<T>>; | ||
@@ -62,3 +62,3 @@ getTextValue(key: Key): string; | ||
/** The current sorted column and direction. */ | ||
sortDescriptor: SortDescriptor; | ||
sortDescriptor: SortDescriptor | null; | ||
/** Calls the provided onSortChange handler with the provided column key and sort direction. */ | ||
@@ -65,0 +65,0 @@ sort(columnKey: Key, direction?: 'ascending' | 'descending'): void; |
@@ -52,2 +52,3 @@ var $7f5a58334d8866a5$exports = require("./TableCollection.main.js"); | ||
}); | ||
var _props_sortDescriptor; | ||
return { | ||
@@ -58,8 +59,8 @@ collection: collection, | ||
showSelectionCheckboxes: props.showSelectionCheckboxes || false, | ||
sortDescriptor: props.sortDescriptor, | ||
sortDescriptor: (_props_sortDescriptor = props.sortDescriptor) !== null && _props_sortDescriptor !== void 0 ? _props_sortDescriptor : null, | ||
isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled, | ||
setKeyboardNavigationDisabled: setKeyboardNavigationDisabled, | ||
sort (columnKey, direction) { | ||
var _props_sortDescriptor; | ||
props.onSortChange({ | ||
var _props_sortDescriptor, _props_onSortChange; | ||
(_props_onSortChange = props.onSortChange) === null || _props_onSortChange === void 0 ? void 0 : _props_onSortChange.call(props, { | ||
column: columnKey, | ||
@@ -66,0 +67,0 @@ 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' |
@@ -46,2 +46,3 @@ import {TableCollection as $788781baa30117fa$export$596e1b2e2cf93690} from "./TableCollection.module.js"; | ||
}); | ||
var _props_sortDescriptor; | ||
return { | ||
@@ -52,8 +53,8 @@ collection: collection, | ||
showSelectionCheckboxes: props.showSelectionCheckboxes || false, | ||
sortDescriptor: props.sortDescriptor, | ||
sortDescriptor: (_props_sortDescriptor = props.sortDescriptor) !== null && _props_sortDescriptor !== void 0 ? _props_sortDescriptor : null, | ||
isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled, | ||
setKeyboardNavigationDisabled: setKeyboardNavigationDisabled, | ||
sort (columnKey, direction) { | ||
var _props_sortDescriptor; | ||
props.onSortChange({ | ||
var _props_sortDescriptor, _props_onSortChange; | ||
(_props_onSortChange = props.onSortChange) === null || _props_onSortChange === void 0 ? void 0 : _props_onSortChange.call(props, { | ||
column: columnKey, | ||
@@ -60,0 +61,0 @@ 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' |
@@ -104,3 +104,3 @@ var $7f5a58334d8866a5$exports = require("./TableCollection.main.js"); | ||
let { expandedKeys: expandedKeys = new Set() } = opts; | ||
let body; | ||
let body = null; | ||
let flattenedRows = []; | ||
@@ -167,3 +167,3 @@ let columnCount = 0; | ||
keyMap.set(node.key, node); | ||
let lastNode; | ||
let lastNode = null; | ||
let rowIndex = 0; | ||
@@ -184,4 +184,4 @@ for (let child of node.childNodes)if (!(child.type === 'item' && expandedKeys !== 'all' && !expandedKeys.has(node.key))) { | ||
}; | ||
let last; | ||
topLevelRows.forEach((node, i)=>{ | ||
let last = null; | ||
for (let [i, node] of topLevelRows.entries()){ | ||
visitNode(node, i); | ||
@@ -193,3 +193,3 @@ if (last) { | ||
last = node; | ||
}); | ||
} | ||
if (last) last.nextKey = null; | ||
@@ -196,0 +196,0 @@ return { |
@@ -98,3 +98,3 @@ import {TableCollection as $788781baa30117fa$export$596e1b2e2cf93690} from "./TableCollection.module.js"; | ||
let { expandedKeys: expandedKeys = new Set() } = opts; | ||
let body; | ||
let body = null; | ||
let flattenedRows = []; | ||
@@ -161,3 +161,3 @@ let columnCount = 0; | ||
keyMap.set(node.key, node); | ||
let lastNode; | ||
let lastNode = null; | ||
let rowIndex = 0; | ||
@@ -178,4 +178,4 @@ for (let child of node.childNodes)if (!(child.type === 'item' && expandedKeys !== 'all' && !expandedKeys.has(node.key))) { | ||
}; | ||
let last; | ||
topLevelRows.forEach((node, i)=>{ | ||
let last = null; | ||
for (let [i, node] of topLevelRows.entries()){ | ||
visitNode(node, i); | ||
@@ -187,3 +187,3 @@ if (last) { | ||
last = node; | ||
}); | ||
} | ||
if (last) last.nextKey = null; | ||
@@ -190,0 +190,0 @@ return { |
{ | ||
"name": "@react-stately/table", | ||
"version": "3.0.0-nightly-d57bd8d90-240927", | ||
"version": "3.0.0-nightly-d87cc4422-250109", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,19 +25,18 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-stately/collections": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-stately/flags": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-stately/grid": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-stately/selection": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-stately/utils": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-types/grid": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-types/shared": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-types/table": "^3.0.0-nightly-d57bd8d90-240927", | ||
"@react-stately/collections": "3.0.0-nightly-d87cc4422-250109", | ||
"@react-stately/flags": "3.0.0-nightly-d87cc4422-250109", | ||
"@react-stately/grid": "3.0.0-nightly-d87cc4422-250109", | ||
"@react-stately/selection": "3.0.0-nightly-d87cc4422-250109", | ||
"@react-stately/utils": "3.0.0-nightly-d87cc4422-250109", | ||
"@react-types/grid": "3.0.0-nightly-d87cc4422-250109", | ||
"@react-types/shared": "3.0.0-nightly-d87cc4422-250109", | ||
"@react-types/table": "3.0.0-nightly-d87cc4422-250109", | ||
"@swc/helpers": "^0.5.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"stableVersion": "3.12.2" | ||
} | ||
} |
@@ -17,3 +17,3 @@ /* | ||
function Cell(props: CellProps): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
function Cell(props: CellProps): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
return null; | ||
@@ -20,0 +20,0 @@ } |
@@ -19,3 +19,3 @@ /* | ||
function Column<T>(props: ColumnProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
function Column<T>(props: ColumnProps<T>): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
return null; | ||
@@ -32,3 +32,3 @@ } | ||
type: 'column', | ||
hasChildNodes: !!childColumns || (title && React.Children.count(children) > 0), | ||
hasChildNodes: !!childColumns || (!!title && React.Children.count(children) > 0), | ||
rendered, | ||
@@ -35,0 +35,0 @@ textValue, |
@@ -18,3 +18,3 @@ /* | ||
function Row<T>(props: RowProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
function Row<T>(props: RowProps<T>): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
return null; | ||
@@ -21,0 +21,0 @@ } |
@@ -17,3 +17,3 @@ /* | ||
function TableBody<T>(props: TableBodyProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
function TableBody<T>(props: TableBodyProps<T>): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
return null; | ||
@@ -20,0 +20,0 @@ } |
@@ -43,3 +43,3 @@ /* | ||
while (parentKey) { | ||
let parent: GridNode<T> = keyMap.get(parentKey); | ||
let parent: GridNode<T> | undefined = keyMap.get(parentKey); | ||
if (!parent) { | ||
@@ -54,2 +54,3 @@ break; | ||
if (seen.has(parent)) { | ||
parent.colspan ??= 0; | ||
parent.colspan++; | ||
@@ -87,3 +88,3 @@ | ||
let maxLength = Math.max(...columns.map(c => c.length)); | ||
let headerRows = Array(maxLength).fill(0).map(() => []); | ||
let headerRows: GridNode<T>[][] = Array(maxLength).fill(0).map(() => []); | ||
@@ -98,3 +99,3 @@ // Convert columns into rows. | ||
let row = headerRows[i]; | ||
let rowLength = row.reduce((p, c) => p + c.colspan, 0); | ||
let rowLength = row.reduce((p, c) => p + (c.colspan ?? 1), 0); | ||
if (rowLength < colIndex) { | ||
@@ -111,3 +112,3 @@ let placeholder: GridNode<T> = { | ||
childNodes: [], | ||
textValue: null | ||
textValue: '' | ||
}; | ||
@@ -143,3 +144,3 @@ | ||
for (let row of headerRows) { | ||
let rowLength = row.reduce((p, c) => p + c.colspan, 0); | ||
let rowLength = row.reduce((p, c) => p + (c.colspan ?? 1), 0); | ||
if (rowLength < columnNodes.length) { | ||
@@ -156,3 +157,3 @@ let placeholder: GridNode<T> = { | ||
childNodes: [], | ||
textValue: null, | ||
textValue: '', | ||
prevKey: row[row.length - 1].key | ||
@@ -177,3 +178,3 @@ }; | ||
childNodes, | ||
textValue: null | ||
textValue: '' | ||
}; | ||
@@ -192,5 +193,5 @@ | ||
constructor(nodes: Iterable<GridNode<T>>, prev?: ITableCollection<T>, opts?: GridCollectionOptions) { | ||
constructor(nodes: Iterable<GridNode<T>>, prev?: ITableCollection<T> | null, opts?: GridCollectionOptions) { | ||
let rowHeaderColumnKeys: Set<Key> = new Set(); | ||
let body: GridNode<T>; | ||
let body: GridNode<T> | null = null; | ||
let columns: GridNode<T>[] = []; | ||
@@ -237,3 +238,3 @@ // Add cell for selection checkboxes if needed. | ||
let rows = []; | ||
let rows: GridNode<T>[] = []; | ||
let columnKeyMap = new Map(); | ||
@@ -281,9 +282,12 @@ let visit = (node: GridNode<T>) => { | ||
this.rowHeaderColumnKeys = rowHeaderColumnKeys; | ||
this.body = body; | ||
this.body = body!; | ||
this.headerRows = headerRows; | ||
this._size = [...body.childNodes].length; | ||
this._size = [...body!.childNodes].length; | ||
// Default row header column to the first one. | ||
if (this.rowHeaderColumnKeys.size === 0) { | ||
this.rowHeaderColumnKeys.add(this.columns.find(column => !column.props?.isDragButtonCell && !column.props?.isSelectionCell).key); | ||
let col = this.columns.find(column => !column.props?.isDragButtonCell && !column.props?.isSelectionCell); | ||
if (col) { | ||
this.rowHeaderColumnKeys.add(col.key); | ||
} | ||
} | ||
@@ -306,3 +310,3 @@ } | ||
let node = this.keyMap.get(key); | ||
return node ? node.prevKey : null; | ||
return node?.prevKey ?? null; | ||
} | ||
@@ -312,15 +316,15 @@ | ||
let node = this.keyMap.get(key); | ||
return node ? node.nextKey : null; | ||
return node?.nextKey ?? null; | ||
} | ||
getFirstKey() { | ||
return getFirstItem(this.body.childNodes)?.key; | ||
return getFirstItem(this.body.childNodes)?.key ?? null; | ||
} | ||
getLastKey() { | ||
return getLastItem(this.body.childNodes)?.key; | ||
return getLastItem(this.body.childNodes)?.key ?? null; | ||
} | ||
getItem(key: Key) { | ||
return this.keyMap.get(key); | ||
return this.keyMap.get(key) ?? null; | ||
} | ||
@@ -355,3 +359,3 @@ | ||
if (rowHeaderColumnKeys) { | ||
let text = []; | ||
let text: string[] = []; | ||
for (let cell of row.childNodes) { | ||
@@ -358,0 +362,0 @@ let column = this.columns[cell.index]; |
@@ -57,3 +57,3 @@ /* | ||
} else { | ||
return [col.key, controlledColumns.get(col.key).props.width]; | ||
return [col.key, controlledColumns.get(col.key)!.props.width]; | ||
} | ||
@@ -95,3 +95,3 @@ })); | ||
// freeze columns to the left to their previous pixel value | ||
newWidths.set(column.key, prevColumnWidths.get(column.key)); | ||
newWidths.set(column.key, prevColumnWidths.get(column.key) ?? 0); | ||
} else { | ||
@@ -98,0 +98,0 @@ newWidths.set(column.key, column.props.width ?? uncontrolledWidths.get(column.key)); |
@@ -18,3 +18,3 @@ /* | ||
function TableHeader<T>(props: TableHeaderProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
function TableHeader<T>(props: TableHeaderProps<T>): ReactElement | null { // eslint-disable-line @typescript-eslint/no-unused-vars | ||
return null; | ||
@@ -21,0 +21,0 @@ } |
@@ -47,3 +47,3 @@ /* | ||
export function getMaxWidth(maxWidth: number | string, tableWidth: number): number { | ||
export function getMaxWidth(maxWidth: number | string | null | undefined, tableWidth: number): number { | ||
return maxWidth != null | ||
@@ -67,5 +67,16 @@ ? parseStaticWidth(maxWidth, tableWidth) | ||
defaultWidth?: number | string, | ||
key?: Key | ||
key: Key | ||
} | ||
interface FlexItem { | ||
frozen: boolean, | ||
baseSize: number, | ||
hypotheticalMainSize: number, | ||
min: number, | ||
max: number, | ||
flex: number, | ||
targetMainSize: number, | ||
violation: number | ||
} | ||
/** | ||
@@ -98,3 +109,3 @@ * Implements the flex algorithm described in https://www.w3.org/TR/css-flexbox-1/#layout-algorithm | ||
let hasNonFrozenItems = false; | ||
let flexItems = columns.map((column, index) => { | ||
let flexItems: FlexItem[] = columns.map((column, index) => { | ||
let width = changedColumns.get(column.key) != null ? changedColumns.get(column.key) : column.width ?? column.defaultWidth ?? getDefaultWidth?.(index) ?? '1fr'; | ||
@@ -104,3 +115,3 @@ let frozen = false; | ||
let flex = 0; | ||
let targetMainSize = null; | ||
let targetMainSize = 0; | ||
if (isStatic(width)) { | ||
@@ -239,3 +250,3 @@ baseSize = parseStaticWidth(width, availableWidth); | ||
function cascadeRounding(flexItems): number[] { | ||
function cascadeRounding(flexItems: FlexItem[]): number[] { | ||
/* | ||
@@ -248,3 +259,3 @@ Given an array of floats that sum to an integer, this rounds the floats | ||
let intTotal = 0; | ||
let roundedArray = []; | ||
let roundedArray: number[] = []; | ||
flexItems.forEach(function (item) { | ||
@@ -251,0 +262,0 @@ let float = item.targetMainSize; |
@@ -111,3 +111,3 @@ /* | ||
let newSizes = columnLayout.resizeColumnWidth(state.collection, uncontrolledWidths, key, width); | ||
let map = new Map(Array.from(uncontrolledColumns).map(([key]) => [key, newSizes.get(key)])); | ||
let map = new Map(Array.from(uncontrolledColumns).map(([key]) => [key, newSizes.get(key)!])); | ||
map.set(key, width); | ||
@@ -114,0 +114,0 @@ setUncontrolledWidths(map); |
@@ -27,3 +27,3 @@ /* | ||
/** The current sorted column and direction. */ | ||
sortDescriptor: SortDescriptor, | ||
sortDescriptor: SortDescriptor | null, | ||
/** Calls the provided onSortChange handler with the provided column key and sort direction. */ | ||
@@ -98,7 +98,7 @@ sort(columnKey: Key, direction?: 'ascending' | 'descending'): void, | ||
showSelectionCheckboxes: props.showSelectionCheckboxes || false, | ||
sortDescriptor: props.sortDescriptor, | ||
sortDescriptor: props.sortDescriptor ?? null, | ||
isKeyboardNavigationDisabled: collection.size === 0 || isKeyboardNavigationDisabled, | ||
setKeyboardNavigationDisabled, | ||
sort(columnKey: Key, direction?: 'ascending' | 'descending') { | ||
props.onSortChange({ | ||
props.onSortChange?.({ | ||
column: columnKey, | ||
@@ -105,0 +105,0 @@ direction: direction ?? (props.sortDescriptor?.column === columnKey |
@@ -143,7 +143,7 @@ /* | ||
let body: GridNode<T>; | ||
let flattenedRows = []; | ||
let body: GridNode<T> | null = null; | ||
let flattenedRows: GridNode<T>[] = []; | ||
let columnCount = 0; | ||
let userColumnCount = 0; | ||
let originalColumns = []; | ||
let originalColumns: GridNode<T>[] = []; | ||
let keyMap = new Map(); | ||
@@ -159,3 +159,3 @@ | ||
let topLevelRows = []; | ||
let topLevelRows: GridNode<T>[] = []; | ||
let visit = (node: GridNode<T>) => { | ||
@@ -188,2 +188,3 @@ switch (node.type) { | ||
} | ||
columnCount += userColumnCount; | ||
@@ -198,3 +199,3 @@ | ||
if (node.type === 'item') { | ||
let childNodes = []; | ||
let childNodes: GridNode<T>[] = []; | ||
for (let child of node.childNodes) { | ||
@@ -209,3 +210,3 @@ if (child.type === 'cell') { | ||
} | ||
let clone = {...node, childNodes: childNodes, parentKey: body.key, level: 1, index: globalRowCount++}; | ||
let clone: GridNode<T> = {...node, childNodes: childNodes, parentKey: body!.key, level: 1, index: globalRowCount++}; | ||
flattenedRows.push(clone); | ||
@@ -226,3 +227,3 @@ } | ||
let lastNode: GridNode<T>; | ||
let lastNode: GridNode<T> | null = null; | ||
let rowIndex = 0; | ||
@@ -259,4 +260,4 @@ for (let child of node.childNodes) { | ||
let last: GridNode<T>; | ||
topLevelRows.forEach((node: GridNode<T>, i) => { | ||
let last: GridNode<T> | null = null; | ||
for (let [i, node] of topLevelRows.entries()) { | ||
visitNode(node as GridNode<T>, i); | ||
@@ -272,3 +273,3 @@ | ||
last = node; | ||
}); | ||
} | ||
@@ -283,4 +284,4 @@ if (last) { | ||
flattenedRows, | ||
tableNodes: [...originalColumns, {...body, childNodes: flattenedRows}] | ||
tableNodes: [...originalColumns, {...body!, childNodes: flattenedRows}] | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
431499
5431
+ Added@react-stately/collections@3.0.0-nightly-d87cc4422-250109(transitive)
+ Added@react-stately/flags@3.0.0-nightly-d87cc4422-250109(transitive)
+ Added@react-stately/grid@3.0.0-nightly-d87cc4422-250109(transitive)
+ Added@react-stately/selection@3.0.0-nightly-d87cc4422-250109(transitive)
+ Added@react-stately/utils@3.0.0-nightly-d87cc4422-250109(transitive)
+ Added@react-types/grid@3.0.0-nightly-d87cc4422-250109(transitive)
+ Added@react-types/shared@3.0.0-nightly-d87cc4422-250109(transitive)
+ Added@react-types/table@3.0.0-nightly-d87cc4422-250109(transitive)
- Removed@react-stately/collections@3.12.0(transitive)
- Removed@react-stately/flags@3.0.5(transitive)
- Removed@react-stately/grid@3.10.0(transitive)
- Removed@react-stately/selection@3.18.0(transitive)
- Removed@react-stately/utils@3.10.5(transitive)
- Removed@react-types/grid@3.2.10(transitive)
- Removed@react-types/shared@3.26.0(transitive)
- Removed@react-types/table@3.10.3(transitive)
Updated@react-stately/collections@3.0.0-nightly-d87cc4422-250109
Updated@react-stately/selection@3.0.0-nightly-d87cc4422-250109