@dxos/plugin-sheet 0.8.3 → 0.8.4-main.1068cf700f

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 (297) hide show
  1. package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs +397 -0
  2. package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs.map +7 -0
  3. package/dist/lib/browser/anchor-sort-AMMLA66W.mjs +24 -0
  4. package/dist/lib/browser/anchor-sort-AMMLA66W.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-EDWHV64N.mjs +1473 -0
  6. package/dist/lib/browser/chunk-EDWHV64N.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-FJRLDX7Z.mjs → chunk-IFLWVS2V.mjs} +7 -7
  8. package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-KE3AKN5W.mjs +397 -0
  10. package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +7 -0
  11. package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs +21 -0
  12. package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +80 -89
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/markdown-D2T2DOVX.mjs +29 -0
  16. package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +7 -0
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/operation-resolver-P2RX75DA.mjs +79 -0
  19. package/dist/lib/browser/operation-resolver-P2RX75DA.mjs.map +7 -0
  20. package/dist/lib/browser/react-surface-45CRAB5G.mjs +51 -0
  21. package/dist/lib/browser/react-surface-45CRAB5G.mjs.map +7 -0
  22. package/dist/lib/browser/types/index.mjs +7 -12
  23. package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs +398 -0
  24. package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs.map +7 -0
  25. package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs +25 -0
  26. package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs.map +7 -0
  27. package/dist/lib/node-esm/chunk-6J5L47IB.mjs +398 -0
  28. package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +7 -0
  29. package/dist/lib/node-esm/chunk-AYSEWH7N.mjs +1474 -0
  30. package/dist/lib/node-esm/chunk-AYSEWH7N.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-NMCVJWDT.mjs → chunk-PPOYR7DK.mjs} +7 -7
  32. package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
  33. package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +22 -0
  34. package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +7 -0
  35. package/dist/lib/node-esm/index.mjs +80 -89
  36. package/dist/lib/node-esm/index.mjs.map +4 -4
  37. package/dist/lib/node-esm/markdown-PTV72DLO.mjs +30 -0
  38. package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +7 -0
  39. package/dist/lib/node-esm/meta.json +1 -1
  40. package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs +80 -0
  41. package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs.map +7 -0
  42. package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs +52 -0
  43. package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs.map +7 -0
  44. package/dist/lib/node-esm/types/index.mjs +7 -12
  45. package/dist/types/src/SheetPlugin.d.ts +2 -1
  46. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
  48. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
  50. package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
  52. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
  53. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
  54. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/index.d.ts +5 -11
  56. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  57. package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
  58. package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
  59. package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
  60. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
  61. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  62. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  63. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  64. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  66. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  68. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  69. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  70. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +9 -4
  71. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
  72. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  73. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +51 -3
  74. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  75. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +11 -20
  76. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  77. package/dist/types/src/components/GridSheet/util.d.ts +1 -1
  78. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  79. package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
  80. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  81. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +5 -6
  82. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  83. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +54 -5
  84. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  85. package/dist/types/src/components/SheetContext/SheetContext.d.ts +3 -3
  86. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  87. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
  88. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
  89. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +88 -4
  90. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
  91. package/dist/types/src/components/SheetToolbar/align.d.ts +13 -20
  92. package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
  93. package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
  94. package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
  95. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -1
  96. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
  97. package/dist/types/src/components/index.d.ts +1 -1
  98. package/dist/types/src/components/index.d.ts.map +1 -1
  99. package/dist/types/src/extensions/compute.d.ts +1 -1
  100. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  101. package/dist/types/src/extensions/compute.stories.d.ts +10 -13
  102. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
  103. package/dist/types/src/extensions/editor/index.d.ts +1 -1
  104. package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
  105. package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
  106. package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
  107. package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
  108. package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
  109. package/dist/types/src/index.d.ts +1 -1
  110. package/dist/types/src/index.d.ts.map +1 -1
  111. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  112. package/dist/types/src/meta.d.ts +2 -3
  113. package/dist/types/src/meta.d.ts.map +1 -1
  114. package/dist/types/src/model/sheet-model.d.ts +6 -6
  115. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  116. package/dist/types/src/model/testing.d.ts +2 -2
  117. package/dist/types/src/model/testing.d.ts.map +1 -1
  118. package/dist/types/src/model/useSheetModel.d.ts +2 -2
  119. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  120. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  121. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  122. package/dist/types/src/{testing/playwright → playwright}/sheet-manager.d.ts +1 -1
  123. package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -0
  124. package/dist/types/src/playwright/sheet.spec.d.ts.map +1 -0
  125. package/dist/types/src/serializer.d.ts +2 -2
  126. package/dist/types/src/serializer.d.ts.map +1 -1
  127. package/dist/types/src/testing/data.d.ts +2 -2
  128. package/dist/types/src/testing/data.d.ts.map +1 -1
  129. package/dist/types/src/testing/testing.d.ts +27 -3
  130. package/dist/types/src/testing/testing.d.ts.map +1 -1
  131. package/dist/types/src/translations.d.ts +8 -62
  132. package/dist/types/src/translations.d.ts.map +1 -1
  133. package/dist/types/src/types/Sheet.d.ts +76 -0
  134. package/dist/types/src/types/Sheet.d.ts.map +1 -0
  135. package/dist/types/src/types/capabilities.d.ts +6 -0
  136. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  137. package/dist/types/src/types/index.d.ts +2 -1
  138. package/dist/types/src/types/index.d.ts.map +1 -1
  139. package/dist/types/src/types/sheet-range-types.d.ts +2 -2
  140. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
  141. package/dist/types/src/types/types.d.ts +92 -75
  142. package/dist/types/src/types/types.d.ts.map +1 -1
  143. package/dist/types/src/types/util.d.ts +10 -10
  144. package/dist/types/src/types/util.d.ts.map +1 -1
  145. package/dist/types/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +83 -73
  147. package/src/SheetPlugin.tsx +53 -65
  148. package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
  149. package/src/capabilities/anchor-sort/index.ts +7 -0
  150. package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
  151. package/src/capabilities/compute-graph-registry/index.ts +7 -0
  152. package/src/capabilities/index.ts +5 -9
  153. package/src/capabilities/markdown/index.ts +7 -0
  154. package/src/capabilities/markdown/markdown.ts +30 -0
  155. package/src/capabilities/operation-resolver/index.ts +7 -0
  156. package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
  157. package/src/capabilities/react-surface/index.ts +7 -0
  158. package/src/capabilities/react-surface/react-surface.tsx +43 -0
  159. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
  160. package/src/components/ComputeGraph/compute-graph.stories.tsx +21 -20
  161. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
  162. package/src/components/GridSheet/GridSheet.stories.tsx +23 -17
  163. package/src/components/GridSheet/GridSheet.tsx +63 -52
  164. package/src/components/GridSheet/SheetCellEditor.stories.tsx +44 -43
  165. package/src/components/GridSheet/util.ts +17 -11
  166. package/src/components/RangeList/RangeList.tsx +13 -10
  167. package/src/components/SheetContainer/SheetContainer.stories.tsx +71 -47
  168. package/src/components/SheetContainer/SheetContainer.tsx +30 -18
  169. package/src/components/SheetContext/SheetContext.tsx +9 -9
  170. package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
  171. package/src/components/SheetToolbar/SheetToolbar.tsx +52 -42
  172. package/src/components/SheetToolbar/align.ts +46 -20
  173. package/src/components/SheetToolbar/style.ts +48 -18
  174. package/src/components/SheetToolbar/useToolbarState.ts +22 -5
  175. package/src/extensions/compute.stories.tsx +43 -30
  176. package/src/extensions/compute.ts +3 -4
  177. package/src/extensions/editor/index.ts +1 -1
  178. package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
  179. package/src/extensions/editor/{extension.ts → sheet-extension.ts} +7 -4
  180. package/src/index.ts +1 -1
  181. package/src/integrations/thread-ranges.ts +43 -51
  182. package/src/meta.ts +9 -7
  183. package/src/model/sheet-model.test.ts +5 -4
  184. package/src/model/sheet-model.ts +85 -53
  185. package/src/model/testing.ts +4 -4
  186. package/src/model/useSheetModel.ts +2 -2
  187. package/src/playwright/playwright.config.ts +17 -0
  188. package/src/{testing/playwright → playwright}/sheet-manager.ts +1 -1
  189. package/src/{testing/playwright → playwright}/sheet.spec.ts +3 -2
  190. package/src/sanity.test.ts +4 -5
  191. package/src/serializer.ts +4 -4
  192. package/src/testing/data.ts +2 -2
  193. package/src/testing/testing.tsx +11 -5
  194. package/src/translations.ts +10 -7
  195. package/src/types/Sheet.ts +97 -0
  196. package/src/types/capabilities.ts +14 -0
  197. package/src/types/index.ts +2 -1
  198. package/src/types/sheet-range-types.ts +2 -2
  199. package/src/types/types.ts +84 -49
  200. package/src/types/util.ts +14 -41
  201. package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs +0 -351
  202. package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs.map +0 -7
  203. package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs +0 -24
  204. package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs.map +0 -7
  205. package/dist/lib/browser/chunk-5TA43LO4.mjs +0 -847
  206. package/dist/lib/browser/chunk-5TA43LO4.mjs.map +0 -7
  207. package/dist/lib/browser/chunk-D3G4UGEK.mjs +0 -18
  208. package/dist/lib/browser/chunk-D3G4UGEK.mjs.map +0 -7
  209. package/dist/lib/browser/chunk-FJRLDX7Z.mjs.map +0 -7
  210. package/dist/lib/browser/chunk-I7FZ4TWJ.mjs +0 -892
  211. package/dist/lib/browser/chunk-I7FZ4TWJ.mjs.map +0 -7
  212. package/dist/lib/browser/chunk-IR42IS3F.mjs +0 -15
  213. package/dist/lib/browser/chunk-IR42IS3F.mjs.map +0 -7
  214. package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs +0 -30
  215. package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs.map +0 -7
  216. package/dist/lib/browser/intent-resolver-IBBI6B74.mjs +0 -56
  217. package/dist/lib/browser/intent-resolver-IBBI6B74.mjs.map +0 -7
  218. package/dist/lib/browser/markdown-T4TUP4BF.mjs +0 -26
  219. package/dist/lib/browser/markdown-T4TUP4BF.mjs.map +0 -7
  220. package/dist/lib/browser/react-surface-UI46P43F.mjs +0 -53
  221. package/dist/lib/browser/react-surface-UI46P43F.mjs.map +0 -7
  222. package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs +0 -351
  223. package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs.map +0 -7
  224. package/dist/lib/node/anchor-sort-A7NABMJM.cjs +0 -39
  225. package/dist/lib/node/anchor-sort-A7NABMJM.cjs.map +0 -7
  226. package/dist/lib/node/chunk-FIM6EZ6M.cjs +0 -256
  227. package/dist/lib/node/chunk-FIM6EZ6M.cjs.map +0 -7
  228. package/dist/lib/node/chunk-JSIDCZHB.cjs +0 -41
  229. package/dist/lib/node/chunk-JSIDCZHB.cjs.map +0 -7
  230. package/dist/lib/node/chunk-LJWWS53Z.cjs +0 -34
  231. package/dist/lib/node/chunk-LJWWS53Z.cjs.map +0 -7
  232. package/dist/lib/node/chunk-N7FSEUIN.cjs +0 -927
  233. package/dist/lib/node/chunk-N7FSEUIN.cjs.map +0 -7
  234. package/dist/lib/node/chunk-ST3WA73J.cjs +0 -855
  235. package/dist/lib/node/chunk-ST3WA73J.cjs.map +0 -7
  236. package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs +0 -56
  237. package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs.map +0 -7
  238. package/dist/lib/node/index.cjs +0 -173
  239. package/dist/lib/node/index.cjs.map +0 -7
  240. package/dist/lib/node/intent-resolver-2657YDOU.cjs +0 -69
  241. package/dist/lib/node/intent-resolver-2657YDOU.cjs.map +0 -7
  242. package/dist/lib/node/markdown-DBPOAYI7.cjs +0 -40
  243. package/dist/lib/node/markdown-DBPOAYI7.cjs.map +0 -7
  244. package/dist/lib/node/meta.json +0 -1
  245. package/dist/lib/node/react-surface-XQEIRKWU.cjs +0 -71
  246. package/dist/lib/node/react-surface-XQEIRKWU.cjs.map +0 -7
  247. package/dist/lib/node/types/index.cjs +0 -84
  248. package/dist/lib/node/types/index.cjs.map +0 -7
  249. package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs +0 -352
  250. package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs.map +0 -7
  251. package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs +0 -25
  252. package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs.map +0 -7
  253. package/dist/lib/node-esm/chunk-C4IKYVTV.mjs +0 -893
  254. package/dist/lib/node-esm/chunk-C4IKYVTV.mjs.map +0 -7
  255. package/dist/lib/node-esm/chunk-IQ76YE6M.mjs +0 -16
  256. package/dist/lib/node-esm/chunk-IQ76YE6M.mjs.map +0 -7
  257. package/dist/lib/node-esm/chunk-NMCVJWDT.mjs.map +0 -7
  258. package/dist/lib/node-esm/chunk-SOC52B67.mjs +0 -848
  259. package/dist/lib/node-esm/chunk-SOC52B67.mjs.map +0 -7
  260. package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs +0 -20
  261. package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs.map +0 -7
  262. package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs +0 -31
  263. package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs.map +0 -7
  264. package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs +0 -57
  265. package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs.map +0 -7
  266. package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs +0 -27
  267. package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs.map +0 -7
  268. package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs +0 -54
  269. package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs.map +0 -7
  270. package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
  271. package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
  272. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  273. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  274. package/dist/types/src/capabilities/compute-graph-registry.d.ts +0 -4
  275. package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +0 -1
  276. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  277. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  278. package/dist/types/src/capabilities/markdown.d.ts +0 -6
  279. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  280. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  281. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  282. package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
  283. package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
  284. package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
  285. package/dist/types/src/testing/playwright/sheet-manager.d.ts.map +0 -1
  286. package/dist/types/src/testing/playwright/sheet.spec.d.ts.map +0 -1
  287. package/dist/types/src/types/schema.d.ts +0 -37
  288. package/dist/types/src/types/schema.d.ts.map +0 -1
  289. package/src/capabilities/anchor-sort.ts +0 -22
  290. package/src/capabilities/capabilities.ts +0 -14
  291. package/src/capabilities/compute-graph-registry.ts +0 -28
  292. package/src/capabilities/intent-resolver.ts +0 -38
  293. package/src/capabilities/markdown.ts +0 -22
  294. package/src/capabilities/react-surface.tsx +0 -39
  295. package/src/testing/playwright/playwright.config.cts +0 -18
  296. package/src/types/schema.ts +0 -60
  297. /package/dist/types/src/{testing/playwright → playwright}/sheet.spec.d.ts +0 -0
