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 |
|
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 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
55 | var fakeNode = document.createElement('react');
|
56 |
|
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 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | var warningWithoutStack = function () {};
|
100 |
|
101 | {
|
102 | warningWithoutStack = function (condition, format) {
|
103 | for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
104 | args[_key - 2] = arguments[_key];
|
105 | }
|
106 |
|
107 | if (format === undefined) {
|
108 | throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
109 | }
|
110 |
|
111 | if (args.length > 8) {
|
112 |
|
113 | throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
114 | }
|
115 |
|
116 | if (condition) {
|
117 | return;
|
118 | }
|
119 |
|
120 | if (typeof console !== 'undefined') {
|
121 | var argsWithFormat = args.map(function (item) {
|
122 | return '' + item;
|
123 | });
|
124 | argsWithFormat.unshift('Warning: ' + format);
|
125 |
|
126 |
|
127 | Function.prototype.apply.call(console.error, console, argsWithFormat);
|
128 | }
|
129 |
|
130 | try {
|
131 |
|
132 |
|
133 |
|
134 | var argIndex = 0;
|
135 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
136 | return args[argIndex++];
|
137 | });
|
138 | throw new Error(message);
|
139 | } catch (x) {}
|
140 | };
|
141 | }
|
142 |
|
143 | var warningWithoutStack$1 = warningWithoutStack;
|
144 |
|
145 | var getFiberCurrentPropsFromNode$1 = null;
|
146 | var getInstanceFromNode$1 = null;
|
147 | var getNodeFromInstance$1 = null;
|
148 | function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
|
149 | getFiberCurrentPropsFromNode$1 = getFiberCurrentPropsFromNodeImpl;
|
150 | getInstanceFromNode$1 = getInstanceFromNodeImpl;
|
151 | getNodeFromInstance$1 = getNodeFromInstanceImpl;
|
152 |
|
153 | {
|
154 | !(getNodeFromInstance$1 && getInstanceFromNode$1) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
|
155 | }
|
156 | }
|
157 | var validateEventDispatches;
|
158 |
|
159 | {
|
160 | validateEventDispatches = function (event) {
|
161 | var dispatchListeners = event._dispatchListeners;
|
162 | var dispatchInstances = event._dispatchInstances;
|
163 | var listenersIsArr = Array.isArray(dispatchListeners);
|
164 | var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
|
165 | var instancesIsArr = Array.isArray(dispatchInstances);
|
166 | var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
|
167 | !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
|
168 | };
|
169 | }
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 | function executeDispatchesInOrderStopAtTrueImpl(event) {
|
193 | var dispatchListeners = event._dispatchListeners;
|
194 | var dispatchInstances = event._dispatchInstances;
|
195 |
|
196 | {
|
197 | validateEventDispatches(event);
|
198 | }
|
199 |
|
200 | if (Array.isArray(dispatchListeners)) {
|
201 | for (var i = 0; i < dispatchListeners.length; i++) {
|
202 | if (event.isPropagationStopped()) {
|
203 | break;
|
204 | }
|
205 |
|
206 |
|
207 | if (dispatchListeners[i](event, dispatchInstances[i])) {
|
208 | return dispatchInstances[i];
|
209 | }
|
210 | }
|
211 | } else if (dispatchListeners) {
|
212 | if (dispatchListeners(event, dispatchInstances)) {
|
213 | return dispatchInstances;
|
214 | }
|
215 | }
|
216 |
|
217 | return null;
|
218 | }
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 | function executeDispatchesInOrderStopAtTrue(event) {
|
225 | var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
226 | event._dispatchInstances = null;
|
227 | event._dispatchListeners = null;
|
228 | return ret;
|
229 | }
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | function executeDirectDispatch(event) {
|
241 | {
|
242 | validateEventDispatches(event);
|
243 | }
|
244 |
|
245 | var dispatchListener = event._dispatchListeners;
|
246 | var dispatchInstance = event._dispatchInstances;
|
247 |
|
248 | if (!!Array.isArray(dispatchListener)) {
|
249 | {
|
250 | throw Error("executeDirectDispatch(...): Invalid `event`.");
|
251 | }
|
252 | }
|
253 |
|
254 | event.currentTarget = dispatchListener ? getNodeFromInstance$1(dispatchInstance) : null;
|
255 | var res = dispatchListener ? dispatchListener(event) : null;
|
256 | event.currentTarget = null;
|
257 | event._dispatchListeners = null;
|
258 | event._dispatchInstances = null;
|
259 | return res;
|
260 | }
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 | function hasDispatches(event) {
|
267 | return !!event._dispatchListeners;
|
268 | }
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 | var HostComponent = 5;
|
277 |
|
278 | function getParent(inst) {
|
279 | do {
|
280 | inst = inst.return;
|
281 |
|
282 |
|
283 |
|
284 |
|
285 | } while (inst && inst.tag !== HostComponent);
|
286 |
|
287 | if (inst) {
|
288 | return inst;
|
289 | }
|
290 |
|
291 | return null;
|
292 | }
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 | function getLowestCommonAncestor(instA, instB) {
|
300 | var depthA = 0;
|
301 |
|
302 | for (var tempA = instA; tempA; tempA = getParent(tempA)) {
|
303 | depthA++;
|
304 | }
|
305 |
|
306 | var depthB = 0;
|
307 |
|
308 | for (var tempB = instB; tempB; tempB = getParent(tempB)) {
|
309 | depthB++;
|
310 | }
|
311 |
|
312 |
|
313 | while (depthA - depthB > 0) {
|
314 | instA = getParent(instA);
|
315 | depthA--;
|
316 | }
|
317 |
|
318 |
|
319 | while (depthB - depthA > 0) {
|
320 | instB = getParent(instB);
|
321 | depthB--;
|
322 | }
|
323 |
|
324 |
|
325 | var depth = depthA;
|
326 |
|
327 | while (depth--) {
|
328 | if (instA === instB || instA === instB.alternate) {
|
329 | return instA;
|
330 | }
|
331 |
|
332 | instA = getParent(instA);
|
333 | instB = getParent(instB);
|
334 | }
|
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 |
|
348 | instB = getParent(instB);
|
349 | }
|
350 |
|
351 | return false;
|
352 | }
|
353 |
|
354 |
|
355 |
|
356 |
|
357 | function getParentInstance(inst) {
|
358 | return getParent(inst);
|
359 | }
|
360 |
|
361 |
|
362 |
|
363 |
|
364 | function traverseTwoPhase(inst, fn, arg) {
|
365 | var path = [];
|
366 |
|
367 | while (inst) {
|
368 | path.push(inst);
|
369 | inst = getParent(inst);
|
370 | }
|
371 |
|
372 | var i;
|
373 |
|
374 | for (i = path.length; i-- > 0;) {
|
375 | fn(path[i], 'captured', arg);
|
376 | }
|
377 |
|
378 | for (i = 0; i < path.length; i++) {
|
379 | fn(path[i], 'bubbled', arg);
|
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 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 | function accumulateInto(current, next) {
|
462 | if (!(next != null)) {
|
463 | {
|
464 | throw Error("accumulateInto(...): Accumulated items must not be null or undefined.");
|
465 | }
|
466 | }
|
467 |
|
468 | if (current == null) {
|
469 | return next;
|
470 | }
|
471 |
|
472 |
|
473 |
|
474 | if (Array.isArray(current)) {
|
475 | if (Array.isArray(next)) {
|
476 | current.push.apply(current, next);
|
477 | return current;
|
478 | }
|
479 |
|
480 | current.push(next);
|
481 | return current;
|
482 | }
|
483 |
|
484 | if (Array.isArray(next)) {
|
485 |
|
486 | return [current].concat(next);
|
487 | }
|
488 |
|
489 | return [current, next];
|
490 | }
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 | function forEachAccumulated(arr, cb, scope) {
|
502 | if (Array.isArray(arr)) {
|
503 | arr.forEach(cb, scope);
|
504 | } else if (arr) {
|
505 | cb.call(scope, arr);
|
506 | }
|
507 | }
|
508 |
|
509 | function isInteractive(tag) {
|
510 | return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
|
511 | }
|
512 |
|
513 | function shouldPreventMouseEvent(name, type, props) {
|
514 | switch (name) {
|
515 | case 'onClick':
|
516 | case 'onClickCapture':
|
517 | case 'onDoubleClick':
|
518 | case 'onDoubleClickCapture':
|
519 | case 'onMouseDown':
|
520 | case 'onMouseDownCapture':
|
521 | case 'onMouseMove':
|
522 | case 'onMouseMoveCapture':
|
523 | case 'onMouseUp':
|
524 | case 'onMouseUpCapture':
|
525 | return !!(props.disabled && isInteractive(type));
|
526 |
|
527 | default:
|
528 | return false;
|
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 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 | function getListener(inst, registrationName) {
|
567 | var listener;
|
568 |
|
569 |
|
570 | var stateNode = inst.stateNode;
|
571 |
|
572 | if (!stateNode) {
|
573 |
|
574 | return null;
|
575 | }
|
576 |
|
577 | var props = getFiberCurrentPropsFromNode$1(stateNode);
|
578 |
|
579 | if (!props) {
|
580 |
|
581 | return null;
|
582 | }
|
583 |
|
584 | listener = props[registrationName];
|
585 |
|
586 | if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
|
587 | return null;
|
588 | }
|
589 |
|
590 | if (!(!listener || typeof listener === 'function')) {
|
591 | {
|
592 | throw Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type.");
|
593 | }
|
594 | }
|
595 |
|
596 | return listener;
|
597 | }
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 | function listenerAtPhase(inst, event, propagationPhase) {
|
604 | var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
605 | return getListener(inst, registrationName);
|
606 | }
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 | function accumulateDirectionalDispatches(inst, phase, event) {
|
626 | {
|
627 | !inst ? warningWithoutStack$1(false, 'Dispatching inst must not be null') : void 0;
|
628 | }
|
629 |
|
630 | var listener = listenerAtPhase(inst, event, phase);
|
631 |
|
632 | if (listener) {
|
633 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
634 | event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
635 | }
|
636 | }
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 | function accumulateTwoPhaseDispatchesSingle(event) {
|
647 | if (event && event.dispatchConfig.phasedRegistrationNames) {
|
648 | traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
|
649 | }
|
650 | }
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 | function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
657 | if (event && event.dispatchConfig.phasedRegistrationNames) {
|
658 | var targetInst = event._targetInst;
|
659 | var parentInst = targetInst ? getParentInstance(targetInst) : null;
|
660 | traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
|
661 | }
|
662 | }
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 | function accumulateDispatches(inst, ignoredDirection, event) {
|
671 | if (inst && event && event.dispatchConfig.registrationName) {
|
672 | var registrationName = event.dispatchConfig.registrationName;
|
673 | var listener = getListener(inst, registrationName);
|
674 |
|
675 | if (listener) {
|
676 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
677 | event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
678 | }
|
679 | }
|
680 | }
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 | function accumulateDirectDispatchesSingle(event) {
|
689 | if (event && event.dispatchConfig.registrationName) {
|
690 | accumulateDispatches(event._targetInst, null, event);
|
691 | }
|
692 | }
|
693 |
|
694 | function accumulateTwoPhaseDispatches(events) {
|
695 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
696 | }
|
697 | function accumulateTwoPhaseDispatchesSkipTarget(events) {
|
698 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
|
699 | }
|
700 |
|
701 | function accumulateDirectDispatches(events) {
|
702 | forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
703 | }
|
704 |
|
705 | var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
706 | var _assign = ReactInternals.assign;
|
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 | return unstableNativeDependencies;
|
1743 |
|
1744 | })));
|