@rc-component/trigger 3.6.10 → 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/index.d.ts +4 -1
- package/es/UniqueProvider/index.js +24 -15
- package/es/index.d.ts +3 -1
- package/es/index.js +2 -1
- package/lib/UniqueProvider/index.d.ts +4 -1
- package/lib/UniqueProvider/index.js +24 -15
- package/lib/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -152,9 +161,9 @@ const UniqueProvider = ({
|
|
|
152
161
|
y: arrowY
|
|
153
162
|
},
|
|
154
163
|
popupSize: popupSize,
|
|
155
|
-
motion:
|
|
156
|
-
uniqueBgClassName: classNames(
|
|
157
|
-
uniqueBgStyle:
|
|
164
|
+
motion: mergedOptions.popupMotion,
|
|
165
|
+
uniqueBgClassName: classNames(mergedOptions.uniqueBgClassName, alignedClassName),
|
|
166
|
+
uniqueBgStyle: mergedOptions.uniqueBgStyle
|
|
158
167
|
}))));
|
|
159
168
|
};
|
|
160
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,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,
|
|
@@ -161,9 +170,9 @@ const UniqueProvider = ({
|
|
|
161
170
|
y: arrowY
|
|
162
171
|
},
|
|
163
172
|
popupSize: popupSize,
|
|
164
|
-
motion:
|
|
165
|
-
uniqueBgClassName: (0, _classnames.default)(
|
|
166
|
-
uniqueBgStyle:
|
|
173
|
+
motion: mergedOptions.popupMotion,
|
|
174
|
+
uniqueBgClassName: (0, _classnames.default)(mergedOptions.uniqueBgClassName, alignedClassName),
|
|
175
|
+
uniqueBgStyle: mergedOptions.uniqueBgStyle
|
|
167
176
|
}))));
|
|
168
177
|
};
|
|
169
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;
|