@dxos/plugin-sheet 0.6.12-main.ed7cda7 → 0.6.12-staging.0b4bb48

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 (260) hide show
  1. package/dist/lib/browser/{chunk-U2JHW3L6.mjs → SheetContainer-U4H5D34A.mjs} +240 -1020
  2. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
  4. package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
  5. package/dist/lib/{node-esm/chunk-D6KU5MI7.mjs → browser/chunk-D5AGLXJP.mjs} +670 -360
  6. package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-T3NJFTD4.mjs → chunk-FUAGSXA4.mjs} +15 -8
  8. package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-QILRZNE5.mjs → chunk-JRL5LGCE.mjs} +5 -2
  10. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
  12. package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +56 -68
  14. package/dist/lib/browser/index.mjs.map +3 -3
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/meta.mjs +1 -1
  17. package/dist/lib/browser/testing.mjs +92 -0
  18. package/dist/lib/browser/testing.mjs.map +7 -0
  19. package/dist/lib/browser/types.mjs +6 -4
  20. package/dist/lib/node/{chunk-OTTD7FBK.cjs → SheetContainer-AXQV3ZT5.cjs} +279 -1050
  21. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-DD6FIXWC.cjs → chunk-5KKJ4NPP.cjs} +667 -360
  23. package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-BNARJ5GM.cjs → chunk-BJ6ZD7MN.cjs} +18 -5
  25. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
  26. package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
  27. package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
  28. package/dist/lib/node/{chunk-Q3HBHPRL.cjs → chunk-DSYKOI4E.cjs} +20 -12
  29. package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
  30. package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
  31. package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
  32. package/dist/lib/node/index.cjs +64 -83
  33. package/dist/lib/node/index.cjs.map +3 -3
  34. package/dist/lib/node/meta.cjs +3 -3
  35. package/dist/lib/node/meta.cjs.map +1 -1
  36. package/dist/lib/node/meta.json +1 -1
  37. package/dist/lib/node/testing.cjs +111 -0
  38. package/dist/lib/node/testing.cjs.map +7 -0
  39. package/dist/lib/node/types.cjs +12 -10
  40. package/dist/lib/node/types.cjs.map +2 -2
  41. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  42. package/dist/types/src/components/CellEditor/CellEditor.d.ts +3 -23
  43. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
  44. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
  45. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
  46. package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
  47. package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
  48. package/dist/types/src/{graph → components/ComputeGraph}/async-function.d.ts +1 -1
  49. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
  50. package/dist/types/src/{graph/custom-function.d.ts → components/ComputeGraph/custom.d.ts} +1 -1
  51. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
  52. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
  53. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
  54. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
  55. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
  56. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
  57. package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
  58. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
  59. package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
  60. package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
  61. package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
  62. package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
  63. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +6 -5
  64. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
  65. package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
  66. package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
  67. package/dist/types/src/components/Sheet/grid.d.ts +2 -2
  68. package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
  69. package/dist/types/src/components/Sheet/nav.d.ts +3 -3
  70. package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
  71. package/dist/types/src/components/Sheet/sheet-context.d.ts +5 -6
  72. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
  73. package/dist/types/src/components/SheetContainer.d.ts +3 -2
  74. package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
  75. package/dist/types/src/components/Toolbar/Toolbar.d.ts +3 -19
  76. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  77. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +13 -18
  78. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  79. package/dist/types/src/components/index.d.ts +2 -2
  80. package/dist/types/src/components/index.d.ts.map +1 -1
  81. package/dist/types/src/meta.d.ts +4 -1
  82. package/dist/types/src/meta.d.ts.map +1 -1
  83. package/dist/types/src/{graph/function-defs.d.ts → model/functions.d.ts} +1 -1
  84. package/dist/types/src/model/functions.d.ts.map +1 -0
  85. package/dist/types/src/model/index.d.ts +3 -2
  86. package/dist/types/src/model/index.d.ts.map +1 -1
  87. package/dist/types/src/model/model.browser.test.d.ts +2 -0
  88. package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
  89. package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +64 -9
  90. package/dist/types/src/model/model.d.ts.map +1 -0
  91. package/dist/types/src/{defs → model}/types.d.ts +3 -8
  92. package/dist/types/src/model/types.d.ts.map +1 -0
  93. package/dist/types/src/model/types.test.d.ts.map +1 -0
  94. package/dist/types/src/model/util.d.ts +15 -0
  95. package/dist/types/src/model/util.d.ts.map +1 -0
  96. package/dist/types/src/testing.d.ts +9 -0
  97. package/dist/types/src/testing.d.ts.map +1 -0
  98. package/dist/types/src/translations.d.ts +12 -17
  99. package/dist/types/src/translations.d.ts.map +1 -1
  100. package/dist/types/src/types.d.ts +3 -83
  101. package/dist/types/src/types.d.ts.map +1 -1
  102. package/package.json +41 -48
  103. package/src/SheetPlugin.tsx +70 -43
  104. package/src/components/CellEditor/CellEditor.stories.tsx +3 -4
  105. package/src/components/CellEditor/CellEditor.tsx +9 -59
  106. package/src/components/CellEditor/extension.test.ts +5 -4
  107. package/src/components/CellEditor/extension.ts +3 -1
  108. package/src/{graph → components/ComputeGraph}/async-function.ts +1 -3
  109. package/src/{graph/custom-function.ts → components/ComputeGraph/custom.ts} +6 -2
  110. package/src/{graph → components/ComputeGraph}/edge-function.ts +1 -2
  111. package/src/components/ComputeGraph/graph-context.tsx +50 -0
  112. package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
  113. package/src/components/ComputeGraph/graph.ts +62 -0
  114. package/src/components/ComputeGraph/index.ts +3 -1
  115. package/src/components/Sheet/Sheet.stories.tsx +82 -45
  116. package/src/components/Sheet/Sheet.tsx +18 -57
  117. package/src/{model/formatting-model.ts → components/Sheet/formatting.ts} +13 -20
  118. package/src/components/Sheet/grid.ts +3 -3
  119. package/src/components/Sheet/nav.ts +19 -19
  120. package/src/components/Sheet/sheet-context.tsx +78 -16
  121. package/src/components/SheetContainer.tsx +19 -73
  122. package/src/components/Toolbar/Toolbar.tsx +12 -53
  123. package/src/components/index.ts +0 -1
  124. package/src/meta.tsx +5 -1
  125. package/src/model/index.ts +3 -2
  126. package/src/model/model.browser.test.ts +100 -0
  127. package/src/model/model.ts +550 -0
  128. package/src/{defs → model}/types.test.ts +9 -8
  129. package/src/{defs → model}/types.ts +14 -23
  130. package/src/model/util.ts +36 -0
  131. package/src/testing.ts +50 -0
  132. package/src/translations.ts +1 -6
  133. package/src/types.ts +5 -30
  134. package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs +0 -261
  135. package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs.map +0 -7
  136. package/dist/lib/browser/chunk-6ZMQVB4Z.mjs +0 -2923
  137. package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +0 -7
  138. package/dist/lib/browser/chunk-QILRZNE5.mjs.map +0 -7
  139. package/dist/lib/browser/chunk-T3NJFTD4.mjs.map +0 -7
  140. package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +0 -7
  141. package/dist/lib/browser/graph-T27BOBOV.mjs +0 -21
  142. package/dist/lib/browser/graph-T27BOBOV.mjs.map +0 -7
  143. package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs +0 -279
  144. package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs.map +0 -7
  145. package/dist/lib/node/chunk-BNARJ5GM.cjs.map +0 -7
  146. package/dist/lib/node/chunk-DD6FIXWC.cjs.map +0 -7
  147. package/dist/lib/node/chunk-OTTD7FBK.cjs.map +0 -7
  148. package/dist/lib/node/chunk-Q3HBHPRL.cjs.map +0 -7
  149. package/dist/lib/node/graph-SPKGX7W4.cjs +0 -43
  150. package/dist/lib/node/graph-SPKGX7W4.cjs.map +0 -7
  151. package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs +0 -262
  152. package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs.map +0 -7
  153. package/dist/lib/node-esm/chunk-7HVSOTGA.mjs +0 -2553
  154. package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +0 -7
  155. package/dist/lib/node-esm/chunk-BMNA27EX.mjs +0 -76
  156. package/dist/lib/node-esm/chunk-BMNA27EX.mjs.map +0 -7
  157. package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +0 -7
  158. package/dist/lib/node-esm/chunk-IU2L277A.mjs +0 -17
  159. package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +0 -7
  160. package/dist/lib/node-esm/graph-U67IO4UC.mjs +0 -22
  161. package/dist/lib/node-esm/graph-U67IO4UC.mjs.map +0 -7
  162. package/dist/lib/node-esm/index.mjs +0 -261
  163. package/dist/lib/node-esm/index.mjs.map +0 -7
  164. package/dist/lib/node-esm/meta.json +0 -1
  165. package/dist/lib/node-esm/meta.mjs +0 -10
  166. package/dist/lib/node-esm/meta.mjs.map +0 -7
  167. package/dist/lib/node-esm/types.mjs +0 -21
  168. package/dist/lib/node-esm/types.mjs.map +0 -7
  169. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
  170. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
  171. package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -10
  172. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
  173. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
  174. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
  175. package/dist/types/src/components/GridSheet/util.d.ts +0 -7
  176. package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
  177. package/dist/types/src/components/Sheet/decorations.d.ts +0 -24
  178. package/dist/types/src/components/Sheet/decorations.d.ts.map +0 -1
  179. package/dist/types/src/components/Sheet/threads.d.ts +0 -2
  180. package/dist/types/src/components/Sheet/threads.d.ts.map +0 -1
  181. package/dist/types/src/defs/index.d.ts +0 -3
  182. package/dist/types/src/defs/index.d.ts.map +0 -1
  183. package/dist/types/src/defs/types.d.ts.map +0 -1
  184. package/dist/types/src/defs/types.test.d.ts.map +0 -1
  185. package/dist/types/src/defs/util.d.ts +0 -43
  186. package/dist/types/src/defs/util.d.ts.map +0 -1
  187. package/dist/types/src/extensions/compute.d.ts +0 -5
  188. package/dist/types/src/extensions/compute.d.ts.map +0 -1
  189. package/dist/types/src/extensions/compute.stories.d.ts +0 -26
  190. package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
  191. package/dist/types/src/extensions/index.d.ts +0 -2
  192. package/dist/types/src/extensions/index.d.ts.map +0 -1
  193. package/dist/types/src/graph/async-function.d.ts.map +0 -1
  194. package/dist/types/src/graph/compute-graph.browser.test.d.ts +0 -2
  195. package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +0 -1
  196. package/dist/types/src/graph/compute-graph.d.ts +0 -81
  197. package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
  198. package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
  199. package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
  200. package/dist/types/src/graph/compute-node.d.ts +0 -19
  201. package/dist/types/src/graph/compute-node.d.ts.map +0 -1
  202. package/dist/types/src/graph/custom-function.d.ts.map +0 -1
  203. package/dist/types/src/graph/edge-function.d.ts.map +0 -1
  204. package/dist/types/src/graph/function-defs.d.ts.map +0 -1
  205. package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
  206. package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
  207. package/dist/types/src/graph/index.d.ts +0 -4
  208. package/dist/types/src/graph/index.d.ts.map +0 -1
  209. package/dist/types/src/graph/util.d.ts +0 -2
  210. package/dist/types/src/graph/util.d.ts.map +0 -1
  211. package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
  212. package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
  213. package/dist/types/src/hooks/index.d.ts +0 -4
  214. package/dist/types/src/hooks/index.d.ts.map +0 -1
  215. package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
  216. package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
  217. package/dist/types/src/hooks/useFormattingModel.d.ts +0 -3
  218. package/dist/types/src/hooks/useFormattingModel.d.ts.map +0 -1
  219. package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
  220. package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
  221. package/dist/types/src/model/formatting-model.d.ts +0 -16
  222. package/dist/types/src/model/formatting-model.d.ts.map +0 -1
  223. package/dist/types/src/model/sheet-model.d.ts.map +0 -1
  224. package/dist/types/src/sanity.test.d.ts +0 -2
  225. package/dist/types/src/sanity.test.d.ts.map +0 -1
  226. package/dist/types/src/testing/index.d.ts +0 -2
  227. package/dist/types/src/testing/index.d.ts.map +0 -1
  228. package/dist/types/src/testing/testing.d.ts +0 -9
  229. package/dist/types/src/testing/testing.d.ts.map +0 -1
  230. package/dist/vendor/hyperformula.mjs +0 -37145
  231. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
  232. package/src/components/GridSheet/GridSheet.stories.tsx +0 -35
  233. package/src/components/GridSheet/GridSheet.tsx +0 -153
  234. package/src/components/GridSheet/util.ts +0 -108
  235. package/src/components/Sheet/decorations.ts +0 -62
  236. package/src/components/Sheet/threads.tsx +0 -205
  237. package/src/defs/index.ts +0 -6
  238. package/src/defs/util.ts +0 -135
  239. package/src/extensions/compute.stories.tsx +0 -151
  240. package/src/extensions/compute.ts +0 -98
  241. package/src/extensions/index.ts +0 -5
  242. package/src/graph/compute-graph.browser.test.ts +0 -104
  243. package/src/graph/compute-graph.stories.tsx +0 -92
  244. package/src/graph/compute-graph.ts +0 -290
  245. package/src/graph/compute-node.ts +0 -51
  246. package/src/graph/hyperformula.test.ts +0 -15
  247. package/src/graph/index.ts +0 -7
  248. package/src/graph/util.ts +0 -8
  249. package/src/hooks/hooks.stories.tsx +0 -50
  250. package/src/hooks/index.ts +0 -7
  251. package/src/hooks/useComputeGraph.ts +0 -20
  252. package/src/hooks/useFormattingModel.ts +0 -11
  253. package/src/hooks/useSheetModel.ts +0 -43
  254. package/src/model/sheet-model.ts +0 -399
  255. package/src/sanity.test.ts +0 -40
  256. package/src/testing/index.ts +0 -5
  257. package/src/testing/testing.tsx +0 -66
  258. /package/dist/types/src/{graph → components/ComputeGraph}/edge-function.d.ts +0 -0
  259. /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
  260. /package/src/{graph/function-defs.ts → model/functions.ts} +0 -0
