@dxos/plugin-sheet 0.8.4-main.937b3ca → 0.8.4-main.abd8ff62ef

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 (319) hide show
  1. package/dist/lib/browser/SheetPlugin-W4PFP6WG.mjs +92 -0
  2. package/dist/lib/browser/SheetPlugin-W4PFP6WG.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-5TXOUIGZ.mjs +118 -0
  4. package/dist/lib/browser/chunk-5TXOUIGZ.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  6. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-2SAGT3BB.mjs → chunk-SVGX3MWY.mjs} +34 -169
  8. package/dist/lib/browser/chunk-SVGX3MWY.mjs.map +7 -0
  9. package/dist/lib/browser/drop-axis-ZLERPPPH.mjs +23 -0
  10. package/dist/lib/browser/drop-axis-ZLERPPPH.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +24 -135
  12. package/dist/lib/browser/index.mjs.map +4 -4
  13. package/dist/lib/browser/insert-axis-WTRA3HE7.mjs +16 -0
  14. package/dist/lib/browser/insert-axis-WTRA3HE7.mjs.map +7 -0
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/operations/index.mjs +13 -0
  17. package/dist/lib/browser/operations/index.mjs.map +7 -0
  18. package/dist/lib/browser/restore-axis-PYGPW2TB.mjs +16 -0
  19. package/dist/lib/browser/restore-axis-PYGPW2TB.mjs.map +7 -0
  20. package/dist/lib/browser/scroll-to-anchor-6I4DNKBW.mjs +65 -0
  21. package/dist/lib/browser/scroll-to-anchor-6I4DNKBW.mjs.map +7 -0
  22. package/dist/lib/browser/translations.mjs +55 -0
  23. package/dist/lib/browser/translations.mjs.map +7 -0
  24. package/dist/lib/browser/types/index.mjs +2 -3
  25. package/dist/lib/node-esm/SheetPlugin-ZJRSEYHB.mjs +93 -0
  26. package/dist/lib/node-esm/SheetPlugin-ZJRSEYHB.mjs.map +7 -0
  27. package/dist/lib/node-esm/{chunk-IMWGSIDG.mjs → chunk-4A2KAXTF.mjs} +34 -169
  28. package/dist/lib/node-esm/chunk-4A2KAXTF.mjs.map +7 -0
  29. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  30. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-MCZFRYOP.mjs +119 -0
  32. package/dist/lib/node-esm/chunk-MCZFRYOP.mjs.map +7 -0
  33. package/dist/lib/node-esm/drop-axis-FV2GXSZP.mjs +24 -0
  34. package/dist/lib/node-esm/drop-axis-FV2GXSZP.mjs.map +7 -0
  35. package/dist/lib/node-esm/index.mjs +24 -135
  36. package/dist/lib/node-esm/index.mjs.map +4 -4
  37. package/dist/lib/node-esm/insert-axis-THXK6DCC.mjs +17 -0
  38. package/dist/lib/node-esm/insert-axis-THXK6DCC.mjs.map +7 -0
  39. package/dist/lib/node-esm/meta.json +1 -1
  40. package/dist/lib/node-esm/operations/index.mjs +14 -0
  41. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  42. package/dist/lib/node-esm/restore-axis-JIFT3Q7Z.mjs +17 -0
  43. package/dist/lib/node-esm/restore-axis-JIFT3Q7Z.mjs.map +7 -0
  44. package/dist/lib/node-esm/scroll-to-anchor-JRDC5KK2.mjs +66 -0
  45. package/dist/lib/node-esm/scroll-to-anchor-JRDC5KK2.mjs.map +7 -0
  46. package/dist/lib/node-esm/translations.mjs +56 -0
  47. package/dist/lib/node-esm/translations.mjs.map +7 -0
  48. package/dist/lib/node-esm/types/index.mjs +2 -3
  49. package/dist/types/src/SheetPlugin.d.ts +1 -0
  50. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  51. package/dist/types/src/SheetPlugin.node.d.ts +4 -0
  52. package/dist/types/src/SheetPlugin.node.d.ts.map +1 -0
  53. package/dist/types/src/SheetPlugin.test.d.ts +2 -0
  54. package/dist/types/src/SheetPlugin.test.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/anchor-sort.d.ts +6 -0
  56. package/dist/types/src/capabilities/anchor-sort.d.ts.map +1 -0
  57. package/dist/types/src/capabilities/compute-graph-registry.d.ts +5 -0
  58. package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
  59. package/dist/types/src/capabilities/index.d.ts +9 -5
  60. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  61. package/dist/types/src/capabilities/markdown.d.ts +5 -0
  62. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  63. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  64. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  66. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/state.d.ts +6 -0
  68. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  69. package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
  70. package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
  71. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
  72. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  73. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
  74. package/dist/types/src/components/Sheet/Sheet.d.ts +17 -0
  75. package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
  76. package/dist/types/src/components/Sheet/index.d.ts +2 -0
  77. package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
  78. package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
  79. package/dist/types/src/components/SheetContent/SheetContent.d.ts +6 -0
  80. package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
  81. package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts +93 -0
  82. package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -0
  83. package/dist/types/src/components/SheetContent/index.d.ts +2 -0
  84. package/dist/types/src/components/SheetContent/index.d.ts.map +1 -0
  85. package/dist/types/src/components/{GridSheet → SheetContent}/util.d.ts +1 -1
  86. package/dist/types/src/components/SheetContent/util.d.ts.map +1 -0
  87. package/dist/types/src/components/{SheetContext/SheetContext.d.ts → SheetRoot/SheetRoot.d.ts} +8 -6
  88. package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -0
  89. package/dist/types/src/components/SheetRoot/index.d.ts +2 -0
  90. package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -0
  91. package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +6 -0
  92. package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -0
  93. package/dist/types/src/components/SheetStatusbar/index.d.ts +2 -0
  94. package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -0
  95. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +5 -5
  96. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
  97. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +72 -68
  98. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
  99. package/dist/types/src/components/SheetToolbar/align.d.ts +2 -2
  100. package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
  101. package/dist/types/src/components/SheetToolbar/style.d.ts +2 -2
  102. package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
  103. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
  104. package/dist/types/src/components/index.d.ts +1 -4
  105. package/dist/types/src/components/index.d.ts.map +1 -1
  106. package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts +1 -1
  107. package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -0
  108. package/dist/types/src/containers/RangeList/index.d.ts +2 -0
  109. package/dist/types/src/containers/RangeList/index.d.ts.map +1 -0
  110. package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +12 -0
  111. package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -0
  112. package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts +92 -0
  113. package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
  114. package/dist/types/src/containers/SheetContainer/index.d.ts +2 -0
  115. package/dist/types/src/containers/SheetContainer/index.d.ts.map +1 -0
  116. package/dist/types/src/containers/index.d.ts +4 -0
  117. package/dist/types/src/containers/index.d.ts.map +1 -0
  118. package/dist/types/src/extensions/compute.d.ts +1 -1
  119. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  120. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
  121. package/dist/types/src/extensions/editor/sheet-extension.d.ts +1 -1
  122. package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -1
  123. package/dist/types/src/index.d.ts +3 -2
  124. package/dist/types/src/index.d.ts.map +1 -1
  125. package/dist/types/src/integrations/thread-ranges.d.ts +1 -3
  126. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  127. package/dist/types/src/model/sheet-model.d.ts +2 -2
  128. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  129. package/dist/types/src/model/testing.d.ts +1 -1
  130. package/dist/types/src/model/testing.d.ts.map +1 -1
  131. package/dist/types/src/model/useSheetModel.d.ts +2 -2
  132. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  133. package/dist/types/src/operations/definitions.d.ts +45 -0
  134. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  135. package/dist/types/src/operations/drop-axis.d.ts +5 -0
  136. package/dist/types/src/operations/drop-axis.d.ts.map +1 -0
  137. package/dist/types/src/operations/index.d.ts +4 -0
  138. package/dist/types/src/operations/index.d.ts.map +1 -0
  139. package/dist/types/src/operations/insert-axis.d.ts +5 -0
  140. package/dist/types/src/operations/insert-axis.d.ts.map +1 -0
  141. package/dist/types/src/operations/restore-axis.d.ts +5 -0
  142. package/dist/types/src/operations/restore-axis.d.ts.map +1 -0
  143. package/dist/types/src/operations/scroll-to-anchor.d.ts +5 -0
  144. package/dist/types/src/operations/scroll-to-anchor.d.ts.map +1 -0
  145. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  146. package/dist/types/src/playwright/sheet-manager.d.ts.map +1 -1
  147. package/dist/types/src/serializer.d.ts +1 -1
  148. package/dist/types/src/serializer.d.ts.map +1 -1
  149. package/dist/types/src/testing/data.d.ts +1 -1
  150. package/dist/types/src/testing/data.d.ts.map +1 -1
  151. package/dist/types/src/testing/testing.d.ts +13 -13
  152. package/dist/types/src/testing/testing.d.ts.map +1 -1
  153. package/dist/types/src/translations.d.ts +74 -39
  154. package/dist/types/src/translations.d.ts.map +1 -1
  155. package/dist/types/src/types/Sheet.d.ts +21 -21
  156. package/dist/types/src/types/Sheet.d.ts.map +1 -1
  157. package/dist/types/src/types/capabilities.d.ts +13 -1
  158. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  159. package/dist/types/src/types/sheet-range-types.d.ts +1 -1
  160. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
  161. package/dist/types/src/types/types.d.ts +0 -92
  162. package/dist/types/src/types/types.d.ts.map +1 -1
  163. package/dist/types/src/types/util.d.ts +3 -2
  164. package/dist/types/src/types/util.d.ts.map +1 -1
  165. package/dist/types/tsconfig.tsbuildinfo +1 -1
  166. package/package.json +89 -70
  167. package/src/SheetPlugin.node.ts +36 -0
  168. package/src/SheetPlugin.test.ts +30 -0
  169. package/src/SheetPlugin.tsx +51 -31
  170. package/src/capabilities/{anchor-sort/anchor-sort.ts → anchor-sort.ts} +4 -3
  171. package/src/capabilities/{compute-graph-registry/compute-graph-registry.ts → compute-graph-registry.ts} +5 -3
  172. package/src/capabilities/index.ts +13 -5
  173. package/src/capabilities/{markdown/markdown.ts → markdown.ts} +4 -3
  174. package/src/capabilities/operation-handler.ts +16 -0
  175. package/src/capabilities/react-surface.tsx +49 -0
  176. package/src/capabilities/state.ts +29 -0
  177. package/src/capabilities/undo-mappings.ts +30 -0
  178. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
  179. package/src/components/ComputeGraph/compute-graph.stories.tsx +19 -16
  180. package/src/components/Sheet/Sheet.tsx +20 -0
  181. package/src/components/Sheet/index.ts +5 -0
  182. package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +10 -9
  183. package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +20 -19
  184. package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +56 -33
  185. package/src/components/{RangeList → SheetContent}/index.ts +1 -1
  186. package/src/components/{GridSheet → SheetContent}/util.ts +6 -5
  187. package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +52 -39
  188. package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
  189. package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +20 -8
  190. package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
  191. package/src/components/SheetToolbar/SheetToolbar.stories.tsx +5 -5
  192. package/src/components/SheetToolbar/SheetToolbar.tsx +19 -23
  193. package/src/components/SheetToolbar/align.ts +15 -15
  194. package/src/components/SheetToolbar/style.ts +12 -12
  195. package/src/components/index.ts +1 -7
  196. package/src/{components → containers}/RangeList/RangeList.tsx +17 -16
  197. package/src/containers/RangeList/index.ts +5 -0
  198. package/src/{components → containers}/SheetContainer/SheetContainer.stories.tsx +42 -46
  199. package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
  200. package/src/containers/SheetContainer/index.ts +5 -0
  201. package/src/containers/index.ts +8 -0
  202. package/src/extensions/compute.stories.tsx +17 -16
  203. package/src/extensions/compute.ts +1 -1
  204. package/src/extensions/editor/sheet-extension.test.ts +1 -1
  205. package/src/extensions/editor/sheet-extension.ts +12 -12
  206. package/src/index.ts +8 -2
  207. package/src/integrations/thread-ranges.ts +8 -41
  208. package/src/meta.ts +1 -1
  209. package/src/model/sheet-model.test.ts +5 -5
  210. package/src/model/sheet-model.ts +39 -37
  211. package/src/model/testing.ts +2 -2
  212. package/src/model/useSheetModel.ts +3 -2
  213. package/src/operations/definitions.ts +73 -0
  214. package/src/operations/drop-axis.ts +26 -0
  215. package/src/operations/index.ts +14 -0
  216. package/src/operations/insert-axis.ts +19 -0
  217. package/src/operations/restore-axis.ts +19 -0
  218. package/src/operations/scroll-to-anchor.ts +31 -0
  219. package/src/playwright/playwright.config.ts +1 -1
  220. package/src/playwright/sheet.spec.ts +3 -3
  221. package/src/sanity.test.ts +6 -3
  222. package/src/serializer.ts +1 -1
  223. package/src/testing/data.ts +1 -1
  224. package/src/testing/testing.tsx +4 -4
  225. package/src/translations.ts +41 -36
  226. package/src/types/Sheet.ts +17 -20
  227. package/src/types/capabilities.ts +15 -3
  228. package/src/types/sheet-range-types.ts +3 -3
  229. package/src/types/types.ts +0 -80
  230. package/src/types/util.ts +3 -2
  231. package/dist/lib/browser/SheetContainer-ESCXPI7Y.mjs +0 -397
  232. package/dist/lib/browser/SheetContainer-ESCXPI7Y.mjs.map +0 -7
  233. package/dist/lib/browser/anchor-sort-JBRMW6OY.mjs +0 -23
  234. package/dist/lib/browser/anchor-sort-JBRMW6OY.mjs.map +0 -7
  235. package/dist/lib/browser/chunk-2SAGT3BB.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-IFLWVS2V.mjs +0 -234
  237. package/dist/lib/browser/chunk-IFLWVS2V.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-W6N44ONZ.mjs +0 -1470
  239. package/dist/lib/browser/chunk-W6N44ONZ.mjs.map +0 -7
  240. package/dist/lib/browser/compute-graph-registry-DL2PX7TF.mjs +0 -21
  241. package/dist/lib/browser/compute-graph-registry-DL2PX7TF.mjs.map +0 -7
  242. package/dist/lib/browser/markdown-BC4KBDUO.mjs +0 -29
  243. package/dist/lib/browser/markdown-BC4KBDUO.mjs.map +0 -7
  244. package/dist/lib/browser/operation-resolver-FJ4UWZUM.mjs +0 -79
  245. package/dist/lib/browser/operation-resolver-FJ4UWZUM.mjs.map +0 -7
  246. package/dist/lib/browser/react-surface-5BXM6TJ3.mjs +0 -51
  247. package/dist/lib/browser/react-surface-5BXM6TJ3.mjs.map +0 -7
  248. package/dist/lib/node-esm/SheetContainer-YVIDJKP4.mjs +0 -398
  249. package/dist/lib/node-esm/SheetContainer-YVIDJKP4.mjs.map +0 -7
  250. package/dist/lib/node-esm/anchor-sort-C3XFPI6S.mjs +0 -24
  251. package/dist/lib/node-esm/anchor-sort-C3XFPI6S.mjs.map +0 -7
  252. package/dist/lib/node-esm/chunk-IMWGSIDG.mjs.map +0 -7
  253. package/dist/lib/node-esm/chunk-PPOYR7DK.mjs +0 -236
  254. package/dist/lib/node-esm/chunk-PPOYR7DK.mjs.map +0 -7
  255. package/dist/lib/node-esm/chunk-S7RYX7DG.mjs +0 -1471
  256. package/dist/lib/node-esm/chunk-S7RYX7DG.mjs.map +0 -7
  257. package/dist/lib/node-esm/compute-graph-registry-VXH55GDI.mjs +0 -22
  258. package/dist/lib/node-esm/compute-graph-registry-VXH55GDI.mjs.map +0 -7
  259. package/dist/lib/node-esm/markdown-6DGZCJRM.mjs +0 -30
  260. package/dist/lib/node-esm/markdown-6DGZCJRM.mjs.map +0 -7
  261. package/dist/lib/node-esm/operation-resolver-OGXEUWHA.mjs +0 -80
  262. package/dist/lib/node-esm/operation-resolver-OGXEUWHA.mjs.map +0 -7
  263. package/dist/lib/node-esm/react-surface-RLHC6B77.mjs +0 -52
  264. package/dist/lib/node-esm/react-surface-RLHC6B77.mjs.map +0 -7
  265. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +0 -5
  266. package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +0 -1
  267. package/dist/types/src/capabilities/anchor-sort/index.d.ts +0 -3
  268. package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +0 -1
  269. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +0 -5
  270. package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +0 -1
  271. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +0 -3
  272. package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +0 -1
  273. package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
  274. package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
  275. package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
  276. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
  277. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  278. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  279. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  280. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  281. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  282. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  283. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  284. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  285. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
  286. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
  287. package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
  288. package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
  289. package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
  290. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
  291. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -55
  292. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
  293. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
  294. package/dist/types/src/components/GridSheet/index.d.ts +0 -2
  295. package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
  296. package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
  297. package/dist/types/src/components/RangeList/RangeList.d.ts.map +0 -1
  298. package/dist/types/src/components/RangeList/index.d.ts +0 -2
  299. package/dist/types/src/components/RangeList/index.d.ts.map +0 -1
  300. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -10
  301. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
  302. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -57
  303. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
  304. package/dist/types/src/components/SheetContainer/index.d.ts +0 -3
  305. package/dist/types/src/components/SheetContainer/index.d.ts.map +0 -1
  306. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
  307. package/dist/types/src/components/SheetContext/index.d.ts +0 -2
  308. package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
  309. package/src/capabilities/anchor-sort/index.ts +0 -7
  310. package/src/capabilities/compute-graph-registry/index.ts +0 -7
  311. package/src/capabilities/markdown/index.ts +0 -7
  312. package/src/capabilities/operation-resolver/index.ts +0 -7
  313. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -77
  314. package/src/capabilities/react-surface/index.ts +0 -7
  315. package/src/capabilities/react-surface/react-surface.tsx +0 -43
  316. package/src/components/SheetContainer/SheetContainer.tsx +0 -48
  317. package/src/components/SheetContainer/index.ts +0 -7
  318. package/src/components/SheetContext/index.ts +0 -5
  319. /package/dist/types/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +0 -0
