@colijnit/corecomponents_v12 12.0.28 → 12.0.29

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 (26) hide show
  1. package/bundles/colijnit-corecomponents_v12.umd.js +117 -30
  2. package/bundles/colijnit-corecomponents_v12.umd.js.map +1 -1
  3. package/colijnit-corecomponents_v12.metadata.json +1 -1
  4. package/esm2015/lib/components/base/base-input.component.js +2 -2
  5. package/esm2015/lib/components/input-search/input-search.component.js +27 -20
  6. package/esm2015/lib/components/input-search/input-search.module.js +6 -2
  7. package/esm2015/lib/components/input-text/input-text.component.js +10 -4
  8. package/esm2015/lib/components/simple-grid/base-simple-grid.component.js +61 -8
  9. package/esm2015/lib/components/simple-grid/simple-grid-column.directive.js +7 -3
  10. package/esm2015/lib/components/simple-grid/simple-grid.component.js +59 -36
  11. package/fesm2015/colijnit-corecomponents_v12.js +158 -63
  12. package/fesm2015/colijnit-corecomponents_v12.js.map +1 -1
  13. package/lib/components/input-search/input-search.component.d.ts +7 -8
  14. package/lib/components/input-search/style/_layout.scss +0 -35
  15. package/lib/components/input-search/style/_material-definition.scss +0 -6
  16. package/lib/components/input-search/style/_theme.scss +0 -2
  17. package/lib/components/input-text/input-text.component.d.ts +3 -1
  18. package/lib/components/input-text/style/_layout.scss +11 -0
  19. package/lib/components/simple-grid/base-simple-grid.component.d.ts +12 -1
  20. package/lib/components/simple-grid/simple-grid-column.directive.d.ts +4 -1
  21. package/lib/components/simple-grid/simple-grid.component.d.ts +2 -1
  22. package/lib/components/simple-grid/style/_layout.scss +26 -9
  23. package/lib/components/simple-grid/style/_material-definition.scss +1 -1
  24. package/lib/style/_variables.scss +2 -2
  25. package/package.json +1 -1
  26. package/colijnit-corecomponents_v12-12.0.28.tgz +0 -0
@@ -3992,7 +3992,7 @@ class BaseInputComponent {
3992
3992
  return node;
3993
3993
  }
3994
3994
  else if (node.children.length > 0) {
3995
- return this._findInputNode(node.children);
3995
+ this._findInputNode(node.children);
3996
3996
  }
3997
3997
  }
3998
3998
  }
@@ -6156,22 +6156,26 @@ class InputTextComponent extends BaseInputComponent {
6156
6156
  this.formUserChangeListener = formUserChangeListener;
6157
6157
  this.ngZoneWrapper = ngZoneWrapper;
6158
6158
  this.elementRef = elementRef;
6159
- this.Icons = CoreComponentsIcon;
6160
6159
  this.placeholder = "";
6161
6160
  this.type = "text";
6162
6161
  this.showClearButton = undefined;
6162
+ this.showPlaceholderOnFocus = true;
6163
6163
  this.hasOwnLabel = true;
6164
6164
  super._markAsOnPush();
6165
6165
  }
6166
6166
  showClass() {
6167
6167
  return true;
6168
6168
  }
6169
+ get hasLeftIcon() {
6170
+ return this.leftIcon !== undefined && this.leftIcon !== null;
6171
+ }
6169
6172
  }
