@@ -10,27 +10,6 @@ import {
10
10
} from 'mo/common/className' ;
11
11
import { Icon } from 'mo/components/icon' ;
12
12
import { Button , IButton } from 'mo/components/button' ;
13
-
14
- let mousePosition : any ;
15
-
16
- const getClickPosition = ( e : MouseEvent ) => {
17
- mousePosition = {
18
- x : e . pageX ,
19
- y : e . pageY ,
20
- } ;
21
- setTimeout ( ( ) => {
22
- mousePosition = null ;
23
- } , 100 ) ;
24
- } ;
25
-
26
- if ( typeof window !== 'undefined' && window . document ?. documentElement ) {
27
- document . documentElement . addEventListener ( 'click' , getClickPosition , true ) ;
28
- }
29
-
30
- export const destroyFns : Array < ( ) => void > = [ ] ;
31
-
32
- export const modalClassName = prefixClaName ( 'modal' ) ;
33
-
34
13
export interface IModalProps extends IDialogPropTypes {
35
14
onOk ?: ( e : React . MouseEvent < HTMLElement > ) => void ;
36
15
onCancel ?: ( e : React . SyntheticEvent < Element , Event > ) => void ;
@@ -41,7 +20,6 @@ export interface IModalProps extends IDialogPropTypes {
41
20
cancelButtonProps ?: IButton ;
42
21
okCancel ?: boolean ;
43
22
}
44
-
45
23
export interface IModalFuncProps extends IDialogPropTypes {
46
24
cancelText ?: React . ReactNode ;
47
25
okText ?: React . ReactNode ;
@@ -56,6 +34,33 @@ export interface IModalFuncProps extends IDialogPropTypes {
56
34
type ?: string ;
57
35
}
58
36
37
+ export const destroyFns : Array < ( ) => void > = [ ] ;
38
+ export const modalClassName = prefixClaName ( 'modal' ) ;
39
+
40
+ let mousePosition : any ;
41
+
42
+ const getClickPosition = ( e : MouseEvent ) => {
43
+ mousePosition = {
44
+ x : e . pageX ,
45
+ y : e . pageY ,
46
+ } ;
47
+ setTimeout ( ( ) => {
48
+ mousePosition = null ;
49
+ } , 100 ) ;
50
+ } ;
51
+
52
+ if ( typeof window !== 'undefined' && window . document ?. documentElement ) {
53
+ document . documentElement . addEventListener ( 'click' , getClickPosition , true ) ;
54
+ }
55
+
56
+ const closeClassName = getBEMElement ( modalClassName , 'close' ) ;
57
+ const closeDescriptorClassName = getBEMModifier ( `${ closeClassName } ` , 'x' ) ;
58
+ const closeIconToRender = (
59
+ < span className = { closeDescriptorClassName } >
60
+ < Icon type = "close" />
61
+ </ span >
62
+ ) ;
63
+
59
64
const Modal : React . FC < IModalProps > = ( props ) => {
60
65
const handleCancel = ( e : React . SyntheticEvent < Element , Event > ) => {
61
66
const { onCancel } = props ;
@@ -82,15 +87,6 @@ const Modal: React.FC<IModalProps> = (props) => {
82
87
[ getBEMModifier ( `${ modalClassName } ` , 'centered' ) ] : ! ! centered ,
83
88
} ) ;
84
89
85
- const closeClassName = getBEMElement ( modalClassName , 'close' ) ;
86
- const closeDescriptorClassName = getBEMModifier ( `${ closeClassName } ` , 'x' ) ;
87
-
88
- const closeIconToRender = (
89
- < span className = { closeDescriptorClassName } >
90
- < Icon type = "close" />
91
- </ span >
92
- ) ;
93
-
94
90
const renderFooter = ( ) => {
95
91
const { footer, cancelButtonProps, okButtonProps } = props ;
96
92
if ( footer !== undefined ) return footer ;
0 commit comments