@dxos/plugin-sheet 0.6.12-main.5cc132e → 0.6.12-main.7907542

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 (273) hide show
  1. package/dist/lib/browser/SheetContainer-T2QWJOFD.mjs +262 -0
  2. package/dist/lib/browser/SheetContainer-T2QWJOFD.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-WUPTZUTX.mjs → chunk-5ZMVZYGB.mjs} +21 -19
  4. package/dist/lib/browser/chunk-5ZMVZYGB.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-GNNVBNCX.mjs → chunk-GSV5QNLD.mjs} +409 -686
  6. package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
  8. package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
  9. package/dist/lib/browser/{SheetContainer-Y7ZMFBAP.mjs → chunk-ZL2V5UJR.mjs} +982 -508
  10. package/dist/lib/browser/chunk-ZL2V5UJR.mjs.map +7 -0
  11. package/dist/lib/browser/graph-M4IQ76QX.mjs +33 -0
  12. package/dist/lib/browser/graph-M4IQ76QX.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +86 -59
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/meta.mjs +1 -1
  17. package/dist/lib/browser/types.mjs +4 -6
  18. package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs +280 -0
  19. package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs.map +7 -0
  20. package/dist/lib/node/{SheetContainer-KEOKUKAQ.cjs → chunk-2K53Z2TU.cjs} +1036 -558
  21. package/dist/lib/node/chunk-2K53Z2TU.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-ZRQZFV5T.cjs → chunk-5XPK2V4A.cjs} +418 -691
  23. package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
  25. package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
  26. package/dist/lib/node/{chunk-VJU3NPUJ.cjs → chunk-STAVQ2JE.cjs} +25 -24
  27. package/dist/lib/node/chunk-STAVQ2JE.cjs.map +7 -0
  28. package/dist/lib/node/graph-Q3N2X26H.cjs +55 -0
  29. package/dist/lib/node/graph-Q3N2X26H.cjs.map +7 -0
  30. package/dist/lib/node/index.cjs +98 -66
  31. package/dist/lib/node/index.cjs.map +4 -4
  32. package/dist/lib/node/meta.cjs +3 -3
  33. package/dist/lib/node/meta.cjs.map +1 -1
  34. package/dist/lib/node/meta.json +1 -1
  35. package/dist/lib/node/types.cjs +10 -12
  36. package/dist/lib/node/types.cjs.map +2 -2
  37. package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs +263 -0
  38. package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs.map +7 -0
  39. package/dist/lib/node-esm/{chunk-WUPTZUTX.mjs → chunk-2HAM45RC.mjs} +22 -19
  40. package/dist/lib/node-esm/chunk-2HAM45RC.mjs.map +7 -0
  41. package/dist/lib/node-esm/{chunk-GNNVBNCX.mjs → chunk-5WPZCXNS.mjs} +411 -686
  42. package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
  43. package/dist/lib/node-esm/{chunk-JRL5LGCE.mjs → chunk-IU2L277A.mjs} +4 -5
  44. package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
  45. package/dist/lib/node-esm/{SheetContainer-Y7ZMFBAP.mjs → chunk-QEUCIHIN.mjs} +983 -508
  46. package/dist/lib/node-esm/chunk-QEUCIHIN.mjs.map +7 -0
  47. package/dist/lib/node-esm/graph-SMPUMOV2.mjs +34 -0
  48. package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +87 -59
  50. package/dist/lib/node-esm/index.mjs.map +4 -4
  51. package/dist/lib/node-esm/meta.json +1 -1
  52. package/dist/lib/node-esm/meta.mjs +2 -1
  53. package/dist/lib/node-esm/types.mjs +5 -6
  54. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  55. package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
  56. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
  57. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
  58. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
  60. package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
  61. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
  62. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
  63. package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
  64. package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
  65. package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
  66. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
  67. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
  68. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
  69. package/dist/types/src/components/GridSheet/util.d.ts +16 -0
  70. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
  71. package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
  72. package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
  73. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +5 -6
  74. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
  75. package/dist/types/src/components/Sheet/grid.d.ts +2 -2
  76. package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
  77. package/dist/types/src/components/Sheet/nav.d.ts +3 -3
  78. package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
  79. package/dist/types/src/components/Sheet/sheet-context.d.ts +6 -7
  80. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
  81. package/dist/types/src/components/Sheet/threads.d.ts.map +1 -1
  82. package/dist/types/src/components/SheetContainer.d.ts +1 -1
  83. package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
  84. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  85. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +1 -1
  86. package/dist/types/src/components/index.d.ts +2 -1
  87. package/dist/types/src/components/index.d.ts.map +1 -1
  88. package/dist/types/src/defs/index.d.ts +3 -0
  89. package/dist/types/src/defs/index.d.ts.map +1 -0
  90. package/dist/types/src/{model → defs}/types.d.ts +8 -3
  91. package/dist/types/src/defs/types.d.ts.map +1 -0
  92. package/dist/types/src/defs/types.test.d.ts.map +1 -0
  93. package/dist/types/src/{model → defs}/util.d.ts +8 -4
  94. package/dist/types/src/defs/util.d.ts.map +1 -0
  95. package/dist/types/src/extensions/compute.d.ts +6 -0
  96. package/dist/types/src/extensions/compute.d.ts.map +1 -0
  97. package/dist/types/src/extensions/compute.stories.d.ts +26 -0
  98. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
  99. package/dist/types/src/extensions/index.d.ts +2 -0
  100. package/dist/types/src/extensions/index.d.ts.map +1 -0
  101. package/dist/types/src/graph/compute-graph-registry.d.ts +34 -0
  102. package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
  103. package/dist/types/src/graph/compute-graph.d.ts +64 -0
  104. package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
  105. package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
  106. package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
  107. package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
  108. package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
  109. package/dist/types/src/graph/compute-node.d.ts +26 -0
  110. package/dist/types/src/graph/compute-node.d.ts.map +1 -0
  111. package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
  112. package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
  113. package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
  114. package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
  115. package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
  116. package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
  117. package/dist/types/src/graph/functions/index.d.ts +4 -0
  118. package/dist/types/src/graph/functions/index.d.ts.map +1 -0
  119. package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
  120. package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
  121. package/dist/types/src/graph/index.d.ts +5 -0
  122. package/dist/types/src/graph/index.d.ts.map +1 -0
  123. package/dist/types/src/graph/testing/index.d.ts +3 -0
  124. package/dist/types/src/graph/testing/index.d.ts.map +1 -0
  125. package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
  126. package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
  127. package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
  128. package/dist/types/src/graph/testing/test-plugin.d.ts.map +1 -0
  129. package/dist/types/src/graph/util.d.ts +2 -0
  130. package/dist/types/src/graph/util.d.ts.map +1 -0
  131. package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
  132. package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
  133. package/dist/types/src/hooks/index.d.ts +4 -0
  134. package/dist/types/src/hooks/index.d.ts.map +1 -0
  135. package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
  136. package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
  137. package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
  138. package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
  139. package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
  140. package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
  141. package/dist/types/src/meta.d.ts +1 -4
  142. package/dist/types/src/meta.d.ts.map +1 -1
  143. package/dist/types/src/model/formatting-model.d.ts +16 -0
  144. package/dist/types/src/model/formatting-model.d.ts.map +1 -0
  145. package/dist/types/src/model/index.d.ts +2 -4
  146. package/dist/types/src/model/index.d.ts.map +1 -1
  147. package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +10 -49
  148. package/dist/types/src/model/sheet-model.d.ts.map +1 -0
  149. package/dist/types/src/model/sheet-model.test.d.ts +2 -0
  150. package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
  151. package/dist/types/src/sanity.test.d.ts +2 -0
  152. package/dist/types/src/sanity.test.d.ts.map +1 -0
  153. package/dist/types/src/testing/index.d.ts +2 -0
  154. package/dist/types/src/testing/index.d.ts.map +1 -0
  155. package/dist/types/src/testing/testing.d.ts +8 -0
  156. package/dist/types/src/testing/testing.d.ts.map +1 -0
  157. package/dist/types/src/types.d.ts +15 -4
  158. package/dist/types/src/types.d.ts.map +1 -1
  159. package/dist/vendor/hyperformula.mjs +37145 -0
  160. package/package.json +48 -44
  161. package/src/SheetPlugin.tsx +46 -62
  162. package/src/components/CellEditor/CellEditor.stories.tsx +6 -6
  163. package/src/components/CellEditor/CellEditor.tsx +59 -9
  164. package/src/components/CellEditor/extension.test.ts +3 -4
  165. package/src/components/CellEditor/extension.ts +5 -6
  166. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
  167. package/src/components/ComputeGraph/index.ts +1 -3
  168. package/src/components/GridSheet/GridSheet.stories.tsx +36 -0
  169. package/src/components/GridSheet/GridSheet.tsx +171 -0
  170. package/src/components/GridSheet/util.ts +148 -0
  171. package/src/components/Sheet/Sheet.stories.tsx +48 -88
  172. package/src/components/Sheet/Sheet.tsx +42 -24
  173. package/src/components/Sheet/grid.ts +3 -3
  174. package/src/components/Sheet/nav.ts +19 -19
  175. package/src/components/Sheet/sheet-context.tsx +12 -82
  176. package/src/components/Sheet/threads.tsx +10 -6
  177. package/src/components/SheetContainer.tsx +13 -15
  178. package/src/components/Toolbar/Toolbar.tsx +1 -2
  179. package/src/components/index.ts +1 -0
  180. package/src/defs/index.ts +6 -0
  181. package/src/{model → defs}/types.test.ts +7 -7
  182. package/src/{model → defs}/types.ts +24 -14
  183. package/src/{model → defs}/util.ts +65 -17
  184. package/src/extensions/compute.stories.tsx +151 -0
  185. package/src/extensions/compute.ts +147 -0
  186. package/src/extensions/index.ts +5 -0
  187. package/src/graph/compute-graph-registry.ts +90 -0
  188. package/src/graph/compute-graph.stories.tsx +93 -0
  189. package/src/graph/compute-graph.test.ts +87 -0
  190. package/src/graph/compute-graph.ts +242 -0
  191. package/src/graph/compute-node.ts +63 -0
  192. package/src/{components/ComputeGraph → graph/functions}/async-function.ts +25 -15
  193. package/src/{components/ComputeGraph → graph/functions}/edge-function.ts +16 -14
  194. package/src/graph/functions/index.ts +7 -0
  195. package/src/graph/hyperformula.test.ts +14 -0
  196. package/src/graph/index.ts +8 -0
  197. package/src/graph/testing/index.ts +6 -0
  198. package/src/graph/testing/test-builder.ts +54 -0
  199. package/src/{components/ComputeGraph/custom.ts → graph/testing/test-plugin.ts} +44 -14
  200. package/src/graph/util.ts +8 -0
  201. package/src/hooks/hooks.stories.tsx +50 -0
  202. package/src/hooks/index.ts +7 -0
  203. package/src/hooks/useComputeGraph.ts +28 -0
  204. package/src/hooks/useFormattingModel.ts +11 -0
  205. package/src/hooks/useSheetModel.ts +40 -0
  206. package/src/meta.tsx +1 -5
  207. package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
  208. package/src/model/index.ts +2 -4
  209. package/src/model/sheet-model.test.ts +57 -0
  210. package/src/model/{model.ts → sheet-model.ts} +88 -188
  211. package/src/sanity.test.ts +40 -0
  212. package/src/testing/index.ts +5 -0
  213. package/src/testing/testing.tsx +68 -0
  214. package/src/types.ts +19 -17
  215. package/dist/lib/browser/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
  216. package/dist/lib/browser/chunk-GNNVBNCX.mjs.map +0 -7
  217. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
  218. package/dist/lib/browser/chunk-PGKZPKUD.mjs +0 -175
  219. package/dist/lib/browser/chunk-PGKZPKUD.mjs.map +0 -7
  220. package/dist/lib/browser/chunk-VBF7YENS.mjs +0 -8
  221. package/dist/lib/browser/chunk-VBF7YENS.mjs.map +0 -7
  222. package/dist/lib/browser/chunk-WUPTZUTX.mjs.map +0 -7
  223. package/dist/lib/browser/testing.mjs +0 -92
  224. package/dist/lib/browser/testing.mjs.map +0 -7
  225. package/dist/lib/node/SheetContainer-KEOKUKAQ.cjs.map +0 -7
  226. package/dist/lib/node/chunk-57PB2HPY.cjs +0 -40
  227. package/dist/lib/node/chunk-57PB2HPY.cjs.map +0 -7
  228. package/dist/lib/node/chunk-6LWBQAQZ.cjs +0 -202
  229. package/dist/lib/node/chunk-6LWBQAQZ.cjs.map +0 -7
  230. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
  231. package/dist/lib/node/chunk-VJU3NPUJ.cjs.map +0 -7
  232. package/dist/lib/node/chunk-ZRQZFV5T.cjs.map +0 -7
  233. package/dist/lib/node/testing.cjs +0 -111
  234. package/dist/lib/node/testing.cjs.map +0 -7
  235. package/dist/lib/node-esm/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
  236. package/dist/lib/node-esm/chunk-GNNVBNCX.mjs.map +0 -7
  237. package/dist/lib/node-esm/chunk-JRL5LGCE.mjs.map +0 -7
  238. package/dist/lib/node-esm/chunk-PGKZPKUD.mjs +0 -175
  239. package/dist/lib/node-esm/chunk-PGKZPKUD.mjs.map +0 -7
  240. package/dist/lib/node-esm/chunk-VBF7YENS.mjs +0 -8
  241. package/dist/lib/node-esm/chunk-VBF7YENS.mjs.map +0 -7
  242. package/dist/lib/node-esm/chunk-WUPTZUTX.mjs.map +0 -7
  243. package/dist/lib/node-esm/testing.mjs +0 -92
  244. package/dist/lib/node-esm/testing.mjs.map +0 -7
  245. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
  246. package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
  247. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
  248. package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
  249. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
  250. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
  251. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
  252. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
  253. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
  254. package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
  255. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
  256. package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
  257. package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
  258. package/dist/types/src/model/functions.d.ts.map +0 -1
  259. package/dist/types/src/model/model.browser.test.d.ts +0 -2
  260. package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
  261. package/dist/types/src/model/model.d.ts.map +0 -1
  262. package/dist/types/src/model/types.d.ts.map +0 -1
  263. package/dist/types/src/model/types.test.d.ts.map +0 -1
  264. package/dist/types/src/model/util.d.ts.map +0 -1
  265. package/dist/types/src/testing.d.ts +0 -9
  266. package/dist/types/src/testing.d.ts.map +0 -1
  267. package/src/components/ComputeGraph/graph-context.tsx +0 -50
  268. package/src/components/ComputeGraph/graph.browser.test.ts +0 -49
  269. package/src/components/ComputeGraph/graph.ts +0 -62
  270. package/src/model/model.browser.test.ts +0 -99
  271. package/src/testing.ts +0 -50
  272. /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
  273. /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
