Skip to content

Commit

Permalink
refactor: break out types
Browse files Browse the repository at this point in the history
  • Loading branch information
makafsal committed May 16, 2024
1 parent d4c4395 commit 0198282
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ import { removeCellSelections } from './utils/removeCellSelections';
import { selectAllCells } from './utils/selectAllCells';
import { handleEditSubmit } from './utils/handleEditSubmit';
import { handleKeyPress } from './utils/commonEventHandlers';
import {
ActiveCellCoordinates,
Column,
PrevStateType,
Size,
Theme,
} from './types';
import { ActiveCellCoordinates, Column, PrevState, Size, Theme } from './types';

// The block part of our conventional BEM class names (blockClass__E--M).
const blockClass = `${pkg.prefix}--data-spreadsheet`;
Expand Down Expand Up @@ -185,7 +179,7 @@ export let DataSpreadsheet = React.forwardRef(
useState<boolean>(false);
const [activeCellInsideSelectionArea, setActiveCellInsideSelectionArea] =
useState(false);
const previousState: PrevStateType =
const previousState: PrevState =
usePreviousValue({
activeCellCoordinates,
isEditing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ import { getSpreadsheetWidth } from './utils/getSpreadsheetWidth';
import { useSpreadsheetMouseMove } from './hooks';
import { checkForHoldingKey } from './utils/checkForHoldingKey';
import { prepareProps } from '../../global/js/utils/props-helper';
import { ActiveCellCoordinates, Column, ItemType, Size } from './types';
import {
ActiveCellCoordinates,
Column,
ItemType,
PrevState,
Size,
} from './types';

const blockClass = `${pkg.prefix}--data-spreadsheet`;

Expand Down Expand Up @@ -131,10 +137,6 @@ interface DataSpreadsheetHeaderProps {
visibleColumns?: [];
}

type PrevState = {
cellSize?: Size;
};

export const DataSpreadsheetHeader = forwardRef(
(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type Size = 'xs' | 'sm' | 'md' | 'lg';
export type Theme = 'light' | 'dark';
export interface Column {
Header?: string;
accessor?: string | (() => void);
Expand All @@ -18,6 +20,7 @@ export interface PrevState {
selectionAreaData?: object[];
clickAndHoldActive?: boolean;
rowHeight?: number;
cellSize?: Size;
}

export interface Point {
Expand All @@ -29,6 +32,3 @@ export interface ItemType {
point1?: Point;
point2?: Point;
}

export type Size = 'xs' | 'sm' | 'md' | 'lg';
export type Theme = 'light' | 'dark';

0 comments on commit 0198282

Please sign in to comment.