@dxos/plugin-sheet 0.8.4-main.28f8d3d → 0.8.4-main.2c6827d

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.
Files changed (195) hide show
  1. package/dist/lib/browser/{SheetContainer-JZNFXBW3.mjs → SheetContainer-67YEU5EA.mjs} +41 -43
  2. package/dist/lib/browser/SheetContainer-67YEU5EA.mjs.map +7 -0
  3. package/dist/lib/browser/anchor-sort-FCQ5OZZK.mjs +23 -0
  4. package/dist/lib/browser/anchor-sort-FCQ5OZZK.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-BVTHIA5U.mjs → chunk-6WBJDEKF.mjs} +37 -32
  6. package/dist/lib/browser/chunk-6WBJDEKF.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-KJWZUQVA.mjs → chunk-73AV3NH6.mjs} +4 -4
  8. package/dist/lib/browser/chunk-73AV3NH6.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-VTTKAHAY.mjs → chunk-7VEWYJJN.mjs} +2 -2
  10. package/dist/lib/browser/chunk-7VEWYJJN.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-ELAASQ5H.mjs → chunk-DVJ3QW3F.mjs} +215 -207
  12. package/dist/lib/browser/chunk-DVJ3QW3F.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-FWFAAGXL.mjs +28 -0
  14. package/dist/lib/browser/chunk-FWFAAGXL.mjs.map +7 -0
  15. package/dist/lib/browser/compute-graph-registry-AP5RA7W3.mjs +21 -0
  16. package/dist/lib/browser/compute-graph-registry-AP5RA7W3.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +20 -21
  18. package/dist/lib/browser/index.mjs.map +3 -3
  19. package/dist/lib/browser/{intent-resolver-SSLPTP5O.mjs → intent-resolver-66OAYVQF.mjs} +9 -9
  20. package/dist/lib/browser/intent-resolver-66OAYVQF.mjs.map +7 -0
  21. package/dist/lib/browser/{markdown-3VPZYNGU.mjs → markdown-B6VKYY2S.mjs} +6 -6
  22. package/dist/lib/browser/{markdown-3VPZYNGU.mjs.map → markdown-B6VKYY2S.mjs.map} +1 -1
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/{react-surface-Y7KTPJW2.mjs → react-surface-HARAYCN7.mjs} +16 -15
  25. package/dist/lib/browser/react-surface-HARAYCN7.mjs.map +7 -0
  26. package/dist/lib/browser/types/index.mjs +4 -12
  27. package/dist/lib/node-esm/{SheetContainer-GOIBAE2P.mjs → SheetContainer-NJONAMYZ.mjs} +41 -43
  28. package/dist/lib/node-esm/SheetContainer-NJONAMYZ.mjs.map +7 -0
  29. package/dist/lib/node-esm/{anchor-sort-YM2UBIKL.mjs → anchor-sort-ZE7IS7SH.mjs} +10 -11
  30. package/dist/lib/node-esm/anchor-sort-ZE7IS7SH.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-6SK5LJ5S.mjs → chunk-44YTKTMP.mjs} +4 -4
  32. package/dist/lib/node-esm/chunk-44YTKTMP.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-4L5CIB7E.mjs → chunk-4H2EHVWE.mjs} +215 -207
  34. package/dist/lib/node-esm/chunk-4H2EHVWE.mjs.map +7 -0
  35. package/dist/lib/node-esm/{chunk-FXRXBHWM.mjs → chunk-4QV4AGWK.mjs} +2 -2
  36. package/dist/lib/node-esm/chunk-4QV4AGWK.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-HILDMVPL.mjs +29 -0
  38. package/dist/lib/node-esm/chunk-HILDMVPL.mjs.map +7 -0
  39. package/dist/lib/node-esm/{chunk-56HYMW55.mjs → chunk-S3RJ7IY6.mjs} +37 -32
  40. package/dist/lib/node-esm/chunk-S3RJ7IY6.mjs.map +7 -0
  41. package/dist/lib/node-esm/compute-graph-registry-UMQ5UYCL.mjs +22 -0
  42. package/dist/lib/node-esm/compute-graph-registry-UMQ5UYCL.mjs.map +7 -0
  43. package/dist/lib/node-esm/index.mjs +20 -21
  44. package/dist/lib/node-esm/index.mjs.map +3 -3
  45. package/dist/lib/node-esm/{intent-resolver-5P6DBGK2.mjs → intent-resolver-VNKIMQQT.mjs} +9 -9
  46. package/dist/lib/node-esm/intent-resolver-VNKIMQQT.mjs.map +7 -0
  47. package/dist/lib/node-esm/{markdown-SFDGQWYE.mjs → markdown-VKY7HXU2.mjs} +6 -6
  48. package/dist/lib/node-esm/{markdown-SFDGQWYE.mjs.map → markdown-VKY7HXU2.mjs.map} +1 -1
  49. package/dist/lib/node-esm/meta.json +1 -1
  50. package/dist/lib/node-esm/{react-surface-6Z5FAOBH.mjs → react-surface-KTQWXV2L.mjs} +16 -15
  51. package/dist/lib/node-esm/react-surface-KTQWXV2L.mjs.map +7 -0
  52. package/dist/lib/node-esm/types/index.mjs +4 -12
  53. package/dist/types/src/SheetPlugin.d.ts +1 -1
  54. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  55. package/dist/types/src/capabilities/anchor-sort.d.ts +2 -4
  56. package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -1
  57. package/dist/types/src/capabilities/compute-graph-registry.d.ts +1 -1
  58. package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -1
  59. package/dist/types/src/capabilities/index.d.ts +5 -10
  60. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  61. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  62. package/dist/types/src/capabilities/markdown.d.ts +1 -3
  63. package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
  64. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  65. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  66. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +9 -4
  67. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
  68. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  69. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +50 -3
  70. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  71. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +11 -20
  72. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  73. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  74. package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
  75. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  76. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +2 -2
  77. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  78. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +52 -5
  79. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  80. package/dist/types/src/components/SheetContext/SheetContext.d.ts +2 -2
  81. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  82. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
  83. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
  84. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +86 -4
  85. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
  86. package/dist/types/src/extensions/compute.d.ts +1 -1
  87. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  88. package/dist/types/src/extensions/compute.stories.d.ts +10 -13
  89. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
  90. package/dist/types/src/extensions/editor/index.d.ts +1 -1
  91. package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
  92. package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
  93. package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
  94. package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
  95. package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
  96. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  97. package/dist/types/src/meta.d.ts +0 -1
  98. package/dist/types/src/meta.d.ts.map +1 -1
  99. package/dist/types/src/model/sheet-model.d.ts +5 -5
  100. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  101. package/dist/types/src/model/testing.d.ts +2 -2
  102. package/dist/types/src/model/testing.d.ts.map +1 -1
  103. package/dist/types/src/model/useSheetModel.d.ts +2 -2
  104. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  105. package/dist/types/src/serializer.d.ts +2 -2
  106. package/dist/types/src/serializer.d.ts.map +1 -1
  107. package/dist/types/src/testing/data.d.ts +2 -2
  108. package/dist/types/src/testing/data.d.ts.map +1 -1
  109. package/dist/types/src/testing/testing.d.ts +27 -3
  110. package/dist/types/src/testing/testing.d.ts.map +1 -1
  111. package/dist/types/src/translations.d.ts +2 -2
  112. package/dist/types/src/translations.d.ts.map +1 -1
  113. package/dist/types/src/types/{schema.d.ts → Sheet.d.ts} +37 -4
  114. package/dist/types/src/types/Sheet.d.ts.map +1 -0
  115. package/dist/types/src/types/index.d.ts +1 -1
  116. package/dist/types/src/types/index.d.ts.map +1 -1
  117. package/dist/types/src/types/sheet-range-types.d.ts +2 -2
  118. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
  119. package/dist/types/src/types/types.d.ts +7 -16
  120. package/dist/types/src/types/types.d.ts.map +1 -1
  121. package/dist/types/src/types/util.d.ts +9 -10
  122. package/dist/types/src/types/util.d.ts.map +1 -1
  123. package/dist/types/tsconfig.tsbuildinfo +1 -1
  124. package/package.json +65 -64
  125. package/src/SheetPlugin.tsx +70 -61
  126. package/src/capabilities/anchor-sort.ts +7 -8
  127. package/src/capabilities/capabilities.ts +2 -2
  128. package/src/capabilities/compute-graph-registry.ts +8 -13
  129. package/src/capabilities/intent-resolver.ts +4 -4
  130. package/src/capabilities/react-surface.tsx +9 -8
  131. package/src/components/ComputeGraph/compute-graph.stories.tsx +18 -18
  132. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
  133. package/src/components/GridSheet/GridSheet.stories.tsx +17 -12
  134. package/src/components/GridSheet/GridSheet.tsx +24 -12
  135. package/src/components/GridSheet/SheetCellEditor.stories.tsx +40 -42
  136. package/src/components/GridSheet/util.ts +9 -3
  137. package/src/components/RangeList/RangeList.tsx +8 -8
  138. package/src/components/SheetContainer/SheetContainer.stories.tsx +45 -42
  139. package/src/components/SheetContainer/SheetContainer.tsx +10 -5
  140. package/src/components/SheetContext/SheetContext.tsx +4 -4
  141. package/src/components/SheetToolbar/SheetToolbar.stories.tsx +17 -12
  142. package/src/components/SheetToolbar/SheetToolbar.tsx +27 -29
  143. package/src/components/SheetToolbar/align.ts +3 -3
  144. package/src/components/SheetToolbar/style.ts +2 -2
  145. package/src/extensions/compute.stories.tsx +29 -26
  146. package/src/extensions/compute.ts +1 -2
  147. package/src/extensions/editor/index.ts +1 -1
  148. package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
  149. package/src/integrations/thread-ranges.ts +15 -20
  150. package/src/meta.ts +7 -5
  151. package/src/model/sheet-model.test.ts +4 -4
  152. package/src/model/sheet-model.ts +4 -4
  153. package/src/model/testing.ts +4 -4
  154. package/src/model/useSheetModel.ts +2 -2
  155. package/src/sanity.test.ts +3 -4
  156. package/src/serializer.ts +3 -3
  157. package/src/testing/data.ts +2 -2
  158. package/src/testing/testing.tsx +11 -5
  159. package/src/translations.ts +2 -2
  160. package/src/types/Sheet.ts +103 -0
  161. package/src/types/index.ts +1 -1
  162. package/src/types/sheet-range-types.ts +2 -2
  163. package/src/types/types.ts +6 -16
  164. package/src/types/util.ts +10 -38
  165. package/dist/lib/browser/SheetContainer-JZNFXBW3.mjs.map +0 -7
  166. package/dist/lib/browser/anchor-sort-VRX3YZKT.mjs +0 -24
  167. package/dist/lib/browser/anchor-sort-VRX3YZKT.mjs.map +0 -7
  168. package/dist/lib/browser/chunk-6AKBCBL4.mjs +0 -18
  169. package/dist/lib/browser/chunk-6AKBCBL4.mjs.map +0 -7
  170. package/dist/lib/browser/chunk-BVTHIA5U.mjs.map +0 -7
  171. package/dist/lib/browser/chunk-ELAASQ5H.mjs.map +0 -7
  172. package/dist/lib/browser/chunk-KJWZUQVA.mjs.map +0 -7
  173. package/dist/lib/browser/chunk-VTTKAHAY.mjs.map +0 -7
  174. package/dist/lib/browser/compute-graph-registry-6YJHXORG.mjs +0 -30
  175. package/dist/lib/browser/compute-graph-registry-6YJHXORG.mjs.map +0 -7
  176. package/dist/lib/browser/intent-resolver-SSLPTP5O.mjs.map +0 -7
  177. package/dist/lib/browser/react-surface-Y7KTPJW2.mjs.map +0 -7
  178. package/dist/lib/node-esm/SheetContainer-GOIBAE2P.mjs.map +0 -7
  179. package/dist/lib/node-esm/anchor-sort-YM2UBIKL.mjs.map +0 -7
  180. package/dist/lib/node-esm/chunk-3K5VNYOF.mjs +0 -20
  181. package/dist/lib/node-esm/chunk-3K5VNYOF.mjs.map +0 -7
  182. package/dist/lib/node-esm/chunk-4L5CIB7E.mjs.map +0 -7
  183. package/dist/lib/node-esm/chunk-56HYMW55.mjs.map +0 -7
  184. package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs.map +0 -7
  185. package/dist/lib/node-esm/chunk-FXRXBHWM.mjs.map +0 -7
  186. package/dist/lib/node-esm/compute-graph-registry-ET5KJNLV.mjs +0 -31
  187. package/dist/lib/node-esm/compute-graph-registry-ET5KJNLV.mjs.map +0 -7
  188. package/dist/lib/node-esm/intent-resolver-5P6DBGK2.mjs.map +0 -7
  189. package/dist/lib/node-esm/react-surface-6Z5FAOBH.mjs.map +0 -7
  190. package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
  191. package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
  192. package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
  193. package/dist/types/src/types/schema.d.ts.map +0 -1
  194. package/src/types/schema.ts +0 -61
  195. /package/src/extensions/editor/{extension.ts → sheet-extension.ts} +0 -0
