@dxos/plugin-sheet 0.7.4 → 0.7.5-main.937ce75

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 (188) hide show
  1. package/dist/lib/browser/{SheetContainer-KCLT6PEO.mjs → SheetContainer-S4NCLUYL.mjs} +16 -22
  2. package/dist/lib/browser/SheetContainer-S4NCLUYL.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-E5WQ7U7G.mjs → chunk-A374JPWV.mjs} +72 -705
  4. package/dist/lib/browser/chunk-A374JPWV.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-Q4XS4YWF.mjs +900 -0
  6. package/dist/lib/browser/chunk-Q4XS4YWF.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +74 -180
  8. package/dist/lib/browser/index.mjs.map +3 -3
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/types/index.mjs +62 -0
  11. package/dist/lib/node/{SheetContainer-VVVRYTQG.cjs → SheetContainer-TP4GYXZB.cjs} +41 -43
  12. package/dist/lib/node/SheetContainer-TP4GYXZB.cjs.map +7 -0
  13. package/dist/lib/node/{chunk-45YW2DX2.cjs → chunk-FDEQ2PGJ.cjs} +115 -726
  14. package/dist/lib/node/chunk-FDEQ2PGJ.cjs.map +7 -0
  15. package/dist/lib/node/chunk-TQOJ7DG2.cjs +935 -0
  16. package/dist/lib/node/chunk-TQOJ7DG2.cjs.map +7 -0
  17. package/dist/lib/node/index.cjs +104 -207
  18. package/dist/lib/node/index.cjs.map +3 -3
  19. package/dist/lib/node/meta.json +1 -1
  20. package/dist/lib/node/types/index.cjs +84 -0
  21. package/dist/lib/node/types/index.cjs.map +7 -0
  22. package/dist/lib/node-esm/{SheetContainer-LSBE6Q4X.mjs → SheetContainer-YB3JBVPZ.mjs} +16 -22
  23. package/dist/lib/node-esm/SheetContainer-YB3JBVPZ.mjs.map +7 -0
  24. package/dist/lib/node-esm/{chunk-NYDNXI7L.mjs → chunk-L5PQHVTX.mjs} +72 -705
  25. package/dist/lib/node-esm/chunk-L5PQHVTX.mjs.map +7 -0
  26. package/dist/lib/node-esm/chunk-NYYIDVR7.mjs +901 -0
  27. package/dist/lib/node-esm/chunk-NYYIDVR7.mjs.map +7 -0
  28. package/dist/lib/node-esm/index.mjs +74 -180
  29. package/dist/lib/node-esm/index.mjs.map +3 -3
  30. package/dist/lib/node-esm/meta.json +1 -1
  31. package/dist/lib/node-esm/types/index.mjs +63 -0
  32. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  33. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
  34. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  35. package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
  36. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
  37. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  38. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
  39. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  40. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  41. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  42. package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
  43. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  44. package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
  45. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  46. package/dist/types/src/components/index.d.ts +1 -1
  47. package/dist/types/src/extensions/compute.d.ts +1 -1
  48. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  49. package/dist/types/src/extensions/editor/extension.d.ts +1 -1
  50. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
  51. package/dist/types/src/index.d.ts +1 -1
  52. package/dist/types/src/index.d.ts.map +1 -1
  53. package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
  54. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  55. package/dist/types/src/model/sheet-model.d.ts +6 -8
  56. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  57. package/dist/types/src/model/testing.d.ts +1 -1
  58. package/dist/types/src/model/testing.d.ts.map +1 -1
  59. package/dist/types/src/model/useSheetModel.d.ts +1 -1
  60. package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
  61. package/dist/types/src/testing/testing.d.ts +2 -2
  62. package/dist/types/src/testing/testing.d.ts.map +1 -1
  63. package/dist/types/src/{defs → types}/index.d.ts +1 -0
  64. package/dist/types/src/types/index.d.ts.map +1 -0
  65. package/dist/types/src/types/schema.d.ts +105 -0
  66. package/dist/types/src/types/schema.d.ts.map +1 -0
  67. package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
  68. package/dist/types/src/types/types.d.ts +82 -0
  69. package/dist/types/src/types/types.d.ts.map +1 -0
  70. package/dist/types/src/{defs → types}/util.d.ts +5 -1
  71. package/dist/types/src/types/util.d.ts.map +1 -0
  72. package/dist/types/tsconfig.tsbuildinfo +1 -0
  73. package/package.json +46 -53
  74. package/src/SheetPlugin.tsx +44 -115
  75. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
  76. package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
  77. package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
  78. package/src/components/GridSheet/GridSheet.tsx +15 -18
  79. package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
  80. package/src/components/GridSheet/util.ts +3 -2
  81. package/src/components/RangeList/RangeList.tsx +2 -1
  82. package/src/components/SheetContainer/SheetContainer.stories.tsx +11 -12
  83. package/src/components/SheetContext/SheetContext.tsx +1 -2
  84. package/src/components/Toolbar/Toolbar.tsx +18 -20
  85. package/src/extensions/compute.ts +7 -4
  86. package/src/extensions/editor/extension.test.ts +2 -1
  87. package/src/extensions/editor/extension.ts +2 -3
  88. package/src/index.ts +1 -3
  89. package/src/integrations/thread-ranges.ts +28 -24
  90. package/src/model/sheet-model.test.ts +4 -10
  91. package/src/model/sheet-model.ts +30 -22
  92. package/src/model/testing.ts +3 -2
  93. package/src/model/useSheetModel.ts +2 -1
  94. package/src/sanity.test.ts +1 -1
  95. package/src/testing/testing.tsx +2 -3
  96. package/src/{defs → types}/index.ts +1 -0
  97. package/src/types/schema.ts +56 -0
  98. package/src/types/types.ts +93 -0
  99. package/src/{defs → types}/util.ts +13 -13
  100. package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
  101. package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
  102. package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
  103. package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
  104. package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
  105. package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
  106. package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
  107. package/dist/lib/browser/types.mjs +0 -16
  108. package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
  109. package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
  110. package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
  111. package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
  112. package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
  113. package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
  114. package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
  115. package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
  116. package/dist/lib/node/types.cjs +0 -38
  117. package/dist/lib/node/types.cjs.map +0 -7
  118. package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
  119. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
  120. package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
  121. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
  122. package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
  123. package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
  124. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
  125. package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
  126. package/dist/lib/node-esm/types.mjs +0 -17
  127. package/dist/lib/node-esm/types.mjs.map +0 -7
  128. package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
  129. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
  130. package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
  131. package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
  132. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
  133. package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
  134. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
  135. package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
  136. package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
  137. package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
  138. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
  139. package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
  140. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
  141. package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
  142. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
  143. package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
  144. package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
  145. package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
  146. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
  147. package/dist/types/src/compute-graph/index.d.ts +0 -5
  148. package/dist/types/src/compute-graph/index.d.ts.map +0 -1
  149. package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
  150. package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
  151. package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
  152. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
  153. package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
  154. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
  155. package/dist/types/src/compute-graph/util.d.ts +0 -2
  156. package/dist/types/src/compute-graph/util.d.ts.map +0 -1
  157. package/dist/types/src/defs/index.d.ts.map +0 -1
  158. package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
  159. package/dist/types/src/defs/types.d.ts +0 -26
  160. package/dist/types/src/defs/types.d.ts.map +0 -1
  161. package/dist/types/src/defs/types.test.d.ts +0 -2
  162. package/dist/types/src/defs/types.test.d.ts.map +0 -1
  163. package/dist/types/src/defs/util.d.ts.map +0 -1
  164. package/dist/types/src/types.d.ts +0 -182
  165. package/dist/types/src/types.d.ts.map +0 -1
  166. package/dist/vendor/hyperformula.mjs +0 -37145
  167. package/src/compute-graph/compute-graph-registry.ts +0 -90
  168. package/src/compute-graph/compute-graph.test.ts +0 -87
  169. package/src/compute-graph/compute-graph.ts +0 -260
  170. package/src/compute-graph/compute-node.ts +0 -62
  171. package/src/compute-graph/functions/async-function.ts +0 -179
  172. package/src/compute-graph/functions/edge-function.ts +0 -102
  173. package/src/compute-graph/functions/function-defs.ts +0 -2427
  174. package/src/compute-graph/functions/index.ts +0 -7
  175. package/src/compute-graph/hyperformula.test.ts +0 -14
  176. package/src/compute-graph/index.ts +0 -8
  177. package/src/compute-graph/testing/index.ts +0 -6
  178. package/src/compute-graph/testing/test-builder.ts +0 -54
  179. package/src/compute-graph/testing/test-plugin.ts +0 -100
  180. package/src/compute-graph/util.ts +0 -8
  181. package/src/defs/types.test.ts +0 -91
  182. package/src/defs/types.ts +0 -88
  183. package/src/types.ts +0 -125
  184. /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
  185. /package/dist/lib/{browser/types.mjs.map → node-esm/types/index.mjs.map} +0 -0
  186. /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
  187. /package/dist/types/src/{defs → types}/sheet-range-types.d.ts +0 -0
  188. /package/src/{defs → types}/sheet-range-types.ts +0 -0
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_45YW2DX2_exports = {};
30
- __export(chunk_45YW2DX2_exports, {
29
+ var chunk_FDEQ2PGJ_exports = {};
30
+ __export(chunk_FDEQ2PGJ_exports, {
31
31
  ComputeGraphContextProvider: () => ComputeGraphContextProvider,
32
32
  GridSheet: () => GridSheet,
33
33
  SheetContainer: () => SheetContainer,
@@ -38,9 +38,8 @@ __export(chunk_45YW2DX2_exports, {
38
38
  useComputeGraph: () => useComputeGraph,
39
39
  useSheetContext: () => useSheetContext
40
40
  });
41
- module.exports = __toCommonJS(chunk_45YW2DX2_exports);
42
- var import_chunk_KSEEI5VC = require("./chunk-KSEEI5VC.cjs");
43
- var import_chunk_OWH2EUHZ = require("./chunk-OWH2EUHZ.cjs");
41
+ module.exports = __toCommonJS(chunk_FDEQ2PGJ_exports);
42
+ var import_chunk_TQOJ7DG2 = require("./chunk-TQOJ7DG2.cjs");
44
43
  var import_chunk_2ZVZI2KJ = require("./chunk-2ZVZI2KJ.cjs");
45
44
  var import_react = __toESM(require("react"));
46
45
  var import_debug = require("@dxos/debug");
@@ -49,6 +48,7 @@ var import_language = require("@codemirror/language");
49
48
  var import_state = require("@codemirror/state");
50
49
  var import_view = require("@codemirror/view");
51
50
  var import_async = require("@dxos/async");
51
+ var import_compute = require("@dxos/compute");
52
52
  var import_invariant = require("@dxos/invariant");
53
53
  var import_react_ui_editor = require("@dxos/react-ui-editor");
54
54
  var import_autocomplete = require("@codemirror/autocomplete");
@@ -56,41 +56,39 @@ var import_language2 = require("@codemirror/language");
56
56
  var import_view2 = require("@codemirror/view");
57
57
  var import_highlight = require("@lezer/highlight");
58
58
  var import_codemirror_lang_spreadsheet = require("codemirror-lang-spreadsheet");
59
+ var import_compute2 = require("@dxos/compute");
59
60
  var import_react_ui_editor2 = require("@dxos/react-ui-editor");
60
61
  var import_react_ui_theme = require("@dxos/react-ui-theme");
61
62
  var import_react2 = __toESM(require("react"));
62
63
  var import_invariant2 = require("@dxos/invariant");
63
64
  var import_echo = require("@dxos/react-client/echo");
64
65
  var import_react_ui_grid = require("@dxos/react-ui-grid");
65
- var import_async2 = require("@dxos/async");
66
- var import_context = require("@dxos/context");
67
- var import_echo_schema = require("@dxos/echo-schema");
68
- var import_invariant3 = require("@dxos/invariant");
69
- var import_keys = require("@dxos/keys");
70
- var import_log = require("@dxos/log");
71
- var import_hyperformula = require("#hyperformula");
72
- var import_react3 = require("react");
73
- var import_react4 = __toESM(require("react"));
66
+ var import_react3 = __toESM(require("react"));
74
67
  var import_app_framework = require("@dxos/app-framework");
68
+ var import_compute3 = require("@dxos/compute");
75
69
  var import_react_ui = require("@dxos/react-ui");
76
70
  var import_react_ui_attention = require("@dxos/react-ui-attention");
77
71
  var import_react_ui_grid2 = require("@dxos/react-ui-grid");
78
- var import_react5 = require("react");
72
+ var import_react4 = require("react");
73
+ var import_compute4 = require("@dxos/compute");
79
74
  var import_echo2 = require("@dxos/react-client/echo");
80
75
  var import_react_ui_form = require("@dxos/react-ui-form");
81
76
  var import_react_ui_grid3 = require("@dxos/react-ui-grid");
82
77
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
83
- var import_react6 = require("react");
78
+ var import_react5 = require("react");
84
79
  var import_app_framework2 = require("@dxos/app-framework");
85
- var import_async3 = require("@dxos/async");
80
+ var import_async2 = require("@dxos/async");
81
+ var import_compute5 = require("@dxos/compute");
82
+ var import_types = require("@dxos/plugin-thread/types");
86
83
  var import_echo3 = require("@dxos/react-client/echo");
87
- var import_react7 = require("react");
88
- var import_react8 = __toESM(require("react"));
89
- var import_echo_schema2 = require("@dxos/echo-schema");
84
+ var import_react6 = require("react");
85
+ var import_react7 = __toESM(require("react"));
86
+ var import_compute6 = require("@dxos/compute");
87
+ var import_echo_schema = require("@dxos/echo-schema");
90
88
  var import_react_ui2 = require("@dxos/react-ui");
91
89
  var import_react_ui_list = require("@dxos/react-ui-list");
92
90
  var import_react_ui_theme3 = require("@dxos/react-ui-theme");
93
- var import_react9 = __toESM(require("react"));
91
+ var import_react8 = __toESM(require("react"));
94
92
  var import_meta = require("@dxos/plugin-space/meta");
95
93
  var import_react_ui3 = require("@dxos/react-ui");
96
94
  var ComputeGraphContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
@@ -295,7 +293,7 @@ var rangeExtension = ({ onInit, onStateChange }) => {
295
293
  });
296
294
  if (!activeRange && view2.state.doc.toString()[0] === "=") {
297
295
  const str = view2.state.doc.sliceString(1);
298
- if (import_chunk_KSEEI5VC.RANGE_NOTATION.test(str)) {
296
+ if (import_compute2.RANGE_NOTATION.test(str)) {
299
297
  activeRange = {
300
298
  from: 1,
301
299
  to: str.length + 1
@@ -319,603 +317,13 @@ var visitTree = (node, callback) => {
319
317
  }
320
318
  return false;
321
319
  };
322
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
323
- var typeMap = {
324
- BOOLEAN: {
325
- type: import_echo_schema.TypeEnum.Boolean
326
- },
327
- NUMBER_RAW: {
328
- type: import_echo_schema.TypeEnum.Number
329
- },
330
- NUMBER_PERCENT: {
331
- type: import_echo_schema.TypeEnum.Number,
332
- format: import_echo_schema.FormatEnum.Percent
333
- },
334
- NUMBER_CURRENCY: {
335
- type: import_echo_schema.TypeEnum.Number,
336
- format: import_echo_schema.FormatEnum.Currency
337
- },
338
- NUMBER_DATETIME: {
339
- type: import_echo_schema.TypeEnum.String,
340
- format: import_echo_schema.FormatEnum.DateTime
341
- },
342
- NUMBER_DATE: {
343
- type: import_echo_schema.TypeEnum.String,
344
- format: import_echo_schema.FormatEnum.Date
345
- },
346
- NUMBER_TIME: {
347
- type: import_echo_schema.TypeEnum.String,
348
- format: import_echo_schema.FormatEnum.Time
349
- }
350
- };
351
- var getTopLeft = (range) => {
352
- const to = range.to ?? range.from;
353
- return {
354
- row: Math.min(range.from.row, to.row),
355
- col: Math.min(range.from.col, to.col)
356
- };
357
- };
358
- var toSimpleCellAddress = (sheet, cell) => ({
359
- sheet,
360
- row: cell.row,
361
- col: cell.col
362
- });
363
- var toModelRange = (sheet, range) => ({
364
- start: toSimpleCellAddress(sheet, range.from),
365
- end: toSimpleCellAddress(sheet, range.to ?? range.from)
366
- });
367
- var SheetModel = class extends import_context.Resource {
368
- constructor(_graph, _sheet, _options = {}) {
369
- super();
370
- this._graph = _graph;
371
- this._sheet = _sheet;
372
- this._options = _options;
373
- this.id = `model-${import_keys.PublicKey.random().truncate()}`;
374
- this.update = new import_async2.Event();
375
- }
376
- get graph() {
377
- return this._graph;
378
- }
379
- get sheet() {
380
- return this._sheet;
381
- }
382
- get readonly() {
383
- return this._options.readonly;
384
- }
385
- get bounds() {
386
- return {
387
- rows: this._sheet.rows.length,
388
- columns: this._sheet.columns.length
389
- };
390
- }
391
- /**
392
- * Initialize sheet and engine.
393
- */
394
- async _open() {
395
- (0, import_log.log)("initialize", {
396
- id: this.id
397
- }, {
398
- F: __dxlog_file,
399
- L: 115,
400
- S: this,
401
- C: (f, a) => f(...a)
402
- });
403
- (0, import_chunk_KSEEI5VC.initialize)(this._sheet);
404
- this._graph.update.on((event) => {
405
- if (event.type === "functionsUpdated") {
406
- this.reset();
407
- }
408
- });
409
- this._node = this._graph.getOrCreateNode((0, import_chunk_KSEEI5VC.createSheetName)({
410
- type: (0, import_echo_schema.getTypename)(this._sheet),
411
- id: this._sheet.id
412
- }));
413
- await this._node.open();
414
- const unsubscribe = this._node.update.on((event) => this.update.emit(event));
415
- this._ctx.onDispose(unsubscribe);
416
- this.reset();
417
- }
418
- /**
419
- * Update engine.
420
- * NOTE: This resets the undo history.
421
- * @deprecated
422
- */
423
- reset() {
424
- (0, import_invariant3.invariant)(this._node, void 0, {
425
- F: __dxlog_file,
426
- L: 141,
427
- S: this,
428
- A: [
429
- "this._node",
430
- ""
431
- ]
432
- });
433
- this._node.graph.hf.clearSheet(this._node.sheetId);
434
- Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
435
- (0, import_invariant3.invariant)(this._node, void 0, {
436
- F: __dxlog_file,
437
- L: 144,
438
- S: this,
439
- A: [
440
- "this._node",
441
- ""
442
- ]
443
- });
444
- const { col, row } = (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, key);
445
- if ((0, import_chunk_KSEEI5VC.isFormula)(value)) {
446
- const binding = this._graph.mapFunctionBindingFromId((0, import_chunk_KSEEI5VC.mapFormulaIndicesToRefs)(this._sheet, value));
447
- if (binding) {
448
- value = this._graph.mapFormulaToNative(binding);
449
- } else {
450
- value = "";
451
- }
452
- }
453
- this._node.graph.hf.setCellContents({
454
- sheet: this._node.sheetId,
455
- row,
456
- col
457
- }, value);
458
- });
459
- }
460
- /**
461
- * Recalculate formulas.
462
- * NOTE: This resets the undo history.
463
- * https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
464
- * @deprecated
465
- */
466
- // TODO(burdon): Remove.
467
- recalculate() {
468
- this._node?.graph.hf.rebuildAndRecalculate();
469
- }
470
- insertRows(i, n = 1) {
471
- const idx = (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.rows, i, n, import_chunk_KSEEI5VC.MAX_ROWS);
472
- this.reset();
473
- return idx;
474
- }
475
- insertColumns(i, n = 1) {
476
- const idx = (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.columns, i, n, import_chunk_KSEEI5VC.MAX_COLUMNS);
477
- this.reset();
478
- return idx;
479
- }
480
- dropRow(rowIndex) {
481
- const range = {
482
- from: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
483
- to: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
484
- };
485
- const values = this.getCellValues(range).flat();
486
- const index = this._sheet.rows.indexOf(rowIndex);
487
- this.clear(range);
488
- this._sheet.rows.splice(index, 1);
489
- delete this._sheet.rowMeta[rowIndex];
490
- this.reset();
491
- return {
492
- axis: "row",
493
- index,
494
- axisIndex: rowIndex,
495
- axisMeta: this._sheet.rowMeta[rowIndex],
496
- values
497
- };
498
- }
499
- dropColumn(colIndex) {
500
- const range = {
501
- from: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
502
- to: (0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
503
- };
504
- const values = this.getCellValues(range).flat();
505
- const index = this._sheet.columns.indexOf(colIndex);
506
- this.clear(range);
507
- this._sheet.columns.splice(index, 1);
508
- delete this._sheet.columnMeta[colIndex];
509
- this.reset();
510
- return {
511
- axis: "col",
512
- index,
513
- axisIndex: colIndex,
514
- axisMeta: this._sheet.rowMeta[colIndex],
515
- values
516
- };
517
- }
518
- restoreRow({ index, axisIndex, axisMeta, values }) {
519
- this._sheet.rows.splice(index, 0, axisIndex);
520
- values.forEach((value, col) => {
521
- if (value) {
522
- this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
523
- value
524
- };
525
- }
526
- });
527
- if (axisMeta) {
528
- this._sheet.rowMeta[axisIndex] = axisMeta;
529
- }
530
- this.reset();
531
- }
532
- restoreColumn({ index, axisIndex, axisMeta, values }) {
533
- this._sheet.columns.splice(index, 0, axisIndex);
534
- values.forEach((value, row) => {
535
- if (value) {
536
- this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
537
- value
538
- };
539
- }
540
- });
541
- if (axisMeta) {
542
- this._sheet.columnMeta[axisIndex] = axisMeta;
543
- }
544
- this.reset();
545
- }
546
- //
547
- // Undoable actions.
548
- // TODO(burdon): Group undoable methods; consistently update hf/sheet.
549
- //
550
- /**
551
- * Clear range of values.
552
- */
553
- clear(range) {
554
- (0, import_invariant3.invariant)(this._node, void 0, {
555
- F: __dxlog_file,
556
- L: 247,
557
- S: this,
558
- A: [
559
- "this._node",
560
- ""
561
- ]
562
- });
563
- const topLeft = getTopLeft(range);
564
- const values = this._iterRange(range, () => null);
565
- this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
566
- this._iterRange(range, (cell) => {
567
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
568
- delete this._sheet.cells[idx];
569
- });
570
- }
571
- cut(range) {
572
- (0, import_invariant3.invariant)(this._node, void 0, {
573
- F: __dxlog_file,
574
- L: 258,
575
- S: this,
576
- A: [
577
- "this._node",
578
- ""
579
- ]
580
- });
581
- this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
582
- this._iterRange(range, (cell) => {
583
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
584
- delete this._sheet.cells[idx];
585
- });
586
- }
587
- copy(range) {
588
- (0, import_invariant3.invariant)(this._node, void 0, {
589
- F: __dxlog_file,
590
- L: 267,
591
- S: this,
592
- A: [
593
- "this._node",
594
- ""
595
- ]
596
- });
597
- this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
598
- }
599
- paste(cell) {
600
- (0, import_invariant3.invariant)(this._node, void 0, {
601
- F: __dxlog_file,
602
- L: 272,
603
- S: this,
604
- A: [
605
- "this._node",
606
- ""
607
- ]
608
- });
609
- if (!this._node.graph.hf.isClipboardEmpty()) {
610
- const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
611
- for (const change of changes) {
612
- if (change instanceof import_hyperformula.ExportedCellChange) {
613
- const { address, newValue } = change;
614
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, {
615
- row: address.row,
616
- col: address.col
617
- });
618
- this._sheet.cells[idx] = {
619
- value: newValue
620
- };
621
- }
622
- }
623
- }
624
- }
625
- // TODO(burdon): Display undo/redo state.
626
- undo() {
627
- (0, import_invariant3.invariant)(this._node, void 0, {
628
- F: __dxlog_file,
629
- L: 287,
630
- S: this,
631
- A: [
632
- "this._node",
633
- ""
634
- ]
635
- });
636
- if (this._node.graph.hf.isThereSomethingToUndo()) {
637
- this._node.graph.hf.undo();
638
- }
639
- }
640
- redo() {
641
- (0, import_invariant3.invariant)(this._node, void 0, {
642
- F: __dxlog_file,
643
- L: 295,
644
- S: this,
645
- A: [
646
- "this._node",
647
- ""
648
- ]
649
- });
650
- if (this._node.graph.hf.isThereSomethingToRedo()) {
651
- this._node.graph.hf.redo();
652
- }
653
- }
654
- /**
655
- * Get value from sheet.
656
- */
657
- getCellValue(cell) {
658
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
659
- return this._sheet.cells[idx]?.value ?? null;
660
- }
661
- /**
662
- * Get value as a string for editing.
663
- */
664
- getCellText(cell) {
665
- const value = this.getCellValue(cell);
666
- if (value == null) {
667
- return void 0;
668
- }
669
- if ((0, import_chunk_KSEEI5VC.isFormula)(value)) {
670
- return this._graph.mapFunctionBindingFromId((0, import_chunk_KSEEI5VC.mapFormulaIndicesToRefs)(this._sheet, value));
671
- } else {
672
- return String(value);
673
- }
674
- }
675
- /**
676
- * Get array of raw values from sheet.
677
- */
678
- getCellValues(range) {
679
- return this._iterRange(range, (cell) => this.getCellValue(cell));
680
- }
681
- /**
682
- * Gets the regular or computed value from the engine.
683
- */
684
- getValue(cell) {
685
- (0, import_invariant3.invariant)(this._node, void 0, {
686
- F: __dxlog_file,
687
- L: 338,
688
- S: this,
689
- A: [
690
- "this._node",
691
- ""
692
- ]
693
- });
694
- const address = toSimpleCellAddress(this._node.sheetId, cell);
695
- const value = this._node.graph.hf.getCellValue(address);
696
- if (value instanceof import_hyperformula.DetailedCellError) {
697
- import_log.log.info("cell error", {
698
- cell,
699
- error: value
700
- }, {
701
- F: __dxlog_file,
702
- L: 343,
703
- S: this,
704
- C: (f, a) => f(...a)
705
- });
706
- return value.toString();
707
- }
708
- return value;
709
- }
710
- /**
711
- * Get value type.
712
- */
713
- getValueDescription(cell) {
714
- (0, import_invariant3.invariant)(this._node, void 0, {
715
- F: __dxlog_file,
716
- L: 354,
717
- S: this,
718
- A: [
719
- "this._node",
720
- ""
721
- ]
722
- });
723
- const addr = toSimpleCellAddress(this._node.sheetId, cell);
724
- const type = this._node.graph.hf.getCellValueDetailedType(addr);
725
- return typeMap[type];
726
- }
727
- /**
728
- * Sets the value, updating the sheet and engine.
729
- */
730
- setValue(cell, value) {
731
- (0, import_invariant3.invariant)(this._node, void 0, {
732
- F: __dxlog_file,
733
- L: 364,
734
- S: this,
735
- A: [
736
- "this._node",
737
- ""
738
- ]
739
- });
740
- if (this._options.readonly) {
741
- throw new import_chunk_KSEEI5VC.ReadonlyException();
742
- }
743
- let refresh = false;
744
- if (cell.row >= this._sheet.rows.length) {
745
- (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_KSEEI5VC.MAX_ROWS);
746
- refresh = true;
747
- }
748
- if (cell.col >= this._sheet.columns.length) {
749
- (0, import_chunk_KSEEI5VC.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_KSEEI5VC.MAX_COLUMNS);
750
- refresh = true;
751
- }
752
- if (refresh) {
753
- this.reset();
754
- }
755
- this._node.graph.hf.setCellContents({
756
- sheet: this._node.sheetId,
757
- row: cell.row,
758
- col: cell.col
759
- }, [
760
- [
761
- (0, import_chunk_KSEEI5VC.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
762
- ]
763
- ]);
764
- const idx = (0, import_chunk_KSEEI5VC.addressToIndex)(this._sheet, cell);
765
- if (value === void 0 || value === null) {
766
- delete this._sheet.cells[idx];
767
- } else {
768
- if ((0, import_chunk_KSEEI5VC.isFormula)(value)) {
769
- value = this._graph.mapFunctionBindingToId((0, import_chunk_KSEEI5VC.mapFormulaRefsToIndices)(this._sheet, value));
770
- }
771
- this._sheet.cells[idx] = {
772
- value
773
- };
774
- }
775
- }
776
- /**
777
- * Sets values from a simple map.
778
- */
779
- setValues(values) {
780
- Object.entries(values).forEach(([key, { value }]) => {
781
- this.setValue((0, import_chunk_KSEEI5VC.addressFromA1Notation)(key), value);
782
- });
783
- }
784
- /**
785
- * Iterate range.
786
- */
787
- _iterRange(range, cb) {
788
- const to = range.to ?? range.from;
789
- const rowRange = [
790
- Math.min(range.from.row, to.row),
791
- Math.max(range.from.row, to.row)
792
- ];
793
- const columnRange = [
794
- Math.min(range.from.col, to.col),
795
- Math.max(range.from.col, to.col)
796
- ];
797
- const rows = [];
798
- for (let row = rowRange[0]; row <= rowRange[1]; row++) {
799
- const rowCells = [];
800
- for (let column = columnRange[0]; column <= columnRange[1]; column++) {
801
- const value = cb({
802
- row,
803
- col: column
804
- });
805
- if (value !== void 0) {
806
- rowCells.push(value);
807
- }
808
- }
809
- rows.push(rowCells);
810
- }
811
- return rows;
812
- }
813
- // TODO(burdon): Delete index.
814
- _deleteIndices(indices, i, n) {
815
- throw new Error("Not implemented");
816
- }
817
- // TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
818
- _moveIndices(indices, i, j, n) {
819
- throw new Error("Not implemented");
820
- }
821
- /**
822
- * Map from indices to A1 notation.
823
- */
824
- mapFormulaIndicesToRefs(formula) {
825
- (0, import_invariant3.invariant)((0, import_chunk_KSEEI5VC.isFormula)(formula), void 0, {
826
- F: __dxlog_file,
827
- L: 449,
828
- S: this,
829
- A: [
830
- "isFormula(formula)",
831
- ""
832
- ]
833
- });
834
- return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
835
- return (0, import_chunk_KSEEI5VC.addressToA1Notation)((0, import_chunk_KSEEI5VC.addressFromIndex)(this._sheet, idx));
836
- });
837
- }
838
- //
839
- // Values
840
- //
841
- /**
842
- * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
843
- * https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
844
- * NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
845
- */
846
- toLocalDate(num) {
847
- const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
848
- return new Date(year, month - 1, day, hours, minutes, seconds);
849
- }
850
- toDateTime(num) {
851
- (0, import_invariant3.invariant)(this._node, void 0, {
852
- F: __dxlog_file,
853
- L: 470,
854
- S: this,
855
- A: [
856
- "this._node",
857
- ""
858
- ]
859
- });
860
- return this._node.graph.hf.numberToDateTime(num);
861
- }
862
- toDate(num) {
863
- (0, import_invariant3.invariant)(this._node, void 0, {
864
- F: __dxlog_file,
865
- L: 475,
866
- S: this,
867
- A: [
868
- "this._node",
869
- ""
870
- ]
871
- });
872
- return this._node.graph.hf.numberToDate(num);
873
- }
874
- toTime(num) {
875
- (0, import_invariant3.invariant)(this._node, void 0, {
876
- F: __dxlog_file,
877
- L: 480,
878
- S: this,
879
- A: [
880
- "this._node",
881
- ""
882
- ]
883
- });
884
- return this._node.graph.hf.numberToTime(num);
885
- }
886
- };
887
- var useSheetModel = (graph, sheet, { readonly } = {}) => {
888
- const [model, setModel] = (0, import_react3.useState)();
889
- (0, import_react3.useEffect)(() => {
890
- if (!graph || !sheet) {
891
- return;
892
- }
893
- let model2;
894
- const t = setTimeout(async () => {
895
- model2 = new SheetModel(graph, sheet, {
896
- readonly
897
- });
898
- await model2.open();
899
- setModel(model2);
900
- });
901
- return () => {
902
- clearTimeout(t);
903
- void model2?.close();
904
- };
905
- }, [
906
- graph,
907
- sheet,
908
- readonly
909
- ]);
910
- return model;
911
- };
912
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
320
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/SheetContext/SheetContext.tsx";
913
321
  var SheetContext = /* @__PURE__ */ (0, import_react2.createContext)(void 0);
914
322
  var useSheetContext = () => {
915
323
  const context = (0, import_react2.useContext)(SheetContext);
916
324
  (0, import_invariant2.invariant)(context, void 0, {
917
- F: __dxlog_file2,
918
- L: 55,
325
+ F: __dxlog_file,
326
+ L: 54,
919
327
  S: void 0,
920
328
  A: [
921
329
  "context",
@@ -968,7 +376,7 @@ var SheetProviderImpl = ({ model, onInfo, ignoreAttention, children, __gridScope
968
376
  }, children);
969
377
  };
970
378
  var SheetProvider = ({ children, graph, sheet, readonly, ignoreAttention, onInfo }) => {
971
- const model = useSheetModel(graph, sheet, {
379
+ const model = (0, import_chunk_TQOJ7DG2.useSheetModel)(graph, sheet, {
972
380
  readonly
973
381
  });
974
382
  return !model ? null : /* @__PURE__ */ import_react2.default.createElement(import_react_ui_grid.Grid.Root, {
@@ -983,50 +391,50 @@ var RangeList = ({ sheet }) => {
983
391
  const { t } = (0, import_react_ui2.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
984
392
  const handleSelectRange = (range) => {
985
393
  };
986
- const handleDeleteRange = (0, import_react8.useCallback)((range) => {
394
+ const handleDeleteRange = (0, import_react7.useCallback)((range) => {
987
395
  const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
988
396
  sheet.ranges.splice(index, 1);
989
397
  }, [
990
398
  sheet
991
399
  ]);
992
- return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("h2", {
400
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement("h2", {
993
401
  className: "p-2 text-sm font-semibold"
994
- }, t("range list heading")), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
402
+ }, t("range list heading")), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.Root, {
995
403
  items: sheet.ranges,
996
- isItem: import_echo_schema2.S.is(import_chunk_OWH2EUHZ.Range)
997
- }, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
404
+ isItem: import_echo_schema.S.is(import_chunk_TQOJ7DG2.Range)
405
+ }, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.Item, {
998
406
  key: i,
999
407
  item: range,
1000
408
  classNames: [
1001
409
  "p-2",
1002
410
  import_react_ui_theme3.ghostHover
1003
411
  ]
1004
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemTitle, {
412
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.ItemTitle, {
1005
413
  onClick: () => handleSelectRange(range)
1006
414
  }, t("range title", {
1007
- position: (0, import_chunk_KSEEI5VC.rangeToA1Notation)((0, import_chunk_KSEEI5VC.rangeFromIndex)(sheet, range.range)),
415
+ position: (0, import_compute6.rangeToA1Notation)((0, import_chunk_TQOJ7DG2.rangeFromIndex)(sheet, range.range)),
1008
416
  key: t(`range key ${range.key} label`),
1009
417
  value: t(`range value ${range.value} label`)
1010
- })), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
418
+ })), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
1011
419
  onClick: () => handleDeleteRange(range)
1012
420
  })))));
1013
421
  };
1014
422
  var SheetObjectSettings = ({ sheet }) => {
1015
423
  const { t } = (0, import_react_ui3.useTranslation)(import_meta.SPACE_PLUGIN);
1016
- return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, /* @__PURE__ */ import_react9.default.createElement("div", {
424
+ return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("div", {
1017
425
  role: "form",
1018
426
  className: "flex flex-col w-full p-2 gap-1"
1019
- }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Input.Root, null, /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Input.Label, null, t("name label")), /* @__PURE__ */ import_react9.default.createElement(import_react_ui3.Input.TextInput, {
427
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Input.Root, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Input.Label, null, t("name label")), /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Input.TextInput, {
1020
428
  placeholder: t("name placeholder"),
1021
429
  value: sheet.name ?? "",
1022
430
  onChange: (event) => {
1023
431
  sheet.name = event.target.value;
1024
432
  }
1025
- }))), /* @__PURE__ */ import_react9.default.createElement(RangeList, {
433
+ }))), /* @__PURE__ */ import_react8.default.createElement(RangeList, {
1026
434
  sheet
1027
435
  }));
1028
436
  };
