@tamagui/react-native-web-internals 1.132.20 → 1.132.22
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/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.native.js +73 -43
- package/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.native.js.map +6 -1
- package/dist/esm/StyleSheet/__tests__/compiler-test.native.js +174 -166
- package/dist/esm/StyleSheet/__tests__/compiler-test.native.js.map +6 -1
- package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.native.js +18 -20
- package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.native.js.map +6 -1
- package/dist/esm/StyleSheet/__tests__/index-test.native.js +203 -149
- package/dist/esm/StyleSheet/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/StyleSheet/__tests__/preprocess-test.native.js +16 -16
- package/dist/esm/StyleSheet/__tests__/preprocess-test.native.js.map +6 -1
- package/dist/esm/StyleSheet/__tests__/validate-test.native.js +11 -10
- package/dist/esm/StyleSheet/__tests__/validate-test.native.js.map +6 -1
- package/dist/esm/StyleSheet/compiler/createReactDOMStyle.native.js +114 -63
- package/dist/esm/StyleSheet/compiler/createReactDOMStyle.native.js.map +6 -1
- package/dist/esm/StyleSheet/compiler/hash.native.js +4 -2
- package/dist/esm/StyleSheet/compiler/hash.native.js.map +6 -1
- package/dist/esm/StyleSheet/compiler/hyphenateStyleName.native.js +7 -6
- package/dist/esm/StyleSheet/compiler/hyphenateStyleName.native.js.map +6 -1
- package/dist/esm/StyleSheet/compiler/index.native.js +221 -220
- package/dist/esm/StyleSheet/compiler/index.native.js.map +6 -1
- package/dist/esm/StyleSheet/compiler/normalizeColor.native.js +15 -17
- package/dist/esm/StyleSheet/compiler/normalizeColor.native.js.map +6 -1
- package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.native.js +6 -4
- package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.native.js.map +6 -1
- package/dist/esm/StyleSheet/compiler/resolveShadowValue.native.js +13 -25
- package/dist/esm/StyleSheet/compiler/resolveShadowValue.native.js.map +6 -1
- package/dist/esm/StyleSheet/dom/createCSSStyleSheet.native.js +15 -10
- package/dist/esm/StyleSheet/dom/createCSSStyleSheet.native.js.map +6 -1
- package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.native.js +22 -22
- package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.native.js.map +6 -1
- package/dist/esm/StyleSheet/dom/index.native.js +34 -29
- package/dist/esm/StyleSheet/dom/index.native.js.map +6 -1
- package/dist/esm/StyleSheet/index.native.js +16 -12
- package/dist/esm/StyleSheet/index.native.js.map +6 -1
- package/dist/esm/StyleSheet/preprocess.native.js +44 -73
- package/dist/esm/StyleSheet/preprocess.native.js.map +6 -1
- package/dist/esm/StyleSheet/validate.native.js +33 -32
- package/dist/esm/StyleSheet/validate.native.js.map +6 -1
- package/dist/esm/TextAncestorContext.native.js +6 -4
- package/dist/esm/TextAncestorContext.native.js.map +6 -1
- package/dist/esm/colorProps.native.js +4 -2
- package/dist/esm/colorProps.native.js.map +6 -1
- package/dist/esm/index.native.js +78 -43
- package/dist/esm/index.native.js.map +6 -1
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.native.js +9 -9
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.native.js.map +6 -1
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.native.js +6 -6
- package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.native.js.map +6 -1
- package/dist/esm/modules/AccessibilityUtil/index.native.js +12 -10
- package/dist/esm/modules/AccessibilityUtil/index.native.js.map +6 -1
- package/dist/esm/modules/AccessibilityUtil/isDisabled.native.js +7 -6
- package/dist/esm/modules/AccessibilityUtil/isDisabled.native.js.map +6 -1
- package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.native.js +34 -34
- package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.native.js.map +6 -1
- package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.native.js +24 -25
- package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.native.js.map +6 -1
- package/dist/esm/modules/AssetRegistry/index.native.js +5 -2
- package/dist/esm/modules/AssetRegistry/index.native.js.map +6 -1
- package/dist/esm/modules/ImageLoader/index.native.js +75 -79
- package/dist/esm/modules/ImageLoader/index.native.js.map +6 -1
- package/dist/esm/modules/InteractionManager.native.js +133 -135
- package/dist/esm/modules/InteractionManager.native.js.map +6 -1
- package/dist/esm/modules/Platform/__tests__/index-test.native.js +9 -9
- package/dist/esm/modules/Platform/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/Platform/index.native.js +9 -8
- package/dist/esm/modules/Platform/index.native.js.map +6 -1
- package/dist/esm/modules/TextInputState/index.native.js +31 -30
- package/dist/esm/modules/TextInputState/index.native.js.map +6 -1
- package/dist/esm/modules/UIManager/__tests__/index-test.native.js +49 -51
- package/dist/esm/modules/UIManager/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/UIManager/index.native.js +39 -36
- package/dist/esm/modules/UIManager/index.native.js.map +6 -1
- package/dist/esm/modules/canUseDOM.native.js +6 -4
- package/dist/esm/modules/canUseDOM.native.js.map +6 -1
- package/dist/esm/modules/createDOMProps/__tests__/index-test.native.js +45 -51
- package/dist/esm/modules/createDOMProps/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/createDOMProps/index.native.js +92 -96
- package/dist/esm/modules/createDOMProps/index.native.js.map +6 -1
- package/dist/esm/modules/createEventHandle/__tests__/index-test.native.js +189 -189
- package/dist/esm/modules/createEventHandle/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/createEventHandle/index.native.js +24 -17
- package/dist/esm/modules/createEventHandle/index.native.js.map +6 -1
- package/dist/esm/modules/dismissKeyboard/index.native.js +8 -7
- package/dist/esm/modules/dismissKeyboard/index.native.js.map +6 -1
- package/dist/esm/modules/forwardedProps/index.native.js +128 -126
- package/dist/esm/modules/forwardedProps/index.native.js.map +6 -1
- package/dist/esm/modules/getBoundingClientRect/index.native.js +11 -9
- package/dist/esm/modules/getBoundingClientRect/index.native.js.map +6 -1
- package/dist/esm/modules/invariant.native.js +22 -12
- package/dist/esm/modules/invariant.native.js.map +6 -1
- package/dist/esm/modules/isSelectionValid/index.native.js +5 -6
- package/dist/esm/modules/isSelectionValid/index.native.js.map +6 -1
- package/dist/esm/modules/isWebColor/index.native.js +7 -6
- package/dist/esm/modules/isWebColor/index.native.js.map +6 -1
- package/dist/esm/modules/mergeRefs/__tests__/index-test.native.js +7 -9
- package/dist/esm/modules/mergeRefs/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/mergeRefs/index.native.js +8 -5
- package/dist/esm/modules/mergeRefs/index.native.js.map +6 -1
- package/dist/esm/modules/modality/__tests__/index-test.native.js +8 -8
- package/dist/esm/modules/modality/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/modality/index.native.js +19 -55
- package/dist/esm/modules/modality/index.native.js.map +6 -1
- package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.native.js +4 -4
- package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/multiplyStyleLengthValue/index.native.js +15 -17
- package/dist/esm/modules/multiplyStyleLengthValue/index.native.js.map +6 -1
- package/dist/esm/modules/normalizeColor/index.native.js +17 -19
- package/dist/esm/modules/normalizeColor/index.native.js.map +6 -1
- package/dist/esm/modules/pick/index.native.js +6 -3
- package/dist/esm/modules/pick/index.native.js.map +6 -1
- package/dist/esm/modules/processColor/__tests__/index-test.native.js +27 -36
- package/dist/esm/modules/processColor/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/processColor/index.native.js +9 -5
- package/dist/esm/modules/processColor/index.native.js.map +6 -1
- package/dist/esm/modules/requestIdleCallback/index.native.js +19 -21
- package/dist/esm/modules/requestIdleCallback/index.native.js.map +6 -1
- package/dist/esm/modules/setValueForStyles/dangerousStyleValue.native.js +5 -3
- package/dist/esm/modules/setValueForStyles/dangerousStyleValue.native.js.map +6 -1
- package/dist/esm/modules/setValueForStyles/index.native.js +10 -8
- package/dist/esm/modules/setValueForStyles/index.native.js.map +6 -1
- package/dist/esm/modules/unitlessNumbers/index.native.js +66 -60
- package/dist/esm/modules/unitlessNumbers/index.native.js.map +6 -1
- package/dist/esm/modules/useElementLayout/index.native.js +9 -5
- package/dist/esm/modules/useElementLayout/index.native.js.map +6 -1
- package/dist/esm/modules/useEvent/__tests__/index-test.native.js +214 -210
- package/dist/esm/modules/useEvent/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/useEvent/index.native.js +24 -21
- package/dist/esm/modules/useEvent/index.native.js.map +6 -1
- package/dist/esm/modules/useHover/__tests__/index-test.native.js +134 -161
- package/dist/esm/modules/useHover/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/useHover/index.native.js +51 -65
- package/dist/esm/modules/useHover/index.native.js.map +6 -1
- package/dist/esm/modules/useLayoutEffect/index.native.js +6 -5
- package/dist/esm/modules/useLayoutEffect/index.native.js.map +6 -1
- package/dist/esm/modules/useLocale/index.native.js +12 -14
- package/dist/esm/modules/useLocale/index.native.js.map +6 -1
- package/dist/esm/modules/useLocale/isLocaleRTL.native.js +25 -9
- package/dist/esm/modules/useLocale/isLocaleRTL.native.js.map +6 -1
- package/dist/esm/modules/useMergeRefs/__tests__/index-test.native.js +54 -54
- package/dist/esm/modules/useMergeRefs/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/useMergeRefs/index.native.js +16 -9
- package/dist/esm/modules/useMergeRefs/index.native.js.map +6 -1
- package/dist/esm/modules/usePlatformMethods/index.native.js +11 -12
- package/dist/esm/modules/usePlatformMethods/index.native.js.map +6 -1
- package/dist/esm/modules/useStable/__tests__/index-test.native.js +36 -45
- package/dist/esm/modules/useStable/__tests__/index-test.native.js.map +6 -1
- package/dist/esm/modules/useStable/index.native.js +4 -2
- package/dist/esm/modules/useStable/index.native.js.map +6 -1
- package/dist/esm/styleTypes.native.js +1 -2
- package/dist/esm/styleTypes.native.js.map +6 -1
- package/dist/esm/types.native.js +1 -2
- package/dist/esm/types.native.js.map +6 -1
- package/package.json +8 -8
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import createEventHandle from "../createEventHandle/index
|
|
2
|
-
import useLayoutEffect from "../useLayoutEffect/index
|
|
3
|
-
import useStable from "../useStable/index
|
|
1
|
+
import createEventHandle from "../createEventHandle/index";
|
|
2
|
+
import useLayoutEffect from "../useLayoutEffect/index";
|
|
3
|
+
import useStable from "../useStable/index";
|
|
4
4
|
function useEvent(event, options) {
|
|
5
|
-
var targetListeners = useStable(function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
targetListeners.forEach(function (removeListener) {
|
|
5
|
+
var targetListeners = useStable(function() {
|
|
6
|
+
return /* @__PURE__ */ new Map();
|
|
7
|
+
}), addListener = useStable(function() {
|
|
8
|
+
var addEventListener = createEventHandle(event, options);
|
|
9
|
+
return function(target, callback) {
|
|
10
|
+
var removeTargetListener = targetListeners.get(target);
|
|
11
|
+
removeTargetListener?.(), callback == null && targetListeners.delete(target);
|
|
12
|
+
var removeEventListener = addEventListener(target, callback);
|
|
13
|
+
return targetListeners.set(target, removeEventListener), removeEventListener;
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
return useLayoutEffect(function() {
|
|
17
|
+
return function() {
|
|
18
|
+
targetListeners.forEach(function(removeListener) {
|
|
20
19
|
removeListener();
|
|
21
20
|
}), targetListeners.clear();
|
|
22
21
|
};
|
|
23
|
-
}, [
|
|
22
|
+
}, [
|
|
23
|
+
targetListeners
|
|
24
|
+
]), addListener;
|
|
24
25
|
}
|
|
25
|
-
export {
|
|
26
|
-
|
|
26
|
+
export {
|
|
27
|
+
useEvent as default
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/useEvent/index.tsx"],
|
|
4
|
+
"mappings": "AASA,OAAOA,uBAAuB;AAC9B,OAAOC,qBAAqB;AAC5B,OAAOC,eAAe;AAiBP,SAAf,SACEC,OACAC,SAGQ;AAER,MAAMC,kBAAkBH,UAAU,WAAA;WAAM,oBAAII,IAAAA;MAEtCC,cAAcL,UAAU,WAAA;AAC5B,QAAMM,mBAAmBR,kBAAkBG,OAAOC,OAAAA;AAClD,WAAO,SAACK,QAAqBC,UAAAA;AAC3B,UAAMC,uBAAuBN,gBAAgBO,IAAIH,MAAAA;AACjD,MACEE,uBAAAA,GAEED,YAAY,QACdL,gBAAgBQ,OAAOJ,MAAAA;AAEzB,UAAMK,sBAAsBN,iBAAiBC,QAAQC,QAAAA;AACrDL,6BAAgBU,IAAIN,QAAQK,mBAAAA,GACrBA;IACT;EACF,CAAA;AAEAb,yBAAgB,WAAA;AACd,WAAO,WAAA;AACLI,sBAAgBW,QAAQ,SAACC,gBAAAA;AACvBA,uBAAAA;MACF,CAAA,GACAZ,gBAAgBa,MAAK;IACvB;EACF,GAAG;IAACb;GAAgB,GAEbE;AACT;",
|
|
5
|
+
"names": ["createEventHandle", "useLayoutEffect", "useStable", "event", "options", "targetListeners", "Map", "addListener", "addEventListener", "target", "callback", "removeTargetListener", "get", "delete", "removeEventListener", "set", "forEach", "removeListener", "clear"]
|
|
6
|
+
}
|
|
@@ -3,7 +3,7 @@ import { clearPointers, createEventTarget, describeWithPointerEvent, setPointerE
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as ReactDOM from "react-dom";
|
|
5
5
|
import { act } from "react-dom/test-utils";
|
|
6
|
-
import { testOnly_resetActiveModality } from "../../modality/index
|
|
6
|
+
import { testOnly_resetActiveModality } from "../../modality/index";
|
|
7
7
|
import useHover from "..";
|
|
8
8
|
function createRoot(rootNode) {
|
|
9
9
|
return {
|
|
@@ -12,118 +12,104 @@ function createRoot(rootNode) {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
describeWithPointerEvent("useHover", function
|
|
15
|
+
describeWithPointerEvent("useHover", function(hasPointerEvents) {
|
|
16
16
|
var root, rootNode;
|
|
17
|
-
beforeEach(function
|
|
17
|
+
beforeEach(function() {
|
|
18
18
|
setPointerEvent(hasPointerEvents), rootNode = document.createElement("div"), document.body.appendChild(rootNode), root = createRoot(rootNode);
|
|
19
|
-
}), afterEach(function
|
|
19
|
+
}), afterEach(function() {
|
|
20
20
|
root.render(null), document.body.removeChild(rootNode), rootNode = null, root = null, testOnly_resetActiveModality(), clearPointers();
|
|
21
|
-
}), describe("contain", function
|
|
22
|
-
var onHoverChange,
|
|
23
|
-
onHoverStart,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
contain: !0
|
|
38
|
-
}), /* @__PURE__ */_jsx("div", {
|
|
39
|
-
ref,
|
|
40
|
-
children: /* @__PURE__ */_jsx("div", {
|
|
41
|
-
ref: childRef
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
act(function () {
|
|
46
|
-
root.render(/* @__PURE__ */_jsx(Component, {}));
|
|
21
|
+
}), describe("contain", function() {
|
|
22
|
+
var onHoverChange, onHoverStart, onHoverUpdate, onHoverEnd, ref, childRef, componentInit = function() {
|
|
23
|
+
onHoverChange = jest.fn(), onHoverStart = jest.fn(), onHoverUpdate = jest.fn(), onHoverEnd = jest.fn(), ref = /* @__PURE__ */ React.createRef(), childRef = /* @__PURE__ */ React.createRef();
|
|
24
|
+
var Component = function() {
|
|
25
|
+
return useHover(ref, {
|
|
26
|
+
onHoverChange,
|
|
27
|
+
onHoverStart,
|
|
28
|
+
onHoverUpdate,
|
|
29
|
+
onHoverEnd
|
|
30
|
+
}), useHover(childRef, {
|
|
31
|
+
contain: !0
|
|
32
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
33
|
+
ref,
|
|
34
|
+
children: /* @__PURE__ */ _jsx("div", {
|
|
35
|
+
ref: childRef
|
|
36
|
+
})
|
|
47
37
|
});
|
|
48
38
|
};
|
|
49
|
-
|
|
39
|
+
act(function() {
|
|
40
|
+
root.render(/* @__PURE__ */ _jsx(Component, {}));
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
test("contains the hover gesture", function() {
|
|
50
44
|
componentInit();
|
|
51
|
-
var target = createEventTarget(ref.current),
|
|
52
|
-
|
|
53
|
-
act(function () {
|
|
45
|
+
var target = createEventTarget(ref.current), child = createEventTarget(childRef.current);
|
|
46
|
+
act(function() {
|
|
54
47
|
target.pointerover(), target.pointerout(), child.pointerover();
|
|
55
|
-
}), expect(onHoverEnd).toBeCalled(), act(function
|
|
48
|
+
}), expect(onHoverEnd).toBeCalled(), act(function() {
|
|
56
49
|
child.pointerout();
|
|
57
50
|
}), expect(onHoverStart).toBeCalled();
|
|
58
51
|
});
|
|
59
|
-
}), describe("disabled", function
|
|
60
|
-
var onHoverChange,
|
|
61
|
-
onHoverStart,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
onHoverStart,
|
|
72
|
-
onHoverUpdate,
|
|
73
|
-
onHoverEnd
|
|
74
|
-
}), /* @__PURE__ */_jsx("div", {
|
|
75
|
-
ref
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
act(function () {
|
|
79
|
-
root.render(/* @__PURE__ */_jsx(Component, {}));
|
|
52
|
+
}), describe("disabled", function() {
|
|
53
|
+
var onHoverChange, onHoverStart, onHoverUpdate, onHoverEnd, ref, componentInit = function() {
|
|
54
|
+
onHoverChange = jest.fn(), onHoverStart = jest.fn(), onHoverUpdate = jest.fn(), onHoverEnd = jest.fn(), ref = /* @__PURE__ */ React.createRef();
|
|
55
|
+
var Component = function() {
|
|
56
|
+
return useHover(ref, {
|
|
57
|
+
disabled: !0,
|
|
58
|
+
onHoverChange,
|
|
59
|
+
onHoverStart,
|
|
60
|
+
onHoverUpdate,
|
|
61
|
+
onHoverEnd
|
|
62
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
63
|
+
ref
|
|
80
64
|
});
|
|
81
65
|
};
|
|
82
|
-
|
|
66
|
+
act(function() {
|
|
67
|
+
root.render(/* @__PURE__ */ _jsx(Component, {}));
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
test("does not call callbacks", function() {
|
|
83
71
|
componentInit();
|
|
84
72
|
var target = createEventTarget(ref.current);
|
|
85
|
-
act(function
|
|
73
|
+
act(function() {
|
|
86
74
|
target.pointerover(), target.pointerout();
|
|
87
75
|
}), expect(onHoverChange).not.toBeCalled(), expect(onHoverStart).not.toBeCalled(), expect(onHoverUpdate).not.toBeCalled(), expect(onHoverEnd).not.toBeCalled();
|
|
88
76
|
});
|
|
89
|
-
}), describe("onHoverStart", function
|
|
90
|
-
var onHoverStart,
|
|
91
|
-
ref
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}), /* @__PURE__ */_jsx("div", {
|
|
98
|
-
ref
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
act(function () {
|
|
102
|
-
root.render(/* @__PURE__ */_jsx(Component, {}));
|
|
77
|
+
}), describe("onHoverStart", function() {
|
|
78
|
+
var onHoverStart, ref, componentInit = function() {
|
|
79
|
+
onHoverStart = jest.fn(), ref = /* @__PURE__ */ React.createRef();
|
|
80
|
+
var Component = function() {
|
|
81
|
+
return useHover(ref, {
|
|
82
|
+
onHoverStart
|
|
83
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
84
|
+
ref
|
|
103
85
|
});
|
|
104
86
|
};
|
|
105
|
-
|
|
87
|
+
act(function() {
|
|
88
|
+
root.render(/* @__PURE__ */ _jsx(Component, {}));
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
test("is called for mouse pointers", function() {
|
|
106
92
|
componentInit();
|
|
107
93
|
var target = createEventTarget(ref.current);
|
|
108
|
-
act(function
|
|
94
|
+
act(function() {
|
|
109
95
|
target.pointerover({
|
|
110
96
|
pointerType: "mouse"
|
|
111
97
|
});
|
|
112
98
|
}), expect(onHoverStart).toBeCalledTimes(1);
|
|
113
|
-
}), test("is not called for touch pointers", function
|
|
99
|
+
}), test("is not called for touch pointers", function() {
|
|
114
100
|
componentInit();
|
|
115
101
|
var target = createEventTarget(ref.current);
|
|
116
|
-
act(function
|
|
102
|
+
act(function() {
|
|
117
103
|
target.pointerdown({
|
|
118
104
|
pointerType: "touch"
|
|
119
105
|
}), target.pointerup({
|
|
120
106
|
pointerType: "touch"
|
|
121
107
|
});
|
|
122
108
|
}), expect(onHoverStart).not.toBeCalled();
|
|
123
|
-
}), test("is called if a mouse pointer is used after a touch pointer", function
|
|
109
|
+
}), test("is called if a mouse pointer is used after a touch pointer", function() {
|
|
124
110
|
componentInit();
|
|
125
111
|
var target = createEventTarget(ref.current);
|
|
126
|
-
act(function
|
|
112
|
+
act(function() {
|
|
127
113
|
target.pointerdown({
|
|
128
114
|
pointerType: "touch"
|
|
129
115
|
}), target.pointerup({
|
|
@@ -133,34 +119,32 @@ describeWithPointerEvent("useHover", function (hasPointerEvents) {
|
|
|
133
119
|
});
|
|
134
120
|
}), expect(onHoverStart).toBeCalledTimes(1);
|
|
135
121
|
});
|
|
136
|
-
}), describe("onHoverChange", function
|
|
137
|
-
var onHoverChange,
|
|
138
|
-
ref
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}), /* @__PURE__ */_jsx("div", {
|
|
145
|
-
ref
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
act(function () {
|
|
149
|
-
root.render(/* @__PURE__ */_jsx(Component, {}));
|
|
122
|
+
}), describe("onHoverChange", function() {
|
|
123
|
+
var onHoverChange, ref, componentInit = function() {
|
|
124
|
+
onHoverChange = jest.fn(), ref = /* @__PURE__ */ React.createRef();
|
|
125
|
+
var Component = function() {
|
|
126
|
+
return useHover(ref, {
|
|
127
|
+
onHoverChange
|
|
128
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
129
|
+
ref
|
|
150
130
|
});
|
|
151
131
|
};
|
|
152
|
-
|
|
132
|
+
act(function() {
|
|
133
|
+
root.render(/* @__PURE__ */ _jsx(Component, {}));
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
test("is called for mouse pointers", function() {
|
|
153
137
|
componentInit();
|
|
154
138
|
var target = createEventTarget(ref.current);
|
|
155
|
-
act(function
|
|
139
|
+
act(function() {
|
|
156
140
|
target.pointerover();
|
|
157
|
-
}), expect(onHoverChange).toBeCalledTimes(1), expect(onHoverChange).toBeCalledWith(!0), act(function
|
|
141
|
+
}), expect(onHoverChange).toBeCalledTimes(1), expect(onHoverChange).toBeCalledWith(!0), act(function() {
|
|
158
142
|
target.pointerout();
|
|
159
143
|
}), expect(onHoverChange).toBeCalledTimes(2), expect(onHoverChange).toBeCalledWith(!1);
|
|
160
|
-
}), test("is not called for touch pointers", function
|
|
144
|
+
}), test("is not called for touch pointers", function() {
|
|
161
145
|
componentInit();
|
|
162
146
|
var target = createEventTarget(ref.current);
|
|
163
|
-
act(function
|
|
147
|
+
act(function() {
|
|
164
148
|
target.pointerdown({
|
|
165
149
|
pointerType: "touch"
|
|
166
150
|
}), target.pointerup({
|
|
@@ -168,47 +152,43 @@ describeWithPointerEvent("useHover", function (hasPointerEvents) {
|
|
|
168
152
|
});
|
|
169
153
|
}), expect(onHoverChange).not.toBeCalled();
|
|
170
154
|
});
|
|
171
|
-
}), describe("onHoverEnd", function
|
|
172
|
-
var onHoverEnd,
|
|
173
|
-
ref,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
children: /* @__PURE__ */_jsx("div", {
|
|
183
|
-
ref: childRef
|
|
184
|
-
})
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
act(function () {
|
|
188
|
-
root.render(/* @__PURE__ */_jsx(Component, {}));
|
|
155
|
+
}), describe("onHoverEnd", function() {
|
|
156
|
+
var onHoverEnd, ref, childRef, componentInit = function() {
|
|
157
|
+
onHoverEnd = jest.fn(), ref = /* @__PURE__ */ React.createRef(), childRef = /* @__PURE__ */ React.createRef();
|
|
158
|
+
var Component = function() {
|
|
159
|
+
return useHover(ref, {
|
|
160
|
+
onHoverEnd
|
|
161
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
162
|
+
ref,
|
|
163
|
+
children: /* @__PURE__ */ _jsx("div", {
|
|
164
|
+
ref: childRef
|
|
165
|
+
})
|
|
189
166
|
});
|
|
190
167
|
};
|
|
191
|
-
|
|
168
|
+
act(function() {
|
|
169
|
+
root.render(/* @__PURE__ */ _jsx(Component, {}));
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
test("is called for mouse pointers", function() {
|
|
192
173
|
componentInit();
|
|
193
174
|
var target = createEventTarget(ref.current);
|
|
194
|
-
act(function
|
|
175
|
+
act(function() {
|
|
195
176
|
target.pointerover(), target.pointerout();
|
|
196
177
|
}), expect(onHoverEnd).toBeCalledTimes(1);
|
|
197
|
-
}), test("is not called for touch pointers", function
|
|
178
|
+
}), test("is not called for touch pointers", function() {
|
|
198
179
|
componentInit();
|
|
199
180
|
var target = createEventTarget(ref.current);
|
|
200
|
-
act(function
|
|
181
|
+
act(function() {
|
|
201
182
|
target.pointerdown({
|
|
202
183
|
pointerType: "touch"
|
|
203
184
|
}), target.pointerup({
|
|
204
185
|
pointerType: "touch"
|
|
205
186
|
});
|
|
206
187
|
}), expect(onHoverEnd).not.toBeCalled();
|
|
207
|
-
}), test("is not called when entering children of the target", function
|
|
188
|
+
}), test("is not called when entering children of the target", function() {
|
|
208
189
|
componentInit();
|
|
209
|
-
var target = createEventTarget(ref.current),
|
|
210
|
-
|
|
211
|
-
act(function () {
|
|
190
|
+
var target = createEventTarget(ref.current), child = createEventTarget(childRef.current);
|
|
191
|
+
act(function() {
|
|
212
192
|
target.pointerover(), target.pointerout({
|
|
213
193
|
relatedTarget: childRef.current
|
|
214
194
|
}), child.pointerover({
|
|
@@ -216,22 +196,20 @@ describeWithPointerEvent("useHover", function (hasPointerEvents) {
|
|
|
216
196
|
});
|
|
217
197
|
}), expect(onHoverEnd).not.toBeCalled();
|
|
218
198
|
});
|
|
219
|
-
}), describe("onHoverUpdate", function
|
|
220
|
-
test('is called after the active pointer moves"', function
|
|
221
|
-
var onHoverUpdate = jest.fn(),
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
};
|
|
230
|
-
act(function () {
|
|
231
|
-
root.render(/* @__PURE__ */_jsx(Component, {}));
|
|
199
|
+
}), describe("onHoverUpdate", function() {
|
|
200
|
+
test('is called after the active pointer moves"', function() {
|
|
201
|
+
var onHoverUpdate = jest.fn(), ref = /* @__PURE__ */ React.createRef(), Component = function() {
|
|
202
|
+
return useHover(ref, {
|
|
203
|
+
onHoverUpdate
|
|
204
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
205
|
+
ref
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
act(function() {
|
|
209
|
+
root.render(/* @__PURE__ */ _jsx(Component, {}));
|
|
232
210
|
});
|
|
233
211
|
var target = createEventTarget(ref.current);
|
|
234
|
-
act(function
|
|
212
|
+
act(function() {
|
|
235
213
|
target.pointerover(), target.pointerhover({
|
|
236
214
|
x: 0,
|
|
237
215
|
y: 0
|
|
@@ -241,37 +219,32 @@ describeWithPointerEvent("useHover", function (hasPointerEvents) {
|
|
|
241
219
|
});
|
|
242
220
|
}), expect(onHoverUpdate).toBeCalledTimes(2);
|
|
243
221
|
});
|
|
244
|
-
}), describe("repeat use", function
|
|
245
|
-
var onHoverChange,
|
|
246
|
-
onHoverStart,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
onHoverStart,
|
|
256
|
-
onHoverUpdate,
|
|
257
|
-
onHoverEnd
|
|
258
|
-
}), /* @__PURE__ */_jsx("div", {
|
|
259
|
-
ref
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
act(function () {
|
|
263
|
-
root.render(/* @__PURE__ */_jsx(Component, {}));
|
|
222
|
+
}), describe("repeat use", function() {
|
|
223
|
+
var onHoverChange, onHoverStart, onHoverUpdate, onHoverEnd, ref, componentInit = function() {
|
|
224
|
+
onHoverChange = jest.fn(), onHoverStart = jest.fn(), onHoverUpdate = jest.fn(), onHoverEnd = jest.fn(), ref = /* @__PURE__ */ React.createRef();
|
|
225
|
+
var Component = function() {
|
|
226
|
+
return useHover(ref, {
|
|
227
|
+
onHoverChange,
|
|
228
|
+
onHoverStart,
|
|
229
|
+
onHoverUpdate,
|
|
230
|
+
onHoverEnd
|
|
231
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
232
|
+
ref
|
|
264
233
|
});
|
|
265
234
|
};
|
|
266
|
-
|
|
235
|
+
act(function() {
|
|
236
|
+
root.render(/* @__PURE__ */ _jsx(Component, {}));
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
test("callbacks are called each time", function() {
|
|
267
240
|
componentInit();
|
|
268
241
|
var target = createEventTarget(ref.current);
|
|
269
|
-
act(function
|
|
242
|
+
act(function() {
|
|
270
243
|
target.pointerover(), target.pointerhover({
|
|
271
244
|
x: 1,
|
|
272
245
|
y: 1
|
|
273
246
|
}), target.pointerout();
|
|
274
|
-
}), expect(onHoverStart).toBeCalledTimes(1), expect(onHoverUpdate).toBeCalledTimes(1), expect(onHoverEnd).toBeCalledTimes(1), expect(onHoverChange).toBeCalledTimes(2), act(function
|
|
247
|
+
}), expect(onHoverStart).toBeCalledTimes(1), expect(onHoverUpdate).toBeCalledTimes(1), expect(onHoverEnd).toBeCalledTimes(1), expect(onHoverChange).toBeCalledTimes(2), act(function() {
|
|
275
248
|
target.pointerover(), target.pointerhover({
|
|
276
249
|
x: 1,
|
|
277
250
|
y: 1
|
|
@@ -280,4 +253,4 @@ describeWithPointerEvent("useHover", function (hasPointerEvents) {
|
|
|
280
253
|
});
|
|
281
254
|
});
|
|
282
255
|
});
|
|
283
|
-
//# sourceMappingURL=index-test.
|
|
256
|
+
//# sourceMappingURL=index-test.js.map
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/useHover/__tests__/index-test.tsx"],
|
|
4
|
+
"mappings": "AAKC,SAAA,OAAA,YAAA;AAED,SACEA,eACAC,mBACAC,0BACAC,uBACK;AACP,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAC1B,SAASC,WAAW;AAEpB,SAASC,oCAAoC;AAC7C,OAAOC,cAAc;AAErB,SAASC,WAAWC,UAAQ;AAC1B,SAAO;IACLC,OAAOC,SAAO;AACZP,eAASM,OAAOC,SAASF,QAAAA;IAC3B;EACF;AACF;AAEAR,yBAAyB,YAAY,SAACW,kBAAAA;AACpC,MAAIC,MACAJ;AAEJK,aAAW,WAAA;AACTZ,oBAAgBU,gBAAAA,GAChBH,WAAWM,SAASC,cAAc,KAAA,GAClCD,SAASE,KAAKC,YAAYT,QAAAA,GAC1BI,OAAOL,WAAWC,QAAAA;EACpB,CAAA,GAEAU,UAAU,WAAA;A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,KAAK;UACZJ;UACAC;UACAC;UACAC;QACF,CAAA,GACO,qBAACS,OAAAA;UAAIR;;MACd;AACArB,UAAI,WAAA;AACFQ,aAAKH,OAAO,qBAACsB,WAAAA,CAAAA,CAAAA,CAAAA;MACf,CAAA;IACF;AAEAG,SAAK,kCAAkC,WAAA;AACrCP,oBAAAA;AACA,UAAMQ,SAASpC,kBAAkB0B,IAAIW,OAAO;AAC5ChC,UAAI,WAAA;AACF+B,eAAOG,YAAW,GAClBH,OAAOgB,aAAa;UAAEC,GAAG;UAAGC,GAAG;QAAE,CAAA,GACjClB,OAAOI,WAAU;MACnB,CAAA,GACAC,OAAOlB,YAAAA,EAAcuB,gBAAgB,CAAA,GACrCL,OAAOjB,aAAAA,EAAesB,gBAAgB,CAAA,GACtCL,OAAOhB,UAAAA,EAAYqB,gBAAgB,CAAA,GACnCL,OAAOnB,aAAAA,EAAewB,gBAAgB,CAAA,GACtCzC,IAAI,WAAA;AACF+B,eAAOG,YAAW,GAClBH,OAAOgB,aAAa;UAAEC,GAAG;UAAGC,GAAG;QAAE,CAAA,GACjClB,OAAOI,WAAU;MACnB,CAAA,GACAC,OAAOlB,YAAAA,EAAcuB,gBAAgB,CAAA,GACrCL,OAAOjB,aAAAA,EAAesB,gBAAgB,CAAA,GACtCL,OAAOhB,UAAAA,EAAYqB,gBAAgB,CAAA,GACnCL,OAAOnB,aAAAA,EAAewB,gBAAgB,CAAA;IACxC,CAAA;EACF,CAAA;AACF,CAAA;",
|
|
5
|
+
"names": ["clearPointers", "createEventTarget", "describeWithPointerEvent", "setPointerEvent", "React", "ReactDOM", "act", "testOnly_resetActiveModality", "useHover", "createRoot", "rootNode", "render", "element", "hasPointerEvents", "root", "beforeEach", "document", "createElement", "body", "appendChild", "afterEach", "removeChild", "describe", "onHoverChange", "onHoverStart", "onHoverUpdate", "onHoverEnd", "ref", "childRef", "componentInit", "jest", "fn", "createRef", "Component", "contain", "div", "test", "target", "current", "child", "pointerover", "pointerout", "expect", "toBeCalled", "disabled", "not", "pointerType", "toBeCalledTimes", "pointerdown", "pointerup", "toBeCalledWith", "relatedTarget", "node", "pointerhover", "x", "y"]
|
|
6
|
+
}
|
|
@@ -1,77 +1,63 @@
|
|
|
1
|
-
import { getModality } from "../modality/index
|
|
2
|
-
import useEvent from "../useEvent/index
|
|
3
|
-
import useLayoutEffect from "../useLayoutEffect/index
|
|
4
|
-
var emptyObject = {},
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
unlockEventType = "react-gui:hover:unlock",
|
|
10
|
-
supportsPointerEvent = function () {
|
|
11
|
-
return typeof window < "u" && window.PointerEvent != null;
|
|
12
|
-
};
|
|
1
|
+
import { getModality } from "../modality/index";
|
|
2
|
+
import useEvent from "../useEvent/index";
|
|
3
|
+
import useLayoutEffect from "../useLayoutEffect/index";
|
|
4
|
+
var emptyObject = {}, opts = {
|
|
5
|
+
passive: !0
|
|
6
|
+
}, lockEventType = "react-gui:hover:lock", unlockEventType = "react-gui:hover:unlock", supportsPointerEvent = function() {
|
|
7
|
+
return typeof window < "u" && window.PointerEvent != null;
|
|
8
|
+
};
|
|
13
9
|
function dispatchCustomEvent(target, type, payload) {
|
|
14
|
-
var event = document.createEvent("CustomEvent"),
|
|
15
|
-
{
|
|
16
|
-
bubbles = !0,
|
|
17
|
-
cancelable = !0,
|
|
18
|
-
detail
|
|
19
|
-
} = payload || emptyObject;
|
|
10
|
+
var event = document.createEvent("CustomEvent"), { bubbles = !0, cancelable = !0, detail } = payload || emptyObject;
|
|
20
11
|
event.initCustomEvent(type, bubbles, cancelable, detail), target.dispatchEvent(event);
|
|
21
12
|
}
|
|
22
13
|
function getPointerType(event) {
|
|
23
|
-
var {
|
|
24
|
-
pointerType
|
|
25
|
-
} = event;
|
|
14
|
+
var { pointerType } = event;
|
|
26
15
|
return pointerType ?? getModality();
|
|
27
16
|
}
|
|
28
17
|
function useHover(targetRef, config) {
|
|
29
|
-
var {
|
|
30
|
-
|
|
31
|
-
disabled,
|
|
32
|
-
onHoverStart,
|
|
33
|
-
onHoverChange,
|
|
34
|
-
onHoverUpdate,
|
|
35
|
-
onHoverEnd
|
|
36
|
-
} = config,
|
|
37
|
-
canUsePE = supportsPointerEvent(),
|
|
38
|
-
addMoveListener = useEvent(canUsePE ? "pointermove" : "mousemove", opts),
|
|
39
|
-
addEnterListener = useEvent(canUsePE ? "pointerenter" : "mouseenter", opts),
|
|
40
|
-
addLeaveListener = useEvent(canUsePE ? "pointerleave" : "mouseleave", opts),
|
|
41
|
-
addLockListener = useEvent(lockEventType, opts),
|
|
42
|
-
addUnlockListener = useEvent(unlockEventType, opts);
|
|
43
|
-
useLayoutEffect(function () {
|
|
18
|
+
var { contain, disabled, onHoverStart, onHoverChange, onHoverUpdate, onHoverEnd } = config, canUsePE = supportsPointerEvent(), addMoveListener = useEvent(canUsePE ? "pointermove" : "mousemove", opts), addEnterListener = useEvent(canUsePE ? "pointerenter" : "mouseenter", opts), addLeaveListener = useEvent(canUsePE ? "pointerleave" : "mouseleave", opts), addLockListener = useEvent(lockEventType, opts), addUnlockListener = useEvent(unlockEventType, opts);
|
|
19
|
+
useLayoutEffect(function() {
|
|
44
20
|
var target = targetRef.current;
|
|
45
21
|
if (target !== null) {
|
|
46
|
-
var hoverEnd = function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
lockEvent.target !== target2 && hoverStart(e);
|
|
68
|
-
};
|
|
69
|
-
addLockListener(target2, disabled ? null : lockListener), addUnlockListener(target2, disabled ? null : unlockListener);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
22
|
+
var hoverEnd = function(e) {
|
|
23
|
+
onHoverEnd?.(e), onHoverChange?.(!1), addMoveListener(target, null), addLeaveListener(target, null);
|
|
24
|
+
}, leaveListener = function(e) {
|
|
25
|
+
var target2 = targetRef.current;
|
|
26
|
+
target2 != null && getPointerType(e) !== "touch" && (contain && dispatchCustomEvent(target2, unlockEventType), hoverEnd(e));
|
|
27
|
+
}, moveListener = function(e) {
|
|
28
|
+
getPointerType(e) !== "touch" && onHoverUpdate != null && (e.x == null && (e.x = e.clientX), e.y == null && (e.y = e.clientY), onHoverUpdate(e));
|
|
29
|
+
}, hoverStart = function(e) {
|
|
30
|
+
onHoverStart?.(e), onHoverChange?.(!0), onHoverUpdate != null && addMoveListener(target, disabled ? null : moveListener), addLeaveListener(target, disabled ? null : leaveListener);
|
|
31
|
+
}, enterListener = function(e) {
|
|
32
|
+
var target2 = targetRef.current;
|
|
33
|
+
if (target2 != null && getPointerType(e) !== "touch") {
|
|
34
|
+
contain && dispatchCustomEvent(target2, lockEventType), hoverStart(e);
|
|
35
|
+
var lockListener = function(lockEvent) {
|
|
36
|
+
lockEvent.target !== target2 && hoverEnd(e);
|
|
37
|
+
}, unlockListener = function(lockEvent) {
|
|
38
|
+
lockEvent.target !== target2 && hoverStart(e);
|
|
39
|
+
};
|
|
40
|
+
addLockListener(target2, disabled ? null : lockListener), addUnlockListener(target2, disabled ? null : unlockListener);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
72
43
|
addEnterListener(target, disabled ? null : enterListener);
|
|
73
44
|
}
|
|
74
|
-
}, [
|
|
45
|
+
}, [
|
|
46
|
+
addEnterListener,
|
|
47
|
+
addMoveListener,
|
|
48
|
+
addLeaveListener,
|
|
49
|
+
addLockListener,
|
|
50
|
+
addUnlockListener,
|
|
51
|
+
contain,
|
|
52
|
+
disabled,
|
|
53
|
+
onHoverStart,
|
|
54
|
+
onHoverChange,
|
|
55
|
+
onHoverUpdate,
|
|
56
|
+
onHoverEnd,
|
|
57
|
+
targetRef
|
|
58
|
+
]);
|
|
75
59
|
}
|
|
76
|
-
export {
|
|
77
|
-
|
|
60
|
+
export {
|
|
61
|
+
useHover as default
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|