@dxos/plugin-sheet 0.6.13 → 0.6.14-staging.9e90729

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-JBB7W52Y.mjs +280 -0
  2. package/dist/lib/browser/SheetContainer-JBB7W52Y.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-2ZK3YMZG.mjs} +621 -675
  4. package/dist/lib/browser/chunk-2ZK3YMZG.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-3QWIMZZJ.mjs +65 -0
  6. package/dist/lib/browser/chunk-3QWIMZZJ.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-D3QTX46O.mjs +14 -0
  8. package/dist/lib/browser/chunk-D3QTX46O.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-XXDHBYZQ.mjs +1455 -0
  10. package/dist/lib/browser/chunk-XXDHBYZQ.mjs.map +7 -0
  11. package/dist/lib/browser/compute-graph-ZQKB6QVP.mjs +35 -0
  12. package/dist/lib/browser/compute-graph-ZQKB6QVP.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +139 -65
  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-L37HUFCF.cjs +286 -0
  19. package/dist/lib/node/SheetContainer-L37HUFCF.cjs.map +7 -0
  20. package/dist/lib/node/chunk-7AWAC3R3.cjs +1441 -0
  21. package/dist/lib/node/chunk-7AWAC3R3.cjs.map +7 -0
  22. package/dist/lib/node/chunk-QIFIGEKV.cjs +37 -0
  23. package/dist/lib/node/chunk-QIFIGEKV.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-QNFMTK3X.cjs} +638 -674
  25. package/dist/lib/node/chunk-QNFMTK3X.cjs.map +7 -0
  26. package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-V7E5JZBD.cjs} +31 -51
  27. package/dist/lib/node/chunk-V7E5JZBD.cjs.map +7 -0
  28. package/dist/lib/node/compute-graph-RJB6OVW6.cjs +57 -0
  29. package/dist/lib/node/compute-graph-RJB6OVW6.cjs.map +7 -0
  30. package/dist/lib/node/index.cjs +148 -73
  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-CLKFEM35.mjs +281 -0
  38. package/dist/lib/node-esm/SheetContainer-CLKFEM35.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-3JYJEOCF.mjs +1456 -0
  40. package/dist/lib/node-esm/chunk-3JYJEOCF.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-JBTORSST.mjs +3182 -0
  42. package/dist/lib/node-esm/chunk-JBTORSST.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-SPQFLYC2.mjs +66 -0
  44. package/dist/lib/node-esm/chunk-SPQFLYC2.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +16 -0
  46. package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +7 -0
  47. package/dist/lib/node-esm/compute-graph-VKRG526N.mjs +36 -0
  48. package/dist/lib/node-esm/compute-graph-VKRG526N.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +323 -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 +16 -0
  74. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
  75. package/dist/types/src/components/RangeList/RangeList.d.ts +9 -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 +6 -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 +5 -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 +8 -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 +23 -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 +296 -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 +38 -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 +27 -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 +240 -111
  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 +12 -1
  233. package/src/types.ts +41 -46
  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
@@ -3,7 +3,6 @@
3
3
  //
4
4
 
5
5
  import { effect } from '@preact/signals-core';
6
- import { CellError, ErrorType, FunctionArgumentType } from 'hyperformula';
7
6
  import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
8
7
  import { type ProcedureAst } from 'hyperformula/typings/parser';
9
8
 
@@ -13,17 +12,20 @@ import { getUserFunctionUrlInMetadata } from '@dxos/plugin-script/edge';
13
12
  import { FunctionType } from '@dxos/plugin-script/types';
14
13
  import { nonNullable } from '@dxos/util';
15
14
 
16
- import { type AsyncFunction, FunctionPluginAsync } from './async-function';
15
+ import { CellError, ErrorType, FunctionArgumentType } from '#hyperformula';
16
+ import { type AsyncFunction, AsyncFunctionPlugin } from './async-function';
17
17
 
18
- const EDGE_FUNCTION_TTL = 10_000;
18
+ export const EDGE_FUNCTION_NAME = 'DX';
19
+
20
+ const FUNCTION_TTL = 10_000;
19
21
 
20
22
  /**
21
- * A hyperformula function plugin for calling EDGE functions.
23
+ * A hyperformula function plugin for calling remote (EDGE) functions.
22
24
  *
23
25
  * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
24
26
  */
