@colijnit/corecomponents_v12 12.1.2 → 12.1.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.
@@ -4926,7 +4926,7 @@
4926
4926
  CoDialogComponent.decorators = [
4927
4927
  { type: i0.Component, args: [{
4928
4928
  selector: 'co-dialog',
4929
- template: "\n <div class=\"co-dialog-overlay\" (click)=\"handleOverlayClick($event)\"></div>\n <div class=\"co-dialog-wrapper\" [ngClass]=\"customCssClass ? customCssClass : undefined\" @showHideDialog>\n <div class=\"dialog-header\" *ngIf=\"!borderless\">\n <div class=\"dialog-header-caption\" *ngIf=\"headerTemplate\">\n <ng-container [ngTemplateOutlet]=\"headerTemplate\"></ng-container>\n </div>\n <div class=\"dialog-close-button\" *ngIf=\"showCloseIcon\" (click)=\"handleCloseDialog($event)\">\n <co-icon [icon]=\"icons.Cancel\"></co-icon>\n </div>\n </div>\n <div class=\"dialog-content\" [ngClass]=\"customCssClass ? customCssClass : undefined\">\n <ng-content></ng-content>\n </div>\n <div class=\"dialog-footer\" *ngIf=\"footerTemplate\">\n <ng-container [ngTemplateOutlet]=\"footerTemplate\"></ng-container>\n </div>\n </div>\n ",
4929
+ template: "\n <div class=\"co-dialog-overlay\" (click)=\"handleOverlayClick($event)\"></div>\n <div class=\"co-dialog-wrapper\" [ngClass]=\"customCssClass ? customCssClass : undefined\" @showHideDialog>\n <div class=\"dialog-header\" *ngIf=\"!borderless\">\n <div class=\"dialog-header-caption\" *ngIf=\"headerTemplate\">\n <ng-container [ngTemplateOutlet]=\"headerTemplate\"></ng-container>\n </div>\n <div class=\"dialog-close-button\" *ngIf=\"showCloseIcon\" (click)=\"handleCloseDialog($event)\">\n <co-icon [icon]=\"icons.CrossSkinny\"></co-icon>\n </div>\n </div>\n <div class=\"dialog-content\" [ngClass]=\"customCssClass ? customCssClass : undefined\">\n <ng-content></ng-content>\n </div>\n <div class=\"dialog-footer\" *ngIf=\"footerTemplate\">\n <ng-container [ngTemplateOutlet]=\"footerTemplate\"></ng-container>\n </div>\n </div>\n ",
4930
4930
  animations: [
4931
4931
  animations.trigger('showHideCoDialog', [
4932
4932
  animations.transition('void => *', [
@@ -7094,6 +7094,9 @@
7094
7094
  this.toggleCalendar();
7095
7095
  }
7096
7096
  };
7097
+ InputDateRangePickerComponent.prototype.clearDate = function (index) {
7098
+ this.model[index] = undefined;
7099
+ };
7097
7100
  InputDateRangePickerComponent.prototype.toggleCalendar = function () {
7098
7101
  var _this = this;
7099
7102
  if (this.readonly) {
@@ -7152,7 +7155,7 @@
7152
7155
  InputDateRangePickerComponent.decorators = [
7153
7156
  { type: i0.Component, args: [{
7154
7157
  selector: 'co-input-date-range',
7155
- template: "\n <div class=\"inputs-wrapper\" overlayParent #parentForOverlay=\"overlayParent\">\n <co-input-text class=\"no-focus-line custom-height\"\n [(model)]=\"firstDateAsString\"\n [noClickFocus]=\"true\"\n [pattern]=\"'yyyy-MM-dd'\"\n [type]=\"'date'\"\n [leftIcon]=\"leftIcon\"\n [leftIconData]=\"leftIconData\"\n [placeholder]=\"placeholder\"\n (blur)=\"handleFirstDateChanged(firstDateAsString)\"\n ></co-input-text>\n <co-input-text class=\"no-focus-line custom-height\"\n [(model)]= \"secondDateAsString\"\n [noClickFocus]=\"true\"\n [pattern]=\"'yyyy-MM-dd'\"\n [type]=\"'date'\"\n [rightIcon]=\"rightIcon\"\n (rightIconClick)=\"toggleCalendar()\"\n (blur)=\"handleSecondDateChanged(secondDateAsString)\"\n ></co-input-text>\n </div>\n ",
7158
+ template: "\n <div class=\"inputs-wrapper\" overlayParent #parentForOverlay=\"overlayParent\">\n <co-input-text class=\"no-focus-line custom-height\"\n [(model)]=\"firstDateAsString\"\n [noClickFocus]=\"true\"\n [pattern]=\"'yyyy-MM-dd'\"\n [type]=\"'date'\"\n [leftIcon]=\"leftIcon\"\n [leftIconData]=\"leftIconData\"\n [placeholder]=\"placeholder\"\n (blur)=\"handleFirstDateChanged(firstDateAsString)\"\n (clearIconClick)=\"clearDate(0)\"\n ></co-input-text>\n <co-input-text class=\"no-focus-line custom-height\"\n [(model)]= \"secondDateAsString\"\n [noClickFocus]=\"true\"\n [pattern]=\"'yyyy-MM-dd'\"\n [type]=\"'date'\"\n [rightIcon]=\"rightIcon\"\n (rightIconClick)=\"toggleCalendar()\"\n (blur)=\"handleSecondDateChanged(secondDateAsString)\"\n (clearIconClick)=\"clearDate(1)\"\n ></co-input-text>\n </div>\n ",
7156
7159
  providers: [
7157
7160
  OverlayService,
7158
7161
  {
@@ -10808,7 +10811,6 @@
10808
10811
  this._collection = [];
10809
10812
  this._searchTerm = '';
10810
10813
  this._lovItems = [];
10811
- this._activeIndex = -1;
10812
10814
  }
10813
10815
  Object.defineProperty(ListOfValuesPopupComponent.prototype, "lovItems", {
10814
10816
  set: function (children) {
@@ -10850,6 +10852,8 @@
10850
10852
  },
10851
10853
  set: function (value) {
10852
10854
  this._searchTerm = value;
10855
+ this.model = undefined;
10856
+ this.highLightModel = undefined;
10853
10857
  this.filterViewModels();
10854
10858
  },
10855
10859
  enumerable: false,
@@ -10859,7 +10863,6 @@
10859
10863
  var _this = this;
10860
10864
  if (this.model) {
10861
10865
  if (!this.multiselect) {
10862
- this._activeIndex = this.viewModelsMain.findIndex(function (v) { return v.model === _this.model; });
10863
10866
  this._scrollIntoView();
10864
10867
  }
10865
10868
  else {
@@ -10876,53 +10879,92 @@
10876
10879
  }
10877
10880
  }
10878
10881
  };
10882
+ ListOfValuesPopupComponent.prototype.handleInputKeyDown = function (event) {
10883
+ if (event) {
10884
+ switch (event.code) {
10885
+ case KeyboardKey.Down:
10886
+ this.selectNextOption();
10887
+ return false;
10888
+ case KeyboardKey.Up:
10889
+ this.selectNextOption(true);
10890
+ return false;
10891
+ case KeyboardKey.SpaceBar:
10892
+ if (this.highLightModel) {
10893
+ this.selectViewModel(this.highLightModel, false);
10894
+ return false;
10895
+ }
10896
+ }
10897
+ }
10898
+ };
10879
10899
  ListOfValuesPopupComponent.prototype.filterViewModels = function () {
10880
10900
  if (!this.collection) {
10881
10901
  return;
10882
10902
  }
10883
10903
  this._prepareViewModels();
10884
10904
  };
10885
- ListOfValuesPopupComponent.prototype.selectViewModel = function (viewModel) {
10886
- var idx = this.viewModelsMain.findIndex(function (vm) { return vm === viewModel; });
10905
+ ListOfValuesPopupComponent.prototype.selectViewModel = function (viewModel, closePopup) {
10906
+ if (closePopup === void 0) { closePopup = true; }
10887
10907
  if (!this.multiselect) {
10888
- this._activeIndex = idx;
10889
- this.selectOptionByActiveIndex();
10908
+ this.selectModelByViewModel(viewModel, closePopup);
10890
10909
  }
10891
10910
  else {
10892
- this.viewModelsMain[idx].checked = !this.viewModelsMain[idx].checked;
10911
+ var idx = this.viewModels.findIndex(function (vm) { return vm === viewModel; });
10912
+ this.viewModels[idx].checked = !this.viewModels[idx].checked;
10893
10913
  this.selectOptions();
10894
10914
  }
10895
10915
  };
10896
- // for single select
10897
- ListOfValuesPopupComponent.prototype.selectOptionByActiveIndex = function (closePopup) {
10916
+ ListOfValuesPopupComponent.prototype.selectModelByViewModel = function (viewModel, closePopup) {
10898
10917
  if (closePopup === void 0) { closePopup = true; }
10899
- if (this._activeIndex > -1) {
10900
- this.model = this.viewModelsMain[this._activeIndex].model;
10901
- this.modelChange.emit(this.model);
10902
- this._scrollIntoView();
10903
- if (closePopup) {
10904
- this.closePopup.emit();
10918
+ this.model = this.viewModelsMain.find(function (vm) { return vm === viewModel; }).model;
10919
+ this.modelChange.emit(this.model);
10920
+ this._scrollIntoView();
10921
+ if (closePopup) {
10922
+ this.closePopup.emit();
10923
+ }
10924
+ };
10925
+ // for single select
10926
+ ListOfValuesPopupComponent.prototype.selectOptionAndClosePopup = function () {
10927
+ var _this = this;
10928
+ if (!this.model && this.searchTerm) {
10929
+ var wishModel = this.viewModelsMain.find(function (vmm) { return vmm.model[_this.displayField] === _this.searchTerm; });
10930
+ if (wishModel) {
10931
+ this.selectViewModel(wishModel);
10932
+ }
10933
+ else {
10934
+ this.model = undefined;
10935
+ this.modelChange.emit(this.model);
10936
+ this.searchTerm = '';
10905
10937
  }
10906
10938
  }
10939
+ else {
10940
+ this.closePopup.emit();
10941
+ }
10907
10942
  };
10908
10943
  // for multi select
10909
10944
  ListOfValuesPopupComponent.prototype.selectOptions = function () {
10910
10945
  this.model = this.viewModelsMain.filter(function (v) { return v.checked; }).map(function (m) { return m.model; });
10911
10946
  this.modelChange.emit(this.model);
10912
10947
  };
10913
- ListOfValuesPopupComponent.prototype.selectNextOption = function () {
10914
- if (!this._lovItems || this._activeIndex >= this._lovItems.length - 1) {
10915
- return;
10948
+ ListOfValuesPopupComponent.prototype.selectNextOption = function (back) {
10949
+ var _this = this;
10950
+ if (back === void 0) { back = false; }
10951
+ var nextModel;
10952
+ if (!this.highLightModel) {
10953
+ nextModel = this.viewModels[back ? this.viewModels.length - 1 : 0];
10916
10954
  }
10917
- this._activeIndex++;
10918
- this.selectOptionByActiveIndex(false);
10919
- };
10920
- ListOfValuesPopupComponent.prototype.selectPreviousOption = function () {
10921
- if (this._activeIndex <= 0) {
10922
- return;
10955
+ else {
10956
+ var currentViewModelIdx = this.viewModels.findIndex(function (vm) { return vm === _this.highLightModel; });
10957
+ if (back) {
10958
+ nextModel = this.viewModels[currentViewModelIdx <= 0 ? this.viewModels.length - 1 : currentViewModelIdx - 1];
10959
+ }
10960
+ else {
10961
+ nextModel = this.viewModels[currentViewModelIdx >= this.viewModels.length - 1 ? 0 : currentViewModelIdx + 1];
10962
+ }
10963
+ }
10964
+ this.highLightModel = nextModel;
10965
+ if (!this.multiselect) {
10966
+ this.selectViewModel(nextModel, false);
10923
10967
  }
10924
- this._activeIndex--;
10925
- this.selectOptionByActiveIndex(false);
10926
10968
  };
10927
10969
  ListOfValuesPopupComponent.prototype._prepareViewModelsMain = function () {
10928
10970
  var _this = this;
@@ -10937,10 +10979,12 @@
10937
10979
  this.viewModels = this.viewModelsMain.filter(function (vm) { return vm.model[_this.displayField] && vm.model[_this.displayField].toLowerCase().includes(_this.searchTerm ? _this.searchTerm.toLowerCase() : ""); });
10938
10980
  };
10939
10981
  ListOfValuesPopupComponent.prototype._scrollIntoView = function () {
10940
- if (!this._lovItems || this._lovItems.length <= 0 || this._activeIndex < 0 || !this._lovItems[this._activeIndex] || !this.dropDownList) {
10982
+ var _this = this;
10983
+ var activeIndex = this.viewModels.findIndex(function (vmm) { return vmm === _this.highLightModel; });
10984
+ if (!this._lovItems || this._lovItems.length <= 0 || activeIndex < 0 || !this.dropDownList) {
10941
10985
  return;
10942
10986
  }
10943
- var activeItem = this._lovItems[this._activeIndex].nativeElement ? this._lovItems[this._activeIndex].nativeElement : undefined;
10987
+ var activeItem = this._lovItems[activeIndex].nativeElement ? this._lovItems[activeIndex].nativeElement : undefined;
10944
10988
  var scrollParent = this.dropDownList.nativeElement ? this.dropDownList.nativeElement : undefined;
10945
10989
  this._scrollActiveItemIntoView(activeItem, scrollParent);
10946
10990
  };
@@ -10964,7 +11008,7 @@
10964
11008
  ListOfValuesPopupComponent.decorators = [
10965
11009
  { type: i0.Component, args: [{
10966
11010
  selector: 'co-list-of-values-popup',
10967
- template: "\n <div class=\"lov-options\" #dropDownList [overlay]=\"parentForOverlay\" [inheritWidth]=\"true\" [ngClass]=\"customCssClass\" id=\"lov-popup\"\n [tabIndex]=\"-1\" role=\"listbox\"\n (clickOutside)=\"closePopup.emit($event)\">\n <co-input-search *ngIf=\"multiselect\" [(model)]=\"searchTerm\" (modelChange)=\"filterViewModels()\" [placeholder]=\"searchPlaceholder\"></co-input-search>\n <ul class=\"dropdown-list\">\n <li #lovItem *ngFor=\"let viewModel of viewModels; let index = index\" [class.selected]=\"viewModel.model === model\"\n (click)=\"selectViewModel(viewModel)\" role=\"option\">\n <ng-container *ngIf=\"!multiselect\">\n <span class=\"lov-options-text\" [textContent]=\"viewModel.model[displayField]\"></span>\n </ng-container>\n <ng-container *ngIf=\"multiselect\">\n <co-input-checkbox [model]=\"viewModel.checked\" (modelChange)=\"selectViewModel(viewModel)\"></co-input-checkbox>\n <span class=\"lov-options-text\" [textContent]=\"viewModel.model[displayField]\"></span>\n </ng-container>\n </li>\n </ul>\n </div>\n ",
11011
+ template: "\n <div class=\"lov-options\" [overlay]=\"parentForOverlay\" [inheritWidth]=\"true\" [ngClass]=\"customCssClass\" id=\"lov-popup\"\n [tabIndex]=\"-1\" role=\"listbox\"\n (clickOutside)=\"closePopup.emit($event)\">\n <co-input-search *ngIf=\"multiselect\" \n [(model)]=\"searchTerm\"\n [placeholder]=\"searchPlaceholder\"\n (keydown)=\"handleInputKeyDown($event)\"\n (modelChange)=\"filterViewModels()\"></co-input-search>\n <ul class=\"dropdown-list\" #dropDownList>\n <li #lovItem *ngFor=\"let viewModel of viewModels; let index = index\" [class.selected]=\"viewModel === highLightModel\"\n (click)=\"selectViewModel(viewModel, false)\" role=\"option\">\n <ng-container *ngIf=\"!multiselect\">\n <span class=\"lov-options-text\" [textContent]=\"viewModel.model[displayField]\"></span>\n </ng-container>\n <ng-container *ngIf=\"multiselect\">\n <co-input-checkbox [model]=\"viewModel.checked\" (modelChange)=\"selectViewModel(viewModel, false)\"></co-input-checkbox>\n <span class=\"lov-options-text\" [textContent]=\"viewModel.model[displayField]\"></span>\n </ng-container>\n </li>\n </ul>\n </div>\n ",
10968
11012
  encapsulation: i0.ViewEncapsulation.None
10969
11013
  },] }
10970
11014
  ];
@@ -11031,6 +11075,7 @@
11031
11075
  if (this._lovPopupComponentRef) {
11032
11076
  this._lovPopupComponentRef.instance.searchTerm = model;
11033
11077
  }
11078
+ this.selectedModel = model;
11034
11079
  };
11035
11080
  ListOfValuesComponent.prototype.handleInputKeyDown = function (event) {
11036
11081
  if (event) {
@@ -11044,13 +11089,13 @@
11044
11089
  this._lovPopupComponentRef.instance.selectNextOption();
11045
11090
  return false;
11046
11091
  case KeyboardKey.Up:
11047
- this._lovPopupComponentRef.instance.selectPreviousOption();
11092
+ this._lovPopupComponentRef.instance.selectNextOption(true);
11048
11093
  return false;
11049
11094
  case KeyboardKey.Enter:
11050
- this._lovPopupComponentRef.instance.selectOptionByActiveIndex();
11095
+ this._lovPopupComponentRef.instance.selectOptionAndClosePopup();
11051
11096
  return false;
11052
11097
  case KeyboardKey.Tab:
11053
- this._lovPopupComponentRef.instance.selectOptionByActiveIndex();
11098
+ this._lovPopupComponentRef.instance.selectOptionAndClosePopup();
11054
11099
  }
11055
11100
  }
11056
11101
  }
@@ -11100,11 +11145,13 @@
11100
11145
  };
11101
11146
  ListOfValuesComponent.prototype.optionChosen = function (option) {
11102
11147
  var _this = this;
11103
- if (this.multiselect) {
11104
- this.selectedModels = option.map(function (o) { return o[_this.displayField]; });
11105
- }
11106
- else {
11107
- this.selectedModel = option[this.displayField];
11148
+ if (option) {
11149
+ if (this.multiselect) {
11150
+ this.selectedModels = option.map(function (o) { return o[_this.displayField]; });
11151
+ }
11152
+ else {
11153
+ this.selectedModel = option[this.displayField];
11154
+ }
11108
11155
  }
11109
11156
  this.model = option;
11110
11157
  this.modelChange.emit(this.model);
@@ -11115,6 +11162,19 @@
11115
11162
  this._lovPopupComponentRef = undefined;
11116
11163
  this.focused = false;
11117
11164
  };
11165
+ ListOfValuesComponent.prototype.checkModel = function () {
11166
+ var _this = this;
11167
+ if (!this.multiselect && this.selectedModel && this.collection) {
11168
+ var model = this.collection.find(function (c) { return c[_this.displayField] === _this.selectedModel; });
11169
+ if (model) {
11170
+ this.model = model;
11171
+ }
11172
+ else {
11173
+ this.model = undefined;
11174
+ }
11175
+ this.modelChange.emit(this.model);
11176
+ }
11177
+ };
11118
11178
  ListOfValuesComponent.prototype._setSelectedModel = function () {
11119
11179
  var _this = this;
11120
11180
  if (this.multiselect) {
@@ -11142,7 +11202,7 @@
11142
11202
  ListOfValuesComponent.decorators = [
11143
11203
  { type: i0.Component, args: [{
11144
11204
  selector: 'co-list-of-values',
11145
- template: "\n <co-input-text aria-haspopup=\"listbox\" [attr.aria-expanded]=\"isSelectOpen\" aria-controls=\"lov-popup\" role=\"combobox\"\n class=\"no-focus-line\"\n overlayParent\n #parentForOverlay=\"overlayParent\" type=\"text\" [id]=\"label\"\n [model]=\"multiselect ? selectedModels : selectedModel\"\n [placeholder]=\"label\"\n [readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [required]=\"required\"\n [noClickFocus]=\"false\"\n [leftIconData]=\"leftIconData\"\n [rightIcon]=\"isSelectOpen ? icons.ChevronUpRegular : icons.ChevronDownRegular\"\n [showClearButton]=\"true\"\n [useContent]=\"multiselect\"\n (modelChange)=\"handleInputModelChange($event)\"\n (click)=\"openPopup()\"\n (rightIconClick)=\"toggleSelect()\"\n (keydown)=\"handleInputKeyDown($event)\"\n (clearIconClick)=\"clearModel($event)\"\n >\n </co-input-text>\n <ng-container *ngIf=\"multiselect\">\n <div class=\"multiselect-chips-wrapper\">\n <div class=\"chips\" *ngFor=\"let chip of model\">\n <span class=\"chips-description\" [textContent]=\"chip[displayField]\"></span>\n <co-icon class=\"remove-chip-icon\" [icon]=\"icons.CrossSkinny\" (click)=\"removeOptionFromModel(chip)\"></co-icon>\n </div>\n </div>\n </ng-container>\n ",
11205
+ template: "\n <co-input-text aria-haspopup=\"listbox\" [attr.aria-expanded]=\"isSelectOpen\" aria-controls=\"lov-popup\" role=\"combobox\"\n class=\"no-focus-line\"\n overlayParent\n #parentForOverlay=\"overlayParent\" type=\"text\" [id]=\"label\"\n [model]=\"multiselect ? selectedModels : selectedModel\"\n [placeholder]=\"label\"\n [readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [required]=\"required\"\n [noClickFocus]=\"false\"\n [leftIconData]=\"leftIconData\"\n [rightIcon]=\"isSelectOpen ? icons.ChevronUpRegular : icons.ChevronDownRegular\"\n [showClearButton]=\"true\"\n [useContent]=\"multiselect\"\n (modelChange)=\"handleInputModelChange($event)\"\n (click)=\"openPopup()\"\n (rightIconClick)=\"toggleSelect()\"\n (keydown)=\"handleInputKeyDown($event)\"\n (clearIconClick)=\"clearModel($event)\"\n (blur)=\"checkModel()\"\n >\n </co-input-text>\n <ng-container *ngIf=\"multiselect\">\n <div class=\"multiselect-chips-wrapper\">\n <div class=\"chips\" *ngFor=\"let chip of model\">\n <span class=\"chips-description\" [textContent]=\"chip[displayField]\"></span>\n <co-icon class=\"remove-chip-icon\" [icon]=\"icons.CrossSkinny\" (click)=\"removeOptionFromModel(chip)\"></co-icon>\n </div>\n </div>\n </ng-container>\n ",
11146
11206
  providers: [
11147
11207
  OverlayService
11148
11208
  ],