@dxos/plugin-sheet 0.6.12 → 0.6.13-main.548ca8d

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 (325) hide show
  1. package/dist/lib/browser/SheetContainer-NDNIS44E.mjs +265 -0
  2. package/dist/lib/browser/SheetContainer-NDNIS44E.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-AQSGDA4X.mjs +1614 -0
  4. package/dist/lib/browser/chunk-AQSGDA4X.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-GKI67SEF.mjs +69 -0
  8. package/dist/lib/browser/chunk-GKI67SEF.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 +4 -10
  18. package/dist/lib/node/SheetContainer-YSQGJD7K.cjs +276 -0
  19. package/dist/lib/node/SheetContainer-YSQGJD7K.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-5XPK2V4A.cjs} +418 -678
  21. package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
  22. package/dist/lib/node/chunk-6F43RV45.cjs +1610 -0
  23. package/dist/lib/node/chunk-6F43RV45.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-ER3PM7GD.cjs} +29 -45
  25. package/dist/lib/node/chunk-ER3PM7GD.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 +8 -14
  36. package/dist/lib/node/types.cjs.map +2 -2
  37. package/dist/lib/node-esm/SheetContainer-M7WRMZDU.mjs +266 -0
  38. package/dist/lib/node-esm/SheetContainer-M7WRMZDU.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-ELTFPX5B.mjs +1615 -0
  42. package/dist/lib/node-esm/chunk-ELTFPX5B.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-ZVLLQ2PJ.mjs +70 -0
  46. package/dist/lib/node-esm/chunk-ZVLLQ2PJ.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 +9 -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} +4 -4
  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 +11 -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 +27 -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 +36 -6
  86. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  87. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +19 -14
  88. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  89. package/dist/types/src/components/index.d.ts +3 -2
  90. package/dist/types/src/components/index.d.ts.map +1 -1
  91. package/dist/types/src/defs/index.d.ts +3 -0
  92. package/dist/types/src/defs/index.d.ts.map +1 -0
  93. package/dist/types/src/{model → defs}/types.d.ts +8 -3
  94. package/dist/types/src/defs/types.d.ts.map +1 -0
  95. package/dist/types/src/defs/types.test.d.ts.map +1 -0
  96. package/dist/types/src/defs/util.d.ts +43 -0
  97. package/dist/types/src/defs/util.d.ts.map +1 -0
  98. package/dist/types/src/extensions/compute.d.ts +6 -0
  99. package/dist/types/src/extensions/compute.d.ts.map +1 -0
  100. package/dist/types/src/extensions/compute.stories.d.ts +26 -0
  101. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
  102. package/dist/types/src/{components/CellEditor → extensions/editor}/extension.d.ts +1 -1
  103. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
  104. package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
  105. package/dist/types/src/extensions/editor/index.d.ts +2 -0
  106. package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
  107. package/dist/types/src/extensions/index.d.ts +3 -0
  108. package/dist/types/src/extensions/index.d.ts.map +1 -0
  109. package/dist/types/src/graph/compute-graph-registry.d.ts +34 -0
  110. package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
  111. package/dist/types/src/graph/compute-graph.d.ts +64 -0
  112. package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
  113. package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
  114. package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
  115. package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
  116. package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
  117. package/dist/types/src/graph/compute-node.d.ts +26 -0
  118. package/dist/types/src/graph/compute-node.d.ts.map +1 -0
  119. package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
  120. package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
  121. package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
  122. package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
  123. package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
  124. package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
  125. package/dist/types/src/graph/functions/index.d.ts +4 -0
  126. package/dist/types/src/graph/functions/index.d.ts.map +1 -0
  127. package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
  128. package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
  129. package/dist/types/src/graph/index.d.ts +5 -0
  130. package/dist/types/src/graph/index.d.ts.map +1 -0
  131. package/dist/types/src/graph/testing/index.d.ts +3 -0
  132. package/dist/types/src/graph/testing/index.d.ts.map +1 -0
  133. package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
  134. package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
  135. package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
  136. package/dist/types/src/graph/testing/test-plugin.d.ts.map +1 -0
  137. package/dist/types/src/graph/util.d.ts +2 -0
  138. package/dist/types/src/graph/util.d.ts.map +1 -0
  139. package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
  140. package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
  141. package/dist/types/src/hooks/index.d.ts +5 -0
  142. package/dist/types/src/hooks/index.d.ts.map +1 -0
  143. package/dist/types/src/hooks/threads.d.ts +8 -0
  144. package/dist/types/src/hooks/threads.d.ts.map +1 -0
  145. package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
  146. package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
  147. package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
  148. package/dist/types/src/hooks/useFormattingModel.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 +25 -0
  154. package/dist/types/src/model/decorations.d.ts.map +1 -0
  155. package/dist/types/src/model/formatting-model.d.ts +19 -0
  156. package/dist/types/src/model/formatting-model.d.ts.map +1 -0
  157. package/dist/types/src/model/index.d.ts +3 -3
  158. package/dist/types/src/model/index.d.ts.map +1 -1
  159. package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +13 -67
  160. package/dist/types/src/model/sheet-model.d.ts.map +1 -0
  161. package/dist/types/src/model/sheet-model.test.d.ts +2 -0
  162. package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
  163. package/dist/types/src/sanity.test.d.ts +2 -0
  164. package/dist/types/src/sanity.test.d.ts.map +1 -0
  165. package/dist/types/src/testing/index.d.ts +2 -0
  166. package/dist/types/src/testing/index.d.ts.map +1 -0
  167. package/dist/types/src/testing/testing.d.ts +8 -0
  168. package/dist/types/src/testing/testing.d.ts.map +1 -0
  169. package/dist/types/src/translations.d.ts +17 -12
  170. package/dist/types/src/translations.d.ts.map +1 -1
  171. package/dist/types/src/types.d.ts +98 -32
  172. package/dist/types/src/types.d.ts.map +1 -1
  173. package/dist/vendor/hyperformula.mjs +37145 -0
  174. package/package.json +57 -52
  175. package/src/SheetPlugin.tsx +52 -74
  176. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
  177. package/src/components/ComputeGraph/index.ts +1 -3
  178. package/src/components/FunctionEditor/FunctionEditor.tsx +45 -0
  179. package/src/components/FunctionEditor/index.ts +5 -0
  180. package/src/components/GridSheet/GridSheet.stories.tsx +41 -0
  181. package/src/components/GridSheet/GridSheet.tsx +161 -0
  182. package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +8 -8
  183. package/src/components/GridSheet/index.ts +5 -0
  184. package/src/components/GridSheet/util.ts +144 -0
  185. package/src/components/SheetContainer/SheetContainer.stories.tsx +40 -0
  186. package/src/components/SheetContainer/SheetContainer.tsx +52 -0
  187. package/src/components/SheetContainer/index.ts +7 -0
  188. package/src/components/SheetContext/SheetContext.tsx +108 -0
  189. package/src/components/SheetContext/index.ts +5 -0
  190. package/src/components/Toolbar/Toolbar.tsx +167 -85
  191. package/src/components/index.ts +2 -0
  192. package/src/defs/index.ts +6 -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 +151 -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 +93 -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 +50 -0
  217. package/src/hooks/index.ts +8 -0
  218. package/src/hooks/threads.ts +147 -0
  219. package/src/hooks/useComputeGraph.ts +28 -0
  220. package/src/hooks/useFormattingModel.ts +11 -0
  221. package/src/hooks/useSheetModel.ts +40 -0
  222. package/src/meta.ts +14 -0
  223. package/src/model/decorations.ts +64 -0
  224. package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +30 -20
  225. package/src/model/index.ts +3 -3
  226. package/src/model/sheet-model.test.ts +57 -0
  227. package/src/model/sheet-model.ts +418 -0
  228. package/src/sanity.test.ts +40 -0
  229. package/src/{components/Sheet → testing}/index.ts +1 -1
  230. package/src/testing/testing.tsx +68 -0
  231. package/src/translations.ts +6 -1
  232. package/src/types.ts +40 -41
  233. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +0 -1772
  234. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
  235. package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
  236. package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
  237. package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-FUAGSXA4.mjs +0 -82
  239. package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
  240. package/dist/lib/browser/chunk-JRL5LGCE.mjs +0 -18
  241. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
  242. package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
  243. package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
  244. package/dist/lib/browser/testing.mjs +0 -92
  245. package/dist/lib/browser/testing.mjs.map +0 -7
  246. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +0 -1765
  247. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
  248. package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
  249. package/dist/lib/node/chunk-BJ6ZD7MN.cjs +0 -51
  250. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
  251. package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
  252. package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
  253. package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
  254. package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
  255. package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
  256. package/dist/lib/node/testing.cjs +0 -111
  257. package/dist/lib/node/testing.cjs.map +0 -7
  258. package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -14
  259. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
  260. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
  261. package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
  262. package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
  263. package/dist/types/src/components/CellEditor/index.d.ts +0 -3
  264. package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
  265. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
  266. package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
  267. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
  268. package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
  269. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
  270. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
  271. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
  272. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
  273. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
  274. package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
  275. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
  276. package/dist/types/src/components/Sheet/Sheet.d.ts +0 -55
  277. package/dist/types/src/components/Sheet/Sheet.d.ts.map +0 -1
  278. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +0 -54
  279. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +0 -1
  280. package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
  281. package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
  282. package/dist/types/src/components/Sheet/grid.d.ts +0 -52
  283. package/dist/types/src/components/Sheet/grid.d.ts.map +0 -1
  284. package/dist/types/src/components/Sheet/index.d.ts +0 -2
  285. package/dist/types/src/components/Sheet/index.d.ts.map +0 -1
  286. package/dist/types/src/components/Sheet/nav.d.ts +0 -29
  287. package/dist/types/src/components/Sheet/nav.d.ts.map +0 -1
  288. package/dist/types/src/components/Sheet/sheet-context.d.ts +0 -25
  289. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +0 -1
  290. package/dist/types/src/components/Sheet/util.d.ts +0 -18
  291. package/dist/types/src/components/Sheet/util.d.ts.map +0 -1
  292. package/dist/types/src/components/SheetContainer.d.ts +0 -9
  293. package/dist/types/src/components/SheetContainer.d.ts.map +0 -1
  294. package/dist/types/src/components/Toolbar/common.d.ts +0 -20
  295. package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
  296. package/dist/types/src/model/functions.d.ts.map +0 -1
  297. package/dist/types/src/model/model.browser.test.d.ts +0 -2
  298. package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
  299. package/dist/types/src/model/model.d.ts.map +0 -1
  300. package/dist/types/src/model/types.d.ts.map +0 -1
  301. package/dist/types/src/model/types.test.d.ts.map +0 -1
  302. package/dist/types/src/model/util.d.ts +0 -15
  303. package/dist/types/src/model/util.d.ts.map +0 -1
  304. package/dist/types/src/testing.d.ts +0 -9
  305. package/dist/types/src/testing.d.ts.map +0 -1
  306. package/src/components/CellEditor/CellEditor.tsx +0 -113
  307. package/src/components/ComputeGraph/graph-context.tsx +0 -50
  308. package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
  309. package/src/components/ComputeGraph/graph.ts +0 -62
  310. package/src/components/Sheet/Sheet.stories.tsx +0 -287
  311. package/src/components/Sheet/Sheet.tsx +0 -1160
  312. package/src/components/Sheet/grid.ts +0 -191
  313. package/src/components/Sheet/nav.ts +0 -157
  314. package/src/components/Sheet/sheet-context.tsx +0 -150
  315. package/src/components/Sheet/util.ts +0 -56
  316. package/src/components/SheetContainer.tsx +0 -34
  317. package/src/components/Toolbar/common.tsx +0 -72
  318. package/src/meta.tsx +0 -18
  319. package/src/model/model.browser.test.ts +0 -100
  320. package/src/model/model.ts +0 -550
  321. package/src/model/util.ts +0 -36
  322. package/src/testing.ts +0 -50
  323. /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
  324. /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
  325. /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
