@syncfusion/ej2-ribbon 23.1.36 → 23.1.41

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.
@@ -3731,7 +3731,7 @@ let Ribbon = Ribbon_1 = class Ribbon extends Component {
3731
3731
  if (((item.displayOptions === DisplayMode.Auto) ||
3732
3732
  (item.displayOptions === (DisplayMode.Simplified | DisplayMode.Overflow))) && !isNullOrUndefined(itemContainer)) {
3733
3733
  itemContainer.setAttribute('data-simplified-width', activeContent.offsetWidth.toString());
3734
- this.createOverflowPopup(item, tabIndex, group.enableGroupOverflow, group.id, group.header, itemContainer, groupContainer);
3734
+ this.createOverflowPopup(item, tabIndex, group.enableGroupOverflow, group.id, group.header, itemContainer, groupContainer, true);
3735
3735
  if (item.activeSize === RibbonItemSize.Small) {
3736
3736
  const itemEle = itemContainer.querySelector('#' + item.id);
3737
3737
  item.setProperties({ activeSize: RibbonItemSize.Medium }, true);
@@ -3851,7 +3851,7 @@ let Ribbon = Ribbon_1 = class Ribbon extends Component {
3851
3851
  }
3852
3852
  }
3853
3853
  }
3854
- createOverflowPopup(item, tabIndex, isGroupOF, groupId, groupHeader, itemEle, groupContainer) {
3854
+ createOverflowPopup(item, tabIndex, isGroupOF, groupId, groupHeader, itemEle, groupContainer, isResize) {
3855
3855
  let overflowButton;
3856
3856
  const contentEle = this.tabObj.items[parseInt(tabIndex.toString(), 10)].content;
3857
3857
  const isDisabledGroup = contentEle.querySelector('#' + groupId);
@@ -3865,10 +3865,12 @@ let Ribbon = Ribbon_1 = class Ribbon extends Component {
3865
3865
  else {
3866
3866
  overflowButton = getInstance(overflowDDB, DropDownButton);
3867
3867
  }
3868
+ const overflowBtnTarget = overflowButton.target;
3868
3869
  if (isDisabledGroup && isDisabledGroup.classList.contains('e-disabled')) {
3869
- overflowButton.target.classList.add('e-disabled');
3870
+ overflowBtnTarget.classList.add('e-disabled');
3870
3871
  }
3871
- overflowButton.target.append(itemEle);
3872
+ isResize ? overflowBtnTarget.insertBefore(itemEle, overflowBtnTarget.querySelector('.' + RIBBON_ITEM))
3873
+ : overflowBtnTarget.append(itemEle);
3872
3874
  }
3873
3875
  else {
3874
3876
  if (!this.overflowDDB) {
@@ -3890,7 +3892,7 @@ let Ribbon = Ribbon_1 = class Ribbon extends Component {
3890
3892
  }
3891
3893
  ofTabContainer.append(ofGroupContainer);
3892
3894
  }
3893
- ofGroupContainer.append(itemEle);
3895
+ isResize ? ofGroupContainer.insertBefore(itemEle, ofGroupContainer.querySelector('.' + RIBBON_ITEM)) : ofGroupContainer.append(itemEle);
3894
3896
  }
3895
3897
  else {
3896
3898
  this.createOfTabContainer(groupId, groupHeader, itemEle, tabIndex);
@@ -4932,21 +4934,79 @@ let Ribbon = Ribbon_1 = class Ribbon extends Component {
4932
4934
  remove(this.tabObj.element.querySelector('.' + RIBBON_COLLAPSE_BUTTON));
4933
4935
  this.collapseButton = null;
4934
4936
  }
4935
- reRenderTabs() {
4937
+ reRenderTabs(tabs) {
4936
4938
  this.destroyScroll();
4937
4939
  this.checkID(this.tabs, 'tab', this.element.id);
4938
- this.destroyTabItems(this.tabsInternal);
4939
- this.tabsInternal = this.tabs.slice();
4940
- this.validateItemSize();
4941
- const tabItems = this.createTabItems(this.tabs);
4942
- if (this.selectedTab >= this.tabs.length) {
4943
- this.selectedTab = this.tabs.length - 1;
4944
- }
4945
- this.tabObj.setProperties({ items: tabItems, selectedItem: this.selectedTab });
4946
- const contentEle = this.tabObj.items[this.selectedTab].content;
4947
- if (contentEle.innerHTML === '') {
4948
- this.renderInitialTab(this.selectedTab);
4940
+ for (const key in tabs) {
4941
+ const index = parseInt(key, 10);
4942
+ const tab = tabs[parseInt(index.toString(), 10)];
4943
+ let isNewTab = false;
4944
+ for (var j = 0; j < (this.tabObj.items.length); j++) {
4945
+ if (this.tabs[parseInt(index.toString(), 10)].id === this.tabObj.items[parseInt(j.toString(), 10)].id) {
4946
+ isNewTab = true;
4947
+ break;
4948
+ }
4949
+ }
4950
+ if (!isNewTab) {
4951
+ this.destroyTabItems(this.tabsInternal);
4952
+ this.tabsInternal = this.tabs.slice();
4953
+ this.validateItemSize();
4954
+ const tabItems = this.createTabItems(this.tabs);
4955
+ if (this.selectedTab >= this.tabs.length) {
4956
+ this.selectedTab = this.tabs.length - 1;
4957
+ }
4958
+ this.tabObj.setProperties({ items: tabItems, selectedItem: this.selectedTab });
4959
+ break;
4960
+ }
4961
+ else {
4962
+ const groups = this.tabs[parseInt(index.toString(), 10)].groups;
4963
+ const tabEle = this.tabObj.element;
4964
+ const ribbonTab = this.tabs[parseInt(index.toString(), 10)];
4965
+ ribbonTab.setProperties(tab, true);
4966
+ this.setProperties({ groups: this.checkID(ribbonTab.groups, 'group', ribbonTab.id) }, true);
4967
+ this.validateItemSize();
4968
+ const contentEle = this.tabObj.items[parseInt(index.toString(), 10)].content;
4969
+ if (groups) {
4970
+ // Check whether header is passed by the user and sets the updated values.
4971
+ if (tab.header) {
4972
+ this.tabObj.items[parseInt(index.toString(), 10)].header.text.innerText = ribbonTab.header;
4973
+ }
4974
+ // Check whether cssClass is passed by the user, and if it is, then remove the old values.
4975
+ if (tab.cssClass) {
4976
+ if (this.tabObj.items[parseInt(index.toString(), 10)].cssClass) {
4977
+ contentEle.classList.remove(this.tabObj.items[parseInt(index.toString(), 10)].cssClass);
4978
+ tabEle.querySelector('.e-active').classList.remove(this.tabObj.items[parseInt(index.toString(), 10)].cssClass);
4979
+ }
4980
+ contentEle.classList.add(ribbonTab.cssClass);
4981
+ tabEle.querySelector('.e-active').classList.add(ribbonTab.cssClass);
4982
+ }
4983
+ // Check whether group is passed by the user, and if it is, then remove the old values.
4984
+ if (tab.groups) {
4985
+ for (const group of groups) {
4986
+ const dropdownElement = group.isCollapsed ? contentEle.querySelector('#' + group.id + OVERFLOW_ID + DROPDOWN_ID) : null;
4987
+ for (const collection of group.collections) {
4988
+ for (const item of collection.items) {
4989
+ const ele = dropdownElement ? this.ribbonDropDownModule.getDDBItemElement(dropdownElement, item.id) : contentEle.querySelector('#' + item.id);
4990
+ if (ele) {
4991
+ this.destroyFunction(item, ele);
4992
+ }
4993
+ }
4994
+ }
4995
+ if (dropdownElement) {
4996
+ this.ribbonDropDownModule.removeOverFlowDropDown(dropdownElement);
4997
+ }
4998
+ }
4999
+ const groupElements = contentEle.querySelectorAll('.e-ribbon-group');
5000
+ // eslint-disable-next-line @typescript-eslint/tslint/config
5001
+ groupElements.forEach(groupEle => { groupEle.remove(); });
5002
+ const elements = this.createGroups(ribbonTab.groups, index);
5003
+ append(elements, contentEle);
5004
+ }
5005
+ }
5006
+ }
4949
5007
  }
5008
+ const activeContent = this.tabObj.element.querySelector('#' + this.tabs[this.selectedTab].id + CONTENT_ID);
5009
+ this.checkOverflow(this.selectedTab, activeContent);
4950
5010
  }
4951
5011
  switchLayout() {
4952
5012
  this.currentControlIndex = 0;
@@ -6730,7 +6790,7 @@ let Ribbon = Ribbon_1 = class Ribbon extends Component {
6730
6790
  this.tabObj.setProperties({ animation: newProp.tabAnimation });
6731
6791
  break;
6732
6792
  case 'tabs':
6733
- this.reRenderTabs();
6793
+ this.reRenderTabs(newProp.tabs);
6734
6794
  break;
6735
6795
  case 'width':
6736
6796
  this.element.style.width = formatUnit(newProp.width);