@dxos/plugin-sheet 0.7.4 → 0.7.5-labs.5f04cf6

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 (320) hide show
  1. package/dist/lib/browser/SheetContainer-CM4CO3DC.mjs +370 -0
  2. package/dist/lib/browser/SheetContainer-CM4CO3DC.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-FOO6NGBM.mjs +229 -0
  4. package/dist/lib/browser/chunk-FOO6NGBM.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-H23JW3DX.mjs +800 -0
  6. package/dist/lib/browser/chunk-H23JW3DX.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-RABELMEQ.mjs → chunk-K6EUYKWT.mjs} +3 -3
  8. package/dist/lib/browser/chunk-K6EUYKWT.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-PW25VUP6.mjs +15 -0
  10. package/dist/lib/browser/chunk-PW25VUP6.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-T3IVPMRX.mjs +900 -0
  12. package/dist/lib/browser/chunk-T3IVPMRX.mjs.map +7 -0
  13. package/dist/lib/browser/compute-graph-registry-XH6B2SWG.mjs +27 -0
  14. package/dist/lib/browser/compute-graph-registry-XH6B2SWG.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +86 -324
  16. package/dist/lib/browser/index.mjs.map +4 -4
  17. package/dist/lib/browser/intent-resolver-Q7DTHAM5.mjs +47 -0
  18. package/dist/lib/browser/intent-resolver-Q7DTHAM5.mjs.map +7 -0
  19. package/dist/lib/browser/markdown-IKG5FNCA.mjs +26 -0
  20. package/dist/lib/browser/markdown-IKG5FNCA.mjs.map +7 -0
  21. package/dist/lib/browser/meta.json +1 -1
  22. package/dist/lib/browser/react-context-JG43577H.mjs +28 -0
  23. package/dist/lib/browser/react-context-JG43577H.mjs.map +7 -0
  24. package/dist/lib/browser/react-surface-URRC3AFC.mjs +43 -0
  25. package/dist/lib/browser/react-surface-URRC3AFC.mjs.map +7 -0
  26. package/dist/lib/browser/thread-YX6KBQNQ.mjs +17 -0
  27. package/dist/lib/browser/thread-YX6KBQNQ.mjs.map +7 -0
  28. package/dist/lib/browser/types/index.mjs +62 -0
  29. package/dist/lib/node/SheetContainer-TJ3JQLWM.cjs +364 -0
  30. package/dist/lib/node/SheetContainer-TJ3JQLWM.cjs.map +7 -0
  31. package/dist/lib/node/chunk-E3RXOEL6.cjs +935 -0
  32. package/dist/lib/node/chunk-E3RXOEL6.cjs.map +7 -0
  33. package/dist/lib/node/{types.cjs → chunk-FU5K66DS.cjs} +12 -16
  34. package/dist/lib/node/chunk-FU5K66DS.cjs.map +7 -0
  35. package/dist/lib/node/{chunk-2ZVZI2KJ.cjs → chunk-NLDXUFDG.cjs} +7 -7
  36. package/dist/lib/node/chunk-NLDXUFDG.cjs.map +7 -0
  37. package/dist/lib/node/chunk-P4KSGZSS.cjs +251 -0
  38. package/dist/lib/node/chunk-P4KSGZSS.cjs.map +7 -0
  39. package/dist/lib/node/chunk-ZPWW4LPY.cjs +807 -0
  40. package/dist/lib/node/chunk-ZPWW4LPY.cjs.map +7 -0
  41. package/dist/lib/node/compute-graph-registry-ORGTIE5M.cjs +53 -0
  42. package/dist/lib/node/compute-graph-registry-ORGTIE5M.cjs.map +7 -0
  43. package/dist/lib/node/index.cjs +87 -318
  44. package/dist/lib/node/index.cjs.map +4 -4
  45. package/dist/lib/node/intent-resolver-ZUDJJUFG.cjs +60 -0
  46. package/dist/lib/node/intent-resolver-ZUDJJUFG.cjs.map +7 -0
  47. package/dist/lib/node/markdown-EUUL3Q36.cjs +40 -0
  48. package/dist/lib/node/markdown-EUUL3Q36.cjs.map +7 -0
  49. package/dist/lib/node/meta.json +1 -1
  50. package/dist/lib/node/react-context-OOH5QFE2.cjs +50 -0
  51. package/dist/lib/node/react-context-OOH5QFE2.cjs.map +7 -0
  52. package/dist/lib/node/react-surface-IQN5JKSS.cjs +64 -0
  53. package/dist/lib/node/react-surface-IQN5JKSS.cjs.map +7 -0
  54. package/dist/lib/node/{meta.cjs → thread-VBPS23P2.cjs} +12 -10
  55. package/dist/lib/node/thread-VBPS23P2.cjs.map +7 -0
  56. package/dist/lib/node/types/index.cjs +84 -0
  57. package/dist/lib/node/types/index.cjs.map +7 -0
  58. package/dist/lib/node-esm/SheetContainer-QEEFORIC.mjs +371 -0
  59. package/dist/lib/node-esm/SheetContainer-QEEFORIC.mjs.map +7 -0
  60. package/dist/lib/node-esm/{chunk-BM2Q3FFC.mjs → chunk-FMOVRTS4.mjs} +3 -3
  61. package/dist/lib/node-esm/chunk-FMOVRTS4.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-KCXK5UM6.mjs +16 -0
  63. package/dist/lib/node-esm/chunk-KCXK5UM6.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-NSVUOAI6.mjs +901 -0
  65. package/dist/lib/node-esm/chunk-NSVUOAI6.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-OXD6RBFF.mjs +801 -0
  67. package/dist/lib/node-esm/chunk-OXD6RBFF.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-PTOI45NK.mjs +231 -0
  69. package/dist/lib/node-esm/chunk-PTOI45NK.mjs.map +7 -0
  70. package/dist/lib/node-esm/compute-graph-registry-JH2FRHLD.mjs +28 -0
  71. package/dist/lib/node-esm/compute-graph-registry-JH2FRHLD.mjs.map +7 -0
  72. package/dist/lib/node-esm/index.mjs +86 -324
  73. package/dist/lib/node-esm/index.mjs.map +4 -4
  74. package/dist/lib/node-esm/intent-resolver-IF64RN7B.mjs +48 -0
  75. package/dist/lib/node-esm/intent-resolver-IF64RN7B.mjs.map +7 -0
  76. package/dist/lib/node-esm/markdown-D2ZMN7LR.mjs +27 -0
  77. package/dist/lib/node-esm/markdown-D2ZMN7LR.mjs.map +7 -0
  78. package/dist/lib/node-esm/meta.json +1 -1
  79. package/dist/lib/node-esm/react-context-CJVSLO74.mjs +29 -0
  80. package/dist/lib/node-esm/react-context-CJVSLO74.mjs.map +7 -0
  81. package/dist/lib/node-esm/react-surface-XJIX5G3I.mjs +44 -0
  82. package/dist/lib/node-esm/react-surface-XJIX5G3I.mjs.map +7 -0
  83. package/dist/lib/node-esm/thread-HSJD3SR6.mjs +18 -0
  84. package/dist/lib/node-esm/thread-HSJD3SR6.mjs.map +7 -0
  85. package/dist/lib/node-esm/types/index.mjs +63 -0
  86. package/dist/types/src/SheetPlugin.d.ts +1 -3
  87. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  88. package/dist/types/src/capabilities/capabilities.d.ts +5 -0
  89. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  90. package/dist/types/src/capabilities/compute-graph-registry.d.ts +4 -0
  91. package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
  92. package/dist/types/src/capabilities/index.d.ts +17 -0
  93. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  94. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  95. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  96. package/dist/types/src/capabilities/markdown.d.ts +6 -0
  97. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  98. package/dist/types/src/capabilities/react-context.d.ts +8 -0
  99. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  100. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  101. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  102. package/dist/types/src/capabilities/thread.d.ts +6 -0
  103. package/dist/types/src/capabilities/thread.d.ts.map +1 -0
  104. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
  105. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  106. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
  107. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
  108. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  109. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  110. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  111. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  112. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  113. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  114. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  115. package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
  116. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  117. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +7 -0
  118. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -0
  119. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +6 -0
  120. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -0
  121. package/dist/types/src/components/SheetToolbar/align.d.ts +28 -0
  122. package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -0
  123. package/dist/types/src/components/SheetToolbar/comment.d.ts +23 -0
  124. package/dist/types/src/components/SheetToolbar/comment.d.ts.map +1 -0
  125. package/dist/types/src/components/SheetToolbar/index.d.ts +2 -0
  126. package/dist/types/src/components/SheetToolbar/index.d.ts.map +1 -0
  127. package/dist/types/src/components/SheetToolbar/style.d.ts +26 -0
  128. package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -0
  129. package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts +8 -0
  130. package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts.map +1 -0
  131. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +6 -0
  132. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -0
  133. package/dist/types/src/components/index.d.ts +0 -1
  134. package/dist/types/src/components/index.d.ts.map +1 -1
  135. package/dist/types/src/extensions/compute.d.ts +1 -1
  136. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  137. package/dist/types/src/extensions/editor/extension.d.ts +1 -1
  138. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
  139. package/dist/types/src/index.d.ts +2 -3
  140. package/dist/types/src/index.d.ts.map +1 -1
  141. package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
  142. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  143. package/dist/types/src/meta.d.ts +1 -2
  144. package/dist/types/src/meta.d.ts.map +1 -1
  145. package/dist/types/src/model/sheet-model.d.ts +6 -8
  146. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  147. package/dist/types/src/model/testing.d.ts +1 -1
  148. package/dist/types/src/model/testing.d.ts.map +1 -1
  149. package/dist/types/src/model/useSheetModel.d.ts +1 -1
  150. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  151. package/dist/types/src/testing/testing.d.ts +1 -1
  152. package/dist/types/src/testing/testing.d.ts.map +1 -1
  153. package/dist/types/src/{defs → types}/index.d.ts +1 -0
  154. package/dist/types/src/types/index.d.ts.map +1 -0
  155. package/dist/types/src/types/schema.d.ts +105 -0
  156. package/dist/types/src/types/schema.d.ts.map +1 -0
  157. package/dist/types/src/{defs → types}/sheet-range-types.d.ts +1 -1
  158. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
  159. package/dist/types/src/types/types.d.ts +71 -0
  160. package/dist/types/src/types/types.d.ts.map +1 -0
  161. package/dist/types/src/{defs → types}/util.d.ts +5 -1
  162. package/dist/types/src/types/util.d.ts.map +1 -0
  163. package/dist/types/tsconfig.tsbuildinfo +1 -0
  164. package/package.json +47 -61
  165. package/src/SheetPlugin.tsx +70 -176
  166. package/src/capabilities/capabilities.ts +14 -0
  167. package/src/capabilities/compute-graph-registry.ts +25 -0
  168. package/src/capabilities/index.ts +14 -0
  169. package/src/capabilities/intent-resolver.ts +29 -0
  170. package/src/capabilities/markdown.ts +22 -0
  171. package/src/capabilities/react-context.tsx +20 -0
  172. package/src/capabilities/react-surface.tsx +30 -0
  173. package/src/capabilities/thread.ts +14 -0
  174. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
  175. package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
  176. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
  177. package/src/components/GridSheet/GridSheet.stories.tsx +2 -0
  178. package/src/components/GridSheet/GridSheet.tsx +15 -18
  179. package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
  180. package/src/components/GridSheet/util.ts +3 -2
  181. package/src/components/RangeList/RangeList.tsx +2 -1
  182. package/src/components/SheetContainer/SheetContainer.stories.tsx +25 -23
  183. package/src/components/SheetContainer/SheetContainer.tsx +3 -8
  184. package/src/components/SheetContext/SheetContext.tsx +1 -2
  185. package/src/components/{Toolbar/Toolbar.stories.tsx → SheetToolbar/SheetToolbar.stories.tsx} +4 -8
  186. package/src/components/SheetToolbar/SheetToolbar.tsx +48 -0
  187. package/src/components/SheetToolbar/align.ts +68 -0
  188. package/src/components/SheetToolbar/comment.ts +56 -0
  189. package/src/components/{Toolbar → SheetToolbar}/index.ts +1 -1
  190. package/src/components/SheetToolbar/style.ts +72 -0
  191. package/src/components/SheetToolbar/useToolbarAction.ts +87 -0
  192. package/src/components/SheetToolbar/useToolbarState.ts +17 -0
  193. package/src/components/index.ts +0 -1
  194. package/src/extensions/compute.ts +7 -4
  195. package/src/extensions/editor/extension.test.ts +2 -1
  196. package/src/extensions/editor/extension.ts +2 -3
  197. package/src/index.ts +2 -7
  198. package/src/integrations/thread-ranges.ts +28 -24
  199. package/src/meta.ts +1 -1
  200. package/src/model/sheet-model.test.ts +4 -10
  201. package/src/model/sheet-model.ts +30 -22
  202. package/src/model/testing.ts +3 -2
  203. package/src/model/useSheetModel.ts +2 -1
  204. package/src/sanity.test.ts +1 -1
  205. package/src/testing/testing.tsx +2 -3
  206. package/src/{defs → types}/index.ts +1 -0
  207. package/src/types/schema.ts +56 -0
  208. package/src/{defs → types}/sheet-range-types.ts +1 -1
  209. package/src/types/types.ts +67 -0
  210. package/src/{defs → types}/util.ts +13 -13
  211. package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs +0 -296
  212. package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
  213. package/dist/lib/browser/chunk-E5WQ7U7G.mjs +0 -1675
  214. package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
  215. package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
  216. package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
  217. package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
  218. package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
  219. package/dist/lib/browser/chunk-RABELMEQ.mjs.map +0 -7
  220. package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
  221. package/dist/lib/browser/meta.mjs +0 -9
  222. package/dist/lib/browser/types.mjs +0 -16
  223. package/dist/lib/browser/types.mjs.map +0 -7
  224. package/dist/lib/node/SheetContainer-VVVRYTQG.cjs +0 -298
  225. package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
  226. package/dist/lib/node/chunk-2ZVZI2KJ.cjs.map +0 -7
  227. package/dist/lib/node/chunk-45YW2DX2.cjs +0 -1656
  228. package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
  229. package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
  230. package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
  231. package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
  232. package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
  233. package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
  234. package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
  235. package/dist/lib/node/meta.cjs.map +0 -7
  236. package/dist/lib/node/types.cjs.map +0 -7
  237. package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs +0 -297
  238. package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
  239. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
  240. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
  241. package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs.map +0 -7
  242. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
  243. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
  244. package/dist/lib/node-esm/chunk-NYDNXI7L.mjs +0 -1676
  245. package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
  246. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
  247. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
  248. package/dist/lib/node-esm/meta.mjs +0 -10
  249. package/dist/lib/node-esm/meta.mjs.map +0 -7
  250. package/dist/lib/node-esm/types.mjs +0 -17
  251. package/dist/lib/node-esm/types.mjs.map +0 -7
  252. package/dist/types/src/components/SheetObjectSettings.d.ts +0 -7
  253. package/dist/types/src/components/SheetObjectSettings.d.ts.map +0 -1
  254. package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -48
  255. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
  256. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +0 -7
  257. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
  258. package/dist/types/src/components/Toolbar/index.d.ts +0 -2
  259. package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
  260. package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
  261. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
  262. package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
  263. package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
  264. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
  265. package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
  266. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
  267. package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
  268. package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
  269. package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
  270. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
  271. package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
  272. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
  273. package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
  274. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
  275. package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
  276. package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
  277. package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
  278. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
  279. package/dist/types/src/compute-graph/index.d.ts +0 -5
  280. package/dist/types/src/compute-graph/index.d.ts.map +0 -1
  281. package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
  282. package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
  283. package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
  284. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
  285. package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
  286. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
  287. package/dist/types/src/compute-graph/util.d.ts +0 -2
  288. package/dist/types/src/compute-graph/util.d.ts.map +0 -1
  289. package/dist/types/src/defs/index.d.ts.map +0 -1
  290. package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
  291. package/dist/types/src/defs/types.d.ts +0 -26
  292. package/dist/types/src/defs/types.d.ts.map +0 -1
  293. package/dist/types/src/defs/types.test.d.ts +0 -2
  294. package/dist/types/src/defs/types.test.d.ts.map +0 -1
  295. package/dist/types/src/defs/util.d.ts.map +0 -1
  296. package/dist/types/src/types.d.ts +0 -182
  297. package/dist/types/src/types.d.ts.map +0 -1
  298. package/dist/vendor/hyperformula.mjs +0 -37145
  299. package/src/components/SheetObjectSettings.tsx +0 -38
  300. package/src/components/Toolbar/Toolbar.tsx +0 -346
  301. package/src/compute-graph/compute-graph-registry.ts +0 -90
  302. package/src/compute-graph/compute-graph.test.ts +0 -87
  303. package/src/compute-graph/compute-graph.ts +0 -260
  304. package/src/compute-graph/compute-node.ts +0 -62
  305. package/src/compute-graph/functions/async-function.ts +0 -179
  306. package/src/compute-graph/functions/edge-function.ts +0 -102
  307. package/src/compute-graph/functions/function-defs.ts +0 -2427
  308. package/src/compute-graph/functions/index.ts +0 -7
  309. package/src/compute-graph/hyperformula.test.ts +0 -14
  310. package/src/compute-graph/index.ts +0 -8
  311. package/src/compute-graph/testing/index.ts +0 -6
  312. package/src/compute-graph/testing/test-builder.ts +0 -54
  313. package/src/compute-graph/testing/test-plugin.ts +0 -100
  314. package/src/compute-graph/util.ts +0 -8
  315. package/src/defs/types.test.ts +0 -91
  316. package/src/defs/types.ts +0 -88
  317. package/src/types.ts +0 -125
  318. /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
  319. /package/dist/lib/{browser/meta.mjs.map → node-esm/types/index.mjs.map} +0 -0
  320. /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
