@modul/mbui 0.0.1-beta-pv-50528-f9e8be2e → 0.0.1-beta-pv-50528-277b7dcf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Popup/BaseModal.tsx +10 -17
- package/src/Popup/Popup.tsx +3 -14
- package/src/Popup/types.ts +16 -0
package/package.json
CHANGED
package/src/Popup/BaseModal.tsx
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import classNames from 'classnames'
|
|
2
|
+
import React, { FC } from 'react'
|
|
2
3
|
import Modal from 'react-modal'
|
|
4
|
+
import { IBaseModal } from './types'
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
type BaseModalProps = {
|
|
6
|
-
shouldCloseOnOverlayClick?: boolean
|
|
7
|
-
children: ReactNode
|
|
8
|
-
isOpen: boolean
|
|
9
|
-
appElement?: object
|
|
10
|
-
onAfterOpen?: () => void
|
|
11
|
-
onRequestClose?: () => void
|
|
12
|
-
overlayClassName?: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const BaseModal: FC<BaseModalProps> = ({
|
|
6
|
+
const BaseModal: FC<IBaseModal> = ({
|
|
16
7
|
shouldCloseOnOverlayClick = true,
|
|
17
8
|
children,
|
|
18
9
|
isOpen,
|
|
@@ -21,27 +12,29 @@ const BaseModal: FC<BaseModalProps> = ({
|
|
|
21
12
|
onRequestClose,
|
|
22
13
|
overlayClassName,
|
|
23
14
|
}) => {
|
|
24
|
-
const handleOverlayOnClick = (
|
|
15
|
+
const handleOverlayOnClick = () => {
|
|
25
16
|
if (shouldCloseOnOverlayClick) {
|
|
26
17
|
onRequestClose?.()
|
|
27
18
|
}
|
|
28
19
|
}
|
|
29
20
|
|
|
21
|
+
//FIXME: из-за portalCreate у нас события клика всплывают с модального окна в компонент где он был замуонтин
|
|
30
22
|
const preventEvents = (e: React.MouseEvent) => {
|
|
31
23
|
e.stopPropagation()
|
|
32
24
|
}
|
|
33
25
|
|
|
34
|
-
|
|
26
|
+
const overlayClasses = classNames('popup_overlay', overlayClassName)
|
|
27
|
+
|
|
35
28
|
return (
|
|
36
29
|
<Modal
|
|
37
30
|
isOpen={isOpen}
|
|
38
31
|
contentLabel=""
|
|
39
|
-
appElement={appElement
|
|
32
|
+
appElement={appElement}
|
|
40
33
|
onRequestClose={onRequestClose}
|
|
41
34
|
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
|
42
35
|
onAfterOpen={onAfterOpen}
|
|
43
36
|
className="popup_table"
|
|
44
|
-
overlayClassName={
|
|
37
|
+
overlayClassName={overlayClasses}
|
|
45
38
|
>
|
|
46
39
|
<div
|
|
47
40
|
className="popup_cell"
|
package/src/Popup/Popup.tsx
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import React, { FC
|
|
1
|
+
import React, { FC } from 'react'
|
|
2
2
|
import BaseModal from './BaseModal'
|
|
3
|
+
import { IPopup } from './types'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
shouldCloseOnOverlayClick?: boolean
|
|
6
|
-
children: ReactNode
|
|
7
|
-
isOpen: boolean
|
|
8
|
-
appElement?: object
|
|
9
|
-
onAfterOpen?: () => void
|
|
10
|
-
onRequestClose?: () => void
|
|
11
|
-
overlayClassName?: string
|
|
12
|
-
layerClassName: string
|
|
13
|
-
disableClose?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const Popup: FC<BaseModalProps> = ({
|
|
5
|
+
const Popup: FC<IPopup> = ({
|
|
17
6
|
shouldCloseOnOverlayClick = true,
|
|
18
7
|
children,
|
|
19
8
|
isOpen,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface IBaseModal {
|
|
4
|
+
isOpen: boolean //modal state
|
|
5
|
+
shouldCloseOnOverlayClick?: boolean // When shouldCloseOnOverlayClick is true. it requires the onRequestClose to be defined in order to close.
|
|
6
|
+
children?: ReactNode
|
|
7
|
+
appElement?: object
|
|
8
|
+
onAfterOpen?: () => void // This event helps to trigger a function just after the modal opens
|
|
9
|
+
onRequestClose?: () => void
|
|
10
|
+
overlayClassName?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IPopup extends IBaseModal {
|
|
14
|
+
layerClassName?: string
|
|
15
|
+
disableClose?: boolean
|
|
16
|
+
}
|