@@ -18,11 +18,22 @@ import { getAlignPopupClassName } from '../util';
1818
1919export interface UniqueProviderProps {
2020 children : React . ReactNode ;
21+ /** Additional handle options data to do the customize info */
22+ postTriggerProps ?: ( options : UniqueShowOptions ) => UniqueShowOptions ;
2123}
2224
23- const UniqueProvider = ( { children } : UniqueProviderProps ) => {
25+ const UniqueProvider = ( { children, postTriggerProps } : UniqueProviderProps ) => {
2426 const [ trigger , open , options , onTargetVisibleChanged ] = useTargetState ( ) ;
2527
28+ // ========================== Options ===========================
29+ const mergedOptions = React . useMemo ( ( ) => {
30+ if ( ! options || ! postTriggerProps ) {
31+ return options ;
32+ }
33+
34+ return postTriggerProps ( options ) ;
35+ } , [ options , postTriggerProps ] ) ;
36+
2637 // =========================== Popup ============================
2738 const [ popupEle , setPopupEle ] = React . useState < HTMLDivElement > ( null ) ;
2839 const [ popupSize , setPopupSize ] = React . useState < {
@@ -155,7 +166,7 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
155166 ) ;
156167
157168 // =========================== Render ===========================
158- const prefixCls = options ?. prefixCls ;
169+ const prefixCls = mergedOptions ?. prefixCls ;
159170
160171 return (
161172 < UniqueContext . Provider value = { contextValue } >
@@ -166,14 +177,14 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
166177 ref = { setPopupRef }
167178 portal = { Portal }
168179 prefixCls = { prefixCls }
169- popup = { options . popup }
180+ popup = { mergedOptions . popup }
170181 className = { classNames (
171- options . popupClassName ,
182+ mergedOptions . popupClassName ,
172183 alignedClassName ,
173184 `${ prefixCls } -unique-controlled` ,
174185 ) }
175- style = { options . popupStyle }
176- target = { options . target }
186+ style = { mergedOptions . popupStyle }
187+ target = { mergedOptions . target }
177188 open = { open }
178189 keepDom = { true }
179190 fresh = { true }
@@ -197,12 +208,12 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
197208 y : arrowY ,
198209 } }
199210 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 }
206217 >
207218 < UniqueBody
208219 prefixCls = { prefixCls }
@@ -219,12 +230,12 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
219230 y : arrowY ,
220231 } }
221232 popupSize = { popupSize }
222- motion = { options . popupMotion }
233+ motion = { mergedOptions . popupMotion }
223234 uniqueBgClassName = { classNames (
224- options . uniqueBgClassName ,
235+ mergedOptions . uniqueBgClassName ,
225236 alignedClassName ,
226237 ) }
227- uniqueBgStyle = { options . uniqueBgStyle }
238+ uniqueBgStyle = { mergedOptions . uniqueBgStyle }
228239 />
229240 </ Popup >
230241 </ TriggerContext . Provider >
0 commit comments