@@ -0,0 +1,30 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
+ import { getSpace } from '@dxos/react-client/echo';
9
+
10
+ import { RangeList, SheetContainer } from '../components';
11
+ import { SHEET_PLUGIN } from '../meta';
12
+ import { SheetType } from '../types';
13
+
14
+ export default () =>
15
+ contributes(Capabilities.ReactSurface, [
16
+ createSurface({
17
+ id: `${SHEET_PLUGIN}/sheet`,
18
+ role: ['article', 'section'],
19
+ filter: (data): data is { subject: SheetType } => data.subject instanceof SheetType && !!getSpace(data.subject),
20
+ component: ({ data, role }) => (
21
+ <SheetContainer space={getSpace(data.subject)!} sheet={data.subject} role={role} />
22
+ ),
23
+ }),
24
+ createSurface({
25
+ id: `${SHEET_PLUGIN}/settings`,
26
+ role: 'complementary--settings',
27
+ filter: (data): data is { subject: SheetType } => data.subject instanceof SheetType,
28
+ component: ({ data }) => <RangeList sheet={data.subject} />,
29
+ }),
30
+ ]);
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { contributes } from '@dxos/app-framework';
6
+ import { ThreadCapabilities } from '@dxos/plugin-space';
7
+
8
+ import { compareIndexPositions, SheetType } from '../types';
9
+
10
+ export default () =>
11
+ contributes(ThreadCapabilities.Thread, {
12
+ predicate: (data) => data instanceof SheetType,
13
+ createSort: (sheet) => (indexA, indexB) => (!indexA || !indexB ? 0 : compareIndexPositions(sheet, indexA, indexB)),
14
+ });
@@ -4,12 +4,11 @@
4
4
 
