sheet-happens 0.0.43 → 0.0.44

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.
@@ -0,0 +1,8 @@
1
+ import { RefObject, KeyboardEvent } from 'react';
2
+ import { CellContentType, CellPropertyFunction, CellPropertyStyledFunction, Change, Rectangle, XY } from './types';
3
+ export declare const useKeyboard: (arrowKeyCommitMode: boolean, overlayRef: RefObject<HTMLDivElement>, cellReadOnly: CellPropertyFunction<boolean | null>, displayData: CellPropertyStyledFunction<CellContentType>, editCell: XY, editMode: boolean, focused: boolean, rawSelection: Rectangle, selection: Rectangle, onEdit?: ((cell: XY, arrowKeyCommitMode?: boolean | undefined) => void) | undefined, onCommit?: (() => void) | undefined, onCancel?: (() => void) | undefined, onSelectionChange?: ((selection: Rectangle, scrollTo?: boolean | undefined, toHead?: boolean | undefined) => void) | undefined, onFocusChange?: ((focus: boolean) => void) | undefined, onClipboardCopy?: ((cut: boolean) => void) | undefined, onChange?: ((changes: Change[]) => void) | undefined) => {
4
+ onInputKeyDown: (e: KeyboardEvent) => void;
5
+ onGridFocus: () => void;
6
+ onGridBlur: () => void;
7
+ onGridKeyDown: (e: KeyboardEvent) => void;
8
+ };
package/dist/mouse.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CellLayout, CellPropertyFunction, Change, Clickable, Rectangle, RowOrColumnPropertyFunction, SheetMouseEvent, SheetStyle, VisibleLayout, XY } from './types';
2
2
  import { MouseEvent, PointerEvent, RefObject } from 'react';
