1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | (function (global, factory) {
|
13 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react-dom'), require('react')) :
|
14 | typeof define === 'function' && define.amd ? define(['react-dom', 'react'], factory) :
|
15 | (global.ReactDOMUnstableNativeDependencies = factory(global.ReactDOM,global.React));
|
16 | }(this, (function (ReactDOM,React) { 'use strict';
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | var validateFormat = function () {};
|
30 |
|
31 | {
|
32 | validateFormat = function (format) {
|
33 | if (format === undefined) {
|
34 | throw new Error('invariant requires an error message argument');
|
35 | }
|
36 | };
|
37 | }
|
38 |
|
39 | function invariant(condition, format, a, b, c, d, e, f) {
|
40 | validateFormat(format);
|
41 |
|
42 | if (!condition) {
|
43 | var error = void 0;
|
44 | if (format === undefined) {
|
45 | error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
46 | } else {
|
47 | var args = [a, b, c, d, e, f];
|
48 | var argIndex = 0;
|
49 | error = new Error(format.replace(/%s/g, function () {
|
50 | return args[argIndex++];
|
51 | }));
|
52 | error.name = 'Invariant Violation';
|
53 | }
|
54 |
|
55 | error.framesToPop = 1;
|
56 | throw error;
|
57 | }
|
58 | }
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | {
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
86 | var fakeNode = document.createElement('react');
|
87 |
|
88 |
|
89 | }
|
90 | }
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 | var warningWithoutStack = function () {};
|
132 |
|
133 | {
|
134 | warningWithoutStack = function (condition, format) {
|
135 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
136 | args[_key - 2] = arguments[_key];
|
137 | }
|
138 |
|
139 | if (format === undefined) {
|
140 | throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
141 | }
|
142 | if (args.length > 8) {
|
143 |
|
144 | throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
145 | }
|
146 | if (condition) {
|
147 | return;
|
148 | }
|
149 | if (typeof console !== 'undefined') {
|
150 | var argsWithFormat = args.map(function (item) {
|
151 | return '' + item;
|
152 | });
|
153 | argsWithFormat.unshift('Warning: ' + format);
|
154 |
|
155 |
|
156 |
|
157 | Function.prototype.apply.call(console.error, console, argsWithFormat);
|
158 | }
|
159 | try {
|
160 |
|
161 |
|
162 |
|
163 | var argIndex = 0;
|
164 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
165 | return args[argIndex++];
|
166 | });
|
167 | throw new Error(message);
|
168 | } catch (x) {}
|
169 | };
|
170 | }
|
171 |
|
172 | var warningWithoutStack$1 = warningWithoutStack;
|
173 |
|
174 | var getFiberCurrentPropsFromNode$1 = null;
|
175 | var getInstanceFromNode$1 = null;
|
176 | var getNodeFromInstance$1 = null;
|
177 |
|
178 | function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
|
179 | getFiberCurrentPropsFromNode$1 = getFiberCurrentPropsFromNodeImpl;
|
180 | getInstanceFromNode$1 = getInstanceFromNodeImpl;
|
181 | getNodeFromInstance$1 = getNodeFromInstanceImpl;
|
182 | {
|
183 | !(getNodeFromInstance$1 && getInstanceFromNode$1) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
|
184 | }
|
185 | }
|
186 |
|
187 | var validateEventDispatches = void 0;
|
188 | {
|
189 | validateEventDispatches = function (event) {
|
190 | var dispatchListeners = event._dispatchListeners;
|
191 | var dispatchInstances = event._dispatchInstances;
|
192 |
|
193 | var listenersIsArr = Array.isArray(dispatchListeners);
|
194 | var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
|
195 |
|
196 | var instancesIsArr = Array.isArray(dispatchInstances);
|
197 | var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
|
198 |
|
199 | !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
|
200 | };
|
201 | }
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 | function executeDispatchesInOrderStopAtTrueImpl(event) {
|
216 | var dispatchListeners = event._dispatchListeners;
|
217 | var dispatchInstances = event._dispatchInstances;
|
218 | {
|
219 | validateEventDispatches(event);
|
220 | }
|
221 | if (Array.isArray(dispatchListeners)) {
|
222 | for (var i = 0; i < dispatchListeners.length; i++) {
|
223 | if (event.isPropagationStopped()) {
|
224 | break;
|
225 | }
|
226 |
|
227 | if (dispatchListeners[i](event, dispatchInstances[i])) {
|
228 | return dispatchInstances[i];
|
229 | }
|
230 | }
|
231 | } else if (dispatchListeners) {
|
232 | if (dispatchListeners(event, dispatchInstances)) {
|
233 | return dispatchInstances;
|
234 | }
|
235 | }
|
236 | return null;
|
237 | }
|
238 |
|
239 |
|
240 |
|
241 |
|
242 | function executeDispatchesInOrderStopAtTrue(event) {
|
243 | var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
244 | event._dispatchInstances = null;
|
245 | event._dispatchListeners = null;
|
246 | return ret;
|
247 | }
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 | function executeDirectDispatch(event) {
|
259 | {
|
260 | validateEventDispatches(event);
|
261 | }
|
262 | var dispatchListener = event._dispatchListeners;
|
263 | var dispatchInstance = event._dispatchInstances;
|
264 | !!Array.isArray(dispatchListener) ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : void 0;
|
265 | event.currentTarget = dispatchListener ? getNodeFromInstance$1(dispatchInstance) : null;
|
266 | var res = dispatchListener ? dispatchListener(event) : null;
|
267 | event.currentTarget = null;
|
268 | event._dispatchListeners = null;
|
269 | event._dispatchInstances = null;
|
270 | return res;
|
271 | }
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 | function hasDispatches(event) {
|
278 | return !!event._dispatchListeners;
|
279 | }
|
280 |
|
281 |
|
282 |
|
283 |
|
284 | var HostComponent = 5;
|
285 |
|
286 | function getParent(inst) {
|
287 | do {
|
288 | inst = inst.return;
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 | } while (inst && inst.tag !== HostComponent);
|
295 | if (inst) {
|
296 | return inst;
|
297 | }
|
298 | return null;
|
299 | }
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 | function getLowestCommonAncestor(instA, instB) {
|
306 | var depthA = 0;
|
307 | for (var tempA = instA; tempA; tempA = getParent(tempA)) {
|
308 | depthA++;
|
309 | }
|
310 | var depthB = 0;
|
311 | for (var tempB = instB; tempB; tempB = getParent(tempB)) {
|
312 | depthB++;
|
313 | }
|
314 |
|
315 |
|
316 | while (depthA - depthB > 0) {
|
317 | instA = getParent(instA);
|
318 | depthA--;
|
319 | }
|
320 |
|
321 |
|
322 | while (depthB - depthA > 0) {
|
323 | instB = getParent(instB);
|
324 | depthB--;
|
325 | }
|
326 |
|
327 |
|
328 | var depth = depthA;
|
329 | while (depth--) {
|
330 | if (instA === instB || instA === instB.alternate) {
|
331 | return instA;
|
332 | }
|
333 | instA = getParent(instA);
|
334 | instB = getParent(instB);
|
335 | }
|
336 | return null;
|
337 | }
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | function isAncestor(instA, instB) {
|
343 | while (instB) {
|
344 | if (instA === instB || instA === instB.alternate) {
|
345 | return true;
|
346 | }
|
347 | instB = getParent(instB);
|
348 | }
|
349 | return false;
|
350 | }
|
351 |
|
352 |
|
353 |
|
354 |
|
355 | function getParentInstance(inst) {
|
356 | return getParent(inst);
|
357 | }
|
358 |
|
359 |
|
360 |
|
361 |
|
362 | function traverseTwoPhase(inst, fn, arg) {
|
363 | var path = [];
|
364 | while (inst) {
|
365 | path.push(inst);
|
366 | inst = getParent(inst);
|
367 | }
|
368 | var i = void 0;
|
369 | for (i = path.length; i-- > 0;) {
|
370 | fn(path[i], 'captured', arg);
|
371 | }
|
372 | for (i = 0; i < path.length; i++) {
|
373 | fn(path[i], 'bubbled', arg);
|
374 | }
|
375 | }
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 | function accumulateInto(current, next) {
|
456 | !(next != null) ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : void 0;
|
457 |
|
458 | if (current == null) {
|
459 | return next;
|
460 | }
|
461 |
|
462 |
|
463 |
|
464 | if (Array.isArray(current)) {
|
465 | if (Array.isArray(next)) {
|
466 | current.push.apply(current, next);
|
467 | return current;
|
468 | }
|
469 | current.push(next);
|
470 | return current;
|
471 | }
|
472 |
|
473 | if (Array.isArray(next)) {
|
474 |
|
475 | return [current].concat(next);
|
476 | }
|
477 |
|
478 | return [current, next];
|
479 | }
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 | function forEachAccumulated(arr, cb, scope) {
|
491 | if (Array.isArray(arr)) {
|
492 | arr.forEach(cb, scope);
|
493 | } else if (arr) {
|
494 | cb.call(scope, arr);
|
495 | }
|
496 | }
|
497 |
|
498 | function isInteractive(tag) {
|
499 | return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
|
500 | }
|
501 |
|
502 | function shouldPreventMouseEvent(name, type, props) {
|
503 | switch (name) {
|
504 | case 'onClick':
|
505 | case 'onClickCapture':
|
506 | case 'onDoubleClick':
|
507 | case 'onDoubleClickCapture':
|
508 | case 'onMouseDown':
|
509 | case 'onMouseDownCapture':
|
510 | case 'onMouseMove':
|
511 | case 'onMouseMoveCapture':
|
512 | case 'onMouseUp':
|
513 | case 'onMouseUpCapture':
|
514 | return !!(props.disabled && isInteractive(type));
|
515 | default:
|
516 | return false;
|
517 | }
|
518 | }
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 | function getListener(inst, registrationName) {
|
554 | var listener = void 0;
|
555 |
|
556 |
|
557 |
|
558 | var stateNode = inst.stateNode;
|
559 | if (!stateNode) {
|
560 |
|
561 | return null;
|
562 | }
|
563 | var props = getFiberCurrentPropsFromNode$1(stateNode);
|
564 | if (!props) {
|
565 |
|
566 | return null;
|
567 | }
|
568 | listener = props[registrationName];
|
569 | if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
|
570 | return null;
|
571 | }
|
572 | !(!listener || typeof listener === 'function') ? invariant(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0;
|
573 | return listener;
|
574 | }
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 | function listenerAtPhase(inst, event, propagationPhase) {
|
581 | var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
582 | return getListener(inst, registrationName);
|
583 | }
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 | function accumulateDirectionalDispatches(inst, phase, event) {
|
602 | {
|
603 | !inst ? warningWithoutStack$1(false, 'Dispatching inst must not be null') : void 0;
|
604 | }
|
605 | var listener = listenerAtPhase(inst, event, phase);
|
606 | if (listener) {
|
607 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
608 | event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
609 | }
|
610 | }
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 | function accumulateTwoPhaseDispatchesSingle(event) {
|
620 | if (event && event.dispatchConfig.phasedRegistrationNames) {
|
621 | traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
|
622 | }
|
623 | }
|
624 |
|
625 |
|
626 |
|
627 |
|
628 | function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
629 | if (event && event.dispatchConfig.phasedRegistrationNames) {
|
630 | var targetInst = event._targetInst;
|
631 | var parentInst = targetInst ? getParentInstance(targetInst) : null;
|
632 | traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
|
633 | }
|
634 | }
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 | function accumulateDispatches(inst, ignoredDirection, event) {
|
642 | if (inst && event && event.dispatchConfig.registrationName) {
|
643 | var registrationName = event.dispatchConfig.registrationName;
|
644 | var listener = getListener(inst, registrationName);
|
645 | if (listener) {
|
646 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
647 | event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
648 | }
|
649 | }
|
650 | }
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 | function accumulateDirectDispatchesSingle(event) {
|
658 | if (event && event.dispatchConfig.registrationName) {
|
659 | accumulateDispatches(event._targetInst, null, event);
|
660 | }
|
661 | }
|
662 |
|
663 | function accumulateTwoPhaseDispatches(events) {
|
664 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
665 | }
|
666 |
|
667 | function accumulateTwoPhaseDispatchesSkipTarget(events) {
|
668 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
|
669 | }
|
670 |
|
671 |
|
672 |
|
673 | function accumulateDirectDispatches(events) {
|
674 | forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
675 | }
|
676 |
|
677 | var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
678 |
|
679 | var _assign = ReactInternals.assign;
|
680 |
|
681 |
|
682 |
|
683 | var EVENT_POOL_SIZE = 10;
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 | var EventInterface = {
|
690 | type: null,
|
691 | target: null,
|
692 |
|
693 | currentTarget: function () {
|
694 | return null;
|
695 | },
|
696 | eventPhase: null,
|
697 | bubbles: null,
|
698 | cancelable: null,
|
699 | timeStamp: function (event) {
|
700 | return event.timeStamp || Date.now();
|
701 | },
|
702 | defaultPrevented: null,
|
703 | isTrusted: null
|
704 | };
|
705 |
|
706 | function functionThatReturnsTrue() {
|
707 | return true;
|
708 | }
|
709 |
|
710 | function functionThatReturnsFalse() {
|
711 | return false;
|
712 | }
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 | function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
|
733 | {
|
734 |
|
735 | delete this.nativeEvent;
|
736 | delete this.preventDefault;
|
737 | delete this.stopPropagation;
|
738 | delete this.isDefaultPrevented;
|
739 | delete this.isPropagationStopped;
|
740 | }
|
741 |
|
742 | this.dispatchConfig = dispatchConfig;
|
743 | this._targetInst = targetInst;
|
744 | this.nativeEvent = nativeEvent;
|
745 |
|
746 | var Interface = this.constructor.Interface;
|
747 | for (var propName in Interface) {
|
748 | if (!Interface.hasOwnProperty(propName)) {
|
749 | continue;
|
750 | }
|
751 | {
|
752 | delete this[propName];
|
753 | }
|
754 | var normalize = Interface[propName];
|
755 | if (normalize) {
|
756 | this[propName] = normalize(nativeEvent);
|
757 | } else {
|
758 | if (propName === 'target') {
|
759 | this.target = nativeEventTarget;
|
760 | } else {
|
761 | this[propName] = nativeEvent[propName];
|
762 | }
|
763 | }
|
764 | }
|
765 |
|
766 | var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
|
767 | if (defaultPrevented) {
|
768 | this.isDefaultPrevented = functionThatReturnsTrue;
|
769 | } else {
|
770 | this.isDefaultPrevented = functionThatReturnsFalse;
|
771 | }
|
772 | this.isPropagationStopped = functionThatReturnsFalse;
|
773 | return this;
|
774 | }
|
775 |
|
776 | _assign(SyntheticEvent.prototype, {
|
777 | preventDefault: function () {
|
778 | this.defaultPrevented = true;
|
779 | var event = this.nativeEvent;
|
780 | if (!event) {
|
781 | return;
|
782 | }
|
783 |
|
784 | if (event.preventDefault) {
|
785 | event.preventDefault();
|
786 | } else if (typeof event.returnValue !== 'unknown') {
|
787 | event.returnValue = false;
|
788 | }
|
789 | this.isDefaultPrevented = functionThatReturnsTrue;
|
790 | },
|
791 |
|
792 | stopPropagation: function () {
|
793 | var event = this.nativeEvent;
|
794 | if (!event) {
|
795 | return;
|
796 | }
|
797 |
|
798 | if (event.stopPropagation) {
|
799 | event.stopPropagation();
|
800 | } else if (typeof event.cancelBubble !== 'unknown') {
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 | event.cancelBubble = true;
|
807 | }
|
808 |
|
809 | this.isPropagationStopped = functionThatReturnsTrue;
|
810 | },
|
811 |
|
812 | |
813 |
|
814 |
|
815 |
|
816 |
|
817 | persist: function () {
|
818 | this.isPersistent = functionThatReturnsTrue;
|
819 | },
|
820 |
|
821 | |
822 |
|
823 |
|
824 |
|
825 |
|
826 | isPersistent: functionThatReturnsFalse,
|
827 |
|
828 | |
829 |
|
830 |
|
831 | destructor: function () {
|
832 | var Interface = this.constructor.Interface;
|
833 | for (var propName in Interface) {
|
834 | {
|
835 | Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
|
836 | }
|
837 | }
|
838 | this.dispatchConfig = null;
|
839 | this._targetInst = null;
|
840 | this.nativeEvent = null;
|
841 | this.isDefaultPrevented = functionThatReturnsFalse;
|
842 | this.isPropagationStopped = functionThatReturnsFalse;
|
843 | this._dispatchListeners = null;
|
844 | this._dispatchInstances = null;
|
845 | {
|
846 | Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
|
847 | Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
|
848 | Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
|
849 | Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
|
850 | Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
|
851 | }
|
852 | }
|
853 | });
|
854 |
|
855 | SyntheticEvent.Interface = EventInterface;
|
856 |
|
857 |
|
858 |
|
859 |
|
860 | SyntheticEvent.extend = function (Interface) {
|
861 | var Super = this;
|
862 |
|
863 | var E = function () {};
|
864 | E.prototype = Super.prototype;
|
865 | var prototype = new E();
|
866 |
|
867 | function Class() {
|
868 | return Super.apply(this, arguments);
|
869 | }
|
870 | _assign(prototype, Class.prototype);
|
871 | Class.prototype = prototype;
|
872 | Class.prototype.constructor = Class;
|
873 |
|
874 | Class.Interface = _assign({}, Super.Interface, Interface);
|
875 | Class.extend = Super.extend;
|
876 | addEventPoolingTo(Class);
|
877 |
|
878 | return Class;
|
879 | };
|
880 |
|
881 | addEventPoolingTo(SyntheticEvent);
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 | function getPooledWarningPropertyDefinition(propName, getVal) {
|
891 | var isFunction = typeof getVal === 'function';
|
892 | return {
|
893 | configurable: true,
|
894 | set: set,
|
895 | get: get
|
896 | };
|
897 |
|
898 | function set(val) {
|
899 | var action = isFunction ? 'setting the method' : 'setting the property';
|
900 | warn(action, 'This is effectively a no-op');
|
901 | return val;
|
902 | }
|
903 |
|
904 | function get() {
|
905 | var action = isFunction ? 'accessing the method' : 'accessing the property';
|
906 | var result = isFunction ? 'This is a no-op function' : 'This is set to null';
|
907 | warn(action, result);
|
908 | return getVal;
|
909 | }
|
910 |
|
911 | function warn(action, result) {
|
912 | var warningCondition = false;
|
913 | !warningCondition ? warningWithoutStack$1(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
|
914 | }
|
915 | }
|
916 |
|
917 | function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
|
918 | var EventConstructor = this;
|
919 | if (EventConstructor.eventPool.length) {
|
920 | var instance = EventConstructor.eventPool.pop();
|
921 | EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
|
922 | return instance;
|
923 | }
|
924 | return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
|
925 | }
|
926 |
|
927 | function releasePooledEvent(event) {
|
928 | var EventConstructor = this;
|
929 | !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
|
930 | event.destructor();
|
931 | if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
|
932 | EventConstructor.eventPool.push(event);
|
933 | }
|
934 | }
|
935 |
|
936 | function addEventPoolingTo(EventConstructor) {
|
937 | EventConstructor.eventPool = [];
|
938 | EventConstructor.getPooled = getPooledEvent;
|
939 | EventConstructor.release = releasePooledEvent;
|
940 | }
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 | var ResponderSyntheticEvent = SyntheticEvent.extend({
|
948 | touchHistory: function (nativeEvent) {
|
949 | return null;
|
950 | }
|
951 | });
|
952 |
|
953 |
|
954 |
|
955 |
|
956 | var TOP_TOUCH_START = 'touchstart';
|
957 | var TOP_TOUCH_MOVE = 'touchmove';
|
958 | var TOP_TOUCH_END = 'touchend';
|
959 | var TOP_TOUCH_CANCEL = 'touchcancel';
|
960 | var TOP_SCROLL = 'scroll';
|
961 | var TOP_SELECTION_CHANGE = 'selectionchange';
|
962 | var TOP_MOUSE_DOWN = 'mousedown';
|
963 | var TOP_MOUSE_MOVE = 'mousemove';
|
964 | var TOP_MOUSE_UP = 'mouseup';
|
965 |
|
966 | function isStartish(topLevelType) {
|
967 | return topLevelType === TOP_TOUCH_START || topLevelType === TOP_MOUSE_DOWN;
|
968 | }
|
969 |
|
970 | function isMoveish(topLevelType) {
|
971 | return topLevelType === TOP_TOUCH_MOVE || topLevelType === TOP_MOUSE_MOVE;
|
972 | }
|
973 |
|
974 | function isEndish(topLevelType) {
|
975 | return topLevelType === TOP_TOUCH_END || topLevelType === TOP_TOUCH_CANCEL || topLevelType === TOP_MOUSE_UP;
|
976 | }
|
977 |
|
978 | var startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN];
|
979 | var moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE];
|
980 | var endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP];
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 | var MAX_TOUCH_BANK = 20;
|
990 | var touchBank = [];
|
991 | var touchHistory = {
|
992 | touchBank: touchBank,
|
993 | numberActiveTouches: 0,
|
994 |
|
995 |
|
996 |
|
997 | indexOfSingleActiveTouch: -1,
|
998 | mostRecentTimeStamp: 0
|
999 | };
|
1000 |
|
1001 | function timestampForTouch(touch) {
|
1002 |
|
1003 |
|
1004 |
|
1005 | return touch.timeStamp || touch.timestamp;
|
1006 | }
|
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 | function createTouchRecord(touch) {
|
1013 | return {
|
1014 | touchActive: true,
|
1015 | startPageX: touch.pageX,
|
1016 | startPageY: touch.pageY,
|
1017 | startTimeStamp: timestampForTouch(touch),
|
1018 | currentPageX: touch.pageX,
|
1019 | currentPageY: touch.pageY,
|
1020 | currentTimeStamp: timestampForTouch(touch),
|
1021 | previousPageX: touch.pageX,
|
1022 | previousPageY: touch.pageY,
|
1023 | previousTimeStamp: timestampForTouch(touch)
|
1024 | };
|
1025 | }
|
1026 |
|
1027 | function resetTouchRecord(touchRecord, touch) {
|
1028 | touchRecord.touchActive = true;
|
1029 | touchRecord.startPageX = touch.pageX;
|
1030 | touchRecord.startPageY = touch.pageY;
|
1031 | touchRecord.startTimeStamp = timestampForTouch(touch);
|
1032 | touchRecord.currentPageX = touch.pageX;
|
1033 | touchRecord.currentPageY = touch.pageY;
|
1034 | touchRecord.currentTimeStamp = timestampForTouch(touch);
|
1035 | touchRecord.previousPageX = touch.pageX;
|
1036 | touchRecord.previousPageY = touch.pageY;
|
1037 | touchRecord.previousTimeStamp = timestampForTouch(touch);
|
1038 | }
|
1039 |
|
1040 | function getTouchIdentifier(_ref) {
|
1041 | var identifier = _ref.identifier;
|
1042 |
|
1043 | !(identifier != null) ? invariant(false, 'Touch object is missing identifier.') : void 0;
|
1044 | {
|
1045 | !(identifier <= MAX_TOUCH_BANK) ? warningWithoutStack$1(false, 'Touch identifier %s is greater than maximum supported %s which causes ' + 'performance issues backfilling array locations for all of the indices.', identifier, MAX_TOUCH_BANK) : void 0;
|
1046 | }
|
1047 | return identifier;
|
1048 | }
|
1049 |
|
1050 | function recordTouchStart(touch) {
|
1051 | var identifier = getTouchIdentifier(touch);
|
1052 | var touchRecord = touchBank[identifier];
|
1053 | if (touchRecord) {
|
1054 | resetTouchRecord(touchRecord, touch);
|
1055 | } else {
|
1056 | touchBank[identifier] = createTouchRecord(touch);
|
1057 | }
|
1058 | touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
1059 | }
|
1060 |
|
1061 | function recordTouchMove(touch) {
|
1062 | var touchRecord = touchBank[getTouchIdentifier(touch)];
|
1063 | if (touchRecord) {
|
1064 | touchRecord.touchActive = true;
|
1065 | touchRecord.previousPageX = touchRecord.currentPageX;
|
1066 | touchRecord.previousPageY = touchRecord.currentPageY;
|
1067 | touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
1068 | touchRecord.currentPageX = touch.pageX;
|
1069 | touchRecord.currentPageY = touch.pageY;
|
1070 | touchRecord.currentTimeStamp = timestampForTouch(touch);
|
1071 | touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
1072 | } else {
|
1073 | console.error('Cannot record touch move without a touch start.\n' + 'Touch Move: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
1074 | }
|
1075 | }
|
1076 |
|
1077 | function recordTouchEnd(touch) {
|
1078 | var touchRecord = touchBank[getTouchIdentifier(touch)];
|
1079 | if (touchRecord) {
|
1080 | touchRecord.touchActive = false;
|
1081 | touchRecord.previousPageX = touchRecord.currentPageX;
|
1082 | touchRecord.previousPageY = touchRecord.currentPageY;
|
1083 | touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
1084 | touchRecord.currentPageX = touch.pageX;
|
1085 | touchRecord.currentPageY = touch.pageY;
|
1086 | touchRecord.currentTimeStamp = timestampForTouch(touch);
|
1087 | touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
1088 | } else {
|
1089 | console.error('Cannot record touch end without a touch start.\n' + 'Touch End: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
1090 | }
|
1091 | }
|
1092 |
|
1093 | function printTouch(touch) {
|
1094 | return JSON.stringify({
|
1095 | identifier: touch.identifier,
|
1096 | pageX: touch.pageX,
|
1097 | pageY: touch.pageY,
|
1098 | timestamp: timestampForTouch(touch)
|
1099 | });
|
1100 | }
|
1101 |
|
1102 | function printTouchBank() {
|
1103 | var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
1104 | if (touchBank.length > MAX_TOUCH_BANK) {
|
1105 | printed += ' (original size: ' + touchBank.length + ')';
|
1106 | }
|
1107 | return printed;
|
1108 | }
|
1109 |
|
1110 | var ResponderTouchHistoryStore = {
|
1111 | recordTouchTrack: function (topLevelType, nativeEvent) {
|
1112 | if (isMoveish(topLevelType)) {
|
1113 | nativeEvent.changedTouches.forEach(recordTouchMove);
|
1114 | } else if (isStartish(topLevelType)) {
|
1115 | nativeEvent.changedTouches.forEach(recordTouchStart);
|
1116 | touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
1117 | if (touchHistory.numberActiveTouches === 1) {
|
1118 | touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
|
1119 | }
|
1120 | } else if (isEndish(topLevelType)) {
|
1121 | nativeEvent.changedTouches.forEach(recordTouchEnd);
|
1122 | touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
1123 | if (touchHistory.numberActiveTouches === 1) {
|
1124 | for (var i = 0; i < touchBank.length; i++) {
|
1125 | var touchTrackToCheck = touchBank[i];
|
1126 | if (touchTrackToCheck != null && touchTrackToCheck.touchActive) {
|
1127 | touchHistory.indexOfSingleActiveTouch = i;
|
1128 | break;
|
1129 | }
|
1130 | }
|
1131 | {
|
1132 | var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
|
1133 | !(activeRecord != null && activeRecord.touchActive) ? warningWithoutStack$1(false, 'Cannot find single active touch.') : void 0;
|
1134 | }
|
1135 | }
|
1136 | }
|
1137 | },
|
1138 |
|
1139 |
|
1140 | touchHistory: touchHistory
|
1141 | };
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 | function accumulate(current, next) {
|
1151 | !(next != null) ? invariant(false, 'accumulate(...): Accumulated items must be not be null or undefined.') : void 0;
|
1152 |
|
1153 | if (current == null) {
|
1154 | return next;
|
1155 | }
|
1156 |
|
1157 |
|
1158 |
|
1159 | if (Array.isArray(current)) {
|
1160 | return current.concat(next);
|
1161 | }
|
1162 |
|
1163 | if (Array.isArray(next)) {
|
1164 | return [current].concat(next);
|
1165 | }
|
1166 |
|
1167 | return [current, next];
|
1168 | }
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 | var responderInst = null;
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 | var trackedTouchCount = 0;
|
1181 |
|
1182 | var changeResponder = function (nextResponderInst, blockHostResponder) {
|
1183 | var oldResponderInst = responderInst;
|
1184 | responderInst = nextResponderInst;
|
1185 | if (ResponderEventPlugin.GlobalResponderHandler !== null) {
|
1186 | ResponderEventPlugin.GlobalResponderHandler.onChange(oldResponderInst, nextResponderInst, blockHostResponder);
|
1187 | }
|
1188 | };
|
1189 |
|
1190 | var eventTypes = {
|
1191 | |
1192 |
|
1193 |
|
1194 |
|
1195 | startShouldSetResponder: {
|
1196 | phasedRegistrationNames: {
|
1197 | bubbled: 'onStartShouldSetResponder',
|
1198 | captured: 'onStartShouldSetResponderCapture'
|
1199 | },
|
1200 | dependencies: startDependencies
|
1201 | },
|
1202 |
|
1203 | |
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 | scrollShouldSetResponder: {
|
1213 | phasedRegistrationNames: {
|
1214 | bubbled: 'onScrollShouldSetResponder',
|
1215 | captured: 'onScrollShouldSetResponderCapture'
|
1216 | },
|
1217 | dependencies: [TOP_SCROLL]
|
1218 | },
|
1219 |
|
1220 | |
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 | selectionChangeShouldSetResponder: {
|
1228 | phasedRegistrationNames: {
|
1229 | bubbled: 'onSelectionChangeShouldSetResponder',
|
1230 | captured: 'onSelectionChangeShouldSetResponderCapture'
|
1231 | },
|
1232 | dependencies: [TOP_SELECTION_CHANGE]
|
1233 | },
|
1234 |
|
1235 | |
1236 |
|
1237 |
|
1238 |
|
1239 | moveShouldSetResponder: {
|
1240 | phasedRegistrationNames: {
|
1241 | bubbled: 'onMoveShouldSetResponder',
|
1242 | captured: 'onMoveShouldSetResponderCapture'
|
1243 | },
|
1244 | dependencies: moveDependencies
|
1245 | },
|
1246 |
|
1247 | |
1248 |
|
1249 |
|
1250 | responderStart: {
|
1251 | registrationName: 'onResponderStart',
|
1252 | dependencies: startDependencies
|
1253 | },
|
1254 | responderMove: {
|
1255 | registrationName: 'onResponderMove',
|
1256 | dependencies: moveDependencies
|
1257 | },
|
1258 | responderEnd: {
|
1259 | registrationName: 'onResponderEnd',
|
1260 | dependencies: endDependencies
|
1261 | },
|
1262 | responderRelease: {
|
1263 | registrationName: 'onResponderRelease',
|
1264 | dependencies: endDependencies
|
1265 | },
|
1266 | responderTerminationRequest: {
|
1267 | registrationName: 'onResponderTerminationRequest',
|
1268 | dependencies: []
|
1269 | },
|
1270 | responderGrant: {
|
1271 | registrationName: 'onResponderGrant',
|
1272 | dependencies: []
|
1273 | },
|
1274 | responderReject: {
|
1275 | registrationName: 'onResponderReject',
|
1276 | dependencies: []
|
1277 | },
|
1278 | responderTerminate: {
|
1279 | registrationName: 'onResponderTerminate',
|
1280 | dependencies: []
|
1281 | }
|
1282 | };
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 | function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
1475 | var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === TOP_SELECTION_CHANGE ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
|
1476 |
|
1477 |
|
1478 | var bubbleShouldSetFrom = !responderInst ? targetInst : getLowestCommonAncestor(responderInst, targetInst);
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 | var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst;
|
1485 | var shouldSetEvent = ResponderSyntheticEvent.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
|
1486 | shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1487 | if (skipOverBubbleShouldSetFrom) {
|
1488 | accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent);
|
1489 | } else {
|
1490 | accumulateTwoPhaseDispatches(shouldSetEvent);
|
1491 | }
|
1492 | var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
|
1493 | if (!shouldSetEvent.isPersistent()) {
|
1494 | shouldSetEvent.constructor.release(shouldSetEvent);
|
1495 | }
|
1496 |
|
1497 | if (!wantsResponderInst || wantsResponderInst === responderInst) {
|
1498 | return null;
|
1499 | }
|
1500 | var extracted = void 0;
|
1501 | var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
|
1502 | grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1503 |
|
1504 | accumulateDirectDispatches(grantEvent);
|
1505 | var blockHostResponder = executeDirectDispatch(grantEvent) === true;
|
1506 | if (responderInst) {
|
1507 | var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
|
1508 | terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1509 | accumulateDirectDispatches(terminationRequestEvent);
|
1510 | var shouldSwitch = !hasDispatches(terminationRequestEvent) || executeDirectDispatch(terminationRequestEvent);
|
1511 | if (!terminationRequestEvent.isPersistent()) {
|
1512 | terminationRequestEvent.constructor.release(terminationRequestEvent);
|
1513 | }
|
1514 |
|
1515 | if (shouldSwitch) {
|
1516 | var terminateEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget);
|
1517 | terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1518 | accumulateDirectDispatches(terminateEvent);
|
1519 | extracted = accumulate(extracted, [grantEvent, terminateEvent]);
|
1520 | changeResponder(wantsResponderInst, blockHostResponder);
|
1521 | } else {
|
1522 | var rejectEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderReject, wantsResponderInst, nativeEvent, nativeEventTarget);
|
1523 | rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1524 | accumulateDirectDispatches(rejectEvent);
|
1525 | extracted = accumulate(extracted, rejectEvent);
|
1526 | }
|
1527 | } else {
|
1528 | extracted = accumulate(extracted, grantEvent);
|
1529 | changeResponder(wantsResponderInst, blockHostResponder);
|
1530 | }
|
1531 | return extracted;
|
1532 | }
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 | function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
|
1543 | return topLevelInst && (
|
1544 |
|
1545 |
|
1546 |
|
1547 | topLevelType === TOP_SCROLL && !nativeEvent.responderIgnoreScroll || trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE || isStartish(topLevelType) || isMoveish(topLevelType));
|
1548 | }
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 |
|
1557 | function noResponderTouches(nativeEvent) {
|
1558 | var touches = nativeEvent.touches;
|
1559 | if (!touches || touches.length === 0) {
|
1560 | return true;
|
1561 | }
|
1562 | for (var i = 0; i < touches.length; i++) {
|
1563 | var activeTouch = touches[i];
|
1564 | var target = activeTouch.target;
|
1565 | if (target !== null && target !== undefined && target !== 0) {
|
1566 |
|
1567 | var targetInst = getInstanceFromNode$1(target);
|
1568 | if (isAncestor(responderInst, targetInst)) {
|
1569 | return false;
|
1570 | }
|
1571 | }
|
1572 | }
|
1573 | return true;
|
1574 | }
|
1575 |
|
1576 | var ResponderEventPlugin = {
|
1577 |
|
1578 | _getResponder: function () {
|
1579 | return responderInst;
|
1580 | },
|
1581 |
|
1582 | eventTypes: eventTypes,
|
1583 |
|
1584 | |
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 | extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
1590 | if (isStartish(topLevelType)) {
|
1591 | trackedTouchCount += 1;
|
1592 | } else if (isEndish(topLevelType)) {
|
1593 | if (trackedTouchCount >= 0) {
|
1594 | trackedTouchCount -= 1;
|
1595 | } else {
|
1596 | console.error('Ended a touch event which was not counted in `trackedTouchCount`.');
|
1597 | return null;
|
1598 | }
|
1599 | }
|
1600 |
|
1601 | ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
|
1602 |
|
1603 | var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null;
|
1604 |
|
1605 |
|
1606 |
|
1607 |
|
1608 |
|
1609 |
|
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 | var isResponderTouchStart = responderInst && isStartish(topLevelType);
|
1615 | var isResponderTouchMove = responderInst && isMoveish(topLevelType);
|
1616 | var isResponderTouchEnd = responderInst && isEndish(topLevelType);
|
1617 | var incrementalTouch = isResponderTouchStart ? eventTypes.responderStart : isResponderTouchMove ? eventTypes.responderMove : isResponderTouchEnd ? eventTypes.responderEnd : null;
|
1618 |
|
1619 | if (incrementalTouch) {
|
1620 | var gesture = ResponderSyntheticEvent.getPooled(incrementalTouch, responderInst, nativeEvent, nativeEventTarget);
|
1621 | gesture.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1622 | accumulateDirectDispatches(gesture);
|
1623 | extracted = accumulate(extracted, gesture);
|
1624 | }
|
1625 |
|
1626 | var isResponderTerminate = responderInst && topLevelType === TOP_TOUCH_CANCEL;
|
1627 | var isResponderRelease = responderInst && !isResponderTerminate && isEndish(topLevelType) && noResponderTouches(nativeEvent);
|
1628 | var finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
|
1629 | if (finalTouch) {
|
1630 | var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
|
1631 | finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1632 | accumulateDirectDispatches(finalEvent);
|
1633 | extracted = accumulate(extracted, finalEvent);
|
1634 | changeResponder(null);
|
1635 | }
|
1636 |
|
1637 | return extracted;
|
1638 | },
|
1639 |
|
1640 | GlobalResponderHandler: null,
|
1641 |
|
1642 | injection: {
|
1643 | |
1644 |
|
1645 |
|
1646 |
|
1647 |
|
1648 | injectGlobalResponderHandler: function (GlobalResponderHandler) {
|
1649 | ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler;
|
1650 | }
|
1651 | }
|
1652 | };
|
1653 |
|
1654 |
|
1655 |
|
1656 | var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
|
1657 | var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
|
1658 | var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
|
1659 | var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
|
1660 | var injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
|
1661 |
|
1662 |
|
1663 | setComponentTree(getFiberCurrentPropsFromNode, getInstanceFromNode, getNodeFromInstance);
|
1664 |
|
1665 |
|
1666 |
|
1667 | var ReactDOMUnstableNativeDependencies = Object.freeze({
|
1668 | ResponderEventPlugin: ResponderEventPlugin,
|
1669 | ResponderTouchHistoryStore: ResponderTouchHistoryStore,
|
1670 | injectEventPluginsByName: injectEventPluginsByName
|
1671 | });
|
1672 |
|
1673 | var unstableNativeDependencies = ReactDOMUnstableNativeDependencies;
|
1674 |
|
1675 | return unstableNativeDependencies;
|
1676 |
|
1677 | })));
|