@@ -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,50 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import '@dxos-theme';
6
+
7
+ import React, { useEffect, useState } from 'react';
8
+
9
+ import { useSpace } from '@dxos/react-client/echo';
10
+ import { withClientProvider } from '@dxos/react-client/testing';
11
+ import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
12
+ import { withTheme } from '@dxos/storybook-utils';
13
+
14
+ import { ComputeGraphContextProvider } from '../components';
15
+ import { createSheet } from '../defs';
16
+ import { useComputeGraph, useSheetModel } from '../hooks';
17
+ import { withComputeGraphDecorator } from '../testing';
18
+ import { SheetType } from '../types';
19
+
20
+ const Story = () => {
21
+ const space = useSpace();
22
+ const graph = useComputeGraph(space);
23
+ const [sheet, setSheet] = useState<SheetType>();
24
+ const model = useSheetModel(graph, sheet);
25
+ useEffect(() => {
26
+ if (space) {
27
+ const sheet = space.db.add(createSheet());
28
+ setSheet(sheet);
29
+ }
30
+ }, [space]);
31
+
32
+ return (
33
+ <SyntaxHighlighter language='json'>
34
+ {JSON.stringify({ space: space?.id, graph: graph?.id, sheet: sheet?.id, model: model?.id }, null, 2)}
35
+ </SyntaxHighlighter>
36
+ );
37
+ };
38
+
39
+ export default {
40
+ title: 'plugin-sheet/hooks',
41
+ component: ComputeGraphContextProvider,
42
+ decorators: [
43
+ withClientProvider({ types: [SheetType], createIdentity: true, createSpace: true }),
44
+ withComputeGraphDecorator(),
45
+ withTheme,
46
+ ],
47
+ render: (args: any) => <Story {...args} />,
48
+ };
49
+
50
+ export const Default = {};
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './useComputeGraph';
6
+ export * from './useFormattingModel';
7
+ export * from './useSheetModel';
8
+ 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,11 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { useMemo } from 'react';
6
+
7
+ import { type SheetModel, FormattingModel } from '../model';
8
+
9
+ export const useFormattingModel = (model: SheetModel | undefined): FormattingModel | undefined => {
10
+ return useMemo(() => model && new FormattingModel(model), [model]);
11
+ };
@@ -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,64 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { create } from '@dxos/echo-schema';
6
+
7
+ export type Decoration = {
8
+ type: string;
9
+ /**
10
+ * A wrapping render function to encapsulate cell content. This function is applied between
11
+ * the cell's border and its padding/layout/content, allowing for custom rendering or
12
+ * additional elements to be inserted around the cell's main content.
13
+ */
14
+ decorate?: (props: { children: React.ReactNode }) => React.ReactNode;
15
+ /**
16
+ * An array of CSS class names to be applied to the content of the SheetCell.
17
+ * These classes can be used to style the cell's content independently of its structure.
18
+ */
19
+ classNames?: string[];
20
+ cellIndex: string;
21
+ };
22
+
23
+ export const createDecorations = () => {
24
+ // Reactive object to hold decorations
25
+ // TODO(Zan): Use CELL ID's to key the decoration map.
26
+ // TODO(Zan): Consider maintaining an index of decorations by type.
27
+ const { decorations } = create<{ decorations: Record<string, Decoration[]> }>({ decorations: {} });
28
+
29
+ const addDecoration = (cellIndex: string, decorator: Decoration) => {
30
+ decorations[cellIndex] = [...(decorations[cellIndex] || []), decorator];
31
+ };
32
+
33
+ const removeDecoration = (cellIndex: string, type?: string) => {
34
+ if (type) {
35
+ decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
36
+ } else {
37
+ delete decorations[cellIndex];
38
+ }
39
+ };
40
+
41
+ // TODO(Zan): I should check if returning the a value from a map in a deep signal is a reactive slice.
42
+ const getDecorationsForCell = (cellIndex: string): Decoration[] | undefined => {
43
+ return decorations[cellIndex];
44
+ };
45
+
46
+ const getAllDecorations = (): Decoration[] => {
47
+ const result: Decoration[] = [];
48
+ for (const decoratorArray of Object.values(decorations)) {
49
+ for (const decorator of decoratorArray) {
50
+ result.push(decorator);
51
+ }
52
+ }
53
+ return result;
54
+ };
55
+
56
+ return {
57
+ addDecoration,
58
+ removeDecoration,
59
+ getDecorationsForCell,
60
+ getAllDecorations,
61
+ } as const;
62
+ };
63
+
64
+ export type Decorations = ReturnType<typeof createDecorations>;
@@ -3,18 +3,28 @@
3
3
  //