3
- export declare const useMouse: (hitmapRef: RefObject<Clickable[]>, selection: Rectangle, knobArea: Rectangle | null, editMode: boolean, editData: CellPropertyFunction<string>, sourceData: CellPropertyFunction<string | number | null>, cellReadOnly: CellPropertyFunction<boolean | null>, canSizeColumn: RowOrColumnPropertyFunction<boolean | null>, canSizeRow: RowOrColumnPropertyFunction<boolean | null>, canOrderColumn: RowOrColumnPropertyFunction<boolean | null>, canOrderRow: RowOrColumnPropertyFunction<boolean | null>, cellLayout: CellLayout, visibleCells: VisibleLayout, sheetStyle: SheetStyle, columnGroupKeys: RowOrColumnPropertyFunction<string | number | null>, rowGroupKeys: RowOrColumnPropertyFunction<string | number | null>, selectedColumnGroups: Set<string | number | null> | null, selectedRowGroups: Set<string | number | null> | null, getAutoSizeWidth: (column: number) => number, onEdit?: ((cell: XY) => void) | undefined, onCommit?: (() => void) | undefined, onKnobAreaChange?: ((knobArea: Rectangle | null) => void) | undefined, onDragIndicesChange?: ((indices: [number[] | null, number[] | null]) => void) | undefined, onDragOffsetChange?: ((dragOffset: XY | null) => void) | undefined, onDropTargetChange?: ((selection: Rectangle | null) => void) | undefined, onSelectionChange?: ((selection: Rectangle, scrollTo?: boolean | undefined, toHead?: boolean | undefined) => void) | undefined, onInvalidateColumn?: ((column: number) => void) | undefined, onInvalidateRow?: ((row: number) => void) | undefined, onChange?: ((changes: Change[]) => void) | undefined, onColumnOrderChange?: ((indices: number[], order: number) => void) | undefined, onRowOrderChange?: ((indices: number[], order: number) => void) | undefined, onCellWidthChange?: ((indices: number[], value: number) => void) | undefined, onCellHeightChange?: ((indices: number[], value: number) => void) | undefined, onRightClick?: ((e: SheetMouseEvent) => void) | undefined, dontCommitEditOnSelectionChange?: boolean | undefined, dontChangeSelectionOnOrderChange?: boolean | undefined) => {
3
+ export declare const useMouse: (hitmapRef: RefObject<Clickable[]>, selection: Rectangle, knobArea: Rectangle | null, editMode: boolean, editData: CellPropertyFunction<string>, sourceData: CellPropertyFunction<string | number | null>, cellReadOnly: CellPropertyFunction<boolean | null>, canSizeColumn: RowOrColumnPropertyFunction<boolean | null>, canSizeRow: RowOrColumnPropertyFunction<boolean | null>, canOrderColumn: RowOrColumnPropertyFunction<boolean | null>, canOrderRow: RowOrColumnPropertyFunction<boolean | null>, cellLayout: CellLayout, visibleCells: VisibleLayout, sheetStyle: SheetStyle, columnGroupKeys: RowOrColumnPropertyFunction<string | number | null>, rowGroupKeys: RowOrColumnPropertyFunction<string | number | null>, selectedColumnGroups: Set<string | number | null> | null, selectedRowGroups: Set<string | number | null> | null, getAutoSizeWidth: (column: number) => number, onEdit?: ((cell: XY) => void) | undefined, onCommit?: (() => void) | undefined, onKnobAreaChange?: ((knobArea: Rectangle | null) => void) | undefined, onDragIndicesChange?: ((indices: [number[] | null, number[] | null]) => void) | undefined, onDragOffsetChange?: ((dragOffset: XY | null) => void) | undefined, onDropTargetChange?: ((selection: Rectangle | null) => void) | undefined, onSelectionChange?: ((selection: Rectangle, scrollTo?: boolean | undefined, toHead?: boolean | undefined) => void) | undefined, onFocusChange?: ((focus: boolean) => void) | undefined, onInvalidateColumn?: ((column: number) => void) | undefined, onInvalidateRow?: ((row: number) => void) | undefined, onChange?: ((changes: Change[]) => void) | undefined, onColumnOrderChange?: ((indices: number[], order: number) => void) | undefined, onRowOrderChange?: ((indices: number[], order: number) => void) | undefined, onCellWidthChange?: ((indices: number[], values: number[]) => void) | undefined, onCellHeightChange?: ((indices: number[], values: number[]) => void) | undefined, onRightClick?: ((e: SheetMouseEvent) => void) | undefined, dontCommitEditOnSelectionChange?: boolean | undefined, dontChangeSelectionOnOrderChange?: boolean | undefined) => {
4
4
  knobPosition: XY | null;
5
5
  mouseHandlers: {
6
6
  onPointerLeave: () => void;
package/dist/props.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { Direction, XY, CellContentType, CellProperty, CellPropertyFunction, PropTypes, RowOrColumnProperty, RowOrColumnPropertyFunction } from './types';
1
+ import { Direction, XY, CellContentType, CellProperty, CellPropertyFunction, CellPropertyStyled, CellPropertyStyledFunction, PropTypes, RowOrColumnProperty, RowOrColumnPropertyFunction, RowOrColumnPropertyStyled, RowOrColumnPropertyStyledFunction } from './types';
2
2
  export declare const createRowOrColumnProp: <T extends PropTypes>(rowColProp: T | T[] | RowOrColumnPropertyFunction<T> | undefined, defaultValue: T) => RowOrColumnPropertyFunction<T>;
3
3
  export declare const createCellProp: <T extends PropTypes>(cellProp: T | T[][] | CellPropertyFunction<T> | undefined, defaultValue: T) => CellPropertyFunction<T>;
4
+ export declare const createRowOrColumnStyledProp: <T extends PropTypes>(rowColProp: T | T[] | RowOrColumnPropertyStyledFunction<T> | undefined, defaultValue: T) => RowOrColumnPropertyStyledFunction<T>;
5
+ export declare const createCellStyledProp: <T extends PropTypes>(cellProp: T | T[][] | CellPropertyStyledFunction<T> | undefined, defaultValue: T) => CellPropertyStyledFunction<T>;
4
6
  export declare const findApproxMaxEditDataIndex: (editData: CellPropertyFunction<string>) => XY;
5
- export declare const findInDisplayData: (displayData: CellPropertyFunction<CellContentType>, start: XY, direction: Direction) => XY;
7
+ export declare const findInDisplayData: (displayData: CellPropertyStyledFunction<CellContentType>, start: XY, direction: Direction) => XY;
package/dist/render.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { CellLayout, CellPropertyFunction, RowOrColumnPropertyFunction, InternalSheetStyle, Rectangle, Selection, Clickable, Style, CellContentType, VisibleLayout, XY } from './types';
2
- export declare const renderSheet: (context: CanvasRenderingContext2D, cellLayout: CellLayout, visibleCells: VisibleLayout, sheetStyle: InternalSheetStyle, cellStyle: CellPropertyFunction<Style>, selection: Rectangle, secondarySelections: Selection[], knobPosition: XY | null, knobArea: Rectangle | null, dragIndices: [number[] | null, number[] | null], dragOffset: XY | null, dropTarget: Rectangle | null, columnHeaders: RowOrColumnPropertyFunction<CellContentType>, columnHeaderStyle: RowOrColumnPropertyFunction<Style>, displayData: CellPropertyFunction<CellContentType>, columnGroupKeys: RowOrColumnPropertyFunction<string | number | null>, rowGroupKeys: RowOrColumnPropertyFunction<string | number | null>, selectedColumnGroups: Set<string | number | null> | null, selectedRowGroups: Set<string | number | null> | null, dataOffset: XY) => Clickable[];
3
- export declare const renderCell: (context: CanvasRenderingContext2D, cellContent: CellContentType, style: Style, defaultCellStyle: Required<Style>, xCoord: number, yCoord: number, cellWidth: number, cellHeight: number) => Clickable[];
1
+ import { CellLayout, CellPropertyFunction, CellPropertyStyledFunction, RowOrColumnPropertyFunction, RowOrColumnPropertyStyledFunction, InternalSheetStyle, Rectangle, Selection, Clickable, Style, CellContentType, VisibleLayout, XY } from './types';
2
+ export declare const renderSheet: (context: CanvasRenderingContext2D, cellLayout: CellLayout, visibleCells: VisibleLayout, sheetStyle: InternalSheetStyle, cellStyle: CellPropertyFunction<Style>, selection: Rectangle, secondarySelections: Selection[], isFocused: boolean, knobPosition: XY | null, knobArea: Rectangle | null, dragIndices: [number[] | null, number[] | null], dragOffset: XY | null, dropTarget: Rectangle | null, columnHeaders: RowOrColumnPropertyStyledFunction<CellContentType>, columnHeaderStyle: RowOrColumnPropertyFunction<Style>, displayData: CellPropertyStyledFunction<CellContentType>, columnGroupKeys: RowOrColumnPropertyFunction<string | number | null>, rowGroupKeys: RowOrColumnPropertyFunction<string | number | null>, selectedColumnGroups: Set<string | number | null> | null, selectedRowGroups: Set<string | number | null> | null, dataOffset: XY) => Clickable[];
3
+ export declare const renderCell: (context: CanvasRenderingContext2D, cellContent: CellContentType, style: Required<Style>, xCoord: number, yCoord: number, cellWidth: number, cellHeight: number) => Clickable[];
package/dist/sheet.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { KeyboardEventHandler, ReactElement } from 'react';
2
- import { XY, Rectangle, CellLayout, CellProperty, CellContentType, RowOrColumnProperty, Selection, Change, SheetPointerEvent, InputStyle, SheetStyle, Style, VisibleLayout } from './types';
2
+ import { XY, Rectangle, CellLayout, CellProperty, CellPropertyStyled, CellContentType, ClipboardPayload, RowOrColumnPropertyStyled, RowOrColumnProperty, Selection, Change, SheetPointerEvent, InputStyle, SheetStyle, Style, VisibleLayout } from './types';
3
3
  export declare type SheetInputProps = {
4
4
  value: string;
5
5
  autoFocus: boolean;
@@ -16,7 +16,7 @@ export declare type SheetRenderProps = {
16
16
  export declare type SheetProps = {
17
17
  cellWidth?: RowOrColumnProperty<number>;
18
18
  cellHeight?: RowOrColumnProperty<number>;
19
- columnHeaders?: RowOrColumnProperty<CellContentType>;
19
+ columnHeaders?: RowOrColumnPropertyStyled<CellContentType>;
20
20
  columnHeaderStyle?: RowOrColumnProperty<Style>;
21
21
  cellStyle?: CellProperty<Style>;
22
22
  readOnly?: CellProperty<boolean>;
@@ -27,7 +27,7 @@ export declare type SheetProps = {
27
27
  columnGroupKeys?: RowOrColumnProperty<string | number | null>;
28
28
  rowGroupKeys?: RowOrColumnProperty<string | number | null>;
29
29
  sourceData?: CellProperty<string | number | null>;
30
- displayData?: CellProperty<CellContentType>;
30
+ displayData?: CellPropertyStyled<CellContentType>;
31
31
  editData?: CellProperty<string>;
32
32
  editKeys?: CellProperty<string>;
33
33
  sheetStyle?: SheetStyle;
@@ -38,6 +38,7 @@ export declare type SheetProps = {
38
38
  cacheLayout?: boolean | number;
39
39
  dontCommitEditOnSelectionChange?: boolean;
40
40
  dontChangeSelectionOnOrderChange?: boolean;
41
+ autoFocus?: boolean;
41
42
  inputComponent?: (x: number, y: number, props: SheetInputProps, commitEditingCell?: (value?: string | number | null) => void) => ReactElement | undefined;
42
43
  renderInside?: (props: SheetRenderProps) => React.ReactNode;
43
44
  renderOutside?: (props: SheetRenderProps) => React.ReactNode;
@@ -46,12 +47,17 @@ export declare type SheetProps = {
46
47
  onChange?: (changes: Array<Change>) => void;
47
48
  onColumnOrderChange?: (indices: number[], order: number) => void;
48
49
  onRowOrderChange?: (indices: number[], order: number) => void;
49
- onCellWidthChange?: (indices: number[], value: number) => void;
50
- onCellHeightChange?: (indices: number[], value: number) => void;
50
+ onCellWidthChange?: (indices: number[], values: number[]) => void;
51
+ onCellHeightChange?: (indices: number[], values: number[]) => void;
51
52
  onScrollChange?: (visibleRows: number[], visibleColumns: number[]) => void;
53
+ onCopy?: (selection: Rectangle, cells: string[][]) => ClipboardPayload<any> | null | undefined;
54
+ onPaste?: (selection: Rectangle, cells: string[][], payload: ClipboardPayload<any>) => boolean | null | undefined | Promise<boolean | null | undefined>;
52
55
  };
53
56
  export declare type SheetRef = CellLayout & {
54
57
  startEditingCell: (editCell: XY, arrowKeyCommitMode?: boolean) => void;
58
+ copySelection: (selection: Rectangle, cut?: boolean) => Promise<void>;
59
+ pasteSelection: (selection: Rectangle) => Promise<void>;
60
+ canPasteSelection: () => boolean;
55
61
  };
56
62
  declare const Sheet: React.ForwardRefExoticComponent<SheetProps & React.RefAttributes<SheetRef>>;
57
63
  export default Sheet;
package/dist/style.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { InternalSheetStyle, SheetStyle, Style } from './types';
2
2
  export declare const resolveSheetStyle: (sheetStyle?: SheetStyle | undefined) => InternalSheetStyle;
3
- export declare const resolveCellStyle: (optionalStyle: Style, defaultStyle: Required<Style>) => Required<Style>;
4
3
  export declare const applyAlignment: (start: number, cellSize: number, style: Required<Style>, imageWidth: number, alignment?: 'left' | 'center' | 'right') => number;
package/dist/types.d.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { MouseEvent, PointerEvent, CSSProperties } from 'react';
2
2
  export declare type PropTypes = string | number | boolean | Style | CellContentType;
3
+ export declare type CellPropertyStyledFunction<T extends PropTypes> = (x: number, y: number, style: Required<Style>) => T;
4
+ export declare type RowOrColumnPropertyStyledFunction<T extends PropTypes> = (rowOrColIndex: number, style: Required<Style>) => T;
3
5
  export declare type CellPropertyFunction<T extends PropTypes> = (x: number, y: number) => T;
4
6
  export declare type RowOrColumnPropertyFunction<T extends PropTypes> = (rowOrColIndex: number) => T;
7
+ export declare type CellPropertyStyled<T extends PropTypes> = T | T[][] | CellPropertyStyledFunction<T>;
8
+ export declare type RowOrColumnPropertyStyled<T extends PropTypes> = T | T[] | RowOrColumnPropertyStyledFunction<T>;
5
9
  export declare type CellProperty<T extends PropTypes> = T | T[][] | CellPropertyFunction<T>;
6
10
  export declare type RowOrColumnProperty<T extends PropTypes> = T | T[] | RowOrColumnPropertyFunction<T>;
7
11
  export declare type CellContentType = null | number | string | CellContent;
@@ -65,6 +69,12 @@ export declare type Resizable = {
65
69
  size: number;
66
70
  indices: number[];
67
71
  };
72
+ export declare type ClipboardPayload<T> = {
73
+ cut: boolean;
74
+ data: T;
75
+ origin: string;
76
+ version: number;
77
+ };
68
78
  export declare type Change = {
69
79
  x: number;
70
80
  y: number;
@@ -74,10 +84,6 @@ export declare type Change = {
74
84
  y: number;
75
85
  };
76
86
  };
77
- export declare type ParsedChange = {
78
- selection: Rectangle;
79
- changes: Change[];
80
- };
81
87
  export declare type SheetMouseEvent = MouseEvent & {
82
88
  cellX: number;
83
89
  cellY: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sheet-happens",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "React Spreadsheet",
5
5
  "author": "Luka-M",
6
6
  "license": "MIT",