5
5
  import React, { createContext, type PropsWithChildren, useContext } from 'react';
6
6
 
7
+ import { type ComputeGraph, type ComputeGraphRegistry } from '@dxos/compute';
7
8
  import { raise } from '@dxos/debug';
8
9
  import { type Space } from '@dxos/react-client/echo';
9
10
  import { useAsyncState } from '@dxos/react-hooks';
10
11
 
11
- import { type ComputeGraph, type ComputeGraphRegistry } from '../../compute-graph';
12
-
13
12
  export type ComputeGraphContextType = {
14
13
  registry: ComputeGraphRegistry;
15
14
  };
@@ -7,19 +7,18 @@ import '@dxos-theme';
7
7
  import { type Meta } from '@storybook/react';
8
8
  import React, { useEffect, useRef, useState } from 'react';
9
9
 
10
- import { FunctionType } from '@dxos/plugin-script/types';
10
+ import { testFunctionPlugins } from '@dxos/compute/testing';
11
+ import { FunctionType } from '@dxos/functions';
11
12
  import { create, useSpace, Filter } from '@dxos/react-client/echo';
12
13
  import { withClientProvider } from '@dxos/react-client/testing';
13
14
  import { Toolbar, Button, Input } from '@dxos/react-ui';
14
15
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
15
16
  import { withTheme } from '@dxos/storybook-utils';
