MCPcopy Create free account
hub / github.com/adobe/react-spectrum / parseStaticWidth

Function parseStaticWidth

packages/react-stately/src/table/TableUtils.ts:39–48  ·  view source on GitHub ↗
(width: number | string, tableWidth: number)

Source from the content-addressed store, hash-verified

37}
38
39export function parseStaticWidth(width: number | string, tableWidth: number): number {
40 if (typeof width === 'string') {
41 let match = width.match(/^(\d+)(?=%$)/);
42 if (!match) {
43 throw new Error('Only percentages or numbers are supported for static column widths');
44 }
45 return tableWidth * (parseFloat(match[0]) / 100);
46 }
47 return width;
48}
49
50export function getMaxWidth(
51 maxWidth: number | string | null | undefined,

Callers 3

getMaxWidthFunction · 0.85
getMinWidthFunction · 0.85
calculateColumnSizesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected