@rc-component/trigger 1.9.0 → 1.10.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/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 +5 -3
- package/es/interface.d.ts +7 -0
- package/lib/Popup/Arrow.d.ts +2 -3
- package/lib/Popup/Arrow.js +12 -7
- package/lib/Popup/index.d.ts +2 -4
- package/lib/Popup/index.js +2 -5
- package/lib/index.d.ts +3 -3
- package/lib/index.js +5 -3
- package/lib/interface.d.ts +7 -0
- package/package.json +1 -1
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, ArrowTypeOuter, AnimationType, 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
|
@@ -436,6 +436,10 @@ export function generateTrigger() {
|
|
|
436
436
|
|
|
437
437
|
// Child Node
|
|
438
438
|
var triggerNode = /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, mergedChildrenProps), passedProps));
|
|
439
|
+
var innerArrow = arrow ? _objectSpread(_objectSpread({}, arrow !== true ? arrow : {}), {}, {
|
|
440
|
+
x: arrowX,
|
|
441
|
+
y: arrowY
|
|
442
|
+
}) : null;
|
|
439
443
|
|
|
440
444
|
// Render
|
|
441
445
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
@@ -481,14 +485,12 @@ export function generateTrigger() {
|
|
|
481
485
|
// Arrow
|
|
482
486
|
,
|
|
483
487
|
align: alignInfo,
|
|
484
|
-
arrow:
|
|
488
|
+
arrow: innerArrow
|
|
485
489
|
// Align
|
|
486
490
|
,
|
|
487
491
|
ready: ready,
|
|
488
492
|
offsetX: offsetX,
|
|
489
493
|
offsetY: offsetY,
|
|
490
|
-
arrowX: arrowX,
|
|
491
|
-
arrowY: arrowY,
|
|
492
494
|
onAlign: triggerAlign
|
|
493
495
|
// Stretch
|
|
494
496
|
,
|
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.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/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.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/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.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, ArrowTypeOuter, AnimationType, 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/lib/index.js
CHANGED
|
@@ -445,6 +445,10 @@ function generateTrigger() {
|
|
|
445
445
|
|
|
446
446
|
// Child Node
|
|
447
447
|
var triggerNode = /*#__PURE__*/React.cloneElement(child, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, mergedChildrenProps), passedProps));
|
|
448
|
+
var innerArrow = arrow ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, arrow !== true ? arrow : {}), {}, {
|
|
449
|
+
x: arrowX,
|
|
450
|
+
y: arrowY
|
|
451
|
+
}) : null;
|
|
448
452
|
|
|
449
453
|
// Render
|
|
450
454
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_rcResizeObserver.default, {
|
|
@@ -490,14 +494,12 @@ function generateTrigger() {
|
|
|
490
494
|
// Arrow
|
|
491
495
|
,
|
|
492
496
|
align: alignInfo,
|
|
493
|
-
arrow:
|
|
497
|
+
arrow: innerArrow
|
|
494
498
|
// Align
|
|
495
499
|
,
|
|
496
500
|
ready: ready,
|
|
497
501
|
offsetX: offsetX,
|
|
498
502
|
offsetY: offsetY,
|
|
499
|
-
arrowX: arrowX,
|
|
500
|
-
arrowY: arrowY,
|
|
501
503
|
onAlign: triggerAlign
|
|
502
504
|
// Stretch
|
|
503
505
|
,
|
package/lib/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';
|