@dxos/plugin-sheet 0.6.11-staging.e6894a4 → 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-P7SSL3EG.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-4XOKHKKZ.mjs → chunk-U2JHW3L6.mjs} +1043 -261
- 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 +80 -66
- 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-SVAIIXWQ.cjs → chunk-DD6FIXWC.cjs} +360 -667
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-IQT6TR4Z.cjs → chunk-OTTD7FBK.cjs} +1062 -289
- 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 +93 -72
- 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 +51 -72
- 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 +48 -87
- package/src/components/Sheet/Sheet.tsx +69 -39
- 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 -21
- package/src/components/Toolbar/Toolbar.stories.tsx +5 -10
- 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-4XOKHKKZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-FWGRE3EG.mjs +0 -175
- package/dist/lib/browser/chunk-FWGRE3EG.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-P7SSL3EG.mjs.map +0 -7
- package/dist/lib/browser/chunk-YPU3R7FA.mjs +0 -8
- package/dist/lib/browser/chunk-YPU3R7FA.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-IQT6TR4Z.cjs.map +0 -7
- package/dist/lib/node/chunk-5EPCDAZC.cjs +0 -40
- package/dist/lib/node/chunk-5EPCDAZC.cjs.map +0 -7
- package/dist/lib/node/chunk-727C6YNP.cjs +0 -202
- package/dist/lib/node/chunk-727C6YNP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-SVAIIXWQ.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 -551
- 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: [
|
|
@@ -392,7 +618,10 @@ var FormattingModel = class {
|
|
|
392
618
|
]
|
|
393
619
|
};
|
|
394
620
|
}
|
|
395
|
-
|
|
621
|
+
//
|
|
622
|
+
// Numbers.
|
|
623
|
+
//
|
|
624
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Number: {
|
|
396
625
|
return {
|
|
397
626
|
value: value.toLocaleString(locales),
|
|
398
627
|
classNames: [
|
|
@@ -401,7 +630,7 @@ var FormattingModel = class {
|
|
|
401
630
|
]
|
|
402
631
|
};
|
|
403
632
|
}
|
|
404
|
-
case
|
|
633
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Percent: {
|
|
405
634
|
return {
|
|
406
635
|
value: value * 100 + "%",
|
|
407
636
|
classNames: [
|
|
@@ -410,7 +639,7 @@ var FormattingModel = class {
|
|
|
410
639
|
]
|
|
411
640
|
};
|
|
412
641
|
}
|
|
413
|
-
case
|
|
642
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Currency: {
|
|
414
643
|
return {
|
|
415
644
|
value: value.toLocaleString(locales, {
|
|
416
645
|
style: "currency",
|
|
@@ -424,22 +653,25 @@ var FormattingModel = class {
|
|
|
424
653
|
]
|
|
425
654
|
};
|
|
426
655
|
}
|
|
427
|
-
|
|
428
|
-
|
|
656
|
+
//
|
|
657
|
+
// Dates.
|
|
658
|
+
//
|
|
659
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.DateTime: {
|
|
660
|
+
const date = this._model.toLocalDate(value);
|
|
429
661
|
return {
|
|
430
662
|
value: date.toLocaleString(locales),
|
|
431
663
|
classNames
|
|
432
664
|
};
|
|
433
665
|
}
|
|
434
|
-
case
|
|
435
|
-
const date = this.
|
|
666
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Date: {
|
|
667
|
+
const date = this._model.toLocalDate(value);
|
|
436
668
|
return {
|
|
437
669
|
value: date.toLocaleDateString(locales),
|
|
438
670
|
classNames
|
|
439
671
|
};
|
|
440
672
|
}
|
|
441
|
-
case
|
|
442
|
-
const date = this.
|
|
673
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Time: {
|
|
674
|
+
const date = this._model.toLocalDate(value);
|
|
443
675
|
return {
|
|
444
676
|
value: date.toLocaleTimeString(locales),
|
|
445
677
|
classNames
|
|
@@ -454,83 +686,414 @@ var FormattingModel = class {
|
|
|
454
686
|
}
|
|
455
687
|
}
|
|
456
688
|
};
|
|
457
|
-
var
|
|
458
|
-
var
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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
|
+
};
|
|
472
705
|
};
|
|
473
|
-
var
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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;
|
|
477
865
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
return `${(0, import_echo2.fullyQualifiedId)(fn)}(${args})`;
|
|
866
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
867
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
481
868
|
} else {
|
|
482
|
-
return
|
|
869
|
+
return String(value);
|
|
483
870
|
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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();
|
|
491
902
|
}
|
|
492
|
-
|
|
493
|
-
if (
|
|
494
|
-
|
|
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];
|
|
495
927
|
} else {
|
|
496
|
-
|
|
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
|
+
};
|
|
497
934
|
}
|
|
498
|
-
}
|
|
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
|
+
]);
|
|
499
1044
|
};
|
|
500
|
-
var
|
|
501
|
-
const graph =
|
|
502
|
-
const [
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
+
}
|
|
507
1052
|
let model2;
|
|
508
|
-
let formatting2;
|
|
509
1053
|
const t = setTimeout(async () => {
|
|
510
|
-
model2 = new
|
|
511
|
-
readonly
|
|
512
|
-
mapFormulaBindingToId,
|
|
513
|
-
mapFormulaBindingFromId
|
|
1054
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1055
|
+
readonly
|
|
514
1056
|
});
|
|
515
|
-
await model2.
|
|
516
|
-
|
|
517
|
-
setModels([
|
|
518
|
-
model2,
|
|
519
|
-
formatting2
|
|
520
|
-
]);
|
|
1057
|
+
await model2.open();
|
|
1058
|
+
setModel(model2);
|
|
521
1059
|
});
|
|
522
1060
|
return () => {
|
|
523
1061
|
clearTimeout(t);
|
|
524
|
-
void model2?.
|
|
1062
|
+
void model2?.close();
|
|
525
1063
|
};
|
|
526
1064
|
}, [
|
|
1065
|
+
space,
|
|
1066
|
+
sheet,
|
|
527
1067
|
graph,
|
|
528
1068
|
readonly
|
|
529
1069
|
]);
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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, {
|
|
534
1097
|
value: {
|
|
535
1098
|
model,
|
|
536
1099
|
formatting,
|
|
@@ -541,10 +1104,168 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
541
1104
|
editing,
|
|
542
1105
|
setEditing,
|
|
543
1106
|
// TODO(burdon): Change to event.
|
|
544
|
-
onInfo
|
|
1107
|
+
onInfo,
|
|
1108
|
+
decorations
|
|
545
1109
|
}
|
|
546
1110
|
}, children);
|
|
547
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
|
+
};
|
|
548
1269
|
var getRelativeClientRect = (root, element) => {
|
|
549
1270
|
const rootRect = root.getBoundingClientRect();
|
|
550
1271
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -621,21 +1342,61 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
621
1342
|
{
|
|
622
1343
|
key: "Enter",
|
|
623
1344
|
run: (editor) => {
|
|
624
|
-
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
|
+
});
|
|
625
1371
|
return true;
|
|
626
1372
|
}
|
|
627
1373
|
},
|
|
628
1374
|
{
|
|
629
1375
|
key: "Escape",
|
|
630
1376
|
run: () => {
|
|
631
|
-
onClose(void 0
|
|
1377
|
+
onClose(void 0, {
|
|
1378
|
+
key: "Escape"
|
|
1379
|
+
});
|
|
632
1380
|
return true;
|
|
633
1381
|
}
|
|
634
1382
|
}
|
|
635
1383
|
]);
|
|
636
1384
|
};
|
|
637
|
-
var
|
|
638
|
-
|
|
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)();
|
|
639
1400
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
640
1401
|
return {
|
|
641
1402
|
autoFocus,
|
|
@@ -661,21 +1422,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
661
1422
|
themeMode,
|
|
662
1423
|
slots: {
|
|
663
1424
|
editor: {
|
|
664
|
-
className:
|
|
1425
|
+
className: editorVariants[variant].editor
|
|
665
1426
|
},
|
|
666
1427
|
content: {
|
|
667
|
-
className:
|
|
1428
|
+
className: editorVariants[variant].content
|
|
668
1429
|
}
|
|
669
1430
|
}
|
|
670
1431
|
})
|
|
671
1432
|
]
|
|
672
1433
|
};
|
|
673
1434
|
}, [
|
|
674
|
-
extension
|
|
1435
|
+
extension,
|
|
1436
|
+
autoFocus,
|
|
1437
|
+
value,
|
|
1438
|
+
variant,
|
|
1439
|
+
onBlur
|
|
675
1440
|
]);
|
|
676
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
677
1442
|
ref: parentRef,
|
|
678
|
-
className:
|
|
1443
|
+
className: editorVariants[variant].root,
|
|
1444
|
+
style: box,
|
|
1445
|
+
...gridId && {
|
|
1446
|
+
"data-grid": gridId
|
|
1447
|
+
}
|
|
679
1448
|
});
|
|
680
1449
|
};
|
|
681
1450
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -788,13 +1557,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
788
1557
|
// NOTE: Useful for debugging.
|
|
789
1558
|
closeOnBlur: false,
|
|
790
1559
|
icons: false,
|
|
791
|
-
tooltipClass: () => (0,
|
|
792
|
-
// TODO(burdon): Factor out fragments.
|
|
793
|
-
// TODO(burdon): Size to make width same as column.
|
|
794
|
-
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
795
|
-
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
796
|
-
"border-separator"
|
|
797
|
-
)
|
|
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")
|
|
798
1561
|
}),
|
|
799
1562
|
import_view2.keymap.of([
|
|
800
1563
|
{
|
|
@@ -881,27 +1644,27 @@ var visitTree = (node, callback) => {
|
|
|
881
1644
|
}
|
|
882
1645
|
return false;
|
|
883
1646
|
};
|
|
884
|
-
var
|
|
1647
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
885
1648
|
var fragments = {
|
|
886
1649
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
887
1650
|
axisSelected: "bg-attention text-baseText",
|
|
888
1651
|
cell: "bg-gridCell",
|
|
889
|
-
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
890
|
-
border: "border-gridLine"
|
|
1652
|
+
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
891
1653
|
};
|
|
892
1654
|
var SheetRoot = ({ children, ...props }) => {
|
|
893
|
-
return /* @__PURE__ */
|
|
1655
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContextProvider, props, children);
|
|
894
1656
|
};
|
|
895
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
1657
|
+
var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
896
1658
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
897
1659
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
898
|
-
|
|
1660
|
+
useThreads();
|
|
1661
|
+
const [rows, setRows] = (0, import_react2.useState)([
|
|
899
1662
|
...model.sheet.rows
|
|
900
1663
|
]);
|
|
901
|
-
const [columns, setColumns] = (0,
|
|
1664
|
+
const [columns, setColumns] = (0, import_react2.useState)([
|
|
902
1665
|
...model.sheet.columns
|
|
903
1666
|
]);
|
|
904
|
-
(0,
|
|
1667
|
+
(0, import_react2.useEffect)(() => {
|
|
905
1668
|
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
906
1669
|
"rows"
|
|
907
1670
|
]);
|
|
@@ -926,37 +1689,37 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
926
1689
|
}, [
|
|
927
1690
|
model
|
|
928
1691
|
]);
|
|
929
|
-
(0,
|
|
1692
|
+
(0, import_react2.useEffect)(() => {
|
|
930
1693
|
model.reset();
|
|
931
1694
|
}, [
|
|
932
1695
|
rows,
|
|
933
1696
|
columns
|
|
934
1697
|
]);
|
|
935
1698
|
const handleMoveRows = (from, to, num = 1) => {
|
|
936
|
-
const cursorIdx = cursor ? model.
|
|
1699
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
937
1700
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
938
1701
|
model.sheet.rows.splice(to, 0, rows2);
|
|
939
1702
|
if (cursorIdx) {
|
|
940
|
-
setCursor(model.
|
|
1703
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
941
1704
|
}
|
|
942
1705
|
setRows([
|
|
943
1706
|
...model.sheet.rows
|
|
944
1707
|
]);
|
|
945
1708
|
};
|
|
946
1709
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
947
|
-
const cursorIdx = cursor ? model.
|
|
1710
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
948
1711
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
949
1712
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
950
1713
|
if (cursorIdx) {
|
|
951
|
-
setCursor(model.
|
|
1714
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
952
1715
|
}
|
|
953
1716
|
setColumns([
|
|
954
1717
|
...model.sheet.columns
|
|
955
1718
|
]);
|
|
956
1719
|
};
|
|
957
|
-
const [rowSizes, setRowSizes] = (0,
|
|
958
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
959
|
-
(0,
|
|
1720
|
+
const [rowSizes, setRowSizes] = (0, import_react2.useState)();
|
|
1721
|
+
const [columnSizes, setColumnSizes] = (0, import_react2.useState)();
|
|
1722
|
+
(0, import_react2.useEffect)(() => {
|
|
960
1723
|
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
961
1724
|
"rowMeta"
|
|
962
1725
|
]);
|
|
@@ -1005,54 +1768,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1005
1768
|
}));
|
|
1006
1769
|
}
|
|
1007
1770
|
};
|
|
1008
|
-
return /* @__PURE__ */
|
|
1771
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1009
1772
|
role: "none",
|
|
1010
|
-
className: (0,
|
|
1011
|
-
}, /* @__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, {
|
|
1012
1775
|
onClick: () => {
|
|
1013
1776
|
setCursor(void 0);
|
|
1014
1777
|
setRange(void 0);
|
|
1015
1778
|
setEditing(false);
|
|
1016
1779
|
}
|
|
1017
|
-
}), /* @__PURE__ */
|
|
1780
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetColumns, {
|
|
1018
1781
|
ref: columnsRef,
|
|
1019
1782
|
columns,
|
|
1020
1783
|
sizes: columnSizes,
|
|
1021
|
-
selected: cursor?.
|
|
1022
|
-
onSelect: (
|
|
1784
|
+
selected: cursor?.col,
|
|
1785
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1023
1786
|
row: -1,
|
|
1024
|
-
|
|
1787
|
+
col
|
|
1025
1788
|
}),
|
|
1026
1789
|
onResize: handleResizeColumn,
|
|
1027
1790
|
onMove: handleMoveColumns
|
|
1028
|
-
}), /* @__PURE__ */
|
|
1791
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetRows, {
|
|
1029
1792
|
ref: rowsRef,
|
|
1030
1793
|
rows,
|
|
1031
1794
|
sizes: rowSizes,
|
|
1032
1795
|
selected: cursor?.row,
|
|
1033
1796
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1034
1797
|
row,
|
|
1035
|
-
|
|
1798
|
+
col: -1
|
|
1036
1799
|
}),
|
|
1037
1800
|
onResize: handleResizeRow,
|
|
1038
1801
|
onMove: handleMoveRows
|
|
1039
|
-
}), /* @__PURE__ */
|
|
1802
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetGrid, {
|
|
1040
1803
|
ref: contentRef,
|
|
1041
1804
|
size: {
|
|
1042
1805
|
numRows: numRows ?? rows.length,
|
|
1043
|
-
|
|
1806
|
+
numCols: numCols ?? columns.length
|
|
1044
1807
|
},
|
|
1045
1808
|
rows,
|
|
1046
1809
|
columns,
|
|
1047
1810
|
rowSizes,
|
|
1048
1811
|
columnSizes
|
|
1049
|
-
}), /* @__PURE__ */
|
|
1812
|
+
}), /* @__PURE__ */ import_react2.default.createElement(GridCorner, null), /* @__PURE__ */ import_react2.default.createElement(SheetStatusBar, null));
|
|
1050
1813
|
});
|
|
1051
1814
|
var useScrollHandlers = () => {
|
|
1052
|
-
const rowsRef = (0,
|
|
1053
|
-
const columnsRef = (0,
|
|
1054
|
-
const contentRef = (0,
|
|
1055
|
-
(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)(() => {
|
|
1056
1819
|
const handleRowsScroll = (ev) => {
|
|
1057
1820
|
const { scrollTop } = ev.target;
|
|
1058
1821
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1089,13 +1852,13 @@ var useScrollHandlers = () => {
|
|
|
1089
1852
|
};
|
|
1090
1853
|
};
|
|
1091
1854
|
var GridCorner = (props) => {
|
|
1092
|
-
return /* @__PURE__ */
|
|
1855
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1093
1856
|
className: fragments.axis,
|
|
1094
1857
|
...props
|
|
1095
1858
|
});
|
|
1096
1859
|
};
|
|
1097
1860
|
var MovingOverlay = ({ label }) => {
|
|
1098
|
-
return /* @__PURE__ */
|
|
1861
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1099
1862
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1100
1863
|
}, label);
|
|
1101
1864
|
};
|
|
@@ -1106,7 +1869,7 @@ var touchConstraints = {
|
|
|
1106
1869
|
delay: 250,
|
|
1107
1870
|
tolerance: 5
|
|
1108
1871
|
};
|
|
1109
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
1872
|
+
var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1110
1873
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1111
1874
|
activationConstraint: mouseConstraints
|
|
1112
1875
|
});
|
|
@@ -1115,7 +1878,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1115
1878
|
});
|
|
1116
1879
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1117
1880
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1118
|
-
const [active, setActive] = (0,
|
|
1881
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1119
1882
|
const handleDragStart = ({ active: active2 }) => {
|
|
1120
1883
|
setActive(active2);
|
|
1121
1884
|
};
|
|
@@ -1139,18 +1902,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1139
1902
|
}
|
|
1140
1903
|
return transform;
|
|
1141
1904
|
};
|
|
1142
|
-
return /* @__PURE__ */
|
|
1905
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1143
1906
|
className: "relative flex grow overflow-hidden"
|
|
1144
|
-
}, /* @__PURE__ */
|
|
1145
|
-
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"),
|
|
1146
1909
|
style: {
|
|
1147
1910
|
width: axisWidth
|
|
1148
1911
|
}
|
|
1149
|
-
}), /* @__PURE__ */
|
|
1912
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1150
1913
|
ref: forwardRef2,
|
|
1151
1914
|
role: "rowheader",
|
|
1152
1915
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1153
|
-
}, /* @__PURE__ */
|
|
1916
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1154
1917
|
sensors,
|
|
1155
1918
|
modifiers: [
|
|
1156
1919
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -1158,12 +1921,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1158
1921
|
],
|
|
1159
1922
|
onDragStart: handleDragStart,
|
|
1160
1923
|
onDragEnd: handleDragEnd
|
|
1161
|
-
}, /* @__PURE__ */
|
|
1924
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1162
1925
|
className: "flex flex-col",
|
|
1163
1926
|
style: {
|
|
1164
1927
|
width: axisWidth
|
|
1165
1928
|
}
|
|
1166
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1929
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridRowCell, {
|
|
1167
1930
|
key: idx,
|
|
1168
1931
|
idx,
|
|
1169
1932
|
index,
|
|
@@ -1173,7 +1936,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1173
1936
|
selected: selected === index,
|
|
1174
1937
|
onResize,
|
|
1175
1938
|
onSelect
|
|
1176
|
-
}))), /* @__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, {
|
|
1177
1940
|
label: String(active.data.current.index + 1)
|
|
1178
1941
|
})), document.body))));
|
|
1179
1942
|
});
|
|
@@ -1191,9 +1954,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1191
1954
|
}
|
|
1192
1955
|
});
|
|
1193
1956
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1194
|
-
const [initialSize, setInitialSize] = (0,
|
|
1195
|
-
const [resizing, setResizing] = (0,
|
|
1196
|
-
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)();
|
|
1197
1960
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1198
1961
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
1199
1962
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -1214,7 +1977,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1214
1977
|
onResize?.(idx, initialSize + height, true);
|
|
1215
1978
|
setResizing(false);
|
|
1216
1979
|
};
|
|
1217
|
-
return /* @__PURE__ */
|
|
1980
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1218
1981
|
enable: {
|
|
1219
1982
|
bottom: resize
|
|
1220
1983
|
},
|
|
@@ -1226,21 +1989,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1226
1989
|
onResizeStart: handleResizeStart,
|
|
1227
1990
|
onResize: handleResize,
|
|
1228
1991
|
onResizeStop: handleResizeStop
|
|
1229
|
-
}, /* @__PURE__ */
|
|
1992
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1230
1993
|
ref: setNodeRef,
|
|
1231
1994
|
...attributes,
|
|
1232
1995
|
...listeners,
|
|
1233
|
-
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),
|
|
1234
1997
|
onClick: () => onSelect?.(index)
|
|
1235
|
-
}, /* @__PURE__ */
|
|
1998
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1236
1999
|
className: "flex w-full justify-center"
|
|
1237
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2000
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1238
2001
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1239
|
-
}), resizing && /* @__PURE__ */
|
|
2002
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1240
2003
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1241
2004
|
})));
|
|
1242
2005
|
};
|
|
1243
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
2006
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1244
2007
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1245
2008
|
activationConstraint: mouseConstraints
|
|
1246
2009
|
});
|
|
@@ -1249,7 +2012,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1249
2012
|
});
|
|
1250
2013
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1251
2014
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1252
|
-
const [active, setActive] = (0,
|
|
2015
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1253
2016
|
const handleDragStart = ({ active: active2 }) => {
|
|
1254
2017
|
setActive(active2);
|
|
1255
2018
|
};
|
|
@@ -1273,18 +2036,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1273
2036
|
}
|
|
1274
2037
|
return transform;
|
|
1275
2038
|
};
|
|
1276
|
-
return /* @__PURE__ */
|
|
2039
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1277
2040
|
className: "relative flex grow overflow-hidden"
|
|
1278
|
-
}, /* @__PURE__ */
|
|
1279
|
-
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"),
|
|
1280
2043
|
style: {
|
|
1281
2044
|
height: axisHeight
|
|
1282
2045
|
}
|
|
1283
|
-
}), /* @__PURE__ */
|
|
2046
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1284
2047
|
ref: forwardRef2,
|
|
1285
2048
|
role: "columnheader",
|
|
1286
2049
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1287
|
-
}, /* @__PURE__ */
|
|
2050
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1288
2051
|
autoScroll: {
|
|
1289
2052
|
enabled: true
|
|
1290
2053
|
},
|
|
@@ -1295,23 +2058,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1295
2058
|
],
|
|
1296
2059
|
onDragStart: handleDragStart,
|
|
1297
2060
|
onDragEnd: handleDragEnd
|
|
1298
|
-
}, /* @__PURE__ */
|
|
2061
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1299
2062
|
className: "flex h-full",
|
|
1300
2063
|
style: {
|
|
1301
2064
|
height: axisHeight
|
|
1302
2065
|
}
|
|
1303
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2066
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridColumnCell, {
|
|
1304
2067
|
key: idx,
|
|
1305
2068
|
idx,
|
|
1306
2069
|
index,
|
|
1307
|
-
label:
|
|
2070
|
+
label: columnLetter(index),
|
|
1308
2071
|
size: sizes?.[idx] ?? defaultWidth,
|
|
1309
2072
|
resize: index < columns.length - 1,
|
|
1310
2073
|
selected: selected === index,
|
|
1311
2074
|
onResize,
|
|
1312
2075
|
onSelect
|
|
1313
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1314
|
-
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)
|
|
1315
2078
|
})), document.body))));
|
|
1316
2079
|
});
|
|
1317
2080
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -1328,9 +2091,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1328
2091
|
}
|
|
1329
2092
|
});
|
|
1330
2093
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1331
|
-
const [initialSize, setInitialSize] = (0,
|
|
1332
|
-
const [resizing, setResizing] = (0,
|
|
1333
|
-
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)();
|
|
1334
2097
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1335
2098
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
1336
2099
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -1351,7 +2114,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1351
2114
|
onResize?.(idx, initialSize + width, true);
|
|
1352
2115
|
setResizing(false);
|
|
1353
2116
|
};
|
|
1354
|
-
return /* @__PURE__ */
|
|
2117
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1355
2118
|
enable: {
|
|
1356
2119
|
right: resize
|
|
1357
2120
|
},
|
|
@@ -1363,37 +2126,37 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1363
2126
|
onResizeStart: handleResizeStart,
|
|
1364
2127
|
onResize: handleResize,
|
|
1365
2128
|
onResizeStop: handleResizeStop
|
|
1366
|
-
}, /* @__PURE__ */
|
|
2129
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1367
2130
|
ref: setNodeRef,
|
|
1368
2131
|
...attributes,
|
|
1369
2132
|
...listeners,
|
|
1370
|
-
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),
|
|
1371
2134
|
onClick: () => onSelect?.(index)
|
|
1372
|
-
}, /* @__PURE__ */
|
|
2135
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1373
2136
|
className: "flex w-full justify-center"
|
|
1374
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2137
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1375
2138
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1376
|
-
}), resizing && /* @__PURE__ */
|
|
2139
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1377
2140
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1378
2141
|
})));
|
|
1379
2142
|
};
|
|
1380
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
2143
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
1381
2144
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
1382
2145
|
refreshRate: 200
|
|
1383
2146
|
});
|
|
1384
|
-
const scrollerRef = (0,
|
|
1385
|
-
(0,
|
|
2147
|
+
const scrollerRef = (0, import_react2.useRef)(null);
|
|
2148
|
+
(0, import_react2.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
1386
2149
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1387
|
-
const initialText = (0,
|
|
1388
|
-
const quickEdit = (0,
|
|
1389
|
-
const [, forceUpdate] = (0,
|
|
1390
|
-
(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)(() => {
|
|
1391
2154
|
const unsubscribe = model.update.on(() => {
|
|
1392
2155
|
(0, import_log.log)("updated", {
|
|
1393
2156
|
id: model.id
|
|
1394
2157
|
}, {
|
|
1395
|
-
F:
|
|
1396
|
-
L:
|
|
2158
|
+
F: __dxlog_file4,
|
|
2159
|
+
L: 737,
|
|
1397
2160
|
S: void 0,
|
|
1398
2161
|
C: (f, a) => f(...a)
|
|
1399
2162
|
});
|
|
@@ -1405,7 +2168,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1405
2168
|
}, [
|
|
1406
2169
|
model
|
|
1407
2170
|
]);
|
|
1408
|
-
const inputRef = (0,
|
|
2171
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
1409
2172
|
const handleKeyDown = (ev) => {
|
|
1410
2173
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
1411
2174
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -1510,19 +2273,19 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1510
2273
|
rowSizes,
|
|
1511
2274
|
columnSizes
|
|
1512
2275
|
});
|
|
1513
|
-
const
|
|
1514
|
-
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(
|
|
1515
|
-
const
|
|
1516
|
-
return /* @__PURE__ */
|
|
2276
|
+
const id = (0, import_echo.fullyQualifiedId)(model.sheet);
|
|
2277
|
+
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(id);
|
|
2278
|
+
const hasAttention = (0, import_react_ui_attention.useHasAttention)(id);
|
|
2279
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1517
2280
|
ref: containerRef,
|
|
1518
2281
|
role: "grid",
|
|
1519
2282
|
className: "relative flex grow overflow-hidden"
|
|
1520
|
-
}, /* @__PURE__ */
|
|
1521
|
-
className: (0,
|
|
1522
|
-
}), /* @__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", {
|
|
1523
2286
|
ref: scrollerRef,
|
|
1524
|
-
className: (0,
|
|
1525
|
-
}, /* @__PURE__ */
|
|
2287
|
+
className: (0, import_react_ui_theme.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2288
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1526
2289
|
className: "relative select-none",
|
|
1527
2290
|
style: {
|
|
1528
2291
|
width,
|
|
@@ -1530,10 +2293,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1530
2293
|
},
|
|
1531
2294
|
onClick: () => inputRef.current?.focus(),
|
|
1532
2295
|
...handlers
|
|
1533
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2296
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react2.default.createElement(SelectionOverlay, {
|
|
1534
2297
|
root: scrollerRef.current
|
|
1535
2298
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1536
|
-
return columnRange.map(({
|
|
2299
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1537
2300
|
const style = {
|
|
1538
2301
|
position: "absolute",
|
|
1539
2302
|
top,
|
|
@@ -1543,11 +2306,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1543
2306
|
};
|
|
1544
2307
|
const cell = {
|
|
1545
2308
|
row,
|
|
1546
|
-
|
|
2309
|
+
col
|
|
1547
2310
|
};
|
|
1548
|
-
const
|
|
1549
|
-
const idx = model.
|
|
1550
|
-
const active =
|
|
2311
|
+
const id2 = addressToA1Notation(cell);
|
|
2312
|
+
const idx = addressToIndex(model.sheet, cell);
|
|
2313
|
+
const active = posEquals(cursor, cell);
|
|
1551
2314
|
if (active && editing) {
|
|
1552
2315
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
1553
2316
|
const handleClose = (value2) => {
|
|
@@ -1579,7 +2342,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1579
2342
|
inputRef.current?.focus();
|
|
1580
2343
|
setEditing(false);
|
|
1581
2344
|
};
|
|
1582
|
-
return /* @__PURE__ */
|
|
2345
|
+
return /* @__PURE__ */ import_react2.default.createElement(GridCellEditor, {
|
|
1583
2346
|
key: idx,
|
|
1584
2347
|
value,
|
|
1585
2348
|
style,
|
|
@@ -1587,9 +2350,9 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1587
2350
|
onClose: handleClose
|
|
1588
2351
|
});
|
|
1589
2352
|
}
|
|
1590
|
-
return /* @__PURE__ */
|
|
1591
|
-
key:
|
|
1592
|
-
id,
|
|
2353
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetCell, {
|
|
2354
|
+
key: id2,
|
|
2355
|
+
id: id2,
|
|
1593
2356
|
cell,
|
|
1594
2357
|
active,
|
|
1595
2358
|
style,
|
|
@@ -1599,7 +2362,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1599
2362
|
}
|
|
1600
2363
|
});
|
|
1601
2364
|
});
|
|
1602
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2365
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement("input", {
|
|
1603
2366
|
ref: inputRef,
|
|
1604
2367
|
autoFocus: true,
|
|
1605
2368
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -1620,20 +2383,34 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1620
2383
|
const b1 = getRelativeClientRect(root, c1);
|
|
1621
2384
|
const b2 = getRelativeClientRect(root, c2);
|
|
1622
2385
|
const bounds = getRectUnion(b1, b2);
|
|
1623
|
-
return /* @__PURE__ */
|
|
2386
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1624
2387
|
role: "none",
|
|
1625
2388
|
style: bounds,
|
|
1626
2389
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
1627
2390
|
});
|
|
1628
2391
|
};
|
|
1629
2392
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
1630
|
-
const { formatting, editing, setRange } = useSheetContext();
|
|
2393
|
+
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1631
2394
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1632
|
-
|
|
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", {
|
|
1633
2410
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1634
2411
|
role: "cell",
|
|
1635
2412
|
style,
|
|
1636
|
-
className: (0,
|
|
2413
|
+
className: (0, import_react_ui_theme.mx)("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1637
2414
|
"z-20",
|
|
1638
2415
|
fragments.cellSelected
|
|
1639
2416
|
], classNames),
|
|
@@ -1647,36 +2424,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1647
2424
|
}
|
|
1648
2425
|
},
|
|
1649
2426
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
1650
|
-
},
|
|
2427
|
+
}, decoratedContent);
|
|
1651
2428
|
};
|
|
1652
2429
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
1653
2430
|
const { model, range } = useSheetContext();
|
|
1654
|
-
const notifier = (0,
|
|
1655
|
-
(0,
|
|
2431
|
+
const notifier = (0, import_react2.useRef)();
|
|
2432
|
+
(0, import_react2.useEffect)(() => {
|
|
1656
2433
|
if (range) {
|
|
1657
|
-
notifier.current?.(
|
|
2434
|
+
notifier.current?.(rangeToA1Notation(range));
|
|
1658
2435
|
}
|
|
1659
2436
|
}, [
|
|
1660
2437
|
range
|
|
1661
2438
|
]);
|
|
1662
|
-
const extension = (0,
|
|
2439
|
+
const extension = (0, import_react2.useMemo)(() => [
|
|
1663
2440
|
editorKeys({
|
|
1664
2441
|
onNav,
|
|
1665
2442
|
onClose
|
|
1666
2443
|
}),
|
|
1667
2444
|
sheetExtension({
|
|
1668
|
-
functions: model.
|
|
2445
|
+
functions: model.graph.getFunctions()
|
|
1669
2446
|
}),
|
|
1670
2447
|
rangeExtension((fn) => notifier.current = fn)
|
|
1671
2448
|
], [
|
|
1672
2449
|
model
|
|
1673
2450
|
]);
|
|
1674
|
-
return /* @__PURE__ */
|
|
2451
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1675
2452
|
role: "cell",
|
|
1676
2453
|
style,
|
|
1677
|
-
className: (0,
|
|
2454
|
+
className: (0, import_react_ui_theme.mx)("z-20 flex", fragments.cellSelected),
|
|
1678
2455
|
onClick: (ev) => ev.stopPropagation()
|
|
1679
|
-
}, /* @__PURE__ */
|
|
2456
|
+
}, /* @__PURE__ */ import_react2.default.createElement(CellEditor, {
|
|
1680
2457
|
autoFocus: true,
|
|
1681
2458
|
value,
|
|
1682
2459
|
extension
|
|
@@ -1689,30 +2466,30 @@ var SheetStatusBar = () => {
|
|
|
1689
2466
|
if (cursor) {
|
|
1690
2467
|
value = model.getCellValue(cursor);
|
|
1691
2468
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1692
|
-
value = model.
|
|
2469
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1693
2470
|
isFormula = true;
|
|
1694
2471
|
} else if (value != null) {
|
|
1695
2472
|
value = String(value);
|
|
1696
2473
|
}
|
|
1697
2474
|
}
|
|
1698
|
-
return /* @__PURE__ */
|
|
1699
|
-
className: (0,
|
|
1700
|
-
}, /* @__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", {
|
|
1701
2478
|
className: "flex gap-4 items-center"
|
|
1702
|
-
}, /* @__PURE__ */
|
|
2479
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1703
2480
|
className: "flex w-16 items-center font-mono"
|
|
1704
|
-
}, range &&
|
|
2481
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1705
2482
|
className: "flex gap-2 items-center"
|
|
1706
|
-
}, /* @__PURE__ */
|
|
1707
|
-
className: (0,
|
|
1708
|
-
}), /* @__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", {
|
|
1709
2486
|
className: "font-mono"
|
|
1710
2487
|
}, value))));
|
|
1711
2488
|
};
|
|
1712
2489
|
var SheetDebug = () => {
|
|
1713
2490
|
const { model, cursor, range } = useSheetContext();
|
|
1714
|
-
const [, forceUpdate] = (0,
|
|
1715
|
-
(0,
|
|
2491
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2492
|
+
(0, import_react2.useEffect)(() => {
|
|
1716
2493
|
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
1717
2494
|
const handleUpdate = () => forceUpdate({});
|
|
1718
2495
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -1723,9 +2500,9 @@ var SheetDebug = () => {
|
|
|
1723
2500
|
}, [
|
|
1724
2501
|
model
|
|
1725
2502
|
]);
|
|
1726
|
-
return /* @__PURE__ */
|
|
1727
|
-
className: (0,
|
|
1728
|
-
}, /* @__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", {
|
|
1729
2506
|
className: "whitespace-pre-wrap"
|
|
1730
2507
|
}, JSON.stringify({
|
|
1731
2508
|
cursor,
|
|
@@ -1746,18 +2523,14 @@ var Sheet = {
|
|
|
1746
2523
|
StatusBar: SheetStatusBar,
|
|
1747
2524
|
Debug: SheetDebug
|
|
1748
2525
|
};
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Main, null)));
|
|
1761
|
-
};
|
|
1762
|
-
var SheetContainer_default = SheetContainer;
|
|
1763
|
-
//# sourceMappingURL=SheetContainer-IQT6TR4Z.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
|