@syncfusion/ej2-dropdowns 34.2.5 → 34.2.7

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.
@@ -3776,6 +3776,7 @@ let DropDownList = class DropDownList extends DropDownBase {
3776
3776
  this.bindClearEvent();
3777
3777
  }
3778
3778
  windowResize() {
3779
+ this.updateFloatLabelOverflowWidth();
3779
3780
  if (this.isPopupOpen) {
3780
3781
  this.popupObj.refreshPosition(this.inputWrapper.container);
3781
3782
  }
@@ -4575,7 +4576,8 @@ let DropDownList = class DropDownList extends DropDownBase {
4575
4576
  }
4576
4577
  onDocumentClick(e) {
4577
4578
  const target = e.target;
4578
- if (!(!isNullOrUndefined(this.popupObj) && closest(target, this.checkSelector(this.popupObj.element.id))) &&
4579
+ if (!isNullOrUndefined(target) && !(!isNullOrUndefined(this.popupObj) &&
4580
+ closest(target, this.checkSelector(this.popupObj.element.id))) &&
4579
4581
  !isNullOrUndefined(this.inputWrapper) && !this.inputWrapper.container.contains(e.target)) {
4580
4582
  if (this.inputWrapper.container.classList.contains(dropDownListClasses.inputFocus) || this.isPopupOpen) {
4581
4583
  this.isDocumentClick = true;
@@ -6214,7 +6216,9 @@ let DropDownList = class DropDownList extends DropDownBase {
6214
6216
  ulElement = null;
6215
6217
  },
6216
6218
  targetExitViewport: () => {
6217
- this.hidePopup();
6219
+ if (!Browser.isDevice || (this.allowFiltering === false && this.isPopupOpen)) {
6220
+ this.hidePopup();
6221
+ }
6218
6222
  }
6219
6223
  });
6220
6224
  }
@@ -8147,6 +8151,7 @@ let DropDownTree = class DropDownTree extends Component {
8147
8151
  this.isNodeChecked = false;
8148
8152
  this.isFromFilterChange = false;
8149
8153
  this.fallbackValue = [];
8154
+ this.uncheckedNodeId = null;
8150
8155
  }
8151
8156
  /**
8152
8157
  * Get the properties to be maintained in the persisted state.
@@ -10282,6 +10287,8 @@ let DropDownTree = class DropDownTree extends Component {
10282
10287
  const eventArgs = this.getEventArgs(args);
10283
10288
  this.trigger('select', eventArgs);
10284
10289
  this.isNodeChecked = args.action === 'check';
10290
+ this.uncheckedNodeId = args.action === 'uncheck' && !isNullOrUndefined(args.data[0]) ?
10291
+ getValue('id', args.data[0]).toString() : null;
10285
10292
  if (this.isFilteredData && args.action === 'uncheck') {
10286
10293
  const id = getValue('id', args.data[0]).toString();
10287
10294
  this.removeSelectedData(id, true);
@@ -10314,21 +10321,8 @@ let DropDownTree = class DropDownTree extends Component {
10314
10321
  this.triggerChangeEvent(this.keyEventArgs);
10315
10322
  this.isValueChange = false;
10316
10323
  }
10317
- if (!this.isRemoteData && !this.treeSettings.loadOnDemand) {
10318
- const treeData = this.treeObj.getTreeData();
10319
- if (this.showCheckBox && this.treeSettings.autoCheck &&
10320
- treeData.length > 0 && this.treeData && this.treeData.length > 0) {
10321
- for (let i = 0; i < treeData.length; i++) {
10322
- for (let j = 0; j < this.treeData.length; j++) {
10323
- if (treeData[i][this.fields.value] === this.treeData[j][this.fields.value]) {
10324
- this.treeData[j].selected = treeData[i].selected !== undefined ?
10325
- treeData[i].selected : false;
10326
- }
10327
- }
10328
- }
10329
- }
10330
- }
10331
10324
  this.updateIndeterminateNodes();
10325
+ this.uncheckedNodeId = null;
10332
10326
  }
10333
10327
  beforeCheck(args) {
10334
10328
  if (args.isInteracted) {
@@ -10620,14 +10614,12 @@ let DropDownTree = class DropDownTree extends Component {
10620
10614
  }
10621
10615
  }
10622
10616
  }
10623
- getFilteredTreeData() {
10624
- return this.treeData;
10625
- }
10626
10617
  getChildren(parentId, result) {
10627
- const treeData = this.getFilteredTreeData();
10628
- treeData.forEach((item) => {
10629
- if (!isNullOrUndefined(item) && !isNullOrUndefined(item.pid) && !isNullOrUndefined(item.id) && item.pid.toString() === parentId.toString()) {
10630
- const childId = item.id.toString();
10618
+ this.treeData.forEach((item) => {
10619
+ const itemId = !isNullOrUndefined(item) ? getValue(this.fields.value, item) : null;
10620
+ const itemPid = !isNullOrUndefined(item) ? getValue(this.fields.parentValue, item) : null;
10621
+ if (!isNullOrUndefined(itemId) && !isNullOrUndefined(itemPid) && itemPid.toString() === parentId.toString()) {
10622
+ const childId = itemId.toString();
10631
10623
  if (result.indexOf(childId) === -1) {
10632
10624
  result.push(childId);
10633
10625
  this.getChildren(childId, result);
@@ -10636,35 +10628,15 @@ let DropDownTree = class DropDownTree extends Component {
10636
10628
  });
10637
10629
  }
10638
10630
  getDirectChildren(parentId) {
10639
- return this.getFilteredTreeData()
10640
- .filter((childNode) => !isNullOrUndefined(childNode) && !isNullOrUndefined(childNode.pid) && !isNullOrUndefined(childNode.id) && childNode.pid.toString() === parentId)
10641
- .map((childNode) => childNode.id.toString());
10642
- }
10643
- restoreRootParentValues() {
10644
- const treeData = this.getFilteredTreeData();
10645
- treeData.forEach((node) => {
10646
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10647
- return;
10648
- }
10649
- if (isNullOrUndefined(node.pid)) {
10650
- const rootId = node.id.toString();
10651
- const currentValues = this.value.map((item) => item.toString());
10652
- if (currentValues.indexOf(rootId) === -1) {
10653
- const childValues = [];
10654
- this.getChildren(rootId, childValues);
10655
- const hasSelectedChild = childValues.some((childId) => currentValues.indexOf(childId) !== -1);
10656
- if (hasSelectedChild) {
10657
- this.value.push(rootId);
10658
- }
10659
- }
10660
- }
10661
- });
10631
+ return this.treeData
10632
+ .filter((childNode) => {
10633
+ const childId = !isNullOrUndefined(childNode) ? getValue(this.fields.value, childNode) : null;
10634
+ const childPid = !isNullOrUndefined(childNode) ? getValue(this.fields.parentValue, childNode) : null;
10635
+ return !isNullOrUndefined(childId) && !isNullOrUndefined(childPid) && childPid.toString() === parentId;
10636
+ })
10637
+ .map((childNode) => getValue(this.fields.value, childNode).toString());
10662
10638
  }
10663
10639
  updateFilteredAutoCheckValues() {
10664
- const treeData = this.getFilteredTreeData();
10665
- if (!this.isNodeChecked && Array.isArray(this.value) && this.value.length > 0 && this.showCheckBox) {
10666
- this.restoreRootParentValues();
10667
- }
10668
10640
  let currentValues = Array.isArray(this.value) ? this.value.map((item) => item.toString()) : [];
10669
10641
  const removeParent = (parentId) => {
10670
10642
  this.value = this.value.filter((value) => value.toString() !== parentId);
@@ -10675,12 +10647,14 @@ let DropDownTree = class DropDownTree extends Component {
10675
10647
  this.value.push(value);
10676
10648
  }
10677
10649
  });
10678
- treeData.forEach((node) => {
10679
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10650
+ this.treeData.forEach((node) => {
10651
+ const nodeId = isNullOrUndefined(node) ? null : getValue(this.fields.value, node);
10652
+ const nodeHasChild = !isNullOrUndefined(node) && !!this.fields.hasChildren && getValue(this.fields.hasChildren, node) === true;
10653
+ if (isNullOrUndefined(nodeId)) {
10680
10654
  return;
10681
10655
  }
10682
- const parentId = node.id.toString();
10683
- if (node.haschild && this.value.indexOf(parentId) !== -1) {
10656
+ const parentId = nodeId.toString();
10657
+ if (nodeHasChild && this.value.indexOf(parentId) !== -1) {
10684
10658
  const childValues = [];
10685
10659
  this.getChildren(parentId, childValues);
10686
10660
  if (this.value.indexOf(parentId) === -1) {
@@ -10694,14 +10668,16 @@ let DropDownTree = class DropDownTree extends Component {
10694
10668
  }
10695
10669
  currentValues = this.value.map((item) => item.toString());
10696
10670
  });
10697
- treeData.forEach((node) => {
10698
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10671
+ this.treeData.forEach((node) => {
10672
+ const nodeId = isNullOrUndefined(node) ? null : getValue(this.fields.value, node);
10673
+ const nodeHasChild = !isNullOrUndefined(node) && !!this.fields.hasChildren && getValue(this.fields.hasChildren, node) === true;
10674
+ if (isNullOrUndefined(nodeId)) {
10699
10675
  return;
10700
10676
  }
10701
- if (!node.haschild) {
10677
+ if (!nodeHasChild) {
10702
10678
  return;
10703
10679
  }
10704
- const parentId = node.id.toString();
10680
+ const parentId = nodeId.toString();
10705
10681
  const directChildren = this.getDirectChildren(parentId);
10706
10682
  if (!directChildren.length) {
10707
10683
  return;
@@ -10733,14 +10709,19 @@ let DropDownTree = class DropDownTree extends Component {
10733
10709
  return;
10734
10710
  }
10735
10711
  const removeValues = [];
10736
- treeData.forEach((node) => {
10737
- if (isNullOrUndefined(node.id)) {
10712
+ this.treeData.forEach((node) => {
10713
+ const nodeId = isNullOrUndefined(node) ? null : getValue(this.fields.value, node);
10714
+ const nodeHasChild = !isNullOrUndefined(node) && !!this.fields.hasChildren && getValue(this.fields.hasChildren, node) === true;
10715
+ if (isNullOrUndefined(nodeId)) {
10716
+ return;
10717
+ }
10718
+ if (!nodeHasChild) {
10738
10719
  return;
10739
10720
  }
10740
- if (!node.haschild) {
10721
+ const parentId = nodeId.toString();
10722
+ if (parentId !== this.uncheckedNodeId) {
10741
10723
  return;
10742
10724
  }
10743
- const parentId = node.id.toString();
10744
10725
  if (currentValues.indexOf(parentId) === -1) {
10745
10726
  const childValues = [];
10746
10727
  this.getChildren(parentId, childValues);
@@ -10756,18 +10737,20 @@ let DropDownTree = class DropDownTree extends Component {
10756
10737
  let stabilized = false;
10757
10738
  const valueBeforeReconciliation = [...this.value];
10758
10739
  let iterationCount = 0;
10759
- const maxIterations = treeData.length + 1;
10740
+ const maxIterations = this.treeData.length + 1;
10760
10741
  while (!stabilized && iterationCount < maxIterations) {
10761
10742
  stabilized = true;
10762
10743
  iterationCount++;
10763
- treeData.forEach((node) => {
10764
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10744
+ this.treeData.forEach((node) => {
10745
+ const nodeId = isNullOrUndefined(node) ? null : getValue(this.fields.value, node);
10746
+ const nodeHasChild = !isNullOrUndefined(node) && !!this.fields.hasChildren && getValue(this.fields.hasChildren, node) === true;
10747
+ if (isNullOrUndefined(nodeId)) {
10765
10748
  return;
10766
10749
  }
10767
- if (!node.haschild) {
10750
+ if (!nodeHasChild) {
10768
10751
  return;
10769
10752
  }
10770
- const parentId = node.id.toString();
10753
+ const parentId = nodeId.toString();
10771
10754
  const directChildren = this.getDirectChildren(parentId);
10772
10755
  if (!directChildren.length) {
10773
10756
  return;
@@ -13917,6 +13900,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
13917
13900
  }
13918
13901
  }
13919
13902
  onPopupShown(e) {
13903
+ this.sanitizeData();
13920
13904
  if (Browser.isDevice && (this.mode === 'CheckBox' && this.allowFiltering)) {
13921
13905
  // eslint-disable-next-line @typescript-eslint/no-this-alias
13922
13906
  const proxy = this;
@@ -15539,7 +15523,10 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15539
15523
  }
15540
15524
  }
15541
15525
  this.UpdateSkeleton();
15542
- const scrollEle = this.ulElement.querySelectorAll('li.' + dropDownBaseClasses.li
15526
+ const hasOnlyVirtualItems = this.ulElement && this.ulElement.querySelector('li.e-virtual-list') &&
15527
+ this.ulElement.querySelectorAll('li:not(.e-virtual-list)').length === 0;
15528
+ const targetElement = hasOnlyVirtualItems ? this.list : this.ulElement;
15529
+ const scrollEle = targetElement.querySelectorAll('li.' + dropDownBaseClasses.li
15543
15530
  + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
15544
15531
  if (scrollEle.length > 0) {
15545
15532
  let element = scrollEle[(isHome) ? 0 : (scrollEle.length - 1)];
@@ -17416,6 +17403,8 @@ let MultiSelect = class MultiSelect extends DropDownBase {
17416
17403
  }
17417
17404
  windowResize() {
17418
17405
  this.refreshPopup();
17406
+ this.calculateWidth();
17407
+ this.updateFloatLabelOverflowWidth();
17419
17408
  if ((!this.inputFocus || this.mode === 'CheckBox') && this.viewWrapper && this.viewWrapper.parentElement) {
17420
17409
  this.updateDelimView();
17421
17410
  }
@@ -17643,6 +17632,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
17643
17632
  }
17644
17633
  this.preventSetCurrentData = false;
17645
17634
  this.initializeData();
17635
+ this.sanitizeData();
17646
17636
  this.updateDataAttribute(this.htmlAttributes);
17647
17637
  super.preRender();
17648
17638
  }
@@ -17673,6 +17663,56 @@ let MultiSelect = class MultiSelect extends DropDownBase {
17673
17663
  endIndex: this.itemCount
17674
17664
  };
17675
17665
  }
17666
+ sanitizeData() {
17667
+ if (this.enableVirtualization && this.mode === 'CheckBox') {
17668
+ if (this.dataSource && Array.isArray(this.dataSource) && !(this.dataSource instanceof DataManager)) {
17669
+ const cleanedDataSource = [];
17670
+ for (let i = 0; i < this.dataSource.length; i++) {
17671
+ const item = this.dataSource[i];
17672
+ if (item !== null && item !== undefined && item !== '') {
17673
+ if (typeof item === 'object') {
17674
+ const itemValue = getValue((this.fields.value ? this.fields.value : 'value'), item);
17675
+ if (this.fields.value !== null) {
17676
+ if (itemValue !== null && itemValue !== undefined && itemValue !== '') {
17677
+ cleanedDataSource.push(item);
17678
+ }
17679
+ }
17680
+ else {
17681
+ cleanedDataSource.push(item);
17682
+ }
17683
+ }
17684
+ else if (typeof item === 'string') {
17685
+ if (item !== null && item !== undefined && item.trim() !== '') {
17686
+ cleanedDataSource.push(item);
17687
+ }
17688
+ }
17689
+ else {
17690
+ cleanedDataSource.push(item);
17691
+ }
17692
+ }
17693
+ }
17694
+ if (cleanedDataSource.length !== this.dataSource.length) {
17695
+ this.setProperties({ dataSource: cleanedDataSource }, true);
17696
+ }
17697
+ }
17698
+ if (this.value && Array.isArray(this.value) && this.value.length > 0) {
17699
+ const cleanedValue = [];
17700
+ for (let i = 0; i < this.value.length; i++) {
17701
+ const val = this.value[i];
17702
+ if (val !== null && val !== undefined && val !== '') {
17703
+ cleanedValue.push(val);
17704
+ }
17705
+ }
17706
+ if (cleanedValue.length !== this.value.length) {
17707
+ this.setProperties({ value: cleanedValue }, true);
17708
+ }
17709
+ }
17710
+ return true;
17711
+ }
17712
+ else {
17713
+ return false;
17714
+ }
17715
+ }
17676
17716
  updateData(delimiterChar, e, isInitialVirtualData) {
17677
17717
  let data = '';
17678
17718
  const delim = this.mode === 'Delimiter' || this.mode === 'CheckBox';
@@ -17815,6 +17855,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
17815
17855
  || this.list.querySelector('.e-ul') && this.list.querySelector('.e-ul').childElementCount === 0)) {
17816
17856
  isEmptyData = true;
17817
17857
  }
17858
+ this.sanitizeData();
17818
17859
  super.render(null, isEmptyData);
17819
17860
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17820
17861
  this.totalItemCount = this.dataSource && this.dataSource.length ? this.dataSource.length : 0;
@@ -19545,6 +19586,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
19545
19586
  switch (prop) {
19546
19587
  case 'query':
19547
19588
  case 'dataSource':
19589
+ this.sanitizeData();
19548
19590
  if (this.mode === 'CheckBox' && this.showSelectAll) {
19549
19591
  if (!isNullOrUndefined(this.popupObj)) {
19550
19592
  this.popupObj.destroy();
@@ -19567,6 +19609,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
19567
19609
  this.updateVal(this.value, this.value, 'text');
19568
19610
  break;
19569
19611
  case 'value':
19612
+ this.sanitizeData();
19570
19613
  if (this.fields.disabled) {
19571
19614
  this.removeDisabledItemsValue(this.value);
19572
19615
  }
@@ -19998,6 +20041,8 @@ let MultiSelect = class MultiSelect extends DropDownBase {
19998
20041
  }
19999
20042
  this.firstItem = this.dataSource && this.dataSource.length > 0 ? this.dataSource[0] : null;
20000
20043
  const args = { cancel: false };
20044
+ const oldValue = extend([], this.value, [], true);
20045
+ const oldData = extend([], this.dataSource, [], true);
20001
20046
  this.trigger('beforeOpen', args, (args) => {
20002
20047
  if (!args.cancel) {
20003
20048
  if (!this.ulElement) {
@@ -20009,6 +20054,50 @@ let MultiSelect = class MultiSelect extends DropDownBase {
20009
20054
  if (this.inputElement && this.mode !== 'CheckBox') {
20010
20055
  this.focusIn();
20011
20056
  }
20057
+ if (this.enableVirtualization && this.mode === 'CheckBox') {
20058
+ if (JSON.stringify(oldData) !== JSON.stringify(this.dataSource) && this.sanitizeData() && this.showSelectAll) {
20059
+ this.renderPopup();
20060
+ }
20061
+ if (!isNullOrUndefined(oldValue) && !isNullOrUndefined(this.value) &&
20062
+ JSON.stringify(oldValue) !== JSON.stringify(this.value) && this.sanitizeData()) {
20063
+ if (this.fields.disabled) {
20064
+ this.removeDisabledItemsValue(this.value);
20065
+ }
20066
+ if (!this.validateValues(this.value, oldValue)) {
20067
+ return;
20068
+ }
20069
+ if (this.isVue && !this.changeOnBlur && !this.validateValues(this.value, oldValue)) {
20070
+ return;
20071
+ }
20072
+ this.updateVal(this.value, oldValue, 'value', this.enableVirtualization);
20073
+ this.addValidInputClass();
20074
+ if (this.showSelectAll) {
20075
+ this.renderPopup();
20076
+ const totalCount = this.dataSource instanceof DataManager ? 0 :
20077
+ this.dataSource.length;
20078
+ const selectedCount = this.value ? this.value.length : 0;
20079
+ if (selectedCount === totalCount) {
20080
+ let frame = null;
20081
+ if (this.popupObj) {
20082
+ frame = this.popupObj.element.querySelector('.e-selectall-parent .e-frame');
20083
+ }
20084
+ if (frame) {
20085
+ frame.classList.add('e-check');
20086
+ frame.classList.remove('e-uncheck');
20087
+ frame.classList.remove('e-stop');
20088
+ }
20089
+ }
20090
+ }
20091
+ if (!this.closePopupOnSelect && this.isPopupOpen()) {
20092
+ this.refreshPopup();
20093
+ }
20094
+ if (this.isPopupOpen() && this.list && this.list.querySelector('.e-active.e-disable')) {
20095
+ const activeItems = this.list.querySelectorAll('li.' + dropDownBaseClasses.li + '.e-active' + '.e-disable');
20096
+ removeClass(activeItems, 'e-disable');
20097
+ }
20098
+ this.preventChange = this.isAngular && this.preventChange ? !this.preventChange : this.preventChange;
20099
+ }
20100
+ }
20012
20101
  return;
20013
20102
  }
20014
20103
  if (this.mode === 'CheckBox' && Browser.isDevice && this.allowFiltering && this.isDeviceFullScreen) {
@@ -20163,6 +20252,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
20163
20252
  // eslint-disable-next-line
20164
20253
  this.value = [...this.value];
20165
20254
  }
20255
+ this.sanitizeData();
20166
20256
  this.setDynValue = this.initStatus = false;
20167
20257
  this.isSelectAll = false;
20168
20258
  this.selectAllEventEle = [];
@@ -24782,7 +24872,7 @@ let Mention = class Mention extends DropDownBase {
24782
24872
  ? lastWordRange.substring(lastWordRange.lastIndexOf(this.mentionChar) + 1).trim()
24783
24873
  : lastWordRange.replace(this.mentionChar, '');
24784
24874
  }
24785
- if (this.queryString !== '' && e.keyCode === 8 && lastWordRange.includes(this.mentionChar) && !this.isPopupOpen &&
24875
+ if (this.queryString !== '' && e.keyCode === 8 && lastWordRange.includes(this.mentionChar) && !this.isPopupOpen && !isNullOrUndefined(this.displayTemplate) &&
24786
24876
  ((typeof this.displayTemplate === 'function' ? this.displayTemplate() : this.displayTemplate)).includes(this.mentionChar)) {
24787
24877
  this.queryString = '';
24788
24878
  }