@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.
@@ -440,7 +440,7 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
440
440
  this.component = component.component;
441
441
  }
442
442
  var endIndex = this.parent.viewPortInfo.endIndex;
443
- if (this.component === 'multiselect' && this.parent.mode === 'CheckBox' && this.parent.value && Array.isArray(this.parent.value) && this.parent.value.length > 0 && this.parent.enableSelectionOrder) {
443
+ 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() === '') {
444
444
  if (this.parent.viewPortInfo.startIndex < this.parent.value.length) {
445
445
  endIndex = this.parent.viewPortInfo.endIndex - this.parent.value.length;
446
446
  if (this.parent.viewPortInfo.startIndex === 0) {
@@ -538,7 +538,8 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
538
538
  if (index === endIndex - 1) {
539
539
  if (currentData.length !== this.parent.itemCount) {
540
540
  if (this.parent.hideSelectedItem) {
541
- var query = this.parent.getForQuery(this.parent.value).clone();
541
+ var query = this.parent.value && this.parent.value.length > 0 ?
542
+ this.parent.getForQuery(this.parent.value).clone() : new Query;
542
543
  if (this.parent.viewPortInfo.endIndex === this.parent.totalItemCount + this.parent.value.length &&
543
544
  this.parent.hideSelectedItem) {
544
545
  query = query.skip(this.parent.totalItemCount - this.parent.itemCount);
@@ -965,6 +966,7 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
965
966
  _this.virtualSelectAllState = false;
966
967
  _this.CurrentEvent = null;
967
968
  _this.isDynamicData = false;
969
+ _this.isPrimitiveData = false;
968
970
  _this.virtualListInfo = {
969
971
  currentPageNumber: null,
970
972
  direction: null,
@@ -1430,9 +1432,11 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1430
1432
  };
1431
1433
  DropDownBase.prototype.renderItemsBySelect = function () {
1432
1434
  var element = this.element;
1433
- var fields = { value: 'value', text: 'text' };
1434
- var jsonElement = [];
1435
1435
  var group = element.querySelectorAll('select>optgroup');
1436
+ var fields;
1437
+ var isSelectGroupCheck = this.getModuleName() === 'multiselect' && this.isGroupChecking && group.length > 0;
1438
+ fields = isSelectGroupCheck ? { value: 'value', text: 'text', groupBy: 'categeory' } : fields = { value: 'value', text: 'text' };
1439
+ var jsonElement = [];
1436
1440
  var option = element.querySelectorAll('select>option');
1437
1441
  this.getJSONfromOption(jsonElement, option, fields);
1438
1442
  if (group.length) {
@@ -1442,12 +1446,17 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1442
1446
  optionGroup[fields.text] = item.label;
1443
1447
  optionGroup.isHeader = true;
1444
1448
  var child = item.querySelectorAll('option');
1445
- jsonElement.push(optionGroup);
1446
- this.getJSONfromOption(jsonElement, child, fields);
1449
+ if (isSelectGroupCheck) {
1450
+ this.getJSONfromOption(jsonElement, child, fields, item.label);
1451
+ }
1452
+ else {
1453
+ jsonElement.push(optionGroup);
1454
+ this.getJSONfromOption(jsonElement, child, fields);
1455
+ }
1447
1456
  }
1448
1457
  element.querySelectorAll('select>option');
1449
1458
  }
1450
- this.updateFields(fields.text, fields.value, this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1459
+ this.updateFields(fields.text, fields.value, isSelectGroupCheck ? fields.groupBy : this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1451
1460
  this.resetList(jsonElement, fields);
1452
1461
  };
1453
1462
  DropDownBase.prototype.updateFields = function (text, value, groupBy, htmlAttributes, iconCss, disabled) {
@@ -1463,13 +1472,17 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1463
1472
  };
1464
1473
  this.setProperties(field, true);
1465
1474
  };
1466
- DropDownBase.prototype.getJSONfromOption = function (items, options, fields) {
1475
+ DropDownBase.prototype.getJSONfromOption = function (items, options, fields, category) {
1476
+ if (category === void 0) { category = null; }
1467
1477
  for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
1468
1478
  var option = options_1[_i];
1469
1479
  var json = {};
1470
1480
  json[fields.text] = option.innerText;
1471
1481
  json[fields.value] = !isNullOrUndefined(option.getAttribute(fields.value)) ?
1472
1482
  option.getAttribute(fields.value) : option.innerText;
1483
+ if (!isNullOrUndefined(category)) {
1484
+ json[fields.groupBy] = category;
1485
+ }
1473
1486
  items.push(json);
1474
1487
  }
1475
1488
  };
@@ -1925,7 +1938,12 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1925
1938
  if (this.sortOrder !== 'None') {
1926
1939
  dataSource = this.getSortedDataSource(dataSource);
1927
1940
  }
1928
- dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1941
+ if (this.element.querySelector('optgroup') && this.isGroupChecking && this.getModuleName() === 'multiselect') {
1942
+ dataSource = ListBase.groupDataSource(dataSource, fields, this.sortOrder);
1943
+ }
1944
+ else {
1945
+ dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1946
+ }
1929
1947
  }
1930
1948
  addClass([this.list], dropDownBaseClasses.grouping);
1931
1949
  }
@@ -2278,6 +2296,7 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
2278
2296
  this.updateFields(this.fields.text, this.fields.text);
2279
2297
  }
2280
2298
  else if (!this.fields.value && !this.fields.text) {
2299
+ this.isPrimitiveData = true;
2281
2300
  this.updateFields('text', 'text');
2282
2301
  }
2283
2302
  };
@@ -2325,6 +2344,7 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
2325
2344
  };
2326
2345
  DropDownBase.prototype.setUpdateInitial = function (props, newProp, oldProp) {
2327
2346
  this.isDataFetched = false;
2347
+ this.isPrimitiveData = false;
2328
2348
  var updateData = {};
2329
2349
  for (var j = 0; props.length > j; j++) {
2330
2350
  if (newProp[props[j]] && props[j] === 'fields') {
@@ -4283,7 +4303,7 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
4283
4303
  else {
4284
4304
  this.setSelectOptions(li, e);
4285
4305
  if (this.enableVirtualization && this.value) {
4286
- var fields = (this.fields.value) ? this.fields.value : '';
4306
+ var fields = !this.isPrimitiveData ? this.fields.value : '';
4287
4307
  var currentValue = this.allowObjectBinding && !isNullOrUndefined(this.value) ?
4288
4308
  getValue((this.fields.value) ? this.fields.value : '', this.value) : this.value;
4289
4309
  if (this.dataSource instanceof DataManager) {
@@ -12836,7 +12856,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
12836
12856
  };
12837
12857
  MultiSelect.prototype.getForQuery = function (valuecheck, isCheckbox) {
12838
12858
  var predicate;
12839
- var field = isNullOrUndefined(this.fields.value) ? this.fields.text : this.fields.value;
12859
+ var field = this.isPrimitiveData ? '' : this.fields.value;
12840
12860
  if (this.enableVirtualization && valuecheck) {
12841
12861
  if (isCheckbox) {
12842
12862
  for (var i = 0; i < valuecheck.length; i++) {
@@ -13276,32 +13296,48 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
13276
13296
  if (this.targetElement().trim() === '') {
13277
13297
  var list = this.enableVirtualization ? this.list.cloneNode(true) : this.mainList.cloneNode ?
13278
13298
  this.mainList.cloneNode(true) : this.mainList;
13279
- if (this.backCommand) {
13299
+ if (this.backCommand || (this.enableVirtualization && this.mode === 'CheckBox' && this.value && this.value.length > 0)) {
13280
13300
  this.remoteCustomValue = false;
13301
+ var isReordered = false;
13281
13302
  if (this.allowCustomValue && list.querySelectorAll('li').length === 0 && this.mainData.length > 0) {
13282
13303
  this.mainData = [];
13283
13304
  }
13284
13305
  if (this.enableVirtualization) {
13285
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13286
- this.totalItemCount = this.dataSource && this.dataSource.length ? this.dataSource.length : 0;
13287
- this.resetList(dataSource, fields, query);
13288
- if (this.mode !== 'CheckBox') {
13289
- this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
13290
- this.totalItemCount;
13306
+ if (this.allowFiltering) {
13307
+ this.isPreventScrollAction = true;
13308
+ this.list.scrollTop = 0;
13309
+ this.previousStartIndex = 0;
13310
+ this.virtualListInfo = null;
13291
13311
  }
13292
- this.UpdateSkeleton();
13293
- if ((isNoData || this.allowCustomValue) && !this.list.classList.contains(dropDownBaseClasses.noData)) {
13294
- if (!this.list.querySelector('.e-virtual-ddl-content')) {
13295
- this.list.appendChild(this.createElement('div', {
13296
- className: 'e-virtual-ddl-content',
13297
- styles: this.getTransformValues()
13298
- })).appendChild(this.list.querySelector('.e-list-parent'));
13312
+ if (this.value && this.value.length > 0 && this.mode === 'CheckBox') {
13313
+ this.notify('setCurrentViewDataAsync', {
13314
+ component: this.getModuleName(),
13315
+ module: 'VirtualScroll'
13316
+ });
13317
+ isReordered = true;
13318
+ }
13319
+ else {
13320
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13321
+ this.totalItemCount = this.dataSource && this.dataSource.length ? this.dataSource.length : 0;
13322
+ this.resetList(dataSource, fields, query);
13323
+ if (this.mode !== 'CheckBox') {
13324
+ this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
13325
+ this.totalItemCount;
13299
13326
  }
13300
- if (!this.list.querySelector('.e-virtual-ddl')) {
13301
- var virualElement = this.createElement('div', {
13302
- id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
13303
- });
13304
- document.getElementsByClassName('e-multi-select-list-wrapper')[0].querySelector('.e-dropdownbase').appendChild(virualElement);
13327
+ this.UpdateSkeleton();
13328
+ if ((isNoData || this.allowCustomValue) && !this.list.classList.contains(dropDownBaseClasses.noData)) {
13329
+ if (!this.list.querySelector('.e-virtual-ddl-content')) {
13330
+ this.list.appendChild(this.createElement('div', {
13331
+ className: 'e-virtual-ddl-content',
13332
+ styles: this.getTransformValues()
13333
+ })).appendChild(this.list.querySelector('.e-list-parent'));
13334
+ }
13335
+ if (!this.list.querySelector('.e-virtual-ddl')) {
13336
+ var virualElement = this.createElement('div', {
13337
+ id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
13338
+ });
13339
+ document.getElementsByClassName('e-multi-select-list-wrapper')[0].querySelector('.e-dropdownbase').appendChild(virualElement);
13340
+ }
13305
13341
  }
13306
13342
  }
13307
13343
  }
@@ -13312,7 +13348,9 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
13312
13348
  if (this.keyCode !== 8) {
13313
13349
  this.focusAtFirstListItem();
13314
13350
  }
13315
- this.notify('reOrder', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', e: this });
13351
+ if (!isReordered) {
13352
+ this.notify('reOrder', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', e: this });
13353
+ }
13316
13354
  }
13317
13355
  }
13318
13356
  else {
@@ -13321,6 +13359,9 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
13321
13359
  this.list.scrollTop = 0;
13322
13360
  this.previousStartIndex = 0;
13323
13361
  this.virtualListInfo = null;
13362
+ if (this.list.querySelector('.e-list-parent' + '.e-reorder')) {
13363
+ this.list.querySelector('.e-list-parent' + '.e-reorder').remove();
13364
+ }
13324
13365
  }
13325
13366
  this.resetList(dataSource, fields, query);
13326
13367
  if (this.enableVirtualization && (isNoData || this.allowCustomValue) &&
@@ -15837,7 +15878,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
15837
15878
  endIndex: this.itemCount
15838
15879
  };
15839
15880
  };
15840
- MultiSelect.prototype.updateData = function (delimiterChar, e) {
15881
+ MultiSelect.prototype.updateData = function (delimiterChar, e, isInitialVirtualData) {
15841
15882
  var data = '';
15842
15883
  var delim = this.mode === 'Delimiter' || this.mode === 'CheckBox';
15843
15884
  var text = [];
@@ -15880,8 +15921,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
15880
15921
  text = this_1.text.split(delimiterChar);
15881
15922
  }
15882
15923
  else {
15883
- temp = this_1.getTextByValue(value);
15884
- var textValues = this_1.text != null && this_1.text !== '' ? this_1.text + ',' + temp : temp;
15924
+ temp = isInitialVirtualData && delim ? this_1.text : this_1.getTextByValue(value);
15925
+ var textValues = isInitialVirtualData ? this_1.text : (this_1.text && this_1.text !== '' ? this_1.text + ',' + temp : temp);
15885
15926
  data += temp + delimiterChar + ' ';
15886
15927
  text.push(textValues);
15887
15928
  hiddenElementContent = this_1.hiddenElement.innerHTML;
@@ -16012,8 +16053,11 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16012
16053
  text = null;
16013
16054
  if (listItems != null && listItems.length > 0) {
16014
16055
  for (var i = 0; i < listItems.length; i++) {
16015
- if (getValue((this.fields.value ? this.fields.value : 'value'), listItems[i]) === value) {
16016
- text = getValue(this.fields.text, listItems[i]);
16056
+ if ((this.isPrimitiveData && listItems[i] === value) || (!this.isPrimitiveData
16057
+ && getValue((this.fields.value ? this.fields.value :
16058
+ 'value'), listItems[i]) === value)) {
16059
+ text = this.isPrimitiveData ? listItems[i] :
16060
+ getValue(this.fields.text, listItems[i]);
16017
16061
  if (this.enableVirtualization) {
16018
16062
  if (isNullOrUndefined(this.selectedListData)) {
16019
16063
  this.selectedListData = [listItems[i]];
@@ -16099,7 +16143,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16099
16143
  this.refreshInputHight();
16100
16144
  }
16101
16145
  else {
16102
- this.updateDelimeter(this.delimiterChar);
16146
+ this.updateDelimeter(this.delimiterChar, null, isInitialVirtualData);
16103
16147
  }
16104
16148
  if (this.mode === 'CheckBox' && this.showSelectAll && (isNullOrUndefined(this.value) || !this.value.length)) {
16105
16149
  this.notify('checkSelectAll', { module: 'CheckBoxSelection', enable: this.mode === 'CheckBox', value: 'uncheck' });
@@ -16311,8 +16355,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16311
16355
  this.selectedElementID = element.id;
16312
16356
  }
16313
16357
  };
16314
- MultiSelect.prototype.updateDelimeter = function (delimChar, e) {
16315
- this.updateData(delimChar, e);
16358
+ MultiSelect.prototype.updateDelimeter = function (delimChar, e, isInitialVirtualData) {
16359
+ this.updateData(delimChar, e, isInitialVirtualData);
16316
16360
  };
16317
16361
  MultiSelect.prototype.onMouseClick = function (e) {
16318
16362
  var _this = this;
@@ -18061,7 +18105,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
18061
18105
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18062
18106
  var listItems_2;
18063
18107
  if (this.enableVirtualization) {
18064
- var fields = (this.fields.value) ? this.fields.value : '';
18108
+ var fields = !this.isPrimitiveData ? this.fields.value : '';
18065
18109
  var predicate = void 0;
18066
18110
  for (var i = 0; i < this.value.length; i++) {
18067
18111
  var value = this.allowObjectBinding ?
@@ -18093,7 +18137,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
18093
18137
  }
18094
18138
  }
18095
18139
  if (!(this.dataSource instanceof DataManager)) {
18096
- this.initialValueUpdate(listItems_2);
18140
+ this.initialValueUpdate(listItems_2, true);
18097
18141
  this.initialUpdate();
18098
18142
  }
18099
18143
  else {
@@ -18871,7 +18915,10 @@ var CheckBoxSelection = /** @__PURE__ @class */ (function () {
18871
18915
  this.parent.refreshPopup();
18872
18916
  this.clearIconElement.style.visibility = 'hidden';
18873
18917
  this.filterInput.focus();
18874
- this.setReorder(e);
18918
+ if (!this.parent.enableVirtualization || (this.parent.enableVirtualization && (isNullOrUndefined(this.parent.value)
18919
+ || (this.parent.value && this.parent.value.length === 0)))) {
18920
+ this.setReorder(e);
18921
+ }
18875
18922
  this.boundPreventListSelection = this.preventListSelection.bind(this);
18876
18923
  this.parent.popupWrapper.addEventListener('mouseup', this.boundPreventListSelection, true);
18877
18924
  e.preventDefault();
@@ -20772,11 +20819,13 @@ var ListBox = /** @__PURE__ @class */ (function (_super) {
20772
20819
  if (fListBox.value.length === 1 && fListBox.getSelectedItems().length) {
20773
20820
  fListBox.value[0] = fListBox.getFormattedValue(fListBox.getSelectedItems()[0].getAttribute('data-value'));
20774
20821
  }
20775
- if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length) {
20822
+ if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length && this.toolbarAction) {
20776
20823
  var wrap = this.list.parentElement.getElementsByClassName('e-listbox-tool')[0];
20777
20824
  var toolbarAction = this.toolbarAction === 'moveFrom' ? 'moveAllFrom' : 'moveAllTo';
20778
- var btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20779
- btn.disabled = true;
20825
+ if (wrap) {
20826
+ var btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20827
+ btn.disabled = true;
20828
+ }
20780
20829
  }
20781
20830
  };
20782
20831
  ListBox.prototype.selectNextList = function (elems, dataLiIdx, dataIdx, inst) {