@dxos/plugin-sheet 0.7.4 → 0.7.5-labs.071a3e2

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 (313) hide show
  1. package/dist/lib/browser/SheetContainer-IMHGS7Z4.mjs +370 -0
  2. package/dist/lib/browser/SheetContainer-IMHGS7Z4.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-AT7F2WDW.mjs +808 -0
  4. package/dist/lib/browser/chunk-AT7F2WDW.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-FOO6NGBM.mjs +229 -0
  6. package/dist/lib/browser/chunk-FOO6NGBM.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-GAFHJBCU.mjs +18 -0
  8. package/dist/lib/browser/chunk-GAFHJBCU.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-LXHRT3CC.mjs +15 -0
  10. package/dist/lib/browser/chunk-LXHRT3CC.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-OOSRC36N.mjs +900 -0
  12. package/dist/lib/browser/chunk-OOSRC36N.mjs.map +7 -0
  13. package/dist/lib/browser/compute-graph-registry-EGPD4HEX.mjs +27 -0
  14. package/dist/lib/browser/compute-graph-registry-EGPD4HEX.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +80 -324
  16. package/dist/lib/browser/index.mjs.map +4 -4
  17. package/dist/lib/browser/intent-resolver-6S2RMLQF.mjs +56 -0
  18. package/dist/lib/browser/intent-resolver-6S2RMLQF.mjs.map +7 -0
  19. package/dist/lib/browser/markdown-CFJIWHZX.mjs +26 -0
  20. package/dist/lib/browser/markdown-CFJIWHZX.mjs.map +7 -0
  21. package/dist/lib/browser/meta.json +1 -1
  22. package/dist/lib/browser/react-surface-PHKJZYFB.mjs +52 -0
  23. package/dist/lib/browser/react-surface-PHKJZYFB.mjs.map +7 -0
  24. package/dist/lib/browser/thread-7ZWW5EA7.mjs +17 -0
  25. package/dist/lib/browser/thread-7ZWW5EA7.mjs.map +7 -0
  26. package/dist/lib/browser/types/index.mjs +62 -0
  27. package/dist/lib/node/SheetContainer-NNIZN4AK.cjs +364 -0
  28. package/dist/lib/node/SheetContainer-NNIZN4AK.cjs.map +7 -0
  29. package/dist/lib/node/chunk-2KCZUH72.cjs +815 -0
  30. package/dist/lib/node/chunk-2KCZUH72.cjs.map +7 -0
  31. package/dist/lib/node/chunk-4LSYTNS4.cjs +935 -0
  32. package/dist/lib/node/chunk-4LSYTNS4.cjs.map +7 -0
  33. package/dist/lib/node/{chunk-2ZVZI2KJ.cjs → chunk-MLU6KRQN.cjs} +12 -9
  34. package/dist/lib/node/chunk-MLU6KRQN.cjs.map +7 -0
  35. package/dist/lib/node/chunk-P4KSGZSS.cjs +251 -0
  36. package/dist/lib/node/chunk-P4KSGZSS.cjs.map +7 -0
  37. package/dist/lib/node/{types.cjs → chunk-ZV2RS3QH.cjs} +12 -16
  38. package/dist/lib/node/chunk-ZV2RS3QH.cjs.map +7 -0
  39. package/dist/lib/node/compute-graph-registry-GJK5H264.cjs +53 -0
  40. package/dist/lib/node/compute-graph-registry-GJK5H264.cjs.map +7 -0
  41. package/dist/lib/node/index.cjs +81 -318
  42. package/dist/lib/node/index.cjs.map +4 -4
  43. package/dist/lib/node/intent-resolver-I25V7SBT.cjs +69 -0
  44. package/dist/lib/node/intent-resolver-I25V7SBT.cjs.map +7 -0
  45. package/dist/lib/node/markdown-YTCSW66K.cjs +40 -0
  46. package/dist/lib/node/markdown-YTCSW66K.cjs.map +7 -0
  47. package/dist/lib/node/meta.json +1 -1
  48. package/dist/lib/node/react-surface-HLE6CRA6.cjs +70 -0
  49. package/dist/lib/node/react-surface-HLE6CRA6.cjs.map +7 -0
  50. package/dist/lib/node/{meta.cjs → thread-DRNYTR6M.cjs} +12 -10
  51. package/dist/lib/node/thread-DRNYTR6M.cjs.map +7 -0
  52. package/dist/lib/node/types/index.cjs +84 -0
  53. package/dist/lib/node/types/index.cjs.map +7 -0
  54. package/dist/lib/node-esm/SheetContainer-PGDJKGTZ.mjs +371 -0
  55. package/dist/lib/node-esm/SheetContainer-PGDJKGTZ.mjs.map +7 -0
  56. package/dist/lib/node-esm/chunk-HPAMZ6SP.mjs +901 -0
  57. package/dist/lib/node-esm/chunk-HPAMZ6SP.mjs.map +7 -0
  58. package/dist/lib/node-esm/chunk-PTOI45NK.mjs +231 -0
  59. package/dist/lib/node-esm/chunk-PTOI45NK.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-RTZXXOS2.mjs +20 -0
  61. package/dist/lib/node-esm/chunk-RTZXXOS2.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-SX3S7UKU.mjs +16 -0
  63. package/dist/lib/node-esm/chunk-SX3S7UKU.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-ZM7XLUGL.mjs +809 -0
  65. package/dist/lib/node-esm/chunk-ZM7XLUGL.mjs.map +7 -0
  66. package/dist/lib/node-esm/compute-graph-registry-3F5JCYEN.mjs +28 -0
  67. package/dist/lib/node-esm/compute-graph-registry-3F5JCYEN.mjs.map +7 -0
  68. package/dist/lib/node-esm/index.mjs +80 -324
  69. package/dist/lib/node-esm/index.mjs.map +4 -4
  70. package/dist/lib/node-esm/intent-resolver-IPRSINII.mjs +57 -0
  71. package/dist/lib/node-esm/intent-resolver-IPRSINII.mjs.map +7 -0
  72. package/dist/lib/node-esm/markdown-CGSK44XJ.mjs +27 -0
  73. package/dist/lib/node-esm/markdown-CGSK44XJ.mjs.map +7 -0
  74. package/dist/lib/node-esm/meta.json +1 -1
  75. package/dist/lib/node-esm/react-surface-PFRJ7V5N.mjs +53 -0
  76. package/dist/lib/node-esm/react-surface-PFRJ7V5N.mjs.map +7 -0
  77. package/dist/lib/node-esm/thread-6T5VXPAF.mjs +18 -0
  78. package/dist/lib/node-esm/thread-6T5VXPAF.mjs.map +7 -0
  79. package/dist/lib/node-esm/types/index.mjs +63 -0
  80. package/dist/types/src/SheetPlugin.d.ts +1 -3
  81. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  82. package/dist/types/src/capabilities/capabilities.d.ts +5 -0
  83. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  84. package/dist/types/src/capabilities/compute-graph-registry.d.ts +4 -0
  85. package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
  86. package/dist/types/src/capabilities/index.d.ts +12 -0
  87. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  88. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  89. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  90. package/dist/types/src/capabilities/markdown.d.ts +6 -0
  91. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  92. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  93. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  94. package/dist/types/src/capabilities/thread.d.ts +6 -0
  95. package/dist/types/src/capabilities/thread.d.ts.map +1 -0
  96. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
  97. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  98. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
  99. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
  100. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  101. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  102. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  103. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  104. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  105. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  106. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  107. package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
  108. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  109. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +7 -0
  110. package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -0
  111. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +6 -0
  112. package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -0
  113. package/dist/types/src/components/SheetToolbar/align.d.ts +28 -0
  114. package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -0
  115. package/dist/types/src/components/SheetToolbar/comment.d.ts +23 -0
  116. package/dist/types/src/components/SheetToolbar/comment.d.ts.map +1 -0
  117. package/dist/types/src/components/SheetToolbar/index.d.ts +2 -0
  118. package/dist/types/src/components/SheetToolbar/index.d.ts.map +1 -0
  119. package/dist/types/src/components/SheetToolbar/style.d.ts +26 -0
  120. package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -0
  121. package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts +8 -0
  122. package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts.map +1 -0
  123. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +6 -0
  124. package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -0
  125. package/dist/types/src/components/index.d.ts +0 -1
  126. package/dist/types/src/components/index.d.ts.map +1 -1
  127. package/dist/types/src/extensions/compute.d.ts +1 -1
  128. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  129. package/dist/types/src/extensions/editor/extension.d.ts +1 -1
  130. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
  131. package/dist/types/src/index.d.ts +2 -3
  132. package/dist/types/src/index.d.ts.map +1 -1
  133. package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
  134. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  135. package/dist/types/src/meta.d.ts +2 -2
  136. package/dist/types/src/meta.d.ts.map +1 -1
  137. package/dist/types/src/model/sheet-model.d.ts +6 -8
  138. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  139. package/dist/types/src/model/testing.d.ts +1 -1
  140. package/dist/types/src/model/testing.d.ts.map +1 -1
  141. package/dist/types/src/model/useSheetModel.d.ts +1 -1
  142. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  143. package/dist/types/src/testing/testing.d.ts +1 -1
  144. package/dist/types/src/testing/testing.d.ts.map +1 -1
  145. package/dist/types/src/{defs → types}/index.d.ts +1 -0
  146. package/dist/types/src/types/index.d.ts.map +1 -0
  147. package/dist/types/src/types/schema.d.ts +105 -0
  148. package/dist/types/src/types/schema.d.ts.map +1 -0
  149. package/dist/types/src/{defs → types}/sheet-range-types.d.ts +1 -1
  150. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
  151. package/dist/types/src/types/types.d.ts +71 -0
  152. package/dist/types/src/types/types.d.ts.map +1 -0
  153. package/dist/types/src/{defs → types}/util.d.ts +5 -1
  154. package/dist/types/src/types/util.d.ts.map +1 -0
  155. package/dist/types/tsconfig.tsbuildinfo +1 -0
  156. package/package.json +48 -62
  157. package/src/SheetPlugin.tsx +57 -176
  158. package/src/capabilities/capabilities.ts +14 -0
  159. package/src/capabilities/compute-graph-registry.ts +25 -0
  160. package/src/capabilities/index.ts +13 -0
  161. package/src/capabilities/intent-resolver.ts +38 -0
  162. package/src/capabilities/markdown.ts +22 -0
  163. package/src/capabilities/react-surface.tsx +37 -0
  164. package/src/capabilities/thread.ts +14 -0
  165. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
  166. package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
  167. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
  168. package/src/components/GridSheet/GridSheet.stories.tsx +2 -0
  169. package/src/components/GridSheet/GridSheet.tsx +15 -18
  170. package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
  171. package/src/components/GridSheet/util.ts +4 -3
  172. package/src/components/RangeList/RangeList.tsx +2 -1
  173. package/src/components/SheetContainer/SheetContainer.stories.tsx +28 -23
  174. package/src/components/SheetContainer/SheetContainer.tsx +3 -8
  175. package/src/components/SheetContext/SheetContext.tsx +1 -2
  176. package/src/components/{Toolbar/Toolbar.stories.tsx → SheetToolbar/SheetToolbar.stories.tsx} +4 -8
  177. package/src/components/SheetToolbar/SheetToolbar.tsx +48 -0
  178. package/src/components/SheetToolbar/align.ts +68 -0
  179. package/src/components/SheetToolbar/comment.ts +56 -0
  180. package/src/components/{Toolbar → SheetToolbar}/index.ts +1 -1
  181. package/src/components/SheetToolbar/style.ts +72 -0
  182. package/src/components/SheetToolbar/useToolbarAction.ts +87 -0
  183. package/src/components/SheetToolbar/useToolbarState.ts +17 -0
  184. package/src/components/index.ts +0 -1
  185. package/src/extensions/compute.ts +7 -4
  186. package/src/extensions/editor/extension.test.ts +2 -1
  187. package/src/extensions/editor/extension.ts +2 -3
  188. package/src/index.ts +2 -7
  189. package/src/integrations/thread-ranges.ts +39 -24
  190. package/src/meta.ts +4 -2
  191. package/src/model/sheet-model.test.ts +4 -10
  192. package/src/model/sheet-model.ts +30 -22
  193. package/src/model/testing.ts +3 -2
  194. package/src/model/useSheetModel.ts +2 -1
  195. package/src/sanity.test.ts +1 -1
  196. package/src/testing/testing.tsx +2 -3
  197. package/src/{defs → types}/index.ts +1 -0
  198. package/src/types/schema.ts +56 -0
  199. package/src/{defs → types}/sheet-range-types.ts +1 -1
  200. package/src/types/types.ts +67 -0
  201. package/src/{defs → types}/util.ts +13 -13
  202. package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs +0 -296
  203. package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
  204. package/dist/lib/browser/chunk-E5WQ7U7G.mjs +0 -1675
  205. package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
  206. package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
  207. package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
  208. package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
  209. package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
  210. package/dist/lib/browser/chunk-RABELMEQ.mjs +0 -15
  211. package/dist/lib/browser/chunk-RABELMEQ.mjs.map +0 -7
  212. package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
  213. package/dist/lib/browser/meta.mjs +0 -9
  214. package/dist/lib/browser/types.mjs +0 -16
  215. package/dist/lib/browser/types.mjs.map +0 -7
  216. package/dist/lib/node/SheetContainer-VVVRYTQG.cjs +0 -298
  217. package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
  218. package/dist/lib/node/chunk-2ZVZI2KJ.cjs.map +0 -7
  219. package/dist/lib/node/chunk-45YW2DX2.cjs +0 -1656
  220. package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
  221. package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
  222. package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
  223. package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
  224. package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
  225. package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
  226. package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
  227. package/dist/lib/node/meta.cjs.map +0 -7
  228. package/dist/lib/node/types.cjs.map +0 -7
  229. package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs +0 -297
  230. package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
  231. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
  232. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
  233. package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs +0 -17
  234. package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs.map +0 -7
  235. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
  236. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
  237. package/dist/lib/node-esm/chunk-NYDNXI7L.mjs +0 -1676
  238. package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
  239. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
  240. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
  241. package/dist/lib/node-esm/meta.mjs +0 -10
  242. package/dist/lib/node-esm/meta.mjs.map +0 -7
  243. package/dist/lib/node-esm/types.mjs +0 -17
  244. package/dist/lib/node-esm/types.mjs.map +0 -7
  245. package/dist/types/src/components/SheetObjectSettings.d.ts +0 -7
  246. package/dist/types/src/components/SheetObjectSettings.d.ts.map +0 -1
  247. package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -48
  248. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
  249. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +0 -7
  250. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
  251. package/dist/types/src/components/Toolbar/index.d.ts +0 -2
  252. package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
  253. package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
  254. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
  255. package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
  256. package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
  257. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
  258. package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
  259. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
  260. package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
  261. package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
  262. package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
  263. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
  264. package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
  265. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
  266. package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
  267. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
  268. package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
  269. package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
  270. package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
  271. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
  272. package/dist/types/src/compute-graph/index.d.ts +0 -5
  273. package/dist/types/src/compute-graph/index.d.ts.map +0 -1
  274. package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
  275. package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
  276. package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
  277. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
  278. package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
  279. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
  280. package/dist/types/src/compute-graph/util.d.ts +0 -2
  281. package/dist/types/src/compute-graph/util.d.ts.map +0 -1
  282. package/dist/types/src/defs/index.d.ts.map +0 -1
  283. package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
  284. package/dist/types/src/defs/types.d.ts +0 -26
  285. package/dist/types/src/defs/types.d.ts.map +0 -1
  286. package/dist/types/src/defs/types.test.d.ts +0 -2
  287. package/dist/types/src/defs/types.test.d.ts.map +0 -1
  288. package/dist/types/src/defs/util.d.ts.map +0 -1
  289. package/dist/types/src/types.d.ts +0 -182
  290. package/dist/types/src/types.d.ts.map +0 -1
  291. package/dist/vendor/hyperformula.mjs +0 -37145
  292. package/src/components/SheetObjectSettings.tsx +0 -38
  293. package/src/components/Toolbar/Toolbar.tsx +0 -346
  294. package/src/compute-graph/compute-graph-registry.ts +0 -90
  295. package/src/compute-graph/compute-graph.test.ts +0 -87
  296. package/src/compute-graph/compute-graph.ts +0 -260
  297. package/src/compute-graph/compute-node.ts +0 -62
  298. package/src/compute-graph/functions/async-function.ts +0 -179
  299. package/src/compute-graph/functions/edge-function.ts +0 -102
  300. package/src/compute-graph/functions/function-defs.ts +0 -2427
  301. package/src/compute-graph/functions/index.ts +0 -7
  302. package/src/compute-graph/hyperformula.test.ts +0 -14
  303. package/src/compute-graph/index.ts +0 -8
  304. package/src/compute-graph/testing/index.ts +0 -6
  305. package/src/compute-graph/testing/test-builder.ts +0 -54
  306. package/src/compute-graph/testing/test-plugin.ts +0 -100
  307. package/src/compute-graph/util.ts +0 -8
  308. package/src/defs/types.test.ts +0 -91
  309. package/src/defs/types.ts +0 -88
  310. package/src/types.ts +0 -125
  311. /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
  312. /package/dist/lib/{browser/meta.mjs.map → node-esm/types/index.mjs.map} +0 -0
  313. /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
