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