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