@syncfusion/ej2-dropdowns 27.1.58 → 27.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.
@@ -1349,9 +1349,11 @@ let DropDownBase = class DropDownBase extends Component {
1349
1349
  }
1350
1350
  renderItemsBySelect() {
1351
1351
  const element = this.element;
1352
- const fields = { value: 'value', text: 'text' };
1353
- const jsonElement = [];
1354
1352
  const group = element.querySelectorAll('select>optgroup');
1353
+ let fields;
1354
+ const isSelectGroupCheck = this.getModuleName() === 'multiselect' && this.isGroupChecking && group.length > 0;
1355
+ fields = isSelectGroupCheck ? { value: 'value', text: 'text', groupBy: 'categeory' } : fields = { value: 'value', text: 'text' };
1356
+ const jsonElement = [];
1355
1357
  const option = element.querySelectorAll('select>option');
1356
1358
  this.getJSONfromOption(jsonElement, option, fields);
1357
1359
  if (group.length) {
@@ -1361,12 +1363,17 @@ let DropDownBase = class DropDownBase extends Component {
1361
1363
  optionGroup[fields.text] = item.label;
1362
1364
  optionGroup.isHeader = true;
1363
1365
  const child = item.querySelectorAll('option');
1364
- jsonElement.push(optionGroup);
1365
- this.getJSONfromOption(jsonElement, child, fields);
1366
+ if (isSelectGroupCheck) {
1367
+ this.getJSONfromOption(jsonElement, child, fields, item.label);
1368
+ }
1369
+ else {
1370
+ jsonElement.push(optionGroup);
1371
+ this.getJSONfromOption(jsonElement, child, fields);
1372
+ }
1366
1373
  }
1367
1374
  element.querySelectorAll('select>option');
1368
1375
  }
1369
- this.updateFields(fields.text, fields.value, this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1376
+ this.updateFields(fields.text, fields.value, isSelectGroupCheck ? fields.groupBy : this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1370
1377
  this.resetList(jsonElement, fields);
1371
1378
  }
1372
1379
  updateFields(text, value, groupBy, htmlAttributes, iconCss, disabled) {
@@ -1382,12 +1389,15 @@ let DropDownBase = class DropDownBase extends Component {
1382
1389
  };
1383
1390
  this.setProperties(field, true);
1384
1391
  }
1385
- getJSONfromOption(items, options, fields) {
1392
+ getJSONfromOption(items, options, fields, category = null) {
1386
1393
  for (const option of options) {
1387
1394
  const json = {};
1388
1395
  json[fields.text] = option.innerText;
1389
1396
  json[fields.value] = !isNullOrUndefined(option.getAttribute(fields.value)) ?
1390
1397
  option.getAttribute(fields.value) : option.innerText;
1398
+ if (!isNullOrUndefined(category)) {
1399
+ json[fields.groupBy] = category;
1400
+ }
1391
1401
  items.push(json);
1392
1402
  }
1393
1403
  }
@@ -1841,7 +1851,12 @@ let DropDownBase = class DropDownBase extends Component {
1841
1851
  if (this.sortOrder !== 'None') {
1842
1852
  dataSource = this.getSortedDataSource(dataSource);
1843
1853
  }
1844
- dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1854
+ if (this.element.querySelector('optgroup') && this.isGroupChecking && this.getModuleName() === 'multiselect') {
1855
+ dataSource = ListBase.groupDataSource(dataSource, fields, this.sortOrder);
1856
+ }
1857
+ else {
1858
+ dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1859
+ }
1845
1860
  }
1846
1861
  addClass([this.list], dropDownBaseClasses.grouping);
1847
1862
  }
@@ -7821,6 +7836,11 @@ let DropDownTree = class DropDownTree extends Component {
7821
7836
  this.checkAllParent.focus();
7822
7837
  }
7823
7838
  break;
7839
+ case 'tab':
7840
+ if (!this.isPopupOpen && this.inputFocus) {
7841
+ this.onFocusOut();
7842
+ }
7843
+ break;
7824
7844
  }
7825
7845
  }
7826
7846
  });
@@ -15274,6 +15294,15 @@ let MultiSelect = class MultiSelect extends DropDownBase {
15274
15294
  this.previousEndIndex = 0;
15275
15295
  }
