@rc-component/trigger 1.8.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/PopupContent.d.ts +7 -0
- package/es/Popup/PopupContent.js +11 -0
- package/es/Popup/index.d.ts +2 -4
- package/es/Popup/index.js +6 -6
- 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/PopupContent.d.ts +7 -0
- package/lib/Popup/PopupContent.js +19 -0
- package/lib/Popup/index.d.ts +2 -4
- package/lib/Popup/index.js +6 -6
- 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
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
var PopupContent = /*#__PURE__*/React.memo(function (_ref) {
|
|
3
|
+
var children = _ref.children;
|
|
4
|
+
return children;
|
|
5
|
+
}, function (_, next) {
|
|
6
|
+
return next.cache;
|
|
7
|
+
});
|
|
8
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
9
|
+
PopupContent.displayName = 'PopupContent';
|
|
10
|
+
}
|
|
11
|
+
export default PopupContent;
|
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
|
@@ -9,6 +9,7 @@ import { composeRef } from "rc-util/es/ref";
|
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import Arrow from "./Arrow";
|
|
11
11
|
import Mask from "./Mask";
|
|
12
|
+
import PopupContent from "./PopupContent";
|
|
12
13
|
var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
13
14
|
var popup = props.popup,
|
|
14
15
|
className = props.className,
|
|
@@ -22,8 +23,6 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
22
23
|
mask = props.mask,
|
|
23
24
|
arrow = props.arrow,
|
|
24
25
|
align = props.align,
|
|
25
|
-
arrowX = props.arrowX,
|
|
26
|
-
arrowY = props.arrowY,
|
|
27
26
|
motion = props.motion,
|
|
28
27
|
maskMotion = props.maskMotion,
|
|
29
28
|
forceRender = props.forceRender,
|
|
@@ -139,10 +138,11 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
139
138
|
onClick: onClick
|
|
140
139
|
}, arrow && /*#__PURE__*/React.createElement(Arrow, {
|
|
141
140
|
prefixCls: prefixCls,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
arrow: arrow,
|
|
142
|
+
align: align
|
|
143
|
+
}), /*#__PURE__*/React.createElement(PopupContent, {
|
|
144
|
+
cache: !open
|
|
145
|
+
}, childNode));
|
|
146
146
|
});
|
|
147
147
|
}));
|
|
148
148
|
});
|
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
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var PopupContent = /*#__PURE__*/React.memo(function (_ref) {
|
|
10
|
+
var children = _ref.children;
|
|
11
|
+
return children;
|
|
12
|
+
}, function (_, next) {
|
|
13
|
+
return next.cache;
|
|
14
|
+
});
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
PopupContent.displayName = 'PopupContent';
|
|
17
|
+
}
|
|
18
|
+
var _default = PopupContent;
|
|
19
|
+
exports.default = _default;
|
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
|
@@ -17,6 +17,7 @@ var _ref2 = require("rc-util/lib/ref");
|
|
|
17
17
|
var React = _interopRequireWildcard(require("react"));
|
|
18
18
|
var _Arrow = _interopRequireDefault(require("./Arrow"));
|
|
19
19
|
var _Mask = _interopRequireDefault(require("./Mask"));
|
|
20
|
+
var _PopupContent = _interopRequireDefault(require("./PopupContent"));
|
|
20
21
|
var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
21
22
|
var popup = props.popup,
|
|
22
23
|
className = props.className,
|
|
@@ -30,8 +31,6 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
30
31
|
mask = props.mask,
|
|
31
32
|
arrow = props.arrow,
|
|
32
33
|
align = props.align,
|
|
33
|
-
arrowX = props.arrowX,
|
|
34
|
-
arrowY = props.arrowY,
|
|
35
34
|
motion = props.motion,
|
|
36
35
|
maskMotion = props.maskMotion,
|
|
37
36
|
forceRender = props.forceRender,
|
|
@@ -147,10 +146,11 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
147
146
|
onClick: onClick
|
|
148
147
|
}, arrow && /*#__PURE__*/React.createElement(_Arrow.default, {
|
|
149
148
|
prefixCls: prefixCls,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
arrow: arrow,
|
|
150
|
+
align: align
|
|
151
|
+
}), /*#__PURE__*/React.createElement(_PopupContent.default, {
|
|
152
|
+
cache: !open
|
|
153
|
+
}, childNode));
|
|
154
154
|
});
|
|
155
155
|
}));
|
|
156
156
|
});
|
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';
|