@dxos/plugin-sheet 0.6.13 → 0.6.14-main.7bd9c89

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 (324) hide show
  1. package/dist/lib/browser/SheetContainer-AKWROARP.mjs +290 -0
  2. package/dist/lib/browser/SheetContainer-AKWROARP.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-BWN5DZWZ.mjs +74 -0
  4. package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-D3QTX46O.mjs +14 -0
  6. package/dist/lib/browser/chunk-D3QTX46O.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-FGMFOW6U.mjs +1570 -0
  8. package/dist/lib/browser/chunk-FGMFOW6U.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-GSV5QNLD.mjs +2966 -0
  10. package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +7 -0
  11. package/dist/lib/browser/graph-M4IQ76QX.mjs +33 -0
  12. package/dist/lib/browser/graph-M4IQ76QX.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +93 -62
  14. package/dist/lib/browser/index.mjs.map +3 -3
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/meta.mjs +1 -1
  17. package/dist/lib/browser/types.mjs +6 -12
  18. package/dist/lib/node/SheetContainer-N5IQGEFL.cjs +300 -0
  19. package/dist/lib/node/SheetContainer-N5IQGEFL.cjs.map +7 -0
  20. package/dist/lib/node/chunk-53BMSUIK.cjs +1569 -0
  21. package/dist/lib/node/chunk-53BMSUIK.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-5XPK2V4A.cjs} +418 -678
  23. package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-NZARD7UP.cjs} +40 -51
  25. package/dist/lib/node/chunk-NZARD7UP.cjs.map +7 -0
  26. package/dist/lib/node/chunk-QIFIGEKV.cjs +37 -0
  27. package/dist/lib/node/chunk-QIFIGEKV.cjs.map +7 -0
  28. package/dist/lib/node/graph-Q3N2X26H.cjs +55 -0
  29. package/dist/lib/node/graph-Q3N2X26H.cjs.map +7 -0
  30. package/dist/lib/node/index.cjs +105 -69
  31. package/dist/lib/node/index.cjs.map +3 -3
  32. package/dist/lib/node/meta.cjs +3 -3
  33. package/dist/lib/node/meta.cjs.map +1 -1
  34. package/dist/lib/node/meta.json +1 -1
  35. package/dist/lib/node/types.cjs +9 -15
  36. package/dist/lib/node/types.cjs.map +2 -2
  37. package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs +291 -0
  38. package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs.map +7 -0
  39. package/dist/lib/{browser/chunk-D5AGLXJP.mjs → node-esm/chunk-5WPZCXNS.mjs} +411 -678
  40. package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-T3PRH7QS.mjs +1571 -0
  42. package/dist/lib/node-esm/chunk-T3PRH7QS.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +16 -0
  44. package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-WFDTY3IC.mjs +75 -0
  46. package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +7 -0
  47. package/dist/lib/node-esm/graph-SMPUMOV2.mjs +34 -0
  48. package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +280 -0
  50. package/dist/lib/node-esm/index.mjs.map +7 -0
  51. package/dist/lib/node-esm/meta.json +1 -0
  52. package/dist/lib/node-esm/meta.mjs +10 -0
  53. package/dist/lib/node-esm/meta.mjs.map +7 -0
  54. package/dist/lib/node-esm/types.mjs +17 -0
  55. package/dist/lib/node-esm/types.mjs.map +7 -0
  56. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  57. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
  58. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
  59. package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
  60. package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
  61. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +3 -0
  62. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -0
  63. package/dist/types/src/components/FunctionEditor/index.d.ts +2 -0
  64. package/dist/types/src/components/FunctionEditor/index.d.ts.map +1 -0
  65. package/dist/types/src/components/GridSheet/GridSheet.d.ts +3 -0
  66. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
  67. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +6 -0
  68. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
  69. package/dist/types/src/components/{CellEditor/CellEditor.stories.d.ts → GridSheet/SheetCellEditor.stories.d.ts} +5 -9
  70. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -0
  71. package/dist/types/src/components/GridSheet/index.d.ts +2 -0
  72. package/dist/types/src/components/GridSheet/index.d.ts.map +1 -0
  73. package/dist/types/src/components/GridSheet/util.d.ts +16 -0
  74. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
  75. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -0
  76. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -0
  77. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +6 -0
  78. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
  79. package/dist/types/src/components/SheetContainer/index.d.ts +3 -0
  80. package/dist/types/src/components/SheetContainer/index.d.ts.map +1 -0
  81. package/dist/types/src/components/SheetContext/SheetContext.d.ts +26 -0
  82. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -0
  83. package/dist/types/src/components/SheetContext/index.d.ts +2 -0
  84. package/dist/types/src/components/SheetContext/index.d.ts.map +1 -0
  85. package/dist/types/src/components/Toolbar/Toolbar.d.ts +33 -9
  86. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  87. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +4 -32
  88. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  89. package/dist/types/src/components/index.d.ts +4 -4
  90. package/dist/types/src/components/index.d.ts.map +1 -1
  91. package/dist/types/src/defs/index.d.ts +4 -0
  92. package/dist/types/src/defs/index.d.ts.map +1 -0
  93. package/dist/types/src/defs/sheet-range-types.d.ts +13 -0
  94. package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -0
  95. package/dist/types/src/{model → defs}/types.d.ts +8 -3
  96. package/dist/types/src/defs/types.d.ts.map +1 -0
  97. package/dist/types/src/defs/types.test.d.ts.map +1 -0
  98. package/dist/types/src/defs/util.d.ts +43 -0
  99. package/dist/types/src/defs/util.d.ts.map +1 -0
  100. package/dist/types/src/extensions/compute.d.ts +6 -0
  101. package/dist/types/src/extensions/compute.d.ts.map +1 -0
  102. package/dist/types/src/extensions/compute.stories.d.ts +21 -0
  103. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
  104. package/dist/types/src/{components/CellEditor → extensions/editor}/extension.d.ts +1 -1
  105. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
  106. package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
  107. package/dist/types/src/extensions/editor/index.d.ts +2 -0
  108. package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
  109. package/dist/types/src/extensions/index.d.ts +3 -0
  110. package/dist/types/src/extensions/index.d.ts.map +1 -0
  111. package/dist/types/src/graph/compute-graph-registry.d.ts +34 -0
  112. package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
  113. package/dist/types/src/graph/compute-graph.d.ts +64 -0
  114. package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
  115. package/dist/types/src/graph/compute-graph.stories.d.ts +6 -0
  116. package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
  117. package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
  118. package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
  119. package/dist/types/src/graph/compute-node.d.ts +26 -0
  120. package/dist/types/src/graph/compute-node.d.ts.map +1 -0
  121. package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
  122. package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
  123. package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
  124. package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
  125. package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
  126. package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
  127. package/dist/types/src/graph/functions/index.d.ts +4 -0
  128. package/dist/types/src/graph/functions/index.d.ts.map +1 -0
  129. package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
  130. package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
  131. package/dist/types/src/graph/index.d.ts +5 -0
  132. package/dist/types/src/graph/index.d.ts.map +1 -0
  133. package/dist/types/src/graph/testing/index.d.ts +3 -0
  134. package/dist/types/src/graph/testing/index.d.ts.map +1 -0
  135. package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
  136. package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
  137. package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
  138. package/dist/types/src/graph/testing/test-plugin.d.ts.map +1 -0
  139. package/dist/types/src/graph/util.d.ts +2 -0
  140. package/dist/types/src/graph/util.d.ts.map +1 -0
  141. package/dist/types/src/hooks/hooks.stories.d.ts +6 -0
  142. package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
  143. package/dist/types/src/hooks/index.d.ts +4 -0
  144. package/dist/types/src/hooks/index.d.ts.map +1 -0
  145. package/dist/types/src/hooks/threads.d.ts +8 -0
  146. package/dist/types/src/hooks/threads.d.ts.map +1 -0
  147. package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
  148. package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
  149. package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
  150. package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
  151. package/dist/types/src/meta.d.ts +3 -9
  152. package/dist/types/src/meta.d.ts.map +1 -1
  153. package/dist/types/src/model/decorations.d.ts +26 -0
  154. package/dist/types/src/model/decorations.d.ts.map +1 -0
  155. package/dist/types/src/model/index.d.ts +2 -3
  156. package/dist/types/src/model/index.d.ts.map +1 -1
  157. package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +13 -67
  158. package/dist/types/src/model/sheet-model.d.ts.map +1 -0
  159. package/dist/types/src/model/sheet-model.test.d.ts +2 -0
  160. package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
  161. package/dist/types/src/sanity.test.d.ts +2 -0
  162. package/dist/types/src/sanity.test.d.ts.map +1 -0
  163. package/dist/types/src/testing/index.d.ts +2 -0
  164. package/dist/types/src/testing/index.d.ts.map +1 -0
  165. package/dist/types/src/testing/testing.d.ts +8 -0
  166. package/dist/types/src/testing/testing.d.ts.map +1 -0
  167. package/dist/types/src/translations.d.ts +17 -12
  168. package/dist/types/src/translations.d.ts.map +1 -1
  169. package/dist/types/src/types.d.ts +125 -40
  170. package/dist/types/src/types.d.ts.map +1 -1
  171. package/dist/vendor/hyperformula.mjs +37145 -0
  172. package/package.json +58 -52
  173. package/src/SheetPlugin.tsx +52 -74
  174. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
  175. package/src/components/ComputeGraph/index.ts +1 -3
  176. package/src/components/FunctionEditor/FunctionEditor.tsx +45 -0
  177. package/src/components/FunctionEditor/index.ts +5 -0
  178. package/src/components/GridSheet/GridSheet.stories.tsx +44 -0
  179. package/src/components/GridSheet/GridSheet.tsx +201 -0
  180. package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +18 -15
  181. package/src/components/GridSheet/index.ts +5 -0
  182. package/src/components/GridSheet/util.ts +154 -0
  183. package/src/components/SheetContainer/SheetContainer.stories.tsx +43 -0
  184. package/src/components/SheetContainer/SheetContainer.tsx +27 -0
  185. package/src/components/SheetContainer/index.ts +7 -0
  186. package/src/components/SheetContext/SheetContext.tsx +104 -0
  187. package/src/components/SheetContext/index.ts +5 -0
  188. package/src/components/Toolbar/Toolbar.stories.tsx +9 -6
  189. package/src/components/Toolbar/Toolbar.tsx +242 -112
  190. package/src/components/index.ts +4 -3
  191. package/src/defs/index.ts +7 -0
  192. package/src/defs/sheet-range-types.ts +46 -0
  193. package/src/{model → defs}/types.test.ts +8 -9
  194. package/src/{model → defs}/types.ts +24 -14
  195. package/src/defs/util.ts +151 -0
  196. package/src/extensions/compute.stories.tsx +155 -0
  197. package/src/extensions/compute.ts +147 -0
  198. package/src/{components/CellEditor → extensions/editor}/extension.test.ts +4 -6
  199. package/src/{components/CellEditor → extensions/editor}/extension.ts +5 -6
  200. package/src/{components/CellEditor → extensions/editor}/index.ts +0 -1
  201. package/src/extensions/index.ts +6 -0
  202. package/src/graph/compute-graph-registry.ts +90 -0
  203. package/src/graph/compute-graph.stories.tsx +96 -0
  204. package/src/graph/compute-graph.test.ts +87 -0
  205. package/src/graph/compute-graph.ts +242 -0
  206. package/src/graph/compute-node.ts +63 -0
  207. package/src/{components/ComputeGraph → graph/functions}/async-function.ts +25 -15
  208. package/src/{components/ComputeGraph → graph/functions}/edge-function.ts +16 -14
  209. package/src/graph/functions/index.ts +7 -0
  210. package/src/graph/hyperformula.test.ts +14 -0
  211. package/src/graph/index.ts +8 -0
  212. package/src/graph/testing/index.ts +6 -0
  213. package/src/graph/testing/test-builder.ts +54 -0
  214. package/src/{components/ComputeGraph/custom.ts → graph/testing/test-plugin.ts} +44 -14
  215. package/src/graph/util.ts +8 -0
  216. package/src/hooks/hooks.stories.tsx +53 -0
  217. package/src/hooks/index.ts +7 -0
  218. package/src/hooks/threads.ts +147 -0
  219. package/src/hooks/useComputeGraph.ts +28 -0
  220. package/src/hooks/useSheetModel.ts +40 -0
  221. package/src/meta.ts +14 -0
  222. package/src/model/decorations.ts +66 -0
  223. package/src/model/index.ts +2 -3
  224. package/src/model/sheet-model.test.ts +57 -0
  225. package/src/model/sheet-model.ts +418 -0
  226. package/src/sanity.test.ts +40 -0
  227. package/src/{components/Sheet → testing}/index.ts +1 -1
  228. package/src/testing/testing.tsx +68 -0
  229. package/src/translations.ts +6 -1
  230. package/src/types.ts +40 -47
  231. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +0 -1772
  232. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
  233. package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
  234. package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
  235. package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-FUAGSXA4.mjs +0 -82
  237. package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-JRL5LGCE.mjs +0 -18
  239. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
  240. package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
  241. package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
  242. package/dist/lib/browser/testing.mjs +0 -92
  243. package/dist/lib/browser/testing.mjs.map +0 -7
  244. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +0 -1765
  245. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
  246. package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
  247. package/dist/lib/node/chunk-BJ6ZD7MN.cjs +0 -51
  248. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
  249. package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
  250. package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
  251. package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
  252. package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
  253. package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
  254. package/dist/lib/node/testing.cjs +0 -111
  255. package/dist/lib/node/testing.cjs.map +0 -7
  256. package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -14
  257. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
  258. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
  259. package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
  260. package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
  261. package/dist/types/src/components/CellEditor/index.d.ts +0 -3
  262. package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
  263. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
  264. package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
  265. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
  266. package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
  267. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
  268. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
  269. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
  270. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
  271. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
  272. package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
  273. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
  274. package/dist/types/src/components/Sheet/Sheet.d.ts +0 -55
  275. package/dist/types/src/components/Sheet/Sheet.d.ts.map +0 -1
  276. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +0 -54
  277. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +0 -1
  278. package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
  279. package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
  280. package/dist/types/src/components/Sheet/grid.d.ts +0 -52
  281. package/dist/types/src/components/Sheet/grid.d.ts.map +0 -1
  282. package/dist/types/src/components/Sheet/index.d.ts +0 -2
  283. package/dist/types/src/components/Sheet/index.d.ts.map +0 -1
  284. package/dist/types/src/components/Sheet/nav.d.ts +0 -29
  285. package/dist/types/src/components/Sheet/nav.d.ts.map +0 -1
  286. package/dist/types/src/components/Sheet/sheet-context.d.ts +0 -25
  287. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +0 -1
  288. package/dist/types/src/components/Sheet/util.d.ts +0 -18
  289. package/dist/types/src/components/Sheet/util.d.ts.map +0 -1
  290. package/dist/types/src/components/SheetContainer.d.ts +0 -9
  291. package/dist/types/src/components/SheetContainer.d.ts.map +0 -1
  292. package/dist/types/src/components/Toolbar/common.d.ts +0 -20
  293. package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
  294. package/dist/types/src/model/functions.d.ts.map +0 -1
  295. package/dist/types/src/model/model.browser.test.d.ts +0 -2
  296. package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
  297. package/dist/types/src/model/model.d.ts.map +0 -1
  298. package/dist/types/src/model/types.d.ts.map +0 -1
  299. package/dist/types/src/model/types.test.d.ts.map +0 -1
  300. package/dist/types/src/model/util.d.ts +0 -15
  301. package/dist/types/src/model/util.d.ts.map +0 -1
  302. package/dist/types/src/testing.d.ts +0 -9
  303. package/dist/types/src/testing.d.ts.map +0 -1
  304. package/src/components/CellEditor/CellEditor.tsx +0 -113
  305. package/src/components/ComputeGraph/graph-context.tsx +0 -50
  306. package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
  307. package/src/components/ComputeGraph/graph.ts +0 -62
  308. package/src/components/Sheet/Sheet.stories.tsx +0 -287
  309. package/src/components/Sheet/Sheet.tsx +0 -1160
  310. package/src/components/Sheet/formatting.ts +0 -106
  311. package/src/components/Sheet/grid.ts +0 -191
  312. package/src/components/Sheet/nav.ts +0 -157
  313. package/src/components/Sheet/sheet-context.tsx +0 -150
  314. package/src/components/Sheet/util.ts +0 -56
  315. package/src/components/SheetContainer.tsx +0 -34
  316. package/src/components/Toolbar/common.tsx +0 -72
  317. package/src/meta.tsx +0 -18
  318. package/src/model/model.browser.test.ts +0 -100
  319. package/src/model/model.ts +0 -550
  320. package/src/model/util.ts +0 -36
  321. package/src/testing.ts +0 -50
  322. /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
  323. /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
  324. /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { describe, test, expect } from 'vitest';
