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