@@ -1,1471 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- rangeExtension,
4
- sheetExtension
5
- } from "./chunk-PPOYR7DK.mjs";
6
- import {
7
- DEFAULT_COLS,
8
- DEFAULT_ROWS,
9
- MAX_COLS,
10
- MAX_ROWS,
11
- ReadonlyException,
12
- SheetOperation,
13
- Sheet_exports,
14
- addressFromIndex,
15
- addressToIndex,
16
- cellClassNameForRange,
17
- initialize,
18
- insertIndices,
19
- mapFormulaIndicesToRefs,
20
- mapFormulaRefsToIndices,
21
- meta,
22
- rangeFromIndex
23
- } from "./chunk-IMWGSIDG.mjs";
24
-
25
- // src/components/ComputeGraph/ComputeGraphContextProvider.tsx
26
- import React, { createContext, useContext } from "react";
27
- import { raise } from "@dxos/debug";
28
- import { useAsyncState } from "@dxos/react-hooks";
29
- var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
30
- var ComputeGraphContextProvider = ({ registry, children }) => {
31
- return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
32
- value: {
33
- registry
34
- }
35
- }, children);
36
- };
37
- var useComputeGraph = (space) => {
38
- const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
39
- const [graph] = useAsyncState(async () => {
40
- if (space) {
41
- const graph2 = registry.getOrCreateGraph(space);
42
- await graph2.open();
43
- return graph2;
44
- }
45
- }, [
46
- space,
47
- registry
48
- ]);
49
- return graph;
50
- };
51
-
52
- // src/components/RangeList/RangeList.tsx
53
- import * as Schema from "effect/Schema";
54
- import React2, { useCallback } from "react";
55
- import { rangeToA1Notation } from "@dxos/compute";
56
- import { Obj } from "@dxos/echo";
57
- import { Callout, useTranslation } from "@dxos/react-ui";
58
- import { List } from "@dxos/react-ui-list";
59
- import { ghostHover } from "@dxos/ui-theme";
60
- var RangeList = ({ sheet }) => {
61
- const { t } = useTranslation(meta.id);
62
- const handleSelectRange = (range) => {
63
- };
64
- const handleDeleteRange = useCallback((range) => {
65
- const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
66
- Obj.change(sheet, (s) => {
67
- s.ranges.splice(index, 1);
68
- });
69
- }, [
70
- sheet
71
- ]);
72
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", {
73
- className: "mbs-cardSpacingBlock mbe-labelSpacingBlock text-sm font-semibold"
74
- }, t("range list heading")), sheet.ranges.length < 1 ? /* @__PURE__ */ React2.createElement(Callout.Root, null, /* @__PURE__ */ React2.createElement(Callout.Title, null, t("no ranges message"))) : /* @__PURE__ */ React2.createElement(List.Root, {
75
- items: sheet.ranges,
76
- isItem: Schema.is(Sheet_exports.Range)
77
- }, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ React2.createElement(List.Item, {
78
- key: i,
79
- item: range,
80
- classNames: [
81
- "p-2",
82
- ghostHover
83
- ]
84
- }, /* @__PURE__ */ React2.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React2.createElement(List.ItemTitle, {
85
- onClick: () => handleSelectRange(range)
86
- }, t("range title", {
87
- position: rangeToA1Notation(rangeFromIndex(sheet, range.range)),
88
- key: t(`range key ${range.key} label`),
89
- value: t(`range value ${range.value} label`)
90
- })), /* @__PURE__ */ React2.createElement(List.ItemDeleteButton, {
91
- onClick: () => handleDeleteRange(range)
92
- })))));
93
- };
94
-
95
- // src/components/index.ts
96
- import { lazy } from "react";
97
-
98
- // src/components/GridSheet/GridSheet.tsx
99
- import React4, { useCallback as useCallback4, useMemo as useMemo2, useRef, useState as useState4 } from "react";
100
- import { useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/react";
101
- import { rangeToA1Notation as rangeToA1Notation2 } from "@dxos/compute";
102
- import { defaultColSize, defaultRowSize } from "@dxos/lit-grid";
103
- import { DropdownMenu, Icon, useTranslation as useTranslation2 } from "@dxos/react-ui";
104
- import { useAttention } from "@dxos/react-ui-attention";
105
- import { Grid as Grid2, GridCellEditor, closestCell, editorKeys, parseCellIndex } from "@dxos/react-ui-grid";
106
-
107
- // src/integrations/thread-ranges.ts
108
- import * as Effect from "effect/Effect";
109
- import { useCallback as useCallback2, useEffect, useMemo } from "react";
110
- import { Common } from "@dxos/app-framework";
111
- import { useOperationInvoker, useOperationResolver } from "@dxos/app-framework/react";
112
- import { debounce } from "@dxos/async";
113
- import { inRange } from "@dxos/compute";
114
- import { Obj as Obj2, Relation } from "@dxos/echo";
115
- import { OperationResolver } from "@dxos/operation";
116
- import { ATTENDABLE_PATH_SEPARATOR, DeckOperation } from "@dxos/plugin-deck/types";
117
- import { ThreadOperation } from "@dxos/plugin-thread/types";
118
- import { Filter, Query, useQuery } from "@dxos/react-client/echo";
119
- import { AnchoredTo, Thread } from "@dxos/types";
120
- var parseThreadAnchorAsCellRange = (cursor) => {
121
- const coords = cursor.split(",");
122
- if (coords.length !== 4) {
123
- return null;
124
- } else {
125
- const [fromCol, fromRow, toCol, toRow] = coords;
126
- return {
127
- from: {
128
- col: parseInt(fromCol),
129
- row: parseInt(fromRow)
130
- },
131
- to: {
132
- col: parseInt(toCol),
133
- row: parseInt(toRow)
134
- }
135
- };
136
- }
137
- };
138
- var useUpdateFocusedCellOnThreadSelection = (grid) => {
139
- const { model, setActiveRefs } = useSheetContext();
140
- const sheetId = Obj2.getDXN(model.sheet).toString();
141
- const scrollIntoViewHandler = useMemo(() => OperationResolver.make({
142
- operation: Common.LayoutOperation.ScrollIntoView,
143
- position: "hoist",
144
- filter: (input) => input.subject === sheetId && !!input.cursor,
145
- handler: (input) => Effect.sync(() => {
146
- const { cursor, ref } = input;
147
- if (cursor) {
148
- setActiveRefs(ref);
149
- const range = parseThreadAnchorAsCellRange(cursor);
150
- range && grid?.setFocus({
151
- ...range.to,
152
- plane: "grid"
153
- }, true);
154
- }
155
- })
156
- }), [
157
- sheetId,
158
- setActiveRefs,
159
- grid
160
- ]);
161
- useOperationResolver(meta.id, scrollIntoViewHandler);
162
- };
163
- var useSelectThreadOnCellFocus = () => {
164
- const { model, cursor } = useSheetContext();
165
- const { invokePromise } = useOperationInvoker();
166
- const db = Obj2.getDatabase(model.sheet);
167
- const anchors = useQuery(db, Query.select(Filter.id(model.sheet.id)).targetOf(AnchoredTo.AnchoredTo));
168
- const selectClosestThread = useCallback2((cellAddress) => {
169
- if (!cellAddress) {
170
- return;
171
- }
172
- const closestThread = anchors.find((anchor) => {
173
- const source = Relation.getSource(anchor);
174
- if (anchor.anchor && Obj2.instanceOf(Thread.Thread, source)) {
175
- const range = parseThreadAnchorAsCellRange(anchor.anchor);
176
- return range ? inRange(range, cellAddress) : false;
177
- } else {
178
- return false;
179
- }
180
- });
181
- if (closestThread) {
182
- const primary = Obj2.getDXN(model.sheet).toString();
183
- void (async () => {
184
- await invokePromise(ThreadOperation.Select, {
185
- current: Relation.getDXN(closestThread).toString()
186
- });
187
- await invokePromise(DeckOperation.ChangeCompanion, {
188
- primary,
189
- companion: `${primary}${ATTENDABLE_PATH_SEPARATOR}comments`
190
- });
191
- })();
192
- }
193
- }, [
194
- invokePromise,
195
- anchors
196
- ]);
197
- const debounced = useMemo(() => {
198
- return debounce((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
199
- }, [
200
- selectClosestThread
201
- ]);
202
- useEffect(() => {
203
- if (!cursor) {
204
- return;
205
- }
206
- debounced(cursor);
207
- }, [
208
- cursor,
209
- debounced
210
- ]);
211
- };
212
-
213
- // src/components/SheetContext/SheetContext.tsx
214
- import React3, { createContext as createContext2, useCallback as useCallback3, useContext as useContext2, useState as useState2 } from "react";
215
- import { Obj as Obj4 } from "@dxos/echo";
216
- import { invariant as invariant2 } from "@dxos/invariant";
217
- import { Grid, useGridContext } from "@dxos/react-ui-grid";
218
-
219
- // src/model/sheet-model.ts
220
- import { Event } from "@dxos/async";
221
- import { DetailedCellError, ExportedCellChange, addressFromA1Notation, addressToA1Notation, createSheetName, isFormula } from "@dxos/compute";
222
- import { Resource } from "@dxos/context";
223
- import { Obj as Obj3 } from "@dxos/echo";
224
- import { Format, TypeEnum } from "@dxos/echo/internal";
225
- import { invariant } from "@dxos/invariant";
226
- import { PublicKey } from "@dxos/keys";
227
- import { log } from "@dxos/log";
228
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
229
- var typeMap = {
230
- BOOLEAN: {
231
- type: TypeEnum.Boolean
232
- },
233
- NUMBER_RAW: {
234
- type: TypeEnum.Number
235
- },
236
- NUMBER_PERCENT: {
237
- type: TypeEnum.Number,
238
- format: Format.TypeFormat.Percent
239
- },
240
- NUMBER_CURRENCY: {
241
- type: TypeEnum.Number,
242
- format: Format.TypeFormat.Currency
243
- },
244
- NUMBER_DATETIME: {
245
- type: TypeEnum.String,
246
- format: Format.TypeFormat.DateTime
247
- },
248
- NUMBER_DATE: {
249
- type: TypeEnum.String,
250
- format: Format.TypeFormat.Date
251
- },
252
- NUMBER_TIME: {
253
- type: TypeEnum.String,
254
- format: Format.TypeFormat.Time
255
- }
256
- };
257
- var getTopLeft = (range) => {
258
- const to = range.to ?? range.from;
259
- return {
260
- row: Math.min(range.from.row, to.row),
261
- col: Math.min(range.from.col, to.col)
262
- };
263
- };
264
- var toSimpleCellAddress = (sheet, cell) => ({
265
- sheet,
266
- row: cell.row,
267
- col: cell.col
268
- });
269
- var toModelRange = (sheet, range) => ({
270
- start: toSimpleCellAddress(sheet, range.from),
271
- end: toSimpleCellAddress(sheet, range.to ?? range.from)
272
- });
273
- var SheetModel = class extends Resource {
274
- _graph;
275
- _sheet;
276
- _options;
277
- id = `model-${PublicKey.random().truncate()}`;
278
- // Wraps compute node.
279
- update = new Event();
280
- _node;
281
- constructor(_graph, _sheet, _options = {}) {
282
- super(), this._graph = _graph, this._sheet = _sheet, this._options = _options;
283
- }
284
- get graph() {
285
- return this._graph;
286
- }
287
- get sheet() {
288
- return this._sheet;
289
- }
290
- get readonly() {
291
- return this._options.readonly;
292
- }
293
- get bounds() {
294
- return {
295
- rows: this._sheet.rows.length,
296
- columns: this._sheet.columns.length
297
- };
298
- }
299
- /**
300
- * Initialize sheet and engine.
301
- */
302
- async _open() {
303
- log("initialize", {
304
- id: this.id
305
- }, {
306
- F: __dxlog_file,
307
- L: 124,
308
- S: this,
309
- C: (f, a) => f(...a)
310
- });
311
- Obj3.change(this._sheet, (s) => {
312
- initialize(s);
313
- });
314
- this._graph.update.on((event) => {
315
- if (event.type === "functionsUpdated") {
316
- this.reset();
317
- }
318
- });
319
- this._node = this._graph.getOrCreateNode(createSheetName({
320
- type: Obj3.getTypename(this._sheet),
321
- id: this._sheet.id
322
- }));
323
- await this._node.open();
324
- const unsubscribe = this._node.update.on((event) => this.update.emit(event));
325
- this._ctx.onDispose(unsubscribe);
326
- this.reset();
327
- }
328
- /**
329
- * Update engine.
330
- * NOTE: This resets the undo history.
331
- * @deprecated
332
- */
333
- reset() {
334
- invariant(this._node, void 0, {
335
- F: __dxlog_file,
336
- L: 154,
337
- S: this,
338
- A: [
339
- "this._node",
340
- ""
341
- ]
342
- });
343
- this._node.graph.hf.clearSheet(this._node.sheetId);
344
- Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
345
- invariant(this._node, void 0, {
346
- F: __dxlog_file,
347
- L: 157,
348
- S: this,
349
- A: [
350
- "this._node",
351
- ""
352
- ]
353
- });
354
- const { col, row } = addressFromIndex(this._sheet, key);
355
- if (isFormula(value)) {
356
- const binding = this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
357
- if (binding) {
358
- value = this._graph.mapFormulaToNative(binding);
359
- } else {
360
- value = "";
361
- }
362
- }
363
- this._node.graph.hf.setCellContents({
364
- sheet: this._node.sheetId,
365
- row,
366
- col
367
- }, value);
368
- });
369
- }
370
- /**
371
- * Recalculate formulas.
372
- * NOTE: This resets the undo history.
373
- * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
374
- * @deprecated
375
- */
376
- // TODO(burdon): Remove.
377
- recalculate() {
378
- this._node?.graph.hf.rebuildAndRecalculate();
379
- }
380
- insertRows(i, n = 1) {
381
- let idx = [];
382
- Obj3.change(this._sheet, (s) => {
383
- idx = insertIndices(s.rows, i, n, MAX_ROWS);
384
- });
385
- this.reset();
386
- return idx;
387
- }
388
- insertColumns(i, n = 1) {
389
- let idx = [];
390
- Obj3.change(this._sheet, (s) => {
391
- idx = insertIndices(s.columns, i, n, MAX_COLS);
392
- });
393
- this.reset();
394
- return idx;
395
- }
396
- dropRow(rowIndex) {
397
- const range = {
398
- from: addressFromIndex(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
399
- to: addressFromIndex(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
400
- };
401
- const values = this.getCellValues(range).flat();
402
- const index = this._sheet.rows.indexOf(rowIndex);
403
- this.clear(range);
404
- Obj3.change(this._sheet, (s) => {
405
- s.rows.splice(index, 1);
406
- delete s.rowMeta[rowIndex];
407
- });
408
- this.reset();
409
- return {
410
- axis: "row",
411
- index,
412
- axisIndex: rowIndex,
413
- axisMeta: this._sheet.rowMeta[rowIndex],
414
- values
415
- };
416
- }
417
- dropColumn(colIndex) {
418
- const range = {
419
- from: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
420
- to: addressFromIndex(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
421
- };
422
- const values = this.getCellValues(range).flat();
423
- const index = this._sheet.columns.indexOf(colIndex);
424
- this.clear(range);
425
- Obj3.change(this._sheet, (s) => {
426
- s.columns.splice(index, 1);
427
- delete s.columnMeta[colIndex];
428
- });
429
- this.reset();
430
- return {
431
- axis: "col",
432
- index,
433
- axisIndex: colIndex,
434
- axisMeta: this._sheet.rowMeta[colIndex],
435
- values
436
- };
437
- }
438
- restoreRow({ index, axisIndex, axisMeta, values }) {
439
- Obj3.change(this._sheet, (s) => {
440
- s.rows.splice(index, 0, axisIndex);
441
- values.forEach((value, col) => {
442
- if (value) {
443
- s.cells[`${s.columns[col]}@${axisIndex}`] = {
444
- value
445
- };
446
- }
447
- });
448
- if (axisMeta) {
449
- s.rowMeta[axisIndex] = axisMeta;
450
- }
451
- });
452
- this.reset();
453
- }
454
- restoreColumn({ index, axisIndex, axisMeta, values }) {
455
- Obj3.change(this._sheet, (s) => {
456
- s.columns.splice(index, 0, axisIndex);
457
- values.forEach((value, row) => {
458
- if (value) {
459
- s.cells[`${axisIndex}@${s.rows[row]}`] = {
460
- value
461
- };
462
- }
463
- });
464
- if (axisMeta) {
465
- s.columnMeta[axisIndex] = axisMeta;
466
- }
467
- });
468
- this.reset();
469
- }
470
- //
471
- // Undoable actions.
472
- // TODO(burdon): Group undoable methods; consistently update hf/sheet.
473
- //
474
- /**
475
- * Clear range of values.
476
- */
477
- clear(range) {
478
- invariant(this._node, void 0, {
479
- F: __dxlog_file,
480
- L: 274,
481
- S: this,
482
- A: [
483
- "this._node",
484
- ""
485
- ]
486
- });
487
- const topLeft = getTopLeft(range);
488
- const values = this._iterRange(range, () => null);
489
- this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
490
- Obj3.change(this._sheet, (s) => {
491
- this._iterRange(range, (cell) => {
492
- const idx = addressToIndex(this._sheet, cell);
493
- delete s.cells[idx];
494
- });
495
- });
496
- }
497
- cut(range) {
498
- invariant(this._node, void 0, {
499
- F: __dxlog_file,
500
- L: 287,
501
- S: this,
502
- A: [
503
- "this._node",
504
- ""
505
- ]
506
- });
507
- this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
508
- Obj3.change(this._sheet, (s) => {
509
- this._iterRange(range, (cell) => {
510
- const idx = addressToIndex(this._sheet, cell);
511
- delete s.cells[idx];
512
- });
513
- });
514
- }
515
- copy(range) {
516
- invariant(this._node, void 0, {
517
- F: __dxlog_file,
518
- L: 298,
519
- S: this,
520
- A: [
521
- "this._node",
522
- ""
523
- ]
524
- });
525
- this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
526
- }
527
- paste(cell) {
528
- invariant(this._node, void 0, {
529
- F: __dxlog_file,
530
- L: 303,
531
- S: this,
532
- A: [
533
- "this._node",
534
- ""
535
- ]
536
- });
537
- if (!this._node.graph.hf.isClipboardEmpty()) {
538
- const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
539
- Obj3.change(this._sheet, (s) => {
540
- for (const change of changes) {
541
- if (change instanceof ExportedCellChange) {
542
- const { address, newValue } = change;
543
- const idx = addressToIndex(this._sheet, {
544
- row: address.row,
545
- col: address.col
546
- });
547
- s.cells[idx] = {
548
- value: newValue
549
- };
550
- }
551
- }
552
- });
553
- }
554
- }
555
- // TODO(burdon): Display undo/redo state.
556
- undo() {
557
- invariant(this._node, void 0, {
558
- F: __dxlog_file,
559
- L: 320,
560
- S: this,
561
- A: [
562
- "this._node",
563
- ""
564
- ]
565
- });
566
- if (this._node.graph.hf.isThereSomethingToUndo()) {
567
- this._node.graph.hf.undo();
568
- }
569
- }
570
- redo() {
571
- invariant(this._node, void 0, {
572
- F: __dxlog_file,
573
- L: 328,
574
- S: this,
575
- A: [
576
- "this._node",
577
- ""
578
- ]
579
- });
580
- if (this._node.graph.hf.isThereSomethingToRedo()) {
581
- this._node.graph.hf.redo();
582
- }
583
- }
584
- /**
585
- * Get value from sheet.
586
- */
587
- getCellValue(cell) {
588
- const idx = addressToIndex(this._sheet, cell);
589
- return this._sheet.cells[idx]?.value ?? null;
590
- }
591
- /**
592
- * Get value as a string for editing.
593
- */
594
- getCellText(cell) {
595
- const value = this.getCellValue(cell);
596
- if (value == null) {
597
- return void 0;
598
- }
599
- if (isFormula(value)) {
600
- return this._graph.mapFunctionBindingFromId(mapFormulaIndicesToRefs(this._sheet, value));
601
- } else {
602
- return String(value);
603
- }
604
- }
605
- /**
606
- * Get array of raw values from sheet.
607
- */
608
- getCellValues(range) {
609
- return this._iterRange(range, (cell) => this.getCellValue(cell));
610
- }
611
- /**
612
- * Gets the regular or computed value from the engine.
613
- */
614
- getValue(cell) {
615
- invariant(this._node, void 0, {
616
- F: __dxlog_file,
617
- L: 371,
618
- S: this,
619
- A: [
620
- "this._node",
621
- ""
622
- ]
623
- });
624
- const address = toSimpleCellAddress(this._node.sheetId, cell);
625
- const value = this._node.graph.hf.getCellValue(address);
626
- if (value instanceof DetailedCellError) {
627
- log.warn("cell error", {
628
- cell,
629
- error: value
630
- }, {
631
- F: __dxlog_file,
632
- L: 376,
633
- S: this,
634
- C: (f, a) => f(...a)
635
- });
636
- return value.toString();
637
- }
638
- return value;
639
- }
640
- /**
641
- * Get value type.
642
- */
643
- getValueDescription(cell) {
644
- invariant(this._node, void 0, {
645
- F: __dxlog_file,
646
- L: 387,
647
- S: this,
648
- A: [
649
- "this._node",
650
- ""
651
- ]
652
- });
653
- const addr = toSimpleCellAddress(this._node.sheetId, cell);
654
- const type = this._node.graph.hf.getCellValueDetailedType(addr);
655
- return typeMap[type];
656
- }
657
- /**
658
- * Sets the value, updating the sheet and engine.
659
- */
660
- setValue(cell, value) {
661
- invariant(this._node, void 0, {
662
- F: __dxlog_file,
663
- L: 397,
664
- S: this,
665
- A: [
666
- "this._node",
667
- ""
668
- ]
669
- });
670
- if (this._options.readonly) {
671
- throw new ReadonlyException();
672
- }
673
- let refresh = false;
674
- if (cell.row >= this._sheet.rows.length) {
675
- Obj3.change(this._sheet, (s) => {
676
- insertIndices(s.rows, cell.row, 1, MAX_ROWS);
677
- });
678
- refresh = true;
679
- }
680
- if (cell.col >= this._sheet.columns.length) {
681
- Obj3.change(this._sheet, (s) => {
682
- insertIndices(s.columns, cell.col, 1, MAX_COLS);
683
- });
684
- refresh = true;
685
- }
686
- if (refresh) {
687
- this.reset();
688
- }
689
- this._node.graph.hf.setCellContents({
690
- sheet: this._node.sheetId,
691
- row: cell.row,
692
- col: cell.col
693
- }, [
694
- [
695
- isFormula(value) ? this._graph.mapFormulaToNative(value) : value
696
- ]
697
- ]);
698
- const idx = addressToIndex(this._sheet, cell);
699
- if (value === void 0 || value === null) {
700
- Obj3.change(this._sheet, (s) => {
701
- delete s.cells[idx];
702
- });
703
- } else {
704
- if (isFormula(value)) {
705
- value = this._graph.mapFunctionBindingToId(mapFormulaRefsToIndices(this._sheet, value));
706
- }
707
- Obj3.change(this._sheet, (s) => {
708
- s.cells[idx] = {
709
- value
710
- };
711
- });
712
- }
713
- }
714
- /**
715
- * Sets values from a simple map.
716
- */
717
- setValues(values) {
718
- Object.entries(values).forEach(([key, { value }]) => {
719
- this.setValue(addressFromA1Notation(key), value);
720
- });
721
- }
722
- /**
723
- * Iterate range.
724
- */
725
- _iterRange(range, cb) {
726
- const to = range.to ?? range.from;
727
- const rowRange = [
728
- Math.min(range.from.row, to.row),
729
- Math.max(range.from.row, to.row)
730
- ];
731
- const columnRange = [
732
- Math.min(range.from.col, to.col),
733
- Math.max(range.from.col, to.col)
734
- ];
735
- const rows = [];
736
- for (let row = rowRange[0]; row <= rowRange[1]; row++) {
737
- const rowCells = [];
738
- for (let column = columnRange[0]; column <= columnRange[1]; column++) {
739
- const value = cb({
740
- row,
741
- col: column
742
- });
743
- if (value !== void 0) {
744
- rowCells.push(value);
745
- }
746
- }
747
- rows.push(rowCells);
748
- }
749
- return rows;
750
- }
751
- // TODO(burdon): Delete index.
752
- _deleteIndices(indices, i, n) {
753
- throw new Error("Not implemented");
754
- }
755
- // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
756
- _moveIndices(indices, i, j, n) {
757
- throw new Error("Not implemented");
758
- }
759
- /**
760
- * Map from indices to A1 notation.
761
- */
762
- mapFormulaIndicesToRefs(formula) {
763
- invariant(isFormula(formula), void 0, {
764
- F: __dxlog_file,
765
- L: 490,
766
- S: this,
767
- A: [
768
- "isFormula(formula)",
769
- ""
770
- ]
771
- });
772
- return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
773
- return addressToA1Notation(addressFromIndex(this._sheet, idx));
774
- });
775
- }
776
- //
777
- // Values
778
- //
779
- /**
780
- * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
781
- * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
782
- * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
783
- */
784
- toLocalDate(num) {
785
- const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
786
- return new Date(year, month - 1, day, hours, minutes, seconds);
787
- }
788
- toDateTime(num) {
789
- invariant(this._node, void 0, {
790
- F: __dxlog_file,
791
- L: 511,
792
- S: this,
793
- A: [
794
- "this._node",
795
- ""
796
- ]
797
- });
798
- return this._node.graph.hf.numberToDateTime(num);
799
- }
800
- toDate(num) {
801
- invariant(this._node, void 0, {
802
- F: __dxlog_file,
803
- L: 516,
804
- S: this,
805
- A: [
806
- "this._node",
807
- ""
808
- ]
809
- });
810
- return this._node.graph.hf.numberToDate(num);
811
- }
812
- toTime(num) {
813
- invariant(this._node, void 0, {
814
- F: __dxlog_file,
815
- L: 521,
816
- S: this,
817
- A: [
818
- "this._node",
819
- ""
820
- ]
821
- });
822
- return this._node.graph.hf.numberToTime(num);
823
- }
824
- };
825
-
826
- // src/model/useSheetModel.ts
827
- import { useEffect as useEffect2, useState } from "react";
828
- var useSheetModel = (graph, sheet, { readonly } = {}) => {
829
- const [model, setModel] = useState();
830
- useEffect2(() => {
831
- if (!graph || !sheet) {
832
- return;
833
- }
834
- let model2;
835
- const t = setTimeout(async () => {
836
- model2 = new SheetModel(graph, sheet, {
837
- readonly
838
- });
839
- await model2.open();
840
- setModel(model2);
841
- });
842
- return () => {
843
- clearTimeout(t);
844
- void model2?.close();
845
- };
846
- }, [
847
- graph,
848
- sheet,
849
- readonly
850
- ]);
851
- return model;
852
- };
853
-
854
- // src/components/SheetContext/SheetContext.tsx
855
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
856
- var SheetContext = /* @__PURE__ */ createContext2(void 0);
857
- var useSheetContext = () => {
858
- const context = useContext2(SheetContext);
859
- invariant2(context, void 0, {
860
- F: __dxlog_file2,
861
- L: 54,
862
- S: void 0,
863
- A: [
864
- "context",
865
- ""
866
- ]
867
- });
868
- return context;
869
- };
870
- var SheetProviderImpl = ({ __gridScope, children, ignoreAttention, model, onInfo }) => {
871
- const { id, editing, setEditing } = useGridContext("SheetProvider", __gridScope);
872
- const [cursor, setCursorInternal] = useState2();
873
- const [range, setRangeInternal] = useState2();
874
- const [cursorFallbackRange, setCursorFallbackRange] = useState2();
875
- const [activeRefs, setActiveRefs] = useState2("");
876
- const setCursor = useCallback3((nextCursor) => {
877
- setCursorInternal(nextCursor);
878
- setCursorFallbackRange(range?.to ? range : nextCursor ? {
879
- from: nextCursor,
880
- to: nextCursor
881
- } : void 0);
882
- }, [
883
- range
884
- ]);
885
- const setRange = useCallback3((nextRange) => {
886
- setRangeInternal(nextRange);
887
- setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
888
- from: cursor,
889
- to: cursor
890
- } : void 0);
891
- }, [
892
- cursor
893
- ]);
894
- return /* @__PURE__ */ React3.createElement(SheetContext.Provider, {
895
- value: {
896
- id,
897
- model,
898
- editing,
899
- setEditing,
900
- cursor,
901
- setCursor,
902
- range,
903
- setRange,
904
- cursorFallbackRange,
905
- activeRefs,
906
- setActiveRefs,
907
- // TODO(burdon): Change to event.
908
- onInfo,
909
- ignoreAttention
910
- }
911
- }, children);
912
- };
913
- var SheetProvider = ({ children, graph, sheet, readonly, ignoreAttention, onInfo }) => {
914
- const model = useSheetModel(graph, sheet, {
915
- readonly
916
- });
917
- return !model ? null : /* @__PURE__ */ React3.createElement(Grid.Root, {
918
- id: Obj4.getDXN(sheet).toString()
919
- }, /* @__PURE__ */ React3.createElement(SheetProviderImpl, {
920
- model,
921
- onInfo,
922
- ignoreAttention
923
- }, children));
924
- };
925
-
926
- // src/components/GridSheet/util.ts
927
- import { useEffect as useEffect3, useState as useState3 } from "react";
928
- import { inRange as inRange2 } from "@dxos/compute";
929
- import { createDocAccessor } from "@dxos/echo-db";
930
- import { cellClassesForFieldType, parseValue } from "@dxos/react-ui-form";
931
- import { colToA1Notation, commentedClassName, rowToA1Notation } from "@dxos/react-ui-grid";
932
- import { mx } from "@dxos/ui-theme";
933
- var createDxGridColumns = (model) => {
934
- return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
935
- if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
936
- acc.grid[numericIndex] = {
937
- size: model.sheet.columnMeta[columnId].size,
938
- resizeable: true
939
- };
940
- }
941
- return acc;
942
- }, {
943
- grid: {}
944
- });
945
- };
946
- var createDxGridRows = (model) => {
947
- return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
948
- if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
949
- acc.grid[numericIndex] = {
950
- size: model.sheet.rowMeta[rowId].size,
951
- resizeable: true
952
- };
953
- }
954
- return acc;
955
- }, {
956
- grid: {}
957
- });
958
- };
959
- var projectCellProps = (model, col, row) => {
960
- const address = {
961
- col,
962
- row
963
- };
964
- const rawValue = model.getValue(address);
965
- const ranges = model.sheet.ranges?.filter(({ range }) => inRange2(rangeFromIndex(model.sheet, range), address));
966
- const threadRefs = void 0;
967
- const description = model.getValueDescription(address);
968
- const type = description?.type;
969
- const format = description?.format;
970
- const classNames = ranges?.map(cellClassNameForRange).reverse();
971
- return {
972
- value: parseValue({
973
- type,
974
- format,
975
- value: rawValue
976
- }),
977
- className: mx(cellClassesForFieldType({
978
- type,
979
- format
980
- }), threadRefs && commentedClassName, classNames),
981
- dataRefs: threadRefs
982
- };
983
- };
984
- var gridCellGetter = (model) => {
985
- const cachedGridCells = {};
986
- return (nextBounds) => {
987
- [
988
- ...Array(nextBounds.end.col - nextBounds.start.col)
989
- ].forEach((_, c0) => {
990
- return [
991
- ...Array(nextBounds.end.row - nextBounds.start.row)
992
- ].forEach((_2, r0) => {
993
- const col = nextBounds.start.col + c0;
994
- const row = nextBounds.start.row + r0;
995
- cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
996
- });
997
- });
998
- return cachedGridCells;
999
- };
1000
- };
1001
- var rowLabelCell = (row) => ({
1002
- value: rowToA1Notation(row),
1003
- className: "!bg-toolbarSurface text-subdued text-end pie-1",
1004
- resizeHandle: "row"
1005
- });
1006
- var colLabelCell = (col) => ({
1007
- value: colToA1Notation(col),
1008
- className: "!bg-toolbarSurface text-subdued",
1009
- resizeHandle: "col"
1010
- });
1011
- var cellGetter = (model) => {
1012
- const getGridCells = gridCellGetter(model);
1013
- return (nextBounds, plane) => {
1014
- switch (plane) {
1015
- case "grid":
1016
- return getGridCells(nextBounds);
1017
- case "fixedStartStart": {
1018
- return {
1019
- "0,0": {
1020
- className: "!bg-toolbarSurface"
1021
- }
1022
- };
1023
- }
1024
- case "frozenColsStart":
1025
- return [
1026
- ...Array(nextBounds.end.row - nextBounds.start.row)
1027
- ].reduce((acc, _, r0) => {
1028
- const r = nextBounds.start.row + r0;
1029
- acc[`0,${r}`] = rowLabelCell(r);
1030
- return acc;
1031
- }, {});
1032
- case "frozenRowsStart":
1033
- return [
1034
- ...Array(nextBounds.end.col - nextBounds.start.col)
1035
- ].reduce((acc, _, c0) => {
1036
- const c = nextBounds.start.col + c0;
1037
- acc[`${c},0`] = colLabelCell(c);
1038
- return acc;
1039
- }, {});
1040
- default:
1041
- return {};
1042
- }
1043
- };
1044
- };
1045
- var useSheetModelDxGridProps = (dxGrid, model) => {
1046
- const [columns, setColumns] = useState3(createDxGridColumns(model));
1047
- const [rows, setRows] = useState3(createDxGridRows(model));
1048
- useEffect3(() => {
1049
- const cellsAccessor = createDocAccessor(model.sheet, [
1050
- "cells"
1051
- ]);
1052
- if (dxGrid) {
1053
- dxGrid.getCells = cellGetter(model);
1054
- }
1055
- const handleCellsUpdate = () => {
1056
- dxGrid?.requestUpdate("initialCells");
1057
- };
1058
- cellsAccessor.handle.addListener("change", handleCellsUpdate);
1059
- const unsubscribe = model.graph.update.on(handleCellsUpdate);
1060
- return () => {
1061
- cellsAccessor.handle.removeListener("change", handleCellsUpdate);
1062
- unsubscribe();
1063
- };
1064
- }, [
1065
- model,
1066
- dxGrid
1067
- ]);
1068
- useEffect3(() => {
1069
- const columnMetaAccessor = createDocAccessor(model.sheet, [
1070
- "columnMeta"
1071
- ]);
1072
- const rowMetaAccessor = createDocAccessor(model.sheet, [
1073
- "rowMeta"
1074
- ]);
1075
- const handleColumnMetaUpdate = () => {
1076
- setColumns(createDxGridColumns(model));
1077
- };
1078
- const handleRowMetaUpdate = () => {
1079
- setRows(createDxGridRows(model));
1080
- };
1081
- columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
1082
- rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
1083
- return () => {
1084
- columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
1085
- rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
1086
- };
1087
- }, [
1088
- model,
1089
- dxGrid
1090
- ]);
1091
- return {
1092
- columns,
1093
- rows
1094
- };
1095
- };
1096
-
1097
- // src/components/GridSheet/GridSheet.tsx
1098
- var inertPosition = {
1099
- plane: "grid",
1100
- col: 0,
1101
- row: 0
1102
- };
1103
- var initialCells = {
1104
- grid: {},
1105
- frozenColsStart: [
1106
- ...Array(64)
1107
- ].reduce((acc, _, i) => {
1108
- acc[`0,${i}`] = rowLabelCell(i);
1109
- return acc;
1110
- }, {}),
1111
- frozenRowsStart: [
1112
- ...Array(12)
1113
- ].reduce((acc, _, i) => {
1114
- acc[`${i},0`] = colLabelCell(i);
1115
- return acc;
1116
- }, {})
1117
- };
1118
- var frozen = {
1119
- frozenColsStart: 1,
1120
- frozenRowsStart: 1
1121
- };
1122
- var sheetColDefault = {
1123
- frozenColsStart: {
1124
- size: 48,
1125
- readonly: true,
1126
- focusUnfurl: false
1127
- },
1128
- grid: {
1129
- size: defaultColSize,
1130
- resizeable: true
1131
- }
1132
- };
1133
- var sheetRowDefault = {
1134
- frozenRowsStart: {
1135
- size: defaultRowSize,
1136
- readonly: true,
1137
- focusUnfurl: false
1138
- },
1139
- grid: {
1140
- size: defaultRowSize,
1141
- resizeable: true
1142
- }
1143
- };
1144
- var GridSheet = () => {
1145
- const { t } = useTranslation2(meta.id);
1146
- const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } = useSheetContext();
1147
- const [dxGrid, setDxGrid] = useState4(null);
1148
- const [extraplanarFocus, setExtraplanarFocus] = useState4(null);
1149
- const { invokePromise } = useOperationInvoker2();
1150
- const rangeController = useRef(null);
1151
- const { hasAttention } = useAttention(id);
1152
- const handleFocus = useCallback4((event) => {
1153
- if (!editing) {
1154
- const cell = closestCell(event.target);
1155
- if (cell) {
1156
- if (cell.plane === "grid") {
1157
- setCursor({
1158
- col: cell.col,
1159
- row: cell.row
1160
- });
1161
- setExtraplanarFocus(null);
1162
- } else {
1163
- setExtraplanarFocus(cell);
1164
- }
1165
- } else {
1166
- setExtraplanarFocus(null);
1167
- }
1168
- }
1169
- }, [
1170
- editing
1171
- ]);
1172
- const handleClose = useCallback4((_value, event) => {
1173
- if (event) {
1174
- const { key, shift } = event;
1175
- const axis = [
1176
- "Enter",
1177
- "ArrowUp",
1178
- "ArrowDown"
1179
- ].includes(key) ? "row" : [
1180
- "Tab",
1181
- "ArrowLeft",
1182
- "ArrowRight"
1183
- ].includes(key) ? "col" : void 0;
1184
- const delta = key.startsWith("Arrow") ? [
1185
- "ArrowUp",
1186
- "ArrowLeft"
1187
- ].includes(key) ? -1 : 1 : shift ? -1 : 1;
1188
- dxGrid?.refocus(axis, delta);
1189
- }
1190
- }, [
1191
- model,
1192
- editing,
1193
- dxGrid
1194
- ]);
1195
- const handleBlur = useCallback4((value) => {
1196
- if (value !== void 0) {
1197
- model.setValue(parseCellIndex(editing.index), value);
1198
- }
1199
- }, [
1200
- model,
1201
- editing
1202
- ]);
1203
- const handleAxisResize = useCallback4(({ axis, size, index: numericIndex }) => {
1204
- if (axis === "row") {
1205
- const rowId = model.sheet.rows[parseInt(numericIndex)];
1206
- model.sheet.rowMeta[rowId] ??= {};
1207
- model.sheet.rowMeta[rowId].size = size;
1208
- } else {
1209
- const columnId = model.sheet.columns[parseInt(numericIndex)];
1210
- model.sheet.columnMeta[columnId] ??= {};
1211
- model.sheet.columnMeta[columnId].size = size;
1212
- }
1213
- }, [
1214
- model
1215
- ]);
1216
- const handleSelect = useCallback4(({ minCol, maxCol, minRow, maxRow }) => {
1217
- const range = {
1218
- from: {
1219
- col: minCol,
1220
- row: minRow
1221
- }
1222
- };
1223
- if (minCol !== maxCol || minRow !== maxRow) {
1224
- range.to = {
1225
- col: maxCol,
1226
- row: maxRow
1227
- };
1228
- }
1229
- if (editing) {
1230
- rangeController.current?.setRange(rangeToA1Notation2(range));
1231
- } else {
1232
- setRange(range.to ? range : void 0);
1233
- }
1234
- }, [
1235
- editing
1236
- ]);
1237
- const handleWheel = useCallback4((event) => {
1238
- if (!ignoreAttention && !hasAttention) {
1239
- event.stopPropagation();
1240
- }
1241
- }, [
1242
- hasAttention,
1243
- ignoreAttention
1244
- ]);
1245
- const selectEntireAxis = useCallback4((pos) => {
1246
- switch (pos.plane) {
1247
- case "frozenRowsStart":
1248
- return dxGrid?.setSelection({
1249
- start: {
1250
- col: pos.col,
1251
- row: 0,
1252
- plane: "grid"
1253
- },
1254
- end: {
1255
- col: pos.col,
1256
- row: model.sheet.rows.length - 1,
1257
- plane: "grid"
1258
- }
1259
- });
1260
- case "frozenColsStart":
1261
- return dxGrid?.setSelection({
1262
- start: {
1263
- row: pos.row,
1264
- col: 0,
1265
- plane: "grid"
1266
- },
1267
- end: {
1268
- row: pos.row,
1269
- col: model.sheet.columns.length - 1,
1270
- plane: "grid"
1271
- }
1272
- });
1273
- }
1274
- }, [
1275
- dxGrid,
1276
- model.sheet
1277
- ]);
1278
- const handleClick = useCallback4((event) => {
1279
- const cell = closestCell(event.target);
1280
- if (cell) {
1281
- selectEntireAxis(cell);
1282
- }
1283
- }, [
1284
- selectEntireAxis
1285
- ]);
1286
- const handleKeyDown = useCallback4((event) => {
1287
- switch (event.key) {
1288
- case "Backspace":
1289
- case "Delete":
1290
- event.preventDefault();
1291
- return cursorFallbackRange && model.clear(cursorFallbackRange);
1292
- case "Enter":
1293
- case "Space":
1294
- if (dxGrid && extraplanarFocus) {
1295
- switch (extraplanarFocus.plane) {
1296
- case "frozenRowsStart":
1297
- case "frozenColsStart":
1298
- event.preventDefault();
1299
- return selectEntireAxis(extraplanarFocus);
1300
- }
1301
- }
1302
- }
1303
- if (event.metaKey || event.ctrlKey) {
1304
- switch (event.key) {
1305
- case "x":
1306
- case "X":
1307
- event.preventDefault();
1308
- return cursorFallbackRange && model.cut(cursorFallbackRange);
1309
- case "c":
1310
- case "C":
1311
- event.preventDefault();
1312
- return cursorFallbackRange && model.copy(cursorFallbackRange);
1313
- case "v":
1314
- case "V":
1315
- event.preventDefault();
1316
- return cursor && model.paste(cursor);
1317
- case "z":
1318
- event.preventDefault();
1319
- return event.shiftKey ? model.redo() : model.undo();
1320
- case "Z":
1321
- case "y":
1322
- event.preventDefault();
1323
- return model.redo();
1324
- }
1325
- }
1326
- }, [
1327
- cursorFallbackRange,
1328
- model,
1329
- cursor,
1330
- extraplanarFocus,
1331
- selectEntireAxis
1332
- ]);
1333
- const contextMenuAnchorRef = useRef(null);
1334
- const [contextMenuOpen, setContextMenuOpen] = useState4(null);
1335
- const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
1336
- const handleContextMenu = useCallback4((event) => {
1337
- const cell = closestCell(event.target);
1338
- if (cell && cell.plane.startsWith("frozen")) {
1339
- event.preventDefault();
1340
- contextMenuAnchorRef.current = event.target;
1341
- setContextMenuOpen(cell);
1342
- }
1343
- }, []);
1344
- const handleAxisMenuAction = useCallback4((operation) => {
1345
- switch (operation) {
1346
- case "insert-before":
1347
- case "insert-after":
1348
- return invokePromise(SheetOperation.InsertAxis, {
1349
- model,
1350
- axis: contextMenuAxis,
1351
- index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
1352
- });
1353
- case "drop":
1354
- return invokePromise(SheetOperation.DropAxis, {
1355
- model,
1356
- axis: contextMenuAxis,
1357
- axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
1358
- });
1359
- }
1360
- }, [
1361
- contextMenuAxis,
1362
- contextMenuOpen,
1363
- model,
1364
- invokePromise
1365
- ]);
1366
- const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
1367
- const extensions = useMemo2(() => [
1368
- editorKeys({
1369
- onClose: handleClose,
1370
- ...editing?.initialContent && {
1371
- onNav: handleClose
1372
- }
1373
- }),
1374
- sheetExtension({
1375
- functions: model.graph.getFunctions()
1376
- }),
1377
- rangeExtension({
1378
- onInit: (fn) => rangeController.current = fn,
1379
- onStateChange: (state) => {
1380
- if (dxGrid) {
1381
- dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
1382
- }
1383
- }
1384
- })
1385
- ], [
1386
- model,
1387
- handleClose,
1388
- editing
1389
- ]);
1390
- const getCellContent = useCallback4((index) => {
1391
- return model.getCellText(parseCellIndex(index));
1392
- }, [
1393
- model
1394
- ]);
1395
- useUpdateFocusedCellOnThreadSelection(dxGrid);
1396
- useSelectThreadOnCellFocus();
1397
- return (
1398
- // TODO(thure): Why are Table’s and Sheet’s editor boxes off by 1px?
1399
- /* @__PURE__ */ React4.createElement("div", {
1400
- role: "none",
1401
- className: "relative min-bs-0 [&_.cm-editor]:!border-lb [&_.cm-editor]:!border-transparent"
1402
- }, /* @__PURE__ */ React4.createElement(GridCellEditor, {
1403
- getCellContent,
1404
- extensions,
1405
- onBlur: handleBlur
1406
- }), /* @__PURE__ */ React4.createElement(Grid2.Content, {
1407
- initialCells,
1408
- limitColumns: DEFAULT_COLS,
1409
- limitRows: DEFAULT_ROWS,
1410
- columns,
1411
- rows,
1412
- // TODO(burdon): `col` vs. `column`?
1413
- columnDefault: sheetColDefault,
1414
- rowDefault: sheetRowDefault,
1415
- frozen,
1416
- onAxisResize: handleAxisResize,
1417
- onSelect: handleSelect,
1418
- onFocus: handleFocus,
1419
- onWheelCapture: handleWheel,
1420
- onKeyDown: handleKeyDown,
1421
- onContextMenu: handleContextMenu,
1422
- onClick: handleClick,
1423
- overscroll: "trap",
1424
- className: "[--dx-grid-base:var(--baseSurface)] [&_.dx-grid]:absolute [&_.dx-grid]:inset-0",
1425
- activeRefs,
1426
- ref: setDxGrid
1427
- }), /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
1428
- modal: false,
1429
- open: !!contextMenuOpen,
1430
- onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
1431
- }, /* @__PURE__ */ React4.createElement(DropdownMenu.VirtualTrigger, {
1432
- virtualRef: contextMenuAnchorRef
1433
- }), /* @__PURE__ */ React4.createElement(DropdownMenu.Content, {
1434
- side: contextMenuAxis === "col" ? "bottom" : "right",
1435
- sideOffset: 4,
1436
- collisionPadding: 8
1437
- }, /* @__PURE__ */ React4.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
1438
- onClick: () => handleAxisMenuAction("insert-before"),
1439
- "data-testid": `grid.${contextMenuAxis}.insert-before`
1440
- }, /* @__PURE__ */ React4.createElement(Icon, {
1441
- size: 5,
1442
- icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
1443
- }), /* @__PURE__ */ React4.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
1444
- onClick: () => handleAxisMenuAction("insert-after"),
1445
- "data-testid": `grid.${contextMenuAxis}.insert-after`
1446
- }, /* @__PURE__ */ React4.createElement(Icon, {
1447
- size: 5,
1448
- icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
1449
- }), /* @__PURE__ */ React4.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
1450
- onClick: () => handleAxisMenuAction("drop"),
1451
- "data-testid": `grid.${contextMenuAxis}.drop`
1452
- }, /* @__PURE__ */ React4.createElement(Icon, {
1453
- size: 5,
1454
- icon: "ph--backspace--regular"
1455
- }), /* @__PURE__ */ React4.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))))
1456
- );
1457
- };
1458
-
1459
- // src/components/index.ts
1460
- var SheetContainer = lazy(() => import("./SheetContainer-YVIDJKP4.mjs"));
1461
-
1462
- export {
1463
- ComputeGraphContextProvider,
1464
- useComputeGraph,
1465
- useSheetContext,
1466
- SheetProvider,
1467
- GridSheet,
1468
- RangeList,
1469
- SheetContainer
1470
- };
1471
- //# sourceMappingURL=chunk-S7RYX7DG.mjs.map