25
- export class EdgeFunctionPlugin extends FunctionPluginAsync {
26
- edge(ast: ProcedureAst, state: InterpreterState) {
27
+ export class EdgeFunctionPlugin extends AsyncFunctionPlugin {
28
+ dx(ast: ProcedureAst, state: InterpreterState) {
27
29
  const handler =
28
30
  (subscribe = false): AsyncFunction =>
29
31
  async (binding: string, ...args: any) => {
@@ -47,7 +49,7 @@ export class EdgeFunctionPlugin extends FunctionPluginAsync {
47
49
 
48
50
  // TODO(wittjosiah): `ttl` should be 0 to force a recalculation when a new version is deployed.
49
51
  // This needs a ttl to prevent a binding change from causing the function not to be found.
50
- this.runAsyncFunction(ast, state, handler(false), { ttl: EDGE_FUNCTION_TTL });
52
+ this.runAsyncFunction(ast, state, handler(false), { ttl: FUNCTION_TTL });
51
53
  });
52
54
 
53
55
  this.context.createSubscription(ast.procedureName, unsubscribe);
@@ -59,22 +61,22 @@ export class EdgeFunctionPlugin extends FunctionPluginAsync {
59
61
  headers: { 'Content-Type': 'application/json' },
60
62
  body: JSON.stringify({ args: args.filter(nonNullable) }),
61
63
  });
64
+
62
65
  return await result.text();
63
66
  };
64
67
 
65
- return this.runAsyncFunction(ast, state, handler(true), { ttl: EDGE_FUNCTION_TTL });
68
+ return this.runAsyncFunction(ast, state, handler(true), { ttl: FUNCTION_TTL });
66
69
  }
67
70
  }
68
71
 
