@@ -11,16 +11,12 @@ import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
1111import classNames from '../_util/classNames' ;
1212import PropTypes from '../_util/vue-types' ;
1313import { getTransitionProps , Transition } from '../_util/transition' ;
14- import { isValidElement } from '../_util/props-util' ;
14+ import { isValidElement , getPropsSlot } from '../_util/props-util' ;
1515import { defaultConfigProvider } from '../config-provider' ;
1616import { tuple , withInstall } from '../_util/type' ;
1717
1818function noop ( ) { }
1919
20- function getDefaultSlot ( slots : Record < string , any > , props : Record < string , any > , prop : string ) {
21- return slots [ prop ] ?.( ) ?? props [ prop ] ;
22- }
23-
2420const iconMapFilled = {
2521 success : CheckCircleFilled ,
2622 info : InfoCircleFilled ,
@@ -39,7 +35,7 @@ const AlertTypes = tuple('success', 'info', 'warning', 'error');
3935
4036export type AlertType = typeof AlertTypes [ number ] ;
4137
42- const alertProps = ( ) => ( {
38+ const alertProps = {
4339 /**
4440 * Type of Alert styles, options: `success`, `info`, `warning`, `error`
4541 */
@@ -52,8 +48,6 @@ const alertProps = () => ({
5248 message : PropTypes . VNodeChild ,
5349 /** Additional content of Alert */
5450 description : PropTypes . VNodeChild ,
55- /** Callback when close Alert */
56- // onClose?: React.MouseEventHandler<HTMLAnchorElement>;
5751 /** Trigger when animation ending of Alert */
5852 afterClose : PropTypes . func . def ( noop ) ,
5953 /** Whether to show icon */
@@ -62,14 +56,14 @@ const alertProps = () => ({
6256 banner : PropTypes . looseBool ,
6357 icon : PropTypes . VNodeChild ,
6458 onClose : PropTypes . VNodeChild ,
65- } ) ;
59+ } ;
6660
67- export type AlertProps = Partial < ExtractPropTypes < ReturnType < typeof alertProps > > > ;
61+ export type AlertProps = Partial < ExtractPropTypes < typeof alertProps > > ;
6862
6963const Alert = defineComponent ( {
7064 name : 'AAlert' ,
7165 inheritAttrs : false ,
72- props : alertProps ( ) ,
66+ props : alertProps ,
7367 emits : [ 'close' ] ,
7468 setup ( props , { slots, emit, attrs, expose } ) {
7569 const configProvider = inject ( 'configProvider' , defaultConfigProvider ) ;
@@ -106,10 +100,10 @@ const Alert = defineComponent({
106100
107101 let { closable, type, showIcon } = props ;
108102
109- const closeText = getDefaultSlot ( slots , props , 'closeText' ) ;
110- const description = getDefaultSlot ( slots , props , 'description' ) ;
111- const message = getDefaultSlot ( slots , props , 'message' ) ;
112- const icon = getDefaultSlot ( slots , props , 'icon' ) ;
103+ const closeText = getPropsSlot ( slots , props , 'closeText' ) ;
104+ const description = getPropsSlot ( slots , props , 'description' ) ;
105+ const message = getPropsSlot ( slots , props , 'message' ) ;
106+ const icon = getPropsSlot ( slots , props , 'icon' ) ;
113107
114108 // banner模式默认有 Icon
115109 showIcon = banner && showIcon === undefined ? true : showIcon ;
0 commit comments