@gridsheet/react-core 1.4.0-alpha.2 → 1.4.0-alpha.3
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/_virtual/_commonjsHelpers.js +7 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/dayjs.min.js +8 -0
- package/dist/_virtual/dayjs.min.js.map +1 -0
- package/dist/_virtual/dayjs.min2.js +5 -0
- package/dist/_virtual/dayjs.min2.js.map +1 -0
- package/dist/_virtual/jsx-runtime.js +6 -0
- package/dist/_virtual/jsx-runtime.js.map +1 -0
- package/dist/_virtual/jsx-runtime2.js +5 -0
- package/dist/_virtual/jsx-runtime2.js.map +1 -0
- package/dist/_virtual/react-jsx-runtime.development.js +5 -0
- package/dist/_virtual/react-jsx-runtime.development.js.map +1 -0
- package/dist/_virtual/react-jsx-runtime.production.js +5 -0
- package/dist/_virtual/react-jsx-runtime.production.js.map +1 -0
- package/dist/_virtual/timezone.js +8 -0
- package/dist/_virtual/timezone.js.map +1 -0
- package/dist/_virtual/timezone2.js +5 -0
- package/dist/_virtual/timezone2.js.map +1 -0
- package/dist/_virtual/utc.js +8 -0
- package/dist/_virtual/utc.js.map +1 -0
- package/dist/_virtual/utc2.js +5 -0
- package/dist/_virtual/utc2.js.map +1 -0
- package/dist/components/Cell.js +232 -0
- package/dist/components/Cell.js.map +1 -0
- package/dist/components/ContextMenu.js +297 -0
- package/dist/components/ContextMenu.js.map +1 -0
- package/dist/components/Editor.js +455 -0
- package/dist/components/Editor.js.map +1 -0
- package/dist/components/Emitter.js +26 -0
- package/dist/components/Emitter.js.map +1 -0
- package/dist/components/Fixed.js +17 -0
- package/dist/components/Fixed.js.map +1 -0
- package/dist/components/FormulaBar.js +149 -0
- package/dist/components/FormulaBar.js.map +1 -0
- package/dist/components/GridSheet.js +246 -0
- package/dist/components/GridSheet.js.map +1 -0
- package/dist/components/HeaderCellLeft.js +131 -0
- package/dist/components/HeaderCellLeft.js.map +1 -0
- package/dist/components/HeaderCellTop.js +132 -0
- package/dist/components/HeaderCellTop.js.map +1 -0
- package/dist/components/PluginBase.js +35 -0
- package/dist/components/PluginBase.js.map +1 -0
- package/dist/components/Resizer.js +98 -0
- package/dist/components/Resizer.js.map +1 -0
- package/dist/components/SearchBar.js +108 -0
- package/dist/components/SearchBar.js.map +1 -0
- package/dist/components/SheetProvider.js +56 -0
- package/dist/components/SheetProvider.js.map +1 -0
- package/dist/components/StoreInitializer.js +84 -0
- package/dist/components/StoreInitializer.js.map +1 -0
- package/dist/components/Tabular.js +308 -0
- package/dist/components/Tabular.js.map +1 -0
- package/dist/components/hooks.js +15 -0
- package/dist/components/hooks.js.map +1 -0
- package/dist/components/svg/Base.js +24 -0
- package/dist/components/svg/Base.js.map +1 -0
- package/dist/components/svg/CloseIcon.js +13 -0
- package/dist/components/svg/CloseIcon.js.map +1 -0
- package/dist/components/svg/SearchIcon.js +13 -0
- package/dist/components/svg/SearchIcon.js.map +1 -0
- package/dist/constants.js +43 -0
- package/dist/constants.js.map +1 -0
- package/dist/formula/evaluator.js +674 -0
- package/dist/formula/evaluator.js.map +1 -0
- package/dist/formula/functions/__base.js +19 -0
- package/dist/formula/functions/__base.js.map +1 -0
- package/dist/formula/functions/__utils.js +145 -0
- package/dist/formula/functions/__utils.js.map +1 -0
- package/dist/formula/functions/abs.js +24 -0
- package/dist/formula/functions/abs.js.map +1 -0
- package/dist/formula/functions/acos.js +32 -0
- package/dist/formula/functions/acos.js.map +1 -0
- package/dist/formula/functions/add.js +57 -0
- package/dist/formula/functions/add.js.map +1 -0
- package/dist/formula/functions/and.js +28 -0
- package/dist/formula/functions/and.js.map +1 -0
- package/dist/formula/functions/asin.js +32 -0
- package/dist/formula/functions/asin.js.map +1 -0
- package/dist/formula/functions/atan.js +29 -0
- package/dist/formula/functions/atan.js.map +1 -0
- package/dist/formula/functions/atan2.js +35 -0
- package/dist/formula/functions/atan2.js.map +1 -0
- package/dist/formula/functions/average.js +44 -0
- package/dist/formula/functions/average.js.map +1 -0
- package/dist/formula/functions/col.js +31 -0
- package/dist/formula/functions/col.js.map +1 -0
- package/dist/formula/functions/concat.js +27 -0
- package/dist/formula/functions/concat.js.map +1 -0
- package/dist/formula/functions/concatenate.js +28 -0
- package/dist/formula/functions/concatenate.js.map +1 -0
- package/dist/formula/functions/cos.js +29 -0
- package/dist/formula/functions/cos.js.map +1 -0
- package/dist/formula/functions/count.js +38 -0
- package/dist/formula/functions/count.js.map +1 -0
- package/dist/formula/functions/counta.js +38 -0
- package/dist/formula/functions/counta.js.map +1 -0
- package/dist/formula/functions/countif.js +32 -0
- package/dist/formula/functions/countif.js.map +1 -0
- package/dist/formula/functions/divide.js +33 -0
- package/dist/formula/functions/divide.js.map +1 -0
- package/dist/formula/functions/eq.js +29 -0
- package/dist/formula/functions/eq.js.map +1 -0
- package/dist/formula/functions/exp.js +29 -0
- package/dist/formula/functions/exp.js.map +1 -0
- package/dist/formula/functions/gt.js +29 -0
- package/dist/formula/functions/gt.js.map +1 -0
- package/dist/formula/functions/gte.js +29 -0
- package/dist/formula/functions/gte.js.map +1 -0
- package/dist/formula/functions/hlookup.js +75 -0
- package/dist/formula/functions/hlookup.js.map +1 -0
- package/dist/formula/functions/if.js +39 -0
- package/dist/formula/functions/if.js.map +1 -0
- package/dist/formula/functions/iferror.js +45 -0
- package/dist/formula/functions/iferror.js.map +1 -0
- package/dist/formula/functions/len.js +29 -0
- package/dist/formula/functions/len.js.map +1 -0
- package/dist/formula/functions/lenb.js +29 -0
- package/dist/formula/functions/lenb.js.map +1 -0
- package/dist/formula/functions/ln.js +32 -0
- package/dist/formula/functions/ln.js.map +1 -0
- package/dist/formula/functions/log.js +36 -0
- package/dist/formula/functions/log.js.map +1 -0
- package/dist/formula/functions/log10.js +32 -0
- package/dist/formula/functions/log10.js.map +1 -0
- package/dist/formula/functions/lt.js +29 -0
- package/dist/formula/functions/lt.js.map +1 -0
- package/dist/formula/functions/lte.js +29 -0
- package/dist/formula/functions/lte.js.map +1 -0
- package/dist/formula/functions/max.js +47 -0
- package/dist/formula/functions/max.js.map +1 -0
- package/dist/formula/functions/min.js +47 -0
- package/dist/formula/functions/min.js.map +1 -0
- package/dist/formula/functions/minus.js +57 -0
- package/dist/formula/functions/minus.js.map +1 -0
- package/dist/formula/functions/mod.js +33 -0
- package/dist/formula/functions/mod.js.map +1 -0
- package/dist/formula/functions/multiply.js +27 -0
- package/dist/formula/functions/multiply.js.map +1 -0
- package/dist/formula/functions/ne.js +29 -0
- package/dist/formula/functions/ne.js.map +1 -0
- package/dist/formula/functions/not.js +30 -0
- package/dist/formula/functions/not.js.map +1 -0
- package/dist/formula/functions/now.js +22 -0
- package/dist/formula/functions/now.js.map +1 -0
- package/dist/formula/functions/or.js +28 -0
- package/dist/formula/functions/or.js.map +1 -0
- package/dist/formula/functions/pi.js +22 -0
- package/dist/formula/functions/pi.js.map +1 -0
- package/dist/formula/functions/power.js +27 -0
- package/dist/formula/functions/power.js.map +1 -0
- package/dist/formula/functions/product.js +40 -0
- package/dist/formula/functions/product.js.map +1 -0
- package/dist/formula/functions/radians.js +29 -0
- package/dist/formula/functions/radians.js.map +1 -0
- package/dist/formula/functions/rand.js +22 -0
- package/dist/formula/functions/rand.js.map +1 -0
- package/dist/formula/functions/round.js +35 -0
- package/dist/formula/functions/round.js.map +1 -0
- package/dist/formula/functions/rounddown.js +35 -0
- package/dist/formula/functions/rounddown.js.map +1 -0
- package/dist/formula/functions/roundup.js +35 -0
- package/dist/formula/functions/roundup.js.map +1 -0
- package/dist/formula/functions/row.js +31 -0
- package/dist/formula/functions/row.js.map +1 -0
- package/dist/formula/functions/sin.js +29 -0
- package/dist/formula/functions/sin.js.map +1 -0
- package/dist/formula/functions/sqrt.js +32 -0
- package/dist/formula/functions/sqrt.js.map +1 -0
- package/dist/formula/functions/sum.js +47 -0
- package/dist/formula/functions/sum.js.map +1 -0
- package/dist/formula/functions/sumif.js +65 -0
- package/dist/formula/functions/sumif.js.map +1 -0
- package/dist/formula/functions/tan.js +29 -0
- package/dist/formula/functions/tan.js.map +1 -0
- package/dist/formula/functions/uminus.js +24 -0
- package/dist/formula/functions/uminus.js.map +1 -0
- package/dist/formula/functions/vlookup.js +75 -0
- package/dist/formula/functions/vlookup.js.map +1 -0
- package/dist/formula/mapping.js +118 -0
- package/dist/formula/mapping.js.map +1 -0
- package/dist/formula/solver.js +70 -0
- package/dist/formula/solver.js.map +1 -0
- package/dist/index.js +16 -9113
- package/dist/index.js.map +1 -1
- package/dist/lib/autofill.js +391 -0
- package/dist/lib/autofill.js.map +1 -0
- package/dist/lib/clipboard.js +46 -0
- package/dist/lib/clipboard.js.map +1 -0
- package/dist/lib/converters.js +141 -0
- package/dist/lib/converters.js.map +1 -0
- package/dist/lib/input.js +52 -0
- package/dist/lib/input.js.map +1 -0
- package/dist/lib/palette.js +24 -0
- package/dist/lib/palette.js.map +1 -0
- package/dist/lib/prevention.js +82 -0
- package/dist/lib/prevention.js.map +1 -0
- package/dist/lib/structs.js +276 -0
- package/dist/lib/structs.js.map +1 -0
- package/dist/lib/table.js +1248 -0
- package/dist/lib/table.js.map +1 -0
- package/dist/lib/time.js +79 -0
- package/dist/lib/time.js.map +1 -0
- package/dist/lib/virtualization.js +129 -0
- package/dist/lib/virtualization.js.map +1 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js +287 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js.map +1 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js +72 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js.map +1 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js +85 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js +454 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js +42 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js +18 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js.map +1 -0
- package/dist/parsers/core.js +139 -0
- package/dist/parsers/core.js.map +1 -0
- package/dist/renderers/checkbox.js +20 -0
- package/dist/renderers/checkbox.js.map +1 -0
- package/dist/renderers/core.js +147 -0
- package/dist/renderers/core.js.map +1 -0
- package/dist/renderers/thousand_separator.js +17 -0
- package/dist/renderers/thousand_separator.js.map +1 -0
- package/dist/store/actions.js +762 -0
- package/dist/store/actions.js.map +1 -0
- package/dist/store/helpers.js +88 -0
- package/dist/store/helpers.js.map +1 -0
- package/dist/store/index.js +8 -0
- package/dist/store/index.js.map +1 -0
- package/dist/styles/embedder.js +19 -0
- package/dist/styles/embedder.js.map +1 -0
- package/dist/styles/minified.js +7 -0
- package/dist/styles/minified.js.map +1 -0
- package/package.json +1 -7
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { x2c, y2r } from "../lib/converters.js";
|
|
4
|
+
import { clip } from "../lib/clipboard.js";
|
|
5
|
+
import { setEditingCell, setInputting, setLastEdited, setLastFocusedRef, redo, undo, cut, paste, setSearchQuery, setEntering, copy, select, arrow, escape, clear, walk, write } from "../store/actions.js";
|
|
6
|
+
import { Context } from "../store/index.js";
|
|
7
|
+
import { areaToZone } from "../lib/structs.js";
|
|
8
|
+
import { isPrevented, Write } from "../lib/prevention.js";
|
|
9
|
+
import { expandInput, insertTextAtCursor } from "../lib/input.js";
|
|
10
|
+
import { useSheetContext } from "./SheetProvider.js";
|
|
11
|
+
import { Lexer } from "../formula/evaluator.js";
|
|
12
|
+
import { REF_PALETTE } from "../lib/palette.js";
|
|
13
|
+
import { Fixed } from "./Fixed.js";
|
|
14
|
+
const Editor = ({ mode }) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const { store, dispatch } = React__default.useContext(Context);
|
|
17
|
+
const {
|
|
18
|
+
showAddress,
|
|
19
|
+
editorRect,
|
|
20
|
+
editingCell,
|
|
21
|
+
choosing,
|
|
22
|
+
inputting,
|
|
23
|
+
selectingZone,
|
|
24
|
+
searchQuery,
|
|
25
|
+
editorRef,
|
|
26
|
+
largeEditorRef,
|
|
27
|
+
searchInputRef,
|
|
28
|
+
editingOnEnter,
|
|
29
|
+
onSave,
|
|
30
|
+
table,
|
|
31
|
+
sheetId
|
|
32
|
+
} = store;
|
|
33
|
+
const [, sheetContext] = useSheetContext();
|
|
34
|
+
React__default.useEffect(() => {
|
|
35
|
+
var _a2, _b2;
|
|
36
|
+
(_b2 = (_a2 = editorRef == null ? void 0 : editorRef.current) == null ? void 0 : _a2.focus) == null ? void 0 : _b2.call(_a2, { preventScroll: true });
|
|
37
|
+
}, [editorRef]);
|
|
38
|
+
React__default.useEffect(() => {
|
|
39
|
+
if (!(sheetContext == null ? void 0 : sheetContext.lastFocusedRef)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (sheetContext.lastFocusedRef === editorRef) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (sheetContext.lastFocusedRef === largeEditorRef) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
dispatch(setEditingCell(""));
|
|
49
|
+
}, [sheetContext == null ? void 0 : sheetContext.lastFocusedRef]);
|
|
50
|
+
React__default.useEffect(() => {
|
|
51
|
+
var _a2;
|
|
52
|
+
(_a2 = sheetContext == null ? void 0 : sheetContext.setEditingCell) == null ? void 0 : _a2.call(sheetContext, editingCell);
|
|
53
|
+
}, [editingCell]);
|
|
54
|
+
const { y, x } = choosing;
|
|
55
|
+
const rowId = `${y2r(y)}`;
|
|
56
|
+
const colId = x2c(x);
|
|
57
|
+
const address = `${colId}${rowId}`;
|
|
58
|
+
const editing = editingCell === address;
|
|
59
|
+
const cell = table.getByPoint({ y, x });
|
|
60
|
+
const value = cell == null ? void 0 : cell.value;
|
|
61
|
+
const valueString = table.stringify({ y, x }, value);
|
|
62
|
+
const [before, setBefore] = React__default.useState(valueString);
|
|
63
|
+
React__default.useEffect(() => {
|
|
64
|
+
setBefore(valueString);
|
|
65
|
+
}, [choosing]);
|
|
66
|
+
const { y: top, x: left, height, width } = editorRect;
|
|
67
|
+
const writeCell = (value2) => {
|
|
68
|
+
if (before !== value2) {
|
|
69
|
+
dispatch(write(value2));
|
|
70
|
+
}
|
|
71
|
+
setBefore(value2);
|
|
72
|
+
};
|
|
73
|
+
const numLines = valueString.split("\n").length;
|
|
74
|
+
const [isKeyDown, setIsKeyDown] = React__default.useState(false);
|
|
75
|
+
const handleKeyDown = (e) => {
|
|
76
|
+
if (isKeyDown) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!(e.key === "Meta" || e.key === "Control")) {
|
|
80
|
+
setIsKeyDown(true);
|
|
81
|
+
const timeout = window.setTimeout(() => {
|
|
82
|
+
setIsKeyDown(false);
|
|
83
|
+
window.clearTimeout(timeout);
|
|
84
|
+
}, 10);
|
|
85
|
+
}
|
|
86
|
+
const input = e.currentTarget;
|
|
87
|
+
const shiftKey = e.shiftKey;
|
|
88
|
+
switch (e.key) {
|
|
89
|
+
case "Tab":
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
if (editing) {
|
|
92
|
+
writeCell(input.value);
|
|
93
|
+
dispatch(setEditingCell(""));
|
|
94
|
+
dispatch(setInputting(""));
|
|
95
|
+
}
|
|
96
|
+
dispatch(
|
|
97
|
+
walk({
|
|
98
|
+
numRows: table.getNumRows(),
|
|
99
|
+
numCols: table.getNumCols(),
|
|
100
|
+
deltaY: 0,
|
|
101
|
+
deltaX: shiftKey ? -1 : 1
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
dispatch(setEditingCell(""));
|
|
105
|
+
resetSize(e.currentTarget);
|
|
106
|
+
return false;
|
|
107
|
+
case "Enter":
|
|
108
|
+
if (editing) {
|
|
109
|
+
if (e.altKey) {
|
|
110
|
+
insertTextAtCursor(input, "\n");
|
|
111
|
+
dispatch(setInputting(input.value));
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
return false;
|
|
114
|
+
} else {
|
|
115
|
+
if (e.nativeEvent.isComposing) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
writeCell(input.value);
|
|
119
|
+
dispatch(setEditingCell(""));
|
|
120
|
+
}
|
|
121
|
+
resetSize(e.currentTarget);
|
|
122
|
+
} else if (editingOnEnter && selectingZone.endY === -1) {
|
|
123
|
+
const dblclick = document.createEvent("MouseEvents");
|
|
124
|
+
dblclick.initEvent("dblclick", true, true);
|
|
125
|
+
input.dispatchEvent(dblclick);
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
dispatch(
|
|
130
|
+
walk({
|
|
131
|
+
numRows: table.getNumRows(),
|
|
132
|
+
numCols: table.getNumCols(),
|
|
133
|
+
deltaY: shiftKey ? -1 : 1,
|
|
134
|
+
deltaX: 0
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
return false;
|
|
139
|
+
case "Backspace":
|
|
140
|
+
if (!editing) {
|
|
141
|
+
dispatch(clear(null));
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case "Shift":
|
|
146
|
+
return false;
|
|
147
|
+
case "Control":
|
|
148
|
+
return false;
|
|
149
|
+
case "Alt":
|
|
150
|
+
return false;
|
|
151
|
+
case "Meta":
|
|
152
|
+
return false;
|
|
153
|
+
case "NumLock":
|
|
154
|
+
return false;
|
|
155
|
+
case "Escape":
|
|
156
|
+
dispatch(escape(null));
|
|
157
|
+
dispatch(setSearchQuery(void 0));
|
|
158
|
+
return false;
|
|
159
|
+
case "ArrowLeft":
|
|
160
|
+
if (!editing) {
|
|
161
|
+
dispatch(
|
|
162
|
+
arrow({
|
|
163
|
+
shiftKey,
|
|
164
|
+
numRows: table.getNumRows(),
|
|
165
|
+
numCols: table.getNumCols(),
|
|
166
|
+
deltaY: 0,
|
|
167
|
+
deltaX: -1
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
case "ArrowUp":
|
|
174
|
+
if (!editing) {
|
|
175
|
+
dispatch(
|
|
176
|
+
arrow({
|
|
177
|
+
shiftKey,
|
|
178
|
+
numRows: table.getNumRows(),
|
|
179
|
+
numCols: table.getNumCols(),
|
|
180
|
+
deltaY: -1,
|
|
181
|
+
deltaX: 0
|
|
182
|
+
})
|
|
183
|
+
);
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case "ArrowRight":
|
|
188
|
+
if (!editing) {
|
|
189
|
+
dispatch(
|
|
190
|
+
arrow({
|
|
191
|
+
shiftKey,
|
|
192
|
+
numRows: table.getNumRows(),
|
|
193
|
+
numCols: table.getNumCols(),
|
|
194
|
+
deltaY: 0,
|
|
195
|
+
deltaX: 1
|
|
196
|
+
})
|
|
197
|
+
);
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
case "ArrowDown":
|
|
202
|
+
if (!editing) {
|
|
203
|
+
dispatch(
|
|
204
|
+
arrow({
|
|
205
|
+
shiftKey,
|
|
206
|
+
numRows: table.getNumRows(),
|
|
207
|
+
numCols: table.getNumCols(),
|
|
208
|
+
deltaY: 1,
|
|
209
|
+
deltaX: 0
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case "a":
|
|
216
|
+
if (e.ctrlKey || e.metaKey) {
|
|
217
|
+
if (!editing) {
|
|
218
|
+
e.preventDefault();
|
|
219
|
+
dispatch(
|
|
220
|
+
select({
|
|
221
|
+
startY: 1,
|
|
222
|
+
startX: 1,
|
|
223
|
+
endY: table.getNumRows(),
|
|
224
|
+
endX: table.getNumCols()
|
|
225
|
+
})
|
|
226
|
+
);
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
case "c":
|
|
232
|
+
if (e.ctrlKey || e.metaKey) {
|
|
233
|
+
if (!editing) {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
const area = clip(store);
|
|
236
|
+
dispatch(copy(areaToZone(area)));
|
|
237
|
+
input.focus();
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
case "f":
|
|
243
|
+
if (e.ctrlKey || e.metaKey) {
|
|
244
|
+
if (!editing) {
|
|
245
|
+
e.preventDefault();
|
|
246
|
+
if (typeof searchQuery === "undefined") {
|
|
247
|
+
dispatch(setSearchQuery(""));
|
|
248
|
+
}
|
|
249
|
+
dispatch(setEntering(false));
|
|
250
|
+
window.setTimeout(() => searchInputRef.current.focus(), 100);
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
case "r":
|
|
256
|
+
if (e.ctrlKey || e.metaKey) {
|
|
257
|
+
if (!editing) {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
dispatch(redo(null));
|
|
260
|
+
window.setTimeout(() => dispatch(setInputting("")), 100);
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
case "s":
|
|
266
|
+
if (e.ctrlKey || e.metaKey) {
|
|
267
|
+
if (!editing) {
|
|
268
|
+
e.preventDefault();
|
|
269
|
+
onSave && onSave(table, {
|
|
270
|
+
pointing: choosing,
|
|
271
|
+
selectingFrom: {
|
|
272
|
+
y: selectingZone.startY,
|
|
273
|
+
x: selectingZone.startX
|
|
274
|
+
},
|
|
275
|
+
selectingTo: {
|
|
276
|
+
y: selectingZone.endY,
|
|
277
|
+
x: selectingZone.endX
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
case "v":
|
|
285
|
+
if (e.ctrlKey || e.metaKey) {
|
|
286
|
+
if (!editing) {
|
|
287
|
+
window.setTimeout(() => {
|
|
288
|
+
dispatch(paste({ text: input.value }));
|
|
289
|
+
dispatch(setInputting(""));
|
|
290
|
+
}, 50);
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
case "x":
|
|
296
|
+
if (e.ctrlKey || e.metaKey) {
|
|
297
|
+
if (!editing) {
|
|
298
|
+
e.preventDefault();
|
|
299
|
+
const area = clip(store);
|
|
300
|
+
dispatch(cut(areaToZone(area)));
|
|
301
|
+
input.focus();
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
break;
|
|
306
|
+
case "z":
|
|
307
|
+
if (e.ctrlKey || e.metaKey) {
|
|
308
|
+
if (!editing) {
|
|
309
|
+
e.preventDefault();
|
|
310
|
+
if (e.shiftKey) {
|
|
311
|
+
dispatch(redo(null));
|
|
312
|
+
} else {
|
|
313
|
+
dispatch(undo(null));
|
|
314
|
+
}
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
case ";":
|
|
320
|
+
if (e.ctrlKey || e.metaKey) {
|
|
321
|
+
if (!editing) {
|
|
322
|
+
e.preventDefault();
|
|
323
|
+
writeCell((/* @__PURE__ */ new Date()).toDateString());
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
if (e.ctrlKey || e.metaKey) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
if (isPrevented(cell == null ? void 0 : cell.prevention, Write)) {
|
|
332
|
+
console.warn("This cell is protected from writing.");
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
dispatch(setEditingCell(address));
|
|
336
|
+
if (!editing) {
|
|
337
|
+
dispatch(setInputting(""));
|
|
338
|
+
}
|
|
339
|
+
return false;
|
|
340
|
+
};
|
|
341
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
342
|
+
Fixed,
|
|
343
|
+
{
|
|
344
|
+
className: `gs-editor ${editing ? "gs-editing" : ""}`,
|
|
345
|
+
style: editing ? { top, left, height } : {},
|
|
346
|
+
...{
|
|
347
|
+
"data-mode": mode,
|
|
348
|
+
"data-sheet-id": sheetId
|
|
349
|
+
},
|
|
350
|
+
children: [
|
|
351
|
+
showAddress && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "gs-cell-label", children: address }),
|
|
352
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "gs-editor-inner", style: { width }, children: [
|
|
353
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
354
|
+
"pre",
|
|
355
|
+
{
|
|
356
|
+
className: "gs-editor-hl",
|
|
357
|
+
style: {
|
|
358
|
+
//...cell?.style,
|
|
359
|
+
height: (_a = editorRef.current) == null ? void 0 : _a.scrollHeight,
|
|
360
|
+
width: (((_b = editorRef.current) == null ? void 0 : _b.scrollWidth) ?? 0) - 4
|
|
361
|
+
},
|
|
362
|
+
children: editorStyle(inputting)
|
|
363
|
+
}
|
|
364
|
+
),
|
|
365
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
366
|
+
"textarea",
|
|
367
|
+
{
|
|
368
|
+
autoFocus: true,
|
|
369
|
+
spellCheck: false,
|
|
370
|
+
draggable: false,
|
|
371
|
+
ref: editorRef,
|
|
372
|
+
rows: numLines,
|
|
373
|
+
onFocus: () => {
|
|
374
|
+
var _a2;
|
|
375
|
+
dispatch(setLastFocusedRef(editorRef));
|
|
376
|
+
(_a2 = sheetContext == null ? void 0 : sheetContext.setLastFocusedRef) == null ? void 0 : _a2.call(sheetContext, editorRef);
|
|
377
|
+
},
|
|
378
|
+
style: { minWidth: width, minHeight: height },
|
|
379
|
+
onDoubleClick: (e) => {
|
|
380
|
+
if (isPrevented(cell == null ? void 0 : cell.prevention, Write)) {
|
|
381
|
+
console.warn("This cell is protected from writing.");
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const input = e.currentTarget;
|
|
385
|
+
resetSize(input);
|
|
386
|
+
if (!editing) {
|
|
387
|
+
dispatch(setInputting(valueString));
|
|
388
|
+
dispatch(setEditingCell(address));
|
|
389
|
+
window.setTimeout(() => {
|
|
390
|
+
input.style.width = `${input.scrollWidth}px`;
|
|
391
|
+
input.style.height = `${input.scrollHeight}px`;
|
|
392
|
+
const length = new String(valueString).length;
|
|
393
|
+
input.setSelectionRange(length, length);
|
|
394
|
+
}, 20);
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
onBlur: (e) => {
|
|
398
|
+
dispatch(setLastEdited(before));
|
|
399
|
+
if (e.target.value.startsWith("=")) {
|
|
400
|
+
return true;
|
|
401
|
+
} else {
|
|
402
|
+
if (editing) {
|
|
403
|
+
writeCell(e.target.value);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
resetSize(e.target);
|
|
407
|
+
},
|
|
408
|
+
value: inputting,
|
|
409
|
+
onChange: (e) => {
|
|
410
|
+
const input = e.currentTarget;
|
|
411
|
+
expandInput(input);
|
|
412
|
+
dispatch(setInputting(e.currentTarget.value));
|
|
413
|
+
},
|
|
414
|
+
onKeyDown: handleKeyDown
|
|
415
|
+
}
|
|
416
|
+
)
|
|
417
|
+
] })
|
|
418
|
+
]
|
|
419
|
+
}
|
|
420
|
+
);
|
|
421
|
+
};
|
|
422
|
+
const editorStyle = (text) => {
|
|
423
|
+
if (text[0] !== "=") {
|
|
424
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: text });
|
|
425
|
+
}
|
|
426
|
+
const lexer = new Lexer(text.substring(1));
|
|
427
|
+
lexer.tokenize();
|
|
428
|
+
let palletIndex = 0;
|
|
429
|
+
const exists = {};
|
|
430
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
431
|
+
"=",
|
|
432
|
+
lexer.tokens.map((token, i) => {
|
|
433
|
+
if (token.type === "REF" || token.type === "RANGE") {
|
|
434
|
+
const normalizedToken = token.stringify();
|
|
435
|
+
const existsIndex = exists[normalizedToken];
|
|
436
|
+
if (existsIndex !== void 0) {
|
|
437
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: REF_PALETTE[existsIndex % REF_PALETTE.length] }, children: token.stringify() }, i);
|
|
438
|
+
}
|
|
439
|
+
const color = REF_PALETTE[palletIndex % REF_PALETTE.length];
|
|
440
|
+
exists[normalizedToken] = palletIndex++;
|
|
441
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color }, className: `gs-token-type-${token.type}`, children: normalizedToken }, i);
|
|
442
|
+
}
|
|
443
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `gs-token-type-${token.type} gs-token-entity-type-${typeof token.entity}`, children: token.stringify() }, i);
|
|
444
|
+
})
|
|
445
|
+
] });
|
|
446
|
+
};
|
|
447
|
+
const resetSize = (input) => {
|
|
448
|
+
input.style.width = "0px";
|
|
449
|
+
input.style.height = "0px";
|
|
450
|
+
};
|
|
451
|
+
export {
|
|
452
|
+
Editor,
|
|
453
|
+
editorStyle
|
|
454
|
+
};
|
|
455
|
+
//# sourceMappingURL=Editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Editor.js","sources":["../../components/Editor.tsx"],"sourcesContent":["import React from 'react';\nimport { x2c, y2r } from '../lib/converters';\nimport { clip } from '../lib/clipboard';\nimport {\n clear,\n escape,\n select,\n setEditingCell,\n undo,\n redo,\n arrow,\n walk,\n write,\n copy,\n cut,\n paste,\n setSearchQuery,\n setEntering,\n setLastEdited,\n setLastFocusedRef,\n setInputting,\n} from '../store/actions';\n\nimport { Context } from '../store';\nimport { areaToZone } from '../lib/structs';\nimport * as prevention from '../lib/prevention';\nimport { expandInput, insertTextAtCursor } from '../lib/input';\nimport { useSheetContext } from './SheetProvider';\nimport { Lexer } from '../formula/evaluator';\nimport { REF_PALETTE } from '../lib/palette';\nimport { ModeType } from '../types';\nimport { Fixed } from './Fixed';\n\ntype Props = {\n mode: ModeType;\n};\n\nexport const Editor: React.FC<Props> = ({ mode }: Props) => {\n const { store, dispatch } = React.useContext(Context);\n const {\n showAddress,\n editorRect,\n editingCell,\n choosing,\n inputting,\n selectingZone,\n searchQuery,\n editorRef,\n largeEditorRef,\n searchInputRef,\n editingOnEnter,\n onSave,\n table,\n sheetId,\n } = store;\n\n const [, sheetContext] = useSheetContext();\n React.useEffect(() => {\n editorRef?.current?.focus?.({ preventScroll: true });\n }, [editorRef]);\n\n React.useEffect(() => {\n if (!sheetContext?.lastFocusedRef) {\n return;\n }\n if (sheetContext.lastFocusedRef === editorRef) {\n return;\n }\n if (sheetContext.lastFocusedRef === largeEditorRef) {\n return;\n }\n dispatch(setEditingCell(''));\n }, [sheetContext?.lastFocusedRef]);\n React.useEffect(() => {\n sheetContext?.setEditingCell?.(editingCell);\n }, [editingCell]);\n\n const { y, x } = choosing;\n const rowId = `${y2r(y)}`;\n const colId = x2c(x);\n const address = `${colId}${rowId}`;\n const editing = editingCell === address;\n\n const cell = table.getByPoint({ y, x });\n const value: any = cell?.value;\n const valueString = table.stringify({ y, x }, value);\n const [before, setBefore] = React.useState<string>(valueString);\n React.useEffect(() => {\n setBefore(valueString);\n }, [choosing]);\n\n const { y: top, x: left, height, width } = editorRect;\n\n const writeCell = (value: string) => {\n if (before !== value) {\n dispatch(write(value));\n }\n setBefore(value);\n };\n\n const numLines = valueString.split('\\n').length;\n const [isKeyDown, setIsKeyDown] = React.useState(false);\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (isKeyDown) {\n return;\n }\n // do not debounce it if control key is down.\n if (!(e.key === 'Meta' || e.key === 'Control')) {\n setIsKeyDown(true);\n const timeout = window.setTimeout(() => {\n setIsKeyDown(false);\n window.clearTimeout(timeout);\n }, 10);\n }\n const input = e.currentTarget;\n\n const shiftKey = e.shiftKey;\n switch (e.key) {\n case 'Tab': // TAB\n e.preventDefault();\n if (editing) {\n writeCell(input.value);\n dispatch(setEditingCell(''));\n dispatch(setInputting(''));\n }\n dispatch(\n walk({\n numRows: table.getNumRows(),\n numCols: table.getNumCols(),\n deltaY: 0,\n deltaX: shiftKey ? -1 : 1,\n }),\n );\n dispatch(setEditingCell(''));\n resetSize(e.currentTarget);\n return false;\n\n case 'Enter': // ENTER\n if (editing) {\n if (e.altKey) {\n insertTextAtCursor(input, '\\n');\n dispatch(setInputting(input.value));\n e.preventDefault();\n return false;\n } else {\n if (e.nativeEvent.isComposing) {\n return false;\n }\n writeCell(input.value);\n dispatch(setEditingCell(''));\n }\n resetSize(e.currentTarget);\n } else if (editingOnEnter && selectingZone.endY === -1) {\n const dblclick = document.createEvent('MouseEvents');\n dblclick.initEvent('dblclick', true, true);\n input.dispatchEvent(dblclick);\n e.preventDefault();\n return false;\n }\n dispatch(\n walk({\n numRows: table.getNumRows(),\n numCols: table.getNumCols(),\n deltaY: shiftKey ? -1 : 1,\n deltaX: 0,\n }),\n );\n e.preventDefault();\n return false;\n\n case 'Backspace': // BACKSPACE\n if (!editing) {\n dispatch(clear(null));\n return false;\n }\n break;\n case 'Shift': // SHIFT\n return false;\n\n case 'Control': // CTRL\n return false;\n\n case 'Alt': // OPTION\n return false;\n\n case 'Meta': // COMMAND\n return false;\n\n case 'NumLock': // NUMLOCK\n return false;\n\n case 'Escape': // ESCAPE\n dispatch(escape(null));\n dispatch(setSearchQuery(undefined));\n // input.blur();\n return false;\n\n case 'ArrowLeft': // LEFT\n if (!editing) {\n dispatch(\n arrow({\n shiftKey,\n numRows: table.getNumRows(),\n numCols: table.getNumCols(),\n deltaY: 0,\n deltaX: -1,\n }),\n );\n return false;\n }\n break;\n case 'ArrowUp': // UP\n if (!editing) {\n dispatch(\n arrow({\n shiftKey,\n numRows: table.getNumRows(),\n numCols: table.getNumCols(),\n deltaY: -1,\n deltaX: 0,\n }),\n );\n return false;\n }\n break;\n case 'ArrowRight': // RIGHT\n if (!editing) {\n dispatch(\n arrow({\n shiftKey,\n numRows: table.getNumRows(),\n numCols: table.getNumCols(),\n deltaY: 0,\n deltaX: 1,\n }),\n );\n return false;\n }\n break;\n case 'ArrowDown': // DOWN\n if (!editing) {\n dispatch(\n arrow({\n shiftKey,\n numRows: table.getNumRows(),\n numCols: table.getNumCols(),\n deltaY: 1,\n deltaX: 0,\n }),\n );\n return false;\n }\n break;\n case 'a': // A\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n dispatch(\n select({\n startY: 1,\n startX: 1,\n endY: table.getNumRows(),\n endX: table.getNumCols(),\n }),\n );\n return false;\n }\n }\n break;\n case 'c': // C\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n const area = clip(store);\n dispatch(copy(areaToZone(area)));\n input.focus(); // refocus\n return false;\n }\n }\n break;\n case 'f': // F\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n if (typeof searchQuery === 'undefined') {\n dispatch(setSearchQuery(''));\n }\n dispatch(setEntering(false));\n window.setTimeout(() => searchInputRef.current!.focus(), 100);\n return false;\n }\n }\n break;\n case 'r': // R\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n dispatch(redo(null));\n window.setTimeout(() => dispatch(setInputting('')), 100); // resetting textarea\n return false;\n }\n }\n break;\n case 's': // S\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n onSave &&\n onSave(table, {\n pointing: choosing,\n selectingFrom: {\n y: selectingZone.startY,\n x: selectingZone.startX,\n },\n selectingTo: {\n y: selectingZone.endY,\n x: selectingZone.endX,\n },\n });\n return false;\n }\n }\n break;\n case 'v': // V\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n window.setTimeout(() => {\n dispatch(paste({ text: input.value }));\n dispatch(setInputting(''));\n }, 50);\n return false;\n }\n }\n break;\n case 'x': // X\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n const area = clip(store);\n dispatch(cut(areaToZone(area)));\n input.focus(); // refocus\n\n return false;\n }\n }\n break;\n case 'z': // Z\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n if (e.shiftKey) {\n dispatch(redo(null));\n //window.setTimeout(() => dispatch(setInputting('')), 100); // resetting textarea\n } else {\n dispatch(undo(null));\n }\n return false;\n }\n }\n break;\n case ';': // semicolon\n if (e.ctrlKey || e.metaKey) {\n if (!editing) {\n e.preventDefault();\n // MAYBE: need to aware timezone.\n writeCell(new Date().toDateString());\n }\n }\n break;\n }\n if (e.ctrlKey || e.metaKey) {\n return false;\n }\n if (prevention.isPrevented(cell?.prevention, prevention.Write)) {\n console.warn('This cell is protected from writing.');\n return false;\n }\n dispatch(setEditingCell(address));\n if (!editing) {\n dispatch(setInputting(''));\n }\n return false;\n };\n\n return (\n <Fixed\n className={`gs-editor ${editing ? 'gs-editing' : ''}`}\n style={editing ? { top, left, height } : {}}\n {...{\n 'data-mode': mode,\n 'data-sheet-id': sheetId,\n }}\n >\n {showAddress && <div className=\"gs-cell-label\">{address}</div>}\n <div className=\"gs-editor-inner\" style={{ width }}>\n <pre\n className=\"gs-editor-hl\"\n style={{\n //...cell?.style,\n height: editorRef.current?.scrollHeight,\n width: (editorRef.current?.scrollWidth ?? 0) - 4,\n }}\n >\n {editorStyle(inputting)}\n </pre>\n <textarea\n autoFocus={true}\n spellCheck={false}\n draggable={false}\n ref={editorRef}\n rows={numLines}\n onFocus={() => {\n dispatch(setLastFocusedRef(editorRef));\n sheetContext?.setLastFocusedRef?.(editorRef);\n }}\n style={{ minWidth: width, minHeight: height }}\n onDoubleClick={(e) => {\n if (prevention.isPrevented(cell?.prevention, prevention.Write)) {\n console.warn('This cell is protected from writing.');\n return;\n }\n const input = e.currentTarget;\n resetSize(input);\n if (!editing) {\n dispatch(setInputting(valueString));\n dispatch(setEditingCell(address));\n window.setTimeout(() => {\n input.style.width = `${input.scrollWidth}px`;\n input.style.height = `${input.scrollHeight}px`;\n const length = new String(valueString).length;\n input.setSelectionRange(length, length);\n }, 20);\n }\n }}\n onBlur={(e) => {\n dispatch(setLastEdited(before));\n if (e.target.value.startsWith('=')) {\n return true;\n } else {\n if (editing) {\n writeCell(e.target.value);\n }\n }\n resetSize(e.target);\n }}\n value={inputting}\n onChange={(e) => {\n const input = e.currentTarget;\n expandInput(input);\n dispatch(setInputting(e.currentTarget.value));\n }}\n onKeyDown={handleKeyDown}\n />\n </div>\n </Fixed>\n );\n};\n\nexport const editorStyle = (text: string) => {\n if (text[0] !== '=') {\n return <>{text}</>;\n }\n const lexer = new Lexer(text.substring(1));\n lexer.tokenize();\n let palletIndex = 0;\n const exists: { [ref: string]: number } = {};\n return (\n <>\n =\n {lexer.tokens.map((token, i) => {\n if (token.type === 'REF' || token.type === 'RANGE') {\n const normalizedToken = token.stringify();\n const existsIndex = exists[normalizedToken];\n if (existsIndex !== undefined) {\n return (\n <span key={i} style={{ color: REF_PALETTE[existsIndex % REF_PALETTE.length] }}>\n {token.stringify()}\n </span>\n );\n }\n const color = REF_PALETTE[palletIndex % REF_PALETTE.length];\n exists[normalizedToken] = palletIndex++;\n return (\n <span key={i} style={{ color }} className={`gs-token-type-${token.type}`}>\n {normalizedToken}\n </span>\n );\n }\n\n return (\n <span key={i} className={`gs-token-type-${token.type} gs-token-entity-type-${typeof token.entity}`}>\n {token.stringify()}\n </span>\n );\n })}\n </>\n );\n};\n\nconst resetSize = (input: HTMLTextAreaElement) => {\n input.style.width = '0px';\n input.style.height = '0px';\n};\n"],"names":["React","_b","_a","value","prevention.isPrevented","prevention.Write","jsxs","jsx","Fragment"],"mappings":";;;;;;;;;;;;;AAqCO,MAAM,SAA0B,CAAC,EAAE,WAAkB;;AAC1D,QAAM,EAAE,OAAO,SAAA,IAAaA,eAAM,WAAW,OAAO;AAC9C,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAEJ,QAAM,CAAG,EAAA,YAAY,IAAI,gBAAgB;AACzCA,iBAAM,UAAU,MAAM;;AACpB,KAAAC,OAAAC,MAAA,uCAAW,YAAX,gBAAAA,IAAoB,UAApB,gBAAAD,IAAA,KAAAC,KAA4B,EAAE,eAAe;EAAM,GAClD,CAAC,SAAS,CAAC;AAEdF,iBAAM,UAAU,MAAM;AAChB,QAAA,EAAC,6CAAc,iBAAgB;AACjC;AAAA,IAAA;AAEE,QAAA,aAAa,mBAAmB,WAAW;AAC7C;AAAA,IAAA;AAEE,QAAA,aAAa,mBAAmB,gBAAgB;AAClD;AAAA,IAAA;AAEO,aAAA,eAAe,EAAE,CAAC;AAAA,EAAA,GAC1B,CAAC,6CAAc,cAAc,CAAC;AACjCA,iBAAM,UAAU,MAAM;;AACpB,KAAAE,MAAA,6CAAc,mBAAd,gBAAAA,IAAA,mBAA+B;AAAA,EAAW,GACzC,CAAC,WAAW,CAAC;AAEV,QAAA,EAAE,GAAG,EAAA,IAAM;AACjB,QAAM,QAAQ,GAAG,IAAI,CAAC,CAAC;AACjB,QAAA,QAAQ,IAAI,CAAC;AACnB,QAAM,UAAU,GAAG,KAAK,GAAG,KAAK;AAChC,QAAM,UAAU,gBAAgB;AAEhC,QAAM,OAAO,MAAM,WAAW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,CAEX;AAAA,IAEH,CAAA;AAAA,EAAA,GACH;AAEJ;AAEA,MAAM,YAAY,CAAC,UAA+B;AAChD,QAAM,MAAM,QAAQ;AACpB,QAAM,MAAM,SAAS;AACvB;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { Context } from "../store/index.js";
|
|
4
|
+
const Emitter = ({ onChange, onSelect }) => {
|
|
5
|
+
const { store } = React__default.useContext(Context);
|
|
6
|
+
const { choosing: pointing, selectingZone: zone, table, tableInitialized } = store;
|
|
7
|
+
React__default.useEffect(() => {
|
|
8
|
+
tableInitialized && table && onChange && onChange(table, {
|
|
9
|
+
pointing,
|
|
10
|
+
selectingFrom: { y: zone.startY, x: zone.startX },
|
|
11
|
+
selectingTo: { y: zone.endY, x: zone.endX }
|
|
12
|
+
});
|
|
13
|
+
}, [table]);
|
|
14
|
+
React__default.useEffect(() => {
|
|
15
|
+
onSelect && onSelect(table, {
|
|
16
|
+
pointing,
|
|
17
|
+
selectingFrom: { y: zone.startY, x: zone.startX },
|
|
18
|
+
selectingTo: { y: zone.endY, x: zone.endX }
|
|
19
|
+
});
|
|
20
|
+
}, [pointing, zone]);
|
|
21
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
Emitter
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=Emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Emitter.js","sources":["../../components/Emitter.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Context } from '../store';\nimport { FeedbackType } from '../types';\n\ntype Props = {\n onChange?: FeedbackType;\n onSelect?: FeedbackType;\n};\n\nexport const Emitter: React.FC<Props> = ({ onChange, onSelect }) => {\n const { store } = React.useContext(Context);\n const { choosing: pointing, selectingZone: zone, table, tableInitialized } = store;\n\n React.useEffect(() => {\n tableInitialized &&\n table &&\n onChange &&\n onChange(table, {\n pointing,\n selectingFrom: { y: zone.startY, x: zone.startX },\n selectingTo: { y: zone.endY, x: zone.endX },\n });\n }, [table]);\n\n React.useEffect(() => {\n onSelect &&\n onSelect(table, {\n pointing,\n selectingFrom: { y: zone.startY, x: zone.startX },\n selectingTo: { y: zone.endY, x: zone.endX },\n });\n }, [pointing, zone]);\n return <></>;\n};\n"],"names":["React","jsx","Fragment"],"mappings":";;;AAUO,MAAM,UAA2B,CAAC,EAAE,UAAU,eAAe;AAClE,QAAM,EAAE,MAAU,IAAAA,eAAM,WAAW,OAAO;AAC1C,QAAM,EAAE,UAAU,UAAU,eAAe,MAAM,OAAO,qBAAqB;AAE7EA,iBAAM,UAAU,MAAM;AAElB,wBAAA,SACA,YACA,SAAS,OAAO;AAAA,MACd;AAAA,MACA,eAAe,EAAE,GAAG,KAAK,QAAQ,GAAG,KAAK,OAAO;AAAA,MAChD,aAAa,EAAE,GAAG,KAAK,MAAM,GAAG,KAAK,KAAK;AAAA,IAAA,CAC3C;AAAA,EAAA,GACF,CAAC,KAAK,CAAC;AAEVA,iBAAM,UAAU,MAAM;AACpB,gBACE,SAAS,OAAO;AAAA,MACd;AAAA,MACA,eAAe,EAAE,GAAG,KAAK,QAAQ,GAAG,KAAK,OAAO;AAAA,MAChD,aAAa,EAAE,GAAG,KAAK,MAAM,GAAG,KAAK,KAAK;AAAA,IAAA,CAC3C;AAAA,EAAA,GACF,CAAC,UAAU,IAAI,CAAC;AACnB,SAASC,kCAAA,IAAAC,kBAAA,UAAA,EAAA;AACX;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { useBrowser } from "./hooks.js";
|
|
4
|
+
const Fixed = ({ children, style, className = "", ...attrs }) => {
|
|
5
|
+
const { document } = useBrowser();
|
|
6
|
+
if (document == null) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return createPortal(
|
|
10
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { ...attrs, className: `gs-fixed ${className}`, style, children }),
|
|
11
|
+
document.body
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
Fixed
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=Fixed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fixed.js","sources":["../../components/Fixed.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useBrowser } from './hooks';\n\ntype Props = {\n className?: string;\n style?: CSSProperties;\n children: React.ReactNode;\n [attr: string]: any;\n};\n\nexport const Fixed: React.FC<Props> = ({ children, style, className = '', ...attrs }) => {\n const { document } = useBrowser();\n if (document == null) {\n return null;\n }\n return createPortal(\n <div {...attrs} className={`gs-fixed ${className}`} style={style}>\n {children}\n </div>,\n document.body,\n );\n};\n"],"names":["jsx"],"mappings":";;;AAWa,MAAA,QAAyB,CAAC,EAAE,UAAU,OAAO,YAAY,IAAI,GAAG,YAAY;AACjF,QAAA,EAAE,SAAS,IAAI,WAAW;AAChC,MAAI,YAAY,MAAM;AACb,WAAA;AAAA,EAAA;AAEF,SAAA;AAAA,IACLA,kCAAAA,IAAC,SAAK,GAAG,OAAO,WAAW,YAAY,SAAS,IAAI,OACjD,SACH,CAAA;AAAA,IACA,SAAS;AAAA,EACX;AACF;"}
|