@dxos/plugin-sheet 0.6.12-main.c974201 → 0.6.12-main.f9d0246

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 (122) hide show
  1. package/dist/lib/browser/{SheetContainer-V4GCCZTX.mjs → SheetContainer-VISF3VUB.mjs} +6 -6
  2. package/dist/lib/browser/{SheetContainer-V4GCCZTX.mjs.map → SheetContainer-VISF3VUB.mjs.map} +3 -3
  3. package/dist/lib/browser/{chunk-T3NJFTD4.mjs → chunk-WZMOZKQZ.mjs} +2 -2
  4. package/dist/lib/browser/{chunk-T3NJFTD4.mjs.map → chunk-WZMOZKQZ.mjs.map} +3 -3
  5. package/dist/lib/browser/{chunk-6ZMQVB4Z.mjs → chunk-Z2XOOC2R.mjs} +81 -62
  6. package/dist/lib/browser/chunk-Z2XOOC2R.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-U2JHW3L6.mjs → chunk-ZLJ2GRE2.mjs} +173 -42
  8. package/dist/lib/browser/chunk-ZLJ2GRE2.mjs.map +7 -0
  9. package/dist/lib/browser/{graph-T27BOBOV.mjs → graph-4XFKIHRL.mjs} +4 -4
  10. package/dist/lib/browser/index.mjs +15 -13
  11. package/dist/lib/browser/index.mjs.map +3 -3
  12. package/dist/lib/browser/meta.json +1 -1
  13. package/dist/lib/browser/types.mjs +1 -1
  14. package/dist/lib/node/{SheetContainer-3ZY7MPWJ.cjs → SheetContainer-2MEALQWW.cjs} +14 -14
  15. package/dist/lib/node/{SheetContainer-3ZY7MPWJ.cjs.map → SheetContainer-2MEALQWW.cjs.map} +3 -3
  16. package/dist/lib/node/{chunk-OTTD7FBK.cjs → chunk-6DQABRGJ.cjs} +192 -60
  17. package/dist/lib/node/chunk-6DQABRGJ.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-Q3HBHPRL.cjs → chunk-AOP42UAA.cjs} +5 -5
  19. package/dist/lib/node/{chunk-Q3HBHPRL.cjs.map → chunk-AOP42UAA.cjs.map} +3 -3
  20. package/dist/lib/node/{chunk-DD6FIXWC.cjs → chunk-P5QYYEHQ.cjs} +86 -67
  21. package/dist/lib/node/chunk-P5QYYEHQ.cjs.map +7 -0
  22. package/dist/lib/node/{graph-SPKGX7W4.cjs → graph-2LRDUXBZ.cjs} +14 -14
  23. package/dist/lib/node/graph-2LRDUXBZ.cjs.map +7 -0
  24. package/dist/lib/node/index.cjs +25 -24
  25. package/dist/lib/node/index.cjs.map +3 -3
  26. package/dist/lib/node/meta.json +1 -1
  27. package/dist/lib/node/types.cjs +8 -8
  28. package/dist/lib/node/types.cjs.map +1 -1
  29. package/dist/lib/node-esm/{SheetContainer-PXSJX6XK.mjs → SheetContainer-RPSUSXWS.mjs} +6 -6
  30. package/dist/lib/node-esm/{SheetContainer-PXSJX6XK.mjs.map → SheetContainer-RPSUSXWS.mjs.map} +3 -3
  31. package/dist/lib/node-esm/{chunk-D6KU5MI7.mjs → chunk-4MM7THJW.mjs} +81 -62
  32. package/dist/lib/node-esm/chunk-4MM7THJW.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-7HVSOTGA.mjs → chunk-5RLTCIE2.mjs} +173 -42
  34. package/dist/lib/node-esm/chunk-5RLTCIE2.mjs.map +7 -0
  35. package/dist/lib/node-esm/{chunk-BMNA27EX.mjs → chunk-RR2AO4SM.mjs} +2 -2
  36. package/dist/lib/node-esm/{chunk-BMNA27EX.mjs.map → chunk-RR2AO4SM.mjs.map} +3 -3
  37. package/dist/lib/node-esm/{graph-U67IO4UC.mjs → graph-WG5EKOMO.mjs} +4 -4
  38. package/dist/lib/node-esm/index.mjs +15 -13
  39. package/dist/lib/node-esm/index.mjs.map +3 -3
  40. package/dist/lib/node-esm/meta.json +1 -1
  41. package/dist/lib/node-esm/types.mjs +1 -1
  42. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  43. package/dist/types/src/components/GridSheet/GridSheet.d.ts +3 -3
  44. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  45. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +1 -1
  46. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  47. package/dist/types/src/components/GridSheet/util.d.ts +3 -2
  48. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  49. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
  50. package/dist/types/src/components/Sheet/sheet-context.d.ts +3 -3
  51. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
  52. package/dist/types/src/components/SheetContainer.d.ts +1 -1
  53. package/dist/types/src/components/index.d.ts +1 -1
  54. package/dist/types/src/defs/types.d.ts.map +1 -1
  55. package/dist/types/src/defs/util.d.ts +1 -1
  56. package/dist/types/src/defs/util.d.ts.map +1 -1
  57. package/dist/types/src/extensions/compute.d.ts +5 -1
  58. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  59. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
  60. package/dist/types/src/graph/async-function.d.ts +7 -1
  61. package/dist/types/src/graph/async-function.d.ts.map +1 -1
  62. package/dist/types/src/graph/compute-graph.d.ts +12 -9
  63. package/dist/types/src/graph/compute-graph.d.ts.map +1 -1
  64. package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -1
  65. package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
  66. package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
  67. package/dist/types/src/graph/compute-node.d.ts +9 -2
  68. package/dist/types/src/graph/compute-node.d.ts.map +1 -1
  69. package/dist/types/src/graph/edge-function.d.ts.map +1 -1
  70. package/dist/types/src/graph/{custom-function.d.ts → testing/custom-function.d.ts} +3 -1
  71. package/dist/types/src/graph/testing/custom-function.d.ts.map +1 -0
  72. package/dist/types/src/graph/testing/index.d.ts +2 -0
  73. package/dist/types/src/graph/testing/index.d.ts.map +1 -0
  74. package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -1
  75. package/dist/types/src/hooks/useSheetModel.d.ts +2 -2
  76. package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -1
  77. package/dist/types/src/model/sheet-model.d.ts +3 -3
  78. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  79. package/dist/types/src/testing/testing.d.ts +4 -5
  80. package/dist/types/src/testing/testing.d.ts.map +1 -1
  81. package/dist/types/src/types.d.ts +4 -3
  82. package/dist/types/src/types.d.ts.map +1 -1
  83. package/package.json +33 -33
  84. package/src/SheetPlugin.tsx +9 -7
  85. package/src/components/CellEditor/CellEditor.stories.tsx +1 -1
  86. package/src/components/GridSheet/GridSheet.stories.tsx +5 -4
  87. package/src/components/GridSheet/GridSheet.tsx +6 -6
  88. package/src/components/GridSheet/util.ts +46 -27
  89. package/src/components/Sheet/Sheet.stories.tsx +21 -20
  90. package/src/components/Sheet/sheet-context.tsx +4 -4
  91. package/src/components/SheetContainer.tsx +2 -2
  92. package/src/defs/types.ts +1 -0
  93. package/src/defs/util.ts +19 -3
  94. package/src/extensions/compute.stories.tsx +18 -16
  95. package/src/extensions/compute.ts +72 -39
  96. package/src/graph/async-function.ts +13 -6
  97. package/src/graph/compute-graph.stories.tsx +4 -3
  98. package/src/graph/compute-graph.test.ts +127 -0
  99. package/src/graph/compute-graph.ts +64 -41
  100. package/src/graph/compute-node.ts +16 -5
  101. package/src/graph/edge-function.ts +1 -2
  102. package/src/graph/{custom-function.ts → testing/custom-function.ts} +10 -2
  103. package/src/graph/testing/index.ts +5 -0
  104. package/src/hooks/hooks.stories.tsx +3 -3
  105. package/src/hooks/useComputeGraph.ts +2 -1
  106. package/src/hooks/useSheetModel.ts +4 -7
  107. package/src/model/sheet-model.ts +44 -29
  108. package/src/testing/testing.tsx +17 -15
  109. package/src/types.ts +3 -3
  110. package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +0 -7
  111. package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +0 -7
  112. package/dist/lib/node/chunk-DD6FIXWC.cjs.map +0 -7
  113. package/dist/lib/node/chunk-OTTD7FBK.cjs.map +0 -7
  114. package/dist/lib/node/graph-SPKGX7W4.cjs.map +0 -7
  115. package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +0 -7
  116. package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +0 -7
  117. package/dist/types/src/graph/compute-graph.browser.test.d.ts +0 -2
  118. package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +0 -1
  119. package/dist/types/src/graph/custom-function.d.ts.map +0 -1
  120. package/src/graph/compute-graph.browser.test.ts +0 -104
  121. /package/dist/lib/browser/{graph-T27BOBOV.mjs.map → graph-4XFKIHRL.mjs.map} +0 -0
  122. /package/dist/lib/node-esm/{graph-U67IO4UC.mjs.map → graph-WG5EKOMO.mjs.map} +0 -0
