@@ -10,10 +10,11 @@ interface BaseListProps extends React.OlHTMLAttributes<HTMLElement> {
1010 marginBottom ?: Space ;
1111}
1212
13- const List : React . FC < BaseListProps > = ( { as, children, ...props } ) => {
13+ const List = React . forwardRef < HTMLOListElement | HTMLUListElement , BaseListProps > ( ( { as, children, ...props } , ref ) => {
1414 return (
1515 < Text
1616 { ...props }
17+ ref = { ref }
1718 as = { as }
1819 marginLeft = "space70"
1920 fontSize = "fontSize30"
@@ -24,58 +25,57 @@ const List: React.FC<BaseListProps> = ({as, children, ...props}) => {
2425 { children }
2526 </ Text >
2627 ) ;
27- } ;
28-
28+ } ) ;
2929List . displayName = 'List' ;
3030
3131/*
3232 * Ordered List
3333 */
3434export type OrderedListProps = Omit < BaseListProps , 'as' > ;
35- const OrderedList : React . FC < OrderedListProps > = ( { children, marginTop, marginBottom, ...props } ) => {
36- return (
37- < List { ...safelySpreadTextProps ( props ) } as = "ol" marginTop = { marginTop } marginBottom = { marginBottom } >
38- { children }
39- </ List >
40- ) ;
41- } ;
4235
36+ const OrderedList = React . forwardRef < HTMLOListElement , OrderedListProps > (
37+ ( { children, marginTop, marginBottom, ...props } , ref ) => {
38+ return (
39+ < List { ...safelySpreadTextProps ( props ) } ref = { ref } as = "ol" marginTop = { marginTop } marginBottom = { marginBottom } >
40+ { children }
41+ </ List >
42+ ) ;
43+ }
44+ ) ;
4345OrderedList . defaultProps = {
4446 marginBottom : 'space70' ,
4547} ;
46-
4748if ( process . env . NODE_ENV === 'development' ) {
4849 OrderedList . propTypes = {
4950 marginTop : isMarginTokenProp ,
5051 marginBottom : isMarginTokenProp ,
5152 } ;
5253}
53-
5454OrderedList . displayName = 'OrderedList' ;
5555
5656/*
5757 * Unordered List
5858 */
5959export type UnorderedListProps = Omit < BaseListProps , 'as' > ;
60- const UnorderedList : React . FC < UnorderedListProps > = ( { children, marginTop, marginBottom, ...props } ) => {
61- return (
62- < List { ...safelySpreadTextProps ( props ) } as = "ul" marginTop = { marginTop } marginBottom = { marginBottom } >
63- { children }
64- </ List >
65- ) ;
66- } ;
6760
61+ const UnorderedList = React . forwardRef < HTMLUListElement , UnorderedListProps > (
62+ ( { children, marginTop, marginBottom, ...props } , ref ) => {
63+ return (
64+ < List { ...safelySpreadTextProps ( props ) } ref = { ref } as = "ul" marginTop = { marginTop } marginBottom = { marginBottom } >
65+ { children }
66+ </ List >
67+ ) ;
68+ }
69+ ) ;
6870UnorderedList . defaultProps = {
6971 marginBottom : 'space70' ,
7072} ;
71-
7273if ( process . env . NODE_ENV === 'development' ) {
7374 UnorderedList . propTypes = {
7475 marginTop : isMarginTokenProp ,
7576 marginBottom : isMarginTokenProp ,
7677 } ;
7778}
78-
7979UnorderedList . displayName = 'UnorderedList' ;
8080
8181/*
@@ -86,10 +86,11 @@ export interface ListItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
8686 style ?: never ;
8787}
8888
89- const ListItem : React . FC < ListItemProps > = props => {
89+ const ListItem = React . forwardRef < HTMLLIElement , ListItemProps > ( ( props , ref ) => {
9090 return (
9191 < Text
9292 { ...safelySpreadTextProps ( props ) }
93+ ref = { ref }
9394 as = "li"
9495 marginTop = "space30"
9596 marginBottom = "space30"
@@ -101,8 +102,7 @@ const ListItem: React.FC<ListItemProps> = props => {
101102 { props . children }
102103 </ Text >
103104 ) ;
104- } ;
105-
105+ } ) ;
106106ListItem . displayName = 'ListItem' ;
107107
108108export { OrderedList , UnorderedList , ListItem } ;
0 commit comments