@zohodesk/components 1.0.0-temp-255 → 1.0.0-temp-256
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.
- package/README.md +20 -3
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +4 -4
- package/assets/Appearance/dark/themes/blue/blue_componentsCTA_DarkModifyCategory.module.css +14 -0
- package/assets/Appearance/dark/themes/green/green_componentsCTA_DarkModifyCategory.module.css +14 -0
- package/assets/Appearance/dark/themes/orange/orange_componentsCTA_DarkModifyCategory.module.css +14 -0
- package/assets/Appearance/dark/themes/red/red_componentsCTA_DarkModifyCategory.module.css +14 -0
- package/assets/Appearance/dark/themes/yellow/yellow_componentsCTA_DarkModifyCategory.module.css +14 -0
- package/assets/Appearance/light/mode/Component_LightMode.module.css +6 -6
- package/assets/Appearance/light/themes/blue/blue_componentsCTA_LightModifyCategory.module.css +14 -0
- package/assets/Appearance/light/themes/green/green_componentsCTA_LightModifyCategory.module.css +14 -0
- package/assets/Appearance/light/themes/orange/orange_componentsCTA_LightModifyCategory.module.css +14 -0
- package/assets/Appearance/light/themes/red/red_componentsCTA_LightModifyCategory.module.css +14 -0
- package/assets/Appearance/light/themes/yellow/yellow_componentsCTA_LightModifyCategory.module.css +14 -0
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +3 -3
- package/assets/Appearance/pureDark/themes/blue/blue_componentsCTA_PureDarkModifyCategory.module.css +14 -0
- package/assets/Appearance/pureDark/themes/green/green_componentsCTA_PureDarkModifyCategory.module.css +14 -0
- package/assets/Appearance/pureDark/themes/orange/orange_componentsCTA_PureDarkModifyCategory.module.css +14 -0
- package/assets/Appearance/pureDark/themes/red/red_componentsCTA_PureDarkModifyCategory.module.css +14 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_componentsCTA_PureDarkModifyCategory.module.css +14 -0
- package/cbt.config.js +12 -3
- package/es/AppContainer/AppContainer.js +2 -0
- package/es/DateTime/DateWidget.js +32 -6
- package/es/Provider/LibraryContext.js +5 -1
- package/es/Select/Select.js +3 -1
- package/es/Tab/Tab.js +62 -11
- package/es/Tab/Tab.module.css +25 -0
- package/es/Tab/Tabs.js +37 -6
- package/es/Tab/Tabs.module.css +48 -3
- package/es/Tab/__tests__/Tab.spec.js +112 -0
- package/es/Tab/__tests__/__snapshots__/Tab.spec.js.snap +316 -0
- package/es/Tab/props/defaultProps.js +3 -2
- package/es/Tab/props/propTypes.js +12 -3
- package/es/Tab/utils/tabConfigs.js +5 -0
- package/es/utils/datetime/common.js +10 -3
- package/lib/AppContainer/AppContainer.js +4 -0
- package/lib/DateTime/DateWidget.js +33 -6
- package/lib/Provider/LibraryContext.js +5 -1
- package/lib/Select/Select.js +3 -1
- package/lib/Tab/Tab.js +62 -9
- package/lib/Tab/Tab.module.css +25 -0
- package/lib/Tab/Tabs.js +34 -3
- package/lib/Tab/Tabs.module.css +48 -3
- package/lib/Tab/__tests__/Tab.spec.js +115 -0
- package/lib/Tab/__tests__/__snapshots__/Tab.spec.js.snap +316 -0
- package/lib/Tab/props/defaultProps.js +3 -2
- package/lib/Tab/props/propTypes.js +14 -3
- package/lib/Tab/utils/tabConfigs.js +7 -1
- package/lib/utils/datetime/common.js +10 -2
- package/package.json +11 -10
package/es/Tab/Tab.js
CHANGED
|
@@ -2,14 +2,16 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
|
|
3
3
|
/* eslint-disable react/forbid-component-props */
|
|
4
4
|
|
|
5
|
-
/* eslint css-modules/no-unused-class: [2, { markAsUsed: ['text', 'tabAlpha', 'alphaActive', 'gammaActive', 'betaActive', 'deltaActive', 'tabGamma', 'tabBeta', 'tabDelta',', 'specialActive', 'tabSpecial', 'alphaActive_border', 'gammaActive_border', 'betaActive_border', 'deltaActive_border'] }] */
|
|
5
|
+
/* eslint css-modules/no-unused-class: [2, { markAsUsed: ['text', 'tabAlpha', 'alphaActive', 'gammaActive', 'betaActive', 'deltaActive', 'tabGamma', 'tabBeta', 'tabDelta',', 'specialActive', 'tabSpecial', 'alphaActive_border', 'gammaActive_border', 'betaActive_border', 'deltaActive_border', 'tabDefault', 'defaultHover', 'defaultActive', 'defaultActive_border'] }] */
|
|
6
6
|
import React, { useMemo, useCallback } from 'react';
|
|
7
7
|
import { Tab_defaultProps } from "./props/defaultProps";
|
|
8
8
|
import { Tab_propTypes } from "./props/propTypes";
|
|
9
9
|
import { Box, Container } from "../Layout";
|
|
10
10
|
import { cs } from "../utils/Common";
|
|
11
|
-
import { TAB_DIRECTION_MAPPING } from "./utils/tabConfigs";
|
|
11
|
+
import { TAB_DIRECTION_MAPPING, VARIANT } from "./utils/tabConfigs";
|
|
12
12
|
import styles from "./Tab.module.css";
|
|
13
|
+
import { renderNode, isRenderable } from '@zohodesk/utils';
|
|
14
|
+
import { Icon } from '@zohodesk/icons';
|
|
13
15
|
const tabTypes = {
|
|
14
16
|
alpha: {
|
|
15
17
|
active: 'alphaActive',
|
|
@@ -22,6 +24,10 @@ const tabTypes = {
|
|
|
22
24
|
delta: {
|
|
23
25
|
active: 'deltaActive',
|
|
24
26
|
tab: 'tabDelta'
|
|
27
|
+
},
|
|
28
|
+
default: {
|
|
29
|
+
active: 'defaultActive',
|
|
30
|
+
tab: 'tabDefault'
|
|
25
31
|
}
|
|
26
32
|
};
|
|
27
33
|
export default function Tab({
|
|
@@ -51,7 +57,14 @@ export default function Tab({
|
|
|
51
57
|
isVirtual,
|
|
52
58
|
contentAlign,
|
|
53
59
|
contentAlignBox,
|
|
54
|
-
customProps
|
|
60
|
+
customProps,
|
|
61
|
+
variant,
|
|
62
|
+
iconPlacement,
|
|
63
|
+
iconName,
|
|
64
|
+
iconSize,
|
|
65
|
+
renderIcon,
|
|
66
|
+
renderBefore,
|
|
67
|
+
renderAfter
|
|
55
68
|
}) {
|
|
56
69
|
let clickListener = useCallback(event => {
|
|
57
70
|
if (isLink && event && (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)) {
|
|
@@ -70,8 +83,50 @@ export default function Tab({
|
|
|
70
83
|
let getTab = useCallback(ref => getTabRef && getTabRef(id, ref, isVirtual), [id, isVirtual]);
|
|
71
84
|
let activeWithAppearance = cs([styles[styleContent.active], needBorder && !isAnimate && styles[`${styleContent.active}_border`]]);
|
|
72
85
|
let activeClasses = cs([needAppearance && activeWithAppearance, activeClass]);
|
|
73
|
-
let inActiveClasses = needAppearance && cs([styles[styleContent.tab], tabTypes[type] && styles[`${
|
|
74
|
-
let tabClass = cs([styles.tab, TAB_DIRECTION_MAPPING[align] === 'column' ? styles.vertical : styles.horizontal, isDisabled && styles.disabled, needBorder && !isAnimate && needAppearance && styles.border, isActive ? activeClasses : inActiveClasses, className]);
|
|
86
|
+
let inActiveClasses = needAppearance && cs([styles[styleContent.tab], tabTypes[type] && styles[`${type}Hover`]]);
|
|
87
|
+
let tabClass = cs([styles.tab, TAB_DIRECTION_MAPPING[align] === 'column' ? styles.vertical : styles.horizontal, isDisabled && styles.disabled, needBorder && !isAnimate && needAppearance && styles.border, isActive ? activeClasses : inActiveClasses, variant === VARIANT.ICON && styles.tabVariantIcon, variant === VARIANT.ICON_WITH_TEXT && styles.tabVariantIconWithText, className]);
|
|
88
|
+
|
|
89
|
+
const _renderIconNode = () => {
|
|
90
|
+
if (isRenderable(renderIcon)) {
|
|
91
|
+
return renderNode(renderIcon);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!iconName) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return /*#__PURE__*/React.createElement(Icon, {
|
|
99
|
+
name: iconName,
|
|
100
|
+
size: iconSize
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const _renderBeforeNode = () => {
|
|
105
|
+
if (!isRenderable(renderBefore)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return renderNode(renderBefore);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const _renderAfterNode = () => {
|
|
113
|
+
if (!isRenderable(renderAfter)) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return renderNode(renderAfter);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const _renderLabel = () => {
|
|
121
|
+
const showIcon = variant !== VARIANT.TEXT && (isRenderable(renderIcon) || iconName);
|
|
122
|
+
const showText = variant !== VARIANT.ICON && text !== undefined && text !== null;
|
|
123
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showIcon ? _renderIconNode() : null, showText ? /*#__PURE__*/React.createElement(Box, {
|
|
124
|
+
flexible: true,
|
|
125
|
+
adjust: true,
|
|
126
|
+
className: styles.tabText
|
|
127
|
+
}, text) : null);
|
|
128
|
+
};
|
|
129
|
+
|
|
75
130
|
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
76
131
|
tourId: tourId,
|
|
77
132
|
tagName: isLink ? 'a' : 'div',
|
|
@@ -95,13 +150,9 @@ export default function Tab({
|
|
|
95
150
|
alignBox: contentAlignBox,
|
|
96
151
|
align: contentAlign,
|
|
97
152
|
className: styles.textContainer
|
|
98
|
-
},
|
|
99
|
-
flexible: true,
|
|
100
|
-
adjust: true,
|
|
101
|
-
className: styles.tabText
|
|
102
|
-
}, text), children ? /*#__PURE__*/React.createElement(Box, {
|
|
153
|
+
}, _renderBeforeNode(), _renderLabel(), children ? /*#__PURE__*/React.createElement(Box, {
|
|
103
154
|
shrink: true
|
|
104
|
-
}, children) : null));
|
|
155
|
+
}, children) : null, _renderAfterNode()));
|
|
105
156
|
}
|
|
106
157
|
Tab.defaultProps = Tab_defaultProps;
|
|
107
158
|
Tab.propTypes = Tab_propTypes; // if (__DOCS__) {
|
package/es/Tab/Tab.module.css
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
width: 100% ;
|
|
12
12
|
max-width: 100% ;
|
|
13
13
|
}
|
|
14
|
+
.textContainer {
|
|
15
|
+
gap: var(--zd_size4) ;
|
|
16
|
+
}
|
|
14
17
|
.textContainer,
|
|
15
18
|
.tabText {
|
|
16
19
|
max-width: inherit ;
|
|
@@ -91,3 +94,25 @@
|
|
|
91
94
|
composes: delta;
|
|
92
95
|
color: var(--zdt_tab_alpha_active_text);
|
|
93
96
|
}
|
|
97
|
+
|
|
98
|
+
.tabDefault {
|
|
99
|
+
transition: all var(--zd_transition2);
|
|
100
|
+
padding-inline: 0 ;
|
|
101
|
+
padding-block: 0 ;
|
|
102
|
+
font-size: var(--zd_font_size11) ;
|
|
103
|
+
line-height: 3;
|
|
104
|
+
margin-inline-end: var(--zd_size34) ;
|
|
105
|
+
color: var(--zd-text-secondary);
|
|
106
|
+
}
|
|
107
|
+
.defaultHover:hover { color: var(--zd-text-primary); }
|
|
108
|
+
.defaultActive {
|
|
109
|
+
transition: all var(--zd_transition2);
|
|
110
|
+
padding-inline: 0 ;
|
|
111
|
+
padding-block: 0 ;
|
|
112
|
+
font-size: var(--zd_font_size11) ;
|
|
113
|
+
line-height: 3;
|
|
114
|
+
margin-inline-end: var(--zd_size34) ;
|
|
115
|
+
color: var(--zd-text-primary);
|
|
116
|
+
border-bottom: 1px solid var(--zdt_tab_alpha_active_border);
|
|
117
|
+
}
|
|
118
|
+
.defaultActive_border { border-color: var(--zdt_tab_alpha_active_border); }
|
package/es/Tab/Tabs.js
CHANGED
|
@@ -4,8 +4,9 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
4
4
|
|
|
5
5
|
/* eslint css-modules/no-unused-class: [2, {
|
|
6
6
|
markAsUsed: [
|
|
7
|
-
'hidden','alpha','gamma','beta','delta','special','text','maxWidth','widgetList','menuContainer','border','tabText','block','tabAlpha','alphaActive','gammaActive','betaActive','deltaActive','tabGamma','tabBeta','tabDelta','specialActive','tabSpecial',
|
|
8
|
-
'alpha_padding','alpha_border','gamma_padding','gamma_border','beta_padding','beta_border','delta_padding','delta_border','textContainer','disabled','alphaActive_border','gammaActive_border','betaActive_border','deltaActive_border'
|
|
7
|
+
'hidden','alpha','gamma','beta','delta','default','special','text','maxWidth','widgetList','menuContainer','border','tabText','block','tabAlpha','alphaActive','gammaActive','betaActive','deltaActive','tabGamma','tabBeta','tabDelta','specialActive','tabSpecial',
|
|
8
|
+
'alpha_padding','alpha_border','gamma_padding','gamma_border','beta_padding','beta_border','delta_padding','delta_border','default_padding','default_border','textContainer','disabled','alphaActive_border','gammaActive_border','betaActive_border','deltaActive_border',
|
|
9
|
+
'defaultMoreButton','defaultMoreButtonActive','defaultMenuListItem'
|
|
9
10
|
]
|
|
10
11
|
}]
|
|
11
12
|
*/
|
|
@@ -18,13 +19,14 @@ import { remConvert, getTotalDimension, cs, bind, throttle, cancelBubblingEffect
|
|
|
18
19
|
import { Box, Container } from "../Layout";
|
|
19
20
|
import ResizeObserver from "../Responsive/ResizeObserver";
|
|
20
21
|
import ListItem from "../ListItem/ListItem";
|
|
22
|
+
import ListItemWithIcon from "../ListItem/ListItemWithIcon";
|
|
21
23
|
import { Icon } from '@zohodesk/icons';
|
|
22
24
|
import tabsStyle from "./Tabs.module.css";
|
|
23
25
|
import Popup from "../Popup/Popup";
|
|
24
26
|
import TextBoxIcon from "../TextBoxIcon/TextBoxIcon";
|
|
25
27
|
import ResponsiveDropBox from "../ResponsiveDropBox/ResponsiveDropBox";
|
|
26
28
|
import { ResponsiveReceiver } from "../Responsive/CustomResponsive";
|
|
27
|
-
import { TAB_DIRECTION_MAPPING, TAB_POPUP_POSITION_MAPPING } from "./utils/tabConfigs";
|
|
29
|
+
import { TAB_DIRECTION_MAPPING, TAB_POPUP_POSITION_MAPPING, VARIANT } from "./utils/tabConfigs";
|
|
28
30
|
import btnstyle from "../semantic/Button/semanticButton.module.css";
|
|
29
31
|
|
|
30
32
|
class Tabs extends React.Component {
|
|
@@ -530,6 +532,10 @@ class Tabs extends React.Component {
|
|
|
530
532
|
moreTabs
|
|
531
533
|
});
|
|
532
534
|
const hasSearch = moreTabs.length > 4;
|
|
535
|
+
const isDefaultType = type === 'default';
|
|
536
|
+
const defaultMoreClass = isDefaultType ? tabsStyle.defaultMoreButton : '';
|
|
537
|
+
const defaultMoreActiveClass = isDefaultType ? tabsStyle.defaultMoreButtonActive : '';
|
|
538
|
+
const effectiveMenuItemClass = isDefaultType ? `${tabsStyle.defaultMenuListItem}${menuItemClass ? ` ${menuItemClass}` : ''}` : menuItemClass;
|
|
533
539
|
return /*#__PURE__*/React.createElement(React.Fragment, null, React.Children.map(mainTabs, child => {
|
|
534
540
|
if (!child) {
|
|
535
541
|
return null;
|
|
@@ -563,7 +569,7 @@ class Tabs extends React.Component {
|
|
|
563
569
|
className: `${tabsStyle.menu} `,
|
|
564
570
|
dataSelectorId: `${dataSelectorId}_moreIcon`
|
|
565
571
|
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
566
|
-
className: `${btnstyle.buttonReset} ${moreButtonClass} ${isPopupOpen ? moreButtonActiveClass : ''}`,
|
|
572
|
+
className: `${btnstyle.buttonReset} ${defaultMoreClass} ${moreButtonClass} ${isPopupOpen ? `${defaultMoreActiveClass} ${moreButtonActiveClass}` : ''}`,
|
|
567
573
|
align: "both",
|
|
568
574
|
onClick: this.togglePopup,
|
|
569
575
|
dataId: "moreTabs",
|
|
@@ -632,9 +638,34 @@ class Tabs extends React.Component {
|
|
|
632
638
|
isLink,
|
|
633
639
|
href,
|
|
634
640
|
children,
|
|
635
|
-
dataId
|
|
641
|
+
dataId,
|
|
642
|
+
variant,
|
|
643
|
+
iconName,
|
|
644
|
+
iconSize
|
|
636
645
|
} = data;
|
|
637
646
|
const value = text ? text : showTitleInMoreOptions ? title : null;
|
|
647
|
+
const showIconInDropdown = variant !== VARIANT.TEXT && iconName;
|
|
648
|
+
|
|
649
|
+
if (showIconInDropdown) {
|
|
650
|
+
return /*#__PURE__*/React.createElement(ListItemWithIcon, _extends({
|
|
651
|
+
key: id,
|
|
652
|
+
value: value,
|
|
653
|
+
onClick: this.moreTabSelect,
|
|
654
|
+
id: id,
|
|
655
|
+
title: title || text,
|
|
656
|
+
isLink: isLink,
|
|
657
|
+
href: href,
|
|
658
|
+
autoHover: true,
|
|
659
|
+
iconName: iconName,
|
|
660
|
+
iconSize: iconSize,
|
|
661
|
+
customClass: {
|
|
662
|
+
customListItem: effectiveMenuItemClass
|
|
663
|
+
},
|
|
664
|
+
target: "self",
|
|
665
|
+
dataId: `${dataId}_Tab`
|
|
666
|
+
}, ListItemProps));
|
|
667
|
+
}
|
|
668
|
+
|
|
638
669
|
return /*#__PURE__*/React.createElement(ListItem, _extends({
|
|
639
670
|
key: id,
|
|
640
671
|
value: value,
|
|
@@ -645,7 +676,7 @@ class Tabs extends React.Component {
|
|
|
645
676
|
href: href,
|
|
646
677
|
autoHover: true,
|
|
647
678
|
customClass: {
|
|
648
|
-
customListItem:
|
|
679
|
+
customListItem: effectiveMenuItemClass
|
|
649
680
|
},
|
|
650
681
|
target: "self",
|
|
651
682
|
dataId: `${dataId}_Tab`
|
package/es/Tab/Tabs.module.css
CHANGED
|
@@ -82,6 +82,51 @@
|
|
|
82
82
|
border-bottom: 1px dotted var(--zdt_tabs_alpha_border);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
.default {
|
|
86
|
+
height: var(--zd_size35) ;
|
|
87
|
+
transition: padding var(--zd_transition3);
|
|
88
|
+
z-index: 2;
|
|
89
|
+
background-color: var(--zd-bg-secondary);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.default_padding {
|
|
93
|
+
padding-inline-start: var(--zd_size10) ;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.default_border {
|
|
97
|
+
border-bottom: 1px solid var(--zd-border-primary);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.defaultMoreButton {
|
|
101
|
+
max-height: var(--zd_size28) ;
|
|
102
|
+
color: var(--zd-text-secondary);
|
|
103
|
+
padding: var(--zd_size6) ;
|
|
104
|
+
border: 1px solid var(--zd-border-transparent);
|
|
105
|
+
border-radius: 4px;
|
|
106
|
+
margin-top: var(--zd_size3) ;
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.defaultMoreButton:hover {
|
|
111
|
+
border-color: var(--zdt_rippleeffect_navy_border);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.defaultMoreButtonActive {
|
|
115
|
+
border-color: var(--zdt_cta_secondary_light_border);
|
|
116
|
+
background: var(--zd-bg-brandLight);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.defaultMoreButtonActive:hover {
|
|
120
|
+
border-color: var(--zdt_cta_secondary_light_border);
|
|
121
|
+
background: var(--zd-bg-brandLight);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.defaultMenuListItem {
|
|
125
|
+
font-size: var(--zd_font_size11) ;
|
|
126
|
+
text-transform: uppercase;
|
|
127
|
+
letter-spacing: 0.4px;
|
|
128
|
+
}
|
|
129
|
+
|
|
85
130
|
.delta .highlight {
|
|
86
131
|
border-color: var(--zdt_tabs_delta_border);
|
|
87
132
|
}
|
|
@@ -126,7 +171,7 @@
|
|
|
126
171
|
|
|
127
172
|
.search {
|
|
128
173
|
padding-block: var(--zd_size6) 0 ;
|
|
129
|
-
padding-inline:var(--zd_size20) ;
|
|
174
|
+
padding-inline: var(--zd_size20) ;
|
|
130
175
|
}
|
|
131
176
|
|
|
132
177
|
.emptyStateContainer {
|
|
@@ -153,5 +198,5 @@
|
|
|
153
198
|
|
|
154
199
|
.listWrapper {
|
|
155
200
|
padding-block: var(--zd_size10) ;
|
|
156
|
-
padding-inline:0 ;
|
|
157
|
-
}
|
|
201
|
+
padding-inline: 0 ;
|
|
202
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import Tab from "../Tab";
|
|
4
|
+
|
|
5
|
+
const noop = () => {};
|
|
6
|
+
|
|
4
7
|
describe('Tab', () => {
|
|
5
8
|
test('rendering the defult props', () => {
|
|
6
9
|
const {
|
|
@@ -8,4 +11,113 @@ describe('Tab', () => {
|
|
|
8
11
|
} = render( /*#__PURE__*/React.createElement(Tab, null));
|
|
9
12
|
expect(asFragment()).toMatchSnapshot();
|
|
10
13
|
});
|
|
14
|
+
describe('variant-based label rendering', () => {
|
|
15
|
+
test('variant="text" renders text only', () => {
|
|
16
|
+
const {
|
|
17
|
+
asFragment
|
|
18
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
19
|
+
id: "t1",
|
|
20
|
+
text: "Home",
|
|
21
|
+
variant: "text",
|
|
22
|
+
onSelect: noop
|
|
23
|
+
}));
|
|
24
|
+
expect(asFragment()).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
test('variant="icon" renders icon and suppresses text label', () => {
|
|
27
|
+
const {
|
|
28
|
+
asFragment
|
|
29
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
30
|
+
id: "t2",
|
|
31
|
+
text: "Home",
|
|
32
|
+
variant: "icon",
|
|
33
|
+
iconName: "ZD-TB-menu",
|
|
34
|
+
onSelect: noop
|
|
35
|
+
}));
|
|
36
|
+
expect(asFragment()).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
test('variant="iconWithText" renders icon followed by text', () => {
|
|
39
|
+
const {
|
|
40
|
+
asFragment
|
|
41
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
42
|
+
id: "t3",
|
|
43
|
+
text: "Home",
|
|
44
|
+
variant: "iconWithText",
|
|
45
|
+
iconName: "ZD-TB-menu",
|
|
46
|
+
onSelect: noop
|
|
47
|
+
}));
|
|
48
|
+
expect(asFragment()).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
test('renderIcon overrides iconName', () => {
|
|
51
|
+
const {
|
|
52
|
+
asFragment
|
|
53
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
54
|
+
id: "t4",
|
|
55
|
+
text: "Home",
|
|
56
|
+
variant: "iconWithText",
|
|
57
|
+
renderIcon: /*#__PURE__*/React.createElement("span", null, "\u2605"),
|
|
58
|
+
iconName: "ZD-TB-menu",
|
|
59
|
+
onSelect: noop
|
|
60
|
+
}));
|
|
61
|
+
expect(asFragment()).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
test('renderIcon as function receives no args and renders custom node', () => {
|
|
64
|
+
const {
|
|
65
|
+
asFragment
|
|
66
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
67
|
+
id: "t5",
|
|
68
|
+
text: "Home",
|
|
69
|
+
variant: "icon",
|
|
70
|
+
renderIcon: () => /*#__PURE__*/React.createElement("span", null, "\u2605"),
|
|
71
|
+
onSelect: noop
|
|
72
|
+
}));
|
|
73
|
+
expect(asFragment()).toMatchSnapshot();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('renderBefore / renderAfter slots', () => {
|
|
77
|
+
test('renderBefore renders a node to the left of the label', () => {
|
|
78
|
+
const {
|
|
79
|
+
asFragment
|
|
80
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
81
|
+
id: "t6",
|
|
82
|
+
text: "Home",
|
|
83
|
+
renderBefore: /*#__PURE__*/React.createElement("span", null, "\u25C0"),
|
|
84
|
+
onSelect: noop
|
|
85
|
+
}));
|
|
86
|
+
expect(asFragment()).toMatchSnapshot();
|
|
87
|
+
});
|
|
88
|
+
test('renderAfter renders a node to the right of the label', () => {
|
|
89
|
+
const {
|
|
90
|
+
asFragment
|
|
91
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
92
|
+
id: "t7",
|
|
93
|
+
text: "Home",
|
|
94
|
+
renderAfter: /*#__PURE__*/React.createElement("span", null, "3"),
|
|
95
|
+
onSelect: noop
|
|
96
|
+
}));
|
|
97
|
+
expect(asFragment()).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
test('renderBefore and renderAfter both render around the label', () => {
|
|
100
|
+
const {
|
|
101
|
+
asFragment
|
|
102
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
103
|
+
id: "t8",
|
|
104
|
+
text: "Home",
|
|
105
|
+
renderBefore: /*#__PURE__*/React.createElement("span", null, "\u25C0"),
|
|
106
|
+
renderAfter: /*#__PURE__*/React.createElement("span", null, "\u25B6"),
|
|
107
|
+
onSelect: noop
|
|
108
|
+
}));
|
|
109
|
+
expect(asFragment()).toMatchSnapshot();
|
|
110
|
+
});
|
|
111
|
+
test('renderBefore as function renders custom node', () => {
|
|
112
|
+
const {
|
|
113
|
+
asFragment
|
|
114
|
+
} = render( /*#__PURE__*/React.createElement(Tab, {
|
|
115
|
+
id: "t9",
|
|
116
|
+
text: "Home",
|
|
117
|
+
renderBefore: () => /*#__PURE__*/React.createElement("span", null, "\u25C0"),
|
|
118
|
+
onSelect: noop
|
|
119
|
+
}));
|
|
120
|
+
expect(asFragment()).toMatchSnapshot();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
11
123
|
});
|