(width?: ColumnSize | null)
| 19 | } |
| 20 | |
| 21 | export function parseFractionalUnit(width?: ColumnSize | null): number { |
| 22 | if (!width || typeof width === 'number') { |
| 23 | return 1; |
| 24 | } |
| 25 | let match = width.match(/^(.+)(?=fr$)/); |
| 26 | // if width is the incorrect format, just default it to a 1fr |
| 27 | if (!match) { |
| 28 | if (process.env.NODE_ENV !== 'production') { |
| 29 | console.warn( |
| 30 | `width: ${width} is not a supported format, width should be a number (ex. 150), percentage (ex. '50%') or fr unit (ex. '2fr')`, |
| 31 | "defaulting to '1fr'" |
| 32 | ); |
| 33 | } |
| 34 | return 1; |
| 35 | } |
| 36 | return parseFloat(match[0]); |
| 37 | } |
| 38 | |
| 39 | export function parseStaticWidth(width: number | string, tableWidth: number): number { |
| 40 | if (typeof width === 'string') { |
no outgoing calls
no test coverage detected