Skip to content

Commit

Permalink
TabPanel: Add stylingMode option
Browse files Browse the repository at this point in the history
  • Loading branch information
marker-dao authored Sep 8, 2023
1 parent a9a5dbf commit 2cec6f8
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ export abstract class DxoTabPanelOptions extends NestedOption {
this._setOption('showNavButtons', value);
}

get stylingMode(): string {
return this._getOption('stylingMode');
}
set stylingMode(value: string) {
this._setOption('stylingMode', value);
}

get swipeEnabled(): boolean {
return this._getOption('swipeEnabled');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import { DxiItemComponent } from './item-dxi';
'selectedIndex',
'selectedItem',
'showNavButtons',
'stylingMode',
'swipeEnabled',
'tabIndex',
'tabsPosition',
Expand Down
21 changes: 21 additions & 0 deletions packages/devextreme-angular/src/ui/tab-panel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,19 @@ export class DxTabPanelComponent extends DxComponent implements OnDestroy, OnCha
}


/**
* [descr:dxTabPanelOptions.stylingMode]
*/
@Input()
get stylingMode(): string {
return this._getOption('stylingMode');
}
set stylingMode(value: string) {
this._setOption('stylingMode', value);
}


/**
* [descr:dxTabPanelOptions.swipeEnabled]
Expand Down Expand Up @@ -725,6 +738,13 @@ export class DxTabPanelComponent extends DxComponent implements OnDestroy, OnCha
*/
@Output() showNavButtonsChange: EventEmitter<boolean>;

/**
* This member supports the internal infrastructure and is not intended to be used directly from your code.
*/
@Output() stylingModeChange: EventEmitter<string>;

