@elliemae/ds-tabs 2.3.1 → 3.0.0-alpha.3
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/dist/cjs/DSTabs.js +63 -0
- package/dist/cjs/DSTabs.js.map +7 -0
- package/dist/cjs/DSTabsCTX.js +56 -0
- package/dist/cjs/DSTabsCTX.js.map +7 -0
- package/dist/cjs/DSTabsDatatestid.js +46 -0
- package/dist/cjs/DSTabsDatatestid.js.map +7 -0
- package/dist/cjs/DSTabsTypes.js +27 -0
- package/dist/cjs/DSTabsTypes.js.map +7 -0
- package/dist/cjs/config/useCrossRef.js +44 -0
- package/dist/cjs/config/useCrossRef.js.map +7 -0
- package/dist/cjs/config/useTabs.js +74 -0
- package/dist/cjs/config/useTabs.js.map +7 -0
- package/dist/cjs/defaultProps.js +53 -0
- package/dist/cjs/defaultProps.js.map +7 -0
- package/dist/cjs/exportsRelated/DSTab.js +58 -0
- package/dist/cjs/exportsRelated/DSTab.js.map +7 -0
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/parts/carousel/Carousel.js +77 -0
- package/dist/cjs/parts/carousel/Carousel.js.map +7 -0
- package/dist/cjs/parts/carousel/styles.js +79 -0
- package/dist/cjs/parts/carousel/styles.js.map +7 -0
- package/dist/cjs/parts/carousel/useCarousel.js +80 -0
- package/dist/cjs/parts/carousel/useCarousel.js.map +7 -0
- package/dist/cjs/parts/carousel/useCarouselCallbacks.js +89 -0
- package/dist/cjs/parts/carousel/useCarouselCallbacks.js.map +7 -0
- package/dist/cjs/parts/tabBar/TabBar.js +171 -0
- package/dist/cjs/parts/tabBar/TabBar.js.map +7 -0
- package/dist/cjs/parts/tabBar/styles.js +294 -0
- package/dist/cjs/parts/tabBar/styles.js.map +7 -0
- package/dist/cjs/parts/tabBar/useTabBar.js +100 -0
- package/dist/cjs/parts/tabBar/useTabBar.js.map +7 -0
- package/dist/cjs/parts/tabsContent/TabsContent.js +69 -0
- package/dist/cjs/parts/tabsContent/TabsContent.js.map +7 -0
- package/dist/cjs/parts/tabsContent/styles.js +39 -0
- package/dist/cjs/parts/tabsContent/styles.js.map +7 -0
- package/dist/cjs/parts/tabsPanel/TabsPanels.js +95 -0
- package/dist/cjs/parts/tabsPanel/TabsPanels.js.map +7 -0
- package/dist/cjs/parts/tabsPanel/styles.js +45 -0
- package/dist/cjs/parts/tabsPanel/styles.js.map +7 -0
- package/dist/cjs/propTypes.js +58 -0
- package/dist/cjs/propTypes.js.map +7 -0
- package/dist/cjs/utils/constants.js +56 -0
- package/dist/cjs/utils/constants.js.map +7 -0
- package/dist/cjs/utils/helpers.js +84 -0
- package/dist/cjs/utils/helpers.js.map +7 -0
- package/dist/cjs/utils/hooks/useKeyboardNavigation.js +77 -0
- package/dist/cjs/utils/hooks/useKeyboardNavigation.js.map +7 -0
- package/dist/cjs/utils/hooks/useTabsCallbacks.js +60 -0
- package/dist/cjs/utils/hooks/useTabsCallbacks.js.map +7 -0
- package/dist/esm/DSTabs.js +34 -0
- package/dist/esm/DSTabs.js.map +7 -0
- package/dist/esm/DSTabsCTX.js +27 -0
- package/dist/esm/DSTabsCTX.js.map +7 -0
- package/dist/esm/DSTabsDatatestid.js +17 -0
- package/dist/esm/DSTabsDatatestid.js.map +7 -0
- package/dist/esm/DSTabsTypes.js +2 -0
- package/dist/esm/DSTabsTypes.js.map +7 -0
- package/{esm → dist/esm}/config/useCrossRef.js +6 -4
- package/dist/esm/config/useCrossRef.js.map +7 -0
- package/dist/esm/config/useTabs.js +45 -0
- package/dist/esm/config/useTabs.js.map +7 -0
- package/{esm → dist/esm}/defaultProps.js +9 -8
- package/dist/esm/defaultProps.js.map +7 -0
- package/dist/esm/exportsRelated/DSTab.js +31 -0
- package/dist/esm/exportsRelated/DSTab.js.map +7 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parts/carousel/Carousel.js +48 -0
- package/dist/esm/parts/carousel/Carousel.js.map +7 -0
- package/dist/esm/parts/carousel/styles.js +50 -0
- package/dist/esm/parts/carousel/styles.js.map +7 -0
- package/{esm → dist/esm}/parts/carousel/useCarousel.js +15 -34
- package/dist/esm/parts/carousel/useCarousel.js.map +7 -0
- package/{esm → dist/esm}/parts/carousel/useCarouselCallbacks.js +20 -28
- package/dist/esm/parts/carousel/useCarouselCallbacks.js.map +7 -0
- package/dist/esm/parts/tabBar/TabBar.js +149 -0
- package/dist/esm/parts/tabBar/TabBar.js.map +7 -0
- package/dist/esm/parts/tabBar/styles.js +265 -0
- package/dist/esm/parts/tabBar/styles.js.map +7 -0
- package/{esm → dist/esm}/parts/tabBar/useTabBar.js +27 -35
- package/dist/esm/parts/tabBar/useTabBar.js.map +7 -0
- package/dist/esm/parts/tabsContent/TabsContent.js +42 -0
- package/dist/esm/parts/tabsContent/TabsContent.js.map +7 -0
- package/dist/esm/parts/tabsContent/styles.js +10 -0
- package/dist/esm/parts/tabsContent/styles.js.map +7 -0
- package/dist/esm/parts/tabsPanel/TabsPanels.js +66 -0
- package/dist/esm/parts/tabsPanel/TabsPanels.js.map +7 -0
- package/dist/esm/parts/tabsPanel/styles.js +16 -0
- package/dist/esm/parts/tabsPanel/styles.js.map +7 -0
- package/dist/esm/propTypes.js +29 -0
- package/dist/esm/propTypes.js.map +7 -0
- package/dist/esm/utils/constants.js +27 -0
- package/dist/esm/utils/constants.js.map +7 -0
- package/{esm → dist/esm}/utils/helpers.js +19 -26
- package/dist/esm/utils/helpers.js.map +7 -0
- package/dist/esm/utils/hooks/useKeyboardNavigation.js +48 -0
- package/dist/esm/utils/hooks/useKeyboardNavigation.js.map +7 -0
- package/dist/esm/utils/hooks/useTabsCallbacks.js +31 -0
- package/dist/esm/utils/hooks/useTabsCallbacks.js.map +7 -0
- package/package.json +78 -69
- package/cjs/DSTabs.js +0 -45
- package/cjs/DSTabsCTX.js +0 -30
- package/cjs/DSTabsDatatestid.js +0 -18
- package/cjs/DSTabsTypes.js +0 -2
- package/cjs/config/useCrossRef.js +0 -17
- package/cjs/config/useTabs.js +0 -54
- package/cjs/defaultProps.js +0 -27
- package/cjs/exportsRelated/DSTab.js +0 -32
- package/cjs/index.js +0 -17
- package/cjs/parts/carousel/Carousel.js +0 -69
- package/cjs/parts/carousel/styles.js +0 -65
- package/cjs/parts/carousel/useCarousel.js +0 -78
- package/cjs/parts/carousel/useCarouselCallbacks.js +0 -72
- package/cjs/parts/tabBar/TabBar.js +0 -168
- package/cjs/parts/tabBar/styles.js +0 -200
- package/cjs/parts/tabBar/useTabBar.js +0 -87
- package/cjs/parts/tabsContent/TabsContent.js +0 -49
- package/cjs/parts/tabsContent/styles.js +0 -15
- package/cjs/parts/tabsPanel/TabsPanels.js +0 -102
- package/cjs/parts/tabsPanel/styles.js +0 -25
- package/cjs/propTypes.js +0 -33
- package/cjs/utils/constants.js +0 -28
- package/cjs/utils/helpers.js +0 -71
- package/cjs/utils/hooks/useKeyboardNavigation.js +0 -61
- package/cjs/utils/hooks/useTabsCallbacks.js +0 -41
- package/esm/DSTabs.js +0 -35
- package/esm/DSTabsCTX.js +0 -25
- package/esm/DSTabsDatatestid.js +0 -14
- package/esm/DSTabsTypes.js +0 -1
- package/esm/config/useTabs.js +0 -50
- package/esm/exportsRelated/DSTab.js +0 -21
- package/esm/index.js +0 -4
- package/esm/parts/carousel/Carousel.js +0 -61
- package/esm/parts/carousel/styles.js +0 -54
- package/esm/parts/tabBar/TabBar.js +0 -159
- package/esm/parts/tabBar/styles.js +0 -186
- package/esm/parts/tabsContent/TabsContent.js +0 -40
- package/esm/parts/tabsContent/styles.js +0 -7
- package/esm/parts/tabsPanel/TabsPanels.js +0 -92
- package/esm/parts/tabsPanel/styles.js +0 -17
- package/esm/propTypes.js +0 -28
- package/esm/utils/constants.js +0 -20
- package/esm/utils/hooks/useKeyboardNavigation.js +0 -57
- package/esm/utils/hooks/useTabsCallbacks.js +0 -37
- package/types/DSTabs.d.ts +0 -14
- package/types/DSTabsCTX.d.ts +0 -4
- package/types/DSTabsDatatestid.d.ts +0 -12
- package/types/DSTabsTypes.d.ts +0 -205
- package/types/config/useCrossRef.d.ts +0 -2
- package/types/config/useTabs.d.ts +0 -2
- package/types/defaultProps.d.ts +0 -2
- package/types/exportsRelated/DSTab.d.ts +0 -14
- package/types/index.d.ts +0 -5
- package/types/parts/carousel/Carousel.d.ts +0 -3
- package/types/parts/carousel/styles.d.ts +0 -6
- package/types/parts/carousel/useCarousel.d.ts +0 -2
- package/types/parts/carousel/useCarouselCallbacks.d.ts +0 -2
- package/types/parts/tabBar/TabBar.d.ts +0 -2
- package/types/parts/tabBar/styles.d.ts +0 -7
- package/types/parts/tabBar/useTabBar.d.ts +0 -2
- package/types/parts/tabsContent/TabsContent.d.ts +0 -2
- package/types/parts/tabsContent/styles.d.ts +0 -1
- package/types/parts/tabsPanel/TabsPanels.d.ts +0 -2
- package/types/parts/tabsPanel/styles.d.ts +0 -2
- package/types/propTypes.d.ts +0 -54
- package/types/tests/DSTabs.callbacks.test.d.ts +0 -1
- package/types/tests/DSTabs.func.test.d.ts +0 -1
- package/types/tests/DSTabs.keyboard.test.d.ts +0 -1
- package/types/tests/DSTabs.test.d.ts +0 -1
- package/types/utils/constants.d.ts +0 -18
- package/types/utils/helpers.d.ts +0 -7
- package/types/utils/hooks/useKeyboardNavigation.d.ts +0 -2
- package/types/utils/hooks/useTabsCallbacks.d.ts +0 -2
package/cjs/propTypes.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactDesc = require('react-desc');
|
|
6
|
-
var constants = require('./utils/constants.js');
|
|
7
|
-
|
|
8
|
-
const tabPropTypes = {
|
|
9
|
-
tabId: reactDesc.PropTypes.string.description('Unique Tab id.').defaultValue(''),
|
|
10
|
-
title: reactDesc.PropTypes.string.description('Tab title.').defaultValue(''),
|
|
11
|
-
required: reactDesc.PropTypes.bool.description('Show a required mark next to the title.').defaultValue(false),
|
|
12
|
-
disabled: reactDesc.PropTypes.bool.description('Disables Tab.').defaultValue(false)
|
|
13
|
-
};
|
|
14
|
-
const tabsPropTypes = {
|
|
15
|
-
animated: reactDesc.PropTypes.bool.description('Whether the Tab transition should animate or not.').defaultValue(true),
|
|
16
|
-
enableMouseEvents: reactDesc.PropTypes.bool.description('Enables Tab transition with mouse drag events.').defaultValue(false),
|
|
17
|
-
allowTextSelection: reactDesc.PropTypes.bool.description('Allows text selection when mouse drag events are active.').defaultValue(false),
|
|
18
|
-
onTabChange: reactDesc.PropTypes.func.description('Handler when a user clicks on a different Tab.').defaultValue('() => {}'),
|
|
19
|
-
type: reactDesc.PropTypes.oneOf(constants.TabTypesValuesAsArray).description('Tab type.').defaultValue(constants.TabTypesValuesAsArray[0]),
|
|
20
|
-
tabBarExtraContent: reactDesc.PropTypes.element.description('Extra content next to the Tab Bar.').defaultValue(undefined),
|
|
21
|
-
onlyRenderActiveTab: reactDesc.PropTypes.bool.description('Only renders the active Tab in the DOM.').defaultValue(false),
|
|
22
|
-
withCarousel: reactDesc.PropTypes.bool.description('Activate carousel behavior.').defaultValue(false),
|
|
23
|
-
activeTab: reactDesc.PropTypes.string.description('Passing a value makes DSTabs a controlled component.').defaultValue('First DSTab children.'),
|
|
24
|
-
children: reactDesc.PropTypes.node.description('Use DSTab component as children.').isRequired,
|
|
25
|
-
tabsListAriaLabel: reactDesc.PropTypes.string.description('Aria label for the list.').defaultValue('Tab list.'),
|
|
26
|
-
containerProps: reactDesc.PropTypes.object.description('Additional properties for the container.').defaultValue({}),
|
|
27
|
-
innerRef: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.func, reactDesc.PropTypes.shape({
|
|
28
|
-
current: reactDesc.PropTypes.any
|
|
29
|
-
})]).description('Ref to the container.').defaultValue(undefined)
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
exports.tabPropTypes = tabPropTypes;
|
|
33
|
-
exports.tabsPropTypes = tabsPropTypes;
|
package/cjs/utils/constants.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const TabTypes = {
|
|
6
|
-
NORMAL: 'normal',
|
|
7
|
-
NORMAL_SMALL: 'normal_small',
|
|
8
|
-
SUBTABS: 'subtabs'
|
|
9
|
-
};
|
|
10
|
-
const TabTypesValuesAsArray = Object.values(TabTypes);
|
|
11
|
-
const MOBILE_GRADIENT_WIDTH = 24;
|
|
12
|
-
const defaultIndicatorStyles = {
|
|
13
|
-
left: '0px',
|
|
14
|
-
width: '0px',
|
|
15
|
-
backgroundWithTransparent: ''
|
|
16
|
-
};
|
|
17
|
-
const gradientOffsetsAccordingType = {
|
|
18
|
-
normal_small: 14,
|
|
19
|
-
normal: 16,
|
|
20
|
-
subtabs: 16,
|
|
21
|
-
fixedTabsHeaders: 0
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.MOBILE_GRADIENT_WIDTH = MOBILE_GRADIENT_WIDTH;
|
|
25
|
-
exports.TabTypes = TabTypes;
|
|
26
|
-
exports.TabTypesValuesAsArray = TabTypesValuesAsArray;
|
|
27
|
-
exports.defaultIndicatorStyles = defaultIndicatorStyles;
|
|
28
|
-
exports.gradientOffsetsAccordingType = gradientOffsetsAccordingType;
|
package/cjs/utils/helpers.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var constants = require('./constants.js');
|
|
6
|
-
|
|
7
|
-
const isElementVisible = (tab, tabList) => {
|
|
8
|
-
const tabDimensions = tab.getBoundingClientRect();
|
|
9
|
-
const tabListDimensions = tabList.getBoundingClientRect();
|
|
10
|
-
return tabDimensions.left <= tabListDimensions.left ? tabListDimensions.left - tabDimensions.left <= tabDimensions.width : tabDimensions.right - tabListDimensions.right <= tabDimensions.width;
|
|
11
|
-
};
|
|
12
|
-
const isElementVisibleCarousel = function (tab, tabContainer) {
|
|
13
|
-
let firstOrLastItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
14
|
-
|
|
15
|
-
if (tab && tabContainer) {
|
|
16
|
-
const tabDimensions = tab.getBoundingClientRect();
|
|
17
|
-
const tabContainerDimensions = tabContainer.getBoundingClientRect();
|
|
18
|
-
const offset = firstOrLastItem ? 16 : 32;
|
|
19
|
-
const tabDimensionsLeft = Math.floor(tabDimensions.left - offset);
|
|
20
|
-
const tabDimensionsRight = Math.floor(tabDimensions.right + offset);
|
|
21
|
-
const tabContainerDimensionsLeft = Math.floor(tabContainerDimensions.left);
|
|
22
|
-
const tabContainerDimensionsRight = Math.floor(tabContainerDimensions.right);
|
|
23
|
-
return tabDimensionsLeft >= tabContainerDimensionsLeft && tabDimensionsRight <= tabContainerDimensionsRight;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return false;
|
|
27
|
-
};
|
|
28
|
-
const centerTab = _ref => {
|
|
29
|
-
let {
|
|
30
|
-
e,
|
|
31
|
-
listRef
|
|
32
|
-
} = _ref;
|
|
33
|
-
|
|
34
|
-
if (listRef.current) {
|
|
35
|
-
const {
|
|
36
|
-
offsetLeft
|
|
37
|
-
} = e === null || e === void 0 ? void 0 : e.target;
|
|
38
|
-
const {
|
|
39
|
-
width: tabWidth
|
|
40
|
-
} = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
|
|
41
|
-
const {
|
|
42
|
-
width: listWidth
|
|
43
|
-
} = listRef.current.getBoundingClientRect();
|
|
44
|
-
const extraSideSpace = listWidth - tabWidth;
|
|
45
|
-
const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
|
|
46
|
-
const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
|
|
47
|
-
listRef.current.scrollTo({
|
|
48
|
-
top: 0,
|
|
49
|
-
left: centeredLeftOffset,
|
|
50
|
-
behavior: 'smooth'
|
|
51
|
-
});
|
|
52
|
-
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const getVisibleDimensions = (node, referenceNode) => {
|
|
56
|
-
const nodeDimensions = node.getBoundingClientRect();
|
|
57
|
-
const referenceNodeDimensions = referenceNode.getBoundingClientRect();
|
|
58
|
-
return {
|
|
59
|
-
width: Math.min(node.clientWidth, referenceNodeDimensions.left + referenceNode.clientWidth - nodeDimensions.left, node.clientWidth - (referenceNodeDimensions.left - nodeDimensions.left)),
|
|
60
|
-
height: Math.min(node.clientHeight, referenceNodeDimensions.top + referenceNode.clientHeight - nodeDimensions.top, node.clientHeight - (referenceNodeDimensions.top - nodeDimensions.top))
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const shouldHaveLeftGradient = scrollLeft => Math.abs(scrollLeft) > constants.MOBILE_GRADIENT_WIDTH;
|
|
64
|
-
const shouldHaveRightGradient = (scrollLeft, clientWidth, scrollWidth) => Math.abs(scrollLeft) <= scrollWidth - (clientWidth + constants.MOBILE_GRADIENT_WIDTH);
|
|
65
|
-
|
|
66
|
-
exports.centerTab = centerTab;
|
|
67
|
-
exports.getVisibleDimensions = getVisibleDimensions;
|
|
68
|
-
exports.isElementVisible = isElementVisible;
|
|
69
|
-
exports.isElementVisibleCarousel = isElementVisibleCarousel;
|
|
70
|
-
exports.shouldHaveLeftGradient = shouldHaveLeftGradient;
|
|
71
|
-
exports.shouldHaveRightGradient = shouldHaveRightGradient;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var DSTabsCTX = require('../../DSTabsCTX.js');
|
|
7
|
-
|
|
8
|
-
/* eslint-disable max-statements */
|
|
9
|
-
const useKeyboardNavigation = () => {
|
|
10
|
-
const {
|
|
11
|
-
focusableTabsRef
|
|
12
|
-
} = React.useContext(DSTabsCTX.DSTabsContext);
|
|
13
|
-
const {
|
|
14
|
-
firstSubtabInternalRef,
|
|
15
|
-
lastTabInternalRef
|
|
16
|
-
} = React.useContext(DSTabsCTX.DSTabsCrossRefContext);
|
|
17
|
-
const handleOnKeyDown = React.useCallback(e => {
|
|
18
|
-
if (e.key === 'ArrowRight' && focusableTabsRef.current) {
|
|
19
|
-
var _focusableTabsRef$cur, _focusableTabsRef$cur2;
|
|
20
|
-
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
e.stopPropagation();
|
|
23
|
-
const nextTab = focusableTabsRef.current[(focusableTabsRef === null || focusableTabsRef === void 0 ? void 0 : (_focusableTabsRef$cur = focusableTabsRef.current) === null || _focusableTabsRef$cur === void 0 ? void 0 : (_focusableTabsRef$cur2 = _focusableTabsRef$cur.indexOf) === null || _focusableTabsRef$cur2 === void 0 ? void 0 : _focusableTabsRef$cur2.call(_focusableTabsRef$cur, e.target)) + 1];
|
|
24
|
-
if (nextTab) nextTab.focus();
|
|
25
|
-
if (!nextTab) return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (e.key === 'ArrowLeft' && focusableTabsRef.current) {
|
|
29
|
-
var _focusableTabsRef$cur3, _focusableTabsRef$cur4;
|
|
30
|
-
|
|
31
|
-
e.preventDefault();
|
|
32
|
-
e.stopPropagation();
|
|
33
|
-
const prevTab = focusableTabsRef.current[(focusableTabsRef === null || focusableTabsRef === void 0 ? void 0 : (_focusableTabsRef$cur3 = focusableTabsRef.current) === null || _focusableTabsRef$cur3 === void 0 ? void 0 : (_focusableTabsRef$cur4 = _focusableTabsRef$cur3.indexOf) === null || _focusableTabsRef$cur4 === void 0 ? void 0 : _focusableTabsRef$cur4.call(_focusableTabsRef$cur3, e.target)) - 1];
|
|
34
|
-
if (prevTab) prevTab.focus();
|
|
35
|
-
if (!prevTab) return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (e.key === 'ArrowDown') {
|
|
39
|
-
var _firstSubtabInternalR;
|
|
40
|
-
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
e.stopPropagation();
|
|
43
|
-
const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
|
|
44
|
-
if (canFocusCrossTabs) (_firstSubtabInternalR = firstSubtabInternalRef.current) === null || _firstSubtabInternalR === void 0 ? void 0 : _firstSubtabInternalR.focus();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (e.key === 'ArrowUp') {
|
|
48
|
-
var _lastTabInternalRef$c;
|
|
49
|
-
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
e.stopPropagation();
|
|
52
|
-
const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
|
|
53
|
-
if (canFocusCrossTabs) (_lastTabInternalRef$c = lastTabInternalRef.current) === null || _lastTabInternalRef$c === void 0 ? void 0 : _lastTabInternalRef$c.focus();
|
|
54
|
-
}
|
|
55
|
-
}, [firstSubtabInternalRef, lastTabInternalRef, focusableTabsRef]);
|
|
56
|
-
return {
|
|
57
|
-
handleOnKeyDown
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
exports.useKeyboardNavigation = useKeyboardNavigation;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var helpers = require('../helpers.js');
|
|
7
|
-
var DSTabsCTX = require('../../DSTabsCTX.js');
|
|
8
|
-
|
|
9
|
-
const useTabsCallbacks = () => {
|
|
10
|
-
const {
|
|
11
|
-
setInternalActiveTab,
|
|
12
|
-
tabsListRef,
|
|
13
|
-
props: {
|
|
14
|
-
onTabChange,
|
|
15
|
-
isDSMobile,
|
|
16
|
-
allowTextSelection,
|
|
17
|
-
fixedTabsHeaders
|
|
18
|
-
}
|
|
19
|
-
} = React.useContext(DSTabsCTX.DSTabsContext);
|
|
20
|
-
const handleOnTabChange = React.useCallback((tabId, e) => {
|
|
21
|
-
setInternalActiveTab(tabId);
|
|
22
|
-
onTabChange(tabId, e);
|
|
23
|
-
|
|
24
|
-
if (isDSMobile && !fixedTabsHeaders && e) {
|
|
25
|
-
helpers.centerTab({
|
|
26
|
-
e,
|
|
27
|
-
listRef: tabsListRef
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}, [fixedTabsHeaders, isDSMobile, onTabChange, setInternalActiveTab, tabsListRef]);
|
|
31
|
-
const handleOnMouseDown = React.useCallback(e => {
|
|
32
|
-
const role = e.target.getAttribute('role');
|
|
33
|
-
if (role !== 'tabpanel' && allowTextSelection) e.stopPropagation();
|
|
34
|
-
}, [allowTextSelection]);
|
|
35
|
-
return {
|
|
36
|
-
handleOnTabChange,
|
|
37
|
-
handleOnMouseDown
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.useTabsCallbacks = useTabsCallbacks;
|
package/esm/DSTabs.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import { describe } from 'react-desc';
|
|
3
|
-
import { tabsPropTypes } from './propTypes.js';
|
|
4
|
-
import { DSTabsContext, DSTabsCrossRefContext } from './DSTabsCTX.js';
|
|
5
|
-
import { TabsContent } from './parts/tabsContent/TabsContent.js';
|
|
6
|
-
import { useTabs } from './config/useTabs.js';
|
|
7
|
-
import { useCrossRef } from './config/useCrossRef.js';
|
|
8
|
-
import { TabTypes } from './utils/constants.js';
|
|
9
|
-
|
|
10
|
-
var _TabsContent, _TabsContent2;
|
|
11
|
-
|
|
12
|
-
const DSTabs = props => {
|
|
13
|
-
const ctx = useTabs(props);
|
|
14
|
-
const crossRefsCtx = useCrossRef();
|
|
15
|
-
const {
|
|
16
|
-
type
|
|
17
|
-
} = props;
|
|
18
|
-
|
|
19
|
-
if (type === TabTypes.SUBTABS) {
|
|
20
|
-
return /*#__PURE__*/_jsx(DSTabsContext.Provider, {
|
|
21
|
-
value: ctx
|
|
22
|
-
}, void 0, _TabsContent || (_TabsContent = /*#__PURE__*/_jsx(TabsContent, {})));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return /*#__PURE__*/_jsx(DSTabsCrossRefContext.Provider, {
|
|
26
|
-
value: crossRefsCtx
|
|
27
|
-
}, void 0, /*#__PURE__*/_jsx(DSTabsContext.Provider, {
|
|
28
|
-
value: ctx
|
|
29
|
-
}, void 0, _TabsContent2 || (_TabsContent2 = /*#__PURE__*/_jsx(TabsContent, {}))));
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const DSTabsWithSchema = describe(DSTabs);
|
|
33
|
-
DSTabsWithSchema.propTypes = tabsPropTypes;
|
|
34
|
-
|
|
35
|
-
export { DSTabs, DSTabsWithSchema, DSTabs as default };
|
package/esm/DSTabsCTX.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createContext, createRef } from 'react';
|
|
2
|
-
import { tabsDefaultProps } from './defaultProps.js';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5
|
-
const noop = () => {};
|
|
6
|
-
|
|
7
|
-
const defaultContext = {
|
|
8
|
-
props: tabsDefaultProps,
|
|
9
|
-
tabsRef: /*#__PURE__*/createRef(),
|
|
10
|
-
tabsListRef: /*#__PURE__*/createRef(),
|
|
11
|
-
carouselOnlyListRef: /*#__PURE__*/createRef(),
|
|
12
|
-
focusableTabsRef: /*#__PURE__*/createRef(),
|
|
13
|
-
tabsRefAsArray: /*#__PURE__*/createRef(),
|
|
14
|
-
actualActiveTabRef: /*#__PURE__*/createRef(),
|
|
15
|
-
setInternalActiveTab: noop,
|
|
16
|
-
actualActiveTab: ''
|
|
17
|
-
};
|
|
18
|
-
const defaultCrossRefsContext = {
|
|
19
|
-
lastTabInternalRef: /*#__PURE__*/createRef(),
|
|
20
|
-
firstSubtabInternalRef: /*#__PURE__*/createRef()
|
|
21
|
-
};
|
|
22
|
-
const DSTabsContext = /*#__PURE__*/createContext(defaultContext);
|
|
23
|
-
const DSTabsCrossRefContext = /*#__PURE__*/createContext(defaultCrossRefsContext);
|
|
24
|
-
|
|
25
|
-
export { DSTabsContext, DSTabsCrossRefContext };
|
package/esm/DSTabsDatatestid.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const DSTabsDatatestid = {
|
|
2
|
-
TABS_CONTAINER: 'ds-tabs-container',
|
|
3
|
-
TAB_BUTTON: 'ds-tabs-tab-button',
|
|
4
|
-
SUBTAB_BUTTON: 'ds-tabs-subtab-button',
|
|
5
|
-
TAB_PANEL: 'ds-tabs-tab-panel',
|
|
6
|
-
SUB_TAB_LIST: 'subtabs-list',
|
|
7
|
-
TAB_LIST: 'tab-list',
|
|
8
|
-
CAROUSEL: {
|
|
9
|
-
BUTTON_RIGHT: 'chevron-right',
|
|
10
|
-
BUTTON_LEFT: 'chevron-left'
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { DSTabsDatatestid };
|
package/esm/DSTabsTypes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/esm/config/useTabs.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
-
import { useRef, useState, useMemo, useEffect } from 'react';
|
|
6
|
-
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
7
|
-
import { tabsDefaultProps } from '../defaultProps.js';
|
|
8
|
-
|
|
9
|
-
const useTabs = props => {
|
|
10
|
-
const propsWithDefaults = useMemoMergePropsWithDefault(props, tabsDefaultProps);
|
|
11
|
-
const {
|
|
12
|
-
activeTab
|
|
13
|
-
} = propsWithDefaults;
|
|
14
|
-
const tabsRef = useRef({});
|
|
15
|
-
const tabsRefAsArray = useRef([]);
|
|
16
|
-
const focusableTabsRef = useRef([]);
|
|
17
|
-
const carouselOnlyListRef = useRef(null);
|
|
18
|
-
const tabsListRef = useRef(null);
|
|
19
|
-
const actualActiveTabRef = useRef(null);
|
|
20
|
-
const [internalActiveTab, setInternalActiveTab] = useState('');
|
|
21
|
-
const actualActiveTab = useMemo(() => {
|
|
22
|
-
if (activeTab !== undefined) return activeTab;
|
|
23
|
-
return internalActiveTab;
|
|
24
|
-
}, [activeTab, internalActiveTab]);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
var _focusableTabsRef$cur;
|
|
27
|
-
|
|
28
|
-
actualActiveTabRef.current = (_focusableTabsRef$cur = focusableTabsRef.current.find(el => el.dataset.tabId === actualActiveTab)) !== null && _focusableTabsRef$cur !== void 0 ? _focusableTabsRef$cur : null;
|
|
29
|
-
}, [actualActiveTab]);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (activeTab === undefined) {
|
|
32
|
-
const firstAvailableTab = focusableTabsRef.current.find(el => el.ariaDisabled !== 'true');
|
|
33
|
-
setInternalActiveTab((firstAvailableTab === null || firstAvailableTab === void 0 ? void 0 : firstAvailableTab.dataset.tabId) || '');
|
|
34
|
-
}
|
|
35
|
-
}, [activeTab]);
|
|
36
|
-
const ctx = useMemo(() => ({
|
|
37
|
-
props: propsWithDefaults,
|
|
38
|
-
tabsRef,
|
|
39
|
-
focusableTabsRef,
|
|
40
|
-
tabsListRef,
|
|
41
|
-
tabsRefAsArray,
|
|
42
|
-
setInternalActiveTab,
|
|
43
|
-
actualActiveTab,
|
|
44
|
-
actualActiveTabRef,
|
|
45
|
-
carouselOnlyListRef
|
|
46
|
-
}), [actualActiveTab, propsWithDefaults]);
|
|
47
|
-
return ctx;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { useTabs };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { describe } from 'react-desc';
|
|
9
|
-
import { tabPropTypes } from '../propTypes.js';
|
|
10
|
-
import { jsx } from 'react/jsx-runtime';
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
|
-
const DSTab = props => /*#__PURE__*/jsx(React.Fragment, _objectSpread({}, props));
|
|
17
|
-
|
|
18
|
-
const DSTabWithSchema = describe(DSTab);
|
|
19
|
-
DSTabWithSchema.propTypes = tabPropTypes;
|
|
20
|
-
|
|
21
|
-
export { DSTab, DSTabWithSchema, DSTab as default };
|
package/esm/index.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import { useContext } from 'react';
|
|
3
|
-
import { DSIconSizes } from '@elliemae/ds-icon';
|
|
4
|
-
import { BUTTON_TYPES } from '@elliemae/ds-button';
|
|
5
|
-
import { ChevronLeft, ChevronRight } from '@elliemae/ds-icons';
|
|
6
|
-
import { StyledCarouselWrapper, StyledCarouselButtonWrapper, StyledCarouselBtn, StyledChildrenWrap } from './styles.js';
|
|
7
|
-
import { useCarousel } from './useCarousel.js';
|
|
8
|
-
import { DSTabsContext } from '../../DSTabsCTX.js';
|
|
9
|
-
import { DSTabsDatatestid } from '../../DSTabsDatatestid.js';
|
|
10
|
-
import { jsx } from 'react/jsx-runtime';
|
|
11
|
-
|
|
12
|
-
const Carousel = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
children,
|
|
15
|
-
updateIndicatorStyle
|
|
16
|
-
} = _ref;
|
|
17
|
-
const {
|
|
18
|
-
showChevrons,
|
|
19
|
-
leftButtonOnClick,
|
|
20
|
-
rightButtonOnClick,
|
|
21
|
-
handleOnClick,
|
|
22
|
-
handleOnScroll
|
|
23
|
-
} = useCarousel({
|
|
24
|
-
updateIndicatorStyle
|
|
25
|
-
});
|
|
26
|
-
const {
|
|
27
|
-
carouselOnlyListRef,
|
|
28
|
-
props: {
|
|
29
|
-
type
|
|
30
|
-
}
|
|
31
|
-
} = useContext(DSTabsContext);
|
|
32
|
-
return /*#__PURE__*/_jsx(StyledCarouselWrapper, {}, void 0, showChevrons.left && /*#__PURE__*/_jsx(StyledCarouselButtonWrapper, {
|
|
33
|
-
tabType: type
|
|
34
|
-
}, void 0, /*#__PURE__*/_jsx(StyledCarouselBtn, {
|
|
35
|
-
size: "s",
|
|
36
|
-
onClick: leftButtonOnClick,
|
|
37
|
-
tabIndex: -1,
|
|
38
|
-
"data-testid": DSTabsDatatestid.CAROUSEL.BUTTON_LEFT,
|
|
39
|
-
buttonType: BUTTON_TYPES.ICON
|
|
40
|
-
}, void 0, /*#__PURE__*/_jsx(ChevronLeft, {
|
|
41
|
-
size: DSIconSizes.S
|
|
42
|
-
}))), showChevrons.right && /*#__PURE__*/_jsx(StyledCarouselButtonWrapper, {
|
|
43
|
-
tabType: type,
|
|
44
|
-
right: showChevrons.right
|
|
45
|
-
}, void 0, /*#__PURE__*/_jsx(StyledCarouselBtn, {
|
|
46
|
-
size: "s",
|
|
47
|
-
onClick: rightButtonOnClick,
|
|
48
|
-
tabIndex: -1,
|
|
49
|
-
"data-testid": DSTabsDatatestid.CAROUSEL.BUTTON_RIGHT,
|
|
50
|
-
buttonType: BUTTON_TYPES.ICON
|
|
51
|
-
}, void 0, /*#__PURE__*/_jsx(ChevronRight, {
|
|
52
|
-
size: DSIconSizes.S
|
|
53
|
-
}))), /*#__PURE__*/jsx(StyledChildrenWrap, {
|
|
54
|
-
ref: carouselOnlyListRef,
|
|
55
|
-
onClick: handleOnClick,
|
|
56
|
-
onScroll: handleOnScroll,
|
|
57
|
-
children: children
|
|
58
|
-
}));
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export { Carousel };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { DSButtonV2 } from '@elliemae/ds-button';
|
|
3
|
-
import { TabTypes } from '../../utils/constants.js';
|
|
4
|
-
|
|
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
|
-
});
|
|
53
|
-
|
|
54
|
-
export { StyledCarouselBtn, StyledCarouselButtonWrapper, StyledCarouselWrapper, StyledChildrenWrap };
|
|
@@ -1,159 +0,0 @@
|
|
|
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 { centerTab } from '../../utils/helpers.js';
|
|
11
|
-
import { TabTypes } from '../../utils/constants.js';
|
|
12
|
-
import { useTabsCallbacks } from '../../utils/hooks/useTabsCallbacks.js';
|
|
13
|
-
import { DSTabsDatatestid } from '../../DSTabsDatatestid.js';
|
|
14
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
15
|
-
|
|
16
|
-
var _StyledRequiredMark;
|
|
17
|
-
const TabBar = () => {
|
|
18
|
-
const {
|
|
19
|
-
tabsRef,
|
|
20
|
-
focusableTabsRef,
|
|
21
|
-
tabsListRef,
|
|
22
|
-
tabsRefAsArray,
|
|
23
|
-
carouselOnlyListRef,
|
|
24
|
-
actualActiveTab,
|
|
25
|
-
props: {
|
|
26
|
-
type,
|
|
27
|
-
fixedTabsHeaders,
|
|
28
|
-
withCarousel,
|
|
29
|
-
isDSMobile,
|
|
30
|
-
showSeparator,
|
|
31
|
-
children: tabs
|
|
32
|
-
}
|
|
33
|
-
} = useContext(DSTabsContext);
|
|
34
|
-
const {
|
|
35
|
-
lastTabInternalRef,
|
|
36
|
-
firstSubtabInternalRef
|
|
37
|
-
} = useContext(DSTabsCrossRefContext);
|
|
38
|
-
const {
|
|
39
|
-
handleOnTabChange
|
|
40
|
-
} = useTabsCallbacks();
|
|
41
|
-
const {
|
|
42
|
-
handleOnKeyDown
|
|
43
|
-
} = useKeyboardNavigation();
|
|
44
|
-
const {
|
|
45
|
-
indicatorStyle,
|
|
46
|
-
mobileGradients,
|
|
47
|
-
updateMobileGradients,
|
|
48
|
-
updateIndicatorStyle
|
|
49
|
-
} = useTabBar();
|
|
50
|
-
const renderTabs = useMemo(() => {
|
|
51
|
-
const availableTabIndexes = [];
|
|
52
|
-
return React.Children.map(tabs, (tab, index) => {
|
|
53
|
-
const {
|
|
54
|
-
tabId = '',
|
|
55
|
-
title = '',
|
|
56
|
-
style,
|
|
57
|
-
required = false,
|
|
58
|
-
disabled = false,
|
|
59
|
-
ref,
|
|
60
|
-
onClick,
|
|
61
|
-
onKeyDown
|
|
62
|
-
} = tab.props;
|
|
63
|
-
if (!disabled) availableTabIndexes.push(index);
|
|
64
|
-
return /*#__PURE__*/jsxs(StyledTabButton, {
|
|
65
|
-
role: "tab",
|
|
66
|
-
ref: tabButtonRef => {
|
|
67
|
-
if (tabButtonRef && tabsRefAsArray.current && focusableTabsRef.current && tabsRef.current) {
|
|
68
|
-
tabsRefAsArray.current[index] = tabButtonRef;
|
|
69
|
-
if (!disabled && !focusableTabsRef.current.includes(tabButtonRef)) focusableTabsRef.current.push(tabButtonRef);
|
|
70
|
-
tabsRef.current[index] = tabButtonRef;
|
|
71
|
-
|
|
72
|
-
if (type === TabTypes.SUBTABS && firstSubtabInternalRef && index === availableTabIndexes[0]) {
|
|
73
|
-
firstSubtabInternalRef.current = tabButtonRef;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (type !== TabTypes.SUBTABS && index === availableTabIndexes[availableTabIndexes.length - 1]) {
|
|
77
|
-
lastTabInternalRef.current = tabButtonRef;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (ref) ref.current = tabButtonRef;
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
type: "button",
|
|
84
|
-
"aria-controls": tabId,
|
|
85
|
-
"aria-selected": actualActiveTab === tabId,
|
|
86
|
-
"aria-disabled": disabled,
|
|
87
|
-
"aria-labelledby": "".concat(tabId, "-label"),
|
|
88
|
-
isDSMobile: isDSMobile,
|
|
89
|
-
fixedTabsHeaders: fixedTabsHeaders,
|
|
90
|
-
tabType: type,
|
|
91
|
-
title: title,
|
|
92
|
-
"data-required": required,
|
|
93
|
-
"data-tab-id": tabId,
|
|
94
|
-
"data-index": index,
|
|
95
|
-
withCarousel: withCarousel,
|
|
96
|
-
isActive: actualActiveTab === tabId,
|
|
97
|
-
disabled: disabled,
|
|
98
|
-
showSeparator: showSeparator && type !== TabTypes.NORMAL,
|
|
99
|
-
"data-testid": type === TabTypes.NORMAL ? DSTabsDatatestid.TAB_BUTTON : DSTabsDatatestid.SUBTAB_BUTTON,
|
|
100
|
-
id: "".concat(tabId, "-label"),
|
|
101
|
-
onClick: e => {
|
|
102
|
-
if (!disabled) {
|
|
103
|
-
handleOnTabChange(tabId, e);
|
|
104
|
-
updateIndicatorStyle();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (onClick && !disabled) onClick(tabId, e);
|
|
108
|
-
},
|
|
109
|
-
onFocus: e => {
|
|
110
|
-
if (withCarousel) centerTab({
|
|
111
|
-
e,
|
|
112
|
-
listRef: carouselOnlyListRef
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
onKeyDown: e => {
|
|
116
|
-
if (e.key === 'Enter') e.stopPropagation();
|
|
117
|
-
if (!disabled) handleOnKeyDown(e);
|
|
118
|
-
if (onKeyDown && !disabled) onKeyDown(e);
|
|
119
|
-
},
|
|
120
|
-
style: style,
|
|
121
|
-
children: [title, required && (_StyledRequiredMark || (_StyledRequiredMark = /*#__PURE__*/_jsx(StyledRequiredMark, {}, void 0, "\u25CF")))]
|
|
122
|
-
}, tabId);
|
|
123
|
-
});
|
|
124
|
-
}, [tabs, actualActiveTab, isDSMobile, fixedTabsHeaders, type, withCarousel, showSeparator, tabsRefAsArray, focusableTabsRef, tabsRef, firstSubtabInternalRef, lastTabInternalRef, handleOnTabChange, updateIndicatorStyle, carouselOnlyListRef, handleOnKeyDown]);
|
|
125
|
-
|
|
126
|
-
if (type === TabTypes.SUBTABS && !isDSMobile) {
|
|
127
|
-
return /*#__PURE__*/jsx(StyledSubTabsList, {
|
|
128
|
-
withCarousel: withCarousel,
|
|
129
|
-
"data-testid": DSTabsDatatestid.SUB_TAB_LIST,
|
|
130
|
-
ref: tabsListRef,
|
|
131
|
-
role: "tablist",
|
|
132
|
-
children: withCarousel ? /*#__PURE__*/_jsx(Carousel, {}, void 0, renderTabs) : renderTabs
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return /*#__PURE__*/jsxs(StyledTabList, {
|
|
137
|
-
withCarousel: withCarousel,
|
|
138
|
-
ref: tabsListRef,
|
|
139
|
-
role: "tablist",
|
|
140
|
-
"data-testid": DSTabsDatatestid.TAB_LIST,
|
|
141
|
-
isDSMobile: isDSMobile,
|
|
142
|
-
fixedTabsHeaders: fixedTabsHeaders,
|
|
143
|
-
mobileGradients: mobileGradients,
|
|
144
|
-
onScroll: updateMobileGradients,
|
|
145
|
-
indicatorStyle: indicatorStyle,
|
|
146
|
-
tabType: type,
|
|
147
|
-
children: [/*#__PURE__*/_jsx(StyledTabWrapper, {
|
|
148
|
-
isDSMobile: isDSMobile,
|
|
149
|
-
fixedTabsHeaders: fixedTabsHeaders
|
|
150
|
-
}, void 0, !isDSMobile && withCarousel ? /*#__PURE__*/_jsx(Carousel, {
|
|
151
|
-
updateIndicatorStyle: updateIndicatorStyle
|
|
152
|
-
}, void 0, renderTabs) : renderTabs), /*#__PURE__*/_jsx(StyledSelectionIndicator, {
|
|
153
|
-
isDSMobile: isDSMobile,
|
|
154
|
-
tabType: type
|
|
155
|
-
})]
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export { TabBar };
|