@dxos/plugin-sheet 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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-IC5RYQYU.mjs +53 -0
- package/dist/lib/browser/RangeList-IC5RYQYU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-S27QJYTN.mjs → SheetContainer-AITFHNUW.mjs} +578 -243
- package/dist/lib/browser/SheetContainer-AITFHNUW.mjs.map +7 -0
- package/dist/lib/browser/{anchor-sort-LLO7PZKF.mjs → anchor-sort-5PYGDBAT.mjs} +5 -4
- package/dist/lib/browser/anchor-sort-5PYGDBAT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KE3AKN5W.mjs → chunk-GUP25ZNZ.mjs} +11 -31
- package/dist/lib/browser/chunk-GUP25ZNZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IFLWVS2V.mjs → chunk-NNWF7EKC.mjs} +10 -10
- package/dist/lib/browser/{chunk-IFLWVS2V.mjs.map → chunk-NNWF7EKC.mjs.map} +2 -2
- package/dist/lib/browser/{compute-graph-registry-RC5L7RE4.mjs → compute-graph-registry-CGBTEI2T.mjs} +2 -2
- package/dist/lib/browser/index.mjs +20 -25
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{markdown-D2T2DOVX.mjs → markdown-SF55PRFI.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-YDOW72CN.mjs → operation-resolver-POWQIMRP.mjs} +5 -19
- package/dist/lib/browser/operation-resolver-POWQIMRP.mjs.map +7 -0
- package/dist/lib/browser/react-surface-U5IEDSN7.mjs +52 -0
- package/dist/lib/browser/react-surface-U5IEDSN7.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/RangeList-QFHOLKRE.mjs +54 -0
- package/dist/lib/node-esm/RangeList-QFHOLKRE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Y4V6HVHO.mjs → SheetContainer-FDV55IZT.mjs} +578 -243
- package/dist/lib/node-esm/SheetContainer-FDV55IZT.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-OX5I2YOW.mjs → anchor-sort-TMYWWZGC.mjs} +5 -4
- package/dist/lib/node-esm/anchor-sort-TMYWWZGC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6J5L47IB.mjs → chunk-B3LMFENM.mjs} +11 -31
- package/dist/lib/node-esm/chunk-B3LMFENM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PPOYR7DK.mjs → chunk-M52YLLWU.mjs} +10 -10
- package/dist/lib/node-esm/{chunk-PPOYR7DK.mjs.map → chunk-M52YLLWU.mjs.map} +2 -2
- package/dist/lib/node-esm/{compute-graph-registry-ZGXVLVGD.mjs → compute-graph-registry-B7OXC4TD.mjs} +2 -2
- package/dist/lib/node-esm/index.mjs +20 -25
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{markdown-PTV72DLO.mjs → markdown-MMKSGCIC.mjs} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-Q63VQBVA.mjs → operation-resolver-XVNBVJVE.mjs} +5 -19
- package/dist/lib/node-esm/operation-resolver-XVNBVJVE.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-SWRZSZVR.mjs → react-surface-ZTRBZ53R.mjs} +22 -21
- package/dist/lib/node-esm/react-surface-ZTRBZ53R.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +3 -2
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +1 -1
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +1 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +15 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/index.d.ts +2 -0
- package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +7 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet/GridSheet.stories.d.ts → SheetContent/SheetContent.stories.d.ts} +5 -2
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/index.d.ts +2 -0
- package/dist/types/src/components/SheetContent/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -0
- package/dist/types/src/components/{SheetContext/SheetContext.d.ts → SheetRoot/SheetRoot.d.ts} +6 -4
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -0
- package/dist/types/src/components/SheetRoot/index.d.ts +2 -0
- package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +7 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +6 -3
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +2 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/containers/RangeList/index.d.ts +3 -0
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +12 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/SheetContainer.stories.d.ts +2 -2
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/index.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +1 -1
- package/dist/types/src/types/Sheet.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -24
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -62
- package/src/SheetPlugin.tsx +11 -22
- package/src/capabilities/anchor-sort/anchor-sort.ts +3 -2
- package/src/capabilities/operation-resolver/operation-resolver.ts +4 -15
- package/src/capabilities/react-surface/react-surface.tsx +19 -13
- package/src/components/ComputeGraph/compute-graph.stories.tsx +2 -2
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +5 -5
- package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +12 -11
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +14 -11
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +3 -3
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +44 -36
- package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
- package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +19 -8
- package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +4 -4
- package/src/components/SheetToolbar/SheetToolbar.tsx +11 -10
- package/src/components/SheetToolbar/align.ts +9 -9
- package/src/components/SheetToolbar/style.ts +7 -7
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +9 -7
- package/src/containers/RangeList/index.ts +7 -0
- package/src/{components → containers}/SheetContainer/SheetContainer.stories.tsx +28 -33
- package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
- package/src/{components → containers}/SheetContainer/index.ts +1 -1
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +12 -11
- package/src/extensions/editor/sheet-extension.ts +10 -10
- package/src/integrations/thread-ranges.ts +6 -9
- package/src/meta.ts +1 -1
- package/src/model/sheet-model.ts +36 -34
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet.spec.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types/Sheet.ts +3 -1
- package/src/types/capabilities.ts +1 -1
- package/src/types/sheet-range-types.ts +3 -3
- package/src/types/types.ts +4 -20
- package/dist/lib/browser/SheetContainer-J72HS2FI.mjs +0 -397
- package/dist/lib/browser/SheetContainer-J72HS2FI.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-LLO7PZKF.mjs.map +0 -7
- package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +0 -7
- package/dist/lib/browser/chunk-S27QJYTN.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-YDOW72CN.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JIYVFH42.mjs +0 -51
- package/dist/lib/browser/react-surface-JIYVFH42.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-OGSSDOZU.mjs +0 -398
- package/dist/lib/node-esm/SheetContainer-OGSSDOZU.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-OX5I2YOW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y4V6HVHO.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-Q63VQBVA.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SWRZSZVR.mjs.map +0 -7
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/index.d.ts +0 -2
- package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/index.d.ts +0 -2
- package/dist/types/src/components/RangeList/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -10
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/index.d.ts +0 -2
- package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
- package/src/components/SheetContainer/SheetContainer.tsx +0 -48
- package/src/components/SheetContext/index.ts +0 -5
- /package/dist/lib/browser/{compute-graph-registry-RC5L7RE4.mjs.map → compute-graph-registry-CGBTEI2T.mjs.map} +0 -0
- /package/dist/lib/browser/{markdown-D2T2DOVX.mjs.map → markdown-SF55PRFI.mjs.map} +0 -0
- /package/dist/lib/node-esm/{compute-graph-registry-ZGXVLVGD.mjs.map → compute-graph-registry-B7OXC4TD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{markdown-PTV72DLO.mjs.map → markdown-MMKSGCIC.mjs.map} +0 -0
- /package/dist/types/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +0 -0
- /package/dist/types/src/components/{GridSheet → SheetContent}/util.d.ts +0 -0
- /package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts +0 -0
- /package/dist/types/src/{components → containers}/SheetContainer/index.d.ts +0 -0
|
@@ -5,8 +5,7 @@
|
|
|
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 {
|
|
9
|
-
import { invariant } from '@dxos/invariant';
|
|
8
|
+
import { raise } from '@dxos/debug';
|
|
10
9
|
import {
|
|
11
10
|
Grid,
|
|
12
11
|
type GridContentProps,
|
|
@@ -20,6 +19,7 @@ import { type Sheet } from '../../types';
|
|
|
20
19
|
|
|
21
20
|
export type SheetContextValue = {
|
|
22
21
|
id: string;
|
|
22
|
+
attendableId: string;
|
|
23
23
|
|
|
24
24
|
model: SheetModel;
|
|
25
25
|
|
|
@@ -39,29 +39,62 @@ export type SheetContextValue = {
|
|
|
39
39
|
activeRefs: GridContentProps['activeRefs'];
|
|
40
40
|
setActiveRefs: (activeRefs: GridContentProps['activeRefs']) => void;
|
|
41
41
|
|
|
42
|
+
// Flags
|
|
43
|
+
ignoreAttention?: boolean;
|
|
44
|
+
|
|
42
45
|
// Events.
|
|
43
46
|
// TODO(burdon): Generalize.
|
|
44
47
|
onInfo?: () => void;
|
|
45
|
-
|
|
46
|
-
// Flags
|
|
47
|
-
ignoreAttention?: boolean;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
// TODO(burdon): Use radix context.
|
|
50
51
|
const SheetContext = createContext<SheetContextValue | undefined>(undefined);
|
|
51
52
|
|
|
52
53
|
export const useSheetContext = (): SheetContextValue => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
return useContext(SheetContext) ?? raise(new Error('Missing SheetContext'));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type SheetRootProps = {
|
|
58
|
+
graph: ComputeGraph;
|
|
59
|
+
sheet: Sheet.Sheet;
|
|
60
|
+
attendableId: string;
|
|
61
|
+
readonly?: boolean;
|
|
62
|
+
ignoreAttention?: boolean;
|
|
63
|
+
} & Pick<SheetContextValue, 'onInfo'>;
|
|
64
|
+
|
|
65
|
+
export const SheetRoot = ({
|
|
66
|
+
children,
|
|
67
|
+
graph,
|
|
68
|
+
sheet,
|
|
69
|
+
attendableId,
|
|
70
|
+
readonly,
|
|
71
|
+
ignoreAttention,
|
|
72
|
+
onInfo,
|
|
73
|
+
}: PropsWithChildren<SheetRootProps>) => {
|
|
74
|
+
const model = useSheetModel(graph, sheet, { readonly });
|
|
75
|
+
if (!model) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Grid.Root id={attendableId}>
|
|
81
|
+
<SheetProviderImpl model={model} attendableId={attendableId} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
82
|
+
{children}
|
|
83
|
+
</SheetProviderImpl>
|
|
84
|
+
</Grid.Root>
|
|
85
|
+
);
|
|
56
86
|
};
|
|
57
87
|
|
|
58
88
|
const SheetProviderImpl = ({
|
|
59
89
|
__gridScope,
|
|
60
90
|
children,
|
|
91
|
+
attendableId,
|
|
61
92
|
ignoreAttention,
|
|
62
93
|
model,
|
|
63
94
|
onInfo,
|
|
64
|
-
}: GridScopedProps<
|
|
95
|
+
}: GridScopedProps<
|
|
96
|
+
PropsWithChildren<Pick<SheetContextValue, 'attendableId' | 'ignoreAttention' | 'model' | 'onInfo'>>
|
|
97
|
+
>) => {
|
|
65
98
|
const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
|
|
66
99
|
|
|
67
100
|
const [cursor, setCursorInternal] = useState<CellAddress>();
|
|
@@ -92,6 +125,7 @@ const SheetProviderImpl = ({
|
|
|
92
125
|
<SheetContext.Provider
|
|
93
126
|
value={{
|
|
94
127
|
id,
|
|
128
|
+
attendableId,
|
|
95
129
|
model,
|
|
96
130
|
editing,
|
|
97
131
|
setEditing,
|
|
@@ -102,38 +136,12 @@ const SheetProviderImpl = ({
|
|
|
102
136
|
cursorFallbackRange,
|
|
103
137
|
activeRefs,
|
|
104
138
|
setActiveRefs,
|
|
139
|
+
ignoreAttention,
|
|
105
140
|
// TODO(burdon): Change to event.
|
|
106
141
|
onInfo,
|
|
107
|
-
ignoreAttention,
|
|
108
142
|
}}
|
|
109
143
|
>
|
|
110
144
|
{children}
|
|
111
145
|
</SheetContext.Provider>
|
|
112
146
|
);
|
|
113
147
|
};
|
|
114
|
-
|
|
115
|
-
export type SheetProviderProps = {
|
|
116
|
-
graph: ComputeGraph;
|
|
117
|
-
sheet: Sheet.Sheet;
|
|
118
|
-
readonly?: boolean;
|
|
119
|
-
ignoreAttention?: boolean;
|
|
120
|
-
} & Pick<SheetContextValue, 'onInfo'>;
|
|
121
|
-
|
|
122
|
-
export const SheetProvider = ({
|
|
123
|
-
children,
|
|
124
|
-
graph,
|
|
125
|
-
sheet,
|
|
126
|
-
readonly,
|
|
127
|
-
ignoreAttention,
|
|
128
|
-
onInfo,
|
|
129
|
-
}: PropsWithChildren<SheetProviderProps>) => {
|
|
130
|
-
const model = useSheetModel(graph, sheet, { readonly });
|
|
131
|
-
|
|
132
|
-
return !model ? null : (
|
|
133
|
-
<Grid.Root id={Obj.getDXN(sheet).toString()}>
|
|
134
|
-
<SheetProviderImpl model={model} onInfo={onInfo} ignoreAttention={ignoreAttention}>
|
|
135
|
-
{children}
|
|
136
|
-
</SheetProviderImpl>
|
|
137
|
-
</Grid.Root>
|
|
138
|
-
);
|
|
139
|
-
};
|
package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx}
RENAMED
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
6
|
|
|
7
7
|
import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute';
|
|
8
|
-
import { Icon } from '@dxos/react-ui';
|
|
8
|
+
import { type ComposableProps, Icon } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
10
|
import { mapFormulaIndicesToRefs } from '../../types';
|
|
11
|
-
import { useSheetContext } from '../
|
|
11
|
+
import { useSheetContext } from '../SheetRoot';
|
|
12
|
+
import { composableProps, mx } from '@dxos/ui-theme';
|
|
12
13
|
|
|
13
|
-
export
|
|
14
|
+
export type SheetStatusbarProps = ComposableProps;
|
|
15
|
+
|
|
16
|
+
export const SheetStatusbar = forwardRef<HTMLDivElement, SheetStatusbarProps>((props, forwardedRef) => {
|
|
17
|
+
const { className, ...rest } = composableProps(props);
|
|
14
18
|
const { model, cursor, range } = useSheetContext();
|
|
15
19
|
|
|
16
20
|
let value;
|
|
@@ -26,16 +30,23 @@ export const FunctionEditor = () => {
|
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
return (
|
|
29
|
-
<div
|
|
33
|
+
<div
|
|
34
|
+
ref={forwardedRef}
|
|
35
|
+
{...rest}
|
|
36
|
+
className={mx(
|
|
37
|
+
'flex shrink-0 justify-between items-center px-4 py-1 text-sm bg-toolbar-surface border-y !border-subdued-separator',
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
30
41
|
<div className='flex gap-4 items-center'>
|
|
31
|
-
<div className='flex
|
|
42
|
+
<div className='flex w-16 items-center font-mono'>
|
|
32
43
|
{(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}
|
|
33
44
|
</div>
|
|
34
45
|
<div className='flex gap-2 items-center'>
|
|
35
|
-
<Icon icon='ph--function--regular' classNames={['text-
|
|
46
|
+
<Icon icon='ph--function--regular' classNames={['text-green-text', formula ? 'visible' : 'invisible']} />
|
|
36
47
|
<span className='font-mono'>{value}</span>
|
|
37
48
|
</div>
|
|
38
49
|
</div>
|
|
39
50
|
</div>
|
|
40
51
|
);
|
|
41
|
-
};
|
|
52
|
+
});
|
|
@@ -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 { withTheme } from '@dxos/react-ui/testing';
|
|
8
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
9
9
|
|
|
10
10
|
import { translations } from '../../translations';
|
|
11
11
|
|
|
12
12
|
import { SheetToolbar } from './SheetToolbar';
|
|
13
13
|
|
|
14
14
|
const DefaultStory = () => {
|
|
15
|
-
// TODO(wittjosiah): Depends on
|
|
15
|
+
// TODO(wittjosiah): Depends on SheetRoot.
|
|
16
16
|
// return <SheetToolbar id='test' />;
|
|
17
17
|
return <>TODO</>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const meta = {
|
|
21
|
-
title: 'plugins/plugin-sheet/Toolbar',
|
|
21
|
+
title: 'plugins/plugin-sheet/components/Toolbar',
|
|
22
22
|
component: SheetToolbar as any,
|
|
23
23
|
render: DefaultStory,
|
|
24
|
-
decorators: [withTheme],
|
|
24
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
25
25
|
parameters: {
|
|
26
26
|
layout: 'fullscreen',
|
|
27
27
|
translations,
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
import { Atom, type Registry, RegistryContext } from '@effect-atom/atom-react';
|
|
6
6
|
import React, { type PropsWithChildren, useContext, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useAppGraph } from '@dxos/app-
|
|
8
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { type CompleteCellRange } from '@dxos/compute';
|
|
10
10
|
import {
|
|
11
11
|
type ActionGraphProps,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Menu,
|
|
13
|
+
type MenuRootProps,
|
|
14
14
|
createGapSeparator,
|
|
15
15
|
useMenuActions,
|
|
16
16
|
} from '@dxos/react-ui-menu';
|
|
17
17
|
|
|
18
18
|
import { type SheetModel } from '../../model';
|
|
19
|
-
import { useSheetContext } from '../
|
|
19
|
+
import { useSheetContext } from '../SheetRoot';
|
|
20
20
|
|
|
21
21
|
import { createAlign, useAlignState } from './align';
|
|
22
22
|
import { createStyle, useStyleState } from './style';
|
|
@@ -59,9 +59,10 @@ const createToolbarActions = ({
|
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export type SheetToolbarProps =
|
|
62
|
+
export type SheetToolbarProps = { id: string } & Partial<MenuRootProps> &
|
|
63
|
+
PropsWithChildren<{ id: string } & Partial<MenuRootProps>>;
|
|
63
64
|
|
|
64
|
-
export const SheetToolbar = ({ id }: SheetToolbarProps) => {
|
|
65
|
+
export const SheetToolbar = ({ id, ...props }: SheetToolbarProps) => {
|
|
65
66
|
const { model, cursorFallbackRange } = useSheetContext();
|
|
66
67
|
const stateAtom = useToolbarState({});
|
|
67
68
|
const registry = useContext(RegistryContext);
|
|
@@ -75,7 +76,7 @@ export const SheetToolbar = ({ id }: SheetToolbarProps) => {
|
|
|
75
76
|
const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
|
|
76
77
|
return {
|
|
77
78
|
nodes,
|
|
78
|
-
edges: nodes.map((node) => ({ source: 'root', target: node.id })),
|
|
79
|
+
edges: nodes.map((node) => ({ source: 'root', target: node.id, relation: 'child' })),
|
|
79
80
|
};
|
|
80
81
|
});
|
|
81
82
|
}, [graph, id]);
|
|
@@ -87,8 +88,8 @@ export const SheetToolbar = ({ id }: SheetToolbarProps) => {
|
|
|
87
88
|
const menu = useMenuActions(actionsCreator);
|
|
88
89
|
|
|
89
90
|
return (
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
</
|
|
91
|
+
<Menu.Root {...props} {...menu} attendableId={id}>
|
|
92
|
+
<Menu.Toolbar />
|
|
93
|
+
</Menu.Root>
|
|
93
94
|
);
|
|
94
95
|
};
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { meta } from '../../meta';
|
|
18
18
|
import { type SheetModel } from '../../model';
|
|
19
19
|
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
20
|
-
import { useSheetContext } from '../
|
|
20
|
+
import { useSheetContext } from '../SheetRoot';
|
|
21
21
|
|
|
22
22
|
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
23
23
|
|
|
@@ -84,18 +84,18 @@ const createAlignActions = ({ model, state, stateAtom, registry, cursorFallbackR
|
|
|
84
84
|
};
|
|
85
85
|
const currentState = registry.get(stateAtom);
|
|
86
86
|
if (index < 0) {
|
|
87
|
-
Obj.change(model.sheet, (
|
|
88
|
-
|
|
87
|
+
Obj.change(model.sheet, (obj) => {
|
|
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.change(model.sheet, (
|
|
93
|
-
|
|
92
|
+
Obj.change(model.sheet, (obj) => {
|
|
93
|
+
obj.ranges?.splice(index, 1);
|
|
94
94
|
});
|
|
95
95
|
registry.set(stateAtom, { ...currentState, [alignKey]: undefined });
|
|
96
96
|
} else {
|
|
97
|
-
Obj.change(model.sheet, (
|
|
98
|
-
|
|
97
|
+
Obj.change(model.sheet, (obj) => {
|
|
98
|
+
obj.ranges?.splice(index, 1, nextRangeEntity);
|
|
99
99
|
});
|
|
100
100
|
registry.set(stateAtom, { ...currentState, [alignKey]: nextRangeEntity.value });
|
|
101
101
|
}
|
|
@@ -117,8 +117,8 @@ export const createAlign = (context: AlignActionsContext): ActionGraphProps => {
|
|
|
117
117
|
return {
|
|
118
118
|
nodes: [alignGroup, ...alignActions],
|
|
119
119
|
edges: [
|
|
120
|
-
{ source: 'root', target: 'align' },
|
|
121
|
-
...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id })),
|
|
120
|
+
{ source: 'root', target: 'align', relation: 'child' },
|
|
121
|
+
...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id, relation: 'child' })),
|
|
122
122
|
],
|
|
123
123
|
};
|
|
124
124
|
};
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { meta } from '../../meta';
|
|
18
18
|
import { type SheetModel } from '../../model';
|
|
19
19
|
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
20
|
-
import { useSheetContext } from '../
|
|
20
|
+
import { useSheetContext } from '../SheetRoot';
|
|
21
21
|
|
|
22
22
|
import { type ToolbarState, type ToolbarStateAtom } from './useToolbarState';
|
|
23
23
|
|
|
@@ -103,14 +103,14 @@ const createStyleActions = ({ model, state, stateAtom, registry, cursorFallbackR
|
|
|
103
103
|
) {
|
|
104
104
|
// this value should be unset
|
|
105
105
|
if (index >= 0) {
|
|
106
|
-
Obj.change(model.sheet, (
|
|
107
|
-
|
|
106
|
+
Obj.change(model.sheet, (obj) => {
|
|
107
|
+
obj.ranges?.splice(index, 1);
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: false });
|
|
111
111
|
} else {
|
|
112
|
-
Obj.change(model.sheet, (
|
|
113
|
-
|
|
112
|
+
Obj.change(model.sheet, (obj) => {
|
|
113
|
+
obj.ranges?.push(nextRangeEntity);
|
|
114
114
|
});
|
|
115
115
|
registry.set(stateAtom, { ...currentState, [nextRangeEntity.value]: true });
|
|
116
116
|
}
|
|
@@ -131,8 +131,8 @@ export const createStyle = (context: StyleActionsContext): ActionGraphProps => {
|
|
|
131
131
|
return {
|
|
132
132
|
nodes: [styleGroupAction, ...styleActions],
|
|
133
133
|
edges: [
|
|
134
|
-
{ source: 'root', target: 'style' },
|
|
135
|
-
...styleActions.map(({ id }) => ({ source: styleGroupAction.id, target: id })),
|
|
134
|
+
{ source: 'root', target: 'style', relation: 'child' },
|
|
135
|
+
...styleActions.map(({ id }) => ({ source: styleGroupAction.id, target: id, relation: 'child' })),
|
|
136
136
|
],
|
|
137
137
|
};
|
|
138
138
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -2,11 +2,5 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { lazy } from 'react';
|
|
6
|
-
|
|
7
5
|
export * from './ComputeGraph';
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './RangeList';
|
|
10
|
-
export * from './SheetContext';
|
|
11
|
-
|
|
12
|
-
export const SheetContainer = lazy(() => import('./SheetContainer'));
|
|
6
|
+
export * from './Sheet';
|
|
@@ -7,7 +7,7 @@ import React, { useCallback } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { rangeToA1Notation } from '@dxos/compute';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
|
-
import {
|
|
10
|
+
import { Input, Message, useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import { List } from '@dxos/react-ui-list';
|
|
12
12
|
import { ghostHover } from '@dxos/ui-theme';
|
|
13
13
|
|
|
@@ -26,19 +26,21 @@ export const RangeList = ({ sheet }: RangeListProps) => {
|
|
|
26
26
|
const handleDeleteRange = useCallback(
|
|
27
27
|
(range: Sheet.Range) => {
|
|
28
28
|
const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
|
|
29
|
-
Obj.change(sheet, (
|
|
30
|
-
|
|
29
|
+
Obj.change(sheet, (obj) => {
|
|
30
|
+
obj.ranges.splice(index, 1);
|
|
31
31
|
});
|
|
32
32
|
},
|
|
33
33
|
[sheet],
|
|
34
34
|
);
|
|
35
35
|
return (
|
|
36
36
|
<>
|
|
37
|
-
<
|
|
37
|
+
<Input.Root>
|
|
38
|
+
<Input.Label>{t('range list heading')}</Input.Label>
|
|
39
|
+
</Input.Root>
|
|
38
40
|
{sheet.ranges.length < 1 ? (
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
</
|
|
41
|
+
<Message.Root>
|
|
42
|
+
<Message.Title>{t('no ranges message')}</Message.Title>
|
|
43
|
+
</Message.Root>
|
|
42
44
|
) : (
|
|
43
45
|
<List.Root<Sheet.Range> items={sheet.ranges} isItem={Schema.is(Sheet.Range)}>
|
|
44
46
|
{({ items: ranges }) =>
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Meta } from '@storybook/react-vite';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
10
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
11
11
|
import { Obj } from '@dxos/echo';
|
|
12
12
|
import { OperationResolver } from '@dxos/operation';
|
|
@@ -16,33 +16,31 @@ import { withClientProvider } from '@dxos/react-client/testing';
|
|
|
16
16
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
17
17
|
import { AttendableContainer } from '@dxos/react-ui-attention';
|
|
18
18
|
|
|
19
|
+
import { ComputeGraphContext, useComputeGraph } from '../../components';
|
|
19
20
|
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
20
21
|
import { translations } from '../../translations';
|
|
21
22
|
import { Sheet, SheetOperation } from '../../types';
|
|
22
|
-
import
|
|
23
|
-
import { RangeList } from '../RangeList';
|
|
23
|
+
import RangeList from '../RangeList';
|
|
24
24
|
|
|
25
25
|
import { SheetContainer } from './SheetContainer';
|
|
26
26
|
|
|
27
27
|
const meta = {
|
|
28
|
-
title: 'plugins/plugin-sheet/SheetContainer',
|
|
28
|
+
title: 'plugins/plugin-sheet/containers/SheetContainer',
|
|
29
29
|
component: SheetContainer,
|
|
30
30
|
decorators: [
|
|
31
|
-
withTheme,
|
|
31
|
+
withTheme(),
|
|
32
32
|
withLayout({ layout: 'fullscreen' }),
|
|
33
33
|
withClientProvider({ types: [Sheet.Sheet], createSpace: true }),
|
|
34
34
|
withComputeGraphDecorator(),
|
|
35
|
-
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
36
35
|
withPluginManager({
|
|
37
36
|
plugins: [...corePlugins()],
|
|
38
37
|
capabilities: [
|
|
39
|
-
Capability.contributes(
|
|
38
|
+
Capability.contributes(Capabilities.OperationResolver, [
|
|
40
39
|
OperationResolver.make({
|
|
41
40
|
operation: SheetOperation.DropAxis,
|
|
42
41
|
handler: ({ model, axis, axisIndex }) =>
|
|
43
42
|
Effect.sync(() => {
|
|
44
43
|
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
45
|
-
// Return stub output for story purposes.
|
|
46
44
|
return { axis, axisIndex, index: 0, axisMeta: null, values: [] };
|
|
47
45
|
}),
|
|
48
46
|
}),
|
|
@@ -61,49 +59,46 @@ export default meta;
|
|
|
61
59
|
export const Default = () => {
|
|
62
60
|
const space = useSpace();
|
|
63
61
|
const graph = useComputeGraph(space);
|
|
62
|
+
const { registry } = useContext(ComputeGraphContext) ?? {};
|
|
64
63
|
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
65
|
-
if (!sheet || !space) {
|
|
64
|
+
if (!sheet || !space || !registry) {
|
|
66
65
|
return null;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
return (
|
|
70
69
|
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
71
|
-
<SheetContainer
|
|
70
|
+
<SheetContainer
|
|
71
|
+
role='article'
|
|
72
|
+
space={space}
|
|
73
|
+
subject={sheet}
|
|
74
|
+
attendableId='test'
|
|
75
|
+
registry={registry}
|
|
76
|
+
ignoreAttention
|
|
77
|
+
/>
|
|
72
78
|
</AttendableContainer>
|
|
73
79
|
);
|
|
74
80
|
};
|
|
75
81
|
|
|
76
|
-
export const Section = () => {
|
|
77
|
-
const space = useSpace();
|
|
78
|
-
const graph = useComputeGraph(space);
|
|
79
|
-
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
80
|
-
if (!sheet || !space) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<div className='is-full flex justify-center'>
|
|
86
|
-
<div className='is-[40rem]'>
|
|
87
|
-
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
88
|
-
<SheetContainer role='section' space={space} subject={sheet} ignoreAttention />
|
|
89
|
-
</AttendableContainer>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
82
|
export const Spec = () => {
|
|
96
83
|
const space = useSpace();
|
|
97
84
|
const graph = useComputeGraph(space);
|
|
85
|
+
const { registry } = useContext(ComputeGraphContext) ?? {};
|
|
98
86
|
const sheet = useTestSheet(space, graph, { cells: { A1: { value: 'Ready' } } });
|
|
99
|
-
if (!sheet || !space) {
|
|
87
|
+
if (!sheet || !space || !registry) {
|
|
100
88
|
return null;
|
|
101
89
|
}
|
|
102
90
|
|
|
103
91
|
return (
|
|
104
92
|
<AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
|
|
105
|
-
<div role='none' className='
|
|
106
|
-
<SheetContainer
|
|
93
|
+
<div role='none' className='w-full grid grid-cols-[1fr_20rem]'>
|
|
94
|
+
<SheetContainer
|
|
95
|
+
role='article'
|
|
96
|
+
space={space}
|
|
97
|
+
subject={sheet}
|
|
98
|
+
attendableId='test'
|
|
99
|
+
registry={registry}
|
|
100
|
+
ignoreAttention
|
|
101
|
+
/>
|
|
107
102
|
<div role='none' data-testid='grid.range-list'>
|
|
108
103
|
<RangeList sheet={sheet} />
|
|
109
104
|
</div>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { type ComputeGraphRegistry } from '@dxos/compute';
|
|
9
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
10
|
+
import { Panel } from '@dxos/react-ui';
|
|
11
|
+
|
|
12
|
+
import { ComputeGraphContextProvider, Sheet, useComputeGraph } from '../../components';
|
|
13
|
+
import { type Sheet as SheetType } from '../../types';
|
|
14
|
+
|
|
15
|
+
export type SheetContainerProps = SurfaceComponentProps<
|
|
16
|
+
SheetType.Sheet,
|
|
17
|
+
{
|
|
18
|
+
space: Space;
|
|
19
|
+
registry: ComputeGraphRegistry;
|
|
20
|
+
ignoreAttention?: boolean;
|
|
21
|
+
}
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export const SheetContainer = ({ registry, ...props }: SheetContainerProps) => (
|
|
25
|
+
<ComputeGraphContextProvider registry={registry}>
|
|
26
|
+
<SheetContainerInner {...props} />
|
|
27
|
+
</ComputeGraphContextProvider>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const SheetContainerInner = ({
|
|
31
|
+
role,
|
|
32
|
+
subject: sheet,
|
|
33
|
+
attendableId,
|
|
34
|
+
space,
|
|
35
|
+
ignoreAttention,
|
|
36
|
+
}: Omit<SheetContainerProps, 'registry'>) => {
|
|
37
|
+
const graph = useComputeGraph(space);
|
|
38
|
+
if (!graph) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Sheet.Root graph={graph} sheet={sheet} attendableId={attendableId!} ignoreAttention={ignoreAttention}>
|
|
44
|
+
<Panel.Root classNames={role === 'section' && 'aspect-aquare'}>
|
|
45
|
+
<Panel.Toolbar asChild>
|
|
46
|
+
<Sheet.Toolbar id={attendableId!} />
|
|
47
|
+
</Panel.Toolbar>
|
|
48
|
+
<Panel.Content asChild>
|
|
49
|
+
<Sheet.Content />
|
|
50
|
+
</Panel.Content>
|
|
51
|
+
<Panel.Statusbar asChild>
|
|
52
|
+
<Sheet.Statusbar />
|
|
53
|
+
</Panel.Statusbar>
|
|
54
|
+
</Panel.Root>
|
|
55
|
+
</Sheet.Root>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ComponentType, lazy } from 'react';
|
|
6
|
+
|
|
7
|
+
export const RangeList: ComponentType<any> = lazy(() => import('./RangeList'));
|
|
8
|
+
export const SheetContainer: ComponentType<any> = lazy(() => import('./SheetContainer'));
|