@@ -1,33 +1,13 @@
1
1
  import {
2
- useComputeGraph
3
- } from "./chunk-PGKZPKUD.mjs";
4
- import {
5
- SheetModel,
6
- addressFromA1Notation,
7
- addressFromIndex,
8
- addressToA1Notation,
9
- addressToIndex,
10
- closest,
11
- columnLetter,
12
- defaultFunctions,
13
- inRange,
14
- posEquals,
15
- rangeFromIndex,
16
- rangeToA1Notation
17
- } from "./chunk-GNNVBNCX.mjs";
18
- import {
2
+ SheetType,
19
3
  ValueTypeEnum
20
- } from "./chunk-WUPTZUTX.mjs";
4
+ } from "./chunk-5ZMVZYGB.mjs";
21
5
  import {
22
6
  SHEET_PLUGIN
23
- } from "./chunk-JRL5LGCE.mjs";
24
-
25
- // packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
26
- import React7, { useCallback as useCallback2 } from "react";
27
- import { useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
28
- import { fullyQualifiedId as fullyQualifiedId4 } from "@dxos/react-client/echo";
29
- import { useIsDirectlyAttended } from "@dxos/react-ui-attention";
30
- import { focusRing, mx as mx4 } from "@dxos/react-ui-theme";
7
+ } from "./chunk-QILRZNE5.mjs";
8
+ import {
9
+ createSheetName
10
+ } from "./chunk-GSV5QNLD.mjs";
31
11
 
32
12
  // packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
33
13
  import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
@@ -35,17 +15,183 @@ import { restrictToHorizontalAxis, restrictToVerticalAxis } from "@dnd-kit/modif
35
15
  import { getEventCoordinates, useCombinedRefs } from "@dnd-kit/utilities";
36
16
  import { Function as FunctionIcon } from "@phosphor-icons/react";
37
17
  import { Resizable } from "re-resizable";
38
- import React4, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo3, useRef, useState as useState4 } from "react";
18
+ import React6, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo4, useRef, useState as useState5 } from "react";
39
19
  import { createPortal } from "react-dom";
40
20
  import { useResizeDetector } from "react-resize-detector";
41
21
  import { debounce as debounce2 } from "@dxos/async";
42
- import { fullyQualifiedId as fullyQualifiedId3, createDocAccessor } from "@dxos/client/echo";
43
- import { log } from "@dxos/log";
44
- import { createAttendableAttributes, useHasAttention } from "@dxos/react-ui-attention";
45
- import { mx as mx3 } from "@dxos/react-ui-theme";
22
+ import { fullyQualifiedId as fullyQualifiedId2, createDocAccessor } from "@dxos/client/echo";
23
+ import { log as log2 } from "@dxos/log";
24
+ import { ATTENABLE_ATTRIBUTE, useAttendableAttributes, useAttention, useAttentionPath } from "@dxos/react-ui-attention";
25
+ import { mx as mx2 } from "@dxos/react-ui-theme";
46
26
 
47
27
  // packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
48
28
  import { useEffect, useState } from "react";
29
+
30
+ // packages/plugins/plugin-sheet/src/defs/types.ts
31
+ import { invariant } from "@dxos/invariant";
32
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
33
+ var DEFAULT_ROWS = 50;
34
+ var DEFAULT_COLUMNS = 26;
35
+ var MAX_ROWS = 500;
36
+ var MAX_COLUMNS = 26 * 2;
37
+ var posEquals = (a, b) => {
38
+ return a?.col === b?.col && a?.row === b?.row;
39
+ };
40
+ var columnLetter = (col) => {
41
+ invariant(col < MAX_COLUMNS, `Invalid column: ${col}`, {
42
+ F: __dxlog_file,
43
+ L: 26,
44
+ S: void 0,
45
+ A: [
46
+ "col < MAX_COLUMNS",
47
+ "`Invalid column: ${col}`"
48
+ ]
49
+ });
50
+ return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
51
+ };
52
+ var addressToA1Notation = ({ col, row }) => {
53
+ return `${columnLetter(col)}${row + 1}`;
54
+ };
55
+ var addressFromA1Notation = (ref) => {
56
+ const match = ref.match(/([A-Z]+)(\d+)/);
57
+ invariant(match, `Invalid notation: ${ref}`, {
58
+ F: __dxlog_file,
59
+ L: 40,
60
+ S: void 0,
61
+ A: [
62
+ "match",
63
+ "`Invalid notation: ${ref}`"
64
+ ]
65
+ });
66
+ return {
67
+ row: parseInt(match[2], 10) - 1,
68
+ col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
69
+ };
70
+ };
71
+ var rangeToA1Notation = (range) => {
72
+ return [
73
+ range?.from && addressToA1Notation(range?.from),
74
+ range?.to && addressToA1Notation(range?.to)
75
+ ].filter(Boolean).join(":");
76
+ };
77
+ var inRange = (range, cell) => {
78
+ if (!range) {
79
+ return false;
80
+ }
81
+ const { from, to } = range;
82
+ if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
83
+ return true;
84
+ }
85
+ if (!from || !to) {
86
+ return false;
87
+ }
88
+ const { col: c1, row: r1 } = from;
89
+ const { col: c2, row: r2 } = to;
90
+ const cMin = Math.min(c1, c2);
91
+ const cMax = Math.max(c1, c2);
92
+ const rMin = Math.min(r1, r2);
93
+ const rMax = Math.max(r1, r2);
94
+ const { col, row } = cell;
95
+ return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
96
+ };
97
+
98
+ // packages/plugins/plugin-sheet/src/defs/util.ts
99
+ import { randomBytes } from "@dxos/crypto";
100
+ import { create } from "@dxos/echo-schema";
101
+ var ApiError = class extends Error {
102
+ };
103
+ var ReadonlyException = class extends ApiError {
104
+ };
105
+ var RangeException = class extends ApiError {
106
+ constructor(n) {
107
+ super();
108
+ }
109
+ };
110
+ var createIndex = (length = 8) => {
111
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
112
+ const charactersLength = characters.length;
113
+ const randomBuffer = randomBytes(length);
114
+ return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
115
+ };
116
+ var createIndices = (length) => Array.from({
117
+ length
118
+ }).map(() => createIndex());
119
+ var insertIndices = (indices, i, n, max) => {
120
+ if (i + n > max) {
121
+ throw new RangeException(i + n);
122
+ }
123
+ const idx = createIndices(n);
124
+ indices.splice(i, 0, ...idx);
125
+ };
126
+ var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
127
+ if (!sheet.rows.length) {
128
+ insertIndices(sheet.rows, 0, rows, MAX_ROWS);
129
+ }
130
+ if (!sheet.columns.length) {
131
+ insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
132
+ }
133
+ };
134
+ var createSheet = ({ name, cells, ...size } = {}) => {
135
+ const sheet = create(SheetType, {
136
+ name,
137
+ cells: {},
138
+ rows: [],
139
+ columns: [],
140
+ rowMeta: {},
141
+ columnMeta: {},
142
+ formatting: {}
143
+ });
144
+ initialize(sheet, size);
145
+ if (cells) {
146
+ Object.entries(cells).forEach(([key, { value }]) => {
147
+ const idx = addressToIndex(sheet, addressFromA1Notation(key));
148
+ sheet.cells[idx] = {
149
+ value
150
+ };
151
+ });
152
+ }
153
+ return sheet;
154
+ };
155
+ var addressToIndex = (sheet, cell) => {
156
+ return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
157
+ };
158
+ var addressFromIndex = (sheet, idx) => {
159
+ const [column, row] = idx.split("@");
160
+ return {
161
+ col: sheet.columns.indexOf(column),
162
+ row: sheet.rows.indexOf(row)
163
+ };
164
+ };
165
+ var rangeFromIndex = (sheet, idx) => {
166
+ const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
167
+ return {
168
+ from,
169
+ to
170
+ };
171
+ };
172
+ var closest = (cursor, cells) => {
173
+ let closestCell;
174
+ let closestDistance = Number.MAX_SAFE_INTEGER;
175
+ for (const cell of cells) {
176
+ const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
177
+ if (distance < closestDistance) {
178
+ closestCell = cell;
179
+ closestDistance = distance;
180
+ }
181
+ }
182
+ return closestCell;
183
+ };
184
+ var compareIndexPositions = (sheet, indexA, indexB) => {
185
+ const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
186
+ const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
187
+ if (rowA !== rowB) {
188
+ return rowA - rowB;
189
+ } else {
190
+ return columnA - columnB;
191
+ }
192
+ };
193
+
194
+ // packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
49
195
  var axisWidth = "calc(var(--rail-size)-2px)";
50
196
  var axisHeight = 34;
51
197
  var minWidth = 40;
@@ -87,7 +233,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
87
233
  const left = x;
88
234
  x += width2 - 1;
89
235
  return {
90
- column: i,
236
+ col: i,
91
237
  left,
92
238
  width: width2
93
239
  };
@@ -192,14 +338,14 @@ var handleNav = (ev, cursor, range, size) => {
192
338
  break;
193
339
  }
194
340
  case "ArrowLeft": {
195
- if (opposite.column > 0) {
196
- opposite.column -= 1;
341
+ if (opposite.col > 0) {
342
+ opposite.col -= 1;
197
343
  }
198
344
  break;
199
345
  }
200
346
  case "ArrowRight": {
201
- if (opposite.column < size.numColumns - 1) {
202
- opposite.column += 1;
347
+ if (opposite.col < size.numCols - 1) {
348
+ opposite.col += 1;
203
349
  }
204
350
  break;
205
351
  }
@@ -217,18 +363,18 @@ var handleNav = (ev, cursor, range, size) => {
217
363
  cursor: next
218
364
  };
219
365
  };
220
- var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
366
+ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
221
367
  switch (ev.key) {
222
368
  case "ArrowUp":
223
369
  if (cursor === void 0) {
224
370
  return {
225
371
  row: 0,
226
- column: 0
372
+ col: 0
227
373
  };
228
374
  } else if (cursor.row > 0) {
229
375
  return {
230
376
  row: ev.metaKey ? 0 : cursor.row - 1,
231
- column: cursor.column
377
+ col: cursor.col
232
378
  };
233
379
  }
234
380
  break;
@@ -236,12 +382,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
236
382
  if (cursor === void 0) {
237
383
  return {
238
384
  row: 0,
239
- column: 0
385
+ col: 0
240
386
  };
241
387
  } else if (cursor.row < numRows - 1) {
242
388
  return {
243
389
  row: ev.metaKey ? numRows - 1 : cursor.row + 1,
244
- column: cursor.column
390
+ col: cursor.col
245
391
  };
246
392
  }
247
393
  break;
@@ -249,12 +395,12 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
249
395
  if (cursor === void 0) {
250
396
  return {
251
397
  row: 0,
252
- column: 0
398
+ col: 0
253
399
  };
254
- } else if (cursor.column > 0) {
400
+ } else if (cursor.col > 0) {
255
401
  return {
256
402
  row: cursor.row,
257
- column: ev.metaKey ? 0 : cursor.column - 1
403
+ col: ev.metaKey ? 0 : cursor.col - 1
258
404
  };
259
405
  }
260
406
  break;
@@ -262,24 +408,24 @@ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
262
408
  if (cursor === void 0) {
263
409
  return {
264
410
  row: 0,
265
- column: 0
411
+ col: 0
266
412
  };
267
- } else if (cursor.column < numColumns - 1) {
413
+ } else if (cursor.col < numCols - 1) {
268
414
  return {
269
415
  row: cursor.row,
270
- column: ev.metaKey ? numColumns - 1 : cursor.column + 1
416
+ col: ev.metaKey ? numCols - 1 : cursor.col + 1
271
417
  };
272
418
  }
273
419
  break;
274
420
  case "Home":
275
421
  return {
276
422
  row: 0,
277
- column: 0
423
+ col: 0
278
424
  };
279
425
  case "End":
280
426
  return {
281
427
  row: numRows - 1,
282
- column: numColumns - 1
428
+ col: numCols - 1
283
429
  };
284
430
  }
285
431
  };
