@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.
Files changed (102) hide show
  1. package/cjs/DSTabs.js +40 -58
  2. package/cjs/DSTabsCTX.js +25 -51
  3. package/cjs/DSTabsDatatestid.js +14 -42
  4. package/cjs/DSTabsTypes.js +2 -27
  5. package/cjs/config/useCrossRef.js +11 -38
  6. package/cjs/config/useTabs.js +36 -53
  7. package/cjs/defaultProps.js +13 -39
  8. package/cjs/exportsRelated/DSTab.js +32 -46
  9. package/cjs/index.js +17 -38
  10. package/cjs/parts/carousel/Carousel.js +53 -61
  11. package/cjs/parts/carousel/styles.js +63 -77
  12. package/cjs/parts/carousel/useCarousel.js +49 -51
  13. package/cjs/parts/carousel/useCarouselCallbacks.js +36 -53
  14. package/cjs/parts/tabBar/TabBar.js +120 -124
  15. package/cjs/parts/tabBar/styles.js +195 -289
  16. package/cjs/parts/tabBar/useTabBar.js +55 -67
  17. package/cjs/parts/tabsContent/TabsContent.js +45 -49
  18. package/cjs/parts/tabsContent/styles.js +15 -39
  19. package/cjs/parts/tabsPanel/TabsPanels.js +58 -60
  20. package/cjs/parts/tabsPanel/styles.js +23 -43
  21. package/cjs/propTypes.js +29 -54
  22. package/cjs/utils/constants.js +16 -44
  23. package/cjs/utils/helpers.js +22 -46
  24. package/cjs/utils/hooks/useKeyboardNavigation.js +43 -59
  25. package/cjs/utils/hooks/useTabsCallbacks.js +33 -49
  26. package/esm/DSTabs.js +25 -24
  27. package/esm/DSTabsCTX.js +20 -22
  28. package/esm/DSTabsDatatestid.js +10 -13
  29. package/esm/DSTabsTypes.js +1 -2
  30. package/esm/config/useCrossRef.js +4 -6
  31. package/esm/config/useTabs.js +22 -14
  32. package/esm/defaultProps.js +8 -9
  33. package/esm/exportsRelated/DSTab.js +19 -15
  34. package/esm/index.js +4 -9
  35. package/esm/parts/carousel/Carousel.js +38 -25
  36. package/esm/parts/carousel/styles.js +52 -48
  37. package/esm/parts/carousel/useCarousel.js +34 -15
  38. package/esm/parts/carousel/useCarouselCallbacks.js +28 -20
  39. package/esm/parts/tabBar/TabBar.js +102 -93
  40. package/esm/parts/tabBar/styles.js +183 -262
  41. package/esm/parts/tabBar/useTabBar.js +36 -27
  42. package/esm/parts/tabsContent/TabsContent.js +35 -19
  43. package/esm/parts/tabsContent/styles.js +7 -10
  44. package/esm/parts/tabsPanel/TabsPanels.js +45 -28
  45. package/esm/parts/tabsPanel/styles.js +15 -14
  46. package/esm/propTypes.js +24 -25
  47. package/esm/utils/constants.js +8 -15
  48. package/esm/utils/helpers.js +11 -16
  49. package/esm/utils/hooks/useKeyboardNavigation.js +39 -30
  50. package/esm/utils/hooks/useTabsCallbacks.js +27 -18
  51. package/package.json +6 -6
  52. package/types/DSTabs.d.ts +2 -2
  53. package/cjs/DSTabs.js.map +0 -7
  54. package/cjs/DSTabsCTX.js.map +0 -7
  55. package/cjs/DSTabsDatatestid.js.map +0 -7
  56. package/cjs/DSTabsTypes.js.map +0 -7
  57. package/cjs/config/useCrossRef.js.map +0 -7
  58. package/cjs/config/useTabs.js.map +0 -7
  59. package/cjs/defaultProps.js.map +0 -7
  60. package/cjs/exportsRelated/DSTab.js.map +0 -7
  61. package/cjs/index.js.map +0 -7
  62. package/cjs/parts/carousel/Carousel.js.map +0 -7
  63. package/cjs/parts/carousel/styles.js.map +0 -7
  64. package/cjs/parts/carousel/useCarousel.js.map +0 -7
  65. package/cjs/parts/carousel/useCarouselCallbacks.js.map +0 -7
  66. package/cjs/parts/tabBar/TabBar.js.map +0 -7
  67. package/cjs/parts/tabBar/styles.js.map +0 -7
  68. package/cjs/parts/tabBar/useTabBar.js.map +0 -7
  69. package/cjs/parts/tabsContent/TabsContent.js.map +0 -7
  70. package/cjs/parts/tabsContent/styles.js.map +0 -7
  71. package/cjs/parts/tabsPanel/TabsPanels.js.map +0 -7
  72. package/cjs/parts/tabsPanel/styles.js.map +0 -7
  73. package/cjs/propTypes.js.map +0 -7
  74. package/cjs/utils/constants.js.map +0 -7
  75. package/cjs/utils/helpers.js.map +0 -7
  76. package/cjs/utils/hooks/useKeyboardNavigation.js.map +0 -7
  77. package/cjs/utils/hooks/useTabsCallbacks.js.map +0 -7
  78. package/esm/DSTabs.js.map +0 -7
  79. package/esm/DSTabsCTX.js.map +0 -7
  80. package/esm/DSTabsDatatestid.js.map +0 -7
  81. package/esm/DSTabsTypes.js.map +0 -7
  82. package/esm/config/useCrossRef.js.map +0 -7
  83. package/esm/config/useTabs.js.map +0 -7
  84. package/esm/defaultProps.js.map +0 -7
  85. package/esm/exportsRelated/DSTab.js.map +0 -7
  86. package/esm/index.js.map +0 -7
  87. package/esm/parts/carousel/Carousel.js.map +0 -7
  88. package/esm/parts/carousel/styles.js.map +0 -7
  89. package/esm/parts/carousel/useCarousel.js.map +0 -7
  90. package/esm/parts/carousel/useCarouselCallbacks.js.map +0 -7
  91. package/esm/parts/tabBar/TabBar.js.map +0 -7
  92. package/esm/parts/tabBar/styles.js.map +0 -7
  93. package/esm/parts/tabBar/useTabBar.js.map +0 -7
  94. package/esm/parts/tabsContent/TabsContent.js.map +0 -7
  95. package/esm/parts/tabsContent/styles.js.map +0 -7
  96. package/esm/parts/tabsPanel/TabsPanels.js.map +0 -7
  97. package/esm/parts/tabsPanel/styles.js.map +0 -7
  98. package/esm/propTypes.js.map +0 -7
  99. package/esm/utils/constants.js.map +0 -7
  100. package/esm/utils/helpers.js.map +0 -7
  101. package/esm/utils/hooks/useKeyboardNavigation.js.map +0 -7
  102. package/esm/utils/hooks/useTabsCallbacks.js.map +0 -7
