@dxos/plugin-sheet 0.6.13 → 0.6.14-main.69511f5

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 (330) hide show
  1. package/dist/lib/browser/SheetContainer-R65IDJHN.mjs +286 -0
  2. package/dist/lib/browser/SheetContainer-R65IDJHN.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-5KVQ5IPW.mjs +65 -0
  4. package/dist/lib/browser/chunk-5KVQ5IPW.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-I2DKJ72A.mjs +1471 -0
  8. package/dist/lib/browser/chunk-I2DKJ72A.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-KCYJSOFB.mjs} +625 -675
  10. package/dist/lib/browser/chunk-KCYJSOFB.mjs.map +7 -0
  11. package/dist/lib/browser/compute-graph-SJT67236.mjs +35 -0
  12. package/dist/lib/browser/compute-graph-SJT67236.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +140 -67
  14. package/dist/lib/browser/index.mjs.map +4 -4
  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-6BO4C5X2.cjs +290 -0
  19. package/dist/lib/node/SheetContainer-6BO4C5X2.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-2XJ5I4UF.cjs} +32 -52
  21. package/dist/lib/node/chunk-2XJ5I4UF.cjs.map +7 -0
  22. package/dist/lib/node/chunk-DEPJHN47.cjs +1457 -0
  23. package/dist/lib/node/chunk-DEPJHN47.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-JF5XNTF3.cjs} +643 -674
  25. package/dist/lib/node/chunk-JF5XNTF3.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/compute-graph-AQBDL7HO.cjs +57 -0
  29. package/dist/lib/node/compute-graph-AQBDL7HO.cjs.map +7 -0
  30. package/dist/lib/node/index.cjs +150 -75
  31. package/dist/lib/node/index.cjs.map +4 -4
  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-MJXC5E3P.mjs +287 -0
  38. package/dist/lib/node-esm/SheetContainer-MJXC5E3P.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-25V7WY4R.mjs +1472 -0
  40. package/dist/lib/node-esm/chunk-25V7WY4R.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-5TXLF6PL.mjs +66 -0
  42. package/dist/lib/node-esm/chunk-5TXLF6PL.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-XBEHKYO7.mjs +3186 -0
  46. package/dist/lib/node-esm/chunk-XBEHKYO7.mjs.map +7 -0
  47. package/dist/lib/node-esm/compute-graph-FRCKXEYK.mjs +36 -0
  48. package/dist/lib/node-esm/compute-graph-FRCKXEYK.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +322 -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 +13 -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 +15 -0
  74. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
  75. package/dist/types/src/components/RangeList/RangeList.d.ts +7 -0
  76. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
  77. package/dist/types/src/components/RangeList/index.d.ts +2 -0
  78. package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
  79. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +9 -0
  80. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -0
  81. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +6 -0
  82. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
  83. package/dist/types/src/components/SheetContainer/index.d.ts +3 -0
  84. package/dist/types/src/components/SheetContainer/index.d.ts.map +1 -0
  85. package/dist/types/src/components/SheetContext/SheetContext.d.ts +28 -0
  86. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -0
  87. package/dist/types/src/components/SheetContext/index.d.ts +2 -0
  88. package/dist/types/src/components/SheetContext/index.d.ts.map +1 -0
  89. package/dist/types/src/components/Toolbar/Toolbar.d.ts +33 -9
  90. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  91. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +4 -32
  92. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  93. package/dist/types/src/components/index.d.ts +7 -4
  94. package/dist/types/src/components/index.d.ts.map +1 -1
  95. package/dist/types/src/compute-graph/compute-graph-registry.d.ts +34 -0
  96. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
  97. package/dist/types/src/compute-graph/compute-graph.d.ts +64 -0
  98. package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
  99. package/dist/types/src/compute-graph/compute-graph.stories.d.ts +6 -0
  100. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
  101. package/dist/types/src/compute-graph/compute-graph.test.d.ts +2 -0
  102. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
  103. package/dist/types/src/compute-graph/compute-node.d.ts +26 -0
  104. package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
  105. package/dist/types/src/{components/ComputeGraph → compute-graph/functions}/async-function.d.ts +14 -5
  106. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
  107. package/dist/types/src/compute-graph/functions/edge-function.d.ts +21 -0
  108. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
  109. package/dist/types/src/{model/functions.d.ts → compute-graph/functions/function-defs.d.ts} +1 -1
  110. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
  111. package/dist/types/src/compute-graph/functions/index.d.ts +4 -0
  112. package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
  113. package/dist/types/src/compute-graph/hyperformula.test.d.ts +2 -0
  114. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
  115. package/dist/types/src/compute-graph/index.d.ts +5 -0
  116. package/dist/types/src/compute-graph/index.d.ts.map +1 -0
  117. package/dist/types/src/compute-graph/testing/index.d.ts +3 -0
  118. package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
  119. package/dist/types/src/compute-graph/testing/test-builder.d.ts +15 -0
  120. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
  121. package/dist/types/src/compute-graph/testing/test-plugin.d.ts +36 -0
  122. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
  123. package/dist/types/src/compute-graph/util.d.ts +2 -0
  124. package/dist/types/src/compute-graph/util.d.ts.map +1 -0
  125. package/dist/types/src/defs/index.d.ts +4 -0
  126. package/dist/types/src/defs/index.d.ts.map +1 -0
  127. package/dist/types/src/defs/sheet-range-types.d.ts +13 -0
  128. package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -0
  129. package/dist/types/src/defs/types.d.ts +28 -0
  130. package/dist/types/src/defs/types.d.ts.map +1 -0
  131. package/dist/types/src/defs/types.test.d.ts.map +1 -0
  132. package/dist/types/src/defs/util.d.ts +39 -0
  133. package/dist/types/src/defs/util.d.ts.map +1 -0
  134. package/dist/types/src/extensions/compute.d.ts +6 -0
  135. package/dist/types/src/extensions/compute.d.ts.map +1 -0
  136. package/dist/types/src/extensions/compute.stories.d.ts +21 -0
  137. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
  138. package/dist/types/src/extensions/editor/extension.d.ts +39 -0
  139. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
  140. package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
  141. package/dist/types/src/extensions/editor/index.d.ts +2 -0
  142. package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
  143. package/dist/types/src/extensions/index.d.ts +3 -0
  144. package/dist/types/src/extensions/index.d.ts.map +1 -0
  145. package/dist/types/src/index.d.ts +1 -1
  146. package/dist/types/src/index.d.ts.map +1 -1
  147. package/dist/types/src/integrations/index.d.ts +2 -0
  148. package/dist/types/src/integrations/index.d.ts.map +1 -0
  149. package/dist/types/src/integrations/thread-ranges.d.ts +7 -0
  150. package/dist/types/src/integrations/thread-ranges.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/index.d.ts +2 -3
  154. package/dist/types/src/model/index.d.ts.map +1 -1
  155. package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +13 -67
  156. package/dist/types/src/model/sheet-model.d.ts.map +1 -0
  157. package/dist/types/src/model/sheet-model.test.d.ts +2 -0
  158. package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
  159. package/dist/types/src/model/useSheetModel.d.ts +8 -0
  160. package/dist/types/src/model/useSheetModel.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/serializer.d.ts +4 -0
  164. package/dist/types/src/serializer.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 +27 -12
  170. package/dist/types/src/translations.d.ts.map +1 -1
  171. package/dist/types/src/types.d.ts +100 -41
  172. package/dist/types/src/types.d.ts.map +1 -1
  173. package/dist/vendor/hyperformula.mjs +37145 -0
  174. package/package.json +60 -61
  175. package/src/SheetPlugin.tsx +69 -78
  176. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +37 -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 +46 -0
  181. package/src/components/GridSheet/GridSheet.tsx +297 -0
  182. package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +18 -15
  183. package/src/components/GridSheet/index.ts +5 -0
  184. package/src/components/GridSheet/util.ts +164 -0
  185. package/src/components/RangeList/RangeList.tsx +53 -0
  186. package/src/components/RangeList/index.ts +5 -0
  187. package/src/components/SheetContainer/SheetContainer.stories.tsx +43 -0
  188. package/src/components/SheetContainer/SheetContainer.tsx +33 -0
  189. package/src/components/SheetContainer/index.ts +7 -0
  190. package/src/components/SheetContext/SheetContext.tsx +127 -0
  191. package/src/components/SheetContext/index.ts +5 -0
  192. package/src/components/Toolbar/Toolbar.stories.tsx +9 -6
  193. package/src/components/Toolbar/Toolbar.tsx +245 -112
  194. package/src/components/index.ts +5 -3
  195. package/src/compute-graph/compute-graph-registry.ts +90 -0
  196. package/src/compute-graph/compute-graph.stories.tsx +97 -0
  197. package/src/compute-graph/compute-graph.test.ts +87 -0
  198. package/src/compute-graph/compute-graph.ts +245 -0
  199. package/src/compute-graph/compute-node.ts +62 -0
  200. package/src/{components/ComputeGraph → compute-graph/functions}/async-function.ts +25 -15
  201. package/src/{components/ComputeGraph → compute-graph/functions}/edge-function.ts +16 -14
  202. package/src/compute-graph/functions/index.ts +7 -0
  203. package/src/compute-graph/hyperformula.test.ts +14 -0
  204. package/src/compute-graph/index.ts +8 -0
  205. package/src/compute-graph/testing/index.ts +6 -0
  206. package/src/compute-graph/testing/test-builder.ts +54 -0
  207. package/src/{components/ComputeGraph/custom.ts → compute-graph/testing/test-plugin.ts} +44 -14
  208. package/src/compute-graph/util.ts +8 -0
  209. package/src/defs/index.ts +7 -0
  210. package/src/defs/sheet-range-types.ts +47 -0
  211. package/src/{model → defs}/types.test.ts +8 -9
  212. package/src/defs/types.ts +86 -0
  213. package/src/defs/util.ts +135 -0
  214. package/src/extensions/compute.stories.tsx +155 -0
  215. package/src/extensions/compute.ts +147 -0
  216. package/src/{components/CellEditor → extensions/editor}/extension.test.ts +4 -6
  217. package/src/{components/CellEditor → extensions/editor}/extension.ts +51 -27
  218. package/src/{components/CellEditor → extensions/editor}/index.ts +0 -1
  219. package/src/extensions/index.ts +6 -0
  220. package/src/index.ts +2 -2
  221. package/src/integrations/index.ts +5 -0
  222. package/src/integrations/thread-ranges.ts +101 -0
  223. package/src/meta.ts +14 -0
  224. package/src/model/index.ts +2 -3
  225. package/src/model/sheet-model.test.ts +57 -0
  226. package/src/model/sheet-model.ts +423 -0
  227. package/src/model/useSheetModel.ts +40 -0
  228. package/src/sanity.test.ts +40 -0
  229. package/src/serializer.ts +27 -0
  230. package/src/{components/Sheet → testing}/index.ts +1 -1
  231. package/src/testing/testing.tsx +68 -0
  232. package/src/translations.ts +19 -4
  233. package/src/types.ts +42 -47
  234. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +0 -1772
  235. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
  237. package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
  239. package/dist/lib/browser/chunk-FUAGSXA4.mjs +0 -82
  240. package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
  241. package/dist/lib/browser/chunk-JRL5LGCE.mjs +0 -18
  242. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
  243. package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
  244. package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
  245. package/dist/lib/browser/testing.mjs +0 -92
  246. package/dist/lib/browser/testing.mjs.map +0 -7
  247. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +0 -1765
  248. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
  249. package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
  250. package/dist/lib/node/chunk-BJ6ZD7MN.cjs +0 -51
  251. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
  252. package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
  253. package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
  254. package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
  255. package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
  256. package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
  257. package/dist/lib/node/testing.cjs +0 -111
  258. package/dist/lib/node/testing.cjs.map +0 -7
  259. package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -14
  260. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
  261. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
  262. package/dist/types/src/components/CellEditor/extension.d.ts +0 -19
  263. package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
  264. package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
  265. package/dist/types/src/components/CellEditor/index.d.ts +0 -3
  266. package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
  267. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
  268. package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
  269. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
  270. package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
  271. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
  272. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
  273. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
  274. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
  275. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
  276. package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
  277. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
  278. package/dist/types/src/components/Sheet/Sheet.d.ts +0 -55
  279. package/dist/types/src/components/Sheet/Sheet.d.ts.map +0 -1
  280. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +0 -54
  281. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +0 -1
  282. package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
  283. package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
  284. package/dist/types/src/components/Sheet/grid.d.ts +0 -52
  285. package/dist/types/src/components/Sheet/grid.d.ts.map +0 -1
  286. package/dist/types/src/components/Sheet/index.d.ts +0 -2
  287. package/dist/types/src/components/Sheet/index.d.ts.map +0 -1
  288. package/dist/types/src/components/Sheet/nav.d.ts +0 -29
  289. package/dist/types/src/components/Sheet/nav.d.ts.map +0 -1
  290. package/dist/types/src/components/Sheet/sheet-context.d.ts +0 -25
  291. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +0 -1
  292. package/dist/types/src/components/Sheet/util.d.ts +0 -18
  293. package/dist/types/src/components/Sheet/util.d.ts.map +0 -1
  294. package/dist/types/src/components/SheetContainer.d.ts +0 -9
  295. package/dist/types/src/components/SheetContainer.d.ts.map +0 -1
  296. package/dist/types/src/components/Toolbar/common.d.ts +0 -20
  297. package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
  298. package/dist/types/src/model/functions.d.ts.map +0 -1
  299. package/dist/types/src/model/model.browser.test.d.ts +0 -2
  300. package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
  301. package/dist/types/src/model/model.d.ts.map +0 -1
  302. package/dist/types/src/model/types.d.ts +0 -17
  303. package/dist/types/src/model/types.d.ts.map +0 -1
  304. package/dist/types/src/model/types.test.d.ts.map +0 -1
  305. package/dist/types/src/model/util.d.ts +0 -15
  306. package/dist/types/src/model/util.d.ts.map +0 -1
  307. package/dist/types/src/testing.d.ts +0 -9
  308. package/dist/types/src/testing.d.ts.map +0 -1
  309. package/src/components/CellEditor/CellEditor.tsx +0 -113
  310. package/src/components/ComputeGraph/graph-context.tsx +0 -50
  311. package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
  312. package/src/components/ComputeGraph/graph.ts +0 -62
  313. package/src/components/Sheet/Sheet.stories.tsx +0 -287
  314. package/src/components/Sheet/Sheet.tsx +0 -1160
  315. package/src/components/Sheet/formatting.ts +0 -106
  316. package/src/components/Sheet/grid.ts +0 -191
  317. package/src/components/Sheet/nav.ts +0 -157
  318. package/src/components/Sheet/sheet-context.tsx +0 -150
  319. package/src/components/Sheet/util.ts +0 -56
  320. package/src/components/SheetContainer.tsx +0 -34
  321. package/src/components/Toolbar/common.tsx +0 -72
  322. package/src/meta.tsx +0 -18
  323. package/src/model/model.browser.test.ts +0 -100
  324. package/src/model/model.ts +0 -550
  325. package/src/model/types.ts +0 -71
  326. package/src/model/util.ts +0 -36
  327. package/src/testing.ts +0 -50
  328. /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
  329. /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
  330. /package/src/{model/functions.ts → compute-graph/functions/function-defs.ts} +0 -0
