@tamagui/react-native-use-responder-events 1.61.2 → 1.62.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/dist/cjs/ResponderSystem.js +75 -243
- package/dist/cjs/ResponderSystem.js.map +1 -1
- package/dist/cjs/ResponderSystem.native.js +222 -0
- package/dist/cjs/ResponderSystem.native.js.map +6 -0
- package/dist/cjs/ResponderTouchHistoryStore.js +48 -115
- package/dist/cjs/ResponderTouchHistoryStore.js.map +1 -1
- package/dist/cjs/ResponderTouchHistoryStore.native.js +124 -0
- package/dist/cjs/ResponderTouchHistoryStore.native.js.map +6 -0
- package/dist/cjs/createResponderEvent.js +33 -61
- package/dist/cjs/createResponderEvent.js.map +1 -1
- package/dist/cjs/createResponderEvent.native.js +122 -0
- package/dist/cjs/createResponderEvent.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +20 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/types.js +6 -23
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/types.native.js +82 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/cjs/useResponderEvents.js +18 -44
- package/dist/cjs/useResponderEvents.js.map +1 -1
- package/dist/cjs/useResponderEvents.native.js +56 -0
- package/dist/cjs/useResponderEvents.native.js.map +6 -0
- package/dist/cjs/utils.js +36 -95
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/utils.native.js +116 -0
- package/dist/cjs/utils.native.js.map +6 -0
- package/dist/esm/ResponderSystem.js +67 -225
- package/dist/esm/ResponderSystem.js.map +1 -1
- package/dist/esm/ResponderTouchHistoryStore.js +43 -106
- package/dist/esm/ResponderTouchHistoryStore.js.map +1 -1
- package/dist/esm/createResponderEvent.js +28 -52
- package/dist/esm/createResponderEvent.js.map +1 -1
- package/dist/esm/types.js +1 -14
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/useResponderEvents.js +9 -26
- package/dist/esm/useResponderEvents.js.map +1 -1
- package/dist/esm/utils.js +31 -86
- package/dist/esm/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,10 +17,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var ResponderSystem_exports = {};
|
|
30
24
|
__export(ResponderSystem_exports, {
|
|
31
25
|
addNode: () => addNode,
|
|
@@ -35,39 +29,27 @@ __export(ResponderSystem_exports, {
|
|
|
35
29
|
terminateResponder: () => terminateResponder
|
|
36
30
|
});
|
|
37
31
|
module.exports = __toCommonJS(ResponderSystem_exports);
|
|
38
|
-
var import_createResponderEvent = __toESM(require("./createResponderEvent"));
|
|
39
|
-
|
|
40
|
-
var import_types = require("./types");
|
|
41
|
-
var import_utils = require("./utils");
|
|
42
|
-
var import_utils2 = require("./utils");
|
|
43
|
-
const emptyObject = {};
|
|
44
|
-
const startRegistration = [
|
|
32
|
+
var import_createResponderEvent = __toESM(require("./createResponderEvent")), import_ResponderTouchHistoryStore = require("./ResponderTouchHistoryStore"), import_types = require("./types"), import_utils = require("./utils"), import_utils2 = require("./utils");
|
|
33
|
+
const emptyObject = {}, startRegistration = [
|
|
45
34
|
"onStartShouldSetResponderCapture",
|
|
46
35
|
"onStartShouldSetResponder",
|
|
47
|
-
{ bubbles:
|
|
48
|
-
]
|
|
49
|
-
const moveRegistration = [
|
|
36
|
+
{ bubbles: !0 }
|
|
37
|
+
], moveRegistration = [
|
|
50
38
|
"onMoveShouldSetResponderCapture",
|
|
51
39
|
"onMoveShouldSetResponder",
|
|
52
|
-
{ bubbles:
|
|
53
|
-
]
|
|
54
|
-
const scrollRegistration = [
|
|
40
|
+
{ bubbles: !0 }
|
|
41
|
+
], scrollRegistration = [
|
|
55
42
|
"onScrollShouldSetResponderCapture",
|
|
56
43
|
"onScrollShouldSetResponder",
|
|
57
|
-
{ bubbles:
|
|
58
|
-
]
|
|
59
|
-
const shouldSetResponderEvents = {
|
|
44
|
+
{ bubbles: !1 }
|
|
45
|
+
], shouldSetResponderEvents = {
|
|
60
46
|
touchstart: startRegistration,
|
|
61
47
|
mousedown: startRegistration,
|
|
62
48
|
touchmove: moveRegistration,
|
|
63
49
|
mousemove: moveRegistration,
|
|
64
50
|
scroll: scrollRegistration
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const responderListenersMap = /* @__PURE__ */ new Map();
|
|
68
|
-
let isEmulatingMouseEvents = false;
|
|
69
|
-
let trackedTouchCount = 0;
|
|
70
|
-
let currentResponder = {
|
|
51
|
+
}, emptyResponder = { id: null, idPath: null, node: null }, responderListenersMap = /* @__PURE__ */ new Map();
|
|
52
|
+
let isEmulatingMouseEvents = !1, trackedTouchCount = 0, currentResponder = {
|
|
71
53
|
id: null,
|
|
72
54
|
node: null,
|
|
73
55
|
idPath: null
|
|
@@ -78,84 +60,44 @@ function changeCurrentResponder(responder) {
|
|
|
78
60
|
}
|
|
79
61
|
function getResponderConfig(id) {
|
|
80
62
|
const config = responderListenersMap.get(id);
|
|
81
|
-
return config
|
|
63
|
+
return config ?? emptyObject;
|
|
82
64
|
}
|
|
83
65
|
function eventListener(domEvent) {
|
|
84
|
-
const eventType = domEvent.type;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
if (eventType === "touchmove" || trackedTouchCount > 1) {
|
|
90
|
-
isEmulatingMouseEvents = false;
|
|
91
|
-
}
|
|
92
|
-
if (
|
|
93
|
-
// Ignore browser emulated mouse events
|
|
94
|
-
eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents || // Ignore mousemove if a mousedown didn't occur first
|
|
95
|
-
eventType === "mousemove" && trackedTouchCount < 1
|
|
96
|
-
) {
|
|
66
|
+
const eventType = domEvent.type, eventTarget = domEvent.target;
|
|
67
|
+
if (eventType === "touchstart" && (isEmulatingMouseEvents = !0), (eventType === "touchmove" || trackedTouchCount > 1) && (isEmulatingMouseEvents = !1), // Ignore browser emulated mouse events
|
|
68
|
+
eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents || // Ignore mousemove if a mousedown didn't occur first
|
|
69
|
+
eventType === "mousemove" && trackedTouchCount < 1)
|
|
97
70
|
return;
|
|
98
|
-
}
|
|
99
71
|
if (isEmulatingMouseEvents && eventType === "mouseup") {
|
|
100
|
-
|
|
101
|
-
isEmulatingMouseEvents = false;
|
|
102
|
-
}
|
|
72
|
+
trackedTouchCount === 0 && (isEmulatingMouseEvents = !1);
|
|
103
73
|
return;
|
|
104
74
|
}
|
|
105
|
-
const isStartEvent = (0, import_types.isStartish)(eventType) && (0, import_utils2.isPrimaryPointerDown)(domEvent);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (isStartEvent || isMoveEvent || isEndEvent) {
|
|
112
|
-
if (domEvent.touches) {
|
|
113
|
-
trackedTouchCount = domEvent.touches.length;
|
|
114
|
-
} else {
|
|
115
|
-
if (isStartEvent) {
|
|
116
|
-
trackedTouchCount = 1;
|
|
117
|
-
} else if (isEndEvent) {
|
|
118
|
-
trackedTouchCount = 0;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
responderTouchHistoryStore.recordTouchTrack(
|
|
122
|
-
eventType,
|
|
123
|
-
responderEvent.nativeEvent
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
let eventPaths = (0, import_utils2.getResponderPaths)(domEvent);
|
|
127
|
-
let wasNegotiated = false;
|
|
128
|
-
let wantsResponder;
|
|
75
|
+
const isStartEvent = (0, import_types.isStartish)(eventType) && (0, import_utils2.isPrimaryPointerDown)(domEvent), isMoveEvent = (0, import_types.isMoveish)(eventType), isEndEvent = (0, import_types.isEndish)(eventType), isScrollEvent = (0, import_types.isScroll)(eventType), isSelectionChangeEvent = (0, import_types.isSelectionChange)(eventType), responderEvent = (0, import_createResponderEvent.default)(domEvent, responderTouchHistoryStore);
|
|
76
|
+
(isStartEvent || isMoveEvent || isEndEvent) && (domEvent.touches ? trackedTouchCount = domEvent.touches.length : isStartEvent ? trackedTouchCount = 1 : isEndEvent && (trackedTouchCount = 0), responderTouchHistoryStore.recordTouchTrack(
|
|
77
|
+
eventType,
|
|
78
|
+
responderEvent.nativeEvent
|
|
79
|
+
));
|
|
80
|
+
let eventPaths = (0, import_utils2.getResponderPaths)(domEvent), wasNegotiated = !1, wantsResponder;
|
|
129
81
|
if (isStartEvent || isMoveEvent || isScrollEvent && trackedTouchCount > 0) {
|
|
130
|
-
const currentResponderIdPath = currentResponder.idPath;
|
|
131
|
-
const eventIdPath = eventPaths.idPath;
|
|
82
|
+
const currentResponderIdPath = currentResponder.idPath, eventIdPath = eventPaths.idPath;
|
|
132
83
|
if (currentResponderIdPath != null && eventIdPath != null) {
|
|
133
84
|
const lowestCommonAncestor = (0, import_utils2.getLowestCommonAncestor)(
|
|
134
85
|
currentResponderIdPath,
|
|
135
86
|
eventIdPath
|
|
136
87
|
);
|
|
137
88
|
if (lowestCommonAncestor != null) {
|
|
138
|
-
const
|
|
139
|
-
const index = indexOfLowestCommonAncestor + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
|
|
89
|
+
const index = eventIdPath.indexOf(lowestCommonAncestor) + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
|
|
140
90
|
eventPaths = {
|
|
141
91
|
idPath: eventIdPath.slice(index),
|
|
142
92
|
nodePath: eventPaths.nodePath.slice(index)
|
|
143
93
|
};
|
|
144
|
-
} else
|
|
94
|
+
} else
|
|
145
95
|
eventPaths = null;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (eventPaths != null) {
|
|
149
|
-
wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent);
|
|
150
|
-
if (wantsResponder != null) {
|
|
151
|
-
attemptTransfer(responderEvent, wantsResponder);
|
|
152
|
-
wasNegotiated = true;
|
|
153
|
-
}
|
|
154
96
|
}
|
|
97
|
+
eventPaths != null && (wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent), wantsResponder != null && (attemptTransfer(responderEvent, wantsResponder), wasNegotiated = !0));
|
|
155
98
|
}
|
|
156
99
|
if (currentResponder.id != null && currentResponder.node != null) {
|
|
157
|
-
const { id, node } = currentResponder
|
|
158
|
-
const {
|
|
100
|
+
const { id, node } = currentResponder, {
|
|
159
101
|
onResponderStart,
|
|
160
102
|
onResponderMove,
|
|
161
103
|
onResponderEnd,
|
|
@@ -163,62 +105,21 @@ function eventListener(domEvent) {
|
|
|
163
105
|
onResponderTerminate,
|
|
164
106
|
onResponderTerminationRequest
|
|
165
107
|
} = getResponderConfig(id);
|
|
166
|
-
responderEvent.bubbles =
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
responderEvent.dispatchConfig.registrationName = "onResponderStart";
|
|
172
|
-
onResponderStart(responderEvent);
|
|
173
|
-
}
|
|
174
|
-
} else if (isMoveEvent) {
|
|
175
|
-
if (onResponderMove != null) {
|
|
176
|
-
responderEvent.dispatchConfig.registrationName = "onResponderMove";
|
|
177
|
-
onResponderMove(responderEvent);
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
108
|
+
if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, isStartEvent)
|
|
109
|
+
onResponderStart != null && (responderEvent.dispatchConfig.registrationName = "onResponderStart", onResponderStart(responderEvent));
|
|
110
|
+
else if (isMoveEvent)
|
|
111
|
+
onResponderMove != null && (responderEvent.dispatchConfig.registrationName = "onResponderMove", onResponderMove(responderEvent));
|
|
112
|
+
else {
|
|
180
113
|
const isTerminateEvent = (0, import_types.isCancelish)(eventType) || // native context menu
|
|
181
114
|
eventType === "contextmenu" || // window blur
|
|
182
115
|
eventType === "blur" && eventTarget === window || // responder (or ancestors) blur
|
|
183
116
|
eventType === "blur" && eventTarget.contains(node) && domEvent.relatedTarget !== node || // native scroll without using a pointer
|
|
184
117
|
isScrollEvent && trackedTouchCount === 0 || // native scroll on node that is parent of the responder (allow siblings to scroll)
|
|
185
118
|
isScrollEvent && eventTarget.contains(node) && eventTarget !== node || // native select/selectionchange on node
|
|
186
|
-
isSelectionChangeEvent && (0, import_utils2.hasValidSelection)(domEvent);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
responderEvent.dispatchConfig.registrationName = "onResponderEnd";
|
|
191
|
-
onResponderEnd(responderEvent);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (isReleaseEvent) {
|
|
195
|
-
if (onResponderRelease != null) {
|
|
196
|
-
responderEvent.dispatchConfig.registrationName = "onResponderRelease";
|
|
197
|
-
onResponderRelease(responderEvent);
|
|
198
|
-
}
|
|
199
|
-
changeCurrentResponder(emptyResponder);
|
|
200
|
-
}
|
|
201
|
-
if (isTerminateEvent) {
|
|
202
|
-
let shouldTerminate = true;
|
|
203
|
-
if (eventType === "contextmenu" || eventType === "scroll" || eventType === "selectionchange") {
|
|
204
|
-
if (wasNegotiated) {
|
|
205
|
-
shouldTerminate = false;
|
|
206
|
-
} else if (onResponderTerminationRequest != null) {
|
|
207
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest";
|
|
208
|
-
if (onResponderTerminationRequest(responderEvent) === false) {
|
|
209
|
-
shouldTerminate = false;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (shouldTerminate) {
|
|
214
|
-
if (onResponderTerminate != null) {
|
|
215
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminate";
|
|
216
|
-
onResponderTerminate(responderEvent);
|
|
217
|
-
}
|
|
218
|
-
changeCurrentResponder(emptyResponder);
|
|
219
|
-
isEmulatingMouseEvents = false;
|
|
220
|
-
trackedTouchCount = 0;
|
|
221
|
-
}
|
|
119
|
+
isSelectionChangeEvent && (0, import_utils2.hasValidSelection)(domEvent), isReleaseEvent = isEndEvent && !isTerminateEvent && !(0, import_utils2.hasTargetTouches)(node, domEvent.touches);
|
|
120
|
+
if (isEndEvent && onResponderEnd != null && (responderEvent.dispatchConfig.registrationName = "onResponderEnd", onResponderEnd(responderEvent)), isReleaseEvent && (onResponderRelease != null && (responderEvent.dispatchConfig.registrationName = "onResponderRelease", onResponderRelease(responderEvent)), changeCurrentResponder(emptyResponder)), isTerminateEvent) {
|
|
121
|
+
let shouldTerminate = !0;
|
|
122
|
+
(eventType === "contextmenu" || eventType === "scroll" || eventType === "selectionchange") && (wasNegotiated ? shouldTerminate = !1 : onResponderTerminationRequest != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (shouldTerminate = !1))), shouldTerminate && (onResponderTerminate != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), changeCurrentResponder(emptyResponder), isEmulatingMouseEvents = !1, trackedTouchCount = 0);
|
|
222
123
|
}
|
|
223
124
|
}
|
|
224
125
|
}
|
|
@@ -226,101 +127,46 @@ function eventListener(domEvent) {
|
|
|
226
127
|
function findWantsResponder(eventPaths, domEvent, responderEvent) {
|
|
227
128
|
const shouldSetCallbacks = shouldSetResponderEvents[domEvent.type];
|
|
228
129
|
if (shouldSetCallbacks != null) {
|
|
229
|
-
const { idPath, nodePath } = eventPaths
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const config = getResponderConfig(id);
|
|
235
|
-
const shouldSetCallback = config[callbackName];
|
|
236
|
-
if (shouldSetCallback != null) {
|
|
237
|
-
responderEvent.currentTarget = node;
|
|
238
|
-
if (shouldSetCallback(responderEvent) === true) {
|
|
239
|
-
const prunedIdPath = idPath.slice(idPath.indexOf(id));
|
|
240
|
-
return { id, node, idPath: prunedIdPath };
|
|
241
|
-
}
|
|
130
|
+
const { idPath, nodePath } = eventPaths, shouldSetCallbackCaptureName = shouldSetCallbacks[0], shouldSetCallbackBubbleName = shouldSetCallbacks[1], { bubbles } = shouldSetCallbacks[2], check = function(id, node, callbackName) {
|
|
131
|
+
const shouldSetCallback = getResponderConfig(id)[callbackName];
|
|
132
|
+
if (shouldSetCallback != null && (responderEvent.currentTarget = node, shouldSetCallback(responderEvent) === !0)) {
|
|
133
|
+
const prunedIdPath = idPath.slice(idPath.indexOf(id));
|
|
134
|
+
return { id, node, idPath: prunedIdPath };
|
|
242
135
|
}
|
|
243
136
|
};
|
|
244
137
|
for (let i = idPath.length - 1; i >= 0; i--) {
|
|
245
|
-
const id = idPath[i];
|
|
246
|
-
|
|
247
|
-
const result = check(id, node, shouldSetCallbackCaptureName);
|
|
248
|
-
if (result != null) {
|
|
138
|
+
const id = idPath[i], node = nodePath[i], result = check(id, node, shouldSetCallbackCaptureName);
|
|
139
|
+
if (result != null)
|
|
249
140
|
return result;
|
|
250
|
-
|
|
251
|
-
if (responderEvent.isPropagationStopped() === true) {
|
|
141
|
+
if (responderEvent.isPropagationStopped() === !0)
|
|
252
142
|
return;
|
|
253
|
-
}
|
|
254
143
|
}
|
|
255
|
-
if (bubbles)
|
|
144
|
+
if (bubbles)
|
|
256
145
|
for (let i = 0; i < idPath.length; i++) {
|
|
257
|
-
const id = idPath[i];
|
|
258
|
-
|
|
259
|
-
const result = check(id, node, shouldSetCallbackBubbleName);
|
|
260
|
-
if (result != null) {
|
|
146
|
+
const id = idPath[i], node = nodePath[i], result = check(id, node, shouldSetCallbackBubbleName);
|
|
147
|
+
if (result != null)
|
|
261
148
|
return result;
|
|
262
|
-
|
|
263
|
-
if (responderEvent.isPropagationStopped() === true) {
|
|
149
|
+
if (responderEvent.isPropagationStopped() === !0)
|
|
264
150
|
return;
|
|
265
|
-
}
|
|
266
151
|
}
|
|
267
|
-
|
|
268
|
-
const id = idPath[0];
|
|
269
|
-
|
|
270
|
-
const target = domEvent.target;
|
|
271
|
-
if (target === node) {
|
|
152
|
+
else {
|
|
153
|
+
const id = idPath[0], node = nodePath[0];
|
|
154
|
+
if (domEvent.target === node)
|
|
272
155
|
return check(id, node, shouldSetCallbackBubbleName);
|
|
273
|
-
}
|
|
274
156
|
}
|
|
275
157
|
}
|
|
276
158
|
}
|
|
277
159
|
function attemptTransfer(responderEvent, wantsResponder) {
|
|
278
|
-
const { id: currentId, node: currentNode } = currentResponder;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
responderEvent.cancelable = false;
|
|
283
|
-
responderEvent.currentTarget = node;
|
|
284
|
-
if (currentId == null) {
|
|
285
|
-
if (onResponderGrant != null) {
|
|
286
|
-
responderEvent.currentTarget = node;
|
|
287
|
-
responderEvent.dispatchConfig.registrationName = "onResponderGrant";
|
|
288
|
-
onResponderGrant(responderEvent);
|
|
289
|
-
}
|
|
290
|
-
changeCurrentResponder(wantsResponder);
|
|
291
|
-
} else {
|
|
160
|
+
const { id: currentId, node: currentNode } = currentResponder, { id, node } = wantsResponder, { onResponderGrant, onResponderReject } = getResponderConfig(id);
|
|
161
|
+
if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, currentId == null)
|
|
162
|
+
onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder);
|
|
163
|
+
else {
|
|
292
164
|
const { onResponderTerminate, onResponderTerminationRequest } = getResponderConfig(currentId);
|
|
293
|
-
let allowTransfer =
|
|
294
|
-
|
|
295
|
-
responderEvent.currentTarget = currentNode;
|
|
296
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest";
|
|
297
|
-
if (onResponderTerminationRequest(responderEvent) === false) {
|
|
298
|
-
allowTransfer = false;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
if (allowTransfer) {
|
|
302
|
-
if (onResponderTerminate != null) {
|
|
303
|
-
responderEvent.currentTarget = currentNode;
|
|
304
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminate";
|
|
305
|
-
onResponderTerminate(responderEvent);
|
|
306
|
-
}
|
|
307
|
-
if (onResponderGrant != null) {
|
|
308
|
-
responderEvent.currentTarget = node;
|
|
309
|
-
responderEvent.dispatchConfig.registrationName = "onResponderGrant";
|
|
310
|
-
onResponderGrant(responderEvent);
|
|
311
|
-
}
|
|
312
|
-
changeCurrentResponder(wantsResponder);
|
|
313
|
-
} else {
|
|
314
|
-
if (onResponderReject != null) {
|
|
315
|
-
responderEvent.currentTarget = node;
|
|
316
|
-
responderEvent.dispatchConfig.registrationName = "onResponderReject";
|
|
317
|
-
onResponderReject(responderEvent);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
165
|
+
let allowTransfer = !0;
|
|
166
|
+
onResponderTerminationRequest != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (allowTransfer = !1)), allowTransfer ? (onResponderTerminate != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder)) : onResponderReject != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderReject", onResponderReject(responderEvent));
|
|
320
167
|
}
|
|
321
168
|
}
|
|
322
|
-
const documentEventsCapturePhase = ["blur", "scroll"]
|
|
323
|
-
const documentEventsBubblePhase = [
|
|
169
|
+
const documentEventsCapturePhase = ["blur", "scroll"], documentEventsBubblePhase = [
|
|
324
170
|
// mouse
|
|
325
171
|
"mousedown",
|
|
326
172
|
"mousemove",
|
|
@@ -335,31 +181,19 @@ const documentEventsBubblePhase = [
|
|
|
335
181
|
"contextmenu",
|
|
336
182
|
"select",
|
|
337
183
|
"selectionchange"
|
|
338
|
-
];
|
|
339
|
-
const isTamaguiResponderActive = Symbol();
|
|
184
|
+
], isTamaguiResponderActive = Symbol();
|
|
340
185
|
function attachListeners() {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
documentEventsCapturePhase.forEach((eventType) => {
|
|
347
|
-
document.addEventListener(eventType, eventListener, true);
|
|
348
|
-
});
|
|
349
|
-
window[isTamaguiResponderActive] = true;
|
|
350
|
-
}
|
|
186
|
+
import_utils.canUseDOM && !window[isTamaguiResponderActive] && (window.addEventListener("blur", eventListener), documentEventsBubblePhase.forEach((eventType) => {
|
|
187
|
+
document.addEventListener(eventType, eventListener);
|
|
188
|
+
}), documentEventsCapturePhase.forEach((eventType) => {
|
|
189
|
+
document.addEventListener(eventType, eventListener, !0);
|
|
190
|
+
}), window[isTamaguiResponderActive] = !0);
|
|
351
191
|
}
|
|
352
192
|
function addNode(id, node, config) {
|
|
353
|
-
(0, import_utils2.setResponderId)(node, id);
|
|
354
|
-
responderListenersMap.set(id, config);
|
|
193
|
+
(0, import_utils2.setResponderId)(node, id), responderListenersMap.set(id, config);
|
|
355
194
|
}
|
|
356
195
|
function removeNode(id) {
|
|
357
|
-
|
|
358
|
-
terminateResponder();
|
|
359
|
-
}
|
|
360
|
-
if (responderListenersMap.has(id)) {
|
|
361
|
-
responderListenersMap.delete(id);
|
|
362
|
-
}
|
|
196
|
+
currentResponder.id === id && terminateResponder(), responderListenersMap.has(id) && responderListenersMap.delete(id);
|
|
363
197
|
}
|
|
364
198
|
function terminateResponder() {
|
|
365
199
|
const { id, node } = currentResponder;
|
|
@@ -367,13 +201,11 @@ function terminateResponder() {
|
|
|
367
201
|
const { onResponderTerminate } = getResponderConfig(id);
|
|
368
202
|
if (onResponderTerminate != null) {
|
|
369
203
|
const event = (0, import_createResponderEvent.default)({}, responderTouchHistoryStore);
|
|
370
|
-
event.currentTarget = node;
|
|
371
|
-
onResponderTerminate(event);
|
|
204
|
+
event.currentTarget = node, onResponderTerminate(event);
|
|
372
205
|
}
|
|
373
206
|
changeCurrentResponder(emptyResponder);
|
|
374
207
|
}
|
|
375
|
-
isEmulatingMouseEvents =
|
|
376
|
-
trackedTouchCount = 0;
|
|
208
|
+
isEmulatingMouseEvents = !1, trackedTouchCount = 0;
|
|
377
209
|
}
|
|
378
210
|
function getResponderNode() {
|
|
379
211
|
return currentResponder.node;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ResponderSystem.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,kCAAiC,4CACjC,oCAA2C,yCAC3C,eAOO,oBACP,eAA0B,oBAC1BA,gBAOO;AA4CP,MAAM,cAAc,CAAC,GAIf,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA,EAAE,SAAS,GAAK;AAClB,GACM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA,EAAE,SAAS,GAAK;AAClB,GACM,qBAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA,EAAE,SAAS,GAAM;AACnB,GACM,2BAA2B;AAAA,EAC/B,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,QAAQ;AACV,GAEM,iBAAiB,EAAE,IAAI,MAAM,QAAQ,MAAM,MAAM,KAAK,GACtD,wBAAwB,oBAAI,IAAI;AAEtC,IAAI,yBAAyB,IACzB,oBAAoB,GACpB,mBAAsC;AAAA,EACxC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,QAAQ;AACV;AACA,MAAM,6BAA6B,IAAI,6DAA2B;AAElE,SAAS,uBAAuB,WAA8B;AAC5D,qBAAmB;AACrB;AAEA,SAAS,mBAAmB,IAAwC;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