@@ -7,6 +7,7 @@ import { useComponentConfig } from '../hooks/useComponentConfig';
77import { useHorizontalScrollToTarget } from '../hooks/useHorizontalScrollToTarget' ;
88import { HStack } from '../layout' ;
99import type { BoxBaseProps } from '../layout/Box' ;
10+ import type { StylesAndClassNames } from '../types' ;
1011
1112import {
1213 TabsScrollAreaOverflowIndicator ,
@@ -24,12 +25,27 @@ export type TabsScrollAreaRenderProps = {
2425 onActiveTabElementChange : ( element : HTMLElement | null ) => void ;
2526} ;
2627
28+ /**
29+ * Static class names for TabsScrollArea component parts.
30+ * Use these selectors to target specific elements with CSS.
31+ */
32+ export const tabsScrollAreaClassNames = {
33+ /** Root layout element */
34+ root : 'cds-TabsScrollArea' ,
35+ /** Horizontal scroll region wrapping `Tabs` */
36+ scrollContainer : 'cds-TabsScrollArea-scrollContainer' ,
37+ /** Applied to each overflow indicator's root */
38+ overflowIndicator : 'cds-TabsScrollArea-overflowIndicator' ,
39+ /** Applied to each overflow indicator's icon button */
40+ overflowIndicatorButton : 'cds-TabsScrollArea-overflowIndicatorButton' ,
41+ /** Applied to each overflow indicator's icon button container */
42+ overflowIndicatorButtonContainer : 'cds-TabsScrollArea-overflowIndicatorButtonContainer' ,
43+ /** Applied to each overflow indicator's gradient */
44+ overflowIndicatorGradient : 'cds-TabsScrollArea-overflowIndicatorGradient' ,
45+ } as const ;
46+
2747export type TabsScrollAreaBaseProps = Omit < BoxBaseProps , 'children' | 'style' > &
2848 Pick < SharedAccessibilityProps , 'id' | 'accessibilityLabelId' | 'accessibilityDescriptionId' > & {
29- /**
30- * Render function that receives `onActiveTabElementChange` (wire to `Tabs` as `onActiveTabElementChange`).
31- */
32- children : ( props : TabsScrollAreaRenderProps ) => React . ReactNode ;
3349 previousArrowAccessibilityLabel ?: string ;
3450 nextArrowAccessibilityLabel ?: string ;
3551 /**
@@ -48,36 +64,17 @@ export type TabsScrollAreaBaseProps = Omit<BoxBaseProps, 'children' | 'style'> &
4864 OverflowIndicatorComponent ?: React . FC < TabsScrollAreaOverflowIndicatorProps > ;
4965 } ;
5066
51- export type TabsScrollAreaProps = TabsScrollAreaBaseProps & {
52- /** Merged with the root `HStack`. */
53- style ?: React . CSSProperties ;
54- /** Merged with the root `HStack`. */
55- className ?: string ;
56- styles ?: {
57- /** Root layout element */
58- root ?: React . CSSProperties ;
59- /** Horizontal scroll region wrapping `Tabs` */
60- scrollContainer ?: React . CSSProperties ;
61- /** Applied to each overflow indicator's root (`style` / `className` on the rendered component) */
62- overflowIndicator ?: React . CSSProperties ;
63- overflowIndicatorButton ?: React . CSSProperties ;
64- overflowIndicatorButtonContainer ?: React . CSSProperties ;
65- overflowIndicatorGradient ?: React . CSSProperties ;
66- } ;
67- classNames ?: {
68- root ?: string ;
69- /** Horizontal scroll region wrapping `Tabs` */
70- scrollContainer ?: string ;
71- /** Applied to each overflow indicator's root */
72- overflowIndicator ?: string ;
73- /** Applied to each overflow indicator's icon button */
74- overflowIndicatorButton ?: string ;
75- /** Applied to each overflow indicator's icon button container */
76- overflowIndicatorButtonContainer ?: string ;
77- /** Applied to each overflow indicator's gradient */
78- overflowIndicatorGradient ?: string ;
67+ export type TabsScrollAreaProps = TabsScrollAreaBaseProps &
68+ StylesAndClassNames < typeof tabsScrollAreaClassNames > & {
69+ /**
70+ * Render function that receives `onActiveTabElementChange` (wire to `Tabs` as `onActiveTabElementChange`).
71+ */
72+ children : ( props : TabsScrollAreaRenderProps ) => React . ReactNode ;
73+ /** Merged with the root `HStack`. */
74+ style ?: React . CSSProperties ;
75+ /** Merged with the root `HStack`. */
76+ className ?: string ;
7977 } ;
80- } ;
8178
8279const containerCss = css `
8380 isolation : isolate;
@@ -102,23 +99,9 @@ export const TabsScrollArea = memo(function TabsScrollArea(_props: TabsScrollAre
10299 compact,
103100 OverflowIndicatorComponent = TabsScrollAreaOverflowIndicator ,
104101 style,
105- styles : {
106- root : rootStyle ,
107- scrollContainer : scrollContainerStyle ,
108- overflowIndicator : overflowIndicatorStyle ,
109- overflowIndicatorButton : overflowIndicatorButtonStyle ,
110- overflowIndicatorButtonContainer : overflowIndicatorButtonContainerStyle ,
111- overflowIndicatorGradient : overflowIndicatorGradientStyle ,
112- } = { } ,
102+ styles,
113103 className,
114- classNames : {
115- root : rootClassName ,
116- scrollContainer : scrollContainerClassName ,
117- overflowIndicator : overflowIndicatorClassName ,
118- overflowIndicatorButton : overflowIndicatorButtonClassName ,
119- overflowIndicatorButtonContainer : overflowIndicatorButtonContainerClassName ,
120- overflowIndicatorGradient : overflowIndicatorGradientClassName ,
121- } = { } ,
104+ classNames,
122105 ...props
123106 } = mergedProps ;
124107
@@ -152,40 +135,49 @@ export const TabsScrollArea = memo(function TabsScrollArea(_props: TabsScrollAre
152135
153136 const overflowIndicatorClassNames = useMemo (
154137 ( ) => ( {
155- root : overflowIndicatorClassName ,
156- button : overflowIndicatorButtonClassName ,
157- buttonContainer : overflowIndicatorButtonContainerClassName ,
158- gradient : overflowIndicatorGradientClassName ,
138+ root : cx ( tabsScrollAreaClassNames . overflowIndicator , classNames ?. overflowIndicator ) ,
139+ button : cx (
140+ tabsScrollAreaClassNames . overflowIndicatorButton ,
141+ classNames ?. overflowIndicatorButton ,
142+ ) ,
143+ buttonContainer : cx (
144+ tabsScrollAreaClassNames . overflowIndicatorButtonContainer ,
145+ classNames ?. overflowIndicatorButtonContainer ,
146+ ) ,
147+ gradient : cx (
148+ tabsScrollAreaClassNames . overflowIndicatorGradient ,
149+ classNames ?. overflowIndicatorGradient ,
150+ ) ,
159151 } ) ,
160152 [
161- overflowIndicatorClassName ,
162- overflowIndicatorButtonClassName ,
163- overflowIndicatorButtonContainerClassName ,
164- overflowIndicatorGradientClassName ,
153+ classNames ?. overflowIndicator ,
154+ classNames ?. overflowIndicatorButton ,
155+ classNames ?. overflowIndicatorButtonContainer ,
156+ classNames ?. overflowIndicatorGradient ,
165157 ] ,
166158 ) ;
167159
168160 const overflowIndicatorStyles = useMemo (
169161 ( ) => ( {
170- root : overflowIndicatorStyle ,
171- button : overflowIndicatorButtonStyle ,
172- buttonContainer : overflowIndicatorButtonContainerStyle ,
173- gradient : overflowIndicatorGradientStyle ,
162+ root : styles ?. overflowIndicator ,
163+ button : styles ?. overflowIndicatorButton ,
164+ buttonContainer : styles ?. overflowIndicatorButtonContainer ,
165+ gradient : styles ?. overflowIndicatorGradient ,
174166 } ) ,
175167 [
176- overflowIndicatorStyle ,
177- overflowIndicatorButtonStyle ,
178- overflowIndicatorButtonContainerStyle ,
179- overflowIndicatorGradientStyle ,
168+ styles ?. overflowIndicator ,
169+ styles ?. overflowIndicatorButton ,
170+ styles ?. overflowIndicatorButtonContainer ,
171+ styles ?. overflowIndicatorGradient ,
180172 ] ,
181173 ) ;
182174
183175 return (
184176 < HStack
185177 alignItems = "center"
186- className = { cx ( containerCss , className , rootClassName ) }
178+ className = { cx ( containerCss , tabsScrollAreaClassNames . root , className , classNames ?. root ) }
187179 position = { position }
188- style = { { ...style , ...rootStyle } }
180+ style = { { ...style , ...styles ?. root } }
189181 testID = { testID }
190182 width = { width }
191183 { ...props }
@@ -202,17 +194,20 @@ export const TabsScrollArea = memo(function TabsScrollArea(_props: TabsScrollAre
202194 < HStack
203195 ref = { scrollRef }
204196 alignItems = "center"
205- className = { cx ( scrollContainerCss , scrollContainerClassName ) }
197+ className = { cx (
198+ scrollContainerCss ,
199+ tabsScrollAreaClassNames . scrollContainer ,
200+ classNames ?. scrollContainer ,
201+ ) }
206202 minWidth = { 0 }
207203 onScroll = { handleScroll }
208204 overflow = "auto"
209- style = { scrollContainerStyle }
205+ style = { styles ?. scrollContainer }
210206 >
211207 { renderedChildren }
212208 </ HStack >
213209 < OverflowIndicatorComponent
214210 accessibilityLabel = { nextArrowAccessibilityLabel }
215- className = { overflowIndicatorClassName }
216211 classNames = { overflowIndicatorClassNames }
217212 compact = { compact }
218213 direction = "right"
0 commit comments