6170
6173
  InputTextComponent.decorators = [
6171
6174
  { type: Component, args: [{
6172
6175
  selector: "co-input-text",
6173
6176
  template: `
6174
- <label [textContent]="placeholder"></label>
6177
+ <label *ngIf="showPlaceholderOnFocus || (!showPlaceholderOnFocus && !hasValue && !focused)" [textContent]="placeholder"></label>
6178
+ <co-icon *ngIf="leftIcon" class="input-text-left-icon" [icon]="leftIcon"></co-icon>
6175
6179
  <input #input
6176
6180
  [type]="type"
6177
6181
  [ngModel]="model"
@@ -6212,7 +6216,10 @@ InputTextComponent.propDecorators = {
6212
6216
  type: [{ type: Input }],
6213
6217
  showClearButton: [{ type: Input }],
6214
6218
  keyDownWhiteList: [{ type: Input }],
6219
+ showPlaceholderOnFocus: [{ type: Input }],
6220
+ leftIcon: [{ type: Input }],
6215
6221
  showClass: [{ type: HostBinding, args: ["class.co-input-text",] }],
6222
+ hasLeftIcon: [{ type: HostBinding, args: ['class.has-left-icon',] }],
6216
6223
  hasOwnLabel: [{ type: HostBinding, args: ["class.has-own-label",] }]
6217
6224
  };
6218
6225
 
@@ -6451,38 +6458,44 @@ InputRadioButtonModule.decorators = [
6451
6458
  },] }
6452
6459
  ];
6453
6460
 
6454
- class InputSearchComponent {
6455
- constructor(_elementRef) {
6456
- this._elementRef = _elementRef;
6461
+ class InputSearchComponent extends BaseInputComponent {
6462
+ constructor() {
6463
+ super(...arguments);
6457
6464
  this.searchIcon = CoreComponentsIcon.Magnifier;
6465
+ this.search = new EventEmitter();
6458
6466
  }
6459
6467
  showClass() {
6460
6468
  return true;
6461
6469
  }
6462
- ngOnDestroy() {
6463
- this._elementRef = undefined;
6464
- }
6465
- focus() {
6466
- this._elementRef.nativeElement.focus();
6470
+ handleKeyDown(event) {
6471
+ switch (event.code) {
6472
+ case 'Enter':
6473
+ event.preventDefault();
6474
+ this.search.next(this.model);
6475
+ return;
6476
+ }
6467
6477
  }
6468
6478
  }
6469
6479
  InputSearchComponent.decorators = [
6470
6480
  { type: Component, args: [{
6471
- selector: "co-input-search",
6481
+ selector: 'co-input-search',
6472
6482
  template: `
6473
- <co-icon class="search-icon" [icon]="searchIcon"></co-icon>
6474
- <input class="input" [placeholder]="placeHolderText">
6475
- `,
6483
+ <co-input-text
6484
+ [model]="model"
6485
+ [leftIcon]="searchIcon"
6486
+ [placeholder]="placeholder"
6487
+ [showPlaceholderOnFocus]="false"
6488
+ (modelChange)="modelChange.emit($event)"
6489
+ ></co-input-text>
6490
+ `,
6476
6491
  changeDetection: ChangeDetectionStrategy.OnPush,
6477
6492
  encapsulation: ViewEncapsulation.None
6478
6493
  },] }
6479
6494
  ];
6480
- InputSearchComponent.ctorParameters = () => [
6481
- { type: ElementRef }
6482
- ];
6483
6495
  InputSearchComponent.propDecorators = {
6484
- placeHolderText: [{ type: Input }],
6485
- showClass: [{ type: HostBinding, args: ["class.co-input-search",] }]
6496
+ placeholder: [{ type: Input }],
6497
+ search: [{ type: Output }],
6498
+ showClass: [{ type: HostBinding, args: ['class.co-input-search',] }]
6486
6499
  };
6487
6500
 
