@syncfusion/ej2-dropdowns 21.2.5 → 21.2.8

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.
@@ -99,7 +99,7 @@ function Search(inputVal, items, searchType, ignoreCase, dataSource, fields, typ
99
99
  dataSource.filter(function (data) {
100
100
  Array.prototype.slice.call(fieldValue).forEach(function (value) {
101
101
  /* eslint-disable security/detect-object-injection */
102
- if (type === 'object' && checkField.textContent.toString().indexOf(data[value]) !== -1 && checkField.getAttribute('data-value') === data[fields.value].toString() || type === 'string' && checkField.textContent.toString().indexOf(data) !== -1) {
102
+ if (type === 'object' && (!data.isHeader && checkField.textContent.toString().indexOf(data[value]) !== -1) && checkField.getAttribute('data-value') === data[fields.value].toString() || type === 'string' && checkField.textContent.toString().indexOf(data) !== -1) {
103
103
  filterValue = type === 'object' ? data[value] : data;
104
104
  }
105
105
  });
@@ -2604,6 +2604,7 @@ let DropDownList = class DropDownList extends DropDownBase {
2604
2604
  const index = this.isSelectCustom ? null : this.activeIndex;
2605
2605
  this.setProperties({ 'index': index, 'text': dataItem.text, 'value': dataItem.value }, true);
2606
2606
  this.detachChangeEvent(eve);
2607
+ this.dispatchEvent(this.hiddenElement, 'change');
2607
2608
  }
2608
2609
  detachChanges(value) {
2609
2610
  let items;
@@ -3274,14 +3275,12 @@ let DropDownList = class DropDownList extends DropDownBase {
3274
3275
  this.isNotSearchList = false;
3275
3276
  this.isDocumentClick = false;
3276
3277
  this.destroyPopup();
3277
- EventHandler.remove(document, 'mousedown', this.onDocumentClick);
3278
3278
  if (this.isFiltering() && this.actionCompleteData.list && this.actionCompleteData.list[0]) {
3279
3279
  this.isActive = true;
3280
3280
  this.onActionComplete(this.actionCompleteData.ulElement, this.actionCompleteData.list, null, true);
3281
3281
  }
3282
3282
  },
3283
3283
  open: () => {
3284
- EventHandler.remove(document, 'mousedown', this.onDocumentClick);
3285
3284
  EventHandler.add(document, 'mousedown', this.onDocumentClick, this);
3286
3285
  this.isPopupOpen = true;
3287
3286
  const actionList = this.actionCompleteData && this.actionCompleteData.ulElement &&
@@ -3460,9 +3459,10 @@ let DropDownList = class DropDownList extends DropDownBase {
3460
3459
  }
3461
3460
  closePopup(delay, e) {
3462
3461
  this.isTyped = false;
3463
- if (!(this.popupObj && document.body.contains(this.popupObj.element) && (this.beforePopupOpen || this.isEventCancel))) {
3462
+ if (!(this.popupObj && document.body.contains(this.popupObj.element) && this.beforePopupOpen)) {
3464
3463
  return;
3465
3464
  }
3465
+ EventHandler.remove(document, 'mousedown', this.onDocumentClick);
3466
3466
  this.isActive = false;
3467
3467
  this.filterInputObj = null;
3468
3468
  this.isDropDownClick = false;
@@ -3511,7 +3511,6 @@ let DropDownList = class DropDownList extends DropDownBase {
3511
3511
  const popupInstance = this.popupObj;
3512
3512
  const eventArgs = { popup: popupInstance, cancel: false, animation: animModel, event: e || null };
3513
3513
  this.trigger('close', eventArgs, (eventArgs) => {
3514
- this.isEventCancel = eventArgs.cancel;
3515
3514
  if (!isNullOrUndefined(this.popupObj) &&
3516
3515
  !isNullOrUndefined(this.popupObj.element.querySelector('.e-fixed-head'))) {
3517
3516
  const fixedHeader = this.popupObj.element.querySelector('.e-fixed-head');
@@ -3688,9 +3687,7 @@ let DropDownList = class DropDownList extends DropDownBase {
3688
3687
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3689
3688
  const footerCompTemp = compiledString({}, this, 'footerTemplate', this.footerTemplateId, this.isStringTemplate, null, this.footer);
3690
3689
  if (footerCompTemp && footerCompTemp.length > 0) {
3691
- for (let i = 0; i < footerCompTemp.length; i++) {
3692
- this.footer.appendChild(footerCompTemp[i]);
3693
- }
3690
+ append(footerCompTemp, this.footer);
3694
3691
  }
3695
3692
  append([this.footer], popupEle);
3696
3693
  }
@@ -3713,9 +3710,7 @@ let DropDownList = class DropDownList extends DropDownBase {
3713
3710
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3714
3711
  const headerCompTemp = compiledString({}, this, 'headerTemplate', this.headerTemplateId, this.isStringTemplate, null, this.header);
3715
3712
  if (headerCompTemp && headerCompTemp.length) {
3716
- for (let i = 0; i < headerCompTemp.length; i++) {
3717
- this.header.appendChild(headerCompTemp[i]);
3718
- }
3713
+ append(headerCompTemp, this.header);
3719
3714
  }
3720
3715
  const contentEle = popupEle.querySelector('div.e-content');
3721
3716
  popupEle.insertBefore(this.header, contentEle);
@@ -10780,10 +10775,10 @@ let MultiSelect = class MultiSelect extends DropDownBase {
10780
10775
  }
10781
10776
  }
10782
10777
  removeChipFocus() {
10783
- const elements = this.chipCollectionWrapper.querySelectorAll('span.' + CHIP$1);
10784
- const closeElements = this.chipCollectionWrapper.querySelectorAll('span.' + CHIP_CLOSE$1.split(' ')[0]);
10778
+ const elements = this.chipCollectionWrapper.querySelectorAll('span.' + CHIP$1 + '.' + CHIP_SELECTED);
10785
10779
  removeClass(elements, CHIP_SELECTED);
10786
10780
  if (Browser.isDevice) {
10781
+ const closeElements = this.chipCollectionWrapper.querySelectorAll('span.' + CHIP_CLOSE$1.split(' ')[0]);
10787
10782
  for (let index = 0; index < closeElements.length; index++) {
10788
10783
  closeElements[index].style.display = 'none';
10789
10784
  }
@@ -11042,9 +11037,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
11042
11037
  // eslint-disable-next-line
11043
11038
  let elements = compiledString({}, this, 'headerTemplate', this.headerTemplateId, this.isStringTemplate, null, this.header);
11044
11039
  if (elements && elements.length > 0) {
11045
- for (let temp = 0; temp < elements.length; temp++) {
11046
- this.header.appendChild(elements[temp]);
11047
- }
11040
+ append(elements, this.header);
11048
11041
  }
11049
11042
  if (this.mode === 'CheckBox' && this.showSelectAll) {
11050
11043
  prepend([this.header], this.popupWrapper);
@@ -11071,9 +11064,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
11071
11064
  // eslint-disable-next-line
11072
11065
  let elements = compiledString({}, this, 'footerTemplate', this.footerTemplateId, this.isStringTemplate, null, this.footer);
11073
11066
  if (elements && elements.length > 0) {
11074
- for (let temp = 0; temp < elements.length; temp++) {
11075
- this.footer.appendChild(elements[temp]);
11076
- }
11067
+ append(elements, this.footer);
11077
11068
  }
11078
11069
  append([this.footer], this.popupWrapper);
11079
11070
  EventHandler.add(this.footer, 'mousedown', this.onListMouseDown, this);
@@ -11288,25 +11279,30 @@ let MultiSelect = class MultiSelect extends DropDownBase {
11288
11279
  this.hiddenElement.innerHTML = '';
11289
11280
  }
11290
11281
  if (!isNullOrUndefined(this.value)) {
11291
- for (let index = 0; !isNullOrUndefined(this.value[index]); index++) {
11292
- const listValue = this.findListElement(((!isNullOrUndefined(this.mainList)) ? this.mainList : this.ulElement), 'li', 'data-value', this.value[index]);
11282
+ let valueLength = this.value.length;
11283
+ let hiddenElementContent = '';
11284
+ for (let index = 0; index < valueLength; index++) {
11285
+ const valueItem = this.value[index];
11286
+ const listValue = this.findListElement((!isNullOrUndefined(this.mainList) ? this.mainList : this.ulElement), 'li', 'data-value', valueItem);
11293
11287
  if (isNullOrUndefined(listValue) && !this.allowCustomValue) {
11294
11288
  this.value.splice(index, 1);
11295
11289
  index -= 1;
11290
+ valueLength -= 1;
11296
11291
  }
11297
11292
  else {
11298
11293
  if (this.listData) {
11299
- temp = this.getTextByValue(this.value[index]);
11294
+ temp = this.getTextByValue(valueItem);
11300
11295
  }
11301
11296
  else {
11302
- temp = this.value[index];
11297
+ temp = valueItem;
11303
11298
  }
11304
11299
  data += temp + delimiterChar + ' ';
11305
11300
  text.push(temp);
11306
11301
  }
11307
- if (!isNullOrUndefined(this.hiddenElement)) {
11308
- this.hiddenElement.innerHTML += '<option selected value ="' + this.value[index] + '">' + index + '</option>';
11309
- }
11302
+ hiddenElementContent += `<option selected value="${valueItem}">${index}</option>`;
11303
+ }
11304
+ if (!isNullOrUndefined(this.hiddenElement)) {
11305
+ this.hiddenElement.innerHTML = hiddenElementContent;
11310
11306
  }
11311
11307
  }
11312
11308
  this.setProperties({ text: text.toString() }, true);
@@ -14405,6 +14401,16 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
14405
14401
  }
14406
14402
  this.setSelection(items, state, !isValue);
14407
14403
  this.updateSelectedOptions();
14404
+ let selElems = [];
14405
+ for (let i = 0; i < items.length; i++) {
14406
+ const liColl = this.list.querySelectorAll('[aria-selected="true"]');
14407
+ for (let j = 0; j < liColl.length; j++) {
14408
+ if (items[i] === this.getFormattedValue(liColl[j].getAttribute('data-value'))) {
14409
+ selElems.push(liColl[j]);
14410
+ }
14411
+ }
14412
+ }
14413
+ this.triggerChange(selElems, null);
14408
14414
  }
14409
14415
  /**
14410
14416
  * Based on the state parameter, entire list item will be selected/deselected.
@@ -15599,8 +15605,11 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
15599
15605
  }
15600
15606
  if (typeof (text) === 'string') {
15601
15607
  text = text.split('\\').join('\\\\');
15608
+ li = this.list.querySelector('[data-value="' + text.replace(/"/g, '\\"') + '"]');
15609
+ }
15610
+ else {
15611
+ li = this.list.querySelector('[data-value="' + text + '"]');
15602
15612
  }
15603
- li = this.list.querySelector('[data-value="' + text + '"]');
15604
15613
  if (li) {
15605
15614
  if (this.selectionSettings.showCheckbox) {
15606
15615
  liselect = li.getElementsByClassName('e-frame')[0].classList.contains('e-check');
@@ -15636,9 +15645,12 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
15636
15645
  ele.innerHTML = '';
15637
15646
  if (this.value) {
15638
15647
  for (let i = 0, len = this.value.length; i < len; i++) {
15639
- innerHTML += '<option selected value="' + this.value[i] + '"></option>';
15648
+ innerHTML += '<option selected>' + this.value[i] + '</option>';
15640
15649
  }
15641
15650
  ele.innerHTML += innerHTML;
15651
+ for (let i = 0, len = ele.childNodes.length; i < len; i++) {
15652
+ ele.childNodes[i].setAttribute('value', this.value[i].toString());
15653
+ }
15642
15654
  }
15643
15655
  this.checkSelectAll();
15644
15656
  }
@@ -16830,7 +16842,7 @@ let Mention = class Mention extends DropDownBase {
16830
16842
  const selectedNodePosition = this.getTriggerCharPosition();
16831
16843
  globalRange = this.range;
16832
16844
  range = document.createRange();
16833
- if (this.getTextRange() && this.getTextRange().lastIndexOf(this.mentionChar) !== -1 && this.isTyped) {
16845
+ if (this.getTextRange() && this.getTextRange().lastIndexOf(this.mentionChar) !== -1) {
16834
16846
  range.setStart(globalRange.startContainer, selectedNodePosition);
16835
16847
  range.setEnd(globalRange.startContainer, selectedNodePosition);
16836
16848
  }