@@ -1,13 +1,24 @@
1
1
  import {
2
- SheetType,
3
- ValueTypeEnum
4
- } from "./chunk-T3NJFTD4.mjs";
2
+ useComputeGraph
3
+ } from "./chunk-APHOLYUB.mjs";
5
4
  import {
6
- SHEET_PLUGIN
7
- } from "./chunk-QILRZNE5.mjs";
5
+ SheetModel,
6
+ addressFromA1Notation,
7
+ addressToA1Notation,
8
+ columnLetter,
9
+ defaultFunctions,
10
+ inRange,
11
+ posEquals,
12
+ rangeToA1Notation
13
+ } from "./chunk-D5AGLXJP.mjs";
8
14
  import {
9
- createSheetName
10
- } from "./chunk-6ZMQVB4Z.mjs";
15
+ ValueTypeEnum
16
+ } from "./chunk-FUAGSXA4.mjs";
17
+ import "./chunk-JRL5LGCE.mjs";
18
+
19
+ // packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
20
+ import React4 from "react";
21
+ import { mx as mx3 } from "@dxos/react-ui-theme";
11
22
 
12
23
  // packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
13
24
  import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
@@ -15,175 +26,17 @@ import { restrictToHorizontalAxis, restrictToVerticalAxis } from "@dnd-kit/modif
15
26
  import { getEventCoordinates, useCombinedRefs } from "@dnd-kit/utilities";
16
27
  import { Function as FunctionIcon } from "@phosphor-icons/react";
17
28
  import { Resizable } from "re-resizable";
18
- import React6, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo4, useRef, useState as useState5 } from "react";
29
+ import React3, { forwardRef, useEffect as useEffect3, useImperativeHandle, useMemo, useRef, useState as useState4 } from "react";
19
30
  import { createPortal } from "react-dom";
20
31
  import { useResizeDetector } from "react-resize-detector";
21
- import { debounce as debounce2 } from "@dxos/async";
32
+ import { debounce } from "@dxos/async";
22
33
  import { fullyQualifiedId as fullyQualifiedId2, createDocAccessor } from "@dxos/client/echo";
23
- import { log as log2 } from "@dxos/log";
34
+ import { log } from "@dxos/log";
24
35
  import { createAttendableAttributes, useHasAttention } from "@dxos/react-ui-attention";
25
36
  import { mx as mx2 } from "@dxos/react-ui-theme";
26
37
 
27
38
  // packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
28
39
  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: 39,
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 = ({ title, ...size } = {}) => {
135
- const sheet = create(SheetType, {
136
- title,
137
- cells: {},
138
- rows: [],
139
- columns: [],
140
- rowMeta: {},
141
- columnMeta: {},
142
- formatting: {}
143
- });
144
- initialize(sheet, size);
145
- return sheet;
146
- };
147
- var addressToIndex = (sheet, cell) => {
148
- return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
149
- };
150
- var addressFromIndex = (sheet, idx) => {
151
- const [column, row] = idx.split("@");
152
- return {
153
- col: sheet.columns.indexOf(column),
154
- row: sheet.rows.indexOf(row)
155
- };
156
- };
157
- var rangeFromIndex = (sheet, idx) => {
158
- const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
159
- return {
160
- from,
161
- to
162
- };
163
- };
164
- var closest = (cursor, cells) => {
165
- let closestCell;
166
- let closestDistance = Number.MAX_SAFE_INTEGER;
167
- for (const cell of cells) {
168
- const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.col - cursor.col);
169
- if (distance < closestDistance) {
170
- closestCell = cell;
171
- closestDistance = distance;
172
- }
173
- }
174
- return closestCell;
175
- };
176
- var compareIndexPositions = (sheet, indexA, indexB) => {
177
- const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
178
- const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
179
- if (rowA !== rowB) {
180
- return rowA - rowB;
181
- } else {
182
- return columnA - columnB;
183
- }
184
- };
185
-
186
- // packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
187
40
  var axisWidth = "calc(var(--rail-size)-2px)";
188
41
  var axisHeight = 34;
189
42
  var minWidth = 40;
@@ -225,7 +78,7 @@ var useGridLayout = ({ scroller, size, rows, columns, rowSizes, columnSizes }) =
225
78
  const left = x;
226
79
  x += width2 - 1;
227
80
  return {
228
- col: i,
81
+ column: i,
229
82
  left,
230
83
  width: width2
231
84
  };
@@ -330,14 +183,14 @@ var handleNav = (ev, cursor, range, size) => {
330
183
  break;
331
184
  }
