@dxos/plugin-sheet 0.8.3 → 0.8.4-main.1068cf700f

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 (297) hide show
  1. package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs +397 -0
  2. package/dist/lib/browser/SheetContainer-6DNFC4TY.mjs.map +7 -0
  3. package/dist/lib/browser/anchor-sort-AMMLA66W.mjs +24 -0
  4. package/dist/lib/browser/anchor-sort-AMMLA66W.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-EDWHV64N.mjs +1473 -0
  6. package/dist/lib/browser/chunk-EDWHV64N.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-FJRLDX7Z.mjs → chunk-IFLWVS2V.mjs} +7 -7
  8. package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-KE3AKN5W.mjs +397 -0
  10. package/dist/lib/browser/chunk-KE3AKN5W.mjs.map +7 -0
  11. package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs +21 -0
  12. package/dist/lib/browser/compute-graph-registry-RC5L7RE4.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +80 -89
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/markdown-D2T2DOVX.mjs +29 -0
  16. package/dist/lib/browser/markdown-D2T2DOVX.mjs.map +7 -0
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/operation-resolver-P2RX75DA.mjs +79 -0
  19. package/dist/lib/browser/operation-resolver-P2RX75DA.mjs.map +7 -0
  20. package/dist/lib/browser/react-surface-45CRAB5G.mjs +51 -0
  21. package/dist/lib/browser/react-surface-45CRAB5G.mjs.map +7 -0
  22. package/dist/lib/browser/types/index.mjs +7 -12
  23. package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs +398 -0
  24. package/dist/lib/node-esm/SheetContainer-7H5R7M54.mjs.map +7 -0
  25. package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs +25 -0
  26. package/dist/lib/node-esm/anchor-sort-VHMBRX2E.mjs.map +7 -0
  27. package/dist/lib/node-esm/chunk-6J5L47IB.mjs +398 -0
  28. package/dist/lib/node-esm/chunk-6J5L47IB.mjs.map +7 -0
  29. package/dist/lib/node-esm/chunk-AYSEWH7N.mjs +1474 -0
  30. package/dist/lib/node-esm/chunk-AYSEWH7N.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-NMCVJWDT.mjs → chunk-PPOYR7DK.mjs} +7 -7
  32. package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +7 -0
  33. package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs +22 -0
  34. package/dist/lib/node-esm/compute-graph-registry-ZGXVLVGD.mjs.map +7 -0
  35. package/dist/lib/node-esm/index.mjs +80 -89
  36. package/dist/lib/node-esm/index.mjs.map +4 -4
  37. package/dist/lib/node-esm/markdown-PTV72DLO.mjs +30 -0
  38. package/dist/lib/node-esm/markdown-PTV72DLO.mjs.map +7 -0
  39. package/dist/lib/node-esm/meta.json +1 -1
  40. package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs +80 -0
  41. package/dist/lib/node-esm/operation-resolver-WPIWQ5IO.mjs.map +7 -0
  42. package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs +52 -0
  43. package/dist/lib/node-esm/react-surface-ITV2L6HK.mjs.map +7 -0
  44. package/dist/lib/node-esm/types/index.mjs +7 -12
  45. package/dist/types/src/SheetPlugin.d.ts +2 -1
  46. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
  48. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
  50. package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
  52. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
  53. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
  54. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/index.d.ts +5 -11
  56. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  57. package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
  58. package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
  59. package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
  60. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
  61. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  62. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  63. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  64. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  66. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  68. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  69. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  70. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts +9 -4
  71. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
  72. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  73. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +51 -3
  74. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  75. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts +11 -20
  76. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  77. package/dist/types/src/components/GridSheet/util.d.ts +1 -1
  78. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  79. package/dist/types/src/components/RangeList/RangeList.d.ts +2 -2
  80. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  81. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +5 -6
  82. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  83. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +54 -5
  84. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  85. package/dist/types/src/components/SheetContext/SheetContext.d.ts +3 -3
  86. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  87. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +3 -4
  88. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
  89. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +88 -4
  90. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
  91. package/dist/types/src/components/SheetToolbar/align.d.ts +13 -20
  92. package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
  93. package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
  94. package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
  95. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -1
  96. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
  97. package/dist/types/src/components/index.d.ts +1 -1
  98. package/dist/types/src/components/index.d.ts.map +1 -1
  99. package/dist/types/src/extensions/compute.d.ts +1 -1
  100. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  101. package/dist/types/src/extensions/compute.stories.d.ts +10 -13
  102. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
  103. package/dist/types/src/extensions/editor/index.d.ts +1 -1
  104. package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
  105. package/dist/types/src/extensions/editor/{extension.d.ts → sheet-extension.d.ts} +1 -1
  106. package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -0
  107. package/dist/types/src/extensions/editor/sheet-extension.test.d.ts +2 -0
  108. package/dist/types/src/extensions/editor/sheet-extension.test.d.ts.map +1 -0
  109. package/dist/types/src/index.d.ts +1 -1
  110. package/dist/types/src/index.d.ts.map +1 -1
  111. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  112. package/dist/types/src/meta.d.ts +2 -3
  113. package/dist/types/src/meta.d.ts.map +1 -1
  114. package/dist/types/src/model/sheet-model.d.ts +6 -6
  115. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  116. package/dist/types/src/model/testing.d.ts +2 -2
  117. package/dist/types/src/model/testing.d.ts.map +1 -1
  118. package/dist/types/src/model/useSheetModel.d.ts +2 -2
  119. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  120. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  121. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  122. package/dist/types/src/{testing/playwright → playwright}/sheet-manager.d.ts +1 -1
  123. package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -0
  124. package/dist/types/src/playwright/sheet.spec.d.ts.map +1 -0
  125. package/dist/types/src/serializer.d.ts +2 -2
  126. package/dist/types/src/serializer.d.ts.map +1 -1
  127. package/dist/types/src/testing/data.d.ts +2 -2
  128. package/dist/types/src/testing/data.d.ts.map +1 -1
  129. package/dist/types/src/testing/testing.d.ts +27 -3
  130. package/dist/types/src/testing/testing.d.ts.map +1 -1
  131. package/dist/types/src/translations.d.ts +8 -62
  132. package/dist/types/src/translations.d.ts.map +1 -1
  133. package/dist/types/src/types/Sheet.d.ts +76 -0
  134. package/dist/types/src/types/Sheet.d.ts.map +1 -0
  135. package/dist/types/src/types/capabilities.d.ts +6 -0
  136. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  137. package/dist/types/src/types/index.d.ts +2 -1
  138. package/dist/types/src/types/index.d.ts.map +1 -1
  139. package/dist/types/src/types/sheet-range-types.d.ts +2 -2
  140. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
  141. package/dist/types/src/types/types.d.ts +92 -75
  142. package/dist/types/src/types/types.d.ts.map +1 -1
  143. package/dist/types/src/types/util.d.ts +10 -10
  144. package/dist/types/src/types/util.d.ts.map +1 -1
  145. package/dist/types/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +83 -73
  147. package/src/SheetPlugin.tsx +53 -65
  148. package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
  149. package/src/capabilities/anchor-sort/index.ts +7 -0
  150. package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
  151. package/src/capabilities/compute-graph-registry/index.ts +7 -0
  152. package/src/capabilities/index.ts +5 -9
  153. package/src/capabilities/markdown/index.ts +7 -0
  154. package/src/capabilities/markdown/markdown.ts +30 -0
  155. package/src/capabilities/operation-resolver/index.ts +7 -0
  156. package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
  157. package/src/capabilities/react-surface/index.ts +7 -0
  158. package/src/capabilities/react-surface/react-surface.tsx +43 -0
  159. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
  160. package/src/components/ComputeGraph/compute-graph.stories.tsx +21 -20
  161. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -2
  162. package/src/components/GridSheet/GridSheet.stories.tsx +23 -17
  163. package/src/components/GridSheet/GridSheet.tsx +63 -52
  164. package/src/components/GridSheet/SheetCellEditor.stories.tsx +44 -43
  165. package/src/components/GridSheet/util.ts +17 -11
  166. package/src/components/RangeList/RangeList.tsx +13 -10
  167. package/src/components/SheetContainer/SheetContainer.stories.tsx +71 -47
  168. package/src/components/SheetContainer/SheetContainer.tsx +30 -18
  169. package/src/components/SheetContext/SheetContext.tsx +9 -9
  170. package/src/components/SheetToolbar/SheetToolbar.stories.tsx +19 -13
  171. package/src/components/SheetToolbar/SheetToolbar.tsx +52 -42
  172. package/src/components/SheetToolbar/align.ts +46 -20
  173. package/src/components/SheetToolbar/style.ts +48 -18
  174. package/src/components/SheetToolbar/useToolbarState.ts +22 -5
  175. package/src/extensions/compute.stories.tsx +43 -30
  176. package/src/extensions/compute.ts +3 -4
  177. package/src/extensions/editor/index.ts +1 -1
  178. package/src/extensions/editor/{extension.test.ts → sheet-extension.test.ts} +1 -1
  179. package/src/extensions/editor/{extension.ts → sheet-extension.ts} +7 -4
  180. package/src/index.ts +1 -1
  181. package/src/integrations/thread-ranges.ts +43 -51
  182. package/src/meta.ts +9 -7
  183. package/src/model/sheet-model.test.ts +5 -4
  184. package/src/model/sheet-model.ts +85 -53
  185. package/src/model/testing.ts +4 -4
  186. package/src/model/useSheetModel.ts +2 -2
  187. package/src/playwright/playwright.config.ts +17 -0
  188. package/src/{testing/playwright → playwright}/sheet-manager.ts +1 -1
  189. package/src/{testing/playwright → playwright}/sheet.spec.ts +3 -2
  190. package/src/sanity.test.ts +4 -5
  191. package/src/serializer.ts +4 -4
  192. package/src/testing/data.ts +2 -2
  193. package/src/testing/testing.tsx +11 -5
  194. package/src/translations.ts +10 -7
  195. package/src/types/Sheet.ts +97 -0
  196. package/src/types/capabilities.ts +14 -0
  197. package/src/types/index.ts +2 -1
  198. package/src/types/sheet-range-types.ts +2 -2
  199. package/src/types/types.ts +84 -49
  200. package/src/types/util.ts +14 -41
  201. package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs +0 -351
  202. package/dist/lib/browser/SheetContainer-BDZXBB5U.mjs.map +0 -7
  203. package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs +0 -24
  204. package/dist/lib/browser/anchor-sort-NYYZLRAA.mjs.map +0 -7
  205. package/dist/lib/browser/chunk-5TA43LO4.mjs +0 -847
  206. package/dist/lib/browser/chunk-5TA43LO4.mjs.map +0 -7
  207. package/dist/lib/browser/chunk-D3G4UGEK.mjs +0 -18
  208. package/dist/lib/browser/chunk-D3G4UGEK.mjs.map +0 -7
  209. package/dist/lib/browser/chunk-FJRLDX7Z.mjs.map +0 -7
  210. package/dist/lib/browser/chunk-I7FZ4TWJ.mjs +0 -892
  211. package/dist/lib/browser/chunk-I7FZ4TWJ.mjs.map +0 -7
  212. package/dist/lib/browser/chunk-IR42IS3F.mjs +0 -15
  213. package/dist/lib/browser/chunk-IR42IS3F.mjs.map +0 -7
  214. package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs +0 -30
  215. package/dist/lib/browser/compute-graph-registry-IXGGJJBU.mjs.map +0 -7
  216. package/dist/lib/browser/intent-resolver-IBBI6B74.mjs +0 -56
  217. package/dist/lib/browser/intent-resolver-IBBI6B74.mjs.map +0 -7
  218. package/dist/lib/browser/markdown-T4TUP4BF.mjs +0 -26
  219. package/dist/lib/browser/markdown-T4TUP4BF.mjs.map +0 -7
  220. package/dist/lib/browser/react-surface-UI46P43F.mjs +0 -53
  221. package/dist/lib/browser/react-surface-UI46P43F.mjs.map +0 -7
  222. package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs +0 -351
  223. package/dist/lib/node/SheetContainer-VWPM3HYJ.cjs.map +0 -7
  224. package/dist/lib/node/anchor-sort-A7NABMJM.cjs +0 -39
  225. package/dist/lib/node/anchor-sort-A7NABMJM.cjs.map +0 -7
  226. package/dist/lib/node/chunk-FIM6EZ6M.cjs +0 -256
  227. package/dist/lib/node/chunk-FIM6EZ6M.cjs.map +0 -7
  228. package/dist/lib/node/chunk-JSIDCZHB.cjs +0 -41
  229. package/dist/lib/node/chunk-JSIDCZHB.cjs.map +0 -7
  230. package/dist/lib/node/chunk-LJWWS53Z.cjs +0 -34
  231. package/dist/lib/node/chunk-LJWWS53Z.cjs.map +0 -7
  232. package/dist/lib/node/chunk-N7FSEUIN.cjs +0 -927
  233. package/dist/lib/node/chunk-N7FSEUIN.cjs.map +0 -7
  234. package/dist/lib/node/chunk-ST3WA73J.cjs +0 -855
  235. package/dist/lib/node/chunk-ST3WA73J.cjs.map +0 -7
  236. package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs +0 -56
  237. package/dist/lib/node/compute-graph-registry-ARLDHPFW.cjs.map +0 -7
  238. package/dist/lib/node/index.cjs +0 -173
  239. package/dist/lib/node/index.cjs.map +0 -7
  240. package/dist/lib/node/intent-resolver-2657YDOU.cjs +0 -69
  241. package/dist/lib/node/intent-resolver-2657YDOU.cjs.map +0 -7
  242. package/dist/lib/node/markdown-DBPOAYI7.cjs +0 -40
  243. package/dist/lib/node/markdown-DBPOAYI7.cjs.map +0 -7
  244. package/dist/lib/node/meta.json +0 -1
  245. package/dist/lib/node/react-surface-XQEIRKWU.cjs +0 -71
  246. package/dist/lib/node/react-surface-XQEIRKWU.cjs.map +0 -7
  247. package/dist/lib/node/types/index.cjs +0 -84
  248. package/dist/lib/node/types/index.cjs.map +0 -7
  249. package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs +0 -352
  250. package/dist/lib/node-esm/SheetContainer-V632Q4HA.mjs.map +0 -7
  251. package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs +0 -25
  252. package/dist/lib/node-esm/anchor-sort-JTNZOE67.mjs.map +0 -7
  253. package/dist/lib/node-esm/chunk-C4IKYVTV.mjs +0 -893
  254. package/dist/lib/node-esm/chunk-C4IKYVTV.mjs.map +0 -7
  255. package/dist/lib/node-esm/chunk-IQ76YE6M.mjs +0 -16
  256. package/dist/lib/node-esm/chunk-IQ76YE6M.mjs.map +0 -7
  257. package/dist/lib/node-esm/chunk-NMCVJWDT.mjs.map +0 -7
  258. package/dist/lib/node-esm/chunk-SOC52B67.mjs +0 -848
  259. package/dist/lib/node-esm/chunk-SOC52B67.mjs.map +0 -7
  260. package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs +0 -20
  261. package/dist/lib/node-esm/chunk-Y6ND5HWX.mjs.map +0 -7
  262. package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs +0 -31
  263. package/dist/lib/node-esm/compute-graph-registry-7PDWXMHF.mjs.map +0 -7
  264. package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs +0 -57
  265. package/dist/lib/node-esm/intent-resolver-M2HNR7PJ.mjs.map +0 -7
  266. package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs +0 -27
  267. package/dist/lib/node-esm/markdown-WWUJ3E5F.mjs.map +0 -7
  268. package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs +0 -54
  269. package/dist/lib/node-esm/react-surface-OLXO2MVB.mjs.map +0 -7
  270. package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
  271. package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
  272. package/dist/types/src/capabilities/capabilities.d.ts +0 -5
  273. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  274. package/dist/types/src/capabilities/compute-graph-registry.d.ts +0 -4
  275. package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +0 -1
  276. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  277. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  278. package/dist/types/src/capabilities/markdown.d.ts +0 -6
  279. package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
  280. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  281. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  282. package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
  283. package/dist/types/src/extensions/editor/extension.test.d.ts +0 -2
  284. package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
  285. package/dist/types/src/testing/playwright/sheet-manager.d.ts.map +0 -1
  286. package/dist/types/src/testing/playwright/sheet.spec.d.ts.map +0 -1
  287. package/dist/types/src/types/schema.d.ts +0 -37
  288. package/dist/types/src/types/schema.d.ts.map +0 -1
  289. package/src/capabilities/anchor-sort.ts +0 -22
  290. package/src/capabilities/capabilities.ts +0 -14
  291. package/src/capabilities/compute-graph-registry.ts +0 -28
  292. package/src/capabilities/intent-resolver.ts +0 -38
  293. package/src/capabilities/markdown.ts +0 -22
  294. package/src/capabilities/react-surface.tsx +0 -39
  295. package/src/testing/playwright/playwright.config.cts +0 -18
  296. package/src/types/schema.ts +0 -60
  297. /package/dist/types/src/{testing/playwright → playwright}/sheet.spec.d.ts +0 -0
