@elliemae/ds-tabs 2.2.0-alpha.2 → 2.2.0-beta.0
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/cjs/DSTabs.js +40 -58
- package/cjs/DSTabsCTX.js +25 -51
- package/cjs/DSTabsDatatestid.js +14 -42
- package/cjs/DSTabsTypes.js +2 -27
- package/cjs/config/useCrossRef.js +11 -38
- package/cjs/config/useTabs.js +36 -53
- package/cjs/defaultProps.js +13 -39
- package/cjs/exportsRelated/DSTab.js +32 -46
- package/cjs/index.js +17 -38
- package/cjs/parts/carousel/Carousel.js +53 -61
- package/cjs/parts/carousel/styles.js +63 -77
- package/cjs/parts/carousel/useCarousel.js +49 -51
- package/cjs/parts/carousel/useCarouselCallbacks.js +36 -53
- package/cjs/parts/tabBar/TabBar.js +120 -124
- package/cjs/parts/tabBar/styles.js +195 -289
- package/cjs/parts/tabBar/useTabBar.js +55 -67
- package/cjs/parts/tabsContent/TabsContent.js +45 -49
- package/cjs/parts/tabsContent/styles.js +15 -39
- package/cjs/parts/tabsPanel/TabsPanels.js +58 -60
- package/cjs/parts/tabsPanel/styles.js +23 -43
- package/cjs/propTypes.js +29 -54
- package/cjs/utils/constants.js +16 -44
- package/cjs/utils/helpers.js +22 -46
- package/cjs/utils/hooks/useKeyboardNavigation.js +43 -59
- package/cjs/utils/hooks/useTabsCallbacks.js +33 -49
- package/esm/DSTabs.js +25 -24
- package/esm/DSTabsCTX.js +20 -22
- package/esm/DSTabsDatatestid.js +10 -13
- package/esm/DSTabsTypes.js +1 -2
- package/esm/config/useCrossRef.js +4 -6
- package/esm/config/useTabs.js +22 -14
- package/esm/defaultProps.js +8 -9
- package/esm/exportsRelated/DSTab.js +19 -15
- package/esm/index.js +4 -9
- package/esm/parts/carousel/Carousel.js +38 -25
- package/esm/parts/carousel/styles.js +52 -48
- package/esm/parts/carousel/useCarousel.js +34 -15
- package/esm/parts/carousel/useCarouselCallbacks.js +28 -20
- package/esm/parts/tabBar/TabBar.js +102 -93
- package/esm/parts/tabBar/styles.js +183 -262
- package/esm/parts/tabBar/useTabBar.js +36 -27
- package/esm/parts/tabsContent/TabsContent.js +35 -19
- package/esm/parts/tabsContent/styles.js +7 -10
- package/esm/parts/tabsPanel/TabsPanels.js +45 -28
- package/esm/parts/tabsPanel/styles.js +15 -14
- package/esm/propTypes.js +24 -25
- package/esm/utils/constants.js +8 -15
- package/esm/utils/helpers.js +11 -16
- package/esm/utils/hooks/useKeyboardNavigation.js +39 -30
- package/esm/utils/hooks/useTabsCallbacks.js +27 -18
- package/package.json +6 -6
- package/types/DSTabs.d.ts +2 -2
- package/cjs/DSTabs.js.map +0 -7
- package/cjs/DSTabsCTX.js.map +0 -7
- package/cjs/DSTabsDatatestid.js.map +0 -7
- package/cjs/DSTabsTypes.js.map +0 -7
- package/cjs/config/useCrossRef.js.map +0 -7
- package/cjs/config/useTabs.js.map +0 -7
- package/cjs/defaultProps.js.map +0 -7
- package/cjs/exportsRelated/DSTab.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/parts/carousel/Carousel.js.map +0 -7
- package/cjs/parts/carousel/styles.js.map +0 -7
- package/cjs/parts/carousel/useCarousel.js.map +0 -7
- package/cjs/parts/carousel/useCarouselCallbacks.js.map +0 -7
- package/cjs/parts/tabBar/TabBar.js.map +0 -7
- package/cjs/parts/tabBar/styles.js.map +0 -7
- package/cjs/parts/tabBar/useTabBar.js.map +0 -7
- package/cjs/parts/tabsContent/TabsContent.js.map +0 -7
- package/cjs/parts/tabsContent/styles.js.map +0 -7
- package/cjs/parts/tabsPanel/TabsPanels.js.map +0 -7
- package/cjs/parts/tabsPanel/styles.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/cjs/utils/constants.js.map +0 -7
- package/cjs/utils/helpers.js.map +0 -7
- package/cjs/utils/hooks/useKeyboardNavigation.js.map +0 -7
- package/cjs/utils/hooks/useTabsCallbacks.js.map +0 -7
- package/esm/DSTabs.js.map +0 -7
- package/esm/DSTabsCTX.js.map +0 -7
- package/esm/DSTabsDatatestid.js.map +0 -7
- package/esm/DSTabsTypes.js.map +0 -7
- package/esm/config/useCrossRef.js.map +0 -7
- package/esm/config/useTabs.js.map +0 -7
- package/esm/defaultProps.js.map +0 -7
- package/esm/exportsRelated/DSTab.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/parts/carousel/Carousel.js.map +0 -7
- package/esm/parts/carousel/styles.js.map +0 -7
- package/esm/parts/carousel/useCarousel.js.map +0 -7
- package/esm/parts/carousel/useCarouselCallbacks.js.map +0 -7
- package/esm/parts/tabBar/TabBar.js.map +0 -7
- package/esm/parts/tabBar/styles.js.map +0 -7
- package/esm/parts/tabBar/useTabBar.js.map +0 -7
- package/esm/parts/tabsContent/TabsContent.js.map +0 -7
- package/esm/parts/tabsContent/styles.js.map +0 -7
- package/esm/parts/tabsPanel/TabsPanels.js.map +0 -7
- package/esm/parts/tabsPanel/styles.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
- package/esm/utils/constants.js.map +0 -7
- package/esm/utils/helpers.js.map +0 -7
- package/esm/utils/hooks/useKeyboardNavigation.js.map +0 -7
- package/esm/utils/hooks/useTabsCallbacks.js.map +0 -7
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { TabTypes } from "../../utils/constants";
|
|
5
|
-
const StyledCarouselBtn = styled(DSButtonV2)`
|
|
6
|
-
margin: 0;
|
|
7
|
-
min-width: ${({ theme }) => theme.space.xs};
|
|
8
|
-
width: ${({ theme }) => theme.space.xs};
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { DSButtonV2 } from '@elliemae/ds-button';
|
|
3
|
+
import { TabTypes } from '../../utils/constants.js';
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const StyledCarouselBtn = /*#__PURE__*/styled(DSButtonV2).withConfig({
|
|
6
|
+
componentId: "sc-prv5a7-0"
|
|
7
|
+
})(["margin:0;min-width:", ";width:", ";&:hover:not(:disabled){background-color:transparent;}background-color:transparent;border-radius:0px;& .em-ds-icon svg{fill:", ";}"], _ref => {
|
|
8
|
+
let {
|
|
9
|
+
theme
|
|
10
|
+
} = _ref;
|
|
11
|
+
return theme.space.xs;
|
|
12
|
+
}, _ref2 => {
|
|
13
|
+
let {
|
|
14
|
+
theme
|
|
15
|
+
} = _ref2;
|
|
16
|
+
return theme.space.xs;
|
|
17
|
+
}, _ref3 => {
|
|
18
|
+
let {
|
|
19
|
+
theme
|
|
20
|
+
} = _ref3;
|
|
21
|
+
return theme.colors.brand[600];
|
|
22
|
+
});
|
|
23
|
+
const StyledCarouselWrapper = /*#__PURE__*/styled.span.withConfig({
|
|
24
|
+
componentId: "sc-prv5a7-1"
|
|
25
|
+
})(["position:relative;width:100%;display:flex;"]);
|
|
26
|
+
const StyledChildrenWrap = /*#__PURE__*/styled.div.withConfig({
|
|
27
|
+
componentId: "sc-prv5a7-2"
|
|
28
|
+
})(["display:flex;flex-wrap:nowrap;flex:1;overflow-x:hidden;"]);
|
|
29
|
+
const StyledCarouselButtonWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
30
|
+
componentId: "sc-prv5a7-3"
|
|
31
|
+
})(["max-width:16px;position:absolute;z-index:200;", " width:16px;height:", ";padding-top:", ";background:white;", ";"], _ref4 => {
|
|
32
|
+
let {
|
|
33
|
+
right
|
|
34
|
+
} = _ref4;
|
|
35
|
+
return right ? 'right: 0;' : "left: 0;";
|
|
36
|
+
}, _ref5 => {
|
|
37
|
+
let {
|
|
38
|
+
tabType
|
|
39
|
+
} = _ref5;
|
|
40
|
+
return tabType === TabTypes.NORMAL ? '32px' : '22px';
|
|
41
|
+
}, _ref6 => {
|
|
42
|
+
let {
|
|
43
|
+
tabType
|
|
44
|
+
} = _ref6;
|
|
45
|
+
return tabType === TabTypes.NORMAL ? '5px' : '0px';
|
|
46
|
+
}, _ref7 => {
|
|
47
|
+
let {
|
|
48
|
+
theme,
|
|
49
|
+
tabType
|
|
50
|
+
} = _ref7;
|
|
51
|
+
return tabType === TabTypes.NORMAL ? "\n background: linear-gradient(to bottom, white 0px, white 30px, ".concat(theme.colors.neutral[400], " 30px, ").concat(theme.colors.neutral[400], " 31px, white 31px , white 32px );\n ") : "";
|
|
52
|
+
});
|
|
15
53
|
|
|
16
|
-
|
|
17
|
-
fill: ${({ theme }) => theme.colors.brand[600]};
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
const StyledCarouselWrapper = styled.span`
|
|
21
|
-
position: relative;
|
|
22
|
-
width: 100%;
|
|
23
|
-
display: flex;
|
|
24
|
-
`;
|
|
25
|
-
const StyledChildrenWrap = styled.div`
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-wrap: nowrap;
|
|
28
|
-
flex: 1;
|
|
29
|
-
overflow-x: hidden;
|
|
30
|
-
`;
|
|
31
|
-
const StyledCarouselButtonWrapper = styled.div`
|
|
32
|
-
max-width: 16px;
|
|
33
|
-
position: absolute;
|
|
34
|
-
z-index: 200;
|
|
35
|
-
${({ right }) => right ? "right: 0;" : `left: 0;`}
|
|
36
|
-
width: 16px;
|
|
37
|
-
height: ${({ tabType }) => tabType === TabTypes.NORMAL ? "32px" : "22px"};
|
|
38
|
-
padding-top: ${({ tabType }) => tabType === TabTypes.NORMAL ? "5px" : "0px"};
|
|
39
|
-
background: white;
|
|
40
|
-
${({ theme, tabType }) => tabType === TabTypes.NORMAL ? `
|
|
41
|
-
background: linear-gradient(to bottom, white 0px, white 30px, ${theme.colors.neutral[400]} 30px, ${theme.colors.neutral[400]} 31px, white 31px , white 32px );
|
|
42
|
-
` : ``};
|
|
43
|
-
`;
|
|
44
|
-
export {
|
|
45
|
-
StyledCarouselBtn,
|
|
46
|
-
StyledCarouselButtonWrapper,
|
|
47
|
-
StyledCarouselWrapper,
|
|
48
|
-
StyledChildrenWrap
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=styles.js.map
|
|
54
|
+
export { StyledCarouselBtn, StyledCarouselButtonWrapper, StyledCarouselWrapper, StyledChildrenWrap };
|
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
5
|
+
import { useContext, useState, useCallback } from 'react';
|
|
6
|
+
import useResizeObserver from '@react-hook/resize-observer';
|
|
7
|
+
import { DSTabsContext } from '../../DSTabsCTX.js';
|
|
8
|
+
import { isElementVisibleCarousel } from '../../utils/helpers.js';
|
|
9
|
+
import { useCarouselCallbacks } from './useCarouselCallbacks.js';
|
|
10
|
+
|
|
11
|
+
const useCarousel = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
updateIndicatorStyle
|
|
14
|
+
} = _ref;
|
|
15
|
+
const {
|
|
16
|
+
carouselOnlyListRef
|
|
17
|
+
} = useContext(DSTabsContext);
|
|
9
18
|
const [showChevrons, setShowChevrons] = useState({
|
|
10
19
|
right: false,
|
|
11
20
|
left: false
|
|
12
21
|
});
|
|
13
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
tabsRefAsArray
|
|
24
|
+
} = useContext(DSTabsContext);
|
|
14
25
|
const shouldShowLeft = useCallback(() => carouselOnlyListRef.current ? carouselOnlyListRef.current.scrollLeft > 0 : false, [carouselOnlyListRef]);
|
|
15
26
|
const shouldShowRight = useCallback(() => carouselOnlyListRef.current ? carouselOnlyListRef.current.scrollLeft < carouselOnlyListRef.current.scrollWidth - carouselOnlyListRef.current.clientWidth : false, [carouselOnlyListRef]);
|
|
16
27
|
const recalcChevrons = useCallback(() => {
|
|
17
|
-
setShowChevrons({
|
|
28
|
+
setShowChevrons({
|
|
29
|
+
right: shouldShowRight(),
|
|
30
|
+
left: shouldShowLeft()
|
|
31
|
+
});
|
|
18
32
|
}, [shouldShowLeft, shouldShowRight]);
|
|
19
33
|
const getVisibleItemsOffset = useCallback(() => {
|
|
20
34
|
if (tabsRefAsArray.current) {
|
|
@@ -25,14 +39,21 @@ const useCarousel = ({ updateIndicatorStyle }) => {
|
|
|
25
39
|
const margin = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
|
26
40
|
return acc + (width + margin);
|
|
27
41
|
}
|
|
42
|
+
|
|
28
43
|
return acc;
|
|
29
44
|
}, 0);
|
|
30
45
|
return scroll - 16;
|
|
31
46
|
}
|
|
47
|
+
|
|
32
48
|
return 0;
|
|
33
49
|
}, [tabsRefAsArray, carouselOnlyListRef]);
|
|
34
50
|
useResizeObserver(carouselOnlyListRef, recalcChevrons);
|
|
35
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
leftButtonOnClick,
|
|
53
|
+
rightButtonOnClick,
|
|
54
|
+
handleOnClick,
|
|
55
|
+
handleOnScroll
|
|
56
|
+
} = useCarouselCallbacks({
|
|
36
57
|
getVisibleItemsOffset,
|
|
37
58
|
recalcChevrons,
|
|
38
59
|
updateIndicatorStyle
|
|
@@ -45,7 +66,5 @@ const useCarousel = ({ updateIndicatorStyle }) => {
|
|
|
45
66
|
handleOnScroll
|
|
46
67
|
};
|
|
47
68
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=useCarousel.js.map
|
|
69
|
+
|
|
70
|
+
export { useCarousel };
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { useContext, useCallback } from 'react';
|
|
2
|
+
import { isElementVisibleCarousel } from '../../utils/helpers.js';
|
|
3
|
+
import { DSTabsContext } from '../../DSTabsCTX.js';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable max-statements */
|
|
6
|
+
const useCarouselCallbacks = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
getVisibleItemsOffset,
|
|
9
|
+
updateIndicatorStyle,
|
|
10
|
+
recalcChevrons
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
focusableTabsRef,
|
|
14
|
+
carouselOnlyListRef
|
|
15
|
+
} = useContext(DSTabsContext);
|
|
11
16
|
const rightButtonOnClick = useCallback(() => {
|
|
12
17
|
if (carouselOnlyListRef.current) {
|
|
13
18
|
carouselOnlyListRef.current.scrollLeft += getVisibleItemsOffset();
|
|
@@ -20,25 +25,30 @@ const useCarouselCallbacks = ({
|
|
|
20
25
|
}, [getVisibleItemsOffset, carouselOnlyListRef]);
|
|
21
26
|
const handleOnScroll = useCallback(() => {
|
|
22
27
|
recalcChevrons();
|
|
23
|
-
if (updateIndicatorStyle)
|
|
24
|
-
updateIndicatorStyle();
|
|
28
|
+
if (updateIndicatorStyle) updateIndicatorStyle();
|
|
25
29
|
}, [recalcChevrons, updateIndicatorStyle]);
|
|
26
|
-
const handleOnClick = useCallback(
|
|
27
|
-
|
|
30
|
+
const handleOnClick = useCallback(_ref2 => {
|
|
31
|
+
let {
|
|
32
|
+
target
|
|
33
|
+
} = _ref2;
|
|
34
|
+
|
|
35
|
+
if (focusableTabsRef.current && target.getAttribute('role') === 'tab') {
|
|
28
36
|
const tabList = carouselOnlyListRef.current;
|
|
29
37
|
const tabButton = target;
|
|
30
38
|
const tabButtonDimensions = tabButton.getBoundingClientRect();
|
|
31
|
-
const tabListDimensions = tabList
|
|
39
|
+
const tabListDimensions = tabList === null || tabList === void 0 ? void 0 : tabList.getBoundingClientRect();
|
|
32
40
|
const tabButtonIndex = tabButton.dataset.index;
|
|
33
41
|
const lastItemIndex = focusableTabsRef.current.length.toString();
|
|
34
42
|
const magicNumber = 34;
|
|
35
|
-
const firstOrLastItem = tabButtonIndex ===
|
|
43
|
+
const firstOrLastItem = tabButtonIndex === '0' || tabButtonIndex === lastItemIndex;
|
|
44
|
+
|
|
36
45
|
if (!isElementVisibleCarousel(tabButton, tabList, firstOrLastItem) && tabListDimensions && carouselOnlyListRef.current) {
|
|
37
46
|
const containerWidth = tabListDimensions.width;
|
|
38
47
|
const halfContainer = containerWidth / 2;
|
|
39
48
|
const elementScrollPosition = tabButtonDimensions.left - tabListDimensions.left;
|
|
40
49
|
const positionInContainer = elementScrollPosition % containerWidth;
|
|
41
50
|
const width = tabButton.offsetWidth + magicNumber;
|
|
51
|
+
|
|
42
52
|
if (positionInContainer > halfContainer) {
|
|
43
53
|
carouselOnlyListRef.current.scrollLeft += width + positionInContainer - containerWidth;
|
|
44
54
|
} else {
|
|
@@ -54,7 +64,5 @@ const useCarouselCallbacks = ({
|
|
|
54
64
|
handleOnScroll
|
|
55
65
|
};
|
|
56
66
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=useCarouselCallbacks.js.map
|
|
67
|
+
|
|
68
|
+
export { useCarouselCallbacks };
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { useTabsCallbacks } from "../../utils/hooks/useTabsCallbacks";
|
|
17
|
-
import { DSTabsDatatestid } from "../../DSTabsDatatestid";
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
+
import React, { useContext, useMemo } from 'react';
|
|
5
|
+
import { Carousel } from '../carousel/Carousel.js';
|
|
6
|
+
import { useTabBar } from './useTabBar.js';
|
|
7
|
+
import { StyledTabButton, StyledRequiredMark, StyledSubTabsList, StyledTabList, StyledTabWrapper, StyledSelectionIndicator } from './styles.js';
|
|
8
|
+
import { DSTabsContext, DSTabsCrossRefContext } from '../../DSTabsCTX.js';
|
|
9
|
+
import { useKeyboardNavigation } from '../../utils/hooks/useKeyboardNavigation.js';
|
|
10
|
+
import { TabTypes } from '../../utils/constants.js';
|
|
11
|
+
import { useTabsCallbacks } from '../../utils/hooks/useTabsCallbacks.js';
|
|
12
|
+
import { DSTabsDatatestid } from '../../DSTabsDatatestid.js';
|
|
13
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
14
|
+
|
|
15
|
+
var _StyledRequiredMark;
|
|
18
16
|
const TabBar = () => {
|
|
19
17
|
const {
|
|
20
18
|
tabsRef,
|
|
@@ -22,121 +20,132 @@ const TabBar = () => {
|
|
|
22
20
|
tabsListRef,
|
|
23
21
|
tabsRefAsArray,
|
|
24
22
|
actualActiveTab,
|
|
25
|
-
props: {
|
|
23
|
+
props: {
|
|
24
|
+
type,
|
|
25
|
+
fixedTabsHeaders,
|
|
26
|
+
withCarousel,
|
|
27
|
+
isDSMobile,
|
|
28
|
+
showSeparator,
|
|
29
|
+
children: tabs
|
|
30
|
+
}
|
|
26
31
|
} = useContext(DSTabsContext);
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
const {
|
|
33
|
+
lastTabInternalRef,
|
|
34
|
+
firstSubtabInternalRef
|
|
35
|
+
} = useContext(DSTabsCrossRefContext);
|
|
36
|
+
const {
|
|
37
|
+
handleOnTabChange
|
|
38
|
+
} = useTabsCallbacks();
|
|
39
|
+
const {
|
|
40
|
+
handleOnKeyDown
|
|
41
|
+
} = useKeyboardNavigation();
|
|
42
|
+
const {
|
|
43
|
+
indicatorStyle,
|
|
44
|
+
mobileGradients,
|
|
45
|
+
updateMobileGradients,
|
|
46
|
+
updateIndicatorStyle
|
|
47
|
+
} = useTabBar();
|
|
31
48
|
const renderTabs = useMemo(() => {
|
|
32
49
|
const availableTabIndexes = [];
|
|
33
|
-
return
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
return React.Children.map(tabs, (tab, index) => {
|
|
51
|
+
const {
|
|
52
|
+
tabId = '',
|
|
53
|
+
title = '',
|
|
54
|
+
style,
|
|
55
|
+
required = false,
|
|
56
|
+
disabled = false,
|
|
57
|
+
ref,
|
|
58
|
+
onClick,
|
|
59
|
+
onKeyDown
|
|
60
|
+
} = tab.props;
|
|
61
|
+
if (!disabled) availableTabIndexes.push(index);
|
|
62
|
+
return /*#__PURE__*/jsxs(StyledTabButton, {
|
|
39
63
|
role: "tab",
|
|
40
|
-
ref:
|
|
64
|
+
ref: t => {
|
|
41
65
|
if (tabsRefAsArray.current && focusableTabsRef.current && tabsRef.current) {
|
|
42
66
|
tabsRefAsArray.current[index] = t;
|
|
43
|
-
if (!disabled && !focusableTabsRef.current.includes(t))
|
|
44
|
-
focusableTabsRef.current.push(t);
|
|
67
|
+
if (!disabled && !focusableTabsRef.current.includes(t)) focusableTabsRef.current.push(t);
|
|
45
68
|
tabsRef.current[index] = t;
|
|
69
|
+
|
|
46
70
|
if (type === TabTypes.SUBTABS && firstSubtabInternalRef && index === availableTabIndexes[0]) {
|
|
47
71
|
firstSubtabInternalRef.current = t;
|
|
48
72
|
}
|
|
73
|
+
|
|
49
74
|
if (type !== TabTypes.SUBTABS && index === availableTabIndexes[availableTabIndexes.length - 1]) {
|
|
50
75
|
lastTabInternalRef.current = t;
|
|
51
76
|
}
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
|
|
78
|
+
if (ref) ref.current = t;
|
|
54
79
|
}
|
|
55
80
|
},
|
|
56
81
|
type: "button",
|
|
57
82
|
"aria-controls": tabId,
|
|
58
83
|
"aria-selected": actualActiveTab === tabId,
|
|
59
84
|
"aria-disabled": disabled,
|
|
60
|
-
"aria-labelledby":
|
|
61
|
-
isDSMobile,
|
|
62
|
-
fixedTabsHeaders,
|
|
85
|
+
"aria-labelledby": "".concat(tabId, "-label"),
|
|
86
|
+
isDSMobile: isDSMobile,
|
|
87
|
+
fixedTabsHeaders: fixedTabsHeaders,
|
|
63
88
|
tabType: type,
|
|
64
|
-
title,
|
|
89
|
+
title: title,
|
|
65
90
|
"data-required": required,
|
|
66
91
|
"data-tab-id": tabId,
|
|
67
92
|
"data-index": index,
|
|
68
|
-
withCarousel,
|
|
93
|
+
withCarousel: withCarousel,
|
|
69
94
|
isActive: actualActiveTab === tabId,
|
|
70
|
-
disabled,
|
|
95
|
+
disabled: disabled,
|
|
71
96
|
showSeparator: showSeparator && type !== TabTypes.NORMAL,
|
|
72
97
|
"data-testid": type === TabTypes.NORMAL ? DSTabsDatatestid.TAB_BUTTON : DSTabsDatatestid.SUBTAB_BUTTON,
|
|
73
|
-
id:
|
|
74
|
-
onClick:
|
|
98
|
+
id: "".concat(tabId, "-label"),
|
|
99
|
+
onClick: e => {
|
|
75
100
|
if (!disabled) {
|
|
76
101
|
handleOnTabChange(tabId, e);
|
|
77
102
|
updateIndicatorStyle();
|
|
78
103
|
}
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
|
|
105
|
+
if (onClick && !disabled) onClick(tabId, e);
|
|
81
106
|
},
|
|
82
|
-
onKeyDown:
|
|
83
|
-
if (e.key ===
|
|
84
|
-
|
|
85
|
-
if (!disabled)
|
|
86
|
-
handleOnKeyDown(e);
|
|
87
|
-
if (onKeyDown && !disabled)
|
|
88
|
-
onKeyDown(e);
|
|
107
|
+
onKeyDown: e => {
|
|
108
|
+
if (e.key === 'Enter') e.stopPropagation();
|
|
109
|
+
if (!disabled) handleOnKeyDown(e);
|
|
110
|
+
if (onKeyDown && !disabled) onKeyDown(e);
|
|
89
111
|
},
|
|
90
|
-
style
|
|
91
|
-
|
|
112
|
+
style: style,
|
|
113
|
+
children: [title, required && (_StyledRequiredMark || (_StyledRequiredMark = /*#__PURE__*/_jsx(StyledRequiredMark, {}, void 0, "\u25CF")))]
|
|
114
|
+
}, tabId);
|
|
92
115
|
});
|
|
93
|
-
}, [
|
|
94
|
-
|
|
95
|
-
actualActiveTab,
|
|
96
|
-
isDSMobile,
|
|
97
|
-
fixedTabsHeaders,
|
|
98
|
-
type,
|
|
99
|
-
withCarousel,
|
|
100
|
-
showSeparator,
|
|
101
|
-
tabsRefAsArray,
|
|
102
|
-
focusableTabsRef,
|
|
103
|
-
tabsRef,
|
|
104
|
-
firstSubtabInternalRef,
|
|
105
|
-
lastTabInternalRef,
|
|
106
|
-
handleOnTabChange,
|
|
107
|
-
updateIndicatorStyle,
|
|
108
|
-
handleOnKeyDown
|
|
109
|
-
]);
|
|
116
|
+
}, [tabs, actualActiveTab, isDSMobile, fixedTabsHeaders, type, withCarousel, showSeparator, tabsRefAsArray, focusableTabsRef, tabsRef, firstSubtabInternalRef, lastTabInternalRef, handleOnTabChange, updateIndicatorStyle, handleOnKeyDown]);
|
|
117
|
+
|
|
110
118
|
if (type === TabTypes.SUBTABS && !isDSMobile) {
|
|
111
|
-
return
|
|
112
|
-
withCarousel,
|
|
119
|
+
return /*#__PURE__*/jsx(StyledSubTabsList, {
|
|
120
|
+
withCarousel: withCarousel,
|
|
113
121
|
"data-testid": DSTabsDatatestid.SUB_TAB_LIST,
|
|
114
122
|
ref: tabsListRef,
|
|
115
|
-
role: "tablist"
|
|
116
|
-
|
|
123
|
+
role: "tablist",
|
|
124
|
+
children: withCarousel ? /*#__PURE__*/_jsx(Carousel, {}, void 0, renderTabs) : renderTabs
|
|
125
|
+
});
|
|
117
126
|
}
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
|
|
128
|
+
return /*#__PURE__*/jsxs(StyledTabList, {
|
|
129
|
+
withCarousel: withCarousel,
|
|
120
130
|
ref: tabsListRef,
|
|
121
131
|
role: "tablist",
|
|
122
132
|
"data-testid": DSTabsDatatestid.TAB_LIST,
|
|
123
|
-
isDSMobile,
|
|
124
|
-
fixedTabsHeaders,
|
|
125
|
-
mobileGradients,
|
|
133
|
+
isDSMobile: isDSMobile,
|
|
134
|
+
fixedTabsHeaders: fixedTabsHeaders,
|
|
135
|
+
mobileGradients: mobileGradients,
|
|
126
136
|
onScroll: updateMobileGradients,
|
|
127
|
-
indicatorStyle,
|
|
128
|
-
tabType: type
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
139
|
-
export {
|
|
140
|
-
TabBar
|
|
137
|
+
indicatorStyle: indicatorStyle,
|
|
138
|
+
tabType: type,
|
|
139
|
+
children: [/*#__PURE__*/_jsx(StyledTabWrapper, {
|
|
140
|
+
isDSMobile: isDSMobile,
|
|
141
|
+
fixedTabsHeaders: fixedTabsHeaders
|
|
142
|
+
}, void 0, !isDSMobile && withCarousel ? /*#__PURE__*/_jsx(Carousel, {
|
|
143
|
+
updateIndicatorStyle: updateIndicatorStyle
|
|
144
|
+
}, void 0, renderTabs) : renderTabs), /*#__PURE__*/_jsx(StyledSelectionIndicator, {
|
|
145
|
+
isDSMobile: isDSMobile,
|
|
146
|
+
tabType: type
|
|
147
|
+
})]
|
|
148
|
+
});
|
|
141
149
|
};
|
|
142
|
-
|
|
150
|
+
|
|
151
|
+
export { TabBar };
|