6
+
7
+ import { HyperFormula } from '#hyperformula';
8
+
9
+ describe('hyperformula', () => {
10
+ test('sanity test', async () => {
11
+ const hf = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' });
12
+ expect(hf).to.exist;
13
+ });
14
+ });
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './compute-graph';
6
+ export * from './compute-graph-registry';
7
+ export * from './compute-node';
8
+ export * from './functions';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './test-builder';
6
+ export * from './test-plugin';
@@ -0,0 +1,54 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Client, type ClientOptions } from '@dxos/client';
6
+ import { type Context, Resource } from '@dxos/context';
7
+ import { invariant } from '@dxos/invariant';
8
+
9
+ import { type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph-registry';
10
+
11
+ export type TestBuilderOptions = ClientOptions & ComputeGraphOptions;
12
+
13
+ // TODO(burdon): Reconcile with @dxos/client/testing.
14
+ export class TestBuilder extends Resource {
15
+ private _client?: Client;
16
+ private _registry?: ComputeGraphRegistry;
17
+
18
+ constructor(private readonly _options: TestBuilderOptions = {}) {
19
+ super();
20
+ }
21
+
22
+ get ctx(): Context {
23
+ return this._ctx;
24
+ }
25
+
26
+ get client(): Client {
27
+ invariant(this._client);
28
+ return this._client;
29
+ }
30
+
31
+ get registry(): ComputeGraphRegistry {
32
+ invariant(this._registry);
33
+ return this._registry;
34
+ }
35
+
36
+ override async _open() {
37
+ const client = new Client(this._options);
38
+ await client.initialize();
39
+ await client.halo.createIdentity();
40
+ this._client = client;
41
+ this._ctx.onDispose(async () => {
42
+ await client.destroy();
43
+ this._client = undefined;
44
+ });
45
+
46
+ const registry = new ComputeGraphRegistry(this._options);
47
+ await registry.open();
48
+ this._registry = registry;
49
+ this._ctx.onDispose(async () => {
50
+ await registry.close();
51
+ this._registry = undefined;
52
+ });
53
+ }
54
+ }
@@ -2,24 +2,36 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { FunctionArgumentType } from 'hyperformula';
6
5
  import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
7
6
  import { type ProcedureAst } from 'hyperformula/typings/parser';
8
7
 
9
8
  import { getDeep } from '@dxos/util';
10
9
 
11
- import { type AsyncFunction, FunctionPluginAsync } from './async-function';
12
-
13
- // TODO(burdon): Factor out.
14
- const parseNumberString = (str: string): number => {
15
- return parseFloat(str.replace(/[^\d.]/g, ''));
16
- };
10
+ import { FunctionArgumentType } from '#hyperformula';
11
+ import { type ComputeGraphPlugin } from '../compute-graph-registry';
12
+ import { type AsyncFunction, AsyncFunctionPlugin } from '../functions';
13
+ import { parseNumberString } from '../util';
17
14
 
18
15
  /**
16
+ * Testing functions run locally (not run via EDGE).
19
17
  * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
20
18
  */
21
- export class CustomPlugin extends FunctionPluginAsync {
19
+ export class TestPlugin extends AsyncFunctionPlugin {
20
+ /**
21
+ * Simple local function returns input value.
22
+ */
22
23
  test(ast: ProcedureAst, state: InterpreterState) {
24
+ const handler: AsyncFunction = async (_value) => {
25
+ return _value;
26
+ };
27
+
28
+ return this.runAsyncFunction(ast, state, handler);
29
+ }
30
+
31
+ /**
32
+ * Simple local function returns random number.
33
+ */
34
+ random(ast: ProcedureAst, state: InterpreterState) {
23
35
  const handler: AsyncFunction = async () => {
24
36
  return Math.random();
25
37
  };
@@ -27,6 +39,9 @@ export class CustomPlugin extends FunctionPluginAsync {
27
39
  return this.runAsyncFunction(ast, state, handler);
28
40
  }
29
41
 
42
+ /**
43
+ * Async HTTP function.
44
+ */
30
45
  crypto(ast: ProcedureAst, state: InterpreterState) {
31
46
  const handler: AsyncFunction = async (_currency) => {
32
47
  const currency = (_currency || 'USD').toUpperCase();
@@ -44,9 +59,15 @@ export class CustomPlugin extends FunctionPluginAsync {
44
59
  }
45
60
  }
46
61
 
47
- CustomPlugin.implementedFunctions = {
62
+ TestPlugin.implementedFunctions = {
48
63
  TEST: {
49
64
  method: 'test',
65
+ parameters: [{ argumentType: FunctionArgumentType.NUMBER, optionalArg: false }],
66
+ isVolatile: true,
67
+ },
68
+
69
+ RANDOM: {
70
+ method: 'random',
50
71
  parameters: [],
51
72
  isVolatile: true,
52
73
  },
@@ -58,13 +79,22 @@ CustomPlugin.implementedFunctions = {
58
79
  },
59
80
  };
60
81
 
61
- export const CustomPluginTranslations = {
82
+ export const TestPluginTranslations = {
62
83
  enGB: {
63
- TEST: 'TEST',
64
- CRYPTO: 'CRYPTO',
84
+ TEST: 'Returns input value',
85
+ RANDOM: 'Random number',
86
+ CRYPTO: 'Crypto token value',
65
87
  },
66
88
  enUS: {
67
- TEST: 'TEST',
68
- CRYPTO: 'CRYPTO',
89
+ TEST: 'Returns input value',
90
+ RANDOM: 'Random number',
91
+ CRYPTO: 'Crypto token value',
69
92
  },
70
93
  };
94
+
95
+ export const testFunctionPlugins: ComputeGraphPlugin[] = [
96
+ {
97
+ plugin: TestPlugin,
98
+ translations: TestPluginTranslations,
99
+ },
100
+ ];
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ // TODO(burdon): Factor out.
6
+ export const parseNumberString = (str: string): number => {
7
+ return parseFloat(str.replace(/[^\d.]/g, ''));
8
+ };
@@ -0,0 +1,53 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import '@dxos-theme';
6
+
7
+ import { type Meta } from '@storybook/react';
8
+ import React, { useEffect, useState } from 'react';
9
+
10
+ import { useSpace } from '@dxos/react-client/echo';
11
+ import { withClientProvider } from '@dxos/react-client/testing';
12
+ import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
13
+ import { withTheme } from '@dxos/storybook-utils';
14
+
15
+ import { ComputeGraphContextProvider } from '../components';
16
+ import { createSheet } from '../defs';
17
+ import { useComputeGraph, useSheetModel } from '../hooks';
18
+ import { withComputeGraphDecorator } from '../testing';
19
+ import { SheetType } from '../types';
20
+
21
+ const DefaultStory = () => {
22
+ const space = useSpace();
23
+ const graph = useComputeGraph(space);
24
+ const [sheet, setSheet] = useState<SheetType>();
25
+ const model = useSheetModel(graph, sheet);
26
+ useEffect(() => {
27
+ if (space) {
28
+ const sheet = space.db.add(createSheet());
29
+ setSheet(sheet);
30
+ }
31
+ }, [space]);
32
+
33
+ return (
34
+ <SyntaxHighlighter language='json'>
35
+ {JSON.stringify({ space: space?.id, graph: graph?.id, sheet: sheet?.id, model: model?.id }, null, 2)}
36
+ </SyntaxHighlighter>
37
+ );
38
+ };
39
+
40
+ export const Default = {};
41
+
42
+ const meta: Meta = {
43
+ title: 'plugins/plugin-sheet/hooks',
44
+ component: ComputeGraphContextProvider,
45
+ render: DefaultStory,
46
+ decorators: [
47
+ withClientProvider({ types: [SheetType], createIdentity: true, createSpace: true }),
48
+ withComputeGraphDecorator(),
49
+ withTheme,
50
+ ],
51
+ };
52
+
53
+ export default meta;
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './useComputeGraph';
6
+ export * from './useSheetModel';
7
+ export * from './threads';
@@ -0,0 +1,147 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { effect } from '@preact/signals-core';
6
+ import { type MutableRefObject, useCallback, useEffect, useMemo } from 'react';
7
+
8
+ import { type IntentResolver, LayoutAction, useIntentDispatcher, useIntentResolver } from '@dxos/app-framework';
9
+ import { debounce } from '@dxos/async';
10
+ import { fullyQualifiedId } from '@dxos/react-client/echo';
11
+ import { type DxGridElement, type DxGridPosition } from '@dxos/react-ui-grid';
12
+
13
+ import { addressFromIndex, addressToIndex, type CellAddress, closest } from '../defs';
14
+ import { SHEET_PLUGIN } from '../meta';
15
+ import { type SheetModel, type Decoration, type Decorations } from '../model';
16
+
17
+ export const useUpdateFocusedCellOnThreadSelection = (
18
+ model: SheetModel,
19
+ grid: MutableRefObject<DxGridElement | null>,
20
+ ) => {
21
+ const handleScrollIntoView: IntentResolver = useCallback(
22
+ ({ action, data }) => {
23
+ switch (action) {
24
+ case LayoutAction.SCROLL_INTO_VIEW: {
25
+ if (!data?.id || data?.cursor === undefined || data?.id !== fullyQualifiedId(model.sheet)) {
26
+ return;
27
+ }
28
+
29
+ // TODO(Zan): Everywhere we refer to the cursor in a thread context should change to `anchor`.
30
+ const cellAddress = addressFromIndex(model.sheet, data.cursor);
31
+ grid.current?.setFocus({ ...cellAddress, plane: 'grid' }, true);
32
+ }
33
+ }
34
+ },
35
+ [model.sheet],
36
+ );
37
+
38
+ useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
39
+ };
40
+
41
+ export const useSelectThreadOnCellFocus = (model: SheetModel, cursor?: CellAddress) => {
42
+ const dispatch = useIntentDispatcher();
43
+
44
+ const activeThreads = useMemo(
45
+ () =>
46
+ model.sheet.threads?.filter(
47
+ (thread): thread is NonNullable<typeof thread> => !!thread && thread.status === 'active',
48
+ ) ?? [],
49
+ [
50
+ // TODO(thure): Surely we can find a better dependency for this…
51
+ JSON.stringify(model.sheet.threads),
52
+ ],
53
+ );
54
+
55
+ const activeThreadAddresses = useMemo(
56
+ () =>
57
+ activeThreads
58
+ .map((thread) => thread.anchor)
59
+ .filter((anchor): anchor is NonNullable<typeof anchor> => anchor !== undefined)
60
+ .map((anchor) => addressFromIndex(model.sheet, anchor)),
61
+ [activeThreads, model.sheet],
62
+ );
63
+
64
+ const selectClosestThread = useCallback(
65
+ (cellAddress: CellAddress) => {
66
+ if (!cellAddress || !activeThreads) {
67
+ return;
68
+ }
69
+
70
+ const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
71
+ if (closestThreadAnchor) {
72
+ const closestThread = activeThreads.find(
73
+ (thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor),
74
+ );
75
+
76
+ if (closestThread) {
77
+ void dispatch([
78
+ { action: 'dxos.org/plugin/thread/action/select', data: { current: fullyQualifiedId(closestThread) } },
79
+ ]);
80
+ }
81
+ }
82
+ },
83
+ [dispatch, activeThreads, activeThreadAddresses, model.sheet],
84
+ );
85
+
86
+ const debounced = useMemo(() => {
87
+ return debounce((cellCoords: DxGridPosition) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
88
+ }, [selectClosestThread]);
89
+
90
+ useEffect(() => {
91
+ if (!cursor) {
92
+ return;
93
+ }
94
+ debounced(cursor);
95
+ }, [cursor, selectClosestThread]);
96
+ };
97
+
98
+ const createThreadDecoration = (cellIndex: string, threadId: string, sheetId: string): Decoration => {
99
+ return {
100
+ type: 'comment',
101
+ classNames: ['bg-greenFill'],
102
+ cellIndex,
103
+ };
104
+ };
105
+
106
+ export const useThreadDecorations = (model: SheetModel, decorations: Decorations) => {
107
+ const sheet = useMemo(() => model.sheet, [model.sheet]);
108
+ const sheetId = useMemo(() => fullyQualifiedId(sheet), [sheet]);
109
+
110
+ useEffect(() => {
111
+ const unsubscribe = effect(() => {
112
+ const activeThreadAnchors = new Set<string>();
113
+ if (!sheet.threads) {
114
+ return;
115
+ }
116
+
117
+ // Process active threads
118
+ for (const thread of sheet.threads) {
119
+ if (!thread || thread.anchor === undefined || thread.status === 'resolved') {
120
+ continue;
121
+ }
122
+
123
+ activeThreadAnchors.add(thread.anchor);
124
+ const index = thread.anchor;
125
+
126
+ // Add decoration only if it doesn't already exist
127
+ const existingDecorations = decorations.getDecorationsForCell(index);
128
+ if (!existingDecorations || !existingDecorations.some((d) => d.type === 'comment')) {
129
+ decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
130
+ }
131
+ }
132
+
133
+ // Remove decorations for resolved or deleted threads
134
+ for (const decoration of decorations.getAllDecorations()) {
135
+ if (decoration.type !== 'comment') {
136
+ continue;
137
+ }
138
+
139
+ if (!activeThreadAnchors.has(decoration.cellIndex)) {
140
+ decorations.removeDecoration(decoration.cellIndex, 'comment');
141
+ }
142
+ }
143
+ });
144
+
145
+ return () => unsubscribe();
146
+ });
147
+ };
@@ -0,0 +1,28 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { useContext } from 'react';
6
+
7
+ import { raise } from '@dxos/debug';
8
+ import { type Space } from '@dxos/react-client/echo';
9
+ import { useAsyncState } from '@dxos/react-hooks';
10
+
11
+ import { ComputeGraphContext } from '../components';
12
+ import { type ComputeGraph } from '../graph';
13
+
14
+ /**
15
+ * Get existing or create new compute graph for the given space.
16
+ */
17
+ export const useComputeGraph = (space?: Space): ComputeGraph | undefined => {
18
+ const { registry } = useContext(ComputeGraphContext) ?? raise(new Error('Missing ComputeGraphContext'));
19
+ const [graph] = useAsyncState(async () => {
20
+ if (space) {
21
+ const graph = registry.getOrCreateGraph(space);
22
+ await graph.open();
23
+ return graph;
24
+ }
25
+ }, [space, registry]);
26
+
27
+ return graph;
28
+ };
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useState } from 'react';
6
+
7
+ import { type ComputeGraph } from '../graph';
8
+ import { SheetModel } from '../model';
9
+ import { type SheetType } from '../types';
10
+
11
+ export type UseSheetModelOptions = {
12
+ readonly?: boolean;
13
+ };
14
+
15
+ export const useSheetModel = (
16
+ graph?: ComputeGraph,
17
+ sheet?: SheetType,
18
+ { readonly }: UseSheetModelOptions = {},
19
+ ): SheetModel | undefined => {
20
+ const [model, setModel] = useState<SheetModel>();
21
+ useEffect(() => {
22
+ if (!graph || !sheet) {
23
+ return;
24
+ }
25
+
26
+ let model: SheetModel | undefined;
27
+ const t = setTimeout(async () => {
28
+ model = new SheetModel(graph, sheet, { readonly });
29
+ await model.open();
30
+ setModel(model);
31
+ });
32
+
33
+ return () => {
34
+ clearTimeout(t);
35
+ void model?.close();
36
+ };
37
+ }, [graph, sheet, readonly]);
38
+
39
+ return model;
40
+ };
package/src/meta.ts ADDED
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type PluginMeta } from '@dxos/app-framework';
6
+
7
+ export const SHEET_PLUGIN = 'dxos.org/plugin/sheet';
8
+
9
+ export default {
10
+ id: SHEET_PLUGIN,
11
+ name: 'Sheet',
12
+ description: 'A simple spreadsheet plugin.',
13
+ icon: 'ph--grid-nine--regular',
14
+ } satisfies PluginMeta;
@@ -0,0 +1,66 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type ReactNode } from 'react';
6
+
7
+ import { create } from '@dxos/echo-schema';
8
+
9
+ export type Decoration = {
10
+ type: string;
11
+ /**
12
+ * A wrapping render function to encapsulate cell content. This function is applied between
13
+ * the cell's border and its padding/layout/content, allowing for custom rendering or
14
+ * additional elements to be inserted around the cell's main content.
15
+ */
16
+ decorate?: (props: { children: ReactNode }) => ReactNode;
17
+ /**
18
+ * An array of CSS class names to be applied to the content of the SheetCell.
19
+ * These classes can be used to style the cell's content independently of its structure.
20
+ */
21
+ classNames?: string[];
22
+ cellIndex: string;
23
+ };
24
+
25
+ export const createDecorations = () => {
26
+ // Reactive object to hold decorations
27
+ // TODO(Zan): Use CELL ID's to key the decoration map.
28
+ // TODO(Zan): Consider maintaining an index of decorations by type.
29
+ const { decorations } = create<{ decorations: Record<string, Decoration[]> }>({ decorations: {} });
30
+
31
+ const addDecoration = (cellIndex: string, decorator: Decoration) => {
32
+ decorations[cellIndex] = [...(decorations[cellIndex] || []), decorator];
33
+ };
34
+
35
+ const removeDecoration = (cellIndex: string, type?: string) => {
36
+ if (type) {
37
+ decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
38
+ } else {
39
+ delete decorations[cellIndex];
40
+ }
41
+ };
42
+
43
+ // TODO(Zan): I should check if returning the a value from a map in a deep signal is a reactive slice.
44
+ const getDecorationsForCell = (cellIndex: string): Decoration[] | undefined => {
45
+ return decorations[cellIndex];
46
+ };
47
+
48
+ const getAllDecorations = (): Decoration[] => {
49
+ const result: Decoration[] = [];
50
+ for (const decoratorArray of Object.values(decorations)) {
51
+ for (const decorator of decoratorArray) {
52
+ result.push(decorator);
53
+ }
54
+ }
55
+ return result;
56
+ };
57
+
58
+ return {
59
+ addDecoration,
60
+ removeDecoration,
61
+ getDecorationsForCell,
62
+ getAllDecorations,
63
+ } as const;
64
+ };
65
+
66
+ export type Decorations = ReturnType<typeof createDecorations>;
@@ -2,6 +2,5 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './functions';
6
- export * from './model';
7
- export * from './types';
5
+ export * from './decorations';
6
+ export * from './sheet-model';
@@ -0,0 +1,57 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { afterEach, beforeEach, describe, expect, test } from 'vitest';
6
+
7
+ import { Trigger } from '@dxos/async';
8
+ import { FunctionType } from '@dxos/plugin-script/types';
9
+
10
+ import { SheetModel } from './sheet-model';
11
+ import { addressFromA1Notation, createSheet } from '../defs';
12
+ import { TestBuilder, testFunctionPlugins } from '../graph/testing';
13
+ import { type CellScalarValue } from '../types';
14
+
15
+ describe('SheetModel', () => {
16
+ let testBuilder: TestBuilder;
17
+ beforeEach(async () => {
18
+ testBuilder = new TestBuilder({ types: [FunctionType], plugins: testFunctionPlugins });
19
+ await testBuilder.open();
20
+ });
21
+ afterEach(async () => {
22
+ await testBuilder.close();
23
+ });
24
+
25
+ test('async function', async () => {
26
+ const space = await testBuilder.client.spaces.create();
27
+ const graph = testBuilder.registry.createGraph(space);
28
+ await graph.open();
29
+
30
+ // TODO(burdon): Create via factory.
31
+ const sheet = createSheet({ rows: 5, columns: 5 });
32
+ const model = new SheetModel(graph, sheet);
33
+ await model.open();
34
+ testBuilder.ctx.onDispose(() => model.close());
35
+
36
+ // Trigger waits for function invocation.
37
+ const trigger = new Trigger<CellScalarValue>();
38
+ model.setValue(addressFromA1Notation('A1'), '=TEST(100)');
39
+ model.update.once((update) => {
40
+ const { type } = update;
41
+ if (type === 'valuesUpdated') {
42
+ const value = model.getValue(addressFromA1Notation('A1'));
43
+ trigger.wake(value);
44
+ }
45
+ });
46
+
47
+ // Initial value will be null.
48
+ const v1 = model.getValue(addressFromA1Notation('A1'));
49
+ expect(v1).to.be.null;
50
+ expect(graph.context.info.invocations.TEST).not.to.exist;
51
+
52
+ // Wait until async update triggered.
53
+ const v2 = await trigger.wait();
54
+ expect(v2).to.eq(100);
55
+ expect(graph.context.info.invocations.TEST).to.eq(1);
56
+ });
57
+ });