@dxos/plugin-sheet 0.6.14-main.8b352a0 → 0.6.14-staging.3e2eaca

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 (109) hide show
  1. package/dist/lib/browser/{SheetContainer-R65IDJHN.mjs → SheetContainer-P3NF5KEI.mjs} +49 -43
  2. package/dist/lib/browser/SheetContainer-P3NF5KEI.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-I2DKJ72A.mjs → chunk-4LKIURJA.mjs} +283 -84
  4. package/dist/lib/browser/chunk-4LKIURJA.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-5KVQ5IPW.mjs → chunk-BVUN7SHF.mjs} +4 -2
  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-KCYJSOFB.mjs → chunk-VMSX6Z4X.mjs} +51 -17
  10. package/dist/lib/browser/chunk-VMSX6Z4X.mjs.map +7 -0
  11. package/dist/lib/browser/{compute-graph-SJT67236.mjs → compute-graph-GGWUX644.mjs} +4 -4
  12. package/dist/lib/browser/index.mjs +38 -10
  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-6BO4C5X2.cjs → SheetContainer-MPFKXY26.cjs} +67 -62
  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-2XJ5I4UF.cjs → chunk-AWKOWDMI.cjs} +8 -6
  22. package/dist/lib/node/chunk-AWKOWDMI.cjs.map +7 -0
  23. package/dist/lib/node/{chunk-JF5XNTF3.cjs → chunk-O7XR4R7Y.cjs} +61 -26
  24. package/dist/lib/node/chunk-O7XR4R7Y.cjs.map +7 -0
  25. package/dist/lib/node/{chunk-DEPJHN47.cjs → chunk-OO24XJBV.cjs} +318 -120
  26. package/dist/lib/node/chunk-OO24XJBV.cjs.map +7 -0
  27. package/dist/lib/node/{compute-graph-AQBDL7HO.cjs → compute-graph-KGWA2QLE.cjs} +21 -21
  28. package/dist/lib/node/{compute-graph-AQBDL7HO.cjs.map → compute-graph-KGWA2QLE.cjs.map} +2 -2
  29. package/dist/lib/node/index.cjs +66 -38
  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-MJXC5E3P.mjs → SheetContainer-22IOAW3B.mjs} +49 -43
  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-25V7WY4R.mjs → chunk-BW36PM2Y.mjs} +283 -84
  41. package/dist/lib/node-esm/chunk-BW36PM2Y.mjs.map +7 -0
  42. package/dist/lib/node-esm/{chunk-XBEHKYO7.mjs → chunk-CR4K75EL.mjs} +51 -17
  43. package/dist/lib/node-esm/chunk-CR4K75EL.mjs.map +7 -0
  44. package/dist/lib/node-esm/{chunk-5TXLF6PL.mjs → chunk-UIBWRHW7.mjs} +4 -2
  45. package/dist/lib/node-esm/chunk-UIBWRHW7.mjs.map +7 -0
  46. package/dist/lib/node-esm/{compute-graph-FRCKXEYK.mjs → compute-graph-2SCZT7N5.mjs} +4 -4
  47. package/dist/lib/node-esm/index.mjs +38 -10
  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 +1 -0
  56. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  57. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  58. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -2
  60. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  61. package/dist/types/src/components/index.d.ts.map +1 -1
  62. package/dist/types/src/compute-graph/compute-graph.d.ts +2 -2
  63. package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -1
  64. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -1
  65. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -1
  66. package/dist/types/src/defs/sheet-range-types.d.ts +1 -1
  67. package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
  68. package/dist/types/src/defs/util.d.ts +1 -1
  69. package/dist/types/src/defs/util.d.ts.map +1 -1
  70. package/dist/types/src/meta.d.ts +1 -0
  71. package/dist/types/src/meta.d.ts.map +1 -1
  72. package/dist/types/src/model/sheet-model.d.ts +12 -5
  73. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  74. package/dist/types/src/translations.d.ts +10 -5
  75. package/dist/types/src/translations.d.ts.map +1 -1
  76. package/dist/types/src/types.d.ts +33 -3
  77. package/dist/types/src/types.d.ts.map +1 -1
  78. package/package.json +37 -36
  79. package/src/SheetPlugin.tsx +20 -0
  80. package/src/components/FunctionEditor/FunctionEditor.tsx +1 -5
  81. package/src/components/GridSheet/GridSheet.tsx +102 -38
  82. package/src/components/GridSheet/util.ts +19 -9
  83. package/src/components/SheetContainer/SheetContainer.stories.tsx +2 -0
  84. package/src/components/SheetContainer/SheetContainer.tsx +9 -8
  85. package/src/components/Toolbar/Toolbar.tsx +62 -53
  86. package/src/compute-graph/compute-graph.ts +22 -7
  87. package/src/compute-graph/functions/async-function.ts +1 -0
  88. package/src/compute-graph/functions/edge-function.ts +5 -3
  89. package/src/defs/sheet-range-types.ts +4 -2
  90. package/src/defs/util.ts +1 -0
  91. package/src/meta.ts +1 -0
  92. package/src/model/sheet-model.test.ts +5 -3
  93. package/src/model/sheet-model.ts +93 -21
  94. package/src/translations.ts +10 -5
  95. package/src/types.ts +20 -0
  96. package/dist/lib/browser/SheetContainer-R65IDJHN.mjs.map +0 -7
  97. package/dist/lib/browser/chunk-5KVQ5IPW.mjs.map +0 -7
  98. package/dist/lib/browser/chunk-I2DKJ72A.mjs.map +0 -7
  99. package/dist/lib/browser/chunk-KCYJSOFB.mjs.map +0 -7
  100. package/dist/lib/node/SheetContainer-6BO4C5X2.cjs.map +0 -7
  101. package/dist/lib/node/chunk-2XJ5I4UF.cjs.map +0 -7
  102. package/dist/lib/node/chunk-DEPJHN47.cjs.map +0 -7
  103. package/dist/lib/node/chunk-JF5XNTF3.cjs.map +0 -7
  104. package/dist/lib/node-esm/SheetContainer-MJXC5E3P.mjs.map +0 -7
  105. package/dist/lib/node-esm/chunk-25V7WY4R.mjs.map +0 -7
  106. package/dist/lib/node-esm/chunk-5TXLF6PL.mjs.map +0 -7
  107. package/dist/lib/node-esm/chunk-XBEHKYO7.mjs.map +0 -7
  108. /package/dist/lib/browser/{compute-graph-SJT67236.mjs.map → compute-graph-GGWUX644.mjs.map} +0 -0
  109. /package/dist/lib/node-esm/{compute-graph-FRCKXEYK.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_DEPJHN47_exports = {};
30
- __export(chunk_DEPJHN47_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_DEPJHN47_exports, {
38
38
  useComputeGraph: () => useComputeGraph,
39
39
  useSheetContext: () => useSheetContext
40
40
  });
41
- module.exports = __toCommonJS(chunk_DEPJHN47_exports);
42
- var import_chunk_JF5XNTF3 = require("./chunk-JF5XNTF3.cjs");
43
- var import_chunk_2XJ5I4UF = require("./chunk-2XJ5I4UF.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,7 +81,7 @@ 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");
@@ -293,7 +293,7 @@ var rangeExtension = ({ onInit, onStateChange }) => {
293
293
  });
