@dxos/plugin-sheet 0.6.12-main.ed7cda7 → 0.6.12-staging.0b4bb48
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/lib/browser/{chunk-U2JHW3L6.mjs → SheetContainer-U4H5D34A.mjs} +240 -1020
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-D6KU5MI7.mjs → browser/chunk-D5AGLXJP.mjs} +670 -360
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-T3NJFTD4.mjs → chunk-FUAGSXA4.mjs} +15 -8
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QILRZNE5.mjs → chunk-JRL5LGCE.mjs} +5 -2
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +56 -68
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{chunk-OTTD7FBK.cjs → SheetContainer-AXQV3ZT5.cjs} +279 -1050
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-DD6FIXWC.cjs → chunk-5KKJ4NPP.cjs} +667 -360
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/{chunk-BNARJ5GM.cjs → chunk-BJ6ZD7MN.cjs} +18 -5
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-Q3HBHPRL.cjs → chunk-DSYKOI4E.cjs} +20 -12
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +64 -83
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +12 -10
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +3 -23
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/{graph → components/ComputeGraph}/async-function.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
- package/dist/types/src/{graph/custom-function.d.ts → components/ComputeGraph/custom.d.ts} +1 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +6 -5
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
- package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +5 -6
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +3 -2
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +3 -19
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +13 -18
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +4 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/{graph/function-defs.d.ts → model/functions.d.ts} +1 -1
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.browser.test.d.ts +2 -0
- package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
- package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +64 -9
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/{defs → model}/types.d.ts +3 -8
- package/dist/types/src/model/types.d.ts.map +1 -0
- package/dist/types/src/model/types.test.d.ts.map +1 -0
- package/dist/types/src/model/util.d.ts +15 -0
- package/dist/types/src/model/util.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +3 -83
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +41 -48
- package/src/SheetPlugin.tsx +70 -43
- package/src/components/CellEditor/CellEditor.stories.tsx +3 -4
- package/src/components/CellEditor/CellEditor.tsx +9 -59
- package/src/components/CellEditor/extension.test.ts +5 -4
- package/src/components/CellEditor/extension.ts +3 -1
- package/src/{graph → components/ComputeGraph}/async-function.ts +1 -3
- package/src/{graph/custom-function.ts → components/ComputeGraph/custom.ts} +6 -2
- package/src/{graph → components/ComputeGraph}/edge-function.ts +1 -2
- package/src/components/ComputeGraph/graph-context.tsx +50 -0
- package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
- package/src/components/ComputeGraph/graph.ts +62 -0
- package/src/components/ComputeGraph/index.ts +3 -1
- package/src/components/Sheet/Sheet.stories.tsx +82 -45
- package/src/components/Sheet/Sheet.tsx +18 -57
- package/src/{model/formatting-model.ts → components/Sheet/formatting.ts} +13 -20
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +78 -16
- package/src/components/SheetContainer.tsx +19 -73
- package/src/components/Toolbar/Toolbar.tsx +12 -53
- package/src/components/index.ts +0 -1
- package/src/meta.tsx +5 -1
- package/src/model/index.ts +3 -2
- package/src/model/model.browser.test.ts +100 -0
- package/src/model/model.ts +550 -0
- package/src/{defs → model}/types.test.ts +9 -8
- package/src/{defs → model}/types.ts +14 -23
- package/src/model/util.ts +36 -0
- package/src/testing.ts +50 -0
- package/src/translations.ts +1 -6
- package/src/types.ts +5 -30
- package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs +0 -261
- package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs.map +0 -7
- package/dist/lib/browser/chunk-6ZMQVB4Z.mjs +0 -2923
- package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +0 -7
- package/dist/lib/browser/chunk-T3NJFTD4.mjs.map +0 -7
- package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +0 -7
- package/dist/lib/browser/graph-T27BOBOV.mjs +0 -21
- package/dist/lib/browser/graph-T27BOBOV.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs +0 -279
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs.map +0 -7
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +0 -7
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +0 -7
- package/dist/lib/node/chunk-OTTD7FBK.cjs.map +0 -7
- package/dist/lib/node/chunk-Q3HBHPRL.cjs.map +0 -7
- package/dist/lib/node/graph-SPKGX7W4.cjs +0 -43
- package/dist/lib/node/graph-SPKGX7W4.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs +0 -262
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs +0 -2553
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs +0 -76
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IU2L277A.mjs +0 -17
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +0 -7
- package/dist/lib/node-esm/graph-U67IO4UC.mjs +0 -22
- package/dist/lib/node-esm/graph-U67IO4UC.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -261
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -21
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -10
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts +0 -7
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/decorations.d.ts +0 -24
- package/dist/types/src/components/Sheet/decorations.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/threads.d.ts +0 -2
- package/dist/types/src/components/Sheet/threads.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts +0 -3
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts +0 -43
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.d.ts +0 -5
- package/dist/types/src/extensions/compute.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.stories.d.ts +0 -26
- package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -2
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/graph/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.browser.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts +0 -81
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts +0 -19
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/custom-function.d.ts.map +0 -1
- package/dist/types/src/graph/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts +0 -4
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts +0 -2
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useFormattingModel.d.ts +0 -3
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/formatting-model.d.ts +0 -16
- package/dist/types/src/model/formatting-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -9
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -35
- package/src/components/GridSheet/GridSheet.tsx +0 -153
- package/src/components/GridSheet/util.ts +0 -108
- package/src/components/Sheet/decorations.ts +0 -62
- package/src/components/Sheet/threads.tsx +0 -205
- package/src/defs/index.ts +0 -6
- package/src/defs/util.ts +0 -135
- package/src/extensions/compute.stories.tsx +0 -151
- package/src/extensions/compute.ts +0 -98
- package/src/extensions/index.ts +0 -5
- package/src/graph/compute-graph.browser.test.ts +0 -104
- package/src/graph/compute-graph.stories.tsx +0 -92
- package/src/graph/compute-graph.ts +0 -290
- package/src/graph/compute-node.ts +0 -51
- package/src/graph/hyperformula.test.ts +0 -15
- package/src/graph/index.ts +0 -7
- package/src/graph/util.ts +0 -8
- package/src/hooks/hooks.stories.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/useComputeGraph.ts +0 -20
- package/src/hooks/useFormattingModel.ts +0 -11
- package/src/hooks/useSheetModel.ts +0 -43
- package/src/model/sheet-model.ts +0 -399
- package/src/sanity.test.ts +0 -40
- package/src/testing/index.ts +0 -5
- package/src/testing/testing.tsx +0 -66
- /package/dist/types/src/{graph → components/ComputeGraph}/edge-function.d.ts +0 -0
- /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
- /package/src/{graph/function-defs.ts → model/functions.ts} +0 -0
|
@@ -26,63 +26,38 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
32
|
-
Sheet: () => Sheet,
|
|
33
|
-
SheetContainer: () => SheetContainer,
|
|
34
|
-
addressToIndex: () => addressToIndex,
|
|
35
|
-
compareIndexPositions: () => compareIndexPositions,
|
|
36
|
-
createSheet: () => createSheet,
|
|
37
|
-
useSheetContext: () => useSheetContext
|
|
29
|
+
var SheetContainer_AXQV3ZT5_exports = {};
|
|
30
|
+
__export(SheetContainer_AXQV3ZT5_exports, {
|
|
31
|
+
default: () => SheetContainer_default
|
|
38
32
|
});
|
|
39
|
-
module.exports = __toCommonJS(
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
33
|
+
module.exports = __toCommonJS(SheetContainer_AXQV3ZT5_exports);
|
|
34
|
+
var import_chunk_CN3RPESU = require("./chunk-CN3RPESU.cjs");
|
|
35
|
+
var import_chunk_5KKJ4NPP = require("./chunk-5KKJ4NPP.cjs");
|
|
36
|
+
var import_chunk_DSYKOI4E = require("./chunk-DSYKOI4E.cjs");
|
|
37
|
+
var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
43
40
|
var import_core = require("@dnd-kit/core");
|
|
44
41
|
var import_modifiers = require("@dnd-kit/modifiers");
|
|
45
42
|
var import_utilities = require("@dnd-kit/utilities");
|
|
46
|
-
var
|
|
43
|
+
var import_react2 = require("@phosphor-icons/react");
|
|
47
44
|
var import_re_resizable = require("re-resizable");
|
|
48
|
-
var
|
|
45
|
+
var import_react3 = __toESM(require("react"));
|
|
49
46
|
var import_react_dom = require("react-dom");
|
|
50
47
|
var import_react_resize_detector = require("react-resize-detector");
|
|
51
48
|
var import_async = require("@dxos/async");
|
|
52
49
|
var import_echo = require("@dxos/client/echo");
|
|
53
50
|
var import_log = require("@dxos/log");
|
|
54
51
|
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
55
|
-
var
|
|
56
|
-
var import_react3 = require("react");
|
|
57
|
-
var import_invariant = require("@dxos/invariant");
|
|
58
|
-
var import_crypto = require("@dxos/crypto");
|
|
59
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
52
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
60
53
|
var import_react4 = require("react");
|
|
61
|
-
var import_react5 =
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var import_react6 = require("react");
|
|
65
|
-
var import_debug = require("@dxos/debug");
|
|
66
|
-
var import_react_hooks = require("@dxos/react-hooks");
|
|
67
|
-
var import_react7 = __toESM(require("react"));
|
|
68
|
-
var import_react8 = __toESM(require("react"));
|
|
69
|
-
var import_react9 = require("react");
|
|
70
|
-
var import_async2 = require("@dxos/async");
|
|
71
|
-
var import_context = require("@dxos/context");
|
|
72
|
-
var import_invariant3 = require("@dxos/invariant");
|
|
73
|
-
var import_keys = require("@dxos/keys");
|
|
74
|
-
var import_log2 = require("@dxos/log");
|
|
75
|
-
var import_hyperformula = require("#hyperformula");
|
|
76
|
-
var import_react10 = require("react");
|
|
77
|
-
var import_signals_core = require("@preact/signals-core");
|
|
78
|
-
var import_react11 = __toESM(require("react"));
|
|
79
|
-
var import_app_framework = require("@dxos/app-framework");
|
|
80
|
-
var import_async3 = require("@dxos/async");
|
|
54
|
+
var import_react5 = require("react");
|
|
55
|
+
var import_react6 = __toESM(require("react"));
|
|
56
|
+
var import_invariant = require("@dxos/invariant");
|
|
81
57
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
82
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
83
58
|
var import_view = require("@codemirror/view");
|
|
84
|
-
var
|
|
85
|
-
var
|
|
59
|
+
var import_react7 = __toESM(require("react"));
|
|
60
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
86
61
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
87
62
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
88
63
|
var import_language = require("@codemirror/language");
|
|
@@ -90,156 +65,7 @@ var import_state = require("@codemirror/state");
|
|
|
90
65
|
var import_view2 = require("@codemirror/view");
|
|
91
66
|
var import_highlight = require("@lezer/highlight");
|
|
92
67
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
93
|
-
var
|
|
94
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
|
|
95
|
-
var DEFAULT_ROWS = 50;
|
|
96
|
-
var DEFAULT_COLUMNS = 26;
|
|
97
|
-
var MAX_ROWS = 500;
|
|
98
|
-
var MAX_COLUMNS = 26 * 2;
|
|
99
|
-
var posEquals = (a, b) => {
|
|
100
|
-
return a?.col === b?.col && a?.row === b?.row;
|
|
101
|
-
};
|
|
102
|
-
var columnLetter = (col) => {
|
|
103
|
-
(0, import_invariant.invariant)(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
104
|
-
F: __dxlog_file,
|
|
105
|
-
L: 26,
|
|
106
|
-
S: void 0,
|
|
107
|
-
A: [
|
|
108
|
-
"col < MAX_COLUMNS",
|
|
109
|
-
"`Invalid column: ${col}`"
|
|
110
|
-
]
|
|
111
|
-
});
|
|
112
|
-
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
113
|
-
};
|
|
114
|
-
var addressToA1Notation = ({ col, row }) => {
|
|
115
|
-
return `${columnLetter(col)}${row + 1}`;
|
|
116
|
-
};
|
|
117
|
-
var addressFromA1Notation = (ref) => {
|
|
118
|
-
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
119
|
-
(0, import_invariant.invariant)(match, `Invalid notation: ${ref}`, {
|
|
120
|
-
F: __dxlog_file,
|
|
121
|
-
L: 39,
|
|
122
|
-
S: void 0,
|
|
123
|
-
A: [
|
|
124
|
-
"match",
|
|
125
|
-
"`Invalid notation: ${ref}`"
|
|
126
|
-
]
|
|
127
|
-
});
|
|
128
|
-
return {
|
|
129
|
-
row: parseInt(match[2], 10) - 1,
|
|
130
|
-
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
var rangeToA1Notation = (range) => {
|
|
134
|
-
return [
|
|
135
|
-
range?.from && addressToA1Notation(range?.from),
|
|
136
|
-
range?.to && addressToA1Notation(range?.to)
|
|
137
|
-
].filter(Boolean).join(":");
|
|
138
|
-
};
|
|
139
|
-
var inRange = (range, cell) => {
|
|
140
|
-
if (!range) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
const { from, to } = range;
|
|
144
|
-
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
if (!from || !to) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
const { col: c1, row: r1 } = from;
|
|
151
|
-
const { col: c2, row: r2 } = to;
|
|
152
|
-
const cMin = Math.min(c1, c2);
|
|
153
|
-
const cMax = Math.max(c1, c2);
|
|
154
|
-
const rMin = Math.min(r1, r2);
|
|
155
|
-
const rMax = Math.max(r1, r2);
|
|
156
|
-
const { col, row } = cell;
|
|
157
|
-
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
158
|
-
};
|
|
159
|
-
var ApiError = class extends Error {
|
|
160
|
-
};
|
|
161
|
-
var ReadonlyException = class extends ApiError {
|
|
162
|
-
};
|
|
163
|
-
var RangeException = class extends ApiError {
|
|
164
|
-
constructor(n) {
|
|
165
|
-
super();
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
var createIndex = (length = 8) => {
|
|
169
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
170
|
-
const charactersLength = characters.length;
|
|
171
|
-
const randomBuffer = (0, import_crypto.randomBytes)(length);
|
|
172
|
-
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
173
|
-
};
|
|
174
|
-
var createIndices = (length) => Array.from({
|
|
175
|
-
length
|
|
176
|
-
}).map(() => createIndex());
|
|
177
|
-
var insertIndices = (indices, i, n, max) => {
|
|
178
|
-
if (i + n > max) {
|
|
179
|
-
throw new RangeException(i + n);
|
|
180
|
-
}
|
|
181
|
-
const idx = createIndices(n);
|
|
182
|
-
indices.splice(i, 0, ...idx);
|
|
183
|
-
};
|
|
184
|
-
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
185
|
-
if (!sheet.rows.length) {
|
|
186
|
-
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
187
|
-
}
|
|
188
|
-
if (!sheet.columns.length) {
|
|
189
|
-
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
var createSheet = ({ title, ...size } = {}) => {
|
|
193
|
-
const sheet = (0, import_echo_schema.create)(import_chunk_Q3HBHPRL.SheetType, {
|
|
194
|
-
title,
|
|
195
|
-
cells: {},
|
|
196
|
-
rows: [],
|
|
197
|
-
columns: [],
|
|
198
|
-
rowMeta: {},
|
|
199
|
-
columnMeta: {},
|
|
200
|
-
formatting: {}
|
|
201
|
-
});
|
|
202
|
-
initialize(sheet, size);
|
|
203
|
-
return sheet;
|
|
204
|
-
};
|
|
205
|
-
var addressToIndex = (sheet, cell) => {
|
|
206
|
-
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
207
|
-
};
|
|
208
|
-
var addressFromIndex = (sheet, idx) => {
|
|
209
|
-
const [column, row] = idx.split("@");
|
|
210
|
-
return {
|
|
211
|
-
col: sheet.columns.indexOf(column),
|
|
212
|
-
row: sheet.rows.indexOf(row)
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
var rangeFromIndex = (sheet, idx) => {
|
|
216
|
-
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
217
|
-
return {
|
|
218
|
-
from,
|
|
219
|
-
to
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
var closest = (cursor, cells) => {
|
|
223
|
-
let closestCell;
|
|
224
|
-
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
225
|
-
for (const cell of cells) {
|
|
226
|
-
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
227
|
-
if (distance < closestDistance) {
|
|
228
|
-
closestCell = cell;
|
|
229
|
-
closestDistance = distance;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return closestCell;
|
|
233
|
-
};
|
|
234
|
-
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
235
|
-
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
236
|
-
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
237
|
-
if (rowA !== rowB) {
|
|
238
|
-
return rowA - rowB;
|
|
239
|
-
} else {
|
|
240
|
-
return columnA - columnB;
|
|
241
|
-
}
|
|
242
|
-
};
|
|
68
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
243
69
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
244
70
|
var axisHeight = 34;
|
|
245
71
|
var minWidth = 40;
|
|
@@ -250,8 +76,8 @@ var defaultWidth = 200;
|
|
|
250
76
|
var defaultHeight = minHeight;
|
|
251
77
|
var CELL_DATA_KEY = "cell";
|
|
252
78
|
var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) => {
|
|
253
|
-
const [rowPositions, setRowPositions] = (0,
|
|
254
|
-
(0,
|
|
79
|
+
const [rowPositions, setRowPositions] = (0, import_react4.useState)([]);
|
|
80
|
+
(0, import_react4.useEffect)(() => {
|
|
255
81
|
if (!rowSizes) {
|
|
256
82
|
return;
|
|
257
83
|
}
|
|
@@ -270,8 +96,8 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
270
96
|
rows,
|
|
271
97
|
rowSizes
|
|
272
98
|
]);
|
|
273
|
-
const [columnPositions, setColumnPositions] = (0,
|
|
274
|
-
(0,
|
|
99
|
+
const [columnPositions, setColumnPositions] = (0, import_react4.useState)([]);
|
|
100
|
+
(0, import_react4.useEffect)(() => {
|
|
275
101
|
if (!columns) {
|
|
276
102
|
return;
|
|
277
103
|
}
|
|
@@ -281,7 +107,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
281
107
|
const left = x;
|
|
282
108
|
x += width2 - 1;
|
|
283
109
|
return {
|
|
284
|
-
|
|
110
|
+
column: i,
|
|
285
111
|
left,
|
|
286
112
|
width: width2
|
|
287
113
|
};
|
|
@@ -292,11 +118,11 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
292
118
|
]);
|
|
293
119
|
const height = rowPositions.length ? rowPositions[rowPositions.length - 1].top + rowPositions[rowPositions.length - 1].height : 0;
|
|
294
120
|
const width = columnPositions.length ? columnPositions[columnPositions.length - 1].left + columnPositions[columnPositions.length - 1].width : 0;
|
|
295
|
-
const [{ rowRange, columnRange }, setWindow] = (0,
|
|
121
|
+
const [{ rowRange, columnRange }, setWindow] = (0, import_react4.useState)({
|
|
296
122
|
rowRange: [],
|
|
297
123
|
columnRange: []
|
|
298
124
|
});
|
|
299
|
-
(0,
|
|
125
|
+
(0, import_react4.useEffect)(() => {
|
|
300
126
|
const handleScroll = () => {
|
|
301
127
|
if (!scroller) {
|
|
302
128
|
return;
|
|
@@ -356,12 +182,12 @@ var getCellAtPointer = (event) => {
|
|
|
356
182
|
if (root) {
|
|
357
183
|
const value = root.dataset[CELL_DATA_KEY];
|
|
358
184
|
if (value) {
|
|
359
|
-
return addressFromA1Notation(value);
|
|
185
|
+
return (0, import_chunk_5KKJ4NPP.addressFromA1Notation)(value);
|
|
360
186
|
}
|
|
361
187
|
}
|
|
362
188
|
};
|
|
363
189
|
var getCellElement = (root, cell) => {
|
|
364
|
-
const pos = addressToA1Notation(cell);
|
|
190
|
+
const pos = (0, import_chunk_5KKJ4NPP.addressToA1Notation)(cell);
|
|
365
191
|
return root.querySelector(`[data-${CELL_DATA_KEY}="${pos}"]`);
|
|
366
192
|
};
|
|
367
193
|
var handleNav = (ev, cursor, range, size) => {
|
|
@@ -383,14 +209,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
383
209
|
break;
|
|
384
210
|
}
|
|
385
211
|
case "ArrowLeft": {
|
|
386
|
-
if (opposite.
|
|
387
|
-
opposite.
|
|
212
|
+
if (opposite.column > 0) {
|
|
213
|
+
opposite.column -= 1;
|
|
388
214
|
}
|
|
389
215
|
break;
|
|
390
216
|
}
|
|
391
217
|
case "ArrowRight": {
|
|
392
|
-
if (opposite.
|
|
393
|
-
opposite.
|
|
218
|
+
if (opposite.column < size.numColumns - 1) {
|
|
219
|
+
opposite.column += 1;
|
|
394
220
|
}
|
|
395
221
|
break;
|
|
396
222
|
}
|
|
@@ -408,18 +234,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
408
234
|
cursor: next
|
|
409
235
|
};
|
|
410
236
|
};
|
|
411
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
237
|
+
var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
412
238
|
switch (ev.key) {
|
|
413
239
|
case "ArrowUp":
|
|
414
240
|
if (cursor === void 0) {
|
|
415
241
|
return {
|
|
416
242
|
row: 0,
|
|
417
|
-
|
|
243
|
+
column: 0
|
|
418
244
|
};
|
|
419
245
|
} else if (cursor.row > 0) {
|
|
420
246
|
return {
|
|
421
247
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
422
|
-
|
|
248
|
+
column: cursor.column
|
|
423
249
|
};
|
|
424
250
|
}
|
|
425
251
|
break;
|
|
@@ -427,12 +253,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
427
253
|
if (cursor === void 0) {
|
|
428
254
|
return {
|
|
429
255
|
row: 0,
|
|
430
|
-
|
|
256
|
+
column: 0
|
|
431
257
|
};
|
|
432
258
|
} else if (cursor.row < numRows - 1) {
|
|
433
259
|
return {
|
|
434
260
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
435
|
-
|
|
261
|
+
column: cursor.column
|
|
436
262
|
};
|
|
437
263
|
}
|
|
438
264
|
break;
|
|
@@ -440,12 +266,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
440
266
|
if (cursor === void 0) {
|
|
441
267
|
return {
|
|
442
268
|
row: 0,
|
|
443
|
-
|
|
269
|
+
column: 0
|
|
444
270
|
};
|
|
445
|
-
} else if (cursor.
|
|
271
|
+
} else if (cursor.column > 0) {
|
|
446
272
|
return {
|
|
447
273
|
row: cursor.row,
|
|
448
|
-
|
|
274
|
+
column: ev.metaKey ? 0 : cursor.column - 1
|
|
449
275
|
};
|
|
450
276
|
}
|
|
451
277
|
break;
|
|
@@ -453,30 +279,30 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
453
279
|
if (cursor === void 0) {
|
|
454
280
|
return {
|
|
455
281
|
row: 0,
|
|
456
|
-
|
|
282
|
+
column: 0
|
|
457
283
|
};
|
|
458
|
-
} else if (cursor.
|
|
284
|
+
} else if (cursor.column < numColumns - 1) {
|
|
459
285
|
return {
|
|
460
286
|
row: cursor.row,
|
|
461
|
-
|
|
287
|
+
column: ev.metaKey ? numColumns - 1 : cursor.column + 1
|
|
462
288
|
};
|
|
463
289
|
}
|
|
464
290
|
break;
|
|
465
291
|
case "Home":
|
|
466
292
|
return {
|
|
467
293
|
row: 0,
|
|
468
|
-
|
|
294
|
+
column: 0
|
|
469
295
|
};
|
|
470
296
|
case "End":
|
|
471
297
|
return {
|
|
472
298
|
row: numRows - 1,
|
|
473
|
-
|
|
299
|
+
column: numColumns - 1
|
|
474
300
|
};
|
|
475
301
|
}
|
|
476
302
|
};
|
|
477
303
|
var useRangeSelect = (cb) => {
|
|
478
|
-
const [from, setFrom] = (0,
|
|
479
|
-
const [to, setTo] = (0,
|
|
304
|
+
const [from, setFrom] = (0, import_react5.useState)();
|
|
305
|
+
const [to, setTo] = (0, import_react5.useState)();
|
|
480
306
|
const onMouseDown = (ev) => {
|
|
481
307
|
const current = getCellAtPointer(ev);
|
|
482
308
|
setFrom(current);
|
|
@@ -489,7 +315,7 @@ var useRangeSelect = (cb) => {
|
|
|
489
315
|
const onMouseMove = (ev) => {
|
|
490
316
|
if (from) {
|
|
491
317
|
let current = getCellAtPointer(ev);
|
|
492
|
-
if (posEquals(current, from)) {
|
|
318
|
+
if ((0, import_chunk_5KKJ4NPP.posEquals)(current, from)) {
|
|
493
319
|
current = void 0;
|
|
494
320
|
}
|
|
495
321
|
setTo(current);
|
|
@@ -502,7 +328,7 @@ var useRangeSelect = (cb) => {
|
|
|
502
328
|
const onMouseUp = (ev) => {
|
|
503
329
|
if (from) {
|
|
504
330
|
let current = getCellAtPointer(ev);
|
|
505
|
-
if (posEquals(current, from)) {
|
|
331
|
+
if ((0, import_chunk_5KKJ4NPP.posEquals)(current, from)) {
|
|
506
332
|
current = void 0;
|
|
507
333
|
}
|
|
508
334
|
setFrom(void 0);
|
|
@@ -525,79 +351,27 @@ var useRangeSelect = (cb) => {
|
|
|
525
351
|
}
|
|
526
352
|
};
|
|
527
353
|
};
|
|
528
|
-
var createDecorations = () => {
|
|
529
|
-
const { decorations } = (0, import_echo_schema2.create)({
|
|
530
|
-
decorations: {}
|
|
531
|
-
});
|
|
532
|
-
const addDecoration = (cellIndex, decorator) => {
|
|
533
|
-
decorations[cellIndex] = [
|
|
534
|
-
...decorations[cellIndex] || [],
|
|
535
|
-
decorator
|
|
536
|
-
];
|
|
537
|
-
};
|
|
538
|
-
const removeDecoration = (cellIndex, type) => {
|
|
539
|
-
if (type) {
|
|
540
|
-
decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
|
|
541
|
-
} else {
|
|
542
|
-
delete decorations[cellIndex];
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
const getDecorationsForCell = (cellIndex) => {
|
|
546
|
-
return decorations[cellIndex];
|
|
547
|
-
};
|
|
548
|
-
const getAllDecorations = () => {
|
|
549
|
-
const result = [];
|
|
550
|
-
for (const decoratorArray of Object.values(decorations)) {
|
|
551
|
-
for (const decorator of decoratorArray) {
|
|
552
|
-
result.push(decorator);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
return result;
|
|
556
|
-
};
|
|
557
|
-
return {
|
|
558
|
-
addDecoration,
|
|
559
|
-
removeDecoration,
|
|
560
|
-
getDecorationsForCell,
|
|
561
|
-
getAllDecorations
|
|
562
|
-
};
|
|
563
|
-
};
|
|
564
|
-
var ComputeGraphContext = /* @__PURE__ */ (0, import_react8.createContext)(void 0);
|
|
565
|
-
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
566
|
-
return /* @__PURE__ */ import_react8.default.createElement(ComputeGraphContext.Provider, {
|
|
567
|
-
value: {
|
|
568
|
-
registry
|
|
569
|
-
}
|
|
570
|
-
}, children);
|
|
571
|
-
};
|
|
572
|
-
var SheetContainer = import_react7.default.lazy(() => import("./SheetContainer-3ZY7MPWJ.cjs"));
|
|
573
|
-
var useComputeGraph = (space) => {
|
|
574
|
-
const { registry } = (0, import_react6.useContext)(ComputeGraphContext) ?? (0, import_debug.raise)(new Error("Missing ComputeGraphContext"));
|
|
575
|
-
return (0, import_react_hooks.useAsyncState)(async () => space && registry.getOrCreateGraph(space), [
|
|
576
|
-
space,
|
|
577
|
-
registry
|
|
578
|
-
]);
|
|
579
|
-
};
|
|
580
354
|
var FormattingModel = class {
|
|
581
|
-
constructor(
|
|
582
|
-
this.
|
|
355
|
+
constructor(model) {
|
|
356
|
+
this.model = model;
|
|
583
357
|
}
|
|
584
358
|
/**
|
|
585
359
|
* Get formatted string value and className for cell.
|
|
586
360
|
*/
|
|
587
361
|
getFormatting(cell) {
|
|
588
|
-
const value = this.
|
|
362
|
+
const value = this.model.getValue(cell);
|
|
589
363
|
if (value === void 0 || value === null) {
|
|
590
364
|
return {};
|
|
591
365
|
}
|
|
592
366
|
const locales = void 0;
|
|
593
|
-
const idx =
|
|
594
|
-
let formatting = this.
|
|
367
|
+
const idx = this.model.addressToIndex(cell);
|
|
368
|
+
let formatting = this.model.sheet.formatting?.[idx] ?? {};
|
|
595
369
|
const classNames = [
|
|
596
370
|
...formatting?.classNames ?? []
|
|
597
371
|
];
|
|
598
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
599
|
-
const range =
|
|
600
|
-
if (inRange(range, cell)) {
|
|
372
|
+
for (const [idx2, _formatting] of Object.entries(this.model.sheet.formatting)) {
|
|
373
|
+
const range = this.model.rangeFromIndex(idx2);
|
|
374
|
+
if ((0, import_chunk_5KKJ4NPP.inRange)(range, cell)) {
|
|
601
375
|
if (_formatting.classNames) {
|
|
602
376
|
classNames.push(..._formatting.classNames);
|
|
603
377
|
}
|
|
@@ -607,9 +381,9 @@ var FormattingModel = class {
|
|
|
607
381
|
}
|
|
608
382
|
}
|
|
609
383
|
const defaultNumber = "justify-end font-mono";
|
|
610
|
-
const type = formatting?.type ?? this.
|
|
384
|
+
const type = formatting?.type ?? this.model.getValueType(cell);
|
|
611
385
|
switch (type) {
|
|
612
|
-
case
|
|
386
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Boolean: {
|
|
613
387
|
return {
|
|
614
388
|
value: value.toLocaleString().toUpperCase(),
|
|
615
389
|
classNames: [
|
|
@@ -621,7 +395,7 @@ var FormattingModel = class {
|
|
|
621
395
|
//
|
|
622
396
|
// Numbers.
|
|
623
397
|
//
|
|
624
|
-
case
|
|
398
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Number: {
|
|
625
399
|
return {
|
|
626
400
|
value: value.toLocaleString(locales),
|
|
627
401
|
classNames: [
|
|
@@ -630,7 +404,7 @@ var FormattingModel = class {
|
|
|
630
404
|
]
|
|
631
405
|
};
|
|
632
406
|
}
|
|
633
|
-
case
|
|
407
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Percent: {
|
|
634
408
|
return {
|
|
635
409
|
value: value * 100 + "%",
|
|
636
410
|
classNames: [
|
|
@@ -639,7 +413,7 @@ var FormattingModel = class {
|
|
|
639
413
|
]
|
|
640
414
|
};
|
|
641
415
|
}
|
|
642
|
-
case
|
|
416
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Currency: {
|
|
643
417
|
return {
|
|
644
418
|
value: value.toLocaleString(locales, {
|
|
645
419
|
style: "currency",
|
|
@@ -656,22 +430,22 @@ var FormattingModel = class {
|
|
|
656
430
|
//
|
|
657
431
|
// Dates.
|
|
658
432
|
//
|
|
659
|
-
case
|
|
660
|
-
const date = this.
|
|
433
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.DateTime: {
|
|
434
|
+
const date = this.model.toLocalDate(value);
|
|
661
435
|
return {
|
|
662
436
|
value: date.toLocaleString(locales),
|
|
663
437
|
classNames
|
|
664
438
|
};
|
|
665
439
|
}
|
|
666
|
-
case
|
|
667
|
-
const date = this.
|
|
440
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Date: {
|
|
441
|
+
const date = this.model.toLocalDate(value);
|
|
668
442
|
return {
|
|
669
443
|
value: date.toLocaleDateString(locales),
|
|
670
444
|
classNames
|
|
671
445
|
};
|
|
672
446
|
}
|
|
673
|
-
case
|
|
674
|
-
const date = this.
|
|
447
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Time: {
|
|
448
|
+
const date = this.model.toLocalDate(value);
|
|
675
449
|
return {
|
|
676
450
|
value: date.toLocaleTimeString(locales),
|
|
677
451
|
classNames
|
|
@@ -686,414 +460,83 @@ var FormattingModel = class {
|
|
|
686
460
|
}
|
|
687
461
|
}
|
|
688
462
|
};
|
|
689
|
-
var
|
|
690
|
-
var
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
};
|
|
463
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
464
|
+
var OBJECT_ID_LENGTH = 60;
|
|
465
|
+
var SheetContext = /* @__PURE__ */ (0, import_react6.createContext)(null);
|
|
466
|
+
var useSheetContext = () => {
|
|
467
|
+
const context = (0, import_react6.useContext)(SheetContext);
|
|
468
|
+
(0, import_invariant.invariant)(context, void 0, {
|
|
469
|
+
F: __dxlog_file,
|
|
470
|
+
L: 45,
|
|
471
|
+
S: void 0,
|
|
472
|
+
A: [
|
|
473
|
+
"context",
|
|
474
|
+
""
|
|
475
|
+
]
|
|
476
|
+
});
|
|
477
|
+
return context;
|
|
705
478
|
};
|
|
706
|
-
var
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
});
|
|
711
|
-
var toModelRange = (sheet, range) => ({
|
|
712
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
713
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
714
|
-
});
|
|
715
|
-
var SheetModel = class extends import_context.Resource {
|
|
716
|
-
constructor(_graph, _sheet, _options = {}) {
|
|
717
|
-
super();
|
|
718
|
-
this._graph = _graph;
|
|
719
|
-
this._sheet = _sheet;
|
|
720
|
-
this._options = _options;
|
|
721
|
-
this.id = `model-${import_keys.PublicKey.random().truncate()}`;
|
|
722
|
-
this.update = new import_async2.Event();
|
|
723
|
-
this._node = this._graph.getOrCreateNode((0, import_chunk_DD6FIXWC.createSheetName)(this._sheet.id));
|
|
724
|
-
this.reset();
|
|
725
|
-
}
|
|
726
|
-
get graph() {
|
|
727
|
-
return this._graph;
|
|
728
|
-
}
|
|
729
|
-
get sheet() {
|
|
730
|
-
return this._sheet;
|
|
731
|
-
}
|
|
732
|
-
get readonly() {
|
|
733
|
-
return this._options.readonly;
|
|
734
|
-
}
|
|
735
|
-
get bounds() {
|
|
736
|
-
return {
|
|
737
|
-
rows: this._sheet.rows.length,
|
|
738
|
-
columns: this._sheet.columns.length
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Initialize sheet and engine.
|
|
743
|
-
*/
|
|
744
|
-
async _open() {
|
|
745
|
-
(0, import_log2.log)("initialize", {
|
|
746
|
-
id: this.id
|
|
747
|
-
}, {
|
|
748
|
-
F: __dxlog_file2,
|
|
749
|
-
L: 105,
|
|
750
|
-
S: this,
|
|
751
|
-
C: (f, a) => f(...a)
|
|
752
|
-
});
|
|
753
|
-
initialize(this._sheet);
|
|
754
|
-
this.reset();
|
|
755
|
-
const unsubscribe = this._graph.update.on(() => this.update.emit());
|
|
756
|
-
this._ctx.onDispose(unsubscribe);
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Update engine.
|
|
760
|
-
* NOTE: This resets the undo history.
|
|
761
|
-
* @deprecated
|
|
762
|
-
*/
|
|
763
|
-
reset() {
|
|
764
|
-
this._node.hf.clearSheet(this._node.sheetId);
|
|
765
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
766
|
-
const { col, row } = addressFromIndex(this._sheet, key);
|
|
767
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
768
|
-
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
769
|
-
}
|
|
770
|
-
this._node.hf.setCellContents({
|
|
771
|
-
sheet: this._node.sheetId,
|
|
772
|
-
row,
|
|
773
|
-
col
|
|
774
|
-
}, value);
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* Recalculate formulas.
|
|
779
|
-
* NOTE: This resets the undo history.
|
|
780
|
-
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
781
|
-
* @deprecated
|
|
782
|
-
*/
|
|
783
|
-
// TODO(burdon): Remove.
|
|
784
|
-
recalculate() {
|
|
785
|
-
this._node.hf.rebuildAndRecalculate();
|
|
786
|
-
}
|
|
787
|
-
insertRows(i, n = 1) {
|
|
788
|
-
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
789
|
-
this.reset();
|
|
790
|
-
}
|
|
791
|
-
insertColumns(i, n = 1) {
|
|
792
|
-
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
793
|
-
this.reset();
|
|
794
|
-
}
|
|
795
|
-
//
|
|
796
|
-
// Undoable actions.
|
|
797
|
-
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
798
|
-
//
|
|
799
|
-
/**
|
|
800
|
-
* Clear range of values.
|
|
801
|
-
*/
|
|
802
|
-
clear(range) {
|
|
803
|
-
const topLeft = getTopLeft(range);
|
|
804
|
-
const values = this._iterRange(range, () => null);
|
|
805
|
-
this._node.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
806
|
-
this._iterRange(range, (cell) => {
|
|
807
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
808
|
-
delete this._sheet.cells[idx];
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
cut(range) {
|
|
812
|
-
this._node.hf.cut(toModelRange(this._node.sheetId, range));
|
|
813
|
-
this._iterRange(range, (cell) => {
|
|
814
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
815
|
-
delete this._sheet.cells[idx];
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
copy(range) {
|
|
819
|
-
this._node.hf.copy(toModelRange(this._node.sheetId, range));
|
|
820
|
-
}
|
|
821
|
-
paste(cell) {
|
|
822
|
-
if (!this._node.hf.isClipboardEmpty()) {
|
|
823
|
-
const changes = this._node.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
824
|
-
for (const change of changes) {
|
|
825
|
-
if (change instanceof import_hyperformula.ExportedCellChange) {
|
|
826
|
-
const { address, newValue } = change;
|
|
827
|
-
const idx = addressToIndex(this._sheet, {
|
|
828
|
-
row: address.row,
|
|
829
|
-
col: address.col
|
|
830
|
-
});
|
|
831
|
-
this._sheet.cells[idx] = {
|
|
832
|
-
value: newValue
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
// TODO(burdon): Display undo/redo state.
|
|
839
|
-
undo() {
|
|
840
|
-
if (this._node.hf.isThereSomethingToUndo()) {
|
|
841
|
-
this._node.hf.undo();
|
|
842
|
-
this.update.emit();
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
redo() {
|
|
846
|
-
if (this._node.hf.isThereSomethingToRedo()) {
|
|
847
|
-
this._node.hf.redo();
|
|
848
|
-
this.update.emit();
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Get value from sheet.
|
|
853
|
-
*/
|
|
854
|
-
getCellValue(cell) {
|
|
855
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
856
|
-
return this._sheet.cells[idx]?.value ?? null;
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* Get value as a string for editing.
|
|
860
|
-
*/
|
|
861
|
-
getCellText(cell) {
|
|
862
|
-
const value = this.getCellValue(cell);
|
|
863
|
-
if (value == null) {
|
|
864
|
-
return void 0;
|
|
479
|
+
var mapFormulaBindingToId = (functions) => (formula) => {
|
|
480
|
+
return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
|
|
481
|
+
if (import_chunk_5KKJ4NPP.defaultFunctions.find((fn2) => fn2.name === binding) || binding === "EDGE") {
|
|
482
|
+
return match;
|
|
865
483
|
}
|
|
866
|
-
|
|
867
|
-
|
|
484
|
+
const fn = functions.find((fn2) => fn2.binding === binding);
|
|
485
|
+
if (fn) {
|
|
486
|
+
return `${(0, import_echo2.fullyQualifiedId)(fn)}(${args})`;
|
|
868
487
|
} else {
|
|
869
|
-
return
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
* Get array of raw values from sheet.
|
|
874
|
-
*/
|
|
875
|
-
getCellValues(range) {
|
|
876
|
-
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* Gets the regular or computed value from the engine.
|
|
880
|
-
*/
|
|
881
|
-
getValue(cell) {
|
|
882
|
-
const value = this._node.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
883
|
-
if (value instanceof import_hyperformula.DetailedCellError) {
|
|
884
|
-
return value.toString();
|
|
885
|
-
}
|
|
886
|
-
return value;
|
|
887
|
-
}
|
|
888
|
-
/**
|
|
889
|
-
* Get value type.
|
|
890
|
-
*/
|
|
891
|
-
getValueType(cell) {
|
|
892
|
-
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
893
|
-
const type = this._node.hf.getCellValueDetailedType(addr);
|
|
894
|
-
return typeMap[type];
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* Sets the value, updating the sheet and engine.
|
|
898
|
-
*/
|
|
899
|
-
setValue(cell, value) {
|
|
900
|
-
if (this._options.readonly) {
|
|
901
|
-
throw new ReadonlyException();
|
|
902
|
-
}
|
|
903
|
-
let refresh = false;
|
|
904
|
-
if (cell.row >= this._sheet.rows.length) {
|
|
905
|
-
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
906
|
-
refresh = true;
|
|
488
|
+
return match;
|
|
907
489
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
var mapFormulaBindingFromId = (functions) => (formula) => {
|
|
493
|
+
return formula.replace(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
|
|
494
|
+
const id = `${spaceId}:${objectId}`;
|
|
495
|
+
if (id.length !== OBJECT_ID_LENGTH) {
|
|
496
|
+
return match;
|
|
914
497
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
col: cell.col
|
|
919
|
-
}, [
|
|
920
|
-
[
|
|
921
|
-
typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
|
|
922
|
-
]
|
|
923
|
-
]);
|
|
924
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
925
|
-
if (value === void 0 || value === null) {
|
|
926
|
-
delete this._sheet.cells[idx];
|
|
498
|
+
const fn = functions.find((fn2) => (0, import_echo2.fullyQualifiedId)(fn2) === id);
|
|
499
|
+
if (fn?.binding) {
|
|
500
|
+
return `${fn.binding}(${args})`;
|
|
927
501
|
} else {
|
|
928
|
-
|
|
929
|
-
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
930
|
-
}
|
|
931
|
-
this._sheet.cells[idx] = {
|
|
932
|
-
value
|
|
933
|
-
};
|
|
502
|
+
return match;
|
|
934
503
|
}
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* Sets values from a simple map.
|
|
938
|
-
*/
|
|
939
|
-
setValues(values) {
|
|
940
|
-
Object.entries(values).forEach(([key, { value }]) => {
|
|
941
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* Iterate range.
|
|
946
|
-
*/
|
|
947
|
-
_iterRange(range, cb) {
|
|
948
|
-
const to = range.to ?? range.from;
|
|
949
|
-
const rowRange = [
|
|
950
|
-
Math.min(range.from.row, to.row),
|
|
951
|
-
Math.max(range.from.row, to.row)
|
|
952
|
-
];
|
|
953
|
-
const columnRange = [
|
|
954
|
-
Math.min(range.from.col, to.col),
|
|
955
|
-
Math.max(range.from.col, to.col)
|
|
956
|
-
];
|
|
957
|
-
const rows = [];
|
|
958
|
-
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
959
|
-
const rowCells = [];
|
|
960
|
-
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
961
|
-
const value = cb({
|
|
962
|
-
row,
|
|
963
|
-
col: column
|
|
964
|
-
});
|
|
965
|
-
if (value !== void 0) {
|
|
966
|
-
rowCells.push(value);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
rows.push(rowCells);
|
|
970
|
-
}
|
|
971
|
-
return rows;
|
|
972
|
-
}
|
|
973
|
-
// TODO(burdon): Delete index.
|
|
974
|
-
_deleteIndices(indices, i, n) {
|
|
975
|
-
throw new Error("Not implemented");
|
|
976
|
-
}
|
|
977
|
-
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
978
|
-
_moveIndices(indices, i, j, n) {
|
|
979
|
-
throw new Error("Not implemented");
|
|
980
|
-
}
|
|
981
|
-
//
|
|
982
|
-
// Indices.
|
|
983
|
-
//
|
|
984
|
-
/**
|
|
985
|
-
* Map from A1 notation to indices.
|
|
986
|
-
*/
|
|
987
|
-
mapFormulaRefsToIndices(formula) {
|
|
988
|
-
(0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
|
|
989
|
-
F: __dxlog_file2,
|
|
990
|
-
L: 358,
|
|
991
|
-
S: this,
|
|
992
|
-
A: [
|
|
993
|
-
"formula.charAt(0) === '='",
|
|
994
|
-
""
|
|
995
|
-
]
|
|
996
|
-
});
|
|
997
|
-
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
998
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Map from indices to A1 notation.
|
|
1003
|
-
*/
|
|
1004
|
-
mapFormulaIndicesToRefs(formula) {
|
|
1005
|
-
(0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
|
|
1006
|
-
F: __dxlog_file2,
|
|
1007
|
-
L: 368,
|
|
1008
|
-
S: this,
|
|
1009
|
-
A: [
|
|
1010
|
-
"formula.charAt(0) === '='",
|
|
1011
|
-
""
|
|
1012
|
-
]
|
|
1013
|
-
});
|
|
1014
|
-
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1015
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
//
|
|
1019
|
-
// Values
|
|
1020
|
-
//
|
|
1021
|
-
/**
|
|
1022
|
-
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
1023
|
-
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
1024
|
-
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
1025
|
-
*/
|
|
1026
|
-
toLocalDate(num) {
|
|
1027
|
-
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
1028
|
-
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1029
|
-
}
|
|
1030
|
-
toDateTime(num) {
|
|
1031
|
-
return this._node.hf.numberToDateTime(num);
|
|
1032
|
-
}
|
|
1033
|
-
toDate(num) {
|
|
1034
|
-
return this._node.hf.numberToDate(num);
|
|
1035
|
-
}
|
|
1036
|
-
toTime(num) {
|
|
1037
|
-
return this._node.hf.numberToTime(num);
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
var useFormattingModel = (model) => {
|
|
1041
|
-
return (0, import_react9.useMemo)(() => model && new FormattingModel(model), [
|
|
1042
|
-
model
|
|
1043
|
-
]);
|
|
504
|
+
});
|
|
1044
505
|
};
|
|
1045
|
-
var
|
|
1046
|
-
const graph = useComputeGraph(space);
|
|
1047
|
-
const [
|
|
1048
|
-
(0,
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
506
|
+
var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...options }) => {
|
|
507
|
+
const graph = (0, import_chunk_CN3RPESU.useComputeGraph)(space, options);
|
|
508
|
+
const [cursor, setCursor] = (0, import_react6.useState)();
|
|
509
|
+
const [range, setRange] = (0, import_react6.useState)();
|
|
510
|
+
const [editing, setEditing] = (0, import_react6.useState)(false);
|
|
511
|
+
const [[model, formatting] = [], setModels] = (0, import_react6.useState)(void 0);
|
|
512
|
+
(0, import_react6.useEffect)(() => {
|
|
1052
513
|
let model2;
|
|
514
|
+
let formatting2;
|
|
1053
515
|
const t = setTimeout(async () => {
|
|
1054
|
-
model2 = new SheetModel(graph, sheet, {
|
|
1055
|
-
readonly
|
|
516
|
+
model2 = new import_chunk_5KKJ4NPP.SheetModel(graph, sheet, space, {
|
|
517
|
+
readonly,
|
|
518
|
+
mapFormulaBindingToId,
|
|
519
|
+
mapFormulaBindingFromId
|
|
1056
520
|
});
|
|
1057
|
-
await model2.
|
|
1058
|
-
|
|
521
|
+
await model2.initialize();
|
|
522
|
+
formatting2 = new FormattingModel(model2);
|
|
523
|
+
setModels([
|
|
524
|
+
model2,
|
|
525
|
+
formatting2
|
|
526
|
+
]);
|
|
1059
527
|
});
|
|
1060
528
|
return () => {
|
|
1061
529
|
clearTimeout(t);
|
|
1062
|
-
void model2?.
|
|
530
|
+
void model2?.destroy();
|
|
1063
531
|
};
|
|
1064
532
|
}, [
|
|
1065
|
-
space,
|
|
1066
|
-
sheet,
|
|
1067
533
|
graph,
|
|
1068
534
|
readonly
|
|
1069
535
|
]);
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
var useSheetContext = () => {
|
|
1075
|
-
const context = (0, import_react5.useContext)(SheetContext);
|
|
1076
|
-
(0, import_invariant2.invariant)(context, void 0, {
|
|
1077
|
-
F: __dxlog_file3,
|
|
1078
|
-
L: 43,
|
|
1079
|
-
S: void 0,
|
|
1080
|
-
A: [
|
|
1081
|
-
"context",
|
|
1082
|
-
""
|
|
1083
|
-
]
|
|
1084
|
-
});
|
|
1085
|
-
return context;
|
|
1086
|
-
};
|
|
1087
|
-
var SheetContextProvider = ({ children, sheet, space, readonly, onInfo }) => {
|
|
1088
|
-
const model = useSheetModel(space, sheet, {
|
|
1089
|
-
readonly
|
|
1090
|
-
});
|
|
1091
|
-
const formatting = useFormattingModel(model);
|
|
1092
|
-
const [cursor, setCursor] = (0, import_react5.useState)();
|
|
1093
|
-
const [range, setRange] = (0, import_react5.useState)();
|
|
1094
|
-
const [editing, setEditing] = (0, import_react5.useState)(false);
|
|
1095
|
-
const decorations = (0, import_react5.useMemo)(() => createDecorations(), []);
|
|
1096
|
-
return !model || !formatting ? null : /* @__PURE__ */ import_react5.default.createElement(SheetContext.Provider, {
|
|
536
|
+
if (!model || !formatting) {
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
return /* @__PURE__ */ import_react6.default.createElement(SheetContext.Provider, {
|
|
1097
540
|
value: {
|
|
1098
541
|
model,
|
|
1099
542
|
formatting,
|
|
@@ -1104,168 +547,10 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo }) => {
|
|
|
1104
547
|
editing,
|
|
1105
548
|
setEditing,
|
|
1106
549
|
// TODO(burdon): Change to event.
|
|
1107
|
-
onInfo
|
|
1108
|
-
decorations
|
|
550
|
+
onInfo
|
|
1109
551
|
}
|
|
1110
552
|
}, children);
|
|
1111
553
|
};
|
|
1112
|
-
var CommentIndicator = () => {
|
|
1113
|
-
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1114
|
-
role: "none",
|
|
1115
|
-
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
1116
|
-
});
|
|
1117
|
-
};
|
|
1118
|
-
var ThreadedCellWrapper = ({ children }) => {
|
|
1119
|
-
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1120
|
-
const [isHovered, setIsHovered] = import_react11.default.useState(false);
|
|
1121
|
-
const { t } = (0, import_react_ui.useTranslation)(import_chunk_BNARJ5GM.SHEET_PLUGIN);
|
|
1122
|
-
const handleClick = import_react11.default.useCallback((_event) => {
|
|
1123
|
-
void dispatch({
|
|
1124
|
-
action: import_app_framework.LayoutAction.SET_LAYOUT,
|
|
1125
|
-
data: {
|
|
1126
|
-
element: "complementary",
|
|
1127
|
-
state: true
|
|
1128
|
-
}
|
|
1129
|
-
});
|
|
1130
|
-
}, [
|
|
1131
|
-
dispatch
|
|
1132
|
-
]);
|
|
1133
|
-
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1134
|
-
role: "none",
|
|
1135
|
-
className: "relative h-full is-full",
|
|
1136
|
-
onMouseEnter: () => {
|
|
1137
|
-
setIsHovered(true);
|
|
1138
|
-
},
|
|
1139
|
-
onMouseLeave: () => {
|
|
1140
|
-
setIsHovered(false);
|
|
1141
|
-
}
|
|
1142
|
-
}, /* @__PURE__ */ import_react11.default.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1143
|
-
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
1144
|
-
}, /* @__PURE__ */ import_react11.default.createElement("button", {
|
|
1145
|
-
className: "ch-button text-xs min-bs-0 p-1",
|
|
1146
|
-
onClick: handleClick,
|
|
1147
|
-
"aria-label": t("open comment for sheet cell")
|
|
1148
|
-
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui.Icon, {
|
|
1149
|
-
icon: "ph--chat--regular",
|
|
1150
|
-
"aria-hidden": true
|
|
1151
|
-
}))), children);
|
|
1152
|
-
};
|
|
1153
|
-
var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
1154
|
-
return {
|
|
1155
|
-
type: "comment",
|
|
1156
|
-
cellIndex,
|
|
1157
|
-
decorate: (props) => /* @__PURE__ */ import_react11.default.createElement(ThreadedCellWrapper, props)
|
|
1158
|
-
};
|
|
1159
|
-
};
|
|
1160
|
-
var useUpdateCursorOnThreadSelection = () => {
|
|
1161
|
-
const { setCursor, model } = useSheetContext();
|
|
1162
|
-
const handleScrollIntoView = (0, import_react11.useCallback)(({ action, data }) => {
|
|
1163
|
-
switch (action) {
|
|
1164
|
-
case import_app_framework.LayoutAction.SCROLL_INTO_VIEW: {
|
|
1165
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo2.fullyQualifiedId)(model.sheet)) {
|
|
1166
|
-
return;
|
|
1167
|
-
}
|
|
1168
|
-
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
1169
|
-
setCursor(cellAddress);
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
}, [
|
|
1173
|
-
model.sheet,
|
|
1174
|
-
setCursor
|
|
1175
|
-
]);
|
|
1176
|
-
(0, import_app_framework.useIntentResolver)(import_chunk_BNARJ5GM.SHEET_PLUGIN, handleScrollIntoView);
|
|
1177
|
-
};
|
|
1178
|
-
var useSelectThreadOnCursorChange = () => {
|
|
1179
|
-
const { cursor, model } = useSheetContext();
|
|
1180
|
-
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1181
|
-
const activeThreads = (0, import_react11.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
1182
|
-
JSON.stringify(model.sheet.threads)
|
|
1183
|
-
]);
|
|
1184
|
-
const activeThreadAddresses = (0, import_react11.useMemo)(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
1185
|
-
activeThreads,
|
|
1186
|
-
model.sheet
|
|
1187
|
-
]);
|
|
1188
|
-
const selectClosestThread = (0, import_react11.useCallback)((cellAddress) => {
|
|
1189
|
-
if (!cellAddress || !activeThreads) {
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
1193
|
-
if (closestThreadAnchor) {
|
|
1194
|
-
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
1195
|
-
if (closestThread) {
|
|
1196
|
-
void dispatch([
|
|
1197
|
-
{
|
|
1198
|
-
action: "dxos.org/plugin/thread/action/select",
|
|
1199
|
-
data: {
|
|
1200
|
-
current: (0, import_echo2.fullyQualifiedId)(closestThread)
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
]);
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
}, [
|
|
1207
|
-
dispatch,
|
|
1208
|
-
activeThreads,
|
|
1209
|
-
activeThreadAddresses,
|
|
1210
|
-
model.sheet
|
|
1211
|
-
]);
|
|
1212
|
-
const debounced = (0, import_react11.useMemo)(() => {
|
|
1213
|
-
return (0, import_async3.debounce)((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
1214
|
-
}, [
|
|
1215
|
-
selectClosestThread
|
|
1216
|
-
]);
|
|
1217
|
-
(0, import_react11.useEffect)(() => {
|
|
1218
|
-
if (!cursor) {
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
debounced(cursor);
|
|
1222
|
-
}, [
|
|
1223
|
-
cursor,
|
|
1224
|
-
selectClosestThread
|
|
1225
|
-
]);
|
|
1226
|
-
};
|
|
1227
|
-
var useThreadDecorations = () => {
|
|
1228
|
-
const { decorations, model } = useSheetContext();
|
|
1229
|
-
const sheet = (0, import_react11.useMemo)(() => model.sheet, [
|
|
1230
|
-
model.sheet
|
|
1231
|
-
]);
|
|
1232
|
-
const sheetId = (0, import_react11.useMemo)(() => (0, import_echo2.fullyQualifiedId)(sheet), [
|
|
1233
|
-
sheet
|
|
1234
|
-
]);
|
|
1235
|
-
(0, import_react11.useEffect)(() => {
|
|
1236
|
-
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
1237
|
-
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
1238
|
-
if (!sheet.threads) {
|
|
1239
|
-
return;
|
|
1240
|
-
}
|
|
1241
|
-
for (const thread of sheet.threads) {
|
|
1242
|
-
if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
|
|
1243
|
-
continue;
|
|
1244
|
-
}
|
|
1245
|
-
activeThreadAnchors.add(thread.anchor);
|
|
1246
|
-
const index = thread.anchor;
|
|
1247
|
-
const existingDecorations = decorations.getDecorationsForCell(index);
|
|
1248
|
-
if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
|
|
1249
|
-
decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
for (const decoration of decorations.getAllDecorations()) {
|
|
1253
|
-
if (decoration.type !== "comment") {
|
|
1254
|
-
continue;
|
|
1255
|
-
}
|
|
1256
|
-
if (!activeThreadAnchors.has(decoration.cellIndex)) {
|
|
1257
|
-
decorations.removeDecoration(decoration.cellIndex, "comment");
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
return () => unsubscribe();
|
|
1262
|
-
});
|
|
1263
|
-
};
|
|
1264
|
-
var useThreads = () => {
|
|
1265
|
-
useUpdateCursorOnThreadSelection();
|
|
1266
|
-
useSelectThreadOnCursorChange();
|
|
1267
|
-
useThreadDecorations();
|
|
1268
|
-
};
|
|
1269
554
|
var getRelativeClientRect = (root, element) => {
|
|
1270
555
|
const rootRect = root.getBoundingClientRect();
|
|
1271
556
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -1342,61 +627,21 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
1342
627
|
{
|
|
1343
628
|
key: "Enter",
|
|
1344
629
|
run: (editor) => {
|
|
1345
|
-
onClose(editor.state.doc.toString()
|
|
1346
|
-
key: "Enter"
|
|
1347
|
-
});
|
|
1348
|
-
return true;
|
|
1349
|
-
},
|
|
1350
|
-
shift: (editor) => {
|
|
1351
|
-
onClose(editor.state.doc.toString(), {
|
|
1352
|
-
key: "Enter",
|
|
1353
|
-
shift: true
|
|
1354
|
-
});
|
|
1355
|
-
return true;
|
|
1356
|
-
}
|
|
1357
|
-
},
|
|
1358
|
-
{
|
|
1359
|
-
key: "Tab",
|
|
1360
|
-
run: (editor) => {
|
|
1361
|
-
onClose(editor.state.doc.toString(), {
|
|
1362
|
-
key: "Tab"
|
|
1363
|
-
});
|
|
1364
|
-
return true;
|
|
1365
|
-
},
|
|
1366
|
-
shift: (editor) => {
|
|
1367
|
-
onClose(editor.state.doc.toString(), {
|
|
1368
|
-
key: "Tab",
|
|
1369
|
-
shift: true
|
|
1370
|
-
});
|
|
630
|
+
onClose(editor.state.doc.toString());
|
|
1371
631
|
return true;
|
|
1372
632
|
}
|
|
1373
633
|
},
|
|
1374
634
|
{
|
|
1375
635
|
key: "Escape",
|
|
1376
636
|
run: () => {
|
|
1377
|
-
onClose(void 0
|
|
1378
|
-
key: "Escape"
|
|
1379
|
-
});
|
|
637
|
+
onClose(void 0);
|
|
1380
638
|
return true;
|
|
1381
639
|
}
|
|
1382
640
|
}
|
|
1383
641
|
]);
|
|
1384
642
|
};
|
|
1385
|
-
var
|
|
1386
|
-
|
|
1387
|
-
legacy: {
|
|
1388
|
-
root: "flex w-full",
|
|
1389
|
-
editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
|
|
1390
|
-
content: "!px-2 !py-1"
|
|
1391
|
-
},
|
|
1392
|
-
grid: {
|
|
1393
|
-
root: "absolute z-[1]",
|
|
1394
|
-
editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
|
|
1395
|
-
content: "!border !border-transparent !p-0.5"
|
|
1396
|
-
}
|
|
1397
|
-
};
|
|
1398
|
-
var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
|
|
1399
|
-
const { themeMode } = (0, import_react_ui2.useThemeContext)();
|
|
643
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
644
|
+
const { themeMode } = (0, import_react_ui.useThemeContext)();
|
|
1400
645
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
1401
646
|
return {
|
|
1402
647
|
autoFocus,
|
|
@@ -1422,29 +667,21 @@ var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box
|
|
|
1422
667
|
themeMode,
|
|
1423
668
|
slots: {
|
|
1424
669
|
editor: {
|
|
1425
|
-
className:
|
|
670
|
+
className: "flex w-full [&>.cm-scroller]:scrollbar-none"
|
|
1426
671
|
},
|
|
1427
672
|
content: {
|
|
1428
|
-
className:
|
|
673
|
+
className: "!px-2 !py-1"
|
|
1429
674
|
}
|
|
1430
675
|
}
|
|
1431
676
|
})
|
|
1432
677
|
]
|
|
1433
678
|
};
|
|
1434
679
|
}, [
|
|
1435
|
-
extension
|
|
1436
|
-
autoFocus,
|
|
1437
|
-
value,
|
|
1438
|
-
variant,
|
|
1439
|
-
onBlur
|
|
680
|
+
extension
|
|
1440
681
|
]);
|
|
1441
|
-
return /* @__PURE__ */
|
|
682
|
+
return /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1442
683
|
ref: parentRef,
|
|
1443
|
-
className:
|
|
1444
|
-
style: box,
|
|
1445
|
-
...gridId && {
|
|
1446
|
-
"data-grid": gridId
|
|
1447
|
-
}
|
|
684
|
+
className: "flex w-full"
|
|
1448
685
|
});
|
|
1449
686
|
};
|
|
1450
687
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -1557,7 +794,13 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
1557
794
|
// NOTE: Useful for debugging.
|
|
1558
795
|
closeOnBlur: false,
|
|
1559
796
|
icons: false,
|
|
1560
|
-
tooltipClass: () => (0,
|
|
797
|
+
tooltipClass: () => (0, import_react_ui_theme3.mx)(
|
|
798
|
+
// TODO(burdon): Factor out fragments.
|
|
799
|
+
// TODO(burdon): Size to make width same as column.
|
|
800
|
+
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
801
|
+
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
802
|
+
"border-separator"
|
|
803
|
+
)
|
|
1561
804
|
}),
|
|
1562
805
|
import_view2.keymap.of([
|
|
1563
806
|
{
|
|
@@ -1644,7 +887,7 @@ var visitTree = (node, callback) => {
|
|
|
1644
887
|
}
|
|
1645
888
|
return false;
|
|
1646
889
|
};
|
|
1647
|
-
var
|
|
890
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
1648
891
|
var fragments = {
|
|
1649
892
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
1650
893
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -1652,19 +895,18 @@ var fragments = {
|
|
|
1652
895
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
1653
896
|
};
|
|
1654
897
|
var SheetRoot = ({ children, ...props }) => {
|
|
1655
|
-
return /* @__PURE__ */
|
|
898
|
+
return /* @__PURE__ */ import_react3.default.createElement(SheetContextProvider, props, children);
|
|
1656
899
|
};
|
|
1657
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
900
|
+
var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, numRows, numColumns }, forwardRef2) => {
|
|
1658
901
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
1659
902
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
1660
|
-
|
|
1661
|
-
const [rows, setRows] = (0, import_react2.useState)([
|
|
903
|
+
const [rows, setRows] = (0, import_react3.useState)([
|
|
1662
904
|
...model.sheet.rows
|
|
1663
905
|
]);
|
|
1664
|
-
const [columns, setColumns] = (0,
|
|
906
|
+
const [columns, setColumns] = (0, import_react3.useState)([
|
|
1665
907
|
...model.sheet.columns
|
|
1666
908
|
]);
|
|
1667
|
-
(0,
|
|
909
|
+
(0, import_react3.useEffect)(() => {
|
|
1668
910
|
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1669
911
|
"rows"
|
|
1670
912
|
]);
|
|
@@ -1689,37 +931,37 @@ var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, num
|
|
|
1689
931
|
}, [
|
|
1690
932
|
model
|
|
1691
933
|
]);
|
|
1692
|
-
(0,
|
|
934
|
+
(0, import_react3.useEffect)(() => {
|
|
1693
935
|
model.reset();
|
|
1694
936
|
}, [
|
|
1695
937
|
rows,
|
|
1696
938
|
columns
|
|
1697
939
|
]);
|
|
1698
940
|
const handleMoveRows = (from, to, num = 1) => {
|
|
1699
|
-
const cursorIdx = cursor ? addressToIndex(
|
|
941
|
+
const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
|
|
1700
942
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
1701
943
|
model.sheet.rows.splice(to, 0, rows2);
|
|
1702
944
|
if (cursorIdx) {
|
|
1703
|
-
setCursor(addressFromIndex(
|
|
945
|
+
setCursor(model.addressFromIndex(cursorIdx));
|
|
1704
946
|
}
|
|
1705
947
|
setRows([
|
|
1706
948
|
...model.sheet.rows
|
|
1707
949
|
]);
|
|
1708
950
|
};
|
|
1709
951
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
1710
|
-
const cursorIdx = cursor ? addressToIndex(
|
|
952
|
+
const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
|
|
1711
953
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
1712
954
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
1713
955
|
if (cursorIdx) {
|
|
1714
|
-
setCursor(addressFromIndex(
|
|
956
|
+
setCursor(model.addressFromIndex(cursorIdx));
|
|
1715
957
|
}
|
|
1716
958
|
setColumns([
|
|
1717
959
|
...model.sheet.columns
|
|
1718
960
|
]);
|
|
1719
961
|
};
|
|
1720
|
-
const [rowSizes, setRowSizes] = (0,
|
|
1721
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
1722
|
-
(0,
|
|
962
|
+
const [rowSizes, setRowSizes] = (0, import_react3.useState)();
|
|
963
|
+
const [columnSizes, setColumnSizes] = (0, import_react3.useState)();
|
|
964
|
+
(0, import_react3.useEffect)(() => {
|
|
1723
965
|
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1724
966
|
"rowMeta"
|
|
1725
967
|
]);
|
|
@@ -1768,54 +1010,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, num
|
|
|
1768
1010
|
}));
|
|
1769
1011
|
}
|
|
1770
1012
|
};
|
|
1771
|
-
return /* @__PURE__ */
|
|
1013
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1772
1014
|
role: "none",
|
|
1773
|
-
className: (0,
|
|
1774
|
-
}, /* @__PURE__ */
|
|
1015
|
+
className: (0, import_react_ui_theme2.mx)("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1016
|
+
}, /* @__PURE__ */ import_react3.default.createElement(GridCorner, {
|
|
1775
1017
|
onClick: () => {
|
|
1776
1018
|
setCursor(void 0);
|
|
1777
1019
|
setRange(void 0);
|
|
1778
1020
|
setEditing(false);
|
|
1779
1021
|
}
|
|
1780
|
-
}), /* @__PURE__ */
|
|
1022
|
+
}), /* @__PURE__ */ import_react3.default.createElement(SheetColumns, {
|
|
1781
1023
|
ref: columnsRef,
|
|
1782
1024
|
columns,
|
|
1783
1025
|
sizes: columnSizes,
|
|
1784
|
-
selected: cursor?.
|
|
1785
|
-
onSelect: (
|
|
1026
|
+
selected: cursor?.column,
|
|
1027
|
+
onSelect: (column) => setCursor(cursor?.column === column ? void 0 : {
|
|
1786
1028
|
row: -1,
|
|
1787
|
-
|
|
1029
|
+
column
|
|
1788
1030
|
}),
|
|
1789
1031
|
onResize: handleResizeColumn,
|
|
1790
1032
|
onMove: handleMoveColumns
|
|
1791
|
-
}), /* @__PURE__ */
|
|
1033
|
+
}), /* @__PURE__ */ import_react3.default.createElement(SheetRows, {
|
|
1792
1034
|
ref: rowsRef,
|
|
1793
1035
|
rows,
|
|
1794
1036
|
sizes: rowSizes,
|
|
1795
1037
|
selected: cursor?.row,
|
|
1796
1038
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1797
1039
|
row,
|
|
1798
|
-
|
|
1040
|
+
column: -1
|
|
1799
1041
|
}),
|
|
1800
1042
|
onResize: handleResizeRow,
|
|
1801
1043
|
onMove: handleMoveRows
|
|
1802
|
-
}), /* @__PURE__ */
|
|
1044
|
+
}), /* @__PURE__ */ import_react3.default.createElement(SheetGrid, {
|
|
1803
1045
|
ref: contentRef,
|
|
1804
1046
|
size: {
|
|
1805
1047
|
numRows: numRows ?? rows.length,
|
|
1806
|
-
|
|
1048
|
+
numColumns: numColumns ?? columns.length
|
|
1807
1049
|
},
|
|
1808
1050
|
rows,
|
|
1809
1051
|
columns,
|
|
1810
1052
|
rowSizes,
|
|
1811
1053
|
columnSizes
|
|
1812
|
-
}), /* @__PURE__ */
|
|
1054
|
+
}), /* @__PURE__ */ import_react3.default.createElement(GridCorner, null), /* @__PURE__ */ import_react3.default.createElement(SheetStatusBar, null));
|
|
1813
1055
|
});
|
|
1814
1056
|
var useScrollHandlers = () => {
|
|
1815
|
-
const rowsRef = (0,
|
|
1816
|
-
const columnsRef = (0,
|
|
1817
|
-
const contentRef = (0,
|
|
1818
|
-
(0,
|
|
1057
|
+
const rowsRef = (0, import_react3.useRef)(null);
|
|
1058
|
+
const columnsRef = (0, import_react3.useRef)(null);
|
|
1059
|
+
const contentRef = (0, import_react3.useRef)(null);
|
|
1060
|
+
(0, import_react3.useEffect)(() => {
|
|
1819
1061
|
const handleRowsScroll = (ev) => {
|
|
1820
1062
|
const { scrollTop } = ev.target;
|
|
1821
1063
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1852,13 +1094,13 @@ var useScrollHandlers = () => {
|
|
|
1852
1094
|
};
|
|
1853
1095
|
};
|
|
1854
1096
|
var GridCorner = (props) => {
|
|
1855
|
-
return /* @__PURE__ */
|
|
1097
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1856
1098
|
className: fragments.axis,
|
|
1857
1099
|
...props
|
|
1858
1100
|
});
|
|
1859
1101
|
};
|
|
1860
1102
|
var MovingOverlay = ({ label }) => {
|
|
1861
|
-
return /* @__PURE__ */
|
|
1103
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1862
1104
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1863
1105
|
}, label);
|
|
1864
1106
|
};
|
|
@@ -1869,7 +1111,7 @@ var touchConstraints = {
|
|
|
1869
1111
|
delay: 250,
|
|
1870
1112
|
tolerance: 5
|
|
1871
1113
|
};
|
|
1872
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
1114
|
+
var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1873
1115
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1874
1116
|
activationConstraint: mouseConstraints
|
|
1875
1117
|
});
|
|
@@ -1878,7 +1120,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
1878
1120
|
});
|
|
1879
1121
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1880
1122
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1881
|
-
const [active, setActive] = (0,
|
|
1123
|
+
const [active, setActive] = (0, import_react3.useState)(null);
|
|
1882
1124
|
const handleDragStart = ({ active: active2 }) => {
|
|
1883
1125
|
setActive(active2);
|
|
1884
1126
|
};
|
|
@@ -1902,18 +1144,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
1902
1144
|
}
|
|
1903
1145
|
return transform;
|
|
1904
1146
|
};
|
|
1905
|
-
return /* @__PURE__ */
|
|
1147
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1906
1148
|
className: "relative flex grow overflow-hidden"
|
|
1907
|
-
}, /* @__PURE__ */
|
|
1908
|
-
className: (0,
|
|
1149
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1150
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
1909
1151
|
style: {
|
|
1910
1152
|
width: axisWidth
|
|
1911
1153
|
}
|
|
1912
|
-
}), /* @__PURE__ */
|
|
1154
|
+
}), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1913
1155
|
ref: forwardRef2,
|
|
1914
1156
|
role: "rowheader",
|
|
1915
1157
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1916
|
-
}, /* @__PURE__ */
|
|
1158
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_core.DndContext, {
|
|
1917
1159
|
sensors,
|
|
1918
1160
|
modifiers: [
|
|
1919
1161
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -1921,12 +1163,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
1921
1163
|
],
|
|
1922
1164
|
onDragStart: handleDragStart,
|
|
1923
1165
|
onDragEnd: handleDragEnd
|
|
1924
|
-
}, /* @__PURE__ */
|
|
1166
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1925
1167
|
className: "flex flex-col",
|
|
1926
1168
|
style: {
|
|
1927
1169
|
width: axisWidth
|
|
1928
1170
|
}
|
|
1929
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1171
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react3.default.createElement(GridRowCell, {
|
|
1930
1172
|
key: idx,
|
|
1931
1173
|
idx,
|
|
1932
1174
|
index,
|
|
@@ -1936,7 +1178,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
1936
1178
|
selected: selected === index,
|
|
1937
1179
|
onResize,
|
|
1938
1180
|
onSelect
|
|
1939
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1181
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react3.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react3.default.createElement(MovingOverlay, {
|
|
1940
1182
|
label: String(active.data.current.index + 1)
|
|
1941
1183
|
})), document.body))));
|
|
1942
1184
|
});
|
|
@@ -1954,9 +1196,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1954
1196
|
}
|
|
1955
1197
|
});
|
|
1956
1198
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1957
|
-
const [initialSize, setInitialSize] = (0,
|
|
1958
|
-
const [resizing, setResizing] = (0,
|
|
1959
|
-
const scrollHandler = (0,
|
|
1199
|
+
const [initialSize, setInitialSize] = (0, import_react3.useState)(size);
|
|
1200
|
+
const [resizing, setResizing] = (0, import_react3.useState)(false);
|
|
1201
|
+
const scrollHandler = (0, import_react3.useRef)();
|
|
1960
1202
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1961
1203
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
1962
1204
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -1977,7 +1219,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1977
1219
|
onResize?.(idx, initialSize + height, true);
|
|
1978
1220
|
setResizing(false);
|
|
1979
1221
|
};
|
|
1980
|
-
return /* @__PURE__ */
|
|
1222
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_re_resizable.Resizable, {
|
|
1981
1223
|
enable: {
|
|
1982
1224
|
bottom: resize
|
|
1983
1225
|
},
|
|
@@ -1989,21 +1231,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1989
1231
|
onResizeStart: handleResizeStart,
|
|
1990
1232
|
onResize: handleResize,
|
|
1991
1233
|
onResizeStop: handleResizeStop
|
|
1992
|
-
}, /* @__PURE__ */
|
|
1234
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1993
1235
|
ref: setNodeRef,
|
|
1994
1236
|
...attributes,
|
|
1995
1237
|
...listeners,
|
|
1996
|
-
className: (0,
|
|
1238
|
+
className: (0, import_react_ui_theme2.mx)("flex h-full items-center justify-center cursor-pointer", "border-t border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
1997
1239
|
onClick: () => onSelect?.(index)
|
|
1998
|
-
}, /* @__PURE__ */
|
|
1240
|
+
}, /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
1999
1241
|
className: "flex w-full justify-center"
|
|
2000
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
1242
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2001
1243
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
2002
|
-
}), resizing && /* @__PURE__ */
|
|
1244
|
+
}), resizing && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2003
1245
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
2004
1246
|
})));
|
|
2005
1247
|
};
|
|
2006
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
1248
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
2007
1249
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
2008
1250
|
activationConstraint: mouseConstraints
|
|
2009
1251
|
});
|
|
@@ -2012,7 +1254,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, siz
|
|
|
2012
1254
|
});
|
|
2013
1255
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
2014
1256
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
2015
|
-
const [active, setActive] = (0,
|
|
1257
|
+
const [active, setActive] = (0, import_react3.useState)(null);
|
|
2016
1258
|
const handleDragStart = ({ active: active2 }) => {
|
|
2017
1259
|
setActive(active2);
|
|
2018
1260
|
};
|
|
@@ -2036,18 +1278,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, siz
|
|
|
2036
1278
|
}
|
|
2037
1279
|
return transform;
|
|
2038
1280
|
};
|
|
2039
|
-
return /* @__PURE__ */
|
|
1281
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2040
1282
|
className: "relative flex grow overflow-hidden"
|
|
2041
|
-
}, /* @__PURE__ */
|
|
2042
|
-
className: (0,
|
|
1283
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1284
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
2043
1285
|
style: {
|
|
2044
1286
|
height: axisHeight
|
|
2045
1287
|
}
|
|
2046
|
-
}), /* @__PURE__ */
|
|
1288
|
+
}), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2047
1289
|
ref: forwardRef2,
|
|
2048
1290
|
role: "columnheader",
|
|
2049
1291
|
className: "grow overflow-x-auto scrollbar-none"
|
|
2050
|
-
}, /* @__PURE__ */
|
|
1292
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_core.DndContext, {
|
|
2051
1293
|
autoScroll: {
|
|
2052
1294
|
enabled: true
|
|
2053
1295
|
},
|
|
@@ -2058,23 +1300,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, siz
|
|
|
2058
1300
|
],
|
|
2059
1301
|
onDragStart: handleDragStart,
|
|
2060
1302
|
onDragEnd: handleDragEnd
|
|
2061
|
-
}, /* @__PURE__ */
|
|
1303
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2062
1304
|
className: "flex h-full",
|
|
2063
1305
|
style: {
|
|
2064
1306
|
height: axisHeight
|
|
2065
1307
|
}
|
|
2066
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
1308
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react3.default.createElement(GridColumnCell, {
|
|
2067
1309
|
key: idx,
|
|
2068
1310
|
idx,
|
|
2069
1311
|
index,
|
|
2070
|
-
label: columnLetter(index),
|
|
1312
|
+
label: (0, import_chunk_5KKJ4NPP.columnLetter)(index),
|
|
2071
1313
|
size: sizes?.[idx] ?? defaultWidth,
|
|
2072
1314
|
resize: index < columns.length - 1,
|
|
2073
1315
|
selected: selected === index,
|
|
2074
1316
|
onResize,
|
|
2075
1317
|
onSelect
|
|
2076
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2077
|
-
label: columnLetter(active.data.current.index)
|
|
1318
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react3.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react3.default.createElement(MovingOverlay, {
|
|
1319
|
+
label: (0, import_chunk_5KKJ4NPP.columnLetter)(active.data.current.index)
|
|
2078
1320
|
})), document.body))));
|
|
2079
1321
|
});
|
|
2080
1322
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -2091,9 +1333,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2091
1333
|
}
|
|
2092
1334
|
});
|
|
2093
1335
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
2094
|
-
const [initialSize, setInitialSize] = (0,
|
|
2095
|
-
const [resizing, setResizing] = (0,
|
|
2096
|
-
const scrollHandler = (0,
|
|
1336
|
+
const [initialSize, setInitialSize] = (0, import_react3.useState)(size);
|
|
1337
|
+
const [resizing, setResizing] = (0, import_react3.useState)(false);
|
|
1338
|
+
const scrollHandler = (0, import_react3.useRef)();
|
|
2097
1339
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
2098
1340
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
2099
1341
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -2114,7 +1356,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2114
1356
|
onResize?.(idx, initialSize + width, true);
|
|
2115
1357
|
setResizing(false);
|
|
2116
1358
|
};
|
|
2117
|
-
return /* @__PURE__ */
|
|
1359
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_re_resizable.Resizable, {
|
|
2118
1360
|
enable: {
|
|
2119
1361
|
right: resize
|
|
2120
1362
|
},
|
|
@@ -2126,37 +1368,37 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2126
1368
|
onResizeStart: handleResizeStart,
|
|
2127
1369
|
onResize: handleResize,
|
|
2128
1370
|
onResizeStop: handleResizeStop
|
|
2129
|
-
}, /* @__PURE__ */
|
|
1371
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2130
1372
|
ref: setNodeRef,
|
|
2131
1373
|
...attributes,
|
|
2132
1374
|
...listeners,
|
|
2133
|
-
className: (0,
|
|
1375
|
+
className: (0, import_react_ui_theme2.mx)("flex h-full items-center justify-center cursor-pointer", "border-l border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
2134
1376
|
onClick: () => onSelect?.(index)
|
|
2135
|
-
}, /* @__PURE__ */
|
|
1377
|
+
}, /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
2136
1378
|
className: "flex w-full justify-center"
|
|
2137
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
1379
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2138
1380
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
2139
|
-
}), resizing && /* @__PURE__ */
|
|
1381
|
+
}), resizing && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2140
1382
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
2141
1383
|
})));
|
|
2142
1384
|
};
|
|
2143
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
1385
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
2144
1386
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
2145
1387
|
refreshRate: 200
|
|
2146
1388
|
});
|
|
2147
|
-
const scrollerRef = (0,
|
|
2148
|
-
(0,
|
|
1389
|
+
const scrollerRef = (0, import_react3.useRef)(null);
|
|
1390
|
+
(0, import_react3.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
2149
1391
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
2150
|
-
const initialText = (0,
|
|
2151
|
-
const quickEdit = (0,
|
|
2152
|
-
const [, forceUpdate] = (0,
|
|
2153
|
-
(0,
|
|
1392
|
+
const initialText = (0, import_react3.useRef)();
|
|
1393
|
+
const quickEdit = (0, import_react3.useRef)(false);
|
|
1394
|
+
const [, forceUpdate] = (0, import_react3.useState)({});
|
|
1395
|
+
(0, import_react3.useEffect)(() => {
|
|
2154
1396
|
const unsubscribe = model.update.on(() => {
|
|
2155
1397
|
(0, import_log.log)("updated", {
|
|
2156
1398
|
id: model.id
|
|
2157
1399
|
}, {
|
|
2158
|
-
F:
|
|
2159
|
-
L:
|
|
1400
|
+
F: __dxlog_file2,
|
|
1401
|
+
L: 730,
|
|
2160
1402
|
S: void 0,
|
|
2161
1403
|
C: (f, a) => f(...a)
|
|
2162
1404
|
});
|
|
@@ -2168,7 +1410,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2168
1410
|
}, [
|
|
2169
1411
|
model
|
|
2170
1412
|
]);
|
|
2171
|
-
const inputRef = (0,
|
|
1413
|
+
const inputRef = (0, import_react3.useRef)(null);
|
|
2172
1414
|
const handleKeyDown = (ev) => {
|
|
2173
1415
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
2174
1416
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -2276,16 +1518,16 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2276
1518
|
const id = (0, import_echo.fullyQualifiedId)(model.sheet);
|
|
2277
1519
|
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(id);
|
|
2278
1520
|
const hasAttention = (0, import_react_ui_attention.useHasAttention)(id);
|
|
2279
|
-
return /* @__PURE__ */
|
|
1521
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2280
1522
|
ref: containerRef,
|
|
2281
1523
|
role: "grid",
|
|
2282
1524
|
className: "relative flex grow overflow-hidden"
|
|
2283
|
-
}, /* @__PURE__ */
|
|
2284
|
-
className: (0,
|
|
2285
|
-
}), /* @__PURE__ */
|
|
1525
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1526
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
1527
|
+
}), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2286
1528
|
ref: scrollerRef,
|
|
2287
|
-
className: (0,
|
|
2288
|
-
}, /* @__PURE__ */
|
|
1529
|
+
className: (0, import_react_ui_theme2.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
1530
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2289
1531
|
className: "relative select-none",
|
|
2290
1532
|
style: {
|
|
2291
1533
|
width,
|
|
@@ -2293,10 +1535,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2293
1535
|
},
|
|
2294
1536
|
onClick: () => inputRef.current?.focus(),
|
|
2295
1537
|
...handlers
|
|
2296
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
1538
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react3.default.createElement(SelectionOverlay, {
|
|
2297
1539
|
root: scrollerRef.current
|
|
2298
1540
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
2299
|
-
return columnRange.map(({
|
|
1541
|
+
return columnRange.map(({ column, left, width: width2 }) => {
|
|
2300
1542
|
const style = {
|
|
2301
1543
|
position: "absolute",
|
|
2302
1544
|
top,
|
|
@@ -2306,11 +1548,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2306
1548
|
};
|
|
2307
1549
|
const cell = {
|
|
2308
1550
|
row,
|
|
2309
|
-
|
|
1551
|
+
column
|
|
2310
1552
|
};
|
|
2311
|
-
const id2 = addressToA1Notation(cell);
|
|
2312
|
-
const idx = addressToIndex(
|
|
2313
|
-
const active = posEquals(cursor, cell);
|
|
1553
|
+
const id2 = (0, import_chunk_5KKJ4NPP.addressToA1Notation)(cell);
|
|
1554
|
+
const idx = model.addressToIndex(cell);
|
|
1555
|
+
const active = (0, import_chunk_5KKJ4NPP.posEquals)(cursor, cell);
|
|
2314
1556
|
if (active && editing) {
|
|
2315
1557
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
2316
1558
|
const handleClose = (value2) => {
|
|
@@ -2342,7 +1584,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2342
1584
|
inputRef.current?.focus();
|
|
2343
1585
|
setEditing(false);
|
|
2344
1586
|
};
|
|
2345
|
-
return /* @__PURE__ */
|
|
1587
|
+
return /* @__PURE__ */ import_react3.default.createElement(GridCellEditor, {
|
|
2346
1588
|
key: idx,
|
|
2347
1589
|
value,
|
|
2348
1590
|
style,
|
|
@@ -2350,7 +1592,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2350
1592
|
onClose: handleClose
|
|
2351
1593
|
});
|
|
2352
1594
|
}
|
|
2353
|
-
return /* @__PURE__ */
|
|
1595
|
+
return /* @__PURE__ */ import_react3.default.createElement(SheetCell, {
|
|
2354
1596
|
key: id2,
|
|
2355
1597
|
id: id2,
|
|
2356
1598
|
cell,
|
|
@@ -2362,7 +1604,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2362
1604
|
}
|
|
2363
1605
|
});
|
|
2364
1606
|
});
|
|
2365
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1607
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react3.default.createElement("input", {
|
|
2366
1608
|
ref: inputRef,
|
|
2367
1609
|
autoFocus: true,
|
|
2368
1610
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -2383,34 +1625,20 @@ var SelectionOverlay = ({ root }) => {
|
|
|
2383
1625
|
const b1 = getRelativeClientRect(root, c1);
|
|
2384
1626
|
const b2 = getRelativeClientRect(root, c2);
|
|
2385
1627
|
const bounds = getRectUnion(b1, b2);
|
|
2386
|
-
return /* @__PURE__ */
|
|
1628
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2387
1629
|
role: "none",
|
|
2388
1630
|
style: bounds,
|
|
2389
1631
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
2390
1632
|
});
|
|
2391
1633
|
};
|
|
2392
1634
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
2393
|
-
const { formatting, editing, setRange
|
|
1635
|
+
const { formatting, editing, setRange } = useSheetContext();
|
|
2394
1636
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
2395
|
-
|
|
2396
|
-
const decorationAddedClasses = (0, import_react2.useMemo)(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
2397
|
-
decorationsForCell
|
|
2398
|
-
]);
|
|
2399
|
-
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
2400
|
-
if (!decorate) {
|
|
2401
|
-
return children;
|
|
2402
|
-
}
|
|
2403
|
-
const DecoratorComponent = decorate;
|
|
2404
|
-
return /* @__PURE__ */ import_react2.default.createElement(DecoratorComponent, null, children);
|
|
2405
|
-
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2406
|
-
role: "none",
|
|
2407
|
-
className: (0, import_react_ui_theme.mx)("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
2408
|
-
}, value));
|
|
2409
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1637
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2410
1638
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
2411
1639
|
role: "cell",
|
|
2412
1640
|
style,
|
|
2413
|
-
className: (0,
|
|
1641
|
+
className: (0, import_react_ui_theme2.mx)("flex w-full h-full px-2 py-1 truncate items-center border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
2414
1642
|
"z-20",
|
|
2415
1643
|
fragments.cellSelected
|
|
2416
1644
|
], classNames),
|
|
@@ -2424,36 +1652,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
2424
1652
|
}
|
|
2425
1653
|
},
|
|
2426
1654
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
2427
|
-
},
|
|
1655
|
+
}, value);
|
|
2428
1656
|
};
|
|
2429
1657
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
2430
1658
|
const { model, range } = useSheetContext();
|
|
2431
|
-
const notifier = (0,
|
|
2432
|
-
(0,
|
|
1659
|
+
const notifier = (0, import_react3.useRef)();
|
|
1660
|
+
(0, import_react3.useEffect)(() => {
|
|
2433
1661
|
if (range) {
|
|
2434
|
-
notifier.current?.(rangeToA1Notation(range));
|
|
1662
|
+
notifier.current?.((0, import_chunk_5KKJ4NPP.rangeToA1Notation)(range));
|
|
2435
1663
|
}
|
|
2436
1664
|
}, [
|
|
2437
1665
|
range
|
|
2438
1666
|
]);
|
|
2439
|
-
const extension = (0,
|
|
1667
|
+
const extension = (0, import_react3.useMemo)(() => [
|
|
2440
1668
|
editorKeys({
|
|
2441
1669
|
onNav,
|
|
2442
1670
|
onClose
|
|
2443
1671
|
}),
|
|
2444
1672
|
sheetExtension({
|
|
2445
|
-
functions: model.
|
|
1673
|
+
functions: model.functions
|
|
2446
1674
|
}),
|
|
2447
1675
|
rangeExtension((fn) => notifier.current = fn)
|
|
2448
1676
|
], [
|
|
2449
1677
|
model
|
|
2450
1678
|
]);
|
|
2451
|
-
return /* @__PURE__ */
|
|
1679
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2452
1680
|
role: "cell",
|
|
2453
1681
|
style,
|
|
2454
|
-
className: (0,
|
|
1682
|
+
className: (0, import_react_ui_theme2.mx)("z-20 flex", fragments.cellSelected),
|
|
2455
1683
|
onClick: (ev) => ev.stopPropagation()
|
|
2456
|
-
}, /* @__PURE__ */
|
|
1684
|
+
}, /* @__PURE__ */ import_react3.default.createElement(CellEditor, {
|
|
2457
1685
|
autoFocus: true,
|
|
2458
1686
|
value,
|
|
2459
1687
|
extension
|
|
@@ -2466,30 +1694,30 @@ var SheetStatusBar = () => {
|
|
|
2466
1694
|
if (cursor) {
|
|
2467
1695
|
value = model.getCellValue(cursor);
|
|
2468
1696
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2469
|
-
value = model.
|
|
1697
|
+
value = model.mapFormulaBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
2470
1698
|
isFormula = true;
|
|
2471
1699
|
} else if (value != null) {
|
|
2472
1700
|
value = String(value);
|
|
2473
1701
|
}
|
|
2474
1702
|
}
|
|
2475
|
-
return /* @__PURE__ */
|
|
2476
|
-
className: (0,
|
|
2477
|
-
}, /* @__PURE__ */
|
|
1703
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1704
|
+
className: (0, import_react_ui_theme2.mx)("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
1705
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2478
1706
|
className: "flex gap-4 items-center"
|
|
2479
|
-
}, /* @__PURE__ */
|
|
1707
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2480
1708
|
className: "flex w-16 items-center font-mono"
|
|
2481
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */
|
|
1709
|
+
}, range && (0, import_chunk_5KKJ4NPP.rangeToA1Notation)(range) || cursor && (0, import_chunk_5KKJ4NPP.addressToA1Notation)(cursor)), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2482
1710
|
className: "flex gap-2 items-center"
|
|
2483
|
-
}, /* @__PURE__ */
|
|
2484
|
-
className: (0,
|
|
2485
|
-
}), /* @__PURE__ */
|
|
1711
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_react2.Function, {
|
|
1712
|
+
className: (0, import_react_ui_theme2.mx)("text-greenText", isFormula ? "visible" : "invisible")
|
|
1713
|
+
}), /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
2486
1714
|
className: "font-mono"
|
|
2487
1715
|
}, value))));
|
|
2488
1716
|
};
|
|
2489
1717
|
var SheetDebug = () => {
|
|
2490
1718
|
const { model, cursor, range } = useSheetContext();
|
|
2491
|
-
const [, forceUpdate] = (0,
|
|
2492
|
-
(0,
|
|
1719
|
+
const [, forceUpdate] = (0, import_react3.useState)({});
|
|
1720
|
+
(0, import_react3.useEffect)(() => {
|
|
2493
1721
|
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
2494
1722
|
const handleUpdate = () => forceUpdate({});
|
|
2495
1723
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -2500,9 +1728,9 @@ var SheetDebug = () => {
|
|
|
2500
1728
|
}, [
|
|
2501
1729
|
model
|
|
2502
1730
|
]);
|
|
2503
|
-
return /* @__PURE__ */
|
|
2504
|
-
className: (0,
|
|
2505
|
-
}, /* @__PURE__ */
|
|
1731
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1732
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute right-0 top-20 bottom-20 w-[30rem] overflow-auto scrollbar-thin", "border border-gridLine text-xs bg-neutral-50 dark:bg-black text-cyan-500 font-mono p-1 opacity-80")
|
|
1733
|
+
}, /* @__PURE__ */ import_react3.default.createElement("pre", {
|
|
2506
1734
|
className: "whitespace-pre-wrap"
|
|
2507
1735
|
}, JSON.stringify({
|
|
2508
1736
|
cursor,
|
|
@@ -2523,14 +1751,15 @@ var Sheet = {
|
|
|
2523
1751
|
StatusBar: SheetStatusBar,
|
|
2524
1752
|
Debug: SheetDebug
|
|
2525
1753
|
};
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
}
|
|
2536
|
-
|
|
1754
|
+
var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
|
|
1755
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
1756
|
+
role: "none",
|
|
1757
|
+
className: (0, import_react_ui_theme.mx)("flex", role === "article" && "row-span-2", role === "section" && "aspect-square border-y border-is border-separator")
|
|
1758
|
+
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Root, {
|
|
1759
|
+
sheet,
|
|
1760
|
+
space,
|
|
1761
|
+
remoteFunctionUrl
|
|
1762
|
+
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Main, null)));
|
|
1763
|
+
};
|
|
1764
|
+
var SheetContainer_default = SheetContainer;
|
|
1765
|
+
//# sourceMappingURL=SheetContainer-AXQV3ZT5.cjs.map
|