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 3.1.0 to 3.1.1

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=2)}([function(t,o){t.exports=e},function(e,t){},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n),l=["pageX","pageY","clientX","clientY"];function i(e,t){l.forEach((function(o){void 0===e[o]&&(e[o]=e[t][0][o])}))}function c(e){if(e.type.includes("mouse"))return e;try{"touchstart"===e.type?i(e,"targetTouches"):"touchmove"===e.type&&i(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},o=t.scrollTop,n=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)},l=r.documentScrollTop,i=r.documentScrollLeft,c=e.getBoundingClientRect();return{top:c.top+l+o,left:c.left+i+n,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,width:c.width,height:c.height}}var a=function(e,t,o){var n=o.tolerance,r=void 0===n?0:n,l=o.useOffsetSize,i=void 0!==l&&l,c=i?e.offsetHeight:e.height,s=i?t.offsetHeight:t.height,a=i?e.offsetWidth:e.width,u=i?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 o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=e instanceof HTMLElement?s(e):e,l=t instanceof HTMLElement?s(t):t;return a(r,l,{tolerance:o,useOffsetSize:1===n})}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 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 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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var S=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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=m(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==h(r)&&"function"!=typeof r?b(n):r,g(b(o),"state",{y:0,x:0,width:0,height:0,isSelecting:!1}),g(b(o),"selectbox",null),g(b(o),"getRef",(function(){return o.selectbox})),g(b(o),"getSelectboxRef",(function(e){o.selectbox=e})),o}var o,n,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,e),o=t,(n=[{key:"render",value:function(){var e=this.props,t=e.fixedPosition,o=e.className,n={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:n,className:o}))}}])&&y(o.prototype,n),l&&y(o,l),t}(n.Component);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 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 j(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 C(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 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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var I=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 l=arguments.length,i=new Array(l),a=0;a<l;a++)i[a]=arguments[a];return n=this,r=(e=k(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==O(r)&&"function"!=typeof r?L(n):r,P(L(o),"state",{selectionMode:!1}),P(L(o),"mouseDownStarted",!1),P(L(o),"mouseMoveStarted",!1),P(L(o),"mouseMoved",!1),P(L(o),"mouseUpStarted",!1),P(L(o),"selectionStarted",!1),P(L(o),"deselectionStarted",!1),P(L(o),"clickedItem",void 0),P(L(o),"mouseDownData",{selectboxY:0,selectboxX:0,target:null}),P(L(o),"registry",new Set),P(L(o),"selectedItems",new Set),P(L(o),"selectingItems",new Set),P(L(o),"ignoreCheckCache",new Map),P(L(o),"ignoreList",o.props.ignoreList.concat([".selectable-select-all",".selectable-deselect-all"])),P(L(o),"ignoreListNodes",[]),P(L(o),"selectbox",null),P(L(o),"selectableGroup",null),P(L(o),"scrollContainer",null),P(L(o),"maxScrollTop",0),P(L(o),"maxScrollLeft",0),P(L(o),"scrollBounds",null),P(L(o),"updateRegistry",(function(){var e={scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft},t=!0,n=!1,r=void 0;try{for(var l,i=o.registry.values()[Symbol.iterator]();!(t=(l=i.next()).done);t=!0){l.value.registerSelectable(e)}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}})),P(L(o),"registerSelectable",(function(e){o.registry.add(e),e.state.isSelected&&o.selectedItems.add(e)})),P(L(o),"unregisterSelectable",(function(e){o.registry.delete(e),o.selectedItems.delete(e),o.selectingItems.delete(e),o.props.onSelectionFinish(j(o.selectedItems))})),P(L(o),"updateContainerScroll",(function(e){var t=o.scrollContainer,n=t.scrollTop,r=t.scrollLeft;o.checkScrollTop(e.clientY,n),o.checkScrollBottom(e.clientY,n),o.checkScrollLeft(e.clientX,r),o.checkScrollRight(e.clientX,r)})),P(L(o),"getScrollStep",(function(e){var t=o.props,n=t.minimumSpeedFactor,r=t.scrollSpeed;return Math.max(e,n)*r})),P(L(o),"checkScrollTop",(function(e,t){var n=o.scrollBounds.top-e;(n>0||e<0)&&(o.scrollContainer.scrollTop=t-o.getScrollStep(n))})),P(L(o),"checkScrollBottom",(function(e,t){var n=e-o.scrollBounds.bottom;if(n>0||e>window.innerHeight){var r=t+o.getScrollStep(n);o.scrollContainer.scrollTop=Math.min(r,o.maxScrollTop)}})),P(L(o),"checkScrollLeft",(function(e,t){var n=o.scrollBounds.left-e;if(n>0||e<0){var r=t-o.getScrollStep(n);o.scrollContainer.scrollLeft=r}})),P(L(o),"checkScrollRight",(function(e,t){var n=e-o.scrollBounds.right;if(n>0||e>window.innerWidth){var r=t+o.getScrollStep(n);o.scrollContainer.scrollLeft=Math.min(r,o.maxScrollLeft)}})),P(L(o),"updateSelectBox",(function(e){var t=c(e);if(o.updateContainerScroll(t),!o.mouseMoveStarted){o.mouseMoveStarted=!0,o.mouseMoved=!0;var n=L(o).mouseDownData,r=t.clientX,l=t.clientY,i=o.scrollContainer,s=i.scrollLeft,a=i.scrollTop,u=l-o.scrollBounds.top+a,f=Math.min(u,n.selectboxY),p=r-o.scrollBounds.left+s,d=Math.min(p,n.selectboxX);o.selectbox.setState({x:d,y:f,isSelecting:!0,width:Math.abs(p-n.selectboxX),height:Math.abs(u-n.selectboxY)},(function(){o.updateSelecting(),o.props.duringSelection(j(o.selectingItems)),o.mouseMoveStarted=!1}))}})),P(L(o),"updateSelecting",(function(){var e=o.selectbox.getRef();if(e){var t=s(e);o.selectItems(function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?x(Object(o),!0).forEach((function(t){P(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):x(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}})),P(L(o),"selectItems",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=o.props,r=n.tolerance,l=n.enableDeselect,i=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({item:p,selectboxBounds:e,tolerance:r,mixedDeselect:i,enableDeselect:l,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(o),"clearSelection",(function(){var e=!0,t=!1,n=void 0;try{for(var r,l=o.selectedItems.values()[Symbol.iterator]();!(e=(r=l.next()).done);e=!0){var i=r.value;i.setState({isSelected:!1}),o.selectedItems.delete(i)}}catch(e){t=!0,n=e}finally{try{e||null==l.return||l.return()}finally{if(t)throw n}}o.setState({selectionMode:!1}),o.props.onSelectionFinish(j(o.selectedItems)),o.props.onSelectionClear()})),P(L(o),"selectAll",(function(){o.updateWhiteListNodes();var e=!0,t=!1,n=void 0;try{for(var r,l=o.registry.values()[Symbol.iterator]();!(e=(r=l.next()).done);e=!0){var i=r.value;o.isInIgnoreList(i.node)||i.state.isSelected||(i.setState({isSelected:!0}),o.selectedItems.add(i))}}catch(e){t=!0,n=e}finally{try{e||null==l.return||l.return()}finally{if(t)throw n}}o.setState({selectionMode:!0}),o.props.onSelectionFinish(j(o.selectedItems))})),P(L(o),"mouseDown",(function(e){var t=!e.type.includes("touch")&&!function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey&&!o.allowShiftClick)&&("buttons"in e?e.buttons===t:"which"in e?e.which===t:e.button===t-1)}(e,1,{allowShiftClick:o.props.allowShiftClick});if(!(o.mouseDownStarted||o.props.disabled||t))if(o.updateWhiteListNodes(),o.isInIgnoreList(e.target))o.mouseDownStarted=!1;else{o.props.resetOnStart&&o.clearSelection(),o.mouseDownStarted=!0,o.mouseUpStarted=!1;var n=c(e);if(!o.props.globalMouse&&!f(n.target,o.selectableGroup)){var r=s(o.selectableGroup);if(!u({top:r.top,left:r.left,width:0,height:0,offsetHeight:r.offsetHeight,offsetWidth:r.offsetWidth},{top:n.pageY,left:n.pageX,width:0,height:0,offsetWidth:0,offsetHeight:0}))return}o.updateRootBounds(),o.updateRegistry(),o.mouseDownData={target:n.target,selectboxY:n.clientY-o.scrollBounds.top+o.scrollContainer.scrollTop,selectboxX:n.clientX-o.scrollBounds.left+o.scrollContainer.scrollLeft},n.preventDefault(),document.addEventListener("mousemove",o.updateSelectBox),document.addEventListener("touchmove",o.updateSelectBox),document.addEventListener("mouseup",o.mouseUp),document.addEventListener("touchend",o.mouseUp)}})),P(L(o),"mouseUp",(function(e){if(!o.mouseUpStarted&&(o.mouseUpStarted=!0,o.mouseDownStarted=!1,o.removeTempEventListeners(),o.mouseDownData)){var t=c(e),n=t.pageX,r=t.pageY;if(!o.mouseMoved&&f(t.target,o.selectableGroup))o.handleClick(t,r,n);else{var l=!0,i=!1,s=void 0;try{for(var a,u=o.selectingItems.values()[Symbol.iterator]();!(l=(a=u.next()).done);l=!0){a.value.setState({isSelected:!0,isSelecting:!1})}}catch(e){i=!0,s=e}finally{try{l||null==u.return||u.return()}finally{if(i)throw s}}o.selectedItems=new Set([].concat(j(o.selectedItems),j(o.selectingItems))),o.selectingItems.clear(),1===t.which&&o.mouseDownData.target===t.target&&o.preventEvent(t.target,"click"),o.selectbox.setState({isSelecting:!1,width:0,height:0}),o.props.onSelectionFinish(j(o.selectedItems))}o.toggleSelectionMode(),o.cleanUp(),o.mouseMoved=!1}})),P(L(o),"keyListener",(function(e){27===e.keyCode&&o.clearSelection()})),P(L(o),"getGroupRef",(function(e){o.selectableGroup=e})),P(L(o),"getSelectboxRef",(function(e){o.selectbox=e})),P(L(o),"defaultContainerStyle",{position:"relative"}),P(L(o),"contextValue",{selectable:{register:o.registerSelectable,unregister:o.unregisterSelectable,selectAll:o.selectAll,clearSelection:o.clearSelection,getScrolledContainer:function(){return o.scrollContainer}}}),o}var o,n,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,e),o=t,(n=[{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,o=e.tolerance,n=e.selectboxBounds,r=e.enableDeselect,l=e.mixedDeselect,i=e.isFromClick;if(this.isInIgnoreList(t.node))return null;var c=u(n,t.bounds,o,this.props.delta),s=t.state,a=s.isSelecting,f=s.isSelected;if(i&&c)return f?this.selectedItems.delete(t):this.selectedItems.add(t),t.setState({isSelected:!f}),this.clickedItem=t;if(!i&&c){if(f&&r&&(!this.selectionStarted||l))return t.setState({isSelected:!1}),t.deselected=!0,this.deselectionStarted=!0,this.selectedItems.delete(t);var p=l?!t.deselected:!this.deselectionStarted;if(!a&&!f&&p)return t.setState({isSelecting:!0}),this.selectionStarted=!0,this.selectingItems.add(t),{updateSelecting:!0}}return!i&&!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 o(n){e.removeEventListener(t,o,!0),n.preventDefault(),n.stopPropagation()}),!0)}},{key:"handleClick",value:function(e,t,o){if(this.props.selectOnClick){var n=this.props,r=n.clickClassName,l=n.allowClickWithoutSelected,i=n.onSelectionFinish,c=e.target.classList||[],s=Array.from(c).indexOf(r)>-1;(l||this.selectedItems.size||s||e.ctrlKey)&&(this.selectItems({top:t,left:o,width:0,height:0,offsetWidth:0,offsetHeight:0},{isFromClick:!0}),i(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,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:"render",value:function(){var e=this.state.selectionMode,t=this.props,o=t.component,n=void 0===o?"div":o,l=t.className,i=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(n,{ref:this.getGroupRef,style:Object.assign({},this.defaultContainerStyle,i),className:"".concat(l," ").concat(e?c:"")},r.a.createElement(w,{ref:this.getSelectboxRef,className:a,fixedPosition:s}),u))}}])&&C(o.prototype,n),l&&C(o,l),t}(n.Component);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,allowShiftClick:!1,selectOnClick:!0});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 o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e}).apply(this,arguments)}function D(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 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,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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=R(o)).call.apply(e,[this].concat(i)),t=!r||"object"!==T(r)&&"function"!=typeof r?B(n):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 n,l,i;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)}(o,t),n=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,M({},this.props,this.state,{selectableRef:this.getSelectableRef}))}}])&&D(n.prototype,l),i&&D(n,i),o}(n.Component),A(t,"contextType",d),A(t,"defaultProps",{isSelected:!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 F(){return(F=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 G(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function U(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 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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var q=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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=X(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==H(r)&&"function"!=typeof r?Y(n):r,K(Y(o),"root",null),K(Y(o),"getRootRef",(function(e){o.root=e})),o}var o,n,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,e),o=t,(n=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",(function(e){return e.stopPropagation()}))}},{key:"render",value:function(){var e=this.props,t=e.component,o=void 0===t?"div":t,n=e.children,l=e.className,i=void 0===l?"":l,c=G(e,["component","children","className"]);return r.a.createElement(o,F({ref:this.getRootRef,className:"selectable-select-all ".concat(i),onClick:this.context.selectable.selectAll},c),n)}}])&&U(o.prototype,n),l&&U(o,l),t}(n.Component);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 o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e}).apply(this,arguments)}function Z(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function $(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 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 oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ne(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var re=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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=ee(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==J(r)&&"function"!=typeof r?te(n):r,ne(te(o),"root",null),ne(te(o),"getRootRef",(function(e){o.root=e})),o}var o,n,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&&oe(e,t)}(t,e),o=t,(n=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",(function(e){return e.stopPropagation()}))}},{key:"render",value:function(){var e=this.props,t=e.component,o=void 0===t?"div":t,n=e.children,l=e.className,i=Z(e,["component","children","className"]);return r.a.createElement(o,Q({ref:this.getRootRef,className:"selectable-select-all ".concat(l),onClick:this.context.selectable.clearSelection},i),n)}}])&&$(o.prototype,n),l&&$(o,l),t}(n.Component);ne(re,"contextType",d);var le=re,ie=o(1);o.d(t,"TSelectableItemProps",(function(){return ie.TSelectableItemProps})),o.d(t,"SelectableGroup",(function(){return _})),o.d(t,"createSelectable",(function(){return W})),o.d(t,"SelectAll",(function(){return V})),o.d(t,"DeselectAll",(function(){return le}))}])}));
!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=2)}([function(t,o){t.exports=e},function(e,t){},function(e,t,o){"use strict";o.r(t);var n=o(0),r=o.n(n),l=["pageX","pageY","clientX","clientY"];function i(e,t){l.forEach((function(o){void 0===e[o]&&(e[o]=e[t][0][o])}))}function c(e){if(e.type.includes("mouse"))return e;try{"touchstart"===e.type?i(e,"targetTouches"):"touchmove"===e.type&&i(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},o=t.scrollTop,n=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)},l=r.documentScrollTop,i=r.documentScrollLeft,c=e.getBoundingClientRect();return{top:c.top+l+o,left:c.left+i+n,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,width:c.width,height:c.height}}var a=function(e,t,o){var n=o.tolerance,r=void 0===n?0:n,l=o.useOffsetSize,i=void 0!==l&&l,c=i?e.offsetHeight:e.height,s=i?t.offsetHeight:t.height,a=i?e.offsetWidth:e.width,u=i?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 o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r=e instanceof HTMLElement?s(e):e,l=t instanceof HTMLElement?s(t):t;return a(r,l,{tolerance:o,useOffsetSize:1===n})}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 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 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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var S=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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=m(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==h(r)&&"function"!=typeof r?b(n):r,g(b(o),"state",{y:0,x:0,width:0,height:0,isSelecting:!1}),g(b(o),"selectbox",null),g(b(o),"getRef",(function(){return o.selectbox})),g(b(o),"getSelectboxRef",(function(e){o.selectbox=e})),o}var o,n,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,e),o=t,(n=[{key:"render",value:function(){var e=this.props,t=e.fixedPosition,o=e.className,n={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:n,className:o}))}}])&&y(o.prototype,n),l&&y(o,l),t}(n.Component);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 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 j(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 C(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 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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var I=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 l=arguments.length,i=new Array(l),a=0;a<l;a++)i[a]=arguments[a];return n=this,r=(e=k(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==O(r)&&"function"!=typeof r?L(n):r,P(L(o),"state",{selectionMode:!1}),P(L(o),"mouseDownStarted",!1),P(L(o),"mouseMoveStarted",!1),P(L(o),"mouseMoved",!1),P(L(o),"mouseUpStarted",!1),P(L(o),"selectionStarted",!1),P(L(o),"deselectionStarted",!1),P(L(o),"clickedItem",void 0),P(L(o),"mouseDownData",{selectboxY:0,selectboxX:0,target:null}),P(L(o),"registry",new Set),P(L(o),"selectedItems",new Set),P(L(o),"selectingItems",new Set),P(L(o),"ignoreCheckCache",new Map),P(L(o),"ignoreList",o.props.ignoreList.concat([".selectable-select-all",".selectable-deselect-all"])),P(L(o),"ignoreListNodes",[]),P(L(o),"selectbox",null),P(L(o),"selectableGroup",null),P(L(o),"scrollContainer",null),P(L(o),"maxScrollTop",0),P(L(o),"maxScrollLeft",0),P(L(o),"scrollBounds",null),P(L(o),"updateRegistry",(function(){var e={scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft},t=!0,n=!1,r=void 0;try{for(var l,i=o.registry.values()[Symbol.iterator]();!(t=(l=i.next()).done);t=!0){l.value.registerSelectable(e)}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}})),P(L(o),"registerSelectable",(function(e){o.registry.add(e),e.state.isSelected&&o.selectedItems.add(e)})),P(L(o),"unregisterSelectable",(function(e){o.registry.delete(e);var t=o.selectedItems.has(e)||o.selectingItems.has(e);o.selectedItems.delete(e),o.selectingItems.delete(e),t&&o.props.onSelectionFinish(j(o.selectedItems))})),P(L(o),"updateContainerScroll",(function(e){var t=o.scrollContainer,n=t.scrollTop,r=t.scrollLeft;o.checkScrollTop(e.clientY,n),o.checkScrollBottom(e.clientY,n),o.checkScrollLeft(e.clientX,r),o.checkScrollRight(e.clientX,r)})),P(L(o),"getScrollStep",(function(e){var t=o.props,n=t.minimumSpeedFactor,r=t.scrollSpeed;return Math.max(e,n)*r})),P(L(o),"checkScrollTop",(function(e,t){var n=o.scrollBounds.top-e;(n>0||e<0)&&(o.scrollContainer.scrollTop=t-o.getScrollStep(n))})),P(L(o),"checkScrollBottom",(function(e,t){var n=e-o.scrollBounds.bottom;if(n>0||e>window.innerHeight){var r=t+o.getScrollStep(n);o.scrollContainer.scrollTop=Math.min(r,o.maxScrollTop)}})),P(L(o),"checkScrollLeft",(function(e,t){var n=o.scrollBounds.left-e;if(n>0||e<0){var r=t-o.getScrollStep(n);o.scrollContainer.scrollLeft=r}})),P(L(o),"checkScrollRight",(function(e,t){var n=e-o.scrollBounds.right;if(n>0||e>window.innerWidth){var r=t+o.getScrollStep(n);o.scrollContainer.scrollLeft=Math.min(r,o.maxScrollLeft)}})),P(L(o),"updateSelectBox",(function(e){var t=c(e);if(o.updateContainerScroll(t),!o.mouseMoveStarted){o.mouseMoveStarted=!0,o.mouseMoved=!0;var n=L(o).mouseDownData,r=t.clientX,l=t.clientY,i=o.scrollContainer,s=i.scrollLeft,a=i.scrollTop,u=l-o.scrollBounds.top+a,f=Math.min(u,n.selectboxY),p=r-o.scrollBounds.left+s,d=Math.min(p,n.selectboxX);o.selectbox.setState({x:d,y:f,isSelecting:!0,width:Math.abs(p-n.selectboxX),height:Math.abs(u-n.selectboxY)},(function(){o.updateSelecting(),o.props.duringSelection(j(o.selectingItems)),o.mouseMoveStarted=!1}))}})),P(L(o),"updateSelecting",(function(){var e=o.selectbox.getRef();if(e){var t=s(e);o.selectItems(function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?x(Object(o),!0).forEach((function(t){P(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):x(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}})),P(L(o),"selectItems",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=o.props,r=n.tolerance,l=n.enableDeselect,i=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({item:p,selectboxBounds:e,tolerance:r,mixedDeselect:i,enableDeselect:l,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(o),"clearSelection",(function(){var e=!0,t=!1,n=void 0;try{for(var r,l=o.selectedItems.values()[Symbol.iterator]();!(e=(r=l.next()).done);e=!0){var i=r.value;i.setState({isSelected:!1}),o.selectedItems.delete(i)}}catch(e){t=!0,n=e}finally{try{e||null==l.return||l.return()}finally{if(t)throw n}}o.setState({selectionMode:!1}),o.props.onSelectionFinish(j(o.selectedItems)),o.props.onSelectionClear()})),P(L(o),"selectAll",(function(){o.updateWhiteListNodes();var e=!0,t=!1,n=void 0;try{for(var r,l=o.registry.values()[Symbol.iterator]();!(e=(r=l.next()).done);e=!0){var i=r.value;o.isInIgnoreList(i.node)||i.state.isSelected||(i.setState({isSelected:!0}),o.selectedItems.add(i))}}catch(e){t=!0,n=e}finally{try{e||null==l.return||l.return()}finally{if(t)throw n}}o.setState({selectionMode:!0}),o.props.onSelectionFinish(j(o.selectedItems))})),P(L(o),"mouseDown",(function(e){var t=!e.type.includes("touch")&&!function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey&&!o.allowShiftClick)&&("buttons"in e?e.buttons===t:"which"in e?e.which===t:e.button===t-1)}(e,1,{allowShiftClick:o.props.allowShiftClick});if(!(o.mouseDownStarted||o.props.disabled||t))if(o.updateWhiteListNodes(),o.isInIgnoreList(e.target))o.mouseDownStarted=!1;else{o.props.resetOnStart&&o.clearSelection(),o.mouseDownStarted=!0,o.mouseUpStarted=!1;var n=c(e);if(!o.props.globalMouse&&!f(n.target,o.selectableGroup)){var r=s(o.selectableGroup);if(!u({top:r.top,left:r.left,width:0,height:0,offsetHeight:r.offsetHeight,offsetWidth:r.offsetWidth},{top:n.pageY,left:n.pageX,width:0,height:0,offsetWidth:0,offsetHeight:0}))return}o.updateRootBounds(),o.updateRegistry(),o.mouseDownData={target:n.target,selectboxY:n.clientY-o.scrollBounds.top+o.scrollContainer.scrollTop,selectboxX:n.clientX-o.scrollBounds.left+o.scrollContainer.scrollLeft},n.preventDefault(),document.addEventListener("mousemove",o.updateSelectBox),document.addEventListener("touchmove",o.updateSelectBox),document.addEventListener("mouseup",o.mouseUp),document.addEventListener("touchend",o.mouseUp)}})),P(L(o),"mouseUp",(function(e){if(!o.mouseUpStarted&&(o.mouseUpStarted=!0,o.mouseDownStarted=!1,o.removeTempEventListeners(),o.mouseDownData)){var t=c(e),n=t.pageX,r=t.pageY;if(!o.mouseMoved&&f(t.target,o.selectableGroup))o.handleClick(t,r,n);else{var l=!0,i=!1,s=void 0;try{for(var a,u=o.selectingItems.values()[Symbol.iterator]();!(l=(a=u.next()).done);l=!0){a.value.setState({isSelected:!0,isSelecting:!1})}}catch(e){i=!0,s=e}finally{try{l||null==u.return||u.return()}finally{if(i)throw s}}o.selectedItems=new Set([].concat(j(o.selectedItems),j(o.selectingItems))),o.selectingItems.clear(),1===t.which&&o.mouseDownData.target===t.target&&o.preventEvent(t.target,"click"),o.selectbox.setState({isSelecting:!1,width:0,height:0}),o.props.onSelectionFinish(j(o.selectedItems))}o.toggleSelectionMode(),o.cleanUp(),o.mouseMoved=!1}})),P(L(o),"keyListener",(function(e){27===e.keyCode&&o.clearSelection()})),P(L(o),"getGroupRef",(function(e){o.selectableGroup=e})),P(L(o),"getSelectboxRef",(function(e){o.selectbox=e})),P(L(o),"defaultContainerStyle",{position:"relative"}),P(L(o),"contextValue",{selectable:{register:o.registerSelectable,unregister:o.unregisterSelectable,selectAll:o.selectAll,clearSelection:o.clearSelection,getScrolledContainer:function(){return o.scrollContainer}}}),o}var o,n,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,e),o=t,(n=[{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,o=e.tolerance,n=e.selectboxBounds,r=e.enableDeselect,l=e.mixedDeselect,i=e.isFromClick;if(this.isInIgnoreList(t.node))return null;var c=u(n,t.bounds,o,this.props.delta),s=t.state,a=s.isSelecting,f=s.isSelected;if(i&&c)return f?this.selectedItems.delete(t):this.selectedItems.add(t),t.setState({isSelected:!f}),this.clickedItem=t;if(!i&&c){if(f&&r&&(!this.selectionStarted||l))return t.setState({isSelected:!1}),t.deselected=!0,this.deselectionStarted=!0,this.selectedItems.delete(t);var p=l?!t.deselected:!this.deselectionStarted;if(!a&&!f&&p)return t.setState({isSelecting:!0}),this.selectionStarted=!0,this.selectingItems.add(t),{updateSelecting:!0}}return!i&&!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 o(n){e.removeEventListener(t,o,!0),n.preventDefault(),n.stopPropagation()}),!0)}},{key:"handleClick",value:function(e,t,o){if(this.props.selectOnClick){var n=this.props,r=n.clickClassName,l=n.allowClickWithoutSelected,i=n.onSelectionFinish,c=e.target.classList||[],s=Array.from(c).indexOf(r)>-1;(l||this.selectedItems.size||s||e.ctrlKey)&&(this.selectItems({top:t,left:o,width:0,height:0,offsetWidth:0,offsetHeight:0},{isFromClick:!0}),i(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,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:"render",value:function(){var e=this.state.selectionMode,t=this.props,o=t.component,n=void 0===o?"div":o,l=t.className,i=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(n,{ref:this.getGroupRef,style:Object.assign({},this.defaultContainerStyle,i),className:"".concat(l," ").concat(e?c:"")},r.a.createElement(w,{ref:this.getSelectboxRef,className:a,fixedPosition:s}),u))}}])&&C(o.prototype,n),l&&C(o,l),t}(n.Component);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,allowShiftClick:!1,selectOnClick:!0});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 o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e}).apply(this,arguments)}function D(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 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,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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=R(o)).call.apply(e,[this].concat(i)),t=!r||"object"!==T(r)&&"function"!=typeof r?B(n):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 n,l,i;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)}(o,t),n=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,M({},this.props,this.state,{selectableRef:this.getSelectableRef}))}}])&&D(n.prototype,l),i&&D(n,i),o}(n.Component),A(t,"contextType",d),A(t,"defaultProps",{isSelected:!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 F(){return(F=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 G(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function U(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 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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var q=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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=X(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==H(r)&&"function"!=typeof r?Y(n):r,K(Y(o),"root",null),K(Y(o),"getRootRef",(function(e){o.root=e})),o}var o,n,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,e),o=t,(n=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",(function(e){return e.stopPropagation()}))}},{key:"render",value:function(){var e=this.props,t=e.component,o=void 0===t?"div":t,n=e.children,l=e.className,i=void 0===l?"":l,c=G(e,["component","children","className"]);return r.a.createElement(o,F({ref:this.getRootRef,className:"selectable-select-all ".concat(i),onClick:this.context.selectable.selectAll},c),n)}}])&&U(o.prototype,n),l&&U(o,l),t}(n.Component);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 o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e}).apply(this,arguments)}function Z(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)o=l[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function $(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 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 oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ne(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var re=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 l=arguments.length,i=new Array(l),c=0;c<l;c++)i[c]=arguments[c];return n=this,r=(e=ee(t)).call.apply(e,[this].concat(i)),o=!r||"object"!==J(r)&&"function"!=typeof r?te(n):r,ne(te(o),"root",null),ne(te(o),"getRootRef",(function(e){o.root=e})),o}var o,n,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&&oe(e,t)}(t,e),o=t,(n=[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",(function(e){return e.stopPropagation()}))}},{key:"render",value:function(){var e=this.props,t=e.component,o=void 0===t?"div":t,n=e.children,l=e.className,i=Z(e,["component","children","className"]);return r.a.createElement(o,Q({ref:this.getRootRef,className:"selectable-select-all ".concat(l),onClick:this.context.selectable.clearSelection},i),n)}}])&&$(o.prototype,n),l&&$(o,l),t}(n.Component);ne(re,"contextType",d);var le=re,ie=o(1);o.d(t,"TSelectableItemProps",(function(){return ie.TSelectableItemProps})),o.d(t,"SelectableGroup",(function(){return _})),o.d(t,"createSelectable",(function(){return W})),o.d(t,"SelectAll",(function(){return V})),o.d(t,"DeselectAll",(function(){return le}))}])}));
//# sourceMappingURL=react-selectable-fast.js.map

@@ -128,5 +128,8 @@ "use strict";

_this.registry.delete(selectableItem);
var isHandled = _this.selectedItems.has(selectableItem) || _this.selectingItems.has(selectableItem);
_this.selectedItems.delete(selectableItem);
_this.selectingItems.delete(selectableItem);
_this.props.onSelectionFinish(__spread(_this.selectedItems));
if (isHandled) {
_this.props.onSelectionFinish(__spread(_this.selectedItems));
}
};

@@ -133,0 +136,0 @@ _this.updateContainerScroll = function (evt) {

{
"name": "react-selectable-fast",
"version": "3.1.0",
"version": "3.1.1",
"description": "Enable other React components to be selectable by drawing a box with your mouse/touch",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

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