File tree Expand file tree Collapse file tree 4 files changed +17
-14
lines changed
packages/coreui-react/src/components Expand file tree Collapse file tree 4 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import type { TransitionStatus } from 'react-transition-group'
1616
1717import { PolymorphicRefForwardingComponent } from '../../helpers'
1818
19- import { CNavContext } from '../sidebar/CSidebarNav '
19+ import { CSidebarNavContext } from '../sidebar/CSidebarNavContext '
2020
2121export interface CNavGroupProps extends HTMLAttributes < HTMLDivElement | HTMLLIElement > {
2222 /**
@@ -62,7 +62,7 @@ export const CNavGroup: PolymorphicRefForwardingComponent<'li', CNavGroupProps>
6262 // eslint-disable-next-line @typescript-eslint/no-explicit-any
6363 const navItemsRef = useRef < any > ( null )
6464
65- const { visibleGroup, setVisibleGroup } = useContext ( CNavContext )
65+ const { visibleGroup, setVisibleGroup } = useContext ( CSidebarNavContext )
6666
6767 const [ _visible , setVisible ] = useState (
6868 Boolean ( visible || ( idx && visibleGroup && isInVisibleGroup ( visibleGroup , idx ) ) ) ,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
33import classNames from 'classnames'
44
55import { CLinkProps , CLink } from '../link/CLink'
6- import { CNavContext } from '../sidebar/CSidebarNav '
6+ import { CSidebarNavContext } from '../sidebar/CSidebarNavContext '
77
88import { PolymorphicRefForwardingComponent } from '../../helpers'
99import { useForkedRef } from '../../hooks'
@@ -26,7 +26,7 @@ export const CNavLink: PolymorphicRefForwardingComponent<'a', CNavLinkProps> = f
2626 const navLinkRef = useRef < HTMLAnchorElement > ( null )
2727 const forkedRef = useForkedRef ( ref , navLinkRef )
2828
29- const { setVisibleGroup } = useContext ( CNavContext )
29+ const { setVisibleGroup } = useContext ( CSidebarNavContext )
3030
3131 useEffect ( ( ) => {
3232 rest . active = navLinkRef . current ?. classList . contains ( 'active' )
Original file line number Diff line number Diff line change 11import React , {
2- createContext ,
32 ElementType ,
43 forwardRef ,
54 HTMLAttributes ,
@@ -13,6 +12,9 @@ import classNames from 'classnames'
1312import type { CNavGroupProps } from '../nav/CNavGroup'
1413import type { CNavLinkProps } from '../nav/CNavLink'
1514import type { CNavItemProps } from '../nav/CNavItem'
15+
16+ import { CSidebarNavContext } from './CSidebarNavContext'
17+
1618import { PolymorphicRefForwardingComponent } from '../../helpers'
1719
1820export interface CSidebarNavProps extends HTMLAttributes < HTMLUListElement > {
@@ -28,13 +30,6 @@ export interface CSidebarNavProps extends HTMLAttributes<HTMLUListElement> {
2830 className ?: string
2931}
3032
31- interface ContextProps {
32- visibleGroup : string
33- setVisibleGroup : React . Dispatch < React . SetStateAction < string | undefined > >
34- }
35-
36- export const CNavContext = createContext ( { } as ContextProps )
37-
3833const isNavElement = (
3934 child : ReactNode
4035) : child is ReactElement < CNavGroupProps | CNavLinkProps | CNavItemProps > => {
@@ -82,11 +77,11 @@ export const CSidebarNav: PolymorphicRefForwardingComponent<'ul', CSidebarNavPro
8277 }
8378
8479 return (
85- < CNavContext . Provider value = { CNavContextValues } >
80+ < CSidebarNavContext . Provider value = { CNavContextValues } >
8681 < Component className = { classNames ( 'sidebar-nav' , className ) } ref = { ref } { ...rest } >
8782 { recursiveClone ( children ) }
8883 </ Component >
89- </ CNavContext . Provider >
84+ </ CSidebarNavContext . Provider >
9085 )
9186} )
9287
Original file line number Diff line number Diff line change 1+ import { createContext } from 'react'
2+
3+ export interface CSidebarNavContextProps {
4+ visibleGroup : string
5+ setVisibleGroup : React . Dispatch < React . SetStateAction < string | undefined > >
6+ }
7+
8+ export const CSidebarNavContext = createContext ( { } as CSidebarNavContextProps )
You can’t perform that action at this time.
0 commit comments