@dxos/plugin-sheet 0.6.11 → 0.6.12-main.15a606f
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/SheetContainer-V4GCCZTX.mjs +261 -0
- package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-6ZMQVB4Z.mjs} +359 -671
- package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FUAGSXA4.mjs → chunk-T3NJFTD4.mjs} +8 -15
- package/dist/lib/browser/chunk-T3NJFTD4.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-U4H5D34A.mjs → chunk-U2JHW3L6.mjs} +1020 -240
- package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +7 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs +21 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +68 -56
- 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/types.mjs +4 -6
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs +279 -0
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-DD6FIXWC.cjs} +360 -667
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-AXQV3ZT5.cjs → chunk-OTTD7FBK.cjs} +1050 -279
- package/dist/lib/node/chunk-OTTD7FBK.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-Q3HBHPRL.cjs} +12 -20
- package/dist/lib/node/chunk-Q3HBHPRL.cjs.map +7 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs +43 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs.map +7 -0
- package/dist/lib/node/index.cjs +83 -64
- 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/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs +262 -0
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs +2553 -0
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs +76 -0
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs +2925 -0
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs +17 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs +22 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +261 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +21 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- 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/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +6 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- 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 +5 -6
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/decorations.d.ts +24 -0
- package/dist/types/src/components/Sheet/decorations.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 +6 -5
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts +2 -0
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +2 -3
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +19 -3
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +18 -13
- 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/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +43 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +5 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph}/async-function.d.ts +1 -1
- package/dist/types/src/graph/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +81 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +19 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph/custom.d.ts → graph/custom-function.d.ts} +1 -1
- package/dist/types/src/graph/custom-function.d.ts.map +1 -0
- package/dist/types/src/graph/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +4 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +9 -64
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +9 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +83 -3
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +48 -41
- package/src/SheetPlugin.tsx +43 -70
- package/src/components/CellEditor/CellEditor.stories.tsx +4 -3
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +4 -5
- package/src/components/CellEditor/extension.ts +1 -3
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +35 -0
- package/src/components/GridSheet/GridSheet.tsx +153 -0
- package/src/components/GridSheet/util.ts +89 -0
- package/src/components/Sheet/Sheet.stories.tsx +45 -82
- package/src/components/Sheet/Sheet.tsx +57 -18
- package/src/components/Sheet/decorations.ts +62 -0
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +16 -78
- package/src/components/Sheet/threads.tsx +205 -0
- package/src/components/SheetContainer.tsx +73 -19
- package/src/components/Toolbar/Toolbar.tsx +53 -12
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/{model → defs}/types.ts +23 -14
- package/src/defs/util.ts +135 -0
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +98 -0
- package/src/extensions/index.ts +5 -0
- package/src/{components/ComputeGraph → graph}/async-function.ts +3 -1
- package/src/graph/compute-graph.browser.test.ts +104 -0
- package/src/graph/compute-graph.stories.tsx +92 -0
- package/src/graph/compute-graph.ts +290 -0
- package/src/graph/compute-node.ts +51 -0
- package/src/{components/ComputeGraph/custom.ts → graph/custom-function.ts} +2 -6
- package/src/{components/ComputeGraph → graph}/edge-function.ts +2 -1
- package/src/graph/hyperformula.test.ts +15 -0
- package/src/graph/index.ts +7 -0
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useComputeGraph.ts +20 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +43 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -3
- package/src/model/sheet-model.ts +399 -0
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +66 -0
- package/src/translations.ts +6 -1
- package/src/types.ts +30 -5
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/ComputeGraph → graph}/edge-function.d.ts +0 -0
- /package/src/{model/functions.ts → graph/function-defs.ts} +0 -0
|
@@ -26,38 +26,63 @@ 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
|
-
|
|
29
|
+
var chunk_OTTD7FBK_exports = {};
|
|
30
|
+
__export(chunk_OTTD7FBK_exports, {
|
|
31
|
+
ComputeGraphContextProvider: () => ComputeGraphContextProvider,
|
|
32
|
+
Sheet: () => Sheet,
|
|
33
|
+
SheetContainer: () => SheetContainer,
|
|
34
|
+
addressToIndex: () => addressToIndex,
|
|
35
|
+
compareIndexPositions: () => compareIndexPositions,
|
|
36
|
+
createSheet: () => createSheet,
|
|
37
|
+
useSheetContext: () => useSheetContext
|
|
32
38
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
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");
|
|
39
|
+
module.exports = __toCommonJS(chunk_OTTD7FBK_exports);
|
|
40
|
+
var import_chunk_Q3HBHPRL = require("./chunk-Q3HBHPRL.cjs");
|
|
41
|
+
var import_chunk_BNARJ5GM = require("./chunk-BNARJ5GM.cjs");
|
|
42
|
+
var import_chunk_DD6FIXWC = require("./chunk-DD6FIXWC.cjs");
|
|
40
43
|
var import_core = require("@dnd-kit/core");
|
|
41
44
|
var import_modifiers = require("@dnd-kit/modifiers");
|
|
42
45
|
var import_utilities = require("@dnd-kit/utilities");
|
|
43
|
-
var
|
|
46
|
+
var import_react = require("@phosphor-icons/react");
|
|
44
47
|
var import_re_resizable = require("re-resizable");
|
|
45
|
-
var
|
|
48
|
+
var import_react2 = __toESM(require("react"));
|
|
46
49
|
var import_react_dom = require("react-dom");
|
|
47
50
|
var import_react_resize_detector = require("react-resize-detector");
|
|
48
51
|
var import_async = require("@dxos/async");
|
|
49
52
|
var import_echo = require("@dxos/client/echo");
|
|
50
53
|
var import_log = require("@dxos/log");
|
|
51
54
|
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var import_react5 = require("react");
|
|
55
|
-
var import_react6 = __toESM(require("react"));
|
|
55
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
56
|
+
var import_react3 = require("react");
|
|
56
57
|
var import_invariant = require("@dxos/invariant");
|
|
57
|
-
var
|
|
58
|
-
var
|
|
58
|
+
var import_crypto = require("@dxos/crypto");
|
|
59
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
60
|
+
var import_react4 = require("react");
|
|
61
|
+
var import_react5 = __toESM(require("react"));
|
|
62
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
63
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
64
|
+
var import_react6 = require("react");
|
|
65
|
+
var import_debug = require("@dxos/debug");
|
|
66
|
+
var import_react_hooks = require("@dxos/react-hooks");
|
|
59
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");
|
|
81
|
+
var import_echo2 = require("@dxos/react-client/echo");
|
|
60
82
|
var import_react_ui = require("@dxos/react-ui");
|
|
83
|
+
var import_view = require("@codemirror/view");
|
|
84
|
+
var import_react12 = __toESM(require("react"));
|
|
85
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
61
86
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
62
87
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
63
88
|
var import_language = require("@codemirror/language");
|
|
@@ -65,7 +90,156 @@ var import_state = require("@codemirror/state");
|
|
|
65
90
|
var import_view2 = require("@codemirror/view");
|
|
66
91
|
var import_highlight = require("@lezer/highlight");
|
|
67
92
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
68
|
-
var
|
|
93
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
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
|
+
};
|
|
69
243
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
70
244
|
var axisHeight = 34;
|
|
71
245
|
var minWidth = 40;
|
|
@@ -76,8 +250,8 @@ var defaultWidth = 200;
|
|
|
76
250
|
var defaultHeight = minHeight;
|
|
77
251
|
var CELL_DATA_KEY = "cell";
|
|
78
252
|
var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) => {
|
|
79
|
-
const [rowPositions, setRowPositions] = (0,
|
|
80
|
-
(0,
|
|
253
|
+
const [rowPositions, setRowPositions] = (0, import_react3.useState)([]);
|
|
254
|
+
(0, import_react3.useEffect)(() => {
|
|
81
255
|
if (!rowSizes) {
|
|
82
256
|
return;
|
|
83
257
|
}
|
|
@@ -96,8 +270,8 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
96
270
|
rows,
|
|
97
271
|
rowSizes
|
|
98
272
|
]);
|
|
99
|
-
const [columnPositions, setColumnPositions] = (0,
|
|
100
|
-
(0,
|
|
273
|
+
const [columnPositions, setColumnPositions] = (0, import_react3.useState)([]);
|
|
274
|
+
(0, import_react3.useEffect)(() => {
|
|
101
275
|
if (!columns) {
|
|
102
276
|
return;
|
|
103
277
|
}
|
|
@@ -107,7 +281,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
107
281
|
const left = x;
|
|
108
282
|
x += width2 - 1;
|
|
109
283
|
return {
|
|
110
|
-
|
|
284
|
+
col: i,
|
|
111
285
|
left,
|
|
112
286
|
width: width2
|
|
113
287
|
};
|
|
@@ -118,11 +292,11 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
118
292
|
]);
|
|
119
293
|
const height = rowPositions.length ? rowPositions[rowPositions.length - 1].top + rowPositions[rowPositions.length - 1].height : 0;
|
|
120
294
|
const width = columnPositions.length ? columnPositions[columnPositions.length - 1].left + columnPositions[columnPositions.length - 1].width : 0;
|
|
121
|
-
const [{ rowRange, columnRange }, setWindow] = (0,
|
|
295
|
+
const [{ rowRange, columnRange }, setWindow] = (0, import_react3.useState)({
|
|
122
296
|
rowRange: [],
|
|
123
297
|
columnRange: []
|
|
124
298
|
});
|
|
125
|
-
(0,
|
|
299
|
+
(0, import_react3.useEffect)(() => {
|
|
126
300
|
const handleScroll = () => {
|
|
127
301
|
if (!scroller) {
|
|
128
302
|
return;
|
|
@@ -182,12 +356,12 @@ var getCellAtPointer = (event) => {
|
|
|
182
356
|
if (root) {
|
|
183
357
|
const value = root.dataset[CELL_DATA_KEY];
|
|
184
358
|
if (value) {
|
|
185
|
-
return
|
|
359
|
+
return addressFromA1Notation(value);
|
|
186
360
|
}
|
|
187
361
|
}
|
|
188
362
|
};
|
|
189
363
|
var getCellElement = (root, cell) => {
|
|
190
|
-
const pos =
|
|
364
|
+
const pos = addressToA1Notation(cell);
|
|
191
365
|
return root.querySelector(`[data-${CELL_DATA_KEY}="${pos}"]`);
|
|
192
366
|
};
|
|
193
367
|
var handleNav = (ev, cursor, range, size) => {
|
|
@@ -209,14 +383,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
209
383
|
break;
|
|
210
384
|
}
|
|
211
385
|
case "ArrowLeft": {
|
|
212
|
-
if (opposite.
|
|
213
|
-
opposite.
|
|
386
|
+
if (opposite.col > 0) {
|
|
387
|
+
opposite.col -= 1;
|
|
214
388
|
}
|
|
215
389
|
break;
|
|
216
390
|
}
|
|
217
391
|
case "ArrowRight": {
|
|
218
|
-
if (opposite.
|
|
219
|
-
opposite.
|
|
392
|
+
if (opposite.col < size.numCols - 1) {
|
|
393
|
+
opposite.col += 1;
|
|
220
394
|
}
|
|
221
395
|
break;
|
|
222
396
|
}
|
|
@@ -234,18 +408,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
234
408
|
cursor: next
|
|
235
409
|
};
|
|
236
410
|
};
|
|
237
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
411
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
238
412
|
switch (ev.key) {
|
|
239
413
|
case "ArrowUp":
|
|
240
414
|
if (cursor === void 0) {
|
|
241
415
|
return {
|
|
242
416
|
row: 0,
|
|
243
|
-
|
|
417
|
+
col: 0
|
|
244
418
|
};
|
|
245
419
|
} else if (cursor.row > 0) {
|
|
246
420
|
return {
|
|
247
421
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
248
|
-
|
|
422
|
+
col: cursor.col
|
|
249
423
|
};
|
|
250
424
|
}
|
|
251
425
|
break;
|
|
@@ -253,12 +427,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
253
427
|
if (cursor === void 0) {
|
|
254
428
|
return {
|
|
255
429
|
row: 0,
|
|
256
|
-
|
|
430
|
+
col: 0
|
|
257
431
|
};
|
|
258
432
|
} else if (cursor.row < numRows - 1) {
|
|
259
433
|
return {
|
|
260
434
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
261
|
-
|
|
435
|
+
col: cursor.col
|
|
262
436
|
};
|
|
263
437
|
}
|
|
264
438
|
break;
|
|
@@ -266,12 +440,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
266
440
|
if (cursor === void 0) {
|
|
267
441
|
return {
|
|
268
442
|
row: 0,
|
|
269
|
-
|
|
443
|
+
col: 0
|
|
270
444
|
};
|
|
271
|
-
} else if (cursor.
|
|
445
|
+
} else if (cursor.col > 0) {
|
|
272
446
|
return {
|
|
273
447
|
row: cursor.row,
|
|
274
|
-
|
|
448
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
275
449
|
};
|
|
276
450
|
}
|
|
277
451
|
break;
|
|
@@ -279,30 +453,30 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
279
453
|
if (cursor === void 0) {
|
|
280
454
|
return {
|
|
281
455
|
row: 0,
|
|
282
|
-
|
|
456
|
+
col: 0
|
|
283
457
|
};
|
|
284
|
-
} else if (cursor.
|
|
458
|
+
} else if (cursor.col < numCols - 1) {
|
|
285
459
|
return {
|
|
286
460
|
row: cursor.row,
|
|
287
|
-
|
|
461
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
288
462
|
};
|
|
289
463
|
}
|
|
290
464
|
break;
|
|
291
465
|
case "Home":
|
|
292
466
|
return {
|
|
293
467
|
row: 0,
|
|
294
|
-
|
|
468
|
+
col: 0
|
|
295
469
|
};
|
|
296
470
|
case "End":
|
|
297
471
|
return {
|
|
298
472
|
row: numRows - 1,
|
|
299
|
-
|
|
473
|
+
col: numCols - 1
|
|
300
474
|
};
|
|
301
475
|
}
|
|
302
476
|
};
|
|
303
477
|
var useRangeSelect = (cb) => {
|
|
304
|
-
const [from, setFrom] = (0,
|
|
305
|
-
const [to, setTo] = (0,
|
|
478
|
+
const [from, setFrom] = (0, import_react4.useState)();
|
|
479
|
+
const [to, setTo] = (0, import_react4.useState)();
|
|
306
480
|
const onMouseDown = (ev) => {
|
|
307
481
|
const current = getCellAtPointer(ev);
|
|
308
482
|
setFrom(current);
|
|
@@ -315,7 +489,7 @@ var useRangeSelect = (cb) => {
|
|
|
315
489
|
const onMouseMove = (ev) => {
|
|
316
490
|
if (from) {
|
|
317
491
|
let current = getCellAtPointer(ev);
|
|
318
|
-
if (
|
|
492
|
+
if (posEquals(current, from)) {
|
|
319
493
|
current = void 0;
|
|
320
494
|
}
|
|
321
495
|
setTo(current);
|
|
@@ -328,7 +502,7 @@ var useRangeSelect = (cb) => {
|
|
|
328
502
|
const onMouseUp = (ev) => {
|
|
329
503
|
if (from) {
|
|
330
504
|
let current = getCellAtPointer(ev);
|
|
331
|
-
if (
|
|
505
|
+
if (posEquals(current, from)) {
|
|
332
506
|
current = void 0;
|
|
333
507
|
}
|
|
334
508
|
setFrom(void 0);
|
|
@@ -351,27 +525,79 @@ var useRangeSelect = (cb) => {
|
|
|
351
525
|
}
|
|
352
526
|
};
|
|
353
527
|
};
|
|
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
|
+
};
|
|
354
580
|
var FormattingModel = class {
|
|
355
|
-
constructor(
|
|
356
|
-
this.
|
|
581
|
+
constructor(_model) {
|
|
582
|
+
this._model = _model;
|
|
357
583
|
}
|
|
358
584
|
/**
|
|
359
585
|
* Get formatted string value and className for cell.
|
|
360
586
|
*/
|
|
361
587
|
getFormatting(cell) {
|
|
362
|
-
const value = this.
|
|
588
|
+
const value = this._model.getValue(cell);
|
|
363
589
|
if (value === void 0 || value === null) {
|
|
364
590
|
return {};
|
|
365
591
|
}
|
|
366
592
|
const locales = void 0;
|
|
367
|
-
const idx = this.
|
|
368
|
-
let formatting = this.
|
|
593
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
594
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
369
595
|
const classNames = [
|
|
370
596
|
...formatting?.classNames ?? []
|
|
371
597
|
];
|
|
372
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
373
|
-
const range = this.
|
|
374
|
-
if (
|
|
598
|
+
for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
|
|
599
|
+
const range = rangeFromIndex(this._model.sheet, idx2);
|
|
600
|
+
if (inRange(range, cell)) {
|
|
375
601
|
if (_formatting.classNames) {
|
|
376
602
|
classNames.push(..._formatting.classNames);
|
|
377
603
|
}
|
|
@@ -381,9 +607,9 @@ var FormattingModel = class {
|
|
|
381
607
|
}
|
|
382
608
|
}
|
|
383
609
|
const defaultNumber = "justify-end font-mono";
|
|
384
|
-
const type = formatting?.type ?? this.
|
|
610
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
385
611
|
switch (type) {
|
|
386
|
-
case
|
|
612
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Boolean: {
|
|
387
613
|
return {
|
|
388
614
|
value: value.toLocaleString().toUpperCase(),
|
|
389
615
|
classNames: [
|
|
@@ -395,7 +621,7 @@ var FormattingModel = class {
|
|
|
395
621
|
//
|
|
396
622
|
// Numbers.
|
|
397
623
|
//
|
|
398
|
-
case
|
|
624
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Number: {
|
|
399
625
|
return {
|
|
400
626
|
value: value.toLocaleString(locales),
|
|
401
627
|
classNames: [
|
|
@@ -404,7 +630,7 @@ var FormattingModel = class {
|
|
|
404
630
|
]
|
|
405
631
|
};
|
|
406
632
|
}
|
|
407
|
-
case
|
|
633
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Percent: {
|
|
408
634
|
return {
|
|
409
635
|
value: value * 100 + "%",
|
|
410
636
|
classNames: [
|
|
@@ -413,7 +639,7 @@ var FormattingModel = class {
|
|
|
413
639
|
]
|
|
414
640
|
};
|
|
415
641
|
}
|
|
416
|
-
case
|
|
642
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Currency: {
|
|
417
643
|
return {
|
|
418
644
|
value: value.toLocaleString(locales, {
|
|
419
645
|
style: "currency",
|
|
@@ -430,22 +656,22 @@ var FormattingModel = class {
|
|
|
430
656
|
//
|
|
431
657
|
// Dates.
|
|
432
658
|
//
|
|
433
|
-
case
|
|
434
|
-
const date = this.
|
|
659
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.DateTime: {
|
|
660
|
+
const date = this._model.toLocalDate(value);
|
|
435
661
|
return {
|
|
436
662
|
value: date.toLocaleString(locales),
|
|
437
663
|
classNames
|
|
438
664
|
};
|
|
439
665
|
}
|
|
440
|
-
case
|
|
441
|
-
const date = this.
|
|
666
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Date: {
|
|
667
|
+
const date = this._model.toLocalDate(value);
|
|
442
668
|
return {
|
|
443
669
|
value: date.toLocaleDateString(locales),
|
|
444
670
|
classNames
|
|
445
671
|
};
|
|
446
672
|
}
|
|
447
|
-
case
|
|
448
|
-
const date = this.
|
|
673
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Time: {
|
|
674
|
+
const date = this._model.toLocalDate(value);
|
|
449
675
|
return {
|
|
450
676
|
value: date.toLocaleTimeString(locales),
|
|
451
677
|
classNames
|
|
@@ -460,83 +686,414 @@ var FormattingModel = class {
|
|
|
460
686
|
}
|
|
461
687
|
}
|
|
462
688
|
};
|
|
463
|
-
var
|
|
464
|
-
var
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
689
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
690
|
+
var typeMap = {
|
|
691
|
+
BOOLEAN: import_chunk_Q3HBHPRL.ValueTypeEnum.Boolean,
|
|
692
|
+
NUMBER_RAW: import_chunk_Q3HBHPRL.ValueTypeEnum.Number,
|
|
693
|
+
NUMBER_PERCENT: import_chunk_Q3HBHPRL.ValueTypeEnum.Percent,
|
|
694
|
+
NUMBER_CURRENCY: import_chunk_Q3HBHPRL.ValueTypeEnum.Currency,
|
|
695
|
+
NUMBER_DATETIME: import_chunk_Q3HBHPRL.ValueTypeEnum.DateTime,
|
|
696
|
+
NUMBER_DATE: import_chunk_Q3HBHPRL.ValueTypeEnum.Date,
|
|
697
|
+
NUMBER_TIME: import_chunk_Q3HBHPRL.ValueTypeEnum.Time
|
|
698
|
+
};
|
|
699
|
+
var getTopLeft = (range) => {
|
|
700
|
+
const to = range.to ?? range.from;
|
|
701
|
+
return {
|
|
702
|
+
row: Math.min(range.from.row, to.row),
|
|
703
|
+
col: Math.min(range.from.col, to.col)
|
|
704
|
+
};
|
|
478
705
|
};
|
|
479
|
-
var
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
706
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
707
|
+
sheet,
|
|
708
|
+
row: cell.row,
|
|
709
|
+
col: cell.col
|
|
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;
|
|
483
865
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return `${(0, import_echo2.fullyQualifiedId)(fn)}(${args})`;
|
|
866
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
867
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
487
868
|
} else {
|
|
488
|
-
return
|
|
869
|
+
return String(value);
|
|
489
870
|
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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();
|
|
497
902
|
}
|
|
498
|
-
|
|
499
|
-
if (
|
|
500
|
-
|
|
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;
|
|
907
|
+
}
|
|
908
|
+
if (cell.col >= this._sheet.columns.length) {
|
|
909
|
+
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
910
|
+
refresh = true;
|
|
911
|
+
}
|
|
912
|
+
if (refresh) {
|
|
913
|
+
this.reset();
|
|
914
|
+
}
|
|
915
|
+
this._node.hf.setCellContents({
|
|
916
|
+
sheet: this._node.sheetId,
|
|
917
|
+
row: cell.row,
|
|
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];
|
|
501
927
|
} else {
|
|
502
|
-
|
|
928
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
929
|
+
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
930
|
+
}
|
|
931
|
+
this._sheet.cells[idx] = {
|
|
932
|
+
value
|
|
933
|
+
};
|
|
503
934
|
}
|
|
504
|
-
}
|
|
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
|
+
]);
|
|
505
1044
|
};
|
|
506
|
-
var
|
|
507
|
-
const graph =
|
|
508
|
-
const [
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
1045
|
+
var useSheetModel = (space, sheet, { readonly } = {}) => {
|
|
1046
|
+
const graph = useComputeGraph(space);
|
|
1047
|
+
const [model, setModel] = (0, import_react10.useState)();
|
|
1048
|
+
(0, import_react10.useEffect)(() => {
|
|
1049
|
+
if (!space || !graph || !sheet) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
513
1052
|
let model2;
|
|
514
|
-
let formatting2;
|
|
515
1053
|
const t = setTimeout(async () => {
|
|
516
|
-
model2 = new
|
|
517
|
-
readonly
|
|
518
|
-
mapFormulaBindingToId,
|
|
519
|
-
mapFormulaBindingFromId
|
|
1054
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1055
|
+
readonly
|
|
520
1056
|
});
|
|
521
|
-
await model2.
|
|
522
|
-
|
|
523
|
-
setModels([
|
|
524
|
-
model2,
|
|
525
|
-
formatting2
|
|
526
|
-
]);
|
|
1057
|
+
await model2.open();
|
|
1058
|
+
setModel(model2);
|
|
527
1059
|
});
|
|
528
1060
|
return () => {
|
|
529
1061
|
clearTimeout(t);
|
|
530
|
-
void model2?.
|
|
1062
|
+
void model2?.close();
|
|
531
1063
|
};
|
|
532
1064
|
}, [
|
|
1065
|
+
space,
|
|
1066
|
+
sheet,
|
|
533
1067
|
graph,
|
|
534
1068
|
readonly
|
|
535
1069
|
]);
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
1070
|
+
return model;
|
|
1071
|
+
};
|
|
1072
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
1073
|
+
var SheetContext = /* @__PURE__ */ (0, import_react5.createContext)(null);
|
|
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, {
|
|
540
1097
|
value: {
|
|
541
1098
|
model,
|
|
542
1099
|
formatting,
|
|
@@ -547,10 +1104,168 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
547
1104
|
editing,
|
|
548
1105
|
setEditing,
|
|
549
1106
|
// TODO(burdon): Change to event.
|
|
550
|
-
onInfo
|
|
1107
|
+
onInfo,
|
|
1108
|
+
decorations
|
|
551
1109
|
}
|
|
552
1110
|
}, children);
|
|
553
1111
|
};
|
|
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
|
+
};
|
|
554
1269
|
var getRelativeClientRect = (root, element) => {
|
|
555
1270
|
const rootRect = root.getBoundingClientRect();
|
|
556
1271
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -627,21 +1342,61 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
627
1342
|
{
|
|
628
1343
|
key: "Enter",
|
|
629
1344
|
run: (editor) => {
|
|
630
|
-
onClose(editor.state.doc.toString()
|
|
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
|
+
});
|
|
631
1371
|
return true;
|
|
632
1372
|
}
|
|
633
1373
|
},
|
|
634
1374
|
{
|
|
635
1375
|
key: "Escape",
|
|
636
1376
|
run: () => {
|
|
637
|
-
onClose(void 0
|
|
1377
|
+
onClose(void 0, {
|
|
1378
|
+
key: "Escape"
|
|
1379
|
+
});
|
|
638
1380
|
return true;
|
|
639
1381
|
}
|
|
640
1382
|
}
|
|
641
1383
|
]);
|
|
642
1384
|
};
|
|
643
|
-
var
|
|
644
|
-
|
|
1385
|
+
var editorVariants = {
|
|
1386
|
+
// TODO(thure): remove when legacy is no longer used.
|
|
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)();
|
|
645
1400
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
646
1401
|
return {
|
|
647
1402
|
autoFocus,
|
|
@@ -667,21 +1422,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
667
1422
|
themeMode,
|
|
668
1423
|
slots: {
|
|
669
1424
|
editor: {
|
|
670
|
-
className:
|
|
1425
|
+
className: editorVariants[variant].editor
|
|
671
1426
|
},
|
|
672
1427
|
content: {
|
|
673
|
-
className:
|
|
1428
|
+
className: editorVariants[variant].content
|
|
674
1429
|
}
|
|
675
1430
|
}
|
|
676
1431
|
})
|
|
677
1432
|
]
|
|
678
1433
|
};
|
|
679
1434
|
}, [
|
|
680
|
-
extension
|
|
1435
|
+
extension,
|
|
1436
|
+
autoFocus,
|
|
1437
|
+
value,
|
|
1438
|
+
variant,
|
|
1439
|
+
onBlur
|
|
681
1440
|
]);
|
|
682
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
683
1442
|
ref: parentRef,
|
|
684
|
-
className:
|
|
1443
|
+
className: editorVariants[variant].root,
|
|
1444
|
+
style: box,
|
|
1445
|
+
...gridId && {
|
|
1446
|
+
"data-grid": gridId
|
|
1447
|
+
}
|
|
685
1448
|
});
|
|
686
1449
|
};
|
|
687
1450
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -794,13 +1557,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
794
1557
|
// NOTE: Useful for debugging.
|
|
795
1558
|
closeOnBlur: false,
|
|
796
1559
|
icons: false,
|
|
797
|
-
tooltipClass: () => (0,
|
|
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
|
-
)
|
|
1560
|
+
tooltipClass: () => (0, import_react_ui_theme2.mx)("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
|
|
804
1561
|
}),
|
|
805
1562
|
import_view2.keymap.of([
|
|
806
1563
|
{
|
|
@@ -887,7 +1644,7 @@ var visitTree = (node, callback) => {
|
|
|
887
1644
|
}
|
|
888
1645
|
return false;
|
|
889
1646
|
};
|
|
890
|
-
var
|
|
1647
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
891
1648
|
var fragments = {
|
|
892
1649
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
893
1650
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -895,18 +1652,19 @@ var fragments = {
|
|
|
895
1652
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
896
1653
|
};
|
|
897
1654
|
var SheetRoot = ({ children, ...props }) => {
|
|
898
|
-
return /* @__PURE__ */
|
|
1655
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContextProvider, props, children);
|
|
899
1656
|
};
|
|
900
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
1657
|
+
var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
901
1658
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
902
1659
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
903
|
-
|
|
1660
|
+
useThreads();
|
|
1661
|
+
const [rows, setRows] = (0, import_react2.useState)([
|
|
904
1662
|
...model.sheet.rows
|
|
905
1663
|
]);
|
|
906
|
-
const [columns, setColumns] = (0,
|
|
1664
|
+
const [columns, setColumns] = (0, import_react2.useState)([
|
|
907
1665
|
...model.sheet.columns
|
|
908
1666
|
]);
|
|
909
|
-
(0,
|
|
1667
|
+
(0, import_react2.useEffect)(() => {
|
|
910
1668
|
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
911
1669
|
"rows"
|
|
912
1670
|
]);
|
|
@@ -931,37 +1689,37 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
931
1689
|
}, [
|
|
932
1690
|
model
|
|
933
1691
|
]);
|
|
934
|
-
(0,
|
|
1692
|
+
(0, import_react2.useEffect)(() => {
|
|
935
1693
|
model.reset();
|
|
936
1694
|
}, [
|
|
937
1695
|
rows,
|
|
938
1696
|
columns
|
|
939
1697
|
]);
|
|
940
1698
|
const handleMoveRows = (from, to, num = 1) => {
|
|
941
|
-
const cursorIdx = cursor ? model.
|
|
1699
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
942
1700
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
943
1701
|
model.sheet.rows.splice(to, 0, rows2);
|
|
944
1702
|
if (cursorIdx) {
|
|
945
|
-
setCursor(model.
|
|
1703
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
946
1704
|
}
|
|
947
1705
|
setRows([
|
|
948
1706
|
...model.sheet.rows
|
|
949
1707
|
]);
|
|
950
1708
|
};
|
|
951
1709
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
952
|
-
const cursorIdx = cursor ? model.
|
|
1710
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
953
1711
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
954
1712
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
955
1713
|
if (cursorIdx) {
|
|
956
|
-
setCursor(model.
|
|
1714
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
957
1715
|
}
|
|
958
1716
|
setColumns([
|
|
959
1717
|
...model.sheet.columns
|
|
960
1718
|
]);
|
|
961
1719
|
};
|
|
962
|
-
const [rowSizes, setRowSizes] = (0,
|
|
963
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
964
|
-
(0,
|
|
1720
|
+
const [rowSizes, setRowSizes] = (0, import_react2.useState)();
|
|
1721
|
+
const [columnSizes, setColumnSizes] = (0, import_react2.useState)();
|
|
1722
|
+
(0, import_react2.useEffect)(() => {
|
|
965
1723
|
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
966
1724
|
"rowMeta"
|
|
967
1725
|
]);
|
|
@@ -1010,54 +1768,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1010
1768
|
}));
|
|
1011
1769
|
}
|
|
1012
1770
|
};
|
|
1013
|
-
return /* @__PURE__ */
|
|
1771
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1014
1772
|
role: "none",
|
|
1015
|
-
className: (0,
|
|
1016
|
-
}, /* @__PURE__ */
|
|
1773
|
+
className: (0, import_react_ui_theme.mx)("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1774
|
+
}, /* @__PURE__ */ import_react2.default.createElement(GridCorner, {
|
|
1017
1775
|
onClick: () => {
|
|
1018
1776
|
setCursor(void 0);
|
|
1019
1777
|
setRange(void 0);
|
|
1020
1778
|
setEditing(false);
|
|
1021
1779
|
}
|
|
1022
|
-
}), /* @__PURE__ */
|
|
1780
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetColumns, {
|
|
1023
1781
|
ref: columnsRef,
|
|
1024
1782
|
columns,
|
|
1025
1783
|
sizes: columnSizes,
|
|
1026
|
-
selected: cursor?.
|
|
1027
|
-
onSelect: (
|
|
1784
|
+
selected: cursor?.col,
|
|
1785
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1028
1786
|
row: -1,
|
|
1029
|
-
|
|
1787
|
+
col
|
|
1030
1788
|
}),
|
|
1031
1789
|
onResize: handleResizeColumn,
|
|
1032
1790
|
onMove: handleMoveColumns
|
|
1033
|
-
}), /* @__PURE__ */
|
|
1791
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetRows, {
|
|
1034
1792
|
ref: rowsRef,
|
|
1035
1793
|
rows,
|
|
1036
1794
|
sizes: rowSizes,
|
|
1037
1795
|
selected: cursor?.row,
|
|
1038
1796
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1039
1797
|
row,
|
|
1040
|
-
|
|
1798
|
+
col: -1
|
|
1041
1799
|
}),
|
|
1042
1800
|
onResize: handleResizeRow,
|
|
1043
1801
|
onMove: handleMoveRows
|
|
1044
|
-
}), /* @__PURE__ */
|
|
1802
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetGrid, {
|
|
1045
1803
|
ref: contentRef,
|
|
1046
1804
|
size: {
|
|
1047
1805
|
numRows: numRows ?? rows.length,
|
|
1048
|
-
|
|
1806
|
+
numCols: numCols ?? columns.length
|
|
1049
1807
|
},
|
|
1050
1808
|
rows,
|
|
1051
1809
|
columns,
|
|
1052
1810
|
rowSizes,
|
|
1053
1811
|
columnSizes
|
|
1054
|
-
}), /* @__PURE__ */
|
|
1812
|
+
}), /* @__PURE__ */ import_react2.default.createElement(GridCorner, null), /* @__PURE__ */ import_react2.default.createElement(SheetStatusBar, null));
|
|
1055
1813
|
});
|
|
1056
1814
|
var useScrollHandlers = () => {
|
|
1057
|
-
const rowsRef = (0,
|
|
1058
|
-
const columnsRef = (0,
|
|
1059
|
-
const contentRef = (0,
|
|
1060
|
-
(0,
|
|
1815
|
+
const rowsRef = (0, import_react2.useRef)(null);
|
|
1816
|
+
const columnsRef = (0, import_react2.useRef)(null);
|
|
1817
|
+
const contentRef = (0, import_react2.useRef)(null);
|
|
1818
|
+
(0, import_react2.useEffect)(() => {
|
|
1061
1819
|
const handleRowsScroll = (ev) => {
|
|
1062
1820
|
const { scrollTop } = ev.target;
|
|
1063
1821
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1094,13 +1852,13 @@ var useScrollHandlers = () => {
|
|
|
1094
1852
|
};
|
|
1095
1853
|
};
|
|
1096
1854
|
var GridCorner = (props) => {
|
|
1097
|
-
return /* @__PURE__ */
|
|
1855
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1098
1856
|
className: fragments.axis,
|
|
1099
1857
|
...props
|
|
1100
1858
|
});
|
|
1101
1859
|
};
|
|
1102
1860
|
var MovingOverlay = ({ label }) => {
|
|
1103
|
-
return /* @__PURE__ */
|
|
1861
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1104
1862
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1105
1863
|
}, label);
|
|
1106
1864
|
};
|
|
@@ -1111,7 +1869,7 @@ var touchConstraints = {
|
|
|
1111
1869
|
delay: 250,
|
|
1112
1870
|
tolerance: 5
|
|
1113
1871
|
};
|
|
1114
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
1872
|
+
var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1115
1873
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1116
1874
|
activationConstraint: mouseConstraints
|
|
1117
1875
|
});
|
|
@@ -1120,7 +1878,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1120
1878
|
});
|
|
1121
1879
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1122
1880
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1123
|
-
const [active, setActive] = (0,
|
|
1881
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1124
1882
|
const handleDragStart = ({ active: active2 }) => {
|
|
1125
1883
|
setActive(active2);
|
|
1126
1884
|
};
|
|
@@ -1144,18 +1902,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1144
1902
|
}
|
|
1145
1903
|
return transform;
|
|
1146
1904
|
};
|
|
1147
|
-
return /* @__PURE__ */
|
|
1905
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1148
1906
|
className: "relative flex grow overflow-hidden"
|
|
1149
|
-
}, /* @__PURE__ */
|
|
1150
|
-
className: (0,
|
|
1907
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1908
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
1151
1909
|
style: {
|
|
1152
1910
|
width: axisWidth
|
|
1153
1911
|
}
|
|
1154
|
-
}), /* @__PURE__ */
|
|
1912
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1155
1913
|
ref: forwardRef2,
|
|
1156
1914
|
role: "rowheader",
|
|
1157
1915
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1158
|
-
}, /* @__PURE__ */
|
|
1916
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1159
1917
|
sensors,
|
|
1160
1918
|
modifiers: [
|
|
1161
1919
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -1163,12 +1921,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1163
1921
|
],
|
|
1164
1922
|
onDragStart: handleDragStart,
|
|
1165
1923
|
onDragEnd: handleDragEnd
|
|
1166
|
-
}, /* @__PURE__ */
|
|
1924
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1167
1925
|
className: "flex flex-col",
|
|
1168
1926
|
style: {
|
|
1169
1927
|
width: axisWidth
|
|
1170
1928
|
}
|
|
1171
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1929
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridRowCell, {
|
|
1172
1930
|
key: idx,
|
|
1173
1931
|
idx,
|
|
1174
1932
|
index,
|
|
@@ -1178,7 +1936,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1178
1936
|
selected: selected === index,
|
|
1179
1937
|
onResize,
|
|
1180
1938
|
onSelect
|
|
1181
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1939
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react2.default.createElement(MovingOverlay, {
|
|
1182
1940
|
label: String(active.data.current.index + 1)
|
|
1183
1941
|
})), document.body))));
|
|
1184
1942
|
});
|
|
@@ -1196,9 +1954,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1196
1954
|
}
|
|
1197
1955
|
});
|
|
1198
1956
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1199
|
-
const [initialSize, setInitialSize] = (0,
|
|
1200
|
-
const [resizing, setResizing] = (0,
|
|
1201
|
-
const scrollHandler = (0,
|
|
1957
|
+
const [initialSize, setInitialSize] = (0, import_react2.useState)(size);
|
|
1958
|
+
const [resizing, setResizing] = (0, import_react2.useState)(false);
|
|
1959
|
+
const scrollHandler = (0, import_react2.useRef)();
|
|
1202
1960
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1203
1961
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
1204
1962
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -1219,7 +1977,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1219
1977
|
onResize?.(idx, initialSize + height, true);
|
|
1220
1978
|
setResizing(false);
|
|
1221
1979
|
};
|
|
1222
|
-
return /* @__PURE__ */
|
|
1980
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1223
1981
|
enable: {
|
|
1224
1982
|
bottom: resize
|
|
1225
1983
|
},
|
|
@@ -1231,21 +1989,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1231
1989
|
onResizeStart: handleResizeStart,
|
|
1232
1990
|
onResize: handleResize,
|
|
1233
1991
|
onResizeStop: handleResizeStop
|
|
1234
|
-
}, /* @__PURE__ */
|
|
1992
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1235
1993
|
ref: setNodeRef,
|
|
1236
1994
|
...attributes,
|
|
1237
1995
|
...listeners,
|
|
1238
|
-
className: (0,
|
|
1996
|
+
className: (0, import_react_ui_theme.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),
|
|
1239
1997
|
onClick: () => onSelect?.(index)
|
|
1240
|
-
}, /* @__PURE__ */
|
|
1998
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1241
1999
|
className: "flex w-full justify-center"
|
|
1242
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2000
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1243
2001
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1244
|
-
}), resizing && /* @__PURE__ */
|
|
2002
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1245
2003
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1246
2004
|
})));
|
|
1247
2005
|
};
|
|
1248
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
2006
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1249
2007
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1250
2008
|
activationConstraint: mouseConstraints
|
|
1251
2009
|
});
|
|
@@ -1254,7 +2012,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1254
2012
|
});
|
|
1255
2013
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1256
2014
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1257
|
-
const [active, setActive] = (0,
|
|
2015
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1258
2016
|
const handleDragStart = ({ active: active2 }) => {
|
|
1259
2017
|
setActive(active2);
|
|
1260
2018
|
};
|
|
@@ -1278,18 +2036,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1278
2036
|
}
|
|
1279
2037
|
return transform;
|
|
1280
2038
|
};
|
|
1281
|
-
return /* @__PURE__ */
|
|
2039
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1282
2040
|
className: "relative flex grow overflow-hidden"
|
|
1283
|
-
}, /* @__PURE__ */
|
|
1284
|
-
className: (0,
|
|
2041
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2042
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
1285
2043
|
style: {
|
|
1286
2044
|
height: axisHeight
|
|
1287
2045
|
}
|
|
1288
|
-
}), /* @__PURE__ */
|
|
2046
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1289
2047
|
ref: forwardRef2,
|
|
1290
2048
|
role: "columnheader",
|
|
1291
2049
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1292
|
-
}, /* @__PURE__ */
|
|
2050
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1293
2051
|
autoScroll: {
|
|
1294
2052
|
enabled: true
|
|
1295
2053
|
},
|
|
@@ -1300,23 +2058,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1300
2058
|
],
|
|
1301
2059
|
onDragStart: handleDragStart,
|
|
1302
2060
|
onDragEnd: handleDragEnd
|
|
1303
|
-
}, /* @__PURE__ */
|
|
2061
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1304
2062
|
className: "flex h-full",
|
|
1305
2063
|
style: {
|
|
1306
2064
|
height: axisHeight
|
|
1307
2065
|
}
|
|
1308
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2066
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridColumnCell, {
|
|
1309
2067
|
key: idx,
|
|
1310
2068
|
idx,
|
|
1311
2069
|
index,
|
|
1312
|
-
label:
|
|
2070
|
+
label: columnLetter(index),
|
|
1313
2071
|
size: sizes?.[idx] ?? defaultWidth,
|
|
1314
2072
|
resize: index < columns.length - 1,
|
|
1315
2073
|
selected: selected === index,
|
|
1316
2074
|
onResize,
|
|
1317
2075
|
onSelect
|
|
1318
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1319
|
-
label:
|
|
2076
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react2.default.createElement(MovingOverlay, {
|
|
2077
|
+
label: columnLetter(active.data.current.index)
|
|
1320
2078
|
})), document.body))));
|
|
1321
2079
|
});
|
|
1322
2080
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -1333,9 +2091,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1333
2091
|
}
|
|
1334
2092
|
});
|
|
1335
2093
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1336
|
-
const [initialSize, setInitialSize] = (0,
|
|
1337
|
-
const [resizing, setResizing] = (0,
|
|
1338
|
-
const scrollHandler = (0,
|
|
2094
|
+
const [initialSize, setInitialSize] = (0, import_react2.useState)(size);
|
|
2095
|
+
const [resizing, setResizing] = (0, import_react2.useState)(false);
|
|
2096
|
+
const scrollHandler = (0, import_react2.useRef)();
|
|
1339
2097
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1340
2098
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
1341
2099
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -1356,7 +2114,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1356
2114
|
onResize?.(idx, initialSize + width, true);
|
|
1357
2115
|
setResizing(false);
|
|
1358
2116
|
};
|
|
1359
|
-
return /* @__PURE__ */
|
|
2117
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1360
2118
|
enable: {
|
|
1361
2119
|
right: resize
|
|
1362
2120
|
},
|
|
@@ -1368,37 +2126,37 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1368
2126
|
onResizeStart: handleResizeStart,
|
|
1369
2127
|
onResize: handleResize,
|
|
1370
2128
|
onResizeStop: handleResizeStop
|
|
1371
|
-
}, /* @__PURE__ */
|
|
2129
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1372
2130
|
ref: setNodeRef,
|
|
1373
2131
|
...attributes,
|
|
1374
2132
|
...listeners,
|
|
1375
|
-
className: (0,
|
|
2133
|
+
className: (0, import_react_ui_theme.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),
|
|
1376
2134
|
onClick: () => onSelect?.(index)
|
|
1377
|
-
}, /* @__PURE__ */
|
|
2135
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1378
2136
|
className: "flex w-full justify-center"
|
|
1379
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2137
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1380
2138
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1381
|
-
}), resizing && /* @__PURE__ */
|
|
2139
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1382
2140
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1383
2141
|
})));
|
|
1384
2142
|
};
|
|
1385
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
2143
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
1386
2144
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
1387
2145
|
refreshRate: 200
|
|
1388
2146
|
});
|
|
1389
|
-
const scrollerRef = (0,
|
|
1390
|
-
(0,
|
|
2147
|
+
const scrollerRef = (0, import_react2.useRef)(null);
|
|
2148
|
+
(0, import_react2.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
1391
2149
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1392
|
-
const initialText = (0,
|
|
1393
|
-
const quickEdit = (0,
|
|
1394
|
-
const [, forceUpdate] = (0,
|
|
1395
|
-
(0,
|
|
2150
|
+
const initialText = (0, import_react2.useRef)();
|
|
2151
|
+
const quickEdit = (0, import_react2.useRef)(false);
|
|
2152
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2153
|
+
(0, import_react2.useEffect)(() => {
|
|
1396
2154
|
const unsubscribe = model.update.on(() => {
|
|
1397
2155
|
(0, import_log.log)("updated", {
|
|
1398
2156
|
id: model.id
|
|
1399
2157
|
}, {
|
|
1400
|
-
F:
|
|
1401
|
-
L:
|
|
2158
|
+
F: __dxlog_file4,
|
|
2159
|
+
L: 737,
|
|
1402
2160
|
S: void 0,
|
|
1403
2161
|
C: (f, a) => f(...a)
|
|
1404
2162
|
});
|
|
@@ -1410,7 +2168,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1410
2168
|
}, [
|
|
1411
2169
|
model
|
|
1412
2170
|
]);
|
|
1413
|
-
const inputRef = (0,
|
|
2171
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
1414
2172
|
const handleKeyDown = (ev) => {
|
|
1415
2173
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
1416
2174
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -1518,16 +2276,16 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1518
2276
|
const id = (0, import_echo.fullyQualifiedId)(model.sheet);
|
|
1519
2277
|
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(id);
|
|
1520
2278
|
const hasAttention = (0, import_react_ui_attention.useHasAttention)(id);
|
|
1521
|
-
return /* @__PURE__ */
|
|
2279
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1522
2280
|
ref: containerRef,
|
|
1523
2281
|
role: "grid",
|
|
1524
2282
|
className: "relative flex grow overflow-hidden"
|
|
1525
|
-
}, /* @__PURE__ */
|
|
1526
|
-
className: (0,
|
|
1527
|
-
}), /* @__PURE__ */
|
|
2283
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2284
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
2285
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1528
2286
|
ref: scrollerRef,
|
|
1529
|
-
className: (0,
|
|
1530
|
-
}, /* @__PURE__ */
|
|
2287
|
+
className: (0, import_react_ui_theme.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2288
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1531
2289
|
className: "relative select-none",
|
|
1532
2290
|
style: {
|
|
1533
2291
|
width,
|
|
@@ -1535,10 +2293,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1535
2293
|
},
|
|
1536
2294
|
onClick: () => inputRef.current?.focus(),
|
|
1537
2295
|
...handlers
|
|
1538
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2296
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react2.default.createElement(SelectionOverlay, {
|
|
1539
2297
|
root: scrollerRef.current
|
|
1540
2298
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1541
|
-
return columnRange.map(({
|
|
2299
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1542
2300
|
const style = {
|
|
1543
2301
|
position: "absolute",
|
|
1544
2302
|
top,
|
|
@@ -1548,11 +2306,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1548
2306
|
};
|
|
1549
2307
|
const cell = {
|
|
1550
2308
|
row,
|
|
1551
|
-
|
|
2309
|
+
col
|
|
1552
2310
|
};
|
|
1553
|
-
const id2 =
|
|
1554
|
-
const idx = model.
|
|
1555
|
-
const active =
|
|
2311
|
+
const id2 = addressToA1Notation(cell);
|
|
2312
|
+
const idx = addressToIndex(model.sheet, cell);
|
|
2313
|
+
const active = posEquals(cursor, cell);
|
|
1556
2314
|
if (active && editing) {
|
|
1557
2315
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
1558
2316
|
const handleClose = (value2) => {
|
|
@@ -1584,7 +2342,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1584
2342
|
inputRef.current?.focus();
|
|
1585
2343
|
setEditing(false);
|
|
1586
2344
|
};
|
|
1587
|
-
return /* @__PURE__ */
|
|
2345
|
+
return /* @__PURE__ */ import_react2.default.createElement(GridCellEditor, {
|
|
1588
2346
|
key: idx,
|
|
1589
2347
|
value,
|
|
1590
2348
|
style,
|
|
@@ -1592,7 +2350,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1592
2350
|
onClose: handleClose
|
|
1593
2351
|
});
|
|
1594
2352
|
}
|
|
1595
|
-
return /* @__PURE__ */
|
|
2353
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetCell, {
|
|
1596
2354
|
key: id2,
|
|
1597
2355
|
id: id2,
|
|
1598
2356
|
cell,
|
|
@@ -1604,7 +2362,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1604
2362
|
}
|
|
1605
2363
|
});
|
|
1606
2364
|
});
|
|
1607
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2365
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement("input", {
|
|
1608
2366
|
ref: inputRef,
|
|
1609
2367
|
autoFocus: true,
|
|
1610
2368
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -1625,20 +2383,34 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1625
2383
|
const b1 = getRelativeClientRect(root, c1);
|
|
1626
2384
|
const b2 = getRelativeClientRect(root, c2);
|
|
1627
2385
|
const bounds = getRectUnion(b1, b2);
|
|
1628
|
-
return /* @__PURE__ */
|
|
2386
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1629
2387
|
role: "none",
|
|
1630
2388
|
style: bounds,
|
|
1631
2389
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
1632
2390
|
});
|
|
1633
2391
|
};
|
|
1634
2392
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
1635
|
-
const { formatting, editing, setRange } = useSheetContext();
|
|
2393
|
+
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1636
2394
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1637
|
-
|
|
2395
|
+
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
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", {
|
|
1638
2410
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1639
2411
|
role: "cell",
|
|
1640
2412
|
style,
|
|
1641
|
-
className: (0,
|
|
2413
|
+
className: (0, import_react_ui_theme.mx)("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1642
2414
|
"z-20",
|
|
1643
2415
|
fragments.cellSelected
|
|
1644
2416
|
], classNames),
|
|
@@ -1652,36 +2424,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1652
2424
|
}
|
|
1653
2425
|
},
|
|
1654
2426
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
1655
|
-
},
|
|
2427
|
+
}, decoratedContent);
|
|
1656
2428
|
};
|
|
1657
2429
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
1658
2430
|
const { model, range } = useSheetContext();
|
|
1659
|
-
const notifier = (0,
|
|
1660
|
-
(0,
|
|
2431
|
+
const notifier = (0, import_react2.useRef)();
|
|
2432
|
+
(0, import_react2.useEffect)(() => {
|
|
1661
2433
|
if (range) {
|
|
1662
|
-
notifier.current?.(
|
|
2434
|
+
notifier.current?.(rangeToA1Notation(range));
|
|
1663
2435
|
}
|
|
1664
2436
|
}, [
|
|
1665
2437
|
range
|
|
1666
2438
|
]);
|
|
1667
|
-
const extension = (0,
|
|
2439
|
+
const extension = (0, import_react2.useMemo)(() => [
|
|
1668
2440
|
editorKeys({
|
|
1669
2441
|
onNav,
|
|
1670
2442
|
onClose
|
|
1671
2443
|
}),
|
|
1672
2444
|
sheetExtension({
|
|
1673
|
-
functions: model.
|
|
2445
|
+
functions: model.graph.getFunctions()
|
|
1674
2446
|
}),
|
|
1675
2447
|
rangeExtension((fn) => notifier.current = fn)
|
|
1676
2448
|
], [
|
|
1677
2449
|
model
|
|
1678
2450
|
]);
|
|
1679
|
-
return /* @__PURE__ */
|
|
2451
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1680
2452
|
role: "cell",
|
|
1681
2453
|
style,
|
|
1682
|
-
className: (0,
|
|
2454
|
+
className: (0, import_react_ui_theme.mx)("z-20 flex", fragments.cellSelected),
|
|
1683
2455
|
onClick: (ev) => ev.stopPropagation()
|
|
1684
|
-
}, /* @__PURE__ */
|
|
2456
|
+
}, /* @__PURE__ */ import_react2.default.createElement(CellEditor, {
|
|
1685
2457
|
autoFocus: true,
|
|
1686
2458
|
value,
|
|
1687
2459
|
extension
|
|
@@ -1694,30 +2466,30 @@ var SheetStatusBar = () => {
|
|
|
1694
2466
|
if (cursor) {
|
|
1695
2467
|
value = model.getCellValue(cursor);
|
|
1696
2468
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1697
|
-
value = model.
|
|
2469
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1698
2470
|
isFormula = true;
|
|
1699
2471
|
} else if (value != null) {
|
|
1700
2472
|
value = String(value);
|
|
1701
2473
|
}
|
|
1702
2474
|
}
|
|
1703
|
-
return /* @__PURE__ */
|
|
1704
|
-
className: (0,
|
|
1705
|
-
}, /* @__PURE__ */
|
|
2475
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2476
|
+
className: (0, import_react_ui_theme.mx)("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
2477
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1706
2478
|
className: "flex gap-4 items-center"
|
|
1707
|
-
}, /* @__PURE__ */
|
|
2479
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1708
2480
|
className: "flex w-16 items-center font-mono"
|
|
1709
|
-
}, range &&
|
|
2481
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1710
2482
|
className: "flex gap-2 items-center"
|
|
1711
|
-
}, /* @__PURE__ */
|
|
1712
|
-
className: (0,
|
|
1713
|
-
}), /* @__PURE__ */
|
|
2483
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_react.Function, {
|
|
2484
|
+
className: (0, import_react_ui_theme.mx)("text-greenText", isFormula ? "visible" : "invisible")
|
|
2485
|
+
}), /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1714
2486
|
className: "font-mono"
|
|
1715
2487
|
}, value))));
|
|
1716
2488
|
};
|
|
1717
2489
|
var SheetDebug = () => {
|
|
1718
2490
|
const { model, cursor, range } = useSheetContext();
|
|
1719
|
-
const [, forceUpdate] = (0,
|
|
1720
|
-
(0,
|
|
2491
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2492
|
+
(0, import_react2.useEffect)(() => {
|
|
1721
2493
|
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
1722
2494
|
const handleUpdate = () => forceUpdate({});
|
|
1723
2495
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -1728,9 +2500,9 @@ var SheetDebug = () => {
|
|
|
1728
2500
|
}, [
|
|
1729
2501
|
model
|
|
1730
2502
|
]);
|
|
1731
|
-
return /* @__PURE__ */
|
|
1732
|
-
className: (0,
|
|
1733
|
-
}, /* @__PURE__ */
|
|
2503
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2504
|
+
className: (0, import_react_ui_theme.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")
|
|
2505
|
+
}, /* @__PURE__ */ import_react2.default.createElement("pre", {
|
|
1734
2506
|
className: "whitespace-pre-wrap"
|
|
1735
2507
|
}, JSON.stringify({
|
|
1736
2508
|
cursor,
|
|
@@ -1751,15 +2523,14 @@ var Sheet = {
|
|
|
1751
2523
|
StatusBar: SheetStatusBar,
|
|
1752
2524
|
Debug: SheetDebug
|
|
1753
2525
|
};
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
|
-
//# sourceMappingURL=SheetContainer-AXQV3ZT5.cjs.map
|
|
2526
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2527
|
+
0 && (module.exports = {
|
|
2528
|
+
ComputeGraphContextProvider,
|
|
2529
|
+
Sheet,
|
|
2530
|
+
SheetContainer,
|
|
2531
|
+
addressToIndex,
|
|
2532
|
+
compareIndexPositions,
|
|
2533
|
+
createSheet,
|
|
2534
|
+
useSheetContext
|
|
2535
|
+
});
|
|
2536
|
+
//# sourceMappingURL=chunk-OTTD7FBK.cjs.map
|