@syncfusion/ej2-dropdowns 34.2.5 → 34.2.6

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