@ishibashi0112/spreadsheet-grid 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +565 -467
- package/dist/CellEditorLayer.d.ts +15 -4
- package/dist/SpreadsheetGrid.d.ts +1 -1
- package/dist/editors/CellEditorErrorBubble.d.ts +4 -0
- package/dist/editors/CheckboxCell.d.ts +7 -0
- package/dist/editors/CustomCellEditor.d.ts +8 -0
- package/dist/editors/DateCellEditor.d.ts +9 -0
- package/dist/editors/NumberCellEditor.d.ts +12 -0
- package/dist/editors/SelectCellEditor.d.ts +11 -0
- package/dist/editors/TextCellEditor.d.ts +9 -0
- package/dist/editors/editorKeyBindings.d.ts +10 -0
- package/dist/hooks/useGridEditController.d.ts +2 -3
- package/dist/hooks/useGridHistoryController.d.ts +23 -0
- package/dist/hooks/useGridKeyboardInteractions.d.ts +5 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2285 -1590
- package/dist/logic/checkboxEditor.d.ts +12 -0
- package/dist/logic/clearCells.d.ts +22 -0
- package/dist/logic/editorValues.d.ts +5 -0
- package/dist/logic/history.d.ts +16 -0
- package/dist/logic/selectEditorState.d.ts +28 -0
- package/dist/logic/setFilterSelection.d.ts +5 -0
- package/dist/logic/validation.d.ts +14 -0
- package/dist/model/gridTypes.d.ts +72 -0
- package/dist/style.css +1 -1
- package/dist/view/ColumnFilterPopover.d.ts +1 -5
- package/package.json +13 -5
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import type { EditorCommitDirection, EditorCommitResult, GridColumn, GridColumnEditor } from './model/gridTypes';
|
|
2
|
+
export type { EditorCommitDirection };
|
|
2
3
|
type CellEditorRect = {
|
|
3
4
|
left: number;
|
|
4
5
|
top: number;
|
|
5
6
|
width: number;
|
|
6
7
|
height: number;
|
|
7
8
|
};
|
|
8
|
-
type
|
|
9
|
+
export type CellEditorSession<T> = {
|
|
10
|
+
row: T;
|
|
11
|
+
rowIndex: number;
|
|
12
|
+
colIndex: number;
|
|
13
|
+
column: GridColumn<T>;
|
|
14
|
+
value: unknown;
|
|
15
|
+
};
|
|
16
|
+
type CellEditorLayerProps<T> = {
|
|
9
17
|
rect: CellEditorRect | null;
|
|
10
18
|
headerHeight: number;
|
|
11
19
|
leadingWidth: number;
|
|
12
20
|
baseOffset?: number;
|
|
13
21
|
initialValue: string;
|
|
14
|
-
|
|
22
|
+
editor?: GridColumnEditor<T>;
|
|
23
|
+
editorSession?: CellEditorSession<T> | null;
|
|
24
|
+
themeClassName?: string;
|
|
25
|
+
onCommit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult | void;
|
|
15
26
|
onCancel: () => void;
|
|
16
27
|
align?: 'left' | 'center' | 'right';
|
|
17
28
|
};
|
|
18
|
-
export declare function CellEditorLayer({ rect, headerHeight, leadingWidth, baseOffset, initialValue, onCommit, onCancel, align, }: CellEditorLayerProps): import("react").JSX.Element | null;
|
|
29
|
+
export declare function CellEditorLayer<T>({ rect, headerHeight, leadingWidth, baseOffset, initialValue, editor, editorSession, themeClassName, onCommit, onCancel, align, }: CellEditorLayerProps<T>): import("react").JSX.Element | null;
|
|
19
30
|
export default CellEditorLayer;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './styles.css';
|
|
2
2
|
import type { SpreadsheetGridProps } from './model/gridTypes';
|
|
3
|
-
export declare function SpreadsheetGrid<T extends object>({ rows, dataSource, serverSideRefreshToken, columns, onRowsChange, onColumnsChange, rowKeyGetter, createRow, createOverflowColumn, rowHeight: rowHeightProp, autoHeight, estimateRowHeight, headerHeight: headerHeightProp, density, theme, rowHeaderWidth, height, maxHeight, readOnly, dimReadOnlyCells, canEditCell, enableRangeSelection, enableRowSelection, rowSelectionMode, enableSelectAllRows: enableSelectAllRowsProp, rowSelection: rowSelectionProp, selectedRowKeys: selectedRowKeysProp, onRowSelectionChange, enableGlobalFilter, enableColumnFilter, enableSorting, enableColumnResize, autoSizeColumns, showCellOverflowTooltip, enableRowHover, enableColumnHeaderHover, enableColumnMenu, noMatchingRowsText, noRowsText, showTopBar, showBottomBar, showTopBarSummary, showTopBarFilter, globalFilterPlaceholder, globalFilterIcon, showTopBarCounts, showBottomBarCounts, showFilterChipBar, renderTopBar, renderBottomBar, className, classNames, getRowClassName, enableContextMenu, getContextMenuItems, onContextMenuOpen, ref, onStateChange, }: SpreadsheetGridProps<T>): import("react").JSX.Element;
|
|
3
|
+
export declare function SpreadsheetGrid<T extends object>({ rows, dataSource, serverSideRefreshToken, columns, onRowsChange, onColumnsChange, rowKeyGetter, createRow, createOverflowColumn, rowHeight: rowHeightProp, autoHeight, estimateRowHeight, headerHeight: headerHeightProp, density, theme, rowHeaderWidth, height, maxHeight, readOnly, dimReadOnlyCells, canEditCell, enableUndoRedo, undoHistoryLimit, onUndoRedoStateChange, enableRangeSelection, enableRowSelection, rowSelectionMode, enableSelectAllRows: enableSelectAllRowsProp, rowSelection: rowSelectionProp, selectedRowKeys: selectedRowKeysProp, onRowSelectionChange, enableGlobalFilter, enableColumnFilter, enableSorting, enableColumnResize, autoSizeColumns, showCellOverflowTooltip, enableRowHover, enableColumnHeaderHover, enableColumnMenu, noMatchingRowsText, noRowsText, showTopBar, showBottomBar, showTopBarSummary, showTopBarFilter, globalFilterPlaceholder, globalFilterIcon, showTopBarCounts, showBottomBarCounts, showFilterChipBar, renderTopBar, renderBottomBar, className, classNames, getRowClassName, enableContextMenu, getContextMenuItems, onContextMenuOpen, ref, onStateChange, }: SpreadsheetGridProps<T>): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { CellEditorContext } from '../model/gridTypes';
|
|
3
|
+
type CustomCellEditorProps<T> = {
|
|
4
|
+
render: (ctx: CellEditorContext<T>) => ReactNode;
|
|
5
|
+
context: CellEditorContext<T>;
|
|
6
|
+
};
|
|
7
|
+
export declare function CustomCellEditor<T>({ render, context, }: CustomCellEditorProps<T>): import("react").JSX.Element;
|
|
8
|
+
export default CustomCellEditor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EditorCommitDirection, EditorCommitResult } from '../model/gridTypes';
|
|
2
|
+
type DateCellEditorProps = {
|
|
3
|
+
initialValue: string;
|
|
4
|
+
onCommit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult | void;
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
align?: 'left' | 'center' | 'right';
|
|
7
|
+
};
|
|
8
|
+
export declare function DateCellEditor({ initialValue, onCommit, onCancel, align, }: DateCellEditorProps): import("react").JSX.Element;
|
|
9
|
+
export default DateCellEditor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditorCommitDirection, EditorCommitResult } from '../model/gridTypes';
|
|
2
|
+
type NumberCellEditorProps = {
|
|
3
|
+
initialValue: string;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
step?: number;
|
|
7
|
+
onCommit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult | void;
|
|
8
|
+
onCancel: () => void;
|
|
9
|
+
align?: 'left' | 'center' | 'right';
|
|
10
|
+
};
|
|
11
|
+
export declare function NumberCellEditor({ initialValue, min, max, step, onCommit, onCancel, align, }: NumberCellEditorProps): import("react").JSX.Element;
|
|
12
|
+
export default NumberCellEditor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EditorCommitDirection, EditorCommitResult, GridSelectEditorOption } from '../model/gridTypes';
|
|
2
|
+
type SelectCellEditorProps = {
|
|
3
|
+
options: GridSelectEditorOption[];
|
|
4
|
+
value: unknown;
|
|
5
|
+
onCommit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult | void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
align?: 'left' | 'center' | 'right';
|
|
8
|
+
themeClassName?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function SelectCellEditor({ options, value, onCommit, onCancel, align, themeClassName, }: SelectCellEditorProps): import("react").JSX.Element;
|
|
11
|
+
export default SelectCellEditor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EditorCommitDirection, EditorCommitResult } from '../model/gridTypes';
|
|
2
|
+
type TextCellEditorProps = {
|
|
3
|
+
initialValue: string;
|
|
4
|
+
onCommit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult | void;
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
align?: 'left' | 'center' | 'right';
|
|
7
|
+
};
|
|
8
|
+
export declare function TextCellEditor({ initialValue, onCommit, onCancel, align, }: TextCellEditorProps): import("react").JSX.Element;
|
|
9
|
+
export default TextCellEditor;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { KeyboardEvent } from 'react';
|
|
2
|
+
import type { EditorCommitDirection, EditorCommitResult } from '../model/gridTypes';
|
|
3
|
+
type CreateEditorKeyDownHandlerArgs = {
|
|
4
|
+
value: unknown;
|
|
5
|
+
onCommit: (value: unknown, direction?: EditorCommitDirection) => EditorCommitResult | void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
onRejected?: (message: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const createEditorKeyDownHandler: ({ value, onCommit, onCancel, onRejected }: CreateEditorKeyDownHandlerArgs) => (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
10
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Dispatch, type RefObject } from 'react';
|
|
2
2
|
import { type GridUiAction } from '../model/gridActions';
|
|
3
|
-
import type { CellCoord, GridColumn, GridUiState, RowModel } from '../model/gridTypes';
|
|
4
|
-
import type { EditorCommitDirection } from '../CellEditorLayer';
|
|
3
|
+
import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridUiState, RowModel } from '../model/gridTypes';
|
|
5
4
|
type UseGridEditControllerArgs<T extends object> = {
|
|
6
5
|
uiState: GridUiState;
|
|
7
6
|
rows: T[];
|
|
@@ -17,7 +16,7 @@ type UseGridEditControllerArgs<T extends object> = {
|
|
|
17
16
|
export declare const useGridEditController: <T extends object>({ uiState, rows, visibleColumns, rowModel, setEditorInitialValue, onRowsChange, dispatch, getMovedCell, gridRootRef, editorActionGuardRef, }: UseGridEditControllerArgs<T>) => {
|
|
18
17
|
activateSingleCell: (cell: CellCoord) => void;
|
|
19
18
|
startEditWithValue: (cell: CellCoord, initialValue: string) => void;
|
|
20
|
-
commitEdit: (committedValue:
|
|
19
|
+
commitEdit: (committedValue: unknown, direction?: EditorCommitDirection) => EditorCommitResult;
|
|
21
20
|
cancelEdit: () => void;
|
|
22
21
|
};
|
|
23
22
|
export default useGridEditController;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Dispatch } from 'react';
|
|
2
|
+
import { type GridUiAction } from '../model/gridActions';
|
|
3
|
+
import type { CellCoord, GridSelection, UndoRedoState } from '../model/gridTypes';
|
|
4
|
+
type UseGridHistoryControllerArgs<T> = {
|
|
5
|
+
rows: T[];
|
|
6
|
+
selection: GridSelection;
|
|
7
|
+
activeCell: CellCoord | null;
|
|
8
|
+
onRowsChange?: (nextRows: T[]) => void;
|
|
9
|
+
dispatch: Dispatch<GridUiAction>;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
limit: number;
|
|
12
|
+
onUndoRedoStateChange?: (state: UndoRedoState) => void;
|
|
13
|
+
onAfterRestore?: (activeCell: CellCoord | null) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const useGridHistoryController: <T>({ rows, selection, activeCell, onRowsChange, dispatch, enabled, limit, onUndoRedoStateChange, onAfterRestore, }: UseGridHistoryControllerArgs<T>) => {
|
|
16
|
+
handleRowsChange: ((nextRows: T[]) => void) | undefined;
|
|
17
|
+
undo: () => void;
|
|
18
|
+
redo: () => void;
|
|
19
|
+
canUndo: () => boolean;
|
|
20
|
+
canRedo: () => boolean;
|
|
21
|
+
clearHistory: () => void;
|
|
22
|
+
};
|
|
23
|
+
export default useGridHistoryController;
|
|
@@ -13,8 +13,12 @@ type UseGridKeyboardInteractionsArgs<T> = {
|
|
|
13
13
|
handleCellDoubleClick: (cell: CellCoord) => void;
|
|
14
14
|
isWholeGridSelected: boolean;
|
|
15
15
|
selectEntireGrid: () => void;
|
|
16
|
+
onUndo: () => void;
|
|
17
|
+
onRedo: () => void;
|
|
18
|
+
onClearSelection: () => void;
|
|
19
|
+
onToggleCheckboxCell: (cell: CellCoord) => void;
|
|
16
20
|
};
|
|
17
|
-
export declare const useGridKeyboardInteractions: <T>({ uiState, rowModel, visibleColumns, readOnly, canEditCell, setEditorInitialValue, dispatch, handleCopy, handleCellDoubleClick, isWholeGridSelected, selectEntireGrid, }: UseGridKeyboardInteractionsArgs<T>) => {
|
|
21
|
+
export declare const useGridKeyboardInteractions: <T>({ uiState, rowModel, visibleColumns, readOnly, canEditCell, setEditorInitialValue, dispatch, handleCopy, handleCellDoubleClick, isWholeGridSelected, selectEntireGrid, onUndo, onRedo, onClearSelection, onToggleCheckboxCell, }: UseGridKeyboardInteractionsArgs<T>) => {
|
|
18
22
|
getMovedCell: (baseCell: CellCoord, deltaRow: number, deltaCol: number) => CellCoord;
|
|
19
23
|
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => Promise<void>;
|
|
20
24
|
};
|