@syncfusion/ej2-dropdowns 34.1.33 → 34.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.
@@ -8313,6 +8313,7 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
8313
8313
  _this.windowResizeContext = _this.windowResize.bind(_this);
8314
8314
  // Specifies if the checkAll method has been called
8315
8315
  _this.isCheckAllCalled = false;
8316
+ _this.isNodeChecked = false;
8316
8317
  _this.isFromFilterChange = false;
8317
8318
  _this.fallbackValue = [];
8318
8319
  return _this;
@@ -10350,6 +10351,7 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10350
10351
  DropDownTree.prototype.onNodeChecked = function (args) {
10351
10352
  var eventArgs = this.getEventArgs(args);
10352
10353
  this.trigger('select', eventArgs);
10354
+ this.isNodeChecked = args.action === 'check';
10353
10355
  if (this.isFilteredData && args.action === 'uncheck') {
10354
10356
  var id = getValue('id', args.data[0]).toString();
10355
10357
  this.removeSelectedData(id, true);
@@ -10675,6 +10677,143 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10675
10677
  }
10676
10678
  }
10677
10679
  };
10680
+ DropDownTree.prototype.getFilteredTreeData = function () {
10681
+ return this.treeData;
10682
+ };
10683
+ DropDownTree.prototype.getChildren = function (parentId, result) {
10684
+ var _this = this;
10685
+ var treeData = this.getFilteredTreeData();
10686
+ treeData.forEach(function (item) {
10687
+ if (!isNullOrUndefined(item) && !isNullOrUndefined(item.pid) && !isNullOrUndefined(item.id) && item.pid.toString() === parentId.toString()) {
10688
+ var childId = item.id.toString();
10689
+ if (result.indexOf(childId) === -1) {
10690
+ result.push(childId);
10691
+ _this.getChildren(childId, result);
10692
+ }
10693
+ }
10694
+ });
10695
+ };
10696
+ DropDownTree.prototype.getDirectChildren = function (parentId) {
10697
+ return this.getFilteredTreeData()
10698
+ .filter(function (childNode) {
10699
+ return !isNullOrUndefined(childNode) && !isNullOrUndefined(childNode.pid) && !isNullOrUndefined(childNode.id) && childNode.pid.toString() === parentId;
10700
+ })
10701
+ .map(function (childNode) { return childNode.id.toString(); });
10702
+ };
10703
+ DropDownTree.prototype.updateFilteredAutoCheckValues = function () {
10704
+ var _this = this;
10705
+ var treeData = this.getFilteredTreeData();
10706
+ var currentValues = Array.isArray(this.value) ? this.value.map(function (item) { return item.toString(); }) : [];
10707
+ var removeParent = function (parentId) {
10708
+ _this.value = _this.value.filter(function (value) { return value.toString() !== parentId; });
10709
+ };
10710
+ if (this.isNodeChecked) {
10711
+ this.treeObj.checkedNodes.map(function (item) { return item.toString(); }).forEach(function (value) {
10712
+ if (_this.value.indexOf(value) === -1) {
10713
+ _this.value.push(value);
10714
+ }
10715
+ });
10716
+ treeData.forEach(function (node) {
10717
+ if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10718
+ return;
10719
+ }
10720
+ var parentId = node.id.toString();
10721
+ if (node.haschild && _this.value.indexOf(parentId) !== -1) {
10722
+ var childValues = [];
10723
+ _this.getChildren(parentId, childValues);
10724
+ if (_this.value.indexOf(parentId) === -1) {
10725
+ _this.value.push(parentId);
10726
+ }
10727
+ childValues.forEach(function (value) {
10728
+ if (_this.value.indexOf(value) === -1) {
10729
+ _this.value.push(value);
10730
+ }
10731
+ });
10732
+ }
10733
+ currentValues = _this.value.map(function (item) { return item.toString(); });
10734
+ });
10735
+ treeData.forEach(function (node) {
10736
+ if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10737
+ return;
10738
+ }
10739
+ if (!node.haschild) {
10740
+ return;
10741
+ }
10742
+ var parentId = node.id.toString();
10743
+ var directChildren = _this.getDirectChildren(parentId);
10744
+ if (!directChildren.length) {
10745
+ return;
10746
+ }
10747
+ var allChildrenSelected = directChildren.every(function (childId) { return _this.value.indexOf(childId) !== -1; });
10748
+ if (allChildrenSelected) {
10749
+ var childValues = [];
10750
+ _this.getChildren(parentId, childValues);
10751
+ if (_this.value.indexOf(parentId) === -1) {
10752
+ _this.value.push(parentId);
10753
+ }
10754
+ childValues.forEach(function (value) {
10755
+ if (_this.value.indexOf(value) === -1) {
10756
+ _this.value.push(value);
10757
+ }
10758
+ });
10759
+ }
10760
+ else {
10761
+ removeParent(parentId);
10762
+ }
10763
+ currentValues = _this.value.map(function (item) { return item.toString(); });
10764
+ });
10765
+ this.selectedData.forEach(function (item) {
10766
+ var value = getValue(_this.treeSettings.loadOnDemand ? _this.fields.value : 'id', item).toString();
10767
+ if (_this.value.indexOf(value) === -1) {
10768
+ _this.selectedData = _this.selectedData.filter(function (data) {
10769
+ return getValue(_this.treeSettings.loadOnDemand ? _this.fields.value : 'id', data).toString() !== value;
10770
+ });
10771
+ }
10772
+ });
10773
+ return;
10774
+ }
10775
+ var removeValues = [];
10776
+ treeData.forEach(function (node) {
10777
+ if (isNullOrUndefined(node.id)) {
10778
+ return;
10779
+ }
10780
+ if (!node.haschild) {
10781
+ return;
10782
+ }
10783
+ var parentId = node.id.toString();
10784
+ if (currentValues.indexOf(parentId) === -1) {
10785
+ var childValues = [];
10786
+ _this.getChildren(parentId, childValues);
10787
+ if (childValues.some(function (child) { return currentValues.indexOf(child) !== -1; })) {
10788
+ removeValues.push.apply(removeValues, childValues);
10789
+ }
10790
+ }
10791
+ });
10792
+ if (removeValues.length) {
10793
+ this.value = this.value.filter(function (value) { return removeValues.indexOf(value.toString()) === -1; });
10794
+ currentValues = this.value.map(function (item) { return item.toString(); });
10795
+ }
10796
+ treeData.forEach(function (node) {
10797
+ if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10798
+ return;
10799
+ }
10800
+ if (!node.haschild) {
10801
+ return;
10802
+ }
10803
+ var parentId = node.id.toString();
10804
+ if (currentValues.indexOf(parentId) === -1) {
10805
+ return;
10806
+ }
10807
+ var hasDirectChild = treeData.some(function (childNode) {
10808
+ return !isNullOrUndefined(childNode) && !isNullOrUndefined(childNode.pid) && !isNullOrUndefined(childNode.id) && childNode.pid.toString() === parentId &&
10809
+ currentValues.indexOf(childNode.id.toString()) !== -1;
10810
+ });
10811
+ if (!hasDirectChild) {
10812
+ removeParent(parentId);
10813
+ currentValues = _this.value.map(function (item) { return item.toString(); });
10814
+ }
10815
+ });
10816
+ };
10678
10817
  DropDownTree.prototype.updateSelectedValues = function () {
10679
10818
  var _this = this;
10680
10819
  this.dataValue = '';
@@ -10690,6 +10829,9 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10690
10829
  if (!this.isFilteredData) {
10691
10830
  this.selectedData = [];
10692
10831
  }
10832
+ if (this.treeSettings.autoCheck && this.isFilteredData && !isNullOrUndefined(this.value)) {
10833
+ this.updateFilteredAutoCheckValues();
10834
+ }
10693
10835
  if (!isNullOrUndefined(this.value)) {
10694
10836
  var compiledString = this.initializeValueTemplate();
10695
10837
  for (var i = 0, len = this.value.length; i < len; i++) {
@@ -13723,6 +13865,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
13723
13865
  _this.isBlurDispatching = false;
13724
13866
  _this.isFilterPrevented = false;
13725
13867
  _this.isFilteringAction = false;
13868
+ _this.isPropertyChanged = false;
13726
13869
  _this.isValidKey = false;
13727
13870
  _this.selectAllEventData = [];
13728
13871
  _this.selectAllEventEle = [];
@@ -13874,7 +14017,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
13874
14017
  if (!eventArgs.cancel) {
13875
14018
  _this.focusAtFirstListItem(true);
13876
14019
  if (_this.popupObj) {
13877
- document.body.appendChild(_this.popupObj.element);
14020
+ var appendToElement = _this.getAppendToElement();
14021
+ appendToElement.appendChild(_this.popupObj.element);
13878
14022
  }
13879
14023
  if (_this.mode === 'CheckBox' && _this.enableGroupCheckBox && !isNullOrUndefined(_this.fields.groupBy)) {
13880
14024
  _this.updateListItems(_this.list.querySelectorAll('li.e-list-item'), _this.mainList.querySelectorAll('li.e-list-item'));
@@ -14433,7 +14577,12 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
14433
14577
  }
14434
14578
  }
14435
14579
  else if (!(this.dataSource instanceof DataManager)) {
14436
- this.initialValueUpdate();
14580
+ if (!this.isRemoveSelection) {
14581
+ this.initialValueUpdate(this.listData, true);
14582
+ }
14583
+ else {
14584
+ this.initialValueUpdate();
14585
+ }
14437
14586
  }
14438
14587
  this.initialUpdate();
14439
14588
  this.refreshPlaceHolder();
@@ -14447,6 +14596,16 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
14447
14596
  this.onPopupShown(e);
14448
14597
  }
14449
14598
  };
14599
+ MultiSelect.prototype.getAppendToElement = function () {
14600
+ if (this.isAngular) {
14601
+ var cdkPane = this.element && this.element.closest ? this.element.closest('.cdk-overlay-pane') : null;
14602
+ var popoverEl = this.element && this.element.closest ? this.element.closest('[popover]') : null;
14603
+ if (cdkPane && popoverEl) {
14604
+ return cdkPane;
14605
+ }
14606
+ }
14607
+ return document.body;
14608
+ };
14450
14609
  MultiSelect.prototype.refreshSelection = function () {
14451
14610
  var value;
14452
14611
  var element;
@@ -16028,7 +16187,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16028
16187
  else {
16029
16188
  var listUl = this.list && this.list.querySelector('ul');
16030
16189
  var isFullList = this.isReact && this.itemTemplate && listUl != null &&
16031
- listUl.querySelectorAll('.e-list-item').length === this.mainData.length && !this.groupTemplate;
16190
+ listUl.querySelectorAll('.e-list-item').length === this.mainData.length && !this.groupTemplate && this.mode !== 'CheckBox';
16032
16191
  this.onActionComplete(isFullList ? listUl : list, this.mainData);
16033
16192
  }
16034
16193
  this.focusAtLastListItem(data);
@@ -16939,7 +17098,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16939
17098
  }
16940
17099
  if (!this.popupObj) {
16941
17100
  if (!isNullOrUndefined(this.popupWrapper)) {
16942
- document.body.appendChild(this.popupWrapper);
17101
+ var appendToElement = this.getAppendToElement();
17102
+ appendToElement.appendChild(this.popupWrapper);
16943
17103
  var checkboxFilter = this.popupWrapper.querySelector('.' + FILTERPARENT);
16944
17104
  if (this.mode === 'CheckBox' && !this.allowFiltering && checkboxFilter && this.filterParent) {
16945
17105
  checkboxFilter.remove();
@@ -17775,6 +17935,33 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17775
17935
  this.unwireListEvents();
17776
17936
  this.wireListEvents();
17777
17937
  };
17938
+ MultiSelect.prototype.getTextByValueFromDataSource = function (value) {
17939
+ var dataSource = this.dataSource;
17940
+ if (isNullOrUndefined(dataSource) || !dataSource.length) {
17941
+ return null;
17942
+ }
17943
+ if (this.isPrimitiveData) {
17944
+ for (var i = 0; i < dataSource.length; i++) {
17945
+ if (dataSource[i] === value) {
17946
+ return dataSource[i];
17947
+ }
17948
+ }
17949
+ return null;
17950
+ }
17951
+ var fields = this.fields;
17952
+ var valueField = fields.value ? fields.value : 'value';
17953
+ var textField = fields.text ? fields.text : 'text';
17954
+ for (var i = 0; i < dataSource.length; i++) {
17955
+ var item = dataSource[i];
17956
+ if (!isNullOrUndefined(item) && getValue(valueField, item) === value) {
17957
+ var resolvedText = getValue(textField, item);
17958
+ if (!isNullOrUndefined(resolvedText)) {
17959
+ return resolvedText;
17960
+ }
17961
+ }
17962
+ }
17963
+ return null;
17964
+ };
17778
17965
  MultiSelect.prototype.initialValueUpdate = function (listItems, isInitialVirtualData, isInitialRender) {
17779
17966
  var _this = this;
17780
17967
  if (this.list) {
@@ -17825,6 +18012,10 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17825
18012
  }
17826
18013
  }
17827
18014
  }
18015
+ if (this.isPropertyChanged && isNullOrUndefined(text) && !this.allowCustomValue &&
18016
+ !(this.dataSource instanceof DataManager)) {
18017
+ text = this.getTextByValueFromDataSource(value_2);
18018
+ }
17828
18019
  if ((isNullOrUndefined(text) && this.allowCustomValue) &&
17829
18020
  ((!(this.dataSource instanceof DataManager)) ||
17830
18021
  (this.dataSource instanceof DataManager && isInitialVirtualData))) {
@@ -19459,6 +19650,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
19459
19650
  * @returns {void}
19460
19651
  */
19461
19652
  MultiSelect.prototype.onPropertyChanged = function (newProp, oldProp) {
19653
+ this.isPropertyChanged = true;
19462
19654
  if (newProp.dataSource && !isNullOrUndefined(Object.keys(newProp.dataSource))
19463
19655
  || newProp.query && !isNullOrUndefined(Object.keys(newProp.query))) {
19464
19656
  this.mainList = null;
@@ -19631,6 +19823,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
19631
19823
  break;
19632
19824
  }
19633
19825
  }
19826
+ this.isPropertyChanged = false;
19634
19827
  };
19635
19828
  MultiSelect.prototype.reInitializePoup = function () {
19636
19829
  if (this.popupObj) {
@@ -19951,8 +20144,11 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
19951
20144
  var mainLiLength = _this.ulElement.querySelectorAll('li.' + 'e-list-item').length;
19952
20145
  var liLength = _this.ulElement.querySelectorAll('li.'
19953
20146
  + dropDownBaseClasses.li + '.' + HIDE_LIST).length;
20147
+ var isFilterText = _this.allowFiltering && !isNullOrUndefined(_this.inputElement) &&
20148
+ _this.inputElement.value.trim() !== '';
20149
+ var isRemoteData = _this.dataSource instanceof DataManager;
19954
20150
  if (mainLiLength > 0 && (mainLiLength === liLength) && (liLength === _this.mainData.length) &&
19955
- !(_this.targetElement() !== '' && _this.allowCustomValue)) {
20151
+ !(_this.targetElement() !== '' && _this.allowCustomValue) && (!isRemoteData || !isFilterText)) {
19956
20152
  _this.beforePopupOpen = false;
19957
20153
  return;
19958
20154
  }
@@ -20380,7 +20576,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
20380
20576
  var listParentHeight = formatUnit(this.popupHeight);
20381
20577
  listParent.style.height = (parseInt(listParentHeight, 10)).toString() + 'px';
20382
20578
  listParent.appendChild(item);
20383
- document.body.appendChild(listParent);
20579
+ var appendToElement = this.getAppendToElement();
20580
+ appendToElement.appendChild(listParent);
20384
20581
  this.virtualListHeight = listParent.getBoundingClientRect().height;
20385
20582
  var listItemHeight = Math.ceil(item.getBoundingClientRect().height) +
20386
20583
  parseInt(window.getComputedStyle(item).marginBottom, 10);
@@ -23709,10 +23906,12 @@ var ListBox = /** @__PURE__ @class */ (function (_super) {
23709
23906
  return;
23710
23907
  }
23711
23908
  var isSpecialKey = e.keyCode >= 186 && e.keyCode <= 192;
23909
+ var isBracketKey = e.keyCode === 219 || e.keyCode === 220 || e.keyCode === 221 || e.keyCode === 222;
23712
23910
  var isNumericKeyPadSpecialKey = e.keyCode === 107 || e.keyCode === 109 || e.keyCode === 111;
23713
23911
  var isWordCharacter = e.key && e.key.match(/\w/);
23714
- var isWordAccentCharacter = e.key && e.key.match(/[A-Za-z0-9\u00C0-\u024F ,>/:;\-+=]/);
23715
- if (!isNullOrUndefined(isWordCharacter) || !isNullOrUndefined(isWordAccentCharacter) || isSpecialKey || isNumericKeyPadSpecialKey) {
23912
+ var isWordAccentCharacter = e.key && e.key.match(/[A-Za-z0-9\u00C0-\u024F ,>/:;\-+=[\]\\ ']/);
23913
+ if (!isNullOrUndefined(isWordCharacter) || !isNullOrUndefined(isWordAccentCharacter)
23914
+ || isSpecialKey || isBracketKey || isNumericKeyPadSpecialKey) {
23716
23915
  this.isValidKey = true;
23717
23916
  }
23718
23917
  this.isBackSpace = e.keyCode === 8;
@@ -25778,11 +25977,12 @@ var Mention = /** @__PURE__ @class */ (function (_super) {
25778
25977
  value = this.displayTempElement.innerHTML;
25779
25978
  }
25780
25979
  if (this.isContentEditable(this.inputElement)) {
25781
- var defaultSuffix = this.isRTE ? '&#8203;' : '';
25980
+ var isMozilla = Browser.info.name === 'mozilla';
25981
+ var defaultSuffix = this.isRTE || isMozilla ? '&#8203;' : '';
25782
25982
  if (Browser.isAndroid) {
25783
25983
  return '<span contenteditable="true" class="e-mention-chip">' + showChar + value + '</span>'.concat(typeof this.suffixText === 'string' ? this.suffixText : defaultSuffix);
25784
25984
  }
25785
- else if (Browser.info.name === 'mozilla') {
25985
+ else if (isMozilla) {
25786
25986
  return '<span>&#65279;<span contenteditable="false" class="e-mention-chip">' + showChar + value + '</span>&#65279;</span>'.concat(typeof this.suffixText === 'string' ? this.suffixText : defaultSuffix);
25787
25987
  }
25788
25988
  else {