@dxos/plugin-sheet 0.8.4-main.2e9d522 → 0.8.4-main.406dc2a
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-KDGD4AVG.mjs → SheetContainer-VL34UND4.mjs} +29 -29
- package/dist/lib/browser/SheetContainer-VL34UND4.mjs.map +7 -0
- package/dist/lib/browser/{anchor-sort-VHURGBOY.mjs → anchor-sort-3N44DS5F.mjs} +5 -5
- package/dist/lib/browser/{anchor-sort-VHURGBOY.mjs.map → anchor-sort-3N44DS5F.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-SI4X5GUR.mjs → chunk-ADK2HW4A.mjs} +25 -11
- package/dist/lib/browser/chunk-ADK2HW4A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6AKBCBL4.mjs → chunk-CSBSADPQ.mjs} +2 -4
- package/dist/lib/browser/chunk-CSBSADPQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7HQX4NQP.mjs → chunk-SSN4HYJL.mjs} +6 -6
- package/dist/lib/browser/chunk-SSN4HYJL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JUOVL3LE.mjs → chunk-ZJWJMX4E.mjs} +208 -203
- package/dist/lib/browser/chunk-ZJWJMX4E.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KJWZUQVA.mjs → chunk-ZMPNHFIP.mjs} +4 -4
- package/dist/lib/browser/chunk-ZMPNHFIP.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +12 -13
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-WOJGZMSV.mjs → intent-resolver-BQLV6IAA.mjs} +8 -8
- package/dist/lib/browser/intent-resolver-BQLV6IAA.mjs.map +7 -0
- package/dist/lib/browser/{markdown-VXMIPUQC.mjs → markdown-RMTMI237.mjs} +6 -6
- package/dist/lib/browser/markdown-RMTMI237.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-SE4HGAEH.mjs → react-surface-7ZDMQDCT.mjs} +11 -11
- package/dist/lib/browser/react-surface-7ZDMQDCT.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{SheetContainer-RMG24NZC.mjs → SheetContainer-NWJ7L6FC.mjs} +29 -29
- package/dist/lib/node-esm/SheetContainer-NWJ7L6FC.mjs.map +7 -0
- package/dist/lib/node-esm/{anchor-sort-CTJGOPET.mjs → anchor-sort-YL2OZHYM.mjs} +5 -5
- package/dist/lib/node-esm/{anchor-sort-CTJGOPET.mjs.map → anchor-sort-YL2OZHYM.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-CADTJFAS.mjs → chunk-BZAPYBSH.mjs} +25 -11
- package/dist/lib/node-esm/chunk-BZAPYBSH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3K5VNYOF.mjs → chunk-H3GSD33H.mjs} +2 -4
- package/dist/lib/node-esm/chunk-H3GSD33H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Q6UYC4G5.mjs → chunk-IK4O7FUJ.mjs} +6 -6
- package/dist/lib/node-esm/chunk-IK4O7FUJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6SK5LJ5S.mjs → chunk-LN6ZSAII.mjs} +4 -4
- package/dist/lib/node-esm/chunk-LN6ZSAII.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IFMIRCZH.mjs → chunk-YL7BVJPC.mjs} +208 -203
- package/dist/lib/node-esm/chunk-YL7BVJPC.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +12 -13
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-PZRXBNIJ.mjs → intent-resolver-MV5ZFXAQ.mjs} +8 -8
- package/dist/lib/node-esm/intent-resolver-MV5ZFXAQ.mjs.map +7 -0
- package/dist/lib/node-esm/{markdown-4VPQJZNZ.mjs → markdown-EDIWHA3P.mjs} +6 -6
- package/dist/lib/node-esm/markdown-EDIWHA3P.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-LAU23XBH.mjs → react-surface-TUME5MM2.mjs} +11 -11
- package/dist/lib/node-esm/react-surface-TUME5MM2.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/SheetPlugin.d.ts +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort.d.ts +2 -2
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +1 -1
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -8
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +1 -3
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +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 +9 -4
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +50 -3
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +11 -20
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +52 -5
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +86 -4
- 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.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.stories.d.ts +10 -13
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/index.d.ts +1 -1
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
- package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.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/playwright/sheet-manager.d.ts +1 -1
- package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +1 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +8 -8
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +65 -63
- package/src/SheetPlugin.tsx +69 -61
- package/src/capabilities/anchor-sort.ts +1 -1
- package/src/capabilities/capabilities.ts +2 -2
- package/src/capabilities/compute-graph-registry.ts +9 -14
- package/src/capabilities/intent-resolver.ts +4 -4
- package/src/capabilities/markdown.ts +3 -2
- package/src/capabilities/react-surface.tsx +5 -4
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +15 -14
- package/src/components/GridSheet/GridSheet.stories.tsx +18 -12
- package/src/components/GridSheet/GridSheet.tsx +23 -22
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +39 -41
- package/src/components/GridSheet/util.ts +6 -6
- package/src/components/RangeList/RangeList.tsx +3 -3
- package/src/components/SheetContainer/SheetContainer.stories.tsx +40 -39
- package/src/components/SheetContainer/SheetContainer.tsx +6 -2
- package/src/components/SheetContext/SheetContext.tsx +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
- package/src/components/SheetToolbar/SheetToolbar.tsx +16 -15
- package/src/components/SheetToolbar/align.ts +7 -6
- package/src/components/SheetToolbar/style.ts +4 -4
- package/src/extensions/compute.stories.tsx +28 -24
- package/src/extensions/compute.ts +2 -3
- package/src/extensions/editor/index.ts +1 -1
- package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
- package/src/integrations/thread-ranges.ts +9 -8
- package/src/meta.ts +1 -3
- package/src/model/sheet-model.test.ts +2 -1
- package/src/model/sheet-model.ts +7 -7
- package/src/playwright/sheet-manager.ts +1 -1
- package/src/playwright/sheet.spec.ts +1 -1
- package/src/sanity.test.ts +1 -1
- package/src/testing/testing.tsx +9 -3
- package/src/types/schema.ts +1 -1
- package/src/types/types.ts +5 -4
- package/src/types/util.ts +3 -3
- package/dist/lib/browser/SheetContainer-KDGD4AVG.mjs.map +0 -7
- package/dist/lib/browser/chunk-6AKBCBL4.mjs.map +0 -7
- package/dist/lib/browser/chunk-7HQX4NQP.mjs.map +0 -7
- package/dist/lib/browser/chunk-JUOVL3LE.mjs.map +0 -7
- package/dist/lib/browser/chunk-KJWZUQVA.mjs.map +0 -7
- package/dist/lib/browser/chunk-SI4X5GUR.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-VG7VP7IV.mjs +0 -30
- package/dist/lib/browser/compute-graph-registry-VG7VP7IV.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-WOJGZMSV.mjs.map +0 -7
- package/dist/lib/browser/markdown-VXMIPUQC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SE4HGAEH.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-RMG24NZC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3K5VNYOF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CADTJFAS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IFMIRCZH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Q6UYC4G5.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-3K3Q2A5T.mjs +0 -31
- package/dist/lib/node-esm/compute-graph-registry-3K3Q2A5T.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-PZRXBNIJ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-4VPQJZNZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LAU23XBH.mjs.map +0 -7
- package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
- /package/src/extensions/editor/{extension.ts → sheet-extension.ts} +0 -0
|
@@ -3,42 +3,43 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import React, {
|
|
6
|
+
type FocusEvent,
|
|
7
|
+
type KeyboardEvent,
|
|
8
|
+
type MouseEvent,
|
|
9
|
+
type WheelEvent,
|
|
6
10
|
useCallback,
|
|
7
11
|
useMemo,
|
|
8
12
|
useRef,
|
|
9
13
|
useState,
|
|
10
|
-
type FocusEvent,
|
|
11
|
-
type KeyboardEvent,
|
|
12
|
-
type WheelEvent,
|
|
13
|
-
type MouseEvent,
|
|
14
14
|
} from 'react';
|
|
15
15
|
|
|
16
16
|
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
17
|
-
import {
|
|
17
|
+
import { type CellRange, rangeToA1Notation } from '@dxos/compute';
|
|
18
18
|
import { defaultColSize, defaultRowSize } from '@dxos/lit-grid';
|
|
19
19
|
import { DropdownMenu, Icon, useTranslation } from '@dxos/react-ui';
|
|
20
20
|
import { useAttention } from '@dxos/react-ui-attention';
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
editorKeys,
|
|
24
|
-
parseCellIndex,
|
|
25
|
-
Grid,
|
|
26
|
-
GridCellEditor,
|
|
22
|
+
type DxGridCellIndex,
|
|
27
23
|
type DxGridElement,
|
|
28
24
|
type DxGridPosition,
|
|
29
|
-
type DxGridCellIndex,
|
|
30
|
-
type EditorKeyHandler,
|
|
31
25
|
type EditorBlurHandler,
|
|
26
|
+
type EditorKeyHandler,
|
|
27
|
+
Grid,
|
|
28
|
+
GridCellEditor,
|
|
32
29
|
type GridContentProps,
|
|
30
|
+
closestCell,
|
|
31
|
+
editorKeys,
|
|
32
|
+
parseCellIndex,
|
|
33
33
|
} from '@dxos/react-ui-grid';
|
|
34
34
|
|
|
35
|
-
import {
|
|
36
|
-
import { rangeExtension, sheetExtension, type RangeController } from '../../extensions';
|
|
35
|
+
import { type RangeController, rangeExtension, sheetExtension } from '../../extensions';
|
|
37
36
|
import { useSelectThreadOnCellFocus, useUpdateFocusedCellOnThreadSelection } from '../../integrations';
|
|
38
|
-
import {
|
|
37
|
+
import { meta } from '../../meta';
|
|
39
38
|
import { DEFAULT_COLS, DEFAULT_ROWS, SheetAction } from '../../types';
|
|
40
39
|
import { useSheetContext } from '../SheetContext';
|
|
41
40
|
|
|
41
|
+
import { colLabelCell, rowLabelCell, useSheetModelDxGridProps } from './util';
|
|
42
|
+
|
|
42
43
|
const inertPosition: DxGridPosition = { plane: 'grid', col: 0, row: 0 };
|
|
43
44
|
|
|
44
45
|
const initialCells = {
|
|
@@ -59,16 +60,16 @@ const frozen = {
|
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
const sheetColDefault = {
|
|
62
|
-
frozenColsStart: { size: 48, readonly: true },
|
|
63
|
+
frozenColsStart: { size: 48, readonly: true, focusUnfurl: false },
|
|
63
64
|
grid: { size: defaultColSize, resizeable: true },
|
|
64
65
|
};
|
|
65
66
|
const sheetRowDefault = {
|
|
66
|
-
frozenRowsStart: { size: defaultRowSize, readonly: true },
|
|
67
|
+
frozenRowsStart: { size: defaultRowSize, readonly: true, focusUnfurl: false },
|
|
67
68
|
grid: { size: defaultRowSize, resizeable: true },
|
|
68
69
|
};
|
|
69
70
|
|
|
70
71
|
export const GridSheet = () => {
|
|
71
|
-
const { t } = useTranslation(
|
|
72
|
+
const { t } = useTranslation(meta.id);
|
|
72
73
|
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } =
|
|
73
74
|
useSheetContext();
|
|
74
75
|
// NOTE(thure): using `useState` instead of `useRef` works with refs provided by `@lit/react` and gives us
|
|
@@ -76,7 +77,7 @@ export const GridSheet = () => {
|
|
|
76
77
|
const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
|
|
77
78
|
const [extraplanarFocus, setExtraplanarFocus] = useState<DxGridPosition | null>(null);
|
|
78
79
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
79
|
-
const rangeController = useRef<RangeController>();
|
|
80
|
+
const rangeController = useRef<RangeController>(null);
|
|
80
81
|
const { hasAttention } = useAttention(id);
|
|
81
82
|
|
|
82
83
|
const handleFocus = useCallback(
|
|
@@ -278,7 +279,7 @@ export const GridSheet = () => {
|
|
|
278
279
|
|
|
279
280
|
const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
|
|
280
281
|
|
|
281
|
-
const
|
|
282
|
+
const extensions = useMemo(
|
|
282
283
|
() => [
|
|
283
284
|
editorKeys({ onClose: handleClose, ...(editing?.initialContent && { onNav: handleClose }) }),
|
|
284
285
|
sheetExtension({ functions: model.graph.getFunctions() }),
|
|
@@ -307,8 +308,8 @@ export const GridSheet = () => {
|
|
|
307
308
|
|
|
308
309
|
return (
|
|
309
310
|
// TODO(thure): Why are Table’s and Sheet’s editor boxes off by 1px?
|
|
310
|
-
<div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent
|
|
311
|
-
<GridCellEditor getCellContent={getCellContent}
|
|
311
|
+
<div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent'>
|
|
312
|
+
<GridCellEditor getCellContent={getCellContent} extensions={extensions} onBlur={handleBlur} />
|
|
312
313
|
<Grid.Content
|
|
313
314
|
initialCells={initialCells}
|
|
314
315
|
limitColumns={DEFAULT_COLS}
|
|
@@ -2,53 +2,48 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
8
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useMemo, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Client } from '@dxos/client';
|
|
11
9
|
import { createDocAccessor } from '@dxos/client/echo';
|
|
12
10
|
import { defaultFunctions } from '@dxos/compute';
|
|
13
11
|
import { getRegisteredFunctionNames } from '@dxos/compute/testing';
|
|
12
|
+
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
14
|
import { automerge } from '@dxos/react-ui-editor';
|
|
15
15
|
import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
|
|
16
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
17
16
|
|
|
18
17
|
import { sheetExtension } from '../../extensions';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
type StoryProps = CellEditorProps;
|
|
18
|
+
import { SheetType, createSheet } from '../../types';
|
|
22
19
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
20
|
+
const DefaultStory = ({ value, ...props }: CellEditorProps) => {
|
|
21
|
+
const extensions = useMemo(() => {
|
|
25
22
|
const functionNames = getRegisteredFunctionNames();
|
|
26
23
|
const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
|
|
27
24
|
return [sheetExtension({ functions })];
|
|
28
25
|
}, []);
|
|
29
26
|
|
|
30
|
-
return <CellEditor {...props} value={value}
|
|
27
|
+
return <CellEditor {...props} value={value} extensions={extensions} />;
|
|
31
28
|
};
|
|
32
29
|
|
|
33
|
-
const AutomergeStory = ({ value, ...props }:
|
|
30
|
+
const AutomergeStory = ({ value, ...props }: CellEditorProps) => {
|
|
34
31
|
const cell = 'A1';
|
|
35
32
|
const [object, setObject] = useState<SheetType>();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
setObject(sheet);
|
|
48
|
-
});
|
|
33
|
+
useAsyncEffect(async () => {
|
|
34
|
+
const client = new Client({ types: [SheetType] });
|
|
35
|
+
await client.initialize();
|
|
36
|
+
await client.halo.createIdentity();
|
|
37
|
+
const space = await client.spaces.create();
|
|
38
|
+
|
|
39
|
+
const sheet = createSheet();
|
|
40
|
+
sheet.name = 'Test';
|
|
41
|
+
sheet.cells[cell] = { value };
|
|
42
|
+
space.db.add(sheet);
|
|
43
|
+
setObject(sheet);
|
|
49
44
|
}, [value]);
|
|
50
45
|
|
|
51
|
-
const
|
|
46
|
+
const extensions = useMemo(() => {
|
|
52
47
|
if (!object) {
|
|
53
48
|
return [];
|
|
54
49
|
}
|
|
@@ -59,35 +54,38 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
|
|
|
59
54
|
return [automerge(accessor), sheetExtension({ functions })];
|
|
60
55
|
}, [object]);
|
|
61
56
|
|
|
62
|
-
return <CellEditor {...props} value={value}
|
|
57
|
+
return <CellEditor {...props} value={value} extensions={extensions} />;
|
|
63
58
|
};
|
|
64
59
|
|
|
65
|
-
|
|
60
|
+
const meta = {
|
|
61
|
+
title: 'plugins/plugin-sheet/CellEditor',
|
|
62
|
+
|
|
63
|
+
decorators: [withTheme],
|
|
64
|
+
component: CellEditor,
|
|
65
|
+
render: DefaultStory,
|
|
66
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
67
|
+
|
|
68
|
+
export default meta;
|
|
69
|
+
|
|
70
|
+
type Story = StoryObj<typeof meta>;
|
|
66
71
|
|
|
67
|
-
export const
|
|
72
|
+
export const Default: Story = {};
|
|
73
|
+
|
|
74
|
+
export const AutoComplete: Story = {
|
|
68
75
|
args: {
|
|
69
76
|
value: '=SUM',
|
|
70
77
|
},
|
|
71
78
|
};
|
|
72
79
|
|
|
73
|
-
export const Formatting = {
|
|
80
|
+
export const Formatting: Story = {
|
|
74
81
|
args: {
|
|
75
82
|
value: '=SUM(A1:A2, 100, TRUE, "100", SUM(A1:A2, B1:B2))',
|
|
76
83
|
},
|
|
77
84
|
};
|
|
78
85
|
|
|
79
|
-
export const Automerge = {
|
|
80
|
-
render:
|
|
86
|
+
export const Automerge: Story = {
|
|
87
|
+
render: AutomergeStory,
|
|
81
88
|
args: {
|
|
82
89
|
value: '=SUM(A1:A2, 100, TRUE, "100", SUM(A1:A2, B1:B2))',
|
|
83
90
|
},
|
|
84
91
|
};
|
|
85
|
-
|
|
86
|
-
const meta: Meta = {
|
|
87
|
-
title: 'plugins/plugin-sheet/CellEditor',
|
|
88
|
-
component: CellEditor,
|
|
89
|
-
decorators: [withTheme],
|
|
90
|
-
render: (args: StoryProps) => <Story {...args} />,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default meta;
|
|
@@ -6,18 +6,18 @@ import { useEffect, useState } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { inRange } from '@dxos/compute';
|
|
8
8
|
import { createDocAccessor } from '@dxos/react-client/echo';
|
|
9
|
-
import {
|
|
9
|
+
import { cellClassesForFieldType, parseValue } from '@dxos/react-ui-form';
|
|
10
10
|
import {
|
|
11
|
-
type GridContentProps,
|
|
12
|
-
type DxGridElement,
|
|
13
11
|
type DxGridAxisMeta,
|
|
12
|
+
type DxGridCellValue,
|
|
13
|
+
type DxGridElement,
|
|
14
14
|
type DxGridPlane,
|
|
15
|
-
type DxGridPlaneRange,
|
|
16
15
|
type DxGridPlaneCells,
|
|
17
|
-
type
|
|
16
|
+
type DxGridPlaneRange,
|
|
17
|
+
type GridContentProps,
|
|
18
18
|
colToA1Notation,
|
|
19
|
-
rowToA1Notation,
|
|
20
19
|
commentedClassName,
|
|
20
|
+
rowToA1Notation,
|
|
21
21
|
} from '@dxos/react-ui-grid';
|
|
22
22
|
import { mx } from '@dxos/react-ui-theme';
|
|
23
23
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
|
|
8
8
|
import { rangeToA1Notation } from '@dxos/compute';
|
|
@@ -10,7 +10,7 @@ import { Callout, useTranslation } from '@dxos/react-ui';
|
|
|
10
10
|
import { List } from '@dxos/react-ui-list';
|
|
11
11
|
import { ghostHover } from '@dxos/react-ui-theme';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { meta } from '../../meta';
|
|
14
14
|
import { rangeFromIndex } from '../../types';
|
|
15
15
|
import { Range, type SheetType } from '../../types';
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ export type RangeListProps = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export const RangeList = ({ sheet }: RangeListProps) => {
|
|
22
|
-
const { t } = useTranslation(
|
|
22
|
+
const { t } = useTranslation(meta.id);
|
|
23
23
|
// TODO(thure): Implement similar to comments, #8121
|
|
24
24
|
const handleSelectRange = (range: Range) => {};
|
|
25
25
|
const handleDeleteRange = useCallback(
|
|
@@ -2,28 +2,59 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import { Capabilities, contributes, createResolver
|
|
8
|
+
import { Capabilities, IntentPlugin, contributes, createResolver } from '@dxos/app-framework';
|
|
11
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
10
|
import { GraphPlugin } from '@dxos/plugin-graph';
|
|
13
11
|
import { fullyQualifiedId, useSpace } from '@dxos/react-client/echo';
|
|
14
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
14
|
import { AttendableContainer } from '@dxos/react-ui-attention';
|
|
16
15
|
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
17
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
18
16
|
|
|
19
|
-
import { SheetContainer } from './SheetContainer';
|
|
20
17
|
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
21
18
|
import { translations } from '../../translations';
|
|
22
19
|
import { SheetAction, SheetType } from '../../types';
|
|
23
20
|
import { useComputeGraph } from '../ComputeGraph';
|
|
24
21
|
import { RangeList } from '../RangeList';
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
import { SheetContainer } from './SheetContainer';
|
|
24
|
+
|
|
25
|
+
const meta = {
|
|
26
|
+
title: 'plugins/plugin-sheet/SheetContainer',
|
|
27
|
+
component: SheetContainer,
|
|
28
|
+
decorators: [
|
|
29
|
+
withTheme,
|
|
30
|
+
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
31
|
+
withComputeGraphDecorator(),
|
|
32
|
+
withAttention,
|
|
33
|
+
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
34
|
+
withPluginManager({
|
|
35
|
+
plugins: [IntentPlugin(), GraphPlugin()],
|
|
36
|
+
capabilities: [
|
|
37
|
+
contributes(
|
|
38
|
+
Capabilities.IntentResolver,
|
|
39
|
+
createResolver({
|
|
40
|
+
intent: SheetAction.DropAxis,
|
|
41
|
+
resolve: ({ model, axis, axisIndex }) => {
|
|
42
|
+
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
),
|
|
46
|
+
],
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
parameters: {
|
|
50
|
+
layout: 'fullscreen',
|
|
51
|
+
translations,
|
|
52
|
+
},
|
|
53
|
+
} satisfies Meta<typeof SheetContainer>;
|
|
54
|
+
|
|
55
|
+
export default meta;
|
|
56
|
+
|
|
57
|
+
export const Default = () => {
|
|
27
58
|
const space = useSpace();
|
|
28
59
|
const graph = useComputeGraph(space);
|
|
29
60
|
const sheet = useTestSheet(space, graph, { cells: createTestCells() });
|
|
@@ -33,7 +64,7 @@ export const Basic = () => {
|
|
|
33
64
|
|
|
34
65
|
return (
|
|
35
66
|
<AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
|
|
36
|
-
<SheetContainer space={space} sheet={sheet} role='
|
|
67
|
+
<SheetContainer space={space} sheet={sheet} role='story' ignoreAttention />
|
|
37
68
|
</AttendableContainer>
|
|
38
69
|
);
|
|
39
70
|
};
|
|
@@ -48,8 +79,8 @@ export const Spec = () => {
|
|
|
48
79
|
|
|
49
80
|
return (
|
|
50
81
|
<AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
|
|
51
|
-
<div role='none' className='grid grid-rows-[66%_33%] grid-cols-1'>
|
|
52
|
-
<SheetContainer space={space} sheet={sheet} role='
|
|
82
|
+
<div role='none' className='grid grid-rows-[66%_33%] bs-full grid-cols-1'>
|
|
83
|
+
<SheetContainer space={space} sheet={sheet} role='story' ignoreAttention />
|
|
53
84
|
<div role='none' data-testid='grid.range-list'>
|
|
54
85
|
<RangeList sheet={sheet} />
|
|
55
86
|
</div>
|
|
@@ -57,33 +88,3 @@ export const Spec = () => {
|
|
|
57
88
|
</AttendableContainer>
|
|
58
89
|
);
|
|
59
90
|
};
|
|
60
|
-
|
|
61
|
-
const meta: Meta = {
|
|
62
|
-
title: 'plugins/plugin-sheet/SheetContainer',
|
|
63
|
-
component: SheetContainer,
|
|
64
|
-
decorators: [
|
|
65
|
-
withClientProvider({ types: [SheetType], createSpace: true }),
|
|
66
|
-
withComputeGraphDecorator(),
|
|
67
|
-
withTheme,
|
|
68
|
-
withLayout({ fullscreen: true, classNames: 'grid' }),
|
|
69
|
-
withAttention,
|
|
70
|
-
// TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
|
|
71
|
-
withPluginManager({
|
|
72
|
-
plugins: [IntentPlugin(), GraphPlugin()],
|
|
73
|
-
capabilities: [
|
|
74
|
-
contributes(
|
|
75
|
-
Capabilities.IntentResolver,
|
|
76
|
-
createResolver({
|
|
77
|
-
intent: SheetAction.DropAxis,
|
|
78
|
-
resolve: ({ model, axis, axisIndex }) => {
|
|
79
|
-
model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
|
|
80
|
-
},
|
|
81
|
-
}),
|
|
82
|
-
),
|
|
83
|
-
],
|
|
84
|
-
}),
|
|
85
|
-
],
|
|
86
|
-
parameters: { translations },
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export default meta;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type Space, fullyQualifiedId } from '@dxos/react-client/echo';
|
|
8
8
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
9
|
|
|
10
10
|
import { type SheetType } from '../../types';
|
|
@@ -26,7 +26,11 @@ export const SheetContainer = ({ space, sheet, role, ignoreAttention }: SheetCon
|
|
|
26
26
|
|
|
27
27
|
return graph ? (
|
|
28
28
|
<SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>
|
|
29
|
-
<StackItem.Content
|
|
29
|
+
<StackItem.Content
|
|
30
|
+
toolbar
|
|
31
|
+
statusbar
|
|
32
|
+
classNames={[role === 'section' && 'aspect-video', role === 'story' && 'bs-full']}
|
|
33
|
+
>
|
|
30
34
|
<SheetToolbar id={fullyQualifiedId(sheet)} />
|
|
31
35
|
<GridSheet />
|
|
32
36
|
<FunctionEditor />
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type CellAddress, type CellRange, type CompleteCellRange, type ComputeGraph } from '@dxos/compute';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
10
10
|
import {
|
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
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
|
-
import { SheetToolbar } from './SheetToolbar';
|
|
13
10
|
import { translations } from '../../translations';
|
|
14
11
|
|
|
12
|
+
import { SheetToolbar } from './SheetToolbar';
|
|
13
|
+
|
|
15
14
|
const DefaultStory = () => {
|
|
16
|
-
|
|
15
|
+
// TODO(wittjosiah): Depends on SheetProvider.
|
|
16
|
+
// return <SheetToolbar id='test' />;
|
|
17
|
+
return <>TODO</>;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const meta: Meta = {
|
|
20
|
+
const meta = {
|
|
22
21
|
title: 'plugins/plugin-sheet/Toolbar',
|
|
23
|
-
component: SheetToolbar,
|
|
22
|
+
component: SheetToolbar as any,
|
|
24
23
|
render: DefaultStory,
|
|
25
|
-
decorators: [withTheme
|
|
26
|
-
parameters: {
|
|
27
|
-
|
|
24
|
+
decorators: [withTheme],
|
|
25
|
+
parameters: {
|
|
26
|
+
layout: 'fullscreen',
|
|
27
|
+
translations,
|
|
28
|
+
},
|
|
29
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
28
30
|
|
|
29
31
|
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof meta>;
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {};
|
|
@@ -9,21 +9,20 @@ import { useAppGraph } from '@dxos/app-framework';
|
|
|
9
9
|
import { type CompleteCellRange } from '@dxos/compute';
|
|
10
10
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
11
|
import {
|
|
12
|
-
type ActionGraphEdges,
|
|
13
|
-
type ActionGraphNodes,
|
|
14
12
|
type ActionGraphProps,
|
|
15
|
-
createGapSeparator,
|
|
16
13
|
MenuProvider,
|
|
17
|
-
rxFromSignal,
|
|
18
14
|
ToolbarMenu,
|
|
15
|
+
createGapSeparator,
|
|
16
|
+
rxFromSignal,
|
|
19
17
|
useMenuActions,
|
|
20
18
|
} from '@dxos/react-ui-menu';
|
|
21
19
|
|
|
20
|
+
import { type SheetModel } from '../../model';
|
|
21
|
+
import { useSheetContext } from '../SheetContext';
|
|
22
|
+
|
|
22
23
|
import { createAlign, useAlignState } from './align';
|
|
23
24
|
import { createStyle, useStyleState } from './style';
|
|
24
25
|
import { type ToolbarState, useToolbarState } from './useToolbarState';
|
|
25
|
-
import { type SheetModel } from '../../model';
|
|
26
|
-
import { useSheetContext } from '../SheetContext';
|
|
27
26
|
|
|
28
27
|
//
|
|
29
28
|
// Root
|
|
@@ -36,22 +35,24 @@ const createToolbarActions = (
|
|
|
36
35
|
state: ToolbarState,
|
|
37
36
|
cursorFallbackRange?: CompleteCellRange,
|
|
38
37
|
customActions?: Rx.Rx<ActionGraphProps>,
|
|
39
|
-
) => {
|
|
38
|
+
): Rx.Rx<ActionGraphProps> => {
|
|
40
39
|
return Rx.make((get) => {
|
|
41
40
|
const align = get(rxFromSignal(() => createAlign(model, state, cursorFallbackRange)));
|
|
42
41
|
const style = get(rxFromSignal(() => createStyle(model, state, cursorFallbackRange)));
|
|
43
42
|
const gap = createGapSeparator();
|
|
44
|
-
|
|
45
|
-
const
|
|
43
|
+
|
|
44
|
+
const graph: ActionGraphProps = {
|
|
45
|
+
nodes: [...align.nodes, ...style.nodes, ...gap.nodes],
|
|
46
|
+
edges: [...align.edges, ...style.edges, ...gap.edges],
|
|
47
|
+
};
|
|
48
|
+
|
|
46
49
|
if (customActions) {
|
|
47
50
|
const custom = get(customActions);
|
|
48
|
-
nodes.push(...custom.nodes);
|
|
49
|
-
edges.push(...custom.edges);
|
|
51
|
+
graph.nodes.push(...custom.nodes);
|
|
52
|
+
graph.edges.push(...custom.edges);
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
edges,
|
|
54
|
-
};
|
|
54
|
+
|
|
55
|
+
return graph;
|
|
55
56
|
});
|
|
56
57
|
};
|
|
57
58
|
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import { createMenuAction, createMenuItemGroup
|
|
8
|
+
import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import { SHEET_PLUGIN } from '../../meta';
|
|
10
|
+
import { meta } from '../../meta';
|
|
12
11
|
import { type SheetModel } from '../../model';
|
|
13
|
-
import { type AlignKey,
|
|
12
|
+
import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
|
|
14
13
|
import { useSheetContext } from '../SheetContext';
|
|
15
14
|
|
|
15
|
+
import { type ToolbarState } from './useToolbarState';
|
|
16
|
+
|
|
16
17
|
export type AlignAction = { key: AlignKey; value: AlignValue };
|
|
17
18
|
|
|
18
19
|
export type AlignState = { [alignKey]: AlignValue | undefined };
|
|
@@ -39,7 +40,7 @@ export const useAlignState = (state: Partial<AlignState>) => {
|
|
|
39
40
|
|
|
40
41
|
const createAlignGroupAction = (value?: AlignValue) =>
|
|
41
42
|
createMenuItemGroup('align', {
|
|
42
|
-
label: ['align label', { ns:
|
|
43
|
+
label: ['align label', { ns: meta.id }],
|
|
43
44
|
variant: 'toggleGroup',
|
|
44
45
|
selectCardinality: 'single',
|
|
45
46
|
value: `${alignKey}--${value}`,
|
|
@@ -78,7 +79,7 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
|
|
|
78
79
|
key: alignKey,
|
|
79
80
|
value: alignValue as AlignValue,
|
|
80
81
|
checked: state[alignKey] === alignValue,
|
|
81
|
-
label: [`range value ${alignValue} label`, { ns:
|
|
82
|
+
label: [`range value ${alignValue} label`, { ns: meta.id }],
|
|
82
83
|
icon,
|
|
83
84
|
testId: `grid.toolbar.${alignKey}.${alignValue}`,
|
|
84
85
|
},
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type CompleteCellRange, inRange } from '@dxos/compute';
|
|
8
|
-
import { createMenuAction, createMenuItemGroup
|
|
8
|
+
import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { meta } from '../../meta';
|
|
11
11
|
import { type SheetModel } from '../../model';
|
|
12
|
-
import {
|
|
12
|
+
import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
|
|
13
13
|
import { useSheetContext } from '../SheetContext';
|
|
14
14
|
|
|
15
15
|
export type StyleState = Partial<Record<StyleValue, boolean>>;
|
|
@@ -89,7 +89,7 @@ const createStyleActions = (model: SheetModel, state: StyleState, cursorFallback
|
|
|
89
89
|
key: 'style',
|
|
90
90
|
value: styleValue as StyleValue,
|
|
91
91
|
icon,
|
|
92
|
-
label: [`range value ${styleValue} label`, { ns:
|
|
92
|
+
label: [`range value ${styleValue} label`, { ns: meta.id }],
|
|
93
93
|
checked: !!state[styleValue as StyleValue],
|
|
94
94
|
},
|
|
95
95
|
);
|