@dxos/plugin-sheet 0.8.4-main.1da679c → 0.8.4-main.21d9917
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-ESCXPI7Y.mjs +397 -0
- package/dist/lib/browser/SheetContainer-ESCXPI7Y.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-JBRMW6OY.mjs +23 -0
- package/dist/lib/browser/anchor-sort-JBRMW6OY.mjs.map +7 -0
- package/dist/lib/browser/chunk-2SAGT3BB.mjs +397 -0
- package/dist/lib/browser/chunk-2SAGT3BB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SSN4HYJL.mjs → chunk-IFLWVS2V.mjs} +9 -9
- package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
- package/dist/lib/browser/chunk-W6N44ONZ.mjs +1470 -0
- package/dist/lib/browser/chunk-W6N44ONZ.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-DL2PX7TF.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-DL2PX7TF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +71 -82
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-BC4KBDUO.mjs +29 -0
- package/dist/lib/browser/markdown-BC4KBDUO.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-FJ4UWZUM.mjs +79 -0
- package/dist/lib/browser/operation-resolver-FJ4UWZUM.mjs.map +7 -0
- package/dist/lib/browser/react-surface-5BXM6TJ3.mjs +51 -0
- package/dist/lib/browser/react-surface-5BXM6TJ3.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/SheetContainer-YVIDJKP4.mjs +398 -0
- package/dist/lib/node-esm/SheetContainer-YVIDJKP4.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-C3XFPI6S.mjs +24 -0
- package/dist/lib/node-esm/anchor-sort-C3XFPI6S.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IMWGSIDG.mjs +398 -0
- package/dist/lib/node-esm/chunk-IMWGSIDG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IK4O7FUJ.mjs → chunk-PPOYR7DK.mjs} +9 -9
- package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-S7RYX7DG.mjs +1471 -0
- package/dist/lib/node-esm/chunk-S7RYX7DG.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-VXH55GDI.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-VXH55GDI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +71 -82
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-6DGZCJRM.mjs +30 -0
- package/dist/lib/node-esm/markdown-6DGZCJRM.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-OGXEUWHA.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-OGXEUWHA.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-RLHC6B77.mjs +52 -0
- package/dist/lib/node-esm/react-surface-RLHC6B77.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 +5 -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 -9
- 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/compute-graph.stories.d.ts +0 -1
- 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 +4 -3
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +2 -3
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +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 +8 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +2 -2
- 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 +3 -2
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +12 -19
- 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.stories.d.ts +2 -3
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -1
- 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/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 +3 -2
- 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 +9 -10
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +79 -72
- package/src/SheetPlugin.tsx +51 -64
- package/src/capabilities/anchor-sort/anchor-sort.ts +26 -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/compute-graph.stories.tsx +10 -12
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
- package/src/components/GridSheet/GridSheet.stories.tsx +14 -11
- package/src/components/GridSheet/GridSheet.tsx +32 -25
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +14 -12
- package/src/components/GridSheet/util.ts +11 -5
- package/src/components/RangeList/RangeList.tsx +13 -10
- package/src/components/SheetContainer/SheetContainer.stories.tsx +68 -47
- package/src/components/SheetContainer/SheetContainer.tsx +30 -18
- package/src/components/SheetContext/SheetContext.tsx +8 -8
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +9 -6
- package/src/components/SheetToolbar/SheetToolbar.tsx +39 -30
- package/src/components/SheetToolbar/align.ts +44 -19
- package/src/components/SheetToolbar/style.ts +47 -17
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/extensions/compute.stories.tsx +29 -17
- package/src/extensions/compute.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +7 -4
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +40 -49
- package/src/meta.ts +9 -7
- package/src/model/sheet-model.test.ts +4 -4
- package/src/model/sheet-model.ts +78 -48
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet.spec.ts +1 -0
- package/src/sanity.test.ts +3 -4
- package/src/serializer.ts +4 -4
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +11 -5
- package/src/translations.ts +3 -2
- package/src/types/Sheet.ts +106 -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 +83 -49
- package/src/types/util.ts +10 -38
- package/dist/lib/browser/SheetContainer-OUN6AARA.mjs +0 -350
- package/dist/lib/browser/SheetContainer-OUN6AARA.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-CAYLDDRF.mjs +0 -24
- package/dist/lib/browser/anchor-sort-CAYLDDRF.mjs.map +0 -7
- package/dist/lib/browser/chunk-6AKBCBL4.mjs +0 -18
- package/dist/lib/browser/chunk-6AKBCBL4.mjs.map +0 -7
- package/dist/lib/browser/chunk-KJWZUQVA.mjs +0 -15
- package/dist/lib/browser/chunk-KJWZUQVA.mjs.map +0 -7
- package/dist/lib/browser/chunk-SSN4HYJL.mjs.map +0 -7
- package/dist/lib/browser/chunk-X4EWLDT3.mjs +0 -851
- package/dist/lib/browser/chunk-X4EWLDT3.mjs.map +0 -7
- package/dist/lib/browser/chunk-XSXUU6FO.mjs +0 -906
- package/dist/lib/browser/chunk-XSXUU6FO.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-WHF3BJTJ.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-WHF3BJTJ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-LKZXAJRJ.mjs +0 -56
- package/dist/lib/browser/intent-resolver-LKZXAJRJ.mjs.map +0 -7
- package/dist/lib/browser/markdown-XKFA4Z2M.mjs +0 -26
- package/dist/lib/browser/markdown-XKFA4Z2M.mjs.map +0 -7
- package/dist/lib/browser/react-surface-N6NYHHT3.mjs +0 -53
- package/dist/lib/browser/react-surface-N6NYHHT3.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-NFLLTGNV.mjs +0 -351
- package/dist/lib/node-esm/SheetContainer-NFLLTGNV.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-4R2ID6GE.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-4R2ID6GE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3K5VNYOF.mjs +0 -20
- package/dist/lib/node-esm/chunk-3K5VNYOF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs +0 -16
- package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IK4O7FUJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ODP4L4OV.mjs +0 -907
- package/dist/lib/node-esm/chunk-ODP4L4OV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PYF4ZJXN.mjs +0 -852
- package/dist/lib/node-esm/chunk-PYF4ZJXN.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-3IUZXRXJ.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-3IUZXRXJ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-JHH6ZVJ4.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-JHH6ZVJ4.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-NOKROLCG.mjs +0 -27
- package/dist/lib/node-esm/markdown-NOKROLCG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TYBS4DOF.mjs +0 -54
- package/dist/lib/node-esm/react-surface-TYBS4DOF.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 -4
- 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/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 -23
- package/src/capabilities/react-surface.tsx +0 -40
- package/src/types/schema.ts +0 -61
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type CellAddress, type CellRange, type CompleteCellRange, type ComputeGraph } from '@dxos/compute';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
8
9
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
10
10
|
import {
|
|
11
11
|
Grid,
|
|
12
12
|
type GridContentProps,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '@dxos/react-ui-grid';
|
|
17
17
|
|
|
18
18
|
import { type SheetModel, useSheetModel } from '../../model';
|
|
19
|
-
import { type
|
|
19
|
+
import { type Sheet } from '../../types';
|
|
20
20
|
|
|
21
21
|
export type SheetContextValue = {
|
|
22
22
|
id: string;
|
|
@@ -56,12 +56,12 @@ export const useSheetContext = (): SheetContextValue => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
const SheetProviderImpl = ({
|
|
59
|
+
__gridScope,
|
|
60
|
+
children,
|
|
61
|
+
ignoreAttention,
|
|
59
62
|
model,
|
|
60
63
|
onInfo,
|
|
61
|
-
|
|
62
|
-
children,
|
|
63
|
-
__gridScope,
|
|
64
|
-
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'onInfo' | 'model' | 'ignoreAttention'>>>) => {
|
|
64
|
+
}: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'ignoreAttention' | 'model' | 'onInfo'>>>) => {
|
|
65
65
|
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
66
66
|
|
|
67
67
|
const [cursor, setCursorInternal] = useState<CellAddress>();
|
|
@@ -114,7 +114,7 @@ const SheetProviderImpl = ({
|
|
|
114
114
|
|
|
115
115
|
export type SheetProviderProps = {
|
|
116
116
|
graph: ComputeGraph;
|
|
117
|
-
sheet:
|
|
117
|
+
sheet: Sheet.Sheet;
|
|
118
118
|
readonly?: boolean;
|
|
119
119
|
ignoreAttention?: boolean;
|
|
120
120
|
} & Pick<SheetContextValue, 'onInfo'>;
|
|
@@ -130,7 +130,7 @@ export const SheetProvider = ({
|
|
|
130
130
|
const model = useSheetModel(graph, sheet, { readonly });
|
|
131
131
|
|
|
132
132
|
return !model ? null : (
|
|
133
|
-
<Grid.Root id={
|
|
133
|
+
<Grid.Root id={Obj.getDXN(sheet).toString()}>
|
|
134
134
|
<SheetProviderImpl model={model} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
135
135
|
{children}
|
|
136
136
|
</SheetProviderImpl>
|
|
@@ -2,27 +2,30 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
10
|
import { translations } from '../../translations';
|
|
13
11
|
|
|
14
12
|
import { SheetToolbar } from './SheetToolbar';
|
|
15
13
|
|
|
16
14
|
const DefaultStory = () => {
|
|
17
|
-
|
|
15
|
+
// TODO(wittjosiah): Depends on SheetProvider.
|
|
16
|
+
// return <SheetToolbar id='test' />;
|
|
17
|
+
return <>TODO</>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const meta = {
|
|
21
21
|
title: 'plugins/plugin-sheet/Toolbar',
|
|
22
22
|
component: SheetToolbar as any,
|
|
23
23
|
render: DefaultStory,
|
|
24
|
-
decorators: [withTheme
|
|
25
|
-
parameters: {
|
|
24
|
+
decorators: [withTheme],
|
|
25
|
+
parameters: {
|
|
26
|
+
layout: 'fullscreen',
|
|
27
|
+
translations,
|
|
28
|
+
},
|
|
26
29
|
} satisfies Meta<typeof DefaultStory>;
|
|
27
30
|
|
|
28
31
|
export default meta;
|
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import React, { type PropsWithChildren, useMemo } from 'react';
|
|
5
|
+
import { Atom, type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { type PropsWithChildren, useContext, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useAppGraph } from '@dxos/app-framework';
|
|
8
|
+
import { useAppGraph } from '@dxos/app-framework/react';
|
|
9
9
|
import { type CompleteCellRange } from '@dxos/compute';
|
|
10
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
10
|
import {
|
|
12
11
|
type ActionGraphProps,
|
|
13
12
|
MenuProvider,
|
|
14
13
|
ToolbarMenu,
|
|
15
14
|
createGapSeparator,
|
|
16
|
-
rxFromSignal,
|
|
17
15
|
useMenuActions,
|
|
18
16
|
} from '@dxos/react-ui-menu';
|
|
19
17
|
|
|
@@ -22,23 +20,28 @@ import { useSheetContext } from '../SheetContext';
|
|
|
22
20
|
|
|
23
21
|
import { createAlign, useAlignState } from './align';
|
|
24
22
|
import { createStyle, useStyleState } from './style';
|
|
25
|
-
import { type
|
|
23
|
+
import { type ToolbarStateAtom, useToolbarState } from './useToolbarState';
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
type ToolbarActionsContext = {
|
|
26
|
+
model: SheetModel;
|
|
27
|
+
stateAtom: ToolbarStateAtom;
|
|
28
|
+
registry: Registry.Registry;
|
|
29
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
30
|
+
customActions?: Atom.Atom<ActionGraphProps>;
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
const createToolbarActions = (
|
|
34
|
-
model
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
33
|
+
const createToolbarActions = ({
|
|
34
|
+
model,
|
|
35
|
+
stateAtom,
|
|
36
|
+
registry,
|
|
37
|
+
cursorFallbackRange,
|
|
38
|
+
customActions,
|
|
39
|
+
}: ToolbarActionsContext): Atom.Atom<ActionGraphProps> => {
|
|
40
|
+
return Atom.make((get) => {
|
|
41
|
+
const state = get(stateAtom);
|
|
42
|
+
const context = { model, state, stateAtom, registry, cursorFallbackRange };
|
|
43
|
+
const align = createAlign(context);
|
|
44
|
+
const style = createStyle(context);
|
|
42
45
|
const gap = createGapSeparator();
|
|
43
46
|
|
|
44
47
|
const graph: ActionGraphProps = {
|
|
@@ -56,30 +59,36 @@ const createToolbarActions = (
|
|
|
56
59
|
});
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
export
|
|
62
|
+
export type SheetToolbarProps = PropsWithChildren<{ id: string }>;
|
|
63
|
+
|
|
64
|
+
export const SheetToolbar = ({ id }: SheetToolbarProps) => {
|
|
60
65
|
const { model, cursorFallbackRange } = useSheetContext();
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
const stateAtom = useToolbarState({});
|
|
67
|
+
const registry = useContext(RegistryContext);
|
|
68
|
+
useAlignState(stateAtom);
|
|
69
|
+
useStyleState(stateAtom);
|
|
64
70
|
|
|
65
71
|
const { graph } = useAppGraph();
|
|
66
72
|
const customActions = useMemo(() => {
|
|
67
|
-
return
|
|
73
|
+
return Atom.make((get) => {
|
|
68
74
|
const actions = get(graph.actions(id));
|
|
69
75
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
70
|
-
return {
|
|
76
|
+
return {
|
|
77
|
+
nodes,
|
|
78
|
+
edges: nodes.map((node) => ({ source: 'root', target: node.id })),
|
|
79
|
+
};
|
|
71
80
|
});
|
|
72
|
-
}, [graph]);
|
|
81
|
+
}, [graph, id]);
|
|
73
82
|
|
|
74
83
|
const actionsCreator = useMemo(
|
|
75
|
-
() => createToolbarActions(model,
|
|
76
|
-
[model,
|
|
84
|
+
() => createToolbarActions({ model, stateAtom, registry, cursorFallbackRange, customActions }),
|
|
85
|
+
[model, stateAtom, registry, cursorFallbackRange, customActions],
|
|
77
86
|
);
|
|
78
87
|
const menu = useMenuActions(actionsCreator);
|
|
79
88
|
|
|
80
89
|
return (
|
|
81
90
|
<MenuProvider {...menu} attendableId={id}>
|
|
82
|
-
<ToolbarMenu
|
|
91
|
+
<ToolbarMenu />
|
|
83
92
|
</MenuProvider>
|
|
84
93
|
);
|
|
85
94
|
};
|
|
@@ -2,17 +2,24 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import { useContext, useEffect } from 'react';
|
|
6
7
|
|
|
7
8
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import {
|
|
11
|
+
type ActionGraphProps,
|
|
12
|
+
type ToolbarMenuActionGroupProperties,
|
|
13
|
+
createMenuAction,
|
|
14
|
+
createMenuItemGroup,
|
|
15
|
+
} from '@dxos/react-ui-menu';
|
|
9
16
|
|
|
10
|
-
import {
|
|
17
|
+
import { meta } from '../../meta';
|
|
11
18
|
import { type SheetModel } from '../../model';
|
|
12
19
|
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
13
20
|
import { useSheetContext } from '../SheetContext';
|
|
14
21
|
|
|
15
|
-
import { type ToolbarState } from './useToolbarState';
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
16
23
|
|
|
17
24
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
18
25
|
|
|
@@ -24,29 +31,40 @@ const aligns: Record<AlignValue, string> = {
|
|
|
24
31
|
end: 'ph--text-align-right--regular',
|
|
25
32
|
};
|
|
26
33
|
|
|
27
|
-
export const useAlignState = (
|
|
34
|
+
export const useAlignState = (stateAtom: ToolbarStateAtom) => {
|
|
35
|
+
const registry = useContext(RegistryContext);
|
|
28
36
|
const { cursor, model } = useSheetContext();
|
|
29
37
|
useEffect(() => {
|
|
30
38
|
// TODO(thure): Can this O(n) call be memoized?
|
|
31
|
-
|
|
39
|
+
const alignValue = (
|
|
32
40
|
cursor
|
|
33
41
|
? model.sheet.ranges?.findLast(
|
|
34
42
|
({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
35
43
|
)?.value
|
|
36
44
|
: undefined
|
|
37
45
|
) as AlignValue | undefined;
|
|
38
|
-
|
|
46
|
+
const prev = registry.get(stateAtom);
|
|
47
|
+
registry.set(stateAtom, { ...prev, [alignKey]: alignValue });
|
|
48
|
+
}, [cursor, model.sheet, registry, stateAtom]);
|
|
39
49
|
};
|
|
40
50
|
|
|
41
51
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
42
52
|
createMenuItemGroup('align', {
|
|
43
|
-
label: ['align label', { ns:
|
|
53
|
+
label: ['align label', { ns: meta.id }],
|
|
44
54
|
variant: 'toggleGroup',
|
|
45
55
|
selectCardinality: 'single',
|
|
46
56
|
value: `${alignKey}--${value}`,
|
|
47
57
|
} as ToolbarMenuActionGroupProperties);
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
type AlignActionsContext = {
|
|
60
|
+
model: SheetModel;
|
|
61
|
+
state: ToolbarState;
|
|
62
|
+
stateAtom: ToolbarStateAtom;
|
|
63
|
+
registry: Registry.Registry;
|
|
64
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: AlignActionsContext) =>
|
|
50
68
|
Object.entries(aligns).map(([alignValue, icon]) => {
|
|
51
69
|
return createMenuAction<AlignAction>(
|
|
52
70
|
`${alignKey}--${alignValue}`,
|
|
@@ -64,31 +82,38 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
64
82
|
key: alignKey,
|
|
65
83
|
value: alignValue as AlignValue,
|
|
66
84
|
};
|
|
85
|
+
const currentState = registry.get(stateAtom);
|
|
67
86
|
if (index < 0) {
|
|
68
|
-
model.sheet
|
|
69
|
-
|
|
87
|
+
Obj.change(model.sheet, (s) => {
|
|
88
|
+
s.ranges?.push(nextRangeEntity);
|
|
89
|
+
});
|
|
90
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
70
91
|
} else if (model.sheet.ranges![index].value === nextRangeEntity.value) {
|
|
71
|
-
model.sheet
|
|
72
|
-
|
|
92
|
+
Obj.change(model.sheet, (s) => {
|
|
93
|
+
s.ranges?.splice(index, 1);
|
|
94
|
+
});
|
|
95
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
|
|
73
96
|
} else {
|
|
74
|
-
model.sheet
|
|
75
|
-
|
|
97
|
+
Obj.change(model.sheet, (s) => {
|
|
98
|
+
s.ranges?.splice(index, 1, nextRangeEntity);
|
|
99
|
+
});
|
|
100
|
+
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
76
101
|
}
|
|
77
102
|
},
|
|
78
103
|
{
|
|
79
104
|
key: alignKey,
|
|
80
105
|
value: alignValue as AlignValue,
|
|
81
106
|
checked: state[alignKey] === alignValue,
|
|
82
|
-
label: [`range value ${alignValue} label`, { ns:
|
|
107
|
+
label: [`range value ${alignValue} label`, { ns: meta.id }],
|
|
83
108
|
icon,
|
|
84
109
|
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
85
110
|
},
|
|
86
111
|
);
|
|
87
112
|
});
|
|
88
113
|
|
|
89
|
-
export const createAlign = (
|
|
90
|
-
const alignGroup = createAlignGroupAction(state[alignKey]);
|
|
91
|
-
const alignActions = createAlignActions(
|
|
114
|
+
export const createAlign = (context: AlignActionsContext): ActionGraphProps => {
|
|
115
|
+
const alignGroup = createAlignGroupAction(context.state[alignKey]);
|
|
116
|
+
const alignActions = createAlignActions(context);
|
|
92
117
|
return {
|
|
93
118
|
nodes: [alignGroup, ...alignActions],
|
|
94
119
|
edges: [
|
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import { useContext, useEffect } from 'react';
|
|
6
7
|
|
|
7
8
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import {
|
|
11
|
+
type ActionGraphProps,
|
|
12
|
+
type ToolbarMenuActionGroupProperties,
|
|
13
|
+
createMenuAction,
|
|
14
|
+
createMenuItemGroup,
|
|
15
|
+
} from '@dxos/react-ui-menu';
|
|
9
16
|
|
|
10
|
-
import {
|
|
17
|
+
import { meta } from '../../meta';
|
|
11
18
|
import { type SheetModel } from '../../model';
|
|
12
19
|
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
13
20
|
import { useSheetContext } from '../SheetContext';
|
|
14
21
|
|
|
22
|
+
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
23
|
+
|
|
15
24
|
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
16
25
|
|
|
17
26
|
export type StyleAction = { key: StyleKey; value: StyleValue };
|
|
@@ -21,22 +30,30 @@ const styles: Record<StyleValue, string> = {
|
|
|
21
30
|
softwrap: 'ph--paragraph--regular',
|
|
22
31
|
};
|
|
23
32
|
|
|
24
|
-
export const useStyleState = (
|
|
33
|
+
export const useStyleState = (stateAtom: ToolbarStateAtom) => {
|
|
34
|
+
const registry = useContext(RegistryContext);
|
|
25
35
|
const { cursorFallbackRange, model } = useSheetContext();
|
|
26
36
|
|
|
27
37
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
let highlight = false;
|
|
39
|
+
let softwrap = false;
|
|
30
40
|
if (cursorFallbackRange && model.sheet.ranges) {
|
|
31
41
|
model.sheet.ranges
|
|
32
42
|
.filter(
|
|
33
43
|
({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
|
|
34
44
|
)
|
|
35
45
|
.forEach(({ value }) => {
|
|
36
|
-
|
|
46
|
+
if (value === 'highlight') {
|
|
47
|
+
highlight = true;
|
|
48
|
+
}
|
|
49
|
+
if (value === 'softwrap') {
|
|
50
|
+
softwrap = true;
|
|
51
|
+
}
|
|
37
52
|
});
|
|
38
53
|
}
|
|
39
|
-
|
|
54
|
+
const prev = registry.get(stateAtom);
|
|
55
|
+
registry.set(stateAtom, { ...prev, highlight, softwrap });
|
|
56
|
+
}, [cursorFallbackRange, model.sheet, registry, stateAtom]);
|
|
40
57
|
};
|
|
41
58
|
|
|
42
59
|
const createStyleGroup = (state: StyleState) => {
|
|
@@ -49,7 +66,15 @@ const createStyleGroup = (state: StyleState) => {
|
|
|
49
66
|
} as ToolbarMenuActionGroupProperties);
|
|
50
67
|
};
|
|
51
68
|
|
|
52
|
-
|
|
69
|
+
type StyleActionsContext = {
|
|
70
|
+
model: SheetModel;
|
|
71
|
+
state: ToolbarState;
|
|
72
|
+
stateAtom: ToolbarStateAtom;
|
|
73
|
+
registry: Registry.Registry;
|
|
74
|
+
cursorFallbackRange?: CompleteCellRange;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackRange }: StyleActionsContext) =>
|
|
53
78
|
Object.entries(styles).map(([styleValue, icon]) => {
|
|
54
79
|
return createMenuAction<StyleAction>(
|
|
55
80
|
`style--${styleValue}`,
|
|
@@ -67,6 +92,7 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
67
92
|
key: 'style',
|
|
68
93
|
value: styleValue as StyleValue,
|
|
69
94
|
};
|
|
95
|
+
const currentState = registry.get(stateAtom);
|
|
70
96
|
if (
|
|
71
97
|
model.sheet.ranges
|
|
72
98
|
.filter(
|
|
@@ -77,27 +103,31 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
77
103
|
) {
|
|
78
104
|
// this value should be unset
|
|
79
105
|
if (index >= 0) {
|
|
80
|
-
model.sheet
|
|
106
|
+
Obj.change(model.sheet, (s) => {
|
|
107
|
+
s.ranges?.splice(index, 1);
|
|
108
|
+
});
|
|
81
109
|
}
|
|
82
|
-
|
|
110
|
+
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: false });
|
|
83
111
|
} else {
|
|
84
|
-
model.sheet
|
|
85
|
-
|
|
112
|
+
Obj.change(model.sheet, (s) => {
|
|
113
|
+
s.ranges?.push(nextRangeEntity);
|
|
114
|
+
});
|
|
115
|
+
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: true });
|
|
86
116
|
}
|
|
87
117
|
},
|
|
88
118
|
{
|
|
89
119
|
key: 'style',
|
|
90
120
|
value: styleValue as StyleValue,
|
|
91
121
|
icon,
|
|
92
|
-
label: [`range value ${styleValue} label`, { ns:
|
|
122
|
+
label: [`range value ${styleValue} label`, { ns: meta.id }],
|
|
93
123
|
checked: !!state[styleValue as StyleValue],
|
|
94
124
|
},
|
|
95
125
|
);
|
|
96
126
|
});
|
|
97
127
|
|
|
98
|
-
export const createStyle = (
|
|
99
|
-
const styleGroupAction = createStyleGroup(state);
|
|
100
|
-
const styleActions = createStyleActions(
|
|
128
|
+
export const createStyle = (context: StyleActionsContext): ActionGraphProps => {
|
|
129
|
+
const styleGroupAction = createStyleGroup(context.state);
|
|
130
|
+
const styleActions = createStyleActions(context);
|
|
101
131
|
return {
|
|
102
132
|
nodes: [styleGroupAction, ...styleActions],
|
|
103
133
|
edges: [
|
|
@@ -2,15 +2,32 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { live } from '@dxos/live-object';
|
|
5
|
+
import { Atom, type Registry, RegistryContext, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import { useContext, useMemo } from 'react';
|
|
8
7
|
|
|
9
8
|
import { type AlignState } from './align';
|
|
10
9
|
import { type StyleState } from './style';
|
|
11
10
|
|
|
12
11
|
export type ToolbarState = Partial<StyleState & AlignState>;
|
|
12
|
+
export type ToolbarStateAtom = Atom.Writable<ToolbarState>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a reactive toolbar state Atom.
|
|
16
|
+
*/
|
|
17
|
+
export const useToolbarState = (initialState: ToolbarState = {}): ToolbarStateAtom => {
|
|
18
|
+
return useMemo(() => Atom.make<ToolbarState>(initialState).pipe(Atom.keepAlive), []);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook to read the current toolbar state value.
|
|
23
|
+
*/
|
|
24
|
+
export const useToolbarStateValue = (stateAtom: ToolbarStateAtom): ToolbarState => {
|
|
25
|
+
return useAtomValue(stateAtom);
|
|
26
|
+
};
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Hook to get the registry for updating toolbar state.
|
|
30
|
+
*/
|
|
31
|
+
export const useToolbarStateRegistry = (): Registry.Registry => {
|
|
32
|
+
return useContext(RegistryContext);
|
|
16
33
|
};
|
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useMemo } from 'react';
|
|
9
7
|
|
|
8
|
+
import { OperationPlugin, RuntimePlugin } from '@dxos/app-framework';
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
10
|
import { PublicKey } from '@dxos/keys';
|
|
11
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
12
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
13
|
import { useThemeContext } from '@dxos/react-ui';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
|
+
import { useTextEditor } from '@dxos/react-ui-editor';
|
|
14
16
|
import {
|
|
15
17
|
createBasicExtensions,
|
|
16
18
|
createMarkdownExtensions,
|
|
17
19
|
createThemeExtensions,
|
|
18
20
|
decorateMarkdown,
|
|
19
21
|
documentId,
|
|
20
|
-
|
|
21
|
-
} from '@dxos/react-ui-editor';
|
|
22
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
22
|
+
} from '@dxos/ui-editor';
|
|
23
23
|
import { isNonNullable } from '@dxos/util';
|
|
24
24
|
|
|
25
25
|
import { GridSheet, SheetProvider, useComputeGraph } from '../components';
|
|
26
26
|
import { useSheetModel } from '../model';
|
|
27
27
|
import { useTestSheet, withComputeGraphDecorator } from '../testing';
|
|
28
|
-
import {
|
|
28
|
+
import { Sheet } from '../types';
|
|
29
29
|
|
|
30
30
|
import { compute, computeGraphFacet } from './compute';
|
|
31
31
|
|
|
@@ -42,7 +42,7 @@ type EditorProps = {
|
|
|
42
42
|
|
|
43
43
|
const SHEET_NAME = 'Test Sheet';
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const DefaultStory = ({ text }: EditorProps) => {
|
|
46
46
|
const id = useMemo(() => PublicKey.random(), []);
|
|
47
47
|
const { themeMode } = useThemeContext();
|
|
48
48
|
const space = useSpace();
|
|
@@ -63,7 +63,7 @@ const EditorStory = ({ text }: EditorProps) => {
|
|
|
63
63
|
[computeGraph, themeMode],
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
return <div className='
|
|
66
|
+
return <div className='is-[40rem] overflow-hidden' ref={parentRef} {...focusAttributes} />;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
const Grid = () => {
|
|
@@ -73,7 +73,12 @@ const Grid = () => {
|
|
|
73
73
|
const model = useSheetModel(graph, sheet);
|
|
74
74
|
useEffect(() => {
|
|
75
75
|
if (model) {
|
|
76
|
-
model.setValues({
|
|
76
|
+
model.setValues({
|
|
77
|
+
A1: { value: 100 },
|
|
78
|
+
A2: { value: 200 },
|
|
79
|
+
A3: { value: 300 },
|
|
80
|
+
A5: { value: '=SUM(A1:A3)' },
|
|
81
|
+
});
|
|
77
82
|
}
|
|
78
83
|
}, [model]);
|
|
79
84
|
|
|
@@ -82,7 +87,7 @@ const Grid = () => {
|
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
return (
|
|
85
|
-
<div className='flex
|
|
90
|
+
<div className='flex is-[40rem] overflow-hidden'>
|
|
86
91
|
<SheetProvider graph={graph} sheet={sheet}>
|
|
87
92
|
<GridSheet />
|
|
88
93
|
</SheetProvider>
|
|
@@ -93,7 +98,7 @@ const Grid = () => {
|
|
|
93
98
|
const GraphStory = (props: EditorProps) => {
|
|
94
99
|
return (
|
|
95
100
|
<div className='grid grid-rows-2'>
|
|
96
|
-
<
|
|
101
|
+
<DefaultStory {...props} />
|
|
97
102
|
<Grid />
|
|
98
103
|
</div>
|
|
99
104
|
);
|
|
@@ -102,19 +107,26 @@ const GraphStory = (props: EditorProps) => {
|
|
|
102
107
|
const meta = {
|
|
103
108
|
title: 'plugins/plugin-sheet/extensions',
|
|
104
109
|
decorators: [
|
|
105
|
-
withClientProvider({ types: [SheetType], createIdentity: true, createSpace: true }),
|
|
106
|
-
withComputeGraphDecorator(),
|
|
107
110
|
withTheme,
|
|
108
|
-
|
|
111
|
+
withClientProvider({
|
|
112
|
+
types: [Sheet.Sheet],
|
|
113
|
+
createIdentity: true,
|
|
114
|
+
createSpace: true,
|
|
115
|
+
}),
|
|
116
|
+
// TODO(wittjosiah): Try to write story which does not depend on plugin manager.
|
|
117
|
+
withPluginManager({ plugins: [OperationPlugin(), RuntimePlugin()] }),
|
|
118
|
+
withComputeGraphDecorator(),
|
|
109
119
|
],
|
|
110
|
-
parameters: {
|
|
120
|
+
parameters: {
|
|
121
|
+
layout: 'fullscreen',
|
|
122
|
+
},
|
|
111
123
|
} satisfies Meta;
|
|
112
124
|
|
|
113
125
|
export default meta;
|
|
114
126
|
|
|
115
127
|
// TODO(burdon): Inline formulae.
|
|
116
|
-
export const Default: StoryObj<typeof
|
|
117
|
-
render:
|
|
128
|
+
export const Default: StoryObj<typeof DefaultStory> = {
|
|
129
|
+
render: DefaultStory,
|
|
118
130
|
args: {
|
|
119
131
|
text: str(
|
|
120
132
|
//
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
createSheetName,
|
|
24
24
|
} from '@dxos/compute';
|
|
25
25
|
import { invariant } from '@dxos/invariant';
|
|
26
|
-
import { documentId, singleValueFacet } from '@dxos/
|
|
26
|
+
import { documentId, singleValueFacet } from '@dxos/ui-editor';
|
|
27
27
|
|
|
28
28
|
const LANGUAGE_TAG = 'dx';
|
|
29
29
|
|
|
@@ -20,8 +20,8 @@ import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
|
20
20
|
|
|
21
21
|
import { type FunctionDefinition } from '@dxos/compute';
|
|
22
22
|
import { RANGE_NOTATION } from '@dxos/compute';
|
|
23
|
-
import { singleValueFacet } from '@dxos/
|
|
24
|
-
import { mx } from '@dxos/
|
|
23
|
+
import { singleValueFacet } from '@dxos/ui-editor';
|
|
24
|
+
import { mx } from '@dxos/ui-theme';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* https://codemirror.net/examples/styling
|
|
@@ -75,7 +75,10 @@ export type SheetExtensionOptions = {
|
|
|
75
75
|
* https://hyperformula.handsontable.com/guide/key-concepts.html#grammar
|
|
76
76
|
*/
|
|
77
77
|
export const sheetExtension = ({ debug, functions = [] }: SheetExtensionOptions): Extension => {
|
|
78
|
-
const { extension, language } = spreadsheet({
|
|
78
|
+
const { extension, language } = spreadsheet({
|
|
79
|
+
idiom: 'en-US',
|
|
80
|
+
decimalSeparator: '.',
|
|
81
|
+
});
|
|
79
82
|
|
|
80
83
|
const createCompletion = (name: string) => {
|
|
81
84
|
const { section = 'Custom', description, syntax } = functions.find((value) => value.name === name) ?? {};
|
|
@@ -166,7 +169,7 @@ export const sheetExtension = ({ debug, functions = [] }: SheetExtensionOptions)
|
|
|
166
169
|
icons: false,
|
|
167
170
|
tooltipClass: () =>
|
|
168
171
|
mx(
|
|
169
|
-
'!-left-[1px] !top-[33px] !-m-0 border !border-
|
|
172
|
+
'!-left-[1px] !top-[33px] !-m-0 border !border-bs-0 [&>ul]:!min-w-[198px]',
|
|
170
173
|
'[&>ul>li[aria-selected]]:!bg-accentSurface',
|
|
171
174
|
'border-separator',
|
|
172
175
|
),
|