@tamagui/react-native-use-responder-events 1.112.3 → 1.112.5
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/cjs/useResponderEvents.js +11 -7
- package/dist/cjs/useResponderEvents.js.map +1 -1
- package/dist/cjs/useResponderEvents.native.js +11 -10
- package/dist/cjs/useResponderEvents.native.js.map +2 -2
- package/dist/esm/useResponderEvents.js +11 -7
- package/dist/esm/useResponderEvents.js.map +1 -1
- package/dist/esm/useResponderEvents.mjs +13 -9
- package/dist/esm/useResponderEvents.mjs.map +1 -1
- package/dist/esm/useResponderEvents.native.js +13 -11
- package/dist/esm/useResponderEvents.native.js.map +1 -1
- package/package.json +2 -2
- package/src/useResponderEvents.ts +29 -25
- package/types/useResponderEvents.d.ts.map +1 -1
|
@@ -26,12 +26,12 @@ __export(useResponderEvents_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(useResponderEvents_exports);
|
|
27
27
|
var React = __toESM(require("react")), ResponderSystem = __toESM(require("./ResponderSystem"));
|
|
28
28
|
__reExport(useResponderEvents_exports, require("./utils"), module.exports);
|
|
29
|
-
const emptyObject = {};
|
|
29
|
+
const emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
|
|
30
30
|
function useResponderEvents(hostRef, config = emptyObject) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
|
|
32
|
+
const id = Ids.get(hostRef);
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
ResponderSystem.attachListeners();
|
|
35
35
|
const {
|
|
36
36
|
onMoveShouldSetResponder,
|
|
37
37
|
onMoveShouldSetResponderCapture,
|
|
@@ -41,8 +41,12 @@ function useResponderEvents(hostRef, config = emptyObject) {
|
|
|
41
41
|
onSelectionChangeShouldSetResponderCapture,
|
|
42
42
|
onStartShouldSetResponder,
|
|
43
43
|
onStartShouldSetResponderCapture
|
|
44
|
-
} = config, requiresResponderSystem = onMoveShouldSetResponder
|
|
45
|
-
|
|
44
|
+
} = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
|
|
45
|
+
if (requiresResponderSystem)
|
|
46
|
+
return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
|
|
47
|
+
ResponderSystem.removeNode(node);
|
|
48
|
+
};
|
|
49
|
+
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
|
|
46
50
|
}, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
|
|
47
51
|
isResponder: hostRef.current === ResponderSystem.getResponderNode()
|
|
48
52
|
}), React.useDebugValue(config));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useResponderEvents.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,MAAM,cAAc,CAAC;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,MAAM,cAAc,CAAC,GAEf,WAAW,oBAAI,QAAsB,GACrC,MAAM,oBAAI,QAAqB;AAE9B,SAAS,mBACd,SACA,SAA0C,aAC1C;AACA,EAAK,IAAI,IAAI,OAAO,KAClB,IAAI,IAAI,SAAS,GAAG,KAAK,OAAO,CAAC,EAAE;AAErC,QAAM,KAAK,IAAI,IAAI,OAAO;AAG1B,QAAM,UAAU,MAAM;AACpB,oBAAgB,gBAAgB;AAEhC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,QAEE,0BAA0B,GAC9B,4BACE,mCACA,8BACA,qCACA,uCACA,8CACA,6BACA,mCAGE,OAAO,QAAQ,QAAQ;AAE7B,QAAI;AACF,6BAAgB,QAAQ,IAAI,MAAM,MAAM,GACxC,SAAS,IAAI,SAAS,EAAI,GAEnB,MAAM;AACX,wBAAgB,WAAW,IAAI;AAAA,MACjC;AAGF,IAAI,SAAS,IAAI,IAAI,MACnB,gBAAgB,WAAW,IAAI,GAC/B,SAAS,IAAI,SAAS,EAAK;AAAA,EAE/B,GAAG,CAAC,QAAQ,SAAS,EAAE,CAAC,GAEpB,QAAQ,IAAI,aAAa,kBAC3B,MAAM,cAAc;AAAA,IAClB,aAAa,QAAQ,YAAY,gBAAgB,iBAAiB;AAAA,EACpE,CAAC,GACD,MAAM,cAAc,MAAM;AAE9B;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -27,18 +27,19 @@ __export(useResponderEvents_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(useResponderEvents_exports);
|
|
28
28
|
var React = __toESM(require("react")), ResponderSystem = __toESM(require("./ResponderSystem"));
|
|
29
29
|
__reExport(useResponderEvents_exports, require("./utils"), module.exports);
|
|
30
|
-
var emptyObject = {};
|
|
30
|
+
var emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
|
|
31
31
|
function useResponderEvents(hostRef) {
|
|
32
|
-
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject
|
|
32
|
+
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject;
|
|
33
|
+
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
|
|
34
|
+
var id = Ids.get(hostRef);
|
|
33
35
|
React.useEffect(function() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
|
|
36
|
+
ResponderSystem.attachListeners();
|
|
37
|
+
var { onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onScrollShouldSetResponder, onScrollShouldSetResponderCapture, onSelectionChangeShouldSetResponder, onSelectionChangeShouldSetResponderCapture, onStartShouldSetResponder, onStartShouldSetResponderCapture } = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
|
|
38
|
+
if (requiresResponderSystem)
|
|
39
|
+
return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), function() {
|
|
40
|
+
ResponderSystem.removeNode(node);
|
|
41
|
+
};
|
|
42
|
+
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
|
|
42
43
|
}, [
|
|
43
44
|
config,
|
|
44
45
|
hostRef,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/react-native-use-responder-events/src/useResponderEvents.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,IAAMA,cAAc,CAAC;
|
|
5
|
-
"names": ["emptyObject", "useResponderEvents", "hostRef", "config", "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,IAAMA,cAAc,CAAC,GAEfC,WAAW,oBAAIC,QAAAA,GACfC,MAAM,oBAAID,QAAAA;AAET,SAASE,mBACdC,SAAY;MACZC,SAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAA0CN;AAE1C,EAAKG,IAAII,IAAIF,OAAAA,KACXF,IAAIK,IAAIH,SAAS,GAAGI,KAAKC,OAAM,CAAA,EAAI;AAErC,MAAMC,KAAKR,IAAIS,IAAIP,OAAAA;AAGnBQ,QAAMC,UAAU,WAAA;AACdC,oBAAgBC,gBAAe;AAE/B,QAAM,EACJC,0BACAC,iCACAC,4BACAC,mCACAC,qCACAC,4CACAC,2BACAC,iCAAgC,IAC9BlB,QAEEmB,0BAA0BC,GAC9BT,4BACEC,mCACAC,8BACAC,qCACAC,uCACAC,8CACAC,6BACAC,mCAGEG,OAAOtB,QAAQuB,QAAQC;AAE7B,QAAIJ;AACFV,6BAAgBe,QAAQnB,IAAIgB,MAAMrB,MAAAA,GAClCL,SAASO,IAAIH,SAAS,EAAA,GAEf,WAAA;AACLU,wBAAgBgB,WAAWJ,IAAAA;MAC7B;AAGF,IAAI1B,SAASW,IAAIe,IAAAA,MACfZ,gBAAgBgB,WAAWJ,IAAAA,GAC3B1B,SAASO,IAAIH,SAAS,EAAA;EAE1B,GAAG;IAACC;IAAQD;IAASM;GAAG,GAEpBqB,QAAQC,IAAIC,aAAa,kBAC3BrB,MAAMsB,cAAc;IAClBC,aAAa/B,QAAQuB,YAAYb,gBAAgBsB,iBAAgB;EACnE,CAAA,GACAxB,MAAMsB,cAAc7B,MAAAA;AAExB;",
|
|
5
|
+
"names": ["emptyObject", "Attached", "WeakMap", "Ids", "useResponderEvents", "hostRef", "config", "has", "set", "Math", "random", "id", "get", "React", "useEffect", "ResponderSystem", "attachListeners", "onMoveShouldSetResponder", "onMoveShouldSetResponderCapture", "onScrollShouldSetResponder", "onScrollShouldSetResponderCapture", "onSelectionChangeShouldSetResponder", "onSelectionChangeShouldSetResponderCapture", "onStartShouldSetResponder", "onStartShouldSetResponderCapture", "requiresResponderSystem", "Boolean", "node", "current", "host", "addNode", "removeNode", "process", "env", "NODE_ENV", "useDebugValue", "isResponder", "getResponderNode"]
|
|
6
6
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as ResponderSystem from "./ResponderSystem";
|
|
3
3
|
export * from "./utils";
|
|
4
|
-
const emptyObject = {};
|
|
4
|
+
const emptyObject = {}, Attached = /* @__PURE__ */ new WeakMap(), Ids = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
function useResponderEvents(hostRef, config = emptyObject) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
|
|
7
|
+
const id = Ids.get(hostRef);
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
ResponderSystem.attachListeners();
|
|
10
10
|
const {
|
|
11
11
|
onMoveShouldSetResponder,
|
|
12
12
|
onMoveShouldSetResponderCapture,
|
|
@@ -16,8 +16,12 @@ function useResponderEvents(hostRef, config = emptyObject) {
|
|
|
16
16
|
onSelectionChangeShouldSetResponderCapture,
|
|
17
17
|
onStartShouldSetResponder,
|
|
18
18
|
onStartShouldSetResponderCapture
|
|
19
|
-
} = config, requiresResponderSystem = onMoveShouldSetResponder
|
|
20
|
-
|
|
19
|
+
} = config, requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture), node = hostRef.current.host;
|
|
20
|
+
if (requiresResponderSystem)
|
|
21
|
+
return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
|
|
22
|
+
ResponderSystem.removeNode(node);
|
|
23
|
+
};
|
|
24
|
+
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
|
|
21
25
|
}, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
|
|
22
26
|
isResponder: hostRef.current === ResponderSystem.getResponderNode()
|
|
23
27
|
}), React.useDebugValue(config));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useResponderEvents.ts"],
|
|
4
|
-
"mappings": "AAMA,YAAY,WAAW;AAEvB,YAAY,qBAAqB;AAEjC,cAAc;AAEd,MAAM,cAAc,CAAC;
|
|
4
|
+
"mappings": "AAMA,YAAY,WAAW;AAEvB,YAAY,qBAAqB;AAEjC,cAAc;AAEd,MAAM,cAAc,CAAC,GAEf,WAAW,oBAAI,QAAsB,GACrC,MAAM,oBAAI,QAAqB;AAE9B,SAAS,mBACd,SACA,SAA0C,aAC1C;AACA,EAAK,IAAI,IAAI,OAAO,KAClB,IAAI,IAAI,SAAS,GAAG,KAAK,OAAO,CAAC,EAAE;AAErC,QAAM,KAAK,IAAI,IAAI,OAAO;AAG1B,QAAM,UAAU,MAAM;AACpB,oBAAgB,gBAAgB;AAEhC,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,QAEE,0BAA0B,GAC9B,4BACE,mCACA,8BACA,qCACA,uCACA,8CACA,6BACA,mCAGE,OAAO,QAAQ,QAAQ;AAE7B,QAAI;AACF,6BAAgB,QAAQ,IAAI,MAAM,MAAM,GACxC,SAAS,IAAI,SAAS,EAAI,GAEnB,MAAM;AACX,wBAAgB,WAAW,IAAI;AAAA,MACjC;AAGF,IAAI,SAAS,IAAI,IAAI,MACnB,gBAAgB,WAAW,IAAI,GAC/B,SAAS,IAAI,SAAS,EAAK;AAAA,EAE/B,GAAG,CAAC,QAAQ,SAAS,EAAE,CAAC,GAEpB,QAAQ,IAAI,aAAa,kBAC3B,MAAM,cAAc;AAAA,IAClB,aAAa,QAAQ,YAAY,gBAAgB,iBAAiB;AAAA,EACpE,CAAC,GACD,MAAM,cAAc,MAAM;AAE9B;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as ResponderSystem from "./ResponderSystem.mjs";
|
|
3
3
|
export * from "./utils.mjs";
|
|
4
|
-
const emptyObject = {}
|
|
4
|
+
const emptyObject = {},
|
|
5
|
+
Attached = /* @__PURE__ */new WeakMap(),
|
|
6
|
+
Ids = /* @__PURE__ */new WeakMap();
|
|
5
7
|
function useResponderEvents(hostRef, config = emptyObject) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
React.useEffect(() =>
|
|
9
|
-
ResponderSystem.
|
|
10
|
-
}), [id]), React.useEffect(() => {
|
|
8
|
+
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
|
|
9
|
+
const id = Ids.get(hostRef);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
ResponderSystem.attachListeners();
|
|
11
12
|
const {
|
|
12
13
|
onMoveShouldSetResponder,
|
|
13
14
|
onMoveShouldSetResponderCapture,
|
|
@@ -18,9 +19,12 @@ function useResponderEvents(hostRef, config = emptyObject) {
|
|
|
18
19
|
onStartShouldSetResponder,
|
|
19
20
|
onStartShouldSetResponderCapture
|
|
20
21
|
} = config,
|
|
21
|
-
requiresResponderSystem = onMoveShouldSetResponder
|
|
22
|
-
node = hostRef.current;
|
|
23
|
-
requiresResponderSystem
|
|
22
|
+
requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture),
|
|
23
|
+
node = hostRef.current.host;
|
|
24
|
+
if (requiresResponderSystem) return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), () => {
|
|
25
|
+
ResponderSystem.removeNode(node);
|
|
26
|
+
};
|
|
27
|
+
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
|
|
24
28
|
}, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
|
|
25
29
|
isResponder: hostRef.current === ResponderSystem.getResponderNode()
|
|
26
30
|
}), React.useDebugValue(config));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ResponderSystem","emptyObject","useResponderEvents","hostRef","config","
|
|
1
|
+
{"version":3,"names":["React","ResponderSystem","emptyObject","Attached","WeakMap","Ids","useResponderEvents","hostRef","config","has","set","Math","random","id","get","useEffect","attachListeners","onMoveShouldSetResponder","onMoveShouldSetResponderCapture","onScrollShouldSetResponder","onScrollShouldSetResponderCapture","onSelectionChangeShouldSetResponder","onSelectionChangeShouldSetResponderCapture","onStartShouldSetResponder","onStartShouldSetResponderCapture","requiresResponderSystem","node","current","host","addNode","removeNode","process","env","NODE_ENV","useDebugValue","isResponder","getResponderNode"],"sources":["../../src/useResponderEvents.ts"],"sourcesContent":[null],"mappings":"AAMA,YAAYA,KAAA,MAAW;AAEvB,YAAYC,eAAA,MAAqB;AAEjC,cAAc;AAEd,MAAMC,WAAA,GAAc,CAAC;EAEfC,QAAA,GAAW,mBAAIC,OAAA,CAAsB;EACrCC,GAAA,GAAM,mBAAID,OAAA,CAAqB;AAE9B,SAASE,mBACdC,OAAA,EACAC,MAAA,GAA0CN,WAAA,EAC1C;EACKG,GAAA,CAAII,GAAA,CAAIF,OAAO,KAClBF,GAAA,CAAIK,GAAA,CAAIH,OAAA,EAAS,GAAGI,IAAA,CAAKC,MAAA,CAAO,CAAC,EAAE;EAErC,MAAMC,EAAA,GAAKR,GAAA,CAAIS,GAAA,CAAIP,OAAO;EAG1BP,KAAA,CAAMe,SAAA,CAAU,MAAM;IACpBd,eAAA,CAAgBe,eAAA,CAAgB;IAEhC,MAAM;QACJC,wBAAA;QACAC,+BAAA;QACAC,0BAAA;QACAC,iCAAA;QACAC,mCAAA;QACAC,0CAAA;QACAC,yBAAA;QACAC;MACF,IAAIhB,MAAA;MAEEiB,uBAAA,GAA0B,GAC9BR,wBAAA,IACEC,+BAAA,IACAC,0BAAA,IACAC,iCAAA,IACAC,mCAAA,IACAC,0CAAA,IACAC,yBAAA,IACAC,gCAAA;MAGEE,IAAA,GAAOnB,OAAA,CAAQoB,OAAA,CAAQC,IAAA;IAE7B,IAAIH,uBAAA,EACF,OAAAxB,eAAA,CAAgB4B,OAAA,CAAQhB,EAAA,EAAIa,IAAA,EAAMlB,MAAM,GACxCL,QAAA,CAASO,GAAA,CAAIH,OAAA,EAAS,EAAI,GAEnB,MAAM;MACXN,eAAA,CAAgB6B,UAAA,CAAWJ,IAAI;IACjC;IAGEvB,QAAA,CAASW,GAAA,CAAIY,IAAI,MACnBzB,eAAA,CAAgB6B,UAAA,CAAWJ,IAAI,GAC/BvB,QAAA,CAASO,GAAA,CAAIH,OAAA,EAAS,EAAK;EAE/B,GAAG,CAACC,MAAA,EAAQD,OAAA,EAASM,EAAE,CAAC,GAEpBkB,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,kBAC3BjC,KAAA,CAAMkC,aAAA,CAAc;IAClBC,WAAA,EAAa5B,OAAA,CAAQoB,OAAA,KAAY1B,eAAA,CAAgBmC,gBAAA,CAAiB;EACpE,CAAC,GACDpC,KAAA,CAAMkC,aAAA,CAAc1B,MAAM;AAE9B","ignoreList":[]}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as ResponderSystem from "./ResponderSystem.native.js";
|
|
3
3
|
export * from "./utils.native.js";
|
|
4
|
-
var emptyObject = {}
|
|
4
|
+
var emptyObject = {},
|
|
5
|
+
Attached = /* @__PURE__ */new WeakMap(),
|
|
6
|
+
Ids = /* @__PURE__ */new WeakMap();
|
|
5
7
|
function useResponderEvents(hostRef) {
|
|
6
|
-
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : emptyObject;
|
|
9
|
+
Ids.has(hostRef) || Ids.set(hostRef, `${Math.random()}`);
|
|
10
|
+
var id = Ids.get(hostRef);
|
|
9
11
|
React.useEffect(function () {
|
|
10
|
-
|
|
11
|
-
ResponderSystem.removeNode(id);
|
|
12
|
-
};
|
|
13
|
-
}, [id]), React.useEffect(function () {
|
|
12
|
+
ResponderSystem.attachListeners();
|
|
14
13
|
var {
|
|
15
14
|
onMoveShouldSetResponder,
|
|
16
15
|
onMoveShouldSetResponderCapture,
|
|
@@ -21,9 +20,12 @@ function useResponderEvents(hostRef) {
|
|
|
21
20
|
onStartShouldSetResponder,
|
|
22
21
|
onStartShouldSetResponderCapture
|
|
23
22
|
} = config,
|
|
24
|
-
requiresResponderSystem = onMoveShouldSetResponder
|
|
25
|
-
node = hostRef.current;
|
|
26
|
-
requiresResponderSystem
|
|
23
|
+
requiresResponderSystem = !!(onMoveShouldSetResponder || onMoveShouldSetResponderCapture || onScrollShouldSetResponder || onScrollShouldSetResponderCapture || onSelectionChangeShouldSetResponder || onSelectionChangeShouldSetResponderCapture || onStartShouldSetResponder || onStartShouldSetResponderCapture),
|
|
24
|
+
node = hostRef.current.host;
|
|
25
|
+
if (requiresResponderSystem) return ResponderSystem.addNode(id, node, config), Attached.set(hostRef, !0), function () {
|
|
26
|
+
ResponderSystem.removeNode(node);
|
|
27
|
+
};
|
|
28
|
+
Attached.get(node) && (ResponderSystem.removeNode(node), Attached.set(hostRef, !1));
|
|
27
29
|
}, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
|
|
28
30
|
isResponder: hostRef.current === ResponderSystem.getResponderNode()
|
|
29
31
|
}), React.useDebugValue(config));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ResponderSystem","emptyObject","useResponderEvents","hostRef","config","arguments","length","
|
|
1
|
+
{"version":3,"names":["React","ResponderSystem","emptyObject","Attached","WeakMap","Ids","useResponderEvents","hostRef","config","arguments","length","has","set","Math","random","id","get","useEffect","attachListeners","onMoveShouldSetResponder","onMoveShouldSetResponderCapture","onScrollShouldSetResponder","onScrollShouldSetResponderCapture","onSelectionChangeShouldSetResponder","onSelectionChangeShouldSetResponderCapture","onStartShouldSetResponder","onStartShouldSetResponderCapture","requiresResponderSystem","node","current","host","addNode","removeNode","process","env","NODE_ENV","useDebugValue","isResponder","getResponderNode"],"sources":["../../src/useResponderEvents.ts"],"sourcesContent":[null],"mappings":"AAMA,YAAYA,KAAA,MAAW;AAEvB,YAAYC,eAAA,MAAqB;AAEjC,cAAc;AAEd,IAAAC,WAAM,KAAc;EAACC,QAEf,kBAAW,IAAAC,OAAI;EAAsBC,GACrC,kBAAM,IAAAD,OAAI;AAET,SAASE,mBACdC,OAAA,EACA;EAEK,IAAIC,MAAI,GAAAC,SACX,CAAAC,MAAQ,QAASD,SAAQ,QAAQ,KAAE,IAAAA,SAAA,MAAAP,WAAA;EAErCG,GAAA,CAAAM,GAAM,CAAAJ,OAAS,KAAIF,GAAA,CAAAO,GAAO,CAAAL,OAAA,KAAAM,IAAA,CAAAC,MAAA;EAG1B,IAAAC,EAAM,GAAAV,GAAA,CAAAW,GAAU,CAAAT,OAAM;EACpBP,KAAA,CAAAiB,SAAA,aAAgB;IAEhBhB,eAAM,CAAAiB,eAAA;IAAA,IACJ;QAAAC,wBAAA;QAAAC,+BAAA;QAAAC,0BAAA;QAAAC,iCAAA;QAAAC,mCAAA;QAAAC,0CAAA;QAAAC,yBAAA;QAAAC;MAAA,IAAAlB,MAAA;MAAAmB,uBAAA,MAAAR,wBAAA,IAAAC,+BAAA,IAAAC,0BAAA,IAAAC,iCAAA,IAAAC,mCAAA,IAAAC,0CAAA,IAAAC,yBAAA,IAAAC,gCAAA;MAAAE,IAAA,GAAArB,OAAA,CAAAsB,OAAA,CAAAC,IAAA;IAAA,IACAH,uBAAA,EACA,OAAA1B,eAAA,CAAA8B,OAAA,CAAAhB,EAAA,EAAAa,IAAA,EAAApB,MAAA,GAAAL,QAAA,CAAAS,GAAA,CAAAL,OAAA;MACAN,eAAA,CAAA+B,UAAA,CAAAJ,IAAA;IACA;IAAAzB,QACA,CAAAa,GAAA,CAAAY,IAAA,MAAA3B,eAAA,CAAA+B,UAAA,CAAAJ,IAAA,GAAAzB,QAAA,CAAAS,GAAA,CAAAL,OAAA;EAAA,IACAC,MACA,EACFD,OAAI,EAeJQ,EAAA,CACE,GAAAkB,OAAA,CAAAC,GAAA,CAAAC,QAAA,KAAgB,aAAY,KAAMnC,KAAM,CAAAoC,aAC/B,CAAI;IAGXC,WAAA,EAAA9B,OAAgB,CAAAsB,OAAA,KAAW5B,eAAI,CAAAqC,gBAAA;EAAA,IACjCtC,KAAA,CAAAoC,aAAA,CAAA5B,MAAA;AAGF;AAE6B,SAKTF,kBACL","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/react-native-use-responder-events",
|
|
3
|
-
"version": "1.112.
|
|
3
|
+
"version": "1.112.5",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@tamagui/build": "1.112.
|
|
31
|
+
"@tamagui/build": "1.112.5",
|
|
32
32
|
"react": "^18.2.0 || ^19.0.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
@@ -12,25 +12,22 @@ export * from './utils'
|
|
|
12
12
|
|
|
13
13
|
const emptyObject = {}
|
|
14
14
|
|
|
15
|
+
const Attached = new WeakMap<any, boolean>()
|
|
16
|
+
const Ids = new WeakMap<any, string>()
|
|
17
|
+
|
|
15
18
|
export function useResponderEvents(
|
|
16
19
|
hostRef: any,
|
|
17
20
|
config: ResponderSystem.ResponderConfig = emptyObject
|
|
18
21
|
) {
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
if (!Ids.has(hostRef)) {
|
|
23
|
+
Ids.set(hostRef, `${Math.random()}`)
|
|
24
|
+
}
|
|
25
|
+
const id = Ids.get(hostRef)!
|
|
21
26
|
|
|
22
|
-
//
|
|
23
|
-
// On initial mount, attach global listeners if needed.
|
|
24
|
-
// On unmount, remove node potentially attached to the Responder System.
|
|
27
|
+
// Register and unregister with the Responder System as necessary
|
|
25
28
|
React.useEffect(() => {
|
|
26
29
|
ResponderSystem.attachListeners()
|
|
27
|
-
return () => {
|
|
28
|
-
ResponderSystem.removeNode(id)
|
|
29
|
-
}
|
|
30
|
-
}, [id])
|
|
31
30
|
|
|
32
|
-
// Register and unregister with the Responder System as necessary
|
|
33
|
-
React.useEffect(() => {
|
|
34
31
|
const {
|
|
35
32
|
onMoveShouldSetResponder,
|
|
36
33
|
onMoveShouldSetResponderCapture,
|
|
@@ -42,24 +39,31 @@ export function useResponderEvents(
|
|
|
42
39
|
onStartShouldSetResponderCapture,
|
|
43
40
|
} = config
|
|
44
41
|
|
|
45
|
-
const requiresResponderSystem =
|
|
46
|
-
onMoveShouldSetResponder
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
const requiresResponderSystem = Boolean(
|
|
43
|
+
onMoveShouldSetResponder ||
|
|
44
|
+
onMoveShouldSetResponderCapture ||
|
|
45
|
+
onScrollShouldSetResponder ||
|
|
46
|
+
onScrollShouldSetResponderCapture ||
|
|
47
|
+
onSelectionChangeShouldSetResponder ||
|
|
48
|
+
onSelectionChangeShouldSetResponderCapture ||
|
|
49
|
+
onStartShouldSetResponder ||
|
|
50
|
+
onStartShouldSetResponderCapture
|
|
51
|
+
)
|
|
54
52
|
|
|
55
|
-
const node = hostRef.current
|
|
53
|
+
const node = hostRef.current.host
|
|
56
54
|
|
|
57
55
|
if (requiresResponderSystem) {
|
|
58
56
|
ResponderSystem.addNode(id, node, config)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
Attached.set(hostRef, true)
|
|
58
|
+
|
|
59
|
+
return () => {
|
|
60
|
+
ResponderSystem.removeNode(node)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (Attached.get(node)) {
|
|
65
|
+
ResponderSystem.removeNode(node)
|
|
66
|
+
Attached.set(hostRef, false)
|
|
63
67
|
}
|
|
64
68
|
}, [config, hostRef, id])
|
|
65
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResponderEvents.d.ts","sourceRoot":"","sources":["../src/useResponderEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAA;AAEpD,cAAc,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"useResponderEvents.d.ts","sourceRoot":"","sources":["../src/useResponderEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAA;AAEpD,cAAc,SAAS,CAAA;AAOvB,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,GAAG,EACZ,MAAM,GAAE,eAAe,CAAC,eAA6B,QAwDtD"}
|