@cleartrip/ct-design-tabs 1.1.0 → 1.1.2

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.
@@ -1,374 +1,181 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined'
3
- ? factory(
4
- exports,
5
- require('react/jsx-runtime'),
6
- require('styled-components'),
7
- require('react'),
8
- require('@cleartrip/ct-design-button'),
9
- require('@cleartrip/ct-design-use-theme'),
10
- require('@cleartrip/ct-design-typography'),
11
- require('@cleartrip/ct-design-use-merge-refs'),
12
- require('@cleartrip/ct-design-use-props-state')
13
- )
14
- : typeof define === 'function' && define.amd
15
- ? define(
16
- [
17
- 'exports',
18
- 'react/jsx-runtime',
19
- 'styled-components',
20
- 'react',
21
- '@cleartrip/ct-design-button',
22
- '@cleartrip/ct-design-use-theme',
23
- '@cleartrip/ct-design-typography',
24
- '@cleartrip/ct-design-use-merge-refs',
25
- '@cleartrip/ct-design-use-props-state',
26
- ],
27
- factory
28
- )
29
- : ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
30
- factory(
31
- (global.CTDesignSystemTabs = {}),
32
- global.jsxRuntime,
33
- global.styled,
34
- global.React,
35
- global.ctDesignButton,
36
- global.useTheme,
37
- global.ctDesignTypography,
38
- global.useMergeRefs,
39
- global.usePropState
40
- ));
41
- })(
42
- this,
43
- function (
44
- exports,
45
- jsxRuntime,
46
- styled,
47
- react,
48
- ctDesignButton,
49
- useTheme,
50
- ctDesignTypography,
51
- useMergeRefs,
52
- usePropState
53
- ) {
54
- 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('styled-components'), require('react'), require('@cleartrip/ct-design-button'), require('@cleartrip/ct-design-use-theme'), require('@cleartrip/ct-design-typography'), require('@cleartrip/ct-design-use-merge-refs'), require('@cleartrip/ct-design-use-prop-state')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'styled-components', 'react', '@cleartrip/ct-design-button', '@cleartrip/ct-design-use-theme', '@cleartrip/ct-design-typography', '@cleartrip/ct-design-use-merge-refs', '@cleartrip/ct-design-use-prop-state'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemTabs = {}, global.jsxRuntime, global.styled, global.React, global.ctDesignButton, global.useTheme, global.ctDesignTypography, global.useMergeRefs, global.usePropState));
5
+ })(this, (function (exports, jsxRuntime, styled, react, ctDesignButton, useTheme, ctDesignTypography, useMergeRefs, usePropState) { 'use strict';
55
6
 
56
- function _interopDefault(e) {
57
- return e && e.__esModule ? e : { default: e };
58
- }
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
59
8
 
60
- var styled__default = /*#__PURE__*/ _interopDefault(styled);
61
- var useTheme__default = /*#__PURE__*/ _interopDefault(useTheme);
62
- var useMergeRefs__default = /*#__PURE__*/ _interopDefault(useMergeRefs);
63
- var usePropState__default = /*#__PURE__*/ _interopDefault(usePropState);
9
+ var styled__default = /*#__PURE__*/_interopDefault(styled);
10
+ var useTheme__default = /*#__PURE__*/_interopDefault(useTheme);
11
+ var useMergeRefs__default = /*#__PURE__*/_interopDefault(useMergeRefs);
12
+ var usePropState__default = /*#__PURE__*/_interopDefault(usePropState);
64
13
 
65
- /******************************************************************************
66
- Copyright (c) Microsoft Corporation.
67
-
68
- Permission to use, copy, modify, and/or distribute this software for any
69
- purpose with or without fee is hereby granted.
70
-
71
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
72
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
73
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
74
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
75
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
76
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
77
- PERFORMANCE OF THIS SOFTWARE.
14
+ /******************************************************************************
15
+ Copyright (c) Microsoft Corporation.
16
+
17
+ Permission to use, copy, modify, and/or distribute this software for any
18
+ purpose with or without fee is hereby granted.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
+ PERFORMANCE OF THIS SOFTWARE.
78
27
  ***************************************************************************** */
79
- /* global Reflect, Promise, SuppressedError, Symbol */
28
+ /* global Reflect, Promise, SuppressedError, Symbol */
29
+
30
+ var __assign = function () {
31
+ __assign = Object.assign || function __assign(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
35
+ }
36
+ return t;
37
+ };
38
+ return __assign.apply(this, arguments);
39
+ };
40
+ function __rest(s, e) {
41
+ var t = {};
42
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
43
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
44
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
45
+ }
46
+ return t;
47
+ }
48
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
49
+ var e = new Error(message);
50
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
+ };
80
52
 