@@ -1,50 +1,67 @@
1
- import * as React from "react";
2
- import React2, { useMemo, useContext, useCallback } from "react";
3
- import SwipeableViews from "react-swipeable-views";
4
- import { getIdByIndex, getIndexById } from "../../utils/helpers";
5
- import { StyledPanelContainer } from "./styles";
6
- import { DSTabsContext } from "../../DSTabsCTX";
7
- import { useTabsCallbacks } from "../../utils/hooks/useTabsCallbacks";
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, useCallback, useMemo } from 'react';
5
+ import SwipeableViews from 'react-swipeable-views';
6
+ import { getIdByIndex, getIndexById } from '../../utils/helpers.js';
7
+ import { StyledPanelContainer } from './styles.js';
8
+ import { DSTabsContext } from '../../DSTabsCTX.js';
9
+ import { useTabsCallbacks } from '../../utils/hooks/useTabsCallbacks.js';
10
+ import { jsx, Fragment } from 'react/jsx-runtime';
11
+
8
12
  const TabsPanels = () => {
9
13
  const {
10
14
  actualActiveTab,
11
15
  focusableTabsRef,
12
- props: { animated, enableMouseEvents, onlyRenderActiveTab, children: tabs, isDSMobile }
16
+ props: {
17
+ animated,
18
+ enableMouseEvents,
19
+ onlyRenderActiveTab,
20
+ children: tabs,
21
+ isDSMobile
22
+ }
13
23
  } = useContext(DSTabsContext);
14
- const { handleOnTabChange, handleOnMouseDown } = useTabsCallbacks();
15
- const handleOnChangeIndex = useCallback((index) => {
24
+ const {
25
+ handleOnTabChange,
26
+ handleOnMouseDown
27
+ } = useTabsCallbacks();
28
+ const handleOnChangeIndex = useCallback(index => {
16
29
  handleOnTabChange(getIdByIndex(tabs, index));
17
- if (focusableTabsRef.current)
18
- focusableTabsRef.current[index].click();
30
+ if (focusableTabsRef.current) focusableTabsRef.current[index].click();
19
31
  }, [focusableTabsRef, handleOnTabChange, tabs]);
20
- const panels = useMemo(() => React2.Children.map(tabs, (tab) => {
21
- const { tabId: panelId = "", style, children: content } = tab.props;
32
+ const panels = useMemo(() => React.Children.map(tabs, tab => {
33
+ const {
34
+ tabId: panelId = '',
35
+ style,
36
+ children: content
37
+ } = tab.props;
22
38
  const isActive = actualActiveTab === panelId;
23
39
  const shouldRender = !onlyRenderActiveTab || isActive;
24
- return shouldRender && /* @__PURE__ */ React2.createElement(StyledPanelContainer, {
25
- key: panelId,
40
+ return shouldRender && /*#__PURE__*/_jsx(StyledPanelContainer, {
26
41
  id: panelId,
27
- "aria-labelledby": `${panelId}-label`,
42
+ "aria-labelledby": "".concat(panelId, "-label"),
28
43
  "aria-hidden": !isActive,
29
44
  "data-panel-id": panelId,
30
45
  "data-testid": "ds-tabs-tab-panel",
31
46
  hidden: !isActive,
32
47
  onMouseDown: handleOnMouseDown,
33
48
  role: "tabpanel",
34
- style,
35
- isDSMobile
36
- }, content);
49
+ style: style,
50
+ isDSMobile: isDSMobile
51
+ }, panelId, content);
37
52
  }), [actualActiveTab, handleOnMouseDown, isDSMobile, onlyRenderActiveTab, tabs]);
53
+
38
54
  if (animated) {
39
- return /* @__PURE__ */ React2.createElement(SwipeableViews, {
40
- enableMouseEvents,
55
+ return /*#__PURE__*/_jsx(SwipeableViews, {
56
+ enableMouseEvents: enableMouseEvents,
41
57
  index: getIndexById(tabs, actualActiveTab),
42
58
  onChangeIndex: handleOnChangeIndex
43
- }, panels);
59
+ }, void 0, panels);
44
60
  }
45
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, panels);
46
- };
47
- export {
48
- TabsPanels
61
+
62
+ return /*#__PURE__*/jsx(Fragment, {
63
+ children: panels
64
+ });
49
65
  };
50
- //# sourceMappingURL=TabsPanels.js.map
66
+
67
+ export { TabsPanels };
@@ -1,16 +1,17 @@
1
- import * as React from "react";
2
- import styled from "styled-components";
3
- const StyledPanelContainer = styled.div`
4
- padding-top: 8px;
5
- &:focus {
6
- outline: none;
7
- }
1
+ import styled from 'styled-components';
8
2
 
9
- ${({ hidden }) => hidden ? "visibility: hidden;" : ""}
3
+ const StyledPanelContainer = /*#__PURE__*/styled.div.withConfig({
4
+ componentId: "sc-oxw5jq-0"
5
+ })(["padding-top:8px;&:focus{outline:none;}", " ", ""], _ref => {
6
+ let {
7
+ hidden
8
+ } = _ref;
9
+ return hidden ? 'visibility: hidden;' : '';
10
+ }, _ref2 => {
11
+ let {
12
+ isDSMobile
13
+ } = _ref2;
14
+ return isDSMobile ? "padding-top: 0;" : "";
15
+ });
10
16
 
11
- ${({ isDSMobile }) => isDSMobile ? `padding-top: 0;` : ``}
12
- `;
13
- export {
14
- StyledPanelContainer
15
- };
16
- //# sourceMappingURL=styles.js.map
17
+ export { StyledPanelContainer };
package/esm/propTypes.js CHANGED
@@ -1,29 +1,28 @@
1
- import * as React from "react";
2
- import { PropTypes } from "react-desc";
3
- import { TabTypesValuesAsArray } from "./utils/constants";
1
+ import { PropTypes } from 'react-desc';
2
+ import { TabTypesValuesAsArray } from './utils/constants.js';
3
+
4
4
  const tabPropTypes = {
5
- tabId: PropTypes.string.description("Unique Tab id.").defaultValue(""),
6
- title: PropTypes.string.description("Tab title.").defaultValue(""),
7
- required: PropTypes.bool.description("Show a required mark next to the title.").defaultValue(false),
8
- disabled: PropTypes.bool.description("Disables Tab.").defaultValue(false)
5
+ tabId: PropTypes.string.description('Unique Tab id.').defaultValue(''),
6
+ title: PropTypes.string.description('Tab title.').defaultValue(''),
7
+ required: PropTypes.bool.description('Show a required mark next to the title.').defaultValue(false),
8
+ disabled: PropTypes.bool.description('Disables Tab.').defaultValue(false)
9
9
  };
10
10
  const tabsPropTypes = {
11
- animated: PropTypes.bool.description("Whether the Tab transition should animate or not.").defaultValue(true),
12
- enableMouseEvents: PropTypes.bool.description("Enables Tab transition with mouse drag events.").defaultValue(false),
13
- allowTextSelection: PropTypes.bool.description("Allows text selection when mouse drag events are active.").defaultValue(false),
14
- onTabChange: PropTypes.func.description("Handler when a user clicks on a different Tab.").defaultValue("() => {}"),
15
- type: PropTypes.oneOf(TabTypesValuesAsArray).description("Tab type.").defaultValue(TabTypesValuesAsArray[0]),
16
- tabBarExtraContent: PropTypes.element.description("Extra content next to the Tab Bar.").defaultValue(void 0),
17
- onlyRenderActiveTab: PropTypes.bool.description("Only renders the active Tab in the DOM.").defaultValue(false),
18
- withCarousel: PropTypes.bool.description("Activate carousel behavior.").defaultValue(false),
19
- activeTab: PropTypes.string.description("Passing a value makes DSTabs a controlled component.").defaultValue("First DSTab children."),
20
- children: PropTypes.node.description("Use DSTab component as children.").isRequired,
21
- tabsListAriaLabel: PropTypes.string.description("Aria label for the list.").defaultValue("Tab list."),
22
- containerProps: PropTypes.object.description("Additional properties for the container.").defaultValue({}),
23
- innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description("Ref to the container.").defaultValue(void 0)
11
+ animated: PropTypes.bool.description('Whether the Tab transition should animate or not.').defaultValue(true),
12
+ enableMouseEvents: PropTypes.bool.description('Enables Tab transition with mouse drag events.').defaultValue(false),
13
+ allowTextSelection: PropTypes.bool.description('Allows text selection when mouse drag events are active.').defaultValue(false),
14
+ onTabChange: PropTypes.func.description('Handler when a user clicks on a different Tab.').defaultValue('() => {}'),
15
+ type: PropTypes.oneOf(TabTypesValuesAsArray).description('Tab type.').defaultValue(TabTypesValuesAsArray[0]),
16
+ tabBarExtraContent: PropTypes.element.description('Extra content next to the Tab Bar.').defaultValue(undefined),
17
+ onlyRenderActiveTab: PropTypes.bool.description('Only renders the active Tab in the DOM.').defaultValue(false),
18
+ withCarousel: PropTypes.bool.description('Activate carousel behavior.').defaultValue(false),
19
+ activeTab: PropTypes.string.description('Passing a value makes DSTabs a controlled component.').defaultValue('First DSTab children.'),
20
+ children: PropTypes.node.description('Use DSTab component as children.').isRequired,
21
+ tabsListAriaLabel: PropTypes.string.description('Aria label for the list.').defaultValue('Tab list.'),
22
+ containerProps: PropTypes.object.description('Additional properties for the container.').defaultValue({}),
23
+ innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
24
+ current: PropTypes.any
25
+ })]).description('Ref to the container.').defaultValue(undefined)
24
26
  };
