UNPKG

react-sortable

Version:
1 lines 5.66 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.Sortable=t(require("React")):e.Sortable=t(e.React)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1);Object.defineProperty(t,"sortable",{enumerable:!0,get:function(){return n.SortableComposition}}),Object.defineProperty(t,"Sortable",{enumerable:!0,get:function(){return n.SortableComposition}}),Object.defineProperty(t,"HORIZONTAL",{enumerable:!0,get:function(){return n.HORIZONTAL}}),Object.defineProperty(t,"VERTICAL",{enumerable:!0,get:function(){return n.VERTICAL}})},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;return function(r){function n(){var e,r,o,u;i(this,n);for(var s=arguments.length,c=Array(s),f=0;f<s;f++)c[f]=arguments[f];return r=o=a(this,(e=n.__proto__||Object.getPrototypeOf(n)).call.apply(e,[this].concat(c))),o.sortEnd=function(e){e.preventDefault(),h=null},o.sortStart=function(e){h=e.currentTarget.dataset.id;var t=e.dataTransfer;void 0!==t&&(e.dataTransfer.setData("text",e.target.innerHTML),t.setDragImage&&"a"===e.currentTarget.tagName.toLowerCase()&&t.setDragImage(e.target,0,0))},o.dragOver=function(e){e.preventDefault();var r=o.props,n=r.moveInMiddle,i=(r.sortId,e.currentTarget),a=Number(i.dataset.id),u=Number(h),s=i.getBoundingClientRect().height,c=i.getBoundingClientRect().width,f=e.clientX,l=e.clientY,p=i.getBoundingClientRect().top,d=i.getBoundingClientRect().left,g=void 0,O=o.props.items;t===b&&(g=(0,y.isMouseBeyond)(l,p,s,n)),t===v&&(g=(0,y.isMouseBeyond)(f,d,c,n));y.isMouseBeyond;a!==u&&g&&(O=(0,y.swapArrayElements)(O,u,a),h=a,o.props.onSortItems(O))},u=r,a(o,u)}return u(n,r),f(n,[{key:"render",value:function(){var t=Object.assign({},this.props);delete t.onSortItems;var r=t.sortId,n=o(t,["sortId"]);return p.default.createElement(e,c({draggable:!0,onDragOver:this.dragOver,onDragStart:this.sortStart,onDragEnd:this.sortEnd,onTouchStart:this.sortStart,onTouchMove:this.dragOver,onTouchEnd:this.sortEnd,"data-id":r},n))}}]),n}(p.default.Component)}Object.defineProperty(t,"__esModule",{value:!0}),t.HORIZONTAL=t.VERTICAL=void 0;var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.SortableComposition=s;var l=r(2),p=n(l),d=r(3),y=(n(d),r(8)),b=t.VERTICAL="VERTICAL",v=t.HORIZONTAL="HORIZONTAL",h=null},function(t,r){t.exports=e},function(e,t,r){e.exports=r(4)()},function(e,t,r){"use strict";var n=r(5),o=r(6),i=r(7);e.exports=function(){function e(e,t,r,n,a,u){u!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=n,r.PropTypes=r,r}},function(e,t,r){"use strict";function n(e){return function(){return e}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,r){"use strict";function n(e,t,r,n,i,a,u,s){if(o(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[r,n,i,a,u,s],l=0;c=new Error(t.replace(/%s/g,function(){return f[l++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var o=function(e){};e.exports=n},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,r){"use strict";function n(e,t,r){var n=e[r];return e[r]=e[t],e[t]=n,e}function o(e,t,r,n){var o;return o=n?r/2:0,e-t>o}Object.defineProperty(t,"__esModule",{value:!0}),t.swapArrayElements=n,t.isMouseBeyond=o}])});