@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.
@@ -1430,9 +1430,11 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1430
1430
  };
1431
1431
  DropDownBase.prototype.renderItemsBySelect = function () {
1432
1432
  var element = this.element;
1433
- var fields = { value: 'value', text: 'text' };
1434
- var jsonElement = [];
1435
1433
  var group = element.querySelectorAll('select>optgroup');
1434
+ var fields;
1435
+ var isSelectGroupCheck = this.getModuleName() === 'multiselect' && this.isGroupChecking && group.length > 0;
1436
+ fields = isSelectGroupCheck ? { value: 'value', text: 'text', groupBy: 'categeory' } : fields = { value: 'value', text: 'text' };
1437
+ var jsonElement = [];
1436
1438
  var option = element.querySelectorAll('select>option');
1437
1439
  this.getJSONfromOption(jsonElement, option, fields);
1438
1440
  if (group.length) {
@@ -1442,12 +1444,17 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1442
1444
  optionGroup[fields.text] = item.label;
1443
1445
  optionGroup.isHeader = true;
1444
1446
  var child = item.querySelectorAll('option');
1445
- jsonElement.push(optionGroup);
1446
- this.getJSONfromOption(jsonElement, child, fields);
1447
+ if (isSelectGroupCheck) {
1448
+ this.getJSONfromOption(jsonElement, child, fields, item.label);
1449
+ }
1450
+ else {
1451
+ jsonElement.push(optionGroup);
1452
+ this.getJSONfromOption(jsonElement, child, fields);
1453
+ }
1447
1454
  }
1448
1455
  element.querySelectorAll('select>option');
1449
1456
  }
1450
- this.updateFields(fields.text, fields.value, this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1457
+ this.updateFields(fields.text, fields.value, isSelectGroupCheck ? fields.groupBy : this.fields.groupBy, this.fields.htmlAttributes, this.fields.iconCss, this.fields.disabled);
1451
1458
  this.resetList(jsonElement, fields);
1452
1459
  };
1453
1460
  DropDownBase.prototype.updateFields = function (text, value, groupBy, htmlAttributes, iconCss, disabled) {
@@ -1463,13 +1470,17 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1463
1470
  };
1464
1471
  this.setProperties(field, true);
1465
1472
  };
1466
- DropDownBase.prototype.getJSONfromOption = function (items, options, fields) {
1473
+ DropDownBase.prototype.getJSONfromOption = function (items, options, fields, category) {
1474
+ if (category === void 0) { category = null; }
1467
1475
  for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
1468
1476
  var option = options_1[_i];
1469
1477
  var json = {};
1470
1478
  json[fields.text] = option.innerText;
1471
1479
  json[fields.value] = !isNullOrUndefined(option.getAttribute(fields.value)) ?
1472
1480
  option.getAttribute(fields.value) : option.innerText;
1481
+ if (!isNullOrUndefined(category)) {
1482
+ json[fields.groupBy] = category;
1483
+ }
1473
1484
  items.push(json);
1474
1485
  }
1475
1486
  };
@@ -1925,7 +1936,12 @@ var DropDownBase = /** @__PURE__ @class */ (function (_super) {
1925
1936
  if (this.sortOrder !== 'None') {
1926
1937
  dataSource = this.getSortedDataSource(dataSource);
1927
1938
  }
1928
- dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1939
+ if (this.element.querySelector('optgroup') && this.isGroupChecking && this.getModuleName() === 'multiselect') {
1940
+ dataSource = ListBase.groupDataSource(dataSource, fields, this.sortOrder);
1941
+ }
1942
+ else {
1943
+ dataSource = ListBase.groupDataSource(dataSource, fields.properties, this.sortOrder);
1944
+ }
1929
1945
  }
1930
1946
  addClass([this.list], dropDownBaseClasses.grouping);
1931
1947
  }
@@ -7994,6 +8010,11 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
7994
8010
  _this.checkAllParent.focus();
7995
8011
  }
7996
8012
  break;
8013
+ case 'tab':
8014
+ if (!_this.isPopupOpen && _this.inputFocus) {
8015
+ _this.onFocusOut();
8016
+ }
8017
+ break;
7997
8018
  }
7998
8019
  }
7999
8020
  });
@@ -15538,6 +15559,15 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
15538
15559
  this.previousEndIndex = 0;
15539
15560
  }
15540
15561
  }
