@gridsheet/preact-core 3.0.0-rc.8 → 3.0.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/LICENSE +190 -0
- package/README.md +28 -34
- package/dist/{react-core/src/components → components}/FunctionGuide.d.ts +1 -2
- package/dist/{react-core/src/components → components}/useAutocomplete.d.ts +1 -3
- package/dist/{hooks-hS8l-fYa.mjs → hooks-DPIr6WaL.mjs} +3 -9
- package/dist/hooks-DPIr6WaL.mjs.map +1 -0
- package/dist/index.d.ts +17 -3
- package/dist/index.js +97 -111
- package/dist/index.js.map +1 -1
- package/dist/{react-core/src/lib → lib}/clipboard.d.ts +1 -1
- package/dist/{react-core/src/lib → lib}/hooks.d.ts +1 -1
- package/dist/{react-core/src/lib → lib}/menu.d.ts +1 -1
- package/dist/policy/checkbox.d.ts +3 -0
- package/dist/spellbook.d.ts +6 -2
- package/dist/spellbook.js +1 -1
- package/dist/{react-core/src/store → store}/actions.d.ts +1 -1
- package/dist/{react-core/src/store → store}/helpers.d.ts +1 -1
- package/dist/{react-core/src/types.d.ts → types.d.ts} +2 -5
- package/package.json +11 -12
- package/dist/hooks-hS8l-fYa.mjs.map +0 -1
- package/dist/react-core/src/index.d.ts +0 -17
- package/dist/react-core/src/policy/checkbox.d.ts +0 -3
- package/dist/react-core/src/spellbook.d.ts +0 -6
- /package/dist/{react-core/src/components → components}/Cell.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/CellStateOverlay.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/ColumnMenu.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/ColumnMenuFilterSection.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/ColumnMenuLabelSection.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/ColumnMenuSortSection.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/ContextMenu.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/Editor.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/EditorOptions.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/Emitter.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/Fixed.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/FormulaBar.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/GridSheet.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/HeaderCellLeft.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/HeaderCellTop.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/MenuItem.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/PluginBase.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/Resizer.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/RowMenu.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/ScrollHandle.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/SearchBar.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/StoreObserver.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/Tabular.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/svg/AddIcon.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/svg/Base.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/svg/CloseIcon.d.ts +0 -0
- /package/dist/{react-core/src/components → components}/svg/SearchIcon.d.ts +0 -0
- /package/dist/{react-core/src/lib → lib}/events.d.ts +0 -0
- /package/dist/{react-core/src/lib → lib}/paste.d.ts +0 -0
- /package/dist/{react-core/src/lib → lib}/style.d.ts +0 -0
- /package/dist/{react-core/src/store → store}/applyers.d.ts +0 -0
- /package/dist/{react-core/src/store → store}/index.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
import { h, render } from "preact";
|
|
2
|
-
import {
|
|
2
|
+
import { calcSideStyle, clampPopup, clampLeft, zoneToArea, focus, Lexer, getFunctionHelps, expandInput, y2r, x2c, resetInput, handleFormulaQuoteAutoClose, areaToZone, insertTextAtCursor, operations, isRefInsertable, COLOR_PALETTE, DEFAULT_WIDTH, DEFAULT_HEIGHT, between, makeSequence, p2a, MIN_HEIGHT, MIN_WIDTH, zoneShape, getLabel, FormulaError, Pending, insertRef, areaToRange, calcBelowPosition, hAlignTransform, among, getAreaInTabular, isFocus, Autofill, getCellRectPositions, a2p, virtualize, stripAddressAbsolute, stripSheetName, preventSafariBounce, smartScroll, isZoneNotSelected, Sheet, embedStyle, getMaxSizesFromCells, HEADER_HEIGHT, DEFAULT_ROW_KEY, SHEET_HEIGHT, HEADER_WIDTH, DEFAULT_COL_KEY, SHEET_WIDTH } from "@gridsheet/core";
|
|
3
|
+
import { BaseFunction, BaseFunctionAsync, DEFAULT_HISTORY_LIMIT, FormulaError as FormulaError2, FormulaParser, Lexer as Lexer2, Pending as Pending2, Policy, RangeEntity, RefEntity, Registry, Sheet as Sheet2, Spilling, ThousandSeparatorPolicyMixin, Time, ValueEntity, a2p as a2p2, aa2oa, addressesToAreas, addressesToCols, addressesToRows, areaToRange as areaToRange2, areaToZone as areaToZone2, buildInitialCells, buildInitialCellsFromOrigin, c2x, ch, check, conditionArg, createBook, createBooleanMask, createRegistry, eachMatrix, ensureBoolean, ensureDate, ensureNumber, ensureString, matrixShape, oa2aa, operations as operations2, p2a as p2a2, r2y, rh, stripMatrix, toCellCols, toCellMatrix, toCellObject, toCellRows, toValueCols, toValueMatrix, toValueObject, toValueRows, x2c as x2c2, y2r as y2r2, zoneToArea as zoneToArea2 } from "@gridsheet/core";
|
|
3
4
|
import { jsxs, jsx, Fragment } from "preact/compat/jsx-runtime";
|
|
4
5
|
import React, { createContext, useRef, useContext, useLayoutEffect, useState, useMemo, useCallback, createPortal, memo, useEffect, createRef, useReducer } from "preact/compat";
|
|
5
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";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { W } from "./hooks-hS8l-fYa.mjs";
|
|
9
|
-
import { calcSideStyle, clampPopup, clampLeft, calcBelowPosition, hAlignTransform } from "@gridsheet/core/lib/popup";
|
|
10
|
-
import { y2r as y2r2, x2c as x2c2, p2a as p2a2, a2p as a2p2, stripAddressAbsolute } from "@gridsheet/core/lib/coords";
|
|
11
|
-
import { zoneToArea as zoneToArea2, areaToZone as areaToZone2, between, makeSequence, zoneShape, areaToRange as areaToRange2, among, isZoneNotSelected, getMaxSizesFromCells } from "@gridsheet/core/lib/spatial";
|
|
12
|
-
import { focus, preventSafariBounce } from "@gridsheet/core/lib/dom";
|
|
13
|
-
import * as prevention from "@gridsheet/core/lib/operation";
|
|
14
|
-
import { expandInput, resetInput, handleFormulaQuoteAutoClose, insertTextAtCursor, isRefInsertable, insertRef, isFocus } from "@gridsheet/core/lib/input";
|
|
15
|
-
import { Lexer as Lexer2, stripSheetName } from "@gridsheet/core/formula/evaluator";
|
|
16
|
-
import { COLOR_PALETTE } from "@gridsheet/core/lib/palette";
|
|
17
|
-
import { getFunctionHelps } from "@gridsheet/core/formula/mapping";
|
|
18
|
-
import { getLabel } from "@gridsheet/core/lib/label";
|
|
19
|
-
import { Sheet as Sheet2 } from "@gridsheet/core/lib/sheet";
|
|
20
|
-
import { FormulaError as FormulaError2 } from "@gridsheet/core/formula/formula-error";
|
|
21
|
-
import { Pending as Pending2 } from "@gridsheet/core/sentinels";
|
|
22
|
-
import { getAreaInTabular, getCellRectPositions, virtualize, smartScroll } from "@gridsheet/core/lib/virtualization";
|
|
23
|
-
import { Autofill } from "@gridsheet/core/lib/autofill";
|
|
24
|
-
import { embedStyle } from "@gridsheet/core/styles/embedder";
|
|
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 } from "./hooks-DPIr6WaL.mjs";
|
|
8
|
+
import { W } from "./hooks-DPIr6WaL.mjs";
|
|
25
9
|
const Context = createContext(
|
|
26
10
|
{}
|
|
27
11
|
);
|
|
@@ -194,7 +178,7 @@ const clip = (store) => {
|
|
|
194
178
|
return { top: 0, left: 0, bottom: 0, right: 0 };
|
|
195
179
|
}
|
|
196
180
|
const { y, x } = choosing;
|
|
197
|
-
const selectingArea =
|
|
181
|
+
const selectingArea = zoneToArea(selectingZone);
|
|
198
182
|
let area = selectingArea;
|
|
199
183
|
if (area.left === -1) {
|
|
200
184
|
area = { top: y, left: x, bottom: y, right: x };
|
|
@@ -315,7 +299,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
|
|
|
315
299
|
if (isFormula && textBeforeCursor.length > 1) {
|
|
316
300
|
try {
|
|
317
301
|
const textToCursor = textBeforeCursor.slice(1);
|
|
318
|
-
const lexer = new
|
|
302
|
+
const lexer = new Lexer(textToCursor);
|
|
319
303
|
lexer.tokenize();
|
|
320
304
|
const functionStack = [];
|
|
321
305
|
for (let i = 0; i < lexer.tokens.length; i++) {
|
|
@@ -357,7 +341,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
|
|
|
357
341
|
let isOnAddress = false;
|
|
358
342
|
if (isFormula) {
|
|
359
343
|
try {
|
|
360
|
-
const fullLexer = new
|
|
344
|
+
const fullLexer = new Lexer(inputting.slice(1));
|
|
361
345
|
fullLexer.tokenize();
|
|
362
346
|
let currentIndex = 1;
|
|
363
347
|
for (const token of fullLexer.tokens) {
|
|
@@ -842,8 +826,8 @@ const Editor = ({ mode }) => {
|
|
|
842
826
|
expandInput(editorRef.current);
|
|
843
827
|
}, [inputting, editingAddress, editorRef]);
|
|
844
828
|
const { y, x } = choosing;
|
|
845
|
-
const rowId = `${
|
|
846
|
-
const colId =
|
|
829
|
+
const rowId = `${y2r(y)}`;
|
|
830
|
+
const colId = x2c(x);
|
|
847
831
|
const address = `${colId}${rowId}`;
|
|
848
832
|
const editing = editingAddress === address;
|
|
849
833
|
const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "RAW" });
|
|
@@ -1106,7 +1090,7 @@ const Editor = ({ mode }) => {
|
|
|
1106
1090
|
if (!editing) {
|
|
1107
1091
|
e.preventDefault();
|
|
1108
1092
|
const area = clip(store);
|
|
1109
|
-
dispatch(copy(
|
|
1093
|
+
dispatch(copy(areaToZone(area)));
|
|
1110
1094
|
focus(input);
|
|
1111
1095
|
return false;
|
|
1112
1096
|
}
|
|
@@ -1171,7 +1155,7 @@ const Editor = ({ mode }) => {
|
|
|
1171
1155
|
if (!editing) {
|
|
1172
1156
|
e.preventDefault();
|
|
1173
1157
|
const area = clip(store);
|
|
1174
|
-
dispatch(cut(
|
|
1158
|
+
dispatch(cut(areaToZone(area)));
|
|
1175
1159
|
focus(input);
|
|
1176
1160
|
return false;
|
|
1177
1161
|
}
|
|
@@ -1202,7 +1186,7 @@ const Editor = ({ mode }) => {
|
|
|
1202
1186
|
if (e.ctrlKey || e.metaKey) {
|
|
1203
1187
|
return false;
|
|
1204
1188
|
}
|
|
1205
|
-
if (
|
|
1189
|
+
if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
|
|
1206
1190
|
console.warn("This cell is protected from writing.");
|
|
1207
1191
|
return false;
|
|
1208
1192
|
}
|
|
@@ -1243,7 +1227,7 @@ const Editor = ({ mode }) => {
|
|
|
1243
1227
|
);
|
|
1244
1228
|
const handleDoubleClick = useCallback(
|
|
1245
1229
|
(e) => {
|
|
1246
|
-
if (
|
|
1230
|
+
if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
|
|
1247
1231
|
console.warn("This cell is protected from writing.");
|
|
1248
1232
|
return;
|
|
1249
1233
|
}
|
|
@@ -1277,10 +1261,11 @@ const Editor = ({ mode }) => {
|
|
|
1277
1261
|
);
|
|
1278
1262
|
const handleChange = useCallback(
|
|
1279
1263
|
(e) => {
|
|
1280
|
-
if (
|
|
1264
|
+
if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
|
|
1281
1265
|
return;
|
|
1282
1266
|
}
|
|
1283
1267
|
dispatch(setInputting(e.currentTarget.value));
|
|
1268
|
+
setSelectionStart(e.currentTarget.selectionStart);
|
|
1284
1269
|
setSelected(0);
|
|
1285
1270
|
},
|
|
1286
1271
|
[cell]
|
|
@@ -1313,7 +1298,7 @@ const Editor = ({ mode }) => {
|
|
|
1313
1298
|
(e) => {
|
|
1314
1299
|
var _a2, _b2;
|
|
1315
1300
|
setShiftKey(false);
|
|
1316
|
-
const selectingArea =
|
|
1301
|
+
const selectingArea = zoneToArea(store.selectingZone);
|
|
1317
1302
|
(_b2 = sheet == null ? void 0 : (_a2 = sheet.registry).onKeyUp) == null ? void 0 : _b2.call(_a2, {
|
|
1318
1303
|
e,
|
|
1319
1304
|
points: {
|
|
@@ -1408,7 +1393,7 @@ const editorStyle = (text) => {
|
|
|
1408
1393
|
if (text[0] !== "=") {
|
|
1409
1394
|
return /* @__PURE__ */ jsx(Fragment, { children: text });
|
|
1410
1395
|
}
|
|
1411
|
-
const lexer = new
|
|
1396
|
+
const lexer = new Lexer(text.substring(1));
|
|
1412
1397
|
lexer.tokenize();
|
|
1413
1398
|
let palletIndex = 0;
|
|
1414
1399
|
const exists = {};
|
|
@@ -1591,7 +1576,7 @@ const Resizer = () => {
|
|
|
1591
1576
|
const width = baseWidth + (endX - startX);
|
|
1592
1577
|
const height = baseHeight + (endY - startY);
|
|
1593
1578
|
const handleResizeEnd = () => {
|
|
1594
|
-
const selectingArea =
|
|
1579
|
+
const selectingArea = zoneToArea(selectingZone);
|
|
1595
1580
|
const { top, left, bottom, right } = selectingArea;
|
|
1596
1581
|
const diff = {};
|
|
1597
1582
|
if (x !== -1) {
|
|
@@ -1600,7 +1585,7 @@ const Resizer = () => {
|
|
|
1600
1585
|
xs = makeSequence(left, right + 1);
|
|
1601
1586
|
}
|
|
1602
1587
|
xs.forEach((x2) => {
|
|
1603
|
-
diff[
|
|
1588
|
+
diff[p2a({ y: 0, x: x2 })] = { width };
|
|
1604
1589
|
});
|
|
1605
1590
|
}
|
|
1606
1591
|
if (y !== -1) {
|
|
@@ -1609,7 +1594,7 @@ const Resizer = () => {
|
|
|
1609
1594
|
ys = makeSequence(top, bottom + 1);
|
|
1610
1595
|
}
|
|
1611
1596
|
ys.forEach((y2) => {
|
|
1612
|
-
diff[
|
|
1597
|
+
diff[p2a({ y: y2, x: 0 })] = { height };
|
|
1613
1598
|
});
|
|
1614
1599
|
}
|
|
1615
1600
|
sheet.update({
|
|
@@ -1696,13 +1681,13 @@ const Emitter = () => {
|
|
|
1696
1681
|
const copier = async ({ store, dispatch }) => {
|
|
1697
1682
|
const { editorRef } = store;
|
|
1698
1683
|
const area = clip(store);
|
|
1699
|
-
dispatch(copy(
|
|
1684
|
+
dispatch(copy(areaToZone(area)));
|
|
1700
1685
|
focus(editorRef.current);
|
|
1701
1686
|
};
|
|
1702
1687
|
const cutter = async ({ store, dispatch }) => {
|
|
1703
1688
|
const { editorRef } = store;
|
|
1704
1689
|
const area = clip(store);
|
|
1705
|
-
dispatch(cut(
|
|
1690
|
+
dispatch(cut(areaToZone(area)));
|
|
1706
1691
|
focus(editorRef.current);
|
|
1707
1692
|
};
|
|
1708
1693
|
const paster = async ({ store, dispatch }, onlyValue = false) => {
|
|
@@ -1742,42 +1727,42 @@ const redoer = async ({ store, dispatch }) => {
|
|
|
1742
1727
|
};
|
|
1743
1728
|
const rowsInserterAbove = async ({ store, dispatch }) => {
|
|
1744
1729
|
const { selectingZone, editorRef } = store;
|
|
1745
|
-
const { top } =
|
|
1730
|
+
const { top } = zoneToArea(selectingZone);
|
|
1746
1731
|
const numRows = zoneShape(selectingZone).rows;
|
|
1747
1732
|
dispatch(insertRowsAbove({ numRows, y: top, operator: "USER" }));
|
|
1748
1733
|
focus(editorRef.current);
|
|
1749
1734
|
};
|
|
1750
1735
|
const rowsInserterBelow = async ({ store, dispatch }) => {
|
|
1751
1736
|
const { selectingZone, editorRef } = store;
|
|
1752
|
-
const { bottom } =
|
|
1737
|
+
const { bottom } = zoneToArea(selectingZone);
|
|
1753
1738
|
const numRows = zoneShape(selectingZone).rows;
|
|
1754
1739
|
dispatch(insertRowsBelow({ numRows, y: bottom, operator: "USER" }));
|
|
1755
1740
|
focus(editorRef.current);
|
|
1756
1741
|
};
|
|
1757
1742
|
const colsInserterLeft = async ({ store, dispatch }) => {
|
|
1758
1743
|
const { selectingZone, editorRef } = store;
|
|
1759
|
-
const { left } =
|
|
1744
|
+
const { left } = zoneToArea(selectingZone);
|
|
1760
1745
|
const numCols = zoneShape(selectingZone).cols;
|
|
1761
1746
|
dispatch(insertColsLeft({ numCols, x: left, operator: "USER" }));
|
|
1762
1747
|
focus(editorRef.current);
|
|
1763
1748
|
};
|
|
1764
1749
|
const colsInserterRight = async ({ store, dispatch }) => {
|
|
1765
1750
|
const { selectingZone, editorRef } = store;
|
|
1766
|
-
const { right } =
|
|
1751
|
+
const { right } = zoneToArea(selectingZone);
|
|
1767
1752
|
const numCols = zoneShape(selectingZone).cols;
|
|
1768
1753
|
dispatch(insertColsRight({ numCols, x: right, operator: "USER" }));
|
|
1769
1754
|
focus(editorRef.current);
|
|
1770
1755
|
};
|
|
1771
1756
|
const rowsRemover = async ({ store, dispatch }) => {
|
|
1772
1757
|
const { selectingZone, editorRef } = store;
|
|
1773
|
-
const { top } =
|
|
1758
|
+
const { top } = zoneToArea(selectingZone);
|
|
1774
1759
|
const numRows = zoneShape(selectingZone).rows;
|
|
1775
1760
|
dispatch(removeRows({ numRows, y: top, operator: "USER" }));
|
|
1776
1761
|
focus(editorRef.current);
|
|
1777
1762
|
};
|
|
1778
1763
|
const colsRemover = async ({ store, dispatch }) => {
|
|
1779
1764
|
const { selectingZone, editorRef } = store;
|
|
1780
|
-
const { left } =
|
|
1765
|
+
const { left } = zoneToArea(selectingZone);
|
|
1781
1766
|
const numCols = zoneShape(selectingZone).cols;
|
|
1782
1767
|
dispatch(removeCols({ numCols, x: left, operator: "USER" }));
|
|
1783
1768
|
focus(editorRef.current);
|
|
@@ -1815,7 +1800,7 @@ const rowSortFixedToggler = ({ store, dispatch }, y) => {
|
|
|
1815
1800
|
if (!sheet) {
|
|
1816
1801
|
return;
|
|
1817
1802
|
}
|
|
1818
|
-
const addr =
|
|
1803
|
+
const addr = p2a({ y, x: 0 });
|
|
1819
1804
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
1820
1805
|
const next = !(rowCell == null ? void 0 : rowCell.sortFixed) || void 0;
|
|
1821
1806
|
sheet.update({ diff: { [addr]: { sortFixed: next } }, partial: true });
|
|
@@ -1827,7 +1812,7 @@ const rowFilterFixedToggler = ({ store, dispatch }, y) => {
|
|
|
1827
1812
|
if (!sheet) {
|
|
1828
1813
|
return;
|
|
1829
1814
|
}
|
|
1830
|
-
const addr =
|
|
1815
|
+
const addr = p2a({ y, x: 0 });
|
|
1831
1816
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
1832
1817
|
const next = !(rowCell == null ? void 0 : rowCell.filterFixed) || void 0;
|
|
1833
1818
|
sheet.update({ diff: { [addr]: { filterFixed: next } }, partial: true });
|
|
@@ -1912,7 +1897,7 @@ const defaultContextMenuDescriptors = [
|
|
|
1912
1897
|
const n = zoneShape(ctx.selectingZone).rows;
|
|
1913
1898
|
const sheet = ctx.sheet;
|
|
1914
1899
|
const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
|
|
1915
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
1900
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsAbove);
|
|
1916
1901
|
},
|
|
1917
1902
|
onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
|
|
1918
1903
|
},
|
|
@@ -1927,7 +1912,7 @@ const defaultContextMenuDescriptors = [
|
|
|
1927
1912
|
const n = zoneShape(ctx.selectingZone).rows;
|
|
1928
1913
|
const sheet = ctx.sheet;
|
|
1929
1914
|
const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
|
|
1930
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
1915
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsBelow);
|
|
1931
1916
|
},
|
|
1932
1917
|
onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
|
|
1933
1918
|
},
|
|
@@ -1942,7 +1927,7 @@ const defaultContextMenuDescriptors = [
|
|
|
1942
1927
|
const n = zoneShape(ctx.selectingZone).cols;
|
|
1943
1928
|
const sheet = ctx.sheet;
|
|
1944
1929
|
const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
|
|
1945
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
1930
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsLeft);
|
|
1946
1931
|
},
|
|
1947
1932
|
onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
|
|
1948
1933
|
},
|
|
@@ -1957,7 +1942,7 @@ const defaultContextMenuDescriptors = [
|
|
|
1957
1942
|
const n = zoneShape(ctx.selectingZone).cols;
|
|
1958
1943
|
const sheet = ctx.sheet;
|
|
1959
1944
|
const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
|
|
1960
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
1945
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsRight);
|
|
1961
1946
|
},
|
|
1962
1947
|
onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
|
|
1963
1948
|
},
|
|
@@ -1972,7 +1957,7 @@ const defaultContextMenuDescriptors = [
|
|
|
1972
1957
|
const n = zoneShape(ctx.selectingZone).rows;
|
|
1973
1958
|
const sheet = ctx.sheet;
|
|
1974
1959
|
const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
|
|
1975
|
-
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows ||
|
|
1960
|
+
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.RemoveRows);
|
|
1976
1961
|
},
|
|
1977
1962
|
onClick: (ctx) => ctx.removeRows(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
|
|
1978
1963
|
},
|
|
@@ -1987,7 +1972,7 @@ const defaultContextMenuDescriptors = [
|
|
|
1987
1972
|
const n = zoneShape(ctx.selectingZone).cols;
|
|
1988
1973
|
const sheet = ctx.sheet;
|
|
1989
1974
|
const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
|
|
1990
|
-
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols ||
|
|
1975
|
+
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.RemoveCols);
|
|
1991
1976
|
},
|
|
1992
1977
|
onClick: (ctx) => ctx.removeCols(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
|
|
1993
1978
|
},
|
|
@@ -2050,7 +2035,7 @@ const defaultRowMenuDescriptors = [
|
|
|
2050
2035
|
const n = rowInsertCount(ctx, y);
|
|
2051
2036
|
const sheet = ctx.sheet;
|
|
2052
2037
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
2053
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
2038
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsAbove);
|
|
2054
2039
|
},
|
|
2055
2040
|
onClick: (ctx, y) => ctx.insertRowsAbove(y, rowInsertCount(ctx, y))
|
|
2056
2041
|
},
|
|
@@ -2064,7 +2049,7 @@ const defaultRowMenuDescriptors = [
|
|
|
2064
2049
|
const n = rowInsertCount(ctx, y);
|
|
2065
2050
|
const sheet = ctx.sheet;
|
|
2066
2051
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
2067
|
-
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows ||
|
|
2052
|
+
return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsBelow);
|
|
2068
2053
|
},
|
|
2069
2054
|
onClick: (ctx, y) => ctx.insertRowsBelow(y, rowInsertCount(ctx, y))
|
|
2070
2055
|
},
|
|
@@ -2078,7 +2063,7 @@ const defaultRowMenuDescriptors = [
|
|
|
2078
2063
|
const n = rowInsertCount(ctx, y);
|
|
2079
2064
|
const sheet = ctx.sheet;
|
|
2080
2065
|
const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
|
|
2081
|
-
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows ||
|
|
2066
|
+
return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.RemoveRows);
|
|
2082
2067
|
},
|
|
2083
2068
|
onClick: (ctx, y) => ctx.removeRows(y, rowInsertCount(ctx, y))
|
|
2084
2069
|
},
|
|
@@ -2149,7 +2134,7 @@ const defaultColMenuDescriptors = [
|
|
|
2149
2134
|
const n = colInsertCount(ctx, x);
|
|
2150
2135
|
const sheet = ctx.sheet;
|
|
2151
2136
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2152
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
2137
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsLeft);
|
|
2153
2138
|
},
|
|
2154
2139
|
onClick: (ctx, x) => ctx.insertColsLeft(x, colInsertCount(ctx, x))
|
|
2155
2140
|
},
|
|
@@ -2163,7 +2148,7 @@ const defaultColMenuDescriptors = [
|
|
|
2163
2148
|
const n = colInsertCount(ctx, x);
|
|
2164
2149
|
const sheet = ctx.sheet;
|
|
2165
2150
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2166
|
-
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols ||
|
|
2151
|
+
return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsRight);
|
|
2167
2152
|
},
|
|
2168
2153
|
onClick: (ctx, x) => ctx.insertColsRight(x, colInsertCount(ctx, x))
|
|
2169
2154
|
},
|
|
@@ -2177,7 +2162,7 @@ const defaultColMenuDescriptors = [
|
|
|
2177
2162
|
const n = colInsertCount(ctx, x);
|
|
2178
2163
|
const sheet = ctx.sheet;
|
|
2179
2164
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2180
|
-
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols ||
|
|
2165
|
+
return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.RemoveCols);
|
|
2181
2166
|
},
|
|
2182
2167
|
onClick: (ctx, x) => ctx.removeCols(x, colInsertCount(ctx, x))
|
|
2183
2168
|
},
|
|
@@ -2245,7 +2230,7 @@ function buildMenuContext(store, dispatch, close) {
|
|
|
2245
2230
|
if (!sheet) {
|
|
2246
2231
|
return;
|
|
2247
2232
|
}
|
|
2248
|
-
const addr =
|
|
2233
|
+
const addr = p2a({ y: 0, x });
|
|
2249
2234
|
sheet.update({
|
|
2250
2235
|
diff: { [addr]: { label: label || void 0 } },
|
|
2251
2236
|
partial: true,
|
|
@@ -2493,7 +2478,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
|
|
|
2493
2478
|
return null;
|
|
2494
2479
|
}
|
|
2495
2480
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2496
|
-
const filterDisabled =
|
|
2481
|
+
const filterDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.Filter);
|
|
2497
2482
|
const hasAnyFilter = sheet.hasActiveFilters();
|
|
2498
2483
|
return /* @__PURE__ */ jsx("li", { className: `gs-column-menu-filter${filterDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2499
2484
|
/* @__PURE__ */ jsxs("div", { className: "gs-filter-header", children: [
|
|
@@ -2632,7 +2617,7 @@ const SortSection = ({ x, close, onWaiting }) => {
|
|
|
2632
2617
|
return null;
|
|
2633
2618
|
}
|
|
2634
2619
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2635
|
-
const sortDisabled =
|
|
2620
|
+
const sortDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.Sort);
|
|
2636
2621
|
return /* @__PURE__ */ jsxs("li", { className: `gs-menu-item gs-column-menu-sort${sortDisabled ? " gs-disabled" : ""}`, children: [
|
|
2637
2622
|
/* @__PURE__ */ jsx("div", { className: "gs-menu-name", children: "Sort:" }),
|
|
2638
2623
|
/* @__PURE__ */ jsxs("div", { className: "gs-sort-buttons", children: [
|
|
@@ -2684,7 +2669,7 @@ const LabelSection = ({ x, close }) => {
|
|
|
2684
2669
|
if (!sheet) {
|
|
2685
2670
|
return;
|
|
2686
2671
|
}
|
|
2687
|
-
const address =
|
|
2672
|
+
const address = p2a({ y: 0, x });
|
|
2688
2673
|
sheet.update({
|
|
2689
2674
|
diff: { [address]: { label: label || void 0 } },
|
|
2690
2675
|
partial: true,
|
|
@@ -2707,8 +2692,8 @@ const LabelSection = ({ x, close }) => {
|
|
|
2707
2692
|
return null;
|
|
2708
2693
|
}
|
|
2709
2694
|
const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
|
|
2710
|
-
const labelDisabled =
|
|
2711
|
-
const labelPlaceholder = getLabel(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x }, x) ??
|
|
2695
|
+
const labelDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.SetLabel);
|
|
2696
|
+
const labelPlaceholder = getLabel(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x }, x) ?? x2c(x);
|
|
2712
2697
|
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: [
|
|
2713
2698
|
/* @__PURE__ */ jsx("div", { className: "gs-label-input-label", children: "Label:" }),
|
|
2714
2699
|
/* @__PURE__ */ jsx(
|
|
@@ -2916,8 +2901,8 @@ const safePreventDefault = (e) => {
|
|
|
2916
2901
|
}
|
|
2917
2902
|
};
|
|
2918
2903
|
const Cell = memo(({ y, x }) => {
|
|
2919
|
-
const rowId =
|
|
2920
|
-
const colId =
|
|
2904
|
+
const rowId = y2r(y);
|
|
2905
|
+
const colId = x2c(x);
|
|
2921
2906
|
const address = `${colId}${rowId}`;
|
|
2922
2907
|
const { store, dispatch } = useContext(Context);
|
|
2923
2908
|
const isFirstPointed = useRef(true);
|
|
@@ -2937,7 +2922,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
2937
2922
|
const sheet = sheetReactive.current;
|
|
2938
2923
|
const xSheetFocused = isXSheetFocused(store);
|
|
2939
2924
|
const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
|
|
2940
|
-
const selectingArea =
|
|
2925
|
+
const selectingArea = zoneToArea(selectingZone);
|
|
2941
2926
|
const editing = editingAddress === address;
|
|
2942
2927
|
const pointed = choosing.y === y && choosing.x === x;
|
|
2943
2928
|
const _setEditorRect = useCallback(() => {
|
|
@@ -2982,7 +2967,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
2982
2967
|
rendered = sheet.render({ sheet, point: { y, x }, apply, value: void 0 });
|
|
2983
2968
|
}
|
|
2984
2969
|
} catch (e) {
|
|
2985
|
-
if (
|
|
2970
|
+
if (FormulaError.is(e)) {
|
|
2986
2971
|
errorMessage = e.message;
|
|
2987
2972
|
rendered = e.code;
|
|
2988
2973
|
} else {
|
|
@@ -2991,7 +2976,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
2991
2976
|
}
|
|
2992
2977
|
}
|
|
2993
2978
|
const [, v] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x })) ?? [void 0, void 0];
|
|
2994
|
-
const isPendingCell =
|
|
2979
|
+
const isPendingCell = Pending.is(v);
|
|
2995
2980
|
const input = editorRef.current;
|
|
2996
2981
|
const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
|
|
2997
2982
|
const handleDragStart = useCallback(
|
|
@@ -3093,8 +3078,8 @@ const Cell = memo(({ y, x }) => {
|
|
|
3093
3078
|
}
|
|
3094
3079
|
dispatch(drag({ y, x }));
|
|
3095
3080
|
if (editingAnywhere) {
|
|
3096
|
-
const newArea =
|
|
3097
|
-
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${
|
|
3081
|
+
const newArea = zoneToArea({ ...selectingZone, endY: y, endX: x });
|
|
3082
|
+
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${areaToRange(newArea)}`;
|
|
3098
3083
|
insertRef({ input: lastFocused || null, ref: fullRange });
|
|
3099
3084
|
}
|
|
3100
3085
|
return true;
|
|
@@ -3301,9 +3286,9 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3301
3286
|
dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
|
|
3302
3287
|
} else {
|
|
3303
3288
|
if (editingAnywhere) {
|
|
3304
|
-
const newArea =
|
|
3289
|
+
const newArea = zoneToArea({ ...selectingZone, endY: y, endX: x });
|
|
3305
3290
|
const sheetPrefix = sheet.sheetPrefix(!xSheetFocused);
|
|
3306
|
-
const sheetRange =
|
|
3291
|
+
const sheetRange = areaToRange(newArea);
|
|
3307
3292
|
const fullRange = `${sheetPrefix}${sheetRange}`;
|
|
3308
3293
|
insertRef({ input: editorRef.current, ref: fullRange });
|
|
3309
3294
|
}
|
|
@@ -3406,7 +3391,7 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
|
|
|
3406
3391
|
);
|
|
3407
3392
|
}
|
|
3408
3393
|
const HeaderCellTop = memo(({ x }) => {
|
|
3409
|
-
const colId =
|
|
3394
|
+
const colId = x2c(x);
|
|
3410
3395
|
const { store, dispatch } = useContext(Context);
|
|
3411
3396
|
const {
|
|
3412
3397
|
sheetReactive: sheetRef,
|
|
@@ -3527,8 +3512,8 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3527
3512
|
return false;
|
|
3528
3513
|
}
|
|
3529
3514
|
if (editingAnywhere) {
|
|
3530
|
-
const newArea =
|
|
3531
|
-
const [left, right] = [
|
|
3515
|
+
const newArea = zoneToArea({ ...selectingZone, endY: 1, endX: x });
|
|
3516
|
+
const [left, right] = [x2c(newArea.left), x2c(newArea.right)];
|
|
3532
3517
|
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${left}:${right}`;
|
|
3533
3518
|
insertRef({ input: lastFocused || null, ref: fullRange });
|
|
3534
3519
|
}
|
|
@@ -3592,7 +3577,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3592
3577
|
}
|
|
3593
3578
|
return displayedLabel;
|
|
3594
3579
|
})(),
|
|
3595
|
-
!
|
|
3580
|
+
!operations.hasOperation(col == null ? void 0 : col.prevention, operations.ColumnMenu) && /* @__PURE__ */ jsx(
|
|
3596
3581
|
"button",
|
|
3597
3582
|
{
|
|
3598
3583
|
className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x ? "gs-active" : ""}`,
|
|
@@ -3631,7 +3616,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3631
3616
|
{
|
|
3632
3617
|
className: `
|
|
3633
3618
|
gs-resizer
|
|
3634
|
-
${
|
|
3619
|
+
${operations.hasOperation(col == null ? void 0 : col.prevention, operations.Resize) ? "gs-protected" : ""}
|
|
3635
3620
|
${dragging ? "gs-hidden" : ""}`,
|
|
3636
3621
|
style: { height: sheet.headerHeight },
|
|
3637
3622
|
onMouseDown: handleResizeMouseDown,
|
|
@@ -3645,7 +3630,7 @@ const HeaderCellTop = memo(({ x }) => {
|
|
|
3645
3630
|
);
|
|
3646
3631
|
});
|
|
3647
3632
|
const HeaderCellLeft = memo(({ y }) => {
|
|
3648
|
-
const rowId = `${
|
|
3633
|
+
const rowId = `${y2r(y)}`;
|
|
3649
3634
|
const { store, dispatch } = useContext(Context);
|
|
3650
3635
|
const {
|
|
3651
3636
|
choosing,
|
|
@@ -3765,8 +3750,8 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3765
3750
|
return false;
|
|
3766
3751
|
}
|
|
3767
3752
|
if (editingAnywhere) {
|
|
3768
|
-
const newArea =
|
|
3769
|
-
const [top, bottom] = [
|
|
3753
|
+
const newArea = zoneToArea({ ...selectingZone, endY: y, endX: 1 });
|
|
3754
|
+
const [top, bottom] = [y2r(newArea.top), y2r(newArea.bottom)];
|
|
3770
3755
|
const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${top}:${bottom}`;
|
|
3771
3756
|
insertRef({ input: lastFocused || null, ref: fullRange });
|
|
3772
3757
|
}
|
|
@@ -3822,7 +3807,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3822
3807
|
}
|
|
3823
3808
|
),
|
|
3824
3809
|
getLabel(sheet, row == null ? void 0 : row.label, { y, x: 0 }, y) ?? rowId,
|
|
3825
|
-
!
|
|
3810
|
+
!operations.hasOperation(row == null ? void 0 : row.prevention, operations.RowMenu) && /* @__PURE__ */ jsx(
|
|
3826
3811
|
"button",
|
|
3827
3812
|
{
|
|
3828
3813
|
className: `gs-menu-btn gs-row-menu-btn ${(rowMenuState == null ? void 0 : rowMenuState.y) === y ? "gs-active" : ""}`,
|
|
@@ -3861,7 +3846,7 @@ const HeaderCellLeft = memo(({ y }) => {
|
|
|
3861
3846
|
{
|
|
3862
3847
|
className: `
|
|
3863
3848
|
gs-resizer
|
|
3864
|
-
${
|
|
3849
|
+
${operations.hasOperation(row == null ? void 0 : row.prevention, operations.Resize) ? "gs-protected" : ""}
|
|
3865
3850
|
${dragging ? "gs-hidden" : ""}`,
|
|
3866
3851
|
style: { width: sheet.headerWidth },
|
|
3867
3852
|
onMouseDown: handleResizeMouseDown
|
|
@@ -3962,7 +3947,7 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
3962
3947
|
ctx.beginPath();
|
|
3963
3948
|
ctx.rect(headerW, headerH, w - headerW, h2 - headerH);
|
|
3964
3949
|
ctx.clip();
|
|
3965
|
-
const selectingArea =
|
|
3950
|
+
const selectingArea = zoneToArea(selectingZone);
|
|
3966
3951
|
drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, selectingArea, COLOR_SELECTED, 1, [], SELECTING_FILL);
|
|
3967
3952
|
if (autofillDraggingTo) {
|
|
3968
3953
|
const autofill = new Autofill(storeRef.current, autofillDraggingTo);
|
|
@@ -3979,7 +3964,7 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
3979
3964
|
}
|
|
3980
3965
|
const { copyingSheetId, copyingZone, cutting } = registry;
|
|
3981
3966
|
if (sheet.id === copyingSheetId) {
|
|
3982
|
-
const copyingArea =
|
|
3967
|
+
const copyingArea = zoneToArea(copyingZone);
|
|
3983
3968
|
const color = cutting ? COLOR_CUTTING : COLOR_COPYING;
|
|
3984
3969
|
const dashPattern = cutting ? [4, 4] : [6, 4];
|
|
3985
3970
|
drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, copyingArea, color, 2.5, dashPattern);
|
|
@@ -3993,7 +3978,7 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
3993
3978
|
}
|
|
3994
3979
|
});
|
|
3995
3980
|
matchingCells.forEach((address, index) => {
|
|
3996
|
-
const { y, x } =
|
|
3981
|
+
const { y, x } = a2p(address);
|
|
3997
3982
|
const pos = getCellRectPositions(sheet, { y, x });
|
|
3998
3983
|
const vx = pos.left - scrollLeft;
|
|
3999
3984
|
const vy = pos.top - scrollTop;
|
|
@@ -4207,7 +4192,7 @@ const Tabular = () => {
|
|
|
4207
4192
|
}
|
|
4208
4193
|
const palette2 = {};
|
|
4209
4194
|
const paletteBySheetName = {};
|
|
4210
|
-
const lexer = new
|
|
4195
|
+
const lexer = new Lexer(inputting.substring(1));
|
|
4211
4196
|
lexer.tokenize();
|
|
4212
4197
|
let i = 0;
|
|
4213
4198
|
for (const token of lexer.tokens) {
|
|
@@ -4240,7 +4225,7 @@ const Tabular = () => {
|
|
|
4240
4225
|
if (!sheet) {
|
|
4241
4226
|
return;
|
|
4242
4227
|
}
|
|
4243
|
-
sheet.registry.choosingAddress =
|
|
4228
|
+
sheet.registry.choosingAddress = p2a(choosing);
|
|
4244
4229
|
sheet.registry.choosingSheetId = sheet.id;
|
|
4245
4230
|
}, [choosing]);
|
|
4246
4231
|
useEffect(() => {
|
|
@@ -4393,11 +4378,11 @@ const FormulaBar = ({ ready }) => {
|
|
|
4393
4378
|
} = store;
|
|
4394
4379
|
const sheet = sheetRef.current;
|
|
4395
4380
|
const hlRef = useRef(null);
|
|
4396
|
-
const address = choosing.x === -1 ? "" :
|
|
4381
|
+
const address = choosing.x === -1 ? "" : p2a(choosing);
|
|
4397
4382
|
const cell = sheet == null ? void 0 : sheet.getCell(choosing, { resolution: "SYSTEM" });
|
|
4398
4383
|
const spilledFromAddress = (_a = sheet == null ? void 0 : sheet.getSystem(choosing)) == null ? void 0 : _a.spilledFrom;
|
|
4399
|
-
const originPoint = spilledFromAddress ?
|
|
4400
|
-
const originAddress = originPoint != null ?
|
|
4384
|
+
const originPoint = spilledFromAddress ? a2p(spilledFromAddress) : void 0;
|
|
4385
|
+
const originAddress = originPoint != null ? p2a(originPoint) : void 0;
|
|
4401
4386
|
useEffect(() => {
|
|
4402
4387
|
var _a2;
|
|
4403
4388
|
if (!sheet) {
|
|
@@ -4448,6 +4433,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4448
4433
|
const largeInput = largeEditorRef.current;
|
|
4449
4434
|
const handleInput = useCallback((e) => {
|
|
4450
4435
|
dispatch(setInputting(e.currentTarget.value));
|
|
4436
|
+
setSelectionStart(e.currentTarget.selectionStart);
|
|
4451
4437
|
}, []);
|
|
4452
4438
|
const handleSelect = useCallback((e) => {
|
|
4453
4439
|
setSelectionStart(e.currentTarget.selectionStart);
|
|
@@ -4586,7 +4572,7 @@ const FormulaBar = ({ ready }) => {
|
|
|
4586
4572
|
break;
|
|
4587
4573
|
}
|
|
4588
4574
|
const cell2 = sheet.getCell(choosing, { resolution: "SYSTEM" });
|
|
4589
|
-
if (
|
|
4575
|
+
if (operations.hasOperation(cell2 == null ? void 0 : cell2.prevention, operations.Write)) {
|
|
4590
4576
|
console.warn("This cell is protected from writing.");
|
|
4591
4577
|
e.preventDefault();
|
|
4592
4578
|
}
|
|
@@ -4787,7 +4773,7 @@ const SearchBar = () => {
|
|
|
4787
4773
|
if (!matchingCell || !sheet) {
|
|
4788
4774
|
return;
|
|
4789
4775
|
}
|
|
4790
|
-
const point =
|
|
4776
|
+
const point = a2p(matchingCell);
|
|
4791
4777
|
if (typeof point === "undefined") {
|
|
4792
4778
|
return;
|
|
4793
4779
|
}
|
|
@@ -4846,8 +4832,8 @@ const SearchBar = () => {
|
|
|
4846
4832
|
return "";
|
|
4847
4833
|
}
|
|
4848
4834
|
const { startY, startX, endY, endX } = selectingZone;
|
|
4849
|
-
const topLeft = `${
|
|
4850
|
-
const bottomRight = `${
|
|
4835
|
+
const topLeft = `${x2c(Math.min(startX, endX))}${y2r(Math.min(startY, endY))}`;
|
|
4836
|
+
const bottomRight = `${x2c(Math.max(startX, endX))}${y2r(Math.max(startY, endY))}`;
|
|
4851
4837
|
return `${topLeft}:${bottomRight}`;
|
|
4852
4838
|
}, [selectingZone, hasSelection]);
|
|
4853
4839
|
const handleRangeClick = useCallback(() => {
|
|
@@ -4870,8 +4856,8 @@ const SearchBar = () => {
|
|
|
4870
4856
|
return "";
|
|
4871
4857
|
}
|
|
4872
4858
|
const { startY, startX, endY, endX } = searchRange;
|
|
4873
|
-
const topLeft = `${
|
|
4874
|
-
const bottomRight = `${
|
|
4859
|
+
const topLeft = `${x2c(startX)}${y2r(startY)}`;
|
|
4860
|
+
const bottomRight = `${x2c(endX)}${y2r(endY)}`;
|
|
4875
4861
|
return `${topLeft}:${bottomRight}`;
|
|
4876
4862
|
}, [searchRange]);
|
|
4877
4863
|
const handleCloseClick = useCallback(() => {
|
|
@@ -4994,7 +4980,7 @@ function GridSheet({
|
|
|
4994
4980
|
console.debug("GridSheet: sheetName is not provided, using default name:", sheetName);
|
|
4995
4981
|
}
|
|
4996
4982
|
const { limits, contextMenu, rowMenu, colMenu } = options;
|
|
4997
|
-
const sheet = new
|
|
4983
|
+
const sheet = new Sheet({
|
|
4998
4984
|
limits,
|
|
4999
4985
|
name: sheetName,
|
|
5000
4986
|
registry
|
|
@@ -5122,7 +5108,7 @@ const estimateSheetHeight = (initialCells) => {
|
|
|
5122
5108
|
const auto = getMaxSizesFromCells(initialCells);
|
|
5123
5109
|
let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? HEADER_HEIGHT;
|
|
5124
5110
|
for (let y = 1; y <= auto.numRows; y++) {
|
|
5125
|
-
const row =
|
|
5111
|
+
const row = y2r(y);
|
|
5126
5112
|
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[DEFAULT_ROW_KEY]) == null ? void 0 : _d.height) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.height) || DEFAULT_HEIGHT;
|
|
5127
5113
|
if (estimatedHeight + height > SHEET_HEIGHT) {
|
|
5128
5114
|
return SHEET_HEIGHT;
|
|
@@ -5136,7 +5122,7 @@ const estimateSheetWidth = (initialCells) => {
|
|
|
5136
5122
|
const auto = getMaxSizesFromCells(initialCells);
|
|
5137
5123
|
let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ?? HEADER_WIDTH;
|
|
5138
5124
|
for (let x = 1; x <= auto.numCols; x++) {
|
|
5139
|
-
const col =
|
|
5125
|
+
const col = x2c(x);
|
|
5140
5126
|
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[DEFAULT_COL_KEY]) == null ? void 0 : _d.width) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.width) || DEFAULT_WIDTH;
|
|
5141
5127
|
if (estimatedWidth + width > SHEET_WIDTH) {
|
|
5142
5128
|
return SHEET_WIDTH;
|
|
@@ -5186,21 +5172,21 @@ export {
|
|
|
5186
5172
|
Children,
|
|
5187
5173
|
Component,
|
|
5188
5174
|
DEFAULT_HISTORY_LIMIT,
|
|
5189
|
-
FormulaError,
|
|
5175
|
+
FormulaError2 as FormulaError,
|
|
5190
5176
|
FormulaParser,
|
|
5191
5177
|
Fragment2 as Fragment,
|
|
5192
5178
|
GridSheet,
|
|
5193
|
-
Lexer,
|
|
5179
|
+
Lexer2 as Lexer,
|
|
5194
5180
|
MenuDivider,
|
|
5195
5181
|
MenuItem,
|
|
5196
|
-
Pending,
|
|
5182
|
+
Pending2 as Pending,
|
|
5197
5183
|
PluginBase,
|
|
5198
5184
|
Policy,
|
|
5199
5185
|
PureComponent,
|
|
5200
5186
|
RangeEntity,
|
|
5201
5187
|
RefEntity,
|
|
5202
5188
|
Registry,
|
|
5203
|
-
Sheet,
|
|
5189
|
+
Sheet2 as Sheet,
|
|
5204
5190
|
Spilling,
|
|
5205
5191
|
StrictMode,
|
|
5206
5192
|
Suspense,
|
|
@@ -5208,14 +5194,14 @@ export {
|
|
|
5208
5194
|
ThousandSeparatorPolicyMixin,
|
|
5209
5195
|
Time,
|
|
5210
5196
|
ValueEntity,
|
|
5211
|
-
a2p,
|
|
5197
|
+
a2p2 as a2p,
|
|
5212
5198
|
aa2oa,
|
|
5213
5199
|
addressesToAreas,
|
|
5214
5200
|
addressesToCols,
|
|
5215
5201
|
addressesToRows,
|
|
5216
5202
|
applyers,
|
|
5217
|
-
areaToRange,
|
|
5218
|
-
areaToZone,
|
|
5203
|
+
areaToRange2 as areaToRange,
|
|
5204
|
+
areaToZone2 as areaToZone,
|
|
5219
5205
|
buildInitialCells,
|
|
5220
5206
|
buildInitialCellsFromOrigin,
|
|
5221
5207
|
c2x,
|
|
@@ -5253,8 +5239,8 @@ export {
|
|
|
5253
5239
|
matrixShape,
|
|
5254
5240
|
memo2 as memo,
|
|
5255
5241
|
oa2aa,
|
|
5256
|
-
operations,
|
|
5257
|
-
p2a,
|
|
5242
|
+
operations2 as operations,
|
|
5243
|
+
p2a2 as p2a,
|
|
5258
5244
|
r2y,
|
|
5259
5245
|
registerMenuComponent,
|
|
5260
5246
|
render,
|
|
@@ -5289,8 +5275,8 @@ export {
|
|
|
5289
5275
|
useStoreRef,
|
|
5290
5276
|
W as userActions,
|
|
5291
5277
|
version,
|
|
5292
|
-
x2c,
|
|
5293
|
-
y2r,
|
|
5294
|
-
zoneToArea
|
|
5278
|
+
x2c2 as x2c,
|
|
5279
|
+
y2r2 as y2r,
|
|
5280
|
+
zoneToArea2 as zoneToArea
|
|
5295
5281
|
};
|
|
5296
5282
|
//# sourceMappingURL=index.js.map
|