@zohodesk/components 1.6.34 → 1.6.35
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/CHANGELOG.md +4 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +20 -0
- package/assets/Appearance/dark/themes/blue/blue_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/green/green_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/orange/orange_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/red/red_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/yellow/yellow_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +20 -0
- package/assets/Appearance/light/themes/blue/blue_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/green/green_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/orange/orange_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/red/red_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/yellow/yellow_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +20 -0
- package/assets/Appearance/pureDark/themes/blue/blue_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/green/green_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/orange/orange_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/red/red_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/cbt.config.js +1 -0
- package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +497 -497
- package/es/index.d.ts +39 -0
- package/es/index.js +12 -12
- package/es/v1/Tab/Tab.js +159 -0
- package/es/v1/Tab/TabList.js +153 -0
- package/es/v1/Tab/TabMoreMenu.js +245 -0
- package/es/v1/Tab/TabPanel.js +51 -0
- package/es/v1/Tab/Tabs.js +125 -0
- package/es/v1/Tab/__tests__/Tab.spec.js +1082 -0
- package/es/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
- package/es/v1/Tab/constants/index.js +112 -0
- package/es/v1/Tab/constants/presets.js +36 -0
- package/es/v1/Tab/context.js +19 -0
- package/es/v1/Tab/core/Tab.js +60 -0
- package/es/v1/Tab/core/TabList.js +51 -0
- package/es/v1/Tab/core/TabListFocusScope.js +18 -0
- package/es/v1/Tab/core/TabPanel.js +54 -0
- package/es/v1/Tab/core/Tabs.js +45 -0
- package/es/v1/Tab/core/index.js +6 -0
- package/es/v1/Tab/css/Tab_v1.module.css +335 -0
- package/es/v1/Tab/css/cssJSLogic.js +1 -0
- package/es/v1/Tab/css/tab.cva.js +205 -0
- package/es/v1/Tab/index.js +8 -0
- package/es/v1/Tab/props/defaultProps.js +55 -0
- package/es/v1/Tab/props/propTypes.js +221 -0
- package/es/v1/Tab/utils/pinSelectedTab.js +44 -0
- package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +497 -497
- package/lib/index.d.ts +39 -0
- package/lib/index.js +270 -173
- package/lib/v1/Tab/Tab.js +180 -0
- package/lib/v1/Tab/TabList.js +191 -0
- package/lib/v1/Tab/TabMoreMenu.js +284 -0
- package/lib/v1/Tab/TabPanel.js +64 -0
- package/lib/v1/Tab/Tabs.js +151 -0
- package/lib/v1/Tab/__tests__/Tab.spec.js +1174 -0
- package/lib/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
- package/lib/v1/Tab/constants/index.js +113 -0
- package/lib/v1/Tab/constants/presets.js +64 -0
- package/lib/v1/Tab/context.js +30 -0
- package/lib/v1/Tab/core/Tab.js +89 -0
- package/lib/v1/Tab/core/TabList.js +82 -0
- package/lib/v1/Tab/core/TabListFocusScope.js +28 -0
- package/lib/v1/Tab/core/TabPanel.js +85 -0
- package/lib/v1/Tab/core/Tabs.js +63 -0
- package/lib/v1/Tab/core/index.js +109 -0
- package/lib/v1/Tab/css/Tab_v1.module.css +335 -0
- package/lib/v1/Tab/css/cssJSLogic.js +25 -0
- package/lib/v1/Tab/css/tab.cva.js +192 -0
- package/lib/v1/Tab/index.js +159 -0
- package/lib/v1/Tab/props/defaultProps.js +69 -0
- package/lib/v1/Tab/props/propTypes.js +246 -0
- package/lib/v1/Tab/utils/pinSelectedTab.js +59 -0
- package/package.json +13 -11
- package/tsconfig.jest.json +5 -0
- package/tsconfig.json +9 -0
- package/ut.config.js +2 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
2
|
+
export const SIZE = Object.freeze({
|
|
3
|
+
SMALL: 'small',
|
|
4
|
+
MEDIUM: 'medium',
|
|
5
|
+
LARGE: 'large'
|
|
6
|
+
});
|
|
7
|
+
export const VARIANT = Object.freeze({
|
|
8
|
+
UNDERLINE: 'underline',
|
|
9
|
+
ELEVATED: 'elevated',
|
|
10
|
+
SPACED: 'spaced',
|
|
11
|
+
DOTTED: 'dotted'
|
|
12
|
+
});
|
|
13
|
+
export const ORIENTATION = Object.freeze({
|
|
14
|
+
HORIZONTAL: 'horizontal',
|
|
15
|
+
VERTICAL: 'vertical'
|
|
16
|
+
});
|
|
17
|
+
export const POSITION = Object.freeze({
|
|
18
|
+
TOP: 'top',
|
|
19
|
+
BOTTOM: 'bottom',
|
|
20
|
+
LEFT: 'left',
|
|
21
|
+
RIGHT: 'right'
|
|
22
|
+
});
|
|
23
|
+
/** @private Internal position→orientation lookup used to derive layout direction. */
|
|
24
|
+
|
|
25
|
+
export const POSITION_ORIENTATION = Object.freeze({
|
|
26
|
+
[POSITION.TOP]: ORIENTATION.HORIZONTAL,
|
|
27
|
+
[POSITION.BOTTOM]: ORIENTATION.HORIZONTAL,
|
|
28
|
+
[POSITION.LEFT]: ORIENTATION.VERTICAL,
|
|
29
|
+
[POSITION.RIGHT]: ORIENTATION.VERTICAL
|
|
30
|
+
});
|
|
31
|
+
export const POSITION_DIRECTION = Object.freeze({
|
|
32
|
+
[POSITION.TOP]: 'column',
|
|
33
|
+
[POSITION.BOTTOM]: 'columnReverse',
|
|
34
|
+
[POSITION.LEFT]: 'row',
|
|
35
|
+
[POSITION.RIGHT]: 'rowReverse'
|
|
36
|
+
});
|
|
37
|
+
export const ORIENTATION_DIRECTION = Object.freeze({
|
|
38
|
+
[ORIENTATION.HORIZONTAL]: 'row',
|
|
39
|
+
[ORIENTATION.VERTICAL]: 'column'
|
|
40
|
+
});
|
|
41
|
+
export const LABEL_STYLE = Object.freeze({
|
|
42
|
+
TEXT: 'text',
|
|
43
|
+
ICON: 'icon',
|
|
44
|
+
ICON_AND_TEXT: 'iconAndText'
|
|
45
|
+
});
|
|
46
|
+
export const SIZE_TEXT_SIZE = Object.freeze({
|
|
47
|
+
[SIZE.SMALL]: '12',
|
|
48
|
+
[SIZE.MEDIUM]: '13',
|
|
49
|
+
[SIZE.LARGE]: '14'
|
|
50
|
+
});
|
|
51
|
+
export const ACTIVATION = Object.freeze({
|
|
52
|
+
AUTO: 'auto',
|
|
53
|
+
MANUAL: 'manual'
|
|
54
|
+
});
|
|
55
|
+
export const ICON_PLACEMENT = Object.freeze({
|
|
56
|
+
LEFT: 'left',
|
|
57
|
+
RIGHT: 'right',
|
|
58
|
+
TOP: 'top',
|
|
59
|
+
BOTTOM: 'bottom'
|
|
60
|
+
});
|
|
61
|
+
export const ICON_PLACEMENT_DIRECTION = Object.freeze({
|
|
62
|
+
[ICON_PLACEMENT.LEFT]: 'row',
|
|
63
|
+
[ICON_PLACEMENT.RIGHT]: 'rowReverse',
|
|
64
|
+
[ICON_PLACEMENT.TOP]: 'column',
|
|
65
|
+
[ICON_PLACEMENT.BOTTOM]: 'columnReverse'
|
|
66
|
+
});
|
|
67
|
+
export const ICON_PLACEMENT_TEXT_ALIGN = Object.freeze({
|
|
68
|
+
[ICON_PLACEMENT.LEFT]: 'left',
|
|
69
|
+
[ICON_PLACEMENT.RIGHT]: 'left',
|
|
70
|
+
[ICON_PLACEMENT.TOP]: 'center',
|
|
71
|
+
[ICON_PLACEMENT.BOTTOM]: 'center'
|
|
72
|
+
});
|
|
73
|
+
export const TEXT_ONLY_TEXT_ALIGN = 'center';
|
|
74
|
+
export const ICON_PLACEMENT_JUSTIFY = Object.freeze({
|
|
75
|
+
[ICON_PLACEMENT.LEFT]: 'start',
|
|
76
|
+
[ICON_PLACEMENT.RIGHT]: 'start',
|
|
77
|
+
[ICON_PLACEMENT.TOP]: 'center',
|
|
78
|
+
[ICON_PLACEMENT.BOTTOM]: 'center'
|
|
79
|
+
});
|
|
80
|
+
export const ICON_SPACING = Object.freeze(['2', '4', '6', '8', '10', '12', '14', '16', '18', '20']);
|
|
81
|
+
export const TEXT_TRANSFORM = Object.freeze({
|
|
82
|
+
UPPER: 'upper',
|
|
83
|
+
CAPITAL: 'capital'
|
|
84
|
+
});
|
|
85
|
+
export const TEXT_TRUNCATE = Object.freeze({
|
|
86
|
+
CLAMP: 'clamp',
|
|
87
|
+
ELLIPSIS: 'ellipsis'
|
|
88
|
+
});
|
|
89
|
+
export const PANEL_SCROLL = Object.freeze({
|
|
90
|
+
VERTICAL: 'vertical',
|
|
91
|
+
HORIZONTAL: 'horizontal',
|
|
92
|
+
BOTH: 'both',
|
|
93
|
+
NONE: 'none'
|
|
94
|
+
});
|
|
95
|
+
/** Defaults for <TabList>'s `moreMenu` prop (overflow menu content/behavior). */
|
|
96
|
+
|
|
97
|
+
export const MORE_MENU_DEFAULTS = Object.freeze({
|
|
98
|
+
iconName: 'ZD-more',
|
|
99
|
+
iconSize: 16,
|
|
100
|
+
searchThreshold: 4,
|
|
101
|
+
searchBoxSize: 'small',
|
|
102
|
+
defaultPosition: 'bottomRightToLeft',
|
|
103
|
+
positionsOffset: DUMMY_OBJECT,
|
|
104
|
+
targetOffset: DUMMY_OBJECT
|
|
105
|
+
});
|
|
106
|
+
/** Defaults for <TabList>'s `customProps.popup` (raw Popup-HOC passthrough for the overflow menu). */
|
|
107
|
+
|
|
108
|
+
export const POPUP_OPTIONS_DEFAULTS = Object.freeze({
|
|
109
|
+
isAbsolutePositioningNeeded: false,
|
|
110
|
+
isOutsideScrollBlocked: false,
|
|
111
|
+
isArrow: false
|
|
112
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { POSITION, SIZE, LABEL_STYLE, ICON_PLACEMENT, TEXT_TRANSFORM, TEXT_TRUNCATE } from "./index";
|
|
2
|
+
const INFO_BAR_RAIL_BASE = {
|
|
3
|
+
position: POSITION.LEFT,
|
|
4
|
+
hasSurface: true,
|
|
5
|
+
hasListBorder: true,
|
|
6
|
+
textTransform: TEXT_TRANSFORM.CAPITAL,
|
|
7
|
+
textTruncate: TEXT_TRUNCATE.CLAMP
|
|
8
|
+
};
|
|
9
|
+
const INFO_BAR_RAIL_LABELLED = { ...INFO_BAR_RAIL_BASE,
|
|
10
|
+
size: SIZE.SMALL,
|
|
11
|
+
iconSpacing: '4'
|
|
12
|
+
};
|
|
13
|
+
export const INFO_BAR_RAIL = { ...INFO_BAR_RAIL_BASE,
|
|
14
|
+
size: SIZE.MEDIUM,
|
|
15
|
+
labelStyle: LABEL_STYLE.ICON
|
|
16
|
+
};
|
|
17
|
+
export const INFO_BAR_RAIL_TEXT = { ...INFO_BAR_RAIL_LABELLED,
|
|
18
|
+
labelStyle: LABEL_STYLE.TEXT
|
|
19
|
+
};
|
|
20
|
+
export const INFO_BAR_RAIL_ICON_LEFT = { ...INFO_BAR_RAIL_LABELLED,
|
|
21
|
+
labelStyle: LABEL_STYLE.ICON_AND_TEXT,
|
|
22
|
+
iconPlacement: ICON_PLACEMENT.LEFT
|
|
23
|
+
};
|
|
24
|
+
export const INFO_BAR_RAIL_ICON_TOP = { ...INFO_BAR_RAIL_LABELLED,
|
|
25
|
+
labelStyle: LABEL_STYLE.ICON_AND_TEXT,
|
|
26
|
+
iconPlacement: ICON_PLACEMENT.TOP
|
|
27
|
+
};
|
|
28
|
+
export const SUBTAB_STRIP = {
|
|
29
|
+
position: POSITION.TOP,
|
|
30
|
+
size: SIZE.SMALL,
|
|
31
|
+
labelStyle: LABEL_STYLE.TEXT,
|
|
32
|
+
hasListBorder: true,
|
|
33
|
+
hasListPadding: true,
|
|
34
|
+
textTransform: TEXT_TRANSFORM.UPPER,
|
|
35
|
+
textTruncate: TEXT_TRUNCATE.ELLIPSIS
|
|
36
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
const TabsStyleContext = /*#__PURE__*/createContext(null);
|
|
3
|
+
TabsStyleContext.displayName = 'TabsStyleContext';
|
|
4
|
+
export default TabsStyleContext;
|
|
5
|
+
export function useTabsStyle(componentName) {
|
|
6
|
+
const context = useContext(TabsStyleContext);
|
|
7
|
+
|
|
8
|
+
if (context === null) {
|
|
9
|
+
const error = new Error(`<${componentName} /> must be rendered inside <Tabs />.`);
|
|
10
|
+
|
|
11
|
+
if (Error.captureStackTrace) {
|
|
12
|
+
Error.captureStackTrace(error, useTabsStyle);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FlexContainer from '@zohodesk/layout/es/Flex/FlexContainer';
|
|
3
|
+
import useTab from '@zohodesk/hooks/es/tabs/useTab';
|
|
4
|
+
import mergeProps from '@zohodesk/utils/es/mergeProps';
|
|
5
|
+
import renderNode, { isRenderable } from '@zohodesk/utils/es/renderNode';
|
|
6
|
+
export default function Tab(props) {
|
|
7
|
+
const {
|
|
8
|
+
value,
|
|
9
|
+
isDisabled = false,
|
|
10
|
+
isAnchor = false,
|
|
11
|
+
tagName: tagNameFromProps,
|
|
12
|
+
a11yAttributes,
|
|
13
|
+
getRef,
|
|
14
|
+
displayMode,
|
|
15
|
+
alignItems,
|
|
16
|
+
justifyContent,
|
|
17
|
+
customId,
|
|
18
|
+
testId,
|
|
19
|
+
children,
|
|
20
|
+
...elementProps
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
tabProps,
|
|
24
|
+
isSelected
|
|
25
|
+
} = useTab({
|
|
26
|
+
value,
|
|
27
|
+
isDisabled
|
|
28
|
+
});
|
|
29
|
+
const slot = {
|
|
30
|
+
value,
|
|
31
|
+
isSelected,
|
|
32
|
+
isDisabled
|
|
33
|
+
};
|
|
34
|
+
const content = isRenderable(children) ? renderNode(children, slot) : children;
|
|
35
|
+
const tagName = tagNameFromProps || (isAnchor ? 'a' : 'button');
|
|
36
|
+
const ownedAria = {
|
|
37
|
+
id: tabProps.id,
|
|
38
|
+
role: tabProps.role,
|
|
39
|
+
type: tagName === 'button' ? tabProps.type : undefined,
|
|
40
|
+
'aria-selected': tabProps['aria-selected'],
|
|
41
|
+
'aria-controls': tabProps['aria-controls'],
|
|
42
|
+
'aria-disabled': tabProps['aria-disabled'],
|
|
43
|
+
tabIndex: tabProps.tabIndex
|
|
44
|
+
};
|
|
45
|
+
const {
|
|
46
|
+
className,
|
|
47
|
+
...mergedProps
|
|
48
|
+
} = mergeProps(tabProps, elementProps, ownedAria, a11yAttributes);
|
|
49
|
+
return /*#__PURE__*/React.createElement(FlexContainer, {
|
|
50
|
+
as: tagName,
|
|
51
|
+
display: displayMode,
|
|
52
|
+
alignItems: alignItems,
|
|
53
|
+
justifyContent: justifyContent,
|
|
54
|
+
customClass: className,
|
|
55
|
+
customId: customId,
|
|
56
|
+
testId: testId,
|
|
57
|
+
customAttributes: mergedProps,
|
|
58
|
+
ref: getRef
|
|
59
|
+
}, content);
|
|
60
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { useMemo, useRef } from 'react';
|
|
2
|
+
import FlexContainer from '@zohodesk/layout/es/Flex/FlexContainer';
|
|
3
|
+
import useTabList from '@zohodesk/hooks/es/tabs/useTabList';
|
|
4
|
+
import useSyncRefs from '@zohodesk/hooks/es/utils/useSyncRefs';
|
|
5
|
+
import TabListFocusScope from "./TabListFocusScope";
|
|
6
|
+
export default function TabList(props) {
|
|
7
|
+
const {
|
|
8
|
+
ariaLabel,
|
|
9
|
+
ariaLabelledBy,
|
|
10
|
+
getRef,
|
|
11
|
+
focusScopeProps,
|
|
12
|
+
displayMode,
|
|
13
|
+
direction,
|
|
14
|
+
alignItems,
|
|
15
|
+
scroll,
|
|
16
|
+
className,
|
|
17
|
+
customId,
|
|
18
|
+
testId,
|
|
19
|
+
children,
|
|
20
|
+
...elementProps
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
tabListProps
|
|
24
|
+
} = useTabList({
|
|
25
|
+
ariaLabel,
|
|
26
|
+
ariaLabelledBy
|
|
27
|
+
});
|
|
28
|
+
const listRef = useRef(null);
|
|
29
|
+
const setRefs = useSyncRefs(listRef, getRef); // FlexContainer spreads a11yAttributes BEFORE customAttributes, so the owned
|
|
30
|
+
// tabListProps (role, aria-orientation) must come last in a single bag to stay
|
|
31
|
+
// unoverridable by consumer-supplied element props.
|
|
32
|
+
|
|
33
|
+
const containerAttributes = useMemo(() => ({ ...elementProps,
|
|
34
|
+
...tabListProps
|
|
35
|
+
}), [elementProps, tabListProps]);
|
|
36
|
+
return /*#__PURE__*/React.createElement(TabListFocusScope, {
|
|
37
|
+
elementRef: listRef,
|
|
38
|
+
focusScopeProps: focusScopeProps
|
|
39
|
+
}, /*#__PURE__*/React.createElement(FlexContainer, {
|
|
40
|
+
as: "div",
|
|
41
|
+
display: displayMode,
|
|
42
|
+
direction: direction,
|
|
43
|
+
alignItems: alignItems,
|
|
44
|
+
scroll: scroll,
|
|
45
|
+
customClass: className,
|
|
46
|
+
customId: customId,
|
|
47
|
+
testId: testId,
|
|
48
|
+
customAttributes: containerAttributes,
|
|
49
|
+
ref: setRefs
|
|
50
|
+
}, children));
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import FocusScope from '@zohodesk/a11y/es/FocusScope/FocusScope';
|
|
5
|
+
export default function TabListFocusScope({
|
|
6
|
+
elementRef,
|
|
7
|
+
focusScopeProps,
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/React.createElement(FocusScope, _extends({
|
|
11
|
+
elementRef: elementRef,
|
|
12
|
+
needListNavigation: true,
|
|
13
|
+
needEnterAction: true,
|
|
14
|
+
needAutoFocus: false,
|
|
15
|
+
needRestoreFocus: false,
|
|
16
|
+
needFocusLoop: false
|
|
17
|
+
}, focusScopeProps), children);
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import FlexItem from '@zohodesk/layout/es/Flex/FlexItem';
|
|
3
|
+
import useTabPanel from '@zohodesk/hooks/es/tabs/useTabPanel';
|
|
4
|
+
import renderNode, { isRenderable } from '@zohodesk/utils/es/renderNode';
|
|
5
|
+
export default function TabPanel(props) {
|
|
6
|
+
const {
|
|
7
|
+
value,
|
|
8
|
+
shouldUnmount,
|
|
9
|
+
isStatic,
|
|
10
|
+
className,
|
|
11
|
+
getRef,
|
|
12
|
+
scroll,
|
|
13
|
+
customId,
|
|
14
|
+
testId,
|
|
15
|
+
children,
|
|
16
|
+
...elementProps
|
|
17
|
+
} = props;
|
|
18
|
+
const {
|
|
19
|
+
tabPanelProps,
|
|
20
|
+
isSelected,
|
|
21
|
+
shouldRender,
|
|
22
|
+
isHidden
|
|
23
|
+
} = useTabPanel({
|
|
24
|
+
value,
|
|
25
|
+
shouldUnmount,
|
|
26
|
+
isStatic
|
|
27
|
+
}); // FlexItem spreads a11yAttributes BEFORE customAttributes, so the owned panel
|
|
28
|
+
// props (role, aria-labelledby, hidden) must come last in a single bag to stay
|
|
29
|
+
// unoverridable by consumer-supplied element props.
|
|
30
|
+
|
|
31
|
+
const itemAttributes = useMemo(() => ({ ...elementProps,
|
|
32
|
+
...tabPanelProps,
|
|
33
|
+
hidden: isHidden || undefined
|
|
34
|
+
}), [elementProps, tabPanelProps, isHidden]);
|
|
35
|
+
|
|
36
|
+
if (!shouldRender) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const slot = {
|
|
41
|
+
value,
|
|
42
|
+
isSelected,
|
|
43
|
+
isHidden
|
|
44
|
+
};
|
|
45
|
+
return /*#__PURE__*/React.createElement(FlexItem, {
|
|
46
|
+
as: "div",
|
|
47
|
+
scroll: scroll,
|
|
48
|
+
customClass: typeof className === 'function' ? className(slot) : className,
|
|
49
|
+
customId: customId,
|
|
50
|
+
testId: testId,
|
|
51
|
+
customAttributes: itemAttributes,
|
|
52
|
+
ref: getRef
|
|
53
|
+
}, isRenderable(children) ? renderNode(children, slot) : children);
|
|
54
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FlexContainer from '@zohodesk/layout/es/Flex/FlexContainer';
|
|
3
|
+
import useTabs from '@zohodesk/hooks/es/tabs/useTabs';
|
|
4
|
+
import TabsProvider from '@zohodesk/hooks/es/tabs/TabsProvider';
|
|
5
|
+
export default function Tabs(props) {
|
|
6
|
+
const {
|
|
7
|
+
selectedValue,
|
|
8
|
+
defaultValue,
|
|
9
|
+
onChange,
|
|
10
|
+
orientation,
|
|
11
|
+
activation,
|
|
12
|
+
uniqueId,
|
|
13
|
+
customReducer,
|
|
14
|
+
displayMode,
|
|
15
|
+
direction,
|
|
16
|
+
className,
|
|
17
|
+
customId,
|
|
18
|
+
testId,
|
|
19
|
+
children,
|
|
20
|
+
...elementProps
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
dataValue,
|
|
24
|
+
actionsValue
|
|
25
|
+
} = useTabs({
|
|
26
|
+
selectedValue,
|
|
27
|
+
defaultValue,
|
|
28
|
+
onChange,
|
|
29
|
+
orientation,
|
|
30
|
+
activation,
|
|
31
|
+
uniqueId
|
|
32
|
+
}, customReducer);
|
|
33
|
+
return /*#__PURE__*/React.createElement(TabsProvider, {
|
|
34
|
+
dataValue: dataValue,
|
|
35
|
+
actionsValue: actionsValue
|
|
36
|
+
}, /*#__PURE__*/React.createElement(FlexContainer, {
|
|
37
|
+
as: "div",
|
|
38
|
+
display: displayMode,
|
|
39
|
+
direction: direction,
|
|
40
|
+
customClass: className,
|
|
41
|
+
customId: customId,
|
|
42
|
+
testId: testId,
|
|
43
|
+
customAttributes: elementProps
|
|
44
|
+
}, children));
|
|
45
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Tabs } from "./Tabs";
|
|
2
|
+
export { default as TabList } from "./TabList";
|
|
3
|
+
export { default as Tab } from "./Tab";
|
|
4
|
+
export { default as TabPanel } from "./TabPanel";
|
|
5
|
+
export { default as TabListFocusScope } from "./TabListFocusScope";
|
|
6
|
+
export { useTabs, useTabList, useTab, useTabPanel, useTabAriaProps, TabsProvider, TabsDataContext, TabsActionsContext, useTabsData, useTabsActions } from '@zohodesk/hooks/es/tabs';
|