@@ -7,7 +7,7 @@ import { useEffect } from 'react';
7
7
  import { type CompleteCellRange, inRange } from '@dxos/compute';
8
8
  import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
9
9
 
10
- import { SHEET_PLUGIN } from '../../meta';
10
+ import { meta } from '../../meta';
11
11
  import { type SheetModel } from '../../model';
12
12
  import { type AlignKey, type AlignValue, alignKey, rangeFromIndex, rangeToIndex } from '../../types';
13
13
  import { useSheetContext } from '../SheetContext';
@@ -40,7 +40,7 @@ export const useAlignState = (state: Partial<AlignState>) => {
40
40
 
41
41
  const createAlignGroupAction = (value?: AlignValue) =>
42
42
  createMenuItemGroup('align', {
43
- label: ['align label', { ns: SHEET_PLUGIN }],
43
+ label: ['align label', { ns: meta.id }],
44
44
  variant: 'toggleGroup',
45
45
  selectCardinality: 'single',
46
46
  value: `${alignKey}--${value}`,
@@ -79,7 +79,7 @@ const createAlignActions = (model: SheetModel, state: ToolbarState, cursorFallba
79
79
  key: alignKey,
80
80
  value: alignValue as AlignValue,
81
81
  checked: state[alignKey] === alignValue,
82
- label: [`range value ${alignValue} label`, { ns: SHEET_PLUGIN }],
82
+ label: [`range value ${alignValue} label`, { ns: meta.id }],
83
83
  icon,
84
84
  testId: `grid.toolbar.${alignKey}.${alignValue}`,
85
85
  },
@@ -7,7 +7,7 @@ import { useEffect } from 'react';
7
7
  import { type CompleteCellRange, inRange } from '@dxos/compute';
8
8
  import { type ToolbarMenuActionGroupProperties, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
9
9
 
10
- import { SHEET_PLUGIN } from '../../meta';
10
+ import { meta } from '../../meta';
11
11
  import { type SheetModel } from '../../model';
12
12
  import { type StyleKey, type StyleValue, rangeFromIndex, rangeToIndex } from '../../types';
13
13
  import { useSheetContext } from '../SheetContext';
@@ -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: SHEET_PLUGIN }],
92
+ label: [`range value ${styleValue} label`, { ns: meta.id }],
93
93
  checked: !!state[styleValue as StyleValue],
94
94
  },
95
95
  );
