Socket
Socket
Sign inDemoInstall

react-sortable-hoc

Package Overview
Dependencies
11
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.10.0 to 1.10.1

8

CHANGELOG.md

@@ -5,2 +5,10 @@ # Change Log

<a name="1.10.1"></a>
## [1.10.1](https://github.com/clauderic/react-sortable-hoc/compare/v1.10.0...v1.10.1) (2019-08-22)
### Bug Fixes
- PropType definition for keyCodes was incorrect ([eaf5070](https://github.com/clauderic/react-sortable-hoc/commit/eaf5070))
<a name="1.10.0"></a>

@@ -7,0 +15,0 @@

2

dist/react-sortable-hoc.esm.js

@@ -509,3 +509,3 @@ import _extends from '@babel/runtime/helpers/esm/extends';

pressThreshold: PropTypes.number,
keyCodes: PropTypes.objectOf({
keyCodes: PropTypes.shape({
lift: PropTypes.arrayOf(PropTypes.number),

@@ -512,0 +512,0 @@ drop: PropTypes.arrayOf(PropTypes.number),

@@ -515,3 +515,3 @@ 'use strict';

pressThreshold: PropTypes.number,
keyCodes: PropTypes.objectOf({
keyCodes: PropTypes.shape({
lift: PropTypes.arrayOf(PropTypes.number),

@@ -518,0 +518,0 @@ drop: PropTypes.arrayOf(PropTypes.number),

@@ -785,3 +785,3 @@ (function (global, factory) {

pressThreshold: PropTypes.number,
keyCodes: PropTypes.objectOf({
keyCodes: PropTypes.shape({
lift: PropTypes.arrayOf(PropTypes.number),

@@ -788,0 +788,0 @@ drop: PropTypes.arrayOf(PropTypes.number),

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-dom"],t):t((e=e||self).SortableHOC={},e.React,e.PropTypes,e.ReactDOM)}(this,function(e,r,i,a){"use strict";function t(e,t){return e(t={exports:{}},t.exports),t.exports}i=i&&i.hasOwnProperty("default")?i.default:i;var s=t(function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},t.apply(this,arguments)}e.exports=t});var n=function(e){if(Array.isArray(e))return e};var o=function(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(o=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(r)throw i}}return n};var l=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var b=function(e,t){return n(e)||o(e,t)||l()};var c=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};var I=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(e){c(t,e,n[e])})}return t};var u=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function d(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var f=function(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),e},h=t(function(t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=o=function(e){return n(e)}:t.exports=o=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)},o(e)}t.exports=o});var p=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var y=function(e,t){return!t||"object"!==h(t)&&"function"!=typeof t?p(e):t},g=t(function(t){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}t.exports=n}),v=t(function(n){function o(e,t){return n.exports=o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}n.exports=o});var m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)},w=function(e,t,n,o,r,i,a,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,r,i,a,s],u=0;(l=new Error(t.replace(/%s/g,function(){return c[u++]}))).name="Invariant Violation"}throw l.framesToPop=1,l}},x=function(){function e(){u(this,e),c(this,"refs",{})}return f(e,[{key:"add",value:function(e,t){this.refs[e]||(this.refs[e]=[]),this.refs[e].push(t)}},{key:"remove",value:function(e,t){var n=this.getIndex(e,t);-1!==n&&this.refs[e].splice(n,1)}},{key:"isActive",value:function(){return this.active}},{key:"getActive",value:function(){var t=this;return this.refs[this.active.collection].find(function(e){return e.node.sortableInfo.index==t.active.index})}},{key:"getIndex",value:function(e,t){return this.refs[e].indexOf(t)}},{key:"getOrderedRefs",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.active.collection;return this.refs[e].sort(S)}}]),e}();function S(e,t){return e.node.sortableInfo.index-t.node.sortableInfo.index}var O=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}};var T=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)};var C=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")};var E=function(e){return O(e)||T(e)||C()};function k(n,o){return Object.keys(n).reduce(function(e,t){return-1===o.indexOf(t)&&(e[t]=n[t]),e},{})}var R={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},D=function(){if("undefined"==typeof window||"undefined"==typeof document)return"";var e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1];switch(t){case"ms":return"ms";default:return t&&t.length?t[0].toUpperCase()+t.substr(1):""}}();function N(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function A(e,t){e.style["".concat(D,"Transform")]=null==t?"":"translate3d(".concat(t.x,"px,").concat(t.y,"px,0)")}function M(e,t){e.style["".concat(D,"TransitionDuration")]=null==t?"":"".concat(t,"ms")}function W(e,t){for(;e;){if(t(e))return e;e=e.parentNode}return null}function j(e,t,n){return Math.max(e,Math.min(n,t))}function L(e){return"px"===e.substr(-2)?parseFloat(e):0}function P(e,t){var n=t.displayName||t.name;return n?"".concat(e,"(").concat(n,")"):e}function H(e,t){var n=e.getBoundingClientRect();return{top:n.top+t.top,left:n.left+t.left}}function K(e){return e.touches&&e.touches.length?{x:e.touches[0].pageX,y:e.touches[0].pageY}:e.changedTouches&&e.changedTouches.length?{x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY}:{x:e.pageX,y:e.pageY}}function _(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{left:0,top:0};if(e){var o={left:n.left+e.offsetLeft,top:n.top+e.offsetTop};return e.parentNode===t?o:_(e.parentNode,t,o)}}function B(e){var t=e.lockOffset,n=e.width,o=e.height,r=t,i=t,a="px";if("string"==typeof t){var s=/^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(t);w(null!==s,'lockOffset value should be a number or a string of a number followed by "px" or "%". Given %s',t),r=parseFloat(t),i=parseFloat(t),a=s[1]}return w(isFinite(r)&&isFinite(i),"lockOffset value should be a finite. Given %s",t),"%"===a&&(r=r*n/100,i=i*o/100),{x:r,y:i}}function G(e){return e instanceof HTMLElement?(t=e,n=window.getComputedStyle(t),o=/(auto|scroll)/,["overflow","overflowX","overflowY"].find(function(e){return o.test(n[e])})?e:G(e.parentNode)):null;var t,n,o}var X=27,U=32,Y=37,q=38,F=39,V=40,z={Anchor:"A",Button:"BUTTON",Canvas:"CANVAS",Input:"INPUT",Option:"OPTION",Textarea:"TEXTAREA",Select:"SELECT"};function $(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return u(this,t),y(this,g(t).apply(this,arguments))}return m(t,e),f(t,[{key:"componentDidMount",value:function(){a.findDOMNode(this).sortableHandle=!0}},{key:"getWrappedInstance",value:function(){return w(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableHandle() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var e=o.withRef?"wrappedInstance":null;return r.createElement(n,s({ref:e},this.props))}}]),t}(r.Component),c(e,"displayName",P("sortableHandle",n)),t}function J(e){return null!=e.sortableHandle}var Q=function(){function n(e,t){u(this,n),this.container=e,this.onScrollCallback=t}return f(n,[{key:"clear",value:function(){clearInterval(this.interval),this.interval=null}},{key:"update",value:function(e){var t=this,n=e.translate,o=e.minTranslate,r=e.maxTranslate,i=e.width,a=e.height,s={x:0,y:0},l={x:1,y:1},c=10,u=10,d=this.container,f=d.scrollTop,h=d.scrollLeft,p=d.scrollHeight,y=d.scrollWidth,g=0===f,v=p-f-d.clientHeight==0,m=0===h,x=y-h-d.clientWidth==0;n.y>=r.y-a/2&&!v?(s.y=1,l.y=u*Math.abs((r.y-a/2-n.y)/a)):n.x>=r.x-i/2&&!x?(s.x=1,l.x=c*Math.abs((r.x-i/2-n.x)/i)):n.y<=o.y+a/2&&!g?(s.y=-1,l.y=u*Math.abs((n.y-a/2-o.y)/a)):n.x<=o.x+i/2&&!m&&(s.x=-1,l.x=c*Math.abs((n.x-i/2-o.x)/i)),this.interval&&(this.clear(),this.isAutoScrolling=!1),0===s.x&&0===s.y||(this.interval=setInterval(function(){t.isAutoScrolling=!0;var e={left:l.x*s.x,top:l.y*s.y};t.container.scrollTop+=e.top,t.container.scrollLeft+=e.left,t.onScrollCallback(e)},5))}}]),n}();var Z={axis:i.oneOf(["x","y","xy"]),contentWindow:i.any,disableAutoscroll:i.bool,distance:i.number,getContainer:i.func,getHelperDimensions:i.func,helperClass:i.string,helperContainer:i.oneOfType([i.func,"undefined"==typeof HTMLElement?i.any:i.instanceOf(HTMLElement)]),hideSortableGhost:i.bool,keyboardSortingTransitionDuration:i.number,lockAxis:i.string,lockOffset:i.oneOfType([i.number,i.string,i.arrayOf(i.oneOfType([i.number,i.string]))]),lockToContainerEdges:i.bool,onSortEnd:i.func,onSortMove:i.func,onSortOver:i.func,onSortStart:i.func,pressDelay:i.number,pressThreshold:i.number,keyCodes:i.objectOf({lift:i.arrayOf(i.number),drop:i.arrayOf(i.number),cancel:i.arrayOf(i.number),up:i.arrayOf(i.number),down:i.arrayOf(i.number)}),shouldCancelStart:i.func,transitionDuration:i.number,updateBeforeSortStart:i.func,useDragHandle:i.bool,useWindowAsScrollContainer:i.bool},ee={lift:[U],drop:[U],cancel:[X],up:[q,Y],down:[V,F]},te={axis:"y",disableAutoscroll:!1,distance:0,getHelperDimensions:function(e){var t=e.node;return{height:t.offsetHeight,width:t.offsetWidth}},hideSortableGhost:!0,lockOffset:"50%",lockToContainerEdges:!1,pressDelay:0,pressThreshold:5,keyCodes:ee,shouldCancelStart:function(e){return-1!==[z.Input,z.Textarea,z.Select,z.Option,z.Button].indexOf(e.target.tagName)||!!W(e.target,function(e){return"true"===e.contentEditable})},transitionDuration:300,useWindowAsScrollContainer:!1},ne=Object.keys(Z);function oe(t){var e,n,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return n=e=function(e){function n(e){var k,t;return u(this,n),k=y(this,g(n).call(this,e)),c(p(p(k)),"state",{}),c(p(p(k)),"handleStart",function(e){var t=k.props,n=t.distance,o=t.shouldCancelStart;if(2!==e.button&&!o(e)){k.touched=!0,k.position=K(e);var r,i=W(e.target,function(e){return null!=e.sortableInfo});if(i&&i.sortableInfo&&k.nodeIsChild(i)&&!k.state.sorting){var a=k.props.useDragHandle,s=i.sortableInfo,l=s.index,c=s.collection;if(s.disabled)return;if(a&&!W(e.target,J))return;k.manager.active={collection:c,index:l},(r=e).touches&&r.touches.length||r.changedTouches&&r.changedTouches.length||e.target.tagName!==z.Anchor||e.preventDefault(),n||(0===k.props.pressDelay?k.handlePress(e):k.pressTimer=setTimeout(function(){return k.handlePress(e)},k.props.pressDelay))}}}),c(p(p(k)),"nodeIsChild",function(e){return e.sortableInfo.manager===k.manager}),c(p(p(k)),"handleMove",function(e){var t=k.props,n=t.distance,o=t.pressThreshold;if(!k.state.sorting&&k.touched&&!k._awaitingUpdateBeforeSortStart){var r=K(e),i={x:k.position.x-r.x,y:k.position.y-r.y},a=Math.abs(i.x)+Math.abs(i.y);k.delta=i,n||o&&!(o<=a)?n&&n<=a&&k.manager.isActive()&&k.handlePress(e):(clearTimeout(k.cancelTimer),k.cancelTimer=setTimeout(k.cancel,0))}}),c(p(p(k)),"handleEnd",function(){k.touched=!1,k.cancel()}),c(p(p(k)),"cancel",function(){var e=k.props.distance;k.state.sorting||(e||clearTimeout(k.pressTimer),k.manager.active=null)}),c(p(p(k)),"handlePress",function(C){try{var r=k.manager.getActive(),e=function(){if(r){var e=function(){var e,t,n,o,r,i,a=S.sortableInfo.index,s=(e=S,{bottom:L((t=window.getComputedStyle(e)).marginBottom),left:L(t.marginLeft),right:L(t.marginRight),top:L(t.marginTop)}),l=k.scrollContainer.getBoundingClientRect(),c=v({collection:O,index:a,node:S});if(k.node=S,k.margin=s,k.width=c.width,k.height=c.height,k.marginOffset={x:k.margin.left+k.margin.right,y:Math.max(k.margin.top,k.margin.bottom)},k.boundingClientRect=S.getBoundingClientRect(),k.containerBoundingRect=l,k.index=a,k.newIndex=a,k.axis={x:0<=g.indexOf("x"),y:0<=g.indexOf("y")},k.offsetEdge=_(S,k.container),k.initialOffset=K(T?I({},C,{pageX:k.boundingClientRect.left,pageY:k.boundingClientRect.top}):C),k.initialScroll={left:k.scrollContainer.scrollLeft,top:k.scrollContainer.scrollTop},k.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset},k.helper=k.helperContainer.appendChild((o="input, textarea, select, canvas, [contenteditable]",r=(n=S).querySelectorAll(o),i=n.cloneNode(!0),E(i.querySelectorAll(o)).forEach(function(e,t){"file"!==e.type&&(e.value=r[t].value),"radio"===e.type&&e.name&&(e.name="__sortableClone__".concat(e.name)),e.tagName===z.Canvas&&0<r[t].width&&0<r[t].height&&e.getContext("2d").drawImage(r[t],0,0)}),i)),N(k.helper,{boxSizing:"border-box",height:"".concat(k.height,"px"),left:"".concat(k.boundingClientRect.left-s.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(k.boundingClientRect.top-s.top,"px"),width:"".concat(k.width,"px")}),T&&k.helper.focus(),x&&N(k.sortableGhost=S,{opacity:0,visibility:"hidden"}),k.minTranslate={},k.maxTranslate={},T){var u=w?{top:0,left:0,width:k.contentWindow.innerWidth,height:k.contentWindow.innerHeight}:k.containerBoundingRect,d=u.top,f=u.left,h=u.width,p=d+u.height,y=f+h;k.axis.x&&(k.minTranslate.x=f-k.boundingClientRect.left,k.maxTranslate.x=y-(k.boundingClientRect.left+k.width)),k.axis.y&&(k.minTranslate.y=d-k.boundingClientRect.top,k.maxTranslate.y=p-(k.boundingClientRect.top+k.height))}else k.axis.x&&(k.minTranslate.x=(w?0:l.left)-k.boundingClientRect.left-k.width/2,k.maxTranslate.x=(w?k.contentWindow.innerWidth:l.left+l.width)-k.boundingClientRect.left-k.width/2),k.axis.y&&(k.minTranslate.y=(w?0:l.top)-k.boundingClientRect.top-k.height/2,k.maxTranslate.y=(w?k.contentWindow.innerHeight:l.top+l.height)-k.boundingClientRect.top-k.height/2);m&&m.split(" ").forEach(function(e){return k.helper.classList.add(e)}),k.listenerNode=C.touches?S:k.contentWindow,T?(k.listenerNode.addEventListener("wheel",k.handleKeyEnd,!0),k.listenerNode.addEventListener("mousedown",k.handleKeyEnd,!0),k.listenerNode.addEventListener("keydown",k.handleKeyDown)):(R.move.forEach(function(e){return k.listenerNode.addEventListener(e,k.handleSortMove,!1)}),R.end.forEach(function(e){return k.listenerNode.addEventListener(e,k.handleSortEnd,!1)})),k.setState({sorting:!0,sortingIndex:a}),b&&b({node:S,index:a,collection:O,isKeySorting:T},C),T&&k.keyMove(0)},t=k.props,g=t.axis,v=t.getHelperDimensions,m=t.helperClass,x=t.hideSortableGhost,n=t.updateBeforeSortStart,b=t.onSortStart,w=t.useWindowAsScrollContainer,S=r.node,O=r.collection,T=k.manager.isKeySorting,o=function(){if("function"==typeof n){k._awaitingUpdateBeforeSortStart=!0;var e=function(e,t){try{var n=e()}catch(e){return t(!0,e)}return n&&n.then?n.then(t.bind(null,!1),t.bind(null,!0)):t(!1,value)}(function(){var e=S.sortableInfo.index;return Promise.resolve(n({collection:O,index:e,node:S,isKeySorting:T},C)).then(function(){})},function(e,t){if(k._awaitingUpdateBeforeSortStart=!1,e)throw t;return t});if(e&&e.then)return e.then(function(){})}}();return o&&o.then?o.then(e):e()}}();return Promise.resolve(e&&e.then?e.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),c(p(p(k)),"handleSortMove",function(e){var t=k.props.onSortMove;"function"==typeof e.preventDefault&&e.preventDefault(),k.updateHelperPosition(e),k.animateNodes(),k.autoscroll(),t&&t(e)}),c(p(p(k)),"handleSortEnd",function(e){var t=k.props,n=t.hideSortableGhost,o=t.onSortEnd,r=k.manager,i=r.active.collection,a=r.isKeySorting,s=k.manager.refs[i];k.listenerNode&&(a?(k.listenerNode.removeEventListener("wheel",k.handleKeyEnd,!0),k.listenerNode.removeEventListener("mousedown",k.handleKeyEnd,!0),k.listenerNode.removeEventListener("keydown",k.handleKeyDown)):(R.move.forEach(function(e){return k.listenerNode.removeEventListener(e,k.handleSortMove)}),R.end.forEach(function(e){return k.listenerNode.removeEventListener(e,k.handleSortEnd)}))),k.helper.parentNode.removeChild(k.helper),n&&k.sortableGhost&&N(k.sortableGhost,{opacity:"",visibility:""});for(var l=0,c=s.length;l<c;l++){var u=s[l],d=u.node;u.edgeOffset=null,A(d,u.boundingClientRect=null),M(d,null),u.translate=null}k.autoScroller.clear(),k.manager.active=null,k.manager.isKeySorting=!1,k.setState({sorting:!1,sortingIndex:null}),"function"==typeof o&&o({collection:i,newIndex:k.newIndex,oldIndex:k.index,isKeySorting:a},e),k.touched=!1}),c(p(p(k)),"autoscroll",function(){var e=k.props.disableAutoscroll,t=k.manager.isKeySorting;if(!e){if(t){var n=I({},k.translate),o=0,r=0;return k.axis.x&&(n.x=Math.min(k.maxTranslate.x,Math.max(k.minTranslate.x,k.translate.x)),o=k.translate.x-n.x),k.axis.y&&(n.y=Math.min(k.maxTranslate.y,Math.max(k.minTranslate.y,k.translate.y)),r=k.translate.y-n.y),k.translate=n,A(k.helper,k.translate),k.scrollContainer.scrollLeft+=o,void(k.scrollContainer.scrollTop+=r)}k.autoScroller.update({height:k.height,maxTranslate:k.maxTranslate,minTranslate:k.minTranslate,translate:k.translate,width:k.width})}}),c(p(p(k)),"onAutoScroll",function(e){k.translate.x+=e.left,k.translate.y+=e.top,k.animateNodes()}),c(p(p(k)),"handleKeyDown",function(e){var t=e.keyCode,n=k.props,o=n.shouldCancelStart,r=n.keyCodes,i=I({},ee,void 0===r?{}:r);k.manager.active&&!k.manager.isKeySorting||!(k.manager.active||i.lift.includes(t)&&!o(e)&&k.isValidSortingTarget(e))||(e.stopPropagation(),e.preventDefault(),i.lift.includes(t)&&!k.manager.active?k.keyLift(e):i.drop.includes(t)&&k.manager.active?k.keyDrop(e):i.cancel.includes(t)?(k.newIndex=k.manager.active.index,k.keyDrop(e)):i.up.includes(t)?k.keyMove(-1):i.down.includes(t)&&k.keyMove(1))}),c(p(p(k)),"keyLift",function(e){var t=e.target,n=W(t,function(e){return null!=e.sortableInfo}).sortableInfo,o=n.index,r=n.collection;k.initialFocusedNode=t,k.manager.isKeySorting=!0,k.manager.active={index:o,collection:r},k.handlePress(e)}),c(p(p(k)),"keyMove",function(e){var t=k.manager.getOrderedRefs(),n=t[t.length-1].node.sortableInfo.index,o=k.newIndex+e,r=k.newIndex;if(!(o<0||n<o)){k.prevIndex=r,k.newIndex=o;var i,a,s,l=(i=k.newIndex,a=k.prevIndex,s=k.index,i<s&&a<i?i-1:s<i&&i<a?i+1:i),c=t.find(function(e){return e.node.sortableInfo.index===l}),u=c.node,d=k.containerScrollDelta,f=c.boundingClientRect||H(u,d),h=c.translate||{x:0,y:0},p=f.top+h.y-d.top,y=f.left+h.x-d.left,g=r<o,v=g&&k.axis.x?u.offsetWidth-k.width:0,m=g&&k.axis.y?u.offsetHeight-k.height:0;k.handleSortMove({pageX:y+v,pageY:p+m,ignoreTransition:0===e})}}),c(p(p(k)),"keyDrop",function(e){k.handleSortEnd(e),k.initialFocusedNode&&k.initialFocusedNode.focus()}),c(p(p(k)),"handleKeyEnd",function(e){k.manager.active&&k.keyDrop(e)}),c(p(p(k)),"isValidSortingTarget",function(e){var t=k.props.useDragHandle,n=e.target,o=W(n,function(e){return null!=e.sortableInfo});return o&&o.sortableInfo&&!o.sortableInfo.disabled&&(t?J(n):n.sortableInfo)}),w(!((t=e).distance&&t.pressDelay),"Attempted to set both `pressDelay` and `distance` on SortableContainer, you may only use one or the other, not both at the same time."),k.manager=new x,k.events={end:k.handleEnd,move:k.handleMove,start:k.handleStart},k}return m(n,e),f(n,[{key:"getChildContext",value:function(){return{manager:this.manager}}},{key:"componentDidMount",value:function(){var n=this,o=this.props.useWindowAsScrollContainer,e=this.getContainer();Promise.resolve(e).then(function(e){n.container=e,n.document=n.container.ownerDocument||document;var t=n.props.contentWindow||n.document.defaultView||window;n.contentWindow="function"==typeof t?t():t,n.scrollContainer=o?n.document.scrollingElement||n.document.documentElement:G(n.container)||n.container,n.autoScroller=new Q(n.scrollContainer,n.onAutoScroll),Object.keys(n.events).forEach(function(t){return R[t].forEach(function(e){return n.container.addEventListener(e,n.events[t],!1)})}),n.container.addEventListener("keydown",n.handleKeyDown)})}},{key:"componentWillUnmount",value:function(){var n=this;this.helper&&this.helper.parentNode&&this.helper.parentNode.removeChild(this.helper),this.container&&(Object.keys(this.events).forEach(function(t){return R[t].forEach(function(e){return n.container.removeEventListener(e,n.events[t])})}),this.container.removeEventListener("keydown",this.handleKeyDown))}},{key:"updateHelperPosition",value:function(e){var t=this.props,n=t.lockAxis,o=t.lockOffset,r=t.lockToContainerEdges,i=t.transitionDuration,a=t.keyboardSortingTransitionDuration,s=void 0===a?i:a,l=this.manager.isKeySorting,c=e.ignoreTransition,u=K(e),d={x:u.x-this.initialOffset.x,y:u.y-this.initialOffset.y};if(d.y-=window.pageYOffset-this.initialWindowScroll.top,d.x-=window.pageXOffset-this.initialWindowScroll.left,this.translate=d,r){var f=function(e){var t=e.height,n=e.width,o=e.lockOffset,r=Array.isArray(o)?o:[o,o];w(2===r.length,"lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given %s",o);var i=b(r,2),a=i[0],s=i[1];return[B({height:t,lockOffset:a,width:n}),B({height:t,lockOffset:s,width:n})]}({height:this.height,lockOffset:o,width:this.width}),h=b(f,2),p=h[0],y=h[1],g=this.width/2-p.x,v=this.height/2-p.y,m=this.width/2-y.x,x=this.height/2-y.y;d.x=j(this.minTranslate.x+g,this.maxTranslate.x-m,d.x),d.y=j(this.minTranslate.y+v,this.maxTranslate.y-x,d.y)}"x"===n?d.y=0:"y"===n&&(d.x=0),l&&s&&!c&&M(this.helper,s),A(this.helper,d)}},{key:"animateNodes",value:function(){var e=this.props,t=e.transitionDuration,n=e.hideSortableGhost,o=e.onSortOver,r=this.containerScrollDelta,i=this.windowScrollDelta,a=this.manager.getOrderedRefs(),s=this.offsetEdge.left+this.translate.x+r.left,l=this.offsetEdge.top+this.translate.y+r.top,c=this.manager.isKeySorting,u=this.newIndex;this.newIndex=null;for(var d=0,f=a.length;d<f;d++){var h=a[d].node,p=h.sortableInfo.index,y=h.offsetWidth,g=h.offsetHeight,v=this.height>g?g/2:this.height/2,m=this.width>y?y/2:this.width/2,x=c&&p>this.index&&p<=u,b=c&&p<this.index&&u<=p,w={x:0,y:0},S=a[d].edgeOffset;S||(S=_(h,this.container),a[d].edgeOffset=S,c&&(a[d].boundingClientRect=H(h,r)));var O=d<a.length-1&&a[d+1],T=0<d&&a[d-1];O&&!O.edgeOffset&&(O.edgeOffset=_(O.node,this.container),c&&(O.boundingClientRect=H(O.node,r))),p!==this.index?(t&&M(h,t),this.axis.x?this.axis.y?b||p<this.index&&(s+i.left-m<=S.left&&l+i.top<=S.top+v||l+i.top+v<=S.top)?(w.x=this.width+this.marginOffset.x,S.left+w.x>this.containerBoundingRect.width-m&&O&&(w.x=O.edgeOffset.left-S.left,w.y=O.edgeOffset.top-S.top),null===this.newIndex&&(this.newIndex=p)):(x||p>this.index&&(s+i.left+m>=S.left&&l+i.top+v>=S.top||l+i.top+v>=S.top+g))&&(w.x=-(this.width+this.marginOffset.x),S.left+w.x<this.containerBoundingRect.left+m&&T&&(w.x=T.edgeOffset.left-S.left,w.y=T.edgeOffset.top-S.top),this.newIndex=p):x||p>this.index&&s+i.left+m>=S.left?(w.x=-(this.width+this.marginOffset.x),this.newIndex=p):(b||p<this.index&&s+i.left<=S.left+m)&&(w.x=this.width+this.marginOffset.x,null==this.newIndex&&(this.newIndex=p)):this.axis.y&&(x||p>this.index&&l+i.top+v>=S.top?(w.y=-(this.height+this.marginOffset.y),this.newIndex=p):(b||p<this.index&&l+i.top<=S.top+v)&&(w.y=this.height+this.marginOffset.y,null==this.newIndex&&(this.newIndex=p))),A(h,w),a[d].translate=w):n&&N(this.sortableGhost=h,{opacity:0,visibility:"hidden"})}null==this.newIndex&&(this.newIndex=this.index),c&&(this.newIndex=u);var C=c?this.prevIndex:u;o&&this.newIndex!==C&&o({collection:this.manager.active.collection,index:this.index,newIndex:this.newIndex,oldIndex:C,isKeySorting:c})}},{key:"getWrappedInstance",value:function(){return w(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableContainer() call"),this.refs.wrappedInstance}},{key:"getContainer",value:function(){var e=this.props.getContainer;return"function"!=typeof e?a.findDOMNode(this):e(o.withRef?this.getWrappedInstance():void 0)}},{key:"render",value:function(){var e=o.withRef?"wrappedInstance":null;return r.createElement(t,s({ref:e},k(this.props,ne)))}},{key:"helperContainer",get:function(){var e=this.props.helperContainer;return"function"==typeof e?e():this.props.helperContainer||this.document.body}},{key:"containerScrollDelta",get:function(){return this.props.useWindowAsScrollContainer?{left:0,top:0}:{left:this.scrollContainer.scrollLeft-this.initialScroll.left,top:this.scrollContainer.scrollTop-this.initialScroll.top}}},{key:"windowScrollDelta",get:function(){return{left:this.contentWindow.pageXOffset-this.initialWindowScroll.left,top:this.contentWindow.pageYOffset-this.initialWindowScroll.top}}}]),n}(r.Component),c(e,"displayName",P("sortableList",t)),c(e,"defaultProps",te),c(e,"propTypes",Z),c(e,"childContextTypes",{manager:i.object.isRequired}),n}var re={index:i.number.isRequired,collection:i.oneOfType([i.number,i.string]),disabled:i.bool},ie=Object.keys(re);function ae(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return u(this,t),y(this,g(t).apply(this,arguments))}return m(t,e),f(t,[{key:"componentDidMount",value:function(){this.register()}},{key:"componentDidUpdate",value:function(e){this.node&&(e.index!==this.props.index&&(this.node.sortableInfo.index=this.props.index),e.disabled!==this.props.disabled&&(this.node.sortableInfo.disabled=this.props.disabled)),e.collection!==this.props.collection&&(this.unregister(e.collection),this.register())}},{key:"componentWillUnmount",value:function(){this.unregister()}},{key:"register",value:function(){var e=this.props,t=e.collection,n=e.disabled,o=e.index,r=a.findDOMNode(this);r.sortableInfo={collection:t,disabled:n,index:o,manager:this.context.manager},this.node=r,this.ref={node:r},this.context.manager.add(t,this.ref)}},{key:"unregister",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.props.collection;this.context.manager.remove(e,this.ref)}},{key:"getWrappedInstance",value:function(){return w(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableElement() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var e=o.withRef?"wrappedInstance":null;return r.createElement(n,s({ref:e},k(this.props,ie)))}}]),t}(r.Component),c(e,"displayName",P("sortableElement",n)),c(e,"contextTypes",{manager:i.object.isRequired}),c(e,"propTypes",re),c(e,"defaultProps",{collection:0}),t}e.SortableContainer=oe,e.sortableContainer=oe,e.SortableElement=ae,e.sortableElement=ae,e.SortableHandle=$,e.sortableHandle=$,e.arrayMove=function(e,t,n){return(e=e.slice()).splice(n<0?e.length+n:n,0,e.splice(t,1)[0]),e},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-dom"],t):t((e=e||self).SortableHOC={},e.React,e.PropTypes,e.ReactDOM)}(this,function(e,r,i,a){"use strict";function t(e,t){return e(t={exports:{}},t.exports),t.exports}i=i&&i.hasOwnProperty("default")?i.default:i;var s=t(function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},t.apply(this,arguments)}e.exports=t});var n=function(e){if(Array.isArray(e))return e};var o=function(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(o=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(r)throw i}}return n};var l=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var b=function(e,t){return n(e)||o(e,t)||l()};var c=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};var I=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(e){c(t,e,n[e])})}return t};var u=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function d(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var f=function(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),e},h=t(function(t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=o=function(e){return n(e)}:t.exports=o=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)},o(e)}t.exports=o});var p=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var y=function(e,t){return!t||"object"!==h(t)&&"function"!=typeof t?p(e):t},g=t(function(t){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}t.exports=n}),v=t(function(n){function o(e,t){return n.exports=o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}n.exports=o});var m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)},w=function(e,t,n,o,r,i,a,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,r,i,a,s],u=0;(l=new Error(t.replace(/%s/g,function(){return c[u++]}))).name="Invariant Violation"}throw l.framesToPop=1,l}},x=function(){function e(){u(this,e),c(this,"refs",{})}return f(e,[{key:"add",value:function(e,t){this.refs[e]||(this.refs[e]=[]),this.refs[e].push(t)}},{key:"remove",value:function(e,t){var n=this.getIndex(e,t);-1!==n&&this.refs[e].splice(n,1)}},{key:"isActive",value:function(){return this.active}},{key:"getActive",value:function(){var t=this;return this.refs[this.active.collection].find(function(e){return e.node.sortableInfo.index==t.active.index})}},{key:"getIndex",value:function(e,t){return this.refs[e].indexOf(t)}},{key:"getOrderedRefs",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.active.collection;return this.refs[e].sort(S)}}]),e}();function S(e,t){return e.node.sortableInfo.index-t.node.sortableInfo.index}var O=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}};var T=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)};var C=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")};var E=function(e){return O(e)||T(e)||C()};function k(n,o){return Object.keys(n).reduce(function(e,t){return-1===o.indexOf(t)&&(e[t]=n[t]),e},{})}var R={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},D=function(){if("undefined"==typeof window||"undefined"==typeof document)return"";var e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1];switch(t){case"ms":return"ms";default:return t&&t.length?t[0].toUpperCase()+t.substr(1):""}}();function N(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function A(e,t){e.style["".concat(D,"Transform")]=null==t?"":"translate3d(".concat(t.x,"px,").concat(t.y,"px,0)")}function M(e,t){e.style["".concat(D,"TransitionDuration")]=null==t?"":"".concat(t,"ms")}function W(e,t){for(;e;){if(t(e))return e;e=e.parentNode}return null}function L(e,t,n){return Math.max(e,Math.min(n,t))}function P(e){return"px"===e.substr(-2)?parseFloat(e):0}function j(e,t){var n=t.displayName||t.name;return n?"".concat(e,"(").concat(n,")"):e}function H(e,t){var n=e.getBoundingClientRect();return{top:n.top+t.top,left:n.left+t.left}}function K(e){return e.touches&&e.touches.length?{x:e.touches[0].pageX,y:e.touches[0].pageY}:e.changedTouches&&e.changedTouches.length?{x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY}:{x:e.pageX,y:e.pageY}}function _(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{left:0,top:0};if(e){var o={left:n.left+e.offsetLeft,top:n.top+e.offsetTop};return e.parentNode===t?o:_(e.parentNode,t,o)}}function B(e){var t=e.lockOffset,n=e.width,o=e.height,r=t,i=t,a="px";if("string"==typeof t){var s=/^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(t);w(null!==s,'lockOffset value should be a number or a string of a number followed by "px" or "%". Given %s',t),r=parseFloat(t),i=parseFloat(t),a=s[1]}return w(isFinite(r)&&isFinite(i),"lockOffset value should be a finite. Given %s",t),"%"===a&&(r=r*n/100,i=i*o/100),{x:r,y:i}}function G(e){return e instanceof HTMLElement?(t=e,n=window.getComputedStyle(t),o=/(auto|scroll)/,["overflow","overflowX","overflowY"].find(function(e){return o.test(n[e])})?e:G(e.parentNode)):null;var t,n,o}var X=27,U=32,Y=37,q=38,F=39,V=40,z={Anchor:"A",Button:"BUTTON",Canvas:"CANVAS",Input:"INPUT",Option:"OPTION",Textarea:"TEXTAREA",Select:"SELECT"};function $(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return u(this,t),y(this,g(t).apply(this,arguments))}return m(t,e),f(t,[{key:"componentDidMount",value:function(){a.findDOMNode(this).sortableHandle=!0}},{key:"getWrappedInstance",value:function(){return w(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableHandle() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var e=o.withRef?"wrappedInstance":null;return r.createElement(n,s({ref:e},this.props))}}]),t}(r.Component),c(e,"displayName",j("sortableHandle",n)),t}function J(e){return null!=e.sortableHandle}var Q=function(){function n(e,t){u(this,n),this.container=e,this.onScrollCallback=t}return f(n,[{key:"clear",value:function(){clearInterval(this.interval),this.interval=null}},{key:"update",value:function(e){var t=this,n=e.translate,o=e.minTranslate,r=e.maxTranslate,i=e.width,a=e.height,s={x:0,y:0},l={x:1,y:1},c=10,u=10,d=this.container,f=d.scrollTop,h=d.scrollLeft,p=d.scrollHeight,y=d.scrollWidth,g=0===f,v=p-f-d.clientHeight==0,m=0===h,x=y-h-d.clientWidth==0;n.y>=r.y-a/2&&!v?(s.y=1,l.y=u*Math.abs((r.y-a/2-n.y)/a)):n.x>=r.x-i/2&&!x?(s.x=1,l.x=c*Math.abs((r.x-i/2-n.x)/i)):n.y<=o.y+a/2&&!g?(s.y=-1,l.y=u*Math.abs((n.y-a/2-o.y)/a)):n.x<=o.x+i/2&&!m&&(s.x=-1,l.x=c*Math.abs((n.x-i/2-o.x)/i)),this.interval&&(this.clear(),this.isAutoScrolling=!1),0===s.x&&0===s.y||(this.interval=setInterval(function(){t.isAutoScrolling=!0;var e={left:l.x*s.x,top:l.y*s.y};t.container.scrollTop+=e.top,t.container.scrollLeft+=e.left,t.onScrollCallback(e)},5))}}]),n}();var Z={axis:i.oneOf(["x","y","xy"]),contentWindow:i.any,disableAutoscroll:i.bool,distance:i.number,getContainer:i.func,getHelperDimensions:i.func,helperClass:i.string,helperContainer:i.oneOfType([i.func,"undefined"==typeof HTMLElement?i.any:i.instanceOf(HTMLElement)]),hideSortableGhost:i.bool,keyboardSortingTransitionDuration:i.number,lockAxis:i.string,lockOffset:i.oneOfType([i.number,i.string,i.arrayOf(i.oneOfType([i.number,i.string]))]),lockToContainerEdges:i.bool,onSortEnd:i.func,onSortMove:i.func,onSortOver:i.func,onSortStart:i.func,pressDelay:i.number,pressThreshold:i.number,keyCodes:i.shape({lift:i.arrayOf(i.number),drop:i.arrayOf(i.number),cancel:i.arrayOf(i.number),up:i.arrayOf(i.number),down:i.arrayOf(i.number)}),shouldCancelStart:i.func,transitionDuration:i.number,updateBeforeSortStart:i.func,useDragHandle:i.bool,useWindowAsScrollContainer:i.bool},ee={lift:[U],drop:[U],cancel:[X],up:[q,Y],down:[V,F]},te={axis:"y",disableAutoscroll:!1,distance:0,getHelperDimensions:function(e){var t=e.node;return{height:t.offsetHeight,width:t.offsetWidth}},hideSortableGhost:!0,lockOffset:"50%",lockToContainerEdges:!1,pressDelay:0,pressThreshold:5,keyCodes:ee,shouldCancelStart:function(e){return-1!==[z.Input,z.Textarea,z.Select,z.Option,z.Button].indexOf(e.target.tagName)||!!W(e.target,function(e){return"true"===e.contentEditable})},transitionDuration:300,useWindowAsScrollContainer:!1},ne=Object.keys(Z);function oe(t){var e,n,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return n=e=function(e){function n(e){var k,t;return u(this,n),k=y(this,g(n).call(this,e)),c(p(p(k)),"state",{}),c(p(p(k)),"handleStart",function(e){var t=k.props,n=t.distance,o=t.shouldCancelStart;if(2!==e.button&&!o(e)){k.touched=!0,k.position=K(e);var r,i=W(e.target,function(e){return null!=e.sortableInfo});if(i&&i.sortableInfo&&k.nodeIsChild(i)&&!k.state.sorting){var a=k.props.useDragHandle,s=i.sortableInfo,l=s.index,c=s.collection;if(s.disabled)return;if(a&&!W(e.target,J))return;k.manager.active={collection:c,index:l},(r=e).touches&&r.touches.length||r.changedTouches&&r.changedTouches.length||e.target.tagName!==z.Anchor||e.preventDefault(),n||(0===k.props.pressDelay?k.handlePress(e):k.pressTimer=setTimeout(function(){return k.handlePress(e)},k.props.pressDelay))}}}),c(p(p(k)),"nodeIsChild",function(e){return e.sortableInfo.manager===k.manager}),c(p(p(k)),"handleMove",function(e){var t=k.props,n=t.distance,o=t.pressThreshold;if(!k.state.sorting&&k.touched&&!k._awaitingUpdateBeforeSortStart){var r=K(e),i={x:k.position.x-r.x,y:k.position.y-r.y},a=Math.abs(i.x)+Math.abs(i.y);k.delta=i,n||o&&!(o<=a)?n&&n<=a&&k.manager.isActive()&&k.handlePress(e):(clearTimeout(k.cancelTimer),k.cancelTimer=setTimeout(k.cancel,0))}}),c(p(p(k)),"handleEnd",function(){k.touched=!1,k.cancel()}),c(p(p(k)),"cancel",function(){var e=k.props.distance;k.state.sorting||(e||clearTimeout(k.pressTimer),k.manager.active=null)}),c(p(p(k)),"handlePress",function(C){try{var r=k.manager.getActive(),e=function(){if(r){var e=function(){var e,t,n,o,r,i,a=S.sortableInfo.index,s=(e=S,{bottom:P((t=window.getComputedStyle(e)).marginBottom),left:P(t.marginLeft),right:P(t.marginRight),top:P(t.marginTop)}),l=k.scrollContainer.getBoundingClientRect(),c=v({collection:O,index:a,node:S});if(k.node=S,k.margin=s,k.width=c.width,k.height=c.height,k.marginOffset={x:k.margin.left+k.margin.right,y:Math.max(k.margin.top,k.margin.bottom)},k.boundingClientRect=S.getBoundingClientRect(),k.containerBoundingRect=l,k.index=a,k.newIndex=a,k.axis={x:0<=g.indexOf("x"),y:0<=g.indexOf("y")},k.offsetEdge=_(S,k.container),k.initialOffset=K(T?I({},C,{pageX:k.boundingClientRect.left,pageY:k.boundingClientRect.top}):C),k.initialScroll={left:k.scrollContainer.scrollLeft,top:k.scrollContainer.scrollTop},k.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset},k.helper=k.helperContainer.appendChild((o="input, textarea, select, canvas, [contenteditable]",r=(n=S).querySelectorAll(o),i=n.cloneNode(!0),E(i.querySelectorAll(o)).forEach(function(e,t){"file"!==e.type&&(e.value=r[t].value),"radio"===e.type&&e.name&&(e.name="__sortableClone__".concat(e.name)),e.tagName===z.Canvas&&0<r[t].width&&0<r[t].height&&e.getContext("2d").drawImage(r[t],0,0)}),i)),N(k.helper,{boxSizing:"border-box",height:"".concat(k.height,"px"),left:"".concat(k.boundingClientRect.left-s.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(k.boundingClientRect.top-s.top,"px"),width:"".concat(k.width,"px")}),T&&k.helper.focus(),x&&N(k.sortableGhost=S,{opacity:0,visibility:"hidden"}),k.minTranslate={},k.maxTranslate={},T){var u=w?{top:0,left:0,width:k.contentWindow.innerWidth,height:k.contentWindow.innerHeight}:k.containerBoundingRect,d=u.top,f=u.left,h=u.width,p=d+u.height,y=f+h;k.axis.x&&(k.minTranslate.x=f-k.boundingClientRect.left,k.maxTranslate.x=y-(k.boundingClientRect.left+k.width)),k.axis.y&&(k.minTranslate.y=d-k.boundingClientRect.top,k.maxTranslate.y=p-(k.boundingClientRect.top+k.height))}else k.axis.x&&(k.minTranslate.x=(w?0:l.left)-k.boundingClientRect.left-k.width/2,k.maxTranslate.x=(w?k.contentWindow.innerWidth:l.left+l.width)-k.boundingClientRect.left-k.width/2),k.axis.y&&(k.minTranslate.y=(w?0:l.top)-k.boundingClientRect.top-k.height/2,k.maxTranslate.y=(w?k.contentWindow.innerHeight:l.top+l.height)-k.boundingClientRect.top-k.height/2);m&&m.split(" ").forEach(function(e){return k.helper.classList.add(e)}),k.listenerNode=C.touches?S:k.contentWindow,T?(k.listenerNode.addEventListener("wheel",k.handleKeyEnd,!0),k.listenerNode.addEventListener("mousedown",k.handleKeyEnd,!0),k.listenerNode.addEventListener("keydown",k.handleKeyDown)):(R.move.forEach(function(e){return k.listenerNode.addEventListener(e,k.handleSortMove,!1)}),R.end.forEach(function(e){return k.listenerNode.addEventListener(e,k.handleSortEnd,!1)})),k.setState({sorting:!0,sortingIndex:a}),b&&b({node:S,index:a,collection:O,isKeySorting:T},C),T&&k.keyMove(0)},t=k.props,g=t.axis,v=t.getHelperDimensions,m=t.helperClass,x=t.hideSortableGhost,n=t.updateBeforeSortStart,b=t.onSortStart,w=t.useWindowAsScrollContainer,S=r.node,O=r.collection,T=k.manager.isKeySorting,o=function(){if("function"==typeof n){k._awaitingUpdateBeforeSortStart=!0;var e=function(e,t){try{var n=e()}catch(e){return t(!0,e)}return n&&n.then?n.then(t.bind(null,!1),t.bind(null,!0)):t(!1,value)}(function(){var e=S.sortableInfo.index;return Promise.resolve(n({collection:O,index:e,node:S,isKeySorting:T},C)).then(function(){})},function(e,t){if(k._awaitingUpdateBeforeSortStart=!1,e)throw t;return t});if(e&&e.then)return e.then(function(){})}}();return o&&o.then?o.then(e):e()}}();return Promise.resolve(e&&e.then?e.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),c(p(p(k)),"handleSortMove",function(e){var t=k.props.onSortMove;"function"==typeof e.preventDefault&&e.preventDefault(),k.updateHelperPosition(e),k.animateNodes(),k.autoscroll(),t&&t(e)}),c(p(p(k)),"handleSortEnd",function(e){var t=k.props,n=t.hideSortableGhost,o=t.onSortEnd,r=k.manager,i=r.active.collection,a=r.isKeySorting,s=k.manager.refs[i];k.listenerNode&&(a?(k.listenerNode.removeEventListener("wheel",k.handleKeyEnd,!0),k.listenerNode.removeEventListener("mousedown",k.handleKeyEnd,!0),k.listenerNode.removeEventListener("keydown",k.handleKeyDown)):(R.move.forEach(function(e){return k.listenerNode.removeEventListener(e,k.handleSortMove)}),R.end.forEach(function(e){return k.listenerNode.removeEventListener(e,k.handleSortEnd)}))),k.helper.parentNode.removeChild(k.helper),n&&k.sortableGhost&&N(k.sortableGhost,{opacity:"",visibility:""});for(var l=0,c=s.length;l<c;l++){var u=s[l],d=u.node;u.edgeOffset=null,A(d,u.boundingClientRect=null),M(d,null),u.translate=null}k.autoScroller.clear(),k.manager.active=null,k.manager.isKeySorting=!1,k.setState({sorting:!1,sortingIndex:null}),"function"==typeof o&&o({collection:i,newIndex:k.newIndex,oldIndex:k.index,isKeySorting:a},e),k.touched=!1}),c(p(p(k)),"autoscroll",function(){var e=k.props.disableAutoscroll,t=k.manager.isKeySorting;if(!e){if(t){var n=I({},k.translate),o=0,r=0;return k.axis.x&&(n.x=Math.min(k.maxTranslate.x,Math.max(k.minTranslate.x,k.translate.x)),o=k.translate.x-n.x),k.axis.y&&(n.y=Math.min(k.maxTranslate.y,Math.max(k.minTranslate.y,k.translate.y)),r=k.translate.y-n.y),k.translate=n,A(k.helper,k.translate),k.scrollContainer.scrollLeft+=o,void(k.scrollContainer.scrollTop+=r)}k.autoScroller.update({height:k.height,maxTranslate:k.maxTranslate,minTranslate:k.minTranslate,translate:k.translate,width:k.width})}}),c(p(p(k)),"onAutoScroll",function(e){k.translate.x+=e.left,k.translate.y+=e.top,k.animateNodes()}),c(p(p(k)),"handleKeyDown",function(e){var t=e.keyCode,n=k.props,o=n.shouldCancelStart,r=n.keyCodes,i=I({},ee,void 0===r?{}:r);k.manager.active&&!k.manager.isKeySorting||!(k.manager.active||i.lift.includes(t)&&!o(e)&&k.isValidSortingTarget(e))||(e.stopPropagation(),e.preventDefault(),i.lift.includes(t)&&!k.manager.active?k.keyLift(e):i.drop.includes(t)&&k.manager.active?k.keyDrop(e):i.cancel.includes(t)?(k.newIndex=k.manager.active.index,k.keyDrop(e)):i.up.includes(t)?k.keyMove(-1):i.down.includes(t)&&k.keyMove(1))}),c(p(p(k)),"keyLift",function(e){var t=e.target,n=W(t,function(e){return null!=e.sortableInfo}).sortableInfo,o=n.index,r=n.collection;k.initialFocusedNode=t,k.manager.isKeySorting=!0,k.manager.active={index:o,collection:r},k.handlePress(e)}),c(p(p(k)),"keyMove",function(e){var t=k.manager.getOrderedRefs(),n=t[t.length-1].node.sortableInfo.index,o=k.newIndex+e,r=k.newIndex;if(!(o<0||n<o)){k.prevIndex=r,k.newIndex=o;var i,a,s,l=(i=k.newIndex,a=k.prevIndex,s=k.index,i<s&&a<i?i-1:s<i&&i<a?i+1:i),c=t.find(function(e){return e.node.sortableInfo.index===l}),u=c.node,d=k.containerScrollDelta,f=c.boundingClientRect||H(u,d),h=c.translate||{x:0,y:0},p=f.top+h.y-d.top,y=f.left+h.x-d.left,g=r<o,v=g&&k.axis.x?u.offsetWidth-k.width:0,m=g&&k.axis.y?u.offsetHeight-k.height:0;k.handleSortMove({pageX:y+v,pageY:p+m,ignoreTransition:0===e})}}),c(p(p(k)),"keyDrop",function(e){k.handleSortEnd(e),k.initialFocusedNode&&k.initialFocusedNode.focus()}),c(p(p(k)),"handleKeyEnd",function(e){k.manager.active&&k.keyDrop(e)}),c(p(p(k)),"isValidSortingTarget",function(e){var t=k.props.useDragHandle,n=e.target,o=W(n,function(e){return null!=e.sortableInfo});return o&&o.sortableInfo&&!o.sortableInfo.disabled&&(t?J(n):n.sortableInfo)}),w(!((t=e).distance&&t.pressDelay),"Attempted to set both `pressDelay` and `distance` on SortableContainer, you may only use one or the other, not both at the same time."),k.manager=new x,k.events={end:k.handleEnd,move:k.handleMove,start:k.handleStart},k}return m(n,e),f(n,[{key:"getChildContext",value:function(){return{manager:this.manager}}},{key:"componentDidMount",value:function(){var n=this,o=this.props.useWindowAsScrollContainer,e=this.getContainer();Promise.resolve(e).then(function(e){n.container=e,n.document=n.container.ownerDocument||document;var t=n.props.contentWindow||n.document.defaultView||window;n.contentWindow="function"==typeof t?t():t,n.scrollContainer=o?n.document.scrollingElement||n.document.documentElement:G(n.container)||n.container,n.autoScroller=new Q(n.scrollContainer,n.onAutoScroll),Object.keys(n.events).forEach(function(t){return R[t].forEach(function(e){return n.container.addEventListener(e,n.events[t],!1)})}),n.container.addEventListener("keydown",n.handleKeyDown)})}},{key:"componentWillUnmount",value:function(){var n=this;this.helper&&this.helper.parentNode&&this.helper.parentNode.removeChild(this.helper),this.container&&(Object.keys(this.events).forEach(function(t){return R[t].forEach(function(e){return n.container.removeEventListener(e,n.events[t])})}),this.container.removeEventListener("keydown",this.handleKeyDown))}},{key:"updateHelperPosition",value:function(e){var t=this.props,n=t.lockAxis,o=t.lockOffset,r=t.lockToContainerEdges,i=t.transitionDuration,a=t.keyboardSortingTransitionDuration,s=void 0===a?i:a,l=this.manager.isKeySorting,c=e.ignoreTransition,u=K(e),d={x:u.x-this.initialOffset.x,y:u.y-this.initialOffset.y};if(d.y-=window.pageYOffset-this.initialWindowScroll.top,d.x-=window.pageXOffset-this.initialWindowScroll.left,this.translate=d,r){var f=function(e){var t=e.height,n=e.width,o=e.lockOffset,r=Array.isArray(o)?o:[o,o];w(2===r.length,"lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given %s",o);var i=b(r,2),a=i[0],s=i[1];return[B({height:t,lockOffset:a,width:n}),B({height:t,lockOffset:s,width:n})]}({height:this.height,lockOffset:o,width:this.width}),h=b(f,2),p=h[0],y=h[1],g=this.width/2-p.x,v=this.height/2-p.y,m=this.width/2-y.x,x=this.height/2-y.y;d.x=L(this.minTranslate.x+g,this.maxTranslate.x-m,d.x),d.y=L(this.minTranslate.y+v,this.maxTranslate.y-x,d.y)}"x"===n?d.y=0:"y"===n&&(d.x=0),l&&s&&!c&&M(this.helper,s),A(this.helper,d)}},{key:"animateNodes",value:function(){var e=this.props,t=e.transitionDuration,n=e.hideSortableGhost,o=e.onSortOver,r=this.containerScrollDelta,i=this.windowScrollDelta,a=this.manager.getOrderedRefs(),s=this.offsetEdge.left+this.translate.x+r.left,l=this.offsetEdge.top+this.translate.y+r.top,c=this.manager.isKeySorting,u=this.newIndex;this.newIndex=null;for(var d=0,f=a.length;d<f;d++){var h=a[d].node,p=h.sortableInfo.index,y=h.offsetWidth,g=h.offsetHeight,v=this.height>g?g/2:this.height/2,m=this.width>y?y/2:this.width/2,x=c&&p>this.index&&p<=u,b=c&&p<this.index&&u<=p,w={x:0,y:0},S=a[d].edgeOffset;S||(S=_(h,this.container),a[d].edgeOffset=S,c&&(a[d].boundingClientRect=H(h,r)));var O=d<a.length-1&&a[d+1],T=0<d&&a[d-1];O&&!O.edgeOffset&&(O.edgeOffset=_(O.node,this.container),c&&(O.boundingClientRect=H(O.node,r))),p!==this.index?(t&&M(h,t),this.axis.x?this.axis.y?b||p<this.index&&(s+i.left-m<=S.left&&l+i.top<=S.top+v||l+i.top+v<=S.top)?(w.x=this.width+this.marginOffset.x,S.left+w.x>this.containerBoundingRect.width-m&&O&&(w.x=O.edgeOffset.left-S.left,w.y=O.edgeOffset.top-S.top),null===this.newIndex&&(this.newIndex=p)):(x||p>this.index&&(s+i.left+m>=S.left&&l+i.top+v>=S.top||l+i.top+v>=S.top+g))&&(w.x=-(this.width+this.marginOffset.x),S.left+w.x<this.containerBoundingRect.left+m&&T&&(w.x=T.edgeOffset.left-S.left,w.y=T.edgeOffset.top-S.top),this.newIndex=p):x||p>this.index&&s+i.left+m>=S.left?(w.x=-(this.width+this.marginOffset.x),this.newIndex=p):(b||p<this.index&&s+i.left<=S.left+m)&&(w.x=this.width+this.marginOffset.x,null==this.newIndex&&(this.newIndex=p)):this.axis.y&&(x||p>this.index&&l+i.top+v>=S.top?(w.y=-(this.height+this.marginOffset.y),this.newIndex=p):(b||p<this.index&&l+i.top<=S.top+v)&&(w.y=this.height+this.marginOffset.y,null==this.newIndex&&(this.newIndex=p))),A(h,w),a[d].translate=w):n&&N(this.sortableGhost=h,{opacity:0,visibility:"hidden"})}null==this.newIndex&&(this.newIndex=this.index),c&&(this.newIndex=u);var C=c?this.prevIndex:u;o&&this.newIndex!==C&&o({collection:this.manager.active.collection,index:this.index,newIndex:this.newIndex,oldIndex:C,isKeySorting:c})}},{key:"getWrappedInstance",value:function(){return w(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableContainer() call"),this.refs.wrappedInstance}},{key:"getContainer",value:function(){var e=this.props.getContainer;return"function"!=typeof e?a.findDOMNode(this):e(o.withRef?this.getWrappedInstance():void 0)}},{key:"render",value:function(){var e=o.withRef?"wrappedInstance":null;return r.createElement(t,s({ref:e},k(this.props,ne)))}},{key:"helperContainer",get:function(){var e=this.props.helperContainer;return"function"==typeof e?e():this.props.helperContainer||this.document.body}},{key:"containerScrollDelta",get:function(){return this.props.useWindowAsScrollContainer?{left:0,top:0}:{left:this.scrollContainer.scrollLeft-this.initialScroll.left,top:this.scrollContainer.scrollTop-this.initialScroll.top}}},{key:"windowScrollDelta",get:function(){return{left:this.contentWindow.pageXOffset-this.initialWindowScroll.left,top:this.contentWindow.pageYOffset-this.initialWindowScroll.top}}}]),n}(r.Component),c(e,"displayName",j("sortableList",t)),c(e,"defaultProps",te),c(e,"propTypes",Z),c(e,"childContextTypes",{manager:i.object.isRequired}),n}var re={index:i.number.isRequired,collection:i.oneOfType([i.number,i.string]),disabled:i.bool},ie=Object.keys(re);function ae(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return u(this,t),y(this,g(t).apply(this,arguments))}return m(t,e),f(t,[{key:"componentDidMount",value:function(){this.register()}},{key:"componentDidUpdate",value:function(e){this.node&&(e.index!==this.props.index&&(this.node.sortableInfo.index=this.props.index),e.disabled!==this.props.disabled&&(this.node.sortableInfo.disabled=this.props.disabled)),e.collection!==this.props.collection&&(this.unregister(e.collection),this.register())}},{key:"componentWillUnmount",value:function(){this.unregister()}},{key:"register",value:function(){var e=this.props,t=e.collection,n=e.disabled,o=e.index,r=a.findDOMNode(this);r.sortableInfo={collection:t,disabled:n,index:o,manager:this.context.manager},this.node=r,this.ref={node:r},this.context.manager.add(t,this.ref)}},{key:"unregister",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.props.collection;this.context.manager.remove(e,this.ref)}},{key:"getWrappedInstance",value:function(){return w(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableElement() call"),this.refs.wrappedInstance}},{key:"render",value:function(){var e=o.withRef?"wrappedInstance":null;return r.createElement(n,s({ref:e},k(this.props,ie)))}}]),t}(r.Component),c(e,"displayName",j("sortableElement",n)),c(e,"contextTypes",{manager:i.object.isRequired}),c(e,"propTypes",re),c(e,"defaultProps",{collection:0}),t}e.SortableContainer=oe,e.sortableContainer=oe,e.SortableElement=ae,e.sortableElement=ae,e.SortableHandle=$,e.sortableHandle=$,e.arrayMove=function(e,t,n){return(e=e.slice()).splice(n<0?e.length+n:n,0,e.splice(t,1)[0]),e},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "react-sortable-hoc",
"version": "1.10.0",
"version": "1.10.1",
"description": "Set of higher-order components to turn any list into a sortable, touch-friendly, animated list",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc