@dxos/plugin-sheet 0.8.3 → 0.8.4-main.1068cf700f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs +397 -0
- package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-AMMLA66W.mjs +24 -0
- package/dist/lib/browser/anchor-sort-AMMLA66W.mjs.map +7 -0
- package/dist/lib/browser/chunk-EDWHV64N.mjs +1473 -0
- package/dist/lib/browser/chunk-EDWHV64N.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FJRLDX7Z.mjs → chunk-IFLWVS2V.mjs} +7 -7
- package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
- package/dist/lib/browser/chunk-KE3AKN5W.mjs +397 -0
- package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +80 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-D2T2DOVX.mjs +29 -0
- package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs +79 -0
- package/dist/lib/browser/operation-resolver-P2RX75DA.mjs.map +7 -0
- package/dist/lib/browser/react-surface-45CRAB5G.mjs +51 -0
- package/dist/lib/browser/react-surface-45CRAB5G.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs +398 -0
- package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs +25 -0
- package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs +398 -0
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs +1474 -0
- package/dist/lib/node-esm/chunk-AYSEWH7N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NMCVJWDT.mjs → chunk-PPOYR7DK.mjs} +7 -7
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +80 -89
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs +30 -0
- package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs +52 -0
- package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -12
- package/dist/types/src/SheetPlugin.d.ts +2 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -11
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +9 -4
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +51 -3
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +11 -20
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +5 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +54 -5
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +3 -3
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +88 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +13 -20
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.stories.d.ts +10 -13
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/index.d.ts +1 -1
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -6
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +2 -2
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +2 -2
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/{testing/playwright → playwright}/sheet-manager.d.ts +1 -1
- package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/sheet.spec.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +2 -2
- package/dist/types/src/serializer.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +2 -2
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +27 -3
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -62
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +76 -0
- package/dist/types/src/types/Sheet.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +6 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts +2 -2
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +92 -75
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +10 -10
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +83 -73
- package/src/SheetPlugin.tsx +53 -65
- package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
- package/src/capabilities/compute-graph-registry/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +30 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +43 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +21 -20
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
- package/src/components/GridSheet/GridSheet.stories.tsx +23 -17
- package/src/components/GridSheet/GridSheet.tsx +63 -52
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +44 -43
- package/src/components/GridSheet/util.ts +17 -11
- package/src/components/RangeList/RangeList.tsx +13 -10
- package/src/components/SheetContainer/SheetContainer.stories.tsx +71 -47
- package/src/components/SheetContainer/SheetContainer.tsx +30 -18
- package/src/components/SheetContext/SheetContext.tsx +9 -9
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
- package/src/components/SheetToolbar/SheetToolbar.tsx +52 -42
- package/src/components/SheetToolbar/align.ts +46 -20
- package/src/components/SheetToolbar/style.ts +48 -18
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/extensions/compute.stories.tsx +43 -30
- package/src/extensions/compute.ts +3 -4
- package/src/extensions/editor/index.ts +1 -1
- package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
- package/src/extensions/editor/{extension.ts → sheet-extension.ts} +7 -4
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +43 -51
- package/src/meta.ts +9 -7
- package/src/model/sheet-model.test.ts +5 -4
- package/src/model/sheet-model.ts +85 -53
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/playwright.config.ts +17 -0
- package/src/{testing/playwright → playwright}/sheet-manager.ts +1 -1
- package/src/{testing/playwright → playwright}/sheet.spec.ts +3 -2
- package/src/sanity.test.ts +4 -5
- package/src/serializer.ts +4 -4
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +11 -5
- package/src/translations.ts +10 -7
- package/src/types/Sheet.ts +97 -0
- package/src/types/capabilities.ts +14 -0
- package/src/types/index.ts +2 -1
- package/src/types/sheet-range-types.ts +2 -2
- package/src/types/types.ts +84 -49
- package/src/types/util.ts +14 -41
- package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs +0 -351
- package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs +0 -24
- package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs.map +0 -7
- package/dist/lib/browser/chunk-5TA43LO4.mjs +0 -847
- package/dist/lib/browser/chunk-5TA43LO4.mjs.map +0 -7
- package/dist/lib/browser/chunk-D3G4UGEK.mjs +0 -18
- package/dist/lib/browser/chunk-D3G4UGEK.mjs.map +0 -7
- package/dist/lib/browser/chunk-FJRLDX7Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-I7FZ4TWJ.mjs +0 -892
- package/dist/lib/browser/chunk-I7FZ4TWJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-IR42IS3F.mjs +0 -15
- package/dist/lib/browser/chunk-IR42IS3F.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-IBBI6B74.mjs +0 -56
- package/dist/lib/browser/intent-resolver-IBBI6B74.mjs.map +0 -7
- package/dist/lib/browser/markdown-T4TUP4BF.mjs +0 -26
- package/dist/lib/browser/markdown-T4TUP4BF.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI46P43F.mjs +0 -53
- package/dist/lib/browser/react-surface-UI46P43F.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs +0 -351
- package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs.map +0 -7
- package/dist/lib/node/anchor-sort-A7NABMJM.cjs +0 -39
- package/dist/lib/node/anchor-sort-A7NABMJM.cjs.map +0 -7
- package/dist/lib/node/chunk-FIM6EZ6M.cjs +0 -256
- package/dist/lib/node/chunk-FIM6EZ6M.cjs.map +0 -7
- package/dist/lib/node/chunk-JSIDCZHB.cjs +0 -41
- package/dist/lib/node/chunk-JSIDCZHB.cjs.map +0 -7
- package/dist/lib/node/chunk-LJWWS53Z.cjs +0 -34
- package/dist/lib/node/chunk-LJWWS53Z.cjs.map +0 -7
- package/dist/lib/node/chunk-N7FSEUIN.cjs +0 -927
- package/dist/lib/node/chunk-N7FSEUIN.cjs.map +0 -7
- package/dist/lib/node/chunk-ST3WA73J.cjs +0 -855
- package/dist/lib/node/chunk-ST3WA73J.cjs.map +0 -7
- package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs +0 -56
- package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -173
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-2657YDOU.cjs +0 -69
- package/dist/lib/node/intent-resolver-2657YDOU.cjs.map +0 -7
- package/dist/lib/node/markdown-DBPOAYI7.cjs +0 -40
- package/dist/lib/node/markdown-DBPOAYI7.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-XQEIRKWU.cjs +0 -71
- package/dist/lib/node/react-surface-XQEIRKWU.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -84
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs +0 -352
- package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C4IKYVTV.mjs +0 -893
- package/dist/lib/node-esm/chunk-C4IKYVTV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IQ76YE6M.mjs +0 -16
- package/dist/lib/node-esm/chunk-IQ76YE6M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NMCVJWDT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SOC52B67.mjs +0 -848
- package/dist/lib/node-esm/chunk-SOC52B67.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs +0 -20
- package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs +0 -27
- package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs +0 -54
- package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +0 -4
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown.d.ts +0 -6
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/sheet-manager.d.ts.map +0 -1
- package/dist/types/src/testing/playwright/sheet.spec.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -37
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -22
- package/src/capabilities/capabilities.ts +0 -14
- package/src/capabilities/compute-graph-registry.ts +0 -28
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/markdown.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -39
- package/src/testing/playwright/playwright.config.cts +0 -18
- package/src/types/schema.ts +0 -60
- /package/dist/types/src/{testing/playwright → playwright}/sheet.spec.d.ts +0 -0
|
@@ -2,37 +2,36 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useRef, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { testFunctionPlugins } from '@dxos/compute/testing';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { Filter } from '@dxos/echo';
|
|
10
|
+
import { Function } from '@dxos/functions';
|
|
13
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
14
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
|
-
import {
|
|
13
|
+
import { Button, Input, Toolbar } from '@dxos/react-ui';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
15
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
17
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
18
16
|
|
|
19
|
-
import { useComputeGraph } from './ComputeGraphContextProvider';
|
|
20
17
|
import { useSheetModel } from '../../model';
|
|
21
18
|
import { withComputeGraphDecorator } from '../../testing';
|
|
22
|
-
import {
|
|
19
|
+
import { Sheet } from '../../types';
|
|
20
|
+
|
|
21
|
+
import { useComputeGraph } from './ComputeGraphContextProvider';
|
|
23
22
|
|
|
24
23
|
const FUNCTION_NAME = 'TEST';
|
|
25
24
|
|
|
26
|
-
const
|
|
25
|
+
const DefaultStory = () => {
|
|
27
26
|
const space = useSpace();
|
|
28
27
|
const graph = useComputeGraph(space);
|
|
29
|
-
const [sheet, setSheet] = useState<
|
|
28
|
+
const [sheet, setSheet] = useState<Sheet.Sheet>();
|
|
30
29
|
const [text, setText] = useState(`${FUNCTION_NAME}(100)`);
|
|
31
30
|
const [result, setResult] = useState<any>();
|
|
32
31
|
const model = useSheetModel(graph, sheet);
|
|
33
32
|
useEffect(() => {
|
|
34
33
|
if (space) {
|
|
35
|
-
const sheet = space.db.add(
|
|
34
|
+
const sheet = space.db.add(Sheet.make());
|
|
36
35
|
setSheet(sheet);
|
|
37
36
|
}
|
|
38
37
|
}, [space]);
|
|
@@ -45,14 +44,14 @@ const Story = () => {
|
|
|
45
44
|
setResult({ functions: { standard: f1.length, echo: f2.length } });
|
|
46
45
|
});
|
|
47
46
|
|
|
48
|
-
space.db.add(
|
|
47
|
+
space.db.add(Function.make({ name: 'test', version: '0.0.1', binding: FUNCTION_NAME }));
|
|
49
48
|
}
|
|
50
49
|
}, [space, graph]);
|
|
51
50
|
|
|
52
51
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
53
52
|
const handleTest = async () => {
|
|
54
53
|
if (space && graph) {
|
|
55
|
-
const
|
|
54
|
+
const objects = await space.db.query(Filter.type(Function.Function)).run();
|
|
56
55
|
const mapped = graph.mapFunctionBindingToId(text);
|
|
57
56
|
const unmapped = graph.mapFunctionBindingFromId(mapped);
|
|
58
57
|
const internal = graph.mapFormulaToNative(text);
|
|
@@ -82,16 +81,18 @@ const Story = () => {
|
|
|
82
81
|
);
|
|
83
82
|
};
|
|
84
83
|
|
|
85
|
-
export const Default = {};
|
|
84
|
+
export const Default: Story = {};
|
|
86
85
|
|
|
87
|
-
const meta
|
|
86
|
+
const meta = {
|
|
88
87
|
title: 'plugins/plugin-sheet/functions',
|
|
88
|
+
render: DefaultStory,
|
|
89
89
|
decorators: [
|
|
90
|
-
|
|
90
|
+
withTheme(),
|
|
91
|
+
withClientProvider({ types: [Function.Function, Sheet.Sheet], createIdentity: true, createSpace: true }),
|
|
91
92
|
withComputeGraphDecorator({ plugins: testFunctionPlugins }),
|
|
92
|
-
withTheme,
|
|
93
93
|
],
|
|
94
|
-
|
|
95
|
-
};
|
|
94
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
96
95
|
|
|
97
96
|
export default meta;
|
|
97
|
+
|
|
98
|
+
type Story = StoryObj<typeof meta>;
|
|
@@ -26,9 +26,9 @@ export const FunctionEditor = () => {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
|
-
<div className='flex shrink-0 justify-between items-center
|
|
29
|
+
<div className='flex shrink-0 justify-between items-center pli-4 plb-1 text-sm bg-toolbarSurface border-bs !border-subduedSeparator'>
|
|
30
30
|
<div className='flex gap-4 items-center'>
|
|
31
|
-
<div className='flex
|
|
31
|
+
<div className='flex is-16 items-center font-mono'>
|
|
32
32
|
{(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}
|
|
33
33
|
</div>
|
|
34
34
|
<div className='flex gap-2 items-center'>
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
8
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { testFunctionPlugins } from '@dxos/compute/testing';
|
|
10
|
+
import { OperationPlugin, RuntimePlugin } from '@dxos/plugin-testing';
|
|
12
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
13
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
-
import { withTheme
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
14
|
|
|
16
|
-
import { GridSheet } from './GridSheet';
|
|
17
15
|
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
18
|
-
import translations from '../../translations';
|
|
19
|
-
import {
|
|
16
|
+
import { translations } from '../../translations';
|
|
17
|
+
import { Sheet } from '../../types';
|
|
20
18
|
import { useComputeGraph } from '../ComputeGraph';
|
|
21
19
|
import { SheetProvider } from '../SheetContext';
|
|
22
20
|
|
|
21
|
+
import { GridSheet } from './GridSheet';
|
|
22
|
+
|
|
23
23
|
export const Basic = () => {
|
|
24
24
|
const space = useSpace();
|
|
25
25
|
const graph = useComputeGraph(space);
|
|
@@ -30,24 +30,30 @@ export const Basic = () => {
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<SheetProvider graph={graph} sheet={sheet} ignoreAttention>
|
|
33
|
-
<
|
|
33
|
+
<div role='none' className='grid bs-full is-full'>
|
|
34
|
+
<GridSheet />
|
|
35
|
+
</div>
|
|
34
36
|
</SheetProvider>
|
|
35
37
|
);
|
|
36
38
|
};
|
|
37
39
|
|
|
38
|
-
const meta
|
|
40
|
+
const meta = {
|
|
39
41
|
title: 'plugins/plugin-sheet/GridSheet',
|
|
40
42
|
component: GridSheet,
|
|
41
43
|
decorators: [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
withLayout({ fullscreen: true, classNames: 'grid' }),
|
|
44
|
+
withTheme(),
|
|
45
|
+
withClientProvider({ types: [Sheet.Sheet], createSpace: true }),
|
|
46
|
+
withComputeGraphDecorator({ plugins: testFunctionPlugins }),
|
|
46
47
|
withPluginManager({
|
|
47
|
-
plugins: [
|
|
48
|
+
plugins: [OperationPlugin(), RuntimePlugin()],
|
|
48
49
|
}),
|
|
49
50
|
],
|
|
50
|
-
parameters: {
|
|
51
|
-
|
|
51
|
+
parameters: {
|
|
52
|
+
layout: 'fullscreen',
|
|
53
|
+
translations,
|
|
54
|
+
},
|
|
55
|
+
} satisfies Meta<typeof GridSheet>;
|
|
52
56
|
|
|
53
57
|
export default meta;
|
|
58
|
+
|
|
59
|
+
type Story = StoryObj<typeof meta>;
|
|
@@ -3,42 +3,44 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import React, {
|
|
6
|
+
type FocusEvent,
|
|
7
|
+
type KeyboardEvent,
|
|
8
|
+
type MouseEvent,
|
|
9
|
+
type WheelEvent,
|
|
6
10
|
useCallback,
|
|
7
11
|
useMemo,
|
|
8
12
|
useRef,
|
|
9
13
|
useState,
|
|
10
|
-
type FocusEvent,
|
|
11
|
-
type KeyboardEvent,
|
|
12
|
-
type WheelEvent,
|
|
13
|
-
type MouseEvent,
|
|
14
14
|
} from 'react';
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
17
|
+
import { type CellRange, rangeToA1Notation } from '@dxos/compute';
|
|
18
|
+
import { Obj } from '@dxos/echo';
|
|
18
19
|
import { defaultColSize, defaultRowSize } from '@dxos/lit-grid';
|
|
19
20
|
import { DropdownMenu, Icon, useTranslation } from '@dxos/react-ui';
|
|
20
21
|
import { useAttention } from '@dxos/react-ui-attention';
|
|
21
22
|
import {
|
|
22
|
-
|
|
23
|
-
editorKeys,
|
|
24
|
-
parseCellIndex,
|
|
25
|
-
Grid,
|
|
26
|
-
GridCellEditor,
|
|
23
|
+
type DxGridCellIndex,
|
|
27
24
|
type DxGridElement,
|
|
28
25
|
type DxGridPosition,
|
|
29
|
-
type DxGridCellIndex,
|
|
30
|
-
type EditorKeyHandler,
|
|
31
26
|
type EditorBlurHandler,
|
|
27
|
+
type EditorKeyHandler,
|
|
28
|
+
Grid,
|
|
29
|
+
GridCellEditor,
|
|
32
30
|
type GridContentProps,
|
|
31
|
+
closestCell,
|
|
32
|
+
editorKeys,
|
|
33
|
+
parseCellIndex,
|
|
33
34
|
} from '@dxos/react-ui-grid';
|
|
34
35
|
|
|
35
|
-
import {
|
|
36
|
-
import { rangeExtension, sheetExtension, type RangeController } from '../../extensions';
|
|
36
|
+
import { type RangeController, rangeExtension, sheetExtension } from '../../extensions';
|
|
37
37
|
import { useSelectThreadOnCellFocus, useUpdateFocusedCellOnThreadSelection } from '../../integrations';
|
|
38
|
-
import {
|
|
39
|
-
import { DEFAULT_COLS, DEFAULT_ROWS,
|
|
38
|
+
import { meta } from '../../meta';
|
|
39
|
+
import { DEFAULT_COLS, DEFAULT_ROWS, SheetOperation } from '../../types';
|
|
40
40
|
import { useSheetContext } from '../SheetContext';
|
|
41
41
|
|
|
42
|
+
import { colLabelCell, rowLabelCell, useSheetModelDxGridProps } from './util';
|
|
43
|
+
|
|
42
44
|
const inertPosition: DxGridPosition = { plane: 'grid', col: 0, row: 0 };
|
|
43
45
|
|
|
44
46
|
const initialCells = {
|
|
@@ -59,24 +61,24 @@ const frozen = {
|
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
const sheetColDefault = {
|
|
62
|
-
frozenColsStart: { size: 48, readonly: true },
|
|
64
|
+
frozenColsStart: { size: 48, readonly: true, focusUnfurl: false },
|
|
63
65
|
grid: { size: defaultColSize, resizeable: true },
|
|
64
66
|
};
|
|
65
67
|
const sheetRowDefault = {
|
|
66
|
-
frozenRowsStart: { size: defaultRowSize, readonly: true },
|
|
68
|
+
frozenRowsStart: { size: defaultRowSize, readonly: true, focusUnfurl: false },
|
|
67
69
|
grid: { size: defaultRowSize, resizeable: true },
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
export const GridSheet = () => {
|
|
71
|
-
const { t } = useTranslation(
|
|
73
|
+
const { t } = useTranslation(meta.id);
|
|
72
74
|
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } =
|
|
73
75
|
useSheetContext();
|
|
74
76
|
// NOTE(thure): using `useState` instead of `useRef` works with refs provided by `@lit/react` and gives us
|
|
75
77
|
// a reliable dependency for `useEffect` whereas `useLayoutEffect` does not guarantee the element will be defined.
|
|
76
78
|
const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
|
|
77
79
|
const [extraplanarFocus, setExtraplanarFocus] = useState<DxGridPosition | null>(null);
|
|
78
|
-
const {
|
|
79
|
-
const rangeController = useRef<RangeController>();
|
|
80
|
+
const { invokePromise } = useOperationInvoker();
|
|
81
|
+
const rangeController = useRef<RangeController>(null);
|
|
80
82
|
const { hasAttention } = useAttention(id);
|
|
81
83
|
|
|
82
84
|
const handleFocus = useCallback(
|
|
@@ -126,15 +128,17 @@ export const GridSheet = () => {
|
|
|
126
128
|
|
|
127
129
|
const handleAxisResize = useCallback<NonNullable<GridContentProps['onAxisResize']>>(
|
|
128
130
|
({ axis, size, index: numericIndex }) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
Obj.change(model.sheet, (sheet) => {
|
|
132
|
+
if (axis === 'row') {
|
|
133
|
+
const rowId = sheet.rows[parseInt(numericIndex)];
|
|
134
|
+
sheet.rowMeta[rowId] ??= {};
|
|
135
|
+
sheet.rowMeta[rowId].size = size;
|
|
136
|
+
} else {
|
|
137
|
+
const columnId = sheet.columns[parseInt(numericIndex)];
|
|
138
|
+
sheet.columnMeta[columnId] ??= {};
|
|
139
|
+
sheet.columnMeta[columnId].size = size;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
138
142
|
},
|
|
139
143
|
[model],
|
|
140
144
|
);
|
|
@@ -171,12 +175,20 @@ export const GridSheet = () => {
|
|
|
171
175
|
case 'frozenRowsStart':
|
|
172
176
|
return dxGrid?.setSelection({
|
|
173
177
|
start: { col: pos.col, row: 0, plane: 'grid' },
|
|
174
|
-
end: {
|
|
178
|
+
end: {
|
|
179
|
+
col: pos.col,
|
|
180
|
+
row: model.sheet.rows.length - 1,
|
|
181
|
+
plane: 'grid',
|
|
182
|
+
},
|
|
175
183
|
});
|
|
176
184
|
case 'frozenColsStart':
|
|
177
185
|
return dxGrid?.setSelection({
|
|
178
186
|
start: { row: pos.row, col: 0, plane: 'grid' },
|
|
179
|
-
end: {
|
|
187
|
+
end: {
|
|
188
|
+
row: pos.row,
|
|
189
|
+
col: model.sheet.columns.length - 1,
|
|
190
|
+
plane: 'grid',
|
|
191
|
+
},
|
|
180
192
|
});
|
|
181
193
|
}
|
|
182
194
|
},
|
|
@@ -256,31 +268,30 @@ export const GridSheet = () => {
|
|
|
256
268
|
switch (operation) {
|
|
257
269
|
case 'insert-before':
|
|
258
270
|
case 'insert-after':
|
|
259
|
-
return
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}),
|
|
265
|
-
);
|
|
271
|
+
return invokePromise(SheetOperation.InsertAxis, {
|
|
272
|
+
model,
|
|
273
|
+
axis: contextMenuAxis,
|
|
274
|
+
index: contextMenuOpen![contextMenuAxis] + (operation === 'insert-before' ? 0 : 1),
|
|
275
|
+
});
|
|
266
276
|
case 'drop':
|
|
267
|
-
return
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}),
|
|
273
|
-
);
|
|
277
|
+
return invokePromise(SheetOperation.DropAxis, {
|
|
278
|
+
model,
|
|
279
|
+
axis: contextMenuAxis,
|
|
280
|
+
axisIndex: model.sheet[contextMenuAxis === 'row' ? 'rows' : 'columns'][contextMenuOpen![contextMenuAxis]],
|
|
281
|
+
});
|
|
274
282
|
}
|
|
275
283
|
},
|
|
276
|
-
[contextMenuAxis, contextMenuOpen, model,
|
|
284
|
+
[contextMenuAxis, contextMenuOpen, model, invokePromise],
|
|
277
285
|
);
|
|
278
286
|
|
|
279
287
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
280
288
|
|
|
281
|
-
const
|
|
289
|
+
const extensions = useMemo(
|
|
282
290
|
() => [
|
|
283
|
-
editorKeys({
|
|
291
|
+
editorKeys({
|
|
292
|
+
onClose: handleClose,
|
|
293
|
+
...(editing?.initialContent && { onNav: handleClose }),
|
|
294
|
+
}),
|
|
284
295
|
sheetExtension({ functions: model.graph.getFunctions() }),
|
|
285
296
|
rangeExtension({
|
|
286
297
|
onInit: (fn) => (rangeController.current = fn),
|
|
@@ -307,8 +318,8 @@ export const GridSheet = () => {
|
|
|
307
318
|
|
|
308
319
|
return (
|
|
309
320
|
// TODO(thure): Why are Table’s and Sheet’s editor boxes off by 1px?
|
|
310
|
-
<div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent
|
|
311
|
-
<GridCellEditor getCellContent={getCellContent}
|
|
321
|
+
<div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent'>
|
|
322
|
+
<GridCellEditor getCellContent={getCellContent} extensions={extensions} onBlur={handleBlur} />
|
|
312
323
|
<Grid.Content
|
|
313
324
|
initialCells={initialCells}
|
|
314
325
|
limitColumns={DEFAULT_COLS}
|
|
@@ -2,53 +2,51 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
8
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useMemo, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Client } from '@dxos/client';
|
|
11
|
-
import { createDocAccessor } from '@dxos/client/echo';
|
|
12
9
|
import { defaultFunctions } from '@dxos/compute';
|
|
13
10
|
import { getRegisteredFunctionNames } from '@dxos/compute/testing';
|
|
14
|
-
import {
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
13
|
+
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
15
|
import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
|
|
16
|
-
import {
|
|
16
|
+
import { automerge } from '@dxos/ui-editor';
|
|
17
17
|
|
|
18
18
|
import { sheetExtension } from '../../extensions';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
type StoryProps = CellEditorProps;
|
|
19
|
+
import { Sheet } from '../../types';
|
|
22
20
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
21
|
+
const DefaultStory = ({ value, ...props }: CellEditorProps) => {
|
|
22
|
+
const extensions = useMemo(() => {
|
|
25
23
|
const functionNames = getRegisteredFunctionNames();
|
|
26
24
|
const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
|
|
27
25
|
return [sheetExtension({ functions })];
|
|
28
26
|
}, []);
|
|
29
27
|
|
|
30
|
-
return <CellEditor {...props} value={value}
|
|
28
|
+
return <CellEditor {...props} value={value} extensions={extensions} />;
|
|
31
29
|
};
|
|
32
30
|
|
|
33
|
-
const AutomergeStory = ({ value, ...props }:
|
|
31
|
+
const AutomergeStory = ({ value, ...props }: CellEditorProps) => {
|
|
34
32
|
const cell = 'A1';
|
|
35
|
-
const [object, setObject] = useState<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
space.db.add(sheet);
|
|
47
|
-
setObject(sheet);
|
|
33
|
+
const [object, setObject] = useState<Sheet.Sheet>();
|
|
34
|
+
useAsyncEffect(async () => {
|
|
35
|
+
const client = new Client({ types: [Sheet.Sheet] });
|
|
36
|
+
await client.initialize();
|
|
37
|
+
await client.halo.createIdentity();
|
|
38
|
+
const space = await client.spaces.create();
|
|
39
|
+
|
|
40
|
+
const sheet = Sheet.make();
|
|
41
|
+
Obj.change(sheet, (obj) => {
|
|
42
|
+
obj.name = 'Test';
|
|
43
|
+
obj.cells[cell] = { value };
|
|
48
44
|
});
|
|
45
|
+
space.db.add(sheet);
|
|
46
|
+
setObject(sheet);
|
|
49
47
|
}, [value]);
|
|
50
48
|
|
|
51
|
-
const
|
|
49
|
+
const extensions = useMemo(() => {
|
|
52
50
|
if (!object) {
|
|
53
51
|
return [];
|
|
54
52
|
}
|
|
@@ -59,35 +57,38 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
|
|
|
59
57
|
return [automerge(accessor), sheetExtension({ functions })];
|
|
60
58
|
}, [object]);
|
|
61
59
|
|
|
62
|
-
return <CellEditor {...props} value={value}
|
|
60
|
+
return <CellEditor {...props} value={value} extensions={extensions} />;
|
|
63
61
|
};
|
|
64
62
|
|
|
65
|
-
|
|
63
|
+
const meta = {
|
|
64
|
+
title: 'plugins/plugin-sheet/CellEditor',
|
|
65
|
+
|
|
66
|
+
decorators: [withTheme()],
|
|
67
|
+
component: CellEditor,
|
|
68
|
+
render: DefaultStory,
|
|
69
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
70
|
+
|
|
71
|
+
export default meta;
|
|
72
|
+
|
|
73
|
+
type Story = StoryObj<typeof meta>;
|
|
66
74
|
|
|
67
|
-
export const
|
|
75
|
+
export const Default: Story = {};
|
|
76
|
+
|
|
77
|
+
export const AutoComplete: Story = {
|
|
68
78
|
args: {
|
|
69
79
|
value: '=SUM',
|
|
70
80
|
},
|
|
71
81
|
};
|
|
72
82
|
|
|
73
|
-
export const Formatting = {
|
|
83
|
+
export const Formatting: Story = {
|
|
74
84
|
args: {
|
|
75
85
|
value: '=SUM(A1:A2, 100, TRUE, "100", SUM(A1:A2, B1:B2))',
|
|
76
86
|
},
|
|
77
87
|
};
|
|
78
88
|
|
|
79
|
-
export const Automerge = {
|
|
80
|
-
render:
|
|
89
|
+
export const Automerge: Story = {
|
|
90
|
+
render: AutomergeStory,
|
|
81
91
|
args: {
|
|
82
92
|
value: '=SUM(A1:A2, 100, TRUE, "100", SUM(A1:A2, B1:B2))',
|
|
83
93
|
},
|
|
84
94
|
};
|
|
85
|
-
|
|
86
|
-
const meta: Meta = {
|
|
87
|
-
title: 'plugins/plugin-sheet/CellEditor',
|
|
88
|
-
component: CellEditor,
|
|
89
|
-
decorators: [withTheme],
|
|
90
|
-
render: (args: StoryProps) => <Story {...args} />,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default meta;
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { inRange } from '@dxos/compute';
|
|
8
|
-
import { createDocAccessor } from '@dxos/
|
|
9
|
-
import {
|
|
8
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
|
+
import { cellClassesForFieldType, parseValue } from '@dxos/react-ui-form';
|
|
10
10
|
import {
|
|
11
|
-
type GridContentProps,
|
|
12
|
-
type DxGridElement,
|
|
13
11
|
type DxGridAxisMeta,
|
|
12
|
+
type DxGridCellValue,
|
|
13
|
+
type DxGridElement,
|
|
14
14
|
type DxGridPlane,
|
|
15
|
-
type DxGridPlaneRange,
|
|
16
15
|
type DxGridPlaneCells,
|
|
17
|
-
type
|
|
16
|
+
type DxGridPlaneRange,
|
|
17
|
+
type GridContentProps,
|
|
18
18
|
colToA1Notation,
|
|
19
|
-
rowToA1Notation,
|
|
20
19
|
commentedClassName,
|
|
20
|
+
rowToA1Notation,
|
|
21
21
|
} from '@dxos/react-ui-grid';
|
|
22
|
-
import { mx } from '@dxos/
|
|
22
|
+
import { mx } from '@dxos/ui-theme';
|
|
23
23
|
|
|
24
24
|
import { type SheetModel } from '../../model';
|
|
25
25
|
import { cellClassNameForRange, rangeFromIndex } from '../../types';
|
|
@@ -28,7 +28,10 @@ const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
|
|
|
28
28
|
return model.sheet.columns.reduce(
|
|
29
29
|
(acc: DxGridAxisMeta, columnId, numericIndex) => {
|
|
30
30
|
if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
|
|
31
|
-
acc.grid[numericIndex] = {
|
|
31
|
+
acc.grid[numericIndex] = {
|
|
32
|
+
size: model.sheet.columnMeta[columnId].size,
|
|
33
|
+
resizeable: true,
|
|
34
|
+
};
|
|
32
35
|
}
|
|
33
36
|
return acc;
|
|
34
37
|
},
|
|
@@ -40,7 +43,10 @@ const createDxGridRows = (model: SheetModel): DxGridAxisMeta => {
|
|
|
40
43
|
return model.sheet.rows.reduce(
|
|
41
44
|
(acc: DxGridAxisMeta, rowId, numericIndex) => {
|
|
42
45
|
if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
|
|
43
|
-
acc.grid[numericIndex] = {
|
|
46
|
+
acc.grid[numericIndex] = {
|
|
47
|
+
size: model.sheet.rowMeta[rowId].size,
|
|
48
|
+
resizeable: true,
|
|
49
|
+
};
|
|
44
50
|
}
|
|
45
51
|
return acc;
|
|
46
52
|
},
|
|
@@ -59,7 +65,7 @@ const projectCellProps = (model: SheetModel, col: number, row: number): DxGridCe
|
|
|
59
65
|
// const range = thread.target?.anchor && parseThreadAnchorAsCellRange(thread.target!.anchor);
|
|
60
66
|
// return thread && range ? inRange(range, address) : false;
|
|
61
67
|
// })
|
|
62
|
-
// .map((thread) =>
|
|
68
|
+
// .map((thread) => Obj.getDXN(thread!).toString())
|
|
63
69
|
// .join(' ');
|
|
64
70
|
|
|
65
71
|
const description = model.getValueDescription(address);
|
|
@@ -2,30 +2,33 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
|
|
8
8
|
import { rangeToA1Notation } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
9
10
|
import { Callout, useTranslation } from '@dxos/react-ui';
|
|
10
11
|
import { List } from '@dxos/react-ui-list';
|
|
11
|
-
import { ghostHover } from '@dxos/
|
|
12
|
+
import { ghostHover } from '@dxos/ui-theme';
|
|
12
13
|
|
|
13
|
-
import {
|
|
14
|
+
import { meta } from '../../meta';
|
|
14
15
|
import { rangeFromIndex } from '../../types';
|
|
15
|
-
import {
|
|
16
|
+
import { Sheet } from '../../types';
|
|
16
17
|
|
|
17
18
|
export type RangeListProps = {
|
|
18
|
-
sheet:
|
|
19
|
+
sheet: Sheet.Sheet;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export const RangeList = ({ sheet }: RangeListProps) => {
|
|
22
|
-
const { t } = useTranslation(
|
|
23
|
+
const { t } = useTranslation(meta.id);
|
|
23
24
|
// TODO(thure): Implement similar to comments, #8121
|
|
24
|
-
const handleSelectRange = (range: Range) => {};
|
|
25
|
+
const handleSelectRange = (range: Sheet.Range) => {};
|
|
25
26
|
const handleDeleteRange = useCallback(
|
|
26
|
-
(range: Range) => {
|
|
27
|
+
(range: Sheet.Range) => {
|
|
27
28
|
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
28
|
-
|
|
29
|
+
Obj.change(sheet, (obj) => {
|
|
30
|
+
obj.ranges.splice(index, 1);
|
|
31
|
+
});
|
|
29
32
|
},
|
|
30
33
|
[sheet],
|
|
31
34
|
);
|
|
@@ -37,7 +40,7 @@ export const RangeList = ({ sheet }: RangeListProps) => {
|
|
|
37
40
|
<Callout.Title>{t('no ranges message')}</Callout.Title>
|
|
38
41
|
</Callout.Root>
|
|
39
42
|
) : (
|
|
40
|
-
<List.Root<Range> items={sheet.ranges} isItem={Schema.is(Range)}>
|
|
43
|
+
<List.Root<Sheet.Range> items={sheet.ranges} isItem={Schema.is(Sheet.Range)}>
|
|
41
44
|
{({ items: ranges }) =>
|
|
42
45
|
ranges.map((range, i) => (
|
|
43
46
|
<List.Item key={i} item={range} classNames={['p-2', ghostHover]}>
|