@@ -11,16 +11,12 @@ import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
11
11
import classNames from '../_util/classNames' ;
12
12
import PropTypes from '../_util/vue-types' ;
13
13
import { getTransitionProps , Transition } from '../_util/transition' ;
14
- import { isValidElement } from '../_util/props-util' ;
14
+ import { isValidElement , getPropsSlot } from '../_util/props-util' ;
15
15
import { defaultConfigProvider } from '../config-provider' ;
16
16
import { tuple , withInstall } from '../_util/type' ;
17
17
18
18
function noop ( ) { }
19
19
20
- function getDefaultSlot ( slots : Record < string , any > , props : Record < string , any > , prop : string ) {
21
- return slots [ prop ] ?.( ) ?? props [ prop ] ;
22
- }
23
-
24
20
const iconMapFilled = {
25
21
success : CheckCircleFilled ,
26
22
info : InfoCircleFilled ,
@@ -39,7 +35,7 @@ const AlertTypes = tuple('success', 'info', 'warning', 'error');
39
35
40
36
export type AlertType = typeof AlertTypes [ number ] ;
41
37
42
- const alertProps = ( ) => ( {
38
+ const alertProps = {
43
39
/**
44
40
* Type of Alert styles, options: `success`, `info`, `warning`, `error`
45
41
*/
@@ -52,8 +48,6 @@ const alertProps = () => ({
52
48
message : PropTypes . VNodeChild ,
53
49
/** Additional content of Alert */
54
50
description : PropTypes . VNodeChild ,
55
- /** Callback when close Alert */
56
- // onClose?: React.MouseEventHandler<HTMLAnchorElement>;
57
51
/** Trigger when animation ending of Alert */
58
52
afterClose : PropTypes . func . def ( noop ) ,
59
53
/** Whether to show icon */
@@ -62,14 +56,14 @@ const alertProps = () => ({
62
56
banner : PropTypes . looseBool ,
63
57
icon : PropTypes . VNodeChild ,
64
58
onClose : PropTypes . VNodeChild ,
65
- } ) ;
59
+ } ;
66
60
67
- export type AlertProps = Partial < ExtractPropTypes < ReturnType < typeof alertProps > > > ;
61
+ export type AlertProps = Partial < ExtractPropTypes < typeof alertProps > > ;
68
62
69
63
const Alert = defineComponent ( {
70
64
name : 'AAlert' ,
71
65
inheritAttrs : false ,
72
- props : alertProps ( ) ,
66
+ props : alertProps ,
73
67
emits : [ 'close' ] ,
74
68
setup ( props , { slots, emit, attrs, expose } ) {
75
69
const configProvider = inject ( 'configProvider' , defaultConfigProvider ) ;
@@ -106,10 +100,10 @@ const Alert = defineComponent({
106
100
107
101
let { closable, type, showIcon } = props ;
108
102
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' ) ;
113
107
114
108
// banner模式默认有 Icon
115
109
showIcon = banner && showIcon === undefined ? true : showIcon ;
0 commit comments