@dxos/plugin-sheet 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe

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 (173) hide show
  1. package/dist/lib/browser/{SheetContainer-OUN6AARA.mjs → SheetContainer-67YEU5EA.mjs} +26 -27
  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-X4EWLDT3.mjs → chunk-6WBJDEKF.mjs} +33 -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-SSN4HYJL.mjs → chunk-7VEWYJJN.mjs} +5 -5
  10. package/dist/lib/browser/{chunk-SSN4HYJL.mjs.map → chunk-7VEWYJJN.mjs.map} +2 -2
  11. package/dist/lib/browser/{chunk-XSXUU6FO.mjs → chunk-DVJ3QW3F.mjs} +222 -221
  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-ROEY4LHM.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-VOY636TS.mjs → markdown-B6VKYY2S.mjs} +6 -6
  22. package/dist/lib/browser/{markdown-VOY636TS.mjs.map → markdown-B6VKYY2S.mjs.map} +1 -1
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/{react-surface-XCNAVF2M.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-NFLLTGNV.mjs → SheetContainer-NJONAMYZ.mjs} +26 -27
  28. package/dist/lib/node-esm/SheetContainer-NJONAMYZ.mjs.map +7 -0
  29. package/dist/lib/node-esm/{anchor-sort-ACQDUIPU.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-ODP4L4OV.mjs → chunk-4H2EHVWE.mjs} +222 -221
  34. package/dist/lib/node-esm/chunk-4H2EHVWE.mjs.map +7 -0
  35. package/dist/lib/node-esm/{chunk-IK4O7FUJ.mjs → chunk-4QV4AGWK.mjs} +5 -5
  36. package/dist/lib/node-esm/{chunk-IK4O7FUJ.mjs.map → chunk-4QV4AGWK.mjs.map} +2 -2
  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-PYF4ZJXN.mjs → chunk-S3RJ7IY6.mjs} +33 -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-HESRI2ML.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-P4CLZ24C.mjs → markdown-VKY7HXU2.mjs} +6 -6
  48. package/dist/lib/node-esm/{markdown-P4CLZ24C.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-KE3EEVF4.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.map +1 -1
  58. package/dist/types/src/capabilities/index.d.ts +1 -4
  59. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  60. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  61. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +0 -1
  62. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
  63. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  64. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +3 -3
  65. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  66. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +1 -2
  67. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  68. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  69. package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
  70. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  71. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +2 -2
  72. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  73. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +5 -5
  74. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  75. package/dist/types/src/components/SheetContext/SheetContext.d.ts +2 -2
  76. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  77. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
  78. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
  79. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +1 -2
  80. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
  81. package/dist/types/src/extensions/compute.stories.d.ts +2 -3
  82. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
  83. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  84. package/dist/types/src/meta.d.ts +0 -1
  85. package/dist/types/src/meta.d.ts.map +1 -1
  86. package/dist/types/src/model/sheet-model.d.ts +5 -5
  87. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  88. package/dist/types/src/model/testing.d.ts +2 -2
  89. package/dist/types/src/model/testing.d.ts.map +1 -1
  90. package/dist/types/src/model/useSheetModel.d.ts +2 -2
  91. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  92. package/dist/types/src/serializer.d.ts +2 -2
  93. package/dist/types/src/serializer.d.ts.map +1 -1
  94. package/dist/types/src/testing/data.d.ts +2 -2
  95. package/dist/types/src/testing/data.d.ts.map +1 -1
  96. package/dist/types/src/testing/testing.d.ts +27 -3
  97. package/dist/types/src/testing/testing.d.ts.map +1 -1
  98. package/dist/types/src/translations.d.ts +2 -2
  99. package/dist/types/src/translations.d.ts.map +1 -1
  100. package/dist/types/src/types/{schema.d.ts → Sheet.d.ts} +37 -4
  101. package/dist/types/src/types/Sheet.d.ts.map +1 -0
  102. package/dist/types/src/types/index.d.ts +1 -1
  103. package/dist/types/src/types/index.d.ts.map +1 -1
  104. package/dist/types/src/types/sheet-range-types.d.ts +2 -2
  105. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
  106. package/dist/types/src/types/types.d.ts +7 -16
  107. package/dist/types/src/types/types.d.ts.map +1 -1
  108. package/dist/types/src/types/util.d.ts +9 -10
  109. package/dist/types/src/types/util.d.ts.map +1 -1
  110. package/dist/types/tsconfig.tsbuildinfo +1 -1
  111. package/package.json +63 -62
  112. package/src/SheetPlugin.tsx +70 -61
  113. package/src/capabilities/anchor-sort.ts +7 -8
  114. package/src/capabilities/capabilities.ts +2 -2
  115. package/src/capabilities/compute-graph-registry.ts +8 -13
  116. package/src/capabilities/intent-resolver.ts +4 -4
  117. package/src/capabilities/react-surface.tsx +9 -8
  118. package/src/components/ComputeGraph/compute-graph.stories.tsx +10 -12
  119. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
  120. package/src/components/GridSheet/GridSheet.stories.tsx +12 -9
  121. package/src/components/GridSheet/GridSheet.tsx +20 -8
  122. package/src/components/GridSheet/SheetCellEditor.stories.tsx +7 -8
  123. package/src/components/GridSheet/util.ts +9 -3
  124. package/src/components/RangeList/RangeList.tsx +8 -8
  125. package/src/components/SheetContainer/SheetContainer.stories.tsx +46 -45
  126. package/src/components/SheetContainer/SheetContainer.tsx +10 -5
  127. package/src/components/SheetContext/SheetContext.tsx +4 -4
  128. package/src/components/SheetToolbar/SheetToolbar.stories.tsx +9 -6
  129. package/src/components/SheetToolbar/SheetToolbar.tsx +17 -19
  130. package/src/components/SheetToolbar/align.ts +3 -3
  131. package/src/components/SheetToolbar/style.ts +2 -2
  132. package/src/extensions/compute.stories.tsx +17 -14
  133. package/src/integrations/thread-ranges.ts +15 -20
  134. package/src/meta.ts +7 -5
  135. package/src/model/sheet-model.test.ts +4 -4
  136. package/src/model/sheet-model.ts +4 -4
  137. package/src/model/testing.ts +4 -4
  138. package/src/model/useSheetModel.ts +2 -2
  139. package/src/sanity.test.ts +3 -4
  140. package/src/serializer.ts +3 -3
  141. package/src/testing/data.ts +2 -2
  142. package/src/testing/testing.tsx +11 -5
  143. package/src/translations.ts +2 -2
  144. package/src/types/Sheet.ts +103 -0
  145. package/src/types/index.ts +1 -1
  146. package/src/types/sheet-range-types.ts +2 -2
  147. package/src/types/types.ts +6 -16
  148. package/src/types/util.ts +10 -38
  149. package/dist/lib/browser/SheetContainer-OUN6AARA.mjs.map +0 -7
  150. package/dist/lib/browser/anchor-sort-7WD2VGXW.mjs +0 -24
  151. package/dist/lib/browser/anchor-sort-7WD2VGXW.mjs.map +0 -7
  152. package/dist/lib/browser/chunk-6AKBCBL4.mjs +0 -18
  153. package/dist/lib/browser/chunk-6AKBCBL4.mjs.map +0 -7
  154. package/dist/lib/browser/chunk-KJWZUQVA.mjs.map +0 -7
  155. package/dist/lib/browser/chunk-X4EWLDT3.mjs.map +0 -7
  156. package/dist/lib/browser/chunk-XSXUU6FO.mjs.map +0 -7
  157. package/dist/lib/browser/compute-graph-registry-6YJHXORG.mjs +0 -30
  158. package/dist/lib/browser/compute-graph-registry-6YJHXORG.mjs.map +0 -7
  159. package/dist/lib/browser/intent-resolver-ROEY4LHM.mjs.map +0 -7
  160. package/dist/lib/browser/react-surface-XCNAVF2M.mjs.map +0 -7
  161. package/dist/lib/node-esm/SheetContainer-NFLLTGNV.mjs.map +0 -7
  162. package/dist/lib/node-esm/anchor-sort-ACQDUIPU.mjs.map +0 -7
  163. package/dist/lib/node-esm/chunk-3K5VNYOF.mjs +0 -20
  164. package/dist/lib/node-esm/chunk-3K5VNYOF.mjs.map +0 -7
  165. package/dist/lib/node-esm/chunk-6SK5LJ5S.mjs.map +0 -7
  166. package/dist/lib/node-esm/chunk-ODP4L4OV.mjs.map +0 -7
  167. package/dist/lib/node-esm/chunk-PYF4ZJXN.mjs.map +0 -7
  168. package/dist/lib/node-esm/compute-graph-registry-ET5KJNLV.mjs +0 -31
  169. package/dist/lib/node-esm/compute-graph-registry-ET5KJNLV.mjs.map +0 -7
  170. package/dist/lib/node-esm/intent-resolver-HESRI2ML.mjs.map +0 -7
  171. package/dist/lib/node-esm/react-surface-KE3EEVF4.mjs.map +0 -7
  172. package/dist/types/src/types/schema.d.ts.map +0 -1
  173. package/src/types/schema.ts +0 -61
@@ -13,7 +13,8 @@ import React, {
13
13
  useState,
14
14
  } from 'react';
15
15
 
16
- import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
16
+ import { createIntent } from '@dxos/app-framework';
17
+ import { useIntentDispatcher } from '@dxos/app-framework/react';
17
18
  import { type CellRange, rangeToA1Notation } from '@dxos/compute';
18
19
  import { defaultColSize, defaultRowSize } from '@dxos/lit-grid';
19
20
  import { DropdownMenu, Icon, useTranslation } from '@dxos/react-ui';
@@ -34,7 +35,7 @@ import {
34
35
 
35
36
  import { type RangeController, rangeExtension, sheetExtension } from '../../extensions';
36
37
  import { useSelectThreadOnCellFocus, useUpdateFocusedCellOnThreadSelection } from '../../integrations';
37
- import { SHEET_PLUGIN } from '../../meta';
38
+ import { meta } from '../../meta';
38
39
  import { DEFAULT_COLS, DEFAULT_ROWS, SheetAction } from '../../types';
39
40
  import { useSheetContext } from '../SheetContext';
40
41
 
@@ -69,7 +70,7 @@ const sheetRowDefault = {
69
70
  };
70
71
 
71
72
  export const GridSheet = () => {
72
- const { t } = useTranslation(SHEET_PLUGIN);
73
+ const { t } = useTranslation(meta.id);
73
74
  const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } =
74
75
  useSheetContext();
75
76
  // NOTE(thure): using `useState` instead of `useRef` works with refs provided by `@lit/react` and gives us
@@ -77,7 +78,7 @@ export const GridSheet = () => {
77
78
  const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
78
79
  const [extraplanarFocus, setExtraplanarFocus] = useState<DxGridPosition | null>(null);
79
80
  const { dispatchPromise: dispatch } = useIntentDispatcher();
80
- const rangeController = useRef<RangeController>();
81
+ const rangeController = useRef<RangeController>(null);
81
82
  const { hasAttention } = useAttention(id);
82
83
 
83
84
  const handleFocus = useCallback(
@@ -172,12 +173,20 @@ export const GridSheet = () => {
172
173
  case 'frozenRowsStart':
173
174
  return dxGrid?.setSelection({
174
175
  start: { col: pos.col, row: 0, plane: 'grid' },
175
- end: { col: pos.col, row: model.sheet.rows.length - 1, plane: 'grid' },
176
+ end: {
177
+ col: pos.col,
178
+ row: model.sheet.rows.length - 1,
179
+ plane: 'grid',
180
+ },
176
181
  });
177
182
  case 'frozenColsStart':
178
183
  return dxGrid?.setSelection({
179
184
  start: { row: pos.row, col: 0, plane: 'grid' },
180
- end: { row: pos.row, col: model.sheet.columns.length - 1, plane: 'grid' },
185
+ end: {
186
+ row: pos.row,
187
+ col: model.sheet.columns.length - 1,
188
+ plane: 'grid',
189
+ },
181
190
  });
182
191
  }
183
192
  },
@@ -281,7 +290,10 @@ export const GridSheet = () => {
281
290
 
282
291
  const extensions = useMemo(
283
292
  () => [
284
- editorKeys({ onClose: handleClose, ...(editing?.initialContent && { onNav: handleClose }) }),
293
+ editorKeys({
294
+ onClose: handleClose,
295
+ ...(editing?.initialContent && { onNav: handleClose }),
296
+ }),
285
297
  sheetExtension({ functions: model.graph.getFunctions() }),
286
298
  rangeExtension({
287
299
  onInit: (fn) => (rangeController.current = fn),
@@ -308,7 +320,7 @@ export const GridSheet = () => {
308
320
 
309
321
  return (
310
322
  // TODO(thure): Why are Table’s and Sheet’s editor boxes off by 1px?
311
- <div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent '>
323
+ <div role='none' className='relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent'>
312
324
  <GridCellEditor getCellContent={getCellContent} extensions={extensions} onBlur={handleBlur} />
313
325
  <Grid.Content
314
326
  initialCells={initialCells}
@@ -2,8 +2,6 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useMemo, useState } from 'react';
9
7
 
@@ -12,12 +10,12 @@ import { createDocAccessor } from '@dxos/client/echo';
12
10
  import { defaultFunctions } from '@dxos/compute';
13
11
  import { getRegisteredFunctionNames } from '@dxos/compute/testing';
14
12
  import { useAsyncEffect } from '@dxos/react-hooks';
13
+ import { withTheme } from '@dxos/react-ui/testing';
15
14
  import { automerge } from '@dxos/react-ui-editor';
16
15
  import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
17
- import { withTheme } from '@dxos/storybook-utils';
18
16
 
19
17
  import { sheetExtension } from '../../extensions';
20
- import { SheetType, createSheet } from '../../types';
18
+ import { Sheet } from '../../types';
21
19
 
22
20
  const DefaultStory = ({ value, ...props }: CellEditorProps) => {
23
21
  const extensions = useMemo(() => {
@@ -31,14 +29,14 @@ const DefaultStory = ({ value, ...props }: CellEditorProps) => {
31
29
 
32
30
  const AutomergeStory = ({ value, ...props }: CellEditorProps) => {
33
31
  const cell = 'A1';
34
- const [object, setObject] = useState<SheetType>();
32
+ const [object, setObject] = useState<Sheet.Sheet>();
35
33
  useAsyncEffect(async () => {
36
- const client = new Client({ types: [SheetType] });
34
+ const client = new Client({ types: [Sheet.Sheet] });
37
35
  await client.initialize();
38
36
  await client.halo.createIdentity();
39
37
  const space = await client.spaces.create();
40
38
 
41
- const sheet = createSheet();
39
+ const sheet = Sheet.make();
42
40
  sheet.name = 'Test';
43
41
  sheet.cells[cell] = { value };
44
42
  space.db.add(sheet);
@@ -61,9 +59,10 @@ const AutomergeStory = ({ value, ...props }: CellEditorProps) => {
61
59
 
62
60
  const meta = {
63
61
  title: 'plugins/plugin-sheet/CellEditor',
62
+
63
+ decorators: [withTheme],
64
64
  component: CellEditor,
65
65
  render: DefaultStory,
66
- decorators: [withTheme],
67
66
  } satisfies Meta<typeof DefaultStory>;
68
67
 
69
68
  export default meta;
@@ -28,7 +28,10 @@ const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
28
28
  return model.sheet.columns.reduce(
29
29
  (acc: DxGridAxisMeta, columnId, numericIndex) => {
30
30
  if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
31
- acc.grid[numericIndex] = { size: model.sheet.columnMeta[columnId].size, resizeable: true };
31
+ acc.grid[numericIndex] = {
32
+ size: model.sheet.columnMeta[columnId].size,
33
+ resizeable: true,
34
+ };
32
35
  }
33
36
  return acc;
34
37
  },
@@ -40,7 +43,10 @@ const createDxGridRows = (model: SheetModel): DxGridAxisMeta => {
40
43
  return model.sheet.rows.reduce(
41
44
  (acc: DxGridAxisMeta, rowId, numericIndex) => {
42
45
  if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
43
- acc.grid[numericIndex] = { size: model.sheet.rowMeta[rowId].size, resizeable: true };
46
+ acc.grid[numericIndex] = {
47
+ size: model.sheet.rowMeta[rowId].size,
48
+ resizeable: true,
49
+ };
44
50
  }
45
51
  return acc;
46
52
  },
@@ -59,7 +65,7 @@ const projectCellProps = (model: SheetModel, col: number, row: number): DxGridCe
59
65
  // const range = thread.target?.anchor && parseThreadAnchorAsCellRange(thread.target!.anchor);
60
66
  // return thread && range ? inRange(range, address) : false;
61
67
  // })
62
- // .map((thread) => fullyQualifiedId(thread!))
68
+ // .map((thread) => Obj.getDXN(thread!).toString())
63
69
  // .join(' ');
64
70
 
65
71
  const description = model.getValueDescription(address);
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useCallback } from 'react';
7
7
 
8
8
  import { rangeToA1Notation } from '@dxos/compute';
@@ -10,20 +10,20 @@ 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 { SHEET_PLUGIN } from '../../meta';
13
+ import { meta } from '../../meta';
14
14
  import { rangeFromIndex } from '../../types';
15
- import { Range, type SheetType } from '../../types';
15
+ import { Sheet } from '../../types';
16
16
 
17
17
  export type RangeListProps = {
18
- sheet: SheetType;
18
+ sheet: Sheet.Sheet;
19
19
  };
20
20
 
21
21
  export const RangeList = ({ sheet }: RangeListProps) => {
22
- const { t } = useTranslation(SHEET_PLUGIN);
22
+ const { t } = useTranslation(meta.id);
23
23
  // TODO(thure): Implement similar to comments, #8121
24
- const handleSelectRange = (range: Range) => {};
24
+ const handleSelectRange = (range: Sheet.Range) => {};
25
25
  const handleDeleteRange = useCallback(
26
- (range: Range) => {
26
+ (range: Sheet.Range) => {
27
27
  const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
28
28
  sheet.ranges.splice(index, 1);
29
29
  },
@@ -37,7 +37,7 @@ export const RangeList = ({ sheet }: RangeListProps) => {
37
37
  <Callout.Title>{t('no ranges message')}</Callout.Title>
38
38
  </Callout.Root>
39
39
  ) : (
40
- <List.Root<Range> items={sheet.ranges} isItem={Schema.is(Range)}>
40
+ <List.Root<Sheet.Range> items={sheet.ranges} isItem={Schema.is(Sheet.Range)}>
41
41
  {({ items: ranges }) =>
42
42
  ranges.map((range, i) => (
43
43
  <List.Item key={i} item={range} classNames={['p-2', ghostHover]}>
@@ -2,29 +2,60 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type Meta, type StoryObj } from '@storybook/react-vite';
5
+ import { type Meta } from '@storybook/react-vite';
8
6
  import React from 'react';
9
7
 
10
8
  import { Capabilities, IntentPlugin, contributes, createResolver } from '@dxos/app-framework';
11
9
  import { withPluginManager } from '@dxos/app-framework/testing';
10
+ import { Obj } from '@dxos/echo';
12
11
  import { GraphPlugin } from '@dxos/plugin-graph';
13
- import { fullyQualifiedId, useSpace } from '@dxos/react-client/echo';
12
+ import { useSpace } from '@dxos/react-client/echo';
14
13
  import { withClientProvider } from '@dxos/react-client/testing';
14
+ import { withTheme } from '@dxos/react-ui/testing';
15
15
  import { AttendableContainer } from '@dxos/react-ui-attention';
16
16
  import { withAttention } from '@dxos/react-ui-attention/testing';
17
- import { withLayout, withTheme } from '@dxos/storybook-utils';
18
17
 
19
18
  import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
20
19
  import { translations } from '../../translations';
21
- import { SheetAction, SheetType } from '../../types';
20
+ import { Sheet, SheetAction } from '../../types';
22
21
  import { useComputeGraph } from '../ComputeGraph';
23
22
  import { RangeList } from '../RangeList';
24
23
 
25
24
  import { SheetContainer } from './SheetContainer';
26
25
 
27
- export const Basic = () => {
26
+ const meta = {
27
+ title: 'plugins/plugin-sheet/SheetContainer',
28
+ component: SheetContainer,
29
+ decorators: [
30
+ withTheme,
31
+ withClientProvider({ types: [Sheet.Sheet], createSpace: true }),
32
+ withComputeGraphDecorator(),
33
+ withAttention,
34
+ // TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
35
+ withPluginManager({
36
+ plugins: [IntentPlugin(), GraphPlugin()],
37
+ capabilities: [
38
+ contributes(
39
+ Capabilities.IntentResolver,
40
+ createResolver({
41
+ intent: SheetAction.DropAxis,
42
+ resolve: ({ model, axis, axisIndex }) => {
43
+ model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
44
+ },
45
+ }),
46
+ ),
47
+ ],
48
+ }),
49
+ ],
50
+ parameters: {
51
+ layout: 'fullscreen',
52
+ translations,
53
+ },
54
+ } satisfies Meta<typeof SheetContainer>;
55
+
56
+ export default meta;
57
+
58
+ export const Default = () => {
28
59
  const space = useSpace();
29
60
  const graph = useComputeGraph(space);
30
61
  const sheet = useTestSheet(space, graph, { cells: createTestCells() });
@@ -33,8 +64,8 @@ export const Basic = () => {
33
64
  }
34
65
 
35
66
  return (
36
- <AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
37
- <SheetContainer space={space} sheet={sheet} role='article' ignoreAttention />
67
+ <AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
68
+ <SheetContainer space={space} sheet={sheet} role='story' ignoreAttention />
38
69
  </AttendableContainer>
39
70
  );
40
71
  };
@@ -42,15 +73,17 @@ export const Basic = () => {
42
73
  export const Spec = () => {
43
74
  const space = useSpace();
44
75
  const graph = useComputeGraph(space);
45
- const sheet = useTestSheet(space, graph, { cells: { A1: { value: 'Ready' } } });
76
+ const sheet = useTestSheet(space, graph, {
77
+ cells: { A1: { value: 'Ready' } },
78
+ });
46
79
  if (!sheet || !space) {
47
80
  return null;
48
81
  }
49
82
 
50
83
  return (
51
- <AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
52
- <div role='none' className='grid grid-rows-[66%_33%] grid-cols-1'>
53
- <SheetContainer space={space} sheet={sheet} role='article' ignoreAttention />
84
+ <AttendableContainer id={Obj.getDXN(sheet).toString()} classNames='contents'>
85
+ <div role='none' className='grid grid-rows-[66%_33%] bs-full grid-cols-1'>
86
+ <SheetContainer space={space} sheet={sheet} role='story' ignoreAttention />
54
87
  <div role='none' data-testid='grid.range-list'>
55
88
  <RangeList sheet={sheet} />
56
89
  </div>
@@ -58,35 +91,3 @@ export const Spec = () => {
58
91
  </AttendableContainer>
59
92
  );
60
93
  };
61
-
62
- const meta = {
63
- title: 'plugins/plugin-sheet/SheetContainer',
64
- component: SheetContainer,
65
- decorators: [
66
- withClientProvider({ types: [SheetType], createSpace: true }),
67
- withComputeGraphDecorator(),
68
- withTheme,
69
- withLayout({ fullscreen: true, classNames: 'grid' }),
70
- withAttention,
71
- // TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
72
- withPluginManager({
73
- plugins: [IntentPlugin(), GraphPlugin()],
74
- capabilities: [
75
- contributes(
76
- Capabilities.IntentResolver,
77
- createResolver({
78
- intent: SheetAction.DropAxis,
79
- resolve: ({ model, axis, axisIndex }) => {
80
- model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
81
- },
82
- }),
83
- ),
84
- ],
85
- }),
86
- ],
87
- parameters: { translations },
88
- } satisfies Meta<typeof SheetContainer>;
89
-
90
- export default meta;
91
-
92
- type Story = StoryObj<typeof meta>;
@@ -4,10 +4,11 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type Space, fullyQualifiedId } from '@dxos/react-client/echo';
7
+ import { Obj } from '@dxos/echo';
8
+ import { type Space } from '@dxos/react-client/echo';
8
9
  import { StackItem } from '@dxos/react-ui-stack';
9
10
 
10
- import { type SheetType } from '../../types';
11
+ import { type Sheet } from '../../types';
11
12
  import { useComputeGraph } from '../ComputeGraph';
12
13
  import { FunctionEditor } from '../FunctionEditor';
13
14
  import { GridSheet } from '../GridSheet';
@@ -16,7 +17,7 @@ import { SheetToolbar } from '../SheetToolbar';
16
17
 
17
18
  export type SheetContainerProps = {
18
19
  space: Space;
19
- sheet: SheetType;
20
+ sheet: Sheet.Sheet;
20
21
  role?: string;
21
22
  ignoreAttention?: boolean;
22
23
  };
@@ -26,8 +27,12 @@ export const SheetContainer = ({ space, sheet, role, ignoreAttention }: SheetCon
26
27
 
27
28
  return graph ? (
28
29
  <SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>
29
- <StackItem.Content toolbar statusbar {...(role === 'section' && { classNames: 'aspect-video' })}>
30
- <SheetToolbar id={fullyQualifiedId(sheet)} />
30
+ <StackItem.Content
31
+ toolbar
32
+ statusbar
33
+ classNames={[role === 'section' && 'aspect-video', role === 'story' && 'bs-full']}
34
+ >
35
+ <SheetToolbar id={Obj.getDXN(sheet).toString()} />
31
36
  <GridSheet />
32
37
  <FunctionEditor />
33
38
  </StackItem.Content>
@@ -5,8 +5,8 @@
5
5
  import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
6
6
 
7
7
  import { type CellAddress, type CellRange, type CompleteCellRange, type ComputeGraph } from '@dxos/compute';
8
+ import { Obj } from '@dxos/echo';
8
9
  import { invariant } from '@dxos/invariant';
9
- import { fullyQualifiedId } from '@dxos/react-client/echo';
10
10
  import {
11
11
  Grid,
12
12
  type GridContentProps,
@@ -16,7 +16,7 @@ import {
16
16
  } from '@dxos/react-ui-grid';
17
17
 
18
18
  import { type SheetModel, useSheetModel } from '../../model';
19
- import { type SheetType } from '../../types';
19
+ import { type Sheet } from '../../types';
20
20
 
21
21
  export type SheetContextValue = {
22
22
  id: string;
@@ -114,7 +114,7 @@ const SheetProviderImpl = ({
114
114
 
115
115
  export type SheetProviderProps = {
116
116
  graph: ComputeGraph;
117
- sheet: SheetType;
117
+ sheet: Sheet.Sheet;
118
118
  readonly?: boolean;
119
119
  ignoreAttention?: boolean;
120
120
  } & Pick<SheetContextValue, 'onInfo'>;
@@ -130,7 +130,7 @@ export const SheetProvider = ({
130
130
  const model = useSheetModel(graph, sheet, { readonly });
131
131
 
132
132
  return !model ? null : (
133
- <Grid.Root id={fullyQualifiedId(sheet)}>
133
+ <Grid.Root id={Obj.getDXN(sheet).toString()}>
134
134
  <SheetProviderImpl model={model} onInfo={onInfo} ignoreAttention={ignoreAttention}>
135
135
  {children}
136
136
  </SheetProviderImpl>
@@ -2,27 +2,30 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React from 'react';
9
7
 
10
- import { withLayout, withTheme } from '@dxos/storybook-utils';
8
+ import { withTheme } from '@dxos/react-ui/testing';
11
9
 
12
10
  import { translations } from '../../translations';
13
11
 
14
12
  import { SheetToolbar } from './SheetToolbar';
15
13
 
16
14
  const DefaultStory = () => {
17
- return <SheetToolbar id='test' />;
15
+ // TODO(wittjosiah): Depends on SheetProvider.
16
+ // return <SheetToolbar id='test' />;
17
+ return <>TODO</>;
18
18
  };
19
19
 
20
20
  const meta = {
21
21
  title: 'plugins/plugin-sheet/Toolbar',
22
22
  component: SheetToolbar as any,
23
23
  render: DefaultStory,
24
- decorators: [withTheme, withLayout()],
25
- parameters: { translations, layout: 'fullscreen' },
24
+ decorators: [withTheme],
25
+ parameters: {
26
+ layout: 'fullscreen',
27
+ translations,
28
+ },
26
29
  } satisfies Meta<typeof DefaultStory>;
27
30
 
28
31
  export default meta;
@@ -2,18 +2,17 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Rx } from '@effect-rx/rx-react';
5
+ import { Atom } from '@effect-atom/atom-react';
6
6
  import React, { type PropsWithChildren, useMemo } from 'react';
7
7
 
8
- import { useAppGraph } from '@dxos/app-framework';
8
+ import { useAppGraph } from '@dxos/app-framework/react';
9
9
  import { type CompleteCellRange } from '@dxos/compute';
10
- import { type ThemedClassName } from '@dxos/react-ui';
11
10
  import {
12
11
  type ActionGraphProps,
13
12
  MenuProvider,
14
13
  ToolbarMenu,
14
+ atomFromSignal,
15
15
  createGapSeparator,
16
- rxFromSignal,
17
16
  useMenuActions,
18
17
  } from '@dxos/react-ui-menu';
19
18
 
@@ -24,21 +23,15 @@ import { createAlign, useAlignState } from './align';
24
23
  import { createStyle, useStyleState } from './style';
25
24
  import { type ToolbarState, useToolbarState } from './useToolbarState';
26
25
 
27
- //
28
- // Root
29
- //
30
-
31
- export type SheetToolbarProps = ThemedClassName<PropsWithChildren<{ id: string }>>;
32
-
33
26
  const createToolbarActions = (
34
27
  model: SheetModel,
35
28
  state: ToolbarState,
36
29
  cursorFallbackRange?: CompleteCellRange,
37
- customActions?: Rx.Rx<ActionGraphProps>,
38
- ): Rx.Rx<ActionGraphProps> => {
39
- return Rx.make((get) => {
40
- const align = get(rxFromSignal(() => createAlign(model, state, cursorFallbackRange)));
41
- const style = get(rxFromSignal(() => createStyle(model, state, cursorFallbackRange)));
30
+ customActions?: Atom.Atom<ActionGraphProps>,
31
+ ): Atom.Atom<ActionGraphProps> => {
32
+ return Atom.make((get) => {
33
+ const align = get(atomFromSignal(() => createAlign(model, state, cursorFallbackRange)));
34
+ const style = get(atomFromSignal(() => createStyle(model, state, cursorFallbackRange)));
42
35
  const gap = createGapSeparator();
43
36
 
44
37
  const graph: ActionGraphProps = {
@@ -56,7 +49,9 @@ const createToolbarActions = (
56
49
  });
57
50
  };
58
51
 
59
- export const SheetToolbar = ({ id, classNames }: SheetToolbarProps) => {
52
+ export type SheetToolbarProps = PropsWithChildren<{ id: string }>;
53
+
54
+ export const SheetToolbar = ({ id }: SheetToolbarProps) => {
60
55
  const { model, cursorFallbackRange } = useSheetContext();
61
56
  const state = useToolbarState({});
62
57
  useAlignState(state);
@@ -64,10 +59,13 @@ export const SheetToolbar = ({ id, classNames }: SheetToolbarProps) => {
64
59
 
65
60
  const { graph } = useAppGraph();
66
61
  const customActions = useMemo(() => {
67
- return Rx.make((get) => {
62
+ return Atom.make((get) => {
68
63
  const actions = get(graph.actions(id));
69
64
  const nodes = actions.filter((action) => action.properties.disposition === 'toolbar');
70
- return { nodes, edges: nodes.map((node) => ({ source: 'root', target: node.id })) };
65
+ return {
66
+ nodes,
67
+ edges: nodes.map((node) => ({ source: 'root', target: node.id })),
68
+ };
71
69
  });
72
70
  }, [graph]);
73
71
 
@@ -79,7 +77,7 @@ export const SheetToolbar = ({ id, classNames }: SheetToolbarProps) => {
79
77
 
80
78
  return (
81
79
  <MenuProvider {...menu} attendableId={id}>
82
- <ToolbarMenu classNames={classNames} />
80
+ <ToolbarMenu />
83
81
  </MenuProvider>
84
82
  );
85
83
  };
@@ -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
  );