react-selectable-fast
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -1,2 +0,2 @@ | ||
!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["React-Selectable-Fast"]=t(require("react")):e["React-Selectable-Fast"]=t(e.React)}(this,function(e){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var o={};return t.m=e,t.c=o,t.i=function(e){return e},t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(t,o){t.exports=e},function(e,t,o){e.exports=o(13)()},function(e,t,o){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{scrollTop:0,scrollLeft:0},o=t.scrollTop,n=t.scrollLeft,r=e.getBoundingClientRect();return{top:r.top+document.body.scrollTop+o,left:r.left+document.body.scrollLeft+n,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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 i(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},c=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),a=o(0),u=n(a),f=o(1),p=o(2),d=n(p),h=function(e){var t,o;return o=t=function(t){function o(){var e,t,n,i;r(this,o);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return t=n=s(this,(e=o.__proto__||Object.getPrototypeOf(o)).call.apply(e,[this].concat(c))),n.state={selected:n.props.selected,selecting:!1},n.registerSelectable=function(e){n.bounds=(0,d.default)(n.node,e),n.context.selectable.register(n)},n.selectableRef=function(e){return n.node=e},i=t,s(n,i)}return i(o,t),c(o,[{key:"componentDidMount",value:function(){this.registerSelectable()}},{key:"componentWillUnmount",value:function(){this.context.selectable.unregister(this)}},{key:"render",value:function(){return u.default.createElement(e,l({},this.props,{selected:this.state.selected,selecting:this.state.selecting,selectableRef:this.selectableRef}))}}]),o}(a.Component),t.defaultProps={selected:!1},t.contextTypes={selectable:f.object},o};t.default=h},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(0),c=function(e){return e&&e.__esModule?e:{default:e}}(l),a=o(1),u=function(e){function t(){var e,o,s,i;n(this,t);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return o=s=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),s.getRootRef=function(e){return s.root=e},i=o,r(s,i)}return s(t,e),i(t,[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){return c.default.createElement(this.props.component,{ref:this.getRootRef,onClick:this.context.selectable.clearSelection,className:"selectable-deselect-all "+this.props.className},this.props.children)}}]),t}(l.Component);u.defaultProps={component:"div"},u.contextTypes={selectable:a.object},t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(0),c=function(e){return e&&e.__esModule?e:{default:e}}(l),a=o(1),u=function(e){function t(){var e,o,s,i;n(this,t);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return o=s=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),s.getRootRef=function(e){return s.root=e},i=o,r(s,i)}return s(t,e),i(t,[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){return c.default.createElement(this.props.component,{ref:this.getRootRef,className:"selectable-select-all "+this.props.className,onClick:this.context.selectable.selectAll},this.props.children)}}]),t}(l.Component);u.defaultProps={component:"div"},u.contextTypes={selectable:a.object},t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 l(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)}Object.defineProperty(t,"__esModule",{value:!0});var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},a=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),u=o(0),f=n(u),p=o(1),d=o(10),h=n(d),m=o(2),v=n(m),y=o(8),b=n(y),g=o(7),S=n(g),w=function(){},x=function(e){function t(e){s(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.applyScale=function(e,t){return{scaledTop:e/o.props.scale,scaledLeft:t/o.props.scale}},o.setScollTop=function(e){var t=o.scrollContainer.scrollTop;o.checkScrollUp(e,t),o.checkScrollDown(e,t)},o.checkScrollUp=function(e,t){var n=o.props,r=n.minimumSpeedFactor,s=n.scrollSpeed,i=o.scrollBounds.top-e.clientY;if(i>0||e.clientY<0){var l=t-Math.max(i,r)*s;o.scrollContainer.scrollTop=l}},o.checkScrollDown=function(e,t){var n=o.props,r=n.minimumSpeedFactor,s=n.scrollSpeed,i=e.clientY-o.scrollBounds.bottom;if(i>0||e.clientY>window.innerHeight){var l=t+Math.max(i,r)*s;o.scrollContainer.scrollTop=Math.min(l,o.maxScroll)}},o.updateRegistry=function(){var e={scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft},t=!0,n=!1,r=void 0;try{for(var s,i=o.registry.values()[Symbol.iterator]();!(t=(s=i.next()).done);t=!0){s.value.registerSelectable(e)}}catch(e){n=!0,r=e}finally{try{!t&&i.return&&i.return()}finally{if(n)throw r}}},o.registerSelectable=function(e){o.registry.add(e),e.props.selected&&o.selectedItems.add(e)},o.unregisterSelectable=function(e){o.registry.delete(e)},o.applyContainerScroll=function(e,t){return e+t/o.props.scale},o.getWindowScroll=function(){return o.supportPageOffset?{windowTopScroll:window.pageYOffset,windowLeftScroll:window.pageXOffset}:{windowTopScroll:o.isCSS1Compat?document.documentElement.scrollTop:document.body.scrollTop,windowLeftScroll:o.isCSS1Compat?document.documentElement.scrollLeft:document.body.scrollLeft}},o.openSelectbox=function(e){var t=o.desktopEventCoords(e);if(o.setScollTop(t),!o.mouseMoveStarted){o.mouseMoveStarted=!0,o.mouseMoved=!0;var n=o.scrollContainer.scrollTop,s=o.applyScale(t.pageY,t.pageX),i=s.scaledTop,l=s.scaledLeft,c=o.getWindowScroll(),a=c.windowTopScroll,u=c.windowLeftScroll,f=o.applyContainerScroll(i-o.scrollBounds.top,n-a),p=o.applyContainerScroll(o.mouseDownData.boxTop-o.scrollBounds.top,o.mouseDownData.scrollTop-a),d=p-f;p=Math.min(p-d,p);var h=o.mouseDownData.boxLeft-l,m=o.mouseDownData.boxLeft-o.scrollBounds.left,v=o.applyContainerScroll(Math.min(m-h/o.props.scale,m/o.props.scale),-u);o.selectbox.setState({isBoxSelecting:!0,boxWidth:Math.abs(h),boxHeight:Math.abs(d),boxLeft:v,boxTop:p},function(){o.updateSelecting(),o.props.duringSelection([].concat(r(o.selectingItems))),o.mouseMoveStarted=!1})}},o.updateSelecting=function(){var e=o.selectbox.getRef();if(e){var t=(0,v.default)(e);o.selectItems(c({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}},o.selectItems=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.click,r=o.props,s=r.tolerance,i=r.enableDeselect,l=r.mixedDeselect;e.top+=o.scrollContainer.scrollTop,e.left+=o.scrollContainer.scrollLeft;var c=!0,a=!1,u=void 0;try{for(var f,p=o.registry.values()[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var d=f.value;o.processItem(d,s,e,n,i,l)}}catch(e){a=!0,u=e}finally{try{!c&&p.return&&p.return()}finally{if(a)throw u}}},o.clearSelection=function(){var e=!0,t=!1,n=void 0;try{for(var s,i=o.selectedItems.values()[Symbol.iterator]();!(e=(s=i.next()).done);e=!0){var l=s.value;l.setState({selected:!1}),o.selectedItems.delete(l)}}catch(e){t=!0,n=e}finally{try{!e&&i.return&&i.return()}finally{if(t)throw n}}o.setState({selectionMode:!1}),o.props.onSelectionFinish([].concat(r(o.selectedItems))),o.props.onSelectionClear()},o.selectAll=function(){o.updateWhiteListNodes();var e=!0,t=!1,n=void 0;try{for(var s,i=o.registry.values()[Symbol.iterator]();!(e=(s=i.next()).done);e=!0){var l=s.value;o.inIgnoreList(l.node)||l.state.selected||(l.setState({selected:!0}),o.selectedItems.add(l))}}catch(e){t=!0,n=e}finally{try{!e&&i.return&&i.return()}finally{if(t)throw n}}o.setState({selectionMode:!0}),o.props.onSelectionFinish([].concat(r(o.selectedItems)))},o.mouseDown=function(e){if(!o.mouseDownStarted){if(o.props.resetOnStart&&o.clearSelection(),o.mouseDownStarted=!0,o.mouseUpStarted=!1,e=o.desktopEventCoords(e),o.updateWhiteListNodes(),o.inIgnoreList(e.target))return void(o.mouseDownStarted=!1);if(!o.props.globalMouse&&!(0,h.default)(e.target,o.selectableGroup)){var t=(0,v.default)(o.selectableGroup);if(!(0,b.default)({top:t.top,left:t.left,bottom:t.offsetHeight,right:t.offsetWidth},{top:e.pageY,left:e.pageX,offsetWidth:0,offsetHeight:0}))return}o.updateRootBounds(),o.updateRegistry();var n=o.applyScale(e.pageY,e.pageX),r=n.scaledTop,s=n.scaledLeft;o.mouseDownData={boxLeft:s,boxTop:r,scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft,target:e.target},e.preventDefault(),document.addEventListener("mousemove",o.openSelectbox),document.addEventListener("touchmove",o.openSelectbox),document.addEventListener("mouseup",o.mouseUp),document.addEventListener("touchend",o.mouseUp)}},o.mouseUp=function(e){if(!o.mouseUpStarted&&(o.mouseUpStarted=!0,o.mouseDownStarted=!1,o.removeTempEventListeners(),o.mouseDownData)){var t=o.desktopEventCoords(e),n=o.applyScale(t.pageY,t.pageX),s=n.scaledTop,i=n.scaledLeft;if(!o.mouseMoved&&(0,h.default)(t.target,o.rootNode))o.handleClick(t,s,i);else{var l=!0,c=!1,a=void 0;try{for(var u,f=o.selectingItems.values()[Symbol.iterator]();!(l=(u=f.next()).done);l=!0){u.value.setState({selected:!0,selecting:!1})}}catch(e){c=!0,a=e}finally{try{!l&&f.return&&f.return()}finally{if(c)throw a}}o.selectedItems=new Set([].concat(r(o.selectedItems),r(o.selectingItems))),o.selectingItems.clear(),1===t.which&&o.mouseDownData.target===t.target&&o.preventEvent(t.target,"click"),o.selectbox.setState({isBoxSelecting:!1,boxWidth:0,boxHeight:0}),o.props.onSelectionFinish([].concat(r(o.selectedItems)))}o.toggleSelectionMode(),o.cleanUp(),o.mouseMoved=!1}},o.keyListener=function(e){o.ctrlPressed=e.ctrlKey||e.metaKey,o.ctrlPressed||27===e.keyCode&&o.clearSelection()},o.getGroupRef=function(e){return o.selectableGroup=e},o.getSelectboxRef=function(e){return o.selectbox=e},o.state={selectionMode:!1},o.mouseDownStarted=!1,o.mouseMoveStarted=!1,o.mouseUpStarted=!1,o.mouseDownData=null,o.registry=new Set,o.selectedItems=new Set,o.selectingItems=new Set,o.ignoreCheckCache=new Map,o.ignoreList=o.props.ignoreList.concat([".selectable-select-all",".selectable-deselect-all"]),o}return l(t,e),a(t,[{key:"getChildContext",value:function(){var e=this;return{selectable:{register:this.registerSelectable,unregister:this.unregisterSelectable,selectAll:this.selectAll,clearSelection:this.clearSelection,getScrolledContainer:function(){return e.scrollContainer}}}}},{key:"componentDidMount",value:function(){this.resizeInProgress=!1,this.rootNode=this.selectableGroup,this.scrollContainer=document.querySelector(this.props.scrollContainer)||this.rootNode,this.initialRootBounds=this.rootNode.getBoundingClientRect(),this.rootNode.addEventListener("mousedown",this.mouseDown),this.rootNode.addEventListener("touchstart",this.mouseDown),document.addEventListener("keydown",this.keyListener),document.addEventListener("keyup",this.keyListener),this.isChrome=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor),this.supportPageOffset=void 0!==window.pageXOffset,this.isCSS1Compat="CSS1Compat"===(document.compatMode||"")}},{key:"componentWillUnmount",value:function(){this.rootNode.removeEventListener("mousedown",this.mouseDown),this.rootNode.removeEventListener("touchstart",this.mouseDown),document.removeEventListener("keydown",this.keyListener),document.removeEventListener("keyup",this.keyListener),this.removeTempEventListeners()}},{key:"removeTempEventListeners",value:function(){document.removeEventListener("mousemove",this.openSelectbox),document.removeEventListener("touchmove",this.openSelectbox),document.removeEventListener("mouseup",this.mouseUp),document.removeEventListener("touchend",this.mouseUp)}},{key:"updateRootBounds",value:function(){this.scrollBounds&&(this.oldScrollBounds=this.scrollBounds),this.scrollBounds=this.scrollContainer.getBoundingClientRect(),this.maxScroll=this.scrollContainer.scrollHeight-this.scrollContainer.clientHeight}},{key:"toggleSelectionMode",value:function(){var e=this.selectedItems,t=this.state.selectionMode;e.size&&!t&&this.setState({selectionMode:!0}),!e.size&&t&&this.setState({selectionMode:!1})}},{key:"processItem",value:function(e,t,o,n,r,s){if(this.inIgnoreList(e.node))return null;var i=(0,b.default)(o,e.bounds,t),l=e.state,c=l.selecting,a=l.selected;if(n&&i)return a?this.selectedItems.delete(e):this.selectedItems.add(e),e.setState({selected:!a}),this.clickedItem=e;if(!n&&i){if(a&&r&&(!this.selectionStarted||s))return e.setState({selected:!1}),e.deselected=!0,this.deselectionStarted=!0,this.selectedItems.delete(e);var u=s?!e.deselected:!this.deselectionStarted;if(!c&&!a&&u)return e.setState({selecting:!0}),this.selectionStarted=!0,this.selectingItems.add(e)}return!n&&!i&&c&&this.selectingItems.has(e)?(e.setState({selecting:!1}),this.selectingItems.delete(e)):null}},{key:"inIgnoreList",value:function(e){if(void 0!==this.ignoreCheckCache.get(e))return this.ignoreCheckCache.get(e);var t=this.ignoreListNodes.some(function(t){return e===t||t.contains(e)});return this.ignoreCheckCache.set(e,t),t}},{key:"updateWhiteListNodes",value:function(){this.ignoreListNodes=[].concat(r(document.querySelectorAll(this.ignoreList.join(", "))))}},{key:"preventEvent",value:function(e,t){var o=function o(n){e.removeEventListener(t,o,!0),n.preventDefault(),n.stopPropagation()};e.addEventListener(t,o,!0)}},{key:"handleClick",value:function(e,t,o){var n=[].concat(r(e.target.classList||[])).indexOf(this.props.clickClassName)>-1;(this.props.allowClickWithoutSelected||this.selectedItems.size||n||this.ctrlPressed)&&(this.selectItems({top:t,left:o,offsetWidth:0,offsetHeight:0},{click:!0}),this.props.onSelectionFinish([].concat(r(this.selectedItems)),this.clickedItem),1===e.which&&this.preventEvent(e.target,"click"),2!==e.which&&3!==e.which||this.preventEvent(e.target,"contextmenu"))}},{key:"cleanUp",value:function(){if(this.deselectionStarted=!1,this.selectionStarted=!1,this.props.mixedDeselect){var e=!0,t=!1,o=void 0;try{for(var n,r=this.registry.values()[Symbol.iterator]();!(e=(n=r.next()).done);e=!0){n.value.deselected=!1}}catch(e){t=!0,o=e}finally{try{!e&&r.return&&r.return()}finally{if(t)throw o}}}}},{key:"desktopEventCoords",value:function(e){return void 0!==e.pageX&&void 0!==e.pageY||(void 0!==e.targetTouches[0]&&void 0!==e.targetTouches[0].pageX?(e.pageX=e.targetTouches[0].pageX,e.pageY=e.targetTouches[0].pageY):void 0!==e.changedTouches[0]&&void 0!==e.changedTouches[0].pageX&&(e.pageX=e.changedTouches[0].pageX,e.pageY=e.changedTouches[0].pageY)),e}},{key:"render",value:function(){return f.default.createElement(this.props.component,{ref:this.getGroupRef,style:this.props.style,className:this.props.className+" "+(this.state.selectionMode?this.props.selectionModeClass:"")},f.default.createElement(S.default,{ref:this.getSelectboxRef,fixedPosition:this.props.fixedPosition}),this.props.children)}}]),t}(u.Component);x.defaultProps={component:"div",tolerance:0,globalMouse:!1,ignoreList:[],scale:1,scrollSpeed:.25,minimumSpeedFactor:60,duringSelection:w,onSelectionFinish:w,onSelectionClear:w,allowClickWithoutSelected:!0,selectionModeClass:"in-selection-mode",resetOnStart:!1},x.childContextTypes={selectable:p.object},t.default=x},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(0),c=function(e){return e&&e.__esModule?e:{default:e}}(l),a=function(e){function t(){var e,o,s,i;n(this,t);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return o=s=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),s.state={top:0,left:0,boxWidth:0,boxHeight:0,isBoxSelecting:!1},s.getRef=function(){return s.selectbox},s.getSelectboxRef=function(e){return s.selectbox=e},i=o,r(s,i)}return s(t,e),i(t,[{key:"render",value:function(){var e={left:this.state.boxLeft,top:this.state.boxTop,width:this.state.boxWidth,height:this.state.boxHeight,zIndex:9e3,position:this.props.fixedPosition?"fixed":"absolute",cursor:"default"};return c.default.createElement("div",null,this.state.isBoxSelecting&&c.default.createElement("div",{ref:this.getSelectboxRef,style:e,className:this.props.className}))}}]),t}(l.Component);a.defaultProps={className:"selectable-selectbox"},t.default=a},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(2),r=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function(e,t,o,n,r,s,i,l,c){return void 0===c&&(c=0),!(e+s-c<o||e+c>o+l||t+r-c<n||t+c>n+i)};t.default=function(e,t,o){var n=e instanceof HTMLElement?(0,r.default)(e):e,i=t instanceof HTMLElement?(0,r.default)(t):t;return s(n.top,n.left,i.top,i.left,n.offsetWidth,n.offsetHeight,i.offsetWidth,i.offsetHeight,o)}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.DeselectAll=t.SelectAll=t.createSelectable=t.SelectableGroup=void 0;var r=o(6),s=n(r),i=o(3),l=n(i),c=o(5),a=n(c),u=o(4),f=n(u);t.SelectableGroup=s.default,t.createSelectable=l.default,t.SelectAll=a.default,t.DeselectAll=f.default},function(e,t,o){"use strict";function n(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,o){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,o){"use strict";function n(e,t,o,n,s,i,l,c){if(r(t),!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[o,n,s,i,l,c],f=0;a=new Error(t.replace(/%s/g,function(){return u[f++]})),a.name="Invariant Violation"}throw a.framesToPop=1,a}}var r=function(e){};e.exports=n},function(e,t,o){"use strict";var n=o(11),r=o(12),s=o(14);e.exports=function(){function e(e,t,o,n,i,l){l!==s&&r(!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 o={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};return o.checkPropTypes=n,o.PropTypes=o,o}},function(e,t,o){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); | ||
!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["React-Selectable-Fast"]=t(require("react")):e["React-Selectable-Fast"]=t(e.React)}(this,function(e){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var o={};return t.m=e,t.c=o,t.i=function(e){return e},t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(t,o){t.exports=e},function(e,t,o){e.exports=o(13)()},function(e,t,o){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{scrollTop:0,scrollLeft:0},o=t.scrollTop,n=t.scrollLeft,r=e.getBoundingClientRect();return{top:r.top+document.body.scrollTop+o,left:r.left+document.body.scrollLeft+n,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,computedWidth:r.width,computedHeight:r.height}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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 i(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)}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},c=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),a=o(0),u=n(a),f=o(1),p=o(2),d=n(p),h=function(e){var t,o;return o=t=function(t){function o(){var e,t,n,i;r(this,o);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return t=n=s(this,(e=o.__proto__||Object.getPrototypeOf(o)).call.apply(e,[this].concat(c))),n.state={selected:n.props.selected,selecting:!1},n.registerSelectable=function(e){n.bounds=(0,d.default)(n.node,e),n.context.selectable.register(n)},n.selectableRef=function(e){return n.node=e},i=t,s(n,i)}return i(o,t),c(o,[{key:"componentDidMount",value:function(){this.registerSelectable()}},{key:"componentWillUnmount",value:function(){this.context.selectable.unregister(this)}},{key:"render",value:function(){return u.default.createElement(e,l({},this.props,{selected:this.state.selected,selecting:this.state.selecting,selectableRef:this.selectableRef}))}}]),o}(a.Component),t.defaultProps={selected:!1},t.contextTypes={selectable:f.object},o};t.default=h},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(0),c=function(e){return e&&e.__esModule?e:{default:e}}(l),a=o(1),u=function(e){function t(){var e,o,s,i;n(this,t);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return o=s=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),s.getRootRef=function(e){return s.root=e},i=o,r(s,i)}return s(t,e),i(t,[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){return c.default.createElement(this.props.component,{ref:this.getRootRef,onClick:this.context.selectable.clearSelection,className:"selectable-deselect-all "+this.props.className},this.props.children)}}]),t}(l.Component);u.defaultProps={component:"div"},u.contextTypes={selectable:a.object},t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(0),c=function(e){return e&&e.__esModule?e:{default:e}}(l),a=o(1),u=function(e){function t(){var e,o,s,i;n(this,t);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return o=s=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),s.getRootRef=function(e){return s.root=e},i=o,r(s,i)}return s(t,e),i(t,[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){return c.default.createElement(this.props.component,{ref:this.getRootRef,className:"selectable-select-all "+this.props.className,onClick:this.context.selectable.selectAll},this.props.children)}}]),t}(l.Component);u.defaultProps={component:"div"},u.contextTypes={selectable:a.object},t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 l(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)}Object.defineProperty(t,"__esModule",{value:!0});var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},a=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),u=o(0),f=n(u),p=o(1),d=o(10),h=n(d),m=o(2),v=n(m),y=o(8),g=n(y),b=o(7),S=n(b),w=function(){},x=function(e){function t(e){s(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.setScollTop=function(e){var t=o.scrollContainer.scrollTop;o.checkScrollUp(e,t),o.checkScrollDown(e,t)},o.checkScrollUp=function(e,t){var n=o.props,r=n.minimumSpeedFactor,s=n.scrollSpeed,i=o.scrollBounds.top-e.clientY;if(i>0||e.clientY<0){var l=t-Math.max(i,r)*s;o.scrollContainer.scrollTop=l}},o.checkScrollDown=function(e,t){var n=o.props,r=n.minimumSpeedFactor,s=n.scrollSpeed,i=e.clientY-o.scrollBounds.bottom;if(i>0||e.clientY>window.innerHeight){var l=t+Math.max(i,r)*s;o.scrollContainer.scrollTop=Math.min(l,o.maxScroll)}},o.updateRegistry=function(){var e={scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft},t=!0,n=!1,r=void 0;try{for(var s,i=o.registry.values()[Symbol.iterator]();!(t=(s=i.next()).done);t=!0){s.value.registerSelectable(e)}}catch(e){n=!0,r=e}finally{try{!t&&i.return&&i.return()}finally{if(n)throw r}}},o.registerSelectable=function(e){o.registry.add(e),e.props.selected&&o.selectedItems.add(e)},o.unregisterSelectable=function(e){o.registry.delete(e)},o.applyContainerScroll=function(e,t){return e+t},o.getWindowScroll=function(){return o.supportPageOffset?{windowTopScroll:window.pageYOffset,windowLeftScroll:window.pageXOffset}:{windowTopScroll:o.isCSS1Compat?document.documentElement.scrollTop:document.body.scrollTop,windowLeftScroll:o.isCSS1Compat?document.documentElement.scrollLeft:document.body.scrollLeft}},o.openSelectbox=function(e){var t=o.desktopEventCoords(e);if(o.setScollTop(t),!o.mouseMoveStarted){o.mouseMoveStarted=!0,o.mouseMoved=!0;var n=o.scrollContainer.scrollTop,s=t.pageY,i=t.pageX,l=o.getWindowScroll(),c=l.windowTopScroll,a=l.windowLeftScroll,u=o.applyContainerScroll(s-o.scrollBounds.top,n-c),f=o.applyContainerScroll(o.mouseDownData.boxTop-o.scrollBounds.top,o.mouseDownData.scrollTop-c),p=f-u;f=Math.min(f-p,f);var d=o.mouseDownData.boxLeft-i,h=o.mouseDownData.boxLeft-o.scrollBounds.left,m=o.applyContainerScroll(Math.min(h-d,h),-a);o.selectbox.setState({isBoxSelecting:!0,boxWidth:Math.abs(d),boxHeight:Math.abs(p),boxLeft:m,boxTop:f},function(){o.updateSelecting(),o.props.duringSelection([].concat(r(o.selectingItems))),o.mouseMoveStarted=!1})}},o.updateSelecting=function(){var e=o.selectbox.getRef();if(e){var t=(0,v.default)(e);o.selectItems(c({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}},o.selectItems=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.click,r=o.props,s=r.tolerance,i=r.enableDeselect,l=r.mixedDeselect;e.top+=o.scrollContainer.scrollTop,e.left+=o.scrollContainer.scrollLeft;var c=!0,a=!1,u=void 0;try{for(var f,p=o.registry.values()[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var d=f.value;o.processItem(d,s,e,n,i,l)}}catch(e){a=!0,u=e}finally{try{!c&&p.return&&p.return()}finally{if(a)throw u}}},o.clearSelection=function(){var e=!0,t=!1,n=void 0;try{for(var s,i=o.selectedItems.values()[Symbol.iterator]();!(e=(s=i.next()).done);e=!0){var l=s.value;l.setState({selected:!1}),o.selectedItems.delete(l)}}catch(e){t=!0,n=e}finally{try{!e&&i.return&&i.return()}finally{if(t)throw n}}o.setState({selectionMode:!1}),o.props.onSelectionFinish([].concat(r(o.selectedItems))),o.props.onSelectionClear()},o.selectAll=function(){o.updateWhiteListNodes();var e=!0,t=!1,n=void 0;try{for(var s,i=o.registry.values()[Symbol.iterator]();!(e=(s=i.next()).done);e=!0){var l=s.value;o.inIgnoreList(l.node)||l.state.selected||(l.setState({selected:!0}),o.selectedItems.add(l))}}catch(e){t=!0,n=e}finally{try{!e&&i.return&&i.return()}finally{if(t)throw n}}o.setState({selectionMode:!0}),o.props.onSelectionFinish([].concat(r(o.selectedItems)))},o.mouseDown=function(e){if(!o.mouseDownStarted&&!o.props.disabled){if(o.props.resetOnStart&&o.clearSelection(),o.mouseDownStarted=!0,o.mouseUpStarted=!1,e=o.desktopEventCoords(e),o.updateWhiteListNodes(),o.inIgnoreList(e.target))return void(o.mouseDownStarted=!1);if(!o.props.globalMouse&&!(0,h.default)(e.target,o.selectableGroup)){var t=(0,v.default)(o.selectableGroup);if(!(0,g.default)({top:t.top,left:t.left,bottom:t.offsetHeight,right:t.offsetWidth},{top:e.pageY,left:e.pageX,offsetWidth:0,offsetHeight:0}))return}o.updateRootBounds(),o.updateRegistry(),o.mouseDownData={boxLeft:e.pageX,boxTop:e.pageY,scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft,target:e.target},e.preventDefault(),document.addEventListener("mousemove",o.openSelectbox),document.addEventListener("touchmove",o.openSelectbox),document.addEventListener("mouseup",o.mouseUp),document.addEventListener("touchend",o.mouseUp)}},o.mouseUp=function(e){if(!o.mouseUpStarted&&(o.mouseUpStarted=!0,o.mouseDownStarted=!1,o.removeTempEventListeners(),o.mouseDownData)){var t=o.desktopEventCoords(e),n=t.pageY,s=t.pageX;if(!o.mouseMoved&&(0,h.default)(t.target,o.rootNode))o.handleClick(t,n,s);else{var i=!0,l=!1,c=void 0;try{for(var a,u=o.selectingItems.values()[Symbol.iterator]();!(i=(a=u.next()).done);i=!0){a.value.setState({selected:!0,selecting:!1})}}catch(e){l=!0,c=e}finally{try{!i&&u.return&&u.return()}finally{if(l)throw c}}o.selectedItems=new Set([].concat(r(o.selectedItems),r(o.selectingItems))),o.selectingItems.clear(),1===t.which&&o.mouseDownData.target===t.target&&o.preventEvent(t.target,"click"),o.selectbox.setState({isBoxSelecting:!1,boxWidth:0,boxHeight:0}),o.props.onSelectionFinish([].concat(r(o.selectedItems)))}o.toggleSelectionMode(),o.cleanUp(),o.mouseMoved=!1}},o.keyListener=function(e){o.ctrlPressed=e.ctrlKey||e.metaKey,o.ctrlPressed||27===e.keyCode&&o.clearSelection()},o.getGroupRef=function(e){return o.selectableGroup=e},o.getSelectboxRef=function(e){return o.selectbox=e},o.state={selectionMode:!1},o.mouseDownStarted=!1,o.mouseMoveStarted=!1,o.mouseUpStarted=!1,o.mouseDownData=null,o.registry=new Set,o.selectedItems=new Set,o.selectingItems=new Set,o.ignoreCheckCache=new Map,o.ignoreList=o.props.ignoreList.concat([".selectable-select-all",".selectable-deselect-all"]),o}return l(t,e),a(t,[{key:"getChildContext",value:function(){var e=this;return{selectable:{register:this.registerSelectable,unregister:this.unregisterSelectable,selectAll:this.selectAll,clearSelection:this.clearSelection,getScrolledContainer:function(){return e.scrollContainer}}}}},{key:"componentDidMount",value:function(){this.resizeInProgress=!1,this.rootNode=this.selectableGroup,this.scrollContainer=document.querySelector(this.props.scrollContainer)||this.rootNode,this.initialRootBounds=this.rootNode.getBoundingClientRect(),this.rootNode.addEventListener("mousedown",this.mouseDown),this.rootNode.addEventListener("touchstart",this.mouseDown),document.addEventListener("keydown",this.keyListener),document.addEventListener("keyup",this.keyListener),this.isChrome=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor),this.supportPageOffset=void 0!==window.pageXOffset,this.isCSS1Compat="CSS1Compat"===(document.compatMode||"")}},{key:"componentWillUnmount",value:function(){this.rootNode.removeEventListener("mousedown",this.mouseDown),this.rootNode.removeEventListener("touchstart",this.mouseDown),document.removeEventListener("keydown",this.keyListener),document.removeEventListener("keyup",this.keyListener),this.removeTempEventListeners()}},{key:"removeTempEventListeners",value:function(){document.removeEventListener("mousemove",this.openSelectbox),document.removeEventListener("touchmove",this.openSelectbox),document.removeEventListener("mouseup",this.mouseUp),document.removeEventListener("touchend",this.mouseUp)}},{key:"updateRootBounds",value:function(){this.scrollBounds&&(this.oldScrollBounds=this.scrollBounds),this.scrollBounds=this.scrollContainer.getBoundingClientRect(),this.maxScroll=this.scrollContainer.scrollHeight-this.scrollContainer.clientHeight}},{key:"toggleSelectionMode",value:function(){var e=this.selectedItems,t=this.state.selectionMode;e.size&&!t&&this.setState({selectionMode:!0}),!e.size&&t&&this.setState({selectionMode:!1})}},{key:"processItem",value:function(e,t,o,n,r,s){if(this.inIgnoreList(e.node))return null;var i=(0,g.default)(o,e.bounds,t,this.props.delta),l=e.state,c=l.selecting,a=l.selected;if(n&&i)return a?this.selectedItems.delete(e):this.selectedItems.add(e),e.setState({selected:!a}),this.clickedItem=e;if(!n&&i){if(a&&r&&(!this.selectionStarted||s))return e.setState({selected:!1}),e.deselected=!0,this.deselectionStarted=!0,this.selectedItems.delete(e);var u=s?!e.deselected:!this.deselectionStarted;if(!c&&!a&&u)return e.setState({selecting:!0}),this.selectionStarted=!0,this.selectingItems.add(e)}return!n&&!i&&c&&this.selectingItems.has(e)?(e.setState({selecting:!1}),this.selectingItems.delete(e)):null}},{key:"inIgnoreList",value:function(e){if(void 0!==this.ignoreCheckCache.get(e))return this.ignoreCheckCache.get(e);var t=this.ignoreListNodes.some(function(t){return e===t||t.contains(e)});return this.ignoreCheckCache.set(e,t),t}},{key:"updateWhiteListNodes",value:function(){this.ignoreListNodes=[].concat(r(document.querySelectorAll(this.ignoreList.join(", "))))}},{key:"preventEvent",value:function(e,t){var o=function o(n){e.removeEventListener(t,o,!0),n.preventDefault(),n.stopPropagation()};e.addEventListener(t,o,!0)}},{key:"handleClick",value:function(e,t,o){var n=[].concat(r(e.target.classList||[])).indexOf(this.props.clickClassName)>-1;(this.props.allowClickWithoutSelected||this.selectedItems.size||n||this.ctrlPressed)&&(this.selectItems({top:t,left:o,offsetWidth:0,offsetHeight:0},{click:!0}),this.props.onSelectionFinish([].concat(r(this.selectedItems)),this.clickedItem),1===e.which&&this.preventEvent(e.target,"click"),2!==e.which&&3!==e.which||this.preventEvent(e.target,"contextmenu"))}},{key:"cleanUp",value:function(){if(this.deselectionStarted=!1,this.selectionStarted=!1,this.props.mixedDeselect){var e=!0,t=!1,o=void 0;try{for(var n,r=this.registry.values()[Symbol.iterator]();!(e=(n=r.next()).done);e=!0){n.value.deselected=!1}}catch(e){t=!0,o=e}finally{try{!e&&r.return&&r.return()}finally{if(t)throw o}}}}},{key:"desktopEventCoords",value:function(e){return void 0!==e.pageX&&void 0!==e.pageY||(void 0!==e.targetTouches[0]&&void 0!==e.targetTouches[0].pageX?(e.pageX=e.targetTouches[0].pageX,e.pageY=e.targetTouches[0].pageY):void 0!==e.changedTouches[0]&&void 0!==e.changedTouches[0].pageX&&(e.pageX=e.changedTouches[0].pageX,e.pageY=e.changedTouches[0].pageY)),e}},{key:"render",value:function(){return f.default.createElement(this.props.component,{ref:this.getGroupRef,style:this.props.style,className:this.props.className+" "+(this.state.selectionMode?this.props.selectionModeClass:"")},f.default.createElement(S.default,{ref:this.getSelectboxRef,fixedPosition:this.props.fixedPosition}),this.props.children)}}]),t}(u.Component);x.defaultProps={component:"div",tolerance:0,globalMouse:!1,ignoreList:[],scrollSpeed:.25,minimumSpeedFactor:60,duringSelection:w,onSelectionFinish:w,onSelectionClear:w,allowClickWithoutSelected:!0,selectionModeClass:"in-selection-mode",resetOnStart:!1,disabled:!1,delta:1},x.childContextTypes={selectable:p.object},t.default=x},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 s(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)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(0),c=function(e){return e&&e.__esModule?e:{default:e}}(l),a=function(e){function t(){var e,o,s,i;n(this,t);for(var l=arguments.length,c=Array(l),a=0;a<l;a++)c[a]=arguments[a];return o=s=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),s.state={top:0,left:0,boxWidth:0,boxHeight:0,isBoxSelecting:!1},s.getRef=function(){return s.selectbox},s.getSelectboxRef=function(e){return s.selectbox=e},i=o,r(s,i)}return s(t,e),i(t,[{key:"render",value:function(){var e={left:this.state.boxLeft,top:this.state.boxTop,width:this.state.boxWidth,height:this.state.boxHeight,zIndex:9e3,position:this.props.fixedPosition?"fixed":"absolute",cursor:"default"};return c.default.createElement("div",null,this.state.isBoxSelecting&&c.default.createElement("div",{ref:this.getSelectboxRef,style:e,className:this.props.className}))}}]),t}(l.Component);a.defaultProps={className:"selectable-selectbox"},t.default=a},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(2),r=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function(e,t,o,n,r,s,i,l,c){return void 0===c&&(c=0),!(e+s-c<o||e+c>o+l||t+r-c<n||t+c>n+i)};t.default=function(e,t,o,n){void 0===n&&(n=1);var i=e instanceof HTMLElement?(0,r.default)(e):e,l=t instanceof HTMLElement?(0,r.default)(t):t;return 1===n?s(i.top,i.left,l.top,l.left,i.offsetWidth,i.offsetHeight,l.offsetWidth,l.offsetHeight,o):s(i.top,i.left,l.top,l.left,i.computedWidth,i.computedHeight,l.computedWidth,l.computedHeight,o)}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.DeselectAll=t.SelectAll=t.createSelectable=t.SelectableGroup=void 0;var r=o(6),s=n(r),i=o(3),l=n(i),c=o(5),a=n(c),u=o(4),f=n(u);t.SelectableGroup=s.default,t.createSelectable=l.default,t.SelectAll=a.default,t.DeselectAll=f.default},function(e,t,o){"use strict";function n(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,o){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,o){"use strict";function n(e,t,o,n,s,i,l,c){if(r(t),!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[o,n,s,i,l,c],f=0;a=new Error(t.replace(/%s/g,function(){return u[f++]})),a.name="Invariant Violation"}throw a.framesToPop=1,a}}var r=function(e){};e.exports=n},function(e,t,o){"use strict";var n=o(11),r=o(12),s=o(14);e.exports=function(){function e(e,t,o,n,i,l){l!==s&&r(!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 o={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};return o.checkPropTypes=n,o.PropTypes=o,o}},function(e,t,o){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); | ||
//# sourceMappingURL=react-selectable-fast.js.map |
@@ -49,7 +49,17 @@ 'use strict'; | ||
exports.default = function (a, b, tolerance) { | ||
exports.default = function (a, b, tolerance, delta) { | ||
if (typeof delta === 'undefined') { | ||
delta = 1; | ||
} | ||
var aObj = a instanceof HTMLElement ? (0, _getBoundsForNode2.default)(a) : a; | ||
var bObj = b instanceof HTMLElement ? (0, _getBoundsForNode2.default)(b) : b; | ||
return coordsCollide(aObj.top, aObj.left, bObj.top, bObj.left, aObj.offsetWidth, aObj.offsetHeight, bObj.offsetWidth, bObj.offsetHeight, tolerance); | ||
if (delta === 1) { | ||
return coordsCollide(aObj.top, aObj.left, bObj.top, bObj.left, aObj.offsetWidth, aObj.offsetHeight, bObj.offsetWidth, bObj.offsetHeight, tolerance); | ||
} | ||
// We have a delta and we need to compute the new values | ||
return coordsCollide(aObj.top, aObj.left, bObj.top, bObj.left, aObj.computedWidth, aObj.computedHeight, bObj.computedWidth, bObj.computedHeight, tolerance); | ||
}; |
@@ -23,4 +23,6 @@ "use strict"; | ||
offsetWidth: node.offsetWidth, | ||
offsetHeight: node.offsetHeight | ||
offsetHeight: node.offsetHeight, | ||
computedWidth: rect.width, | ||
computedHeight: rect.height | ||
}; | ||
} |
@@ -53,9 +53,2 @@ 'use strict'; | ||
_this.applyScale = function (top, left) { | ||
return { | ||
scaledTop: top / _this.props.scale, | ||
scaledLeft: left / _this.props.scale | ||
}; | ||
}; | ||
_this.setScollTop = function (e) { | ||
@@ -137,3 +130,3 @@ var scrollTop = _this.scrollContainer.scrollTop; | ||
_this.applyContainerScroll = function (value, scroll) { | ||
return value + scroll / _this.props.scale; | ||
return value + scroll; | ||
}; | ||
@@ -164,7 +157,5 @@ | ||
var scrollTop = _this.scrollContainer.scrollTop; | ||
var eventTop = e.pageY; | ||
var eventLeft = e.pageX; | ||
var _this$applyScale = _this.applyScale(e.pageY, e.pageX), | ||
scaledTop = _this$applyScale.scaledTop, | ||
scaledLeft = _this$applyScale.scaledLeft; | ||
var _this$getWindowScroll = _this.getWindowScroll(), | ||
@@ -174,3 +165,3 @@ windowTopScroll = _this$getWindowScroll.windowTopScroll, | ||
var top = _this.applyContainerScroll(scaledTop - _this.scrollBounds.top, scrollTop - windowTopScroll); | ||
var top = _this.applyContainerScroll(eventTop - _this.scrollBounds.top, scrollTop - windowTopScroll); | ||
@@ -182,6 +173,6 @@ var boxTop = _this.applyContainerScroll(_this.mouseDownData.boxTop - _this.scrollBounds.top, _this.mouseDownData.scrollTop - windowTopScroll); | ||
var bowWidth = _this.mouseDownData.boxLeft - scaledLeft; | ||
var bowWidth = _this.mouseDownData.boxLeft - eventLeft; | ||
var leftContainerRelative = _this.mouseDownData.boxLeft - _this.scrollBounds.left; | ||
var boxLeft = _this.applyContainerScroll(Math.min(leftContainerRelative - bowWidth / _this.props.scale, leftContainerRelative / _this.props.scale), -windowLeftScroll); | ||
var boxLeft = _this.applyContainerScroll(Math.min(leftContainerRelative - bowWidth, leftContainerRelative), -windowLeftScroll); | ||
@@ -317,3 +308,3 @@ _this.selectbox.setState({ | ||
_this.mouseDown = function (e) { | ||
if (_this.mouseDownStarted) return; | ||
if (_this.mouseDownStarted || _this.props.disabled) return; | ||
if (_this.props.resetOnStart) { | ||
@@ -351,9 +342,5 @@ _this.clearSelection(); | ||
var _this$applyScale2 = _this.applyScale(e.pageY, e.pageX), | ||
scaledTop = _this$applyScale2.scaledTop, | ||
scaledLeft = _this$applyScale2.scaledLeft; | ||
_this.mouseDownData = { | ||
boxLeft: scaledLeft, | ||
boxTop: scaledTop, | ||
boxLeft: e.pageX, | ||
boxTop: e.pageY, | ||
scrollTop: _this.scrollContainer.scrollTop, | ||
@@ -383,8 +370,7 @@ scrollLeft: _this.scrollContainer.scrollLeft, | ||
var _this$applyScale3 = _this.applyScale(e.pageY, e.pageX), | ||
scaledTop = _this$applyScale3.scaledTop, | ||
scaledLeft = _this$applyScale3.scaledLeft; | ||
var eventTop = e.pageY; | ||
var eventLeft = e.pageX; | ||
if (!_this.mouseMoved && (0, _nodeInRoot2.default)(e.target, _this.rootNode)) { | ||
_this.handleClick(e, scaledTop, scaledLeft); | ||
_this.handleClick(e, eventTop, eventLeft); | ||
} else { | ||
@@ -550,4 +536,3 @@ var _iteratorNormalCompletion5 = true; | ||
} | ||
var isCollided = (0, _doObjectsCollide2.default)(selectboxBounds, item.bounds, tolerance); | ||
var isCollided = (0, _doObjectsCollide2.default)(selectboxBounds, item.bounds, tolerance, this.props.delta); | ||
var _item$state = item.state, | ||
@@ -716,3 +701,2 @@ selecting = _item$state.selecting, | ||
SelectableGroup.propTypes = { | ||
scale: _propTypes.number, | ||
globalMouse: _propTypes.bool, | ||
@@ -729,2 +713,4 @@ ignoreList: _propTypes.array, | ||
resetOnStart: _propTypes.bool, | ||
disabled: _propTypes.bool, | ||
delta: _propTypes.number, | ||
/** | ||
@@ -770,3 +756,2 @@ * Scroll container selector | ||
ignoreList: [], | ||
scale: 1, | ||
scrollSpeed: 0.25, | ||
@@ -779,3 +764,5 @@ minimumSpeedFactor: 60, | ||
selectionModeClass: 'in-selection-mode', | ||
resetOnStart: false | ||
resetOnStart: false, | ||
disabled: false, | ||
delta: 1 | ||
}; | ||
@@ -782,0 +769,0 @@ SelectableGroup.childContextTypes = { |
{ | ||
"name": "react-selectable-fast", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Enable other React components to be selectable by drawing a box with your mouse/touch", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -130,1 +130,3 @@ # React-selectable-fast ![npm](https://img.shields.io/npm/v/react-selectable-fast.svg) ![license](https://img.shields.io/npm/l/react-selectable-fast.svg) ![github-issues](https://img.shields.io/github/issues/valerybugakov/react-selectable-fast.svg) | ||
* `resetOnStart` (Boolean) Unselect all items when you start a new drag. Default value is `false`. | ||
* `disabled` (Boolean) Enable or disable the selectable draggable, useful if you want to enable drag of sub-items. Default value is `false`. | ||
* `delta` (Number) Value of the CSS transform property scaled list, useful if your list of items in `<SelectableGroup />` is wrapped by a scale css transform property. Default value is `1`. |
Sorry, the diff of this file is not supported yet
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
198819
132