. Read more: https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute"),n?t.cloneElement(e,{ref:function(e){st(n,e),st(r,e)}}):t.cloneElement(e,{ref:r})}function lt(e){if("string"!=typeof e.type){var t=e.type.displayName||e.type.name||"the component";throw new Error("Only native element nodes can now be passed to React DnD connectors."+"You can either wrap ".concat(t," into a
, or turn it into a ")+"drag source or a drop target itself.")}}function dt(e){var r={};return Object.keys(e).forEach((function(n){var o=e[n];if(n.endsWith("Ref"))r[n]=e[n];else{var i=function(e){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t.isValidElement(r)){var o=r;return e(o,n),o}var i=r;lt(i);var a=n?function(t){return e(t,n)}:e;return ft(i,a)}}(o);r[n]=function(){return i}}})),r}function pt(e){return(pt="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 gt(e){return null!==e&&"object"===pt(e)&&e.hasOwnProperty("current")}function ht(e,t){for(var r=0;r1?t-1:0),n=1;n2?r-2:0),o=2;o1&&void 0!==arguments[1]?arguments[1]:{};return At("DragLayer","collect[, options]",e,r),c("function"==typeof e,'Expected "collect" provided as the first argument to DragLayer to be a function that collects props to inject into the component. ',"Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer",e),c(Rt(r),'Expected "options" provided as the second argument to DragLayer to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer',r),function(n){var o=n,i=r.arePropsEqual,a=void 0===i?Je:i,u=o.displayName||o.name||"Component",s=function(r){function n(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(e=wr(this,Dr(n).apply(this,arguments))).isCurrentlyMounted=!1,e.ref=t.createRef(),e.handleChange=function(){if(e.isCurrentlyMounted){var t=e.getCurrentState();Je(t,e.state)||e.setState(t)}},e}var i,s,f;return 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&&Cr(e,t)}(n,r),i=n,(s=[{key:"getDecoratedComponentInstance",value:function(){return c(this.ref.current,"In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()"),this.ref.current}},{key:"shouldComponentUpdate",value:function(e,t){return!a(e,this.props)||!Je(t,this.state)}},{key:"componentDidMount",value:function(){this.isCurrentlyMounted=!0,this.handleChange()}},{key:"componentWillUnmount",value:function(){this.isCurrentlyMounted=!1,this.unsubscribeFromOffsetChange&&(this.unsubscribeFromOffsetChange(),this.unsubscribeFromOffsetChange=void 0),this.unsubscribeFromStateChange&&(this.unsubscribeFromStateChange(),this.unsubscribeFromStateChange=void 0)}},{key:"render",value:function(){var e=this;return t.createElement(Le.Consumer,null,(function(r){var n=r.dragDropManager;return void 0===n?null:(e.receiveDragDropManager(n),e.isCurrentlyMounted?t.createElement(o,Object.assign({},e.props,e.state,{ref:Mt(o)?e.ref:null})):null)}))}},{key:"receiveDragDropManager",value:function(e){if(void 0===this.manager){this.manager=e,c("object"===Or(e),"Could not find the drag and drop manager in the context of %s. Make sure to render a DndProvider component in your top-level component. Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context",u,u);var t=this.manager.getMonitor();this.unsubscribeFromOffsetChange=t.subscribeToOffsetChange(this.handleChange),this.unsubscribeFromStateChange=t.subscribeToStateChange(this.handleChange)}}},{key:"getCurrentState",value:function(){if(!this.manager)return{};var t=this.manager.getMonitor();return e(t,this.props)}}])&&Sr(i.prototype,s),f&&Sr(i,f),n}(t.Component);return s.displayName="DragLayer(".concat(u,")"),s.DecoratedComponent=n,Jt(s,n)}},e.DragPreviewImage=Ke,e.DragSource=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};At("DragSource","type, spec, collect[, options]",e,t,r,n);var o=e;"function"!=typeof e&&(c(dr(e),'Expected "type" provided as the first argument to DragSource to be a string, or a function that returns a string given the current props. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',e),o=function(){return e}),c(Rt(t),'Expected "spec" provided as the second argument to DragSource to be a plain object. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',t);var i=function(e){return Object.keys(e).forEach((function(t){c(gr.indexOf(t)>-1,'Expected the drag source specification to only have some of the following keys: %s. Instead received a specification with an unexpected "%s" key. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',gr.join(", "),t),c("function"==typeof e[t],"Expected %s in the drag source specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source",t,t,e[t])})),hr.forEach((function(t){c("function"==typeof e[t],"Expected %s in the drag source specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source",t,t,e[t])})),function(t,r){return new yr(e,t,r)}}(t);return c("function"==typeof r,'Expected "collect" provided as the third argument to DragSource to be a function that returns a plain object of props to inject. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',r),c(Rt(n),'Expected "options" provided as the fourth argument to DragSource to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',r),function(e){return fr({containerDisplayName:"DragSource",createHandler:i,registerHandler:nt,createConnector:function(e){return new yt(e)},createMonitor:function(e){return new ct(e)},DecoratedComponent:e,getType:o,collect:r,options:n})}},e.DropTarget=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};At("DropTarget","type, spec, collect[, options]",e,t,r,n);var o=e;"function"!=typeof e&&(c(dr(e,!0),'Expected "type" provided as the first argument to DropTarget to be a string, an array of strings, or a function that returns either given the current props. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',e),o=function(){return e}),c(Rt(t),'Expected "spec" provided as the second argument to DropTarget to be a plain object. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',t);var i=function(e){return Object.keys(e).forEach((function(t){c(br.indexOf(t)>-1,'Expected the drop target specification to only have some of the following keys: %s. Instead received a specification with an unexpected "%s" key. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',br.join(", "),t),c("function"==typeof e[t],"Expected %s in the drop target specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target",t,t,e[t])})),function(t,r){return new mr(e,t,r)}}(t);return c("function"==typeof r,'Expected "collect" provided as the third argument to DropTarget to be a function that returns a plain object of props to inject. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',r),c(Rt(n),'Expected "options" provided as the fourth argument to DropTarget to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',r),function(e){return fr({containerDisplayName:"DropTarget",createHandler:i,registerHandler:rt,createMonitor:function(e){return new Ct(e)},createConnector:function(e){return new St(e)},DecoratedComponent:e,getType:o,collect:r,options:n})}},e.createDndContext=Ve,e.useDrag=function(e){var r=t.useRef(e);r.current=e,c(null!=e.item,"item must be defined"),c(null!=e.item.type,"item type must be defined");var n,o=mt((n=ot(),[t.useMemo((function(){return new ct(n)}),[n]),t.useMemo((function(){return new yt(n.getBackend())}),[n])]),2),i=o[0],a=o[1];!function(e,r,n){var o=ot(),i=t.useMemo((function(){return{beginDrag:function(){var t=e.current,n=t.begin,o=t.item;if(n){var i=n(r);return c(null==i||"object"===bt(i),"dragSpec.begin() must either return an object, undefined, or null"),i||o||{}}return o||{}},canDrag:function(){return"boolean"==typeof e.current.canDrag?e.current.canDrag:"function"!=typeof e.current.canDrag||e.current.canDrag(r)},isDragging:function(t,n){var o=e.current.isDragging;return o?o(r):n===t.getSourceId()},endDrag:function(){var t=e.current.end;t&&t(r.getItem(),r),n.reconnect()}}}),[]);Xe((function(){var t=vt(nt(e.current.item.type,i,o),2),a=t[0],u=t[1];return r.receiveHandlerId(a),n.receiveHandlerId(a),u}),[])}(r,i,a);var u=tt(i,r.current.collect||function(){return{}},(function(){return a.reconnect()})),s=t.useMemo((function(){return a.hooks.dragSource()}),[a]),f=t.useMemo((function(){return a.hooks.dragPreview()}),[a]);return Xe((function(){a.dragSourceOptions=r.current.options||null,a.reconnect()}),[a]),Xe((function(){a.dragPreviewOptions=r.current.previewOptions||null,a.reconnect()}),[a]),[u,s,f]},e.useDragLayer=function(e){var r=ot().getMonitor(),n=Tt(Ze(r,e),2),o=n[0],i=n[1];return t.useEffect((function(){return r.subscribeToOffsetChange(i)})),t.useEffect((function(){return r.subscribeToStateChange(i)})),o},e.useDrop=function(e){var r=t.useRef(e);r.current=e,c(null!=e.accept,"accept must be defined");var n,o=kt((n=ot(),[t.useMemo((function(){return new Ct(n)}),[n]),t.useMemo((function(){return new St(n.getBackend())}),[n])]),2),i=o[0],a=o[1];!function(e,r,n){var o=ot(),i=t.useMemo((function(){return{canDrop:function(){var t=e.current.canDrop;return!t||t(r.getItem(),r)},hover:function(){var t=e.current.hover;t&&t(r.getItem(),r)},drop:function(){var t=e.current.drop;if(t)return t(r.getItem(),r)}}}),[r]);Xe((function(){var t=It(rt(e.current.accept,i,o),2),a=t[0],u=t[1];return r.receiveHandlerId(a),n.receiveHandlerId(a),u}),[r,n])}(r,i,a);var u=tt(i,r.current.collect||function(){return{}},(function(){return a.reconnect()})),s=t.useMemo((function(){return a.hooks.dropTarget()}),[a]);return Xe((function(){a.dropTargetOptions=e.options||null,a.reconnect()}),[e.options]),[u,s]},Object.defineProperty(e,"__esModule",{value:!0})}));