@@ -336,14 +482,13 @@ var useRangeSelect = (cb) => {
336
482
  };
337
483
 
338
484
  // packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
339
- import React, { createContext, useContext, useState as useState3, useEffect as useEffect2, useMemo } from "react";
340
- import { invariant } from "@dxos/invariant";
341
- import { fullyQualifiedId } from "@dxos/react-client/echo";
485
+ import React3, { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useState as useState4 } from "react";
486
+ import { invariant as invariant3 } from "@dxos/invariant";
342
487
 
343
488
  // packages/plugins/plugin-sheet/src/components/Sheet/decorations.ts
344
- import { create } from "@dxos/echo-schema";
489
+ import { create as create2 } from "@dxos/echo-schema";
345
490
  var createDecorations = () => {
346
- const { decorations } = create({
491
+ const { decorations } = create2({
347
492
  decorations: {}
348
493
  });
349
494
  const addDecoration = (cellIndex, decorator) => {
@@ -379,27 +524,68 @@ var createDecorations = () => {
379
524
  };
380
525
  };
381
526
 
382
- // packages/plugins/plugin-sheet/src/components/Sheet/formatting.ts
527
+ // packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
528
+ import { useContext } from "react";
529
+ import { raise } from "@dxos/debug";
530
+ import { useAsyncState } from "@dxos/react-hooks";
531
+
532
+ // packages/plugins/plugin-sheet/src/components/index.ts
533
+ import React2 from "react";
534
+
535
+ // packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
536
+ import React, { createContext } from "react";
537
+ var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
538
+ var ComputeGraphContextProvider = ({ registry, children }) => {
539
+ return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
540
+ value: {
541
+ registry
542
+ }
543
+ }, children);
544
+ };
545
+
546
+ // packages/plugins/plugin-sheet/src/components/index.ts
547
+ var SheetContainer = React2.lazy(() => import("./SheetContainer-T2QWJOFD.mjs"));
548
+
549
+ // packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
550
+ var useComputeGraph = (space) => {
551
+ const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
552
+ const [graph] = useAsyncState(async () => {
553
+ if (space) {
554
+ const graph2 = registry.getOrCreateGraph(space);
555
+ await graph2.open();
556
+ return graph2;
557
+ }
558
+ }, [
559
+ space,
560
+ registry
561
+ ]);
562
+ return graph;
563
+ };
564
+
565
+ // packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
566
+ import { useMemo } from "react";
567
+
568
+ // packages/plugins/plugin-sheet/src/model/formatting-model.ts
383
569
  var FormattingModel = class {
384
- constructor(model) {
385
- this.model = model;
570
+ constructor(_model) {
571
+ this._model = _model;
386
572
  }
387
573
  /**
388
574
  * Get formatted string value and className for cell.
389
575
  */
390
576
  getFormatting(cell) {
391
- const value = this.model.getValue(cell);
577
+ const value = this._model.getValue(cell);
392
578
  if (value === void 0 || value === null) {
393
579
  return {};
394
580
  }
395
581
  const locales = void 0;
396
- const idx = addressToIndex(this.model.sheet, cell);
397
- let formatting = this.model.sheet.formatting?.[idx] ?? {};
582
+ const idx = addressToIndex(this._model.sheet, cell);
583
+ let formatting = this._model.sheet.formatting?.[idx] ?? {};
398
584
  const classNames = [
399
585
  ...formatting?.classNames ?? []
400
586
  ];
401
- for (const [idx2, _formatting] of Object.entries(this.model.sheet.formatting)) {
402
- const range = rangeFromIndex(this.model.sheet, idx2);
587
+ for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
588
+ const range = rangeFromIndex(this._model.sheet, idx2);
403
589
  if (inRange(range, cell)) {
404
590
  if (_formatting.classNames) {
405
591
  classNames.push(..._formatting.classNames);
@@ -410,7 +596,7 @@ var FormattingModel = class {
410
596
  }
411
597
  }
412
598
  const defaultNumber = "justify-end font-mono";
413
- const type = formatting?.type ?? this.model.getValueType(cell);
599
+ const type = formatting?.type ?? this._model.getValueType(cell);
414
600
  switch (type) {
415
601
  case ValueTypeEnum.Boolean: {
416
602
  return {
@@ -460,21 +646,21 @@ var FormattingModel = class {
460
646
  // Dates.
461
647
  //
462
648
  case ValueTypeEnum.DateTime: {
463
- const date = this.model.toLocalDate(value);
649
+ const date = this._model.toLocalDate(value);
464
650
  return {
465
651
  value: date.toLocaleString(locales),
466
652
  classNames
467
653
  };
468
654
  }
469
655
  case ValueTypeEnum.Date: {
470
- const date = this.model.toLocalDate(value);
656
+ const date = this._model.toLocalDate(value);
471
657
  return {
472
658
  value: date.toLocaleDateString(locales),
473
659
  classNames
474
660
  };
475
661
  }
476
662
  case ValueTypeEnum.Time: {
477
- const date = this.model.toLocalDate(value);
663
+ const date = this._model.toLocalDate(value);
478
664
  return {
479
665
  value: date.toLocaleTimeString(locales),
480
666
  classNames
@@ -490,85 +676,554 @@ var FormattingModel = class {
490
676
  }
491
677
  };
492
678
 
493
- // packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
494
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
495
- var OBJECT_ID_LENGTH = 60;
496
- var SheetContext = /* @__PURE__ */ createContext(null);
497
- var useSheetContext = () => {
498
- const context = useContext(SheetContext);
499
- invariant(context, void 0, {
500
- F: __dxlog_file,
501
- L: 49,
502
- S: void 0,
503
- A: [
504
- "context",
505
- ""
506
- ]
507
- });
508
- return context;
679
+ // packages/plugins/plugin-sheet/src/model/sheet-model.ts
680
+ import { Event } from "@dxos/async";
681
+ import { Resource } from "@dxos/context";
682
+ import { getTypename } from "@dxos/echo-schema";
683
+ import { invariant as invariant2 } from "@dxos/invariant";
684
+ import { PublicKey } from "@dxos/keys";
685
+ import { log } from "@dxos/log";
686
+ import { DetailedCellError, ExportedCellChange } from "#hyperformula";
687
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
688
+ var typeMap = {
689
+ BOOLEAN: ValueTypeEnum.Boolean,
690
+ NUMBER_RAW: ValueTypeEnum.Number,
691
+ NUMBER_PERCENT: ValueTypeEnum.Percent,
692
+ NUMBER_CURRENCY: ValueTypeEnum.Currency,
693
+ NUMBER_DATETIME: ValueTypeEnum.DateTime,
694
+ NUMBER_DATE: ValueTypeEnum.Date,
695
+ NUMBER_TIME: ValueTypeEnum.Time
509
696
  };
510
- var mapFormulaBindingToId = (functions) => (formula) => {
511
- return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
512
- if (defaultFunctions.find((fn2) => fn2.name === binding) || binding === "EDGE") {
513
- return match;
697
+ var getTopLeft = (range) => {
698
+ const to = range.to ?? range.from;
699
+ return {
700
+ row: Math.min(range.from.row, to.row),
701
+ col: Math.min(range.from.col, to.col)
702
+ };
703
+ };
704
+ var toSimpleCellAddress = (sheet, cell) => ({
705
+ sheet,
706
+ row: cell.row,
707
+ col: cell.col
708
+ });
709
+ var toModelRange = (sheet, range) => ({
710
+ start: toSimpleCellAddress(sheet, range.from),
711
+ end: toSimpleCellAddress(sheet, range.to ?? range.from)
712
+ });
713
+ var SheetModel = class extends Resource {
714
+ constructor(_graph, _sheet, _options = {}) {
715
+ super();
716
+ this._graph = _graph;
717
+ this._sheet = _sheet;
718
+ this._options = _options;
719
+ this.id = `model-${PublicKey.random().truncate()}`;
720
+ this.update = new Event();
721
+ }
722
+ get graph() {
723
+ return this._graph;
724
+ }
725
+ get sheet() {
726
+ return this._sheet;
727
+ }
728
+ get readonly() {
729
+ return this._options.readonly;
730
+ }
731
+ get bounds() {
732
+ return {
733
+ rows: this._sheet.rows.length,
734
+ columns: this._sheet.columns.length
735
+ };
736
+ }
737
+ /**
738
+ * Initialize sheet and engine.
739
+ */
740
+ async _open() {
741
+ log("initialize", {
742
+ id: this.id
743
+ }, {
744
+ F: __dxlog_file2,
745
+ L: 104,
746
+ S: this,
747
+ C: (f, a) => f(...a)
748
+ });
749
+ initialize(this._sheet);
750
+ this._node = this._graph.getOrCreateNode(createSheetName({
751
+ type: getTypename(this._sheet),
752
+ id: this._sheet.id
753
+ }));
754
+ await this._node.open();
755
+ const unsubscribe = this._node.update.on((event) => this.update.emit(event));
756
+ this._ctx.onDispose(unsubscribe);
757
+ this.reset();
758
+ }
759
+ /**
760
+ * Update engine.
761
+ * NOTE: This resets the undo history.
762
+ * @deprecated
763
+ */
764
+ reset() {
765
+ invariant2(this._node, void 0, {
766
+ F: __dxlog_file2,
767
+ L: 124,
768
+ S: this,
769
+ A: [
770
+ "this._node",
771
+ ""
772
+ ]
773
+ });
774
+ this._node.graph.hf.clearSheet(this._node.sheetId);
775
+ Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
776
+ invariant2(this._node, void 0, {
777
+ F: __dxlog_file2,
778
+ L: 127,
779
+ S: this,
780
+ A: [
781
+ "this._node",
782
+ ""
783
+ ]
784
+ });
785
+ const { col, row } = addressFromIndex(this._sheet, key);
786
+ if (typeof value === "string" && value.charAt(0) === "=") {
787
+ value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
788
+ }
789
+ this._node.graph.hf.setCellContents({
790
+ sheet: this._node.sheetId,
791
+ row,
792
+ col
793
+ }, value);
794
+ });
795
+ }
796
+ /**
797
+ * Recalculate formulas.
798
+ * NOTE: This resets the undo history.
799
+ * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
800
+ * @deprecated
801
+ */
802
+ // TODO(burdon): Remove.
803
+ recalculate() {
804
+ this._node?.graph.hf.rebuildAndRecalculate();
805
+ }
806
+ insertRows(i, n = 1) {
807
+ insertIndices(this._sheet.rows, i, n, MAX_ROWS);
808
+ this.reset();
809
+ }
810
+ insertColumns(i, n = 1) {
811
+ insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
812
+ this.reset();
813
+ }
814
+ //
815
+ // Undoable actions.
816
+ // TODO(burdon): Group undoable methods; consistently update hf/sheet.
817
+ //
818
+ /**
819
+ * Clear range of values.
820
+ */
821
+ clear(range) {
822
+ invariant2(this._node, void 0, {
823
+ F: __dxlog_file2,
824
+ L: 169,
825
+ S: this,
826
+ A: [
827
+ "this._node",
828
+ ""
829
+ ]
830
+ });
831
+ const topLeft = getTopLeft(range);
832
+ const values = this._iterRange(range, () => null);
833
+ this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
834
+ this._iterRange(range, (cell) => {
835
+ const idx = addressToIndex(this._sheet, cell);
836
+ delete this._sheet.cells[idx];
837
+ });
838
+ }
839
+ cut(range) {
840
+ invariant2(this._node, void 0, {
841
+ F: __dxlog_file2,
842
+ L: 180,
843
+ S: this,
844
+ A: [
845
+ "this._node",
846
+ ""
847
+ ]
848
+ });
849
+ this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
850
+ this._iterRange(range, (cell) => {
851
+ const idx = addressToIndex(this._sheet, cell);
852
+ delete this._sheet.cells[idx];
853
+ });
854
+ }
855
+ copy(range) {
856
+ invariant2(this._node, void 0, {
857
+ F: __dxlog_file2,
858
+ L: 189,
859
+ S: this,
860
+ A: [
861
+ "this._node",
862
+ ""
863
+ ]
864
+ });
865
+ this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
866
+ }
867
+ paste(cell) {
868
+ invariant2(this._node, void 0, {
869
+ F: __dxlog_file2,
870
+ L: 194,
871
+ S: this,
872
+ A: [
873
+ "this._node",
874
+ ""
875
+ ]
876
+ });
877
+ if (!this._node.graph.hf.isClipboardEmpty()) {
878
+ const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
879
+ for (const change of changes) {
880
+ if (change instanceof ExportedCellChange) {
881
+ const { address, newValue } = change;
882
+ const idx = addressToIndex(this._sheet, {
883
+ row: address.row,
884
+ col: address.col
885
+ });
886
+ this._sheet.cells[idx] = {
887
+ value: newValue
888
+ };
889
+ }
890
+ }
891
+ }
892
+ }
893
+ // TODO(burdon): Display undo/redo state.
894
+ undo() {
895
+ invariant2(this._node, void 0, {
896
+ F: __dxlog_file2,
897
+ L: 209,
898
+ S: this,
899
+ A: [
900
+ "this._node",
901
+ ""
902
+ ]
903
+ });
904
+ if (this._node.graph.hf.isThereSomethingToUndo()) {
905
+ this._node.graph.hf.undo();
514
906
  }
515
- const fn = functions.find((fn2) => fn2.binding === binding);
516
- if (fn) {
517
- return `${fullyQualifiedId(fn)}(${args})`;
907
+ }
908
+ redo() {
909
+ invariant2(this._node, void 0, {
910
+ F: __dxlog_file2,
911
+ L: 217,
912
+ S: this,
913
+ A: [
914
+ "this._node",
915
+ ""
916
+ ]
917
+ });
918
+ if (this._node.graph.hf.isThereSomethingToRedo()) {
919
+ this._node.graph.hf.redo();
920
+ }
921
+ }
922
+ /**
923
+ * Get value from sheet.
924
+ */
925
+ getCellValue(cell) {
926
+ const idx = addressToIndex(this._sheet, cell);
927
+ return this._sheet.cells[idx]?.value ?? null;
928
+ }
929
+ /**
930
+ * Get value as a string for editing.
931
+ */
932
+ getCellText(cell) {
933
+ const value = this.getCellValue(cell);
934
+ if (value == null) {
935
+ return void 0;
936
+ }
937
+ if (typeof value === "string" && value.charAt(0) === "=") {
938
+ return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
518
939
  } else {
519
- return match;
940
+ return String(value);
520
941
  }
521
- });
522
- };
523
- var mapFormulaBindingFromId = (functions) => (formula) => {
524
- return formula.replace(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
525
- const id = `${spaceId}:${objectId}`;
526
- if (id.length !== OBJECT_ID_LENGTH) {
527
- return match;
942
+ }
943
+ /**
944
+ * Get array of raw values from sheet.
945
+ */
946
+ getCellValues(range) {
947
+ return this._iterRange(range, (cell) => this.getCellValue(cell));
948
+ }
949
+ /**
950
+ * Gets the regular or computed value from the engine.
951
+ */
952
+ getValue(cell) {
953
+ invariant2(this._node, void 0, {
954
+ F: __dxlog_file2,
955
+ L: 260,
956
+ S: this,
957
+ A: [
958
+ "this._node",
959
+ ""
960
+ ]
961
+ });
962
+ const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
963
+ if (value instanceof DetailedCellError) {
964
+ return value.toString();
965
+ }
966
+ return value;
967
+ }
968
+ /**
969
+ * Get value type.
970
+ */
971
+ getValueType(cell) {
972
+ invariant2(this._node, void 0, {
973
+ F: __dxlog_file2,
974
+ L: 273,
975
+ S: this,
976
+ A: [
977
+ "this._node",
978
+ ""
979
+ ]
980
+ });
981
+ const addr = toSimpleCellAddress(this._node.sheetId, cell);
982
+ const type = this._node.graph.hf.getCellValueDetailedType(addr);
983
+ return typeMap[type];
984
+ }
985
+ /**
986
+ * Sets the value, updating the sheet and engine.
987
+ */
988
+ setValue(cell, value) {
989
+ invariant2(this._node, void 0, {
990
+ F: __dxlog_file2,
991
+ L: 283,
992
+ S: this,
993
+ A: [
994
+ "this._node",
995
+ ""
996
+ ]
997
+ });
998
+ if (this._options.readonly) {
999
+ throw new ReadonlyException();
1000
+ }
1001
+ let refresh = false;
1002
+ if (cell.row >= this._sheet.rows.length) {
1003
+ insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
1004
+ refresh = true;
1005
+ }
1006
+ if (cell.col >= this._sheet.columns.length) {
1007
+ insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
1008
+ refresh = true;
528
1009
  }
529
- const fn = functions.find((fn2) => fullyQualifiedId(fn2) === id);
530
- if (fn?.binding) {
531
- return `${fn.binding}(${args})`;
1010
+ if (refresh) {
1011
+ this.reset();
1012
+ }
1013
+ this._node.graph.hf.setCellContents({
1014
+ sheet: this._node.sheetId,
1015
+ row: cell.row,
1016
+ col: cell.col
1017
+ }, [
1018
+ [
1019
+ typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
1020
+ ]
1021
+ ]);
1022
+ const idx = addressToIndex(this._sheet, cell);
1023
+ if (value === void 0 || value === null) {
1024
+ delete this._sheet.cells[idx];
532
1025
  } else {
533
- return match;
1026
+ if (typeof value === "string" && value.charAt(0) === "=") {
1027
+ value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
1028
+ }
1029
+ this._sheet.cells[idx] = {
1030
+ value
1031
+ };
534
1032
  }
535
- });
1033
+ }
1034
+ /**
1035
+ * Sets values from a simple map.
1036
+ */
1037
+ setValues(values) {
1038
+ Object.entries(values).forEach(([key, { value }]) => {
1039
+ this.setValue(addressFromA1Notation(key), value);
1040
+ });
1041
+ }
1042
+ /**
1043
+ * Iterate range.
1044
+ */
1045
+ _iterRange(range, cb) {
1046
+ const to = range.to ?? range.from;
1047
+ const rowRange = [
1048
+ Math.min(range.from.row, to.row),
1049
+ Math.max(range.from.row, to.row)
1050
+ ];
1051
+ const columnRange = [
1052
+ Math.min(range.from.col, to.col),
1053
+ Math.max(range.from.col, to.col)
1054
+ ];
1055
+ const rows = [];
1056
+ for (let row = rowRange[0]; row <= rowRange[1]; row++) {
1057
+ const rowCells = [];
1058
+ for (let column = columnRange[0]; column <= columnRange[1]; column++) {
1059
+ const value = cb({
1060
+ row,
1061
+ col: column
1062
+ });
1063
+ if (value !== void 0) {
1064
+ rowCells.push(value);
1065
+ }
1066
+ }
1067
+ rows.push(rowCells);
1068
+ }
1069
+ return rows;
1070
+ }
1071
+ // TODO(burdon): Delete index.
1072
+ _deleteIndices(indices, i, n) {
1073
+ throw new Error("Not implemented");
1074
+ }
1075
+ // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
1076
+ _moveIndices(indices, i, j, n) {
1077
+ throw new Error("Not implemented");
1078
+ }
1079
+ //
1080
+ // Indices.
1081
+ //
1082
+ /**
1083
+ * Map from A1 notation to indices.
1084
+ */
1085
+ mapFormulaRefsToIndices(formula) {
1086
+ invariant2(formula.charAt(0) === "=", void 0, {
1087
+ F: __dxlog_file2,
1088
+ L: 372,
1089
+ S: this,
1090
+ A: [
1091
+ "formula.charAt(0) === '='",
1092
+ ""
1093
+ ]
1094
+ });
1095
+ return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
1096
+ return addressToIndex(this._sheet, addressFromA1Notation(match));
1097
+ });
1098
+ }
1099
+ /**
1100
+ * Map from indices to A1 notation.
1101
+ */
1102
+ mapFormulaIndicesToRefs(formula) {
1103
+ invariant2(formula.charAt(0) === "=", void 0, {
1104
+ F: __dxlog_file2,
1105
+ L: 382,
1106
+ S: this,
1107
+ A: [
1108
+ "formula.charAt(0) === '='",
1109
+ ""
1110
+ ]
1111
+ });
1112
+ return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
1113
+ return addressToA1Notation(addressFromIndex(this._sheet, idx));
1114
+ });
1115
+ }
1116
+ //
1117
+ // Values
1118
+ //
1119
+ /**
1120
+ * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
1121
+ * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
1122
+ * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
1123
+ */
1124
+ toLocalDate(num) {
1125
+ const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
1126
+ return new Date(year, month - 1, day, hours, minutes, seconds);
1127
+ }
1128
+ toDateTime(num) {
1129
+ invariant2(this._node, void 0, {
1130
+ F: __dxlog_file2,
1131
+ L: 403,
1132
+ S: this,
1133
+ A: [
1134
+ "this._node",
1135
+ ""
1136
+ ]
1137
+ });
1138
+ return this._node.graph.hf.numberToDateTime(num);
1139
+ }
1140
+ toDate(num) {
1141
+ invariant2(this._node, void 0, {
1142
+ F: __dxlog_file2,
1143
+ L: 408,
1144
+ S: this,
1145
+ A: [
1146
+ "this._node",
1147
+ ""
1148
+ ]
1149
+ });
1150
+ return this._node.graph.hf.numberToDate(num);
1151
+ }
1152
+ toTime(num) {
1153
+ invariant2(this._node, void 0, {
1154
+ F: __dxlog_file2,
1155
+ L: 413,
1156
+ S: this,
1157
+ A: [
1158
+ "this._node",
1159
+ ""
1160
+ ]
1161
+ });
1162
+ return this._node.graph.hf.numberToTime(num);
1163
+ }
1164
+ };
1165
+
1166
+ // packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
1167
+ var useFormattingModel = (model) => {
1168
+ return useMemo(() => model && new FormattingModel(model), [
1169
+ model
1170
+ ]);
536
1171
  };
537
- var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...options }) => {
538
- const graph = useComputeGraph(space, options);
539
- const [cursor, setCursor] = useState3();
540
- const [range, setRange] = useState3();
541
- const [editing, setEditing] = useState3(false);
542
- const decorations = useMemo(() => createDecorations(), []);
543
- const [[model, formatting] = [], setModels] = useState3(void 0);
1172
+
1173
+ // packages/plugins/plugin-sheet/src/hooks/useSheetModel.ts
1174
+ import { useEffect as useEffect2, useState as useState3 } from "react";
1175
+ var useSheetModel = (graph, sheet, { readonly } = {}) => {
1176
+ const [model, setModel] = useState3();
544
1177
  useEffect2(() => {
1178
+ if (!graph || !sheet) {
1179
+ return;
1180
+ }
545
1181
  let model2;
546
- let formatting2;
547
1182
  const t = setTimeout(async () => {
548
- model2 = new SheetModel(graph, sheet, space, {
549
- readonly,
550
- mapFormulaBindingToId,
551
- mapFormulaBindingFromId
1183
+ model2 = new SheetModel(graph, sheet, {
1184
+ readonly
552
1185
  });
553
- await model2.initialize();
554
- formatting2 = new FormattingModel(model2);
555
- setModels([
556
- model2,
557
- formatting2
558
- ]);
1186
+ await model2.open();
1187
+ setModel(model2);
559
1188
  });
560
1189
  return () => {
561
1190
  clearTimeout(t);
562
- void model2?.destroy();
1191
+ void model2?.close();
563
1192
  };
564
1193
  }, [
565
1194
  graph,
1195
+ sheet,
566
1196
  readonly
567
1197
  ]);
568
- if (!model || !formatting) {
569
- return null;
570
- }
571
- return /* @__PURE__ */ React.createElement(SheetContext.Provider, {
1198
+ return model;
1199
+ };
1200
+
1201
+ // packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
1202
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
1203
+ var SheetContext = /* @__PURE__ */ createContext2(null);
1204
+ var useSheetContext = () => {
1205
+ const context = useContext2(SheetContext);
1206
+ invariant3(context, void 0, {
1207
+ F: __dxlog_file3,
1208
+ L: 43,
1209
+ S: void 0,
1210
+ A: [
1211
+ "context",
1212
+ ""
1213
+ ]
1214
+ });
1215
+ return context;
1216
+ };
1217
+ var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
1218
+ const model = useSheetModel(graph, sheet, {
1219
+ readonly
1220
+ });
1221
+ const formatting = useFormattingModel(model);
1222
+ const [cursor, setCursor] = useState4();
1223
+ const [range, setRange] = useState4();
1224
+ const [editing, setEditing] = useState4(false);
1225
+ const decorations = useMemo2(() => createDecorations(), []);
1226
+ return !model || !formatting ? null : /* @__PURE__ */ React3.createElement(SheetContext.Provider, {
572
1227
  value: {
573
1228
  model,
574
1229
  formatting,
@@ -587,23 +1242,22 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...optio
587
1242
 
588
1243
  // packages/plugins/plugin-sheet/src/components/Sheet/threads.tsx
589
1244
  import { effect } from "@preact/signals-core";
590
- import React2, { useCallback, useEffect as useEffect3, useMemo as useMemo2 } from "react";
1245
+ import React4, { useCallback, useEffect as useEffect3, useMemo as useMemo3 } from "react";
591
1246
  import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
592
1247
  import { debounce } from "@dxos/async";
593
- import { fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
1248
+ import { fullyQualifiedId } from "@dxos/react-client/echo";
594
1249
  import { Icon, useTranslation } from "@dxos/react-ui";
595
- import { mx } from "@dxos/react-ui-theme";
596
1250
  var CommentIndicator = () => {
597
- return /* @__PURE__ */ React2.createElement("div", {
1251
+ return /* @__PURE__ */ React4.createElement("div", {
598
1252
  role: "none",
599
1253
  className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
600
1254
  });
601
1255
  };
602
1256
  var ThreadedCellWrapper = ({ children }) => {
603
1257
  const dispatch = useIntentDispatcher();
604
- const [isHovered, setIsHovered] = React2.useState(true);
1258
+ const [isHovered, setIsHovered] = React4.useState(false);
605
1259
  const { t } = useTranslation(SHEET_PLUGIN);
606
- const handleClick = React2.useCallback((_event) => {
1260
+ const handleClick = React4.useCallback((_event) => {
607
1261
  void dispatch({
608
1262
  action: LayoutAction.SET_LAYOUT,
609
1263
  data: {
@@ -614,22 +1268,22 @@ var ThreadedCellWrapper = ({ children }) => {
614
1268
  }, [
615
1269
  dispatch
616
1270
  ]);
617
- return /* @__PURE__ */ React2.createElement("div", {
1271
+ return /* @__PURE__ */ React4.createElement("div", {
618
1272
  role: "none",
619
- className: mx("relative h-full is-full"),
1273
+ className: "relative h-full is-full",
620
1274
  onMouseEnter: () => {
621
1275
  setIsHovered(true);
622
1276
  },
623
1277
  onMouseLeave: () => {
624
1278
  setIsHovered(false);
625
1279
  }
626
- }, /* @__PURE__ */ React2.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ React2.createElement("div", {
1280
+ }, /* @__PURE__ */ React4.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ React4.createElement("div", {
627
1281
  className: "absolute inset-0 flex items-center justify-end pr-1"
628
- }, /* @__PURE__ */ React2.createElement("button", {
1282
+ }, /* @__PURE__ */ React4.createElement("button", {
629
1283
  className: "ch-button text-xs min-bs-0 p-1",
630
1284
  onClick: handleClick,
631
1285
  "aria-label": t("open comment for sheet cell")
632
- }, /* @__PURE__ */ React2.createElement(Icon, {
1286
+ }, /* @__PURE__ */ React4.createElement(Icon, {
633
1287
  icon: "ph--chat--regular",
634
1288
  "aria-hidden": true
635
1289
  }))), children);
@@ -638,7 +1292,7 @@ var createThreadDecoration = (cellIndex, threadId, sheetId) => {
638
1292
  return {
639
1293
  type: "comment",
640
1294
  cellIndex,
641
- decorate: (props) => /* @__PURE__ */ React2.createElement(ThreadedCellWrapper, props)
1295
+ decorate: (props) => /* @__PURE__ */ React4.createElement(ThreadedCellWrapper, props)
642
1296
  };
643
1297
  };
644
1298
  var useUpdateCursorOnThreadSelection = () => {
@@ -646,7 +1300,7 @@ var useUpdateCursorOnThreadSelection = () => {
646
1300
  const handleScrollIntoView = useCallback(({ action, data }) => {
647
1301
  switch (action) {
648
1302
  case LayoutAction.SCROLL_INTO_VIEW: {
649
- if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId2(model.sheet)) {
1303
+ if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId(model.sheet)) {
650
1304
  return;
651
1305
  }
652
1306
  const cellAddress = addressFromIndex(model.sheet, data.cursor);
@@ -662,10 +1316,10 @@ var useUpdateCursorOnThreadSelection = () => {
662
1316
  var useSelectThreadOnCursorChange = () => {
663
1317
  const { cursor, model } = useSheetContext();
664
1318
  const dispatch = useIntentDispatcher();
665
- const activeThreads = useMemo2(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
1319
+ const activeThreads = useMemo3(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
666
1320
  JSON.stringify(model.sheet.threads)
667
1321
  ]);
668
- const activeThreadAddresses = useMemo2(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
1322
+ const activeThreadAddresses = useMemo3(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
669
1323
  activeThreads,
670
1324
  model.sheet
671
1325
  ]);
@@ -681,7 +1335,7 @@ var useSelectThreadOnCursorChange = () => {
681
1335
  {
682
1336
  action: "dxos.org/plugin/thread/action/select",
683
1337
  data: {
684
- current: fullyQualifiedId2(closestThread)
1338
+ current: fullyQualifiedId(closestThread)
685
1339
  }
686
1340
  }
687
1341
  ]);
@@ -693,7 +1347,7 @@ var useSelectThreadOnCursorChange = () => {
693
1347
  activeThreadAddresses,
694
1348
  model.sheet
695
1349
  ]);
696
- const debounced = useMemo2(() => {
1350
+ const debounced = useMemo3(() => {
697
1351
  return debounce((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
698
1352
  }, [
699
1353
  selectClosestThread
@@ -710,10 +1364,10 @@ var useSelectThreadOnCursorChange = () => {
710
1364
  };
711
1365
  var useThreadDecorations = () => {
712
1366
  const { decorations, model } = useSheetContext();
713
- const sheet = useMemo2(() => model.sheet, [
1367
+ const sheet = useMemo3(() => model.sheet, [
714
1368
  model.sheet
715
1369
  ]);
716
- const sheetId = useMemo2(() => fullyQualifiedId2(sheet), [
1370
+ const sheetId = useMemo3(() => fullyQualifiedId(sheet), [
717
1371
  sheet
718
1372
  ]);
719
1373
  useEffect3(() => {
@@ -786,7 +1440,7 @@ var scrollIntoView = (scrollContainer, el) => {
786
1440
 
787
1441
  // packages/plugins/plugin-sheet/src/components/CellEditor/CellEditor.tsx
788
1442
  import { EditorView, keymap } from "@codemirror/view";
789
- import React3 from "react";
1443
+ import React5 from "react";
790
1444
  import { useThemeContext } from "@dxos/react-ui";
791
1445
  import { createBasicExtensions, createThemeExtensions, preventNewline, useTextEditor } from "@dxos/react-ui-editor";
792
1446
  var editorKeys = ({ onNav, onClose }) => {
@@ -834,20 +1488,60 @@ var editorKeys = ({ onNav, onClose }) => {
834
1488
  {
835
1489
  key: "Enter",
836
1490
  run: (editor) => {
837
- onClose(editor.state.doc.toString());
1491
+ onClose(editor.state.doc.toString(), {
1492
+ key: "Enter"
1493
+ });
1494
+ return true;
1495
+ },
1496
+ shift: (editor) => {
1497
+ onClose(editor.state.doc.toString(), {
1498
+ key: "Enter",
1499
+ shift: true
1500
+ });
1501
+ return true;
1502
+ }
1503
+ },
1504
+ {
1505
+ key: "Tab",
1506
+ run: (editor) => {
1507
+ onClose(editor.state.doc.toString(), {
1508
+ key: "Tab"
1509
+ });
1510
+ return true;
1511
+ },
1512
+ shift: (editor) => {
1513
+ onClose(editor.state.doc.toString(), {
1514
+ key: "Tab",
1515
+ shift: true
1516
+ });
838
1517
  return true;
839
1518
  }
840
1519
  },
841
1520
  {
842
1521
  key: "Escape",
843
1522
  run: () => {
844
- onClose(void 0);
1523
+ onClose(void 0, {
1524
+ key: "Escape"
1525
+ });
845
1526
  return true;
846
1527
  }
847
1528
  }
848
1529
  ]);
849
1530
  };
850
- var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
1531
+ var editorVariants = {
1532
+ // TODO(thure): remove when legacy is no longer used.
1533
+ legacy: {
1534
+ root: "flex w-full",
1535
+ editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
1536
+ content: "!px-2 !py-1"
1537
+ },
1538
+ grid: {
1539
+ root: "absolute z-[1]",
1540
+ editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
1541
+ content: "!border !border-transparent !p-0.5"
1542
+ }
1543
+ };
1544
+ var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
851
1545
  const { themeMode } = useThemeContext();
852
1546
  const { parentRef } = useTextEditor(() => {
853
1547
  return {
@@ -874,32 +1568,40 @@ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
874
1568
  themeMode,
875
1569
  slots: {
876
1570
  editor: {
877
- className: "flex w-full [&>.cm-scroller]:scrollbar-none"
1571
+ className: editorVariants[variant].editor
878
1572
  },
879
1573
  content: {
880
- className: "!px-2 !py-1"
1574
+ className: editorVariants[variant].content
881
1575
  }
882
1576
  }
883
1577
  })
884
1578
  ]
885
1579
  };
886
1580
  }, [
887
- extension
1581
+ extension,
1582
+ autoFocus,
1583
+ value,
1584
+ variant,
1585
+ onBlur
888
1586
  ]);
889
- return /* @__PURE__ */ React3.createElement("div", {
1587
+ return /* @__PURE__ */ React5.createElement("div", {
890
1588
  ref: parentRef,
891
- className: "flex w-full"
1589
+ className: editorVariants[variant].root,
1590
+ style: box,
1591
+ ...gridId && {
1592
+ "data-grid": gridId
1593
+ }
892
1594
  });
893
1595
  };
894
1596
 
895
1597
  // packages/plugins/plugin-sheet/src/components/CellEditor/extension.ts
896
1598
  import { acceptCompletion, autocompletion, completionStatus, startCompletion } from "@codemirror/autocomplete";
897
1599
  import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
898
- import { Facet } from "@codemirror/state";
899
1600
  import { ViewPlugin, keymap as keymap2 } from "@codemirror/view";
900
1601
  import { tags } from "@lezer/highlight";
901
1602
  import { spreadsheet } from "codemirror-lang-spreadsheet";
902
- import { mx as mx2 } from "@dxos/react-ui-theme";
1603
+ import { singleValueFacet } from "@dxos/react-ui-editor/state";
1604
+ import { mx } from "@dxos/react-ui-theme";
903
1605
  var highlightStyles = HighlightStyle.define([
904
1606
  // Function.
905
1607
  {
@@ -930,7 +1632,7 @@ var highlightStyles = HighlightStyle.define([
930
1632
  class: "text-unAccent"
931
1633
  }
932
1634
  ]);
933
- var languageFacet = Facet.define();
1635
+ var languageFacet = singleValueFacet();
934
1636
  var sheetExtension = ({ functions = [] }) => {
935
1637
  const { extension, language } = spreadsheet({
936
1638
  idiom: "en-US",
@@ -1010,13 +1712,7 @@ var sheetExtension = ({ functions = [] }) => {
1010
1712
  // NOTE: Useful for debugging.
1011
1713
  closeOnBlur: false,
1012
1714
  icons: false,
1013
- tooltipClass: () => mx2(
1014
- // TODO(burdon): Factor out fragments.
1015
- // TODO(burdon): Size to make width same as column.
1016
- "!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
1017
- "[&>ul>li[aria-selected]]:!bg-accentSurface",
1018
- "border-separator"
1019
- )
1715
+ tooltipClass: () => mx("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
1020
1716
  }),
1021
1717
  keymap2.of([
1022
1718
  {
@@ -1053,7 +1749,7 @@ var rangeExtension = (onInit) => {
1053
1749
  update(view2) {
1054
1750
  const { anchor } = view2.state.selection.ranges[0];
1055
1751
  activeRange = void 0;
1056
- const [language] = view2.state.facet(languageFacet);
1752
+ const language = view2.state.facet(languageFacet);
1057
1753
  const { topNode } = language.parser.parse(view2.state.doc.toString());
1058
1754
  visitTree(topNode, ({ type, from, to }) => {
1059
1755
  if (from <= anchor && to >= anchor) {
@@ -1105,7 +1801,7 @@ var visitTree = (node, callback) => {
1105
1801
  };
1106
1802
 
1107
1803
  // packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
1108
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
1804
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
1109
1805
  var fragments = {
1110
1806
  axis: "bg-axisSurface text-axisText text-xs select-none",
1111
1807
  axisSelected: "bg-attention text-baseText",
@@ -1113,16 +1809,16 @@ var fragments = {
1113
1809
  cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
1114
1810
  };
1115
1811
  var SheetRoot = ({ children, ...props }) => {
1116
- return /* @__PURE__ */ React4.createElement(SheetContextProvider, props, children);
1812
+ return /* @__PURE__ */ React6.createElement(SheetContextProvider, props, children);
1117
1813
  };
1118
- var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns }, forwardRef2) => {
1814
+ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, forwardRef2) => {
1119
1815
  const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
1120
1816
  const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
1121
1817
  useThreads();
1122
- const [rows, setRows] = useState4([
1818
+ const [rows, setRows] = useState5([
1123
1819
  ...model.sheet.rows
1124
1820
  ]);
1125
- const [columns, setColumns] = useState4([
1821
+ const [columns, setColumns] = useState5([
1126
1822
  ...model.sheet.columns
1127
1823
  ]);
1128
1824
  useEffect4(() => {
@@ -1178,8 +1874,8 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
1178
1874
  ...model.sheet.columns
1179
1875
  ]);
1180
1876
  };
1181
- const [rowSizes, setRowSizes] = useState4();
1182
- const [columnSizes, setColumnSizes] = useState4();
1877
+ const [rowSizes, setRowSizes] = useState5();
1878
+ const [columnSizes, setColumnSizes] = useState5();
1183
1879
  useEffect4(() => {
1184
1880
  const rowAccessor = createDocAccessor(model.sheet, [
1185
1881
  "rowMeta"
@@ -1229,48 +1925,48 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns },
1229
1925
  }));
1230
1926
  }
1231
1927
  };
1232
- return /* @__PURE__ */ React4.createElement("div", {
1928
+ return /* @__PURE__ */ React6.createElement("div", {
1233
1929
  role: "none",
1234
- className: mx3("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
1235
- }, /* @__PURE__ */ React4.createElement(GridCorner, {
1930
+ className: mx2("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
1931
+ }, /* @__PURE__ */ React6.createElement(GridCorner, {
1236
1932
  onClick: () => {
1237
1933
  setCursor(void 0);
1238
1934
  setRange(void 0);
1239
1935
  setEditing(false);
1240
1936
  }
1241
- }), /* @__PURE__ */ React4.createElement(SheetColumns, {
1937
+ }), /* @__PURE__ */ React6.createElement(SheetColumns, {
1242
1938
  ref: columnsRef,
1243
1939
  columns,
1244
1940
  sizes: columnSizes,
1245
- selected: cursor?.column,
1246
- onSelect: (column) => setCursor(cursor?.column === column ? void 0 : {
1941
+ selected: cursor?.col,
1942
+ onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
1247
1943
  row: -1,
1248
- column
1944
+ col
1249
1945
  }),
1250
1946
  onResize: handleResizeColumn,
1251
1947
  onMove: handleMoveColumns
1252
- }), /* @__PURE__ */ React4.createElement(SheetRows, {
1948
+ }), /* @__PURE__ */ React6.createElement(SheetRows, {
1253
1949
  ref: rowsRef,
1254
1950
  rows,
1255
1951
  sizes: rowSizes,
1256
1952
  selected: cursor?.row,
1257
1953
  onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
1258
1954
  row,
1259
- column: -1
1955
+ col: -1
1260
1956
  }),
1261
1957
  onResize: handleResizeRow,
1262
1958
  onMove: handleMoveRows
1263
- }), /* @__PURE__ */ React4.createElement(SheetGrid, {
1959
+ }), /* @__PURE__ */ React6.createElement(SheetGrid, {
1264
1960
  ref: contentRef,
1265
1961
  size: {
1266
1962
  numRows: numRows ?? rows.length,
1267
- numColumns: numColumns ?? columns.length
1963
+ numCols: numCols ?? columns.length
1268
1964
  },
1269
1965
  rows,
1270
1966
  columns,
1271
1967
  rowSizes,
1272
1968
  columnSizes
1273
- }), /* @__PURE__ */ React4.createElement(GridCorner, null), /* @__PURE__ */ React4.createElement(SheetStatusBar, null));
1969
+ }), /* @__PURE__ */ React6.createElement(GridCorner, null), /* @__PURE__ */ React6.createElement(SheetStatusBar, null));
1274
1970
  });
1275
1971
  var useScrollHandlers = () => {
1276
1972
  const rowsRef = useRef(null);
@@ -1313,13 +2009,13 @@ var useScrollHandlers = () => {
1313
2009
  };
1314
2010
  };
1315
2011
  var GridCorner = (props) => {
1316
- return /* @__PURE__ */ React4.createElement("div", {
2012
+ return /* @__PURE__ */ React6.createElement("div", {
1317
2013
  className: fragments.axis,
1318
2014
  ...props
1319
2015
  });
1320
2016
  };
1321
2017
  var MovingOverlay = ({ label }) => {
1322
- return /* @__PURE__ */ React4.createElement("div", {
2018
+ return /* @__PURE__ */ React6.createElement("div", {
1323
2019
  className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
1324
2020
  }, label);
1325
2021
  };
@@ -1339,7 +2035,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1339
2035
  });
1340
2036
  const keyboardSensor = useSensor(KeyboardSensor, {});
1341
2037
  const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
1342
- const [active, setActive] = useState4(null);
2038
+ const [active, setActive] = useState5(null);
1343
2039
  const handleDragStart = ({ active: active2 }) => {
1344
2040
  setActive(active2);
1345
2041
  };
@@ -1363,18 +2059,18 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1363
2059
  }
1364
2060
  return transform;
1365
2061
  };
1366
- return /* @__PURE__ */ React4.createElement("div", {
2062
+ return /* @__PURE__ */ React6.createElement("div", {
1367
2063
  className: "relative flex grow overflow-hidden"
1368
- }, /* @__PURE__ */ React4.createElement("div", {
1369
- className: mx3("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
2064
+ }, /* @__PURE__ */ React6.createElement("div", {
2065
+ className: mx2("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
1370
2066
  style: {
1371
2067
  width: axisWidth
1372
2068
  }
1373
- }), /* @__PURE__ */ React4.createElement("div", {
2069
+ }), /* @__PURE__ */ React6.createElement("div", {
1374
2070
  ref: forwardRef2,
1375
2071
  role: "rowheader",
1376
2072
  className: "grow overflow-y-auto scrollbar-none"
1377
- }, /* @__PURE__ */ React4.createElement(DndContext, {
2073
+ }, /* @__PURE__ */ React6.createElement(DndContext, {
1378
2074
  sensors,
1379
2075
  modifiers: [
1380
2076
  restrictToVerticalAxis,
@@ -1382,12 +2078,12 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1382
2078
  ],
1383
2079
  onDragStart: handleDragStart,
1384
2080
  onDragEnd: handleDragEnd
1385
- }, /* @__PURE__ */ React4.createElement("div", {
2081
+ }, /* @__PURE__ */ React6.createElement("div", {
1386
2082
  className: "flex flex-col",
1387
2083
  style: {
1388
2084
  width: axisWidth
1389
2085
  }
1390
- }, rows.map((idx, index) => /* @__PURE__ */ React4.createElement(GridRowCell, {
2086
+ }, rows.map((idx, index) => /* @__PURE__ */ React6.createElement(GridRowCell, {
1391
2087
  key: idx,
1392
2088
  idx,
1393
2089
  index,
@@ -1397,7 +2093,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1397
2093
  selected: selected === index,
1398
2094
  onResize,
1399
2095
  onSelect
1400
- }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(DragOverlay, null, active && /* @__PURE__ */ React4.createElement(MovingOverlay, {
2096
+ }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
1401
2097
  label: String(active.data.current.index + 1)
1402
2098
  })), document.body))));
1403
2099
  });
@@ -1415,8 +2111,8 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
1415
2111
  }
1416
2112
  });
1417
2113
  const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
1418
- const [initialSize, setInitialSize] = useState4(size);
1419
- const [resizing, setResizing] = useState4(false);
2114
+ const [initialSize, setInitialSize] = useState5(size);
2115
+ const [resizing, setResizing] = useState5(false);
1420
2116
  const scrollHandler = useRef();
1421
2117
  const handleResizeStart = (_ev, _dir, elementRef) => {
1422
2118
  const scrollContainer = elementRef.closest('[role="rowheader"]');
@@ -1438,7 +2134,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
1438
2134
  onResize?.(idx, initialSize + height, true);
1439
2135
  setResizing(false);
1440
2136
  };
1441
- return /* @__PURE__ */ React4.createElement(Resizable, {
2137
+ return /* @__PURE__ */ React6.createElement(Resizable, {
1442
2138
  enable: {
1443
2139
  bottom: resize
1444
2140
  },
@@ -1450,17 +2146,17 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
1450
2146
  onResizeStart: handleResizeStart,
1451
2147
  onResize: handleResize,
1452
2148
  onResizeStop: handleResizeStop
1453
- }, /* @__PURE__ */ React4.createElement("div", {
2149
+ }, /* @__PURE__ */ React6.createElement("div", {
1454
2150
  ref: setNodeRef,
1455
2151
  ...attributes,
1456
2152
  ...listeners,
1457
- className: mx3("flex h-full items-center justify-center cursor-pointer", "border-t border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
2153
+ className: mx2("flex h-full items-center justify-center cursor-pointer", "border-t border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
1458
2154
  onClick: () => onSelect?.(index)
1459
- }, /* @__PURE__ */ React4.createElement("span", {
2155
+ }, /* @__PURE__ */ React6.createElement("span", {
1460
2156
  className: "flex w-full justify-center"
1461
- }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React4.createElement("div", {
2157
+ }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
1462
2158
  className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
1463
- }), resizing && /* @__PURE__ */ React4.createElement("div", {
2159
+ }), resizing && /* @__PURE__ */ React6.createElement("div", {
1464
2160
  className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
1465
2161
  })));
1466
2162
  };
@@ -1473,7 +2169,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
1473
2169
  });
1474
2170
  const keyboardSensor = useSensor(KeyboardSensor, {});
1475
2171
  const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
1476
- const [active, setActive] = useState4(null);
2172
+ const [active, setActive] = useState5(null);
1477
2173
  const handleDragStart = ({ active: active2 }) => {
1478
2174
  setActive(active2);
1479
2175
  };
@@ -1497,18 +2193,18 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
1497
2193
  }
1498
2194
  return transform;
1499
2195
  };
1500
- return /* @__PURE__ */ React4.createElement("div", {
2196
+ return /* @__PURE__ */ React6.createElement("div", {
1501
2197
  className: "relative flex grow overflow-hidden"
1502
- }, /* @__PURE__ */ React4.createElement("div", {
1503
- className: mx3("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
2198
+ }, /* @__PURE__ */ React6.createElement("div", {
2199
+ className: mx2("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
1504
2200
  style: {
1505
2201
  height: axisHeight
1506
2202
  }
1507
- }), /* @__PURE__ */ React4.createElement("div", {
2203
+ }), /* @__PURE__ */ React6.createElement("div", {
1508
2204
  ref: forwardRef2,
1509
2205
  role: "columnheader",
1510
2206
  className: "grow overflow-x-auto scrollbar-none"
1511
- }, /* @__PURE__ */ React4.createElement(DndContext, {
2207
+ }, /* @__PURE__ */ React6.createElement(DndContext, {
1512
2208
  autoScroll: {
1513
2209
  enabled: true
1514
2210
  },
@@ -1519,12 +2215,12 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
1519
2215
  ],
1520
2216
  onDragStart: handleDragStart,
1521
2217
  onDragEnd: handleDragEnd
1522
- }, /* @__PURE__ */ React4.createElement("div", {
2218
+ }, /* @__PURE__ */ React6.createElement("div", {
1523
2219
  className: "flex h-full",
1524
2220
  style: {
1525
2221
  height: axisHeight
1526
2222
  }
1527
- }, columns.map((idx, index) => /* @__PURE__ */ React4.createElement(GridColumnCell, {
2223
+ }, columns.map((idx, index) => /* @__PURE__ */ React6.createElement(GridColumnCell, {
1528
2224
  key: idx,
1529
2225
  idx,
1530
2226
  index,
@@ -1534,7 +2230,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
1534
2230
  selected: selected === index,
1535
2231
  onResize,
1536
2232
  onSelect
1537
- }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(DragOverlay, null, active && /* @__PURE__ */ React4.createElement(MovingOverlay, {
2233
+ }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
1538
2234
  label: columnLetter(active.data.current.index)
1539
2235
  })), document.body))));
1540
2236
  });
@@ -1552,8 +2248,8 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
1552
2248
  }
1553
2249
  });
1554
2250
  const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
1555
- const [initialSize, setInitialSize] = useState4(size);
1556
- const [resizing, setResizing] = useState4(false);
2251
+ const [initialSize, setInitialSize] = useState5(size);
2252
+ const [resizing, setResizing] = useState5(false);
1557
2253
  const scrollHandler = useRef();
1558
2254
  const handleResizeStart = (_ev, _dir, elementRef) => {
1559
2255
  const scrollContainer = elementRef.closest('[role="columnheader"]');
@@ -1575,7 +2271,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
1575
2271
  onResize?.(idx, initialSize + width, true);
1576
2272
  setResizing(false);
1577
2273
  };
1578
- return /* @__PURE__ */ React4.createElement(Resizable, {
2274
+ return /* @__PURE__ */ React6.createElement(Resizable, {
1579
2275
  enable: {
1580
2276
  right: resize
1581
2277
  },
@@ -1587,17 +2283,17 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
1587
2283
  onResizeStart: handleResizeStart,
1588
2284
  onResize: handleResize,
1589
2285
  onResizeStop: handleResizeStop
1590
- }, /* @__PURE__ */ React4.createElement("div", {
2286
+ }, /* @__PURE__ */ React6.createElement("div", {
1591
2287
  ref: setNodeRef,
1592
2288
  ...attributes,
1593
2289
  ...listeners,
1594
- className: mx3("flex h-full items-center justify-center cursor-pointer", "border-l border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
2290
+ className: mx2("flex h-full items-center justify-center cursor-pointer", "border-l border-gridLine focus-visible:outline-none", fragments.axis, selected && fragments.axisSelected, isDragging && fragments.axisSelected),
1595
2291
  onClick: () => onSelect?.(index)
1596
- }, /* @__PURE__ */ React4.createElement("span", {
2292
+ }, /* @__PURE__ */ React6.createElement("span", {
1597
2293
  className: "flex w-full justify-center"
1598
- }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React4.createElement("div", {
2294
+ }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
1599
2295
  className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
1600
- }), resizing && /* @__PURE__ */ React4.createElement("div", {
2296
+ }), resizing && /* @__PURE__ */ React6.createElement("div", {
1601
2297
  className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
1602
2298
  })));
1603
2299
  };
@@ -1610,14 +2306,14 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
1610
2306
  const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
1611
2307
  const initialText = useRef();
1612
2308
  const quickEdit = useRef(false);
1613
- const [, forceUpdate] = useState4({});
2309
+ const [, forceUpdate] = useState5({});
1614
2310
  useEffect4(() => {
1615
2311
  const unsubscribe = model.update.on(() => {
1616
- log("updated", {
2312
+ log2("updated", {
1617
2313
  id: model.id
1618
2314
  }, {
1619
- F: __dxlog_file2,
1620
- L: 737,
2315
+ F: __dxlog_file4,
2316
+ L: 738,
1621
2317
  S: void 0,
1622
2318
  C: (f, a) => f(...a)
1623
2319
  });
@@ -1734,19 +2430,18 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
1734
2430
  rowSizes,
1735
2431
  columnSizes
1736
2432
  });
1737
- const id = fullyQualifiedId3(model.sheet);
1738
- const attendableAttrs = createAttendableAttributes(id);
1739
- const hasAttention = useHasAttention(id);
1740
- return /* @__PURE__ */ React4.createElement("div", {
2433
+ const id = fullyQualifiedId2(model.sheet);
2434
+ const { hasAttention } = useAttention(id);
2435
+ return /* @__PURE__ */ React6.createElement("div", {
1741
2436
  ref: containerRef,
1742
2437
  role: "grid",
1743
2438
  className: "relative flex grow overflow-hidden"
1744
- }, /* @__PURE__ */ React4.createElement("div", {
1745
- className: mx3("z-20 absolute inset-0 border border-gridLine pointer-events-none")
1746
- }), /* @__PURE__ */ React4.createElement("div", {
2439
+ }, /* @__PURE__ */ React6.createElement("div", {
2440
+ className: mx2("z-20 absolute inset-0 border border-gridLine pointer-events-none")
2441
+ }), /* @__PURE__ */ React6.createElement("div", {
1747
2442
  ref: scrollerRef,
1748
- className: mx3("grow", hasAttention && "overflow-auto scrollbar-thin")
1749
- }, /* @__PURE__ */ React4.createElement("div", {
2443
+ className: mx2("grow", hasAttention && "overflow-auto scrollbar-thin")
2444
+ }, /* @__PURE__ */ React6.createElement("div", {
1750
2445
  className: "relative select-none",
1751
2446
  style: {
1752
2447
  width,
@@ -1754,10 +2449,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
1754
2449
  },
1755
2450
  onClick: () => inputRef.current?.focus(),
1756
2451
  ...handlers
1757
- }, scrollerRef.current && /* @__PURE__ */ React4.createElement(SelectionOverlay, {
2452
+ }, scrollerRef.current && /* @__PURE__ */ React6.createElement(SelectionOverlay, {
1758
2453
  root: scrollerRef.current
1759
2454
  }), rowRange.map(({ row, top, height: height2 }) => {
1760
- return columnRange.map(({ column, left, width: width2 }) => {
2455
+ return columnRange.map(({ col, left, width: width2 }) => {
1761
2456
  const style = {
1762
2457
  position: "absolute",
1763
2458
  top,
@@ -1767,7 +2462,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
1767
2462
  };
1768
2463
  const cell = {
1769
2464
  row,
1770
- column
2465
+ col
1771
2466
  };
1772
2467
  const id2 = addressToA1Notation(cell);
1773
2468
  const idx = addressToIndex(model.sheet, cell);
@@ -1803,7 +2498,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
1803
2498
  inputRef.current?.focus();
1804
2499
  setEditing(false);
1805
2500
  };
1806
- return /* @__PURE__ */ React4.createElement(GridCellEditor, {
2501
+ return /* @__PURE__ */ React6.createElement(GridCellEditor, {
1807
2502
  key: idx,
1808
2503
  value,
1809
2504
  style,
@@ -1811,7 +2506,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
1811
2506
  onClose: handleClose
1812
2507
  });
1813
2508
  }
1814
- return /* @__PURE__ */ React4.createElement(SheetCell, {
2509
+ return /* @__PURE__ */ React6.createElement(SheetCell, {
1815
2510
  key: id2,
1816
2511
  id: id2,
1817
2512
  cell,
@@ -1823,13 +2518,25 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
1823
2518
  }
1824
2519
  });
1825
2520
  });
1826
- }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement("input", {
2521
+ }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(SheetInput, {
1827
2522
  ref: inputRef,
1828
- autoFocus: true,
2523
+ id,
2524
+ onKeyDown: handleKeyDown
2525
+ }), document.body));
2526
+ });
2527
+ var SheetInput = /* @__PURE__ */ forwardRef(({ id, onKeyDown }, forwardedRef) => {
2528
+ const path = useAttentionPath();
2529
+ const attendableAttrs = useAttendableAttributes(id);
2530
+ return path.toReversed().reduce((acc, part) => {
2531
+ return /* @__PURE__ */ React6.createElement("div", {
2532
+ [ATTENABLE_ATTRIBUTE]: part
2533
+ }, acc);
2534
+ }, /* @__PURE__ */ React6.createElement("input", {
2535
+ ref: forwardedRef,
1829
2536
  className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
1830
- onKeyDown: handleKeyDown,
2537
+ onKeyDown,
1831
2538
  ...attendableAttrs
1832
- }), document.body));
2539
+ }));
1833
2540
  });
1834
2541
  var SelectionOverlay = ({ root }) => {
1835
2542
  const { range } = useSheetContext();
@@ -1844,7 +2551,7 @@ var SelectionOverlay = ({ root }) => {
1844
2551
  const b1 = getRelativeClientRect(root, c1);
1845
2552
  const b2 = getRelativeClientRect(root, c2);
1846
2553
  const bounds = getRectUnion(b1, b2);
1847
- return /* @__PURE__ */ React4.createElement("div", {
2554
+ return /* @__PURE__ */ React6.createElement("div", {
1848
2555
  role: "none",
1849
2556
  style: bounds,
1850
2557
  className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
@@ -1854,7 +2561,7 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
1854
2561
  const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
1855
2562
  const { value, classNames } = formatting.getFormatting(cell);
1856
2563
  const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
1857
- const decorationAddedClasses = useMemo3(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
2564
+ const decorationAddedClasses = useMemo4(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
1858
2565
  decorationsForCell
1859
2566
  ]);
1860
2567
  const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
@@ -1862,16 +2569,16 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
1862
2569
  return children;
1863
2570
  }
1864
2571
  const DecoratorComponent = decorate;
1865
- return /* @__PURE__ */ React4.createElement(DecoratorComponent, null, children);
1866
- }, /* @__PURE__ */ React4.createElement("div", {
2572
+ return /* @__PURE__ */ React6.createElement(DecoratorComponent, null, children);
2573
+ }, /* @__PURE__ */ React6.createElement("div", {
1867
2574
  role: "none",
1868
- className: mx3("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
2575
+ className: mx2("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
1869
2576
  }, value));
1870
- return /* @__PURE__ */ React4.createElement("div", {
2577
+ return /* @__PURE__ */ React6.createElement("div", {
1871
2578
  [`data-${CELL_DATA_KEY}`]: id,
1872
2579
  role: "cell",
1873
2580
  style,
1874
- className: mx3("border border-gridLine cursor-pointer", fragments.cell, active && [
2581
+ className: mx2("border border-gridLine cursor-pointer", fragments.cell, active && [
1875
2582
  "z-20",
1876
2583
  fragments.cellSelected
1877
2584
  ], classNames),
@@ -1897,24 +2604,24 @@ var GridCellEditor = ({ style, value, onNav, onClose }) => {
1897
2604
  }, [
1898
2605
  range
1899
2606
  ]);
1900
- const extension = useMemo3(() => [
2607
+ const extension = useMemo4(() => [
1901
2608
  editorKeys({
1902
2609
  onNav,
1903
2610
  onClose
1904
2611
  }),
1905
2612
  sheetExtension({
1906
- functions: model.functions
2613
+ functions: model.graph.getFunctions()
1907
2614
  }),
1908
2615
  rangeExtension((fn) => notifier.current = fn)
1909
2616
  ], [
1910
2617
  model
1911
2618
  ]);
1912
- return /* @__PURE__ */ React4.createElement("div", {
2619
+ return /* @__PURE__ */ React6.createElement("div", {
1913
2620
  role: "cell",
1914
2621
  style,
1915
- className: mx3("z-20 flex", fragments.cellSelected),
2622
+ className: mx2("z-20 flex", fragments.cellSelected),
1916
2623
  onClick: (ev) => ev.stopPropagation()
1917
- }, /* @__PURE__ */ React4.createElement(CellEditor, {
2624
+ }, /* @__PURE__ */ React6.createElement(CellEditor, {
1918
2625
  autoFocus: true,
1919
2626
  value,
1920
2627
  extension
@@ -1927,29 +2634,29 @@ var SheetStatusBar = () => {
1927
2634
  if (cursor) {
1928
2635
  value = model.getCellValue(cursor);
1929
2636
  if (typeof value === "string" && value.charAt(0) === "=") {
1930
- value = model.mapFormulaBindingFromId(model.mapFormulaIndicesToRefs(value));
2637
+ value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
1931
2638
  isFormula = true;
1932
2639
  } else if (value != null) {
1933
2640
  value = String(value);
1934
2641
  }
1935
2642
  }
1936
- return /* @__PURE__ */ React4.createElement("div", {
1937
- className: mx3("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
1938
- }, /* @__PURE__ */ React4.createElement("div", {
2643
+ return /* @__PURE__ */ React6.createElement("div", {
2644
+ className: mx2("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
2645
+ }, /* @__PURE__ */ React6.createElement("div", {
1939
2646
  className: "flex gap-4 items-center"
1940
- }, /* @__PURE__ */ React4.createElement("div", {
2647
+ }, /* @__PURE__ */ React6.createElement("div", {
1941
2648
  className: "flex w-16 items-center font-mono"
1942
- }, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React4.createElement("div", {
2649
+ }, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React6.createElement("div", {
1943
2650
  className: "flex gap-2 items-center"
1944
- }, /* @__PURE__ */ React4.createElement(FunctionIcon, {
1945
- className: mx3("text-greenText", isFormula ? "visible" : "invisible")
1946
- }), /* @__PURE__ */ React4.createElement("span", {
2651
+ }, /* @__PURE__ */ React6.createElement(FunctionIcon, {
2652
+ className: mx2("text-greenText", isFormula ? "visible" : "invisible")
2653
+ }), /* @__PURE__ */ React6.createElement("span", {
1947
2654
  className: "font-mono"
1948
2655
  }, value))));
1949
2656
  };
1950
2657
  var SheetDebug = () => {
1951
2658
  const { model, cursor, range } = useSheetContext();
1952
- const [, forceUpdate] = useState4({});
2659
+ const [, forceUpdate] = useState5({});
1953
2660
  useEffect4(() => {
1954
2661
  const accessor = createDocAccessor(model.sheet, []);
1955
2662
  const handleUpdate = () => forceUpdate({});
@@ -1961,9 +2668,9 @@ var SheetDebug = () => {
1961
2668
  }, [
1962
2669
  model
1963
2670
  ]);
1964
- return /* @__PURE__ */ React4.createElement("div", {
1965
- className: mx3("z-20 absolute right-0 top-20 bottom-20 w-[30rem] overflow-auto scrollbar-thin", "border border-gridLine text-xs bg-neutral-50 dark:bg-black text-cyan-500 font-mono p-1 opacity-80")
1966
- }, /* @__PURE__ */ React4.createElement("pre", {
2671
+ return /* @__PURE__ */ React6.createElement("div", {
2672
+ className: mx2("z-20 absolute right-0 top-20 bottom-20 w-[30rem] overflow-auto scrollbar-thin", "border border-gridLine text-xs bg-neutral-50 dark:bg-black text-cyan-500 font-mono p-1 opacity-80")
2673
+ }, /* @__PURE__ */ React6.createElement("pre", {
1967
2674
  className: "whitespace-pre-wrap"
1968
2675
  }, JSON.stringify({
1969
2676
  cursor,
@@ -1985,247 +2692,14 @@ var Sheet = {
1985
2692
  Debug: SheetDebug
1986
2693
  };
1987
2694
 
1988
- // packages/plugins/plugin-sheet/src/components/Toolbar/Toolbar.tsx
1989
- import { Calendar, ChatText, CurrencyDollar, Eraser, HighlighterCircle, TextAlignCenter, TextAlignLeft, TextAlignRight } from "@phosphor-icons/react";
1990
- import { createContext as createContext2 } from "@radix-ui/react-context";
1991
- import React6 from "react";
1992
- import { DensityProvider, ElevationProvider, Toolbar as NaturalToolbar2, useTranslation as useTranslation2 } from "@dxos/react-ui";
1993
- import { nonNullable } from "@dxos/util";
1994
-
1995
- // packages/plugins/plugin-sheet/src/components/Toolbar/common.tsx
1996
- import React5 from "react";
1997
- import { Toolbar as NaturalToolbar, Tooltip } from "@dxos/react-ui";
1998
- import { getSize } from "@dxos/react-ui-theme";
1999
- var iconStyles = getSize(5);
2000
- var buttonStyles = "min-bs-0 p-2";
2001
- var tooltipProps = {
2002
- side: "top",
2003
- classNames: "z-10"
2004
- };
2005
- var ToolbarSeparator = () => /* @__PURE__ */ React5.createElement("div", {
2006
- role: "separator",
2007
- className: "grow"
2008
- });
2009
- var ToolbarButton = ({ Icon: Icon2, children, ...props }) => {
2010
- return /* @__PURE__ */ React5.createElement(Tooltip.Root, null, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
2011
- asChild: true
2012
- }, /* @__PURE__ */ React5.createElement(NaturalToolbar.Button, {
2013
- variant: "ghost",
2014
- ...props,
2015
- classNames: buttonStyles
2016
- }, /* @__PURE__ */ React5.createElement(Icon2, {
2017
- className: iconStyles
2018
- }), /* @__PURE__ */ React5.createElement("span", {
2019
- className: "sr-only"
2020
- }, children))), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, tooltipProps, children, /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null))));
2021
- };
2022
- var ToolbarToggleButton = ({ Icon: Icon2, children, ...props }) => {
2023
- return /* @__PURE__ */ React5.createElement(Tooltip.Root, null, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
2024
- asChild: true
2025
- }, /* @__PURE__ */ React5.createElement(NaturalToolbar.ToggleGroupItem, {
2026
- variant: "ghost",
2027
- ...props,
2028
- classNames: buttonStyles
2029
- }, /* @__PURE__ */ React5.createElement(Icon2, {
2030
- className: iconStyles
2031
- }), /* @__PURE__ */ React5.createElement("span", {
2032
- className: "sr-only"
2033
- }, children))), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, tooltipProps, children, /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null))));
2034
- };
2035
-
2036
- // packages/plugins/plugin-sheet/src/components/Toolbar/Toolbar.tsx
2037
- var [ToolbarContextProvider, useToolbarContext] = createContext2("Toolbar");
2038
- var ToolbarRoot = ({ children, onAction, classNames }) => {
2039
- return /* @__PURE__ */ React6.createElement(ToolbarContextProvider, {
2040
- onAction
2041
- }, /* @__PURE__ */ React6.createElement(DensityProvider, {
2042
- density: "fine"
2043
- }, /* @__PURE__ */ React6.createElement(ElevationProvider, {
2044
- elevation: "chrome"
2045
- }, /* @__PURE__ */ React6.createElement(NaturalToolbar2.Root, {
2046
- classNames: [
2047
- "is-full shrink-0 overflow-x-auto overflow-y-hidden p-1",
2048
- classNames
2049
- ]
2050
- }, children))));
2051
- };
2052
- var formatOptions = [
2053
- {
2054
- type: "date",
2055
- Icon: Calendar,
2056
- getState: (state) => false
2057
- },
2058
- {
2059
- type: "currency",
2060
- Icon: CurrencyDollar,
2061
- getState: (state) => false
2062
- }
2063
- ];
2064
- var Format = () => {
2065
- const { onAction } = useToolbarContext("Format");
2066
- const { t } = useTranslation2(SHEET_PLUGIN);
2067
- return /* @__PURE__ */ React6.createElement(NaturalToolbar2.ToggleGroup, {
2068
- type: "single"
2069
- }, formatOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ React6.createElement(ToolbarToggleButton, {
2070
- key: type,
2071
- value: type,
2072
- Icon: Icon2,
2073
- // disabled={state?.blockType === 'codeblock'}
2074
- // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
2075
- onClick: () => onAction?.({
2076
- type
2077
- })
2078
- }, t(`toolbar ${type} label`))));
2079
- };
2080
- var alignmentOptions = [
2081
- {
2082
- type: "left",
2083
- Icon: TextAlignLeft,
2084
- getState: (state) => false
2085
- },
2086
- {
2087
- type: "center",
2088
- Icon: TextAlignCenter,
2089
- getState: (state) => false
2090
- },
2091
- {
2092
- type: "right",
2093
- Icon: TextAlignRight,
2094
- getState: (state) => false
2095
- }
2096
- ];
2097
- var Alignment = () => {
2098
- const { onAction } = useToolbarContext("Alignment");
2099
- const { t } = useTranslation2(SHEET_PLUGIN);
2100
- return /* @__PURE__ */ React6.createElement(NaturalToolbar2.ToggleGroup, {
2101
- type: "single"
2102
- }, alignmentOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ React6.createElement(ToolbarToggleButton, {
2103
- key: type,
2104
- value: type,
2105
- Icon: Icon2,
2106
- // disabled={state?.blockType === 'codeblock'}
2107
- // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
2108
- onClick: () => onAction?.({
2109
- type
2110
- })
2111
- }, t(`toolbar ${type} label`))));
2112
- };
2113
- var styleOptions = [
2114
- {
2115
- type: "clear",
2116
- Icon: Eraser,
2117
- getState: (state) => false
2118
- },
2119
- {
2120
- type: "highlight",
2121
- Icon: HighlighterCircle,
2122
- getState: (state) => false
2123
- }
2124
- ];
2125
- var Styles = () => {
2126
- const { onAction } = useToolbarContext("Alignment");
2127
- const { t } = useTranslation2(SHEET_PLUGIN);
2128
- return /* @__PURE__ */ React6.createElement(NaturalToolbar2.ToggleGroup, {
2129
- type: "single"
2130
- }, styleOptions.map(({ type, getState, Icon: Icon2 }) => /* @__PURE__ */ React6.createElement(ToolbarToggleButton, {
2131
- key: type,
2132
- value: type,
2133
- Icon: Icon2,
2134
- // disabled={state?.blockType === 'codeblock'}
2135
- // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}
2136
- onClick: () => onAction?.({
2137
- type
2138
- })
2139
- }, t(`toolbar ${type} label`))));
2140
- };
2141
- var Actions = () => {
2142
- const { onAction } = useToolbarContext("Actions");
2143
- const { cursor, range, model } = useSheetContext();
2144
- const { t } = useTranslation2(SHEET_PLUGIN);
2145
- const overlapsCommentAnchor = (model.sheet.threads ?? []).filter(nonNullable).filter((thread) => thread.status !== "resolved").some((thread) => {
2146
- if (!cursor) {
2147
- return false;
2148
- }
2149
- return addressToIndex(model.sheet, cursor) === thread.anchor;
2150
- });
2151
- const hasCursor = !!cursor;
2152
- const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;
2153
- const tooltipLabelKey = !hasCursor ? "no cursor label" : overlapsCommentAnchor ? "selection overlaps existing comment label" : range ? "comment ranges not supported label" : "comment label";
2154
- return /* @__PURE__ */ React6.createElement(ToolbarButton, {
2155
- value: "comment",
2156
- Icon: ChatText,
2157
- "data-testid": "editor.toolbar.comment",
2158
- onClick: () => {
2159
- if (!cursor) {
2160
- return;
2161
- }
2162
- return onAction?.({
2163
- type: "comment",
2164
- anchor: addressToIndex(model.sheet, cursor),
2165
- cellContent: model.getCellText(cursor)
2166
- });
2167
- },
2168
- disabled: !cursorOnly || overlapsCommentAnchor
2169
- }, t(tooltipLabelKey));
2170
- };
2171
- var Toolbar = {
2172
- Root: ToolbarRoot,
2173
- Separator: ToolbarSeparator,
2174
- Alignment,
2175
- Format,
2176
- Styles,
2177
- Actions
2178
- };
2179
-
2180
- // packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
2181
- var attentionFragment = mx4("group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface", "group-focus-within/editor:border-separator");
2182
- var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
2183
- var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
2184
- const dispatch = useIntentDispatcher2();
2185
- const id = fullyQualifiedId4(sheet);
2186
- const isDirectlyAttended = useIsDirectlyAttended(id);
2187
- const handleAction = useCallback2((action) => {
2188
- switch (action.type) {
2189
- case "comment": {
2190
- void dispatch({
2191
- action: "dxos.org/plugin/thread/action/create",
2192
- data: {
2193
- cursor: action.anchor,
2194
- name: action.cellContent,
2195
- subject: sheet
2196
- }
2197
- });
2198
- }
2199
- }
2200
- }, [
2201
- sheet,
2202
- dispatch
2203
- ]);
2204
- return /* @__PURE__ */ React7.createElement("div", {
2205
- role: "none",
2206
- className: role === "article" ? "row-span-2 grid grid-rows-subgrid" : void 0
2207
- }, /* @__PURE__ */ React7.createElement(Sheet.Root, {
2208
- sheet,
2209
- space,
2210
- remoteFunctionUrl
2211
- }, /* @__PURE__ */ React7.createElement("div", {
2212
- role: "none",
2213
- className: mx4("flex flex-0 justify-center overflow-x-auto")
2214
- }, /* @__PURE__ */ React7.createElement(Toolbar.Root, {
2215
- onAction: handleAction,
2216
- classNames: mx4(role === "section" ? [
2217
- "z-[2] group-focus-within/section:visible",
2218
- !isDirectlyAttended && "invisible",
2219
- sectionToolbarLayout
2220
- ] : "group-focus-within/editor:border-separator group-[[aria-current]]/editor:border-separator")
2221
- }, /* @__PURE__ */ React7.createElement(Toolbar.Separator, null), /* @__PURE__ */ React7.createElement(Toolbar.Actions, null))), /* @__PURE__ */ React7.createElement("div", {
2222
- role: "none",
2223
- className: mx4(role === "section" && "aspect-square border-is border-bs border-be border-separator", role === "article" && "flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator", focusRing, attentionFragment)
2224
- }, /* @__PURE__ */ React7.createElement(Sheet.Main, null))));
2225
- };
2226
- var SheetContainer_default = SheetContainer;
2227
2695
  export {
2228
- SheetContainer_default as default,
2229
- sectionToolbarLayout
2696
+ ComputeGraphContextProvider,
2697
+ createSheet,
2698
+ addressToIndex,
2699
+ compareIndexPositions,
2700
+ useComputeGraph,
2701
+ useSheetContext,
2702
+ Sheet,
2703
+ SheetContainer
2230
2704
  };
2231
- //# sourceMappingURL=SheetContainer-Y7ZMFBAP.mjs.map
2705
+ //# sourceMappingURL=chunk-ZL2V5UJR.mjs.map