@gridsheet/preact-core 3.2.0 → 3.4.0
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/AsyncProgressOverlay.d.ts +14 -0
- package/dist/components/FunctionGuide.d.ts +1 -1
- package/dist/components/GridSheet.d.ts +1 -1
- package/dist/components/MenuNodes.d.ts +28 -0
- package/dist/components/ProgressOverlay.d.ts +18 -0
- package/dist/components/useAutocomplete.d.ts +1 -1
- package/dist/hooks-BTcuh87d.mjs +7189 -0
- package/dist/hooks-BTcuh87d.mjs.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +736 -436
- package/dist/index.js.map +1 -1
- package/dist/lib/clipboard.d.ts +1 -1
- package/dist/lib/hooks.d.ts +1 -1
- package/dist/lib/menu.d.ts +17 -4
- package/dist/policy/checkbox.d.ts +1 -1
- package/dist/spellbook.d.ts +3 -3
- package/dist/spellbook.js +2 -3
- package/dist/spellbook.js.map +1 -1
- package/dist/store/actions.d.ts +56 -1
- package/dist/store/helpers.d.ts +1 -1
- package/dist/types.d.ts +19 -2
- package/package.json +4 -3
- package/dist/hooks-ykrgAwg5.mjs +0 -1533
- package/dist/hooks-ykrgAwg5.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { h, render } from "preact";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import React, { createContext, useRef, useContext, useLayoutEffect,
|
|
6
|
-
import { Children, Component, Fragment as Fragment2, PureComponent, StrictMode, Suspense, SuspenseList, cloneElement, render as render2, createContext as createContext2, createElement, createFactory, createPortal as createPortal2, createRef as createRef2, findDOMNode, forwardRef, hydrate, isValidElement, lazy, memo as memo2, unmountComponentAtNode, unstable_batchedUpdates, useCallback as useCallback2, useContext as useContext2, useDebugValue, useEffect as useEffect2, useImperativeHandle, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useReducer as useReducer2, useRef as useRef2, useState as useState2, version } from "preact/compat";
|
|
7
|
-
import { u as useBrowser, s as setEditingAddress, w as write, a as setInputting, b as updateSheet, r as redo, c as undo, d as cut, e as setSearchQuery, f as setEntering, g as copy, h as select, i as arrow, j as escape, k as clear, l as walk, p as paste, m as setEditorHovering, n as setStore, o as setResizingPositionY, q as setResizingPositionX, t as filterRows, v as sortRows, x as removeCols, y as removeRows, z as insertColsRight, A as insertColsLeft, B as insertRowsBelow, C as insertRowsAbove, D as setContextMenuPosition, E as setColumnMenu, F as setRowMenu, G as isXSheetFocused, H as setEditorRect, I as choose, J as drag, K as setDragging, L as submitAutofill, M as setAutofillDraggingTo, N as selectCols, O as useDebounceCallback, P as selectRows, Q as search, R as setSearchCaseSensitive, S as setSearchRegex, T as setSearchRange, U as useBook, V as reducer, W as isMutationAction } from "./hooks-ykrgAwg5.mjs";
|
|
8
|
-
import { X } from "./hooks-ykrgAwg5.mjs";
|
|
2
|
+
import { f as fe, u as ue, p as pe, k as ks, _, t as te, D as Dn, a as useBrowser, s as setEditingAddress, o as oe, G, w as write, b as setInputting, c as updateSheet, d as bt, e as te$1, g as ae, r as redo, h as undo, i as cut, P as Pe, j as fillRight, l as setSearchQuery, m as setEntering, n as fillDown, q as copy, v as select, x as selectToDataEdge, y as arrow, z as escape, A as clear, R, B as walk, M as Mn, C as ee, E as paste, F as setEditorHovering, H as Pn, I as setStore, J as submitAutofill, K as setDragging, L as setAutofillDraggingTo, N as drag, O as he, Q as rt, S as setResizingPositionY, T as setResizingPositionX, U as nn, V as cn, W as M, X as qr, Z as Zr, Y as filterRows, $ as sortRows, a0 as an, a1 as removeCols, a2 as removeRows, a3 as insertColsRight, a4 as insertColsLeft, a5 as insertRowsBelow, a6 as insertRowsAbove, a7 as setContextMenuPosition, a8 as Ln, a9 as setColumnMenu, aa as setRowMenu, ab as isXSheetFocused, ac as setEditorRect, ad as S, ae as L, af as choose, ag as q, ah as rn, ai as ce, aj as be, ak as on, al as le, am as re, an as selectCols, ao as useDebounceCallback, ap as selectRows, aq as W, ar as Hn, as as Q, at as T, au as ge, av as se, aw as ne, ax as en, ay as bn, az as Z, aA as ie, aB as de, aC as search, aD as setSearchCaseSensitive, aE as setSearchRegex, aF as wn, aG as setSearchRange, aH as useBook, aI as Y, aJ as reducer, aK as me, aL as isAsyncMutationAction, aM as isMutationAction, aN as commitAsyncOp, aO as Hs, aP as $e, aQ as $t, aR as jr, aS as Le, aT as kt, aU as Gr } from "./hooks-BTcuh87d.mjs";
|
|
3
|
+
import { bi, bj, bA, bk, bz, bx, bn as bn2, bl, b6, bB, by, b1, bm, aW, a_, a$, b0, aX, aY, b2, b5, bs, bv, b7, bu, b8, bt as bt2, bq, br, bp, bo, aZ, aV, b3, b4, bw, bh, be as be2, bf, bg, bd, b9, ba, bb, bc, bC } from "./hooks-BTcuh87d.mjs";
|
|
4
|
+
import { jsx, jsxs, Fragment } from "preact/compat/jsx-runtime";
|
|
5
|
+
import React, { createContext, forwardRef, useState, useImperativeHandle, useRef, useContext, useLayoutEffect, useMemo, useCallback, createPortal, memo, useEffect, createRef, useReducer } from "preact/compat";
|
|
6
|
+
import { Children, Component, Fragment as Fragment2, PureComponent, StrictMode, Suspense, SuspenseList, cloneElement, render as render2, createContext as createContext2, createElement, createFactory, createPortal as createPortal2, createRef as createRef2, findDOMNode, forwardRef as forwardRef2, hydrate, isValidElement, lazy, memo as memo2, unmountComponentAtNode, unstable_batchedUpdates, useCallback as useCallback2, useContext as useContext2, useDebugValue, useEffect as useEffect2, useImperativeHandle as useImperativeHandle2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useReducer as useReducer2, useRef as useRef2, useState as useState2, version } from "preact/compat";
|
|
9
7
|
const Context = createContext(
|
|
10
8
|
{}
|
|
11
9
|
);
|
|
10
|
+
const ProgressOverlay = ({ progress, label = "Loading" }) => {
|
|
11
|
+
const determinate = progress != null;
|
|
12
|
+
const pct = determinate ? Math.max(0, Math.min(100, Math.round(progress * 100))) : 0;
|
|
13
|
+
return /* @__PURE__ */ jsx("div", { className: "gs-progress-overlay", children: /* @__PURE__ */ jsxs("div", { className: "gs-progress-box", children: [
|
|
14
|
+
/* @__PURE__ */ jsxs("div", { className: "gs-progress-head", children: [
|
|
15
|
+
/* @__PURE__ */ jsx("span", { className: "gs-loading-spinner" }),
|
|
16
|
+
/* @__PURE__ */ jsx("span", { children: determinate ? `${label}… ${pct}%` : `${label}…` })
|
|
17
|
+
] }),
|
|
18
|
+
determinate && /* @__PURE__ */ jsx("div", { className: "gs-progress-track", children: /* @__PURE__ */ jsx("div", { className: "gs-progress-fill", style: { width: `${pct}%` } }) })
|
|
19
|
+
] }) });
|
|
20
|
+
};
|
|
21
|
+
const AsyncProgressOverlay = forwardRef(({ label }, ref) => {
|
|
22
|
+
const [progress, setProgress] = useState(0);
|
|
23
|
+
useImperativeHandle(ref, () => ({ setProgress }), []);
|
|
24
|
+
return /* @__PURE__ */ jsx(ProgressOverlay, { progress, label });
|
|
25
|
+
});
|
|
12
26
|
const FunctionGuide = ({
|
|
13
27
|
option,
|
|
14
28
|
activeFunctionGuide,
|
|
@@ -25,14 +39,14 @@ const FunctionGuide = ({
|
|
|
25
39
|
if (!el) {
|
|
26
40
|
return;
|
|
27
41
|
}
|
|
28
|
-
|
|
42
|
+
fe(el);
|
|
29
43
|
});
|
|
30
44
|
useLayoutEffect(() => {
|
|
31
45
|
const el = ref.current;
|
|
32
46
|
if (!el || left === void 0) {
|
|
33
47
|
return;
|
|
34
48
|
}
|
|
35
|
-
|
|
49
|
+
ue(el);
|
|
36
50
|
});
|
|
37
51
|
if (option) {
|
|
38
52
|
return /* @__PURE__ */ jsxs(
|
|
@@ -150,7 +164,7 @@ const EditorOptions = ({
|
|
|
150
164
|
return;
|
|
151
165
|
}
|
|
152
166
|
const width = ulRef.current.getBoundingClientRect().width;
|
|
153
|
-
setAdjustedLeft(
|
|
167
|
+
setAdjustedLeft(pe(left, width));
|
|
154
168
|
}, [left, filteredOptions]);
|
|
155
169
|
if (filteredOptions.length === 0) {
|
|
156
170
|
return null;
|
|
@@ -178,7 +192,7 @@ const clip = (store) => {
|
|
|
178
192
|
return { top: 0, left: 0, bottom: 0, right: 0 };
|
|
179
193
|
}
|
|
180
194
|
const { y, x } = choosing;
|
|
181
|
-
const selectingArea =
|
|
195
|
+
const selectingArea = ks(selectingZone);
|
|
182
196
|
let area = selectingArea;
|
|
183
197
|
if (area.left === -1) {
|
|
184
198
|
area = { top: y, left: x, bottom: y, right: x };
|
|
@@ -208,7 +222,7 @@ const clip = (store) => {
|
|
|
208
222
|
]);
|
|
209
223
|
} else if (input != null) {
|
|
210
224
|
input.value = tsv;
|
|
211
|
-
|
|
225
|
+
_(input);
|
|
212
226
|
input.select();
|
|
213
227
|
document.execCommand("copy");
|
|
214
228
|
input.value = "";
|
|
@@ -299,7 +313,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
|
|
|
299
313
|
if (isFormula && textBeforeCursor.length > 1) {
|
|
300
314
|
try {
|
|
301
315
|
const textToCursor = textBeforeCursor.slice(1);
|
|
302
|
-
const lexer = new
|
|
316
|
+
const lexer = new te(textToCursor);
|
|
303
317
|
lexer.tokenize();
|
|
304
318
|
const functionStack = [];
|
|
305
319
|
for (let i = 0; i < lexer.tokens.length; i++) {
|
|
@@ -326,7 +340,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
|
|
|
326
340
|
}
|
|
327
341
|
if (functionStack.length > 0) {
|
|
328
342
|
const activeItem = functionStack[functionStack.length - 1];
|
|
329
|
-
const helps =
|
|
343
|
+
const helps = Dn(functions);
|
|
330
344
|
activeArgIndex2 = activeItem.argIndex;
|
|
331
345
|
activeFunctionHelp2 = helps.find((h2) => h2.name === activeItem.name.toUpperCase()) || null;
|
|
332
346
|
}
|
|
@@ -341,7 +355,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
|
|
|
341
355
|
let isOnAddress = false;
|
|
342
356
|
if (isFormula) {
|
|
343
357
|
try {
|
|
344
|
-
const fullLexer = new
|
|
358
|
+
const fullLexer = new te(inputting.slice(1));
|
|
345
359
|
fullLexer.tokenize();
|
|
346
360
|
let currentIndex = 1;
|
|
347
361
|
for (const token of fullLexer.tokens) {
|
|
@@ -367,7 +381,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
|
|
|
367
381
|
}
|
|
368
382
|
if (isFormula && !isOnAddress) {
|
|
369
383
|
if (currentWord.length > 0 && !hasOpenParenAssigned) {
|
|
370
|
-
filtered =
|
|
384
|
+
filtered = Dn(functions).map((help) => {
|
|
371
385
|
const keywordLower = help.name.toLowerCase();
|
|
372
386
|
const startsWith = keywordLower.startsWith(currentWord);
|
|
373
387
|
const index = startsWith ? 0 : -1;
|
|
@@ -599,7 +613,7 @@ function parseStyleString(element) {
|
|
|
599
613
|
if (rawKey === "height" || rawKey === "width") {
|
|
600
614
|
return;
|
|
601
615
|
}
|
|
602
|
-
const key = rawKey.trim().replace(/-([a-z])/g, (
|
|
616
|
+
const key = rawKey.trim().replace(/-([a-z])/g, (_2, letter) => letter.toUpperCase());
|
|
603
617
|
if (key === "float" || key === "display" || key.startsWith("padding")) {
|
|
604
618
|
return;
|
|
605
619
|
}
|
|
@@ -754,7 +768,10 @@ const Editor = ({ mode }) => {
|
|
|
754
768
|
}
|
|
755
769
|
const { bottom: top2, left: left2 } = rect;
|
|
756
770
|
return createPortal(
|
|
757
|
-
|
|
771
|
+
// Portaled to <body>, outside .gs-root1 / .gs-editor, so carry data-mode
|
|
772
|
+
// here too — otherwise the theme-specific styles (e.g. the dark function
|
|
773
|
+
// guide) never match and the help renders with the light palette.
|
|
774
|
+
/* @__PURE__ */ jsxs("div", { className: "gs-editor-portal", "data-mode": mode, children: [
|
|
758
775
|
activeFunctionHelp && filteredOptions.length === 0 && (!selectingZone || selectingZone.endY === -1 && selectingZone.endX === -1) && /* @__PURE__ */ jsx(
|
|
759
776
|
FunctionGuide,
|
|
760
777
|
{
|
|
@@ -799,7 +816,7 @@ const Editor = ({ mode }) => {
|
|
|
799
816
|
functions: sheet == null ? void 0 : sheet.registry.functions
|
|
800
817
|
});
|
|
801
818
|
useEffect(() => {
|
|
802
|
-
|
|
819
|
+
_(editorRef == null ? void 0 : editorRef.current);
|
|
803
820
|
}, [editorRef]);
|
|
804
821
|
useEffect(() => {
|
|
805
822
|
if (!sheet) {
|
|
@@ -824,11 +841,11 @@ const Editor = ({ mode }) => {
|
|
|
824
841
|
sheet.registry.editingAddress = editingAddress;
|
|
825
842
|
}, [editingAddress, sheet, sheetId]);
|
|
826
843
|
useEffect(() => {
|
|
827
|
-
|
|
844
|
+
oe(editorRef.current);
|
|
828
845
|
}, [inputting, editingAddress, editorRef]);
|
|
829
846
|
const { y, x } = choosing;
|
|
830
|
-
const rowId = `${
|
|
831
|
-
const colId =
|
|
847
|
+
const rowId = `${bt(y)}`;
|
|
848
|
+
const colId = G(x);
|
|
832
849
|
const address = `${colId}${rowId}`;
|
|
833
850
|
const editing = editingAddress === address;
|
|
834
851
|
const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "RAW" });
|
|
@@ -855,7 +872,7 @@ const Editor = ({ mode }) => {
|
|
|
855
872
|
dispatch(setInputting(newValue));
|
|
856
873
|
setTimeout(() => {
|
|
857
874
|
if (editorRef.current) {
|
|
858
|
-
|
|
875
|
+
_(editorRef.current);
|
|
859
876
|
editorRef.current.setSelectionRange(newCursor, newCursor);
|
|
860
877
|
}
|
|
861
878
|
}, 0);
|
|
@@ -879,7 +896,7 @@ const Editor = ({ mode }) => {
|
|
|
879
896
|
}
|
|
880
897
|
setBefore(currentString);
|
|
881
898
|
dispatch(setInputting(currentString));
|
|
882
|
-
|
|
899
|
+
te$1(editorRef.current, sheet, choosing);
|
|
883
900
|
}, [choosing, currentString, dispatch, editorRef, sheet]);
|
|
884
901
|
const { y: top, x: left, height, width } = editorRect;
|
|
885
902
|
const numLines = currentString.split("\n").length;
|
|
@@ -903,7 +920,7 @@ const Editor = ({ mode }) => {
|
|
|
903
920
|
});
|
|
904
921
|
}
|
|
905
922
|
const input = e.currentTarget;
|
|
906
|
-
if (
|
|
923
|
+
if (ae(e, inputting)) {
|
|
907
924
|
dispatch(setInputting(input.value));
|
|
908
925
|
return false;
|
|
909
926
|
}
|
|
@@ -944,7 +961,7 @@ const Editor = ({ mode }) => {
|
|
|
944
961
|
return false;
|
|
945
962
|
}
|
|
946
963
|
} else if (e.altKey) {
|
|
947
|
-
|
|
964
|
+
R(input, "\n");
|
|
948
965
|
dispatch(setInputting(input.value));
|
|
949
966
|
e.preventDefault();
|
|
950
967
|
return false;
|
|
@@ -1013,6 +1030,11 @@ const Editor = ({ mode }) => {
|
|
|
1013
1030
|
return false;
|
|
1014
1031
|
case "ArrowLeft":
|
|
1015
1032
|
if (!editing) {
|
|
1033
|
+
if ((e.ctrlKey || e.metaKey) && shiftKey2) {
|
|
1034
|
+
e.preventDefault();
|
|
1035
|
+
dispatch(selectToDataEdge({ deltaY: 0, deltaX: -1 }));
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1016
1038
|
dispatch(
|
|
1017
1039
|
arrow({
|
|
1018
1040
|
shiftKey: shiftKey2,
|
|
@@ -1027,6 +1049,11 @@ const Editor = ({ mode }) => {
|
|
|
1027
1049
|
break;
|
|
1028
1050
|
case "ArrowUp":
|
|
1029
1051
|
if (!editing) {
|
|
1052
|
+
if ((e.ctrlKey || e.metaKey) && shiftKey2) {
|
|
1053
|
+
e.preventDefault();
|
|
1054
|
+
dispatch(selectToDataEdge({ deltaY: -1, deltaX: 0 }));
|
|
1055
|
+
return false;
|
|
1056
|
+
}
|
|
1030
1057
|
dispatch(
|
|
1031
1058
|
arrow({
|
|
1032
1059
|
shiftKey: shiftKey2,
|
|
@@ -1044,6 +1071,11 @@ const Editor = ({ mode }) => {
|
|
|
1044
1071
|
break;
|
|
1045
1072
|
case "ArrowRight":
|
|
1046
1073
|
if (!editing) {
|
|
1074
|
+
if ((e.ctrlKey || e.metaKey) && shiftKey2) {
|
|
1075
|
+
e.preventDefault();
|
|
1076
|
+
dispatch(selectToDataEdge({ deltaY: 0, deltaX: 1 }));
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1047
1079
|
dispatch(
|
|
1048
1080
|
arrow({
|
|
1049
1081
|
shiftKey: shiftKey2,
|
|
@@ -1058,6 +1090,11 @@ const Editor = ({ mode }) => {
|
|
|
1058
1090
|
break;
|
|
1059
1091
|
case "ArrowDown":
|
|
1060
1092
|
if (!editing) {
|
|
1093
|
+
if ((e.ctrlKey || e.metaKey) && shiftKey2) {
|
|
1094
|
+
e.preventDefault();
|
|
1095
|
+
dispatch(selectToDataEdge({ deltaY: 1, deltaX: 0 }));
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1061
1098
|
dispatch(
|
|
1062
1099
|
arrow({
|
|
1063
1100
|
shiftKey: shiftKey2,
|
|
@@ -1094,13 +1131,23 @@ const Editor = ({ mode }) => {
|
|
|
1094
1131
|
if (!editing) {
|
|
1095
1132
|
e.preventDefault();
|
|
1096
1133
|
const area = clip(store);
|
|
1097
|
-
dispatch(copy(
|
|
1098
|
-
|
|
1134
|
+
dispatch(copy(Pe(area)));
|
|
1135
|
+
_(input);
|
|
1099
1136
|
return false;
|
|
1100
1137
|
}
|
|
1101
1138
|
return true;
|
|
1102
1139
|
}
|
|
1103
1140
|
break;
|
|
1141
|
+
case "d":
|
|
1142
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1143
|
+
if (!editing) {
|
|
1144
|
+
e.preventDefault();
|
|
1145
|
+
dispatch(fillDown(null));
|
|
1146
|
+
requestAnimationFrame(() => dispatch(setInputting("")));
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
break;
|
|
1104
1151
|
case "f":
|
|
1105
1152
|
if (e.ctrlKey || e.metaKey) {
|
|
1106
1153
|
if (!editing) {
|
|
@@ -1109,13 +1156,21 @@ const Editor = ({ mode }) => {
|
|
|
1109
1156
|
dispatch(setSearchQuery(""));
|
|
1110
1157
|
}
|
|
1111
1158
|
dispatch(setEntering(false));
|
|
1112
|
-
requestAnimationFrame(() =>
|
|
1159
|
+
requestAnimationFrame(() => _(searchInputRef.current));
|
|
1113
1160
|
return false;
|
|
1114
1161
|
}
|
|
1115
1162
|
}
|
|
1116
1163
|
break;
|
|
1117
1164
|
case "r":
|
|
1118
|
-
|
|
1165
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1166
|
+
if (!editing) {
|
|
1167
|
+
e.preventDefault();
|
|
1168
|
+
dispatch(fillRight(null));
|
|
1169
|
+
requestAnimationFrame(() => dispatch(setInputting("")));
|
|
1170
|
+
return false;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
break;
|
|
1119
1174
|
case "y":
|
|
1120
1175
|
if (e.ctrlKey || e.metaKey) {
|
|
1121
1176
|
if (!editing) {
|
|
@@ -1159,8 +1214,8 @@ const Editor = ({ mode }) => {
|
|
|
1159
1214
|
if (!editing) {
|
|
1160
1215
|
e.preventDefault();
|
|
1161
1216
|
const area = clip(store);
|
|
1162
|
-
dispatch(cut(
|
|
1163
|
-
|
|
1217
|
+
dispatch(cut(Pe(area)));
|
|
1218
|
+
_(input);
|
|
1164
1219
|
return false;
|
|
1165
1220
|
}
|
|
1166
1221
|
}
|
|
@@ -1190,7 +1245,7 @@ const Editor = ({ mode }) => {
|
|
|
1190
1245
|
if (e.ctrlKey || e.metaKey) {
|
|
1191
1246
|
return false;
|
|
1192
1247
|
}
|
|
1193
|
-
if (
|
|
1248
|
+
if (Mn.hasOperation(cell == null ? void 0 : cell.prevention, Mn.Write)) {
|
|
1194
1249
|
console.warn("This cell is protected from writing.");
|
|
1195
1250
|
return false;
|
|
1196
1251
|
}
|
|
@@ -1231,7 +1286,7 @@ const Editor = ({ mode }) => {
|
|
|
1231
1286
|
);
|
|
1232
1287
|
const handleDoubleClick = useCallback(
|
|
1233
1288
|
(e) => {
|
|
1234
|
-
if (
|
|
1289
|
+
if (Mn.hasOperation(cell == null ? void 0 : cell.prevention, Mn.Write)) {
|
|
1235
1290
|
console.warn("This cell is protected from writing.");
|
|
1236
1291
|
return;
|
|
1237
1292
|
}
|
|
@@ -1252,7 +1307,7 @@ const Editor = ({ mode }) => {
|
|
|
1252
1307
|
const handleBlur = useCallback(
|
|
1253
1308
|
(e) => {
|
|
1254
1309
|
setIsFocused(false);
|
|
1255
|
-
if (
|
|
1310
|
+
if (ee(e.currentTarget)) {
|
|
1256
1311
|
return true;
|
|
1257
1312
|
} else {
|
|
1258
1313
|
if (editing) {
|
|
@@ -1265,7 +1320,7 @@ const Editor = ({ mode }) => {
|
|
|
1265
1320
|
);
|
|
1266
1321
|
const handleChange = useCallback(
|
|
1267
1322
|
(e) => {
|
|
1268
|
-
if (
|
|
1323
|
+
if (Mn.hasOperation(cell == null ? void 0 : cell.prevention, Mn.Write)) {
|
|
1269
1324
|
return;
|
|
1270
1325
|
}
|
|
1271
1326
|
dispatch(setInputting(e.currentTarget.value));
|
|
@@ -1302,7 +1357,7 @@ const Editor = ({ mode }) => {
|
|
|
1302
1357
|
(e) => {
|
|
1303
1358
|
var _a2, _b2;
|
|
1304
1359
|
setShiftKey(false);
|
|
1305
|
-
const selectingArea =
|
|
1360
|
+
const selectingArea = ks(store.selectingZone);
|
|
1306
1361
|
(_b2 = sheet == null ? void 0 : (_a2 = sheet.registry).onKeyUp) == null ? void 0 : _b2.call(_a2, {
|
|
1307
1362
|
e,
|
|
1308
1363
|
points: {
|
|
@@ -1408,7 +1463,7 @@ const editorStyle = (text) => {
|
|
|
1408
1463
|
if (text[0] !== "=") {
|
|
1409
1464
|
return /* @__PURE__ */ jsx(Fragment, { children: text });
|
|
1410
1465
|
}
|
|
1411
|
-
const lexer = new
|
|
1466
|
+
const lexer = new te(text.substring(1));
|
|
1412
1467
|
lexer.tokenize();
|
|
1413
1468
|
let palletIndex = 0;
|
|
1414
1469
|
const exists = {};
|
|
@@ -1431,12 +1486,12 @@ const editorStyle = (text) => {
|
|
|
1431
1486
|
{
|
|
1432
1487
|
token,
|
|
1433
1488
|
tokenKey,
|
|
1434
|
-
color:
|
|
1489
|
+
color: Pn[existsIndex % Pn.length]
|
|
1435
1490
|
},
|
|
1436
1491
|
tokenKey
|
|
1437
1492
|
);
|
|
1438
1493
|
}
|
|
1439
|
-
const color =
|
|
1494
|
+
const color = Pn[palletIndex % Pn.length];
|
|
1440
1495
|
exists[normalizedToken] = palletIndex++;
|
|
1441
1496
|
return /* @__PURE__ */ jsx(
|
|
1442
1497
|
TokenSpan,
|
|
@@ -1501,6 +1556,116 @@ const StoreObserver = ({
|
|
|
1501
1556
|
const { store, dispatch } = useContext(Context);
|
|
1502
1557
|
const { sheetReactive } = store;
|
|
1503
1558
|
const sheet = sheetReactive.current;
|
|
1559
|
+
const dragRef = useRef({ store, dispatch });
|
|
1560
|
+
dragRef.current = { store, dispatch };
|
|
1561
|
+
useEffect(() => {
|
|
1562
|
+
let raf = 0;
|
|
1563
|
+
let running = false;
|
|
1564
|
+
let dead = false;
|
|
1565
|
+
let cx = 0;
|
|
1566
|
+
let cy = 0;
|
|
1567
|
+
let lastCell = "";
|
|
1568
|
+
let lastExtend = 0;
|
|
1569
|
+
const EDGE = 0;
|
|
1570
|
+
const SPEED = 18;
|
|
1571
|
+
const stop = () => {
|
|
1572
|
+
running = false;
|
|
1573
|
+
cancelAnimationFrame(raf);
|
|
1574
|
+
};
|
|
1575
|
+
const finish = () => {
|
|
1576
|
+
if (dead) {
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
dead = true;
|
|
1580
|
+
stop();
|
|
1581
|
+
const { store: s, dispatch: d } = dragRef.current;
|
|
1582
|
+
if (s.autofillDraggingTo) {
|
|
1583
|
+
d(submitAutofill(s.autofillDraggingTo));
|
|
1584
|
+
}
|
|
1585
|
+
if (s.dragging) {
|
|
1586
|
+
d(setDragging(false));
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
const tick = () => {
|
|
1590
|
+
var _a, _b;
|
|
1591
|
+
if (dead || !running) {
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
const { store: s, dispatch: d } = dragRef.current;
|
|
1595
|
+
const el = (_a = s.tabularRef) == null ? void 0 : _a.current;
|
|
1596
|
+
if (!el || !(s.dragging || s.autofillDraggingTo)) {
|
|
1597
|
+
running = false;
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
const r = el.getBoundingClientRect();
|
|
1601
|
+
const dy = cy > r.bottom - EDGE ? SPEED : cy < r.top + EDGE ? -18 : 0;
|
|
1602
|
+
const dx = cx > r.right - EDGE ? SPEED : cx < r.left + EDGE ? -18 : 0;
|
|
1603
|
+
if (dy || dx) {
|
|
1604
|
+
el.scrollTop += dy;
|
|
1605
|
+
el.scrollLeft += dx;
|
|
1606
|
+
const px = Math.min(Math.max(cx, r.left + 1), r.right - 1);
|
|
1607
|
+
const py = Math.min(Math.max(cy, r.top + 1), r.bottom - 1);
|
|
1608
|
+
const cell = (_b = document.elementFromPoint(px, py)) == null ? void 0 : _b.closest(".gs-cell");
|
|
1609
|
+
if (cell) {
|
|
1610
|
+
const y = Number(cell.dataset.y);
|
|
1611
|
+
const x = Number(cell.dataset.x);
|
|
1612
|
+
const key = y + ":" + x;
|
|
1613
|
+
const now = performance.now();
|
|
1614
|
+
if (!Number.isNaN(y) && !Number.isNaN(x) && key !== lastCell && now - lastExtend > 80) {
|
|
1615
|
+
lastCell = key;
|
|
1616
|
+
lastExtend = now;
|
|
1617
|
+
d(s.autofillDraggingTo ? setAutofillDraggingTo({ x, y }) : drag({ y, x }));
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
raf = requestAnimationFrame(tick);
|
|
1622
|
+
};
|
|
1623
|
+
const onMove = (e) => {
|
|
1624
|
+
if (e.buttons === 0) {
|
|
1625
|
+
const { store: s2 } = dragRef.current;
|
|
1626
|
+
if (!dead && (running || s2.autofillDraggingTo != null || s2.dragging)) {
|
|
1627
|
+
finish();
|
|
1628
|
+
}
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
cx = e.clientX;
|
|
1632
|
+
cy = e.clientY;
|
|
1633
|
+
const { store: s } = dragRef.current;
|
|
1634
|
+
if (!dead && !running && (s.dragging || s.autofillDraggingTo)) {
|
|
1635
|
+
running = true;
|
|
1636
|
+
lastCell = "";
|
|
1637
|
+
raf = requestAnimationFrame(tick);
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
const onDown = () => {
|
|
1641
|
+
dead = false;
|
|
1642
|
+
};
|
|
1643
|
+
const onUp = () => {
|
|
1644
|
+
dead = true;
|
|
1645
|
+
stop();
|
|
1646
|
+
const { store: s, dispatch: d } = dragRef.current;
|
|
1647
|
+
if (s.autofillDraggingTo) {
|
|
1648
|
+
d(submitAutofill(s.autofillDraggingTo));
|
|
1649
|
+
}
|
|
1650
|
+
if (s.dragging) {
|
|
1651
|
+
d(setDragging(false));
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
const onLeaveWindow = () => finish();
|
|
1655
|
+
window.addEventListener("mousedown", onDown, true);
|
|
1656
|
+
window.addEventListener("mousemove", onMove, true);
|
|
1657
|
+
window.addEventListener("mouseup", onUp, true);
|
|
1658
|
+
window.addEventListener("blur", onLeaveWindow);
|
|
1659
|
+
document.addEventListener("mouseleave", onLeaveWindow);
|
|
1660
|
+
return () => {
|
|
1661
|
+
window.removeEventListener("mousedown", onDown, true);
|
|
1662
|
+
window.removeEventListener("mousemove", onMove, true);
|
|
1663
|
+
window.removeEventListener("mouseup", onUp, true);
|
|
1664
|
+
window.removeEventListener("blur", onLeaveWindow);
|
|
1665
|
+
document.removeEventListener("mouseleave", onLeaveWindow);
|
|
1666
|
+
cancelAnimationFrame(raf);
|
|
1667
|
+
};
|
|
1668
|
+
}, []);
|
|
1504
1669
|
useEffect(() => {
|
|
1505
1670
|
if (!sheet) {
|
|
1506
1671
|
return;
|
|
@@ -1591,30 +1756,30 @@ const Resizer = () => {
|
|
|
1591
1756
|
}
|
|
1592
1757
|
const cell = sheet.getCell({ y: y === -1 ? 0 : y, x: x === -1 ? 0 : x }, { resolution: "SYSTEM" });
|
|
1593
1758
|
const { y: offsetY, x: offsetX } = mainRef.current.getBoundingClientRect();
|
|
1594
|
-
const baseWidth = (cell == null ? void 0 : cell.width) ||
|
|
1595
|
-
const baseHeight = (cell == null ? void 0 : cell.height) ||
|
|
1759
|
+
const baseWidth = (cell == null ? void 0 : cell.width) || he;
|
|
1760
|
+
const baseHeight = (cell == null ? void 0 : cell.height) || rt;
|
|
1596
1761
|
const width = baseWidth + (endX - startX);
|
|
1597
1762
|
const height = baseHeight + (endY - startY);
|
|
1598
1763
|
const handleResizeEnd = () => {
|
|
1599
|
-
const selectingArea =
|
|
1764
|
+
const selectingArea = ks(selectingZone);
|
|
1600
1765
|
const { top, left, bottom, right } = selectingArea;
|
|
1601
1766
|
const diff = {};
|
|
1602
1767
|
if (x !== -1) {
|
|
1603
1768
|
let xs = [x];
|
|
1604
|
-
if (topHeaderSelecting &&
|
|
1605
|
-
xs =
|
|
1769
|
+
if (topHeaderSelecting && nn({ start: left, end: right }, x)) {
|
|
1770
|
+
xs = cn(left, right + 1);
|
|
1606
1771
|
}
|
|
1607
1772
|
xs.forEach((x2) => {
|
|
1608
|
-
diff[
|
|
1773
|
+
diff[M({ y: 0, x: x2 })] = { width };
|
|
1609
1774
|
});
|
|
1610
1775
|
}
|
|
1611
1776
|
if (y !== -1) {
|
|
1612
1777
|
let ys = [y];
|
|
1613
|
-
if (leftHeaderSelecting &&
|
|
1614
|
-
ys =
|
|
1778
|
+
if (leftHeaderSelecting && nn({ start: top, end: bottom }, y)) {
|
|
1779
|
+
ys = cn(top, bottom + 1);
|
|
1615
1780
|
}
|
|
1616
1781
|
ys.forEach((y2) => {
|
|
1617
|
-
diff[
|
|
1782
|
+
diff[M({ y: y2, x: 0 })] = { height };
|
|
1618
1783
|
});
|
|
1619
1784
|
}
|
|
1620
1785
|
sheet.update({
|
|
@@ -1630,21 +1795,21 @@ const Resizer = () => {
|
|
|
1630
1795
|
);
|
|
1631
1796
|
dispatch(setResizingPositionY([-1, -1, -1]));
|
|
1632
1797
|
dispatch(setResizingPositionX([-1, -1, -1]));
|
|
1633
|
-
|
|
1798
|
+
_(editorRef.current);
|
|
1634
1799
|
};
|
|
1635
1800
|
const handleResizeMove = (e) => {
|
|
1636
1801
|
if (y !== -1) {
|
|
1637
1802
|
let endY2 = e.clientY;
|
|
1638
1803
|
const height2 = baseHeight + (endY2 - startY);
|
|
1639
|
-
if (height2 <
|
|
1640
|
-
endY2 +=
|
|
1804
|
+
if (height2 < qr) {
|
|
1805
|
+
endY2 += qr - height2;
|
|
1641
1806
|
}
|
|
1642
1807
|
dispatch(setResizingPositionY([y, startY, endY2]));
|
|
1643
1808
|
} else if (x !== -1) {
|
|
1644
1809
|
let endX2 = e.clientX;
|
|
1645
1810
|
const width2 = baseWidth + (endX2 - startX);
|
|
1646
|
-
if (width2 <
|
|
1647
|
-
endX2 +=
|
|
1811
|
+
if (width2 < Zr) {
|
|
1812
|
+
endX2 += Zr - width2;
|
|
1648
1813
|
}
|
|
1649
1814
|
dispatch(setResizingPositionX([x, startX, endX2]));
|
|
1650
1815
|
}
|
|
@@ -1701,14 +1866,14 @@ const Emitter = () => {
|
|
|
1701
1866
|
const copier = async ({ store, dispatch }) => {
|
|
1702
1867
|
const { editorRef } = store;
|
|
1703
1868
|
const area = clip(store);
|
|
1704
|
-
dispatch(copy(
|
|
1705
|
-
|
|
1869
|
+
dispatch(copy(Pe(area)));
|
|
1870
|
+
_(editorRef.current);
|
|
1706
1871
|
};
|
|
1707
1872
|
const cutter = async ({ store, dispatch }) => {
|
|
1708
1873
|
const { editorRef } = store;
|
|
1709
1874
|
const area = clip(store);
|
|
1710
|
-
dispatch(cut(
|
|
1711
|
-
|
|
1875
|
+
dispatch(cut(Pe(area)));
|
|
1876
|
+
_(editorRef.current);
|
|
1712
1877
|
};
|
|
1713
1878
|
const paster = async ({ store, dispatch }, onlyValue = false) => {
|
|
1714
1879
|
const { editorRef } = store;
|
|
@@ -1733,59 +1898,59 @@ const paster = async ({ store, dispatch }, onlyValue = false) => {
|
|
|
1733
1898
|
}
|
|
1734
1899
|
}
|
|
1735
1900
|
dispatch(paste({ matrix: cells, onlyValue }));
|
|
1736
|
-
|
|
1901
|
+
_(editorRef.current);
|
|
1737
1902
|
};
|
|
1738
1903
|
const undoer = async ({ store, dispatch }) => {
|
|
1739
1904
|
const { editorRef } = store;
|
|
1740
1905
|
dispatch(undo(null));
|
|
1741
|
-
|
|
1906
|
+
_(editorRef.current);
|
|
1742
1907
|
};
|
|
1743
1908
|
const redoer = async ({ store, dispatch }) => {
|
|
1744
1909
|
const { editorRef } = store;
|
|
1745
1910
|
dispatch(redo(null));
|
|
1746
|
-
|
|
1911
|
+
_(editorRef.current);
|
|
1747
1912
|
};
|
|
1748
1913
|
const rowsInserterAbove = async ({ store, dispatch }) => {
|
|
1749
1914
|
const { selectingZone, editorRef } = store;
|
|
1750
|
-
const { top } =
|
|
1751
|
-
const numRows =
|
|
1915
|
+
const { top } = ks(selectingZone);
|
|
1916
|
+
const numRows = an(selectingZone).rows;
|
|
1752
1917
|
dispatch(insertRowsAbove({ numRows, y: top, operator: "USER" }));
|
|
1753
|
-
|
|
1918
|
+
_(editorRef.current);
|
|
1754
1919
|
};
|
|
1755
1920
|
const rowsInserterBelow = async ({ store, dispatch }) => {
|
|
1756
1921
|
const { selectingZone, editorRef } = store;
|
|
1757
|
-
const { bottom } =
|
|
1758
|
-
const numRows =
|
|
1922
|
+
const { bottom } = ks(selectingZone);
|
|
1923
|
+
const numRows = an(selectingZone).rows;
|
|
1759
1924
|
dispatch(insertRowsBelow({ numRows, y: bottom, operator: "USER" }));
|
|
1760
|
-
|
|
1925
|
+
_(editorRef.current);
|
|
1761
1926
|
};
|
|
1762
1927
|
const colsInserterLeft = async ({ store, dispatch }) => {
|
|
1763
1928
|
const { selectingZone, editorRef } = store;
|
|
1764
|
-
const { left } =
|
|
1765
|
-
const numCols =
|
|
1929
|
+
const { left } = ks(selectingZone);
|
|
1930
|
+
const numCols = an(selectingZone).cols;
|
|
1766
1931
|
dispatch(insertColsLeft({ numCols, x: left, operator: "USER" }));
|
|
1767
|
-
|
|
1932
|
+
_(editorRef.current);
|
|
1768
1933
|
};
|
|
1769
1934
|
const colsInserterRight = async ({ store, dispatch }) => {
|
|
1770
1935
|
const { selectingZone, editorRef } = store;
|
|
1771
|
-
const { right } =
|
|
1772
|
-
const numCols =
|
|
1936
|
+
const { right } = ks(selectingZone);
|
|
1937
|
+
const numCols = an(selectingZone).cols;
|
|
1773
1938
|
dispatch(insertColsRight({ numCols, x: right, operator: "USER" }));
|
|
1774
|
-
|
|
1939
|
+
_(editorRef.current);
|
|
1775
1940
|
};
|
|
1776
1941
|
const rowsRemover = async ({ store, dispatch }) => {
|
|
1777
1942
|
const { selectingZone, editorRef } = store;
|
|
1778
|
-
const { top } =
|
|
1779
|
-
const numRows =
|
|
1943
|
+
const { top } = ks(selectingZone);
|
|
1944
|
+
const numRows = an(selectingZone).rows;
|
|
1780
1945
|
dispatch(removeRows({ numRows, y: top, operator: "USER" }));
|
|
1781
|
-
|
|
1946
|
+
_(editorRef.current);
|
|
1782
1947
|
};
|
|
1783
1948
|
const colsRemover = async ({ store, dispatch }) => {
|
|
1784
1949
|
const { selectingZone, editorRef } = store;
|
|
1785
|
-
const { left } =
|
|
1786
|
-
const numCols =
|
|
1950
|
+
const { left } = ks(selectingZone);
|
|
1951
|
+
const numCols = an(selectingZone).cols;
|
|
1787
1952
|
dispatch(removeCols({ numCols, x: left, operator: "USER" }));
|
|
1788
|
-
|
|
1953
|
+
_(editorRef.current);
|
|
1789
1954
|
};
|
|
1790
1955
|
const rowsSorterAsc = async ({ store, dispatch }, x) => {
|
|
1791
1956
|
const sheet = store.sheetReactive.current;
|
|
@@ -1793,7 +1958,7 @@ const rowsSorterAsc = async ({ store, dispatch }, x) => {
|
|
|
1793
1958
|
await sheet.waitForPending();
|
|
1794
1959
|
}
|
|
1795
1960
|
dispatch(sortRows({ x, direction: "asc" }));
|
|
1796
|
-
|
|
1961
|
+
_(store.editorRef.current);
|
|
1797
1962
|
};
|
|
1798
1963
|
const rowsSorterDesc = async ({ store, dispatch }, x) => {
|
|
1799
1964
|
const sheet = store.sheetReactive.current;
|
|
@@ -1801,7 +1966,7 @@ const rowsSorterDesc = async ({ store, dispatch }, x) => {
|
|
|
1801
1966
|
await sheet.waitForPending();
|
|
1802
1967
|
}
|
|
1803
1968
|
dispatch(sortRows({ x, direction: "desc" }));
|
|
1804
|
-
|
|
1969
|
+
_(store.editorRef.current);
|
|
1805
1970
|
};
|
|
1806
1971
|
const rowsFilterer = async ({ store, dispatch }, x, filter) => {
|
|
1807
1972
|
const sheet = store.sheetReactive.current;
|
|
@@ -1809,42 +1974,42 @@ const rowsFilterer = async ({ store, dispatch }, x, filter) => {
|
|
|
1809
1974
|
await sheet.waitForPending();
|
|
1810
1975
|
}
|
|
1811
1976
|
dispatch(filterRows({ x, filter }));
|
|
1812
|
-
|
|
1977
|
+
_(store.editorRef.current);
|
|
1813
1978
|
};
|
|
1814
1979
|
const rowsFilterClearer = async ({ store, dispatch }, x) => {
|
|
1815
1980
|
dispatch(filterRows({ x }));
|
|
1816
|
-
|
|
1981
|
+
_(store.editorRef.current);
|
|
1817
1982
|
};
|
|
1818
1983
|
const rowSortFixedToggler = ({ store, dispatch }, y) => {
|
|
1819
1984
|
const sheet = store.sheetReactive.current;
|
|
1820
1985
|
if (!sheet) {
|
|
1821
1986
|
return;
|
|
1822
1987
|
}
|
|
1823
|
-
const addr =
|
|
1988
|
+
const addr = M({ y, x: 0 });
|
|
1824
1989
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
1825
1990
|
const next = !(rowCell == null ? void 0 : rowCell.sortFixed) || void 0;
|
|
1826
1991
|
sheet.update({ diff: { [addr]: { sortFixed: next } }, partial: true });
|
|
1827
1992
|
dispatch(updateSheet(sheet));
|
|
1828
|
-
|
|
1993
|
+
_(store.editorRef.current);
|
|
1829
1994
|
};
|
|
1830
1995
|
const rowFilterFixedToggler = ({ store, dispatch }, y) => {
|
|
1831
1996
|
const sheet = store.sheetReactive.current;
|
|
1832
1997
|
if (!sheet) {
|
|
1833
1998
|
return;
|
|
1834
1999
|
}
|
|
1835
|
-
const addr =
|
|
2000
|
+
const addr = M({ y, x: 0 });
|
|
1836
2001
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
1837
2002
|
const next = !(rowCell == null ? void 0 : rowCell.filterFixed) || void 0;
|
|
1838
2003
|
sheet.update({ diff: { [addr]: { filterFixed: next } }, partial: true });
|
|
1839
2004
|
dispatch(updateSheet(sheet));
|
|
1840
|
-
|
|
2005
|
+
_(store.editorRef.current);
|
|
1841
2006
|
};
|
|
1842
2007
|
const searcher = async ({ store, dispatch }) => {
|
|
1843
2008
|
if (typeof store.searchQuery === "undefined") {
|
|
1844
2009
|
dispatch(setSearchQuery(""));
|
|
1845
2010
|
}
|
|
1846
2011
|
dispatch(setEntering(false));
|
|
1847
|
-
requestAnimationFrame(() =>
|
|
2012
|
+
requestAnimationFrame(() => _(store.searchInputRef.current));
|
|
1848
2013
|
};
|
|
1849
2014
|
const applyers = {
|
|
1850
2015
|
copy: copier,
|
|
@@ -1909,92 +2074,92 @@ const defaultContextMenuDescriptors = [
|
|
|
1909
2074
|
{
|
|
1910
2075
|
id: "insert-rows-above",
|
|
1911
2076
|
label: (ctx) => {
|
|
1912
|
-
const n =
|
|
2077
|
+
const n = an(ctx.selectingZone).rows;
|
|
1913
2078
|
return `Insert ${n} row${n > 1 ? "s" : ""} above`;
|
|
1914
2079
|
},
|
|
1915
2080
|
visible: (ctx) => ctx.leftHeaderSelecting,
|
|
1916
2081
|
disabled: (ctx) => {
|
|
1917
|
-
const n =
|
|
2082
|
+
const n = an(ctx.selectingZone).rows;
|
|
1918
2083
|
const sheet = ctx.sheet;
|
|
1919
2084
|
const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
|
|
1920
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
2085
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsAbove);
|
|
1921
2086
|
},
|
|
1922
|
-
onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y,
|
|
2087
|
+
onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, an(ctx.selectingZone).rows)
|
|
1923
2088
|
},
|
|
1924
2089
|
{
|
|
1925
2090
|
id: "insert-rows-below",
|
|
1926
2091
|
label: (ctx) => {
|
|
1927
|
-
const n =
|
|
2092
|
+
const n = an(ctx.selectingZone).rows;
|
|
1928
2093
|
return `Insert ${n} row${n > 1 ? "s" : ""} below`;
|
|
1929
2094
|
},
|
|
1930
2095
|
visible: (ctx) => ctx.leftHeaderSelecting,
|
|
1931
2096
|
disabled: (ctx) => {
|
|
1932
|
-
const n =
|
|
2097
|
+
const n = an(ctx.selectingZone).rows;
|
|
1933
2098
|
const sheet = ctx.sheet;
|
|
1934
2099
|
const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
|
|
1935
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
2100
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsBelow);
|
|
1936
2101
|
},
|
|
1937
|
-
onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y,
|
|
2102
|
+
onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, an(ctx.selectingZone).rows)
|
|
1938
2103
|
},
|
|
1939
2104
|
{
|
|
1940
2105
|
id: "insert-cols-left",
|
|
1941
2106
|
label: (ctx) => {
|
|
1942
|
-
const n =
|
|
2107
|
+
const n = an(ctx.selectingZone).cols;
|
|
1943
2108
|
return `Insert ${n} column${n > 1 ? "s" : ""} left`;
|
|
1944
2109
|
},
|
|
1945
2110
|
visible: (ctx) => ctx.topHeaderSelecting,
|
|
1946
2111
|
disabled: (ctx) => {
|
|
1947
|
-
const n =
|
|
2112
|
+
const n = an(ctx.selectingZone).cols;
|
|
1948
2113
|
const sheet = ctx.sheet;
|
|
1949
2114
|
const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
|
|
1950
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
2115
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsLeft);
|
|
1951
2116
|
},
|
|
1952
|
-
onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x,
|
|
2117
|
+
onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, an(ctx.selectingZone).cols)
|
|
1953
2118
|
},
|
|
1954
2119
|
{
|
|
1955
2120
|
id: "insert-cols-right",
|
|
1956
2121
|
label: (ctx) => {
|
|
1957
|
-
const n =
|
|
2122
|
+
const n = an(ctx.selectingZone).cols;
|
|
1958
2123
|
return `Insert ${n} column${n > 1 ? "s" : ""} right`;
|
|
1959
2124
|
},
|
|
1960
2125
|
visible: (ctx) => ctx.topHeaderSelecting,
|
|
1961
2126
|
disabled: (ctx) => {
|
|
1962
|
-
const n =
|
|
2127
|
+
const n = an(ctx.selectingZone).cols;
|
|
1963
2128
|
const sheet = ctx.sheet;
|
|
1964
2129
|
const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
|
|
1965
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
2130
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsRight);
|
|
1966
2131
|
},
|
|
1967
|
-
onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x,
|
|
2132
|
+
onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, an(ctx.selectingZone).cols)
|
|
1968
2133
|
},
|
|
1969
2134
|
{
|
|
1970
2135
|
id: "remove-rows",
|
|
1971
2136
|
label: (ctx) => {
|
|
1972
|
-
const n =
|
|
2137
|
+
const n = an(ctx.selectingZone).rows;
|
|
1973
2138
|
return `Remove ${n} row${n > 1 ? "s" : ""}`;
|
|
1974
2139
|
},
|
|
1975
2140
|
visible: (ctx) => ctx.leftHeaderSelecting,
|
|
1976
2141
|
disabled: (ctx) => {
|
|
1977
|
-
const n =
|
|
2142
|
+
const n = an(ctx.selectingZone).rows;
|
|
1978
2143
|
const sheet = ctx.sheet;
|
|
1979
2144
|
const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
|
|
1980
|
-
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows ||
|
|
2145
|
+
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.RemoveRows);
|
|
1981
2146
|
},
|
|
1982
|
-
onClick: (ctx) => ctx.removeRows(ctx.choosing.y,
|
|
2147
|
+
onClick: (ctx) => ctx.removeRows(ctx.choosing.y, an(ctx.selectingZone).rows)
|
|
1983
2148
|
},
|
|
1984
2149
|
{
|
|
1985
2150
|
id: "remove-cols",
|
|
1986
2151
|
label: (ctx) => {
|
|
1987
|
-
const n =
|
|
2152
|
+
const n = an(ctx.selectingZone).cols;
|
|
1988
2153
|
return `Remove ${n} column${n > 1 ? "s" : ""}`;
|
|
1989
2154
|
},
|
|
1990
2155
|
visible: (ctx) => ctx.topHeaderSelecting,
|
|
1991
2156
|
disabled: (ctx) => {
|
|
1992
|
-
const n =
|
|
2157
|
+
const n = an(ctx.selectingZone).cols;
|
|
1993
2158
|
const sheet = ctx.sheet;
|
|
1994
2159
|
const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
|
|
1995
|
-
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols ||
|
|
2160
|
+
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.RemoveCols);
|
|
1996
2161
|
},
|
|
1997
|
-
onClick: (ctx) => ctx.removeCols(ctx.choosing.x,
|
|
2162
|
+
onClick: (ctx) => ctx.removeCols(ctx.choosing.x, an(ctx.selectingZone).cols)
|
|
1998
2163
|
},
|
|
1999
2164
|
{ type: "divider" },
|
|
2000
2165
|
{
|
|
@@ -2055,7 +2220,7 @@ const defaultRowMenuDescriptors = [
|
|
|
2055
2220
|
const n = rowInsertCount(ctx, y);
|
|
2056
2221
|
const sheet = ctx.sheet;
|
|
2057
2222
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
2058
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
2223
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsAbove);
|
|
2059
2224
|
},
|
|
2060
2225
|
onClick: (ctx, y) => ctx.insertRowsAbove(y, rowInsertCount(ctx, y))
|
|
2061
2226
|
},
|
|
@@ -2069,7 +2234,7 @@ const defaultRowMenuDescriptors = [
|
|
|
2069
2234
|
const n = rowInsertCount(ctx, y);
|
|
2070
2235
|
const sheet = ctx.sheet;
|
|
2071
2236
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
2072
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
2237
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsBelow);
|
|
2073
2238
|
},
|
|
2074
2239
|
onClick: (ctx, y) => ctx.insertRowsBelow(y, rowInsertCount(ctx, y))
|
|
2075
2240
|
},
|
|
@@ -2083,7 +2248,7 @@ const defaultRowMenuDescriptors = [
|
|
|
2083
2248
|
const n = rowInsertCount(ctx, y);
|
|
2084
2249
|
const sheet = ctx.sheet;
|
|
2085
2250
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
2086
|
-
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows ||
|
|
2251
|
+
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.RemoveRows);
|
|
2087
2252
|
},
|
|
2088
2253
|
onClick: (ctx, y) => ctx.removeRows(y, rowInsertCount(ctx, y))
|
|
2089
2254
|
},
|
|
@@ -2115,6 +2280,8 @@ const defaultRowMenuDescriptors = [
|
|
|
2115
2280
|
}
|
|
2116
2281
|
];
|
|
2117
2282
|
const defaultColMenuDescriptors = [
|
|
2283
|
+
{ type: "component", componentId: "col-label" },
|
|
2284
|
+
{ type: "divider" },
|
|
2118
2285
|
{ type: "component", componentId: "col-filter" },
|
|
2119
2286
|
{ type: "divider" },
|
|
2120
2287
|
{ type: "component", componentId: "col-sort" },
|
|
@@ -2154,7 +2321,7 @@ const defaultColMenuDescriptors = [
|
|
|
2154
2321
|
const n = colInsertCount(ctx, x);
|
|
2155
2322
|
const sheet = ctx.sheet;
|
|
2156
2323
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2157
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
2324
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsLeft);
|
|
2158
2325
|
},
|
|
2159
2326
|
onClick: (ctx, x) => ctx.insertColsLeft(x, colInsertCount(ctx, x))
|
|
2160
2327
|
},
|
|
@@ -2168,7 +2335,7 @@ const defaultColMenuDescriptors = [
|
|
|
2168
2335
|
const n = colInsertCount(ctx, x);
|
|
2169
2336
|
const sheet = ctx.sheet;
|
|
2170
2337
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2171
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
2338
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsRight);
|
|
2172
2339
|
},
|
|
2173
2340
|
onClick: (ctx, x) => ctx.insertColsRight(x, colInsertCount(ctx, x))
|
|
2174
2341
|
},
|
|
@@ -2182,7 +2349,7 @@ const defaultColMenuDescriptors = [
|
|
|
2182
2349
|
const n = colInsertCount(ctx, x);
|
|
2183
2350
|
const sheet = ctx.sheet;
|
|
2184
2351
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2185
|
-
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols ||
|
|
2352
|
+
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.RemoveCols);
|
|
2186
2353
|
},
|
|
2187
2354
|
onClick: (ctx, x) => ctx.removeCols(x, colInsertCount(ctx, x))
|
|
2188
2355
|
},
|
|
@@ -2192,9 +2359,7 @@ const defaultColMenuDescriptors = [
|
|
|
2192
2359
|
label: "Search",
|
|
2193
2360
|
shortcuts: ["F"],
|
|
2194
2361
|
onClick: (ctx) => ctx.search()
|
|
2195
|
-
}
|
|
2196
|
-
{ type: "divider" },
|
|
2197
|
-
{ type: "component", componentId: "col-label" }
|
|
2362
|
+
}
|
|
2198
2363
|
];
|
|
2199
2364
|
function buildMenuContext(store, dispatch, close) {
|
|
2200
2365
|
const props = { store, dispatch };
|
|
@@ -2250,7 +2415,7 @@ function buildMenuContext(store, dispatch, close) {
|
|
|
2250
2415
|
if (!sheet) {
|
|
2251
2416
|
return;
|
|
2252
2417
|
}
|
|
2253
|
-
const addr =
|
|
2418
|
+
const addr = M({ y: 0, x });
|
|
2254
2419
|
sheet.update({
|
|
2255
2420
|
diff: { [addr]: { label: label || void 0 } },
|
|
2256
2421
|
partial: true,
|
|
@@ -2312,6 +2477,129 @@ const MenuItem = ({
|
|
|
2312
2477
|
);
|
|
2313
2478
|
};
|
|
2314
2479
|
const MenuDivider = () => /* @__PURE__ */ jsx("li", { className: "gs-menu-divider" });
|
|
2480
|
+
const MenuNodes = ({ items, ctx, args, onSelect, renderComponent }) => {
|
|
2481
|
+
return /* @__PURE__ */ jsx(Fragment, { children: items.map((d, i) => {
|
|
2482
|
+
var _a, _b;
|
|
2483
|
+
if (d.type === "divider") {
|
|
2484
|
+
if (d.visible && !d.visible(ctx, ...args)) {
|
|
2485
|
+
return null;
|
|
2486
|
+
}
|
|
2487
|
+
return /* @__PURE__ */ jsx(MenuDivider, {}, i);
|
|
2488
|
+
}
|
|
2489
|
+
if (d.type === "component") {
|
|
2490
|
+
if (d.visible && !d.visible(ctx, ...args)) {
|
|
2491
|
+
return null;
|
|
2492
|
+
}
|
|
2493
|
+
return renderComponent && d.componentId ? renderComponent(d.componentId, i) : null;
|
|
2494
|
+
}
|
|
2495
|
+
if (d.visible && !d.visible(ctx, ...args)) {
|
|
2496
|
+
return null;
|
|
2497
|
+
}
|
|
2498
|
+
const label = typeof d.label === "function" ? d.label(ctx, ...args) : d.label ?? "";
|
|
2499
|
+
const disabled = ((_a = d.disabled) == null ? void 0 : _a.call(d, ctx, ...args)) ?? false;
|
|
2500
|
+
if (d.type === "submenu") {
|
|
2501
|
+
return /* @__PURE__ */ jsx(
|
|
2502
|
+
SubmenuNode,
|
|
2503
|
+
{
|
|
2504
|
+
label,
|
|
2505
|
+
disabled,
|
|
2506
|
+
testId: d.id,
|
|
2507
|
+
items: d.children ?? [],
|
|
2508
|
+
ctx,
|
|
2509
|
+
args,
|
|
2510
|
+
onSelect,
|
|
2511
|
+
renderComponent
|
|
2512
|
+
},
|
|
2513
|
+
i
|
|
2514
|
+
);
|
|
2515
|
+
}
|
|
2516
|
+
const shortcuts = typeof d.shortcuts === "function" ? d.shortcuts(ctx, ...args) : d.shortcuts;
|
|
2517
|
+
const checked = (_b = d.checked) == null ? void 0 : _b.call(d, ctx, ...args);
|
|
2518
|
+
return /* @__PURE__ */ jsx(
|
|
2519
|
+
MenuItem,
|
|
2520
|
+
{
|
|
2521
|
+
label,
|
|
2522
|
+
shortcuts,
|
|
2523
|
+
disabled,
|
|
2524
|
+
checked,
|
|
2525
|
+
testId: d.id ? `${d.id}-item` : void 0,
|
|
2526
|
+
onClick: () => {
|
|
2527
|
+
var _a2;
|
|
2528
|
+
(_a2 = d.onClick) == null ? void 0 : _a2.call(d, ctx, ...args);
|
|
2529
|
+
onSelect();
|
|
2530
|
+
}
|
|
2531
|
+
},
|
|
2532
|
+
i
|
|
2533
|
+
);
|
|
2534
|
+
}) });
|
|
2535
|
+
};
|
|
2536
|
+
const SubmenuNode = ({ label, disabled, testId, items, ctx, args, onSelect, renderComponent }) => {
|
|
2537
|
+
const [open, setOpen] = useState(false);
|
|
2538
|
+
const liRef = useRef(null);
|
|
2539
|
+
const flyoutRef = useRef(null);
|
|
2540
|
+
const [pos, setPos] = useState(null);
|
|
2541
|
+
useLayoutEffect(() => {
|
|
2542
|
+
if (!open || disabled) {
|
|
2543
|
+
setPos(null);
|
|
2544
|
+
return;
|
|
2545
|
+
}
|
|
2546
|
+
const li = liRef.current;
|
|
2547
|
+
const fly = flyoutRef.current;
|
|
2548
|
+
if (!li || !fly) {
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
const p = li.getBoundingClientRect();
|
|
2552
|
+
const f = fly.getBoundingClientRect();
|
|
2553
|
+
const margin = 6;
|
|
2554
|
+
let left = p.right;
|
|
2555
|
+
if (left + f.width > window.innerWidth - margin) {
|
|
2556
|
+
left = p.left - f.width;
|
|
2557
|
+
if (left < margin) {
|
|
2558
|
+
left = Math.max(margin, window.innerWidth - f.width - margin);
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
let top = p.top;
|
|
2562
|
+
if (top + f.height > window.innerHeight - margin) {
|
|
2563
|
+
top = window.innerHeight - f.height - margin;
|
|
2564
|
+
}
|
|
2565
|
+
if (top < margin) {
|
|
2566
|
+
top = margin;
|
|
2567
|
+
}
|
|
2568
|
+
setPos({ left, top });
|
|
2569
|
+
}, [open, disabled]);
|
|
2570
|
+
return /* @__PURE__ */ jsxs(
|
|
2571
|
+
"li",
|
|
2572
|
+
{
|
|
2573
|
+
ref: liRef,
|
|
2574
|
+
className: `gs-menu-item gs-submenu-parent ${disabled ? "gs-disabled" : "gs-enabled"}`,
|
|
2575
|
+
"data-testid": testId ? `${testId}-item` : void 0,
|
|
2576
|
+
onMouseEnter: () => setOpen(true),
|
|
2577
|
+
onMouseLeave: () => setOpen(false),
|
|
2578
|
+
onClick: (e) => {
|
|
2579
|
+
e.stopPropagation();
|
|
2580
|
+
setOpen(true);
|
|
2581
|
+
},
|
|
2582
|
+
children: [
|
|
2583
|
+
/* @__PURE__ */ jsx("div", { className: "gs-menu-name", children: label }),
|
|
2584
|
+
/* @__PURE__ */ jsx("span", { className: "gs-submenu-arrow", children: "▸" }),
|
|
2585
|
+
open && !disabled && /* @__PURE__ */ jsx(
|
|
2586
|
+
"ul",
|
|
2587
|
+
{
|
|
2588
|
+
ref: flyoutRef,
|
|
2589
|
+
className: "gs-menu-items gs-submenu-flyout",
|
|
2590
|
+
style: {
|
|
2591
|
+
position: "fixed",
|
|
2592
|
+
left: pos ? pos.left : -9999,
|
|
2593
|
+
top: pos ? pos.top : -9999,
|
|
2594
|
+
visibility: pos ? "visible" : "hidden"
|
|
2595
|
+
},
|
|
2596
|
+
children: /* @__PURE__ */ jsx(MenuNodes, { items, ctx, args, onSelect, renderComponent })
|
|
2597
|
+
}
|
|
2598
|
+
)
|
|
2599
|
+
]
|
|
2600
|
+
}
|
|
2601
|
+
);
|
|
2602
|
+
};
|
|
2315
2603
|
const ContextMenu = () => {
|
|
2316
2604
|
const { store, dispatch } = useContext(Context);
|
|
2317
2605
|
const { contextMenuPosition, contextMenu } = store;
|
|
@@ -2319,7 +2607,7 @@ const ContextMenu = () => {
|
|
|
2319
2607
|
const menuRef = useRef(null);
|
|
2320
2608
|
useEffect(() => {
|
|
2321
2609
|
if (menuRef.current) {
|
|
2322
|
-
|
|
2610
|
+
ue(menuRef.current);
|
|
2323
2611
|
}
|
|
2324
2612
|
});
|
|
2325
2613
|
if (top === -1) {
|
|
@@ -2336,38 +2624,7 @@ const ContextMenu = () => {
|
|
|
2336
2624
|
close();
|
|
2337
2625
|
return false;
|
|
2338
2626
|
},
|
|
2339
|
-
children: /* @__PURE__ */ jsx("div", { ref: menuRef, className: "gs-context-menu", style: { top, left }, children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children:
|
|
2340
|
-
var _a, _b;
|
|
2341
|
-
if (d.type === "divider") {
|
|
2342
|
-
if (d.visible && !d.visible(ctx)) {
|
|
2343
|
-
return null;
|
|
2344
|
-
}
|
|
2345
|
-
return /* @__PURE__ */ jsx(MenuDivider, {}, i);
|
|
2346
|
-
}
|
|
2347
|
-
if (d.type === "component") {
|
|
2348
|
-
return null;
|
|
2349
|
-
}
|
|
2350
|
-
const visible = !d.visible || d.visible(ctx);
|
|
2351
|
-
if (!visible) {
|
|
2352
|
-
return null;
|
|
2353
|
-
}
|
|
2354
|
-
const disabled = ((_a = d.disabled) == null ? void 0 : _a.call(d, ctx)) ?? false;
|
|
2355
|
-
const label = typeof d.label === "function" ? d.label(ctx) : d.label;
|
|
2356
|
-
const shortcuts = typeof d.shortcuts === "function" ? d.shortcuts(ctx) : d.shortcuts;
|
|
2357
|
-
const checked = (_b = d.checked) == null ? void 0 : _b.call(d, ctx);
|
|
2358
|
-
return /* @__PURE__ */ jsx(
|
|
2359
|
-
MenuItem,
|
|
2360
|
-
{
|
|
2361
|
-
label,
|
|
2362
|
-
shortcuts,
|
|
2363
|
-
disabled,
|
|
2364
|
-
checked,
|
|
2365
|
-
testId: d.id ? `${d.id}-item` : void 0,
|
|
2366
|
-
onClick: () => d.onClick(ctx)
|
|
2367
|
-
},
|
|
2368
|
-
i
|
|
2369
|
-
);
|
|
2370
|
-
}) }) })
|
|
2627
|
+
children: /* @__PURE__ */ jsx("div", { ref: menuRef, className: "gs-context-menu", style: { top, left }, children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: /* @__PURE__ */ jsx(MenuNodes, { items: contextMenu, ctx, args: [], onSelect: close }) }) })
|
|
2371
2628
|
}
|
|
2372
2629
|
);
|
|
2373
2630
|
};
|
|
@@ -2472,7 +2729,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
|
|
|
2472
2729
|
if (prev.length <= 1) {
|
|
2473
2730
|
return [{ ...DEFAULT_CONDITION, value: [""] }];
|
|
2474
2731
|
}
|
|
2475
|
-
return prev.filter((
|
|
2732
|
+
return prev.filter((_2, i) => i !== index);
|
|
2476
2733
|
});
|
|
2477
2734
|
}, []);
|
|
2478
2735
|
const handleApplyFilter = useCallback(() => {
|
|
@@ -2498,7 +2755,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
|
|
|
2498
2755
|
return null;
|
|
2499
2756
|
}
|
|
2500
2757
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2501
|
-
const filterDisabled =
|
|
2758
|
+
const filterDisabled = Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.Filter);
|
|
2502
2759
|
const hasAnyFilter = sheet.hasActiveFilters();
|
|
2503
2760
|
return /* @__PURE__ */ jsx("li", { className: `gs-column-menu-filter${filterDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2504
2761
|
/* @__PURE__ */ jsxs("div", { className: "gs-filter-header", children: [
|
|
@@ -2637,7 +2894,7 @@ const SortSection = ({ x, close, onWaiting }) => {
|
|
|
2637
2894
|
return null;
|
|
2638
2895
|
}
|
|
2639
2896
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2640
|
-
const sortDisabled =
|
|
2897
|
+
const sortDisabled = Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.Sort);
|
|
2641
2898
|
return /* @__PURE__ */ jsxs("li", { className: `gs-menu-item gs-column-menu-sort${sortDisabled ? " gs-disabled" : ""}`, children: [
|
|
2642
2899
|
/* @__PURE__ */ jsx("div", { className: "gs-menu-name", children: "Sort:" }),
|
|
2643
2900
|
/* @__PURE__ */ jsxs("div", { className: "gs-sort-buttons", children: [
|
|
@@ -2680,16 +2937,28 @@ const LabelSection = ({ x, close }) => {
|
|
|
2680
2937
|
const labelInputRef = useRef(null);
|
|
2681
2938
|
const [label, setLabel] = useState("");
|
|
2682
2939
|
useEffect(() => {
|
|
2940
|
+
var _a;
|
|
2683
2941
|
if (sheet) {
|
|
2684
2942
|
const colCell2 = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2685
2943
|
setLabel((colCell2 == null ? void 0 : colCell2.label) ?? "");
|
|
2686
2944
|
}
|
|
2945
|
+
if ((_a = store.columnMenuState) == null ? void 0 : _a.focusLabel) {
|
|
2946
|
+
requestAnimationFrame(
|
|
2947
|
+
() => requestAnimationFrame(() => {
|
|
2948
|
+
const input = labelInputRef.current;
|
|
2949
|
+
if (input) {
|
|
2950
|
+
input.focus();
|
|
2951
|
+
input.setSelectionRange(0, input.value.length);
|
|
2952
|
+
}
|
|
2953
|
+
})
|
|
2954
|
+
);
|
|
2955
|
+
}
|
|
2687
2956
|
}, [x, sheet]);
|
|
2688
2957
|
const handleApplyLabel = useCallback(() => {
|
|
2689
2958
|
if (!sheet) {
|
|
2690
2959
|
return;
|
|
2691
2960
|
}
|
|
2692
|
-
const address =
|
|
2961
|
+
const address = M({ y: 0, x });
|
|
2693
2962
|
sheet.update({
|
|
2694
2963
|
diff: { [address]: { label: label || void 0 } },
|
|
2695
2964
|
partial: true,
|
|
@@ -2712,8 +2981,8 @@ const LabelSection = ({ x, close }) => {
|
|
|
2712
2981
|
return null;
|
|
2713
2982
|
}
|
|
2714
2983
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2715
|
-
const labelDisabled =
|
|
2716
|
-
const labelPlaceholder =
|
|
2984
|
+
const labelDisabled = Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.SetLabel);
|
|
2985
|
+
const labelPlaceholder = Ln(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x }, x) ?? G(x);
|
|
2717
2986
|
return /* @__PURE__ */ jsx("li", { className: `gs-menu-item gs-column-menu-label${labelDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs("label", { className: "gs-label-input-row", children: [
|
|
2718
2987
|
/* @__PURE__ */ jsx("div", { className: "gs-label-input-label", children: "Label:" }),
|
|
2719
2988
|
/* @__PURE__ */ jsx(
|
|
@@ -2752,7 +3021,7 @@ const ColumnMenu = () => {
|
|
|
2752
3021
|
const [waitingState, setWaitingState] = useState(null);
|
|
2753
3022
|
const handleClose = useCallback(() => {
|
|
2754
3023
|
dispatch(setColumnMenu(null));
|
|
2755
|
-
|
|
3024
|
+
_(editorRef.current);
|
|
2756
3025
|
}, [dispatch, editorRef]);
|
|
2757
3026
|
const handleWaiting = useCallback(
|
|
2758
3027
|
(message, cancel) => {
|
|
@@ -2786,47 +3055,19 @@ const ColumnMenu = () => {
|
|
|
2786
3055
|
className: "gs-column-menu",
|
|
2787
3056
|
style: { top: position.y, left: position.x, display: waitingState ? "none" : void 0 },
|
|
2788
3057
|
onClick: (e) => e.stopPropagation(),
|
|
2789
|
-
children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children:
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
return null;
|
|
2799
|
-
}
|
|
2800
|
-
return /* @__PURE__ */ jsx(Section, { x, close: handleClose, onWaiting: handleWaiting }, index);
|
|
2801
|
-
}
|
|
2802
|
-
if (descriptor.type === "divider") {
|
|
2803
|
-
if (descriptor.visible && !descriptor.visible(ctx)) {
|
|
2804
|
-
return null;
|
|
3058
|
+
children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: /* @__PURE__ */ jsx(
|
|
3059
|
+
MenuNodes,
|
|
3060
|
+
{
|
|
3061
|
+
items: colMenu,
|
|
3062
|
+
ctx,
|
|
3063
|
+
args: [x],
|
|
3064
|
+
onSelect: () => dispatch(setColumnMenu(null)),
|
|
3065
|
+
renderComponent: (componentId, key) => {
|
|
3066
|
+
const Section = getMenuComponent(componentId);
|
|
3067
|
+
return Section ? /* @__PURE__ */ jsx(Section, { x, close: handleClose, onWaiting: handleWaiting }, key) : null;
|
|
2805
3068
|
}
|
|
2806
|
-
return /* @__PURE__ */ jsx(MenuDivider, {}, index);
|
|
2807
3069
|
}
|
|
2808
|
-
|
|
2809
|
-
if (!visible) {
|
|
2810
|
-
return null;
|
|
2811
|
-
}
|
|
2812
|
-
const disabled = ((_a = descriptor.disabled) == null ? void 0 : _a.call(descriptor, ctx, x)) ?? false;
|
|
2813
|
-
const label = typeof descriptor.label === "function" ? descriptor.label(ctx, x) : descriptor.label;
|
|
2814
|
-
const shortcuts = typeof descriptor.shortcuts === "function" ? descriptor.shortcuts(ctx, x) : descriptor.shortcuts;
|
|
2815
|
-
return /* @__PURE__ */ jsx(
|
|
2816
|
-
MenuItem,
|
|
2817
|
-
{
|
|
2818
|
-
label,
|
|
2819
|
-
shortcuts,
|
|
2820
|
-
disabled,
|
|
2821
|
-
testId: descriptor.id ? `${descriptor.id}-item` : void 0,
|
|
2822
|
-
onClick: () => {
|
|
2823
|
-
descriptor.onClick(ctx, x);
|
|
2824
|
-
dispatch(setColumnMenu(null));
|
|
2825
|
-
}
|
|
2826
|
-
},
|
|
2827
|
-
index
|
|
2828
|
-
);
|
|
2829
|
-
}) })
|
|
3070
|
+
) })
|
|
2830
3071
|
}
|
|
2831
3072
|
),
|
|
2832
3073
|
waitingState && /* @__PURE__ */ jsxs(
|
|
@@ -2846,38 +3087,6 @@ const ColumnMenu = () => {
|
|
|
2846
3087
|
}
|
|
2847
3088
|
);
|
|
2848
3089
|
};
|
|
2849
|
-
function renderRowDescriptor(descriptor, ctx, y, index, close) {
|
|
2850
|
-
var _a;
|
|
2851
|
-
if (descriptor.type === "divider") {
|
|
2852
|
-
return /* @__PURE__ */ jsx(MenuDivider, {}, index);
|
|
2853
|
-
}
|
|
2854
|
-
if (descriptor.type === "component") {
|
|
2855
|
-
return null;
|
|
2856
|
-
}
|
|
2857
|
-
const visible = !descriptor.visible || descriptor.visible(ctx, y);
|
|
2858
|
-
if (!visible) {
|
|
2859
|
-
return null;
|
|
2860
|
-
}
|
|
2861
|
-
const disabled = ((_a = descriptor.disabled) == null ? void 0 : _a.call(descriptor, ctx, y)) ?? false;
|
|
2862
|
-
const label = typeof descriptor.label === "function" ? descriptor.label(ctx, y) : descriptor.label;
|
|
2863
|
-
const shortcuts = typeof descriptor.shortcuts === "function" ? descriptor.shortcuts(ctx, y) : descriptor.shortcuts;
|
|
2864
|
-
const checked = descriptor.checked != null ? descriptor.checked(ctx, y) : void 0;
|
|
2865
|
-
return /* @__PURE__ */ jsx(
|
|
2866
|
-
MenuItem,
|
|
2867
|
-
{
|
|
2868
|
-
label,
|
|
2869
|
-
shortcuts,
|
|
2870
|
-
disabled,
|
|
2871
|
-
checked,
|
|
2872
|
-
testId: descriptor.id ? `${descriptor.id}-item` : void 0,
|
|
2873
|
-
onClick: () => {
|
|
2874
|
-
descriptor.onClick(ctx, y);
|
|
2875
|
-
close();
|
|
2876
|
-
}
|
|
2877
|
-
},
|
|
2878
|
-
index
|
|
2879
|
-
);
|
|
2880
|
-
}
|
|
2881
3090
|
const RowMenu = () => {
|
|
2882
3091
|
const { store, dispatch } = useContext(Context);
|
|
2883
3092
|
const { rowMenuState, sheetReactive: sheetRef, editorRef, rowMenu } = store;
|
|
@@ -2886,7 +3095,7 @@ const RowMenu = () => {
|
|
|
2886
3095
|
const position = rowMenuState == null ? void 0 : rowMenuState.position;
|
|
2887
3096
|
const handleClose = () => {
|
|
2888
3097
|
dispatch(setRowMenu(null));
|
|
2889
|
-
|
|
3098
|
+
_(editorRef.current);
|
|
2890
3099
|
};
|
|
2891
3100
|
if (!rowMenuState || !sheet || y == null || !position) {
|
|
2892
3101
|
return null;
|
|
@@ -2901,7 +3110,7 @@ const RowMenu = () => {
|
|
|
2901
3110
|
handleClose();
|
|
2902
3111
|
return false;
|
|
2903
3112
|
},
|
|
2904
|
-
children: /* @__PURE__ */ jsx("div", { className: "gs-row-menu", style: { top: position.y, left: position.x }, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children:
|
|
3113
|
+
children: /* @__PURE__ */ jsx("div", { className: "gs-row-menu", style: { top: position.y, left: position.x }, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: /* @__PURE__ */ jsx(MenuNodes, { items: rowMenu, ctx, args: [y], onSelect: handleClose }) }) })
|
|
2905
3114
|
}
|
|
2906
3115
|
);
|
|
2907
3116
|
};
|
|
@@ -2922,8 +3131,8 @@ const safePreventDefault = (e) => {
|
|
|
2922
3131
|
};
|
|
2923
3132
|
const Cell = memo(({ y, x }) => {
|
|
2924
3133
|
var _a;
|
|
2925
|
-
const rowId =
|
|
2926
|
-
const colId =
|
|
3134
|
+
const rowId = bt(y);
|
|
3135
|
+
const colId = G(x);
|
|
2927
3136
|
const address = `${colId}${rowId}`;
|
|
2928
3137
|
const { store, dispatch } = useContext(Context);
|
|
2929
3138
|
const isFirstPointed = useRef(true);
|
|
@@ -2943,7 +3152,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
2943
3152
|
const sheet = sheetReactive.current;
|
|
2944
3153
|
const xSheetFocused = isXSheetFocused(store);
|
|
2945
3154
|
const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
|
|
2946
|
-
const selectingArea =
|
|
3155
|
+
const selectingArea = ks(selectingZone);
|
|
2947
3156
|
const editing = editingAddress === address;
|
|
2948
3157
|
const pointed = choosing.y === y && choosing.x === x;
|
|
2949
3158
|
const _setEditorRect = useCallback(() => {
|
|
@@ -2988,7 +3197,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
2988
3197
|
rendered = sheet.render({ sheet, point: { y, x }, apply, value: void 0 });
|
|
2989
3198
|
}
|
|
2990
3199
|
} catch (e) {
|
|
2991
|
-
if (
|
|
3200
|
+
if (S.is(e)) {
|
|
2992
3201
|
errorMessage = e.message;
|
|
2993
3202
|
rendered = e.code;
|
|
2994
3203
|
} else {
|
|
@@ -2997,7 +3206,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
2997
3206
|
}
|
|
2998
3207
|
}
|
|
2999
3208
|
const [, v] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x })) ?? [void 0, void 0];
|
|
3000
|
-
const isPendingCell =
|
|
3209
|
+
const isPendingCell = L.is(v);
|
|
3001
3210
|
const input = editorRef.current;
|
|
3002
3211
|
const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
|
|
3003
3212
|
const handleDragStart = useCallback(
|
|
@@ -3029,13 +3238,13 @@ const Cell = memo(({ y, x }) => {
|
|
|
3029
3238
|
dispatch(setDragging(true));
|
|
3030
3239
|
const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${address}`;
|
|
3031
3240
|
if (editingAnywhere) {
|
|
3032
|
-
const inserted =
|
|
3241
|
+
const inserted = q({ input: lastFocused || null, ref: fullAddress });
|
|
3033
3242
|
if (inserted) {
|
|
3034
3243
|
return false;
|
|
3035
3244
|
}
|
|
3036
3245
|
}
|
|
3037
3246
|
sheet.registry.lastFocused = input;
|
|
3038
|
-
|
|
3247
|
+
_(input);
|
|
3039
3248
|
dispatch(setEditingAddress(""));
|
|
3040
3249
|
if (autofillDraggingTo) {
|
|
3041
3250
|
return false;
|
|
@@ -3058,16 +3267,11 @@ const Cell = memo(({ y, x }) => {
|
|
|
3058
3267
|
}
|
|
3059
3268
|
safePreventDefault(e);
|
|
3060
3269
|
dispatch(setDragging(false));
|
|
3061
|
-
if (autofillDraggingTo) {
|
|
3062
|
-
dispatch(submitAutofill(autofillDraggingTo));
|
|
3063
|
-
focus(input);
|
|
3064
|
-
return false;
|
|
3065
|
-
}
|
|
3066
3270
|
if (editingAnywhere) {
|
|
3067
3271
|
dispatch(drag({ y: -1, x: -1 }));
|
|
3068
3272
|
}
|
|
3069
3273
|
},
|
|
3070
|
-
[
|
|
3274
|
+
[editingAnywhere]
|
|
3071
3275
|
);
|
|
3072
3276
|
const handleDragging = useCallback(
|
|
3073
3277
|
(e) => {
|
|
@@ -3094,14 +3298,14 @@ const Cell = memo(({ y, x }) => {
|
|
|
3094
3298
|
dispatch(drag({ y: sheet.numRows, x }));
|
|
3095
3299
|
return false;
|
|
3096
3300
|
}
|
|
3097
|
-
if (editingAnywhere && !
|
|
3301
|
+
if (editingAnywhere && !ee(lastFocused || null)) {
|
|
3098
3302
|
return false;
|
|
3099
3303
|
}
|
|
3100
3304
|
dispatch(drag({ y, x }));
|
|
3101
3305
|
if (editingAnywhere) {
|
|
3102
|
-
const newArea =
|
|
3103
|
-
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${
|
|
3104
|
-
|
|
3306
|
+
const newArea = ks({ ...selectingZone, endY: y, endX: x });
|
|
3307
|
+
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${rn(newArea)}`;
|
|
3308
|
+
q({ input: lastFocused || null, ref: fullRange });
|
|
3105
3309
|
}
|
|
3106
3310
|
return true;
|
|
3107
3311
|
},
|
|
@@ -3130,7 +3334,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
3130
3334
|
if (!rect) {
|
|
3131
3335
|
return;
|
|
3132
3336
|
}
|
|
3133
|
-
setErrorTooltipPos(
|
|
3337
|
+
setErrorTooltipPos(ce(rect));
|
|
3134
3338
|
}, []);
|
|
3135
3339
|
const handleErrorTriangleLeave = useCallback(() => {
|
|
3136
3340
|
setErrorTooltipPos(null);
|
|
@@ -3184,7 +3388,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
3184
3388
|
"data-x": x,
|
|
3185
3389
|
"data-y": y,
|
|
3186
3390
|
"data-address": address,
|
|
3187
|
-
className: `gs-cell ${
|
|
3391
|
+
className: `gs-cell ${on(selectingArea, { y, x }) ? "gs-selecting" : ""} ${pointed ? "gs-choosing" : ""} ${editing ? "gs-editing" : ""} ${isPendingCell ? "gs-pending" : ""}`,
|
|
3188
3392
|
style: {
|
|
3189
3393
|
...cell == null ? void 0 : cell.style
|
|
3190
3394
|
},
|
|
@@ -3239,7 +3443,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
3239
3443
|
style: {
|
|
3240
3444
|
top: errorTooltipPos.y + 4,
|
|
3241
3445
|
left: errorTooltipPos.x,
|
|
3242
|
-
transform:
|
|
3446
|
+
transform: be(errorTooltipPos.hAlign)
|
|
3243
3447
|
},
|
|
3244
3448
|
children: errorMessage
|
|
3245
3449
|
}
|
|
@@ -3270,6 +3474,8 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3270
3474
|
editingAddress
|
|
3271
3475
|
} = store;
|
|
3272
3476
|
const sheet = sheetRef.current;
|
|
3477
|
+
const storeRef = useRef(store);
|
|
3478
|
+
storeRef.current = store;
|
|
3273
3479
|
let isScrolling = false;
|
|
3274
3480
|
const xSheetFocused = isXSheetFocused(store);
|
|
3275
3481
|
const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
|
|
@@ -3286,7 +3492,7 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3286
3492
|
vertical = e.pageY > bottom ? 1 : e.pageY < top ? -1 : 0;
|
|
3287
3493
|
}
|
|
3288
3494
|
}
|
|
3289
|
-
const area =
|
|
3495
|
+
const area = le(tabularRef.current);
|
|
3290
3496
|
let { endX: x, endY: y } = selectingZone;
|
|
3291
3497
|
if (horizontal) {
|
|
3292
3498
|
x = horizontal > 0 ? area.right : area.left;
|
|
@@ -3302,6 +3508,15 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3302
3508
|
if (!isScrolling || tabularRef.current === null || !sheet) {
|
|
3303
3509
|
return;
|
|
3304
3510
|
}
|
|
3511
|
+
const live = storeRef.current;
|
|
3512
|
+
if (!live.dragging && !live.autofillDraggingTo) {
|
|
3513
|
+
if (scrollRef.current !== null) {
|
|
3514
|
+
cancelAnimationFrame(scrollRef.current);
|
|
3515
|
+
scrollRef.current = null;
|
|
3516
|
+
}
|
|
3517
|
+
isScrolling = false;
|
|
3518
|
+
return;
|
|
3519
|
+
}
|
|
3305
3520
|
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
3306
3521
|
if (now - lastScrollTime > 1e3) {
|
|
3307
3522
|
currentSpeed = 0;
|
|
@@ -3311,18 +3526,18 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3311
3526
|
left: currentSpeed * horizontal,
|
|
3312
3527
|
top: currentSpeed * vertical
|
|
3313
3528
|
});
|
|
3314
|
-
|
|
3529
|
+
_(editorRef.current);
|
|
3315
3530
|
const { x, y } = getDestEdge(e);
|
|
3316
|
-
if (autofillDraggingTo) {
|
|
3317
|
-
const { y: curY, x: curX } = autofillDraggingTo;
|
|
3531
|
+
if (live.autofillDraggingTo) {
|
|
3532
|
+
const { y: curY, x: curX } = live.autofillDraggingTo;
|
|
3318
3533
|
dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
|
|
3319
3534
|
} else {
|
|
3320
3535
|
if (editingAnywhere) {
|
|
3321
|
-
const newArea =
|
|
3536
|
+
const newArea = ks({ ...selectingZone, endY: y, endX: x });
|
|
3322
3537
|
const sheetPrefix = sheet.sheetPrefix(!xSheetFocused);
|
|
3323
|
-
const sheetRange =
|
|
3538
|
+
const sheetRange = rn(newArea);
|
|
3324
3539
|
const fullRange = `${sheetPrefix}${sheetRange}`;
|
|
3325
|
-
|
|
3540
|
+
q({ input: editorRef.current, ref: fullRange });
|
|
3326
3541
|
}
|
|
3327
3542
|
dispatch(drag({ y, x }));
|
|
3328
3543
|
}
|
|
@@ -3367,15 +3582,15 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3367
3582
|
scrollRef.current = null;
|
|
3368
3583
|
}
|
|
3369
3584
|
isScrolling = false;
|
|
3370
|
-
if (!
|
|
3371
|
-
|
|
3585
|
+
if (!re(searchInputRef.current)) {
|
|
3586
|
+
_(editorRef.current);
|
|
3372
3587
|
}
|
|
3373
3588
|
}, []);
|
|
3374
3589
|
const handleMouseUp = useCallback(
|
|
3375
3590
|
(e) => {
|
|
3376
3591
|
e.preventDefault();
|
|
3377
3592
|
e.stopPropagation();
|
|
3378
|
-
const area =
|
|
3593
|
+
const area = le(tabularRef.current);
|
|
3379
3594
|
if (area.bottom === -1 || area.right === -1) {
|
|
3380
3595
|
return;
|
|
3381
3596
|
}
|
|
@@ -3383,7 +3598,7 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3383
3598
|
if (autofillDraggingTo) {
|
|
3384
3599
|
const { y: curY, x: curX } = autofillDraggingTo;
|
|
3385
3600
|
dispatch(submitAutofill({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
|
|
3386
|
-
|
|
3601
|
+
_(editorRef.current);
|
|
3387
3602
|
} else {
|
|
3388
3603
|
if (editingAnywhere) {
|
|
3389
3604
|
dispatch(drag({ y: -1, x: -1 }));
|
|
@@ -3425,7 +3640,7 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3425
3640
|
);
|
|
3426
3641
|
}
|
|
3427
3642
|
const HeaderCellTop = memo(({ x }) => {
|
|
3428
|
-
const colId =
|
|
3643
|
+
const colId = G(x);
|
|
3429
3644
|
const { store, dispatch } = useContext(Context);
|
|
3430
3645
|
const {
|
|
3431
3646
|
sheetReactive: sheetRef,
|
|
@@ -3441,7 +3656,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3441
3656
|
} = store;
|
|
3442
3657
|
const sheet = sheetRef.current;
|
|
3443
3658
|
const col = sheet == null ? void 0 : sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
3444
|
-
const width = (col == null ? void 0 : col.width) ||
|
|
3659
|
+
const width = (col == null ? void 0 : col.width) || he;
|
|
3445
3660
|
const hasFilter = !!((col == null ? void 0 : col.filter) && col.filter.conditions.length > 0);
|
|
3446
3661
|
const xSheetFocused = isXSheetFocused(store);
|
|
3447
3662
|
const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
|
|
@@ -3478,7 +3693,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3478
3693
|
dispatch(select({ startY: 1, startX: x, endY: -1, endX: x }));
|
|
3479
3694
|
const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${colId}:${colId}`;
|
|
3480
3695
|
if (editingAnywhere) {
|
|
3481
|
-
const inserted =
|
|
3696
|
+
const inserted = q({ input: lastFocused || null, ref: fullAddress });
|
|
3482
3697
|
if (inserted) {
|
|
3483
3698
|
dispatch(select({ startY: sheet.numRows, startX: x, endY: 0, endX: x }));
|
|
3484
3699
|
return false;
|
|
@@ -3499,7 +3714,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3499
3714
|
}
|
|
3500
3715
|
dispatch(setEditingAddress(""));
|
|
3501
3716
|
dispatch(setDragging(true));
|
|
3502
|
-
|
|
3717
|
+
_(editorRef.current);
|
|
3503
3718
|
if (autofillDraggingTo) {
|
|
3504
3719
|
return false;
|
|
3505
3720
|
}
|
|
@@ -3526,7 +3741,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3526
3741
|
safePreventDefault(e);
|
|
3527
3742
|
dispatch(setDragging(false));
|
|
3528
3743
|
if (autofillDraggingTo) {
|
|
3529
|
-
|
|
3744
|
+
_(editorRef.current);
|
|
3530
3745
|
return false;
|
|
3531
3746
|
}
|
|
3532
3747
|
},
|
|
@@ -3546,10 +3761,10 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3546
3761
|
return false;
|
|
3547
3762
|
}
|
|
3548
3763
|
if (editingAnywhere) {
|
|
3549
|
-
const newArea =
|
|
3550
|
-
const [left, right] = [
|
|
3764
|
+
const newArea = ks({ ...selectingZone, endY: 1, endX: x });
|
|
3765
|
+
const [left, right] = [G(newArea.left), G(newArea.right)];
|
|
3551
3766
|
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${left}:${right}`;
|
|
3552
|
-
|
|
3767
|
+
q({ input: lastFocused || null, ref: fullRange });
|
|
3553
3768
|
}
|
|
3554
3769
|
if (autofillDraggingTo == null) {
|
|
3555
3770
|
const { startY } = selectingZone;
|
|
@@ -3571,8 +3786,25 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3571
3786
|
"th",
|
|
3572
3787
|
{
|
|
3573
3788
|
"data-x": x,
|
|
3574
|
-
className: `gs-th gs-th-top ${choosing.x === x ? "gs-choosing" : ""} ${
|
|
3789
|
+
className: `gs-th gs-th-top ${choosing.x === x ? "gs-choosing" : ""} ${nn({ start: selectingZone.startX, end: selectingZone.endX }, x) ? topHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""}`,
|
|
3575
3790
|
style: { ...col == null ? void 0 : col.style, width, minWidth: width, maxWidth: width },
|
|
3791
|
+
onDoubleClick: (e) => {
|
|
3792
|
+
const target = e.target;
|
|
3793
|
+
if (target.closest(".gs-resizer, .gs-menu-btn")) {
|
|
3794
|
+
return;
|
|
3795
|
+
}
|
|
3796
|
+
if (Mn.hasOperation(col == null ? void 0 : col.prevention, Mn.ColumnMenu)) {
|
|
3797
|
+
return;
|
|
3798
|
+
}
|
|
3799
|
+
e.stopPropagation();
|
|
3800
|
+
const inner = e.currentTarget.querySelector(".gs-th-inner");
|
|
3801
|
+
const rect = (inner ?? e.currentTarget).getBoundingClientRect();
|
|
3802
|
+
const alreadySelected = nn({ start: selectingZone.startX, end: selectingZone.endX }, x) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
|
|
3803
|
+
if (!alreadySelected) {
|
|
3804
|
+
dispatch(selectCols({ range: { start: x, end: x }, numRows: sheet.numRows }));
|
|
3805
|
+
}
|
|
3806
|
+
dispatch(setColumnMenu({ x, position: { y: rect.bottom, x: rect.left }, focusLabel: true }));
|
|
3807
|
+
},
|
|
3576
3808
|
onContextMenu: (e) => {
|
|
3577
3809
|
if (contextMenu.length > 0) {
|
|
3578
3810
|
e.stopPropagation();
|
|
@@ -3602,7 +3834,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3602
3834
|
}
|
|
3603
3835
|
),
|
|
3604
3836
|
(() => {
|
|
3605
|
-
const displayedLabel =
|
|
3837
|
+
const displayedLabel = Ln(sheet, col == null ? void 0 : col.label, { y: 0, x }, x) ?? colId;
|
|
3606
3838
|
if (displayedLabel !== colId) {
|
|
3607
3839
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3608
3840
|
/* @__PURE__ */ jsx("span", { className: "gs-col-addr", children: colId }),
|
|
@@ -3611,7 +3843,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3611
3843
|
}
|
|
3612
3844
|
return displayedLabel;
|
|
3613
3845
|
})(),
|
|
3614
|
-
!
|
|
3846
|
+
!Mn.hasOperation(col == null ? void 0 : col.prevention, Mn.ColumnMenu) && /* @__PURE__ */ jsx(
|
|
3615
3847
|
"button",
|
|
3616
3848
|
{
|
|
3617
3849
|
className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x ? "gs-active" : ""}`,
|
|
@@ -3634,7 +3866,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3634
3866
|
if ((columnMenuState == null ? void 0 : columnMenuState.x) === x) {
|
|
3635
3867
|
dispatch(setColumnMenu(null));
|
|
3636
3868
|
} else {
|
|
3637
|
-
const alreadySelected =
|
|
3869
|
+
const alreadySelected = nn({ start: selectingZone.startX, end: selectingZone.endX }, x) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
|
|
3638
3870
|
if (!alreadySelected) {
|
|
3639
3871
|
dispatch(selectCols({ range: { start: x, end: x }, numRows: sheet.numRows }));
|
|
3640
3872
|
}
|
|
@@ -3649,7 +3881,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3649
3881
|
{
|
|
3650
3882
|
className: `
|
|
3651
3883
|
gs-resizer
|
|
3652
|
-
${
|
|
3884
|
+
${Mn.hasOperation(col == null ? void 0 : col.prevention, Mn.Resize) ? "gs-protected" : ""}
|
|
3653
3885
|
${dragging ? "gs-hidden" : ""}`,
|
|
3654
3886
|
style: { height: sheet.headerHeight },
|
|
3655
3887
|
onMouseDown: handleResizeMouseDown,
|
|
@@ -3663,7 +3895,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3663
3895
|
);
|
|
3664
3896
|
});
|
|
3665
3897
|
const HeaderCellLeft = memo(({ y }) => {
|
|
3666
|
-
const rowId = `${
|
|
3898
|
+
const rowId = `${bt(y)}`;
|
|
3667
3899
|
const { store, dispatch } = useContext(Context);
|
|
3668
3900
|
const {
|
|
3669
3901
|
choosing,
|
|
@@ -3679,7 +3911,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3679
3911
|
} = store;
|
|
3680
3912
|
const sheet = sheetRef.current;
|
|
3681
3913
|
const row = sheet == null ? void 0 : sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
3682
|
-
const height = (row == null ? void 0 : row.height) ||
|
|
3914
|
+
const height = (row == null ? void 0 : row.height) || rt;
|
|
3683
3915
|
const xSheetFocused = isXSheetFocused(store);
|
|
3684
3916
|
const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
|
|
3685
3917
|
const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
|
|
@@ -3715,7 +3947,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3715
3947
|
dispatch(select({ startY: y, startX: 1, endY: y, endX: -1 }));
|
|
3716
3948
|
const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${rowId}:${rowId}`;
|
|
3717
3949
|
if (editingAnywhere) {
|
|
3718
|
-
const inserted =
|
|
3950
|
+
const inserted = q({ input: lastFocused || null, ref: fullAddress });
|
|
3719
3951
|
if (inserted) {
|
|
3720
3952
|
dispatch(select({ startY: y, startX: sheet.numCols, endY: y, endX: 0 }));
|
|
3721
3953
|
return false;
|
|
@@ -3736,7 +3968,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3736
3968
|
}
|
|
3737
3969
|
dispatch(setEditingAddress(""));
|
|
3738
3970
|
dispatch(setDragging(true));
|
|
3739
|
-
|
|
3971
|
+
_(editorRef.current);
|
|
3740
3972
|
if (autofillDraggingTo) {
|
|
3741
3973
|
return false;
|
|
3742
3974
|
}
|
|
@@ -3763,7 +3995,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3763
3995
|
safePreventDefault(e);
|
|
3764
3996
|
dispatch(setDragging(false));
|
|
3765
3997
|
if (autofillDraggingTo) {
|
|
3766
|
-
|
|
3998
|
+
_(editorRef.current);
|
|
3767
3999
|
return false;
|
|
3768
4000
|
}
|
|
3769
4001
|
},
|
|
@@ -3783,10 +4015,10 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3783
4015
|
return false;
|
|
3784
4016
|
}
|
|
3785
4017
|
if (editingAnywhere) {
|
|
3786
|
-
const newArea =
|
|
3787
|
-
const [top, bottom] = [
|
|
4018
|
+
const newArea = ks({ ...selectingZone, endY: y, endX: 1 });
|
|
4019
|
+
const [top, bottom] = [bt(newArea.top), bt(newArea.bottom)];
|
|
3788
4020
|
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${top}:${bottom}`;
|
|
3789
|
-
|
|
4021
|
+
q({ input: lastFocused || null, ref: fullRange });
|
|
3790
4022
|
}
|
|
3791
4023
|
if (autofillDraggingTo == null) {
|
|
3792
4024
|
const { startX } = selectingZone;
|
|
@@ -3817,7 +4049,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3817
4049
|
"th",
|
|
3818
4050
|
{
|
|
3819
4051
|
"data-y": y,
|
|
3820
|
-
className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${
|
|
4052
|
+
className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${nn({ start: selectingZone.startY, end: selectingZone.endY }, y) ? leftHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""} ${(row == null ? void 0 : row.filterFixed) ? "gs-filter-fixed" : ""} ${(row == null ? void 0 : row.sortFixed) ? "gs-sort-fixed" : ""}`,
|
|
3821
4053
|
style: { ...row == null ? void 0 : row.style, height },
|
|
3822
4054
|
onContextMenu: handleContextMenu,
|
|
3823
4055
|
children: /* @__PURE__ */ jsx(
|
|
@@ -3839,8 +4071,8 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3839
4071
|
horizontal: -1
|
|
3840
4072
|
}
|
|
3841
4073
|
),
|
|
3842
|
-
|
|
3843
|
-
!
|
|
4074
|
+
Ln(sheet, row == null ? void 0 : row.label, { y, x: 0 }, y) ?? rowId,
|
|
4075
|
+
!Mn.hasOperation(row == null ? void 0 : row.prevention, Mn.RowMenu) && /* @__PURE__ */ jsx(
|
|
3844
4076
|
"button",
|
|
3845
4077
|
{
|
|
3846
4078
|
className: `gs-menu-btn gs-row-menu-btn ${(rowMenuState == null ? void 0 : rowMenuState.y) === y ? "gs-active" : ""}`,
|
|
@@ -3863,7 +4095,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3863
4095
|
if ((rowMenuState == null ? void 0 : rowMenuState.y) === y) {
|
|
3864
4096
|
dispatch(setRowMenu(null));
|
|
3865
4097
|
} else {
|
|
3866
|
-
const alreadySelected =
|
|
4098
|
+
const alreadySelected = nn({ start: selectingZone.startY, end: selectingZone.endY }, y) && selectingZone.startX === 1 && selectingZone.endX === sheet.numCols;
|
|
3867
4099
|
if (!alreadySelected) {
|
|
3868
4100
|
dispatch(selectRows({ range: { start: y, end: y }, numCols: sheet.numCols }));
|
|
3869
4101
|
}
|
|
@@ -3878,7 +4110,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3878
4110
|
{
|
|
3879
4111
|
className: `
|
|
3880
4112
|
gs-resizer
|
|
3881
|
-
${
|
|
4113
|
+
${Mn.hasOperation(row == null ? void 0 : row.prevention, Mn.Resize) ? "gs-protected" : ""}
|
|
3882
4114
|
${dragging ? "gs-hidden" : ""}`,
|
|
3883
4115
|
style: { width: sheet.headerWidth },
|
|
3884
4116
|
onMouseDown: handleResizeMouseDown
|
|
@@ -3918,8 +4150,8 @@ const drawAreaRectViewport = (ctx, sheet, scrollTop, scrollLeft, viewW, viewH, a
|
|
|
3918
4150
|
if (top === -1 || left === -1 || bottom === -1 || right === -1) {
|
|
3919
4151
|
return;
|
|
3920
4152
|
}
|
|
3921
|
-
const topLeft =
|
|
3922
|
-
const bottomRight =
|
|
4153
|
+
const topLeft = Q(sheet, { y: top, x: left });
|
|
4154
|
+
const bottomRight = Q(sheet, { y: bottom, x: right });
|
|
3923
4155
|
const x1 = topLeft.left - scrollLeft;
|
|
3924
4156
|
const y1 = topLeft.top - scrollTop;
|
|
3925
4157
|
const x2 = bottomRight.right - scrollLeft;
|
|
@@ -3971,7 +4203,7 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
3971
4203
|
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
3972
4204
|
ctx.clearRect(0, 0, w, h2);
|
|
3973
4205
|
const { registry } = sheet;
|
|
3974
|
-
const scrollTop = container.scrollTop;
|
|
4206
|
+
const scrollTop = W(sheet, container.scrollTop, container.clientHeight);
|
|
3975
4207
|
const scrollLeft = container.scrollLeft;
|
|
3976
4208
|
const headerW = sheet.headerWidth;
|
|
3977
4209
|
const headerH = sheet.headerHeight;
|
|
@@ -3979,16 +4211,16 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
3979
4211
|
ctx.beginPath();
|
|
3980
4212
|
ctx.rect(headerW, headerH, w - headerW, h2 - headerH);
|
|
3981
4213
|
ctx.clip();
|
|
3982
|
-
const selectingArea =
|
|
4214
|
+
const selectingArea = ks(selectingZone);
|
|
3983
4215
|
drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, selectingArea, COLOR_SELECTED, 1, [], SELECTING_FILL);
|
|
3984
4216
|
if (autofillDraggingTo) {
|
|
3985
|
-
const autofill = new
|
|
4217
|
+
const autofill = new Hn(storeRef.current, autofillDraggingTo);
|
|
3986
4218
|
drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, autofill.wholeArea, COLOR_AUTOFILL, 1, [5, 5]);
|
|
3987
4219
|
}
|
|
3988
4220
|
{
|
|
3989
4221
|
const { y, x } = choosing;
|
|
3990
4222
|
if (y !== -1 && x !== -1) {
|
|
3991
|
-
const pos =
|
|
4223
|
+
const pos = Q(sheet, { y, x });
|
|
3992
4224
|
const vx = pos.left - scrollLeft;
|
|
3993
4225
|
const vy = pos.top - scrollTop;
|
|
3994
4226
|
drawRect(ctx, vx, vy, pos.width, pos.height, COLOR_POINTED, 2, []);
|
|
@@ -3996,13 +4228,13 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
3996
4228
|
}
|
|
3997
4229
|
const { copyingSheetId, copyingZone, cutting } = registry;
|
|
3998
4230
|
if (sheet.id === copyingSheetId) {
|
|
3999
|
-
const copyingArea =
|
|
4231
|
+
const copyingArea = ks(copyingZone);
|
|
4000
4232
|
const color = cutting ? COLOR_CUTTING : COLOR_COPYING;
|
|
4001
4233
|
const dashPattern = cutting ? [4, 4] : [6, 4];
|
|
4002
4234
|
drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, copyingArea, color, 2.5, dashPattern);
|
|
4003
4235
|
}
|
|
4004
4236
|
Object.entries(refs).forEach(([ref, i]) => {
|
|
4005
|
-
const palette =
|
|
4237
|
+
const palette = Pn[i % Pn.length];
|
|
4006
4238
|
try {
|
|
4007
4239
|
const refArea = sheet.rangeToArea(ref);
|
|
4008
4240
|
drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, refArea, palette, 2, [5, 5]);
|
|
@@ -4010,8 +4242,8 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
4010
4242
|
}
|
|
4011
4243
|
});
|
|
4012
4244
|
matchingCells.forEach((address, index) => {
|
|
4013
|
-
const { y, x } =
|
|
4014
|
-
const pos =
|
|
4245
|
+
const { y, x } = T(address);
|
|
4246
|
+
const pos = Q(sheet, { y, x });
|
|
4015
4247
|
const vx = pos.left - scrollLeft;
|
|
4016
4248
|
const vy = pos.top - scrollTop;
|
|
4017
4249
|
if (vx + pos.width < 0 || vx > w || vy + pos.height < 0 || vy > h2) {
|
|
@@ -4031,12 +4263,12 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
4031
4263
|
);
|
|
4032
4264
|
});
|
|
4033
4265
|
ctx.restore();
|
|
4034
|
-
const
|
|
4035
|
-
const
|
|
4036
|
-
for (let x =
|
|
4266
|
+
const [firstCol, lastCol] = ge(sheet, scrollLeft, w);
|
|
4267
|
+
const [firstRow, lastRow] = se(sheet, scrollTop, h2);
|
|
4268
|
+
for (let x = firstCol; x <= lastCol; x++) {
|
|
4037
4269
|
let color = null;
|
|
4038
4270
|
let backgroundColor = null;
|
|
4039
|
-
if (
|
|
4271
|
+
if (nn({ start: selectingZone.startX, end: selectingZone.endX }, x)) {
|
|
4040
4272
|
color = "rgba(80, 180, 255, 1)";
|
|
4041
4273
|
backgroundColor = topHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
|
|
4042
4274
|
}
|
|
@@ -4047,7 +4279,7 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
4047
4279
|
if (!color) {
|
|
4048
4280
|
continue;
|
|
4049
4281
|
}
|
|
4050
|
-
const pos =
|
|
4282
|
+
const pos = Q(sheet, { y: 1, x });
|
|
4051
4283
|
const left = pos.left - scrollLeft;
|
|
4052
4284
|
if (left + pos.width < headerW || left > w) {
|
|
4053
4285
|
continue;
|
|
@@ -4066,13 +4298,13 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
4066
4298
|
ctx.stroke();
|
|
4067
4299
|
}
|
|
4068
4300
|
}
|
|
4069
|
-
for (let y =
|
|
4301
|
+
for (let y = firstRow; y <= lastRow; y++) {
|
|
4070
4302
|
if (sheet.isRowFiltered(y)) {
|
|
4071
4303
|
continue;
|
|
4072
4304
|
}
|
|
4073
4305
|
let color = null;
|
|
4074
4306
|
let backgroundColor = null;
|
|
4075
|
-
if (
|
|
4307
|
+
if (nn({ start: selectingZone.startY, end: selectingZone.endY }, y)) {
|
|
4076
4308
|
color = "rgba(80, 180, 255, 1)";
|
|
4077
4309
|
backgroundColor = leftHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
|
|
4078
4310
|
}
|
|
@@ -4083,7 +4315,7 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
4083
4315
|
if (!color) {
|
|
4084
4316
|
continue;
|
|
4085
4317
|
}
|
|
4086
|
-
const pos =
|
|
4318
|
+
const pos = Q(sheet, { y, x: 1 });
|
|
4087
4319
|
const top = pos.top - scrollTop;
|
|
4088
4320
|
if (top + pos.height < headerH || top > h2) {
|
|
4089
4321
|
continue;
|
|
@@ -4217,7 +4449,7 @@ const Tabular = () => {
|
|
|
4217
4449
|
const handleScroll = useCallback(
|
|
4218
4450
|
(e) => {
|
|
4219
4451
|
if (sheet) {
|
|
4220
|
-
setVirtualized(
|
|
4452
|
+
setVirtualized(ne(sheet, e.currentTarget));
|
|
4221
4453
|
}
|
|
4222
4454
|
},
|
|
4223
4455
|
[sheetReactive]
|
|
@@ -4251,17 +4483,17 @@ const Tabular = () => {
|
|
|
4251
4483
|
}
|
|
4252
4484
|
const palette2 = {};
|
|
4253
4485
|
const paletteBySheetName = {};
|
|
4254
|
-
const lexer = new
|
|
4486
|
+
const lexer = new te(inputting.substring(1));
|
|
4255
4487
|
lexer.tokenize();
|
|
4256
4488
|
let i = 0;
|
|
4257
4489
|
for (const token of lexer.tokens) {
|
|
4258
4490
|
if (token.type === "REF" || token.type === "RANGE") {
|
|
4259
|
-
const normalizedRef =
|
|
4491
|
+
const normalizedRef = en(token.stringify());
|
|
4260
4492
|
const splitterIndex = normalizedRef.indexOf("!");
|
|
4261
4493
|
if (splitterIndex !== -1) {
|
|
4262
4494
|
const sheetName = normalizedRef.substring(0, splitterIndex);
|
|
4263
4495
|
const ref = normalizedRef.substring(splitterIndex + 1);
|
|
4264
|
-
const stripped =
|
|
4496
|
+
const stripped = bn(sheetName);
|
|
4265
4497
|
const upperRef = ref.toUpperCase();
|
|
4266
4498
|
if (paletteBySheetName[stripped] == null) {
|
|
4267
4499
|
paletteBySheetName[stripped] = {};
|
|
@@ -4284,14 +4516,14 @@ const Tabular = () => {
|
|
|
4284
4516
|
if (!sheet) {
|
|
4285
4517
|
return;
|
|
4286
4518
|
}
|
|
4287
|
-
sheet.registry.choosingAddress =
|
|
4519
|
+
sheet.registry.choosingAddress = M(choosing);
|
|
4288
4520
|
sheet.registry.choosingSheetId = sheet.id;
|
|
4289
4521
|
}, [choosing]);
|
|
4290
4522
|
useEffect(() => {
|
|
4291
4523
|
if (!sheet) {
|
|
4292
4524
|
return;
|
|
4293
4525
|
}
|
|
4294
|
-
setVirtualized(
|
|
4526
|
+
setVirtualized(ne(sheet, tabularRef.current));
|
|
4295
4527
|
}, [
|
|
4296
4528
|
tabularRef.current,
|
|
4297
4529
|
sheetReactive,
|
|
@@ -4305,7 +4537,7 @@ const Tabular = () => {
|
|
|
4305
4537
|
if (!el) {
|
|
4306
4538
|
return;
|
|
4307
4539
|
}
|
|
4308
|
-
return
|
|
4540
|
+
return Z(el);
|
|
4309
4541
|
}, [sheetReactive]);
|
|
4310
4542
|
useEffect(() => {
|
|
4311
4543
|
if (!sheet || !sheet.eager || !sheet.registry.ready) {
|
|
@@ -4339,7 +4571,9 @@ const Tabular = () => {
|
|
|
4339
4571
|
className: "gs-tabular-inner",
|
|
4340
4572
|
style: {
|
|
4341
4573
|
width: sheet.totalWidth,
|
|
4342
|
-
height
|
|
4574
|
+
// Physical scroll height is capped below the browser's ~2^24px precision limit;
|
|
4575
|
+
// virtualize() maps this back to the sheet's full virtual height (see SCROLL_CAP).
|
|
4576
|
+
height: ie(sheet),
|
|
4343
4577
|
overflow: "clip"
|
|
4344
4578
|
},
|
|
4345
4579
|
children: [
|
|
@@ -4452,11 +4686,11 @@ const FormulaBar = ({ ready }) => {
|
|
|
4452
4686
|
} = store;
|
|
4453
4687
|
const sheet = sheetRef.current;
|
|
4454
4688
|
const hlRef = useRef(null);
|
|
4455
|
-
const address = choosing.x === -1 ? "" :
|
|
4689
|
+
const address = choosing.x === -1 ? "" : M(choosing);
|
|
4456
4690
|
const cell = sheet == null ? void 0 : sheet.getCell(choosing, { resolution: "SYSTEM" });
|
|
4457
4691
|
const spilledFromAddress = (_a = sheet == null ? void 0 : sheet.getSystem(choosing)) == null ? void 0 : _a.spilledFrom;
|
|
4458
|
-
const originPoint = spilledFromAddress ?
|
|
4459
|
-
const originAddress = originPoint != null ?
|
|
4692
|
+
const originPoint = spilledFromAddress ? T(spilledFromAddress) : void 0;
|
|
4693
|
+
const originAddress = originPoint != null ? M(originPoint) : void 0;
|
|
4460
4694
|
useEffect(() => {
|
|
4461
4695
|
var _a2;
|
|
4462
4696
|
if (!sheet) {
|
|
@@ -4473,7 +4707,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4473
4707
|
dispatch(write({ value }));
|
|
4474
4708
|
}
|
|
4475
4709
|
dispatch(setEditingAddress(""));
|
|
4476
|
-
|
|
4710
|
+
_(editorRef.current);
|
|
4477
4711
|
},
|
|
4478
4712
|
[before]
|
|
4479
4713
|
);
|
|
@@ -4554,10 +4788,6 @@ const FormulaBar = ({ ready }) => {
|
|
|
4554
4788
|
return true;
|
|
4555
4789
|
}
|
|
4556
4790
|
const input = e.currentTarget;
|
|
4557
|
-
if (handleFormulaQuoteAutoClose(e, inputting)) {
|
|
4558
|
-
dispatch(setInputting(input.value));
|
|
4559
|
-
return false;
|
|
4560
|
-
}
|
|
4561
4791
|
switch (e.key) {
|
|
4562
4792
|
case "Tab":
|
|
4563
4793
|
e.preventDefault();
|
|
@@ -4569,7 +4799,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4569
4799
|
dispatch(setInputting(newValue));
|
|
4570
4800
|
setTimeout(() => {
|
|
4571
4801
|
if (largeEditorRef.current) {
|
|
4572
|
-
|
|
4802
|
+
_(largeEditorRef.current);
|
|
4573
4803
|
largeEditorRef.current.setSelectionRange(newCursor, newCursor);
|
|
4574
4804
|
}
|
|
4575
4805
|
}, 0);
|
|
@@ -4600,7 +4830,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4600
4830
|
dispatch(setInputting(newValue));
|
|
4601
4831
|
setTimeout(() => {
|
|
4602
4832
|
if (largeEditorRef.current) {
|
|
4603
|
-
|
|
4833
|
+
_(largeEditorRef.current);
|
|
4604
4834
|
largeEditorRef.current.setSelectionRange(newCursor, newCursor);
|
|
4605
4835
|
}
|
|
4606
4836
|
}, 0);
|
|
@@ -4609,7 +4839,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4609
4839
|
}
|
|
4610
4840
|
}
|
|
4611
4841
|
if (e.altKey) {
|
|
4612
|
-
|
|
4842
|
+
R(input, "\n");
|
|
4613
4843
|
} else {
|
|
4614
4844
|
writeCell(input.value);
|
|
4615
4845
|
dispatch(setInputting(""));
|
|
@@ -4631,7 +4861,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4631
4861
|
dispatch(setInputting(before));
|
|
4632
4862
|
dispatch(setEditingAddress(""));
|
|
4633
4863
|
e.preventDefault();
|
|
4634
|
-
|
|
4864
|
+
_(editorRef.current);
|
|
4635
4865
|
break;
|
|
4636
4866
|
}
|
|
4637
4867
|
case "a":
|
|
@@ -4650,7 +4880,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4650
4880
|
break;
|
|
4651
4881
|
}
|
|
4652
4882
|
const cell2 = sheet.getCell(choosing, { resolution: "SYSTEM" });
|
|
4653
|
-
if (
|
|
4883
|
+
if (Mn.hasOperation(cell2 == null ? void 0 : cell2.prevention, Mn.Write)) {
|
|
4654
4884
|
console.warn("This cell is protected from writing.");
|
|
4655
4885
|
e.preventDefault();
|
|
4656
4886
|
}
|
|
@@ -4683,7 +4913,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4683
4913
|
dispatch(setInputting(newValue));
|
|
4684
4914
|
setTimeout(() => {
|
|
4685
4915
|
if (largeEditorRef.current) {
|
|
4686
|
-
|
|
4916
|
+
_(largeEditorRef.current);
|
|
4687
4917
|
largeEditorRef.current.setSelectionRange(newCursor, newCursor);
|
|
4688
4918
|
}
|
|
4689
4919
|
}, 0);
|
|
@@ -4858,15 +5088,15 @@ const SearchBar = () => {
|
|
|
4858
5088
|
if (!matchingCell || !sheet) {
|
|
4859
5089
|
return;
|
|
4860
5090
|
}
|
|
4861
|
-
const point =
|
|
5091
|
+
const point = T(matchingCell);
|
|
4862
5092
|
if (typeof point === "undefined") {
|
|
4863
5093
|
return;
|
|
4864
5094
|
}
|
|
4865
|
-
|
|
5095
|
+
de(sheet, tabularRef.current, point);
|
|
4866
5096
|
}, [searchQuery, matchingCellIndex, searchCaseSensitive, searchRegex, sheet, tabularRef]);
|
|
4867
5097
|
const handleProgressClick = useCallback((e) => {
|
|
4868
5098
|
const input = e.currentTarget.previousSibling;
|
|
4869
|
-
(input == null ? void 0 : input.nodeName) === "INPUT" &&
|
|
5099
|
+
(input == null ? void 0 : input.nodeName) === "INPUT" && _(input);
|
|
4870
5100
|
}, []);
|
|
4871
5101
|
const handleSearchClick = useCallback(() => {
|
|
4872
5102
|
dispatch(search(1));
|
|
@@ -4879,7 +5109,7 @@ const SearchBar = () => {
|
|
|
4879
5109
|
if (e.key === "Escape") {
|
|
4880
5110
|
const el = editorRef == null ? void 0 : editorRef.current;
|
|
4881
5111
|
if (el) {
|
|
4882
|
-
|
|
5112
|
+
_(el);
|
|
4883
5113
|
}
|
|
4884
5114
|
dispatch(setSearchQuery(void 0));
|
|
4885
5115
|
}
|
|
@@ -4906,7 +5136,7 @@ const SearchBar = () => {
|
|
|
4906
5136
|
if (!selectingZone) {
|
|
4907
5137
|
return false;
|
|
4908
5138
|
}
|
|
4909
|
-
if (
|
|
5139
|
+
if (wn(selectingZone)) {
|
|
4910
5140
|
return false;
|
|
4911
5141
|
}
|
|
4912
5142
|
const { startY, startX, endY, endX } = selectingZone;
|
|
@@ -4917,8 +5147,8 @@ const SearchBar = () => {
|
|
|
4917
5147
|
return "";
|
|
4918
5148
|
}
|
|
4919
5149
|
const { startY, startX, endY, endX } = selectingZone;
|
|
4920
|
-
const topLeft = `${
|
|
4921
|
-
const bottomRight = `${
|
|
5150
|
+
const topLeft = `${G(Math.min(startX, endX))}${bt(Math.min(startY, endY))}`;
|
|
5151
|
+
const bottomRight = `${G(Math.max(startX, endX))}${bt(Math.max(startY, endY))}`;
|
|
4922
5152
|
return `${topLeft}:${bottomRight}`;
|
|
4923
5153
|
}, [selectingZone, hasSelection]);
|
|
4924
5154
|
const handleRangeClick = useCallback(() => {
|
|
@@ -4941,13 +5171,13 @@ const SearchBar = () => {
|
|
|
4941
5171
|
return "";
|
|
4942
5172
|
}
|
|
4943
5173
|
const { startY, startX, endY, endX } = searchRange;
|
|
4944
|
-
const topLeft = `${
|
|
4945
|
-
const bottomRight = `${
|
|
5174
|
+
const topLeft = `${G(startX)}${bt(startY)}`;
|
|
5175
|
+
const bottomRight = `${G(endX)}${bt(endY)}`;
|
|
4946
5176
|
return `${topLeft}:${bottomRight}`;
|
|
4947
5177
|
}, [searchRange]);
|
|
4948
5178
|
const handleCloseClick = useCallback(() => {
|
|
4949
5179
|
dispatch(setSearchQuery(void 0));
|
|
4950
|
-
|
|
5180
|
+
_(editorRef.current);
|
|
4951
5181
|
}, [editorRef]);
|
|
4952
5182
|
if (typeof searchQuery === "undefined") {
|
|
4953
5183
|
return null;
|
|
@@ -5030,7 +5260,8 @@ function GridSheet({
|
|
|
5030
5260
|
options = {},
|
|
5031
5261
|
className,
|
|
5032
5262
|
style,
|
|
5033
|
-
book: initialBook
|
|
5263
|
+
book: initialBook,
|
|
5264
|
+
loading: loadingProp
|
|
5034
5265
|
}) {
|
|
5035
5266
|
var _a, _b, _c;
|
|
5036
5267
|
const {
|
|
@@ -5042,16 +5273,16 @@ function GridSheet({
|
|
|
5042
5273
|
formulaBarBorders = { all: true },
|
|
5043
5274
|
matrixBorders = { all: true }
|
|
5044
5275
|
} = options;
|
|
5045
|
-
const
|
|
5276
|
+
const bw2 = (b, side) => b[side] ?? b.all ?? false ? "1px" : "0";
|
|
5046
5277
|
const borderVars = {
|
|
5047
|
-
"--gs-fb-bl":
|
|
5048
|
-
"--gs-fb-bt":
|
|
5049
|
-
"--gs-fb-br":
|
|
5050
|
-
"--gs-fb-bb":
|
|
5051
|
-
"--gs-mx-bl":
|
|
5052
|
-
"--gs-mx-bt":
|
|
5053
|
-
"--gs-mx-br":
|
|
5054
|
-
"--gs-mx-bb":
|
|
5278
|
+
"--gs-fb-bl": bw2(formulaBarBorders, "left"),
|
|
5279
|
+
"--gs-fb-bt": bw2(formulaBarBorders, "top"),
|
|
5280
|
+
"--gs-fb-br": bw2(formulaBarBorders, "right"),
|
|
5281
|
+
"--gs-fb-bb": bw2(formulaBarBorders, "bottom"),
|
|
5282
|
+
"--gs-mx-bl": bw2(matrixBorders, "left"),
|
|
5283
|
+
"--gs-mx-bt": bw2(matrixBorders, "top"),
|
|
5284
|
+
"--gs-mx-br": bw2(matrixBorders, "right"),
|
|
5285
|
+
"--gs-mx-bb": bw2(matrixBorders, "bottom")
|
|
5055
5286
|
};
|
|
5056
5287
|
const rootRef = useRef(null);
|
|
5057
5288
|
const flashRef = useRef(null);
|
|
@@ -5084,7 +5315,7 @@ function GridSheet({
|
|
|
5084
5315
|
console.debug("GridSheet: sheetName is not provided, using default name:", sheetName);
|
|
5085
5316
|
}
|
|
5086
5317
|
const { limits, contextMenu, rowMenu, colMenu, eager } = options;
|
|
5087
|
-
const sheet = new
|
|
5318
|
+
const sheet = new Y({
|
|
5088
5319
|
limits,
|
|
5089
5320
|
name: sheetName,
|
|
5090
5321
|
registry,
|
|
@@ -5134,7 +5365,8 @@ function GridSheet({
|
|
|
5134
5365
|
columnMenuState: null,
|
|
5135
5366
|
rowMenuState: null,
|
|
5136
5367
|
editorHovering: true,
|
|
5137
|
-
mode: "light"
|
|
5368
|
+
mode: "light",
|
|
5369
|
+
pendingAsyncOp: null
|
|
5138
5370
|
};
|
|
5139
5371
|
return store2;
|
|
5140
5372
|
});
|
|
@@ -5144,7 +5376,7 @@ function GridSheet({
|
|
|
5144
5376
|
() => initialState
|
|
5145
5377
|
);
|
|
5146
5378
|
useEffect(() => {
|
|
5147
|
-
|
|
5379
|
+
me();
|
|
5148
5380
|
}, []);
|
|
5149
5381
|
const fillWidth = typeof options.sheetWidth === "string";
|
|
5150
5382
|
const fillHeight = typeof options.sheetHeight === "string";
|
|
@@ -5198,24 +5430,74 @@ function GridSheet({
|
|
|
5198
5430
|
}
|
|
5199
5431
|
}, [options.sheetWidth]);
|
|
5200
5432
|
const [loading, setLoading] = useState(false);
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
setLoading(false);
|
|
5204
|
-
}
|
|
5205
|
-
});
|
|
5433
|
+
const latestStoreRef = useRef(store);
|
|
5434
|
+
latestStoreRef.current = store;
|
|
5206
5435
|
const wrappedDispatch = useCallback(
|
|
5207
5436
|
(action) => {
|
|
5208
|
-
|
|
5437
|
+
const async = isAsyncMutationAction(action.type);
|
|
5438
|
+
const mutating = isMutationAction(action.type);
|
|
5439
|
+
if (latestStoreRef.current.pendingAsyncOp != null && (async || mutating)) {
|
|
5440
|
+
return;
|
|
5441
|
+
}
|
|
5442
|
+
if (async) {
|
|
5209
5443
|
dispatch(action);
|
|
5210
5444
|
return;
|
|
5211
5445
|
}
|
|
5212
|
-
|
|
5213
|
-
requestAnimationFrame(() => {
|
|
5446
|
+
if (!mutating) {
|
|
5214
5447
|
dispatch(action);
|
|
5215
|
-
|
|
5448
|
+
return;
|
|
5449
|
+
}
|
|
5450
|
+
setLoading(true);
|
|
5451
|
+
requestAnimationFrame(
|
|
5452
|
+
() => requestAnimationFrame(() => {
|
|
5453
|
+
dispatch(action);
|
|
5454
|
+
setLoading(false);
|
|
5455
|
+
})
|
|
5456
|
+
);
|
|
5216
5457
|
},
|
|
5217
5458
|
[dispatch]
|
|
5218
5459
|
);
|
|
5460
|
+
const overlayRef = useRef(null);
|
|
5461
|
+
const pendingAsyncOp = store.pendingAsyncOp;
|
|
5462
|
+
useEffect(() => {
|
|
5463
|
+
if (pendingAsyncOp == null) {
|
|
5464
|
+
return;
|
|
5465
|
+
}
|
|
5466
|
+
let cancelled = false;
|
|
5467
|
+
const raf = requestAnimationFrame(
|
|
5468
|
+
() => requestAnimationFrame(async () => {
|
|
5469
|
+
var _a2;
|
|
5470
|
+
if (cancelled) {
|
|
5471
|
+
return;
|
|
5472
|
+
}
|
|
5473
|
+
try {
|
|
5474
|
+
const nextSheet = await pendingAsyncOp.run((ratio) => {
|
|
5475
|
+
var _a3;
|
|
5476
|
+
(_a3 = overlayRef.current) == null ? void 0 : _a3.setProgress(ratio);
|
|
5477
|
+
});
|
|
5478
|
+
if (!cancelled) {
|
|
5479
|
+
dispatch(
|
|
5480
|
+
commitAsyncOp({
|
|
5481
|
+
sheet: nextSheet,
|
|
5482
|
+
selectingZone: pendingAsyncOp.selectingZone,
|
|
5483
|
+
finalize: pendingAsyncOp.finalize
|
|
5484
|
+
})
|
|
5485
|
+
);
|
|
5486
|
+
(_a2 = pendingAsyncOp.postCommit) == null ? void 0 : _a2.call(pendingAsyncOp);
|
|
5487
|
+
}
|
|
5488
|
+
} catch (e) {
|
|
5489
|
+
console.error("[gridsheet] async op failed:", e);
|
|
5490
|
+
if (!cancelled) {
|
|
5491
|
+
dispatch(commitAsyncOp({ sheet: latestStoreRef.current.sheetReactive.current, selectingZone: pendingAsyncOp.selectingZone }));
|
|
5492
|
+
}
|
|
5493
|
+
}
|
|
5494
|
+
})
|
|
5495
|
+
);
|
|
5496
|
+
return () => {
|
|
5497
|
+
cancelled = true;
|
|
5498
|
+
cancelAnimationFrame(raf);
|
|
5499
|
+
};
|
|
5500
|
+
}, [pendingAsyncOp, dispatch]);
|
|
5219
5501
|
return /* @__PURE__ */ jsx(Context.Provider, { value: { store, dispatch: wrappedDispatch }, children: /* @__PURE__ */ jsxs(
|
|
5220
5502
|
"div",
|
|
5221
5503
|
{
|
|
@@ -5272,7 +5554,22 @@ function GridSheet({
|
|
|
5272
5554
|
/* @__PURE__ */ jsx(RowMenu, {}),
|
|
5273
5555
|
/* @__PURE__ */ jsx(Resizer, {}),
|
|
5274
5556
|
/* @__PURE__ */ jsx(Emitter, {}),
|
|
5275
|
-
|
|
5557
|
+
store.pendingAsyncOp != null ? (
|
|
5558
|
+
// Chunked async mutation (large fill/paste): imperative progress, grid not re-rendered.
|
|
5559
|
+
/* @__PURE__ */ jsx(AsyncProgressOverlay, { ref: overlayRef, label: store.pendingAsyncOp.label })
|
|
5560
|
+
) : loading ? (
|
|
5561
|
+
// Internal sync mutation in flight: brief indeterminate spinner.
|
|
5562
|
+
/* @__PURE__ */ jsx("div", { className: "gs-loading-overlay", children: /* @__PURE__ */ jsx("div", { className: "gs-loading-spinner" }) })
|
|
5563
|
+
) : loadingProp ? (
|
|
5564
|
+
// Consumer-driven initial loading (data not ready yet).
|
|
5565
|
+
/* @__PURE__ */ jsx(
|
|
5566
|
+
ProgressOverlay,
|
|
5567
|
+
{
|
|
5568
|
+
progress: typeof loadingProp === "object" ? loadingProp.progress ?? null : null,
|
|
5569
|
+
label: typeof loadingProp === "object" ? loadingProp.label : void 0
|
|
5570
|
+
}
|
|
5571
|
+
)
|
|
5572
|
+
) : null
|
|
5276
5573
|
]
|
|
5277
5574
|
}
|
|
5278
5575
|
)
|
|
@@ -5282,13 +5579,13 @@ function GridSheet({
|
|
|
5282
5579
|
}
|
|
5283
5580
|
const estimateSheetHeight = (initialCells) => {
|
|
5284
5581
|
var _a, _b, _c, _d, _e;
|
|
5285
|
-
const auto =
|
|
5286
|
-
let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ??
|
|
5582
|
+
const auto = Hs(initialCells);
|
|
5583
|
+
let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? $e;
|
|
5287
5584
|
for (let y = 1; y <= auto.numRows; y++) {
|
|
5288
|
-
const row =
|
|
5289
|
-
const height = ((_b = initialCells == null ? void 0 : initialCells[row]) == null ? void 0 : _b.height) || ((_c = initialCells == null ? void 0 : initialCells["0" + row]) == null ? void 0 : _c.height) || ((_d = initialCells == null ? void 0 : initialCells[
|
|
5290
|
-
if (estimatedHeight + height >
|
|
5291
|
-
return
|
|
5585
|
+
const row = bt(y);
|
|
5586
|
+
const height = ((_b = initialCells == null ? void 0 : initialCells[row]) == null ? void 0 : _b.height) || ((_c = initialCells == null ? void 0 : initialCells["0" + row]) == null ? void 0 : _c.height) || ((_d = initialCells == null ? void 0 : initialCells[$t]) == null ? void 0 : _d.height) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.height) || rt;
|
|
5587
|
+
if (estimatedHeight + height > jr) {
|
|
5588
|
+
return jr;
|
|
5292
5589
|
}
|
|
5293
5590
|
estimatedHeight += height;
|
|
5294
5591
|
}
|
|
@@ -5296,13 +5593,13 @@ const estimateSheetHeight = (initialCells) => {
|
|
|
5296
5593
|
};
|
|
5297
5594
|
const estimateSheetWidth = (initialCells) => {
|
|
5298
5595
|
var _a, _b, _c, _d, _e;
|
|
5299
|
-
const auto =
|
|
5300
|
-
let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ??
|
|
5596
|
+
const auto = Hs(initialCells);
|
|
5597
|
+
let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ?? Le;
|
|
5301
5598
|
for (let x = 1; x <= auto.numCols; x++) {
|
|
5302
|
-
const col =
|
|
5303
|
-
const width = ((_b = initialCells == null ? void 0 : initialCells[col]) == null ? void 0 : _b.width) || ((_c = initialCells == null ? void 0 : initialCells[col + "0"]) == null ? void 0 : _c.width) || ((_d = initialCells == null ? void 0 : initialCells[
|
|
5304
|
-
if (estimatedWidth + width >
|
|
5305
|
-
return
|
|
5599
|
+
const col = G(x);
|
|
5600
|
+
const width = ((_b = initialCells == null ? void 0 : initialCells[col]) == null ? void 0 : _b.width) || ((_c = initialCells == null ? void 0 : initialCells[col + "0"]) == null ? void 0 : _c.width) || ((_d = initialCells == null ? void 0 : initialCells[kt]) == null ? void 0 : _d.width) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.width) || he;
|
|
5601
|
+
if (estimatedWidth + width > Gr) {
|
|
5602
|
+
return Gr;
|
|
5306
5603
|
}
|
|
5307
5604
|
estimatedWidth += width;
|
|
5308
5605
|
}
|
|
@@ -5343,96 +5640,99 @@ function makeBorder(options) {
|
|
|
5343
5640
|
return result;
|
|
5344
5641
|
}
|
|
5345
5642
|
export {
|
|
5346
|
-
BaseFunction,
|
|
5347
|
-
BaseFunctionAsync,
|
|
5643
|
+
bi as BaseFunction,
|
|
5644
|
+
bj as BaseFunctionAsync,
|
|
5348
5645
|
CheckboxPolicyMixin,
|
|
5349
5646
|
Children,
|
|
5350
5647
|
Component,
|
|
5351
|
-
DEFAULT_HISTORY_LIMIT,
|
|
5352
|
-
|
|
5353
|
-
FormulaParser,
|
|
5648
|
+
bA as DEFAULT_HISTORY_LIMIT,
|
|
5649
|
+
S as FormulaError,
|
|
5650
|
+
bk as FormulaParser,
|
|
5354
5651
|
Fragment2 as Fragment,
|
|
5355
5652
|
GridSheet,
|
|
5356
|
-
|
|
5653
|
+
te as Lexer,
|
|
5357
5654
|
MenuDivider,
|
|
5358
5655
|
MenuItem,
|
|
5359
|
-
|
|
5360
|
-
PercentagePolicyMixin,
|
|
5656
|
+
L as Pending,
|
|
5657
|
+
bz as PercentagePolicyMixin,
|
|
5361
5658
|
PluginBase,
|
|
5362
|
-
Policy,
|
|
5659
|
+
bx as Policy,
|
|
5660
|
+
ProgressOverlay,
|
|
5363
5661
|
PureComponent,
|
|
5364
|
-
RangeEntity,
|
|
5365
|
-
RefEntity,
|
|
5366
|
-
Registry,
|
|
5367
|
-
|
|
5368
|
-
Spilling,
|
|
5662
|
+
bn2 as RangeEntity,
|
|
5663
|
+
bl as RefEntity,
|
|
5664
|
+
b6 as Registry,
|
|
5665
|
+
Y as Sheet,
|
|
5666
|
+
bB as Spilling,
|
|
5369
5667
|
StrictMode,
|
|
5370
5668
|
Suspense,
|
|
5371
5669
|
SuspenseList,
|
|
5372
|
-
ThousandSeparatorPolicyMixin,
|
|
5373
|
-
Time,
|
|
5374
|
-
ValueEntity,
|
|
5375
|
-
|
|
5376
|
-
aa2oa,
|
|
5377
|
-
addressesToAreas,
|
|
5378
|
-
addressesToCols,
|
|
5379
|
-
addressesToRows,
|
|
5670
|
+
by as ThousandSeparatorPolicyMixin,
|
|
5671
|
+
b1 as Time,
|
|
5672
|
+
bm as ValueEntity,
|
|
5673
|
+
T as a2p,
|
|
5674
|
+
aW as aa2oa,
|
|
5675
|
+
a_ as addressesToAreas,
|
|
5676
|
+
a$ as addressesToCols,
|
|
5677
|
+
b0 as addressesToRows,
|
|
5380
5678
|
applyers,
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
buildInitialCells,
|
|
5384
|
-
buildInitialCellsFromOrigin,
|
|
5385
|
-
c2x,
|
|
5386
|
-
ch,
|
|
5387
|
-
check,
|
|
5679
|
+
rn as areaToRange,
|
|
5680
|
+
Pe as areaToZone,
|
|
5681
|
+
aX as buildInitialCells,
|
|
5682
|
+
aY as buildInitialCellsFromOrigin,
|
|
5683
|
+
b2 as c2x,
|
|
5684
|
+
b5 as ch,
|
|
5685
|
+
bs as check,
|
|
5388
5686
|
clip,
|
|
5389
5687
|
cloneElement,
|
|
5390
5688
|
render2 as compatRender,
|
|
5391
|
-
conditionArg,
|
|
5392
|
-
createBook,
|
|
5393
|
-
createBooleanMask,
|
|
5689
|
+
bv as conditionArg,
|
|
5690
|
+
b7 as createBook,
|
|
5691
|
+
bu as createBooleanMask,
|
|
5394
5692
|
createContext2 as createContext,
|
|
5395
5693
|
createElement,
|
|
5396
5694
|
createFactory,
|
|
5397
5695
|
createPortal2 as createPortal,
|
|
5398
5696
|
createRef2 as createRef,
|
|
5399
|
-
createRegistry,
|
|
5697
|
+
b8 as createRegistry,
|
|
5400
5698
|
createSheetRef,
|
|
5401
5699
|
createStoreRef,
|
|
5402
5700
|
defaultColMenuDescriptors,
|
|
5403
5701
|
defaultContextMenuDescriptors,
|
|
5404
5702
|
defaultRowMenuDescriptors,
|
|
5405
|
-
eachMatrix,
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5703
|
+
bt2 as eachMatrix,
|
|
5704
|
+
me as embedStyle,
|
|
5705
|
+
bq as ensureBoolean,
|
|
5706
|
+
br as ensureDate,
|
|
5707
|
+
bp as ensureNumber,
|
|
5708
|
+
bo as ensureString,
|
|
5410
5709
|
findDOMNode,
|
|
5411
|
-
forwardRef,
|
|
5710
|
+
forwardRef2 as forwardRef,
|
|
5412
5711
|
h,
|
|
5413
5712
|
hydrate,
|
|
5414
5713
|
isValidElement,
|
|
5415
5714
|
lazy,
|
|
5416
5715
|
makeBorder,
|
|
5417
|
-
matrixShape,
|
|
5716
|
+
aZ as matrixShape,
|
|
5418
5717
|
memo2 as memo,
|
|
5419
|
-
oa2aa,
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
r2y,
|
|
5718
|
+
aV as oa2aa,
|
|
5719
|
+
Mn as operations,
|
|
5720
|
+
M as p2a,
|
|
5721
|
+
b3 as r2y,
|
|
5423
5722
|
registerMenuComponent,
|
|
5424
5723
|
render,
|
|
5425
|
-
rh,
|
|
5724
|
+
b4 as rh,
|
|
5426
5725
|
sheet2csv,
|
|
5427
|
-
stripMatrix,
|
|
5428
|
-
toCellCols,
|
|
5429
|
-
toCellMatrix,
|
|
5430
|
-
toCellObject,
|
|
5431
|
-
toCellRows,
|
|
5432
|
-
toValueCols,
|
|
5433
|
-
toValueMatrix,
|
|
5434
|
-
|
|
5435
|
-
|
|
5726
|
+
bw as stripMatrix,
|
|
5727
|
+
bh as toCellCols,
|
|
5728
|
+
be2 as toCellMatrix,
|
|
5729
|
+
bf as toCellObject,
|
|
5730
|
+
bg as toCellRows,
|
|
5731
|
+
bd as toValueCols,
|
|
5732
|
+
b9 as toValueMatrix,
|
|
5733
|
+
ba as toValueMatrixAsync,
|
|
5734
|
+
bb as toValueObject,
|
|
5735
|
+
bc as toValueRows,
|
|
5436
5736
|
unmountComponentAtNode,
|
|
5437
5737
|
unstable_batchedUpdates,
|
|
5438
5738
|
updateSheet,
|
|
@@ -5441,7 +5741,7 @@ export {
|
|
|
5441
5741
|
useContext2 as useContext,
|
|
5442
5742
|
useDebugValue,
|
|
5443
5743
|
useEffect2 as useEffect,
|
|
5444
|
-
useImperativeHandle,
|
|
5744
|
+
useImperativeHandle2 as useImperativeHandle,
|
|
5445
5745
|
useInitialPluginContext,
|
|
5446
5746
|
useLayoutEffect2 as useLayoutEffect,
|
|
5447
5747
|
useMemo2 as useMemo,
|
|
@@ -5451,10 +5751,10 @@ export {
|
|
|
5451
5751
|
useSheetRef,
|
|
5452
5752
|
useState2 as useState,
|
|
5453
5753
|
useStoreRef,
|
|
5454
|
-
|
|
5754
|
+
bC as userActions,
|
|
5455
5755
|
version,
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5756
|
+
G as x2c,
|
|
5757
|
+
bt as y2r,
|
|
5758
|
+
ks as zoneToArea
|
|
5459
5759
|
};
|
|
5460
5760
|
//# sourceMappingURL=index.js.map
|