Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabPanel: Add iconPosition option #25411

Merged
merged 18 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/devextreme-angular/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export {
StoreType,
StringLengthRule,
SubmenuShowMode,
TabsIconPosition,
TextBoxPredefinedButton,
TextEditorButton,
TextEditorButtonLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ export abstract class DxoTabPanelOptions extends NestedOption {
this._setOption('hoverStateEnabled', value);
}

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

get itemHoldTimeout(): number {
return this._getOption('itemHoldTimeout');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { DxiItemComponent } from './item-dxi';
'height',
'hint',
'hoverStateEnabled',
'iconPosition',
'itemHoldTimeout',
'items',
'itemTemplate',
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 @@ -208,6 +208,19 @@ export class DxTabPanelComponent extends DxComponent implements OnDestroy, OnCha
}


/**
* [descr:dxTabPanelOptions.iconPosition]

*/
@Input()
get iconPosition(): string {
return this._getOption('iconPosition');
}
set iconPosition(value: string) {
this._setOption('iconPosition', value);
}


/**
* [descr:CollectionWidgetOptions.itemHoldTimeout]

Expand Down Expand Up @@ -614,6 +627,13 @@ export class DxTabPanelComponent extends DxComponent implements OnDestroy, OnCha
*/
@Output() hoverStateEnabledChange: EventEmitter<boolean>;

/**

* This member supports the internal infrastructure and is not intended to be used directly from your code.

*/
@Output() iconPositionChange: EventEmitter<string>;

/**

* This member supports the internal infrastructure and is not intended to be used directly from your code.
Expand Down Expand Up @@ -787,6 +807,7 @@ export class DxTabPanelComponent extends DxComponent implements OnDestroy, OnCha
{ emit: 'heightChange' },
{ emit: 'hintChange' },
{ emit: 'hoverStateEnabledChange' },
{ emit: 'iconPositionChange' },
{ emit: 'itemHoldTimeoutChange' },
{ emit: 'itemsChange' },
{ emit: 'itemTemplateChange' },
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme-react/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export {
StoreType,
StringLengthRule,
SubmenuShowMode,
TabsIconPosition,
TextBoxPredefinedButton,
TextEditorButton,
TextEditorButtonLocation,
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 @@ -681,6 +681,7 @@ type ITabPanelOptionsProps = React.PropsWithChildren<{
height?: (() => number | string) | number | string;
hint?: string;
hoverStateEnabled?: boolean;
iconPosition?: "top" | "end" | "bottom" | "start";
itemHoldTimeout?: number;
items?: Array<any | dxTabPanelItem | string>;
itemTemplate?: ((itemData: any, itemIndex: number, itemElement: any) => string | any) | template;
Expand Down
8 changes: 8 additions & 0 deletions packages/devextreme-react/src/tab-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ class TabPanel<TItem = any, TKey = any> extends BaseComponent<React.PropsWithChi
]),
hint: PropTypes.string,
hoverStateEnabled: PropTypes.bool,
iconPosition: PropTypes.oneOfType([
PropTypes.string,
PropTypes.oneOf([
"top",
"end",
"bottom",
"start"])
]),
itemHoldTimeout: PropTypes.number,
items: PropTypes.array,
loop: PropTypes.bool,
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme-vue/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export {
StoreType,
StringLengthRule,
SubmenuShowMode,
TabsIconPosition,
TextBoxPredefinedButton,
TextEditorButton,
TextEditorButtonLocation,
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 @@ -756,6 +756,7 @@ const DxTabPanelOptions = createConfigurationComponent({
"update:height": null,
"update:hint": null,
"update:hoverStateEnabled": null,
"update:iconPosition": null,
"update:itemHoldTimeout": null,
"update:items": null,
"update:itemTemplate": null,
Expand Down Expand Up @@ -800,6 +801,7 @@ const DxTabPanelOptions = createConfigurationComponent({
height: [Function, Number, String],
hint: String,
hoverStateEnabled: Boolean,
iconPosition: String,
itemHoldTimeout: Number,
items: Array,
itemTemplate: {},
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 @@ -15,6 +15,7 @@ type AccessibleOptions = Pick<Properties,
"height" |
"hint" |
"hoverStateEnabled" |
"iconPosition" |
"itemHoldTimeout" |
"items" |
"itemTemplate" |
Expand Down Expand Up @@ -63,6 +64,7 @@ const DxTabPanel = createComponent({
height: [Function, Number, String],
hint: String,
hoverStateEnabled: Boolean,
iconPosition: String,
itemHoldTimeout: Number,
items: Array,
itemTemplate: {},
Expand Down Expand Up @@ -108,6 +110,7 @@ const DxTabPanel = createComponent({
"update:height": null,
"update:hint": null,
"update:hoverStateEnabled": null,
"update:iconPosition": null,
"update:itemHoldTimeout": null,
"update:items": null,
"update:itemTemplate": null,
Expand Down
6 changes: 6 additions & 0 deletions packages/devextreme/js/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,12 @@ export type StringLengthRule = {
*/
export type SubmenuShowMode = 'onClick' | 'onHover';

/**
* @public
* @namespace DevExpress.common
*/
export type TabsIconPosition = 'top' | 'end' | 'bottom' | 'start';

/**
* @public
* @namespace DevExpress.common
Expand Down
12 changes: 12 additions & 0 deletions packages/devextreme/js/ui/tab_panel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {

import {
Position,
TabsIconPosition,
IlyaKhD marked this conversation as resolved.
Show resolved Hide resolved
} from '../common';

import CollectionWidget, {
Expand All @@ -29,6 +30,11 @@ import {
dxMultiViewBaseOptions,
} from './multi_view';

export {
Position,
TabsIconPosition,
};

type ItemLike = string | Item | any;

/**
Expand Down Expand Up @@ -179,6 +185,12 @@ export interface dxTabPanelOptions<
* @public
*/
itemTitleTemplate?: template | ((itemData: TItem, itemIndex: number, itemElement: DxElement) => string | UserDefinedElement);
/**
* @docid
* @default 'start'
* @public
*/
iconPosition?: TabsIconPosition;
/**
* @docid
* @type Array<string | dxTabPanelItem | any>
Expand Down
17 changes: 17 additions & 0 deletions packages/devextreme/js/ui/tab_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ const TABS_ORIENTATION = {
vertical: 'vertical',
};

const ICON_POSITION = {
top: 'top',
end: 'end',
bottom: 'bottom',
start: 'start',
};

const TabPanel = MultiView.inherit({

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

tabsPosition: TABS_POSITION.top,

iconPosition: ICON_POSITION.start,

onTitleClick: null,

onTitleHold: null,
Expand Down Expand Up @@ -237,6 +246,7 @@ const TabPanel = MultiView.inherit({
}
}).bind(this),
orientation: this._getTabsOrientation(),
iconPosition: this.option('iconPosition'),
_itemAttributes: {
class: TABPANEL_TABS_ITEM_CLASS,
},
Expand Down Expand Up @@ -289,6 +299,10 @@ const TabPanel = MultiView.inherit({
this._tabs.option('orientation', orientation);
},

_updateTabsIconPosition(iconPosition) {
this._tabs.option({ iconPosition });
},

_toggleWrapperFocusedClass(isFocused) {
this._toggleFocusClass(isFocused, this._$wrapper);
},
Expand Down Expand Up @@ -434,6 +448,9 @@ const TabPanel = MultiView.inherit({
this._toggleTabPanelTabsPositionClass();
this._updateTabsOrientation();
break;
case 'iconPosition':
this._updateTabsIconPosition(value);
break;
default:
this.callBase(args);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/devextreme/js/ui/tab_panel_types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export {
Position,
TabsIconPosition,
ContentReadyEvent,
DisposingEvent,
InitializedEvent,
Expand Down
10 changes: 3 additions & 7 deletions packages/devextreme/js/ui/tabs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ import CollectionWidget, {
import {
Orientation,
SingleOrMultiple,
TabsIconPosition,
} from '../common';

export type ItemLike = string | Item | any;

export {
SingleOrMultiple,
Orientation,
TabsIconPosition,
};

/**
* @public
* @namespace DevExpress.ui.dxTabs
*/
export type IconPosition = 'top' | 'end' | 'bottom' | 'start';

/**
* @docid _ui_tabs_ContentReadyEvent
* @public
Expand Down Expand Up @@ -149,7 +145,7 @@ export interface dxTabsBaseOptions<
* @default 'start'
* @public
*/
iconPosition?: IconPosition;
iconPosition?: TabsIconPosition;
/**
* @docid dxTabsOptions.items
* @type Array<string | dxTabsItem | any>
Expand Down
23 changes: 12 additions & 11 deletions packages/devextreme/js/ui/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ const TABS_WRAPPER_CLASS = 'dx-tabs-wrapper';
const TABS_STRETCHED_CLASS = 'dx-tabs-stretched';
const TABS_SCROLLABLE_CLASS = 'dx-tabs-scrollable';
const TABS_NAV_BUTTONS_CLASS = 'dx-tabs-nav-buttons';
const TABS_ORIENTATION_CLASS = {
vertical: 'dx-tabs-vertical',
horizontal: 'dx-tabs-horizontal',
};
const TABS_ICON_POSITION_CLASS = {
top: 'dx-tabs-icon-position-top',
end: 'dx-tabs-icon-position-end',
bottom: 'dx-tabs-icon-position-bottom',
start: 'dx-tabs-icon-position-start',
};

const OVERFLOW_HIDDEN_CLASS = 'dx-overflow-hidden';

const TABS_ITEM_CLASS = 'dx-tab';
Expand All @@ -56,6 +45,18 @@ const STATE_DISABLED_CLASS = 'dx-state-disabled';
const FOCUSED_DISABLED_NEXT_TAB_CLASS = 'dx-focused-disabled-next-tab';
const FOCUSED_DISABLED_PREV_TAB_CLASS = 'dx-focused-disabled-prev-tab';

const TABS_ORIENTATION_CLASS = {
vertical: 'dx-tabs-vertical',
horizontal: 'dx-tabs-horizontal',
};

const TABS_ICON_POSITION_CLASS = {
top: 'dx-tabs-icon-position-top',
end: 'dx-tabs-icon-position-end',
bottom: 'dx-tabs-icon-position-bottom',
start: 'dx-tabs-icon-position-start',
};

const TABS_ITEM_DATA_KEY = 'dxTabData';

const BUTTON_NEXT_ICON = 'chevronnext';
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/ui/tabs_types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export {
SingleOrMultiple,
Orientation,
IconPosition,
TabsIconPosition,
ContentReadyEvent,
DisposingEvent,
InitializedEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ QUnit.module('options', {
assert.strictEqual(this.tabWidgetInstance.option('orientation'), TABS_ORIENTATION.vertical, 'option <orientation> of nested tabs widget successfully changed');
});

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

this.tabPanelInstance.option('iconPosition', 'top');

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

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

Expand Down
8 changes: 6 additions & 2 deletions packages/devextreme/ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,7 @@ declare module DevExpress.common {
type: 'stringLength';
};
export type SubmenuShowMode = 'onClick' | 'onHover';
export type TabsIconPosition = 'top' | 'end' | 'bottom' | 'start';
export type TextBoxPredefinedButton = 'clear';

/**
Expand Down Expand Up @@ -25534,6 +25535,10 @@ declare module DevExpress.ui {
itemIndex: number,
itemElement: DevExpress.core.DxElement
) => string | DevExpress.core.UserDefinedElement);
/**
* [descr:dxTabPanelOptions.iconPosition]
*/
iconPosition?: DevExpress.common.TabsIconPosition;
/**
* [descr:dxTabPanelOptions.items]
*/
Expand Down Expand Up @@ -25717,7 +25722,7 @@ declare module DevExpress.ui {
/**
* [descr:dxTabsOptions.iconPosition]
*/
iconPosition?: DevExpress.ui.dxTabs.IconPosition;
iconPosition?: DevExpress.common.TabsIconPosition;
/**
* [descr:dxTabsOptions.items]
*/
Expand Down Expand Up @@ -30025,7 +30030,6 @@ declare module DevExpress.ui.dxTabPanel {
export type Item = dxTabPanelItem;
}
declare module DevExpress.ui.dxTabs {
export type IconPosition = 'top' | 'end' | 'bottom' | 'start';
export type Item = dxTabsItem;
}
declare module DevExpress.ui.dxTileView {
Expand Down
1 change: 1 addition & 0 deletions packages/vue2-strategy/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export {
StoreType,
StringLengthRule,
SubmenuShowMode,
TabsIconPosition,
TextBoxPredefinedButton,
TextEditorButton,
TextEditorButtonLocation,
Expand Down
Loading
Loading