@rc-component/trigger 3.6.9 → 3.6.11
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/UniqueProvider/UniqueBody.d.ts +2 -1
- package/es/UniqueProvider/UniqueBody.js +3 -0
- package/es/UniqueProvider/index.d.ts +4 -1
- package/es/UniqueProvider/index.js +28 -15
- package/es/index.d.ts +3 -1
- package/es/index.js +2 -1
- package/lib/UniqueProvider/UniqueBody.d.ts +2 -1
- package/lib/UniqueProvider/UniqueBody.js +3 -0
- package/lib/UniqueProvider/index.d.ts +4 -1
- package/lib/UniqueProvider/index.js +28 -15
- package/lib/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CSSMotionProps } from '@rc-component/motion';
|
|
3
|
-
import type { AlignType } from '../interface';
|
|
3
|
+
import type { AlignType, ArrowPos } from '../interface';
|
|
4
4
|
export interface UniqueBodyProps {
|
|
5
5
|
prefixCls: string;
|
|
6
6
|
isMobile: boolean;
|
|
@@ -11,6 +11,7 @@ export interface UniqueBodyProps {
|
|
|
11
11
|
offsetB: number;
|
|
12
12
|
offsetX: number;
|
|
13
13
|
offsetY: number;
|
|
14
|
+
arrowPos?: ArrowPos;
|
|
14
15
|
popupSize?: {
|
|
15
16
|
width: number;
|
|
16
17
|
height: number;
|
|
@@ -14,6 +14,7 @@ const UniqueBody = props => {
|
|
|
14
14
|
offsetB,
|
|
15
15
|
offsetX,
|
|
16
16
|
offsetY,
|
|
17
|
+
arrowPos,
|
|
17
18
|
popupSize,
|
|
18
19
|
motion,
|
|
19
20
|
uniqueBgClassName,
|
|
@@ -54,6 +55,8 @@ const UniqueBody = props => {
|
|
|
54
55
|
return /*#__PURE__*/React.createElement("div", {
|
|
55
56
|
className: cls,
|
|
56
57
|
style: {
|
|
58
|
+
'--arrow-x': `${arrowPos?.x || 0}px`,
|
|
59
|
+
'--arrow-y': `${arrowPos?.y || 0}px`,
|
|
57
60
|
...offsetStyle,
|
|
58
61
|
...sizeStyle,
|
|
59
62
|
...motionStyle,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type UniqueShowOptions } from '../context';
|
|
2
3
|
export interface UniqueProviderProps {
|
|
3
4
|
children: React.ReactNode;
|
|
5
|
+
/** Additional handle options data to do the customize info */
|
|
6
|
+
postTriggerProps?: (options: UniqueShowOptions) => UniqueShowOptions;
|
|
4
7
|
}
|
|
5
|
-
declare const UniqueProvider: ({ children }: UniqueProviderProps) => React.JSX.Element;
|
|
8
|
+
declare const UniqueProvider: ({ children, postTriggerProps }: UniqueProviderProps) => React.JSX.Element;
|
|
6
9
|
export default UniqueProvider;
|
|
@@ -11,10 +11,19 @@ import UniqueBody from "./UniqueBody";
|
|
|
11
11
|
import classNames from 'classnames';
|
|
12
12
|
import { getAlignPopupClassName } from "../util";
|
|
13
13
|
const UniqueProvider = ({
|
|
14
|
-
children
|
|
14
|
+
children,
|
|
15
|
+
postTriggerProps
|
|
15
16
|
}) => {
|
|
16
17
|
const [trigger, open, options, onTargetVisibleChanged] = useTargetState();
|
|
17
18
|
|
|
19
|
+
// ========================== Options ===========================
|
|
20
|
+
const mergedOptions = React.useMemo(() => {
|
|
21
|
+
if (!options || !postTriggerProps) {
|
|
22
|
+
return options;
|
|
23
|
+
}
|
|
24
|
+
return postTriggerProps(options);
|
|
25
|
+
}, [options, postTriggerProps]);
|
|
26
|
+
|
|
18
27
|
// =========================== Popup ============================
|
|
19
28
|
const [popupEle, setPopupEle] = React.useState(null);
|
|
20
29
|
const [popupSize, setPopupSize] = React.useState(null);
|
|
@@ -97,7 +106,7 @@ const UniqueProvider = ({
|
|
|
97
106
|
}), [parentContext]);
|
|
98
107
|
|
|
99
108
|
// =========================== Render ===========================
|
|
100
|
-
const prefixCls =
|
|
109
|
+
const prefixCls = mergedOptions?.prefixCls;
|
|
101
110
|
return /*#__PURE__*/React.createElement(UniqueContext.Provider, {
|
|
102
111
|
value: contextValue
|
|
103
112
|
}, children, options && /*#__PURE__*/React.createElement(TriggerContext.Provider, {
|
|
@@ -106,10 +115,10 @@ const UniqueProvider = ({
|
|
|
106
115
|
ref: setPopupRef,
|
|
107
116
|
portal: Portal,
|
|
108
117
|
prefixCls: prefixCls,
|
|
109
|
-
popup:
|
|
110
|
-
className: classNames(
|
|
111
|
-
style:
|
|
112
|
-
target:
|
|
118
|
+
popup: mergedOptions.popup,
|
|
119
|
+
className: classNames(mergedOptions.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
|
|
120
|
+
style: mergedOptions.popupStyle,
|
|
121
|
+
target: mergedOptions.target,
|
|
113
122
|
open: open,
|
|
114
123
|
keepDom: true,
|
|
115
124
|
fresh: true,
|
|
@@ -131,12 +140,12 @@ const UniqueProvider = ({
|
|
|
131
140
|
y: arrowY
|
|
132
141
|
},
|
|
133
142
|
align: alignInfo,
|
|
134
|
-
zIndex:
|
|
135
|
-
mask:
|
|
136
|
-
arrow:
|
|
137
|
-
motion:
|
|
138
|
-
maskMotion:
|
|
139
|
-
|
|
143
|
+
zIndex: mergedOptions.zIndex,
|
|
144
|
+
mask: mergedOptions.mask,
|
|
145
|
+
arrow: mergedOptions.arrow,
|
|
146
|
+
motion: mergedOptions.popupMotion,
|
|
147
|
+
maskMotion: mergedOptions.maskMotion,
|
|
148
|
+
getPopupContainer: mergedOptions.getPopupContainer
|
|
140
149
|
}, /*#__PURE__*/React.createElement(UniqueBody, {
|
|
141
150
|
prefixCls: prefixCls,
|
|
142
151
|
isMobile: false,
|
|
@@ -147,10 +156,14 @@ const UniqueProvider = ({
|
|
|
147
156
|
offsetB: offsetB,
|
|
148
157
|
offsetX: offsetX,
|
|
149
158
|
offsetY: offsetY,
|
|
159
|
+
arrowPos: {
|
|
160
|
+
x: arrowX,
|
|
161
|
+
y: arrowY
|
|
162
|
+
},
|
|
150
163
|
popupSize: popupSize,
|
|
151
|
-
motion:
|
|
152
|
-
uniqueBgClassName: classNames(
|
|
153
|
-
uniqueBgStyle:
|
|
164
|
+
motion: mergedOptions.popupMotion,
|
|
165
|
+
uniqueBgClassName: classNames(mergedOptions.uniqueBgClassName, alignedClassName),
|
|
166
|
+
uniqueBgStyle: mergedOptions.uniqueBgStyle
|
|
154
167
|
}))));
|
|
155
168
|
};
|
|
156
169
|
export default UniqueProvider;
|
package/es/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import * as React from 'react';
|
|
|
3
3
|
import { type MobileConfig } from './Popup';
|
|
4
4
|
import type { ActionType, AlignType, ArrowTypeOuter, BuildInPlacements } from './interface';
|
|
5
5
|
export type { ActionType, AlignType, ArrowTypeOuter as ArrowType, BuildInPlacements, };
|
|
6
|
-
|
|
6
|
+
import UniqueProvider, { type UniqueProviderProps } from './UniqueProvider';
|
|
7
|
+
export { UniqueProvider };
|
|
8
|
+
export type { UniqueProviderProps };
|
|
7
9
|
export interface TriggerRef {
|
|
8
10
|
nativeElement: HTMLElement;
|
|
9
11
|
popupElement: HTMLDivElement;
|
package/es/index.js
CHANGED
|
@@ -15,7 +15,8 @@ import useDelay from "./hooks/useDelay";
|
|
|
15
15
|
import useWatch from "./hooks/useWatch";
|
|
16
16
|
import useWinClick from "./hooks/useWinClick";
|
|
17
17
|
import { getAlignPopupClassName } from "./util";
|
|
18
|
-
|
|
18
|
+
import UniqueProvider from "./UniqueProvider";
|
|
19
|
+
export { UniqueProvider };
|
|
19
20
|
|
|
20
21
|
// Removed Props List
|
|
21
22
|
// Seems this can be auto
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CSSMotionProps } from '@rc-component/motion';
|
|
3
|
-
import type { AlignType } from '../interface';
|
|
3
|
+
import type { AlignType, ArrowPos } from '../interface';
|
|
4
4
|
export interface UniqueBodyProps {
|
|
5
5
|
prefixCls: string;
|
|
6
6
|
isMobile: boolean;
|
|
@@ -11,6 +11,7 @@ export interface UniqueBodyProps {
|
|
|
11
11
|
offsetB: number;
|
|
12
12
|
offsetX: number;
|
|
13
13
|
offsetY: number;
|
|
14
|
+
arrowPos?: ArrowPos;
|
|
14
15
|
popupSize?: {
|
|
15
16
|
width: number;
|
|
16
17
|
height: number;
|
|
@@ -21,6 +21,7 @@ const UniqueBody = props => {
|
|
|
21
21
|
offsetB,
|
|
22
22
|
offsetX,
|
|
23
23
|
offsetY,
|
|
24
|
+
arrowPos,
|
|
24
25
|
popupSize,
|
|
25
26
|
motion,
|
|
26
27
|
uniqueBgClassName,
|
|
@@ -61,6 +62,8 @@ const UniqueBody = props => {
|
|
|
61
62
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
62
63
|
className: cls,
|
|
63
64
|
style: {
|
|
65
|
+
'--arrow-x': `${arrowPos?.x || 0}px`,
|
|
66
|
+
'--arrow-y': `${arrowPos?.y || 0}px`,
|
|
64
67
|
...offsetStyle,
|
|
65
68
|
...sizeStyle,
|
|
66
69
|
...motionStyle,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type UniqueShowOptions } from '../context';
|
|
2
3
|
export interface UniqueProviderProps {
|
|
3
4
|
children: React.ReactNode;
|
|
5
|
+
/** Additional handle options data to do the customize info */
|
|
6
|
+
postTriggerProps?: (options: UniqueShowOptions) => UniqueShowOptions;
|
|
4
7
|
}
|
|
5
|
-
declare const UniqueProvider: ({ children }: UniqueProviderProps) => React.JSX.Element;
|
|
8
|
+
declare const UniqueProvider: ({ children, postTriggerProps }: UniqueProviderProps) => React.JSX.Element;
|
|
6
9
|
export default UniqueProvider;
|
|
@@ -20,10 +20,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
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); }
|
|
21
21
|
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; }
|
|
22
22
|
const UniqueProvider = ({
|
|
23
|
-
children
|
|
23
|
+
children,
|
|
24
|
+
postTriggerProps
|
|
24
25
|
}) => {
|
|
25
26
|
const [trigger, open, options, onTargetVisibleChanged] = (0, _useTargetState.default)();
|
|
26
27
|
|
|
28
|
+
// ========================== Options ===========================
|
|
29
|
+
const mergedOptions = React.useMemo(() => {
|
|
30
|
+
if (!options || !postTriggerProps) {
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
33
|
+
return postTriggerProps(options);
|
|
34
|
+
}, [options, postTriggerProps]);
|
|
35
|
+
|
|
27
36
|
// =========================== Popup ============================
|
|
28
37
|
const [popupEle, setPopupEle] = React.useState(null);
|
|
29
38
|
const [popupSize, setPopupSize] = React.useState(null);
|
|
@@ -106,7 +115,7 @@ const UniqueProvider = ({
|
|
|
106
115
|
}), [parentContext]);
|
|
107
116
|
|
|
108
117
|
// =========================== Render ===========================
|
|
109
|
-
const prefixCls =
|
|
118
|
+
const prefixCls = mergedOptions?.prefixCls;
|
|
110
119
|
return /*#__PURE__*/React.createElement(_context.UniqueContext.Provider, {
|
|
111
120
|
value: contextValue
|
|
112
121
|
}, children, options && /*#__PURE__*/React.createElement(_context.default.Provider, {
|
|
@@ -115,10 +124,10 @@ const UniqueProvider = ({
|
|
|
115
124
|
ref: setPopupRef,
|
|
116
125
|
portal: _portal.default,
|
|
117
126
|
prefixCls: prefixCls,
|
|
118
|
-
popup:
|
|
119
|
-
className: (0, _classnames.default)(
|
|
120
|
-
style:
|
|
121
|
-
target:
|
|
127
|
+
popup: mergedOptions.popup,
|
|
128
|
+
className: (0, _classnames.default)(mergedOptions.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
|
|
129
|
+
style: mergedOptions.popupStyle,
|
|
130
|
+
target: mergedOptions.target,
|
|
122
131
|
open: open,
|
|
123
132
|
keepDom: true,
|
|
124
133
|
fresh: true,
|
|
@@ -140,12 +149,12 @@ const UniqueProvider = ({
|
|
|
140
149
|
y: arrowY
|
|
141
150
|
},
|
|
142
151
|
align: alignInfo,
|
|
143
|
-
zIndex:
|
|
144
|
-
mask:
|
|
145
|
-
arrow:
|
|
146
|
-
motion:
|
|
147
|
-
maskMotion:
|
|
148
|
-
|
|
152
|
+
zIndex: mergedOptions.zIndex,
|
|
153
|
+
mask: mergedOptions.mask,
|
|
154
|
+
arrow: mergedOptions.arrow,
|
|
155
|
+
motion: mergedOptions.popupMotion,
|
|
156
|
+
maskMotion: mergedOptions.maskMotion,
|
|
157
|
+
getPopupContainer: mergedOptions.getPopupContainer
|
|
149
158
|
}, /*#__PURE__*/React.createElement(_UniqueBody.default, {
|
|
150
159
|
prefixCls: prefixCls,
|
|
151
160
|
isMobile: false,
|
|
@@ -156,10 +165,14 @@ const UniqueProvider = ({
|
|
|
156
165
|
offsetB: offsetB,
|
|
157
166
|
offsetX: offsetX,
|
|
158
167
|
offsetY: offsetY,
|
|
168
|
+
arrowPos: {
|
|
169
|
+
x: arrowX,
|
|
170
|
+
y: arrowY
|
|
171
|
+
},
|
|
159
172
|
popupSize: popupSize,
|
|
160
|
-
motion:
|
|
161
|
-
uniqueBgClassName: (0, _classnames.default)(
|
|
162
|
-
uniqueBgStyle:
|
|
173
|
+
motion: mergedOptions.popupMotion,
|
|
174
|
+
uniqueBgClassName: (0, _classnames.default)(mergedOptions.uniqueBgClassName, alignedClassName),
|
|
175
|
+
uniqueBgStyle: mergedOptions.uniqueBgStyle
|
|
163
176
|
}))));
|
|
164
177
|
};
|
|
165
178
|
var _default = exports.default = UniqueProvider;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import * as React from 'react';
|
|
|
3
3
|
import { type MobileConfig } from './Popup';
|
|
4
4
|
import type { ActionType, AlignType, ArrowTypeOuter, BuildInPlacements } from './interface';
|
|
5
5
|
export type { ActionType, AlignType, ArrowTypeOuter as ArrowType, BuildInPlacements, };
|
|
6
|
-
|
|
6
|
+
import UniqueProvider, { type UniqueProviderProps } from './UniqueProvider';
|
|
7
|
+
export { UniqueProvider };
|
|
8
|
+
export type { UniqueProviderProps };
|
|
7
9
|
export interface TriggerRef {
|
|
8
10
|
nativeElement: HTMLElement;
|
|
9
11
|
popupElement: HTMLDivElement;
|