react-selectable-fast
Advanced tools
Comparing version 2.1.2 to 2.2.0
@@ -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=3)}([function(t,o){t.exports=e},function(e,t,o){e.exports=o(5)()},function(e,t,o){"use strict";function n(){return{documentScrollTop:Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop),documentScrollLeft:Math.max(window.pageXOffset,document.documentElement.scrollLeft,document.body.scrollLeft)}}Object.defineProperty(t,"__esModule",{value:!0}),t.getDocumentScroll=n,t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{scrollTop:0,scrollLeft:0},o=t.scrollTop,r=t.scrollLeft,s=n(),l=s.documentScrollTop,i=s.documentScrollLeft,c=e.getBoundingClientRect();return{top:c.top+l+o,left:c.left+i+r,offsetWidth:e.offsetWidth,offsetHeight:e.offsetHeight,computedWidth:c.width,computedHeight:c.height}}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeselectAll=t.SelectAll=t.createSelectable=t.SelectableGroup=void 0;var n=i(o(4)),r=i(o(10)),s=i(o(11)),l=i(o(12));function i(e){return e&&e.__esModule?e:{default:e}}t.SelectableGroup=n.default,t.createSelectable=r.default,t.SelectAll=s.default,t.DeselectAll=l.default},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=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},r=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),s=o(0),l=d(s),i=o(1),c=d(o(7)),a=o(2),u=d(a),f=d(o(8)),p=d(o(9));function d(e){return e&&e.__esModule?e:{default:e}}function h(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}var m=function(){},v=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.setScollTop=function(e){var t=o.scrollContainer.scrollTop;o.checkScrollTop(e,t),o.checkScrollBottom(e,t)},o.checkScrollTop=function(e,t){var n=o.props,r=n.minimumSpeedFactor,s=n.scrollSpeed,l=o.scrollBounds.top-e.clientY;if(l>0||e.clientY<0){var i=t-Math.max(l,r)*s;o.scrollContainer.scrollTop=i}},o.checkScrollBottom=function(e,t){var n=o.props,r=n.minimumSpeedFactor,s=n.scrollSpeed,l=e.clientY-o.scrollBounds.bottom;if(l>0||e.clientY>window.innerHeight){var i=t+Math.max(l,r)*s;o.scrollContainer.scrollTop=Math.min(i,o.maxScroll)}},o.updateRegistry=function(){var e={scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft},t=!0,n=!1,r=void 0;try{for(var s,l=o.registry.values()[Symbol.iterator]();!(t=(s=l.next()).done);t=!0){s.value.registerSelectable(e)}}catch(e){n=!0,r=e}finally{try{!t&&l.return&&l.return()}finally{if(n)throw r}}},o.registerSelectable=function(e){o.registry.add(e),e.state.selected&&o.selectedItems.add(e)},o.unregisterSelectable=function(e){o.registry.delete(e),o.selectedItems.delete(e),o.selectingItems.delete(e)},o.applyContainerScroll=function(e,t){return e+t},o.openSelectbox=function(e){var t=o.desktopEventCoords(e);if(o.setScollTop(t),!o.mouseMoveStarted){o.mouseMoveStarted=!0,o.mouseMoved=!0;var n=o.scrollContainer.scrollTop,r=t.pageY,s=t.pageX,l=(0,a.getDocumentScroll)(),i=l.documentScrollTop,c=l.documentScrollLeft,u=o.applyContainerScroll(r-o.scrollBounds.top,n-i),f=o.applyContainerScroll(o.mouseDownData.boxTop-o.scrollBounds.top,o.mouseDownData.scrollTop-i),p=f-u;f=Math.min(f-p,f);var d=o.mouseDownData.boxLeft-s,m=o.mouseDownData.boxLeft-o.scrollBounds.left,v=o.applyContainerScroll(Math.min(m-d,m),-c);o.selectbox.setState({isBoxSelecting:!0,boxWidth:Math.abs(d),boxHeight:Math.abs(p),boxLeft:v,boxTop:f},function(){o.updateSelecting(),o.props.duringSelection([].concat(h(o.selectingItems))),o.mouseMoveStarted=!1})}},o.updateSelecting=function(){var e=o.selectbox.getRef();if(e){var t=(0,u.default)(e);o.selectItems(n({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}},o.selectItems=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).click,n=o.props,r=n.tolerance,s=n.enableDeselect,l=n.mixedDeselect;e.top+=o.scrollContainer.scrollTop,e.left+=o.scrollContainer.scrollLeft;var i=!0,c=!1,a=void 0;try{for(var u,f=o.registry.values()[Symbol.iterator]();!(i=(u=f.next()).done);i=!0){var p=u.value;o.processItem(p,r,e,t,s,l)}}catch(e){c=!0,a=e}finally{try{!i&&f.return&&f.return()}finally{if(c)throw a}}},o.clearSelection=function(){var e=!0,t=!1,n=void 0;try{for(var r,s=o.selectedItems.values()[Symbol.iterator]();!(e=(r=s.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&&s.return&&s.return()}finally{if(t)throw n}}o.setState({selectionMode:!1}),o.props.onSelectionFinish([].concat(h(o.selectedItems))),o.props.onSelectionClear()},o.selectAll=function(){o.updateWhiteListNodes();var e=!0,t=!1,n=void 0;try{for(var r,s=o.registry.values()[Symbol.iterator]();!(e=(r=s.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&&s.return&&s.return()}finally{if(t)throw n}}o.setState({selectionMode:!0}),o.props.onSelectionFinish([].concat(h(o.selectedItems)))},o.mouseDown=function(e){if(!o.mouseDownStarted&&!o.props.disabled)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&&!(0,c.default)(e.target,o.selectableGroup)){var t=(0,u.default)(o.selectableGroup);if(!(0,f.default)({top:t.top,left:t.left,bottom:t.offsetHeight,right:t.offsetWidth},{top:e.pageY,left:e.pageX,offsetWidth:0,offsetHeight:0}))return}o.updateRootBounds(),o.updateRegistry(),o.mouseDownData={boxLeft:e.pageX,boxTop:e.pageY,scrollTop:o.scrollContainer.scrollTop,scrollLeft:o.scrollContainer.scrollLeft,target:e.target},e.preventDefault(),document.addEventListener("mousemove",o.openSelectbox),document.addEventListener("touchmove",o.openSelectbox),document.addEventListener("mouseup",o.mouseUp),document.addEventListener("touchend",o.mouseUp)}},o.mouseUp=function(e){if(!o.mouseUpStarted&&(o.mouseUpStarted=!0,o.mouseDownStarted=!1,o.removeTempEventListeners(),o.mouseDownData)){var t=o.desktopEventCoords(e),n=t.pageY,r=t.pageX;if(!o.mouseMoved&&(0,c.default)(t.target,o.rootNode))o.handleClick(t,n,r);else{var s=!0,l=!1,i=void 0;try{for(var a,u=o.selectingItems.values()[Symbol.iterator]();!(s=(a=u.next()).done);s=!0){a.value.setState({selected:!0,selecting:!1})}}catch(e){l=!0,i=e}finally{try{!s&&u.return&&u.return()}finally{if(l)throw i}}o.selectedItems=new Set([].concat(h(o.selectedItems),h(o.selectingItems))),o.selectingItems.clear(),1===t.which&&o.mouseDownData.target===t.target&&o.preventEvent(t.target,"click"),o.selectbox.setState({isBoxSelecting:!1,boxWidth:0,boxHeight:0}),o.props.onSelectionFinish([].concat(h(o.selectedItems)))}o.toggleSelectionMode(),o.cleanUp(),o.mouseMoved=!1}},o.keyListener=function(e){e.ctrlKey||e.metaKey||27===e.keyCode&&o.clearSelection()},o.getGroupRef=function(e){return o.selectableGroup=e},o.getSelectboxRef=function(e){return o.selectbox=e},o.state={selectionMode:!1},o.mouseDownStarted=!1,o.mouseMoveStarted=!1,o.mouseUpStarted=!1,o.mouseDownData=null,o.registry=new Set,o.selectedItems=new Set,o.selectingItems=new Set,o.ignoreCheckCache=new Map,o.ignoreList=o.props.ignoreList.concat([".selectable-select-all",".selectable-deselect-all"]),o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,s.Component),r(t,[{key:"getChildContext",value:function(){var e=this;return{selectable:{register:this.registerSelectable,unregister:this.unregisterSelectable,selectAll:this.selectAll,clearSelection:this.clearSelection,getScrolledContainer:function(){return e.scrollContainer}}}}},{key:"componentDidMount",value:function(){this.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,s){if(this.inIgnoreList(e.node))return null;var l=(0,f.default)(o,e.bounds,t,this.props.delta),i=e.state,c=i.selecting,a=i.selected;if(n&&l)return a?this.selectedItems.delete(e):this.selectedItems.add(e),e.setState({selected:!a}),this.clickedItem=e;if(!n&&l){if(a&&r&&(!this.selectionStarted||s))return e.setState({selected:!1}),e.deselected=!0,this.deselectionStarted=!0,this.selectedItems.delete(e);var u=s?!e.deselected:!this.deselectionStarted;if(!c&&!a&&u)return e.setState({selecting:!0}),this.selectionStarted=!0,this.selectingItems.add(e),{updateSelecting:!0}}return!n&&!l&&c&&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=[].concat(h(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){var n=[].concat(h(e.target.classList||[])).indexOf(this.props.clickClassName)>-1;(this.props.allowClickWithoutSelected||this.selectedItems.size||n||this.ctrlPressed)&&(this.selectItems({top:t,left:o,offsetWidth:0,offsetHeight:0},{click:!0}),this.props.onSelectionFinish([].concat(h(this.selectedItems)),this.clickedItem),1===e.which&&this.preventEvent(e.target,"click"),2!==e.which&&3!==e.which||this.preventEvent(e.target,"contextmenu"))}},{key:"cleanUp",value:function(){if(this.deselectionStarted=!1,this.selectionStarted=!1,this.props.mixedDeselect){var e=!0,t=!1,o=void 0;try{for(var n,r=this.registry.values()[Symbol.iterator]();!(e=(n=r.next()).done);e=!0){n.value.deselected=!1}}catch(e){t=!0,o=e}finally{try{!e&&r.return&&r.return()}finally{if(t)throw o}}}}},{key:"desktopEventCoords",value:function(e){return void 0!==e.pageX&&void 0!==e.pageY||(void 0!==e.targetTouches[0]&&void 0!==e.targetTouches[0].pageX?(e.pageX=e.targetTouches[0].pageX,e.pageY=e.targetTouches[0].pageY):void 0!==e.changedTouches[0]&&void 0!==e.changedTouches[0].pageX&&(e.pageX=e.changedTouches[0].pageX,e.pageY=e.changedTouches[0].pageY)),e}},{key:"render",value:function(){return l.default.createElement(this.props.component,{ref:this.getGroupRef,style:this.props.style,className:this.props.className+" "+(this.state.selectionMode?this.props.selectionModeClass:"")},l.default.createElement(p.default,{ref:this.getSelectboxRef,fixedPosition:this.props.fixedPosition,className:this.props.selectboxClassName}),this.props.children)}}]),t}();v.defaultProps={component:"div",tolerance:0,globalMouse:!1,ignoreList:[],scrollSpeed:.25,minimumSpeedFactor:60,duringSelection:m,onSelectionFinish:m,onSelectionClear:m,allowClickWithoutSelected:!0,selectionModeClass:"in-selection-mode",resetOnStart:!1,disabled:!1,deselectOnEsc:!0,delta:1},v.childContextTypes={selectable:i.object},t.default=v},function(e,t,o){"use strict";var n=o(6);function r(){}e.exports=function(){function e(e,t,o,r,s,l){if(l!==n){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var o={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return o.checkPropTypes=r,o.PropTypes=o,o}},function(e,t,o){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,r=o(2),s=(n=r)&&n.__esModule?n:{default:n};var l=function(e,t,o,n,r,s,l,i,c){return void 0===c&&(c=0),!(e+s-c<o||e+c>o+i||t+r-c<n||t+c>n+l)};t.default=function(e,t,o,n){void 0===n&&(n=1);var r=e instanceof HTMLElement?(0,s.default)(e):e,i=t instanceof HTMLElement?(0,s.default)(t):t;return 1===n?l(r.top,r.left,i.top,i.left,r.offsetWidth,r.offsetHeight,i.offsetWidth,i.offsetHeight,o):l(r.top,r.left,i.top,i.left,r.computedWidth,r.computedHeight,i.computedWidth,i.computedHeight,o)}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,r=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),s=o(0),l=(n=s)&&n.__esModule?n:{default:n};function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var c=function(e){function t(){var e,o,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,s=Array(r),l=0;l<r;l++)s[l]=arguments[l];return o=n=i(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),n.state={boxTop:0,boxLeft:0,boxWidth:0,boxHeight:0,isBoxSelecting:!1},n.getRef=function(){return n.selectbox},n.getSelectboxRef=function(e){return n.selectbox=e},i(n,o)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,s.Component),r(t,[{key:"render",value:function(){var e={left:this.state.boxLeft,top:this.state.boxTop,width:this.state.boxWidth,height:this.state.boxHeight,zIndex:9e3,position:this.props.fixedPosition?"fixed":"absolute",cursor:"default"};return l.default.createElement("div",null,this.state.isBoxSelecting&&l.default.createElement("div",{ref:this.getSelectboxRef,style:e,className:this.props.className}))}}]),t}();c.defaultProps={className:"selectable-selectbox"},t.default=c},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=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},r=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),s=o(0),l=a(s),i=o(1),c=a(o(2));function a(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}t.default=function(e){var t,o;return o=t=function(t){function o(){var e,t,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o);for(var r=arguments.length,s=Array(r),l=0;l<r;l++)s[l]=arguments[l];return t=n=u(this,(e=o.__proto__||Object.getPrototypeOf(o)).call.apply(e,[this].concat(s))),n.state={selected:n.props.selected,selecting:!1},n.registerSelectable=function(e){n.bounds=(0,c.default)(n.node,e),n.context.selectable.register(n)},n.selectableRef=function(e){return n.node=e},u(n,t)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(o,s.Component),r(o,[{key:"componentDidMount",value:function(){this.registerSelectable()}},{key:"componentWillUnmount",value:function(){this.context.selectable.unregister(this)}},{key:"render",value:function(){return l.default.createElement(e,n({},this.props,{selected:this.state.selected,selecting:this.state.selecting,selectableRef:this.selectableRef}))}}]),o}(),t.defaultProps={selected:!1},t.contextTypes={selectable:i.object},o}},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,r=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),s=o(0),l=(n=s)&&n.__esModule?n:{default:n},i=o(1);function c(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var a=function(e){function t(){var e,o,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,s=Array(r),l=0;l<r;l++)s[l]=arguments[l];return o=n=c(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),n.getRootRef=function(e){return n.root=e},c(n,o)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,s.Component),r(t,[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){return l.default.createElement(this.props.component,{ref:this.getRootRef,className:"selectable-select-all "+this.props.className,onClick:this.context.selectable.selectAll},this.props.children)}}]),t}();a.defaultProps={component:"div"},a.contextTypes={selectable:i.object},t.default=a},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,r=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),s=o(0),l=(n=s)&&n.__esModule?n:{default:n},i=o(1);function c(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var a=function(e){function t(){var e,o,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,s=Array(r),l=0;l<r;l++)s[l]=arguments[l];return o=n=c(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),n.getRootRef=function(e){return n.root=e},c(n,o)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,s.Component),r(t,[{key:"componentDidMount",value:function(){this.root.addEventListener("mousedown",function(e){return e.stopPropagation()})}},{key:"render",value:function(){return l.default.createElement(this.props.component,{ref:this.getRootRef,onClick:this.context.selectable.clearSelection,className:"selectable-deselect-all "+this.props.className},this.props.children)}}]),t}();a.defaultProps={component:"div"},a.contextTypes={selectable:i.object},t.default=a}])}); | ||
!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,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}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?h(n):r,y(h(h(o)),"state",{boxTop:0,boxLeft:0,boxWidth:0,boxHeight:0,isBoxSelecting:!1}),y(h(h(o)),"getRef",function(){return o.selectbox}),y(h(h(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&&d(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){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 w(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 O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}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 E=function(){},L=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=O(t).call(this,e),o=!r||"object"!==g(r)&&"function"!=typeof r?j(n):r,k(j(j(o)),"setScollTop",function(e){var t=o.scrollContainer.scrollTop;o.checkScrollTop(e,t),o.checkScrollBottom(e,t)}),k(j(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(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(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(j(o)),"registerSelectable",function(e){o.registry.add(e),e.state.selected&&o.selectedItems.add(e)}),k(j(j(o)),"unregisterSelectable",function(e){o.registry.delete(e),o.selectedItems.delete(e),o.selectingItems.delete(e)}),k(j(j(o)),"applyContainerScroll",function(e,t){return e+t}),k(j(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.scrollTop,r=t.pageY,i=t.pageX,c=l(),s=c.documentScrollTop,a=c.documentScrollLeft,u=o.applyContainerScroll(r-o.scrollBounds.top,n-s),f=o.applyContainerScroll(o.mouseDownData.boxTop-o.scrollBounds.top,o.mouseDownData.scrollTop-s),p=f-u;f=Math.min(f-p,f);var d=o.mouseDownData.boxLeft-i,h=o.mouseDownData.boxLeft-o.scrollBounds.left,y=o.applyContainerScroll(Math.min(h-d,h),-a);o.selectbox.setState({isBoxSelecting:!0,boxWidth:Math.abs(d),boxHeight:Math.abs(p),boxLeft:y,boxTop:f},function(){o.updateSelecting(),o.props.duringSelection(S(o.selectingItems)),o.mouseMoveStarted=!1})}}),k(j(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]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){k(e,t,o[t])})}return e}({},t,{offsetWidth:t.offsetWidth||1,offsetHeight:t.offsetHeight||1}))}}),k(j(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(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(S(o.selectedItems)),o.props.onSelectionClear()}),k(j(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(S(o.selectedItems))}),k(j(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(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(S(o.selectedItems).concat(S(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(S(o.selectedItems))}o.toggleSelectionMode(),o.cleanUp(),o.mouseMoved=!1}}),k(j(j(o)),"keyListener",function(e){e.ctrlKey||e.metaKey||27===e.keyCode&&o.clearSelection()}),k(j(j(o)),"getGroupRef",function(e){return o.selectableGroup=e}),k(j(j(o)),"getSelectboxRef",function(e){return o.selectbox=e}),k(j(j(o)),"defaultContainerStyle",{position:"relative"}),k(j(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&&x(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=S(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=S(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(S(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))}}])&&w(o.prototype,s),u&&w(o,u),t}();k(L,"defaultProps",{component:"div",tolerance:0,globalMouse:!1,ignoreList:[],scrollSpeed:.25,minimumSpeedFactor:60,duringSelection:E,onSelectionFinish:E,onSelectionClear:E,allowClickWithoutSelected:!0,selectionModeClass:"in-selection-mode",resetOnStart:!1,disabled:!1,deselectOnEsc:!0,delta:1});var C=L;function P(e){return(P="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 T(){return(T=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 _(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 I(e){return(I=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function M(e,t){return(M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var N=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=I(o)).call.apply(e,[this].concat(l)),t=!r||"object"!==P(r)&&"function"!=typeof r?D(n):r,R(D(D(t)),"state",{selected:t.props.selected,selecting:!1}),R(D(D(t)),"registerSelectable",function(e){t.bounds=c(t.node,e),t.context.selectable.register(D(D(t)))}),R(D(D(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&&M(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,T({},this.props,{selected:this.state.selected,selecting:this.state.selecting,selectableRef:this.selectableRef}))}}])&&_(i.prototype,l),s&&_(i,s),o}(),R(t,"contextType",v),R(t,"defaultProps",{selected:!1}),o};function W(e){return(W="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 H(){return(H=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 B(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 A(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 Y(e){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return(U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var G=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=Y(t)).call.apply(e,[this].concat(l)),o=!r||"object"!==W(r)&&"function"!=typeof r?X(n):r,F(X(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&&U(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=B(e,["children","className"]);return r.a.createElement(this.props.component,H({ref:this.getRootRef,className:"selectable-select-all ".concat(o),onClick:this.context.selectable.selectAll},n),t)}}])&&A(o.prototype,i),l&&A(o,l),t}();F(G,"contextType",v),F(G,"defaultProps",{component:"div"});var K=G;function q(e){return(q="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 z(){return(z=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 V(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 J(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 Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Z(e,t){return(Z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}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,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var te=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=Q(t)).call.apply(e,[this].concat(l)),o=!r||"object"!==q(r)&&"function"!=typeof r?$(n):r,ee($($(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&&Z(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=V(e,["children","className"]);return r.a.createElement(this.props.component,z({ref:this.getRootRef,className:"selectable-deselect-all ".concat(o),onClick:this.context.selectable.clearSelection},n),t)}}])&&J(o.prototype,i),l&&J(o,l),t}();ee(te,"contextType",v),ee(te,"defaultProps",{component:"div"});var oe=te;o.d(t,"SelectableGroup",function(){return C}),o.d(t,"createSelectable",function(){return N}),o.d(t,"SelectAll",function(){return K}),o.d(t,"DeselectAll",function(){return oe})}])}); | ||
//# sourceMappingURL=react-selectable-fast.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,55 +6,79 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _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; }; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _propTypes = require("prop-types"); | ||
var _react = require('react'); | ||
var _getBoundsForNode = _interopRequireDefault(require("./getBoundsForNode")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _Context = _interopRequireDefault(require("./Context")); | ||
var _propTypes = require('prop-types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _getBoundsForNode = require('./getBoundsForNode'); | ||
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; } } | ||
var _getBoundsForNode2 = _interopRequireDefault(_getBoundsForNode); | ||
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
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 _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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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, _temp2; | ||
var _class, _temp; | ||
return _temp2 = _class = function (_Component) { | ||
return _temp = _class = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(SelectableItem, _Component); | ||
function SelectableItem() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, SelectableItem); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = SelectableItem.__proto__ || Object.getPrototypeOf(SelectableItem)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SelectableItem)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
selected: _this.props.selected, | ||
selecting: false | ||
}, _this.registerSelectable = function (containerScroll) { | ||
_this.bounds = (0, _getBoundsForNode2.default)(_this.node, containerScroll); | ||
_this.context.selectable.register(_this); | ||
}, _this.selectableRef = function (ref) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "registerSelectable", function (containerScroll) { | ||
_this.bounds = (0, _getBoundsForNode.default)(_this.node, containerScroll); | ||
_this.context.selectable.register(_assertThisInitialized(_assertThisInitialized(_this))); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "selectableRef", function (ref) { | ||
return _this.node = ref; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(SelectableItem, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
@@ -64,3 +88,3 @@ this.registerSelectable(); | ||
}, { | ||
key: 'componentWillUnmount', | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
@@ -70,5 +94,5 @@ this.context.selectable.unregister(this); | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
return _react2.default.createElement(WrappedComponent, _extends({}, this.props, { | ||
return _react.default.createElement(WrappedComponent, _extends({}, this.props, { | ||
selected: this.state.selected, | ||
@@ -82,11 +106,10 @@ selecting: this.state.selecting, | ||
return SelectableItem; | ||
}(_react.Component), _class.propTypes = { | ||
}(_react.Component), _defineProperty(_class, "contextType", _Context.default), _defineProperty(_class, "propTypes", { | ||
selected: _propTypes.bool | ||
}, _class.defaultProps = { | ||
}), _defineProperty(_class, "defaultProps", { | ||
selected: false | ||
}, _class.contextTypes = { | ||
selectable: _propTypes.object | ||
}, _temp2; | ||
}), _temp; | ||
}; | ||
exports.default = createSelectable; | ||
var _default = createSelectable; | ||
exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,40 +6,67 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _propTypes = require("prop-types"); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _Context = _interopRequireDefault(require("./Context")); | ||
var _propTypes = require('prop-types'); | ||
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var DeselectAllButton = function (_Component) { | ||
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 _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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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 _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, DeselectAllButton); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DeselectAllButton.__proto__ || Object.getPrototypeOf(DeselectAllButton)).call.apply(_ref, [this].concat(args))), _this), _this.getRootRef = function (c) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DeselectAllButton)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getRootRef", function (c) { | ||
return _this.root = c; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(DeselectAllButton, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
@@ -51,13 +78,14 @@ this.root.addEventListener('mousedown', function (e) { | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
return _react2.default.createElement( | ||
this.props.component, | ||
{ | ||
ref: this.getRootRef, | ||
onClick: this.context.selectable.clearSelection, | ||
className: 'selectable-deselect-all ' + this.props.className | ||
}, | ||
this.props.children | ||
); | ||
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); | ||
} | ||
@@ -69,12 +97,14 @@ }]); | ||
DeselectAllButton.propTypes = { | ||
children: _propTypes.object, | ||
_defineProperty(DeselectAllButton, "contextType", _Context.default); | ||
_defineProperty(DeselectAllButton, "propTypes", { | ||
children: _propTypes.node, | ||
component: _propTypes.node | ||
}; | ||
DeselectAllButton.defaultProps = { | ||
}); | ||
_defineProperty(DeselectAllButton, "defaultProps", { | ||
component: 'div' | ||
}; | ||
DeselectAllButton.contextTypes = { | ||
selectable: _propTypes.object | ||
}; | ||
exports.default = DeselectAllButton; | ||
}); | ||
var _default = DeselectAllButton; | ||
exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _getBoundsForNode = require('./getBoundsForNode'); | ||
var _getBoundsForNode = _interopRequireDefault(require("./getBoundsForNode")); | ||
var _getBoundsForNode2 = _interopRequireDefault(_getBoundsForNode); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -31,11 +30,7 @@ | ||
return !(aTop + aHeight - tolerance < bTop || | ||
// 'a' top doesn't touch 'b' bottom | ||
aTop + tolerance > bTop + bHeight || | ||
// 'a' right doesn't touch 'b' left | ||
aLeft + aWidth - tolerance < bLeft || | ||
// 'a' left doesn't touch 'b' right | ||
aLeft + tolerance > bLeft + bWidth); | ||
return !(aTop + aHeight - tolerance < bTop // 'a' top doesn't touch 'b' bottom | ||
|| aTop + tolerance > bTop + bHeight // 'a' right doesn't touch 'b' left | ||
|| aLeft + aWidth - tolerance < bLeft // 'a' left doesn't touch 'b' right | ||
|| aLeft + tolerance > bLeft + bWidth); | ||
}; | ||
/** | ||
@@ -49,3 +44,4 @@ * Given two objects containing "top", "left", "offsetWidth" and "offsetHeight" | ||
exports.default = function (a, b, tolerance, delta) { | ||
var _default = function _default(a, b, tolerance, delta) { | ||
if (typeof delta === 'undefined') { | ||
@@ -55,12 +51,13 @@ delta = 1; | ||
var aObj = a instanceof HTMLElement ? (0, _getBoundsForNode2.default)(a) : a; | ||
var bObj = b instanceof HTMLElement ? (0, _getBoundsForNode2.default)(b) : b; | ||
var aObj = a instanceof HTMLElement ? (0, _getBoundsForNode.default)(a) : a; | ||
var bObj = b instanceof HTMLElement ? (0, _getBoundsForNode.default)(b) : b; | ||
if (delta === 1) { | ||
return coordsCollide(aObj.top, aObj.left, bObj.top, bObj.left, aObj.offsetWidth, aObj.offsetHeight, bObj.offsetWidth, bObj.offsetHeight, tolerance); | ||
} | ||
} // We have a delta and we need to compute the new values | ||
// We have a delta and we need to compute the new values | ||
return coordsCollide(aObj.top, aObj.left, bObj.top, bObj.left, aObj.computedWidth, aObj.computedHeight, bObj.computedWidth, bObj.computedHeight, tolerance); | ||
}; | ||
}; | ||
exports.default = _default; |
@@ -8,10 +8,11 @@ "use strict"; | ||
exports.default = getBoundsForNode; | ||
function getDocumentScroll() { | ||
var documentScrollTop = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop); | ||
var documentScrollLeft = Math.max(window.pageXOffset, document.documentElement.scrollLeft, document.body.scrollLeft); | ||
return { documentScrollTop: documentScrollTop, documentScrollLeft: documentScrollLeft }; | ||
return { | ||
documentScrollTop: documentScrollTop, | ||
documentScrollLeft: documentScrollLeft | ||
}; | ||
} | ||
/** | ||
@@ -22,4 +23,9 @@ * Given a node, get everything needed to calculate its boundaries | ||
*/ | ||
function getBoundsForNode(node) { | ||
var containerScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { scrollTop: 0, scrollLeft: 0 }; | ||
var containerScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { | ||
scrollTop: 0, | ||
scrollLeft: 0 | ||
}; | ||
var scrollTop = containerScroll.scrollTop, | ||
@@ -33,3 +39,2 @@ scrollLeft = containerScroll.scrollLeft; | ||
var rect = node.getBoundingClientRect(); | ||
return { | ||
@@ -36,0 +41,0 @@ top: rect.top + documentScrollTop + scrollTop, |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,20 +6,35 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.DeselectAll = exports.SelectAll = exports.createSelectable = exports.SelectableGroup = undefined; | ||
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 = require('./SelectableGroup'); | ||
var _SelectableGroup = _interopRequireDefault(require("./SelectableGroup")); | ||
var _SelectableGroup2 = _interopRequireDefault(_SelectableGroup); | ||
var _CreateSelectable = _interopRequireDefault(require("./CreateSelectable")); | ||
var _CreateSelectable = require('./CreateSelectable'); | ||
var _SelectAll = _interopRequireDefault(require("./SelectAll")); | ||
var _CreateSelectable2 = _interopRequireDefault(_CreateSelectable); | ||
var _DeselectAll = _interopRequireDefault(require("./DeselectAll")); | ||
var _SelectAll = require('./SelectAll'); | ||
var _SelectAll2 = _interopRequireDefault(_SelectAll); | ||
var _DeselectAll = require('./DeselectAll'); | ||
var _DeselectAll2 = _interopRequireDefault(_DeselectAll); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -31,9 +46,4 @@ | ||
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 '); | ||
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 "); | ||
} | ||
} | ||
exports.SelectableGroup = _SelectableGroup2.default; | ||
exports.createSelectable = _CreateSelectable2.default; | ||
exports.SelectAll = _SelectAll2.default; | ||
exports.DeselectAll = _DeselectAll2.default; | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.default = isNodeInRoot; | ||
function isNodeInRoot(node, root) { | ||
@@ -13,2 +14,3 @@ while (node) { | ||
} | ||
node = node.parentNode; | ||
@@ -15,0 +17,0 @@ } |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,62 +6,78 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _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; }; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _propTypes = require("prop-types"); | ||
var _react = require('react'); | ||
var _nodeInRoot = _interopRequireDefault(require("./nodeInRoot")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _getBoundsForNode = _interopRequireWildcard(require("./getBoundsForNode")); | ||
var _propTypes = require('prop-types'); | ||
var _doObjectsCollide = _interopRequireDefault(require("./doObjectsCollide")); | ||
var _nodeInRoot = require('./nodeInRoot'); | ||
var _Selectbox = _interopRequireDefault(require("./Selectbox")); | ||
var _nodeInRoot2 = _interopRequireDefault(_nodeInRoot); | ||
var _Context = _interopRequireDefault(require("./Context")); | ||
var _getBoundsForNode = require('./getBoundsForNode'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _getBoundsForNode2 = _interopRequireDefault(_getBoundsForNode); | ||
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; } } | ||
var _doObjectsCollide = require('./doObjectsCollide'); | ||
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); } | ||
var _doObjectsCollide2 = _interopRequireDefault(_doObjectsCollide); | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
var _Selectbox = require('./Selectbox'); | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
var _Selectbox2 = _interopRequireDefault(_Selectbox); | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
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 _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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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 = function (_Component) { | ||
var SelectableGroup = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(SelectableGroup, _Component); | ||
function SelectableGroup(props) { | ||
var _this; | ||
_classCallCheck(this, SelectableGroup); | ||
var _this = _possibleConstructorReturn(this, (SelectableGroup.__proto__ || Object.getPrototypeOf(SelectableGroup)).call(this, props)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(SelectableGroup).call(this, props)); | ||
_this.setScollTop = function (e) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setScollTop", function (e) { | ||
var scrollTop = _this.scrollContainer.scrollTop; | ||
_this.checkScrollTop(e, scrollTop); | ||
_this.checkScrollTop(e, scrollTop); | ||
_this.checkScrollBottom(e, scrollTop); | ||
}; | ||
}); | ||
_this.checkScrollTop = function (e, currentTop) { | ||
_defineProperty(_assertThisInitialized(_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; | ||
@@ -73,9 +89,8 @@ | ||
} | ||
}; | ||
}); | ||
_this.checkScrollBottom = function (e, currentTop) { | ||
_defineProperty(_assertThisInitialized(_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; | ||
@@ -85,8 +100,7 @@ | ||
var newTop = currentTop + Math.max(offset, minimumSpeedFactor) * scrollSpeed; | ||
_this.scrollContainer.scrollTop = Math.min(newTop, _this.maxScroll); | ||
} | ||
}; | ||
}); | ||
_this.updateRegistry = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateRegistry", function () { | ||
var containerScroll = { | ||
@@ -96,3 +110,2 @@ scrollTop: _this.scrollContainer.scrollTop, | ||
}; | ||
var _iteratorNormalCompletion = true; | ||
@@ -105,3 +118,2 @@ var _didIteratorError = false; | ||
var selectableItem = _step.value; | ||
selectableItem.registerSelectable(containerScroll); | ||
@@ -114,3 +126,3 @@ } | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
@@ -124,23 +136,27 @@ } | ||
} | ||
}; | ||
}); | ||
_this.registerSelectable = function (selectableItem) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "registerSelectable", function (selectableItem) { | ||
_this.registry.add(selectableItem); | ||
if (selectableItem.state.selected) { | ||
_this.selectedItems.add(selectableItem); | ||
} | ||
}; | ||
}); | ||
_this.unregisterSelectable = function (selectableItem) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "unregisterSelectable", function (selectableItem) { | ||
_this.registry.delete(selectableItem); | ||
_this.selectedItems.delete(selectableItem); | ||
_this.selectingItems.delete(selectableItem); | ||
}; | ||
}); | ||
_this.applyContainerScroll = function (value, scroll) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "applyContainerScroll", function (value, scroll) { | ||
return value + scroll; | ||
}; | ||
}); | ||
_this.openSelectbox = function (event) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "openSelectbox", function (event) { | ||
var e = _this.desktopEventCoords(event); | ||
_this.setScollTop(e); | ||
@@ -151,5 +167,3 @@ | ||
_this.mouseMoved = true; | ||
var scrollTop = _this.scrollContainer.scrollTop; | ||
var eventTop = e.pageY; | ||
@@ -168,3 +182,2 @@ var eventLeft = e.pageX; | ||
boxTop = Math.min(boxTop - boxHeight, boxTop); | ||
var bowWidth = _this.mouseDownData.boxLeft - eventLeft; | ||
@@ -183,20 +196,22 @@ var leftContainerRelative = _this.mouseDownData.boxLeft - _this.scrollBounds.left; | ||
_this.updateSelecting(); | ||
_this.props.duringSelection([].concat(_toConsumableArray(_this.selectingItems))); | ||
_this.props.duringSelection(_toConsumableArray(_this.selectingItems)); | ||
_this.mouseMoveStarted = false; | ||
}); | ||
}; | ||
}); | ||
_this.updateSelecting = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateSelecting", function () { | ||
var selectbox = _this.selectbox.getRef(); | ||
if (!selectbox) return; | ||
var selectboxBounds = (0, _getBoundsForNode.default)(selectbox); | ||
var selectboxBounds = (0, _getBoundsForNode2.default)(selectbox); | ||
_this.selectItems(_extends({}, selectboxBounds, { | ||
_this.selectItems(_objectSpread({}, selectboxBounds, { | ||
offsetWidth: selectboxBounds.offsetWidth || 1, | ||
offsetHeight: selectboxBounds.offsetHeight || 1 | ||
})); | ||
}; | ||
}); | ||
_this.selectItems = function (selectboxBounds) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "selectItems", function (selectboxBounds) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
@@ -209,6 +224,4 @@ click = _ref.click; | ||
mixedDeselect = _this$props3.mixedDeselect; | ||
selectboxBounds.top += _this.scrollContainer.scrollTop; | ||
selectboxBounds.left += _this.scrollContainer.scrollLeft; | ||
var _iteratorNormalCompletion2 = true; | ||
@@ -229,3 +242,3 @@ var _didIteratorError2 = false; | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) { | ||
_iterator2.return(); | ||
@@ -239,5 +252,5 @@ } | ||
} | ||
}; | ||
}); | ||
_this.clearSelection = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "clearSelection", function () { | ||
var _iteratorNormalCompletion3 = true; | ||
@@ -250,4 +263,6 @@ var _didIteratorError3 = false; | ||
var item = _step3.value; | ||
item.setState({ | ||
selected: false | ||
}); | ||
item.setState({ selected: false }); | ||
_this.selectedItems.delete(item); | ||
@@ -260,3 +275,3 @@ } | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return != null) { | ||
_iterator3.return(); | ||
@@ -271,9 +286,14 @@ } | ||
_this.setState({ selectionMode: false }); | ||
_this.props.onSelectionFinish([].concat(_toConsumableArray(_this.selectedItems))); | ||
_this.setState({ | ||
selectionMode: false | ||
}); | ||
_this.props.onSelectionFinish(_toConsumableArray(_this.selectedItems)); | ||
_this.props.onSelectionClear(); | ||
}; | ||
}); | ||
_this.selectAll = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "selectAll", function () { | ||
_this.updateWhiteListNodes(); | ||
var _iteratorNormalCompletion4 = true; | ||
@@ -288,3 +308,6 @@ var _didIteratorError4 = false; | ||
if (!_this.inIgnoreList(item.node) && !item.state.selected) { | ||
item.setState({ selected: true }); | ||
item.setState({ | ||
selected: true | ||
}); | ||
_this.selectedItems.add(item); | ||
@@ -298,3 +321,3 @@ } | ||
try { | ||
if (!_iteratorNormalCompletion4 && _iterator4.return) { | ||
if (!_iteratorNormalCompletion4 && _iterator4.return != null) { | ||
_iterator4.return(); | ||
@@ -309,10 +332,14 @@ } | ||
_this.setState({ selectionMode: true }); | ||
_this.props.onSelectionFinish([].concat(_toConsumableArray(_this.selectedItems))); | ||
}; | ||
_this.setState({ | ||
selectionMode: true | ||
}); | ||
_this.mouseDown = function (e) { | ||
if (_this.mouseDownStarted || _this.props.disabled) return; | ||
_this.props.onSelectionFinish(_toConsumableArray(_this.selectedItems)); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "mouseDown", function (e) { | ||
if (_this.mouseDownStarted || _this.props.disabled || !_this.detectLeftButton(e)) return; | ||
_this.updateWhiteListNodes(); | ||
if (_this.inIgnoreList(e.target)) { | ||
@@ -326,2 +353,3 @@ _this.mouseDownStarted = false; | ||
} | ||
_this.mouseDownStarted = true; | ||
@@ -331,5 +359,5 @@ _this.mouseUpStarted = false; | ||
if (!_this.props.globalMouse && !(0, _nodeInRoot2.default)(e.target, _this.selectableGroup)) { | ||
var offsetData = (0, _getBoundsForNode2.default)(_this.selectableGroup); | ||
var collides = (0, _doObjectsCollide2.default)({ | ||
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, | ||
@@ -349,2 +377,3 @@ left: offsetData.left, | ||
_this.updateRootBounds(); | ||
_this.updateRegistry(); | ||
@@ -359,5 +388,3 @@ | ||
}; | ||
e.preventDefault(); | ||
document.addEventListener('mousemove', _this.openSelectbox); | ||
@@ -367,9 +394,9 @@ document.addEventListener('touchmove', _this.openSelectbox); | ||
document.addEventListener('touchend', _this.mouseUp); | ||
}; | ||
}); | ||
_this.mouseUp = function (event) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "mouseUp", function (event) { | ||
if (_this.mouseUpStarted) return; | ||
_this.mouseUpStarted = true; | ||
_this.mouseDownStarted = false; | ||
_this.removeTempEventListeners(); | ||
@@ -384,3 +411,3 @@ | ||
if (!_this.mouseMoved && (0, _nodeInRoot2.default)(e.target, _this.rootNode)) { | ||
if (!_this.mouseMoved && (0, _nodeInRoot.default)(e.target, _this.rootNode)) { | ||
_this.handleClick(e, eventTop, eventLeft); | ||
@@ -395,4 +422,6 @@ } else { | ||
var item = _step5.value; | ||
item.setState({ selected: true, selecting: false }); | ||
item.setState({ | ||
selected: true, | ||
selecting: false | ||
}); | ||
} | ||
@@ -404,3 +433,3 @@ } catch (err) { | ||
try { | ||
if (!_iteratorNormalCompletion5 && _iterator5.return) { | ||
if (!_iteratorNormalCompletion5 && _iterator5.return != null) { | ||
_iterator5.return(); | ||
@@ -415,3 +444,4 @@ } | ||
_this.selectedItems = new Set([].concat(_toConsumableArray(_this.selectedItems), _toConsumableArray(_this.selectingItems))); | ||
_this.selectedItems = new Set(_toConsumableArray(_this.selectedItems).concat(_toConsumableArray(_this.selectingItems))); | ||
_this.selectingItems.clear(); | ||
@@ -428,11 +458,14 @@ | ||
}); | ||
_this.props.onSelectionFinish([].concat(_toConsumableArray(_this.selectedItems))); | ||
_this.props.onSelectionFinish(_toConsumableArray(_this.selectedItems)); | ||
} | ||
_this.toggleSelectionMode(); | ||
_this.cleanUp(); | ||
_this.mouseMoved = false; | ||
}; | ||
}); | ||
_this.keyListener = function (e) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "keyListener", function (e) { | ||
if (e.ctrlKey || e.metaKey) { | ||
@@ -446,14 +479,31 @@ return; | ||
} | ||
}; | ||
}); | ||
_this.getGroupRef = function (c) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getGroupRef", function (c) { | ||
return _this.selectableGroup = c; | ||
}; | ||
}); | ||
_this.getSelectboxRef = function (c) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getSelectboxRef", function (c) { | ||
return _this.selectbox = c; | ||
}; | ||
}); | ||
_this.state = { selectionMode: false }; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "defaultContainerStyle", { | ||
position: 'relative' | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "contextValue", { | ||
selectable: { | ||
register: _this.registerSelectable, | ||
unregister: _this.unregisterSelectable, | ||
selectAll: _this.selectAll, | ||
clearSelection: _this.clearSelection, | ||
getScrolledContainer: function getScrolledContainer() { | ||
return _this.scrollContainer; | ||
} | ||
} | ||
}); | ||
_this.state = { | ||
selectionMode: false | ||
}; | ||
_this.mouseDownStarted = false; | ||
@@ -463,3 +513,2 @@ _this.mouseMoveStarted = false; | ||
_this.mouseDownData = null; | ||
_this.registry = new Set(); | ||
@@ -474,20 +523,3 @@ _this.selectedItems = new Set(); | ||
_createClass(SelectableGroup, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
var _this2 = this; | ||
return { | ||
selectable: { | ||
register: this.registerSelectable, | ||
unregister: this.unregisterSelectable, | ||
selectAll: this.selectAll, | ||
clearSelection: this.clearSelection, | ||
getScrolledContainer: function getScrolledContainer() { | ||
return _this2.scrollContainer; | ||
} | ||
} | ||
}; | ||
} | ||
}, { | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
@@ -505,3 +537,3 @@ this.rootNode = this.selectableGroup; | ||
}, { | ||
key: 'componentWillUnmount', | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
@@ -519,3 +551,3 @@ this.rootNode.removeEventListener('mousedown', this.mouseDown); | ||
}, { | ||
key: 'removeTempEventListeners', | ||
key: "removeTempEventListeners", | ||
value: function removeTempEventListeners() { | ||
@@ -528,3 +560,3 @@ document.removeEventListener('mousemove', this.openSelectbox); | ||
}, { | ||
key: 'updateRootBounds', | ||
key: "updateRootBounds", | ||
value: function updateRootBounds() { | ||
@@ -535,3 +567,3 @@ this.scrollBounds = this.scrollContainer.getBoundingClientRect(); | ||
}, { | ||
key: 'toggleSelectionMode', | ||
key: "toggleSelectionMode", | ||
value: function toggleSelectionMode() { | ||
@@ -541,12 +573,16 @@ var selectedItems = this.selectedItems, | ||
if (selectedItems.size && !selectionMode) { | ||
this.setState({ selectionMode: true }); | ||
this.setState({ | ||
selectionMode: true | ||
}); | ||
} | ||
if (!selectedItems.size && selectionMode) { | ||
this.setState({ selectionMode: false }); | ||
this.setState({ | ||
selectionMode: false | ||
}); | ||
} | ||
} | ||
}, { | ||
key: 'processItem', | ||
key: "processItem", | ||
value: function processItem(item, tolerance, selectboxBounds, click, enableDeselect, mixedDeselect) { | ||
@@ -557,3 +593,3 @@ if (this.inIgnoreList(item.node)) { | ||
var isCollided = (0, _doObjectsCollide2.default)(selectboxBounds, item.bounds, tolerance, this.props.delta); | ||
var isCollided = (0, _doObjectsCollide.default)(selectboxBounds, item.bounds, tolerance, this.props.delta); | ||
var _item$state = item.state, | ||
@@ -563,3 +599,2 @@ selecting = _item$state.selecting, | ||
if (click && isCollided) { | ||
@@ -572,4 +607,5 @@ if (selected) { | ||
item.setState({ selected: !selected }); | ||
item.setState({ | ||
selected: !selected | ||
}); | ||
return this.clickedItem = item; | ||
@@ -580,7 +616,7 @@ } | ||
if (selected && enableDeselect && (!this.selectionStarted || mixedDeselect)) { | ||
item.setState({ selected: false }); | ||
item.setState({ | ||
selected: false | ||
}); | ||
item.deselected = true; | ||
this.deselectionStarted = true; | ||
return this.selectedItems.delete(item); | ||
@@ -592,8 +628,10 @@ } | ||
if (!selecting && !selected && canSelect) { | ||
item.setState({ selecting: true }); | ||
item.setState({ | ||
selecting: true | ||
}); | ||
this.selectionStarted = true; | ||
this.selectingItems.add(item); | ||
return { updateSelecting: true }; | ||
return { | ||
updateSelecting: true | ||
}; | ||
} | ||
@@ -604,7 +642,9 @@ } | ||
if (this.selectingItems.has(item)) { | ||
item.setState({ selecting: false }); | ||
item.setState({ | ||
selecting: false | ||
}); | ||
this.selectingItems.delete(item); | ||
return { updateSelecting: true }; | ||
return { | ||
updateSelecting: true | ||
}; | ||
} | ||
@@ -616,3 +656,3 @@ } | ||
}, { | ||
key: 'inIgnoreList', | ||
key: "inIgnoreList", | ||
value: function inIgnoreList(target) { | ||
@@ -626,3 +666,2 @@ if (this.ignoreCheckCache.get(target) !== undefined) { | ||
}); | ||
this.ignoreCheckCache.set(target, shouldBeIgnored); | ||
@@ -632,8 +671,25 @@ return shouldBeIgnored; | ||
}, { | ||
key: 'updateWhiteListNodes', | ||
key: "updateWhiteListNodes", | ||
value: function updateWhiteListNodes() { | ||
this.ignoreListNodes = [].concat(_toConsumableArray(document.querySelectorAll(this.ignoreList.join(', ')))); | ||
this.ignoreListNodes = _toConsumableArray(document.querySelectorAll(this.ignoreList.join(', '))); | ||
} | ||
}, { | ||
key: 'preventEvent', | ||
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) { | ||
@@ -645,8 +701,10 @@ var preventHandler = function preventHandler(e) { | ||
}; | ||
target.addEventListener(type, preventHandler, true); | ||
} | ||
}, { | ||
key: 'handleClick', | ||
key: "handleClick", | ||
value: function handleClick(e, top, left) { | ||
var isMouseUpOnClickElement = [].concat(_toConsumableArray(e.target.classList || [])).indexOf(this.props.clickClassName) > -1; | ||
var classNames = e.target.classList || []; | ||
var isMouseUpOnClickElement = _toConsumableArray(classNames).indexOf(this.props.clickClassName) > -1; | ||
@@ -659,4 +717,6 @@ if (this.props.allowClickWithoutSelected || this.selectedItems.size || isMouseUpOnClickElement || this.ctrlPressed) { | ||
offsetHeight: 0 | ||
}, { click: true }); | ||
this.props.onSelectionFinish([].concat(_toConsumableArray(this.selectedItems)), this.clickedItem); | ||
}, { | ||
click: true | ||
}); | ||
this.props.onSelectionFinish(_toConsumableArray(this.selectedItems), this.clickedItem); | ||
@@ -666,2 +726,3 @@ if (e.which === 1) { | ||
} | ||
if (e.which === 2 || e.which === 3) { | ||
@@ -673,6 +734,7 @@ this.preventEvent(e.target, 'contextmenu'); | ||
}, { | ||
key: 'cleanUp', | ||
key: "cleanUp", | ||
value: function cleanUp() { | ||
this.deselectionStarted = false; | ||
this.selectionStarted = false; | ||
if (this.props.mixedDeselect) { | ||
@@ -686,3 +748,2 @@ var _iteratorNormalCompletion6 = true; | ||
var item = _step6.value; | ||
item.deselected = false; | ||
@@ -695,3 +756,3 @@ } | ||
try { | ||
if (!_iteratorNormalCompletion6 && _iterator6.return) { | ||
if (!_iteratorNormalCompletion6 && _iterator6.return != null) { | ||
_iterator6.return(); | ||
@@ -707,3 +768,2 @@ } | ||
} | ||
/** | ||
@@ -715,3 +775,3 @@ * Used to return event object with desktop (non-touch) format of event | ||
}, { | ||
key: 'desktopEventCoords', | ||
key: "desktopEventCoords", | ||
value: function desktopEventCoords(e) { | ||
@@ -730,21 +790,19 @@ if (e.pageX === undefined || e.pageY === undefined) { | ||
} | ||
return e; | ||
} | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
return _react2.default.createElement( | ||
this.props.component, | ||
{ | ||
ref: this.getGroupRef, | ||
style: this.props.style, | ||
className: this.props.className + ' ' + (this.state.selectionMode ? this.props.selectionModeClass : '') | ||
}, | ||
_react2.default.createElement(_Selectbox2.default, { | ||
ref: this.getSelectboxRef, | ||
fixedPosition: this.props.fixedPosition, | ||
className: this.props.selectboxClassName | ||
}), | ||
this.props.children | ||
); | ||
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)); | ||
} | ||
@@ -756,3 +814,3 @@ }]); | ||
SelectableGroup.propTypes = { | ||
_defineProperty(SelectableGroup, "propTypes", { | ||
globalMouse: _propTypes.bool, | ||
@@ -774,2 +832,3 @@ ignoreList: _propTypes.array, | ||
delta: _propTypes.number, | ||
/** | ||
@@ -809,4 +868,5 @@ * Scroll container selector | ||
fixedPosition: _propTypes.bool | ||
}; | ||
SelectableGroup.defaultProps = { | ||
}); | ||
_defineProperty(SelectableGroup, "defaultProps", { | ||
component: 'div', | ||
@@ -827,6 +887,5 @@ tolerance: 0, | ||
delta: 1 | ||
}; | ||
SelectableGroup.childContextTypes = { | ||
selectable: _propTypes.object | ||
}; | ||
exports.default = SelectableGroup; | ||
}); | ||
var _default = SelectableGroup; | ||
exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,40 +6,67 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _propTypes = require("prop-types"); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _Context = _interopRequireDefault(require("./Context")); | ||
var _propTypes = require('prop-types'); | ||
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var SelectAllButton = function (_Component) { | ||
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 _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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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 _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, SelectAllButton); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = SelectAllButton.__proto__ || Object.getPrototypeOf(SelectAllButton)).call.apply(_ref, [this].concat(args))), _this), _this.getRootRef = function (c) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SelectAllButton)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getRootRef", function (c) { | ||
return _this.root = c; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(SelectAllButton, [{ | ||
key: 'componentDidMount', | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
@@ -51,13 +78,14 @@ this.root.addEventListener('mousedown', function (e) { | ||
}, { | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
return _react2.default.createElement( | ||
this.props.component, | ||
{ | ||
ref: this.getRootRef, | ||
className: 'selectable-select-all ' + this.props.className, | ||
onClick: this.context.selectable.selectAll | ||
}, | ||
this.props.children | ||
); | ||
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); | ||
} | ||
@@ -69,12 +97,14 @@ }]); | ||
SelectAllButton.propTypes = { | ||
children: _propTypes.object, | ||
_defineProperty(SelectAllButton, "contextType", _Context.default); | ||
_defineProperty(SelectAllButton, "propTypes", { | ||
children: _propTypes.node, | ||
component: _propTypes.node | ||
}; | ||
SelectAllButton.defaultProps = { | ||
}); | ||
_defineProperty(SelectAllButton, "defaultProps", { | ||
component: 'div' | ||
}; | ||
SelectAllButton.contextTypes = { | ||
selectable: _propTypes.object | ||
}; | ||
exports.default = SelectAllButton; | ||
}); | ||
var _default = SelectAllButton; | ||
exports.default = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,34 +6,49 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = require('react'); | ||
var _propTypes = require("prop-types"); | ||
var _react2 = _interopRequireDefault(_react); | ||
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; } } | ||
var _propTypes = require('prop-types'); | ||
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var Selectbox = function (_Component) { | ||
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 _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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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 _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, Selectbox); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Selectbox.__proto__ || Object.getPrototypeOf(Selectbox)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Selectbox)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
boxTop: 0, | ||
@@ -44,11 +59,17 @@ boxLeft: 0, | ||
isBoxSelecting: false | ||
}, _this.getRef = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getRef", function () { | ||
return _this.selectbox; | ||
}, _this.getSelectboxRef = function (c) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getSelectboxRef", function (c) { | ||
return _this.selectbox = c; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(Selectbox, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
@@ -64,8 +85,7 @@ var boxStyle = { | ||
}; | ||
return _react2.default.createElement( | ||
'div', | ||
null, | ||
this.state.isBoxSelecting && _react2.default.createElement('div', { ref: this.getSelectboxRef, style: boxStyle, className: this.props.className }) | ||
); | ||
return _react.default.createElement("div", null, this.state.isBoxSelecting && _react.default.createElement("div", { | ||
ref: this.getSelectboxRef, | ||
style: boxStyle, | ||
className: this.props.className | ||
})); | ||
} | ||
@@ -77,9 +97,12 @@ }]); | ||
Selectbox.propTypes = { | ||
_defineProperty(Selectbox, "propTypes", { | ||
fixedPosition: _propTypes.bool, | ||
className: _propTypes.string | ||
}; | ||
Selectbox.defaultProps = { | ||
}); | ||
_defineProperty(Selectbox, "defaultProps", { | ||
className: 'selectable-selectbox' | ||
}; | ||
exports.default = Selectbox; | ||
}); | ||
var _default = Selectbox; | ||
exports.default = _default; |
{ | ||
"name": "react-selectable-fast", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "Enable other React components to be selectable by drawing a box with your mouse/touch", | ||
@@ -21,4 +21,3 @@ "repository": { | ||
"lint": "npx eslint --fix --ext js .", | ||
"format": "npm run prettier && npm run lint", | ||
"precommit": "lint-staged" | ||
"format": "npm run prettier && npm run lint" | ||
}, | ||
@@ -61,24 +60,22 @@ "lint-staged": { | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-core": "^6.25.0", | ||
"babel-eslint": "^8.2.3", | ||
"babel-loader": "^7.0.0", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-loader": "^8.0.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.5", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-react": "^6.24.1", | ||
"babel-preset-stage-0": "^6.24.1", | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint": "^4.19.1 || ^5.3.0", | ||
"eslint-config-airbnb": "^17.1.0", | ||
"eslint-plugin-babel": "^5.1.0", | ||
"eslint-plugin-import": "^2.3.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-react": "^7.0.1", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^7.2.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^6.1.1", | ||
"eslint-plugin-react": "^7.11.0", | ||
"husky": "^1.2.0", | ||
"lint-staged": "^8.1.0", | ||
"prettier": "^1.12.1", | ||
"prop-types": "^15.6.2", | ||
"react": "^16.5.2", | ||
"react-dom": "^16.5.2", | ||
"react": "^16.6.3", | ||
"react-dom": "^16.6.3", | ||
"rimraf": "^2.6.1", | ||
@@ -89,3 +86,8 @@ "webpack": "^4.21.0", | ||
"webpack-dev-server": "^3.1.9" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144539
25
15
1254