@dxos/plugin-sheet 0.6.11 → 0.6.12-main.5a87ad5
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-VISF3VUB.mjs +261 -0
- package/dist/lib/browser/SheetContainer-VISF3VUB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FUAGSXA4.mjs → chunk-WZMOZKQZ.mjs} +9 -16
- package/dist/lib/browser/chunk-WZMOZKQZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-Z2XOOC2R.mjs} +385 -678
- package/dist/lib/browser/chunk-Z2XOOC2R.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-U4H5D34A.mjs → chunk-ZLJ2GRE2.mjs} +1151 -240
- package/dist/lib/browser/chunk-ZLJ2GRE2.mjs.map +7 -0
- package/dist/lib/browser/graph-4XFKIHRL.mjs +21 -0
- package/dist/lib/browser/graph-4XFKIHRL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +74 -60
- 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-2MEALQWW.cjs +279 -0
- package/dist/lib/node/SheetContainer-2MEALQWW.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-AXQV3ZT5.cjs → chunk-6DQABRGJ.cjs} +1182 -279
- package/dist/lib/node/chunk-6DQABRGJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-AOP42UAA.cjs} +13 -21
- package/dist/lib/node/chunk-AOP42UAA.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-P5QYYEHQ.cjs} +388 -676
- package/dist/lib/node/chunk-P5QYYEHQ.cjs.map +7 -0
- package/dist/lib/node/graph-2LRDUXBZ.cjs +43 -0
- package/dist/lib/node/graph-2LRDUXBZ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +86 -66
- 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-RPSUSXWS.mjs +262 -0
- package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs +2944 -0
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs +2684 -0
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs +17 -0
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs +76 -0
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs.map +7 -0
- package/dist/lib/node-esm/graph-WG5EKOMO.mjs +22 -0
- package/dist/lib/node-esm/graph-WG5EKOMO.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +263 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +10 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +21 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +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/decorations.d.ts +24 -0
- package/dist/types/src/components/Sheet/decorations.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +8 -7
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts +2 -0
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +2 -3
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +19 -3
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +18 -13
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/defs/util.d.ts +43 -0
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +9 -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 +8 -2
- package/dist/types/src/graph/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +84 -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-graph.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +26 -0
- package/dist/types/src/graph/compute-node.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/{components/ComputeGraph/custom.d.ts → graph/testing/custom-function.d.ts} +4 -2
- package/dist/types/src/graph/testing/custom-function.d.ts.map +1 -0
- package/dist/types/src/graph/testing/index.d.ts +2 -0
- package/dist/types/src/graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -3
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +10 -65
- 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 +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +86 -5
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +48 -41
- package/src/SheetPlugin.tsx +48 -73
- package/src/components/CellEditor/CellEditor.stories.tsx +5 -4
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +4 -5
- package/src/components/CellEditor/extension.ts +1 -3
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +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 +52 -88
- package/src/components/Sheet/Sheet.tsx +57 -18
- package/src/components/Sheet/decorations.ts +62 -0
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +18 -80
- package/src/components/Sheet/threads.tsx +205 -0
- package/src/components/SheetContainer.tsx +73 -19
- package/src/components/Toolbar/Toolbar.tsx +53 -12
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +8 -9
- package/src/{model → defs}/types.ts +24 -14
- package/src/defs/util.ts +151 -0
- package/src/extensions/compute.stories.tsx +153 -0
- package/src/extensions/compute.ts +131 -0
- package/src/extensions/index.ts +5 -0
- package/src/{components/ComputeGraph → graph}/async-function.ts +15 -6
- package/src/graph/compute-graph.stories.tsx +93 -0
- package/src/graph/compute-graph.test.ts +127 -0
- package/src/graph/compute-graph.ts +313 -0
- package/src/graph/compute-node.ts +62 -0
- package/src/{components/ComputeGraph → graph}/edge-function.ts +3 -3
- package/src/graph/hyperformula.test.ts +15 -0
- package/src/graph/index.ts +7 -0
- package/src/{components/ComputeGraph/custom.ts → graph/testing/custom-function.ts} +11 -7
- package/src/graph/testing/index.ts +5 -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 +21 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +40 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -3
- package/src/model/sheet-model.ts +414 -0
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +68 -0
- package/src/translations.ts +6 -1
- package/src/types.ts +31 -6
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
- package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
- package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts +0 -15
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -100
- package/src/model/model.ts +0 -550
- package/src/model/util.ts +0 -36
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/ComputeGraph → graph}/edge-function.d.ts +0 -0
- /package/src/{model/functions.ts → graph/function-defs.ts} +0 -0
|
@@ -26,38 +26,64 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
29
|
+
var chunk_6DQABRGJ_exports = {};
|
|
30
|
+
__export(chunk_6DQABRGJ_exports, {
|
|
31
|
+
ComputeGraphContextProvider: () => ComputeGraphContextProvider,
|
|
32
|
+
Sheet: () => Sheet,
|
|
33
|
+
SheetContainer: () => SheetContainer,
|
|
34
|
+
addressToIndex: () => addressToIndex,
|
|
35
|
+
compareIndexPositions: () => compareIndexPositions,
|
|
36
|
+
createSheet: () => createSheet,
|
|
37
|
+
useComputeGraph: () => useComputeGraph,
|
|
38
|
+
useSheetContext: () => useSheetContext
|
|
32
39
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
|
|
38
|
-
var import_react = __toESM(require("react"));
|
|
39
|
-
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
40
|
+
module.exports = __toCommonJS(chunk_6DQABRGJ_exports);
|
|
41
|
+
var import_chunk_AOP42UAA = require("./chunk-AOP42UAA.cjs");
|
|
42
|
+
var import_chunk_BNARJ5GM = require("./chunk-BNARJ5GM.cjs");
|
|
43
|
+
var import_chunk_P5QYYEHQ = require("./chunk-P5QYYEHQ.cjs");
|
|
40
44
|
var import_core = require("@dnd-kit/core");
|
|
41
45
|
var import_modifiers = require("@dnd-kit/modifiers");
|
|
42
46
|
var import_utilities = require("@dnd-kit/utilities");
|
|
43
|
-
var
|
|
47
|
+
var import_react = require("@phosphor-icons/react");
|
|
44
48
|
var import_re_resizable = require("re-resizable");
|
|
45
|
-
var
|
|
49
|
+
var import_react2 = __toESM(require("react"));
|
|
46
50
|
var import_react_dom = require("react-dom");
|
|
47
51
|
var import_react_resize_detector = require("react-resize-detector");
|
|
48
52
|
var import_async = require("@dxos/async");
|
|
49
53
|
var import_echo = require("@dxos/client/echo");
|
|
50
54
|
var import_log = require("@dxos/log");
|
|
51
55
|
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var import_react5 = require("react");
|
|
55
|
-
var import_react6 = __toESM(require("react"));
|
|
56
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
57
|
+
var import_react3 = require("react");
|
|
56
58
|
var import_invariant = require("@dxos/invariant");
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
+
var import_crypto = require("@dxos/crypto");
|
|
60
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
61
|
+
var import_react4 = require("react");
|
|
62
|
+
var import_react5 = __toESM(require("react"));
|
|
63
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
64
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
65
|
+
var import_react6 = require("react");
|
|
66
|
+
var import_debug = require("@dxos/debug");
|
|
67
|
+
var import_react_hooks = require("@dxos/react-hooks");
|
|
59
68
|
var import_react7 = __toESM(require("react"));
|
|
69
|
+
var import_react8 = __toESM(require("react"));
|
|
70
|
+
var import_react9 = require("react");
|
|
71
|
+
var import_async2 = require("@dxos/async");
|
|
72
|
+
var import_context = require("@dxos/context");
|
|
73
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
74
|
+
var import_keys = require("@dxos/keys");
|
|
75
|
+
var import_log2 = require("@dxos/log");
|
|
76
|
+
var import_hyperformula = require("#hyperformula");
|
|
77
|
+
var import_react10 = require("react");
|
|
78
|
+
var import_signals_core = require("@preact/signals-core");
|
|
79
|
+
var import_react11 = __toESM(require("react"));
|
|
80
|
+
var import_app_framework = require("@dxos/app-framework");
|
|
81
|
+
var import_async3 = require("@dxos/async");
|
|
82
|
+
var import_echo2 = require("@dxos/react-client/echo");
|
|
60
83
|
var import_react_ui = require("@dxos/react-ui");
|
|
84
|
+
var import_view = require("@codemirror/view");
|
|
85
|
+
var import_react12 = __toESM(require("react"));
|
|
86
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
61
87
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
62
88
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
63
89
|
var import_language = require("@codemirror/language");
|
|
@@ -65,7 +91,164 @@ var import_state = require("@codemirror/state");
|
|
|
65
91
|
var import_view2 = require("@codemirror/view");
|
|
66
92
|
var import_highlight = require("@lezer/highlight");
|
|
67
93
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
68
|
-
var
|
|
94
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
95
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
|
|
96
|
+
var DEFAULT_ROWS = 50;
|
|
97
|
+
var DEFAULT_COLUMNS = 26;
|
|
98
|
+
var MAX_ROWS = 500;
|
|
99
|
+
var MAX_COLUMNS = 26 * 2;
|
|
100
|
+
var posEquals = (a, b) => {
|
|
101
|
+
return a?.col === b?.col && a?.row === b?.row;
|
|
102
|
+
};
|
|
103
|
+
var columnLetter = (col) => {
|
|
104
|
+
(0, import_invariant.invariant)(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
105
|
+
F: __dxlog_file,
|
|
106
|
+
L: 26,
|
|
107
|
+
S: void 0,
|
|
108
|
+
A: [
|
|
109
|
+
"col < MAX_COLUMNS",
|
|
110
|
+
"`Invalid column: ${col}`"
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
114
|
+
};
|
|
115
|
+
var addressToA1Notation = ({ col, row }) => {
|
|
116
|
+
return `${columnLetter(col)}${row + 1}`;
|
|
117
|
+
};
|
|
118
|
+
var addressFromA1Notation = (ref) => {
|
|
119
|
+
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
120
|
+
(0, import_invariant.invariant)(match, `Invalid notation: ${ref}`, {
|
|
121
|
+
F: __dxlog_file,
|
|
122
|
+
L: 40,
|
|
123
|
+
S: void 0,
|
|
124
|
+
A: [
|
|
125
|
+
"match",
|
|
126
|
+
"`Invalid notation: ${ref}`"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
row: parseInt(match[2], 10) - 1,
|
|
131
|
+
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
var rangeToA1Notation = (range) => {
|
|
135
|
+
return [
|
|
136
|
+
range?.from && addressToA1Notation(range?.from),
|
|
137
|
+
range?.to && addressToA1Notation(range?.to)
|
|
138
|
+
].filter(Boolean).join(":");
|
|
139
|
+
};
|
|
140
|
+
var inRange = (range, cell) => {
|
|
141
|
+
if (!range) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
const { from, to } = range;
|
|
145
|
+
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
if (!from || !to) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
const { col: c1, row: r1 } = from;
|
|
152
|
+
const { col: c2, row: r2 } = to;
|
|
153
|
+
const cMin = Math.min(c1, c2);
|
|
154
|
+
const cMax = Math.max(c1, c2);
|
|
155
|
+
const rMin = Math.min(r1, r2);
|
|
156
|
+
const rMax = Math.max(r1, r2);
|
|
157
|
+
const { col, row } = cell;
|
|
158
|
+
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
159
|
+
};
|
|
160
|
+
var ApiError = class extends Error {
|
|
161
|
+
};
|
|
162
|
+
var ReadonlyException = class extends ApiError {
|
|
163
|
+
};
|
|
164
|
+
var RangeException = class extends ApiError {
|
|
165
|
+
constructor(n) {
|
|
166
|
+
super();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var createIndex = (length = 8) => {
|
|
170
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
171
|
+
const charactersLength = characters.length;
|
|
172
|
+
const randomBuffer = (0, import_crypto.randomBytes)(length);
|
|
173
|
+
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
174
|
+
};
|
|
175
|
+
var createIndices = (length) => Array.from({
|
|
176
|
+
length
|
|
177
|
+
}).map(() => createIndex());
|
|
178
|
+
var insertIndices = (indices, i, n, max) => {
|
|
179
|
+
if (i + n > max) {
|
|
180
|
+
throw new RangeException(i + n);
|
|
181
|
+
}
|
|
182
|
+
const idx = createIndices(n);
|
|
183
|
+
indices.splice(i, 0, ...idx);
|
|
184
|
+
};
|
|
185
|
+
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
186
|
+
if (!sheet.rows.length) {
|
|
187
|
+
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
188
|
+
}
|
|
189
|
+
if (!sheet.columns.length) {
|
|
190
|
+
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var createSheet = ({ name, cells, ...size } = {}) => {
|
|
194
|
+
const sheet = (0, import_echo_schema.create)(import_chunk_AOP42UAA.SheetType, {
|
|
195
|
+
name,
|
|
196
|
+
cells: {},
|
|
197
|
+
rows: [],
|
|
198
|
+
columns: [],
|
|
199
|
+
rowMeta: {},
|
|
200
|
+
columnMeta: {},
|
|
201
|
+
formatting: {}
|
|
202
|
+
});
|
|
203
|
+
initialize(sheet, size);
|
|
204
|
+
if (cells) {
|
|
205
|
+
Object.entries(cells).forEach(([key, { value }]) => {
|
|
206
|
+
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
207
|
+
sheet.cells[idx] = {
|
|
208
|
+
value
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return sheet;
|
|
213
|
+
};
|
|
214
|
+
var addressToIndex = (sheet, cell) => {
|
|
215
|
+
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
216
|
+
};
|
|
217
|
+
var addressFromIndex = (sheet, idx) => {
|
|
218
|
+
const [column, row] = idx.split("@");
|
|
219
|
+
return {
|
|
220
|
+
col: sheet.columns.indexOf(column),
|
|
221
|
+
row: sheet.rows.indexOf(row)
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
var rangeFromIndex = (sheet, idx) => {
|
|
225
|
+
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
226
|
+
return {
|
|
227
|
+
from,
|
|
228
|
+
to
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
var closest = (cursor, cells) => {
|
|
232
|
+
let closestCell;
|
|
233
|
+
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
234
|
+
for (const cell of cells) {
|
|
235
|
+
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
|
|
236
|
+
if (distance < closestDistance) {
|
|
237
|
+
closestCell = cell;
|
|
238
|
+
closestDistance = distance;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return closestCell;
|
|
242
|
+
};
|
|
243
|
+
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
244
|
+
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
245
|
+
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
246
|
+
if (rowA !== rowB) {
|
|
247
|
+
return rowA - rowB;
|
|
248
|
+
} else {
|
|
249
|
+
return columnA - columnB;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
69
252
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
70
253
|
var axisHeight = 34;
|
|
71
254
|
var minWidth = 40;
|
|
@@ -76,8 +259,8 @@ var defaultWidth = 200;
|
|
|
76
259
|
var defaultHeight = minHeight;
|
|
77
260
|
var CELL_DATA_KEY = "cell";
|
|
78
261
|
var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) => {
|
|
79
|
-
const [rowPositions, setRowPositions] = (0,
|
|
80
|
-
(0,
|
|
262
|
+
const [rowPositions, setRowPositions] = (0, import_react3.useState)([]);
|
|
263
|
+
(0, import_react3.useEffect)(() => {
|
|
81
264
|
if (!rowSizes) {
|
|
82
265
|
return;
|
|
83
266
|
}
|
|
@@ -96,8 +279,8 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
96
279
|
rows,
|
|
97
280
|
rowSizes
|
|
98
281
|
]);
|
|
99
|
-
const [columnPositions, setColumnPositions] = (0,
|
|
100
|
-
(0,
|
|
282
|
+
const [columnPositions, setColumnPositions] = (0, import_react3.useState)([]);
|
|
283
|
+
(0, import_react3.useEffect)(() => {
|
|
101
284
|
if (!columns) {
|
|
102
285
|
return;
|
|
103
286
|
}
|
|
@@ -107,7 +290,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
107
290
|
const left = x;
|
|
108
291
|
x += width2 - 1;
|
|
109
292
|
return {
|
|
110
|
-
|
|
293
|
+
col: i,
|
|
111
294
|
left,
|
|
112
295
|
width: width2
|
|
113
296
|
};
|
|
@@ -118,11 +301,11 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
118
301
|
]);
|
|
119
302
|
const height = rowPositions.length ? rowPositions[rowPositions.length - 1].top + rowPositions[rowPositions.length - 1].height : 0;
|
|
120
303
|
const width = columnPositions.length ? columnPositions[columnPositions.length - 1].left + columnPositions[columnPositions.length - 1].width : 0;
|
|
121
|
-
const [{ rowRange, columnRange }, setWindow] = (0,
|
|
304
|
+
const [{ rowRange, columnRange }, setWindow] = (0, import_react3.useState)({
|
|
122
305
|
rowRange: [],
|
|
123
306
|
columnRange: []
|
|
124
307
|
});
|
|
125
|
-
(0,
|
|
308
|
+
(0, import_react3.useEffect)(() => {
|
|
126
309
|
const handleScroll = () => {
|
|
127
310
|
if (!scroller) {
|
|
128
311
|
return;
|
|
@@ -182,12 +365,12 @@ var getCellAtPointer = (event) => {
|
|
|
182
365
|
if (root) {
|
|
183
366
|
const value = root.dataset[CELL_DATA_KEY];
|
|
184
367
|
if (value) {
|
|
185
|
-
return
|
|
368
|
+
return addressFromA1Notation(value);
|
|
186
369
|
}
|
|
187
370
|
}
|
|
188
371
|
};
|
|
189
372
|
var getCellElement = (root, cell) => {
|
|
190
|
-
const pos =
|
|
373
|
+
const pos = addressToA1Notation(cell);
|
|
191
374
|
return root.querySelector(`[data-${CELL_DATA_KEY}="${pos}"]`);
|
|
192
375
|
};
|
|
193
376
|
var handleNav = (ev, cursor, range, size) => {
|
|
@@ -209,14 +392,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
209
392
|
break;
|
|
210
393
|
}
|
|
211
394
|
case "ArrowLeft": {
|
|
212
|
-
if (opposite.
|
|
213
|
-
opposite.
|
|
395
|
+
if (opposite.col > 0) {
|
|
396
|
+
opposite.col -= 1;
|
|
214
397
|
}
|
|
215
398
|
break;
|
|
216
399
|
}
|
|
217
400
|
case "ArrowRight": {
|
|
218
|
-
if (opposite.
|
|
219
|
-
opposite.
|
|
401
|
+
if (opposite.col < size.numCols - 1) {
|
|
402
|
+
opposite.col += 1;
|
|
220
403
|
}
|
|
221
404
|
break;
|
|
222
405
|
}
|
|
@@ -234,18 +417,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
234
417
|
cursor: next
|
|
235
418
|
};
|
|
236
419
|
};
|
|
237
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
420
|
+
var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
238
421
|
switch (ev.key) {
|
|
239
422
|
case "ArrowUp":
|
|
240
423
|
if (cursor === void 0) {
|
|
241
424
|
return {
|
|
242
425
|
row: 0,
|
|
243
|
-
|
|
426
|
+
col: 0
|
|
244
427
|
};
|
|
245
428
|
} else if (cursor.row > 0) {
|
|
246
429
|
return {
|
|
247
430
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
248
|
-
|
|
431
|
+
col: cursor.col
|
|
249
432
|
};
|
|
250
433
|
}
|
|
251
434
|
break;
|
|
@@ -253,12 +436,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
253
436
|
if (cursor === void 0) {
|
|
254
437
|
return {
|
|
255
438
|
row: 0,
|
|
256
|
-
|
|
439
|
+
col: 0
|
|
257
440
|
};
|
|
258
441
|
} else if (cursor.row < numRows - 1) {
|
|
259
442
|
return {
|
|
260
443
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
261
|
-
|
|
444
|
+
col: cursor.col
|
|
262
445
|
};
|
|
263
446
|
}
|
|
264
447
|
break;
|
|
@@ -266,12 +449,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
266
449
|
if (cursor === void 0) {
|
|
267
450
|
return {
|
|
268
451
|
row: 0,
|
|
269
|
-
|
|
452
|
+
col: 0
|
|
270
453
|
};
|
|
271
|
-
} else if (cursor.
|
|
454
|
+
} else if (cursor.col > 0) {
|
|
272
455
|
return {
|
|
273
456
|
row: cursor.row,
|
|
274
|
-
|
|
457
|
+
col: ev.metaKey ? 0 : cursor.col - 1
|
|
275
458
|
};
|
|
276
459
|
}
|
|
277
460
|
break;
|
|
@@ -279,30 +462,30 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
|
279
462
|
if (cursor === void 0) {
|
|
280
463
|
return {
|
|
281
464
|
row: 0,
|
|
282
|
-
|
|
465
|
+
col: 0
|
|
283
466
|
};
|
|
284
|
-
} else if (cursor.
|
|
467
|
+
} else if (cursor.col < numCols - 1) {
|
|
285
468
|
return {
|
|
286
469
|
row: cursor.row,
|
|
287
|
-
|
|
470
|
+
col: ev.metaKey ? numCols - 1 : cursor.col + 1
|
|
288
471
|
};
|
|
289
472
|
}
|
|
290
473
|
break;
|
|
291
474
|
case "Home":
|
|
292
475
|
return {
|
|
293
476
|
row: 0,
|
|
294
|
-
|
|
477
|
+
col: 0
|
|
295
478
|
};
|
|
296
479
|
case "End":
|
|
297
480
|
return {
|
|
298
481
|
row: numRows - 1,
|
|
299
|
-
|
|
482
|
+
col: numCols - 1
|
|
300
483
|
};
|
|
301
484
|
}
|
|
302
485
|
};
|
|
303
486
|
var useRangeSelect = (cb) => {
|
|
304
|
-
const [from, setFrom] = (0,
|
|
305
|
-
const [to, setTo] = (0,
|
|
487
|
+
const [from, setFrom] = (0, import_react4.useState)();
|
|
488
|
+
const [to, setTo] = (0, import_react4.useState)();
|
|
306
489
|
const onMouseDown = (ev) => {
|
|
307
490
|
const current = getCellAtPointer(ev);
|
|
308
491
|
setFrom(current);
|
|
@@ -315,7 +498,7 @@ var useRangeSelect = (cb) => {
|
|
|
315
498
|
const onMouseMove = (ev) => {
|
|
316
499
|
if (from) {
|
|
317
500
|
let current = getCellAtPointer(ev);
|
|
318
|
-
if (
|
|
501
|
+
if (posEquals(current, from)) {
|
|
319
502
|
current = void 0;
|
|
320
503
|
}
|
|
321
504
|
setTo(current);
|
|
@@ -328,7 +511,7 @@ var useRangeSelect = (cb) => {
|
|
|
328
511
|
const onMouseUp = (ev) => {
|
|
329
512
|
if (from) {
|
|
330
513
|
let current = getCellAtPointer(ev);
|
|
331
|
-
if (
|
|
514
|
+
if (posEquals(current, from)) {
|
|
332
515
|
current = void 0;
|
|
333
516
|
}
|
|
334
517
|
setFrom(void 0);
|
|
@@ -351,27 +534,80 @@ var useRangeSelect = (cb) => {
|
|
|
351
534
|
}
|
|
352
535
|
};
|
|
353
536
|
};
|
|
537
|
+
var createDecorations = () => {
|
|
538
|
+
const { decorations } = (0, import_echo_schema2.create)({
|
|
539
|
+
decorations: {}
|
|
540
|
+
});
|
|
541
|
+
const addDecoration = (cellIndex, decorator) => {
|
|
542
|
+
decorations[cellIndex] = [
|
|
543
|
+
...decorations[cellIndex] || [],
|
|
544
|
+
decorator
|
|
545
|
+
];
|
|
546
|
+
};
|
|
547
|
+
const removeDecoration = (cellIndex, type) => {
|
|
548
|
+
if (type) {
|
|
549
|
+
decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
|
|
550
|
+
} else {
|
|
551
|
+
delete decorations[cellIndex];
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const getDecorationsForCell = (cellIndex) => {
|
|
555
|
+
return decorations[cellIndex];
|
|
556
|
+
};
|
|
557
|
+
const getAllDecorations = () => {
|
|
558
|
+
const result = [];
|
|
559
|
+
for (const decoratorArray of Object.values(decorations)) {
|
|
560
|
+
for (const decorator of decoratorArray) {
|
|
561
|
+
result.push(decorator);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return result;
|
|
565
|
+
};
|
|
566
|
+
return {
|
|
567
|
+
addDecoration,
|
|
568
|
+
removeDecoration,
|
|
569
|
+
getDecorationsForCell,
|
|
570
|
+
getAllDecorations
|
|
571
|
+
};
|
|
572
|
+
};
|
|
573
|
+
var ComputeGraphContext = /* @__PURE__ */ (0, import_react8.createContext)(void 0);
|
|
574
|
+
var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
575
|
+
return /* @__PURE__ */ import_react8.default.createElement(ComputeGraphContext.Provider, {
|
|
576
|
+
value: {
|
|
577
|
+
registry
|
|
578
|
+
}
|
|
579
|
+
}, children);
|
|
580
|
+
};
|
|
581
|
+
var SheetContainer = import_react7.default.lazy(() => import("./SheetContainer-2MEALQWW.cjs"));
|
|
582
|
+
var useComputeGraph = (space) => {
|
|
583
|
+
const { registry } = (0, import_react6.useContext)(ComputeGraphContext) ?? (0, import_debug.raise)(new Error("Missing ComputeGraphContext"));
|
|
584
|
+
const [graph] = (0, import_react_hooks.useAsyncState)(async () => space && registry.getOrCreateGraph(space), [
|
|
585
|
+
space,
|
|
586
|
+
registry
|
|
587
|
+
]);
|
|
588
|
+
return graph;
|
|
589
|
+
};
|
|
354
590
|
var FormattingModel = class {
|
|
355
|
-
constructor(
|
|
356
|
-
this.
|
|
591
|
+
constructor(_model) {
|
|
592
|
+
this._model = _model;
|
|
357
593
|
}
|
|
358
594
|
/**
|
|
359
595
|
* Get formatted string value and className for cell.
|
|
360
596
|
*/
|
|
361
597
|
getFormatting(cell) {
|
|
362
|
-
const value = this.
|
|
598
|
+
const value = this._model.getValue(cell);
|
|
363
599
|
if (value === void 0 || value === null) {
|
|
364
600
|
return {};
|
|
365
601
|
}
|
|
366
602
|
const locales = void 0;
|
|
367
|
-
const idx = this.
|
|
368
|
-
let formatting = this.
|
|
603
|
+
const idx = addressToIndex(this._model.sheet, cell);
|
|
604
|
+
let formatting = this._model.sheet.formatting?.[idx] ?? {};
|
|
369
605
|
const classNames = [
|
|
370
606
|
...formatting?.classNames ?? []
|
|
371
607
|
];
|
|
372
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
373
|
-
const range = this.
|
|
374
|
-
if (
|
|
608
|
+
for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
|
|
609
|
+
const range = rangeFromIndex(this._model.sheet, idx2);
|
|
610
|
+
if (inRange(range, cell)) {
|
|
375
611
|
if (_formatting.classNames) {
|
|
376
612
|
classNames.push(..._formatting.classNames);
|
|
377
613
|
}
|
|
@@ -381,9 +617,9 @@ var FormattingModel = class {
|
|
|
381
617
|
}
|
|
382
618
|
}
|
|
383
619
|
const defaultNumber = "justify-end font-mono";
|
|
384
|
-
const type = formatting?.type ?? this.
|
|
620
|
+
const type = formatting?.type ?? this._model.getValueType(cell);
|
|
385
621
|
switch (type) {
|
|
386
|
-
case
|
|
622
|
+
case import_chunk_AOP42UAA.ValueTypeEnum.Boolean: {
|
|
387
623
|
return {
|
|
388
624
|
value: value.toLocaleString().toUpperCase(),
|
|
389
625
|
classNames: [
|
|
@@ -395,7 +631,7 @@ var FormattingModel = class {
|
|
|
395
631
|
//
|
|
396
632
|
// Numbers.
|
|
397
633
|
//
|
|
398
|
-
case
|
|
634
|
+
case import_chunk_AOP42UAA.ValueTypeEnum.Number: {
|
|
399
635
|
return {
|
|
400
636
|
value: value.toLocaleString(locales),
|
|
401
637
|
classNames: [
|
|
@@ -404,7 +640,7 @@ var FormattingModel = class {
|
|
|
404
640
|
]
|
|
405
641
|
};
|
|
406
642
|
}
|
|
407
|
-
case
|
|
643
|
+
case import_chunk_AOP42UAA.ValueTypeEnum.Percent: {
|
|
408
644
|
return {
|
|
409
645
|
value: value * 100 + "%",
|
|
410
646
|
classNames: [
|
|
@@ -413,7 +649,7 @@ var FormattingModel = class {
|
|
|
413
649
|
]
|
|
414
650
|
};
|
|
415
651
|
}
|
|
416
|
-
case
|
|
652
|
+
case import_chunk_AOP42UAA.ValueTypeEnum.Currency: {
|
|
417
653
|
return {
|
|
418
654
|
value: value.toLocaleString(locales, {
|
|
419
655
|
style: "currency",
|
|
@@ -430,22 +666,22 @@ var FormattingModel = class {
|
|
|
430
666
|
//
|
|
431
667
|
// Dates.
|
|
432
668
|
//
|
|
433
|
-
case
|
|
434
|
-
const date = this.
|
|
669
|
+
case import_chunk_AOP42UAA.ValueTypeEnum.DateTime: {
|
|
670
|
+
const date = this._model.toLocalDate(value);
|
|
435
671
|
return {
|
|
436
672
|
value: date.toLocaleString(locales),
|
|
437
673
|
classNames
|
|
438
674
|
};
|
|
439
675
|
}
|
|
440
|
-
case
|
|
441
|
-
const date = this.
|
|
676
|
+
case import_chunk_AOP42UAA.ValueTypeEnum.Date: {
|
|
677
|
+
const date = this._model.toLocalDate(value);
|
|
442
678
|
return {
|
|
443
679
|
value: date.toLocaleDateString(locales),
|
|
444
680
|
classNames
|
|
445
681
|
};
|
|
446
682
|
}
|
|
447
|
-
case
|
|
448
|
-
const date = this.
|
|
683
|
+
case import_chunk_AOP42UAA.ValueTypeEnum.Time: {
|
|
684
|
+
const date = this._model.toLocalDate(value);
|
|
449
685
|
return {
|
|
450
686
|
value: date.toLocaleTimeString(locales),
|
|
451
687
|
classNames
|
|
@@ -460,83 +696,535 @@ var FormattingModel = class {
|
|
|
460
696
|
}
|
|
461
697
|
}
|
|
462
698
|
};
|
|
463
|
-
var
|
|
464
|
-
var
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
699
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
|
|
700
|
+
var typeMap = {
|
|
701
|
+
BOOLEAN: import_chunk_AOP42UAA.ValueTypeEnum.Boolean,
|
|
702
|
+
NUMBER_RAW: import_chunk_AOP42UAA.ValueTypeEnum.Number,
|
|
703
|
+
NUMBER_PERCENT: import_chunk_AOP42UAA.ValueTypeEnum.Percent,
|
|
704
|
+
NUMBER_CURRENCY: import_chunk_AOP42UAA.ValueTypeEnum.Currency,
|
|
705
|
+
NUMBER_DATETIME: import_chunk_AOP42UAA.ValueTypeEnum.DateTime,
|
|
706
|
+
NUMBER_DATE: import_chunk_AOP42UAA.ValueTypeEnum.Date,
|
|
707
|
+
NUMBER_TIME: import_chunk_AOP42UAA.ValueTypeEnum.Time
|
|
708
|
+
};
|
|
709
|
+
var getTopLeft = (range) => {
|
|
710
|
+
const to = range.to ?? range.from;
|
|
711
|
+
return {
|
|
712
|
+
row: Math.min(range.from.row, to.row),
|
|
713
|
+
col: Math.min(range.from.col, to.col)
|
|
714
|
+
};
|
|
478
715
|
};
|
|
479
|
-
var
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
716
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
717
|
+
sheet,
|
|
718
|
+
row: cell.row,
|
|
719
|
+
col: cell.col
|
|
720
|
+
});
|
|
721
|
+
var toModelRange = (sheet, range) => ({
|
|
722
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
723
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
724
|
+
});
|
|
725
|
+
var SheetModel = class extends import_context.Resource {
|
|
726
|
+
constructor(_graph, _sheet, _options = {}) {
|
|
727
|
+
super();
|
|
728
|
+
this._graph = _graph;
|
|
729
|
+
this._sheet = _sheet;
|
|
730
|
+
this._options = _options;
|
|
731
|
+
this.id = `model-${import_keys.PublicKey.random().truncate()}`;
|
|
732
|
+
this.update = new import_async2.Event();
|
|
733
|
+
}
|
|
734
|
+
get graph() {
|
|
735
|
+
return this._graph;
|
|
736
|
+
}
|
|
737
|
+
get sheet() {
|
|
738
|
+
return this._sheet;
|
|
739
|
+
}
|
|
740
|
+
get readonly() {
|
|
741
|
+
return this._options.readonly;
|
|
742
|
+
}
|
|
743
|
+
get bounds() {
|
|
744
|
+
return {
|
|
745
|
+
rows: this._sheet.rows.length,
|
|
746
|
+
columns: this._sheet.columns.length
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Initialize sheet and engine.
|
|
751
|
+
*/
|
|
752
|
+
async _open() {
|
|
753
|
+
(0, import_log2.log)("initialize", {
|
|
754
|
+
id: this.id
|
|
755
|
+
}, {
|
|
756
|
+
F: __dxlog_file2,
|
|
757
|
+
L: 103,
|
|
758
|
+
S: this,
|
|
759
|
+
C: (f, a) => f(...a)
|
|
760
|
+
});
|
|
761
|
+
initialize(this._sheet);
|
|
762
|
+
this._node = await this._graph.getOrCreateNode((0, import_chunk_P5QYYEHQ.createSheetName)(this._sheet.id));
|
|
763
|
+
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
764
|
+
this._ctx.onDispose(unsubscribe);
|
|
765
|
+
this.reset();
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Update engine.
|
|
769
|
+
* NOTE: This resets the undo history.
|
|
770
|
+
* @deprecated
|
|
771
|
+
*/
|
|
772
|
+
reset() {
|
|
773
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
774
|
+
F: __dxlog_file2,
|
|
775
|
+
L: 122,
|
|
776
|
+
S: this,
|
|
777
|
+
A: [
|
|
778
|
+
"this._node",
|
|
779
|
+
""
|
|
780
|
+
]
|
|
781
|
+
});
|
|
782
|
+
this._node.graph.hf.clearSheet(this._node.sheetId);
|
|
783
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
784
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
785
|
+
F: __dxlog_file2,
|
|
786
|
+
L: 125,
|
|
787
|
+
S: this,
|
|
788
|
+
A: [
|
|
789
|
+
"this._node",
|
|
790
|
+
""
|
|
791
|
+
]
|
|
792
|
+
});
|
|
793
|
+
const { col, row } = addressFromIndex(this._sheet, key);
|
|
794
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
795
|
+
value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
796
|
+
}
|
|
797
|
+
this._node.graph.hf.setCellContents({
|
|
798
|
+
sheet: this._node.sheetId,
|
|
799
|
+
row,
|
|
800
|
+
col
|
|
801
|
+
}, value);
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Recalculate formulas.
|
|
806
|
+
* NOTE: This resets the undo history.
|
|
807
|
+
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
808
|
+
* @deprecated
|
|
809
|
+
*/
|
|
810
|
+
// TODO(burdon): Remove.
|
|
811
|
+
recalculate() {
|
|
812
|
+
this._node?.graph.hf.rebuildAndRecalculate();
|
|
813
|
+
}
|
|
814
|
+
insertRows(i, n = 1) {
|
|
815
|
+
insertIndices(this._sheet.rows, i, n, MAX_ROWS);
|
|
816
|
+
this.reset();
|
|
817
|
+
}
|
|
818
|
+
insertColumns(i, n = 1) {
|
|
819
|
+
insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
|
|
820
|
+
this.reset();
|
|
821
|
+
}
|
|
822
|
+
//
|
|
823
|
+
// Undoable actions.
|
|
824
|
+
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
825
|
+
//
|
|
826
|
+
/**
|
|
827
|
+
* Clear range of values.
|
|
828
|
+
*/
|
|
829
|
+
clear(range) {
|
|
830
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
831
|
+
F: __dxlog_file2,
|
|
832
|
+
L: 167,
|
|
833
|
+
S: this,
|
|
834
|
+
A: [
|
|
835
|
+
"this._node",
|
|
836
|
+
""
|
|
837
|
+
]
|
|
838
|
+
});
|
|
839
|
+
const topLeft = getTopLeft(range);
|
|
840
|
+
const values = this._iterRange(range, () => null);
|
|
841
|
+
this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
|
|
842
|
+
this._iterRange(range, (cell) => {
|
|
843
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
844
|
+
delete this._sheet.cells[idx];
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
cut(range) {
|
|
848
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
849
|
+
F: __dxlog_file2,
|
|
850
|
+
L: 178,
|
|
851
|
+
S: this,
|
|
852
|
+
A: [
|
|
853
|
+
"this._node",
|
|
854
|
+
""
|
|
855
|
+
]
|
|
856
|
+
});
|
|
857
|
+
this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
|
|
858
|
+
this._iterRange(range, (cell) => {
|
|
859
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
860
|
+
delete this._sheet.cells[idx];
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
copy(range) {
|
|
864
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
865
|
+
F: __dxlog_file2,
|
|
866
|
+
L: 187,
|
|
867
|
+
S: this,
|
|
868
|
+
A: [
|
|
869
|
+
"this._node",
|
|
870
|
+
""
|
|
871
|
+
]
|
|
872
|
+
});
|
|
873
|
+
this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
|
|
874
|
+
}
|
|
875
|
+
paste(cell) {
|
|
876
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
877
|
+
F: __dxlog_file2,
|
|
878
|
+
L: 192,
|
|
879
|
+
S: this,
|
|
880
|
+
A: [
|
|
881
|
+
"this._node",
|
|
882
|
+
""
|
|
883
|
+
]
|
|
884
|
+
});
|
|
885
|
+
if (!this._node.graph.hf.isClipboardEmpty()) {
|
|
886
|
+
const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
|
|
887
|
+
for (const change of changes) {
|
|
888
|
+
if (change instanceof import_hyperformula.ExportedCellChange) {
|
|
889
|
+
const { address, newValue } = change;
|
|
890
|
+
const idx = addressToIndex(this._sheet, {
|
|
891
|
+
row: address.row,
|
|
892
|
+
col: address.col
|
|
893
|
+
});
|
|
894
|
+
this._sheet.cells[idx] = {
|
|
895
|
+
value: newValue
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
// TODO(burdon): Display undo/redo state.
|
|
902
|
+
undo() {
|
|
903
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
904
|
+
F: __dxlog_file2,
|
|
905
|
+
L: 207,
|
|
906
|
+
S: this,
|
|
907
|
+
A: [
|
|
908
|
+
"this._node",
|
|
909
|
+
""
|
|
910
|
+
]
|
|
911
|
+
});
|
|
912
|
+
if (this._node.graph.hf.isThereSomethingToUndo()) {
|
|
913
|
+
this._node.graph.hf.undo();
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
redo() {
|
|
917
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
918
|
+
F: __dxlog_file2,
|
|
919
|
+
L: 215,
|
|
920
|
+
S: this,
|
|
921
|
+
A: [
|
|
922
|
+
"this._node",
|
|
923
|
+
""
|
|
924
|
+
]
|
|
925
|
+
});
|
|
926
|
+
if (this._node.graph.hf.isThereSomethingToRedo()) {
|
|
927
|
+
this._node.graph.hf.redo();
|
|
483
928
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Get value from sheet.
|
|
932
|
+
*/
|
|
933
|
+
getCellValue(cell) {
|
|
934
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
935
|
+
return this._sheet.cells[idx]?.value ?? null;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Get value as a string for editing.
|
|
939
|
+
*/
|
|
940
|
+
getCellText(cell) {
|
|
941
|
+
const value = this.getCellValue(cell);
|
|
942
|
+
if (value == null) {
|
|
943
|
+
return void 0;
|
|
944
|
+
}
|
|
945
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
946
|
+
return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
487
947
|
} else {
|
|
488
|
-
return
|
|
948
|
+
return String(value);
|
|
489
949
|
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Get array of raw values from sheet.
|
|
953
|
+
*/
|
|
954
|
+
getCellValues(range) {
|
|
955
|
+
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Gets the regular or computed value from the engine.
|
|
959
|
+
*/
|
|
960
|
+
getValue(cell) {
|
|
961
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
962
|
+
F: __dxlog_file2,
|
|
963
|
+
L: 258,
|
|
964
|
+
S: this,
|
|
965
|
+
A: [
|
|
966
|
+
"this._node",
|
|
967
|
+
""
|
|
968
|
+
]
|
|
969
|
+
});
|
|
970
|
+
const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
|
|
971
|
+
if (value instanceof import_hyperformula.DetailedCellError) {
|
|
972
|
+
return value.toString();
|
|
497
973
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
974
|
+
return value;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Get value type.
|
|
978
|
+
*/
|
|
979
|
+
getValueType(cell) {
|
|
980
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
981
|
+
F: __dxlog_file2,
|
|
982
|
+
L: 271,
|
|
983
|
+
S: this,
|
|
984
|
+
A: [
|
|
985
|
+
"this._node",
|
|
986
|
+
""
|
|
987
|
+
]
|
|
988
|
+
});
|
|
989
|
+
const addr = toSimpleCellAddress(this._node.sheetId, cell);
|
|
990
|
+
const type = this._node.graph.hf.getCellValueDetailedType(addr);
|
|
991
|
+
return typeMap[type];
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Sets the value, updating the sheet and engine.
|
|
995
|
+
*/
|
|
996
|
+
setValue(cell, value) {
|
|
997
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
998
|
+
F: __dxlog_file2,
|
|
999
|
+
L: 281,
|
|
1000
|
+
S: this,
|
|
1001
|
+
A: [
|
|
1002
|
+
"this._node",
|
|
1003
|
+
""
|
|
1004
|
+
]
|
|
1005
|
+
});
|
|
1006
|
+
if (this._options.readonly) {
|
|
1007
|
+
throw new ReadonlyException();
|
|
1008
|
+
}
|
|
1009
|
+
let refresh = false;
|
|
1010
|
+
if (cell.row >= this._sheet.rows.length) {
|
|
1011
|
+
insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
|
|
1012
|
+
refresh = true;
|
|
1013
|
+
}
|
|
1014
|
+
if (cell.col >= this._sheet.columns.length) {
|
|
1015
|
+
insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
|
|
1016
|
+
refresh = true;
|
|
1017
|
+
}
|
|
1018
|
+
if (refresh) {
|
|
1019
|
+
this.reset();
|
|
1020
|
+
}
|
|
1021
|
+
this._node.graph.hf.setCellContents({
|
|
1022
|
+
sheet: this._node.sheetId,
|
|
1023
|
+
row: cell.row,
|
|
1024
|
+
col: cell.col
|
|
1025
|
+
}, [
|
|
1026
|
+
[
|
|
1027
|
+
typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
|
|
1028
|
+
]
|
|
1029
|
+
]);
|
|
1030
|
+
const idx = addressToIndex(this._sheet, cell);
|
|
1031
|
+
if (value === void 0 || value === null) {
|
|
1032
|
+
delete this._sheet.cells[idx];
|
|
501
1033
|
} else {
|
|
502
|
-
|
|
1034
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1035
|
+
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1036
|
+
}
|
|
1037
|
+
this._sheet.cells[idx] = {
|
|
1038
|
+
value
|
|
1039
|
+
};
|
|
503
1040
|
}
|
|
504
|
-
}
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Sets values from a simple map.
|
|
1044
|
+
*/
|
|
1045
|
+
setValues(values) {
|
|
1046
|
+
Object.entries(values).forEach(([key, { value }]) => {
|
|
1047
|
+
this.setValue(addressFromA1Notation(key), value);
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Iterate range.
|
|
1052
|
+
*/
|
|
1053
|
+
_iterRange(range, cb) {
|
|
1054
|
+
const to = range.to ?? range.from;
|
|
1055
|
+
const rowRange = [
|
|
1056
|
+
Math.min(range.from.row, to.row),
|
|
1057
|
+
Math.max(range.from.row, to.row)
|
|
1058
|
+
];
|
|
1059
|
+
const columnRange = [
|
|
1060
|
+
Math.min(range.from.col, to.col),
|
|
1061
|
+
Math.max(range.from.col, to.col)
|
|
1062
|
+
];
|
|
1063
|
+
const rows = [];
|
|
1064
|
+
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
1065
|
+
const rowCells = [];
|
|
1066
|
+
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
1067
|
+
const value = cb({
|
|
1068
|
+
row,
|
|
1069
|
+
col: column
|
|
1070
|
+
});
|
|
1071
|
+
if (value !== void 0) {
|
|
1072
|
+
rowCells.push(value);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
rows.push(rowCells);
|
|
1076
|
+
}
|
|
1077
|
+
return rows;
|
|
1078
|
+
}
|
|
1079
|
+
// TODO(burdon): Delete index.
|
|
1080
|
+
_deleteIndices(indices, i, n) {
|
|
1081
|
+
throw new Error("Not implemented");
|
|
1082
|
+
}
|
|
1083
|
+
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
1084
|
+
_moveIndices(indices, i, j, n) {
|
|
1085
|
+
throw new Error("Not implemented");
|
|
1086
|
+
}
|
|
1087
|
+
//
|
|
1088
|
+
// Indices.
|
|
1089
|
+
//
|
|
1090
|
+
/**
|
|
1091
|
+
* Map from A1 notation to indices.
|
|
1092
|
+
*/
|
|
1093
|
+
mapFormulaRefsToIndices(formula) {
|
|
1094
|
+
(0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
|
|
1095
|
+
F: __dxlog_file2,
|
|
1096
|
+
L: 370,
|
|
1097
|
+
S: this,
|
|
1098
|
+
A: [
|
|
1099
|
+
"formula.charAt(0) === '='",
|
|
1100
|
+
""
|
|
1101
|
+
]
|
|
1102
|
+
});
|
|
1103
|
+
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
1104
|
+
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Map from indices to A1 notation.
|
|
1109
|
+
*/
|
|
1110
|
+
mapFormulaIndicesToRefs(formula) {
|
|
1111
|
+
(0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
|
|
1112
|
+
F: __dxlog_file2,
|
|
1113
|
+
L: 380,
|
|
1114
|
+
S: this,
|
|
1115
|
+
A: [
|
|
1116
|
+
"formula.charAt(0) === '='",
|
|
1117
|
+
""
|
|
1118
|
+
]
|
|
1119
|
+
});
|
|
1120
|
+
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
1121
|
+
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
//
|
|
1125
|
+
// Values
|
|
1126
|
+
//
|
|
1127
|
+
/**
|
|
1128
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
1129
|
+
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
1130
|
+
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
1131
|
+
*/
|
|
1132
|
+
toLocalDate(num) {
|
|
1133
|
+
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
1134
|
+
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1135
|
+
}
|
|
1136
|
+
toDateTime(num) {
|
|
1137
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1138
|
+
F: __dxlog_file2,
|
|
1139
|
+
L: 401,
|
|
1140
|
+
S: this,
|
|
1141
|
+
A: [
|
|
1142
|
+
"this._node",
|
|
1143
|
+
""
|
|
1144
|
+
]
|
|
1145
|
+
});
|
|
1146
|
+
return this._node.graph.hf.numberToDateTime(num);
|
|
1147
|
+
}
|
|
1148
|
+
toDate(num) {
|
|
1149
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1150
|
+
F: __dxlog_file2,
|
|
1151
|
+
L: 406,
|
|
1152
|
+
S: this,
|
|
1153
|
+
A: [
|
|
1154
|
+
"this._node",
|
|
1155
|
+
""
|
|
1156
|
+
]
|
|
1157
|
+
});
|
|
1158
|
+
return this._node.graph.hf.numberToDate(num);
|
|
1159
|
+
}
|
|
1160
|
+
toTime(num) {
|
|
1161
|
+
(0, import_invariant3.invariant)(this._node, void 0, {
|
|
1162
|
+
F: __dxlog_file2,
|
|
1163
|
+
L: 411,
|
|
1164
|
+
S: this,
|
|
1165
|
+
A: [
|
|
1166
|
+
"this._node",
|
|
1167
|
+
""
|
|
1168
|
+
]
|
|
1169
|
+
});
|
|
1170
|
+
return this._node.graph.hf.numberToTime(num);
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
var useFormattingModel = (model) => {
|
|
1174
|
+
return (0, import_react9.useMemo)(() => model && new FormattingModel(model), [
|
|
1175
|
+
model
|
|
1176
|
+
]);
|
|
505
1177
|
};
|
|
506
|
-
var
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
(0, import_react6.useEffect)(() => {
|
|
1178
|
+
var useSheetModel = (graph, sheet, { readonly } = {}) => {
|
|
1179
|
+
const [model, setModel] = (0, import_react10.useState)();
|
|
1180
|
+
(0, import_react10.useEffect)(() => {
|
|
1181
|
+
if (!graph || !sheet) {
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
513
1184
|
let model2;
|
|
514
|
-
let formatting2;
|
|
515
1185
|
const t = setTimeout(async () => {
|
|
516
|
-
model2 = new
|
|
517
|
-
readonly
|
|
518
|
-
mapFormulaBindingToId,
|
|
519
|
-
mapFormulaBindingFromId
|
|
1186
|
+
model2 = new SheetModel(graph, sheet, {
|
|
1187
|
+
readonly
|
|
520
1188
|
});
|
|
521
|
-
await model2.
|
|
522
|
-
|
|
523
|
-
setModels([
|
|
524
|
-
model2,
|
|
525
|
-
formatting2
|
|
526
|
-
]);
|
|
1189
|
+
await model2.open();
|
|
1190
|
+
setModel(model2);
|
|
527
1191
|
});
|
|
528
1192
|
return () => {
|
|
529
1193
|
clearTimeout(t);
|
|
530
|
-
void model2?.
|
|
1194
|
+
void model2?.close();
|
|
531
1195
|
};
|
|
532
1196
|
}, [
|
|
533
1197
|
graph,
|
|
1198
|
+
sheet,
|
|
534
1199
|
readonly
|
|
535
1200
|
]);
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
1201
|
+
return model;
|
|
1202
|
+
};
|
|
1203
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
1204
|
+
var SheetContext = /* @__PURE__ */ (0, import_react5.createContext)(null);
|
|
1205
|
+
var useSheetContext = () => {
|
|
1206
|
+
const context = (0, import_react5.useContext)(SheetContext);
|
|
1207
|
+
(0, import_invariant2.invariant)(context, void 0, {
|
|
1208
|
+
F: __dxlog_file3,
|
|
1209
|
+
L: 43,
|
|
1210
|
+
S: void 0,
|
|
1211
|
+
A: [
|
|
1212
|
+
"context",
|
|
1213
|
+
""
|
|
1214
|
+
]
|
|
1215
|
+
});
|
|
1216
|
+
return context;
|
|
1217
|
+
};
|
|
1218
|
+
var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
1219
|
+
const model = useSheetModel(graph, sheet, {
|
|
1220
|
+
readonly
|
|
1221
|
+
});
|
|
1222
|
+
const formatting = useFormattingModel(model);
|
|
1223
|
+
const [cursor, setCursor] = (0, import_react5.useState)();
|
|
1224
|
+
const [range, setRange] = (0, import_react5.useState)();
|
|
1225
|
+
const [editing, setEditing] = (0, import_react5.useState)(false);
|
|
1226
|
+
const decorations = (0, import_react5.useMemo)(() => createDecorations(), []);
|
|
1227
|
+
return !model || !formatting ? null : /* @__PURE__ */ import_react5.default.createElement(SheetContext.Provider, {
|
|
540
1228
|
value: {
|
|
541
1229
|
model,
|
|
542
1230
|
formatting,
|
|
@@ -547,10 +1235,168 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
|
|
|
547
1235
|
editing,
|
|
548
1236
|
setEditing,
|
|
549
1237
|
// TODO(burdon): Change to event.
|
|
550
|
-
onInfo
|
|
1238
|
+
onInfo,
|
|
1239
|
+
decorations
|
|
551
1240
|
}
|
|
552
1241
|
}, children);
|
|
553
1242
|
};
|
|
1243
|
+
var CommentIndicator = () => {
|
|
1244
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1245
|
+
role: "none",
|
|
1246
|
+
className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
|
|
1247
|
+
});
|
|
1248
|
+
};
|
|
1249
|
+
var ThreadedCellWrapper = ({ children }) => {
|
|
1250
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1251
|
+
const [isHovered, setIsHovered] = import_react11.default.useState(false);
|
|
1252
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_BNARJ5GM.SHEET_PLUGIN);
|
|
1253
|
+
const handleClick = import_react11.default.useCallback((_event) => {
|
|
1254
|
+
void dispatch({
|
|
1255
|
+
action: import_app_framework.LayoutAction.SET_LAYOUT,
|
|
1256
|
+
data: {
|
|
1257
|
+
element: "complementary",
|
|
1258
|
+
state: true
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
}, [
|
|
1262
|
+
dispatch
|
|
1263
|
+
]);
|
|
1264
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1265
|
+
role: "none",
|
|
1266
|
+
className: "relative h-full is-full",
|
|
1267
|
+
onMouseEnter: () => {
|
|
1268
|
+
setIsHovered(true);
|
|
1269
|
+
},
|
|
1270
|
+
onMouseLeave: () => {
|
|
1271
|
+
setIsHovered(false);
|
|
1272
|
+
}
|
|
1273
|
+
}, /* @__PURE__ */ import_react11.default.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1274
|
+
className: "absolute inset-0 flex items-center justify-end pr-1"
|
|
1275
|
+
}, /* @__PURE__ */ import_react11.default.createElement("button", {
|
|
1276
|
+
className: "ch-button text-xs min-bs-0 p-1",
|
|
1277
|
+
onClick: handleClick,
|
|
1278
|
+
"aria-label": t("open comment for sheet cell")
|
|
1279
|
+
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui.Icon, {
|
|
1280
|
+
icon: "ph--chat--regular",
|
|
1281
|
+
"aria-hidden": true
|
|
1282
|
+
}))), children);
|
|
1283
|
+
};
|
|
1284
|
+
var createThreadDecoration = (cellIndex, threadId, sheetId) => {
|
|
1285
|
+
return {
|
|
1286
|
+
type: "comment",
|
|
1287
|
+
cellIndex,
|
|
1288
|
+
decorate: (props) => /* @__PURE__ */ import_react11.default.createElement(ThreadedCellWrapper, props)
|
|
1289
|
+
};
|
|
1290
|
+
};
|
|
1291
|
+
var useUpdateCursorOnThreadSelection = () => {
|
|
1292
|
+
const { setCursor, model } = useSheetContext();
|
|
1293
|
+
const handleScrollIntoView = (0, import_react11.useCallback)(({ action, data }) => {
|
|
1294
|
+
switch (action) {
|
|
1295
|
+
case import_app_framework.LayoutAction.SCROLL_INTO_VIEW: {
|
|
1296
|
+
if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo2.fullyQualifiedId)(model.sheet)) {
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
const cellAddress = addressFromIndex(model.sheet, data.cursor);
|
|
1300
|
+
setCursor(cellAddress);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}, [
|
|
1304
|
+
model.sheet,
|
|
1305
|
+
setCursor
|
|
1306
|
+
]);
|
|
1307
|
+
(0, import_app_framework.useIntentResolver)(import_chunk_BNARJ5GM.SHEET_PLUGIN, handleScrollIntoView);
|
|
1308
|
+
};
|
|
1309
|
+
var useSelectThreadOnCursorChange = () => {
|
|
1310
|
+
const { cursor, model } = useSheetContext();
|
|
1311
|
+
const dispatch = (0, import_app_framework.useIntentDispatcher)();
|
|
1312
|
+
const activeThreads = (0, import_react11.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
|
|
1313
|
+
JSON.stringify(model.sheet.threads)
|
|
1314
|
+
]);
|
|
1315
|
+
const activeThreadAddresses = (0, import_react11.useMemo)(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
|
|
1316
|
+
activeThreads,
|
|
1317
|
+
model.sheet
|
|
1318
|
+
]);
|
|
1319
|
+
const selectClosestThread = (0, import_react11.useCallback)((cellAddress) => {
|
|
1320
|
+
if (!cellAddress || !activeThreads) {
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
|
|
1324
|
+
if (closestThreadAnchor) {
|
|
1325
|
+
const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
|
|
1326
|
+
if (closestThread) {
|
|
1327
|
+
void dispatch([
|
|
1328
|
+
{
|
|
1329
|
+
action: "dxos.org/plugin/thread/action/select",
|
|
1330
|
+
data: {
|
|
1331
|
+
current: (0, import_echo2.fullyQualifiedId)(closestThread)
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
]);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}, [
|
|
1338
|
+
dispatch,
|
|
1339
|
+
activeThreads,
|
|
1340
|
+
activeThreadAddresses,
|
|
1341
|
+
model.sheet
|
|
1342
|
+
]);
|
|
1343
|
+
const debounced = (0, import_react11.useMemo)(() => {
|
|
1344
|
+
return (0, import_async3.debounce)((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
|
|
1345
|
+
}, [
|
|
1346
|
+
selectClosestThread
|
|
1347
|
+
]);
|
|
1348
|
+
(0, import_react11.useEffect)(() => {
|
|
1349
|
+
if (!cursor) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
debounced(cursor);
|
|
1353
|
+
}, [
|
|
1354
|
+
cursor,
|
|
1355
|
+
selectClosestThread
|
|
1356
|
+
]);
|
|
1357
|
+
};
|
|
1358
|
+
var useThreadDecorations = () => {
|
|
1359
|
+
const { decorations, model } = useSheetContext();
|
|
1360
|
+
const sheet = (0, import_react11.useMemo)(() => model.sheet, [
|
|
1361
|
+
model.sheet
|
|
1362
|
+
]);
|
|
1363
|
+
const sheetId = (0, import_react11.useMemo)(() => (0, import_echo2.fullyQualifiedId)(sheet), [
|
|
1364
|
+
sheet
|
|
1365
|
+
]);
|
|
1366
|
+
(0, import_react11.useEffect)(() => {
|
|
1367
|
+
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
1368
|
+
const activeThreadAnchors = /* @__PURE__ */ new Set();
|
|
1369
|
+
if (!sheet.threads) {
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
for (const thread of sheet.threads) {
|
|
1373
|
+
if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
|
|
1374
|
+
continue;
|
|
1375
|
+
}
|
|
1376
|
+
activeThreadAnchors.add(thread.anchor);
|
|
1377
|
+
const index = thread.anchor;
|
|
1378
|
+
const existingDecorations = decorations.getDecorationsForCell(index);
|
|
1379
|
+
if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
|
|
1380
|
+
decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
for (const decoration of decorations.getAllDecorations()) {
|
|
1384
|
+
if (decoration.type !== "comment") {
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
if (!activeThreadAnchors.has(decoration.cellIndex)) {
|
|
1388
|
+
decorations.removeDecoration(decoration.cellIndex, "comment");
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
return () => unsubscribe();
|
|
1393
|
+
});
|
|
1394
|
+
};
|
|
1395
|
+
var useThreads = () => {
|
|
1396
|
+
useUpdateCursorOnThreadSelection();
|
|
1397
|
+
useSelectThreadOnCursorChange();
|
|
1398
|
+
useThreadDecorations();
|
|
1399
|
+
};
|
|
554
1400
|
var getRelativeClientRect = (root, element) => {
|
|
555
1401
|
const rootRect = root.getBoundingClientRect();
|
|
556
1402
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -627,21 +1473,61 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
627
1473
|
{
|
|
628
1474
|
key: "Enter",
|
|
629
1475
|
run: (editor) => {
|
|
630
|
-
onClose(editor.state.doc.toString()
|
|
1476
|
+
onClose(editor.state.doc.toString(), {
|
|
1477
|
+
key: "Enter"
|
|
1478
|
+
});
|
|
1479
|
+
return true;
|
|
1480
|
+
},
|
|
1481
|
+
shift: (editor) => {
|
|
1482
|
+
onClose(editor.state.doc.toString(), {
|
|
1483
|
+
key: "Enter",
|
|
1484
|
+
shift: true
|
|
1485
|
+
});
|
|
1486
|
+
return true;
|
|
1487
|
+
}
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
key: "Tab",
|
|
1491
|
+
run: (editor) => {
|
|
1492
|
+
onClose(editor.state.doc.toString(), {
|
|
1493
|
+
key: "Tab"
|
|
1494
|
+
});
|
|
1495
|
+
return true;
|
|
1496
|
+
},
|
|
1497
|
+
shift: (editor) => {
|
|
1498
|
+
onClose(editor.state.doc.toString(), {
|
|
1499
|
+
key: "Tab",
|
|
1500
|
+
shift: true
|
|
1501
|
+
});
|
|
631
1502
|
return true;
|
|
632
1503
|
}
|
|
633
1504
|
},
|
|
634
1505
|
{
|
|
635
1506
|
key: "Escape",
|
|
636
1507
|
run: () => {
|
|
637
|
-
onClose(void 0
|
|
1508
|
+
onClose(void 0, {
|
|
1509
|
+
key: "Escape"
|
|
1510
|
+
});
|
|
638
1511
|
return true;
|
|
639
1512
|
}
|
|
640
1513
|
}
|
|
641
1514
|
]);
|
|
642
1515
|
};
|
|
643
|
-
var
|
|
644
|
-
|
|
1516
|
+
var editorVariants = {
|
|
1517
|
+
// TODO(thure): remove when legacy is no longer used.
|
|
1518
|
+
legacy: {
|
|
1519
|
+
root: "flex w-full",
|
|
1520
|
+
editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
|
|
1521
|
+
content: "!px-2 !py-1"
|
|
1522
|
+
},
|
|
1523
|
+
grid: {
|
|
1524
|
+
root: "absolute z-[1]",
|
|
1525
|
+
editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
|
|
1526
|
+
content: "!border !border-transparent !p-0.5"
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
|
|
1530
|
+
const { themeMode } = (0, import_react_ui2.useThemeContext)();
|
|
645
1531
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
646
1532
|
return {
|
|
647
1533
|
autoFocus,
|
|
@@ -667,21 +1553,29 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
|
667
1553
|
themeMode,
|
|
668
1554
|
slots: {
|
|
669
1555
|
editor: {
|
|
670
|
-
className:
|
|
1556
|
+
className: editorVariants[variant].editor
|
|
671
1557
|
},
|
|
672
1558
|
content: {
|
|
673
|
-
className:
|
|
1559
|
+
className: editorVariants[variant].content
|
|
674
1560
|
}
|
|
675
1561
|
}
|
|
676
1562
|
})
|
|
677
1563
|
]
|
|
678
1564
|
};
|
|
679
1565
|
}, [
|
|
680
|
-
extension
|
|
1566
|
+
extension,
|
|
1567
|
+
autoFocus,
|
|
1568
|
+
value,
|
|
1569
|
+
variant,
|
|
1570
|
+
onBlur
|
|
681
1571
|
]);
|
|
682
|
-
return /* @__PURE__ */
|
|
1572
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
683
1573
|
ref: parentRef,
|
|
684
|
-
className:
|
|
1574
|
+
className: editorVariants[variant].root,
|
|
1575
|
+
style: box,
|
|
1576
|
+
...gridId && {
|
|
1577
|
+
"data-grid": gridId
|
|
1578
|
+
}
|
|
685
1579
|
});
|
|
686
1580
|
};
|
|
687
1581
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -794,13 +1688,7 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
794
1688
|
// NOTE: Useful for debugging.
|
|
795
1689
|
closeOnBlur: false,
|
|
796
1690
|
icons: false,
|
|
797
|
-
tooltipClass: () => (0,
|
|
798
|
-
// TODO(burdon): Factor out fragments.
|
|
799
|
-
// TODO(burdon): Size to make width same as column.
|
|
800
|
-
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
801
|
-
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
802
|
-
"border-separator"
|
|
803
|
-
)
|
|
1691
|
+
tooltipClass: () => (0, import_react_ui_theme2.mx)("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
|
|
804
1692
|
}),
|
|
805
1693
|
import_view2.keymap.of([
|
|
806
1694
|
{
|
|
@@ -887,7 +1775,7 @@ var visitTree = (node, callback) => {
|
|
|
887
1775
|
}
|
|
888
1776
|
return false;
|
|
889
1777
|
};
|
|
890
|
-
var
|
|
1778
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
891
1779
|
var fragments = {
|
|
892
1780
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
893
1781
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -895,18 +1783,19 @@ var fragments = {
|
|
|
895
1783
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
896
1784
|
};
|
|
897
1785
|
var SheetRoot = ({ children, ...props }) => {
|
|
898
|
-
return /* @__PURE__ */
|
|
1786
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetContextProvider, props, children);
|
|
899
1787
|
};
|
|
900
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
1788
|
+
var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, numRows, numCols }, forwardRef2) => {
|
|
901
1789
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
902
1790
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
903
|
-
|
|
1791
|
+
useThreads();
|
|
1792
|
+
const [rows, setRows] = (0, import_react2.useState)([
|
|
904
1793
|
...model.sheet.rows
|
|
905
1794
|
]);
|
|
906
|
-
const [columns, setColumns] = (0,
|
|
1795
|
+
const [columns, setColumns] = (0, import_react2.useState)([
|
|
907
1796
|
...model.sheet.columns
|
|
908
1797
|
]);
|
|
909
|
-
(0,
|
|
1798
|
+
(0, import_react2.useEffect)(() => {
|
|
910
1799
|
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
911
1800
|
"rows"
|
|
912
1801
|
]);
|
|
@@ -931,37 +1820,37 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
931
1820
|
}, [
|
|
932
1821
|
model
|
|
933
1822
|
]);
|
|
934
|
-
(0,
|
|
1823
|
+
(0, import_react2.useEffect)(() => {
|
|
935
1824
|
model.reset();
|
|
936
1825
|
}, [
|
|
937
1826
|
rows,
|
|
938
1827
|
columns
|
|
939
1828
|
]);
|
|
940
1829
|
const handleMoveRows = (from, to, num = 1) => {
|
|
941
|
-
const cursorIdx = cursor ? model.
|
|
1830
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
942
1831
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
943
1832
|
model.sheet.rows.splice(to, 0, rows2);
|
|
944
1833
|
if (cursorIdx) {
|
|
945
|
-
setCursor(model.
|
|
1834
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
946
1835
|
}
|
|
947
1836
|
setRows([
|
|
948
1837
|
...model.sheet.rows
|
|
949
1838
|
]);
|
|
950
1839
|
};
|
|
951
1840
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
952
|
-
const cursorIdx = cursor ? model.
|
|
1841
|
+
const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
|
|
953
1842
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
954
1843
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
955
1844
|
if (cursorIdx) {
|
|
956
|
-
setCursor(model.
|
|
1845
|
+
setCursor(addressFromIndex(model.sheet, cursorIdx));
|
|
957
1846
|
}
|
|
958
1847
|
setColumns([
|
|
959
1848
|
...model.sheet.columns
|
|
960
1849
|
]);
|
|
961
1850
|
};
|
|
962
|
-
const [rowSizes, setRowSizes] = (0,
|
|
963
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
964
|
-
(0,
|
|
1851
|
+
const [rowSizes, setRowSizes] = (0, import_react2.useState)();
|
|
1852
|
+
const [columnSizes, setColumnSizes] = (0, import_react2.useState)();
|
|
1853
|
+
(0, import_react2.useEffect)(() => {
|
|
965
1854
|
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
966
1855
|
"rowMeta"
|
|
967
1856
|
]);
|
|
@@ -1010,54 +1899,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, num
|
|
|
1010
1899
|
}));
|
|
1011
1900
|
}
|
|
1012
1901
|
};
|
|
1013
|
-
return /* @__PURE__ */
|
|
1902
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1014
1903
|
role: "none",
|
|
1015
|
-
className: (0,
|
|
1016
|
-
}, /* @__PURE__ */
|
|
1904
|
+
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)
|
|
1905
|
+
}, /* @__PURE__ */ import_react2.default.createElement(GridCorner, {
|
|
1017
1906
|
onClick: () => {
|
|
1018
1907
|
setCursor(void 0);
|
|
1019
1908
|
setRange(void 0);
|
|
1020
1909
|
setEditing(false);
|
|
1021
1910
|
}
|
|
1022
|
-
}), /* @__PURE__ */
|
|
1911
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetColumns, {
|
|
1023
1912
|
ref: columnsRef,
|
|
1024
1913
|
columns,
|
|
1025
1914
|
sizes: columnSizes,
|
|
1026
|
-
selected: cursor?.
|
|
1027
|
-
onSelect: (
|
|
1915
|
+
selected: cursor?.col,
|
|
1916
|
+
onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
|
|
1028
1917
|
row: -1,
|
|
1029
|
-
|
|
1918
|
+
col
|
|
1030
1919
|
}),
|
|
1031
1920
|
onResize: handleResizeColumn,
|
|
1032
1921
|
onMove: handleMoveColumns
|
|
1033
|
-
}), /* @__PURE__ */
|
|
1922
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetRows, {
|
|
1034
1923
|
ref: rowsRef,
|
|
1035
1924
|
rows,
|
|
1036
1925
|
sizes: rowSizes,
|
|
1037
1926
|
selected: cursor?.row,
|
|
1038
1927
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1039
1928
|
row,
|
|
1040
|
-
|
|
1929
|
+
col: -1
|
|
1041
1930
|
}),
|
|
1042
1931
|
onResize: handleResizeRow,
|
|
1043
1932
|
onMove: handleMoveRows
|
|
1044
|
-
}), /* @__PURE__ */
|
|
1933
|
+
}), /* @__PURE__ */ import_react2.default.createElement(SheetGrid, {
|
|
1045
1934
|
ref: contentRef,
|
|
1046
1935
|
size: {
|
|
1047
1936
|
numRows: numRows ?? rows.length,
|
|
1048
|
-
|
|
1937
|
+
numCols: numCols ?? columns.length
|
|
1049
1938
|
},
|
|
1050
1939
|
rows,
|
|
1051
1940
|
columns,
|
|
1052
1941
|
rowSizes,
|
|
1053
1942
|
columnSizes
|
|
1054
|
-
}), /* @__PURE__ */
|
|
1943
|
+
}), /* @__PURE__ */ import_react2.default.createElement(GridCorner, null), /* @__PURE__ */ import_react2.default.createElement(SheetStatusBar, null));
|
|
1055
1944
|
});
|
|
1056
1945
|
var useScrollHandlers = () => {
|
|
1057
|
-
const rowsRef = (0,
|
|
1058
|
-
const columnsRef = (0,
|
|
1059
|
-
const contentRef = (0,
|
|
1060
|
-
(0,
|
|
1946
|
+
const rowsRef = (0, import_react2.useRef)(null);
|
|
1947
|
+
const columnsRef = (0, import_react2.useRef)(null);
|
|
1948
|
+
const contentRef = (0, import_react2.useRef)(null);
|
|
1949
|
+
(0, import_react2.useEffect)(() => {
|
|
1061
1950
|
const handleRowsScroll = (ev) => {
|
|
1062
1951
|
const { scrollTop } = ev.target;
|
|
1063
1952
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1094,13 +1983,13 @@ var useScrollHandlers = () => {
|
|
|
1094
1983
|
};
|
|
1095
1984
|
};
|
|
1096
1985
|
var GridCorner = (props) => {
|
|
1097
|
-
return /* @__PURE__ */
|
|
1986
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1098
1987
|
className: fragments.axis,
|
|
1099
1988
|
...props
|
|
1100
1989
|
});
|
|
1101
1990
|
};
|
|
1102
1991
|
var MovingOverlay = ({ label }) => {
|
|
1103
|
-
return /* @__PURE__ */
|
|
1992
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1104
1993
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1105
1994
|
}, label);
|
|
1106
1995
|
};
|
|
@@ -1111,7 +2000,7 @@ var touchConstraints = {
|
|
|
1111
2000
|
delay: 250,
|
|
1112
2001
|
tolerance: 5
|
|
1113
2002
|
};
|
|
1114
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
2003
|
+
var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1115
2004
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1116
2005
|
activationConstraint: mouseConstraints
|
|
1117
2006
|
});
|
|
@@ -1120,7 +2009,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1120
2009
|
});
|
|
1121
2010
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1122
2011
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1123
|
-
const [active, setActive] = (0,
|
|
2012
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1124
2013
|
const handleDragStart = ({ active: active2 }) => {
|
|
1125
2014
|
setActive(active2);
|
|
1126
2015
|
};
|
|
@@ -1144,18 +2033,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1144
2033
|
}
|
|
1145
2034
|
return transform;
|
|
1146
2035
|
};
|
|
1147
|
-
return /* @__PURE__ */
|
|
2036
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1148
2037
|
className: "relative flex grow overflow-hidden"
|
|
1149
|
-
}, /* @__PURE__ */
|
|
1150
|
-
className: (0,
|
|
2038
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2039
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
1151
2040
|
style: {
|
|
1152
2041
|
width: axisWidth
|
|
1153
2042
|
}
|
|
1154
|
-
}), /* @__PURE__ */
|
|
2043
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1155
2044
|
ref: forwardRef2,
|
|
1156
2045
|
role: "rowheader",
|
|
1157
2046
|
className: "grow overflow-y-auto scrollbar-none"
|
|
1158
|
-
}, /* @__PURE__ */
|
|
2047
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1159
2048
|
sensors,
|
|
1160
2049
|
modifiers: [
|
|
1161
2050
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -1163,12 +2052,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1163
2052
|
],
|
|
1164
2053
|
onDragStart: handleDragStart,
|
|
1165
2054
|
onDragEnd: handleDragEnd
|
|
1166
|
-
}, /* @__PURE__ */
|
|
2055
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1167
2056
|
className: "flex flex-col",
|
|
1168
2057
|
style: {
|
|
1169
2058
|
width: axisWidth
|
|
1170
2059
|
}
|
|
1171
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
2060
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridRowCell, {
|
|
1172
2061
|
key: idx,
|
|
1173
2062
|
idx,
|
|
1174
2063
|
index,
|
|
@@ -1178,7 +2067,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, se
|
|
|
1178
2067
|
selected: selected === index,
|
|
1179
2068
|
onResize,
|
|
1180
2069
|
onSelect
|
|
1181
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2070
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react2.default.createElement(MovingOverlay, {
|
|
1182
2071
|
label: String(active.data.current.index + 1)
|
|
1183
2072
|
})), document.body))));
|
|
1184
2073
|
});
|
|
@@ -1196,9 +2085,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1196
2085
|
}
|
|
1197
2086
|
});
|
|
1198
2087
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1199
|
-
const [initialSize, setInitialSize] = (0,
|
|
1200
|
-
const [resizing, setResizing] = (0,
|
|
1201
|
-
const scrollHandler = (0,
|
|
2088
|
+
const [initialSize, setInitialSize] = (0, import_react2.useState)(size);
|
|
2089
|
+
const [resizing, setResizing] = (0, import_react2.useState)(false);
|
|
2090
|
+
const scrollHandler = (0, import_react2.useRef)();
|
|
1202
2091
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1203
2092
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
1204
2093
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -1219,7 +2108,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1219
2108
|
onResize?.(idx, initialSize + height, true);
|
|
1220
2109
|
setResizing(false);
|
|
1221
2110
|
};
|
|
1222
|
-
return /* @__PURE__ */
|
|
2111
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1223
2112
|
enable: {
|
|
1224
2113
|
bottom: resize
|
|
1225
2114
|
},
|
|
@@ -1231,21 +2120,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
1231
2120
|
onResizeStart: handleResizeStart,
|
|
1232
2121
|
onResize: handleResize,
|
|
1233
2122
|
onResizeStop: handleResizeStop
|
|
1234
|
-
}, /* @__PURE__ */
|
|
2123
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1235
2124
|
ref: setNodeRef,
|
|
1236
2125
|
...attributes,
|
|
1237
2126
|
...listeners,
|
|
1238
|
-
className: (0,
|
|
2127
|
+
className: (0, import_react_ui_theme.mx)("flex h-full items-center justify-center cursor-pointer", "border-t border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
1239
2128
|
onClick: () => onSelect?.(index)
|
|
1240
|
-
}, /* @__PURE__ */
|
|
2129
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1241
2130
|
className: "flex w-full justify-center"
|
|
1242
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2131
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1243
2132
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1244
|
-
}), resizing && /* @__PURE__ */
|
|
2133
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1245
2134
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
1246
2135
|
})));
|
|
1247
2136
|
};
|
|
1248
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
2137
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
1249
2138
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
1250
2139
|
activationConstraint: mouseConstraints
|
|
1251
2140
|
});
|
|
@@ -1254,7 +2143,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1254
2143
|
});
|
|
1255
2144
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
1256
2145
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
1257
|
-
const [active, setActive] = (0,
|
|
2146
|
+
const [active, setActive] = (0, import_react2.useState)(null);
|
|
1258
2147
|
const handleDragStart = ({ active: active2 }) => {
|
|
1259
2148
|
setActive(active2);
|
|
1260
2149
|
};
|
|
@@ -1278,18 +2167,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1278
2167
|
}
|
|
1279
2168
|
return transform;
|
|
1280
2169
|
};
|
|
1281
|
-
return /* @__PURE__ */
|
|
2170
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1282
2171
|
className: "relative flex grow overflow-hidden"
|
|
1283
|
-
}, /* @__PURE__ */
|
|
1284
|
-
className: (0,
|
|
2172
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2173
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
1285
2174
|
style: {
|
|
1286
2175
|
height: axisHeight
|
|
1287
2176
|
}
|
|
1288
|
-
}), /* @__PURE__ */
|
|
2177
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1289
2178
|
ref: forwardRef2,
|
|
1290
2179
|
role: "columnheader",
|
|
1291
2180
|
className: "grow overflow-x-auto scrollbar-none"
|
|
1292
|
-
}, /* @__PURE__ */
|
|
2181
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_core.DndContext, {
|
|
1293
2182
|
autoScroll: {
|
|
1294
2183
|
enabled: true
|
|
1295
2184
|
},
|
|
@@ -1300,23 +2189,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, siz
|
|
|
1300
2189
|
],
|
|
1301
2190
|
onDragStart: handleDragStart,
|
|
1302
2191
|
onDragEnd: handleDragEnd
|
|
1303
|
-
}, /* @__PURE__ */
|
|
2192
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1304
2193
|
className: "flex h-full",
|
|
1305
2194
|
style: {
|
|
1306
2195
|
height: axisHeight
|
|
1307
2196
|
}
|
|
1308
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
2197
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react2.default.createElement(GridColumnCell, {
|
|
1309
2198
|
key: idx,
|
|
1310
2199
|
idx,
|
|
1311
2200
|
index,
|
|
1312
|
-
label:
|
|
2201
|
+
label: columnLetter(index),
|
|
1313
2202
|
size: sizes?.[idx] ?? defaultWidth,
|
|
1314
2203
|
resize: index < columns.length - 1,
|
|
1315
2204
|
selected: selected === index,
|
|
1316
2205
|
onResize,
|
|
1317
2206
|
onSelect
|
|
1318
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1319
|
-
label:
|
|
2207
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react2.default.createElement(MovingOverlay, {
|
|
2208
|
+
label: columnLetter(active.data.current.index)
|
|
1320
2209
|
})), document.body))));
|
|
1321
2210
|
});
|
|
1322
2211
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -1333,9 +2222,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1333
2222
|
}
|
|
1334
2223
|
});
|
|
1335
2224
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
1336
|
-
const [initialSize, setInitialSize] = (0,
|
|
1337
|
-
const [resizing, setResizing] = (0,
|
|
1338
|
-
const scrollHandler = (0,
|
|
2225
|
+
const [initialSize, setInitialSize] = (0, import_react2.useState)(size);
|
|
2226
|
+
const [resizing, setResizing] = (0, import_react2.useState)(false);
|
|
2227
|
+
const scrollHandler = (0, import_react2.useRef)();
|
|
1339
2228
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
1340
2229
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
1341
2230
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -1356,7 +2245,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1356
2245
|
onResize?.(idx, initialSize + width, true);
|
|
1357
2246
|
setResizing(false);
|
|
1358
2247
|
};
|
|
1359
|
-
return /* @__PURE__ */
|
|
2248
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_re_resizable.Resizable, {
|
|
1360
2249
|
enable: {
|
|
1361
2250
|
right: resize
|
|
1362
2251
|
},
|
|
@@ -1368,37 +2257,37 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
1368
2257
|
onResizeStart: handleResizeStart,
|
|
1369
2258
|
onResize: handleResize,
|
|
1370
2259
|
onResizeStop: handleResizeStop
|
|
1371
|
-
}, /* @__PURE__ */
|
|
2260
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1372
2261
|
ref: setNodeRef,
|
|
1373
2262
|
...attributes,
|
|
1374
2263
|
...listeners,
|
|
1375
|
-
className: (0,
|
|
2264
|
+
className: (0, import_react_ui_theme.mx)("flex h-full items-center justify-center cursor-pointer", "border-l border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
1376
2265
|
onClick: () => onSelect?.(index)
|
|
1377
|
-
}, /* @__PURE__ */
|
|
2266
|
+
}, /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1378
2267
|
className: "flex w-full justify-center"
|
|
1379
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
2268
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1380
2269
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
1381
|
-
}), resizing && /* @__PURE__ */
|
|
2270
|
+
}), resizing && /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1382
2271
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
1383
2272
|
})));
|
|
1384
2273
|
};
|
|
1385
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
2274
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
1386
2275
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
1387
2276
|
refreshRate: 200
|
|
1388
2277
|
});
|
|
1389
|
-
const scrollerRef = (0,
|
|
1390
|
-
(0,
|
|
2278
|
+
const scrollerRef = (0, import_react2.useRef)(null);
|
|
2279
|
+
(0, import_react2.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
1391
2280
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
1392
|
-
const initialText = (0,
|
|
1393
|
-
const quickEdit = (0,
|
|
1394
|
-
const [, forceUpdate] = (0,
|
|
1395
|
-
(0,
|
|
2281
|
+
const initialText = (0, import_react2.useRef)();
|
|
2282
|
+
const quickEdit = (0, import_react2.useRef)(false);
|
|
2283
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2284
|
+
(0, import_react2.useEffect)(() => {
|
|
1396
2285
|
const unsubscribe = model.update.on(() => {
|
|
1397
2286
|
(0, import_log.log)("updated", {
|
|
1398
2287
|
id: model.id
|
|
1399
2288
|
}, {
|
|
1400
|
-
F:
|
|
1401
|
-
L:
|
|
2289
|
+
F: __dxlog_file4,
|
|
2290
|
+
L: 737,
|
|
1402
2291
|
S: void 0,
|
|
1403
2292
|
C: (f, a) => f(...a)
|
|
1404
2293
|
});
|
|
@@ -1410,7 +2299,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1410
2299
|
}, [
|
|
1411
2300
|
model
|
|
1412
2301
|
]);
|
|
1413
|
-
const inputRef = (0,
|
|
2302
|
+
const inputRef = (0, import_react2.useRef)(null);
|
|
1414
2303
|
const handleKeyDown = (ev) => {
|
|
1415
2304
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
1416
2305
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -1518,16 +2407,16 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1518
2407
|
const id = (0, import_echo.fullyQualifiedId)(model.sheet);
|
|
1519
2408
|
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(id);
|
|
1520
2409
|
const hasAttention = (0, import_react_ui_attention.useHasAttention)(id);
|
|
1521
|
-
return /* @__PURE__ */
|
|
2410
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1522
2411
|
ref: containerRef,
|
|
1523
2412
|
role: "grid",
|
|
1524
2413
|
className: "relative flex grow overflow-hidden"
|
|
1525
|
-
}, /* @__PURE__ */
|
|
1526
|
-
className: (0,
|
|
1527
|
-
}), /* @__PURE__ */
|
|
2414
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2415
|
+
className: (0, import_react_ui_theme.mx)("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
2416
|
+
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1528
2417
|
ref: scrollerRef,
|
|
1529
|
-
className: (0,
|
|
1530
|
-
}, /* @__PURE__ */
|
|
2418
|
+
className: (0, import_react_ui_theme.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
2419
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1531
2420
|
className: "relative select-none",
|
|
1532
2421
|
style: {
|
|
1533
2422
|
width,
|
|
@@ -1535,10 +2424,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1535
2424
|
},
|
|
1536
2425
|
onClick: () => inputRef.current?.focus(),
|
|
1537
2426
|
...handlers
|
|
1538
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
2427
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react2.default.createElement(SelectionOverlay, {
|
|
1539
2428
|
root: scrollerRef.current
|
|
1540
2429
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
1541
|
-
return columnRange.map(({
|
|
2430
|
+
return columnRange.map(({ col, left, width: width2 }) => {
|
|
1542
2431
|
const style = {
|
|
1543
2432
|
position: "absolute",
|
|
1544
2433
|
top,
|
|
@@ -1548,11 +2437,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1548
2437
|
};
|
|
1549
2438
|
const cell = {
|
|
1550
2439
|
row,
|
|
1551
|
-
|
|
2440
|
+
col
|
|
1552
2441
|
};
|
|
1553
|
-
const id2 =
|
|
1554
|
-
const idx = model.
|
|
1555
|
-
const active =
|
|
2442
|
+
const id2 = addressToA1Notation(cell);
|
|
2443
|
+
const idx = addressToIndex(model.sheet, cell);
|
|
2444
|
+
const active = posEquals(cursor, cell);
|
|
1556
2445
|
if (active && editing) {
|
|
1557
2446
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
1558
2447
|
const handleClose = (value2) => {
|
|
@@ -1584,7 +2473,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1584
2473
|
inputRef.current?.focus();
|
|
1585
2474
|
setEditing(false);
|
|
1586
2475
|
};
|
|
1587
|
-
return /* @__PURE__ */
|
|
2476
|
+
return /* @__PURE__ */ import_react2.default.createElement(GridCellEditor, {
|
|
1588
2477
|
key: idx,
|
|
1589
2478
|
value,
|
|
1590
2479
|
style,
|
|
@@ -1592,7 +2481,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1592
2481
|
onClose: handleClose
|
|
1593
2482
|
});
|
|
1594
2483
|
}
|
|
1595
|
-
return /* @__PURE__ */
|
|
2484
|
+
return /* @__PURE__ */ import_react2.default.createElement(SheetCell, {
|
|
1596
2485
|
key: id2,
|
|
1597
2486
|
id: id2,
|
|
1598
2487
|
cell,
|
|
@@ -1604,7 +2493,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, col
|
|
|
1604
2493
|
}
|
|
1605
2494
|
});
|
|
1606
2495
|
});
|
|
1607
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2496
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react2.default.createElement("input", {
|
|
1608
2497
|
ref: inputRef,
|
|
1609
2498
|
autoFocus: true,
|
|
1610
2499
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -1625,20 +2514,34 @@ var SelectionOverlay = ({ root }) => {
|
|
|
1625
2514
|
const b1 = getRelativeClientRect(root, c1);
|
|
1626
2515
|
const b2 = getRelativeClientRect(root, c2);
|
|
1627
2516
|
const bounds = getRectUnion(b1, b2);
|
|
1628
|
-
return /* @__PURE__ */
|
|
2517
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1629
2518
|
role: "none",
|
|
1630
2519
|
style: bounds,
|
|
1631
2520
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
1632
2521
|
});
|
|
1633
2522
|
};
|
|
1634
2523
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
1635
|
-
const { formatting, editing, setRange } = useSheetContext();
|
|
2524
|
+
const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
|
|
1636
2525
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
1637
|
-
|
|
2526
|
+
const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
|
|
2527
|
+
const decorationAddedClasses = (0, import_react2.useMemo)(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
|
|
2528
|
+
decorationsForCell
|
|
2529
|
+
]);
|
|
2530
|
+
const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
|
|
2531
|
+
if (!decorate) {
|
|
2532
|
+
return children;
|
|
2533
|
+
}
|
|
2534
|
+
const DecoratorComponent = decorate;
|
|
2535
|
+
return /* @__PURE__ */ import_react2.default.createElement(DecoratorComponent, null, children);
|
|
2536
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2537
|
+
role: "none",
|
|
2538
|
+
className: (0, import_react_ui_theme.mx)("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
|
|
2539
|
+
}, value));
|
|
2540
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1638
2541
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
1639
2542
|
role: "cell",
|
|
1640
2543
|
style,
|
|
1641
|
-
className: (0,
|
|
2544
|
+
className: (0, import_react_ui_theme.mx)("border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
1642
2545
|
"z-20",
|
|
1643
2546
|
fragments.cellSelected
|
|
1644
2547
|
], classNames),
|
|
@@ -1652,36 +2555,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
1652
2555
|
}
|
|
1653
2556
|
},
|
|
1654
2557
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
1655
|
-
},
|
|
2558
|
+
}, decoratedContent);
|
|
1656
2559
|
};
|
|
1657
2560
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
1658
2561
|
const { model, range } = useSheetContext();
|
|
1659
|
-
const notifier = (0,
|
|
1660
|
-
(0,
|
|
2562
|
+
const notifier = (0, import_react2.useRef)();
|
|
2563
|
+
(0, import_react2.useEffect)(() => {
|
|
1661
2564
|
if (range) {
|
|
1662
|
-
notifier.current?.(
|
|
2565
|
+
notifier.current?.(rangeToA1Notation(range));
|
|
1663
2566
|
}
|
|
1664
2567
|
}, [
|
|
1665
2568
|
range
|
|
1666
2569
|
]);
|
|
1667
|
-
const extension = (0,
|
|
2570
|
+
const extension = (0, import_react2.useMemo)(() => [
|
|
1668
2571
|
editorKeys({
|
|
1669
2572
|
onNav,
|
|
1670
2573
|
onClose
|
|
1671
2574
|
}),
|
|
1672
2575
|
sheetExtension({
|
|
1673
|
-
functions: model.
|
|
2576
|
+
functions: model.graph.getFunctions()
|
|
1674
2577
|
}),
|
|
1675
2578
|
rangeExtension((fn) => notifier.current = fn)
|
|
1676
2579
|
], [
|
|
1677
2580
|
model
|
|
1678
2581
|
]);
|
|
1679
|
-
return /* @__PURE__ */
|
|
2582
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1680
2583
|
role: "cell",
|
|
1681
2584
|
style,
|
|
1682
|
-
className: (0,
|
|
2585
|
+
className: (0, import_react_ui_theme.mx)("z-20 flex", fragments.cellSelected),
|
|
1683
2586
|
onClick: (ev) => ev.stopPropagation()
|
|
1684
|
-
}, /* @__PURE__ */
|
|
2587
|
+
}, /* @__PURE__ */ import_react2.default.createElement(CellEditor, {
|
|
1685
2588
|
autoFocus: true,
|
|
1686
2589
|
value,
|
|
1687
2590
|
extension
|
|
@@ -1694,30 +2597,30 @@ var SheetStatusBar = () => {
|
|
|
1694
2597
|
if (cursor) {
|
|
1695
2598
|
value = model.getCellValue(cursor);
|
|
1696
2599
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
1697
|
-
value = model.
|
|
2600
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1698
2601
|
isFormula = true;
|
|
1699
2602
|
} else if (value != null) {
|
|
1700
2603
|
value = String(value);
|
|
1701
2604
|
}
|
|
1702
2605
|
}
|
|
1703
|
-
return /* @__PURE__ */
|
|
1704
|
-
className: (0,
|
|
1705
|
-
}, /* @__PURE__ */
|
|
2606
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2607
|
+
className: (0, import_react_ui_theme.mx)("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
2608
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1706
2609
|
className: "flex gap-4 items-center"
|
|
1707
|
-
}, /* @__PURE__ */
|
|
2610
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1708
2611
|
className: "flex w-16 items-center font-mono"
|
|
1709
|
-
}, range &&
|
|
2612
|
+
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
1710
2613
|
className: "flex gap-2 items-center"
|
|
1711
|
-
}, /* @__PURE__ */
|
|
1712
|
-
className: (0,
|
|
1713
|
-
}), /* @__PURE__ */
|
|
2614
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_react.Function, {
|
|
2615
|
+
className: (0, import_react_ui_theme.mx)("text-greenText", isFormula ? "visible" : "invisible")
|
|
2616
|
+
}), /* @__PURE__ */ import_react2.default.createElement("span", {
|
|
1714
2617
|
className: "font-mono"
|
|
1715
2618
|
}, value))));
|
|
1716
2619
|
};
|
|
1717
2620
|
var SheetDebug = () => {
|
|
1718
2621
|
const { model, cursor, range } = useSheetContext();
|
|
1719
|
-
const [, forceUpdate] = (0,
|
|
1720
|
-
(0,
|
|
2622
|
+
const [, forceUpdate] = (0, import_react2.useState)({});
|
|
2623
|
+
(0, import_react2.useEffect)(() => {
|
|
1721
2624
|
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
1722
2625
|
const handleUpdate = () => forceUpdate({});
|
|
1723
2626
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -1728,9 +2631,9 @@ var SheetDebug = () => {
|
|
|
1728
2631
|
}, [
|
|
1729
2632
|
model
|
|
1730
2633
|
]);
|
|
1731
|
-
return /* @__PURE__ */
|
|
1732
|
-
className: (0,
|
|
1733
|
-
}, /* @__PURE__ */
|
|
2634
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
2635
|
+
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")
|
|
2636
|
+
}, /* @__PURE__ */ import_react2.default.createElement("pre", {
|
|
1734
2637
|
className: "whitespace-pre-wrap"
|
|
1735
2638
|
}, JSON.stringify({
|
|
1736
2639
|
cursor,
|
|
@@ -1751,15 +2654,15 @@ var Sheet = {
|
|
|
1751
2654
|
StatusBar: SheetStatusBar,
|
|
1752
2655
|
Debug: SheetDebug
|
|
1753
2656
|
};
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
//# sourceMappingURL=
|
|
2657
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2658
|
+
0 && (module.exports = {
|
|
2659
|
+
ComputeGraphContextProvider,
|
|
2660
|
+
Sheet,
|
|
2661
|
+
SheetContainer,
|
|
2662
|
+
addressToIndex,
|
|
2663
|
+
compareIndexPositions,
|
|
2664
|
+
createSheet,
|
|
2665
|
+
useComputeGraph,
|
|
2666
|
+
useSheetContext
|
|
2667
|
+
});
|
|
2668
|
+
//# sourceMappingURL=chunk-6DQABRGJ.cjs.map
|