15562
+ this.isClearAllItem = true;
15563
+ EventHandler.add(document, 'mouseup', this.preventSelection, this);
15564
+ };
15565
+ MultiSelect.prototype.preventSelection = function (e) {
15566
+ if (this.isClearAllItem) {
15567
+ e.stopPropagation();
15568
+ }
15569
+ this.isClearAllItem = false;
15570
+ EventHandler.remove(document, 'mouseup', this.preventSelection);
15541
15571
  };
15542
15572
  MultiSelect.prototype.clearAllCallback = function (e, isClearAll) {
15543
15573
  var tempValues = this.value ? this.value.slice() : [];
@@ -16302,127 +16332,131 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16302
16332
  };
16303
16333
  MultiSelect.prototype.onMouseClick = function (e) {
16304
16334
  var _this = this;
16305
- this.keyCode = null;
16306
- this.scrollFocusStatus = false;
16307
- this.keyboardEvent = null;
16308
- var target = e.target;
16309
- var li = closest(target, '.' + dropDownBaseClasses.li);
16310
- if (this.enableVirtualization && li && li.classList.contains('e-virtual-list')) {
16311
- return;
16312
- }
16313
- var headerLi = closest(target, '.' + dropDownBaseClasses.group);
16314
- if (headerLi && this.enableGroupCheckBox && this.mode === 'CheckBox' && this.fields.groupBy) {
16315
- target = target.classList.contains('e-list-group-item') ? target.firstElementChild.lastElementChild
16316
- : e.target;
16317
- if (target.classList.contains('e-check')) {
16318
- this.selectAllItem(false, e);
16319
- target.classList.remove('e-check');
16320
- target.classList.remove('e-stop');
16321
- closest(target, '.' + 'e-list-group-item').classList.remove('e-active');
16322
- target.setAttribute('aria-selected', 'false');
16323
- }
16324
- else {
16325
- this.selectAllItem(true, e);
16326
- target.classList.remove('e-stop');
16327
- target.classList.add('e-check');
16328
- closest(target, '.' + 'e-list-group-item').classList.add('e-active');
16329
- target.setAttribute('aria-selected', 'true');
16335
+ if (!this.isClearAllItem) {
16336
+ this.keyCode = null;
16337
+ this.scrollFocusStatus = false;
16338
+ this.keyboardEvent = null;
16339
+ var target = e.target;
16340
+ var li = closest(target, '.' + dropDownBaseClasses.li);
16341
+ if (this.enableVirtualization && li && li.classList.contains('e-virtual-list')) {
16342
+ return;
16330
16343
  }
16331
- this.refreshSelection();
16332
- this.checkSelectAll();
16333
- }
16334
- else {
16335
- if (this.isValidLI(li)) {
16336
- var limit = this.value && this.value.length ? this.value.length : 0;
16337
- if (li.classList.contains('e-active')) {
16338
- limit = limit - 1;
16344
+ var headerLi = closest(target, '.' + dropDownBaseClasses.group);
16345
+ if (headerLi && this.enableGroupCheckBox && this.mode === 'CheckBox' && this.fields.groupBy) {
16346
+ target = target.classList.contains('e-list-group-item') ? target.firstElementChild.lastElementChild
16347
+ : e.target;
16348
+ if (target.classList.contains('e-check')) {
16349
+ this.selectAllItem(false, e);
16350
+ target.classList.remove('e-check');
16351
+ target.classList.remove('e-stop');
16352
+ closest(target, '.' + 'e-list-group-item').classList.remove('e-active');
16353
+ target.setAttribute('aria-selected', 'false');
16339
16354
  }
16340
- if (limit < this.maximumSelectionLength) {
16341
- this.updateListSelection(li, e);
16342
- this.checkPlaceholderSize();
16343
- this.addListFocus(li);
16344
- if ((this.allowCustomValue || this.allowFiltering) && this.mainList && this.listData) {
16345
- if (this.mode !== 'CheckBox') {
16346
- this.focusAtLastListItem(li.getAttribute('data-value'));
16347
- this.refreshSelection();
16355
+ else {
16356
+ this.selectAllItem(true, e);
16357
+ target.classList.remove('e-stop');
16358
+ target.classList.add('e-check');
16359
+ closest(target, '.' + 'e-list-group-item').classList.add('e-active');
16360
+ target.setAttribute('aria-selected', 'true');
16361
+ }
16362
+ this.refreshSelection();
16363
+ this.checkSelectAll();
16364
+ }
16365
+ else {
16366
+ if (this.isValidLI(li)) {
16367
+ var limit = this.value && this.value.length ? this.value.length : 0;
16368
+ if (li.classList.contains('e-active')) {
16369
+ limit = limit - 1;
16370
+ }
16371
+ if (limit < this.maximumSelectionLength) {
16372
+ this.updateListSelection(li, e);
16373
+ this.checkPlaceholderSize();
16374
+ this.addListFocus(li);
16375
+ if ((this.allowCustomValue || this.allowFiltering) && this.mainList && this.listData) {
16376
+ if (this.mode !== 'CheckBox') {
16377
+ this.focusAtLastListItem(li.getAttribute('data-value'));
16378
+ this.refreshSelection();
16379
+ }
16380
+ }
16381
+ else {
16382
+ this.makeTextBoxEmpty();
16348
16383
  }
16349
16384
  }
16385
+ if (this.mode === 'CheckBox') {
16386
+ this.updateDelimView();
16387
+ if (this.value && this.value.length > 50) {
16388
+ setTimeout(function () {
16389
+ _this.updateDelimeter(_this.delimiterChar, e);
16390
+ }, 0);
16391
+ }
16392
+ else {
16393
+ this.updateDelimeter(this.delimiterChar, e);
16394
+ }
16395
+ this.refreshInputHight();
16396
+ }
16350
16397
  else {
16351
- this.makeTextBoxEmpty();
16398
+ this.updateDelimeter(this.delimiterChar, e);
16352
16399
  }
16353
- }
16354
- if (this.mode === 'CheckBox') {
16355
- this.updateDelimView();
16356
- if (this.value && this.value.length > 50) {
16357
- setTimeout(function () {
16358
- _this.updateDelimeter(_this.delimiterChar, e);
16359
- }, 0);
16400
+ this.checkSelectAll();
16401
+ this.refreshPopup();
16402
+ if (this.hideSelectedItem) {
16403
+ this.focusAtFirstListItem();
16404
+ }
16405
+ if (this.closePopupOnSelect) {
16406
+ this.hidePopup(e);
16360
16407
  }
16361
16408
  else {
16362
- this.updateDelimeter(this.delimiterChar, e);
16409
+ e.preventDefault();
16410
+ }
16411
+ var isFilterData = this.targetElement().trim() !== '' ? true : false;
16412
+ this.makeTextBoxEmpty();
16413
+ this.findGroupStart(target);
16414
+ if (this.mode !== 'CheckBox') {
16415
+ this.refreshListItems(isNullOrUndefined(li) ? null : li.textContent, isFilterData);
16363
16416
  }
16364
- this.refreshInputHight();
16365
- }
16366
- else {
16367
- this.updateDelimeter(this.delimiterChar, e);
16368
- }
16369
- this.checkSelectAll();
16370
- this.refreshPopup();
16371
- if (this.hideSelectedItem) {
16372
- this.focusAtFirstListItem();
16373
- }
16374
- if (this.closePopupOnSelect) {
16375
- this.hidePopup(e);
16376
16417
  }
16377
16418
  else {
16378
16419
  e.preventDefault();
16379
16420
  }
16380
- var isFilterData = this.targetElement().trim() !== '' ? true : false;
16381
- this.makeTextBoxEmpty();
16382
- this.findGroupStart(target);
16383
- if (this.mode !== 'CheckBox') {
16384
- this.refreshListItems(isNullOrUndefined(li) ? null : li.textContent, isFilterData);
16385
- }
16386
- }
16387
- else {
16388
- e.preventDefault();
16389
- }
16390
- if (this.enableVirtualization && this.hideSelectedItem) {
16391
- var visibleListElements = this.list.querySelectorAll('li.'
16392
- + dropDownBaseClasses.li
16393
- + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)' + ':not(.e-virtual-list)');
16394
- if (visibleListElements.length) {
16395
- var actualCount = this.virtualListHeight > 0 ? Math.floor(this.virtualListHeight / this.listItemHeight) : 0;
16396
- if (visibleListElements.length < (actualCount + 2)) {
16397
- var query = this.getForQuery(this.value).clone();
16398
- query = query.skip(this.virtualItemStartIndex);
16399
- this.resetList(this.dataSource, this.fields, query);
16400
- this.UpdateSkeleton();
16401
- this.liCollections = this.list.querySelectorAll('.' + dropDownBaseClasses.li);
16402
- this.virtualItemCount = this.itemCount;
16403
- if (this.mode !== 'CheckBox') {
16404
- this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
16405
- this.totalItemCount;
16406
- }
16407
- if (!this.list.querySelector('.e-virtual-ddl')) {
16408
- var virualElement = this.createElement('div', {
16409
- id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
16410
- });
16411
- this.popupWrapper.querySelector('.e-dropdownbase').appendChild(virualElement);
16412
- }
16413
- else {
16414
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16415
- this.list.getElementsByClassName('e-virtual-ddl')[0].style = this.GetVirtualTrackHeight();
16416
- }
16417
- if (this.list.querySelector('.e-virtual-ddl-content')) {
16418
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16419
- this.list.getElementsByClassName('e-virtual-ddl-content')[0].style = this.getTransformValues();
16421
+ if (this.enableVirtualization && this.hideSelectedItem) {
16422
+ var visibleListElements = this.list.querySelectorAll('li.'
16423
+ + dropDownBaseClasses.li
16424
+ + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)' + ':not(.e-virtual-list)');
16425
+ if (visibleListElements.length) {
16426
+ var actualCount = this.virtualListHeight > 0 ?
16427
+ Math.floor(this.virtualListHeight / this.listItemHeight) : 0;
16428
+ if (visibleListElements.length < (actualCount + 2)) {
16429
+ var query = this.getForQuery(this.value).clone();
16430
+ query = query.skip(this.virtualItemStartIndex);
16431
+ this.resetList(this.dataSource, this.fields, query);
16432
+ this.UpdateSkeleton();
16433
+ this.liCollections = this.list.querySelectorAll('.'
16434
+ + dropDownBaseClasses.li);
16435
+ this.virtualItemCount = this.itemCount;
16436
+ if (this.mode !== 'CheckBox') {
16437
+ this.totalItemCount = this.value && this.value.length ? this.totalItemCount - this.value.length :
16438
+ this.totalItemCount;
16439
+ }
16440
+ if (!this.list.querySelector('.e-virtual-ddl')) {
16441
+ var virualElement = this.createElement('div', {
16442
+ id: this.element.id + '_popup', className: 'e-virtual-ddl', styles: this.GetVirtualTrackHeight()
16443
+ });
16444
+ this.popupWrapper.querySelector('.e-dropdownbase').appendChild(virualElement);
16445
+ }
16446
+ else {
16447
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16448
+ this.list.getElementsByClassName('e-virtual-ddl')[0].style = this.GetVirtualTrackHeight();
16449
+ }
16450
+ if (this.list.querySelector('.e-virtual-ddl-content')) {
16451
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16452
+ this.list.getElementsByClassName('e-virtual-ddl-content')[0].style = this.getTransformValues();
16453
+ }
16420
16454
  }
16421
16455
  }
16422
16456
  }
16457
+ this.refreshPlaceHolder();
16458
+ this.deselectHeader();
16423
16459
  }
16424
- this.refreshPlaceHolder();
16425
- this.deselectHeader();
16426
16460
  }
16427
16461
  };
16428
16462
  MultiSelect.prototype.findGroupStart = function (target) {
@@ -20754,11 +20788,13 @@ var ListBox = /** @__PURE__ @class */ (function (_super) {
20754
20788
  if (fListBox.value.length === 1 && fListBox.getSelectedItems().length) {
20755
20789
  fListBox.value[0] = fListBox.getFormattedValue(fListBox.getSelectedItems()[0].getAttribute('data-value'));
20756
20790
  }
20757
- if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length) {
20791
+ if (fListBox.liCollections.length === fListBox.ulElement.querySelectorAll('.e-disabled').length && this.toolbarAction) {
20758
20792
  var wrap = this.list.parentElement.getElementsByClassName('e-listbox-tool')[0];
20759
20793
  var toolbarAction = this.toolbarAction === 'moveFrom' ? 'moveAllFrom' : 'moveAllTo';
20760
- var btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20761
- btn.disabled = true;
20794
+ if (wrap) {
20795
+ var btn = wrap.querySelector('[data-value="' + toolbarAction + '"]');
20796
+ btn.disabled = true;
20797
+ }
20762
20798
  }
20763
20799
  };
20764
20800
  ListBox.prototype.selectNextList = function (elems, dataLiIdx, dataIdx, inst) {