294
294
  if (!activeRange && view2.state.doc.toString()[0] === "=") {
295
295
  const str = view2.state.doc.sliceString(1);
296
- if (import_chunk_JF5XNTF3.RANGE_NOTATION.test(str)) {
296
+ if (import_chunk_O7XR4R7Y.RANGE_NOTATION.test(str)) {
297
297
  activeRange = {
298
298
  from: 1,
299
299
  to: str.length + 1
@@ -319,13 +319,32 @@ var visitTree = (node, callback) => {
319
319
  };
320
320
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/sheet-model.ts";
321
321
  var typeMap = {
322
- BOOLEAN: import_schema.FieldValueType.Boolean,
323
- NUMBER_RAW: import_schema.FieldValueType.Number,
324
- NUMBER_PERCENT: import_schema.FieldValueType.Percent,
325
- NUMBER_CURRENCY: import_schema.FieldValueType.Currency,
326
- NUMBER_DATETIME: import_schema.FieldValueType.DateTime,
327
- NUMBER_DATE: import_schema.FieldValueType.Date,
328
- 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
+ }
329
348
  };
330
349
  var getTopLeft = (range) => {
331
350
  const to = range.to ?? range.from;
@@ -375,12 +394,17 @@ var SheetModel = class extends import_context.Resource {
375
394
  id: this.id
376
395
  }, {
377
396
  F: __dxlog_file,
378
- L: 111,
397
+ L: 113,
379
398
  S: this,
380
399
  C: (f, a) => f(...a)
381
400
  });
382
- (0, import_chunk_JF5XNTF3.initialize)(this._sheet);
383
- this._node = this._graph.getOrCreateNode((0, import_chunk_JF5XNTF3.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)({
384
408
  type: (0, import_echo_schema.getTypename)(this._sheet),
385
409
  id: this._sheet.id
386
410
  }));
@@ -397,7 +421,7 @@ var SheetModel = class extends import_context.Resource {
397
421
  reset() {
398
422
  (0, import_invariant3.invariant)(this._node, void 0, {
399
423
  F: __dxlog_file,
400
- L: 131,
424
+ L: 139,
401
425
  S: this,
402
426
  A: [
403
427
  "this._node",
@@ -408,16 +432,21 @@ var SheetModel = class extends import_context.Resource {
408
432
  Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
409
433
  (0, import_invariant3.invariant)(this._node, void 0, {
410
434
  F: __dxlog_file,
411
- L: 134,
435
+ L: 142,
412
436
  S: this,
413
437
  A: [
414
438
  "this._node",
415
439
  ""
416
440
  ]
417
441
  });
418
- const { col, row } = (0, import_chunk_JF5XNTF3.addressFromIndex)(this._sheet, key);
419
- if ((0, import_chunk_JF5XNTF3.isFormula)(value)) {
420
- 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
+ }
421
450
  }
422
451
  this._node.graph.hf.setCellContents({
423
452
  sheet: this._node.sheetId,
@@ -437,11 +466,79 @@ var SheetModel = class extends import_context.Resource {
437
466
  this._node?.graph.hf.rebuildAndRecalculate();
438
467
  }
439
468
  insertRows(i, n = 1) {
440
- (0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.rows, i, n, import_chunk_JF5XNTF3.MAX_ROWS);
469
+ const idx = (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.rows, i, n, import_chunk_O7XR4R7Y.MAX_ROWS);
441
470
  this.reset();
471
+ return idx;
442
472
  }
443
473
  insertColumns(i, n = 1) {
444
- (0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.columns, i, n, import_chunk_JF5XNTF3.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
+ }
445
542
  this.reset();
446
543
  }
447
544
  //
@@ -454,7 +551,7 @@ var SheetModel = class extends import_context.Resource {
454
551
  clear(range) {
455
552
  (0, import_invariant3.invariant)(this._node, void 0, {
456
553
  F: __dxlog_file,
457
- L: 176,
554
+ L: 245,
458
555
  S: this,
459
556
  A: [
460
557
  "this._node",
@@ -465,14 +562,14 @@ var SheetModel = class extends import_context.Resource {
465
562
  const values = this._iterRange(range, () => null);
466
563
  this._node.graph.hf.setCellContents(toSimpleCellAddress(this._node.sheetId, topLeft), values);
467
564
  this._iterRange(range, (cell) => {
468
- const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
565
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
469
566
  delete this._sheet.cells[idx];
470
567
  });
471
568
  }
472
569
  cut(range) {
473
570
  (0, import_invariant3.invariant)(this._node, void 0, {
474
571
  F: __dxlog_file,
475
- L: 187,
572
+ L: 256,
476
573
  S: this,
477
574
  A: [
478
575
  "this._node",
@@ -481,14 +578,14 @@ var SheetModel = class extends import_context.Resource {
481
578
  });
482
579
  this._node.graph.hf.cut(toModelRange(this._node.sheetId, range));
483
580
  this._iterRange(range, (cell) => {
484
- const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
581
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
485
582
  delete this._sheet.cells[idx];
486
583
  });
487
584
  }
488
585
  copy(range) {
489
586
  (0, import_invariant3.invariant)(this._node, void 0, {
490
587
  F: __dxlog_file,
491
- L: 196,
588
+ L: 265,
492
589
  S: this,
493
590
  A: [
494
591
  "this._node",
@@ -500,7 +597,7 @@ var SheetModel = class extends import_context.Resource {
500
597
  paste(cell) {
501
598
  (0, import_invariant3.invariant)(this._node, void 0, {
502
599
  F: __dxlog_file,
503
- L: 201,
600
+ L: 270,
504
601
  S: this,
505
602
  A: [
506
603
  "this._node",
@@ -512,7 +609,7 @@ var SheetModel = class extends import_context.Resource {
512
609
  for (const change of changes) {
513
610
  if (change instanceof import_hyperformula.ExportedCellChange) {
514
611
  const { address, newValue } = change;
515
- const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, {
612
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, {
516
613
  row: address.row,
517
614
  col: address.col
518
615
  });
@@ -527,7 +624,7 @@ var SheetModel = class extends import_context.Resource {
527
624
  undo() {
528
625
  (0, import_invariant3.invariant)(this._node, void 0, {
529
626
  F: __dxlog_file,
530
- L: 216,
627
+ L: 285,
531
628
  S: this,
532
629
  A: [
533
630
  "this._node",
@@ -541,7 +638,7 @@ var SheetModel = class extends import_context.Resource {
541
638
  redo() {
542
639
  (0, import_invariant3.invariant)(this._node, void 0, {
543
640
  F: __dxlog_file,
544
- L: 224,
641
+ L: 293,
545
642
  S: this,
546
643
  A: [
547
644
  "this._node",
@@ -556,7 +653,7 @@ var SheetModel = class extends import_context.Resource {
556
653
  * Get value from sheet.
557
654
  */
558
655
  getCellValue(cell) {
559
- const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
656
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
560
657
  return this._sheet.cells[idx]?.value ?? null;
561
658
  }
562
659
  /**
@@ -567,7 +664,7 @@ var SheetModel = class extends import_context.Resource {
567
664
  if (value == null) {
568
665
  return void 0;
569
666
  }
570
- if ((0, import_chunk_JF5XNTF3.isFormula)(value)) {
667
+ if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
571
668
  return this._graph.mapFunctionBindingFromId(this.mapFormulaIndicesToRefs(value));
572
669
  } else {
573
670
  return String(value);
@@ -585,15 +682,25 @@ var SheetModel = class extends import_context.Resource {
585
682
  getValue(cell) {
586
683
  (0, import_invariant3.invariant)(this._node, void 0, {
587
684
  F: __dxlog_file,
588
- L: 267,
685
+ L: 336,
589
686
  S: this,
590
687
  A: [
591
688
  "this._node",
592
689
  ""
593
690
  ]
594
691
  });
595
- 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);
596
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
+ });
597
704
  return value.toString();
598
705
  }
599
706
  return value;
@@ -601,10 +708,10 @@ var SheetModel = class extends import_context.Resource {
601
708
  /**
602
709
  * Get value type.
603
710
  */
604
- getValueType(cell) {
711
+ getValueDescription(cell) {
605
712
  (0, import_invariant3.invariant)(this._node, void 0, {
606
713
  F: __dxlog_file,
607
- L: 280,
714
+ L: 352,
608
715
  S: this,
609
716
  A: [
610
717
  "this._node",
@@ -621,7 +728,7 @@ var SheetModel = class extends import_context.Resource {
621
728
  setValue(cell, value) {
622
729
  (0, import_invariant3.invariant)(this._node, void 0, {
623
730
  F: __dxlog_file,
624
- L: 290,
731
+ L: 362,
625
732
  S: this,
626
733
  A: [
627
734
  "this._node",
@@ -629,15 +736,15 @@ var SheetModel = class extends import_context.Resource {
629
736
  ]
630
737
  });
631
738
  if (this._options.readonly) {
632
- throw new import_chunk_JF5XNTF3.ReadonlyException();
739
+ throw new import_chunk_O7XR4R7Y.ReadonlyException();
633
740
  }
634
741
  let refresh = false;
635
742
  if (cell.row >= this._sheet.rows.length) {
636
- (0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_JF5XNTF3.MAX_ROWS);
743
+ (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.rows, cell.row, 1, import_chunk_O7XR4R7Y.MAX_ROWS);
637
744
  refresh = true;
638
745
  }
639
746
  if (cell.col >= this._sheet.columns.length) {
640
- (0, import_chunk_JF5XNTF3.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_JF5XNTF3.MAX_COLUMNS);
747
+ (0, import_chunk_O7XR4R7Y.insertIndices)(this._sheet.columns, cell.col, 1, import_chunk_O7XR4R7Y.MAX_COLUMNS);
641
748
  refresh = true;
642
749
  }
643
750
  if (refresh) {
@@ -649,14 +756,14 @@ var SheetModel = class extends import_context.Resource {
649
756
  col: cell.col
650
757
  }, [
651
758
  [
652
- (0, import_chunk_JF5XNTF3.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
759
+ (0, import_chunk_O7XR4R7Y.isFormula)(value) ? this._graph.mapFormulaToNative(value) : value
653
760
  ]
654
761
  ]);
655
- const idx = (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, cell);
762
+ const idx = (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, cell);
656
763
  if (value === void 0 || value === null) {
657
764
  delete this._sheet.cells[idx];
658
765
  } else {
659
- if ((0, import_chunk_JF5XNTF3.isFormula)(value)) {
766
+ if ((0, import_chunk_O7XR4R7Y.isFormula)(value)) {
660
767
  value = this._graph.mapFunctionBindingToId(this.mapFormulaRefsToIndices(value));
661
768
  }
662
769
  this._sheet.cells[idx] = {
@@ -669,7 +776,7 @@ var SheetModel = class extends import_context.Resource {
669
776
  */
670
777
  setValues(values) {
671
778
  Object.entries(values).forEach(([key, { value }]) => {
672
- this.setValue((0, import_chunk_JF5XNTF3.addressFromA1Notation)(key), value);
779
+ this.setValue((0, import_chunk_O7XR4R7Y.addressFromA1Notation)(key), value);
673
780
  });
674
781
  }
675
782
  /**
@@ -716,9 +823,9 @@ var SheetModel = class extends import_context.Resource {
716
823
  * Map from A1 notation to indices.
717
824
  */
718
825
  mapFormulaRefsToIndices(formula) {
719
- (0, import_invariant3.invariant)((0, import_chunk_JF5XNTF3.isFormula)(formula), void 0, {
826
+ (0, import_invariant3.invariant)((0, import_chunk_O7XR4R7Y.isFormula)(formula), void 0, {
720
827
  F: __dxlog_file,
721
- L: 379,
828
+ L: 451,
722
829
  S: this,
723
830
  A: [
724
831
  "isFormula(formula)",
@@ -726,16 +833,16 @@ var SheetModel = class extends import_context.Resource {
726
833
  ]
727
834
  });
728
835
  return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
729
- return (0, import_chunk_JF5XNTF3.addressToIndex)(this._sheet, (0, import_chunk_JF5XNTF3.addressFromA1Notation)(match));
836
+ return (0, import_chunk_O7XR4R7Y.addressToIndex)(this._sheet, (0, import_chunk_O7XR4R7Y.addressFromA1Notation)(match));
730
837
  });
731
838
  }
732
839
  /**
733
840
  * Map from indices to A1 notation.
734
841
  */
735
842
  mapFormulaIndicesToRefs(formula) {
736
- (0, import_invariant3.invariant)((0, import_chunk_JF5XNTF3.isFormula)(formula), void 0, {
843
+ (0, import_invariant3.invariant)((0, import_chunk_O7XR4R7Y.isFormula)(formula), void 0, {
737
844
  F: __dxlog_file,
738
- L: 389,
845
+ L: 461,
739
846
  S: this,
740
847
  A: [
741
848
  "isFormula(formula)",
@@ -743,7 +850,7 @@ var SheetModel = class extends import_context.Resource {
743
850
  ]
744
851
  });
745
852
  return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
746
- return (0, import_chunk_JF5XNTF3.addressToA1Notation)((0, import_chunk_JF5XNTF3.addressFromIndex)(this._sheet, idx));
853
+ return (0, import_chunk_O7XR4R7Y.addressToA1Notation)((0, import_chunk_O7XR4R7Y.addressFromIndex)(this._sheet, idx));
747
854
  });
748
855
  }
749
856
  //
@@ -761,7 +868,7 @@ var SheetModel = class extends import_context.Resource {
761
868
  toDateTime(num) {
762
869
  (0, import_invariant3.invariant)(this._node, void 0, {
763
870
  F: __dxlog_file,
764
- L: 410,
871
+ L: 482,
765
872
  S: this,
766
873
  A: [
767
874
  "this._node",
@@ -773,7 +880,7 @@ var SheetModel = class extends import_context.Resource {
773
880
  toDate(num) {
774
881
  (0, import_invariant3.invariant)(this._node, void 0, {
775
882
  F: __dxlog_file,
776
- L: 415,
883
+ L: 487,
777
884
  S: this,
778
885
  A: [
779
886
  "this._node",
@@ -785,7 +892,7 @@ var SheetModel = class extends import_context.Resource {
785
892
  toTime(num) {
786
893
  (0, import_invariant3.invariant)(this._node, void 0, {
787
894
  F: __dxlog_file,
788
- L: 420,
895
+ L: 492,
789
896
  S: this,
790
897
  A: [
791
898
  "this._node",
@@ -889,7 +996,7 @@ var SheetProvider = ({ children, graph, sheet, readonly, onInfo }) => {
889
996
  }, children));
890
997
  };
891
998
  var RangeList = ({ sheet }) => {
892
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_QIFIGEKV.SHEET_PLUGIN);
999
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
893
1000
  const handleSelectRange = (range) => {
894
1001
  };
895
1002
  const handleDeleteRange = (0, import_react8.useCallback)((range) => {
@@ -902,7 +1009,7 @@ var RangeList = ({ sheet }) => {
902
1009
  className: "p-2 text-sm font-semibold"
903
1010
  }, t("range list heading")), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Root, {
904
1011
  items: sheet.ranges,
905
- isItem: import_echo_schema2.S.is(import_chunk_2XJ5I4UF.Range)
1012
+ isItem: import_echo_schema2.S.is(import_chunk_AWKOWDMI.Range)
906
1013
  }, ({ items: ranges }) => ranges.map((range, i) => /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.Item, {
907
1014
  key: i,
908
1015
  item: range,
@@ -913,14 +1020,14 @@ var RangeList = ({ sheet }) => {
913
1020
  }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemTitle, {
914
1021
  onClick: () => handleSelectRange(range)
915
1022
  }, t("range title", {
916
- position: (0, import_chunk_JF5XNTF3.rangeToA1Notation)((0, import_chunk_JF5XNTF3.rangeFromIndex)(sheet, range.range)),
1023
+ position: (0, import_chunk_O7XR4R7Y.rangeToA1Notation)((0, import_chunk_O7XR4R7Y.rangeFromIndex)(sheet, range.range)),
917
1024
  key: t(`range key ${range.key} label`),
918
1025
  value: t(`range value ${range.value} label`)
919
1026
  })), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_list.List.ItemDeleteButton, {
920
1027
  onClick: () => handleDeleteRange(range)
921
1028
  })))));
922
1029
  };
923
- var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-6BO4C5X2.cjs"));
1030
+ var SheetContainer = (0, import_react7.lazy)(() => import("./SheetContainer-MPFKXY26.cjs"));
924
1031
  var completeCellRangeToThreadCursor = (range) => {
925
1032
  return `${range.from.col},${range.from.row},${range.to.col},${range.to.row}`;
926
1033
  };
@@ -946,7 +1053,7 @@ var useUpdateFocusedCellOnThreadSelection = (grid) => {
946
1053
  const { model, setActiveRefs } = useSheetContext();
947
1054
  const handleScrollIntoView = (0, import_react6.useCallback)(({ action, data }) => {
948
1055
  switch (action) {
949
- case import_app_framework.LayoutAction.SCROLL_INTO_VIEW: {
1056
+ case import_app_framework2.LayoutAction.SCROLL_INTO_VIEW: {
950
1057
  if (!data?.id || data?.cursor === void 0 || data?.id !== (0, import_echo3.fullyQualifiedId)(model.sheet)) {
951
1058
  return;
952
1059
  }
@@ -962,11 +1069,11 @@ var useUpdateFocusedCellOnThreadSelection = (grid) => {
962
1069
  model.sheet,
963
1070
  setActiveRefs
964
1071
  ]);
965
- (0, import_app_framework.useIntentResolver)(import_chunk_QIFIGEKV.SHEET_PLUGIN, handleScrollIntoView);
1072
+ (0, import_app_framework2.useIntentResolver)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN, handleScrollIntoView);
966
1073
  };
967
1074
  var useSelectThreadOnCellFocus = () => {
968
1075
  const { model, cursor } = useSheetContext();
969
- const dispatch = (0, import_app_framework.useIntentDispatcher)();
1076
+ const dispatch = (0, import_app_framework2.useIntentDispatcher)();
970
1077
  const threads = (0, import_react6.useMemo)(() => model.sheet.threads?.filter((thread) => !!thread) ?? [], [
971
1078
  // TODO(thure): Surely we can find a better dependency for this…
972
1079
  JSON.stringify(model.sheet.threads)
@@ -978,7 +1085,7 @@ var useSelectThreadOnCellFocus = () => {
978
1085
  const closestThread = threads?.find(({ anchor }) => {
979
1086
  if (anchor) {
980
1087
  const range = parseThreadAnchorAsCellRange(anchor);
981
- return range ? (0, import_chunk_JF5XNTF3.inRange)(range, cellAddress) : false;
1088
+ return range ? (0, import_chunk_O7XR4R7Y.inRange)(range, cellAddress) : false;
982
1089
  } else {
983
1090
  return false;
984
1091
  }
@@ -1051,16 +1158,25 @@ var projectCellProps = (model, col, row) => {
1051
1158
  row
1052
1159
  };
1053
1160
  const rawValue = model.getValue(address);
1054
- const ranges = model.sheet.ranges?.filter(({ range }) => (0, import_chunk_JF5XNTF3.inRange)((0, import_chunk_JF5XNTF3.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));
1055
1162
  const threadRefs = model.sheet.threads?.filter((thread) => {
1056
1163
  const range = thread?.anchor && parseThreadAnchorAsCellRange(thread.anchor);
1057
- return thread && range ? (0, import_chunk_JF5XNTF3.inRange)(range, address) : false;
1164
+ return thread && range ? (0, import_chunk_O7XR4R7Y.inRange)(range, address) : false;
1058
1165
  }).map((thread) => (0, import_echo2.fullyQualifiedId)(thread)).join(" ");
1059
- const type = model.getValueType(address);
1060
- const classNames = ranges?.map(import_chunk_JF5XNTF3.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();
1061
1170
  return {
1062
- value: (0, import_react_ui_data.parseValue)(type, rawValue),
1063
- 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),
1064
1180
  dataRefs: threadRefs
1065
1181
  };
1066
1182
  };
@@ -1083,11 +1199,12 @@ var gridCellGetter = (model) => {
1083
1199
  };
1084
1200
  var rowLabelCell = (row) => ({
1085
1201
  value: (0, import_react_ui_grid3.rowToA1Notation)(row),
1086
- className: "text-end !pie-1",
1202
+ className: "text-end !pie-1 text-subdued",
1087
1203
  resizeHandle: "row"
1088
1204
  });
1089
1205
  var colLabelCell = (col) => ({
1090
1206
  value: (0, import_react_ui_grid3.colToA1Notation)(col),
1207
+ className: "text-subdued",
1091
1208
  resizeHandle: "col"
1092
1209
  });
1093
1210
  var cellGetter = (model) => {
@@ -1119,7 +1236,7 @@ var cellGetter = (model) => {
1119
1236
  };
1120
1237
  var useSheetModelDxGridProps = (dxGrid, model) => {
1121
1238
  const [columns, setColumns] = (0, import_react5.useState)(createDxGridColumns(model));
1122
- const [rows, setRows] = (0, import_react5.useState)(createDxGridColumns(model));
1239
+ const [rows, setRows] = (0, import_react5.useState)(createDxGridRows(model));
1123
1240
  (0, import_react5.useEffect)(() => {
1124
1241
  const cellsAccessor = (0, import_echo2.createDocAccessor)(model.sheet, [
1125
1242
  "cells"
@@ -1131,7 +1248,11 @@ var useSheetModelDxGridProps = (dxGrid, model) => {
1131
1248
  dxGrid?.requestUpdate("initialCells");
1132
1249
  };
1133
1250
  cellsAccessor.handle.addListener("change", handleCellsUpdate);
1134
- 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
+ };
1135
1256
  }, [
1136
1257
  model,
1137
1258
  dxGrid
@@ -1156,7 +1277,8 @@ var useSheetModelDxGridProps = (dxGrid, model) => {
1156
1277
  rowMetaAccessor.handle.removeListener("change", handleRowMetaUpdate);
1157
1278
  };
1158
1279
  }, [
1159
- model
1280
+ model,
1281
+ dxGrid
1160
1282
  ]);
1161
1283
  return {
1162
1284
  columns,
@@ -1189,11 +1311,11 @@ var frozen = {
1189
1311
  };
1190
1312
  var sheetRowDefault = {
1191
1313
  frozenRowsStart: {
1192
- size: 32,
1314
+ size: import_react_ui_grid2.defaultSizeRow,
1193
1315
  readonly: true
1194
1316
  },
1195
1317
  grid: {
1196
- size: 32,
1318
+ size: import_react_ui_grid2.defaultSizeRow,
1197
1319
  resizeable: true
1198
1320
  }
1199
1321
  };
@@ -1208,43 +1330,51 @@ var sheetColDefault = {
1208
1330
  }
1209
1331
  };
1210
1332
  var GridSheet = () => {
1211
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_QIFIGEKV.SHEET_PLUGIN);
1212
- const { id, model, editing, setEditing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
1333
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_2ZVZI2KJ.SHEET_PLUGIN);
1334
+ const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs } = useSheetContext();
1213
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)();
1214
1338
  const rangeController = (0, import_react4.useRef)();
1215
1339
  const { hasAttention } = (0, import_react_ui_attention.useAttention)(id);
1216
1340
  const handleFocus = (0, import_react4.useCallback)((event) => {
1217
1341
  if (!editing) {
1218
1342
  const cell = (0, import_react_ui_grid2.closestCell)(event.target);
1219
- if (cell && cell.plane === "grid") {
1220
- setCursor({
1221
- col: cell.col,
1222
- row: cell.row
1223
- });
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);
1224
1355
  }
1225
1356
  }
1226
1357
  }, [
1227
1358
  editing
1228
1359
  ]);
1229
- const handleClose = (0, import_react4.useCallback)((value, { key, shift }) => {
1230
- if (value !== void 0) {
1231
- 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);
1232
1377
  }
1233
- setEditing(null);
1234
- const axis = [
1235
- "Enter",
1236
- "ArrowUp",
1237
- "ArrowDown"
1238
- ].includes(key) ? "row" : [
1239
- "Tab",
1240
- "ArrowLeft",
1241
- "ArrowRight"
1242
- ].includes(key) ? "col" : void 0;
1243
- const delta = key.startsWith("Arrow") ? [
1244
- "ArrowUp",
1245
- "ArrowLeft"
1246
- ].includes(key) ? -1 : 1 : shift ? -1 : 1;
1247
- dxGrid?.refocus(axis, delta);
1248
1378
  }, [
1249
1379
  model,
1250
1380
  editing,
@@ -1254,7 +1384,6 @@ var GridSheet = () => {
1254
1384
  if (value !== void 0) {
1255
1385
  model.setValue(dxGridCellIndexToSheetCellAddress(editing.index), value);
1256
1386
  }
1257
- setEditing(null);
1258
1387
  }, [
1259
1388
  model,
1260
1389
  editing
@@ -1286,7 +1415,7 @@ var GridSheet = () => {
1286
1415
  };
1287
1416
  }
1288
1417
  if (editing) {
1289
- rangeController.current?.setRange((0, import_chunk_JF5XNTF3.rangeToA1Notation)(range));
1418
+ rangeController.current?.setRange((0, import_chunk_O7XR4R7Y.rangeToA1Notation)(range));
1290
1419
  } else {
1291
1420
  setRange(range.to ? range : void 0);
1292
1421
  }
@@ -1300,12 +1429,63 @@ var GridSheet = () => {
1300
1429
  }, [
1301
1430
  hasAttention
1302
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
+ ]);
1303
1473
  const handleKeyDown = (0, import_react4.useCallback)((event) => {
1304
1474
  switch (event.key) {
1305
1475
  case "Backspace":
1306
1476
  case "Delete":
1307
1477
  event.preventDefault();
1308
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
+ }
1309
1489
  }
1310
1490
  if (event.metaKey || event.ctrlKey) {
1311
1491
  switch (event.key) {
@@ -1333,7 +1513,9 @@ var GridSheet = () => {
1333
1513
  }, [
1334
1514
  cursorFallbackRange,
1335
1515
  model,
1336
- cursor
1516
+ cursor,
1517
+ extraplanarFocus,
1518
+ selectEntireAxis
1337
1519
  ]);
1338
1520
  const contextMenuAnchorRef = (0, import_react4.useRef)(null);
1339
1521
  const [contextMenuOpen, setContextMenuOpen] = (0, import_react4.useState)(null);
@@ -1348,16 +1530,32 @@ var GridSheet = () => {
1348
1530
  }, []);
1349
1531
  const handleAxisMenuAction = (0, import_react4.useCallback)((operation) => {
1350
1532
  switch (operation) {
1351
- case "add-before":
1352
- case "add-after":
1353
- 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
+ });
1354
1543
  break;
1355
- 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
+ });
1356
1553
  }
1357
1554
  }, [
1358
1555
  contextMenuAxis,
1359
1556
  contextMenuOpen,
1360
- model
1557
+ model,
1558
+ dispatch
1361
1559
  ]);
1362
1560
  const { columns, rows } = useSheetModelDxGridProps(dxGrid, model);
1363
1561
  const extension = (0, import_react4.useMemo)(() => [
@@ -1397,8 +1595,8 @@ var GridSheet = () => {
1397
1595
  onBlur: handleBlur
1398
1596
  }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_grid2.Grid.Content, {
1399
1597
  initialCells,
1400
- limitColumns: import_chunk_JF5XNTF3.DEFAULT_COLUMNS,
1401
- limitRows: import_chunk_JF5XNTF3.DEFAULT_ROWS,
1598
+ limitColumns: import_chunk_O7XR4R7Y.DEFAULT_COLUMNS,
1599
+ limitRows: import_chunk_O7XR4R7Y.DEFAULT_ROWS,
1402
1600
  columns,
1403
1601
  rows,
1404
1602
  onAxisResize: handleAxisResize,
@@ -1410,8 +1608,9 @@ var GridSheet = () => {
1410
1608
  onWheelCapture: handleWheel,
1411
1609
  onKeyDown: handleKeyDown,
1412
1610
  onContextMenu: handleContextMenu,
1413
- overscroll: "inline",
1414
- 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",
1415
1614
  activeRefs,
1416
1615
  ref: setDxGrid
1417
1616
  }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Root, {
@@ -1425,18 +1624,17 @@ var GridSheet = () => {
1425
1624
  sideOffset: 4,
1426
1625
  collisionPadding: 8
1427
1626
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1428
- onClick: () => handleAxisMenuAction("add-before")
1627
+ onClick: () => handleAxisMenuAction("insert-before")
1429
1628
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1430
1629
  size: 5,
1431
1630
  icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
1432
1631
  }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1433
- onClick: () => handleAxisMenuAction("add-after")
1632
+ onClick: () => handleAxisMenuAction("insert-after")
1434
1633
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1435
1634
  size: 5,
1436
1635
  icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
1437
1636
  }), /* @__PURE__ */ import_react4.default.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.DropdownMenu.Item, {
1438
- disabled: true,
1439
- onClick: () => handleAxisMenuAction("remove")
1637
+ onClick: () => handleAxisMenuAction("drop")
1440
1638
  }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Icon, {
1441
1639
  size: 5,
1442
1640
  icon: "ph--backspace--regular"
@@ -1454,4 +1652,4 @@ var GridSheet = () => {
1454
1652
  useComputeGraph,
1455
1653
  useSheetContext
1456
1654
  });
1457
- //# sourceMappingURL=chunk-DEPJHN47.cjs.map
1655
+ //# sourceMappingURL=chunk-OO24XJBV.cjs.map