@semcore/modal 3.0.5 → 3.0.8
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/CHANGELOG.md +18 -0
- package/README.md +67 -0
- package/lib/cjs/Modal.js +6 -6
- package/lib/es6/Modal.js +6 -6
- package/package.json +2 -2
- package/src/Modal.jsx +0 -149
- package/src/index.d.ts +0 -37
- package/src/index.js +0 -1
- package/src/style/modal.shadow.css +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [3.0.8] - 2022-07-21
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/icon` [2.28.0 ~> 2.29.0]).
|
|
10
|
+
|
|
11
|
+
## [3.0.7] - 2022-07-07
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.33.0 ~> 3.34.0], `@semcore/animation` [1.5.3 ~> 1.5.4], `@semcore/flex-box` [4.5.5 ~> 4.5.6], `@semcore/icon` [2.27.0 ~> 2.28.0]).
|
|
16
|
+
|
|
17
|
+
## [3.0.6] - 2022-06-02
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.32.2 ~> 3.33.0], `@semcore/animation` [1.5.2 ~> 1.5.3], `@semcore/flex-box` [4.5.4 ~> 4.5.5], `@semcore/icon` [2.26.1 ~> 2.27.0]).
|
|
22
|
+
|
|
5
23
|
## [3.0.5] - 2022-05-31
|
|
6
24
|
|
|
7
25
|
### Changed
|
package/README.md
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @semcore/modal
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/@semcore/modal)
|
|
4
|
+
[](https://www.npmjs.com/package/@semcore/modal)
|
|
5
|
+
[](https://github.com/semrush/intergalactic/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
> This component is part of the Intergalactic design system
|
|
8
|
+
|
|
9
|
+
### 📖 [Component documentation](https://developer.semrush.com/intergalactic/components/modal/)
|
|
10
|
+
|
|
11
|
+
### 🏠 [Design system](https://developer.semrush.com/intergalactic/)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @semcore/ui
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import Modal from '@semcore/ui/modal';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<details>
|
|
26
|
+
<summary>Alternative installation and use</summary>
|
|
27
|
+
|
|
28
|
+
**We do not recommend this usage path due to possible dependency and update issues.**
|
|
29
|
+
|
|
30
|
+
### Install
|
|
31
|
+
|
|
32
|
+
You can only install one package from the design system
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm install @semcore/modal @semcore/core
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`@semcore/core` - _is the basic package by which we create our components, and it contains all of the common logic
|
|
39
|
+
of the components that is discussed below. There should only be one version of the package in the project._
|
|
40
|
+
|
|
41
|
+
### Usage
|
|
42
|
+
|
|
43
|
+
You can use the package the same way but without `/ui/` in the import path.
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
import Modal from '@semcore/modal';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
</details>
|
|
50
|
+
|
|
51
|
+
## 👤 Author
|
|
52
|
+
|
|
53
|
+
[UI-kit team](https://github.com/semrush/intergalactic/blob/master/MAINTAINERS) and [others ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
|
|
54
|
+
|
|
55
|
+
## 🤝 Contributing
|
|
56
|
+
|
|
57
|
+
Contributions, issues and feature requests are welcome!
|
|
58
|
+
|
|
59
|
+
Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/master/CONTRIBUTING.md).
|
|
60
|
+
|
|
61
|
+
## Show your support
|
|
62
|
+
|
|
63
|
+
Give a ⭐️ if this project helped you!
|
|
64
|
+
|
|
65
|
+
## 📝 License
|
|
66
|
+
|
|
67
|
+
This project is [MIT](https://github.com/semrush/intergalactic/blob/master/LICENSE) licensed.
|
package/lib/cjs/Modal.js
CHANGED
|
@@ -70,15 +70,15 @@ var style = (
|
|
|
70
70
|
/*__reshadow_css_start__*/
|
|
71
71
|
_core.sstyled.insert(
|
|
72
72
|
/*__inner_css_start__*/
|
|
73
|
-
".
|
|
73
|
+
".___SWindow_uplm1_gg_{position:relative;border-radius:12px;background:#ffffff;box-sizing:border-box;margin:auto;padding:40px;box-shadow:0 3px 8px rgba(25,27,35,.2)}.___SWindow_uplm1_gg_:focus{outline:none}.___SOverlay_uplm1_gg_{position:fixed;top:0;bottom:0;left:0;right:0;margin:0;display:flex;justify-content:center;align-items:center;padding:40px;background:rgba(25,27,35,.7);overflow:auto;z-index:10005;-webkit-overflow-scrolling:touch}.___SOverlay_uplm1_gg_ .___SOverlay_uplm1_gg_{background:rgba(25,27,35,.4)}.___SClose_uplm1_gg_{display:inline-flex;position:absolute;right:0;top:0;padding:12px;color:#a9abb6;cursor:pointer;z-index:1;border:none;background:none;outline:none}.___SClose_uplm1_gg_:hover{color:#8a8e9b}.___SClose_uplm1_gg_.__keyboardFocused_uplm1_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2)}@media (max-width:767px){.___SWindow_uplm1_gg_{min-width:60%}.___SOverlay_uplm1_gg_{padding:12px}}"
|
|
74
74
|
/*__inner_css_end__*/
|
|
75
|
-
, "
|
|
75
|
+
, "uplm1_gg_")
|
|
76
76
|
/*__reshadow_css_end__*/
|
|
77
77
|
, {
|
|
78
|
-
"__SWindow": "
|
|
79
|
-
"__SOverlay": "
|
|
80
|
-
"__SClose": "
|
|
81
|
-
"_keyboardFocused": "
|
|
78
|
+
"__SWindow": "___SWindow_uplm1_gg_",
|
|
79
|
+
"__SOverlay": "___SOverlay_uplm1_gg_",
|
|
80
|
+
"__SClose": "___SClose_uplm1_gg_",
|
|
81
|
+
"_keyboardFocused": "__keyboardFocused_uplm1_gg_"
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
var ModalRoot = /*#__PURE__*/function (_Component) {
|
package/lib/es6/Modal.js
CHANGED
|
@@ -40,15 +40,15 @@ var style = (
|
|
|
40
40
|
/*__reshadow_css_start__*/
|
|
41
41
|
_sstyled.insert(
|
|
42
42
|
/*__inner_css_start__*/
|
|
43
|
-
".
|
|
43
|
+
".___SWindow_uplm1_gg_{position:relative;border-radius:12px;background:#ffffff;box-sizing:border-box;margin:auto;padding:40px;box-shadow:0 3px 8px rgba(25,27,35,.2)}.___SWindow_uplm1_gg_:focus{outline:none}.___SOverlay_uplm1_gg_{position:fixed;top:0;bottom:0;left:0;right:0;margin:0;display:flex;justify-content:center;align-items:center;padding:40px;background:rgba(25,27,35,.7);overflow:auto;z-index:10005;-webkit-overflow-scrolling:touch}.___SOverlay_uplm1_gg_ .___SOverlay_uplm1_gg_{background:rgba(25,27,35,.4)}.___SClose_uplm1_gg_{display:inline-flex;position:absolute;right:0;top:0;padding:12px;color:#a9abb6;cursor:pointer;z-index:1;border:none;background:none;outline:none}.___SClose_uplm1_gg_:hover{color:#8a8e9b}.___SClose_uplm1_gg_.__keyboardFocused_uplm1_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2)}@media (max-width:767px){.___SWindow_uplm1_gg_{min-width:60%}.___SOverlay_uplm1_gg_{padding:12px}}"
|
|
44
44
|
/*__inner_css_end__*/
|
|
45
|
-
, "
|
|
45
|
+
, "uplm1_gg_")
|
|
46
46
|
/*__reshadow_css_end__*/
|
|
47
47
|
, {
|
|
48
|
-
"__SWindow": "
|
|
49
|
-
"__SOverlay": "
|
|
50
|
-
"__SClose": "
|
|
51
|
-
"_keyboardFocused": "
|
|
48
|
+
"__SWindow": "___SWindow_uplm1_gg_",
|
|
49
|
+
"__SOverlay": "___SOverlay_uplm1_gg_",
|
|
50
|
+
"__SClose": "___SClose_uplm1_gg_",
|
|
51
|
+
"_keyboardFocused": "__keyboardFocused_uplm1_gg_"
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
var ModalRoot = /*#__PURE__*/function (_Component) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/modal",
|
|
3
3
|
"description": "SEMRush Modal Component",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.8",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
|
-
"author": "
|
|
9
|
+
"author": "UI-kit team <ui-kit-team@semrush.com>",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "build --source=js",
|
package/src/Modal.jsx
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import FocusLock from 'react-focus-lock';
|
|
3
|
-
import { FadeInOut } from '@semcore/animation';
|
|
4
|
-
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
5
|
-
import Portal, { PortalProvider } from '@semcore/portal';
|
|
6
|
-
import { Box } from '@semcore/flex-box';
|
|
7
|
-
import OutsideClick from '@semcore/outside-click';
|
|
8
|
-
import CloseIcon from '@semcore/icon/Close/l';
|
|
9
|
-
import fire from '@semcore/utils/lib/fire';
|
|
10
|
-
import usePreventScroll from '@semcore/utils/lib/use/usePreventScroll';
|
|
11
|
-
import { isAdvanceMode } from '@semcore/utils/lib/findComponent';
|
|
12
|
-
import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
13
|
-
import style from './style/modal.shadow.css';
|
|
14
|
-
|
|
15
|
-
class ModalRoot extends Component {
|
|
16
|
-
static displayName = 'Modal';
|
|
17
|
-
static style = style;
|
|
18
|
-
static defaultProps = {
|
|
19
|
-
duration: 200,
|
|
20
|
-
closable: true,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
handleKeyDown = (e) => {
|
|
24
|
-
if (e.key === 'Escape') {
|
|
25
|
-
e.stopPropagation();
|
|
26
|
-
fire(this, 'onClose', 'onEscape', e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
handleIconCloseClick = (e) => {
|
|
31
|
-
fire(this, 'onClose', 'onCloseClick', e);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
handleOutsideClick = (e) => {
|
|
35
|
-
fire(this, 'onClose', 'onOutsideClick', e);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
getOverlayProps() {
|
|
39
|
-
const { duration, visible } = this.asProps;
|
|
40
|
-
return {
|
|
41
|
-
duration,
|
|
42
|
-
visible,
|
|
43
|
-
onOutsideClick: this.handleOutsideClick,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getWindowProps() {
|
|
48
|
-
const { visible, closable } = this.asProps;
|
|
49
|
-
return {
|
|
50
|
-
visible,
|
|
51
|
-
closable,
|
|
52
|
-
onKeyDown: this.handleKeyDown,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
getCloseProps() {
|
|
57
|
-
return {
|
|
58
|
-
onClick: this.handleIconCloseClick,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
render() {
|
|
63
|
-
const { Children, disablePortal } = this.asProps;
|
|
64
|
-
|
|
65
|
-
const advanceMode = isAdvanceMode(Children, [
|
|
66
|
-
Modal.Overlay.displayName,
|
|
67
|
-
Modal.Window.displayName,
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<Portal disablePortal={disablePortal}>
|
|
72
|
-
{advanceMode ? (
|
|
73
|
-
<Children />
|
|
74
|
-
) : (
|
|
75
|
-
<Modal.Overlay>
|
|
76
|
-
<Root render={Modal.Window} />
|
|
77
|
-
</Modal.Overlay>
|
|
78
|
-
)}
|
|
79
|
-
</Portal>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const FocusLockWrapper = React.forwardRef(function ({ tag, ...other }, ref) {
|
|
85
|
-
return <FocusLock ref={ref} as={tag} lockProps={other} {...other} />;
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
function Window(props) {
|
|
89
|
-
const SWindow = Root;
|
|
90
|
-
const { Children, styles, visible, closable } = props;
|
|
91
|
-
const windowRef = useRef(null);
|
|
92
|
-
|
|
93
|
-
if (!visible) return null;
|
|
94
|
-
|
|
95
|
-
return sstyled(styles)(
|
|
96
|
-
<SWindow
|
|
97
|
-
render={FocusLockWrapper}
|
|
98
|
-
tag={Box}
|
|
99
|
-
ref={windowRef}
|
|
100
|
-
returnFocus={true}
|
|
101
|
-
tabIndex={-1}
|
|
102
|
-
autoFocus={true}
|
|
103
|
-
role="dialog"
|
|
104
|
-
aria-modal={true}
|
|
105
|
-
aria-label="Modal window"
|
|
106
|
-
>
|
|
107
|
-
<PortalProvider value={windowRef}>
|
|
108
|
-
{closable && <Modal.Close />}
|
|
109
|
-
<Children />
|
|
110
|
-
</PortalProvider>
|
|
111
|
-
</SWindow>,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function Overlay(props) {
|
|
116
|
-
const SOverlay = Root;
|
|
117
|
-
const { Children, styles, onOutsideClick, visible } = props;
|
|
118
|
-
const overlayRef = useRef(null);
|
|
119
|
-
usePreventScroll(visible);
|
|
120
|
-
|
|
121
|
-
return sstyled(styles)(
|
|
122
|
-
<SOverlay render={FadeInOut} ref={overlayRef}>
|
|
123
|
-
<OutsideClick root={overlayRef} onOutsideClick={onOutsideClick}>
|
|
124
|
-
<Children />
|
|
125
|
-
</OutsideClick>
|
|
126
|
-
</SOverlay>,
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function Close(props) {
|
|
131
|
-
const SClose = Root;
|
|
132
|
-
return sstyled(props.styles)(
|
|
133
|
-
<SClose render={Box} tag="button" tabIndex={0} aria-label="Close" />,
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
Close.defaultProps = {
|
|
138
|
-
children: <CloseIcon title="Close" />,
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
Close.enhance = [keyboardFocusEnhance()];
|
|
142
|
-
|
|
143
|
-
const Modal = createComponent(ModalRoot, {
|
|
144
|
-
Window,
|
|
145
|
-
Overlay,
|
|
146
|
-
Close,
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
export default Modal;
|
package/src/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { ComponentProps } from 'react';
|
|
2
|
-
import { IFadeInOutProps } from '@semcore/animation';
|
|
3
|
-
import { CProps, PropGetterFn, ReturnEl } from '@semcore/core';
|
|
4
|
-
import { IPortalProps } from '@semcore/portal';
|
|
5
|
-
import { Box, IBoxProps } from '@semcore/flex-box';
|
|
6
|
-
|
|
7
|
-
export interface IModalProps extends IPortalProps, IBoxProps, IFadeInOutProps {
|
|
8
|
-
/** Duration of animation, ms
|
|
9
|
-
* @default 200
|
|
10
|
-
*/
|
|
11
|
-
duration?: number;
|
|
12
|
-
/** This property is responsible for the visibility of the modal window */
|
|
13
|
-
visible?: boolean;
|
|
14
|
-
/** Function called when the component is hidden */
|
|
15
|
-
onClose?: (
|
|
16
|
-
trigger: 'onOutsideClick' | 'onCloseClick' | 'onEscape',
|
|
17
|
-
e?: React.MouseEvent | React.KeyboardEvent,
|
|
18
|
-
) => void;
|
|
19
|
-
/** Displaying the close button(x) in the upper-right corner of the modal dialog
|
|
20
|
-
* @default true
|
|
21
|
-
* */
|
|
22
|
-
closable?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface IModalContext {
|
|
26
|
-
getOverlayProps: PropGetterFn;
|
|
27
|
-
getWindowProps: PropGetterFn;
|
|
28
|
-
getCloseProps: PropGetterFn;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
declare const Modal: (<T>(props: CProps<IModalProps & T, IModalContext>) => ReturnEl) & {
|
|
32
|
-
Window: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
|
|
33
|
-
Overlay: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
|
|
34
|
-
Close: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default Modal;
|
package/src/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Modal';
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
@import '@semcore/utils/style/var.css';
|
|
2
|
-
|
|
3
|
-
SWindow {
|
|
4
|
-
position: relative;
|
|
5
|
-
border-radius: var(--rounded-l);
|
|
6
|
-
background: var(--white);
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
margin: auto;
|
|
9
|
-
padding: 40px;
|
|
10
|
-
box-shadow: 0 3px 8px color-mod(var(--gray-800) a(20%));
|
|
11
|
-
|
|
12
|
-
&:focus {
|
|
13
|
-
outline: none;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
SOverlay {
|
|
18
|
-
position: fixed;
|
|
19
|
-
top: 0;
|
|
20
|
-
bottom: 0;
|
|
21
|
-
left: 0;
|
|
22
|
-
right: 0;
|
|
23
|
-
margin: 0;
|
|
24
|
-
display: flex;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
align-items: center;
|
|
27
|
-
padding: 40px;
|
|
28
|
-
background: color-mod(var(--gray-800) a(70%));
|
|
29
|
-
overflow: auto;
|
|
30
|
-
z-index: 10005;
|
|
31
|
-
-webkit-overflow-scrolling: touch;
|
|
32
|
-
|
|
33
|
-
& SOverlay {
|
|
34
|
-
background: color-mod(var(--gray-800) a(40%));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
SClose {
|
|
39
|
-
display: inline-flex;
|
|
40
|
-
position: absolute;
|
|
41
|
-
right: 0;
|
|
42
|
-
top: 0;
|
|
43
|
-
padding: 12px;
|
|
44
|
-
color: var(--gray-300);
|
|
45
|
-
cursor: pointer;
|
|
46
|
-
z-index: 1;
|
|
47
|
-
border: none;
|
|
48
|
-
background: none;
|
|
49
|
-
outline: none;
|
|
50
|
-
|
|
51
|
-
&:hover {
|
|
52
|
-
color: var(--gray-400);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
SClose[keyboardFocused] {
|
|
57
|
-
box-shadow: var(--keyboard-focus);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@media (max-width: 767px) {
|
|
61
|
-
SWindow {
|
|
62
|
-
min-width: 60%;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
SOverlay {
|
|
66
|
-
padding: 12px;
|
|
67
|
-
}
|
|
68
|
-
}
|