@@ -18,11 +18,22 @@ import { getAlignPopupClassName } from '../util';
18
18
19
19
export interface UniqueProviderProps {
20
20
children : React . ReactNode ;
21
+ /** Additional handle options data to do the customize info */
22
+ postTriggerProps ?: ( options : UniqueShowOptions ) => UniqueShowOptions ;
21
23
}
22
24
23
- const UniqueProvider = ( { children } : UniqueProviderProps ) => {
25
+ const UniqueProvider = ( { children, postTriggerProps } : UniqueProviderProps ) => {
24
26
const [ trigger , open , options , onTargetVisibleChanged ] = useTargetState ( ) ;
25
27
28
+ // ========================== Options ===========================
29
+ const mergedOptions = React . useMemo ( ( ) => {
30
+ if ( ! options || ! postTriggerProps ) {
31
+ return options ;
32
+ }
33
+
34
+ return postTriggerProps ( options ) ;
35
+ } , [ options , postTriggerProps ] ) ;
36
+
26
37
// =========================== Popup ============================
27
38
const [ popupEle , setPopupEle ] = React . useState < HTMLDivElement > ( null ) ;
28
39
const [ popupSize , setPopupSize ] = React . useState < {
@@ -155,7 +166,7 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
155
166
) ;
156
167
157
168
// =========================== Render ===========================
158
- const prefixCls = options ?. prefixCls ;
169
+ const prefixCls = mergedOptions ?. prefixCls ;
159
170
160
171
return (
161
172
< UniqueContext . Provider value = { contextValue } >
@@ -166,14 +177,14 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
166
177
ref = { setPopupRef }
167
178
portal = { Portal }
168
179
prefixCls = { prefixCls }
169
- popup = { options . popup }
180
+ popup = { mergedOptions . popup }
170
181
className = { classNames (
171
- options . popupClassName ,
182
+ mergedOptions . popupClassName ,
172
183
alignedClassName ,
173
184
`${ prefixCls } -unique-controlled` ,
174
185
) }
175
- style = { options . popupStyle }
176
- target = { options . target }
186
+ style = { mergedOptions . popupStyle }
187
+ target = { mergedOptions . target }
177
188
open = { open }
178
189
keepDom = { true }
179
190
fresh = { true }
@@ -197,12 +208,12 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
197
208
y : arrowY ,
198
209
} }
199
210
align = { alignInfo }
200
- zIndex = { options . zIndex }
201
- mask = { options . mask }
202
- arrow = { options . arrow }
203
- motion = { options . popupMotion }
204
- maskMotion = { options . maskMotion }
205
- // getPopupContainer={options .getPopupContainer}
211
+ zIndex = { mergedOptions . zIndex }
212
+ mask = { mergedOptions . mask }
213
+ arrow = { mergedOptions . arrow }
214
+ motion = { mergedOptions . popupMotion }
215
+ maskMotion = { mergedOptions . maskMotion }
216
+ getPopupContainer = { mergedOptions . getPopupContainer }
206
217
>
207
218
< UniqueBody
208
219
prefixCls = { prefixCls }
@@ -219,12 +230,12 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
219
230
y : arrowY ,
220
231
} }
221
232
popupSize = { popupSize }
222
- motion = { options . popupMotion }
233
+ motion = { mergedOptions . popupMotion }
223
234
uniqueBgClassName = { classNames (
224
- options . uniqueBgClassName ,
235
+ mergedOptions . uniqueBgClassName ,
225
236
alignedClassName ,
226
237
) }
227
- uniqueBgStyle = { options . uniqueBgStyle }
238
+ uniqueBgStyle = { mergedOptions . uniqueBgStyle }
228
239
/>
229
240
</ Popup >
230
241
</ TriggerContext . Provider >
0 commit comments