@rowsncolumns/grid 9.0.4 → 13.2.32
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/LICENSE.md +100 -0
- package/Readme.md +53 -59
- package/dist/cjs/Cell.d.ts +35 -0
- package/dist/cjs/Cell.d.ts.map +1 -0
- package/dist/cjs/Cell.js +29 -0
- package/dist/{CellOverlay.d.ts → cjs/CellOverlay.d.ts} +5 -5
- package/dist/cjs/CellOverlay.d.ts.map +1 -0
- package/dist/cjs/CellOverlay.js +126 -0
- package/dist/cjs/Context.d.ts +8 -0
- package/dist/cjs/Context.d.ts.map +1 -0
- package/dist/cjs/Context.js +13 -0
- package/dist/{FillHandle.d.ts → cjs/FillHandle.d.ts} +2 -1
- package/dist/cjs/FillHandle.d.ts.map +1 -0
- package/dist/cjs/FillHandle.js +26 -0
- package/dist/cjs/Grid.d.ts +558 -0
- package/dist/cjs/Grid.d.ts.map +1 -0
- package/dist/cjs/Grid.js +2446 -0
- package/dist/{GridLine.d.ts → cjs/GridLine.d.ts} +2 -1
- package/dist/cjs/GridLine.d.ts.map +1 -0
- package/dist/cjs/GridLine.js +10 -0
- package/dist/cjs/Image.d.ts +11 -0
- package/dist/cjs/Image.d.ts.map +1 -0
- package/dist/cjs/Image.js +57 -0
- package/dist/cjs/MemoizedGrid.d.ts +49 -0
- package/dist/cjs/MemoizedGrid.d.ts.map +1 -0
- package/dist/cjs/MemoizedGrid.js +105 -0
- package/dist/cjs/Selection.d.ts +5 -0
- package/dist/cjs/Selection.d.ts.map +1 -0
- package/dist/cjs/Selection.js +10 -0
- package/dist/{helpers.d.ts → cjs/helpers.d.ts} +59 -39
- package/dist/cjs/helpers.d.ts.map +1 -0
- package/dist/cjs/helpers.js +1409 -0
- package/dist/{hooks → cjs/hooks}/useCopyPaste.d.ts +3 -2
- package/dist/cjs/hooks/useCopyPaste.d.ts.map +1 -0
- package/dist/cjs/hooks/useCopyPaste.js +230 -0
- package/dist/{hooks → cjs/hooks}/useEditable.d.ts +21 -8
- package/dist/cjs/hooks/useEditable.d.ts.map +1 -0
- package/dist/cjs/hooks/useEditable.js +491 -0
- package/dist/{hooks → cjs/hooks}/useFilter.d.ts +3 -2
- package/dist/cjs/hooks/useFilter.d.ts.map +1 -0
- package/dist/cjs/hooks/useFilter.js +97 -0
- package/dist/{hooks → cjs/hooks}/useImage.d.ts +1 -0
- package/dist/cjs/hooks/useImage.d.ts.map +1 -0
- package/dist/cjs/hooks/useImage.js +80 -0
- package/dist/{hooks → cjs/hooks}/usePagination.d.ts +3 -2
- package/dist/cjs/hooks/usePagination.d.ts.map +1 -0
- package/dist/cjs/hooks/usePagination.js +53 -0
- package/dist/{hooks → cjs/hooks}/useSizer.d.ts +28 -29
- package/dist/cjs/hooks/useSizer.d.ts.map +1 -0
- package/dist/cjs/hooks/useSizer.js +176 -0
- package/dist/{hooks → cjs/hooks}/useTooltip.d.ts +2 -1
- package/dist/cjs/hooks/useTooltip.d.ts.map +1 -0
- package/dist/cjs/hooks/useTooltip.js +82 -0
- package/dist/{hooks → cjs/hooks}/useUndo.d.ts +2 -1
- package/dist/cjs/hooks/useUndo.d.ts.map +1 -0
- package/dist/cjs/hooks/useUndo.js +87 -0
- package/dist/cjs/index.d.ts +19 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +29 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/{types.d.ts → cjs/types.d.ts} +8 -3
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/{types.js → cjs/types.js} +7 -8
- package/dist/cjs/utils.d.ts +9 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +58 -0
- package/dist/cjs/vitest.config.d.ts +3 -0
- package/dist/cjs/vitest.config.d.ts.map +1 -0
- package/dist/cjs/vitest.config.js +24 -0
- package/dist/esm/Cell.d.ts +35 -0
- package/dist/esm/Cell.d.ts.map +1 -0
- package/dist/esm/Cell.js +24 -0
- package/dist/esm/CellOverlay.d.ts +21 -0
- package/dist/esm/CellOverlay.d.ts.map +1 -0
- package/dist/esm/CellOverlay.js +120 -0
- package/dist/esm/Context.d.ts +8 -0
- package/dist/esm/Context.d.ts.map +1 -0
- package/dist/esm/Context.js +9 -0
- package/dist/esm/FillHandle.d.ts +8 -0
- package/dist/esm/FillHandle.d.ts.map +1 -0
- package/dist/{FillHandle.js → esm/FillHandle.js} +5 -11
- package/dist/esm/Grid.d.ts +558 -0
- package/dist/esm/Grid.d.ts.map +1 -0
- package/dist/esm/Grid.js +2451 -0
- package/dist/esm/GridLine.d.ts +5 -0
- package/dist/esm/GridLine.d.ts.map +1 -0
- package/dist/esm/GridLine.js +7 -0
- package/dist/esm/Image.d.ts +11 -0
- package/dist/esm/Image.d.ts.map +1 -0
- package/dist/esm/Image.js +53 -0
- package/dist/esm/MemoizedGrid.d.ts +49 -0
- package/dist/esm/MemoizedGrid.d.ts.map +1 -0
- package/dist/esm/MemoizedGrid.js +98 -0
- package/dist/esm/Selection.d.ts +5 -0
- package/dist/esm/Selection.d.ts.map +1 -0
- package/dist/esm/Selection.js +7 -0
- package/dist/esm/helpers.d.ts +281 -0
- package/dist/esm/helpers.d.ts.map +1 -0
- package/dist/esm/helpers.js +1260 -0
- package/dist/esm/hooks/useCopyPaste.d.ts +53 -0
- package/dist/esm/hooks/useCopyPaste.d.ts.map +1 -0
- package/dist/{hooks → esm/hooks}/useCopyPaste.js +40 -46
- package/dist/esm/hooks/useEditable.d.ts +253 -0
- package/dist/esm/hooks/useEditable.d.ts.map +1 -0
- package/dist/esm/hooks/useEditable.js +482 -0
- package/dist/esm/hooks/useFilter.d.ts +69 -0
- package/dist/esm/hooks/useFilter.d.ts.map +1 -0
- package/dist/{hooks → esm/hooks}/useFilter.js +22 -42
- package/dist/esm/hooks/useImage.d.ts +13 -0
- package/dist/esm/hooks/useImage.d.ts.map +1 -0
- package/dist/esm/hooks/useImage.js +76 -0
- package/dist/esm/hooks/usePagination.d.ts +69 -0
- package/dist/esm/hooks/usePagination.d.ts.map +1 -0
- package/dist/esm/hooks/usePagination.js +47 -0
- package/dist/esm/hooks/useSizer.d.ts +114 -0
- package/dist/esm/hooks/useSizer.d.ts.map +1 -0
- package/dist/esm/hooks/useSizer.js +176 -0
- package/dist/esm/hooks/useTooltip.d.ts +43 -0
- package/dist/esm/hooks/useTooltip.d.ts.map +1 -0
- package/dist/esm/hooks/useTooltip.js +80 -0
- package/dist/esm/hooks/useUndo.d.ts +36 -0
- package/dist/esm/hooks/useUndo.d.ts.map +1 -0
- package/dist/{hooks → esm/hooks}/useUndo.js +16 -25
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +70 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +68 -0
- package/dist/esm/utils.d.ts +9 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +104 -0
- package/dist/esm/vitest.config.d.ts +3 -0
- package/dist/esm/vitest.config.d.ts.map +1 -0
- package/dist/esm/vitest.config.js +22 -0
- package/package.json +28 -29
- package/dist/Cell.d.ts +0 -23
- package/dist/Cell.js +0 -55
- package/dist/Cell.js.map +0 -1
- package/dist/CellOverlay.js +0 -116
- package/dist/CellOverlay.js.map +0 -1
- package/dist/FillHandle.js.map +0 -1
- package/dist/Grid.d.ts +0 -385
- package/dist/Grid.js +0 -1684
- package/dist/Grid.js.map +0 -1
- package/dist/GridLine.js +0 -13
- package/dist/GridLine.js.map +0 -1
- package/dist/Image.d.ts +0 -8
- package/dist/Image.js +0 -50
- package/dist/Image.js.map +0 -1
- package/dist/Selection.d.ts +0 -4
- package/dist/Selection.js +0 -9
- package/dist/Selection.js.map +0 -1
- package/dist/helpers.js +0 -1033
- package/dist/helpers.js.map +0 -1
- package/dist/hooks/useCopyPaste.js.map +0 -1
- package/dist/hooks/useEditable.js +0 -477
- package/dist/hooks/useEditable.js.map +0 -1
- package/dist/hooks/useFilter.js.map +0 -1
- package/dist/hooks/useImage.js +0 -42
- package/dist/hooks/useImage.js.map +0 -1
- package/dist/hooks/usePagination.js +0 -73
- package/dist/hooks/usePagination.js.map +0 -1
- package/dist/hooks/useSelection.d.ts +0 -175
- package/dist/hooks/useSelection.js +0 -982
- package/dist/hooks/useSelection.js.map +0 -1
- package/dist/hooks/useSizer.js +0 -150
- package/dist/hooks/useSizer.js.map +0 -1
- package/dist/hooks/useTooltip.js +0 -106
- package/dist/hooks/useTooltip.js.map +0 -1
- package/dist/hooks/useTouch.d.ts +0 -21
- package/dist/hooks/useTouch.js +0 -73
- package/dist/hooks/useTouch.js.map +0 -1
- package/dist/hooks/useUndo.js.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -61
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +0 -153
- package/dist/utils.js.map +0 -1
- package/src/Cell.tsx +0 -100
- package/src/CellOverlay.tsx +0 -191
- package/src/FillHandle.tsx +0 -37
- package/src/Grid.tsx +0 -2677
- package/src/GridLine.tsx +0 -23
- package/src/Image.tsx +0 -43
- package/src/Selection.tsx +0 -9
- package/src/helpers.ts +0 -1455
- package/src/hooks/useCopyPaste.ts +0 -265
- package/src/hooks/useEditable.tsx +0 -945
- package/src/hooks/useFilter.tsx +0 -233
- package/src/hooks/useImage.ts +0 -57
- package/src/hooks/usePagination.tsx +0 -153
- package/src/hooks/useSelection.ts +0 -1440
- package/src/hooks/useSizer.ts +0 -312
- package/src/hooks/useTooltip.tsx +0 -172
- package/src/hooks/useTouch.ts +0 -116
- package/src/hooks/useUndo.ts +0 -134
- package/src/index.tsx +0 -46
- package/src/tests/Grid.spec.tsx +0 -47
- package/src/tests/helpers.test.ts +0 -292
- package/src/tests/usePagination.test.ts +0 -28
- package/src/tests/useSelection.test.ts +0 -27
- package/src/tests/useUndo.test.ts +0 -73
- package/src/types.ts +0 -69
- package/src/utils.tsx +0 -287
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
const helpers_1 = require("../helpers");
|
|
1
|
+
import { useCallback, useEffect, useReducer, useRef } from "react";
|
|
2
|
+
import { KeyCodes } from "../types";
|
|
6
3
|
/**
|
|
7
4
|
* Undo/Redo hook
|
|
8
5
|
* @param
|
|
9
6
|
*/
|
|
10
7
|
const useUndo = (props = {}) => {
|
|
11
8
|
const { enableGlobalKeyHandlers, onRedo, onUndo, identifier } = props;
|
|
12
|
-
const undoStack =
|
|
13
|
-
const undoStackPointer =
|
|
14
|
-
const [_, forceRender] =
|
|
15
|
-
|
|
9
|
+
const undoStack = useRef([]);
|
|
10
|
+
const undoStackPointer = useRef(-1);
|
|
11
|
+
const [_, forceRender] = useReducer((s) => s + 1, 0);
|
|
12
|
+
useEffect(() => {
|
|
16
13
|
if (enableGlobalKeyHandlers)
|
|
17
14
|
document.addEventListener("keydown", handleKeyDown);
|
|
18
15
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
19
16
|
}, [enableGlobalKeyHandlers]);
|
|
20
|
-
const handleKeyDown =
|
|
21
|
-
var _a;
|
|
17
|
+
const handleKeyDown = useCallback((e) => {
|
|
22
18
|
/* Is user focused on an input, textarea or select element */
|
|
23
|
-
if (document.activeElement &&
|
|
24
|
-
helpers_1.focusableNodeNames.has((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.nodeName)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
19
|
const isMeta = e.metaKey || e.ctrlKey;
|
|
28
|
-
const isUndo = isMeta && e.which ===
|
|
29
|
-
const isRedo = (e.shiftKey && isUndo) || e.which ===
|
|
20
|
+
const isUndo = isMeta && e.which === KeyCodes.Z;
|
|
21
|
+
const isRedo = (e.shiftKey && isUndo) || e.which === KeyCodes.KEY_Y;
|
|
30
22
|
if (!isRedo && !isUndo)
|
|
31
23
|
return;
|
|
32
24
|
if (isRedo) {
|
|
@@ -36,7 +28,7 @@ const useUndo = (props = {}) => {
|
|
|
36
28
|
handleUndo();
|
|
37
29
|
}
|
|
38
30
|
}, []);
|
|
39
|
-
const handleUndo =
|
|
31
|
+
const handleUndo = useCallback(() => {
|
|
40
32
|
if (undoStackPointer.current < 0)
|
|
41
33
|
return;
|
|
42
34
|
const patches = undoStack.current[undoStackPointer.current].inversePatches;
|
|
@@ -44,7 +36,7 @@ const useUndo = (props = {}) => {
|
|
|
44
36
|
onUndo && onUndo(patches);
|
|
45
37
|
forceRender();
|
|
46
38
|
}, []);
|
|
47
|
-
const handleRedo =
|
|
39
|
+
const handleRedo = useCallback(() => {
|
|
48
40
|
if (undoStackPointer.current === undoStack.current.length - 1)
|
|
49
41
|
return;
|
|
50
42
|
undoStackPointer.current++;
|
|
@@ -52,7 +44,7 @@ const useUndo = (props = {}) => {
|
|
|
52
44
|
onRedo && onRedo(patches);
|
|
53
45
|
forceRender();
|
|
54
46
|
}, []);
|
|
55
|
-
const addUndoable =
|
|
47
|
+
const addUndoable = useCallback((history) => {
|
|
56
48
|
const { patches, inversePatches } = history;
|
|
57
49
|
const pointer = ++undoStackPointer.current;
|
|
58
50
|
undoStack.current.length = pointer;
|
|
@@ -62,18 +54,18 @@ const useUndo = (props = {}) => {
|
|
|
62
54
|
/**
|
|
63
55
|
* Use for async update where you want to replace the last patch
|
|
64
56
|
*/
|
|
65
|
-
const replaceLastPatch =
|
|
57
|
+
const replaceLastPatch = useCallback((patches, inversePatches) => {
|
|
66
58
|
if (patches === void 0) {
|
|
67
59
|
return;
|
|
68
60
|
}
|
|
69
61
|
const currentStack = undoStack.current;
|
|
70
62
|
const pointer = undoStackPointer.current;
|
|
71
63
|
const curPatches = currentStack[pointer];
|
|
72
|
-
if (
|
|
64
|
+
if (curPatches?.patches === void 0) {
|
|
73
65
|
return;
|
|
74
66
|
}
|
|
75
67
|
curPatches.patches.push(...patches);
|
|
76
|
-
if (inversePatches &&
|
|
68
|
+
if (inversePatches && curPatches?.inversePatches) {
|
|
77
69
|
curPatches.inversePatches.unshift(...inversePatches);
|
|
78
70
|
}
|
|
79
71
|
}, []);
|
|
@@ -87,5 +79,4 @@ const useUndo = (props = {}) => {
|
|
|
87
79
|
canRedo: !(undoStackPointer.current === undoStack.current.length - 1),
|
|
88
80
|
};
|
|
89
81
|
};
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=useUndo.js.map
|
|
82
|
+
export default useUndo;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Cell, CellRenderer } from "./Cell";
|
|
2
|
+
import { CellOverlay, CellRenderer as CellOverlayRenderer } from "./CellOverlay";
|
|
3
|
+
import Grid from "./Grid";
|
|
4
|
+
import useFilter from "./hooks/useFilter";
|
|
5
|
+
import useUndo from "./hooks/useUndo";
|
|
6
|
+
import { Image } from "./Image";
|
|
7
|
+
import Selection from "./Selection";
|
|
8
|
+
export { Grid, CellRenderer, Cell, CellOverlay, useUndo, useFilter, CellOverlayRenderer, Image, Selection, };
|
|
9
|
+
export * from "./Grid";
|
|
10
|
+
export * from "./helpers";
|
|
11
|
+
export * from "./hooks/useFilter";
|
|
12
|
+
export * from "./hooks/useUndo";
|
|
13
|
+
export * from "./hooks/useTooltip";
|
|
14
|
+
export * from "./hooks/useEditable";
|
|
15
|
+
export * from "./types";
|
|
16
|
+
export type { ImageProps } from "./Image";
|
|
17
|
+
export * from "./utils";
|
|
18
|
+
export * from "./Context";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,YAAY,IAAI,mBAAmB,EACpC,MAAM,eAAe,CAAC;AACvB,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,OAAO,EACP,SAAS,EACT,mBAAmB,EACnB,KAAK,EACL,SAAS,GACV,CAAC;AACF,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Cell, CellRenderer } from "./Cell";
|
|
2
|
+
import { CellOverlay, CellRenderer as CellOverlayRenderer, } from "./CellOverlay";
|
|
3
|
+
import Grid from "./Grid";
|
|
4
|
+
import useFilter from "./hooks/useFilter";
|
|
5
|
+
import useUndo from "./hooks/useUndo";
|
|
6
|
+
import { Image } from "./Image";
|
|
7
|
+
import Selection from "./Selection";
|
|
8
|
+
export { Grid, CellRenderer, Cell, CellOverlay, useUndo, useFilter, CellOverlayRenderer, Image, Selection, };
|
|
9
|
+
export * from "./Grid";
|
|
10
|
+
export * from "./helpers";
|
|
11
|
+
export * from "./hooks/useFilter";
|
|
12
|
+
export * from "./hooks/useUndo";
|
|
13
|
+
export * from "./hooks/useTooltip";
|
|
14
|
+
export * from "./hooks/useEditable";
|
|
15
|
+
export * from "./types";
|
|
16
|
+
export * from "./utils";
|
|
17
|
+
export * from "./Context";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../../cell.tsx","../../celloverlay.tsx","../../context.tsx","../../fillhandle.tsx","../../grid.tsx","../../gridline.tsx","../../image.tsx","../../memoizedgrid.tsx","../../selection.tsx","../../helpers.ts","../../index.tsx","../../types.ts","../../utils.tsx","../../vitest.config.ts","../../hooks/usecopypaste.ts","../../hooks/useeditable.tsx","../../hooks/usefilter.tsx","../../hooks/useimage.ts","../../hooks/usepagination.tsx","../../hooks/usesizer.ts","../../hooks/usetooltip.tsx","../../hooks/useundo.ts"],"version":"5.8.3"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export declare enum KeyCodes {
|
|
2
|
+
Right = 39,
|
|
3
|
+
Left = 37,
|
|
4
|
+
Up = 38,
|
|
5
|
+
Down = 40,
|
|
6
|
+
Escape = 27,
|
|
7
|
+
Tab = 9,
|
|
8
|
+
Meta = 91,
|
|
9
|
+
Delete = 46,
|
|
10
|
+
BackSpace = 8,
|
|
11
|
+
Enter = 13,
|
|
12
|
+
A = 65,
|
|
13
|
+
SPACE = 32,
|
|
14
|
+
ALT = 18,
|
|
15
|
+
C = 67,
|
|
16
|
+
Home = 36,
|
|
17
|
+
End = 35,
|
|
18
|
+
PageDown = 34,
|
|
19
|
+
PageUp = 33,
|
|
20
|
+
Z = 90,
|
|
21
|
+
CapsLock = 20,
|
|
22
|
+
KEY_B = 66,
|
|
23
|
+
KEY_I = 73,
|
|
24
|
+
KEY_U = 85,
|
|
25
|
+
KEY_X = 88,
|
|
26
|
+
KEY_L = 76,
|
|
27
|
+
KEY_E = 69,
|
|
28
|
+
KEY_R = 82,
|
|
29
|
+
BACK_SLASH = 220,
|
|
30
|
+
KEY_Y = 89,
|
|
31
|
+
ScrollLock = 145,
|
|
32
|
+
NumLock = 144,
|
|
33
|
+
Pause = 19,
|
|
34
|
+
Insert = 45,
|
|
35
|
+
F1 = 112,
|
|
36
|
+
F2 = 113,
|
|
37
|
+
F3 = 114,
|
|
38
|
+
F4 = 115,
|
|
39
|
+
F5 = 116,
|
|
40
|
+
F6 = 117,
|
|
41
|
+
F7 = 118,
|
|
42
|
+
F8 = 119,
|
|
43
|
+
F9 = 120,
|
|
44
|
+
F10 = 121,
|
|
45
|
+
F11 = 122,
|
|
46
|
+
F12 = 123
|
|
47
|
+
}
|
|
48
|
+
export declare enum Direction {
|
|
49
|
+
Up = "UP",
|
|
50
|
+
Down = "DOWN",
|
|
51
|
+
Left = "LEFT",
|
|
52
|
+
Right = "RIGHT"
|
|
53
|
+
}
|
|
54
|
+
export declare enum MimeType {
|
|
55
|
+
html = "text/html",
|
|
56
|
+
csv = "text/csv",
|
|
57
|
+
plain = "text/plain",
|
|
58
|
+
json = "application/json"
|
|
59
|
+
}
|
|
60
|
+
export declare enum MouseButtonCodes {
|
|
61
|
+
"left" = 0,
|
|
62
|
+
"middle" = 1,
|
|
63
|
+
"right" = 2
|
|
64
|
+
}
|
|
65
|
+
export type SelectionPolicy = "single" | "range" | "multiple";
|
|
66
|
+
export type RowRange = {
|
|
67
|
+
start: number;
|
|
68
|
+
end: number;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,KAAK,KAAK;IACV,IAAI,KAAK;IACT,EAAE,KAAK;IACP,IAAI,KAAK;IACT,MAAM,KAAK;IACX,GAAG,IAAI;IACP,IAAI,KAAK;IACT,MAAM,KAAK;IACX,SAAS,IAAI;IACb,KAAK,KAAK;IACV,CAAC,KAAK;IACN,KAAK,KAAK;IACV,GAAG,KAAK;IACR,CAAC,KAAK;IACN,IAAI,KAAK;IACT,GAAG,KAAK;IACR,QAAQ,KAAK;IACb,MAAM,KAAK;IACX,CAAC,KAAK;IACN,QAAQ,KAAK;IACb,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,KAAK;IACV,UAAU,MAAM;IAChB,KAAK,KAAK;IACV,UAAU,MAAM;IAChB,OAAO,MAAM;IACb,KAAK,KAAK;IACV,MAAM,KAAK;IACX,EAAE,MAAM;IACR,EAAE,MAAM;IACR,EAAE,MAAM;IACR,EAAE,MAAM;IACR,EAAE,MAAM;IACR,EAAE,MAAM;IACR,EAAE,MAAM;IACR,EAAE,MAAM;IACR,EAAE,MAAM;IACR,GAAG,MAAM;IACT,GAAG,MAAM;IACT,GAAG,MAAM;CACV;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,QAAQ;IAClB,IAAI,cAAc;IAClB,GAAG,aAAa;IAChB,KAAK,eAAe;IACpB,IAAI,qBAAqB;CAC1B;AAED,oBAAY,gBAAgB;IAC1B,MAAM,IAAI;IACV,QAAQ,IAAI;IACZ,OAAO,IAAI;CACZ;AAED,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export var KeyCodes;
|
|
2
|
+
(function (KeyCodes) {
|
|
3
|
+
KeyCodes[KeyCodes["Right"] = 39] = "Right";
|
|
4
|
+
KeyCodes[KeyCodes["Left"] = 37] = "Left";
|
|
5
|
+
KeyCodes[KeyCodes["Up"] = 38] = "Up";
|
|
6
|
+
KeyCodes[KeyCodes["Down"] = 40] = "Down";
|
|
7
|
+
KeyCodes[KeyCodes["Escape"] = 27] = "Escape";
|
|
8
|
+
KeyCodes[KeyCodes["Tab"] = 9] = "Tab";
|
|
9
|
+
KeyCodes[KeyCodes["Meta"] = 91] = "Meta";
|
|
10
|
+
KeyCodes[KeyCodes["Delete"] = 46] = "Delete";
|
|
11
|
+
KeyCodes[KeyCodes["BackSpace"] = 8] = "BackSpace";
|
|
12
|
+
KeyCodes[KeyCodes["Enter"] = 13] = "Enter";
|
|
13
|
+
KeyCodes[KeyCodes["A"] = 65] = "A";
|
|
14
|
+
KeyCodes[KeyCodes["SPACE"] = 32] = "SPACE";
|
|
15
|
+
KeyCodes[KeyCodes["ALT"] = 18] = "ALT";
|
|
16
|
+
KeyCodes[KeyCodes["C"] = 67] = "C";
|
|
17
|
+
KeyCodes[KeyCodes["Home"] = 36] = "Home";
|
|
18
|
+
KeyCodes[KeyCodes["End"] = 35] = "End";
|
|
19
|
+
KeyCodes[KeyCodes["PageDown"] = 34] = "PageDown";
|
|
20
|
+
KeyCodes[KeyCodes["PageUp"] = 33] = "PageUp";
|
|
21
|
+
KeyCodes[KeyCodes["Z"] = 90] = "Z";
|
|
22
|
+
KeyCodes[KeyCodes["CapsLock"] = 20] = "CapsLock";
|
|
23
|
+
KeyCodes[KeyCodes["KEY_B"] = 66] = "KEY_B";
|
|
24
|
+
KeyCodes[KeyCodes["KEY_I"] = 73] = "KEY_I";
|
|
25
|
+
KeyCodes[KeyCodes["KEY_U"] = 85] = "KEY_U";
|
|
26
|
+
KeyCodes[KeyCodes["KEY_X"] = 88] = "KEY_X";
|
|
27
|
+
KeyCodes[KeyCodes["KEY_L"] = 76] = "KEY_L";
|
|
28
|
+
KeyCodes[KeyCodes["KEY_E"] = 69] = "KEY_E";
|
|
29
|
+
KeyCodes[KeyCodes["KEY_R"] = 82] = "KEY_R";
|
|
30
|
+
KeyCodes[KeyCodes["BACK_SLASH"] = 220] = "BACK_SLASH";
|
|
31
|
+
KeyCodes[KeyCodes["KEY_Y"] = 89] = "KEY_Y";
|
|
32
|
+
KeyCodes[KeyCodes["ScrollLock"] = 145] = "ScrollLock";
|
|
33
|
+
KeyCodes[KeyCodes["NumLock"] = 144] = "NumLock";
|
|
34
|
+
KeyCodes[KeyCodes["Pause"] = 19] = "Pause";
|
|
35
|
+
KeyCodes[KeyCodes["Insert"] = 45] = "Insert";
|
|
36
|
+
KeyCodes[KeyCodes["F1"] = 112] = "F1";
|
|
37
|
+
KeyCodes[KeyCodes["F2"] = 113] = "F2";
|
|
38
|
+
KeyCodes[KeyCodes["F3"] = 114] = "F3";
|
|
39
|
+
KeyCodes[KeyCodes["F4"] = 115] = "F4";
|
|
40
|
+
KeyCodes[KeyCodes["F5"] = 116] = "F5";
|
|
41
|
+
KeyCodes[KeyCodes["F6"] = 117] = "F6";
|
|
42
|
+
KeyCodes[KeyCodes["F7"] = 118] = "F7";
|
|
43
|
+
KeyCodes[KeyCodes["F8"] = 119] = "F8";
|
|
44
|
+
KeyCodes[KeyCodes["F9"] = 120] = "F9";
|
|
45
|
+
KeyCodes[KeyCodes["F10"] = 121] = "F10";
|
|
46
|
+
KeyCodes[KeyCodes["F11"] = 122] = "F11";
|
|
47
|
+
KeyCodes[KeyCodes["F12"] = 123] = "F12";
|
|
48
|
+
})(KeyCodes || (KeyCodes = {}));
|
|
49
|
+
export var Direction;
|
|
50
|
+
(function (Direction) {
|
|
51
|
+
Direction["Up"] = "UP";
|
|
52
|
+
Direction["Down"] = "DOWN";
|
|
53
|
+
Direction["Left"] = "LEFT";
|
|
54
|
+
Direction["Right"] = "RIGHT";
|
|
55
|
+
})(Direction || (Direction = {}));
|
|
56
|
+
export var MimeType;
|
|
57
|
+
(function (MimeType) {
|
|
58
|
+
MimeType["html"] = "text/html";
|
|
59
|
+
MimeType["csv"] = "text/csv";
|
|
60
|
+
MimeType["plain"] = "text/plain";
|
|
61
|
+
MimeType["json"] = "application/json";
|
|
62
|
+
})(MimeType || (MimeType = {}));
|
|
63
|
+
export var MouseButtonCodes;
|
|
64
|
+
(function (MouseButtonCodes) {
|
|
65
|
+
MouseButtonCodes[MouseButtonCodes["left"] = 0] = "left";
|
|
66
|
+
MouseButtonCodes[MouseButtonCodes["middle"] = 1] = "middle";
|
|
67
|
+
MouseButtonCodes[MouseButtonCodes["right"] = 2] = "right";
|
|
68
|
+
})(MouseButtonCodes || (MouseButtonCodes = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { SelectionProps } from "./Grid";
|
|
3
|
+
/**
|
|
4
|
+
* Create Pure HTML boxes
|
|
5
|
+
* @param param0
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const createHTMLBox: ({ x, y, width, height, fill, stroke, strokeLeftColor, strokeTopColor, strokeRightColor, strokeBottomColor, strokeWidth, strokeTopWidth, strokeRightWidth, strokeBottomWidth, strokeLeftWidth, index, strokeStyle, fillOpacity, draggable, isDragging, borderCoverWidth, children, ...props }: SelectionProps) => React.JSX.Element;
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,8RAwB3B,cAAc,sBA4IhB,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Create Pure HTML boxes
|
|
4
|
+
* @param param0
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export const createHTMLBox = ({ x = 0, y = 0, width = 0, height = 0, fill, stroke, strokeLeftColor = stroke, strokeTopColor = stroke, strokeRightColor = stroke, strokeBottomColor = stroke, strokeWidth = 0, strokeTopWidth = strokeWidth, strokeRightWidth = strokeWidth, strokeBottomWidth = strokeWidth, strokeLeftWidth = strokeWidth, index, strokeStyle = "solid", fillOpacity = 1, draggable, isDragging, borderCoverWidth = 5, children, ...props }) => {
|
|
8
|
+
const lineStyles = {
|
|
9
|
+
borderWidth: 0,
|
|
10
|
+
position: "absolute",
|
|
11
|
+
pointerEvents: "none",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Border cover is so that there is enough
|
|
15
|
+
* draggable handle area for the user.
|
|
16
|
+
* Default is 5px
|
|
17
|
+
*/
|
|
18
|
+
const showBorderCover = draggable;
|
|
19
|
+
const borderCoverStyle = {
|
|
20
|
+
position: "absolute",
|
|
21
|
+
pointerEvents: draggable ? "auto" : "none",
|
|
22
|
+
cursor: draggable ? (isDragging ? "grabbing" : "grab") : "initial",
|
|
23
|
+
};
|
|
24
|
+
width = width - Math.floor(strokeWidth / 2);
|
|
25
|
+
height = height - Math.floor(strokeWidth / 2);
|
|
26
|
+
const lines = [
|
|
27
|
+
React.createElement("div", { style: {
|
|
28
|
+
...lineStyles,
|
|
29
|
+
transform: `translate3d(${x}px, ${y}px, 0)`,
|
|
30
|
+
width: width,
|
|
31
|
+
height: strokeTopWidth,
|
|
32
|
+
borderColor: strokeTopColor,
|
|
33
|
+
borderTopWidth: strokeTopWidth,
|
|
34
|
+
borderStyle: strokeStyle,
|
|
35
|
+
}, key: "top", ...props }),
|
|
36
|
+
React.createElement("div", { style: {
|
|
37
|
+
...lineStyles,
|
|
38
|
+
transform: `translate3d(${x + width}px, ${y}px, 0)`,
|
|
39
|
+
width: strokeRightWidth,
|
|
40
|
+
height: height,
|
|
41
|
+
borderColor: strokeRightColor,
|
|
42
|
+
borderRightWidth: strokeRightWidth,
|
|
43
|
+
borderStyle: strokeStyle,
|
|
44
|
+
}, key: "right", ...props }),
|
|
45
|
+
React.createElement("div", { style: {
|
|
46
|
+
...lineStyles,
|
|
47
|
+
transform: `translate3d(${x}px, ${y + height}px, 0)`,
|
|
48
|
+
width: width + strokeTopWidth,
|
|
49
|
+
height: strokeBottomWidth,
|
|
50
|
+
borderColor: strokeBottomColor,
|
|
51
|
+
borderBottomWidth: strokeBottomWidth,
|
|
52
|
+
borderStyle: strokeStyle,
|
|
53
|
+
}, key: "bottom", ...props }),
|
|
54
|
+
React.createElement("div", { style: {
|
|
55
|
+
...lineStyles,
|
|
56
|
+
transform: `translate3d(${x}px, ${y}px, 0)`,
|
|
57
|
+
width: strokeLeftWidth,
|
|
58
|
+
height: height,
|
|
59
|
+
borderColor: strokeLeftColor,
|
|
60
|
+
borderLeftWidth: strokeLeftWidth,
|
|
61
|
+
borderStyle: strokeStyle,
|
|
62
|
+
}, key: "left", ...props }),
|
|
63
|
+
];
|
|
64
|
+
const borderCovers = [
|
|
65
|
+
React.createElement("div", { style: {
|
|
66
|
+
...borderCoverStyle,
|
|
67
|
+
transform: `translate3d(${x}px, ${y}px, 0)`,
|
|
68
|
+
width: width,
|
|
69
|
+
height: 5,
|
|
70
|
+
}, key: "top", ...props }),
|
|
71
|
+
React.createElement("div", { style: {
|
|
72
|
+
...borderCoverStyle,
|
|
73
|
+
transform: `translate3d(${x + width - borderCoverWidth + strokeRightWidth}px, ${y}px, 0)`,
|
|
74
|
+
width: borderCoverWidth,
|
|
75
|
+
height: height,
|
|
76
|
+
}, key: "right", ...props }),
|
|
77
|
+
React.createElement("div", { style: {
|
|
78
|
+
...borderCoverStyle,
|
|
79
|
+
transform: `translate3d(${x}px, ${y + height - borderCoverWidth + strokeBottomWidth}px, 0)`,
|
|
80
|
+
width: width + strokeTopWidth,
|
|
81
|
+
height: borderCoverWidth,
|
|
82
|
+
}, key: "bottom", ...props }),
|
|
83
|
+
React.createElement("div", { style: {
|
|
84
|
+
...borderCoverStyle,
|
|
85
|
+
transform: `translate3d(${x}px, ${y}px, 0)`,
|
|
86
|
+
width: borderCoverWidth,
|
|
87
|
+
height: height,
|
|
88
|
+
}, key: "left", ...props }),
|
|
89
|
+
];
|
|
90
|
+
return (React.createElement(React.Fragment, { key: index },
|
|
91
|
+
fill && (React.createElement("div", { style: {
|
|
92
|
+
position: "absolute",
|
|
93
|
+
transform: `translate3d(${x}px, ${y}px, 0)`,
|
|
94
|
+
height,
|
|
95
|
+
width,
|
|
96
|
+
backgroundColor: fill,
|
|
97
|
+
opacity: fillOpacity,
|
|
98
|
+
userSelect: "none",
|
|
99
|
+
pointerEvents: "none",
|
|
100
|
+
} })),
|
|
101
|
+
lines,
|
|
102
|
+
showBorderCover && borderCovers,
|
|
103
|
+
children));
|
|
104
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../../vitest.config.ts"],"names":[],"mappings":";AAGA,wBAsBG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// vitest.config.ts
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: "jsdom",
|
|
7
|
+
// ✅ correct location for deps.inline
|
|
8
|
+
deps: {
|
|
9
|
+
inline: ["konva", "react-konva"],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
// Ensure Vite bundles these for SSR-style test runs
|
|
13
|
+
ssr: {
|
|
14
|
+
noExternal: ["konva", "react-konva"],
|
|
15
|
+
},
|
|
16
|
+
// Prefer the ESM build of react-konva (avoid its CJS wrapper that requires konva)
|
|
17
|
+
resolve: {
|
|
18
|
+
alias: {
|
|
19
|
+
"react-konva": "react-konva/es/ReactKonvaCore.js",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
package/package.json
CHANGED
|
@@ -1,47 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowsncolumns/grid",
|
|
3
3
|
"description": "Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets",
|
|
4
|
-
"version": "
|
|
5
|
-
"
|
|
6
|
-
"license": "MIT",
|
|
4
|
+
"version": "13.2.32",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
6
|
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
"src"
|
|
7
|
+
"dist"
|
|
10
8
|
],
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"precommit": "yarn test && yarn check:types"
|
|
9
|
+
"main": "./dist/cjs/index.js",
|
|
10
|
+
"module": "./dist/esm/index.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"require": "./dist/cjs/index.js"
|
|
15
|
+
}
|
|
19
16
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json",
|
|
19
|
+
"clean": "rimraf dist",
|
|
20
|
+
"build:watch": "tsc -p ./tsconfig.esm.json --watch",
|
|
21
|
+
"test": "vitest --run",
|
|
22
|
+
"precommit": "yarn test && yarn check:types",
|
|
23
|
+
"lint": "eslint . --ext .ts,.tsx"
|
|
22
24
|
},
|
|
23
25
|
"author": "Vinay M <rmdort@gmail.com>",
|
|
24
26
|
"repository": {
|
|
25
27
|
"type": "git",
|
|
26
|
-
"url": "https://github.com/rowsncolumns/
|
|
28
|
+
"url": "https://github.com/rowsncolumns/spreadsheet.git"
|
|
27
29
|
},
|
|
28
30
|
"bugs": {
|
|
29
|
-
"url": "https://github.com/rowsncolumns/
|
|
31
|
+
"url": "https://github.com/rowsncolumns/spreadsheet/issues"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"konva": "^
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"tiny-invariant": "^1.1.0"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"react": ">=18.2.0",
|
|
40
|
-
"react-dom": ">=18.2.0"
|
|
34
|
+
"konva": "^10.0.12",
|
|
35
|
+
"react-konva": "^19.2.1",
|
|
36
|
+
"scheduler": "^0.26.0",
|
|
37
|
+
"tiny-invariant": "^1.3.3"
|
|
41
38
|
},
|
|
42
39
|
"devDependencies": {
|
|
43
|
-
"
|
|
44
|
-
"react-dom": "^18.2.0"
|
|
40
|
+
"canvas": "^3.2.0"
|
|
45
41
|
},
|
|
46
|
-
"
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": ">16.13.1",
|
|
44
|
+
"react-dom": ">16.13.1"
|
|
45
|
+
}
|
|
47
46
|
}
|
package/dist/Cell.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { RendererProps } from "./Grid";
|
|
3
|
-
import { KonvaEventObject } from "konva/lib/Node";
|
|
4
|
-
export interface CellProps extends RendererProps {
|
|
5
|
-
value?: string;
|
|
6
|
-
textColor?: string;
|
|
7
|
-
padding?: number;
|
|
8
|
-
fontWeight?: string;
|
|
9
|
-
fontStyle?: string;
|
|
10
|
-
onClick?: (e: KonvaEventObject<MouseEvent>) => void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Default cell component
|
|
14
|
-
* @param props
|
|
15
|
-
*/
|
|
16
|
-
declare const Cell: React.FC<CellProps>;
|
|
17
|
-
/**
|
|
18
|
-
* Default CellRenderer
|
|
19
|
-
* @param props
|
|
20
|
-
*/
|
|
21
|
-
declare const CellRenderer: (props: RendererProps) => JSX.Element;
|
|
22
|
-
export default CellRenderer;
|
|
23
|
-
export { CellRenderer, Cell };
|
package/dist/Cell.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Cell = exports.CellRenderer = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const react_konva_1 = require("react-konva");
|
|
29
|
-
const helpers_1 = require("./helpers");
|
|
30
|
-
/**
|
|
31
|
-
* Default cell component
|
|
32
|
-
* @param props
|
|
33
|
-
*/
|
|
34
|
-
const Cell = (0, react_1.memo)((props) => {
|
|
35
|
-
const { x = 0, y = 0, width, height, value, fill = "white", strokeWidth = 1, stroke = "#d9d9d9", align = "left", verticalAlign = "middle", textColor = "#333", padding = 5, fontFamily = "Arial", fontSize = 12, children, wrap = "none", fontWeight = "normal", fontStyle = "normal", textDecoration, alpha = 1, strokeEnabled = true, globalCompositeOperation = "multiply", isOverlay, ...rest } = props;
|
|
36
|
-
if (isOverlay)
|
|
37
|
-
return null;
|
|
38
|
-
const fillEnabled = !!fill;
|
|
39
|
-
const textStyle = `${fontWeight} ${fontStyle}`;
|
|
40
|
-
return (react_1.default.createElement(react_konva_1.Group, { ...rest },
|
|
41
|
-
react_1.default.createElement(react_konva_1.Rect, { x: x + 0.5, y: y + 0.5, height: height, width: width, fill: fill, stroke: stroke, strokeWidth: strokeWidth, shadowForStrokeEnabled: false, strokeScaleEnabled: false, hitStrokeWidth: 0, alpha: alpha, fillEnabled: fillEnabled, strokeEnabled: strokeEnabled }),
|
|
42
|
-
(0, helpers_1.isNull)(value) ? null : (react_1.default.createElement(react_konva_1.Text, { x: x, y: y, height: height, width: width, text: value, fill: textColor, verticalAlign: verticalAlign, align: align, fontFamily: fontFamily, fontStyle: textStyle, textDecoration: textDecoration, padding: padding, wrap: wrap, fontSize: fontSize, hitStrokeWidth: 0 })),
|
|
43
|
-
children));
|
|
44
|
-
});
|
|
45
|
-
exports.Cell = Cell;
|
|
46
|
-
/**
|
|
47
|
-
* Default CellRenderer
|
|
48
|
-
* @param props
|
|
49
|
-
*/
|
|
50
|
-
const CellRenderer = (props) => {
|
|
51
|
-
return react_1.default.createElement(Cell, { ...props });
|
|
52
|
-
};
|
|
53
|
-
exports.CellRenderer = CellRenderer;
|
|
54
|
-
exports.default = CellRenderer;
|
|
55
|
-
//# sourceMappingURL=Cell.js.map
|
package/dist/Cell.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cell.js","sourceRoot":"","sources":["../src/Cell.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAoC;AAEpC,6CAAgD;AAEhD,uCAAmC;AAWnC;;;GAGG;AACH,MAAM,IAAI,GAAwB,IAAA,YAAI,EAAC,CAAC,KAAK,EAAE,EAAE;IAC/C,MAAM,EACJ,CAAC,GAAG,CAAC,EACL,CAAC,GAAG,CAAC,EACL,KAAK,EACL,MAAM,EACN,KAAK,EACL,IAAI,GAAG,OAAO,EACd,WAAW,GAAG,CAAC,EACf,MAAM,GAAG,SAAS,EAClB,KAAK,GAAG,MAAM,EACd,aAAa,GAAG,QAAQ,EACxB,SAAS,GAAG,MAAM,EAClB,OAAO,GAAG,CAAC,EACX,UAAU,GAAG,OAAO,EACpB,QAAQ,GAAG,EAAE,EACb,QAAQ,EACR,IAAI,GAAG,MAAM,EACb,UAAU,GAAG,QAAQ,EACrB,SAAS,GAAG,QAAQ,EACpB,cAAc,EACd,KAAK,GAAG,CAAC,EACT,aAAa,GAAG,IAAI,EACpB,wBAAwB,GAAG,UAAU,EACrC,SAAS,EACT,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IACV,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC;IAC3B,MAAM,SAAS,GAAG,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC;IAC/C,OAAO,CACL,8BAAC,mBAAK,OAAK,IAAI;QACb,8BAAC,kBAAI,IACH,CAAC,EAAE,CAAC,GAAG,GAAG,EACV,CAAC,EAAE,CAAC,GAAG,GAAG,EACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,KAAK,EAC7B,kBAAkB,EAAE,KAAK,EACzB,cAAc,EAAE,CAAC,EACjB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,GAC5B;QACD,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,8BAAC,kBAAI,IACH,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,CAAC,GACjB,CACH;QACA,QAAQ,CACH,CACT,CAAC;AACJ,CAAC,CAAC,CAAC;AAWoB,oBAAI;AAT3B;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;IAC5C,OAAO,8BAAC,IAAI,OAAK,KAAK,GAAI,CAAC;AAC7B,CAAC,CAAC;AAGO,oCAAY;AADrB,kBAAe,YAAY,CAAC"}
|