@@ -3,7 +3,7 @@ import classNames from 'classnames';
3
3
import Portal from '@rc-component/portal' ;
4
4
import type { PosInfo } from './hooks/useTarget' ;
5
5
import useId from 'rc-util/lib/hooks/useId' ;
6
- import { SemanticName } from './interface' ;
6
+ import type { SemanticName , TourProps } from './interface' ;
7
7
8
8
const COVER_PROPS = {
9
9
fill : 'transparent' ,
@@ -24,6 +24,7 @@ export interface MaskProps {
24
24
disabledInteraction ?: boolean ;
25
25
classNames ?: Partial < Record < SemanticName , string > > ;
26
26
styles ?: Partial < Record < SemanticName , React . CSSProperties > > ;
27
+ getPopupContainer ?: TourProps [ 'getPopupContainer' ] ;
27
28
}
28
29
29
30
const Mask = ( props : MaskProps ) => {
@@ -33,29 +34,44 @@ const Mask = (props: MaskProps) => {
33
34
pos,
34
35
showMask,
35
36
style = { } ,
36
- fill = " rgba(0,0,0,0.5)" ,
37
+ fill = ' rgba(0,0,0,0.5)' ,
37
38
open,
38
39
animated,
39
40
zIndex,
40
41
disabledInteraction,
41
42
styles,
42
43
classNames : tourClassNames ,
44
+ getPopupContainer,
43
45
} = props ;
44
46
45
47
const id = useId ( ) ;
46
48
const maskId = `${ prefixCls } -mask-${ id } ` ;
47
49
const mergedAnimated =
48
50
typeof animated === 'object' ? animated ?. placeholder : animated ;
49
51
50
- const isSafari = typeof navigator !== 'undefined' && / ^ ( (? ! c h r o m e | a n d r o i d ) .) * s a f a r i / i. test ( navigator . userAgent ) ;
51
- const maskRectSize = isSafari ? { width : '100%' , height : '100%' } : { width : '100vw' , height : '100vh' } ;
52
+ const isSafari =
53
+ typeof navigator !== 'undefined' &&
54
+ / ^ ( (? ! c h r o m e | a n d r o i d ) .) * s a f a r i / i. test ( navigator . userAgent ) ;
55
+ const maskRectSize = isSafari
56
+ ? { width : '100%' , height : '100%' }
57
+ : { width : '100vw' , height : '100vh' } ;
58
+
59
+ const inlineMode = getPopupContainer === false ;
52
60
53
61
return (
54
- < Portal open = { open } autoLock >
62
+ < Portal
63
+ open = { open }
64
+ autoLock = { ! inlineMode }
65
+ getContainer = { getPopupContainer as any }
66
+ >
55
67
< div
56
- className = { classNames ( `${ prefixCls } -mask` , rootClassName , tourClassNames ?. mask ) }
68
+ className = { classNames (
69
+ `${ prefixCls } -mask` ,
70
+ rootClassName ,
71
+ tourClassNames ?. mask ,
72
+ ) }
57
73
style = { {
58
- position : 'fixed' ,
74
+ position : inlineMode ? 'absolute' : 'fixed' ,
59
75
left : 0 ,
60
76
right : 0 ,
61
77
top : 0 ,
@@ -103,32 +119,37 @@ const Mask = (props: MaskProps) => {
103
119
{ /* Block click region */ }
104
120
{ pos && (
105
121
< >
122
+ { /* Top */ }
123
+
106
124
< rect
107
125
{ ...COVER_PROPS }
108
126
x = "0"
109
127
y = "0"
110
128
width = "100%"
111
- height = { pos . top }
129
+ height = { Math . max ( pos . top , 0 ) }
112
130
/>
131
+ { /* Left */ }
113
132
< rect
114
133
{ ...COVER_PROPS }
115
134
x = "0"
116
135
y = "0"
117
- width = { pos . left }
136
+ width = { Math . max ( pos . left , 0 ) }
118
137
height = "100%"
119
138
/>
139
+ { /* Bottom */ }
120
140
< rect
121
141
{ ...COVER_PROPS }
122
142
x = "0"
123
143
y = { pos . top + pos . height }
124
144
width = "100%"
125
- height = { `calc(100vh - ${ pos . top + pos . height } px)` }
145
+ height = { `calc(100% - ${ pos . top + pos . height } px)` }
126
146
/>
147
+ { /* Right */ }
127
148
< rect
128
149
{ ...COVER_PROPS }
129
150
x = { pos . left + pos . width }
130
151
y = "0"
131
- width = { `calc(100vw - ${ pos . left + pos . width } px)` }
152
+ width = { `calc(100% - ${ pos . left + pos . width } px)` }
132
153
height = "100%"
133
154
/>
134
155
</ >
0 commit comments