81
- var __assign = function () {
82
- __assign =
83
- Object.assign ||
84
- function __assign(t) {
85
- for (var s, i = 1, n = arguments.length; i < n; i++) {
86
- s = arguments[i];
87
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
88
- }
89
- return t;
90
- };
91
- return __assign.apply(this, arguments);
92
- };
93
- function __rest(s, e) {
94
- var t = {};
95
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
96
- if (s != null && typeof Object.getOwnPropertySymbols === 'function')
97
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
98
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
99
- }
100
- return t;
101
- }
102
- typeof SuppressedError === 'function'
103
- ? SuppressedError
104
- : function (error, suppressed, message) {
105
- var e = new Error(message);
106
- return (e.name = 'SuppressedError'), (e.error = error), (e.suppressed = suppressed), e;
107
- };
53
+ var getTabStyles = function (_a) {
54
+ var theme = _a.theme, isHorizontal = _a.isHorizontal, width = _a.width, height = _a.height, rest = __rest(_a, ["theme", "isHorizontal", "width", "height"]);
55
+ return (__assign({ display: 'flex', flexDirection: isHorizontal ? 'row' : 'column', width: width || isHorizontal ? '100%' : '', height: height || !isHorizontal ? '100%' : '', justifyContent: 'space-between', borderBottomWidth: theme.border.width.sm, borderColor: theme.color.border.default, borderBottomStyle: theme.border.style.solid, cursor: 'pointer', position: 'relative' }, rest));
56
+ };
108
57
 
109
- var getTabStyles = function (_a) {
110
- var theme = _a.theme,
111
- isHorizontal = _a.isHorizontal,
112
- width = _a.width,
113
- height = _a.height,
114
- rest = __rest(_a, ['theme', 'isHorizontal', 'width', 'height']);
115
- return __assign(
116
- {
117
- display: 'flex',
118
- flexDirection: isHorizontal ? 'row' : 'column',
119
- width: width || isHorizontal ? '100%' : '',
120
- height: height || !isHorizontal ? '100%' : '',
121
- justifyContent: 'space-between',
122
- borderBottomWidth: theme.border.width.sm,
123
- borderColor: theme.color.border.default,
124
- borderBottomStyle: theme.border.style.solid,
125
- cursor: 'pointer',
126
- position: 'relative',
127
- },
128
- rest
129
- );
130
- };
58
+ var getTabItemStyles = function (_a) {
59
+ _a.theme; var rest = __rest(_a, ["theme"]);
60
+ return (__assign({ backgroundColor: 'transparent', outline: 0, border: 0 }, rest));
61
+ };
62
+ var getLabelVariant = function (_a) {
63
+ var size = _a.size;
64
+ switch (size) {
65
+ case 'small': {
66
+ return ctDesignTypography.TypographyVariant.B2;
67
+ }
68
+ case 'medium': {
69
+ return ctDesignTypography.TypographyVariant.B1;
70
+ }
71
+ case 'large': {
72
+ return ctDesignTypography.TypographyVariant.B1;
73
+ }
74
+ default: {
75
+ return ctDesignTypography.TypographyVariant.B2;
76
+ }
77
+ }
78
+ };
79
+ var getTabLabelColor = function (_a) {
80
+ var selected = _a.selected, theme = _a.theme, focusColor = _a.focusColor, color = _a.color;
81
+ if (selected) {
82
+ return focusColor || color || theme.color.tab.selectedPrimaryLabel;
83
+ }
84
+ else {
85
+ return color || theme.color.tab.nonSelectedPrimaryLabel;
86
+ }
87
+ };
88
+ var TabItem = react.forwardRef(function (props) {
89
+ var tabKey = props.tabKey, onClick = props.onClick, tabIndex = props.tabIndex, _a = props.selected, selected = _a === void 0 ? false : _a, label = props.label, disabled = props.disabled, size = props.size, _b = props.tabItemCSS, tabItemCSS = _b === void 0 ? { label: {}, Root: {} } : _b, css = props.css, focusColor = props.focusColor, children = props.children;
90
+ var theme = useTheme__default.default();
91
+ var tabItemStyles = getTabItemStyles(__assign(__assign({ theme: theme }, css), tabItemCSS === null || tabItemCSS === void 0 ? void 0 : tabItemCSS.Root));
92
+ var handleClick = react.useCallback(function (event) {
93
+ if (!disabled) {
94
+ onClick(event, props);
95
+ }
96
+ }, [tabKey, onClick]);
97
+ var _c = tabItemCSS.label, color = _c.color; __rest(_c, ["color"]);
98
+ return (jsxRuntime.jsx(ctDesignButton.Button, __assign({ disabled: disabled, css: tabItemStyles, onClick: handleClick, tabIndex: tabIndex }, { children: label ? (jsxRuntime.jsx(ctDesignTypography.Typography, __assign({ variant: getLabelVariant({ size: size }), colorCode: getTabLabelColor({ selected: selected, theme: theme, focusColor: focusColor, color: color }) }, { children: label }))) : (children) })));
99
+ });
131
100
 
