@dxos/plugin-sheet 0.6.14-staging.9e90729 → 0.6.14-staging.c117501

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 (117) hide show
  1. package/dist/lib/browser/{SheetContainer-JBB7W52Y.mjs → SheetContainer-P3NF5KEI.mjs} +60 -48
  2. package/dist/lib/browser/SheetContainer-P3NF5KEI.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-XXDHBYZQ.mjs → chunk-4LKIURJA.mjs} +337 -122
  4. package/dist/lib/browser/chunk-4LKIURJA.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-3QWIMZZJ.mjs → chunk-BVUN7SHF.mjs} +5 -3
  6. package/dist/lib/browser/chunk-BVUN7SHF.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-D3QTX46O.mjs → chunk-RABELMEQ.mjs} +3 -2
  8. package/dist/lib/browser/{chunk-D3QTX46O.mjs.map → chunk-RABELMEQ.mjs.map} +3 -3
  9. package/dist/lib/browser/{chunk-2ZK3YMZG.mjs → chunk-VMSX6Z4X.mjs} +58 -20
  10. package/dist/lib/browser/chunk-VMSX6Z4X.mjs.map +7 -0
  11. package/dist/lib/browser/{compute-graph-ZQKB6QVP.mjs → compute-graph-GGWUX644.mjs} +4 -4
  12. package/dist/lib/browser/index.mjs +48 -21
  13. package/dist/lib/browser/index.mjs.map +3 -3
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/meta.mjs +1 -1
  16. package/dist/lib/browser/types.mjs +2 -2
  17. package/dist/lib/node/{SheetContainer-L37HUFCF.cjs → SheetContainer-MPFKXY26.cjs} +72 -63
  18. package/dist/lib/node/SheetContainer-MPFKXY26.cjs.map +7 -0
  19. package/dist/lib/node/{chunk-QIFIGEKV.cjs → chunk-2ZVZI2KJ.cjs} +6 -5
  20. package/dist/lib/node/{chunk-QIFIGEKV.cjs.map → chunk-2ZVZI2KJ.cjs.map} +3 -3
  21. package/dist/lib/node/{chunk-V7E5JZBD.cjs → chunk-AWKOWDMI.cjs} +9 -7
  22. package/dist/lib/node/chunk-AWKOWDMI.cjs.map +7 -0
  23. package/dist/lib/node/{chunk-QNFMTK3X.cjs → chunk-O7XR4R7Y.cjs} +69 -29
  24. package/dist/lib/node/chunk-O7XR4R7Y.cjs.map +7 -0
  25. package/dist/lib/node/{chunk-7AWAC3R3.cjs → chunk-OO24XJBV.cjs} +353 -139
  26. package/dist/lib/node/chunk-OO24XJBV.cjs.map +7 -0
  27. package/dist/lib/node/{compute-graph-RJB6OVW6.cjs → compute-graph-KGWA2QLE.cjs} +21 -21
  28. package/dist/lib/node/{compute-graph-RJB6OVW6.cjs.map → compute-graph-KGWA2QLE.cjs.map} +2 -2
  29. package/dist/lib/node/index.cjs +74 -46
  30. package/dist/lib/node/index.cjs.map +3 -3
  31. package/dist/lib/node/meta.cjs +3 -3
  32. package/dist/lib/node/meta.cjs.map +1 -1
  33. package/dist/lib/node/meta.json +1 -1
  34. package/dist/lib/node/types.cjs +7 -7
  35. package/dist/lib/node/types.cjs.map +1 -1
  36. package/dist/lib/node-esm/{SheetContainer-CLKFEM35.mjs → SheetContainer-22IOAW3B.mjs} +60 -48
  37. package/dist/lib/node-esm/SheetContainer-22IOAW3B.mjs.map +7 -0
  38. package/dist/lib/node-esm/{chunk-VCYJWE3O.mjs → chunk-BM2Q3FFC.mjs} +3 -2
  39. package/dist/lib/node-esm/{chunk-VCYJWE3O.mjs.map → chunk-BM2Q3FFC.mjs.map} +3 -3
  40. package/dist/lib/node-esm/{chunk-3JYJEOCF.mjs → chunk-BW36PM2Y.mjs} +337 -122
  41. package/dist/lib/node-esm/chunk-BW36PM2Y.mjs.map +7 -0
  42. package/dist/lib/node-esm/{chunk-JBTORSST.mjs → chunk-CR4K75EL.mjs} +58 -20
  43. package/dist/lib/node-esm/chunk-CR4K75EL.mjs.map +7 -0
  44. package/dist/lib/node-esm/{chunk-SPQFLYC2.mjs → chunk-UIBWRHW7.mjs} +5 -3
  45. package/dist/lib/node-esm/chunk-UIBWRHW7.mjs.map +7 -0
  46. package/dist/lib/node-esm/{compute-graph-VKRG526N.mjs → compute-graph-2SCZT7N5.mjs} +4 -4
  47. package/dist/lib/node-esm/index.mjs +48 -21
  48. package/dist/lib/node-esm/index.mjs.map +3 -3
  49. package/dist/lib/node-esm/meta.json +1 -1
  50. package/dist/lib/node-esm/meta.mjs +1 -1
  51. package/dist/lib/node-esm/types.mjs +2 -2
  52. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  53. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
  54. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  55. package/dist/types/src/components/GridSheet/util.d.ts +2 -2
  56. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  57. package/dist/types/src/components/RangeList/RangeList.d.ts +2 -4
  58. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
  59. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -3
  60. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  61. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  62. package/dist/types/src/components/Toolbar/Toolbar.d.ts +6 -3
  63. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  64. package/dist/types/src/components/index.d.ts +4 -2
  65. package/dist/types/src/components/index.d.ts.map +1 -1
  66. package/dist/types/src/compute-graph/compute-graph.d.ts +2 -2
  67. package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -1
  68. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -1
  69. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -1
  70. package/dist/types/src/defs/sheet-range-types.d.ts +2 -2
  71. package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
  72. package/dist/types/src/defs/util.d.ts +1 -1
  73. package/dist/types/src/defs/util.d.ts.map +1 -1
  74. package/dist/types/src/integrations/thread-ranges.d.ts +1 -2
  75. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
  76. package/dist/types/src/meta.d.ts +1 -0
  77. package/dist/types/src/meta.d.ts.map +1 -1
  78. package/dist/types/src/model/sheet-model.d.ts +12 -5
  79. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  80. package/dist/types/src/translations.d.ts +12 -3
  81. package/dist/types/src/translations.d.ts.map +1 -1
  82. package/dist/types/src/types.d.ts +33 -3
  83. package/dist/types/src/types.d.ts.map +1 -1
  84. package/package.json +37 -36
  85. package/src/SheetPlugin.tsx +27 -7
  86. package/src/components/FunctionEditor/FunctionEditor.tsx +1 -5
  87. package/src/components/GridSheet/GridSheet.tsx +107 -42
  88. package/src/components/GridSheet/util.ts +26 -16
  89. package/src/components/RangeList/RangeList.tsx +27 -12
  90. package/src/components/SheetContainer/SheetContainer.stories.tsx +4 -2
  91. package/src/components/SheetContainer/SheetContainer.tsx +19 -12
  92. package/src/components/Toolbar/Toolbar.tsx +72 -59
  93. package/src/compute-graph/compute-graph.ts +22 -7
  94. package/src/compute-graph/functions/async-function.ts +1 -0
  95. package/src/compute-graph/functions/edge-function.ts +5 -3
  96. package/src/defs/sheet-range-types.ts +8 -6
  97. package/src/defs/util.ts +1 -0
  98. package/src/integrations/thread-ranges.ts +3 -3
  99. package/src/meta.ts +1 -0
  100. package/src/model/sheet-model.test.ts +5 -3
  101. package/src/model/sheet-model.ts +93 -21
  102. package/src/translations.ts +12 -3
  103. package/src/types.ts +21 -1
  104. package/dist/lib/browser/SheetContainer-JBB7W52Y.mjs.map +0 -7
  105. package/dist/lib/browser/chunk-2ZK3YMZG.mjs.map +0 -7
  106. package/dist/lib/browser/chunk-3QWIMZZJ.mjs.map +0 -7
  107. package/dist/lib/browser/chunk-XXDHBYZQ.mjs.map +0 -7
  108. package/dist/lib/node/SheetContainer-L37HUFCF.cjs.map +0 -7
  109. package/dist/lib/node/chunk-7AWAC3R3.cjs.map +0 -7
  110. package/dist/lib/node/chunk-QNFMTK3X.cjs.map +0 -7
  111. package/dist/lib/node/chunk-V7E5JZBD.cjs.map +0 -7
  112. package/dist/lib/node-esm/SheetContainer-CLKFEM35.mjs.map +0 -7
  113. package/dist/lib/node-esm/chunk-3JYJEOCF.mjs.map +0 -7
  114. package/dist/lib/node-esm/chunk-JBTORSST.mjs.map +0 -7
  115. package/dist/lib/node-esm/chunk-SPQFLYC2.mjs.map +0 -7
  116. /package/dist/lib/browser/{compute-graph-ZQKB6QVP.mjs.map → compute-graph-GGWUX644.mjs.map} +0 -0
  117. /package/dist/lib/node-esm/{compute-graph-VKRG526N.mjs.map → compute-graph-2SCZT7N5.mjs.map} +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_7AWAC3R3_exports = {};