16
17
 
17
- import { testFunctionPlugins } from './testing';
18
- import { useComputeGraph } from '../components';
19
- import { createSheet } from '../defs';
20
- import { useSheetModel } from '../model';
21
- import { withComputeGraphDecorator } from '../testing';
22
- import { SheetType } from '../types';
18
+ import { useComputeGraph } from './ComputeGraphContextProvider';
19
+ import { useSheetModel } from '../../model';
20
+ import { withComputeGraphDecorator } from '../../testing';
21
+ import { createSheet, SheetType } from '../../types';
23
22
 
24
23
  const FUNCTION_NAME = 'TEST';
25
24
 
@@ -4,9 +4,10 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
+ import { addressToA1Notation, isFormula, rangeToA1Notation } from '@dxos/compute';
7
8
  import { Icon } from '@dxos/react-ui';
8
9
 
9
- import { addressToA1Notation, isFormula, mapFormulaIndicesToRefs, rangeToA1Notation } from '../../defs';
10
+ import { mapFormulaIndicesToRefs } from '../../types';
10
11
  import { useSheetContext } from '../SheetContext';
11
12
 
12
13
  export const FunctionEditor = () => {
@@ -7,6 +7,7 @@ import '@dxos-theme';
7
7
  import { type Meta } from '@storybook/react';
8
8
  import React from 'react';
9
9
 
10
+ import { withPluginManager } from '@dxos/app-framework/testing';
10
11
  import { useSpace } from '@dxos/react-client/echo';
11
12
  import { withClientProvider } from '@dxos/react-client/testing';
12
13
  import { withTheme, withLayout } from '@dxos/storybook-utils';
@@ -41,6 +42,7 @@ const meta: Meta = {
41
42
  withComputeGraphDecorator(),
42
43
  withTheme,
43
44
  withLayout({ fullscreen: true, tooltips: true, classNames: 'grid' }),
45
+ withPluginManager(),
44
46
  ],
45
47
  parameters: { translations },
46
48
  };
@@ -13,7 +13,8 @@ import React, {
13
13
  useState,
14
14
  } from 'react';
