@elliemae/ds-tabs 2.2.0 → 2.3.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.
Files changed (104) hide show
  1. package/cjs/DSTabs.js +58 -40
  2. package/cjs/DSTabs.js.map +7 -0
  3. package/cjs/DSTabsCTX.js +51 -25
  4. package/cjs/DSTabsCTX.js.map +7 -0
  5. package/cjs/DSTabsDatatestid.js +42 -14
  6. package/cjs/DSTabsDatatestid.js.map +7 -0
  7. package/cjs/DSTabsTypes.js +27 -2
  8. package/cjs/DSTabsTypes.js.map +7 -0
  9. package/cjs/config/useCrossRef.js +38 -11
  10. package/cjs/config/useCrossRef.js.map +7 -0
  11. package/cjs/config/useTabs.js +53 -36
  12. package/cjs/config/useTabs.js.map +7 -0
  13. package/cjs/defaultProps.js +39 -13
  14. package/cjs/defaultProps.js.map +7 -0
  15. package/cjs/exportsRelated/DSTab.js +46 -32
  16. package/cjs/exportsRelated/DSTab.js.map +7 -0
  17. package/cjs/index.js +38 -17
  18. package/cjs/index.js.map +7 -0
  19. package/cjs/parts/carousel/Carousel.js +61 -53
  20. package/cjs/parts/carousel/Carousel.js.map +7 -0
  21. package/cjs/parts/carousel/styles.js +77 -63
  22. package/cjs/parts/carousel/styles.js.map +7 -0
  23. package/cjs/parts/carousel/useCarousel.js +51 -49
  24. package/cjs/parts/carousel/useCarousel.js.map +7 -0
  25. package/cjs/parts/carousel/useCarouselCallbacks.js +53 -36
  26. package/cjs/parts/carousel/useCarouselCallbacks.js.map +7 -0
  27. package/cjs/parts/tabBar/TabBar.js +131 -120
  28. package/cjs/parts/tabBar/TabBar.js.map +7 -0
  29. package/cjs/parts/tabBar/styles.js +289 -195
  30. package/cjs/parts/tabBar/styles.js.map +7 -0
  31. package/cjs/parts/tabBar/useTabBar.js +66 -62
  32. package/cjs/parts/tabBar/useTabBar.js.map +7 -0
  33. package/cjs/parts/tabsContent/TabsContent.js +49 -45
  34. package/cjs/parts/tabsContent/TabsContent.js.map +7 -0
  35. package/cjs/parts/tabsContent/styles.js +39 -15
  36. package/cjs/parts/tabsContent/styles.js.map +7 -0
  37. package/cjs/parts/tabsPanel/TabsPanels.js +60 -58
  38. package/cjs/parts/tabsPanel/TabsPanels.js.map +7 -0
  39. package/cjs/parts/tabsPanel/styles.js +43 -23
  40. package/cjs/parts/tabsPanel/styles.js.map +7 -0
  41. package/cjs/propTypes.js +54 -29
  42. package/cjs/propTypes.js.map +7 -0
  43. package/cjs/utils/constants.js +44 -16
  44. package/cjs/utils/constants.js.map +7 -0
  45. package/cjs/utils/helpers.js +63 -22
  46. package/cjs/utils/helpers.js.map +7 -0
  47. package/cjs/utils/hooks/useKeyboardNavigation.js +59 -43
  48. package/cjs/utils/hooks/useKeyboardNavigation.js.map +7 -0
  49. package/cjs/utils/hooks/useTabsCallbacks.js +46 -45
  50. package/cjs/utils/hooks/useTabsCallbacks.js.map +7 -0
  51. package/esm/DSTabs.js +24 -25
  52. package/esm/DSTabs.js.map +7 -0
  53. package/esm/DSTabsCTX.js +22 -20
  54. package/esm/DSTabsCTX.js.map +7 -0
  55. package/esm/DSTabsDatatestid.js +13 -10
  56. package/esm/DSTabsDatatestid.js.map +7 -0
  57. package/esm/DSTabsTypes.js +2 -1
  58. package/esm/DSTabsTypes.js.map +7 -0
  59. package/esm/config/useCrossRef.js +6 -4
  60. package/esm/config/useCrossRef.js.map +7 -0
  61. package/esm/config/useTabs.js +14 -22
  62. package/esm/config/useTabs.js.map +7 -0
  63. package/esm/defaultProps.js +9 -8
  64. package/esm/defaultProps.js.map +7 -0
  65. package/esm/exportsRelated/DSTab.js +15 -19
  66. package/esm/exportsRelated/DSTab.js.map +7 -0
  67. package/esm/index.js +9 -4
  68. package/esm/index.js.map +7 -0
  69. package/esm/parts/carousel/Carousel.js +25 -38
  70. package/esm/parts/carousel/Carousel.js.map +7 -0
  71. package/esm/parts/carousel/styles.js +48 -52
  72. package/esm/parts/carousel/styles.js.map +7 -0
  73. package/esm/parts/carousel/useCarousel.js +15 -34
  74. package/esm/parts/carousel/useCarousel.js.map +7 -0
  75. package/esm/parts/carousel/useCarouselCallbacks.js +20 -28
  76. package/esm/parts/carousel/useCarouselCallbacks.js.map +7 -0
  77. package/esm/parts/tabBar/TabBar.js +100 -102
  78. package/esm/parts/tabBar/TabBar.js.map +7 -0
  79. package/esm/parts/tabBar/styles.js +262 -183
  80. package/esm/parts/tabBar/styles.js.map +7 -0
  81. package/esm/parts/tabBar/useTabBar.js +27 -44
  82. package/esm/parts/tabBar/useTabBar.js.map +7 -0
  83. package/esm/parts/tabsContent/TabsContent.js +19 -35
  84. package/esm/parts/tabsContent/TabsContent.js.map +7 -0
  85. package/esm/parts/tabsContent/styles.js +10 -7
  86. package/esm/parts/tabsContent/styles.js.map +7 -0
  87. package/esm/parts/tabsPanel/TabsPanels.js +28 -45
  88. package/esm/parts/tabsPanel/TabsPanels.js.map +7 -0
  89. package/esm/parts/tabsPanel/styles.js +14 -15
  90. package/esm/parts/tabsPanel/styles.js.map +7 -0
  91. package/esm/propTypes.js +25 -24
  92. package/esm/propTypes.js.map +7 -0
  93. package/esm/utils/constants.js +15 -8
  94. package/esm/utils/constants.js.map +7 -0
  95. package/esm/utils/helpers.js +33 -11
  96. package/esm/utils/helpers.js.map +7 -0
  97. package/esm/utils/hooks/useKeyboardNavigation.js +30 -39
  98. package/esm/utils/hooks/useKeyboardNavigation.js.map +7 -0
  99. package/esm/utils/hooks/useTabsCallbacks.js +15 -39
  100. package/esm/utils/hooks/useTabsCallbacks.js.map +7 -0
  101. package/package.json +6 -6
  102. package/types/DSTabs.d.ts +2 -2
  103. package/types/DSTabsTypes.d.ts +4 -0
  104. package/types/utils/helpers.d.ts +2 -1
