@react-stately/table
Advanced tools
Comparing version
@@ -23,3 +23,3 @@ | ||
function $9e5f6a0caf75716e$export$9078bad4c3934604(width) { | ||
if (!width) return 1; | ||
if (!width || typeof width === 'number') return 1; | ||
let match = width.match(/^(.+)(?=fr$)/); | ||
@@ -50,4 +50,4 @@ // if width is the incorrect format, just default it to a 1fr | ||
let flexItems = columns.map((column, index)=>{ | ||
var _column_width, _ref, _ref1; | ||
let width = changedColumns.get(column.key) != null ? changedColumns.get(column.key) : (_ref1 = (_ref = (_column_width = column.width) !== null && _column_width !== void 0 ? _column_width : column.defaultWidth) !== null && _ref !== void 0 ? _ref : getDefaultWidth === null || getDefaultWidth === void 0 ? void 0 : getDefaultWidth(index)) !== null && _ref1 !== void 0 ? _ref1 : '1fr'; | ||
var _changedColumns_get, _column_width, _ref, _ref1; | ||
let width = changedColumns.get(column.key) != null ? (_changedColumns_get = changedColumns.get(column.key)) !== null && _changedColumns_get !== void 0 ? _changedColumns_get : '1fr' : (_ref1 = (_ref = (_column_width = column.width) !== null && _column_width !== void 0 ? _column_width : column.defaultWidth) !== null && _ref !== void 0 ? _ref : getDefaultWidth === null || getDefaultWidth === void 0 ? void 0 : getDefaultWidth(index)) !== null && _ref1 !== void 0 ? _ref1 : '1fr'; | ||
let frozen = false; | ||
@@ -54,0 +54,0 @@ let baseSize = 0; |
@@ -15,3 +15,3 @@ /* | ||
function $6818b1c4fc67028d$export$9078bad4c3934604(width) { | ||
if (!width) return 1; | ||
if (!width || typeof width === 'number') return 1; | ||
let match = width.match(/^(.+)(?=fr$)/); | ||
@@ -42,4 +42,4 @@ // if width is the incorrect format, just default it to a 1fr | ||
let flexItems = columns.map((column, index)=>{ | ||
var _column_width, _ref, _ref1; | ||
let width = changedColumns.get(column.key) != null ? changedColumns.get(column.key) : (_ref1 = (_ref = (_column_width = column.width) !== null && _column_width !== void 0 ? _column_width : column.defaultWidth) !== null && _ref !== void 0 ? _ref : getDefaultWidth === null || getDefaultWidth === void 0 ? void 0 : getDefaultWidth(index)) !== null && _ref1 !== void 0 ? _ref1 : '1fr'; | ||
var _changedColumns_get, _column_width, _ref, _ref1; | ||
let width = changedColumns.get(column.key) != null ? (_changedColumns_get = changedColumns.get(column.key)) !== null && _changedColumns_get !== void 0 ? _changedColumns_get : '1fr' : (_ref1 = (_ref = (_column_width = column.width) !== null && _column_width !== void 0 ? _column_width : column.defaultWidth) !== null && _ref !== void 0 ? _ref : getDefaultWidth === null || getDefaultWidth === void 0 ? void 0 : getDefaultWidth(index)) !== null && _ref1 !== void 0 ? _ref1 : '1fr'; | ||
let frozen = false; | ||
@@ -46,0 +46,0 @@ let baseSize = 0; |
@@ -43,3 +43,3 @@ import { ColumnSize, TableCollection as _TableCollection1, TableBodyProps, TableHeaderProps, ColumnProps, RowProps, CellProps } from "@react-types/table"; | ||
constructor(nodes: Iterable<GridNode<T>>, prev?: _TableCollection1<T> | null, opts?: GridCollectionOptions); | ||
[Symbol.iterator](): Generator<Node<T>, void, undefined>; | ||
[Symbol.iterator](): IterableIterator<GridNode<T>>; | ||
get size(): number; | ||
@@ -46,0 +46,0 @@ getKeys(): IterableIterator<Key>; |
{ | ||
"name": "@react-stately/table", | ||
"version": "3.0.0-nightly-9bd8a5f19-250304", | ||
"version": "3.0.0-nightly-9d471e48d-250314", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,10 +25,10 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-stately/collections": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-stately/flags": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-stately/grid": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-stately/selection": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-stately/utils": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-types/grid": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-types/shared": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-types/table": "3.0.0-nightly-9bd8a5f19-250304", | ||
"@react-stately/collections": "3.0.0-nightly-9d471e48d-250314", | ||
"@react-stately/flags": "3.0.0-nightly-9d471e48d-250314", | ||
"@react-stately/grid": "3.0.0-nightly-9d471e48d-250314", | ||
"@react-stately/selection": "3.0.0-nightly-9d471e48d-250314", | ||
"@react-stately/utils": "3.0.0-nightly-9d471e48d-250314", | ||
"@react-types/grid": "3.0.0-nightly-9d471e48d-250314", | ||
"@react-types/shared": "3.0.0-nightly-9d471e48d-250314", | ||
"@react-types/table": "3.0.0-nightly-9d471e48d-250314", | ||
"@swc/helpers": "^0.5.0" | ||
@@ -35,0 +35,0 @@ }, |
@@ -289,15 +289,15 @@ /* | ||
*[Symbol.iterator]() { | ||
*[Symbol.iterator](): IterableIterator<GridNode<T>> { | ||
yield* this.body.childNodes; | ||
} | ||
get size() { | ||
get size(): number { | ||
return this._size; | ||
} | ||
getKeys() { | ||
getKeys(): IterableIterator<Key> { | ||
return this.keyMap.keys(); | ||
} | ||
getKeyBefore(key: Key) { | ||
getKeyBefore(key: Key): Key | null { | ||
let node = this.keyMap.get(key); | ||
@@ -307,3 +307,3 @@ return node?.prevKey ?? null; | ||
getKeyAfter(key: Key) { | ||
getKeyAfter(key: Key): Key | null { | ||
let node = this.keyMap.get(key); | ||
@@ -313,15 +313,15 @@ return node?.nextKey ?? null; | ||
getFirstKey() { | ||
getFirstKey(): Key | null { | ||
return getFirstItem(this.body.childNodes)?.key ?? null; | ||
} | ||
getLastKey() { | ||
getLastKey(): Key | null { | ||
return getLastItem(this.body.childNodes)?.key ?? null; | ||
} | ||
getItem(key: Key) { | ||
getItem(key: Key): GridNode<T> | null { | ||
return this.keyMap.get(key) ?? null; | ||
} | ||
at(idx: number) { | ||
at(idx: number): GridNode<T> | null { | ||
const keys = [...this.getKeys()]; | ||
@@ -328,0 +328,0 @@ return this.getItem(keys[idx]); |
@@ -103,3 +103,3 @@ /* | ||
buildColumnWidths(tableWidth: number, collection: TableCollection<T>, widths: Map<Key, ColumnSize>) { | ||
buildColumnWidths(tableWidth: number, collection: TableCollection<T>, widths: Map<Key, ColumnSize>): Map<Key, number> { | ||
this.columnWidths = new Map(); | ||
@@ -106,0 +106,0 @@ this.columnMinWidths = new Map(); |
@@ -17,8 +17,8 @@ /* | ||
// numbers and percents are considered static. *fr units or a lack of units are considered dynamic. | ||
export function isStatic(width: number | string): boolean { | ||
export function isStatic(width?: ColumnSize | null): boolean { | ||
return width != null && (!isNaN(width as number) || (String(width)).match(/^(\d+)(?=%$)/) !== null); | ||
} | ||
export function parseFractionalUnit(width: string): number { | ||
if (!width) { | ||
export function parseFractionalUnit(width?: ColumnSize | null): number { | ||
if (!width || typeof width === 'number') { | ||
return 1; | ||
@@ -106,6 +106,6 @@ } | ||
*/ | ||
export function calculateColumnSizes(availableWidth: number, columns: IColumn[], changedColumns: Map<Key, ColumnSize>, getDefaultWidth, getDefaultMinWidth) { | ||
export function calculateColumnSizes(availableWidth: number, columns: IColumn[], changedColumns: Map<Key, ColumnSize>, getDefaultWidth?: (number) => ColumnSize | null | undefined, getDefaultMinWidth?: (number) => ColumnSize | null | undefined): number[] { | ||
let hasNonFrozenItems = false; | ||
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'; | ||
let width: ColumnSize = (changedColumns.get(column.key) != null ? changedColumns.get(column.key) ?? '1fr' : column.width ?? column.defaultWidth ?? getDefaultWidth?.(index) ?? '1fr') as ColumnSize; | ||
let frozen = false; | ||
@@ -112,0 +112,0 @@ let baseSize = 0; |
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
435932
0.43%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated