@rc-component/trigger 3.6.14 → 3.6.16
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 +4 -4
- package/assets/index.css +3 -3
- package/assets/index.less +2 -2
- package/es/Popup/Arrow.js +2 -2
- package/es/Popup/Mask.js +2 -2
- package/es/Popup/index.js +2 -2
- package/es/UniqueProvider/{UniqueBody.d.ts → UniqueContainer.d.ts} +5 -5
- package/es/UniqueProvider/{UniqueBody.js → UniqueContainer.js} +10 -10
- package/es/UniqueProvider/index.js +7 -7
- package/es/context.d.ts +2 -2
- package/es/index.d.ts +4 -4
- package/es/index.js +7 -7
- package/lib/Popup/Arrow.js +2 -3
- package/lib/Popup/Mask.js +2 -2
- package/lib/Popup/index.js +2 -2
- package/lib/UniqueProvider/{UniqueBody.d.ts → UniqueContainer.d.ts} +5 -5
- package/lib/UniqueProvider/{UniqueBody.js → UniqueContainer.js} +10 -10
- package/lib/UniqueProvider/index.js +7 -7
- package/lib/context.d.ts +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.js +7 -7
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@ React Trigger Component
|
|
|
9
9
|
[![bundle size][bundlephobia-image]][bundlephobia-url]
|
|
10
10
|
[![dumi][dumi-image]][dumi-url]
|
|
11
11
|
|
|
12
|
-
[npm-image]:
|
|
13
|
-
[npm-url]:
|
|
14
|
-
[github-actions-image]: https://github.com/react-component/trigger/workflows/
|
|
15
|
-
[github-actions-url]: https://github.com/react-component/trigger/actions
|
|
12
|
+
[npm-image]: https://img.shields.io/npm/v/@rc-component/trigger.svg?style=flat-square
|
|
13
|
+
[npm-url]: https://npmjs.org/package/@rc-component/trigger
|
|
14
|
+
[github-actions-image]: https://github.com/react-component/trigger/actions/workflows/main.yml/badge.svg
|
|
15
|
+
[github-actions-url]: https://github.com/react-component/trigger/actions/workflows/main.yml
|
|
16
16
|
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/trigger/master.svg?style=flat-square
|
|
17
17
|
[codecov-url]: https://codecov.io/gh/react-component/trigger/branch/master
|
|
18
18
|
[david-url]: https://david-dm.org/react-component/trigger
|
package/assets/index.css
CHANGED
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
opacity: 0;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
.rc-trigger-popup-unique-
|
|
65
|
+
.rc-trigger-popup-unique-container {
|
|
66
66
|
position: absolute;
|
|
67
67
|
z-index: 0;
|
|
68
68
|
box-sizing: border-box;
|
|
69
69
|
border: 1px solid red;
|
|
70
70
|
background: green;
|
|
71
71
|
}
|
|
72
|
-
.rc-trigger-popup-unique-
|
|
72
|
+
.rc-trigger-popup-unique-container-hidden {
|
|
73
73
|
display: none;
|
|
74
74
|
}
|
|
75
|
-
.rc-trigger-popup-unique-
|
|
75
|
+
.rc-trigger-popup-unique-container-visible {
|
|
76
76
|
transition: all 0.1s;
|
|
77
77
|
}
|
|
78
78
|
.rc-trigger-popup-unique-controlled {
|
package/assets/index.less
CHANGED
package/es/Popup/Arrow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
export default function Arrow(props) {
|
|
4
4
|
const {
|
|
@@ -55,7 +55,7 @@ export default function Arrow(props) {
|
|
|
55
55
|
}
|
|
56
56
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
57
|
ref: arrowRef,
|
|
58
|
-
className:
|
|
58
|
+
className: clsx(`${prefixCls}-arrow`, className),
|
|
59
59
|
style: {
|
|
60
60
|
...alignStyle,
|
|
61
61
|
...style
|
package/es/Popup/Mask.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
3
|
import CSSMotion from '@rc-component/motion';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
export default function Mask(props) {
|
|
@@ -24,6 +24,6 @@ export default function Mask(props) {
|
|
|
24
24
|
style: {
|
|
25
25
|
zIndex
|
|
26
26
|
},
|
|
27
|
-
className:
|
|
27
|
+
className: clsx(`${prefixCls}-mask`, mobile && `${prefixCls}-mobile-mask`, className)
|
|
28
28
|
}));
|
|
29
29
|
}
|
package/es/Popup/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
3
|
import CSSMotion from '@rc-component/motion';
|
|
4
4
|
import ResizeObserver from '@rc-component/resize-observer';
|
|
5
5
|
import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
|
|
@@ -151,7 +151,7 @@ const Popup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
151
151
|
className: motionClassName,
|
|
152
152
|
style: motionStyle
|
|
153
153
|
}, motionRef) => {
|
|
154
|
-
const cls =
|
|
154
|
+
const cls = clsx(prefixCls, motionClassName, className, {
|
|
155
155
|
[`${prefixCls}-mobile`]: isMobile
|
|
156
156
|
});
|
|
157
157
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CSSMotionProps } from '@rc-component/motion';
|
|
3
3
|
import type { AlignType, ArrowPos } from '../interface';
|
|
4
|
-
export interface
|
|
4
|
+
export interface UniqueContainerProps {
|
|
5
5
|
prefixCls: string;
|
|
6
6
|
isMobile: boolean;
|
|
7
7
|
ready: boolean;
|
|
@@ -17,8 +17,8 @@ export interface UniqueBodyProps {
|
|
|
17
17
|
height: number;
|
|
18
18
|
};
|
|
19
19
|
motion?: CSSMotionProps;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
uniqueContainerClassName?: string;
|
|
21
|
+
uniqueContainerStyle?: React.CSSProperties;
|
|
22
22
|
}
|
|
23
|
-
declare const
|
|
24
|
-
export default
|
|
23
|
+
declare const UniqueContainer: (props: UniqueContainerProps) => React.JSX.Element;
|
|
24
|
+
export default UniqueContainer;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import useOffsetStyle from "../hooks/useOffsetStyle";
|
|
4
|
-
import
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
5
|
import CSSMotion from '@rc-component/motion';
|
|
6
|
-
const
|
|
6
|
+
const UniqueContainer = props => {
|
|
7
7
|
const {
|
|
8
8
|
prefixCls,
|
|
9
9
|
isMobile,
|
|
@@ -17,10 +17,10 @@ const UniqueBody = props => {
|
|
|
17
17
|
arrowPos,
|
|
18
18
|
popupSize,
|
|
19
19
|
motion,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
uniqueContainerClassName,
|
|
21
|
+
uniqueContainerStyle
|
|
22
22
|
} = props;
|
|
23
|
-
const
|
|
23
|
+
const containerCls = `${prefixCls}-unique-container`;
|
|
24
24
|
const [motionVisible, setMotionVisible] = React.useState(false);
|
|
25
25
|
|
|
26
26
|
// ========================= Styles =========================
|
|
@@ -47,7 +47,7 @@ const UniqueBody = props => {
|
|
|
47
47
|
motionEnter: true,
|
|
48
48
|
motionLeave: true,
|
|
49
49
|
removeOnLeave: false,
|
|
50
|
-
leavedClassName: `${
|
|
50
|
+
leavedClassName: `${containerCls}-hidden`
|
|
51
51
|
}, motion, {
|
|
52
52
|
visible: open,
|
|
53
53
|
onVisibleChanged: nextVisible => {
|
|
@@ -57,8 +57,8 @@ const UniqueBody = props => {
|
|
|
57
57
|
className: motionClassName,
|
|
58
58
|
style: motionStyle
|
|
59
59
|
}) => {
|
|
60
|
-
const cls =
|
|
61
|
-
[`${
|
|
60
|
+
const cls = clsx(containerCls, motionClassName, uniqueContainerClassName, {
|
|
61
|
+
[`${containerCls}-visible`]: motionVisible
|
|
62
62
|
});
|
|
63
63
|
return /*#__PURE__*/React.createElement("div", {
|
|
64
64
|
className: cls,
|
|
@@ -68,9 +68,9 @@ const UniqueBody = props => {
|
|
|
68
68
|
...cachedOffsetStyleRef.current,
|
|
69
69
|
...sizeStyle,
|
|
70
70
|
...motionStyle,
|
|
71
|
-
...
|
|
71
|
+
...uniqueContainerStyle
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
|
-
export default
|
|
76
|
+
export default UniqueContainer;
|
|
@@ -7,8 +7,8 @@ import Popup from "../Popup";
|
|
|
7
7
|
import { useEvent } from '@rc-component/util';
|
|
8
8
|
import useTargetState from "./useTargetState";
|
|
9
9
|
import { isDOM } from "@rc-component/util/es/Dom/findDOMNode";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import UniqueContainer from "./UniqueContainer";
|
|
11
|
+
import { clsx } from 'clsx';
|
|
12
12
|
import { getAlignPopupClassName } from "../util";
|
|
13
13
|
const UniqueProvider = ({
|
|
14
14
|
children,
|
|
@@ -82,7 +82,7 @@ const UniqueProvider = ({
|
|
|
82
82
|
}
|
|
83
83
|
const baseClassName = getAlignPopupClassName(mergedOptions.builtinPlacements || {}, mergedOptions.prefixCls || '', alignInfo, false // alignPoint is false for UniqueProvider
|
|
84
84
|
);
|
|
85
|
-
return
|
|
85
|
+
return clsx(baseClassName, mergedOptions.getPopupClassNameFromAlign?.(alignInfo));
|
|
86
86
|
}, [alignInfo, mergedOptions?.getPopupClassNameFromAlign, mergedOptions?.builtinPlacements, mergedOptions?.prefixCls]);
|
|
87
87
|
const contextValue = React.useMemo(() => ({
|
|
88
88
|
show,
|
|
@@ -121,7 +121,7 @@ const UniqueProvider = ({
|
|
|
121
121
|
portal: Portal,
|
|
122
122
|
prefixCls: prefixCls,
|
|
123
123
|
popup: mergedOptions.popup,
|
|
124
|
-
className:
|
|
124
|
+
className: clsx(mergedOptions.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
|
|
125
125
|
style: mergedOptions.popupStyle,
|
|
126
126
|
target: mergedOptions.target,
|
|
127
127
|
open: open,
|
|
@@ -151,7 +151,7 @@ const UniqueProvider = ({
|
|
|
151
151
|
motion: mergedOptions.popupMotion,
|
|
152
152
|
maskMotion: mergedOptions.maskMotion,
|
|
153
153
|
getPopupContainer: mergedOptions.getPopupContainer
|
|
154
|
-
}, /*#__PURE__*/React.createElement(
|
|
154
|
+
}, /*#__PURE__*/React.createElement(UniqueContainer, {
|
|
155
155
|
prefixCls: prefixCls,
|
|
156
156
|
isMobile: false,
|
|
157
157
|
ready: ready,
|
|
@@ -167,8 +167,8 @@ const UniqueProvider = ({
|
|
|
167
167
|
},
|
|
168
168
|
popupSize: popupSize,
|
|
169
169
|
motion: mergedOptions.popupMotion,
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
uniqueContainerClassName: clsx(mergedOptions.uniqueContainerClassName, alignedClassName),
|
|
171
|
+
uniqueContainerStyle: mergedOptions.uniqueContainerStyle
|
|
172
172
|
}))));
|
|
173
173
|
};
|
|
174
174
|
export default UniqueProvider;
|
package/es/context.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export interface UniqueShowOptions {
|
|
|
14
14
|
delay: number;
|
|
15
15
|
prefixCls?: string;
|
|
16
16
|
popupClassName?: string;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
uniqueContainerClassName?: string;
|
|
18
|
+
uniqueContainerStyle?: React.CSSProperties;
|
|
19
19
|
popupStyle?: React.CSSProperties;
|
|
20
20
|
popupPlacement?: string;
|
|
21
21
|
builtinPlacements?: BuildInPlacements;
|
package/es/index.d.ts
CHANGED
|
@@ -46,10 +46,10 @@ export interface TriggerProps {
|
|
|
46
46
|
builtinPlacements?: BuildInPlacements;
|
|
47
47
|
popupAlign?: AlignType;
|
|
48
48
|
popupClassName?: string;
|
|
49
|
-
/** Pass to `UniqueProvider`
|
|
50
|
-
|
|
51
|
-
/** Pass to `UniqueProvider`
|
|
52
|
-
|
|
49
|
+
/** Pass to `UniqueProvider` UniqueContainer */
|
|
50
|
+
uniqueContainerClassName?: string;
|
|
51
|
+
/** Pass to `UniqueProvider` UniqueContainer */
|
|
52
|
+
uniqueContainerStyle?: React.CSSProperties;
|
|
53
53
|
popupStyle?: React.CSSProperties;
|
|
54
54
|
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
55
55
|
onPopupClick?: React.MouseEventHandler<HTMLDivElement>;
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Portal from '@rc-component/portal';
|
|
2
|
-
import
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
3
|
import ResizeObserver from '@rc-component/resize-observer';
|
|
4
4
|
import { isDOM } from "@rc-component/util/es/Dom/findDOMNode";
|
|
5
5
|
import { getShadowRoot } from "@rc-component/util/es/Dom/shadow";
|
|
@@ -55,8 +55,8 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
55
55
|
// Popup
|
|
56
56
|
popup,
|
|
57
57
|
popupClassName,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
uniqueContainerClassName,
|
|
59
|
+
uniqueContainerStyle,
|
|
60
60
|
popupStyle,
|
|
61
61
|
popupPlacement,
|
|
62
62
|
builtinPlacements = {},
|
|
@@ -167,8 +167,8 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
167
167
|
delay,
|
|
168
168
|
prefixCls,
|
|
169
169
|
popupClassName,
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
uniqueContainerClassName,
|
|
171
|
+
uniqueContainerStyle,
|
|
172
172
|
popupStyle,
|
|
173
173
|
popupPlacement,
|
|
174
174
|
builtinPlacements,
|
|
@@ -281,7 +281,7 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
281
281
|
}, [JSON.stringify(popupAlign)]);
|
|
282
282
|
const alignedClassName = React.useMemo(() => {
|
|
283
283
|
const baseClassName = getAlignPopupClassName(builtinPlacements, prefixCls, alignInfo, alignPoint);
|
|
284
|
-
return
|
|
284
|
+
return clsx(baseClassName, getPopupClassNameFromAlign?.(alignInfo));
|
|
285
285
|
}, [alignInfo, getPopupClassNameFromAlign, builtinPlacements, prefixCls, alignPoint]);
|
|
286
286
|
|
|
287
287
|
// ============================ Refs ============================
|
|
@@ -493,7 +493,7 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
493
493
|
ref: setPopupRef,
|
|
494
494
|
prefixCls: prefixCls,
|
|
495
495
|
popup: popup,
|
|
496
|
-
className:
|
|
496
|
+
className: clsx(popupClassName, !isMobile && alignedClassName),
|
|
497
497
|
style: popupStyle,
|
|
498
498
|
target: targetEle,
|
|
499
499
|
onMouseEnter: onPopupMouseEnter,
|
package/lib/Popup/Arrow.js
CHANGED
|
@@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = Arrow;
|
|
7
|
-
var
|
|
7
|
+
var _clsx = require("clsx");
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
11
|
function Arrow(props) {
|
|
13
12
|
const {
|
|
14
13
|
prefixCls,
|
|
@@ -64,7 +63,7 @@ function Arrow(props) {
|
|
|
64
63
|
}
|
|
65
64
|
return /*#__PURE__*/React.createElement("div", {
|
|
66
65
|
ref: arrowRef,
|
|
67
|
-
className: (0,
|
|
66
|
+
className: (0, _clsx.clsx)(`${prefixCls}-arrow`, className),
|
|
68
67
|
style: {
|
|
69
68
|
...alignStyle,
|
|
70
69
|
...style
|
package/lib/Popup/Mask.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = Mask;
|
|
7
|
-
var
|
|
7
|
+
var _clsx = require("clsx");
|
|
8
8
|
var _motion = _interopRequireDefault(require("@rc-component/motion"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -33,6 +33,6 @@ function Mask(props) {
|
|
|
33
33
|
style: {
|
|
34
34
|
zIndex
|
|
35
35
|
},
|
|
36
|
-
className: (0,
|
|
36
|
+
className: (0, _clsx.clsx)(`${prefixCls}-mask`, mobile && `${prefixCls}-mobile-mask`, className)
|
|
37
37
|
}));
|
|
38
38
|
}
|
package/lib/Popup/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _clsx = require("clsx");
|
|
8
8
|
var _motion = _interopRequireDefault(require("@rc-component/motion"));
|
|
9
9
|
var _resizeObserver = _interopRequireDefault(require("@rc-component/resize-observer"));
|
|
10
10
|
var _useLayoutEffect = _interopRequireDefault(require("@rc-component/util/lib/hooks/useLayoutEffect"));
|
|
@@ -160,7 +160,7 @@ const Popup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
160
160
|
className: motionClassName,
|
|
161
161
|
style: motionStyle
|
|
162
162
|
}, motionRef) => {
|
|
163
|
-
const cls = (0,
|
|
163
|
+
const cls = (0, _clsx.clsx)(prefixCls, motionClassName, className, {
|
|
164
164
|
[`${prefixCls}-mobile`]: isMobile
|
|
165
165
|
});
|
|
166
166
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CSSMotionProps } from '@rc-component/motion';
|
|
3
3
|
import type { AlignType, ArrowPos } from '../interface';
|
|
4
|
-
export interface
|
|
4
|
+
export interface UniqueContainerProps {
|
|
5
5
|
prefixCls: string;
|
|
6
6
|
isMobile: boolean;
|
|
7
7
|
ready: boolean;
|
|
@@ -17,8 +17,8 @@ export interface UniqueBodyProps {
|
|
|
17
17
|
height: number;
|
|
18
18
|
};
|
|
19
19
|
motion?: CSSMotionProps;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
uniqueContainerClassName?: string;
|
|
21
|
+
uniqueContainerStyle?: React.CSSProperties;
|
|
22
22
|
}
|
|
23
|
-
declare const
|
|
24
|
-
export default
|
|
23
|
+
declare const UniqueContainer: (props: UniqueContainerProps) => React.JSX.Element;
|
|
24
|
+
export default UniqueContainer;
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _useOffsetStyle = _interopRequireDefault(require("../hooks/useOffsetStyle"));
|
|
9
|
-
var
|
|
9
|
+
var _clsx = require("clsx");
|
|
10
10
|
var _motion = _interopRequireDefault(require("@rc-component/motion"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
-
const
|
|
13
|
+
const UniqueContainer = props => {
|
|
14
14
|
const {
|
|
15
15
|
prefixCls,
|
|
16
16
|
isMobile,
|
|
@@ -24,10 +24,10 @@ const UniqueBody = props => {
|
|
|
24
24
|
arrowPos,
|
|
25
25
|
popupSize,
|
|
26
26
|
motion,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
uniqueContainerClassName,
|
|
28
|
+
uniqueContainerStyle
|
|
29
29
|
} = props;
|
|
30
|
-
const
|
|
30
|
+
const containerCls = `${prefixCls}-unique-container`;
|
|
31
31
|
const [motionVisible, setMotionVisible] = _react.default.useState(false);
|
|
32
32
|
|
|
33
33
|
// ========================= Styles =========================
|
|
@@ -54,7 +54,7 @@ const UniqueBody = props => {
|
|
|
54
54
|
motionEnter: true,
|
|
55
55
|
motionLeave: true,
|
|
56
56
|
removeOnLeave: false,
|
|
57
|
-
leavedClassName: `${
|
|
57
|
+
leavedClassName: `${containerCls}-hidden`
|
|
58
58
|
}, motion, {
|
|
59
59
|
visible: open,
|
|
60
60
|
onVisibleChanged: nextVisible => {
|
|
@@ -64,8 +64,8 @@ const UniqueBody = props => {
|
|
|
64
64
|
className: motionClassName,
|
|
65
65
|
style: motionStyle
|
|
66
66
|
}) => {
|
|
67
|
-
const cls = (0,
|
|
68
|
-
[`${
|
|
67
|
+
const cls = (0, _clsx.clsx)(containerCls, motionClassName, uniqueContainerClassName, {
|
|
68
|
+
[`${containerCls}-visible`]: motionVisible
|
|
69
69
|
});
|
|
70
70
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
71
71
|
className: cls,
|
|
@@ -75,9 +75,9 @@ const UniqueBody = props => {
|
|
|
75
75
|
...cachedOffsetStyleRef.current,
|
|
76
76
|
...sizeStyle,
|
|
77
77
|
...motionStyle,
|
|
78
|
-
...
|
|
78
|
+
...uniqueContainerStyle
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
|
-
var _default = exports.default =
|
|
83
|
+
var _default = exports.default = UniqueContainer;
|
|
@@ -13,8 +13,8 @@ var _Popup = _interopRequireDefault(require("../Popup"));
|
|
|
13
13
|
var _util = require("@rc-component/util");
|
|
14
14
|
var _useTargetState = _interopRequireDefault(require("./useTargetState"));
|
|
15
15
|
var _findDOMNode = require("@rc-component/util/lib/Dom/findDOMNode");
|
|
16
|
-
var
|
|
17
|
-
var
|
|
16
|
+
var _UniqueContainer = _interopRequireDefault(require("./UniqueContainer"));
|
|
17
|
+
var _clsx = require("clsx");
|
|
18
18
|
var _util2 = require("../util");
|
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -91,7 +91,7 @@ const UniqueProvider = ({
|
|
|
91
91
|
}
|
|
92
92
|
const baseClassName = (0, _util2.getAlignPopupClassName)(mergedOptions.builtinPlacements || {}, mergedOptions.prefixCls || '', alignInfo, false // alignPoint is false for UniqueProvider
|
|
93
93
|
);
|
|
94
|
-
return (0,
|
|
94
|
+
return (0, _clsx.clsx)(baseClassName, mergedOptions.getPopupClassNameFromAlign?.(alignInfo));
|
|
95
95
|
}, [alignInfo, mergedOptions?.getPopupClassNameFromAlign, mergedOptions?.builtinPlacements, mergedOptions?.prefixCls]);
|
|
96
96
|
const contextValue = React.useMemo(() => ({
|
|
97
97
|
show,
|
|
@@ -130,7 +130,7 @@ const UniqueProvider = ({
|
|
|
130
130
|
portal: _portal.default,
|
|
131
131
|
prefixCls: prefixCls,
|
|
132
132
|
popup: mergedOptions.popup,
|
|
133
|
-
className: (0,
|
|
133
|
+
className: (0, _clsx.clsx)(mergedOptions.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
|
|
134
134
|
style: mergedOptions.popupStyle,
|
|
135
135
|
target: mergedOptions.target,
|
|
136
136
|
open: open,
|
|
@@ -160,7 +160,7 @@ const UniqueProvider = ({
|
|
|
160
160
|
motion: mergedOptions.popupMotion,
|
|
161
161
|
maskMotion: mergedOptions.maskMotion,
|
|
162
162
|
getPopupContainer: mergedOptions.getPopupContainer
|
|
163
|
-
}, /*#__PURE__*/React.createElement(
|
|
163
|
+
}, /*#__PURE__*/React.createElement(_UniqueContainer.default, {
|
|
164
164
|
prefixCls: prefixCls,
|
|
165
165
|
isMobile: false,
|
|
166
166
|
ready: ready,
|
|
@@ -176,8 +176,8 @@ const UniqueProvider = ({
|
|
|
176
176
|
},
|
|
177
177
|
popupSize: popupSize,
|
|
178
178
|
motion: mergedOptions.popupMotion,
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
uniqueContainerClassName: (0, _clsx.clsx)(mergedOptions.uniqueContainerClassName, alignedClassName),
|
|
180
|
+
uniqueContainerStyle: mergedOptions.uniqueContainerStyle
|
|
181
181
|
}))));
|
|
182
182
|
};
|
|
183
183
|
var _default = exports.default = UniqueProvider;
|
package/lib/context.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export interface UniqueShowOptions {
|
|
|
14
14
|
delay: number;
|
|
15
15
|
prefixCls?: string;
|
|
16
16
|
popupClassName?: string;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
uniqueContainerClassName?: string;
|
|
18
|
+
uniqueContainerStyle?: React.CSSProperties;
|
|
19
19
|
popupStyle?: React.CSSProperties;
|
|
20
20
|
popupPlacement?: string;
|
|
21
21
|
builtinPlacements?: BuildInPlacements;
|
package/lib/index.d.ts
CHANGED
|
@@ -46,10 +46,10 @@ export interface TriggerProps {
|
|
|
46
46
|
builtinPlacements?: BuildInPlacements;
|
|
47
47
|
popupAlign?: AlignType;
|
|
48
48
|
popupClassName?: string;
|
|
49
|
-
/** Pass to `UniqueProvider`
|
|
50
|
-
|
|
51
|
-
/** Pass to `UniqueProvider`
|
|
52
|
-
|
|
49
|
+
/** Pass to `UniqueProvider` UniqueContainer */
|
|
50
|
+
uniqueContainerClassName?: string;
|
|
51
|
+
/** Pass to `UniqueProvider` UniqueContainer */
|
|
52
|
+
uniqueContainerStyle?: React.CSSProperties;
|
|
53
53
|
popupStyle?: React.CSSProperties;
|
|
54
54
|
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
55
55
|
onPopupClick?: React.MouseEventHandler<HTMLDivElement>;
|
package/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "UniqueProvider", {
|
|
|
12
12
|
exports.default = void 0;
|
|
13
13
|
exports.generateTrigger = generateTrigger;
|
|
14
14
|
var _portal = _interopRequireDefault(require("@rc-component/portal"));
|
|
15
|
-
var
|
|
15
|
+
var _clsx = require("clsx");
|
|
16
16
|
var _resizeObserver = _interopRequireDefault(require("@rc-component/resize-observer"));
|
|
17
17
|
var _findDOMNode = require("@rc-component/util/lib/Dom/findDOMNode");
|
|
18
18
|
var _shadow = require("@rc-component/util/lib/Dom/shadow");
|
|
@@ -69,8 +69,8 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
69
69
|
// Popup
|
|
70
70
|
popup,
|
|
71
71
|
popupClassName,
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
uniqueContainerClassName,
|
|
73
|
+
uniqueContainerStyle,
|
|
74
74
|
popupStyle,
|
|
75
75
|
popupPlacement,
|
|
76
76
|
builtinPlacements = {},
|
|
@@ -181,8 +181,8 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
181
181
|
delay,
|
|
182
182
|
prefixCls,
|
|
183
183
|
popupClassName,
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
uniqueContainerClassName,
|
|
185
|
+
uniqueContainerStyle,
|
|
186
186
|
popupStyle,
|
|
187
187
|
popupPlacement,
|
|
188
188
|
builtinPlacements,
|
|
@@ -295,7 +295,7 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
295
295
|
}, [JSON.stringify(popupAlign)]);
|
|
296
296
|
const alignedClassName = React.useMemo(() => {
|
|
297
297
|
const baseClassName = (0, _util.getAlignPopupClassName)(builtinPlacements, prefixCls, alignInfo, alignPoint);
|
|
298
|
-
return (0,
|
|
298
|
+
return (0, _clsx.clsx)(baseClassName, getPopupClassNameFromAlign?.(alignInfo));
|
|
299
299
|
}, [alignInfo, getPopupClassNameFromAlign, builtinPlacements, prefixCls, alignPoint]);
|
|
300
300
|
|
|
301
301
|
// ============================ Refs ============================
|
|
@@ -507,7 +507,7 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
507
507
|
ref: setPopupRef,
|
|
508
508
|
prefixCls: prefixCls,
|
|
509
509
|
popup: popup,
|
|
510
|
-
className: (0,
|
|
510
|
+
className: (0, _clsx.clsx)(popupClassName, !isMobile && alignedClassName),
|
|
511
511
|
style: popupStyle,
|
|
512
512
|
target: targetEle,
|
|
513
513
|
onMouseEnter: onPopupMouseEnter,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/trigger",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.16",
|
|
4
4
|
"description": "base abstract trigger component for react",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.x"
|
|
@@ -45,14 +45,13 @@
|
|
|
45
45
|
"@rc-component/portal": "^2.0.0",
|
|
46
46
|
"@rc-component/resize-observer": "^1.0.0",
|
|
47
47
|
"@rc-component/util": "^1.2.1",
|
|
48
|
-
"
|
|
48
|
+
"clsx": "^2.1.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@rc-component/father-plugin": "^2.0.0",
|
|
52
52
|
"@rc-component/np": "^1.0.3",
|
|
53
53
|
"@testing-library/jest-dom": "^6.1.4",
|
|
54
54
|
"@testing-library/react": "^16.0.0",
|
|
55
|
-
"@types/classnames": "^2.2.10",
|
|
56
55
|
"@types/jest": "^29.5.2",
|
|
57
56
|
"@types/node": "^24.0.3",
|
|
58
57
|
"@types/react": "^19.1.2",
|