@@ -1,892 +0,0 @@
1
- import {
2
- SHEET_PLUGIN
3
- } from "./chunk-D3G4UGEK.mjs";
4
-
5
- // packages/plugins/plugin-sheet/src/types/schema.ts
6
- import { Schema } from "effect";
7
- import { Type } from "@dxos/echo";
8
- var CellValue = Schema.Struct({
9
- // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.
10
- // Consider import/export; natural access for other plugins. Special handling for currency (precision).
11
- // TODO(burdon): Automerge (long string) or short string or number.
12
- value: Schema.Any
13
- });
14
- var Range = Schema.Struct({
15
- range: Schema.String,
16
- key: Schema.String,
17
- value: Schema.String
18
- });
19
- var RowColumnMeta = Schema.Struct({
20
- size: Schema.optional(Schema.Number)
21
- });
22
- var SheetType = Schema.Struct({
23
- name: Schema.optional(Schema.String),
24
- // Sparse map of cells referenced by index.
25
- cells: Schema.mutable(Schema.Record({
26
- key: Schema.String,
27
- value: Schema.mutable(CellValue)
28
- })),
29
- // Ordered row indices.
30
- rows: Schema.mutable(Schema.Array(Schema.String)),
31
- // Ordered column indices.
32
- columns: Schema.mutable(Schema.Array(Schema.String)),
33
- // Row metadata referenced by index.
34
- rowMeta: Schema.mutable(Schema.Record({
35
- key: Schema.String,
36
- value: Schema.mutable(RowColumnMeta)
37
- })),
38
- // Column metadata referenced by index.
39
- columnMeta: Schema.mutable(Schema.Record({
40
- key: Schema.String,
41
- value: Schema.mutable(RowColumnMeta)
42
- })),
43
- // Cell formatting referenced by indexed range.
44
- ranges: Schema.mutable(Schema.Array(Range))
45
- }).pipe(Type.Obj({
46
- typename: "dxos.org/type/Sheet",
47
- version: "0.1.0"
48
- }));
49
-
50
- // packages/plugins/plugin-sheet/src/types/sheet-range-types.ts
51
- var alignKey = "alignment";
52
- var commentKey = "comment";
53
- var styleKey = "style";
54
- var cellClassNameForRange = ({ key, value }) => {
55
- switch (key) {
56
- case alignKey:
57
- switch (value) {
58
- case "start":
59
- return "text-start";
60
- case "center":
61
- return "text-center";
62
- case "end":
63
- return "text-end";
64
- default:
65
- return void 0;
66
- }
67
- case commentKey:
68
- return "bg-gridComment";
69
- case styleKey:
70
- switch (value) {
71
- case "highlight":
72
- return "!bg-gridHighlight";
73
- case "softwrap":
74
- return "!whitespace-normal";
75
- default:
76
- return void 0;
77
- }
78
- default:
79
- return void 0;
80
- }
81
- };
82
-
83
- // packages/plugins/plugin-sheet/src/types/types.ts
84
- import { Schema as Schema2 } from "effect";
85
-
86
- // packages/plugins/plugin-sheet/src/model/sheet-model.ts
87
- import { Event } from "@dxos/async";
88
- import { addressFromA1Notation, addressToA1Notation, createSheetName, isFormula, DetailedCellError, ExportedCellChange } from "@dxos/compute";
89
- import { Resource } from "@dxos/context";
90
- import { Obj } from "@dxos/echo";
91
- import { FormatEnum, TypeEnum } from "@dxos/echo-schema";
92
- import { invariant } from "@dxos/invariant";
93
- import { PublicKey } from "@dxos/keys";
94
- import { log } from "@dxos/log";
95
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
96
- var typeMap = {
97
- BOOLEAN: {
98
- type: TypeEnum.Boolean
99
- },
100
- NUMBER_RAW: {
101
- type: TypeEnum.Number
102
- },
103
- NUMBER_PERCENT: {
104
- type: TypeEnum.Number,
105
- format: FormatEnum.Percent
106
- },
107
- NUMBER_CURRENCY: {
108
- type: TypeEnum.Number,
109
- format: FormatEnum.Currency
110
- },
111
- NUMBER_DATETIME: {
112
- type: TypeEnum.String,
113
- format: FormatEnum.DateTime
114
- },
115
- NUMBER_DATE: {
116
- type: TypeEnum.String,
117
- format: FormatEnum.Date
118
- },
119
- NUMBER_TIME: {
120
- type: TypeEnum.String,
121
- format: FormatEnum.Time
122
- }
123
- };
124
- var getTopLeft = (range) => {
125
- const to = range.to ?? range.from;
126
- return {
127
- row: Math.min(range.from.row, to.row),
128
- col: Math.min(range.from.col, to.col)
129
- };
130
- };
131
- var toSimpleCellAddress = (sheet, cell) => ({
132
- sheet,
133
- row: cell.row,
134
- col: cell.col
135
- });
136
- var toModelRange = (sheet, range) => ({
137
- start: toSimpleCellAddress(sheet, range.from),
138
- end: toSimpleCellAddress(sheet, range.to ?? range.from)
139
- });
140
- var SheetModel = class extends Resource {
141
- constructor(_graph, _sheet, _options = {}) {
142
- super(), this._graph = _graph, this._sheet = _sheet, this._options = _options, this.id = `model-${PublicKey.random().truncate()}`, this.update = new Event();
143
- }
144
- get graph() {
145
- return this._graph;
146
- }
147
- get sheet() {
148
- return this._sheet;
149
- }
150
- get readonly() {
151
- return this._options.readonly;
152
- }
153
- get bounds() {
154
- return {
155
- rows: this._sheet.rows.length,
156
- columns: this._sheet.columns.length
157
- };
158
- }
159
- /**
160
- * Initialize sheet and engine.
161
- */
162
- async _open() {
163
- log("initialize", {
164
- id: this.id
165
- }, {
166
- F: __dxlog_file,
167
- L: 124,
168
- S: this,
169
- C: (f, a) => f(...a)
170
- });
171
- initialize(this._sheet);
172
- this._graph.update.on((event) => {
173
- if (event.type === "functionsUpdated") {
174
- this.reset();
175
- }
176
- });
177
- this._node = this._graph.getOrCreateNode(createSheetName({
178
- type: Obj.getTypename(this._sheet),
179
- id: this._sheet.id
180
- }));
181
- await this._node.open();
182
- const unsubscribe = this._node.update.on((event) => this.update.emit(event));
183
- this._ctx.onDispose(unsubscribe);
184
- this.reset();
185
- }
186
- /**
187
- * Update engine.
188
- * NOTE: This resets the undo history.
189
- * @deprecated
190
- */
191
- reset() {
192
- invariant(this._node, void 0, {
193
- F: __dxlog_file,
194
- L: 152,
195
- S: this,
196
- A: [
197
- "this._node",
198
- ""
199
- ]
200
- });
201
- this._node.graph.hf.clearSheet(this._node.sheetId);
202
- Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
203
- invariant(this._node, void 0, {
204
- F: __dxlog_file,
205
- L: 155,
206
- S: this,
207
- A: [
208
- "this._node",
209
- ""
210
- ]
211
- });
212
- const { col, row } = addressFromIndex(this._sheet, key);
213
- if (isFormula(value)) {
214
- const binding = this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
215
- if (binding) {
216
- value = this._graph.mapFormulaToNative(binding);
217
- } else {
218
- value = "";
219
- }
220
- }
221
- this._node.graph.hf.setCellContents({
222
- sheet: this._node.sheetId,
223
- row,
224
- col
225
- }, value);
226
- });
227
- }
228
- /**
229
- * Recalculate formulas.
230
- * NOTE: This resets the undo history.
231
- * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
232
- * @deprecated
233
- */
234
- // TODO(burdon): Remove.
235
- recalculate() {
236
- this._node?.graph.hf.rebuildAndRecalculate();
237
- }
238
- insertRows(i, n = 1) {
239
- const idx = insertIndices(this._sheet.rows, i, n, MAX_ROWS);
240
- this.reset();
241
- return idx;
242
- }
243
- insertColumns(i, n = 1) {
244
- const idx = insertIndices(this._sheet.columns, i, n, MAX_COLS);
245
- this.reset();
246
- return idx;
247
- }
248
- dropRow(rowIndex) {
249
- const range = {
250
- from: addressFromIndex(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
251
- to: addressFromIndex(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
252
- };
253
- const values = this.getCellValues(range).flat();
254
- const index = this._sheet.rows.indexOf(rowIndex);
255
- this.clear(range);
256
- this._sheet.rows.splice(index, 1);
257
- delete this._sheet.rowMeta[rowIndex];
258
- this.reset();
259
- return {
260
- axis: "row",
261
- index,
262
- axisIndex: rowIndex,
263
- axisMeta: this._sheet.rowMeta[rowIndex],
264
- values
265
- };
266
- }
267
- dropColumn(colIndex) {
268
- const range = {
269
- from: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
270
- to: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
271
- };
272
- const values = this.getCellValues(range).flat();
273
- const index = this._sheet.columns.indexOf(colIndex);
274
- this.clear(range);
275
- this._sheet.columns.splice(index, 1);
276
- delete this._sheet.columnMeta[colIndex];
277
- this.reset();
278
- return {
279
- axis: "col",
280
- index,
281
- axisIndex: colIndex,
282
- axisMeta: this._sheet.rowMeta[colIndex],
283
- values
284
- };
285
- }
286
- restoreRow({ index, axisIndex, axisMeta, values }) {
287
- this._sheet.rows.splice(index, 0, axisIndex);
288
- values.forEach((value, col) => {
289
- if (value) {
290
- this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
291
- value
292
- };
293
- }
294
- });
295
- if (axisMeta) {
296
- this._sheet.rowMeta[axisIndex] = axisMeta;
297
- }
298
- this.reset();
299
- }
300
- restoreColumn({ index, axisIndex, axisMeta, values }) {
301
- this._sheet.columns.splice(index, 0, axisIndex);
302
- values.forEach((value, row) => {
303
- if (value) {
304
- this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
305
- value
306
- };
307
- }
308
- });
309
- if (axisMeta) {
310
- this._sheet.columnMeta[axisIndex] = axisMeta;
311
- }
312
- this.reset();
313
- }
314
- //
315
- // Undoable actions.
316
- // TODO(burdon): Group undoable methods; consistently update hf/sheet.
317
- //
318
- /**
319
- * Clear range of values.
320
- */
321
- clear(range) {
322
- invariant(this._node, void 0, {
323
- F: __dxlog_file,
324
- L: 258,
325
- S: this,
326
- A: [
327
- "this._node",
328
- ""
329
- ]
330
- });
331
- const topLeft = getTopLeft(range);
332
- const values = this._iterRange(range, () => null);
333
- this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
334
- this._iterRange(range, (cell) => {
335
- const idx = addressToIndex(this._sheet, cell);
336
- delete this._sheet.cells[idx];
337
- });
338
- }
339
- cut(range) {
340
- invariant(this._node, void 0, {
341
- F: __dxlog_file,
342
- L: 269,
343
- S: this,
344
- A: [
345
- "this._node",
346
- ""
347
- ]
348
- });
349
- this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
350
- this._iterRange(range, (cell) => {
351
- const idx = addressToIndex(this._sheet, cell);
352
- delete this._sheet.cells[idx];
353
- });
354
- }
355
- copy(range) {
356
- invariant(this._node, void 0, {
357
- F: __dxlog_file,
358
- L: 278,
359
- S: this,
360
- A: [
361
- "this._node",
362
- ""
363
- ]
364
- });
365
- this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
366
- }
367
- paste(cell) {
368
- invariant(this._node, void 0, {
369
- F: __dxlog_file,
370
- L: 283,
371
- S: this,
372
- A: [
373
- "this._node",
374
- ""
375
- ]
376
- });
377
- if (!this._node.graph.hf.isClipboardEmpty()) {
378
- const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
379
- for (const change of changes) {
380
- if (change instanceof ExportedCellChange) {
381
- const { address, newValue } = change;
382
- const idx = addressToIndex(this._sheet, {
383
- row: address.row,
384
- col: address.col
385
- });
386
- this._sheet.cells[idx] = {
387
- value: newValue
388
- };
389
- }
390
- }
391
- }
392
- }
393
- // TODO(burdon): Display undo/redo state.
394
- undo() {
395
- invariant(this._node, void 0, {
396
- F: __dxlog_file,
397
- L: 298,
398
- S: this,
399
- A: [
400
- "this._node",
401
- ""
402
- ]
403
- });
404
- if (this._node.graph.hf.isThereSomethingToUndo()) {
405
- this._node.graph.hf.undo();
406
- }
407
- }
408
- redo() {
409
- invariant(this._node, void 0, {
410
- F: __dxlog_file,
411
- L: 306,
412
- S: this,
413
- A: [
414
- "this._node",
415
- ""
416
- ]
417
- });
418
- if (this._node.graph.hf.isThereSomethingToRedo()) {
419
- this._node.graph.hf.redo();
420
- }
421
- }
422
- /**
423
- * Get value from sheet.
424
- */
425
- getCellValue(cell) {
426
- const idx = addressToIndex(this._sheet, cell);
427
- return this._sheet.cells[idx]?.value ?? null;
428
- }
429
- /**
430
- * Get value as a string for editing.
431
- */
432
- getCellText(cell) {
433
- const value = this.getCellValue(cell);
434
- if (value == null) {
435
- return void 0;
436
- }
437
- if (isFormula(value)) {
438
- return this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
439
- } else {
440
- return String(value);
441
- }
442
- }
443
- /**
444
- * Get array of raw values from sheet.
445
- */
446
- getCellValues(range) {
447
- return this._iterRange(range, (cell) => this.getCellValue(cell));
448
- }
449
- /**
450
- * Gets the regular or computed value from the engine.
451
- */
452
- getValue(cell) {
453
- invariant(this._node, void 0, {
454
- F: __dxlog_file,
455
- L: 349,
456
- S: this,
457
- A: [
458
- "this._node",
459
- ""
460
- ]
461
- });
462
- const address = toSimpleCellAddress(this._node.sheetId, cell);
463
- const value = this._node.graph.hf.getCellValue(address);
464
- if (value instanceof DetailedCellError) {
465
- log.warn("cell error", {
466
- cell,
467
- error: value
468
- }, {
469
- F: __dxlog_file,
470
- L: 354,
471
- S: this,
472
- C: (f, a) => f(...a)
473
- });
474
- return value.toString();
475
- }
476
- return value;
477
- }
478
- /**
479
- * Get value type.
480
- */
481
- getValueDescription(cell) {
482
- invariant(this._node, void 0, {
483
- F: __dxlog_file,
484
- L: 365,
485
- S: this,
486
- A: [
487
- "this._node",
488
- ""
489
- ]
490
- });
491
- const addr = toSimpleCellAddress(this._node.sheetId, cell);
492
- const type = this._node.graph.hf.getCellValueDetailedType(addr);
493
- return typeMap[type];
494
- }
495
- /**
496
- * Sets the value, updating the sheet and engine.
497
- */
498
- setValue(cell, value) {
499
- invariant(this._node, void 0, {
500
- F: __dxlog_file,
501
- L: 375,
502
- S: this,
503
- A: [
504
- "this._node",
505
- ""
506
- ]
507
- });
508
- if (this._options.readonly) {
509
- throw new ReadonlyException();
510
- }
511
- let refresh = false;
512
- if (cell.row >= this._sheet.rows.length) {
513
- insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
514
- refresh = true;
515
- }
516
- if (cell.col >= this._sheet.columns.length) {
517
- insertIndices(this._sheet.columns, cell.col, 1, MAX_COLS);
518
- refresh = true;
519
- }
520
- if (refresh) {
521
- this.reset();
522
- }
523
- this._node.graph.hf.setCellContents({
524
- sheet: this._node.sheetId,
525
- row: cell.row,
526
- col: cell.col
527
- }, [
528
- [
529
- isFormula(value) ? this._graph.mapFormulaToNative(value) : value
530
- ]
531
- ]);
532
- const idx = addressToIndex(this._sheet, cell);
533
- if (value === void 0 || value === null) {
534
- delete this._sheet.cells[idx];
535
- } else {
536
- if (isFormula(value)) {
537
- value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
538
- }
539
- this._sheet.cells[idx] = {
540
- value
541
- };
542
- }
543
- }
544
- /**
545
- * Sets values from a simple map.
546
- */
547
- setValues(values) {
548
- Object.entries(values).forEach(([key, { value }]) => {
549
- this.setValue(addressFromA1Notation(key), value);
550
- });
551
- }
552
- /**
553
- * Iterate range.
554
- */
555
- _iterRange(range, cb) {
556
- const to = range.to ?? range.from;
557
- const rowRange = [
558
- Math.min(range.from.row, to.row),
559
- Math.max(range.from.row, to.row)
560
- ];
561
- const columnRange = [
562
- Math.min(range.from.col, to.col),
563
- Math.max(range.from.col, to.col)
564
- ];
565
- const rows = [];
566
- for (let row = rowRange[0]; row <= rowRange[1]; row++) {
567
- const rowCells = [];
568
- for (let column = columnRange[0]; column <= columnRange[1]; column++) {
569
- const value = cb({
570
- row,
571
- col: column
572
- });
573
- if (value !== void 0) {
574
- rowCells.push(value);
575
- }
576
- }
577
- rows.push(rowCells);
578
- }
579
- return rows;
580
- }
581
- // TODO(burdon): Delete index.
582
- _deleteIndices(indices, i, n) {
583
- throw new Error("Not implemented");
584
- }
585
- // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
586
- _moveIndices(indices, i, j, n) {
587
- throw new Error("Not implemented");
588
- }
589
- /**
590
- * Map from indices to A1 notation.
591
- */
592
- mapFormulaIndicesToRefs(formula) {
593
- invariant(isFormula(formula), void 0, {
594
- F: __dxlog_file,
595
- L: 460,
596
- S: this,
597
- A: [
598
- "isFormula(formula)",
599
- ""
600
- ]
601
- });
602
- return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
603
- return addressToA1Notation(addressFromIndex(this._sheet, idx));
604
- });
605
- }
606
- //
607
- // Values
608
- //
609
- /**
610
- * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
611
- * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
612
- * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
613
- */
614
- toLocalDate(num) {
615
- const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
616
- return new Date(year, month - 1, day, hours, minutes, seconds);
617
- }
618
- toDateTime(num) {
619
- invariant(this._node, void 0, {
620
- F: __dxlog_file,
621
- L: 481,
622
- S: this,
623
- A: [
624
- "this._node",
625
- ""
626
- ]
627
- });
628
- return this._node.graph.hf.numberToDateTime(num);
629
- }
630
- toDate(num) {
631
- invariant(this._node, void 0, {
632
- F: __dxlog_file,
633
- L: 486,
634
- S: this,
635
- A: [
636
- "this._node",
637
- ""
638
- ]
639
- });
640
- return this._node.graph.hf.numberToDate(num);
641
- }
642
- toTime(num) {
643
- invariant(this._node, void 0, {
644
- F: __dxlog_file,
645
- L: 491,
646
- S: this,
647
- A: [
648
- "this._node",
649
- ""
650
- ]
651
- });
652
- return this._node.graph.hf.numberToTime(num);
653
- }
654
- };
655
-
656
- // packages/plugins/plugin-sheet/src/model/useSheetModel.ts
657
- import { useEffect, useState } from "react";
658
- var useSheetModel = (graph, sheet, { readonly } = {}) => {
659
- const [model, setModel] = useState();
660
- useEffect(() => {
661
- if (!graph || !sheet) {
662
- return;
663
- }
664
- let model2;
665
- const t = setTimeout(async () => {
666
- model2 = new SheetModel(graph, sheet, {
667
- readonly
668
- });
669
- await model2.open();
670
- setModel(model2);
671
- });
672
- return () => {
673
- clearTimeout(t);
674
- void model2?.close();
675
- };
676
- }, [
677
- graph,
678
- sheet,
679
- readonly
680
- ]);
681
- return model;
682
- };
683
-
684
- // packages/plugins/plugin-sheet/src/types/types.ts
685
- (function(SheetAction2) {
686
- const SHEET_ACTION = `${SHEET_PLUGIN}/action`;
687
- class Create extends Schema2.TaggedClass()(`${SHEET_ACTION}/create`, {
688
- input: Schema2.Struct({
689
- name: Schema2.optional(Schema2.String)
690
- }),
691
- output: Schema2.Struct({
692
- object: SheetType
693
- })
694
- }) {
695
- }
696
- SheetAction2.Create = Create;
697
- const Axis = Schema2.Union(Schema2.Literal("row"), Schema2.Literal("col"));
698
- class InsertAxis extends Schema2.TaggedClass()(`${SHEET_ACTION}/axis-insert`, {
699
- input: Schema2.Struct({
700
- // TODO(wittjosiah): Schema.instanceOf(SheetModel) throws when running tests.
701
- model: Schema2.Any.pipe(Schema2.filter((model) => model instanceof SheetModel)),
702
- axis: Axis,
703
- index: Schema2.Number,
704
- count: Schema2.optional(Schema2.Number)
705
- }),
706
- output: Schema2.Void
707
- }) {
708
- }
709
- SheetAction2.InsertAxis = InsertAxis;
710
- SheetAction2.RestoreAxis = Schema2.Struct({
711
- axis: Axis,
712
- axisIndex: Schema2.String,
713
- index: Schema2.Number,
714
- axisMeta: RowColumnMeta,
715
- values: Schema2.Array(Schema2.Any)
716
- });
717
- class DropAxis extends Schema2.TaggedClass()(`${SHEET_ACTION}/axis-drop`, {
718
- input: Schema2.Struct({
719
- // TODO(wittjosiah): Schema.instanceOf(SheetModel) throws when running tests.
720
- model: Schema2.Any.pipe(Schema2.filter((model) => model instanceof SheetModel)),
721
- axis: Axis,
722
- axisIndex: Schema2.String,
723
- deletionData: Schema2.optional(SheetAction2.RestoreAxis)
724
- }),
725
- output: Schema2.Void
726
- }) {
727
- }
728
- SheetAction2.DropAxis = DropAxis;
729
- })(SheetAction || (SheetAction = {}));
730
- var SheetAction;
731
-
732
- // packages/plugins/plugin-sheet/src/types/util.ts
733
- import { addressFromA1Notation as addressFromA1Notation2, addressToA1Notation as addressToA1Notation2, isFormula as isFormula2 } from "@dxos/compute";
734
- import { randomBytes } from "@dxos/crypto";
735
- import { Obj as Obj2 } from "@dxos/echo";
736
- import { invariant as invariant2 } from "@dxos/invariant";
737
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/types/util.ts";
738
- var MAX_ROWS = 500;
739
- var MAX_COLS = 676;
740
- var DEFAULT_ROWS = 50;
741
- var DEFAULT_COLS = 26;
742
- var ApiError = class extends Error {
743
- };
744
- var ReadonlyException = class extends ApiError {
745
- };
746
- var RangeException = class extends ApiError {
747
- constructor(n) {
748
- super();
749
- }
750
- };
751
- var createIndex = (length = 8) => {
752
- const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
753
- const charactersLength = characters.length;
754
- const randomBuffer = randomBytes(length);
755
- return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
756
- };
757
- var createIndices = (length) => Array.from({
758
- length
759
- }).map(() => createIndex());
760
- var insertIndices = (indices, i, n, max) => {
761
- if (i + n > max) {
762
- throw new RangeException(i + n);
763
- }
764
- const idx = createIndices(n);
765
- indices.splice(i, 0, ...idx);
766
- return idx;
767
- };
768
- var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLS } = {}) => {
769
- if (!sheet.rows.length) {
770
- insertIndices(sheet.rows, 0, rows, MAX_ROWS);
771
- }
772
- if (!sheet.columns.length) {
773
- insertIndices(sheet.columns, 0, columns, MAX_COLS);
774
- }
775
- };
776
- var createSheet = ({ name, cells, ...size } = {}) => {
777
- const sheet = Obj2.make(SheetType, {
778
- name,
779
- cells: {},
780
- rows: [],
781
- columns: [],
782
- rowMeta: {},
783
- columnMeta: {},
784
- ranges: []
785
- });
786
- initialize(sheet, size);
787
- if (cells) {
788
- Object.entries(cells).forEach(([key, { value }]) => {
789
- const idx = addressToIndex(sheet, addressFromA1Notation2(key));
790
- if (isFormula2(value)) {
791
- value = mapFormulaRefsToIndices(sheet, value);
792
- }
793
- sheet.cells[idx] = {
794
- value
795
- };
796
- });
797
- }
798
- return sheet;
799
- };
800
- var addressToIndex = (sheet, cell) => {
801
- return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
802
- };
803
- var addressFromIndex = (sheet, idx) => {
804
- const [column, row] = idx.split("@");
805
- return {
806
- col: sheet.columns.indexOf(column),
807
- row: sheet.rows.indexOf(row)
808
- };
809
- };
810
- var rangeToIndex = (sheet, range) => {
811
- return [
812
- range.from,
813
- range.to ?? range.from
814
- ].map((cell) => addressToIndex(sheet, cell)).join(":");
815
- };
816
- var rangeFromIndex = (sheet, idx) => {
817
- const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
818
- return {
819
- from,
820
- to
821
- };
822
- };
823
- var compareIndexPositions = (sheet, indexA, indexB) => {
824
- const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
825
- const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
826
- if (rowA !== rowB) {
827
- return rowA - rowB;
828
- } else {
829
- return columnA - columnB;
830
- }
831
- };
832
- var mapFormulaRefsToIndices = (sheet, formula) => {
833
- invariant2(isFormula2(formula), void 0, {
834
- F: __dxlog_file2,
835
- L: 152,
836
- S: void 0,
837
- A: [
838
- "isFormula(formula)",
839
- ""
840
- ]
841
- });
842
- return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
843
- return addressToIndex(sheet, addressFromA1Notation2(match));
844
- });
845
- };
846
- var mapFormulaIndicesToRefs = (sheet, formula) => {
847
- invariant2(isFormula2(formula), void 0, {
848
- F: __dxlog_file2,
849
- L: 162,
850
- S: void 0,
851
- A: [
852
- "isFormula(formula)",
853
- ""
854
- ]
855
- });
856
- return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
857
- return addressToA1Notation2(addressFromIndex(sheet, idx));
858
- });
859
- };
860
-
861
- export {
862
- CellValue,
863
- Range,
864
- RowColumnMeta,
865
- SheetType,
866
- alignKey,
867
- commentKey,
868
- styleKey,
869
- cellClassNameForRange,
870
- useSheetModel,
871
- SheetAction,
872
- MAX_ROWS,
873
- MAX_COLS,
874
- DEFAULT_ROWS,
875
- DEFAULT_COLS,
876
- ApiError,
877
- ReadonlyException,
878
- RangeException,
879
- createIndex,
880
- createIndices,
881
- insertIndices,
882
- initialize,
883
- createSheet,
884
- addressToIndex,
885
- addressFromIndex,
886
- rangeToIndex,
887
- rangeFromIndex,
888
- compareIndexPositions,
889
- mapFormulaRefsToIndices,
890
- mapFormulaIndicesToRefs
891
- };
892
- //# sourceMappingURL=chunk-I7FZ4TWJ.mjs.map