15
15
 
16
- import { useIntentDispatcher } from '@dxos/app-framework';
16
+ import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
17
+ import { rangeToA1Notation, type CellRange } from '@dxos/compute';
17
18
  import { DropdownMenu, Icon, useTranslation } from '@dxos/react-ui';
18
19
  import { useAttention } from '@dxos/react-ui-attention';
19
20
  import {
@@ -23,20 +24,19 @@ import {
23
24
  Grid,
24
25
  GridCellEditor,
25
26
  type DxGridElement,
27
+ type DxGridPosition,
28
+ type DxGridCellIndex,
26
29
  type EditorKeyHandler,
27
30
  type EditorBlurHandler,
28
31
  type GridContentProps,
29
- type DxGridPosition,
30
- type DxGridCellIndex,
31
32
  parseCellIndex,
32
33
  } from '@dxos/react-ui-grid';
33
34
 
34
35
  import { colLabelCell, rowLabelCell, useSheetModelDxGridProps } from './util';
35
- import { DEFAULT_COLUMNS, DEFAULT_ROWS, rangeToA1Notation, type CellRange } from '../../defs';
36
36
  import { rangeExtension, sheetExtension, type RangeController } from '../../extensions';
37
37
  import { useSelectThreadOnCellFocus, useUpdateFocusedCellOnThreadSelection } from '../../integrations';
38
38
  import { SHEET_PLUGIN } from '../../meta';
39
- import { SheetAction } from '../../types';
39
+ import { DEFAULT_COLS, DEFAULT_ROWS, SheetAction } from '../../types';
40
40
  import { useSheetContext } from '../SheetContext';
41
41
 
42
42
  const inertPosition: DxGridPosition = { plane: 'grid', col: 0, row: 0 };
@@ -72,7 +72,7 @@ export const GridSheet = () => {
72
72
  // a reliable dependency for `useEffect` whereas `useLayoutEffect` does not guarantee the element will be defined.
73
73
  const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
74
74
  const [extraplanarFocus, setExtraplanarFocus] = useState<DxGridPosition | null>(null);
75
- const dispatch = useIntentDispatcher();
75
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
76
76
  const rangeController = useRef<RangeController>();
77
77
  const { hasAttention } = useAttention(id);
78
78
 
@@ -252,24 +252,21 @@ export const GridSheet = () => {
252
252
  switch (operation) {
253
253
  case 'insert-before':
254
254
  case 'insert-after':
255
- return dispatch({
256
- action: SheetAction.INSERT_AXIS,
257
- data: {
255
+ return dispatch(
256
+ createIntent(SheetAction.InsertAxis, {
258
257
  model,
259
258
  axis: contextMenuAxis,
260
259
  index: contextMenuOpen![contextMenuAxis] + (operation === 'insert-before' ? 0 : 1),
261
- } satisfies SheetAction.InsertAxis,
262
- });
263
- break;
260
+ }),
261
+ );
264
262
  case 'drop':
265
- return dispatch({
266
- action: SheetAction.DROP_AXIS,
267
- data: {
263
+ return dispatch(
264
+ createIntent(SheetAction.DropAxis, {
268
265
  model,
269
266
  axis: contextMenuAxis,
270
267
  axisIndex: model.sheet[contextMenuAxis === 'row' ? 'rows' : 'columns'][contextMenuOpen![contextMenuAxis]],
271
- } satisfies SheetAction.DropAxis,
272
- });
268
+ }),
269
+ );
273
270
  }
274
271
  },
275
272
  [contextMenuAxis, contextMenuOpen, model, dispatch],
@@ -309,7 +306,7 @@ export const GridSheet = () => {
309
306
  <GridCellEditor getCellContent={getCellContent} extension={extension} onBlur={handleBlur} />
310
307
  <Grid.Content
311
308
  initialCells={initialCells}
312
- limitColumns={DEFAULT_COLUMNS}
309
+ limitColumns={DEFAULT_COLS}
313
310
  limitRows={DEFAULT_ROWS}
314
311
  columns={columns}
315
312
  rows={rows}
@@ -9,21 +9,20 @@ import React, { useEffect, useMemo, useState } from 'react';
9
9
 
10
10
  import { Client } from '@dxos/client';
11
11
  import { createDocAccessor, type ReactiveEchoObject } from '@dxos/client/echo';
12
+ import { defaultFunctions } from '@dxos/compute';
13
+ import { getRegisteredFunctionNames } from '@dxos/compute/testing';
12
14
  import { automerge } from '@dxos/react-ui-editor';
13
15
  import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
14
16
  import { withTheme } from '@dxos/storybook-utils';
15
17
 
16
- import { HyperFormula } from '#hyperformula';
17
- import { defaultFunctions } from '../../compute-graph';
18
- import { createSheet } from '../../defs';
19
18
  import { sheetExtension } from '../../extensions';
20
- import { SheetType } from '../../types';
19
+ import { createSheet, SheetType } from '../../types';
21
20
 
22
21
  type StoryProps = CellEditorProps;
23
22
 
24
23
  const Story = ({ value, ...props }: StoryProps) => {
25
24
  const extension = useMemo(() => {
26
- const functionNames = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' }).getRegisteredFunctionNames();
25
+ const functionNames = getRegisteredFunctionNames();
27
26
  const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
28
27
  return [sheetExtension({ functions })];
29
28
  }, []);
@@ -54,7 +53,7 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
54
53
  return [];
55
54
  }
56
55
 
57
- const functionNames = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' }).getRegisteredFunctionNames();
56
+ const functionNames = getRegisteredFunctionNames();
58
57
  const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
59
58
  const accessor = createDocAccessor(object, ['cells', cell, 'value']);
60
59
  return [automerge(accessor), sheetExtension({ functions })];
@@ -87,8 +86,8 @@ export const Automerge = {
87
86
  const meta: Meta = {
88
87
  title: 'plugins/plugin-sheet/CellEditor',
89
88
  component: CellEditor,
90
- render: (args: StoryProps) => <Story {...args} />,
91
89
  decorators: [withTheme],
90
+ render: (args: StoryProps) => <Story {...args} />,
92
91
  };
93
92
 
94
93
  export default meta;
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { useEffect, useState } from 'react';
6
6
 
7
+ import { inRange } from '@dxos/compute';
7
8
  import { createDocAccessor, fullyQualifiedId } from '@dxos/react-client/echo';
8
9
  import { parseValue, cellClassesForFieldType } from '@dxos/react-ui-form';
9
10
  import {
@@ -20,9 +21,9 @@ import {
20
21
  } from '@dxos/react-ui-grid';
21
22
  import { mx } from '@dxos/react-ui-theme';
22
23
 
23
- import { inRange, cellClassNameForRange, rangeFromIndex } from '../../defs';
24
24
  import { parseThreadAnchorAsCellRange } from '../../integrations';
25
25
  import { type SheetModel } from '../../model';
26
+ import { cellClassNameForRange, rangeFromIndex } from '../../types';
26
27
 
27
28
  const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
28
29
  return model.sheet.columns.reduce(
@@ -54,7 +55,7 @@ const projectCellProps = (model: SheetModel, col: number, row: number): DxGridCe
54
55
  const ranges = model.sheet.ranges?.filter(({ range }) => inRange(rangeFromIndex(model.sheet, range), address));
55
56
  const threadRefs = model.sheet.threads
56
57
  ?.filter((thread) => {
57
- const range = thread?.anchor && parseThreadAnchorAsCellRange(thread!.anchor);
58
+ const range = thread.target?.anchor && parseThreadAnchorAsCellRange(thread.target!.anchor);
58
59
  return thread && range ? inRange(range, address) : false;
59
60
  })
60
61
  .map((thread) => fullyQualifiedId(thread!))
@@ -4,13 +4,14 @@
4
4
 
5
5
  import React, { useCallback } from 'react';
6
6
 
7
+ import { rangeToA1Notation } from '@dxos/compute';
7
8
  import { S } from '@dxos/echo-schema';
8
9
  import { useTranslation } from '@dxos/react-ui';
9
10
  import { List } from '@dxos/react-ui-list';
10
11
  import { ghostHover } from '@dxos/react-ui-theme';
11
12
 
12
- import { rangeFromIndex, rangeToA1Notation } from '../../defs';
13
13
  import { SHEET_PLUGIN } from '../../meta';
14
+ import { rangeFromIndex } from '../../types';
14
15
  import { Range, type SheetType } from '../../types';
15
16
 
16
17
  export type RangeListProps = {
@@ -7,9 +7,12 @@ import '@dxos-theme';
7
7
  import { type Meta } from '@storybook/react';
8
8
  import React from 'react';
9
9
 
10
- import { type Intent, IntentProvider } from '@dxos/app-framework';
11
- import { useSpace, create } from '@dxos/react-client/echo';
10
+ import { Capabilities, contributes, createResolver, IntentPlugin } from '@dxos/app-framework';
11
+ import { withPluginManager } from '@dxos/app-framework/testing';
12
+ import { fullyQualifiedId, useSpace } from '@dxos/react-client/echo';
12
13
  import { withClientProvider } from '@dxos/react-client/testing';
14
+ import { AttendableContainer } from '@dxos/react-ui-attention';
15
+ import { withAttention } from '@dxos/react-ui-attention/testing';
13
16
  import { withTheme, withLayout } from '@dxos/storybook-utils';
14
17
 
15
18
  import { SheetContainer } from './SheetContainer';
@@ -19,24 +22,6 @@ import { SheetAction, SheetType } from '../../types';
19
22
  import { useComputeGraph } from '../ComputeGraph';
20
23
  import { RangeList } from '../RangeList';
21
24
 
22
- // TODO(thure via wittjosiah): stories/components should be written such that the dependency on intents is external and provided via callback and then the story can implement it differently.
23
- const storybookIntentValue = create({
24
- dispatch: async (intents: Intent | Intent[]) => {
25
- const intent = Array.isArray(intents) ? intents[0] : intents;
26
- switch (intent.action) {
27
- case SheetAction.DROP_AXIS: {
28
- if (!intent.undo) {
29
- const { model, axis, axisIndex } = intent.data as SheetAction.DropAxis;
30
- model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
31
- }
32
- }
33
- }
34
- },
35
- undo: async () => ({}),
36
- history: [],
37
- registerResolver: () => () => {},
38
- });
39
-
40
25
  export const Basic = () => {
41
26
  const space = useSpace();
42
27
  const graph = useComputeGraph(space);
@@ -45,7 +30,11 @@ export const Basic = () => {
45
30
  return null;
46
31
  }
47
32
 
48
- return <SheetContainer space={space} sheet={sheet} role='article' ignoreAttention />;
33
+ return (
34
+ <AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
35
+ <SheetContainer space={space} sheet={sheet} role='article' ignoreAttention />
36
+ </AttendableContainer>
37
+ );
49
38
  };
50
39
 
51
40
  export const Spec = () => {
@@ -57,14 +46,14 @@ export const Spec = () => {
57
46
  }
58
47
 
59
48
  return (
60
- <IntentProvider value={storybookIntentValue}>
49
+ <AttendableContainer id={fullyQualifiedId(sheet)} classNames='contents'>
61
50
  <div role='none' className='grid grid-rows-[66%_33%] grid-cols-1'>
62
51
  <SheetContainer space={space} sheet={sheet} role='article' ignoreAttention />
63
52
  <div role='none' data-testid='grid.range-list'>
64
53
  <RangeList sheet={sheet} />
65
54
  </div>
66
55
  </div>
67
- </IntentProvider>
56
+ </AttendableContainer>
68
57
  );
69
58
  };
70
59
 
@@ -80,6 +69,19 @@ const meta: Meta = {
80
69
  tooltips: true,
81
70
  classNames: 'grid',
82
71
  }),
72
+ withAttention,
73
+ // TODO(wittjosiah): Consider whether we should refactor component so story doesn't need to depend on intents.
74
+ withPluginManager({
75
+ plugins: [IntentPlugin()],
76
+ capabilities: [
77
+ contributes(
78
+ Capabilities.IntentResolver,
79
+ createResolver(SheetAction.DropAxis, ({ model, axis, axisIndex }) => {
80
+ model[axis === 'col' ? 'dropColumn' : 'dropRow'](axisIndex);
81
+ }),
82
+ ),
83
+ ],
84
+ }),
83
85
  ],
84
86
  parameters: { translations },
85
87
  };
@@ -4,7 +4,7 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type Space } from '@dxos/react-client/echo';
7
+ import { fullyQualifiedId, type Space } from '@dxos/react-client/echo';
8
8
  import { StackItem } from '@dxos/react-ui-stack';
9
9
 
10
10
  import { type SheetType } from '../../types';
@@ -12,7 +12,7 @@ import { useComputeGraph } from '../ComputeGraph';
12
12
  import { FunctionEditor } from '../FunctionEditor';
13
13
  import { GridSheet } from '../GridSheet';
14
14
  import { SheetProvider } from '../SheetContext';
15
- import { Toolbar } from '../Toolbar';
15
+ import { SheetToolbar } from '../SheetToolbar';
16
16
 
17
17
  export const SheetContainer = ({
18
18
  space,
@@ -30,12 +30,7 @@ export const SheetContainer = ({
30
30
  return graph ? (
31
31
  <SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>
32
32
  <StackItem.Content toolbar statusbar {...(role === 'section' && { classNames: 'aspect-video' })}>
33
- <Toolbar.Root role={role}>
34
- <Toolbar.Styles />
35
- <Toolbar.Alignment />
36
- <Toolbar.Separator />
37
- <Toolbar.Actions />
38
- </Toolbar.Root>
33
+ <SheetToolbar attendableId={fullyQualifiedId(sheet)} />
39
34
  <GridSheet />
40
35
  <FunctionEditor />
41
36
  </StackItem.Content>
@@ -4,6 +4,7 @@
4
4
 
5
5
  import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
6
6
 
7
+ import { type ComputeGraph, type CellAddress, type CellRange, type CompleteCellRange } from '@dxos/compute';
7
8
  import { invariant } from '@dxos/invariant';
8
9
  import { fullyQualifiedId } from '@dxos/react-client/echo';
9
10
  import {
@@ -14,8 +15,6 @@ import {
14
15
  useGridContext,
15
16
  } from '@dxos/react-ui-grid';
16
17
 
17
- import { type ComputeGraph } from '../../compute-graph';
18
- import { type CellAddress, type CellRange, type CompleteCellRange } from '../../defs';
19
18
  import { type SheetModel, useSheetModel } from '../../model';
20
19
  import { type SheetType } from '../../types';
21
20
 
@@ -10,22 +10,18 @@ import React from 'react';
10
10
  import { textBlockWidth } from '@dxos/react-ui-theme';
11
11
  import { withLayout, withTheme } from '@dxos/storybook-utils';
12
12
 
13
- import { Toolbar } from './Toolbar';
13
+ import { SheetToolbar } from './SheetToolbar';
14
14
  import translations from '../../translations';
15
15
 
16
16
  const DefaultStory = () => {
17
- return (
18
- <Toolbar.Root classNames={textBlockWidth}>
19
- <Toolbar.Alignment />
20
- </Toolbar.Root>
21
- );
17
+ return <SheetToolbar classNames={textBlockWidth} />;
22
18
  };
23
19
 
24
20
  export const Default = {};
25
21
 
26
- const meta: Meta<typeof Toolbar.Root> = {
22
+ const meta: Meta = {
27
23
  title: 'plugins/plugin-sheet/Toolbar',
28
- component: Toolbar.Root,
24
+ component: SheetToolbar,
29
25
  render: DefaultStory,
30
26
  decorators: [withTheme, withLayout({ tooltips: true })],
31
27
  parameters: { translations, layout: 'fullscreen' },
@@ -0,0 +1,48 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { type PropsWithChildren, useCallback } from 'react';
6
+
7
+ import { type ThemedClassName } from '@dxos/react-ui';
8
+ import { createGapSeparator, MenuProvider, ToolbarMenu, useMenuActions } from '@dxos/react-ui-menu';
9
+
10
+ import { createAlign, useAlignState } from './align';
11
+ import { createComment, useCommentState } from './comment';
12
+ import { createStyle, useStyleState } from './style';
13
+ import { useToolbarAction } from './useToolbarAction';
14
+ import { type ToolbarState, useToolbarState } from './useToolbarState';
15
+
16
+ //
17
+ // Root
18
+ //
19
+
20
+ export type SheetToolbarProps = ThemedClassName<PropsWithChildren<{ attendableId?: string }>>;
21
+
22
+ const createToolbarActions = (state: ToolbarState) => {
23
+ const align = createAlign(state);
24
+ const style = createStyle(state);
25
+ const gap = createGapSeparator();
26
+ const comment = createComment(state);
27
+ return {
28
+ nodes: [...align.nodes, ...style.nodes, ...gap.nodes, ...comment.nodes],
29
+ edges: [...align.edges, ...style.edges, ...gap.edges, ...comment.edges],
30
+ };
31
+ };
32
+
33
+ export const SheetToolbar = ({ attendableId, classNames }: SheetToolbarProps) => {
34
+ const state = useToolbarState({});
35
+ useAlignState(state);
36
+ useStyleState(state);
37
+ useCommentState(state);
38
+
39
+ const actionsCreator = useCallback(() => createToolbarActions(state), [state]);
40
+ const menu = useMenuActions(actionsCreator);
41
+ const handleAction = useToolbarAction(state);
42
+
43
+ return (
44
+ <MenuProvider {...menu} attendableId={attendableId} onAction={handleAction}>
45
+ <ToolbarMenu classNames={classNames} />
46
+ </MenuProvider>
47
+ );
48
+ };
@@ -0,0 +1,68 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useEffect } from 'react';
6
+
7
+ import { inRange } from '@dxos/compute';
8
+ import { createMenuAction, createMenuItemGroup, type ToolbarMenuActionGroupProperties } from '@dxos/react-ui-menu';
9
+
10
+ import { SHEET_PLUGIN } from '../../meta';
11
+ import { type AlignKey, alignKey, type AlignValue, rangeFromIndex } from '../../types';
12
+ import { useSheetContext } from '../SheetContext';
13
+
14
+ export type AlignAction = { key: AlignKey; value: AlignValue };
15
+
16
+ export type AlignState = { [alignKey]: AlignValue | undefined };
17
+
18
+ const aligns: Record<AlignValue, string> = {
19
+ start: 'ph--text-align-left--regular',
20
+ center: 'ph--text-align-center--regular',
21
+ end: 'ph--text-align-right--regular',
22
+ };
23
+
24
+ export const useAlignState = (state: Partial<AlignState>) => {
25
+ const { cursor, model } = useSheetContext();
26
+ useEffect(() => {
27
+ // TODO(thure): Can this O(n) call be memoized?
28
+ state[alignKey] = (
29
+ cursor
30
+ ? model.sheet.ranges?.findLast(
31
+ ({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
32
+ )?.value
33
+ : undefined
34
+ ) as AlignValue | undefined;
35
+ }, [cursor, model.sheet]);
36
+ };
37
+
38
+ const createAlignGroupAction = (value?: AlignValue) =>
39
+ createMenuItemGroup('align', {
40
+ label: ['align label', { ns: SHEET_PLUGIN }],
41
+ variant: 'toggleGroup',
42
+ selectCardinality: 'single',
43
+ value: `${alignKey}--${value}`,
44
+ } as ToolbarMenuActionGroupProperties);
45
+
46
+ const createAlignActions = (value?: AlignValue) =>
47
+ Object.entries(aligns).map(([alignValue, icon]) => {
48
+ return createMenuAction<AlignAction>(`${alignKey}--${alignValue}`, {
49
+ key: alignKey,
50
+ value: alignValue as AlignValue,
51
+ checked: value === alignValue,
52
+ label: [`range value ${alignValue} label`, { ns: SHEET_PLUGIN }],
53
+ icon,
54
+ testId: `grid.toolbar.${alignKey}.${alignValue}`,
55
+ });
56
+ });
57
+
58
+ export const createAlign = ({ [alignKey]: alignValue }: Partial<AlignState>) => {
59
+ const alignGroup = createAlignGroupAction(alignValue);
60
+ const alignActions = createAlignActions(alignValue);
61
+ return {
62
+ nodes: [alignGroup, ...alignActions],
63
+ edges: [
64
+ { source: 'root', target: 'align' },
65
+ ...alignActions.map(({ id }) => ({ source: alignGroup.id, target: id })),
66
+ ],
67
+ };
68
+ };
@@ -0,0 +1,56 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useMemo } from 'react';
6
+
7
+ import { RefArray } from '@dxos/live-object';
8
+ import { createMenuAction } from '@dxos/react-ui-menu';
9
+
10
+ import { SHEET_PLUGIN } from '../../meta';
11
+ import { commentKey, type CommentKey, type CommentValue, rangeToIndex } from '../../types';
12
+ import { useSheetContext } from '../SheetContext';
13
+
14
+ export type CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };
15
+
16
+ export type CommentState = { commentEnabled: 'comment' | 'no cursor' | 'selection overlaps existing comment' };
17
+
18
+ export const useCommentState = (state: Partial<CommentState>) => {
19
+ const { cursorFallbackRange, model } = useSheetContext();
20
+
21
+ // TODO(thure): Can this O(n) call be memoized?
22
+ const overlapsCommentAnchor = useMemo(
23
+ () =>
24
+ RefArray.allResolvedTargets(model.sheet.threads ?? [])
25
+ .filter((thread) => thread.status !== 'resolved')
26
+ .some((thread) => {
27
+ if (!cursorFallbackRange) {
28
+ return false;
29
+ }
30
+ return rangeToIndex(model.sheet, cursorFallbackRange) === thread.anchor;
31
+ }),
32
+ [cursorFallbackRange, model.sheet],
33
+ );
34
+
35
+ useEffect(() => {
36
+ state.commentEnabled = !cursorFallbackRange
37
+ ? 'no cursor'
38
+ : overlapsCommentAnchor
39
+ ? 'selection overlaps existing comment'
40
+ : 'comment';
41
+ }, [overlapsCommentAnchor, cursorFallbackRange]);
42
+ };
43
+
44
+ const createCommentAction = (state: Partial<CommentState>) =>
45
+ createMenuAction<Pick<CommentAction, 'key'>>('comment', {
46
+ key: commentKey,
47
+ testId: 'editor.toolbar.comment',
48
+ icon: 'ph--chat-text--regular',
49
+ label: [`${state.commentEnabled} label`, { ns: SHEET_PLUGIN }],
50
+ disabled: state.commentEnabled !== 'comment',
51
+ });
52
+
53
+ export const createComment = (state: Partial<CommentState>) => ({
54
+ nodes: [createCommentAction(state)],
55
+ edges: [{ source: 'root', target: 'comment' }],
56
+ });
@@ -2,4 +2,4 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './Toolbar';
5
+ export * from './SheetToolbar';