6488
6501
  class InputSearchModule {
@@ -6491,7 +6504,9 @@ InputSearchModule.decorators = [
6491
6504
  { type: NgModule, args: [{
6492
6505
  imports: [
6493
6506
  CommonModule,
6494
- IconModule
6507
+ IconModule,
6508
+ FormsModule,
6509
+ InputTextModule
6495
6510
  ],
6496
6511
  declarations: [InputSearchComponent],
6497
6512
  exports: [InputSearchComponent]
@@ -8034,7 +8049,8 @@ var ColumnAlign;
8034
8049
  ColumnAlign["Right"] = "right-align";
8035
8050
  })(ColumnAlign || (ColumnAlign = {}));
8036
8051
  class SimpleGridColumnDirective {
8037
- constructor() {
8052
+ constructor(elementRef) {
8053
+ this.elementRef = elementRef;
8038
8054
  this.resizable = true;
8039
8055
  this.required = false;
8040
8056
  this.readonly = false;
@@ -8083,6 +8099,9 @@ SimpleGridColumnDirective.decorators = [
8083
8099
  selector: "co-simple-grid-column"
8084
8100
  },] }
8085
8101
  ];
8102
+ SimpleGridColumnDirective.ctorParameters = () => [
8103
+ { type: ElementRef }
8104
+ ];
8086
8105
  SimpleGridColumnDirective.propDecorators = {
8087
8106
  template: [{ type: ContentChild, args: ['template',] }],
8088
8107
  editTemplate: [{ type: ContentChild, args: ['editTemplate',] }],
@@ -8103,8 +8122,9 @@ SimpleGridColumnDirective.propDecorators = {
8103
8122
 
8104
8123
  class BaseSimpleGridComponent {
8105
8124
  constructor() {
8106
- this.data = [];
8125
+ this.MIN_COLUMN_WIDTH = 60;
8107
8126
  this.dragDropEnabled = false;
8127
+ this.resizable = false;
8108
8128
  this.inlineEdit = false;
8109
8129
  this.showToolbar = false;
8110
8130
  /**
@@ -8117,27 +8137,38 @@ class BaseSimpleGridComponent {
8117
8137
  this.dblClickRow = new EventEmitter();
8118
8138
  this.saveRow = new EventEmitter();
8119
8139
  this.columns = [];
8140
+ this.headerColumns = [];
8141
+ this._data = [];
8142
+ this._prepared = false;
8120
8143
  }
8121
8144
  set content(columnComponents) {
8122
8145
  this._setColumns(columnComponents.toArray());
8146
+ this._prepareData();
8147
+ }
8148
+ set data(value) {
8149
+ this._data = value;
8150
+ this._prepareData();
8151
+ }
8152
+ get data() {
8153
+ return this._data;
8123
8154
  }
8124
8155
  set extraColumns(value) {
8125
8156
  this._setColumns(value);
8126
8157
  }
8127
8158
  handleMouseMove(event) {
8128
- if (event.buttons === 1 && this._columnForResize) {
8129
- if (!this._columnForResize.width) {
8130
- const rect = event.target.parentElement.getBoundingClientRect();
8131
- this._columnForResize.width = rect.width;
8132
- }
8133
- this._columnForResize.width += event.movementX;
8159
+ if (this.resizable && event.buttons === 1 && this._columnForResize) {
8160
+ this._columnForResize.width = this._columnForResize.originalWidth - (this._startMousePositionX - event.clientX);
8134
8161
  }
8135
8162
  }
8136
8163
  handleMouseUp(event) {
8164
+ this._startMousePositionX = undefined;
8137
8165
  this._columnForResize = undefined;
8138
8166
  }
8139
8167
  handleSizerMouseDown(event, column) {
8168
+ this._setWidthOfAllColumns();
8169
+ this._startMousePositionX = event.clientX;
8140
8170
  this._columnForResize = column;
8171
+ this._columnForResize.originalWidth = this._columnForResize.width;
8141
8172
  }
8142
8173
  handleCanDragDrop(drag, drop) {
8143
8174
  return true;
@@ -8160,10 +8191,50 @@ class BaseSimpleGridComponent {
8160
8191
  console.error(e);
8161
8192
  }
8162
8193
  }
8194
+ isSingleColumnRow(row) {
8195
+ return row.hasOwnProperty('singleColumnIndex');
8196
+ }
8197
+ singleColumnIndex(row) {
8198
+ return row.singleColumnIndex;
8199
+ }
8163
8200
  _setColumns(columns) {
8164
8201
  this.columns.push(...columns);
8165
8202
  this.columns.sort((a, b) => a.order < b.order ? -1 : 1);
8166
8203
  }
8204
+ _prepareData() {
8205
+ if (this._prepared) {
8206
+ return;
8207
+ }
8208
+ if (this.columns && this.columns.length > 0 && this.data && this.data.length > 0) {
8209
+ this.headerColumns = this.columns.filter(c => !c.singleColumn);
8210
+ let singleColumnIndex = -1;
8211
+ for (let i = 0; i < this.columns.length; i++) {
8212
+ if (this.columns[i].singleColumn) {
8213
+ singleColumnIndex = i;
8214
+ break;
8215
+ }
8216
+ }
8217
+ // first check if there's single column data
8218
+ if (singleColumnIndex > -1) {
8219
+ const field = this.columns[singleColumnIndex].field;
8220
+ for (let i = 0; i < this.data.length; i++) { // then mark row as single column row
8221
+ if (this.data[i][field] !== undefined && this.data[i][field] !== null && this.data[i][field] !== "") {
8222
+ // bit nasty to add prop, but cool for now
8223
+ this.data[i].singleColumnIndex = singleColumnIndex;
8224
+ }
8225
+ }
8226
+ }
8227
+ this._prepared = true;
8228
+ }
8229
+ }
8230
+ _setWidthOfAllColumns() {
8231
+ this.columns.forEach((column) => {
8232
+ if ((column.width === undefined || column.width === null) && column.elementRef && column.elementRef.nativeElement) {
8233
+ const rect = column.elementRef.nativeElement.getBoundingClientRect();
8234
+ column.width = rect.width;
8235
+ }
8236
+ });
8237
+ }
8167
8238
  }
8168
8239
  BaseSimpleGridComponent.decorators = [
8169
8240
  { type: Directive }
@@ -8172,6 +8243,7 @@ BaseSimpleGridComponent.propDecorators = {
8172
8243
  content: [{ type: ContentChildren, args: [SimpleGridColumnDirective,] }],
8173
8244
  data: [{ type: Input }],
8174
8245
  dragDropEnabled: [{ type: Input }],
8246
+ resizable: [{ type: Input }],
8175
8247
  inlineEdit: [{ type: Input }],
8176
8248
  showToolbar: [{ type: Input }],
8177
8249
  emitDragDrop: [{ type: Input }],
@@ -8197,6 +8269,12 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
8197
8269
  this._doubleClicked = false;
8198
8270
  this._newRow = false;
8199
8271
  }
8272
+ set headerCells(cells) {
8273
+ const headerElements = cells.toArray();
8274
+ for (let i = 0; i < headerElements.length; i++) {
8275
+ this.columns[i].elementRef = headerElements[i];
8276
+ }
8277
+ }
8200
8278
  showClass() {
8201
8279
  return true;
8202
8280
  }
@@ -8434,45 +8512,61 @@ SimpleGridComponent.decorators = [
8434
8512
  (saveClick)="validateAndSave()"
8435
8513
  (cancelClick)="cancelEditRow()"
8436
8514
  ></co-grid-toolbar>
8437
- <div class="simple-grid-column-header-wrapper">
8438
- <div class="simple-grid-column-header" *ngFor="let column of columns; let index = index"
8439
- [style.min-width.px]="column.width" [style.max-width.px]="column.width" [style.padding-right.px]="isSingleColumn(column) ? 0 : 5">
8440
- <div class="simple-grid-column-header-label" [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign"
8441
- [textContent]="column.headerText"
8442
- ></div>
8443
- <div *ngIf="column.resizable" class="simple-grid-column-sizer"
8444
- (mousedown)="handleSizerMouseDown($event, column)"
8445
- ></div>
8446
- </div>
8447
- </div>
8448
- <div cdkDropListGroup class="drop-list-group">
8449
- <div #dropList cdkDropList cdkDropListOrientation="vertical"
8450
- class="simple-grid-drag-drop-list"
8451
- [cdkDropListDisabled]="!dragDropEnabled"
8452
- [cdkDropListData]="data"
8453
- [cdkDropListEnterPredicate]="handleCanDragDrop"
8454
- (cdkDropListDropped)="handleDrop($event)"
8455
- >
8456
- <div class="simple-grid-row" [class.selected]="rowIndex === selectedRowIndex"
8457
- [class.editting]="rowIndex === editRowIndex" *ngFor="let row of data; let rowIndex = index" cdkDrag
8458
- (click)="handleClickRow($event, rowIndex)" (dblclick)="handleDblClickRow($event, rowIndex)">
8515
+ <table class="simple-grid-table">
8516
+ <colgroup>
8517
+ <col *ngFor="let column of headerColumns; let index = index" [attr.width]="column.width">
8518
+ </colgroup>
8519
+ <thead>
8520
+ <tr>
8521
+ <th scope="col" #headerCell class="simple-grid-column-header" *ngFor="let column of headerColumns; let index = index">
8522
+ <div class="simple-grid-column-header-wrapper" [class.resizable]="resizable">
8523
+ <div class="simple-grid-column-header-label" [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign"
8524
+ [textContent]="column.headerText"
8525
+ ></div>
8526
+ <div *ngIf="resizable && column.resizable" class="simple-grid-column-sizer"
8527
+ (mousedown)="handleSizerMouseDown($event, column)"
8528
+ ></div>
8529
+ </div>
8530
+ </th>
8531
+ </tr>
8532
+ </thead>
8533
+ <tbody #dropList cdkDropList cdkDropListOrientation="vertical"
8534
+ class="simple-grid-drag-drop-list"
8535
+ [cdkDropListDisabled]="!dragDropEnabled"
8536
+ [cdkDropListData]="data"
8537
+ [cdkDropListEnterPredicate]="handleCanDragDrop"
8538
+ (cdkDropListDropped)="handleDrop($event)">
8539
+ <tr class="simple-grid-row" [class.selected]="rowIndex === selectedRowIndex"
8540
+ [class.editting]="rowIndex === editRowIndex" *ngFor="let row of data; let rowIndex = index" cdkDrag
8541
+ (click)="handleClickRow($event, rowIndex)" (dblclick)="handleDblClickRow($event, rowIndex)">
8459
8542
  <co-form class="simple-grid-row-form">
8460
- <div class="simple-grid-column-cell" *ngFor="let column of columns; let columnIndex = index"
8461
- [style.min-width]="isSingleColumn(column) ? 'fit-content' : column.width" [style.max-width.px]="column.width"
8462
- [style.padding-right.px]="isSingleColumn(column) ? 0 : 5" >
8543
+ <ng-container *ngIf="isSingleColumnRow(row)">
8544
+ <td class="simple-grid-single-column-cell" [attr.colspan]="headerColumns.length">
8463
8545
  <co-simple-grid-cell
8464
- [column]="column"
8546
+ [column]="columns[singleColumnIndex(row)]"
8465
8547
  [row]="row"
8466
- [editMode]="inlineEdit && editting && rowIndex === editRowIndex && !isSingleColumn(column) && !rowContainsSingleColumn(row, columns)"
8467
- [fieldEditMode]="editCellIndex === columnIndex"
8468
- (cellClick)="handleCellClick(columnIndex)"
8548
+ [editMode]="false"
8469
8549
  ></co-simple-grid-cell>
8470
- <div *ngIf="column.resizable" class="simple-grid-column-sizer-placeholder"></div>
8471
- </div>
8550
+ </td>
8551
+ </ng-container>
8552
+ <ng-container *ngIf="!isSingleColumnRow(row)">
8553
+ <ng-container *ngFor="let column of headerColumns; let columnIndex = index">
8554
+ <td class="simple-grid-column-cell" *ngIf="columnIndex !== singleColumnIndex(row)">
8555
+ <co-simple-grid-cell
8556
+ [column]="column"
8557
+ [row]="row"
8558
+ [editMode]="inlineEdit && editting && rowIndex === editRowIndex"
8559
+ [fieldEditMode]="editCellIndex === columnIndex"
8560
+ (cellClick)="handleCellClick(columnIndex)"
8561
+ ></co-simple-grid-cell>
8562
+ <div *ngIf="column.resizable" class="simple-grid-column-sizer-placeholder"></div>
8563
+ </td>
8564
+ </ng-container>
8565
+ </ng-container>
8472
8566
  </co-form>
8473
- </div>
8474
- </div>
8475
- </div>
8567
+ </tr>
8568
+ </tbody>
8569
+ </table>
8476
8570
  `,
8477
8571
  providers: [
8478
8572
  FormMasterService
@@ -8486,6 +8580,7 @@ SimpleGridComponent.ctorParameters = () => [
8486
8580
  { type: FormMasterService }
8487
8581
  ];
8488
8582
  SimpleGridComponent.propDecorators = {
8583
+ headerCells: [{ type: ViewChildren, args: ["headerCell",] }],
8489
8584
  showClass: [{ type: HostBinding, args: ["class.co-simple-grid",] }],
8490
8585
  handleKeyDown: [{ type: HostListener, args: ['keydown', ['$event'],] }]
8491
8586
  };