@@ -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 { TestBuilder, testFunctionPlugins } from '../compute-graph/testing';
12
+ import { addressFromA1Notation, createSheet } from '../defs';
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
+ });
@@ -0,0 +1,423 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type SimpleCellRange } from 'hyperformula/typings/AbsoluteCellRange';
6
+ import { type SimpleCellAddress } from 'hyperformula/typings/Cell';
7
+ import { type SimpleDate, type SimpleDateTime } from 'hyperformula/typings/DateTimeHelper';
8
+
9
+ import { Event } from '@dxos/async';
10
+ import { Resource } from '@dxos/context';
11
+ import { getTypename } from '@dxos/echo-schema';
12
+ import { invariant } from '@dxos/invariant';
13
+ import { PublicKey } from '@dxos/keys';
14
+ import { log } from '@dxos/log';
15
+ import { FieldValueType } from '@dxos/schema';
16
+
17
+ import { DetailedCellError, ExportedCellChange } from '#hyperformula';
18
+ import { type ComputeGraph, type ComputeNode, type ComputeNodeEvent, createSheetName } from '../compute-graph';
19
+ import {
20
+ addressFromA1Notation,
21
+ addressFromIndex,
22
+ addressToA1Notation,
23
+ addressToIndex,
24
+ type CellAddress,
25
+ type CellRange,
26
+ initialize,
27
+ insertIndices,
28
+ isFormula,
29
+ MAX_COLUMNS,
30
+ MAX_ROWS,
31
+ ReadonlyException,
32
+ } from '../defs';
33
+ import { type CellScalarValue, type CellValue, type SheetType } from '../types';
34
+
35
+ // Map sheet types to system types.
36
+ const typeMap: Record<string, FieldValueType> = {
37
+ BOOLEAN: FieldValueType.Boolean,
38
+ NUMBER_RAW: FieldValueType.Number,
39
+ NUMBER_PERCENT: FieldValueType.Percent,
40
+ NUMBER_CURRENCY: FieldValueType.Currency,
41
+ NUMBER_DATETIME: FieldValueType.DateTime,
42
+ NUMBER_DATE: FieldValueType.Date,
43
+ NUMBER_TIME: FieldValueType.Time,
44
+ };
45
+
46
+ const getTopLeft = (range: CellRange): CellAddress => {
47
+ const to = range.to ?? range.from;
48
+ return { row: Math.min(range.from.row, to.row), col: Math.min(range.from.col, to.col) };
49
+ };
50
+
51
+ const toSimpleCellAddress = (sheet: number, cell: CellAddress): SimpleCellAddress => ({
52
+ sheet,
53
+ row: cell.row,
54
+ col: cell.col,
55
+ });
56
+
57
+ const toModelRange = (sheet: number, range: CellRange): SimpleCellRange => ({
58
+ start: toSimpleCellAddress(sheet, range.from),
59
+ end: toSimpleCellAddress(sheet, range.to ?? range.from),
60
+ });
61
+
62
+ export type SheetModelOptions = {
63
+ readonly?: boolean;
64
+ };
65
+
66
+ /**
67
+ * Spreadsheet data model.
68
+ *
69
+ * [ComputeGraphContext] > [SheetContext]:[SheetModel] > [Sheet.Root]
70
+ */
71
+ // TODO(burdon): Factor out commonality with ComputeNode. Factor out HF.
72
+ export class SheetModel extends Resource {
73
+ public readonly id = `model-${PublicKey.random().truncate()}`;
74
+
75
+ // Wraps compute node.
76
+ public readonly update = new Event<ComputeNodeEvent>();
77
+
78
+ private _node?: ComputeNode;
79
+
80
+ constructor(
81
+ private readonly _graph: ComputeGraph,
82
+ private readonly _sheet: SheetType,
83
+ private readonly _options: SheetModelOptions = {},
84
+ ) {
85
+ super();
86
+ }
87
+
88
+ get graph() {
89
+ return this._graph;
90
+ }
91
+
92
+ get sheet() {
93
+ return this._sheet;
94
+ }
95
+
96
+ get readonly() {
97
+ return this._options.readonly;
98
+ }
99
+
100
+ get bounds() {
101
+ return {
102
+ rows: this._sheet.rows.length,
103
+ columns: this._sheet.columns.length,
104
+ };
105
+ }
106
+
107
+ /**
108
+ * Initialize sheet and engine.
109
+ */
110
+ protected override async _open() {
111
+ log('initialize', { id: this.id });
112
+ initialize(this._sheet);
113
+
114
+ // TODO(burdon): SheetModel should extend ComputeNode and be constructed via the graph.
115
+ this._node = this._graph.getOrCreateNode(createSheetName({ type: getTypename(this._sheet)!, id: this._sheet.id }));
116
+ await this._node.open();
117
+
118
+ // Listen for model updates (e.g., async calculations).
119
+ const unsubscribe = this._node.update.on((event) => this.update.emit(event));
120
+ this._ctx.onDispose(unsubscribe);
121
+
122
+ this.reset();
123
+ }
124
+
125
+ /**
126
+ * Update engine.
127
+ * NOTE: This resets the undo history.
128
+ * @deprecated
129
+ */
130
+ reset() {
131
+ invariant(this._node);
132
+ this._node.graph.hf.clearSheet(this._node.sheetId);
133
+ Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
134
+ invariant(this._node);
135
+ const { col, row } = addressFromIndex(this._sheet, key);
136
+ if (isFormula(value)) {
137
+ value = this._graph.mapFormulaToNative(
138
+ this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)),
139
+ );
140
+ }
141
+
142
+ this._node.graph.hf.setCellContents({ sheet: this._node.sheetId, row, col }, value);
143
+ });
144
+ }
145
+
146
+ /**
147
+ * Recalculate formulas.
148
+ * NOTE: This resets the undo history.
149
+ * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
150
+ * @deprecated
151
+ */
152
+ // TODO(burdon): Remove.
153
+ recalculate() {
154
+ this._node?.graph.hf.rebuildAndRecalculate();
155
+ }
156
+
157
+ insertRows(i: number, n = 1) {
158
+ insertIndices(this._sheet.rows, i, n, MAX_ROWS);
159
+ this.reset();
160
+ }
161
+
162
+ insertColumns(i: number, n = 1) {
163
+ insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
164
+ this.reset();
165
+ }
166
+
167
+ //
168
+ // Undoable actions.
169
+ // TODO(burdon): Group undoable methods; consistently update hf/sheet.
170
+ //
171
+
172
+ /**
173
+ * Clear range of values.
174
+ */
175
+ clear(range: CellRange) {
176
+ invariant(this._node);
177
+ const topLeft = getTopLeft(range);
178
+ const values = this._iterRange(range, () => null);
179
+ this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
180
+ this._iterRange(range, (cell) => {
181
+ const idx = addressToIndex(this._sheet, cell);
182
+ delete this._sheet.cells[idx];
183
+ });
184
+ }
185
+
186
+ cut(range: CellRange) {
187
+ invariant(this._node);
188
+ this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
189
+ this._iterRange(range, (cell) => {
190
+ const idx = addressToIndex(this._sheet, cell);
191
+ delete this._sheet.cells[idx];
192
+ });
193
+ }
194
+
195
+ copy(range: CellRange) {
196
+ invariant(this._node);
197
+ this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
198
+ }
199
+
200
+ paste(cell: CellAddress) {
201
+ invariant(this._node);
202
+ if (!this._node.graph.hf.isClipboardEmpty()) {
203
+ const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
204
+ for (const change of changes) {
205
+ if (change instanceof ExportedCellChange) {
206
+ const { address, newValue } = change;
207
+ const idx = addressToIndex(this._sheet, { row: address.row, col: address.col });
208
+ this._sheet.cells[idx] = { value: newValue };
209
+ }
210
+ }
211
+ }
212
+ }
213
+
214
+ // TODO(burdon): Display undo/redo state.
215
+ undo() {
216
+ invariant(this._node);
217
+ if (this._node.graph.hf.isThereSomethingToUndo()) {
218
+ this._node.graph.hf.undo();
219
+ // this.update.emit();
220
+ }
221
+ }
222
+
223
+ redo() {
224
+ invariant(this._node);
225
+ if (this._node.graph.hf.isThereSomethingToRedo()) {
226
+ this._node.graph.hf.redo();
227
+ // this.update.emit();
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Get value from sheet.
233
+ */
234
+ getCellValue(cell: CellAddress): CellScalarValue {
235
+ const idx = addressToIndex(this._sheet, cell);
236
+ return this._sheet.cells[idx]?.value ?? null;
237
+ }
238
+
239
+ /**
240
+ * Get value as a string for editing.
241
+ */
242
+ getCellText(cell: CellAddress): string | undefined {
243
+ const value = this.getCellValue(cell);
244
+ if (value == null) {
245
+ return undefined;
246
+ }
247
+
248
+ if (isFormula(value)) {
249
+ return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
250
+ } else {
251
+ return String(value);
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Get array of raw values from sheet.
257
+ */
258
+ getCellValues(range: CellRange): CellScalarValue[][] {
259
+ return this._iterRange(range, (cell) => this.getCellValue(cell));
260
+ }
261
+
262
+ /**
263
+ * Gets the regular or computed value from the engine.
264
+ */
265
+ getValue(cell: CellAddress): CellScalarValue {
266
+ // Applies rounding and post-processing.
267
+ invariant(this._node);
268
+ const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
269
+ if (value instanceof DetailedCellError) {
270
+ return value.toString();
271
+ }
272
+
273
+ return value;
274
+ }
275
+
276
+ /**
277
+ * Get value type.
278
+ */
279
+ getValueType(cell: CellAddress): FieldValueType {
280
+ invariant(this._node);
281
+ const addr = toSimpleCellAddress(this._node.sheetId, cell);
282
+ const type = this._node.graph.hf.getCellValueDetailedType(addr);
283
+ return typeMap[type];
284
+ }
285
+
286
+ /**
287
+ * Sets the value, updating the sheet and engine.
288
+ */
289
+ setValue(cell: CellAddress, value: CellScalarValue) {
290
+ invariant(this._node);
291
+ if (this._options.readonly) {
292
+ throw new ReadonlyException();
293
+ }
294
+
295
+ // Reallocate if > current bounds.
296
+ let refresh = false;
297
+ if (cell.row >= this._sheet.rows.length) {
298
+ insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
299
+ refresh = true;
300
+ }
301
+ if (cell.col >= this._sheet.columns.length) {
302
+ insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
303
+ refresh = true;
304
+ }
305
+
306
+ if (refresh) {
307
+ // TODO(burdon): Remove.
308
+ this.reset();
309
+ }
310
+
311
+ // Insert into engine.
312
+ this._node.graph.hf.setCellContents({ sheet: this._node.sheetId, row: cell.row, col: cell.col }, [
313
+ [isFormula(value) ? this._graph.mapFormulaToNative(value) : value],
314
+ ]);
315
+
316
+ // Insert into sheet.
317
+ const idx = addressToIndex(this._sheet, cell);
318
+ if (value === undefined || value === null) {
319
+ delete this._sheet.cells[idx];
320
+ } else {
321
+ if (isFormula(value)) {
322
+ value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
323
+ }
324
+
325
+ this._sheet.cells[idx] = { value };
326
+ }
327
+ }
328
+
329
+ /**
330
+ * Sets values from a simple map.
331
+ */
332
+ setValues(values: Record<string, CellValue>) {
333
+ Object.entries(values).forEach(([key, { value }]) => {
334
+ this.setValue(addressFromA1Notation(key), value);
335
+ });
336
+ }
337
+
338
+ /**
339
+ * Iterate range.
340
+ */
341
+ private _iterRange(range: CellRange, cb: (cell: CellAddress) => CellScalarValue | void): CellScalarValue[][] {
342
+ const to = range.to ?? range.from;
343
+ const rowRange = [Math.min(range.from.row, to.row), Math.max(range.from.row, to.row)];
344
+ const columnRange = [Math.min(range.from.col, to.col), Math.max(range.from.col, to.col)];
345
+ const rows: CellScalarValue[][] = [];
346
+ for (let row = rowRange[0]; row <= rowRange[1]; row++) {
347
+ const rowCells: CellScalarValue[] = [];
348
+ for (let column = columnRange[0]; column <= columnRange[1]; column++) {
349
+ const value = cb({ row, col: column });
350
+ if (value !== undefined) {
351
+ rowCells.push(value);
352
+ }
353
+ }
354
+
355
+ rows.push(rowCells);
356
+ }
357
+
358
+ return rows;
359
+ }
360
+
361
+ // TODO(burdon): Delete index.
362
+ private _deleteIndices(indices: string[], i: number, n: number) {
363
+ throw new Error('Not implemented');
364
+ }
365
+
366
+ // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
367
+ private _moveIndices(indices: string[], i: number, j: number, n: number) {
368
+ throw new Error('Not implemented');
369
+ }
370
+
371
+ //
372
+ // Indices.
373
+ //
374
+
375
+ /**
376
+ * Map from A1 notation to indices.
377
+ */
378
+ mapFormulaRefsToIndices(formula: string): string {
379
+ invariant(isFormula(formula));
380
+ return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
381
+ return addressToIndex(this._sheet, addressFromA1Notation(match));
382
+ });
383
+ }
384
+
385
+ /**
386
+ * Map from indices to A1 notation.
387
+ */
388
+ mapFormulaIndicesToRefs(formula: string): string {
389
+ invariant(isFormula(formula));
390
+ return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
391
+ return addressToA1Notation(addressFromIndex(this._sheet, idx));
392
+ });
393
+ }
394
+
395
+ //
396
+ // Values
397
+ //
398
+
399
+ /**
400
+ * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
401
+ * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
402
+ * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
403
+ */
404
+ toLocalDate(num: number): Date {
405
+ const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
406
+ return new Date(year, month - 1, day, hours, minutes, seconds);
407
+ }
408
+
409
+ toDateTime(num: number): SimpleDateTime {
410
+ invariant(this._node);
411
+ return this._node.graph.hf.numberToDateTime(num) as SimpleDateTime;
412
+ }
413
+
414
+ toDate(num: number): SimpleDate {
415
+ invariant(this._node);
416
+ return this._node.graph.hf.numberToDate(num) as SimpleDate;
417
+ }
418
+
419
+ toTime(num: number): SimpleDate {
420
+ invariant(this._node);
421
+ return this._node.graph.hf.numberToTime(num) as SimpleDate;
422
+ }
423
+ }
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useState } from 'react';
6
+
7
+ import { type ComputeGraph } from '../compute-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
+ };
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { describe, test, expect } from 'vitest';
6
+
7
+ // Part 2.
8
+ // TODO(burdon): Cannot test outside of browser.
9
+ // - Cannot test Hyperformula
10
+ // - throws "Cannot convert undefined or null to object" in vitest (no browser).
11
+ // - throws "process.nextTick is not a function" (if browser)
12
+
13
+ import { Client } from '@dxos/client';
14
+ import { create } from '@dxos/client/echo';
15
+ import { FunctionType } from '@dxos/plugin-script/types';
16
+
17
+ // TODO(burdon): Fix test infrastructure:
18
+ // - Need docs? esp. needed for config. need pristine example package?
19
+ // - NOTE for non browser tests, import types from x-plugin/types (otherwise will bring in react deps).
20
+ // - Can't add flags to our tools?
21
+ // - .only / .skip ignored (have to comment out tests)
22
+
23
+ describe('test', () => {
24
+ test('test', async () => {
25
+ const client = new Client();
26
+ client.addTypes([FunctionType]);
27
+ await client.initialize();
28
+ await client.halo.createIdentity();
29
+
30
+ // Part 1.
31
+ // Create script.
32
+ // VITEST_ENV=chromium p test
33
+ // TODO(burdon): Test after initialize.
34
+ // - ERROR "process.nextTick is not a function"
35
+ // - ERROR "Identifier 'Buffer' has already been declared" if { nodeExternal: true }
36
+ const space = await client.spaces.create();
37
+ const fn = space.db.add(create(FunctionType, { version: 1, binding: 'HELLO' }));
38
+ expect(fn).to.exist;
39
+ });
40
+ });
@@ -0,0 +1,27 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
6
+ import { create, getObjectCore } from '@dxos/react-client/echo';
7
+
8
+ import { SheetType } from './types';
9
+
10
+ export const serializer: TypedObjectSerializer<SheetType> = {
11
+ serialize: async ({ object }): Promise<string> => {
12
+ const { threads: _threads, ...sheet } = object;
13
+ return JSON.stringify(sheet, null, 2);
14
+ },
15
+
16
+ deserialize: async ({ content, newId }) => {
17
+ const { id, ...parsed } = JSON.parse(content);
18
+ const sheet = create(SheetType, parsed);
19
+
20
+ if (!newId) {
21
+ const core = getObjectCore(sheet);
22
+ core.id = id;
23
+ }
24
+
25
+ return sheet;
26
+ },
27
+ };
@@ -2,4 +2,4 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './Sheet';
5
+ export * from './testing';
@@ -0,0 +1,68 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type Decorator } from '@storybook/react';
6
+ import React, { useState } from 'react';
7
+
8
+ import { type Space } from '@dxos/react-client/echo';
9
+ import { useAsyncState } from '@dxos/react-hooks';
10
+
11
+ import { ComputeGraphContextProvider } from '../components';
12
+ import { type ComputeGraph, type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph';
13
+ import { createSheet } from '../defs';
14
+ import { type CellValue, type CreateSheetOptions } from '../types';
15
+
16
+ const testSheetName = 'test';
17
+
18
+ export const createTestCells = (): Record<string, CellValue> => ({
19
+ B1: { value: 'Qty2' },
20
+ B3: { value: 1 },
21
+ B4: { value: 2 },
22
+ B5: { value: 3 },
23
+ B7: { value: 'Total' },
24
+
25
+ C1: { value: 'Price' },
26
+ C3: { value: 2_000 },
27
+ C4: { value: 2_500 },
28
+ C5: { value: 3_000 },
29
+ C7: { value: '=SUMPRODUCT(B2:B6, C2:C6)' },
30
+ // C8: { value: '=C7*CRYPTO(D7)' },
31
+ C8: { value: '=C7*TEST()' },
32
+
33
+ D7: { value: 'USD' },
34
+ D8: { value: 'BTC' },
35
+
36
+ E3: { value: '=TODAY()' },
37
+ E4: { value: '=NOW()' },
38
+
39
+ F1: { value: `=${testSheetName}!A1` }, // Ref test sheet.
40
+ F3: { value: true },
41
+ F4: { value: false },
42
+ F5: { value: '8%' },
43
+ F6: { value: '$10000' },
44
+ });
45
+
46
+ export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: CreateSheetOptions) => {
47
+ const [sheet] = useAsyncState(async () => {
48
+ if (!space || !graph) {
49
+ return;
50
+ }
51
+
52
+ const sheet = createSheet(options);
53
+ space.db.add(sheet);
54
+ return sheet;
55
+ }, [space, graph]);
56
+ return sheet;
57
+ };
58
+
59
+ export const withComputeGraphDecorator =
60
+ (options?: ComputeGraphOptions): Decorator =>
61
+ (Story) => {
62
+ const [registry] = useState(new ComputeGraphRegistry(options));
63
+ return (
64
+ <ComputeGraphContextProvider registry={registry}>
65
+ <Story />
66
+ </ComputeGraphContextProvider>
67
+ );
68
+ };
@@ -13,10 +13,25 @@ export default [
13
13
  'create sheet label': 'Create sheet',
14
14
  'create sheet section label': 'Create sheet',
15
15
  'cell placeholder': 'Cell value...',
16
- 'toolbar left label': 'Align left',
17
- 'toolbar left center': 'Align center',
18
- 'toolbar left right': 'Align right',
16
+ 'range key alignment label': 'Align',
17
+ 'range value start label': 'left',
18
+ 'range value center label': 'center',
19
+ 'range value end label': 'right',
20
+ 'toolbar action label': '{{key}} {{value}}',
21
+ 'selection overlaps existing comment label': 'Selected cell already has a comment',
22
+ 'comment label': 'Add comment',
23
+ 'comment ranges not supported label': 'Commenting on ranges is not yet supported',
24
+ 'no cursor label': 'Select a cell to comment',
25
+ 'open comment for sheet cell': 'View comments for cell',
26
+ 'add col before label': 'Add column before',
27
+ 'add col after label': 'Add column after',
28
+ 'delete col label': 'Delete column',
29
+ 'add row before label': 'Add row before',
30
+ 'add row after label': 'Add row after',
31
+ 'delete row label': 'Delete row',
32
+ 'range list heading': 'Ranges',
33
+ 'range title': '{{position}} — {{key}}: {{value}}',
19
34
  },
20
35
  },
21
36
  },
22
- ];
37
+ ] as const;