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