@trudb/tru-common-lib 0.2.146 → 0.2.148

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.
@@ -5,7 +5,7 @@ import * as i1$1 from '@angular/common';
5
5
  import { CommonModule, NgIf, NgClass, DatePipe } from '@angular/common';
6
6
  import * as i7 from '@angular/forms';
7
7
  import { FormsModule, FormControl, ReactiveFormsModule, FormGroup, Validators } from '@angular/forms';
8
- import { BehaviorSubject, defer, from, of, Subject, Observable, fromEvent, skip, forkJoin, first, tap as tap$1, delayWhen, interval, finalize, throwError } from 'rxjs';
8
+ import { BehaviorSubject, defer, from, of, Subject, Observable, fromEvent, skip, forkJoin, first, finalize, throwError } from 'rxjs';
9
9
  import * as _ from 'underscore';
10
10
  import ___default from 'underscore';
11
11
  import * as i2 from '@angular/common/http';
@@ -6055,53 +6055,32 @@ class TruDataGridCellRenderer {
6055
6055
  // private eGui: is an empty element to satisfy the getGui method.
6056
6056
  eGui;
6057
6057
  validationContainer;
6058
+ windowClickSubscription;
6058
6059
  params;
6059
- contextMenuPosition = { x: 0, y: 0 };
6060
+ contextMenuPosition = { x: '0px', y: '0px' };
6060
6061
  displayValue = '';
6061
6062
  copyIsDisabled = true;
6062
6063
  pasteIsDisabled = true;
6063
- menuSubscription;
6064
6064
  constructor(dataContext, dataGridClipboard) {
6065
6065
  this.dataContext = dataContext;
6066
6066
  this.dataGridClipboard = dataGridClipboard;
6067
6067
  }
6068
- delay(delayInms) {
6069
- return new Promise((resolve) => {
6070
- setTimeout(() => {
6071
- resolve(2);
6072
- }, delayInms);
6073
- });
6074
- }
6075
6068
  onMouseOver = (e) => {
6076
6069
  if (e.target)
6077
6070
  e.target.classList.contains('invalid-flag') ? this.validationContainer.classList.toggle('show') : this.validationContainer.classList.remove('show');
6078
6071
  };
6079
6072
  onRightClick = (event) => {
6080
6073
  event.preventDefault();
6081
- if (this.params.api.getEditingCells().length > 0)
6082
- return;
6083
6074
  this.pasteIsDisabled = this.dataGridClipboard.getCopiedRows().length && this.params.api.getSelectedRows().length ? false : true;
6084
- this.menuSubscription && this.menuSubscription.unsubscribe();
6085
- this.menuSubscription = of(1)
6086
- .pipe(tap$1(() => {
6087
- if (this.contextMenu.menuOpen) {
6088
- this.contextMenu.closeMenu();
6075
+ let clickedElement = event.target;
6076
+ if (clickedElement instanceof Element) {
6077
+ if (this.params.api.getEditingCells().length <= 0) {
6078
+ this.contextMenuPosition.x = event.clientX + 'px';
6079
+ this.contextMenuPosition.y = event.clientY + 'px';
6080
+ this.contextMenu.menu?.focusFirstItem('mouse');
6081
+ this.contextMenu.openMenu();
6089
6082
  }
6090
- this.contextMenuPosition.x = event.clientX;
6091
- this.contextMenuPosition.y = event.clientY;
6092
- }),
6093
- // delay(this.contextMenu.menuOpen ? 200 : 0),
6094
- delayWhen((_) => (this.contextMenu.menuOpen ? interval(200) : of(undefined))), tap$1(async () => {
6095
- this.contextMenu.menu?.focusFirstItem('mouse');
6096
- this.contextMenu.openMenu();
6097
- let backdrop;
6098
- do {
6099
- await this.delay(100);
6100
- backdrop = document.querySelector('div.cdk-overlay-backdrop.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing');
6101
- } while (backdrop === null);
6102
- backdrop.style.pointerEvents = 'none';
6103
- }))
6104
- .subscribe();
6083
+ }
6105
6084
  };
6106
6085
  onCopy = (event) => {
6107
6086
  this.dataGridClipboard.copyCell(this.params.context.grid.config.tableName, this.params.colDef?.field, this.params.data.$entity);
@@ -6114,18 +6093,16 @@ class TruDataGridCellRenderer {
6114
6093
  agInit(params) {
6115
6094
  this.params = params;
6116
6095
  this.displayValue = params.value;
6117
- //params.eGridCell.innerHTML = '';
6118
- //let value = params.value;
6119
- //if (params.value === null)
6120
- // value = '';
6121
- //if (params.colDef.cellEditor && params.colDef.cellEditor.name === "StdRichTextList") {
6122
- // var p = document.createElement('div');
6123
- // p.innerHTML = value
6124
- // params.eGridCell.appendChild(p);
6125
- //} else {
6126
- // var content = document.createTextNode(value);
6127
- // params.eGridCell.appendChild(content);
6128
- //}
6096
+ if (params.value === null)
6097
+ this.displayValue = '';
6098
+ if (params.colDef.cellEditor && params.colDef.cellEditor.name === "StdRichTextList") {
6099
+ var p = document.createElement('div');
6100
+ p.innerHTML = params.value;
6101
+ params.eGridCell.appendChild(p);
6102
+ }
6103
+ else {
6104
+ this.displayValue = params.value;
6105
+ }
6129
6106
  this.validationContainer = document.createElement('div');
6130
6107
  this.validationContainer.className = 'dialog-target';
6131
6108
  let validationFlag = document.createElement('span');
@@ -6134,6 +6111,11 @@ class TruDataGridCellRenderer {
6134
6111
  params.eGridCell.appendChild(validationFlag);
6135
6112
  params.eGridCell.addEventListener('mouseover', this.onMouseOver);
6136
6113
  params.eGridCell.addEventListener('contextmenu', this.onRightClick);
6114
+ this.windowClickSubscription = fromEvent(window, 'click').subscribe((_) => {
6115
+ if (this.contextMenu.menuOpen) {
6116
+ this.contextMenu.closeMenu();
6117
+ }
6118
+ });
6137
6119
  Object.assign(params.eGridCell.style, new TruUtil().rulesEval(params.data[params.colDef.field].rules(params.data.$entity)));
6138
6120
  }
6139
6121
  getGui() {
@@ -6144,8 +6126,7 @@ class TruDataGridCellRenderer {
6144
6126
  }
6145
6127
  destroy() {
6146
6128
  document.removeEventListener('mouseover', this.onMouseOver);
6147
- this.contextMenu.closeMenu();
6148
- this.contextMenu.ngOnDestroy();
6129
+ this.windowClickSubscription && this.windowClickSubscription.unsubscribe();
6149
6130
  }
6150
6131
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridCellRenderer, deps: [{ token: TruDataContext }, { token: TruDataGridClipboard }], target: i0.ɵɵFactoryTarget.Component });
6151
6132
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: TruDataGridCellRenderer, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "contextMenu", first: true, predicate: TruContextMenuTrigger, descendants: true }], ngImport: i0, template: `<div>{{displayValue}}
@@ -6198,14 +6179,15 @@ class TruDataGridPkeyCellRenderer {
6198
6179
  dataContext;
6199
6180
  dataGridClipboard;
6200
6181
  contextMenu;
6182
+ // private eGui: is an empty element to satisfy the getGui method.
6183
+ eGui;
6184
+ windowClickSubscription;
6201
6185
  params;
6202
6186
  contextMenuPosition = { x: '0px', y: '0px' };
6203
6187
  displayValue = '';
6204
6188
  copyIsDisabled = true;
6205
6189
  pasteIsDisabled = true;
6206
6190
  insertAtTopIsDisabled = true;
6207
- // private eGui: is an empty element to satisfy the getGui method.
6208
- eGui;
6209
6191
  constructor(dataContext, dataGridClipboard) {
6210
6192
  this.dataContext = dataContext;
6211
6193
  this.dataGridClipboard = dataGridClipboard;
@@ -6246,6 +6228,11 @@ class TruDataGridPkeyCellRenderer {
6246
6228
  params.eGridCell.addEventListener('contextmenu', this.onRightClick);
6247
6229
  params.eGridCell.addEventListener('mousedown', this.onMouseDown);
6248
6230
  params.eGridCell.addEventListener('mousedown', this.onMouseUp);
6231
+ this.windowClickSubscription = fromEvent(window, 'click').subscribe((_) => {
6232
+ if (this.contextMenu.menuOpen) {
6233
+ this.contextMenu.closeMenu();
6234
+ }
6235
+ });
6249
6236
  }
6250
6237
  getGui() {
6251
6238
  return this.eGui;
@@ -6257,14 +6244,15 @@ class TruDataGridPkeyCellRenderer {
6257
6244
  this.params.eGridCell.removeEventListener('contextmenu', this.onRightClick);
6258
6245
  this.params.eGridCell.removeEventListener('mousedown', this.onMouseDown);
6259
6246
  this.params.eGridCell.removeEventListener('mousedown', this.onMouseUp);
6247
+ this.windowClickSubscription && this.windowClickSubscription.unsubscribe();
6260
6248
  }
6261
6249
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridPkeyCellRenderer, deps: [{ token: TruDataContext }, { token: TruDataGridClipboard }], target: i0.ɵɵFactoryTarget.Component });
6262
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: TruDataGridPkeyCellRenderer, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "contextMenu", first: true, predicate: MatMenuTrigger, descendants: true }], ngImport: i0, template: `<div (contextmenu)="onRightClick($event)">{{displayValue}}
6250
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: TruDataGridPkeyCellRenderer, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "contextMenu", first: true, predicate: MatMenuTrigger, descendants: true }], ngImport: i0, template: `<div>{{displayValue}}
6263
6251
  <div style="visibility: hidden; position: relative"
6264
6252
  [style.left]="contextMenuPosition.x"
6265
6253
  [matMenuTriggerFor]="truDataGridContextMenu">
6266
6254
  </div>
6267
- <mat-menu #truDataGridContextMenu="matMenu">
6255
+ <mat-menu #truDataGridContextMenu="matMenu" [hasBackdrop]="false">
6268
6256
  <button mat-menu-item [disabled]="copyIsDisabled" (click)="onCopy($event)">
6269
6257
  <mat-icon [svgIcon]="'copy-icon'"></mat-icon>
6270
6258
  <span>Copy</span>
@@ -6289,12 +6277,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
6289
6277
  MatIconModule,
6290
6278
  MatButtonModule,
6291
6279
  MatMenuModule
6292
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: `<div (contextmenu)="onRightClick($event)">{{displayValue}}
6280
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: `<div>{{displayValue}}
6293
6281
  <div style="visibility: hidden; position: relative"
6294
6282
  [style.left]="contextMenuPosition.x"
6295
6283
  [matMenuTriggerFor]="truDataGridContextMenu">
6296
6284
  </div>
6297
- <mat-menu #truDataGridContextMenu="matMenu">
6285
+ <mat-menu #truDataGridContextMenu="matMenu" [hasBackdrop]="false">
6298
6286
  <button mat-menu-item [disabled]="copyIsDisabled" (click)="onCopy($event)">
6299
6287
  <mat-icon [svgIcon]="'copy-icon'"></mat-icon>
6300
6288
  <span>Copy</span>