@trebco/treb 31.3.2 → 31.3.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "31.3.2",
3
+ "version": "31.3.3",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -121,6 +121,10 @@
121
121
  flex-direction: column;
122
122
  justify-content: center;
123
123
 
124
+ & > .treb-editor-shadow {
125
+ opacity: .4;
126
+ }
127
+
124
128
  }
125
129
 
126
130
  &[expanded] {
@@ -67,6 +67,26 @@ export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
67
67
 
68
68
  public tolled?: { text: string, substring: string };
69
69
 
70
+ /**
71
+ * if we're showing a spill array and it's not the first cell, show
72
+ * the formula using a shadow style (and it's not editable).
73
+ */
74
+ public shadow_ = false;
75
+
76
+ public get shadow() { return this.shadow_; }
77
+
78
+ public set shadow(shadow: boolean) {
79
+ this.shadow_ = shadow;
80
+ if (this.active_editor?.node) {
81
+ if (shadow) {
82
+ this.active_editor.node.classList.add('treb-editor-shadow');
83
+ }
84
+ else {
85
+ this.active_editor.node.classList.remove('treb-editor-shadow');
86
+ }
87
+ }
88
+ }
89
+
70
90
  /** is the _editor_ currently focused */
71
91
  // tslint:disable-next-line:variable-name
72
92
  public focused_ = false;
@@ -244,6 +264,12 @@ export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
244
264
 
245
265
  let text = this.active_editor.node.textContent || '';
246
266
 
267
+ if (this.shadow) {
268
+ this.shadow = false;
269
+ text = '';
270
+ this.active_editor.node.textContent = text;
271
+ this.active_editor.formatted_text = undefined; // why do we clear this here?
272
+ }
247
273
  if (text[0] === '{' && text[text.length - 1] === '}') {
248
274
  text = text.substring(1, text.length - 1);
249
275
  this.active_editor.node.textContent = text;
@@ -555,6 +581,7 @@ export class FormulaBar extends Editor<FormulaBar2Event|FormulaEditorEvent> {
555
581
  case 'Escape':
556
582
  case 'Esc':
557
583
  // this.selecting_ = false;
584
+ this.committed = true;
558
585
  this.Publish({ type: 'discard' });
559
586
  // this.FlushReference();
560
587
  break;
@@ -6692,6 +6692,7 @@ export class Grid extends GridBase {
6692
6692
 
6693
6693
  if (override) {
6694
6694
  if (this.formula_bar) {
6695
+ this.formula_bar.shadow = false;
6695
6696
  this.formula_bar.formula = override;
6696
6697
  }
6697
6698
  return;
@@ -6699,6 +6700,7 @@ export class Grid extends GridBase {
6699
6700
 
6700
6701
  if (this.primary_selection.empty) {
6701
6702
  if (this.formula_bar) {
6703
+ this.formula_bar.shadow = false;
6702
6704
  this.formula_bar.formula = '';
6703
6705
  }
6704
6706
  }
@@ -6708,11 +6710,14 @@ export class Grid extends GridBase {
6708
6710
  // optimally we would do this check prior to this call, but
6709
6711
  // it's the uncommon case... not sure how important that is
6710
6712
 
6711
- const head = data.merge_area || data.area;
6713
+ const head = data.merge_area || data.area || data.spill;
6714
+ let shadow = false;
6715
+
6712
6716
  if (head) {
6713
6717
  if (head.start.column !== this.primary_selection.target.column
6714
6718
  || head.start.row !== this.primary_selection.target.row) {
6715
6719
  data = this.active_sheet.CellData(head.start);
6720
+ if (data.spill) { shadow = true; }
6716
6721
  }
6717
6722
  }
6718
6723
 
@@ -6752,12 +6757,13 @@ export class Grid extends GridBase {
6752
6757
 
6753
6758
  if (this.formula_bar) {
6754
6759
 
6755
- // add braces for area
6760
+ this.formula_bar.shadow = shadow;
6761
+
6756
6762
  if (data.area) {
6757
6763
  this.formula_bar.formula = '{' + (value || '') + '}';
6758
6764
  }
6759
6765
  else {
6760
- this.formula_bar.formula = (typeof value !== 'undefined') ? value.toString() : ''; // value || ''; // what about zero?
6766
+ this.formula_bar.formula = (value ?? '').toString();
6761
6767
  }
6762
6768
 
6763
6769
  }