react-sortable-hoc
Advanced tools
Comparing version 1.8.0 to 1.8.1
@@ -5,20 +5,40 @@ # Change Log | ||
<a name="1.8.1"></a> | ||
## [1.8.1](https://github.com/clauderic/react-sortable-hoc/compare/v1.8.0...v1.8.1) (2019-03-18) | ||
### Bug Fixes | ||
- issue with cloning canvas context of dragged items ([#512](https://github.com/clauderic/react-sortable-hoc/issues/512)) ([4df34ad](https://github.com/clauderic/react-sortable-hoc/commit/4df34ad)) | ||
<a name="1.8.0"></a> | ||
# [1.8.0](https://github.com/clauderic/react-sortable-hoc/compare/v1.7.1...v1.8.0) (2019-03-18) | ||
# [1.8.0](https://github.com/clauderic/react-sortable-hoc/compare/v1.1.0...v1.8.0) (2019-03-18) | ||
### Bug Fixes | ||
* copy canvas content into cloned node ([43ad122](https://github.com/clauderic/react-sortable-hoc/commit/43ad122)) | ||
* added prop-types to peerDependencies ([0e855c5](https://github.com/clauderic/react-sortable-hoc/commit/0e855c5)) | ||
* get updated index after updateBeforeSortStart ([4471a0a](https://github.com/clauderic/react-sortable-hoc/commit/4471a0a)) | ||
* replace process.env.NODE_ENV in UMD builds ([16135df](https://github.com/clauderic/react-sortable-hoc/commit/16135df)) | ||
- added prop-types to peerDependencies ([0e855c5](https://github.com/clauderic/react-sortable-hoc/commit/0e855c5)) | ||
- copy canvas content into cloned node ([43ad122](https://github.com/clauderic/react-sortable-hoc/commit/43ad122)) | ||
- get updated index after updateBeforeSortStart ([4471a0a](https://github.com/clauderic/react-sortable-hoc/commit/4471a0a)) | ||
- helperContainer PropType definition broke server-side rendering ([#471](https://github.com/clauderic/react-sortable-hoc/issues/471)) ([c0eef97](https://github.com/clauderic/react-sortable-hoc/commit/c0eef97)) | ||
- invalid helperContainer PropType definition ([#493](https://github.com/clauderic/react-sortable-hoc/issues/493)) ([dc1d18f](https://github.com/clauderic/react-sortable-hoc/commit/dc1d18f)) | ||
- lock axis story should not use lockToContainerEdges ([db1d3a9](https://github.com/clauderic/react-sortable-hoc/commit/db1d3a9)) | ||
- omit disableAutoscroll prop ([#502](https://github.com/clauderic/react-sortable-hoc/issues/502)) ([e994e73](https://github.com/clauderic/react-sortable-hoc/commit/e994e73)) | ||
- omit spreading helperContainer prop ([#497](https://github.com/clauderic/react-sortable-hoc/issues/497)) ([12bafdf](https://github.com/clauderic/react-sortable-hoc/commit/12bafdf)) | ||
- overflow bug while dragging an item upwards in a grid ([1a2c87e](https://github.com/clauderic/react-sortable-hoc/commit/1a2c87e)) | ||
- replace process.env.NODE_ENV in UMD builds ([16135df](https://github.com/clauderic/react-sortable-hoc/commit/16135df)) | ||
- update helperContainer prop type definition ([#491](https://github.com/clauderic/react-sortable-hoc/issues/491)) ([fd30383](https://github.com/clauderic/react-sortable-hoc/commit/fd30383)) | ||
- updated the behaviour of disabled elements ([bd3d041](https://github.com/clauderic/react-sortable-hoc/commit/bd3d041)) | ||
- virtualized collection grid bug ([a57975c](https://github.com/clauderic/react-sortable-hoc/commit/a57975c)) | ||
### Features | ||
* Detect scroll container automatically ([#507](https://github.com/clauderic/react-sortable-hoc/issues/507)) ([6572921](https://github.com/clauderic/react-sortable-hoc/commit/6572921)) | ||
- Add disableAutoscroll prop ([#484](https://github.com/clauderic/react-sortable-hoc/issues/484)) ([7845e76](https://github.com/clauderic/react-sortable-hoc/commit/7845e76)) | ||
- added helperContainer prop ([286eff4](https://github.com/clauderic/react-sortable-hoc/commit/286eff4)) | ||
- allow helperContainer prop to be a function returning an HTMLElement ([#489](https://github.com/clauderic/react-sortable-hoc/issues/489)) ([f4a9b4a](https://github.com/clauderic/react-sortable-hoc/commit/f4a9b4a)) | ||
- Detect scroll container automatically ([#507](https://github.com/clauderic/react-sortable-hoc/issues/507)) ([6572921](https://github.com/clauderic/react-sortable-hoc/commit/6572921)) | ||
<a name="1.7.1"></a> | ||
## [1.7.1](https://github.com/clauderic/react-sortable-hoc/compare/v1.7.0...v1.7.1) (2019-03-06) | ||
## [1.7.1](https://github.com/clauderic/react-sortable-hoc/compare/v1.1.0...v1.7.1) (2019-03-06) | ||
@@ -31,3 +51,3 @@ ### Bug Fixes | ||
# [1.7.0](https://github.com/clauderic/react-sortable-hoc/compare/v1.6.1...v1.7.0) (2019-03-06) | ||
# [1.7.0](https://github.com/clauderic/react-sortable-hoc/compare/v1.1.0...v1.7.0) (2019-03-06) | ||
@@ -34,0 +54,0 @@ ### Bug Fixes |
@@ -668,3 +668,3 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
var destCtx = field.getContext('2d'); | ||
destCtx.drawImage(fields[index], 0, 0); | ||
destCtx.drawImage(fields[i], 0, 0); | ||
} | ||
@@ -671,0 +671,0 @@ }); |
@@ -674,3 +674,3 @@ 'use strict'; | ||
var destCtx = field.getContext('2d'); | ||
destCtx.drawImage(fields[index], 0, 0); | ||
destCtx.drawImage(fields[i], 0, 0); | ||
} | ||
@@ -677,0 +677,0 @@ }); |
@@ -924,3 +924,3 @@ (function (global, factory) { | ||
var destCtx = field.getContext('2d'); | ||
destCtx.drawImage(fields[index], 0, 0); | ||
destCtx.drawImage(fields[i], 0, 0); | ||
} | ||
@@ -927,0 +927,0 @@ }); |
@@ -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 y=function(e,t){return n(e)||o(e,t)||l()};var c=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 u=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)};var f=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")};var m=function(e){return c(e)||u(e)||f()};var h=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 p=function(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),e},g=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 x=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var b=function(e,t){return!t||"object"!==g(t)&&"function"!=typeof t?x(e):t},w=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 S=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)};var O=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},T=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}},C=function(){function e(){h(this,e),O(this,"refs",{})}return p(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(I)}}]),e}();function I(e,t){return e.node.sortableInfo.index-t.node.sortableInfo.index}function k(n){for(var e=arguments.length,o=new Array(1<e?e-1:0),t=1;t<e;t++)o[t-1]=arguments[t];return Object.keys(n).reduce(function(e,t){return-1===o.indexOf(t)&&(e[t]=n[t]),e},{})}var E={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},A=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 R(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function N(e,t){e.style["".concat(A,"Transform")]=null==t?"":"translate3d(".concat(t.x,"px,").concat(t.y,"px,0)")}function M(e,t){e.style["".concat(A,"TransitionDuration")]=null==t?"":"".concat(t,"ms")}function D(e,t){for(;e;){if(t(e))return e;e=e.parentNode}return null}function W(e,t,n){return Math.max(e,Math.min(n,t))}function j(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){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 L(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:L(e.parentNode,t,o)}}function _(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);T(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 T(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 B(e){return e?(t=e,n=window.getComputedStyle(t),o=/(auto|scroll)/,["overflow","overflowX","overflowY"].find(function(e){return o.test(n[e])})?e:B(e.parentNode)):null;var t,n,o}var G="A",U="BUTTON",q="CANVAS",X="INPUT",Y="OPTION",F="TEXTAREA",z="SELECT";function V(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return h(this,t),b(this,w(t).apply(this,arguments))}return S(t,e),p(t,[{key:"componentDidMount",value:function(){a.findDOMNode(this).sortableHandle=!0}},{key:"getWrappedInstance",value:function(){return T(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),O(e,"displayName",P("sortableHandle",n)),t}function $(e){return null!=e.sortableHandle}var J=function(){function n(e,t){h(this,n),this.container=e,this.onScrollCallback=t}return p(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,f=this.container,h=f.scrollTop,d=f.scrollLeft,p=f.scrollHeight,y=f.scrollWidth,g=0===h,v=p-h-f.clientHeight==0,m=0===d,x=y-d-f.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 K={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,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,shouldCancelStart:i.func,transitionDuration:i.number,updateBeforeSortStart:i.func,useDragHandle:i.bool,useWindowAsScrollContainer:i.bool},Q={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,shouldCancelStart:function(e){return-1!==[X,F,z,Y,U].indexOf(e.target.tagName)},transitionDuration:300,useWindowAsScrollContainer:!1},Z=Object.keys(K);function ee(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 v,t;return h(this,n),v=b(this,w(n).call(this,e)),O(x(x(v)),"handleStart",function(e){var t=v.props,n=t.distance,o=t.shouldCancelStart;if(2!==e.button&&!o(e)){v.touched=!0,v.position=H(e);var r,i=D(e.target,function(e){return null!=e.sortableInfo});if(i&&i.sortableInfo&&v.nodeIsChild(i)&&!v.state.sorting){var a=v.props.useDragHandle,s=i.sortableInfo,l=s.index,c=s.collection;if(s.disabled)return;if(a&&!D(e.target,$))return;v.manager.active={collection:c,index:l},(r=e).touches&&r.touches.length||r.changedTouches&&r.changedTouches.length||e.target.tagName!==G||e.preventDefault(),n||(0===v.props.pressDelay?v.handlePress(e):v.pressTimer=setTimeout(function(){return v.handlePress(e)},v.props.pressDelay))}}}),O(x(x(v)),"nodeIsChild",function(e){return e.sortableInfo.manager===v.manager}),O(x(x(v)),"handleMove",function(e){var t=v.props,n=t.distance,o=t.pressThreshold;if(!v.state.sorting&&v.touched&&!v._awaitingUpdateBeforeSortStart){var r=H(e),i={x:v.position.x-r.x,y:v.position.y-r.y},a=Math.abs(i.x)+Math.abs(i.y);v.delta=i,n||o&&!(o<=a)?n&&n<=a&&v.manager.isActive()&&v.handlePress(e):(clearTimeout(v.cancelTimer),v.cancelTimer=setTimeout(v.cancel,0))}}),O(x(x(v)),"handleEnd",function(){v.touched=!1,v.cancel()}),O(x(x(v)),"cancel",function(){var e=v.props.distance;v.state.sorting||(e||clearTimeout(v.pressTimer),v.manager.active=null)}),O(x(x(v)),"handlePress",function(g){try{var r=v.manager.getActive(),e=function(){if(r){var e=function(){var e,t,n=p.sortableInfo.index,o=(e=p,{bottom:j((t=window.getComputedStyle(e)).marginBottom),left:j(t.marginLeft),right:j(t.marginRight),top:j(t.marginTop)}),r=v.scrollContainer.getBoundingClientRect(),i=c({collection:y,index:n,node:p});v.node=p,v.margin=o,v.width=i.width,v.height=i.height,v.marginOffset={x:v.margin.left+v.margin.right,y:Math.max(v.margin.top,v.margin.bottom)},v.boundingClientRect=p.getBoundingClientRect(),v.containerBoundingRect=r,v.index=n,v.newIndex=n,v.axis={x:0<=l.indexOf("x"),y:0<=l.indexOf("y")},v.offsetEdge=L(p,v.container),v.initialOffset=H(g),v.initialScroll={left:v.scrollContainer.scrollLeft,top:v.scrollContainer.scrollTop},v.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset};var a=p.querySelectorAll("input, textarea, select, canvas"),s=p.cloneNode(!0);m(s.querySelectorAll("input, textarea, select, canvas")).forEach(function(e,t){("file"!==e.type&&a[n]&&(e.value=a[t].value),e.tagName===q)&&e.getContext("2d").drawImage(a[n],0,0)}),v.helper=v.helperContainer.appendChild(s),R(v.helper,{boxSizing:"border-box",height:"".concat(v.height,"px"),left:"".concat(v.boundingClientRect.left-o.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(v.boundingClientRect.top-o.top,"px"),width:"".concat(v.width,"px")}),f&&R(v.sortableGhost=p,{opacity:0,visibility:"hidden"}),v.minTranslate={},v.maxTranslate={},v.axis.x&&(v.minTranslate.x=(d?0:r.left)-v.boundingClientRect.left-v.width/2,v.maxTranslate.x=(d?v.contentWindow.innerWidth:r.left+r.width)-v.boundingClientRect.left-v.width/2),v.axis.y&&(v.minTranslate.y=(d?0:r.top)-v.boundingClientRect.top-v.height/2,v.maxTranslate.y=(d?v.contentWindow.innerHeight:r.top+r.height)-v.boundingClientRect.top-v.height/2),u&&u.split(" ").forEach(function(e){return v.helper.classList.add(e)}),v.listenerNode=g.touches?p:v.contentWindow,E.move.forEach(function(e){return v.listenerNode.addEventListener(e,v.handleSortMove,!1)}),E.end.forEach(function(e){return v.listenerNode.addEventListener(e,v.handleSortEnd,!1)}),v.setState({sorting:!0,sortingIndex:n}),h&&h({collection:y,index:n,node:p},g)},t=v.props,l=t.axis,c=t.getHelperDimensions,u=t.helperClass,f=t.hideSortableGhost,n=t.updateBeforeSortStart,h=t.onSortStart,d=t.useWindowAsScrollContainer,p=r.node,y=r.collection,o=function(){if("function"==typeof n){v._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=p.sortableInfo.index;return Promise.resolve(n({collection:y,index:e,node:p},g)).then(function(){})},function(e,t){if(v._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)}}),O(x(x(v)),"handleSortMove",function(e){var t=v.props.onSortMove;e.preventDefault(),v.updateHelperPosition(e),v.animateNodes(),v.autoscroll(),t&&t(e)}),O(x(x(v)),"handleSortEnd",function(e){var t=v.props,n=t.hideSortableGhost,o=t.onSortEnd,r=v.manager.active.collection,i=v.manager.refs[r];v.listenerNode&&(E.move.forEach(function(e){return v.listenerNode.removeEventListener(e,v.handleSortMove)}),E.end.forEach(function(e){return v.listenerNode.removeEventListener(e,v.handleSortEnd)})),v.helper.parentNode.removeChild(v.helper),n&&v.sortableGhost&&R(v.sortableGhost,{opacity:"",visibility:""});for(var a=0,s=i.length;a<s;a++){var l=i[a],c=l.node;N(c,l.edgeOffset=null),M(c,null)}v.autoScroller.clear(),v.manager.active=null,v.setState({sorting:!1,sortingIndex:null}),"function"==typeof o&&o({collection:r,newIndex:v.newIndex,oldIndex:v.index},e),v.touched=!1}),O(x(x(v)),"autoscroll",function(){v.props.disableAutoscroll||v.autoScroller.update({height:v.height,maxTranslate:v.maxTranslate,minTranslate:v.minTranslate,translate:v.translate,width:v.width})}),O(x(x(v)),"onAutoScroll",function(e){v.translate.x+=e.left,v.translate.y+=e.top,v.animateNodes()}),T(!((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."),v.state={},v.manager=new C,v.events={end:v.handleEnd,move:v.handleMove,start:v.handleStart},v}return S(n,e),p(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:B(n.container)||n.container,n.autoScroller=new J(n.scrollContainer,n.onAutoScroll),Object.keys(n.events).forEach(function(t){return E[t].forEach(function(e){return n.container.addEventListener(e,n.events[t],!1)})})})}},{key:"componentWillUnmount",value:function(){var n=this;this.container&&Object.keys(this.events).forEach(function(t){return E[t].forEach(function(e){return n.container.removeEventListener(e,n.events[t])})})}},{key:"updateHelperPosition",value:function(e){var t=this.props,n=t.lockAxis,o=t.lockOffset,r=t.lockToContainerEdges,i=H(e),a={x:i.x-this.initialOffset.x,y:i.y-this.initialOffset.y};if(a.y-=window.pageYOffset-this.initialWindowScroll.top,a.x-=window.pageXOffset-this.initialWindowScroll.left,this.translate=a,r){var s=function(e){var t=e.height,n=e.width,o=e.lockOffset,r=Array.isArray(o)?o:[o,o];T(2===r.length,"lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given %s",o);var i=y(r,2),a=i[0],s=i[1];return[_({height:t,lockOffset:a,width:n}),_({height:t,lockOffset:s,width:n})]}({height:this.height,lockOffset:o,width:this.width}),l=y(s,2),c=l[0],u=l[1],f=this.width/2-c.x,h=this.height/2-c.y,d=this.width/2-u.x,p=this.height/2-u.y;a.x=W(this.minTranslate.x+f,this.maxTranslate.x-d,a.x),a.y=W(this.minTranslate.y+h,this.maxTranslate.y-p,a.y)}"x"===n?a.y=0:"y"===n&&(a.x=0),N(this.helper,a)}},{key:"animateNodes",value:function(){var e=this.props,t=e.transitionDuration,n=e.hideSortableGhost,o=e.onSortOver,r=this.manager.getOrderedRefs(),i=this.scrollContainer.scrollLeft-this.initialScroll.left,a=this.scrollContainer.scrollTop-this.initialScroll.top,s=this.offsetEdge.left+this.translate.x+i,l=this.offsetEdge.top+this.translate.y+a,c=window.pageXOffset-this.initialWindowScroll.left,u=window.pageYOffset-this.initialWindowScroll.top,f=this.newIndex;this.newIndex=null;for(var h=0,d=r.length;h<d;h++){var p=r[h].node,y=p.sortableInfo.index,g=p.offsetWidth,v=p.offsetHeight,m=this.height>v?v/2:this.height/2,x=this.width>g?g/2:this.width/2,b={x:0,y:0},w=r[h].edgeOffset;w||(w=L(p,this.container),r[h].edgeOffset=w);var S=h<r.length-1&&r[h+1],O=0<h&&r[h-1];S&&!S.edgeOffset&&(S.edgeOffset=L(S.node,this.container)),y!==this.index?(t&&M(p,t),this.axis.x?this.axis.y?y<this.index&&(s+c-x<=w.left&&l+u<=w.top+m||l+u+m<=w.top)?(b.x=this.width+this.marginOffset.x,w.left+b.x>this.containerBoundingRect.width-x&&S&&(b.x=S.edgeOffset.left-w.left,b.y=S.edgeOffset.top-w.top),null===this.newIndex&&(this.newIndex=y)):y>this.index&&(s+c+x>=w.left&&l+u+m>=w.top||l+u+m>=w.top+v)&&(b.x=-(this.width+this.marginOffset.x),w.left+b.x<this.containerBoundingRect.left+x&&O&&(b.x=O.edgeOffset.left-w.left,b.y=O.edgeOffset.top-w.top),this.newIndex=y):y>this.index&&s+c+x>=w.left?(b.x=-(this.width+this.marginOffset.x),this.newIndex=y):y<this.index&&s+c<=w.left+x&&(b.x=this.width+this.marginOffset.x,null==this.newIndex&&(this.newIndex=y)):this.axis.y&&(y>this.index&&l+u+m>=w.top?(b.y=-(this.height+this.marginOffset.y),this.newIndex=y):y<this.index&&l+u<=w.top+m&&(b.y=this.height+this.marginOffset.y,null==this.newIndex&&(this.newIndex=y))),N(p,b)):n&&R(this.sortableGhost=p,{opacity:0,visibility:"hidden"})}null==this.newIndex&&(this.newIndex=this.index),o&&this.newIndex!==f&&o({collection:this.manager.active.collection,index:this.index,newIndex:this.newIndex,oldIndex:f})}},{key:"getWrappedInstance",value:function(){return T(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,Z)))}},{key:"helperContainer",get:function(){var e=this.props.helperContainer;return"function"==typeof e?e():this.props.helperContainer||this.document.body}}]),n}(r.Component),O(e,"displayName",P("sortableList",t)),O(e,"defaultProps",Q),O(e,"propTypes",K),O(e,"childContextTypes",{manager:i.object.isRequired}),n}var te={index:i.number.isRequired,collection:i.oneOfType([i.number,i.string]),disabled:i.bool},ne=Object.keys(te);function oe(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return h(this,t),b(this,w(t).apply(this,arguments))}return S(t,e),p(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 T(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,ne)))}}]),t}(r.Component),O(e,"displayName",P("sortableElement",n)),O(e,"contextTypes",{manager:i.object.isRequired}),O(e,"propTypes",te),O(e,"defaultProps",{collection:0}),t}e.SortableContainer=ee,e.sortableContainer=ee,e.SortableElement=oe,e.sortableElement=oe,e.SortableHandle=V,e.sortableHandle=V,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 y=function(e,t){return n(e)||o(e,t)||l()};var c=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 u=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)};var f=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")};var m=function(e){return c(e)||u(e)||f()};var h=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 p=function(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),e},g=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 x=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var b=function(e,t){return!t||"object"!==g(t)&&"function"!=typeof t?x(e):t},w=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 S=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)};var O=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},T=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}},C=function(){function e(){h(this,e),O(this,"refs",{})}return p(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(I)}}]),e}();function I(e,t){return e.node.sortableInfo.index-t.node.sortableInfo.index}function k(n){for(var e=arguments.length,o=new Array(1<e?e-1:0),t=1;t<e;t++)o[t-1]=arguments[t];return Object.keys(n).reduce(function(e,t){return-1===o.indexOf(t)&&(e[t]=n[t]),e},{})}var E={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},A=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 R(t,n){Object.keys(n).forEach(function(e){t.style[e]=n[e]})}function N(e,t){e.style["".concat(A,"Transform")]=null==t?"":"translate3d(".concat(t.x,"px,").concat(t.y,"px,0)")}function M(e,t){e.style["".concat(A,"TransitionDuration")]=null==t?"":"".concat(t,"ms")}function D(e,t){for(;e;){if(t(e))return e;e=e.parentNode}return null}function W(e,t,n){return Math.max(e,Math.min(n,t))}function j(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){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 L(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:L(e.parentNode,t,o)}}function _(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);T(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 T(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 B(e){return e?(t=e,n=window.getComputedStyle(t),o=/(auto|scroll)/,["overflow","overflowX","overflowY"].find(function(e){return o.test(n[e])})?e:B(e.parentNode)):null;var t,n,o}var G="A",U="BUTTON",q="CANVAS",X="INPUT",Y="OPTION",F="TEXTAREA",z="SELECT";function V(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return h(this,t),b(this,w(t).apply(this,arguments))}return S(t,e),p(t,[{key:"componentDidMount",value:function(){a.findDOMNode(this).sortableHandle=!0}},{key:"getWrappedInstance",value:function(){return T(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),O(e,"displayName",P("sortableHandle",n)),t}function $(e){return null!=e.sortableHandle}var J=function(){function n(e,t){h(this,n),this.container=e,this.onScrollCallback=t}return p(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,f=this.container,h=f.scrollTop,d=f.scrollLeft,p=f.scrollHeight,y=f.scrollWidth,g=0===h,v=p-h-f.clientHeight==0,m=0===d,x=y-d-f.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 K={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,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,shouldCancelStart:i.func,transitionDuration:i.number,updateBeforeSortStart:i.func,useDragHandle:i.bool,useWindowAsScrollContainer:i.bool},Q={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,shouldCancelStart:function(e){return-1!==[X,F,z,Y,U].indexOf(e.target.tagName)},transitionDuration:300,useWindowAsScrollContainer:!1},Z=Object.keys(K);function ee(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 v,t;return h(this,n),v=b(this,w(n).call(this,e)),O(x(x(v)),"handleStart",function(e){var t=v.props,n=t.distance,o=t.shouldCancelStart;if(2!==e.button&&!o(e)){v.touched=!0,v.position=H(e);var r,i=D(e.target,function(e){return null!=e.sortableInfo});if(i&&i.sortableInfo&&v.nodeIsChild(i)&&!v.state.sorting){var a=v.props.useDragHandle,s=i.sortableInfo,l=s.index,c=s.collection;if(s.disabled)return;if(a&&!D(e.target,$))return;v.manager.active={collection:c,index:l},(r=e).touches&&r.touches.length||r.changedTouches&&r.changedTouches.length||e.target.tagName!==G||e.preventDefault(),n||(0===v.props.pressDelay?v.handlePress(e):v.pressTimer=setTimeout(function(){return v.handlePress(e)},v.props.pressDelay))}}}),O(x(x(v)),"nodeIsChild",function(e){return e.sortableInfo.manager===v.manager}),O(x(x(v)),"handleMove",function(e){var t=v.props,n=t.distance,o=t.pressThreshold;if(!v.state.sorting&&v.touched&&!v._awaitingUpdateBeforeSortStart){var r=H(e),i={x:v.position.x-r.x,y:v.position.y-r.y},a=Math.abs(i.x)+Math.abs(i.y);v.delta=i,n||o&&!(o<=a)?n&&n<=a&&v.manager.isActive()&&v.handlePress(e):(clearTimeout(v.cancelTimer),v.cancelTimer=setTimeout(v.cancel,0))}}),O(x(x(v)),"handleEnd",function(){v.touched=!1,v.cancel()}),O(x(x(v)),"cancel",function(){var e=v.props.distance;v.state.sorting||(e||clearTimeout(v.pressTimer),v.manager.active=null)}),O(x(x(v)),"handlePress",function(g){try{var r=v.manager.getActive(),e=function(){if(r){var e=function(){var e,t,n=p.sortableInfo.index,o=(e=p,{bottom:j((t=window.getComputedStyle(e)).marginBottom),left:j(t.marginLeft),right:j(t.marginRight),top:j(t.marginTop)}),r=v.scrollContainer.getBoundingClientRect(),i=c({collection:y,index:n,node:p});v.node=p,v.margin=o,v.width=i.width,v.height=i.height,v.marginOffset={x:v.margin.left+v.margin.right,y:Math.max(v.margin.top,v.margin.bottom)},v.boundingClientRect=p.getBoundingClientRect(),v.containerBoundingRect=r,v.index=n,v.newIndex=n,v.axis={x:0<=l.indexOf("x"),y:0<=l.indexOf("y")},v.offsetEdge=L(p,v.container),v.initialOffset=H(g),v.initialScroll={left:v.scrollContainer.scrollLeft,top:v.scrollContainer.scrollTop},v.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset};var a=p.querySelectorAll("input, textarea, select, canvas"),s=p.cloneNode(!0);m(s.querySelectorAll("input, textarea, select, canvas")).forEach(function(e,t){("file"!==e.type&&a[n]&&(e.value=a[t].value),e.tagName===q)&&e.getContext("2d").drawImage(a[t],0,0)}),v.helper=v.helperContainer.appendChild(s),R(v.helper,{boxSizing:"border-box",height:"".concat(v.height,"px"),left:"".concat(v.boundingClientRect.left-o.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(v.boundingClientRect.top-o.top,"px"),width:"".concat(v.width,"px")}),f&&R(v.sortableGhost=p,{opacity:0,visibility:"hidden"}),v.minTranslate={},v.maxTranslate={},v.axis.x&&(v.minTranslate.x=(d?0:r.left)-v.boundingClientRect.left-v.width/2,v.maxTranslate.x=(d?v.contentWindow.innerWidth:r.left+r.width)-v.boundingClientRect.left-v.width/2),v.axis.y&&(v.minTranslate.y=(d?0:r.top)-v.boundingClientRect.top-v.height/2,v.maxTranslate.y=(d?v.contentWindow.innerHeight:r.top+r.height)-v.boundingClientRect.top-v.height/2),u&&u.split(" ").forEach(function(e){return v.helper.classList.add(e)}),v.listenerNode=g.touches?p:v.contentWindow,E.move.forEach(function(e){return v.listenerNode.addEventListener(e,v.handleSortMove,!1)}),E.end.forEach(function(e){return v.listenerNode.addEventListener(e,v.handleSortEnd,!1)}),v.setState({sorting:!0,sortingIndex:n}),h&&h({collection:y,index:n,node:p},g)},t=v.props,l=t.axis,c=t.getHelperDimensions,u=t.helperClass,f=t.hideSortableGhost,n=t.updateBeforeSortStart,h=t.onSortStart,d=t.useWindowAsScrollContainer,p=r.node,y=r.collection,o=function(){if("function"==typeof n){v._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=p.sortableInfo.index;return Promise.resolve(n({collection:y,index:e,node:p},g)).then(function(){})},function(e,t){if(v._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)}}),O(x(x(v)),"handleSortMove",function(e){var t=v.props.onSortMove;e.preventDefault(),v.updateHelperPosition(e),v.animateNodes(),v.autoscroll(),t&&t(e)}),O(x(x(v)),"handleSortEnd",function(e){var t=v.props,n=t.hideSortableGhost,o=t.onSortEnd,r=v.manager.active.collection,i=v.manager.refs[r];v.listenerNode&&(E.move.forEach(function(e){return v.listenerNode.removeEventListener(e,v.handleSortMove)}),E.end.forEach(function(e){return v.listenerNode.removeEventListener(e,v.handleSortEnd)})),v.helper.parentNode.removeChild(v.helper),n&&v.sortableGhost&&R(v.sortableGhost,{opacity:"",visibility:""});for(var a=0,s=i.length;a<s;a++){var l=i[a],c=l.node;N(c,l.edgeOffset=null),M(c,null)}v.autoScroller.clear(),v.manager.active=null,v.setState({sorting:!1,sortingIndex:null}),"function"==typeof o&&o({collection:r,newIndex:v.newIndex,oldIndex:v.index},e),v.touched=!1}),O(x(x(v)),"autoscroll",function(){v.props.disableAutoscroll||v.autoScroller.update({height:v.height,maxTranslate:v.maxTranslate,minTranslate:v.minTranslate,translate:v.translate,width:v.width})}),O(x(x(v)),"onAutoScroll",function(e){v.translate.x+=e.left,v.translate.y+=e.top,v.animateNodes()}),T(!((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."),v.state={},v.manager=new C,v.events={end:v.handleEnd,move:v.handleMove,start:v.handleStart},v}return S(n,e),p(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:B(n.container)||n.container,n.autoScroller=new J(n.scrollContainer,n.onAutoScroll),Object.keys(n.events).forEach(function(t){return E[t].forEach(function(e){return n.container.addEventListener(e,n.events[t],!1)})})})}},{key:"componentWillUnmount",value:function(){var n=this;this.container&&Object.keys(this.events).forEach(function(t){return E[t].forEach(function(e){return n.container.removeEventListener(e,n.events[t])})})}},{key:"updateHelperPosition",value:function(e){var t=this.props,n=t.lockAxis,o=t.lockOffset,r=t.lockToContainerEdges,i=H(e),a={x:i.x-this.initialOffset.x,y:i.y-this.initialOffset.y};if(a.y-=window.pageYOffset-this.initialWindowScroll.top,a.x-=window.pageXOffset-this.initialWindowScroll.left,this.translate=a,r){var s=function(e){var t=e.height,n=e.width,o=e.lockOffset,r=Array.isArray(o)?o:[o,o];T(2===r.length,"lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given %s",o);var i=y(r,2),a=i[0],s=i[1];return[_({height:t,lockOffset:a,width:n}),_({height:t,lockOffset:s,width:n})]}({height:this.height,lockOffset:o,width:this.width}),l=y(s,2),c=l[0],u=l[1],f=this.width/2-c.x,h=this.height/2-c.y,d=this.width/2-u.x,p=this.height/2-u.y;a.x=W(this.minTranslate.x+f,this.maxTranslate.x-d,a.x),a.y=W(this.minTranslate.y+h,this.maxTranslate.y-p,a.y)}"x"===n?a.y=0:"y"===n&&(a.x=0),N(this.helper,a)}},{key:"animateNodes",value:function(){var e=this.props,t=e.transitionDuration,n=e.hideSortableGhost,o=e.onSortOver,r=this.manager.getOrderedRefs(),i=this.scrollContainer.scrollLeft-this.initialScroll.left,a=this.scrollContainer.scrollTop-this.initialScroll.top,s=this.offsetEdge.left+this.translate.x+i,l=this.offsetEdge.top+this.translate.y+a,c=window.pageXOffset-this.initialWindowScroll.left,u=window.pageYOffset-this.initialWindowScroll.top,f=this.newIndex;this.newIndex=null;for(var h=0,d=r.length;h<d;h++){var p=r[h].node,y=p.sortableInfo.index,g=p.offsetWidth,v=p.offsetHeight,m=this.height>v?v/2:this.height/2,x=this.width>g?g/2:this.width/2,b={x:0,y:0},w=r[h].edgeOffset;w||(w=L(p,this.container),r[h].edgeOffset=w);var S=h<r.length-1&&r[h+1],O=0<h&&r[h-1];S&&!S.edgeOffset&&(S.edgeOffset=L(S.node,this.container)),y!==this.index?(t&&M(p,t),this.axis.x?this.axis.y?y<this.index&&(s+c-x<=w.left&&l+u<=w.top+m||l+u+m<=w.top)?(b.x=this.width+this.marginOffset.x,w.left+b.x>this.containerBoundingRect.width-x&&S&&(b.x=S.edgeOffset.left-w.left,b.y=S.edgeOffset.top-w.top),null===this.newIndex&&(this.newIndex=y)):y>this.index&&(s+c+x>=w.left&&l+u+m>=w.top||l+u+m>=w.top+v)&&(b.x=-(this.width+this.marginOffset.x),w.left+b.x<this.containerBoundingRect.left+x&&O&&(b.x=O.edgeOffset.left-w.left,b.y=O.edgeOffset.top-w.top),this.newIndex=y):y>this.index&&s+c+x>=w.left?(b.x=-(this.width+this.marginOffset.x),this.newIndex=y):y<this.index&&s+c<=w.left+x&&(b.x=this.width+this.marginOffset.x,null==this.newIndex&&(this.newIndex=y)):this.axis.y&&(y>this.index&&l+u+m>=w.top?(b.y=-(this.height+this.marginOffset.y),this.newIndex=y):y<this.index&&l+u<=w.top+m&&(b.y=this.height+this.marginOffset.y,null==this.newIndex&&(this.newIndex=y))),N(p,b)):n&&R(this.sortableGhost=p,{opacity:0,visibility:"hidden"})}null==this.newIndex&&(this.newIndex=this.index),o&&this.newIndex!==f&&o({collection:this.manager.active.collection,index:this.index,newIndex:this.newIndex,oldIndex:f})}},{key:"getWrappedInstance",value:function(){return T(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,Z)))}},{key:"helperContainer",get:function(){var e=this.props.helperContainer;return"function"==typeof e?e():this.props.helperContainer||this.document.body}}]),n}(r.Component),O(e,"displayName",P("sortableList",t)),O(e,"defaultProps",Q),O(e,"propTypes",K),O(e,"childContextTypes",{manager:i.object.isRequired}),n}var te={index:i.number.isRequired,collection:i.oneOfType([i.number,i.string]),disabled:i.bool},ne=Object.keys(te);function oe(n){var e,t,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return t=e=function(e){function t(){return h(this,t),b(this,w(t).apply(this,arguments))}return S(t,e),p(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 T(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,ne)))}}]),t}(r.Component),O(e,"displayName",P("sortableElement",n)),O(e,"contextTypes",{manager:i.object.isRequired}),O(e,"propTypes",te),O(e,"defaultProps",{collection:0}),t}e.SortableContainer=ee,e.sortableContainer=ee,e.SortableElement=oe,e.sortableElement=oe,e.SortableHandle=V,e.sortableHandle=V,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.8.0", | ||
"version": "1.8.1", | ||
"description": "Set of higher-order components to turn any list into a sortable, touch-friendly, animated list", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
697297