@dxos/plugin-sheet 0.6.12-main.5cc132e → 0.6.12-main.78ddbdf
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-GNNVBNCX.mjs → chunk-6ZMQVB4Z.mjs} +358 -678
- 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/{node-esm/chunk-WUPTZUTX.mjs → browser/chunk-T3NJFTD4.mjs} +4 -14
- package/dist/lib/browser/chunk-T3NJFTD4.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-Y7ZMFBAP.mjs → chunk-U2JHW3L6.mjs} +819 -498
- 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 +58 -55
- 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-ZRQZFV5T.cjs → chunk-DD6FIXWC.cjs} +359 -679
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-KEOKUKAQ.cjs → chunk-OTTD7FBK.cjs} +875 -551
- package/dist/lib/node/chunk-OTTD7FBK.cjs.map +7 -0
- package/dist/lib/node/{chunk-VJU3NPUJ.cjs → chunk-Q3HBHPRL.cjs} +8 -19
- 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 +75 -64
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs +262 -0
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs.map +7 -0
- package/dist/lib/node-esm/{SheetContainer-Y7ZMFBAP.mjs → chunk-7HVSOTGA.mjs} +820 -498
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +7 -0
- package/dist/lib/{browser/chunk-WUPTZUTX.mjs → node-esm/chunk-BMNA27EX.mjs} +5 -14
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GNNVBNCX.mjs → chunk-D6KU5MI7.mjs} +359 -677
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JRL5LGCE.mjs → chunk-IU2L277A.mjs} +4 -5
- 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 +59 -55
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -1
- package/dist/lib/node-esm/types.mjs +5 -6
- 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 +7 -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/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 +4 -5
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- 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/{model → defs}/util.d.ts +8 -4
- 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 -4
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +9 -48
- 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/types.d.ts +12 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +41 -38
- package/src/SheetPlugin.tsx +39 -59
- package/src/components/CellEditor/CellEditor.stories.tsx +4 -3
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +3 -3
- 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 +36 -0
- package/src/components/GridSheet/GridSheet.tsx +153 -0
- package/src/components/GridSheet/util.ts +108 -0
- package/src/components/Sheet/Sheet.stories.tsx +41 -82
- package/src/components/Sheet/Sheet.tsx +12 -10
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +10 -80
- package/src/components/Sheet/threads.tsx +10 -6
- package/src/components/SheetContainer.tsx +2 -2
- package/src/components/Toolbar/Toolbar.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +7 -7
- package/src/{model → defs}/types.ts +23 -14
- package/src/{model → defs}/util.ts +49 -17
- 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 -4
- package/src/model/{model.ts → sheet-model.ts} +67 -184
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +66 -0
- package/src/types.ts +14 -12
- package/dist/lib/browser/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/browser/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/browser/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/browser/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/browser/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/browser/chunk-WUPTZUTX.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-KEOKUKAQ.cjs.map +0 -7
- package/dist/lib/node/chunk-57PB2HPY.cjs +0 -40
- package/dist/lib/node/chunk-57PB2HPY.cjs.map +0 -7
- package/dist/lib/node/chunk-6LWBQAQZ.cjs +0 -202
- package/dist/lib/node/chunk-6LWBQAQZ.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-VJU3NPUJ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZRQZFV5T.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/node-esm/testing.mjs +0 -92
- package/dist/lib/node-esm/testing.mjs.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.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 -49
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -99
- 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,49 +26,62 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
33
38
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
|
|
39
|
-
var import_react = __toESM(require("react"));
|
|
40
|
-
var import_app_framework = require("@dxos/app-framework");
|
|
41
|
-
var import_echo = require("@dxos/react-client/echo");
|
|
42
|
-
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
43
|
-
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");
|
|
44
43
|
var import_core = require("@dnd-kit/core");
|
|
45
44
|
var import_modifiers = require("@dnd-kit/modifiers");
|
|
46
45
|
var import_utilities = require("@dnd-kit/utilities");
|
|
47
|
-
var
|
|
46
|
+
var import_react = require("@phosphor-icons/react");
|
|
48
47
|
var import_re_resizable = require("re-resizable");
|
|
49
|
-
var
|
|
48
|
+
var import_react2 = __toESM(require("react"));
|
|
50
49
|
var import_react_dom = require("react-dom");
|
|
51
50
|
var import_react_resize_detector = require("react-resize-detector");
|
|
52
51
|
var import_async = require("@dxos/async");
|
|
53
|
-
var
|
|
52
|
+
var import_echo = require("@dxos/client/echo");
|
|
54
53
|
var import_log = require("@dxos/log");
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var import_react5 = require("react");
|
|
59
|
-
var import_react6 = __toESM(require("react"));
|
|
54
|
+
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
55
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
56
|
+
var import_react3 = require("react");
|
|
60
57
|
var import_invariant = require("@dxos/invariant");
|
|
61
|
-
var
|
|
58
|
+
var import_crypto = require("@dxos/crypto");
|
|
62
59
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
63
|
-
var
|
|
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");
|
|
64
67
|
var import_react7 = __toESM(require("react"));
|
|
65
|
-
var
|
|
68
|
+
var import_react8 = __toESM(require("react"));
|
|
69
|
+
var import_react9 = require("react");
|
|
66
70
|
var import_async2 = require("@dxos/async");
|
|
67
|
-
var
|
|
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");
|
|
68
82
|
var import_react_ui = require("@dxos/react-ui");
|
|
69
|
-
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
70
83
|
var import_view = require("@codemirror/view");
|
|
71
|
-
var
|
|
84
|
+
var import_react12 = __toESM(require("react"));
|
|
72
85
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
73
86
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
74
87
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
@@ -77,15 +90,156 @@ var import_state = require("@codemirror/state");
|
|
|
77
90
|
var import_view2 = require("@codemirror/view");
|
|
78
91
|
var import_highlight = require("@lezer/highlight");
|
|
79
92
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
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
|
+
};
|
|
89
243
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
90
244
|
var axisHeight = 34;
|
|
91
245
|
var minWidth = 40;
|
|
@@ -96,8 +250,8 @@ var defaultWidth = 200;
|
|
|
96
250
|
var defaultHeight = minHeight;
|
|
97
251
|
var CELL_DATA_KEY = "cell";
|
|
98
252
|
var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) => {
|
|
99
|
-
const [rowPositions, setRowPositions] = (0,
|
|
100
|
-
(0,
|
|
253
|
+
const [rowPositions, setRowPositions] = (0, import_react3.useState)([]);
|
|
254
|
+
(0, import_react3.useEffect)(() => {
|
|
101
255
|
if (!rowSizes) {
|
|
102
256
|
return;
|
|
103
257
|
}
|
|
@@ -116,8 +270,8 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
116
270
|
rows,
|
|
117
271
|
rowSizes
|
|
118
272
|
]);
|
|
119
|
-
const [columnPositions, setColumnPositions] = (0,
|
|
120
|
-
(0,
|
|
273
|
+
const [columnPositions, setColumnPositions] = (0, import_react3.useState)([]);
|
|
274
|
+
(0, import_react3.useEffect)(() => {
|
|
121
275
|
if (!columns) {
|
|
122
276
|
return;
|
|
123
277
|
}
|
|
@@ -127,7 +281,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
127
281
|
const left = x;
|
|
128
282
|
x += width2 - 1;
|
|
129
283
|
return {
|
|
130
|
-
|
|
284
|
+
col: i,
|
|
131
285
|
left,
|
|
132
286
|
width: width2
|
|
133
287
|
};
|
|
@@ -138,11 +292,11 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
138
292
|
]);
|
|
139
293
|
const height = rowPositions.length ? rowPositions[rowPositions.length - 1].top + rowPositions[rowPositions.length - 1].height : 0;
|
|
140
294
|
const width = columnPositions.length ? columnPositions[columnPositions.length - 1].left + columnPositions[columnPositions.length - 1].width : 0;
|
|
141
|
-
const [{ rowRange, columnRange }, setWindow] = (0,
|
|
295
|
+
const [{ rowRange, columnRange }, setWindow] = (0, import_react3.useState)({
|
|
142
296
|
rowRange: [],
|
|
143
297
|
columnRange: []
|
|
144
298
|
});
|
|
145
|
-
(0,
|
|
299
|
+
(0, import_react3.useEffect)(() => {
|
|
146
300
|
const handleScroll = () => {
|
|
147
301
|
if (!scroller) {
|
|
148
302
|
return;
|
|
@@ -202,12 +356,12 @@ var getCellAtPointer = (event) => {
|
|
|
202
356
|
if (root) {
|
|
203
357
|
const value = root.dataset[CELL_DATA_KEY];
|
|
204
358
|
if (value) {
|
|
205
|
-
return
|
|
359
|
+
return addressFromA1Notation(value);
|
|
206
360
|
}
|
|
207
361
|
}
|
|
208
362
|
};
|
|
209
363
|
var getCellElement = (root, cell) => {
|
|
210
|
-
const pos =
|
|
364
|
+
const pos = addressToA1Notation(cell);
|
|
211
365
|
return root.querySelector(`[data-${CELL_DATA_KEY}="${pos}"]`);
|
|
212
366
|
};
|
|
213
367
|
var handleNav = (ev, cursor, range, size) => {
|
|
@@ -229,14 +383,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
229
383
|
break;
|
|
230
384
|
}
|
|
231
385
|
case "ArrowLeft": {
|
|
232
|
-
if (opposite.
|
|
233
|
-
opposite.
|
|
386
|
+
if (opposite.col > 0) {
|
|
387
|
+
opposite.col -= 1;
|
|
234
388
|
}
|
|
235
389
|
break;
|
|
236
390
|
}
|
|
237
391
|
case "ArrowRight": {
|
|
238
|
-
if (opposite.
|
|
239
|
-
opposite.
|
|
392
|
+
if (opposite.col < size.numCols - 1) {
|
|
393
|
+
opposite.col += 1;
|
|
240
394
|
}
|
|
241
395
|
break;
|
|
242
396
|
}
|
|
@@ -254,18 +408,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
254
408
|
cursor: next
|
|
255
409
|
};
|
|
256
410
|
};
|
|
257
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
411
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
258
412
|
switch (ev.key) {
|
|
259
413
|
case "ArrowUp":
|
|
260
414
|
if (cursor === void 0) {
|
|
261
415
|
return {
|
|
262
416
|
row: 0,
|
|
263
|
-
|
|
417
|
+
col: 0
|
|
264
418
|
};
|
|
265
419
|
} else if (cursor.row > 0) {
|
|
266
420
|
return {
|
|
267
421
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
268
|
-
|
|
422
|
+
col: cursor.col
|
|
269
423
|
};
|
|
270
424
|
}
|
|
271
425
|
break;
|
|
@@ -273,12 +427,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
273
427
|
if (cursor === void 0) {
|
|
274
428
|
return {
|
|
275
429
|
row: 0,
|
|
276
|
-
|
|
430
|
+
col: 0
|
|
277
431
|
};
|
|
278
432
|
} else if (cursor.row < numRows - 1) {
|
|
279
433
|
return {
|
|
280
434
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
281
|
-
|
|
435
|
+
col: cursor.col
|
|
282
436
|
};
|
|
283
437
|
}
|
|
284
438
|
break;
|
|
@@ -286,12 +440,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
286
440
|
if (cursor === void 0) {
|
|
287
441
|
return {
|
|
288
442
|
row: 0,
|
|
289
|
-
|
|
443
|
+
col: 0
|
|
290
444
|
};
|
|
291
|
-
} else if (cursor.
|
|
445
|
+
} else if (cursor.col > 0) {
|
|
292
446
|
return {
|
|
293
447
|
row: cursor.row,
|
|
294
|
-
|
|
448
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
295
449
|
};
|
|
296
450
|
}
|
|
297
451
|
break;
|
|
@@ -299,30 +453,30 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
299
453
|
if (cursor === void 0) {
|
|
300
454
|
return {
|
|
301
455
|
row: 0,
|
|
302
|
-
|
|
456
|
+
col: 0
|
|
303
457
|
};
|
|
304
|
-
} else if (cursor.
|
|
458
|
+
} else if (cursor.col < numCols - 1) {
|
|
305
459
|
return {
|
|
306
460
|
row: cursor.row,
|
|
307
|
-
|
|
461
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
308
462
|
};
|
|
309
463
|
}
|
|
310
464
|
break;
|
|
311
465
|
case "Home":
|
|
312
466
|
return {
|
|
313
467
|
row: 0,
|
|
314
|
-
|
|
468
|
+
col: 0
|
|
315
469
|
};
|
|
316
470
|
case "End":
|
|
317
471
|
return {
|
|
318
472
|
row: numRows - 1,
|
|
319
|
-
|
|
473
|
+
col: numCols - 1
|
|
320
474
|
};
|
|
321
475
|
}
|
|
322
476
|
};
|
|
323
477
|
var useRangeSelect = (cb) => {
|
|
324
|
-
const [from, setFrom] = (0,
|
|
325
|
-
const [to, setTo] = (0,
|
|
478
|
+
const [from, setFrom] = (0, import_react4.useState)();
|
|
479
|
+
const [to, setTo] = (0, import_react4.useState)();
|
|
326
480
|
const onMouseDown = (ev) => {
|
|
327
481
|
const current = getCellAtPointer(ev);
|
|
328
482
|
setFrom(current);
|
|
@@ -335,7 +489,7 @@ var useRangeSelect = (cb) => {
|
|
|
335
489
|
const onMouseMove = (ev) => {
|
|
336
490
|
if (from) {
|
|
337
491
|
let current = getCellAtPointer(ev);
|
|
338
|
-
if (
|
|
492
|
+
if (posEquals(current, from)) {
|
|
339
493
|
current = void 0;
|
|
340
494
|
}
|
|
341
495
|
setTo(current);
|
|
@@ -348,7 +502,7 @@ var useRangeSelect = (cb) => {
|
|
|
348
502
|
const onMouseUp = (ev) => {
|
|
349
503
|
if (from) {
|
|
350
504
|
let current = getCellAtPointer(ev);
|
|
351
|
-
if (
|
|
505
|
+
if (posEquals(current, from)) {
|
|
352
506
|
current = void 0;
|
|
353
507
|
}
|
|
354
508
|
setFrom(void 0);
|
|
@@ -372,7 +526,7 @@ var useRangeSelect = (cb) => {
|
|
|
372
526
|
};
|
|
373
527
|
};
|
|
374
528
|
var createDecorations = () => {
|
|
375
|
-
const { decorations } = (0,
|
|
529
|
+
const { decorations } = (0, import_echo_schema2.create)({
|
|
376
530
|
decorations: {}
|
|
377
531
|
});
|
|
378
532
|
const addDecoration = (cellIndex, decorator) => {
|
|
@@ -407,27 +561,43 @@ var createDecorations = () => {
|
|
|
407
561
|
getAllDecorations
|
|
408
562
|
};
|
|
409
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
|
+
};
|
|
410
580
|
var FormattingModel = class {
|
|
411
|
-
constructor(
|
|
412
|
-
this.
|
|
581
|
+
constructor(_model) {
|
|
582
|
+
this._model = _model;
|
|
413
583
|
}
|
|
414
584
|
/**
|
|
415
585
|
* Get formatted string value and className for cell.
|
|
416
586
|
*/
|
|
417
587
|
getFormatting(cell) {
|
|
418
|
-
const value = this.
|
|
588
|
+
const value = this._model.getValue(cell);
|
|
419
589
|
if (value === void 0 || value === null) {
|
|
420
590
|
return {};
|
|
421
591
|
}
|
|
422
592
|
const locales = void 0;
|
|
423
|
-
const idx =
|
|
424
|
-
let formatting = this.
|
|
593
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
594
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
425
595
|
const classNames = [
|
|
426
596
|
...formatting?.classNames ?? []
|
|
427
597
|
];
|
|
428
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
429
|
-
const range =
|
|
430
|
-
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)) {
|
|
431
601
|
if (_formatting.classNames) {
|
|
432
602
|
classNames.push(..._formatting.classNames);
|
|
433
603
|
}
|
|
@@ -437,9 +607,9 @@ var FormattingModel = class {
|
|
|
437
607
|
}
|
|
438
608
|
}
|
|
439
609
|
const defaultNumber = "justify-end font-mono";
|
|
440
|
-
const type = formatting?.type ?? this.
|
|
610
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
441
611
|
switch (type) {
|
|
442
|
-
case
|
|
612
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Boolean: {
|
|
443
613
|
return {
|
|
444
614
|
value: value.toLocaleString().toUpperCase(),
|
|
445
615
|
classNames: [
|
|
@@ -451,7 +621,7 @@ var FormattingModel = class {
|
|
|
451
621
|
//
|
|
452
622
|
// Numbers.
|
|
453
623
|
//
|
|
454
|
-
case
|
|
624
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Number: {
|
|
455
625
|
return {
|
|
456
626
|
value: value.toLocaleString(locales),
|
|
457
627
|
classNames: [
|
|
@@ -460,7 +630,7 @@ var FormattingModel = class {
|
|
|
460
630
|
]
|
|
461
631
|
};
|
|
462
632
|
}
|
|
463
|
-
case
|
|
633
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Percent: {
|
|
464
634
|
return {
|
|
465
635
|
value: value * 100 + "%",
|
|
466
636
|
classNames: [
|
|
@@ -469,7 +639,7 @@ var FormattingModel = class {
|
|
|
469
639
|
]
|
|
470
640
|
};
|
|
471
641
|
}
|
|
472
|
-
case
|
|
642
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Currency: {
|
|
473
643
|
return {
|
|
474
644
|
value: value.toLocaleString(locales, {
|
|
475
645
|
style: "currency",
|
|
@@ -486,22 +656,22 @@ var FormattingModel = class {
|
|
|
486
656
|
//
|
|
487
657
|
// Dates.
|
|
488
658
|
//
|
|
489
|
-
case
|
|
490
|
-
const date = this.
|
|
659
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.DateTime: {
|
|
660
|
+
const date = this._model.toLocalDate(value);
|
|
491
661
|
return {
|
|
492
662
|
value: date.toLocaleString(locales),
|
|
493
663
|
classNames
|
|
494
664
|
};
|
|
495
665
|
}
|
|
496
|
-
case
|
|
497
|
-
const date = this.
|
|
666
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Date: {
|
|
667
|
+
const date = this._model.toLocalDate(value);
|
|
498
668
|
return {
|
|
499
669
|
value: date.toLocaleDateString(locales),
|
|
500
670
|
classNames
|
|
501
671
|
};
|
|
502
672
|
}
|
|
503
|
-
case
|
|
504
|
-
const date = this.
|
|
673
|
+
case import_chunk_Q3HBHPRL.ValueTypeEnum.Time: {
|
|
674
|
+
const date = this._model.toLocalDate(value);
|
|
505
675
|
return {
|
|
506
676
|
value: date.toLocaleTimeString(locales),
|
|
507
677
|
classNames
|
|
@@ -516,84 +686,414 @@ var FormattingModel = class {
|
|
|
516
686
|
}
|
|
517
687
|
}
|
|
518
688
|
};
|
|
519
|
-
var
|
|
520
|
-
var
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
A: [
|
|
529
|
-
"context",
|
|
530
|
-
""
|
|
531
|
-
]
|
|
532
|
-
});
|
|
533
|
-
return context;
|
|
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
|
|
534
698
|
};
|
|
535
|
-
var
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
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
|
+
};
|
|
705
|
+
};
|
|
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
|
+
}
|
|
539
836
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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;
|
|
865
|
+
}
|
|
866
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
867
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
543
868
|
} else {
|
|
544
|
-
return
|
|
869
|
+
return String(value);
|
|
545
870
|
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
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();
|
|
553
885
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
886
|
+
return value;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Get value type.
|
|
890
|
+
*/
|
|
891
|
+
getValueType(cell) {
|
|
892
|
+
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
893
|
+
const type = this._node.hf.getCellValueDetailedType(addr);
|
|
894
|
+
return typeMap[type];
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Sets the value, updating the sheet and engine.
|
|
898
|
+
*/
|
|
899
|
+
setValue(cell, value) {
|
|
900
|
+
if (this._options.readonly) {
|
|
901
|
+
throw new ReadonlyException();
|
|
902
|
+
}
|
|
903
|
+
let refresh = false;
|
|
904
|
+
if (cell.row >= this._sheet.rows.length) {
|
|
905
|
+
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
906
|
+
refresh = true;
|
|
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];
|
|
557
927
|
} else {
|
|
558
|
-
|
|
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
|
+
};
|
|
559
934
|
}
|
|
560
|
-
}
|
|
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
|
+
}
|
|
561
1039
|
};
|
|
562
|
-
var
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
const
|
|
569
|
-
(0,
|
|
1040
|
+
var useFormattingModel = (model) => {
|
|
1041
|
+
return (0, import_react9.useMemo)(() => model && new FormattingModel(model), [
|
|
1042
|
+
model
|
|
1043
|
+
]);
|
|
1044
|
+
};
|
|
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
|
+
}
|
|
570
1052
|
let model2;
|
|
571
|
-
let formatting2;
|
|
572
1053
|
const t = setTimeout(async () => {
|
|
573
|
-
model2 = new
|
|
574
|
-
readonly
|
|
575
|
-
mapFormulaBindingToId,
|
|
576
|
-
mapFormulaBindingFromId
|
|
1054
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1055
|
+
readonly
|
|
577
1056
|
});
|
|
578
|
-
await model2.
|
|
579
|
-
|
|
580
|
-
setModels([
|
|
581
|
-
model2,
|
|
582
|
-
formatting2
|
|
583
|
-
]);
|
|
1057
|
+
await model2.open();
|
|
1058
|
+
setModel(model2);
|
|
584
1059
|
});
|
|
585
1060
|
return () => {
|
|
586
1061
|
clearTimeout(t);
|
|
587
|
-
void model2?.
|
|
1062
|
+
void model2?.close();
|
|
588
1063
|
};
|
|
589
1064
|
}, [
|
|
1065
|
+
space,
|
|
1066
|
+
sheet,
|
|
590
1067
|
graph,
|
|
591
1068
|
readonly
|
|
592
1069
|
]);
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
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, {
|
|
597
1097
|
value: {
|
|
598
1098
|
model,
|
|
599
1099
|
formatting,
|
|
@@ -610,18 +1110,18 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
610
1110
|
}, children);
|
|
611
1111
|
};
|
|
612
1112
|
var CommentIndicator = () => {
|
|
613
|
-
return /* @__PURE__ */
|
|
1113
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
614
1114
|
role: "none",
|
|
615
1115
|
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
616
1116
|
});
|
|
617
1117
|
};
|
|
618
1118
|
var ThreadedCellWrapper = ({ children }) => {
|
|
619
|
-
const dispatch = (0,
|
|
620
|
-
const [isHovered, setIsHovered] =
|
|
621
|
-
const { t } = (0, import_react_ui.useTranslation)(
|
|
622
|
-
const handleClick =
|
|
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) => {
|
|
623
1123
|
void dispatch({
|
|
624
|
-
action:
|
|
1124
|
+
action: import_app_framework.LayoutAction.SET_LAYOUT,
|
|
625
1125
|
data: {
|
|
626
1126
|
element: "complementary",
|
|
627
1127
|
state: true
|
|
@@ -630,22 +1130,22 @@ var ThreadedCellWrapper = ({ children }) => {
|
|
|
630
1130
|
}, [
|
|
631
1131
|
dispatch
|
|
632
1132
|
]);
|
|
633
|
-
return /* @__PURE__ */
|
|
1133
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
634
1134
|
role: "none",
|
|
635
|
-
className:
|
|
1135
|
+
className: "relative h-full is-full",
|
|
636
1136
|
onMouseEnter: () => {
|
|
637
1137
|
setIsHovered(true);
|
|
638
1138
|
},
|
|
639
1139
|
onMouseLeave: () => {
|
|
640
1140
|
setIsHovered(false);
|
|
641
1141
|
}
|
|
642
|
-
}, /* @__PURE__ */
|
|
1142
|
+
}, /* @__PURE__ */ import_react11.default.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
643
1143
|
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
644
|
-
}, /* @__PURE__ */
|
|
1144
|
+
}, /* @__PURE__ */ import_react11.default.createElement("button", {
|
|
645
1145
|
className: "ch-button text-xs min-bs-0 p-1",
|
|
646
1146
|
onClick: handleClick,
|
|
647
1147
|
"aria-label": t("open comment for sheet cell")
|
|
648
|
-
}, /* @__PURE__ */
|
|
1148
|
+
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui.Icon, {
|
|
649
1149
|
icon: "ph--chat--regular",
|
|
650
1150
|
"aria-hidden": true
|
|
651
1151
|
}))), children);
|
|
@@ -654,18 +1154,18 @@ var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
|
654
1154
|
return {
|
|
655
1155
|
type: "comment",
|
|
656
1156
|
cellIndex,
|
|
657
|
-
decorate: (props) => /* @__PURE__ */
|
|
1157
|
+
decorate: (props) => /* @__PURE__ */ import_react11.default.createElement(ThreadedCellWrapper, props)
|
|
658
1158
|
};
|
|
659
1159
|
};
|
|
660
1160
|
var useUpdateCursorOnThreadSelection = () => {
|
|
661
1161
|
const { setCursor, model } = useSheetContext();
|
|
662
|
-
const handleScrollIntoView = (0,
|
|
1162
|
+
const handleScrollIntoView = (0, import_react11.useCallback)(({ action, data }) => {
|
|
663
1163
|
switch (action) {
|
|
664
|
-
case
|
|
665
|
-
if (!data?.id || data?.cursor === void 0 || data?.id !== (0,
|
|
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)) {
|
|
666
1166
|
return;
|
|
667
1167
|
}
|
|
668
|
-
const cellAddress =
|
|
1168
|
+
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
669
1169
|
setCursor(cellAddress);
|
|
670
1170
|
}
|
|
671
1171
|
}
|
|
@@ -673,31 +1173,31 @@ var useUpdateCursorOnThreadSelection = () => {
|
|
|
673
1173
|
model.sheet,
|
|
674
1174
|
setCursor
|
|
675
1175
|
]);
|
|
676
|
-
(0,
|
|
1176
|
+
(0, import_app_framework.useIntentResolver)(import_chunk_BNARJ5GM.SHEET_PLUGIN, handleScrollIntoView);
|
|
677
1177
|
};
|
|
678
1178
|
var useSelectThreadOnCursorChange = () => {
|
|
679
1179
|
const { cursor, model } = useSheetContext();
|
|
680
|
-
const dispatch = (0,
|
|
681
|
-
const activeThreads = (0,
|
|
1180
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1181
|
+
const activeThreads = (0, import_react11.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
682
1182
|
JSON.stringify(model.sheet.threads)
|
|
683
1183
|
]);
|
|
684
|
-
const activeThreadAddresses = (0,
|
|
1184
|
+
const activeThreadAddresses = (0, import_react11.useMemo)(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
685
1185
|
activeThreads,
|
|
686
1186
|
model.sheet
|
|
687
1187
|
]);
|
|
688
|
-
const selectClosestThread = (0,
|
|
1188
|
+
const selectClosestThread = (0, import_react11.useCallback)((cellAddress) => {
|
|
689
1189
|
if (!cellAddress || !activeThreads) {
|
|
690
1190
|
return;
|
|
691
1191
|
}
|
|
692
|
-
const closestThreadAnchor =
|
|
1192
|
+
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
693
1193
|
if (closestThreadAnchor) {
|
|
694
|
-
const closestThread = activeThreads.find((thread) => thread && thread.anchor ===
|
|
1194
|
+
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
695
1195
|
if (closestThread) {
|
|
696
1196
|
void dispatch([
|
|
697
1197
|
{
|
|
698
1198
|
action: "dxos.org/plugin/thread/action/select",
|
|
699
1199
|
data: {
|
|
700
|
-
current: (0,
|
|
1200
|
+
current: (0, import_echo2.fullyQualifiedId)(closestThread)
|
|
701
1201
|
}
|
|
702
1202
|
}
|
|
703
1203
|
]);
|
|
@@ -709,12 +1209,12 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
709
1209
|
activeThreadAddresses,
|
|
710
1210
|
model.sheet
|
|
711
1211
|
]);
|
|
712
|
-
const debounced = (0,
|
|
713
|
-
return (0,
|
|
1212
|
+
const debounced = (0, import_react11.useMemo)(() => {
|
|
1213
|
+
return (0, import_async3.debounce)((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
714
1214
|
}, [
|
|
715
1215
|
selectClosestThread
|
|
716
1216
|
]);
|
|
717
|
-
(0,
|
|
1217
|
+
(0, import_react11.useEffect)(() => {
|
|
718
1218
|
if (!cursor) {
|
|
719
1219
|
return;
|
|
720
1220
|
}
|
|
@@ -726,13 +1226,13 @@ var useSelectThreadOnCursorChange = () => {
|
|
|
726
1226
|
};
|
|
727
1227
|
var useThreadDecorations = () => {
|
|
728
1228
|
const { decorations, model } = useSheetContext();
|
|
729
|
-
const sheet = (0,
|
|
1229
|
+
const sheet = (0, import_react11.useMemo)(() => model.sheet, [
|
|
730
1230
|
model.sheet
|
|
731
1231
|
]);
|
|
732
|
-
const sheetId = (0,
|
|
1232
|
+
const sheetId = (0, import_react11.useMemo)(() => (0, import_echo2.fullyQualifiedId)(sheet), [
|
|
733
1233
|
sheet
|
|
734
1234
|
]);
|
|
735
|
-
(0,
|
|
1235
|
+
(0, import_react11.useEffect)(() => {
|
|
736
1236
|
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
737
1237
|
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
738
1238
|
if (!sheet.threads) {
|
|
@@ -842,20 +1342,60 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
842
1342
|
{
|
|
843
1343
|
key: "Enter",
|
|
844
1344
|
run: (editor) => {
|
|
845
|
-
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
|
+
});
|
|
846
1371
|
return true;
|
|
847
1372
|
}
|
|
848
1373
|
},
|
|
849
1374
|
{
|
|
850
1375
|
key: "Escape",
|
|
851
1376
|
run: () => {
|
|
852
|
-
onClose(void 0
|
|
1377
|
+
onClose(void 0, {
|
|
1378
|
+
key: "Escape"
|
|
1379
|
+
});
|
|
853
1380
|
return true;
|
|
854
1381
|
}
|
|
855
1382
|
}
|
|
856
1383
|
]);
|
|
857
1384
|
};
|
|
858
|
-
var
|
|
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 }) => {
|
|
859
1399
|
const { themeMode } = (0, import_react_ui2.useThemeContext)();
|
|
860
1400
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
861
1401
|
return {
|
|
@@ -882,21 +1422,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
882
1422
|
themeMode,
|
|
883
1423
|
slots: {
|
|
884
1424
|
editor: {
|
|
885
|
-
className:
|
|
1425
|
+
className: editorVariants[variant].editor
|
|
886
1426
|
},
|
|
887
1427
|
content: {
|
|
888
|
-
className:
|
|
1428
|
+
className: editorVariants[variant].content
|
|
889
1429
|
}
|
|
890
1430
|
}
|
|
891
1431
|
})
|
|
892
1432
|
]
|
|
893
1433
|
};
|
|
894
1434
|
}, [
|
|
895
|
-
extension
|
|
1435
|
+
extension,
|
|
1436
|
+
autoFocus,
|
|
1437
|
+
value,
|
|
1438
|
+
variant,
|
|
1439
|
+
onBlur
|
|
896
1440
|
]);
|
|
897
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
898
1442
|
ref: parentRef,
|
|
899
|
-
className:
|
|
1443
|
+
className: editorVariants[variant].root,
|
|
1444
|
+
style: box,
|
|
1445
|
+
...gridId && {
|
|
1446
|
+
"data-grid": gridId
|
|
1447
|
+
}
|
|
900
1448
|
});
|
|
901
1449
|
};
|
|
902
1450
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -1009,13 +1557,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
1009
1557
|
// NOTE: Useful for debugging.
|
|
1010
1558
|
closeOnBlur: false,
|
|
1011
1559
|
icons: false,
|
|
1012
|
-
tooltipClass: () => (0,
|
|
1013
|
-
// TODO(burdon): Factor out fragments.
|
|
1014
|
-
// TODO(burdon): Size to make width same as column.
|
|
1015
|
-
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
1016
|
-
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
1017
|
-
"border-separator"
|
|
1018
|
-
)
|
|
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")
|
|
1019
1561
|
}),
|
|
1020
1562
|
import_view2.keymap.of([
|
|
1021
1563
|
{
|
|
@@ -1102,7 +1644,7 @@ var visitTree = (node, callback) => {
|
|
|
1102
1644
|
}
|
|
1103
1645
|
return false;
|
|
1104
1646
|
};
|
|
1105
|
-
var
|
|
1647
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
1106
1648
|
var fragments = {
|
|
1107
1649
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
1108
1650
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -1110,23 +1652,23 @@ var fragments = {
|
|
|
1110
1652
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
1111
1653
|
};
|
|
1112
1654
|
var SheetRoot = ({ children, ...props }) => {
|
|
1113
|
-
return /* @__PURE__ */
|
|
1655
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContextProvider, props, children);
|
|
1114
1656
|
};
|
|
1115
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
1657
|
+
var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
1116
1658
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
1117
1659
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
1118
1660
|
useThreads();
|
|
1119
|
-
const [rows, setRows] = (0,
|
|
1661
|
+
const [rows, setRows] = (0, import_react2.useState)([
|
|
1120
1662
|
...model.sheet.rows
|
|
1121
1663
|
]);
|
|
1122
|
-
const [columns, setColumns] = (0,
|
|
1664
|
+
const [columns, setColumns] = (0, import_react2.useState)([
|
|
1123
1665
|
...model.sheet.columns
|
|
1124
1666
|
]);
|
|
1125
|
-
(0,
|
|
1126
|
-
const rowsAccessor = (0,
|
|
1667
|
+
(0, import_react2.useEffect)(() => {
|
|
1668
|
+
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1127
1669
|
"rows"
|
|
1128
1670
|
]);
|
|
1129
|
-
const columnsAccessor = (0,
|
|
1671
|
+
const columnsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1130
1672
|
"columns"
|
|
1131
1673
|
]);
|
|
1132
1674
|
const handleUpdate = (0, import_async.debounce)(() => {
|
|
@@ -1147,41 +1689,41 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1147
1689
|
}, [
|
|
1148
1690
|
model
|
|
1149
1691
|
]);
|
|
1150
|
-
(0,
|
|
1692
|
+
(0, import_react2.useEffect)(() => {
|
|
1151
1693
|
model.reset();
|
|
1152
1694
|
}, [
|
|
1153
1695
|
rows,
|
|
1154
1696
|
columns
|
|
1155
1697
|
]);
|
|
1156
1698
|
const handleMoveRows = (from, to, num = 1) => {
|
|
1157
|
-
const cursorIdx = cursor ?
|
|
1699
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
1158
1700
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
1159
1701
|
model.sheet.rows.splice(to, 0, rows2);
|
|
1160
1702
|
if (cursorIdx) {
|
|
1161
|
-
setCursor(
|
|
1703
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
1162
1704
|
}
|
|
1163
1705
|
setRows([
|
|
1164
1706
|
...model.sheet.rows
|
|
1165
1707
|
]);
|
|
1166
1708
|
};
|
|
1167
1709
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
1168
|
-
const cursorIdx = cursor ?
|
|
1710
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
1169
1711
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
1170
1712
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
1171
1713
|
if (cursorIdx) {
|
|
1172
|
-
setCursor(
|
|
1714
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
1173
1715
|
}
|
|
1174
1716
|
setColumns([
|
|
1175
1717
|
...model.sheet.columns
|
|
1176
1718
|
]);
|
|
1177
1719
|
};
|
|
1178
|
-
const [rowSizes, setRowSizes] = (0,
|
|
1179
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
1180
|
-
(0,
|
|
1181
|
-
const rowAccessor = (0,
|
|
1720
|
+
const [rowSizes, setRowSizes] = (0, import_react2.useState)();
|
|
1721
|
+
const [columnSizes, setColumnSizes] = (0, import_react2.useState)();
|
|
1722
|
+
(0, import_react2.useEffect)(() => {
|
|
1723
|
+
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1182
1724
|
"rowMeta"
|
|
1183
1725
|
]);
|
|
1184
|
-
const columnAccessor = (0,
|
|
1726
|
+
const columnAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1185
1727
|
"columnMeta"
|
|
1186
1728
|
]);
|
|
1187
1729
|
const handleUpdate = (0, import_async.debounce)(() => {
|
|
@@ -1226,54 +1768,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1226
1768
|
}));
|
|
1227
1769
|
}
|
|
1228
1770
|
};
|
|
1229
|
-
return /* @__PURE__ */
|
|
1771
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1230
1772
|
role: "none",
|
|
1231
|
-
className: (0,
|
|
1232
|
-
}, /* @__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, {
|
|
1233
1775
|
onClick: () => {
|
|
1234
1776
|
setCursor(void 0);
|
|
1235
1777
|
setRange(void 0);
|
|
1236
1778
|
setEditing(false);
|
|
1237
1779
|
}
|
|
1238
|
-
}), /* @__PURE__ */
|
|
1780
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetColumns, {
|
|
1239
1781
|
ref: columnsRef,
|
|
1240
1782
|
columns,
|
|
1241
1783
|
sizes: columnSizes,
|
|
1242
|
-
selected: cursor?.
|
|
1243
|
-
onSelect: (
|
|
1784
|
+
selected: cursor?.col,
|
|
1785
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1244
1786
|
row: -1,
|
|
1245
|
-
|
|
1787
|
+
col
|
|
1246
1788
|
}),
|
|
1247
1789
|
onResize: handleResizeColumn,
|
|
1248
1790
|
onMove: handleMoveColumns
|
|
1249
|
-
}), /* @__PURE__ */
|
|
1791
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetRows, {
|
|
1250
1792
|
ref: rowsRef,
|
|
1251
1793
|
rows,
|
|
1252
1794
|
sizes: rowSizes,
|
|
1253
1795
|
selected: cursor?.row,
|
|
1254
1796
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1255
1797
|
row,
|
|
1256
|
-
|
|
1798
|
+
col: -1
|
|
1257
1799
|
}),
|
|
1258
1800
|
onResize: handleResizeRow,
|
|
1259
1801
|
onMove: handleMoveRows
|
|
1260
|
-
}), /* @__PURE__ */
|
|
1802
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetGrid, {
|
|
1261
1803
|
ref: contentRef,
|
|
1262
1804
|
size: {
|
|
1263
1805
|
numRows: numRows ?? rows.length,
|
|
1264
|
-
|
|
1806
|
+
numCols: numCols ?? columns.length
|
|
1265
1807
|
},
|
|
1266
1808
|
rows,
|
|
1267
1809
|
columns,
|
|
1268
1810
|
rowSizes,
|
|
1269
1811
|
columnSizes
|
|
1270
|
-
}), /* @__PURE__ */
|
|
1812
|
+
}), /* @__PURE__ */ import_react2.default.createElement(GridCorner, null), /* @__PURE__ */ import_react2.default.createElement(SheetStatusBar, null));
|
|
1271
1813
|
});
|
|
1272
1814
|
var useScrollHandlers = () => {
|
|
1273
|
-
const rowsRef = (0,
|
|
1274
|
-
const columnsRef = (0,
|
|
1275
|
-
const contentRef = (0,
|
|
1276
|
-
(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)(() => {
|
|
1277
1819
|
const handleRowsScroll = (ev) => {
|
|
1278
1820
|
const { scrollTop } = ev.target;
|
|
1279
1821
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1310,13 +1852,13 @@ var useScrollHandlers = () => {
|
|
|
1310
1852
|
};
|
|
1311
1853
|
};
|
|
1312
1854
|
var GridCorner = (props) => {
|
|
1313
|
-
return /* @__PURE__ */
|
|
1855
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1314
1856
|
className: fragments.axis,
|
|
1315
1857
|
...props
|
|
1316
1858
|
});
|
|
1317
1859
|
};
|
|
1318
1860
|
var MovingOverlay = ({ label }) => {
|
|
1319
|
-
return /* @__PURE__ */
|
|
1861
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1320
1862
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1321
1863
|
}, label);
|
|
1322
1864
|
};
|
|
@@ -1327,7 +1869,7 @@ var touchConstraints = {
|
|
|
1327
1869
|
delay: 250,
|
|
1328
1870
|
tolerance: 5
|
|
1329
1871
|
};
|
|
1330
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
1872
|
+
var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1331
1873
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1332
1874
|
activationConstraint: mouseConstraints
|
|
1333
1875
|
});
|
|
@@ -1336,7 +1878,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1336
1878
|
});
|
|
1337
1879
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1338
1880
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1339
|
-
const [active, setActive] = (0,
|
|
1881
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1340
1882
|
const handleDragStart = ({ active: active2 }) => {
|
|
1341
1883
|
setActive(active2);
|
|
1342
1884
|
};
|
|
@@ -1360,18 +1902,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1360
1902
|
}
|
|
1361
1903
|
return transform;
|
|
1362
1904
|
};
|
|
1363
|
-
return /* @__PURE__ */
|
|
1905
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1364
1906
|
className: "relative flex grow overflow-hidden"
|
|
1365
|
-
}, /* @__PURE__ */
|
|
1366
|
-
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"),
|
|
1367
1909
|
style: {
|
|
1368
1910
|
width: axisWidth
|
|
1369
1911
|
}
|
|
1370
|
-
}), /* @__PURE__ */
|
|
1912
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1371
1913
|
ref: forwardRef2,
|
|
1372
1914
|
role: "rowheader",
|
|
1373
1915
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1374
|
-
}, /* @__PURE__ */
|
|
1916
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1375
1917
|
sensors,
|
|
1376
1918
|
modifiers: [
|
|
1377
1919
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -1379,12 +1921,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1379
1921
|
],
|
|
1380
1922
|
onDragStart: handleDragStart,
|
|
1381
1923
|
onDragEnd: handleDragEnd
|
|
1382
|
-
}, /* @__PURE__ */
|
|
1924
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1383
1925
|
className: "flex flex-col",
|
|
1384
1926
|
style: {
|
|
1385
1927
|
width: axisWidth
|
|
1386
1928
|
}
|
|
1387
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1929
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridRowCell, {
|
|
1388
1930
|
key: idx,
|
|
1389
1931
|
idx,
|
|
1390
1932
|
index,
|
|
@@ -1394,7 +1936,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1394
1936
|
selected: selected === index,
|
|
1395
1937
|
onResize,
|
|
1396
1938
|
onSelect
|
|
1397
|
-
}))), /* @__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, {
|
|
1398
1940
|
label: String(active.data.current.index + 1)
|
|
1399
1941
|
})), document.body))));
|
|
1400
1942
|
});
|
|
@@ -1412,9 +1954,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1412
1954
|
}
|
|
1413
1955
|
});
|
|
1414
1956
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1415
|
-
const [initialSize, setInitialSize] = (0,
|
|
1416
|
-
const [resizing, setResizing] = (0,
|
|
1417
|
-
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)();
|
|
1418
1960
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1419
1961
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
1420
1962
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -1435,7 +1977,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1435
1977
|
onResize?.(idx, initialSize + height, true);
|
|
1436
1978
|
setResizing(false);
|
|
1437
1979
|
};
|
|
1438
|
-
return /* @__PURE__ */
|
|
1980
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1439
1981
|
enable: {
|
|
1440
1982
|
bottom: resize
|
|
1441
1983
|
},
|
|
@@ -1447,21 +1989,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1447
1989
|
onResizeStart: handleResizeStart,
|
|
1448
1990
|
onResize: handleResize,
|
|
1449
1991
|
onResizeStop: handleResizeStop
|
|
1450
|
-
}, /* @__PURE__ */
|
|
1992
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1451
1993
|
ref: setNodeRef,
|
|
1452
1994
|
...attributes,
|
|
1453
1995
|
...listeners,
|
|
1454
|
-
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),
|
|
1455
1997
|
onClick: () => onSelect?.(index)
|
|
1456
|
-
}, /* @__PURE__ */
|
|
1998
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1457
1999
|
className: "flex w-full justify-center"
|
|
1458
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2000
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1459
2001
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1460
|
-
}), resizing && /* @__PURE__ */
|
|
2002
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1461
2003
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1462
2004
|
})));
|
|
1463
2005
|
};
|
|
1464
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
2006
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1465
2007
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1466
2008
|
activationConstraint: mouseConstraints
|
|
1467
2009
|
});
|
|
@@ -1470,7 +2012,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1470
2012
|
});
|
|
1471
2013
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1472
2014
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1473
|
-
const [active, setActive] = (0,
|
|
2015
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1474
2016
|
const handleDragStart = ({ active: active2 }) => {
|
|
1475
2017
|
setActive(active2);
|
|
1476
2018
|
};
|
|
@@ -1494,18 +2036,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1494
2036
|
}
|
|
1495
2037
|
return transform;
|
|
1496
2038
|
};
|
|
1497
|
-
return /* @__PURE__ */
|
|
2039
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1498
2040
|
className: "relative flex grow overflow-hidden"
|
|
1499
|
-
}, /* @__PURE__ */
|
|
1500
|
-
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"),
|
|
1501
2043
|
style: {
|
|
1502
2044
|
height: axisHeight
|
|
1503
2045
|
}
|
|
1504
|
-
}), /* @__PURE__ */
|
|
2046
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1505
2047
|
ref: forwardRef2,
|
|
1506
2048
|
role: "columnheader",
|
|
1507
2049
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1508
|
-
}, /* @__PURE__ */
|
|
2050
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1509
2051
|
autoScroll: {
|
|
1510
2052
|
enabled: true
|
|
1511
2053
|
},
|
|
@@ -1516,23 +2058,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1516
2058
|
],
|
|
1517
2059
|
onDragStart: handleDragStart,
|
|
1518
2060
|
onDragEnd: handleDragEnd
|
|
1519
|
-
}, /* @__PURE__ */
|
|
2061
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1520
2062
|
className: "flex h-full",
|
|
1521
2063
|
style: {
|
|
1522
2064
|
height: axisHeight
|
|
1523
2065
|
}
|
|
1524
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2066
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridColumnCell, {
|
|
1525
2067
|
key: idx,
|
|
1526
2068
|
idx,
|
|
1527
2069
|
index,
|
|
1528
|
-
label:
|
|
2070
|
+
label: columnLetter(index),
|
|
1529
2071
|
size: sizes?.[idx] ?? defaultWidth,
|
|
1530
2072
|
resize: index < columns.length - 1,
|
|
1531
2073
|
selected: selected === index,
|
|
1532
2074
|
onResize,
|
|
1533
2075
|
onSelect
|
|
1534
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1535
|
-
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)
|
|
1536
2078
|
})), document.body))));
|
|
1537
2079
|
});
|
|
1538
2080
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -1549,9 +2091,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1549
2091
|
}
|
|
1550
2092
|
});
|
|
1551
2093
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1552
|
-
const [initialSize, setInitialSize] = (0,
|
|
1553
|
-
const [resizing, setResizing] = (0,
|
|
1554
|
-
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)();
|
|
1555
2097
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1556
2098
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
1557
2099
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -1572,7 +2114,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1572
2114
|
onResize?.(idx, initialSize + width, true);
|
|
1573
2115
|
setResizing(false);
|
|
1574
2116
|
};
|
|
1575
|
-
return /* @__PURE__ */
|
|
2117
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1576
2118
|
enable: {
|
|
1577
2119
|
right: resize
|
|
1578
2120
|
},
|
|
@@ -1584,36 +2126,36 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1584
2126
|
onResizeStart: handleResizeStart,
|
|
1585
2127
|
onResize: handleResize,
|
|
1586
2128
|
onResizeStop: handleResizeStop
|
|
1587
|
-
}, /* @__PURE__ */
|
|
2129
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1588
2130
|
ref: setNodeRef,
|
|
1589
2131
|
...attributes,
|
|
1590
2132
|
...listeners,
|
|
1591
|
-
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),
|
|
1592
2134
|
onClick: () => onSelect?.(index)
|
|
1593
|
-
}, /* @__PURE__ */
|
|
2135
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1594
2136
|
className: "flex w-full justify-center"
|
|
1595
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2137
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1596
2138
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1597
|
-
}), resizing && /* @__PURE__ */
|
|
2139
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1598
2140
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1599
2141
|
})));
|
|
1600
2142
|
};
|
|
1601
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
2143
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
1602
2144
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
1603
2145
|
refreshRate: 200
|
|
1604
2146
|
});
|
|
1605
|
-
const scrollerRef = (0,
|
|
1606
|
-
(0,
|
|
2147
|
+
const scrollerRef = (0, import_react2.useRef)(null);
|
|
2148
|
+
(0, import_react2.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
1607
2149
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1608
|
-
const initialText = (0,
|
|
1609
|
-
const quickEdit = (0,
|
|
1610
|
-
const [, forceUpdate] = (0,
|
|
1611
|
-
(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)(() => {
|
|
1612
2154
|
const unsubscribe = model.update.on(() => {
|
|
1613
2155
|
(0, import_log.log)("updated", {
|
|
1614
2156
|
id: model.id
|
|
1615
2157
|
}, {
|
|
1616
|
-
F:
|
|
2158
|
+
F: __dxlog_file4,
|
|
1617
2159
|
L: 737,
|
|
1618
2160
|
S: void 0,
|
|
1619
2161
|
C: (f, a) => f(...a)
|
|
@@ -1626,7 +2168,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1626
2168
|
}, [
|
|
1627
2169
|
model
|
|
1628
2170
|
]);
|
|
1629
|
-
const inputRef = (0,
|
|
2171
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
1630
2172
|
const handleKeyDown = (ev) => {
|
|
1631
2173
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
1632
2174
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -1731,19 +2273,19 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1731
2273
|
rowSizes,
|
|
1732
2274
|
columnSizes
|
|
1733
2275
|
});
|
|
1734
|
-
const id = (0,
|
|
1735
|
-
const attendableAttrs = (0,
|
|
1736
|
-
const hasAttention = (0,
|
|
1737
|
-
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", {
|
|
1738
2280
|
ref: containerRef,
|
|
1739
2281
|
role: "grid",
|
|
1740
2282
|
className: "relative flex grow overflow-hidden"
|
|
1741
|
-
}, /* @__PURE__ */
|
|
1742
|
-
className: (0,
|
|
1743
|
-
}), /* @__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", {
|
|
1744
2286
|
ref: scrollerRef,
|
|
1745
|
-
className: (0,
|
|
1746
|
-
}, /* @__PURE__ */
|
|
2287
|
+
className: (0, import_react_ui_theme.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2288
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1747
2289
|
className: "relative select-none",
|
|
1748
2290
|
style: {
|
|
1749
2291
|
width,
|
|
@@ -1751,10 +2293,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1751
2293
|
},
|
|
1752
2294
|
onClick: () => inputRef.current?.focus(),
|
|
1753
2295
|
...handlers
|
|
1754
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2296
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react2.default.createElement(SelectionOverlay, {
|
|
1755
2297
|
root: scrollerRef.current
|
|
1756
2298
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1757
|
-
return columnRange.map(({
|
|
2299
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1758
2300
|
const style = {
|
|
1759
2301
|
position: "absolute",
|
|
1760
2302
|
top,
|
|
@@ -1764,11 +2306,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1764
2306
|
};
|
|
1765
2307
|
const cell = {
|
|
1766
2308
|
row,
|
|
1767
|
-
|
|
2309
|
+
col
|
|
1768
2310
|
};
|
|
1769
|
-
const id2 =
|
|
1770
|
-
const idx =
|
|
1771
|
-
const active =
|
|
2311
|
+
const id2 = addressToA1Notation(cell);
|
|
2312
|
+
const idx = addressToIndex(model.sheet, cell);
|
|
2313
|
+
const active = posEquals(cursor, cell);
|
|
1772
2314
|
if (active && editing) {
|
|
1773
2315
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
1774
2316
|
const handleClose = (value2) => {
|
|
@@ -1800,7 +2342,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1800
2342
|
inputRef.current?.focus();
|
|
1801
2343
|
setEditing(false);
|
|
1802
2344
|
};
|
|
1803
|
-
return /* @__PURE__ */
|
|
2345
|
+
return /* @__PURE__ */ import_react2.default.createElement(GridCellEditor, {
|
|
1804
2346
|
key: idx,
|
|
1805
2347
|
value,
|
|
1806
2348
|
style,
|
|
@@ -1808,7 +2350,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1808
2350
|
onClose: handleClose
|
|
1809
2351
|
});
|
|
1810
2352
|
}
|
|
1811
|
-
return /* @__PURE__ */
|
|
2353
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetCell, {
|
|
1812
2354
|
key: id2,
|
|
1813
2355
|
id: id2,
|
|
1814
2356
|
cell,
|
|
@@ -1820,7 +2362,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1820
2362
|
}
|
|
1821
2363
|
});
|
|
1822
2364
|
});
|
|
1823
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2365
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement("input", {
|
|
1824
2366
|
ref: inputRef,
|
|
1825
2367
|
autoFocus: true,
|
|
1826
2368
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -1841,7 +2383,7 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1841
2383
|
const b1 = getRelativeClientRect(root, c1);
|
|
1842
2384
|
const b2 = getRelativeClientRect(root, c2);
|
|
1843
2385
|
const bounds = getRectUnion(b1, b2);
|
|
1844
|
-
return /* @__PURE__ */
|
|
2386
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1845
2387
|
role: "none",
|
|
1846
2388
|
style: bounds,
|
|
1847
2389
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
@@ -1850,8 +2392,8 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1850
2392
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
1851
2393
|
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1852
2394
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1853
|
-
const decorationsForCell = decorations.getDecorationsForCell(
|
|
1854
|
-
const decorationAddedClasses = (0,
|
|
2395
|
+
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
2396
|
+
const decorationAddedClasses = (0, import_react2.useMemo)(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
1855
2397
|
decorationsForCell
|
|
1856
2398
|
]);
|
|
1857
2399
|
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
@@ -1859,16 +2401,16 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1859
2401
|
return children;
|
|
1860
2402
|
}
|
|
1861
2403
|
const DecoratorComponent = decorate;
|
|
1862
|
-
return /* @__PURE__ */
|
|
1863
|
-
}, /* @__PURE__ */
|
|
2404
|
+
return /* @__PURE__ */ import_react2.default.createElement(DecoratorComponent, null, children);
|
|
2405
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1864
2406
|
role: "none",
|
|
1865
|
-
className: (0,
|
|
2407
|
+
className: (0, import_react_ui_theme.mx)("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
1866
2408
|
}, value));
|
|
1867
|
-
return /* @__PURE__ */
|
|
2409
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1868
2410
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1869
2411
|
role: "cell",
|
|
1870
2412
|
style,
|
|
1871
|
-
className: (0,
|
|
2413
|
+
className: (0, import_react_ui_theme.mx)("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1872
2414
|
"z-20",
|
|
1873
2415
|
fragments.cellSelected
|
|
1874
2416
|
], classNames),
|
|
@@ -1886,32 +2428,32 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1886
2428
|
};
|
|
1887
2429
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
1888
2430
|
const { model, range } = useSheetContext();
|
|
1889
|
-
const notifier = (0,
|
|
1890
|
-
(0,
|
|
2431
|
+
const notifier = (0, import_react2.useRef)();
|
|
2432
|
+
(0, import_react2.useEffect)(() => {
|
|
1891
2433
|
if (range) {
|
|
1892
|
-
notifier.current?.(
|
|
2434
|
+
notifier.current?.(rangeToA1Notation(range));
|
|
1893
2435
|
}
|
|
1894
2436
|
}, [
|
|
1895
2437
|
range
|
|
1896
2438
|
]);
|
|
1897
|
-
const extension = (0,
|
|
2439
|
+
const extension = (0, import_react2.useMemo)(() => [
|
|
1898
2440
|
editorKeys({
|
|
1899
2441
|
onNav,
|
|
1900
2442
|
onClose
|
|
1901
2443
|
}),
|
|
1902
2444
|
sheetExtension({
|
|
1903
|
-
functions: model.
|
|
2445
|
+
functions: model.graph.getFunctions()
|
|
1904
2446
|
}),
|
|
1905
2447
|
rangeExtension((fn) => notifier.current = fn)
|
|
1906
2448
|
], [
|
|
1907
2449
|
model
|
|
1908
2450
|
]);
|
|
1909
|
-
return /* @__PURE__ */
|
|
2451
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1910
2452
|
role: "cell",
|
|
1911
2453
|
style,
|
|
1912
|
-
className: (0,
|
|
2454
|
+
className: (0, import_react_ui_theme.mx)("z-20 flex", fragments.cellSelected),
|
|
1913
2455
|
onClick: (ev) => ev.stopPropagation()
|
|
1914
|
-
}, /* @__PURE__ */
|
|
2456
|
+
}, /* @__PURE__ */ import_react2.default.createElement(CellEditor, {
|
|
1915
2457
|
autoFocus: true,
|
|
1916
2458
|
value,
|
|
1917
2459
|
extension
|
|
@@ -1924,31 +2466,31 @@ var SheetStatusBar = () => {
|
|
|
1924
2466
|
if (cursor) {
|
|
1925
2467
|
value = model.getCellValue(cursor);
|
|
1926
2468
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1927
|
-
value = model.
|
|
2469
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1928
2470
|
isFormula = true;
|
|
1929
2471
|
} else if (value != null) {
|
|
1930
2472
|
value = String(value);
|
|
1931
2473
|
}
|
|
1932
2474
|
}
|
|
1933
|
-
return /* @__PURE__ */
|
|
1934
|
-
className: (0,
|
|
1935
|
-
}, /* @__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", {
|
|
1936
2478
|
className: "flex gap-4 items-center"
|
|
1937
|
-
}, /* @__PURE__ */
|
|
2479
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1938
2480
|
className: "flex w-16 items-center font-mono"
|
|
1939
|
-
}, range &&
|
|
2481
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1940
2482
|
className: "flex gap-2 items-center"
|
|
1941
|
-
}, /* @__PURE__ */
|
|
1942
|
-
className: (0,
|
|
1943
|
-
}), /* @__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", {
|
|
1944
2486
|
className: "font-mono"
|
|
1945
2487
|
}, value))));
|
|
1946
2488
|
};
|
|
1947
2489
|
var SheetDebug = () => {
|
|
1948
2490
|
const { model, cursor, range } = useSheetContext();
|
|
1949
|
-
const [, forceUpdate] = (0,
|
|
1950
|
-
(0,
|
|
1951
|
-
const accessor = (0,
|
|
2491
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2492
|
+
(0, import_react2.useEffect)(() => {
|
|
2493
|
+
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
1952
2494
|
const handleUpdate = () => forceUpdate({});
|
|
1953
2495
|
accessor.handle.addListener("change", handleUpdate);
|
|
1954
2496
|
handleUpdate();
|
|
@@ -1958,9 +2500,9 @@ var SheetDebug = () => {
|
|
|
1958
2500
|
}, [
|
|
1959
2501
|
model
|
|
1960
2502
|
]);
|
|
1961
|
-
return /* @__PURE__ */
|
|
1962
|
-
className: (0,
|
|
1963
|
-
}, /* @__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", {
|
|
1964
2506
|
className: "whitespace-pre-wrap"
|
|
1965
2507
|
}, JSON.stringify({
|
|
1966
2508
|
cursor,
|
|
@@ -1981,232 +2523,14 @@ var Sheet = {
|
|
|
1981
2523
|
StatusBar: SheetStatusBar,
|
|
1982
2524
|
Debug: SheetDebug
|
|
1983
2525
|
};
|
|
1984
|
-
var iconStyles = (0, import_react_ui_theme5.getSize)(5);
|
|
1985
|
-
var buttonStyles = "min-bs-0 p-2";
|
|
1986
|
-
var tooltipProps = {
|
|
1987
|
-
side: "top",
|
|
1988
|
-
classNames: "z-10"
|
|
1989
|
-
};
|
|
1990
|
-
var ToolbarSeparator = () => /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1991
|
-
role: "separator",
|
|
1992
|
-
className: "grow"
|
|
1993
|
-
});
|
|
1994
|
-
var ToolbarButton = ({ Icon: Icon2, children, ...props }) => {
|
|
1995
|
-
return /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Trigger, {
|
|
1996
|
-
asChild: true
|
|
1997
|
-
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Toolbar.Button, {
|
|
1998
|
-
variant: "ghost",
|
|
1999
|
-
...props,
|
|
2000
|
-
classNames: buttonStyles
|
|
2001
|
-
}, /* @__PURE__ */ import_react11.default.createElement(Icon2, {
|
|
2002
|
-
className: iconStyles
|
|
2003
|
-
}), /* @__PURE__ */ import_react11.default.createElement("span", {
|
|
2004
|
-
className: "sr-only"
|
|
2005
|
-
}, children))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Content, tooltipProps, children, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Arrow, null))));
|
|
2006
|
-
};
|
|
2007
|
-
var ToolbarToggleButton = ({ Icon: Icon2, children, ...props }) => {
|
|
2008
|
-
return /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Trigger, {
|
|
2009
|
-
asChild: true
|
|
2010
|
-
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Toolbar.ToggleGroupItem, {
|
|
2011
|
-
variant: "ghost",
|
|
2012
|
-
...props,
|
|
2013
|
-
classNames: buttonStyles
|
|
2014
|
-
}, /* @__PURE__ */ import_react11.default.createElement(Icon2, {
|
|
2015
|
-
className: iconStyles
|
|
2016
|
-
}), /* @__PURE__ */ import_react11.default.createElement("span", {
|
|
2017
|
-
className: "sr-only"
|
|
2018
|
-
}, children))), /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Content, tooltipProps, children, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Tooltip.Arrow, null))));
|
|
2019
|
-
};
|
|
2020
|
-
var [ToolbarContextProvider, useToolbarContext] = (0, import_react_context.createContext)("Toolbar");
|
|
2021
|
-
var ToolbarRoot = ({ children, onAction, classNames }) => {
|
|
2022
|
-
return /* @__PURE__ */ import_react10.default.createElement(ToolbarContextProvider, {
|
|
2023
|
-
onAction
|
|
2024
|
-
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.DensityProvider, {
|
|
2025
|
-
density: "fine"
|
|
2026
|
-
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.ElevationProvider, {
|
|
2027
|
-
elevation: "chrome"
|
|
2028
|
-
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.Root, {
|
|
2029
|
-
classNames: [
|
|
2030
|
-
"is-full shrink-0 overflow-x-auto overflow-y-hidden p-1",
|
|
2031
|
-
classNames
|
|
2032
|
-
]
|
|
2033
|
-
}, children))));
|
|
2034
|
-
};
|
|
2035
|
-
var formatOptions = [
|
|
2036
|
-
{
|
|
2037
|
-
type: "date",
|
|
2038
|
-
Icon: import_react9.Calendar,
|
|
2039
|
-
getState: (state) => false
|
|
2040
|
-
},
|
|
2041
|
-
{
|
|
2042
|
-
type: "currency",
|
|
2043
|
-
Icon: import_react9.CurrencyDollar,
|
|
2044
|
-
getState: (state) => false
|
|
2045
|
-
}
|
|
2046
|
-
];
|
|
2047
|
-
var Format = () => {
|
|
2048
|
-
const { onAction } = useToolbarContext("Format");
|
|
2049
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2050
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.ToggleGroup, {
|
|
2051
|
-
type: "single"
|
|
2052
|
-
}, formatOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ import_react10.default.createElement(ToolbarToggleButton, {
|
|
2053
|
-
key: type,
|
|
2054
|
-
value: type,
|
|
2055
|
-
Icon: Icon2,
|
|
2056
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2057
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2058
|
-
onClick: () => onAction?.({
|
|
2059
|
-
type
|
|
2060
|
-
})
|
|
2061
|
-
}, t(`toolbar ${type} label`))));
|
|
2062
|
-
};
|
|
2063
|
-
var alignmentOptions = [
|
|
2064
|
-
{
|
|
2065
|
-
type: "left",
|
|
2066
|
-
Icon: import_react9.TextAlignLeft,
|
|
2067
|
-
getState: (state) => false
|
|
2068
|
-
},
|
|
2069
|
-
{
|
|
2070
|
-
type: "center",
|
|
2071
|
-
Icon: import_react9.TextAlignCenter,
|
|
2072
|
-
getState: (state) => false
|
|
2073
|
-
},
|
|
2074
|
-
{
|
|
2075
|
-
type: "right",
|
|
2076
|
-
Icon: import_react9.TextAlignRight,
|
|
2077
|
-
getState: (state) => false
|
|
2078
|
-
}
|
|
2079
|
-
];
|
|
2080
|
-
var Alignment = () => {
|
|
2081
|
-
const { onAction } = useToolbarContext("Alignment");
|
|
2082
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2083
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.ToggleGroup, {
|
|
2084
|
-
type: "single"
|
|
2085
|
-
}, alignmentOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ import_react10.default.createElement(ToolbarToggleButton, {
|
|
2086
|
-
key: type,
|
|
2087
|
-
value: type,
|
|
2088
|
-
Icon: Icon2,
|
|
2089
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2090
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2091
|
-
onClick: () => onAction?.({
|
|
2092
|
-
type
|
|
2093
|
-
})
|
|
2094
|
-
}, t(`toolbar ${type} label`))));
|
|
2095
|
-
};
|
|
2096
|
-
var styleOptions = [
|
|
2097
|
-
{
|
|
2098
|
-
type: "clear",
|
|
2099
|
-
Icon: import_react9.Eraser,
|
|
2100
|
-
getState: (state) => false
|
|
2101
|
-
},
|
|
2102
|
-
{
|
|
2103
|
-
type: "highlight",
|
|
2104
|
-
Icon: import_react9.HighlighterCircle,
|
|
2105
|
-
getState: (state) => false
|
|
2106
|
-
}
|
|
2107
|
-
];
|
|
2108
|
-
var Styles = () => {
|
|
2109
|
-
const { onAction } = useToolbarContext("Alignment");
|
|
2110
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2111
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Toolbar.ToggleGroup, {
|
|
2112
|
-
type: "single"
|
|
2113
|
-
}, styleOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ import_react10.default.createElement(ToolbarToggleButton, {
|
|
2114
|
-
key: type,
|
|
2115
|
-
value: type,
|
|
2116
|
-
Icon: Icon2,
|
|
2117
|
-
// disabled={state?.blockType === 'codeblock'}
|
|
2118
|
-
// onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
|
|
2119
|
-
onClick: () => onAction?.({
|
|
2120
|
-
type
|
|
2121
|
-
})
|
|
2122
|
-
}, t(`toolbar ${type} label`))));
|
|
2123
|
-
};
|
|
2124
|
-
var Actions = () => {
|
|
2125
|
-
const { onAction } = useToolbarContext("Actions");
|
|
2126
|
-
const { cursor, range, model } = useSheetContext();
|
|
2127
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BJ6ZD7MN.SHEET_PLUGIN);
|
|
2128
|
-
const overlapsCommentAnchor = (model.sheet.threads ?? []).filter(import_util.nonNullable).filter((thread) => thread.status !== "resolved").some((thread) => {
|
|
2129
|
-
if (!cursor) {
|
|
2130
|
-
return false;
|
|
2131
|
-
}
|
|
2132
|
-
return (0, import_chunk_ZRQZFV5T.addressToIndex)(model.sheet, cursor) === thread.anchor;
|
|
2133
|
-
});
|
|
2134
|
-
const hasCursor = !!cursor;
|
|
2135
|
-
const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;
|
|
2136
|
-
const tooltipLabelKey = !hasCursor ? "no cursor label" : overlapsCommentAnchor ? "selection overlaps existing comment label" : range ? "comment ranges not supported label" : "comment label";
|
|
2137
|
-
return /* @__PURE__ */ import_react10.default.createElement(ToolbarButton, {
|
|
2138
|
-
value: "comment",
|
|
2139
|
-
Icon: import_react9.ChatText,
|
|
2140
|
-
"data-testid": "editor.toolbar.comment",
|
|
2141
|
-
onClick: () => {
|
|
2142
|
-
if (!cursor) {
|
|
2143
|
-
return;
|
|
2144
|
-
}
|
|
2145
|
-
return onAction?.({
|
|
2146
|
-
type: "comment",
|
|
2147
|
-
anchor: (0, import_chunk_ZRQZFV5T.addressToIndex)(model.sheet, cursor),
|
|
2148
|
-
cellContent: model.getCellText(cursor)
|
|
2149
|
-
});
|
|
2150
|
-
},
|
|
2151
|
-
disabled: !cursorOnly || overlapsCommentAnchor
|
|
2152
|
-
}, t(tooltipLabelKey));
|
|
2153
|
-
};
|
|
2154
|
-
var Toolbar = {
|
|
2155
|
-
Root: ToolbarRoot,
|
|
2156
|
-
Separator: ToolbarSeparator,
|
|
2157
|
-
Alignment,
|
|
2158
|
-
Format,
|
|
2159
|
-
Styles,
|
|
2160
|
-
Actions
|
|
2161
|
-
};
|
|
2162
|
-
var attentionFragment = (0, import_react_ui_theme.mx)("group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface", "group-focus-within/editor:border-separator");
|
|
2163
|
-
var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
|
|
2164
|
-
var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
|
|
2165
|
-
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
2166
|
-
const id = (0, import_echo.fullyQualifiedId)(sheet);
|
|
2167
|
-
const isDirectlyAttended = (0, import_react_ui_attention.useIsDirectlyAttended)(id);
|
|
2168
|
-
const handleAction = (0, import_react.useCallback)((action) => {
|
|
2169
|
-
switch (action.type) {
|
|
2170
|
-
case "comment": {
|
|
2171
|
-
void dispatch({
|
|
2172
|
-
action: "dxos.org/plugin/thread/action/create",
|
|
2173
|
-
data: {
|
|
2174
|
-
cursor: action.anchor,
|
|
2175
|
-
name: action.cellContent,
|
|
2176
|
-
subject: sheet
|
|
2177
|
-
}
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2180
|
-
}
|
|
2181
|
-
}, [
|
|
2182
|
-
sheet,
|
|
2183
|
-
dispatch
|
|
2184
|
-
]);
|
|
2185
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
2186
|
-
role: "none",
|
|
2187
|
-
className: role === "article" ? "row-span-2 grid grid-rows-subgrid" : void 0
|
|
2188
|
-
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Root, {
|
|
2189
|
-
sheet,
|
|
2190
|
-
space,
|
|
2191
|
-
remoteFunctionUrl
|
|
2192
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
2193
|
-
role: "none",
|
|
2194
|
-
className: (0, import_react_ui_theme.mx)("flex flex-0 justify-center overflow-x-auto")
|
|
2195
|
-
}, /* @__PURE__ */ import_react.default.createElement(Toolbar.Root, {
|
|
2196
|
-
onAction: handleAction,
|
|
2197
|
-
classNames: (0, import_react_ui_theme.mx)(role === "section" ? [
|
|
2198
|
-
"z-[2] group-focus-within/section:visible",
|
|
2199
|
-
!isDirectlyAttended && "invisible",
|
|
2200
|
-
sectionToolbarLayout
|
|
2201
|
-
] : "group-focus-within/editor:border-separator group-[[aria-current]]/editor:border-separator")
|
|
2202
|
-
}, /* @__PURE__ */ import_react.default.createElement(Toolbar.Separator, null), /* @__PURE__ */ import_react.default.createElement(Toolbar.Actions, null))), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
2203
|
-
role: "none",
|
|
2204
|
-
className: (0, import_react_ui_theme.mx)(role === "section" && "aspect-square border-is border-bs border-be border-separator", role === "article" && "flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator", import_react_ui_theme.focusRing, attentionFragment)
|
|
2205
|
-
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Main, null))));
|
|
2206
|
-
};
|
|
2207
|
-
var SheetContainer_default = SheetContainer;
|
|
2208
2526
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2209
2527
|
0 && (module.exports = {
|
|
2210
|
-
|
|
2528
|
+
ComputeGraphContextProvider,
|
|
2529
|
+
Sheet,
|
|
2530
|
+
SheetContainer,
|
|
2531
|
+
addressToIndex,
|
|
2532
|
+
compareIndexPositions,
|
|
2533
|
+
createSheet,
|
|
2534
|
+
useSheetContext
|
|
2211
2535
|
});
|
|
2212
|
-
//# sourceMappingURL=
|
|
2536
|
+
//# sourceMappingURL=chunk-OTTD7FBK.cjs.map
|