132
- var getTabItemStyles = function (_a) {
133
- _a.theme;
134
- var rest = __rest(_a, ['theme']);
135
- return __assign({ backgroundColor: 'transparent', outline: 0, border: 0 }, rest);
136
- };
137
- var getLabelVariant = function (_a) {
138
- var size = _a.size;
139
- switch (size) {
140
- case 'small': {
141
- return ctDesignTypography.TypographyVariant.B2;
142
- }
143
- case 'medium': {
144
- return ctDesignTypography.TypographyVariant.B1;
145
- }
146
- case 'large': {
147
- return ctDesignTypography.TypographyVariant.B1;
148
- }
149
- default: {
150
- return ctDesignTypography.TypographyVariant.B2;
151
- }
152
- }
153
- };
154
- var getTabLabelColor = function (_a) {
155
- var selected = _a.selected,
156
- theme = _a.theme,
157
- focusColor = _a.focusColor,
158
- color = _a.color;
159
- if (selected) {
160
- return focusColor || color || theme.color.tab.selectedPrimaryLabel;
161
- } else {
162
- return color || theme.color.tab.nonSelectedPrimaryLabel;
163
- }
164
- };
165
- var TabItem = react.forwardRef(function (props) {
166
- var tabKey = props.tabKey,
167
- onClick = props.onClick,
168
- tabIndex = props.tabIndex,
169
- _a = props.selected,
170
- selected = _a === void 0 ? false : _a,
171
- label = props.label,
172
- disabled = props.disabled,
173
- size = props.size,
174
- _b = props.tabItemCSS,
175
- tabItemCSS = _b === void 0 ? { label: {}, Root: {} } : _b,
176
- css = props.css,
177
- focusColor = props.focusColor,
178
- children = props.children;
179
- var theme = useTheme__default.default();
180
- var tabItemStyles = getTabItemStyles(
181
- __assign(
182
- __assign({ theme: theme }, css),
183
- tabItemCSS === null || tabItemCSS === void 0 ? void 0 : tabItemCSS.Root
184
- )
185
- );
186
- var handleClick = react.useCallback(
187
- function (event) {
188
- if (!disabled) {
189
- onClick(event, props);
190
- }
191
- },
192
- [tabKey, onClick]
193
- );
194
- var _c = tabItemCSS.label,
195
- color = _c.color;
196
- __rest(_c, ['color']);
197
- return jsxRuntime.jsx(
198
- ctDesignButton.Button,
199
- __assign(
200
- { disabled: disabled, css: tabItemStyles, onClick: handleClick, tabIndex: tabIndex },
201
- {
202
- children: label
203
- ? jsxRuntime.jsx(
204
- ctDesignTypography.Typography,
205
- __assign(
206
- {
207
- variant: getLabelVariant({ size: size }),
208
- colorCode: getTabLabelColor({
209
- selected: selected,
210
- theme: theme,
211
- focusColor: focusColor,
212
- color: color,
213
- }),
214
- },
215
- { children: label }
216
- )
217
- )
218
- : children,
219
- }
220
- )
221
- );
222
- });
101
+ var useMounted = function () {
102
+ var _a = react.useState(false), isMounted = _a[0], setIsMounted = _a[1];
103
+ react.useEffect(function () {
104
+ setIsMounted(true);
105
+ }, []);
106
+ return isMounted;
107
+ };
108
+ var StyledTab = styled__default.default.div(function (_a) {
109
+ var css = _a.css, theme = _a.theme, _b = _a.isHorizontal, isHorizontal = _b === void 0 ? true : _b, width = _a.width, height = _a.height;
110
+ return getTabStyles(__assign({ theme: theme, isHorizontal: isHorizontal, width: width, height: height }, css));
111
+ });
112
+ var StyledFlexContainer = styled__default.default.div(function (_a) {
113
+ _a.theme;
114
+ return ({
115
+ display: 'flex',
116
+ flexDirection: 'row',
117
+ });
118
+ });
119
+ var Indicator = styled__default.default.div(function (_a) {
120
+ var theme = _a.theme, width = _a.width, left = _a.left, color = _a.color;
121
+ return ({
122
+ position: 'absolute',
123
+ height: '2px',
124
+ bottom: 0,
125
+ transition: 'all ease-in 0.3s',
126
+ backgroundColor: color || theme.color.background.primary,
127
+ width: width,
128
+ left: left,
129
+ });
130
+ });
131
+ var Tab = react.forwardRef(function (_a, forwardedRef) {
132
+ _a.children; var tabList = _a.tabList, _b = _a.selectedTabIndex, selectedTabIndex = _b === void 0 ? 0 : _b, onClick = _a.onClick, _c = _a.isHorizontal, isHorizontal = _c === void 0 ? true : _c, css = _a.css, tabCSS = _a.tabCSS, focusColor = _a.focusColor, props = __rest(_a, ["children", "tabList", "selectedTabIndex", "onClick", "isHorizontal", "css", "tabCSS", "focusColor"]);
133
+ var theme = styled.useTheme();
134
+ var isMounted = useMounted();
135
+ var _d = usePropState__default.default(selectedTabIndex), selectedIndex = _d[0], setSelectedIndex = _d[1];
136
+ var _e = react.useState({ width: 0, left: 0 }), indicatorStyle = _e[0], setIndicatorStyle = _e[1];
137
+ var listRef = react.useRef(null);
138
+ var tabsRef = react.useRef(null);
139
+ var handleRef = useMergeRefs__default.default(react.forwardRef, tabsRef);
140
+ var updateIndicatorState = function () {
141
+ var _a, _b;
142
+ if (listRef.current && selectedIndex !== undefined) {
143
+ var children = listRef.current.children;
144
+ var tab = children[selectedIndex];
145
+ var tabMeta = tab ? tab.getBoundingClientRect() : { left: 0, width: 0 };
146
+ var rect = (_a = tabsRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
147
+ var tabsMeta = {
148
+ scrollLeft: ((_b = tabsRef.current) === null || _b === void 0 ? void 0 : _b.scrollLeft) || 0,
149
+ left: (rect === null || rect === void 0 ? void 0 : rect.left) || 0,
150
+ };
151
+ var correction = tabsMeta.scrollLeft;
152
+ var startValue = tabMeta.left - tabsMeta.left + correction;
153
+ var newIndicatorStyle = { left: startValue, width: tabMeta.width };
154
+ var dStart = Math.abs(indicatorStyle.left - newIndicatorStyle.left);
155
+ var dSize = Math.abs(indicatorStyle.width - newIndicatorStyle.width);
156
+ if (dStart >= 1 || dSize >= 1) {
157
+ setIndicatorStyle(newIndicatorStyle);
158
+ }
159
+ }
160
+ };
161
+ react.useEffect(function () {
162
+ updateIndicatorState();
163
+ }, [selectedIndex]);
164
+ var handleClick = function (e, tabItem) {
165
+ setSelectedIndex(tabItem.tabIndex || 0);
166
+ if (onClick) {
167
+ onClick(e, tabItem);
168
+ }
169
+ };
170
+ var tabItemList = tabList.map(function (item, index) {
171
+ return (jsxRuntime.jsx(TabItem, { selected: index === selectedIndex, tabIndex: index, tabKey: index, onClick: handleClick, label: item.label, tabItemCSS: tabCSS === null || tabCSS === void 0 ? void 0 : tabCSS.TabItemCSS, focusColor: focusColor }, index));
172
+ });
173
+ var indicatorStyles = __assign(__assign({}, indicatorStyle), tabCSS === null || tabCSS === void 0 ? void 0 : tabCSS.IndicatorCSS);
174
+ return (jsxRuntime.jsxs(StyledTab, __assign({ ref: handleRef, theme: theme, isHorizontal: isHorizontal, css: __assign(__assign({}, css), tabCSS === null || tabCSS === void 0 ? void 0 : tabCSS.Root) }, props, { children: [jsxRuntime.jsx(StyledFlexContainer, __assign({ ref: listRef }, { children: tabItemList })), isMounted && jsxRuntime.jsx(Indicator, __assign({ color: focusColor }, indicatorStyles))] })));
175
+ });
223
176
 
224
- var useMounted = function () {
225
- var _a = react.useState(false),
226
- isMounted = _a[0],
227
- setIsMounted = _a[1];
228
- react.useEffect(function () {
229
- setIsMounted(true);
230
- }, []);
231
- return isMounted;
232
- };
233
- var StyledTab = styled__default.default.div(function (_a) {
234
- var css = _a.css,
235
- theme = _a.theme,
236
- _b = _a.isHorizontal,
237
- isHorizontal = _b === void 0 ? true : _b,
238
- width = _a.width,
239
- height = _a.height;
240
- return getTabStyles(
241
- __assign({ theme: theme, isHorizontal: isHorizontal, width: width, height: height }, css)
242
- );
243
- });
244
- var StyledFlexContainer = styled__default.default.div(function (_a) {
245
- _a.theme;
246
- return {
247
- display: 'flex',
248
- flexDirection: 'row',
249
- };
250
- });
251
- var Indicator = styled__default.default.div(function (_a) {
252
- var theme = _a.theme,
253
- width = _a.width,
254
- left = _a.left,
255
- color = _a.color;
256
- return {
257
- position: 'absolute',
258
- height: '2px',
259
- bottom: 0,
260
- transition: 'all ease-in 0.3s',
261
- backgroundColor: color || theme.color.background.primary,
262
- width: width,
263
- left: left,
264
- };
265
- });
266
- var Tab = react.forwardRef(function (_a, forwardedRef) {
267
- _a.children;
268
- var tabList = _a.tabList,
269
- _b = _a.selectedTabIndex,
270
- selectedTabIndex = _b === void 0 ? 0 : _b,
271
- onClick = _a.onClick,
272
- _c = _a.isHorizontal,
273
- isHorizontal = _c === void 0 ? true : _c,
274
- css = _a.css,
275
- tabCSS = _a.tabCSS,
276
- focusColor = _a.focusColor,
277
- props = __rest(_a, [
278
- 'children',
279
- 'tabList',
280
- 'selectedTabIndex',
281
- 'onClick',
282
- 'isHorizontal',
283
- 'css',
284
- 'tabCSS',
285
- 'focusColor',
286
- ]);
287
- var theme = styled.useTheme();
288
- var isMounted = useMounted();
289
- var _d = usePropState__default.default(selectedTabIndex),
290
- selectedIndex = _d[0],
291
- setSelectedIndex = _d[1];
292
- var _e = react.useState({ width: 0, left: 0 }),
293
- indicatorStyle = _e[0],
294
- setIndicatorStyle = _e[1];
295
- var listRef = react.useRef(null);
296
- var tabsRef = react.useRef(null);
297
- var handleRef = useMergeRefs__default.default(react.forwardRef, tabsRef);
298
- var updateIndicatorState = function () {
299
- var _a, _b;
300
- if (listRef.current && selectedIndex !== undefined) {
301
- var children = listRef.current.children;
302
- var tab = children[selectedIndex];
303
- var tabMeta = tab ? tab.getBoundingClientRect() : { left: 0, width: 0 };
304
- var rect = (_a = tabsRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
305
- var tabsMeta = {
306
- scrollLeft: ((_b = tabsRef.current) === null || _b === void 0 ? void 0 : _b.scrollLeft) || 0,
307
- left: (rect === null || rect === void 0 ? void 0 : rect.left) || 0,
308
- };
309
- var correction = tabsMeta.scrollLeft;
310
- var startValue = tabMeta.left - tabsMeta.left + correction;
311
- var newIndicatorStyle = { left: startValue, width: tabMeta.width };
312
- var dStart = Math.abs(indicatorStyle.left - newIndicatorStyle.left);
313
- var dSize = Math.abs(indicatorStyle.width - newIndicatorStyle.width);
314
- if (dStart >= 1 || dSize >= 1) {
315
- setIndicatorStyle(newIndicatorStyle);
316
- }
317
- }
318
- };
319
- react.useEffect(
320
- function () {
321
- updateIndicatorState();
322
- },
323
- [selectedIndex]
324
- );
325
- var handleClick = function (e, tabItem) {
326
- setSelectedIndex(tabItem.tabIndex || 0);
327
- if (onClick) {
328
- onClick(e, tabItem);
329
- }
330
- };
331
- var tabItemList = tabList.map(function (item, index) {
332
- return jsxRuntime.jsx(
333
- TabItem,
334
- {
335
- selected: index === selectedIndex,
336
- tabIndex: index,
337
- tabKey: index,
338
- onClick: handleClick,
339
- label: item.label,
340
- tabItemCSS: tabCSS === null || tabCSS === void 0 ? void 0 : tabCSS.TabItemCSS,
341
- focusColor: focusColor,
342
- },
343
- index
344
- );
345
- });
346
- var indicatorStyles = __assign(
347
- __assign({}, indicatorStyle),
348
- tabCSS === null || tabCSS === void 0 ? void 0 : tabCSS.IndicatorCSS
349
- );
350
- return jsxRuntime.jsxs(
351
- StyledTab,
352
- __assign(
353
- {
354
- ref: handleRef,
355
- theme: theme,
356
- isHorizontal: isHorizontal,
357
- css: __assign(__assign({}, css), tabCSS === null || tabCSS === void 0 ? void 0 : tabCSS.Root),
358
- },
359
- props,
360
- {
361
- children: [
362
- jsxRuntime.jsx(StyledFlexContainer, __assign({ ref: listRef }, { children: tabItemList })),
363
- isMounted && jsxRuntime.jsx(Indicator, __assign({ color: focusColor }, indicatorStyles)),
364
- ],
365
- }
366
- )
367
- );
368
- });
177
+ exports.TabItem = TabItem;
178
+ exports.Tabs = Tab;
369
179
 
370
- exports.TabItem = TabItem;
371
- exports.Tabs = Tab;
372
- }
373
- );
180
+ }));
374
181
  //# sourceMappingURL=ct-design-tabs.umd.js.map