@@ -2,15 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useEffect, useMemo } from 'react';
9
7
 
8
+ import { IntentPlugin } 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';
14
15
  import {
15
16
  createBasicExtensions,
16
17
  createMarkdownExtensions,
@@ -19,13 +20,12 @@ import {
19
20
  documentId,
20
21
  useTextEditor,
21
22
  } from '@dxos/react-ui-editor';
22
- import { withLayout, withTheme } from '@dxos/storybook-utils';
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 { SheetType } from '../types';
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 EditorStory = ({ text }: EditorProps) => {
45
+ const DefaultStory = ({ text }: EditorProps) => {
46
46
  const id = useMemo(() => PublicKey.random(), []);
47
47
  const { themeMode } = useThemeContext();
48
48
  const space = useSpace();
@@ -52,7 +52,7 @@ const EditorStory = ({ text }: EditorProps) => {
52
52
  initialValue: text,
53
53
  extensions: [
54
54
  createBasicExtensions(),
55
- createMarkdownExtensions({ themeMode }),
55
+ createMarkdownExtensions(),
56
56
  createThemeExtensions({ themeMode, syntaxHighlighting: true }),
57
57
  documentId.of(id.toHex()),
58
58
  computeGraph && computeGraphFacet.of(computeGraph),
@@ -63,7 +63,7 @@ const EditorStory = ({ text }: EditorProps) => {
63
63
  [computeGraph, themeMode],
64
64
  );
65
65
 
66
- return <div className='w-[40rem] overflow-hidden' ref={parentRef} {...focusAttributes} />;
66
+ return <div className='is-[40rem] overflow-hidden' ref={parentRef} {...focusAttributes} />;
67
67
  };
68
68
 
69
69
  const Grid = () => {
@@ -82,7 +82,7 @@ const Grid = () => {
82
82
  }
83
83
 
84
84
  return (
85
- <div className='flex w-[40rem] overflow-hidden'>
85
+ <div className='flex is-[40rem] overflow-hidden'>
86
86
  <SheetProvider graph={graph} sheet={sheet}>
87
87
  <GridSheet />
88
88
  </SheetProvider>
@@ -93,15 +93,31 @@ const Grid = () => {
93
93
  const GraphStory = (props: EditorProps) => {
94
94
  return (
95
95
  <div className='grid grid-rows-2'>
96
- <EditorStory {...props} />
96
+ <DefaultStory {...props} />
97
97
  <Grid />
98
98
  </div>
99
99
  );
100
100
  };
101
101
 
102
+ const meta = {
103
+ title: 'plugins/plugin-sheet/extensions',
104
+ decorators: [
105
+ withTheme,
106
+ withClientProvider({ types: [Sheet.Sheet], createIdentity: true, createSpace: true }),
107
+ // TODO(wittjosiah): Try to write story which does not depend on plugin manager.
108
+ withPluginManager({ plugins: [IntentPlugin()] }),
109
+ withComputeGraphDecorator(),
110
+ ],
111
+ parameters: {
112
+ layout: 'fullscreen',
113
+ },
114
+ } satisfies Meta;
115
+
116
+ export default meta;
117
+
102
118
  // TODO(burdon): Inline formulae.
103
- export const Default = {
104
- render: EditorStory,
119
+ export const Default: StoryObj<typeof DefaultStory> = {
120
+ render: DefaultStory,
105
121
  args: {
106
122
  text: str(
107
123
  //
@@ -124,7 +140,7 @@ export const Default = {
124
140
  },
125
141
  };
126
142
 
127
- export const Graph = {
143
+ export const Graph: StoryObj<typeof GraphStory> = {
128
144
  render: GraphStory,
129
145
  args: {
130
146
  text: str(
@@ -141,16 +157,3 @@ export const Graph = {
141
157
  ),
142
158
  },
143
159
  };
144
-
145
- const meta: Meta = {
146
- title: 'plugins/plugin-sheet/extensions',
147
- decorators: [
148
- withClientProvider({ types: [SheetType], createIdentity: true, createSpace: true }),
149
- withComputeGraphDecorator(),
150
- withTheme,
151
- withLayout({ fullscreen: true, classNames: 'justify-center' }),
152
- ],
153
- parameters: { layout: 'fullscreen' },
154
- };
155
-
156
- export default meta;
@@ -34,7 +34,7 @@ export const computeGraphFacet = singleValueFacet<ComputeGraph>();
34
34
 
35
35
  export type ComputeOptions = {};
36
36
 
37
- export const compute = (options: ComputeOptions = {}): Extension => {
37
+ export const compute = (_options: ComputeOptions = {}): Extension => {
38
38
  let computeNode: ComputeNode | undefined;
39
39
 
40
40
  const update = (state: EditorState, current?: RangeSet<Decoration>) => {
@@ -53,7 +53,6 @@ export const compute = (options: ComputeOptions = {}): Extension => {
53
53
  const text = node.node.getChild('CodeText');
54
54
  if (type === LANGUAGE_TAG && text) {
55
55
  const formula = state.sliceDoc(text.from, text.to);
56
-
57
56
  const iter = current?.iter(node.node.from);
58
57
  if (iter?.value && iter?.value.spec.formula === formula) {
59
58
  // Add existing widget.
@@ -2,4 +2,4 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './extension';
5
+ export * from './sheet-extension';
@@ -10,7 +10,7 @@ import { describe, expect, test } from 'vitest';
10
10
 
11
11
  import { defaultFunctions } from '@dxos/compute';
12
12
 
13
- import { sheetExtension } from './extension';
13
+ import { sheetExtension } from './sheet-extension';
14
14
 
15
15
  describe('formula parser', () => {
16
16
  const {
@@ -2,28 +2,23 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema, pipe } from 'effect';
5
+ import * as Function from 'effect/Function';
6
+ import * as Schema from 'effect/Schema';
6
7
  import { useCallback, useEffect, useMemo } from 'react';
7
8
 
8
- import {
9
- LayoutAction,
10
- chain,
11
- createIntent,
12
- createResolver,
13
- useIntentDispatcher,
14
- useIntentResolver,
15
- } from '@dxos/app-framework';
9
+ import { LayoutAction, chain, createIntent, createResolver } from '@dxos/app-framework';
10
+ import { useIntentDispatcher, useIntentResolver } from '@dxos/app-framework/react';
16
11
  import { debounce } from '@dxos/async';
17
12
  import { type CellAddress, type CompleteCellRange, inRange } from '@dxos/compute';
18
13
  import { Obj, Relation } from '@dxos/echo';
19
14
  import { ATTENDABLE_PATH_SEPARATOR, DeckAction } from '@dxos/plugin-deck/types';
20
- import { ThreadAction, ThreadType } from '@dxos/plugin-thread/types';
21
- import { Filter, Query, fullyQualifiedId, getSpace, useQuery } from '@dxos/react-client/echo';
15
+ import { ThreadAction } from '@dxos/plugin-thread/types';
16
+ import { Filter, Query, getSpace, useQuery } from '@dxos/react-client/echo';
22
17
  import { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';
23
- import { AnchoredTo } from '@dxos/schema';
18
+ import { AnchoredTo, Thread } from '@dxos/types';
24
19
 
25
20
  import { useSheetContext } from '../components';
26
- import { SHEET_PLUGIN } from '../meta';
21
+ import { meta } from '../meta';
27
22
 
28
23
  export const completeCellRangeToThreadCursor = (range: CompleteCellRange): string => {
29
24
  return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
@@ -60,7 +55,7 @@ export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null
60
55
  return false;
61
56
  }
62
57
 
63
- return data.subject === fullyQualifiedId(model.sheet) && !!data.options?.cursor;
58
+ return data.subject === Obj.getDXN(model.sheet).toString() && !!data.options?.cursor;
64
59
  },
65
60
  resolve: ({ options: { cursor, ref } }) => {
66
61
  setActiveRefs(ref);
@@ -72,7 +67,7 @@ export const useUpdateFocusedCellOnThreadSelection = (grid: DxGridElement | null
72
67
  [model.sheet, setActiveRefs],
73
68
  );
74
69
 
75
- useIntentResolver(SHEET_PLUGIN, scrollIntoViewResolver);
70
+ useIntentResolver(meta.id, scrollIntoViewResolver);
76
71
  };
77
72
 
78
73
  export const useSelectThreadOnCellFocus = () => {
@@ -80,7 +75,7 @@ export const useSelectThreadOnCellFocus = () => {
80
75
  const { dispatchPromise: dispatch } = useIntentDispatcher();
81
76
 
82
77
  const space = getSpace(model.sheet);
83
- const anchors = useQuery(space, Query.select(Filter.ids(model.sheet.id)).targetOf(AnchoredTo));
78
+ const anchors = useQuery(space, Query.select(Filter.ids(model.sheet.id)).targetOf(AnchoredTo.AnchoredTo));
84
79
 
85
80
  const selectClosestThread = useCallback(
86
81
  (cellAddress: CellAddress) => {
@@ -90,7 +85,7 @@ export const useSelectThreadOnCellFocus = () => {
90
85
 
91
86
  const closestThread = anchors.find((anchor) => {
92
87
  const source = Relation.getSource(anchor);
93
- if (anchor.anchor && Obj.instanceOf(ThreadType, source)) {
88
+ if (anchor.anchor && Obj.instanceOf(Thread.Thread, source)) {
94
89
  const range = parseThreadAnchorAsCellRange(anchor.anchor);
95
90
  return range ? inRange(range, cellAddress) : false;
96
91
  } else {
@@ -99,9 +94,9 @@ export const useSelectThreadOnCellFocus = () => {
99
94
  });
100
95
 
101
96
  if (closestThread) {
102
- const primary = fullyQualifiedId(model.sheet);
103
- const intent = pipe(
104
- createIntent(ThreadAction.Select, { current: fullyQualifiedId(closestThread) }),
97
+ const primary = Obj.getDXN(model.sheet).toString();
98
+ const intent = Function.pipe(
99
+ createIntent(ThreadAction.Select, { current: Obj.getDXN(closestThread).toString() }),
105
100
  chain(DeckAction.ChangeCompanion, { primary, companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments` }),
106
101
  );
107
102
  void dispatch(intent);
package/src/meta.ts CHANGED
@@ -3,15 +3,17 @@
3
3
  //
4
4
 
5
5
  import { type PluginMeta } from '@dxos/app-framework';
6
-
7
- export const SHEET_PLUGIN = 'dxos.org/plugin/sheet';
6
+ import { trim } from '@dxos/util';
8
7
 
9
8
  export const meta: PluginMeta = {
10
- id: SHEET_PLUGIN,
9
+ id: 'dxos.org/plugin/sheet',
11
10
  name: 'Sheet',
12
- description:
13
- 'Sheets in Composer are simple spreadsheets which allow you to leverage custom functions inside of cell grids. Leverage more than 400 pre-built formulas like Sum, Average, Count, Max, Min along with many others. You can also deploy your own custom functions using the Scripts plugin. ',
11
+ description: trim`
12
+ Full-featured spreadsheet application with over 400 built-in formulas for calculations and data analysis.
13
+ Create custom JavaScript functions and integrate with AI agents for advanced automation.
14
+ `,
14
15
  icon: 'ph--grid-nine--regular',
16
+ iconHue: 'indigo',
15
17
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-sheet',
16
18
  screenshots: ['https://dxos.network/plugin-details-sheet-dark.png'],
17
19
  };
@@ -7,10 +7,10 @@ import { afterEach, beforeEach, describe, expect, onTestFinished, test } from 'v
7
7
  import { Trigger } from '@dxos/async';
8
8
  import { type CellScalarValue, addressFromA1Notation, isFormula } from '@dxos/compute';
9
9
  import { TestBuilder, testFunctionPlugins } from '@dxos/compute/testing';
10
- import { FunctionType } from '@dxos/functions';
10
+ import { Function } from '@dxos/functions';
11
11
  import { log } from '@dxos/log';
12
12
 
13
- import { createSheet, mapFormulaIndicesToRefs, mapFormulaRefsToIndices } from '../types';
13
+ import { Sheet, mapFormulaIndicesToRefs, mapFormulaRefsToIndices } from '../types';
14
14
 
15
15
  import { SheetModel } from './sheet-model';
16
16
  import { createTestGrid } from './testing';
@@ -18,7 +18,7 @@ import { createTestGrid } from './testing';
18
18
  describe('SheetModel', () => {
19
19
  let testBuilder: TestBuilder;
20
20
  beforeEach(async () => {
21
- testBuilder = new TestBuilder({ types: [FunctionType], plugins: testFunctionPlugins });
21
+ testBuilder = new TestBuilder({ types: [Function.Function], plugins: testFunctionPlugins });
22
22
  await testBuilder.open();
23
23
  });
24
24
  afterEach(async () => {
@@ -31,7 +31,7 @@ describe('SheetModel', () => {
31
31
  await graph.open();
32
32
 
33
33
  // TODO(burdon): Create via factory.
34
- const sheet = createSheet({ rows: 5, columns: 5 });
34
+ const sheet = Sheet.make({ rows: 5, columns: 5 });
35
35
  const model = new SheetModel(graph, sheet);
36
36
  await model.open();
37
37
  testBuilder.ctx.onDispose(() => model.close());
@@ -23,7 +23,7 @@ import {
23
23
  } from '@dxos/compute';
24
24
  import { Resource } from '@dxos/context';
25
25
  import { Obj } from '@dxos/echo';
26
- import { FormatEnum, TypeEnum } from '@dxos/echo-schema';
26
+ import { FormatEnum, TypeEnum } from '@dxos/echo/internal';
27
27
  import { invariant } from '@dxos/invariant';
28
28
  import { PublicKey } from '@dxos/keys';
29
29
  import { log } from '@dxos/log';
@@ -39,7 +39,7 @@ import {
39
39
  mapFormulaIndicesToRefs,
40
40
  mapFormulaRefsToIndices,
41
41
  } from '../types';
42
- import { type CellValue, type SheetAction, type SheetType } from '../types';
42
+ import { type Sheet, type SheetAction } from '../types';
43
43
 
44
44
  // TODO(burdon): Move to compute.
45
45
  // Map sheet types to system types.
@@ -92,7 +92,7 @@ export class SheetModel extends Resource {
92
92
 
93
93
  constructor(
94
94
  private readonly _graph: ComputeGraph,
95
- private readonly _sheet: SheetType,
95
+ private readonly _sheet: Sheet.Sheet,
96
96
  private readonly _options: SheetModelOptions = {},
97
97
  ) {
98
98
  super();
@@ -414,7 +414,7 @@ export class SheetModel extends Resource {
414
414
  /**
415
415
  * Sets values from a simple map.
416
416
  */
417
- setValues(values: Record<string, CellValue>): void {
417
+ setValues(values: Record<string, Sheet.CellValue>): void {
418
418
  Object.entries(values).forEach(([key, { value }]) => {
419
419
  this.setValue(addressFromA1Notation(key), value);
420
420
  });
@@ -4,14 +4,14 @@
4
4
 
5
5
  import { addressToA1Notation } from '@dxos/compute';
6
6
 
7
- import { type CellValue, type SheetType, createSheet } from '../types';
7
+ import { Sheet } from '../types';
8
8
 
9
9
  // TODO(burdon): Create testing endpoint.
10
10
  // TODO(burdon): Move to react-ui-sheet.
11
- export const createTestGrid = ({ cols = 4, rows = 10 }: { cols: number; rows: number }): SheetType => {
11
+ export const createTestGrid = ({ cols = 4, rows = 10 }: { cols: number; rows: number }): Sheet.Sheet => {
12
12
  const year = new Date().getFullYear();
13
13
 
14
- const cells: Record<string, CellValue> = {};
14
+ const cells: Record<string, Sheet.CellValue> = {};
15
15
  for (let col = 1; col <= cols; col++) {
16
16
  for (let row = 1; row <= 10; row++) {
17
17
  const cell = addressToA1Notation({ col, row });
@@ -27,7 +27,7 @@ export const createTestGrid = ({ cols = 4, rows = 10 }: { cols: number; rows: nu
27
27
  }
28
28
  }
29
29
 
30
- const sheet = createSheet({
30
+ const sheet = Sheet.make({
31
31
  name: 'Test',
32
32
  cells,
33
33
  });
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';
7
7
  import { type ComputeGraph } from '@dxos/compute';
8
8
 
9
9
  import { SheetModel } from '../model';
10
- import { type SheetType } from '../types';
10
+ import { type Sheet } from '../types';
11
11
 
12
12
  export type UseSheetModelOptions = {
13
13
  readonly?: boolean;
@@ -15,7 +15,7 @@ export type UseSheetModelOptions = {
15
15
 
16
16
  export const useSheetModel = (
17
17
  graph?: ComputeGraph,
18
- sheet?: SheetType,
18
+ sheet?: Sheet.Sheet,
19
19
  { readonly }: UseSheetModelOptions = {},
20
20
  ): SheetModel | undefined => {
21
21
  const [model, setModel] = useState<SheetModel>();
@@ -5,8 +5,7 @@
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
7
  import { Client } from '@dxos/client';
8
- import { Obj } from '@dxos/echo';
9
- import { FunctionType } from '@dxos/functions';
8
+ import { Function } from '@dxos/functions';
10
9
 
11
10
  // Part 2.
12
11
  // TODO(burdon): Cannot test outside of browser.
@@ -23,7 +22,7 @@ import { FunctionType } from '@dxos/functions';
23
22
  describe('test', () => {
24
23
  test('test', async () => {
25
24
  const client = new Client();
26
- client.addTypes([FunctionType]);
25
+ client.addTypes([Function.Function]);
27
26
  await client.initialize();
28
27
  await client.halo.createIdentity();
29
28
 
@@ -34,7 +33,7 @@ describe('test', () => {
34
33
  // - ERROR "process.nextTick is not a function"
35
34
  // - ERROR "Identifier 'Buffer' has already been declared" if { nodeExternal: true }
36
35
  const space = await client.spaces.create();
37
- const fn = space.db.add(Obj.make(FunctionType, { name: 'test', version: '0.0.1', binding: 'HELLO' }));
36
+ const fn = space.db.add(Function.make({ name: 'test', version: '0.0.1', binding: 'HELLO' }));
38
37
  expect(fn).to.exist;
39
38
  });
40
39
  });
package/src/serializer.ts CHANGED
@@ -6,16 +6,16 @@ import { Obj } from '@dxos/echo';
6
6
  import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
7
7
  import { getObjectCore } from '@dxos/react-client/echo';
8
8
 
9
- import { SheetType } from './types';
9
+ import { Sheet } from './types';
10
10
 
11
- export const serializer: TypedObjectSerializer<SheetType> = {
11
+ export const serializer: TypedObjectSerializer<Sheet.Sheet> = {
12
12
  serialize: async ({ object }): Promise<string> => {
13
13
  return JSON.stringify(object, null, 2);
14
14
  },
15
15
 
16
16
  deserialize: async ({ content, newId }) => {
17
17
  const { id, ...parsed } = JSON.parse(content);
18
- const sheet = Obj.make(SheetType, parsed);
18
+ const sheet = Obj.make(Sheet.Sheet, parsed);
19
19
 
20
20
  if (!newId) {
21
21
  const core = getObjectCore(sheet);
@@ -2,9 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import type { CellValue } from '../types';
5
+ import type { Sheet } from '../types';
6
6
 
7
- export const createTestCells = (testSheetName = 'test'): Record<string, CellValue> => ({
7
+ export const createTestCells = (testSheetName = 'test'): Record<string, Sheet.CellValue> => ({
8
8
  B1: { value: 'Qty2' },
9
9
  B3: { value: 1 },
10
10
  B4: { value: 2 },
@@ -6,19 +6,20 @@ import { type Decorator } from '@storybook/react';
6
6
  import React, { useState } from 'react';
7
7
 
8
8
  import { type ComputeGraph, type ComputeGraphOptions, ComputeGraphRegistry } from '@dxos/compute';
9
+ import { createMockedComputeRuntimeProvider } from '@dxos/compute/testing';
9
10
  import { type Space } from '@dxos/react-client/echo';
10
11
  import { useAsyncState } from '@dxos/react-hooks';
11
12
 
12
13
  import { ComputeGraphContextProvider } from '../components';
13
- import { type CreateSheetOptions, createSheet } from '../types';
14
+ import { Sheet } from '../types';
14
15
 
15
- export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: CreateSheetOptions) => {
16
+ export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: Sheet.SheetProps) => {
16
17
  const [sheet] = useAsyncState(async () => {
17
18
  if (!space || !graph) {
18
19
  return;
19
20
  }
20
21
 
21
- const sheet = createSheet(options);
22
+ const sheet = Sheet.make(options);
22
23
  space.db.add(sheet);
23
24
  return sheet;
24
25
  }, [space, graph]);
@@ -26,9 +27,14 @@ export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: Crea
26
27
  };
27
28
 
28
29
  export const withComputeGraphDecorator =
29
- (options?: ComputeGraphOptions): Decorator =>
30
+ (options?: Partial<ComputeGraphOptions>): Decorator =>
30
31
  (Story) => {
31
- const [registry] = useState(new ComputeGraphRegistry(options));
32
+ const [registry] = useState(
33
+ new ComputeGraphRegistry({
34
+ ...options,
35
+ computeRuntime: options?.computeRuntime ?? createMockedComputeRuntimeProvider(),
36
+ }),
37
+ );
32
38
  return (
33
39
  <ComputeGraphContextProvider registry={registry}>
34
40
  <Story />
@@ -5,12 +5,12 @@
5
5
  import { type Resource } from '@dxos/react-ui';
6
6
 
7
7
  import { meta } from './meta';
8
- import { SheetType } from './types';
8
+ import { Sheet } from './types';
9
9
 
10
10
  export const translations = [
11
11
  {
12
12
  'en-US': {
13
- [SheetType.typename]: {
13
+ [Sheet.Sheet.typename]: {
14
14
  'typename label': 'Sheet',
15
15
  'typename label_zero': 'Sheets',
16
16
  'typename label_one': 'Sheet',
@@ -0,0 +1,103 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { addressFromA1Notation, isFormula } from '@dxos/compute';
8
+ import { Obj, Type } from '@dxos/echo';
9
+ import { FormAnnotation } from '@dxos/echo/internal';
10
+
11
+ import { addressToIndex, initialize, mapFormulaRefsToIndices } from './util';
12
+
13
+ export type SheetSize = {
14
+ rows: number;
15
+ columns: number;
16
+ };
17
+
18
+ export const CellValue = Schema.Struct({
19
+ // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.
20
+ // Consider import/export; natural access for other plugins. Special handling for currency (precision).
21
+ // TODO(burdon): Automerge (long string) or short string or number.
22
+ value: Schema.Any,
23
+ });
24
+
25
+ export type CellValue = Schema.Schema.Type<typeof CellValue>;
26
+
27
+ // TODO(burdon): IMPORTANT: Reconcile with Field definition.
28
+ export const Range = Schema.Struct({
29
+ range: Schema.String,
30
+ key: Schema.String,
31
+ value: Schema.String,
32
+ });
33
+
34
+ export type Range = Schema.Schema.Type<typeof Range>;
35
+
36
+ // TODO(burdon): Visibility, locked, frozen, etc.
37
+ export const RowColumnMeta = Schema.Struct({
38
+ size: Schema.optional(Schema.Number),
39
+ });
40
+
41
+ // TODO(burdon): Reconcile col/column (across packages).
42
+ // TODO(burdon): Index to all updates when rows/columns are inserted/deleted.
43
+ export const Sheet = Schema.Struct({
44
+ name: Schema.optional(Schema.String),
45
+
46
+ // Sparse map of cells referenced by index.
47
+ cells: Schema.Record({ key: Schema.String, value: Schema.mutable(CellValue) }).pipe(
48
+ Schema.mutable,
49
+ FormAnnotation.set(false),
50
+ ),
51
+
52
+ // Ordered row indices.
53
+ rows: Schema.Array(Schema.String).pipe(Schema.mutable, FormAnnotation.set(false)),
54
+
55
+ // Ordered column indices.
56
+ columns: Schema.Array(Schema.String).pipe(Schema.mutable, FormAnnotation.set(false)),
57
+
58
+ // Row metadata referenced by index.
59
+ rowMeta: Schema.Record({ key: Schema.String, value: Schema.mutable(RowColumnMeta) }).pipe(
60
+ Schema.mutable,
61
+ FormAnnotation.set(false),
62
+ ),
63
+
64
+ // Column metadata referenced by index.
65
+ columnMeta: Schema.Record({ key: Schema.String, value: Schema.mutable(RowColumnMeta) }).pipe(
66
+ Schema.mutable,
67
+ FormAnnotation.set(false),
68
+ ),
69
+
70
+ // Cell formatting referenced by indexed range.
71
+ ranges: Schema.Array(Range).pipe(Schema.mutable, FormAnnotation.set(false)),
72
+ }).pipe(
73
+ Type.Obj({
74
+ typename: 'dxos.org/type/Sheet',
75
+ version: '0.1.0',
76
+ }),
77
+ );
78
+
79
+ export interface Sheet extends Schema.Schema.Type<typeof Sheet> {}
80
+
81
+ export type SheetProps = {
82
+ name?: string;
83
+ cells?: Record<string, CellValue>;
84
+ } & Partial<SheetSize>;
85
+
86
+ export const make = ({ name, cells = {}, ...size }: SheetProps = {}) => {
87
+ const sheet = Obj.make(Sheet, { name, cells: {}, rows: [], columns: [], rowMeta: {}, columnMeta: {}, ranges: [] });
88
+
89
+ initialize(sheet, size);
90
+
91
+ if (cells) {
92
+ Object.entries(cells).forEach(([key, { value }]) => {
93
+ const idx = addressToIndex(sheet, addressFromA1Notation(key));
94
+ if (isFormula(value)) {
95
+ value = mapFormulaRefsToIndices(sheet, value);
96
+ }
97
+
98
+ sheet.cells[idx] = { value };
99
+ });
100
+ }
101
+
102
+ return sheet;
103
+ };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './schema';
5
+ export * as Sheet from './Sheet';
6
6
  export * from './sheet-range-types';
7
7
  export * from './types';
8
8
  export * from './util';