@rc-component/trigger 1.9.0 → 1.10.1
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/README.md +0 -66
- package/es/Popup/Arrow.d.ts +2 -3
- package/es/Popup/Arrow.js +11 -7
- package/es/Popup/index.d.ts +2 -4
- package/es/Popup/index.js +2 -5
- package/es/index.d.ts +3 -3
- package/es/index.js +19 -5
- package/es/interface.d.ts +7 -0
- package/lib/Popup/Arrow.js +12 -7
- package/lib/Popup/index.js +2 -5
- package/lib/index.js +19 -5
- package/package.json +1 -1
- package/lib/Popup/Arrow.d.ts +0 -9
- package/lib/Popup/Mask.d.ts +0 -10
- package/lib/Popup/PopupContent.d.ts +0 -7
- package/lib/Popup/index.d.ts +0 -40
- package/lib/TriggerWrapper.d.ts +0 -8
- package/lib/context.d.ts +0 -6
- package/lib/hooks/useAction.d.ts +0 -4
- package/lib/hooks/useAlign.d.ts +0 -13
- package/lib/hooks/useWatch.d.ts +0 -1
- package/lib/index.d.ts +0 -64
- package/lib/interface.d.ts +0 -75
- package/lib/mock.d.ts +0 -3
- package/lib/util.d.ts +0 -25
package/README.md
CHANGED
|
@@ -65,8 +65,6 @@ ReactDOM.render((
|
|
|
65
65
|
|
|
66
66
|
http://localhost:9001
|
|
67
67
|
|
|
68
|
-
online example: http://react-component.github.io/trigger/
|
|
69
|
-
|
|
70
68
|
## Development
|
|
71
69
|
|
|
72
70
|
```
|
|
@@ -252,75 +250,11 @@ npm start
|
|
|
252
250
|
|
|
253
251
|
```
|
|
254
252
|
npm test
|
|
255
|
-
npm run chrome-test
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
## Coverage
|
|
259
|
-
|
|
260
|
-
```
|
|
261
253
|
npm run coverage
|
|
262
254
|
```
|
|
263
255
|
|
|
264
256
|
open coverage/ dir
|
|
265
257
|
|
|
266
|
-
## React 16 Note
|
|
267
|
-
|
|
268
|
-
After React 16, you won't access popup element's ref in parent component's componentDidMount, which means following code won't work.
|
|
269
|
-
|
|
270
|
-
```javascript
|
|
271
|
-
class App extends React.Component {
|
|
272
|
-
componentDidMount() {
|
|
273
|
-
this.input.focus(); // error, this.input is undefined.
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
render() {
|
|
277
|
-
return (
|
|
278
|
-
<Trigger
|
|
279
|
-
action={['click']}
|
|
280
|
-
popup={<div><input ref={node => this.input = node} type="text" /></div>}
|
|
281
|
-
>
|
|
282
|
-
<button>click</button>
|
|
283
|
-
</Trigger>
|
|
284
|
-
)
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
Consider wrap your popup element to a separate component:
|
|
290
|
-
|
|
291
|
-
```javascript
|
|
292
|
-
class InputPopup extends React.Component {
|
|
293
|
-
componentDidMount() {
|
|
294
|
-
this.props.onMount();
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
render() {
|
|
298
|
-
return (
|
|
299
|
-
<div>
|
|
300
|
-
<input ref={this.props.inputRef} type="text" />
|
|
301
|
-
</div>
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
class App extends React.Component {
|
|
307
|
-
handlePopupMount() {
|
|
308
|
-
this.input.focus(); // error, this.input is undefined.
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
render() {
|
|
312
|
-
return (
|
|
313
|
-
<Trigger
|
|
314
|
-
action={['click']}
|
|
315
|
-
popup={<InputPopup inputRef={node => this.input = node} onMount={this.handlePopupMount} />}
|
|
316
|
-
>
|
|
317
|
-
<button>click</button>
|
|
318
|
-
</Trigger>
|
|
319
|
-
)
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
258
|
## License
|
|
325
259
|
|
|
326
260
|
rc-trigger is released under the MIT license.
|
package/es/Popup/Arrow.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { AlignType } from '../interface';
|
|
2
|
+
import type { AlignType, ArrowType } from '../interface';
|
|
3
3
|
export interface ArrowProps {
|
|
4
4
|
prefixCls: string;
|
|
5
5
|
align: AlignType;
|
|
6
|
-
|
|
7
|
-
arrowY?: number;
|
|
6
|
+
arrow: ArrowType;
|
|
8
7
|
}
|
|
9
8
|
export default function Arrow(props: ArrowProps): JSX.Element;
|
package/es/Popup/Arrow.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
2
3
|
export default function Arrow(props) {
|
|
3
4
|
var prefixCls = props.prefixCls,
|
|
4
5
|
align = props.align,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
arrow = props.arrow;
|
|
7
|
+
var _ref = arrow || {},
|
|
8
|
+
_ref$x = _ref.x,
|
|
9
|
+
x = _ref$x === void 0 ? 0 : _ref$x,
|
|
10
|
+
_ref$y = _ref.y,
|
|
11
|
+
y = _ref$y === void 0 ? 0 : _ref$y,
|
|
12
|
+
className = _ref.className;
|
|
9
13
|
var arrowRef = React.useRef();
|
|
10
14
|
|
|
11
15
|
// Skip if no align
|
|
@@ -27,7 +31,7 @@ export default function Arrow(props) {
|
|
|
27
31
|
|
|
28
32
|
// Top & Bottom
|
|
29
33
|
if (popupTB === targetTB || !['t', 'b'].includes(popupTB)) {
|
|
30
|
-
alignStyle.top =
|
|
34
|
+
alignStyle.top = y;
|
|
31
35
|
} else if (popupTB === 't') {
|
|
32
36
|
alignStyle.top = 0;
|
|
33
37
|
} else {
|
|
@@ -36,7 +40,7 @@ export default function Arrow(props) {
|
|
|
36
40
|
|
|
37
41
|
// Left & Right
|
|
38
42
|
if (popupLR === targetLR || !['l', 'r'].includes(popupLR)) {
|
|
39
|
-
alignStyle.left =
|
|
43
|
+
alignStyle.left = x;
|
|
40
44
|
} else if (popupLR === 'l') {
|
|
41
45
|
alignStyle.left = 0;
|
|
42
46
|
} else {
|
|
@@ -45,7 +49,7 @@ export default function Arrow(props) {
|
|
|
45
49
|
}
|
|
46
50
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
51
|
ref: arrowRef,
|
|
48
|
-
className: "".concat(prefixCls, "-arrow"),
|
|
52
|
+
className: classNames("".concat(prefixCls, "-arrow"), className),
|
|
49
53
|
style: alignStyle
|
|
50
54
|
});
|
|
51
55
|
}
|
package/es/Popup/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSMotionProps } from 'rc-motion';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { TriggerProps } from '../';
|
|
4
|
-
import type { AlignType } from '../interface';
|
|
4
|
+
import type { AlignType, ArrowType } from '../interface';
|
|
5
5
|
export interface PopupProps {
|
|
6
6
|
prefixCls: string;
|
|
7
7
|
className?: string;
|
|
@@ -14,9 +14,7 @@ export interface PopupProps {
|
|
|
14
14
|
mask?: boolean;
|
|
15
15
|
onVisibleChanged: (visible: boolean) => void;
|
|
16
16
|
align?: AlignType;
|
|
17
|
-
arrow?:
|
|
18
|
-
arrowX?: number;
|
|
19
|
-
arrowY?: number;
|
|
17
|
+
arrow?: ArrowType;
|
|
20
18
|
open: boolean;
|
|
21
19
|
/** Tell Portal that should keep in screen. e.g. should wait all motion end */
|
|
22
20
|
keepDom: boolean;
|
package/es/Popup/index.js
CHANGED
|
@@ -23,8 +23,6 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
23
23
|
mask = props.mask,
|
|
24
24
|
arrow = props.arrow,
|
|
25
25
|
align = props.align,
|
|
26
|
-
arrowX = props.arrowX,
|
|
27
|
-
arrowY = props.arrowY,
|
|
28
26
|
motion = props.motion,
|
|
29
27
|
maskMotion = props.maskMotion,
|
|
30
28
|
forceRender = props.forceRender,
|
|
@@ -140,9 +138,8 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
140
138
|
onClick: onClick
|
|
141
139
|
}, arrow && /*#__PURE__*/React.createElement(Arrow, {
|
|
142
140
|
prefixCls: prefixCls,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
arrowY: arrowY
|
|
141
|
+
arrow: arrow,
|
|
142
|
+
align: align
|
|
146
143
|
}), /*#__PURE__*/React.createElement(PopupContent, {
|
|
147
144
|
cache: !open
|
|
148
145
|
}, childNode));
|
package/es/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSMotionProps } from 'rc-motion';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import type { ActionType, AlignType, AnimationType, BuildInPlacements, TransitionNameType } from './interface';
|
|
4
|
-
export type { BuildInPlacements, AlignType, ActionType };
|
|
3
|
+
import type { ActionType, AlignType, AnimationType, ArrowTypeOuter, BuildInPlacements, TransitionNameType } from './interface';
|
|
4
|
+
export type { BuildInPlacements, AlignType, ActionType, ArrowTypeOuter as ArrowType, };
|
|
5
5
|
export interface TriggerRef {
|
|
6
6
|
forceAlign: VoidFunction;
|
|
7
7
|
}
|
|
@@ -50,7 +50,7 @@ export interface TriggerProps {
|
|
|
50
50
|
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
51
51
|
onPopupClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
52
52
|
alignPoint?: boolean;
|
|
53
|
-
arrow?: boolean;
|
|
53
|
+
arrow?: boolean | ArrowTypeOuter;
|
|
54
54
|
/** @deprecated Add `className` on `children`. Please add `className` directly instead. */
|
|
55
55
|
className?: string;
|
|
56
56
|
/**
|
package/es/index.js
CHANGED
|
@@ -327,19 +327,29 @@ export function generateTrigger() {
|
|
|
327
327
|
// Click to hide is special action since click popup element should not hide
|
|
328
328
|
React.useEffect(function () {
|
|
329
329
|
if (clickToHide && popupEle && (!mask || maskClosable)) {
|
|
330
|
-
var
|
|
330
|
+
var clickInside = false;
|
|
331
|
+
|
|
332
|
+
// User may mouseDown inside and drag out of popup and mouse up
|
|
333
|
+
// Record here to prevent close
|
|
334
|
+
var onWindowMouseDown = function onWindowMouseDown(_ref) {
|
|
331
335
|
var target = _ref.target;
|
|
332
|
-
|
|
336
|
+
clickInside = inPopupOrChild(target);
|
|
337
|
+
};
|
|
338
|
+
var onWindowClick = function onWindowClick(_ref2) {
|
|
339
|
+
var target = _ref2.target;
|
|
340
|
+
if (openRef.current && !clickInside && !inPopupOrChild(target)) {
|
|
333
341
|
triggerOpen(false);
|
|
334
342
|
}
|
|
335
343
|
};
|
|
336
344
|
var win = getWin(popupEle);
|
|
337
345
|
var targetRoot = targetEle === null || targetEle === void 0 ? void 0 : targetEle.getRootNode();
|
|
346
|
+
win.addEventListener('mousedown', onWindowMouseDown);
|
|
338
347
|
win.addEventListener('click', onWindowClick);
|
|
339
348
|
|
|
340
349
|
// shadow root
|
|
341
350
|
var inShadow = targetRoot && targetRoot !== targetEle.ownerDocument;
|
|
342
351
|
if (inShadow) {
|
|
352
|
+
targetRoot.addEventListener('mousedown', onWindowMouseDown);
|
|
343
353
|
targetRoot.addEventListener('click', onWindowClick);
|
|
344
354
|
}
|
|
345
355
|
|
|
@@ -349,8 +359,10 @@ export function generateTrigger() {
|
|
|
349
359
|
warning(targetRoot === popupRoot, "trigger element and popup element should in same shadow root.");
|
|
350
360
|
}
|
|
351
361
|
return function () {
|
|
362
|
+
win.removeEventListener('mousedown', onWindowMouseDown);
|
|
352
363
|
win.removeEventListener('click', onWindowClick);
|
|
353
364
|
if (inShadow) {
|
|
365
|
+
targetRoot.removeEventListener('mousedown', onWindowMouseDown);
|
|
354
366
|
targetRoot.removeEventListener('click', onWindowClick);
|
|
355
367
|
}
|
|
356
368
|
};
|
|
@@ -436,6 +448,10 @@ export function generateTrigger() {
|
|
|
436
448
|
|
|
437
449
|
// Child Node
|
|
438
450
|
var triggerNode = /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, mergedChildrenProps), passedProps));
|
|
451
|
+
var innerArrow = arrow ? _objectSpread(_objectSpread({}, arrow !== true ? arrow : {}), {}, {
|
|
452
|
+
x: arrowX,
|
|
453
|
+
y: arrowY
|
|
454
|
+
}) : null;
|
|
439
455
|
|
|
440
456
|
// Render
|
|
441
457
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
@@ -481,14 +497,12 @@ export function generateTrigger() {
|
|
|
481
497
|
// Arrow
|
|
482
498
|
,
|
|
483
499
|
align: alignInfo,
|
|
484
|
-
arrow:
|
|
500
|
+
arrow: innerArrow
|
|
485
501
|
// Align
|
|
486
502
|
,
|
|
487
503
|
ready: ready,
|
|
488
504
|
offsetX: offsetX,
|
|
489
505
|
offsetY: offsetY,
|
|
490
|
-
arrowX: arrowX,
|
|
491
|
-
arrowY: arrowY,
|
|
492
506
|
onAlign: triggerAlign
|
|
493
507
|
// Stretch
|
|
494
508
|
,
|
package/es/interface.d.ts
CHANGED
|
@@ -54,6 +54,13 @@ export interface AlignType {
|
|
|
54
54
|
useCssTransform?: boolean;
|
|
55
55
|
ignoreShake?: boolean;
|
|
56
56
|
}
|
|
57
|
+
export interface ArrowTypeOuter {
|
|
58
|
+
className?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare type ArrowType = ArrowTypeOuter & {
|
|
61
|
+
x?: number;
|
|
62
|
+
y?: number;
|
|
63
|
+
};
|
|
57
64
|
export declare type BuildInPlacements = Record<string, AlignType>;
|
|
58
65
|
export declare type StretchType = string;
|
|
59
66
|
export declare type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
|
package/lib/Popup/Arrow.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = Arrow;
|
|
8
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
11
|
function Arrow(props) {
|
|
10
12
|
var prefixCls = props.prefixCls,
|
|
11
13
|
align = props.align,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
arrow = props.arrow;
|
|
15
|
+
var _ref = arrow || {},
|
|
16
|
+
_ref$x = _ref.x,
|
|
17
|
+
x = _ref$x === void 0 ? 0 : _ref$x,
|
|
18
|
+
_ref$y = _ref.y,
|
|
19
|
+
y = _ref$y === void 0 ? 0 : _ref$y,
|
|
20
|
+
className = _ref.className;
|
|
16
21
|
var arrowRef = React.useRef();
|
|
17
22
|
|
|
18
23
|
// Skip if no align
|
|
@@ -34,7 +39,7 @@ function Arrow(props) {
|
|
|
34
39
|
|
|
35
40
|
// Top & Bottom
|
|
36
41
|
if (popupTB === targetTB || !['t', 'b'].includes(popupTB)) {
|
|
37
|
-
alignStyle.top =
|
|
42
|
+
alignStyle.top = y;
|
|
38
43
|
} else if (popupTB === 't') {
|
|
39
44
|
alignStyle.top = 0;
|
|
40
45
|
} else {
|
|
@@ -43,7 +48,7 @@ function Arrow(props) {
|
|
|
43
48
|
|
|
44
49
|
// Left & Right
|
|
45
50
|
if (popupLR === targetLR || !['l', 'r'].includes(popupLR)) {
|
|
46
|
-
alignStyle.left =
|
|
51
|
+
alignStyle.left = x;
|
|
47
52
|
} else if (popupLR === 'l') {
|
|
48
53
|
alignStyle.left = 0;
|
|
49
54
|
} else {
|
|
@@ -52,7 +57,7 @@ function Arrow(props) {
|
|
|
52
57
|
}
|
|
53
58
|
return /*#__PURE__*/React.createElement("div", {
|
|
54
59
|
ref: arrowRef,
|
|
55
|
-
className: "".concat(prefixCls, "-arrow"),
|
|
60
|
+
className: (0, _classnames.default)("".concat(prefixCls, "-arrow"), className),
|
|
56
61
|
style: alignStyle
|
|
57
62
|
});
|
|
58
63
|
}
|
package/lib/Popup/index.js
CHANGED
|
@@ -31,8 +31,6 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
31
31
|
mask = props.mask,
|
|
32
32
|
arrow = props.arrow,
|
|
33
33
|
align = props.align,
|
|
34
|
-
arrowX = props.arrowX,
|
|
35
|
-
arrowY = props.arrowY,
|
|
36
34
|
motion = props.motion,
|
|
37
35
|
maskMotion = props.maskMotion,
|
|
38
36
|
forceRender = props.forceRender,
|
|
@@ -148,9 +146,8 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
148
146
|
onClick: onClick
|
|
149
147
|
}, arrow && /*#__PURE__*/React.createElement(_Arrow.default, {
|
|
150
148
|
prefixCls: prefixCls,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
arrowY: arrowY
|
|
149
|
+
arrow: arrow,
|
|
150
|
+
align: align
|
|
154
151
|
}), /*#__PURE__*/React.createElement(_PopupContent.default, {
|
|
155
152
|
cache: !open
|
|
156
153
|
}, childNode));
|
package/lib/index.js
CHANGED
|
@@ -336,19 +336,29 @@ function generateTrigger() {
|
|
|
336
336
|
// Click to hide is special action since click popup element should not hide
|
|
337
337
|
React.useEffect(function () {
|
|
338
338
|
if (clickToHide && popupEle && (!mask || maskClosable)) {
|
|
339
|
-
var
|
|
339
|
+
var clickInside = false;
|
|
340
|
+
|
|
341
|
+
// User may mouseDown inside and drag out of popup and mouse up
|
|
342
|
+
// Record here to prevent close
|
|
343
|
+
var onWindowMouseDown = function onWindowMouseDown(_ref) {
|
|
340
344
|
var target = _ref.target;
|
|
341
|
-
|
|
345
|
+
clickInside = inPopupOrChild(target);
|
|
346
|
+
};
|
|
347
|
+
var onWindowClick = function onWindowClick(_ref2) {
|
|
348
|
+
var target = _ref2.target;
|
|
349
|
+
if (openRef.current && !clickInside && !inPopupOrChild(target)) {
|
|
342
350
|
triggerOpen(false);
|
|
343
351
|
}
|
|
344
352
|
};
|
|
345
353
|
var win = (0, _util.getWin)(popupEle);
|
|
346
354
|
var targetRoot = targetEle === null || targetEle === void 0 ? void 0 : targetEle.getRootNode();
|
|
355
|
+
win.addEventListener('mousedown', onWindowMouseDown);
|
|
347
356
|
win.addEventListener('click', onWindowClick);
|
|
348
357
|
|
|
349
358
|
// shadow root
|
|
350
359
|
var inShadow = targetRoot && targetRoot !== targetEle.ownerDocument;
|
|
351
360
|
if (inShadow) {
|
|
361
|
+
targetRoot.addEventListener('mousedown', onWindowMouseDown);
|
|
352
362
|
targetRoot.addEventListener('click', onWindowClick);
|
|
353
363
|
}
|
|
354
364
|
|
|
@@ -358,8 +368,10 @@ function generateTrigger() {
|
|
|
358
368
|
(0, _warning.default)(targetRoot === popupRoot, "trigger element and popup element should in same shadow root.");
|
|
359
369
|
}
|
|
360
370
|
return function () {
|
|
371
|
+
win.removeEventListener('mousedown', onWindowMouseDown);
|
|
361
372
|
win.removeEventListener('click', onWindowClick);
|
|
362
373
|
if (inShadow) {
|
|
374
|
+
targetRoot.removeEventListener('mousedown', onWindowMouseDown);
|
|
363
375
|
targetRoot.removeEventListener('click', onWindowClick);
|
|
364
376
|
}
|
|
365
377
|
};
|
|
@@ -445,6 +457,10 @@ function generateTrigger() {
|
|
|
445
457
|
|
|
446
458
|
// Child Node
|
|
447
459
|
var triggerNode = /*#__PURE__*/React.cloneElement(child, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, mergedChildrenProps), passedProps));
|
|
460
|
+
var innerArrow = arrow ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, arrow !== true ? arrow : {}), {}, {
|
|
461
|
+
x: arrowX,
|
|
462
|
+
y: arrowY
|
|
463
|
+
}) : null;
|
|
448
464
|
|
|
449
465
|
// Render
|
|
450
466
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_rcResizeObserver.default, {
|
|
@@ -490,14 +506,12 @@ function generateTrigger() {
|
|
|
490
506
|
// Arrow
|
|
491
507
|
,
|
|
492
508
|
align: alignInfo,
|
|
493
|
-
arrow:
|
|
509
|
+
arrow: innerArrow
|
|
494
510
|
// Align
|
|
495
511
|
,
|
|
496
512
|
ready: ready,
|
|
497
513
|
offsetX: offsetX,
|
|
498
514
|
offsetY: offsetY,
|
|
499
|
-
arrowX: arrowX,
|
|
500
|
-
arrowY: arrowY,
|
|
501
515
|
onAlign: triggerAlign
|
|
502
516
|
// Stretch
|
|
503
517
|
,
|
package/package.json
CHANGED
package/lib/Popup/Arrow.d.ts
DELETED
package/lib/Popup/Mask.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { CSSMotionProps } from 'rc-motion';
|
|
3
|
-
export interface MaskProps {
|
|
4
|
-
prefixCls: string;
|
|
5
|
-
open?: boolean;
|
|
6
|
-
zIndex?: number;
|
|
7
|
-
mask?: boolean;
|
|
8
|
-
motion?: CSSMotionProps;
|
|
9
|
-
}
|
|
10
|
-
export default function Mask(props: MaskProps): JSX.Element;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export interface PopupContentProps {
|
|
3
|
-
children?: React.ReactNode;
|
|
4
|
-
cache?: boolean;
|
|
5
|
-
}
|
|
6
|
-
declare const PopupContent: React.MemoExoticComponent<({ children }: PopupContentProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>>;
|
|
7
|
-
export default PopupContent;
|
package/lib/Popup/index.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { CSSMotionProps } from 'rc-motion';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import type { TriggerProps } from '../';
|
|
4
|
-
import type { AlignType } from '../interface';
|
|
5
|
-
export interface PopupProps {
|
|
6
|
-
prefixCls: string;
|
|
7
|
-
className?: string;
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
popup?: TriggerProps['popup'];
|
|
10
|
-
target: HTMLElement;
|
|
11
|
-
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
12
|
-
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
|
-
zIndex?: number;
|
|
14
|
-
mask?: boolean;
|
|
15
|
-
onVisibleChanged: (visible: boolean) => void;
|
|
16
|
-
align?: AlignType;
|
|
17
|
-
arrow?: boolean;
|
|
18
|
-
arrowX?: number;
|
|
19
|
-
arrowY?: number;
|
|
20
|
-
open: boolean;
|
|
21
|
-
/** Tell Portal that should keep in screen. e.g. should wait all motion end */
|
|
22
|
-
keepDom: boolean;
|
|
23
|
-
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
24
|
-
motion?: CSSMotionProps;
|
|
25
|
-
maskMotion?: CSSMotionProps;
|
|
26
|
-
forceRender?: boolean;
|
|
27
|
-
getPopupContainer?: TriggerProps['getPopupContainer'];
|
|
28
|
-
autoDestroy?: boolean;
|
|
29
|
-
portal: React.ComponentType<any>;
|
|
30
|
-
ready: boolean;
|
|
31
|
-
offsetX: number;
|
|
32
|
-
offsetY: number;
|
|
33
|
-
onAlign: VoidFunction;
|
|
34
|
-
onPrepare: () => Promise<void>;
|
|
35
|
-
stretch?: string;
|
|
36
|
-
targetWidth?: number;
|
|
37
|
-
targetHeight?: number;
|
|
38
|
-
}
|
|
39
|
-
declare const Popup: React.ForwardRefExoticComponent<PopupProps & React.RefAttributes<HTMLDivElement>>;
|
|
40
|
-
export default Popup;
|
package/lib/TriggerWrapper.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { TriggerProps } from '.';
|
|
3
|
-
export interface TriggerWrapperProps {
|
|
4
|
-
getTriggerDOMNode?: TriggerProps['getTriggerDOMNode'];
|
|
5
|
-
children: React.ReactElement;
|
|
6
|
-
}
|
|
7
|
-
declare const TriggerWrapper: React.ForwardRefExoticComponent<TriggerWrapperProps & React.RefAttributes<HTMLElement>>;
|
|
8
|
-
export default TriggerWrapper;
|
package/lib/context.d.ts
DELETED
package/lib/hooks/useAction.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ActionType } from '../interface';
|
|
2
|
-
declare type ActionTypes = ActionType | ActionType[];
|
|
3
|
-
export default function useAction(mobile: boolean, action: ActionTypes, showAction?: ActionTypes, hideAction?: ActionTypes): [showAction: Set<ActionType>, hideAction: Set<ActionType>];
|
|
4
|
-
export {};
|
package/lib/hooks/useAlign.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TriggerProps } from '..';
|
|
2
|
-
import type { AlignType } from '../interface';
|
|
3
|
-
export default function useAlign(open: boolean, popupEle: HTMLElement, target: HTMLElement | [x: number, y: number], placement: string, builtinPlacements: any, popupAlign?: AlignType, onPopupAlign?: TriggerProps['onPopupAlign']): [
|
|
4
|
-
ready: boolean,
|
|
5
|
-
offsetX: number,
|
|
6
|
-
offsetY: number,
|
|
7
|
-
arrowX: number,
|
|
8
|
-
arrowY: number,
|
|
9
|
-
scaleX: number,
|
|
10
|
-
scaleY: number,
|
|
11
|
-
align: AlignType,
|
|
12
|
-
onAlign: VoidFunction
|
|
13
|
-
];
|
package/lib/hooks/useWatch.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function useWatch(open: boolean, target: HTMLElement, popup: HTMLElement, onAlign: VoidFunction): void;
|
package/lib/index.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { CSSMotionProps } from 'rc-motion';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import type { ActionType, AlignType, AnimationType, BuildInPlacements, TransitionNameType } from './interface';
|
|
4
|
-
export type { BuildInPlacements, AlignType, ActionType };
|
|
5
|
-
export interface TriggerRef {
|
|
6
|
-
forceAlign: VoidFunction;
|
|
7
|
-
}
|
|
8
|
-
export interface TriggerProps {
|
|
9
|
-
children: React.ReactElement;
|
|
10
|
-
action?: ActionType | ActionType[];
|
|
11
|
-
showAction?: ActionType[];
|
|
12
|
-
hideAction?: ActionType[];
|
|
13
|
-
prefixCls?: string;
|
|
14
|
-
zIndex?: number;
|
|
15
|
-
onPopupAlign?: (element: HTMLElement, align: AlignType) => void;
|
|
16
|
-
stretch?: string;
|
|
17
|
-
popupVisible?: boolean;
|
|
18
|
-
defaultPopupVisible?: boolean;
|
|
19
|
-
onPopupVisibleChange?: (visible: boolean) => void;
|
|
20
|
-
afterPopupVisibleChange?: (visible: boolean) => void;
|
|
21
|
-
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
22
|
-
forceRender?: boolean;
|
|
23
|
-
autoDestroy?: boolean;
|
|
24
|
-
/** @deprecated Please use `autoDestroy` instead */
|
|
25
|
-
destroyPopupOnHide?: boolean;
|
|
26
|
-
mask?: boolean;
|
|
27
|
-
maskClosable?: boolean;
|
|
28
|
-
/** Set popup motion. You can ref `rc-motion` for more info. */
|
|
29
|
-
popupMotion?: CSSMotionProps;
|
|
30
|
-
/** Set mask motion. You can ref `rc-motion` for more info. */
|
|
31
|
-
maskMotion?: CSSMotionProps;
|
|
32
|
-
/** @deprecated Please us `popupMotion` instead. */
|
|
33
|
-
popupTransitionName?: TransitionNameType;
|
|
34
|
-
/** @deprecated Please us `popupMotion` instead. */
|
|
35
|
-
popupAnimation?: AnimationType;
|
|
36
|
-
/** @deprecated Please us `maskMotion` instead. */
|
|
37
|
-
maskTransitionName?: TransitionNameType;
|
|
38
|
-
/** @deprecated Please us `maskMotion` instead. */
|
|
39
|
-
maskAnimation?: AnimationType;
|
|
40
|
-
mouseEnterDelay?: number;
|
|
41
|
-
mouseLeaveDelay?: number;
|
|
42
|
-
focusDelay?: number;
|
|
43
|
-
blurDelay?: number;
|
|
44
|
-
popup: React.ReactNode | (() => React.ReactNode);
|
|
45
|
-
popupPlacement?: string;
|
|
46
|
-
builtinPlacements?: BuildInPlacements;
|
|
47
|
-
popupAlign?: AlignType;
|
|
48
|
-
popupClassName?: string;
|
|
49
|
-
popupStyle?: React.CSSProperties;
|
|
50
|
-
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
51
|
-
onPopupClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
52
|
-
alignPoint?: boolean;
|
|
53
|
-
arrow?: boolean;
|
|
54
|
-
/** @deprecated Add `className` on `children`. Please add `className` directly instead. */
|
|
55
|
-
className?: string;
|
|
56
|
-
/**
|
|
57
|
-
* @private Get trigger DOM node.
|
|
58
|
-
* Used for some component is function component which can not access by `findDOMNode`
|
|
59
|
-
*/
|
|
60
|
-
getTriggerDOMNode?: (node: React.ReactInstance) => HTMLElement;
|
|
61
|
-
}
|
|
62
|
-
export declare function generateTrigger(PortalComponent?: React.ComponentType<any>): React.ForwardRefExoticComponent<TriggerProps & React.RefAttributes<TriggerRef>>;
|
|
63
|
-
declare const _default: React.ForwardRefExoticComponent<TriggerProps & React.RefAttributes<TriggerRef>>;
|
|
64
|
-
export default _default;
|
package/lib/interface.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { CSSMotionProps } from 'rc-motion';
|
|
3
|
-
export declare type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
4
|
-
export declare type AlignPointTopBottom = 't' | 'b' | 'c';
|
|
5
|
-
export declare type AlignPointLeftRight = 'l' | 'r' | 'c';
|
|
6
|
-
/** Two char of 't' 'b' 'c' 'l' 'r'. Example: 'lt' */
|
|
7
|
-
export declare type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
|
|
8
|
-
export interface AlignType {
|
|
9
|
-
/**
|
|
10
|
-
* move point of source node to align with point of target node.
|
|
11
|
-
* Such as ['tr','cc'], align top right point of source node with center point of target node.
|
|
12
|
-
* Point can be 't'(top), 'b'(bottom), 'c'(center), 'l'(left), 'r'(right) */
|
|
13
|
-
points?: (string | AlignPoint)[];
|
|
14
|
-
/**
|
|
15
|
-
* offset source node by offset[0] in x and offset[1] in y.
|
|
16
|
-
* If offset contains percentage string value, it is relative to sourceNode region.
|
|
17
|
-
*/
|
|
18
|
-
offset?: number[];
|
|
19
|
-
/**
|
|
20
|
-
* offset target node by offset[0] in x and offset[1] in y.
|
|
21
|
-
* If targetOffset contains percentage string value, it is relative to targetNode region.
|
|
22
|
-
*/
|
|
23
|
-
targetOffset?: number[];
|
|
24
|
-
/**
|
|
25
|
-
* If adjustX field is true, will adjust source node in x direction if source node is invisible.
|
|
26
|
-
* If adjustY field is true, will adjust source node in y direction if source node is invisible.
|
|
27
|
-
*/
|
|
28
|
-
overflow?: {
|
|
29
|
-
adjustX?: boolean | number;
|
|
30
|
-
adjustY?: boolean | number;
|
|
31
|
-
shiftX?: boolean | number;
|
|
32
|
-
shiftY?: boolean | number;
|
|
33
|
-
};
|
|
34
|
-
/** Auto adjust arrow position */
|
|
35
|
-
autoArrow?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Config visible region check of html node. Default `visible`:
|
|
38
|
-
* - `visible`: The visible region of user browser window. Use `clientHeight` for check.
|
|
39
|
-
* - `scroll`: The whole region of the html scroll area. Use `scrollHeight` for check.
|
|
40
|
-
*/
|
|
41
|
-
htmlRegion?: 'visible' | 'scroll';
|
|
42
|
-
/**
|
|
43
|
-
* Whether use css right instead of left to position
|
|
44
|
-
*/
|
|
45
|
-
useCssRight?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Whether use css bottom instead of top to position
|
|
48
|
-
*/
|
|
49
|
-
useCssBottom?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Whether use css transform instead of left/top/right/bottom to position if browser supports.
|
|
52
|
-
* Defaults to false.
|
|
53
|
-
*/
|
|
54
|
-
useCssTransform?: boolean;
|
|
55
|
-
ignoreShake?: boolean;
|
|
56
|
-
}
|
|
57
|
-
export declare type BuildInPlacements = Record<string, AlignType>;
|
|
58
|
-
export declare type StretchType = string;
|
|
59
|
-
export declare type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
|
|
60
|
-
export declare type AnimationType = string;
|
|
61
|
-
export declare type TransitionNameType = string;
|
|
62
|
-
export interface Point {
|
|
63
|
-
pageX: number;
|
|
64
|
-
pageY: number;
|
|
65
|
-
}
|
|
66
|
-
export interface CommonEventHandler {
|
|
67
|
-
remove: () => void;
|
|
68
|
-
}
|
|
69
|
-
export interface MobileConfig {
|
|
70
|
-
/** Set popup motion. You can ref `rc-motion` for more info. */
|
|
71
|
-
popupMotion?: CSSMotionProps;
|
|
72
|
-
popupClassName?: string;
|
|
73
|
-
popupStyle?: React.CSSProperties;
|
|
74
|
-
popupRender?: (originNode: React.ReactNode) => React.ReactNode;
|
|
75
|
-
}
|
package/lib/mock.d.ts
DELETED
package/lib/util.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { CSSMotionProps } from 'rc-motion';
|
|
2
|
-
import type { AlignType, AnimationType, BuildInPlacements, TransitionNameType } from './interface';
|
|
3
|
-
export declare function getAlignPopupClassName(builtinPlacements: BuildInPlacements, prefixCls: string, align: AlignType, isAlignPoint: boolean): string;
|
|
4
|
-
/** @deprecated We should not use this if we can refactor all deps */
|
|
5
|
-
export declare function getMotion(prefixCls: string, motion: CSSMotionProps, animation: AnimationType, transitionName: TransitionNameType): CSSMotionProps;
|
|
6
|
-
export declare function getWin(ele: HTMLElement): Window & typeof globalThis;
|
|
7
|
-
/**
|
|
8
|
-
* Get all the scrollable parent elements of the element
|
|
9
|
-
* @param ele The element to be detected
|
|
10
|
-
* @param areaOnly Only return the parent which will cut visible area
|
|
11
|
-
*/
|
|
12
|
-
export declare function collectScroller(ele: HTMLElement): HTMLElement[];
|
|
13
|
-
export declare function toNum(num: number): number;
|
|
14
|
-
export interface VisibleArea {
|
|
15
|
-
left: number;
|
|
16
|
-
top: number;
|
|
17
|
-
right: number;
|
|
18
|
-
bottom: number;
|
|
19
|
-
}
|
|
20
|
-
export declare function getVisibleArea(initArea: VisibleArea, scrollerList?: HTMLElement[]): {
|
|
21
|
-
left: number;
|
|
22
|
-
top: number;
|
|
23
|
-
right: number;
|
|
24
|
-
bottom: number;
|
|
25
|
-
};
|