@dxos/plugin-sheet 0.8.4-main.c85a9c8dae → 0.8.4-main.dfabb4ec29
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/RangeList-S3SHV7T6.mjs → neutral/RangeList-HYB5S6KQ.mjs} +21 -28
- package/dist/lib/neutral/RangeList-HYB5S6KQ.mjs.map +7 -0
- package/dist/lib/neutral/SheetContainer-ZOVKGHLT.mjs +33 -0
- package/dist/lib/neutral/SheetContainer-ZOVKGHLT.mjs.map +7 -0
- package/dist/lib/neutral/SheetPlugin.mjs +48 -0
- package/dist/lib/neutral/SheetPlugin.mjs.map +7 -0
- package/dist/lib/neutral/SheetPlugin.node.mjs +27 -0
- package/dist/lib/neutral/SheetPlugin.node.mjs.map +7 -0
- package/dist/lib/{browser/anchor-sort-DZ3IHHJJ.mjs → neutral/anchor-sort-TTCKGX7V.mjs} +5 -7
- package/dist/lib/neutral/anchor-sort-TTCKGX7V.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +25 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4GWJDLTH.mjs +83 -0
- package/dist/lib/neutral/chunk-4GWJDLTH.mjs.map +7 -0
- package/dist/lib/{browser/chunk-NNWF7EKC.mjs → neutral/chunk-4SBAIU6F.mjs} +3 -3
- package/dist/lib/neutral/chunk-4SBAIU6F.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/{browser/chunk-S445OQGW.mjs → neutral/chunk-KC2SMDNF.mjs} +167 -191
- package/dist/lib/neutral/chunk-KC2SMDNF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YFHTB6MX.mjs +8 -0
- package/dist/lib/neutral/chunk-YFHTB6MX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZWOQCLH7.mjs +21 -0
- package/dist/lib/neutral/chunk-ZWOQCLH7.mjs.map +7 -0
- package/dist/lib/neutral/comment-config-ZBWNCJMZ.mjs +20 -0
- package/dist/lib/neutral/comment-config-ZBWNCJMZ.mjs.map +7 -0
- package/dist/lib/{browser/SheetContainer-I3NFVVDQ.mjs → neutral/components/index.mjs} +160 -414
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/{browser/compute-graph-registry-W6HO2G3P.mjs → neutral/compute-graph-registry-IEQBF5XZ.mjs} +5 -6
- package/dist/lib/neutral/compute-graph-registry-IEQBF5XZ.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-OKQAXJCW.mjs +27 -0
- package/dist/lib/neutral/create-object-OKQAXJCW.mjs.map +7 -0
- package/dist/lib/neutral/drop-axis-G6UOXG54.mjs +23 -0
- package/dist/lib/neutral/drop-axis-G6UOXG54.mjs.map +7 -0
- package/dist/lib/{browser/types → neutral}/index.mjs +14 -5
- package/dist/lib/neutral/insert-axis-ZFFNG22G.mjs +16 -0
- package/dist/lib/neutral/insert-axis-ZFFNG22G.mjs.map +7 -0
- package/dist/lib/{browser/markdown-S6GVLHB4.mjs → neutral/markdown-I2AKJYPF.mjs} +5 -6
- package/dist/lib/neutral/markdown-I2AKJYPF.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-TB6LFV2H.mjs +13 -0
- package/dist/lib/neutral/operation-handler-TB6LFV2H.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-surface-KIU6DGKW.mjs → neutral/react-surface-ID4JCAFR.mjs} +12 -19
- package/dist/lib/neutral/react-surface-ID4JCAFR.mjs.map +7 -0
- package/dist/lib/neutral/restore-axis-44DM6N54.mjs +16 -0
- package/dist/lib/neutral/restore-axis-44DM6N54.mjs.map +7 -0
- package/dist/lib/neutral/scroll-to-anchor-WHX3HJC7.mjs +33 -0
- package/dist/lib/neutral/scroll-to-anchor-WHX3HJC7.mjs.map +7 -0
- package/dist/lib/neutral/state-HPA27MX2.mjs +29 -0
- package/dist/lib/neutral/state-HPA27MX2.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +103 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +55 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/types/index.mjs +6 -6
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/undo-mappings-3FQLSTCZ.mjs +31 -0
- package/dist/lib/neutral/undo-mappings-3FQLSTCZ.mjs.map +7 -0
- package/dist/types/src/SheetPlugin.d.ts +1 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/SheetPlugin.node.d.ts +4 -0
- package/dist/types/src/SheetPlugin.node.d.ts.map +1 -0
- package/dist/types/src/SheetPlugin.test.d.ts +2 -0
- package/dist/types/src/SheetPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/comment-config.d.ts +12 -0
- package/dist/types/src/capabilities/comment-config.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +5 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +23 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/{compute-graph-registry/compute-graph-registry.d.ts → state.d.ts} +3 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +10 -4
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +4 -3
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -1
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts +77 -39
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContent/util.d.ts +1 -1
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -1
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts +5 -3
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -1
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +4 -3
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +5 -8
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +72 -68
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +2 -2
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +2 -2
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/containers/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/containers/RangeList/index.d.ts +1 -2
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -1
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +4 -4
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts +74 -38
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/containers/SheetContainer/index.d.ts +1 -2
- package/dist/types/src/containers/SheetContainer/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.map +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts +1 -3
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +2 -2
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +1 -1
- 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/operations/drop-axis.d.ts +5 -0
- package/dist/types/src/operations/drop-axis.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/insert-axis.d.ts +5 -0
- package/dist/types/src/operations/insert-axis.d.ts.map +1 -0
- package/dist/types/src/operations/restore-axis.d.ts +5 -0
- package/dist/types/src/operations/restore-axis.d.ts.map +1 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts +5 -0
- package/dist/types/src/operations/scroll-to-anchor.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.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 +1 -1
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +3 -3
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +74 -39
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +2 -2
- package/dist/types/src/types/Sheet.d.ts.map +1 -1
- package/dist/types/src/types/SheetCapabilities.d.ts +16 -0
- package/dist/types/src/types/SheetCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/SheetOperation.d.ts +45 -0
- package/dist/types/src/types/SheetOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +0 -92
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +1 -1
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +116 -73
- package/src/SheetPlugin.node.ts +21 -0
- package/src/SheetPlugin.test.ts +30 -0
- package/src/SheetPlugin.tsx +25 -35
- package/src/capabilities/{anchor-sort/anchor-sort.ts → anchor-sort.ts} +1 -1
- package/src/capabilities/comment-config.ts +24 -0
- package/src/capabilities/{compute-graph-registry/compute-graph-registry.ts → compute-graph-registry.ts} +4 -2
- package/src/capabilities/create-object.ts +30 -0
- package/src/capabilities/index.ts +17 -5
- package/src/capabilities/{markdown/markdown.ts → markdown.ts} +3 -2
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +12 -9
- package/src/capabilities/state.ts +29 -0
- package/src/capabilities/undo-mappings.ts +30 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +17 -14
- package/src/components/SheetContent/SheetCellEditor.stories.tsx +8 -7
- package/src/components/SheetContent/SheetContent.stories.tsx +10 -10
- package/src/components/SheetContent/SheetContent.tsx +40 -23
- package/src/components/SheetContent/util.ts +3 -2
- package/src/components/SheetRoot/SheetRoot.tsx +18 -7
- package/src/components/SheetStatusbar/SheetStatusbar.tsx +15 -8
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +1 -1
- package/src/components/SheetToolbar/SheetToolbar.tsx +15 -20
- package/src/components/SheetToolbar/align.ts +9 -9
- package/src/components/SheetToolbar/style.ts +7 -7
- package/src/containers/RangeList/RangeList.tsx +17 -17
- package/src/containers/RangeList/index.ts +1 -3
- package/src/containers/SheetContainer/SheetContainer.stories.tsx +36 -20
- package/src/containers/SheetContainer/SheetContainer.tsx +8 -8
- package/src/containers/SheetContainer/index.ts +1 -3
- package/src/extensions/compute.stories.tsx +9 -9
- package/src/extensions/compute.ts +1 -1
- package/src/extensions/editor/sheet-extension.test.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +2 -2
- package/src/index.ts +2 -2
- package/src/integrations/thread-ranges.ts +7 -39
- package/src/meta.ts +1 -1
- package/src/model/sheet-model.test.ts +5 -5
- package/src/model/sheet-model.ts +17 -17
- package/src/model/testing.ts +2 -2
- package/src/model/useSheetModel.ts +3 -2
- package/src/operations/drop-axis.ts +26 -0
- package/src/operations/index.ts +12 -0
- package/src/operations/insert-axis.ts +19 -0
- package/src/operations/restore-axis.ts +19 -0
- package/src/operations/scroll-to-anchor.ts +30 -0
- package/src/playwright/sheet.spec.ts +2 -2
- package/src/plugin.ts +11 -0
- package/src/sanity.test.ts +6 -3
- package/src/serializer.ts +2 -2
- package/src/testing/data.ts +1 -1
- package/src/testing/testing.tsx +4 -4
- package/src/translations.ts +41 -36
- package/src/types/Sheet.ts +15 -9
- package/src/types/SheetCapabilities.ts +26 -0
- package/src/types/SheetOperation.ts +75 -0
- package/src/types/index.ts +4 -2
- package/src/types/types.ts +0 -80
- package/src/types/util.ts +1 -1
- package/dist/lib/browser/RangeList-S3SHV7T6.mjs.map +0 -7
- package/dist/lib/browser/SheetContainer-I3NFVVDQ.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-DZ3IHHJJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-NNWF7EKC.mjs.map +0 -7
- package/dist/lib/browser/chunk-S445OQGW.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-W6HO2G3P.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -145
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/markdown-S6GVLHB4.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs +0 -79
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs.map +0 -7
- package/dist/lib/browser/react-surface-KIU6DGKW.mjs.map +0 -7
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs +0 -54
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs +0 -1806
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-M52YLLWU.mjs +0 -236
- package/dist/lib/node-esm/chunk-M52YLLWU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs +0 -398
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs +0 -22
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -146
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs +0 -30
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs +0 -80
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7FZAE3S7.mjs +0 -52
- package/dist/lib/node-esm/react-surface-7FZAE3S7.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +0 -3
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +0 -3
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
- package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -6
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/src/capabilities/anchor-sort/index.ts +0 -7
- package/src/capabilities/compute-graph-registry/index.ts +0 -7
- package/src/capabilities/markdown/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -77
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/types/capabilities.ts +0 -14
- /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
- /package/dist/types/src/capabilities/{anchor-sort/anchor-sort.d.ts → anchor-sort.d.ts} +0 -0
- /package/dist/types/src/capabilities/{markdown/markdown.d.ts → markdown.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
|
@@ -5,25 +5,26 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React, { useEffect, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { testFunctionPlugins } from '@dxos/compute-hyperformula/testing';
|
|
9
10
|
import { Filter } from '@dxos/echo';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { useSpaces } from '@dxos/react-client/echo';
|
|
12
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
14
|
import { Button, Input, Toolbar } from '@dxos/react-ui';
|
|
15
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
14
16
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
|
-
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { Sheet } from '../../types';
|
|
18
|
+
import { withComputeGraphDecorator } from '#testing';
|
|
19
|
+
import { Sheet } from '#types';
|
|
20
20
|
|
|
21
|
+
import { useSheetModel } from '../../model';
|
|
21
22
|
import { useComputeGraph } from './ComputeGraphContextProvider';
|
|
22
23
|
|
|
23
24
|
const FUNCTION_NAME = 'TEST';
|
|
24
25
|
|
|
25
26
|
const DefaultStory = () => {
|
|
26
|
-
const space =
|
|
27
|
+
const [space] = useSpaces();
|
|
27
28
|
const graph = useComputeGraph(space);
|
|
28
29
|
const [sheet, setSheet] = useState<Sheet.Sheet>();
|
|
29
30
|
const [text, setText] = useState(`${FUNCTION_NAME}(100)`);
|
|
@@ -44,14 +45,14 @@ const DefaultStory = () => {
|
|
|
44
45
|
setResult({ functions: { standard: f1.length, echo: f2.length } });
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
space.db.add(
|
|
48
|
+
space.db.add(Obj.make(Operation.PersistentOperation, { name: 'test', version: '0.0.1', binding: FUNCTION_NAME }));
|
|
48
49
|
}
|
|
49
50
|
}, [space, graph]);
|
|
50
51
|
|
|
51
52
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
52
53
|
const handleTest = async () => {
|
|
53
54
|
if (space && graph) {
|
|
54
|
-
const objects = await space.db.query(Filter.type(
|
|
55
|
+
const objects = await space.db.query(Filter.type(Operation.PersistentOperation)).run();
|
|
55
56
|
const mapped = graph.mapFunctionBindingToId(text);
|
|
56
57
|
const unmapped = graph.mapFunctionBindingFromId(mapped);
|
|
57
58
|
const internal = graph.mapFormulaToNative(text);
|
|
@@ -74,9 +75,7 @@ const DefaultStory = () => {
|
|
|
74
75
|
</Input.Root>
|
|
75
76
|
<Button onClick={handleTest}>Test</Button>
|
|
76
77
|
</Toolbar.Root>
|
|
77
|
-
<
|
|
78
|
-
{JSON.stringify({ space: space?.id, graph: graph?.id, sheet: sheet?.id, model: model?.id, result }, null, 2)}
|
|
79
|
-
</SyntaxHighlighter>
|
|
78
|
+
<JsonHighlighter data={{ space: space?.id, graph: graph?.id, sheet: sheet?.id, model: model?.id, result }} />
|
|
80
79
|
</div>
|
|
81
80
|
);
|
|
82
81
|
};
|
|
@@ -88,7 +87,11 @@ const meta = {
|
|
|
88
87
|
render: DefaultStory,
|
|
89
88
|
decorators: [
|
|
90
89
|
withTheme(),
|
|
91
|
-
withClientProvider({
|
|
90
|
+
withClientProvider({
|
|
91
|
+
types: [Operation.PersistentOperation, Sheet.Sheet],
|
|
92
|
+
createIdentity: true,
|
|
93
|
+
createSpace: true,
|
|
94
|
+
}),
|
|
92
95
|
withComputeGraphDecorator({ plugins: testFunctionPlugins }),
|
|
93
96
|
],
|
|
94
97
|
} satisfies Meta<typeof DefaultStory>;
|
|
@@ -6,17 +6,18 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import React, { useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Client } from '@dxos/client';
|
|
9
|
-
import { defaultFunctions } from '@dxos/compute';
|
|
10
|
-
import { getRegisteredFunctionNames } from '@dxos/compute/testing';
|
|
9
|
+
import { defaultFunctions } from '@dxos/compute-hyperformula';
|
|
10
|
+
import { getRegisteredFunctionNames } from '@dxos/compute-hyperformula/testing';
|
|
11
11
|
import { Obj } from '@dxos/echo';
|
|
12
12
|
import { createDocAccessor } from '@dxos/echo-db';
|
|
13
13
|
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
14
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
14
|
import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
|
|
15
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
16
|
import { automerge } from '@dxos/ui-editor';
|
|
17
17
|
|
|
18
|
+
import { Sheet } from '#types';
|
|
19
|
+
|
|
18
20
|
import { sheetExtension } from '../../extensions';
|
|
19
|
-
import { Sheet } from '../../types';
|
|
20
21
|
|
|
21
22
|
const DefaultStory = ({ value, ...props }: CellEditorProps) => {
|
|
22
23
|
const extensions = useMemo(() => {
|
|
@@ -38,9 +39,9 @@ const AutomergeStory = ({ value, ...props }: CellEditorProps) => {
|
|
|
38
39
|
const space = await client.spaces.create();
|
|
39
40
|
|
|
40
41
|
const sheet = Sheet.make();
|
|
41
|
-
Obj.
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
Obj.update(sheet, (sheet) => {
|
|
43
|
+
sheet.name = 'Test';
|
|
44
|
+
sheet.cells[cell] = { value };
|
|
44
45
|
});
|
|
45
46
|
space.db.add(sheet);
|
|
46
47
|
setObject(sheet);
|
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { OperationPlugin, RuntimePlugin } from '@dxos/app-framework';
|
|
8
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
-
import { testFunctionPlugins } from '@dxos/compute/testing';
|
|
10
|
-
import {
|
|
11
|
-
import { useSpace } from '@dxos/react-client/echo';
|
|
10
|
+
import { testFunctionPlugins } from '@dxos/compute-hyperformula/testing';
|
|
11
|
+
import { useSpaces } from '@dxos/react-client/echo';
|
|
12
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
13
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
14
14
|
|
|
15
|
-
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '
|
|
16
|
-
import { translations } from '
|
|
17
|
-
import { Sheet } from '
|
|
15
|
+
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '#testing';
|
|
16
|
+
import { translations } from '#translations';
|
|
17
|
+
import { Sheet } from '#types';
|
|
18
|
+
|
|
18
19
|
import { useComputeGraph } from '../ComputeGraph';
|
|
19
20
|
import { SheetRoot } from '../SheetRoot';
|
|
20
|
-
|
|
21
21
|
import { SheetContent } from './SheetContent';
|
|
22
22
|
|
|
23
23
|
export const Basic = () => {
|
|
24
|
-
const space =
|
|
24
|
+
const [space] = useSpaces();
|
|
25
25
|
const graph = useComputeGraph(space);
|
|
26
26
|
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
27
27
|
if (!sheet || !graph) {
|
|
@@ -29,8 +29,8 @@ export const Basic = () => {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
|
-
<SheetRoot graph={graph} sheet={sheet} ignoreAttention>
|
|
33
|
-
<div
|
|
32
|
+
<SheetRoot graph={graph} sheet={sheet} attendableId='test' ignoreAttention>
|
|
33
|
+
<div className='grid h-full w-full'>
|
|
34
34
|
<SheetContent />
|
|
35
35
|
</div>
|
|
36
36
|
</SheetRoot>
|
|
@@ -8,16 +8,17 @@ import React, {
|
|
|
8
8
|
type MouseEvent,
|
|
9
9
|
type WheelEvent,
|
|
10
10
|
useCallback,
|
|
11
|
+
useEffect,
|
|
11
12
|
useMemo,
|
|
12
13
|
useRef,
|
|
13
14
|
useState,
|
|
14
15
|
} from 'react';
|
|
15
16
|
|
|
16
|
-
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
17
|
-
import { type CellRange, rangeToA1Notation } from '@dxos/compute';
|
|
17
|
+
import { useCapabilities, useOperationInvoker } from '@dxos/app-framework/ui';
|
|
18
|
+
import { type CellRange, rangeToA1Notation } from '@dxos/compute-hyperformula';
|
|
18
19
|
import { Obj } from '@dxos/echo';
|
|
19
20
|
import { defaultColSize, defaultRowSize } from '@dxos/lit-grid';
|
|
20
|
-
import {
|
|
21
|
+
import { DropdownMenu, Icon, useTranslation } from '@dxos/react-ui';
|
|
21
22
|
import { useAttention } from '@dxos/react-ui-attention';
|
|
22
23
|
import {
|
|
23
24
|
type DxGridCellIndex,
|
|
@@ -32,14 +33,15 @@ import {
|
|
|
32
33
|
editorKeys,
|
|
33
34
|
parseCellIndex,
|
|
34
35
|
} from '@dxos/react-ui-grid';
|
|
35
|
-
import {
|
|
36
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
37
|
+
|
|
38
|
+
import { meta } from '#meta';
|
|
39
|
+
import { SheetOperation } from '#types';
|
|
40
|
+
import { DEFAULT_COLS, DEFAULT_ROWS, SheetCapabilities } from '#types';
|
|
36
41
|
|
|
37
42
|
import { type RangeController, rangeExtension, sheetExtension } from '../../extensions';
|
|
38
|
-
import { useSelectThreadOnCellFocus
|
|
39
|
-
import { meta } from '../../meta';
|
|
40
|
-
import { DEFAULT_COLS, DEFAULT_ROWS, SheetOperation } from '../../types';
|
|
43
|
+
import { useSelectThreadOnCellFocus } from '../../integrations';
|
|
41
44
|
import { useSheetContext } from '../SheetRoot';
|
|
42
|
-
|
|
43
45
|
import { colLabelCell, rowLabelCell, useSheetModelDxGridProps } from './util';
|
|
44
46
|
|
|
45
47
|
const inertPosition: DxGridPosition = { plane: 'grid', col: 0, row: 0 };
|
|
@@ -70,12 +72,23 @@ const sheetRowDefault = {
|
|
|
70
72
|
grid: { size: defaultRowSize, resizeable: true },
|
|
71
73
|
};
|
|
72
74
|
|
|
73
|
-
export type SheetContentProps =
|
|
75
|
+
export type SheetContentProps = {};
|
|
74
76
|
|
|
75
|
-
export const SheetContent = (props
|
|
77
|
+
export const SheetContent = composable<HTMLDivElement, SheetContentProps>((props, forwardedRef) => {
|
|
76
78
|
const { t } = useTranslation(meta.id);
|
|
77
|
-
const {
|
|
78
|
-
|
|
79
|
+
const {
|
|
80
|
+
id,
|
|
81
|
+
attendableId,
|
|
82
|
+
model,
|
|
83
|
+
editing,
|
|
84
|
+
setCursor,
|
|
85
|
+
setRange,
|
|
86
|
+
cursor,
|
|
87
|
+
cursorFallbackRange,
|
|
88
|
+
activeRefs,
|
|
89
|
+
setActiveRefs,
|
|
90
|
+
ignoreAttention,
|
|
91
|
+
} = useSheetContext();
|
|
79
92
|
|
|
80
93
|
// NOTE(thure): using `useState` instead of `useRef` works with refs provided by `@lit/react` and gives us
|
|
81
94
|
// a reliable dependency for `useEffect` whereas `useLayoutEffect` does not guarantee the element will be defined.
|
|
@@ -84,7 +97,6 @@ export const SheetContent = (props: SheetContentProps) => {
|
|
|
84
97
|
const { invokePromise } = useOperationInvoker();
|
|
85
98
|
const rangeController = useRef<RangeController>(null);
|
|
86
99
|
const { hasAttention } = useAttention(id);
|
|
87
|
-
const { className, ...rest } = useComposableProps(props);
|
|
88
100
|
|
|
89
101
|
const handleFocus = useCallback(
|
|
90
102
|
(event: FocusEvent) => {
|
|
@@ -133,7 +145,7 @@ export const SheetContent = (props: SheetContentProps) => {
|
|
|
133
145
|
|
|
134
146
|
const handleAxisResize = useCallback<NonNullable<GridContentProps['onAxisResize']>>(
|
|
135
147
|
({ axis, size, index: numericIndex }) => {
|
|
136
|
-
Obj.
|
|
148
|
+
Obj.update(model.sheet, (sheet) => {
|
|
137
149
|
if (axis === 'row') {
|
|
138
150
|
const rowId = sheet.rows[parseInt(numericIndex)];
|
|
139
151
|
sheet.rowMeta[rowId] ??= {};
|
|
@@ -318,11 +330,18 @@ export const SheetContent = (props: SheetContentProps) => {
|
|
|
318
330
|
[model],
|
|
319
331
|
);
|
|
320
332
|
|
|
321
|
-
|
|
333
|
+
const [gridInstances] = useCapabilities(SheetCapabilities.GridInstances);
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
if (dxGrid && gridInstances) {
|
|
336
|
+
gridInstances.register(attendableId, dxGrid, setActiveRefs);
|
|
337
|
+
return () => gridInstances.unregister(attendableId);
|
|
338
|
+
}
|
|
339
|
+
}, [dxGrid, gridInstances, attendableId, setActiveRefs]);
|
|
340
|
+
|
|
322
341
|
useSelectThreadOnCellFocus();
|
|
323
342
|
|
|
324
343
|
return (
|
|
325
|
-
<div {
|
|
344
|
+
<div ref={forwardedRef} {...composableProps(props, { classNames: 'relative min-h-0' })}>
|
|
326
345
|
<GridCellEditor getCellContent={getCellContent} extensions={extensions} onBlur={handleBlur} />
|
|
327
346
|
<Grid.Content
|
|
328
347
|
className='[--dx-grid-base:var(--base-surface)] [&_.dx-grid]:absolute [&_.dx-grid]:inset-0'
|
|
@@ -358,27 +377,25 @@ export const SheetContent = (props: SheetContentProps) => {
|
|
|
358
377
|
data-testid={`grid.${contextMenuAxis}.insert-before`}
|
|
359
378
|
>
|
|
360
379
|
<Icon
|
|
361
|
-
size={5}
|
|
362
380
|
icon={contextMenuAxis === 'col' ? 'ph--columns-plus-left--regular' : 'ph--rows-plus-top--regular'}
|
|
363
381
|
/>
|
|
364
|
-
<span>{t(`add
|
|
382
|
+
<span>{t(`add-${contextMenuAxis}-before.label`)}</span>
|
|
365
383
|
</DropdownMenu.Item>
|
|
366
384
|
<DropdownMenu.Item
|
|
367
385
|
onClick={() => handleAxisMenuAction('insert-after')}
|
|
368
386
|
data-testid={`grid.${contextMenuAxis}.insert-after`}
|
|
369
387
|
>
|
|
370
388
|
<Icon
|
|
371
|
-
size={5}
|
|
372
389
|
icon={contextMenuAxis === 'col' ? 'ph--columns-plus-right--regular' : 'ph--rows-plus-bottom--regular'}
|
|
373
390
|
/>
|
|
374
|
-
<span>{t(`add
|
|
391
|
+
<span>{t(`add-${contextMenuAxis}-after.label`)}</span>
|
|
375
392
|
</DropdownMenu.Item>
|
|
376
393
|
<DropdownMenu.Item
|
|
377
394
|
onClick={() => handleAxisMenuAction('drop')}
|
|
378
395
|
data-testid={`grid.${contextMenuAxis}.drop`}
|
|
379
396
|
>
|
|
380
|
-
<Icon
|
|
381
|
-
<span>{t(`delete
|
|
397
|
+
<Icon icon='ph--backspace--regular' />
|
|
398
|
+
<span>{t(`delete-${contextMenuAxis}.label`)}</span>
|
|
382
399
|
</DropdownMenu.Item>
|
|
383
400
|
</DropdownMenu.Viewport>
|
|
384
401
|
<DropdownMenu.Arrow />
|
|
@@ -386,4 +403,4 @@ export const SheetContent = (props: SheetContentProps) => {
|
|
|
386
403
|
</DropdownMenu.Root>
|
|
387
404
|
</div>
|
|
388
405
|
);
|
|
389
|
-
};
|
|
406
|
+
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { inRange } from '@dxos/compute';
|
|
7
|
+
import { inRange } from '@dxos/compute-hyperformula';
|
|
8
8
|
import { createDocAccessor } from '@dxos/echo-db';
|
|
9
9
|
import { cellClassesForFieldType, parseValue } from '@dxos/react-ui-form';
|
|
10
10
|
import {
|
|
@@ -21,8 +21,9 @@ import {
|
|
|
21
21
|
} from '@dxos/react-ui-grid';
|
|
22
22
|
import { mx } from '@dxos/ui-theme';
|
|
23
23
|
|
|
24
|
+
import { cellClassNameForRange, rangeFromIndex } from '#types';
|
|
25
|
+
|
|
24
26
|
import { type SheetModel } from '../../model';
|
|
25
|
-
import { cellClassNameForRange, rangeFromIndex } from '../../types';
|
|
26
27
|
|
|
27
28
|
const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
|
|
28
29
|
return model.sheet.columns.reduce(
|
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
type CellAddress,
|
|
9
|
+
type CellRange,
|
|
10
|
+
type CompleteCellRange,
|
|
11
|
+
type ComputeGraph,
|
|
12
|
+
} from '@dxos/compute-hyperformula';
|
|
8
13
|
import { raise } from '@dxos/debug';
|
|
9
|
-
import { Obj } from '@dxos/echo';
|
|
10
14
|
import {
|
|
11
15
|
Grid,
|
|
12
16
|
type GridContentProps,
|
|
@@ -15,12 +19,13 @@ import {
|
|
|
15
19
|
useGridContext,
|
|
16
20
|
} from '@dxos/react-ui-grid';
|
|
17
21
|
|
|
22
|
+
import { type Sheet } from '#types';
|
|
23
|
+
|
|
18
24
|
import { type SheetModel, useSheetModel } from '../../model';
|
|
19
|
-
import { type Sheet } from '../../types';
|
|
20
25
|
|
|
21
26
|
export type SheetContextValue = {
|
|
22
27
|
id: string;
|
|
23
|
-
|
|
28
|
+
attendableId: string;
|
|
24
29
|
model: SheetModel;
|
|
25
30
|
|
|
26
31
|
// Cursor state.
|
|
@@ -57,6 +62,7 @@ export const useSheetContext = (): SheetContextValue => {
|
|
|
57
62
|
export type SheetRootProps = {
|
|
58
63
|
graph: ComputeGraph;
|
|
59
64
|
sheet: Sheet.Sheet;
|
|
65
|
+
attendableId: string;
|
|
60
66
|
readonly?: boolean;
|
|
61
67
|
ignoreAttention?: boolean;
|
|
62
68
|
} & Pick<SheetContextValue, 'onInfo'>;
|
|
@@ -65,6 +71,7 @@ export const SheetRoot = ({
|
|
|
65
71
|
children,
|
|
66
72
|
graph,
|
|
67
73
|
sheet,
|
|
74
|
+
attendableId,
|
|
68
75
|
readonly,
|
|
69
76
|
ignoreAttention,
|
|
70
77
|
onInfo,
|
|
@@ -75,8 +82,8 @@ export const SheetRoot = ({
|
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
return (
|
|
78
|
-
<Grid.Root id={
|
|
79
|
-
<SheetProviderImpl model={model} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
85
|
+
<Grid.Root id={attendableId}>
|
|
86
|
+
<SheetProviderImpl model={model} attendableId={attendableId} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
80
87
|
{children}
|
|
81
88
|
</SheetProviderImpl>
|
|
82
89
|
</Grid.Root>
|
|
@@ -86,10 +93,13 @@ export const SheetRoot = ({
|
|
|
86
93
|
const SheetProviderImpl = ({
|
|
87
94
|
__gridScope,
|
|
88
95
|
children,
|
|
96
|
+
attendableId,
|
|
89
97
|
ignoreAttention,
|
|
90
98
|
model,
|
|
91
99
|
onInfo,
|
|
92
|
-
}: GridScopedProps<
|
|
100
|
+
}: GridScopedProps<
|
|
101
|
+
PropsWithChildren<Pick<SheetContextValue, 'attendableId' | 'ignoreAttention' | 'model' | 'onInfo'>>
|
|
102
|
+
>) => {
|
|
93
103
|
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
94
104
|
|
|
95
105
|
const [cursor, setCursorInternal] = useState<CellAddress>();
|
|
@@ -120,6 +130,7 @@ const SheetProviderImpl = ({
|
|
|
120
130
|
<SheetContext.Provider
|
|
121
131
|
value={{
|
|
122
132
|
id,
|
|
133
|
+
attendableId,
|
|
123
134
|
model,
|
|
124
135
|
editing,
|
|
125
136
|
setEditing,
|
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute';
|
|
8
|
-
import {
|
|
7
|
+
import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute-hyperformula';
|
|
8
|
+
import { Icon } from '@dxos/react-ui';
|
|
9
|
+
import { composable, composableProps, mx } from '@dxos/ui-theme';
|
|
10
|
+
|
|
11
|
+
import { mapFormulaIndicesToRefs } from '#types';
|
|
9
12
|
|
|
10
|
-
import { mapFormulaIndicesToRefs } from '../../types';
|
|
11
13
|
import { useSheetContext } from '../SheetRoot';
|
|
12
14
|
|
|
13
|
-
export type SheetStatusbarProps =
|
|
15
|
+
export type SheetStatusbarProps = {};
|
|
14
16
|
|
|
15
|
-
export const SheetStatusbar = (props
|
|
17
|
+
export const SheetStatusbar = composable<HTMLDivElement, SheetStatusbarProps>((props, forwardedRef) => {
|
|
18
|
+
const { className, ...rest } = composableProps(props);
|
|
16
19
|
const { model, cursor, range } = useSheetContext();
|
|
17
20
|
|
|
18
21
|
let value;
|
|
@@ -29,8 +32,12 @@ export const SheetStatusbar = (props: SheetStatusbarProps) => {
|
|
|
29
32
|
|
|
30
33
|
return (
|
|
31
34
|
<div
|
|
32
|
-
{
|
|
33
|
-
|
|
35
|
+
ref={forwardedRef}
|
|
36
|
+
{...rest}
|
|
37
|
+
className={mx(
|
|
38
|
+
'flex shrink-0 justify-between items-center px-4 py-1 text-sm bg-toolbar-surface border-y !border-subdued-separator',
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
34
41
|
>
|
|
35
42
|
<div className='flex gap-4 items-center'>
|
|
36
43
|
<div className='flex w-16 items-center font-mono'>
|
|
@@ -43,4 +50,4 @@ export const SheetStatusbar = (props: SheetStatusbarProps) => {
|
|
|
43
50
|
</div>
|
|
44
51
|
</div>
|
|
45
52
|
);
|
|
46
|
-
};
|
|
53
|
+
});
|
|
@@ -3,21 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Atom, type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { useContext, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
|
-
import { type CompleteCellRange } from '@dxos/compute';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
Menu,
|
|
13
|
-
type MenuRootProps,
|
|
14
|
-
createGapSeparator,
|
|
15
|
-
useMenuActions,
|
|
16
|
-
} from '@dxos/react-ui-menu';
|
|
9
|
+
import { type CompleteCellRange } from '@dxos/compute-hyperformula';
|
|
10
|
+
import { type ActionGraphProps, Menu, createGapSeparator, useMenuActions } from '@dxos/react-ui-menu';
|
|
11
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
17
12
|
|
|
18
13
|
import { type SheetModel } from '../../model';
|
|
19
14
|
import { useSheetContext } from '../SheetRoot';
|
|
20
|
-
|
|
21
15
|
import { createAlign, useAlignState } from './align';
|
|
22
16
|
import { createStyle, useStyleState } from './style';
|
|
23
17
|
import { type ToolbarStateAtom, useToolbarState } from './useToolbarState';
|
|
@@ -59,11 +53,10 @@ const createToolbarActions = ({
|
|
|
59
53
|
});
|
|
60
54
|
};
|
|
61
55
|
|
|
62
|
-
export type SheetToolbarProps = {
|
|
63
|
-
PropsWithChildren<{ id: string } & Partial<MenuRootProps>>;
|
|
56
|
+
export type SheetToolbarProps = {};
|
|
64
57
|
|
|
65
|
-
export const SheetToolbar =
|
|
66
|
-
const { model, cursorFallbackRange } = useSheetContext();
|
|
58
|
+
export const SheetToolbar = composable<HTMLDivElement, SheetToolbarProps>((props, forwardedRef) => {
|
|
59
|
+
const { attendableId, model, cursorFallbackRange } = useSheetContext();
|
|
67
60
|
const stateAtom = useToolbarState({});
|
|
68
61
|
const registry = useContext(RegistryContext);
|
|
69
62
|
useAlignState(stateAtom);
|
|
@@ -72,24 +65,26 @@ export const SheetToolbar = ({ id, ...props }: SheetToolbarProps) => {
|
|
|
72
65
|
const { graph } = useAppGraph();
|
|
73
66
|
const customActions = useMemo(() => {
|
|
74
67
|
return Atom.make((get) => {
|
|
75
|
-
const actions = get(graph.actions(
|
|
68
|
+
const actions = get(graph.actions(attendableId));
|
|
76
69
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
77
70
|
return {
|
|
78
71
|
nodes,
|
|
79
72
|
edges: nodes.map((node) => ({ source: 'root', target: node.id, relation: 'child' })),
|
|
80
73
|
};
|
|
81
74
|
});
|
|
82
|
-
}, [graph,
|
|
75
|
+
}, [graph, attendableId]);
|
|
83
76
|
|
|
84
77
|
const actionsCreator = useMemo(
|
|
85
78
|
() => createToolbarActions({ model, stateAtom, registry, cursorFallbackRange, customActions }),
|
|
86
79
|
[model, stateAtom, registry, cursorFallbackRange, customActions],
|
|
87
80
|
);
|
|
88
|
-
const
|
|
81
|
+
const menuActions = useMenuActions(actionsCreator);
|
|
89
82
|
|
|
90
83
|
return (
|
|
91
|
-
<Menu.Root {...
|
|
92
|
-
<Menu.Toolbar />
|
|
84
|
+
<Menu.Root {...menuActions} attendableId={attendableId}>
|
|
85
|
+
<Menu.Toolbar {...composableProps(props)} ref={forwardedRef} />
|
|
93
86
|
</Menu.Root>
|
|
94
87
|
);
|
|
95
|
-
};
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
SheetToolbar.displayName = 'SheetToolbar';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
6
|
import { useContext, useEffect } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
+
import { type CompleteCellRange, inRange } from '@dxos/compute-hyperformula';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
import {
|
|
11
11
|
type ActionGraphProps,
|
|
@@ -14,11 +14,11 @@ import {
|
|
|
14
14
|
createMenuItemGroup,
|
|
15
15
|
} from '@dxos/react-ui-menu';
|
|
16
16
|
|
|
17
|
-
import { meta } from '
|
|
17
|
+
import { meta } from '#meta';
|
|
18
|
+
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '#types';
|
|
19
|
+
|
|
18
20
|
import { type SheetModel } from '../../model';
|
|
19
|
-
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
20
21
|
import { useSheetContext } from '../SheetRoot';
|
|
21
|
-
|
|
22
22
|
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
23
23
|
|
|
24
24
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
@@ -50,7 +50,7 @@ export const useAlignState = (stateAtom: ToolbarStateAtom) => {
|
|
|
50
50
|
|
|
51
51
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
52
52
|
createMenuItemGroup('align', {
|
|
53
|
-
label: ['align
|
|
53
|
+
label: ['align.label', { ns: meta.id }],
|
|
54
54
|
variant: 'toggleGroup',
|
|
55
55
|
selectCardinality: 'single',
|
|
56
56
|
value: `${alignKey}--${value}`,
|
|
@@ -84,17 +84,17 @@ const createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackR
|
|
|
84
84
|
};
|
|
85
85
|
const currentState = registry.get(stateAtom);
|
|
86
86
|
if (index < 0) {
|
|
87
|
-
Obj.
|
|
87
|
+
Obj.update(model.sheet, (obj) => {
|
|
88
88
|
obj.ranges?.push(nextRangeEntity);
|
|
89
89
|
});
|
|
90
90
|
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
91
91
|
} else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
|
|
92
|
-
Obj.
|
|
92
|
+
Obj.update(model.sheet, (obj) => {
|
|
93
93
|
obj.ranges?.splice(index, 1);
|
|
94
94
|
});
|
|
95
95
|
registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
|
|
96
96
|
} else {
|
|
97
|
-
Obj.
|
|
97
|
+
Obj.update(model.sheet, (obj) => {
|
|
98
98
|
obj.ranges?.splice(index, 1, nextRangeEntity);
|
|
99
99
|
});
|
|
100
100
|
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
@@ -104,7 +104,7 @@ const createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackR
|
|
|
104
104
|
key: alignKey,
|
|
105
105
|
value: alignValue as AlignValue,
|
|
106
106
|
checked: state[alignKey] === alignValue,
|
|
107
|
-
label: [`range
|
|
107
|
+
label: [`range-value.${alignValue}.label`, { ns: meta.id }],
|
|
108
108
|
icon,
|
|
109
109
|
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
110
110
|
},
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
6
|
import { useContext, useEffect } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
+
import { type CompleteCellRange, inRange } from '@dxos/compute-hyperformula';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
import {
|
|
11
11
|
type ActionGraphProps,
|
|
@@ -14,11 +14,11 @@ import {
|
|
|
14
14
|
createMenuItemGroup,
|
|
15
15
|
} from '@dxos/react-ui-menu';
|
|
16
16
|
|
|
17
|
-
import { meta } from '
|
|
17
|
+
import { meta } from '#meta';
|
|
18
|
+
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '#types';
|
|
19
|
+
|
|
18
20
|
import { type SheetModel } from '../../model';
|
|
19
|
-
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
20
21
|
import { useSheetContext } from '../SheetRoot';
|
|
21
|
-
|
|
22
22
|
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
23
23
|
|
|
24
24
|
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
@@ -103,13 +103,13 @@ const createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackR
|
|
|
103
103
|
) {
|
|
104
104
|
// this value should be unset
|
|
105
105
|
if (index >= 0) {
|
|
106
|
-
Obj.
|
|
106
|
+
Obj.update(model.sheet, (obj) => {
|
|
107
107
|
obj.ranges?.splice(index, 1);
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: false });
|
|
111
111
|
} else {
|
|
112
|
-
Obj.
|
|
112
|
+
Obj.update(model.sheet, (obj) => {
|
|
113
113
|
obj.ranges?.push(nextRangeEntity);
|
|
114
114
|
});
|
|
115
115
|
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: true });
|
|
@@ -119,7 +119,7 @@ const createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackR
|
|
|
119
119
|
key: 'style',
|
|
120
120
|
value: styleValue as StyleValue,
|
|
121
121
|
icon,
|
|
122
|
-
label: [`range
|
|
122
|
+
label: [`range-value.${styleValue}.label`, { ns: meta.id }],
|
|
123
123
|
checked: !!state[styleValue as StyleValue],
|
|
124
124
|
},
|
|
125
125
|
);
|