sheet-happens 0.0.49 → 0.0.51

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/dist/layout.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { XY, CellLayout, LayoutCache } from './types';
2
- export declare const makeCellLayout: (freeze: XY, indent: XY, offset: XY, columns: LayoutCache, rows: LayoutCache) => CellLayout;
2
+ export declare const makeCellLayout: (freeze: XY, offset: XY, columns: LayoutCache, rows: LayoutCache) => CellLayout;
3
3
  export declare const makeLayoutCache: (sizer: (index: number) => number) => LayoutCache;
package/dist/mouse.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { CellLayout, CellPropertyFunction, Change, Clickable, Rectangle, RowOrColumnPropertyFunction, SheetMouseEvent, SheetStyle, VisibleLayout, XY } from './types';
1
+ import { CellContentRender, CellLayout, CellPropertyFunction, Change, 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, 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) => {
3
+ export declare const useMouse: (hitmapRef: RefObject<CellContentRender[]>, 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, getAutoSizeHeight: (row: 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/render.d.ts CHANGED
@@ -1,3 +1,5 @@
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[];
1
+ import { CellContentRender, CellLayout, CellPropertyFunction, CellPropertyStyledFunction, RowOrColumnPropertyFunction, RowOrColumnPropertyStyledFunction, ImageRenderer, InternalSheetStyle, Rectangle, Selection, Style, CellContentType, VisibleLayout, XY } from './types';
2
+ export declare const renderSheet: (context: CanvasRenderingContext2D, imageRenderer: ImageRenderer, 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) => CellContentRender[];
3
+ export declare const renderCell: (context: CanvasRenderingContext2D, imageRenderer: ImageRenderer, cellContent: CellContentType, style: Required<Style>, xCoord: number, yCoord: number, cellWidth: number, cellHeight: number) => CellContentRender[] | null;
4
+ export declare const getDpiNudge: () => number;
5
+ export declare const roundDpi: (y: number) => number;
package/dist/style.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import { InternalSheetStyle, SheetStyle, Style } from './types';
1
+ import { InternalSheetStyle, SheetStyle } from './types';
2
2
  export declare const resolveSheetStyle: (sheetStyle?: SheetStyle | undefined) => InternalSheetStyle;
3
- export declare const applyAlignment: (start: number, cellSize: number, style: Required<Style>, imageWidth: number, alignment?: 'left' | 'center' | 'right') => number;
package/dist/text.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { Align, Style } from './types';
2
+ export declare const wrapText: (context: CanvasRenderingContext2D, text: string | number, style: Required<Style>, itemAlign: Align | undefined, xCoord: number, yCoord: number, cellWidth: number, cellHeight: number, emit: (text: string, x: number, y: number) => void) => void;
package/dist/types.d.ts CHANGED
@@ -8,22 +8,56 @@ export declare type CellPropertyStyled<T extends PropTypes> = T | T[][] | CellPr
8
8
  export declare type RowOrColumnPropertyStyled<T extends PropTypes> = T | T[] | RowOrColumnPropertyStyledFunction<T>;
9
9
  export declare type CellProperty<T extends PropTypes> = T | T[][] | CellPropertyFunction<T>;
10
10
  export declare type RowOrColumnProperty<T extends PropTypes> = T | T[] | RowOrColumnPropertyFunction<T>;
11
- export declare type CellContentType = null | number | string | CellContent;
12
- export declare type CellContent = {
11
+ export declare type CellContentType = null | number | string | CellContentContainer;
12
+ export declare type CellContentContainer = {
13
+ inspect?: boolean;
14
+ flexAlign?: Anchor;
15
+ flexJustify?: Justify;
16
+ flexGap?: number;
13
17
  items: CellContentItem[];
14
18
  };
15
- export declare type CellContentItem = {
16
- content: HTMLImageElement | string | number;
17
- x: number;
18
- y: number;
19
+ export declare type CellContentDisplay = {
20
+ display: 'space';
21
+ } | {
22
+ display: 'inline';
23
+ text: string | number | null;
24
+ } | {
25
+ display: 'image' | 'icon';
26
+ image: HTMLImageElement;
27
+ } | {
28
+ display: 'image' | 'icon';
29
+ src: string;
30
+ };
31
+ export declare type CellContentItem = CellContentDisplay & {
32
+ color?: string;
33
+ textAlign?: Align;
34
+ flexGrow?: number;
35
+ flexShrink?: number;
36
+ flexAlignSelf?: Anchor;
37
+ absolute?: boolean;
38
+ left?: number;
39
+ top?: number;
40
+ right?: number;
41
+ bottom?: number;
19
42
  width?: number;
20
43
  height?: number;
21
- horizontalAlign?: 'left' | 'right' | 'center';
44
+ marginLeft?: number;
45
+ marginRight?: number;
46
+ marginTop?: number;
47
+ marginBottom?: number;
22
48
  onClick?: (e: MouseEvent) => void;
23
49
  };
50
+ export declare type CellContentRender = {
51
+ box: Rectangle;
52
+ item: CellContentItem;
53
+ };
54
+ export declare type ImageRenderer = (context: CanvasRenderingContext2D, content: CellContentItem, style: Required<Style>, box: Rectangle) => void;
24
55
  export declare type XY = [number, number];
25
56
  export declare type Rectangle = [XY, XY];
26
57
  export declare type Direction = 'up' | 'down' | 'left' | 'right';
58
+ export declare type Align = 'left' | 'center' | 'right';
59
+ export declare type Anchor = 'start' | 'center' | 'end';
60
+ export declare type Justify = 'start' | 'center' | 'end' | 'justify' | 'between' | 'evenly';
27
61
  export declare type LayoutCache = {
28
62
  getSize: (i: number) => number;
29
63
  getStart: (i: number) => number;
@@ -59,10 +93,6 @@ export declare type Selection = {
59
93
  span: Rectangle;
60
94
  color: string;
61
95
  };
62
- export declare type Clickable = {
63
- rect: Rectangle;
64
- obj: CellContentItem;
65
- };
66
96
  export declare type Resizable = {
67
97
  rect: Rectangle;
68
98
  anchor: number;
@@ -97,10 +127,13 @@ export declare type Style = {
97
127
  color?: string;
98
128
  fontSize?: number;
99
129
  fontFamily?: string;
100
- textAlign?: 'right' | 'left' | 'center';
101
- marginRight?: number;
130
+ fontWeight?: string;
131
+ lineHeight?: number;
132
+ textAlign?: Align;
133
+ marginTop?: number;
134
+ marginBottom?: number;
102
135
  marginLeft?: number;
103
- weight?: string;
136
+ marginRight?: number;
104
137
  fillColor?: string;
105
138
  backgroundColor?: string;
106
139
  };
@@ -115,7 +148,4 @@ export declare type SheetStyle = {
115
148
  shadowBlur?: number;
116
149
  shadowOpacity?: number;
117
150
  };
118
- export declare type InternalSheetStyle = Required<SheetStyle> & {
119
- columnHeaderHeight: number;
120
- rowHeaderWidth: number;
121
- };
151
+ export declare type InternalSheetStyle = Required<SheetStyle>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sheet-happens",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "description": "React Spreadsheet",
5
5
  "author": "Luka-M",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "module": "dist/index.modern.js",
13
13
  "source": "src/index.ts",
14
14
  "engines": {
15
- "node": ">=10"
15
+ "node": ">=18"
16
16
  },
17
17
  "scripts": {
18
18
  "build": "microbundle-crl --no-compress --format modern,cjs",
@@ -27,42 +27,43 @@
27
27
  "deploy": "gh-pages -d example/build"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^16.0.0"
30
+ "react": "^18.3.1",
31
+ "react-dom": "^18.3.1"
31
32
  },
32
33
  "devDependencies": {
34
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
33
35
  "@testing-library/jest-dom": "^4.2.4",
34
36
  "@testing-library/react": "^9.5.0",
35
37
  "@testing-library/user-event": "^7.2.1",
36
- "@types/jest": "^25.1.4",
37
- "@types/node": "^12.12.38",
38
- "@types/react": "^16.9.27",
39
- "@types/react-dom": "^16.9.7",
38
+ "@types/color-rgba": "^2.1.3",
39
+ "@types/jest": "^29.5.4",
40
+ "@types/node": "^18.0.0",
41
+ "@types/react": "^18.3.12",
42
+ "@types/react-dom": "^18.3.1",
40
43
  "@typescript-eslint/eslint-plugin": "^2.26.0",
41
44
  "@typescript-eslint/parser": "^2.26.0",
42
45
  "babel-eslint": "^10.0.3",
43
46
  "cross-env": "^7.0.2",
44
- "eslint": "^6.8.0",
45
- "eslint-config-prettier": "^6.7.0",
46
- "eslint-config-standard": "^14.1.0",
47
- "eslint-config-standard-react": "^9.2.0",
48
- "eslint-plugin-import": "^2.18.2",
49
- "eslint-plugin-node": "^11.0.0",
50
- "eslint-plugin-prettier": "^3.1.1",
51
- "eslint-plugin-promise": "^4.2.1",
52
- "eslint-plugin-react": "^7.17.0",
53
- "eslint-plugin-standard": "^4.0.1",
54
- "gh-pages": "^2.2.0",
55
- "microbundle-crl": "^0.13.10",
47
+ "eslint": "^8.0.1",
48
+ "eslint-config-react-app": "^7.0.1",
49
+ "gh-pages": "^6.2.0",
50
+ "microbundle-crl": "^0.13.11",
56
51
  "npm-run-all": "^4.1.5",
57
- "prettier": "^2.0.4",
58
- "react": "^16.13.1",
59
- "react-dom": "^16.13.1",
60
- "react-scripts": "^3.4.1"
52
+ "prettier": "^3.3.3",
53
+ "react": "^18.3.1",
54
+ "react-dom": "^18.3.1",
55
+ "react-scripts": "^5.0.1"
61
56
  },
62
57
  "files": [
63
58
  "dist"
64
59
  ],
65
60
  "dependencies": {
61
+ "@babel/plugin-proposal-unicode-property-regex": "^7.18.6",
62
+ "color-rgba": "^3.0.0",
63
+ "linebreak": "^1.1.0",
64
+ "postcss-flexbugs-fixes": "^5.0.2",
65
+ "postcss-normalize": "^13.0.1",
66
+ "postcss-preset-env": "^10.1.1",
66
67
  "use-resize-observer": "^7.0.0"
67
68
  },
68
69
  "bugs": {