@rc-component/dialog 1.0.0
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/LICENSE.md +9 -0
- package/README.md +108 -0
- package/assets/bootstrap.css +177 -0
- package/assets/index.css +174 -0
- package/es/Dialog/Content/MemoChildren.d.ts +7 -0
- package/es/Dialog/Content/MemoChildren.js +8 -0
- package/es/Dialog/Content/Panel.d.ts +15 -0
- package/es/Dialog/Content/Panel.js +149 -0
- package/es/Dialog/Content/index.d.ts +13 -0
- package/es/Dialog/Content/index.js +63 -0
- package/es/Dialog/Mask.d.ts +11 -0
- package/es/Dialog/Mask.js +28 -0
- package/es/Dialog/index.d.ts +4 -0
- package/es/Dialog/index.js +201 -0
- package/es/DialogWrap.d.ts +4 -0
- package/es/DialogWrap.js +59 -0
- package/es/IDialogPropTypes.d.ts +52 -0
- package/es/IDialogPropTypes.js +1 -0
- package/es/context.d.ts +5 -0
- package/es/context.js +2 -0
- package/es/index.d.ts +6 -0
- package/es/index.js +4 -0
- package/es/util.d.ts +5 -0
- package/es/util.js +34 -0
- package/lib/Dialog/Content/MemoChildren.d.ts +7 -0
- package/lib/Dialog/Content/MemoChildren.js +17 -0
- package/lib/Dialog/Content/Panel.d.ts +15 -0
- package/lib/Dialog/Content/Panel.js +159 -0
- package/lib/Dialog/Content/index.d.ts +13 -0
- package/lib/Dialog/Content/index.js +73 -0
- package/lib/Dialog/Mask.d.ts +11 -0
- package/lib/Dialog/Mask.js +38 -0
- package/lib/Dialog/index.d.ts +4 -0
- package/lib/Dialog/index.js +211 -0
- package/lib/DialogWrap.d.ts +4 -0
- package/lib/DialogWrap.js +69 -0
- package/lib/IDialogPropTypes.d.ts +52 -0
- package/lib/IDialogPropTypes.js +5 -0
- package/lib/context.d.ts +5 -0
- package/lib/context.js +11 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +16 -0
- package/lib/util.d.ts +5 -0
- package/lib/util.js +41 -0
- package/package.json +98 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present yiminghe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# rc-dialog
|
|
2
|
+
|
|
3
|
+
react dialog component
|
|
4
|
+
|
|
5
|
+
[![NPM version][npm-image]][npm-url] [](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Test coverage][codecov-image]][codecov-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
|
|
6
|
+
|
|
7
|
+
[npm-image]: http://img.shields.io/npm/v/rc-dialog.svg?style=flat-square
|
|
8
|
+
[npm-url]: http://npmjs.org/package/rc-dialog
|
|
9
|
+
[github-actions-image]: https://github.com/react-component/dialog/workflows/CI/badge.svg
|
|
10
|
+
[github-actions-url]: https://github.com/react-component/dialog/actions
|
|
11
|
+
[circleci-image]: https://img.shields.io/circleci/react-component/dialog/master?style=flat-square
|
|
12
|
+
[circleci-url]: https://circleci.com/gh/react-component/dialog
|
|
13
|
+
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/dialog/master.svg?style=flat-square
|
|
14
|
+
[codecov-url]: https://app.codecov.io/gh/react-component/dialog
|
|
15
|
+
[download-image]: https://img.shields.io/npm/dm/rc-dialog.svg?style=flat-square
|
|
16
|
+
[download-url]: https://npmjs.org/package/rc-dialog
|
|
17
|
+
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-dialog
|
|
18
|
+
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-dialog
|
|
19
|
+
|
|
20
|
+
## Screenshot
|
|
21
|
+
|
|
22
|
+
<img src="http://gtms04.alicdn.com/tps/i4/TB1dp5lHXXXXXbmXpXXyVug.FXX-664-480.png" />
|
|
23
|
+
|
|
24
|
+
## Example
|
|
25
|
+
|
|
26
|
+
http://localhost:8007/examples/
|
|
27
|
+
|
|
28
|
+
online example: https://dialog.react-component.vercel.app/
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
[](https://npmjs.org/package/rc-dialog)
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
var Dialog = require('rc-dialog');
|
|
38
|
+
|
|
39
|
+
ReactDOM.render(
|
|
40
|
+
<Dialog title={title} onClose={callback1} visible>
|
|
41
|
+
<p>first dialog</p>
|
|
42
|
+
</Dialog>
|
|
43
|
+
), document.getElementById('t1'));
|
|
44
|
+
|
|
45
|
+
// use dialog
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### rc-dialog
|
|
51
|
+
|
|
52
|
+
| Name | Type | Default | Description | Version |
|
|
53
|
+
| ---------------------- | ------------------------------ | --------- | ------------------------------------------------------------------------------- | ------- |
|
|
54
|
+
| prefixCls | String | rc-dialog | The dialog dom node's prefixCls | |
|
|
55
|
+
| className | String | | additional className for dialog | |
|
|
56
|
+
| classNames | { header?: string; body?: string; footer?: string; mask?: string; content?: string; wrapper?: string; } | | pass className to target area | |
|
|
57
|
+
| styles | { header?: CSSProperties; body?: CSSProperties; footer?: CSSProperties; mask?: CSSProperties; content?: CSSProperties; wrapper?: CSSProperties; } | | pass styles to target area | |
|
|
58
|
+
| style | Object | {} | Root style for dialog element.Such as width, height | |
|
|
59
|
+
| zIndex | Number | | | |
|
|
60
|
+
| visible | Boolean | false | current dialog's visible status | |
|
|
61
|
+
| animation | String | | part of dialog animation css class name | |
|
|
62
|
+
| maskAnimation | String | | part of dialog's mask animation css class name | |
|
|
63
|
+
| transitionName | String | | dialog animation css class name | |
|
|
64
|
+
| maskTransitionName | String | | mask animation css class name | |
|
|
65
|
+
| title | String\|React.Element | | Title of the dialog | |
|
|
66
|
+
| footer | React.Element | | footer of the dialog | |
|
|
67
|
+
| closable | Boolean \| ({ closeIcon?: React.ReactNode; disabled?: boolean } & React.AriaAttributes | true | whether show close button | |
|
|
68
|
+
| mask | Boolean | true | whether show mask | |
|
|
69
|
+
| maskClosable | Boolean | true | whether click mask to close | |
|
|
70
|
+
| keyboard | Boolean | true | whether support press esc to close | |
|
|
71
|
+
| mousePosition | {x:number,y:number} | | set pageX and pageY of current mouse(it will cause transform origin to be set). | |
|
|
72
|
+
| onClose | function() | | called when click close button or mask | |
|
|
73
|
+
| afterClose | function() | | called when close animation end | |
|
|
74
|
+
| getContainer | function(): HTMLElement | | to determine where Dialog will be mounted | |
|
|
75
|
+
| destroyOnClose | Boolean | false | to unmount child compenents on onClose | |
|
|
76
|
+
| closeIcon | ReactNode | | specific the close icon. | |
|
|
77
|
+
| forceRender | Boolean | false | Create dialog dom node before dialog first show | |
|
|
78
|
+
| focusTriggerAfterClose | Boolean | true | focus trigger element when dialog closed | |
|
|
79
|
+
| modalRender | (node: ReactNode) => ReactNode | | Custom modal content render | 8.3.0 |
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
npm install
|
|
85
|
+
npm start
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## Test Case
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
npm test
|
|
94
|
+
npm run chrome-test
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Coverage
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
npm run coverage
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
open coverage/ dir
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
rc-dialog is released under the MIT license.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
.rc-dialog {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: auto;
|
|
4
|
+
margin: 10px;
|
|
5
|
+
}
|
|
6
|
+
.rc-dialog-wrap {
|
|
7
|
+
position: fixed;
|
|
8
|
+
overflow: auto;
|
|
9
|
+
top: 0;
|
|
10
|
+
right: 0;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
left: 0;
|
|
13
|
+
z-index: 1050;
|
|
14
|
+
-webkit-overflow-scrolling: touch;
|
|
15
|
+
outline: 0;
|
|
16
|
+
}
|
|
17
|
+
.rc-dialog-section {
|
|
18
|
+
position: relative;
|
|
19
|
+
background-color: #fff;
|
|
20
|
+
border: 1px solid #999;
|
|
21
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
22
|
+
border-radius: 6px;
|
|
23
|
+
box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
|
|
24
|
+
background-clip: padding-box;
|
|
25
|
+
outline: 0;
|
|
26
|
+
}
|
|
27
|
+
.rc-dialog-header {
|
|
28
|
+
padding: 15px;
|
|
29
|
+
border-bottom: 1px solid #e5e5e5;
|
|
30
|
+
}
|
|
31
|
+
.rc-dialog-close {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
border: 0;
|
|
34
|
+
background: transparent;
|
|
35
|
+
font-size: 21px;
|
|
36
|
+
position: absolute;
|
|
37
|
+
right: 20px;
|
|
38
|
+
top: 12px;
|
|
39
|
+
font-weight: 700;
|
|
40
|
+
line-height: 1;
|
|
41
|
+
color: #000;
|
|
42
|
+
text-shadow: 0 1px 0 #fff;
|
|
43
|
+
filter: alpha(opacity=20);
|
|
44
|
+
opacity: 0.2;
|
|
45
|
+
text-decoration: none;
|
|
46
|
+
}
|
|
47
|
+
.rc-dialog-close-x:after {
|
|
48
|
+
content: '×';
|
|
49
|
+
}
|
|
50
|
+
.rc-dialog-close:hover {
|
|
51
|
+
opacity: 1;
|
|
52
|
+
filter: alpha(opacity=100);
|
|
53
|
+
text-decoration: none;
|
|
54
|
+
}
|
|
55
|
+
.rc-dialog-title {
|
|
56
|
+
margin: 0;
|
|
57
|
+
line-height: 1.42857143;
|
|
58
|
+
}
|
|
59
|
+
.rc-dialog-body {
|
|
60
|
+
position: relative;
|
|
61
|
+
padding: 15px;
|
|
62
|
+
}
|
|
63
|
+
.rc-dialog-footer {
|
|
64
|
+
padding: 15px;
|
|
65
|
+
text-align: right;
|
|
66
|
+
border-top: 1px solid #e5e5e5;
|
|
67
|
+
}
|
|
68
|
+
.rc-dialog-footer .btn + .btn {
|
|
69
|
+
margin-left: 5px;
|
|
70
|
+
margin-bottom: 0;
|
|
71
|
+
}
|
|
72
|
+
.rc-dialog-footer .btn-group .btn + .btn {
|
|
73
|
+
margin-left: -1px;
|
|
74
|
+
}
|
|
75
|
+
.rc-dialog-footer .btn-block + .btn-block {
|
|
76
|
+
margin-left: 0;
|
|
77
|
+
}
|
|
78
|
+
@media (min-width: 768px) {
|
|
79
|
+
.rc-dialog {
|
|
80
|
+
width: 600px;
|
|
81
|
+
margin: 30px auto;
|
|
82
|
+
}
|
|
83
|
+
.rc-dialog-section {
|
|
84
|
+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
.rc-dialog-slide-fade-enter,
|
|
88
|
+
.rc-dialog-slide-fade-appear {
|
|
89
|
+
transform: translate(0, -25%);
|
|
90
|
+
}
|
|
91
|
+
.rc-dialog-slide-fade-enter,
|
|
92
|
+
.rc-dialog-slide-fade-appear,
|
|
93
|
+
.rc-dialog-slide-fade-leave {
|
|
94
|
+
animation-duration: 0.3s;
|
|
95
|
+
animation-fill-mode: both;
|
|
96
|
+
animation-timing-function: ease-out;
|
|
97
|
+
animation-play-state: paused;
|
|
98
|
+
}
|
|
99
|
+
.rc-dialog-slide-fade-enter.rc-dialog-slide-fade-enter-active,
|
|
100
|
+
.rc-dialog-slide-fade-appear.rc-dialog-slide-fade-appear-active {
|
|
101
|
+
animation-name: rcDialogSlideFadeIn;
|
|
102
|
+
animation-play-state: running;
|
|
103
|
+
}
|
|
104
|
+
.rc-dialog-slide-fade-leave.rc-dialog-slide-fade-leave-active {
|
|
105
|
+
animation-name: rcDialogSlideFadeOut;
|
|
106
|
+
animation-play-state: running;
|
|
107
|
+
}
|
|
108
|
+
@keyframes rcDialogSlideFadeIn {
|
|
109
|
+
0% {
|
|
110
|
+
transform: translate(0, -25%);
|
|
111
|
+
}
|
|
112
|
+
100% {
|
|
113
|
+
transform: translate(0, 0);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
@keyframes rcDialogSlideFadeOut {
|
|
117
|
+
0% {
|
|
118
|
+
transform: translate(0, 0);
|
|
119
|
+
}
|
|
120
|
+
100% {
|
|
121
|
+
transform: translate(0, -25%);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
.rc-dialog-mask {
|
|
125
|
+
position: fixed;
|
|
126
|
+
top: 0;
|
|
127
|
+
right: 0;
|
|
128
|
+
left: 0;
|
|
129
|
+
bottom: 0;
|
|
130
|
+
background-color: #373737;
|
|
131
|
+
background-color: rgba(55, 55, 55, 0.6);
|
|
132
|
+
height: 100%;
|
|
133
|
+
filter: alpha(opacity=50);
|
|
134
|
+
z-index: 1050;
|
|
135
|
+
}
|
|
136
|
+
.rc-dialog-mask-hidden {
|
|
137
|
+
display: none;
|
|
138
|
+
}
|
|
139
|
+
.rc-dialog-fade-enter,
|
|
140
|
+
.rc-dialog-fade-appear {
|
|
141
|
+
opacity: 0;
|
|
142
|
+
animation-duration: 0.3s;
|
|
143
|
+
animation-fill-mode: both;
|
|
144
|
+
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
145
|
+
animation-play-state: paused;
|
|
146
|
+
}
|
|
147
|
+
.rc-dialog-fade-leave {
|
|
148
|
+
animation-duration: 0.3s;
|
|
149
|
+
animation-fill-mode: both;
|
|
150
|
+
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
151
|
+
animation-play-state: paused;
|
|
152
|
+
}
|
|
153
|
+
.rc-dialog-fade-enter.rc-dialog-fade-enter-active,
|
|
154
|
+
.rc-dialog-fade-appear.rc-dialog-fade-appear-active {
|
|
155
|
+
animation-name: rcDialogFadeIn;
|
|
156
|
+
animation-play-state: running;
|
|
157
|
+
}
|
|
158
|
+
.rc-dialog-fade-leave.rc-dialog-fade-leave-active {
|
|
159
|
+
animation-name: rcDialogFadeOut;
|
|
160
|
+
animation-play-state: running;
|
|
161
|
+
}
|
|
162
|
+
@keyframes rcDialogFadeIn {
|
|
163
|
+
0% {
|
|
164
|
+
opacity: 0;
|
|
165
|
+
}
|
|
166
|
+
100% {
|
|
167
|
+
opacity: 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
@keyframes rcDialogFadeOut {
|
|
171
|
+
0% {
|
|
172
|
+
opacity: 1;
|
|
173
|
+
}
|
|
174
|
+
100% {
|
|
175
|
+
opacity: 0;
|
|
176
|
+
}
|
|
177
|
+
}
|
package/assets/index.css
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
.rc-dialog {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: auto;
|
|
4
|
+
margin: 10px;
|
|
5
|
+
}
|
|
6
|
+
.rc-dialog-wrap {
|
|
7
|
+
position: fixed;
|
|
8
|
+
overflow: auto;
|
|
9
|
+
top: 0;
|
|
10
|
+
right: 0;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
left: 0;
|
|
13
|
+
z-index: 1050;
|
|
14
|
+
-webkit-overflow-scrolling: touch;
|
|
15
|
+
outline: 0;
|
|
16
|
+
}
|
|
17
|
+
.rc-dialog-title {
|
|
18
|
+
margin: 0;
|
|
19
|
+
font-size: 14px;
|
|
20
|
+
line-height: 21px;
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
}
|
|
23
|
+
.rc-dialog-section {
|
|
24
|
+
position: relative;
|
|
25
|
+
background-color: #ffffff;
|
|
26
|
+
border: none;
|
|
27
|
+
border-radius: 6px 6px;
|
|
28
|
+
background-clip: padding-box;
|
|
29
|
+
}
|
|
30
|
+
.rc-dialog-close {
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
border: 0;
|
|
33
|
+
background: transparent;
|
|
34
|
+
font-size: 21px;
|
|
35
|
+
position: absolute;
|
|
36
|
+
right: 20px;
|
|
37
|
+
top: 12px;
|
|
38
|
+
font-weight: 700;
|
|
39
|
+
line-height: 1;
|
|
40
|
+
color: #000;
|
|
41
|
+
text-shadow: 0 1px 0 #fff;
|
|
42
|
+
filter: alpha(opacity=20);
|
|
43
|
+
opacity: 0.2;
|
|
44
|
+
text-decoration: none;
|
|
45
|
+
}
|
|
46
|
+
.rc-dialog-close:disabled {
|
|
47
|
+
pointer-events: none;
|
|
48
|
+
}
|
|
49
|
+
.rc-dialog-close-x:after {
|
|
50
|
+
content: '×';
|
|
51
|
+
}
|
|
52
|
+
.rc-dialog-close:hover {
|
|
53
|
+
opacity: 1;
|
|
54
|
+
filter: alpha(opacity=100);
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
}
|
|
57
|
+
.rc-dialog-header {
|
|
58
|
+
padding: 13px 20px 14px 20px;
|
|
59
|
+
border-radius: 5px 5px 0 0;
|
|
60
|
+
background: #fff;
|
|
61
|
+
color: #666;
|
|
62
|
+
border-bottom: 1px solid #e9e9e9;
|
|
63
|
+
}
|
|
64
|
+
.rc-dialog-body {
|
|
65
|
+
padding: 20px;
|
|
66
|
+
}
|
|
67
|
+
.rc-dialog-footer {
|
|
68
|
+
border-top: 1px solid #e9e9e9;
|
|
69
|
+
padding: 10px 20px;
|
|
70
|
+
text-align: right;
|
|
71
|
+
border-radius: 0 0 5px 5px;
|
|
72
|
+
}
|
|
73
|
+
.rc-dialog-zoom-enter,
|
|
74
|
+
.rc-dialog-zoom-appear {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
animation-duration: 0.3s;
|
|
77
|
+
animation-fill-mode: both;
|
|
78
|
+
animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1);
|
|
79
|
+
animation-play-state: paused;
|
|
80
|
+
}
|
|
81
|
+
.rc-dialog-zoom-leave {
|
|
82
|
+
animation-duration: 0.3s;
|
|
83
|
+
animation-fill-mode: both;
|
|
84
|
+
animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34);
|
|
85
|
+
animation-play-state: paused;
|
|
86
|
+
}
|
|
87
|
+
.rc-dialog-zoom-enter.rc-dialog-zoom-enter-active,
|
|
88
|
+
.rc-dialog-zoom-appear.rc-dialog-zoom-appear-active {
|
|
89
|
+
animation-name: rcDialogZoomIn;
|
|
90
|
+
animation-play-state: running;
|
|
91
|
+
}
|
|
92
|
+
.rc-dialog-zoom-leave.rc-dialog-zoom-leave-active {
|
|
93
|
+
animation-name: rcDialogZoomOut;
|
|
94
|
+
animation-play-state: running;
|
|
95
|
+
}
|
|
96
|
+
@keyframes rcDialogZoomIn {
|
|
97
|
+
0% {
|
|
98
|
+
opacity: 0;
|
|
99
|
+
transform: scale(0, 0);
|
|
100
|
+
}
|
|
101
|
+
100% {
|
|
102
|
+
opacity: 1;
|
|
103
|
+
transform: scale(1, 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
@keyframes rcDialogZoomOut {
|
|
107
|
+
0% {
|
|
108
|
+
transform: scale(1, 1);
|
|
109
|
+
}
|
|
110
|
+
100% {
|
|
111
|
+
opacity: 0;
|
|
112
|
+
transform: scale(0, 0);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
@media (min-width: 768px) {
|
|
116
|
+
.rc-dialog {
|
|
117
|
+
width: 600px;
|
|
118
|
+
margin: 30px auto;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
.rc-dialog-mask {
|
|
122
|
+
position: fixed;
|
|
123
|
+
top: 0;
|
|
124
|
+
right: 0;
|
|
125
|
+
left: 0;
|
|
126
|
+
bottom: 0;
|
|
127
|
+
background-color: #373737;
|
|
128
|
+
background-color: rgba(55, 55, 55, 0.6);
|
|
129
|
+
height: 100%;
|
|
130
|
+
filter: alpha(opacity=50);
|
|
131
|
+
z-index: 1050;
|
|
132
|
+
}
|
|
133
|
+
.rc-dialog-mask-hidden {
|
|
134
|
+
display: none;
|
|
135
|
+
}
|
|
136
|
+
.rc-dialog-fade-enter,
|
|
137
|
+
.rc-dialog-fade-appear {
|
|
138
|
+
opacity: 0;
|
|
139
|
+
animation-duration: 0.3s;
|
|
140
|
+
animation-fill-mode: both;
|
|
141
|
+
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
142
|
+
animation-play-state: paused;
|
|
143
|
+
}
|
|
144
|
+
.rc-dialog-fade-leave {
|
|
145
|
+
animation-duration: 0.3s;
|
|
146
|
+
animation-fill-mode: both;
|
|
147
|
+
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
148
|
+
animation-play-state: paused;
|
|
149
|
+
}
|
|
150
|
+
.rc-dialog-fade-enter.rc-dialog-fade-enter-active,
|
|
151
|
+
.rc-dialog-fade-appear.rc-dialog-fade-appear-active {
|
|
152
|
+
animation-name: rcDialogFadeIn;
|
|
153
|
+
animation-play-state: running;
|
|
154
|
+
}
|
|
155
|
+
.rc-dialog-fade-leave.rc-dialog-fade-leave-active {
|
|
156
|
+
animation-name: rcDialogFadeOut;
|
|
157
|
+
animation-play-state: running;
|
|
158
|
+
}
|
|
159
|
+
@keyframes rcDialogFadeIn {
|
|
160
|
+
0% {
|
|
161
|
+
opacity: 0;
|
|
162
|
+
}
|
|
163
|
+
100% {
|
|
164
|
+
opacity: 1;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
@keyframes rcDialogFadeOut {
|
|
168
|
+
0% {
|
|
169
|
+
opacity: 1;
|
|
170
|
+
}
|
|
171
|
+
100% {
|
|
172
|
+
opacity: 0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type MemoChildrenProps = {
|
|
3
|
+
shouldUpdate: boolean;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: React.MemoExoticComponent<({ children }: MemoChildrenProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IDialogPropTypes } from '../../IDialogPropTypes';
|
|
3
|
+
export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
|
|
4
|
+
prefixCls: string;
|
|
5
|
+
ariaId?: string;
|
|
6
|
+
onMouseDown?: React.MouseEventHandler;
|
|
7
|
+
onMouseUp?: React.MouseEventHandler;
|
|
8
|
+
holderRef?: React.Ref<HTMLDivElement>;
|
|
9
|
+
}
|
|
10
|
+
export type ContentRef = {
|
|
11
|
+
focus: () => void;
|
|
12
|
+
changeActive: (next: boolean) => void;
|
|
13
|
+
};
|
|
14
|
+
declare const Panel: React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<ContentRef>>;
|
|
15
|
+
export default Panel;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { useComposeRef } from "rc-util/es/ref";
|
|
6
|
+
import React, { useMemo, useRef } from 'react';
|
|
7
|
+
import { RefContext } from "../../context";
|
|
8
|
+
import MemoChildren from "./MemoChildren";
|
|
9
|
+
import pickAttrs from "rc-util/es/pickAttrs";
|
|
10
|
+
var sentinelStyle = {
|
|
11
|
+
width: 0,
|
|
12
|
+
height: 0,
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
outline: 'none'
|
|
15
|
+
};
|
|
16
|
+
var entityStyle = {
|
|
17
|
+
outline: 'none'
|
|
18
|
+
};
|
|
19
|
+
var Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
20
|
+
var prefixCls = props.prefixCls,
|
|
21
|
+
className = props.className,
|
|
22
|
+
style = props.style,
|
|
23
|
+
title = props.title,
|
|
24
|
+
ariaId = props.ariaId,
|
|
25
|
+
footer = props.footer,
|
|
26
|
+
closable = props.closable,
|
|
27
|
+
closeIcon = props.closeIcon,
|
|
28
|
+
onClose = props.onClose,
|
|
29
|
+
children = props.children,
|
|
30
|
+
bodyStyle = props.bodyStyle,
|
|
31
|
+
bodyProps = props.bodyProps,
|
|
32
|
+
modalRender = props.modalRender,
|
|
33
|
+
onMouseDown = props.onMouseDown,
|
|
34
|
+
onMouseUp = props.onMouseUp,
|
|
35
|
+
holderRef = props.holderRef,
|
|
36
|
+
visible = props.visible,
|
|
37
|
+
forceRender = props.forceRender,
|
|
38
|
+
width = props.width,
|
|
39
|
+
height = props.height,
|
|
40
|
+
modalClassNames = props.classNames,
|
|
41
|
+
modalStyles = props.styles;
|
|
42
|
+
|
|
43
|
+
// ================================= Refs =================================
|
|
44
|
+
var _React$useContext = React.useContext(RefContext),
|
|
45
|
+
panelRef = _React$useContext.panel;
|
|
46
|
+
var mergedRef = useComposeRef(holderRef, panelRef);
|
|
47
|
+
var sentinelStartRef = useRef();
|
|
48
|
+
var sentinelEndRef = useRef();
|
|
49
|
+
React.useImperativeHandle(ref, function () {
|
|
50
|
+
return {
|
|
51
|
+
focus: function focus() {
|
|
52
|
+
var _sentinelStartRef$cur;
|
|
53
|
+
(_sentinelStartRef$cur = sentinelStartRef.current) === null || _sentinelStartRef$cur === void 0 || _sentinelStartRef$cur.focus({
|
|
54
|
+
preventScroll: true
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
changeActive: function changeActive(next) {
|
|
58
|
+
var _document = document,
|
|
59
|
+
activeElement = _document.activeElement;
|
|
60
|
+
if (next && activeElement === sentinelEndRef.current) {
|
|
61
|
+
sentinelStartRef.current.focus({
|
|
62
|
+
preventScroll: true
|
|
63
|
+
});
|
|
64
|
+
} else if (!next && activeElement === sentinelStartRef.current) {
|
|
65
|
+
sentinelEndRef.current.focus({
|
|
66
|
+
preventScroll: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// ================================ Style =================================
|
|
74
|
+
var contentStyle = {};
|
|
75
|
+
if (width !== undefined) {
|
|
76
|
+
contentStyle.width = width;
|
|
77
|
+
}
|
|
78
|
+
if (height !== undefined) {
|
|
79
|
+
contentStyle.height = height;
|
|
80
|
+
}
|
|
81
|
+
// ================================ Render ================================
|
|
82
|
+
var footerNode = footer ? /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: classNames("".concat(prefixCls, "-footer"), modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.footer),
|
|
84
|
+
style: _objectSpread({}, modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.footer)
|
|
85
|
+
}, footer) : null;
|
|
86
|
+
var headerNode = title ? /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: classNames("".concat(prefixCls, "-header"), modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.header),
|
|
88
|
+
style: _objectSpread({}, modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.header)
|
|
89
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: classNames("".concat(prefixCls, "-title"), modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.title),
|
|
91
|
+
id: ariaId,
|
|
92
|
+
style: _objectSpread({}, modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.title)
|
|
93
|
+
}, title)) : null;
|
|
94
|
+
var closableObj = useMemo(function () {
|
|
95
|
+
if (_typeof(closable) === 'object' && closable !== null) {
|
|
96
|
+
return closable;
|
|
97
|
+
}
|
|
98
|
+
if (closable) {
|
|
99
|
+
return {
|
|
100
|
+
closeIcon: closeIcon !== null && closeIcon !== void 0 ? closeIcon : /*#__PURE__*/React.createElement("span", {
|
|
101
|
+
className: "".concat(prefixCls, "-close-x")
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return {};
|
|
106
|
+
}, [closable, closeIcon, prefixCls]);
|
|
107
|
+
var ariaProps = pickAttrs(closableObj, true);
|
|
108
|
+
var closeBtnIsDisabled = _typeof(closable) === 'object' && closable.disabled;
|
|
109
|
+
var closerNode = closable ? /*#__PURE__*/React.createElement("button", _extends({
|
|
110
|
+
type: "button",
|
|
111
|
+
onClick: onClose,
|
|
112
|
+
"aria-label": "Close"
|
|
113
|
+
}, ariaProps, {
|
|
114
|
+
className: "".concat(prefixCls, "-close"),
|
|
115
|
+
disabled: closeBtnIsDisabled
|
|
116
|
+
}), closableObj.closeIcon) : null;
|
|
117
|
+
var content = /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: classNames("".concat(prefixCls, "-section"), modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.section),
|
|
119
|
+
style: modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.section
|
|
120
|
+
}, closerNode, headerNode, /*#__PURE__*/React.createElement("div", _extends({
|
|
121
|
+
className: classNames("".concat(prefixCls, "-body"), modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.body),
|
|
122
|
+
style: _objectSpread(_objectSpread({}, bodyStyle), modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.body)
|
|
123
|
+
}, bodyProps), children), footerNode);
|
|
124
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
125
|
+
key: "dialog-element",
|
|
126
|
+
role: "dialog",
|
|
127
|
+
"aria-labelledby": title ? ariaId : null,
|
|
128
|
+
"aria-modal": "true",
|
|
129
|
+
ref: mergedRef,
|
|
130
|
+
style: _objectSpread(_objectSpread({}, style), contentStyle),
|
|
131
|
+
className: classNames(prefixCls, className),
|
|
132
|
+
onMouseDown: onMouseDown,
|
|
133
|
+
onMouseUp: onMouseUp
|
|
134
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
135
|
+
ref: sentinelStartRef,
|
|
136
|
+
tabIndex: 0,
|
|
137
|
+
style: entityStyle
|
|
138
|
+
}, /*#__PURE__*/React.createElement(MemoChildren, {
|
|
139
|
+
shouldUpdate: visible || forceRender
|
|
140
|
+
}, modalRender ? modalRender(content) : content)), /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
tabIndex: 0,
|
|
142
|
+
ref: sentinelEndRef,
|
|
143
|
+
style: sentinelStyle
|
|
144
|
+
}));
|
|
145
|
+
});
|
|
146
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
147
|
+
Panel.displayName = 'Panel';
|
|
148
|
+
}
|
|
149
|
+
export default Panel;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PanelProps, ContentRef } from './Panel';
|
|
3
|
+
export type ContentProps = {
|
|
4
|
+
motionName: string;
|
|
5
|
+
ariaId: string;
|
|
6
|
+
onVisibleChanged: (visible: boolean) => void;
|
|
7
|
+
} & PanelProps;
|
|
8
|
+
declare const Content: React.ForwardRefExoticComponent<{
|
|
9
|
+
motionName: string;
|
|
10
|
+
ariaId: string;
|
|
11
|
+
onVisibleChanged: (visible: boolean) => void;
|
|
12
|
+
} & PanelProps & React.RefAttributes<ContentRef>>;
|
|
13
|
+
export default Content;
|