@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
@@ -4,18 +4,19 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import { HyperFormula } from 'hyperformula';
8
7
  import React, { useEffect, useMemo, useState } from 'react';
9
8
 
10
9
  import { Client } from '@dxos/client';
11
10
  import { createDocAccessor, type EchoReactiveObject } from '@dxos/client/echo';
12
11
  import { automerge } from '@dxos/react-ui-editor';
12
+ import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
13
13
  import { withTheme } from '@dxos/storybook-utils';
14
14
 
15
- import { CellEditor, type CellEditorProps } from './CellEditor';
16
- import { sheetExtension } from './extension';
17
- import { defaultFunctions } from '../../model';
18
- import { createSheet, SheetType } from '../../types';
15
+ import { HyperFormula } from '#hyperformula';
16
+ import { createSheet } from '../../defs';
17
+ import { sheetExtension } from '../../extensions';
18
+ import { defaultFunctions } from '../../graph';
19
+ import { SheetType } from '../../types';
19
20
 
20
21
  export default {
21
22
  title: 'plugin-sheet/CellEditor',
@@ -41,14 +42,13 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
41
42
  const [object, setObject] = useState<EchoReactiveObject<SheetType>>();
42
43
  useEffect(() => {
43
44
  setTimeout(async () => {
44
- const client = new Client();
45
+ const client = new Client({ types: [SheetType] });
45
46
  await client.initialize();
46
47
  await client.halo.createIdentity();
47
48
  const space = await client.spaces.create();
48
- client.addTypes([SheetType]);
49
49
 
50
50
  const sheet = createSheet();
51
- sheet.title = 'Test';
51
+ sheet.name = 'Test';
52
52
  sheet.cells[cell] = { value };
53
53
  space.db.add(sheet);
54
54
  setObject(sheet);
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './GridSheet';
@@ -0,0 +1,144 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type MutableRefObject, useEffect, useLayoutEffect, useState } from 'react';
6
+
7
+ import { createDocAccessor } from '@dxos/react-client/echo';
8
+ import {
9
+ type GridContentProps,
10
+ type DxGridElement,
11
+ type DxGridAxisMeta,
12
+ type DxGridPlane,
13
+ type DxGridPlaneRange,
14
+ type DxGridPlaneCells,
15
+ colToA1Notation,
16
+ rowToA1Notation,
17
+ } from '@dxos/react-ui-grid';
18
+ import { mx } from '@dxos/react-ui-theme';
19
+
20
+ import { type CellAddress } from '../../defs';
21
+ import { type SheetModel, type FormattingModel } from '../../model';
22
+
23
+ export const dxGridCellIndexToSheetCellAddress = (index: string): CellAddress => {
24
+ const [colStr, rowStr] = index.split(',');
25
+ return {
26
+ col: parseInt(colStr),
27
+ row: parseInt(rowStr),
28
+ };
29
+ };
30
+
31
+ const createDxGridColumns = (model: SheetModel): DxGridAxisMeta => {
32
+ return model.sheet.columns.reduce(
33
+ (acc: DxGridAxisMeta, columnId, numericIndex) => {
34
+ if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
35
+ acc.grid[numericIndex] = { size: model.sheet.columnMeta[columnId].size, resizeable: true };
36
+ }
37
+ return acc;
38
+ },
39
+ { grid: {} },
40
+ );
41
+ };
42
+
43
+ const createDxGridRows = (model: SheetModel): DxGridAxisMeta => {
44
+ return model.sheet.rows.reduce(
45
+ (acc: DxGridAxisMeta, rowId, numericIndex) => {
46
+ if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
47
+ acc.grid[numericIndex] = { size: model.sheet.rowMeta[rowId].size, resizeable: true };
48
+ }
49
+ return acc;
50
+ },
51
+ { grid: {} },
52
+ );
53
+ };
54
+
55
+ const gridCellGetter = (model: SheetModel, formatting: FormattingModel) => {
56
+ // TODO(thure): Actually use the cache.
57
+ const cachedGridCells: DxGridPlaneCells = {};
58
+ return (nextBounds: DxGridPlaneRange): DxGridPlaneCells => {
59
+ [...Array(nextBounds.end.col - nextBounds.start.col)].forEach((_, c0) => {
60
+ return [...Array(nextBounds.end.row - nextBounds.start.row)].forEach((_, r0) => {
61
+ const col = nextBounds.start.col + c0;
62
+ const row = nextBounds.start.row + r0;
63
+ const cell = formatting.getFormatting({ col, row });
64
+ if (cell.value) {
65
+ cachedGridCells;
66
+ cachedGridCells[`${col},${row}`] = { value: cell.value, className: mx(cell.classNames) };
67
+ }
68
+ });
69
+ });
70
+ return cachedGridCells;
71
+ };
72
+ };
73
+
74
+ export const rowLabelCell = (row: number) => ({
75
+ value: rowToA1Notation(row),
76
+ className: 'text-end !pie-1',
77
+ resizeHandle: 'row',
78
+ });
79
+
80
+ export const colLabelCell = (col: number) => ({ value: colToA1Notation(col), resizeHandle: 'col' });
81
+
82
+ const cellGetter = (model: SheetModel, formatting: FormattingModel) => {
83
+ const getGridCells = gridCellGetter(model, formatting);
84
+ return (nextBounds: DxGridPlaneRange, plane: DxGridPlane): DxGridPlaneCells => {
85
+ switch (plane) {
86
+ case 'grid':
87
+ return getGridCells(nextBounds);
88
+ case 'frozenColsStart':
89
+ return [...Array(nextBounds.end.row - nextBounds.start.row)].reduce((acc, _, r0) => {
90
+ const r = nextBounds.start.row + r0;
91
+ acc[`0,${r}`] = rowLabelCell(r);
92
+ return acc;
93
+ }, {});
94
+ case 'frozenRowsStart':
95
+ return [...Array(nextBounds.end.col - nextBounds.start.col)].reduce((acc, _, c0) => {
96
+ const c = nextBounds.start.col + c0;
97
+ acc[`${c},0`] = colLabelCell(c);
98
+ return acc;
99
+ }, {});
100
+ default:
101
+ return {};
102
+ }
103
+ };
104
+ };
105
+
106
+ export const useSheetModelDxGridProps = (
107
+ dxGridRef: MutableRefObject<DxGridElement | null>,
108
+ model: SheetModel,
109
+ formatting: FormattingModel,
110
+ ): Pick<GridContentProps, 'columns' | 'rows'> => {
111
+ const [columns, setColumns] = useState<DxGridAxisMeta>(createDxGridColumns(model));
112
+ const [rows, setRows] = useState<DxGridAxisMeta>(createDxGridColumns(model));
113
+
114
+ useLayoutEffect(() => {
115
+ const cellsAccessor = createDocAccessor(model.sheet, ['cells']);
116
+ if (dxGridRef.current) {
117
+ dxGridRef.current.getCells = cellGetter(model, formatting);
118
+ }
119
+ const handleCellsUpdate = () => {
120
+ dxGridRef.current?.requestUpdate('initialCells');
121
+ };
122
+ cellsAccessor.handle.addListener('change', handleCellsUpdate);
123
+ return () => cellsAccessor.handle.removeListener('change', handleCellsUpdate);
124
+ }, [model, formatting]);
125
+
126
+ useEffect(() => {
127
+ const columnMetaAccessor = createDocAccessor(model.sheet, ['columnMeta']);
128
+ const rowMetaAccessor = createDocAccessor(model.sheet, ['rowMeta']);
129
+ const handleColumnMetaUpdate = () => {
130
+ setColumns(createDxGridColumns(model));
131
+ };
132
+ const handleRowMetaUpdate = () => {
133
+ setRows(createDxGridRows(model));
134
+ };
135
+ columnMetaAccessor.handle.addListener('change', handleColumnMetaUpdate);
136
+ rowMetaAccessor.handle.addListener('change', handleRowMetaUpdate);
137
+ return () => {
138
+ columnMetaAccessor.handle.removeListener('change', handleColumnMetaUpdate);
139
+ rowMetaAccessor.handle.removeListener('change', handleRowMetaUpdate);
140
+ };
141
+ }, [model]);
142
+
143
+ return { columns, rows };
144
+ };
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { useSpace } from '@dxos/react-client/echo';
8
+ import { withClientProvider } from '@dxos/react-client/testing';
9
+ import { withTheme, withLayout } from '@dxos/storybook-utils';
10
+
11
+ import { SheetContainer } from './SheetContainer';
12
+ import { useComputeGraph } from '../../hooks';
13
+ import { useTestSheet, withComputeGraphDecorator } from '../../testing';
14
+ import { SheetType } from '../../types';
15
+
16
+ export default {
17
+ title: 'plugin-sheet/SheetContainer',
18
+ component: SheetContainer,
19
+ decorators: [
20
+ withClientProvider({ types: [SheetType], createSpace: true }),
21
+ withComputeGraphDecorator(),
22
+ withTheme,
23
+ withLayout({
24
+ fullscreen: true,
25
+ tooltips: true,
26
+ classNames: 'grid grid-cols-1 grid-rows-[min-content_minmax(0,1fr)_min-content]',
27
+ }),
28
+ ],
29
+ };
30
+
31
+ export const Basic = () => {
32
+ const space = useSpace();
33
+ const graph = useComputeGraph(space);
34
+ const sheet = useTestSheet(space, graph);
35
+ if (!sheet || !graph) {
36
+ return null;
37
+ }
38
+
39
+ return <SheetContainer graph={graph} sheet={sheet} role='article' />;
40
+ };
@@ -0,0 +1,52 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback } from 'react';
6
+
7
+ import { useIntentDispatcher } from '@dxos/app-framework';
8
+
9
+ import { FunctionEditor } from '../FunctionEditor';
10
+ import { GridSheet } from '../GridSheet';
11
+ import { SheetProvider, type SheetProviderProps } from '../SheetContext';
12
+ import { Toolbar, type ToolbarAction } from '../Toolbar';
13
+
14
+ export const SheetContainer = ({ graph, sheet, role }: SheetProviderProps & { role?: string }) => {
15
+ const dispatch = useIntentDispatcher();
16
+
17
+ // TODO(Zan): Centralise the toolbar action handler. Current implementation in stories.
18
+ const handleAction = useCallback(
19
+ (action: ToolbarAction) => {
20
+ switch (action.type) {
21
+ case 'comment': {
22
+ // TODO(Zan): We shouldn't hardcode the action ID.
23
+ void dispatch({
24
+ action: 'dxos.org/plugin/thread/action/create',
25
+ data: {
26
+ cursor: action.anchor,
27
+ name: action.cellContent,
28
+ subject: sheet,
29
+ },
30
+ });
31
+ }
32
+ }
33
+ },
34
+ [sheet, dispatch],
35
+ );
36
+
37
+ return (
38
+ <SheetProvider sheet={sheet} graph={graph}>
39
+ <Toolbar.Root onAction={handleAction} role={role}>
40
+ <Toolbar.Styles />
41
+ <Toolbar.Format />
42
+ <Toolbar.Alignment />
43
+ <Toolbar.Separator />
44
+ <Toolbar.Actions />
45
+ </Toolbar.Root>
46
+ <div role='none' className='border-bs border-separator grid cols-1 rows-[1fr_min-content] min-bs-0'>
47
+ <GridSheet />
48
+ <FunctionEditor />
49
+ </div>
50
+ </SheetProvider>
51
+ );
52
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { SheetContainer } from './SheetContainer';
6
+
7
+ export default SheetContainer;
@@ -0,0 +1,108 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { type PropsWithChildren, createContext, useContext, useMemo, useState } from 'react';
6
+
7
+ import { invariant } from '@dxos/invariant';
8
+ import { fullyQualifiedId } from '@dxos/react-client/echo';
9
+ import { Grid, useGridContext, type GridScopedProps, type GridEditing } from '@dxos/react-ui-grid';
10
+
11
+ import { type CellAddress, type CellRange } from '../../defs';
12
+ import { type ComputeGraph } from '../../graph';
13
+ import { useSheetModel, useFormattingModel, useSelectThreadOnCellFocus, useThreadDecorations } from '../../hooks';
14
+ import { type FormattingModel, type SheetModel, createDecorations } from '../../model';
15
+ import { type SheetType } from '../../types';
16
+
17
+ export type SheetContextValue = {
18
+ id: string;
19
+
20
+ model: SheetModel;
21
+ formatting: FormattingModel;
22
+
23
+ // Cursor state.
24
+ // TODO(burdon): Cursor and range should use indices.
25
+ cursor?: CellAddress;
26
+ setCursor: (cell: CellAddress | undefined) => void;
27
+ range?: CellRange;
28
+ setRange: (range: CellRange | undefined) => void;
29
+
30
+ // Editing state (undefined if not editing).
31
+ editing: GridEditing;
32
+ setEditing: (editing: GridEditing) => void;
33
+
34
+ // Events.
35
+ // TODO(burdon): Generalize.
36
+ onInfo?: () => void;
37
+
38
+ // Decorations.
39
+ decorations: ReturnType<typeof createDecorations>;
40
+ };
41
+
42
+ const SheetContext = createContext<SheetContextValue | null>(null);
43
+
44
+ export const useSheetContext = (): SheetContextValue => {
45
+ const context = useContext(SheetContext);
46
+ invariant(context);
47
+ return context;
48
+ };
49
+
50
+ const SheetProviderImpl = ({
51
+ model,
52
+ formatting,
53
+ onInfo,
54
+ children,
55
+ __gridScope,
56
+ }: GridScopedProps<PropsWithChildren<Pick<SheetContextValue, 'onInfo' | 'model' | 'formatting'>>>) => {
57
+ const { id, editing, setEditing } = useGridContext('SheetProvider', __gridScope);
58
+
59
+ // TODO(Zan): Impl. set range and set cursor that scrolls to that cell or range if it is not visible.
60
+ const decorations = useMemo(() => createDecorations(), []);
61
+
62
+ // TODO(thure): Reconnect these.
63
+ const [cursor, setCursor] = useState<CellAddress>();
64
+ const [range, setRange] = useState<CellRange>();
65
+
66
+ useSelectThreadOnCellFocus(model, cursor);
67
+ useThreadDecorations(model, decorations);
68
+
69
+ return (
70
+ <SheetContext.Provider
71
+ value={{
72
+ id,
73
+ model,
74
+ formatting,
75
+ editing,
76
+ setEditing,
77
+ cursor,
78
+ setCursor,
79
+ range,
80
+ setRange,
81
+ // TODO(burdon): Change to event.
82
+ onInfo,
83
+ decorations,
84
+ }}
85
+ >
86
+ {children}
87
+ </SheetContext.Provider>
88
+ );
89
+ };
90
+
91
+ export type SheetProviderProps = {
92
+ graph: ComputeGraph;
93
+ sheet: SheetType;
94
+ readonly?: boolean;
95
+ } & Pick<SheetContextValue, 'onInfo'>;
96
+
97
+ export const SheetProvider = ({ children, graph, sheet, readonly, onInfo }: PropsWithChildren<SheetProviderProps>) => {
98
+ const model = useSheetModel(graph, sheet, { readonly });
99
+ const formatting = useFormattingModel(model);
100
+
101
+ return !model || !formatting ? null : (
102
+ <Grid.Root id={fullyQualifiedId(sheet)}>
103
+ <SheetProviderImpl model={model} formatting={formatting} onInfo={onInfo}>
104
+ {children}
105
+ </SheetProviderImpl>
106
+ </Grid.Root>
107
+ );
108
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './SheetContext';