25
- export {
26
- tabPropTypes,
27
- tabsPropTypes
28
- };
29
- //# sourceMappingURL=propTypes.js.map
27
+
28
+ export { tabPropTypes, tabsPropTypes };
@@ -1,15 +1,14 @@
1
- import * as React from "react";
2
1
  const TabTypes = {
3
- NORMAL: "normal",
4
- NORMAL_SMALL: "normal_small",
5
- SUBTABS: "subtabs"
2
+ NORMAL: 'normal',
3
+ NORMAL_SMALL: 'normal_small',
4
+ SUBTABS: 'subtabs'
6
5
  };
7
6
  const TabTypesValuesAsArray = Object.values(TabTypes);
8
7
  const MOBILE_GRADIENT_WIDTH = 24;
9
8
  const defaultIndicatorStyles = {
10
- left: "0px",
11
- width: "0px",
12
- backgroundWithTransparent: ""
9
+ left: '0px',
10
+ width: '0px',
11
+ backgroundWithTransparent: ''
13
12
  };
14
13
  const gradientOffsetsAccordingType = {
15
14
  normal_small: 14,
@@ -17,11 +16,5 @@ const gradientOffsetsAccordingType = {
17
16
  subtabs: 16,
18
17
  fixedTabsHeaders: 0
19
18
  };
20
- export {
21
- MOBILE_GRADIENT_WIDTH,
22
- TabTypes,
23
- TabTypesValuesAsArray,
24
- defaultIndicatorStyles,
25
- gradientOffsetsAccordingType
26
- };
27
- //# sourceMappingURL=constants.js.map
19
+
20
+ export { MOBILE_GRADIENT_WIDTH, TabTypes, TabTypesValuesAsArray, defaultIndicatorStyles, gradientOffsetsAccordingType };
@@ -1,11 +1,13 @@
1
- import * as React from "react";
2
- import { MOBILE_GRADIENT_WIDTH } from "./constants";
1
+ import { MOBILE_GRADIENT_WIDTH } from './constants.js';
2
+
3
3
  const isElementVisible = (tab, tabList) => {
4
4
  const tabDimensions = tab.getBoundingClientRect();
5
5
  const tabListDimensions = tabList.getBoundingClientRect();
6
6
  return tabDimensions.left <= tabListDimensions.left ? tabListDimensions.left - tabDimensions.left <= tabDimensions.width : tabDimensions.right - tabListDimensions.right <= tabDimensions.width;
7
7
  };
8
- const isElementVisibleCarousel = (tab, tabContainer, firstOrLastItem = true) => {
8
+ const isElementVisibleCarousel = function (tab, tabContainer) {
9
+ let firstOrLastItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
10
+
9
11
  if (tab && tabContainer) {
10
12
  const tabDimensions = tab.getBoundingClientRect();
11
13
  const tabContainerDimensions = tabContainer.getBoundingClientRect();
@@ -16,6 +18,7 @@ const isElementVisibleCarousel = (tab, tabContainer, firstOrLastItem = true) =>
16
18
  const tabContainerDimensionsRight = Math.floor(tabContainerDimensions.right);
17
19
  return tabDimensionsLeft >= tabContainerDimensionsLeft && tabDimensionsRight <= tabContainerDimensionsRight;
18
20
  }
21
+
19
22
  return false;
20
23
  };
21
24
  const getVisibleDimensions = (node, referenceNode) => {
@@ -26,17 +29,9 @@ const getVisibleDimensions = (node, referenceNode) => {
26
29
  height: Math.min(node.clientHeight, referenceNodeDimensions.top + referenceNode.clientHeight - nodeDimensions.top, node.clientHeight - (referenceNodeDimensions.top - nodeDimensions.top))
27
30
  };
28
31
  };
29
- const getIndexById = (children, activeId) => children && children.findIndex((item) => item.props.tabId === activeId);
30
- const getIdByIndex = (children, index) => children && children[index].props.tabId || "";
31
- const shouldHaveLeftGradient = (scrollLeft) => Math.abs(scrollLeft) > MOBILE_GRADIENT_WIDTH;
32
+ const getIndexById = (children, activeId) => children && children.findIndex(item => item.props.tabId === activeId);
33
+ const getIdByIndex = (children, index) => children && children[index].props.tabId || '';
34
+ const shouldHaveLeftGradient = scrollLeft => Math.abs(scrollLeft) > MOBILE_GRADIENT_WIDTH;
32
35
  const shouldHaveRightGradient = (scrollLeft, clientWidth, scrollWidth) => Math.abs(scrollLeft) <= scrollWidth - (clientWidth + MOBILE_GRADIENT_WIDTH);
33
- export {
34
- getIdByIndex,
35
- getIndexById,
36
- getVisibleDimensions,
37
- isElementVisible,
38
- isElementVisibleCarousel,
39
- shouldHaveLeftGradient,
40
- shouldHaveRightGradient
41
- };
42
- //# sourceMappingURL=helpers.js.map
36
+
37
+ export { getIdByIndex, getIndexById, getVisibleDimensions, isElementVisible, isElementVisibleCarousel, shouldHaveLeftGradient, shouldHaveRightGradient };
@@ -1,48 +1,57 @@
1
- import * as React from "react";
2
- import { useCallback, useContext } from "react";
3
- import { DSTabsContext, DSTabsCrossRefContext } from "../../DSTabsCTX";
1
+ import { useContext, useCallback } from 'react';
2
+ import { DSTabsContext, DSTabsCrossRefContext } from '../../DSTabsCTX.js';
3
+
4
+ /* eslint-disable max-statements */
4
5
  const useKeyboardNavigation = () => {
5
- const { focusableTabsRef } = useContext(DSTabsContext);
6
- const { firstSubtabInternalRef, lastTabInternalRef } = useContext(DSTabsCrossRefContext);
7
- const handleOnKeyDown = useCallback((e) => {
8
- if (e.key === "ArrowRight" && focusableTabsRef.current) {
6
+ const {
7
+ focusableTabsRef
8
+ } = useContext(DSTabsContext);
9
+ const {
10
+ firstSubtabInternalRef,
11
+ lastTabInternalRef
12
+ } = useContext(DSTabsCrossRefContext);
13
+ const handleOnKeyDown = useCallback(e => {
14
+ if (e.key === 'ArrowRight' && focusableTabsRef.current) {
15
+ var _focusableTabsRef$cur, _focusableTabsRef$cur2;
16
+
9
17
  e.preventDefault();
10
18
  e.stopPropagation();
11
- const nextTab = focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target) + 1];
12
- if (nextTab)
13
- nextTab.focus();
14
- if (!nextTab)
15
- return;
19
+ 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];
20
+ if (nextTab) nextTab.focus();
21
+ if (!nextTab) return;
16
22
  }
17
- if (e.key === "ArrowLeft" && focusableTabsRef.current) {
23
+
24
+ if (e.key === 'ArrowLeft' && focusableTabsRef.current) {
25
+ var _focusableTabsRef$cur3, _focusableTabsRef$cur4;
26
+
18
27
  e.preventDefault();
19
28
  e.stopPropagation();
20
- const prevTab = focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target) - 1];
21
- if (prevTab)
22
- prevTab.focus();
23
- if (!prevTab)
24
- return;
29
+ 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];
30
+ if (prevTab) prevTab.focus();
31
+ if (!prevTab) return;
25
32
  }
26
- if (e.key === "ArrowDown") {
33
+
34
+ if (e.key === 'ArrowDown') {
35
+ var _firstSubtabInternalR;
36
+
27
37
  e.preventDefault();
28
38
  e.stopPropagation();
29
- const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;
30
- if (canFocusCrossTabs)
31
- firstSubtabInternalRef.current?.focus();
39
+ const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
40
+ if (canFocusCrossTabs) (_firstSubtabInternalR = firstSubtabInternalRef.current) === null || _firstSubtabInternalR === void 0 ? void 0 : _firstSubtabInternalR.focus();
32
41
  }
33
- if (e.key === "ArrowUp") {
42
+
43
+ if (e.key === 'ArrowUp') {
44
+ var _lastTabInternalRef$c;
45
+
34
46
  e.preventDefault();
35
47
  e.stopPropagation();
36
- const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;
37
- if (canFocusCrossTabs)
38
- lastTabInternalRef.current?.focus();
48
+ const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
49
+ if (canFocusCrossTabs) (_lastTabInternalRef$c = lastTabInternalRef.current) === null || _lastTabInternalRef$c === void 0 ? void 0 : _lastTabInternalRef$c.focus();
39
50
  }
40
51
  }, [firstSubtabInternalRef, lastTabInternalRef, focusableTabsRef]);
41
52
  return {
42
53
  handleOnKeyDown
43
54
  };
44
55
  };
45
- export {
46
- useKeyboardNavigation
47
- };
48
- //# sourceMappingURL=useKeyboardNavigation.js.map
56
+
57
+ export { useKeyboardNavigation };
@@ -1,46 +1,55 @@
1
- import * as React from "react";
2
- import { useCallback, useContext } from "react";
3
- import { DSTabsContext } from "../../DSTabsCTX";
1
+ import { useContext, useCallback } from 'react';
2
+ import { DSTabsContext } from '../../DSTabsCTX.js';
3
+
4
4
  const useTabsCallbacks = () => {
5
5
  const {
6
6
  setInternalActiveTab,
7
7
  tabsListRef,
8
- props: { onTabChange, isDSMobile, allowTextSelection, fixedTabsHeaders }
8
+ props: {
9
+ onTabChange,
10
+ isDSMobile,
11
+ allowTextSelection,
12
+ fixedTabsHeaders
13
+ }
9
14
  } = useContext(DSTabsContext);
10
- const centerTabWhenTabChangeMobile = useCallback((e) => {
15
+ const centerTabWhenTabChangeMobile = useCallback(e => {
11
16
  if (tabsListRef.current) {
12
- const { offsetLeft } = e?.target;
13
- const { width: tabWidth } = (e?.target).getBoundingClientRect();
14
- const { width: listWidth } = tabsListRef.current.getBoundingClientRect();
17
+ const {
18
+ offsetLeft
19
+ } = e === null || e === void 0 ? void 0 : e.target;
20
+ const {
21
+ width: tabWidth
22
+ } = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
23
+ const {
24
+ width: listWidth
25
+ } = tabsListRef.current.getBoundingClientRect();
15
26
  const extraSideSpace = listWidth - tabWidth;
16
27
  const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
17
28
  const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
18
29
  tabsListRef.current.scrollTo({
19
30
  top: 0,
20
31
  left: centeredLeftOffset,
21
- behavior: "smooth"
32
+ behavior: 'smooth'
22
33
  });
23
- e?.preventDefault();
34
+ e === null || e === void 0 ? void 0 : e.preventDefault();
24
35
  }
25
36
  }, [tabsListRef]);
26
37
  const handleOnTabChange = useCallback((tabId, e) => {
27
38
  setInternalActiveTab(tabId);
28
39
  onTabChange(tabId, e);
40
+
29
41
  if (isDSMobile && !fixedTabsHeaders && e) {
30
42
  centerTabWhenTabChangeMobile(e);
31
43
  }
32
44
  }, [centerTabWhenTabChangeMobile, fixedTabsHeaders, isDSMobile, onTabChange, setInternalActiveTab]);
33
- const handleOnMouseDown = useCallback((e) => {
34
- const role = e.target.getAttribute("role");
35
- if (role !== "tabpanel" && allowTextSelection)
36
- e.stopPropagation();
45
+ const handleOnMouseDown = useCallback(e => {
46
+ const role = e.target.getAttribute('role');
47
+ if (role !== 'tabpanel' && allowTextSelection) e.stopPropagation();
37
48
  }, [allowTextSelection]);
38
49
  return {
39
50
  handleOnTabChange,
40
51
  handleOnMouseDown
41
52
  };
42
53
  };
43
- export {
44
- useTabsCallbacks
45
- };
46
- //# sourceMappingURL=useTabsCallbacks.js.map
54
+
55
+ export { useTabsCallbacks };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-tabs",
3
- "version": "2.2.0-alpha.2",
3
+ "version": "2.2.0-beta.0",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Tabs",
6
6
  "module": "./esm/index.js",
@@ -128,11 +128,11 @@
128
128
  "build": "node ../../scripts/build/build.js"
129
129
  },
130
130
  "dependencies": {
131
- "@elliemae/ds-button": "2.2.0-alpha.2",
132
- "@elliemae/ds-icon": "2.2.0-alpha.2",
133
- "@elliemae/ds-icons": "2.2.0-alpha.2",
134
- "@elliemae/ds-props-helpers": "2.2.0-alpha.2",
135
- "@elliemae/ds-system": "2.2.0-alpha.2",
131
+ "@elliemae/ds-button": "2.2.0-beta.0",
132
+ "@elliemae/ds-icon": "2.2.0-beta.0",
133
+ "@elliemae/ds-icons": "2.2.0-beta.0",
134
+ "@elliemae/ds-props-helpers": "2.2.0-beta.0",
135
+ "@elliemae/ds-system": "2.2.0-beta.0",
136
136
  "@react-hook/resize-observer": "~1.2.5",
137
137
  "prop-types": "~15.7.2",
138
138
  "react-desc": "~4.1.3",
package/types/DSTabs.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /// <reference path="../../../../shared/typings/react-desc.d.ts" />
2
- import React from 'react';
2
+ import type { WeakValidationMap } from 'react';
3
3
  import type { DSTabsPropsT } from './DSTabsTypes';
4
4
  declare const DSTabs: {
5
5
  (props: DSTabsPropsT): JSX.Element;
6
- propTypes: React.WeakValidationMap<unknown>;
6
+ propTypes: WeakValidationMap<unknown>;
7
7
  };
8
8
  declare const DSTabsWithSchema: {
9
9
  (props?: DSTabsPropsT | undefined): JSX.Element;
package/cjs/DSTabs.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/DSTabs.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { describe } from 'react-desc';\nimport { tabsPropTypes } from './propTypes';\nimport { DSTabsContext, DSTabsCrossRefContext } from './DSTabsCTX';\nimport { TabsContent } from './parts/tabsContent/TabsContent';\nimport { useTabs } from './config/useTabs';\nimport { useCrossRef } from './config/useCrossRef';\nimport { TabTypes } from './utils/constants';\nimport type { DSTabsPropsT } from './DSTabsTypes';\n\nconst DSTabs = (props: DSTabsPropsT): JSX.Element => {\n const ctx = useTabs(props);\n const crossRefsCtx = useCrossRef();\n\n const { type } = props;\n\n if (type === TabTypes.SUBTABS) {\n return (\n <DSTabsContext.Provider value={ctx}>\n <TabsContent />\n </DSTabsContext.Provider>\n );\n }\n\n return (\n <DSTabsCrossRefContext.Provider value={crossRefsCtx}>\n <DSTabsContext.Provider value={ctx}>\n <TabsContent />\n </DSTabsContext.Provider>\n </DSTabsCrossRefContext.Provider>\n );\n};\n\nDSTabs.propTypes = tabsPropTypes as WeakValidationMap<unknown>;\nconst DSTabsWithSchema = describe<DSTabsPropsT>(DSTabs);\nDSTabsWithSchema.propTypes = tabsPropTypes;\n\nexport { DSTabs, DSTabsWithSchema };\nexport default DSTabs;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAElB,wBAAyB;AACzB,uBAA8B;AAC9B,uBAAqD;AACrD,yBAA4B;AAC5B,qBAAwB;AACxB,yBAA4B;AAC5B,uBAAyB;AAGzB,MAAM,SAAS,CAAC,UAAqC;AACnD,QAAM,MAAM,4BAAQ;AACpB,QAAM,eAAe;AAErB,QAAM,EAAE,SAAS;AAEjB,MAAI,SAAS,0BAAS,SAAS;AAC7B,WACE,mDAAC,+BAAc,UAAf;AAAA,MAAwB,OAAO;AAAA,OAC7B,mDAAC,gCAAD;AAAA;AAKN,SACE,mDAAC,uCAAsB,UAAvB;AAAA,IAAgC,OAAO;AAAA,KACrC,mDAAC,+BAAc,UAAf;AAAA,IAAwB,OAAO;AAAA,KAC7B,mDAAC,gCAAD;AAAA;AAMR,OAAO,YAAY;AACnB,MAAM,mBAAmB,gCAAuB;AAChD,iBAAiB,YAAY;AAG7B,IAAO,iBAAQ;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/DSTabsCTX.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { createContext, createRef } from 'react';\nimport { tabsDefaultProps as defaultProps } from './defaultProps';\nimport type { DSTabsUseCrossRefContextT, DSTabsUseTabsContextT } from './DSTabsTypes';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\nconst defaultContext = {\n props: defaultProps,\n tabsRef: createRef<Record<number, HTMLButtonElement> | null>(),\n tabsListRef: createRef<HTMLDivElement | null>(),\n carouselOnlyListRef: createRef<HTMLDivElement | null>(),\n focusableTabsRef: createRef<HTMLButtonElement[] | null>(),\n tabsRefAsArray: createRef<HTMLButtonElement[] | null>(),\n actualActiveTabRef: createRef<HTMLButtonElement | null>(),\n setInternalActiveTab: noop,\n actualActiveTab: '',\n};\n\nconst defaultCrossRefsContext = {\n lastTabInternalRef: createRef<HTMLButtonElement | null>(),\n firstSubtabInternalRef: createRef<HTMLButtonElement | null>(),\n};\n\nexport const DSTabsContext = createContext<DSTabsUseTabsContextT>(defaultContext);\nexport const DSTabsCrossRefContext = createContext<DSTabsUseCrossRefContextT>(defaultCrossRefsContext);\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,0BAAiD;AAIjD,MAAM,OAAO,MAAM;AAAA;AAEnB,MAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,iBAAiB;AAAA;AAGnB,MAAM,0BAA0B;AAAA,EAC9B,oBAAoB;AAAA,EACpB,wBAAwB;AAAA;AAGnB,MAAM,gBAAgB,gCAAqC;AAC3D,MAAM,wBAAwB,gCAAyC;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/DSTabsDatatestid.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export const DSTabsDatatestid = {\n TABS_CONTAINER: 'ds-tabs-container',\n TAB_BUTTON: 'ds-tabs-tab-button',\n SUBTAB_BUTTON: 'ds-tabs-subtab-button',\n TAB_PANEL: 'ds-tabs-tab-panel',\n SUB_TAB_LIST: 'subtabs-list',\n TAB_LIST: 'tab-list',\n CAROUSEL: {\n BUTTON_RIGHT: 'chevron-right',\n BUTTON_LEFT: 'chevron-left',\n },\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,mBAAmB;AAAA,EAC9B,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,WAAW;AAAA,EACX,cAAc;AAAA,EACd,UAAU;AAAA,EACV,UAAU;AAAA,IACR,cAAc;AAAA,IACd,aAAa;AAAA;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/DSTabsTypes.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\nimport type React from 'react';\nimport { TabTypes } from './utils/constants';\n\n// **** **** **** **** **** **** **** **** CONSTANT TYPES **** **** **** **** **** **** **** **** **** //\n\ntype TabTypesT = typeof TabTypes[keyof typeof TabTypes];\n\n// **** **** **** **** **** **** **** **** COMPONENT TYPES **** **** **** **** **** **** **** **** **** //\n\nexport interface DSTabsPropsT {\n containerProps?: Record<string, unknown>;\n innerRef?: React.MutableRefObject<HTMLDivElement>;\n animated?: boolean;\n enableMouseEvents?: boolean;\n allowTextSelection?: boolean;\n onTabChange?: (tabId: string, e?: React.MouseEvent) => void;\n tabsListAriaLabel?: string;\n type?: TabTypesT;\n tabBarExtraContent?: React.ReactNode;\n children: React.ReactElement<DSTabPropsWithDefaultT>[];\n onlyRenderActiveTab?: boolean;\n activeTab?: string;\n withCarousel?: boolean;\n firstSubtabRef?: React.MutableRefObject<HTMLElement>;\n lastTabRef?: React.MutableRefObject<HTMLElement>;\n fixedTabsHeaders?: boolean;\n isDSMobile?: boolean;\n showSelectionIndicator?: boolean;\n showSeparator?: boolean;\n}\n\nexport interface DSTabsPropsWithDefaultsT {\n containerProps: Record<string, unknown>;\n innerRef?: React.MutableRefObject<HTMLDivElement>;\n animated: boolean;\n enableMouseEvents: boolean;\n allowTextSelection: boolean;\n onTabChange: (tabId: string, e?: React.MouseEvent) => void;\n tabsListAriaLabel: string;\n type: TabTypesT;\n tabBarExtraContent?: React.ReactNode;\n children: React.ReactElement<DSTabPropsWithDefaultT>[];\n onlyRenderActiveTab: boolean;\n activeTab?: string;\n withCarousel: boolean;\n firstSubtabRef?: React.MutableRefObject<HTMLElement>;\n lastTabRef?: React.MutableRefObject<HTMLElement>;\n fixedTabsHeaders: boolean;\n isDSMobile: boolean;\n showSelectionIndicator: boolean;\n showSeparator: boolean;\n}\n\nexport interface DSTabsDefaultPropsT {\n containerProps: Record<string, unknown>;\n animated: boolean;\n enableMouseEvents: boolean;\n allowTextSelection: boolean;\n onTabChange: (tabId: string, e?: React.MouseEvent) => void;\n tabsListAriaLabel: string;\n type: TabTypesT;\n onlyRenderActiveTab: boolean;\n fixedTabsHeaders: boolean;\n children: React.ReactElement<DSTabPropsWithDefaultT>[];\n withCarousel: boolean;\n isDSMobile: boolean;\n showSelectionIndicator: boolean;\n showSeparator: boolean;\n}\n\nexport interface CarouselPropsT {\n children: React.ReactNode[];\n updateIndicatorStyle?: () => void;\n}\n\nexport interface DSTabPropsT {\n tabId: string;\n title?: string;\n required?: boolean;\n children?: React.ReactNode;\n style?: Record<string, unknown>;\n disabled?: boolean;\n ref?: React.MutableRefObject<HTMLButtonElement>;\n onClick?: (tabId: string, e: React.MouseEvent) => null | void;\n onKeyDown?: (e: React.KeyboardEvent) => null | void;\n}\n\nexport interface DSTabPropsWithDefaultT {\n tabId: string;\n title: string;\n required: boolean;\n children?: React.ReactNode;\n style?: Record<string, unknown>;\n disabled: boolean;\n ref?: React.MutableRefObject<HTMLButtonElement>;\n onClick?: (tabId: string, e: React.MouseEvent) => null | void;\n onKeyDown?: (e: React.KeyboardEvent) => null | void;\n}\n\nexport interface CarouselButtonsPropsT {\n leftButtonOnClick: () => void;\n rightButtonOnClick: () => void;\n showChevrons: ShowChevronsT;\n type: TabTypesT;\n}\n\n// **** **** **** **** **** **** **** **** CONTEXT AND HOOK TYPES **** **** **** **** **** **** **** **** **** //\n\nexport interface DSTabsUseCrossRefContextT {\n lastTabInternalRef: React.MutableRefObject<HTMLButtonElement | null | undefined>;\n firstSubtabInternalRef: React.MutableRefObject<HTMLButtonElement | null | undefined>;\n}\n\nexport interface DSTabsUseTabsContextT {\n props: DSTabsPropsWithDefaultsT;\n tabsRef: React.MutableRefObject<Record<number, HTMLButtonElement> | null>;\n focusableTabsRef: React.MutableRefObject<HTMLButtonElement[] | null>;\n tabsListRef: React.MutableRefObject<HTMLDivElement | null>;\n tabsRefAsArray: React.MutableRefObject<HTMLButtonElement[] | null>;\n actualActiveTabRef: React.MutableRefObject<HTMLButtonElement | null>;\n carouselOnlyListRef: React.MutableRefObject<HTMLDivElement | null>;\n setInternalActiveTab: React.Dispatch<React.SetStateAction<string>>;\n actualActiveTab: string;\n}\n\nexport interface UseRezisePropsT {\n ref: React.MutableRefObject<HTMLDivElement | null>;\n callback: () => void;\n}\n\nexport interface UseCarouselPropsT {\n updateIndicatorStyle?: () => void;\n}\n\nexport interface ShowChevronsT {\n right: boolean;\n left: boolean;\n}\n\nexport interface MobileGradientsT {\n right: boolean;\n left: boolean;\n}\n\nexport interface IndicatorStyleT {\n left: string;\n width: string;\n backgroundWithTransparent: string;\n}\nexport interface UseCarouselReturnTypeT {\n showChevrons: ShowChevronsT;\n leftButtonOnClick: () => void;\n rightButtonOnClick: () => void;\n handleOnClick: (e: React.MouseEvent) => void;\n handleOnScroll: (e: React.UIEvent) => void;\n}\n\nexport interface UseCarouselCallbacksPropsT {\n getVisibleItemsOffset: () => number;\n recalcChevrons: () => void;\n updateIndicatorStyle?: () => void;\n}\n\nexport interface UseCarouselCallbacksReturnTypeT {\n leftButtonOnClick: () => void;\n rightButtonOnClick: () => void;\n handleOnClick: (e: React.MouseEvent) => void;\n handleOnScroll: (e: React.UIEvent) => void;\n}\n\nexport interface UseKeyboardNavigationReturnTypeT {\n handleOnKeyDown: (e: React.KeyboardEvent) => void;\n}\n\nexport interface UseTabsCallbacksReturnTypeT {\n handleOnTabChange: (tabId: string, e?: React.MouseEvent) => void;\n handleOnMouseDown: (e: React.MouseEvent) => void;\n}\n\nexport interface UseTabBarReturnTypeT {\n updateIndicatorStyle: () => void;\n updateMobileGradients: () => void;\n setIndicatorStyle: React.Dispatch<React.SetStateAction<IndicatorStyleT>>;\n indicatorStyle: IndicatorStyleT;\n mobileGradients: MobileGradientsT;\n}\n\n// **** **** **** **** **** **** **** **** HELPERS TYPES **** **** **** **** **** **** **** **** **** //\n\nexport interface VisibleDimensionsT {\n width: number;\n height: number;\n}\n\n// **** **** **** **** **** **** **** **** STYLED TYPES **** **** **** **** **** **** **** **** **** //\n\nexport interface StyledTabWrapperPropsT {\n isDSMobile: boolean;\n fixedTabsHeaders: boolean;\n}\n\nexport interface StyledTabListPropsT {\n withCarousel: boolean;\n isDSMobile: boolean;\n fixedTabsHeaders: boolean;\n mobileGradients: MobileGradientsT;\n indicatorStyle: IndicatorStyleT;\n tabType: TabTypesT;\n}\n\nexport interface StyledSubTabsListPropsT {\n withCarousel: boolean;\n}\n\nexport interface StyledTabButtonPropsT {\n isActive: boolean;\n disabled: boolean;\n showSeparator: boolean;\n isDSMobile: boolean;\n fixedTabsHeaders: boolean;\n withCarousel: boolean;\n tabType: TabTypesT;\n}\n\nexport interface StyledCarouselButtonWrapperPropsT {\n right?: boolean;\n tabType: TabTypesT;\n}\n\nexport interface StyledPanelContainerPropsT {\n hidden: boolean;\n isDSMobile: boolean;\n}\n\nexport interface StyledSelectionIndicatoPropsT {\n isDSMobile: boolean;\n tabType: TabTypesT;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/config/useCrossRef.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useRef, useMemo } from 'react';\nimport type { DSTabsUseCrossRefContextT } from '../DSTabsTypes';\n\nexport const useCrossRef = (): DSTabsUseCrossRefContextT => {\n const firstSubtabInternalRef = useRef<HTMLButtonElement>();\n const lastTabInternalRef = useRef<HTMLButtonElement>();\n\n const ctx = useMemo(\n () => ({\n firstSubtabInternalRef,\n lastTabInternalRef,\n }),\n [],\n );\n\n return ctx;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAgC;AAGzB,MAAM,cAAc,MAAiC;AAC1D,QAAM,yBAAyB;AAC/B,QAAM,qBAAqB;AAE3B,QAAM,MAAM,0BACV,MAAO;AAAA,IACL;AAAA,IACA;AAAA,MAEF;AAGF,SAAO;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/config/useTabs.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useRef, useState, useMemo, useEffect } from 'react';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { tabsDefaultProps } from '../defaultProps';\nimport type { DSTabsPropsT, DSTabsUseTabsContextT, DSTabsPropsWithDefaultsT } from '../DSTabsTypes';\n\nexport const useTabs = (props: DSTabsPropsT): DSTabsUseTabsContextT => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, tabsDefaultProps) as DSTabsPropsWithDefaultsT;\n\n const { activeTab, children } = propsWithDefaults;\n\n const tabsRef = useRef<Record<number, HTMLButtonElement>>({});\n const tabsRefAsArray = useRef<HTMLButtonElement[]>([]);\n const focusableTabsRef = useRef<HTMLButtonElement[]>([]);\n const carouselOnlyListRef = useRef<HTMLDivElement | null>(null);\n const tabsListRef = useRef<HTMLDivElement | null>(null);\n const actualActiveTabRef = useRef<HTMLButtonElement | null>(null);\n\n const [internalActiveTab, setInternalActiveTab] = useState<string>(children?.[0]?.props?.tabId);\n\n const actualActiveTab = useMemo(() => {\n if (activeTab !== undefined) return activeTab;\n return internalActiveTab;\n }, [activeTab, internalActiveTab]);\n\n useEffect(() => {\n actualActiveTabRef.current = focusableTabsRef.current.find((el) => el.dataset.tabId === actualActiveTab) ?? null;\n }, [actualActiveTab]);\n\n const ctx = useMemo(\n () => ({\n props: propsWithDefaults,\n tabsRef,\n focusableTabsRef,\n tabsListRef,\n tabsRefAsArray,\n setInternalActiveTab,\n actualActiveTab,\n actualActiveTabRef,\n carouselOnlyListRef,\n }),\n [actualActiveTab, propsWithDefaults],\n );\n\n return ctx;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAqD;AACrD,8BAA6C;AAC7C,0BAAiC;AAG1B,MAAM,UAAU,CAAC,UAA+C;AACrE,QAAM,oBAAoB,0DAA6B,OAAO;AAE9D,QAAM,EAAE,WAAW,aAAa;AAEhC,QAAM,UAAU,yBAA0C;AAC1D,QAAM,iBAAiB,yBAA4B;AACnD,QAAM,mBAAmB,yBAA4B;AACrD,QAAM,sBAAsB,yBAA8B;AAC1D,QAAM,cAAc,yBAA8B;AAClD,QAAM,qBAAqB,yBAAiC;AAE5D,QAAM,CAAC,mBAAmB,wBAAwB,2BAAiB,WAAW,IAAI,OAAO;AAEzF,QAAM,kBAAkB,0BAAQ,MAAM;AACpC,QAAI,cAAc;AAAW,aAAO;AACpC,WAAO;AAAA,KACN,CAAC,WAAW;AAEf,8BAAU,MAAM;AACd,uBAAmB,UAAU,iBAAiB,QAAQ,KAAK,CAAC,OAAO,GAAG,QAAQ,UAAU,oBAAoB;AAAA,KAC3G,CAAC;AAEJ,QAAM,MAAM,0BACV,MAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF,CAAC,iBAAiB;AAGpB,SAAO;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/defaultProps.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { TabTypes } from './utils/constants';\nimport type { DSTabsDefaultPropsT } from './DSTabsTypes';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = (): void => {};\n\nexport const tabsDefaultProps: DSTabsDefaultPropsT = {\n containerProps: {},\n animated: true,\n enableMouseEvents: false,\n allowTextSelection: false,\n onTabChange: noop,\n tabsListAriaLabel: 'Tab list',\n type: TabTypes.NORMAL,\n onlyRenderActiveTab: false,\n withCarousel: false,\n isDSMobile: false,\n showSelectionIndicator: true,\n children: [],\n fixedTabsHeaders: false,\n showSeparator: true,\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAyB;AAIzB,MAAM,OAAO,MAAY;AAAA;AAElB,MAAM,mBAAwC;AAAA,EACnD,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,MAAM,0BAAS;AAAA,EACf,qBAAqB;AAAA,EACrB,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,wBAAwB;AAAA,EACxB,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,eAAe;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/exportsRelated/DSTab.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { describe } from 'react-desc';\nimport { tabPropTypes } from '../propTypes';\nimport type { DSTabPropsT } from '../DSTabsTypes';\n\nconst DSTab = (props: DSTabPropsT): JSX.Element => <React.Fragment {...props} />;\n\nDSTab.propTypes = tabPropTypes as WeakValidationMap<unknown>;\nconst DSTabWithSchema = describe<DSTabPropsT>(DSTab);\nDSTabWithSchema.propTypes = tabPropTypes;\n\nexport { DSTab, DSTabWithSchema };\nexport default DSTab;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAElB,wBAAyB;AACzB,uBAA6B;AAG7B,MAAM,QAAQ,CAAC,UAAoC,mDAAC,qBAAM,UAAP;AAAA,KAAoB;AAAA;AAEvE,MAAM,YAAY;AAClB,MAAM,kBAAkB,gCAAsB;AAC9C,gBAAgB,YAAY;AAG5B,IAAO,gBAAQ;",
6
- "names": []
7
- }
package/cjs/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export * from './exportsRelated/DSTab';\nexport * from './DSTabs';\nexport { TabTypes } from './utils/constants';\nexport * from './DSTabsDatatestid';\n\nexport type { DSTabsPropsT, DSTabPropsT } from './DSTabsTypes';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,wBAAc;AACd,uBAAyB;AACzB,wBAAc;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/parts/carousel/Carousel.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useContext } from 'react';\nimport { DSIconSizes } from '@elliemae/ds-icon';\nimport { BUTTON_TYPES } from '@elliemae/ds-button';\nimport { ChevronRight, ChevronLeft } from '@elliemae/ds-icons';\nimport { StyledCarouselBtn, StyledCarouselButtonWrapper, StyledCarouselWrapper, StyledChildrenWrap } from './styles';\nimport { useCarousel } from './useCarousel';\nimport { DSTabsContext } from '../../DSTabsCTX';\nimport { DSTabsDatatestid } from '../../DSTabsDatatestid';\nimport type { CarouselPropsT } from '../../DSTabsTypes';\n\nexport const Carousel = ({ children, updateIndicatorStyle }: CarouselPropsT): JSX.Element => {\n const { showChevrons, leftButtonOnClick, rightButtonOnClick, handleOnClick, handleOnScroll } = useCarousel({\n updateIndicatorStyle,\n });\n\n const {\n carouselOnlyListRef,\n props: { type },\n } = useContext(DSTabsContext);\n\n return (\n <StyledCarouselWrapper>\n {showChevrons.left && (\n <StyledCarouselButtonWrapper tabType={type}>\n <StyledCarouselBtn\n size=\"s\"\n onClick={leftButtonOnClick}\n tabIndex={-1}\n data-testid={DSTabsDatatestid.CAROUSEL.BUTTON_LEFT}\n buttonType={BUTTON_TYPES.ICON}\n >\n <ChevronLeft size={DSIconSizes.S} />\n </StyledCarouselBtn>\n </StyledCarouselButtonWrapper>\n )}\n {showChevrons.right && (\n <StyledCarouselButtonWrapper tabType={type} right={showChevrons.right}>\n <StyledCarouselBtn\n size=\"s\"\n onClick={rightButtonOnClick}\n tabIndex={-1}\n data-testid={DSTabsDatatestid.CAROUSEL.BUTTON_RIGHT}\n buttonType={BUTTON_TYPES.ICON}\n >\n <ChevronRight size={DSIconSizes.S} />\n </StyledCarouselBtn>\n </StyledCarouselButtonWrapper>\n )}\n <StyledChildrenWrap ref={carouselOnlyListRef} onClick={handleOnClick} onScroll={handleOnScroll}>\n {children}\n </StyledChildrenWrap>\n </StyledCarouselWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA2B;AAC3B,qBAA4B;AAC5B,uBAA6B;AAC7B,sBAA0C;AAC1C,oBAA0G;AAC1G,yBAA4B;AAC5B,uBAA8B;AAC9B,8BAAiC;AAG1B,MAAM,WAAW,CAAC,EAAE,UAAU,2BAAwD;AAC3F,QAAM,EAAE,cAAc,mBAAmB,oBAAoB,eAAe,mBAAmB,oCAAY;AAAA,IACzG;AAAA;AAGF,QAAM;AAAA,IACJ;AAAA,IACA,OAAO,EAAE;AAAA,MACP,6BAAW;AAEf,SACE,oCAAC,qCAAD,MACG,aAAa,QACZ,oCAAC,2CAAD;AAAA,IAA6B,SAAS;AAAA,KACpC,oCAAC,iCAAD;AAAA,IACE,MAAK;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,IACV,eAAa,yCAAiB,SAAS;AAAA,IACvC,YAAY,8BAAa;AAAA,KAEzB,oCAAC,6BAAD;AAAA,IAAa,MAAM,2BAAY;AAAA,QAIpC,aAAa,SACZ,oCAAC,2CAAD;AAAA,IAA6B,SAAS;AAAA,IAAM,OAAO,aAAa;AAAA,KAC9D,oCAAC,iCAAD;AAAA,IACE,MAAK;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,IACV,eAAa,yCAAiB,SAAS;AAAA,IACvC,YAAY,8BAAa;AAAA,KAEzB,oCAAC,8BAAD;AAAA,IAAc,MAAM,2BAAY;AAAA,QAItC,oCAAC,kCAAD;AAAA,IAAoB,KAAK;AAAA,IAAqB,SAAS;AAAA,IAAe,UAAU;AAAA,KAC7E;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/parts/carousel/styles.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import styled from 'styled-components';\nimport { DSButtonV2 } from '@elliemae/ds-button';\nimport { TabTypes } from '../../utils/constants';\nimport type { StyledCarouselButtonWrapperPropsT } from '../../DSTabsTypes';\n\nexport const StyledCarouselBtn = styled(DSButtonV2)`\n margin: 0;\n min-width: ${({ theme }) => theme.space.xs};\n width: ${({ theme }) => theme.space.xs};\n\n &:hover:not(:disabled) {\n background-color: transparent;\n }\n background-color: transparent;\n border-radius: 0px;\n\n & .em-ds-icon svg {\n fill: ${({ theme }) => theme.colors.brand[600]};\n }\n`;\n\nexport const StyledCarouselWrapper = styled.span`\n position: relative;\n width: 100%;\n display: flex;\n`;\n\nexport const StyledChildrenWrap = styled.div`\n display: flex;\n flex-wrap: nowrap;\n flex: 1;\n overflow-x: hidden;\n`;\n\nexport const StyledCarouselButtonWrapper = styled.div<StyledCarouselButtonWrapperPropsT>`\n max-width: 16px;\n position: absolute;\n z-index: 200;\n ${({ right }) => (right ? 'right: 0;' : `left: 0;`)}\n width: 16px;\n height: ${({ tabType }) => (tabType === TabTypes.NORMAL ? '32px' : '22px')};\n padding-top: ${({ tabType }) => (tabType === TabTypes.NORMAL ? '5px' : '0px')};\n background: white;\n ${({ theme, tabType }) =>\n tabType === TabTypes.NORMAL\n ? `\n background: linear-gradient(to bottom, white 0px, white 30px, ${theme.colors.neutral[400]} 30px, ${theme.colors.neutral[400]} 31px, white 31px , white 32px );\n `\n : ``};\n`;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,+BAAmB;AACnB,uBAA2B;AAC3B,uBAAyB;AAGlB,MAAM,oBAAoB,sCAAO;AAAA;AAAA,eAEzB,CAAC,EAAE,YAAY,MAAM,MAAM;AAAA,WAC/B,CAAC,EAAE,YAAY,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAS1B,CAAC,EAAE,YAAY,MAAM,OAAO,MAAM;AAAA;AAAA;AAIvC,MAAM,wBAAwB,iCAAO;AAAA;AAAA;AAAA;AAAA;AAMrC,MAAM,qBAAqB,iCAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOlC,MAAM,8BAA8B,iCAAO;AAAA;AAAA;AAAA;AAAA,IAI9C,CAAC,EAAE,YAAa,QAAQ,cAAc;AAAA;AAAA,YAE9B,CAAC,EAAE,cAAe,YAAY,0BAAS,SAAS,SAAS;AAAA,iBACpD,CAAC,EAAE,cAAe,YAAY,0BAAS,SAAS,QAAQ;AAAA;AAAA,IAErE,CAAC,EAAE,OAAO,cACV,YAAY,0BAAS,SACjB;AAAA,sEAC8D,MAAM,OAAO,QAAQ,cAAc,MAAM,OAAO,QAAQ;AAAA,KAEtH;AAAA;",
6
- "names": []
7
- }