@syncfusion/ej2-dropdowns 32.2.7 → 32.2.9

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.
@@ -368,7 +368,7 @@ class VirtualScroll {
368
368
  if (this.component === 'combobox') {
369
369
  let totalData = 0;
370
370
  if (this.parent.dataSource instanceof DataManager) {
371
- totalData = this.parent.remoteDataCount;
371
+ totalData = this.parent.dataSource.dataSource.json.length;
372
372
  }
373
373
  else if (this.parent.dataSource && this.parent.dataSource.length > 0) {
374
374
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -5530,7 +5530,7 @@ let DropDownList = class DropDownList extends DropDownBase {
5530
5530
  });
5531
5531
  return checkField;
5532
5532
  }
5533
- checkAndFetchItemData(list, value, checkField) {
5533
+ checkAndFetchItemData(list, value, checkField, isOffline = false) {
5534
5534
  const fieldValue = this.fields.value.split('.');
5535
5535
  let checkVal = list.some((x) => isNullOrUndefined(x[checkField]) && fieldValue.length > 1 ?
5536
5536
  this.checkFieldValue(x, fieldValue) === value : x[checkField] === value);
@@ -5539,27 +5539,66 @@ let DropDownList = class DropDownList extends DropDownBase {
5539
5539
  this.checkFieldValue(x, fieldValue) === value : x[checkField] === value);
5540
5540
  }
5541
5541
  if (!checkVal && this.dataSource instanceof DataManager) {
5542
- (this.dataSource).executeQuery(this.getQuery(this.query).where(new Predicate(checkField, 'equal', value)))
5543
- .then((e) => {
5544
- if (e.result.length > 0) {
5545
- if (!this.enableVirtualization) {
5546
- this.addItem(e.result, list.length);
5542
+ if (isOffline) {
5543
+ this.searchOfflineData(value, checkField);
5544
+ }
5545
+ else {
5546
+ (this.dataSource).executeQuery(this.getQuery(this.query).where(new Predicate(checkField, 'equal', value)))
5547
+ .then((e) => {
5548
+ if (e.result.length > 0) {
5549
+ if (!this.enableVirtualization) {
5550
+ this.addItem(e.result, list.length);
5551
+ }
5552
+ else {
5553
+ this.itemData = e.result[0];
5554
+ const dataItem = this.getItemData();
5555
+ if ((this.value === dataItem.value && this.text !== dataItem.text) ||
5556
+ (this.value !== dataItem.value && this.text === dataItem.text)) {
5557
+ this.setProperties({ text: dataItem.text.toString() });
5558
+ Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
5559
+ }
5560
+ }
5561
+ this.updateValues();
5547
5562
  }
5548
5563
  else {
5549
- this.itemData = e.result[0];
5550
- const dataItem = this.getItemData();
5551
- if ((this.value === dataItem.value && this.text !== dataItem.text) ||
5552
- (this.value !== dataItem.value && this.text === dataItem.text)) {
5553
- this.setProperties({ text: dataItem.text.toString() });
5554
- Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
5555
- }
5564
+ this.updateValues();
5556
5565
  }
5557
- this.updateValues();
5558
- }
5559
- else {
5560
- this.updateValues();
5566
+ });
5567
+ }
5568
+ }
5569
+ else {
5570
+ this.updateValues();
5571
+ }
5572
+ }
5573
+ searchOfflineData(value, checkField) {
5574
+ if (!(this.dataSource instanceof DataManager)) {
5575
+ this.updateValues();
5576
+ return;
5577
+ }
5578
+ const dataManager = this.dataSource;
5579
+ const fullData = dataManager.dataSource.json || [];
5580
+ if (fullData && fullData.length > 0) {
5581
+ const foundItem = fullData.find((item) => {
5582
+ if (this.fields.value && this.fields.value.includes('.')) {
5583
+ const fieldValueArray = this.fields.value.split('.');
5584
+ const fieldVal = this.checkFieldValue(item, fieldValueArray);
5585
+ return fieldVal === value;
5561
5586
  }
5587
+ return item[checkField] === value;
5562
5588
  });
5589
+ if (foundItem) {
5590
+ this.itemData = foundItem;
5591
+ const dataItem = this.getItemData();
5592
+ if ((this.value === dataItem.value && this.text !== dataItem.text) ||
5593
+ (this.value !== dataItem.value && this.text === dataItem.text)) {
5594
+ this.setProperties({ text: dataItem.text.toString() });
5595
+ Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
5596
+ }
5597
+ this.updateValues();
5598
+ }
5599
+ else {
5600
+ this.updateValues();
5601
+ }
5563
5602
  }
5564
5603
  else {
5565
5604
  this.updateValues();
@@ -5679,7 +5718,8 @@ let DropDownList = class DropDownList extends DropDownBase {
5679
5718
  this.setFooterTemplate(popupEle);
5680
5719
  this.isUpdateFooterHeight = this.footer.offsetHeight !== 0;
5681
5720
  }
5682
- document.body.appendChild(popupEle);
5721
+ const appendToElement = this.getAppendToElement();
5722
+ appendToElement.appendChild(popupEle);
5683
5723
  popupEle.style.top = '0px';
5684
5724
  initialPopupHeight = popupEle.clientHeight;
5685
5725
  if (this.enableVirtualization && (this.itemTemplate || this.isAngular)) {
@@ -5940,6 +5980,16 @@ let DropDownList = class DropDownList extends DropDownBase {
5940
5980
  }
5941
5981
  });
5942
5982
  }
5983
+ getAppendToElement() {
5984
+ if (this.isAngular) {
5985
+ const cdkPane = this.element && this.element.closest ? this.element.closest('.cdk-overlay-pane') : null;
5986
+ const popoverEl = this.element && this.element.closest ? this.element.closest('[popover]') : null;
5987
+ if (cdkPane && popoverEl) {
5988
+ return cdkPane;
5989
+ }
5990
+ }
5991
+ return document.body;
5992
+ }
5943
5993
  checkCollision(popupEle) {
5944
5994
  if (!Browser.isDevice || (Browser.isDevice && !(this.getModuleName() === 'dropdownlist' || this.isDropDownClick))) {
5945
5995
  const collision = isCollide(popupEle);
@@ -6705,7 +6755,8 @@ let DropDownList = class DropDownList extends DropDownBase {
6705
6755
  const listParentHeight = formatUnit(this.popupHeight);
6706
6756
  listParent.style.height = (parseInt(listParentHeight, 10)).toString() + 'px';
6707
6757
  listParent.appendChild(item);
6708
- document.body.appendChild(listParent);
6758
+ const appendToElement = this.getAppendToElement();
6759
+ appendToElement.appendChild(listParent);
6709
6760
  this.virtualListHeight = listParent.getBoundingClientRect().height;
6710
6761
  const listItemHeight = Math.ceil(item.getBoundingClientRect().height) +
6711
6762
  parseInt(window.getComputedStyle(item).marginBottom, 10);
@@ -6979,10 +7030,12 @@ let DropDownList = class DropDownList extends DropDownBase {
6979
7030
  }
6980
7031
  if (this.enableVirtualization) {
6981
7032
  if (newProp.value && this.dataSource instanceof DataManager) {
7033
+ const isOfflineMode = this.dataSource instanceof DataManager &&
7034
+ this.dataSource.dataSource.offline === true;
6982
7035
  const checkField = isNullOrUndefined(this.fields.value) ? this.fields.text : this.fields.value;
6983
7036
  const value = this.allowObjectBinding && !isNullOrUndefined(newProp.value) ?
6984
7037
  getValue(checkField, newProp.value) : newProp.value;
6985
- this.checkAndFetchItemData(this.listData, value, checkField);
7038
+ this.checkAndFetchItemData(this.listData, value, checkField, isOfflineMode);
6986
7039
  }
6987
7040
  this.updateValues();
6988
7041
  this.updateInputFields();
@@ -15322,7 +15375,10 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15322
15375
  }
15323
15376
  }
15324
15377
  else {
15325
- this.onActionComplete(list, this.mainData);
15378
+ const listUl = this.list && this.list.querySelector('ul');
15379
+ const isFullList = this.isReact && this.itemTemplate && listUl != null &&
15380
+ listUl.querySelectorAll('.e-list-item').length === this.mainData.length;
15381
+ this.onActionComplete(isFullList ? listUl : list, this.mainData);
15326
15382
  }
15327
15383
  this.focusAtLastListItem(data);
15328
15384
  if (this.value && this.value.length) {
@@ -15553,9 +15609,13 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15553
15609
  addClass([element], CHIP_SELECTED);
15554
15610
  if (element) {
15555
15611
  element.setAttribute('id', this.element.id + '_chip_item');
15556
- if (!isNullOrUndefined(this.inputElement) && element.id && !this.inputElement.hasAttribute('aria-activedescendant')) {
15612
+ if (!isNullOrUndefined(this.inputElement) && element.id) {
15557
15613
  this.inputElement.setAttribute('aria-activedescendant', element.id);
15558
15614
  }
15615
+ const chipClose = element.querySelector('span.' + CHIP_CLOSE$1.split(' ')[0]);
15616
+ if (chipClose) {
15617
+ chipClose.removeAttribute('aria-hidden');
15618
+ }
15559
15619
  }
15560
15620
  this.trigger('chipSelection', e);
15561
15621
  }
@@ -15950,6 +16010,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15950
16010
  dispatchSelect(value, eve, element, isNotTrigger, length, dataValue, text) {
15951
16011
  const list = this.listData;
15952
16012
  if (this.initStatus && !isNotTrigger && (!this.allowObjectBinding || (this.allowObjectBinding && value))) {
16013
+ let selectAllArgsLocal = null;
15953
16014
  value = this.allowObjectBinding ? getValue(((this.fields.value) ? this.fields.value : ''), value) : value;
15954
16015
  const val = dataValue ? dataValue : this.getDataByValue(value);
15955
16016
  const eventArgs = {
@@ -15966,15 +16027,13 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15966
16027
  this.selectAllEventEle.push(element);
15967
16028
  }
15968
16029
  if (length === 1) {
15969
- const args = {
16030
+ selectAllArgsLocal = {
15970
16031
  event: eve,
15971
16032
  items: this.selectAllEventEle,
15972
16033
  itemData: this.selectAllEventData,
15973
16034
  isInteracted: eve ? true : false,
15974
16035
  isChecked: true
15975
16036
  };
15976
- this.trigger('selectedAll', args);
15977
- this.selectAllEventData = [];
15978
16037
  }
15979
16038
  if (this.allowCustomValue && this.isServerRendered && this.listData !== list) {
15980
16039
  this.listData = list;
@@ -16011,6 +16070,10 @@ let MultiSelect = class MultiSelect extends DropDownBase {
16011
16070
  if (this.hideSelectedItem && this.fixedHeaderElement && this.fields.groupBy && this.mode !== 'CheckBox') {
16012
16071
  super.scrollStop();
16013
16072
  }
16073
+ if (selectAllArgsLocal) {
16074
+ this.trigger('selectedAll', selectAllArgsLocal);
16075
+ this.selectAllEventData = [];
16076
+ }
16014
16077
  }
16015
16078
  });
16016
16079
  }
@@ -16023,12 +16086,18 @@ let MultiSelect = class MultiSelect extends DropDownBase {
16023
16086
  removeChipFocus() {
16024
16087
  const elements = this.chipCollectionWrapper.querySelectorAll('span.' + CHIP$1 + '.' + CHIP_SELECTED);
16025
16088
  removeClass(elements, CHIP_SELECTED);
16089
+ const closeElements = this.chipCollectionWrapper.querySelectorAll('span.' + CHIP_CLOSE$1.split(' ')[0]);
16026
16090
  if (Browser.isDevice) {
16027
- const closeElements = this.chipCollectionWrapper.querySelectorAll('span.' + CHIP_CLOSE$1.split(' ')[0]);
16028
16091
  for (let index = 0; index < closeElements.length; index++) {
16092
+ closeElements[index].setAttribute('aria-hidden', 'true');
16029
16093
  closeElements[index].style.display = 'none';
16030
16094
  }
16031
16095
  }
16096
+ else {
16097
+ for (let index = 0; index < closeElements.length; index++) {
16098
+ closeElements[index].setAttribute('aria-hidden', 'true');
16099
+ }
16100
+ }
16032
16101
  }
16033
16102
  onMobileChipInteraction(e) {
16034
16103
  const chipElem = closest(e.target, '.' + CHIP$1);
@@ -16068,7 +16137,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
16068
16137
  });
16069
16138
  let compiledString;
16070
16139
  const chipContent = this.createElement('span', { className: CHIP_CONTENT$1 });
16071
- const chipClose = this.createElement('span', { className: CHIP_CLOSE$1 });
16140
+ const chipClose = this.createElement('span', { className: CHIP_CLOSE$1, attrs: { 'aria-label': 'delete', 'aria-hidden': 'true', 'tabindex': '-1' } });
16072
16141
  if (this.mainData) {
16073
16142
  itemData = this.getDataByValue(value);
16074
16143
  }
@@ -17411,6 +17480,9 @@ let MultiSelect = class MultiSelect extends DropDownBase {
17411
17480
  }
17412
17481
  else {
17413
17482
  e.preventDefault();
17483
+ if (this.value.length === this.listData.length && this.isPopupOpen()) {
17484
+ this.hidePopup(e);
17485
+ }
17414
17486
  }
17415
17487
  const isFilterData = this.targetElement().trim() !== '' ? true : false;
17416
17488
  this.makeTextBoxEmpty();
@@ -19045,7 +19117,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
19045
19117
  }
19046
19118
  else {
19047
19119
  this.chipCollectionWrapper = this.createElement('span', {
19048
- className: CHIP_WRAPPER$1
19120
+ className: CHIP_WRAPPER$1, attrs: { role: 'listbox' }
19049
19121
  });
19050
19122
  this.chipCollectionWrapper.style.display = 'none';
19051
19123
  if (this.mode === 'Default') {