Comparing version 0.0.9 to 0.0.10
@@ -0,1 +1,3 @@ | ||
export declare const injector: import("css-styled").StyledInjector; | ||
export declare const CLASS_NAME: string; | ||
export declare const OPTIONS: readonly ["dragContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate"]; | ||
@@ -2,0 +4,0 @@ export declare const PROPERTIES: readonly ["dragContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate"]; |
import Selecto from "./Selecto"; | ||
export default Selecto; | ||
export * from "./consts"; | ||
export { OPTIONS, PROPERTIES, EVENTS, METHODS, CLASS_NAME, } from "./consts"; | ||
export * from "./types"; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.9 | ||
version: 0.0.10 | ||
*/ | ||
@@ -14,3 +14,2 @@ 'use strict'; | ||
var Dragger = require('@daybrush/drag'); | ||
var styled = require('css-styled'); | ||
var frameworkUtils = require('framework-utils'); | ||
@@ -20,2 +19,3 @@ var utils = require('@daybrush/utils'); | ||
var KeyController = require('keycon'); | ||
var styled = require('css-styled'); | ||
@@ -171,5 +171,12 @@ /*! ***************************************************************************** | ||
var injector = styled("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
/** | ||
* @memberof Selecto | ||
*/ | ||
var CLASS_NAME = "selecto-selection " + injector.className; | ||
/** | ||
* @memberof Selecto | ||
*/ | ||
var OPTIONS = [// ignore target, container, | ||
@@ -189,3 +196,2 @@ "dragContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate"]; | ||
var injector = styled("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
/** | ||
@@ -545,3 +551,3 @@ * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch. | ||
this.target = createElement(h("div", { | ||
className: "selecto-selection " + injector.className | ||
className: CLASS_NAME | ||
}), this.target, this.container); | ||
@@ -803,2 +809,3 @@ var target = this.target; | ||
exports.CLASS_NAME = CLASS_NAME; | ||
exports.EVENTS = EVENTS; | ||
@@ -805,0 +812,0 @@ exports.METHODS = METHODS; |
@@ -7,7 +7,6 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.9 | ||
version: 0.0.10 | ||
*/ | ||
import Component from '@egjs/component'; | ||
import Dragger from '@daybrush/drag'; | ||
import styled from 'css-styled'; | ||
import { Properties } from 'framework-utils'; | ||
@@ -17,2 +16,3 @@ import { hasClass, addClass, isObject, camelize } from '@daybrush/utils'; | ||
import KeyController from 'keycon'; | ||
import styled from 'css-styled'; | ||
@@ -168,5 +168,12 @@ /*! ***************************************************************************** | ||
var injector = styled("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
/** | ||
* @memberof Selecto | ||
*/ | ||
var CLASS_NAME = "selecto-selection " + injector.className; | ||
/** | ||
* @memberof Selecto | ||
*/ | ||
var OPTIONS = [// ignore target, container, | ||
@@ -186,3 +193,2 @@ "dragContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate"]; | ||
var injector = styled("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
/** | ||
@@ -542,3 +548,3 @@ * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch. | ||
this.target = createElement(h("div", { | ||
className: "selecto-selection " + injector.className | ||
className: CLASS_NAME | ||
}), this.target, this.container); | ||
@@ -801,3 +807,3 @@ var target = this.target; | ||
export default Selecto; | ||
export { EVENTS, METHODS, OPTIONS, PROPERTIES }; | ||
export { CLASS_NAME, EVENTS, METHODS, OPTIONS, PROPERTIES }; | ||
//# sourceMappingURL=selecto.esm.js.map |
@@ -7,9 +7,9 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.9 | ||
version: 0.0.10 | ||
*/ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@daybrush/drag'), require('css-styled'), require('framework-utils'), require('@daybrush/utils'), require('@egjs/children-differ'), require('keycon')) : | ||
typeof define === 'function' && define.amd ? define(['@egjs/component', '@daybrush/drag', 'css-styled', 'framework-utils', '@daybrush/utils', '@egjs/children-differ', 'keycon'], factory) : | ||
(global = global || self, global.Selecto = factory(global.Component, global.Dragger, global.styled, global.frameworkUtils, global.utils, global.ChildrenDiffer, global.KeyController)); | ||
}(this, (function (Component, Dragger, styled, frameworkUtils, utils, ChildrenDiffer, KeyController) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@egjs/component'), require('@daybrush/drag'), require('framework-utils'), require('@daybrush/utils'), require('@egjs/children-differ'), require('keycon'), require('css-styled')) : | ||
typeof define === 'function' && define.amd ? define(['@egjs/component', '@daybrush/drag', 'framework-utils', '@daybrush/utils', '@egjs/children-differ', 'keycon', 'css-styled'], factory) : | ||
(global = global || self, global.Selecto = factory(global.Component, global.Dragger, global.frameworkUtils, global.utils, global.ChildrenDiffer, global.KeyController, global.styled)); | ||
}(this, (function (Component, Dragger, frameworkUtils, utils, ChildrenDiffer, KeyController, styled) { 'use strict'; | ||
@@ -165,8 +165,10 @@ /*! ***************************************************************************** | ||
var injector = styled("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
/** | ||
* @memberof Selecto | ||
*/ | ||
var CLASS_NAME = "selecto-selection " + injector.className; | ||
var PROPERTIES = ["dragContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate"]; | ||
var injector = styled("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
/** | ||
@@ -526,3 +528,3 @@ * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch. | ||
this.target = createElement(h("div", { | ||
className: "selecto-selection " + injector.className | ||
className: CLASS_NAME | ||
}), this.target, this.container); | ||
@@ -529,0 +531,0 @@ var target = this.target; |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.9 | ||
version: 0.0.10 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component"),require("@daybrush/drag"),require("css-styled"),require("framework-utils"),require("@daybrush/utils"),require("@egjs/children-differ"),require("keycon")):"function"==typeof define&&define.amd?define(["@egjs/component","@daybrush/drag","css-styled","framework-utils","@daybrush/utils","@egjs/children-differ","keycon"],e):(t=t||self).Selecto=e(t.Component,t.Dragger,t.styled,t.frameworkUtils,t.utils,t.ChildrenDiffer,t.KeyController)}(this,function(t,s,e,a,g,y,c){"use strict";var l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function d(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=e||{},o=i.className,s=i.style;return{tag:t,className:void 0===o?"":o,style:void 0===s?{}:s,attributes:function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(i,["className","style"]),children:n}}function f(t,e,n){t!==e&&n(t,e)}var h=["dragContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate"],p=e("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"),n=function(e){function t(){this.constructor=n}var n,r;function i(t){void 0===t&&(t={});var p=e.call(this)||this;return p.selectedTargets=[],p.differ=new y,p.onDragStart=function(t,e){var n=t.datas,r=t.clientX,i=t.clientY,o=t.inputEvent,s=p.options,a=s.continueSelect,c=s.selectFromInside,l=p.getSelectableTargets(),u=l.map(function(t){var e=t.getBoundingClientRect(),n=e.left,r=e.top;return{left:n,top:r,right:n+e.width,bottom:r+e.height}});n.selectableTargets=l,n.selectableRects=u,n.startSelectedTargets=p.selectedTargets;var d=e||document.elementFromPoint(r,i),f=p.hitTest({left:r,top:i,right:r,bottom:i},r,i,l,u).filter(function(t){return t===d||t.contains(d)}),g=0<f.length;a?f=p.getSelectedTargets(f):p.selectedTargets=[];var h=o.type;return!(("mousedown"===h||"touchstart"===h)&&!p.trigger("dragStart",t))&&(p.select(f,o,!0),n.startX=r,n.startY=i,n.selectedTargets=f,p.target.style.cssText+="left:"+r+"px;top:"+i+"px",!(!c&&g)||(p.onDragEnd(t),!1))},p.onDrag=function(t){var e=t.distX,n=t.distY,r=t.datas,i=t.inputEvent,o=r.startX,s=r.startY,a=Math.min(0,e),c=Math.min(0,n),l=Math.abs(e),u=Math.abs(n);p.target.style.cssText+="display: block;transform: translate("+a+"px, "+c+"px);width:"+l+"px;height:"+u+"px;";var d=o+a,f=s+c,g=p.hitTest({left:d,top:f,right:d+l,bottom:f+u},r.startX,r.startY,r.selectableTargets,r.selectableRects),h=p.getSelectedTargets(g);p.select(h,i),r.selectedTargets=h},p.onDragEnd=function(t){var e=t.datas,n=t.inputEvent;p.target.style.cssText+="display: none;",p.selecteEnd(e.startSelectedTargets,e.selectedTargets,n),p.selectedTargets=e.selectedTargets},p.onKeyDown=function(){p.continueSelect=!0,p.trigger("keydown",{})},p.onKeyUp=function(){p.continueSelect=!1,p.trigger("keyup",{})},p.target=t.target,p.container=t.container,p.options=u({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null},t),p.initElement(),p.setKeyController(),p}l(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return o.setSelectedTargets=function(t){this.selectedTargets=t,this.differ=new y(t)},o.setKeyContainer=function(t){var e=this,n=this.options;f(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},o.setToggleContinueSelect=function(t){var e=this,n=this.options;f(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},o.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.dragger.unset(),this.injectResult.destroy(),this.keycon=null,this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},o.click=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),r={datas:{},clientX:n.clientX,clientY:n.clientY,inputEvent:t};this.onDragStart(r,e)&&this.onDragEnd(r)},o.setKeyController=function(){var t=this.options,e=t.keyContainer,n=t.toggleContinueSelect;this.keycon&&(this.keycon.destroy(),this.keycon=null),n&&(this.keycon=new c(e||window)),this.setKeyEvent()},o.setKeyEvent=function(){var t=this.options.toggleContinueSelect;this.keycon?(this.keycon.off(),t&&this.keycon.keydown(t,this.onKeyDown).keyup(t,this.onKeyUp)):this.setKeyController()},o.initElement=function(){this.target=function n(t,e,r){var i=t.tag,o=t.children,s=t.attributes,a=t.className,c=t.style,l=e||document.createElement(i);for(var u in s)l.setAttribute(u,s[u]);var d=l.children;if(o.forEach(function(t,e){n(t,d[e],l)}),a&&a.split(" ").forEach(function(t){g.hasClass(l,t)||g.addClass(l,t)}),c){var f=l.style;for(var u in c)f[u]=c[u]}return!e&&r&&r.appendChild(l),l}(d("div",{className:"selecto-selection "+p.className}),this.target,this.container);var t=this.target;this.dragger=new s(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=p.inject(t)},o.hitTest=function(t,g,h,p,e){var n=this.options,y=n.hitRate,v=n.selectByClick,m=t.left,b=t.top,T=t.right,k=t.bottom,C=[];return e.forEach(function(t,e){var n=t.left,r=t.top,i=t.right,o=t.bottom,s=n<=g&&g<=i&&r<=h&&h<=o,a=(i-n)*(o-r),c=Math.max(n,m),l=Math.min(i,T),u=Math.max(r,b),d=Math.min(o,k);if(v&&s)C.push(p[e]);else if(!(l<c||d<u)){var f=Math.round((l-c)*(d-u)/a*100);y<=f&&C.push(p[e])}}),C},o.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){g.isObject(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},o.getSelectedTargets=function(t){var e=y.diff(this.selectedTargets,t),n=e.list,r=e.prevList,i=e.added,o=e.removed;return i.map(function(t){return n[t]}).concat(o.map(function(t){return r[t]}))},o.select=function(t,e,n){var r=this.differ.update(t),i=r.added,o=r.removed,s=r.prevList,a=r.list;n&&this.trigger("selectStart",{selected:t,added:i.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e}),(i.length||o.length)&&this.trigger("select",{selected:t,added:i.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e})},o.selecteEnd=function(t,e,n){var r=y.diff(t,e),i=r.added,o=r.removed,s=r.prevList,a=r.list,c=y.diff(this.selectedTargets,e),l=c.added,u=c.removed,d=c.prevList,f=c.list,g=n.type,h="mousedown"===g||"touchstart"===g;this.trigger("selectEnd",{selected:e,added:i.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),afterAdded:l.map(function(t){return f[t]}),afterRemoved:u.map(function(t){return d[t]}),isDragStart:h,inputEvent:n})},i=function(t,e,n,r){var i,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;0<=a;a--)(i=t[a])&&(s=(o<3?i(s):3<o?i(e,n,s):i(e,n))||s);return 3<o&&s&&Object.defineProperty(e,n,s),s}([a.Properties(h,function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},r=g.camelize("set "+e);t[r]?n.set=function(t){this[r](t)}:n.set=function(t){this.options[e]=t},Object.defineProperty(t,e,n)})],i)}(t),r={__proto__:null,default:n};for(var i in r)n[i]=r[i];return n}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component"),require("@daybrush/drag"),require("framework-utils"),require("@daybrush/utils"),require("@egjs/children-differ"),require("keycon"),require("css-styled")):"function"==typeof define&&define.amd?define(["@egjs/component","@daybrush/drag","framework-utils","@daybrush/utils","@egjs/children-differ","keycon","css-styled"],e):(t=t||self).Selecto=e(t.Component,t.Dragger,t.frameworkUtils,t.utils,t.ChildrenDiffer,t.KeyController,t.styled)}(this,function(t,s,a,g,y,c,e){"use strict";var l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function d(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=e||{},o=i.className,s=i.style;return{tag:t,className:void 0===o?"":o,style:void 0===s?{}:s,attributes:function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(i,["className","style"]),children:n}}function f(t,e,n){t!==e&&n(t,e)}var h=e("\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"),p="selecto-selection "+h.className,v=["dragContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate"],n=function(e){function t(){this.constructor=n}var n,r;function i(t){void 0===t&&(t={});var p=e.call(this)||this;return p.selectedTargets=[],p.differ=new y,p.onDragStart=function(t,e){var n=t.datas,r=t.clientX,i=t.clientY,o=t.inputEvent,s=p.options,a=s.continueSelect,c=s.selectFromInside,l=p.getSelectableTargets(),u=l.map(function(t){var e=t.getBoundingClientRect(),n=e.left,r=e.top;return{left:n,top:r,right:n+e.width,bottom:r+e.height}});n.selectableTargets=l,n.selectableRects=u,n.startSelectedTargets=p.selectedTargets;var d=e||document.elementFromPoint(r,i),f=p.hitTest({left:r,top:i,right:r,bottom:i},r,i,l,u).filter(function(t){return t===d||t.contains(d)}),g=0<f.length;a?f=p.getSelectedTargets(f):p.selectedTargets=[];var h=o.type;return!(("mousedown"===h||"touchstart"===h)&&!p.trigger("dragStart",t))&&(p.select(f,o,!0),n.startX=r,n.startY=i,n.selectedTargets=f,p.target.style.cssText+="left:"+r+"px;top:"+i+"px",!(!c&&g)||(p.onDragEnd(t),!1))},p.onDrag=function(t){var e=t.distX,n=t.distY,r=t.datas,i=t.inputEvent,o=r.startX,s=r.startY,a=Math.min(0,e),c=Math.min(0,n),l=Math.abs(e),u=Math.abs(n);p.target.style.cssText+="display: block;transform: translate("+a+"px, "+c+"px);width:"+l+"px;height:"+u+"px;";var d=o+a,f=s+c,g=p.hitTest({left:d,top:f,right:d+l,bottom:f+u},r.startX,r.startY,r.selectableTargets,r.selectableRects),h=p.getSelectedTargets(g);p.select(h,i),r.selectedTargets=h},p.onDragEnd=function(t){var e=t.datas,n=t.inputEvent;p.target.style.cssText+="display: none;",p.selecteEnd(e.startSelectedTargets,e.selectedTargets,n),p.selectedTargets=e.selectedTargets},p.onKeyDown=function(){p.continueSelect=!0,p.trigger("keydown",{})},p.onKeyUp=function(){p.continueSelect=!1,p.trigger("keyup",{})},p.target=t.target,p.container=t.container,p.options=u({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null},t),p.initElement(),p.setKeyController(),p}l(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return o.setSelectedTargets=function(t){this.selectedTargets=t,this.differ=new y(t)},o.setKeyContainer=function(t){var e=this,n=this.options;f(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},o.setToggleContinueSelect=function(t){var e=this,n=this.options;f(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},o.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.dragger.unset(),this.injectResult.destroy(),this.keycon=null,this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},o.click=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),r={datas:{},clientX:n.clientX,clientY:n.clientY,inputEvent:t};this.onDragStart(r,e)&&this.onDragEnd(r)},o.setKeyController=function(){var t=this.options,e=t.keyContainer,n=t.toggleContinueSelect;this.keycon&&(this.keycon.destroy(),this.keycon=null),n&&(this.keycon=new c(e||window)),this.setKeyEvent()},o.setKeyEvent=function(){var t=this.options.toggleContinueSelect;this.keycon?(this.keycon.off(),t&&this.keycon.keydown(t,this.onKeyDown).keyup(t,this.onKeyUp)):this.setKeyController()},o.initElement=function(){this.target=function n(t,e,r){var i=t.tag,o=t.children,s=t.attributes,a=t.className,c=t.style,l=e||document.createElement(i);for(var u in s)l.setAttribute(u,s[u]);var d=l.children;if(o.forEach(function(t,e){n(t,d[e],l)}),a&&a.split(" ").forEach(function(t){g.hasClass(l,t)||g.addClass(l,t)}),c){var f=l.style;for(var u in c)f[u]=c[u]}return!e&&r&&r.appendChild(l),l}(d("div",{className:p}),this.target,this.container);var t=this.target;this.dragger=new s(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=h.inject(t)},o.hitTest=function(t,g,h,p,e){var n=this.options,y=n.hitRate,v=n.selectByClick,m=t.left,b=t.top,T=t.right,k=t.bottom,C=[];return e.forEach(function(t,e){var n=t.left,r=t.top,i=t.right,o=t.bottom,s=n<=g&&g<=i&&r<=h&&h<=o,a=(i-n)*(o-r),c=Math.max(n,m),l=Math.min(i,T),u=Math.max(r,b),d=Math.min(o,k);if(v&&s)C.push(p[e]);else if(!(l<c||d<u)){var f=Math.round((l-c)*(d-u)/a*100);y<=f&&C.push(p[e])}}),C},o.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){g.isObject(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},o.getSelectedTargets=function(t){var e=y.diff(this.selectedTargets,t),n=e.list,r=e.prevList,i=e.added,o=e.removed;return i.map(function(t){return n[t]}).concat(o.map(function(t){return r[t]}))},o.select=function(t,e,n){var r=this.differ.update(t),i=r.added,o=r.removed,s=r.prevList,a=r.list;n&&this.trigger("selectStart",{selected:t,added:i.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e}),(i.length||o.length)&&this.trigger("select",{selected:t,added:i.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e})},o.selecteEnd=function(t,e,n){var r=y.diff(t,e),i=r.added,o=r.removed,s=r.prevList,a=r.list,c=y.diff(this.selectedTargets,e),l=c.added,u=c.removed,d=c.prevList,f=c.list,g=n.type,h="mousedown"===g||"touchstart"===g;this.trigger("selectEnd",{selected:e,added:i.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),afterAdded:l.map(function(t){return f[t]}),afterRemoved:u.map(function(t){return d[t]}),isDragStart:h,inputEvent:n})},i=function(t,e,n,r){var i,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;0<=a;a--)(i=t[a])&&(s=(o<3?i(s):3<o?i(e,n,s):i(e,n))||s);return 3<o&&s&&Object.defineProperty(e,n,s),s}([a.Properties(v,function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},r=g.camelize("set "+e);t[r]?n.set=function(t){this[r](t)}:n.set=function(t){this.options[e]=t},Object.defineProperty(t,e,n)})],i)}(t),r={__proto__:null,default:n};for(var i in r)n[i]=r[i];return n}); | ||
//# sourceMappingURL=selecto.min.js.map |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 0.0.9 | ||
version: 0.0.10 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Selecto=e()}(this,function(){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var u=function(){return(u=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function a(t){return void 0===t}var t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var i=!1,r=[e],o=0;e.stop=function(){i=!0},e.currentTarget=this;for(var s=arguments.length,a=new Array(2<s?s-2:0),c=2;c<s;c++)a[c-2]=arguments[c];for(1<=a.length&&(r=r.concat(a)),o=0;n[o];o++)n[o].apply(this,r);return!i},e.once=function(r,o){if("object"==typeof r&&a(o)){var t,e=r;for(t in e)this.once(t,e[t]);return this}if("string"==typeof r&&"function"==typeof o){var s=this;this.on(r,function t(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];o.apply(s,n),s.off(r,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&a(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}if("string"==typeof t&&"function"==typeof e){var r=this._eventHandler[t];a(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)}return this},e.off=function(t,e){if(a(t))return this._eventHandler={},this;if(a(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,i=t;for(n in i)this.off(n,i[n]);return this}var r,o,s=this._eventHandler[t];if(s)for(r=0;void 0!==(o=s[r]);r++)if(o===e){s=s.splice(r,1);break}return this},t}();return t.VERSION="2.1.2",t}();function l(t,e,n,i){t.addEventListener(e,n,i)}function n(t,e,n){t.removeEventListener(e,n)}var h=function(){return(h=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function f(t,e,n,i){var r=m(t),o=m(e),s=m(i);return p(C(i[0],b(r,s)),C(i[0],b(o,s)),n[0])}function d(t){return t.touches?y(t.touches):[r(t)]}function p(t,e,n){var i=t.clientX,r=t.clientY;return{clientX:i,clientY:r,deltaX:i-e.clientX,deltaY:r-e.clientY,distX:i-n.clientX,distY:r-n.clientY}}function v(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function g(t,n,i){return t.map(function(t,e){return p(t,n[e],i[e])})}function y(t){for(var e=Math.min(t.length,2),n=[],i=0;i<e;++i)n.push(r(t[i]));return n}function r(t){return{clientX:t.clientX,clientY:t.clientY}}function m(t){return{clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function C(t,e){return{clientX:t.clientX+e.clientX,clientY:t.clientY+e.clientY}}function b(t,e){return{clientX:t.clientX-e.clientX,clientY:t.clientY-e.clientY}}var E=function(){function t(t,e){var s=this;void 0===e&&(e={}),this.el=t,this.options={},this.flag=!1,this.pinchFlag=!1,this.datas={},this.isDrag=!1,this.isPinch=!1,this.isMouse=!1,this.isTouch=!1,this.prevClients=[],this.startClients=[],this.movement=0,this.startPinchClients=[],this.startDistance=0,this.customDist=[0,0],this.onDragStart=function(t){if(s.flag||!1!==t.cancelable){if((e=t).touches&&2<=e.touches.length){if(!s.flag&&t.touches.length!==t.changedTouches.length)return;s.pinchFlag||s.onPinchStart(t)}var e;if(!s.flag){var n=s.startClients[0]?s.startClients:d(t);s.customDist=[0,0],s.flag=!0,s.isDrag=!1,s.startClients=n,s.prevClients=n,s.datas={};var i=p(n[s.movement=0],s.prevClients[0],s.startClients[0]),r=s.options,o=r.dragstart;(r.preventRightClick&&3===t.which||!1===(o&&o(h({datas:s.datas,inputEvent:t},i))))&&(s.startClients=[],s.prevClients=[],s.flag=!1),s.flag&&t.preventDefault()}}},this.onDrag=function(t,e){if(s.flag){var n=d(t);s.pinchFlag&&s.onPinch(t,n);var i=s.move([0,0],t,n);if(i&&(i.deltaX||i.deltaY)){var r=s.options.drag;r&&r(h({},i,{isScroll:!!e,inputEvent:t}))}}},this.onDragEnd=function(t){if(s.flag){s.pinchFlag&&s.onPinchEnd(t),s.flag=!1;var e=s.options.dragend,n=s.prevClients,i=s.startClients,r=s.pinchFlag?f(n,n,i,s.startPinchClients):p(n[0],n[0],i[0]);s.startClients=[],s.prevClients=[],e&&e(h({datas:s.datas,isDrag:s.isDrag,inputEvent:t},r))}},this.options=h({container:t,preventRightClick:!0,pinchThreshold:0,events:["touch","mouse"]},e);var n=this.options,i=n.container,r=n.events;if(this.isTouch=-1<r.indexOf("touch"),this.isMouse=-1<r.indexOf("mouse"),this.customDist=[0,0],this.isMouse&&(l(t,"mousedown",this.onDragStart),l(i,"mousemove",this.onDrag),l(i,"mouseup",this.onDragEnd)),this.isTouch){var o={passive:!1};l(t,"touchstart",this.onDragStart,o),l(i,"touchmove",this.onDrag,o),l(i,"touchend",this.onDragEnd,o)}}var e=t.prototype;return e.isDragging=function(){return this.isDrag},e.isPinching=function(){return this.isPinch},e.scrollBy=function(e,n,t,i){void 0===i&&(i=!0),this.flag&&(this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),i&&this.onDrag(t,!0))},e.move=function(t,e,n){var i=t[0],r=t[1];void 0===n&&(n=this.prevClients);var o=this.customDist,s=this.prevClients,a=this.startClients,c=this.pinchFlag?f(n,s,a,this.startPinchClients):p(n[0],s[0],a[0]);o[0]+=i,o[1]+=r,c.deltaX+=i,c.deltaY+=r;var u=c.deltaX,l=c.deltaY;return c.distX+=o[0],c.distY+=o[1],this.movement+=Math.sqrt(u*u+l*l),this.prevClients=n,this.isDrag=!0,h({datas:this.datas},c,{isScroll:!1,inputEvent:e})},e.onPinchStart=function(t){var e,n,i=this.options,r=i.pinchstart,o=i.pinchThreshold;if(!(this.isDrag&&this.movement>o)){var s=y(t.changedTouches);if(this.pinchFlag=!0,(e=this.startClients).push.apply(e,s),(n=this.prevClients).push.apply(n,s),this.startDistance=v(this.prevClients),this.startPinchClients=this.prevClients.slice(),r){var a=this.prevClients,c=m(a),u=p(c,c,c);r(h({datas:this.datas,touches:g(a,a,a)},u,{inputEvent:t}))}}},e.onPinch=function(t,e){if(this.flag&&this.pinchFlag){this.isPinch=!0;var n=this.options.pinch;if(n){var i=this.prevClients,r=this.startClients,o=p(m(e),m(i),m(r)),s=v(e);n(h({datas:this.datas,touches:g(e,i,r),scale:s/this.startDistance,distance:s},o,{inputEvent:t}))}}},e.onPinchEnd=function(t){if(this.flag&&this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.options.pinchend;if(n){var i=this.prevClients,r=this.startClients,o=p(m(i),m(i),m(r));n(h({datas:this.datas,isPinch:e,touches:g(i,i,r)},o,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},e.unset=function(){var t=this.el,e=this.options.container;this.isMouse&&(n(t,"mousedown",this.onDragStart),n(e,"mousemove",this.onDrag),n(e,"mouseup",this.onDragEnd)),this.isTouch&&(n(t,"touchstart",this.onDragStart),n(e,"touchmove",this.onDrag),n(e,"touchend",this.onDragEnd))},t}();var e=function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0};function o(i,t,e){var n=document.createElement("style");return n.setAttribute("type","text/css"),n.innerHTML=t.replace(/([^}{]*){/gm,function(t,e){return((n=e.match(/("[^"]*"|'[^']*'|[^,\s()]*\((?:[^()]*|\([^()]*\))*\)[^,\s()]*|[^,])+/g))?n.map(function(t){return t.trim()}):[]).map(function(t){return-1<t.indexOf(":global")?t.replace(/\:global/g,""):-1<t.indexOf(":host")?""+t.replace(/\:host/g,"."+i):"."+i+" "+t}).join(", ")+"{";var n}),(e||document.head||document.body).appendChild(n),n}var k=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,i=this.values,r=n.indexOf(t),o=-1===r?n.length:r;n[o]=t,i[o]=e},t}(),w=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),O="function"==typeof Map,s=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var _=function(){function t(t,e,n,i,r,o,s,a){this.prevList=t,this.list=e,this.added=n,this.removed=i,this.changed=r,this.maintained=o,this.changedBeforeAdded=s,this.fixed=a}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,a,c,e=(t=this.changedBeforeAdded,n=this.fixed,a=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],i=new s;a[e]=i,c[n]=i}),a.forEach(function(t,e){t.connect(a[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],i=t[1];if(n===i)return[0,0];var r=a[n],o=c[i-1],s=r.getIndex();return r.disconnect(),o?r.connect(o,o.next):r.connect(void 0,a[0]),[s,r.getIndex()]})),u=this.changed,l=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],i=t[1],r=u[e],o=r[0],s=r[1];if(n!==i)return l.push([o,s]),!0}),this.cachePureChanged=l},t}();function i(t,e,n){var i=O?Map:n?w:k,r=n||function(t){return t},o=[],s=[],a=[],c=t.map(r),u=e.map(r),l=new i,h=new i,f=[],d=[],p={},v=[],g=0,y=0;return c.forEach(function(t,e){l.set(t,e)}),u.forEach(function(t,e){h.set(t,e)}),c.forEach(function(t,e){var n=h.get(t);void 0===n?(++y,s.push(e)):p[n]=y}),u.forEach(function(t,e){var n=l.get(t);void 0===n?(o.push(e),++g):(a.push([n,e]),y=p[e]||0,f.push([n-y,e-g]),d.push(e===n),n!==e&&v.push([n,e]))}),s.reverse(),new _(t,e,o,s,v,a,f,d)}var D=function(t,e){return(D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var K,S="function"==typeof Map?void 0:(K=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++K)}),T=function(e){function t(){this.constructor=n}var n,i;function r(t){return void 0===t&&(t=[]),e.call(this,t,S)||this}return D(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t),r}(function(){function t(t,e){void 0===t&&(t=[]),this.findKeyCallback=e,this.list=[].slice.call(t)}return t.prototype.update=function(t){var e=[].slice.call(t),n=i(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function x(t,e){return i(t,e,S)}var j=function(t,e){return(j=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var P,Y=(function(t,e){function n(t){if(t&&"object"==typeof t){var e=t.which||t.keyCode||t.charCode;e&&(t=e)}if("number"==typeof t)return s[t];var n,i=String(t);return(n=r[i.toLowerCase()])?n:(n=o[i.toLowerCase()])||(1===i.length?i.charCodeAt(0):void 0)}n.isEventKey=function(t,e){if(t&&"object"==typeof t){var n=t.which||t.keyCode||t.charCode;if(null==n)return!1;if("string"==typeof e){var i;if(i=r[e.toLowerCase()])return i===n;if(i=o[e.toLowerCase()])return i===n}else if("number"==typeof e)return e===n;return!1}};var r=(e=t.exports=n).code=e.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=e.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(i=97;i<123;i++)r[String.fromCharCode(i)]=i-32;for(var i=48;i<58;i++)r[i-48]=i;for(i=1;i<13;i++)r["f"+i]=i+111;for(i=0;i<10;i++)r["numpad "+i]=i+96;var s=e.names=e.title={};for(i in r)s[r[i]]=i;for(var a in o)r[a]=o[a]}(P={exports:{}},P.exports),P.exports),X=(Y.code,Y.codes,Y.aliases,Y.names);Y.title;function M(t){return Array.isArray(t)}function F(t){return"string"==typeof t}function R(t,e,n,i){t.addEventListener(e,n,i)}function L(t,e,n){t.removeEventListener(e,n)}var A,N={"+":"plus","left command":"meta","right command":"meta"},H={shift:1,ctrl:2,alt:3,meta:4};function I(t){var e=X[t]||"";for(var n in N)e=e.replace(n,N[n]);return e.replace(/\s/g,"")}function B(t){var e=t.slice();return e.sort(function(t,e){return(H[t]||5)-(H[e]||5)}),e}var q=function(n){function t(){this.constructor=e}var e,i;function r(t){void 0===t&&(t=window);var e=n.call(this)||this;return e.container=t,e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e.clear=function(){return e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e},e.keydownEvent=function(t){e.triggerEvent("keydown",t)},e.keyupEvent=function(t){e.triggerEvent("keyup",t)},R(t,"blur",e.clear),R(t,"keydown",e.keydownEvent),R(t,"keyup",e.keyupEvent),e}j(e=r,i=n),e.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var o=r.prototype;return Object.defineProperty(r,"global",{get:function(){return A=A||new r},enumerable:!0,configurable:!0}),r.setGlobal=function(){return this.global},o.destroy=function(){var t=this.container;this.clear(),this.off(),L(t,"blur",this.clear),L(t,"keydown",this.keydownEvent),L(t,"keyup",this.keyupEvent)},o.keydown=function(t,e){return this.addEvent("keydown",t,e)},o.offKeydown=function(t,e){return this.removeEvent("keydown",t,e)},o.offKeyup=function(t,e){return this.removeEvent("keyup",t,e)},o.keyup=function(t,e){return this.addEvent("keyup",t,e)},o.addEvent=function(t,e,n){return M(e)?this.on(t+"."+B(e).join("."),n):F(e)?this.on(t+"."+e,n):this.on(t,e),this},o.removeEvent=function(t,e,n){return M(e)?this.off(t+"."+B(e).join("."),n):F(e)?this.off(t+"."+e,n):this.off(t,e),this},o.triggerEvent=function(t,e){this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey;var n=I(e.keyCode),i={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:e,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey};this.trigger(t,i),this.trigger(t+"."+n,i);var r=function(t,e){void 0===e&&(e=I(t.keyCode));var n=[t.shiftKey&&"shift",t.ctrlKey&&"ctrl",t.altKey&&"alt",t.metaKey&&"meta"];return-1===n.indexOf(e)&&n.push(e),n.filter(Boolean)}(e,n);1<r.length&&this.trigger(t+"."+r.join("."),i)},r}(t);function U(t,e,n){var i=t.tag,r=t.children,o=t.attributes,s=t.className,a=t.style,c=e||document.createElement(i);for(var u in o)c.setAttribute(u,o[u]);var l=c.children;if(r.forEach(function(t,e){U(t,l[e],c)}),s&&s.split(" ").forEach(function(t){var e,n,i,r;r=t,((i=c).classList?i.classList.contains(r):i.className.match(new RegExp("(\\s|^)"+r+"(\\s|$)")))||(n=t,(e=c).classList?e.classList.add(n):e.className+=" "+n)}),a){var h=c.style;for(var u in a)h[u]=a[u]}return!e&&n&&n.appendChild(c),c}function z(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var r=e||{},o=r.className,s=r.style;return{tag:t,className:void 0===o?"":o,style:void 0===s?{}:s,attributes:function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(r,["className","style"]),children:n}}function G(t,e,n){t!==e&&n(t,e)}var V,$,J,Q,W=["dragContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate"],Z=(J="rCS"+e(V="\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),Q=0,{className:J,inject:function(t){var e,n=function(t){if(t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===Q;return(n||i)&&(e=o(J,V)),i&&($=e),n||++Q,{destroy:function(){n?(t.removeChild(e),e=null):(0<Q&&--Q,0===Q&&$&&($.parentNode.removeChild($),$=null))}}}}),tt=function(e){function t(){this.constructor=n}var n,i;function r(t){void 0===t&&(t={});var v=e.call(this)||this;return v.selectedTargets=[],v.differ=new T,v.onDragStart=function(t,e){var n=t.datas,i=t.clientX,r=t.clientY,o=t.inputEvent,s=v.options,a=s.continueSelect,c=s.selectFromInside,u=v.getSelectableTargets(),l=u.map(function(t){var e=t.getBoundingClientRect(),n=e.left,i=e.top;return{left:n,top:i,right:n+e.width,bottom:i+e.height}});n.selectableTargets=u,n.selectableRects=l,n.startSelectedTargets=v.selectedTargets;var h=e||document.elementFromPoint(i,r),f=v.hitTest({left:i,top:r,right:i,bottom:r},i,r,u,l).filter(function(t){return t===h||t.contains(h)}),d=0<f.length;a?f=v.getSelectedTargets(f):v.selectedTargets=[];var p=o.type;return!(("mousedown"===p||"touchstart"===p)&&!v.trigger("dragStart",t))&&(v.select(f,o,!0),n.startX=i,n.startY=r,n.selectedTargets=f,v.target.style.cssText+="left:"+i+"px;top:"+r+"px",!(!c&&d)||(v.onDragEnd(t),!1))},v.onDrag=function(t){var e=t.distX,n=t.distY,i=t.datas,r=t.inputEvent,o=i.startX,s=i.startY,a=Math.min(0,e),c=Math.min(0,n),u=Math.abs(e),l=Math.abs(n);v.target.style.cssText+="display: block;transform: translate("+a+"px, "+c+"px);width:"+u+"px;height:"+l+"px;";var h=o+a,f=s+c,d=v.hitTest({left:h,top:f,right:h+u,bottom:f+l},i.startX,i.startY,i.selectableTargets,i.selectableRects),p=v.getSelectedTargets(d);v.select(p,r),i.selectedTargets=p},v.onDragEnd=function(t){var e=t.datas,n=t.inputEvent;v.target.style.cssText+="display: none;",v.selecteEnd(e.startSelectedTargets,e.selectedTargets,n),v.selectedTargets=e.selectedTargets},v.onKeyDown=function(){v.continueSelect=!0,v.trigger("keydown",{})},v.onKeyUp=function(){v.continueSelect=!1,v.trigger("keyup",{})},v.target=t.target,v.container=t.container,v.options=u({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null},t),v.initElement(),v.setKeyController(),v}c(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var o,s,a=r.prototype;return a.setSelectedTargets=function(t){this.selectedTargets=t,this.differ=new T(t)},a.setKeyContainer=function(t){var e=this,n=this.options;G(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},a.setToggleContinueSelect=function(t){var e=this,n=this.options;G(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},a.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.dragger.unset(),this.injectResult.destroy(),this.keycon=null,this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},a.click=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),i={datas:{},clientX:n.clientX,clientY:n.clientY,inputEvent:t};this.onDragStart(i,e)&&this.onDragEnd(i)},a.setKeyController=function(){var t=this.options,e=t.keyContainer,n=t.toggleContinueSelect;this.keycon&&(this.keycon.destroy(),this.keycon=null),n&&(this.keycon=new q(e||window)),this.setKeyEvent()},a.setKeyEvent=function(){var t=this.options.toggleContinueSelect;this.keycon?(this.keycon.off(),t&&this.keycon.keydown(t,this.onKeyDown).keyup(t,this.onKeyUp)):this.setKeyController()},a.initElement=function(){this.target=U(z("div",{className:"selecto-selection "+Z.className}),this.target,this.container);var t=this.target;this.dragger=new E(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=Z.inject(t)},a.hitTest=function(t,d,p,v,e){var n=this.options,g=n.hitRate,y=n.selectByClick,m=t.left,C=t.top,b=t.right,E=t.bottom,k=[];return e.forEach(function(t,e){var n=t.left,i=t.top,r=t.right,o=t.bottom,s=n<=d&&d<=r&&i<=p&&p<=o,a=(r-n)*(o-i),c=Math.max(n,m),u=Math.min(r,b),l=Math.max(i,C),h=Math.min(o,E);if(y&&s)k.push(v[e]);else if(!(u<c||h<l)){var f=Math.round((u-c)*(h-l)/a*100);g<=f&&k.push(v[e])}}),k},a.getSelectableTargets=function(){var n=[];return this.options.selectableTargets.forEach(function(t){var e;(e=t)&&"object"==typeof e?n.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){n.push(t)})}),n},a.getSelectedTargets=function(t){var e=x(this.selectedTargets,t),n=e.list,i=e.prevList,r=e.added,o=e.removed;return r.map(function(t){return n[t]}).concat(o.map(function(t){return i[t]}))},a.select=function(t,e,n){var i=this.differ.update(t),r=i.added,o=i.removed,s=i.prevList,a=i.list;n&&this.trigger("selectStart",{selected:t,added:r.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e}),(r.length||o.length)&&this.trigger("select",{selected:t,added:r.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e})},a.selecteEnd=function(t,e,n){var i=x(t,e),r=i.added,o=i.removed,s=i.prevList,a=i.list,c=x(this.selectedTargets,e),u=c.added,l=c.removed,h=c.prevList,f=c.list,d=n.type,p="mousedown"===d||"touchstart"===d;this.trigger("selectEnd",{selected:e,added:r.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),afterAdded:u.map(function(t){return f[t]}),afterRemoved:l.map(function(t){return h[t]}),isDragStart:p,inputEvent:n})},r=function(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;0<=a;a--)(r=t[a])&&(s=(o<3?r(s):3<o?r(e,n,s):r(e,n))||s);return 3<o&&s&&Object.defineProperty(e,n,s),s}([(o=W,s=function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},i=("set "+e).replace(/[\s-_]([a-z])/g,function(t,e){return e.toUpperCase()});t[i]?n.set=function(t){this[i](t)}:n.set=function(t){this.options[e]=t},Object.defineProperty(t,e,n)},function(t){var e=t.prototype;o.forEach(function(t){s(e,t)})})],r)}(t),et={__proto__:null,default:tt};for(var nt in et)tt[nt]=et[nt];return tt}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Selecto=e()}(this,function(){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var u=function(){return(u=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function a(t){return void 0===t}var t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var i=!1,r=[e],o=0;e.stop=function(){i=!0},e.currentTarget=this;for(var s=arguments.length,a=new Array(2<s?s-2:0),c=2;c<s;c++)a[c-2]=arguments[c];for(1<=a.length&&(r=r.concat(a)),o=0;n[o];o++)n[o].apply(this,r);return!i},e.once=function(r,o){if("object"==typeof r&&a(o)){var t,e=r;for(t in e)this.once(t,e[t]);return this}if("string"==typeof r&&"function"==typeof o){var s=this;this.on(r,function t(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];o.apply(s,n),s.off(r,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&a(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}if("string"==typeof t&&"function"==typeof e){var r=this._eventHandler[t];a(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)}return this},e.off=function(t,e){if(a(t))return this._eventHandler={},this;if(a(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,i=t;for(n in i)this.off(n,i[n]);return this}var r,o,s=this._eventHandler[t];if(s)for(r=0;void 0!==(o=s[r]);r++)if(o===e){s=s.splice(r,1);break}return this},t}();return t.VERSION="2.1.2",t}();function l(t,e,n,i){t.addEventListener(e,n,i)}function n(t,e,n){t.removeEventListener(e,n)}var h=function(){return(h=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function f(t,e,n,i){var r=m(t),o=m(e),s=m(i);return p(C(i[0],b(r,s)),C(i[0],b(o,s)),n[0])}function d(t){return t.touches?y(t.touches):[r(t)]}function p(t,e,n){var i=t.clientX,r=t.clientY;return{clientX:i,clientY:r,deltaX:i-e.clientX,deltaY:r-e.clientY,distX:i-n.clientX,distY:r-n.clientY}}function v(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function g(t,n,i){return t.map(function(t,e){return p(t,n[e],i[e])})}function y(t){for(var e=Math.min(t.length,2),n=[],i=0;i<e;++i)n.push(r(t[i]));return n}function r(t){return{clientX:t.clientX,clientY:t.clientY}}function m(t){return{clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function C(t,e){return{clientX:t.clientX+e.clientX,clientY:t.clientY+e.clientY}}function b(t,e){return{clientX:t.clientX-e.clientX,clientY:t.clientY-e.clientY}}var E=function(){function t(t,e){var s=this;void 0===e&&(e={}),this.el=t,this.options={},this.flag=!1,this.pinchFlag=!1,this.datas={},this.isDrag=!1,this.isPinch=!1,this.isMouse=!1,this.isTouch=!1,this.prevClients=[],this.startClients=[],this.movement=0,this.startPinchClients=[],this.startDistance=0,this.customDist=[0,0],this.onDragStart=function(t){if(s.flag||!1!==t.cancelable){if((e=t).touches&&2<=e.touches.length){if(!s.flag&&t.touches.length!==t.changedTouches.length)return;s.pinchFlag||s.onPinchStart(t)}var e;if(!s.flag){var n=s.startClients[0]?s.startClients:d(t);s.customDist=[0,0],s.flag=!0,s.isDrag=!1,s.startClients=n,s.prevClients=n,s.datas={};var i=p(n[s.movement=0],s.prevClients[0],s.startClients[0]),r=s.options,o=r.dragstart;(r.preventRightClick&&3===t.which||!1===(o&&o(h({datas:s.datas,inputEvent:t},i))))&&(s.startClients=[],s.prevClients=[],s.flag=!1),s.flag&&t.preventDefault()}}},this.onDrag=function(t,e){if(s.flag){var n=d(t);s.pinchFlag&&s.onPinch(t,n);var i=s.move([0,0],t,n);if(i&&(i.deltaX||i.deltaY)){var r=s.options.drag;r&&r(h({},i,{isScroll:!!e,inputEvent:t}))}}},this.onDragEnd=function(t){if(s.flag){s.pinchFlag&&s.onPinchEnd(t),s.flag=!1;var e=s.options.dragend,n=s.prevClients,i=s.startClients,r=s.pinchFlag?f(n,n,i,s.startPinchClients):p(n[0],n[0],i[0]);s.startClients=[],s.prevClients=[],e&&e(h({datas:s.datas,isDrag:s.isDrag,inputEvent:t},r))}},this.options=h({container:t,preventRightClick:!0,pinchThreshold:0,events:["touch","mouse"]},e);var n=this.options,i=n.container,r=n.events;if(this.isTouch=-1<r.indexOf("touch"),this.isMouse=-1<r.indexOf("mouse"),this.customDist=[0,0],this.isMouse&&(l(t,"mousedown",this.onDragStart),l(i,"mousemove",this.onDrag),l(i,"mouseup",this.onDragEnd)),this.isTouch){var o={passive:!1};l(t,"touchstart",this.onDragStart,o),l(i,"touchmove",this.onDrag,o),l(i,"touchend",this.onDragEnd,o)}}var e=t.prototype;return e.isDragging=function(){return this.isDrag},e.isPinching=function(){return this.isPinch},e.scrollBy=function(e,n,t,i){void 0===i&&(i=!0),this.flag&&(this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),i&&this.onDrag(t,!0))},e.move=function(t,e,n){var i=t[0],r=t[1];void 0===n&&(n=this.prevClients);var o=this.customDist,s=this.prevClients,a=this.startClients,c=this.pinchFlag?f(n,s,a,this.startPinchClients):p(n[0],s[0],a[0]);o[0]+=i,o[1]+=r,c.deltaX+=i,c.deltaY+=r;var u=c.deltaX,l=c.deltaY;return c.distX+=o[0],c.distY+=o[1],this.movement+=Math.sqrt(u*u+l*l),this.prevClients=n,this.isDrag=!0,h({datas:this.datas},c,{isScroll:!1,inputEvent:e})},e.onPinchStart=function(t){var e,n,i=this.options,r=i.pinchstart,o=i.pinchThreshold;if(!(this.isDrag&&this.movement>o)){var s=y(t.changedTouches);if(this.pinchFlag=!0,(e=this.startClients).push.apply(e,s),(n=this.prevClients).push.apply(n,s),this.startDistance=v(this.prevClients),this.startPinchClients=this.prevClients.slice(),r){var a=this.prevClients,c=m(a),u=p(c,c,c);r(h({datas:this.datas,touches:g(a,a,a)},u,{inputEvent:t}))}}},e.onPinch=function(t,e){if(this.flag&&this.pinchFlag){this.isPinch=!0;var n=this.options.pinch;if(n){var i=this.prevClients,r=this.startClients,o=p(m(e),m(i),m(r)),s=v(e);n(h({datas:this.datas,touches:g(e,i,r),scale:s/this.startDistance,distance:s},o,{inputEvent:t}))}}},e.onPinchEnd=function(t){if(this.flag&&this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.options.pinchend;if(n){var i=this.prevClients,r=this.startClients,o=p(m(i),m(i),m(r));n(h({datas:this.datas,isPinch:e,touches:g(i,i,r)},o,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},e.unset=function(){var t=this.el,e=this.options.container;this.isMouse&&(n(t,"mousedown",this.onDragStart),n(e,"mousemove",this.onDrag),n(e,"mouseup",this.onDragEnd)),this.isTouch&&(n(t,"touchstart",this.onDragStart),n(e,"touchmove",this.onDrag),n(e,"touchend",this.onDragEnd))},t}();var k=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,i=this.values,r=n.indexOf(t),o=-1===r?n.length:r;n[o]=t,i[o]=e},t}(),w=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),O="function"==typeof Map,o=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var _=function(){function t(t,e,n,i,r,o,s,a){this.prevList=t,this.list=e,this.added=n,this.removed=i,this.changed=r,this.maintained=o,this.changedBeforeAdded=s,this.fixed=a}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,a,c,e=(t=this.changedBeforeAdded,n=this.fixed,a=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],i=new o;a[e]=i,c[n]=i}),a.forEach(function(t,e){t.connect(a[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],i=t[1];if(n===i)return[0,0];var r=a[n],o=c[i-1],s=r.getIndex();return r.disconnect(),o?r.connect(o,o.next):r.connect(void 0,a[0]),[s,r.getIndex()]})),u=this.changed,l=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],i=t[1],r=u[e],o=r[0],s=r[1];if(n!==i)return l.push([o,s]),!0}),this.cachePureChanged=l},t}();function i(t,e,n){var i=O?Map:n?w:k,r=n||function(t){return t},o=[],s=[],a=[],c=t.map(r),u=e.map(r),l=new i,h=new i,f=[],d=[],p={},v=[],g=0,y=0;return c.forEach(function(t,e){l.set(t,e)}),u.forEach(function(t,e){h.set(t,e)}),c.forEach(function(t,e){var n=h.get(t);void 0===n?(++y,s.push(e)):p[n]=y}),u.forEach(function(t,e){var n=l.get(t);void 0===n?(o.push(e),++g):(a.push([n,e]),y=p[e]||0,f.push([n-y,e-g]),d.push(e===n),n!==e&&v.push([n,e]))}),s.reverse(),new _(t,e,o,s,v,a,f,d)}var s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var e,D="function"==typeof Map?void 0:(e=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++e)}),K=function(e){function t(){this.constructor=n}var n,i;function r(t){return void 0===t&&(t=[]),e.call(this,t,D)||this}return s(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t),r}(function(){function t(t,e){void 0===t&&(t=[]),this.findKeyCallback=e,this.list=[].slice.call(t)}return t.prototype.update=function(t){var e=[].slice.call(t),n=i(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function S(t,e){return i(t,e,D)}var T=function(t,e){return(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var x,j=(function(t,e){function n(t){if(t&&"object"==typeof t){var e=t.which||t.keyCode||t.charCode;e&&(t=e)}if("number"==typeof t)return s[t];var n,i=String(t);return(n=r[i.toLowerCase()])?n:(n=o[i.toLowerCase()])||(1===i.length?i.charCodeAt(0):void 0)}n.isEventKey=function(t,e){if(t&&"object"==typeof t){var n=t.which||t.keyCode||t.charCode;if(null==n)return!1;if("string"==typeof e){var i;if(i=r[e.toLowerCase()])return i===n;if(i=o[e.toLowerCase()])return i===n}else if("number"==typeof e)return e===n;return!1}};var r=(e=t.exports=n).code=e.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=e.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(i=97;i<123;i++)r[String.fromCharCode(i)]=i-32;for(var i=48;i<58;i++)r[i-48]=i;for(i=1;i<13;i++)r["f"+i]=i+111;for(i=0;i<10;i++)r["numpad "+i]=i+96;var s=e.names=e.title={};for(i in r)s[r[i]]=i;for(var a in o)r[a]=o[a]}(x={exports:{}},x.exports),x.exports),P=(j.code,j.codes,j.aliases,j.names);j.title;function Y(t){return Array.isArray(t)}function X(t){return"string"==typeof t}function M(t,e,n,i){t.addEventListener(e,n,i)}function F(t,e,n){t.removeEventListener(e,n)}var R,L={"+":"plus","left command":"meta","right command":"meta"},A={shift:1,ctrl:2,alt:3,meta:4};function N(t){var e=P[t]||"";for(var n in L)e=e.replace(n,L[n]);return e.replace(/\s/g,"")}function H(t){var e=t.slice();return e.sort(function(t,e){return(A[t]||5)-(A[e]||5)}),e}var I=function(n){function t(){this.constructor=e}var e,i;function r(t){void 0===t&&(t=window);var e=n.call(this)||this;return e.container=t,e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e.clear=function(){return e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e},e.keydownEvent=function(t){e.triggerEvent("keydown",t)},e.keyupEvent=function(t){e.triggerEvent("keyup",t)},M(t,"blur",e.clear),M(t,"keydown",e.keydownEvent),M(t,"keyup",e.keyupEvent),e}T(e=r,i=n),e.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var o=r.prototype;return Object.defineProperty(r,"global",{get:function(){return R=R||new r},enumerable:!0,configurable:!0}),r.setGlobal=function(){return this.global},o.destroy=function(){var t=this.container;this.clear(),this.off(),F(t,"blur",this.clear),F(t,"keydown",this.keydownEvent),F(t,"keyup",this.keyupEvent)},o.keydown=function(t,e){return this.addEvent("keydown",t,e)},o.offKeydown=function(t,e){return this.removeEvent("keydown",t,e)},o.offKeyup=function(t,e){return this.removeEvent("keyup",t,e)},o.keyup=function(t,e){return this.addEvent("keyup",t,e)},o.addEvent=function(t,e,n){return Y(e)?this.on(t+"."+H(e).join("."),n):X(e)?this.on(t+"."+e,n):this.on(t,e),this},o.removeEvent=function(t,e,n){return Y(e)?this.off(t+"."+H(e).join("."),n):X(e)?this.off(t+"."+e,n):this.off(t,e),this},o.triggerEvent=function(t,e){this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey;var n=N(e.keyCode),i={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:e,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey};this.trigger(t,i),this.trigger(t+"."+n,i);var r=function(t,e){void 0===e&&(e=N(t.keyCode));var n=[t.shiftKey&&"shift",t.ctrlKey&&"ctrl",t.altKey&&"alt",t.metaKey&&"meta"];return-1===n.indexOf(e)&&n.push(e),n.filter(Boolean)}(e,n);1<r.length&&this.trigger(t+"."+r.join("."),i)},r}(t);function B(t,e,n){var i=t.tag,r=t.children,o=t.attributes,s=t.className,a=t.style,c=e||document.createElement(i);for(var u in o)c.setAttribute(u,o[u]);var l=c.children;if(r.forEach(function(t,e){B(t,l[e],c)}),s&&s.split(" ").forEach(function(t){var e,n,i,r;r=t,((i=c).classList?i.classList.contains(r):i.className.match(new RegExp("(\\s|^)"+r+"(\\s|$)")))||(n=t,(e=c).classList?e.classList.add(n):e.className+=" "+n)}),a){var h=c.style;for(var u in a)h[u]=a[u]}return!e&&n&&n.appendChild(c),c}function q(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var r=e||{},o=r.className,s=r.style;return{tag:t,className:void 0===o?"":o,style:void 0===s?{}:s,attributes:function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(r,["className","style"]),children:n}}function U(t,e,n){t!==e&&n(t,e)}function z(i,t,e){var n=document.createElement("style");return n.setAttribute("type","text/css"),n.innerHTML=t.replace(/([^}{]*){/gm,function(t,e){return((n=e.match(/("[^"]*"|'[^']*'|[^,\s()]*\((?:[^()]*|\([^()]*\))*\)[^,\s()]*|[^,])+/g))?n.map(function(t){return t.trim()}):[]).map(function(t){return-1<t.indexOf(":global")?t.replace(/\:global/g,""):-1<t.indexOf(":host")?""+t.replace(/\:host/g,"."+i):"."+i+" "+t}).join(", ")+"{";var n}),(e||document.head||document.body).appendChild(n),n}var G,V,$,J,Q=($="rCS"+function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0}(G="\n:host {\n position: absolute;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),J=0,{className:$,inject:function(t){var e,n=function(t){if(t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===J;return(n||i)&&(e=z($,G)),i&&(V=e),n||++J,{destroy:function(){n?(t.removeChild(e),e=null):(0<J&&--J,0===J&&V&&(V.parentNode.removeChild(V),V=null))}}}}),W="selecto-selection "+Q.className,Z=["dragContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate"],tt=function(e){function t(){this.constructor=n}var n,i;function r(t){void 0===t&&(t={});var v=e.call(this)||this;return v.selectedTargets=[],v.differ=new K,v.onDragStart=function(t,e){var n=t.datas,i=t.clientX,r=t.clientY,o=t.inputEvent,s=v.options,a=s.continueSelect,c=s.selectFromInside,u=v.getSelectableTargets(),l=u.map(function(t){var e=t.getBoundingClientRect(),n=e.left,i=e.top;return{left:n,top:i,right:n+e.width,bottom:i+e.height}});n.selectableTargets=u,n.selectableRects=l,n.startSelectedTargets=v.selectedTargets;var h=e||document.elementFromPoint(i,r),f=v.hitTest({left:i,top:r,right:i,bottom:r},i,r,u,l).filter(function(t){return t===h||t.contains(h)}),d=0<f.length;a?f=v.getSelectedTargets(f):v.selectedTargets=[];var p=o.type;return!(("mousedown"===p||"touchstart"===p)&&!v.trigger("dragStart",t))&&(v.select(f,o,!0),n.startX=i,n.startY=r,n.selectedTargets=f,v.target.style.cssText+="left:"+i+"px;top:"+r+"px",!(!c&&d)||(v.onDragEnd(t),!1))},v.onDrag=function(t){var e=t.distX,n=t.distY,i=t.datas,r=t.inputEvent,o=i.startX,s=i.startY,a=Math.min(0,e),c=Math.min(0,n),u=Math.abs(e),l=Math.abs(n);v.target.style.cssText+="display: block;transform: translate("+a+"px, "+c+"px);width:"+u+"px;height:"+l+"px;";var h=o+a,f=s+c,d=v.hitTest({left:h,top:f,right:h+u,bottom:f+l},i.startX,i.startY,i.selectableTargets,i.selectableRects),p=v.getSelectedTargets(d);v.select(p,r),i.selectedTargets=p},v.onDragEnd=function(t){var e=t.datas,n=t.inputEvent;v.target.style.cssText+="display: none;",v.selecteEnd(e.startSelectedTargets,e.selectedTargets,n),v.selectedTargets=e.selectedTargets},v.onKeyDown=function(){v.continueSelect=!0,v.trigger("keydown",{})},v.onKeyUp=function(){v.continueSelect=!1,v.trigger("keyup",{})},v.target=t.target,v.container=t.container,v.options=u({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null},t),v.initElement(),v.setKeyController(),v}c(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var o,s,a=r.prototype;return a.setSelectedTargets=function(t){this.selectedTargets=t,this.differ=new K(t)},a.setKeyContainer=function(t){var e=this,n=this.options;U(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},a.setToggleContinueSelect=function(t){var e=this,n=this.options;U(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},a.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.dragger.unset(),this.injectResult.destroy(),this.keycon=null,this.dragger=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},a.click=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),i={datas:{},clientX:n.clientX,clientY:n.clientY,inputEvent:t};this.onDragStart(i,e)&&this.onDragEnd(i)},a.setKeyController=function(){var t=this.options,e=t.keyContainer,n=t.toggleContinueSelect;this.keycon&&(this.keycon.destroy(),this.keycon=null),n&&(this.keycon=new I(e||window)),this.setKeyEvent()},a.setKeyEvent=function(){var t=this.options.toggleContinueSelect;this.keycon?(this.keycon.off(),t&&this.keycon.keydown(t,this.onKeyDown).keyup(t,this.onKeyUp)):this.setKeyController()},a.initElement=function(){this.target=B(q("div",{className:W}),this.target,this.container);var t=this.target;this.dragger=new E(this.options.dragContainer||this.target.parentElement,{container:window,dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd}),this.injectResult=Q.inject(t)},a.hitTest=function(t,d,p,v,e){var n=this.options,g=n.hitRate,y=n.selectByClick,m=t.left,C=t.top,b=t.right,E=t.bottom,k=[];return e.forEach(function(t,e){var n=t.left,i=t.top,r=t.right,o=t.bottom,s=n<=d&&d<=r&&i<=p&&p<=o,a=(r-n)*(o-i),c=Math.max(n,m),u=Math.min(r,b),l=Math.max(i,C),h=Math.min(o,E);if(y&&s)k.push(v[e]);else if(!(u<c||h<l)){var f=Math.round((u-c)*(h-l)/a*100);g<=f&&k.push(v[e])}}),k},a.getSelectableTargets=function(){var n=[];return this.options.selectableTargets.forEach(function(t){var e;(e=t)&&"object"==typeof e?n.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){n.push(t)})}),n},a.getSelectedTargets=function(t){var e=S(this.selectedTargets,t),n=e.list,i=e.prevList,r=e.added,o=e.removed;return r.map(function(t){return n[t]}).concat(o.map(function(t){return i[t]}))},a.select=function(t,e,n){var i=this.differ.update(t),r=i.added,o=i.removed,s=i.prevList,a=i.list;n&&this.trigger("selectStart",{selected:t,added:r.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e}),(r.length||o.length)&&this.trigger("select",{selected:t,added:r.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),inputEvent:e})},a.selecteEnd=function(t,e,n){var i=S(t,e),r=i.added,o=i.removed,s=i.prevList,a=i.list,c=S(this.selectedTargets,e),u=c.added,l=c.removed,h=c.prevList,f=c.list,d=n.type,p="mousedown"===d||"touchstart"===d;this.trigger("selectEnd",{selected:e,added:r.map(function(t){return a[t]}),removed:o.map(function(t){return s[t]}),afterAdded:u.map(function(t){return f[t]}),afterRemoved:l.map(function(t){return h[t]}),isDragStart:p,inputEvent:n})},r=function(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;0<=a;a--)(r=t[a])&&(s=(o<3?r(s):3<o?r(e,n,s):r(e,n))||s);return 3<o&&s&&Object.defineProperty(e,n,s),s}([(o=Z,s=function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},i=("set "+e).replace(/[\s-_]([a-z])/g,function(t,e){return e.toUpperCase()});t[i]?n.set=function(t){this[i](t)}:n.set=function(t){this.options[e]=t},Object.defineProperty(t,e,n)},function(t){var e=t.prototype;o.forEach(function(t){s(e,t)})})],r)}(t),et={__proto__:null,default:tt};for(var nt in et)tt[nt]=et[nt];return tt}); | ||
//# sourceMappingURL=selecto.pkgd.min.js.map |
{ | ||
"name": "selecto", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/selecto.cjs.js", |
@@ -0,4 +1,21 @@ | ||
import styled from "css-styled"; | ||
export const injector = styled(` | ||
:host { | ||
position: absolute; | ||
display: none; | ||
border: 1px solid #4af; | ||
background: rgba(68, 170, 255, 0.5); | ||
z-index: 100; | ||
} | ||
`); | ||
/** | ||
* @memberof Selecto | ||
*/ | ||
export const CLASS_NAME = `selecto-selection ${injector.className}`; | ||
/** | ||
* @memberof Selecto | ||
*/ | ||
export const OPTIONS = [ | ||
@@ -5,0 +22,0 @@ // ignore target, container, |
import Selecto from "./Selecto"; | ||
export default Selecto; | ||
export * from "./consts"; | ||
export { | ||
OPTIONS, | ||
PROPERTIES, | ||
EVENTS, | ||
METHODS, | ||
CLASS_NAME, | ||
} from "./consts"; | ||
export * from "./types"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
446162
5750