@@ -1,186 +1,265 @@
1
- import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
- import styled from 'styled-components';
3
- import { css, onlySafariAndFirefox, safariAndFirefoxBold } from '@elliemae/ds-system';
4
- import { TabTypes } from '../../utils/constants.js';
5
-
6
- var _templateObject;
7
- const StyledSelectionIndicator = /*#__PURE__*/styled.div.withConfig({
8
- componentId: "sc-3hla56-0"
9
- })(["position:absolute;height:3px;top:", ";margin-top:", ";pointer-events:none;transition:200ms cubic-bezier(0.36,0,1,1);z-index:10;", ""], _ref => {
10
- let {
11
- tabType,
12
- isDSMobile
13
- } = _ref;
14
- if (isDSMobile) return "35px";
15
- if (tabType === TabTypes.NORMAL_SMALL) return "15px";
16
- return "25px";
17
- }, _ref2 => {
18
- let {
19
- theme
20
- } = _ref2;
21
- return theme.space.xxxs;
22
- }, _ref3 => {
23
- let {
24
- isDSMobile
25
- } = _ref3;
26
- return isDSMobile ? " \n margin-left: 0;\n margin-top: 3px;\n " : "";
27
- });
28
- const mobileGradientsSettings = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n"])), _ref4 => {
29
- let {
30
- theme,
31
- mobileGradients,
32
- isDSMobile,
33
- fixedTabsHeaders
34
- } = _ref4;
35
-
1
+ import * as React from "react";
2
+ import styled from "styled-components";
3
+ import { safariAndFirefoxBold, onlySafariAndFirefox, css } from "@elliemae/ds-system";
4
+ import { TabTypes } from "../../utils/constants";
5
+ const StyledSelectionIndicator = styled.div`
6
+ position: absolute;
7
+ height: 3px;
8
+ top: ${({ tabType, isDSMobile }) => {
9
+ if (isDSMobile)
10
+ return `35px`;
11
+ if (tabType === TabTypes.NORMAL_SMALL)
12
+ return `15px`;
13
+ return `25px`;
14
+ }};
15
+ margin-top: ${({ theme }) => theme.space.xxxs};
16
+ pointer-events: none;
17
+ transition: 200ms cubic-bezier(0.36, 0, 1, 1);
18
+ z-index: 10;
19
+ ${({ isDSMobile }) => isDSMobile ? `
20
+ margin-left: 0;
21
+ margin-top: 3px;
22
+ ` : ``}
23
+ `;
24
+ const mobileGradientsSettings = css`
25
+ ${({ theme, mobileGradients, isDSMobile, fixedTabsHeaders }) => {
36
26
  if (isDSMobile && !fixedTabsHeaders) {
37
- if (mobileGradients.right && mobileGradients.left) return "background: linear-gradient(90deg, rgba(238,238,238,0) 0%, ".concat(theme.colors.brand[200], " 20%, ").concat(theme.colors.brand[200], " 80%, rgba(238,238,238,0) 100%);");
38
- if (mobileGradients.right) return "background: linear-gradient(90deg, ".concat(theme.colors.brand[200], " 0%, ").concat(theme.colors.brand[200], " 80%, rgba(238,238,238,0) 100%);");
39
- if (mobileGradients.left) return "background: linear-gradient(90deg, rgba(238,238,238,0) 0%, ".concat(theme.colors.brand[200], " 20%, ").concat(theme.colors.brand[200], " 100%);");
27
+ if (mobileGradients.right && mobileGradients.left)
28
+ return `background: linear-gradient(90deg, rgba(238,238,238,0) 0%, ${theme.colors.brand[200]} 20%, ${theme.colors.brand[200]} 80%, rgba(238,238,238,0) 100%);`;
29
+ if (mobileGradients.right)
30
+ return `background: linear-gradient(90deg, ${theme.colors.brand[200]} 0%, ${theme.colors.brand[200]} 80%, rgba(238,238,238,0) 100%);`;
31
+ if (mobileGradients.left)
32
+ return `background: linear-gradient(90deg, rgba(238,238,238,0) 0%, ${theme.colors.brand[200]} 20%, ${theme.colors.brand[200]} 100%);`;
40
33
  }
34
+ return ``;
35
+ }}
36
+ `;
37
+ const StyledTabWrapper = styled.div`
38
+ display: flex;
39
+ flex: 1;
40
+ flex-wrap: nowrap;
41
+ ${({ fixedTabsHeaders, isDSMobile }) => !fixedTabsHeaders && isDSMobile ? "" : "overflow-x: hidden;"}
42
+ ${({ theme, isDSMobile }) => isDSMobile ? `border-bottom: 1px solid ${theme.colors.brand[300]};` : ``}
43
+ `;
44
+ const StyledTabButton = styled.button`
45
+ position: relative;
46
+ background-color: transparent;
47
+ border: none;
48
+ cursor: pointer;
49
+ transition: 100ms cubic-bezier(0, 0, 0.42, 1);
50
+ text-transform: ${({ tabType }) => tabType === TabTypes.SUBTABS ? `capitalize` : `uppercase`};
51
+ letter-spacing: 0px;
52
+ white-space: nowrap;
53
+ padding: 2px 0;
54
+ margin-right: ${({ fixedTabsHeaders, isDSMobile }) => {
55
+ if (fixedTabsHeaders)
56
+ return "0px";
57
+ if (!fixedTabsHeaders && isDSMobile)
58
+ return "14px";
59
+ return "16px";
60
+ }};
61
+
62
+ margin-left: ${({ fixedTabsHeaders, isDSMobile }) => {
63
+ if (fixedTabsHeaders)
64
+ return "0px";
65
+ if (!fixedTabsHeaders && isDSMobile)
66
+ return "14px";
67
+ return "16px";
68
+ }};
69
+
70
+ color: ${({ theme }) => theme.colors.neutral[700]};
71
+ ${onlySafariAndFirefox("-webkit-text-stroke: 0.4px transparent;")}
72
+
73
+ ${({ tabType }) => tabType === TabTypes.NORMAL ? `height: 32px;` : `height: 22px;`}
74
+
75
+ ${({ theme, isActive, disabled }) => isActive && !disabled ? `
76
+ font-weight: ${theme.fontWeights.semibold};
77
+ ${safariAndFirefoxBold(`#353C46`)}
78
+
79
+ &:hover {
80
+ ${safariAndFirefoxBold(`#1E79C2`)}
81
+ }
82
+
83
+ ` : `
84
+
85
+ `}
86
+
87
+ ${({ theme, disabled }) => disabled ? `
88
+ color: ${theme.colors.neutral[500]};
89
+ cursor: not-allowed;
90
+ ` : `
91
+ &:hover {
92
+ color: ${theme.colors.brand[600]};
93
+ }
94
+ `}
95
+
96
+
97
+ ${({ theme, showSeparator, tabType }) => showSeparator ? `
98
+ &:not(:last-of-type):before
99
+ {
100
+ content: "";
101
+ position: absolute;
102
+ width: 1px;
103
+ right: -16px;
104
+ top: 50%;
105
+ transform: translateY(-50%);
106
+ height: ${tabType === TabTypes.SUBTABS ? `10px` : `16px`};
107
+ background: ${theme.colors.neutral[400]};
108
+ }` : ``}
109
+
110
+ ${({ theme, isDSMobile, tabType, isActive }) => !isDSMobile ? `
111
+ &:focus {
112
+ outline: none;
113
+ &:after {
114
+ position: absolute;
115
+ content: '';
116
+ top: 0;
117
+ left: -16px;
118
+ width: calc(100% + 32px);
119
+ height: 100%;
120
+ z-index: 5;
121
+ border-radius: 2px;
122
+ border: 2px solid ${theme.colors.brand[700]};
123
+ }
124
+
125
+ ${tabType !== TabTypes.SUBTABS && isActive ? `
126
+ &:before {
127
+ position: absolute;
128
+ content: '';
129
+ left: -16px;
130
+ right: 0;
131
+ top: calc(100% - 2px);
132
+ transform: none;
133
+ width: calc(100% + 32px);
134
+ height: 2px;
135
+ z-index: 10;
136
+ background: linear-gradient(to right, transparent 0px, transparent 12px, white 12px, white 16px, transparent 16px,transparent calc(100% - 16px), white calc(100% - 16px), white calc(100% - 12px), transparent calc(100% - 12px), transparent 100%);
137
+ }
138
+ ` : ``}
139
+ }
140
+
141
+ ` : ``}
142
+
143
+
144
+
145
+ ${({ theme, isActive, disabled, isDSMobile }) => isDSMobile ? `
146
+ height: 40px;
147
+ color: ${theme.colors.brand[600]};
148
+ font-weight: ${theme.fontWeights.regular};
149
+ padding: 0;
150
+ font-size: 13px;
151
+ line-height: 1.3;
152
+ ${onlySafariAndFirefox("-webkit-text-stroke: 0.4px transparent;")}
153
+
154
+ &:focus {
155
+ font-weight: ${theme.fontWeights.regular};
156
+ font-size: 13px;
157
+ ${safariAndFirefoxBold("#006AA9")}
158
+ }
159
+
160
+ ${isActive ? `
161
+ font-weight: ${theme.fontWeights.regular};
162
+ font-size: 13px;
163
+ ${safariAndFirefoxBold("#006AA9")}
164
+ ` : ``}
41
165
 