@@ -26,20 +26,21 @@ 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_OTTD7FBK_exports = {};
30
- __export(chunk_OTTD7FBK_exports, {
29
+ var chunk_6DQABRGJ_exports = {};
30
+ __export(chunk_6DQABRGJ_exports, {
31
31
  ComputeGraphContextProvider: () => ComputeGraphContextProvider,
32
32
  Sheet: () => Sheet,
33
33
  SheetContainer: () => SheetContainer,
34
34
  addressToIndex: () => addressToIndex,
35
35
  compareIndexPositions: () => compareIndexPositions,
36
36
  createSheet: () => createSheet,
37
+ useComputeGraph: () => useComputeGraph,
37
38
  useSheetContext: () => useSheetContext
38
39
  });
39
- module.exports = __toCommonJS(chunk_OTTD7FBK_exports);
40
- var import_chunk_Q3HBHPRL = require("./chunk-Q3HBHPRL.cjs");
40
+ module.exports = __toCommonJS(chunk_6DQABRGJ_exports);
41
+ var import_chunk_AOP42UAA = require("./chunk-AOP42UAA.cjs");
41
42
  var import_chunk_BNARJ5GM = require("./chunk-BNARJ5GM.cjs");
42
- var import_chunk_DD6FIXWC = require("./chunk-DD6FIXWC.cjs");
43
+ var import_chunk_P5QYYEHQ = require("./chunk-P5QYYEHQ.cjs");
43
44
  var import_core = require("@dnd-kit/core");
44
45
  var import_modifiers = require("@dnd-kit/modifiers");
45
46
  var import_utilities = require("@dnd-kit/utilities");
@@ -118,7 +119,7 @@ var addressFromA1Notation = (ref) => {
118
119
  const match = ref.match(/([A-Z]+)(\d+)/);
119
120
  (0, import_invariant.invariant)(match, `Invalid notation: ${ref}`, {
120
121
  F: __dxlog_file,
121
- L: 39,
122
+ L: 40,
122
123
  S: void 0,
123
124
  A: [
124
125
  "match",
@@ -189,9 +190,9 @@ var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}
189
190
  insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
190
191
  }
191
192
  };
192
- var createSheet = ({ title, ...size } = {}) => {
193
- const sheet = (0, import_echo_schema.create)(import_chunk_Q3HBHPRL.SheetType, {
194
- title,
193
+ var createSheet = ({ name, cells, ...size } = {}) => {
194
+ const sheet = (0, import_echo_schema.create)(import_chunk_AOP42UAA.SheetType, {
195
+ name,
195
196
  cells: {},
196
197
  rows: [],
197
198
  columns: [],
@@ -200,6 +201,14 @@ var createSheet = ({ title, ...size } = {}) => {
200
201
  formatting: {}
201
202
  });
202
203
  initialize(sheet, size);
204
+ if (cells) {
205
+ Object.entries(cells).forEach(([key, { value }]) => {
206
+ const idx = addressToIndex(sheet, addressFromA1Notation(key));
207
+ sheet.cells[idx] = {
208
+ value
209
+ };
210
+ });
211
+ }
203
212
  return sheet;
204
213
  };
205
214
  var addressToIndex = (sheet, cell) => {
@@ -569,13 +578,14 @@ var ComputeGraphContextProvider = ({ registry, children }) => {
569
578
  }
570
579
  }, children);
571
580
  };
572
- var SheetContainer = import_react7.default.lazy(() => import("./SheetContainer-3ZY7MPWJ.cjs"));
581
+ var SheetContainer = import_react7.default.lazy(() => import("./SheetContainer-2MEALQWW.cjs"));
573
582
  var useComputeGraph = (space) => {
574
583
  const { registry } = (0, import_react6.useContext)(ComputeGraphContext) ?? (0, import_debug.raise)(new Error("Missing ComputeGraphContext"));
575
- return (0, import_react_hooks.useAsyncState)(async () => space && registry.getOrCreateGraph(space), [
584
+ const [graph] = (0, import_react_hooks.useAsyncState)(async () => space && registry.getOrCreateGraph(space), [
576
585
  space,
577
586
  registry
578
587
  ]);
588
+ return graph;
579
589
  };
580
590
  var FormattingModel = class {
581
591
  constructor(_model) {
@@ -609,7 +619,7 @@ var FormattingModel = class {
609
619
  const defaultNumber = "justify-end font-mono";
610
620
  const type = formatting?.type ?? this._model.getValueType(cell);
611
621
  switch (type) {
612
- case import_chunk_Q3HBHPRL.ValueTypeEnum.Boolean: {
622
+ case import_chunk_AOP42UAA.ValueTypeEnum.Boolean: {
613
623
  return {
614
624
  value: value.toLocaleString().toUpperCase(),
615
625
  classNames: [
@@ -621,7 +631,7 @@ var FormattingModel = class {
621
631
  //
622
632
  // Numbers.
623
633
  //
624
- case import_chunk_Q3HBHPRL.ValueTypeEnum.Number: {
634
+ case import_chunk_AOP42UAA.ValueTypeEnum.Number: {
625
635
  return {
626
636
  value: value.toLocaleString(locales),
627
637
  classNames: [
@@ -630,7 +640,7 @@ var FormattingModel = class {
630
640
  ]
631
641
  };
632
642
  }
633
- case import_chunk_Q3HBHPRL.ValueTypeEnum.Percent: {
643
+ case import_chunk_AOP42UAA.ValueTypeEnum.Percent: {
634
644
  return {
635
645
  value: value * 100 + "%",
636
646
  classNames: [
@@ -639,7 +649,7 @@ var FormattingModel = class {
639
649
  ]
640
650
  };
641
651
  }
642
- case import_chunk_Q3HBHPRL.ValueTypeEnum.Currency: {
652
+ case import_chunk_AOP42UAA.ValueTypeEnum.Currency: {
643
653
  return {
644
654
  value: value.toLocaleString(locales, {
645
655
  style: "currency",
@@ -656,21 +666,21 @@ var FormattingModel = class {
656
666
  //
657
667
  // Dates.
658
668
  //
659
- case import_chunk_Q3HBHPRL.ValueTypeEnum.DateTime: {
669
+ case import_chunk_AOP42UAA.ValueTypeEnum.DateTime: {
660
670
  const date = this._model.toLocalDate(value);
661
671
  return {
662
672
  value: date.toLocaleString(locales),
663
673
  classNames
664
674
  };
665
675
  }
666
- case import_chunk_Q3HBHPRL.ValueTypeEnum.Date: {
676
+ case import_chunk_AOP42UAA.ValueTypeEnum.Date: {
667
677
  const date = this._model.toLocalDate(value);
668
678
  return {
669
679
  value: date.toLocaleDateString(locales),
670
680
  classNames
671
681
  };
672
682
  }
673
- case import_chunk_Q3HBHPRL.ValueTypeEnum.Time: {
683
+ case import_chunk_AOP42UAA.ValueTypeEnum.Time: {
674
684
  const date = this._model.toLocalDate(value);
675
685
  return {
676
686
  value: date.toLocaleTimeString(locales),
@@ -688,13 +698,13 @@ var FormattingModel = class {
688
698
  };
689
699
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
690
700
  var typeMap = {
691
- BOOLEAN: import_chunk_Q3HBHPRL.ValueTypeEnum.Boolean,
692
- NUMBER_RAW: import_chunk_Q3HBHPRL.ValueTypeEnum.Number,
693
- NUMBER_PERCENT: import_chunk_Q3HBHPRL.ValueTypeEnum.Percent,
694
- NUMBER_CURRENCY: import_chunk_Q3HBHPRL.ValueTypeEnum.Currency,
695
- NUMBER_DATETIME: import_chunk_Q3HBHPRL.ValueTypeEnum.DateTime,
696
- NUMBER_DATE: import_chunk_Q3HBHPRL.ValueTypeEnum.Date,
697
- NUMBER_TIME: import_chunk_Q3HBHPRL.ValueTypeEnum.Time
701
+ BOOLEAN: import_chunk_AOP42UAA.ValueTypeEnum.Boolean,
702
+ NUMBER_RAW: import_chunk_AOP42UAA.ValueTypeEnum.Number,
703
+ NUMBER_PERCENT: import_chunk_AOP42UAA.ValueTypeEnum.Percent,
704
+ NUMBER_CURRENCY: import_chunk_AOP42UAA.ValueTypeEnum.Currency,
705
+ NUMBER_DATETIME: import_chunk_AOP42UAA.ValueTypeEnum.DateTime,
706
+ NUMBER_DATE: import_chunk_AOP42UAA.ValueTypeEnum.Date,
707
+ NUMBER_TIME: import_chunk_AOP42UAA.ValueTypeEnum.Time
698
708
  };
699
709
  var getTopLeft = (range) => {
700
710
  const to = range.to ?? range.from;
@@ -720,8 +730,6 @@ var SheetModel = class extends import_context.Resource {
720
730
  this._options = _options;
721
731
  this.id = `model-${import_keys.PublicKey.random().truncate()}`;
722
732
  this.update = new import_async2.Event();
723
- this._node = this._graph.getOrCreateNode((0, import_chunk_DD6FIXWC.createSheetName)(this._sheet.id));
724
- this.reset();
725
733
  }
726
734
  get graph() {
727
735
  return this._graph;
@@ -746,14 +754,15 @@ var SheetModel = class extends import_context.Resource {
746
754
  id: this.id
747
755
  }, {
748
756
  F: __dxlog_file2,
749
- L: 105,
757
+ L: 103,
750
758
  S: this,
751
759
  C: (f, a) => f(...a)
752
760
  });
753
761
  initialize(this._sheet);
754
- this.reset();
755
- const unsubscribe = this._graph.update.on(() => this.update.emit());
762
+ this._node = await this._graph.getOrCreateNode((0, import_chunk_P5QYYEHQ.createSheetName)(this._sheet.id));
763
+ const unsubscribe = this._node.update.on((event) => this.update.emit(event));
756
764
  this._ctx.onDispose(unsubscribe);
765
+ this.reset();
757
766
  }
758
767
  /**
759
768
  * Update engine.
@@ -761,13 +770,31 @@ var SheetModel = class extends import_context.Resource {
761
770
  * @deprecated
762
771
  */
763
772
  reset() {
764
- this._node.hf.clearSheet(this._node.sheetId);
773
+ (0, import_invariant3.invariant)(this._node, void 0, {
774
+ F: __dxlog_file2,
775
+ L: 122,
776
+ S: this,
777
+ A: [
778
+ "this._node",
779
+ ""
780
+ ]
781
+ });
782
+ this._node.graph.hf.clearSheet(this._node.sheetId);
765
783
  Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
784
+ (0, import_invariant3.invariant)(this._node, void 0, {
785
+ F: __dxlog_file2,
786
+ L: 125,
787
+ S: this,
788
+ A: [
789
+ "this._node",
790
+ ""
791
+ ]
792
+ });
766
793
  const { col, row } = addressFromIndex(this._sheet, key);
767
794
  if (typeof value === "string" && value.charAt(0) === "=") {
768
795
  value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
769
796
  }
770
- this._node.hf.setCellContents({
797
+ this._node.graph.hf.setCellContents({
771
798
  sheet: this._node.sheetId,
772
799
  row,
773
800
  col
@@ -782,7 +809,7 @@ var SheetModel = class extends import_context.Resource {
782
809
  */
783
810
  // TODO(burdon): Remove.
784
811
  recalculate() {
785
- this._node.hf.rebuildAndRecalculate();
812
+ this._node?.graph.hf.rebuildAndRecalculate();
786
813
  }
787
814
  insertRows(i, n = 1) {
788
815
  insertIndices(this._sheet.rows, i, n, MAX_ROWS);
@@ -800,27 +827,63 @@ var SheetModel = class extends import_context.Resource {
800
827
  * Clear range of values.
801
828
  */
802
829
  clear(range) {
830
+ (0, import_invariant3.invariant)(this._node, void 0, {
831
+ F: __dxlog_file2,
832
+ L: 167,
833
+ S: this,
834
+ A: [
835
+ "this._node",
836
+ ""
837
+ ]
838
+ });
803
839
  const topLeft = getTopLeft(range);
804
840
  const values = this._iterRange(range, () => null);
805
- this._node.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
841
+ this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
806
842
  this._iterRange(range, (cell) => {
807
843
  const idx = addressToIndex(this._sheet, cell);
808
844
  delete this._sheet.cells[idx];
809
845
  });
810
846
  }
811
847
  cut(range) {
812
- this._node.hf.cut(toModelRange(this._node.sheetId, range));
848
+ (0, import_invariant3.invariant)(this._node, void 0, {
849
+ F: __dxlog_file2,
850
+ L: 178,
851
+ S: this,
852
+ A: [
853
+ "this._node",
854
+ ""
855
+ ]
856
+ });
857
+ this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
813
858
  this._iterRange(range, (cell) => {
814
859
  const idx = addressToIndex(this._sheet, cell);
815
860
  delete this._sheet.cells[idx];
816
861
  });
817
862
  }
818
863
  copy(range) {
819
- this._node.hf.copy(toModelRange(this._node.sheetId, range));
864
+ (0, import_invariant3.invariant)(this._node, void 0, {
865
+ F: __dxlog_file2,
866
+ L: 187,
867
+ S: this,
868
+ A: [
869
+ "this._node",
870
+ ""
871
+ ]
872
+ });
873
+ this._node.graph.hf.copy(toModelRange(this._node.sheetId, range));
820
874
  }
821
875
  paste(cell) {
822
- if (!this._node.hf.isClipboardEmpty()) {
823
- const changes = this._node.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
876
+ (0, import_invariant3.invariant)(this._node, void 0, {
877
+ F: __dxlog_file2,
878
+ L: 192,
879
+ S: this,
880
+ A: [
881
+ "this._node",
882
+ ""
883
+ ]
884
+ });
885
+ if (!this._node.graph.hf.isClipboardEmpty()) {
886
+ const changes = this._node.graph.hf.paste(toSimpleCellAddress(this._node.sheetId, cell));
824
887
  for (const change of changes) {
825
888
  if (change instanceof import_hyperformula.ExportedCellChange) {
826
889
  const { address, newValue } = change;
@@ -837,15 +900,31 @@ var SheetModel = class extends import_context.Resource {
837
900
  }
838
901
  // TODO(burdon): Display undo/redo state.
839
902
  undo() {
840
- if (this._node.hf.isThereSomethingToUndo()) {
841
- this._node.hf.undo();
842
- this.update.emit();
903
+ (0, import_invariant3.invariant)(this._node, void 0, {
904
+ F: __dxlog_file2,
905
+ L: 207,
906
+ S: this,
907
+ A: [
908
+ "this._node",
909
+ ""
910
+ ]
911
+ });
912
+ if (this._node.graph.hf.isThereSomethingToUndo()) {
913
+ this._node.graph.hf.undo();
843
914
  }
844
915
  }
845
916
  redo() {
846
- if (this._node.hf.isThereSomethingToRedo()) {
847
- this._node.hf.redo();
848
- this.update.emit();
917
+ (0, import_invariant3.invariant)(this._node, void 0, {
918
+ F: __dxlog_file2,
919
+ L: 215,
920
+ S: this,
921
+ A: [
922
+ "this._node",
923
+ ""
924
+ ]
925
+ });
926
+ if (this._node.graph.hf.isThereSomethingToRedo()) {
927
+ this._node.graph.hf.redo();
849
928
  }
850
929
  }
851
930
  /**
@@ -879,7 +958,16 @@ var SheetModel = class extends import_context.Resource {
879
958
  * Gets the regular or computed value from the engine.
880
959
  */
881
960
  getValue(cell) {
882
- const value = this._node.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
961
+ (0, import_invariant3.invariant)(this._node, void 0, {
962
+ F: __dxlog_file2,
963
+ L: 258,
964
+ S: this,
965
+ A: [
966
+ "this._node",
967
+ ""
968
+ ]
969
+ });
970
+ const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
883
971
  if (value instanceof import_hyperformula.DetailedCellError) {
884
972
  return value.toString();
885
973
  }
@@ -889,14 +977,32 @@ var SheetModel = class extends import_context.Resource {
889
977
  * Get value type.
890
978
  */
891
979
  getValueType(cell) {
980
+ (0, import_invariant3.invariant)(this._node, void 0, {
981
+ F: __dxlog_file2,
982
+ L: 271,
983
+ S: this,
984
+ A: [
985
+ "this._node",
986
+ ""
987
+ ]
988
+ });
892
989
  const addr = toSimpleCellAddress(this._node.sheetId, cell);
893
- const type = this._node.hf.getCellValueDetailedType(addr);
990
+ const type = this._node.graph.hf.getCellValueDetailedType(addr);
894
991
  return typeMap[type];
895
992
  }
896
993
  /**
897
994
  * Sets the value, updating the sheet and engine.
898
995
  */
899
996
  setValue(cell, value) {
997
+ (0, import_invariant3.invariant)(this._node, void 0, {
998
+ F: __dxlog_file2,
999
+ L: 281,
1000
+ S: this,
1001
+ A: [
1002
+ "this._node",
1003
+ ""
1004
+ ]
1005
+ });
900
1006
  if (this._options.readonly) {
901
1007
  throw new ReadonlyException();
902
1008
  }
@@ -912,7 +1018,7 @@ var SheetModel = class extends import_context.Resource {
912
1018
  if (refresh) {
913
1019
  this.reset();
914
1020
  }
915
- this._node.hf.setCellContents({
1021
+ this._node.graph.hf.setCellContents({
916
1022
  sheet: this._node.sheetId,
917
1023
  row: cell.row,
918
1024
  col: cell.col
@@ -987,7 +1093,7 @@ var SheetModel = class extends import_context.Resource {
987
1093
  mapFormulaRefsToIndices(formula) {
988
1094
  (0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
989
1095
  F: __dxlog_file2,
990
- L: 358,
1096
+ L: 370,
991
1097
  S: this,
992
1098
  A: [
993
1099
  "formula.charAt(0) === '='",
@@ -1004,7 +1110,7 @@ var SheetModel = class extends import_context.Resource {
1004
1110
  mapFormulaIndicesToRefs(formula) {
1005
1111
  (0, import_invariant3.invariant)(formula.charAt(0) === "=", void 0, {
1006
1112
  F: __dxlog_file2,
1007
- L: 368,
1113
+ L: 380,
1008
1114
  S: this,
1009
1115
  A: [
1010
1116
  "formula.charAt(0) === '='",
@@ -1028,13 +1134,40 @@ var SheetModel = class extends import_context.Resource {
1028
1134
  return new Date(year, month - 1, day, hours, minutes, seconds);
1029
1135
  }
1030
1136
  toDateTime(num) {
1031
- return this._node.hf.numberToDateTime(num);
1137
+ (0, import_invariant3.invariant)(this._node, void 0, {
1138
+ F: __dxlog_file2,
1139
+ L: 401,
1140
+ S: this,
1141
+ A: [
1142
+ "this._node",
1143
+ ""
1144
+ ]
1145
+ });
1146
+ return this._node.graph.hf.numberToDateTime(num);
1032
1147
  }
1033
1148
  toDate(num) {
1034
- return this._node.hf.numberToDate(num);
1149
+ (0, import_invariant3.invariant)(this._node, void 0, {
1150
+ F: __dxlog_file2,
1151
+ L: 406,
1152
+ S: this,
1153
+ A: [
1154
+ "this._node",
1155
+ ""
1156
+ ]
1157
+ });
1158
+ return this._node.graph.hf.numberToDate(num);
1035
1159
  }
1036
1160
  toTime(num) {
1037
- return this._node.hf.numberToTime(num);
1161
+ (0, import_invariant3.invariant)(this._node, void 0, {
1162
+ F: __dxlog_file2,
1163
+ L: 411,
1164
+ S: this,
1165
+ A: [
1166
+ "this._node",
1167
+ ""
1168
+ ]
1169
+ });
1170
+ return this._node.graph.hf.numberToTime(num);
1038
1171
  }
1039
1172
  };
1040
1173
  var useFormattingModel = (model) => {
@@ -1042,11 +1175,10 @@ var useFormattingModel = (model) => {
1042
1175
  model
1043
1176
  ]);
1044
1177
  };
1045
- var useSheetModel = (space, sheet, { readonly } = {}) => {
1046
- const graph = useComputeGraph(space);
1178
+ var useSheetModel = (graph, sheet, { readonly } = {}) => {
1047
1179
  const [model, setModel] = (0, import_react10.useState)();
1048
1180
  (0, import_react10.useEffect)(() => {
1049
- if (!space || !graph || !sheet) {
1181
+ if (!graph || !sheet) {
1050
1182
  return;
1051
1183
  }
1052
1184
  let model2;
@@ -1062,9 +1194,8 @@ var useSheetModel = (space, sheet, { readonly } = {}) => {
1062
1194
  void model2?.close();
1063
1195
  };
1064
1196
  }, [
1065
- space,
1066
- sheet,
1067
1197
  graph,
1198
+ sheet,
1068
1199
  readonly
1069
1200
  ]);
1070
1201
  return model;
@@ -1084,8 +1215,8 @@ var useSheetContext = () => {
1084
1215
  });
1085
1216
  return context;
1086
1217
  };
1087
- var SheetContextProvider = ({ children, sheet, space, readonly, onInfo }) => {
1088
- const model = useSheetModel(space, sheet, {
1218
+ var SheetContextProvider = ({ children, graph, sheet, readonly, onInfo }) => {
1219
+ const model = useSheetModel(graph, sheet, {
1089
1220
  readonly
1090
1221
  });
1091
1222
  const formatting = useFormattingModel(model);
@@ -2531,6 +2662,7 @@ var Sheet = {
2531
2662
  addressToIndex,
2532
2663
  compareIndexPositions,
2533
2664
  createSheet,
2665
+ useComputeGraph,
2534
2666
  useSheetContext
2535
2667
  });
2536
- //# sourceMappingURL=chunk-OTTD7FBK.cjs.map
2668
+ //# sourceMappingURL=chunk-6DQABRGJ.cjs.map