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