@rc-component/trigger 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 +20 -0
- package/README.md +321 -0
- package/assets/index/Mask.less +63 -0
- package/assets/index/Mobile.less +25 -0
- package/assets/index.css +133 -0
- package/assets/index.less +79 -0
- package/es/Popup/Arrow.d.ts +9 -0
- package/es/Popup/Arrow.js +47 -0
- package/es/Popup/Mask.d.ts +10 -0
- package/es/Popup/Mask.js +26 -0
- package/es/Popup/index.d.ts +39 -0
- package/es/Popup/index.js +149 -0
- package/es/TriggerWrapper.d.ts +8 -0
- package/es/TriggerWrapper.js +19 -0
- package/es/context.d.ts +6 -0
- package/es/context.js +3 -0
- package/es/hooks/useAction.d.ts +4 -0
- package/es/hooks/useAction.js +8 -0
- package/es/hooks/useAlign.d.ts +12 -0
- package/es/hooks/useAlign.js +275 -0
- package/es/hooks/useWatch.d.ts +1 -0
- package/es/hooks/useWatch.js +50 -0
- package/es/index.d.ts +61 -0
- package/es/index.js +448 -0
- package/es/interface.d.ts +122 -0
- package/es/interface.js +1 -0
- package/es/util.d.ts +7 -0
- package/es/util.js +47 -0
- package/lib/Popup/Arrow.d.ts +9 -0
- package/lib/Popup/Arrow.js +54 -0
- package/lib/Popup/Mask.d.ts +10 -0
- package/lib/Popup/Mask.js +33 -0
- package/lib/Popup/index.d.ts +39 -0
- package/lib/Popup/index.js +158 -0
- package/lib/TriggerWrapper.d.ts +8 -0
- package/lib/TriggerWrapper.js +27 -0
- package/lib/context.d.ts +6 -0
- package/lib/context.js +11 -0
- package/lib/hooks/useAction.d.ts +4 -0
- package/lib/hooks/useAction.js +14 -0
- package/lib/hooks/useAlign.d.ts +12 -0
- package/lib/hooks/useAlign.js +283 -0
- package/lib/hooks/useWatch.d.ts +1 -0
- package/lib/hooks/useWatch.js +57 -0
- package/lib/index.d.ts +61 -0
- package/lib/index.js +457 -0
- package/lib/interface.d.ts +122 -0
- package/lib/interface.js +5 -0
- package/lib/util.d.ts +7 -0
- package/lib/util.js +57 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# rc-trigger
|
|
2
|
+
|
|
3
|
+
React Trigger Component
|
|
4
|
+
|
|
5
|
+
[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url]
|
|
6
|
+
|
|
7
|
+
[npm-image]: http://img.shields.io/npm/v/rc-trigger.svg?style=flat-square
|
|
8
|
+
[npm-url]: http://npmjs.org/package/rc-trigger
|
|
9
|
+
[github-actions-image]: https://github.com/react-component/trigger/workflows/CI/badge.svg
|
|
10
|
+
[github-actions-url]: https://github.com/react-component/trigger/actions
|
|
11
|
+
[circleci-image]: https://img.shields.io/circleci/react-component/trigger/master?style=flat-square
|
|
12
|
+
[circleci-url]: https://circleci.com/gh/react-component/trigger
|
|
13
|
+
[coveralls-image]: https://img.shields.io/coveralls/react-component/trigger.svg?style=flat-square
|
|
14
|
+
[coveralls-url]: https://coveralls.io/r/react-component/trigger?branch=master
|
|
15
|
+
[david-url]: https://david-dm.org/react-component/trigger
|
|
16
|
+
[david-image]: https://david-dm.org/react-component/trigger/status.svg?style=flat-square
|
|
17
|
+
[david-dev-url]: https://david-dm.org/react-component/trigger?type=dev
|
|
18
|
+
[david-dev-image]: https://david-dm.org/react-component/trigger/dev-status.svg?style=flat-square
|
|
19
|
+
[download-image]: https://img.shields.io/npm/dm/rc-trigger.svg?style=flat-square
|
|
20
|
+
[download-url]: https://npmjs.org/package/rc-trigger
|
|
21
|
+
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-trigger
|
|
22
|
+
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-trigger
|
|
23
|
+
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
|
|
24
|
+
[dumi-url]: https://github.com/umijs/dumi
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
[](https://npmjs.org/package/rc-trigger)
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Include the default [styling](https://github.com/react-component/trigger/blob/master/assets/index.less#L4:L11) and then:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import React from 'react';
|
|
36
|
+
import ReactDOM from 'react-dom';
|
|
37
|
+
import Trigger from 'rc-trigger';
|
|
38
|
+
|
|
39
|
+
ReactDOM.render((
|
|
40
|
+
<Trigger
|
|
41
|
+
action={['click']}
|
|
42
|
+
popup={<span>popup</span>}
|
|
43
|
+
popupAlign={{
|
|
44
|
+
points: ['tl', 'bl'],
|
|
45
|
+
offset: [0, 3]
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<a href='#'>hover</a>
|
|
49
|
+
</Trigger>
|
|
50
|
+
), container);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Compatibility
|
|
54
|
+
|
|
55
|
+
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
|
|
56
|
+
| --- | --- | --- | --- | --- |
|
|
57
|
+
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
|
|
58
|
+
|
|
59
|
+
## Example
|
|
60
|
+
|
|
61
|
+
http://localhost:9001
|
|
62
|
+
|
|
63
|
+
online example: http://react-component.github.io/trigger/
|
|
64
|
+
|
|
65
|
+
## Development
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
npm install
|
|
69
|
+
npm start
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## API
|
|
73
|
+
|
|
74
|
+
### props
|
|
75
|
+
|
|
76
|
+
<table class="table table-bordered table-striped">
|
|
77
|
+
<thead>
|
|
78
|
+
<tr>
|
|
79
|
+
<th style="width: 100px;">name</th>
|
|
80
|
+
<th style="width: 50px;">type</th>
|
|
81
|
+
<th style="width: 50px;">default</th>
|
|
82
|
+
<th>description</th>
|
|
83
|
+
</tr>
|
|
84
|
+
</thead>
|
|
85
|
+
<tbody>
|
|
86
|
+
<tr>
|
|
87
|
+
<td>alignPoint</td>
|
|
88
|
+
<td>bool</td>
|
|
89
|
+
<td>false</td>
|
|
90
|
+
<td>Popup will align with mouse position (support action of 'click', 'hover' and 'contextMenu')</td>
|
|
91
|
+
</tr>
|
|
92
|
+
<tr>
|
|
93
|
+
<td>popupClassName</td>
|
|
94
|
+
<td>string</td>
|
|
95
|
+
<td></td>
|
|
96
|
+
<td>additional className added to popup</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td>forceRender</td>
|
|
100
|
+
<td>boolean</td>
|
|
101
|
+
<td>false</td>
|
|
102
|
+
<td>whether render popup before first show</td>
|
|
103
|
+
</tr>
|
|
104
|
+
<tr>
|
|
105
|
+
<td>destroyPopupOnHide</td>
|
|
106
|
+
<td>boolean</td>
|
|
107
|
+
<td>false</td>
|
|
108
|
+
<td>whether destroy popup when hide</td>
|
|
109
|
+
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td>getPopupClassNameFromAlign</td>
|
|
112
|
+
<td>getPopupClassNameFromAlign(align: Object):String</td>
|
|
113
|
+
<td></td>
|
|
114
|
+
<td>additional className added to popup according to align</td>
|
|
115
|
+
</tr>
|
|
116
|
+
<tr>
|
|
117
|
+
<td>action</td>
|
|
118
|
+
<td>string[]</td>
|
|
119
|
+
<td>['hover']</td>
|
|
120
|
+
<td>which actions cause popup shown. enum of 'hover','click','focus','contextMenu'</td>
|
|
121
|
+
</tr>
|
|
122
|
+
<tr>
|
|
123
|
+
<td>mouseEnterDelay</td>
|
|
124
|
+
<td>number</td>
|
|
125
|
+
<td>0</td>
|
|
126
|
+
<td>delay time to show when mouse enter. unit: s.</td>
|
|
127
|
+
</tr>
|
|
128
|
+
<tr>
|
|
129
|
+
<td>mouseLeaveDelay</td>
|
|
130
|
+
<td>number</td>
|
|
131
|
+
<td>0.1</td>
|
|
132
|
+
<td>delay time to hide when mouse leave. unit: s.</td>
|
|
133
|
+
</tr>
|
|
134
|
+
<tr>
|
|
135
|
+
<td>popupStyle</td>
|
|
136
|
+
<td>Object</td>
|
|
137
|
+
<td></td>
|
|
138
|
+
<td>additional style of popup</td>
|
|
139
|
+
</tr>
|
|
140
|
+
<tr>
|
|
141
|
+
<td>prefixCls</td>
|
|
142
|
+
<td>String</td>
|
|
143
|
+
<td>rc-trigger-popup</td>
|
|
144
|
+
<td>prefix class name</td>
|
|
145
|
+
</tr>
|
|
146
|
+
<tr>
|
|
147
|
+
<td>popupTransitionName</td>
|
|
148
|
+
<td>String|Object</td>
|
|
149
|
+
<td></td>
|
|
150
|
+
<td>https://github.com/react-component/animate</td>
|
|
151
|
+
</tr>
|
|
152
|
+
<tr>
|
|
153
|
+
<td>maskTransitionName</td>
|
|
154
|
+
<td>String|Object</td>
|
|
155
|
+
<td></td>
|
|
156
|
+
<td>https://github.com/react-component/animate</td>
|
|
157
|
+
</tr>
|
|
158
|
+
<tr>
|
|
159
|
+
<td>onPopupVisibleChange</td>
|
|
160
|
+
<td>Function</td>
|
|
161
|
+
<td></td>
|
|
162
|
+
<td>call when popup visible is changed</td>
|
|
163
|
+
</tr>
|
|
164
|
+
<tr>
|
|
165
|
+
<td>mask</td>
|
|
166
|
+
<td>boolean</td>
|
|
167
|
+
<td>false</td>
|
|
168
|
+
<td>whether to support mask</td>
|
|
169
|
+
</tr>
|
|
170
|
+
<tr>
|
|
171
|
+
<td>maskClosable</td>
|
|
172
|
+
<td>boolean</td>
|
|
173
|
+
<td>true</td>
|
|
174
|
+
<td>whether to support click mask to hide</td>
|
|
175
|
+
</tr>
|
|
176
|
+
<tr>
|
|
177
|
+
<td>popupVisible</td>
|
|
178
|
+
<td>boolean</td>
|
|
179
|
+
<td></td>
|
|
180
|
+
<td>whether popup is visible</td>
|
|
181
|
+
</tr>
|
|
182
|
+
<tr>
|
|
183
|
+
<td>zIndex</td>
|
|
184
|
+
<td>number</td>
|
|
185
|
+
<td></td>
|
|
186
|
+
<td>popup's zIndex</td>
|
|
187
|
+
</tr>
|
|
188
|
+
<tr>
|
|
189
|
+
<td>defaultPopupVisible</td>
|
|
190
|
+
<td>boolean</td>
|
|
191
|
+
<td></td>
|
|
192
|
+
<td>whether popup is visible initially</td>
|
|
193
|
+
</tr>
|
|
194
|
+
<tr>
|
|
195
|
+
<td>popupAlign</td>
|
|
196
|
+
<td>Object: alignConfig of [dom-align](https://github.com/yiminghe/dom-align)</td>
|
|
197
|
+
<td></td>
|
|
198
|
+
<td>popup 's align config</td>
|
|
199
|
+
</tr>
|
|
200
|
+
<tr>
|
|
201
|
+
<td>onPopupAlign</td>
|
|
202
|
+
<td>function(popupDomNode, align)</td>
|
|
203
|
+
<td></td>
|
|
204
|
+
<td>callback when popup node is aligned</td>
|
|
205
|
+
</tr>
|
|
206
|
+
<tr>
|
|
207
|
+
<td>popup</td>
|
|
208
|
+
<td>React.Element | function() => React.Element</td>
|
|
209
|
+
<td></td>
|
|
210
|
+
<td>popup content</td>
|
|
211
|
+
</tr>
|
|
212
|
+
<tr>
|
|
213
|
+
<td>getPopupContainer</td>
|
|
214
|
+
<td>getPopupContainer(): HTMLElement</td>
|
|
215
|
+
<td></td>
|
|
216
|
+
<td>function returning html node which will act as popup container</td>
|
|
217
|
+
</tr>
|
|
218
|
+
<tr>
|
|
219
|
+
<td>getDocument</td>
|
|
220
|
+
<td>getDocument(): HTMLElement</td>
|
|
221
|
+
<td></td>
|
|
222
|
+
<td>function returning document node which will be attached click event to close trigger</td>
|
|
223
|
+
</tr>
|
|
224
|
+
<tr>
|
|
225
|
+
<td>popupPlacement</td>
|
|
226
|
+
<td>string</td>
|
|
227
|
+
<td></td>
|
|
228
|
+
<td>use preset popup align config from builtinPlacements, can be merged by popupAlign prop</td>
|
|
229
|
+
</tr>
|
|
230
|
+
<tr>
|
|
231
|
+
<td>builtinPlacements</td>
|
|
232
|
+
<td>object</td>
|
|
233
|
+
<td></td>
|
|
234
|
+
<td>builtin placement align map. used by placement prop</td>
|
|
235
|
+
</tr>
|
|
236
|
+
<tr>
|
|
237
|
+
<td>stretch</td>
|
|
238
|
+
<td>string</td>
|
|
239
|
+
<td></td>
|
|
240
|
+
<td>Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')</td>
|
|
241
|
+
</tr>
|
|
242
|
+
</tbody>
|
|
243
|
+
</table>
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
## Test Case
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
npm test
|
|
250
|
+
npm run chrome-test
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Coverage
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
npm run coverage
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
open coverage/ dir
|
|
260
|
+
|
|
261
|
+
## React 16 Note
|
|
262
|
+
|
|
263
|
+
After React 16, you won't access popup element's ref in parent component's componentDidMount, which means following code won't work.
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
class App extends React.Component {
|
|
267
|
+
componentDidMount() {
|
|
268
|
+
this.input.focus(); // error, this.input is undefined.
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
render() {
|
|
272
|
+
return (
|
|
273
|
+
<Trigger
|
|
274
|
+
action={['click']}
|
|
275
|
+
popup={<div><input ref={node => this.input = node} type="text" /></div>}
|
|
276
|
+
>
|
|
277
|
+
<button>click</button>
|
|
278
|
+
</Trigger>
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Consider wrap your popup element to a separate component:
|
|
285
|
+
|
|
286
|
+
```javascript
|
|
287
|
+
class InputPopup extends React.Component {
|
|
288
|
+
componentDidMount() {
|
|
289
|
+
this.props.onMount();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
render() {
|
|
293
|
+
return (
|
|
294
|
+
<div>
|
|
295
|
+
<input ref={this.props.inputRef} type="text" />
|
|
296
|
+
</div>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
class App extends React.Component {
|
|
302
|
+
handlePopupMount() {
|
|
303
|
+
this.input.focus(); // error, this.input is undefined.
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
render() {
|
|
307
|
+
return (
|
|
308
|
+
<Trigger
|
|
309
|
+
action={['click']}
|
|
310
|
+
popup={<InputPopup inputRef={node => this.input = node} onMount={this.handlePopupMount} />}
|
|
311
|
+
>
|
|
312
|
+
<button>click</button>
|
|
313
|
+
</Trigger>
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## License
|
|
320
|
+
|
|
321
|
+
rc-trigger is released under the MIT license.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
.@{triggerPrefixCls} {
|
|
2
|
+
&-mask {
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
bottom: 0;
|
|
8
|
+
background-color: rgb(55, 55, 55);
|
|
9
|
+
background-color: rgba(55, 55, 55, 0.6);
|
|
10
|
+
height: 100%;
|
|
11
|
+
filter: alpha(opacity=50);
|
|
12
|
+
z-index: 1050;
|
|
13
|
+
|
|
14
|
+
&-hidden {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.fade-effect() {
|
|
20
|
+
animation-duration: 0.3s;
|
|
21
|
+
animation-fill-mode: both;
|
|
22
|
+
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-fade-enter,&-fade-appear {
|
|
26
|
+
opacity: 0;
|
|
27
|
+
.fade-effect();
|
|
28
|
+
animation-play-state: paused;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&-fade-leave {
|
|
32
|
+
.fade-effect();
|
|
33
|
+
animation-play-state: paused;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&-fade-enter&-fade-enter-active,&-fade-appear&-fade-appear-active {
|
|
37
|
+
animation-name: rcTriggerMaskFadeIn;
|
|
38
|
+
animation-play-state: running;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&-fade-leave&-fade-leave-active {
|
|
42
|
+
animation-name: rcDialogFadeOut;
|
|
43
|
+
animation-play-state: running;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@keyframes rcTriggerMaskFadeIn {
|
|
47
|
+
0% {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
}
|
|
50
|
+
100% {
|
|
51
|
+
opacity: 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@keyframes rcDialogFadeOut {
|
|
56
|
+
0% {
|
|
57
|
+
opacity: 1;
|
|
58
|
+
}
|
|
59
|
+
100% {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.@{triggerPrefixCls} {
|
|
2
|
+
&-mobile {
|
|
3
|
+
transition: all 0.3s;
|
|
4
|
+
position: fixed;
|
|
5
|
+
left: 0;
|
|
6
|
+
right: 0;
|
|
7
|
+
bottom: 0;
|
|
8
|
+
top: auto;
|
|
9
|
+
|
|
10
|
+
&-fade {
|
|
11
|
+
&-appear,
|
|
12
|
+
&-enter {
|
|
13
|
+
&-start {
|
|
14
|
+
transform: translateY(100%);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-leave {
|
|
19
|
+
&-active {
|
|
20
|
+
transform: translateY(100%);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/assets/index.css
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
.rc-trigger-popup {
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: -9999px;
|
|
4
|
+
left: -9999px;
|
|
5
|
+
z-index: 1050;
|
|
6
|
+
}
|
|
7
|
+
.rc-trigger-popup-hidden {
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
.rc-trigger-popup-zoom-enter,
|
|
11
|
+
.rc-trigger-popup-zoom-appear {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
animation-play-state: paused;
|
|
14
|
+
animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
|
|
15
|
+
animation-duration: 0.3s;
|
|
16
|
+
animation-fill-mode: both;
|
|
17
|
+
}
|
|
18
|
+
.rc-trigger-popup-zoom-leave {
|
|
19
|
+
animation-duration: 0.3s;
|
|
20
|
+
animation-fill-mode: both;
|
|
21
|
+
animation-play-state: paused;
|
|
22
|
+
animation-timing-function: cubic-bezier(0.6, -0.3, 0.74, 0.05);
|
|
23
|
+
}
|
|
24
|
+
.rc-trigger-popup-zoom-enter.rc-trigger-popup-zoom-enter-active,
|
|
25
|
+
.rc-trigger-popup-zoom-appear.rc-trigger-popup-zoom-appear-active {
|
|
26
|
+
animation-name: rcTriggerZoomIn;
|
|
27
|
+
animation-play-state: running;
|
|
28
|
+
}
|
|
29
|
+
.rc-trigger-popup-zoom-leave.rc-trigger-popup-zoom-leave-active {
|
|
30
|
+
animation-name: rcTriggerZoomOut;
|
|
31
|
+
animation-play-state: running;
|
|
32
|
+
}
|
|
33
|
+
.rc-trigger-popup-arrow {
|
|
34
|
+
width: 0px;
|
|
35
|
+
height: 0px;
|
|
36
|
+
background: #000;
|
|
37
|
+
border-radius: 100vw;
|
|
38
|
+
box-shadow: 0 0 0 3px black;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
}
|
|
41
|
+
@keyframes rcTriggerZoomIn {
|
|
42
|
+
0% {
|
|
43
|
+
transform: scale(0, 0);
|
|
44
|
+
transform-origin: 50% 50%;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
100% {
|
|
48
|
+
transform: scale(1, 1);
|
|
49
|
+
transform-origin: 50% 50%;
|
|
50
|
+
opacity: 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
@keyframes rcTriggerZoomOut {
|
|
54
|
+
0% {
|
|
55
|
+
transform: scale(1, 1);
|
|
56
|
+
transform-origin: 50% 50%;
|
|
57
|
+
opacity: 1;
|
|
58
|
+
}
|
|
59
|
+
100% {
|
|
60
|
+
transform: scale(0, 0);
|
|
61
|
+
transform-origin: 50% 50%;
|
|
62
|
+
opacity: 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
.rc-trigger-popup-mask {
|
|
66
|
+
position: fixed;
|
|
67
|
+
top: 0;
|
|
68
|
+
right: 0;
|
|
69
|
+
left: 0;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
background-color: #373737;
|
|
72
|
+
background-color: rgba(55, 55, 55, 0.6);
|
|
73
|
+
height: 100%;
|
|
74
|
+
filter: alpha(opacity=50);
|
|
75
|
+
z-index: 1050;
|
|
76
|
+
}
|
|
77
|
+
.rc-trigger-popup-mask-hidden {
|
|
78
|
+
display: none;
|
|
79
|
+
}
|
|
80
|
+
.rc-trigger-popup-fade-enter,
|
|
81
|
+
.rc-trigger-popup-fade-appear {
|
|
82
|
+
opacity: 0;
|
|
83
|
+
animation-duration: 0.3s;
|
|
84
|
+
animation-fill-mode: both;
|
|
85
|
+
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
86
|
+
animation-play-state: paused;
|
|
87
|
+
}
|
|
88
|
+
.rc-trigger-popup-fade-leave {
|
|
89
|
+
animation-duration: 0.3s;
|
|
90
|
+
animation-fill-mode: both;
|
|
91
|
+
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
92
|
+
animation-play-state: paused;
|
|
93
|
+
}
|
|
94
|
+
.rc-trigger-popup-fade-enter.rc-trigger-popup-fade-enter-active,
|
|
95
|
+
.rc-trigger-popup-fade-appear.rc-trigger-popup-fade-appear-active {
|
|
96
|
+
animation-name: rcTriggerMaskFadeIn;
|
|
97
|
+
animation-play-state: running;
|
|
98
|
+
}
|
|
99
|
+
.rc-trigger-popup-fade-leave.rc-trigger-popup-fade-leave-active {
|
|
100
|
+
animation-name: rcDialogFadeOut;
|
|
101
|
+
animation-play-state: running;
|
|
102
|
+
}
|
|
103
|
+
@keyframes rcTriggerMaskFadeIn {
|
|
104
|
+
0% {
|
|
105
|
+
opacity: 0;
|
|
106
|
+
}
|
|
107
|
+
100% {
|
|
108
|
+
opacity: 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
@keyframes rcDialogFadeOut {
|
|
112
|
+
0% {
|
|
113
|
+
opacity: 1;
|
|
114
|
+
}
|
|
115
|
+
100% {
|
|
116
|
+
opacity: 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
.rc-trigger-popup-mobile {
|
|
120
|
+
transition: all 0.3s;
|
|
121
|
+
position: fixed;
|
|
122
|
+
left: 0;
|
|
123
|
+
right: 0;
|
|
124
|
+
bottom: 0;
|
|
125
|
+
top: auto;
|
|
126
|
+
}
|
|
127
|
+
.rc-trigger-popup-mobile-fade-appear-start,
|
|
128
|
+
.rc-trigger-popup-mobile-fade-enter-start {
|
|
129
|
+
transform: translateY(100%);
|
|
130
|
+
}
|
|
131
|
+
.rc-trigger-popup-mobile-fade-leave-active {
|
|
132
|
+
transform: translateY(100%);
|
|
133
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
@triggerPrefixCls: rc-trigger-popup;
|
|
2
|
+
|
|
3
|
+
.@{triggerPrefixCls} {
|
|
4
|
+
position: absolute;
|
|
5
|
+
top: -9999px;
|
|
6
|
+
left: -9999px;
|
|
7
|
+
z-index: 1050;
|
|
8
|
+
|
|
9
|
+
&-hidden {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.effect() {
|
|
14
|
+
animation-duration: 0.3s;
|
|
15
|
+
animation-fill-mode: both;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-zoom-enter,
|
|
19
|
+
&-zoom-appear {
|
|
20
|
+
opacity: 0;
|
|
21
|
+
animation-play-state: paused;
|
|
22
|
+
animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
|
|
23
|
+
.effect();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&-zoom-leave {
|
|
27
|
+
.effect();
|
|
28
|
+
animation-play-state: paused;
|
|
29
|
+
animation-timing-function: cubic-bezier(0.6, -0.3, 0.74, 0.05);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&-zoom-enter&-zoom-enter-active,
|
|
33
|
+
&-zoom-appear&-zoom-appear-active {
|
|
34
|
+
animation-name: rcTriggerZoomIn;
|
|
35
|
+
animation-play-state: running;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-zoom-leave&-zoom-leave-active {
|
|
39
|
+
animation-name: rcTriggerZoomOut;
|
|
40
|
+
animation-play-state: running;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-arrow {
|
|
44
|
+
width: 0px;
|
|
45
|
+
height: 0px;
|
|
46
|
+
background: #000;
|
|
47
|
+
border-radius: 100vw;
|
|
48
|
+
box-shadow: 0 0 0 3px black;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes rcTriggerZoomIn {
|
|
53
|
+
0% {
|
|
54
|
+
transform: scale(0, 0);
|
|
55
|
+
transform-origin: 50% 50%;
|
|
56
|
+
opacity: 0;
|
|
57
|
+
}
|
|
58
|
+
100% {
|
|
59
|
+
transform: scale(1, 1);
|
|
60
|
+
transform-origin: 50% 50%;
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
@keyframes rcTriggerZoomOut {
|
|
65
|
+
0% {
|
|
66
|
+
transform: scale(1, 1);
|
|
67
|
+
transform-origin: 50% 50%;
|
|
68
|
+
opacity: 1;
|
|
69
|
+
}
|
|
70
|
+
100% {
|
|
71
|
+
transform: scale(0, 0);
|
|
72
|
+
transform-origin: 50% 50%;
|
|
73
|
+
opacity: 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@import './index/Mask';
|
|
79
|
+
@import './index/Mobile';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export default function Arrow(props) {
|
|
3
|
+
var prefixCls = props.prefixCls,
|
|
4
|
+
align = props.align,
|
|
5
|
+
_props$arrowX = props.arrowX,
|
|
6
|
+
arrowX = _props$arrowX === void 0 ? 0 : _props$arrowX,
|
|
7
|
+
_props$arrowY = props.arrowY,
|
|
8
|
+
arrowY = _props$arrowY === void 0 ? 0 : _props$arrowY;
|
|
9
|
+
var arrowRef = React.useRef();
|
|
10
|
+
|
|
11
|
+
// Skip if no align
|
|
12
|
+
if (!align || !align.points) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
var alignStyle = {
|
|
16
|
+
position: 'absolute'
|
|
17
|
+
};
|
|
18
|
+
var popupPoints = align.points[0];
|
|
19
|
+
var targetPoints = align.points[1];
|
|
20
|
+
var popupTB = popupPoints[0];
|
|
21
|
+
var popupLR = popupPoints[1];
|
|
22
|
+
var targetTB = targetPoints[0];
|
|
23
|
+
var targetLR = targetPoints[1];
|
|
24
|
+
|
|
25
|
+
// Top & Bottom
|
|
26
|
+
if (popupTB === targetTB || !['t', 'b'].includes(popupTB)) {
|
|
27
|
+
alignStyle.top = arrowY;
|
|
28
|
+
} else if (popupTB === 't') {
|
|
29
|
+
alignStyle.top = 0;
|
|
30
|
+
} else {
|
|
31
|
+
alignStyle.bottom = 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Left & Right
|
|
35
|
+
if (popupLR === targetLR || !['l', 'r'].includes(popupLR)) {
|
|
36
|
+
alignStyle.left = arrowX;
|
|
37
|
+
} else if (popupLR === 'l') {
|
|
38
|
+
alignStyle.left = 0;
|
|
39
|
+
} else {
|
|
40
|
+
alignStyle.right = 0;
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
ref: arrowRef,
|
|
44
|
+
className: "".concat(prefixCls, "-arrow"),
|
|
45
|
+
style: alignStyle
|
|
46
|
+
});
|
|
47
|
+
}
|