@gridsheet/react-core 1.4.0-alpha.2 → 1.4.0-alpha.4
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/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/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,149 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { Context } from "../store/index.js";
|
|
4
|
+
import { p2a } from "../lib/converters.js";
|
|
5
|
+
import { setEditingCell, setInputting, walk, setLastEdited, setLastFocusedRef, write } from "../store/actions.js";
|
|
6
|
+
import { isPrevented, Write } from "../lib/prevention.js";
|
|
7
|
+
import { insertTextAtCursor } from "../lib/input.js";
|
|
8
|
+
import { useSheetContext } from "./SheetProvider.js";
|
|
9
|
+
import { editorStyle } from "./Editor.js";
|
|
10
|
+
const FormulaBar = () => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const { store, dispatch } = React__default.useContext(Context);
|
|
13
|
+
const [before, setBefore] = React__default.useState("");
|
|
14
|
+
const { choosing, editorRef, largeEditorRef, table, inputting, editingCell } = store;
|
|
15
|
+
const [, sheetContext] = useSheetContext();
|
|
16
|
+
const hlRef = React__default.useRef(null);
|
|
17
|
+
const address = choosing.x === -1 ? "" : p2a(choosing);
|
|
18
|
+
React__default.useEffect(() => {
|
|
19
|
+
var _a2;
|
|
20
|
+
let value = ((_a2 = table.getByPoint(choosing)) == null ? void 0 : _a2.value) ?? "";
|
|
21
|
+
value = table.stringify(choosing, value);
|
|
22
|
+
largeEditorRef.current.value = value;
|
|
23
|
+
setBefore(value);
|
|
24
|
+
}, [address, table]);
|
|
25
|
+
const writeCell = (value) => {
|
|
26
|
+
if (before !== value) {
|
|
27
|
+
dispatch(write(value));
|
|
28
|
+
}
|
|
29
|
+
dispatch(setEditingCell(""));
|
|
30
|
+
editorRef.current.focus();
|
|
31
|
+
};
|
|
32
|
+
React__default.useEffect(() => {
|
|
33
|
+
const observer = new ResizeObserver((entries) => {
|
|
34
|
+
entries.forEach(updateScroll);
|
|
35
|
+
});
|
|
36
|
+
if (largeEditorRef.current) {
|
|
37
|
+
observer.observe(largeEditorRef.current);
|
|
38
|
+
}
|
|
39
|
+
return () => {
|
|
40
|
+
observer.disconnect();
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
const largeInput = largeEditorRef.current;
|
|
44
|
+
const handleFocus = () => {
|
|
45
|
+
var _a2;
|
|
46
|
+
if (!largeInput) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
dispatch(setEditingCell(address));
|
|
50
|
+
dispatch(setLastFocusedRef(largeEditorRef));
|
|
51
|
+
(_a2 = sheetContext == null ? void 0 : sheetContext.setLastFocusedRef) == null ? void 0 : _a2.call(sheetContext, largeEditorRef);
|
|
52
|
+
};
|
|
53
|
+
const handleInput = (e) => {
|
|
54
|
+
var _a2;
|
|
55
|
+
dispatch(setInputting(e.currentTarget.value));
|
|
56
|
+
(_a2 = sheetContext == null ? void 0 : sheetContext.forceRender) == null ? void 0 : _a2.call(sheetContext);
|
|
57
|
+
};
|
|
58
|
+
const updateScroll = () => {
|
|
59
|
+
if (!hlRef.current || !largeEditorRef.current) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
hlRef.current.style.height = `${largeEditorRef.current.clientHeight}px`;
|
|
63
|
+
hlRef.current.scrollLeft = largeEditorRef.current.scrollLeft;
|
|
64
|
+
hlRef.current.scrollTop = largeEditorRef.current.scrollTop;
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsxs("label", { className: "gs-formula-bar", children: [
|
|
67
|
+
/* @__PURE__ */ jsx("div", { className: "gs-selecting-address", children: address }),
|
|
68
|
+
/* @__PURE__ */ jsx("div", { className: "gs-fx", children: "Fx" }),
|
|
69
|
+
/* @__PURE__ */ jsxs("div", { className: "gs-formula-bar-editor-inner", children: [
|
|
70
|
+
/* @__PURE__ */ jsx(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
className: "gs-editor-hl",
|
|
74
|
+
ref: hlRef,
|
|
75
|
+
style: {
|
|
76
|
+
height: (_a = largeEditorRef.current) == null ? void 0 : _a.clientHeight,
|
|
77
|
+
width: (_b = largeEditorRef.current) == null ? void 0 : _b.clientWidth
|
|
78
|
+
},
|
|
79
|
+
children: editorStyle(inputting)
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
"textarea",
|
|
84
|
+
{
|
|
85
|
+
rows: 1,
|
|
86
|
+
spellCheck: false,
|
|
87
|
+
ref: largeEditorRef,
|
|
88
|
+
value: inputting,
|
|
89
|
+
onInput: handleInput,
|
|
90
|
+
onFocus: handleFocus,
|
|
91
|
+
onBlur: (e) => {
|
|
92
|
+
dispatch(setLastEdited(before));
|
|
93
|
+
if (e.target.value.startsWith("=")) {
|
|
94
|
+
return true;
|
|
95
|
+
} else {
|
|
96
|
+
if (editingCell) {
|
|
97
|
+
writeCell(e.target.value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
onKeyDown: (e) => {
|
|
102
|
+
const input = e.currentTarget;
|
|
103
|
+
switch (e.key) {
|
|
104
|
+
case "Enter": {
|
|
105
|
+
if (e.altKey) {
|
|
106
|
+
insertTextAtCursor(input, "\n");
|
|
107
|
+
} else {
|
|
108
|
+
writeCell(input.value);
|
|
109
|
+
dispatch(setInputting(""));
|
|
110
|
+
dispatch(
|
|
111
|
+
walk({
|
|
112
|
+
numRows: table.getNumRows(),
|
|
113
|
+
numCols: table.getNumCols(),
|
|
114
|
+
deltaY: 1,
|
|
115
|
+
deltaX: 0
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "Escape": {
|
|
124
|
+
input.value = before;
|
|
125
|
+
dispatch(setEditingCell(""));
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
editorRef.current.focus();
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const cell = table.getByPoint(choosing);
|
|
132
|
+
if (isPrevented(cell == null ? void 0 : cell.prevention, Write)) {
|
|
133
|
+
console.warn("This cell is protected from writing.");
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
}
|
|
136
|
+
updateScroll();
|
|
137
|
+
return false;
|
|
138
|
+
},
|
|
139
|
+
onKeyUp: updateScroll,
|
|
140
|
+
onScroll: updateScroll
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
] });
|
|
145
|
+
};
|
|
146
|
+
export {
|
|
147
|
+
FormulaBar
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=FormulaBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormulaBar.js","sources":["../../components/FormulaBar.tsx"],"sourcesContent":["import React from 'react';\nimport { Context } from '../store';\nimport { p2a } from '../lib/converters';\nimport { setEditingCell, setInputting, setLastEdited, setLastFocusedRef, walk, write } from '../store/actions';\nimport * as prevention from '../lib/prevention';\nimport { insertTextAtCursor } from '../lib/input';\nimport { useSheetContext } from './SheetProvider';\nimport { editorStyle } from './Editor';\n\nexport const FormulaBar: React.FC = () => {\n const { store, dispatch } = React.useContext(Context);\n const [before, setBefore] = React.useState('');\n const { choosing, editorRef, largeEditorRef, table, inputting, editingCell } = store;\n const [, sheetContext] = useSheetContext();\n const hlRef = React.useRef<HTMLDivElement | null>(null);\n\n const address = choosing.x === -1 ? '' : p2a(choosing);\n React.useEffect(() => {\n let value = table.getByPoint(choosing)?.value ?? '';\n // debug to remove this line\n value = table.stringify(choosing, value);\n largeEditorRef.current!.value = value;\n setBefore(value as string);\n }, [address, table]);\n\n const writeCell = (value: string) => {\n if (before !== value) {\n dispatch(write(value));\n }\n dispatch(setEditingCell(''));\n editorRef.current!.focus();\n };\n React.useEffect(() => {\n const observer = new ResizeObserver((entries) => {\n entries.forEach(updateScroll);\n });\n if (largeEditorRef.current) {\n observer.observe(largeEditorRef.current);\n }\n return () => {\n observer.disconnect();\n };\n }, []);\n\n const largeInput = largeEditorRef.current;\n\n const handleFocus = () => {\n if (!largeInput) {\n return;\n }\n dispatch(setEditingCell(address));\n dispatch(setLastFocusedRef(largeEditorRef));\n sheetContext?.setLastFocusedRef?.(largeEditorRef);\n };\n const handleInput = (e: React.FormEvent<HTMLTextAreaElement>) => {\n dispatch(setInputting(e.currentTarget.value));\n sheetContext?.forceRender?.();\n };\n\n const updateScroll = () => {\n if (!hlRef.current || !largeEditorRef.current) {\n return;\n }\n hlRef.current.style.height = `${largeEditorRef.current.clientHeight}px`;\n hlRef.current.scrollLeft = largeEditorRef.current.scrollLeft;\n hlRef.current.scrollTop = largeEditorRef.current.scrollTop;\n };\n\n return (\n <label className=\"gs-formula-bar\">\n <div className=\"gs-selecting-address\">{address}</div>\n <div className=\"gs-fx\">Fx</div>\n <div className=\"gs-formula-bar-editor-inner\">\n <div\n className=\"gs-editor-hl\"\n ref={hlRef}\n style={{\n height: largeEditorRef.current?.clientHeight,\n width: largeEditorRef.current?.clientWidth,\n }}\n >\n {editorStyle(inputting)}\n </div>\n <textarea\n rows={1}\n spellCheck={false}\n ref={largeEditorRef}\n value={inputting}\n onInput={handleInput}\n onFocus={handleFocus}\n onBlur={(e) => {\n dispatch(setLastEdited(before));\n if (e.target.value.startsWith('=')) {\n return true;\n } else {\n if (editingCell) {\n writeCell(e.target.value);\n }\n }\n }}\n onKeyDown={(e) => {\n const input = e.currentTarget;\n switch (e.key) {\n case 'Enter': {\n if (e.altKey) {\n insertTextAtCursor(input, '\\n');\n } else {\n writeCell(input.value);\n dispatch(setInputting(''));\n dispatch(\n walk({\n numRows: table.getNumRows(),\n numCols: table.getNumCols(),\n deltaY: 1,\n deltaX: 0,\n }),\n );\n e.preventDefault();\n return false;\n }\n break;\n }\n case 'Escape': {\n input.value = before;\n dispatch(setEditingCell(''));\n e.preventDefault();\n editorRef.current!.focus();\n\n break;\n }\n }\n\n const cell = table.getByPoint(choosing);\n if (prevention.isPrevented(cell?.prevention, prevention.Write)) {\n console.warn('This cell is protected from writing.');\n e.preventDefault();\n }\n updateScroll();\n return false;\n }}\n onKeyUp={updateScroll}\n onScroll={updateScroll}\n ></textarea>\n </div>\n </label>\n );\n};\n"],"names":["React","_a","prevention.isPrevented","prevention.Write"],"mappings":";;;;;;;;;AASO,MAAM,aAAuB,MAAM;;AACxC,QAAM,EAAE,OAAO,SAAA,IAAaA,eAAM,WAAW,OAAO;AACpD,QAAM,CAAC,QAAQ,SAAS,IAAIA,eAAM,SAAS,EAAE;AAC7C,QAAM,EAAE,UAAU,WAAW,gBAAgB,OAAO,WAAW,gBAAgB;AAC/E,QAAM,CAAG,EAAA,YAAY,IAAI,gBAAgB;AACnC,QAAA,QAAQA,eAAM,OAA8B,IAAI;AAEtD,QAAM,UAAU,SAAS,MAAM,KAAK,KAAK,IAAI,QAAQ;AACrDA,iBAAM,UAAU,MAAM;;AACpB,QAAI,UAAQC,MAAA,MAAM,WAAW,QAAQ,MAAzB,gBAAAA,IAA4B,UAAS;AAEzC,YAAA,MAAM,UAAU,UAAU,KAAK;AACvC,mBAAe,QAAS,QAAQ;AAChC,cAAU,KAAe;AAAA,EA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AAA,OAAO,MAAM,WAAW,QAAQ;AACtC,gBAAIC,YAAuB,6BAAM,YAAYC,KAAgB,GAAG;AAC9D,sBAAQ,KAAK,sCAAsC;AACnD,gBAAE,eAAe;AAAA,YAAA;AAEN,yBAAA;AACN,mBAAA;AAAA,UACT;AAAA,UACA,SAAS;AAAA,UACT,UAAU;AAAA,QAAA;AAAA,MAAA;AAAA,IACX,EACH,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { HEADER_HEIGHT, HEADER_WIDTH, HISTORY_LIMIT, DEFAULT_HEIGHT, SHEET_HEIGHT, DEFAULT_WIDTH, SHEET_WIDTH } from "../constants.js";
|
|
4
|
+
import { functions } from "../formula/mapping.js";
|
|
5
|
+
import { Context } from "../store/index.js";
|
|
6
|
+
import { reducer } from "../store/actions.js";
|
|
7
|
+
import { Editor } from "./Editor.js";
|
|
8
|
+
import { StoreInitializer } from "./StoreInitializer.js";
|
|
9
|
+
import { Resizer } from "./Resizer.js";
|
|
10
|
+
import { Emitter } from "./Emitter.js";
|
|
11
|
+
import { ContextMenu } from "./ContextMenu.js";
|
|
12
|
+
import { Table } from "../lib/table.js";
|
|
13
|
+
import { Tabular } from "./Tabular.js";
|
|
14
|
+
import { getMaxSizesFromCells } from "../lib/structs.js";
|
|
15
|
+
import { x2c, y2r } from "../lib/converters.js";
|
|
16
|
+
import { embedStyle } from "../styles/embedder.js";
|
|
17
|
+
import { useSheetContext } from "./SheetProvider.js";
|
|
18
|
+
import { FormulaBar } from "./FormulaBar.js";
|
|
19
|
+
import { SearchBar } from "./SearchBar.js";
|
|
20
|
+
function GridSheet({
|
|
21
|
+
initialCells,
|
|
22
|
+
sheetName = "",
|
|
23
|
+
tableRef,
|
|
24
|
+
options = {},
|
|
25
|
+
className,
|
|
26
|
+
style,
|
|
27
|
+
additionalFunctions = {}
|
|
28
|
+
}) {
|
|
29
|
+
const { sheetResize, showFormulaBar = true, onInit, mode = "light" } = options;
|
|
30
|
+
const [prevSheetName, setPrevSheetName] = React.useState(sheetName);
|
|
31
|
+
const rootRef = React.useRef(null);
|
|
32
|
+
const mainRef = React.useRef(null);
|
|
33
|
+
const searchInputRef = React.useRef(null);
|
|
34
|
+
const editorRef = React.useRef(null);
|
|
35
|
+
const largeEditorRef = React.useRef(null);
|
|
36
|
+
const tabularRef = React.useRef(null);
|
|
37
|
+
const lastFocusedRef = React.useRef(null);
|
|
38
|
+
const [sheetProvided, sheetContext] = useSheetContext();
|
|
39
|
+
const [initialState] = React.useState(() => {
|
|
40
|
+
const {
|
|
41
|
+
headerHeight = HEADER_HEIGHT,
|
|
42
|
+
headerWidth = HEADER_WIDTH,
|
|
43
|
+
historyLimit = HISTORY_LIMIT,
|
|
44
|
+
renderers,
|
|
45
|
+
parsers,
|
|
46
|
+
labelers,
|
|
47
|
+
minNumRows,
|
|
48
|
+
maxNumRows,
|
|
49
|
+
minNumCols,
|
|
50
|
+
maxNumCols
|
|
51
|
+
} = options;
|
|
52
|
+
const table = new Table({
|
|
53
|
+
historyLimit,
|
|
54
|
+
parsers,
|
|
55
|
+
renderers,
|
|
56
|
+
labelers,
|
|
57
|
+
minNumRows,
|
|
58
|
+
maxNumRows,
|
|
59
|
+
minNumCols,
|
|
60
|
+
maxNumCols,
|
|
61
|
+
headerHeight,
|
|
62
|
+
headerWidth,
|
|
63
|
+
functions: { ...functions, ...additionalFunctions }
|
|
64
|
+
});
|
|
65
|
+
let sheetId = 0;
|
|
66
|
+
if (sheetProvided) {
|
|
67
|
+
sheetId = sheetContext.head.current++;
|
|
68
|
+
table.tables = sheetContext.tables.current;
|
|
69
|
+
table.sheets = sheetContext.sheets.current;
|
|
70
|
+
}
|
|
71
|
+
table.tables[sheetId] = table;
|
|
72
|
+
table.sheetId = sheetId;
|
|
73
|
+
table.initialize(initialCells);
|
|
74
|
+
onInit == null ? void 0 : onInit(table);
|
|
75
|
+
return {
|
|
76
|
+
sheetId,
|
|
77
|
+
table,
|
|
78
|
+
// temporary (see StoreInitializer for detail)
|
|
79
|
+
tableInitialized: false,
|
|
80
|
+
rootRef,
|
|
81
|
+
mainRef,
|
|
82
|
+
searchInputRef,
|
|
83
|
+
editorRef,
|
|
84
|
+
largeEditorRef,
|
|
85
|
+
tabularRef,
|
|
86
|
+
lastFocusedRef,
|
|
87
|
+
choosing: { y: 1, x: 1 },
|
|
88
|
+
cutting: false,
|
|
89
|
+
inputting: "",
|
|
90
|
+
selectingZone: { startY: -1, startX: -1, endY: -1, endX: -1 },
|
|
91
|
+
copyingZone: { startY: -1, startX: -1, endY: -1, endX: -1 },
|
|
92
|
+
autofillDraggingTo: null,
|
|
93
|
+
leftHeaderSelecting: false,
|
|
94
|
+
topHeaderSelecting: false,
|
|
95
|
+
editingCell: "",
|
|
96
|
+
editorRect: { y: 0, x: 0, height: 0, width: 0 },
|
|
97
|
+
resizingRect: { y: -1, x: -1, height: -1, width: -1 },
|
|
98
|
+
sheetHeight: 0,
|
|
99
|
+
sheetWidth: 0,
|
|
100
|
+
headerHeight: 0,
|
|
101
|
+
headerWidth: 0,
|
|
102
|
+
entering: false,
|
|
103
|
+
matchingCells: [],
|
|
104
|
+
matchingCellIndex: 0,
|
|
105
|
+
searchCaseSensitive: false,
|
|
106
|
+
editingOnEnter: true,
|
|
107
|
+
showAddress: true,
|
|
108
|
+
contextMenuPosition: { y: -1, x: -1 },
|
|
109
|
+
resizingPositionY: [-1, -1, -1],
|
|
110
|
+
resizingPositionX: [-1, -1, -1],
|
|
111
|
+
minNumRows: 1,
|
|
112
|
+
maxNumRows: -1,
|
|
113
|
+
minNumCols: 1,
|
|
114
|
+
maxNumCols: -1,
|
|
115
|
+
mode: "light",
|
|
116
|
+
lastEdited: ""
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
const [store, dispatch] = React.useReducer(
|
|
120
|
+
reducer,
|
|
121
|
+
initialState,
|
|
122
|
+
() => initialState
|
|
123
|
+
);
|
|
124
|
+
React.useEffect(() => {
|
|
125
|
+
embedStyle();
|
|
126
|
+
}, []);
|
|
127
|
+
React.useEffect(() => {
|
|
128
|
+
var _a;
|
|
129
|
+
if (!sheetProvided) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
sheetContext.tables.current[store.sheetId] = store.table;
|
|
133
|
+
(_a = sheetContext == null ? void 0 : sheetContext.forceRender) == null ? void 0 : _a.call(sheetContext);
|
|
134
|
+
}, [store.table]);
|
|
135
|
+
React.useEffect(() => {
|
|
136
|
+
if (!sheetProvided) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (prevSheetName !== sheetName) {
|
|
140
|
+
delete sheetContext.sheets.current[prevSheetName];
|
|
141
|
+
setPrevSheetName(sheetName);
|
|
142
|
+
}
|
|
143
|
+
if (sheetName) {
|
|
144
|
+
sheetContext.sheets.current[sheetName] = store.sheetId;
|
|
145
|
+
}
|
|
146
|
+
store.table.sheetName = sheetName;
|
|
147
|
+
}, [sheetName]);
|
|
148
|
+
const [sheetHeight, setSheetHeight] = React.useState(
|
|
149
|
+
(options == null ? void 0 : options.sheetHeight) || estimateSheetHeight({ options, initialData: initialCells })
|
|
150
|
+
);
|
|
151
|
+
const [sheetWidth, setSheetWidth] = React.useState(
|
|
152
|
+
(options == null ? void 0 : options.sheetWidth) || estimateSheetWidth({ options, initialData: initialCells })
|
|
153
|
+
);
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
const intervalId = window.setInterval(() => {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
setSheetHeight(((_a = mainRef.current) == null ? void 0 : _a.clientHeight) || 0);
|
|
158
|
+
setSheetWidth(((_b = mainRef.current) == null ? void 0 : _b.clientWidth) || 0);
|
|
159
|
+
}, 1e3);
|
|
160
|
+
return () => window.clearInterval(intervalId);
|
|
161
|
+
}, []);
|
|
162
|
+
React.useEffect(() => {
|
|
163
|
+
if (options.sheetHeight) {
|
|
164
|
+
setSheetHeight(options.sheetHeight);
|
|
165
|
+
}
|
|
166
|
+
}, [options.sheetHeight]);
|
|
167
|
+
React.useEffect(() => {
|
|
168
|
+
if (options.sheetWidth) {
|
|
169
|
+
setSheetWidth(options.sheetWidth);
|
|
170
|
+
}
|
|
171
|
+
}, [options.sheetWidth]);
|
|
172
|
+
const { onChange, onSelect } = options;
|
|
173
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: { store, dispatch }, children: /* @__PURE__ */ jsxs(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: `gs-root1`,
|
|
177
|
+
ref: rootRef,
|
|
178
|
+
"data-sheet-name": sheetName,
|
|
179
|
+
"data-mode": mode,
|
|
180
|
+
style: { maxWidth: `min(100%, ${store.table.totalWidth + 2}px)` },
|
|
181
|
+
children: [
|
|
182
|
+
typeof store.searchQuery === "undefined" ? showFormulaBar && /* @__PURE__ */ jsx(FormulaBar, {}) : /* @__PURE__ */ jsx(SearchBar, {}),
|
|
183
|
+
/* @__PURE__ */ jsxs(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: `gs-main ${className || ""}`,
|
|
187
|
+
ref: mainRef,
|
|
188
|
+
style: {
|
|
189
|
+
maxWidth: `min(100%-1px, ${store.table.totalWidth + 2}px)`,
|
|
190
|
+
maxHeight: store.table.totalHeight + 2,
|
|
191
|
+
...style,
|
|
192
|
+
resize: sheetResize
|
|
193
|
+
},
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsx(Editor, { mode }),
|
|
196
|
+
/* @__PURE__ */ jsx(Tabular, { tableRef }),
|
|
197
|
+
/* @__PURE__ */ jsx(
|
|
198
|
+
StoreInitializer,
|
|
199
|
+
{
|
|
200
|
+
initialCells,
|
|
201
|
+
options: { ...options, sheetHeight, sheetWidth },
|
|
202
|
+
additionalFunctions
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ jsx(ContextMenu, {}),
|
|
206
|
+
/* @__PURE__ */ jsx(Resizer, {}),
|
|
207
|
+
/* @__PURE__ */ jsx(Emitter, { onChange, onSelect })
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
) });
|
|
214
|
+
}
|
|
215
|
+
const estimateSheetHeight = ({ initialData, options }) => {
|
|
216
|
+
var _a, _b;
|
|
217
|
+
const auto = getMaxSizesFromCells(initialData);
|
|
218
|
+
let estimatedHeight = options.headerHeight || HEADER_HEIGHT;
|
|
219
|
+
for (let y = 0; y < auto.numRows; y++) {
|
|
220
|
+
const row = y2r(y);
|
|
221
|
+
const height = ((_a = initialData == null ? void 0 : initialData[row]) == null ? void 0 : _a.height) || ((_b = initialData == null ? void 0 : initialData.default) == null ? void 0 : _b.height) || DEFAULT_HEIGHT;
|
|
222
|
+
if (estimatedHeight + height > SHEET_HEIGHT) {
|
|
223
|
+
return SHEET_HEIGHT;
|
|
224
|
+
}
|
|
225
|
+
estimatedHeight += height;
|
|
226
|
+
}
|
|
227
|
+
return estimatedHeight + 3;
|
|
228
|
+
};
|
|
229
|
+
const estimateSheetWidth = ({ initialData, options }) => {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
const auto = getMaxSizesFromCells(initialData);
|
|
232
|
+
let estimatedWidth = options.headerWidth || HEADER_WIDTH;
|
|
233
|
+
for (let x = 0; x < auto.numCols; x++) {
|
|
234
|
+
const col = x2c(x);
|
|
235
|
+
const width = ((_a = initialData == null ? void 0 : initialData[col]) == null ? void 0 : _a.width) || ((_b = initialData == null ? void 0 : initialData.default) == null ? void 0 : _b.width) || DEFAULT_WIDTH;
|
|
236
|
+
if (estimatedWidth + width > SHEET_WIDTH) {
|
|
237
|
+
return SHEET_WIDTH;
|
|
238
|
+
}
|
|
239
|
+
estimatedWidth += width;
|
|
240
|
+
}
|
|
241
|
+
return estimatedWidth + 3;
|
|
242
|
+
};
|
|
243
|
+
export {
|
|
244
|
+
GridSheet
|
|
245
|
+
};
|
|
246
|
+
//# sourceMappingURL=GridSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridSheet.js","sources":["../../components/GridSheet.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReducerWithoutAction } from 'react';\n\nimport { CellsByAddressType, OptionsType, Props, StoreType } from '../types';\nimport {\n DEFAULT_HEIGHT,\n DEFAULT_WIDTH,\n HEADER_HEIGHT,\n HEADER_WIDTH,\n SHEET_HEIGHT,\n SHEET_WIDTH,\n HISTORY_LIMIT,\n} from '../constants';\nimport { functions } from '../formula/mapping';\nimport { Context } from '../store';\nimport { reducer as defaultReducer } from '../store/actions';\n\nimport { Editor } from './Editor';\nimport { StoreInitializer } from './StoreInitializer';\nimport { Resizer } from './Resizer';\nimport { Emitter } from './Emitter';\nimport { ContextMenu } from './ContextMenu';\nimport { Table } from '../lib/table';\nimport { Tabular } from './Tabular';\nimport { getMaxSizesFromCells } from '../lib/structs';\nimport { x2c, y2r } from '../lib/converters';\nimport { embedStyle } from '../styles/embedder';\nimport { useSheetContext } from './SheetProvider';\nimport { FormulaBar } from './FormulaBar';\nimport { SearchBar } from './SearchBar';\n\nexport function GridSheet({\n initialCells,\n sheetName = '',\n tableRef,\n options = {},\n className,\n style,\n additionalFunctions = {},\n}: Props) {\n const { sheetResize, showFormulaBar = true, onInit, mode = 'light' } = options;\n const [prevSheetName, setPrevSheetName] = React.useState(sheetName);\n const rootRef = React.useRef<HTMLDivElement | null>(null);\n const mainRef = React.useRef<HTMLDivElement | null>(null);\n const searchInputRef = React.useRef<HTMLTextAreaElement | null>(null);\n const editorRef = React.useRef<HTMLTextAreaElement | null>(null);\n const largeEditorRef = React.useRef<HTMLTextAreaElement | null>(null);\n const tabularRef = React.useRef<HTMLDivElement | null>(null);\n const lastFocusedRef = React.useRef<HTMLTextAreaElement | null>(null);\n const [sheetProvided, sheetContext] = useSheetContext();\n\n const [initialState] = React.useState<StoreType>(() => {\n const {\n headerHeight = HEADER_HEIGHT,\n headerWidth = HEADER_WIDTH,\n historyLimit = HISTORY_LIMIT,\n renderers,\n parsers,\n labelers,\n minNumRows,\n maxNumRows,\n minNumCols,\n maxNumCols,\n } = options;\n const table = new Table({\n historyLimit,\n parsers,\n renderers,\n labelers,\n minNumRows,\n maxNumRows,\n minNumCols,\n maxNumCols,\n headerHeight,\n headerWidth,\n functions: { ...functions, ...additionalFunctions },\n });\n let sheetId = 0;\n if (sheetProvided) {\n sheetId = sheetContext.head.current++;\n table.tables = sheetContext.tables.current;\n table.sheets = sheetContext.sheets.current;\n }\n table.tables[sheetId] = table;\n table.sheetId = sheetId;\n table.initialize(initialCells);\n onInit?.(table);\n return {\n sheetId,\n table, // temporary (see StoreInitializer for detail)\n tableInitialized: false,\n rootRef,\n mainRef,\n searchInputRef,\n editorRef,\n largeEditorRef,\n tabularRef,\n lastFocusedRef,\n choosing: { y: 1, x: 1 },\n cutting: false,\n inputting: '',\n selectingZone: { startY: -1, startX: -1, endY: -1, endX: -1 },\n copyingZone: { startY: -1, startX: -1, endY: -1, endX: -1 },\n autofillDraggingTo: null,\n leftHeaderSelecting: false,\n topHeaderSelecting: false,\n editingCell: '',\n editorRect: { y: 0, x: 0, height: 0, width: 0 },\n resizingRect: { y: -1, x: -1, height: -1, width: -1 },\n sheetHeight: 0,\n sheetWidth: 0,\n headerHeight: 0,\n headerWidth: 0,\n entering: false,\n matchingCells: [],\n matchingCellIndex: 0,\n searchCaseSensitive: false,\n editingOnEnter: true,\n showAddress: true,\n contextMenuPosition: { y: -1, x: -1 },\n resizingPositionY: [-1, -1, -1],\n resizingPositionX: [-1, -1, -1],\n minNumRows: 1,\n maxNumRows: -1,\n minNumCols: 1,\n maxNumCols: -1,\n mode: 'light',\n lastEdited: '',\n };\n });\n\n const [store, dispatch] = React.useReducer(\n defaultReducer as unknown as ReducerWithoutAction<StoreType>,\n initialState,\n () => initialState,\n );\n\n React.useEffect(() => {\n embedStyle();\n }, []);\n\n React.useEffect(() => {\n if (!sheetProvided) {\n return;\n }\n sheetContext.tables.current[store.sheetId] = store.table;\n sheetContext?.forceRender?.();\n }, [store.table]);\n\n React.useEffect(() => {\n if (!sheetProvided) {\n return;\n }\n if (prevSheetName !== sheetName) {\n delete sheetContext.sheets.current[prevSheetName];\n setPrevSheetName(sheetName);\n }\n if (sheetName) {\n sheetContext.sheets.current[sheetName] = store.sheetId;\n }\n store.table.sheetName = sheetName;\n }, [sheetName]);\n\n const [sheetHeight, setSheetHeight] = React.useState(\n options?.sheetHeight || estimateSheetHeight({ options, initialData: initialCells }),\n );\n const [sheetWidth, setSheetWidth] = React.useState(\n options?.sheetWidth || estimateSheetWidth({ options, initialData: initialCells }),\n );\n React.useEffect(() => {\n const intervalId = window.setInterval(() => {\n setSheetHeight(mainRef.current?.clientHeight || 0);\n setSheetWidth(mainRef.current?.clientWidth || 0);\n }, 1000);\n return () => window.clearInterval(intervalId);\n }, []);\n React.useEffect(() => {\n if (options.sheetHeight) {\n setSheetHeight(options.sheetHeight);\n }\n }, [options.sheetHeight]);\n React.useEffect(() => {\n if (options.sheetWidth) {\n setSheetWidth(options.sheetWidth);\n }\n }, [options.sheetWidth]);\n\n const { onChange, onSelect } = options;\n return (\n <Context.Provider value={{ store, dispatch }}>\n <div\n className={`gs-root1`}\n ref={rootRef}\n data-sheet-name={sheetName}\n data-mode={mode}\n style={{ maxWidth: `min(100%, ${store.table.totalWidth + 2}px)` }}\n >\n {typeof store.searchQuery === 'undefined' ? showFormulaBar && <FormulaBar /> : <SearchBar />}\n <div\n className={`gs-main ${className || ''}`}\n ref={mainRef}\n style={{\n maxWidth: `min(100%-1px, ${store.table.totalWidth + 2}px)`,\n maxHeight: store.table.totalHeight + 2,\n ...style,\n resize: sheetResize,\n }}\n >\n <Editor mode={mode} />\n <Tabular tableRef={tableRef} />\n <StoreInitializer\n initialCells={initialCells}\n options={{ ...options, sheetHeight, sheetWidth }}\n additionalFunctions={additionalFunctions}\n />\n <ContextMenu />\n <Resizer />\n <Emitter onChange={onChange} onSelect={onSelect} />\n </div>\n </div>\n </Context.Provider>\n );\n}\n\ntype EstimateProps = {\n initialData: CellsByAddressType;\n options: OptionsType;\n};\n\nconst estimateSheetHeight = ({ initialData, options }: EstimateProps) => {\n const auto = getMaxSizesFromCells(initialData);\n let estimatedHeight = options.headerHeight || HEADER_HEIGHT;\n for (let y = 0; y < auto.numRows; y++) {\n const row = y2r(y);\n const height = initialData?.[row]?.height || initialData?.default?.height || DEFAULT_HEIGHT;\n if (estimatedHeight + height > SHEET_HEIGHT) {\n return SHEET_HEIGHT;\n }\n estimatedHeight += height;\n }\n return estimatedHeight + 3;\n};\n\nconst estimateSheetWidth = ({ initialData, options }: EstimateProps) => {\n const auto = getMaxSizesFromCells(initialData);\n let estimatedWidth = options.headerWidth || HEADER_WIDTH;\n for (let x = 0; x < auto.numCols; x++) {\n const col = x2c(x);\n const width = initialData?.[col]?.width || initialData?.default?.width || DEFAULT_WIDTH;\n if (estimatedWidth + width > SHEET_WIDTH) {\n return SHEET_WIDTH;\n }\n estimatedWidth += width;\n }\n return estimatedWidth + 3;\n};\n"],"names":["defaultReducer"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BO,SAAS,UAAU;AAAA,EACxB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AAAA,EACA;AAAA,EACA,sBAAsB,CAAA;AACxB,GAAU;AACR,QAAM,EAAE,aAAa,iBAAiB,MAAM,QAAQ,OAAO,YAAY;AACvE,QAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,SAAS;AAC5D,QAAA,UAAU,MAAM,OAA8B,IAAI;AAClD,QAAA,UAAU,MAAM,OAA8B,IAAI;AAClD,QAAA,iBAAiB,MAAM,OAAmC,IAAI;AAC9D,QAAA,YAAY,MAAM,OAAmC,IAAI;AACzD,QAAA,iBAAiB,MAAM,OAAmC,IAAI;AAC9D,QAAA,aAAa,MAAM,OAA8B,IAAI;AACrD,QAAA,iBAA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1,131 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { y2r } from "../lib/converters.js";
|
|
4
|
+
import { zoneToArea, between } from "../lib/structs.js";
|
|
5
|
+
import { Context } from "../store/index.js";
|
|
6
|
+
import { setResizingPositionY, drag, select, selectRows, choose, setContextMenuPosition, setEditingCell } from "../store/actions.js";
|
|
7
|
+
import { DEFAULT_HEIGHT, DUMMY_IMG } from "../constants.js";
|
|
8
|
+
import { isPrevented, Resize } from "../lib/prevention.js";
|
|
9
|
+
import { insertRef, isRefInsertable } from "../lib/input.js";
|
|
10
|
+
import { useSheetContext } from "./SheetProvider.js";
|
|
11
|
+
const HeaderCellLeft = React__default.memo(({ y }) => {
|
|
12
|
+
const rowId = `${y2r(y)}`;
|
|
13
|
+
const { store, dispatch } = React__default.useContext(Context);
|
|
14
|
+
const {
|
|
15
|
+
choosing,
|
|
16
|
+
selectingZone,
|
|
17
|
+
leftHeaderSelecting,
|
|
18
|
+
resizingRect,
|
|
19
|
+
headerWidth,
|
|
20
|
+
editorRef,
|
|
21
|
+
table,
|
|
22
|
+
autofillDraggingTo
|
|
23
|
+
} = store;
|
|
24
|
+
const row = table.getByPoint({ y, x: 0 });
|
|
25
|
+
const height = (row == null ? void 0 : row.height) || DEFAULT_HEIGHT;
|
|
26
|
+
const [sheetProvided, sheetContext] = useSheetContext();
|
|
27
|
+
const differentSheetFocused = sheetProvided && (sheetContext == null ? void 0 : sheetContext.lastFocusedRef) !== store.lastFocusedRef;
|
|
28
|
+
const lastFocusedRef = (sheetContext == null ? void 0 : sheetContext.lastFocusedRef) || store.lastFocusedRef;
|
|
29
|
+
const lastInput = lastFocusedRef.current;
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
"th",
|
|
32
|
+
{
|
|
33
|
+
"data-y": y,
|
|
34
|
+
className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${between({ start: selectingZone.startY, end: selectingZone.endY }, y) ? leftHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""}`,
|
|
35
|
+
style: { height },
|
|
36
|
+
onClick: (e) => {
|
|
37
|
+
let startY = e.shiftKey ? selectingZone.startY : y;
|
|
38
|
+
if (startY === -1) {
|
|
39
|
+
startY = choosing.y;
|
|
40
|
+
}
|
|
41
|
+
const fullColId = `${table.sheetPrefix(!differentSheetFocused)}${rowId}:${rowId}`;
|
|
42
|
+
const inserted = insertRef(lastInput, fullColId);
|
|
43
|
+
if (inserted) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
dispatch(
|
|
47
|
+
selectRows({
|
|
48
|
+
range: { start: startY, end: y },
|
|
49
|
+
numCols: table.getNumCols()
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
dispatch(setContextMenuPosition({ y: -1, x: -1 }));
|
|
53
|
+
dispatch(choose({ y: startY, x: 1 }));
|
|
54
|
+
dispatch(setEditingCell(""));
|
|
55
|
+
editorRef.current.focus();
|
|
56
|
+
return false;
|
|
57
|
+
},
|
|
58
|
+
onContextMenu: (e) => {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
dispatch(setContextMenuPosition({ y: e.clientY, x: e.clientX }));
|
|
61
|
+
return false;
|
|
62
|
+
},
|
|
63
|
+
children: /* @__PURE__ */ jsx(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
className: "gs-th-inner-wrap",
|
|
67
|
+
draggable: true,
|
|
68
|
+
onDragStart: (e) => {
|
|
69
|
+
e.dataTransfer.setDragImage(DUMMY_IMG, 0, 0);
|
|
70
|
+
const insertable = isRefInsertable(lastInput);
|
|
71
|
+
if (insertable) {
|
|
72
|
+
dispatch(select({ startY: y, startX: table.getNumCols(), endY: y, endX: 0 }));
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
dispatch(
|
|
76
|
+
selectRows({
|
|
77
|
+
range: { start: y, end: y },
|
|
78
|
+
numCols: table.getNumCols()
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
dispatch(choose({ y, x: 1 }));
|
|
82
|
+
return false;
|
|
83
|
+
},
|
|
84
|
+
onDragEnd: () => {
|
|
85
|
+
if (isRefInsertable(lastInput)) {
|
|
86
|
+
dispatch(select({ startY: -1, startX: -1, endY: -1, endX: -1 }));
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
onDragEnter: () => {
|
|
90
|
+
const newArea = zoneToArea({ ...selectingZone, endY: y, endX: 1 });
|
|
91
|
+
const [top, bottom] = [y2r(newArea.top), y2r(newArea.bottom)];
|
|
92
|
+
const fullRange = `${table.sheetPrefix(!differentSheetFocused)}${top}:${bottom}`;
|
|
93
|
+
insertRef(lastInput, fullRange);
|
|
94
|
+
if (resizingRect.y === -1 && autofillDraggingTo == null) {
|
|
95
|
+
const { startX } = selectingZone;
|
|
96
|
+
if (startX === 1) {
|
|
97
|
+
dispatch(drag({ y, x: table.getNumCols() }));
|
|
98
|
+
} else {
|
|
99
|
+
dispatch(drag({ y, x: 1 }));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
},
|
|
104
|
+
onDragOver: (e) => {
|
|
105
|
+
e.dataTransfer.dropEffect = "move";
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
},
|
|
108
|
+
children: /* @__PURE__ */ jsxs("div", { className: "gs-th-inner", style: { width: headerWidth, position: "relative" }, children: [
|
|
109
|
+
(row == null ? void 0 : row.labeler) ? table.getLabel(row.labeler, y) : rowId,
|
|
110
|
+
/* @__PURE__ */ jsx(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
className: `gs-resizer ${isPrevented(row == null ? void 0 : row.prevention, Resize) ? "gs-protected" : ""}`,
|
|
114
|
+
style: { width: headerWidth },
|
|
115
|
+
onMouseDown: (e) => {
|
|
116
|
+
dispatch(setResizingPositionY([y, e.clientY, e.clientY]));
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] })
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
export {
|
|
129
|
+
HeaderCellLeft
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=HeaderCellLeft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderCellLeft.js","sources":["../../components/HeaderCellLeft.tsx"],"sourcesContent":["import React from 'react';\nimport { y2r } from '../lib/converters';\nimport { between, zoneToArea } from '../lib/structs';\nimport { Context } from '../store';\nimport {\n choose,\n drag,\n select,\n selectRows,\n setContextMenuPosition,\n setEditingCell,\n setResizingPositionY,\n} from '../store/actions';\nimport { DUMMY_IMG, DEFAULT_HEIGHT } from '../constants';\nimport * as prevention from '../lib/prevention';\nimport { insertRef, isRefInsertable } from '../lib/input';\nimport { useSheetContext } from './SheetProvider';\n\ntype Props = {\n y: number;\n};\n\nexport const HeaderCellLeft: React.FC<Props> = React.memo(({ y }) => {\n const rowId = `${y2r(y)}`;\n const { store, dispatch } = React.useContext(Context);\n\n const {\n choosing,\n selectingZone,\n leftHeaderSelecting,\n resizingRect,\n headerWidth,\n editorRef,\n table,\n autofillDraggingTo,\n } = store;\n\n const row = table.getByPoint({ y, x: 0 });\n const height = row?.height || DEFAULT_HEIGHT;\n\n const [sheetProvided, sheetContext] = useSheetContext();\n const differentSheetFocused = sheetProvided && sheetContext?.lastFocusedRef !== store.lastFocusedRef;\n\n const lastFocusedRef = sheetContext?.lastFocusedRef || store.lastFocusedRef;\n const lastInput = lastFocusedRef.current;\n\n return (\n <th\n data-y={y}\n className={`gs-th gs-th-left ${choosing.y === y ? 'gs-choosing' : ''} ${\n between({ start: selectingZone.startY, end: selectingZone.endY }, y)\n ? leftHeaderSelecting\n ? 'gs-th-selecting'\n : 'gs-selecting'\n : ''\n }`}\n style={{ height }}\n onClick={(e) => {\n let startY = e.shiftKey ? selectingZone.startY : y;\n if (startY === -1) {\n startY = choosing.y;\n }\n const fullColId = `${table.sheetPrefix(!differentSheetFocused)}${rowId}:${rowId}`;\n const inserted = insertRef(lastInput, fullColId);\n if (inserted) {\n return false;\n }\n\n dispatch(\n selectRows({\n range: { start: startY, end: y },\n numCols: table.getNumCols(),\n }),\n );\n dispatch(setContextMenuPosition({ y: -1, x: -1 }));\n dispatch(choose({ y: startY, x: 1 }));\n dispatch(setEditingCell(''));\n editorRef.current!.focus();\n return false;\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n dispatch(setContextMenuPosition({ y: e.clientY, x: e.clientX }));\n return false;\n }}\n >\n <div\n className=\"gs-th-inner-wrap\"\n draggable\n onDragStart={(e) => {\n e.dataTransfer.setDragImage(DUMMY_IMG, 0, 0);\n const insertable = isRefInsertable(lastInput);\n if (insertable) {\n dispatch(select({ startY: y, startX: table.getNumCols(), endY: y, endX: 0 }));\n return false;\n }\n dispatch(\n selectRows({\n range: { start: y, end: y },\n numCols: table.getNumCols(),\n }),\n );\n dispatch(choose({ y, x: 1 }));\n return false;\n }}\n onDragEnd={() => {\n if (isRefInsertable(lastInput)) {\n dispatch(select({ startY: -1, startX: -1, endY: -1, endX: -1 }));\n }\n }}\n onDragEnter={() => {\n const newArea = zoneToArea({ ...selectingZone, endY: y, endX: 1 });\n const [top, bottom] = [y2r(newArea.top), y2r(newArea.bottom)];\n const fullRange = `${table.sheetPrefix(!differentSheetFocused)}${top}:${bottom}`;\n insertRef(lastInput, fullRange);\n\n if (resizingRect.y === -1 && autofillDraggingTo == null) {\n const { startX } = selectingZone;\n if (startX === 1) {\n dispatch(drag({ y, x: table.getNumCols() }));\n } else {\n dispatch(drag({ y, x: 1 }));\n }\n }\n return false;\n }}\n onDragOver={(e) => {\n e.dataTransfer.dropEffect = 'move';\n e.preventDefault();\n }}\n >\n <div className=\"gs-th-inner\" style={{ width: headerWidth, position: 'relative' }}>\n {row?.labeler ? table.getLabel(row.labeler, y) : rowId}\n <div\n className={`gs-resizer ${prevention.isPrevented(row?.prevention, prevention.Resize) ? 'gs-protected' : ''}`}\n style={{ width: headerWidth }}\n onMouseDown={(e) => {\n dispatch(setResizingPositionY([y, e.clientY, e.clientY]));\n e.preventDefault();\n e.stopPropagation();\n }}\n ></div>\n </div>\n </div>\n </th>\n );\n});\n"],"names":["React","prevention.isPrevented","prevention.Resize"],"mappings":";;;;;;;;;;AAsBO,MAAM,iBAAkCA,eAAM,KAAK,CAAC,EAAE,QAAQ;AACnE,QAAM,QAAQ,GAAG,IAAI,CAAC,CAAC;AACvB,QAAM,EAAE,OAAO,SAAA,IAAaA,eAAM,WAAW,OAAO;AAE9C,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAEJ,QAAM,MAAM,MAAM,WAAW,EAAE,GAAG,GAAG,GAAG;AAClC,QAAA,UAAS,2BAAK,WAAU;AAE9B,QAAM,CAAC,eAAe,YAAY,IAAI,gBAAgB;AACtD,QAAM,wBAAwB,kBAAiB,6CAAc,oBAAmB,MAAM;AAEhF,QAAA,kBAAiB,6CAAc,mBAAkB,MAAM;AAC7D,QAAM,YAAY,eAAe;AAG/B,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAQ;AAAA,MACR,WAAW,oBAAoB,SAAS,MAAM,IAAI,gBAAgB,EAAE,IAClE,QAAQ,EAAE,OAAO,cAAc,QAAQ,KAAK,cAAc,QAAQ,CAAC,IAC/D,sBACE,oBACA,iBACF,EACN;AAAA,MACA,OAAO,EAAE,OAAO;AAAA,MAChB,SAAS,CAAC,MAAM;AACd,YAAI,SAAS,EAAE,WAAW,cAAc,SAAS;AACjD,YAAI,WAAW,IAAI;AACjB,mBAAS,SAAS;AAAA,QAAA;AAEd,cAAA,YAAY,GAAG,MAAM,YAAY,CAAC,qBAAqB,CAAC,GAAG,KAAK,IAAI,KAAK;AACz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