@@ -16,7 +16,7 @@ import { type VariantProps, tv } from 'tailwind-variants'
1616
1717import { flatArrayToMap } from '../../libs/map'
1818
19- import { getNewExpandedItems } from './accordionPanelHelper '
19+ import { getNewExpandedItems } from './accordionHelper '
2020
2121type AbstractProps = PropsWithChildren < {
2222 /** アイコンの左右位置 */
@@ -29,13 +29,13 @@ type AbstractProps = PropsWithChildren<{
2929 onClick ?: ( expandedItems : string [ ] ) => void
3030} > &
3131 VariantProps < typeof classNameGenerator >
32- type Props = AbstractProps & Omit < ComponentProps < 'div ' > , keyof AbstractProps >
32+ type Props = AbstractProps & Omit < ComponentProps < 'ul ' > , keyof AbstractProps >
3333
34- export const AccordionPanelContext = createContext < {
34+ export const AccordionListContext = createContext < {
3535 iconPosition : 'left' | 'right'
3636 expandedItems : Map < string , string >
3737 expandableMultiply : boolean
38- parentRef : RefObject < HTMLDivElement > | null
38+ parentRef : RefObject < HTMLUListElement > | null
3939 onClickTrigger ?: ( itemName : string , isExpanded : boolean ) => void
4040 onClickProps ?: ( expandedItems : string [ ] ) => void
4141} > ( {
@@ -46,16 +46,16 @@ export const AccordionPanelContext = createContext<{
4646} )
4747
4848const ROUNDED = {
49- t_l : '[&>.smarthr-ui-AccordionPanel -item:first-child_.smarthr-ui-AccordionPanel -trigger]:shr-rounded-tl-l' ,
50- t_r : '[&>.smarthr-ui-AccordionPanel -item:first-child_.smarthr-ui-AccordionPanel -trigger]:shr-rounded-tr-l' ,
51- b_l : '[&>.smarthr-ui-AccordionPanel -item:last-child_.smarthr-ui-AccordionPanel -trigger:not([aria-expanded="true"])]:shr-rounded-bl-l' ,
52- b_r : '[&>.smarthr-ui-AccordionPanel -item:last-child_.smarthr-ui-AccordionPanel -trigger:not([aria-expanded="true"])]:shr-rounded-br-l' ,
49+ t_l : '[&>.smarthr-ui-AccordionList -item:first-child_.smarthr-ui-AccordionList -trigger]:shr-rounded-tl-l' ,
50+ t_r : '[&>.smarthr-ui-AccordionList -item:first-child_.smarthr-ui-AccordionList -trigger]:shr-rounded-tr-l' ,
51+ b_l : '[&>.smarthr-ui-AccordionList -item:last-child_.smarthr-ui-AccordionList -trigger:not([aria-expanded="true"])]:shr-rounded-bl-l' ,
52+ b_r : '[&>.smarthr-ui-AccordionList -item:last-child_.smarthr-ui-AccordionList -trigger:not([aria-expanded="true"])]:shr-rounded-br-l' ,
5353}
5454
5555const ROUNDED_ALL = [ ROUNDED . t_l , ROUNDED . t_r , ROUNDED . b_l , ROUNDED . b_r ]
5656
5757const classNameGenerator = tv ( {
58- base : 'smarthr-ui-AccordionPanel ' ,
58+ base : 'smarthr-ui-AccordionList ' ,
5959 variants : {
6060 rounded : {
6161 true : ROUNDED_ALL ,
@@ -72,7 +72,7 @@ const classNameGenerator = tv({
7272 } ,
7373} )
7474
75- export const AccordionPanel : FC < Props > = ( {
75+ export const AccordionList : FC < Props > = ( {
7676 iconPosition = 'left' ,
7777 expandableMultiply = true ,
7878 defaultExpanded = [ ] ,
@@ -82,7 +82,7 @@ export const AccordionPanel: FC<Props> = ({
8282 ...rest
8383} ) => {
8484 const [ expandedItems , setExpanded ] = useState ( flatArrayToMap ( defaultExpanded ) )
85- const parentRef = useRef < HTMLDivElement > ( null )
85+ const parentRef = useRef < HTMLUListElement > ( null )
8686 const actualClassName = useMemo (
8787 ( ) => classNameGenerator ( { className, rounded } ) ,
8888 [ rounded , className ] ,
@@ -100,7 +100,7 @@ export const AccordionPanel: FC<Props> = ({
100100 } , [ defaultExpanded ] )
101101
102102 return (
103- < AccordionPanelContext . Provider
103+ < AccordionListContext . Provider
104104 value = { {
105105 onClickTrigger,
106106 onClickProps,
@@ -110,7 +110,7 @@ export const AccordionPanel: FC<Props> = ({
110110 parentRef,
111111 } }
112112 >
113- < div { ...rest } ref = { parentRef } role = "presentation" className = { actualClassName } />
114- </ AccordionPanelContext . Provider >
113+ < ul { ...rest } ref = { parentRef } className = { actualClassName } />
114+ </ AccordionListContext . Provider >
115115 )
116116}
0 commit comments