332
185
  case "ArrowLeft": {
333
- if (opposite.col > 0) {
334
- opposite.col -= 1;
186
+ if (opposite.column > 0) {
187
+ opposite.column -= 1;
335
188
  }
336
189
  break;
337
190
  }
338
191
  case "ArrowRight": {
339
- if (opposite.col < size.numCols - 1) {
340
- opposite.col += 1;
192
+ if (opposite.column < size.numColumns - 1) {
193
+ opposite.column += 1;
341
194
  }
342
195
  break;
343
196
  }
@@ -355,18 +208,18 @@ var handleNav = (ev, cursor, range, size) => {
355
208
  cursor: next
356
209
  };
357
210
  };
358
- var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
211
+ var handleArrowNav = (ev, cursor, { numRows, numColumns }) => {
359
212
  switch (ev.key) {
360
213
  case "ArrowUp":
361
214
  if (cursor === void 0) {
362
215
  return {
363
216
  row: 0,
364
- col: 0
217
+ column: 0
365
218
  };
366
219
  } else if (cursor.row > 0) {
367
220
  return {
368
221
  row: ev.metaKey ? 0 : cursor.row - 1,
369
- col: cursor.col
222
+ column: cursor.column
370
223
  };
371
224
  }
372
225
  break;
@@ -374,12 +227,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
374
227
  if (cursor === void 0) {
375
228
  return {
376
229
  row: 0,
377
- col: 0
230
+ column: 0
378
231
  };
379
232
  } else if (cursor.row < numRows - 1) {
380
233
  return {
381
234
  row: ev.metaKey ? numRows - 1 : cursor.row + 1,
382
- col: cursor.col
235
+ column: cursor.column
383
236
  };
384
237
  }
385
238
  break;
@@ -387,12 +240,12 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
387
240
  if (cursor === void 0) {
388
241
  return {
389
242
  row: 0,
390
- col: 0
243
+ column: 0
391
244
  };
392
- } else if (cursor.col > 0) {
245
+ } else if (cursor.column > 0) {
393
246
  return {
394
247
  row: cursor.row,
395
- col: ev.metaKey ? 0 : cursor.col - 1
248
+ column: ev.metaKey ? 0 : cursor.column - 1
396
249
  };
397
250
  }
398
251
  break;
@@ -400,24 +253,24 @@ var handleArrowNav = (ev, cursor, { numRows, numCols }) => {
400
253
  if (cursor === void 0) {
401
254
  return {
402
255
  row: 0,
403
- col: 0
256
+ column: 0
404
257
  };
405
- } else if (cursor.col < numCols - 1) {
258
+ } else if (cursor.column < numColumns - 1) {
406
259
  return {
407
260
  row: cursor.row,
408
- col: ev.metaKey ? numCols - 1 : cursor.col + 1
261
+ column: ev.metaKey ? numColumns - 1 : cursor.column + 1
409
262
  };
410
263
  }
411
264
  break;
412
265
  case "Home":
413
266
  return {
414
267
  row: 0,
415
- col: 0
268
+ column: 0
416
269
  };
417
270
  case "End":
418
271
  return {
419
272
  row: numRows - 1,
420
- col: numCols - 1
273
+ column: numColumns - 1
421
274
  };
422
275
  }
423
276
  };
@@ -474,103 +327,31 @@ var useRangeSelect = (cb) => {
474
327
  };
475
328
 
476
329
  // packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
477
- import React3, { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useState as useState4 } from "react";
478
- import { invariant as invariant3 } from "@dxos/invariant";
479
-
480
- // packages/plugins/plugin-sheet/src/components/Sheet/decorations.ts
481
- import { create as create2 } from "@dxos/echo-schema";
482
- var createDecorations = () => {
483
- const { decorations } = create2({
484
- decorations: {}
485
- });
486
- const addDecoration = (cellIndex, decorator) => {
487
- decorations[cellIndex] = [
488
- ...decorations[cellIndex] || [],
489
- decorator
490
- ];
491
- };
492
- const removeDecoration = (cellIndex, type) => {
493
- if (type) {
494
- decorations[cellIndex] = (decorations[cellIndex] || []).filter((d) => d.type !== type);
495
- } else {
496
- delete decorations[cellIndex];
497
- }
498
- };
499
- const getDecorationsForCell = (cellIndex) => {
500
- return decorations[cellIndex];
501
- };
502
- const getAllDecorations = () => {
503
- const result = [];
504
- for (const decoratorArray of Object.values(decorations)) {
505
- for (const decorator of decoratorArray) {
506
- result.push(decorator);
507
- }
508
- }
509
- return result;
510
- };
511
- return {
512
- addDecoration,
513
- removeDecoration,
514
- getDecorationsForCell,
515
- getAllDecorations
516
- };
517
- };
518
-
519
- // packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
520
- import { useContext } from "react";
521
- import { raise } from "@dxos/debug";
522
- import { useAsyncState } from "@dxos/react-hooks";
523
-
524
- // packages/plugins/plugin-sheet/src/components/index.ts
525
- import React2 from "react";
526
-
527
- // packages/plugins/plugin-sheet/src/components/ComputeGraph/ComputeGraphContextProvider.tsx
528
- import React, { createContext } from "react";
529
- var ComputeGraphContext = /* @__PURE__ */ createContext(void 0);
530
- var ComputeGraphContextProvider = ({ registry, children }) => {
531
- return /* @__PURE__ */ React.createElement(ComputeGraphContext.Provider, {
532
- value: {
533
- registry
534
- }
535
- }, children);
536
- };
537
-
538
- // packages/plugins/plugin-sheet/src/components/index.ts
539
- var SheetContainer = React2.lazy(() => import("./SheetContainer-V4GCCZTX.mjs"));
540
-
541
- // packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
542
- var useComputeGraph = (space) => {
543
- const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
544
- return useAsyncState(async () => space && registry.getOrCreateGraph(space), [
545
- space,
546
- registry
547
- ]);
548
- };
549
-
550
- // packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
551
- import { useMemo } from "react";
330
+ import React, { createContext, useContext, useState as useState3, useEffect as useEffect2 } from "react";
331
+ import { invariant } from "@dxos/invariant";
332
+ import { fullyQualifiedId } from "@dxos/react-client/echo";
552
333
 
553
- // packages/plugins/plugin-sheet/src/model/formatting-model.ts
334
+ // packages/plugins/plugin-sheet/src/components/Sheet/formatting.ts
554
335
  var FormattingModel = class {
555
- constructor(_model) {
556
- this._model = _model;
336
+ constructor(model) {
337
+ this.model = model;
557
338
  }
558
339
  /**
559
340
  * Get formatted string value and className for cell.
560
341
  */
561
342
  getFormatting(cell) {
562
- const value = this._model.getValue(cell);
343
+ const value = this.model.getValue(cell);
563
344
  if (value === void 0 || value === null) {
564
345
  return {};
565
346
  }
566
347
  const locales = void 0;
567
- const idx = addressToIndex(this._model.sheet, cell);
568
- let formatting = this._model.sheet.formatting?.[idx] ?? {};
348
+ const idx = this.model.addressToIndex(cell);
349
+ let formatting = this.model.sheet.formatting?.[idx] ?? {};
569
350
  const classNames = [
570
351
  ...formatting?.classNames ?? []
571
352
  ];
572
- for (const [idx2, _formatting] of Object.entries(this._model.sheet.formatting)) {
573
- const range = rangeFromIndex(this._model.sheet, idx2);
353
+ for (const [idx2, _formatting] of Object.entries(this.model.sheet.formatting)) {
354
+ const range = this.model.rangeFromIndex(idx2);
574
355
  if (inRange(range, cell)) {
575
356
  if (_formatting.classNames) {
576
357
  classNames.push(..._formatting.classNames);
@@ -581,7 +362,7 @@ var FormattingModel = class {
581
362
  }
582
363
  }
583
364
  const defaultNumber = "justify-end font-mono";
584
- const type = formatting?.type ?? this._model.getValueType(cell);
365
+ const type = formatting?.type ?? this.model.getValueType(cell);
585
366
  switch (type) {
586
367
  case ValueTypeEnum.Boolean: {
587
368
  return {
@@ -631,21 +412,21 @@ var FormattingModel = class {
631
412
  // Dates.
632
413
  //
633
414
  case ValueTypeEnum.DateTime: {
634
- const date = this._model.toLocalDate(value);
415
+ const date = this.model.toLocalDate(value);
635
416
  return {
636
417
  value: date.toLocaleString(locales),
637
418
  classNames
638
419
  };
639
420
  }
640
421
  case ValueTypeEnum.Date: {
641
- const date = this._model.toLocalDate(value);
422
+ const date = this.model.toLocalDate(value);
642
423
  return {
643
424
  value: date.toLocaleDateString(locales),
644
425
  classNames
645
426
  };
646
427
  }
647
428
  case ValueTypeEnum.Time: {
648
- const date = this._model.toLocalDate(value);
429
+ const date = this.model.toLocalDate(value);
649
430
  return {
650
431
  value: date.toLocaleTimeString(locales),
651
432
  classNames
@@ -661,428 +442,84 @@ var FormattingModel = class {
661
442
  }
662
443
  };
663
444
 
664
- // packages/plugins/plugin-sheet/src/model/sheet-model.ts
665
- import { Event } from "@dxos/async";
666
- import { Resource } from "@dxos/context";
667
- import { invariant as invariant2 } from "@dxos/invariant";
668
- import { PublicKey } from "@dxos/keys";
669
- import { log } from "@dxos/log";
670
- import { DetailedCellError, ExportedCellChange } from "#hyperformula";
671
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
672
- var typeMap = {
673
- BOOLEAN: ValueTypeEnum.Boolean,
674
- NUMBER_RAW: ValueTypeEnum.Number,
675
- NUMBER_PERCENT: ValueTypeEnum.Percent,
676
- NUMBER_CURRENCY: ValueTypeEnum.Currency,
677
- NUMBER_DATETIME: ValueTypeEnum.DateTime,
678
- NUMBER_DATE: ValueTypeEnum.Date,
679
- NUMBER_TIME: ValueTypeEnum.Time
680
- };
681
- var getTopLeft = (range) => {
682
- const to = range.to ?? range.from;
683
- return {
684
- row: Math.min(range.from.row, to.row),
685
- col: Math.min(range.from.col, to.col)
686
- };
445
+ // packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
446
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
447
+ var OBJECT_ID_LENGTH = 60;
448
+ var SheetContext = /* @__PURE__ */ createContext(null);
449
+ var useSheetContext = () => {
450
+ const context = useContext(SheetContext);
451
+ invariant(context, void 0, {
452
+ F: __dxlog_file,
453
+ L: 45,
454
+ S: void 0,
455
+ A: [
456
+ "context",
457
+ ""
458
+ ]
459
+ });
460
+ return context;
687
461
  };
688
- var toSimpleCellAddress = (sheet, cell) => ({
689
- sheet,
690
- row: cell.row,
691
- col: cell.col
692
- });
693
- var toModelRange = (sheet, range) => ({
694
- start: toSimpleCellAddress(sheet, range.from),
695
- end: toSimpleCellAddress(sheet, range.to ?? range.from)
696
- });
697
- var SheetModel = class extends Resource {
698
- constructor(_graph, _sheet, _options = {}) {
699
- super();
700
- this._graph = _graph;
701
- this._sheet = _sheet;
702
- this._options = _options;
703
- this.id = `model-${PublicKey.random().truncate()}`;
704
- this.update = new Event();
705
- this._node = this._graph.getOrCreateNode(createSheetName(this._sheet.id));
706
- this.reset();
707
- }
708
- get graph() {
709
- return this._graph;
710
- }
711
- get sheet() {
712
- return this._sheet;
713
- }
714
- get readonly() {
715
- return this._options.readonly;
716
- }
717
- get bounds() {
718
- return {
719
- rows: this._sheet.rows.length,
720
- columns: this._sheet.columns.length
721
- };
722
- }
723
- /**
724
- * Initialize sheet and engine.
725
- */
726
- async _open() {
727
- log("initialize", {
728
- id: this.id
729
- }, {
730
- F: __dxlog_file2,
731
- L: 105,
732
- S: this,
733
- C: (f, a) => f(...a)
734
- });
735
- initialize(this._sheet);
736
- this.reset();
737
- const unsubscribe = this._graph.update.on(() => this.update.emit());
738
- this._ctx.onDispose(unsubscribe);
739
- }
740
- /**
741
- * Update engine.
742
- * NOTE: This resets the undo history.
743
- * @deprecated
744
- */
745
- reset() {
746
- this._node.hf.clearSheet(this._node.sheetId);
747
- Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
748
- const { col, row } = addressFromIndex(this._sheet, key);
749
- if (typeof value === "string" && value.charAt(0) === "=") {
750
- value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
751
- }
752
- this._node.hf.setCellContents({
753
- sheet: this._node.sheetId,
754
- row,
755
- col
756
- }, value);
757
- });
758
- }
759
- /**
760
- * Recalculate formulas.
761
- * NOTE: This resets the undo history.
762
- * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
763
- * @deprecated
764
- */
765
- // TODO(burdon): Remove.
766
- recalculate() {
767
- this._node.hf.rebuildAndRecalculate();
768
- }
769
- insertRows(i, n = 1) {
770
- insertIndices(this._sheet.rows, i, n, MAX_ROWS);
771
- this.reset();
772
- }
773
- insertColumns(i, n = 1) {
774
- insertIndices(this._sheet.columns, i, n, MAX_COLUMNS);
775
- this.reset();
776
- }
777
- //
778
- // Undoable actions.
779
- // TODO(burdon): Group undoable methods; consistently update hf/sheet.
780
- //
781
- /**
782
- * Clear range of values.
783
- */
784
- clear(range) {
785
- const topLeft = getTopLeft(range);
786
- const values = this._iterRange(range, () => null);
787
- this._node.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
788
- this._iterRange(range, (cell) => {
789
- const idx = addressToIndex(this._sheet, cell);
790
- delete this._sheet.cells[idx];
791
- });
792
- }
793
- cut(range) {
794
- this._node.hf.cut(toModelRange(this._node.sheetId, range));
795
- this._iterRange(range, (cell) => {
796
- const idx = addressToIndex(this._sheet, cell);
797
- delete this._sheet.cells[idx];
798
- });
799
- }
800
- copy(range) {
801
- this._node.hf.copy(toModelRange(this._node.sheetId, range));
802
- }
803
- paste(cell) {
804
- if (!this._node.hf.isClipboardEmpty()) {
805
- const changes = this._node.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
806
- for (const change of changes) {
807
- if (change instanceof ExportedCellChange) {
808
- const { address, newValue } = change;
809
- const idx = addressToIndex(this._sheet, {
810
- row: address.row,
811
- col: address.col
812
- });
813
- this._sheet.cells[idx] = {
814
- value: newValue
815
- };
816
- }
817
- }
818
- }
819
- }
820
- // TODO(burdon): Display undo/redo state.
821
- undo() {
822
- if (this._node.hf.isThereSomethingToUndo()) {
823
- this._node.hf.undo();
824
- this.update.emit();
825
- }
826
- }
827
- redo() {
828
- if (this._node.hf.isThereSomethingToRedo()) {
829
- this._node.hf.redo();
830
- this.update.emit();
462
+ var mapFormulaBindingToId = (functions) => (formula) => {
463
+ return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
464
+ if (defaultFunctions.find((fn2) => fn2.name === binding) || binding === "EDGE") {
465
+ return match;
831
466
  }
832
- }
833
- /**
834
- * Get value from sheet.
835
- */
836
- getCellValue(cell) {
837
- const idx = addressToIndex(this._sheet, cell);
838
- return this._sheet.cells[idx]?.value ?? null;
839
- }
840
- /**
841
- * Get value as a string for editing.
842
- */
843
- getCellText(cell) {
844
- const value = this.getCellValue(cell);
845
- if (value == null) {
846
- return void 0;
847
- }
848
- if (typeof value === "string" && value.charAt(0) === "=") {
849
- return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
467
+ const fn = functions.find((fn2) => fn2.binding === binding);
468
+ if (fn) {
469
+ return `${fullyQualifiedId(fn)}(${args})`;
850
470
  } else {
851
- return String(value);
852
- }
853
- }
854
- /**
855
- * Get array of raw values from sheet.
856
- */
857
- getCellValues(range) {
858
- return this._iterRange(range, (cell) => this.getCellValue(cell));
859
- }
860
- /**
861
- * Gets the regular or computed value from the engine.
862
- */
863
- getValue(cell) {
864
- const value = this._node.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
865
- if (value instanceof DetailedCellError) {
866
- return value.toString();
471
+ return match;
867
472
  }
868
- return value;
869
- }
870
- /**
871
- * Get value type.
872
- */
873
- getValueType(cell) {
874
- const addr = toSimpleCellAddress(this._node.sheetId, cell);
875
- const type = this._node.hf.getCellValueDetailedType(addr);
876
- return typeMap[type];
877
- }
878
- /**
879
- * Sets the value, updating the sheet and engine.
880
- */
881
- setValue(cell, value) {
882
- if (this._options.readonly) {
883
- throw new ReadonlyException();
884
- }
885
- let refresh = false;
886
- if (cell.row >= this._sheet.rows.length) {
887
- insertIndices(this._sheet.rows, cell.row, 1, MAX_ROWS);
888
- refresh = true;
889
- }
890
- if (cell.col >= this._sheet.columns.length) {
891
- insertIndices(this._sheet.columns, cell.col, 1, MAX_COLUMNS);
892
- refresh = true;
893
- }
894
- if (refresh) {
895
- this.reset();
473
+ });
474
+ };
475
+ var mapFormulaBindingFromId = (functions) => (formula) => {
476
+ return formula.replace(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
477
+ const id = `${spaceId}:${objectId}`;
478
+ if (id.length !== OBJECT_ID_LENGTH) {
479
+ return match;
896
480
  }
897
- this._node.hf.setCellContents({
898
- sheet: this._node.sheetId,
899
- row: cell.row,
900
- col: cell.col
901
- }, [
902
- [
903
- typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value
904
- ]
905
- ]);
906
- const idx = addressToIndex(this._sheet, cell);
907
- if (value === void 0 || value === null) {
908
- delete this._sheet.cells[idx];
481
+ const fn = functions.find((fn2) => fullyQualifiedId(fn2) === id);
482
+ if (fn?.binding) {
483
+ return `${fn.binding}(${args})`;
909
484
  } else {
910
- if (typeof value === "string" && value.charAt(0) === "=") {
911
- value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
912
- }
913
- this._sheet.cells[idx] = {
914
- value
915
- };
485
+ return match;
916
486
  }
917
- }
918
- /**
919
- * Sets values from a simple map.
920
- */
921
- setValues(values) {
922
- Object.entries(values).forEach(([key, { value }]) => {
923
- this.setValue(addressFromA1Notation(key), value);
924
- });
925
- }
926
- /**
927
- * Iterate range.
928
- */
929
- _iterRange(range, cb) {
930
- const to = range.to ?? range.from;
931
- const rowRange = [
932
- Math.min(range.from.row, to.row),
933
- Math.max(range.from.row, to.row)
934
- ];
935
- const columnRange = [
936
- Math.min(range.from.col, to.col),
937
- Math.max(range.from.col, to.col)
938
- ];
939
- const rows = [];
940
- for (let row = rowRange[0]; row <= rowRange[1]; row++) {
941
- const rowCells = [];
942
- for (let column = columnRange[0]; column <= columnRange[1]; column++) {
943
- const value = cb({
944
- row,
945
- col: column
946
- });
947
- if (value !== void 0) {
948
- rowCells.push(value);
949
- }
950
- }
951
- rows.push(rowCells);
952
- }
953
- return rows;
954
- }
955
- // TODO(burdon): Delete index.
956
- _deleteIndices(indices, i, n) {
957
- throw new Error("Not implemented");
958
- }
959
- // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
960
- _moveIndices(indices, i, j, n) {
961
- throw new Error("Not implemented");
962
- }
963
- //
964
- // Indices.
965
- //
966
- /**
967
- * Map from A1 notation to indices.
968
- */
969
- mapFormulaRefsToIndices(formula) {
970
- invariant2(formula.charAt(0) === "=", void 0, {
971
- F: __dxlog_file2,
972
- L: 358,
973
- S: this,
974
- A: [
975
- "formula.charAt(0) === '='",
976
- ""
977
- ]
978
- });
979
- return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
980
- return addressToIndex(this._sheet, addressFromA1Notation(match));
981
- });
982
- }
983
- /**
984
- * Map from indices to A1 notation.
985
- */
986
- mapFormulaIndicesToRefs(formula) {
987
- invariant2(formula.charAt(0) === "=", void 0, {
988
- F: __dxlog_file2,
989
- L: 368,
990
- S: this,
991
- A: [
992
- "formula.charAt(0) === '='",
993
- ""
994
- ]
995
- });
996
- return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
997
- return addressToA1Notation(addressFromIndex(this._sheet, idx));
998
- });
999
- }
1000
- //
1001
- // Values
1002
- //
1003
- /**
1004
- * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
1005
- * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
1006
- * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
1007
- */
1008
- toLocalDate(num) {
1009
- const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
1010
- return new Date(year, month - 1, day, hours, minutes, seconds);
1011
- }
1012
- toDateTime(num) {
1013
- return this._node.hf.numberToDateTime(num);
1014
- }
1015
- toDate(num) {
1016
- return this._node.hf.numberToDate(num);
1017
- }
1018
- toTime(num) {
1019
- return this._node.hf.numberToTime(num);
1020
- }
1021
- };
1022
-
1023
- // packages/plugins/plugin-sheet/src/hooks/useFormattingModel.ts
1024
- var useFormattingModel = (model) => {
1025
- return useMemo(() => model && new FormattingModel(model), [
1026
- model
1027
- ]);
487
+ });
1028
488
  };
1029
-
1030
- // packages/plugins/plugin-sheet/src/hooks/useSheetModel.ts
1031
- import { useEffect as useEffect2, useState as useState3 } from "react";
1032
- var useSheetModel = (space, sheet, { readonly } = {}) => {
1033
- const graph = useComputeGraph(space);
1034
- const [model, setModel] = useState3();
489
+ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo, ...options }) => {
490
+ const graph = useComputeGraph(space, options);
491
+ const [cursor, setCursor] = useState3();
492
+ const [range, setRange] = useState3();
493
+ const [editing, setEditing] = useState3(false);
494
+ const [[model, formatting] = [], setModels] = useState3(void 0);
1035
495
  useEffect2(() => {
1036
- if (!space || !graph || !sheet) {
1037
- return;
1038
- }
1039
496
  let model2;
497
+ let formatting2;
1040
498
  const t = setTimeout(async () => {
1041
- model2 = new SheetModel(graph, sheet, {
1042
- readonly
499
+ model2 = new SheetModel(graph, sheet, space, {
500
+ readonly,
501
+ mapFormulaBindingToId,
502
+ mapFormulaBindingFromId
1043
503
  });
1044
- await model2.open();
1045
- setModel(model2);
504
+ await model2.initialize();
505
+ formatting2 = new FormattingModel(model2);
506
+ setModels([
507
+ model2,
508
+ formatting2
509
+ ]);
1046
510
  });
1047
511
  return () => {
1048
512
  clearTimeout(t);
1049
- void model2?.close();
513
+ void model2?.destroy();
1050
514
  };
1051
515
  }, [
1052
- space,
1053
- sheet,
1054
516
  graph,
1055
517
  readonly
1056
518
  ]);
1057
- return model;
1058
- };
1059
-
1060
- // packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx
1061
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/sheet-context.tsx";
1062
- var SheetContext = /* @__PURE__ */ createContext2(null);
1063
- var useSheetContext = () => {
1064
- const context = useContext2(SheetContext);
1065
- invariant3(context, void 0, {
1066
- F: __dxlog_file3,
1067
- L: 43,
1068
- S: void 0,
1069
- A: [
1070
- "context",
1071
- ""
1072
- ]
1073
- });
1074
- return context;
1075
- };
1076
- var SheetContextProvider = ({ children, sheet, space, readonly, onInfo }) => {
1077
- const model = useSheetModel(space, sheet, {
1078
- readonly
1079
- });
1080
- const formatting = useFormattingModel(model);
1081
- const [cursor, setCursor] = useState4();
1082
- const [range, setRange] = useState4();
1083
- const [editing, setEditing] = useState4(false);
1084
- const decorations = useMemo2(() => createDecorations(), []);
1085
- return !model || !formatting ? null : /* @__PURE__ */ React3.createElement(SheetContext.Provider, {
519
+ if (!model || !formatting) {
520
+ return null;
521
+ }
522
+ return /* @__PURE__ */ React.createElement(SheetContext.Provider, {
1086
523
  value: {
1087
524
  model,
1088
525
  formatting,
@@ -1093,177 +530,11 @@ var SheetContextProvider = ({ children, sheet, space, readonly, onInfo }) => {
1093
530
  editing,
1094
531
  setEditing,
1095
532
  // TODO(burdon): Change to event.
1096
- onInfo,
1097
- decorations
533
+ onInfo
1098
534
  }
1099
535
  }, children);
1100
536
  };
1101
537
 
1102
- // packages/plugins/plugin-sheet/src/components/Sheet/threads.tsx
1103
- import { effect } from "@preact/signals-core";
1104
- import React4, { useCallback, useEffect as useEffect3, useMemo as useMemo3 } from "react";
1105
- import { LayoutAction, useIntentDispatcher, useIntentResolver } from "@dxos/app-framework";
1106
- import { debounce } from "@dxos/async";
1107
- import { fullyQualifiedId } from "@dxos/react-client/echo";
1108
- import { Icon, useTranslation } from "@dxos/react-ui";
1109
- var CommentIndicator = () => {
1110
- return /* @__PURE__ */ React4.createElement("div", {
1111
- role: "none",
1112
- className: "absolute top-0 right-0 w-0 h-0 border-t-8 border-l-8 border-t-cmCommentSurface border-l-transparent"
1113
- });
1114
- };
1115
- var ThreadedCellWrapper = ({ children }) => {
1116
- const dispatch = useIntentDispatcher();
1117
- const [isHovered, setIsHovered] = React4.useState(false);
1118
- const { t } = useTranslation(SHEET_PLUGIN);
1119
- const handleClick = React4.useCallback((_event) => {
1120
- void dispatch({
1121
- action: LayoutAction.SET_LAYOUT,
1122
- data: {
1123
- element: "complementary",
1124
- state: true
1125
- }
1126
- });
1127
- }, [
1128
- dispatch
1129
- ]);
1130
- return /* @__PURE__ */ React4.createElement("div", {
1131
- role: "none",
1132
- className: "relative h-full is-full",
1133
- onMouseEnter: () => {
1134
- setIsHovered(true);
1135
- },
1136
- onMouseLeave: () => {
1137
- setIsHovered(false);
1138
- }
1139
- }, /* @__PURE__ */ React4.createElement(CommentIndicator, null), isHovered && /* @__PURE__ */ React4.createElement("div", {
1140
- className: "absolute inset-0 flex items-center justify-end pr-1"
1141
- }, /* @__PURE__ */ React4.createElement("button", {
1142
- className: "ch-button text-xs min-bs-0 p-1",
1143
- onClick: handleClick,
1144
- "aria-label": t("open comment for sheet cell")
1145
- }, /* @__PURE__ */ React4.createElement(Icon, {
1146
- icon: "ph--chat--regular",
1147
- "aria-hidden": true
1148
- }))), children);
1149
- };
1150
- var createThreadDecoration = (cellIndex, threadId, sheetId) => {
1151
- return {
1152
- type: "comment",
1153
- cellIndex,
1154
- decorate: (props) => /* @__PURE__ */ React4.createElement(ThreadedCellWrapper, props)
1155
- };
1156
- };
1157
- var useUpdateCursorOnThreadSelection = () => {
1158
- const { setCursor, model } = useSheetContext();
1159
- const handleScrollIntoView = useCallback(({ action, data }) => {
1160
- switch (action) {
1161
- case LayoutAction.SCROLL_INTO_VIEW: {
1162
- if (!data?.id || data?.cursor === void 0 || data?.id !== fullyQualifiedId(model.sheet)) {
1163
- return;
1164
- }
1165
- const cellAddress = addressFromIndex(model.sheet, data.cursor);
1166
- setCursor(cellAddress);
1167
- }
1168
- }
1169
- }, [
1170
- model.sheet,
1171
- setCursor
1172
- ]);
1173
- useIntentResolver(SHEET_PLUGIN, handleScrollIntoView);
1174
- };
1175
- var useSelectThreadOnCursorChange = () => {
1176
- const { cursor, model } = useSheetContext();
1177
- const dispatch = useIntentDispatcher();
1178
- const activeThreads = useMemo3(() => model.sheet.threads?.filter((thread) => !!thread && thread.status === "active") ?? [], [
1179
- JSON.stringify(model.sheet.threads)
1180
- ]);
1181
- const activeThreadAddresses = useMemo3(() => activeThreads.map((thread) => thread.anchor).filter((anchor) => anchor !== void 0).map((anchor) => addressFromIndex(model.sheet, anchor)), [
1182
- activeThreads,
1183
- model.sheet
1184
- ]);
1185
- const selectClosestThread = useCallback((cellAddress) => {
1186
- if (!cellAddress || !activeThreads) {
1187
- return;
1188
- }
1189
- const closestThreadAnchor = closest(cellAddress, activeThreadAddresses);
1190
- if (closestThreadAnchor) {
1191
- const closestThread = activeThreads.find((thread) => thread && thread.anchor === addressToIndex(model.sheet, closestThreadAnchor));
1192
- if (closestThread) {
1193
- void dispatch([
1194
- {
1195
- action: "dxos.org/plugin/thread/action/select",
1196
- data: {
1197
- current: fullyQualifiedId(closestThread)
1198
- }
1199
- }
1200
- ]);
1201
- }
1202
- }
1203
- }, [
1204
- dispatch,
1205
- activeThreads,
1206
- activeThreadAddresses,
1207
- model.sheet
1208
- ]);
1209
- const debounced = useMemo3(() => {
1210
- return debounce((cursor2) => requestAnimationFrame(() => selectClosestThread(cursor2)), 50);
1211
- }, [
1212
- selectClosestThread
1213
- ]);
1214
- useEffect3(() => {
1215
- if (!cursor) {
1216
- return;
1217
- }
1218
- debounced(cursor);
1219
- }, [
1220
- cursor,
1221
- selectClosestThread
1222
- ]);
1223
- };
1224
- var useThreadDecorations = () => {
1225
- const { decorations, model } = useSheetContext();
1226
- const sheet = useMemo3(() => model.sheet, [
1227
- model.sheet
1228
- ]);
1229
- const sheetId = useMemo3(() => fullyQualifiedId(sheet), [
1230
- sheet
1231
- ]);
1232
- useEffect3(() => {
1233
- const unsubscribe = effect(() => {
1234
- const activeThreadAnchors = /* @__PURE__ */ new Set();
1235
- if (!sheet.threads) {
1236
- return;
1237
- }
1238
- for (const thread of sheet.threads) {
1239
- if (!thread || thread.anchor === void 0 || thread.status === "resolved") {
1240
- continue;
1241
- }
1242
- activeThreadAnchors.add(thread.anchor);
1243
- const index = thread.anchor;
1244
- const existingDecorations = decorations.getDecorationsForCell(index);
1245
- if (!existingDecorations || !existingDecorations.some((d) => d.type === "comment")) {
1246
- decorations.addDecoration(index, createThreadDecoration(index, thread.id, sheetId));
1247
- }
1248
- }
1249
- for (const decoration of decorations.getAllDecorations()) {
1250
- if (decoration.type !== "comment") {
1251
- continue;
1252
- }
1253
- if (!activeThreadAnchors.has(decoration.cellIndex)) {
1254
- decorations.removeDecoration(decoration.cellIndex, "comment");
1255
- }
1256
- }
1257
- });
1258
- return () => unsubscribe();
1259
- });
1260
- };
1261
- var useThreads = () => {
1262
- useUpdateCursorOnThreadSelection();
1263
- useSelectThreadOnCursorChange();
1264
- useThreadDecorations();
1265
- };
1266
-
1267
538
  // packages/plugins/plugin-sheet/src/components/Sheet/util.ts
1268
539
  var getRelativeClientRect = (root, element) => {
1269
540
  const rootRect = root.getBoundingClientRect();
@@ -1299,7 +570,7 @@ var scrollIntoView = (scrollContainer, el) => {
1299
570
 
1300
571
  // packages/plugins/plugin-sheet/src/components/CellEditor/CellEditor.tsx
1301
572
  import { EditorView, keymap } from "@codemirror/view";
1302
- import React5 from "react";
573
+ import React2 from "react";
1303
574
  import { useThemeContext } from "@dxos/react-ui";
1304
575
  import { createBasicExtensions, createThemeExtensions, preventNewline, useTextEditor } from "@dxos/react-ui-editor";
1305
576
  var editorKeys = ({ onNav, onClose }) => {
@@ -1347,60 +618,20 @@ var editorKeys = ({ onNav, onClose }) => {
1347
618
  {
1348
619
  key: "Enter",
1349
620
  run: (editor) => {
1350
- onClose(editor.state.doc.toString(), {
1351
- key: "Enter"
1352
- });
1353
- return true;
1354
- },
1355
- shift: (editor) => {
1356
- onClose(editor.state.doc.toString(), {
1357
- key: "Enter",
1358
- shift: true
1359
- });
1360
- return true;
1361
- }
1362
- },
1363
- {
1364
- key: "Tab",
1365
- run: (editor) => {
1366
- onClose(editor.state.doc.toString(), {
1367
- key: "Tab"
1368
- });
1369
- return true;
1370
- },
1371
- shift: (editor) => {
1372
- onClose(editor.state.doc.toString(), {
1373
- key: "Tab",
1374
- shift: true
1375
- });
621
+ onClose(editor.state.doc.toString());
1376
622
  return true;
1377
623
  }
1378
624
  },
1379
625
  {
1380
626
  key: "Escape",
1381
627
  run: () => {
1382
- onClose(void 0, {
1383
- key: "Escape"
1384
- });
628
+ onClose(void 0);
1385
629
  return true;
1386
630
  }
1387
631
  }
1388
632
  ]);
1389
633
  };
1390
- var editorVariants = {
1391
- // TODO(thure): remove when legacy is no longer used.
1392
- legacy: {
1393
- root: "flex w-full",
1394
- editor: "flex w-full [&>.cm-scroller]:scrollbar-none",
1395
- content: "!px-2 !py-1"
1396
- },
1397
- grid: {
1398
- root: "absolute z-[1]",
1399
- editor: "[&>.cm-scroller]:scrollbar-none tabular-nums",
1400
- content: "!border !border-transparent !p-0.5"
1401
- }
1402
- };
1403
- var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box, gridId }) => {
634
+ var CellEditor = ({ value, extension, autoFocus, onBlur }) => {
1404
635
  const { themeMode } = useThemeContext();
1405
636
  const { parentRef } = useTextEditor(() => {
1406
637
  return {
@@ -1427,29 +658,21 @@ var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box
1427
658
  themeMode,
1428
659
  slots: {
1429
660
  editor: {
1430
- className: editorVariants[variant].editor
661
+ className: "flex w-full [&>.cm-scroller]:scrollbar-none"
1431
662
  },
1432
663
  content: {
1433
- className: editorVariants[variant].content
664
+ className: "!px-2 !py-1"
1434
665
  }
1435
666
  }
1436
667
  })
1437
668
  ]
1438
669
  };
1439
670
  }, [
1440
- extension,
1441
- autoFocus,
1442
- value,
1443
- variant,
1444
- onBlur
671
+ extension
1445
672
  ]);
1446
- return /* @__PURE__ */ React5.createElement("div", {
673
+ return /* @__PURE__ */ React2.createElement("div", {
1447
674
  ref: parentRef,
1448
- className: editorVariants[variant].root,
1449
- style: box,
1450
- ...gridId && {
1451
- "data-grid": gridId
1452
- }
675
+ className: "flex w-full"
1453
676
  });
1454
677
  };
1455
678
 
@@ -1571,7 +794,13 @@ var sheetExtension = ({ functions = [] }) => {
1571
794
  // NOTE: Useful for debugging.
1572
795
  closeOnBlur: false,
1573
796
  icons: false,
1574
- tooltipClass: () => mx("!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]", "[&>ul>li[aria-selected]]:!bg-accentSurface", "border-separator")
797
+ tooltipClass: () => mx(
798
+ // TODO(burdon): Factor out fragments.
799
+ // TODO(burdon): Size to make width same as column.
800
+ "!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]",
801
+ "[&>ul>li[aria-selected]]:!bg-accentSurface",
802
+ "border-separator"
803
+ )
1575
804
  }),
1576
805
  keymap2.of([
1577
806
  {
@@ -1660,7 +889,7 @@ var visitTree = (node, callback) => {
1660
889
  };
1661
890
 
1662
891
  // packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
1663
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
892
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx";
1664
893
  var fragments = {
1665
894
  axis: "bg-axisSurface text-axisText text-xs select-none",
1666
895
  axisSelected: "bg-attention text-baseText",
@@ -1668,26 +897,25 @@ var fragments = {
1668
897
  cellSelected: "bg-gridCellSelected text-baseText border !border-accentSurface"
1669
898
  };
1670
899
  var SheetRoot = ({ children, ...props }) => {
1671
- return /* @__PURE__ */ React6.createElement(SheetContextProvider, props, children);
900
+ return /* @__PURE__ */ React3.createElement(SheetContextProvider, props, children);
1672
901
  };
1673
- var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, forwardRef2) => {
902
+ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numColumns }, forwardRef2) => {
1674
903
  const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
1675
904
  const { rowsRef, columnsRef, contentRef } = useScrollHandlers();
1676
- useThreads();
1677
- const [rows, setRows] = useState5([
905
+ const [rows, setRows] = useState4([
1678
906
  ...model.sheet.rows
1679
907
  ]);
1680
- const [columns, setColumns] = useState5([
908
+ const [columns, setColumns] = useState4([
1681
909
  ...model.sheet.columns
1682
910
  ]);
1683
- useEffect4(() => {
911
+ useEffect3(() => {
1684
912
  const rowsAccessor = createDocAccessor(model.sheet, [
1685
913
  "rows"
1686
914
  ]);
1687
915
  const columnsAccessor = createDocAccessor(model.sheet, [
1688
916
  "columns"
1689
917
  ]);
1690
- const handleUpdate = debounce2(() => {
918
+ const handleUpdate = debounce(() => {
1691
919
  setRows([
1692
920
  ...model.sheet.rows
1693
921
  ]);
@@ -1705,44 +933,44 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, fo
1705
933
  }, [
1706
934
  model
1707
935
  ]);
1708
- useEffect4(() => {
936
+ useEffect3(() => {
1709
937
  model.reset();
1710
938
  }, [
1711
939
  rows,
1712
940
  columns
1713
941
  ]);
1714
942
  const handleMoveRows = (from, to, num = 1) => {
1715
- const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
943
+ const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
1716
944
  const [rows2] = model.sheet.rows.splice(from, num);
1717
945
  model.sheet.rows.splice(to, 0, rows2);
1718
946
  if (cursorIdx) {
1719
- setCursor(addressFromIndex(model.sheet, cursorIdx));
947
+ setCursor(model.addressFromIndex(cursorIdx));
1720
948
  }
1721
949
  setRows([
1722
950
  ...model.sheet.rows
1723
951
  ]);
1724
952
  };
1725
953
  const handleMoveColumns = (from, to, num = 1) => {
1726
- const cursorIdx = cursor ? addressToIndex(model.sheet, cursor) : void 0;
954
+ const cursorIdx = cursor ? model.addressToIndex(cursor) : void 0;
1727
955
  const columns2 = model.sheet.columns.splice(from, num);
1728
956
  model.sheet.columns.splice(to, 0, ...columns2);
1729
957
  if (cursorIdx) {
1730
- setCursor(addressFromIndex(model.sheet, cursorIdx));
958
+ setCursor(model.addressFromIndex(cursorIdx));
1731
959
  }
1732
960
  setColumns([
1733
961
  ...model.sheet.columns
1734
962
  ]);
1735
963
  };
1736
- const [rowSizes, setRowSizes] = useState5();
1737
- const [columnSizes, setColumnSizes] = useState5();
1738
- useEffect4(() => {
964
+ const [rowSizes, setRowSizes] = useState4();
965
+ const [columnSizes, setColumnSizes] = useState4();
966
+ useEffect3(() => {
1739
967
  const rowAccessor = createDocAccessor(model.sheet, [
1740
968
  "rowMeta"
1741
969
  ]);
1742
970
  const columnAccessor = createDocAccessor(model.sheet, [
1743
971
  "columnMeta"
1744
972
  ]);
1745
- const handleUpdate = debounce2(() => {
973
+ const handleUpdate = debounce(() => {
1746
974
  const mapSizes = (values) => values.reduce((map, [idx, meta]) => {
1747
975
  if (meta.size) {
1748
976
  map[idx] = meta.size;
@@ -1784,54 +1012,54 @@ var SheetMain = /* @__PURE__ */ forwardRef(({ classNames, numRows, numCols }, fo
1784
1012
  }));
1785
1013
  }
1786
1014
  };
1787
- return /* @__PURE__ */ React6.createElement("div", {
1015
+ return /* @__PURE__ */ React3.createElement("div", {
1788
1016
  role: "none",
1789
1017
  className: mx2("grid grid-cols-[calc(var(--rail-size)-2px)_1fr] grid-rows-[32px_1fr_32px] bs-full is-full overflow-hidden", classNames)
1790
- }, /* @__PURE__ */ React6.createElement(GridCorner, {
1018
+ }, /* @__PURE__ */ React3.createElement(GridCorner, {
1791
1019
  onClick: () => {
1792
1020
  setCursor(void 0);
1793
1021
  setRange(void 0);
1794
1022
  setEditing(false);
1795
1023
  }
1796
- }), /* @__PURE__ */ React6.createElement(SheetColumns, {
1024
+ }), /* @__PURE__ */ React3.createElement(SheetColumns, {
1797
1025
  ref: columnsRef,
1798
1026
  columns,
1799
1027
  sizes: columnSizes,
1800
- selected: cursor?.col,
1801
- onSelect: (col) => setCursor(cursor?.col === col ? void 0 : {
1028
+ selected: cursor?.column,
1029
+ onSelect: (column) => setCursor(cursor?.column === column ? void 0 : {
1802
1030
  row: -1,
1803
- col
1031
+ column
1804
1032
  }),
1805
1033
  onResize: handleResizeColumn,
1806
1034
  onMove: handleMoveColumns
1807
- }), /* @__PURE__ */ React6.createElement(SheetRows, {
1035
+ }), /* @__PURE__ */ React3.createElement(SheetRows, {
1808
1036
  ref: rowsRef,
1809
1037
  rows,
1810
1038
  sizes: rowSizes,
1811
1039
  selected: cursor?.row,
1812
1040
  onSelect: (row) => setCursor(cursor?.row === row ? void 0 : {
1813
1041
  row,
1814
- col: -1
1042
+ column: -1
1815
1043
  }),
1816
1044
  onResize: handleResizeRow,
1817
1045
  onMove: handleMoveRows
1818
- }), /* @__PURE__ */ React6.createElement(SheetGrid, {
1046
+ }), /* @__PURE__ */ React3.createElement(SheetGrid, {
1819
1047
  ref: contentRef,
1820
1048
  size: {
1821
1049
  numRows: numRows ?? rows.length,
1822
- numCols: numCols ?? columns.length
1050
+ numColumns: numColumns ?? columns.length
1823
1051
  },
1824
1052
  rows,
1825
1053
  columns,
1826
1054
  rowSizes,
1827
1055
  columnSizes
1828
- }), /* @__PURE__ */ React6.createElement(GridCorner, null), /* @__PURE__ */ React6.createElement(SheetStatusBar, null));
1056
+ }), /* @__PURE__ */ React3.createElement(GridCorner, null), /* @__PURE__ */ React3.createElement(SheetStatusBar, null));
1829
1057
  });
1830
1058
  var useScrollHandlers = () => {
1831
1059
  const rowsRef = useRef(null);
1832
1060
  const columnsRef = useRef(null);
1833
1061
  const contentRef = useRef(null);
1834
- useEffect4(() => {
1062
+ useEffect3(() => {
1835
1063
  const handleRowsScroll = (ev) => {
1836
1064
  const { scrollTop } = ev.target;
1837
1065
  if (!rowsRef.current.dataset.locked) {
@@ -1868,13 +1096,13 @@ var useScrollHandlers = () => {
1868
1096
  };
1869
1097
  };
1870
1098
  var GridCorner = (props) => {
1871
- return /* @__PURE__ */ React6.createElement("div", {
1099
+ return /* @__PURE__ */ React3.createElement("div", {
1872
1100
  className: fragments.axis,
1873
1101
  ...props
1874
1102
  });
1875
1103
  };
1876
1104
  var MovingOverlay = ({ label }) => {
1877
- return /* @__PURE__ */ React6.createElement("div", {
1105
+ return /* @__PURE__ */ React3.createElement("div", {
1878
1106
  className: "flex w-full h-full justify-center items-center text-sm p-1 bg-gridOverlay cursor-pointer"
1879
1107
  }, label);
1880
1108
  };
@@ -1894,7 +1122,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1894
1122
  });
1895
1123
  const keyboardSensor = useSensor(KeyboardSensor, {});
1896
1124
  const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
1897
- const [active, setActive] = useState5(null);
1125
+ const [active, setActive] = useState4(null);
1898
1126
  const handleDragStart = ({ active: active2 }) => {
1899
1127
  setActive(active2);
1900
1128
  };
@@ -1918,18 +1146,18 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1918
1146
  }
1919
1147
  return transform;
1920
1148
  };
1921
- return /* @__PURE__ */ React6.createElement("div", {
1149
+ return /* @__PURE__ */ React3.createElement("div", {
1922
1150
  className: "relative flex grow overflow-hidden"
1923
- }, /* @__PURE__ */ React6.createElement("div", {
1151
+ }, /* @__PURE__ */ React3.createElement("div", {
1924
1152
  className: mx2("z-20 absolute inset-0 border-y border-gridLine pointer-events-none"),
1925
1153
  style: {
1926
1154
  width: axisWidth
1927
1155
  }
1928
- }), /* @__PURE__ */ React6.createElement("div", {
1156
+ }), /* @__PURE__ */ React3.createElement("div", {
1929
1157
  ref: forwardRef2,
1930
1158
  role: "rowheader",
1931
1159
  className: "grow overflow-y-auto scrollbar-none"
1932
- }, /* @__PURE__ */ React6.createElement(DndContext, {
1160
+ }, /* @__PURE__ */ React3.createElement(DndContext, {
1933
1161
  sensors,
1934
1162
  modifiers: [
1935
1163
  restrictToVerticalAxis,
@@ -1937,12 +1165,12 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1937
1165
  ],
1938
1166
  onDragStart: handleDragStart,
1939
1167
  onDragEnd: handleDragEnd
1940
- }, /* @__PURE__ */ React6.createElement("div", {
1168
+ }, /* @__PURE__ */ React3.createElement("div", {
1941
1169
  className: "flex flex-col",
1942
1170
  style: {
1943
1171
  width: axisWidth
1944
1172
  }
1945
- }, rows.map((idx, index) => /* @__PURE__ */ React6.createElement(GridRowCell, {
1173
+ }, rows.map((idx, index) => /* @__PURE__ */ React3.createElement(GridRowCell, {
1946
1174
  key: idx,
1947
1175
  idx,
1948
1176
  index,
@@ -1952,7 +1180,7 @@ var SheetRows = /* @__PURE__ */ forwardRef(({ rows, sizes, selected, onSelect, o
1952
1180
  selected: selected === index,
1953
1181
  onResize,
1954
1182
  onSelect
1955
- }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
1183
+ }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement(DragOverlay, null, active && /* @__PURE__ */ React3.createElement(MovingOverlay, {
1956
1184
  label: String(active.data.current.index + 1)
1957
1185
  })), document.body))));
1958
1186
  });
@@ -1970,8 +1198,8 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
1970
1198
  }
1971
1199
  });
1972
1200
  const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
1973
- const [initialSize, setInitialSize] = useState5(size);
1974
- const [resizing, setResizing] = useState5(false);
1201
+ const [initialSize, setInitialSize] = useState4(size);
1202
+ const [resizing, setResizing] = useState4(false);
1975
1203
  const scrollHandler = useRef();
1976
1204
  const handleResizeStart = (_ev, _dir, elementRef) => {
1977
1205
  const scrollContainer = elementRef.closest('[role="rowheader"]');
@@ -1993,7 +1221,7 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
1993
1221
  onResize?.(idx, initialSize + height, true);
1994
1222
  setResizing(false);
1995
1223
  };
1996
- return /* @__PURE__ */ React6.createElement(Resizable, {
1224
+ return /* @__PURE__ */ React3.createElement(Resizable, {
1997
1225
  enable: {
1998
1226
  bottom: resize
1999
1227
  },
@@ -2005,17 +1233,17 @@ var GridRowCell = ({ idx, index, label, size, resize, selected, onSelect, onResi
2005
1233
  onResizeStart: handleResizeStart,
2006
1234
  onResize: handleResize,
2007
1235
  onResizeStop: handleResizeStop
2008
- }, /* @__PURE__ */ React6.createElement("div", {
1236
+ }, /* @__PURE__ */ React3.createElement("div", {
2009
1237
  ref: setNodeRef,
2010
1238
  ...attributes,
2011
1239
  ...listeners,
2012
1240
  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),
2013
1241
  onClick: () => onSelect?.(index)
2014
- }, /* @__PURE__ */ React6.createElement("span", {
1242
+ }, /* @__PURE__ */ React3.createElement("span", {
2015
1243
  className: "flex w-full justify-center"
2016
- }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
1244
+ }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React3.createElement("div", {
2017
1245
  className: "z-20 absolute top-0 w-full min-h-[4px] border-b-4 border-accentSurface"
2018
- }), resizing && /* @__PURE__ */ React6.createElement("div", {
1246
+ }), resizing && /* @__PURE__ */ React3.createElement("div", {
2019
1247
  className: "z-20 absolute bottom-0 w-full min-h-[4px] border-b-4 border-accentSurface"
2020
1248
  })));
2021
1249
  };
@@ -2028,7 +1256,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
2028
1256
  });
2029
1257
  const keyboardSensor = useSensor(KeyboardSensor, {});
2030
1258
  const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);
2031
- const [active, setActive] = useState5(null);
1259
+ const [active, setActive] = useState4(null);
2032
1260
  const handleDragStart = ({ active: active2 }) => {
2033
1261
  setActive(active2);
2034
1262
  };
@@ -2052,18 +1280,18 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
2052
1280
  }
2053
1281
  return transform;
2054
1282
  };
2055
- return /* @__PURE__ */ React6.createElement("div", {
1283
+ return /* @__PURE__ */ React3.createElement("div", {
2056
1284
  className: "relative flex grow overflow-hidden"
2057
- }, /* @__PURE__ */ React6.createElement("div", {
1285
+ }, /* @__PURE__ */ React3.createElement("div", {
2058
1286
  className: mx2("z-20 absolute inset-0 border-x border-gridLine pointer-events-none"),
2059
1287
  style: {
2060
1288
  height: axisHeight
2061
1289
  }
2062
- }), /* @__PURE__ */ React6.createElement("div", {
1290
+ }), /* @__PURE__ */ React3.createElement("div", {
2063
1291
  ref: forwardRef2,
2064
1292
  role: "columnheader",
2065
1293
  className: "grow overflow-x-auto scrollbar-none"
2066
- }, /* @__PURE__ */ React6.createElement(DndContext, {
1294
+ }, /* @__PURE__ */ React3.createElement(DndContext, {
2067
1295
  autoScroll: {
2068
1296
  enabled: true
2069
1297
  },
@@ -2074,12 +1302,12 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
2074
1302
  ],
2075
1303
  onDragStart: handleDragStart,
2076
1304
  onDragEnd: handleDragEnd
2077
- }, /* @__PURE__ */ React6.createElement("div", {
1305
+ }, /* @__PURE__ */ React3.createElement("div", {
2078
1306
  className: "flex h-full",
2079
1307
  style: {
2080
1308
  height: axisHeight
2081
1309
  }
2082
- }, columns.map((idx, index) => /* @__PURE__ */ React6.createElement(GridColumnCell, {
1310
+ }, columns.map((idx, index) => /* @__PURE__ */ React3.createElement(GridColumnCell, {
2083
1311
  key: idx,
2084
1312
  idx,
2085
1313
  index,
@@ -2089,7 +1317,7 @@ var SheetColumns = /* @__PURE__ */ forwardRef(({ columns, sizes, selected, onSel
2089
1317
  selected: selected === index,
2090
1318
  onResize,
2091
1319
  onSelect
2092
- }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(DragOverlay, null, active && /* @__PURE__ */ React6.createElement(MovingOverlay, {
1320
+ }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement(DragOverlay, null, active && /* @__PURE__ */ React3.createElement(MovingOverlay, {
2093
1321
  label: columnLetter(active.data.current.index)
2094
1322
  })), document.body))));
2095
1323
  });
@@ -2107,8 +1335,8 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
2107
1335
  }
2108
1336
  });
2109
1337
  const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
2110
- const [initialSize, setInitialSize] = useState5(size);
2111
- const [resizing, setResizing] = useState5(false);
1338
+ const [initialSize, setInitialSize] = useState4(size);
1339
+ const [resizing, setResizing] = useState4(false);
2112
1340
  const scrollHandler = useRef();
2113
1341
  const handleResizeStart = (_ev, _dir, elementRef) => {
2114
1342
  const scrollContainer = elementRef.closest('[role="columnheader"]');
@@ -2130,7 +1358,7 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
2130
1358
  onResize?.(idx, initialSize + width, true);
2131
1359
  setResizing(false);
2132
1360
  };
2133
- return /* @__PURE__ */ React6.createElement(Resizable, {
1361
+ return /* @__PURE__ */ React3.createElement(Resizable, {
2134
1362
  enable: {
2135
1363
  right: resize
2136
1364
  },
@@ -2142,17 +1370,17 @@ var GridColumnCell = ({ idx, index, label, size, resize, selected, onSelect, onR
2142
1370
  onResizeStart: handleResizeStart,
2143
1371
  onResize: handleResize,
2144
1372
  onResizeStop: handleResizeStop
2145
- }, /* @__PURE__ */ React6.createElement("div", {
1373
+ }, /* @__PURE__ */ React3.createElement("div", {
2146
1374
  ref: setNodeRef,
2147
1375
  ...attributes,
2148
1376
  ...listeners,
2149
1377
  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),
2150
1378
  onClick: () => onSelect?.(index)
2151
- }, /* @__PURE__ */ React6.createElement("span", {
1379
+ }, /* @__PURE__ */ React3.createElement("span", {
2152
1380
  className: "flex w-full justify-center"
2153
- }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React6.createElement("div", {
1381
+ }, label), over?.id === idx && !isDragging && /* @__PURE__ */ React3.createElement("div", {
2154
1382
  className: "z-20 absolute left-0 h-full min-w-[4px] border-l-4 border-accentSurface"
2155
- }), resizing && /* @__PURE__ */ React6.createElement("div", {
1383
+ }), resizing && /* @__PURE__ */ React3.createElement("div", {
2156
1384
  className: "z-20 absolute right-0 h-full min-h-[4px] border-l-4 border-accentSurface"
2157
1385
  })));
2158
1386
  };
@@ -2165,14 +1393,14 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
2165
1393
  const { model, cursor, range, editing, setCursor, setRange, setEditing, onInfo } = useSheetContext();
2166
1394
  const initialText = useRef();
2167
1395
  const quickEdit = useRef(false);
2168
- const [, forceUpdate] = useState5({});
2169
- useEffect4(() => {
1396
+ const [, forceUpdate] = useState4({});
1397
+ useEffect3(() => {
2170
1398
  const unsubscribe = model.update.on(() => {
2171
- log2("updated", {
1399
+ log("updated", {
2172
1400
  id: model.id
2173
1401
  }, {
2174
- F: __dxlog_file4,
2175
- L: 737,
1402
+ F: __dxlog_file2,
1403
+ L: 730,
2176
1404
  S: void 0,
2177
1405
  C: (f, a) => f(...a)
2178
1406
  });
@@ -2292,16 +1520,16 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
2292
1520
  const id = fullyQualifiedId2(model.sheet);
2293
1521
  const attendableAttrs = createAttendableAttributes(id);
2294
1522
  const hasAttention = useHasAttention(id);
2295
- return /* @__PURE__ */ React6.createElement("div", {
1523
+ return /* @__PURE__ */ React3.createElement("div", {
2296
1524
  ref: containerRef,
2297
1525
  role: "grid",
2298
1526
  className: "relative flex grow overflow-hidden"
2299
- }, /* @__PURE__ */ React6.createElement("div", {
1527
+ }, /* @__PURE__ */ React3.createElement("div", {
2300
1528
  className: mx2("z-20 absolute inset-0 border border-gridLine pointer-events-none")
2301
- }), /* @__PURE__ */ React6.createElement("div", {
1529
+ }), /* @__PURE__ */ React3.createElement("div", {
2302
1530
  ref: scrollerRef,
2303
1531
  className: mx2("grow", hasAttention && "overflow-auto scrollbar-thin")
2304
- }, /* @__PURE__ */ React6.createElement("div", {
1532
+ }, /* @__PURE__ */ React3.createElement("div", {
2305
1533
  className: "relative select-none",
2306
1534
  style: {
2307
1535
  width,
@@ -2309,10 +1537,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
2309
1537
  },
2310
1538
  onClick: () => inputRef.current?.focus(),
2311
1539
  ...handlers
2312
- }, scrollerRef.current && /* @__PURE__ */ React6.createElement(SelectionOverlay, {
1540
+ }, scrollerRef.current && /* @__PURE__ */ React3.createElement(SelectionOverlay, {
2313
1541
  root: scrollerRef.current
2314
1542
  }), rowRange.map(({ row, top, height: height2 }) => {
2315
- return columnRange.map(({ col, left, width: width2 }) => {
1543
+ return columnRange.map(({ column, left, width: width2 }) => {
2316
1544
  const style = {
2317
1545
  position: "absolute",
2318
1546
  top,
@@ -2322,10 +1550,10 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
2322
1550
  };
2323
1551
  const cell = {
2324
1552
  row,
2325
- col
1553
+ column
2326
1554
  };
2327
1555
  const id2 = addressToA1Notation(cell);
2328
- const idx = addressToIndex(model.sheet, cell);
1556
+ const idx = model.addressToIndex(cell);
2329
1557
  const active = posEquals(cursor, cell);
2330
1558
  if (active && editing) {
2331
1559
  const value = initialText.current ?? model.getCellText(cell) ?? "";
@@ -2358,7 +1586,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
2358
1586
  inputRef.current?.focus();
2359
1587
  setEditing(false);
2360
1588
  };
2361
- return /* @__PURE__ */ React6.createElement(GridCellEditor, {
1589
+ return /* @__PURE__ */ React3.createElement(GridCellEditor, {
2362
1590
  key: idx,
2363
1591
  value,
2364
1592
  style,
@@ -2366,7 +1594,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
2366
1594
  onClose: handleClose
2367
1595
  });
2368
1596
  }
2369
- return /* @__PURE__ */ React6.createElement(SheetCell, {
1597
+ return /* @__PURE__ */ React3.createElement(SheetCell, {
2370
1598
  key: id2,
2371
1599
  id: id2,
2372
1600
  cell,
@@ -2378,7 +1606,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
2378
1606
  }
2379
1607
  });
2380
1608
  });
2381
- }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement("input", {
1609
+ }))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement("input", {
2382
1610
  ref: inputRef,
2383
1611
  autoFocus: true,
2384
1612
  className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
@@ -2399,34 +1627,20 @@ var SelectionOverlay = ({ root }) => {
2399
1627
  const b1 = getRelativeClientRect(root, c1);
2400
1628
  const b2 = getRelativeClientRect(root, c2);
2401
1629
  const bounds = getRectUnion(b1, b2);
2402
- return /* @__PURE__ */ React6.createElement("div", {
1630
+ return /* @__PURE__ */ React3.createElement("div", {
2403
1631
  role: "none",
2404
1632
  style: bounds,
2405
1633
  className: "z-10 absolute pointer-events-none bg-gridSelectionOverlay border border-gridOverlay"
2406
1634
  });
2407
1635
  };
2408
1636
  var SheetCell = ({ id, cell, style, active, onSelect }) => {
2409
- const { formatting, editing, setRange, decorations, model: { sheet } } = useSheetContext();
1637
+ const { formatting, editing, setRange } = useSheetContext();
2410
1638
  const { value, classNames } = formatting.getFormatting(cell);
2411
- const decorationsForCell = decorations.getDecorationsForCell(addressToIndex(sheet, cell)) ?? [];
2412
- const decorationAddedClasses = useMemo4(() => decorationsForCell.flatMap((d) => d.classNames ?? []), [
2413
- decorationsForCell
2414
- ]);
2415
- const decoratedContent = decorationsForCell.reduce((children, { decorate }) => {
2416
- if (!decorate) {
2417
- return children;
2418
- }
2419
- const DecoratorComponent = decorate;
2420
- return /* @__PURE__ */ React6.createElement(DecoratorComponent, null, children);
2421
- }, /* @__PURE__ */ React6.createElement("div", {
2422
- role: "none",
2423
- className: mx2("flex flex-grow bs-full is-full px-2 items-center truncate cursor-pointer", ...decorationAddedClasses)
2424
- }, value));
2425
- return /* @__PURE__ */ React6.createElement("div", {
1639
+ return /* @__PURE__ */ React3.createElement("div", {
2426
1640
  [`data-${CELL_DATA_KEY}`]: id,
2427
1641
  role: "cell",
2428
1642
  style,
2429
- className: mx2("border border-gridLine cursor-pointer", fragments.cell, active && [
1643
+ className: mx2("flex w-full h-full px-2 py-1 truncate items-center border border-gridLine cursor-pointer", fragments.cell, active && [
2430
1644
  "z-20",
2431
1645
  fragments.cellSelected
2432
1646
  ], classNames),
@@ -2440,36 +1654,36 @@ var SheetCell = ({ id, cell, style, active, onSelect }) => {
2440
1654
  }
2441
1655
  },
2442
1656
  onDoubleClick: () => onSelect?.(cell, true)
2443
- }, decoratedContent);
1657
+ }, value);
2444
1658
  };
2445
1659
  var GridCellEditor = ({ style, value, onNav, onClose }) => {
2446
1660
  const { model, range } = useSheetContext();
2447
1661
  const notifier = useRef();
2448
- useEffect4(() => {
1662
+ useEffect3(() => {
2449
1663
  if (range) {
2450
1664
  notifier.current?.(rangeToA1Notation(range));
2451
1665
  }
2452
1666
  }, [
2453
1667
  range
2454
1668
  ]);
2455
- const extension = useMemo4(() => [
1669
+ const extension = useMemo(() => [
2456
1670
  editorKeys({
2457
1671
  onNav,
2458
1672
  onClose
2459
1673
  }),
2460
1674
  sheetExtension({
2461
- functions: model.graph.getFunctions()
1675
+ functions: model.functions
2462
1676
  }),
2463
1677
  rangeExtension((fn) => notifier.current = fn)
2464
1678
  ], [
2465
1679
  model
2466
1680
  ]);
2467
- return /* @__PURE__ */ React6.createElement("div", {
1681
+ return /* @__PURE__ */ React3.createElement("div", {
2468
1682
  role: "cell",
2469
1683
  style,
2470
1684
  className: mx2("z-20 flex", fragments.cellSelected),
2471
1685
  onClick: (ev) => ev.stopPropagation()
2472
- }, /* @__PURE__ */ React6.createElement(CellEditor, {
1686
+ }, /* @__PURE__ */ React3.createElement(CellEditor, {
2473
1687
  autoFocus: true,
2474
1688
  value,
2475
1689
  extension
@@ -2482,30 +1696,30 @@ var SheetStatusBar = () => {
2482
1696
  if (cursor) {
2483
1697
  value = model.getCellValue(cursor);
2484
1698
  if (typeof value === "string" && value.charAt(0) === "=") {
2485
- value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
1699
+ value = model.mapFormulaBindingFromId(model.mapFormulaIndicesToRefs(value));
2486
1700
  isFormula = true;
2487
1701
  } else if (value != null) {
2488
1702
  value = String(value);
2489
1703
  }
2490
1704
  }
2491
- return /* @__PURE__ */ React6.createElement("div", {
1705
+ return /* @__PURE__ */ React3.createElement("div", {
2492
1706
  className: mx2("flex shrink-0 justify-between items-center px-4 py-1 text-sm border-x border-gridLine")
2493
- }, /* @__PURE__ */ React6.createElement("div", {
1707
+ }, /* @__PURE__ */ React3.createElement("div", {
2494
1708
  className: "flex gap-4 items-center"
2495
- }, /* @__PURE__ */ React6.createElement("div", {
1709
+ }, /* @__PURE__ */ React3.createElement("div", {
2496
1710
  className: "flex w-16 items-center font-mono"
2497
- }, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React6.createElement("div", {
1711
+ }, range && rangeToA1Notation(range) || cursor && addressToA1Notation(cursor)), /* @__PURE__ */ React3.createElement("div", {
2498
1712
  className: "flex gap-2 items-center"
2499
- }, /* @__PURE__ */ React6.createElement(FunctionIcon, {
1713
+ }, /* @__PURE__ */ React3.createElement(FunctionIcon, {
2500
1714
  className: mx2("text-greenText", isFormula ? "visible" : "invisible")
2501
- }), /* @__PURE__ */ React6.createElement("span", {
1715
+ }), /* @__PURE__ */ React3.createElement("span", {
2502
1716
  className: "font-mono"
2503
1717
  }, value))));
2504
1718
  };
2505
1719
  var SheetDebug = () => {
2506
1720
  const { model, cursor, range } = useSheetContext();
2507
- const [, forceUpdate] = useState5({});
2508
- useEffect4(() => {
1721
+ const [, forceUpdate] = useState4({});
1722
+ useEffect3(() => {
2509
1723
  const accessor = createDocAccessor(model.sheet, []);
2510
1724
  const handleUpdate = () => forceUpdate({});
2511
1725
  accessor.handle.addListener("change", handleUpdate);
@@ -2516,9 +1730,9 @@ var SheetDebug = () => {
2516
1730
  }, [
2517
1731
  model
2518
1732
  ]);
2519
- return /* @__PURE__ */ React6.createElement("div", {
1733
+ return /* @__PURE__ */ React3.createElement("div", {
2520
1734
  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")
2521
- }, /* @__PURE__ */ React6.createElement("pre", {
1735
+ }, /* @__PURE__ */ React3.createElement("pre", {
2522
1736
  className: "whitespace-pre-wrap"
2523
1737
  }, JSON.stringify({
2524
1738
  cursor,
@@ -2540,13 +1754,19 @@ var Sheet = {
2540
1754
  Debug: SheetDebug
2541
1755
  };
2542
1756
 
1757
+ // packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
1758
+ var SheetContainer = ({ sheet, space, role, remoteFunctionUrl }) => {
1759
+ return /* @__PURE__ */ React4.createElement("div", {
1760
+ role: "none",
1761
+ className: mx3("flex", role === "article" && "row-span-2", role === "section" && "aspect-square border-y border-is border-separator")
1762
+ }, /* @__PURE__ */ React4.createElement(Sheet.Root, {
1763
+ sheet,
1764
+ space,
1765
+ remoteFunctionUrl
1766
+ }, /* @__PURE__ */ React4.createElement(Sheet.Main, null)));
1767
+ };
1768
+ var SheetContainer_default = SheetContainer;
2543
1769
  export {
2544
- ComputeGraphContextProvider,
2545
- createSheet,
2546
- addressToIndex,
2547
- compareIndexPositions,
2548
- useSheetContext,
2549
- Sheet,
2550
- SheetContainer
1770
+ SheetContainer_default as default
2551
1771
  };
2552
- //# sourceMappingURL=chunk-U2JHW3L6.mjs.map
1772
+ //# sourceMappingURL=SheetContainer-U4H5D34A.mjs.map