@syncfusion/ej2-dropdowns 21.1.39 → 21.2.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.
@@ -414,6 +414,9 @@ let DropDownBase = class DropDownBase extends Component {
414
414
  const noDataCompTemp = compiledString({}, this, templateName, templateId, this.isStringTemplate, null, ele);
415
415
  if (noDataCompTemp && noDataCompTemp.length > 0) {
416
416
  for (let i = 0; i < noDataCompTemp.length; i++) {
417
+ if (this.getModuleName() === 'listbox' && templateName === 'noRecordsTemplate') {
418
+ noDataCompTemp[i].classList.add('e-list-nr-template');
419
+ }
417
420
  ele.appendChild(noDataCompTemp[i]);
418
421
  }
419
422
  }
@@ -454,7 +457,13 @@ let DropDownBase = class DropDownBase extends Component {
454
457
  }
455
458
  getFormattedValue(value) {
456
459
  if (this.listData && this.listData.length) {
457
- const item = this.typeOfData(this.listData);
460
+ let item;
461
+ if (this.properties.allowCustomValue && this.properties.value && this.properties.value instanceof Array && this.properties.value.length > 0) {
462
+ item = this.typeOfData(this.properties.value);
463
+ }
464
+ else {
465
+ item = this.typeOfData(this.listData);
466
+ }
458
467
  if (typeof getValue((this.fields.value ? this.fields.value : 'value'), item.item) === 'number'
459
468
  || item.typeof === 'number') {
460
469
  return parseFloat(value);
@@ -4486,6 +4495,7 @@ let DropDownTree = class DropDownTree extends Component {
4486
4495
  this.isClicked = false;
4487
4496
  // Specifies if the checkAll method has been called
4488
4497
  this.isCheckAllCalled = false;
4498
+ this.isFromFilterChange = false;
4489
4499
  }
4490
4500
  /**
4491
4501
  * Get the properties to be maintained in the persisted state.
@@ -4696,6 +4706,7 @@ let DropDownTree = class DropDownTree extends Component {
4696
4706
  }
4697
4707
  }
4698
4708
  filterHandler(value, event) {
4709
+ this.isFromFilterChange = true;
4699
4710
  if (!this.isFilteredData) {
4700
4711
  this.treeData = this.treeObj.getTreeData();
4701
4712
  }
@@ -5170,7 +5181,7 @@ let DropDownTree = class DropDownTree extends Component {
5170
5181
  case 'moveDown':
5171
5182
  let focusedElement = this.treeObj.element.querySelector('li');
5172
5183
  focusedElement.focus();
5173
- addClass([focusedElement], ['e-hover', 'e-node-focus']);
5184
+ addClass([focusedElement], ['e-node-focus']);
5174
5185
  }
5175
5186
  }
5176
5187
  });
@@ -5845,7 +5856,7 @@ let DropDownTree = class DropDownTree extends Component {
5845
5856
  && this.treeItems.length > 0)) {
5846
5857
  let focusedElement = this.treeObj.element.querySelector('li');
5847
5858
  focusedElement.focus();
5848
- addClass([focusedElement], ['e-hover', 'e-node-focus']);
5859
+ addClass([focusedElement], ['e-node-focus']);
5849
5860
  }
5850
5861
  if (this.checkSelectAll && this.checkBoxElement) {
5851
5862
  const wrap = closest(this.checkBoxElement, '.' + CHECKBOXWRAP);
@@ -5964,7 +5975,7 @@ let DropDownTree = class DropDownTree extends Component {
5964
5975
  this.isDocumentClick = false;
5965
5976
  e.preventDefault();
5966
5977
  }
5967
- else if (this.inputWrapper != null && !this.inputWrapper.contains(target) && this.inputFocus && !isFilter) {
5978
+ else if (!isNullOrUndefined(this.inputWrapper) && !this.inputWrapper.contains(target) && this.inputFocus && !isFilter) {
5968
5979
  this.focusOut(e);
5969
5980
  }
5970
5981
  }
@@ -6383,7 +6394,8 @@ let DropDownTree = class DropDownTree extends Component {
6383
6394
  }
6384
6395
  setMultiSelectValue(newValues) {
6385
6396
  if (!this.isFilteredData) {
6386
- this.setProperties({ value: newValues }, true);
6397
+ this.setProperties({ value: this.isFromFilterChange && newValues && newValues.length == 0 ? this.value : newValues }, true);
6398
+ this.isFromFilterChange = false;
6387
6399
  if (newValues && newValues.length !== 0 && !this.showCheckBox) {
6388
6400
  this.treeObj.selectedNodes = this.value.slice();
6389
6401
  this.treeObj.dataBind();
@@ -9129,7 +9141,9 @@ let MultiSelect = class MultiSelect extends DropDownBase {
9129
9141
  this.trigger('open', eventArgs, (eventArgs) => {
9130
9142
  if (!eventArgs.cancel) {
9131
9143
  this.focusAtFirstListItem();
9132
- document.body.appendChild(this.popupObj.element);
9144
+ if (this.popupObj) {
9145
+ document.body.appendChild(this.popupObj.element);
9146
+ }
9133
9147
  if (this.mode === 'CheckBox' && this.enableGroupCheckBox && !isNullOrUndefined(this.fields.groupBy)) {
9134
9148
  this.updateListItems(this.list.querySelectorAll('li.e-list-item'), this.mainList.querySelectorAll('li.e-list-item'));
9135
9149
  }
@@ -9138,7 +9152,9 @@ let MultiSelect = class MultiSelect extends DropDownBase {
9138
9152
  }
9139
9153
  this.refreshPopup();
9140
9154
  this.renderReactTemplates();
9141
- this.popupObj.show(eventArgs.animation, (this.zIndex === 1000) ? this.element : null);
9155
+ if (this.popupObj) {
9156
+ this.popupObj.show(eventArgs.animation, (this.zIndex === 1000) ? this.element : null);
9157
+ }
9142
9158
  attributes(this.inputElement, { 'aria-expanded': 'true', 'aria-owns': this.inputElement.id + '_options' });
9143
9159
  this.updateAriaActiveDescendant();
9144
9160
  if (this.isFirstClick) {
@@ -10311,6 +10327,9 @@ let MultiSelect = class MultiSelect extends DropDownBase {
10311
10327
  this.refreshSelection();
10312
10328
  }
10313
10329
  }
10330
+ else if (!isNullOrUndefined(this.fields.groupBy) && this.value && this.value.length) {
10331
+ this.refreshSelection();
10332
+ }
10314
10333
  }
10315
10334
  removeSelectedChip(e) {
10316
10335
  const selectedElem = this.chipCollectionWrapper.querySelector('span.' + CHIP_SELECTED);
@@ -11919,7 +11938,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
11919
11938
  overAllContainer = this.componentWrapper.offsetWidth -
11920
11939
  parseInt(window.getComputedStyle(this.componentWrapper).paddingLeft, 10) -
11921
11940
  parseInt(window.getComputedStyle(this.componentWrapper).paddingRight, 10);
11922
- if ((wrapperleng + downIconWidth + this.clearIconWidth) >= overAllContainer) {
11941
+ if ((wrapperleng + downIconWidth + this.clearIconWidth) > overAllContainer) {
11923
11942
  if (tempData !== undefined && tempData !== '') {
11924
11943
  temp = tempData;
11925
11944
  index = tempIndex + 1;
@@ -11928,7 +11947,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
11928
11947
  remaining = this.value.length - index;
11929
11948
  wrapperleng = this.viewWrapper.offsetWidth +
11930
11949
  parseInt(window.getComputedStyle(this.viewWrapper).paddingRight, 10);
11931
- while (((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) >= overAllContainer) && wrapperleng !== 0
11950
+ while (((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) > overAllContainer) && wrapperleng !== 0
11932
11951
  && this.viewWrapper.innerHTML !== '') {
11933
11952
  const textArr = [];
11934
11953
  this.viewWrapper.innerHTML = textArr.join(this.delimiterChar);
@@ -11938,7 +11957,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
11938
11957
  }
11939
11958
  break;
11940
11959
  }
11941
- else if ((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) < overAllContainer) {
11960
+ else if ((wrapperleng + remainSize + downIconWidth + this.clearIconWidth) <= overAllContainer) {
11942
11961
  tempData = data;
11943
11962
  tempIndex = index;
11944
11963
  }
@@ -14060,17 +14079,26 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
14060
14079
  const scrollMoved = 36;
14061
14080
  let scrollHeight = 10;
14062
14081
  if (this.itemTemplate && args.target) {
14063
- scrollHeight = args.target.scrollHeight;
14082
+ if (args.target && args.target.closest('.e-list-item')) {
14083
+ scrollHeight = args.target.closest('.e-list-item').scrollHeight;
14084
+ }
14085
+ else {
14086
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14087
+ const listItem = args.element.querySelector('.e-list-item');
14088
+ if (listItem) {
14089
+ scrollHeight = listItem.scrollHeight;
14090
+ }
14091
+ }
14064
14092
  }
14065
14093
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14066
14094
  const event = args.event;
14067
14095
  let wrapper;
14068
14096
  if (args.target && (args.target.classList.contains('e-listbox-wrapper') || args.target.classList.contains('e-list-item')
14069
- || (args.target.parentElement && args.target.parentElement.classList.contains('e-list-item'))
14070
- || args.target.classList.contains('e-filter-parent') || args.target.classList.contains('e-input-group'))) {
14097
+ || args.target.classList.contains('e-filter-parent') || args.target.classList.contains('e-input-group')
14098
+ || args.target.closest('.e-list-item'))) {
14071
14099
  if (args.target.classList.contains('e-list-item') || args.target.classList.contains('e-filter-parent')
14072
- || (args.target.parentElement && args.target.parentElement.classList.contains('e-list-item'))
14073
- || args.target.classList.contains('e-input-group')) {
14100
+ || args.target.classList.contains('e-input-group')
14101
+ || args.target.closest('.e-list-item')) {
14074
14102
  wrapper = args.target.closest('.e-listbox-wrapper');
14075
14103
  }
14076
14104
  else {
@@ -14355,6 +14383,13 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
14355
14383
  * @returns {void}
14356
14384
  */
14357
14385
  selectItems(items, state = true, isValue) {
14386
+ if (state && !this.selectionSettings.showCheckbox && this.selectionSettings.mode === 'Single') {
14387
+ this.getSelectedItems().forEach((li) => {
14388
+ li.classList.remove('e-active');
14389
+ li.removeAttribute('aria-selected');
14390
+ removeClass([li], cssClass.selected);
14391
+ });
14392
+ }
14358
14393
  this.setSelection(items, state, !isValue);
14359
14394
  this.updateSelectedOptions();
14360
14395
  }