sheet-happens 0.0.22 → 0.0.24

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,4 @@
1
+ import { CellPropertyFunction, Change, Rectangle } from './types';
2
+ import { RefObject } from 'react';
3
+ export declare const useClipboardCopy: (textAreaRef: RefObject<HTMLTextAreaElement>, selection: Rectangle, editMode: boolean, editData: CellPropertyFunction<string>) => void;
4
+ export declare const useClipboardPaste: (textAreaRef: RefObject<HTMLTextAreaElement>, selection: Rectangle, onSelectionChange?: ((selection: Rectangle) => void) | undefined, onChange?: ((changes: Array<Change>) => void) | undefined) => void;
@@ -0,0 +1,45 @@
1
+ import { XY, Rectangle, Selection, Clickable, Direction, Style } from './types';
2
+ export declare const INITIAL_MAX_SCROLL: XY;
3
+ export declare const ORIGIN: XY;
4
+ export declare const ONE_ONE: XY;
5
+ export declare const NO_CELL: XY;
6
+ export declare const NO_SELECTION: Rectangle;
7
+ export declare const NO_SELECTIONS: Selection[];
8
+ export declare const NO_CLICKABLES: Clickable[];
9
+ export declare const NO_STYLE: {};
10
+ export declare const MAX_SEARCHABLE_INDEX = 65536;
11
+ export declare const MAX_XY: XY;
12
+ export declare const COLORS: {
13
+ selectionBorder: string;
14
+ selectionBackground: string;
15
+ gridLine: string;
16
+ dragGhost: string;
17
+ dropTarget: string;
18
+ knobAreaBorder: string;
19
+ headerBackground: string;
20
+ headerText: string;
21
+ headerActive: string;
22
+ headerActiveText: string;
23
+ headerSelected: string;
24
+ headerSelectedText: string;
25
+ };
26
+ export declare const SIZES: {
27
+ knobArea: number;
28
+ headerWidth: number;
29
+ headerHeight: number;
30
+ minimumWidth: number;
31
+ minimumHeight: number;
32
+ resizeZone: number;
33
+ scrollZone: number;
34
+ scrollSpeed: number;
35
+ };
36
+ export declare const DEFAULT_CELL_STYLE: Required<Style>;
37
+ export declare const DEFAULT_COLUMN_HEADER_STYLE: Required<Style>;
38
+ export declare const HEADER_ACTIVE_STYLE: {
39
+ color: string;
40
+ };
41
+ export declare const HEADER_SELECTED_STYLE: {
42
+ backgroundColor: string;
43
+ color: string;
44
+ };
45
+ export declare const ARROW_KEYS: Record<string, Direction>;
@@ -0,0 +1,18 @@
1
+ import { XY, Rectangle } from './types';
2
+ export declare const addXY: (a: XY, b: XY) => XY;
3
+ export declare const subXY: (a: XY, b: XY) => XY;
4
+ export declare const mulXY: (a: XY, b: XY) => XY;
5
+ export declare const maxXY: (a: XY, b: XY) => XY;
6
+ export declare const minXY: (a: XY, b: XY) => XY;
7
+ export declare const clampXY: (p: XY, min: XY, max?: XY) => XY;
8
+ export declare const getDirectionStep: (direction: string) => XY;
9
+ export declare const isSameXY: (a: XY, b: XY) => boolean;
10
+ export declare const isSameSelection: (a: Rectangle, b: Rectangle) => boolean;
11
+ export declare const isMaybeRowSelection: (selection: Rectangle) => boolean;
12
+ export declare const isMaybeColumnSelection: (selection: Rectangle) => boolean;
13
+ export declare const isRowSelection: (selection: Rectangle) => boolean;
14
+ export declare const isColumnSelection: (selection: Rectangle) => boolean;
15
+ export declare const isCellSelection: (selection: Rectangle) => boolean;
16
+ export declare const isEmptySelection: (selection: Rectangle) => boolean;
17
+ export declare const isPointInsideSelection: (selection: Rectangle, point: XY) => boolean;
18
+ export declare const normalizeSelection: (selection: Rectangle) => Rectangle;
package/dist/index.d.ts CHANGED
@@ -1,91 +1,41 @@
1
- import React, { MouseEvent, CSSProperties, ReactElement } from 'react';
2
- declare type PropTypes = string | number | boolean | Style | CellContentType;
3
- declare type RowOrColumnProperty<T extends PropTypes> = T | Array<T> | ((index: number) => T);
4
- declare type CellProperty<T extends PropTypes> = T | Array<Array<T>> | ((x: number, y: number) => T);
5
- declare type CellContentType = null | number | string | CellContent;
6
- declare type InputStyle = Pick<CSSProperties, 'position' | 'top' | 'left' | 'width' | 'height' | 'outline' | 'border' | 'textAlign' | 'color' | 'fontSize' | 'fontFamily'>;
7
- export interface SheetInputProps {
1
+ import React, { KeyboardEventHandler, ReactElement } from 'react';
2
+ import { CellLayout, CellProperty, CellContentType, RowOrColumnProperty, Selection, Change, SheetPointerEvent, InputStyle, SheetStyle, Style } from './types';
3
+ export declare type SheetInputProps = {
8
4
  value: string;
9
5
  autoFocus: boolean;
10
- onKeyDown: React.KeyboardEventHandler<HTMLElement>;
11
- onChange: (valiue: string) => void;
6
+ onKeyDown: KeyboardEventHandler<HTMLElement>;
7
+ onChange: (value: string) => void;
12
8
  style: InputStyle;
13
- }
14
- interface SelectionSpan {
15
- x1: number;
16
- y1: number;
17
- x2: number;
18
- y2: number;
19
- }
20
- interface Selection {
21
- span: SelectionSpan;
22
- color: string;
23
- }
24
- export interface Change {
25
- x: number;
26
- y: number;
27
- value: string | number | null;
28
- source?: {
29
- x: number;
30
- y: number;
31
- };
32
- }
33
- export interface CellContentItem {
34
- content: HTMLImageElement | string | number;
35
- x: number;
36
- y: number;
37
- width?: number;
38
- height?: number;
39
- horiozntalAlign?: 'left' | 'right' | 'center';
40
- onClick?: (e: MouseEvent) => void;
41
- }
42
- export interface CellContent {
43
- items: Array<CellContentItem>;
44
- }
45
- export interface SheetMouseEvent extends MouseEvent {
46
- cellX: number;
47
- cellY: number;
48
- }
49
- export interface SheetStyle {
50
- hideGridlines?: boolean;
51
- hideColumnHeaders?: boolean;
52
- hideRowHeaders?: boolean;
53
- freezeColumns?: number;
54
- freezeRows?: number;
55
- hideScrollBars?: boolean;
56
- }
57
- export interface SheetProps {
9
+ };
10
+ export declare type SheetProps = {
58
11
  cellWidth?: RowOrColumnProperty<number>;
59
12
  cellHeight?: RowOrColumnProperty<number>;
60
13
  columnHeaders?: RowOrColumnProperty<CellContentType>;
61
14
  columnHeaderStyle?: RowOrColumnProperty<Style>;
62
15
  cellStyle?: CellProperty<Style>;
63
16
  readOnly?: CellProperty<boolean>;
17
+ canSizeColumn?: RowOrColumnProperty<boolean>;
18
+ canSizeRow?: RowOrColumnProperty<boolean>;
19
+ canOrderColumn?: RowOrColumnProperty<boolean>;
20
+ canOrderRow?: RowOrColumnProperty<boolean>;
64
21
  sourceData?: CellProperty<string | number | null>;
65
22
  displayData?: CellProperty<CellContentType>;
66
23
  editData?: CellProperty<string>;
67
24
  editKeys?: CellProperty<string>;
68
25
  sheetStyle?: SheetStyle;
69
- dontCommitEditOnSelectionChange?: boolean;
70
26
  secondarySelections?: Selection[];
27
+ cacheLayout?: boolean;
28
+ dontCommitEditOnSelectionChange?: boolean;
71
29
  inputComponent?: (x: number, y: number, props: SheetInputProps, commitEditingCell?: () => void) => ReactElement | undefined;
72
- onSelectionChanged?: (x1: number, y1: number, x2: number, y2: number) => void;
73
- onRightClick?: (e: SheetMouseEvent) => void;
30
+ onSelectionChanged?: (minX: number, minY: number, maxX: number, maxY: number) => void;
31
+ onRightClick?: (e: SheetPointerEvent) => void;
74
32
  onChange?: (changes: Array<Change>) => void;
33
+ onColumnOrderChange?: (indices: number[], order: number) => void;
34
+ onRowOrderChange?: (indices: number[], order: number) => void;
75
35
  onCellWidthChange?: (indices: number[], value: number) => void;
76
36
  onCellHeightChange?: (indices: number[], value: number) => void;
77
- onScrollChange?: (scrollX: number, scrolLY: number) => void;
78
- }
79
- export interface Style {
80
- color?: string;
81
- fontSize?: number;
82
- fontFamily?: string;
83
- textAlign?: 'right' | 'left' | 'center';
84
- marginRight?: number;
85
- marginLeft?: number;
86
- weight?: string;
87
- fillColor?: string;
88
- backgroundColor?: string;
89
- }
90
- declare function Sheet(props: SheetProps): JSX.Element;
37
+ onScrollChange?: (visibleRows: number[], visibleColumns: number[]) => void;
38
+ };
39
+ export declare type SheetRef = CellLayout;
40
+ declare const Sheet: React.ForwardRefExoticComponent<SheetProps & React.RefAttributes<CellLayout>>;
91
41
  export default Sheet;