8000 feat(CTabPane): add `onHide` and `onShow` event · v-rr/coreui-react@eef79ae · GitHub
[go: up one dir, main page]

Skip to content

Commit eef79ae

Browse files
committed
feat(CTabPane): add onHide and onShow event
1 parent d4d4b04 commit eef79ae

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/tabs/CTabPane.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ export interface CTabPaneProps extends HTMLAttributes<HTMLDivElement> {
88
* A string of all className you want applied to the base component.
99
*/
1010
className?: string
11+
/**
12+
* Callback fired when the component requests to be hidden.
13+
*/
14+
onHide?: () => void
15+
/**
16+
* Callback fired when the component requests to be shown.
17+
*/
18+
onShow?: () => void
1119
/**
1220
* Toggle the visibility of component.
1321
*/
1422
visible?: boolean
1523
}
1624

1725
export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
18-
({ children, className, visible, ...rest }, ref) => {
26+
({ children, className, onHide, onShow, visible, ...rest }, ref) => {
1927
const style = {
2028
transition: `opacity 150ms linear`,
2129
}
@@ -32,7 +40,7 @@ export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
3240

3341
const _className = classNames('tab-pane', 'fade', className)
3442
return (
35-
<Transition in={visible} timeout={350}>
43+
<Transition in={visible} onEnter={onShow} onExit={onHide} timeout={350}>
3644
{(state) => {
3745
const transitionClass = getTransitionClass(state)
3846
return (
@@ -54,6 +62,8 @@ export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
5462
CTabPane.propTypes = {
5563
children: PropTypes.node,
5664
className: PropTypes.string,
65+
onHide: PropTypes.func,
66+
onShow: PropTypes.func,
5767
visible: PropTypes.bool,
5868
}
5969

0 commit comments

Comments
 (0)
0