@modul/mbui 0.0.1-beta-pv-50520-797e2860 → 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 +3 -2
- package/src/Popup/BaseModal.tsx +53 -0
- package/src/Popup/Popup.tsx +45 -0
- package/src/Popup/index.ts +3 -0
- package/src/Popup/types.ts +16 -0
- package/src/index.ts +3 -2
- package/src/Base/Checkbox/Checkbox.tsx +0 -66
- package/src/Base/Checkbox/index.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modul/mbui",
|
|
3
|
-
"version": "0.0.1-beta-pv-
|
|
3
|
+
"version": "0.0.1-beta-pv-50528-277b7dcf",
|
|
4
4
|
"packageManager": "yarn@3.5.1",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"react-datepicker": "4.16.0",
|
|
17
|
-
"react-imask": "7.1.3"
|
|
17
|
+
"react-imask": "7.1.3",
|
|
18
|
+
"react-modal": "3.16.1"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@babel/core": "^7.9.0",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import classNames from 'classnames'
|
|
2
|
+
import React, { FC } from 'react'
|
|
3
|
+
import Modal from 'react-modal'
|
|
4
|
+
import { IBaseModal } from './types'
|
|
5
|
+
|
|
6
|
+
const BaseModal: FC<IBaseModal> = ({
|
|
7
|
+
shouldCloseOnOverlayClick = true,
|
|
8
|
+
children,
|
|
9
|
+
isOpen,
|
|
10
|
+
appElement,
|
|
11
|
+
onAfterOpen,
|
|
12
|
+
onRequestClose,
|
|
13
|
+
overlayClassName,
|
|
14
|
+
}) => {
|
|
15
|
+
const handleOverlayOnClick = () => {
|
|
16
|
+
if (shouldCloseOnOverlayClick) {
|
|
17
|
+
onRequestClose?.()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//FIXME: из-за portalCreate у нас события клика всплывают с модального окна в компонент где он был замуонтин
|
|
22
|
+
const preventEvents = (e: React.MouseEvent) => {
|
|
23
|
+
e.stopPropagation()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const overlayClasses = classNames('popup_overlay', overlayClassName)
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Modal
|
|
30
|
+
isOpen={isOpen}
|
|
31
|
+
contentLabel=""
|
|
32
|
+
appElement={appElement}
|
|
33
|
+
onRequestClose={onRequestClose}
|
|
34
|
+
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
|
35
|
+
onAfterOpen={onAfterOpen}
|
|
36
|
+
className="popup_table"
|
|
37
|
+
overlayClassName={overlayClasses}
|
|
38
|
+
>
|
|
39
|
+
<div
|
|
40
|
+
className="popup_cell"
|
|
41
|
+
onClick={preventEvents}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
<div
|
|
45
|
+
className="popup_backdrop"
|
|
46
|
+
onClick={handleOverlayOnClick}
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
</Modal>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default BaseModal
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { FC } from 'react'
|
|
2
|
+
import BaseModal from './BaseModal'
|
|
3
|
+
import { IPopup } from './types'
|
|
4
|
+
|
|
5
|
+
const Popup: FC<IPopup> = ({
|
|
6
|
+
shouldCloseOnOverlayClick = true,
|
|
7
|
+
children,
|
|
8
|
+
isOpen,
|
|
9
|
+
appElement = document.getElementsByTagName('body')[0],
|
|
10
|
+
onAfterOpen,
|
|
11
|
+
onRequestClose,
|
|
12
|
+
overlayClassName,
|
|
13
|
+
layerClassName,
|
|
14
|
+
disableClose,
|
|
15
|
+
...props
|
|
16
|
+
}) => {
|
|
17
|
+
const handleRequestClose = () => {
|
|
18
|
+
onRequestClose()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const classNames = ['popup_layer', layerClassName || ''].join(' ')
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<BaseModal
|
|
25
|
+
{...props}
|
|
26
|
+
isOpen={isOpen}
|
|
27
|
+
appElement={appElement}
|
|
28
|
+
onAfterOpen={onAfterOpen}
|
|
29
|
+
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
|
30
|
+
onRequestClose={handleRequestClose}
|
|
31
|
+
>
|
|
32
|
+
<div className={classNames}>
|
|
33
|
+
{!disableClose && (
|
|
34
|
+
<button
|
|
35
|
+
className="popup_close icon-close"
|
|
36
|
+
onClick={handleRequestClose}
|
|
37
|
+
/>
|
|
38
|
+
)}
|
|
39
|
+
{children}
|
|
40
|
+
</div>
|
|
41
|
+
</BaseModal>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default Popup
|
|
@@ -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
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Button } from './Base/Buttons'
|
|
|
2
2
|
import { TextLink } from './Base/Links'
|
|
3
3
|
import { DatePicker } from './DatePicker'
|
|
4
4
|
import { Input } from './Base/Input'
|
|
5
|
-
|
|
5
|
+
//
|
|
6
|
+
import { Popup } from './Popup'
|
|
6
7
|
|
|
7
|
-
export { Button, TextLink, DatePicker, Input,
|
|
8
|
+
export { Button, TextLink, DatePicker, Input, Popup }
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React, { FC, InputHTMLAttributes, ReactNode } from 'react'
|
|
2
|
-
import classnames from 'classnames'
|
|
3
|
-
interface ICheckbox extends InputHTMLAttributes<HTMLInputElement> {
|
|
4
|
-
switcher?: boolean
|
|
5
|
-
children?: ReactNode
|
|
6
|
-
childrenWrapperClassName?: string
|
|
7
|
-
labelClassName?: string
|
|
8
|
-
iconId?: string
|
|
9
|
-
onClick?: () => void
|
|
10
|
-
disabled?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const Checkbox: FC<ICheckbox> = ({
|
|
14
|
-
id,
|
|
15
|
-
name,
|
|
16
|
-
checked,
|
|
17
|
-
onChange,
|
|
18
|
-
onClick,
|
|
19
|
-
value = 'on',
|
|
20
|
-
switcher,
|
|
21
|
-
onBlur,
|
|
22
|
-
onFocus,
|
|
23
|
-
iconId,
|
|
24
|
-
children,
|
|
25
|
-
childrenWrapperClassName,
|
|
26
|
-
labelClassName,
|
|
27
|
-
disabled,
|
|
28
|
-
}) => {
|
|
29
|
-
const labelClasses = classnames('label-check', labelClassName, { _switcher: switcher })
|
|
30
|
-
|
|
31
|
-
const renderIcon = (
|
|
32
|
-
<i
|
|
33
|
-
className="icon"
|
|
34
|
-
id={iconId}
|
|
35
|
-
/>
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
const renderChildren = children && <span className={childrenWrapperClassName}>{children}</span>
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<span onClick={onClick}>
|
|
42
|
-
<input
|
|
43
|
-
type="checkbox"
|
|
44
|
-
checked={checked}
|
|
45
|
-
name={name}
|
|
46
|
-
id={id}
|
|
47
|
-
onChange={onChange}
|
|
48
|
-
value={value}
|
|
49
|
-
onBlur={onBlur}
|
|
50
|
-
onFocus={onFocus}
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
/>
|
|
53
|
-
|
|
54
|
-
<label
|
|
55
|
-
htmlFor={id}
|
|
56
|
-
className={labelClasses}
|
|
57
|
-
data-checked={checked}
|
|
58
|
-
>
|
|
59
|
-
{renderIcon}
|
|
60
|
-
{renderChildren}
|
|
61
|
-
</label>
|
|
62
|
-
</span>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default Checkbox
|