1029
- var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-VVVRYTQG.cjs"));
437
+ var SheetContainer = (0, import_react6.lazy)(() => import("./SheetContainer-TP4GYXZB.cjs"));
1030
438
  var completeCellRangeToThreadCursor = (range) => {
1031
439
  return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
1032
440
  };
@@ -1050,68 +458,56 @@ var parseThreadAnchorAsCellRange = (cursor) => {
1050
458
  };
1051
459
  var useUpdateFocusedCellOnThreadSelection = (grid) => {
1052
460
  const { model, setActiveRefs } = useSheetContext();
1053
- const handleScrollIntoView = (0, import_react6.useCallback)(({ action, data }) => {
1054
- switch (action) {
1055
- case import_app_framework2.LayoutAction.SCROLL_INTO_VIEW: {
1056
- if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo3.fullyQualifiedId)(model.sheet)) {
1057
- return;
1058
- }
1059
- setActiveRefs(data.thread);
1060
- const range = parseThreadAnchorAsCellRange(data.cursor);
1061
- range && grid?.setFocus({
1062
- ...range.to,
1063
- plane: "grid"
1064
- }, true);
1065
- return {
1066
- data: true
1067
- };
1068
- }
1069
- }
1070
- }, [
461
+ const scrollIntoViewResolver = (0, import_react5.useMemo)(() => (0, import_app_framework2.createResolver)(import_app_framework2.LayoutAction.ScrollIntoView, ({ cursor, ref }) => {
462
+ setActiveRefs(ref);
463
+ const range = parseThreadAnchorAsCellRange(cursor);
464
+ range && grid?.setFocus({
465
+ ...range.to,
466
+ plane: "grid"
467
+ }, true);
468
+ }, {
469
+ disposition: "hoist",
470
+ filter: (data) => data.id === (0, import_echo3.fullyQualifiedId)(model.sheet) && !!data.cursor
471
+ }), [
1071
472
  model.sheet,
1072
473
  setActiveRefs
1073
474
  ]);
1074
- (0, import_app_framework2.useIntentResolver)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN, handleScrollIntoView);
475
+ (0, import_app_framework2.useIntentResolver)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN, scrollIntoViewResolver);
1075
476
  };