@@ -1,1656 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_45YW2DX2_exports = {};
30
- __export(chunk_45YW2DX2_exports, {
31
- ComputeGraphContextProvider: () => ComputeGraphContextProvider,
32
- GridSheet: () => GridSheet,
33
- SheetContainer: () => SheetContainer,
34
- SheetObjectSettings: () => SheetObjectSettings,
35
- SheetProvider: () => SheetProvider,
36
- completeCellRangeToThreadCursor: () => completeCellRangeToThreadCursor,
37
- computeGraphFacet: () => computeGraphFacet,
38
- useComputeGraph: () => useComputeGraph,
39
- useSheetContext: () => useSheetContext
40
- });
41
- module.exports = __toCommonJS(chunk_45YW2DX2_exports);
42
- var import_chunk_KSEEI5VC = require("./chunk-KSEEI5VC.cjs");
43
- var import_chunk_OWH2EUHZ = require("./chunk-OWH2EUHZ.cjs");
44
- var import_chunk_2ZVZI2KJ = require("./chunk-2ZVZI2KJ.cjs");
45
- var import_react = __toESM(require("react"));
46
- var import_debug = require("@dxos/debug");
47
- var import_react_hooks = require("@dxos/react-hooks");
48
- var import_language = require("@codemirror/language");
49
- var import_state = require("@codemirror/state");
50
- var import_view = require("@codemirror/view");
51
- var import_async = require("@dxos/async");
52
- var import_invariant = require("@dxos/invariant");
53
- var import_react_ui_editor = require("@dxos/react-ui-editor");
54
- var import_autocomplete = require("@codemirror/autocomplete");
55
- var import_language2 = require("@codemirror/language");
56
- var import_view2 = require("@codemirror/view");
57
- var import_highlight = require("@lezer/highlight");
58
- var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
59
- var import_react_ui_editor2 = require("@dxos/react-ui-editor");
60
- var import_react_ui_theme = require("@dxos/react-ui-theme");
61
- var import_react2 = __toESM(require("react"));
62
- var import_invariant2 = require("@dxos/invariant");
63
- var import_echo = require("@dxos/react-client/echo");
64
- var import_react_ui_grid = require("@dxos/react-ui-grid");
65
- var import_async2 = require("@dxos/async");
66
- var import_context = require("@dxos/context");
67
- var import_echo_schema = require("@dxos/echo-schema");
68
- var import_invariant3 = require("@dxos/invariant");
69
- var import_keys = require("@dxos/keys");
70
- var import_log = require("@dxos/log");
71
- var import_hyperformula = require("#hyperformula");
72
- var import_react3 = require("react");
73
- var import_react4 = __toESM(require("react"));
74
- var import_app_framework = require("@dxos/app-framework");
75
- var import_react_ui = require("@dxos/react-ui");
76
- var import_react_ui_attention = require("@dxos/react-ui-attention");
77
- var import_react_ui_grid2 = require("@dxos/react-ui-grid");
78
- var import_react5 = require("react");
79
- var import_echo2 = require("@dxos/react-client/echo");
80
- var import_react_ui_form = require("@dxos/react-ui-form");
81
- var import_react_ui_grid3 = require("@dxos/react-ui-grid");
82
- var import_react_ui_theme2 = require("@dxos/react-ui-theme");
83
- var import_react6 = require("react");
84
- var import_app_framework2 = require("@dxos/app-framework");
85
- var import_async3 = require("@dxos/async");
86
- var import_echo3 = require("@dxos/react-client/echo");
87
- var import_react7 = require("react");
88
- var import_react8 = __toESM(require("react"));
89
- var import_echo_schema2 = require("@dxos/echo-schema");
90
- var import_react_ui2 = require("@dxos/react-ui");
91
- var import_react_ui_list = require("@dxos/react-ui-list");
92
- var import_react_ui_theme3 = require("@dxos/react-ui-theme");
93
- var import_react9 = __toESM(require("react"));
94
- var import_meta = require("@dxos/plugin-space/meta");
95
- var import_react_ui3 = require("@dxos/react-ui");
96
- var ComputeGraphContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
97
- var ComputeGraphContextProvider = ({ registry, children }) => {
98
- return /* @__PURE__ */ import_react.default.createElement(ComputeGraphContext.Provider, {
99
- value: {
100
- registry
101
- }
102
- }, children);
103
- };
104
- var useComputeGraph = (space) => {
105
- const { registry } = (0, import_react.useContext)(ComputeGraphContext) ?? (0, import_debug.raise)(new Error("Missing ComputeGraphContext"));
106
- const [graph] = (0, import_react_hooks.useAsyncState)(async () => {
107
- if (space) {
108
- const graph2 = registry.getOrCreateGraph(space);
109
- await graph2.open();
110
- return graph2;
111
- }
112
- }, [
113
- space,
114
- registry
115
- ]);
116
- return graph;
117
- };
118
- var updateAllDecorations = import_state.StateEffect.define();
119
- var computeGraphFacet = (0, import_react_ui_editor.singleValueFacet)();
120
- var highlightStyles = import_language2.HighlightStyle.define([
121
- // Function.
122
- {
123
- tag: import_highlight.tags.name,
124
- class: "text-accentText"
125
- },
126
- // Range.
127
- {
128
- tag: import_highlight.tags.tagName,
129
- class: "text-pinkText"
130
- },
131
- // Values.
132
- {
133
- tag: import_highlight.tags.number,
134
- class: "text-tealText"
135
- },
136
- {
137
- tag: import_highlight.tags.bool,
138
- class: "text-tealText"
139
- },
140
- {
141
- tag: import_highlight.tags.string,
142
- class: "text-tealText"
143
- },
144
- // Error.
145
- {
146
- tag: import_highlight.tags.invalid,
147
- class: "text-unAccent"
148
- }
149
- ]);
150
- var languageFacet = (0, import_react_ui_editor2.singleValueFacet)();
151
- var sheetExtension = ({ debug, functions = [] }) => {
152
- const { extension, language } = (0, import_codemirror_lang_spreadsheet.spreadsheet)({
153
- idiom: "en-US",
154
- decimalSeparator: "."
155
- });
156
- const createCompletion = (name) => {
157
- const { section = "Custom", description, syntax } = functions.find((value) => value.name === name) ?? {};
158
- return {
159
- section,
160
- label: name,
161
- info: () => {
162
- if (!description && !syntax) {
163
- return null;
164
- }
165
- const root = document.createElement("div");
166
- root.className = "flex flex-col gap-2 text-sm";
167
- const title = document.createElement("h2");
168
- title.innerText = name;
169
- title.className = "text-lg font-mono text-accentText";
170
- root.appendChild(title);
171
- if (description) {
172
- const info = document.createElement("p");
173
- info.innerText = description;
174
- info.className = "text-subdued";
175
- root.appendChild(info);
176
- }
177
- if (syntax) {
178
- const detail = document.createElement("pre");
179
- detail.innerText = syntax;
180
- detail.className = "whitespace-pre-wrap text-greenText";
181
- root.appendChild(detail);
182
- }
183
- return root;
184
- },
185
- apply: (view, completion, from, to) => {
186
- const insertParens = to === view.state.doc.toString().length;
187
- view.dispatch(view.state.update({
188
- changes: {
189
- from,
190
- to,
191
- insert: completion.label + (insertParens ? "()" : "")
192
- },
193
- selection: {
194
- anchor: from + completion.label.length + 1
195
- }
196
- }));
197
- }
198
- };
199
- };
200
- return [
201
- extension,
202
- languageFacet.of(language),
203
- language.data.of({
204
- autocomplete: (context) => {
205
- if (context.state.doc.toString()[0] !== "=") {
206
- return null;
207
- }
208
- const match = context.matchBefore(/\w*/);
209
- if (!match || match.from === match.to) {
210
- return null;
211
- }
212
- const text = match.text.toUpperCase();
213
- if (!context.explicit && match.text.length < 2) {
214
- return null;
215
- }
216
- return {
217
- from: match.from,
218
- options: functions?.filter(({ name }) => name.startsWith(text)).map(({ name }) => createCompletion(name)) ?? []
219
- };
220
- }
221
- }),
222
- (0, import_language2.syntaxHighlighting)(highlightStyles),
223
- (0, import_autocomplete.autocompletion)({
224
- aboveCursor: false,
225
- defaultKeymap: true,
226
- activateOnTyping: true,
227
- closeOnBlur: !debug,
228
- icons: false,
229
- tooltipClass: () => (0, import_react_ui_theme.mx)("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
230
- }),
231
- import_view2.keymap.of([
232
- {
233
- key: "Tab",
234
- run: (view) => {
235
- return (0, import_autocomplete.completionStatus)(view.state) === "active" ? (0, import_autocomplete.acceptCompletion)(view) : (0, import_autocomplete.startCompletion)(view);
236
- }
237
- }
238
- ])
239
- ];
240
- };
241
- var rangeExtension = ({ onInit, onStateChange }) => {
242
- let view;
243
- let activeRange;
244
- const notifier = {
245
- setRange: (range) => {
246
- if (activeRange) {
247
- view.dispatch(view.state.update({
248
- changes: {
249
- ...activeRange,
250
- insert: range.toString()
251
- },
252
- selection: {
253
- anchor: activeRange.from + range.length
254
- }
255
- }));
256
- }
257
- view.focus();
258
- }
259
- };
260
- return import_view2.ViewPlugin.fromClass(class {
261
- constructor(_view) {
262
- view = _view;
263
- onInit?.(notifier);
264
- }
265
- update(view2) {
266
- const { anchor } = view2.state.selection.ranges[0];
267
- activeRange = void 0;
268
- const language = view2.state.facet(languageFacet);
269
- const { topNode } = language.parser.parse(view2.state.doc.toString());
270
- visitTree(topNode, ({ type, from, to }) => {
271
- if (from <= anchor && to >= anchor) {
272
- switch (type.name) {
273
- case "Function":
274
- activeRange = {
275
- from: to,
276
- to
277
- };
278
- break;
279
- case "CloseParen":
280
- activeRange = {
281
- from,
282
- to: from
283
- };
284
- break;
285
- case "RangeToken":
286
- case "CellToken":
287
- activeRange = {
288
- from,
289
- to
290
- };
291
- return true;
292
- }
293
- }
294
- return false;
295
- });
296
- if (!activeRange && view2.state.doc.toString()[0] === "=") {
297
- const str = view2.state.doc.sliceString(1);
298
- if (import_chunk_KSEEI5VC.RANGE_NOTATION.test(str)) {
299
- activeRange = {
300
- from: 1,
301
- to: str.length + 1
302
- };
303
- }
304
- }
305
- onStateChange?.({
306
- activeRange: activeRange ? view2.state.doc.sliceString(activeRange.from, activeRange.to) : void 0
307
- });
308
- }
309
- });
310
- };
311
- var visitTree = (node, callback) => {
312
- if (callback(node)) {
313
- return true;
314
- }
315
- for (let child = node.firstChild; child !== null; child = child.nextSibling) {
316
- if (visitTree(child, callback)) {
317
- return true;
318
- }
319
- }
320
- return false;
321
- };
322
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
323
- var typeMap = {
324
- BOOLEAN: {
325
- type: import_echo_schema.TypeEnum.Boolean
326
- },
327
- NUMBER_RAW: {
328
- type: import_echo_schema.TypeEnum.Number
329
- },
330
- NUMBER_PERCENT: {
331
- type: import_echo_schema.TypeEnum.Number,
332
- format: import_echo_schema.FormatEnum.Percent
333
- },
334
- NUMBER_CURRENCY: {
335
- type: import_echo_schema.TypeEnum.Number,
336
- format: import_echo_schema.FormatEnum.Currency
337
- },
338
- NUMBER_DATETIME: {
339
- type: import_echo_schema.TypeEnum.String,
340
- format: import_echo_schema.FormatEnum.DateTime
341
- },
342
- NUMBER_DATE: {
343
- type: import_echo_schema.TypeEnum.String,
344
- format: import_echo_schema.FormatEnum.Date
345
- },
346
- NUMBER_TIME: {
347
- type: import_echo_schema.TypeEnum.String,
348
- format: import_echo_schema.FormatEnum.Time
349
- }
350
- };
351
- var getTopLeft = (range) => {
352
- const to = range.to ?? range.from;
353
- return {
354
- row: Math.min(range.from.row, to.row),
355
- col: Math.min(range.from.col, to.col)
356
- };
357
- };
358
- var toSimpleCellAddress = (sheet, cell) => ({
359
- sheet,
360
- row: cell.row,
361
- col: cell.col
362
- });
363
- var toModelRange = (sheet, range) => ({
364
- start: toSimpleCellAddress(sheet, range.from),
365
- end: toSimpleCellAddress(sheet, range.to ?? range.from)
366
- });
367
- var SheetModel = class extends import_context.Resource {
368
- constructor(_graph, _sheet, _options = {}) {
369
- super();
370
- this._graph = _graph;
371
- this._sheet = _sheet;
372
- this._options = _options;
373
- this.id = `model-${import_keys.PublicKey.random().truncate()}`;
374
- this.update = new import_async2.Event();
375
- }
376
- get graph() {
377
- return this._graph;
378
- }
379
- get sheet() {
380
- return this._sheet;
381
- }
382
- get readonly() {
383
- return this._options.readonly;
384
- }
385
- get bounds() {
386
- return {
387
- rows: this._sheet.rows.length,
388
- columns: this._sheet.columns.length
389
- };
390
- }
391
- /**
392
- * Initialize sheet and engine.
393
- */
394
- async _open() {
395
- (0, import_log.log)("initialize", {
396
- id: this.id
397
- }, {
398
- F: __dxlog_file,
399
- L: 115,
400
- S: this,
401
- C: (f, a) => f(...a)
402
- });
403
- (0, import_chunk_KSEEI5VC.initialize)(this._sheet);
404
- this._graph.update.on((event) => {
405
- if (event.type === "functionsUpdated") {
406
- this.reset();
407
- }
408
- });
409
- this._node = this._graph.getOrCreateNode((0, import_chunk_KSEEI5VC.createSheetName)({
410
- type: (0, import_echo_schema.getTypename)(this._sheet),
411
- id: this._sheet.id
412
- }));
413
- await this._node.open();
414
- const unsubscribe = this._node.update.on((event) => this.update.emit(event));
415
- this._ctx.onDispose(unsubscribe);
416
- this.reset();
417
- }
418
- /**
419
- * Update engine.
420
- * NOTE: This resets the undo history.
421
- * @deprecated
422
- */
423
- reset() {
424
- (0, import_invariant3.invariant)(this._node, void 0, {
425
- F: __dxlog_file,
426
- L: 141,
427
- S: this,
428
- A: [
429
- "this._node",
430
- ""
431
- ]
432
- });
433
- this._node.graph.hf.clearSheet(this._node.sheetId);
434
- Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
435
- (0, import_invariant3.invariant)(this._node, void 0, {
436
- F: __dxlog_file,
437
- L: 144,
438
- S: this,
439
- A: [
440
- "this._node",
441
- ""
442
- ]
443
- });
444
- const { col, row } = (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, key);
445
- if ((0, import_chunk_KSEEI5VC.isFormula)(value)) {
446
- const binding = this._graph.mapFunctionBindingFromId((0, import_chunk_KSEEI5VC.mapFormulaIndicesToRefs)(this._sheet, value));
447
- if (binding) {
448
- value = this._graph.mapFormulaToNative(binding);
449
- } else {
450
- value = "";
451
- }
452
- }
453
- this._node.graph.hf.setCellContents({
454
- sheet: this._node.sheetId,
455
- row,
456
- col
457
- }, value);
458
- });
459
- }
460
- /**
461
- * Recalculate formulas.
462
- * NOTE: This resets the undo history.
463
- * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
464
- * @deprecated
465
- */
466
- // TODO(burdon): Remove.
467
- recalculate() {
468
- this._node?.graph.hf.rebuildAndRecalculate();
469
- }
470
- insertRows(i, n = 1) {
471
- const idx = (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.rows, i, n, import_chunk_KSEEI5VC.MAX_ROWS);
472
- this.reset();
473
- return idx;
474
- }
475
- insertColumns(i, n = 1) {
476
- const idx = (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.columns, i, n, import_chunk_KSEEI5VC.MAX_COLUMNS);
477
- this.reset();
478
- return idx;
479
- }
480
- dropRow(rowIndex) {
481
- const range = {
482
- from: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
483
- to: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
484
- };
485
- const values = this.getCellValues(range).flat();
486
- const index = this._sheet.rows.indexOf(rowIndex);
487
- this.clear(range);
488
- this._sheet.rows.splice(index, 1);
489
- delete this._sheet.rowMeta[rowIndex];
490
- this.reset();
491
- return {
492
- axis: "row",
493
- index,
494
- axisIndex: rowIndex,
495
- axisMeta: this._sheet.rowMeta[rowIndex],
496
- values
497
- };
498
- }
499
- dropColumn(colIndex) {
500
- const range = {
501
- from: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
502
- to: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
503
- };
504
- const values = this.getCellValues(range).flat();
505
- const index = this._sheet.columns.indexOf(colIndex);
506
- this.clear(range);
507
- this._sheet.columns.splice(index, 1);
508
- delete this._sheet.columnMeta[colIndex];
509
- this.reset();
510
- return {
511
- axis: "col",
512
- index,
513
- axisIndex: colIndex,
514
- axisMeta: this._sheet.rowMeta[colIndex],
515
- values
516
- };
517
- }
518
- restoreRow({ index, axisIndex, axisMeta, values }) {
519
- this._sheet.rows.splice(index, 0, axisIndex);
520
- values.forEach((value, col) => {
521
- if (value) {
522
- this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
523
- value
524
- };
525
- }
526
- });
527
- if (axisMeta) {
528
- this._sheet.rowMeta[axisIndex] = axisMeta;
529
- }
530
- this.reset();
531
- }
532
- restoreColumn({ index, axisIndex, axisMeta, values }) {
533
- this._sheet.columns.splice(index, 0, axisIndex);
534
- values.forEach((value, row) => {
535
- if (value) {
536
- this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
537
- value
538
- };
539
- }
540
- });
541
- if (axisMeta) {
542
- this._sheet.columnMeta[axisIndex] = axisMeta;
543
- }
544
- this.reset();
545
- }
546
- //
547
- // Undoable actions.
548
- // TODO(burdon): Group undoable methods; consistently update hf/sheet.
549
- //
550
- /**
551
- * Clear range of values.
552
- */
553
- clear(range) {
554
- (0, import_invariant3.invariant)(this._node, void 0, {
555
- F: __dxlog_file,
556
- L: 247,
557
- S: this,
558
- A: [
559
- "this._node",
560
- ""
561
- ]
562
- });
563
- const topLeft = getTopLeft(range);
564
- const values = this._iterRange(range, () => null);
565
- this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
566
- this._iterRange(range, (cell) => {
567
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
568
- delete this._sheet.cells[idx];
569
- });
570
- }
571
- cut(range) {
572
- (0, import_invariant3.invariant)(this._node, void 0, {
573
- F: __dxlog_file,
574
- L: 258,
575
- S: this,
576
- A: [
577
- "this._node",
578
- ""
579
- ]
580
- });
581
- this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
582
- this._iterRange(range, (cell) => {
583
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
584
- delete this._sheet.cells[idx];
585
- });
586
- }
587
- copy(range) {
588
- (0, import_invariant3.invariant)(this._node, void 0, {
589
- F: __dxlog_file,
590
- L: 267,
591
- S: this,
592
- A: [
593
- "this._node",
594
- ""
595
- ]
596
- });
597
- this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
598
- }
599
- paste(cell) {
600
- (0, import_invariant3.invariant)(this._node, void 0, {
601
- F: __dxlog_file,
602
- L: 272,
603
- S: this,
604
- A: [
605
- "this._node",
606
- ""
607
- ]
608
- });
609
- if (!this._node.graph.hf.isClipboardEmpty()) {
610
- const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
611
- for (const change of changes) {
612
- if (change instanceof import_hyperformula.ExportedCellChange) {
613
- const { address, newValue } = change;
614
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, {
615
- row: address.row,
616
- col: address.col
617
- });
618
- this._sheet.cells[idx] = {
619
- value: newValue
620
- };
621
- }
622
- }
623
- }
624
- }
625
- // TODO(burdon): Display undo/redo state.
626
- undo() {
627
- (0, import_invariant3.invariant)(this._node, void 0, {
628
- F: __dxlog_file,
629
- L: 287,
630
- S: this,
631
- A: [
632
- "this._node",
633
- ""
634
- ]
635
- });
636
- if (this._node.graph.hf.isThereSomethingToUndo()) {
637
- this._node.graph.hf.undo();
638
- }
639
- }
640
- redo() {
641
- (0, import_invariant3.invariant)(this._node, void 0, {
642
- F: __dxlog_file,
643
- L: 295,
644
- S: this,
645
- A: [
646
- "this._node",
647
- ""
648
- ]
649
- });
650
- if (this._node.graph.hf.isThereSomethingToRedo()) {
651
- this._node.graph.hf.redo();
652
- }
653
- }
654
- /**
655
- * Get value from sheet.
656
- */
657
- getCellValue(cell) {
658
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
659
- return this._sheet.cells[idx]?.value ?? null;
660
- }
661
- /**
662
- * Get value as a string for editing.
663
- */
664
- getCellText(cell) {
665
- const value = this.getCellValue(cell);
666
- if (value == null) {
667
- return void 0;
668
- }
669
- if ((0, import_chunk_KSEEI5VC.isFormula)(value)) {
670
- return this._graph.mapFunctionBindingFromId((0, import_chunk_KSEEI5VC.mapFormulaIndicesToRefs)(this._sheet, value));
671
- } else {
672
- return String(value);
673
- }
674
- }
675
- /**
676
- * Get array of raw values from sheet.
677
- */
678
- getCellValues(range) {
679
- return this._iterRange(range, (cell) => this.getCellValue(cell));
680
- }
681
- /**
682
- * Gets the regular or computed value from the engine.
683
- */
684
- getValue(cell) {
685
- (0, import_invariant3.invariant)(this._node, void 0, {
686
- F: __dxlog_file,
687
- L: 338,
688
- S: this,
689
- A: [
690
- "this._node",
691
- ""
692
- ]
693
- });
694
- const address = toSimpleCellAddress(this._node.sheetId, cell);
695
- const value = this._node.graph.hf.getCellValue(address);
696
- if (value instanceof import_hyperformula.DetailedCellError) {
697
- import_log.log.info("cell error", {
698
- cell,
699
- error: value
700
- }, {
701
- F: __dxlog_file,
702
- L: 343,
703
- S: this,
704
- C: (f, a) => f(...a)
705
- });
706
- return value.toString();
707
- }
708
- return value;
709
- }
710
- /**
711
- * Get value type.
712
- */
713
- getValueDescription(cell) {
714
- (0, import_invariant3.invariant)(this._node, void 0, {
715
- F: __dxlog_file,
716
- L: 354,
717
- S: this,
718
- A: [
719
- "this._node",
720
- ""
721
- ]
722
- });
723
- const addr = toSimpleCellAddress(this._node.sheetId, cell);
724
- const type = this._node.graph.hf.getCellValueDetailedType(addr);
725
- return typeMap[type];
726
- }
727
- /**
728
- * Sets the value, updating the sheet and engine.
729
- */
730
- setValue(cell, value) {
731
- (0, import_invariant3.invariant)(this._node, void 0, {
732
- F: __dxlog_file,
733
- L: 364,
734
- S: this,
735
- A: [
736
- "this._node",
737
- ""
738
- ]
739
- });
740
- if (this._options.readonly) {
741
- throw new import_chunk_KSEEI5VC.ReadonlyException();
742
- }
743
- let refresh = false;
744
- if (cell.row >= this._sheet.rows.length) {
745
- (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_KSEEI5VC.MAX_ROWS);
746
- refresh = true;
747
- }
748
- if (cell.col >= this._sheet.columns.length) {
749
- (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_KSEEI5VC.MAX_COLUMNS);
750
- refresh = true;
751
- }
752
- if (refresh) {
753
- this.reset();
754
- }
755
- this._node.graph.hf.setCellContents({
756
- sheet: this._node.sheetId,
757
- row: cell.row,
758
- col: cell.col
759
- }, [
760
- [
761
- (0, import_chunk_KSEEI5VC.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
762
- ]
763
- ]);
764
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
765
- if (value === void 0 || value === null) {
766
- delete this._sheet.cells[idx];
767
- } else {
768
- if ((0, import_chunk_KSEEI5VC.isFormula)(value)) {
769
- value = this._graph.mapFunctionBindingToId((0, import_chunk_KSEEI5VC.mapFormulaRefsToIndices)(this._sheet, value));
770
- }
771
- this._sheet.cells[idx] = {
772
- value
773
- };
774
- }
775
- }
776
- /**
777
- * Sets values from a simple map.
778
- */
779
- setValues(values) {
780
- Object.entries(values).forEach(([key, { value }]) => {
781
- this.setValue((0, import_chunk_KSEEI5VC.addressFromA1Notation)(key), value);
782
- });
783
- }
784
- /**
785
- * Iterate range.
786
- */
787
- _iterRange(range, cb) {
788
- const to = range.to ?? range.from;
789
- const rowRange = [
790
- Math.min(range.from.row, to.row),
791
- Math.max(range.from.row, to.row)
792
- ];
793
- const columnRange = [
794
- Math.min(range.from.col, to.col),
795
- Math.max(range.from.col, to.col)
796
- ];
797
- const rows = [];
798
- for (let row = rowRange[0]; row <= rowRange[1]; row++) {
799
- const rowCells = [];
800
- for (let column = columnRange[0]; column <= columnRange[1]; column++) {
801
- const value = cb({
802
- row,
803
- col: column
804
- });
805
- if (value !== void 0) {
806
- rowCells.push(value);
807
- }
808
- }
809
- rows.push(rowCells);
810
- }
811
- return rows;
812
- }
813
- // TODO(burdon): Delete index.
814
- _deleteIndices(indices, i, n) {
815
- throw new Error("Not implemented");
816
- }
817
- // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
818
- _moveIndices(indices, i, j, n) {
819
- throw new Error("Not implemented");
820
- }
821
- /**
822
- * Map from indices to A1 notation.
823
- */
824
- mapFormulaIndicesToRefs(formula) {
825
- (0, import_invariant3.invariant)((0, import_chunk_KSEEI5VC.isFormula)(formula), void 0, {
826
- F: __dxlog_file,
827
- L: 449,
828
- S: this,
829
- A: [
830
- "isFormula(formula)",
831
- ""
832
- ]
833
- });
834
- return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
835
- return (0, import_chunk_KSEEI5VC.addressToA1Notation)((0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, idx));
836
- });
837
- }
838
- //
839
- // Values
840
- //
841
- /**
842
- * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
843
- * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
844
- * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
845
- */
846
- toLocalDate(num) {
847
- const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
848
- return new Date(year, month - 1, day, hours, minutes, seconds);
849
- }
850
- toDateTime(num) {
851
- (0, import_invariant3.invariant)(this._node, void 0, {
852
- F: __dxlog_file,
853
- L: 470,
854
- S: this,
855
- A: [
856
- "this._node",
857
- ""
858
- ]
859
- });
860
- return this._node.graph.hf.numberToDateTime(num);
861
- }
862
- toDate(num) {
863
- (0, import_invariant3.invariant)(this._node, void 0, {
864
- F: __dxlog_file,
865
- L: 475,
866
- S: this,
867
- A: [
868
- "this._node",
869
- ""
870
- ]
871
- });
872
- return this._node.graph.hf.numberToDate(num);
873
- }
874
- toTime(num) {
875
- (0, import_invariant3.invariant)(this._node, void 0, {
876
- F: __dxlog_file,
877
- L: 480,
878
- S: this,
879
- A: [
880
- "this._node",
881
- ""
882
- ]
883
- });
884
- return this._node.graph.hf.numberToTime(num);
885
- }
886
- };
887
- var useSheetModel = (graph, sheet, { readonly } = {}) => {
888
- const [model, setModel] = (0, import_react3.useState)();
889
- (0, import_react3.useEffect)(() => {
890
- if (!graph || !sheet) {
891
- return;
892
- }
893
- let model2;
894
- const t = setTimeout(async () => {
895
- model2 = new SheetModel(graph, sheet, {
896
- readonly
897
- });
898
- await model2.open();
899
- setModel(model2);
900
- });
901
- return () => {
902
- clearTimeout(t);
903
- void model2?.close();
904
- };
905
- }, [
906
- graph,
907
- sheet,
908
- readonly
909
- ]);
910
- return model;
911
- };
912
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
913
- var SheetContext = /* @__PURE__ */ (0, import_react2.createContext)(void 0);
914
- var useSheetContext = () => {
915
- const context = (0, import_react2.useContext)(SheetContext);
916
- (0, import_invariant2.invariant)(context, void 0, {
917
- F: __dxlog_file2,
918
- L: 55,
919
- S: void 0,
920
- A: [
921
- "context",
922
- ""
923
- ]
924
- });
925
- return context;
926
- };
927
- var SheetProviderImpl = ({ model, onInfo, ignoreAttention, children, __gridScope }) => {
928
- const { id, editing, setEditing } = (0, import_react_ui_grid.useGridContext)("SheetProvider", __gridScope);
929
- const [cursor, setCursorInternal] = (0, import_react2.useState)();
930
- const [range, setRangeInternal] = (0, import_react2.useState)();
931
- const [cursorFallbackRange, setCursorFallbackRange] = (0, import_react2.useState)();
932
- const [activeRefs, setActiveRefs] = (0, import_react2.useState)("");
933
- const setCursor = (0, import_react2.useCallback)((nextCursor) => {
934
- setCursorInternal(nextCursor);
935
- setCursorFallbackRange(range?.to ? range : nextCursor ? {
936
- from: nextCursor,
937
- to: nextCursor
938
- } : void 0);
939
- }, [
940
- range
941
- ]);
942
- const setRange = (0, import_react2.useCallback)((nextRange) => {
943
- setRangeInternal(nextRange);
944
- setCursorFallbackRange(nextRange?.to ? nextRange : cursor ? {
945
- from: cursor,
946
- to: cursor
947
- } : void 0);
948
- }, [
949
- cursor
950
- ]);
951
- return /* @__PURE__ */ import_react2.default.createElement(SheetContext.Provider, {
952
- value: {
953
- id,
954
- model,
955
- editing,
956
- setEditing,
957
- cursor,
958
- setCursor,
959
- range,
960
- setRange,
961
- cursorFallbackRange,
962
- activeRefs,
963
- setActiveRefs,
964
- // TODO(burdon): Change to event.
965
- onInfo,
966
- ignoreAttention
967
- }
968
- }, children);
969
- };
970
- var SheetProvider = ({ children, graph, sheet, readonly, ignoreAttention, onInfo }) => {
971
- const model = useSheetModel(graph, sheet, {
972
- readonly
973
- });
974
- return !model ? null : /* @__PURE__ */ import_react2.default.createElement(import_react_ui_grid.Grid.Root, {
975
- id: (0, import_echo.fullyQualifiedId)(sheet)
976
- }, /* @__PURE__ */ import_react2.default.createElement(SheetProviderImpl, {
977
- model,
978
- onInfo,
979
- ignoreAttention
980
- }, children));
981
- };
982
- var RangeList = ({ sheet }) => {
983
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
984
- const handleSelectRange = (range) => {
985
- };
986
- const handleDeleteRange = (0, import_react8.useCallback)((range) => {
987
- const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
988
- sheet.ranges.splice(index, 1);
989
- }, [
990
- sheet
991
- ]);
992
- return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("h2", {
993
- className: "p-2 text-sm font-semibold"
994
- }, t("range list heading")), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
995
- items: sheet.ranges,
996
- isItem: import_echo_schema2.S.is(import_chunk_OWH2EUHZ.Range)
997
- }, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
998
- key: i,
999
- item: range,
1000
- classNames: [
1001
- "p-2",
1002
- import_react_ui_theme3.ghostHover
1003
- ]
1004
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemTitle, {
1005
- onClick: () => handleSelectRange(range)
1006
- }, t("range title", {
1007
- position: (0, import_chunk_KSEEI5VC.rangeToA1Notation)((0, import_chunk_KSEEI5VC.rangeFromIndex)(sheet, range.range)),
1008
- key: t(`range key ${range.key} label`),
1009
- value: t(`range value ${range.value} label`)
1010
- })), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
1011
- onClick: () => handleDeleteRange(range)
1012
- })))));
1013
- };
1014
- var SheetObjectSettings = ({ sheet }) => {
1015
- const { t } = (0, import_react_ui3.useTranslation)(import_meta.SPACE_PLUGIN);
1016
- return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, /* @__PURE__ */ import_react9.default.createElement("div", {
1017
- role: "form",
1018
- className: "flex flex-col w-full p-2 gap-1"
1019
- }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Input.Root, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Input.Label, null, t("name label")), /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Input.TextInput, {
1020
- placeholder: t("name placeholder"),
1021
- value: sheet.name ?? "",
1022
- onChange: (event) => {
1023
- sheet.name = event.target.value;
1024
- }
1025
- }))), /* @__PURE__ */ import_react9.default.createElement(RangeList, {
1026
- sheet
1027
- }));
1028
- };
1029
- var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-VVVRYTQG.cjs"));
1030
- var completeCellRangeToThreadCursor = (range) => {
1031
- return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
1032
- };
1033
- var parseThreadAnchorAsCellRange = (cursor) => {
1034
- const coords = cursor.split(",");
1035
- if (coords.length !== 4) {
1036
- return null;
1037
- } else {
1038
- const [fromCol, fromRow, toCol, toRow] = coords;
1039
- return {
1040
- from: {
1041
- col: parseInt(fromCol),
1042
- row: parseInt(fromRow)
1043
- },
1044
- to: {
1045
- col: parseInt(toCol),
1046
- row: parseInt(toRow)
1047
- }
1048
- };
1049
- }
1050
- };
1051
- var useUpdateFocusedCellOnThreadSelection = (grid) => {
1052
- const { model, setActiveRefs } = useSheetContext();
1053
- const handleScrollIntoView = (0, import_react6.useCallback)(({ action, data }) => {
1054
- switch (action) {
1055
- case import_app_framework2.LayoutAction.SCROLL_INTO_VIEW: {
1056
- if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo3.fullyQualifiedId)(model.sheet)) {
1057
- return;
1058
- }
1059
- setActiveRefs(data.thread);
1060
- const range = parseThreadAnchorAsCellRange(data.cursor);
1061
- range && grid?.setFocus({
1062
- ...range.to,
1063
- plane: "grid"
1064
- }, true);
1065
- return {
1066
- data: true
1067
- };
1068
- }
1069
- }
1070
- }, [
1071
- model.sheet,
1072
- setActiveRefs
1073
- ]);
1074
- (0, import_app_framework2.useIntentResolver)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN, handleScrollIntoView);
1075
- };
1076
- var useSelectThreadOnCellFocus = () => {
1077
- const { model, cursor } = useSheetContext();
1078
- const dispatch = (0, import_app_framework2.useIntentDispatcher)();
1079
- const threads = (0, import_react6.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
1080
- // TODO(thure): Surely we can find a better dependency for this…
1081
- JSON.stringify(model.sheet.threads)
1082
- ]);
1083
- const selectClosestThread = (0, import_react6.useCallback)((cellAddress) => {
1084
- if (!cellAddress || !threads) {
1085
- return;
1086
- }
1087
- const closestThread = threads?.find(({ anchor }) => {
1088
- if (anchor) {
1089
- const range = parseThreadAnchorAsCellRange(anchor);
1090
- return range ? (0, import_chunk_KSEEI5VC.inRange)(range, cellAddress) : false;
1091
- } else {
1092
- return false;
1093
- }
1094
- });
1095
- if (closestThread) {
1096
- void dispatch([
1097
- {
1098
- action: "dxos.org/plugin/thread/action/select",
1099
- data: {
1100
- current: (0, import_echo3.fullyQualifiedId)(closestThread)
1101
- }
1102
- }
1103
- ]);
1104
- }
1105
- }, [
1106
- dispatch,
1107
- threads
1108
- ]);
1109
- const debounced = (0, import_react6.useMemo)(() => {
1110
- return (0, import_async3.debounce)((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
1111
- }, [
1112
- selectClosestThread
1113
- ]);
1114
- (0, import_react6.useEffect)(() => {
1115
- if (!cursor) {
1116
- return;
1117
- }
1118
- debounced(cursor);
1119
- }, [
1120
- cursor,
1121
- debounced
1122
- ]);
1123
- };
1124
- var createDxGridColumns = (model) => {
1125
- return model.sheet.columns.reduce((acc, columnId, numericIndex) => {
1126
- if (model.sheet.columnMeta[columnId] && model.sheet.columnMeta[columnId].size) {
1127
- acc.grid[numericIndex] = {
1128
- size: model.sheet.columnMeta[columnId].size,
1129
- resizeable: true
1130
- };
1131
- }
1132
- return acc;
1133
- }, {
1134
- grid: {}
1135
- });
1136
- };
1137
- var createDxGridRows = (model) => {
1138
- return model.sheet.rows.reduce((acc, rowId, numericIndex) => {
1139
- if (model.sheet.rowMeta[rowId] && model.sheet.rowMeta[rowId].size) {
1140
- acc.grid[numericIndex] = {
1141
- size: model.sheet.rowMeta[rowId].size,
1142
- resizeable: true
1143
- };
1144
- }
1145
- return acc;
1146
- }, {
1147
- grid: {}
1148
- });
1149
- };
1150
- var projectCellProps = (model, col, row) => {
1151
- const address = {
1152
- col,
1153
- row
1154
- };
1155
- const rawValue = model.getValue(address);
1156
- const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_KSEEI5VC.inRange)((0, import_chunk_KSEEI5VC.rangeFromIndex)(model.sheet, range), address));
1157
- const threadRefs = model.sheet.threads?.filter((thread) => {
1158
- const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
1159
- return thread && range ? (0, import_chunk_KSEEI5VC.inRange)(range, address) : false;
1160
- }).map((thread) => (0, import_echo2.fullyQualifiedId)(thread)).join(" ");
1161
- const description = model.getValueDescription(address);
1162
- const type = description?.type;
1163
- const format = description?.format;
1164
- const classNames = ranges?.map(import_chunk_KSEEI5VC.cellClassNameForRange).reverse();
1165
- return {
1166
- value: (0, import_react_ui_form.parseValue)({
1167
- type,
1168
- format,
1169
- value: rawValue
1170
- }),
1171
- className: (0, import_react_ui_theme2.mx)((0, import_react_ui_form.cellClassesForFieldType)({
1172
- type,
1173
- format
1174
- }), threadRefs && import_react_ui_grid3.commentedClassName, classNames),
1175
- dataRefs: threadRefs
1176
- };
1177
- };
1178
- var gridCellGetter = (model) => {
1179
- const cachedGridCells = {};
1180
- return (nextBounds) => {
1181
- [
1182
- ...Array(nextBounds.end.col - nextBounds.start.col)
1183
- ].forEach((_, c0) => {
1184
- return [
1185
- ...Array(nextBounds.end.row - nextBounds.start.row)
1186
- ].forEach((_2, r0) => {
1187
- const col = nextBounds.start.col + c0;
1188
- const row = nextBounds.start.row + r0;
1189
- cachedGridCells[`${col},${row}`] = projectCellProps(model, col, row);
1190
- });
1191
- });
1192
- return cachedGridCells;
1193
- };
1194
- };
1195
- var rowLabelCell = (row) => ({
1196
- value: (0, import_react_ui_grid3.rowToA1Notation)(row),
1197
- className: "text-end !pie-1 text-subdued",
1198
- resizeHandle: "row"
1199
- });
1200
- var colLabelCell = (col) => ({
1201
- value: (0, import_react_ui_grid3.colToA1Notation)(col),
1202
- className: "text-subdued",
1203
- resizeHandle: "col"
1204
- });
1205
- var cellGetter = (model) => {
1206
- const getGridCells = gridCellGetter(model);
1207
- return (nextBounds, plane) => {
1208
- switch (plane) {
1209
- case "grid":
1210
- return getGridCells(nextBounds);
1211
- case "frozenColsStart":
1212
- return [
1213
- ...Array(nextBounds.end.row - nextBounds.start.row)
1214
- ].reduce((acc, _, r0) => {
1215
- const r = nextBounds.start.row + r0;
1216
- acc[`0,${r}`] = rowLabelCell(r);
1217
- return acc;
1218
- }, {});
1219
- case "frozenRowsStart":
1220
- return [
1221
- ...Array(nextBounds.end.col - nextBounds.start.col)
1222
- ].reduce((acc, _, c0) => {
1223
- const c = nextBounds.start.col + c0;
1224
- acc[`${c},0`] = colLabelCell(c);
1225
- return acc;
1226
- }, {});
1227
- default:
1228
- return {};
1229
- }
1230
- };
1231
- };
1232
- var useSheetModelDxGridProps = (dxGrid, model) => {
1233
- const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
1234
- const [rows, setRows] = (0, import_react5.useState)(createDxGridRows(model));
1235
- (0, import_react5.useEffect)(() => {
1236
- const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
1237
- "cells"
1238
- ]);
1239
- if (dxGrid) {
1240
- dxGrid.getCells = cellGetter(model);
1241
- }
1242
- const handleCellsUpdate = () => {
1243
- dxGrid?.requestUpdate("initialCells");
1244
- };
1245
- cellsAccessor.handle.addListener("change", handleCellsUpdate);
1246
- const unsubscribe = model.graph.update.on(handleCellsUpdate);
1247
- return () => {
1248
- cellsAccessor.handle.removeListener("change", handleCellsUpdate);
1249
- unsubscribe();
1250
- };
1251
- }, [
1252
- model,
1253
- dxGrid
1254
- ]);
1255
- (0, import_react5.useEffect)(() => {
1256
- const columnMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
1257
- "columnMeta"
1258
- ]);
1259
- const rowMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
1260
- "rowMeta"
1261
- ]);
1262
- const handleColumnMetaUpdate = () => {
1263
- setColumns(createDxGridColumns(model));
1264
- };
1265
- const handleRowMetaUpdate = () => {
1266
- setRows(createDxGridRows(model));
1267
- };
1268
- columnMetaAccessor.handle.addListener("change", handleColumnMetaUpdate);
1269
- rowMetaAccessor.handle.addListener("change", handleRowMetaUpdate);
1270
- return () => {
1271
- columnMetaAccessor.handle.removeListener("change", handleColumnMetaUpdate);
1272
- rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
1273
- };
1274
- }, [
1275
- model,
1276
- dxGrid
1277
- ]);
1278
- return {
1279
- columns,
1280
- rows
1281
- };
1282
- };
1283
- var inertPosition = {
1284
- plane: "grid",
1285
- col: 0,
1286
- row: 0
1287
- };
1288
- var initialCells = {
1289
- grid: {},
1290
- frozenColsStart: [
1291
- ...Array(64)
1292
- ].reduce((acc, _, i) => {
1293
- acc[`0,${i}`] = rowLabelCell(i);
1294
- return acc;
1295
- }, {}),
1296
- frozenRowsStart: [
1297
- ...Array(12)
1298
- ].reduce((acc, _, i) => {
1299
- acc[`${i},0`] = colLabelCell(i);
1300
- return acc;
1301
- }, {})
1302
- };
1303
- var frozen = {
1304
- frozenColsStart: 1,
1305
- frozenRowsStart: 1
1306
- };
1307
- var sheetRowDefault = {
1308
- frozenRowsStart: {
1309
- size: import_react_ui_grid2.defaultSizeRow,
1310
- readonly: true
1311
- },
1312
- grid: {
1313
- size: import_react_ui_grid2.defaultSizeRow,
1314
- resizeable: true
1315
- }
1316
- };
1317
- var sheetColDefault = {
1318
- frozenColsStart: {
1319
- size: 48,
1320
- readonly: true
1321
- },
1322
- grid: {
1323
- size: 180,
1324
- resizeable: true
1325
- }
1326
- };
1327
- var GridSheet = () => {
1328
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
1329
- const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } = useSheetContext();
1330
- const [dxGrid, setDxGrid] = (0, import_react4.useState)(null);
1331
- const [extraplanarFocus, setExtraplanarFocus] = (0, import_react4.useState)(null);
1332
- const dispatch = (0, import_app_framework.useIntentDispatcher)();
1333
- const rangeController = (0, import_react4.useRef)();
1334
- const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
1335
- const handleFocus = (0, import_react4.useCallback)((event) => {
1336
- if (!editing) {
1337
- const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1338
- if (cell) {
1339
- if (cell.plane === "grid") {
1340
- setCursor({
1341
- col: cell.col,
1342
- row: cell.row
1343
- });
1344
- setExtraplanarFocus(null);
1345
- } else {
1346
- setExtraplanarFocus(cell);
1347
- }
1348
- } else {
1349
- setExtraplanarFocus(null);
1350
- }
1351
- }
1352
- }, [
1353
- editing
1354
- ]);
1355
- const handleClose = (0, import_react4.useCallback)((_value, event) => {
1356
- if (event) {
1357
- const { key, shift } = event;
1358
- const axis = [
1359
- "Enter",
1360
- "ArrowUp",
1361
- "ArrowDown"
1362
- ].includes(key) ? "row" : [
1363
- "Tab",
1364
- "ArrowLeft",
1365
- "ArrowRight"
1366
- ].includes(key) ? "col" : void 0;
1367
- const delta = key.startsWith("Arrow") ? [
1368
- "ArrowUp",
1369
- "ArrowLeft"
1370
- ].includes(key) ? -1 : 1 : shift ? -1 : 1;
1371
- dxGrid?.refocus(axis, delta);
1372
- }
1373
- }, [
1374
- model,
1375
- editing,
1376
- dxGrid
1377
- ]);
1378
- const handleBlur = (0, import_react4.useCallback)((value) => {
1379
- if (value !== void 0) {
1380
- model.setValue((0, import_react_ui_grid2.parseCellIndex)(editing.index), value);
1381
- }
1382
- }, [
1383
- model,
1384
- editing
1385
- ]);
1386
- const handleAxisResize = (0, import_react4.useCallback)(({ axis, size, index: numericIndex }) => {
1387
- if (axis === "row") {
1388
- const rowId = model.sheet.rows[parseInt(numericIndex)];
1389
- model.sheet.rowMeta[rowId] ??= {};
1390
- model.sheet.rowMeta[rowId].size = size;
1391
- } else {
1392
- const columnId = model.sheet.columns[parseInt(numericIndex)];
1393
- model.sheet.columnMeta[columnId] ??= {};
1394
- model.sheet.columnMeta[columnId].size = size;
1395
- }
1396
- }, [
1397
- model
1398
- ]);
1399
- const handleSelect = (0, import_react4.useCallback)(({ minCol, maxCol, minRow, maxRow }) => {
1400
- const range = {
1401
- from: {
1402
- col: minCol,
1403
- row: minRow
1404
- }
1405
- };
1406
- if (minCol !== maxCol || minRow !== maxRow) {
1407
- range.to = {
1408
- col: maxCol,
1409
- row: maxRow
1410
- };
1411
- }
1412
- if (editing) {
1413
- rangeController.current?.setRange((0, import_chunk_KSEEI5VC.rangeToA1Notation)(range));
1414
- } else {
1415
- setRange(range.to ? range : void 0);
1416
- }
1417
- }, [
1418
- editing
1419
- ]);
1420
- const handleWheel = (0, import_react4.useCallback)((event) => {
1421
- if (!ignoreAttention && !hasAttention) {
1422
- event.stopPropagation();
1423
- }
1424
- }, [
1425
- hasAttention,
1426
- ignoreAttention
1427
- ]);
1428
- const selectEntireAxis = (0, import_react4.useCallback)((pos) => {
1429
- switch (pos.plane) {
1430
- case "frozenRowsStart":
1431
- return dxGrid?.setSelection({
1432
- start: {
1433
- col: pos.col,
1434
- row: 0,
1435
- plane: "grid"
1436
- },
1437
- end: {
1438
- col: pos.col,
1439
- row: model.sheet.rows.length - 1,
1440
- plane: "grid"
1441
- }
1442
- });
1443
- case "frozenColsStart":
1444
- return dxGrid?.setSelection({
1445
- start: {
1446
- row: pos.row,
1447
- col: 0,
1448
- plane: "grid"
1449
- },
1450
- end: {
1451
- row: pos.row,
1452
- col: model.sheet.columns.length - 1,
1453
- plane: "grid"
1454
- }
1455
- });
1456
- }
1457
- }, [
1458
- dxGrid,
1459
- model.sheet
1460
- ]);
1461
- const handleClick = (0, import_react4.useCallback)((event) => {
1462
- const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1463
- if (cell) {
1464
- selectEntireAxis(cell);
1465
- }
1466
- }, [
1467
- selectEntireAxis
1468
- ]);
1469
- const handleKeyDown = (0, import_react4.useCallback)((event) => {
1470
- switch (event.key) {
1471
- case "Backspace":
1472
- case "Delete":
1473
- event.preventDefault();
1474
- return cursorFallbackRange && model.clear(cursorFallbackRange);
1475
- case "Enter":
1476
- case "Space":
1477
- if (dxGrid && extraplanarFocus) {
1478
- switch (extraplanarFocus.plane) {
1479
- case "frozenRowsStart":
1480
- case "frozenColsStart":
1481
- event.preventDefault();
1482
- return selectEntireAxis(extraplanarFocus);
1483
- }
1484
- }
1485
- }
1486
- if (event.metaKey || event.ctrlKey) {
1487
- switch (event.key) {
1488
- case "x":
1489
- case "X":
1490
- event.preventDefault();
1491
- return cursorFallbackRange && model.cut(cursorFallbackRange);
1492
- case "c":
1493
- case "C":
1494
- event.preventDefault();
1495
- return cursorFallbackRange && model.copy(cursorFallbackRange);
1496
- case "v":
1497
- case "V":
1498
- event.preventDefault();
1499
- return cursor && model.paste(cursor);
1500
- case "z":
1501
- event.preventDefault();
1502
- return event.shiftKey ? model.redo() : model.undo();
1503
- case "Z":
1504
- case "y":
1505
- event.preventDefault();
1506
- return model.redo();
1507
- }
1508
- }
1509
- }, [
1510
- cursorFallbackRange,
1511
- model,
1512
- cursor,
1513
- extraplanarFocus,
1514
- selectEntireAxis
1515
- ]);
1516
- const contextMenuAnchorRef = (0, import_react4.useRef)(null);
1517
- const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
1518
- const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
1519
- const handleContextMenu = (0, import_react4.useCallback)((event) => {
1520
- const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1521
- if (cell && cell.plane.startsWith("frozen")) {
1522
- event.preventDefault();
1523
- contextMenuAnchorRef.current = event.target;
1524
- setContextMenuOpen(cell);
1525
- }
1526
- }, []);
1527
- const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
1528
- switch (operation) {
1529
- case "insert-before":
1530
- case "insert-after":
1531
- return dispatch({
1532
- action: import_chunk_OWH2EUHZ.SheetAction.INSERT_AXIS,
1533
- data: {
1534
- model,
1535
- axis: contextMenuAxis,
1536
- index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
1537
- }
1538
- });
1539
- break;
1540
- case "drop":
1541
- return dispatch({
1542
- action: import_chunk_OWH2EUHZ.SheetAction.DROP_AXIS,
1543
- data: {
1544
- model,
1545
- axis: contextMenuAxis,
1546
- axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
1547
- }
1548
- });
1549
- }
1550
- }, [
1551
- contextMenuAxis,
1552
- contextMenuOpen,
1553
- model,
1554
- dispatch
1555
- ]);
1556
- const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
1557
- const extension = (0, import_react4.useMemo)(() => [
1558
- (0, import_react_ui_grid2.editorKeys)({
1559
- onClose: handleClose,
1560
- ...editing?.initialContent && {
1561
- onNav: handleClose
1562
- }
1563
- }),
1564
- sheetExtension({
1565
- functions: model.graph.getFunctions()
1566
- }),
1567
- rangeExtension({
1568
- onInit: (fn) => rangeController.current = fn,
1569
- onStateChange: (state) => {
1570
- if (dxGrid) {
1571
- dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
1572
- }
1573
- }
1574
- })
1575
- ], [
1576
- model,
1577
- handleClose,
1578
- editing
1579
- ]);
1580
- const getCellContent = (0, import_react4.useCallback)((index) => {
1581
- return model.getCellText((0, import_react_ui_grid2.parseCellIndex)(index));
1582
- }, [
1583
- model
1584
- ]);
1585
- useUpdateFocusedCellOnThreadSelection(dxGrid);
1586
- useSelectThreadOnCellFocus();
1587
- return /* @__PURE__ */ import_react4.default.createElement("div", {
1588
- role: "none",
1589
- className: "relative min-bs-0"
1590
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.GridCellEditor, {
1591
- getCellContent,
1592
- extension,
1593
- onBlur: handleBlur
1594
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
1595
- initialCells,
1596
- limitColumns: import_chunk_KSEEI5VC.DEFAULT_COLUMNS,
1597
- limitRows: import_chunk_KSEEI5VC.DEFAULT_ROWS,
1598
- columns,
1599
- rows,
1600
- onAxisResize: handleAxisResize,
1601
- onSelect: handleSelect,
1602
- rowDefault: sheetRowDefault,
1603
- columnDefault: sheetColDefault,
1604
- frozen,
1605
- onFocus: handleFocus,
1606
- onWheelCapture: handleWheel,
1607
- onKeyDown: handleKeyDown,
1608
- onContextMenu: handleContextMenu,
1609
- onClick: handleClick,
1610
- overscroll: "trap",
1611
- className: "[--dx-grid-base:var(--surface-bg)] [&_.dx-grid]:border-bs [&_.dx-grid]:absolute [&_.dx-grid]:inset-0 [&_.dx-grid]:border-separator",
1612
- activeRefs,
1613
- ref: setDxGrid
1614
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
1615
- modal: false,
1616
- open: !!contextMenuOpen,
1617
- onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
1618
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.VirtualTrigger, {
1619
- virtualRef: contextMenuAnchorRef
1620
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Content, {
1621
- side: contextMenuAxis === "col" ? "bottom" : "right",
1622
- sideOffset: 4,
1623
- collisionPadding: 8
1624
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1625
- onClick: () => handleAxisMenuAction("insert-before"),
1626
- "data-testid": `grid.${contextMenuAxis}.insert-before`
1627
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1628
- size: 5,
1629
- icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
1630
- }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1631
- onClick: () => handleAxisMenuAction("insert-after"),
1632
- "data-testid": `grid.${contextMenuAxis}.insert-after`
1633
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1634
- size: 5,
1635
- icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
1636
- }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1637
- onClick: () => handleAxisMenuAction("drop"),
1638
- "data-testid": `grid.${contextMenuAxis}.drop`
1639
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1640
- size: 5,
1641
- icon: "ph--backspace--regular"
1642
- }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Arrow, null))));
1643
- };
1644
- // Annotate the CommonJS export names for ESM import in node:
1645
- 0 && (module.exports = {
1646
- ComputeGraphContextProvider,
1647
- GridSheet,
1648
- SheetContainer,
1649
- SheetObjectSettings,
1650
- SheetProvider,
1651
- completeCellRangeToThreadCursor,
1652
- computeGraphFacet,
1653
- useComputeGraph,
1654
- useSheetContext
1655
- });
1656
- //# sourceMappingURL=chunk-45YW2DX2.cjs.map