15276
15296
  }
15297
+ this.isClearAllItem = true;
15298
+ EventHandler.add(document, 'mouseup', this.preventSelection, this);
15299
+ }
15300
+ preventSelection(e) {
15301
+ if (this.isClearAllItem) {
15302
+ e.stopPropagation();
15303
+ }
15304
+ this.isClearAllItem = false;
15305
+ EventHandler.remove(document, 'mouseup', this.preventSelection);
15277
15306
  }
15278
15307
  clearAllCallback(e, isClearAll) {
15279
15308
  const tempValues = this.value ? this.value.slice() : [];
@@ -16026,127 +16055,131 @@ let MultiSelect = class MultiSelect extends DropDownBase {
16026
16055
  this.updateData(delimChar, e);
16027
16056
  }
16028
16057
  onMouseClick(e) {
16029
- this.keyCode = null;
16030
- this.scrollFocusStatus = false;
16031
- this.keyboardEvent = null;
16032
- let target = e.target;
16033
- const li = closest(target, '.' + dropDownBaseClasses.li);
16034
- if (this.enableVirtualization && li && li.classList.contains('e-virtual-list')) {
16035
- return;
16036
- }
16037
- const headerLi = closest(target, '.' + dropDownBaseClasses.group);
16038
- if (headerLi && this.enableGroupCheckBox && this.mode === 'CheckBox' && this.fields.groupBy) {
16039
- target = target.classList.contains('e-list-group-item') ? target.firstElementChild.lastElementChild
16040
- : e.target;
16041
- if (target.classList.contains('e-check')) {
16042
- this.selectAllItem(false, e);
16043
- target.classList.remove('e-check');
16044
- target.classList.remove('e-stop');
16045
- closest(target, '.' + 'e-list-group-item').classList.remove('e-active');
16046
- target.setAttribute('aria-selected', 'false');
16047
- }
16048
- else {
16049
- this.selectAllItem(true, e);
16050
- target.classList.remove('e-stop');
16051
- target.classList.add('e-check');
16052
- closest(target, '.' + 'e-list-group-item').classList.add('e-active');
16053
- target.setAttribute('aria-selected', 'true');
16058
+ if (!this.isClearAllItem) {
16059
+ this.keyCode = null;
16060
+ this.scrollFocusStatus = false;
16061
+ this.keyboardEvent = null;
16062
+ let target = e.target;
16063
+ const li = closest(target, '.' + dropDownBaseClasses.li);
16064
+ if (this.enableVirtualization && li && li.classList.contains('e-virtual-list')) {
16065
+ return;
16054
16066
  }
16055
- this.refreshSelection();
16056
- this.checkSelectAll();
16057
- }
16058
- else {
16059
- if (this.isValidLI(li)) {
16060
- let limit = this.value && this.value.length ? this.value.length : 0;
16061
- if (li.classList.contains('e-active')) {
16062
- limit = limit - 1;
16067
+ const headerLi = closest(target, '.' + dropDownBaseClasses.group);
16068
+ if (headerLi && this.enableGroupCheckBox && this.mode === 'CheckBox' && this.fields.groupBy) {
16069
+ target = target.classList.contains('e-list-group-item') ? target.firstElementChild.lastElementChild
16070
+ : e.target;
16071
+ if (target.classList.contains('e-check')) {
16072
+ this.selectAllItem(false, e);
16073
+ target.classList.remove('e-check');
16074
+ target.classList.remove('e-stop');
16075
+ closest(target, '.' + 'e-list-group-item').classList.remove('e-active');
16076
+ target.setAttribute('aria-selected', 'false');
16063
16077
  }
16064
- if (limit < this.maximumSelectionLength) {
16065
- this.updateListSelection(li, e);
16066
- this.checkPlaceholderSize();
16067
- this.addListFocus(li);
16068
- if ((this.allowCustomValue || this.allowFiltering) && this.mainList && this.listData) {
16069
- if (this.mode !== 'CheckBox') {
16070
- this.focusAtLastListItem(li.getAttribute('data-value'));
16071
- this.refreshSelection();
16072
- }
16078
+ else {
16079
+ this.selectAllItem(true, e);
16080
+ target.classList.remove('e-stop');
16081
+ target.classList.add('e-check');
16082
+ closest(target, '.' + 'e-list-group-item').classList.add('e-active');
16083
+ target.setAttribute('aria-selected', 'true');
16084
+ }
16085
+ this.refreshSelection();
16086
+ this.checkSelectAll();
16087
+ }
16088
+ else {
16089
+ if (this.isValidLI(li)) {
16090
+ let limit = this.value && this.value.length ? this.value.length : 0;
16091
+ if (li.classList.contains('e-active')) {
16092
+ limit = limit - 1;
16073
16093
  }
16074
- else {
16075
- this.makeTextBoxEmpty();
16094
+ if (limit < this.maximumSelectionLength) {
16095
+ this.updateListSelection(li, e);
16096
+ this.checkPlaceholderSize();
16097
+ this.addListFocus(li);
16098
+ if ((this.allowCustomValue || this.allowFiltering) && this.mainList && this.listData) {
16099
+ if (this.mode !== 'CheckBox') {
16100
+ this.focusAtLastListItem(li.getAttribute('data-value'));
16101
+ this.refreshSelection();
16102
+ }
16103
+ }
16104
+ else {
16105
+ this.makeTextBoxEmpty();
16106
+ }
16076
16107
  }
16077
- }
16078
- if (this.mode === 'CheckBox') {
16079
- this.updateDelimView();
16080
- if (this.value && this.value.length > 50) {
16081
- setTimeout(() => {
16108
+ if (this.mode === 'CheckBox') {
16109
+ this.updateDelimView();
16110
+ if (this.value && this.value.length > 50) {
16111
+ setTimeout(() => {
16112
+ this.updateDelimeter(this.delimiterChar, e);
16113
+ }, 0);
16114
+ }
16115
+ else {
16082
16116
  this.updateDelimeter(this.delimiterChar, e);
16083
- }, 0);
16117
+ }
16118
+ this.refreshInputHight();
16084
16119
  }
16085
16120
  else {
16086
16121
  this.updateDelimeter(this.delimiterChar, e);
16087
16122
  }
16088
- this.refreshInputHight();
16089
- }
16090
- else {
16091
- this.updateDelimeter(this.delimiterChar, e);
16092
- }
16093
- this.checkSelectAll();
16094
- this.refreshPopup();
16095
- if (this.hideSelectedItem) {
16096
- this.focusAtFirstListItem();
16097
- }
16098
- if (this.closePopupOnSelect) {
16099
- this.hidePopup(e);
16123
+ this.checkSelectAll();
16124
+ this.refreshPopup();
16125
+ if (this.hideSelectedItem) {
16126
+ this.focusAtFirstListItem();
16127
+ }
16128
+ if (this.closePopupOnSelect) {
16129
+ this.hidePopup(e);
16130
+ }
16131
+ else {
16132
+ e.preventDefault();
16133
+ }
16134
+ const isFilterData = this.targetElement().trim() !== '' ? true : false;
16135
+ this.makeTextBoxEmpty();
16136
+ this.findGroupStart(target);
16137
+ if (this.mode !== 'CheckBox') {
16138
+ this.refreshListItems(isNullOrUndefined(li) ? null : li.textContent, isFilterData);
16139
+ }
16100
16140
  }
16101
16141
  else {
16102
16142
  e.preventDefault();
16103
16143
  }
16104
- const isFilterData = this.targetElement().trim() !== '' ? true : false;
16105
- this.makeTextBoxEmpty();
16106
- this.findGroupStart(target);
16107
- if (this.mode !== 'CheckBox') {
16108
- this.refreshListItems(isNullOrUndefined(li) ? null : li.textContent, isFilterData);
16109
- }
16110
- }
16111
- else {
16112
- e.preventDefault();
16113
- }
16114
- if (this.enableVirtualization && this.hideSelectedItem) {
16115
- const visibleListElements = this.list.querySelectorAll('li.'
16116
- + dropDownBaseClasses.li
16117
- + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)' + ':not(.e-virtual-list)');
16118
- if (visibleListElements.length) {
16119
- const actualCount = this.virtualListHeight > 0 ? Math.floor(this.virtualListHeight / this.listItemHeight) : 0;
16120
- if (visibleListElements.length < (actualCount + 2)) {
16121
- let query = this.getForQuery(this.value).clone();
16122
- query = query.skip(this.virtualItemStartIndex);
16123
- this.resetList(this.dataSource, this.fields, query);
16124
- this.UpdateSkeleton();
16125
- this.liCollections = this.list.querySelectorAll('.' + dropDownBaseClasses.li);
16126
- this.virtualItemCount = this.itemCount;
16127
- if (this.mode !== 'CheckBox') {
16128
- this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
16129
- this.totalItemCount;
16130
- }
16131
- if (!this.list.querySelector('.e-virtual-ddl')) {
16132
- const virualElement = this.createElement('div', {
16133
- id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
16134
- });
16135
- this.popupWrapper.querySelector('.e-dropdownbase').appendChild(virualElement);
16136
- }
16137
- else {
16138
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16139
- this.list.getElementsByClassName('e-virtual-ddl')[0].style = this.GetVirtualTrackHeight();
16140
- }
16141
- if (this.list.querySelector('.e-virtual-ddl-content')) {
16142
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16143
- this.list.getElementsByClassName('e-virtual-ddl-content')[0].style = this.getTransformValues();
16144
+ if (this.enableVirtualization && this.hideSelectedItem) {
16145
+ const visibleListElements = this.list.querySelectorAll('li.'
16146
+ + dropDownBaseClasses.li
16147
+ + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)' + ':not(.e-virtual-list)');
16148
+ if (visibleListElements.length) {
16149
+ const actualCount = this.virtualListHeight > 0 ?
16150
+ Math.floor(this.virtualListHeight / this.listItemHeight) : 0;
16151
+ if (visibleListElements.length < (actualCount + 2)) {
16152
+ let query = this.getForQuery(this.value).clone();
16153
+ query = query.skip(this.virtualItemStartIndex);
16154
+ this.resetList(this.dataSource, this.fields, query);
16155
+ this.UpdateSkeleton();
16156
+ this.liCollections = this.list.querySelectorAll('.'
16157
+ + dropDownBaseClasses.li);
16158
+ this.virtualItemCount = this.itemCount;
16159
+ if (this.mode !== 'CheckBox') {
16160
+ this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
16161
+ this.totalItemCount;
16162
+ }
16163
+ if (!this.list.querySelector('.e-virtual-ddl')) {
16164
+ const virualElement = this.createElement('div', {
16165
+ id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
16166
+ });
16167
+ this.popupWrapper.querySelector('.e-dropdownbase').appendChild(virualElement);
16168
+ }
16169
+ else {
16170
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16171
+ this.list.getElementsByClassName('e-virtual-ddl')[0].style = this.GetVirtualTrackHeight();
16172
+ }
16173
+ if (this.list.querySelector('.e-virtual-ddl-content')) {
16174
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16175
+ this.list.getElementsByClassName('e-virtual-ddl-content')[0].style = this.getTransformValues();
16176
+ }
16144
16177
  }
16145
16178
  }
16146
16179
  }
16180
+ this.refreshPlaceHolder();
16181
+ this.deselectHeader();
16147
16182
  }
16148
- this.refreshPlaceHolder();
16149
- this.deselectHeader();
16150
16183
  }
16151
16184
  }
16152
16185
  findGroupStart(target) {
@@ -20412,11 +20445,13 @@ let ListBox = ListBox_1 = class ListBox extends DropDownBase {
20412
20445
  if (fListBox.value.length === 1 && fListBox.getSelectedItems().length) {
20413
20446
  fListBox.value[0] = fListBox.getFormattedValue(fListBox.getSelectedItems()[0].getAttribute('data-value'));
20414
20447
  }
20415
- if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length) {
20448
+ if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length && this.toolbarAction) {
20416
20449
  const wrap = this.list.parentElement.getElementsByClassName('e-listbox-tool')[0];
20417
20450
  const toolbarAction = this.toolbarAction === 'moveFrom' ? 'moveAllFrom' : 'moveAllTo';
20418
- const btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20419
- btn.disabled = true;
20451
+ if (wrap) {
20452
+ const btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20453
+ btn.disabled = true;
20454
+ }
20420
20455
  }
20421
20456
  }
20422
20457
  selectNextList(elems, dataLiIdx, dataIdx, inst) {