@rc-component/trigger 3.6.16 → 3.7.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/index.d.ts +3 -1
- package/es/index.js +9 -4
- package/lib/index.d.ts +3 -1
- package/lib/index.js +9 -4
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export interface TriggerRef {
|
|
|
12
12
|
forceAlign: VoidFunction;
|
|
13
13
|
}
|
|
14
14
|
export interface TriggerProps {
|
|
15
|
-
children: React.ReactElement<any
|
|
15
|
+
children: React.ReactElement<any> | ((info: {
|
|
16
|
+
open: boolean;
|
|
17
|
+
}) => React.ReactElement<any>);
|
|
16
18
|
action?: ActionType | ActionType[];
|
|
17
19
|
showAction?: ActionType[];
|
|
18
20
|
hideAction?: ActionType[];
|
package/es/index.js
CHANGED
|
@@ -125,10 +125,6 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
125
125
|
externalForwardRef.current = node;
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
|
|
129
|
-
// ========================== Children ==========================
|
|
130
|
-
const child = React.Children.only(children);
|
|
131
|
-
const originChildProps = child?.props || {};
|
|
132
128
|
const cloneProps = {};
|
|
133
129
|
const inPopupOrChild = useEvent(ele => {
|
|
134
130
|
const childDOM = targetEle;
|
|
@@ -147,6 +143,15 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
147
143
|
// Render still use props as first priority
|
|
148
144
|
const mergedOpen = popupVisible ?? internalOpen;
|
|
149
145
|
|
|
146
|
+
// ========================== Children ==========================
|
|
147
|
+
const child = React.useMemo(() => {
|
|
148
|
+
const nextChild = typeof children === 'function' ? children({
|
|
149
|
+
open: mergedOpen
|
|
150
|
+
}) : children;
|
|
151
|
+
return React.Children.only(nextChild);
|
|
152
|
+
}, [children, mergedOpen]);
|
|
153
|
+
const originChildProps = child?.props || {};
|
|
154
|
+
|
|
150
155
|
// We use effect sync here in case `popupVisible` back to `undefined`
|
|
151
156
|
const setMergedOpen = useEvent(nextOpen => {
|
|
152
157
|
if (openUncontrolled) {
|
package/lib/index.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export interface TriggerRef {
|
|
|
12
12
|
forceAlign: VoidFunction;
|
|
13
13
|
}
|
|
14
14
|
export interface TriggerProps {
|
|
15
|
-
children: React.ReactElement<any
|
|
15
|
+
children: React.ReactElement<any> | ((info: {
|
|
16
|
+
open: boolean;
|
|
17
|
+
}) => React.ReactElement<any>);
|
|
16
18
|
action?: ActionType | ActionType[];
|
|
17
19
|
showAction?: ActionType[];
|
|
18
20
|
hideAction?: ActionType[];
|
package/lib/index.js
CHANGED
|
@@ -139,10 +139,6 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
139
139
|
externalForwardRef.current = node;
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
|
-
|
|
143
|
-
// ========================== Children ==========================
|
|
144
|
-
const child = React.Children.only(children);
|
|
145
|
-
const originChildProps = child?.props || {};
|
|
146
142
|
const cloneProps = {};
|
|
147
143
|
const inPopupOrChild = (0, _useEvent.default)(ele => {
|
|
148
144
|
const childDOM = targetEle;
|
|
@@ -161,6 +157,15 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
161
157
|
// Render still use props as first priority
|
|
162
158
|
const mergedOpen = popupVisible ?? internalOpen;
|
|
163
159
|
|
|
160
|
+
// ========================== Children ==========================
|
|
161
|
+
const child = React.useMemo(() => {
|
|
162
|
+
const nextChild = typeof children === 'function' ? children({
|
|
163
|
+
open: mergedOpen
|
|
164
|
+
}) : children;
|
|
165
|
+
return React.Children.only(nextChild);
|
|
166
|
+
}, [children, mergedOpen]);
|
|
167
|
+
const originChildProps = child?.props || {};
|
|
168
|
+
|
|
164
169
|
// We use effect sync here in case `popupVisible` back to `undefined`
|
|
165
170
|
const setMergedOpen = (0, _useEvent.default)(nextOpen => {
|
|
166
171
|
if (openUncontrolled) {
|