UNPKG

241 kBJavaScriptView Raw
1import React, { useLayoutEffect, useEffect, useRef, useState, useContext } from 'react';
2import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
3import _extends from '@babel/runtime/helpers/esm/extends';
4import { createStore as createStore$1, applyMiddleware, compose, bindActionCreators } from 'redux';
5import { Provider, connect } from 'react-redux';
6import { useMemo, useCallback } from 'use-memo-one';
7import { getRect, expand, offset, withScroll, getBox, createBox, calculateBox } from 'css-box-model';
8import memoizeOne from 'memoize-one';
9import rafSchd from 'raf-schd';
10import ReactDOM from 'react-dom';
11
12var isProduction = process.env.NODE_ENV === 'production';
13var spacesAndTabs = /[ \t]{2,}/g;
14var lineStartWithSpaces = /^[ \t]*/gm;
15
16var clean = function clean(value) {
17 return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
18};
19
20var getDevMessage = function getDevMessage(message) {
21 return clean("\n %creact-beautiful-dnd\n\n %c" + clean(message) + "\n\n %c\uD83D\uDC77\u200D This is a development only message. It will be removed in production builds.\n");
22};
23
24var getFormattedMessage = function getFormattedMessage(message) {
25 return [getDevMessage(message), 'color: #00C584; font-size: 1.2em; font-weight: bold;', 'line-height: 1.5', 'color: #723874;'];
26};
27var isDisabledFlag = '__react-beautiful-dnd-disable-dev-warnings';
28function log(type, message) {
29 var _console;
30
31 if (isProduction) {
32 return;
33 }
34
35 if (typeof window !== 'undefined' && window[isDisabledFlag]) {
36 return;
37 }
38
39 (_console = console)[type].apply(_console, getFormattedMessage(message));
40}
41var warning = log.bind(null, 'warn');
42var error = log.bind(null, 'error');
43
44function noop() {}
45
46function getOptions(shared, fromBinding) {
47 return _extends({}, shared, {}, fromBinding);
48}
49
50function bindEvents(el, bindings, sharedOptions) {
51 var unbindings = bindings.map(function (binding) {
52 var options = getOptions(sharedOptions, binding.options);
53 el.addEventListener(binding.eventName, binding.fn, options);
54 return function unbind() {
55 el.removeEventListener(binding.eventName, binding.fn, options);
56 };
57 });
58 return function unbindAll() {
59 unbindings.forEach(function (unbind) {
60 unbind();
61 });
62 };
63}
64
65var isProduction$1 = process.env.NODE_ENV === 'production';
66var prefix = 'Invariant failed';
67function RbdInvariant(message) {
68 this.message = message;
69}
70
71RbdInvariant.prototype.toString = function toString() {
72 return this.message;
73};
74
75function invariant(condition, message) {
76 if (condition) {
77 return;
78 }
79
80 if (isProduction$1) {
81 throw new RbdInvariant(prefix);
82 } else {
83 throw new RbdInvariant(prefix + ": " + (message || ''));
84 }
85}
86
87var ErrorBoundary = function (_React$Component) {
88 _inheritsLoose(ErrorBoundary, _React$Component);
89
90 function ErrorBoundary() {
91 var _this;
92
93 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
94 args[_key] = arguments[_key];
95 }
96
97 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
98 _this.callbacks = null;
99 _this.unbind = noop;
100
101 _this.onWindowError = function (event) {
102 var callbacks = _this.getCallbacks();
103
104 if (callbacks.isDragging()) {
105 callbacks.tryAbort();
106 process.env.NODE_ENV !== "production" ? warning("\n An error was caught by our window 'error' event listener while a drag was occurring.\n The active drag has been aborted.\n ") : void 0;
107 }
108
109 var err = event.error;
110
111 if (err instanceof RbdInvariant) {
112 event.preventDefault();
113
114 if (process.env.NODE_ENV !== 'production') {
115 error(err.message);
116 }
117 }
118 };
119
120 _this.getCallbacks = function () {
121 if (!_this.callbacks) {
122 throw new Error('Unable to find AppCallbacks in <ErrorBoundary/>');
123 }
124
125 return _this.callbacks;
126 };
127
128 _this.setCallbacks = function (callbacks) {
129 _this.callbacks = callbacks;
130 };
131
132 return _this;
133 }
134
135 var _proto = ErrorBoundary.prototype;
136
137 _proto.componentDidMount = function componentDidMount() {
138 this.unbind = bindEvents(window, [{
139 eventName: 'error',
140 fn: this.onWindowError
141 }]);
142 };
143
144 _proto.componentDidCatch = function componentDidCatch(err) {
145 if (err instanceof RbdInvariant) {
146 if (process.env.NODE_ENV !== 'production') {
147 error(err.message);
148 }
149
150 this.setState({});
151 return;
152 }
153
154 throw err;
155 };
156
157 _proto.componentWillUnmount = function componentWillUnmount() {
158 this.unbind();
159 };
160
161 _proto.render = function render() {
162 return this.props.children(this.setCallbacks);
163 };
164
165 return ErrorBoundary;
166}(React.Component);
167
168var dragHandleUsageInstructions = "\n Press space bar to start a drag.\n When dragging you can use the arrow keys to move the item around and escape to cancel.\n Some screen readers may require you to be in focus mode or to use your pass through key\n";
169
170var position = function position(index) {
171 return index + 1;
172};
173
174var onDragStart = function onDragStart(start) {
175 return "\n You have lifted an item in position " + position(start.source.index) + "\n";
176};
177
178var withLocation = function withLocation(source, destination) {
179 var isInHomeList = source.droppableId === destination.droppableId;
180 var startPosition = position(source.index);
181 var endPosition = position(destination.index);
182
183 if (isInHomeList) {
184 return "\n You have moved the item from position " + startPosition + "\n to position " + endPosition + "\n ";
185 }
186
187 return "\n You have moved the item from position " + startPosition + "\n in list " + source.droppableId + "\n to list " + destination.droppableId + "\n in position " + endPosition + "\n ";
188};
189
190var withCombine = function withCombine(id, source, combine) {
191 var inHomeList = source.droppableId === combine.droppableId;
192
193 if (inHomeList) {
194 return "\n The item " + id + "\n has been combined with " + combine.draggableId;
195 }
196
197 return "\n The item " + id + "\n in list " + source.droppableId + "\n has been combined with " + combine.draggableId + "\n in list " + combine.droppableId + "\n ";
198};
199
200var onDragUpdate = function onDragUpdate(update) {
201 var location = update.destination;
202
203 if (location) {
204 return withLocation(update.source, location);
205 }
206
207 var combine = update.combine;
208
209 if (combine) {
210 return withCombine(update.draggableId, update.source, combine);
211 }
212
213 return 'You are over an area that cannot be dropped on';
214};
215
216var returnedToStart = function returnedToStart(source) {
217 return "\n The item has returned to its starting position\n of " + position(source.index) + "\n";
218};
219
220var onDragEnd = function onDragEnd(result) {
221 if (result.reason === 'CANCEL') {
222 return "\n Movement cancelled.\n " + returnedToStart(result.source) + "\n ";
223 }
224
225 var location = result.destination;
226 var combine = result.combine;
227
228 if (location) {
229 return "\n You have dropped the item.\n " + withLocation(result.source, location) + "\n ";
230 }
231
232 if (combine) {
233 return "\n You have dropped the item.\n " + withCombine(result.draggableId, result.source, combine) + "\n ";
234 }
235
236 return "\n The item has been dropped while not over a drop area.\n " + returnedToStart(result.source) + "\n ";
237};
238
239var preset = {
240 dragHandleUsageInstructions: dragHandleUsageInstructions,
241 onDragStart: onDragStart,
242 onDragUpdate: onDragUpdate,
243 onDragEnd: onDragEnd
244};
245
246var origin = {
247 x: 0,
248 y: 0
249};
250var add = function add(point1, point2) {
251 return {
252 x: point1.x + point2.x,
253 y: point1.y + point2.y
254 };
255};
256var subtract = function subtract(point1, point2) {
257 return {
258 x: point1.x - point2.x,
259 y: point1.y - point2.y
260 };
261};
262var isEqual = function isEqual(point1, point2) {
263 return point1.x === point2.x && point1.y === point2.y;
264};
265var negate = function negate(point) {
266 return {
267 x: point.x !== 0 ? -point.x : 0,
268 y: point.y !== 0 ? -point.y : 0
269 };
270};
271var patch = function patch(line, value, otherValue) {
272 var _ref;
273
274 if (otherValue === void 0) {
275 otherValue = 0;
276 }
277
278 return _ref = {}, _ref[line] = value, _ref[line === 'x' ? 'y' : 'x'] = otherValue, _ref;
279};
280var distance = function distance(point1, point2) {
281 return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
282};
283var closest = function closest(target, points) {
284 return Math.min.apply(Math, points.map(function (point) {
285 return distance(target, point);
286 }));
287};
288var apply = function apply(fn) {
289 return function (point) {
290 return {
291 x: fn(point.x),
292 y: fn(point.y)
293 };
294 };
295};
296
297var executeClip = (function (frame, subject) {
298 var result = getRect({
299 top: Math.max(subject.top, frame.top),
300 right: Math.min(subject.right, frame.right),
301 bottom: Math.min(subject.bottom, frame.bottom),
302 left: Math.max(subject.left, frame.left)
303 });
304
305 if (result.width <= 0 || result.height <= 0) {
306 return null;
307 }
308
309 return result;
310});
311
312var offsetByPosition = function offsetByPosition(spacing, point) {
313 return {
314 top: spacing.top + point.y,
315 left: spacing.left + point.x,
316 bottom: spacing.bottom + point.y,
317 right: spacing.right + point.x
318 };
319};
320var getCorners = function getCorners(spacing) {
321 return [{
322 x: spacing.left,
323 y: spacing.top
324 }, {
325 x: spacing.right,
326 y: spacing.top
327 }, {
328 x: spacing.left,
329 y: spacing.bottom
330 }, {
331 x: spacing.right,
332 y: spacing.bottom
333 }];
334};
335var noSpacing = {
336 top: 0,
337 right: 0,
338 bottom: 0,
339 left: 0
340};
341
342var scroll = function scroll(target, frame) {
343 if (!frame) {
344 return target;
345 }
346
347 return offsetByPosition(target, frame.scroll.diff.displacement);
348};
349
350var increase = function increase(target, axis, withPlaceholder) {
351 if (withPlaceholder && withPlaceholder.increasedBy) {
352 var _extends2;
353
354 return _extends({}, target, (_extends2 = {}, _extends2[axis.end] = target[axis.end] + withPlaceholder.increasedBy[axis.line], _extends2));
355 }
356
357 return target;
358};
359
360var clip = function clip(target, frame) {
361 if (frame && frame.shouldClipSubject) {
362 return executeClip(frame.pageMarginBox, target);
363 }
364
365 return getRect(target);
366};
367
368var getSubject = (function (_ref) {
369 var page = _ref.page,
370 withPlaceholder = _ref.withPlaceholder,
371 axis = _ref.axis,
372 frame = _ref.frame;
373 var scrolled = scroll(page.marginBox, frame);
374 var increased = increase(scrolled, axis, withPlaceholder);
375 var clipped = clip(increased, frame);
376 return {
377 page: page,
378 withPlaceholder: withPlaceholder,
379 active: clipped
380 };
381});
382
383var scrollDroppable = (function (droppable, newScroll) {
384 !droppable.frame ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
385 var scrollable = droppable.frame;
386 var scrollDiff = subtract(newScroll, scrollable.scroll.initial);
387 var scrollDisplacement = negate(scrollDiff);
388
389 var frame = _extends({}, scrollable, {
390 scroll: {
391 initial: scrollable.scroll.initial,
392 current: newScroll,
393 diff: {
394 value: scrollDiff,
395 displacement: scrollDisplacement
396 },
397 max: scrollable.scroll.max
398 }
399 });
400
401 var subject = getSubject({
402 page: droppable.subject.page,
403 withPlaceholder: droppable.subject.withPlaceholder,
404 axis: droppable.axis,
405 frame: frame
406 });
407
408 var result = _extends({}, droppable, {
409 frame: frame,
410 subject: subject
411 });
412
413 return result;
414});
415
416function isInteger(value) {
417 if (Number.isInteger) {
418 return Number.isInteger(value);
419 }
420
421 return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
422}
423function values(map) {
424 if (Object.values) {
425 return Object.values(map);
426 }
427
428 return Object.keys(map).map(function (key) {
429 return map[key];
430 });
431}
432function findIndex(list, predicate) {
433 if (list.findIndex) {
434 return list.findIndex(predicate);
435 }
436
437 for (var i = 0; i < list.length; i++) {
438 if (predicate(list[i])) {
439 return i;
440 }
441 }
442
443 return -1;
444}
445function find(list, predicate) {
446 if (list.find) {
447 return list.find(predicate);
448 }
449
450 var index = findIndex(list, predicate);
451
452 if (index !== -1) {
453 return list[index];
454 }
455
456 return undefined;
457}
458function toArray(list) {
459 return Array.prototype.slice.call(list);
460}
461
462var toDroppableMap = memoizeOne(function (droppables) {
463 return droppables.reduce(function (previous, current) {
464 previous[current.descriptor.id] = current;
465 return previous;
466 }, {});
467});
468var toDraggableMap = memoizeOne(function (draggables) {
469 return draggables.reduce(function (previous, current) {
470 previous[current.descriptor.id] = current;
471 return previous;
472 }, {});
473});
474var toDroppableList = memoizeOne(function (droppables) {
475 return values(droppables);
476});
477var toDraggableList = memoizeOne(function (draggables) {
478 return values(draggables);
479});
480
481var getDraggablesInsideDroppable = memoizeOne(function (droppableId, draggables) {
482 var result = toDraggableList(draggables).filter(function (draggable) {
483 return droppableId === draggable.descriptor.droppableId;
484 }).sort(function (a, b) {
485 return a.descriptor.index - b.descriptor.index;
486 });
487 return result;
488});
489
490function tryGetDestination(impact) {
491 if (impact.at && impact.at.type === 'REORDER') {
492 return impact.at.destination;
493 }
494
495 return null;
496}
497function tryGetCombine(impact) {
498 if (impact.at && impact.at.type === 'COMBINE') {
499 return impact.at.combine;
500 }
501
502 return null;
503}
504
505var removeDraggableFromList = memoizeOne(function (remove, list) {
506 return list.filter(function (item) {
507 return item.descriptor.id !== remove.descriptor.id;
508 });
509});
510
511var moveToNextCombine = (function (_ref) {
512 var isMovingForward = _ref.isMovingForward,
513 draggable = _ref.draggable,
514 destination = _ref.destination,
515 insideDestination = _ref.insideDestination,
516 previousImpact = _ref.previousImpact;
517
518 if (!destination.isCombineEnabled) {
519 return null;
520 }
521
522 var location = tryGetDestination(previousImpact);
523
524 if (!location) {
525 return null;
526 }
527
528 function getImpact(target) {
529 var at = {
530 type: 'COMBINE',
531 combine: {
532 draggableId: target,
533 droppableId: destination.descriptor.id
534 }
535 };
536 return _extends({}, previousImpact, {
537 at: at
538 });
539 }
540
541 var all = previousImpact.displaced.all;
542 var closestId = all.length ? all[0] : null;
543
544 if (isMovingForward) {
545 return closestId ? getImpact(closestId) : null;
546 }
547
548 var withoutDraggable = removeDraggableFromList(draggable, insideDestination);
549
550 if (!closestId) {
551 if (!withoutDraggable.length) {
552 return null;
553 }
554
555 var last = withoutDraggable[withoutDraggable.length - 1];
556 return getImpact(last.descriptor.id);
557 }
558
559 var indexOfClosest = findIndex(withoutDraggable, function (d) {
560 return d.descriptor.id === closestId;
561 });
562 !(indexOfClosest !== -1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find displaced item in set') : invariant(false) : void 0;
563 var proposedIndex = indexOfClosest - 1;
564
565 if (proposedIndex < 0) {
566 return null;
567 }
568
569 var before = withoutDraggable[proposedIndex];
570 return getImpact(before.descriptor.id);
571});
572
573var isHomeOf = (function (draggable, destination) {
574 return draggable.descriptor.droppableId === destination.descriptor.id;
575});
576
577var noDisplacedBy = {
578 point: origin,
579 value: 0
580};
581var emptyGroups = {
582 invisible: {},
583 visible: {},
584 all: []
585};
586var noImpact = {
587 displaced: emptyGroups,
588 displacedBy: noDisplacedBy,
589 at: null
590};
591
592var isWithin = (function (lowerBound, upperBound) {
593 return function (value) {
594 return lowerBound <= value && value <= upperBound;
595 };
596});
597
598var isPartiallyVisibleThroughFrame = (function (frame) {
599 var isWithinVertical = isWithin(frame.top, frame.bottom);
600 var isWithinHorizontal = isWithin(frame.left, frame.right);
601 return function (subject) {
602 var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
603
604 if (isContained) {
605 return true;
606 }
607
608 var isPartiallyVisibleVertically = isWithinVertical(subject.top) || isWithinVertical(subject.bottom);
609 var isPartiallyVisibleHorizontally = isWithinHorizontal(subject.left) || isWithinHorizontal(subject.right);
610 var isPartiallyContained = isPartiallyVisibleVertically && isPartiallyVisibleHorizontally;
611
612 if (isPartiallyContained) {
613 return true;
614 }
615
616 var isBiggerVertically = subject.top < frame.top && subject.bottom > frame.bottom;
617 var isBiggerHorizontally = subject.left < frame.left && subject.right > frame.right;
618 var isTargetBiggerThanFrame = isBiggerVertically && isBiggerHorizontally;
619
620 if (isTargetBiggerThanFrame) {
621 return true;
622 }
623
624 var isTargetBiggerOnOneAxis = isBiggerVertically && isPartiallyVisibleHorizontally || isBiggerHorizontally && isPartiallyVisibleVertically;
625 return isTargetBiggerOnOneAxis;
626 };
627});
628
629var isTotallyVisibleThroughFrame = (function (frame) {
630 var isWithinVertical = isWithin(frame.top, frame.bottom);
631 var isWithinHorizontal = isWithin(frame.left, frame.right);
632 return function (subject) {
633 var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
634 return isContained;
635 };
636});
637
638var vertical = {
639 direction: 'vertical',
640 line: 'y',
641 crossAxisLine: 'x',
642 start: 'top',
643 end: 'bottom',
644 size: 'height',
645 crossAxisStart: 'left',
646 crossAxisEnd: 'right',
647 crossAxisSize: 'width'
648};
649var horizontal = {
650 direction: 'horizontal',
651 line: 'x',
652 crossAxisLine: 'y',
653 start: 'left',
654 end: 'right',
655 size: 'width',
656 crossAxisStart: 'top',
657 crossAxisEnd: 'bottom',
658 crossAxisSize: 'height'
659};
660
661var isTotallyVisibleThroughFrameOnAxis = (function (axis) {
662 return function (frame) {
663 var isWithinVertical = isWithin(frame.top, frame.bottom);
664 var isWithinHorizontal = isWithin(frame.left, frame.right);
665 return function (subject) {
666 if (axis === vertical) {
667 return isWithinVertical(subject.top) && isWithinVertical(subject.bottom);
668 }
669
670 return isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
671 };
672 };
673});
674
675var getDroppableDisplaced = function getDroppableDisplaced(target, destination) {
676 var displacement = destination.frame ? destination.frame.scroll.diff.displacement : origin;
677 return offsetByPosition(target, displacement);
678};
679
680var isVisibleInDroppable = function isVisibleInDroppable(target, destination, isVisibleThroughFrameFn) {
681 if (!destination.subject.active) {
682 return false;
683 }
684
685 return isVisibleThroughFrameFn(destination.subject.active)(target);
686};
687
688var isVisibleInViewport = function isVisibleInViewport(target, viewport, isVisibleThroughFrameFn) {
689 return isVisibleThroughFrameFn(viewport)(target);
690};
691
692var isVisible = function isVisible(_ref) {
693 var toBeDisplaced = _ref.target,
694 destination = _ref.destination,
695 viewport = _ref.viewport,
696 withDroppableDisplacement = _ref.withDroppableDisplacement,
697 isVisibleThroughFrameFn = _ref.isVisibleThroughFrameFn;
698 var displacedTarget = withDroppableDisplacement ? getDroppableDisplaced(toBeDisplaced, destination) : toBeDisplaced;
699 return isVisibleInDroppable(displacedTarget, destination, isVisibleThroughFrameFn) && isVisibleInViewport(displacedTarget, viewport, isVisibleThroughFrameFn);
700};
701
702var isPartiallyVisible = function isPartiallyVisible(args) {
703 return isVisible(_extends({}, args, {
704 isVisibleThroughFrameFn: isPartiallyVisibleThroughFrame
705 }));
706};
707var isTotallyVisible = function isTotallyVisible(args) {
708 return isVisible(_extends({}, args, {
709 isVisibleThroughFrameFn: isTotallyVisibleThroughFrame
710 }));
711};
712var isTotallyVisibleOnAxis = function isTotallyVisibleOnAxis(args) {
713 return isVisible(_extends({}, args, {
714 isVisibleThroughFrameFn: isTotallyVisibleThroughFrameOnAxis(args.destination.axis)
715 }));
716};
717
718var getShouldAnimate = function getShouldAnimate(id, last, forceShouldAnimate) {
719 if (typeof forceShouldAnimate === 'boolean') {
720 return forceShouldAnimate;
721 }
722
723 if (!last) {
724 return true;
725 }
726
727 var invisible = last.invisible,
728 visible = last.visible;
729
730 if (invisible[id]) {
731 return false;
732 }
733
734 var previous = visible[id];
735 return previous ? previous.shouldAnimate : true;
736};
737
738function getTarget(draggable, displacedBy) {
739 var marginBox = draggable.page.marginBox;
740 var expandBy = {
741 top: displacedBy.point.y,
742 right: 0,
743 bottom: 0,
744 left: displacedBy.point.x
745 };
746 return getRect(expand(marginBox, expandBy));
747}
748
749function getDisplacementGroups(_ref) {
750 var afterDragging = _ref.afterDragging,
751 destination = _ref.destination,
752 displacedBy = _ref.displacedBy,
753 viewport = _ref.viewport,
754 forceShouldAnimate = _ref.forceShouldAnimate,
755 last = _ref.last;
756 return afterDragging.reduce(function process(groups, draggable) {
757 var target = getTarget(draggable, displacedBy);
758 var id = draggable.descriptor.id;
759 groups.all.push(id);
760 var isVisible = isPartiallyVisible({
761 target: target,
762 destination: destination,
763 viewport: viewport,
764 withDroppableDisplacement: true
765 });
766
767 if (!isVisible) {
768 groups.invisible[draggable.descriptor.id] = true;
769 return groups;
770 }
771
772 var shouldAnimate = getShouldAnimate(id, last, forceShouldAnimate);
773 var displacement = {
774 draggableId: id,
775 shouldAnimate: shouldAnimate
776 };
777 groups.visible[id] = displacement;
778 return groups;
779 }, {
780 all: [],
781 visible: {},
782 invisible: {}
783 });
784}
785
786function getIndexOfLastItem(draggables, options) {
787 if (!draggables.length) {
788 return 0;
789 }
790
791 var indexOfLastItem = draggables[draggables.length - 1].descriptor.index;
792 return options.inHomeList ? indexOfLastItem : indexOfLastItem + 1;
793}
794
795function goAtEnd(_ref) {
796 var insideDestination = _ref.insideDestination,
797 inHomeList = _ref.inHomeList,
798 displacedBy = _ref.displacedBy,
799 destination = _ref.destination;
800 var newIndex = getIndexOfLastItem(insideDestination, {
801 inHomeList: inHomeList
802 });
803 return {
804 displaced: emptyGroups,
805 displacedBy: displacedBy,
806 at: {
807 type: 'REORDER',
808 destination: {
809 droppableId: destination.descriptor.id,
810 index: newIndex
811 }
812 }
813 };
814}
815
816function calculateReorderImpact(_ref2) {
817 var draggable = _ref2.draggable,
818 insideDestination = _ref2.insideDestination,
819 destination = _ref2.destination,
820 viewport = _ref2.viewport,
821 displacedBy = _ref2.displacedBy,
822 last = _ref2.last,
823 index = _ref2.index,
824 forceShouldAnimate = _ref2.forceShouldAnimate;
825 var inHomeList = isHomeOf(draggable, destination);
826
827 if (index == null) {
828 return goAtEnd({
829 insideDestination: insideDestination,
830 inHomeList: inHomeList,
831 displacedBy: displacedBy,
832 destination: destination
833 });
834 }
835
836 var match = find(insideDestination, function (item) {
837 return item.descriptor.index === index;
838 });
839
840 if (!match) {
841 return goAtEnd({
842 insideDestination: insideDestination,
843 inHomeList: inHomeList,
844 displacedBy: displacedBy,
845 destination: destination
846 });
847 }
848
849 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
850 var sliceFrom = insideDestination.indexOf(match);
851 var impacted = withoutDragging.slice(sliceFrom);
852 var displaced = getDisplacementGroups({
853 afterDragging: impacted,
854 destination: destination,
855 displacedBy: displacedBy,
856 last: last,
857 viewport: viewport.frame,
858 forceShouldAnimate: forceShouldAnimate
859 });
860 return {
861 displaced: displaced,
862 displacedBy: displacedBy,
863 at: {
864 type: 'REORDER',
865 destination: {
866 droppableId: destination.descriptor.id,
867 index: index
868 }
869 }
870 };
871}
872
873function didStartAfterCritical(draggableId, afterCritical) {
874 return Boolean(afterCritical.effected[draggableId]);
875}
876
877var fromCombine = (function (_ref) {
878 var isMovingForward = _ref.isMovingForward,
879 destination = _ref.destination,
880 draggables = _ref.draggables,
881 combine = _ref.combine,
882 afterCritical = _ref.afterCritical;
883
884 if (!destination.isCombineEnabled) {
885 return null;
886 }
887
888 var combineId = combine.draggableId;
889 var combineWith = draggables[combineId];
890 var combineWithIndex = combineWith.descriptor.index;
891 var didCombineWithStartAfterCritical = didStartAfterCritical(combineId, afterCritical);
892
893 if (didCombineWithStartAfterCritical) {
894 if (isMovingForward) {
895 return combineWithIndex;
896 }
897
898 return combineWithIndex - 1;
899 }
900
901 if (isMovingForward) {
902 return combineWithIndex + 1;
903 }
904
905 return combineWithIndex;
906});
907
908var fromReorder = (function (_ref) {
909 var isMovingForward = _ref.isMovingForward,
910 isInHomeList = _ref.isInHomeList,
911 insideDestination = _ref.insideDestination,
912 location = _ref.location;
913
914 if (!insideDestination.length) {
915 return null;
916 }
917
918 var currentIndex = location.index;
919 var proposedIndex = isMovingForward ? currentIndex + 1 : currentIndex - 1;
920 var firstIndex = insideDestination[0].descriptor.index;
921 var lastIndex = insideDestination[insideDestination.length - 1].descriptor.index;
922 var upperBound = isInHomeList ? lastIndex : lastIndex + 1;
923
924 if (proposedIndex < firstIndex) {
925 return null;
926 }
927
928 if (proposedIndex > upperBound) {
929 return null;
930 }
931
932 return proposedIndex;
933});
934
935var moveToNextIndex = (function (_ref) {
936 var isMovingForward = _ref.isMovingForward,
937 isInHomeList = _ref.isInHomeList,
938 draggable = _ref.draggable,
939 draggables = _ref.draggables,
940 destination = _ref.destination,
941 insideDestination = _ref.insideDestination,
942 previousImpact = _ref.previousImpact,
943 viewport = _ref.viewport,
944 afterCritical = _ref.afterCritical;
945 var wasAt = previousImpact.at;
946 !wasAt ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot move in direction without previous impact location') : invariant(false) : void 0;
947
948 if (wasAt.type === 'REORDER') {
949 var _newIndex = fromReorder({
950 isMovingForward: isMovingForward,
951 isInHomeList: isInHomeList,
952 location: wasAt.destination,
953 insideDestination: insideDestination
954 });
955
956 if (_newIndex == null) {
957 return null;
958 }
959
960 return calculateReorderImpact({
961 draggable: draggable,
962 insideDestination: insideDestination,
963 destination: destination,
964 viewport: viewport,
965 last: previousImpact.displaced,
966 displacedBy: previousImpact.displacedBy,
967 index: _newIndex
968 });
969 }
970
971 var newIndex = fromCombine({
972 isMovingForward: isMovingForward,
973 destination: destination,
974 displaced: previousImpact.displaced,
975 draggables: draggables,
976 combine: wasAt.combine,
977 afterCritical: afterCritical
978 });
979
980 if (newIndex == null) {
981 return null;
982 }
983
984 return calculateReorderImpact({
985 draggable: draggable,
986 insideDestination: insideDestination,
987 destination: destination,
988 viewport: viewport,
989 last: previousImpact.displaced,
990 displacedBy: previousImpact.displacedBy,
991 index: newIndex
992 });
993});
994
995var getCombinedItemDisplacement = (function (_ref) {
996 var displaced = _ref.displaced,
997 afterCritical = _ref.afterCritical,
998 combineWith = _ref.combineWith,
999 displacedBy = _ref.displacedBy;
1000 var isDisplaced = Boolean(displaced.visible[combineWith] || displaced.invisible[combineWith]);
1001
1002 if (didStartAfterCritical(combineWith, afterCritical)) {
1003 return isDisplaced ? origin : negate(displacedBy.point);
1004 }
1005
1006 return isDisplaced ? displacedBy.point : origin;
1007});
1008
1009var whenCombining = (function (_ref) {
1010 var afterCritical = _ref.afterCritical,
1011 impact = _ref.impact,
1012 draggables = _ref.draggables;
1013 var combine = tryGetCombine(impact);
1014 !combine ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
1015 var combineWith = combine.draggableId;
1016 var center = draggables[combineWith].page.borderBox.center;
1017 var displaceBy = getCombinedItemDisplacement({
1018 displaced: impact.displaced,
1019 afterCritical: afterCritical,
1020 combineWith: combineWith,
1021 displacedBy: impact.displacedBy
1022 });
1023 return add(center, displaceBy);
1024});
1025
1026var distanceFromStartToBorderBoxCenter = function distanceFromStartToBorderBoxCenter(axis, box) {
1027 return box.margin[axis.start] + box.borderBox[axis.size] / 2;
1028};
1029
1030var distanceFromEndToBorderBoxCenter = function distanceFromEndToBorderBoxCenter(axis, box) {
1031 return box.margin[axis.end] + box.borderBox[axis.size] / 2;
1032};
1033
1034var getCrossAxisBorderBoxCenter = function getCrossAxisBorderBoxCenter(axis, target, isMoving) {
1035 return target[axis.crossAxisStart] + isMoving.margin[axis.crossAxisStart] + isMoving.borderBox[axis.crossAxisSize] / 2;
1036};
1037
1038var goAfter = function goAfter(_ref) {
1039 var axis = _ref.axis,
1040 moveRelativeTo = _ref.moveRelativeTo,
1041 isMoving = _ref.isMoving;
1042 return patch(axis.line, moveRelativeTo.marginBox[axis.end] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
1043};
1044var goBefore = function goBefore(_ref2) {
1045 var axis = _ref2.axis,
1046 moveRelativeTo = _ref2.moveRelativeTo,
1047 isMoving = _ref2.isMoving;
1048 return patch(axis.line, moveRelativeTo.marginBox[axis.start] - distanceFromEndToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
1049};
1050var goIntoStart = function goIntoStart(_ref3) {
1051 var axis = _ref3.axis,
1052 moveInto = _ref3.moveInto,
1053 isMoving = _ref3.isMoving;
1054 return patch(axis.line, moveInto.contentBox[axis.start] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveInto.contentBox, isMoving));
1055};
1056
1057var whenReordering = (function (_ref) {
1058 var impact = _ref.impact,
1059 draggable = _ref.draggable,
1060 draggables = _ref.draggables,
1061 droppable = _ref.droppable,
1062 afterCritical = _ref.afterCritical;
1063 var insideDestination = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
1064 var draggablePage = draggable.page;
1065 var axis = droppable.axis;
1066
1067 if (!insideDestination.length) {
1068 return goIntoStart({
1069 axis: axis,
1070 moveInto: droppable.page,
1071 isMoving: draggablePage
1072 });
1073 }
1074
1075 var displaced = impact.displaced,
1076 displacedBy = impact.displacedBy;
1077 var closestAfter = displaced.all[0];
1078
1079 if (closestAfter) {
1080 var closest = draggables[closestAfter];
1081
1082 if (didStartAfterCritical(closestAfter, afterCritical)) {
1083 return goBefore({
1084 axis: axis,
1085 moveRelativeTo: closest.page,
1086 isMoving: draggablePage
1087 });
1088 }
1089
1090 var withDisplacement = offset(closest.page, displacedBy.point);
1091 return goBefore({
1092 axis: axis,
1093 moveRelativeTo: withDisplacement,
1094 isMoving: draggablePage
1095 });
1096 }
1097
1098 var last = insideDestination[insideDestination.length - 1];
1099
1100 if (last.descriptor.id === draggable.descriptor.id) {
1101 return draggablePage.borderBox.center;
1102 }
1103
1104 if (didStartAfterCritical(last.descriptor.id, afterCritical)) {
1105 var page = offset(last.page, negate(afterCritical.displacedBy.point));
1106 return goAfter({
1107 axis: axis,
1108 moveRelativeTo: page,
1109 isMoving: draggablePage
1110 });
1111 }
1112
1113 return goAfter({
1114 axis: axis,
1115 moveRelativeTo: last.page,
1116 isMoving: draggablePage
1117 });
1118});
1119
1120var withDroppableDisplacement = (function (droppable, point) {
1121 var frame = droppable.frame;
1122
1123 if (!frame) {
1124 return point;
1125 }
1126
1127 return add(point, frame.scroll.diff.displacement);
1128});
1129
1130var getResultWithoutDroppableDisplacement = function getResultWithoutDroppableDisplacement(_ref) {
1131 var impact = _ref.impact,
1132 draggable = _ref.draggable,
1133 droppable = _ref.droppable,
1134 draggables = _ref.draggables,
1135 afterCritical = _ref.afterCritical;
1136 var original = draggable.page.borderBox.center;
1137 var at = impact.at;
1138
1139 if (!droppable) {
1140 return original;
1141 }
1142
1143 if (!at) {
1144 return original;
1145 }
1146
1147 if (at.type === 'REORDER') {
1148 return whenReordering({
1149 impact: impact,
1150 draggable: draggable,
1151 draggables: draggables,
1152 droppable: droppable,
1153 afterCritical: afterCritical
1154 });
1155 }
1156
1157 return whenCombining({
1158 impact: impact,
1159 draggables: draggables,
1160 afterCritical: afterCritical
1161 });
1162};
1163
1164var getPageBorderBoxCenterFromImpact = (function (args) {
1165 var withoutDisplacement = getResultWithoutDroppableDisplacement(args);
1166 var droppable = args.droppable;
1167 var withDisplacement = droppable ? withDroppableDisplacement(droppable, withoutDisplacement) : withoutDisplacement;
1168 return withDisplacement;
1169});
1170
1171var scrollViewport = (function (viewport, newScroll) {
1172 var diff = subtract(newScroll, viewport.scroll.initial);
1173 var displacement = negate(diff);
1174 var frame = getRect({
1175 top: newScroll.y,
1176 bottom: newScroll.y + viewport.frame.height,
1177 left: newScroll.x,
1178 right: newScroll.x + viewport.frame.width
1179 });
1180 var updated = {
1181 frame: frame,
1182 scroll: {
1183 initial: viewport.scroll.initial,
1184 max: viewport.scroll.max,
1185 current: newScroll,
1186 diff: {
1187 value: diff,
1188 displacement: displacement
1189 }
1190 }
1191 };
1192 return updated;
1193});
1194
1195function getDraggables(ids, draggables) {
1196 return ids.map(function (id) {
1197 return draggables[id];
1198 });
1199}
1200
1201function tryGetVisible(id, groups) {
1202 for (var i = 0; i < groups.length; i++) {
1203 var displacement = groups[i].visible[id];
1204
1205 if (displacement) {
1206 return displacement;
1207 }
1208 }
1209
1210 return null;
1211}
1212
1213var speculativelyIncrease = (function (_ref) {
1214 var impact = _ref.impact,
1215 viewport = _ref.viewport,
1216 destination = _ref.destination,
1217 draggables = _ref.draggables,
1218 maxScrollChange = _ref.maxScrollChange;
1219 var scrolledViewport = scrollViewport(viewport, add(viewport.scroll.current, maxScrollChange));
1220 var scrolledDroppable = destination.frame ? scrollDroppable(destination, add(destination.frame.scroll.current, maxScrollChange)) : destination;
1221 var last = impact.displaced;
1222 var withViewportScroll = getDisplacementGroups({
1223 afterDragging: getDraggables(last.all, draggables),
1224 destination: destination,
1225 displacedBy: impact.displacedBy,
1226 viewport: scrolledViewport.frame,
1227 last: last,
1228 forceShouldAnimate: false
1229 });
1230 var withDroppableScroll = getDisplacementGroups({
1231 afterDragging: getDraggables(last.all, draggables),
1232 destination: scrolledDroppable,
1233 displacedBy: impact.displacedBy,
1234 viewport: viewport.frame,
1235 last: last,
1236 forceShouldAnimate: false
1237 });
1238 var invisible = {};
1239 var visible = {};
1240 var groups = [last, withViewportScroll, withDroppableScroll];
1241 last.all.forEach(function (id) {
1242 var displacement = tryGetVisible(id, groups);
1243
1244 if (displacement) {
1245 visible[id] = displacement;
1246 return;
1247 }
1248
1249 invisible[id] = true;
1250 });
1251
1252 var newImpact = _extends({}, impact, {
1253 displaced: {
1254 all: last.all,
1255 invisible: invisible,
1256 visible: visible
1257 }
1258 });
1259
1260 return newImpact;
1261});
1262
1263var withViewportDisplacement = (function (viewport, point) {
1264 return add(viewport.scroll.diff.displacement, point);
1265});
1266
1267var getClientFromPageBorderBoxCenter = (function (_ref) {
1268 var pageBorderBoxCenter = _ref.pageBorderBoxCenter,
1269 draggable = _ref.draggable,
1270 viewport = _ref.viewport;
1271 var withoutPageScrollChange = withViewportDisplacement(viewport, pageBorderBoxCenter);
1272 var offset = subtract(withoutPageScrollChange, draggable.page.borderBox.center);
1273 return add(draggable.client.borderBox.center, offset);
1274});
1275
1276var isTotallyVisibleInNewLocation = (function (_ref) {
1277 var draggable = _ref.draggable,
1278 destination = _ref.destination,
1279 newPageBorderBoxCenter = _ref.newPageBorderBoxCenter,
1280 viewport = _ref.viewport,
1281 withDroppableDisplacement = _ref.withDroppableDisplacement,
1282 _ref$onlyOnMainAxis = _ref.onlyOnMainAxis,
1283 onlyOnMainAxis = _ref$onlyOnMainAxis === void 0 ? false : _ref$onlyOnMainAxis;
1284 var changeNeeded = subtract(newPageBorderBoxCenter, draggable.page.borderBox.center);
1285 var shifted = offsetByPosition(draggable.page.borderBox, changeNeeded);
1286 var args = {
1287 target: shifted,
1288 destination: destination,
1289 withDroppableDisplacement: withDroppableDisplacement,
1290 viewport: viewport
1291 };
1292 return onlyOnMainAxis ? isTotallyVisibleOnAxis(args) : isTotallyVisible(args);
1293});
1294
1295var moveToNextPlace = (function (_ref) {
1296 var isMovingForward = _ref.isMovingForward,
1297 draggable = _ref.draggable,
1298 destination = _ref.destination,
1299 draggables = _ref.draggables,
1300 previousImpact = _ref.previousImpact,
1301 viewport = _ref.viewport,
1302 previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
1303 previousClientSelection = _ref.previousClientSelection,
1304 afterCritical = _ref.afterCritical;
1305
1306 if (!destination.isEnabled) {
1307 return null;
1308 }
1309
1310 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
1311 var isInHomeList = isHomeOf(draggable, destination);
1312 var impact = moveToNextCombine({
1313 isMovingForward: isMovingForward,
1314 draggable: draggable,
1315 destination: destination,
1316 insideDestination: insideDestination,
1317 previousImpact: previousImpact
1318 }) || moveToNextIndex({
1319 isMovingForward: isMovingForward,
1320 isInHomeList: isInHomeList,
1321 draggable: draggable,
1322 draggables: draggables,
1323 destination: destination,
1324 insideDestination: insideDestination,
1325 previousImpact: previousImpact,
1326 viewport: viewport,
1327 afterCritical: afterCritical
1328 });
1329
1330 if (!impact) {
1331 return null;
1332 }
1333
1334 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
1335 impact: impact,
1336 draggable: draggable,
1337 droppable: destination,
1338 draggables: draggables,
1339 afterCritical: afterCritical
1340 });
1341 var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
1342 draggable: draggable,
1343 destination: destination,
1344 newPageBorderBoxCenter: pageBorderBoxCenter,
1345 viewport: viewport.frame,
1346 withDroppableDisplacement: false,
1347 onlyOnMainAxis: true
1348 });
1349
1350 if (isVisibleInNewLocation) {
1351 var clientSelection = getClientFromPageBorderBoxCenter({
1352 pageBorderBoxCenter: pageBorderBoxCenter,
1353 draggable: draggable,
1354 viewport: viewport
1355 });
1356 return {
1357 clientSelection: clientSelection,
1358 impact: impact,
1359 scrollJumpRequest: null
1360 };
1361 }
1362
1363 var distance = subtract(pageBorderBoxCenter, previousPageBorderBoxCenter);
1364 var cautious = speculativelyIncrease({
1365 impact: impact,
1366 viewport: viewport,
1367 destination: destination,
1368 draggables: draggables,
1369 maxScrollChange: distance
1370 });
1371 return {
1372 clientSelection: previousClientSelection,
1373 impact: cautious,
1374 scrollJumpRequest: distance
1375 };
1376});
1377
1378var getKnownActive = function getKnownActive(droppable) {
1379 var rect = droppable.subject.active;
1380 !rect ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot get clipped area from droppable') : invariant(false) : void 0;
1381 return rect;
1382};
1383
1384var getBestCrossAxisDroppable = (function (_ref) {
1385 var isMovingForward = _ref.isMovingForward,
1386 pageBorderBoxCenter = _ref.pageBorderBoxCenter,
1387 source = _ref.source,
1388 droppables = _ref.droppables,
1389 viewport = _ref.viewport;
1390 var active = source.subject.active;
1391
1392 if (!active) {
1393 return null;
1394 }
1395
1396 var axis = source.axis;
1397 var isBetweenSourceClipped = isWithin(active[axis.start], active[axis.end]);
1398 var candidates = toDroppableList(droppables).filter(function (droppable) {
1399 return droppable !== source;
1400 }).filter(function (droppable) {
1401 return droppable.isEnabled;
1402 }).filter(function (droppable) {
1403 return Boolean(droppable.subject.active);
1404 }).filter(function (droppable) {
1405 return isPartiallyVisibleThroughFrame(viewport.frame)(getKnownActive(droppable));
1406 }).filter(function (droppable) {
1407 var activeOfTarget = getKnownActive(droppable);
1408
1409 if (isMovingForward) {
1410 return active[axis.crossAxisEnd] < activeOfTarget[axis.crossAxisEnd];
1411 }
1412
1413 return activeOfTarget[axis.crossAxisStart] < active[axis.crossAxisStart];
1414 }).filter(function (droppable) {
1415 var activeOfTarget = getKnownActive(droppable);
1416 var isBetweenDestinationClipped = isWithin(activeOfTarget[axis.start], activeOfTarget[axis.end]);
1417 return isBetweenSourceClipped(activeOfTarget[axis.start]) || isBetweenSourceClipped(activeOfTarget[axis.end]) || isBetweenDestinationClipped(active[axis.start]) || isBetweenDestinationClipped(active[axis.end]);
1418 }).sort(function (a, b) {
1419 var first = getKnownActive(a)[axis.crossAxisStart];
1420 var second = getKnownActive(b)[axis.crossAxisStart];
1421
1422 if (isMovingForward) {
1423 return first - second;
1424 }
1425
1426 return second - first;
1427 }).filter(function (droppable, index, array) {
1428 return getKnownActive(droppable)[axis.crossAxisStart] === getKnownActive(array[0])[axis.crossAxisStart];
1429 });
1430
1431 if (!candidates.length) {
1432 return null;
1433 }
1434
1435 if (candidates.length === 1) {
1436 return candidates[0];
1437 }
1438
1439 var contains = candidates.filter(function (droppable) {
1440 var isWithinDroppable = isWithin(getKnownActive(droppable)[axis.start], getKnownActive(droppable)[axis.end]);
1441 return isWithinDroppable(pageBorderBoxCenter[axis.line]);
1442 });
1443
1444 if (contains.length === 1) {
1445 return contains[0];
1446 }
1447
1448 if (contains.length > 1) {
1449 return contains.sort(function (a, b) {
1450 return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
1451 })[0];
1452 }
1453
1454 return candidates.sort(function (a, b) {
1455 var first = closest(pageBorderBoxCenter, getCorners(getKnownActive(a)));
1456 var second = closest(pageBorderBoxCenter, getCorners(getKnownActive(b)));
1457
1458 if (first !== second) {
1459 return first - second;
1460 }
1461
1462 return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
1463 })[0];
1464});
1465
1466var getCurrentPageBorderBoxCenter = function getCurrentPageBorderBoxCenter(draggable, afterCritical) {
1467 var original = draggable.page.borderBox.center;
1468 return didStartAfterCritical(draggable.descriptor.id, afterCritical) ? subtract(original, afterCritical.displacedBy.point) : original;
1469};
1470var getCurrentPageBorderBox = function getCurrentPageBorderBox(draggable, afterCritical) {
1471 var original = draggable.page.borderBox;
1472 return didStartAfterCritical(draggable.descriptor.id, afterCritical) ? offsetByPosition(original, negate(afterCritical.displacedBy.point)) : original;
1473};
1474
1475var getClosestDraggable = (function (_ref) {
1476 var pageBorderBoxCenter = _ref.pageBorderBoxCenter,
1477 viewport = _ref.viewport,
1478 destination = _ref.destination,
1479 insideDestination = _ref.insideDestination,
1480 afterCritical = _ref.afterCritical;
1481 var sorted = insideDestination.filter(function (draggable) {
1482 return isTotallyVisible({
1483 target: getCurrentPageBorderBox(draggable, afterCritical),
1484 destination: destination,
1485 viewport: viewport.frame,
1486 withDroppableDisplacement: true
1487 });
1488 }).sort(function (a, b) {
1489 var distanceToA = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(a, afterCritical)));
1490 var distanceToB = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(b, afterCritical)));
1491
1492 if (distanceToA < distanceToB) {
1493 return -1;
1494 }
1495
1496 if (distanceToB < distanceToA) {
1497 return 1;
1498 }
1499
1500 return a.descriptor.index - b.descriptor.index;
1501 });
1502 return sorted[0] || null;
1503});
1504
1505var getDisplacedBy = memoizeOne(function getDisplacedBy(axis, displaceBy) {
1506 var displacement = displaceBy[axis.line];
1507 return {
1508 value: displacement,
1509 point: patch(axis.line, displacement)
1510 };
1511});
1512
1513var getRequiredGrowthForPlaceholder = function getRequiredGrowthForPlaceholder(droppable, placeholderSize, draggables) {
1514 var axis = droppable.axis;
1515
1516 if (droppable.descriptor.mode === 'virtual') {
1517 return patch(axis.line, placeholderSize[axis.line]);
1518 }
1519
1520 var availableSpace = droppable.subject.page.contentBox[axis.size];
1521 var insideDroppable = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
1522 var spaceUsed = insideDroppable.reduce(function (sum, dimension) {
1523 return sum + dimension.client.marginBox[axis.size];
1524 }, 0);
1525 var requiredSpace = spaceUsed + placeholderSize[axis.line];
1526 var needsToGrowBy = requiredSpace - availableSpace;
1527
1528 if (needsToGrowBy <= 0) {
1529 return null;
1530 }
1531
1532 return patch(axis.line, needsToGrowBy);
1533};
1534
1535var withMaxScroll = function withMaxScroll(frame, max) {
1536 return _extends({}, frame, {
1537 scroll: _extends({}, frame.scroll, {
1538 max: max
1539 })
1540 });
1541};
1542
1543var addPlaceholder = function addPlaceholder(droppable, draggable, draggables) {
1544 var frame = droppable.frame;
1545 !!isHomeOf(draggable, droppable) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Should not add placeholder space to home list') : invariant(false) : void 0;
1546 !!droppable.subject.withPlaceholder ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot add placeholder size to a subject when it already has one') : invariant(false) : void 0;
1547 var placeholderSize = getDisplacedBy(droppable.axis, draggable.displaceBy).point;
1548 var requiredGrowth = getRequiredGrowthForPlaceholder(droppable, placeholderSize, draggables);
1549 var added = {
1550 placeholderSize: placeholderSize,
1551 increasedBy: requiredGrowth,
1552 oldFrameMaxScroll: droppable.frame ? droppable.frame.scroll.max : null
1553 };
1554
1555 if (!frame) {
1556 var _subject = getSubject({
1557 page: droppable.subject.page,
1558 withPlaceholder: added,
1559 axis: droppable.axis,
1560 frame: droppable.frame
1561 });
1562
1563 return _extends({}, droppable, {
1564 subject: _subject
1565 });
1566 }
1567
1568 var maxScroll = requiredGrowth ? add(frame.scroll.max, requiredGrowth) : frame.scroll.max;
1569 var newFrame = withMaxScroll(frame, maxScroll);
1570 var subject = getSubject({
1571 page: droppable.subject.page,
1572 withPlaceholder: added,
1573 axis: droppable.axis,
1574 frame: newFrame
1575 });
1576 return _extends({}, droppable, {
1577 subject: subject,
1578 frame: newFrame
1579 });
1580};
1581var removePlaceholder = function removePlaceholder(droppable) {
1582 var added = droppable.subject.withPlaceholder;
1583 !added ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot remove placeholder form subject when there was none') : invariant(false) : void 0;
1584 var frame = droppable.frame;
1585
1586 if (!frame) {
1587 var _subject2 = getSubject({
1588 page: droppable.subject.page,
1589 axis: droppable.axis,
1590 frame: null,
1591 withPlaceholder: null
1592 });
1593
1594 return _extends({}, droppable, {
1595 subject: _subject2
1596 });
1597 }
1598
1599 var oldMaxScroll = added.oldFrameMaxScroll;
1600 !oldMaxScroll ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected droppable with frame to have old max frame scroll when removing placeholder') : invariant(false) : void 0;
1601 var newFrame = withMaxScroll(frame, oldMaxScroll);
1602 var subject = getSubject({
1603 page: droppable.subject.page,
1604 axis: droppable.axis,
1605 frame: newFrame,
1606 withPlaceholder: null
1607 });
1608 return _extends({}, droppable, {
1609 subject: subject,
1610 frame: newFrame
1611 });
1612};
1613
1614var moveToNewDroppable = (function (_ref) {
1615 var previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
1616 moveRelativeTo = _ref.moveRelativeTo,
1617 insideDestination = _ref.insideDestination,
1618 draggable = _ref.draggable,
1619 draggables = _ref.draggables,
1620 destination = _ref.destination,
1621 viewport = _ref.viewport,
1622 afterCritical = _ref.afterCritical;
1623
1624 if (!moveRelativeTo) {
1625 if (insideDestination.length) {
1626 return null;
1627 }
1628
1629 var proposed = {
1630 displaced: emptyGroups,
1631 displacedBy: noDisplacedBy,
1632 at: {
1633 type: 'REORDER',
1634 destination: {
1635 droppableId: destination.descriptor.id,
1636 index: 0
1637 }
1638 }
1639 };
1640 var proposedPageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
1641 impact: proposed,
1642 draggable: draggable,
1643 droppable: destination,
1644 draggables: draggables,
1645 afterCritical: afterCritical
1646 });
1647 var withPlaceholder = isHomeOf(draggable, destination) ? destination : addPlaceholder(destination, draggable, draggables);
1648 var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
1649 draggable: draggable,
1650 destination: withPlaceholder,
1651 newPageBorderBoxCenter: proposedPageBorderBoxCenter,
1652 viewport: viewport.frame,
1653 withDroppableDisplacement: false,
1654 onlyOnMainAxis: true
1655 });
1656 return isVisibleInNewLocation ? proposed : null;
1657 }
1658
1659 var isGoingBeforeTarget = Boolean(previousPageBorderBoxCenter[destination.axis.line] <= moveRelativeTo.page.borderBox.center[destination.axis.line]);
1660
1661 var proposedIndex = function () {
1662 var relativeTo = moveRelativeTo.descriptor.index;
1663
1664 if (moveRelativeTo.descriptor.id === draggable.descriptor.id) {
1665 return relativeTo;
1666 }
1667
1668 if (isGoingBeforeTarget) {
1669 return relativeTo;
1670 }
1671
1672 return relativeTo + 1;
1673 }();
1674
1675 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
1676 return calculateReorderImpact({
1677 draggable: draggable,
1678 insideDestination: insideDestination,
1679 destination: destination,
1680 viewport: viewport,
1681 displacedBy: displacedBy,
1682 last: emptyGroups,
1683 index: proposedIndex
1684 });
1685});
1686
1687var moveCrossAxis = (function (_ref) {
1688 var isMovingForward = _ref.isMovingForward,
1689 previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter,
1690 draggable = _ref.draggable,
1691 isOver = _ref.isOver,
1692 draggables = _ref.draggables,
1693 droppables = _ref.droppables,
1694 viewport = _ref.viewport,
1695 afterCritical = _ref.afterCritical;
1696 var destination = getBestCrossAxisDroppable({
1697 isMovingForward: isMovingForward,
1698 pageBorderBoxCenter: previousPageBorderBoxCenter,
1699 source: isOver,
1700 droppables: droppables,
1701 viewport: viewport
1702 });
1703
1704 if (!destination) {
1705 return null;
1706 }
1707
1708 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
1709 var moveRelativeTo = getClosestDraggable({
1710 pageBorderBoxCenter: previousPageBorderBoxCenter,
1711 viewport: viewport,
1712 destination: destination,
1713 insideDestination: insideDestination,
1714 afterCritical: afterCritical
1715 });
1716 var impact = moveToNewDroppable({
1717 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
1718 destination: destination,
1719 draggable: draggable,
1720 draggables: draggables,
1721 moveRelativeTo: moveRelativeTo,
1722 insideDestination: insideDestination,
1723 viewport: viewport,
1724 afterCritical: afterCritical
1725 });
1726
1727 if (!impact) {
1728 return null;
1729 }
1730
1731 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
1732 impact: impact,
1733 draggable: draggable,
1734 droppable: destination,
1735 draggables: draggables,
1736 afterCritical: afterCritical
1737 });
1738 var clientSelection = getClientFromPageBorderBoxCenter({
1739 pageBorderBoxCenter: pageBorderBoxCenter,
1740 draggable: draggable,
1741 viewport: viewport
1742 });
1743 return {
1744 clientSelection: clientSelection,
1745 impact: impact,
1746 scrollJumpRequest: null
1747 };
1748});
1749
1750var whatIsDraggedOver = (function (impact) {
1751 var at = impact.at;
1752
1753 if (!at) {
1754 return null;
1755 }
1756
1757 if (at.type === 'REORDER') {
1758 return at.destination.droppableId;
1759 }
1760
1761 return at.combine.droppableId;
1762});
1763
1764var getDroppableOver = function getDroppableOver(impact, droppables) {
1765 var id = whatIsDraggedOver(impact);
1766 return id ? droppables[id] : null;
1767};
1768
1769var moveInDirection = (function (_ref) {
1770 var state = _ref.state,
1771 type = _ref.type;
1772 var isActuallyOver = getDroppableOver(state.impact, state.dimensions.droppables);
1773 var isMainAxisMovementAllowed = Boolean(isActuallyOver);
1774 var home = state.dimensions.droppables[state.critical.droppable.id];
1775 var isOver = isActuallyOver || home;
1776 var direction = isOver.axis.direction;
1777 var isMovingOnMainAxis = direction === 'vertical' && (type === 'MOVE_UP' || type === 'MOVE_DOWN') || direction === 'horizontal' && (type === 'MOVE_LEFT' || type === 'MOVE_RIGHT');
1778
1779 if (isMovingOnMainAxis && !isMainAxisMovementAllowed) {
1780 return null;
1781 }
1782
1783 var isMovingForward = type === 'MOVE_DOWN' || type === 'MOVE_RIGHT';
1784 var draggable = state.dimensions.draggables[state.critical.draggable.id];
1785 var previousPageBorderBoxCenter = state.current.page.borderBoxCenter;
1786 var _state$dimensions = state.dimensions,
1787 draggables = _state$dimensions.draggables,
1788 droppables = _state$dimensions.droppables;
1789 return isMovingOnMainAxis ? moveToNextPlace({
1790 isMovingForward: isMovingForward,
1791 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
1792 draggable: draggable,
1793 destination: isOver,
1794 draggables: draggables,
1795 viewport: state.viewport,
1796 previousClientSelection: state.current.client.selection,
1797 previousImpact: state.impact,
1798 afterCritical: state.afterCritical
1799 }) : moveCrossAxis({
1800 isMovingForward: isMovingForward,
1801 previousPageBorderBoxCenter: previousPageBorderBoxCenter,
1802 draggable: draggable,
1803 isOver: isOver,
1804 draggables: draggables,
1805 droppables: droppables,
1806 viewport: state.viewport,
1807 afterCritical: state.afterCritical
1808 });
1809});
1810
1811function isMovementAllowed(state) {
1812 return state.phase === 'DRAGGING' || state.phase === 'COLLECTING';
1813}
1814
1815function isPositionInFrame(frame) {
1816 var isWithinVertical = isWithin(frame.top, frame.bottom);
1817 var isWithinHorizontal = isWithin(frame.left, frame.right);
1818 return function run(point) {
1819 return isWithinVertical(point.y) && isWithinHorizontal(point.x);
1820 };
1821}
1822
1823function getHasOverlap(first, second) {
1824 return first.left < second.right && first.right > second.left && first.top < second.bottom && first.bottom > second.top;
1825}
1826
1827function getFurthestAway(_ref) {
1828 var pageBorderBox = _ref.pageBorderBox,
1829 draggable = _ref.draggable,
1830 candidates = _ref.candidates;
1831 var startCenter = draggable.page.borderBox.center;
1832 var sorted = candidates.map(function (candidate) {
1833 var axis = candidate.axis;
1834 var target = patch(candidate.axis.line, pageBorderBox.center[axis.line], candidate.page.borderBox.center[axis.crossAxisLine]);
1835 return {
1836 id: candidate.descriptor.id,
1837 distance: distance(startCenter, target)
1838 };
1839 }).sort(function (a, b) {
1840 return b.distance - a.distance;
1841 });
1842 return sorted[0] ? sorted[0].id : null;
1843}
1844
1845function getDroppableOver$1(_ref2) {
1846 var pageBorderBox = _ref2.pageBorderBox,
1847 draggable = _ref2.draggable,
1848 droppables = _ref2.droppables;
1849 var candidates = toDroppableList(droppables).filter(function (item) {
1850 if (!item.isEnabled) {
1851 return false;
1852 }
1853
1854 var active = item.subject.active;
1855
1856 if (!active) {
1857 return false;
1858 }
1859
1860 if (!getHasOverlap(pageBorderBox, active)) {
1861 return false;
1862 }
1863
1864 if (isPositionInFrame(active)(pageBorderBox.center)) {
1865 return true;
1866 }
1867
1868 var axis = item.axis;
1869 var childCenter = active.center[axis.crossAxisLine];
1870 var crossAxisStart = pageBorderBox[axis.crossAxisStart];
1871 var crossAxisEnd = pageBorderBox[axis.crossAxisEnd];
1872 var isContained = isWithin(active[axis.crossAxisStart], active[axis.crossAxisEnd]);
1873 var isStartContained = isContained(crossAxisStart);
1874 var isEndContained = isContained(crossAxisEnd);
1875
1876 if (!isStartContained && !isEndContained) {
1877 return true;
1878 }
1879
1880 if (isStartContained) {
1881 return crossAxisStart < childCenter;
1882 }
1883
1884 return crossAxisEnd > childCenter;
1885 });
1886
1887 if (!candidates.length) {
1888 return null;
1889 }
1890
1891 if (candidates.length === 1) {
1892 return candidates[0].descriptor.id;
1893 }
1894
1895 return getFurthestAway({
1896 pageBorderBox: pageBorderBox,
1897 draggable: draggable,
1898 candidates: candidates
1899 });
1900}
1901
1902var offsetRectByPosition = function offsetRectByPosition(rect, point) {
1903 return getRect(offsetByPosition(rect, point));
1904};
1905
1906var withDroppableScroll = (function (droppable, area) {
1907 var frame = droppable.frame;
1908
1909 if (!frame) {
1910 return area;
1911 }
1912
1913 return offsetRectByPosition(area, frame.scroll.diff.value);
1914});
1915
1916function getIsDisplaced(_ref) {
1917 var displaced = _ref.displaced,
1918 id = _ref.id;
1919 return Boolean(displaced.visible[id] || displaced.invisible[id]);
1920}
1921
1922function atIndex(_ref) {
1923 var draggable = _ref.draggable,
1924 closest = _ref.closest,
1925 inHomeList = _ref.inHomeList;
1926
1927 if (!closest) {
1928 return null;
1929 }
1930
1931 if (!inHomeList) {
1932 return closest.descriptor.index;
1933 }
1934
1935 if (closest.descriptor.index > draggable.descriptor.index) {
1936 return closest.descriptor.index - 1;
1937 }
1938
1939 return closest.descriptor.index;
1940}
1941
1942var getReorderImpact = (function (_ref2) {
1943 var targetRect = _ref2.pageBorderBoxWithDroppableScroll,
1944 draggable = _ref2.draggable,
1945 destination = _ref2.destination,
1946 insideDestination = _ref2.insideDestination,
1947 last = _ref2.last,
1948 viewport = _ref2.viewport,
1949 afterCritical = _ref2.afterCritical;
1950 var axis = destination.axis;
1951 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
1952 var displacement = displacedBy.value;
1953 var targetStart = targetRect[axis.start];
1954 var targetEnd = targetRect[axis.end];
1955 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
1956 var closest = find(withoutDragging, function (child) {
1957 var id = child.descriptor.id;
1958 var childCenter = child.page.borderBox.center[axis.line];
1959 var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
1960 var isDisplaced = getIsDisplaced({
1961 displaced: last,
1962 id: id
1963 });
1964
1965 if (didStartAfterCritical$1) {
1966 if (isDisplaced) {
1967 return targetEnd <= childCenter;
1968 }
1969
1970 return targetStart < childCenter - displacement;
1971 }
1972
1973 if (isDisplaced) {
1974 return targetEnd <= childCenter + displacement;
1975 }
1976
1977 return targetStart < childCenter;
1978 });
1979 var newIndex = atIndex({
1980 draggable: draggable,
1981 closest: closest,
1982 inHomeList: isHomeOf(draggable, destination)
1983 });
1984 return calculateReorderImpact({
1985 draggable: draggable,
1986 insideDestination: insideDestination,
1987 destination: destination,
1988 viewport: viewport,
1989 last: last,
1990 displacedBy: displacedBy,
1991 index: newIndex
1992 });
1993});
1994
1995var combineThresholdDivisor = 4;
1996var getCombineImpact = (function (_ref) {
1997 var draggable = _ref.draggable,
1998 targetRect = _ref.pageBorderBoxWithDroppableScroll,
1999 previousImpact = _ref.previousImpact,
2000 destination = _ref.destination,
2001 insideDestination = _ref.insideDestination,
2002 afterCritical = _ref.afterCritical;
2003
2004 if (!destination.isCombineEnabled) {
2005 return null;
2006 }
2007
2008 var axis = destination.axis;
2009 var displacedBy = getDisplacedBy(destination.axis, draggable.displaceBy);
2010 var displacement = displacedBy.value;
2011 var targetStart = targetRect[axis.start];
2012 var targetEnd = targetRect[axis.end];
2013 var withoutDragging = removeDraggableFromList(draggable, insideDestination);
2014 var combineWith = find(withoutDragging, function (child) {
2015 var id = child.descriptor.id;
2016 var childRect = child.page.borderBox;
2017 var childSize = childRect[axis.size];
2018 var threshold = childSize / combineThresholdDivisor;
2019 var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
2020 var isDisplaced = getIsDisplaced({
2021 displaced: previousImpact.displaced,
2022 id: id
2023 });
2024
2025 if (didStartAfterCritical$1) {
2026 if (isDisplaced) {
2027 return targetEnd > childRect[axis.start] + threshold && targetEnd < childRect[axis.end] - threshold;
2028 }
2029
2030 return targetStart > childRect[axis.start] - displacement + threshold && targetStart < childRect[axis.end] - displacement - threshold;
2031 }
2032
2033 if (isDisplaced) {
2034 return targetEnd > childRect[axis.start] + displacement + threshold && targetEnd < childRect[axis.end] + displacement - threshold;
2035 }
2036
2037 return targetStart > childRect[axis.start] + threshold && targetStart < childRect[axis.end] - threshold;
2038 });
2039
2040 if (!combineWith) {
2041 return null;
2042 }
2043
2044 var impact = {
2045 displacedBy: displacedBy,
2046 displaced: previousImpact.displaced,
2047 at: {
2048 type: 'COMBINE',
2049 combine: {
2050 draggableId: combineWith.descriptor.id,
2051 droppableId: destination.descriptor.id
2052 }
2053 }
2054 };
2055 return impact;
2056});
2057
2058var getDragImpact = (function (_ref) {
2059 var pageOffset = _ref.pageOffset,
2060 draggable = _ref.draggable,
2061 draggables = _ref.draggables,
2062 droppables = _ref.droppables,
2063 previousImpact = _ref.previousImpact,
2064 viewport = _ref.viewport,
2065 afterCritical = _ref.afterCritical;
2066 var pageBorderBox = offsetRectByPosition(draggable.page.borderBox, pageOffset);
2067 var destinationId = getDroppableOver$1({
2068 pageBorderBox: pageBorderBox,
2069 draggable: draggable,
2070 droppables: droppables
2071 });
2072
2073 if (!destinationId) {
2074 return noImpact;
2075 }
2076
2077 var destination = droppables[destinationId];
2078 var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
2079 var pageBorderBoxWithDroppableScroll = withDroppableScroll(destination, pageBorderBox);
2080 return getCombineImpact({
2081 pageBorderBoxWithDroppableScroll: pageBorderBoxWithDroppableScroll,
2082 draggable: draggable,
2083 previousImpact: previousImpact,
2084 destination: destination,
2085 insideDestination: insideDestination,
2086 afterCritical: afterCritical
2087 }) || getReorderImpact({
2088 pageBorderBoxWithDroppableScroll: pageBorderBoxWithDroppableScroll,
2089 draggable: draggable,
2090 destination: destination,
2091 insideDestination: insideDestination,
2092 last: previousImpact.displaced,
2093 viewport: viewport,
2094 afterCritical: afterCritical
2095 });
2096});
2097
2098var patchDroppableMap = (function (droppables, updated) {
2099 var _extends2;
2100
2101 return _extends({}, droppables, (_extends2 = {}, _extends2[updated.descriptor.id] = updated, _extends2));
2102});
2103
2104var clearUnusedPlaceholder = function clearUnusedPlaceholder(_ref) {
2105 var previousImpact = _ref.previousImpact,
2106 impact = _ref.impact,
2107 droppables = _ref.droppables;
2108 var last = whatIsDraggedOver(previousImpact);
2109 var now = whatIsDraggedOver(impact);
2110
2111 if (!last) {
2112 return droppables;
2113 }
2114
2115 if (last === now) {
2116 return droppables;
2117 }
2118
2119 var lastDroppable = droppables[last];
2120
2121 if (!lastDroppable.subject.withPlaceholder) {
2122 return droppables;
2123 }
2124
2125 var updated = removePlaceholder(lastDroppable);
2126 return patchDroppableMap(droppables, updated);
2127};
2128
2129var recomputePlaceholders = (function (_ref2) {
2130 var draggable = _ref2.draggable,
2131 draggables = _ref2.draggables,
2132 droppables = _ref2.droppables,
2133 previousImpact = _ref2.previousImpact,
2134 impact = _ref2.impact;
2135 var cleaned = clearUnusedPlaceholder({
2136 previousImpact: previousImpact,
2137 impact: impact,
2138 droppables: droppables
2139 });
2140 var isOver = whatIsDraggedOver(impact);
2141
2142 if (!isOver) {
2143 return cleaned;
2144 }
2145
2146 var droppable = droppables[isOver];
2147
2148 if (isHomeOf(draggable, droppable)) {
2149 return cleaned;
2150 }
2151
2152 if (droppable.subject.withPlaceholder) {
2153 return cleaned;
2154 }
2155
2156 var patched = addPlaceholder(droppable, draggable, draggables);
2157 return patchDroppableMap(cleaned, patched);
2158});
2159
2160var update = (function (_ref) {
2161 var state = _ref.state,
2162 forcedClientSelection = _ref.clientSelection,
2163 forcedDimensions = _ref.dimensions,
2164 forcedViewport = _ref.viewport,
2165 forcedImpact = _ref.impact,
2166 scrollJumpRequest = _ref.scrollJumpRequest;
2167 var viewport = forcedViewport || state.viewport;
2168 var dimensions = forcedDimensions || state.dimensions;
2169 var clientSelection = forcedClientSelection || state.current.client.selection;
2170 var offset = subtract(clientSelection, state.initial.client.selection);
2171 var client = {
2172 offset: offset,
2173 selection: clientSelection,
2174 borderBoxCenter: add(state.initial.client.borderBoxCenter, offset)
2175 };
2176 var page = {
2177 selection: add(client.selection, viewport.scroll.current),
2178 borderBoxCenter: add(client.borderBoxCenter, viewport.scroll.current),
2179 offset: add(client.offset, viewport.scroll.diff.value)
2180 };
2181 var current = {
2182 client: client,
2183 page: page
2184 };
2185
2186 if (state.phase === 'COLLECTING') {
2187 return _extends({
2188 phase: 'COLLECTING'
2189 }, state, {
2190 dimensions: dimensions,
2191 viewport: viewport,
2192 current: current
2193 });
2194 }
2195
2196 var draggable = dimensions.draggables[state.critical.draggable.id];
2197 var newImpact = forcedImpact || getDragImpact({
2198 pageOffset: page.offset,
2199 draggable: draggable,
2200 draggables: dimensions.draggables,
2201 droppables: dimensions.droppables,
2202 previousImpact: state.impact,
2203 viewport: viewport,
2204 afterCritical: state.afterCritical
2205 });
2206 var withUpdatedPlaceholders = recomputePlaceholders({
2207 draggable: draggable,
2208 impact: newImpact,
2209 previousImpact: state.impact,
2210 draggables: dimensions.draggables,
2211 droppables: dimensions.droppables
2212 });
2213
2214 var result = _extends({}, state, {
2215 current: current,
2216 dimensions: {
2217 draggables: dimensions.draggables,
2218 droppables: withUpdatedPlaceholders
2219 },
2220 impact: newImpact,
2221 viewport: viewport,
2222 scrollJumpRequest: scrollJumpRequest || null,
2223 forceShouldAnimate: scrollJumpRequest ? false : null
2224 });
2225
2226 return result;
2227});
2228
2229function getDraggables$1(ids, draggables) {
2230 return ids.map(function (id) {
2231 return draggables[id];
2232 });
2233}
2234
2235var recompute = (function (_ref) {
2236 var impact = _ref.impact,
2237 viewport = _ref.viewport,
2238 draggables = _ref.draggables,
2239 destination = _ref.destination,
2240 forceShouldAnimate = _ref.forceShouldAnimate;
2241 var last = impact.displaced;
2242 var afterDragging = getDraggables$1(last.all, draggables);
2243 var displaced = getDisplacementGroups({
2244 afterDragging: afterDragging,
2245 destination: destination,
2246 displacedBy: impact.displacedBy,
2247 viewport: viewport.frame,
2248 forceShouldAnimate: forceShouldAnimate,
2249 last: last
2250 });
2251 return _extends({}, impact, {
2252 displaced: displaced
2253 });
2254});
2255
2256var getClientBorderBoxCenter = (function (_ref) {
2257 var impact = _ref.impact,
2258 draggable = _ref.draggable,
2259 droppable = _ref.droppable,
2260 draggables = _ref.draggables,
2261 viewport = _ref.viewport,
2262 afterCritical = _ref.afterCritical;
2263 var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
2264 impact: impact,
2265 draggable: draggable,
2266 draggables: draggables,
2267 droppable: droppable,
2268 afterCritical: afterCritical
2269 });
2270 return getClientFromPageBorderBoxCenter({
2271 pageBorderBoxCenter: pageBorderBoxCenter,
2272 draggable: draggable,
2273 viewport: viewport
2274 });
2275});
2276
2277var refreshSnap = (function (_ref) {
2278 var state = _ref.state,
2279 forcedDimensions = _ref.dimensions,
2280 forcedViewport = _ref.viewport;
2281 !(state.movementMode === 'SNAP') ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
2282 var needsVisibilityCheck = state.impact;
2283 var viewport = forcedViewport || state.viewport;
2284 var dimensions = forcedDimensions || state.dimensions;
2285 var draggables = dimensions.draggables,
2286 droppables = dimensions.droppables;
2287 var draggable = draggables[state.critical.draggable.id];
2288 var isOver = whatIsDraggedOver(needsVisibilityCheck);
2289 !isOver ? process.env.NODE_ENV !== "production" ? invariant(false, 'Must be over a destination in SNAP movement mode') : invariant(false) : void 0;
2290 var destination = droppables[isOver];
2291 var impact = recompute({
2292 impact: needsVisibilityCheck,
2293 viewport: viewport,
2294 destination: destination,
2295 draggables: draggables
2296 });
2297 var clientSelection = getClientBorderBoxCenter({
2298 impact: impact,
2299 draggable: draggable,
2300 droppable: destination,
2301 draggables: draggables,
2302 viewport: viewport,
2303 afterCritical: state.afterCritical
2304 });
2305 return update({
2306 impact: impact,
2307 clientSelection: clientSelection,
2308 state: state,
2309 dimensions: dimensions,
2310 viewport: viewport
2311 });
2312});
2313
2314var getHomeLocation = (function (descriptor) {
2315 return {
2316 index: descriptor.index,
2317 droppableId: descriptor.droppableId
2318 };
2319});
2320
2321var getLiftEffect = (function (_ref) {
2322 var draggable = _ref.draggable,
2323 home = _ref.home,
2324 draggables = _ref.draggables,
2325 viewport = _ref.viewport;
2326 var displacedBy = getDisplacedBy(home.axis, draggable.displaceBy);
2327 var insideHome = getDraggablesInsideDroppable(home.descriptor.id, draggables);
2328 var rawIndex = insideHome.indexOf(draggable);
2329 !(rawIndex !== -1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected draggable to be inside home list') : invariant(false) : void 0;
2330 var afterDragging = insideHome.slice(rawIndex + 1);
2331 var effected = afterDragging.reduce(function (previous, item) {
2332 previous[item.descriptor.id] = true;
2333 return previous;
2334 }, {});
2335 var afterCritical = {
2336 inVirtualList: home.descriptor.mode === 'virtual',
2337 displacedBy: displacedBy,
2338 effected: effected
2339 };
2340 var displaced = getDisplacementGroups({
2341 afterDragging: afterDragging,
2342 destination: home,
2343 displacedBy: displacedBy,
2344 last: null,
2345 viewport: viewport.frame,
2346 forceShouldAnimate: false
2347 });
2348 var impact = {
2349 displaced: displaced,
2350 displacedBy: displacedBy,
2351 at: {
2352 type: 'REORDER',
2353 destination: getHomeLocation(draggable.descriptor)
2354 }
2355 };
2356 return {
2357 impact: impact,
2358 afterCritical: afterCritical
2359 };
2360});
2361
2362var patchDimensionMap = (function (dimensions, updated) {
2363 return {
2364 draggables: dimensions.draggables,
2365 droppables: patchDroppableMap(dimensions.droppables, updated)
2366 };
2367});
2368
2369var start = function start(key) {
2370 if (process.env.NODE_ENV !== 'production') {
2371 {
2372 return;
2373 }
2374 }
2375};
2376var finish = function finish(key) {
2377 if (process.env.NODE_ENV !== 'production') {
2378 {
2379 return;
2380 }
2381 }
2382};
2383
2384var offsetDraggable = (function (_ref) {
2385 var draggable = _ref.draggable,
2386 offset$1 = _ref.offset,
2387 initialWindowScroll = _ref.initialWindowScroll;
2388 var client = offset(draggable.client, offset$1);
2389 var page = withScroll(client, initialWindowScroll);
2390
2391 var moved = _extends({}, draggable, {
2392 placeholder: _extends({}, draggable.placeholder, {
2393 client: client
2394 }),
2395 client: client,
2396 page: page
2397 });
2398
2399 return moved;
2400});
2401
2402var getFrame = (function (droppable) {
2403 var frame = droppable.frame;
2404 !frame ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected Droppable to have a frame') : invariant(false) : void 0;
2405 return frame;
2406});
2407
2408var adjustAdditionsForScrollChanges = (function (_ref) {
2409 var additions = _ref.additions,
2410 updatedDroppables = _ref.updatedDroppables,
2411 viewport = _ref.viewport;
2412 var windowScrollChange = viewport.scroll.diff.value;
2413 return additions.map(function (draggable) {
2414 var droppableId = draggable.descriptor.droppableId;
2415 var modified = updatedDroppables[droppableId];
2416 var frame = getFrame(modified);
2417 var droppableScrollChange = frame.scroll.diff.value;
2418 var totalChange = add(windowScrollChange, droppableScrollChange);
2419 var moved = offsetDraggable({
2420 draggable: draggable,
2421 offset: totalChange,
2422 initialWindowScroll: viewport.scroll.initial
2423 });
2424 return moved;
2425 });
2426});
2427
2428var publishWhileDraggingInVirtual = (function (_ref) {
2429 var state = _ref.state,
2430 published = _ref.published;
2431 start();
2432 var withScrollChange = published.modified.map(function (update) {
2433 var existing = state.dimensions.droppables[update.droppableId];
2434 var scrolled = scrollDroppable(existing, update.scroll);
2435 return scrolled;
2436 });
2437
2438 var droppables = _extends({}, state.dimensions.droppables, {}, toDroppableMap(withScrollChange));
2439
2440 var updatedAdditions = toDraggableMap(adjustAdditionsForScrollChanges({
2441 additions: published.additions,
2442 updatedDroppables: droppables,
2443 viewport: state.viewport
2444 }));
2445
2446 var draggables = _extends({}, state.dimensions.draggables, {}, updatedAdditions);
2447
2448 published.removals.forEach(function (id) {
2449 delete draggables[id];
2450 });
2451 var dimensions = {
2452 droppables: droppables,
2453 draggables: draggables
2454 };
2455 var wasOverId = whatIsDraggedOver(state.impact);
2456 var wasOver = wasOverId ? dimensions.droppables[wasOverId] : null;
2457 var draggable = dimensions.draggables[state.critical.draggable.id];
2458 var home = dimensions.droppables[state.critical.droppable.id];
2459
2460 var _getLiftEffect = getLiftEffect({
2461 draggable: draggable,
2462 home: home,
2463 draggables: draggables,
2464 viewport: state.viewport
2465 }),
2466 onLiftImpact = _getLiftEffect.impact,
2467 afterCritical = _getLiftEffect.afterCritical;
2468
2469 var previousImpact = wasOver && wasOver.isCombineEnabled ? state.impact : onLiftImpact;
2470 var impact = getDragImpact({
2471 pageOffset: state.current.page.offset,
2472 draggable: dimensions.draggables[state.critical.draggable.id],
2473 draggables: dimensions.draggables,
2474 droppables: dimensions.droppables,
2475 previousImpact: previousImpact,
2476 viewport: state.viewport,
2477 afterCritical: afterCritical
2478 });
2479 finish();
2480
2481 var draggingState = _extends({
2482 phase: 'DRAGGING'
2483 }, state, {
2484 phase: 'DRAGGING',
2485 impact: impact,
2486 onLiftImpact: onLiftImpact,
2487 dimensions: dimensions,
2488 afterCritical: afterCritical,
2489 forceShouldAnimate: false
2490 });
2491
2492 if (state.phase === 'COLLECTING') {
2493 return draggingState;
2494 }
2495
2496 var dropPending = _extends({
2497 phase: 'DROP_PENDING'
2498 }, draggingState, {
2499 phase: 'DROP_PENDING',
2500 reason: state.reason,
2501 isWaiting: false
2502 });
2503
2504 return dropPending;
2505});
2506
2507var isSnapping = function isSnapping(state) {
2508 return state.movementMode === 'SNAP';
2509};
2510
2511var postDroppableChange = function postDroppableChange(state, updated, isEnabledChanging) {
2512 var dimensions = patchDimensionMap(state.dimensions, updated);
2513
2514 if (!isSnapping(state) || isEnabledChanging) {
2515 return update({
2516 state: state,
2517 dimensions: dimensions
2518 });
2519 }
2520
2521 return refreshSnap({
2522 state: state,
2523 dimensions: dimensions
2524 });
2525};
2526
2527function removeScrollJumpRequest(state) {
2528 if (state.isDragging && state.movementMode === 'SNAP') {
2529 return _extends({
2530 phase: 'DRAGGING'
2531 }, state, {
2532 scrollJumpRequest: null
2533 });
2534 }
2535
2536 return state;
2537}
2538
2539var idle = {
2540 phase: 'IDLE',
2541 completed: null,
2542 shouldFlush: false
2543};
2544var reducer = (function (state, action) {
2545 if (state === void 0) {
2546 state = idle;
2547 }
2548
2549 if (action.type === 'FLUSH') {
2550 return _extends({}, idle, {
2551 shouldFlush: true
2552 });
2553 }
2554
2555 if (action.type === 'INITIAL_PUBLISH') {
2556 !(state.phase === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'INITIAL_PUBLISH must come after a IDLE phase') : invariant(false) : void 0;
2557 var _action$payload = action.payload,
2558 critical = _action$payload.critical,
2559 clientSelection = _action$payload.clientSelection,
2560 viewport = _action$payload.viewport,
2561 dimensions = _action$payload.dimensions,
2562 movementMode = _action$payload.movementMode;
2563 var draggable = dimensions.draggables[critical.draggable.id];
2564 var home = dimensions.droppables[critical.droppable.id];
2565 var client = {
2566 selection: clientSelection,
2567 borderBoxCenter: draggable.client.borderBox.center,
2568 offset: origin
2569 };
2570 var initial = {
2571 client: client,
2572 page: {
2573 selection: add(client.selection, viewport.scroll.initial),
2574 borderBoxCenter: add(client.selection, viewport.scroll.initial),
2575 offset: add(client.selection, viewport.scroll.diff.value)
2576 }
2577 };
2578 var isWindowScrollAllowed = toDroppableList(dimensions.droppables).every(function (item) {
2579 return !item.isFixedOnPage;
2580 });
2581
2582 var _getLiftEffect = getLiftEffect({
2583 draggable: draggable,
2584 home: home,
2585 draggables: dimensions.draggables,
2586 viewport: viewport
2587 }),
2588 impact = _getLiftEffect.impact,
2589 afterCritical = _getLiftEffect.afterCritical;
2590
2591 var result = {
2592 phase: 'DRAGGING',
2593 isDragging: true,
2594 critical: critical,
2595 movementMode: movementMode,
2596 dimensions: dimensions,
2597 initial: initial,
2598 current: initial,
2599 isWindowScrollAllowed: isWindowScrollAllowed,
2600 impact: impact,
2601 afterCritical: afterCritical,
2602 onLiftImpact: impact,
2603 viewport: viewport,
2604 scrollJumpRequest: null,
2605 forceShouldAnimate: null
2606 };
2607 return result;
2608 }
2609
2610 if (action.type === 'COLLECTION_STARTING') {
2611 if (state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') {
2612 return state;
2613 }
2614
2615 !(state.phase === 'DRAGGING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Collection cannot start from phase " + state.phase) : invariant(false) : void 0;
2616
2617 var _result = _extends({
2618 phase: 'COLLECTING'
2619 }, state, {
2620 phase: 'COLLECTING'
2621 });
2622
2623 return _result;
2624 }
2625
2626 if (action.type === 'PUBLISH_WHILE_DRAGGING') {
2627 !(state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Unexpected " + action.type + " received in phase " + state.phase) : invariant(false) : void 0;
2628 return publishWhileDraggingInVirtual({
2629 state: state,
2630 published: action.payload
2631 });
2632 }
2633
2634 if (action.type === 'MOVE') {
2635 if (state.phase === 'DROP_PENDING') {
2636 return state;
2637 }
2638
2639 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, action.type + " not permitted in phase " + state.phase) : invariant(false) : void 0;
2640 var _clientSelection = action.payload.client;
2641
2642 if (isEqual(_clientSelection, state.current.client.selection)) {
2643 return state;
2644 }
2645
2646 return update({
2647 state: state,
2648 clientSelection: _clientSelection,
2649 impact: isSnapping(state) ? state.impact : null
2650 });
2651 }
2652
2653 if (action.type === 'UPDATE_DROPPABLE_SCROLL') {
2654 if (state.phase === 'DROP_PENDING') {
2655 return removeScrollJumpRequest(state);
2656 }
2657
2658 if (state.phase === 'COLLECTING') {
2659 return removeScrollJumpRequest(state);
2660 }
2661
2662 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, action.type + " not permitted in phase " + state.phase) : invariant(false) : void 0;
2663 var _action$payload2 = action.payload,
2664 id = _action$payload2.id,
2665 newScroll = _action$payload2.newScroll;
2666 var target = state.dimensions.droppables[id];
2667
2668 if (!target) {
2669 return state;
2670 }
2671
2672 var scrolled = scrollDroppable(target, newScroll);
2673 return postDroppableChange(state, scrolled, false);
2674 }
2675
2676 if (action.type === 'UPDATE_DROPPABLE_IS_ENABLED') {
2677 if (state.phase === 'DROP_PENDING') {
2678 return state;
2679 }
2680
2681 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, "Attempting to move in an unsupported phase " + state.phase) : invariant(false) : void 0;
2682 var _action$payload3 = action.payload,
2683 _id = _action$payload3.id,
2684 isEnabled = _action$payload3.isEnabled;
2685 var _target = state.dimensions.droppables[_id];
2686 !_target ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find Droppable[id: " + _id + "] to toggle its enabled state") : invariant(false) : void 0;
2687 !(_target.isEnabled !== isEnabled) ? process.env.NODE_ENV !== "production" ? invariant(false, "Trying to set droppable isEnabled to " + String(isEnabled) + "\n but it is already " + String(_target.isEnabled)) : invariant(false) : void 0;
2688
2689 var updated = _extends({}, _target, {
2690 isEnabled: isEnabled
2691 });
2692
2693 return postDroppableChange(state, updated, true);
2694 }
2695
2696 if (action.type === 'UPDATE_DROPPABLE_IS_COMBINE_ENABLED') {
2697 if (state.phase === 'DROP_PENDING') {
2698 return state;
2699 }
2700
2701 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, "Attempting to move in an unsupported phase " + state.phase) : invariant(false) : void 0;
2702 var _action$payload4 = action.payload,
2703 _id2 = _action$payload4.id,
2704 isCombineEnabled = _action$payload4.isCombineEnabled;
2705 var _target2 = state.dimensions.droppables[_id2];
2706 !_target2 ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find Droppable[id: " + _id2 + "] to toggle its isCombineEnabled state") : invariant(false) : void 0;
2707 !(_target2.isCombineEnabled !== isCombineEnabled) ? process.env.NODE_ENV !== "production" ? invariant(false, "Trying to set droppable isCombineEnabled to " + String(isCombineEnabled) + "\n but it is already " + String(_target2.isCombineEnabled)) : invariant(false) : void 0;
2708
2709 var _updated = _extends({}, _target2, {
2710 isCombineEnabled: isCombineEnabled
2711 });
2712
2713 return postDroppableChange(state, _updated, true);
2714 }
2715
2716 if (action.type === 'MOVE_BY_WINDOW_SCROLL') {
2717 if (state.phase === 'DROP_PENDING' || state.phase === 'DROP_ANIMATING') {
2718 return state;
2719 }
2720
2721 !isMovementAllowed(state) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot move by window in phase " + state.phase) : invariant(false) : void 0;
2722 !state.isWindowScrollAllowed ? process.env.NODE_ENV !== "production" ? invariant(false, 'Window scrolling is currently not supported for fixed lists') : invariant(false) : void 0;
2723 var _newScroll = action.payload.newScroll;
2724
2725 if (isEqual(state.viewport.scroll.current, _newScroll)) {
2726 return removeScrollJumpRequest(state);
2727 }
2728
2729 var _viewport = scrollViewport(state.viewport, _newScroll);
2730
2731 if (isSnapping(state)) {
2732 return refreshSnap({
2733 state: state,
2734 viewport: _viewport
2735 });
2736 }
2737
2738 return update({
2739 state: state,
2740 viewport: _viewport
2741 });
2742 }
2743
2744 if (action.type === 'UPDATE_VIEWPORT_MAX_SCROLL') {
2745 if (!isMovementAllowed(state)) {
2746 return state;
2747 }
2748
2749 var maxScroll = action.payload.maxScroll;
2750
2751 if (isEqual(maxScroll, state.viewport.scroll.max)) {
2752 return state;
2753 }
2754
2755 var withMaxScroll = _extends({}, state.viewport, {
2756 scroll: _extends({}, state.viewport.scroll, {
2757 max: maxScroll
2758 })
2759 });
2760
2761 return _extends({
2762 phase: 'DRAGGING'
2763 }, state, {
2764 viewport: withMaxScroll
2765 });
2766 }
2767
2768 if (action.type === 'MOVE_UP' || action.type === 'MOVE_DOWN' || action.type === 'MOVE_LEFT' || action.type === 'MOVE_RIGHT') {
2769 if (state.phase === 'COLLECTING' || state.phase === 'DROP_PENDING') {
2770 return state;
2771 }
2772
2773 !(state.phase === 'DRAGGING') ? process.env.NODE_ENV !== "production" ? invariant(false, action.type + " received while not in DRAGGING phase") : invariant(false) : void 0;
2774
2775 var _result2 = moveInDirection({
2776 state: state,
2777 type: action.type
2778 });
2779
2780 if (!_result2) {
2781 return state;
2782 }
2783
2784 return update({
2785 state: state,
2786 impact: _result2.impact,
2787 clientSelection: _result2.clientSelection,
2788 scrollJumpRequest: _result2.scrollJumpRequest
2789 });
2790 }
2791
2792 if (action.type === 'DROP_PENDING') {
2793 var reason = action.payload.reason;
2794 !(state.phase === 'COLLECTING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only move into the DROP_PENDING phase from the COLLECTING phase') : invariant(false) : void 0;
2795
2796 var newState = _extends({
2797 phase: 'DROP_PENDING'
2798 }, state, {
2799 phase: 'DROP_PENDING',
2800 isWaiting: true,
2801 reason: reason
2802 });
2803
2804 return newState;
2805 }
2806
2807 if (action.type === 'DROP_ANIMATE') {
2808 var _action$payload5 = action.payload,
2809 completed = _action$payload5.completed,
2810 dropDuration = _action$payload5.dropDuration,
2811 newHomeClientOffset = _action$payload5.newHomeClientOffset;
2812 !(state.phase === 'DRAGGING' || state.phase === 'DROP_PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot animate drop from phase " + state.phase) : invariant(false) : void 0;
2813 var _result3 = {
2814 phase: 'DROP_ANIMATING',
2815 completed: completed,
2816 dropDuration: dropDuration,
2817 newHomeClientOffset: newHomeClientOffset,
2818 dimensions: state.dimensions
2819 };
2820 return _result3;
2821 }
2822
2823 if (action.type === 'DROP_COMPLETE') {
2824 var _completed = action.payload.completed;
2825 return {
2826 phase: 'IDLE',
2827 completed: _completed,
2828 shouldFlush: false
2829 };
2830 }
2831
2832 return state;
2833});
2834
2835var beforeInitialCapture = function beforeInitialCapture(args) {
2836 return {
2837 type: 'BEFORE_INITIAL_CAPTURE',
2838 payload: args
2839 };
2840};
2841var lift = function lift(args) {
2842 return {
2843 type: 'LIFT',
2844 payload: args
2845 };
2846};
2847var initialPublish = function initialPublish(args) {
2848 return {
2849 type: 'INITIAL_PUBLISH',
2850 payload: args
2851 };
2852};
2853var publishWhileDragging = function publishWhileDragging(args) {
2854 return {
2855 type: 'PUBLISH_WHILE_DRAGGING',
2856 payload: args
2857 };
2858};
2859var collectionStarting = function collectionStarting() {
2860 return {
2861 type: 'COLLECTION_STARTING',
2862 payload: null
2863 };
2864};
2865var updateDroppableScroll = function updateDroppableScroll(args) {
2866 return {
2867 type: 'UPDATE_DROPPABLE_SCROLL',
2868 payload: args
2869 };
2870};
2871var updateDroppableIsEnabled = function updateDroppableIsEnabled(args) {
2872 return {
2873 type: 'UPDATE_DROPPABLE_IS_ENABLED',
2874 payload: args
2875 };
2876};
2877var updateDroppableIsCombineEnabled = function updateDroppableIsCombineEnabled(args) {
2878 return {
2879 type: 'UPDATE_DROPPABLE_IS_COMBINE_ENABLED',
2880 payload: args
2881 };
2882};
2883var move = function move(args) {
2884 return {
2885 type: 'MOVE',
2886 payload: args
2887 };
2888};
2889var moveByWindowScroll = function moveByWindowScroll(args) {
2890 return {
2891 type: 'MOVE_BY_WINDOW_SCROLL',
2892 payload: args
2893 };
2894};
2895var updateViewportMaxScroll = function updateViewportMaxScroll(args) {
2896 return {
2897 type: 'UPDATE_VIEWPORT_MAX_SCROLL',
2898 payload: args
2899 };
2900};
2901var moveUp = function moveUp() {
2902 return {
2903 type: 'MOVE_UP',
2904 payload: null
2905 };
2906};
2907var moveDown = function moveDown() {
2908 return {
2909 type: 'MOVE_DOWN',
2910 payload: null
2911 };
2912};
2913var moveRight = function moveRight() {
2914 return {
2915 type: 'MOVE_RIGHT',
2916 payload: null
2917 };
2918};
2919var moveLeft = function moveLeft() {
2920 return {
2921 type: 'MOVE_LEFT',
2922 payload: null
2923 };
2924};
2925var flush = function flush() {
2926 return {
2927 type: 'FLUSH',
2928 payload: null
2929 };
2930};
2931var animateDrop = function animateDrop(args) {
2932 return {
2933 type: 'DROP_ANIMATE',
2934 payload: args
2935 };
2936};
2937var completeDrop = function completeDrop(args) {
2938 return {
2939 type: 'DROP_COMPLETE',
2940 payload: args
2941 };
2942};
2943var drop = function drop(args) {
2944 return {
2945 type: 'DROP',
2946 payload: args
2947 };
2948};
2949var dropPending = function dropPending(args) {
2950 return {
2951 type: 'DROP_PENDING',
2952 payload: args
2953 };
2954};
2955var dropAnimationFinished = function dropAnimationFinished() {
2956 return {
2957 type: 'DROP_ANIMATION_FINISHED',
2958 payload: null
2959 };
2960};
2961
2962function checkIndexes(insideDestination) {
2963 if (insideDestination.length <= 1) {
2964 return;
2965 }
2966
2967 var indexes = insideDestination.map(function (d) {
2968 return d.descriptor.index;
2969 });
2970 var errors = {};
2971
2972 for (var i = 1; i < indexes.length; i++) {
2973 var current = indexes[i];
2974 var previous = indexes[i - 1];
2975
2976 if (current !== previous + 1) {
2977 errors[current] = true;
2978 }
2979 }
2980
2981 if (!Object.keys(errors).length) {
2982 return;
2983 }
2984
2985 var formatted = indexes.map(function (index) {
2986 var hasError = Boolean(errors[index]);
2987 return hasError ? "[\uD83D\uDD25" + index + "]" : "" + index;
2988 }).join(', ');
2989 process.env.NODE_ENV !== "production" ? warning("\n Detected non-consecutive <Draggable /> indexes.\n\n (This can cause unexpected bugs)\n\n " + formatted + "\n ") : void 0;
2990}
2991
2992function validateDimensions(critical, dimensions) {
2993 if (process.env.NODE_ENV !== 'production') {
2994 var insideDestination = getDraggablesInsideDroppable(critical.droppable.id, dimensions.draggables);
2995 checkIndexes(insideDestination);
2996 }
2997}
2998
2999var lift$1 = (function (marshal) {
3000 return function (_ref) {
3001 var getState = _ref.getState,
3002 dispatch = _ref.dispatch;
3003 return function (next) {
3004 return function (action) {
3005 if (action.type !== 'LIFT') {
3006 next(action);
3007 return;
3008 }
3009
3010 var _action$payload = action.payload,
3011 id = _action$payload.id,
3012 clientSelection = _action$payload.clientSelection,
3013 movementMode = _action$payload.movementMode;
3014 var initial = getState();
3015
3016 if (initial.phase === 'DROP_ANIMATING') {
3017 dispatch(completeDrop({
3018 completed: initial.completed
3019 }));
3020 }
3021
3022 !(getState().phase === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Unexpected phase to start a drag') : invariant(false) : void 0;
3023 dispatch(flush());
3024 dispatch(beforeInitialCapture({
3025 draggableId: id,
3026 movementMode: movementMode
3027 }));
3028 var scrollOptions = {
3029 shouldPublishImmediately: movementMode === 'SNAP'
3030 };
3031 var request = {
3032 draggableId: id,
3033 scrollOptions: scrollOptions
3034 };
3035
3036 var _marshal$startPublish = marshal.startPublishing(request),
3037 critical = _marshal$startPublish.critical,
3038 dimensions = _marshal$startPublish.dimensions,
3039 viewport = _marshal$startPublish.viewport;
3040
3041 validateDimensions(critical, dimensions);
3042 dispatch(initialPublish({
3043 critical: critical,
3044 dimensions: dimensions,
3045 clientSelection: clientSelection,
3046 movementMode: movementMode,
3047 viewport: viewport
3048 }));
3049 };
3050 };
3051 };
3052});
3053
3054var style = (function (marshal) {
3055 return function () {
3056 return function (next) {
3057 return function (action) {
3058 if (action.type === 'INITIAL_PUBLISH') {
3059 marshal.dragging();
3060 }
3061
3062 if (action.type === 'DROP_ANIMATE') {
3063 marshal.dropping(action.payload.completed.result.reason);
3064 }
3065
3066 if (action.type === 'FLUSH' || action.type === 'DROP_COMPLETE') {
3067 marshal.resting();
3068 }
3069
3070 next(action);
3071 };
3072 };
3073 };
3074});
3075
3076var curves = {
3077 outOfTheWay: 'cubic-bezier(0.2, 0, 0, 1)',
3078 drop: 'cubic-bezier(.2,1,.1,1)'
3079};
3080var combine = {
3081 opacity: {
3082 drop: 0,
3083 combining: 0.7
3084 },
3085 scale: {
3086 drop: 0.75
3087 }
3088};
3089var timings = {
3090 outOfTheWay: 0.2,
3091 minDropTime: 0.33,
3092 maxDropTime: 0.55
3093};
3094var outOfTheWayTiming = timings.outOfTheWay + "s " + curves.outOfTheWay;
3095var transitions = {
3096 fluid: "opacity " + outOfTheWayTiming,
3097 snap: "transform " + outOfTheWayTiming + ", opacity " + outOfTheWayTiming,
3098 drop: function drop(duration) {
3099 var timing = duration + "s " + curves.drop;
3100 return "transform " + timing + ", opacity " + timing;
3101 },
3102 outOfTheWay: "transform " + outOfTheWayTiming,
3103 placeholder: "height " + outOfTheWayTiming + ", width " + outOfTheWayTiming + ", margin " + outOfTheWayTiming
3104};
3105
3106var moveTo = function moveTo(offset) {
3107 return isEqual(offset, origin) ? null : "translate(" + offset.x + "px, " + offset.y + "px)";
3108};
3109
3110var transforms = {
3111 moveTo: moveTo,
3112 drop: function drop(offset, isCombining) {
3113 var translate = moveTo(offset);
3114
3115 if (!translate) {
3116 return null;
3117 }
3118
3119 if (!isCombining) {
3120 return translate;
3121 }
3122
3123 return translate + " scale(" + combine.scale.drop + ")";
3124 }
3125};
3126
3127var minDropTime = timings.minDropTime,
3128 maxDropTime = timings.maxDropTime;
3129var dropTimeRange = maxDropTime - minDropTime;
3130var maxDropTimeAtDistance = 1500;
3131var cancelDropModifier = 0.6;
3132var getDropDuration = (function (_ref) {
3133 var current = _ref.current,
3134 destination = _ref.destination,
3135 reason = _ref.reason;
3136 var distance$1 = distance(current, destination);
3137
3138 if (distance$1 <= 0) {
3139 return minDropTime;
3140 }
3141
3142 if (distance$1 >= maxDropTimeAtDistance) {
3143 return maxDropTime;
3144 }
3145
3146 var percentage = distance$1 / maxDropTimeAtDistance;
3147 var duration = minDropTime + dropTimeRange * percentage;
3148 var withDuration = reason === 'CANCEL' ? duration * cancelDropModifier : duration;
3149 return Number(withDuration.toFixed(2));
3150});
3151
3152var getNewHomeClientOffset = (function (_ref) {
3153 var impact = _ref.impact,
3154 draggable = _ref.draggable,
3155 dimensions = _ref.dimensions,
3156 viewport = _ref.viewport,
3157 afterCritical = _ref.afterCritical;
3158 var draggables = dimensions.draggables,
3159 droppables = dimensions.droppables;
3160 var droppableId = whatIsDraggedOver(impact);
3161 var destination = droppableId ? droppables[droppableId] : null;
3162 var home = droppables[draggable.descriptor.droppableId];
3163 var newClientCenter = getClientBorderBoxCenter({
3164 impact: impact,
3165 draggable: draggable,
3166 draggables: draggables,
3167 afterCritical: afterCritical,
3168 droppable: destination || home,
3169 viewport: viewport
3170 });
3171 var offset = subtract(newClientCenter, draggable.client.borderBox.center);
3172 return offset;
3173});
3174
3175var getDropImpact = (function (_ref) {
3176 var draggables = _ref.draggables,
3177 reason = _ref.reason,
3178 lastImpact = _ref.lastImpact,
3179 home = _ref.home,
3180 viewport = _ref.viewport,
3181 onLiftImpact = _ref.onLiftImpact;
3182
3183 if (!lastImpact.at || reason !== 'DROP') {
3184 var recomputedHomeImpact = recompute({
3185 draggables: draggables,
3186 impact: onLiftImpact,
3187 destination: home,
3188 viewport: viewport,
3189 forceShouldAnimate: true
3190 });
3191 return {
3192 impact: recomputedHomeImpact,
3193 didDropInsideDroppable: false
3194 };
3195 }
3196
3197 if (lastImpact.at.type === 'REORDER') {
3198 return {
3199 impact: lastImpact,
3200 didDropInsideDroppable: true
3201 };
3202 }
3203
3204 var withoutMovement = _extends({}, lastImpact, {
3205 displaced: emptyGroups
3206 });
3207
3208 return {
3209 impact: withoutMovement,
3210 didDropInsideDroppable: true
3211 };
3212});
3213
3214var drop$1 = (function (_ref) {
3215 var getState = _ref.getState,
3216 dispatch = _ref.dispatch;
3217 return function (next) {
3218 return function (action) {
3219 if (action.type !== 'DROP') {
3220 next(action);
3221 return;
3222 }
3223
3224 var state = getState();
3225 var reason = action.payload.reason;
3226
3227 if (state.phase === 'COLLECTING') {
3228 dispatch(dropPending({
3229 reason: reason
3230 }));
3231 return;
3232 }
3233
3234 if (state.phase === 'IDLE') {
3235 return;
3236 }
3237
3238 var isWaitingForDrop = state.phase === 'DROP_PENDING' && state.isWaiting;
3239 !!isWaitingForDrop ? process.env.NODE_ENV !== "production" ? invariant(false, 'A DROP action occurred while DROP_PENDING and still waiting') : invariant(false) : void 0;
3240 !(state.phase === 'DRAGGING' || state.phase === 'DROP_PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot drop in phase: " + state.phase) : invariant(false) : void 0;
3241 var critical = state.critical;
3242 var dimensions = state.dimensions;
3243 var draggable = dimensions.draggables[state.critical.draggable.id];
3244
3245 var _getDropImpact = getDropImpact({
3246 reason: reason,
3247 lastImpact: state.impact,
3248 afterCritical: state.afterCritical,
3249 onLiftImpact: state.onLiftImpact,
3250 home: state.dimensions.droppables[state.critical.droppable.id],
3251 viewport: state.viewport,
3252 draggables: state.dimensions.draggables
3253 }),
3254 impact = _getDropImpact.impact,
3255 didDropInsideDroppable = _getDropImpact.didDropInsideDroppable;
3256
3257 var destination = didDropInsideDroppable ? tryGetDestination(impact) : null;
3258 var combine = didDropInsideDroppable ? tryGetCombine(impact) : null;
3259 var source = {
3260 index: critical.draggable.index,
3261 droppableId: critical.droppable.id
3262 };
3263 var result = {
3264 draggableId: draggable.descriptor.id,
3265 type: draggable.descriptor.type,
3266 source: source,
3267 reason: reason,
3268 mode: state.movementMode,
3269 destination: destination,
3270 combine: combine
3271 };
3272 var newHomeClientOffset = getNewHomeClientOffset({
3273 impact: impact,
3274 draggable: draggable,
3275 dimensions: dimensions,
3276 viewport: state.viewport,
3277 afterCritical: state.afterCritical
3278 });
3279 var completed = {
3280 critical: state.critical,
3281 afterCritical: state.afterCritical,
3282 result: result,
3283 impact: impact
3284 };
3285 var isAnimationRequired = !isEqual(state.current.client.offset, newHomeClientOffset) || Boolean(result.combine);
3286
3287 if (!isAnimationRequired) {
3288 dispatch(completeDrop({
3289 completed: completed
3290 }));
3291 return;
3292 }
3293
3294 var dropDuration = getDropDuration({
3295 current: state.current.client.offset,
3296 destination: newHomeClientOffset,
3297 reason: reason
3298 });
3299 var args = {
3300 newHomeClientOffset: newHomeClientOffset,
3301 dropDuration: dropDuration,
3302 completed: completed
3303 };
3304 dispatch(animateDrop(args));
3305 };
3306 };
3307});
3308
3309var getWindowScroll = (function () {
3310 return {
3311 x: window.pageXOffset,
3312 y: window.pageYOffset
3313 };
3314});
3315
3316function getWindowScrollBinding(update) {
3317 return {
3318 eventName: 'scroll',
3319 options: {
3320 passive: true,
3321 capture: false
3322 },
3323 fn: function fn(event) {
3324 if (event.target !== window && event.target !== window.document) {
3325 return;
3326 }
3327
3328 update();
3329 }
3330 };
3331}
3332
3333function getScrollListener(_ref) {
3334 var onWindowScroll = _ref.onWindowScroll;
3335
3336 function updateScroll() {
3337 onWindowScroll(getWindowScroll());
3338 }
3339
3340 var scheduled = rafSchd(updateScroll);
3341 var binding = getWindowScrollBinding(scheduled);
3342 var unbind = noop;
3343
3344 function isActive() {
3345 return unbind !== noop;
3346 }
3347
3348 function start() {
3349 !!isActive() ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot start scroll listener when already active') : invariant(false) : void 0;
3350 unbind = bindEvents(window, [binding]);
3351 }
3352
3353 function stop() {
3354 !isActive() ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot stop scroll listener when not active') : invariant(false) : void 0;
3355 scheduled.cancel();
3356 unbind();
3357 unbind = noop;
3358 }
3359
3360 return {
3361 start: start,
3362 stop: stop,
3363 isActive: isActive
3364 };
3365}
3366
3367var shouldEnd = function shouldEnd(action) {
3368 return action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATE' || action.type === 'FLUSH';
3369};
3370
3371var scrollListener = (function (store) {
3372 var listener = getScrollListener({
3373 onWindowScroll: function onWindowScroll(newScroll) {
3374 store.dispatch(moveByWindowScroll({
3375 newScroll: newScroll
3376 }));
3377 }
3378 });
3379 return function (next) {
3380 return function (action) {
3381 if (!listener.isActive() && action.type === 'INITIAL_PUBLISH') {
3382 listener.start();
3383 }
3384
3385 if (listener.isActive() && shouldEnd(action)) {
3386 listener.stop();
3387 }
3388
3389 next(action);
3390 };
3391 };
3392});
3393
3394var getExpiringAnnounce = (function (announce) {
3395 var wasCalled = false;
3396 var isExpired = false;
3397 var timeoutId = setTimeout(function () {
3398 isExpired = true;
3399 });
3400
3401 var result = function result(message) {
3402 if (wasCalled) {
3403 process.env.NODE_ENV !== "production" ? warning('Announcement already made. Not making a second announcement') : void 0;
3404 return;
3405 }
3406
3407 if (isExpired) {
3408 process.env.NODE_ENV !== "production" ? warning("\n Announcements cannot be made asynchronously.\n Default message has already been announced.\n ") : void 0;
3409 return;
3410 }
3411
3412 wasCalled = true;
3413 announce(message);
3414 clearTimeout(timeoutId);
3415 };
3416
3417 result.wasCalled = function () {
3418 return wasCalled;
3419 };
3420
3421 return result;
3422});
3423
3424var getAsyncMarshal = (function () {
3425 var entries = [];
3426
3427 var execute = function execute(timerId) {
3428 var index = findIndex(entries, function (item) {
3429 return item.timerId === timerId;
3430 });
3431 !(index !== -1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find timer') : invariant(false) : void 0;
3432
3433 var _entries$splice = entries.splice(index, 1),
3434 entry = _entries$splice[0];
3435
3436 entry.callback();
3437 };
3438
3439 var add = function add(fn) {
3440 var timerId = setTimeout(function () {
3441 return execute(timerId);
3442 });
3443 var entry = {
3444 timerId: timerId,
3445 callback: fn
3446 };
3447 entries.push(entry);
3448 };
3449
3450 var flush = function flush() {
3451 if (!entries.length) {
3452 return;
3453 }
3454
3455 var shallow = [].concat(entries);
3456 entries.length = 0;
3457 shallow.forEach(function (entry) {
3458 clearTimeout(entry.timerId);
3459 entry.callback();
3460 });
3461 };
3462
3463 return {
3464 add: add,
3465 flush: flush
3466 };
3467});
3468
3469var areLocationsEqual = function areLocationsEqual(first, second) {
3470 if (first == null && second == null) {
3471 return true;
3472 }
3473
3474 if (first == null || second == null) {
3475 return false;
3476 }
3477
3478 return first.droppableId === second.droppableId && first.index === second.index;
3479};
3480var isCombineEqual = function isCombineEqual(first, second) {
3481 if (first == null && second == null) {
3482 return true;
3483 }
3484
3485 if (first == null || second == null) {
3486 return false;
3487 }
3488
3489 return first.draggableId === second.draggableId && first.droppableId === second.droppableId;
3490};
3491var isCriticalEqual = function isCriticalEqual(first, second) {
3492 if (first === second) {
3493 return true;
3494 }
3495
3496 var isDraggableEqual = first.draggable.id === second.draggable.id && first.draggable.droppableId === second.draggable.droppableId && first.draggable.type === second.draggable.type && first.draggable.index === second.draggable.index;
3497 var isDroppableEqual = first.droppable.id === second.droppable.id && first.droppable.type === second.droppable.type;
3498 return isDraggableEqual && isDroppableEqual;
3499};
3500
3501var withTimings = function withTimings(key, fn) {
3502 start();
3503 fn();
3504 finish();
3505};
3506
3507var getDragStart = function getDragStart(critical, mode) {
3508 return {
3509 draggableId: critical.draggable.id,
3510 type: critical.droppable.type,
3511 source: {
3512 droppableId: critical.droppable.id,
3513 index: critical.draggable.index
3514 },
3515 mode: mode
3516 };
3517};
3518
3519var execute = function execute(responder, data, announce, getDefaultMessage) {
3520 if (!responder) {
3521 announce(getDefaultMessage(data));
3522 return;
3523 }
3524
3525 var willExpire = getExpiringAnnounce(announce);
3526 var provided = {
3527 announce: willExpire
3528 };
3529 responder(data, provided);
3530
3531 if (!willExpire.wasCalled()) {
3532 announce(getDefaultMessage(data));
3533 }
3534};
3535
3536var getPublisher = (function (getResponders, announce) {
3537 var asyncMarshal = getAsyncMarshal();
3538 var dragging = null;
3539
3540 var beforeCapture = function beforeCapture(draggableId, mode) {
3541 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onBeforeCapture as a drag start has already been published') : invariant(false) : void 0;
3542 withTimings('onBeforeCapture', function () {
3543 var fn = getResponders().onBeforeCapture;
3544
3545 if (fn) {
3546 var before = {
3547 draggableId: draggableId,
3548 mode: mode
3549 };
3550 fn(before);
3551 }
3552 });
3553 };
3554
3555 var beforeStart = function beforeStart(critical, mode) {
3556 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onBeforeDragStart as a drag start has already been published') : invariant(false) : void 0;
3557 withTimings('onBeforeDragStart', function () {
3558 var fn = getResponders().onBeforeDragStart;
3559
3560 if (fn) {
3561 fn(getDragStart(critical, mode));
3562 }
3563 });
3564 };
3565
3566 var start = function start(critical, mode) {
3567 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onBeforeDragStart as a drag start has already been published') : invariant(false) : void 0;
3568 var data = getDragStart(critical, mode);
3569 dragging = {
3570 mode: mode,
3571 lastCritical: critical,
3572 lastLocation: data.source,
3573 lastCombine: null
3574 };
3575 asyncMarshal.add(function () {
3576 withTimings('onDragStart', function () {
3577 return execute(getResponders().onDragStart, data, announce, preset.onDragStart);
3578 });
3579 });
3580 };
3581
3582 var update = function update(critical, impact) {
3583 var location = tryGetDestination(impact);
3584 var combine = tryGetCombine(impact);
3585 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onDragMove when onDragStart has not been called') : invariant(false) : void 0;
3586 var hasCriticalChanged = !isCriticalEqual(critical, dragging.lastCritical);
3587
3588 if (hasCriticalChanged) {
3589 dragging.lastCritical = critical;
3590 }
3591
3592 var hasLocationChanged = !areLocationsEqual(dragging.lastLocation, location);
3593
3594 if (hasLocationChanged) {
3595 dragging.lastLocation = location;
3596 }
3597
3598 var hasGroupingChanged = !isCombineEqual(dragging.lastCombine, combine);
3599
3600 if (hasGroupingChanged) {
3601 dragging.lastCombine = combine;
3602 }
3603
3604 if (!hasCriticalChanged && !hasLocationChanged && !hasGroupingChanged) {
3605 return;
3606 }
3607
3608 var data = _extends({}, getDragStart(critical, dragging.mode), {
3609 combine: combine,
3610 destination: location
3611 });
3612
3613 asyncMarshal.add(function () {
3614 withTimings('onDragUpdate', function () {
3615 return execute(getResponders().onDragUpdate, data, announce, preset.onDragUpdate);
3616 });
3617 });
3618 };
3619
3620 var flush = function flush() {
3621 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only flush responders while dragging') : invariant(false) : void 0;
3622 asyncMarshal.flush();
3623 };
3624
3625 var drop = function drop(result) {
3626 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fire onDragEnd when there is no matching onDragStart') : invariant(false) : void 0;
3627 dragging = null;
3628 withTimings('onDragEnd', function () {
3629 return execute(getResponders().onDragEnd, result, announce, preset.onDragEnd);
3630 });
3631 };
3632
3633 var abort = function abort() {
3634 if (!dragging) {
3635 return;
3636 }
3637
3638 var result = _extends({}, getDragStart(dragging.lastCritical, dragging.mode), {
3639 combine: null,
3640 destination: null,
3641 reason: 'CANCEL'
3642 });
3643
3644 drop(result);
3645 };
3646
3647 return {
3648 beforeCapture: beforeCapture,
3649 beforeStart: beforeStart,
3650 start: start,
3651 update: update,
3652 flush: flush,
3653 drop: drop,
3654 abort: abort
3655 };
3656});
3657
3658var responders = (function (getResponders, announce) {
3659 var publisher = getPublisher(getResponders, announce);
3660 return function (store) {
3661 return function (next) {
3662 return function (action) {
3663 if (action.type === 'BEFORE_INITIAL_CAPTURE') {
3664 publisher.beforeCapture(action.payload.draggableId, action.payload.movementMode);
3665 return;
3666 }
3667
3668 if (action.type === 'INITIAL_PUBLISH') {
3669 var critical = action.payload.critical;
3670 publisher.beforeStart(critical, action.payload.movementMode);
3671 next(action);
3672 publisher.start(critical, action.payload.movementMode);
3673 return;
3674 }
3675
3676 if (action.type === 'DROP_COMPLETE') {
3677 var result = action.payload.completed.result;
3678 publisher.flush();
3679 next(action);
3680 publisher.drop(result);
3681 return;
3682 }
3683
3684 next(action);
3685
3686 if (action.type === 'FLUSH') {
3687 publisher.abort();
3688 return;
3689 }
3690
3691 var state = store.getState();
3692
3693 if (state.phase === 'DRAGGING') {
3694 publisher.update(state.critical, state.impact);
3695 }
3696 };
3697 };
3698 };
3699});
3700
3701var dropAnimationFinish = (function (store) {
3702 return function (next) {
3703 return function (action) {
3704 if (action.type !== 'DROP_ANIMATION_FINISHED') {
3705 next(action);
3706 return;
3707 }
3708
3709 var state = store.getState();
3710 !(state.phase === 'DROP_ANIMATING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot finish a drop animating when no drop is occurring') : invariant(false) : void 0;
3711 store.dispatch(completeDrop({
3712 completed: state.completed
3713 }));
3714 };
3715 };
3716});
3717
3718var dropAnimationFlushOnScroll = (function (store) {
3719 var unbind = null;
3720 var frameId = null;
3721
3722 function clear() {
3723 if (frameId) {
3724 cancelAnimationFrame(frameId);
3725 frameId = null;
3726 }
3727
3728 if (unbind) {
3729 unbind();
3730 unbind = null;
3731 }
3732 }
3733
3734 return function (next) {
3735 return function (action) {
3736 if (action.type === 'FLUSH' || action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATION_FINISHED') {
3737 clear();
3738 }
3739
3740 next(action);
3741
3742 if (action.type !== 'DROP_ANIMATE') {
3743 return;
3744 }
3745
3746 var binding = {
3747 eventName: 'scroll',
3748 options: {
3749 capture: true,
3750 passive: false,
3751 once: true
3752 },
3753 fn: function flushDropAnimation() {
3754 var state = store.getState();
3755
3756 if (state.phase === 'DROP_ANIMATING') {
3757 store.dispatch(dropAnimationFinished());
3758 }
3759 }
3760 };
3761 frameId = requestAnimationFrame(function () {
3762 frameId = null;
3763 unbind = bindEvents(window, [binding]);
3764 });
3765 };
3766 };
3767});
3768
3769var dimensionMarshalStopper = (function (marshal) {
3770 return function () {
3771 return function (next) {
3772 return function (action) {
3773 if (action.type === 'DROP_COMPLETE' || action.type === 'FLUSH' || action.type === 'DROP_ANIMATE') {
3774 marshal.stopPublishing();
3775 }
3776
3777 next(action);
3778 };
3779 };
3780 };
3781});
3782
3783var focus = (function (marshal) {
3784 var isWatching = false;
3785 return function () {
3786 return function (next) {
3787 return function (action) {
3788 if (action.type === 'INITIAL_PUBLISH') {
3789 isWatching = true;
3790 marshal.tryRecordFocus(action.payload.critical.draggable.id);
3791 next(action);
3792 marshal.tryRestoreFocusRecorded();
3793 return;
3794 }
3795
3796 next(action);
3797
3798 if (!isWatching) {
3799 return;
3800 }
3801
3802 if (action.type === 'FLUSH') {
3803 isWatching = false;
3804 marshal.tryRestoreFocusRecorded();
3805 return;
3806 }
3807
3808 if (action.type === 'DROP_COMPLETE') {
3809 isWatching = false;
3810 var result = action.payload.completed.result;
3811
3812 if (result.combine) {
3813 marshal.tryShiftRecord(result.draggableId, result.combine.draggableId);
3814 }
3815
3816 marshal.tryRestoreFocusRecorded();
3817 }
3818 };
3819 };
3820 };
3821});
3822
3823var shouldStop = function shouldStop(action) {
3824 return action.type === 'DROP_COMPLETE' || action.type === 'DROP_ANIMATE' || action.type === 'FLUSH';
3825};
3826
3827var autoScroll = (function (autoScroller) {
3828 return function (store) {
3829 return function (next) {
3830 return function (action) {
3831 if (shouldStop(action)) {
3832 autoScroller.stop();
3833 next(action);
3834 return;
3835 }
3836
3837 if (action.type === 'INITIAL_PUBLISH') {
3838 next(action);
3839 var state = store.getState();
3840 !(state.phase === 'DRAGGING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected phase to be DRAGGING after INITIAL_PUBLISH') : invariant(false) : void 0;
3841 autoScroller.start(state);
3842 return;
3843 }
3844
3845 next(action);
3846 autoScroller.scroll(store.getState());
3847 };
3848 };
3849 };
3850});
3851
3852var pendingDrop = (function (store) {
3853 return function (next) {
3854 return function (action) {
3855 next(action);
3856
3857 if (action.type !== 'PUBLISH_WHILE_DRAGGING') {
3858 return;
3859 }
3860
3861 var postActionState = store.getState();
3862
3863 if (postActionState.phase !== 'DROP_PENDING') {
3864 return;
3865 }
3866
3867 if (postActionState.isWaiting) {
3868 return;
3869 }
3870
3871 store.dispatch(drop({
3872 reason: postActionState.reason
3873 }));
3874 };
3875 };
3876});
3877
3878var composeEnhancers = process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
3879 name: 'react-beautiful-dnd'
3880}) : compose;
3881var createStore = (function (_ref) {
3882 var dimensionMarshal = _ref.dimensionMarshal,
3883 focusMarshal = _ref.focusMarshal,
3884 styleMarshal = _ref.styleMarshal,
3885 getResponders = _ref.getResponders,
3886 announce = _ref.announce,
3887 autoScroller = _ref.autoScroller;
3888 return createStore$1(reducer, composeEnhancers(applyMiddleware(style(styleMarshal), dimensionMarshalStopper(dimensionMarshal), lift$1(dimensionMarshal), drop$1, dropAnimationFinish, dropAnimationFlushOnScroll, pendingDrop, autoScroll(autoScroller), scrollListener, focus(focusMarshal), responders(getResponders, announce))));
3889});
3890
3891var clean$1 = function clean() {
3892 return {
3893 additions: {},
3894 removals: {},
3895 modified: {}
3896 };
3897};
3898function createPublisher(_ref) {
3899 var registry = _ref.registry,
3900 callbacks = _ref.callbacks;
3901 var staging = clean$1();
3902 var frameId = null;
3903
3904 var collect = function collect() {
3905 if (frameId) {
3906 return;
3907 }
3908
3909 callbacks.collectionStarting();
3910 frameId = requestAnimationFrame(function () {
3911 frameId = null;
3912 start();
3913 var _staging = staging,
3914 additions = _staging.additions,
3915 removals = _staging.removals,
3916 modified = _staging.modified;
3917 var added = Object.keys(additions).map(function (id) {
3918 return registry.draggable.getById(id).getDimension(origin);
3919 }).sort(function (a, b) {
3920 return a.descriptor.index - b.descriptor.index;
3921 });
3922 var updated = Object.keys(modified).map(function (id) {
3923 var entry = registry.droppable.getById(id);
3924 var scroll = entry.callbacks.getScrollWhileDragging();
3925 return {
3926 droppableId: id,
3927 scroll: scroll
3928 };
3929 });
3930 var result = {
3931 additions: added,
3932 removals: Object.keys(removals),
3933 modified: updated
3934 };
3935 staging = clean$1();
3936 finish();
3937 callbacks.publish(result);
3938 });
3939 };
3940
3941 var add = function add(entry) {
3942 var id = entry.descriptor.id;
3943 staging.additions[id] = entry;
3944 staging.modified[entry.descriptor.droppableId] = true;
3945
3946 if (staging.removals[id]) {
3947 delete staging.removals[id];
3948 }
3949
3950 collect();
3951 };
3952
3953 var remove = function remove(entry) {
3954 var descriptor = entry.descriptor;
3955 staging.removals[descriptor.id] = true;
3956 staging.modified[descriptor.droppableId] = true;
3957
3958 if (staging.additions[descriptor.id]) {
3959 delete staging.additions[descriptor.id];
3960 }
3961
3962 collect();
3963 };
3964
3965 var stop = function stop() {
3966 if (!frameId) {
3967 return;
3968 }
3969
3970 cancelAnimationFrame(frameId);
3971 frameId = null;
3972 staging = clean$1();
3973 };
3974
3975 return {
3976 add: add,
3977 remove: remove,
3978 stop: stop
3979 };
3980}
3981
3982var getMaxScroll = (function (_ref) {
3983 var scrollHeight = _ref.scrollHeight,
3984 scrollWidth = _ref.scrollWidth,
3985 height = _ref.height,
3986 width = _ref.width;
3987 var maxScroll = subtract({
3988 x: scrollWidth,
3989 y: scrollHeight
3990 }, {
3991 x: width,
3992 y: height
3993 });
3994 var adjustedMaxScroll = {
3995 x: Math.max(0, maxScroll.x),
3996 y: Math.max(0, maxScroll.y)
3997 };
3998 return adjustedMaxScroll;
3999});
4000
4001var getDocumentElement = (function () {
4002 var doc = document.documentElement;
4003 !doc ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot find document.documentElement') : invariant(false) : void 0;
4004 return doc;
4005});
4006
4007var getMaxWindowScroll = (function () {
4008 var doc = getDocumentElement();
4009 var maxScroll = getMaxScroll({
4010 scrollHeight: doc.scrollHeight,
4011 scrollWidth: doc.scrollWidth,
4012 width: doc.clientWidth,
4013 height: doc.clientHeight
4014 });
4015 return maxScroll;
4016});
4017
4018var getViewport = (function () {
4019 var scroll = getWindowScroll();
4020 var maxScroll = getMaxWindowScroll();
4021 var top = scroll.y;
4022 var left = scroll.x;
4023 var doc = getDocumentElement();
4024 var width = doc.clientWidth;
4025 var height = doc.clientHeight;
4026 var right = left + width;
4027 var bottom = top + height;
4028 var frame = getRect({
4029 top: top,
4030 left: left,
4031 right: right,
4032 bottom: bottom
4033 });
4034 var viewport = {
4035 frame: frame,
4036 scroll: {
4037 initial: scroll,
4038 current: scroll,
4039 max: maxScroll,
4040 diff: {
4041 value: origin,
4042 displacement: origin
4043 }
4044 }
4045 };
4046 return viewport;
4047});
4048
4049var getInitialPublish = (function (_ref) {
4050 var critical = _ref.critical,
4051 scrollOptions = _ref.scrollOptions,
4052 registry = _ref.registry;
4053 start();
4054 var viewport = getViewport();
4055 var windowScroll = viewport.scroll.current;
4056 var home = critical.droppable;
4057 var droppables = registry.droppable.getAllByType(home.type).map(function (entry) {
4058 return entry.callbacks.getDimensionAndWatchScroll(windowScroll, scrollOptions);
4059 });
4060 var draggables = registry.draggable.getAllByType(critical.draggable.type).map(function (entry) {
4061 return entry.getDimension(windowScroll);
4062 });
4063 var dimensions = {
4064 draggables: toDraggableMap(draggables),
4065 droppables: toDroppableMap(droppables)
4066 };
4067 finish();
4068 var result = {
4069 dimensions: dimensions,
4070 critical: critical,
4071 viewport: viewport
4072 };
4073 return result;
4074});
4075
4076function shouldPublishUpdate(registry, dragging, entry) {
4077 if (entry.descriptor.id === dragging.id) {
4078 return false;
4079 }
4080
4081 if (entry.descriptor.type !== dragging.type) {
4082 return false;
4083 }
4084
4085 var home = registry.droppable.getById(entry.descriptor.droppableId);
4086
4087 if (home.descriptor.mode !== 'virtual') {
4088 process.env.NODE_ENV !== "production" ? warning("\n You are attempting to add or remove a Draggable [id: " + entry.descriptor.id + "]\n while a drag is occurring. This is only supported for virtual lists.\n\n See https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/patterns/virtual-lists.md\n ") : void 0;
4089 return false;
4090 }
4091
4092 return true;
4093}
4094
4095var createDimensionMarshal = (function (registry, callbacks) {
4096 var collection = null;
4097 var publisher = createPublisher({
4098 callbacks: {
4099 publish: callbacks.publishWhileDragging,
4100 collectionStarting: callbacks.collectionStarting
4101 },
4102 registry: registry
4103 });
4104
4105 var updateDroppableIsEnabled = function updateDroppableIsEnabled(id, isEnabled) {
4106 !registry.droppable.exists(id) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot update is enabled flag of Droppable " + id + " as it is not registered") : invariant(false) : void 0;
4107
4108 if (!collection) {
4109 return;
4110 }
4111
4112 callbacks.updateDroppableIsEnabled({
4113 id: id,
4114 isEnabled: isEnabled
4115 });
4116 };
4117
4118 var updateDroppableIsCombineEnabled = function updateDroppableIsCombineEnabled(id, isCombineEnabled) {
4119 if (!collection) {
4120 return;
4121 }
4122
4123 !registry.droppable.exists(id) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot update isCombineEnabled flag of Droppable " + id + " as it is not registered") : invariant(false) : void 0;
4124 callbacks.updateDroppableIsCombineEnabled({
4125 id: id,
4126 isCombineEnabled: isCombineEnabled
4127 });
4128 };
4129
4130 var updateDroppableScroll = function updateDroppableScroll(id, newScroll) {
4131 if (!collection) {
4132 return;
4133 }
4134
4135 !registry.droppable.exists(id) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot update the scroll on Droppable " + id + " as it is not registered") : invariant(false) : void 0;
4136 callbacks.updateDroppableScroll({
4137 id: id,
4138 newScroll: newScroll
4139 });
4140 };
4141
4142 var scrollDroppable = function scrollDroppable(id, change) {
4143 if (!collection) {
4144 return;
4145 }
4146
4147 registry.droppable.getById(id).callbacks.scroll(change);
4148 };
4149
4150 var stopPublishing = function stopPublishing() {
4151 if (!collection) {
4152 return;
4153 }
4154
4155 publisher.stop();
4156 var home = collection.critical.droppable;
4157 registry.droppable.getAllByType(home.type).forEach(function (entry) {
4158 return entry.callbacks.dragStopped();
4159 });
4160 collection.unsubscribe();
4161 collection = null;
4162 };
4163
4164 var subscriber = function subscriber(event) {
4165 !collection ? process.env.NODE_ENV !== "production" ? invariant(false, 'Should only be subscribed when a collection is occurring') : invariant(false) : void 0;
4166 var dragging = collection.critical.draggable;
4167
4168 if (event.type === 'ADDITION') {
4169 if (shouldPublishUpdate(registry, dragging, event.value)) {
4170 publisher.add(event.value);
4171 }
4172 }
4173
4174 if (event.type === 'REMOVAL') {
4175 if (shouldPublishUpdate(registry, dragging, event.value)) {
4176 publisher.remove(event.value);
4177 }
4178 }
4179 };
4180
4181 var startPublishing = function startPublishing(request) {
4182 !!collection ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot start capturing critical dimensions as there is already a collection') : invariant(false) : void 0;
4183 var entry = registry.draggable.getById(request.draggableId);
4184 var home = registry.droppable.getById(entry.descriptor.droppableId);
4185 var critical = {
4186 draggable: entry.descriptor,
4187 droppable: home.descriptor
4188 };
4189 var unsubscribe = registry.subscribe(subscriber);
4190 collection = {
4191 critical: critical,
4192 unsubscribe: unsubscribe
4193 };
4194 return getInitialPublish({
4195 critical: critical,
4196 registry: registry,
4197 scrollOptions: request.scrollOptions
4198 });
4199 };
4200
4201 var marshal = {
4202 updateDroppableIsEnabled: updateDroppableIsEnabled,
4203 updateDroppableIsCombineEnabled: updateDroppableIsCombineEnabled,
4204 scrollDroppable: scrollDroppable,
4205 updateDroppableScroll: updateDroppableScroll,
4206 startPublishing: startPublishing,
4207 stopPublishing: stopPublishing
4208 };
4209 return marshal;
4210});
4211
4212var canStartDrag = (function (state, id) {
4213 if (state.phase === 'IDLE') {
4214 return true;
4215 }
4216
4217 if (state.phase !== 'DROP_ANIMATING') {
4218 return false;
4219 }
4220
4221 if (state.completed.result.draggableId === id) {
4222 return false;
4223 }
4224
4225 return state.completed.result.reason === 'DROP';
4226});
4227
4228var scrollWindow = (function (change) {
4229 window.scrollBy(change.x, change.y);
4230});
4231
4232var getScrollableDroppables = memoizeOne(function (droppables) {
4233 return toDroppableList(droppables).filter(function (droppable) {
4234 if (!droppable.isEnabled) {
4235 return false;
4236 }
4237
4238 if (!droppable.frame) {
4239 return false;
4240 }
4241
4242 return true;
4243 });
4244});
4245
4246var getScrollableDroppableOver = function getScrollableDroppableOver(target, droppables) {
4247 var maybe = find(getScrollableDroppables(droppables), function (droppable) {
4248 !droppable.frame ? process.env.NODE_ENV !== "production" ? invariant(false, 'Invalid result') : invariant(false) : void 0;
4249 return isPositionInFrame(droppable.frame.pageMarginBox)(target);
4250 });
4251 return maybe;
4252};
4253
4254var getBestScrollableDroppable = (function (_ref) {
4255 var center = _ref.center,
4256 destination = _ref.destination,
4257 droppables = _ref.droppables;
4258
4259 if (destination) {
4260 var _dimension = droppables[destination];
4261
4262 if (!_dimension.frame) {
4263 return null;
4264 }
4265
4266 return _dimension;
4267 }
4268
4269 var dimension = getScrollableDroppableOver(center, droppables);
4270 return dimension;
4271});
4272
4273var config = {
4274 startFromPercentage: 0.25,
4275 maxScrollAtPercentage: 0.05,
4276 maxPixelScroll: 28,
4277 ease: function ease(percentage) {
4278 return Math.pow(percentage, 2);
4279 },
4280 durationDampening: {
4281 stopDampeningAt: 1200,
4282 accelerateAt: 360
4283 }
4284};
4285
4286var getDistanceThresholds = (function (container, axis) {
4287 var startScrollingFrom = container[axis.size] * config.startFromPercentage;
4288 var maxScrollValueAt = container[axis.size] * config.maxScrollAtPercentage;
4289 var thresholds = {
4290 startScrollingFrom: startScrollingFrom,
4291 maxScrollValueAt: maxScrollValueAt
4292 };
4293 return thresholds;
4294});
4295
4296var getPercentage = (function (_ref) {
4297 var startOfRange = _ref.startOfRange,
4298 endOfRange = _ref.endOfRange,
4299 current = _ref.current;
4300 var range = endOfRange - startOfRange;
4301
4302 if (range === 0) {
4303 process.env.NODE_ENV !== "production" ? warning("\n Detected distance range of 0 in the fluid auto scroller\n This is unexpected and would cause a divide by 0 issue.\n Not allowing an auto scroll\n ") : void 0;
4304 return 0;
4305 }
4306
4307 var currentInRange = current - startOfRange;
4308 var percentage = currentInRange / range;
4309 return percentage;
4310});
4311
4312var minScroll = 1;
4313
4314var getValueFromDistance = (function (distanceToEdge, thresholds) {
4315 if (distanceToEdge > thresholds.startScrollingFrom) {
4316 return 0;
4317 }
4318
4319 if (distanceToEdge <= thresholds.maxScrollValueAt) {
4320 return config.maxPixelScroll;
4321 }
4322
4323 if (distanceToEdge === thresholds.startScrollingFrom) {
4324 return minScroll;
4325 }
4326
4327 var percentageFromMaxScrollValueAt = getPercentage({
4328 startOfRange: thresholds.maxScrollValueAt,
4329 endOfRange: thresholds.startScrollingFrom,
4330 current: distanceToEdge
4331 });
4332 var percentageFromStartScrollingFrom = 1 - percentageFromMaxScrollValueAt;
4333 var scroll = config.maxPixelScroll * config.ease(percentageFromStartScrollingFrom);
4334 return Math.ceil(scroll);
4335});
4336
4337var accelerateAt = config.durationDampening.accelerateAt;
4338var stopAt = config.durationDampening.stopDampeningAt;
4339var dampenValueByTime = (function (proposedScroll, dragStartTime) {
4340 var startOfRange = dragStartTime;
4341 var endOfRange = stopAt;
4342 var now = Date.now();
4343 var runTime = now - startOfRange;
4344
4345 if (runTime >= stopAt) {
4346 return proposedScroll;
4347 }
4348
4349 if (runTime < accelerateAt) {
4350 return minScroll;
4351 }
4352
4353 var betweenAccelerateAtAndStopAtPercentage = getPercentage({
4354 startOfRange: accelerateAt,
4355 endOfRange: endOfRange,
4356 current: runTime
4357 });
4358 var scroll = proposedScroll * config.ease(betweenAccelerateAtAndStopAtPercentage);
4359 return Math.ceil(scroll);
4360});
4361
4362var getValue = (function (_ref) {
4363 var distanceToEdge = _ref.distanceToEdge,
4364 thresholds = _ref.thresholds,
4365 dragStartTime = _ref.dragStartTime,
4366 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4367 var scroll = getValueFromDistance(distanceToEdge, thresholds);
4368
4369 if (scroll === 0) {
4370 return 0;
4371 }
4372
4373 if (!shouldUseTimeDampening) {
4374 return scroll;
4375 }
4376
4377 return Math.max(dampenValueByTime(scroll, dragStartTime), minScroll);
4378});
4379
4380var getScrollOnAxis = (function (_ref) {
4381 var container = _ref.container,
4382 distanceToEdges = _ref.distanceToEdges,
4383 dragStartTime = _ref.dragStartTime,
4384 axis = _ref.axis,
4385 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4386 var thresholds = getDistanceThresholds(container, axis);
4387 var isCloserToEnd = distanceToEdges[axis.end] < distanceToEdges[axis.start];
4388
4389 if (isCloserToEnd) {
4390 return getValue({
4391 distanceToEdge: distanceToEdges[axis.end],
4392 thresholds: thresholds,
4393 dragStartTime: dragStartTime,
4394 shouldUseTimeDampening: shouldUseTimeDampening
4395 });
4396 }
4397
4398 return -1 * getValue({
4399 distanceToEdge: distanceToEdges[axis.start],
4400 thresholds: thresholds,
4401 dragStartTime: dragStartTime,
4402 shouldUseTimeDampening: shouldUseTimeDampening
4403 });
4404});
4405
4406var adjustForSizeLimits = (function (_ref) {
4407 var container = _ref.container,
4408 subject = _ref.subject,
4409 proposedScroll = _ref.proposedScroll;
4410 var isTooBigVertically = subject.height > container.height;
4411 var isTooBigHorizontally = subject.width > container.width;
4412
4413 if (!isTooBigHorizontally && !isTooBigVertically) {
4414 return proposedScroll;
4415 }
4416
4417 if (isTooBigHorizontally && isTooBigVertically) {
4418 return null;
4419 }
4420
4421 return {
4422 x: isTooBigHorizontally ? 0 : proposedScroll.x,
4423 y: isTooBigVertically ? 0 : proposedScroll.y
4424 };
4425});
4426
4427var clean$2 = apply(function (value) {
4428 return value === 0 ? 0 : value;
4429});
4430var getScroll = (function (_ref) {
4431 var dragStartTime = _ref.dragStartTime,
4432 container = _ref.container,
4433 subject = _ref.subject,
4434 center = _ref.center,
4435 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4436 var distanceToEdges = {
4437 top: center.y - container.top,
4438 right: container.right - center.x,
4439 bottom: container.bottom - center.y,
4440 left: center.x - container.left
4441 };
4442 var y = getScrollOnAxis({
4443 container: container,
4444 distanceToEdges: distanceToEdges,
4445 dragStartTime: dragStartTime,
4446 axis: vertical,
4447 shouldUseTimeDampening: shouldUseTimeDampening
4448 });
4449 var x = getScrollOnAxis({
4450 container: container,
4451 distanceToEdges: distanceToEdges,
4452 dragStartTime: dragStartTime,
4453 axis: horizontal,
4454 shouldUseTimeDampening: shouldUseTimeDampening
4455 });
4456 var required = clean$2({
4457 x: x,
4458 y: y
4459 });
4460
4461 if (isEqual(required, origin)) {
4462 return null;
4463 }
4464
4465 var limited = adjustForSizeLimits({
4466 container: container,
4467 subject: subject,
4468 proposedScroll: required
4469 });
4470
4471 if (!limited) {
4472 return null;
4473 }
4474
4475 return isEqual(limited, origin) ? null : limited;
4476});
4477
4478var smallestSigned = apply(function (value) {
4479 if (value === 0) {
4480 return 0;
4481 }
4482
4483 return value > 0 ? 1 : -1;
4484});
4485var getOverlap = function () {
4486 var getRemainder = function getRemainder(target, max) {
4487 if (target < 0) {
4488 return target;
4489 }
4490
4491 if (target > max) {
4492 return target - max;
4493 }
4494
4495 return 0;
4496 };
4497
4498 return function (_ref) {
4499 var current = _ref.current,
4500 max = _ref.max,
4501 change = _ref.change;
4502 var targetScroll = add(current, change);
4503 var overlap = {
4504 x: getRemainder(targetScroll.x, max.x),
4505 y: getRemainder(targetScroll.y, max.y)
4506 };
4507
4508 if (isEqual(overlap, origin)) {
4509 return null;
4510 }
4511
4512 return overlap;
4513 };
4514}();
4515var canPartiallyScroll = function canPartiallyScroll(_ref2) {
4516 var rawMax = _ref2.max,
4517 current = _ref2.current,
4518 change = _ref2.change;
4519 var max = {
4520 x: Math.max(current.x, rawMax.x),
4521 y: Math.max(current.y, rawMax.y)
4522 };
4523 var smallestChange = smallestSigned(change);
4524 var overlap = getOverlap({
4525 max: max,
4526 current: current,
4527 change: smallestChange
4528 });
4529
4530 if (!overlap) {
4531 return true;
4532 }
4533
4534 if (smallestChange.x !== 0 && overlap.x === 0) {
4535 return true;
4536 }
4537
4538 if (smallestChange.y !== 0 && overlap.y === 0) {
4539 return true;
4540 }
4541
4542 return false;
4543};
4544var canScrollWindow = function canScrollWindow(viewport, change) {
4545 return canPartiallyScroll({
4546 current: viewport.scroll.current,
4547 max: viewport.scroll.max,
4548 change: change
4549 });
4550};
4551var getWindowOverlap = function getWindowOverlap(viewport, change) {
4552 if (!canScrollWindow(viewport, change)) {
4553 return null;
4554 }
4555
4556 var max = viewport.scroll.max;
4557 var current = viewport.scroll.current;
4558 return getOverlap({
4559 current: current,
4560 max: max,
4561 change: change
4562 });
4563};
4564var canScrollDroppable = function canScrollDroppable(droppable, change) {
4565 var frame = droppable.frame;
4566
4567 if (!frame) {
4568 return false;
4569 }
4570
4571 return canPartiallyScroll({
4572 current: frame.scroll.current,
4573 max: frame.scroll.max,
4574 change: change
4575 });
4576};
4577var getDroppableOverlap = function getDroppableOverlap(droppable, change) {
4578 var frame = droppable.frame;
4579
4580 if (!frame) {
4581 return null;
4582 }
4583
4584 if (!canScrollDroppable(droppable, change)) {
4585 return null;
4586 }
4587
4588 return getOverlap({
4589 current: frame.scroll.current,
4590 max: frame.scroll.max,
4591 change: change
4592 });
4593};
4594
4595var getWindowScrollChange = (function (_ref) {
4596 var viewport = _ref.viewport,
4597 subject = _ref.subject,
4598 center = _ref.center,
4599 dragStartTime = _ref.dragStartTime,
4600 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4601 var scroll = getScroll({
4602 dragStartTime: dragStartTime,
4603 container: viewport.frame,
4604 subject: subject,
4605 center: center,
4606 shouldUseTimeDampening: shouldUseTimeDampening
4607 });
4608 return scroll && canScrollWindow(viewport, scroll) ? scroll : null;
4609});
4610
4611var getDroppableScrollChange = (function (_ref) {
4612 var droppable = _ref.droppable,
4613 subject = _ref.subject,
4614 center = _ref.center,
4615 dragStartTime = _ref.dragStartTime,
4616 shouldUseTimeDampening = _ref.shouldUseTimeDampening;
4617 var frame = droppable.frame;
4618
4619 if (!frame) {
4620 return null;
4621 }
4622
4623 var scroll = getScroll({
4624 dragStartTime: dragStartTime,
4625 container: frame.pageMarginBox,
4626 subject: subject,
4627 center: center,
4628 shouldUseTimeDampening: shouldUseTimeDampening
4629 });
4630 return scroll && canScrollDroppable(droppable, scroll) ? scroll : null;
4631});
4632
4633var scroll$1 = (function (_ref) {
4634 var state = _ref.state,
4635 dragStartTime = _ref.dragStartTime,
4636 shouldUseTimeDampening = _ref.shouldUseTimeDampening,
4637 scrollWindow = _ref.scrollWindow,
4638 scrollDroppable = _ref.scrollDroppable;
4639 var center = state.current.page.borderBoxCenter;
4640 var draggable = state.dimensions.draggables[state.critical.draggable.id];
4641 var subject = draggable.page.marginBox;
4642
4643 if (state.isWindowScrollAllowed) {
4644 var viewport = state.viewport;
4645
4646 var _change = getWindowScrollChange({
4647 dragStartTime: dragStartTime,
4648 viewport: viewport,
4649 subject: subject,
4650 center: center,
4651 shouldUseTimeDampening: shouldUseTimeDampening
4652 });
4653
4654 if (_change) {
4655 scrollWindow(_change);
4656 return;
4657 }
4658 }
4659
4660 var droppable = getBestScrollableDroppable({
4661 center: center,
4662 destination: whatIsDraggedOver(state.impact),
4663 droppables: state.dimensions.droppables
4664 });
4665
4666 if (!droppable) {
4667 return;
4668 }
4669
4670 var change = getDroppableScrollChange({
4671 dragStartTime: dragStartTime,
4672 droppable: droppable,
4673 subject: subject,
4674 center: center,
4675 shouldUseTimeDampening: shouldUseTimeDampening
4676 });
4677
4678 if (change) {
4679 scrollDroppable(droppable.descriptor.id, change);
4680 }
4681});
4682
4683var createFluidScroller = (function (_ref) {
4684 var scrollWindow = _ref.scrollWindow,
4685 scrollDroppable = _ref.scrollDroppable;
4686 var scheduleWindowScroll = rafSchd(scrollWindow);
4687 var scheduleDroppableScroll = rafSchd(scrollDroppable);
4688 var dragging = null;
4689
4690 var tryScroll = function tryScroll(state) {
4691 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot fluid scroll if not dragging') : invariant(false) : void 0;
4692 var _dragging = dragging,
4693 shouldUseTimeDampening = _dragging.shouldUseTimeDampening,
4694 dragStartTime = _dragging.dragStartTime;
4695 scroll$1({
4696 state: state,
4697 scrollWindow: scheduleWindowScroll,
4698 scrollDroppable: scheduleDroppableScroll,
4699 dragStartTime: dragStartTime,
4700 shouldUseTimeDampening: shouldUseTimeDampening
4701 });
4702 };
4703
4704 var start$1 = function start$1(state) {
4705 start();
4706 !!dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot start auto scrolling when already started') : invariant(false) : void 0;
4707 var dragStartTime = Date.now();
4708 var wasScrollNeeded = false;
4709
4710 var fakeScrollCallback = function fakeScrollCallback() {
4711 wasScrollNeeded = true;
4712 };
4713
4714 scroll$1({
4715 state: state,
4716 dragStartTime: 0,
4717 shouldUseTimeDampening: false,
4718 scrollWindow: fakeScrollCallback,
4719 scrollDroppable: fakeScrollCallback
4720 });
4721 dragging = {
4722 dragStartTime: dragStartTime,
4723 shouldUseTimeDampening: wasScrollNeeded
4724 };
4725 finish();
4726
4727 if (wasScrollNeeded) {
4728 tryScroll(state);
4729 }
4730 };
4731
4732 var stop = function stop() {
4733 if (!dragging) {
4734 return;
4735 }
4736
4737 scheduleWindowScroll.cancel();
4738 scheduleDroppableScroll.cancel();
4739 dragging = null;
4740 };
4741
4742 return {
4743 start: start$1,
4744 stop: stop,
4745 scroll: tryScroll
4746 };
4747});
4748
4749var createJumpScroller = (function (_ref) {
4750 var move = _ref.move,
4751 scrollDroppable = _ref.scrollDroppable,
4752 scrollWindow = _ref.scrollWindow;
4753
4754 var moveByOffset = function moveByOffset(state, offset) {
4755 var client = add(state.current.client.selection, offset);
4756 move({
4757 client: client
4758 });
4759 };
4760
4761 var scrollDroppableAsMuchAsItCan = function scrollDroppableAsMuchAsItCan(droppable, change) {
4762 if (!canScrollDroppable(droppable, change)) {
4763 return change;
4764 }
4765
4766 var overlap = getDroppableOverlap(droppable, change);
4767
4768 if (!overlap) {
4769 scrollDroppable(droppable.descriptor.id, change);
4770 return null;
4771 }
4772
4773 var whatTheDroppableCanScroll = subtract(change, overlap);
4774 scrollDroppable(droppable.descriptor.id, whatTheDroppableCanScroll);
4775 var remainder = subtract(change, whatTheDroppableCanScroll);
4776 return remainder;
4777 };
4778
4779 var scrollWindowAsMuchAsItCan = function scrollWindowAsMuchAsItCan(isWindowScrollAllowed, viewport, change) {
4780 if (!isWindowScrollAllowed) {
4781 return change;
4782 }
4783
4784 if (!canScrollWindow(viewport, change)) {
4785 return change;
4786 }
4787
4788 var overlap = getWindowOverlap(viewport, change);
4789
4790 if (!overlap) {
4791 scrollWindow(change);
4792 return null;
4793 }
4794
4795 var whatTheWindowCanScroll = subtract(change, overlap);
4796 scrollWindow(whatTheWindowCanScroll);
4797 var remainder = subtract(change, whatTheWindowCanScroll);
4798 return remainder;
4799 };
4800
4801 var jumpScroller = function jumpScroller(state) {
4802 var request = state.scrollJumpRequest;
4803
4804 if (!request) {
4805 return;
4806 }
4807
4808 var destination = whatIsDraggedOver(state.impact);
4809 !destination ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot perform a jump scroll when there is no destination') : invariant(false) : void 0;
4810 var droppableRemainder = scrollDroppableAsMuchAsItCan(state.dimensions.droppables[destination], request);
4811
4812 if (!droppableRemainder) {
4813 return;
4814 }
4815
4816 var viewport = state.viewport;
4817 var windowRemainder = scrollWindowAsMuchAsItCan(state.isWindowScrollAllowed, viewport, droppableRemainder);
4818
4819 if (!windowRemainder) {
4820 return;
4821 }
4822
4823 moveByOffset(state, windowRemainder);
4824 };
4825
4826 return jumpScroller;
4827});
4828
4829var createAutoScroller = (function (_ref) {
4830 var scrollDroppable = _ref.scrollDroppable,
4831 scrollWindow = _ref.scrollWindow,
4832 move = _ref.move;
4833 var fluidScroller = createFluidScroller({
4834 scrollWindow: scrollWindow,
4835 scrollDroppable: scrollDroppable
4836 });
4837 var jumpScroll = createJumpScroller({
4838 move: move,
4839 scrollWindow: scrollWindow,
4840 scrollDroppable: scrollDroppable
4841 });
4842
4843 var scroll = function scroll(state) {
4844 if (state.phase !== 'DRAGGING') {
4845 return;
4846 }
4847
4848 if (state.movementMode === 'FLUID') {
4849 fluidScroller.scroll(state);
4850 return;
4851 }
4852
4853 if (!state.scrollJumpRequest) {
4854 return;
4855 }
4856
4857 jumpScroll(state);
4858 };
4859
4860 var scroller = {
4861 scroll: scroll,
4862 start: fluidScroller.start,
4863 stop: fluidScroller.stop
4864 };
4865 return scroller;
4866});
4867
4868var prefix$1 = 'data-rbd';
4869var dragHandle = function () {
4870 var base = prefix$1 + "-drag-handle";
4871 return {
4872 base: base,
4873 draggableId: base + "-draggable-id",
4874 contextId: base + "-context-id"
4875 };
4876}();
4877var draggable = function () {
4878 var base = prefix$1 + "-draggable";
4879 return {
4880 base: base,
4881 contextId: base + "-context-id",
4882 id: base + "-id"
4883 };
4884}();
4885var droppable = function () {
4886 var base = prefix$1 + "-droppable";
4887 return {
4888 base: base,
4889 contextId: base + "-context-id",
4890 id: base + "-id"
4891 };
4892}();
4893var scrollContainer = {
4894 contextId: prefix$1 + "-scroll-container-context-id"
4895};
4896
4897var makeGetSelector = function makeGetSelector(context) {
4898 return function (attribute) {
4899 return "[" + attribute + "=\"" + context + "\"]";
4900 };
4901};
4902
4903var getStyles = function getStyles(rules, property) {
4904 return rules.map(function (rule) {
4905 var value = rule.styles[property];
4906
4907 if (!value) {
4908 return '';
4909 }
4910
4911 return rule.selector + " { " + value + " }";
4912 }).join(' ');
4913};
4914
4915var noPointerEvents = 'pointer-events: none;';
4916var getStyles$1 = (function (contextId) {
4917 var getSelector = makeGetSelector(contextId);
4918
4919 var dragHandle$1 = function () {
4920 var grabCursor = "\n cursor: -webkit-grab;\n cursor: grab;\n ";
4921 return {
4922 selector: getSelector(dragHandle.contextId),
4923 styles: {
4924 always: "\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: rgba(0,0,0,0);\n touch-action: manipulation;\n ",
4925 resting: grabCursor,
4926 dragging: noPointerEvents,
4927 dropAnimating: grabCursor
4928 }
4929 };
4930 }();
4931
4932 var draggable$1 = function () {
4933 var transition = "\n transition: " + transitions.outOfTheWay + ";\n ";
4934 return {
4935 selector: getSelector(draggable.contextId),
4936 styles: {
4937 dragging: transition,
4938 dropAnimating: transition,
4939 userCancel: transition
4940 }
4941 };
4942 }();
4943
4944 var droppable$1 = {
4945 selector: getSelector(droppable.contextId),
4946 styles: {
4947 always: "overflow-anchor: none;"
4948 }
4949 };
4950 var body = {
4951 selector: 'body',
4952 styles: {
4953 dragging: "\n cursor: grabbing;\n cursor: -webkit-grabbing;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n overflow-anchor: none;\n "
4954 }
4955 };
4956 var rules = [draggable$1, dragHandle$1, droppable$1, body];
4957 return {
4958 always: getStyles(rules, 'always'),
4959 resting: getStyles(rules, 'resting'),
4960 dragging: getStyles(rules, 'dragging'),
4961 dropAnimating: getStyles(rules, 'dropAnimating'),
4962 userCancel: getStyles(rules, 'userCancel')
4963 };
4964});
4965
4966var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
4967
4968var getHead = function getHead() {
4969 var head = document.querySelector('head');
4970 !head ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot find the head to append a style to') : invariant(false) : void 0;
4971 return head;
4972};
4973
4974var createStyleEl = function createStyleEl(nonce) {
4975 var el = document.createElement('style');
4976
4977 if (nonce) {
4978 el.setAttribute('nonce', nonce);
4979 }
4980
4981 el.type = 'text/css';
4982 return el;
4983};
4984
4985function useStyleMarshal(contextId, nonce) {
4986 var styles = useMemo(function () {
4987 return getStyles$1(contextId);
4988 }, [contextId]);
4989 var alwaysRef = useRef(null);
4990 var dynamicRef = useRef(null);
4991 var setDynamicStyle = useCallback(memoizeOne(function (proposed) {
4992 var el = dynamicRef.current;
4993 !el ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot set dynamic style element if it is not set') : invariant(false) : void 0;
4994 el.textContent = proposed;
4995 }), []);
4996 var setAlwaysStyle = useCallback(function (proposed) {
4997 var el = alwaysRef.current;
4998 !el ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot set dynamic style element if it is not set') : invariant(false) : void 0;
4999 el.textContent = proposed;
5000 }, []);
5001 useIsomorphicLayoutEffect(function () {
5002 !(!alwaysRef.current && !dynamicRef.current) ? process.env.NODE_ENV !== "production" ? invariant(false, 'style elements already mounted') : invariant(false) : void 0;
5003 var always = createStyleEl(nonce);
5004 var dynamic = createStyleEl(nonce);
5005 alwaysRef.current = always;
5006 dynamicRef.current = dynamic;
5007 always.setAttribute(prefix$1 + "-always", contextId);
5008 dynamic.setAttribute(prefix$1 + "-dynamic", contextId);
5009 getHead().appendChild(always);
5010 getHead().appendChild(dynamic);
5011 setAlwaysStyle(styles.always);
5012 setDynamicStyle(styles.resting);
5013 return function () {
5014 var remove = function remove(ref) {
5015 var current = ref.current;
5016 !current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot unmount ref as it is not set') : invariant(false) : void 0;
5017 getHead().removeChild(current);
5018 ref.current = null;
5019 };
5020
5021 remove(alwaysRef);
5022 remove(dynamicRef);
5023 };
5024 }, [nonce, setAlwaysStyle, setDynamicStyle, styles.always, styles.resting, contextId]);
5025 var dragging = useCallback(function () {
5026 return setDynamicStyle(styles.dragging);
5027 }, [setDynamicStyle, styles.dragging]);
5028 var dropping = useCallback(function (reason) {
5029 if (reason === 'DROP') {
5030 setDynamicStyle(styles.dropAnimating);
5031 return;
5032 }
5033
5034 setDynamicStyle(styles.userCancel);
5035 }, [setDynamicStyle, styles.dropAnimating, styles.userCancel]);
5036 var resting = useCallback(function () {
5037 if (!dynamicRef.current) {
5038 return;
5039 }
5040
5041 setDynamicStyle(styles.resting);
5042 }, [setDynamicStyle, styles.resting]);
5043 var marshal = useMemo(function () {
5044 return {
5045 dragging: dragging,
5046 dropping: dropping,
5047 resting: resting
5048 };
5049 }, [dragging, dropping, resting]);
5050 return marshal;
5051}
5052
5053var getWindowFromEl = (function (el) {
5054 return el && el.ownerDocument ? el.ownerDocument.defaultView : window;
5055});
5056
5057function isHtmlElement(el) {
5058 return el instanceof getWindowFromEl(el).HTMLElement;
5059}
5060
5061function findDragHandle(contextId, draggableId) {
5062 var selector = "[" + dragHandle.contextId + "=\"" + contextId + "\"]";
5063 var possible = toArray(document.querySelectorAll(selector));
5064
5065 if (!possible.length) {
5066 process.env.NODE_ENV !== "production" ? warning("Unable to find any drag handles in the context \"" + contextId + "\"") : void 0;
5067 return null;
5068 }
5069
5070 var handle = find(possible, function (el) {
5071 return el.getAttribute(dragHandle.draggableId) === draggableId;
5072 });
5073
5074 if (!handle) {
5075 process.env.NODE_ENV !== "production" ? warning("Unable to find drag handle with id \"" + draggableId + "\" as no handle with a matching id was found") : void 0;
5076 return null;
5077 }
5078
5079 if (!isHtmlElement(handle)) {
5080 process.env.NODE_ENV !== "production" ? warning('drag handle needs to be a HTMLElement') : void 0;
5081 return null;
5082 }
5083
5084 return handle;
5085}
5086
5087function useFocusMarshal(contextId) {
5088 var entriesRef = useRef({});
5089 var recordRef = useRef(null);
5090 var restoreFocusFrameRef = useRef(null);
5091 var isMountedRef = useRef(false);
5092 var register = useCallback(function register(id, focus) {
5093 var entry = {
5094 id: id,
5095 focus: focus
5096 };
5097 entriesRef.current[id] = entry;
5098 return function unregister() {
5099 var entries = entriesRef.current;
5100 var current = entries[id];
5101
5102 if (current !== entry) {
5103 delete entries[id];
5104 }
5105 };
5106 }, []);
5107 var tryGiveFocus = useCallback(function tryGiveFocus(tryGiveFocusTo) {
5108 var handle = findDragHandle(contextId, tryGiveFocusTo);
5109
5110 if (handle && handle !== document.activeElement) {
5111 handle.focus();
5112 }
5113 }, [contextId]);
5114 var tryShiftRecord = useCallback(function tryShiftRecord(previous, redirectTo) {
5115 if (recordRef.current === previous) {
5116 recordRef.current = redirectTo;
5117 }
5118 }, []);
5119 var tryRestoreFocusRecorded = useCallback(function tryRestoreFocusRecorded() {
5120 if (restoreFocusFrameRef.current) {
5121 return;
5122 }
5123
5124 if (!isMountedRef.current) {
5125 return;
5126 }
5127
5128 restoreFocusFrameRef.current = requestAnimationFrame(function () {
5129 restoreFocusFrameRef.current = null;
5130 var record = recordRef.current;
5131
5132 if (record) {
5133 tryGiveFocus(record);
5134 }
5135 });
5136 }, [tryGiveFocus]);
5137 var tryRecordFocus = useCallback(function tryRecordFocus(id) {
5138 recordRef.current = null;
5139 var focused = document.activeElement;
5140
5141 if (!focused) {
5142 return;
5143 }
5144
5145 if (focused.getAttribute(dragHandle.draggableId) !== id) {
5146 return;
5147 }
5148
5149 recordRef.current = id;
5150 }, []);
5151 useIsomorphicLayoutEffect(function () {
5152 isMountedRef.current = true;
5153 return function clearFrameOnUnmount() {
5154 isMountedRef.current = false;
5155 var frameId = restoreFocusFrameRef.current;
5156
5157 if (frameId) {
5158 cancelAnimationFrame(frameId);
5159 }
5160 };
5161 }, []);
5162 var marshal = useMemo(function () {
5163 return {
5164 register: register,
5165 tryRecordFocus: tryRecordFocus,
5166 tryRestoreFocusRecorded: tryRestoreFocusRecorded,
5167 tryShiftRecord: tryShiftRecord
5168 };
5169 }, [register, tryRecordFocus, tryRestoreFocusRecorded, tryShiftRecord]);
5170 return marshal;
5171}
5172
5173function createRegistry() {
5174 var entries = {
5175 draggables: {},
5176 droppables: {}
5177 };
5178 var subscribers = [];
5179
5180 function subscribe(cb) {
5181 subscribers.push(cb);
5182 return function unsubscribe() {
5183 var index = subscribers.indexOf(cb);
5184
5185 if (index === -1) {
5186 return;
5187 }
5188
5189 subscribers.splice(index, 1);
5190 };
5191 }
5192
5193 function notify(event) {
5194 if (subscribers.length) {
5195 subscribers.forEach(function (cb) {
5196 return cb(event);
5197 });
5198 }
5199 }
5200
5201 function findDraggableById(id) {
5202 return entries.draggables[id] || null;
5203 }
5204
5205 function getDraggableById(id) {
5206 var entry = findDraggableById(id);
5207 !entry ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find draggable entry with id [" + id + "]") : invariant(false) : void 0;
5208 return entry;
5209 }
5210
5211 var draggableAPI = {
5212 register: function register(entry) {
5213 entries.draggables[entry.descriptor.id] = entry;
5214 notify({
5215 type: 'ADDITION',
5216 value: entry
5217 });
5218 },
5219 update: function update(entry, last) {
5220 var current = entries.draggables[last.descriptor.id];
5221
5222 if (!current) {
5223 return;
5224 }
5225
5226 if (current.uniqueId !== entry.uniqueId) {
5227 return;
5228 }
5229
5230 delete entries.draggables[last.descriptor.id];
5231 entries.draggables[entry.descriptor.id] = entry;
5232 },
5233 unregister: function unregister(entry) {
5234 var draggableId = entry.descriptor.id;
5235 var current = findDraggableById(draggableId);
5236
5237 if (!current) {
5238 return;
5239 }
5240
5241 if (entry.uniqueId !== current.uniqueId) {
5242 return;
5243 }
5244
5245 delete entries.draggables[draggableId];
5246 notify({
5247 type: 'REMOVAL',
5248 value: entry
5249 });
5250 },
5251 getById: getDraggableById,
5252 findById: findDraggableById,
5253 exists: function exists(id) {
5254 return Boolean(findDraggableById(id));
5255 },
5256 getAllByType: function getAllByType(type) {
5257 return values(entries.draggables).filter(function (entry) {
5258 return entry.descriptor.type === type;
5259 });
5260 }
5261 };
5262
5263 function findDroppableById(id) {
5264 return entries.droppables[id] || null;
5265 }
5266
5267 function getDroppableById(id) {
5268 var entry = findDroppableById(id);
5269 !entry ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot find droppable entry with id [" + id + "]") : invariant(false) : void 0;
5270 return entry;
5271 }
5272
5273 var droppableAPI = {
5274 register: function register(entry) {
5275 entries.droppables[entry.descriptor.id] = entry;
5276 },
5277 unregister: function unregister(entry) {
5278 var current = findDroppableById(entry.descriptor.id);
5279
5280 if (!current) {
5281 return;
5282 }
5283
5284 if (entry.uniqueId !== current.uniqueId) {
5285 return;
5286 }
5287
5288 delete entries.droppables[entry.descriptor.id];
5289 },
5290 getById: getDroppableById,
5291 findById: findDroppableById,
5292 exists: function exists(id) {
5293 return Boolean(findDroppableById(id));
5294 },
5295 getAllByType: function getAllByType(type) {
5296 return values(entries.droppables).filter(function (entry) {
5297 return entry.descriptor.type === type;
5298 });
5299 }
5300 };
5301
5302 function clean() {
5303 entries.draggables = {};
5304 entries.droppables = {};
5305 subscribers.length = 0;
5306 }
5307
5308 return {
5309 draggable: draggableAPI,
5310 droppable: droppableAPI,
5311 subscribe: subscribe,
5312 clean: clean
5313 };
5314}
5315
5316function useRegistry() {
5317 var registry = useMemo(createRegistry, []);
5318 useEffect(function () {
5319 return function unmount() {
5320 requestAnimationFrame(registry.clean);
5321 };
5322 }, [registry]);
5323 return registry;
5324}
5325
5326var StoreContext = React.createContext(null);
5327
5328var getBodyElement = (function () {
5329 var body = document.body;
5330 !body ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot find document.body') : invariant(false) : void 0;
5331 return body;
5332});
5333
5334var visuallyHidden = {
5335 position: 'absolute',
5336 width: '1px',
5337 height: '1px',
5338 margin: '-1px',
5339 border: '0',
5340 padding: '0',
5341 overflow: 'hidden',
5342 clip: 'rect(0 0 0 0)',
5343 'clip-path': 'inset(100%)'
5344};
5345
5346var getId = function getId(contextId) {
5347 return "rbd-announcement-" + contextId;
5348};
5349function useAnnouncer(contextId) {
5350 var id = useMemo(function () {
5351 return getId(contextId);
5352 }, [contextId]);
5353 var ref = useRef(null);
5354 useEffect(function setup() {
5355 var el = document.createElement('div');
5356 ref.current = el;
5357 el.id = id;
5358 el.setAttribute('aria-live', 'assertive');
5359 el.setAttribute('aria-atomic', 'true');
5360
5361 _extends(el.style, visuallyHidden);
5362
5363 getBodyElement().appendChild(el);
5364 return function cleanup() {
5365 setTimeout(function remove() {
5366 var body = getBodyElement();
5367
5368 if (body.contains(el)) {
5369 body.removeChild(el);
5370 }
5371
5372 if (el === ref.current) {
5373 ref.current = null;
5374 }
5375 });
5376 };
5377 }, [id]);
5378 var announce = useCallback(function (message) {
5379 var el = ref.current;
5380
5381 if (el) {
5382 el.textContent = message;
5383 return;
5384 }
5385
5386 process.env.NODE_ENV !== "production" ? warning("\n A screen reader message was trying to be announced but it was unable to do so.\n This can occur if you unmount your <DragDropContext /> in your onDragEnd.\n Consider calling provided.announce() before the unmount so that the instruction will\n not be lost for users relying on a screen reader.\n\n Message not passed to screen reader:\n\n \"" + message + "\"\n ") : void 0;
5387 }, []);
5388 return announce;
5389}
5390
5391var count = 0;
5392var defaults = {
5393 separator: '::'
5394};
5395function reset() {
5396 count = 0;
5397}
5398function useUniqueId(prefix, options) {
5399 if (options === void 0) {
5400 options = defaults;
5401 }
5402
5403 return useMemo(function () {
5404 return "" + prefix + options.separator + count++;
5405 }, [options.separator, prefix]);
5406}
5407
5408function getElementId(_ref) {
5409 var contextId = _ref.contextId,
5410 uniqueId = _ref.uniqueId;
5411 return "rbd-hidden-text-" + contextId + "-" + uniqueId;
5412}
5413function useHiddenTextElement(_ref2) {
5414 var contextId = _ref2.contextId,
5415 text = _ref2.text;
5416 var uniqueId = useUniqueId('hidden-text', {
5417 separator: '-'
5418 });
5419 var id = useMemo(function () {
5420 return getElementId({
5421 contextId: contextId,
5422 uniqueId: uniqueId
5423 });
5424 }, [uniqueId, contextId]);
5425 useEffect(function mount() {
5426 var el = document.createElement('div');
5427 el.id = id;
5428 el.textContent = text;
5429 el.style.display = 'none';
5430 getBodyElement().appendChild(el);
5431 return function unmount() {
5432 var body = getBodyElement();
5433
5434 if (body.contains(el)) {
5435 body.removeChild(el);
5436 }
5437 };
5438 }, [id, text]);
5439 return id;
5440}
5441
5442var AppContext = React.createContext(null);
5443
5444var peerDependencies = {
5445 react: "^16.8.5 || ^17.0.0 || ^18.0.0",
5446 "react-dom": "^16.8.5 || ^17.0.0 || ^18.0.0"
5447};
5448
5449var semver = /(\d+)\.(\d+)\.(\d+)/;
5450
5451var getVersion = function getVersion(value) {
5452 var result = semver.exec(value);
5453 !(result != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Unable to parse React version " + value) : invariant(false) : void 0;
5454 var major = Number(result[1]);
5455 var minor = Number(result[2]);
5456 var patch = Number(result[3]);
5457 return {
5458 major: major,
5459 minor: minor,
5460 patch: patch,
5461 raw: value
5462 };
5463};
5464
5465var isSatisfied = function isSatisfied(expected, actual) {
5466 if (actual.major > expected.major) {
5467 return true;
5468 }
5469
5470 if (actual.major < expected.major) {
5471 return false;
5472 }
5473
5474 if (actual.minor > expected.minor) {
5475 return true;
5476 }
5477
5478 if (actual.minor < expected.minor) {
5479 return false;
5480 }
5481
5482 return actual.patch >= expected.patch;
5483};
5484
5485var checkReactVersion = (function (peerDepValue, actualValue) {
5486 var peerDep = getVersion(peerDepValue);
5487 var actual = getVersion(actualValue);
5488
5489 if (isSatisfied(peerDep, actual)) {
5490 return;
5491 }
5492
5493 process.env.NODE_ENV !== "production" ? warning("\n React version: [" + actual.raw + "]\n does not satisfy expected peer dependency version: [" + peerDep.raw + "]\n\n This can result in run time bugs, and even fatal crashes\n ") : void 0;
5494});
5495
5496var suffix = "\n We expect a html5 doctype: <!doctype html>\n This is to ensure consistent browser layout and measurement\n\n More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/doctype.md\n";
5497var checkDoctype = (function (doc) {
5498 var doctype = doc.doctype;
5499
5500 if (!doctype) {
5501 process.env.NODE_ENV !== "production" ? warning("\n No <!doctype html> found.\n\n " + suffix + "\n ") : void 0;
5502 return;
5503 }
5504
5505 if (doctype.name.toLowerCase() !== 'html') {
5506 process.env.NODE_ENV !== "production" ? warning("\n Unexpected <!doctype> found: (" + doctype.name + ")\n\n " + suffix + "\n ") : void 0;
5507 }
5508
5509 if (doctype.publicId !== '') {
5510 process.env.NODE_ENV !== "production" ? warning("\n Unexpected <!doctype> publicId found: (" + doctype.publicId + ")\n A html5 doctype does not have a publicId\n\n " + suffix + "\n ") : void 0;
5511 }
5512});
5513
5514function useDev(useHook) {
5515 if (process.env.NODE_ENV !== 'production') {
5516 useHook();
5517 }
5518}
5519
5520function useDevSetupWarning(fn, inputs) {
5521 useDev(function () {
5522 useEffect(function () {
5523 try {
5524 fn();
5525 } catch (e) {
5526 error("\n A setup problem was encountered.\n\n > " + e.message + "\n ");
5527 }
5528 }, inputs);
5529 });
5530}
5531
5532function useStartupValidation() {
5533 useDevSetupWarning(function () {
5534 checkReactVersion(peerDependencies.react, React.version);
5535 checkDoctype(document);
5536 }, []);
5537}
5538
5539function usePrevious(current) {
5540 var ref = useRef(current);
5541 useEffect(function () {
5542 ref.current = current;
5543 });
5544 return ref;
5545}
5546
5547function create() {
5548 var lock = null;
5549
5550 function isClaimed() {
5551 return Boolean(lock);
5552 }
5553
5554 function isActive(value) {
5555 return value === lock;
5556 }
5557
5558 function claim(abandon) {
5559 !!lock ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot claim lock as it is already claimed') : invariant(false) : void 0;
5560 var newLock = {
5561 abandon: abandon
5562 };
5563 lock = newLock;
5564 return newLock;
5565 }
5566
5567 function release() {
5568 !lock ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot release lock when there is no lock') : invariant(false) : void 0;
5569 lock = null;
5570 }
5571
5572 function tryAbandon() {
5573 if (lock) {
5574 lock.abandon();
5575 release();
5576 }
5577 }
5578
5579 return {
5580 isClaimed: isClaimed,
5581 isActive: isActive,
5582 claim: claim,
5583 release: release,
5584 tryAbandon: tryAbandon
5585 };
5586}
5587
5588var tab = 9;
5589var enter = 13;
5590var escape = 27;
5591var space = 32;
5592var pageUp = 33;
5593var pageDown = 34;
5594var end = 35;
5595var home = 36;
5596var arrowLeft = 37;
5597var arrowUp = 38;
5598var arrowRight = 39;
5599var arrowDown = 40;
5600
5601var _preventedKeys;
5602var preventedKeys = (_preventedKeys = {}, _preventedKeys[enter] = true, _preventedKeys[tab] = true, _preventedKeys);
5603var preventStandardKeyEvents = (function (event) {
5604 if (preventedKeys[event.keyCode]) {
5605 event.preventDefault();
5606 }
5607});
5608
5609var supportedEventName = function () {
5610 var base = 'visibilitychange';
5611
5612 if (typeof document === 'undefined') {
5613 return base;
5614 }
5615
5616 var candidates = [base, "ms" + base, "webkit" + base, "moz" + base, "o" + base];
5617 var supported = find(candidates, function (eventName) {
5618 return "on" + eventName in document;
5619 });
5620 return supported || base;
5621}();
5622
5623var primaryButton = 0;
5624var sloppyClickThreshold = 5;
5625
5626function isSloppyClickThresholdExceeded(original, current) {
5627 return Math.abs(current.x - original.x) >= sloppyClickThreshold || Math.abs(current.y - original.y) >= sloppyClickThreshold;
5628}
5629
5630var idle$1 = {
5631 type: 'IDLE'
5632};
5633
5634function getCaptureBindings(_ref) {
5635 var cancel = _ref.cancel,
5636 completed = _ref.completed,
5637 getPhase = _ref.getPhase,
5638 setPhase = _ref.setPhase;
5639 return [{
5640 eventName: 'mousemove',
5641 fn: function fn(event) {
5642 var button = event.button,
5643 clientX = event.clientX,
5644 clientY = event.clientY;
5645
5646 if (button !== primaryButton) {
5647 return;
5648 }
5649
5650 var point = {
5651 x: clientX,
5652 y: clientY
5653 };
5654 var phase = getPhase();
5655
5656 if (phase.type === 'DRAGGING') {
5657 event.preventDefault();
5658 phase.actions.move(point);
5659 return;
5660 }
5661
5662 !(phase.type === 'PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot be IDLE') : invariant(false) : void 0;
5663 var pending = phase.point;
5664
5665 if (!isSloppyClickThresholdExceeded(pending, point)) {
5666 return;
5667 }
5668
5669 event.preventDefault();
5670 var actions = phase.actions.fluidLift(point);
5671 setPhase({
5672 type: 'DRAGGING',
5673 actions: actions
5674 });
5675 }
5676 }, {
5677 eventName: 'mouseup',
5678 fn: function fn(event) {
5679 var phase = getPhase();
5680
5681 if (phase.type !== 'DRAGGING') {
5682 cancel();
5683 return;
5684 }
5685
5686 event.preventDefault();
5687 phase.actions.drop({
5688 shouldBlockNextClick: true
5689 });
5690 completed();
5691 }
5692 }, {
5693 eventName: 'mousedown',
5694 fn: function fn(event) {
5695 if (getPhase().type === 'DRAGGING') {
5696 event.preventDefault();
5697 }
5698
5699 cancel();
5700 }
5701 }, {
5702 eventName: 'keydown',
5703 fn: function fn(event) {
5704 var phase = getPhase();
5705
5706 if (phase.type === 'PENDING') {
5707 cancel();
5708 return;
5709 }
5710
5711 if (event.keyCode === escape) {
5712 event.preventDefault();
5713 cancel();
5714 return;
5715 }
5716
5717 preventStandardKeyEvents(event);
5718 }
5719 }, {
5720 eventName: 'resize',
5721 fn: cancel
5722 }, {
5723 eventName: 'scroll',
5724 options: {
5725 passive: true,
5726 capture: false
5727 },
5728 fn: function fn() {
5729 if (getPhase().type === 'PENDING') {
5730 cancel();
5731 }
5732 }
5733 }, {
5734 eventName: 'webkitmouseforcedown',
5735 fn: function fn(event) {
5736 var phase = getPhase();
5737 !(phase.type !== 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Unexpected phase') : invariant(false) : void 0;
5738
5739 if (phase.actions.shouldRespectForcePress()) {
5740 cancel();
5741 return;
5742 }
5743
5744 event.preventDefault();
5745 }
5746 }, {
5747 eventName: supportedEventName,
5748 fn: cancel
5749 }];
5750}
5751
5752function useMouseSensor(api) {
5753 var phaseRef = useRef(idle$1);
5754 var unbindEventsRef = useRef(noop);
5755 var startCaptureBinding = useMemo(function () {
5756 return {
5757 eventName: 'mousedown',
5758 fn: function onMouseDown(event) {
5759 if (event.defaultPrevented) {
5760 return;
5761 }
5762
5763 if (event.button !== primaryButton) {
5764 return;
5765 }
5766
5767 if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
5768 return;
5769 }
5770
5771 var draggableId = api.findClosestDraggableId(event);
5772
5773 if (!draggableId) {
5774 return;
5775 }
5776
5777 var actions = api.tryGetLock(draggableId, stop, {
5778 sourceEvent: event
5779 });
5780
5781 if (!actions) {
5782 return;
5783 }
5784
5785 event.preventDefault();
5786 var point = {
5787 x: event.clientX,
5788 y: event.clientY
5789 };
5790 unbindEventsRef.current();
5791 startPendingDrag(actions, point);
5792 }
5793 };
5794 }, [api]);
5795 var preventForcePressBinding = useMemo(function () {
5796 return {
5797 eventName: 'webkitmouseforcewillbegin',
5798 fn: function fn(event) {
5799 if (event.defaultPrevented) {
5800 return;
5801 }
5802
5803 var id = api.findClosestDraggableId(event);
5804
5805 if (!id) {
5806 return;
5807 }
5808
5809 var options = api.findOptionsForDraggable(id);
5810
5811 if (!options) {
5812 return;
5813 }
5814
5815 if (options.shouldRespectForcePress) {
5816 return;
5817 }
5818
5819 if (!api.canGetLock(id)) {
5820 return;
5821 }
5822
5823 event.preventDefault();
5824 }
5825 };
5826 }, [api]);
5827 var listenForCapture = useCallback(function listenForCapture() {
5828 var options = {
5829 passive: false,
5830 capture: true
5831 };
5832 unbindEventsRef.current = bindEvents(window, [preventForcePressBinding, startCaptureBinding], options);
5833 }, [preventForcePressBinding, startCaptureBinding]);
5834 var stop = useCallback(function () {
5835 var current = phaseRef.current;
5836
5837 if (current.type === 'IDLE') {
5838 return;
5839 }
5840
5841 phaseRef.current = idle$1;
5842 unbindEventsRef.current();
5843 listenForCapture();
5844 }, [listenForCapture]);
5845 var cancel = useCallback(function () {
5846 var phase = phaseRef.current;
5847 stop();
5848
5849 if (phase.type === 'DRAGGING') {
5850 phase.actions.cancel({
5851 shouldBlockNextClick: true
5852 });
5853 }
5854
5855 if (phase.type === 'PENDING') {
5856 phase.actions.abort();
5857 }
5858 }, [stop]);
5859 var bindCapturingEvents = useCallback(function bindCapturingEvents() {
5860 var options = {
5861 capture: true,
5862 passive: false
5863 };
5864 var bindings = getCaptureBindings({
5865 cancel: cancel,
5866 completed: stop,
5867 getPhase: function getPhase() {
5868 return phaseRef.current;
5869 },
5870 setPhase: function setPhase(phase) {
5871 phaseRef.current = phase;
5872 }
5873 });
5874 unbindEventsRef.current = bindEvents(window, bindings, options);
5875 }, [cancel, stop]);
5876 var startPendingDrag = useCallback(function startPendingDrag(actions, point) {
5877 !(phaseRef.current.type === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected to move from IDLE to PENDING drag') : invariant(false) : void 0;
5878 phaseRef.current = {
5879 type: 'PENDING',
5880 point: point,
5881 actions: actions
5882 };
5883 bindCapturingEvents();
5884 }, [bindCapturingEvents]);
5885 useIsomorphicLayoutEffect(function mount() {
5886 listenForCapture();
5887 return function unmount() {
5888 unbindEventsRef.current();
5889 };
5890 }, [listenForCapture]);
5891}
5892
5893var _scrollJumpKeys;
5894
5895function noop$1() {}
5896
5897var scrollJumpKeys = (_scrollJumpKeys = {}, _scrollJumpKeys[pageDown] = true, _scrollJumpKeys[pageUp] = true, _scrollJumpKeys[home] = true, _scrollJumpKeys[end] = true, _scrollJumpKeys);
5898
5899function getDraggingBindings(actions, stop) {
5900 function cancel() {
5901 stop();
5902 actions.cancel();
5903 }
5904
5905 function drop() {
5906 stop();
5907 actions.drop();
5908 }
5909
5910 return [{
5911 eventName: 'keydown',
5912 fn: function fn(event) {
5913 if (event.keyCode === escape) {
5914 event.preventDefault();
5915 cancel();
5916 return;
5917 }
5918
5919 if (event.keyCode === space) {
5920 event.preventDefault();
5921 drop();
5922 return;
5923 }
5924
5925 if (event.keyCode === arrowDown) {
5926 event.preventDefault();
5927 actions.moveDown();
5928 return;
5929 }
5930
5931 if (event.keyCode === arrowUp) {
5932 event.preventDefault();
5933 actions.moveUp();
5934 return;
5935 }
5936
5937 if (event.keyCode === arrowRight) {
5938 event.preventDefault();
5939 actions.moveRight();
5940 return;
5941 }
5942
5943 if (event.keyCode === arrowLeft) {
5944 event.preventDefault();
5945 actions.moveLeft();
5946 return;
5947 }
5948
5949 if (scrollJumpKeys[event.keyCode]) {
5950 event.preventDefault();
5951 return;
5952 }
5953
5954 preventStandardKeyEvents(event);
5955 }
5956 }, {
5957 eventName: 'mousedown',
5958 fn: cancel
5959 }, {
5960 eventName: 'mouseup',
5961 fn: cancel
5962 }, {
5963 eventName: 'click',
5964 fn: cancel
5965 }, {
5966 eventName: 'touchstart',
5967 fn: cancel
5968 }, {
5969 eventName: 'resize',
5970 fn: cancel
5971 }, {
5972 eventName: 'wheel',
5973 fn: cancel,
5974 options: {
5975 passive: true
5976 }
5977 }, {
5978 eventName: supportedEventName,
5979 fn: cancel
5980 }];
5981}
5982
5983function useKeyboardSensor(api) {
5984 var unbindEventsRef = useRef(noop$1);
5985 var startCaptureBinding = useMemo(function () {
5986 return {
5987 eventName: 'keydown',
5988 fn: function onKeyDown(event) {
5989 if (event.defaultPrevented) {
5990 return;
5991 }
5992
5993 if (event.keyCode !== space) {
5994 return;
5995 }
5996
5997 var draggableId = api.findClosestDraggableId(event);
5998
5999 if (!draggableId) {
6000 return;
6001 }
6002
6003 var preDrag = api.tryGetLock(draggableId, stop, {
6004 sourceEvent: event
6005 });
6006
6007 if (!preDrag) {
6008 return;
6009 }
6010
6011 event.preventDefault();
6012 var isCapturing = true;
6013 var actions = preDrag.snapLift();
6014 unbindEventsRef.current();
6015
6016 function stop() {
6017 !isCapturing ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot stop capturing a keyboard drag when not capturing') : invariant(false) : void 0;
6018 isCapturing = false;
6019 unbindEventsRef.current();
6020 listenForCapture();
6021 }
6022
6023 unbindEventsRef.current = bindEvents(window, getDraggingBindings(actions, stop), {
6024 capture: true,
6025 passive: false
6026 });
6027 }
6028 };
6029 }, [api]);
6030 var listenForCapture = useCallback(function tryStartCapture() {
6031 var options = {
6032 passive: false,
6033 capture: true
6034 };
6035 unbindEventsRef.current = bindEvents(window, [startCaptureBinding], options);
6036 }, [startCaptureBinding]);
6037 useIsomorphicLayoutEffect(function mount() {
6038 listenForCapture();
6039 return function unmount() {
6040 unbindEventsRef.current();
6041 };
6042 }, [listenForCapture]);
6043}
6044
6045var idle$2 = {
6046 type: 'IDLE'
6047};
6048var timeForLongPress = 120;
6049var forcePressThreshold = 0.15;
6050
6051function getWindowBindings(_ref) {
6052 var cancel = _ref.cancel,
6053 getPhase = _ref.getPhase;
6054 return [{
6055 eventName: 'orientationchange',
6056 fn: cancel
6057 }, {
6058 eventName: 'resize',
6059 fn: cancel
6060 }, {
6061 eventName: 'contextmenu',
6062 fn: function fn(event) {
6063 event.preventDefault();
6064 }
6065 }, {
6066 eventName: 'keydown',
6067 fn: function fn(event) {
6068 if (getPhase().type !== 'DRAGGING') {
6069 cancel();
6070 return;
6071 }
6072
6073 if (event.keyCode === escape) {
6074 event.preventDefault();
6075 }
6076
6077 cancel();
6078 }
6079 }, {
6080 eventName: supportedEventName,
6081 fn: cancel
6082 }];
6083}
6084
6085function getHandleBindings(_ref2) {
6086 var cancel = _ref2.cancel,
6087 completed = _ref2.completed,
6088 getPhase = _ref2.getPhase;
6089 return [{
6090 eventName: 'touchmove',
6091 options: {
6092 capture: false
6093 },
6094 fn: function fn(event) {
6095 var phase = getPhase();
6096
6097 if (phase.type !== 'DRAGGING') {
6098 cancel();
6099 return;
6100 }
6101
6102 phase.hasMoved = true;
6103 var _event$touches$ = event.touches[0],
6104 clientX = _event$touches$.clientX,
6105 clientY = _event$touches$.clientY;
6106 var point = {
6107 x: clientX,
6108 y: clientY
6109 };
6110 event.preventDefault();
6111 phase.actions.move(point);
6112 }
6113 }, {
6114 eventName: 'touchend',
6115 fn: function fn(event) {
6116 var phase = getPhase();
6117
6118 if (phase.type !== 'DRAGGING') {
6119 cancel();
6120 return;
6121 }
6122
6123 event.preventDefault();
6124 phase.actions.drop({
6125 shouldBlockNextClick: true
6126 });
6127 completed();
6128 }
6129 }, {
6130 eventName: 'touchcancel',
6131 fn: function fn(event) {
6132 if (getPhase().type !== 'DRAGGING') {
6133 cancel();
6134 return;
6135 }
6136
6137 event.preventDefault();
6138 cancel();
6139 }
6140 }, {
6141 eventName: 'touchforcechange',
6142 fn: function fn(event) {
6143 var phase = getPhase();
6144 !(phase.type !== 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
6145 var touch = event.touches[0];
6146
6147 if (!touch) {
6148 return;
6149 }
6150
6151 var isForcePress = touch.force >= forcePressThreshold;
6152
6153 if (!isForcePress) {
6154 return;
6155 }
6156
6157 var shouldRespect = phase.actions.shouldRespectForcePress();
6158
6159 if (phase.type === 'PENDING') {
6160 if (shouldRespect) {
6161 cancel();
6162 }
6163
6164 return;
6165 }
6166
6167 if (shouldRespect) {
6168 if (phase.hasMoved) {
6169 event.preventDefault();
6170 return;
6171 }
6172
6173 cancel();
6174 return;
6175 }
6176
6177 event.preventDefault();
6178 }
6179 }, {
6180 eventName: supportedEventName,
6181 fn: cancel
6182 }];
6183}
6184
6185function useTouchSensor(api) {
6186 var phaseRef = useRef(idle$2);
6187 var unbindEventsRef = useRef(noop);
6188 var getPhase = useCallback(function getPhase() {
6189 return phaseRef.current;
6190 }, []);
6191 var setPhase = useCallback(function setPhase(phase) {
6192 phaseRef.current = phase;
6193 }, []);
6194 var startCaptureBinding = useMemo(function () {
6195 return {
6196 eventName: 'touchstart',
6197 fn: function onTouchStart(event) {
6198 if (event.defaultPrevented) {
6199 return;
6200 }
6201
6202 var draggableId = api.findClosestDraggableId(event);
6203
6204 if (!draggableId) {
6205 return;
6206 }
6207
6208 var actions = api.tryGetLock(draggableId, stop, {
6209 sourceEvent: event
6210 });
6211
6212 if (!actions) {
6213 return;
6214 }
6215
6216 var touch = event.touches[0];
6217 var clientX = touch.clientX,
6218 clientY = touch.clientY;
6219 var point = {
6220 x: clientX,
6221 y: clientY
6222 };
6223 unbindEventsRef.current();
6224 startPendingDrag(actions, point);
6225 }
6226 };
6227 }, [api]);
6228 var listenForCapture = useCallback(function listenForCapture() {
6229 var options = {
6230 capture: true,
6231 passive: false
6232 };
6233 unbindEventsRef.current = bindEvents(window, [startCaptureBinding], options);
6234 }, [startCaptureBinding]);
6235 var stop = useCallback(function () {
6236 var current = phaseRef.current;
6237
6238 if (current.type === 'IDLE') {
6239 return;
6240 }
6241
6242 if (current.type === 'PENDING') {
6243 clearTimeout(current.longPressTimerId);
6244 }
6245
6246 setPhase(idle$2);
6247 unbindEventsRef.current();
6248 listenForCapture();
6249 }, [listenForCapture, setPhase]);
6250 var cancel = useCallback(function () {
6251 var phase = phaseRef.current;
6252 stop();
6253
6254 if (phase.type === 'DRAGGING') {
6255 phase.actions.cancel({
6256 shouldBlockNextClick: true
6257 });
6258 }
6259
6260 if (phase.type === 'PENDING') {
6261 phase.actions.abort();
6262 }
6263 }, [stop]);
6264 var bindCapturingEvents = useCallback(function bindCapturingEvents() {
6265 var options = {
6266 capture: true,
6267 passive: false
6268 };
6269 var args = {
6270 cancel: cancel,
6271 completed: stop,
6272 getPhase: getPhase
6273 };
6274 var unbindTarget = bindEvents(window, getHandleBindings(args), options);
6275 var unbindWindow = bindEvents(window, getWindowBindings(args), options);
6276
6277 unbindEventsRef.current = function unbindAll() {
6278 unbindTarget();
6279 unbindWindow();
6280 };
6281 }, [cancel, getPhase, stop]);
6282 var startDragging = useCallback(function startDragging() {
6283 var phase = getPhase();
6284 !(phase.type === 'PENDING') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot start dragging from phase " + phase.type) : invariant(false) : void 0;
6285 var actions = phase.actions.fluidLift(phase.point);
6286 setPhase({
6287 type: 'DRAGGING',
6288 actions: actions,
6289 hasMoved: false
6290 });
6291 }, [getPhase, setPhase]);
6292 var startPendingDrag = useCallback(function startPendingDrag(actions, point) {
6293 !(getPhase().type === 'IDLE') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected to move from IDLE to PENDING drag') : invariant(false) : void 0;
6294 var longPressTimerId = setTimeout(startDragging, timeForLongPress);
6295 setPhase({
6296 type: 'PENDING',
6297 point: point,
6298 actions: actions,
6299 longPressTimerId: longPressTimerId
6300 });
6301 bindCapturingEvents();
6302 }, [bindCapturingEvents, getPhase, setPhase, startDragging]);
6303 useIsomorphicLayoutEffect(function mount() {
6304 listenForCapture();
6305 return function unmount() {
6306 unbindEventsRef.current();
6307 var phase = getPhase();
6308
6309 if (phase.type === 'PENDING') {
6310 clearTimeout(phase.longPressTimerId);
6311 setPhase(idle$2);
6312 }
6313 };
6314 }, [getPhase, listenForCapture, setPhase]);
6315 useIsomorphicLayoutEffect(function webkitHack() {
6316 var unbind = bindEvents(window, [{
6317 eventName: 'touchmove',
6318 fn: function fn() {},
6319 options: {
6320 capture: false,
6321 passive: false
6322 }
6323 }]);
6324 return unbind;
6325 }, []);
6326}
6327
6328function useValidateSensorHooks(sensorHooks) {
6329 useDev(function () {
6330 var previousRef = usePrevious(sensorHooks);
6331 useDevSetupWarning(function () {
6332 !(previousRef.current.length === sensorHooks.length) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot change the amount of sensor hooks after mounting') : invariant(false) : void 0;
6333 });
6334 });
6335}
6336
6337var interactiveTagNames = {
6338 input: true,
6339 button: true,
6340 textarea: true,
6341 select: true,
6342 option: true,
6343 optgroup: true,
6344 video: true,
6345 audio: true
6346};
6347
6348function isAnInteractiveElement(parent, current) {
6349 if (current == null) {
6350 return false;
6351 }
6352
6353 var hasAnInteractiveTag = Boolean(interactiveTagNames[current.tagName.toLowerCase()]);
6354
6355 if (hasAnInteractiveTag) {
6356 return true;
6357 }
6358
6359 var attribute = current.getAttribute('contenteditable');
6360
6361 if (attribute === 'true' || attribute === '') {
6362 return true;
6363 }
6364
6365 if (current === parent) {
6366 return false;
6367 }
6368
6369 return isAnInteractiveElement(parent, current.parentElement);
6370}
6371
6372function isEventInInteractiveElement(draggable, event) {
6373 var target = event.target;
6374
6375 if (!isHtmlElement(target)) {
6376 return false;
6377 }
6378
6379 return isAnInteractiveElement(draggable, target);
6380}
6381
6382var getBorderBoxCenterPosition = (function (el) {
6383 return getRect(el.getBoundingClientRect()).center;
6384});
6385
6386function isElement(el) {
6387 return el instanceof getWindowFromEl(el).Element;
6388}
6389
6390var supportedMatchesName = function () {
6391 var base = 'matches';
6392
6393 if (typeof document === 'undefined') {
6394 return base;
6395 }
6396
6397 var candidates = [base, 'msMatchesSelector', 'webkitMatchesSelector'];
6398 var value = find(candidates, function (name) {
6399 return name in Element.prototype;
6400 });
6401 return value || base;
6402}();
6403
6404function closestPonyfill(el, selector) {
6405 if (el == null) {
6406 return null;
6407 }
6408
6409 if (el[supportedMatchesName](selector)) {
6410 return el;
6411 }
6412
6413 return closestPonyfill(el.parentElement, selector);
6414}
6415
6416function closest$1(el, selector) {
6417 if (el.closest) {
6418 return el.closest(selector);
6419 }
6420
6421 return closestPonyfill(el, selector);
6422}
6423
6424function getSelector(contextId) {
6425 return "[" + dragHandle.contextId + "=\"" + contextId + "\"]";
6426}
6427
6428function findClosestDragHandleFromEvent(contextId, event) {
6429 var target = event.target;
6430
6431 if (!isElement(target)) {
6432 process.env.NODE_ENV !== "production" ? warning('event.target must be a Element') : void 0;
6433 return null;
6434 }
6435
6436 var selector = getSelector(contextId);
6437 var handle = closest$1(target, selector);
6438
6439 if (!handle) {
6440 return null;
6441 }
6442
6443 if (!isHtmlElement(handle)) {
6444 process.env.NODE_ENV !== "production" ? warning('drag handle must be a HTMLElement') : void 0;
6445 return null;
6446 }
6447
6448 return handle;
6449}
6450
6451function tryGetClosestDraggableIdFromEvent(contextId, event) {
6452 var handle = findClosestDragHandleFromEvent(contextId, event);
6453
6454 if (!handle) {
6455 return null;
6456 }
6457
6458 return handle.getAttribute(dragHandle.draggableId);
6459}
6460
6461function findDraggable(contextId, draggableId) {
6462 var selector = "[" + draggable.contextId + "=\"" + contextId + "\"]";
6463 var possible = toArray(document.querySelectorAll(selector));
6464 var draggable$1 = find(possible, function (el) {
6465 return el.getAttribute(draggable.id) === draggableId;
6466 });
6467
6468 if (!draggable$1) {
6469 return null;
6470 }
6471
6472 if (!isHtmlElement(draggable$1)) {
6473 process.env.NODE_ENV !== "production" ? warning('Draggable element is not a HTMLElement') : void 0;
6474 return null;
6475 }
6476
6477 return draggable$1;
6478}
6479
6480function preventDefault(event) {
6481 event.preventDefault();
6482}
6483
6484function _isActive(_ref) {
6485 var expected = _ref.expected,
6486 phase = _ref.phase,
6487 isLockActive = _ref.isLockActive,
6488 shouldWarn = _ref.shouldWarn;
6489
6490 if (!isLockActive()) {
6491 if (shouldWarn) {
6492 process.env.NODE_ENV !== "production" ? warning("\n Cannot perform action.\n The sensor no longer has an action lock.\n\n Tips:\n\n - Throw away your action handlers when forceStop() is called\n - Check actions.isActive() if you really need to\n ") : void 0;
6493 }
6494
6495 return false;
6496 }
6497
6498 if (expected !== phase) {
6499 if (shouldWarn) {
6500 process.env.NODE_ENV !== "production" ? warning("\n Cannot perform action.\n The actions you used belong to an outdated phase\n\n Current phase: " + expected + "\n You called an action from outdated phase: " + phase + "\n\n Tips:\n\n - Do not use preDragActions actions after calling preDragActions.lift()\n ") : void 0;
6501 }
6502
6503 return false;
6504 }
6505
6506 return true;
6507}
6508
6509function canStart(_ref2) {
6510 var lockAPI = _ref2.lockAPI,
6511 store = _ref2.store,
6512 registry = _ref2.registry,
6513 draggableId = _ref2.draggableId;
6514
6515 if (lockAPI.isClaimed()) {
6516 return false;
6517 }
6518
6519 var entry = registry.draggable.findById(draggableId);
6520
6521 if (!entry) {
6522 process.env.NODE_ENV !== "production" ? warning("Unable to find draggable with id: " + draggableId) : void 0;
6523 return false;
6524 }
6525
6526 if (!entry.options.isEnabled) {
6527 return false;
6528 }
6529
6530 if (!canStartDrag(store.getState(), draggableId)) {
6531 return false;
6532 }
6533
6534 return true;
6535}
6536
6537function tryStart(_ref3) {
6538 var lockAPI = _ref3.lockAPI,
6539 contextId = _ref3.contextId,
6540 store = _ref3.store,
6541 registry = _ref3.registry,
6542 draggableId = _ref3.draggableId,
6543 forceSensorStop = _ref3.forceSensorStop,
6544 sourceEvent = _ref3.sourceEvent;
6545 var shouldStart = canStart({
6546 lockAPI: lockAPI,
6547 store: store,
6548 registry: registry,
6549 draggableId: draggableId
6550 });
6551
6552 if (!shouldStart) {
6553 return null;
6554 }
6555
6556 var entry = registry.draggable.getById(draggableId);
6557 var el = findDraggable(contextId, entry.descriptor.id);
6558
6559 if (!el) {
6560 process.env.NODE_ENV !== "production" ? warning("Unable to find draggable element with id: " + draggableId) : void 0;
6561 return null;
6562 }
6563
6564 if (sourceEvent && !entry.options.canDragInteractiveElements && isEventInInteractiveElement(el, sourceEvent)) {
6565 return null;
6566 }
6567
6568 var lock = lockAPI.claim(forceSensorStop || noop);
6569 var phase = 'PRE_DRAG';
6570
6571 function getShouldRespectForcePress() {
6572 return entry.options.shouldRespectForcePress;
6573 }
6574
6575 function isLockActive() {
6576 return lockAPI.isActive(lock);
6577 }
6578
6579 function tryDispatch(expected, getAction) {
6580 if (_isActive({
6581 expected: expected,
6582 phase: phase,
6583 isLockActive: isLockActive,
6584 shouldWarn: true
6585 })) {
6586 store.dispatch(getAction());
6587 }
6588 }
6589
6590 var tryDispatchWhenDragging = tryDispatch.bind(null, 'DRAGGING');
6591
6592 function lift$1(args) {
6593 function completed() {
6594 lockAPI.release();
6595 phase = 'COMPLETED';
6596 }
6597
6598 if (phase !== 'PRE_DRAG') {
6599 completed();
6600 !(phase === 'PRE_DRAG') ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot lift in phase " + phase) : invariant(false) : void 0;
6601 }
6602
6603 store.dispatch(lift(args.liftActionArgs));
6604 phase = 'DRAGGING';
6605
6606 function finish(reason, options) {
6607 if (options === void 0) {
6608 options = {
6609 shouldBlockNextClick: false
6610 };
6611 }
6612
6613 args.cleanup();
6614
6615 if (options.shouldBlockNextClick) {
6616 var unbind = bindEvents(window, [{
6617 eventName: 'click',
6618 fn: preventDefault,
6619 options: {
6620 once: true,
6621 passive: false,
6622 capture: true
6623 }
6624 }]);
6625 setTimeout(unbind);
6626 }
6627
6628 completed();
6629 store.dispatch(drop({
6630 reason: reason
6631 }));
6632 }
6633
6634 return _extends({
6635 isActive: function isActive() {
6636 return _isActive({
6637 expected: 'DRAGGING',
6638 phase: phase,
6639 isLockActive: isLockActive,
6640 shouldWarn: false
6641 });
6642 },
6643 shouldRespectForcePress: getShouldRespectForcePress,
6644 drop: function drop(options) {
6645 return finish('DROP', options);
6646 },
6647 cancel: function cancel(options) {
6648 return finish('CANCEL', options);
6649 }
6650 }, args.actions);
6651 }
6652
6653 function fluidLift(clientSelection) {
6654 var move$1 = rafSchd(function (client) {
6655 tryDispatchWhenDragging(function () {
6656 return move({
6657 client: client
6658 });
6659 });
6660 });
6661 var api = lift$1({
6662 liftActionArgs: {
6663 id: draggableId,
6664 clientSelection: clientSelection,
6665 movementMode: 'FLUID'
6666 },
6667 cleanup: function cleanup() {
6668 return move$1.cancel();
6669 },
6670 actions: {
6671 move: move$1
6672 }
6673 });
6674 return _extends({}, api, {
6675 move: move$1
6676 });
6677 }
6678
6679 function snapLift() {
6680 var actions = {
6681 moveUp: function moveUp$1() {
6682 return tryDispatchWhenDragging(moveUp);
6683 },
6684 moveRight: function moveRight$1() {
6685 return tryDispatchWhenDragging(moveRight);
6686 },
6687 moveDown: function moveDown$1() {
6688 return tryDispatchWhenDragging(moveDown);
6689 },
6690 moveLeft: function moveLeft$1() {
6691 return tryDispatchWhenDragging(moveLeft);
6692 }
6693 };
6694 return lift$1({
6695 liftActionArgs: {
6696 id: draggableId,
6697 clientSelection: getBorderBoxCenterPosition(el),
6698 movementMode: 'SNAP'
6699 },
6700 cleanup: noop,
6701 actions: actions
6702 });
6703 }
6704
6705 function abortPreDrag() {
6706 var shouldRelease = _isActive({
6707 expected: 'PRE_DRAG',
6708 phase: phase,
6709 isLockActive: isLockActive,
6710 shouldWarn: true
6711 });
6712
6713 if (shouldRelease) {
6714 lockAPI.release();
6715 }
6716 }
6717
6718 var preDrag = {
6719 isActive: function isActive() {
6720 return _isActive({
6721 expected: 'PRE_DRAG',
6722 phase: phase,
6723 isLockActive: isLockActive,
6724 shouldWarn: false
6725 });
6726 },
6727 shouldRespectForcePress: getShouldRespectForcePress,
6728 fluidLift: fluidLift,
6729 snapLift: snapLift,
6730 abort: abortPreDrag
6731 };
6732 return preDrag;
6733}
6734
6735var defaultSensors = [useMouseSensor, useKeyboardSensor, useTouchSensor];
6736function useSensorMarshal(_ref4) {
6737 var contextId = _ref4.contextId,
6738 store = _ref4.store,
6739 registry = _ref4.registry,
6740 customSensors = _ref4.customSensors,
6741 enableDefaultSensors = _ref4.enableDefaultSensors;
6742 var useSensors = [].concat(enableDefaultSensors ? defaultSensors : [], customSensors || []);
6743 var lockAPI = useState(function () {
6744 return create();
6745 })[0];
6746 var tryAbandonLock = useCallback(function tryAbandonLock(previous, current) {
6747 if (previous.isDragging && !current.isDragging) {
6748 lockAPI.tryAbandon();
6749 }
6750 }, [lockAPI]);
6751 useIsomorphicLayoutEffect(function listenToStore() {
6752 var previous = store.getState();
6753 var unsubscribe = store.subscribe(function () {
6754 var current = store.getState();
6755 tryAbandonLock(previous, current);
6756 previous = current;
6757 });
6758 return unsubscribe;
6759 }, [lockAPI, store, tryAbandonLock]);
6760 useIsomorphicLayoutEffect(function () {
6761 return lockAPI.tryAbandon;
6762 }, [lockAPI.tryAbandon]);
6763 var canGetLock = useCallback(function (draggableId) {
6764 return canStart({
6765 lockAPI: lockAPI,
6766 registry: registry,
6767 store: store,
6768 draggableId: draggableId
6769 });
6770 }, [lockAPI, registry, store]);
6771 var tryGetLock = useCallback(function (draggableId, forceStop, options) {
6772 return tryStart({
6773 lockAPI: lockAPI,
6774 registry: registry,
6775 contextId: contextId,
6776 store: store,
6777 draggableId: draggableId,
6778 forceSensorStop: forceStop,
6779 sourceEvent: options && options.sourceEvent ? options.sourceEvent : null
6780 });
6781 }, [contextId, lockAPI, registry, store]);
6782 var findClosestDraggableId = useCallback(function (event) {
6783 return tryGetClosestDraggableIdFromEvent(contextId, event);
6784 }, [contextId]);
6785 var findOptionsForDraggable = useCallback(function (id) {
6786 var entry = registry.draggable.findById(id);
6787 return entry ? entry.options : null;
6788 }, [registry.draggable]);
6789 var tryReleaseLock = useCallback(function tryReleaseLock() {
6790 if (!lockAPI.isClaimed()) {
6791 return;
6792 }
6793
6794 lockAPI.tryAbandon();
6795
6796 if (store.getState().phase !== 'IDLE') {
6797 store.dispatch(flush());
6798 }
6799 }, [lockAPI, store]);
6800 var isLockClaimed = useCallback(lockAPI.isClaimed, [lockAPI]);
6801 var api = useMemo(function () {
6802 return {
6803 canGetLock: canGetLock,
6804 tryGetLock: tryGetLock,
6805 findClosestDraggableId: findClosestDraggableId,
6806 findOptionsForDraggable: findOptionsForDraggable,
6807 tryReleaseLock: tryReleaseLock,
6808 isLockClaimed: isLockClaimed
6809 };
6810 }, [canGetLock, tryGetLock, findClosestDraggableId, findOptionsForDraggable, tryReleaseLock, isLockClaimed]);
6811 useValidateSensorHooks(useSensors);
6812
6813 for (var i = 0; i < useSensors.length; i++) {
6814 useSensors[i](api);
6815 }
6816}
6817
6818var createResponders = function createResponders(props) {
6819 return {
6820 onBeforeCapture: props.onBeforeCapture,
6821 onBeforeDragStart: props.onBeforeDragStart,
6822 onDragStart: props.onDragStart,
6823 onDragEnd: props.onDragEnd,
6824 onDragUpdate: props.onDragUpdate
6825 };
6826};
6827
6828function getStore(lazyRef) {
6829 !lazyRef.current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find store from lazy ref') : invariant(false) : void 0;
6830 return lazyRef.current;
6831}
6832
6833function App(props) {
6834 var contextId = props.contextId,
6835 setCallbacks = props.setCallbacks,
6836 sensors = props.sensors,
6837 nonce = props.nonce,
6838 dragHandleUsageInstructions = props.dragHandleUsageInstructions;
6839 var lazyStoreRef = useRef(null);
6840 useStartupValidation();
6841 var lastPropsRef = usePrevious(props);
6842 var getResponders = useCallback(function () {
6843 return createResponders(lastPropsRef.current);
6844 }, [lastPropsRef]);
6845 var announce = useAnnouncer(contextId);
6846 var dragHandleUsageInstructionsId = useHiddenTextElement({
6847 contextId: contextId,
6848 text: dragHandleUsageInstructions
6849 });
6850 var styleMarshal = useStyleMarshal(contextId, nonce);
6851 var lazyDispatch = useCallback(function (action) {
6852 getStore(lazyStoreRef).dispatch(action);
6853 }, []);
6854 var marshalCallbacks = useMemo(function () {
6855 return bindActionCreators({
6856 publishWhileDragging: publishWhileDragging,
6857 updateDroppableScroll: updateDroppableScroll,
6858 updateDroppableIsEnabled: updateDroppableIsEnabled,
6859 updateDroppableIsCombineEnabled: updateDroppableIsCombineEnabled,
6860 collectionStarting: collectionStarting
6861 }, lazyDispatch);
6862 }, [lazyDispatch]);
6863 var registry = useRegistry();
6864 var dimensionMarshal = useMemo(function () {
6865 return createDimensionMarshal(registry, marshalCallbacks);
6866 }, [registry, marshalCallbacks]);
6867 var autoScroller = useMemo(function () {
6868 return createAutoScroller(_extends({
6869 scrollWindow: scrollWindow,
6870 scrollDroppable: dimensionMarshal.scrollDroppable
6871 }, bindActionCreators({
6872 move: move
6873 }, lazyDispatch)));
6874 }, [dimensionMarshal.scrollDroppable, lazyDispatch]);
6875 var focusMarshal = useFocusMarshal(contextId);
6876 var store = useMemo(function () {
6877 return createStore({
6878 announce: announce,
6879 autoScroller: autoScroller,
6880 dimensionMarshal: dimensionMarshal,
6881 focusMarshal: focusMarshal,
6882 getResponders: getResponders,
6883 styleMarshal: styleMarshal
6884 });
6885 }, [announce, autoScroller, dimensionMarshal, focusMarshal, getResponders, styleMarshal]);
6886
6887 if (process.env.NODE_ENV !== 'production') {
6888 if (lazyStoreRef.current && lazyStoreRef.current !== store) {
6889 process.env.NODE_ENV !== "production" ? warning('unexpected store change') : void 0;
6890 }
6891 }
6892
6893 lazyStoreRef.current = store;
6894 var tryResetStore = useCallback(function () {
6895 var current = getStore(lazyStoreRef);
6896 var state = current.getState();
6897
6898 if (state.phase !== 'IDLE') {
6899 current.dispatch(flush());
6900 }
6901 }, []);
6902 var isDragging = useCallback(function () {
6903 var state = getStore(lazyStoreRef).getState();
6904 return state.isDragging || state.phase === 'DROP_ANIMATING';
6905 }, []);
6906 var appCallbacks = useMemo(function () {
6907 return {
6908 isDragging: isDragging,
6909 tryAbort: tryResetStore
6910 };
6911 }, [isDragging, tryResetStore]);
6912 setCallbacks(appCallbacks);
6913 var getCanLift = useCallback(function (id) {
6914 return canStartDrag(getStore(lazyStoreRef).getState(), id);
6915 }, []);
6916 var getIsMovementAllowed = useCallback(function () {
6917 return isMovementAllowed(getStore(lazyStoreRef).getState());
6918 }, []);
6919 var appContext = useMemo(function () {
6920 return {
6921 marshal: dimensionMarshal,
6922 focus: focusMarshal,
6923 contextId: contextId,
6924 canLift: getCanLift,
6925 isMovementAllowed: getIsMovementAllowed,
6926 dragHandleUsageInstructionsId: dragHandleUsageInstructionsId,
6927 registry: registry
6928 };
6929 }, [contextId, dimensionMarshal, dragHandleUsageInstructionsId, focusMarshal, getCanLift, getIsMovementAllowed, registry]);
6930 useSensorMarshal({
6931 contextId: contextId,
6932 store: store,
6933 registry: registry,
6934 customSensors: sensors,
6935 enableDefaultSensors: props.enableDefaultSensors !== false
6936 });
6937 useEffect(function () {
6938 return tryResetStore;
6939 }, [tryResetStore]);
6940 return React.createElement(AppContext.Provider, {
6941 value: appContext
6942 }, React.createElement(Provider, {
6943 context: StoreContext,
6944 store: store
6945 }, props.children));
6946}
6947
6948var count$1 = 0;
6949function reset$1() {
6950 count$1 = 0;
6951}
6952function useInstanceCount() {
6953 return useMemo(function () {
6954 return "" + count$1++;
6955 }, []);
6956}
6957
6958function resetServerContext() {
6959 reset$1();
6960 reset();
6961}
6962function DragDropContext(props) {
6963 var contextId = useInstanceCount();
6964 var dragHandleUsageInstructions = props.dragHandleUsageInstructions || preset.dragHandleUsageInstructions;
6965 return React.createElement(ErrorBoundary, null, function (setCallbacks) {
6966 return React.createElement(App, {
6967 nonce: props.nonce,
6968 contextId: contextId,
6969 setCallbacks: setCallbacks,
6970 dragHandleUsageInstructions: dragHandleUsageInstructions,
6971 enableDefaultSensors: props.enableDefaultSensors,
6972 sensors: props.sensors,
6973 onBeforeCapture: props.onBeforeCapture,
6974 onBeforeDragStart: props.onBeforeDragStart,
6975 onDragStart: props.onDragStart,
6976 onDragUpdate: props.onDragUpdate,
6977 onDragEnd: props.onDragEnd
6978 }, props.children);
6979 });
6980}
6981
6982var isEqual$1 = function isEqual(base) {
6983 return function (value) {
6984 return base === value;
6985 };
6986};
6987
6988var isScroll = isEqual$1('scroll');
6989var isAuto = isEqual$1('auto');
6990var isVisible$1 = isEqual$1('visible');
6991
6992var isEither = function isEither(overflow, fn) {
6993 return fn(overflow.overflowX) || fn(overflow.overflowY);
6994};
6995
6996var isBoth = function isBoth(overflow, fn) {
6997 return fn(overflow.overflowX) && fn(overflow.overflowY);
6998};
6999
7000var isElementScrollable = function isElementScrollable(el) {
7001 var style = window.getComputedStyle(el);
7002 var overflow = {
7003 overflowX: style.overflowX,
7004 overflowY: style.overflowY
7005 };
7006 return isEither(overflow, isScroll) || isEither(overflow, isAuto);
7007};
7008
7009var isBodyScrollable = function isBodyScrollable() {
7010 if (process.env.NODE_ENV === 'production') {
7011 return false;
7012 }
7013
7014 var body = getBodyElement();
7015 var html = document.documentElement;
7016 !html ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
7017
7018 if (!isElementScrollable(body)) {
7019 return false;
7020 }
7021
7022 var htmlStyle = window.getComputedStyle(html);
7023 var htmlOverflow = {
7024 overflowX: htmlStyle.overflowX,
7025 overflowY: htmlStyle.overflowY
7026 };
7027
7028 if (isBoth(htmlOverflow, isVisible$1)) {
7029 return false;
7030 }
7031
7032 process.env.NODE_ENV !== "production" ? warning("\n We have detected that your <body> element might be a scroll container.\n We have found no reliable way of detecting whether the <body> element is a scroll container.\n Under most circumstances a <body> scroll bar will be on the <html> element (document.documentElement)\n\n Because we cannot determine if the <body> is a scroll container, and generally it is not one,\n we will be treating the <body> as *not* a scroll container\n\n More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/how-we-detect-scroll-containers.md\n ") : void 0;
7033 return false;
7034};
7035
7036var getClosestScrollable = function getClosestScrollable(el) {
7037 if (el == null) {
7038 return null;
7039 }
7040
7041 if (el === document.body) {
7042 return isBodyScrollable() ? el : null;
7043 }
7044
7045 if (el === document.documentElement) {
7046 return null;
7047 }
7048
7049 if (!isElementScrollable(el)) {
7050 return getClosestScrollable(el.parentElement);
7051 }
7052
7053 return el;
7054};
7055
7056var checkForNestedScrollContainers = (function (scrollable) {
7057 if (!scrollable) {
7058 return;
7059 }
7060
7061 var anotherScrollParent = getClosestScrollable(scrollable.parentElement);
7062
7063 if (!anotherScrollParent) {
7064 return;
7065 }
7066
7067 process.env.NODE_ENV !== "production" ? warning("\n Droppable: unsupported nested scroll container detected.\n A Droppable can only have one scroll parent (which can be itself)\n Nested scroll containers are currently not supported.\n\n We hope to support nested scroll containers soon: https://github.com/atlassian/react-beautiful-dnd/issues/131\n ") : void 0;
7068});
7069
7070var getScroll$1 = (function (el) {
7071 return {
7072 x: el.scrollLeft,
7073 y: el.scrollTop
7074 };
7075});
7076
7077var getIsFixed = function getIsFixed(el) {
7078 if (!el) {
7079 return false;
7080 }
7081
7082 var style = window.getComputedStyle(el);
7083
7084 if (style.position === 'fixed') {
7085 return true;
7086 }
7087
7088 return getIsFixed(el.parentElement);
7089};
7090
7091var getEnv = (function (start) {
7092 var closestScrollable = getClosestScrollable(start);
7093 var isFixedOnPage = getIsFixed(start);
7094 return {
7095 closestScrollable: closestScrollable,
7096 isFixedOnPage: isFixedOnPage
7097 };
7098});
7099
7100var getDroppableDimension = (function (_ref) {
7101 var descriptor = _ref.descriptor,
7102 isEnabled = _ref.isEnabled,
7103 isCombineEnabled = _ref.isCombineEnabled,
7104 isFixedOnPage = _ref.isFixedOnPage,
7105 direction = _ref.direction,
7106 client = _ref.client,
7107 page = _ref.page,
7108 closest = _ref.closest;
7109
7110 var frame = function () {
7111 if (!closest) {
7112 return null;
7113 }
7114
7115 var scrollSize = closest.scrollSize,
7116 frameClient = closest.client;
7117 var maxScroll = getMaxScroll({
7118 scrollHeight: scrollSize.scrollHeight,
7119 scrollWidth: scrollSize.scrollWidth,
7120 height: frameClient.paddingBox.height,
7121 width: frameClient.paddingBox.width
7122 });
7123 return {
7124 pageMarginBox: closest.page.marginBox,
7125 frameClient: frameClient,
7126 scrollSize: scrollSize,
7127 shouldClipSubject: closest.shouldClipSubject,
7128 scroll: {
7129 initial: closest.scroll,
7130 current: closest.scroll,
7131 max: maxScroll,
7132 diff: {
7133 value: origin,
7134 displacement: origin
7135 }
7136 }
7137 };
7138 }();
7139
7140 var axis = direction === 'vertical' ? vertical : horizontal;
7141 var subject = getSubject({
7142 page: page,
7143 withPlaceholder: null,
7144 axis: axis,
7145 frame: frame
7146 });
7147 var dimension = {
7148 descriptor: descriptor,
7149 isCombineEnabled: isCombineEnabled,
7150 isFixedOnPage: isFixedOnPage,
7151 axis: axis,
7152 isEnabled: isEnabled,
7153 client: client,
7154 page: page,
7155 frame: frame,
7156 subject: subject
7157 };
7158 return dimension;
7159});
7160
7161var getClient = function getClient(targetRef, closestScrollable) {
7162 var base = getBox(targetRef);
7163
7164 if (!closestScrollable) {
7165 return base;
7166 }
7167
7168 if (targetRef !== closestScrollable) {
7169 return base;
7170 }
7171
7172 var top = base.paddingBox.top - closestScrollable.scrollTop;
7173 var left = base.paddingBox.left - closestScrollable.scrollLeft;
7174 var bottom = top + closestScrollable.scrollHeight;
7175 var right = left + closestScrollable.scrollWidth;
7176 var paddingBox = {
7177 top: top,
7178 right: right,
7179 bottom: bottom,
7180 left: left
7181 };
7182 var borderBox = expand(paddingBox, base.border);
7183 var client = createBox({
7184 borderBox: borderBox,
7185 margin: base.margin,
7186 border: base.border,
7187 padding: base.padding
7188 });
7189 return client;
7190};
7191
7192var getDimension = (function (_ref) {
7193 var ref = _ref.ref,
7194 descriptor = _ref.descriptor,
7195 env = _ref.env,
7196 windowScroll = _ref.windowScroll,
7197 direction = _ref.direction,
7198 isDropDisabled = _ref.isDropDisabled,
7199 isCombineEnabled = _ref.isCombineEnabled,
7200 shouldClipSubject = _ref.shouldClipSubject;
7201 var closestScrollable = env.closestScrollable;
7202 var client = getClient(ref, closestScrollable);
7203 var page = withScroll(client, windowScroll);
7204
7205 var closest = function () {
7206 if (!closestScrollable) {
7207 return null;
7208 }
7209
7210 var frameClient = getBox(closestScrollable);
7211 var scrollSize = {
7212 scrollHeight: closestScrollable.scrollHeight,
7213 scrollWidth: closestScrollable.scrollWidth
7214 };
7215 return {
7216 client: frameClient,
7217 page: withScroll(frameClient, windowScroll),
7218 scroll: getScroll$1(closestScrollable),
7219 scrollSize: scrollSize,
7220 shouldClipSubject: shouldClipSubject
7221 };
7222 }();
7223
7224 var dimension = getDroppableDimension({
7225 descriptor: descriptor,
7226 isEnabled: !isDropDisabled,
7227 isCombineEnabled: isCombineEnabled,
7228 isFixedOnPage: env.isFixedOnPage,
7229 direction: direction,
7230 client: client,
7231 page: page,
7232 closest: closest
7233 });
7234 return dimension;
7235});
7236
7237var immediate = {
7238 passive: false
7239};
7240var delayed = {
7241 passive: true
7242};
7243var getListenerOptions = (function (options) {
7244 return options.shouldPublishImmediately ? immediate : delayed;
7245});
7246
7247function useRequiredContext(Context) {
7248 var result = useContext(Context);
7249 !result ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find required context') : invariant(false) : void 0;
7250 return result;
7251}
7252
7253var getClosestScrollableFromDrag = function getClosestScrollableFromDrag(dragging) {
7254 return dragging && dragging.env.closestScrollable || null;
7255};
7256
7257function useDroppablePublisher(args) {
7258 var whileDraggingRef = useRef(null);
7259 var appContext = useRequiredContext(AppContext);
7260 var uniqueId = useUniqueId('droppable');
7261 var registry = appContext.registry,
7262 marshal = appContext.marshal;
7263 var previousRef = usePrevious(args);
7264 var descriptor = useMemo(function () {
7265 return {
7266 id: args.droppableId,
7267 type: args.type,
7268 mode: args.mode
7269 };
7270 }, [args.droppableId, args.mode, args.type]);
7271 var publishedDescriptorRef = useRef(descriptor);
7272 var memoizedUpdateScroll = useMemo(function () {
7273 return memoizeOne(function (x, y) {
7274 !whileDraggingRef.current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only update scroll when dragging') : invariant(false) : void 0;
7275 var scroll = {
7276 x: x,
7277 y: y
7278 };
7279 marshal.updateDroppableScroll(descriptor.id, scroll);
7280 });
7281 }, [descriptor.id, marshal]);
7282 var getClosestScroll = useCallback(function () {
7283 var dragging = whileDraggingRef.current;
7284
7285 if (!dragging || !dragging.env.closestScrollable) {
7286 return origin;
7287 }
7288
7289 return getScroll$1(dragging.env.closestScrollable);
7290 }, []);
7291 var updateScroll = useCallback(function () {
7292 var scroll = getClosestScroll();
7293 memoizedUpdateScroll(scroll.x, scroll.y);
7294 }, [getClosestScroll, memoizedUpdateScroll]);
7295 var scheduleScrollUpdate = useMemo(function () {
7296 return rafSchd(updateScroll);
7297 }, [updateScroll]);
7298 var onClosestScroll = useCallback(function () {
7299 var dragging = whileDraggingRef.current;
7300 var closest = getClosestScrollableFromDrag(dragging);
7301 !(dragging && closest) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find scroll options while scrolling') : invariant(false) : void 0;
7302 var options = dragging.scrollOptions;
7303
7304 if (options.shouldPublishImmediately) {
7305 updateScroll();
7306 return;
7307 }
7308
7309 scheduleScrollUpdate();
7310 }, [scheduleScrollUpdate, updateScroll]);
7311 var getDimensionAndWatchScroll = useCallback(function (windowScroll, options) {
7312 !!whileDraggingRef.current ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot collect a droppable while a drag is occurring') : invariant(false) : void 0;
7313 var previous = previousRef.current;
7314 var ref = previous.getDroppableRef();
7315 !ref ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot collect without a droppable ref') : invariant(false) : void 0;
7316 var env = getEnv(ref);
7317 var dragging = {
7318 ref: ref,
7319 descriptor: descriptor,
7320 env: env,
7321 scrollOptions: options
7322 };
7323 whileDraggingRef.current = dragging;
7324 var dimension = getDimension({
7325 ref: ref,
7326 descriptor: descriptor,
7327 env: env,
7328 windowScroll: windowScroll,
7329 direction: previous.direction,
7330 isDropDisabled: previous.isDropDisabled,
7331 isCombineEnabled: previous.isCombineEnabled,
7332 shouldClipSubject: !previous.ignoreContainerClipping
7333 });
7334 var scrollable = env.closestScrollable;
7335
7336 if (scrollable) {
7337 scrollable.setAttribute(scrollContainer.contextId, appContext.contextId);
7338 scrollable.addEventListener('scroll', onClosestScroll, getListenerOptions(dragging.scrollOptions));
7339
7340 if (process.env.NODE_ENV !== 'production') {
7341 checkForNestedScrollContainers(scrollable);
7342 }
7343 }
7344
7345 return dimension;
7346 }, [appContext.contextId, descriptor, onClosestScroll, previousRef]);
7347 var getScrollWhileDragging = useCallback(function () {
7348 var dragging = whileDraggingRef.current;
7349 var closest = getClosestScrollableFromDrag(dragging);
7350 !(dragging && closest) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Can only recollect Droppable client for Droppables that have a scroll container') : invariant(false) : void 0;
7351 return getScroll$1(closest);
7352 }, []);
7353 var dragStopped = useCallback(function () {
7354 var dragging = whileDraggingRef.current;
7355 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot stop drag when no active drag') : invariant(false) : void 0;
7356 var closest = getClosestScrollableFromDrag(dragging);
7357 whileDraggingRef.current = null;
7358
7359 if (!closest) {
7360 return;
7361 }
7362
7363 scheduleScrollUpdate.cancel();
7364 closest.removeAttribute(scrollContainer.contextId);
7365 closest.removeEventListener('scroll', onClosestScroll, getListenerOptions(dragging.scrollOptions));
7366 }, [onClosestScroll, scheduleScrollUpdate]);
7367 var scroll = useCallback(function (change) {
7368 var dragging = whileDraggingRef.current;
7369 !dragging ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot scroll when there is no drag') : invariant(false) : void 0;
7370 var closest = getClosestScrollableFromDrag(dragging);
7371 !closest ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot scroll a droppable with no closest scrollable') : invariant(false) : void 0;
7372 closest.scrollTop += change.y;
7373 closest.scrollLeft += change.x;
7374 }, []);
7375 var callbacks = useMemo(function () {
7376 return {
7377 getDimensionAndWatchScroll: getDimensionAndWatchScroll,
7378 getScrollWhileDragging: getScrollWhileDragging,
7379 dragStopped: dragStopped,
7380 scroll: scroll
7381 };
7382 }, [dragStopped, getDimensionAndWatchScroll, getScrollWhileDragging, scroll]);
7383 var entry = useMemo(function () {
7384 return {
7385 uniqueId: uniqueId,
7386 descriptor: descriptor,
7387 callbacks: callbacks
7388 };
7389 }, [callbacks, descriptor, uniqueId]);
7390 useIsomorphicLayoutEffect(function () {
7391 publishedDescriptorRef.current = entry.descriptor;
7392 registry.droppable.register(entry);
7393 return function () {
7394 if (whileDraggingRef.current) {
7395 process.env.NODE_ENV !== "production" ? warning('Unsupported: changing the droppableId or type of a Droppable during a drag') : void 0;
7396 dragStopped();
7397 }
7398
7399 registry.droppable.unregister(entry);
7400 };
7401 }, [callbacks, descriptor, dragStopped, entry, marshal, registry.droppable]);
7402 useIsomorphicLayoutEffect(function () {
7403 if (!whileDraggingRef.current) {
7404 return;
7405 }
7406
7407 marshal.updateDroppableIsEnabled(publishedDescriptorRef.current.id, !args.isDropDisabled);
7408 }, [args.isDropDisabled, marshal]);
7409 useIsomorphicLayoutEffect(function () {
7410 if (!whileDraggingRef.current) {
7411 return;
7412 }
7413
7414 marshal.updateDroppableIsCombineEnabled(publishedDescriptorRef.current.id, args.isCombineEnabled);
7415 }, [args.isCombineEnabled, marshal]);
7416}
7417
7418function noop$2() {}
7419
7420var empty = {
7421 width: 0,
7422 height: 0,
7423 margin: noSpacing
7424};
7425
7426var getSize = function getSize(_ref) {
7427 var isAnimatingOpenOnMount = _ref.isAnimatingOpenOnMount,
7428 placeholder = _ref.placeholder,
7429 animate = _ref.animate;
7430
7431 if (isAnimatingOpenOnMount) {
7432 return empty;
7433 }
7434
7435 if (animate === 'close') {
7436 return empty;
7437 }
7438
7439 return {
7440 height: placeholder.client.borderBox.height,
7441 width: placeholder.client.borderBox.width,
7442 margin: placeholder.client.margin
7443 };
7444};
7445
7446var getStyle = function getStyle(_ref2) {
7447 var isAnimatingOpenOnMount = _ref2.isAnimatingOpenOnMount,
7448 placeholder = _ref2.placeholder,
7449 animate = _ref2.animate;
7450 var size = getSize({
7451 isAnimatingOpenOnMount: isAnimatingOpenOnMount,
7452 placeholder: placeholder,
7453 animate: animate
7454 });
7455 return {
7456 display: placeholder.display,
7457 boxSizing: 'border-box',
7458 width: size.width,
7459 height: size.height,
7460 marginTop: size.margin.top,
7461 marginRight: size.margin.right,
7462 marginBottom: size.margin.bottom,
7463 marginLeft: size.margin.left,
7464 flexShrink: '0',
7465 flexGrow: '0',
7466 pointerEvents: 'none',
7467 transition: animate !== 'none' ? transitions.placeholder : null
7468 };
7469};
7470
7471function Placeholder(props) {
7472 var animateOpenTimerRef = useRef(null);
7473 var tryClearAnimateOpenTimer = useCallback(function () {
7474 if (!animateOpenTimerRef.current) {
7475 return;
7476 }
7477
7478 clearTimeout(animateOpenTimerRef.current);
7479 animateOpenTimerRef.current = null;
7480 }, []);
7481 var animate = props.animate,
7482 onTransitionEnd = props.onTransitionEnd,
7483 onClose = props.onClose,
7484 contextId = props.contextId;
7485
7486 var _useState = useState(props.animate === 'open'),
7487 isAnimatingOpenOnMount = _useState[0],
7488 setIsAnimatingOpenOnMount = _useState[1];
7489
7490 useEffect(function () {
7491 if (!isAnimatingOpenOnMount) {
7492 return noop$2;
7493 }
7494
7495 if (animate !== 'open') {
7496 tryClearAnimateOpenTimer();
7497 setIsAnimatingOpenOnMount(false);
7498 return noop$2;
7499 }
7500
7501 if (animateOpenTimerRef.current) {
7502 return noop$2;
7503 }
7504
7505 animateOpenTimerRef.current = setTimeout(function () {
7506 animateOpenTimerRef.current = null;
7507 setIsAnimatingOpenOnMount(false);
7508 });
7509 return tryClearAnimateOpenTimer;
7510 }, [animate, isAnimatingOpenOnMount, tryClearAnimateOpenTimer]);
7511 var onSizeChangeEnd = useCallback(function (event) {
7512 if (event.propertyName !== 'height') {
7513 return;
7514 }
7515
7516 onTransitionEnd();
7517
7518 if (animate === 'close') {
7519 onClose();
7520 }
7521 }, [animate, onClose, onTransitionEnd]);
7522 var style = getStyle({
7523 isAnimatingOpenOnMount: isAnimatingOpenOnMount,
7524 animate: props.animate,
7525 placeholder: props.placeholder
7526 });
7527 return React.createElement(props.placeholder.tagName, {
7528 style: style,
7529 'data-rbd-placeholder-context-id': contextId,
7530 onTransitionEnd: onSizeChangeEnd,
7531 ref: props.innerRef
7532 });
7533}
7534
7535var Placeholder$1 = React.memo(Placeholder);
7536
7537var DroppableContext = React.createContext(null);
7538
7539function checkIsValidInnerRef(el) {
7540 !(el && isHtmlElement(el)) ? process.env.NODE_ENV !== "production" ? invariant(false, "\n provided.innerRef has not been provided with a HTMLElement.\n\n You can find a guide on using the innerRef callback functions at:\n https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/using-inner-ref.md\n ") : invariant(false) : void 0;
7541}
7542
7543function isBoolean(value) {
7544 return typeof value === 'boolean';
7545}
7546
7547function runChecks(args, checks) {
7548 checks.forEach(function (check) {
7549 return check(args);
7550 });
7551}
7552
7553var shared = [function required(_ref) {
7554 var props = _ref.props;
7555 !props.droppableId ? process.env.NODE_ENV !== "production" ? invariant(false, 'A Droppable requires a droppableId prop') : invariant(false) : void 0;
7556 !(typeof props.droppableId === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, "A Droppable requires a [string] droppableId. Provided: [" + typeof props.droppableId + "]") : invariant(false) : void 0;
7557}, function _boolean(_ref2) {
7558 var props = _ref2.props;
7559 !isBoolean(props.isDropDisabled) ? process.env.NODE_ENV !== "production" ? invariant(false, 'isDropDisabled must be a boolean') : invariant(false) : void 0;
7560 !isBoolean(props.isCombineEnabled) ? process.env.NODE_ENV !== "production" ? invariant(false, 'isCombineEnabled must be a boolean') : invariant(false) : void 0;
7561 !isBoolean(props.ignoreContainerClipping) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ignoreContainerClipping must be a boolean') : invariant(false) : void 0;
7562}, function ref(_ref3) {
7563 var getDroppableRef = _ref3.getDroppableRef;
7564 checkIsValidInnerRef(getDroppableRef());
7565}];
7566var standard = [function placeholder(_ref4) {
7567 var props = _ref4.props,
7568 getPlaceholderRef = _ref4.getPlaceholderRef;
7569
7570 if (!props.placeholder) {
7571 return;
7572 }
7573
7574 var ref = getPlaceholderRef();
7575
7576 if (ref) {
7577 return;
7578 }
7579
7580 process.env.NODE_ENV !== "production" ? warning("\n Droppable setup issue [droppableId: \"" + props.droppableId + "\"]:\n DroppableProvided > placeholder could not be found.\n\n Please be sure to add the {provided.placeholder} React Node as a child of your Droppable.\n More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/api/droppable.md\n ") : void 0;
7581}];
7582var virtual = [function hasClone(_ref5) {
7583 var props = _ref5.props;
7584 !props.renderClone ? process.env.NODE_ENV !== "production" ? invariant(false, 'Must provide a clone render function (renderClone) for virtual lists') : invariant(false) : void 0;
7585}, function hasNoPlaceholder(_ref6) {
7586 var getPlaceholderRef = _ref6.getPlaceholderRef;
7587 !!getPlaceholderRef() ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected virtual list to not have a placeholder') : invariant(false) : void 0;
7588}];
7589function useValidation(args) {
7590 useDevSetupWarning(function () {
7591 runChecks(args, shared);
7592
7593 if (args.props.mode === 'standard') {
7594 runChecks(args, standard);
7595 }
7596
7597 if (args.props.mode === 'virtual') {
7598 runChecks(args, virtual);
7599 }
7600 });
7601}
7602
7603var AnimateInOut = function (_React$PureComponent) {
7604 _inheritsLoose(AnimateInOut, _React$PureComponent);
7605
7606 function AnimateInOut() {
7607 var _this;
7608
7609 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7610 args[_key] = arguments[_key];
7611 }
7612
7613 _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
7614 _this.state = {
7615 isVisible: Boolean(_this.props.on),
7616 data: _this.props.on,
7617 animate: _this.props.shouldAnimate && _this.props.on ? 'open' : 'none'
7618 };
7619
7620 _this.onClose = function () {
7621 if (_this.state.animate !== 'close') {
7622 return;
7623 }
7624
7625 _this.setState({
7626 isVisible: false
7627 });
7628 };
7629
7630 return _this;
7631 }
7632
7633 AnimateInOut.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
7634 if (!props.shouldAnimate) {
7635 return {
7636 isVisible: Boolean(props.on),
7637 data: props.on,
7638 animate: 'none'
7639 };
7640 }
7641
7642 if (props.on) {
7643 return {
7644 isVisible: true,
7645 data: props.on,
7646 animate: 'open'
7647 };
7648 }
7649
7650 if (state.isVisible) {
7651 return {
7652 isVisible: true,
7653 data: state.data,
7654 animate: 'close'
7655 };
7656 }
7657
7658 return {
7659 isVisible: false,
7660 animate: 'close',
7661 data: null
7662 };
7663 };
7664
7665 var _proto = AnimateInOut.prototype;
7666
7667 _proto.render = function render() {
7668 if (!this.state.isVisible) {
7669 return null;
7670 }
7671
7672 var provided = {
7673 onClose: this.onClose,
7674 data: this.state.data,
7675 animate: this.state.animate
7676 };
7677 return this.props.children(provided);
7678 };
7679
7680 return AnimateInOut;
7681}(React.PureComponent);
7682
7683var zIndexOptions = {
7684 dragging: 5000,
7685 dropAnimating: 4500
7686};
7687
7688var getDraggingTransition = function getDraggingTransition(shouldAnimateDragMovement, dropping) {
7689 if (dropping) {
7690 return transitions.drop(dropping.duration);
7691 }
7692
7693 if (shouldAnimateDragMovement) {
7694 return transitions.snap;
7695 }
7696
7697 return transitions.fluid;
7698};
7699
7700var getDraggingOpacity = function getDraggingOpacity(isCombining, isDropAnimating) {
7701 if (!isCombining) {
7702 return null;
7703 }
7704
7705 return isDropAnimating ? combine.opacity.drop : combine.opacity.combining;
7706};
7707
7708var getShouldDraggingAnimate = function getShouldDraggingAnimate(dragging) {
7709 if (dragging.forceShouldAnimate != null) {
7710 return dragging.forceShouldAnimate;
7711 }
7712
7713 return dragging.mode === 'SNAP';
7714};
7715
7716function getDraggingStyle(dragging) {
7717 var dimension = dragging.dimension;
7718 var box = dimension.client;
7719 var offset = dragging.offset,
7720 combineWith = dragging.combineWith,
7721 dropping = dragging.dropping;
7722 var isCombining = Boolean(combineWith);
7723 var shouldAnimate = getShouldDraggingAnimate(dragging);
7724 var isDropAnimating = Boolean(dropping);
7725 var transform = isDropAnimating ? transforms.drop(offset, isCombining) : transforms.moveTo(offset);
7726 var style = {
7727 position: 'fixed',
7728 top: box.marginBox.top,
7729 left: box.marginBox.left,
7730 boxSizing: 'border-box',
7731 width: box.borderBox.width,
7732 height: box.borderBox.height,
7733 transition: getDraggingTransition(shouldAnimate, dropping),
7734 transform: transform,
7735 opacity: getDraggingOpacity(isCombining, isDropAnimating),
7736 zIndex: isDropAnimating ? zIndexOptions.dropAnimating : zIndexOptions.dragging,
7737 pointerEvents: 'none'
7738 };
7739 return style;
7740}
7741
7742function getSecondaryStyle(secondary) {
7743 return {
7744 transform: transforms.moveTo(secondary.offset),
7745 transition: secondary.shouldAnimateDisplacement ? null : 'none'
7746 };
7747}
7748
7749function getStyle$1(mapped) {
7750 return mapped.type === 'DRAGGING' ? getDraggingStyle(mapped) : getSecondaryStyle(mapped);
7751}
7752
7753function getDimension$1(descriptor, el, windowScroll) {
7754 if (windowScroll === void 0) {
7755 windowScroll = origin;
7756 }
7757
7758 var computedStyles = window.getComputedStyle(el);
7759 var borderBox = el.getBoundingClientRect();
7760 var client = calculateBox(borderBox, computedStyles);
7761 var page = withScroll(client, windowScroll);
7762 var placeholder = {
7763 client: client,
7764 tagName: el.tagName.toLowerCase(),
7765 display: computedStyles.display
7766 };
7767 var displaceBy = {
7768 x: client.marginBox.width,
7769 y: client.marginBox.height
7770 };
7771 var dimension = {
7772 descriptor: descriptor,
7773 placeholder: placeholder,
7774 displaceBy: displaceBy,
7775 client: client,
7776 page: page
7777 };
7778 return dimension;
7779}
7780
7781function useDraggablePublisher(args) {
7782 var uniqueId = useUniqueId('draggable');
7783 var descriptor = args.descriptor,
7784 registry = args.registry,
7785 getDraggableRef = args.getDraggableRef,
7786 canDragInteractiveElements = args.canDragInteractiveElements,
7787 shouldRespectForcePress = args.shouldRespectForcePress,
7788 isEnabled = args.isEnabled;
7789 var options = useMemo(function () {
7790 return {
7791 canDragInteractiveElements: canDragInteractiveElements,
7792 shouldRespectForcePress: shouldRespectForcePress,
7793 isEnabled: isEnabled
7794 };
7795 }, [canDragInteractiveElements, isEnabled, shouldRespectForcePress]);
7796 var getDimension = useCallback(function (windowScroll) {
7797 var el = getDraggableRef();
7798 !el ? process.env.NODE_ENV !== "production" ? invariant(false, 'Cannot get dimension when no ref is set') : invariant(false) : void 0;
7799 return getDimension$1(descriptor, el, windowScroll);
7800 }, [descriptor, getDraggableRef]);
7801 var entry = useMemo(function () {
7802 return {
7803 uniqueId: uniqueId,
7804 descriptor: descriptor,
7805 options: options,
7806 getDimension: getDimension
7807 };
7808 }, [descriptor, getDimension, options, uniqueId]);
7809 var publishedRef = useRef(entry);
7810 var isFirstPublishRef = useRef(true);
7811 useIsomorphicLayoutEffect(function () {
7812 registry.draggable.register(publishedRef.current);
7813 return function () {
7814 return registry.draggable.unregister(publishedRef.current);
7815 };
7816 }, [registry.draggable]);
7817 useIsomorphicLayoutEffect(function () {
7818 if (isFirstPublishRef.current) {
7819 isFirstPublishRef.current = false;
7820 return;
7821 }
7822
7823 var last = publishedRef.current;
7824 publishedRef.current = entry;
7825 registry.draggable.update(entry, last);
7826 }, [entry, registry.draggable]);
7827}
7828
7829function useValidation$1(props, contextId, getRef) {
7830 useDevSetupWarning(function () {
7831 function prefix(id) {
7832 return "Draggable[id: " + id + "]: ";
7833 }
7834
7835 var id = props.draggableId;
7836 !id ? process.env.NODE_ENV !== "production" ? invariant(false, 'Draggable requires a draggableId') : invariant(false) : void 0;
7837 !(typeof id === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, "Draggable requires a [string] draggableId.\n Provided: [type: " + typeof id + "] (value: " + id + ")") : invariant(false) : void 0;
7838 !isInteger(props.index) ? process.env.NODE_ENV !== "production" ? invariant(false, prefix(id) + " requires an integer index prop") : invariant(false) : void 0;
7839
7840 if (props.mapped.type === 'DRAGGING') {
7841 return;
7842 }
7843
7844 checkIsValidInnerRef(getRef());
7845
7846 if (props.isEnabled) {
7847 !findDragHandle(contextId, id) ? process.env.NODE_ENV !== "production" ? invariant(false, prefix(id) + " Unable to find drag handle") : invariant(false) : void 0;
7848 }
7849 });
7850}
7851function useClonePropValidation(isClone) {
7852 useDev(function () {
7853 var initialRef = useRef(isClone);
7854 useDevSetupWarning(function () {
7855 !(isClone === initialRef.current) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Draggable isClone prop value changed during component life') : invariant(false) : void 0;
7856 }, [isClone]);
7857 });
7858}
7859
7860function preventHtml5Dnd(event) {
7861 event.preventDefault();
7862}
7863
7864function Draggable(props) {
7865 var ref = useRef(null);
7866 var setRef = useCallback(function (el) {
7867 ref.current = el;
7868 }, []);
7869 var getRef = useCallback(function () {
7870 return ref.current;
7871 }, []);
7872
7873 var _useRequiredContext = useRequiredContext(AppContext),
7874 contextId = _useRequiredContext.contextId,
7875 dragHandleUsageInstructionsId = _useRequiredContext.dragHandleUsageInstructionsId,
7876 registry = _useRequiredContext.registry;
7877
7878 var _useRequiredContext2 = useRequiredContext(DroppableContext),
7879 type = _useRequiredContext2.type,
7880 droppableId = _useRequiredContext2.droppableId;
7881
7882 var descriptor = useMemo(function () {
7883 return {
7884 id: props.draggableId,
7885 index: props.index,
7886 type: type,
7887 droppableId: droppableId
7888 };
7889 }, [props.draggableId, props.index, type, droppableId]);
7890 var children = props.children,
7891 draggableId = props.draggableId,
7892 isEnabled = props.isEnabled,
7893 shouldRespectForcePress = props.shouldRespectForcePress,
7894 canDragInteractiveElements = props.canDragInteractiveElements,
7895 isClone = props.isClone,
7896 mapped = props.mapped,
7897 dropAnimationFinishedAction = props.dropAnimationFinished;
7898 useValidation$1(props, contextId, getRef);
7899 useClonePropValidation(isClone);
7900
7901 if (!isClone) {
7902 var forPublisher = useMemo(function () {
7903 return {
7904 descriptor: descriptor,
7905 registry: registry,
7906 getDraggableRef: getRef,
7907 canDragInteractiveElements: canDragInteractiveElements,
7908 shouldRespectForcePress: shouldRespectForcePress,
7909 isEnabled: isEnabled
7910 };
7911 }, [descriptor, registry, getRef, canDragInteractiveElements, shouldRespectForcePress, isEnabled]);
7912 useDraggablePublisher(forPublisher);
7913 }
7914
7915 var dragHandleProps = useMemo(function () {
7916 return isEnabled ? {
7917 tabIndex: 0,
7918 role: 'button',
7919 'aria-describedby': dragHandleUsageInstructionsId,
7920 'data-rbd-drag-handle-draggable-id': draggableId,
7921 'data-rbd-drag-handle-context-id': contextId,
7922 draggable: false,
7923 onDragStart: preventHtml5Dnd
7924 } : null;
7925 }, [contextId, dragHandleUsageInstructionsId, draggableId, isEnabled]);
7926 var onMoveEnd = useCallback(function (event) {
7927 if (mapped.type !== 'DRAGGING') {
7928 return;
7929 }
7930
7931 if (!mapped.dropping) {
7932 return;
7933 }
7934
7935 if (event.propertyName !== 'transform') {
7936 return;
7937 }
7938
7939 dropAnimationFinishedAction();
7940 }, [dropAnimationFinishedAction, mapped]);
7941 var provided = useMemo(function () {
7942 var style = getStyle$1(mapped);
7943 var onTransitionEnd = mapped.type === 'DRAGGING' && mapped.dropping ? onMoveEnd : null;
7944 var result = {
7945 innerRef: setRef,
7946 draggableProps: {
7947 'data-rbd-draggable-context-id': contextId,
7948 'data-rbd-draggable-id': draggableId,
7949 style: style,
7950 onTransitionEnd: onTransitionEnd
7951 },
7952 dragHandleProps: dragHandleProps
7953 };
7954 return result;
7955 }, [contextId, dragHandleProps, draggableId, mapped, onMoveEnd, setRef]);
7956 var rubric = useMemo(function () {
7957 return {
7958 draggableId: descriptor.id,
7959 type: descriptor.type,
7960 source: {
7961 index: descriptor.index,
7962 droppableId: descriptor.droppableId
7963 }
7964 };
7965 }, [descriptor.droppableId, descriptor.id, descriptor.index, descriptor.type]);
7966 return children(provided, mapped.snapshot, rubric);
7967}
7968
7969var isStrictEqual = (function (a, b) {
7970 return a === b;
7971});
7972
7973var whatIsDraggedOverFromResult = (function (result) {
7974 var combine = result.combine,
7975 destination = result.destination;
7976
7977 if (destination) {
7978 return destination.droppableId;
7979 }
7980
7981 if (combine) {
7982 return combine.droppableId;
7983 }
7984
7985 return null;
7986});
7987
7988var getCombineWithFromResult = function getCombineWithFromResult(result) {
7989 return result.combine ? result.combine.draggableId : null;
7990};
7991
7992var getCombineWithFromImpact = function getCombineWithFromImpact(impact) {
7993 return impact.at && impact.at.type === 'COMBINE' ? impact.at.combine.draggableId : null;
7994};
7995
7996function getDraggableSelector() {
7997 var memoizedOffset = memoizeOne(function (x, y) {
7998 return {
7999 x: x,
8000 y: y
8001 };
8002 });
8003 var getMemoizedSnapshot = memoizeOne(function (mode, isClone, draggingOver, combineWith, dropping) {
8004 return {
8005 isDragging: true,
8006 isClone: isClone,
8007 isDropAnimating: Boolean(dropping),
8008 dropAnimation: dropping,
8009 mode: mode,
8010 draggingOver: draggingOver,
8011 combineWith: combineWith,
8012 combineTargetFor: null
8013 };
8014 });
8015 var getMemoizedProps = memoizeOne(function (offset, mode, dimension, isClone, draggingOver, combineWith, forceShouldAnimate) {
8016 return {
8017 mapped: {
8018 type: 'DRAGGING',
8019 dropping: null,
8020 draggingOver: draggingOver,
8021 combineWith: combineWith,
8022 mode: mode,
8023 offset: offset,
8024 dimension: dimension,
8025 forceShouldAnimate: forceShouldAnimate,
8026 snapshot: getMemoizedSnapshot(mode, isClone, draggingOver, combineWith, null)
8027 }
8028 };
8029 });
8030
8031 var selector = function selector(state, ownProps) {
8032 if (state.isDragging) {
8033 if (state.critical.draggable.id !== ownProps.draggableId) {
8034 return null;
8035 }
8036
8037 var offset = state.current.client.offset;
8038 var dimension = state.dimensions.draggables[ownProps.draggableId];
8039 var draggingOver = whatIsDraggedOver(state.impact);
8040 var combineWith = getCombineWithFromImpact(state.impact);
8041 var forceShouldAnimate = state.forceShouldAnimate;
8042 return getMemoizedProps(memoizedOffset(offset.x, offset.y), state.movementMode, dimension, ownProps.isClone, draggingOver, combineWith, forceShouldAnimate);
8043 }
8044
8045 if (state.phase === 'DROP_ANIMATING') {
8046 var completed = state.completed;
8047
8048 if (completed.result.draggableId !== ownProps.draggableId) {
8049 return null;
8050 }
8051
8052 var isClone = ownProps.isClone;
8053 var _dimension = state.dimensions.draggables[ownProps.draggableId];
8054 var result = completed.result;
8055 var mode = result.mode;
8056
8057 var _draggingOver = whatIsDraggedOverFromResult(result);
8058
8059 var _combineWith = getCombineWithFromResult(result);
8060
8061 var duration = state.dropDuration;
8062 var dropping = {
8063 duration: duration,
8064 curve: curves.drop,
8065 moveTo: state.newHomeClientOffset,
8066 opacity: _combineWith ? combine.opacity.drop : null,
8067 scale: _combineWith ? combine.scale.drop : null
8068 };
8069 return {
8070 mapped: {
8071 type: 'DRAGGING',
8072 offset: state.newHomeClientOffset,
8073 dimension: _dimension,
8074 dropping: dropping,
8075 draggingOver: _draggingOver,
8076 combineWith: _combineWith,
8077 mode: mode,
8078 forceShouldAnimate: null,
8079 snapshot: getMemoizedSnapshot(mode, isClone, _draggingOver, _combineWith, dropping)
8080 }
8081 };
8082 }
8083
8084 return null;
8085 };
8086
8087 return selector;
8088}
8089
8090function getSecondarySnapshot(combineTargetFor) {
8091 return {
8092 isDragging: false,
8093 isDropAnimating: false,
8094 isClone: false,
8095 dropAnimation: null,
8096 mode: null,
8097 draggingOver: null,
8098 combineTargetFor: combineTargetFor,
8099 combineWith: null
8100 };
8101}
8102
8103var atRest = {
8104 mapped: {
8105 type: 'SECONDARY',
8106 offset: origin,
8107 combineTargetFor: null,
8108 shouldAnimateDisplacement: true,
8109 snapshot: getSecondarySnapshot(null)
8110 }
8111};
8112
8113function getSecondarySelector() {
8114 var memoizedOffset = memoizeOne(function (x, y) {
8115 return {
8116 x: x,
8117 y: y
8118 };
8119 });
8120 var getMemoizedSnapshot = memoizeOne(getSecondarySnapshot);
8121 var getMemoizedProps = memoizeOne(function (offset, combineTargetFor, shouldAnimateDisplacement) {
8122 if (combineTargetFor === void 0) {
8123 combineTargetFor = null;
8124 }
8125
8126 return {
8127 mapped: {
8128 type: 'SECONDARY',
8129 offset: offset,
8130 combineTargetFor: combineTargetFor,
8131 shouldAnimateDisplacement: shouldAnimateDisplacement,
8132 snapshot: getMemoizedSnapshot(combineTargetFor)
8133 }
8134 };
8135 });
8136
8137 var getFallback = function getFallback(combineTargetFor) {
8138 return combineTargetFor ? getMemoizedProps(origin, combineTargetFor, true) : null;
8139 };
8140
8141 var getProps = function getProps(ownId, draggingId, impact, afterCritical) {
8142 var visualDisplacement = impact.displaced.visible[ownId];
8143 var isAfterCriticalInVirtualList = Boolean(afterCritical.inVirtualList && afterCritical.effected[ownId]);
8144 var combine = tryGetCombine(impact);
8145 var combineTargetFor = combine && combine.draggableId === ownId ? draggingId : null;
8146
8147 if (!visualDisplacement) {
8148 if (!isAfterCriticalInVirtualList) {
8149 return getFallback(combineTargetFor);
8150 }
8151
8152 if (impact.displaced.invisible[ownId]) {
8153 return null;
8154 }
8155
8156 var change = negate(afterCritical.displacedBy.point);
8157
8158 var _offset = memoizedOffset(change.x, change.y);
8159
8160 return getMemoizedProps(_offset, combineTargetFor, true);
8161 }
8162
8163 if (isAfterCriticalInVirtualList) {
8164 return getFallback(combineTargetFor);
8165 }
8166
8167 var displaceBy = impact.displacedBy.point;
8168 var offset = memoizedOffset(displaceBy.x, displaceBy.y);
8169 return getMemoizedProps(offset, combineTargetFor, visualDisplacement.shouldAnimate);
8170 };
8171
8172 var selector = function selector(state, ownProps) {
8173 if (state.isDragging) {
8174 if (state.critical.draggable.id === ownProps.draggableId) {
8175 return null;
8176 }
8177
8178 return getProps(ownProps.draggableId, state.critical.draggable.id, state.impact, state.afterCritical);
8179 }
8180
8181 if (state.phase === 'DROP_ANIMATING') {
8182 var completed = state.completed;
8183
8184 if (completed.result.draggableId === ownProps.draggableId) {
8185 return null;
8186 }
8187
8188 return getProps(ownProps.draggableId, completed.result.draggableId, completed.impact, completed.afterCritical);
8189 }
8190
8191 return null;
8192 };
8193
8194 return selector;
8195}
8196
8197var makeMapStateToProps = function makeMapStateToProps() {
8198 var draggingSelector = getDraggableSelector();
8199 var secondarySelector = getSecondarySelector();
8200
8201 var selector = function selector(state, ownProps) {
8202 return draggingSelector(state, ownProps) || secondarySelector(state, ownProps) || atRest;
8203 };
8204
8205 return selector;
8206};
8207var mapDispatchToProps = {
8208 dropAnimationFinished: dropAnimationFinished
8209};
8210var ConnectedDraggable = connect(makeMapStateToProps, mapDispatchToProps, null, {
8211 context: StoreContext,
8212 pure: true,
8213 areStatePropsEqual: isStrictEqual
8214})(Draggable);
8215
8216function PrivateDraggable(props) {
8217 var droppableContext = useRequiredContext(DroppableContext);
8218 var isUsingCloneFor = droppableContext.isUsingCloneFor;
8219
8220 if (isUsingCloneFor === props.draggableId && !props.isClone) {
8221 return null;
8222 }
8223
8224 return React.createElement(ConnectedDraggable, props);
8225}
8226function PublicDraggable(props) {
8227 var isEnabled = typeof props.isDragDisabled === 'boolean' ? !props.isDragDisabled : true;
8228 var canDragInteractiveElements = Boolean(props.disableInteractiveElementBlocking);
8229 var shouldRespectForcePress = Boolean(props.shouldRespectForcePress);
8230 return React.createElement(PrivateDraggable, _extends({}, props, {
8231 isClone: false,
8232 isEnabled: isEnabled,
8233 canDragInteractiveElements: canDragInteractiveElements,
8234 shouldRespectForcePress: shouldRespectForcePress
8235 }));
8236}
8237
8238function Droppable(props) {
8239 var appContext = useContext(AppContext);
8240 !appContext ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not find app context') : invariant(false) : void 0;
8241 var contextId = appContext.contextId,
8242 isMovementAllowed = appContext.isMovementAllowed;
8243 var droppableRef = useRef(null);
8244 var placeholderRef = useRef(null);
8245 var children = props.children,
8246 droppableId = props.droppableId,
8247 type = props.type,
8248 mode = props.mode,
8249 direction = props.direction,
8250 ignoreContainerClipping = props.ignoreContainerClipping,
8251 isDropDisabled = props.isDropDisabled,
8252 isCombineEnabled = props.isCombineEnabled,
8253 snapshot = props.snapshot,
8254 useClone = props.useClone,
8255 updateViewportMaxScroll = props.updateViewportMaxScroll,
8256 getContainerForClone = props.getContainerForClone;
8257 var getDroppableRef = useCallback(function () {
8258 return droppableRef.current;
8259 }, []);
8260 var setDroppableRef = useCallback(function (value) {
8261 droppableRef.current = value;
8262 }, []);
8263 var getPlaceholderRef = useCallback(function () {
8264 return placeholderRef.current;
8265 }, []);
8266 var setPlaceholderRef = useCallback(function (value) {
8267 placeholderRef.current = value;
8268 }, []);
8269 useValidation({
8270 props: props,
8271 getDroppableRef: getDroppableRef,
8272 getPlaceholderRef: getPlaceholderRef
8273 });
8274 var onPlaceholderTransitionEnd = useCallback(function () {
8275 if (isMovementAllowed()) {
8276 updateViewportMaxScroll({
8277 maxScroll: getMaxWindowScroll()
8278 });
8279 }
8280 }, [isMovementAllowed, updateViewportMaxScroll]);
8281 useDroppablePublisher({
8282 droppableId: droppableId,
8283 type: type,
8284 mode: mode,
8285 direction: direction,
8286 isDropDisabled: isDropDisabled,
8287 isCombineEnabled: isCombineEnabled,
8288 ignoreContainerClipping: ignoreContainerClipping,
8289 getDroppableRef: getDroppableRef
8290 });
8291 var placeholder = React.createElement(AnimateInOut, {
8292 on: props.placeholder,
8293 shouldAnimate: props.shouldAnimatePlaceholder
8294 }, function (_ref) {
8295 var onClose = _ref.onClose,
8296 data = _ref.data,
8297 animate = _ref.animate;
8298 return React.createElement(Placeholder$1, {
8299 placeholder: data,
8300 onClose: onClose,
8301 innerRef: setPlaceholderRef,
8302 animate: animate,
8303 contextId: contextId,
8304 onTransitionEnd: onPlaceholderTransitionEnd
8305 });
8306 });
8307 var provided = useMemo(function () {
8308 return {
8309 innerRef: setDroppableRef,
8310 placeholder: placeholder,
8311 droppableProps: {
8312 'data-rbd-droppable-id': droppableId,
8313 'data-rbd-droppable-context-id': contextId
8314 }
8315 };
8316 }, [contextId, droppableId, placeholder, setDroppableRef]);
8317 var isUsingCloneFor = useClone ? useClone.dragging.draggableId : null;
8318 var droppableContext = useMemo(function () {
8319 return {
8320 droppableId: droppableId,
8321 type: type,
8322 isUsingCloneFor: isUsingCloneFor
8323 };
8324 }, [droppableId, isUsingCloneFor, type]);
8325
8326 function getClone() {
8327 if (!useClone) {
8328 return null;
8329 }
8330
8331 var dragging = useClone.dragging,
8332 render = useClone.render;
8333 var node = React.createElement(PrivateDraggable, {
8334 draggableId: dragging.draggableId,
8335 index: dragging.source.index,
8336 isClone: true,
8337 isEnabled: true,
8338 shouldRespectForcePress: false,
8339 canDragInteractiveElements: true
8340 }, function (draggableProvided, draggableSnapshot) {
8341 return render(draggableProvided, draggableSnapshot, dragging);
8342 });
8343 return ReactDOM.createPortal(node, getContainerForClone());
8344 }
8345
8346 return React.createElement(DroppableContext.Provider, {
8347 value: droppableContext
8348 }, children(provided, snapshot), getClone());
8349}
8350
8351var isMatchingType = function isMatchingType(type, critical) {
8352 return type === critical.droppable.type;
8353};
8354
8355var getDraggable = function getDraggable(critical, dimensions) {
8356 return dimensions.draggables[critical.draggable.id];
8357};
8358
8359var makeMapStateToProps$1 = function makeMapStateToProps() {
8360 var idleWithAnimation = {
8361 placeholder: null,
8362 shouldAnimatePlaceholder: true,
8363 snapshot: {
8364 isDraggingOver: false,
8365 draggingOverWith: null,
8366 draggingFromThisWith: null,
8367 isUsingPlaceholder: false
8368 },
8369 useClone: null
8370 };
8371
8372 var idleWithoutAnimation = _extends({}, idleWithAnimation, {
8373 shouldAnimatePlaceholder: false
8374 });
8375
8376 var getDraggableRubric = memoizeOne(function (descriptor) {
8377 return {
8378 draggableId: descriptor.id,
8379 type: descriptor.type,
8380 source: {
8381 index: descriptor.index,
8382 droppableId: descriptor.droppableId
8383 }
8384 };
8385 });
8386 var getMapProps = memoizeOne(function (id, isEnabled, isDraggingOverForConsumer, isDraggingOverForImpact, dragging, renderClone) {
8387 var draggableId = dragging.descriptor.id;
8388 var isHome = dragging.descriptor.droppableId === id;
8389
8390 if (isHome) {
8391 var useClone = renderClone ? {
8392 render: renderClone,
8393 dragging: getDraggableRubric(dragging.descriptor)
8394 } : null;
8395 var _snapshot = {
8396 isDraggingOver: isDraggingOverForConsumer,
8397 draggingOverWith: isDraggingOverForConsumer ? draggableId : null,
8398 draggingFromThisWith: draggableId,
8399 isUsingPlaceholder: true
8400 };
8401 return {
8402 placeholder: dragging.placeholder,
8403 shouldAnimatePlaceholder: false,
8404 snapshot: _snapshot,
8405 useClone: useClone
8406 };
8407 }
8408
8409 if (!isEnabled) {
8410 return idleWithoutAnimation;
8411 }
8412
8413 if (!isDraggingOverForImpact) {
8414 return idleWithAnimation;
8415 }
8416
8417 var snapshot = {
8418 isDraggingOver: isDraggingOverForConsumer,
8419 draggingOverWith: draggableId,
8420 draggingFromThisWith: null,
8421 isUsingPlaceholder: true
8422 };
8423 return {
8424 placeholder: dragging.placeholder,
8425 shouldAnimatePlaceholder: true,
8426 snapshot: snapshot,
8427 useClone: null
8428 };
8429 });
8430
8431 var selector = function selector(state, ownProps) {
8432 var id = ownProps.droppableId;
8433 var type = ownProps.type;
8434 var isEnabled = !ownProps.isDropDisabled;
8435 var renderClone = ownProps.renderClone;
8436
8437 if (state.isDragging) {
8438 var critical = state.critical;
8439
8440 if (!isMatchingType(type, critical)) {
8441 return idleWithoutAnimation;
8442 }
8443
8444 var dragging = getDraggable(critical, state.dimensions);
8445 var isDraggingOver = whatIsDraggedOver(state.impact) === id;
8446 return getMapProps(id, isEnabled, isDraggingOver, isDraggingOver, dragging, renderClone);
8447 }
8448
8449 if (state.phase === 'DROP_ANIMATING') {
8450 var completed = state.completed;
8451
8452 if (!isMatchingType(type, completed.critical)) {
8453 return idleWithoutAnimation;
8454 }
8455
8456 var _dragging = getDraggable(completed.critical, state.dimensions);
8457
8458 return getMapProps(id, isEnabled, whatIsDraggedOverFromResult(completed.result) === id, whatIsDraggedOver(completed.impact) === id, _dragging, renderClone);
8459 }
8460
8461 if (state.phase === 'IDLE' && state.completed && !state.shouldFlush) {
8462 var _completed = state.completed;
8463
8464 if (!isMatchingType(type, _completed.critical)) {
8465 return idleWithoutAnimation;
8466 }
8467
8468 var wasOver = whatIsDraggedOver(_completed.impact) === id;
8469 var wasCombining = Boolean(_completed.impact.at && _completed.impact.at.type === 'COMBINE');
8470 var isHome = _completed.critical.droppable.id === id;
8471
8472 if (wasOver) {
8473 return wasCombining ? idleWithAnimation : idleWithoutAnimation;
8474 }
8475
8476 if (isHome) {
8477 return idleWithAnimation;
8478 }
8479
8480 return idleWithoutAnimation;
8481 }
8482
8483 return idleWithoutAnimation;
8484 };
8485
8486 return selector;
8487};
8488var mapDispatchToProps$1 = {
8489 updateViewportMaxScroll: updateViewportMaxScroll
8490};
8491
8492function getBody() {
8493 !document.body ? process.env.NODE_ENV !== "production" ? invariant(false, 'document.body is not ready') : invariant(false) : void 0;
8494 return document.body;
8495}
8496
8497var defaultProps = {
8498 mode: 'standard',
8499 type: 'DEFAULT',
8500 direction: 'vertical',
8501 isDropDisabled: false,
8502 isCombineEnabled: false,
8503 ignoreContainerClipping: false,
8504 renderClone: null,
8505 getContainerForClone: getBody
8506};
8507var ConnectedDroppable = connect(makeMapStateToProps$1, mapDispatchToProps$1, null, {
8508 context: StoreContext,
8509 pure: true,
8510 areStatePropsEqual: isStrictEqual
8511})(Droppable);
8512ConnectedDroppable.defaultProps = defaultProps;
8513
8514export { DragDropContext, PublicDraggable as Draggable, ConnectedDroppable as Droppable, resetServerContext, useKeyboardSensor, useMouseSensor, useTouchSensor };