@dxos/plugin-sheet 0.6.12-main.f9d0246 → 0.6.12-staging.0b4bb48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-ZLJ2GRE2.mjs → SheetContainer-U4H5D34A.mjs} +240 -1151
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-Z2XOOC2R.mjs → chunk-D5AGLXJP.mjs} +678 -385
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WZMOZKQZ.mjs → chunk-FUAGSXA4.mjs} +16 -9
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-IU2L277A.mjs → browser/chunk-JRL5LGCE.mjs} +5 -4
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +60 -74
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{chunk-6DQABRGJ.cjs → SheetContainer-AXQV3ZT5.cjs} +279 -1182
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-P5QYYEHQ.cjs → chunk-5KKJ4NPP.cjs} +676 -388
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/{chunk-BNARJ5GM.cjs → chunk-BJ6ZD7MN.cjs} +18 -5
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-AOP42UAA.cjs → chunk-DSYKOI4E.cjs} +21 -13
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +66 -86
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +12 -10
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +3 -23
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/{graph → components/ComputeGraph}/async-function.d.ts +2 -8
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
- package/dist/types/src/{graph/testing/custom-function.d.ts → components/ComputeGraph/custom.d.ts} +2 -4
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +6 -5
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
- package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +7 -8
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +3 -2
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +3 -19
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +13 -18
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +4 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/{graph/function-defs.d.ts → model/functions.d.ts} +1 -1
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.browser.test.d.ts +2 -0
- package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
- package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +65 -10
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/{defs → model}/types.d.ts +3 -8
- package/dist/types/src/model/types.d.ts.map +1 -0
- package/dist/types/src/model/types.test.d.ts.map +1 -0
- package/dist/types/src/model/util.d.ts +15 -0
- package/dist/types/src/model/util.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -86
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +41 -48
- package/src/SheetPlugin.tsx +73 -48
- package/src/components/CellEditor/CellEditor.stories.tsx +4 -5
- package/src/components/CellEditor/CellEditor.tsx +9 -59
- package/src/components/CellEditor/extension.test.ts +5 -4
- package/src/components/CellEditor/extension.ts +3 -1
- package/src/{graph → components/ComputeGraph}/async-function.ts +6 -15
- package/src/{graph/testing/custom-function.ts → components/ComputeGraph/custom.ts} +7 -11
- package/src/{graph → components/ComputeGraph}/edge-function.ts +3 -3
- package/src/components/ComputeGraph/graph-context.tsx +50 -0
- package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
- package/src/components/ComputeGraph/graph.ts +62 -0
- package/src/components/ComputeGraph/index.ts +3 -1
- package/src/components/Sheet/Sheet.stories.tsx +88 -52
- package/src/components/Sheet/Sheet.tsx +18 -57
- package/src/{model/formatting-model.ts → components/Sheet/formatting.ts} +13 -20
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +80 -18
- package/src/components/SheetContainer.tsx +19 -73
- package/src/components/Toolbar/Toolbar.tsx +12 -53
- package/src/components/index.ts +0 -1
- package/src/meta.tsx +5 -1
- package/src/model/index.ts +3 -2
- package/src/model/model.browser.test.ts +100 -0
- package/src/model/model.ts +550 -0
- package/src/{defs → model}/types.test.ts +9 -8
- package/src/{defs → model}/types.ts +14 -24
- package/src/model/util.ts +36 -0
- package/src/testing.ts +50 -0
- package/src/translations.ts +1 -6
- package/src/types.ts +6 -31
- package/dist/lib/browser/SheetContainer-VISF3VUB.mjs +0 -261
- package/dist/lib/browser/SheetContainer-VISF3VUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-QILRZNE5.mjs +0 -15
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +0 -7
- package/dist/lib/browser/chunk-WZMOZKQZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z2XOOC2R.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZLJ2GRE2.mjs.map +0 -7
- package/dist/lib/browser/graph-4XFKIHRL.mjs +0 -21
- package/dist/lib/browser/graph-4XFKIHRL.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-2MEALQWW.cjs +0 -279
- package/dist/lib/node/SheetContainer-2MEALQWW.cjs.map +0 -7
- package/dist/lib/node/chunk-6DQABRGJ.cjs.map +0 -7
- package/dist/lib/node/chunk-AOP42UAA.cjs.map +0 -7
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +0 -7
- package/dist/lib/node/chunk-P5QYYEHQ.cjs.map +0 -7
- package/dist/lib/node/graph-2LRDUXBZ.cjs +0 -43
- package/dist/lib/node/graph-2LRDUXBZ.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs +0 -262
- package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs +0 -2944
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs +0 -2684
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs +0 -76
- package/dist/lib/node-esm/chunk-RR2AO4SM.mjs.map +0 -7
- package/dist/lib/node-esm/graph-WG5EKOMO.mjs +0 -22
- package/dist/lib/node-esm/graph-WG5EKOMO.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -263
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -21
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -10
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts +0 -7
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/decorations.d.ts +0 -24
- package/dist/types/src/components/Sheet/decorations.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/threads.d.ts +0 -2
- package/dist/types/src/components/Sheet/threads.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts +0 -3
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts +0 -43
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.d.ts +0 -9
- package/dist/types/src/extensions/compute.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.stories.d.ts +0 -26
- package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -2
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/graph/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts +0 -84
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts +0 -26
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts +0 -4
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/custom-function.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts +0 -2
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts +0 -2
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useFormattingModel.d.ts +0 -3
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/formatting-model.d.ts +0 -16
- package/dist/types/src/model/formatting-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -8
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -36
- package/src/components/GridSheet/GridSheet.tsx +0 -153
- package/src/components/GridSheet/util.ts +0 -108
- package/src/components/Sheet/decorations.ts +0 -62
- package/src/components/Sheet/threads.tsx +0 -205
- package/src/defs/index.ts +0 -6
- package/src/defs/util.ts +0 -151
- package/src/extensions/compute.stories.tsx +0 -153
- package/src/extensions/compute.ts +0 -131
- package/src/extensions/index.ts +0 -5
- package/src/graph/compute-graph.stories.tsx +0 -93
- package/src/graph/compute-graph.test.ts +0 -127
- package/src/graph/compute-graph.ts +0 -313
- package/src/graph/compute-node.ts +0 -62
- package/src/graph/hyperformula.test.ts +0 -15
- package/src/graph/index.ts +0 -7
- package/src/graph/testing/index.ts +0 -5
- package/src/graph/util.ts +0 -8
- package/src/hooks/hooks.stories.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/useComputeGraph.ts +0 -21
- package/src/hooks/useFormattingModel.ts +0 -11
- package/src/hooks/useSheetModel.ts +0 -40
- package/src/model/sheet-model.ts +0 -414
- package/src/sanity.test.ts +0 -40
- package/src/testing/index.ts +0 -5
- package/src/testing/testing.tsx +0 -68
- /package/dist/types/src/{graph → components/ComputeGraph}/edge-function.d.ts +0 -0
- /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
- /package/src/{graph/function-defs.ts → model/functions.ts} +0 -0
|
@@ -26,64 +26,38 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
32
|
-
Sheet: () => Sheet,
|
|
33
|
-
SheetContainer: () => SheetContainer,
|
|
34
|
-
addressToIndex: () => addressToIndex,
|
|
35
|
-
compareIndexPositions: () => compareIndexPositions,
|
|
36
|
-
createSheet: () => createSheet,
|
|
37
|
-
useComputeGraph: () => useComputeGraph,
|
|
38
|
-
useSheetContext: () => useSheetContext
|
|
29
|
+
var SheetContainer_AXQV3ZT5_exports = {};
|
|
30
|
+
__export(SheetContainer_AXQV3ZT5_exports, {
|
|
31
|
+
default: () => SheetContainer_default
|
|
39
32
|
});
|
|
40
|
-
module.exports = __toCommonJS(
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
33
|
+
module.exports = __toCommonJS(SheetContainer_AXQV3ZT5_exports);
|
|
34
|
+
var import_chunk_CN3RPESU = require("./chunk-CN3RPESU.cjs");
|
|
35
|
+
var import_chunk_5KKJ4NPP = require("./chunk-5KKJ4NPP.cjs");
|
|
36
|
+
var import_chunk_DSYKOI4E = require("./chunk-DSYKOI4E.cjs");
|
|
37
|
+
var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
44
40
|
var import_core = require("@dnd-kit/core");
|
|
45
41
|
var import_modifiers = require("@dnd-kit/modifiers");
|
|
46
42
|
var import_utilities = require("@dnd-kit/utilities");
|
|
47
|
-
var
|
|
43
|
+
var import_react2 = require("@phosphor-icons/react");
|
|
48
44
|
var import_re_resizable = require("re-resizable");
|
|
49
|
-
var
|
|
45
|
+
var import_react3 = __toESM(require("react"));
|
|
50
46
|
var import_react_dom = require("react-dom");
|
|
51
47
|
var import_react_resize_detector = require("react-resize-detector");
|
|
52
48
|
var import_async = require("@dxos/async");
|
|
53
49
|
var import_echo = require("@dxos/client/echo");
|
|
54
50
|
var import_log = require("@dxos/log");
|
|
55
51
|
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
56
|
-
var
|
|
57
|
-
var import_react3 = require("react");
|
|
58
|
-
var import_invariant = require("@dxos/invariant");
|
|
59
|
-
var import_crypto = require("@dxos/crypto");
|
|
60
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
52
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
61
53
|
var import_react4 = require("react");
|
|
62
|
-
var import_react5 =
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
var import_react6 = require("react");
|
|
66
|
-
var import_debug = require("@dxos/debug");
|
|
67
|
-
var import_react_hooks = require("@dxos/react-hooks");
|
|
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");
|
|
54
|
+
var import_react5 = require("react");
|
|
55
|
+
var import_react6 = __toESM(require("react"));
|
|
56
|
+
var import_invariant = require("@dxos/invariant");
|
|
82
57
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
83
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
84
58
|
var import_view = require("@codemirror/view");
|
|
85
|
-
var
|
|
86
|
-
var
|
|
59
|
+
var import_react7 = __toESM(require("react"));
|
|
60
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
87
61
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
88
62
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
89
63
|
var import_language = require("@codemirror/language");
|
|
@@ -91,164 +65,7 @@ var import_state = require("@codemirror/state");
|
|
|
91
65
|
var import_view2 = require("@codemirror/view");
|
|
92
66
|
var import_highlight = require("@lezer/highlight");
|
|
93
67
|
var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
|
|
94
|
-
var
|
|
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
|
-
};
|
|
68
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
252
69
|
var axisWidth = "calc(var(--rail-size)-2px)";
|
|
253
70
|
var axisHeight = 34;
|
|
254
71
|
var minWidth = 40;
|
|
@@ -259,8 +76,8 @@ var defaultWidth = 200;
|
|
|
259
76
|
var defaultHeight = minHeight;
|
|
260
77
|
var CELL_DATA_KEY = "cell";
|
|
261
78
|
var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) => {
|
|
262
|
-
const [rowPositions, setRowPositions] = (0,
|
|
263
|
-
(0,
|
|
79
|
+
const [rowPositions, setRowPositions] = (0, import_react4.useState)([]);
|
|
80
|
+
(0, import_react4.useEffect)(() => {
|
|
264
81
|
if (!rowSizes) {
|
|
265
82
|
return;
|
|
266
83
|
}
|
|
@@ -279,8 +96,8 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
279
96
|
rows,
|
|
280
97
|
rowSizes
|
|
281
98
|
]);
|
|
282
|
-
const [columnPositions, setColumnPositions] = (0,
|
|
283
|
-
(0,
|
|
99
|
+
const [columnPositions, setColumnPositions] = (0, import_react4.useState)([]);
|
|
100
|
+
(0, import_react4.useEffect)(() => {
|
|
284
101
|
if (!columns) {
|
|
285
102
|
return;
|
|
286
103
|
}
|
|
@@ -290,7 +107,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
290
107
|
const left = x;
|
|
291
108
|
x += width2 - 1;
|
|
292
109
|
return {
|
|
293
|
-
|
|
110
|
+
column: i,
|
|
294
111
|
left,
|
|
295
112
|
width: width2
|
|
296
113
|
};
|
|
@@ -301,11 +118,11 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
|
|
|
301
118
|
]);
|
|
302
119
|
const height = rowPositions.length ? rowPositions[rowPositions.length - 1].top + rowPositions[rowPositions.length - 1].height : 0;
|
|
303
120
|
const width = columnPositions.length ? columnPositions[columnPositions.length - 1].left + columnPositions[columnPositions.length - 1].width : 0;
|
|
304
|
-
const [{ rowRange, columnRange }, setWindow] = (0,
|
|
121
|
+
const [{ rowRange, columnRange }, setWindow] = (0, import_react4.useState)({
|
|
305
122
|
rowRange: [],
|
|
306
123
|
columnRange: []
|
|
307
124
|
});
|
|
308
|
-
(0,
|
|
125
|
+
(0, import_react4.useEffect)(() => {
|
|
309
126
|
const handleScroll = () => {
|
|
310
127
|
if (!scroller) {
|
|
311
128
|
return;
|
|
@@ -365,12 +182,12 @@ var getCellAtPointer = (event) => {
|
|
|
365
182
|
if (root) {
|
|
366
183
|
const value = root.dataset[CELL_DATA_KEY];
|
|
367
184
|
if (value) {
|
|
368
|
-
return addressFromA1Notation(value);
|
|
185
|
+
return (0, import_chunk_5KKJ4NPP.addressFromA1Notation)(value);
|
|
369
186
|
}
|
|
370
187
|
}
|
|
371
188
|
};
|
|
372
189
|
var getCellElement = (root, cell) => {
|
|
373
|
-
const pos = addressToA1Notation(cell);
|
|
190
|
+
const pos = (0, import_chunk_5KKJ4NPP.addressToA1Notation)(cell);
|
|
374
191
|
return root.querySelector(`[data-${CELL_DATA_KEY}="${pos}"]`);
|
|
375
192
|
};
|
|
376
193
|
var handleNav = (ev, cursor, range, size) => {
|
|
@@ -392,14 +209,14 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
392
209
|
break;
|
|
393
210
|
}
|
|
394
211
|
case "ArrowLeft": {
|
|
395
|
-
if (opposite.
|
|
396
|
-
opposite.
|
|
212
|
+
if (opposite.column > 0) {
|
|
213
|
+
opposite.column -= 1;
|
|
397
214
|
}
|
|
398
215
|
break;
|
|
399
216
|
}
|
|
400
217
|
case "ArrowRight": {
|
|
401
|
-
if (opposite.
|
|
402
|
-
opposite.
|
|
218
|
+
if (opposite.column < size.numColumns - 1) {
|
|
219
|
+
opposite.column += 1;
|
|
403
220
|
}
|
|
404
221
|
break;
|
|
405
222
|
}
|
|
@@ -417,18 +234,18 @@ var handleNav = (ev, cursor, range, size) => {
|
|
|
417
234
|
cursor: next
|
|
418
235
|
};
|
|
419
236
|
};
|
|
420
|
-
var handleArrowNav = (ev, cursor, { numRows,
|
|
237
|
+
var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
|
|
421
238
|
switch (ev.key) {
|
|
422
239
|
case "ArrowUp":
|
|
423
240
|
if (cursor === void 0) {
|
|
424
241
|
return {
|
|
425
242
|
row: 0,
|
|
426
|
-
|
|
243
|
+
column: 0
|
|
427
244
|
};
|
|
428
245
|
} else if (cursor.row > 0) {
|
|
429
246
|
return {
|
|
430
247
|
row: ev.metaKey ? 0 : cursor.row - 1,
|
|
431
|
-
|
|
248
|
+
column: cursor.column
|
|
432
249
|
};
|
|
433
250
|
}
|
|
434
251
|
break;
|
|
@@ -436,12 +253,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
436
253
|
if (cursor === void 0) {
|
|
437
254
|
return {
|
|
438
255
|
row: 0,
|
|
439
|
-
|
|
256
|
+
column: 0
|
|
440
257
|
};
|
|
441
258
|
} else if (cursor.row < numRows - 1) {
|
|
442
259
|
return {
|
|
443
260
|
row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
444
|
-
|
|
261
|
+
column: cursor.column
|
|
445
262
|
};
|
|
446
263
|
}
|
|
447
264
|
break;
|
|
@@ -449,12 +266,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
449
266
|
if (cursor === void 0) {
|
|
450
267
|
return {
|
|
451
268
|
row: 0,
|
|
452
|
-
|
|
269
|
+
column: 0
|
|
453
270
|
};
|
|
454
|
-
} else if (cursor.
|
|
271
|
+
} else if (cursor.column > 0) {
|
|
455
272
|
return {
|
|
456
273
|
row: cursor.row,
|
|
457
|
-
|
|
274
|
+
column: ev.metaKey ? 0 : cursor.column - 1
|
|
458
275
|
};
|
|
459
276
|
}
|
|
460
277
|
break;
|
|
@@ -462,30 +279,30 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
|
|
|
462
279
|
if (cursor === void 0) {
|
|
463
280
|
return {
|
|
464
281
|
row: 0,
|
|
465
|
-
|
|
282
|
+
column: 0
|
|
466
283
|
};
|
|
467
|
-
} else if (cursor.
|
|
284
|
+
} else if (cursor.column < numColumns - 1) {
|
|
468
285
|
return {
|
|
469
286
|
row: cursor.row,
|
|
470
|
-
|
|
287
|
+
column: ev.metaKey ? numColumns - 1 : cursor.column + 1
|
|
471
288
|
};
|
|
472
289
|
}
|
|
473
290
|
break;
|
|
474
291
|
case "Home":
|
|
475
292
|
return {
|
|
476
293
|
row: 0,
|
|
477
|
-
|
|
294
|
+
column: 0
|
|
478
295
|
};
|
|
479
296
|
case "End":
|
|
480
297
|
return {
|
|
481
298
|
row: numRows - 1,
|
|
482
|
-
|
|
299
|
+
column: numColumns - 1
|
|
483
300
|
};
|
|
484
301
|
}
|
|
485
302
|
};
|
|
486
303
|
var useRangeSelect = (cb) => {
|
|
487
|
-
const [from, setFrom] = (0,
|
|
488
|
-
const [to, setTo] = (0,
|
|
304
|
+
const [from, setFrom] = (0, import_react5.useState)();
|
|
305
|
+
const [to, setTo] = (0, import_react5.useState)();
|
|
489
306
|
const onMouseDown = (ev) => {
|
|
490
307
|
const current = getCellAtPointer(ev);
|
|
491
308
|
setFrom(current);
|
|
@@ -498,7 +315,7 @@ var useRangeSelect = (cb) => {
|
|
|
498
315
|
const onMouseMove = (ev) => {
|
|
499
316
|
if (from) {
|
|
500
317
|
let current = getCellAtPointer(ev);
|
|
501
|
-
if (posEquals(current, from)) {
|
|
318
|
+
if ((0, import_chunk_5KKJ4NPP.posEquals)(current, from)) {
|
|
502
319
|
current = void 0;
|
|
503
320
|
}
|
|
504
321
|
setTo(current);
|
|
@@ -511,7 +328,7 @@ var useRangeSelect = (cb) => {
|
|
|
511
328
|
const onMouseUp = (ev) => {
|
|
512
329
|
if (from) {
|
|
513
330
|
let current = getCellAtPointer(ev);
|
|
514
|
-
if (posEquals(current, from)) {
|
|
331
|
+
if ((0, import_chunk_5KKJ4NPP.posEquals)(current, from)) {
|
|
515
332
|
current = void 0;
|
|
516
333
|
}
|
|
517
334
|
setFrom(void 0);
|
|
@@ -534,80 +351,27 @@ var useRangeSelect = (cb) => {
|
|
|
534
351
|
}
|
|
535
352
|
};
|
|
536
353
|
};
|
|
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
|
-
};
|
|
590
354
|
var FormattingModel = class {
|
|
591
|
-
constructor(
|
|
592
|
-
this.
|
|
355
|
+
constructor(model) {
|
|
356
|
+
this.model = model;
|
|
593
357
|
}
|
|
594
358
|
/**
|
|
595
359
|
* Get formatted string value and className for cell.
|
|
596
360
|
*/
|
|
597
361
|
getFormatting(cell) {
|
|
598
|
-
const value = this.
|
|
362
|
+
const value = this.model.getValue(cell);
|
|
599
363
|
if (value === void 0 || value === null) {
|
|
600
364
|
return {};
|
|
601
365
|
}
|
|
602
366
|
const locales = void 0;
|
|
603
|
-
const idx =
|
|
604
|
-
let formatting = this.
|
|
367
|
+
const idx = this.model.addressToIndex(cell);
|
|
368
|
+
let formatting = this.model.sheet.formatting?.[idx] ?? {};
|
|
605
369
|
const classNames = [
|
|
606
370
|
...formatting?.classNames ?? []
|
|
607
371
|
];
|
|
608
|
-
for (const [idx2, _formatting] of Object.entries(this.
|
|
609
|
-
const range =
|
|
610
|
-
if (inRange(range, cell)) {
|
|
372
|
+
for (const [idx2, _formatting] of Object.entries(this.model.sheet.formatting)) {
|
|
373
|
+
const range = this.model.rangeFromIndex(idx2);
|
|
374
|
+
if ((0, import_chunk_5KKJ4NPP.inRange)(range, cell)) {
|
|
611
375
|
if (_formatting.classNames) {
|
|
612
376
|
classNames.push(..._formatting.classNames);
|
|
613
377
|
}
|
|
@@ -617,9 +381,9 @@ var FormattingModel = class {
|
|
|
617
381
|
}
|
|
618
382
|
}
|
|
619
383
|
const defaultNumber = "justify-end font-mono";
|
|
620
|
-
const type = formatting?.type ?? this.
|
|
384
|
+
const type = formatting?.type ?? this.model.getValueType(cell);
|
|
621
385
|
switch (type) {
|
|
622
|
-
case
|
|
386
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Boolean: {
|
|
623
387
|
return {
|
|
624
388
|
value: value.toLocaleString().toUpperCase(),
|
|
625
389
|
classNames: [
|
|
@@ -631,7 +395,7 @@ var FormattingModel = class {
|
|
|
631
395
|
//
|
|
632
396
|
// Numbers.
|
|
633
397
|
//
|
|
634
|
-
case
|
|
398
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Number: {
|
|
635
399
|
return {
|
|
636
400
|
value: value.toLocaleString(locales),
|
|
637
401
|
classNames: [
|
|
@@ -640,7 +404,7 @@ var FormattingModel = class {
|
|
|
640
404
|
]
|
|
641
405
|
};
|
|
642
406
|
}
|
|
643
|
-
case
|
|
407
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Percent: {
|
|
644
408
|
return {
|
|
645
409
|
value: value * 100 + "%",
|
|
646
410
|
classNames: [
|
|
@@ -649,7 +413,7 @@ var FormattingModel = class {
|
|
|
649
413
|
]
|
|
650
414
|
};
|
|
651
415
|
}
|
|
652
|
-
case
|
|
416
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Currency: {
|
|
653
417
|
return {
|
|
654
418
|
value: value.toLocaleString(locales, {
|
|
655
419
|
style: "currency",
|
|
@@ -666,22 +430,22 @@ var FormattingModel = class {
|
|
|
666
430
|
//
|
|
667
431
|
// Dates.
|
|
668
432
|
//
|
|
669
|
-
case
|
|
670
|
-
const date = this.
|
|
433
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.DateTime: {
|
|
434
|
+
const date = this.model.toLocalDate(value);
|
|
671
435
|
return {
|
|
672
436
|
value: date.toLocaleString(locales),
|
|
673
437
|
classNames
|
|
674
438
|
};
|
|
675
439
|
}
|
|
676
|
-
case
|
|
677
|
-
const date = this.
|
|
440
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Date: {
|
|
441
|
+
const date = this.model.toLocalDate(value);
|
|
678
442
|
return {
|
|
679
443
|
value: date.toLocaleDateString(locales),
|
|
680
444
|
classNames
|
|
681
445
|
};
|
|
682
446
|
}
|
|
683
|
-
case
|
|
684
|
-
const date = this.
|
|
447
|
+
case import_chunk_DSYKOI4E.ValueTypeEnum.Time: {
|
|
448
|
+
const date = this.model.toLocalDate(value);
|
|
685
449
|
return {
|
|
686
450
|
value: date.toLocaleTimeString(locales),
|
|
687
451
|
classNames
|
|
@@ -696,535 +460,83 @@ var FormattingModel = class {
|
|
|
696
460
|
}
|
|
697
461
|
}
|
|
698
462
|
};
|
|
699
|
-
var
|
|
700
|
-
var
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
};
|
|
463
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
|
|
464
|
+
var OBJECT_ID_LENGTH = 60;
|
|
465
|
+
var SheetContext = /* @__PURE__ */ (0, import_react6.createContext)(null);
|
|
466
|
+
var useSheetContext = () => {
|
|
467
|
+
const context = (0, import_react6.useContext)(SheetContext);
|
|
468
|
+
(0, import_invariant.invariant)(context, void 0, {
|
|
469
|
+
F: __dxlog_file,
|
|
470
|
+
L: 45,
|
|
471
|
+
S: void 0,
|
|
472
|
+
A: [
|
|
473
|
+
"context",
|
|
474
|
+
""
|
|
475
|
+
]
|
|
476
|
+
});
|
|
477
|
+
return context;
|
|
715
478
|
};
|
|
716
|
-
var
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
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();
|
|
479
|
+
var mapFormulaBindingToId = (functions) => (formula) => {
|
|
480
|
+
return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
|
|
481
|
+
if (import_chunk_5KKJ4NPP.defaultFunctions.find((fn2) => fn2.name === binding) || binding === "EDGE") {
|
|
482
|
+
return match;
|
|
928
483
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
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));
|
|
484
|
+
const fn = functions.find((fn2) => fn2.binding === binding);
|
|
485
|
+
if (fn) {
|
|
486
|
+
return `${(0, import_echo2.fullyQualifiedId)(fn)}(${args})`;
|
|
947
487
|
} else {
|
|
948
|
-
return
|
|
488
|
+
return match;
|
|
949
489
|
}
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
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();
|
|
973
|
-
}
|
|
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();
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
var mapFormulaBindingFromId = (functions) => (formula) => {
|
|
493
|
+
return formula.replace(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
|
|
494
|
+
const id = `${spaceId}:${objectId}`;
|
|
495
|
+
if (id.length !== OBJECT_ID_LENGTH) {
|
|
496
|
+
return match;
|
|
1020
497
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
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];
|
|
498
|
+
const fn = functions.find((fn2) => (0, import_echo2.fullyQualifiedId)(fn2) === id);
|
|
499
|
+
if (fn?.binding) {
|
|
500
|
+
return `${fn.binding}(${args})`;
|
|
1033
501
|
} else {
|
|
1034
|
-
|
|
1035
|
-
value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
|
|
1036
|
-
}
|
|
1037
|
-
this._sheet.cells[idx] = {
|
|
1038
|
-
value
|
|
1039
|
-
};
|
|
502
|
+
return match;
|
|
1040
503
|
}
|
|
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
|
-
]);
|
|
504
|
+
});
|
|
1177
505
|
};
|
|
1178
|
-
var
|
|
1179
|
-
const
|
|
1180
|
-
(0,
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
506
|
+
var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...options }) => {
|
|
507
|
+
const graph = (0, import_chunk_CN3RPESU.useComputeGraph)(space, options);
|
|
508
|
+
const [cursor, setCursor] = (0, import_react6.useState)();
|
|
509
|
+
const [range, setRange] = (0, import_react6.useState)();
|
|
510
|
+
const [editing, setEditing] = (0, import_react6.useState)(false);
|
|
511
|
+
const [[model, formatting] = [], setModels] = (0, import_react6.useState)(void 0);
|
|
512
|
+
(0, import_react6.useEffect)(() => {
|
|
1184
513
|
let model2;
|
|
514
|
+
let formatting2;
|
|
1185
515
|
const t = setTimeout(async () => {
|
|
1186
|
-
model2 = new SheetModel(graph, sheet, {
|
|
1187
|
-
readonly
|
|
516
|
+
model2 = new import_chunk_5KKJ4NPP.SheetModel(graph, sheet, space, {
|
|
517
|
+
readonly,
|
|
518
|
+
mapFormulaBindingToId,
|
|
519
|
+
mapFormulaBindingFromId
|
|
1188
520
|
});
|
|
1189
|
-
await model2.
|
|
1190
|
-
|
|
521
|
+
await model2.initialize();
|
|
522
|
+
formatting2 = new FormattingModel(model2);
|
|
523
|
+
setModels([
|
|
524
|
+
model2,
|
|
525
|
+
formatting2
|
|
526
|
+
]);
|
|
1191
527
|
});
|
|
1192
528
|
return () => {
|
|
1193
529
|
clearTimeout(t);
|
|
1194
|
-
void model2?.
|
|
530
|
+
void model2?.destroy();
|
|
1195
531
|
};
|
|
1196
532
|
}, [
|
|
1197
533
|
graph,
|
|
1198
|
-
sheet,
|
|
1199
534
|
readonly
|
|
1200
535
|
]);
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
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, {
|
|
536
|
+
if (!model || !formatting) {
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
return /* @__PURE__ */ import_react6.default.createElement(SheetContext.Provider, {
|
|
1228
540
|
value: {
|
|
1229
541
|
model,
|
|
1230
542
|
formatting,
|
|
@@ -1235,168 +547,10 @@ var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
|
|
|
1235
547
|
editing,
|
|
1236
548
|
setEditing,
|
|
1237
549
|
// TODO(burdon): Change to event.
|
|
1238
|
-
onInfo
|
|
1239
|
-
decorations
|
|
550
|
+
onInfo
|
|
1240
551
|
}
|
|
1241
552
|
}, children);
|
|
1242
553
|
};
|
|
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
|
-
};
|
|
1400
554
|
var getRelativeClientRect = (root, element) => {
|
|
1401
555
|
const rootRect = root.getBoundingClientRect();
|
|
1402
556
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -1473,61 +627,21 @@ var editorKeys = ({ onNav, onClose }) => {
|
|
|
1473
627
|
{
|
|
1474
628
|
key: "Enter",
|
|
1475
629
|
run: (editor) => {
|
|
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
|
-
});
|
|
630
|
+
onClose(editor.state.doc.toString());
|
|
1502
631
|
return true;
|
|
1503
632
|
}
|
|
1504
633
|
},
|
|
1505
634
|
{
|
|
1506
635
|
key: "Escape",
|
|
1507
636
|
run: () => {
|
|
1508
|
-
onClose(void 0
|
|
1509
|
-
key: "Escape"
|
|
1510
|
-
});
|
|
637
|
+
onClose(void 0);
|
|
1511
638
|
return true;
|
|
1512
639
|
}
|
|
1513
640
|
}
|
|
1514
641
|
]);
|
|
1515
642
|
};
|
|
1516
|
-
var
|
|
1517
|
-
|
|
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)();
|
|
643
|
+
var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
|
|
644
|
+
const { themeMode } = (0, import_react_ui.useThemeContext)();
|
|
1531
645
|
const { parentRef } = (0, import_react_ui_editor.useTextEditor)(() => {
|
|
1532
646
|
return {
|
|
1533
647
|
autoFocus,
|
|
@@ -1553,29 +667,21 @@ var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box
|
|
|
1553
667
|
themeMode,
|
|
1554
668
|
slots: {
|
|
1555
669
|
editor: {
|
|
1556
|
-
className:
|
|
670
|
+
className: "flex w-full [&>.cm-scroller]:scrollbar-none"
|
|
1557
671
|
},
|
|
1558
672
|
content: {
|
|
1559
|
-
className:
|
|
673
|
+
className: "!px-2 !py-1"
|
|
1560
674
|
}
|
|
1561
675
|
}
|
|
1562
676
|
})
|
|
1563
677
|
]
|
|
1564
678
|
};
|
|
1565
679
|
}, [
|
|
1566
|
-
extension
|
|
1567
|
-
autoFocus,
|
|
1568
|
-
value,
|
|
1569
|
-
variant,
|
|
1570
|
-
onBlur
|
|
680
|
+
extension
|
|
1571
681
|
]);
|
|
1572
|
-
return /* @__PURE__ */
|
|
682
|
+
return /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
1573
683
|
ref: parentRef,
|
|
1574
|
-
className:
|
|
1575
|
-
style: box,
|
|
1576
|
-
...gridId && {
|
|
1577
|
-
"data-grid": gridId
|
|
1578
|
-
}
|
|
684
|
+
className: "flex w-full"
|
|
1579
685
|
});
|
|
1580
686
|
};
|
|
1581
687
|
var highlightStyles = import_language.HighlightStyle.define([
|
|
@@ -1688,7 +794,13 @@ var sheetExtension = ({ functions = [] }) => {
|
|
|
1688
794
|
// NOTE: Useful for debugging.
|
|
1689
795
|
closeOnBlur: false,
|
|
1690
796
|
icons: false,
|
|
1691
|
-
tooltipClass: () => (0,
|
|
797
|
+
tooltipClass: () => (0, import_react_ui_theme3.mx)(
|
|
798
|
+
// TODO(burdon): Factor out fragments.
|
|
799
|
+
// TODO(burdon): Size to make width same as column.
|
|
800
|
+
"!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
|
|
801
|
+
"[&>ul>li[aria-selected]]:!bg-accentSurface",
|
|
802
|
+
"border-separator"
|
|
803
|
+
)
|
|
1692
804
|
}),
|
|
1693
805
|
import_view2.keymap.of([
|
|
1694
806
|
{
|
|
@@ -1775,7 +887,7 @@ var visitTree = (node, callback) => {
|
|
|
1775
887
|
}
|
|
1776
888
|
return false;
|
|
1777
889
|
};
|
|
1778
|
-
var
|
|
890
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
|
|
1779
891
|
var fragments = {
|
|
1780
892
|
axis: "bg-axisSurface text-axisText text-xs select-none",
|
|
1781
893
|
axisSelected: "bg-attention text-baseText",
|
|
@@ -1783,19 +895,18 @@ var fragments = {
|
|
|
1783
895
|
cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
|
|
1784
896
|
};
|
|
1785
897
|
var SheetRoot = ({ children, ...props }) => {
|
|
1786
|
-
return /* @__PURE__ */
|
|
898
|
+
return /* @__PURE__ */ import_react3.default.createElement(SheetContextProvider, props, children);
|
|
1787
899
|
};
|
|
1788
|
-
var SheetMain = /* @__PURE__ */ (0,
|
|
900
|
+
var SheetMain = /* @__PURE__ */ (0, import_react3.forwardRef)(({ classNames, numRows, numColumns }, forwardRef2) => {
|
|
1789
901
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
1790
902
|
const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
|
|
1791
|
-
|
|
1792
|
-
const [rows, setRows] = (0, import_react2.useState)([
|
|
903
|
+
const [rows, setRows] = (0, import_react3.useState)([
|
|
1793
904
|
...model.sheet.rows
|
|
1794
905
|
]);
|
|
1795
|
-
const [columns, setColumns] = (0,
|
|
906
|
+
const [columns, setColumns] = (0, import_react3.useState)([
|
|
1796
907
|
...model.sheet.columns
|
|
1797
908
|
]);
|
|
1798
|
-
(0,
|
|
909
|
+
(0, import_react3.useEffect)(() => {
|
|
1799
910
|
const rowsAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1800
911
|
"rows"
|
|
1801
912
|
]);
|
|
@@ -1820,37 +931,37 @@ var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, num
|
|
|
1820
931
|
}, [
|
|
1821
932
|
model
|
|
1822
933
|
]);
|
|
1823
|
-
(0,
|
|
934
|
+
(0, import_react3.useEffect)(() => {
|
|
1824
935
|
model.reset();
|
|
1825
936
|
}, [
|
|
1826
937
|
rows,
|
|
1827
938
|
columns
|
|
1828
939
|
]);
|
|
1829
940
|
const handleMoveRows = (from, to, num = 1) => {
|
|
1830
|
-
const cursorIdx = cursor ? addressToIndex(
|
|
941
|
+
const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
|
|
1831
942
|
const [rows2] = model.sheet.rows.splice(from, num);
|
|
1832
943
|
model.sheet.rows.splice(to, 0, rows2);
|
|
1833
944
|
if (cursorIdx) {
|
|
1834
|
-
setCursor(addressFromIndex(
|
|
945
|
+
setCursor(model.addressFromIndex(cursorIdx));
|
|
1835
946
|
}
|
|
1836
947
|
setRows([
|
|
1837
948
|
...model.sheet.rows
|
|
1838
949
|
]);
|
|
1839
950
|
};
|
|
1840
951
|
const handleMoveColumns = (from, to, num = 1) => {
|
|
1841
|
-
const cursorIdx = cursor ? addressToIndex(
|
|
952
|
+
const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
|
|
1842
953
|
const columns2 = model.sheet.columns.splice(from, num);
|
|
1843
954
|
model.sheet.columns.splice(to, 0, ...columns2);
|
|
1844
955
|
if (cursorIdx) {
|
|
1845
|
-
setCursor(addressFromIndex(
|
|
956
|
+
setCursor(model.addressFromIndex(cursorIdx));
|
|
1846
957
|
}
|
|
1847
958
|
setColumns([
|
|
1848
959
|
...model.sheet.columns
|
|
1849
960
|
]);
|
|
1850
961
|
};
|
|
1851
|
-
const [rowSizes, setRowSizes] = (0,
|
|
1852
|
-
const [columnSizes, setColumnSizes] = (0,
|
|
1853
|
-
(0,
|
|
962
|
+
const [rowSizes, setRowSizes] = (0, import_react3.useState)();
|
|
963
|
+
const [columnSizes, setColumnSizes] = (0, import_react3.useState)();
|
|
964
|
+
(0, import_react3.useEffect)(() => {
|
|
1854
965
|
const rowAccessor = (0, import_echo.createDocAccessor)(model.sheet, [
|
|
1855
966
|
"rowMeta"
|
|
1856
967
|
]);
|
|
@@ -1899,54 +1010,54 @@ var SheetMain = /* @__PURE__ */ (0, import_react2.forwardRef)(({ classNames, num
|
|
|
1899
1010
|
}));
|
|
1900
1011
|
}
|
|
1901
1012
|
};
|
|
1902
|
-
return /* @__PURE__ */
|
|
1013
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1903
1014
|
role: "none",
|
|
1904
|
-
className: (0,
|
|
1905
|
-
}, /* @__PURE__ */
|
|
1015
|
+
className: (0, import_react_ui_theme2.mx)("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
|
|
1016
|
+
}, /* @__PURE__ */ import_react3.default.createElement(GridCorner, {
|
|
1906
1017
|
onClick: () => {
|
|
1907
1018
|
setCursor(void 0);
|
|
1908
1019
|
setRange(void 0);
|
|
1909
1020
|
setEditing(false);
|
|
1910
1021
|
}
|
|
1911
|
-
}), /* @__PURE__ */
|
|
1022
|
+
}), /* @__PURE__ */ import_react3.default.createElement(SheetColumns, {
|
|
1912
1023
|
ref: columnsRef,
|
|
1913
1024
|
columns,
|
|
1914
1025
|
sizes: columnSizes,
|
|
1915
|
-
selected: cursor?.
|
|
1916
|
-
onSelect: (
|
|
1026
|
+
selected: cursor?.column,
|
|
1027
|
+
onSelect: (column) => setCursor(cursor?.column === column ? void 0 : {
|
|
1917
1028
|
row: -1,
|
|
1918
|
-
|
|
1029
|
+
column
|
|
1919
1030
|
}),
|
|
1920
1031
|
onResize: handleResizeColumn,
|
|
1921
1032
|
onMove: handleMoveColumns
|
|
1922
|
-
}), /* @__PURE__ */
|
|
1033
|
+
}), /* @__PURE__ */ import_react3.default.createElement(SheetRows, {
|
|
1923
1034
|
ref: rowsRef,
|
|
1924
1035
|
rows,
|
|
1925
1036
|
sizes: rowSizes,
|
|
1926
1037
|
selected: cursor?.row,
|
|
1927
1038
|
onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
|
|
1928
1039
|
row,
|
|
1929
|
-
|
|
1040
|
+
column: -1
|
|
1930
1041
|
}),
|
|
1931
1042
|
onResize: handleResizeRow,
|
|
1932
1043
|
onMove: handleMoveRows
|
|
1933
|
-
}), /* @__PURE__ */
|
|
1044
|
+
}), /* @__PURE__ */ import_react3.default.createElement(SheetGrid, {
|
|
1934
1045
|
ref: contentRef,
|
|
1935
1046
|
size: {
|
|
1936
1047
|
numRows: numRows ?? rows.length,
|
|
1937
|
-
|
|
1048
|
+
numColumns: numColumns ?? columns.length
|
|
1938
1049
|
},
|
|
1939
1050
|
rows,
|
|
1940
1051
|
columns,
|
|
1941
1052
|
rowSizes,
|
|
1942
1053
|
columnSizes
|
|
1943
|
-
}), /* @__PURE__ */
|
|
1054
|
+
}), /* @__PURE__ */ import_react3.default.createElement(GridCorner, null), /* @__PURE__ */ import_react3.default.createElement(SheetStatusBar, null));
|
|
1944
1055
|
});
|
|
1945
1056
|
var useScrollHandlers = () => {
|
|
1946
|
-
const rowsRef = (0,
|
|
1947
|
-
const columnsRef = (0,
|
|
1948
|
-
const contentRef = (0,
|
|
1949
|
-
(0,
|
|
1057
|
+
const rowsRef = (0, import_react3.useRef)(null);
|
|
1058
|
+
const columnsRef = (0, import_react3.useRef)(null);
|
|
1059
|
+
const contentRef = (0, import_react3.useRef)(null);
|
|
1060
|
+
(0, import_react3.useEffect)(() => {
|
|
1950
1061
|
const handleRowsScroll = (ev) => {
|
|
1951
1062
|
const { scrollTop } = ev.target;
|
|
1952
1063
|
if (!rowsRef.current.dataset.locked) {
|
|
@@ -1983,13 +1094,13 @@ var useScrollHandlers = () => {
|
|
|
1983
1094
|
};
|
|
1984
1095
|
};
|
|
1985
1096
|
var GridCorner = (props) => {
|
|
1986
|
-
return /* @__PURE__ */
|
|
1097
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1987
1098
|
className: fragments.axis,
|
|
1988
1099
|
...props
|
|
1989
1100
|
});
|
|
1990
1101
|
};
|
|
1991
1102
|
var MovingOverlay = ({ label }) => {
|
|
1992
|
-
return /* @__PURE__ */
|
|
1103
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1993
1104
|
className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
|
|
1994
1105
|
}, label);
|
|
1995
1106
|
};
|
|
@@ -2000,7 +1111,7 @@ var touchConstraints = {
|
|
|
2000
1111
|
delay: 250,
|
|
2001
1112
|
tolerance: 5
|
|
2002
1113
|
};
|
|
2003
|
-
var SheetRows = /* @__PURE__ */ (0,
|
|
1114
|
+
var SheetRows = /* @__PURE__ */ (0, import_react3.forwardRef)(({ rows, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
2004
1115
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
2005
1116
|
activationConstraint: mouseConstraints
|
|
2006
1117
|
});
|
|
@@ -2009,7 +1120,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
2009
1120
|
});
|
|
2010
1121
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
2011
1122
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
2012
|
-
const [active, setActive] = (0,
|
|
1123
|
+
const [active, setActive] = (0, import_react3.useState)(null);
|
|
2013
1124
|
const handleDragStart = ({ active: active2 }) => {
|
|
2014
1125
|
setActive(active2);
|
|
2015
1126
|
};
|
|
@@ -2033,18 +1144,18 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
2033
1144
|
}
|
|
2034
1145
|
return transform;
|
|
2035
1146
|
};
|
|
2036
|
-
return /* @__PURE__ */
|
|
1147
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2037
1148
|
className: "relative flex grow overflow-hidden"
|
|
2038
|
-
}, /* @__PURE__ */
|
|
2039
|
-
className: (0,
|
|
1149
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1150
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
|
|
2040
1151
|
style: {
|
|
2041
1152
|
width: axisWidth
|
|
2042
1153
|
}
|
|
2043
|
-
}), /* @__PURE__ */
|
|
1154
|
+
}), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2044
1155
|
ref: forwardRef2,
|
|
2045
1156
|
role: "rowheader",
|
|
2046
1157
|
className: "grow overflow-y-auto scrollbar-none"
|
|
2047
|
-
}, /* @__PURE__ */
|
|
1158
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_core.DndContext, {
|
|
2048
1159
|
sensors,
|
|
2049
1160
|
modifiers: [
|
|
2050
1161
|
import_modifiers.restrictToVerticalAxis,
|
|
@@ -2052,12 +1163,12 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
2052
1163
|
],
|
|
2053
1164
|
onDragStart: handleDragStart,
|
|
2054
1165
|
onDragEnd: handleDragEnd
|
|
2055
|
-
}, /* @__PURE__ */
|
|
1166
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2056
1167
|
className: "flex flex-col",
|
|
2057
1168
|
style: {
|
|
2058
1169
|
width: axisWidth
|
|
2059
1170
|
}
|
|
2060
|
-
}, rows.map((idx, index) => /* @__PURE__ */
|
|
1171
|
+
}, rows.map((idx, index) => /* @__PURE__ */ import_react3.default.createElement(GridRowCell, {
|
|
2061
1172
|
key: idx,
|
|
2062
1173
|
idx,
|
|
2063
1174
|
index,
|
|
@@ -2067,7 +1178,7 @@ var SheetRows = /* @__PURE__ */ (0, import_react2.forwardRef)(({ rows, sizes, se
|
|
|
2067
1178
|
selected: selected === index,
|
|
2068
1179
|
onResize,
|
|
2069
1180
|
onSelect
|
|
2070
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1181
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react3.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react3.default.createElement(MovingOverlay, {
|
|
2071
1182
|
label: String(active.data.current.index + 1)
|
|
2072
1183
|
})), document.body))));
|
|
2073
1184
|
});
|
|
@@ -2085,9 +1196,9 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
2085
1196
|
}
|
|
2086
1197
|
});
|
|
2087
1198
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
2088
|
-
const [initialSize, setInitialSize] = (0,
|
|
2089
|
-
const [resizing, setResizing] = (0,
|
|
2090
|
-
const scrollHandler = (0,
|
|
1199
|
+
const [initialSize, setInitialSize] = (0, import_react3.useState)(size);
|
|
1200
|
+
const [resizing, setResizing] = (0, import_react3.useState)(false);
|
|
1201
|
+
const scrollHandler = (0, import_react3.useRef)();
|
|
2091
1202
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
2092
1203
|
const scrollContainer = elementRef.closest('[role="rowheader"]');
|
|
2093
1204
|
const scrollTop = scrollContainer.scrollTop;
|
|
@@ -2108,7 +1219,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
2108
1219
|
onResize?.(idx, initialSize + height, true);
|
|
2109
1220
|
setResizing(false);
|
|
2110
1221
|
};
|
|
2111
|
-
return /* @__PURE__ */
|
|
1222
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_re_resizable.Resizable, {
|
|
2112
1223
|
enable: {
|
|
2113
1224
|
bottom: resize
|
|
2114
1225
|
},
|
|
@@ -2120,21 +1231,21 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
|
|
|
2120
1231
|
onResizeStart: handleResizeStart,
|
|
2121
1232
|
onResize: handleResize,
|
|
2122
1233
|
onResizeStop: handleResizeStop
|
|
2123
|
-
}, /* @__PURE__ */
|
|
1234
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2124
1235
|
ref: setNodeRef,
|
|
2125
1236
|
...attributes,
|
|
2126
1237
|
...listeners,
|
|
2127
|
-
className: (0,
|
|
1238
|
+
className: (0, import_react_ui_theme2.mx)("flex h-full items-center justify-center cursor-pointer", "border-t border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
2128
1239
|
onClick: () => onSelect?.(index)
|
|
2129
|
-
}, /* @__PURE__ */
|
|
1240
|
+
}, /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
2130
1241
|
className: "flex w-full justify-center"
|
|
2131
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
1242
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2132
1243
|
className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
2133
|
-
}), resizing && /* @__PURE__ */
|
|
1244
|
+
}), resizing && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2134
1245
|
className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
|
|
2135
1246
|
})));
|
|
2136
1247
|
};
|
|
2137
|
-
var SheetColumns = /* @__PURE__ */ (0,
|
|
1248
|
+
var SheetColumns = /* @__PURE__ */ (0, import_react3.forwardRef)(({ columns, sizes, selected, onSelect, onResize, onMove }, forwardRef2) => {
|
|
2138
1249
|
const mouseSensor = (0, import_core.useSensor)(import_core.MouseSensor, {
|
|
2139
1250
|
activationConstraint: mouseConstraints
|
|
2140
1251
|
});
|
|
@@ -2143,7 +1254,7 @@ var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, siz
|
|
|
2143
1254
|
});
|
|
2144
1255
|
const keyboardSensor = (0, import_core.useSensor)(import_core.KeyboardSensor, {});
|
|
2145
1256
|
const sensors = (0, import_core.useSensors)(mouseSensor, touchSensor, keyboardSensor);
|
|
2146
|
-
const [active, setActive] = (0,
|
|
1257
|
+
const [active, setActive] = (0, import_react3.useState)(null);
|
|
2147
1258
|
const handleDragStart = ({ active: active2 }) => {
|
|
2148
1259
|
setActive(active2);
|
|
2149
1260
|
};
|
|
@@ -2167,18 +1278,18 @@ var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, siz
|
|
|
2167
1278
|
}
|
|
2168
1279
|
return transform;
|
|
2169
1280
|
};
|
|
2170
|
-
return /* @__PURE__ */
|
|
1281
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2171
1282
|
className: "relative flex grow overflow-hidden"
|
|
2172
|
-
}, /* @__PURE__ */
|
|
2173
|
-
className: (0,
|
|
1283
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1284
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
|
|
2174
1285
|
style: {
|
|
2175
1286
|
height: axisHeight
|
|
2176
1287
|
}
|
|
2177
|
-
}), /* @__PURE__ */
|
|
1288
|
+
}), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2178
1289
|
ref: forwardRef2,
|
|
2179
1290
|
role: "columnheader",
|
|
2180
1291
|
className: "grow overflow-x-auto scrollbar-none"
|
|
2181
|
-
}, /* @__PURE__ */
|
|
1292
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_core.DndContext, {
|
|
2182
1293
|
autoScroll: {
|
|
2183
1294
|
enabled: true
|
|
2184
1295
|
},
|
|
@@ -2189,23 +1300,23 @@ var SheetColumns = /* @__PURE__ */ (0, import_react2.forwardRef)(({ columns, siz
|
|
|
2189
1300
|
],
|
|
2190
1301
|
onDragStart: handleDragStart,
|
|
2191
1302
|
onDragEnd: handleDragEnd
|
|
2192
|
-
}, /* @__PURE__ */
|
|
1303
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2193
1304
|
className: "flex h-full",
|
|
2194
1305
|
style: {
|
|
2195
1306
|
height: axisHeight
|
|
2196
1307
|
}
|
|
2197
|
-
}, columns.map((idx, index) => /* @__PURE__ */
|
|
1308
|
+
}, columns.map((idx, index) => /* @__PURE__ */ import_react3.default.createElement(GridColumnCell, {
|
|
2198
1309
|
key: idx,
|
|
2199
1310
|
idx,
|
|
2200
1311
|
index,
|
|
2201
|
-
label: columnLetter(index),
|
|
1312
|
+
label: (0, import_chunk_5KKJ4NPP.columnLetter)(index),
|
|
2202
1313
|
size: sizes?.[idx] ?? defaultWidth,
|
|
2203
1314
|
resize: index < columns.length - 1,
|
|
2204
1315
|
selected: selected === index,
|
|
2205
1316
|
onResize,
|
|
2206
1317
|
onSelect
|
|
2207
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
2208
|
-
label: columnLetter(active.data.current.index)
|
|
1318
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react3.default.createElement(import_core.DragOverlay, null, active && /* @__PURE__ */ import_react3.default.createElement(MovingOverlay, {
|
|
1319
|
+
label: (0, import_chunk_5KKJ4NPP.columnLetter)(active.data.current.index)
|
|
2209
1320
|
})), document.body))));
|
|
2210
1321
|
});
|
|
2211
1322
|
var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onResize }) => {
|
|
@@ -2222,9 +1333,9 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2222
1333
|
}
|
|
2223
1334
|
});
|
|
2224
1335
|
const setNodeRef = (0, import_utilities.useCombinedRefs)(setDroppableNodeRef, setDraggableNodeRef);
|
|
2225
|
-
const [initialSize, setInitialSize] = (0,
|
|
2226
|
-
const [resizing, setResizing] = (0,
|
|
2227
|
-
const scrollHandler = (0,
|
|
1336
|
+
const [initialSize, setInitialSize] = (0, import_react3.useState)(size);
|
|
1337
|
+
const [resizing, setResizing] = (0, import_react3.useState)(false);
|
|
1338
|
+
const scrollHandler = (0, import_react3.useRef)();
|
|
2228
1339
|
const handleResizeStart = (_ev, _dir, elementRef) => {
|
|
2229
1340
|
const scrollContainer = elementRef.closest('[role="columnheader"]');
|
|
2230
1341
|
const scrollLeft = scrollContainer.scrollLeft;
|
|
@@ -2245,7 +1356,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2245
1356
|
onResize?.(idx, initialSize + width, true);
|
|
2246
1357
|
setResizing(false);
|
|
2247
1358
|
};
|
|
2248
|
-
return /* @__PURE__ */
|
|
1359
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_re_resizable.Resizable, {
|
|
2249
1360
|
enable: {
|
|
2250
1361
|
right: resize
|
|
2251
1362
|
},
|
|
@@ -2257,37 +1368,37 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
|
|
|
2257
1368
|
onResizeStart: handleResizeStart,
|
|
2258
1369
|
onResize: handleResize,
|
|
2259
1370
|
onResizeStop: handleResizeStop
|
|
2260
|
-
}, /* @__PURE__ */
|
|
1371
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2261
1372
|
ref: setNodeRef,
|
|
2262
1373
|
...attributes,
|
|
2263
1374
|
...listeners,
|
|
2264
|
-
className: (0,
|
|
1375
|
+
className: (0, import_react_ui_theme2.mx)("flex h-full items-center justify-center cursor-pointer", "border-l border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
|
|
2265
1376
|
onClick: () => onSelect?.(index)
|
|
2266
|
-
}, /* @__PURE__ */
|
|
1377
|
+
}, /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
2267
1378
|
className: "flex w-full justify-center"
|
|
2268
|
-
}, label), over?.id === idx && !isDragging && /* @__PURE__ */
|
|
1379
|
+
}, label), over?.id === idx && !isDragging && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2269
1380
|
className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
|
|
2270
|
-
}), resizing && /* @__PURE__ */
|
|
1381
|
+
}), resizing && /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2271
1382
|
className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
|
|
2272
1383
|
})));
|
|
2273
1384
|
};
|
|
2274
|
-
var SheetGrid = /* @__PURE__ */ (0,
|
|
1385
|
+
var SheetGrid = /* @__PURE__ */ (0, import_react3.forwardRef)(({ size, rows, columns, rowSizes, columnSizes }, forwardRef2) => {
|
|
2275
1386
|
const { ref: containerRef, width: containerWidth = 0, height: containerHeight = 0 } = (0, import_react_resize_detector.useResizeDetector)({
|
|
2276
1387
|
refreshRate: 200
|
|
2277
1388
|
});
|
|
2278
|
-
const scrollerRef = (0,
|
|
2279
|
-
(0,
|
|
1389
|
+
const scrollerRef = (0, import_react3.useRef)(null);
|
|
1390
|
+
(0, import_react3.useImperativeHandle)(forwardRef2, () => scrollerRef.current);
|
|
2280
1391
|
const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
|
|
2281
|
-
const initialText = (0,
|
|
2282
|
-
const quickEdit = (0,
|
|
2283
|
-
const [, forceUpdate] = (0,
|
|
2284
|
-
(0,
|
|
1392
|
+
const initialText = (0, import_react3.useRef)();
|
|
1393
|
+
const quickEdit = (0, import_react3.useRef)(false);
|
|
1394
|
+
const [, forceUpdate] = (0, import_react3.useState)({});
|
|
1395
|
+
(0, import_react3.useEffect)(() => {
|
|
2285
1396
|
const unsubscribe = model.update.on(() => {
|
|
2286
1397
|
(0, import_log.log)("updated", {
|
|
2287
1398
|
id: model.id
|
|
2288
1399
|
}, {
|
|
2289
|
-
F:
|
|
2290
|
-
L:
|
|
1400
|
+
F: __dxlog_file2,
|
|
1401
|
+
L: 730,
|
|
2291
1402
|
S: void 0,
|
|
2292
1403
|
C: (f, a) => f(...a)
|
|
2293
1404
|
});
|
|
@@ -2299,7 +1410,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2299
1410
|
}, [
|
|
2300
1411
|
model
|
|
2301
1412
|
]);
|
|
2302
|
-
const inputRef = (0,
|
|
1413
|
+
const inputRef = (0, import_react3.useRef)(null);
|
|
2303
1414
|
const handleKeyDown = (ev) => {
|
|
2304
1415
|
const isMacOS = /Mac|iPhone|iPod|iPad/.test(navigator.userAgent);
|
|
2305
1416
|
if (cursor && (isMacOS && ev.metaKey || ev.ctrlKey)) {
|
|
@@ -2407,16 +1518,16 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2407
1518
|
const id = (0, import_echo.fullyQualifiedId)(model.sheet);
|
|
2408
1519
|
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(id);
|
|
2409
1520
|
const hasAttention = (0, import_react_ui_attention.useHasAttention)(id);
|
|
2410
|
-
return /* @__PURE__ */
|
|
1521
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2411
1522
|
ref: containerRef,
|
|
2412
1523
|
role: "grid",
|
|
2413
1524
|
className: "relative flex grow overflow-hidden"
|
|
2414
|
-
}, /* @__PURE__ */
|
|
2415
|
-
className: (0,
|
|
2416
|
-
}), /* @__PURE__ */
|
|
1525
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1526
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute inset-0 border border-gridLine pointer-events-none")
|
|
1527
|
+
}), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2417
1528
|
ref: scrollerRef,
|
|
2418
|
-
className: (0,
|
|
2419
|
-
}, /* @__PURE__ */
|
|
1529
|
+
className: (0, import_react_ui_theme2.mx)("grow", hasAttention && "overflow-auto scrollbar-thin")
|
|
1530
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2420
1531
|
className: "relative select-none",
|
|
2421
1532
|
style: {
|
|
2422
1533
|
width,
|
|
@@ -2424,10 +1535,10 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2424
1535
|
},
|
|
2425
1536
|
onClick: () => inputRef.current?.focus(),
|
|
2426
1537
|
...handlers
|
|
2427
|
-
}, scrollerRef.current && /* @__PURE__ */
|
|
1538
|
+
}, scrollerRef.current && /* @__PURE__ */ import_react3.default.createElement(SelectionOverlay, {
|
|
2428
1539
|
root: scrollerRef.current
|
|
2429
1540
|
}), rowRange.map(({ row, top, height: height2 }) => {
|
|
2430
|
-
return columnRange.map(({
|
|
1541
|
+
return columnRange.map(({ column, left, width: width2 }) => {
|
|
2431
1542
|
const style = {
|
|
2432
1543
|
position: "absolute",
|
|
2433
1544
|
top,
|
|
@@ -2437,11 +1548,11 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2437
1548
|
};
|
|
2438
1549
|
const cell = {
|
|
2439
1550
|
row,
|
|
2440
|
-
|
|
1551
|
+
column
|
|
2441
1552
|
};
|
|
2442
|
-
const id2 = addressToA1Notation(cell);
|
|
2443
|
-
const idx = addressToIndex(
|
|
2444
|
-
const active = posEquals(cursor, cell);
|
|
1553
|
+
const id2 = (0, import_chunk_5KKJ4NPP.addressToA1Notation)(cell);
|
|
1554
|
+
const idx = model.addressToIndex(cell);
|
|
1555
|
+
const active = (0, import_chunk_5KKJ4NPP.posEquals)(cursor, cell);
|
|
2445
1556
|
if (active && editing) {
|
|
2446
1557
|
const value = initialText.current ?? model.getCellText(cell) ?? "";
|
|
2447
1558
|
const handleClose = (value2) => {
|
|
@@ -2473,7 +1584,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2473
1584
|
inputRef.current?.focus();
|
|
2474
1585
|
setEditing(false);
|
|
2475
1586
|
};
|
|
2476
|
-
return /* @__PURE__ */
|
|
1587
|
+
return /* @__PURE__ */ import_react3.default.createElement(GridCellEditor, {
|
|
2477
1588
|
key: idx,
|
|
2478
1589
|
value,
|
|
2479
1590
|
style,
|
|
@@ -2481,7 +1592,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2481
1592
|
onClose: handleClose
|
|
2482
1593
|
});
|
|
2483
1594
|
}
|
|
2484
|
-
return /* @__PURE__ */
|
|
1595
|
+
return /* @__PURE__ */ import_react3.default.createElement(SheetCell, {
|
|
2485
1596
|
key: id2,
|
|
2486
1597
|
id: id2,
|
|
2487
1598
|
cell,
|
|
@@ -2493,7 +1604,7 @@ var SheetGrid = /* @__PURE__ */ (0, import_react2.forwardRef)(({ size, rows, col
|
|
|
2493
1604
|
}
|
|
2494
1605
|
});
|
|
2495
1606
|
});
|
|
2496
|
-
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
1607
|
+
}))), /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react3.default.createElement("input", {
|
|
2497
1608
|
ref: inputRef,
|
|
2498
1609
|
autoFocus: true,
|
|
2499
1610
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
@@ -2514,34 +1625,20 @@ var SelectionOverlay = ({ root }) => {
|
|
|
2514
1625
|
const b1 = getRelativeClientRect(root, c1);
|
|
2515
1626
|
const b2 = getRelativeClientRect(root, c2);
|
|
2516
1627
|
const bounds = getRectUnion(b1, b2);
|
|
2517
|
-
return /* @__PURE__ */
|
|
1628
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2518
1629
|
role: "none",
|
|
2519
1630
|
style: bounds,
|
|
2520
1631
|
className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
|
|
2521
1632
|
});
|
|
2522
1633
|
};
|
|
2523
1634
|
var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
2524
|
-
const { formatting, editing, setRange
|
|
1635
|
+
const { formatting, editing, setRange } = useSheetContext();
|
|
2525
1636
|
const { value, classNames } = formatting.getFormatting(cell);
|
|
2526
|
-
|
|
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", {
|
|
1637
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2541
1638
|
[`data-${CELL_DATA_KEY}`]: id,
|
|
2542
1639
|
role: "cell",
|
|
2543
1640
|
style,
|
|
2544
|
-
className: (0,
|
|
1641
|
+
className: (0, import_react_ui_theme2.mx)("flex w-full h-full px-2 py-1 truncate items-center border border-gridLine cursor-pointer", fragments.cell, active && [
|
|
2545
1642
|
"z-20",
|
|
2546
1643
|
fragments.cellSelected
|
|
2547
1644
|
], classNames),
|
|
@@ -2555,36 +1652,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
|
|
|
2555
1652
|
}
|
|
2556
1653
|
},
|
|
2557
1654
|
onDoubleClick: () => onSelect?.(cell, true)
|
|
2558
|
-
},
|
|
1655
|
+
}, value);
|
|
2559
1656
|
};
|
|
2560
1657
|
var GridCellEditor = ({ style, value, onNav, onClose }) => {
|
|
2561
1658
|
const { model, range } = useSheetContext();
|
|
2562
|
-
const notifier = (0,
|
|
2563
|
-
(0,
|
|
1659
|
+
const notifier = (0, import_react3.useRef)();
|
|
1660
|
+
(0, import_react3.useEffect)(() => {
|
|
2564
1661
|
if (range) {
|
|
2565
|
-
notifier.current?.(rangeToA1Notation(range));
|
|
1662
|
+
notifier.current?.((0, import_chunk_5KKJ4NPP.rangeToA1Notation)(range));
|
|
2566
1663
|
}
|
|
2567
1664
|
}, [
|
|
2568
1665
|
range
|
|
2569
1666
|
]);
|
|
2570
|
-
const extension = (0,
|
|
1667
|
+
const extension = (0, import_react3.useMemo)(() => [
|
|
2571
1668
|
editorKeys({
|
|
2572
1669
|
onNav,
|
|
2573
1670
|
onClose
|
|
2574
1671
|
}),
|
|
2575
1672
|
sheetExtension({
|
|
2576
|
-
functions: model.
|
|
1673
|
+
functions: model.functions
|
|
2577
1674
|
}),
|
|
2578
1675
|
rangeExtension((fn) => notifier.current = fn)
|
|
2579
1676
|
], [
|
|
2580
1677
|
model
|
|
2581
1678
|
]);
|
|
2582
|
-
return /* @__PURE__ */
|
|
1679
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2583
1680
|
role: "cell",
|
|
2584
1681
|
style,
|
|
2585
|
-
className: (0,
|
|
1682
|
+
className: (0, import_react_ui_theme2.mx)("z-20 flex", fragments.cellSelected),
|
|
2586
1683
|
onClick: (ev) => ev.stopPropagation()
|
|
2587
|
-
}, /* @__PURE__ */
|
|
1684
|
+
}, /* @__PURE__ */ import_react3.default.createElement(CellEditor, {
|
|
2588
1685
|
autoFocus: true,
|
|
2589
1686
|
value,
|
|
2590
1687
|
extension
|
|
@@ -2597,30 +1694,30 @@ var SheetStatusBar = () => {
|
|
|
2597
1694
|
if (cursor) {
|
|
2598
1695
|
value = model.getCellValue(cursor);
|
|
2599
1696
|
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2600
|
-
value = model.
|
|
1697
|
+
value = model.mapFormulaBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
2601
1698
|
isFormula = true;
|
|
2602
1699
|
} else if (value != null) {
|
|
2603
1700
|
value = String(value);
|
|
2604
1701
|
}
|
|
2605
1702
|
}
|
|
2606
|
-
return /* @__PURE__ */
|
|
2607
|
-
className: (0,
|
|
2608
|
-
}, /* @__PURE__ */
|
|
1703
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1704
|
+
className: (0, import_react_ui_theme2.mx)("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
|
|
1705
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2609
1706
|
className: "flex gap-4 items-center"
|
|
2610
|
-
}, /* @__PURE__ */
|
|
1707
|
+
}, /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2611
1708
|
className: "flex w-16 items-center font-mono"
|
|
2612
|
-
}, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */
|
|
1709
|
+
}, range && (0, import_chunk_5KKJ4NPP.rangeToA1Notation)(range) || cursor && (0, import_chunk_5KKJ4NPP.addressToA1Notation)(cursor)), /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
2613
1710
|
className: "flex gap-2 items-center"
|
|
2614
|
-
}, /* @__PURE__ */
|
|
2615
|
-
className: (0,
|
|
2616
|
-
}), /* @__PURE__ */
|
|
1711
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_react2.Function, {
|
|
1712
|
+
className: (0, import_react_ui_theme2.mx)("text-greenText", isFormula ? "visible" : "invisible")
|
|
1713
|
+
}), /* @__PURE__ */ import_react3.default.createElement("span", {
|
|
2617
1714
|
className: "font-mono"
|
|
2618
1715
|
}, value))));
|
|
2619
1716
|
};
|
|
2620
1717
|
var SheetDebug = () => {
|
|
2621
1718
|
const { model, cursor, range } = useSheetContext();
|
|
2622
|
-
const [, forceUpdate] = (0,
|
|
2623
|
-
(0,
|
|
1719
|
+
const [, forceUpdate] = (0, import_react3.useState)({});
|
|
1720
|
+
(0, import_react3.useEffect)(() => {
|
|
2624
1721
|
const accessor = (0, import_echo.createDocAccessor)(model.sheet, []);
|
|
2625
1722
|
const handleUpdate = () => forceUpdate({});
|
|
2626
1723
|
accessor.handle.addListener("change", handleUpdate);
|
|
@@ -2631,9 +1728,9 @@ var SheetDebug = () => {
|
|
|
2631
1728
|
}, [
|
|
2632
1729
|
model
|
|
2633
1730
|
]);
|
|
2634
|
-
return /* @__PURE__ */
|
|
2635
|
-
className: (0,
|
|
2636
|
-
}, /* @__PURE__ */
|
|
1731
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", {
|
|
1732
|
+
className: (0, import_react_ui_theme2.mx)("z-20 absolute right-0 top-20 bottom-20 w-[30rem] overflow-auto scrollbar-thin", "border border-gridLine text-xs bg-neutral-50 dark:bg-black text-cyan-500 font-mono p-1 opacity-80")
|
|
1733
|
+
}, /* @__PURE__ */ import_react3.default.createElement("pre", {
|
|
2637
1734
|
className: "whitespace-pre-wrap"
|
|
2638
1735
|
}, JSON.stringify({
|
|
2639
1736
|
cursor,
|
|
@@ -2654,15 +1751,15 @@ var Sheet = {
|
|
|
2654
1751
|
StatusBar: SheetStatusBar,
|
|
2655
1752
|
Debug: SheetDebug
|
|
2656
1753
|
};
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
//# sourceMappingURL=
|
|
1754
|
+
var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
|
|
1755
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
1756
|
+
role: "none",
|
|
1757
|
+
className: (0, import_react_ui_theme.mx)("flex", role === "article" && "row-span-2", role === "section" && "aspect-square border-y border-is border-separator")
|
|
1758
|
+
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Root, {
|
|
1759
|
+
sheet,
|
|
1760
|
+
space,
|
|
1761
|
+
remoteFunctionUrl
|
|
1762
|
+
}, /* @__PURE__ */ import_react.default.createElement(Sheet.Main, null)));
|
|
1763
|
+
};
|
|
1764
|
+
var SheetContainer_default = SheetContainer;
|
|
1765
|
+
//# sourceMappingURL=SheetContainer-AXQV3ZT5.cjs.map
|