From d060ee30caf2f56d6eeff5258979fc2be5d6644c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Thu, 7 Sep 2023 17:47:59 +0400 Subject: [PATCH] Tabs: Add stylingMode option --- .../devextreme-angular/src/common/index.ts | 1 + .../devextreme-angular/src/ui/tabs/index.ts | 21 ++++++++++++ packages/devextreme-react/src/common/index.ts | 1 + packages/devextreme-react/src/tabs.ts | 6 ++++ packages/devextreme-vue/src/common/index.ts | 1 + packages/devextreme-vue/src/tabs.ts | 3 ++ packages/devextreme/js/common.d.ts | 6 ++++ packages/devextreme/js/ui/tabs.d.ts | 8 +++++ packages/devextreme/js/ui/tabs.js | 34 ++++++++++++++++--- packages/devextreme/js/ui/tabs_types.d.ts | 1 + .../tests/DevExpress.ui.widgets/tabs.tests.js | 23 +++++++++++++ packages/devextreme/ts/dx.all.d.ts | 5 +++ 12 files changed, 106 insertions(+), 4 deletions(-) diff --git a/packages/devextreme-angular/src/common/index.ts b/packages/devextreme-angular/src/common/index.ts index a839f33156e8..8bf03d75991c 100644 --- a/packages/devextreme-angular/src/common/index.ts +++ b/packages/devextreme-angular/src/common/index.ts @@ -51,6 +51,7 @@ export { StringLengthRule, SubmenuShowMode, TabsIconPosition, + TabsStyle, TextBoxPredefinedButton, TextEditorButton, TextEditorButtonLocation, diff --git a/packages/devextreme-angular/src/ui/tabs/index.ts b/packages/devextreme-angular/src/ui/tabs/index.ts index f84a3359844c..cde6c1367fba 100644 --- a/packages/devextreme-angular/src/ui/tabs/index.ts +++ b/packages/devextreme-angular/src/ui/tabs/index.ts @@ -390,6 +390,19 @@ export class DxTabsComponent extends DxComponent implements OnDestroy, OnChanges } + /** + * [descr:dxTabsOptions.stylingMode] + + */ + @Input() + get stylingMode(): string { + return this._getOption('stylingMode'); + } + set stylingMode(value: string) { + this._setOption('stylingMode', value); + } + + /** * [descr:WidgetOptions.tabIndex] @@ -675,6 +688,13 @@ export class DxTabsComponent extends DxComponent implements OnDestroy, OnChanges */ @Output() showNavButtonsChange: EventEmitter; + /** + + * This member supports the internal infrastructure and is not intended to be used directly from your code. + + */ + @Output() stylingModeChange: EventEmitter; + /** * This member supports the internal infrastructure and is not intended to be used directly from your code. @@ -754,6 +774,7 @@ export class DxTabsComponent extends DxComponent implements OnDestroy, OnChanges { emit: 'selectedItemsChange' }, { emit: 'selectionModeChange' }, { emit: 'showNavButtonsChange' }, + { emit: 'stylingModeChange' }, { emit: 'tabIndexChange' }, { emit: 'visibleChange' }, { emit: 'widthChange' } diff --git a/packages/devextreme-react/src/common/index.ts b/packages/devextreme-react/src/common/index.ts index bd42a4a4bb97..83397af54a21 100644 --- a/packages/devextreme-react/src/common/index.ts +++ b/packages/devextreme-react/src/common/index.ts @@ -51,6 +51,7 @@ export { StringLengthRule, SubmenuShowMode, TabsIconPosition, + TabsStyle, TextBoxPredefinedButton, TextEditorButton, TextEditorButtonLocation, diff --git a/packages/devextreme-react/src/tabs.ts b/packages/devextreme-react/src/tabs.ts index e336dc5ec20d..776f20395106 100644 --- a/packages/devextreme-react/src/tabs.ts +++ b/packages/devextreme-react/src/tabs.ts @@ -129,6 +129,12 @@ class Tabs extends BaseComponent { assert.ok($element.hasClass(TABS_ICON_POSITION_CLASS[iconPosition])); }); }); + + QUnit.test('the tabs element must have a correct styling mode class', function(assert) { + const $element = $('#tabs').dxTabs({ items: [1, 2, 3] }); + const instance = $element.dxTabs('instance'); + + assert.strictEqual(instance.option('stylingMode'), STYLING_MODE.primary); + assert.strictEqual($element.hasClass(TABS_STYLING_MODE_CLASS.primary), true); + assert.strictEqual($element.hasClass(TABS_STYLING_MODE_CLASS.secondary), false); + + instance.option({ stylingMode: 'secondary' }); + + assert.strictEqual(instance.option('stylingMode'), STYLING_MODE.secondary); + assert.strictEqual($element.hasClass(TABS_STYLING_MODE_CLASS.secondary), true); + assert.strictEqual($element.hasClass(TABS_STYLING_MODE_CLASS.primary), false); + }); }); QUnit.module('Tab select action', () => { diff --git a/packages/devextreme/ts/dx.all.d.ts b/packages/devextreme/ts/dx.all.d.ts index cbee855e170d..a5a7ee0e1efd 100644 --- a/packages/devextreme/ts/dx.all.d.ts +++ b/packages/devextreme/ts/dx.all.d.ts @@ -1764,6 +1764,7 @@ declare module DevExpress.common { }; export type SubmenuShowMode = 'onClick' | 'onHover'; export type TabsIconPosition = 'top' | 'end' | 'bottom' | 'start'; + export type TabsStyle = 'primary' | 'secondary'; export type TextBoxPredefinedButton = 'clear'; /** @@ -25747,6 +25748,10 @@ declare module DevExpress.ui { * [descr:dxTabsOptions.showNavButtons] */ showNavButtons?: boolean; + /** + * [descr:dxTabsOptions.stylingMode] + */ + stylingMode?: DevExpress.common.TabsStyle; } /** * @deprecated Use Item instead