@colijnit/corecomponents_v12 300.1.4 → 300.1.5

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.
@@ -11942,35 +11942,17 @@ class SimpleGridCellComponent {
11942
11942
  _changeDetector;
11943
11943
  _injector;
11944
11944
  _formComponent;
11945
- get editMode() {
11946
- return this._editMode;
11947
- }
11948
- set editMode(value) {
11949
- this._editMode = value;
11950
- }
11945
+ editMode;
11951
11946
  defaultTextAlign = ColumnAlign.Left;
11952
- set editTemplateContent(template) {
11953
- if (template) {
11954
- this._editTemplate = template;
11955
- this._setFocusComponent();
11956
- }
11957
- }
11958
- set noEditTemplateContent(template) {
11959
- if (template) {
11960
- this._template = template;
11961
- this._setFocusComponent();
11962
- }
11963
- }
11964
- set noTemplateContent(template) {
11965
- if (template) {
11966
- this._inputTemplate = template;
11947
+ set cellFieldContent(element) {
11948
+ if (element) {
11949
+ this._cellField = element;
11967
11950
  this._setFocusComponent();
11968
11951
  }
11969
11952
  }
11970
11953
  column;
11971
11954
  row;
11972
11955
  columnInjector;
11973
- _editMode = false;
11974
11956
  set fieldEditMode(value) {
11975
11957
  this._fieldEditMode = value;
11976
11958
  this._setFocusComponent();
@@ -11989,9 +11971,7 @@ class SimpleGridCellComponent {
11989
11971
  }
11990
11972
  _fieldEditMode = false;
11991
11973
  _focused = false;
11992
- _editTemplate;
11993
- _template;
11994
- _inputTemplate;
11974
+ _cellField;
11995
11975
  constructor(_changeDetector, _injector, _formComponent) {
11996
11976
  this._changeDetector = _changeDetector;
11997
11977
  this._injector = _injector;
@@ -12006,7 +11986,7 @@ class SimpleGridCellComponent {
12006
11986
  });
12007
11987
  }
12008
11988
  _setFocusComponent() {
12009
- if (this._editMode && this.fieldEditMode) {
11989
+ if (this.editMode && this.fieldEditMode) {
12010
11990
  const element = this._getElement();
12011
11991
  if (element) {
12012
11992
  const focusEvent = this._createNewEvent(element, 'focus');
@@ -12050,22 +12030,10 @@ class SimpleGridCellComponent {
12050
12030
  return event;
12051
12031
  }
12052
12032
  _getElement() {
12053
- let templ;
12054
- if (this._editTemplate) {
12055
- templ = this._editTemplate;
12056
- }
12057
- else if (this._template) {
12058
- templ = this._template;
12059
- }
12060
- else {
12061
- templ = this._inputTemplate;
12062
- }
12063
- if (templ) {
12064
- if (templ && templ.elementRef) {
12065
- const inputElement = this._getFirstFormInput(templ.elementRef.nativeElement.parentElement);
12066
- if (inputElement) {
12067
- return inputElement;
12068
- }
12033
+ if (this._cellField && this._cellField.nativeElement) {
12034
+ const inputElement = this._getFirstFormInput(this._cellField.nativeElement);
12035
+ if (inputElement) {
12036
+ return inputElement;
12069
12037
  }
12070
12038
  }
12071
12039
  }
@@ -12073,12 +12041,12 @@ class SimpleGridCellComponent {
12073
12041
  this._changeDetector.detectChanges();
12074
12042
  }
12075
12043
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: SimpleGridCellComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.Injector }, { token: FormComponent, optional: true }], target: i0.ɵɵFactoryTarget.Component });
12076
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: SimpleGridCellComponent, isStandalone: false, selector: "co-simple-grid-cell", inputs: { editMode: "editMode", column: "column", row: "row", fieldEditMode: "fieldEditMode" }, outputs: { cellClick: "cellClick" }, host: { listeners: { "click": "handleClick($event)" }, properties: { "class.co-simple-grid-cell": "this.showClass" } }, viewQueries: [{ propertyName: "editTemplateContent", first: true, predicate: ["editTemplate"], descendants: true, read: BaseInputComponent }, { propertyName: "noEditTemplateContent", first: true, predicate: ["noEditTemplate"], descendants: true }, { propertyName: "noTemplateContent", first: true, predicate: ["noTemplate"], descendants: true }], ngImport: i0, template: `
12044
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: SimpleGridCellComponent, isStandalone: false, selector: "co-simple-grid-cell", inputs: { editMode: "editMode", column: "column", row: "row", fieldEditMode: "fieldEditMode" }, outputs: { cellClick: "cellClick" }, host: { listeners: { "click": "handleClick($event)" }, properties: { "class.co-simple-grid-cell": "this.showClass" } }, viewQueries: [{ propertyName: "cellFieldContent", first: true, predicate: ["cellField"], descendants: true }], ngImport: i0, template: `
12077
12045
  <div class="simple-grid-column-cell-value" [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign">
12078
12046
  @if (editMode) {
12079
- <div class="simple-grid-column-cell-field">
12047
+ <div #cellField class="simple-grid-column-cell-field">
12080
12048
  @if (column.editTemplate) {
12081
- <ng-container #editTemplate
12049
+ <ng-container
12082
12050
  [ngTemplateOutlet]="column.editTemplate"
12083
12051
  [ngTemplateOutletInjector]="columnInjector"
12084
12052
  [ngTemplateOutletContext]="{value: row[column.field], row: row}"></ng-container>
@@ -12092,7 +12060,7 @@ class SimpleGridCellComponent {
12092
12060
  }
12093
12061
  </div>
12094
12062
  } @else {
12095
- <div class="simple-grid-column-cell-field">
12063
+ <div #cellField class="simple-grid-column-cell-field">
12096
12064
  @if (column.template) {
12097
12065
  <ng-container [ngTemplateOutlet]="column.template"
12098
12066
  [ngTemplateOutletContext]="{value: row[column.field], row: row}"></ng-container>
@@ -12111,9 +12079,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
12111
12079
  template: `
12112
12080
  <div class="simple-grid-column-cell-value" [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign">
12113
12081
  @if (editMode) {
12114
- <div class="simple-grid-column-cell-field">
12082
+ <div #cellField class="simple-grid-column-cell-field">
12115
12083
  @if (column.editTemplate) {
12116
- <ng-container #editTemplate
12084
+ <ng-container
12117
12085
  [ngTemplateOutlet]="column.editTemplate"
12118
12086
  [ngTemplateOutletInjector]="columnInjector"
12119
12087
  [ngTemplateOutletContext]="{value: row[column.field], row: row}"></ng-container>
@@ -12127,7 +12095,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
12127
12095
  }
12128
12096
  </div>
12129
12097
  } @else {
12130
- <div class="simple-grid-column-cell-field">
12098
+ <div #cellField class="simple-grid-column-cell-field">
12131
12099
  @if (column.template) {
12132
12100
  <ng-container [ngTemplateOutlet]="column.template"
12133
12101
  [ngTemplateOutletContext]="{value: row[column.field], row: row}"></ng-container>
@@ -12145,15 +12113,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
12145
12113
  type: Optional
12146
12114
  }] }], propDecorators: { editMode: [{
12147
12115
  type: Input
12148
- }], editTemplateContent: [{
12116
+ }], cellFieldContent: [{
12149
12117
  type: ViewChild,
12150
- args: ["editTemplate", { read: BaseInputComponent }]
12151
- }], noEditTemplateContent: [{
12152
- type: ViewChild,
12153
- args: ["noEditTemplate"]
12154
- }], noTemplateContent: [{
12155
- type: ViewChild,
12156
- args: ["noTemplate"]
12118
+ args: ["cellField"]
12157
12119
  }], column: [{
12158
12120
  type: Input
12159
12121
  }], row: [{
@@ -12278,9 +12240,11 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
12278
12240
  defaultTextAlign = ColumnAlign.Left;
12279
12241
  scrollDirections = ScrollDirection;
12280
12242
  set headerCells(cells) {
12243
+ // The header cells are rendered from headerColumnsCopy, so the elementRefs
12244
+ // have to be handed back to that same collection.
12281
12245
  const headerElements = cells.toArray();
12282
- for (let i = 0; i < headerElements.length; i++) {
12283
- this.columns[i].elementRef = headerElements[i];
12246
+ for (let i = 0; i < headerElements.length && i < this.headerColumnsCopy.length; i++) {
12247
+ this.headerColumnsCopy[i].elementRef = headerElements[i];
12284
12248
  }
12285
12249
  }
12286
12250
  rowElements;
@@ -12315,8 +12279,11 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
12315
12279
  .then((index) => {
12316
12280
  this.editCellIndex = index;
12317
12281
  this.changeDetection.markForCheck();
12282
+ this._detectChanges();
12283
+ })
12284
+ .catch(() => {
12285
+ // row change was blocked by validation, keep the current cell in edit mode
12318
12286
  });
12319
- this._detectChanges();
12320
12287
  }
12321
12288
  if (event.code === 'Escape') {
12322
12289
  this.cancelEditRow();
@@ -12719,6 +12686,9 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
12719
12686
  }, 500);
12720
12687
  }
12721
12688
  /**
12689
+ * Cell indexes are expressed in `headerColumnsCopy` space, because that is the
12690
+ * collection the rows are rendered from. Using `columns` here would drift as soon
12691
+ * as a column is hidden or marked as single column.
12722
12692
  *
12723
12693
  * @param next; Move to next or previous cell
12724
12694
  * @param start; Start from cellindex
@@ -12726,9 +12696,16 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
12726
12696
  */
12727
12697
  _nextAvailableCellToEdit(next, start = -1) {
12728
12698
  return new Promise((resolve, reject) => {
12729
- const numEditableColumns = this.columns.filter(c => !c.readonly).length;
12730
12699
  const wantedIndex = start + (next ? 1 : -1);
12731
- if (wantedIndex >= numEditableColumns) {
12700
+ const cellIndex = next
12701
+ ? this._getNextEditCellIndex(Math.max(wantedIndex, 0))
12702
+ : this._getPreviousEditCellIndex(wantedIndex);
12703
+ // Still an editable column left in the current row
12704
+ if (cellIndex > -1) {
12705
+ resolve(cellIndex);
12706
+ return;
12707
+ }
12708
+ if (next) {
12732
12709
  this._getNextEditRowIndex()
12733
12710
  .then((index) => {
12734
12711
  this.editRowIndex = index;
@@ -12738,34 +12715,37 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
12738
12715
  reject();
12739
12716
  });
12740
12717
  }
12741
- else if (wantedIndex < 0) {
12718
+ else {
12742
12719
  this._getPreviousEditRowIndex()
12743
12720
  .then((index) => {
12744
12721
  this.editRowIndex = index;
12745
- resolve(this._getPreviousEditCellIndex(this.columns.length - 1));
12722
+ resolve(this._getPreviousEditCellIndex(this.headerColumnsCopy.length - 1));
12746
12723
  })
12747
12724
  .catch((e) => {
12748
12725
  reject();
12749
12726
  });
12750
12727
  }
12751
- else {
12752
- resolve(next ? this._getNextEditCellIndex(start + 1) : this._getPreviousEditCellIndex(start - 1));
12753
- }
12754
12728
  });
12755
12729
  }
12756
12730
  _getNextEditCellIndex(start) {
12757
- for (let i = start; i < this.columns.length; i++) {
12758
- if (!this.columns[i].readonly) {
12731
+ for (let i = start; i < this.headerColumnsCopy.length; i++) {
12732
+ if (this._isCellEditable(i)) {
12759
12733
  return i;
12760
12734
  }
12761
12735
  }
12736
+ return -1;
12762
12737
  }
12763
12738
  _getPreviousEditCellIndex(start) {
12764
- for (let i = start; i >= 0; i--) {
12765
- if (!this.columns[i].readonly) {
12739
+ for (let i = Math.min(start, this.headerColumnsCopy.length - 1); i >= 0; i--) {
12740
+ if (this._isCellEditable(i)) {
12766
12741
  return i;
12767
12742
  }
12768
12743
  }
12744
+ return -1;
12745
+ }
12746
+ _isCellEditable(cellIndex) {
12747
+ const column = this.headerColumnsCopy[cellIndex];
12748
+ return !!column && !column.readonly;
12769
12749
  }
12770
12750
  _getNextEditRowIndex() {
12771
12751
  return new Promise((resolve, reject) => {