30
- __export(chunk_7AWAC3R3_exports, {
29
+ var chunk_OO24XJBV_exports = {};
30
+ __export(chunk_OO24XJBV_exports, {
31
31
  ComputeGraphContextProvider: () => ComputeGraphContextProvider,
32
32
  GridSheet: () => GridSheet,
33
33
  RangeList: () => RangeList,
@@ -38,10 +38,10 @@ __export(chunk_7AWAC3R3_exports, {
38
38
  useComputeGraph: () => useComputeGraph,
39
39
  useSheetContext: () => useSheetContext
40
40
  });
41
- module.exports = __toCommonJS(chunk_7AWAC3R3_exports);
42
- var import_chunk_QNFMTK3X = require("./chunk-QNFMTK3X.cjs");
43
- var import_chunk_V7E5JZBD = require("./chunk-V7E5JZBD.cjs");
44
- var import_chunk_QIFIGEKV = require("./chunk-QIFIGEKV.cjs");
41
+ module.exports = __toCommonJS(chunk_OO24XJBV_exports);
42
+ var import_chunk_O7XR4R7Y = require("./chunk-O7XR4R7Y.cjs");
43
+ var import_chunk_AWKOWDMI = require("./chunk-AWKOWDMI.cjs");
44
+ var import_chunk_2ZVZI2KJ = require("./chunk-2ZVZI2KJ.cjs");
45
45
  var import_react = __toESM(require("react"));
46
46
  var import_debug = require("@dxos/debug");
47
47
  var import_react_hooks = require("@dxos/react-hooks");
@@ -68,10 +68,10 @@ var import_echo_schema = require("@dxos/echo-schema");
68
68
  var import_invariant3 = require("@dxos/invariant");
69
69
  var import_keys = require("@dxos/keys");
70
70
  var import_log = require("@dxos/log");
71
- var import_schema = require("@dxos/schema");
72
71
  var import_hyperformula = require("#hyperformula");
73
72
  var import_react3 = require("react");
74
73
  var import_react4 = __toESM(require("react"));
74
+ var import_app_framework = require("@dxos/app-framework");
75
75
  var import_react_ui = require("@dxos/react-ui");
76
76
  var import_react_ui_attention = require("@dxos/react-ui-attention");
77
77
  var import_react_ui_grid2 = require("@dxos/react-ui-grid");
@@ -81,12 +81,13 @@ var import_react_ui_data = require("@dxos/react-ui-data");
81
81
  var import_react_ui_grid3 = require("@dxos/react-ui-grid");
82
82
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
83
83
  var import_react6 = require("react");
84
- var import_app_framework = require("@dxos/app-framework");
84
+ var import_app_framework2 = require("@dxos/app-framework");
85
85
  var import_async3 = require("@dxos/async");
86
86
  var import_echo3 = require("@dxos/react-client/echo");
87
87
  var import_react7 = require("react");
88
88
  var import_react8 = __toESM(require("react"));
89
89
  var import_echo_schema2 = require("@dxos/echo-schema");
90
+ var import_react_ui2 = require("@dxos/react-ui");
90
91
  var import_react_ui_list = require("@dxos/react-ui-list");
91
92
  var import_react_ui_theme3 = require("@dxos/react-ui-theme");
92
93
  var ComputeGraphContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
@@ -292,7 +293,7 @@ var rangeExtension = ({ onInit, onStateChange }) => {
292
293
  });
293
294
  if (!activeRange && view2.state.doc.toString()[0] === "=") {
294
295
  const str = view2.state.doc.sliceString(1);
295
- if (import_chunk_QNFMTK3X.RANGE_NOTATION.test(str)) {
296
+ if (import_chunk_O7XR4R7Y.RANGE_NOTATION.test(str)) {
296
297
  activeRange = {
297
298
  from: 1,
298
299
  to: str.length + 1
@@ -318,13 +319,32 @@ var visitTree = (node, callback) => {
318
319
  };
319
320
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
320
321
  var typeMap = {
321
- BOOLEAN: import_schema.FieldValueType.Boolean,
322
- NUMBER_RAW: import_schema.FieldValueType.Number,
323
- NUMBER_PERCENT: import_schema.FieldValueType.Percent,
324
- NUMBER_CURRENCY: import_schema.FieldValueType.Currency,
325
- NUMBER_DATETIME: import_schema.FieldValueType.DateTime,
326
- NUMBER_DATE: import_schema.FieldValueType.Date,
327
- NUMBER_TIME: import_schema.FieldValueType.Time
322
+ BOOLEAN: {
323
+ type: import_echo_schema.TypeEnum.Boolean
324
+ },
325
+ NUMBER_RAW: {
326
+ type: import_echo_schema.TypeEnum.Number
327
+ },
328
+ NUMBER_PERCENT: {
329
+ type: import_echo_schema.TypeEnum.Number,
330
+ format: import_echo_schema.FormatEnum.Percent
331
+ },
332
+ NUMBER_CURRENCY: {
333
+ type: import_echo_schema.TypeEnum.Number,
334
+ format: import_echo_schema.FormatEnum.Currency
335
+ },
336
+ NUMBER_DATETIME: {
337
+ type: import_echo_schema.TypeEnum.String,
338
+ format: import_echo_schema.FormatEnum.DateTime
339
+ },
340
+ NUMBER_DATE: {
341
+ type: import_echo_schema.TypeEnum.String,
342
+ format: import_echo_schema.FormatEnum.Date
343
+ },
344
+ NUMBER_TIME: {
345
+ type: import_echo_schema.TypeEnum.String,
346
+ format: import_echo_schema.FormatEnum.Time
347
+ }
328
348
  };
329
349
  var getTopLeft = (range) => {
330
350
  const to = range.to ?? range.from;
@@ -374,12 +394,17 @@ var SheetModel = class extends import_context.Resource {
374
394
  id: this.id
375
395
  }, {
376
396
  F: __dxlog_file,
377
- L: 111,
397
+ L: 113,
378
398
  S: this,
379
399
  C: (f, a) => f(...a)
380
400
  });
381
- (0, import_chunk_QNFMTK3X.initialize)(this._sheet);
382
- this._node = this._graph.getOrCreateNode((0, import_chunk_QNFMTK3X.createSheetName)({
401
+ (0, import_chunk_O7XR4R7Y.initialize)(this._sheet);
402
+ this._graph.update.on((event) => {
403
+ if (event.type === "functionsUpdated") {
404
+ this.reset();
405
+ }
406
+ });
407
+ this._node = this._graph.getOrCreateNode((0, import_chunk_O7XR4R7Y.createSheetName)({
383
408
  type: (0, import_echo_schema.getTypename)(this._sheet),
384
409
  id: this._sheet.id
385
410
  }));
@@ -396,7 +421,7 @@ var SheetModel = class extends import_context.Resource {
396
421
  reset() {
397
422
  (0, import_invariant3.invariant)(this._node, void 0, {
398
423
  F: __dxlog_file,
399
- L: 131,
424
+ L: 139,
400
425
  S: this,
401
426
  A: [
402
427
  "this._node",
@@ -407,16 +432,21 @@ var SheetModel = class extends import_context.Resource {
407
432
  Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
408
433
  (0, import_invariant3.invariant)(this._node, void 0, {
409
434
  F: __dxlog_file,
410
- L: 134,
435
+ L: 142,
411
436
  S: this,
412
437
  A: [
413
438
  "this._node",
414
439
  ""
415
440
  ]
416
441
  });
417
- const { col, row } = (0, import_chunk_QNFMTK3X.addressFromIndex)(this._sheet, key);
418
- if ((0, import_chunk_QNFMTK3X.isFormula)(value)) {
419
- value = this._graph.mapFormulaToNative(this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value)));
442
+ const { col, row } = (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, key);
443
+ if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
444
+ const binding = this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
445
+ if (binding) {
446
+ value = this._graph.mapFormulaToNative(binding);
447
+ } else {
448
+ value = "";
449
+ }
420
450
  }
421
451
  this._node.graph.hf.setCellContents({
422
452
  sheet: this._node.sheetId,
@@ -436,11 +466,79 @@ var SheetModel = class extends import_context.Resource {
436
466
  this._node?.graph.hf.rebuildAndRecalculate();
437
467
  }
438
468
  insertRows(i, n = 1) {
439
- (0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.rows, i, n, import_chunk_QNFMTK3X.MAX_ROWS);
469
+ const idx = (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.rows, i, n, import_chunk_O7XR4R7Y.MAX_ROWS);
440
470
  this.reset();
471
+ return idx;
441
472
  }
442
473
  insertColumns(i, n = 1) {
443
- (0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.columns, i, n, import_chunk_QNFMTK3X.MAX_COLUMNS);
474
+ const idx = (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.columns, i, n, import_chunk_O7XR4R7Y.MAX_COLUMNS);
475
+ this.reset();
476
+ return idx;
477
+ }
478
+ dropRow(rowIndex) {
479
+ const range = {
480
+ from: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${this._sheet.columns[0]}@${rowIndex}`),
481
+ to: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${this._sheet.columns[this._sheet.columns.length - 1]}@${rowIndex}`)
482
+ };
483
+ const values = this.getCellValues(range).flat();
484
+ const index = this._sheet.rows.indexOf(rowIndex);
485
+ this.clear(range);
486
+ this._sheet.rows.splice(index, 1);
487
+ delete this._sheet.rowMeta[rowIndex];
488
+ this.reset();
489
+ return {
490
+ axis: "row",
491
+ index,
492
+ axisIndex: rowIndex,
493
+ axisMeta: this._sheet.rowMeta[rowIndex],
494
+ values
495
+ };
496
+ }
497
+ dropColumn(colIndex) {
498
+ const range = {
499
+ from: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[0]}`),
500
+ to: (0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, `${colIndex}@${this._sheet.rows[this._sheet.rows.length - 1]}`)
501
+ };
502
+ const values = this.getCellValues(range).flat();
503
+ const index = this._sheet.columns.indexOf(colIndex);
504
+ this.clear(range);
505
+ this._sheet.columns.splice(index, 1);
506
+ delete this._sheet.columnMeta[colIndex];
507
+ this.reset();
508
+ return {
509
+ axis: "col",
510
+ index,
511
+ axisIndex: colIndex,
512
+ axisMeta: this._sheet.rowMeta[colIndex],
513
+ values
514
+ };
515
+ }
516
+ restoreRow({ index, axisIndex, axisMeta, values }) {
517
+ this._sheet.rows.splice(index, 0, axisIndex);
518
+ values.forEach((value, col) => {
519
+ if (value) {
520
+ this._sheet.cells[`${this._sheet.columns[col]}@${axisIndex}`] = {
521
+ value
522
+ };
523
+ }
524
+ });
525
+ if (axisMeta) {
526
+ this._sheet.rowMeta[axisIndex] = axisMeta;
527
+ }
528
+ this.reset();
529
+ }
530
+ restoreColumn({ index, axisIndex, axisMeta, values }) {
531
+ this._sheet.columns.splice(index, 0, axisIndex);
532
+ values.forEach((value, row) => {
533
+ if (value) {
534
+ this._sheet.cells[`${axisIndex}@${this._sheet.rows[row]}`] = {
535
+ value
536
+ };
537
+ }
538
+ });
539
+ if (axisMeta) {
540
+ this._sheet.columnMeta[axisIndex] = axisMeta;
541
+ }
444
542
  this.reset();
445
543
  }
446
544
  //
@@ -453,7 +551,7 @@ var SheetModel = class extends import_context.Resource {
453
551
  clear(range) {
454
552
  (0, import_invariant3.invariant)(this._node, void 0, {
455
553
  F: __dxlog_file,
456
- L: 176,
554
+ L: 245,
457
555
  S: this,
458
556
  A: [
459
557
  "this._node",
@@ -464,14 +562,14 @@ var SheetModel = class extends import_context.Resource {
464
562
  const values = this._iterRange(range, () => null);
465
563
  this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
466
564
  this._iterRange(range, (cell) => {
467
- const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
565
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
468
566
  delete this._sheet.cells[idx];
469
567
  });
470
568
  }
471
569
  cut(range) {
472
570
  (0, import_invariant3.invariant)(this._node, void 0, {
473
571
  F: __dxlog_file,
474
- L: 187,
572
+ L: 256,
475
573
  S: this,
476
574
  A: [
477
575
  "this._node",
@@ -480,14 +578,14 @@ var SheetModel = class extends import_context.Resource {
480
578
  });
481
579
  this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
482
580
  this._iterRange(range, (cell) => {
483
- const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
581
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
484
582
  delete this._sheet.cells[idx];
485
583
  });
486
584
  }
487
585
  copy(range) {
488
586
  (0, import_invariant3.invariant)(this._node, void 0, {
489
587
  F: __dxlog_file,
490
- L: 196,
588
+ L: 265,
491
589
  S: this,
492
590
  A: [
493
591
  "this._node",
@@ -499,7 +597,7 @@ var SheetModel = class extends import_context.Resource {
499
597
  paste(cell) {
500
598
  (0, import_invariant3.invariant)(this._node, void 0, {
501
599
  F: __dxlog_file,
502
- L: 201,
600
+ L: 270,
503
601
  S: this,
504
602
  A: [
505
603
  "this._node",
@@ -511,7 +609,7 @@ var SheetModel = class extends import_context.Resource {
511
609
  for (const change of changes) {
512
610
  if (change instanceof import_hyperformula.ExportedCellChange) {
513
611
  const { address, newValue } = change;
514
- const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, {
612
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, {
515
613
  row: address.row,
516
614
  col: address.col
517
615
  });
@@ -526,7 +624,7 @@ var SheetModel = class extends import_context.Resource {
526
624
  undo() {
527
625
  (0, import_invariant3.invariant)(this._node, void 0, {
528
626
  F: __dxlog_file,
529
- L: 216,
627
+ L: 285,
530
628
  S: this,
531
629
  A: [
532
630
  "this._node",
@@ -540,7 +638,7 @@ var SheetModel = class extends import_context.Resource {
540
638
  redo() {
541
639
  (0, import_invariant3.invariant)(this._node, void 0, {
542
640
  F: __dxlog_file,
543
- L: 224,
641
+ L: 293,
544
642
  S: this,
545
643
  A: [
546
644
  "this._node",
@@ -555,7 +653,7 @@ var SheetModel = class extends import_context.Resource {
555
653
  * Get value from sheet.
556
654
  */
557
655
  getCellValue(cell) {
558
- const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
656
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
559
657
  return this._sheet.cells[idx]?.value ?? null;
560
658
  }
561
659
  /**
@@ -566,7 +664,7 @@ var SheetModel = class extends import_context.Resource {
566
664
  if (value == null) {
567
665
  return void 0;
568
666
  }
569
- if ((0, import_chunk_QNFMTK3X.isFormula)(value)) {
667
+ if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
570
668
  return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
571
669
  } else {
572
670
  return String(value);
@@ -584,15 +682,25 @@ var SheetModel = class extends import_context.Resource {
584
682
  getValue(cell) {
585
683
  (0, import_invariant3.invariant)(this._node, void 0, {
586
684
  F: __dxlog_file,
587
- L: 267,
685
+ L: 336,
588
686
  S: this,
589
687
  A: [
590
688
  "this._node",
591
689
  ""
592
690
  ]
593
691
  });
594
- const value = this._node.graph.hf.getCellValue(toSimpleCellAddress(this._node.sheetId, cell));
692
+ const address = toSimpleCellAddress(this._node.sheetId, cell);
693
+ const value = this._node.graph.hf.getCellValue(address);
595
694
  if (value instanceof import_hyperformula.DetailedCellError) {
695
+ import_log.log.info("cell error", {
696
+ cell,
697
+ error: value
698
+ }, {
699
+ F: __dxlog_file,
700
+ L: 341,
701
+ S: this,
702
+ C: (f, a) => f(...a)
703
+ });
596
704
  return value.toString();
597
705
  }
598
706
  return value;
@@ -600,10 +708,10 @@ var SheetModel = class extends import_context.Resource {
600
708
  /**
601
709
  * Get value type.
602
710
  */
603
- getValueType(cell) {
711
+ getValueDescription(cell) {
604
712
  (0, import_invariant3.invariant)(this._node, void 0, {
605
713
  F: __dxlog_file,
606
- L: 280,
714
+ L: 352,
607
715
  S: this,
608
716
  A: [
609
717
  "this._node",
@@ -620,7 +728,7 @@ var SheetModel = class extends import_context.Resource {
620
728
  setValue(cell, value) {
621
729
  (0, import_invariant3.invariant)(this._node, void 0, {
622
730
  F: __dxlog_file,
623
- L: 290,
731
+ L: 362,
624
732
  S: this,
625
733
  A: [
626
734
  "this._node",
@@ -628,15 +736,15 @@ var SheetModel = class extends import_context.Resource {
628
736
  ]
629
737
  });
630
738
  if (this._options.readonly) {
631
- throw new import_chunk_QNFMTK3X.ReadonlyException();
739
+ throw new import_chunk_O7XR4R7Y.ReadonlyException();
632
740
  }
633
741
  let refresh = false;
634
742
  if (cell.row >= this._sheet.rows.length) {
635
- (0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_QNFMTK3X.MAX_ROWS);
743
+ (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_O7XR4R7Y.MAX_ROWS);
636
744
  refresh = true;
637
745
  }
638
746
  if (cell.col >= this._sheet.columns.length) {
639
- (0, import_chunk_QNFMTK3X.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_QNFMTK3X.MAX_COLUMNS);
747
+ (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_O7XR4R7Y.MAX_COLUMNS);
640
748
  refresh = true;
641
749
  }
642
750
  if (refresh) {
@@ -648,14 +756,14 @@ var SheetModel = class extends import_context.Resource {
648
756
  col: cell.col
649
757
  }, [
650
758
  [
651
- (0, import_chunk_QNFMTK3X.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
759
+ (0, import_chunk_O7XR4R7Y.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
652
760
  ]
653
761
  ]);
654
- const idx = (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, cell);
762
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
655
763
  if (value === void 0 || value === null) {
656
764
  delete this._sheet.cells[idx];
657
765
  } else {
658
- if ((0, import_chunk_QNFMTK3X.isFormula)(value)) {
766
+ if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
659
767
  value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
660
768
  }
661
769
  this._sheet.cells[idx] = {
@@ -668,7 +776,7 @@ var SheetModel = class extends import_context.Resource {
668
776
  */
669
777
  setValues(values) {
670
778
  Object.entries(values).forEach(([key, { value }]) => {
671
- this.setValue((0, import_chunk_QNFMTK3X.addressFromA1Notation)(key), value);
779
+ this.setValue((0, import_chunk_O7XR4R7Y.addressFromA1Notation)(key), value);
672
780
  });
673
781
  }
674
782
  /**
@@ -715,9 +823,9 @@ var SheetModel = class extends import_context.Resource {
715
823
  * Map from A1 notation to indices.
716
824
  */
717
825
  mapFormulaRefsToIndices(formula) {
718
- (0, import_invariant3.invariant)((0, import_chunk_QNFMTK3X.isFormula)(formula), void 0, {
826
+ (0, import_invariant3.invariant)((0, import_chunk_O7XR4R7Y.isFormula)(formula), void 0, {
719
827
  F: __dxlog_file,
720
- L: 379,
828
+ L: 451,
721
829
  S: this,
722
830
  A: [
723
831
  "isFormula(formula)",
@@ -725,16 +833,16 @@ var SheetModel = class extends import_context.Resource {
725
833
  ]
726
834
  });
727
835
  return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
728
- return (0, import_chunk_QNFMTK3X.addressToIndex)(this._sheet, (0, import_chunk_QNFMTK3X.addressFromA1Notation)(match));
836
+ return (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, (0, import_chunk_O7XR4R7Y.addressFromA1Notation)(match));
729
837
  });
730
838
  }
731
839
  /**
732
840
  * Map from indices to A1 notation.
733
841
  */
734
842
  mapFormulaIndicesToRefs(formula) {
735
- (0, import_invariant3.invariant)((0, import_chunk_QNFMTK3X.isFormula)(formula), void 0, {
843
+ (0, import_invariant3.invariant)((0, import_chunk_O7XR4R7Y.isFormula)(formula), void 0, {
736
844
  F: __dxlog_file,
737
- L: 389,
845
+ L: 461,
738
846
  S: this,
739
847
  A: [
740
848
  "isFormula(formula)",
@@ -742,7 +850,7 @@ var SheetModel = class extends import_context.Resource {
742
850
  ]
743
851
  });
744
852
  return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
745
- return (0, import_chunk_QNFMTK3X.addressToA1Notation)((0, import_chunk_QNFMTK3X.addressFromIndex)(this._sheet, idx));
853
+ return (0, import_chunk_O7XR4R7Y.addressToA1Notation)((0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, idx));
746
854
  });
747
855
  }
748
856
  //
@@ -760,7 +868,7 @@ var SheetModel = class extends import_context.Resource {
760
868
  toDateTime(num) {
761
869
  (0, import_invariant3.invariant)(this._node, void 0, {
762
870
  F: __dxlog_file,
763
- L: 410,
871
+ L: 482,
764
872
  S: this,
765
873
  A: [
766
874
  "this._node",
@@ -772,7 +880,7 @@ var SheetModel = class extends import_context.Resource {
772
880
  toDate(num) {
773
881
  (0, import_invariant3.invariant)(this._node, void 0, {
774
882
  F: __dxlog_file,
775
- L: 415,
883
+ L: 487,
776
884
  S: this,
777
885
  A: [
778
886
  "this._node",
@@ -784,7 +892,7 @@ var SheetModel = class extends import_context.Resource {
784
892
  toTime(num) {
785
893
  (0, import_invariant3.invariant)(this._node, void 0, {
786
894
  F: __dxlog_file,
787
- L: 420,
895
+ L: 492,
788
896
  S: this,
789
897
  A: [
790
898
  "this._node",
@@ -887,26 +995,39 @@ var SheetProvider = ({ children, graph, sheet, readonly, onInfo }) => {
887
995
  onInfo
888
996
  }, children));
889
997
  };
890
- var RangeList = ({ sheet, onSelect, onDelete }) => {
891
- return /* @__PURE__ */ import_react8.default.createElement("div", {
892
- className: "flex flex-col"
893
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
998
+ var RangeList = ({ sheet }) => {
999
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
1000
+ const handleSelectRange = (range) => {
1001
+ };
1002
+ const handleDeleteRange = (0, import_react8.useCallback)((range) => {
1003
+ const index = sheet.ranges.findIndex((sheetRange) => sheetRange === range);
1004
+ sheet.ranges.splice(index, 1);
1005
+ }, [
1006
+ sheet
1007
+ ]);
1008
+ return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("h2", {
1009
+ className: "p-2 text-sm font-semibold"
1010
+ }, t("range list heading")), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
894
1011
  items: sheet.ranges,
895
- isItem: import_echo_schema2.S.is(import_chunk_V7E5JZBD.Range)
896
- }, ({ items }) => items.map((item, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
1012
+ isItem: import_echo_schema2.S.is(import_chunk_AWKOWDMI.Range)
1013
+ }, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
897
1014
  key: i,
898
- item,
1015
+ item: range,
899
1016
  classNames: [
900
1017
  "p-2",
901
1018
  import_react_ui_theme3.ghostHover
902
1019
  ]
903
1020
  }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemTitle, {
904
- onClick: () => onSelect?.(item)
905
- }, (0, import_chunk_QNFMTK3X.rangeToA1Notation)((0, import_chunk_QNFMTK3X.rangeFromIndex)(sheet, item.range))), onDelete && /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
906
- onClick: () => onDelete(item)
1021
+ onClick: () => handleSelectRange(range)
1022
+ }, t("range title", {
1023
+ position: (0, import_chunk_O7XR4R7Y.rangeToA1Notation)((0, import_chunk_O7XR4R7Y.rangeFromIndex)(sheet, range.range)),
1024
+ key: t(`range key ${range.key} label`),
1025
+ value: t(`range value ${range.value} label`)
1026
+ })), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
1027
+ onClick: () => handleDeleteRange(range)
907
1028
  })))));
908
1029
  };
909
- var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-L37HUFCF.cjs"));
1030
+ var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-MPFKXY26.cjs"));
910
1031
  var completeCellRangeToThreadCursor = (range) => {
911
1032
  return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
912
1033
  };
@@ -932,13 +1053,13 @@ var useUpdateFocusedCellOnThreadSelection = (grid) => {
932
1053
  const { model, setActiveRefs } = useSheetContext();
933
1054
  const handleScrollIntoView = (0, import_react6.useCallback)(({ action, data }) => {
934
1055
  switch (action) {
935
- case import_app_framework.LayoutAction.SCROLL_INTO_VIEW: {
1056
+ case import_app_framework2.LayoutAction.SCROLL_INTO_VIEW: {
936
1057
  if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo3.fullyQualifiedId)(model.sheet)) {
937
1058
  return;
938
1059
  }
939
1060
  setActiveRefs(data.thread);
940
1061
  const range = parseThreadAnchorAsCellRange(data.cursor);
941
- range && grid.current?.setFocus({
1062
+ range && grid?.setFocus({
942
1063
  ...range.to,
943
1064
  plane: "grid"
944
1065
  }, true);
@@ -948,11 +1069,11 @@ var useUpdateFocusedCellOnThreadSelection = (grid) => {
948
1069
  model.sheet,
949
1070
  setActiveRefs
950
1071
  ]);
951
- (0, import_app_framework.useIntentResolver)(import_chunk_QIFIGEKV.SHEET_PLUGIN, handleScrollIntoView);
1072
+ (0, import_app_framework2.useIntentResolver)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN, handleScrollIntoView);
952
1073
  };
953
1074
  var useSelectThreadOnCellFocus = () => {
954
1075
  const { model, cursor } = useSheetContext();
955
- const dispatch = (0, import_app_framework.useIntentDispatcher)();
1076
+ const dispatch = (0, import_app_framework2.useIntentDispatcher)();
956
1077
  const threads = (0, import_react6.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
957
1078
  // TODO(thure): Surely we can find a better dependency for this…
958
1079
  JSON.stringify(model.sheet.threads)
@@ -964,7 +1085,7 @@ var useSelectThreadOnCellFocus = () => {
964
1085
  const closestThread = threads?.find(({ anchor }) => {
965
1086
  if (anchor) {
966
1087
  const range = parseThreadAnchorAsCellRange(anchor);
967
- return range ? (0, import_chunk_QNFMTK3X.inRange)(range, cellAddress) : false;
1088
+ return range ? (0, import_chunk_O7XR4R7Y.inRange)(range, cellAddress) : false;
968
1089
  } else {
969
1090
  return false;
970
1091
  }
@@ -1037,16 +1158,25 @@ var projectCellProps = (model, col, row) => {
1037
1158
  row
1038
1159
  };
1039
1160
  const rawValue = model.getValue(address);
1040
- const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_QNFMTK3X.inRange)((0, import_chunk_QNFMTK3X.rangeFromIndex)(model.sheet, range), address));
1161
+ const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_O7XR4R7Y.inRange)((0, import_chunk_O7XR4R7Y.rangeFromIndex)(model.sheet, range), address));
1041
1162
  const threadRefs = model.sheet.threads?.filter((thread) => {
1042
1163
  const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
1043
- return thread && range ? (0, import_chunk_QNFMTK3X.inRange)(range, address) : false;
1164
+ return thread && range ? (0, import_chunk_O7XR4R7Y.inRange)(range, address) : false;
1044
1165
  }).map((thread) => (0, import_echo2.fullyQualifiedId)(thread)).join(" ");
1045
- const type = model.getValueType(address);
1046
- const classNames = ranges?.map(import_chunk_QNFMTK3X.cellClassNameForRange).reverse();
1166
+ const description = model.getValueDescription(address);
1167
+ const type = description?.type;
1168
+ const format = description?.format;
1169
+ const classNames = ranges?.map(import_chunk_O7XR4R7Y.cellClassNameForRange).reverse();
1047
1170
  return {
1048
- value: (0, import_react_ui_data.parseValue)(type, rawValue),
1049
- className: (0, import_react_ui_theme2.mx)((0, import_react_ui_data.cellClassesForFieldType)(type), threadRefs && import_react_ui_grid3.commentedClassName, classNames),
1171
+ value: (0, import_react_ui_data.parseValue)({
1172
+ type,
1173
+ format,
1174
+ value: rawValue
1175
+ }),
1176
+ className: (0, import_react_ui_theme2.mx)((0, import_react_ui_data.cellClassesForFieldType)({
1177
+ type,
1178
+ format
1179
+ }), threadRefs && import_react_ui_grid3.commentedClassName, classNames),
1050
1180
  dataRefs: threadRefs
1051
1181
  };
1052
1182
  };
@@ -1069,11 +1199,12 @@ var gridCellGetter = (model) => {
1069
1199
  };
1070
1200
  var rowLabelCell = (row) => ({
1071
1201
  value: (0, import_react_ui_grid3.rowToA1Notation)(row),
1072
- className: "text-end !pie-1",
1202
+ className: "text-end !pie-1 text-subdued",
1073
1203
  resizeHandle: "row"
1074
1204
  });
1075
1205
  var colLabelCell = (col) => ({
1076
1206
  value: (0, import_react_ui_grid3.colToA1Notation)(col),
1207
+ className: "text-subdued",
1077
1208
  resizeHandle: "col"
1078
1209
  });
1079
1210
  var cellGetter = (model) => {
@@ -1103,23 +1234,28 @@ var cellGetter = (model) => {
1103
1234
  }
1104
1235
  };
1105
1236
  };
1106
- var useSheetModelDxGridProps = (dxGridRef, model) => {
1237
+ var useSheetModelDxGridProps = (dxGrid, model) => {
1107
1238
  const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
1108
- const [rows, setRows] = (0, import_react5.useState)(createDxGridColumns(model));
1109
- (0, import_react5.useLayoutEffect)(() => {
1239
+ const [rows, setRows] = (0, import_react5.useState)(createDxGridRows(model));
1240
+ (0, import_react5.useEffect)(() => {
1110
1241
  const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
1111
1242
  "cells"
1112
1243
  ]);
1113
- if (dxGridRef.current) {
1114
- dxGridRef.current.getCells = cellGetter(model);
1244
+ if (dxGrid) {
1245
+ dxGrid.getCells = cellGetter(model);
1115
1246
  }
1116
1247
  const handleCellsUpdate = () => {
1117
- dxGridRef.current?.requestUpdate("initialCells");
1248
+ dxGrid?.requestUpdate("initialCells");
1118
1249
  };
1119
1250
  cellsAccessor.handle.addListener("change", handleCellsUpdate);
1120
- return () => cellsAccessor.handle.removeListener("change", handleCellsUpdate);
1251
+ const unsubscribe = model.graph.update.on(handleCellsUpdate);
1252
+ return () => {
1253
+ cellsAccessor.handle.removeListener("change", handleCellsUpdate);
1254
+ unsubscribe();
1255
+ };
1121
1256
  }, [
1122
- model
1257
+ model,
1258
+ dxGrid
1123
1259
  ]);
1124
1260
  (0, import_react5.useEffect)(() => {
1125
1261
  const columnMetaAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
@@ -1141,7 +1277,8 @@ var useSheetModelDxGridProps = (dxGridRef, model) => {
1141
1277
  rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
1142
1278
  };
1143
1279
  }, [
1144
- model
1280
+ model,
1281
+ dxGrid
1145
1282
  ]);
1146
1283
  return {
1147
1284
  columns,
@@ -1174,11 +1311,11 @@ var frozen = {
1174
1311
  };
1175
1312
  var sheetRowDefault = {
1176
1313
  frozenRowsStart: {
1177
- size: 32,
1314
+ size: import_react_ui_grid2.defaultSizeRow,
1178
1315
  readonly: true
1179
1316
  },
1180
1317
  grid: {
1181
- size: 32,
1318
+ size: import_react_ui_grid2.defaultSizeRow,
1182
1319
  resizeable: true
1183
1320
  }
1184
1321
  };
@@ -1193,52 +1330,60 @@ var sheetColDefault = {
1193
1330
  }
1194
1331
  };
1195
1332
  var GridSheet = () => {
1196
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_QIFIGEKV.SHEET_PLUGIN);
1197
- const { id, model, editing, setEditing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
1198
- const dxGrid = (0, import_react4.useRef)(null);
1333
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
1334
+ const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
1335
+ const [dxGrid, setDxGrid] = (0, import_react4.useState)(null);
1336
+ const [extraplanarFocus, setExtraplanarFocus] = (0, import_react4.useState)(null);
1337
+ const dispatch = (0, import_app_framework.useIntentDispatcher)();
1199
1338
  const rangeController = (0, import_react4.useRef)();
1200
1339
  const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
1201
1340
  const handleFocus = (0, import_react4.useCallback)((event) => {
1202
1341
  if (!editing) {
1203
1342
  const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1204
- if (cell && cell.plane === "grid") {
1205
- setCursor({
1206
- col: cell.col,
1207
- row: cell.row
1208
- });
1343
+ if (cell) {
1344
+ if (cell.plane === "grid") {
1345
+ setCursor({
1346
+ col: cell.col,
1347
+ row: cell.row
1348
+ });
1349
+ setExtraplanarFocus(null);
1350
+ } else {
1351
+ setExtraplanarFocus(cell);
1352
+ }
1353
+ } else {
1354
+ setExtraplanarFocus(null);
1209
1355
  }
1210
1356
  }
1211
1357
  }, [
1212
1358
  editing
1213
1359
  ]);
1214
- const handleClose = (0, import_react4.useCallback)((value, { key, shift }) => {
1215
- if (value !== void 0) {
1216
- model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
1360
+ const handleClose = (0, import_react4.useCallback)((_value, event) => {
1361
+ if (event) {
1362
+ const { key, shift } = event;
1363
+ const axis = [
1364
+ "Enter",
1365
+ "ArrowUp",
1366
+ "ArrowDown"
1367
+ ].includes(key) ? "row" : [
1368
+ "Tab",
1369
+ "ArrowLeft",
1370
+ "ArrowRight"
1371
+ ].includes(key) ? "col" : void 0;
1372
+ const delta = key.startsWith("Arrow") ? [
1373
+ "ArrowUp",
1374
+ "ArrowLeft"
1375
+ ].includes(key) ? -1 : 1 : shift ? -1 : 1;
1376
+ dxGrid?.refocus(axis, delta);
1217
1377
  }
1218
- setEditing(null);
1219
- const axis = [
1220
- "Enter",
1221
- "ArrowUp",
1222
- "ArrowDown"
1223
- ].includes(key) ? "row" : [
1224
- "Tab",
1225
- "ArrowLeft",
1226
- "ArrowRight"
1227
- ].includes(key) ? "col" : void 0;
1228
- const delta = key.startsWith("Arrow") ? [
1229
- "ArrowUp",
1230
- "ArrowLeft"
1231
- ].includes(key) ? -1 : 1 : shift ? -1 : 1;
1232
- dxGrid.current?.refocus(axis, delta);
1233
1378
  }, [
1234
1379
  model,
1235
- editing
1380
+ editing,
1381
+ dxGrid
1236
1382
  ]);
1237
1383
  const handleBlur = (0, import_react4.useCallback)((value) => {
1238
1384
  if (value !== void 0) {
1239
1385
  model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
1240
1386
  }
1241
- setEditing(null);
1242
1387
  }, [
1243
1388
  model,
1244
1389
  editing
@@ -1270,7 +1415,7 @@ var GridSheet = () => {
1270
1415
  };
1271
1416
  }
1272
1417
  if (editing) {
1273
- rangeController.current?.setRange((0, import_chunk_QNFMTK3X.rangeToA1Notation)(range));
1418
+ rangeController.current?.setRange((0, import_chunk_O7XR4R7Y.rangeToA1Notation)(range));
1274
1419
  } else {
1275
1420
  setRange(range.to ? range : void 0);
1276
1421
  }
@@ -1284,12 +1429,63 @@ var GridSheet = () => {
1284
1429
  }, [
1285
1430
  hasAttention
1286
1431
  ]);
1432
+ const selectEntireAxis = (0, import_react4.useCallback)((pos) => {
1433
+ switch (pos.plane) {
1434
+ case "frozenRowsStart":
1435
+ return dxGrid?.setSelection({
1436
+ start: {
1437
+ col: pos.col,
1438
+ row: 0,
1439
+ plane: "grid"
1440
+ },
1441
+ end: {
1442
+ col: pos.col,
1443
+ row: model.sheet.rows.length - 1,
1444
+ plane: "grid"
1445
+ }
1446
+ });
1447
+ case "frozenColsStart":
1448
+ return dxGrid?.setSelection({
1449
+ start: {
1450
+ row: pos.row,
1451
+ col: 0,
1452
+ plane: "grid"
1453
+ },
1454
+ end: {
1455
+ row: pos.row,
1456
+ col: model.sheet.columns.length - 1,
1457
+ plane: "grid"
1458
+ }
1459
+ });
1460
+ }
1461
+ }, [
1462
+ dxGrid,
1463
+ model.sheet
1464
+ ]);
1465
+ const handleClick = (0, import_react4.useCallback)((event) => {
1466
+ const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1467
+ if (cell) {
1468
+ selectEntireAxis(cell);
1469
+ }
1470
+ }, [
1471
+ selectEntireAxis
1472
+ ]);
1287
1473
  const handleKeyDown = (0, import_react4.useCallback)((event) => {
1288
1474
  switch (event.key) {
1289
1475
  case "Backspace":
1290
1476
  case "Delete":
1291
1477
  event.preventDefault();
1292
1478
  return cursorFallbackRange && model.clear(cursorFallbackRange);
1479
+ case "Enter":
1480
+ case "Space":
1481
+ if (dxGrid && extraplanarFocus) {
1482
+ switch (extraplanarFocus.plane) {
1483
+ case "frozenRowsStart":
1484
+ case "frozenColsStart":
1485
+ event.preventDefault();
1486
+ return selectEntireAxis(extraplanarFocus);
1487
+ }
1488
+ }
1293
1489
  }
1294
1490
  if (event.metaKey || event.ctrlKey) {
1295
1491
  switch (event.key) {
@@ -1317,7 +1513,9 @@ var GridSheet = () => {
1317
1513
  }, [
1318
1514
  cursorFallbackRange,
1319
1515
  model,
1320
- cursor
1516
+ cursor,
1517
+ extraplanarFocus,
1518
+ selectEntireAxis
1321
1519
  ]);
1322
1520
  const contextMenuAnchorRef = (0, import_react4.useRef)(null);
1323
1521
  const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
@@ -1332,16 +1530,32 @@ var GridSheet = () => {
1332
1530
  }, []);
1333
1531
  const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
1334
1532
  switch (operation) {
1335
- case "add-before":
1336
- case "add-after":
1337
- model[contextMenuAxis === "col" ? "insertColumns" : "insertRows"](contextMenuOpen[contextMenuAxis] + (operation === "add-before" ? 0 : 1), 1);
1533
+ case "insert-before":
1534
+ case "insert-after":
1535
+ return dispatch({
1536
+ action: import_chunk_AWKOWDMI.SheetAction.INSERT_AXIS,
1537
+ data: {
1538
+ model,
1539
+ axis: contextMenuAxis,
1540
+ index: contextMenuOpen[contextMenuAxis] + (operation === "insert-before" ? 0 : 1)
1541
+ }
1542
+ });
1338
1543
  break;
1339
- case "remove":
1544
+ case "drop":
1545
+ return dispatch({
1546
+ action: import_chunk_AWKOWDMI.SheetAction.DROP_AXIS,
1547
+ data: {
1548
+ model,
1549
+ axis: contextMenuAxis,
1550
+ axisIndex: model.sheet[contextMenuAxis === "row" ? "rows" : "columns"][contextMenuOpen[contextMenuAxis]]
1551
+ }
1552
+ });
1340
1553
  }
1341
1554
  }, [
1342
1555
  contextMenuAxis,
1343
1556
  contextMenuOpen,
1344
- model
1557
+ model,
1558
+ dispatch
1345
1559
  ]);
1346
1560
  const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
1347
1561
  const extension = (0, import_react4.useMemo)(() => [
@@ -1357,8 +1571,8 @@ var GridSheet = () => {
1357
1571
  rangeExtension({
1358
1572
  onInit: (fn) => rangeController.current = fn,
1359
1573
  onStateChange: (state) => {
1360
- if (dxGrid.current) {
1361
- dxGrid.current.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
1574
+ if (dxGrid) {
1575
+ dxGrid.mode = typeof state.activeRange === "undefined" ? "edit" : "edit-select";
1362
1576
  }
1363
1577
  }
1364
1578
  })
@@ -1381,8 +1595,8 @@ var GridSheet = () => {
1381
1595
  onBlur: handleBlur
1382
1596
  }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
1383
1597
  initialCells,
1384
- limitColumns: import_chunk_QNFMTK3X.DEFAULT_COLUMNS,
1385
- limitRows: import_chunk_QNFMTK3X.DEFAULT_ROWS,
1598
+ limitColumns: import_chunk_O7XR4R7Y.DEFAULT_COLUMNS,
1599
+ limitRows: import_chunk_O7XR4R7Y.DEFAULT_ROWS,
1386
1600
  columns,
1387
1601
  rows,
1388
1602
  onAxisResize: handleAxisResize,
@@ -1394,10 +1608,11 @@ var GridSheet = () => {
1394
1608
  onWheelCapture: handleWheel,
1395
1609
  onKeyDown: handleKeyDown,
1396
1610
  onContextMenu: handleContextMenu,
1397
- overscroll: "inline",
1398
- className: "[--dx-grid-base:var(--surface-bg)]",
1611
+ onClick: handleClick,
1612
+ overscroll: "trap",
1613
+ className: "[--dx-grid-base:var(--surface-bg)] [&_.dx-grid]:border-bs [&_.dx-grid]:border-separator",
1399
1614
  activeRefs,
1400
- ref: dxGrid
1615
+ ref: setDxGrid
1401
1616
  }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
1402
1617
  modal: false,
1403
1618
  open: !!contextMenuOpen,
@@ -1409,18 +1624,17 @@ var GridSheet = () => {
1409
1624
  sideOffset: 4,
1410
1625
  collisionPadding: 8
1411
1626
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1412
- onClick: () => handleAxisMenuAction("add-before")
1627
+ onClick: () => handleAxisMenuAction("insert-before")
1413
1628
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1414
1629
  size: 5,
1415
1630
  icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
1416
1631
  }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1417
- onClick: () => handleAxisMenuAction("add-after")
1632
+ onClick: () => handleAxisMenuAction("insert-after")
1418
1633
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1419
1634
  size: 5,
1420
1635
  icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
1421
1636
  }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1422
- disabled: true,
1423
- onClick: () => handleAxisMenuAction("remove")
1637
+ onClick: () => handleAxisMenuAction("drop")
1424
1638
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1425
1639
  size: 5,
1426
1640
  icon: "ph--backspace--regular"
@@ -1438,4 +1652,4 @@ var GridSheet = () => {
1438
1652
  useComputeGraph,
1439
1653
  useSheetContext
1440
1654
  });
1441
- //# sourceMappingURL=chunk-7AWAC3R3.cjs.map
1655
+ //# sourceMappingURL=chunk-OO24XJBV.cjs.map