Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-selectable-fast

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-selectable-fast - npm Package Compare versions

Comparing version 2.3.1 to 3.0.0

lib/Context.d.ts

2

dist/react-selectable-fast.js

@@ -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)}(window,function(e){return function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=1)}([function(t,o){t.exports=e},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n);function i(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function l(){return{documentScrollTop:Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop),documentScrollLeft:Math.max(window.pageXOffset,document.documentElement.scrollLeft,document.body.scrollLeft)}}function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{scrollTop:0,scrollLeft:0},o=t.scrollTop,n=t.scrollLeft,r=l(),i=r.documentScrollTop,c=r.documentScrollLeft,s=e.getBoundingClientRect();return{top:s.top+i+o,left:s.left+c+n,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,computedWidth:s.width,computedHeight:s.height}}var s=function(e,t,o,n,r,i,l,c,s){return void 0===s&&(s=0),!(e+i-s<o||e+s>o+c||t+r-s<n||t+s>n+l)},a=function(e,t,o,n){void 0===n&&(n=1);var r=e instanceof HTMLElement?c(e):e,i=t instanceof HTMLElement?c(t):t;return 1===n?s(r.top,r.left,i.top,i.left,r.offsetWidth,r.offsetHeight,i.offsetWidth,i.offsetHeight,o):s(r.top,r.left,i.top,i.left,r.computedWidth,r.computedHeight,i.computedWidth,i.computedHeight,o)};function u(e){return(u="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 f(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)}}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var m=function(e){function t(){var e,o,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return n=this,r=(e=p(t)).call.apply(e,[this].concat(l)),o=!r||"object"!==u(r)&&"function"!=typeof r?d(n):r,y(d(o),"state",{boxTop:0,boxLeft:0,boxWidth:0,boxHeight:0,isBoxSelecting:!1}),y(d(o),"getRef",function(){return o.selectbox}),y(d(o),"getSelectboxRef",function(e){return o.selectbox=e}),o}var o,i,l;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&&h(e,t)}(t,n["Component"]),o=t,(i=[{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 r.a.createElement("div",null,this.state.isBoxSelecting&&r.a.createElement("div",{ref:this.getSelectboxRef,style:e,className:this.props.className}))}}])&&f(o.prototype,i),l&&f(o,l),t}();y(m,"defaultProps",{className:"selectable-selectbox"});var b=m,v=r.a.createContext({selectable:"omg"});function g(e){return(g="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 S(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)}return o}function w(e){return function(e){if(Array.isArray(e)){for(var t=0,o=new Array(e.length);t<e.length;t++)o[t]=e[t];return o}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function O(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)}}function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var L=function(){},P=function(e){function t(e){var o,n,r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=this,r=x(t).call(this,e),o=!r||"object"!==g(r)&&"function"!=typeof r?j(n):r,k(j(o),"setScollTop",function(e){var t=o.scrollContainer.scrollTop;o.checkScrollTop(e,t),o.checkScrollBottom(e,t)}),k(j(o),"checkScrollTop",function(e,t){var n=o.props,r=n.minimumSpeedFactor,i=n.scrollSpeed,l=o.scrollBounds.top-e.clientY;if(l>0||e.clientY<0){var c=t-Math.max(l,r)*i;o.scrollContainer.scrollTop=c}}),k(j(o),"checkScrollBottom",function(e,t){var n=o.props,r=n.minimumSpeedFactor,i=n.scrollSpeed,l=e.clientY-o.scrollBounds.bottom;if(l>0||e.clientY>window.innerHeight){var c=t+Math.max(l,r)*i;o.scrollContainer.scrollTop=Math.min(c,o.maxScroll)}}),k(j(o),"updateRegistry",function(){var e={scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft},t=!0,n=!1,r=void 0;try{for(var i,l=o.registry.values()[Symbol.iterator]();!(t=(i=l.next()).done);t=!0){i.value.registerSelectable(e)}}catch(e){n=!0,r=e}finally{try{t||null==l.return||l.return()}finally{if(n)throw r}}}),k(j(o),"registerSelectable",function(e){o.registry.add(e),e.state.selected&&o.selectedItems.add(e)}),k(j(o),"unregisterSelectable",function(e){o.registry.delete(e),o.selectedItems.delete(e),o.selectingItems.delete(e)}),k(j(o),"applyContainerScroll",function(e,t){return e+t}),k(j(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,r=n.scrollTop,i=n.scrollLeft,c=t.pageY,s=t.pageX,a=l(),u=a.documentScrollTop,f=a.documentScrollLeft,p=o.applyContainerScroll(c-o.scrollBounds.top,r-u),d=o.applyContainerScroll(o.mouseDownData.boxTop-o.scrollBounds.top,o.mouseDownData.scrollTop-u),h=d-p;d=Math.min(d-h,d);var y=o.applyContainerScroll(s-o.scrollBounds.left,i-f),m=o.applyContainerScroll(o.mouseDownData.boxLeft-o.scrollBounds.left,o.mouseDownData.scrollLeft-f),b=m-y;m=Math.min(m-b,m),o.selectbox.setState({isBoxSelecting:!0,boxWidth:Math.abs(b),boxHeight:Math.abs(h),boxLeft:m,boxTop:d},function(){o.updateSelecting(),o.props.duringSelection(w(o.selectingItems)),o.mouseMoveStarted=!1})}}),k(j(o),"updateSelecting",function(){var e=o.selectbox.getRef();if(e){var t=c(e);o.selectItems(function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?S(o,!0).forEach(function(t){k(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):S(o).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}}),k(j(o),"selectItems",function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).click,n=o.props,r=n.tolerance,i=n.enableDeselect,l=n.mixedDeselect;e.top+=o.scrollContainer.scrollTop,e.left+=o.scrollContainer.scrollLeft;var c=!0,s=!1,a=void 0;try{for(var u,f=o.registry.values()[Symbol.iterator]();!(c=(u=f.next()).done);c=!0){var p=u.value;o.processItem(p,r,e,t,i,l)}}catch(e){s=!0,a=e}finally{try{c||null==f.return||f.return()}finally{if(s)throw a}}}),k(j(o),"clearSelection",function(){var e=!0,t=!1,n=void 0;try{for(var r,i=o.selectedItems.values()[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var l=r.value;l.setState({selected:!1}),o.selectedItems.delete(l)}}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}o.setState({selectionMode:!1}),o.props.onSelectionFinish(w(o.selectedItems)),o.props.onSelectionClear()}),k(j(o),"selectAll",function(){o.updateWhiteListNodes();var e=!0,t=!1,n=void 0;try{for(var r,i=o.registry.values()[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var l=r.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||null==i.return||i.return()}finally{if(t)throw n}}o.setState({selectionMode:!0}),o.props.onSelectionFinish(w(o.selectedItems))}),k(j(o),"mouseDown",function(e){if(!o.mouseDownStarted&&!o.props.disabled&&o.detectLeftButton(e))if(o.updateWhiteListNodes(),o.inIgnoreList(e.target))o.mouseDownStarted=!1;else{if(o.props.resetOnStart&&o.clearSelection(),o.mouseDownStarted=!0,o.mouseUpStarted=!1,e=o.desktopEventCoords(e),!o.props.globalMouse&&!i(e.target,o.selectableGroup)){var t=c(o.selectableGroup);if(!a({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)}}),k(j(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,r=t.pageX;if(!o.mouseMoved&&i(t.target,o.rootNode))o.handleClick(t,n,r);else{var l=!0,c=!1,s=void 0;try{for(var a,u=o.selectingItems.values()[Symbol.iterator]();!(l=(a=u.next()).done);l=!0){a.value.setState({selected:!0,selecting:!1})}}catch(e){c=!0,s=e}finally{try{l||null==u.return||u.return()}finally{if(c)throw s}}o.selectedItems=new Set(w(o.selectedItems).concat(w(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(w(o.selectedItems))}o.toggleSelectionMode(),o.cleanUp(),o.mouseMoved=!1}}),k(j(o),"keyListener",function(e){e.ctrlKey||e.metaKey||27===e.keyCode&&o.clearSelection()}),k(j(o),"getGroupRef",function(e){return o.selectableGroup=e}),k(j(o),"getSelectboxRef",function(e){return o.selectbox=e}),k(j(o),"defaultContainerStyle",{position:"relative"}),k(j(o),"contextValue",{selectable:{register:o.registerSelectable,unregister:o.unregisterSelectable,selectAll:o.selectAll,clearSelection:o.clearSelection,getScrolledContainer:function(){return o.scrollContainer}}}),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}var o,s,u;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&&E(e,t)}(t,n["Component"]),o=t,(s=[{key:"componentDidMount",value:function(){this.rootNode=this.selectableGroup,this.scrollContainer=document.querySelector(this.props.scrollContainer)||this.rootNode,this.rootNode.addEventListener("mousedown",this.mouseDown),this.rootNode.addEventListener("touchstart",this.mouseDown),this.props.deselectOnEsc&&(document.addEventListener("keydown",this.keyListener),document.addEventListener("keyup",this.keyListener))}},{key:"componentWillUnmount",value:function(){this.rootNode.removeEventListener("mousedown",this.mouseDown),this.rootNode.removeEventListener("touchstart",this.mouseDown),this.props.deselectOnEsc&&(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.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,i){if(this.inIgnoreList(e.node))return null;var l=a(o,e.bounds,t,this.props.delta),c=e.state,s=c.selecting,u=c.selected;if(n&&l)return u?this.selectedItems.delete(e):this.selectedItems.add(e),e.setState({selected:!u}),this.clickedItem=e;if(!n&&l){if(u&&r&&(!this.selectionStarted||i))return e.setState({selected:!1}),e.deselected=!0,this.deselectionStarted=!0,this.selectedItems.delete(e);var f=i?!e.deselected:!this.deselectionStarted;if(!s&&!u&&f)return e.setState({selecting:!0}),this.selectionStarted=!0,this.selectingItems.add(e),{updateSelecting:!0}}return!n&&!l&&s&&this.selectingItems.has(e)?(e.setState({selecting:!1}),this.selectingItems.delete(e),{updateSelecting:!0}):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=w(document.querySelectorAll(this.ignoreList.join(", ")))}},{key:"detectLeftButton",value:function(e){return!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)&&("buttons"in e?1===e.buttons:"which"in e?1===e.which:1===e.button)}},{key:"preventEvent",value:function(e,t){e.addEventListener(t,function o(n){e.removeEventListener(t,o,!0),n.preventDefault(),n.stopPropagation()},!0)}},{key:"handleClick",value:function(e,t,o){var n=w(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(w(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||null==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 r.a.createElement(v.Provider,{value:this.contextValue},r.a.createElement(this.props.component,{ref:this.getGroupRef,style:Object.assign({},this.defaultContainerStyle,this.props.style),className:"".concat(this.props.className," ").concat(this.state.selectionMode?this.props.selectionModeClass:"")},r.a.createElement(b,{ref:this.getSelectboxRef,fixedPosition:this.props.fixedPosition,className:this.props.selectboxClassName}),this.props.children))}}])&&O(o.prototype,s),u&&O(o,u),t}();k(P,"defaultProps",{component:"div",tolerance:0,globalMouse:!1,ignoreList:[],scrollSpeed:.25,minimumSpeedFactor:60,duringSelection:L,onSelectionFinish:L,onSelectionClear:L,allowClickWithoutSelected:!0,selectionModeClass:"in-selection-mode",resetOnStart:!1,disabled:!1,deselectOnEsc:!0,delta:1});var C=P;function T(e){return(T="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 _(){return(_=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}).apply(this,arguments)}function I(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)}}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function M(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(e,t){return(R=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var W=function(e){var t,o;return o=t=function(t){function o(){var e,t,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o);for(var i=arguments.length,l=new Array(i),s=0;s<i;s++)l[s]=arguments[s];return n=this,r=(e=D(o)).call.apply(e,[this].concat(l)),t=!r||"object"!==T(r)&&"function"!=typeof r?M(n):r,N(M(t),"state",{selected:t.props.selected,selecting:!1}),N(M(t),"registerSelectable",function(e){t.bounds=c(t.node,e),t.context.selectable.register(M(t))}),N(M(t),"selectableRef",function(e){return t.node=e}),t}var i,l,s;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&&R(e,t)}(o,n.Component),i=o,(l=[{key:"componentDidMount",value:function(){this.registerSelectable()}},{key:"componentWillUnmount",value:function(){this.context.selectable.unregister(this)}},{key:"render",value:function(){return r.a.createElement(e,_({},this.props,{selected:this.state.selected,selecting:this.state.selecting,selectableRef:this.selectableRef}))}}])&&I(i.prototype,l),s&&I(i,s),o}(),N(t,"contextType",v),N(t,"defaultProps",{selected:!1}),o};function H(e){return(H="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 B(){return(B=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}).apply(this,arguments)}function A(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function Y(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)}}function U(e){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function F(e,t){return(F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var K=function(e){function t(){var e,o,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return n=this,r=(e=U(t)).call.apply(e,[this].concat(l)),o=!r||"object"!==H(r)&&"function"!=typeof r?X(n):r,G(X(o),"getRootRef",function(e){return o.root=e}),o}var o,i,l;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&&F(e,t)}(t,n["Component"]),o=t,(i=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){var e=this.props,t=e.children,o=e.className,n=A(e,["children","className"]);return r.a.createElement(this.props.component,B({ref:this.getRootRef,className:"selectable-select-all ".concat(o),onClick:this.context.selectable.selectAll},n),t)}}])&&Y(o.prototype,i),l&&Y(o,l),t}();G(K,"contextType",v),G(K,"defaultProps",{component:"div"});var q=K;function z(e){return(z="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 V(){return(V=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}).apply(this,arguments)}function J(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function Q(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)}}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function te(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var oe=function(e){function t(){var e,o,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return n=this,r=(e=Z(t)).call.apply(e,[this].concat(l)),o=!r||"object"!==z(r)&&"function"!=typeof r?$(n):r,te($(o),"getRootRef",function(e){return o.root=e}),o}var o,i,l;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&&ee(e,t)}(t,n["Component"]),o=t,(i=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){var e=this.props,t=e.children,o=e.className,n=J(e,["children","className"]);return r.a.createElement(this.props.component,V({ref:this.getRootRef,className:"selectable-deselect-all ".concat(o),onClick:this.context.selectable.clearSelection},n),t)}}])&&Q(o.prototype,i),l&&Q(o,l),t}();te(oe,"contextType",v),te(oe,"defaultProps",{component:"div"});var ne=oe;o.d(t,"SelectableGroup",function(){return C}),o.d(t,"createSelectable",function(){return W}),o.d(t,"SelectAll",function(){return q}),o.d(t,"DeselectAll",function(){return ne})}])});
!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)}(window,function(e){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(t,n){t.exports=e},function(e,t){},function(e,t,n){"use strict";n.r(t);var o=n(0),r=n.n(o),i=["pageX","pageY","clientX","clientY"];function l(e,t){i.forEach(function(n){void 0===e[n]&&(e[n]=e[t][0][n])})}function c(e){if(e.type.includes("mouse"))return e;try{"touchstart"===e.type?l(e,"targetTouches"):"touchmove"===e.type&&l(e,"changedTouches")}catch(e){alert(e.message)}return e}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{scrollTop:0,scrollLeft:0},n=t.scrollTop,o=t.scrollLeft,r={documentScrollTop:Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop),documentScrollLeft:Math.max(window.pageXOffset,document.documentElement.scrollLeft,document.body.scrollLeft)},i=r.documentScrollTop,l=r.documentScrollLeft,c=e.getBoundingClientRect();return{top:c.top+i+n,left:c.left+l+o,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,width:c.width,height:c.height}}var a=function(e,t,n){var o=n.tolerance,r=void 0===o?0:o,i=n.useOffsetSize,l=void 0!==i&&i,c=l?e.offsetHeight:e.height,s=l?t.offsetHeight:t.height,a=l?e.offsetWidth:e.width,u=l?t.offsetWidth:t.width;return!(e.top+c-r<t.top||e.top+r>t.top+s||e.left+a-r<t.left||e.left+r>t.left+u)};function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=e instanceof HTMLElement?s(e):e,i=t instanceof HTMLElement?s(t):t;return a(r,i,{tolerance:n,useOffsetSize:1===o})}function f(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}var p=function(){},d=r.a.createContext({selectable:{register:function(e){},unregister:function(e){},selectAll:p,clearSelection:p,getScrolledContainer:function(){return null}}});function h(e){return(h="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 y(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)}}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var S=function(e){function t(){var e,n,o,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return o=this,r=(e=m(t)).call.apply(e,[this].concat(l)),n=!r||"object"!==h(r)&&"function"!=typeof r?b(o):r,g(b(n),"state",{y:0,x:0,width:0,height:0,isSelecting:!1}),g(b(n),"selectbox",null),g(b(n),"getRef",function(){return n.selectbox}),g(b(n),"getSelectboxRef",function(e){n.selectbox=e}),n}var n,i,l;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&&v(e,t)}(t,o["Component"]),n=t,(i=[{key:"render",value:function(){var e=this.props,t=e.fixedPosition,n=e.className,o={left:this.state.x,top:this.state.y,width:this.state.width,height:this.state.height,zIndex:9e3,position:t?"fixed":"absolute",cursor:"default"};return r.a.createElement("div",null,this.state.isSelecting&&r.a.createElement("div",{ref:this.getSelectboxRef,style:o,className:n}))}}])&&y(n.prototype,i),l&&y(n,l),t}();g(S,"defaultProps",{className:"selectable-selectbox"});var w=S;function O(e){return(O="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 x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function j(e){return 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}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function C(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)}}function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function L(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var I=function(e){function t(){var e,n,o,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,l=new Array(i),a=0;a<i;a++)l[a]=arguments[a];return o=this,r=(e=k(t)).call.apply(e,[this].concat(l)),n=!r||"object"!==O(r)&&"function"!=typeof r?L(o):r,P(L(n),"state",{selectionMode:!1}),P(L(n),"mouseDownStarted",!1),P(L(n),"mouseMoveStarted",!1),P(L(n),"mouseMoved",!1),P(L(n),"mouseUpStarted",!1),P(L(n),"selectionStarted",!1),P(L(n),"deselectionStarted",!1),P(L(n),"clickedItem",void 0),P(L(n),"mouseDownData",{selectboxY:0,selectboxX:0,target:null}),P(L(n),"registry",new Set),P(L(n),"selectedItems",new Set),P(L(n),"selectingItems",new Set),P(L(n),"ignoreCheckCache",new Map),P(L(n),"ignoreList",n.props.ignoreList.concat([".selectable-select-all",".selectable-deselect-all"])),P(L(n),"ignoreListNodes",[]),P(L(n),"selectbox",null),P(L(n),"selectableGroup",null),P(L(n),"scrollContainer",null),P(L(n),"maxScrollTop",0),P(L(n),"maxScrollLeft",0),P(L(n),"scrollBounds",null),P(L(n),"updateRegistry",function(){var e={scrollTop:n.scrollContainer.scrollTop,scrollLeft:n.scrollContainer.scrollLeft},t=!0,o=!1,r=void 0;try{for(var i,l=n.registry.values()[Symbol.iterator]();!(t=(i=l.next()).done);t=!0){i.value.registerSelectable(e)}}catch(e){o=!0,r=e}finally{try{t||null==l.return||l.return()}finally{if(o)throw r}}}),P(L(n),"registerSelectable",function(e){n.registry.add(e),e.state.isSelected&&n.selectedItems.add(e)}),P(L(n),"unregisterSelectable",function(e){n.registry.delete(e),n.selectedItems.delete(e),n.selectingItems.delete(e),n.props.onSelectionFinish(j(n.selectedItems))}),P(L(n),"updateContainerScroll",function(e){var t=n.scrollContainer,o=t.scrollTop,r=t.scrollLeft;n.checkScrollTop(e.clientY,o),n.checkScrollBottom(e.clientY,o),n.checkScrollLeft(e.clientX,r),n.checkScrollRight(e.clientX,r)}),P(L(n),"getScrollStep",function(e){var t=n.props,o=t.minimumSpeedFactor,r=t.scrollSpeed;return Math.max(e,o)*r}),P(L(n),"checkScrollTop",function(e,t){var o=n.scrollBounds.top-e;(o>0||e<0)&&(n.scrollContainer.scrollTop=t-n.getScrollStep(o))}),P(L(n),"checkScrollBottom",function(e,t){var o=e-n.scrollBounds.bottom;if(o>0||e>window.innerHeight){var r=t+n.getScrollStep(o);n.scrollContainer.scrollTop=Math.min(r,n.maxScrollTop)}}),P(L(n),"checkScrollLeft",function(e,t){var o=n.scrollBounds.left-e;if(o>0||e<0){var r=t-n.getScrollStep(o);n.scrollContainer.scrollLeft=r}}),P(L(n),"checkScrollRight",function(e,t){var o=e-n.scrollBounds.right;if(o>0||e>window.innerWidth){var r=t+n.getScrollStep(o);n.scrollContainer.scrollLeft=Math.min(r,n.maxScrollLeft)}}),P(L(n),"updateSelectBox",function(e){var t=c(e);if(n.updateContainerScroll(t),!n.mouseMoveStarted){n.mouseMoveStarted=!0,n.mouseMoved=!0;var o=L(n).mouseDownData,r=t.clientX,i=t.clientY,l=n.scrollContainer,s=l.scrollLeft,a=l.scrollTop,u=i-n.scrollBounds.top+a,f=Math.min(u,o.selectboxY),p=r-n.scrollBounds.left+s,d=Math.min(p,o.selectboxX);n.selectbox.setState({x:d,y:f,isSelecting:!0,width:Math.abs(p-o.selectboxX),height:Math.abs(u-o.selectboxY)},function(){n.updateSelecting(),n.props.duringSelection(j(n.selectingItems)),n.mouseMoveStarted=!1})}}),P(L(n),"updateSelecting",function(){var e=n.selectbox.getRef();if(e){var t=s(e);n.selectItems(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?x(n,!0).forEach(function(t){P(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}}),P(L(n),"selectItems",function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.props,r=o.tolerance,i=o.enableDeselect,l=o.mixedDeselect;e.top+=n.scrollContainer.scrollTop,e.left+=n.scrollContainer.scrollLeft;var c=!0,s=!1,a=void 0;try{for(var u,f=n.registry.values()[Symbol.iterator]();!(c=(u=f.next()).done);c=!0){var p=u.value;n.processItem({item:p,selectboxBounds:e,tolerance:r,mixedDeselect:l,enableDeselect:i,isFromClick:t&&t.isFromClick})}}catch(e){s=!0,a=e}finally{try{c||null==f.return||f.return()}finally{if(s)throw a}}}),P(L(n),"clearSelection",function(){var e=!0,t=!1,o=void 0;try{for(var r,i=n.selectedItems.values()[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var l=r.value;l.setState({isSelected:!1}),n.selectedItems.delete(l)}}catch(e){t=!0,o=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw o}}n.setState({selectionMode:!1}),n.props.onSelectionFinish(j(n.selectedItems)),n.props.onSelectionClear()}),P(L(n),"selectAll",function(){n.updateWhiteListNodes();var e=!0,t=!1,o=void 0;try{for(var r,i=n.registry.values()[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var l=r.value;n.isInIgnoreList(l.node)||l.state.isSelected||(l.setState({isSelected:!0}),n.selectedItems.add(l))}}catch(e){t=!0,o=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw o}}n.setState({selectionMode:!0}),n.props.onSelectionFinish(j(n.selectedItems))}),P(L(n),"mouseDown",function(e){var t=!e.type.includes("touch")&&!function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)&&("buttons"in e?e.buttons===t:"which"in e?e.which===t:e.button===t-1)}(e,1);if(!(n.mouseDownStarted||n.props.disabled||t))if(n.updateWhiteListNodes(),n.isInIgnoreList(e.target))n.mouseDownStarted=!1;else{n.props.resetOnStart&&n.clearSelection(),n.mouseDownStarted=!0,n.mouseUpStarted=!1;var o=c(e);if(!n.props.globalMouse&&!f(o.target,n.selectableGroup)){var r=s(n.selectableGroup);if(!u({top:r.top,left:r.left,width:0,height:0,offsetHeight:r.offsetHeight,offsetWidth:r.offsetWidth},{top:o.pageY,left:o.pageX,width:0,height:0,offsetWidth:0,offsetHeight:0}))return}n.updateRootBounds(),n.updateRegistry(),n.mouseDownData={target:o.target,selectboxY:o.clientY-n.scrollBounds.top+n.scrollContainer.scrollTop,selectboxX:o.clientX-n.scrollBounds.left+n.scrollContainer.scrollLeft},o.preventDefault(),document.addEventListener("mousemove",n.updateSelectBox),document.addEventListener("touchmove",n.updateSelectBox),document.addEventListener("mouseup",n.mouseUp),document.addEventListener("touchend",n.mouseUp)}}),P(L(n),"mouseUp",function(e){if(!n.mouseUpStarted&&(n.mouseUpStarted=!0,n.mouseDownStarted=!1,n.removeTempEventListeners(),n.mouseDownData)){var t=c(e),o=t.pageX,r=t.pageY;if(!n.mouseMoved&&f(t.target,n.selectableGroup))n.handleClick(t,r,o);else{var i=!0,l=!1,s=void 0;try{for(var a,u=n.selectingItems.values()[Symbol.iterator]();!(i=(a=u.next()).done);i=!0){a.value.setState({isSelected:!0,isSelecting:!1})}}catch(e){l=!0,s=e}finally{try{i||null==u.return||u.return()}finally{if(l)throw s}}n.selectedItems=new Set(j(n.selectedItems).concat(j(n.selectingItems))),n.selectingItems.clear(),1===t.which&&n.mouseDownData.target===t.target&&n.preventEvent(t.target,"click"),n.selectbox.setState({isSelecting:!1,width:0,height:0}),n.props.onSelectionFinish(j(n.selectedItems))}n.toggleSelectionMode(),n.cleanUp(),n.mouseMoved=!1}}),P(L(n),"keyListener",function(e){27===e.keyCode&&n.clearSelection()}),P(L(n),"getGroupRef",function(e){n.selectableGroup=e}),P(L(n),"getSelectboxRef",function(e){n.selectbox=e}),P(L(n),"defaultContainerStyle",{position:"relative"}),P(L(n),"contextValue",{selectable:{register:n.registerSelectable,unregister:n.unregisterSelectable,selectAll:n.selectAll,clearSelection:n.clearSelection,getScrolledContainer:function(){return n.scrollContainer}}}),n}var n,i,l;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&&E(e,t)}(t,o["Component"]),n=t,(i=[{key:"componentDidMount",value:function(){this.props.scrollContainer?this.scrollContainer=document.querySelector(this.props.scrollContainer):this.scrollContainer=this.selectableGroup,this.selectableGroup.addEventListener("mousedown",this.mouseDown),this.selectableGroup.addEventListener("touchstart",this.mouseDown),this.props.deselectOnEsc&&(document.addEventListener("keydown",this.keyListener),document.addEventListener("keyup",this.keyListener))}},{key:"componentWillUnmount",value:function(){this.selectableGroup.removeEventListener("mousedown",this.mouseDown),this.selectableGroup.removeEventListener("touchstart",this.mouseDown),this.props.deselectOnEsc&&(document.removeEventListener("keydown",this.keyListener),document.removeEventListener("keyup",this.keyListener)),this.removeTempEventListeners()}},{key:"removeTempEventListeners",value:function(){document.removeEventListener("mousemove",this.updateSelectBox),document.removeEventListener("touchmove",this.updateSelectBox),document.removeEventListener("mouseup",this.mouseUp),document.removeEventListener("touchend",this.mouseUp)}},{key:"updateRootBounds",value:function(){this.scrollBounds=this.scrollContainer.getBoundingClientRect(),this.maxScrollTop=this.scrollContainer.scrollHeight-this.scrollContainer.clientHeight,this.maxScrollLeft=this.scrollContainer.scrollWidth-this.scrollContainer.clientWidth}},{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){var t=e.item,n=e.tolerance,o=e.selectboxBounds,r=e.enableDeselect,i=e.mixedDeselect,l=e.isFromClick;if(this.isInIgnoreList(t.node))return null;var c=u(o,t.bounds,n,this.props.delta),s=t.state,a=s.isSelecting,f=s.isSelected;if(l&&c)return f?this.selectedItems.delete(t):this.selectedItems.add(t),t.setState({isSelected:!f}),this.clickedItem=t;if(!l&&c){if(f&&r&&(!this.selectionStarted||i))return t.setState({isSelected:!1}),t.deselected=!0,this.deselectionStarted=!0,this.selectedItems.delete(t);var p=i?!t.deselected:!this.deselectionStarted;if(!a&&!f&&p)return t.setState({isSelecting:!0}),this.selectionStarted=!0,this.selectingItems.add(t),{updateSelecting:!0}}return!l&&!c&&a&&this.selectingItems.has(t)?(t.setState({isSelecting:!1}),this.selectingItems.delete(t),{updateSelecting:!0}):null}},{key:"isInIgnoreList",value:function(e){if(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=Array.from(document.querySelectorAll(this.ignoreList.join(", ")))}},{key:"preventEvent",value:function(e,t){e.addEventListener(t,function n(o){e.removeEventListener(t,n,!0),o.preventDefault(),o.stopPropagation()},!0)}},{key:"handleClick",value:function(e,t,n){var o=this.props,r=o.clickClassName,i=o.allowClickWithoutSelected,l=o.onSelectionFinish,c=e.target.classList||[],s=Array.from(c).indexOf(r)>-1;(i||this.selectedItems.size||s||e.ctrlKey)&&(this.selectItems({top:t,left:n,width:0,height:0,offsetWidth:0,offsetHeight:0},{isFromClick:!0}),l(j(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,n=void 0;try{for(var o,r=this.registry.values()[Symbol.iterator]();!(e=(o=r.next()).done);e=!0){o.value.deselected=!1}}catch(e){t=!0,n=e}finally{try{e||null==r.return||r.return()}finally{if(t)throw n}}}}},{key:"render",value:function(){var e=this.state.selectionMode,t=this.props,n=t.component,o=void 0===n?"div":n,i=t.className,l=t.style,c=t.selectionModeClass,s=t.fixedPosition,a=t.selectboxClassName,u=t.children;return r.a.createElement(d.Provider,{value:this.contextValue},r.a.createElement(o,{ref:this.getGroupRef,style:Object.assign({},this.defaultContainerStyle,l),className:"".concat(i," ").concat(e?c:"")},r.a.createElement(w,{ref:this.getSelectboxRef,className:a,fixedPosition:s}),u))}}])&&C(n.prototype,i),l&&C(n,l),t}();P(I,"defaultProps",{clickClassName:"",tolerance:0,globalMouse:!1,ignoreList:[],scrollSpeed:.25,minimumSpeedFactor:60,duringSelection:p,onSelectionFinish:p,onSelectionClear:p,allowClickWithoutSelected:!0,selectionModeClass:"in-selection-mode",resetOnStart:!1,disabled:!1,deselectOnEsc:!0,fixedPosition:!1,delta:1});var _=I;function T(e){return(T="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 M(){return(M=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}).apply(this,arguments)}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)}}function R(e){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function B(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N(e,t){return(N=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function A(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var W=function(e){var t,n;return n=t=function(t){function n(){var e,t,o,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return o=this,r=(e=R(n)).call.apply(e,[this].concat(l)),t=!r||"object"!==T(r)&&"function"!=typeof r?B(o):r,A(B(t),"state",{isSelected:t.props.isSelected,isSelecting:!1}),A(B(t),"node",null),A(B(t),"bounds",null),A(B(t),"registerSelectable",function(e){t.bounds=s(t.node,e),t.context.selectable.register(B(t))}),A(B(t),"getSelectableRef",function(e){t.node=e}),t}var i,l,c;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&&N(e,t)}(n,o.Component),i=n,(l=[{key:"componentDidMount",value:function(){this.registerSelectable()}},{key:"componentWillUnmount",value:function(){this.context.selectable.unregister(this)}},{key:"render",value:function(){return r.a.createElement(e,M({},this.props,this.state,{selectableRef:this.getSelectableRef}))}}])&&D(i.prototype,l),c&&D(i,c),n}(),A(t,"contextType",d),A(t,"defaultProps",{isSelected:!1}),n};function H(e){return(H="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 F(){return(F=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}).apply(this,arguments)}function G(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function U(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)}}function X(e){return(X=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function K(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var q=function(e){function t(){var e,n,o,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return o=this,r=(e=X(t)).call.apply(e,[this].concat(l)),n=!r||"object"!==H(r)&&"function"!=typeof r?Y(o):r,K(Y(n),"root",null),K(Y(n),"getRootRef",function(e){n.root=e}),n}var n,i,l;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&&z(e,t)}(t,o["Component"]),n=t,(i=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){var e=this.props,t=e.component,n=void 0===t?"div":t,o=e.children,i=e.className,l=void 0===i?"":i,c=G(e,["component","children","className"]);return r.a.createElement(n,F({ref:this.getRootRef,className:"selectable-select-all ".concat(l),onClick:this.context.selectable.selectAll},c),o)}}])&&U(n.prototype,i),l&&U(n,l),t}();K(q,"contextType",d);var V=q;function J(e){return(J="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 Q(){return(Q=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}).apply(this,arguments)}function Z(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function $(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)}}function ee(e){return(ee=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function te(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ne(e,t){return(ne=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function oe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var re=function(e){function t(){var e,n,o,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return o=this,r=(e=ee(t)).call.apply(e,[this].concat(l)),n=!r||"object"!==J(r)&&"function"!=typeof r?te(o):r,oe(te(n),"root",null),oe(te(n),"getRootRef",function(e){n.root=e}),n}var n,i,l;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&&ne(e,t)}(t,o["Component"]),n=t,(i=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){var e=this.props,t=e.component,n=void 0===t?"div":t,o=e.children,i=e.className,l=Z(e,["component","children","className"]);return r.a.createElement(n,Q({ref:this.getRootRef,className:"selectable-select-all ".concat(i),onClick:this.context.selectable.clearSelection},l),o)}}])&&$(n.prototype,i),l&&$(n,l),t}();oe(re,"contextType",d);var ie=re,le=n(1);n.d(t,"TSelectableItemProps",function(){return le.TSelectableItemProps}),n.d(t,"SelectableGroup",function(){return _}),n.d(t,"createSelectable",function(){return W}),n.d(t,"SelectAll",function(){return V}),n.d(t,"DeselectAll",function(){return ie})}])});
//# sourceMappingURL=react-selectable-fast.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var utils_1 = require("./utils");
var SelectableGroupContext = react_1.default.createContext({
selectable: {
register: function (_) { },
unregister: function (_) { },
selectAll: utils_1.noop,
clearSelection: utils_1.noop,
getScrolledContainer: function () { return null; }
}
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var SelectableGroupContext = _react["default"].createContext({
selectable: 'omg'
});
var _default = SelectableGroupContext;
exports["default"] = _default;
exports.default = SelectableGroupContext;
//# sourceMappingURL=Context.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = require("prop-types");
var _getBoundsForNode = _interopRequireDefault(require("./getBoundsForNode"));
var _Context = _interopRequireDefault(require("./Context"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var createSelectable = function createSelectable(WrappedComponent) {
var _class, _temp;
return _temp = _class =
/*#__PURE__*/
function (_Component) {
_inherits(SelectableItem, _Component);
function SelectableItem() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, SelectableItem);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SelectableItem)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_this), "state", {
selected: _this.props.selected,
selecting: false
});
_defineProperty(_assertThisInitialized(_this), "registerSelectable", function (containerScroll) {
_this.bounds = (0, _getBoundsForNode["default"])(_this.node, containerScroll);
_this.context.selectable.register(_assertThisInitialized(_this));
});
_defineProperty(_assertThisInitialized(_this), "selectableRef", function (ref) {
return _this.node = ref;
});
return _this;
}
_createClass(SelectableItem, [{
key: "componentDidMount",
value: function componentDidMount() {
this.registerSelectable();
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.context.selectable.unregister(this);
}
}, {
key: "render",
value: function render() {
return _react["default"].createElement(WrappedComponent, _extends({}, this.props, {
selected: this.state.selected,
selecting: this.state.selecting,
selectableRef: this.selectableRef
}));
}
}]);
return SelectableItem;
}(_react.Component), _defineProperty(_class, "contextType", _Context["default"]), _defineProperty(_class, "propTypes", {
selected: _propTypes.bool
}), _defineProperty(_class, "defaultProps", {
selected: false
}), _temp;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var _default = createSelectable;
exports["default"] = _default;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var prop_types_1 = require("prop-types");
var utils_1 = require("./utils");
var Context_1 = __importDefault(require("./Context"));
var createSelectable = function (WrappedComponent) { var _a; return _a = (function (_super) {
__extends(SelectableItem, _super);
function SelectableItem() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.state = {
isSelected: _this.props.isSelected,
isSelecting: false
};
_this.node = null;
_this.bounds = null;
_this.registerSelectable = function (containerScroll) {
_this.bounds = utils_1.getBoundsForNode(_this.node, containerScroll);
_this.context.selectable.register(_this);
};
_this.getSelectableRef = function (ref) {
_this.node = ref;
};
return _this;
}
SelectableItem.prototype.componentDidMount = function () {
this.registerSelectable();
};
SelectableItem.prototype.componentWillUnmount = function () {
this.context.selectable.unregister(this);
};
SelectableItem.prototype.render = function () {
return (react_1.default.createElement(WrappedComponent, __assign({}, this.props, this.state, { selectableRef: this.getSelectableRef })));
};
return SelectableItem;
}(react_1.Component)),
_a.contextType = Context_1.default,
_a.propTypes = {
isSelected: prop_types_1.bool
},
_a.defaultProps = {
isSelected: false
},
_a; };
exports.default = createSelectable;
//# sourceMappingURL=CreateSelectable.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = require("prop-types");
var _Context = _interopRequireDefault(require("./Context"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var DeselectAllButton =
/*#__PURE__*/
function (_Component) {
_inherits(DeselectAllButton, _Component);
function DeselectAllButton() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, DeselectAllButton);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var Context_1 = __importDefault(require("./Context"));
var DeselectAllButton = (function (_super) {
__extends(DeselectAllButton, _super);
function DeselectAllButton() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.root = null;
_this.getRootRef = function (ref) {
_this.root = ref;
};
return _this;
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DeselectAllButton)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_this), "getRootRef", function (c) {
return _this.root = c;
});
return _this;
}
_createClass(DeselectAllButton, [{
key: "componentDidMount",
value: function componentDidMount() {
this.root.addEventListener('mousedown', function (e) {
return e.stopPropagation();
});
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
children = _this$props.children,
className = _this$props.className,
rest = _objectWithoutProperties(_this$props, ["children", "className"]);
return _react["default"].createElement(this.props.component, _extends({
ref: this.getRootRef,
className: "selectable-deselect-all ".concat(className),
onClick: this.context.selectable.clearSelection
}, rest), children);
}
}]);
return DeselectAllButton;
}(_react.Component);
_defineProperty(DeselectAllButton, "contextType", _Context["default"]);
_defineProperty(DeselectAllButton, "propTypes", {
children: _propTypes.node,
component: _propTypes.node
});
_defineProperty(DeselectAllButton, "defaultProps", {
component: 'div'
});
var _default = DeselectAllButton;
exports["default"] = _default;
DeselectAllButton.prototype.componentDidMount = function () {
this.root.addEventListener('mousedown', function (evt) { return evt.stopPropagation(); });
};
DeselectAllButton.prototype.render = function () {
var _a = this.props, _b = _a.component, ButtonComponent = _b === void 0 ? 'div' : _b, children = _a.children, className = _a.className, rest = __rest(_a, ["component", "children", "className"]);
return (react_1.default.createElement(ButtonComponent, __assign({ ref: this.getRootRef, className: "selectable-select-all " + className, onClick: this.context.selectable.clearSelection }, rest), children));
};
DeselectAllButton.contextType = Context_1.default;
return DeselectAllButton;
}(react_1.Component));
exports.default = DeselectAllButton;
//# sourceMappingURL=DeselectAll.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SelectableGroup", {
enumerable: true,
get: function get() {
return _SelectableGroup["default"];
}
});
Object.defineProperty(exports, "createSelectable", {
enumerable: true,
get: function get() {
return _CreateSelectable["default"];
}
});
Object.defineProperty(exports, "SelectAll", {
enumerable: true,
get: function get() {
return _SelectAll["default"];
}
});
Object.defineProperty(exports, "DeselectAll", {
enumerable: true,
get: function get() {
return _DeselectAll["default"];
}
});
var _SelectableGroup = _interopRequireDefault(require("./SelectableGroup"));
var _CreateSelectable = _interopRequireDefault(require("./CreateSelectable"));
var _SelectAll = _interopRequireDefault(require("./SelectAll"));
var _DeselectAll = _interopRequireDefault(require("./DeselectAll"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// As early as possible, check for the existence of the JavaScript globals which
// Relay Runtime relies upon, and produce a clear message if they do not exist.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var SelectableGroup_1 = __importDefault(require("./SelectableGroup"));
exports.SelectableGroup = SelectableGroup_1.default;
var CreateSelectable_1 = __importDefault(require("./CreateSelectable"));
exports.createSelectable = CreateSelectable_1.default;
var SelectAll_1 = __importDefault(require("./SelectAll"));
exports.SelectAll = SelectAll_1.default;
var DeselectAll_1 = __importDefault(require("./DeselectAll"));
exports.DeselectAll = DeselectAll_1.default;
if (process.env.NODE_ENV === 'development') {
if (typeof Map !== 'function' || typeof Set !== 'function' || typeof Array.from !== 'function' || typeof Array.isArray !== 'function' || typeof Object.assign !== 'function') {
throw new Error("\n React-Selectable-Fast requires Map, Set, Array.from,\n Array.isArray, and Object.assign to exist.\n Use a polyfill to provide these for older browsers.\n ");
}
}
if (typeof Map !== 'function' ||
typeof Set !== 'function' ||
typeof Array.from !== 'function' ||
typeof Array.isArray !== 'function' ||
typeof Object.assign !== 'function') {
throw new Error("\n React-Selectable-Fast requires Map, Set, Array.from,\n Array.isArray, and Object.assign to exist.\n Use a polyfill to provide these for older browsers.\n ");
}
}
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = require("prop-types");
var _nodeInRoot = _interopRequireDefault(require("./nodeInRoot"));
var _getBoundsForNode = _interopRequireWildcard(require("./getBoundsForNode"));
var _doObjectsCollide = _interopRequireDefault(require("./doObjectsCollide"));
var _Selectbox = _interopRequireDefault(require("./Selectbox"));
var _Context = _interopRequireDefault(require("./Context"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var noop = function noop() {};
var SelectableGroup =
/*#__PURE__*/
function (_Component) {
_inherits(SelectableGroup, _Component);
function SelectableGroup(props) {
var _this;
_classCallCheck(this, SelectableGroup);
_this = _possibleConstructorReturn(this, _getPrototypeOf(SelectableGroup).call(this, props));
_defineProperty(_assertThisInitialized(_this), "setScollTop", function (e) {
var scrollTop = _this.scrollContainer.scrollTop;
_this.checkScrollTop(e, scrollTop);
_this.checkScrollBottom(e, scrollTop);
});
_defineProperty(_assertThisInitialized(_this), "checkScrollTop", function (e, currentTop) {
var _this$props = _this.props,
minimumSpeedFactor = _this$props.minimumSpeedFactor,
scrollSpeed = _this$props.scrollSpeed;
var offset = _this.scrollBounds.top - e.clientY;
if (offset > 0 || e.clientY < 0) {
var newTop = currentTop - Math.max(offset, minimumSpeedFactor) * scrollSpeed;
_this.scrollContainer.scrollTop = newTop;
}
});
_defineProperty(_assertThisInitialized(_this), "checkScrollBottom", function (e, currentTop) {
var _this$props2 = _this.props,
minimumSpeedFactor = _this$props2.minimumSpeedFactor,
scrollSpeed = _this$props2.scrollSpeed;
var offset = e.clientY - _this.scrollBounds.bottom;
if (offset > 0 || e.clientY > window.innerHeight) {
var newTop = currentTop + Math.max(offset, minimumSpeedFactor) * scrollSpeed;
_this.scrollContainer.scrollTop = Math.min(newTop, _this.maxScroll);
}
});
_defineProperty(_assertThisInitialized(_this), "updateRegistry", function () {
var containerScroll = {
scrollTop: _this.scrollContainer.scrollTop,
scrollLeft: _this.scrollContainer.scrollLeft
};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = _this.registry.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var selectableItem = _step.value;
selectableItem.registerSelectable(containerScroll);
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
return t;
};
return __assign.apply(this, arguments);
};
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
if (r && !r.done && (m = i["return"])) m.call(i);
}
}
});
_defineProperty(_assertThisInitialized(_this), "registerSelectable", function (selectableItem) {
_this.registry.add(selectableItem);
if (selectableItem.state.selected) {
_this.selectedItems.add(selectableItem);
}
});
_defineProperty(_assertThisInitialized(_this), "unregisterSelectable", function (selectableItem) {
_this.registry["delete"](selectableItem);
_this.selectedItems["delete"](selectableItem);
_this.selectingItems["delete"](selectableItem);
});
_defineProperty(_assertThisInitialized(_this), "applyContainerScroll", function (value, scroll) {
return value + scroll;
});
_defineProperty(_assertThisInitialized(_this), "openSelectbox", function (event) {
var e = _this.desktopEventCoords(event);
_this.setScollTop(e);
if (_this.mouseMoveStarted) return;
_this.mouseMoveStarted = true;
_this.mouseMoved = true;
var _this$scrollContainer = _this.scrollContainer,
scrollTop = _this$scrollContainer.scrollTop,
scrollLeft = _this$scrollContainer.scrollLeft;
var eventTop = e.pageY;
var eventLeft = e.pageX;
var _getDocumentScroll = (0, _getBoundsForNode.getDocumentScroll)(),
documentScrollTop = _getDocumentScroll.documentScrollTop,
documentScrollLeft = _getDocumentScroll.documentScrollLeft;
var top = _this.applyContainerScroll(eventTop - _this.scrollBounds.top, scrollTop - documentScrollTop);
var boxTop = _this.applyContainerScroll(_this.mouseDownData.boxTop - _this.scrollBounds.top, _this.mouseDownData.scrollTop - documentScrollTop);
var boxHeight = boxTop - top;
boxTop = Math.min(boxTop - boxHeight, boxTop);
var left = _this.applyContainerScroll(eventLeft - _this.scrollBounds.left, scrollLeft - documentScrollLeft);
var boxLeft = _this.applyContainerScroll(_this.mouseDownData.boxLeft - _this.scrollBounds.left, _this.mouseDownData.scrollLeft - documentScrollLeft);
var boxWidth = boxLeft - left;
boxLeft = Math.min(boxLeft - boxWidth, boxLeft);
_this.selectbox.setState({
isBoxSelecting: true,
boxWidth: Math.abs(boxWidth),
boxHeight: Math.abs(boxHeight),
boxLeft: boxLeft,
boxTop: boxTop
}, function () {
_this.updateSelecting();
_this.props.duringSelection(_toConsumableArray(_this.selectingItems));
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var utils_1 = require("./utils");
var Context_1 = __importDefault(require("./Context"));
var Selectbox_1 = __importDefault(require("./Selectbox"));
var SelectableGroup = (function (_super) {
__extends(SelectableGroup, _super);
function SelectableGroup() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.state = { selectionMode: false };
_this.mouseDownStarted = false;
_this.mouseMoveStarted = false;
});
});
_defineProperty(_assertThisInitialized(_this), "updateSelecting", function () {
var selectbox = _this.selectbox.getRef();
if (!selectbox) return;
var selectboxBounds = (0, _getBoundsForNode["default"])(selectbox);
_this.selectItems(_objectSpread({}, selectboxBounds, {
offsetWidth: selectboxBounds.offsetWidth || 1,
offsetHeight: selectboxBounds.offsetHeight || 1
}));
});
_defineProperty(_assertThisInitialized(_this), "selectItems", function (selectboxBounds) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
click = _ref.click;
var _this$props3 = _this.props,
tolerance = _this$props3.tolerance,
enableDeselect = _this$props3.enableDeselect,
mixedDeselect = _this$props3.mixedDeselect;
selectboxBounds.top += _this.scrollContainer.scrollTop;
selectboxBounds.left += _this.scrollContainer.scrollLeft;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = _this.registry.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var item = _step2.value;
_this.processItem(item, tolerance, selectboxBounds, click, enableDeselect, mixedDeselect);
_this.mouseMoved = false;
_this.mouseUpStarted = false;
_this.selectionStarted = false;
_this.deselectionStarted = false;
_this.mouseDownData = {
selectboxY: 0,
selectboxX: 0,
target: null
};
_this.registry = new Set();
_this.selectedItems = new Set();
_this.selectingItems = new Set();
_this.ignoreCheckCache = new Map();
_this.ignoreList = _this.props.ignoreList.concat(['.selectable-select-all', '.selectable-deselect-all']);
_this.ignoreListNodes = [];
_this.selectbox = null;
_this.selectableGroup = null;
_this.scrollContainer = null;
_this.maxScrollTop = 0;
_this.maxScrollLeft = 0;
_this.scrollBounds = null;
_this.updateRegistry = function () {
var e_1, _a;
var containerScroll = {
scrollTop: _this.scrollContainer.scrollTop,
scrollLeft: _this.scrollContainer.scrollLeft
};
try {
for (var _b = __values(_this.registry.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
var selectableItem = _c.value;
selectableItem.registerSelectable(containerScroll);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
_this.registerSelectable = function (selectableItem) {
_this.registry.add(selectableItem);
if (selectableItem.state.isSelected) {
_this.selectedItems.add(selectableItem);
}
};
_this.unregisterSelectable = function (selectableItem) {
_this.registry.delete(selectableItem);
_this.selectedItems.delete(selectableItem);
_this.selectingItems.delete(selectableItem);
_this.props.onSelectionFinish(__spread(_this.selectedItems));
};
_this.updateContainerScroll = function (evt) {
var _a = _this.scrollContainer, scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
_this.checkScrollTop(evt.clientY, scrollTop);
_this.checkScrollBottom(evt.clientY, scrollTop);
_this.checkScrollLeft(evt.clientX, scrollLeft);
_this.checkScrollRight(evt.clientX, scrollLeft);
};
_this.getScrollStep = function (offset) {
var _a = _this.props, minimumSpeedFactor = _a.minimumSpeedFactor, scrollSpeed = _a.scrollSpeed;
return Math.max(offset, minimumSpeedFactor) * scrollSpeed;
};
_this.checkScrollTop = function (clientY, currentTop) {
var offset = _this.scrollBounds.top - clientY;
if (offset > 0 || clientY < 0) {
_this.scrollContainer.scrollTop = currentTop - _this.getScrollStep(offset);
}
};
_this.checkScrollBottom = function (clientY, currentTop) {
var offset = clientY - _this.scrollBounds.bottom;
if (offset > 0 || clientY > window.innerHeight) {
var newTop = currentTop + _this.getScrollStep(offset);
_this.scrollContainer.scrollTop = Math.min(newTop, _this.maxScrollTop);
}
};
_this.checkScrollLeft = function (clientX, currentLeft) {
var offset = _this.scrollBounds.left - clientX;
if (offset > 0 || clientX < 0) {
var newLeft = currentLeft - _this.getScrollStep(offset);
_this.scrollContainer.scrollLeft = newLeft;
}
};
_this.checkScrollRight = function (clientX, currentLeft) {
var offset = clientX - _this.scrollBounds.right;
if (offset > 0 || clientX > window.innerWidth) {
var newLeft = currentLeft + _this.getScrollStep(offset);
_this.scrollContainer.scrollLeft = Math.min(newLeft, _this.maxScrollLeft);
}
};
_this.updateSelectBox = function (event) {
var evt = utils_1.castTouchToMouseEvent(event);
_this.updateContainerScroll(evt);
if (_this.mouseMoveStarted) {
return;
}
_this.mouseMoveStarted = true;
_this.mouseMoved = true;
var mouseDownData = _this.mouseDownData;
var clientX = evt.clientX, clientY = evt.clientY;
var _a = _this.scrollContainer, scrollLeft = _a.scrollLeft, scrollTop = _a.scrollTop;
var pointY = clientY - _this.scrollBounds.top + scrollTop;
var selectboxY = Math.min(pointY, mouseDownData.selectboxY);
var pointX = clientX - _this.scrollBounds.left + scrollLeft;
var selectboxX = Math.min(pointX, mouseDownData.selectboxX);
_this.selectbox.setState({
x: selectboxX,
y: selectboxY,
isSelecting: true,
width: Math.abs(pointX - mouseDownData.selectboxX),
height: Math.abs(pointY - mouseDownData.selectboxY)
}, function () {
_this.updateSelecting();
_this.props.duringSelection(__spread(_this.selectingItems));
_this.mouseMoveStarted = false;
});
};
_this.updateSelecting = function () {
var selectboxNode = _this.selectbox.getRef();
if (!selectboxNode) {
return;
}
var selectboxBounds = utils_1.getBoundsForNode(selectboxNode);
_this.selectItems(__assign({}, selectboxBounds, { offsetWidth: selectboxBounds.offsetWidth || 1, offsetHeight: selectboxBounds.offsetHeight || 1 }));
};
_this.selectItems = function (selectboxBounds, options) {
var e_2, _a;
if (options === void 0) { options = {}; }
var _b = _this.props, tolerance = _b.tolerance, enableDeselect = _b.enableDeselect, mixedDeselect = _b.mixedDeselect;
selectboxBounds.top += _this.scrollContainer.scrollTop;
selectboxBounds.left += _this.scrollContainer.scrollLeft;
try {
for (var _c = __values(_this.registry.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
var item = _d.value;
_this.processItem({
item: item,
selectboxBounds: selectboxBounds,
tolerance: tolerance,
mixedDeselect: mixedDeselect,
enableDeselect: enableDeselect,
isFromClick: options && options.isFromClick
});
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_2) throw e_2.error; }
}
};
_this.clearSelection = function () {
var e_3, _a;
try {
for (var _b = __values(_this.selectedItems.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
var item = _c.value;
item.setState({ isSelected: false });
_this.selectedItems.delete(item);
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_3) throw e_3.error; }
}
_this.setState({ selectionMode: false });
_this.props.onSelectionFinish(__spread(_this.selectedItems));
_this.props.onSelectionClear();
};
_this.selectAll = function () {
var e_4, _a;
_this.updateWhiteListNodes();
try {
for (var _b = __values(_this.registry.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
var item = _c.value;
if (!_this.isInIgnoreList(item.node) && !item.state.isSelected) {
item.setState({ isSelected: true });
_this.selectedItems.add(item);
}
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_4) throw e_4.error; }
}
_this.setState({ selectionMode: true });
_this.props.onSelectionFinish(__spread(_this.selectedItems));
};
_this.mouseDown = function (e) {
var isNotLeftButtonClick = !e.type.includes('touch') && !utils_1.detectMouseButton(e, 1);
if (_this.mouseDownStarted || _this.props.disabled || isNotLeftButtonClick) {
return;
}
_this.updateWhiteListNodes();
if (_this.isInIgnoreList(e.target)) {
_this.mouseDownStarted = false;
return;
}
if (_this.props.resetOnStart) {
_this.clearSelection();
}
_this.mouseDownStarted = true;
_this.mouseUpStarted = false;
var evt = utils_1.castTouchToMouseEvent(e);
if (!_this.props.globalMouse && !utils_1.isNodeInRoot(evt.target, _this.selectableGroup)) {
var offsetData = utils_1.getBoundsForNode(_this.selectableGroup);
var collides = utils_1.doObjectsCollide({
top: offsetData.top,
left: offsetData.left,
width: 0,
height: 0,
offsetHeight: offsetData.offsetHeight,
offsetWidth: offsetData.offsetWidth
}, {
top: evt.pageY,
left: evt.pageX,
width: 0,
height: 0,
offsetWidth: 0,
offsetHeight: 0
});
if (!collides) {
return;
}
}
_this.updateRootBounds();
_this.updateRegistry();
_this.mouseDownData = {
target: evt.target,
selectboxY: evt.clientY - _this.scrollBounds.top + _this.scrollContainer.scrollTop,
selectboxX: evt.clientX - _this.scrollBounds.left + _this.scrollContainer.scrollLeft
};
evt.preventDefault();
document.addEventListener('mousemove', _this.updateSelectBox);
document.addEventListener('touchmove', _this.updateSelectBox);
document.addEventListener('mouseup', _this.mouseUp);
document.addEventListener('touchend', _this.mouseUp);
};
_this.mouseUp = function (event) {
var e_5, _a;
if (_this.mouseUpStarted) {
return;
}
_this.mouseUpStarted = true;
_this.mouseDownStarted = false;
_this.removeTempEventListeners();
if (!_this.mouseDownData) {
return;
}
var evt = utils_1.castTouchToMouseEvent(event);
var pageX = evt.pageX, pageY = evt.pageY;
if (!_this.mouseMoved && utils_1.isNodeInRoot(evt.target, _this.selectableGroup)) {
_this.handleClick(evt, pageY, pageX);
}
else {
try {
for (var _b = __values(_this.selectingItems.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
var item = _c.value;
item.setState({ isSelected: true, isSelecting: false });
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_5) throw e_5.error; }
}
_this.selectedItems = new Set(__spread(_this.selectedItems, _this.selectingItems));
_this.selectingItems.clear();
if (evt.which === 1 && _this.mouseDownData.target === evt.target) {
_this.preventEvent(evt.target, 'click');
}
_this.selectbox.setState({
isSelecting: false,
width: 0,
height: 0
});
_this.props.onSelectionFinish(__spread(_this.selectedItems));
}
_this.toggleSelectionMode();
_this.cleanUp();
_this.mouseMoved = false;
};
_this.keyListener = function (evt) {
if (evt.keyCode === 27) {
_this.clearSelection();
}
};
_this.getGroupRef = function (ref) {
_this.selectableGroup = ref;
};
_this.getSelectboxRef = function (ref) {
_this.selectbox = ref;
};
_this.defaultContainerStyle = {
position: 'relative'
};
_this.contextValue = {
selectable: {
register: _this.registerSelectable,
unregister: _this.unregisterSelectable,
selectAll: _this.selectAll,
clearSelection: _this.clearSelection,
getScrolledContainer: function () { return _this.scrollContainer; }
}
};
return _this;
}
SelectableGroup.prototype.componentDidMount = function () {
if (this.props.scrollContainer) {
this.scrollContainer = document.querySelector(this.props.scrollContainer);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
else {
this.scrollContainer = this.selectableGroup;
}
}
});
_defineProperty(_assertThisInitialized(_this), "clearSelection", function () {
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = _this.selectedItems.values()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var item = _step3.value;
item.setState({
selected: false
});
_this.selectedItems["delete"](item);
this.selectableGroup.addEventListener('mousedown', this.mouseDown);
this.selectableGroup.addEventListener('touchstart', this.mouseDown);
if (this.props.deselectOnEsc) {
document.addEventListener('keydown', this.keyListener);
document.addEventListener('keyup', this.keyListener);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
_iterator3["return"]();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
};
SelectableGroup.prototype.componentWillUnmount = function () {
this.selectableGroup.removeEventListener('mousedown', this.mouseDown);
this.selectableGroup.removeEventListener('touchstart', this.mouseDown);
if (this.props.deselectOnEsc) {
document.removeEventListener('keydown', this.keyListener);
document.removeEventListener('keyup', this.keyListener);
}
}
_this.setState({
selectionMode: false
});
_this.props.onSelectionFinish(_toConsumableArray(_this.selectedItems));
_this.props.onSelectionClear();
});
_defineProperty(_assertThisInitialized(_this), "selectAll", function () {
_this.updateWhiteListNodes();
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = _this.registry.values()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var item = _step4.value;
if (!_this.inIgnoreList(item.node) && !item.state.selected) {
item.setState({
selected: true
});
_this.selectedItems.add(item);
}
this.removeTempEventListeners();
};
SelectableGroup.prototype.removeTempEventListeners = function () {
document.removeEventListener('mousemove', this.updateSelectBox);
document.removeEventListener('touchmove', this.updateSelectBox);
document.removeEventListener('mouseup', this.mouseUp);
document.removeEventListener('touchend', this.mouseUp);
};
SelectableGroup.prototype.updateRootBounds = function () {
this.scrollBounds = this.scrollContainer.getBoundingClientRect();
this.maxScrollTop = this.scrollContainer.scrollHeight - this.scrollContainer.clientHeight;
this.maxScrollLeft = this.scrollContainer.scrollWidth - this.scrollContainer.clientWidth;
};
SelectableGroup.prototype.toggleSelectionMode = function () {
var _a = this, selectedItems = _a.selectedItems, selectionMode = _a.state.selectionMode;
if (selectedItems.size && !selectionMode) {
this.setState({ selectionMode: true });
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
_iterator4["return"]();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
if (!selectedItems.size && selectionMode) {
this.setState({ selectionMode: false });
}
}
_this.setState({
selectionMode: true
});
_this.props.onSelectionFinish(_toConsumableArray(_this.selectedItems));
});
_defineProperty(_assertThisInitialized(_this), "mouseDown", function (e) {
if (_this.mouseDownStarted || _this.props.disabled || !_this.detectLeftButton(e)) return;
_this.updateWhiteListNodes();
if (_this.inIgnoreList(e.target)) {
_this.mouseDownStarted = false;
return;
}
if (_this.props.resetOnStart) {
_this.clearSelection();
}
_this.mouseDownStarted = true;
_this.mouseUpStarted = false;
e = _this.desktopEventCoords(e);
if (!_this.props.globalMouse && !(0, _nodeInRoot["default"])(e.target, _this.selectableGroup)) {
var offsetData = (0, _getBoundsForNode["default"])(_this.selectableGroup);
var collides = (0, _doObjectsCollide["default"])({
top: offsetData.top,
left: offsetData.left,
bottom: offsetData.offsetHeight,
right: offsetData.offsetWidth
}, {
top: e.pageY,
left: e.pageX,
offsetWidth: 0,
offsetHeight: 0
});
if (!collides) return;
}
_this.updateRootBounds();
_this.updateRegistry();
_this.mouseDownData = {
boxLeft: e.pageX,
boxTop: e.pageY,
scrollTop: _this.scrollContainer.scrollTop,
scrollLeft: _this.scrollContainer.scrollLeft,
target: e.target
};
e.preventDefault();
document.addEventListener('mousemove', _this.openSelectbox);
document.addEventListener('touchmove', _this.openSelectbox);
document.addEventListener('mouseup', _this.mouseUp);
document.addEventListener('touchend', _this.mouseUp);
});
_defineProperty(_assertThisInitialized(_this), "mouseUp", function (event) {
if (_this.mouseUpStarted) return;
_this.mouseUpStarted = true;
_this.mouseDownStarted = false;
_this.removeTempEventListeners();
if (!_this.mouseDownData) return;
var e = _this.desktopEventCoords(event);
var eventTop = e.pageY;
var eventLeft = e.pageX;
if (!_this.mouseMoved && (0, _nodeInRoot["default"])(e.target, _this.rootNode)) {
_this.handleClick(e, eventTop, eventLeft);
} else {
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = _this.selectingItems.values()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var item = _step5.value;
item.setState({
selected: true,
selecting: false
});
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
_iterator5["return"]();
};
SelectableGroup.prototype.processItem = function (options) {
var item = options.item, tolerance = options.tolerance, selectboxBounds = options.selectboxBounds, enableDeselect = options.enableDeselect, mixedDeselect = options.mixedDeselect, isFromClick = options.isFromClick;
if (this.isInIgnoreList(item.node)) {
return null;
}
var isCollided = utils_1.doObjectsCollide(selectboxBounds, item.bounds, tolerance, this.props.delta);
var _a = item.state, isSelecting = _a.isSelecting, isSelected = _a.isSelected;
if (isFromClick && isCollided) {
if (isSelected) {
this.selectedItems.delete(item);
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
else {
this.selectedItems.add(item);
}
}
item.setState({ isSelected: !isSelected });
return (this.clickedItem = item);
}
_this.selectedItems = new Set(_toConsumableArray(_this.selectedItems).concat(_toConsumableArray(_this.selectingItems)));
_this.selectingItems.clear();
if (e.which === 1 && _this.mouseDownData.target === e.target) {
_this.preventEvent(e.target, 'click');
if (!isFromClick && isCollided) {
if (isSelected && enableDeselect && (!this.selectionStarted || mixedDeselect)) {
item.setState({ isSelected: false });
item.deselected = true;
this.deselectionStarted = true;
return this.selectedItems.delete(item);
}
var canSelect = mixedDeselect ? !item.deselected : !this.deselectionStarted;
if (!isSelecting && !isSelected && canSelect) {
item.setState({ isSelecting: true });
this.selectionStarted = true;
this.selectingItems.add(item);
return { updateSelecting: true };
}
}
_this.selectbox.setState({
isBoxSelecting: false,
boxWidth: 0,
boxHeight: 0
});
_this.props.onSelectionFinish(_toConsumableArray(_this.selectedItems));
}
_this.toggleSelectionMode();
_this.cleanUp();
_this.mouseMoved = false;
});
_defineProperty(_assertThisInitialized(_this), "keyListener", function (e) {
if (e.ctrlKey || e.metaKey) {
return;
}
if (e.keyCode === 27) {
// escape
_this.clearSelection();
}
});
_defineProperty(_assertThisInitialized(_this), "getGroupRef", function (c) {
return _this.selectableGroup = c;
});
_defineProperty(_assertThisInitialized(_this), "getSelectboxRef", function (c) {
return _this.selectbox = c;
});
_defineProperty(_assertThisInitialized(_this), "defaultContainerStyle", {
position: 'relative'
});
_defineProperty(_assertThisInitialized(_this), "contextValue", {
selectable: {
register: _this.registerSelectable,
unregister: _this.unregisterSelectable,
selectAll: _this.selectAll,
clearSelection: _this.clearSelection,
getScrolledContainer: function getScrolledContainer() {
return _this.scrollContainer;
if (!isFromClick && !isCollided && isSelecting) {
if (this.selectingItems.has(item)) {
item.setState({ isSelecting: false });
this.selectingItems.delete(item);
return { updateSelecting: true };
}
}
}
});
_this.state = {
selectionMode: false
return null;
};
_this.mouseDownStarted = false;
_this.mouseMoveStarted = false;
_this.mouseUpStarted = false;
_this.mouseDownData = null;
_this.registry = new Set();
_this.selectedItems = new Set();
_this.selectingItems = new Set();
_this.ignoreCheckCache = new Map();
_this.ignoreList = _this.props.ignoreList.concat(['.selectable-select-all', '.selectable-deselect-all']);
return _this;
}
_createClass(SelectableGroup, [{
key: "componentDidMount",
value: function componentDidMount() {
this.rootNode = this.selectableGroup;
this.scrollContainer = document.querySelector(this.props.scrollContainer) || this.rootNode;
this.rootNode.addEventListener('mousedown', this.mouseDown);
this.rootNode.addEventListener('touchstart', this.mouseDown);
if (this.props.deselectOnEsc) {
document.addEventListener('keydown', this.keyListener);
document.addEventListener('keyup', this.keyListener);
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.rootNode.removeEventListener('mousedown', this.mouseDown);
this.rootNode.removeEventListener('touchstart', this.mouseDown);
if (this.props.deselectOnEsc) {
document.removeEventListener('keydown', this.keyListener);
document.removeEventListener('keyup', this.keyListener);
}
this.removeTempEventListeners();
}
}, {
key: "removeTempEventListeners",
value: function removeTempEventListeners() {
document.removeEventListener('mousemove', this.openSelectbox);
document.removeEventListener('touchmove', this.openSelectbox);
document.removeEventListener('mouseup', this.mouseUp);
document.removeEventListener('touchend', this.mouseUp);
}
}, {
key: "updateRootBounds",
value: function updateRootBounds() {
this.scrollBounds = this.scrollContainer.getBoundingClientRect();
this.maxScroll = this.scrollContainer.scrollHeight - this.scrollContainer.clientHeight;
}
}, {
key: "toggleSelectionMode",
value: function toggleSelectionMode() {
var selectedItems = this.selectedItems,
selectionMode = this.state.selectionMode;
if (selectedItems.size && !selectionMode) {
this.setState({
selectionMode: true
});
}
if (!selectedItems.size && selectionMode) {
this.setState({
selectionMode: false
});
}
}
}, {
key: "processItem",
value: function processItem(item, tolerance, selectboxBounds, click, enableDeselect, mixedDeselect) {
if (this.inIgnoreList(item.node)) {
return null;
}
var isCollided = (0, _doObjectsCollide["default"])(selectboxBounds, item.bounds, tolerance, this.props.delta);
var _item$state = item.state,
selecting = _item$state.selecting,
selected = _item$state.selected;
if (click && isCollided) {
if (selected) {
this.selectedItems["delete"](item);
} else {
this.selectedItems.add(item);
SelectableGroup.prototype.isInIgnoreList = function (target) {
if (!target) {
return;
}
item.setState({
selected: !selected
});
return this.clickedItem = item;
}
if (!click && isCollided) {
if (selected && enableDeselect && (!this.selectionStarted || mixedDeselect)) {
item.setState({
selected: false
});
item.deselected = true;
this.deselectionStarted = true;
return this.selectedItems["delete"](item);
if (this.ignoreCheckCache.get(target) !== undefined) {
return this.ignoreCheckCache.get(target);
}
var canSelect = mixedDeselect ? !item.deselected : !this.deselectionStarted;
if (!selecting && !selected && canSelect) {
item.setState({
selecting: true
});
this.selectionStarted = true;
this.selectingItems.add(item);
return {
updateSelecting: true
};
var shouldBeIgnored = this.ignoreListNodes.some(function (ignoredNode) { return target === ignoredNode || ignoredNode.contains(target); });
this.ignoreCheckCache.set(target, shouldBeIgnored);
return shouldBeIgnored;
};
SelectableGroup.prototype.updateWhiteListNodes = function () {
this.ignoreListNodes = Array.from(document.querySelectorAll(this.ignoreList.join(', ')));
};
SelectableGroup.prototype.preventEvent = function (target, type) {
var preventHandler = function (evt) {
target.removeEventListener(type, preventHandler, true);
evt.preventDefault();
evt.stopPropagation();
};
target.addEventListener(type, preventHandler, true);
};
SelectableGroup.prototype.handleClick = function (evt, top, left) {
var _a = this.props, clickClassName = _a.clickClassName, allowClickWithoutSelected = _a.allowClickWithoutSelected, onSelectionFinish = _a.onSelectionFinish;
var classNames = evt.target.classList || [];
var isMouseUpOnClickElement = Array.from(classNames).indexOf(clickClassName) > -1;
if (allowClickWithoutSelected ||
this.selectedItems.size ||
isMouseUpOnClickElement ||
evt.ctrlKey) {
this.selectItems({
top: top,
left: left,
width: 0,
height: 0,
offsetWidth: 0,
offsetHeight: 0
}, { isFromClick: true });
onSelectionFinish(__spread(this.selectedItems), this.clickedItem);
if (evt.which === 1) {
this.preventEvent(evt.target, 'click');
}
if (evt.which === 2 || evt.which === 3) {
this.preventEvent(evt.target, 'contextmenu');
}
}
}
if (!click && !isCollided && selecting) {
if (this.selectingItems.has(item)) {
item.setState({
selecting: false
});
this.selectingItems["delete"](item);
return {
updateSelecting: true
};
}
}
return null;
}
}, {
key: "inIgnoreList",
value: function inIgnoreList(target) {
if (this.ignoreCheckCache.get(target) !== undefined) {
return this.ignoreCheckCache.get(target);
}
var shouldBeIgnored = this.ignoreListNodes.some(function (ignoredNode) {
return target === ignoredNode || ignoredNode.contains(target);
});
this.ignoreCheckCache.set(target, shouldBeIgnored);
return shouldBeIgnored;
}
}, {
key: "updateWhiteListNodes",
value: function updateWhiteListNodes() {
this.ignoreListNodes = _toConsumableArray(document.querySelectorAll(this.ignoreList.join(', ')));
}
}, {
key: "detectLeftButton",
value: function detectLeftButton(event) {
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) {
return false;
}
if ('buttons' in event) {
return event.buttons === 1;
}
if ('which' in event) {
return event.which === 1;
}
return event.button === 1;
}
}, {
key: "preventEvent",
value: function preventEvent(target, type) {
var preventHandler = function preventHandler(e) {
target.removeEventListener(type, preventHandler, true);
e.preventDefault();
e.stopPropagation();
};
target.addEventListener(type, preventHandler, true);
}
}, {
key: "handleClick",
value: function handleClick(e, top, left) {
var classNames = e.target.classList || [];
var isMouseUpOnClickElement = _toConsumableArray(classNames).indexOf(this.props.clickClassName) > -1;
if (this.props.allowClickWithoutSelected || this.selectedItems.size || isMouseUpOnClickElement || this.ctrlPressed) {
this.selectItems({
top: top,
left: left,
offsetWidth: 0,
offsetHeight: 0
}, {
click: true
});
this.props.onSelectionFinish(_toConsumableArray(this.selectedItems), this.clickedItem);
if (e.which === 1) {
this.preventEvent(e.target, 'click');
}
if (e.which === 2 || e.which === 3) {
this.preventEvent(e.target, 'contextmenu');
}
}
}
}, {
key: "cleanUp",
value: function cleanUp() {
this.deselectionStarted = false;
this.selectionStarted = false;
if (this.props.mixedDeselect) {
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
try {
for (var _iterator6 = this.registry.values()[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
var item = _step6.value;
item.deselected = false;
}
} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
_iterator6["return"]();
};
SelectableGroup.prototype.cleanUp = function () {
var e_6, _a;
this.deselectionStarted = false;
this.selectionStarted = false;
if (this.props.mixedDeselect) {
try {
for (var _b = __values(this.registry.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
var item = _c.value;
item.deselected = false;
}
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
catch (e_6_1) { e_6 = { error: e_6_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_6) throw e_6.error; }
}
}
}
}
}
/**
* Used to return event object with desktop (non-touch) format of event
* coordinates, regardless of whether the action is from mobile or desktop.
*/
}, {
key: "desktopEventCoords",
value: function desktopEventCoords(e) {
if (e.pageX === undefined || e.pageY === undefined) {
// Touch-device
if (e.targetTouches[0] !== undefined && e.targetTouches[0].pageX !== undefined) {
// For touchmove
e.pageX = e.targetTouches[0].pageX;
e.pageY = e.targetTouches[0].pageY;
} else if (e.changedTouches[0] !== undefined && e.changedTouches[0].pageX !== undefined) {
// For touchstart
e.pageX = e.changedTouches[0].pageX;
e.pageY = e.changedTouches[0].pageY;
}
}
return e;
}
}, {
key: "render",
value: function render() {
return _react["default"].createElement(_Context["default"].Provider, {
value: this.contextValue
}, _react["default"].createElement(this.props.component, {
ref: this.getGroupRef,
style: Object.assign({}, this.defaultContainerStyle, this.props.style),
className: "".concat(this.props.className, " ").concat(this.state.selectionMode ? this.props.selectionModeClass : '')
}, _react["default"].createElement(_Selectbox["default"], {
ref: this.getSelectboxRef,
fixedPosition: this.props.fixedPosition,
className: this.props.selectboxClassName
}), this.props.children));
}
}]);
return SelectableGroup;
}(_react.Component);
_defineProperty(SelectableGroup, "propTypes", {
globalMouse: _propTypes.bool,
ignoreList: _propTypes.array,
scrollSpeed: _propTypes.number,
minimumSpeedFactor: _propTypes.number,
allowClickWithoutSelected: _propTypes.bool,
className: _propTypes.string,
selectboxClassName: _propTypes.string,
style: _propTypes.object,
selectionModeClass: _propTypes.string,
onSelectionClear: _propTypes.func,
enableDeselect: _propTypes.bool,
mixedDeselect: _propTypes.bool,
deselectOnEsc: _propTypes.bool,
resetOnStart: _propTypes.bool,
disabled: _propTypes.bool,
delta: _propTypes.number,
/**
* Scroll container selector
*/
scrollContainer: _propTypes.string,
/**
* Event that will fire rapidly during selection (while the selector is
* being dragged). Passes an array of keys.
*/
duringSelection: _propTypes.func,
/**
* Event that will fire when items are selected. Passes an array of keys.
*/
onSelectionFinish: _propTypes.func,
/**
* The component that will represent the Selectable DOM node
*/
component: _propTypes.node,
/**
* Amount of forgiveness an item will offer to the selectbox before registering
* a selection, i.e. if only 1px of the item is in the selection, it shouldn't be
* included.
*/
tolerance: _propTypes.number,
/**
* In some cases, it the bounding box may need fixed positioning, if your layout
* is relying on fixed positioned elements, for instance.
* @type boolean
*/
fixedPosition: _propTypes.bool
});
_defineProperty(SelectableGroup, "defaultProps", {
component: 'div',
tolerance: 0,
globalMouse: false,
ignoreList: [],
scrollSpeed: 0.25,
minimumSpeedFactor: 60,
duringSelection: noop,
onSelectionFinish: noop,
onSelectionClear: noop,
allowClickWithoutSelected: true,
selectionModeClass: 'in-selection-mode',
resetOnStart: false,
disabled: false,
deselectOnEsc: true,
delta: 1
});
var _default = SelectableGroup;
exports["default"] = _default;
};
SelectableGroup.prototype.render = function () {
var selectionMode = this.state.selectionMode;
var _a = this.props, _b = _a.component, GroupComponent = _b === void 0 ? 'div' : _b, className = _a.className, style = _a.style, selectionModeClass = _a.selectionModeClass, fixedPosition = _a.fixedPosition, selectboxClassName = _a.selectboxClassName, children = _a.children;
return (react_1.default.createElement(Context_1.default.Provider, { value: this.contextValue },
react_1.default.createElement(GroupComponent, { ref: this.getGroupRef, style: Object.assign({}, this.defaultContainerStyle, style), className: className + " " + (selectionMode ? selectionModeClass : '') },
react_1.default.createElement(Selectbox_1.default, { ref: this.getSelectboxRef, className: selectboxClassName, fixedPosition: fixedPosition }),
children)));
};
SelectableGroup.defaultProps = {
clickClassName: '',
tolerance: 0,
globalMouse: false,
ignoreList: [],
scrollSpeed: 0.25,
minimumSpeedFactor: 60,
duringSelection: utils_1.noop,
onSelectionFinish: utils_1.noop,
onSelectionClear: utils_1.noop,
allowClickWithoutSelected: true,
selectionModeClass: 'in-selection-mode',
resetOnStart: false,
disabled: false,
deselectOnEsc: true,
fixedPosition: false,
delta: 1
};
return SelectableGroup;
}(react_1.Component));
exports.default = SelectableGroup;
//# sourceMappingURL=SelectableGroup.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = require("prop-types");
var _Context = _interopRequireDefault(require("./Context"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var SelectAllButton =
/*#__PURE__*/
function (_Component) {
_inherits(SelectAllButton, _Component);
function SelectAllButton() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, SelectAllButton);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var Context_1 = __importDefault(require("./Context"));
var SelectAllButton = (function (_super) {
__extends(SelectAllButton, _super);
function SelectAllButton() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.root = null;
_this.getRootRef = function (ref) {
_this.root = ref;
};
return _this;
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SelectAllButton)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_this), "getRootRef", function (c) {
return _this.root = c;
});
return _this;
}
_createClass(SelectAllButton, [{
key: "componentDidMount",
value: function componentDidMount() {
this.root.addEventListener('mousedown', function (e) {
return e.stopPropagation();
});
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
children = _this$props.children,
className = _this$props.className,
rest = _objectWithoutProperties(_this$props, ["children", "className"]);
return _react["default"].createElement(this.props.component, _extends({
ref: this.getRootRef,
className: "selectable-select-all ".concat(className),
onClick: this.context.selectable.selectAll
}, rest), children);
}
}]);
return SelectAllButton;
}(_react.Component);
_defineProperty(SelectAllButton, "contextType", _Context["default"]);
_defineProperty(SelectAllButton, "propTypes", {
children: _propTypes.node,
component: _propTypes.node
});
_defineProperty(SelectAllButton, "defaultProps", {
component: 'div'
});
var _default = SelectAllButton;
exports["default"] = _default;
SelectAllButton.prototype.componentDidMount = function () {
this.root.addEventListener('mousedown', function (evt) { return evt.stopPropagation(); });
};
SelectAllButton.prototype.render = function () {
var _a = this.props, _b = _a.component, ButtonComponent = _b === void 0 ? 'div' : _b, children = _a.children, _c = _a.className, className = _c === void 0 ? '' : _c, rest = __rest(_a, ["component", "children", "className"]);
return (react_1.default.createElement(ButtonComponent, __assign({ ref: this.getRootRef, className: "selectable-select-all " + className, onClick: this.context.selectable.selectAll }, rest), children));
};
SelectAllButton.contextType = Context_1.default;
return SelectAllButton;
}(react_1.Component));
exports.default = SelectAllButton;
//# sourceMappingURL=SelectAll.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = require("prop-types");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Selectbox =
/*#__PURE__*/
function (_Component) {
_inherits(Selectbox, _Component);
function Selectbox() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, Selectbox);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var Selectbox = (function (_super) {
__extends(Selectbox, _super);
function Selectbox() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.state = {
y: 0,
x: 0,
width: 0,
height: 0,
isSelecting: false
};
_this.selectbox = null;
_this.getRef = function () { return _this.selectbox; };
_this.getSelectboxRef = function (ref) {
_this.selectbox = ref;
};
return _this;
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Selectbox)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_this), "state", {
boxTop: 0,
boxLeft: 0,
boxWidth: 0,
boxHeight: 0,
isBoxSelecting: false
});
_defineProperty(_assertThisInitialized(_this), "getRef", function () {
return _this.selectbox;
});
_defineProperty(_assertThisInitialized(_this), "getSelectboxRef", function (c) {
return _this.selectbox = c;
});
return _this;
}
_createClass(Selectbox, [{
key: "render",
value: function render() {
var boxStyle = {
left: this.state.boxLeft,
top: this.state.boxTop,
width: this.state.boxWidth,
height: this.state.boxHeight,
zIndex: 9000,
position: this.props.fixedPosition ? 'fixed' : 'absolute',
cursor: 'default'
};
return _react["default"].createElement("div", null, this.state.isBoxSelecting && _react["default"].createElement("div", {
ref: this.getSelectboxRef,
style: boxStyle,
className: this.props.className
}));
}
}]);
return Selectbox;
}(_react.Component);
_defineProperty(Selectbox, "propTypes", {
fixedPosition: _propTypes.bool,
className: _propTypes.string
});
_defineProperty(Selectbox, "defaultProps", {
className: 'selectable-selectbox'
});
var _default = Selectbox;
exports["default"] = _default;
Selectbox.prototype.render = function () {
var _a = this.props, fixedPosition = _a.fixedPosition, className = _a.className;
var boxStyle = {
left: this.state.x,
top: this.state.y,
width: this.state.width,
height: this.state.height,
zIndex: 9000,
position: fixedPosition ? 'fixed' : 'absolute',
cursor: 'default'
};
return (react_1.default.createElement("div", null, this.state.isSelecting && (react_1.default.createElement("div", { ref: this.getSelectboxRef, style: boxStyle, className: className }))));
};
Selectbox.defaultProps = {
className: 'selectable-selectbox'
};
return Selectbox;
}(react_1.Component));
exports.default = Selectbox;
//# sourceMappingURL=Selectbox.js.map
{
"name": "react-selectable-fast",
"version": "2.3.1",
"version": "3.0.0",
"description": "Enable other React components to be selectable by drawing a box with your mouse/touch",

@@ -12,23 +12,33 @@ "repository": {

"clean": "rimraf ./lib ./dist",
"watch:example": "webpack-dev-server --config ./example/webpack.config.js --content-base example",
"build:example": "webpack --config ./example/webpack.config.js --mode production",
"watch": "webpack --watch",
"build": "webpack",
"transpile": "babel ./src/ -d ./lib/",
"build:prod": "cross-env NODE_ENV=production webpack --config webpack.production.config.js",
"prepublish": "npm run lint && npm run clean && npm run build:prod && npm run transpile",
"prettier": "npx prettier --write src/**/*.js example/**/*.js *.js",
"lint": "npx eslint --fix --ext js .",
"format": "npm run prettier && npm run lint"
"transpile": "tsc",
"build:prod": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"prepublishOnly": "yarn lint && yarn clean && yarn build:prod && yarn transpile",
"prettier": "prettier --write src/**/*.{js,ts,tsx} example/src/**/*.{js,ts,tsx} .js",
"lint:basic": "tsc --pretty --noEmit && tslint --fix --format codeFrame",
"lint": "yarn lint:basic --project ./tsconfig.json 'src/**/*.{ts,tsx} example/src/**/*.{ts,tsx}'",
"format": "yarn prettier && yarn lint",
"test": "yarn lint",
"watch:example": "webpack-dev-server --config ./example/webpack.config.example.js --content-base website",
"build:example": "webpack --config ./example/webpack.config.example.js --mode production"
},
"lint-staged": {
"*.js": [
"*.{js,ts,tsx}": [
"prettier --write",
"eslint --fix",
"yarn lint:basic",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"bugs": {
"url": "https://github.com/valerybugakov/react-selectable-fast/issues"
},
"engines": {
"node": ">8.0.0"
},
"keywords": [

@@ -45,3 +55,6 @@ "selectable",

],
"author": "Valery Bugakov <skymk1@gmail.com>",
"author": "Valery Bugakov <skymk1@gmail.com> (https://github.com/valerybugakov/)",
"contributors": [
"Valery Bugakov <skymk1@gmail.com> (https://github.com/valerybugakov/)"
],
"license": "MIT",

@@ -66,13 +79,9 @@ "files": [

"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.2",
"@babel/preset-typescript": "^7.3.3",
"@types/react": "^16.9.1",
"@types/react-dom": "^16.8.5",
"babel-loader": "^8.0.6",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"cross-env": "^5.2.0",
"eslint": "^6.0.1",
"eslint-config-airbnb": "^17.1.1",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.2",
"husky": "^3.0.0",
"husky": "^3.0.3",
"lint-staged": "^9.2.0",

@@ -84,2 +93,7 @@ "prettier": "^1.18.2",

"rimraf": "^2.6.3",
"tslint": "^5.18.0",
"tslint-config-airbnb": "^5.11.1",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.0.0",
"typescript": "^3.5.3",
"webpack": "^4.36.1",

@@ -89,8 +103,3 @@ "webpack-bundle-analyzer": "^3.3.2",

"webpack-dev-server": "^3.7.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}

@@ -7,3 +7,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)

http://valerybugakov.github.io/react-selectable-fast
https://react-selectable-fast.now.sh

@@ -25,6 +25,11 @@ ## Install

Package exports 4 entities `{ SelectableGroup, createSelectable, SelectAll, DeselectAll }`.
Package exports 5 entities
```ts
export { TSelectableItemProps, SelectableGroup, createSelectable, SelectAll, DeselectAll }
```
To make other components selectable wrap them using HoC `createSelectable`, add passed `selectableRef` prop to the target node and put a list of seletable items under `SelectableGroup`.
```js
```ts
import React, { Component } from 'react'

@@ -57,12 +62,18 @@ import { SelectableGroup } from 'react-selectable-fast'

```js
```ts
import React from 'react'
import { createSelectable } from 'react-selectable-fast'
import { TSelectableItemProps, createSelectable } from 'react-selectable-fast'
const SomeComponent = ({ selectableRef, selected, selecting }) => <div ref={selectableRef}>...</div>
class SomeComponent extends Component<TSelectableItemProps> {
render() {
const { selectableRef, isSelected, isSelecting } = this.props
return <div ref={selectableRef}>...</div>
}
}
export default createSelectable(SomeComponent)
```
```js
```ts
import React from 'react'

@@ -81,3 +92,3 @@ import { SelectAll, DeselectAll } from 'react-selectable-fast'

{this.props.items.map((item, i) => (
<SelectableComponent key={i} title={item.title} year={item.year} />
<SelectableComponent key={i} player={item.player} year={item.year} />
))}

@@ -100,5 +111,5 @@ </div>

A polyfilled environment for React-Selectable-Fast using [core-js](https://github.com/zloirock/core-js) to support older browsers
might look like:
might look like this:
```js
```ts
import 'core-js/fn/object/assign'

@@ -105,0 +116,0 @@ import 'core-js/fn/array/from'

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc