xxf_react 0.6.8 → 0.6.9
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
CHANGED
|
@@ -142,6 +142,6 @@ export interface XHoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onMou
|
|
|
142
142
|
* </XHover>
|
|
143
143
|
* ```
|
|
144
144
|
*/
|
|
145
|
-
export declare
|
|
145
|
+
export declare const XHover: React.ForwardRefExoticComponent<XHoverProps & React.RefAttributes<HTMLElement>>;
|
|
146
146
|
export default XHover;
|
|
147
147
|
//# sourceMappingURL=XHover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XHover.d.ts","sourceRoot":"","sources":["../../../src/layout/hover/XHover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"XHover.d.ts","sourceRoot":"","sources":["../../../src/layout/hover/XHover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuD,SAAS,EAAE,cAAc,EAAC,MAAM,OAAO,CAAA;AAE5G;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC;IACtG;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAA;IAEnB;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IAEpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;IAEtC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,EAAE,MAAM,SAAS,CAAA;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;OAIG;IACH,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,eAAO,MAAM,MAAM,iFAyFjB,CAAA;AAEF,eAAe,MAAM,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useRef, useEffect, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, useCallback, useRef, useEffect, useState } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* 悬浮触发组件
|
|
4
4
|
*
|
|
@@ -63,7 +63,7 @@ import React, { useCallback, useRef, useEffect, useState } from 'react';
|
|
|
63
63
|
* </XHover>
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
export function XHover({ children, hoverDelay = 0, onEnter, onHover, onLeave, hoverLayer, disabled = false, as: Component = 'div', style, ...rest }) {
|
|
66
|
+
export const XHover = forwardRef(function XHover({ children, hoverDelay = 0, onEnter, onHover, onLeave, hoverLayer, disabled = false, as: Component = 'div', style, ...rest }, ref) {
|
|
67
67
|
const timerRef = useRef(null);
|
|
68
68
|
const hasTriggeredRef = useRef(false);
|
|
69
69
|
// 只有 hoverLayer 存在时才需要状态
|
|
@@ -121,8 +121,8 @@ export function XHover({ children, hoverDelay = 0, onEnter, onHover, onLeave, ho
|
|
|
121
121
|
const containerStyle = hoverLayer
|
|
122
122
|
? { position: 'relative', ...style }
|
|
123
123
|
: style;
|
|
124
|
-
return (React.createElement(Component, { ...rest, style: containerStyle, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
124
|
+
return (React.createElement(Component, { ref: ref, ...rest, style: containerStyle, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
125
125
|
children,
|
|
126
126
|
hoverLayer && showLayer && hoverLayer()));
|
|
127
|
-
}
|
|
127
|
+
});
|
|
128
128
|
export default XHover;
|