@rc-component/trigger 3.6.11 → 3.6.12
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.
|
@@ -26,6 +26,14 @@ const UniqueBody = props => {
|
|
|
26
26
|
// ========================= Styles =========================
|
|
27
27
|
const offsetStyle = useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY);
|
|
28
28
|
|
|
29
|
+
// Cache for offsetStyle when ready is true
|
|
30
|
+
const cachedOffsetStyleRef = React.useRef(offsetStyle);
|
|
31
|
+
|
|
32
|
+
// Update cached offset style when ready is true
|
|
33
|
+
if (ready) {
|
|
34
|
+
cachedOffsetStyleRef.current = offsetStyle;
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
// Apply popup size if available
|
|
30
38
|
const sizeStyle = {};
|
|
31
39
|
if (popupSize) {
|
|
@@ -57,7 +65,7 @@ const UniqueBody = props => {
|
|
|
57
65
|
style: {
|
|
58
66
|
'--arrow-x': `${arrowPos?.x || 0}px`,
|
|
59
67
|
'--arrow-y': `${arrowPos?.y || 0}px`,
|
|
60
|
-
...
|
|
68
|
+
...cachedOffsetStyleRef.current,
|
|
61
69
|
...sizeStyle,
|
|
62
70
|
...motionStyle,
|
|
63
71
|
...uniqueBgStyle
|
|
@@ -72,18 +72,18 @@ const UniqueProvider = ({
|
|
|
72
72
|
// scaleX - not used in UniqueProvider
|
|
73
73
|
,,
|
|
74
74
|
// scaleY - not used in UniqueProvider
|
|
75
|
-
alignInfo, onAlign] = useAlign(open, popupEle,
|
|
75
|
+
alignInfo, onAlign] = useAlign(open, popupEle, mergedOptions?.target, mergedOptions?.popupPlacement, mergedOptions?.builtinPlacements || {}, mergedOptions?.popupAlign, undefined,
|
|
76
76
|
// onPopupAlign
|
|
77
77
|
false // isMobile
|
|
78
78
|
);
|
|
79
79
|
const alignedClassName = React.useMemo(() => {
|
|
80
|
-
if (!
|
|
80
|
+
if (!mergedOptions) {
|
|
81
81
|
return '';
|
|
82
82
|
}
|
|
83
|
-
const baseClassName = getAlignPopupClassName(
|
|
83
|
+
const baseClassName = getAlignPopupClassName(mergedOptions.builtinPlacements || {}, mergedOptions.prefixCls || '', alignInfo, false // alignPoint is false for UniqueProvider
|
|
84
84
|
);
|
|
85
|
-
return classNames(baseClassName,
|
|
86
|
-
}, [alignInfo,
|
|
85
|
+
return classNames(baseClassName, mergedOptions.getPopupClassNameFromAlign?.(alignInfo));
|
|
86
|
+
}, [alignInfo, mergedOptions?.getPopupClassNameFromAlign, mergedOptions?.builtinPlacements, mergedOptions?.prefixCls]);
|
|
87
87
|
const contextValue = React.useMemo(() => ({
|
|
88
88
|
show,
|
|
89
89
|
hide
|
|
@@ -109,7 +109,7 @@ const UniqueProvider = ({
|
|
|
109
109
|
const prefixCls = mergedOptions?.prefixCls;
|
|
110
110
|
return /*#__PURE__*/React.createElement(UniqueContext.Provider, {
|
|
111
111
|
value: contextValue
|
|
112
|
-
}, children,
|
|
112
|
+
}, children, mergedOptions && /*#__PURE__*/React.createElement(TriggerContext.Provider, {
|
|
113
113
|
value: triggerContextValue
|
|
114
114
|
}, /*#__PURE__*/React.createElement(Popup, {
|
|
115
115
|
ref: setPopupRef,
|
|
@@ -33,6 +33,14 @@ const UniqueBody = props => {
|
|
|
33
33
|
// ========================= Styles =========================
|
|
34
34
|
const offsetStyle = (0, _useOffsetStyle.default)(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY);
|
|
35
35
|
|
|
36
|
+
// Cache for offsetStyle when ready is true
|
|
37
|
+
const cachedOffsetStyleRef = _react.default.useRef(offsetStyle);
|
|
38
|
+
|
|
39
|
+
// Update cached offset style when ready is true
|
|
40
|
+
if (ready) {
|
|
41
|
+
cachedOffsetStyleRef.current = offsetStyle;
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
// Apply popup size if available
|
|
37
45
|
const sizeStyle = {};
|
|
38
46
|
if (popupSize) {
|
|
@@ -64,7 +72,7 @@ const UniqueBody = props => {
|
|
|
64
72
|
style: {
|
|
65
73
|
'--arrow-x': `${arrowPos?.x || 0}px`,
|
|
66
74
|
'--arrow-y': `${arrowPos?.y || 0}px`,
|
|
67
|
-
...
|
|
75
|
+
...cachedOffsetStyleRef.current,
|
|
68
76
|
...sizeStyle,
|
|
69
77
|
...motionStyle,
|
|
70
78
|
...uniqueBgStyle
|
|
@@ -81,18 +81,18 @@ const UniqueProvider = ({
|
|
|
81
81
|
// scaleX - not used in UniqueProvider
|
|
82
82
|
,,
|
|
83
83
|
// scaleY - not used in UniqueProvider
|
|
84
|
-
alignInfo, onAlign] = (0, _useAlign.default)(open, popupEle,
|
|
84
|
+
alignInfo, onAlign] = (0, _useAlign.default)(open, popupEle, mergedOptions?.target, mergedOptions?.popupPlacement, mergedOptions?.builtinPlacements || {}, mergedOptions?.popupAlign, undefined,
|
|
85
85
|
// onPopupAlign
|
|
86
86
|
false // isMobile
|
|
87
87
|
);
|
|
88
88
|
const alignedClassName = React.useMemo(() => {
|
|
89
|
-
if (!
|
|
89
|
+
if (!mergedOptions) {
|
|
90
90
|
return '';
|
|
91
91
|
}
|
|
92
|
-
const baseClassName = (0, _util2.getAlignPopupClassName)(
|
|
92
|
+
const baseClassName = (0, _util2.getAlignPopupClassName)(mergedOptions.builtinPlacements || {}, mergedOptions.prefixCls || '', alignInfo, false // alignPoint is false for UniqueProvider
|
|
93
93
|
);
|
|
94
|
-
return (0, _classnames.default)(baseClassName,
|
|
95
|
-
}, [alignInfo,
|
|
94
|
+
return (0, _classnames.default)(baseClassName, mergedOptions.getPopupClassNameFromAlign?.(alignInfo));
|
|
95
|
+
}, [alignInfo, mergedOptions?.getPopupClassNameFromAlign, mergedOptions?.builtinPlacements, mergedOptions?.prefixCls]);
|
|
96
96
|
const contextValue = React.useMemo(() => ({
|
|
97
97
|
show,
|
|
98
98
|
hide
|
|
@@ -118,7 +118,7 @@ const UniqueProvider = ({
|
|
|
118
118
|
const prefixCls = mergedOptions?.prefixCls;
|
|
119
119
|
return /*#__PURE__*/React.createElement(_context.UniqueContext.Provider, {
|
|
120
120
|
value: contextValue
|
|
121
|
-
}, children,
|
|
121
|
+
}, children, mergedOptions && /*#__PURE__*/React.createElement(_context.default.Provider, {
|
|
122
122
|
value: triggerContextValue
|
|
123
123
|
}, /*#__PURE__*/React.createElement(_Popup.default, {
|
|
124
124
|
ref: setPopupRef,
|