Skip to content

Commit e6bb382

Browse files
committed
Add ResizedWidth type
1 parent d3b412d commit e6bb382

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/HeaderRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { css } from '@linaria/core';
33
import clsx from 'clsx';
44

55
import { getColSpan } from './utils';
6-
import type { CalculatedColumn, Direction, Position } from './types';
6+
import type { CalculatedColumn, Direction, Position, ResizedWidth } from './types';
77
import type { DataGridProps } from './DataGrid';
88
import HeaderCell from './HeaderCell';
99
import { cell, cellFrozen } from './style/cell';
@@ -17,7 +17,7 @@ type SharedDataGridProps<R, SR, K extends React.Key> = Pick<
1717
export interface HeaderRowProps<R, SR, K extends React.Key> extends SharedDataGridProps<R, SR, K> {
1818
rowIdx: number;
1919
columns: readonly CalculatedColumn<R, SR>[];
20-
onColumnResize: (column: CalculatedColumn<R, SR>, width: number | 'max-content') => void;
20+
onColumnResize: (column: CalculatedColumn<R, SR>, width: ResizedWidth) => void;
2121
selectCell: (position: Position) => void;
2222
lastFrozenColumnIndex: number;
2323
selectedCellIdx: number | undefined;

src/hooks/useColumnWidths.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useLayoutEffect, useState } from 'react';
22

33
import { getColumnWidthForMeasurement } from '../utils';
4-
import type { CalculatedColumn, StateSetter } from '../types';
4+
import type { CalculatedColumn, ResizedWidth, StateSetter } from '../types';
55
import type { DataGridProps } from '../DataGrid';
66

77
export function useColumnWidths<R, SR>(
@@ -18,7 +18,7 @@ export function useColumnWidths<R, SR>(
1818
) {
1919
const [columnToAutoResize, setColumnToAutoResize] = useState<{
2020
readonly key: string;
21-
readonly width: number | 'max-content';
21+
readonly width: ResizedWidth;
2222
} | null>(null);
2323
const [prevGridWidth, setPreviousGridWidth] = useState(gridWidth);
2424
const columnsCanFlex: boolean = columns.length === viewportColumns.length;
@@ -87,7 +87,7 @@ export function useColumnWidths<R, SR>(
8787
}
8888
}
8989

90-
function handleColumnResize(column: CalculatedColumn<R, SR>, nextWidth: number | 'max-content') {
90+
function handleColumnResize(column: CalculatedColumn<R, SR>, nextWidth: ResizedWidth) {
9191
const { key: resizingKey } = column;
9292
const columnsToMeasure: string[] = [];
9393

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,5 @@ export interface Renderers<TRow, TSummaryRow> {
322322
}
323323

324324
export type Direction = 'ltr' | 'rtl';
325+
326+
export type ResizedWidth = number | 'max-content';

0 commit comments

Comments
 (0)