69
72
  EdgeFunctionPlugin.implementedFunctions = {
70
- EDGE: {
71
- method: 'edge',
73
+ [EDGE_FUNCTION_NAME]: {
74
+ method: 'dx',
72
75
  parameters: [
73
76
  // Binding
74
77
  { argumentType: FunctionArgumentType.STRING },
75
78
 
76
- // Remote function arguments (currently supporting up to 9).
77
- { argumentType: FunctionArgumentType.ANY, optionalArg: true },
79
+ // Remote function arguments (currently supporting up to 8).
78
80
  { argumentType: FunctionArgumentType.ANY, optionalArg: true },
79
81
  { argumentType: FunctionArgumentType.ANY, optionalArg: true },
80
82
  { argumentType: FunctionArgumentType.ANY, optionalArg: true },
@@ -90,9 +92,9 @@ EdgeFunctionPlugin.implementedFunctions = {
90
92
 
91
93
  export const EdgeFunctionPluginTranslations = {
92
94
  enGB: {
93
- EDGE: 'EDGE',
95
+ [EDGE_FUNCTION_NAME]: 'Remote function',
94
96
  },
95
97
  enUS: {
96
- EDGE: 'EDGE',
98
+ [EDGE_FUNCTION_NAME]: 'Remote function',
97
99
  },
98
100
  };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './async-function';
6
+ export * from './edge-function';
7
+ export * from './function-defs';
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { describe, test, expect } from 'vitest';
6
+
7
+ import { HyperFormula } from '#hyperformula';
8
+
9
+ describe('hyperformula', () => {
10
+ test('sanity test', async () => {
11
+ const hf = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' });
12
+ expect(hf).to.exist;
13
+ });
14
+ });
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './compute-graph';
6
+ export * from './compute-graph-registry';
7
+ export * from './compute-node';
8
+ export * from './functions';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './test-builder';
6
+ export * from './test-plugin';
@@ -0,0 +1,54 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Client, type ClientOptions } from '@dxos/client';
6
+ import { type Context, Resource } from '@dxos/context';
7
+ import { invariant } from '@dxos/invariant';
8
+
9
+ import { type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph-registry';
10
+
11
+ export type TestBuilderOptions = ClientOptions & ComputeGraphOptions;
12
+
13
+ // TODO(burdon): Reconcile with @dxos/client/testing.
14
+ export class TestBuilder extends Resource {
15
+ private _client?: Client;
16
+ private _registry?: ComputeGraphRegistry;
17
+
18
+ constructor(private readonly _options: TestBuilderOptions = {}) {
19
+ super();
20
+ }
21
+
22
+ get ctx(): Context {
23
+ return this._ctx;
24
+ }
25
+
26
+ get client(): Client {
27
+ invariant(this._client);
28
+ return this._client;
29
+ }
30
+
31
+ get registry(): ComputeGraphRegistry {
32
+ invariant(this._registry);
33
+ return this._registry;
34
+ }
35
+
36
+ override async _open() {
37
+ const client = new Client(this._options);
38
+ await client.initialize();
39
+ await client.halo.createIdentity();
40
+ this._client = client;
41
+ this._ctx.onDispose(async () => {
42
+ await client.destroy();
43
+ this._client = undefined;
44
+ });
45
+
46
+ const registry = new ComputeGraphRegistry(this._options);
47
+ await registry.open();
48
+ this._registry = registry;
49
+ this._ctx.onDispose(async () => {
50
+ await registry.close();
51
+ this._registry = undefined;
52
+ });
53
+ }
54
+ }
@@ -2,24 +2,36 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { FunctionArgumentType } from 'hyperformula';
6
5
  import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
7
6
  import { type ProcedureAst } from 'hyperformula/typings/parser';
8
7
 
9
8
  import { getDeep } from '@dxos/util';
10
9
 
11
- import { type AsyncFunction, FunctionPluginAsync } from './async-function';
12
-
13
- // TODO(burdon): Factor out.
14
- const parseNumberString = (str: string): number => {
15
- return parseFloat(str.replace(/[^\d.]/g, ''));
16
- };
10
+ import { FunctionArgumentType } from '#hyperformula';
11
+ import { type ComputeGraphPlugin } from '../compute-graph-registry';
12
+ import { type AsyncFunction, AsyncFunctionPlugin } from '../functions';
13
+ import { parseNumberString } from '../util';
17
14
 
18
15
  /**
16
+ * Testing functions run locally (not run via EDGE).
19
17
  * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
20
18
  */
21
- export class CustomPlugin extends FunctionPluginAsync {
19
+ export class TestPlugin extends AsyncFunctionPlugin {
20
+ /**
21
+ * Simple local function returns input value.
22
+ */
22
23
  test(ast: ProcedureAst, state: InterpreterState) {
24
+ const handler: AsyncFunction = async (_value) => {
25
+ return _value;
26
+ };
27
+
28
+ return this.runAsyncFunction(ast, state, handler);
29
+ }
30
+
31
+ /**
32
+ * Simple local function returns random number.
33
+ */
34
+ random(ast: ProcedureAst, state: InterpreterState) {
23
35
  const handler: AsyncFunction = async () => {
24
36
  return Math.random();
25
37
  };
@@ -27,6 +39,9 @@ export class CustomPlugin extends FunctionPluginAsync {
27
39
  return this.runAsyncFunction(ast, state, handler);
28
40
  }
29
41
 
42
+ /**
43
+ * Async HTTP function.
44
+ */
30
45
  crypto(ast: ProcedureAst, state: InterpreterState) {
31
46
  const handler: AsyncFunction = async (_currency) => {
32
47
  const currency = (_currency || 'USD').toUpperCase();
@@ -44,9 +59,15 @@ export class CustomPlugin extends FunctionPluginAsync {
44
59
  }
45
60
  }
46
61
 
47
- CustomPlugin.implementedFunctions = {
62
+ TestPlugin.implementedFunctions = {
48
63
  TEST: {
49
64
  method: 'test',
65
+ parameters: [{ argumentType: FunctionArgumentType.NUMBER, optionalArg: false }],
66
+ isVolatile: true,
67
+ },
68
+
69
+ RANDOM: {
70
+ method: 'random',
50
71
  parameters: [],
51
72
  isVolatile: true,
52
73
  },
@@ -58,13 +79,22 @@ CustomPlugin.implementedFunctions = {
58
79
  },
59
80
  };
60
81
 
61
- export const CustomPluginTranslations = {
82
+ export const TestPluginTranslations = {
62
83
  enGB: {
63
- TEST: 'TEST',
64
- CRYPTO: 'CRYPTO',
84
+ TEST: 'Returns input value',
85
+ RANDOM: 'Random number',
86
+ CRYPTO: 'Crypto token value',
65
87
  },
66
88
  enUS: {
67
- TEST: 'TEST',
68
- CRYPTO: 'CRYPTO',
89
+ TEST: 'Returns input value',
90
+ RANDOM: 'Random number',
91
+ CRYPTO: 'Crypto token value',
69
92
  },
70
93
  };
94
+
95
+ export const testFunctionPlugins: ComputeGraphPlugin[] = [
96
+ {
97
+ plugin: TestPlugin,
98
+ translations: TestPluginTranslations,
99
+ },
100
+ ];
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ // TODO(burdon): Factor out.
6
+ export const parseNumberString = (str: string): number => {
7
+ return parseFloat(str.replace(/[^\d.]/g, ''));
8
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './sheet-range-types';
6
+ export * from './types';
7
+ export * from './util';
@@ -0,0 +1,47 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type ClassNameValue } from '@dxos/react-ui';
6
+
7
+ import { type SheetType } from '../types';
8
+
9
+ export const alignKey = 'align';
10
+ export type AlignKey = typeof alignKey;
11
+ export type AlignValue = 'start' | 'center' | 'end' | 'unset';
12
+
13
+ export const commentKey = 'comment';
14
+ export type CommentKey = typeof commentKey;
15
+ export type CommentValue = string;
16
+
17
+ export const styleKey = 'style';
18
+ export type StyleKey = typeof styleKey;
19
+ export type StyleValue = 'highlight' | 'unset';
20
+
21
+ // TODO(burdon): Reconcile with plugin-table.
22
+ export const cellClassNameForRange = ({ key, value }: SheetType['ranges'][number]): ClassNameValue => {
23
+ switch (key) {
24
+ case 'align':
25
+ switch (value) {
26
+ case 'start':
27
+ return 'text-start';
28
+ case 'center':
29
+ return 'text-center';
30
+ case 'end':
31
+ return 'text-end';
32
+ default:
33
+ return undefined;
34
+ }
35
+ case 'comment':
36
+ return 'bg-gridComment';
37
+ case 'style':
38
+ switch (value) {
39
+ case 'highlight':
40
+ return 'bg-gridHighlight';
41
+ default:
42
+ return undefined;
43
+ }
44
+ default:
45
+ return undefined;
46
+ }
47
+ };
@@ -3,15 +3,14 @@
3
3
  //
4
4
 
5
5
  import { getIndices, sortByIndex, getIndicesBelow, getIndicesAbove, getIndicesBetween } from '@tldraw/indices';
6
- import { expect } from 'chai';
7
- import { describe, test } from 'vitest';
6
+ import { describe, expect, test } from 'vitest';
8
7
 
9
8
  import { inRange, addressFromA1Notation, addressToA1Notation, rangeFromA1Notation, rangeToA1Notation } from './types';
10
9
 
11
10
  describe('cell', () => {
12
11
  test('posToA1Notation', () => {
13
- expect(addressToA1Notation({ column: 0, row: 0 })).to.eq('A1');
14
- expect(addressFromA1Notation('C2')).to.deep.eq({ column: 2, row: 1 });
12
+ expect(addressToA1Notation({ col: 0, row: 0 })).to.eq('A1');
13
+ expect(addressFromA1Notation('C2')).to.deep.eq({ col: 2, row: 1 });
15
14
  });
16
15
 
17
16
  test('rangeToA1Notation', () => {
@@ -56,19 +55,19 @@ describe('cell', () => {
56
55
  // Values.
57
56
  const cells: Record<string, any> = {};
58
57
  const setCell = (cell: string, value: any) => {
59
- const { column, row } = addressFromA1Notation(cell);
58
+ const { col, row } = addressFromA1Notation(cell);
60
59
  // Reallocate if > current bounds.
61
- if (column >= columns.length) {
62
- insertIndex(columns, column);
60
+ if (col >= columns.length) {
61
+ insertIndex(columns, col);
63
62
  }
64
63
  if (row >= rows.length) {
65
64
  insertIndex(rows, row);
66
65
  }
67
- const index = `${columns[column]}@${rows[row]}`;
66
+ const index = `${columns[col]}@${rows[row]}`;
68
67
  cells[index] = value;
69
68
  };
70
69
 
71
- expect(addressFromA1Notation('A1')).to.deep.eq({ column: 0, row: 0 });
70
+ expect(addressFromA1Notation('A1')).to.deep.eq({ col: 0, row: 0 });
72
71
 
73
72
  expect(columns).to.deep.eq(['a1', 'a2', 'a3', 'a4', 'a5']);
74
73
  insertIndex(columns, 7);
@@ -0,0 +1,86 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { invariant } from '@dxos/invariant';
6
+
7
+ export const DEFAULT_ROWS = 50;
8
+ export const DEFAULT_COLUMNS = 26;
9
+
10
+ export const MAX_ROWS = 500;
11
+ export const MAX_COLUMNS = 26 * 2;
12
+
13
+ export type CellAddress = { col: number; row: number };
14
+
15
+ export type CellRange = { from: CellAddress; to?: CellAddress };
16
+ export type CompleteCellRange = { from: CellAddress; to: CellAddress };
17
+
18
+ export type CellIndex = string;
19
+
20
+ export type CellContentValue = number | string | boolean | null;
21
+
22
+ export const RANGE_NOTATION = /^[A-Z]+[0-9]+(:[A-Z]+[0-9]+)?$/;
23
+
24
+ export const isFormula = (value: any): value is string => typeof value === 'string' && value.charAt(0) === '=';
25
+
26
+ export const posEquals = (a: CellAddress | undefined, b: CellAddress | undefined) => {
27
+ return a?.col === b?.col && a?.row === b?.row;
28
+ };
29
+
30
+ export const columnLetter = (col: number): string => {
31
+ invariant(col < MAX_COLUMNS, `Invalid column: ${col}`);
32
+ return (
33
+ (col >= 26 ? String.fromCharCode('A'.charCodeAt(0) + Math.floor(col / 26) - 1) : '') +
34
+ String.fromCharCode('A'.charCodeAt(0) + (col % 26))
35
+ );
36
+ };
37
+
38
+ export const addressToA1Notation = ({ col, row }: CellAddress): string => {
39
+ return `${columnLetter(col)}${row + 1}`;
40
+ };
41
+
42
+ // TODO(burdon): See (HF) simpleCellAddressFromString.
43
+ export const addressFromA1Notation = (ref: string): CellAddress => {
44
+ const match = ref.match(/([A-Z]+)(\d+)/);
45
+ invariant(match, `Invalid notation: ${ref}`);
46
+ return {
47
+ row: parseInt(match[2], 10) - 1,
48
+ col: match[1].split('').reduce((acc, c) => acc * 26 + c.charCodeAt(0) - 'A'.charCodeAt(0) + 1, 0) - 1,
49
+ };
50
+ };
51
+
52
+ export const rangeToA1Notation = (range: CellRange) => {
53
+ return [range?.from && addressToA1Notation(range?.from), range?.to && addressToA1Notation(range?.to)]
54
+ .filter(Boolean)
55
+ .join(':');
56
+ };
57
+
58
+ export const rangeFromA1Notation = (ref: string): CellRange => {
59
+ const [from, to] = ref.split(':').map(addressFromA1Notation);
60
+ return { from, to };
61
+ };
62
+
63
+ export const inRange = (range: CellRange | undefined, cell: CellAddress): boolean => {
64
+ if (!range) {
65
+ return false;
66
+ }
67
+
68
+ const { from, to } = range;
69
+ if ((from && posEquals(from, cell)) || (to && posEquals(to, cell))) {
70
+ return true;
71
+ }
72
+
73
+ if (!from || !to) {
74
+ return false;
75
+ }
76
+
77
+ const { col: c1, row: r1 } = from;
78
+ const { col: c2, row: r2 } = to;
79
+ const cMin = Math.min(c1, c2);
80
+ const cMax = Math.max(c1, c2);
81
+ const rMin = Math.min(r1, r2);
82
+ const rMax = Math.max(r1, r2);
83
+
84
+ const { col, row } = cell;
85
+ return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
86
+ };
@@ -0,0 +1,135 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { randomBytes } from '@dxos/crypto';
6
+ import { create } from '@dxos/echo-schema';
7
+
8
+ import {
9
+ addressFromA1Notation,
10
+ type CellAddress,
11
+ type CellRange,
12
+ type CompleteCellRange,
13
+ DEFAULT_COLUMNS,
14
+ DEFAULT_ROWS,
15
+ MAX_COLUMNS,
16
+ MAX_ROWS,
17
+ } from './types';
18
+ import { type CreateSheetOptions, type SheetSize, SheetType } from '../types';
19
+
20
+ // TODO(burdon): Factor out from dxos/protocols to new common package.
21
+ export class ApiError extends Error {}
22
+
23
+ export class ReadonlyException extends ApiError {}
24
+
25
+ export class RangeException extends ApiError {
26
+ constructor(n: number) {
27
+ super();
28
+ }
29
+ }
30
+
31
+ /**
32
+ * With a string length of 8, the chance of a collision is 0.02% for a sheet with 10,000 strings.
33
+ */
34
+ export const createIndex = (length = 8): string => {
35
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
36
+ const charactersLength = characters.length;
37
+ const randomBuffer = randomBytes(length);
38
+ return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join('');
39
+ };
40
+
41
+ export const createIndices = (length: number): string[] => Array.from({ length }).map(() => createIndex());
42
+
43
+ export const insertIndices = (indices: string[], i: number, n: number, max: number) => {
44
+ if (i + n > max) {
45
+ throw new RangeException(i + n);
46
+ }
47
+
48
+ const idx = createIndices(n);
49
+ indices.splice(i, 0, ...idx);
50
+ };
51
+
52
+ export const initialize = (
53
+ sheet: SheetType,
54
+ { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS }: Partial<SheetSize> = {},
55
+ ) => {
56
+ if (!sheet.rows.length) {
57
+ insertIndices(sheet.rows, 0, rows, MAX_ROWS);
58
+ }
59
+ if (!sheet.columns.length) {
60
+ insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
61
+ }
62
+ };
63
+
64
+ export const createSheet = ({ name, cells, ...size }: CreateSheetOptions = {}): SheetType => {
65
+ const sheet = create(SheetType, {
66
+ name,
67
+ cells: {},
68
+ rows: [],
69
+ columns: [],
70
+ rowMeta: {},
71
+ columnMeta: {},
72
+ ranges: [],
73
+ threads: [],
74
+ });
75
+
76
+ initialize(sheet, size);
77
+
78
+ if (cells) {
79
+ Object.entries(cells).forEach(([key, { value }]) => {
80
+ const idx = addressToIndex(sheet, addressFromA1Notation(key));
81
+ sheet.cells[idx] = { value };
82
+ });
83
+ }
84
+
85
+ return sheet;
86
+ };
87
+
88
+ /**
89
+ * E.g., "A1" => "CA2@CB3".
90
+ */
91
+ export const addressToIndex = (sheet: SheetType, cell: CellAddress): string => {
92
+ return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
93
+ };
94
+
95
+ /**
96
+ * E.g., "CA2@CB3" => "A1".
97
+ */
98
+ export const addressFromIndex = (sheet: SheetType, idx: string): CellAddress => {
99
+ const [column, row] = idx.split('@');
100
+ return {
101
+ col: sheet.columns.indexOf(column),
102
+ row: sheet.rows.indexOf(row),
103
+ };
104
+ };
105
+
106
+ /**
107
+ * E.g., "A1:B2" => "CA2@CB3:CC4@CD5".
108
+ */
109
+ export const rangeToIndex = (sheet: SheetType, range: CellRange): string => {
110
+ return [range.from, range.to ?? range.from].map((cell) => addressToIndex(sheet, cell)).join(':');
111
+ };
112
+
113
+ /**
114
+ * E.g., "CA2@CB3:CC4@CD5" => "A1:B2".
115
+ */
116
+ export const rangeFromIndex = (sheet: SheetType, idx: string): CompleteCellRange => {
117
+ const [from, to] = idx.split(':').map((index) => addressFromIndex(sheet, index));
118
+ return { from, to };
119
+ };
120
+
121
+ /**
122
+ * Compares the positions of two cell indexes in a sheet.
123
+ * Sorts primarily by row, then by column if rows are equal.
124
+ */
125
+ export const compareIndexPositions = (sheet: SheetType, indexA: string, indexB: string): number => {
126
+ const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
127
+ const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
128
+
129
+ // Sort by row first, then by column.
130
+ if (rowA !== rowB) {
131
+ return rowA - rowB;
132
+ } else {
133
+ return columnA - columnB;
134
+ }
135
+ };