1076
477
  var useSelectThreadOnCellFocus = () => {
1077
478
  const { model, cursor } = useSheetContext();
1078
- const dispatch = (0, import_app_framework2.useIntentDispatcher)();
1079
- const threads = (0, import_react6.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
479
+ const { dispatchPromise: dispatch } = (0, import_app_framework2.useIntentDispatcher)();
480
+ const threads = (0, import_react5.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
1080
481
  // TODO(thure): Surely we can find a better dependency for this…
1081
482
  JSON.stringify(model.sheet.threads)
1082
483
  ]);
1083
- const selectClosestThread = (0, import_react6.useCallback)((cellAddress) => {
484
+ const selectClosestThread = (0, import_react5.useCallback)((cellAddress) => {
1084
485
  if (!cellAddress || !threads) {
1085
486
  return;
1086
487
  }
1087
- const closestThread = threads?.find(({ anchor }) => {
1088
- if (anchor) {
1089
- const range = parseThreadAnchorAsCellRange(anchor);
1090
- return range ? (0, import_chunk_KSEEI5VC.inRange)(range, cellAddress) : false;
488
+ const closestThread = threads?.find((ref) => {
489
+ if (ref.target?.anchor) {
490
+ const range = parseThreadAnchorAsCellRange(ref.target.anchor);
491
+ return range ? (0, import_compute5.inRange)(range, cellAddress) : false;
1091
492
  } else {
1092
493
  return false;
1093
494
  }
1094
495
  });
1095
496
  if (closestThread) {
1096
- void dispatch([
1097
- {
1098
- action: "dxos.org/plugin/thread/action/select",
1099
- data: {
1100
- current: (0, import_echo3.fullyQualifiedId)(closestThread)
1101
- }
1102
- }
1103
- ]);
497
+ void dispatch((0, import_app_framework2.createIntent)(import_types.ThreadAction.Select, {
498
+ current: (0, import_echo3.fullyQualifiedId)(closestThread)
499
+ }));
1104
500
  }
1105
501
  }, [
1106
502
  dispatch,
1107
503
  threads
1108
504
  ]);
1109
- const debounced = (0, import_react6.useMemo)(() => {
1110
- return (0, import_async3.debounce)((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
505
+ const debounced = (0, import_react5.useMemo)(() => {
506
+ return (0, import_async2.debounce)((cellCoords) => requestAnimationFrame(() => selectClosestThread(cellCoords)), 50);
1111
507
  }, [
1112
508
  selectClosestThread
1113
509
  ]);
1114
- (0, import_react6.useEffect)(() => {
510
+ (0, import_react5.useEffect)(() => {
1115
511
  if (!cursor) {
1116
512
  return;
1117
513
  }
@@ -1153,15 +549,15 @@ var projectCellProps = (model, col, row) => {
1153
549
  row
1154
550
  };
1155
551
  const rawValue = model.getValue(address);
1156
- const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_KSEEI5VC.inRange)((0, import_chunk_KSEEI5VC.rangeFromIndex)(model.sheet, range), address));
552
+ const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_compute4.inRange)((0, import_chunk_TQOJ7DG2.rangeFromIndex)(model.sheet, range), address));
1157
553
  const threadRefs = model.sheet.threads?.filter((thread) => {
1158
- const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
1159
- return thread && range ? (0, import_chunk_KSEEI5VC.inRange)(range, address) : false;
554
+ const range = thread.target?.anchor && parseThreadAnchorAsCellRange(thread.target.anchor);
555
+ return thread && range ? (0, import_compute4.inRange)(range, address) : false;
1160
556
  }).map((thread) => (0, import_echo2.fullyQualifiedId)(thread)).join(" ");
1161
557
  const description = model.getValueDescription(address);
1162
558
  const type = description?.type;
1163
559
  const format = description?.format;
1164
- const classNames = ranges?.map(import_chunk_KSEEI5VC.cellClassNameForRange).reverse();
560
+ const classNames = ranges?.map(import_chunk_TQOJ7DG2.cellClassNameForRange).reverse();
1165
561
  return {
1166
562
  value: (0, import_react_ui_form.parseValue)({
1167
563
  type,
@@ -1230,9 +626,9 @@ var cellGetter = (model) => {
1230
626
  };
1231
627
  };
1232
628
  var useSheetModelDxGridProps = (dxGrid, model) => {
1233
- const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
1234
- const [rows, setRows] = (0, import_react5.useState)(createDxGridRows(model));
1235
- (0, import_react5.useEffect)(() => {
629
+ const [columns, setColumns] = (0, import_react4.useState)(createDxGridColumns(model));
630
+ const [rows, setRows] = (0, import_react4.useState)(createDxGridRows(model));
631
+ (0, import_react4.useEffect)(() => {
1236
632
  const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
1237
633
  "cells"
1238
634
  ]);
@@ -1252,7 +648,7 @@ var useSheetModelDxGridProps = (dxGrid, model) => {
1252
648
  model,
1253
649
  dxGrid
1254
650
  ]);
1255
- (0, import_react5.useEffect)(() => {
651
+ (0, import_react4.useEffect)(() => {
1256
652
  const columnMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
1257
653
  "columnMeta"
1258
654
  ]);
@@ -1327,12 +723,12 @@ var sheetColDefault = {
1327
723
  var GridSheet = () => {
1328
724
  const { t } = (0, import_react_ui.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
1329
725
  const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } = useSheetContext();
1330
- const [dxGrid, setDxGrid] = (0, import_react4.useState)(null);
1331
- const [extraplanarFocus, setExtraplanarFocus] = (0, import_react4.useState)(null);
1332
- const dispatch = (0, import_app_framework.useIntentDispatcher)();
1333
- const rangeController = (0, import_react4.useRef)();
726
+ const [dxGrid, setDxGrid] = (0, import_react3.useState)(null);
727
+ const [extraplanarFocus, setExtraplanarFocus] = (0, import_react3.useState)(null);
728
+ const { dispatchPromise: dispatch } = (0, import_app_framework.useIntentDispatcher)();
729
+ const rangeController = (0, import_react3.useRef)();
1334
730
  const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
1335
- const handleFocus = (0, import_react4.useCallback)((event) => {
731
+ const handleFocus = (0, import_react3.useCallback)((event) => {
1336
732
  if (!editing) {
1337
733
  const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1338
734
  if (cell) {
@@ -1352,7 +748,7 @@ var GridSheet = () => {
1352
748
  }, [
1353
749
  editing
1354
750
  ]);
1355
- const handleClose = (0, import_react4.useCallback)((_value, event) => {
751
+ const handleClose = (0, import_react3.useCallback)((_value, event) => {
1356
752
  if (event) {
1357
753
  const { key, shift } = event;
1358
754
  const axis = [
@@ -1375,7 +771,7 @@ var GridSheet = () => {
1375
771
  editing,
1376
772
  dxGrid
1377
773
  ]);
1378
- const handleBlur = (0, import_react4.useCallback)((value) => {
774
+ const handleBlur = (0, import_react3.useCallback)((value) => {
1379
775
  if (value !== void 0) {
1380
776
  model.setValue((0, import_react_ui_grid2.parseCellIndex)(editing.index), value);
1381
777
  }
@@ -1383,7 +779,7 @@ var GridSheet = () => {
1383
779
  model,
1384
780
  editing
1385
781
  ]);
1386
- const handleAxisResize = (0, import_react4.useCallback)(({ axis, size, index: numericIndex }) => {
782
+ const handleAxisResize = (0, import_react3.useCallback)(({ axis, size, index: numericIndex }) => {
1387
783
  if (axis === "row") {
1388
784
  const rowId = model.sheet.rows[parseInt(numericIndex)];
1389
785
  model.sheet.rowMeta[rowId] ??= {};
@@ -1396,7 +792,7 @@ var GridSheet = () => {
1396
792
  }, [
1397
793
  model
1398
794
  ]);
1399
- const handleSelect = (0, import_react4.useCallback)(({ minCol, maxCol, minRow, maxRow }) => {
795
+ const handleSelect = (0, import_react3.useCallback)(({ minCol, maxCol, minRow, maxRow }) => {
1400
796
  const range = {
1401
797
  from: {
1402
798
  col: minCol,
@@ -1410,14 +806,14 @@ var GridSheet = () => {
1410
806
  };
1411
807
  }
1412
808
  if (editing) {
1413
- rangeController.current?.setRange((0, import_chunk_KSEEI5VC.rangeToA1Notation)(range));
809
+ rangeController.current?.setRange((0, import_compute3.rangeToA1Notation)(range));
1414
810
  } else {
1415
811
  setRange(range.to ? range : void 0);
1416
812
  }
1417
813
  }, [
1418
814
  editing
1419
815
  ]);
1420
- const handleWheel = (0, import_react4.useCallback)((event) => {
816
+ const handleWheel = (0, import_react3.useCallback)((event) => {
1421
817
  if (!ignoreAttention && !hasAttention) {
1422
818
  event.stopPropagation();
1423
819
  }
@@ -1425,7 +821,7 @@ var GridSheet = () => {
1425
821
  hasAttention,
1426
822
  ignoreAttention
1427
823
  ]);
1428
- const selectEntireAxis = (0, import_react4.useCallback)((pos) => {
824
+ const selectEntireAxis = (0, import_react3.useCallback)((pos) => {
1429
825
  switch (pos.plane) {
1430
826
  case "frozenRowsStart":
1431
827
  return dxGrid?.setSelection({
@@ -1458,7 +854,7 @@ var GridSheet = () => {
1458
854
  dxGrid,
1459
855
  model.sheet
1460
856
  ]);
1461
- const handleClick = (0, import_react4.useCallback)((event) => {
857
+ const handleClick = (0, import_react3.useCallback)((event) => {
1462
858
  const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1463
859
  if (cell) {
1464
860
  selectEntireAxis(cell);
@@ -1466,7 +862,7 @@ var GridSheet = () => {
1466
862
  }, [
1467
863
  selectEntireAxis
1468
864
  ]);
1469
- const handleKeyDown = (0, import_react4.useCallback)((event) => {
865
+ const handleKeyDown = (0, import_react3.useCallback)((event) => {
1470
866
  switch (event.key) {
1471
867
  case "Backspace":
1472
868
  case "Delete":
@@ -1513,10 +909,10 @@ var GridSheet = () => {
1513
909
  extraplanarFocus,
1514
910
  selectEntireAxis
1515
911
  ]);
1516
- const contextMenuAnchorRef = (0, import_react4.useRef)(null);
1517
- const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
912
+ const contextMenuAnchorRef = (0, import_react3.useRef)(null);
913
+ const [contextMenuOpen, setContextMenuOpen] = (0, import_react3.useState)(null);
1518
914
  const contextMenuAxis = contextMenuOpen?.plane.startsWith("frozenRows") ? "col" : "row";
1519
- const handleContextMenu = (0, import_react4.useCallback)((event) => {
915
+ const handleContextMenu = (0, import_react3.useCallback)((event) => {
1520
916
  const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1521
917
  if (cell && cell.plane.startsWith("frozen")) {
1522
918
  event.preventDefault();
@@ -1524,28 +920,21 @@ var GridSheet = () => {
1524
920
  setContextMenuOpen(cell);
1525
921
  }
1526
922
  }, []);
1527
- const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
923
+ const handleAxisMenuAction = (0, import_react3.useCallback)((operation) => {
1528
924
  switch (operation) {
1529
925
  case "insert-before":
1530
926
  case "insert-after":
1531
- return dispatch({
1532
- action: import_chunk_OWH2EUHZ.SheetAction.INSERT_AXIS,
1533
- data: {
1534
- model,
1535
- axis: contextMenuAxis,
1536
- index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
1537
- }
1538
- });
1539
- break;
927
+ return dispatch((0, import_app_framework.createIntent)(import_chunk_TQOJ7DG2.SheetAction.InsertAxis, {
928
+ model,
929
+ axis: contextMenuAxis,
930
+ index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
931
+ }));
1540
932
  case "drop":
1541
- return dispatch({
1542
- action: import_chunk_OWH2EUHZ.SheetAction.DROP_AXIS,
1543
- data: {
1544
- model,
1545
- axis: contextMenuAxis,
1546
- axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
1547
- }
1548
- });
933
+ return dispatch((0, import_app_framework.createIntent)(import_chunk_TQOJ7DG2.SheetAction.DropAxis, {
934
+ model,
935
+ axis: contextMenuAxis,
936
+ axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
937
+ }));
1549
938
  }
1550
939
  }, [
1551
940
  contextMenuAxis,
@@ -1554,7 +943,7 @@ var GridSheet = () => {
1554
943
  dispatch
1555
944
  ]);
1556
945
  const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
1557
- const extension = (0, import_react4.useMemo)(() => [
946
+ const extension = (0, import_react3.useMemo)(() => [
1558
947
  (0, import_react_ui_grid2.editorKeys)({
1559
948
  onClose: handleClose,
1560
949
  ...editing?.initialContent && {
@@ -1577,24 +966,24 @@ var GridSheet = () => {
1577
966
  handleClose,
1578
967
  editing
1579
968
  ]);
1580
- const getCellContent = (0, import_react4.useCallback)((index) => {
969
+ const getCellContent = (0, import_react3.useCallback)((index) => {
1581
970
  return model.getCellText((0, import_react_ui_grid2.parseCellIndex)(index));
1582
971
  }, [
1583
972
  model
1584
973
  ]);
1585
974
  useUpdateFocusedCellOnThreadSelection(dxGrid);
1586
975
  useSelectThreadOnCellFocus();
1587
- return /* @__PURE__ */ import_react4.default.createElement("div", {
976
+ return /* @__PURE__ */ import_react3.default.createElement("div", {
1588
977
  role: "none",
1589
978
  className: "relative min-bs-0"
1590
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.GridCellEditor, {
979
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_grid2.GridCellEditor, {
1591
980
  getCellContent,
1592
981
  extension,
1593
982
  onBlur: handleBlur
1594
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
983
+ }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui_grid2.Grid.Content, {
1595
984
  initialCells,
1596
- limitColumns: import_chunk_KSEEI5VC.DEFAULT_COLUMNS,
1597
- limitRows: import_chunk_KSEEI5VC.DEFAULT_ROWS,
985
+ limitColumns: import_chunk_TQOJ7DG2.DEFAULT_COLS,
986
+ limitRows: import_chunk_TQOJ7DG2.DEFAULT_ROWS,
1598
987
  columns,
1599
988
  rows,
1600
989
  onAxisResize: handleAxisResize,
@@ -1611,35 +1000,35 @@ var GridSheet = () => {
1611
1000
  className: "[--dx-grid-base:var(--surface-bg)] [&_.dx-grid]:border-bs [&_.dx-grid]:absolute [&_.dx-grid]:inset-0 [&_.dx-grid]:border-separator",
1612
1001
  activeRefs,
1613
1002
  ref: setDxGrid
1614
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
1003
+ }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.Root, {
1615
1004
  modal: false,
1616
1005
  open: !!contextMenuOpen,
1617
1006
  onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
1618
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.VirtualTrigger, {
1007
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.VirtualTrigger, {
1619
1008
  virtualRef: contextMenuAnchorRef
1620
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Content, {
1009
+ }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.Content, {
1621
1010
  side: contextMenuAxis === "col" ? "bottom" : "right",
1622
1011
  sideOffset: 4,
1623
1012
  collisionPadding: 8
1624
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1013
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.Item, {
1625
1014
  onClick: () => handleAxisMenuAction("insert-before"),
1626
1015
  "data-testid": `grid.${contextMenuAxis}.insert-before`
1627
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1016
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Icon, {
1628
1017
  size: 5,
1629
1018
  icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
1630
- }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1019
+ }), /* @__PURE__ */ import_react3.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.Item, {
1631
1020
  onClick: () => handleAxisMenuAction("insert-after"),
1632
1021
  "data-testid": `grid.${contextMenuAxis}.insert-after`
1633
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1022
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Icon, {
1634
1023
  size: 5,
1635
1024
  icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
1636
- }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1025
+ }), /* @__PURE__ */ import_react3.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.Item, {
1637
1026
  onClick: () => handleAxisMenuAction("drop"),
1638
1027
  "data-testid": `grid.${contextMenuAxis}.drop`
1639
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1028
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Icon, {
1640
1029
  size: 5,
1641
1030
  icon: "ph--backspace--regular"
1642
- }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Arrow, null))));
1031
+ }), /* @__PURE__ */ import_react3.default.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ import_react3.default.createElement(import_react_ui.DropdownMenu.Arrow, null))));
1643
1032
  };
1644
1033
  // Annotate the CommonJS export names for ESM import in node:
1645
1034
  0 && (module.exports = {
@@ -1653,4 +1042,4 @@ var GridSheet = () => {
1653
1042
  useComputeGraph,
1654
1043
  useSheetContext
1655
1044
  });
1656
- //# sourceMappingURL=chunk-45YW2DX2.cjs.map
1045
+ //# sourceMappingURL=chunk-FDEQ2PGJ.cjs.map