/**
* This member supports the internal infrastructure and is not intended to be used directly from your code.
Expand Down Expand Up @@ -821,6 +841,7 @@ export class DxTabPanelComponent extends DxComponent implements OnDestroy, OnCha
{ emit: 'selectedIndexChange' },
{ emit: 'selectedItemChange' },
{ emit: 'showNavButtonsChange' },
{ emit: 'stylingModeChange' },
{ emit: 'swipeEnabledChange' },
{ emit: 'tabIndexChange' },
{ emit: 'tabsPositionChange' },
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme-react/src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ type ITabPanelOptionsProps = React.PropsWithChildren<{
selectedIndex?: number;
selectedItem?: any;
showNavButtons?: boolean;
stylingMode?: "primary" | "secondary";
swipeEnabled?: boolean;
tabIndex?: number;
tabsPosition?: "bottom" | "left" | "right" | "top";
Expand Down
6 changes: 6 additions & 0 deletions packages/devextreme-react/src/tab-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ class TabPanel<TItem = any, TKey = any> extends BaseComponent<React.PropsWithChi
scrollingEnabled: PropTypes.bool,
selectedIndex: PropTypes.number,
showNavButtons: PropTypes.bool,
stylingMode: PropTypes.oneOfType([
PropTypes.string,
PropTypes.oneOf([
"primary",
"secondary"])
]),
swipeEnabled: PropTypes.bool,
tabIndex: PropTypes.number,
tabsPosition: PropTypes.oneOfType([
Expand Down
2 changes: 2 additions & 0 deletions packages/devextreme-vue/src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ const DxTabPanelOptions = createConfigurationComponent({
"update:selectedIndex": null,
"update:selectedItem": null,
"update:showNavButtons": null,
"update:stylingMode": null,
"update:swipeEnabled": null,
"update:tabIndex": null,
"update:tabsPosition": null,
Expand Down Expand Up @@ -827,6 +828,7 @@ const DxTabPanelOptions = createConfigurationComponent({
selectedIndex: Number,
selectedItem: {},
showNavButtons: Boolean,
stylingMode: String,
swipeEnabled: Boolean,
tabIndex: Number,
tabsPosition: String,
Expand Down
3 changes: 3 additions & 0 deletions packages/devextreme-vue/src/tab-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type AccessibleOptions = Pick<Properties,
"selectedIndex" |
"selectedItem" |
"showNavButtons" |
"stylingMode" |
"swipeEnabled" |
"tabIndex" |
"tabsPosition" |
Expand Down Expand Up @@ -90,6 +91,7 @@ const DxTabPanel = createComponent({
selectedIndex: Number,
selectedItem: {},
showNavButtons: Boolean,
stylingMode: String,
swipeEnabled: Boolean,
tabIndex: Number,
tabsPosition: String,
Expand Down Expand Up @@ -136,6 +138,7 @@ const DxTabPanel = createComponent({
"update:selectedIndex": null,
"update:selectedItem": null,
"update:showNavButtons": null,
"update:stylingMode": null,
"update:swipeEnabled": null,
"update:tabIndex": null,
"update:tabsPosition": null,
Expand Down
8 changes: 8 additions & 0 deletions packages/devextreme/js/ui/tab_panel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
Position,
TabsIconPosition,
TabsStyle,
} from '../common';

import CollectionWidget, {
Expand All @@ -33,6 +34,7 @@ import {
export {
Position,
TabsIconPosition,
TabsStyle,
};

type ItemLike = string | Item | any;
Expand Down Expand Up @@ -247,6 +249,12 @@ export interface dxTabPanelOptions<
* @public
*/
showNavButtons?: boolean;
/**
* @docid
* @default 'primary'
* @public
*/
stylingMode?: TabsStyle;
/**
* @docid
* @default false &for(non-touch_devices)
Expand Down
15 changes: 15 additions & 0 deletions packages/devextreme/js/ui/tab_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const ICON_POSITION = {
start: 'start',
};

const STYLING_MODE = {
primary: 'primary',
secondary: 'secondary',
};

const TabPanel = MultiView.inherit({

_getDefaultOptions: function() {
Expand All @@ -67,6 +72,8 @@ const TabPanel = MultiView.inherit({

iconPosition: ICON_POSITION.start,

stylingMode: STYLING_MODE.primary,

onTitleClick: null,

onTitleHold: null,
Expand Down Expand Up @@ -247,6 +254,7 @@ const TabPanel = MultiView.inherit({
}).bind(this),
orientation: this._getTabsOrientation(),
iconPosition: this.option('iconPosition'),
stylingMode: this.option('stylingMode'),
_itemAttributes: {
class: TABPANEL_TABS_ITEM_CLASS,
},
Expand Down Expand Up @@ -303,6 +311,10 @@ const TabPanel = MultiView.inherit({
this._tabs.option({ iconPosition });
},

_updateTabsStylingMode(stylingMode) {
this._tabs.option({ stylingMode });
},

_toggleWrapperFocusedClass(isFocused) {
this._toggleFocusClass(isFocused, this._$wrapper);
},
Expand Down Expand Up @@ -451,6 +463,9 @@ const TabPanel = MultiView.inherit({
case 'iconPosition':
this._updateTabsIconPosition(value);
break;
case 'stylingMode':
this._updateTabsStylingMode(value);
break;
default:
this.callBase(args);
}
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/ui/tab_panel_types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export {
Position,
TabsIconPosition,
TabsStyle,
ContentReadyEvent,
DisposingEvent,
InitializedEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ QUnit.module('options', {
assert.strictEqual(this.tabWidgetInstance.option('iconPosition'), 'top', 'option <iconPosition> of nested tabs widget successfully changed');
});

QUnit.test('stylingMode option should be passed to tabs correctly', function(assert) {
assert.strictEqual(this.tabWidgetInstance.option('stylingMode'), 'primary', 'option <stylingMode> successfully passed to nested tabs widget');

this.tabPanelInstance.option('stylingMode', 'secondary');

assert.strictEqual(this.tabWidgetInstance.option('stylingMode'), 'secondary', 'option <stylingMode> of nested tabs widget successfully changed');
});

QUnit.test('dataSource option test', function(assert) {
assert.expect(2);

Expand Down
4 changes: 4 additions & 0 deletions packages/devextreme/ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25574,6 +25574,10 @@ declare module DevExpress.ui {
* [descr:dxTabPanelOptions.showNavButtons]
*/
showNavButtons?: boolean;
/**
* [descr:dxTabPanelOptions.stylingMode]
*/
stylingMode?: DevExpress.common.TabsStyle;
/**
* [descr:dxTabPanelOptions.swipeEnabled]
*/
Expand Down

0 comments on commit 2cec6f8

Please sign in to comment.