@syncfusion/ej2-dropdowns 27.2.2 → 27.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.
@@ -392,7 +392,7 @@ class VirtualScroll {
392
392
  this.component = component.component;
393
393
  }
394
394
  let endIndex = this.parent.viewPortInfo.endIndex;
395
- if (this.component === 'multiselect' && this.parent.mode === 'CheckBox' && this.parent.value && Array.isArray(this.parent.value) && this.parent.value.length > 0 && this.parent.enableSelectionOrder) {
395
+ if (this.component === 'multiselect' && this.parent.mode === 'CheckBox' && this.parent.value && Array.isArray(this.parent.value) && this.parent.value.length > 0 && this.parent.enableSelectionOrder && this.parent.targetElement().trim() === '') {
396
396
  if (this.parent.viewPortInfo.startIndex < this.parent.value.length) {
397
397
  endIndex = this.parent.viewPortInfo.endIndex - this.parent.value.length;
398
398
  if (this.parent.viewPortInfo.startIndex === 0) {
@@ -490,7 +490,8 @@ class VirtualScroll {
490
490
  if (index === endIndex - 1) {
491
491
  if (currentData.length !== this.parent.itemCount) {
492
492
  if (this.parent.hideSelectedItem) {
493
- let query = this.parent.getForQuery(this.parent.value).clone();
493
+ let query = this.parent.value && this.parent.value.length > 0 ?
494
+ this.parent.getForQuery(this.parent.value).clone() : new Query;
494
495
  if (this.parent.viewPortInfo.endIndex === this.parent.totalItemCount + this.parent.value.length &&
495
496
  this.parent.hideSelectedItem) {
496
497
  query = query.skip(this.parent.totalItemCount - this.parent.itemCount);
@@ -887,6 +888,7 @@ let DropDownBase = class DropDownBase extends Component {
887
888
  this.virtualSelectAllState = false;
888
889
  this.CurrentEvent = null;
889
890
  this.isDynamicData = false;
891
+ this.isPrimitiveData = false;
890
892
  this.virtualListInfo = {
891
893
  currentPageNumber: null,
892
894
  direction: null,
@@ -1349,9 +1351,11 @@ let DropDownBase = class DropDownBase extends Component {
1349
1351
  }
1350
1352
  renderItemsBySelect() {
1351
1353
  const element = this.element;
1352
- const fields = { value: 'value', text: 'text' };
1353
- const jsonElement = [];
1354
1354
  const group = element.querySelectorAll('select>optgroup');
1355
+ let fields;
1356
+ const isSelectGroupCheck = this.getModuleName() === 'multiselect' && this.isGroupChecking && group.length > 0;
1357
+ fields = isSelectGroupCheck ? { value: 'value', text: 'text', groupBy: 'categeory' } : fields = { value: 'value', text: 'text' };
1358
+ const jsonElement = [];
1355
1359
  const option = element.querySelectorAll('select>option');
1356
1360
  this.getJSONfromOption(jsonElement, option, fields);
1357
1361
  if (group.length) {
@@ -1361,12 +1365,17 @@ let DropDownBase = class DropDownBase extends Component {
1361
1365
  optionGroup[fields.text] = item.label;
1362
1366
  optionGroup.isHeader = true;
1363
1367
  const child = item.querySelectorAll('option');
1364
- jsonElement.push(optionGroup);
1365
- this.getJSONfromOption(jsonElement, child, fields);
1368
+ if (isSelectGroupCheck) {
1369
+ this.getJSONfromOption(jsonElement, child, fields, item.label);
1370
+ }
1371
+ else {
1372
+ jsonElement.push(optionGroup);
1373
+ this.getJSONfromOption(jsonElement, child, fields);
1374
+ }
1366
1375
  }
1367
1376
  element.querySelectorAll('select>option');
1368
1377
  }
1369
- this.updateFields(fields.text, fields.value, this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1378
+ this.updateFields(fields.text, fields.value, isSelectGroupCheck ? fields.groupBy : this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1370
1379
  this.resetList(jsonElement, fields);
1371
1380
  }
1372
1381
  updateFields(text, value, groupBy, htmlAttributes, iconCss, disabled) {
@@ -1382,12 +1391,15 @@ let DropDownBase = class DropDownBase extends Component {
1382
1391
  };
1383
1392
  this.setProperties(field, true);
1384
1393
  }
1385
- getJSONfromOption(items, options, fields) {
1394
+ getJSONfromOption(items, options, fields, category = null) {
1386
1395
  for (const option of options) {
1387
1396
  const json = {};
1388
1397
  json[fields.text] = option.innerText;
1389
1398
  json[fields.value] = !isNullOrUndefined(option.getAttribute(fields.value)) ?
1390
1399
  option.getAttribute(fields.value) : option.innerText;
1400
+ if (!isNullOrUndefined(category)) {
1401
+ json[fields.groupBy] = category;
1402
+ }
1391
1403
  items.push(json);
1392
1404
  }
1393
1405
  }
@@ -1841,7 +1853,12 @@ let DropDownBase = class DropDownBase extends Component {
1841
1853
  if (this.sortOrder !== 'None') {
1842
1854
  dataSource = this.getSortedDataSource(dataSource);
1843
1855
  }
1844
- dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1856
+ if (this.element.querySelector('optgroup') && this.isGroupChecking && this.getModuleName() === 'multiselect') {
1857
+ dataSource = ListBase.groupDataSource(dataSource, fields, this.sortOrder);
1858
+ }
1859
+ else {
1860
+ dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1861
+ }
1845
1862
  }
1846
1863
  addClass([this.list], dropDownBaseClasses.grouping);
1847
1864
  }
@@ -2194,6 +2211,7 @@ let DropDownBase = class DropDownBase extends Component {
2194
2211
  this.updateFields(this.fields.text, this.fields.text);
2195
2212
  }
2196
2213
  else if (!this.fields.value && !this.fields.text) {
2214
+ this.isPrimitiveData = true;
2197
2215
  this.updateFields('text', 'text');
2198
2216
  }
2199
2217
  }
@@ -2241,6 +2259,7 @@ let DropDownBase = class DropDownBase extends Component {
2241
2259
  }
2242
2260
  setUpdateInitial(props, newProp, oldProp) {
2243
2261
  this.isDataFetched = false;
2262
+ this.isPrimitiveData = false;
2244
2263
  const updateData = {};
2245
2264
  for (let j = 0; props.length > j; j++) {
2246
2265
  if (newProp[props[j]] && props[j] === 'fields') {
@@ -4177,7 +4196,7 @@ let DropDownList = class DropDownList extends DropDownBase {
4177
4196
  else {
4178
4197
  this.setSelectOptions(li, e);
4179
4198
  if (this.enableVirtualization && this.value) {
4180
- const fields = (this.fields.value) ? this.fields.value : '';
4199
+ const fields = !this.isPrimitiveData ? this.fields.value : '';
4181
4200
  const currentValue = this.allowObjectBinding && !isNullOrUndefined(this.value) ?
4182
4201
  getValue((this.fields.value) ? this.fields.value : '', this.value) : this.value;
4183
4202
  if (this.dataSource instanceof DataManager) {
@@ -12586,7 +12605,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
12586
12605
  }
12587
12606
  getForQuery(valuecheck, isCheckbox) {
12588
12607
  let predicate;
12589
- const field = isNullOrUndefined(this.fields.value) ? this.fields.text : this.fields.value;
12608
+ const field = this.isPrimitiveData ? '' : this.fields.value;
12590
12609
  if (this.enableVirtualization && valuecheck) {
12591
12610
  if (isCheckbox) {
12592
12611
  for (let i = 0; i < valuecheck.length; i++) {
@@ -13026,32 +13045,48 @@ let MultiSelect = class MultiSelect extends DropDownBase {
13026
13045
  if (this.targetElement().trim() === '') {
13027
13046
  const list = this.enableVirtualization ? this.list.cloneNode(true) : this.mainList.cloneNode ?
13028
13047
  this.mainList.cloneNode(true) : this.mainList;
13029
- if (this.backCommand) {
13048
+ if (this.backCommand || (this.enableVirtualization && this.mode === 'CheckBox' && this.value && this.value.length > 0)) {
13030
13049
  this.remoteCustomValue = false;
13050
+ let isReordered = false;
13031
13051
  if (this.allowCustomValue && list.querySelectorAll('li').length === 0 && this.mainData.length > 0) {
13032
13052
  this.mainData = [];
13033
13053
  }
13034
13054
  if (this.enableVirtualization) {
13035
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13036
- this.totalItemCount = this.dataSource && this.dataSource.length ? this.dataSource.length : 0;
13037
- this.resetList(dataSource, fields, query);
13038
- if (this.mode !== 'CheckBox') {
13039
- this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
13040
- this.totalItemCount;
13055
+ if (this.allowFiltering) {
13056
+ this.isPreventScrollAction = true;
13057
+ this.list.scrollTop = 0;
13058
+ this.previousStartIndex = 0;
13059
+ this.virtualListInfo = null;
13041
13060
  }
13042
- this.UpdateSkeleton();
13043
- if ((isNoData || this.allowCustomValue) && !this.list.classList.contains(dropDownBaseClasses.noData)) {
13044
- if (!this.list.querySelector('.e-virtual-ddl-content')) {
13045
- this.list.appendChild(this.createElement('div', {
13046
- className: 'e-virtual-ddl-content',
13047
- styles: this.getTransformValues()
13048
- })).appendChild(this.list.querySelector('.e-list-parent'));
13061
+ if (this.value && this.value.length > 0 && this.mode === 'CheckBox') {
13062
+ this.notify('setCurrentViewDataAsync', {
13063
+ component: this.getModuleName(),
13064
+ module: 'VirtualScroll'
13065
+ });
13066
+ isReordered = true;
13067
+ }
13068
+ else {
13069
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13070
+ this.totalItemCount = this.dataSource && this.dataSource.length ? this.dataSource.length : 0;
13071
+ this.resetList(dataSource, fields, query);
13072
+ if (this.mode !== 'CheckBox') {
13073
+ this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
13074
+ this.totalItemCount;
13049
13075
  }
13050
- if (!this.list.querySelector('.e-virtual-ddl')) {
13051
- const virualElement = this.createElement('div', {
13052
- id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
13053
- });
13054
- document.getElementsByClassName('e-multi-select-list-wrapper')[0].querySelector('.e-dropdownbase').appendChild(virualElement);
13076
+ this.UpdateSkeleton();
13077
+ if ((isNoData || this.allowCustomValue) && !this.list.classList.contains(dropDownBaseClasses.noData)) {
13078
+ if (!this.list.querySelector('.e-virtual-ddl-content')) {
13079
+ this.list.appendChild(this.createElement('div', {
13080
+ className: 'e-virtual-ddl-content',
13081
+ styles: this.getTransformValues()
13082
+ })).appendChild(this.list.querySelector('.e-list-parent'));
13083
+ }
13084
+ if (!this.list.querySelector('.e-virtual-ddl')) {
13085
+ const virualElement = this.createElement('div', {
13086
+ id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
13087
+ });
13088
+ document.getElementsByClassName('e-multi-select-list-wrapper')[0].querySelector('.e-dropdownbase').appendChild(virualElement);
13089
+ }
13055
13090
  }
13056
13091
  }
13057
13092
  }
@@ -13062,7 +13097,9 @@ let MultiSelect = class MultiSelect extends DropDownBase {
13062
13097
  if (this.keyCode !== 8) {
13063
13098
  this.focusAtFirstListItem();
13064
13099
  }
13065
- this.notify('reOrder', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', e: this });
13100
+ if (!isReordered) {
13101
+ this.notify('reOrder', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', e: this });
13102
+ }
13066
13103
  }
13067
13104
  }
13068
13105
  else {
@@ -13071,6 +13108,9 @@ let MultiSelect = class MultiSelect extends DropDownBase {
13071
13108
  this.list.scrollTop = 0;
13072
13109
  this.previousStartIndex = 0;
13073
13110
  this.virtualListInfo = null;
13111
+ if (this.list.querySelector('.e-list-parent' + '.e-reorder')) {
13112
+ this.list.querySelector('.e-list-parent' + '.e-reorder').remove();
13113
+ }
13074
13114
  }
13075
13115
  this.resetList(dataSource, fields, query);
13076
13116
  if (this.enableVirtualization && (isNoData || this.allowCustomValue) &&
@@ -15571,7 +15611,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15571
15611
  endIndex: this.itemCount
15572
15612
  };
15573
15613
  }
15574
- updateData(delimiterChar, e) {
15614
+ updateData(delimiterChar, e, isInitialVirtualData) {
15575
15615
  let data = '';
15576
15616
  const delim = this.mode === 'Delimiter' || this.mode === 'CheckBox';
15577
15617
  let text = [];
@@ -15614,8 +15654,8 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15614
15654
  text = this.text.split(delimiterChar);
15615
15655
  }
15616
15656
  else {
15617
- temp = this.getTextByValue(value);
15618
- const textValues = this.text != null && this.text !== '' ? this.text + ',' + temp : temp;
15657
+ temp = isInitialVirtualData && delim ? this.text : this.getTextByValue(value);
15658
+ const textValues = isInitialVirtualData ? this.text : (this.text && this.text !== '' ? this.text + ',' + temp : temp);
15619
15659
  data += temp + delimiterChar + ' ';
15620
15660
  text.push(textValues);
15621
15661
  hiddenElementContent = this.hiddenElement.innerHTML;
@@ -15738,8 +15778,11 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15738
15778
  text = null;
15739
15779
  if (listItems != null && listItems.length > 0) {
15740
15780
  for (let i = 0; i < listItems.length; i++) {
15741
- if (getValue((this.fields.value ? this.fields.value : 'value'), listItems[i]) === value) {
15742
- text = getValue(this.fields.text, listItems[i]);
15781
+ if ((this.isPrimitiveData && listItems[i] === value) || (!this.isPrimitiveData
15782
+ && getValue((this.fields.value ? this.fields.value :
15783
+ 'value'), listItems[i]) === value)) {
15784
+ text = this.isPrimitiveData ? listItems[i] :
15785
+ getValue(this.fields.text, listItems[i]);
15743
15786
  if (this.enableVirtualization) {
15744
15787
  if (isNullOrUndefined(this.selectedListData)) {
15745
15788
  this.selectedListData = [listItems[i]];
@@ -15825,7 +15868,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15825
15868
  this.refreshInputHight();
15826
15869
  }
15827
15870
  else {
15828
- this.updateDelimeter(this.delimiterChar);
15871
+ this.updateDelimeter(this.delimiterChar, null, isInitialVirtualData);
15829
15872
  }
15830
15873
  if (this.mode === 'CheckBox' && this.showSelectAll && (isNullOrUndefined(this.value) || !this.value.length)) {
15831
15874
  this.notify('checkSelectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'uncheck' });
@@ -16036,8 +16079,8 @@ let MultiSelect = class MultiSelect extends DropDownBase {
16036
16079
  this.selectedElementID = element.id;
16037
16080
  }
16038
16081
  }
16039
- updateDelimeter(delimChar, e) {
16040
- this.updateData(delimChar, e);
16082
+ updateDelimeter(delimChar, e, isInitialVirtualData) {
16083
+ this.updateData(delimChar, e, isInitialVirtualData);
16041
16084
  }
16042
16085
  onMouseClick(e) {
16043
16086
  if (!this.isClearAllItem) {
@@ -17774,7 +17817,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
17774
17817
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17775
17818
  let listItems;
17776
17819
  if (this.enableVirtualization) {
17777
- const fields = (this.fields.value) ? this.fields.value : '';
17820
+ const fields = !this.isPrimitiveData ? this.fields.value : '';
17778
17821
  let predicate;
17779
17822
  for (let i = 0; i < this.value.length; i++) {
17780
17823
  const value = this.allowObjectBinding ?
@@ -17806,7 +17849,7 @@ let MultiSelect = class MultiSelect extends DropDownBase {
17806
17849
  }
17807
17850
  }
17808
17851
  if (!(this.dataSource instanceof DataManager)) {
17809
- this.initialValueUpdate(listItems);
17852
+ this.initialValueUpdate(listItems, true);
17810
17853
  this.initialUpdate();
17811
17854
  }
17812
17855
  else {
@@ -18581,7 +18624,10 @@ class CheckBoxSelection {
18581
18624
  this.parent.refreshPopup();
18582
18625
  this.clearIconElement.style.visibility = 'hidden';
18583
18626
  this.filterInput.focus();
18584
- this.setReorder(e);
18627
+ if (!this.parent.enableVirtualization || (this.parent.enableVirtualization && (isNullOrUndefined(this.parent.value)
18628
+ || (this.parent.value && this.parent.value.length === 0)))) {
18629
+ this.setReorder(e);
18630
+ }
18585
18631
  this.boundPreventListSelection = this.preventListSelection.bind(this);
18586
18632
  this.parent.popupWrapper.addEventListener('mouseup', this.boundPreventListSelection, true);
18587
18633
  e.preventDefault();
@@ -20430,11 +20476,13 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
20430
20476
  if (fListBox.value.length === 1 && fListBox.getSelectedItems().length) {
20431
20477
  fListBox.value[0] = fListBox.getFormattedValue(fListBox.getSelectedItems()[0].getAttribute('data-value'));
20432
20478
  }
20433
- if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length) {
20479
+ if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length && this.toolbarAction) {
20434
20480
  const wrap = this.list.parentElement.getElementsByClassName('e-listbox-tool')[0];
20435
20481
  const toolbarAction = this.toolbarAction === 'moveFrom' ? 'moveAllFrom' : 'moveAllTo';
20436
- const btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20437
- btn.disabled = true;
20482
+ if (wrap) {
20483
+ const btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20484
+ btn.disabled = true;
20485
+ }
20438
20486
  }
20439
20487
  }
20440
20488
  selectNextList(elems, dataLiIdx, dataIdx, inst) {