8000 feat(CToast): add `onShow` event · v-rr/coreui-react@8fb9206 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8fb9206

Browse files
committed
feat(CToast): add onShow event
1 parent f832976 commit 8fb9206

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/components/toast/CToast.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ export interface CToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title
4343
* @ignore
4444
*/
4545
key?: number
46-
/**
47-
* Toggle the visibility of component.
48-
*/
49-
visible?: boolean
5046
/**
5147
* Callback fired when the component requests to be closed.
5248
*/
5349
onClose?: (index: number | null) => void
50+
/**
51+
* Callback fired when the component requests to be shown.
52+
*/
53+
onShow?: (index: number | null) => void
54+
/**
55+
* Toggle the visibility of component.
56+
*/
57+
visible?: boolean
5458
}
5559

5660
interface ContextProps extends CToastProps {
@@ -73,6 +77,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
7377
key,
7478
visible = false,
7579
onClose,
80+
onShow,
7681
...rest
7782
},
7883
ref,
@@ -129,6 +134,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
129134
<CSSTransition
130135
in={_visible}
131136
timeout={250}
137+
onEnter={() => onShow && onShow(index ? index : null)}
132138
onExited={() => onClose && onClose(index ? index : null)}
133139
unmountOnExit
134140
>
@@ -167,6 +173,7 @@ CToast.propTypes = {
167173
index: PropTypes.number,
168174
key: PropTypes.number,
169175
onClose: PropTypes.func,
176+
onShow: PropTypes.func,
170177
visible: PropTypes.bool,
171178
}
172179

0 commit comments

Comments
 (0)
0