@syncfusion/ej2-dropdowns 34.2.2 → 34.2.4

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.
@@ -10192,6 +10192,17 @@ let DropDownTree = class DropDownTree extends Component {
10192
10192
  this.triggerChangeEvent(this.keyEventArgs);
10193
10193
  this.isValueChange = false;
10194
10194
  }
10195
+ const treeData = this.treeObj.getTreeData();
10196
+ if (this.showCheckBox && this.treeSettings.autoCheck && treeData.length > 0 && this.treeData && this.treeData.length > 0) {
10197
+ for (let i = 0; i < treeData.length; i++) {
10198
+ for (let j = 0; j < this.treeData.length; j++) {
10199
+ if (treeData[i].id === this.treeData[j].id) {
10200
+ this.treeData[j].selected = treeData[i].selected !== undefined ?
10201
+ treeData[i].selected : false;
10202
+ }
10203
+ }
10204
+ }
10205
+ }
10195
10206
  }
10196
10207
  beforeCheck(args) {
10197
10208
  if (args.isInteracted) {
@@ -10503,8 +10514,31 @@ let DropDownTree = class DropDownTree extends Component {
10503
10514
  .filter((childNode) => !isNullOrUndefined(childNode) && !isNullOrUndefined(childNode.pid) && !isNullOrUndefined(childNode.id) && childNode.pid.toString() === parentId)
10504
10515
  .map((childNode) => childNode.id.toString());
10505
10516
  }
10517
+ restoreRootParentValues() {
10518
+ const treeData = this.getFilteredTreeData();
10519
+ treeData.forEach((node) => {
10520
+ if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10521
+ return;
10522
+ }
10523
+ if (isNullOrUndefined(node.pid)) {
10524
+ const rootId = node.id.toString();
10525
+ const currentValues = this.value.map((item) => item.toString());
10526
+ if (currentValues.indexOf(rootId) === -1) {
10527
+ const childValues = [];
10528
+ this.getChildren(rootId, childValues);
10529
+ const hasSelectedChild = childValues.some((childId) => currentValues.indexOf(childId) !== -1);
10530
+ if (hasSelectedChild) {
10531
+ this.value.push(rootId);
10532
+ }
10533
+ }
10534
+ }
10535
+ });
10536
+ }
10506
10537
  updateFilteredAutoCheckValues() {
10507
10538
  const treeData = this.getFilteredTreeData();
10539
+ if (!this.isNodeChecked && Array.isArray(this.value) && this.value.length > 0 && this.showCheckBox) {
10540
+ this.restoreRootParentValues();
10541
+ }
10508
10542
  let currentValues = Array.isArray(this.value) ? this.value.map((item) => item.toString()) : [];
10509
10543
  const removeParent = (parentId) => {
10510
10544
  this.value = this.value.filter((value) => value.toString() !== parentId);
@@ -10593,24 +10627,44 @@ let DropDownTree = class DropDownTree extends Component {
10593
10627
  this.value = this.value.filter((value) => removeValues.indexOf(value.toString()) === -1);
10594
10628
  currentValues = this.value.map((item) => item.toString());
10595
10629
  }
10596
- treeData.forEach((node) => {
10597
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10598
- return;
10599
- }
10600
- if (!node.haschild) {
10601
- return;
10602
- }
10603
- const parentId = node.id.toString();
10604
- if (currentValues.indexOf(parentId) === -1) {
10605
- return;
10606
- }
10607
- const hasDirectChild = treeData.some((childNode) => !isNullOrUndefined(childNode) && !isNullOrUndefined(childNode.pid) && !isNullOrUndefined(childNode.id) && childNode.pid.toString() === parentId &&
10608
- currentValues.indexOf(childNode.id.toString()) !== -1);
10609
- if (!hasDirectChild) {
10610
- removeParent(parentId);
10611
- currentValues = this.value.map((item) => item.toString());
10612
- }
10613
- });
10630
+ let stabilized = false;
10631
+ const valueBeforeReconciliation = [...this.value];
10632
+ let iterationCount = 0;
10633
+ const maxIterations = treeData.length + 1;
10634
+ while (!stabilized && iterationCount < maxIterations) {
10635
+ stabilized = true;
10636
+ iterationCount++;
10637
+ treeData.forEach((node) => {
10638
+ if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10639
+ return;
10640
+ }
10641
+ if (!node.haschild) {
10642
+ return;
10643
+ }
10644
+ const parentId = node.id.toString();
10645
+ const directChildren = this.getDirectChildren(parentId);
10646
+ if (!directChildren.length) {
10647
+ return;
10648
+ }
10649
+ const allDirectChildrenChecked = directChildren.every((childId) => currentValues.indexOf(childId) !== -1);
10650
+ if (allDirectChildrenChecked) {
10651
+ if (currentValues.indexOf(parentId) === -1) {
10652
+ this.value.push(parentId);
10653
+ currentValues = this.value.map((item) => item.toString());
10654
+ stabilized = false;
10655
+ }
10656
+ }
10657
+ else if (currentValues.indexOf(parentId) !== -1) {
10658
+ removeParent(parentId);
10659
+ currentValues = this.value.map((item) => item.toString());
10660
+ stabilized = false;
10661
+ }
10662
+ });
10663
+ }
10664
+ if ((valueBeforeReconciliation.length > 0 && this.value.length === 0) ||
10665
+ iterationCount >= maxIterations) {
10666
+ this.value = valueBeforeReconciliation;
10667
+ }
10614
10668
  }