@@ -4,10 +4,6 @@
4
4
 
5
5
  import { Event } from '@dxos/async';
6
6
  import {
7
- addressFromA1Notation,
8
- addressToA1Notation,
9
- createSheetName,
10
- isFormula,
11
7
  type CellAddress,
12
8
  type CellRange,
13
9
  type CellScalarValue,
@@ -16,14 +12,18 @@ import {
16
12
  type ComputeNodeEvent,
17
13
  DetailedCellError,
18
14
  ExportedCellChange,
19
- type SimpleCellRange,
20
15
  type SimpleCellAddress,
16
+ type SimpleCellRange,
21
17
  type SimpleDate,
22
18
  type SimpleDateTime,
19
+ addressFromA1Notation,
20
+ addressToA1Notation,
21
+ createSheetName,
22
+ isFormula,
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 { Format, 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,21 +39,21 @@ import {
39
39
  mapFormulaIndicesToRefs,
40
40
  mapFormulaRefsToIndices,
41
41
  } from '../types';
42
- import { type SheetAction, type CellValue, 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.
46
46
  // https://hyperformula.handsontable.com/guide/types-of-values.html
47
47
  // - https://github.com/handsontable/hyperformula/blob/master/src/Cell.ts (CellValueType)
48
48
  // - https://github.com/handsontable/hyperformula/blob/master/src/interpreter/InterpreterValue.ts (NumberType)
49
- const typeMap: Record<string, { type: TypeEnum; format?: FormatEnum }> = {
49
+ const typeMap: Record<string, { type: TypeEnum; format?: Format.TypeFormat }> = {
50
50
  BOOLEAN: { type: TypeEnum.Boolean },
51
51
  NUMBER_RAW: { type: TypeEnum.Number },
52
- NUMBER_PERCENT: { type: TypeEnum.Number, format: FormatEnum.Percent },
53
- NUMBER_CURRENCY: { type: TypeEnum.Number, format: FormatEnum.Currency },
54
- NUMBER_DATETIME: { type: TypeEnum.String, format: FormatEnum.DateTime },
55
- NUMBER_DATE: { type: TypeEnum.String, format: FormatEnum.Date },
56
- NUMBER_TIME: { type: TypeEnum.String, format: FormatEnum.Time },
52
+ NUMBER_PERCENT: { type: TypeEnum.Number, format: Format.TypeFormat.Percent },
53
+ NUMBER_CURRENCY: { type: TypeEnum.Number, format: Format.TypeFormat.Currency },
54
+ NUMBER_DATETIME: { type: TypeEnum.String, format: Format.TypeFormat.DateTime },
55
+ NUMBER_DATE: { type: TypeEnum.String, format: Format.TypeFormat.Date },
56
+ NUMBER_TIME: { type: TypeEnum.String, format: Format.TypeFormat.Time },
57
57
  };
58
58
 
59
59
  const getTopLeft = (range: CellRange): CellAddress => {
@@ -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();
@@ -122,7 +122,9 @@ export class SheetModel extends Resource {
122
122
  */
123
123
  protected override async _open(): Promise<void> {
124
124
  log('initialize', { id: this.id });
125
- initialize(this._sheet);
125
+ Obj.change(this._sheet, (obj) => {
126
+ initialize(obj);
127
+ });
126
128
 
127
129
  this._graph.update.on((event) => {
128
130
  if (event.type === 'functionsUpdated') {
@@ -181,13 +183,19 @@ export class SheetModel extends Resource {
181
183
  }
182
184
 
183
185
  insertRows(i: number, n = 1): string[] {
184
- const idx = insertIndices(this._sheet.rows, i, n, MAX_ROWS);
186
+ let idx: string[] = [];
187
+ Obj.change(this._sheet, (obj) => {
188
+ idx = insertIndices(obj.rows, i, n, MAX_ROWS);
189
+ });
185
190
  this.reset();
186
191
  return idx;
187
192
  }
188
193
 
189
194
  insertColumns(i: number, n = 1): string[] {
190
- const idx = insertIndices(this._sheet.columns, i, n, MAX_COLS);
195
+ let idx: string[] = [];
196
+ Obj.change(this._sheet, (obj) => {
197
+ idx = insertIndices(obj.columns, i, n, MAX_COLS);
198
+ });
191
199
  this.reset();
192
200
  return idx;
193
201
  }
@@ -200,8 +208,10 @@ export class SheetModel extends Resource {
200
208
  const values = this.getCellValues(range).flat();
201
209
  const index = this._sheet.rows.indexOf(rowIndex);
202
210
  this.clear(range);
203
- this._sheet.rows.splice(index, 1);
204
- delete this._sheet.rowMeta[rowIndex];
211
+ Obj.change(this._sheet, (obj) => {
212
+ obj.rows.splice(index, 1);
213
+ delete obj.rowMeta[rowIndex];
214
+ });
205
215
  this.reset();
206
216
  return { axis: 'row', index, axisIndex: rowIndex, axisMeta: this._sheet.rowMeta[rowIndex], values };
207
217
  }
@@ -214,35 +224,43 @@ export class SheetModel extends Resource {
214
224
  const values = this.getCellValues(range).flat();
215
225
  const index = this._sheet.columns.indexOf(colIndex);
216
226
  this.clear(range);
217
- this._sheet.columns.splice(index, 1);
218
- delete this._sheet.columnMeta[colIndex];
227
+ Obj.change(this._sheet, (obj) => {
228
+ obj.columns.splice(index, 1);
229
+ delete obj.columnMeta[colIndex];
230
+ });
219
231
  this.reset();
220
232
  return { axis: 'col', index, axisIndex: colIndex, axisMeta: this._sheet.rowMeta[colIndex], values };
221
233
  }
222
234
 
223
235
  restoreRow({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
224
- this._sheet.rows.splice(index, 0, axisIndex);
225
- values.forEach((value, col) => {
226
- if (value) {
227
- this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = { value };
236
+ Obj.change(this._sheet, (obj) => {
237
+ obj.rows.splice(index, 0, axisIndex);
238
+ values.forEach((value, col) => {
239
+ if (value) {
240
+ obj.cells[`${obj.columns[col]}@${axisIndex}`] = { value };
241
+ }
242
+ });
243
+
244
+ if (axisMeta) {
245
+ obj.rowMeta[axisIndex] = axisMeta;
228
246
  }
229
247
  });
230
- if (axisMeta) {
231
- this._sheet.rowMeta[axisIndex] = axisMeta;
232
- }
233
248
  this.reset();
234
249
  }
235
250
 
236
251
  restoreColumn({ index, axisIndex, axisMeta, values }: SheetAction.RestoreAxis): void {
237
- this._sheet.columns.splice(index, 0, axisIndex);
238
- values.forEach((value, row) => {
239
- if (value) {
240
- this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = { value };
252
+ Obj.change(this._sheet, (obj) => {
253
+ obj.columns.splice(index, 0, axisIndex);
254
+ values.forEach((value, row) => {
255
+ if (value) {
256
+ obj.cells[`${axisIndex}@${obj.rows[row]}`] = { value };
257
+ }
258
+ });
259
+
260
+ if (axisMeta) {
261
+ obj.columnMeta[axisIndex] = axisMeta;
241
262
  }
242
263
  });
243
- if (axisMeta) {
244
- this._sheet.columnMeta[axisIndex] = axisMeta;
245
- }
246
264
  this.reset();
247
265
  }
248
266
 
@@ -259,18 +277,22 @@ export class SheetModel extends Resource {
259
277
  const topLeft = getTopLeft(range);
260
278
  const values = this._iterRange(range, () => null);
261
279
  this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
262
- this._iterRange(range, (cell) => {
263
- const idx = addressToIndex(this._sheet, cell);
264
- delete this._sheet.cells[idx];
280
+ Obj.change(this._sheet, (obj) => {
281
+ this._iterRange(range, (cell) => {
282
+ const idx = addressToIndex(this._sheet, cell);
283
+ delete obj.cells[idx];
284
+ });
265
285
  });
266
286
  }
267
287
 
268
288
  cut(range: CellRange): void {
269
289
  invariant(this._node);
270
290
  this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
271
- this._iterRange(range, (cell) => {
272
- const idx = addressToIndex(this._sheet, cell);
273
- delete this._sheet.cells[idx];
291
+ Obj.change(this._sheet, (obj) => {
292
+ this._iterRange(range, (cell) => {
293
+ const idx = addressToIndex(this._sheet, cell);
294
+ delete obj.cells[idx];
295
+ });
274
296
  });
275
297
  }
276
298
 
@@ -283,13 +305,15 @@ export class SheetModel extends Resource {
283
305
  invariant(this._node);
284
306
  if (!this._node.graph.hf.isClipboardEmpty()) {
285
307
  const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
286
- for (const change of changes) {
287
- if (change instanceof ExportedCellChange) {
288
- const { address, newValue } = change;
289
- const idx = addressToIndex(this._sheet, { row: address.row, col: address.col });
290
- this._sheet.cells[idx] = { value: newValue };
308
+ Obj.change(this._sheet, (obj) => {
309
+ for (const change of changes) {
310
+ if (change instanceof ExportedCellChange) {
311
+ const { address, newValue } = change;
312
+ const idx = addressToIndex(this._sheet, { row: address.row, col: address.col });
313
+ obj.cells[idx] = { value: newValue };
314
+ }
291
315
  }
292
- }
316
+ });
293
317
  }
294
318
  }
295
319
 
@@ -361,7 +385,7 @@ export class SheetModel extends Resource {
361
385
  /**
362
386
  * Get value type.
363
387
  */
364
- getValueDescription(cell: CellAddress): { type: TypeEnum; format?: FormatEnum } | undefined {
388
+ getValueDescription(cell: CellAddress): { type: TypeEnum; format?: Format.TypeFormat } | undefined {
365
389
  invariant(this._node);
366
390
  const addr = toSimpleCellAddress(this._node.sheetId, cell);
367
391
  const type = this._node.graph.hf.getCellValueDetailedType(addr);
@@ -380,11 +404,15 @@ export class SheetModel extends Resource {
380
404
  // Reallocate if > current bounds.
381
405
  let refresh = false;
382
406
  if (cell.row >= this._sheet.rows.length) {
383
- insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
407
+ Obj.change(this._sheet, (obj) => {
408
+ insertIndices(obj.rows, cell.row, 1, MAX_ROWS);
409
+ });
384
410
  refresh = true;
385
411
  }
386
412
  if (cell.col >= this._sheet.columns.length) {
387
- insertIndices(this._sheet.columns, cell.col, 1, MAX_COLS);
413
+ Obj.change(this._sheet, (obj) => {
414
+ insertIndices(obj.columns, cell.col, 1, MAX_COLS);
415
+ });
388
416
  refresh = true;
389
417
  }
390
418
 
@@ -401,20 +429,24 @@ export class SheetModel extends Resource {
401
429
  // Insert into sheet.
402
430
  const idx = addressToIndex(this._sheet, cell);
403
431
  if (value === undefined || value === null) {
404
- delete this._sheet.cells[idx];
432
+ Obj.change(this._sheet, (obj) => {
433
+ delete obj.cells[idx];
434
+ });
405
435
  } else {
406
436
  if (isFormula(value)) {
407
437
  value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
408
438
  }
409
439
 
410
- this._sheet.cells[idx] = { value };
440
+ Obj.change(this._sheet, (obj) => {
441
+ obj.cells[idx] = { value };
442
+ });
411
443
  }
412
444
  }
413
445
 
414
446
  /**
415
447
  * Sets values from a simple map.
416
448
  */
417
- setValues(values: Record<string, CellValue>): void {
449
+ setValues(values: Record<string, Sheet.CellValue>): void {
418
450
  Object.entries(values).forEach(([key, { value }]) => {
419
451
  this.setValue(addressFromA1Notation(key), value);
420
452
  });
@@ -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>();
@@ -0,0 +1,17 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { defineConfig } from '@playwright/test';
6
+
7
+ import { e2ePreset } from '@dxos/test-utils/playwright';
8
+
9
+ export default defineConfig({
10
+ ...e2ePreset(import.meta.dirname),
11
+ // TODO(wittjosiah): Avoid hard-coding ports.
12
+ webServer: {
13
+ command: 'moon run storybook-react:serve-e2e -- --port=9005',
14
+ port: 9005,
15
+ reuseExistingServer: false,
16
+ },
17
+ });
@@ -5,7 +5,7 @@
5
5
  import { type Locator, type Page } from '@playwright/test';
6
6
 
7
7
  import { DxGridManager } from '@dxos/lit-grid/testing';
8
- import { type DxGridPosition, type DxGridAxis } from '@dxos/react-ui-grid';
8
+ import { type DxGridAxis, type DxGridPosition } from '@dxos/react-ui-grid';
9
9
 
10
10
  /**
11
11
  * Test helper for managing dx-grid interactions and assertions in Playwright tests.
@@ -2,7 +2,7 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { expect, test, type Page } from '@playwright/test';
5
+ import { type Page, expect, test } from '@playwright/test';
6
6
 
7
7
  import { faker } from '@dxos/random';
8
8
  import { setupPage, storybookUrl } from '@dxos/test-utils/playwright';
@@ -15,7 +15,8 @@ test.describe('plugin-sheet', () => {
15
15
 
16
16
  test.beforeEach(async ({ browser }) => {
17
17
  const setup = await setupPage(browser, {
18
- url: storybookUrl('plugins-plugin-sheet-sheetcontainer--spec'),
18
+ url: storybookUrl('plugins-plugin-sheet-sheetcontainer--spec', 9005),
19
+ viewportSize: { width: 1280, height: 720 },
19
20
  });
20
21
  page = setup.page;
21
22
  sheet = new SheetManager(page);
@@ -2,11 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { describe, test, expect } from 'vitest';
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
+ await 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
@@ -3,19 +3,19 @@
3
3
  //
4
4
 
5
5
  import { Obj } from '@dxos/echo';
6
+ import { getObjectCore } from '@dxos/echo-db';
6
7
  import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
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 { createSheet, type CreateSheetOptions } 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 />
@@ -2,22 +2,25 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Type } from '@dxos/echo';
5
+ import { type Resource } from '@dxos/react-ui';
6
6
 
7
- import { SHEET_PLUGIN } from './meta';
8
- import { SheetType } from './types';
7
+ import { meta } from './meta';
8
+ import { Sheet } from './types';
9
9
 
10
- export default [
10
+ export const translations = [
11
11
  {
12
12
  'en-US': {
13
- [Type.getTypename(SheetType)]: {
13
+ [Sheet.Sheet.typename]: {
14
14
  'typename label': 'Sheet',
15
15
  'typename label_zero': 'Sheets',
16
16
  'typename label_one': 'Sheet',
17
17
  'typename label_other': 'Sheets',
18
18
  'object name placeholder': 'New sheet',
19
+ 'rename object label': 'Rename sheet',
20
+ 'delete object label': 'Delete sheet',
21
+ 'object deleted label': 'Sheet deleted',
19
22
  },
20
- [SHEET_PLUGIN]: {
23
+ [meta.id]: {
21
24
  'plugin name': 'Sheets',
22
25
  'cell placeholder': 'Cell value...',
23
26
  'range key alignment label': 'Align',
@@ -47,4 +50,4 @@ export default [
47
50
  },
48
51
  },
49
52
  },
50
- ] as const;
53
+ ] as const satisfies Resource[];
@@ -0,0 +1,97 @@
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 { FormInputAnnotation } 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: CellValue }).pipe(FormInputAnnotation.set(false)),
48
+
49
+ // Ordered row indices.
50
+ rows: Schema.Array(Schema.String).pipe(FormInputAnnotation.set(false)),
51
+
52
+ // Ordered column indices.
53
+ columns: Schema.Array(Schema.String).pipe(FormInputAnnotation.set(false)),
54
+
55
+ // Row metadata referenced by index.
56
+ rowMeta: Schema.Record({ key: Schema.String, value: RowColumnMeta }).pipe(FormInputAnnotation.set(false)),
57
+
58
+ // Column metadata referenced by index.
59
+ columnMeta: Schema.Record({ key: Schema.String, value: RowColumnMeta }).pipe(FormInputAnnotation.set(false)),
60
+
61
+ // Cell formatting referenced by indexed range.
62
+ ranges: Schema.Array(Range).pipe(FormInputAnnotation.set(false)),
63
+ }).pipe(
64
+ Type.object({
65
+ typename: 'dxos.org/type/Sheet',
66
+ version: '0.1.0',
67
+ }),
68
+ );
69
+
70
+ export interface Sheet extends Schema.Schema.Type<typeof Sheet> {}
71
+
72
+ export type SheetProps = {
73
+ name?: string;
74
+ cells?: Record<string, CellValue>;
75
+ } & Partial<SheetSize>;
76
+
77
+ export const make = ({ name, cells = {}, ...size }: SheetProps = {}) => {
78
+ const sheet = Obj.make(Sheet, { name, cells: {}, rows: [], columns: [], rowMeta: {}, columnMeta: {}, ranges: [] });
79
+
80
+ // Initialize and set cells within Obj.change to satisfy change context requirements.
81
+ Obj.change(sheet, (s) => {
82
+ initialize(s, size);
83
+
84
+ if (cells) {
85
+ Object.entries(cells).forEach(([key, { value }]) => {
86
+ const idx = addressToIndex(s, addressFromA1Notation(key));
87
+ if (isFormula(value)) {
88
+ value = mapFormulaRefsToIndices(s, value);
89
+ }
90
+
91
+ s.cells[idx] = { value };
92
+ });
93
+ }
94
+ });
95
+
96
+ return sheet;
97
+ };
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+ import { type ComputeGraphRegistry } from '@dxos/compute';
7
+
8
+ import { meta } from '../meta';
9
+
10
+ export namespace SheetCapabilities {
11
+ export const ComputeGraphRegistry = Capability.make<ComputeGraphRegistry>(
12
+ `${meta.id}/capability/compute-graph-registry`,
13
+ );
14
+ }
@@ -2,7 +2,8 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './schema';
5
+ export * from './capabilities';
6
+ export * as Sheet from './Sheet';
6
7
  export * from './sheet-range-types';
7
8
  export * from './types';
8
9
  export * from './util';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { type ClassNameValue } from '@dxos/react-ui';
6
6
 
7
- import { type SheetType } from '../types';
7
+ import { type Sheet } from '../types';
8
8
 
9
9
  export const alignKey = 'alignment';
10
10
  export type AlignKey = typeof alignKey;
@@ -19,7 +19,7 @@ export type StyleKey = typeof styleKey;
19
19
  export type StyleValue = 'highlight' | 'softwrap';
20
20
 
21
21
  // TODO(burdon): Reconcile with plugin-table.
22
- export const cellClassNameForRange = ({ key, value }: SheetType['ranges'][number]): ClassNameValue => {
22
+ export const cellClassNameForRange = ({ key, value }: Sheet.Sheet['ranges'][number]): ClassNameValue => {
23
23
  switch (key) {
24
24
  case alignKey:
25
25
  switch (value) {