@@ -45,13 +45,13 @@ const NoticeList: FC<NoticeListProps> = (props) => {
45
45
46
46
const { classNames : ctxCls } = useContext ( NotificationContext ) ;
47
47
48
- const dictRef = useRef < Record < React . Key , HTMLDivElement > > ( { } ) ;
48
+ const dictRef = useRef < Record < string , HTMLDivElement > > ( { } ) ;
49
49
const [ latestNotice , setLatestNotice ] = useState < HTMLDivElement > ( null ) ;
50
- const [ hoverKeys , setHoverKeys ] = useState < React . Key [ ] > ( [ ] ) ;
50
+ const [ hoverKeys , setHoverKeys ] = useState < string [ ] > ( [ ] ) ;
51
51
52
52
const keys = configList . map ( ( config ) => ( {
53
53
config,
54
- key : config . key ,
54
+ key : String ( config . key ) ,
55
55
} ) ) ;
56
56
57
57
const [ stack , { offset, threshold, gap } ] = useStack ( stackConfig ) ;
@@ -96,8 +96,15 @@ const NoticeList: FC<NoticeListProps> = (props) => {
96
96
nodeRef ,
97
97
) => {
98
98
const { key, times } = config as InnerOpenConfig ;
99
- const { className : configClassName , style : configStyle } = config as NoticeConfig ;
100
- const dataIndex = keys . findIndex ( ( item ) => item . key === key ) ;
99
+ const strKey = String ( key ) ;
100
+ const {
101
+ className : configClassName ,
102
+ style : configStyle ,
103
+ classNames : configClassNames ,
104
+ styles : configStyles ,
105
+ ...restConfig
106
+ } = config as NoticeConfig ;
107
+ const dataIndex = keys . findIndex ( ( item ) => item . key === strKey ) ;
101
108
102
109
// If dataIndex is -1, that means this notice has been removed in data, but still in dom
103
110
// Should minus (motionIndex - 1) to get the correct index because keys.length is not the same as dom length
@@ -107,7 +114,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
107
114
const transformX = placement === 'top' || placement === 'bottom' ? '-50%' : '0' ;
108
115
if ( index > 0 ) {
109
116
stackStyle . height = expanded
110
- ? dictRef . current [ key ] ?. offsetHeight
117
+ ? dictRef . current [ strKey ] ?. offsetHeight
111
118
: latestNotice ?. offsetHeight ;
112
119
113
120
// Transform
@@ -119,9 +126,9 @@ const NoticeList: FC<NoticeListProps> = (props) => {
119
126
const transformY =
120
127
( expanded ? verticalOffset : index * offset ) * ( placement . startsWith ( 'top' ) ? 1 : - 1 ) ;
121
128
const scaleX =
122
- ! expanded && latestNotice ?. offsetWidth && dictRef . current [ key ] ?. offsetWidth
129
+ ! expanded && latestNotice ?. offsetWidth && dictRef . current [ strKey ] ?. offsetWidth
123
130
? ( latestNotice ?. offsetWidth - offset * 2 * ( index < 3 ? index : 3 ) ) /
124
- dictRef . current [ key ] ?. offsetWidth
131
+ dictRef . current [ strKey ] ?. offsetWidth
125
132
: 1 ;
126
133
stackStyle . transform = `translate3d(${ transformX } , ${ transformY } px, 0) scaleX(${ scaleX } )` ;
127
134
} else {
@@ -132,28 +139,35 @@ const NoticeList: FC<NoticeListProps> = (props) => {
132
139
return (
133
140
< div
134
141
ref = { nodeRef }
135
- className = { clsx ( `${ prefixCls } -notice-wrapper` , motionClassName ) }
142
+ className = { clsx (
143
+ `${ prefixCls } -notice-wrapper` ,
144
+ motionClassName ,
145
+ configClassNames ?. wrapper ,
146
+ ) }
136
147
style = { {
137
148
...motionStyle ,
138
149
...stackStyle ,
139
- ...configStyle ,
150
+ ...configStyles ?. wrapper ,
140
151
} }
141
152
onMouseEnter = { ( ) =>
142
- setHoverKeys ( ( prev ) => ( prev . includes ( key ) ? prev : [ ...prev , key ] ) )
153
+ setHoverKeys ( ( prev ) => ( prev . includes ( strKey ) ? prev : [ ...prev , strKey ] ) )
143
154
}
144
- onMouseLeave = { ( ) => setHoverKeys ( ( prev ) => prev . filter ( ( k ) => k !== key ) ) }
155
+ onMouseLeave = { ( ) => setHoverKeys ( ( prev ) => prev . filter ( ( k ) => k !== strKey ) ) }
145
156
>
146
157
< Notice
147
- { ...config }
158
+ { ...restConfig }
148
159
ref = { ( node ) => {
149
160
if ( dataIndex > - 1 ) {
150
- dictRef . current [ key ] = node ;
161
+ dictRef . current [ strKey ] = node ;
151
162
} else {
152
- delete dictRef . current [ key ] ;
163
+ delete dictRef . current [ strKey ] ;
153
164
}
154
165
} }
155
166
prefixCls = { prefixCls }
167
+ classNames = { configClassNames }
168
+ styles = { configStyles }
156
169
className = { clsx ( configClassName , ctxCls ?. notice ) }
170
+ style = { configStyle }
157
171
times = { times }
158
172
key = { key }
159
173
eventKey = { key }
0 commit comments