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