4
4
 
5
5
  import { type ClassNameValue } from '@dxos/react-ui-types';
6
+ import { FieldValueType } from '@dxos/schema';
6
7
 
7
- import { type SheetModel, type CellAddress, inRange } from '../../model';
8
- import { ValueTypeEnum } from '../../types';
8
+ import { type SheetModel } from './sheet-model';
9
+ import { type CellAddress, inRange } from '../defs';
10
+ import { addressToIndex, rangeFromIndex } from '../defs';
9
11
 
12
+ export type CellFormat = {
13
+ value?: string;
14
+ classNames?: ClassNameValue;
15
+ };
16
+
17
+ /**
18
+ * @deprecated See react-ui-data.
19
+ */
10
20
  export class FormattingModel {
11
- constructor(private readonly model: SheetModel) {}
21
+ constructor(private readonly _model: SheetModel) {}
12
22
 
13
23
  /**
14
24
  * Get formatted string value and className for cell.
15
25
  */
16
- getFormatting(cell: CellAddress): { value?: string; classNames?: ClassNameValue } {
17
- const value = this.model.getValue(cell);
26
+ getFormatting(cell: CellAddress): CellFormat {
27
+ const value = this._model.getValue(cell);
18
28
  if (value === undefined || value === null) {
19
29
  return {};
20
30
  }
@@ -23,15 +33,15 @@ export class FormattingModel {
23
33
  const locales = undefined;
24
34
 
25
35
  // Cell-specific formatting.
26
- const idx = this.model.addressToIndex(cell);
27
- let formatting = this.model.sheet.formatting?.[idx] ?? {};
36
+ const idx = addressToIndex(this._model.sheet, cell);
37
+ let formatting = this._model.sheet.formatting.find?.(({ range }) => range === idx);
28
38
  const classNames = [...(formatting?.classNames ?? [])];
29
39
 
30
40
  // Range formatting.
31
41
  // TODO(burdon): NOTE: D0 means the D column.
32
42
  // TODO(burdon): Cache model formatting (e.g., for ranges). Create class out of this function.
33
- for (const [idx, _formatting] of Object.entries(this.model.sheet.formatting)) {
34
- const range = this.model.rangeFromIndex(idx);
43
+ for (const [idx, _formatting] of Object.entries(this._model.sheet.formatting)) {
44
+ const range = rangeFromIndex(this._model.sheet, idx);
35
45
  if (inRange(range, cell)) {
36
46
  if (_formatting.classNames) {
37
47
  classNames.push(..._formatting.classNames);
@@ -46,9 +56,9 @@ export class FormattingModel {
46
56
 
47
57
  const defaultNumber = 'justify-end font-mono';
48
58
 
49
- const type = formatting?.type ?? this.model.getValueType(cell);
59
+ const type = formatting?.type ?? this._model.getValueType(cell);
50
60
  switch (type) {
51
- case ValueTypeEnum.Boolean: {
61
+ case FieldValueType.Boolean: {
52
62
  return {
53
63
  value: (value as boolean).toLocaleString().toUpperCase(),
54
64
  classNames: [...classNames, value ? '!text-greenText' : '!text-orangeText'],
@@ -59,15 +69,15 @@ export class FormattingModel {
59
69
  // Numbers.
60
70
  //
61
71
 
62
- case ValueTypeEnum.Number: {
72
+ case FieldValueType.Number: {
63
73
  return { value: value.toLocaleString(locales), classNames: [...classNames, defaultNumber] };
64
74
  }
65
75
 
66
- case ValueTypeEnum.Percent: {
76
+ case FieldValueType.Percent: {
67
77
  return { value: (value as number) * 100 + '%', classNames: [...classNames, defaultNumber] };
68
78
  }
69
79
 
70
- case ValueTypeEnum.Currency: {
80
+ case FieldValueType.Currency: {
71
81
  return {
72
82
  value: (value as number).toLocaleString(locales, {
73
83
  style: 'currency',
@@ -83,18 +93,18 @@ export class FormattingModel {
83
93
  // Dates.
84
94
  //
85
95
 
86
- case ValueTypeEnum.DateTime: {
87
- const date = this.model.toLocalDate(value as number);
96
+ case FieldValueType.DateTime: {
97
+ const date = this._model.toLocalDate(value as number);
88
98
  return { value: date.toLocaleString(locales), classNames };
89
99
  }
90
100
 
91
- case ValueTypeEnum.Date: {
92
- const date = this.model.toLocalDate(value as number);
101
+ case FieldValueType.Date: {
102
+ const date = this._model.toLocalDate(value as number);
93
103
  return { value: date.toLocaleDateString(locales), classNames };
94
104
  }
95
105
 
96
- case ValueTypeEnum.Time: {
97
- const date = this.model.toLocalDate(value as number);
106
+ case FieldValueType.Time: {
107
+ const date = this._model.toLocalDate(value as number);
98
108
  return { value: date.toLocaleTimeString(locales), classNames };
99
109
  }
100
110
 
@@ -2,6 +2,6 @@
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 './formatting-model';
7
+ 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
+ });