42
- return "";
43
- });
44
- const StyledTabWrapper = /*#__PURE__*/styled.div.withConfig({
45
- componentId: "sc-3hla56-1"
46
- })(["display:flex;flex:1;flex-wrap:nowrap;", " ", ""], _ref5 => {
47
- let {
48
- fixedTabsHeaders,
49
- isDSMobile
50
- } = _ref5;
51
- return !fixedTabsHeaders && isDSMobile ? '' : 'overflow-x: hidden;';
52
- }, _ref6 => {
53
- let {
54
- theme,
55
- isDSMobile
56
- } = _ref6;
57
- return isDSMobile ? "border-bottom: 1px solid ".concat(theme.colors.brand[300], ";") : "";
58
- });
59
- const StyledTabButton = /*#__PURE__*/styled.button.withConfig({
60
- componentId: "sc-3hla56-2"
61
- })(["position:relative;background-color:transparent;border:none;cursor:pointer;transition:100ms cubic-bezier(0,0,0.42,1);text-transform:", ";letter-spacing:0px;white-space:nowrap;padding:2px 0;margin-right:", ";margin-left:", ";color:", ";", " ", " ", " ", " ", " ", " ", ""], _ref7 => {
62
- let {
63
- tabType
64
- } = _ref7;
65
- return tabType === TabTypes.SUBTABS ? "capitalize" : "uppercase";
66
- }, _ref8 => {
67
- let {
68
- fixedTabsHeaders,
69
- isDSMobile
70
- } = _ref8;
71
- if (fixedTabsHeaders) return '0px';
72
- if (!fixedTabsHeaders && isDSMobile) return '14px';
73
- return '16px';
74
- }, _ref9 => {
75
- let {
76
- fixedTabsHeaders,
77
- isDSMobile
78
- } = _ref9;
79
- if (fixedTabsHeaders) return '0px';
80
- if (!fixedTabsHeaders && isDSMobile) return '14px';
81
- return '16px';
82
- }, _ref10 => {
83
- let {
84
- theme
85
- } = _ref10;
86
- return theme.colors.neutral[700];
87
- }, onlySafariAndFirefox('-webkit-text-stroke: 0.4px transparent;'), _ref11 => {
88
- let {
89
- tabType
90
- } = _ref11;
91
- return tabType === TabTypes.NORMAL ? "height: 32px;" : "height: 22px;";
92
- }, _ref12 => {
93
- let {
94
- theme,
95
- isActive,
96
- disabled
97
- } = _ref12;
98
- return isActive && !disabled ? "\n font-weight: ".concat(theme.fontWeights.semibold, ";\n ").concat(safariAndFirefoxBold("#353C46"), "\n\n &:hover {\n ").concat(safariAndFirefoxBold("#1E79C2"), "\n }\n \n ") : "\n \n ";
99
- }, _ref13 => {
100
- let {
101
- theme,
102
- disabled
103
- } = _ref13;
104
- return disabled ? "\n color: ".concat(theme.colors.neutral[500], ";\n cursor: not-allowed;\n ") : "\n &:hover {\n color: ".concat(theme.colors.brand[600], ";\n }\n ");
105
- }, _ref14 => {
106
- let {
107
- theme,
108
- showSeparator,
109
- tabType
110
- } = _ref14;
111
- return showSeparator ? "\n &:not(:last-of-type):before\n {\n content: \"\";\n position: absolute;\n width: 1px;\n right: -16px;\n top: 50%;\n transform: translateY(-50%);\n height: ".concat(tabType === TabTypes.SUBTABS ? "10px" : "16px", ";\n background: ").concat(theme.colors.neutral[400], ";\n }") : "";
112
- }, _ref15 => {
113
- let {
114
- theme,
115
- isDSMobile,
116
- tabType,
117
- isActive
118
- } = _ref15;
119
- return !isDSMobile ? "\n &:focus {\n outline: none;\n &:after {\n position: absolute;\n content: '';\n top: 0;\n left: -16px;\n width: calc(100% + 32px);\n height: 100%;\n z-index: 5;\n border-radius: 2px;\n border: 2px solid ".concat(theme.colors.brand[700], ";\n }\n\n ").concat(tabType !== TabTypes.SUBTABS && isActive ? "\n &:before {\n position: absolute;\n content: '';\n left: -16px;\n right: 0;\n top: calc(100% - 2px);\n transform: none;\n width: calc(100% + 32px);\n height: 2px;\n z-index: 10;\n background: linear-gradient(to right, transparent 0px, transparent 12px, white 12px, white 16px, transparent 16px,transparent calc(100% - 16px), white calc(100% - 16px), white calc(100% - 12px), transparent calc(100% - 12px), transparent 100%);\n }\n " : "", "\n }\n \n ") : "";
120
- }, _ref16 => {
121
- let {
122
- theme,
123
- isActive,
124
- disabled,
125
- isDSMobile
126
- } = _ref16;
127
- return isDSMobile ? "\n height: 40px;\n color: ".concat(theme.colors.brand[600], ";\n font-weight: ").concat(theme.fontWeights.regular, ";\n padding: 0;\n font-size: 13px;\n line-height: 1.3;\n ").concat(onlySafariAndFirefox('-webkit-text-stroke: 0.4px transparent;'), " \n\n &:focus {\n font-weight: ").concat(theme.fontWeights.regular, ";\n font-size: 13px;\n ").concat(safariAndFirefoxBold('#006AA9'), "\n }\n\n ").concat(isActive ? "\n font-weight: ".concat(theme.fontWeights.regular, ";\n font-size: 13px;\n ").concat(safariAndFirefoxBold('#006AA9'), "\n ") : "", "\n\n ").concat(isActive && !disabled ? "\n font-size: 13px;\n color: ".concat(theme.colors.brand[700], ";\n line-height: 1.3;\n font-weight: ").concat(theme.fontWeights.regular, ";\n -webkit-font-smoothing: subpixel-antialiased; \n -webkit-text-stroke: 0.4px ").concat(theme.colors.brand[700], ";") : "", "\n\n ").concat(!disabled ? "\n &:hover,\n &:focus {\n outline: none;\n color: ".concat(theme.colors.brand[700], ";\n ").concat(safariAndFirefoxBold('#006AA9'), "\n }") : "", "\n\n ") : "";
128
- });
129
- const StyledSubTabsList = /*#__PURE__*/styled.div.withConfig({
130
- componentId: "sc-3hla56-3"
131
- })(["position:relative;display:flex;flex-wrap:nowrap;flex:1;width:100%;", ""], _ref17 => {
132
- let {
133
- withCarousel
134
- } = _ref17;
135
- return withCarousel ? 'max-width: 100%;' : '';
136
- });
137
- const StyledTabList = /*#__PURE__*/styled.div.withConfig({
138
- componentId: "sc-3hla56-4"
139
- })(["position:relative;display:flex;flex-wrap:nowrap;flex:1;width:100%;", " ", " ", "{padding-bottom:0;padding-top:0;}", " ", " ", " ", "{", "}", "{background:", ";}"], _ref18 => {
140
- let {
141
- withCarousel,
142
- isDSMobile
143
- } = _ref18;
144
- return withCarousel && !isDSMobile ? "max-width: 100%;" : '';
145
- }, _ref19 => {
146
- let {
147
- theme,
148
- isDSMobile,
149
- tabType
150
- } = _ref19;
151
- return tabType !== TabTypes.NORMAL_SMALL && !isDSMobile ? "\n &:after {\n content: '';\n position: absolute;\n width: 100%;\n height: 1px;\n box-shadow: 0px 0px 0px 1px ".concat(theme.colors.neutral[400], ";\n pointer-events: none;\n bottom: 0px;\n }\n ") : "";
152
- }, StyledTabButton, _ref20 => {
153
- let {
154
- theme,
155
- isDSMobile
156
- } = _ref20;
157
- return isDSMobile ? "\n \n background: ".concat(theme.colors.brand[200], ";") : "";
158
- }, mobileGradientsSettings, _ref21 => {
159
- let {
160
- isDSMobile,
161
- fixedTabsHeaders
162
- } = _ref21;
163
- return isDSMobile ? "\n ".concat(!fixedTabsHeaders ? "\n z-index: 0;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: thin;\n &::-webkit-scrollbar {\n display: none;\n }" : "\n display: flex;\n ".concat(StyledTabButton, " {\n flex: 1;\n overflow-x: hidden;\n }")) : "";
164
- }, StyledSelectionIndicator, _ref22 => {
165
- let {
166
- indicatorStyle
167
- } = _ref22;
168
- return "\n width: ".concat(indicatorStyle.width, ";\n left: ").concat(indicatorStyle.left, ";\n ");
169
- }, StyledSelectionIndicator, _ref23 => {
170
- let {
171
- theme,
172
- indicatorStyle,
173
- isDSMobile
174
- } = _ref23;
175
- return !isDSMobile ? indicatorStyle.backgroundWithTransparent : theme.colors.brand[600];
176
- });
177
- const StyledRequiredMark = /*#__PURE__*/styled.span.withConfig({
178
- componentId: "sc-3hla56-5"
179
- })(["color:", ";font-size:6px;margin-left:2px;position:absolute;top:5px;"], _ref24 => {
180
- let {
181
- theme
182
- } = _ref24;
183
- return theme.colors.danger[900];
184
- });
185
-
186
- export { StyledRequiredMark, StyledSelectionIndicator, StyledSubTabsList, StyledTabButton, StyledTabList, StyledTabWrapper };
166
+ ${isActive && !disabled ? `
167
+ font-size: 13px;
168
+ color: ${theme.colors.brand[700]};
169
+ line-height: 1.3;
170
+ font-weight: ${theme.fontWeights.regular};
171
+ -webkit-font-smoothing: subpixel-antialiased;
172
+ -webkit-text-stroke: 0.4px ${theme.colors.brand[700]};` : ``}
173
+
174
+ ${!disabled ? `
175
+ &:hover,
176
+ &:focus {
177
+ outline: none;
178
+ color: ${theme.colors.brand[700]};
179
+ ${safariAndFirefoxBold("#006AA9")}
180
+ }` : ``}
181
+
182
+ ` : ``}
183
+ `;
184
+ const StyledSubTabsList = styled.div`
185
+ position: relative;
186
+ display: flex;
187
+ flex-wrap: nowrap;
188
+ flex: 1;
189
+ width: 100%;
190
+ ${({ withCarousel }) => withCarousel ? "max-width: 100%;" : ""}
191
+ `;
192
+ const StyledTabList = styled.div`
193
+ position: relative;
194
+ display: flex;
195
+ flex-wrap: nowrap;
196
+ flex: 1;
197
+ width: 100%;
198
+ ${({ withCarousel, isDSMobile }) => withCarousel && !isDSMobile ? `max-width: 100%;` : ""}
199
+
200
+ ${({ theme, isDSMobile, tabType }) => tabType !== TabTypes.NORMAL_SMALL && !isDSMobile ? `
201
+ &:after {
202
+ content: '';
203
+ position: absolute;
204
+ width: 100%;
205
+ height: 1px;
206
+ box-shadow: 0px 0px 0px 1px ${theme.colors.neutral[400]};
207
+ pointer-events: none;
208
+ bottom: 0px;
209
+ }
210
+ ` : ``}
211
+
212
+ ${StyledTabButton} {
213
+ padding-bottom: 0;
214
+ padding-top: 0;
215
+ }
216
+
217
+ ${({ theme, isDSMobile }) => isDSMobile ? `
218
+
219
+ background: ${theme.colors.brand[200]};` : ``}
220
+
221
+ ${mobileGradientsSettings}
222
+
223
+
224
+ ${({ isDSMobile, fixedTabsHeaders }) => isDSMobile ? `
225
+ ${!fixedTabsHeaders ? `
226
+ z-index: 0;
227
+ overflow-x: auto;
228
+ overflow-y: hidden;
229
+ scrollbar-width: thin;
230
+ &::-webkit-scrollbar {
231
+ display: none;
232
+ }` : `
233
+ display: flex;
234
+ ${StyledTabButton} {
235
+ flex: 1;
236
+ overflow-x: hidden;
237
+ }`}` : ``}
238
+
239
+ ${StyledSelectionIndicator} {
240
+ ${({ indicatorStyle }) => `
241
+ width: ${indicatorStyle.width};
242
+ left: ${indicatorStyle.left};
243
+ `}
244
+ }
245
+
246
+ ${StyledSelectionIndicator} {
247
+ background: ${({ theme, indicatorStyle, isDSMobile }) => !isDSMobile ? indicatorStyle.backgroundWithTransparent : theme.colors.brand[600]};
248
+ }
249
+ `;
250
+ const StyledRequiredMark = styled.span`
251
+ color: ${({ theme }) => theme.colors.danger[900]};
252
+ font-size: 6px;
253
+ margin-left: 2px;
254
+ position: absolute;
255
+ top: 5px;
256
+ `;
257
+ export {
258
+ StyledRequiredMark,
259
+ StyledSelectionIndicator,
260
+ StyledSubTabsList,
261
+ StyledTabButton,
262
+ StyledTabList,
263
+ StyledTabWrapper
264
+ };
265
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/tabBar/styles.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\n/* eslint-disable max-lines */\nimport styled from 'styled-components';\nimport { safariAndFirefoxBold, onlySafariAndFirefox, css } from '@elliemae/ds-system';\nimport { TabTypes } from '../../utils/constants';\nimport type {\n StyledSelectionIndicatoPropsT,\n StyledSubTabsListPropsT,\n StyledTabListPropsT,\n StyledTabButtonPropsT,\n StyledTabWrapperPropsT,\n} from '../../DSTabsTypes';\n\nexport const StyledSelectionIndicator = styled.div<StyledSelectionIndicatoPropsT>`\n position: absolute;\n height: 3px;\n top: ${({ tabType, isDSMobile }) => {\n if (isDSMobile) return `35px`;\n if (tabType === TabTypes.NORMAL_SMALL) return `15px`;\n return `25px`;\n }};\n margin-top: ${({ theme }) => theme.space.xxxs};\n pointer-events: none;\n transition: 200ms cubic-bezier(0.36, 0, 1, 1);\n z-index: 10;\n ${({ isDSMobile }) =>\n isDSMobile\n ? ` \n margin-left: 0;\n margin-top: 3px;\n `\n : ``}\n`;\n\nconst mobileGradientsSettings = css<StyledTabListPropsT>`\n ${({ theme, mobileGradients, isDSMobile, fixedTabsHeaders }) => {\n if (isDSMobile && !fixedTabsHeaders) {\n if (mobileGradients.right && mobileGradients.left)\n return `background: linear-gradient(90deg, rgba(238,238,238,0) 0%, ${theme.colors.brand[200]} 20%, ${theme.colors.brand[200]} 80%, rgba(238,238,238,0) 100%);`;\n if (mobileGradients.right)\n return `background: linear-gradient(90deg, ${theme.colors.brand[200]} 0%, ${theme.colors.brand[200]} 80%, rgba(238,238,238,0) 100%);`;\n if (mobileGradients.left)\n return `background: linear-gradient(90deg, rgba(238,238,238,0) 0%, ${theme.colors.brand[200]} 20%, ${theme.colors.brand[200]} 100%);`;\n }\n return ``;\n }}\n`;\n\nexport const StyledTabWrapper = styled.div<StyledTabWrapperPropsT>`\n display: flex;\n flex: 1;\n flex-wrap: nowrap;\n ${({ fixedTabsHeaders, isDSMobile }) => (!fixedTabsHeaders && isDSMobile ? '' : 'overflow-x: hidden;')}\n ${({ theme, isDSMobile }) => (isDSMobile ? `border-bottom: 1px solid ${theme.colors.brand[300]};` : ``)}\n`;\n\nexport const StyledTabButton = styled.button<StyledTabButtonPropsT>`\n position: relative;\n background-color: transparent;\n border: none;\n cursor: pointer;\n transition: 100ms cubic-bezier(0, 0, 0.42, 1);\n text-transform: ${({ tabType }) => (tabType === TabTypes.SUBTABS ? `capitalize` : `uppercase`)};\n letter-spacing: 0px;\n white-space: nowrap;\n padding: 2px 0;\n margin-right: ${({ fixedTabsHeaders, isDSMobile }) => {\n if (fixedTabsHeaders) return '0px';\n if (!fixedTabsHeaders && isDSMobile) return '14px';\n return '16px';\n }};\n\n margin-left: ${({ fixedTabsHeaders, isDSMobile }) => {\n if (fixedTabsHeaders) return '0px';\n if (!fixedTabsHeaders && isDSMobile) return '14px';\n return '16px';\n }};\n\n color: ${({ theme }) => theme.colors.neutral[700]};\n ${onlySafariAndFirefox('-webkit-text-stroke: 0.4px transparent;')}\n\n ${({ tabType }) => (tabType === TabTypes.NORMAL ? `height: 32px;` : `height: 22px;`)}\n\n ${({ theme, isActive, disabled }) =>\n isActive && !disabled\n ? `\n font-weight: ${theme.fontWeights.semibold};\n ${safariAndFirefoxBold(`#353C46`)}\n\n &:hover {\n ${safariAndFirefoxBold(`#1E79C2`)}\n }\n \n `\n : `\n \n `}\n\n ${({ theme, disabled }) =>\n disabled\n ? `\n color: ${theme.colors.neutral[500]};\n cursor: not-allowed;\n `\n : `\n &:hover {\n color: ${theme.colors.brand[600]};\n }\n `}\n\n\n ${({ theme, showSeparator, tabType }) =>\n showSeparator\n ? `\n &:not(:last-of-type):before\n {\n content: \"\";\n position: absolute;\n width: 1px;\n right: -16px;\n top: 50%;\n transform: translateY(-50%);\n height: ${tabType === TabTypes.SUBTABS ? `10px` : `16px`};\n background: ${theme.colors.neutral[400]};\n }`\n : ``}\n\n ${({ theme, isDSMobile, tabType, isActive }) =>\n !isDSMobile\n ? `\n &:focus {\n outline: none;\n &:after {\n position: absolute;\n content: '';\n top: 0;\n left: -16px;\n width: calc(100% + 32px);\n height: 100%;\n z-index: 5;\n border-radius: 2px;\n border: 2px solid ${theme.colors.brand[700]};\n }\n\n ${\n tabType !== TabTypes.SUBTABS && isActive\n ? `\n &:before {\n position: absolute;\n content: '';\n left: -16px;\n right: 0;\n top: calc(100% - 2px);\n transform: none;\n width: calc(100% + 32px);\n height: 2px;\n z-index: 10;\n background: linear-gradient(to right, transparent 0px, transparent 12px, white 12px, white 16px, transparent 16px,transparent calc(100% - 16px), white calc(100% - 16px), white calc(100% - 12px), transparent calc(100% - 12px), transparent 100%);\n }\n `\n : ``\n }\n }\n \n `\n : ``}\n\n \n \n${({ theme, isActive, disabled, isDSMobile }) =>\n isDSMobile\n ? `\n height: 40px;\n color: ${theme.colors.brand[600]};\n font-weight: ${theme.fontWeights.regular};\n padding: 0;\n font-size: 13px;\n line-height: 1.3;\n ${onlySafariAndFirefox('-webkit-text-stroke: 0.4px transparent;')} \n\n &:focus {\n font-weight: ${theme.fontWeights.regular};\n font-size: 13px;\n ${safariAndFirefoxBold('#006AA9')}\n }\n\n ${\n isActive\n ? `\n font-weight: ${theme.fontWeights.regular};\n font-size: 13px;\n ${safariAndFirefoxBold('#006AA9')}\n `\n : ``\n }\n\n ${\n isActive && !disabled\n ? `\n font-size: 13px;\n color: ${theme.colors.brand[700]};\n line-height: 1.3;\n font-weight: ${theme.fontWeights.regular};\n -webkit-font-smoothing: subpixel-antialiased; \n -webkit-text-stroke: 0.4px ${theme.colors.brand[700]};`\n : ``\n }\n\n ${\n !disabled\n ? `\n &:hover,\n &:focus {\n outline: none;\n color: ${theme.colors.brand[700]};\n ${safariAndFirefoxBold('#006AA9')}\n }`\n : ``\n }\n\n `\n : ``}\n`;\n\nexport const StyledSubTabsList = styled.div<StyledSubTabsListPropsT>`\n position: relative;\n display: flex;\n flex-wrap: nowrap;\n flex: 1;\n width: 100%;\n ${({ withCarousel }) => (withCarousel ? 'max-width: 100%;' : '')}\n`;\n\nexport const StyledTabList = styled.div<StyledTabListPropsT>`\n position: relative;\n display: flex;\n flex-wrap: nowrap;\n flex: 1;\n width: 100%;\n ${({ withCarousel, isDSMobile }) => (withCarousel && !isDSMobile ? `max-width: 100%;` : '')}\n\n ${({ theme, isDSMobile, tabType }) =>\n tabType !== TabTypes.NORMAL_SMALL && !isDSMobile\n ? `\n &:after {\n content: '';\n position: absolute;\n width: 100%;\n height: 1px;\n box-shadow: 0px 0px 0px 1px ${theme.colors.neutral[400]};\n pointer-events: none;\n bottom: 0px;\n }\n `\n : ``}\n\n ${StyledTabButton} {\n padding-bottom: 0;\n padding-top: 0;\n }\n\n ${({ theme, isDSMobile }) =>\n isDSMobile\n ? `\n \n background: ${theme.colors.brand[200]};`\n : ``}\n\n ${mobileGradientsSettings}\n\n\n ${({ isDSMobile, fixedTabsHeaders }) =>\n isDSMobile\n ? `\n ${\n !fixedTabsHeaders\n ? `\n z-index: 0;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: thin;\n &::-webkit-scrollbar {\n display: none;\n }`\n : `\n display: flex;\n ${StyledTabButton} {\n flex: 1;\n overflow-x: hidden;\n }`\n }`\n : ``}\n\n ${StyledSelectionIndicator} {\n ${({ indicatorStyle }) => `\n width: ${indicatorStyle.width};\n left: ${indicatorStyle.left};\n `}\n }\n\n ${StyledSelectionIndicator} {\n background: ${({ theme, indicatorStyle, isDSMobile }) =>\n !isDSMobile ? indicatorStyle.backgroundWithTransparent : theme.colors.brand[600]};\n }\n`;\n\nexport const StyledRequiredMark = styled.span`\n color: ${({ theme }) => theme.colors.danger[900]};\n font-size: 6px;\n margin-left: 2px;\n position: absolute;\n top: 5px;\n`;\n"],
5
+ "mappings": "AAAA;ACEA;AACA;AACA;AASO,MAAM,2BAA2B,OAAO;AAAA;AAAA;AAAA,SAGtC,CAAC,EAAE,SAAS,iBAAiB;AAClC,MAAI;AAAY,WAAO;AACvB,MAAI,YAAY,SAAS;AAAc,WAAO;AAC9C,SAAO;AAAA;AAAA,gBAEK,CAAC,EAAE,YA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,EAAE,YAAY,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,81 +1,62 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useContext, useState, useCallback, useEffect, useLayoutEffect } from 'react';
3
- import useResizeObserver from '@react-hook/resize-observer';
4
- import { isElementVisible, shouldHaveLeftGradient, shouldHaveRightGradient } from '../../utils/helpers.js';
5
- import { DSTabsContext } from '../../DSTabsCTX.js';
6
- import { defaultIndicatorStyles } from '../../utils/constants.js';
7
-
1
+ import * as React from "react";
2
+ import { useCallback, useLayoutEffect, useState, useContext } from "react";
3
+ import useResizeObserver from "@react-hook/resize-observer";
4
+ import { isElementVisible, shouldHaveLeftGradient, shouldHaveRightGradient } from "../../utils/helpers";
5
+ import { DSTabsContext } from "../../DSTabsCTX";
6
+ import { defaultIndicatorStyles } from "../../utils/constants";
8
7
  const useTabBar = () => {
9
8
  const {
10
9
  actualActiveTab,
11
10
  actualActiveTabRef,
12
11
  tabsListRef,
13
- props: {
14
- showSelectionIndicator,
15
- isDSMobile,
16
- fixedTabsHeaders
17
- }
12
+ props: { showSelectionIndicator, isDSMobile, fixedTabsHeaders }
18
13
  } = useContext(DSTabsContext);
19
- const [mobileGradients, setMobileGradients] = useState({
20
- left: false,
21
- right: false
22
- });
14
+ const [mobileGradients, setMobileGradients] = useState({ left: false, right: false });
23
15
  const [indicatorStyle, setIndicatorStyle] = useState(defaultIndicatorStyles);
24
16
  const getIndicatorStyles = useCallback(() => {
25
17
  if (tabsListRef.current) {
26
18
  const tabList = tabsListRef.current;
27
19
  const activeTabButton = actualActiveTabRef.current;
28
- if (!activeTabButton || !isElementVisible(activeTabButton, tabList)) return defaultIndicatorStyles; // The missingMargins are to make the selection indicator white marks work properly in desktop, we need
29
- // the full width of the tab button with margins.
30
-
20
+ if (!activeTabButton || !isElementVisible(activeTabButton, tabList))
21
+ return defaultIndicatorStyles;
31
22
  const missingMargins = isDSMobile ? 0 : 16;
32
- const tabClientWidth = isDSMobile && !fixedTabsHeaders ? activeTabButton.clientWidth : activeTabButton.clientWidth + missingMargins * 2; // The reason why we use the tabList.scrollLeft is due to the centerOnTabChange (only in Mobile and FlexibleTabs)
33
- // behavior that adds scroll to the tabList
34
-
23
+ const tabClientWidth = isDSMobile && !fixedTabsHeaders ? activeTabButton.clientWidth : activeTabButton.clientWidth + missingMargins * 2;
35
24
  const position = isDSMobile && !fixedTabsHeaders ? activeTabButton.getBoundingClientRect().left - tabList.getBoundingClientRect().left + tabList.scrollLeft : activeTabButton.getBoundingClientRect().left - tabList.getBoundingClientRect().left - missingMargins;
36
- const backgroundWithTransparent = "linear-gradient(to right, transparent 0px, transparent 16px, #1E79C2 16px, #1E79C2 ".concat(tabClientWidth - 16, "px,transparent ").concat(tabClientWidth - 16, "px,transparent ").concat(tabClientWidth, "px )");
25
+ const backgroundWithTransparent = `linear-gradient(to right, transparent 0px, transparent 16px, #1E79C2 16px, #1E79C2 ${tabClientWidth - 16}px,transparent ${tabClientWidth - 16}px,transparent ${tabClientWidth}px )`;
37
26
  return {
38
- left: "".concat(position, "px"),
39
- width: "".concat(tabClientWidth, "px"),
27
+ left: `${position}px`,
28
+ width: `${tabClientWidth}px`,
40
29
  backgroundWithTransparent
41
30
  };
42
31
  }
43
-
44
32
  return defaultIndicatorStyles;
45
33
  }, [actualActiveTabRef, fixedTabsHeaders, isDSMobile, tabsListRef]);
46
34
  const updateIndicatorStyle = useCallback(() => setTimeout(() => setIndicatorStyle(getIndicatorStyles()), 100), [getIndicatorStyles, setIndicatorStyle]);
47
35
  useResizeObserver(tabsListRef, updateIndicatorStyle);
48
36
  const updateMobileGradients = useCallback(() => {
49
37
  if (tabsListRef.current && isDSMobile && !fixedTabsHeaders) {
50
- const {
51
- scrollLeft,
52
- scrollWidth,
53
- clientWidth
54
- } = tabsListRef.current;
38
+ const { scrollLeft, scrollWidth, clientWidth } = tabsListRef.current;
55
39
  setMobileGradients({
56
40
  left: shouldHaveLeftGradient(scrollLeft),
57
41
  right: shouldHaveRightGradient(scrollLeft, clientWidth, scrollWidth)
58
42
  });
59
43
  }
60
44
  }, [fixedTabsHeaders, isDSMobile, tabsListRef]);
61
- useEffect(() => {
62
- if (showSelectionIndicator) {
63
- updateIndicatorStyle();
64
- }
65
-
66
- if (isDSMobile && !fixedTabsHeaders) {
67
- updateMobileGradients();
68
- }
69
- }, [updateIndicatorStyle, showSelectionIndicator, actualActiveTab, updateMobileGradients, isDSMobile, fixedTabsHeaders]);
70
45
  useLayoutEffect(() => {
71
46
  if (showSelectionIndicator) {
72
47
  updateIndicatorStyle();
73
48
  }
74
-
75
49
  if (isDSMobile && !fixedTabsHeaders) {
76
50
  updateMobileGradients();
77
51
  }
78
- }, [updateMobileGradients, showSelectionIndicator, updateIndicatorStyle, isDSMobile, fixedTabsHeaders]);
52
+ }, [
53
+ updateMobileGradients,
54
+ showSelectionIndicator,
55
+ updateIndicatorStyle,
56
+ isDSMobile,
57
+ fixedTabsHeaders,
58
+ actualActiveTab
59
+ ]);
79
60
  return {
80
61
  updateIndicatorStyle,
81
62
  setIndicatorStyle,
@@ -84,5 +65,7 @@ const useTabBar = () => {
84
65
  updateMobileGradients
85
66
  };
86
67
  };