10615
10669
  updateSelectedValues() {
10616
10670
  this.dataValue = '';
@@ -13750,7 +13804,8 @@ let MultiSelect = class MultiSelect extends DropDownBase {
13750
13804
  if (!eventArgs.cancel) {
13751
13805
  this.focusAtFirstListItem(true);
13752
13806
  if (this.popupObj) {
13753
- document.body.appendChild(this.popupObj.element);
13807
+ const appendToElement = this.getAppendToElement();
13808
+ appendToElement.appendChild(this.popupObj.element);
13754
13809
  }
13755
13810
  if (this.mode === 'CheckBox' && this.enableGroupCheckBox && !isNullOrUndefined(this.fields.groupBy)) {
13756
13811
  this.updateListItems(this.list.querySelectorAll('li.e-list-item'), this.mainList.querySelectorAll('li.e-list-item'));
@@ -14327,6 +14382,16 @@ let MultiSelect = class MultiSelect extends DropDownBase {
14327
14382
  this.onPopupShown(e);
14328
14383
  }
14329
14384
  }
14385
+ getAppendToElement() {
14386
+ if (this.isAngular) {
14387
+ const cdkPane = this.element && this.element.closest ? this.element.closest('.cdk-overlay-pane') : null;
14388
+ const popoverEl = this.element && this.element.closest ? this.element.closest('[popover]') : null;
14389
+ if (cdkPane && popoverEl) {
14390
+ return cdkPane;
14391
+ }
14392
+ }
14393
+ return document.body;
14394
+ }
14330
14395
  refreshSelection() {
14331
14396
  let value;
14332
14397
  let element;
@@ -15903,7 +15968,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15903
15968
  else {
15904
15969
  const listUl = this.list && this.list.querySelector('ul');
15905
15970
  const isFullList = this.isReact && this.itemTemplate && listUl != null &&
15906
- listUl.querySelectorAll('.e-list-item').length === this.mainData.length && !this.groupTemplate;
15971
+ listUl.querySelectorAll('.e-list-item').length === this.mainData.length && !this.groupTemplate && this.mode !== 'CheckBox';
15907
15972
  this.onActionComplete(isFullList ? listUl : list, this.mainData);
15908
15973
  }
15909
15974
  this.focusAtLastListItem(data);
@@ -16801,7 +16866,8 @@ let MultiSelect = class MultiSelect extends DropDownBase {
16801
16866
  }
16802
16867
  if (!this.popupObj) {
16803
16868
  if (!isNullOrUndefined(this.popupWrapper)) {
16804
- document.body.appendChild(this.popupWrapper);
16869
+ const appendToElement = this.getAppendToElement();
16870
+ appendToElement.appendChild(this.popupWrapper);
16805
16871
  const checkboxFilter = this.popupWrapper.querySelector('.' + FILTERPARENT);
16806
16872
  if (this.mode === 'CheckBox' && !this.allowFiltering && checkboxFilter && this.filterParent) {
16807
16873
  checkboxFilter.remove();
@@ -19823,8 +19889,11 @@ let MultiSelect = class MultiSelect extends DropDownBase {
19823
19889
  const mainLiLength = this.ulElement.querySelectorAll('li.' + 'e-list-item').length;
19824
19890
  const liLength = this.ulElement.querySelectorAll('li.'
19825
19891
  + dropDownBaseClasses.li + '.' + HIDE_LIST).length;
19892
+ const isFilterText = this.allowFiltering && !isNullOrUndefined(this.inputElement) &&
19893
+ this.inputElement.value.trim() !== '';
19894
+ const isRemoteData = this.dataSource instanceof DataManager;
19826
19895
  if (mainLiLength > 0 && (mainLiLength === liLength) && (liLength === this.mainData.length) &&
19827
- !(this.targetElement() !== '' && this.allowCustomValue)) {
19896
+ !(this.targetElement() !== '' && this.allowCustomValue) && (!isRemoteData || !isFilterText)) {
19828
19897
  this.beforePopupOpen = false;
19829
19898
  return;
19830
19899
  }
@@ -20249,7 +20318,8 @@ let MultiSelect = class MultiSelect extends DropDownBase {
20249
20318
  const listParentHeight = formatUnit(this.popupHeight);
20250
20319
  listParent.style.height = (parseInt(listParentHeight, 10)).toString() + 'px';
20251
20320
  listParent.appendChild(item);
20252
- document.body.appendChild(listParent);
20321
+ const appendToElement = this.getAppendToElement();
20322
+ appendToElement.appendChild(listParent);
20253
20323
  this.virtualListHeight = listParent.getBoundingClientRect().height;
20254
20324
  const listItemHeight = Math.ceil(item.getBoundingClientRect().height) +
20255
20325
  parseInt(window.getComputedStyle(item).marginBottom, 10);
@@ -23512,15 +23582,17 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
23512
23582
  }
23513
23583
  }
23514
23584
  KeyUp(e) {
23515
- if (this.allowFiltering && e.ctrlKey && e.keyCode === 65) {
23585
+ if (this.allowFiltering && ((e.ctrlKey && e.keyCode === 65) || e.keyCode === 16)) {
23516
23586
  e.preventDefault();
23517
23587
  return;
23518
23588
  }
23519
23589
  const isSpecialKey = e.keyCode >= 186 && e.keyCode <= 192;
23590
+ const isBracketKey = e.keyCode === 219 || e.keyCode === 220 || e.keyCode === 221 || e.keyCode === 222;
23520
23591
  const isNumericKeyPadSpecialKey = e.keyCode === 107 || e.keyCode === 109 || e.keyCode === 111;
23521
23592
  const isWordCharacter = e.key && e.key.match(/\w/);
23522
- const isWordAccentCharacter = e.key && e.key.match(/[A-Za-z0-9\u00C0-\u024F ,>/:;\-+=]/);
23523
- if (!isNullOrUndefined(isWordCharacter) || !isNullOrUndefined(isWordAccentCharacter) || isSpecialKey || isNumericKeyPadSpecialKey) {
23593
+ const isWordAccentCharacter = e.key && e.key.match(/[A-Za-z0-9\u00C0-\u024F ,>/:;\-+=[\]\\ '@!#$%^&*()]/);
23594
+ if (!isNullOrUndefined(isWordCharacter) || !isNullOrUndefined(isWordAccentCharacter)
23595
+ || isSpecialKey || isBracketKey || isNumericKeyPadSpecialKey) {
23524
23596
  this.isValidKey = true;
23525
23597
  }
23526
23598
  this.isBackSpace = e.keyCode === 8;
@@ -25551,11 +25623,12 @@ let Mention = class Mention extends DropDownBase {
25551
25623
  value = this.displayTempElement.innerHTML;
25552
25624
  }
25553
25625
  if (this.isContentEditable(this.inputElement)) {
25554
- const defaultSuffix = this.isRTE ? '&#8203;' : '';
25626
+ const isMozilla = Browser.info.name === 'mozilla';
25627
+ const defaultSuffix = this.isRTE || isMozilla ? '&#8203;' : '';
25555
25628
  if (Browser.isAndroid) {
25556
25629
  return '<span contenteditable="true" class="e-mention-chip">' + showChar + value + '</span>'.concat(typeof this.suffixText === 'string' ? this.suffixText : defaultSuffix);
25557
25630
  }
25558
- else if (Browser.info.name === 'mozilla') {
25631
+ else if (isMozilla) {
25559
25632
  return '<span>&#65279;<span contenteditable="false" class="e-mention-chip">' + showChar + value + '</span>&#65279;</span>'.concat(typeof this.suffixText === 'string' ? this.suffixText : defaultSuffix);
25560
25633
  }
25561
25634
  else {