87
-
88
- export { useTabBar };
68
+ export {
69
+ useTabBar
70
+ };
71
+ //# sourceMappingURL=useTabBar.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/tabBar/useTabBar.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\nimport { useCallback, useLayoutEffect, useState, useContext } from 'react';\nimport useResizeObserver from '@react-hook/resize-observer';\nimport { isElementVisible, shouldHaveLeftGradient, shouldHaveRightGradient } from '../../utils/helpers';\nimport { DSTabsContext } from '../../DSTabsCTX';\nimport { defaultIndicatorStyles } from '../../utils/constants';\nimport type { IndicatorStyleT, MobileGradientsT, UseTabBarReturnTypeT } from '../../DSTabsTypes';\n\nexport const useTabBar = (): UseTabBarReturnTypeT => {\n const {\n actualActiveTab,\n actualActiveTabRef,\n tabsListRef,\n props: { showSelectionIndicator, isDSMobile, fixedTabsHeaders },\n } = useContext(DSTabsContext);\n\n const [mobileGradients, setMobileGradients] = useState<MobileGradientsT>({ left: false, right: false });\n const [indicatorStyle, setIndicatorStyle] = useState<IndicatorStyleT>(defaultIndicatorStyles);\n\n const getIndicatorStyles = useCallback(() => {\n if (tabsListRef.current) {\n const tabList = tabsListRef.current;\n const activeTabButton = actualActiveTabRef.current;\n\n if (!activeTabButton || !isElementVisible(activeTabButton, tabList)) return defaultIndicatorStyles;\n\n // The missingMargins are to make the selection indicator white marks work properly in desktop, we need\n // the full width of the tab button with margins.\n const missingMargins = isDSMobile ? 0 : 16;\n\n const tabClientWidth =\n isDSMobile && !fixedTabsHeaders\n ? activeTabButton.clientWidth\n : activeTabButton.clientWidth + missingMargins * 2;\n\n // The reason why we use the tabList.scrollLeft is due to the centerOnTabChange (only in Mobile and FlexibleTabs)\n // behavior that adds scroll to the tabList\n const position =\n isDSMobile && !fixedTabsHeaders\n ? activeTabButton.getBoundingClientRect().left - tabList.getBoundingClientRect().left + tabList.scrollLeft\n : activeTabButton.getBoundingClientRect().left - tabList.getBoundingClientRect().left - missingMargins;\n\n const backgroundWithTransparent = `linear-gradient(to right, transparent 0px, transparent 16px, #1E79C2 16px, #1E79C2 ${\n tabClientWidth - 16\n }px,transparent ${tabClientWidth - 16}px,transparent ${tabClientWidth}px )`;\n\n return {\n left: `${position}px`,\n width: `${tabClientWidth}px`,\n backgroundWithTransparent,\n };\n }\n return defaultIndicatorStyles;\n }, [actualActiveTabRef, fixedTabsHeaders, isDSMobile, tabsListRef]);\n\n const updateIndicatorStyle = useCallback(\n () => setTimeout(() => setIndicatorStyle(getIndicatorStyles()), 100),\n [getIndicatorStyles, setIndicatorStyle],\n );\n\n useResizeObserver(tabsListRef, updateIndicatorStyle);\n\n const updateMobileGradients = useCallback(() => {\n if (tabsListRef.current && isDSMobile && !fixedTabsHeaders) {\n const { scrollLeft, scrollWidth, clientWidth } = tabsListRef.current;\n setMobileGradients({\n left: shouldHaveLeftGradient(scrollLeft),\n right: shouldHaveRightGradient(scrollLeft, clientWidth, scrollWidth),\n });\n }\n }, [fixedTabsHeaders, isDSMobile, tabsListRef]);\n\n useLayoutEffect(() => {\n if (showSelectionIndicator) {\n updateIndicatorStyle();\n }\n if (isDSMobile && !fixedTabsHeaders) {\n updateMobileGradients();\n }\n }, [\n updateMobileGradients,\n showSelectionIndicator,\n updateIndicatorStyle,\n isDSMobile,\n fixedTabsHeaders,\n actualActiveTab,\n ]);\n\n return {\n updateIndicatorStyle,\n setIndicatorStyle,\n indicatorStyle,\n mobileGradients,\n updateMobileGradients,\n };\n};\n"],
5
+ "mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AAGO,MAAM,YAAY,MAA4B;AACnD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,wBAAwB,YAAY;AAAA,MAC3C,WAAW;AAEf,QAAM,CAAC,iBAAiB,sBAAsB,SAA2B,EAAE,MAAM,OAAO,OAAO;AAC/F,QAAM,CAAC,gBAAgB,qBAAqB,SAA0B;AAEtE,QAAM,qBAAqB,YAAY,MAAM;AAC3C,QAAI,YAAY,SAAS;AACvB,YAAM,UAAU,YAAY;AAC5B,YAAM,kBAAkB,mBAAmB;AAE3C,UAAI,CAAC,mBAAmB,CAAC,iBAAiB,iBAAiB;AAAU,eAAO;AAI5E,YAAM,iBAAiB,aAAa,IAAI;AAExC,YAAM,iBACJ,cAAc,CAAC,mBACX,gBAAgB,cAChB,gBAAgB,cAAc,iBAAiB;AAIrD,YAAM,WACJ,cAAc,CAAC,mBACX,gBAAgB,wBAAwB,OAAO,QAAQ,wBAAwB,OAAO,QAAQ,aAC9F,gBAAgB,wBAAwB,OAAO,QAAQ,wBAAwB,OAAO;AAE5F,YAAM,4B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