Comparing version 1.7.4 to 1.8.0
import { SelectoOptions } from "./types"; | ||
export declare const injector: import("css-styled").StyledInjector; | ||
export declare const CLASS_NAME: string; | ||
export declare const PROPERTIES: readonly ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementPoints"]; | ||
export declare const OPTIONS: readonly ["dragContainer", "cspNonce", ...("boundContainer" | "selectableTargets" | "selectByClick" | "selectFromInside" | "continueSelect" | "toggleContinueSelect" | "keyContainer" | "hitRate" | "scrollOptions" | "checkInput" | "preventDefault" | "ratio" | "getElementPoints")[]]; | ||
export declare const PROPERTIES: readonly ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementRect"]; | ||
export declare const OPTIONS: readonly ["dragContainer", "cspNonce", ...("boundContainer" | "selectableTargets" | "selectByClick" | "selectFromInside" | "continueSelect" | "toggleContinueSelect" | "keyContainer" | "hitRate" | "scrollOptions" | "checkInput" | "preventDefault" | "ratio" | "getElementRect")[]]; | ||
export declare const OPTION_TYPES: { | ||
@@ -7,0 +7,0 @@ [key in keyof SelectoOptions]: any; |
@@ -1,46 +0,4 @@ | ||
import EventEmitter from "@scena/event-emitter"; | ||
import { SelectoOptions, SelectoProperties, SelectoEvents } from "./types"; | ||
declare class Selecto extends EventEmitter<SelectoEvents> { | ||
options: SelectoOptions; | ||
private target; | ||
private dragContainer; | ||
private container; | ||
private gesto; | ||
private injectResult; | ||
private selectedTargets; | ||
private differ; | ||
private dragScroll; | ||
private keycon; | ||
constructor(options?: Partial<SelectoOptions>); | ||
setSelectedTargets(selectedTargets: Array<HTMLElement | SVGElement>): this; | ||
getSelectedTargets(): Array<HTMLElement | SVGElement>; | ||
setKeyContainer(keyContainer: HTMLElement | Document | Window): void; | ||
setToggleContinueSelect(toggleContinueSelect: string[][] | string[] | string): void; | ||
setPreventDefault(value: boolean): void; | ||
setCheckInput(value: boolean): void; | ||
triggerDragStart(e: MouseEvent | TouchEvent): this; | ||
destroy(): void; | ||
findSelectableTargets(datas?: any): void; | ||
clickTarget(e: MouseEvent | TouchEvent, clickedTarget?: Element): this; | ||
private setKeyController; | ||
private setKeyEvent; | ||
private initElement; | ||
private hitTest; | ||
private initDragScroll; | ||
private getSelectableTargets; | ||
private passSelectedTargets; | ||
private select; | ||
private selectEnd; | ||
private onDragStart; | ||
private check; | ||
private onDrag; | ||
private onDragEnd; | ||
private sameCombiKey; | ||
private onKeyDown; | ||
private onKeyUp; | ||
private onBlur; | ||
private onDocumentSelectStart; | ||
import SelectoManager from "./SelectoManager"; | ||
declare class Selecto extends SelectoManager { | ||
} | ||
interface Selecto extends SelectoProperties { | ||
} | ||
export default Selecto; |
@@ -23,3 +23,3 @@ import { IObject } from "@daybrush/utils"; | ||
ratio: number; | ||
getElementPoints: GetElementPointsFunction; | ||
getElementRect: getElementRectFunction; | ||
} | ||
@@ -82,5 +82,7 @@ export interface Hypertext { | ||
rect: Rect; | ||
isSelect: boolean; | ||
} | ||
export interface OnDragEnd extends OnParentDragEnd { | ||
rect: Rect; | ||
isSelect: boolean; | ||
} | ||
@@ -104,3 +106,4 @@ export interface SelectoEvents { | ||
}; | ||
export declare type GetElementPointsFunction = (el: HTMLElement | SVGElement) => { | ||
export declare type getElementRectFunction = (el: HTMLElement | SVGElement) => PointArea; | ||
export interface PointArea { | ||
pos1: number[]; | ||
@@ -110,2 +113,2 @@ pos2: number[]; | ||
pos4: number[]; | ||
}; | ||
} |
@@ -10,9 +10,4 @@ import { Hypertext, Rect } from "./types"; | ||
export declare function diffValue<T>(prev: T, cur: T, func: (prev: T, cur: T) => void): void; | ||
export declare function getRect(e: any, ratio: number, boundArea: { | ||
left: number; | ||
right: number; | ||
top: number; | ||
bottom: number; | ||
}): Rect; | ||
export declare function getDefaultElementPoints(el: HTMLElement): { | ||
export declare function getRect(e: any, ratio: number, boundArea?: any): Rect; | ||
export declare function getDefaultElementRect(el: HTMLElement): { | ||
pos1: number[]; | ||
@@ -23,1 +18,2 @@ pos2: number[]; | ||
}; | ||
export declare function passTargets(beforeTargets: Array<HTMLElement | SVGElement>, afterTargets: Array<HTMLElement | SVGElement>): (HTMLElement | SVGElement)[]; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 1.7.4 | ||
version: 1.8.0 | ||
*/ | ||
@@ -16,5 +16,6 @@ 'use strict'; | ||
var utils = require('@daybrush/utils'); | ||
var ChildrenDiffer = require('@egjs/children-differ'); | ||
var childrenDiffer = require('@egjs/children-differ'); | ||
var DragScroll = require('@scena/dragscroll'); | ||
var KeyController = require('keycon'); | ||
var overlapArea = require('overlap-area'); | ||
var styled = require('css-styled'); | ||
@@ -180,2 +181,6 @@ | ||
if (boundArea === void 0) { | ||
boundArea = e.datas.boundArea; | ||
} | ||
var _b = e.distX, | ||
@@ -216,3 +221,3 @@ distX = _b === void 0 ? 0 : _b, | ||
} | ||
function getDefaultElementPoints(el) { | ||
function getDefaultElementRect(el) { | ||
var rect = el.getBoundingClientRect(); | ||
@@ -230,3 +235,16 @@ var left = rect.left, | ||
} | ||
function passTargets(beforeTargets, afterTargets) { | ||
var _a = childrenDiffer.diff(beforeTargets, afterTargets), | ||
list = _a.list, | ||
prevList = _a.prevList, | ||
added = _a.added, | ||
removed = _a.removed; | ||
return added.map(function (index) { | ||
return list[index]; | ||
}).concat(removed.map(function (index) { | ||
return prevList[index]; | ||
})); | ||
} | ||
var injector = styled("\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
@@ -238,3 +256,3 @@ /** | ||
var CLASS_NAME = "selecto-selection " + injector.className; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementPoints"]; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementRect"]; | ||
/** | ||
@@ -263,3 +281,3 @@ * @memberof Selecto | ||
ratio: Number, | ||
getElementPoints: Function | ||
getElementRect: Function | ||
}; | ||
@@ -300,3 +318,2 @@ /** | ||
_this.selectedTargets = []; | ||
_this.differ = new ChildrenDiffer(); | ||
_this.dragScroll = new DragScroll(); | ||
@@ -346,3 +363,2 @@ | ||
datas.boundArea = boundArea; | ||
datas.selectedTargets = []; | ||
var hitRect = { | ||
@@ -419,21 +435,21 @@ left: clientX, | ||
if (!continueSelect) { | ||
_this.selectedTargets = []; | ||
datas.startPassedTargets = []; | ||
} else { | ||
firstPassedTargets = _this.passSelectedTargets(firstPassedTargets); | ||
firstPassedTargets = passTargets(_this.selectedTargets, firstPassedTargets); | ||
datas.startPassedTargets = _this.selectedTargets; | ||
} | ||
_this.select(firstPassedTargets, hitRect, inputEvent, true); | ||
_this.select(_this.selectedTargets, firstPassedTargets, hitRect, inputEvent, true); | ||
datas.startX = clientX; | ||
datas.startY = clientY; | ||
datas.selectedTargets = firstPassedTargets; | ||
datas.selectFlag = false; | ||
datas.boundsArea = _this.target.style.cssText += "left:0px;top:0px;transform: translate(" + clientX + "px, " + clientY + "px)"; | ||
if (isPreventSelect && selectByClick) { | ||
_this.onDragEnd(e); | ||
inputEvent.preventDefault(); | ||
e.stop(); | ||
return false; | ||
} else { | ||
datas.selectFlag = true; | ||
if (type === "touchstart") { | ||
@@ -454,7 +470,9 @@ inputEvent.preventDefault(); | ||
_this.onDrag = function (e) { | ||
var scrollOptions = _this.options.scrollOptions; | ||
if (e.datas.selectFlag) { | ||
var scrollOptions = _this.options.scrollOptions; | ||
if (scrollOptions && scrollOptions.container) { | ||
if (_this.dragScroll.drag(e, scrollOptions)) { | ||
return; | ||
if (scrollOptions && scrollOptions.container) { | ||
if (_this.dragScroll.drag(e, scrollOptions)) { | ||
return; | ||
} | ||
} | ||
@@ -469,12 +487,10 @@ } | ||
inputEvent = e.inputEvent; | ||
var rect = getRect(e, _this.options.ratio, datas.boundArea); | ||
var rect = getRect(e, _this.options.ratio); | ||
var selectFlag = datas.selectFlag; | ||
_this.dragScroll.dragEnd(); | ||
_this.target.style.cssText += "display: none;"; | ||
if (inputEvent && inputEvent.type !== "mousedown" && inputEvent.type !== "touchstart") { | ||
if (inputEvent) { | ||
_this.trigger("dragEnd", __assign(__assign({ | ||
isDouble: false, | ||
isDrag: false | ||
isDrag: false, | ||
isSelect: selectFlag | ||
}, e), { | ||
@@ -485,5 +501,11 @@ rect: rect | ||
_this.selectEnd(datas.startSelectedTargets, datas.selectedTargets, rect, e); | ||
if (selectFlag) { | ||
datas.selectFlag = false; | ||
_this.selectedTargets = datas.selectedTargets; | ||
_this.dragScroll.dragEnd(); | ||
_this.target.style.cssText += "display: none;"; | ||
} | ||
_this.selectEnd(datas.startSelectedTargets, datas.startPassedTargets, rect, e); | ||
}; | ||
@@ -593,3 +615,3 @@ | ||
_this.target = options.target; | ||
_this.container = options.container; | ||
_this.container = options.container || document.body; | ||
_this.options = __assign({ | ||
@@ -610,3 +632,3 @@ target: null, | ||
boundContainer: false, | ||
getElementPoints: getDefaultElementPoints, | ||
getElementRect: getDefaultElementRect, | ||
cspNonce: "", | ||
@@ -634,3 +656,2 @@ ratio: 0 | ||
this.selectedTargets = selectedTargets; | ||
this.differ = new ChildrenDiffer(selectedTargets); | ||
return this; | ||
@@ -712,2 +733,15 @@ }; | ||
}; | ||
__proto.getElementPoints = function (target) { | ||
var getElementRect = this.getElementRect; | ||
var info = getElementRect(target); | ||
var points = [info.pos1, info.pos2, info.pos4, info.pos3]; | ||
if (getElementRect !== getDefaultElementRect) { | ||
var rect = target.getBoundingClientRect(); | ||
return overlapArea.fitPoints(points, rect); | ||
} | ||
return points; | ||
}; | ||
/** | ||
@@ -719,2 +753,4 @@ * Find for selectableTargets again during drag event | ||
__proto.findSelectableTargets = function (datas) { | ||
var _this = this; | ||
if (datas === void 0) { | ||
@@ -724,6 +760,5 @@ datas = this.gesto.getEventDatas(); | ||
var getElementPoints = this.getElementPoints; | ||
var selectableTargets = this.getSelectableTargets(); | ||
var selectablePoints = selectableTargets.map(function (target) { | ||
return getElementPoints(target); | ||
return _this.getElementPoints(target); | ||
}); | ||
@@ -746,3 +781,5 @@ datas.selectableTargets = selectableTargets; | ||
var dragEvent = { | ||
datas: {}, | ||
datas: { | ||
flag: false | ||
}, | ||
clientX: clientX, | ||
@@ -757,2 +794,3 @@ clientY: clientY, | ||
if (this.onDragStart(dragEvent, clickedTarget)) { | ||
dragEvent.datas.flag = false; | ||
this.onDragEnd(dragEvent); | ||
@@ -816,3 +854,3 @@ } | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, points) { | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, selectablePoints) { | ||
var _a = this.options, | ||
@@ -825,39 +863,22 @@ hitRate = _a.hitRate, | ||
bottom = selectRect.bottom; | ||
return targets.filter(function (target, i) { | ||
var _a = points[i], | ||
pos1 = _a.pos1, | ||
pos2 = _a.pos2, | ||
pos3 = _a.pos3, | ||
pos4 = _a.pos4; | ||
var rectPoints = [[left, top], [right, top], [right, bottom], [left, bottom]]; | ||
return targets.filter(function (_, i) { | ||
var points = selectablePoints[i]; | ||
var inArea = overlapArea.isInside([clientX, clientY], points); | ||
var _b = [0, 1].map(function (j) { | ||
return Math.min(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectLeft = _b[0], | ||
rectTop = _b[1]; | ||
var _c = [0, 1].map(function (j) { | ||
return Math.max(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectRight = _c[0], | ||
rectBottom = _c[1]; | ||
var isStart = rectLeft <= clientX && clientX <= rectRight && rectTop <= clientY && clientY <= rectBottom; | ||
var rectSize = (rectRight - rectLeft) * (rectBottom - rectTop); | ||
var testLeft = Math.max(rectLeft, left); | ||
var testRight = Math.min(rectRight, right); | ||
var testTop = Math.max(rectTop, top); | ||
var testBottom = Math.min(rectBottom, bottom); | ||
if (selectByClick && isStart) { | ||
if (selectByClick && inArea) { | ||
return true; | ||
} | ||
if (testRight < testLeft || testBottom < testTop) { | ||
var overlapPoints = overlapArea.getOverlapPoints(rectPoints, points); | ||
if (!overlapPoints.length) { | ||
return false; | ||
} | ||
var rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100); | ||
var overlapSize = overlapArea.getAreaSize(overlapPoints); | ||
var targetSize = overlapArea.getAreaSize(points); | ||
var rate = utils.between(Math.round(overlapSize / targetSize * 100), 0, 100); | ||
if (rate >= hitRate) { | ||
if (rate >= Math.min(100, hitRate)) { | ||
return true; | ||
@@ -888,4 +909,4 @@ } | ||
datas.startY -= offsetY; | ||
datas.selectablePoints.forEach(function (rect) { | ||
[rect.pos1, rect.pos2, rect.pos3, rect.pos4].forEach(function (pos) { | ||
datas.selectablePoints.forEach(function (points) { | ||
points.forEach(function (pos) { | ||
pos[0] -= offsetX; | ||
@@ -920,19 +941,5 @@ pos[1] -= offsetY; | ||
__proto.passSelectedTargets = function (passedTargets) { | ||
var _a = ChildrenDiffer.diff(this.selectedTargets, passedTargets), | ||
list = _a.list, | ||
prevList = _a.prevList, | ||
__proto.select = function (prevSelectedTargets, selectedTargets, rect, inputEvent, isStart) { | ||
var _a = childrenDiffer.diff(prevSelectedTargets, selectedTargets), | ||
added = _a.added, | ||
removed = _a.removed; | ||
return added.map(function (index) { | ||
return list[index]; | ||
}).concat(removed.map(function (index) { | ||
return prevList[index]; | ||
})); | ||
}; | ||
__proto.select = function (selectedTargets, rect, inputEvent, isStart) { | ||
var _a = this.differ.update(selectedTargets), | ||
added = _a.added, | ||
removed = _a.removed, | ||
@@ -942,2 +949,4 @@ prevList = _a.prevList, | ||
this.selectedTargets = selectedTargets; | ||
if (isStart) { | ||
@@ -1025,7 +1034,7 @@ /** | ||
__proto.selectEnd = function (startSelectedTargets, selectedTargets, rect, e) { | ||
__proto.selectEnd = function (startSelectedTargets, startPassedTargets, rect, e) { | ||
var inputEvent = e.inputEvent, | ||
isDouble = e.isDouble; | ||
var _a = ChildrenDiffer.diff(startSelectedTargets, selectedTargets), | ||
var _a = childrenDiffer.diff(startSelectedTargets, this.selectedTargets), | ||
added = _a.added, | ||
@@ -1036,3 +1045,3 @@ removed = _a.removed, | ||
var _b = ChildrenDiffer.diff(this.selectedTargets, selectedTargets), | ||
var _b = childrenDiffer.diff(startPassedTargets, this.selectedTargets), | ||
afterAdded = _b.added, | ||
@@ -1077,3 +1086,3 @@ afterRemoved = _b.removed, | ||
this.trigger("selectEnd", { | ||
selected: selectedTargets, | ||
selected: this.selectedTargets, | ||
added: added.map(function (index) { | ||
@@ -1098,6 +1107,9 @@ return list[index]; | ||
__proto.check = function (e) { | ||
__proto.check = function (e, rect) { | ||
if (rect === void 0) { | ||
rect = getRect(e, this.options.ratio); | ||
} | ||
var datas = e.datas, | ||
inputEvent = e.inputEvent; | ||
var rect = getRect(e, this.options.ratio, datas.boundArea); | ||
var top = rect.top, | ||
@@ -1107,10 +1119,22 @@ left = rect.left, | ||
height = rect.height; | ||
this.target.style.cssText += "display: block;" + "left:0px;top:0px;" + ("transform: translate(" + left + "px, " + top + "px);") + ("width:" + width + "px;height:" + height + "px;"); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectablePoints); | ||
var selectedTargets = this.passSelectedTargets(passedTargets); | ||
var selectFlag = datas.selectFlag; | ||
var prevSelectedTargets = []; | ||
var selectedTargets = []; | ||
if (selectFlag) { | ||
this.target.style.cssText += "display: block;" + "left:0px;top:0px;" + ("transform: translate(" + left + "px, " + top + "px);") + ("width:" + width + "px;height:" + height + "px;"); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectablePoints); | ||
prevSelectedTargets = this.selectedTargets; | ||
selectedTargets = passTargets(datas.startPassedTargets, passedTargets); | ||
this.selectedTargets = selectedTargets; | ||
} | ||
this.trigger("drag", __assign(__assign({}, e), { | ||
isSelect: selectFlag, | ||
rect: rect | ||
})); | ||
this.select(selectedTargets, rect, inputEvent); | ||
datas.selectedTargets = selectedTargets; | ||
if (selectFlag) { | ||
this.select(prevSelectedTargets, selectedTargets, rect, inputEvent); | ||
} | ||
}; | ||
@@ -1164,7 +1188,19 @@ | ||
var Selecto$1 = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
__extends(Selecto, _super); | ||
function Selecto() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return Selecto; | ||
}(Selecto); | ||
var modules = ({ | ||
__proto__: null, | ||
'default': Selecto, | ||
'default': Selecto$1, | ||
OPTIONS: OPTIONS, | ||
@@ -1179,6 +1215,6 @@ OPTION_TYPES: OPTION_TYPES, | ||
for (var name in modules) { | ||
Selecto[name] = modules[name]; | ||
Selecto$1[name] = modules[name]; | ||
} | ||
module.exports = Selecto; | ||
module.exports = Selecto$1; | ||
//# sourceMappingURL=selecto.cjs.js.map |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 1.7.4 | ||
version: 1.8.0 | ||
*/ | ||
@@ -13,6 +13,7 @@ import EventEmitter from '@scena/event-emitter'; | ||
import { Properties } from 'framework-utils'; | ||
import { hasClass, addClass, calculateBoundSize, removeEvent, addEvent, isObject, isArray, camelize, isString } from '@daybrush/utils'; | ||
import ChildrenDiffer, { diff } from '@egjs/children-differ'; | ||
import { hasClass, addClass, calculateBoundSize, isString, removeEvent, addEvent, between, isObject, isArray, camelize } from '@daybrush/utils'; | ||
import { diff } from '@egjs/children-differ'; | ||
import DragScroll from '@scena/dragscroll'; | ||
import KeyController, { getCombi } from 'keycon'; | ||
import { fitPoints, isInside, getOverlapPoints, getAreaSize } from 'overlap-area'; | ||
import styled from 'css-styled'; | ||
@@ -178,2 +179,6 @@ | ||
if (boundArea === void 0) { | ||
boundArea = e.datas.boundArea; | ||
} | ||
var _b = e.distX, | ||
@@ -214,3 +219,3 @@ distX = _b === void 0 ? 0 : _b, | ||
} | ||
function getDefaultElementPoints(el) { | ||
function getDefaultElementRect(el) { | ||
var rect = el.getBoundingClientRect(); | ||
@@ -228,3 +233,16 @@ var left = rect.left, | ||
} | ||
function passTargets(beforeTargets, afterTargets) { | ||
var _a = diff(beforeTargets, afterTargets), | ||
list = _a.list, | ||
prevList = _a.prevList, | ||
added = _a.added, | ||
removed = _a.removed; | ||
return added.map(function (index) { | ||
return list[index]; | ||
}).concat(removed.map(function (index) { | ||
return prevList[index]; | ||
})); | ||
} | ||
var injector = styled("\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
@@ -236,3 +254,3 @@ /** | ||
var CLASS_NAME = "selecto-selection " + injector.className; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementPoints"]; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementRect"]; | ||
/** | ||
@@ -261,3 +279,3 @@ * @memberof Selecto | ||
ratio: Number, | ||
getElementPoints: Function | ||
getElementRect: Function | ||
}; | ||
@@ -298,3 +316,2 @@ /** | ||
_this.selectedTargets = []; | ||
_this.differ = new ChildrenDiffer(); | ||
_this.dragScroll = new DragScroll(); | ||
@@ -344,3 +361,2 @@ | ||
datas.boundArea = boundArea; | ||
datas.selectedTargets = []; | ||
var hitRect = { | ||
@@ -417,21 +433,21 @@ left: clientX, | ||
if (!continueSelect) { | ||
_this.selectedTargets = []; | ||
datas.startPassedTargets = []; | ||
} else { | ||
firstPassedTargets = _this.passSelectedTargets(firstPassedTargets); | ||
firstPassedTargets = passTargets(_this.selectedTargets, firstPassedTargets); | ||
datas.startPassedTargets = _this.selectedTargets; | ||
} | ||
_this.select(firstPassedTargets, hitRect, inputEvent, true); | ||
_this.select(_this.selectedTargets, firstPassedTargets, hitRect, inputEvent, true); | ||
datas.startX = clientX; | ||
datas.startY = clientY; | ||
datas.selectedTargets = firstPassedTargets; | ||
datas.selectFlag = false; | ||
datas.boundsArea = _this.target.style.cssText += "left:0px;top:0px;transform: translate(" + clientX + "px, " + clientY + "px)"; | ||
if (isPreventSelect && selectByClick) { | ||
_this.onDragEnd(e); | ||
inputEvent.preventDefault(); | ||
e.stop(); | ||
return false; | ||
} else { | ||
datas.selectFlag = true; | ||
if (type === "touchstart") { | ||
@@ -452,7 +468,9 @@ inputEvent.preventDefault(); | ||
_this.onDrag = function (e) { | ||
var scrollOptions = _this.options.scrollOptions; | ||
if (e.datas.selectFlag) { | ||
var scrollOptions = _this.options.scrollOptions; | ||
if (scrollOptions && scrollOptions.container) { | ||
if (_this.dragScroll.drag(e, scrollOptions)) { | ||
return; | ||
if (scrollOptions && scrollOptions.container) { | ||
if (_this.dragScroll.drag(e, scrollOptions)) { | ||
return; | ||
} | ||
} | ||
@@ -467,12 +485,10 @@ } | ||
inputEvent = e.inputEvent; | ||
var rect = getRect(e, _this.options.ratio, datas.boundArea); | ||
var rect = getRect(e, _this.options.ratio); | ||
var selectFlag = datas.selectFlag; | ||
_this.dragScroll.dragEnd(); | ||
_this.target.style.cssText += "display: none;"; | ||
if (inputEvent && inputEvent.type !== "mousedown" && inputEvent.type !== "touchstart") { | ||
if (inputEvent) { | ||
_this.trigger("dragEnd", __assign(__assign({ | ||
isDouble: false, | ||
isDrag: false | ||
isDrag: false, | ||
isSelect: selectFlag | ||
}, e), { | ||
@@ -483,5 +499,11 @@ rect: rect | ||
_this.selectEnd(datas.startSelectedTargets, datas.selectedTargets, rect, e); | ||
if (selectFlag) { | ||
datas.selectFlag = false; | ||
_this.selectedTargets = datas.selectedTargets; | ||
_this.dragScroll.dragEnd(); | ||
_this.target.style.cssText += "display: none;"; | ||
} | ||
_this.selectEnd(datas.startSelectedTargets, datas.startPassedTargets, rect, e); | ||
}; | ||
@@ -591,3 +613,3 @@ | ||
_this.target = options.target; | ||
_this.container = options.container; | ||
_this.container = options.container || document.body; | ||
_this.options = __assign({ | ||
@@ -608,3 +630,3 @@ target: null, | ||
boundContainer: false, | ||
getElementPoints: getDefaultElementPoints, | ||
getElementRect: getDefaultElementRect, | ||
cspNonce: "", | ||
@@ -632,3 +654,2 @@ ratio: 0 | ||
this.selectedTargets = selectedTargets; | ||
this.differ = new ChildrenDiffer(selectedTargets); | ||
return this; | ||
@@ -710,2 +731,15 @@ }; | ||
}; | ||
__proto.getElementPoints = function (target) { | ||
var getElementRect = this.getElementRect; | ||
var info = getElementRect(target); | ||
var points = [info.pos1, info.pos2, info.pos4, info.pos3]; | ||
if (getElementRect !== getDefaultElementRect) { | ||
var rect = target.getBoundingClientRect(); | ||
return fitPoints(points, rect); | ||
} | ||
return points; | ||
}; | ||
/** | ||
@@ -717,2 +751,4 @@ * Find for selectableTargets again during drag event | ||
__proto.findSelectableTargets = function (datas) { | ||
var _this = this; | ||
if (datas === void 0) { | ||
@@ -722,6 +758,5 @@ datas = this.gesto.getEventDatas(); | ||
var getElementPoints = this.getElementPoints; | ||
var selectableTargets = this.getSelectableTargets(); | ||
var selectablePoints = selectableTargets.map(function (target) { | ||
return getElementPoints(target); | ||
return _this.getElementPoints(target); | ||
}); | ||
@@ -744,3 +779,5 @@ datas.selectableTargets = selectableTargets; | ||
var dragEvent = { | ||
datas: {}, | ||
datas: { | ||
flag: false | ||
}, | ||
clientX: clientX, | ||
@@ -755,2 +792,3 @@ clientY: clientY, | ||
if (this.onDragStart(dragEvent, clickedTarget)) { | ||
dragEvent.datas.flag = false; | ||
this.onDragEnd(dragEvent); | ||
@@ -814,3 +852,3 @@ } | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, points) { | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, selectablePoints) { | ||
var _a = this.options, | ||
@@ -823,39 +861,22 @@ hitRate = _a.hitRate, | ||
bottom = selectRect.bottom; | ||
return targets.filter(function (target, i) { | ||
var _a = points[i], | ||
pos1 = _a.pos1, | ||
pos2 = _a.pos2, | ||
pos3 = _a.pos3, | ||
pos4 = _a.pos4; | ||
var rectPoints = [[left, top], [right, top], [right, bottom], [left, bottom]]; | ||
return targets.filter(function (_, i) { | ||
var points = selectablePoints[i]; | ||
var inArea = isInside([clientX, clientY], points); | ||
var _b = [0, 1].map(function (j) { | ||
return Math.min(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectLeft = _b[0], | ||
rectTop = _b[1]; | ||
var _c = [0, 1].map(function (j) { | ||
return Math.max(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectRight = _c[0], | ||
rectBottom = _c[1]; | ||
var isStart = rectLeft <= clientX && clientX <= rectRight && rectTop <= clientY && clientY <= rectBottom; | ||
var rectSize = (rectRight - rectLeft) * (rectBottom - rectTop); | ||
var testLeft = Math.max(rectLeft, left); | ||
var testRight = Math.min(rectRight, right); | ||
var testTop = Math.max(rectTop, top); | ||
var testBottom = Math.min(rectBottom, bottom); | ||
if (selectByClick && isStart) { | ||
if (selectByClick && inArea) { | ||
return true; | ||
} | ||
if (testRight < testLeft || testBottom < testTop) { | ||
var overlapPoints = getOverlapPoints(rectPoints, points); | ||
if (!overlapPoints.length) { | ||
return false; | ||
} | ||
var rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100); | ||
var overlapSize = getAreaSize(overlapPoints); | ||
var targetSize = getAreaSize(points); | ||
var rate = between(Math.round(overlapSize / targetSize * 100), 0, 100); | ||
if (rate >= hitRate) { | ||
if (rate >= Math.min(100, hitRate)) { | ||
return true; | ||
@@ -886,4 +907,4 @@ } | ||
datas.startY -= offsetY; | ||
datas.selectablePoints.forEach(function (rect) { | ||
[rect.pos1, rect.pos2, rect.pos3, rect.pos4].forEach(function (pos) { | ||
datas.selectablePoints.forEach(function (points) { | ||
points.forEach(function (pos) { | ||
pos[0] -= offsetX; | ||
@@ -918,19 +939,5 @@ pos[1] -= offsetY; | ||
__proto.passSelectedTargets = function (passedTargets) { | ||
var _a = diff(this.selectedTargets, passedTargets), | ||
list = _a.list, | ||
prevList = _a.prevList, | ||
__proto.select = function (prevSelectedTargets, selectedTargets, rect, inputEvent, isStart) { | ||
var _a = diff(prevSelectedTargets, selectedTargets), | ||
added = _a.added, | ||
removed = _a.removed; | ||
return added.map(function (index) { | ||
return list[index]; | ||
}).concat(removed.map(function (index) { | ||
return prevList[index]; | ||
})); | ||
}; | ||
__proto.select = function (selectedTargets, rect, inputEvent, isStart) { | ||
var _a = this.differ.update(selectedTargets), | ||
added = _a.added, | ||
removed = _a.removed, | ||
@@ -940,2 +947,4 @@ prevList = _a.prevList, | ||
this.selectedTargets = selectedTargets; | ||
if (isStart) { | ||
@@ -1023,7 +1032,7 @@ /** | ||
__proto.selectEnd = function (startSelectedTargets, selectedTargets, rect, e) { | ||
__proto.selectEnd = function (startSelectedTargets, startPassedTargets, rect, e) { | ||
var inputEvent = e.inputEvent, | ||
isDouble = e.isDouble; | ||
var _a = diff(startSelectedTargets, selectedTargets), | ||
var _a = diff(startSelectedTargets, this.selectedTargets), | ||
added = _a.added, | ||
@@ -1034,3 +1043,3 @@ removed = _a.removed, | ||
var _b = diff(this.selectedTargets, selectedTargets), | ||
var _b = diff(startPassedTargets, this.selectedTargets), | ||
afterAdded = _b.added, | ||
@@ -1075,3 +1084,3 @@ afterRemoved = _b.removed, | ||
this.trigger("selectEnd", { | ||
selected: selectedTargets, | ||
selected: this.selectedTargets, | ||
added: added.map(function (index) { | ||
@@ -1096,6 +1105,9 @@ return list[index]; | ||
__proto.check = function (e) { | ||
__proto.check = function (e, rect) { | ||
if (rect === void 0) { | ||
rect = getRect(e, this.options.ratio); | ||
} | ||
var datas = e.datas, | ||
inputEvent = e.inputEvent; | ||
var rect = getRect(e, this.options.ratio, datas.boundArea); | ||
var top = rect.top, | ||
@@ -1105,10 +1117,22 @@ left = rect.left, | ||
height = rect.height; | ||
this.target.style.cssText += "display: block;" + "left:0px;top:0px;" + ("transform: translate(" + left + "px, " + top + "px);") + ("width:" + width + "px;height:" + height + "px;"); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectablePoints); | ||
var selectedTargets = this.passSelectedTargets(passedTargets); | ||
var selectFlag = datas.selectFlag; | ||
var prevSelectedTargets = []; | ||
var selectedTargets = []; | ||
if (selectFlag) { | ||
this.target.style.cssText += "display: block;" + "left:0px;top:0px;" + ("transform: translate(" + left + "px, " + top + "px);") + ("width:" + width + "px;height:" + height + "px;"); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectablePoints); | ||
prevSelectedTargets = this.selectedTargets; | ||
selectedTargets = passTargets(datas.startPassedTargets, passedTargets); | ||
this.selectedTargets = selectedTargets; | ||
} | ||
this.trigger("drag", __assign(__assign({}, e), { | ||
isSelect: selectFlag, | ||
rect: rect | ||
})); | ||
this.select(selectedTargets, rect, inputEvent); | ||
datas.selectedTargets = selectedTargets; | ||
if (selectFlag) { | ||
this.select(prevSelectedTargets, selectedTargets, rect, inputEvent); | ||
} | ||
}; | ||
@@ -1162,4 +1186,16 @@ | ||
export default Selecto; | ||
var Selecto$1 = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
__extends(Selecto, _super); | ||
function Selecto() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return Selecto; | ||
}(Selecto); | ||
export default Selecto$1; | ||
export { CLASS_NAME, EVENTS, METHODS, OPTIONS, OPTION_TYPES, PROPERTIES }; | ||
//# sourceMappingURL=selecto.esm.js.map |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 1.7.4 | ||
version: 1.8.0 | ||
*/ | ||
!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 E=function(){return(E=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)};var S="string",l=['"',"'",'\\"',"\\'"];function u(t){return t&&"object"==typeof t}function h(t,e,n,r){for(var i=n;i<r;++i){var o=e[i].trim();if(o===t)return i;var s=i;if("("===o?s=h(")",e,i+1,r):-1<l.indexOf(o)&&(s=h(o,e,i+1,r)),-1===s)break;i=s}return-1}function a(t){return function(t,e){for(var n=new RegExp("(\\s*"+(e||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=t.split(n).filter(Boolean),i=r.length,o=[],s=[],a=0;a<i;++a){var c=r[a].trim(),u=a;if("("===c)u=h(")",r,a+1,i);else{if(")"===c)throw new Error("invalid format");if(-1<l.indexOf(c))u=h(c,r,a+1,i);else if(c===e){s.length&&(o.push(s.join("")),s=[]);continue}}-1===u&&(u=i-1),s.push(r.slice(a,u+1).join("")),a=u}return s.length&&o.push(s.join("")),o}(t,",")}function w(){return Date.now?Date.now():(new Date).getTime()}function f(t,n,r){return[[n[0],n[0]*t[1]/t[0]],[n[1]*t[0]/t[1],n[1]]].filter(function(t){return t.every(function(t,e){return r?t<=n[e]:t>=n[e]})})[0]||t}function v(t,o,s,e){if(!e)return t.map(function(t,e){return n=t,r=o[e],i=s[e],Math.max(r,Math.min(n,i));var n,r,i});var n=t[0],r=t[1],i=f(t,o,!1),a=i[0],c=i[1],u=f(t,s,!0),l=u[0],h=u[1];return n<a||r<c?(n=a,r=c):(l<n||h<r)&&(n=l,r=h),[n,r]}function C(t,e,n,r){t.addEventListener(e,n,r)}function b(t,e,n){t.removeEventListener(e,n)}var i=function(){return(i=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)};var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(u(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(u(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(i({listener:e},n))},t}(),o=function(t,e){return(o=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 D=function(){return(D=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 n(t){return 180*(e=[t[0].clientX,t[0].clientY],n=[t[1].clientX,t[1].clientY],r=n[0]-e[0],i=n[1]-e[1],(0<=(o=Math.atan2(i,r))?o:o+2*Math.PI)/Math.PI);var e,n,r,i,o}function k(t){return t.touches?function(t){for(var e=Math.min(t.length,2),n=[],r=0;r<e;++r)n.push(g(t[r]));return n}(t.touches):[g(t)]}function s(t,e,n){var r=n.length,i=d(t,r),o=i.clientX,s=i.clientY,a=i.originalClientX,c=i.originalClientY,u=d(e,r),l=u.clientX,h=u.clientY,f=d(n,r);return{clientX:a,clientY:c,deltaX:o-l,deltaY:s-h,distX:o-f.clientX,distY:s-f.clientY}}function r(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){return{clientX:t.clientX,clientY:t.clientY}}function d(t,e){void 0===e&&(e=t.length);for(var n={clientX:0,clientY:0,originalClientX:0,originalClientY:0},r=0;r<e;++r){var i=t[r];n.originalClientX+="originalClientX"in i?i.originalClientX:i.clientX,n.originalClientY+="originalClientY"in i?i.originalClientY:i.clientY,n.clientX+=i.clientX,n.clientY+=i.clientY}return e?{clientX:n.clientX/e,clientY:n.clientY/e,originalClientX:n.originalClientX/e,originalClientY:n.originalClientY/e}:n}var O=function(){function t(t){this.prevClients=[],this.startClients=[],this.movement=0,this.length=0,this.startClients=t,this.prevClients=t,this.length=t.length}var e=t.prototype;return e.addClients=function(t){void 0===t&&(t=this.prevClients);var e=this.getPosition(t),n=e.deltaX,r=e.deltaY;return this.movement+=Math.sqrt(n*n+r*r),this.prevClients=t,e},e.getAngle=function(t){return void 0===t&&(t=this.prevClients),n(t)},e.getRotation=function(t){return void 0===t&&(t=this.prevClients),n(t)-n(this.startClients)},e.getPosition=function(t){return s(t||this.prevClients,this.prevClients,this.startClients)},e.getPositions=function(n){void 0===n&&(n=this.prevClients);var r=this.prevClients;return this.startClients.map(function(t,e){return s([n[e]],[r[e]],[t])})},e.getMovement=function(t){var e=this.movement;if(!t)return e;var n=d(t,this.length),r=d(this.prevClients,this.length),i=n.clientX-r.clientX,o=n.clientY-r.clientY;return Math.sqrt(i*i+o*o)+e},e.getDistance=function(t){return void 0===t&&(t=this.prevClients),r(t)},e.getScale=function(t){return void 0===t&&(t=this.prevClients),r(t)/r(this.startClients)},e.move=function(e,n){this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n})},t}(),T=["textarea","input"],p=function(c){function t(){this.constructor=e}var e,n;function r(t,e){void 0===e&&(e={});var y=c.call(this)||this;y.options={},y.flag=!1,y.pinchFlag=!1,y.datas={},y.isDrag=!1,y.isPinch=!1,y.isMouse=!1,y.isTouch=!1,y.clientStores=[],y.targets=[],y.prevTime=0,y.isDouble=!1,y.onDragStart=function(t,e){if(void 0===e&&(e=!0),y.flag||!1!==t.cancelable){var n=y.options,r=n.container,i=n.pinchOutside,o=n.preventRightClick,s=n.preventDefault,a=n.checkInput,c=y.isTouch,u=!y.flag;if(u){var l=document.activeElement,h=t.target,f=h.tagName.toLowerCase(),g=-1<T.indexOf(f),d=h.isContentEditable;if(g||d){if(a||l===h)return!1;if(l&&d&&l.isContentEditable&&l.contains(h))return!1}else if((s||"touchstart"===t.type)&&l){var p=l.tagName;(l.isContentEditable||-1<T.indexOf(p))&&l.blur()}if(y.clientStores=[new O(k(t))],y.flag=!0,y.isDrag=!1,y.datas={},o&&(3===t.which||2===t.button))return y.initDrag(),!1;!1===y.emit("dragStart",D({datas:y.datas,inputEvent:t,isTrusted:e},y.getCurrentStore().getPosition()))&&y.initDrag(),y.isDouble=w()-y.prevTime<200,y.flag&&s&&t.preventDefault()}if(!y.flag)return!1;var v,m=0;if(u&&c&&i&&(m=setTimeout(function(){C(r,"touchstart",y.onDragStart,{passive:!1})})),!u&&c&&i&&b(r,"touchstart",y.onDragStart),y.flag&&((v=t).touches&&2<=v.touches.length)){if(clearTimeout(m),u&&t.touches.length!==t.changedTouches.length)return;y.pinchFlag||y.onPinchStart(t)}}},y.onDrag=function(t,e){if(y.flag){var n=k(t),r=y.moveClients(n,t,!1);(y.pinchFlag||r.deltaX||r.deltaY)&&y.emit("drag",D({},r,{isScroll:!!e,inputEvent:t})),y.pinchFlag&&y.onPinch(t,n),y.getCurrentStore().addClients(n)}},y.onDragEnd=function(t){if(y.flag){var e=y.options,n=e.pinchOutside,r=e.container;y.isTouch&&n&&b(r,"touchstart",y.onDragStart),y.flag=!1;var i=y.getCurrentStore().getPosition(),o=w(),s=!y.isDrag&&y.isDouble;y.prevTime=y.isDrag||s?0:o,y.emit("dragEnd",D({datas:y.datas,isDouble:s,isDrag:y.isDrag,inputEvent:t},i)),y.pinchFlag&&y.onPinchEnd(t),y.clientStores=[]}},y.onBlur=function(){y.onDragEnd()};var n=[].concat(t);y.options=D({checkInput:!1,container:1<n.length?window:n[0],preventRightClick:!0,preventDefault:!0,checkWindowBlur:!1,pinchThreshold:0,events:["touch","mouse"]},e);var r=y.options,i=r.container,o=r.events,s=r.checkWindowBlur;if(y.isTouch=-1<o.indexOf("touch"),y.isMouse=-1<o.indexOf("mouse"),y.targets=n,y.isMouse&&(n.forEach(function(t){C(t,"mousedown",y.onDragStart)}),C(i,"mousemove",y.onDrag),C(i,"mouseup",y.onDragEnd),C(i,"contextmenu",y.onDragEnd)),s&&C(window,"blur",y.onBlur),y.isTouch){var a={passive:!1};n.forEach(function(t){C(t,"touchstart",y.onDragStart,a)}),C(i,"touchmove",y.onDrag,a),C(i,"touchend",y.onDragEnd,a),C(i,"touchcancel",y.onDragEnd,a)}return y}o(e=r,n=c),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t);var i=r.prototype;return i.getMovement=function(t){return this.getCurrentStore().getMovement(t)+this.clientStores.slice(1).reduce(function(t,e){return t+e.movement},0)},i.isDragging=function(){return this.isDrag},i.isFlag=function(){return this.flag},i.isPinchFlag=function(){return this.pinchFlag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(t,e,n,r){void 0===r&&(r=!0),this.flag&&(this.clientStores[0].move(t,e),r&&this.onDrag(n,!0))},i.move=function(t,e){var r=t[0],i=t[1],n=this.getCurrentStore().prevClients;return this.moveClients(n.map(function(t){var e=t.clientX,n=t.clientY;return{clientX:e+r,clientY:n+i,originalClientX:e,originalClientY:n}}),e,!0)},i.triggerDragStart=function(t){this.onDragStart(t,!1)},i.setEventDatas=function(t){var e=this.datas;for(var n in t)e[n]=t[n];return this},i.getEventDatas=function(){return this.datas},i.unset=function(){var e=this,t=this.targets,n=this.options.container;this.off(),b(window,"blur",this.onBlur),this.isMouse&&(t.forEach(function(t){b(t,"mousedown",e.onDragStart)}),b(n,"mousemove",this.onDrag),b(n,"mouseup",this.onDragEnd),b(n,"contextmenu",this.onDragEnd)),this.isTouch&&(t.forEach(function(t){b(t,"touchstart",e.onDragStart)}),b(n,"touchstart",this.onDragStart),b(n,"touchmove",this.onDrag),b(n,"touchend",this.onDragEnd),b(n,"touchcancel",this.onDragEnd))},i.onPinchStart=function(t){var e=this.options.pinchThreshold;if(!(this.isDrag&&this.getMovement()>e)){var n=new O(k(t));this.pinchFlag=!0,this.clientStores.splice(0,0,n),!1===this.emit("pinchStart",D({datas:this.datas,angle:n.getAngle(),touches:this.getCurrentStore().getPositions()},n.getPosition(),{inputEvent:t}))&&(this.pinchFlag=!1)}},i.onPinch=function(t,e){if(this.flag&&this.pinchFlag&&!(e.length<2)){var n=this.getCurrentStore();this.isPinch=!0,this.emit("pinch",D({datas:this.datas,movement:this.getMovement(e),angle:n.getAngle(e),rotation:n.getRotation(e),touches:n.getPositions(e),scale:n.getScale(e),distance:n.getDistance(e)},n.getPosition(e),{inputEvent:t}))}},i.onPinchEnd=function(t){if(this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.getCurrentStore();this.emit("pinchEnd",D({datas:this.datas,isPinch:e,touches:n.getPositions()},n.getPosition(),{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}},i.initDrag=function(){this.clientStores=[],this.pinchFlag=!1,this.flag=!1},i.getCurrentStore=function(){return this.clientStores[0]},i.moveClients=function(t,e,n){var r=this.getCurrentStore()[n?"addClients":"getPosition"](t);return this.isDrag=!0,D({datas:this.datas},r,{movement:this.getMovement(t),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,inputEvent:e})},r}(t);var y=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,r=this.values,i=n.indexOf(t),o=-1===i?n.length:i;n[o]=t,r[o]=e},t}(),P=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}(),_="function"==typeof Map,m=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 x=function(){function t(t,e,n,r,i,o,s,a){this.prevList=t,this.list=e,this.added=n,this.removed=r,this.changed=i,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],r=new m;a[e]=r,c[n]=r}),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],r=t[1];if(n===r)return[0,0];var i=a[n],o=c[r-1],s=i.getIndex();return i.disconnect(),o?i.connect(o,o.next):i.connect(void 0,a[0]),[s,i.getIndex()]})),u=this.changed,l=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],r=t[1],i=u[e],o=i[0],s=i[1];if(n!==r)return l.push([o,s]),!0}),this.cachePureChanged=l},t}();function Y(t,e,n){var r=_?Map:n?P:y,i=n||function(t){return t},o=[],s=[],a=[],c=t.map(i),u=e.map(i),l=new r,h=new r,f=[],g=[],d={},p=[],v=0,m=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?(++m,s.push(e)):d[n]=m}),u.forEach(function(t,e){var n=l.get(t);void 0===n?(o.push(e),++v):(a.push([n,e]),m=d[e]||0,f.push([n-m,e-v]),g.push(e===n),n!==e&&p.push([n,e]))}),s.reverse(),new x(t,e,o,s,p,a,f,g)}var X=function(t,e){return(X=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,j="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,r;function i(t){return void 0===t&&(t=[]),e.call(this,t,j)||this}return X(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t),i}(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=Y(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function M(t,e){return Y(t,e,j)}var A=function(t,e){return(A=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)};function B(t){var e=t.container;return[e.scrollLeft,e.scrollTop]}var R=function(e){function t(){this.constructor=n}var n,r;function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.startRect=null,t.startPos=[],t.prevTime=0,t.timer=0,t}A(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return o.dragStart=function(t,e){var n=e.container.getBoundingClientRect(),r=n.top,i=n.left,o=n.width,s=n.height;this.startPos=[t.clientX,t.clientY],this.startRect={top:r,left:i,width:o,height:s}},o.drag=function(t,e){var n=this,r=t.clientX,i=t.clientY,o=e.container,s=e.threshold,a=void 0===s?0:s,c=e.throttleTime,u=void 0===c?0:c,l=e.getScrollPosition,h=void 0===l?B:l,f=this.startRect,g=this.startPos,d=w(),p=Math.max(u+this.prevTime-d,0),v=[0,0];if(f.top>i-a?(g[1]>f.top||i<g[1])&&(v[1]=-1):f.top+f.height<i+a&&(g[1]<f.top+f.height||i>g[1])&&(v[1]=1),f.left>r-a?(g[0]>f.left||r<g[0])&&(v[0]=-1):f.left+f.width<r+a&&(g[0]<f.left+f.width||r>g[0])&&(v[0]=1),clearTimeout(this.timer),!v[0]&&!v[1])return!1;if(0<p)return this.timer=window.setTimeout(function(){n.drag(t,e)},p),!1;this.prevTime=d;var m=h({container:o,direction:v});this.trigger("scroll",{container:o,direction:v,inputEvent:t});var y=h({container:o,direction:v}),C=y[0]-m[0],b=y[1]-m[1];return!(!C&&!b)&&(this.trigger("move",{offsetX:v[0]?C:0,offsetY:v[1]?b:0,inputEvent:t}),u&&(this.timer=window.setTimeout(function(){n.drag(t,e)},u)),!0)},o.dragEnd=function(){clearTimeout(this.timer)},i}(t),F=function(t,e){return(F=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)};function N(t){return t&&"object"==typeof t}function I(t){return Array.isArray(t)}function L(t){return"string"==typeof t}function q(t,e,n,r){t.addEventListener(e,n,r)}function U(t,e,n){t.removeEventListener(e,n)}var W=function(){return(W=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)};var z=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(N(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(N(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(W({listener:e},n))},t}();var H,G,V=(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,r=String(t);return(n=i[r.toLowerCase()])?n:(n=o[r.toLowerCase()])||(1===r.length?r.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 r;if(r=i[e.toLowerCase()])return r===n;if(r=o[e.toLowerCase()])return r===n}else if("number"==typeof e)return e===n;return!1}};var i=(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(r=97;r<123;r++)i[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)i[r-48]=r;for(r=1;r<13;r++)i["f"+r]=r+111;for(r=0;r<10;r++)i["numpad "+r]=r+96;var s=e.names=e.title={};for(r in i)s[i[r]]=r;for(var a in o)i[a]=o[a]}(H={exports:{}},H.exports),H.exports),$=(V.code,V.codes,V.aliases,V.names),J=(V.title,{"+":"plus","left command":"meta","right command":"meta"}),Q={shift:1,ctrl:2,alt:3,meta:4};function Z(t){var e=$[t]||"";for(var n in J)e=e.replace(n,J[n]);return e.replace(/\s/g,"")}function tt(t,e){void 0===e&&(e=Z(t.keyCode));var n,r=[(n=t).shiftKey&&"shift",n.ctrlKey&&"ctrl",n.altKey&&"alt",n.metaKey&&"meta"].filter(Boolean);return-1===r.indexOf(e)&&r.push(e),r.filter(Boolean)}function et(t){var e=t.slice();return e.sort(function(t,e){return(Q[t]||5)-(Q[e]||5)}),e}var nt=function(n){function t(){this.constructor=e}var e,r;function i(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)},e.blur=function(){e.clear(),e.trigger("blur")},q(t,"blur",e.blur),q(t,"keydown",e.keydownEvent),q(t,"keyup",e.keyupEvent),e}F(e=i,r=n),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return Object.defineProperty(i,"global",{get:function(){return G=G||new i},enumerable:!1,configurable:!0}),i.setGlobal=function(){return this.global},o.destroy=function(){var t=this.container;this.clear(),this.off(),U(t,"blur",this.blur),U(t,"keydown",this.keydownEvent),U(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 I(e)?this.on(t+"."+et(e).join("."),n):L(e)?this.on(t+"."+e,n):this.on(t,e),this},o.removeEvent=function(t,e,n){return I(e)?this.off(t+"."+et(e).join("."),n):L(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=Z(e.keyCode),r={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,r),this.trigger(t+"."+n,r);var i=tt(e,n);1<i.length&&this.trigger(t+"."+i.join("."),r)},i}(z);function rt(t,e,n){var r=t.tag,i=t.children,o=t.attributes,s=t.className,a=t.style,c=e||document.createElement(r);for(var u in o)c.setAttribute(u,o[u]);var l=c.children;if(i.forEach(function(t,e){rt(t,l[e],c)}),s&&s.split(" ").forEach(function(t){var e,n,r,i;i=t,((r=c).classList?r.classList.contains(i):r.className.match(new RegExp("(\\s|^)"+i+"(\\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 it(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 ot(t,e,n){t!==e&&n(t,e)}function st(t,e,n){var r,i=t.distX,o=void 0===i?0:i,s=t.distY,a=void 0===s?0:s,c=t.datas,u=c.startX,l=c.startY;if(0<e){var h=Math.sqrt((o*o+a*a)/(1+e*e));o=(0<=o?1:-1)*(e*h),a=(0<=a?1:-1)*h}var f=Math.abs(o),g=Math.abs(a);o=(0<=o?1:-1)*(f=(r=v([f,g],[0,0],[o<0?u-n.left:n.right-u,a<0?l-n.top:n.bottom-l],!!e))[0]),a=(0<=a?1:-1)*(g=r[1]);var d=u+Math.min(0,o),p=l+Math.min(0,a);return{left:d,top:p,right:d+f,bottom:p+g,width:f,height:g}}function at(t){var e=t.getBoundingClientRect(),n=e.left,r=e.top,i=e.width,o=e.height;return{pos1:[n,r],pos2:[n+i,r],pos3:[n,r+o],pos4:[n+i,r+o]}}function ct(t,e,n,r){var i,o,s=document.createElement("style");return s.setAttribute("type","text/css"),s.setAttribute("data-styled-id",t),n.nonce&&s.setAttribute("nonce",n.nonce),s.innerHTML=(i=t,o=e,n.original?o:o.replace(/([^};{\s}][^};{]*|^\s*){/gm,function(t,e){var n=e.trim();return(n?a(n):[""]).map(function(t){var e=t.trim();return 0===e.indexOf("@")?e:-1<e.indexOf(":global")?e.replace(/\:global/g,""):-1<e.indexOf(":host")?""+e.replace(/\:host/g,"."+i):e?"."+i+" "+e:"."+i}).join(", ")+" {"})),(r||document.head||document.body).appendChild(s),s}var ut,lt,ht,ft,gt=(ht="rCS"+function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0}(ut="\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),ft=0,{className:ht,inject:function(t,e){void 0===e&&(e={});var n,r=function(t){if(t&&t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===ft;return(r||i)&&(n=ct(ht,ut,e,r)),i&&(lt=n),r||++ft,{destroy:function(){r?(t.removeChild(n),n=null):(0<ft&&--ft,0===ft&<&&(lt.parentNode.removeChild(lt),lt=null))}}}}),dt="selecto-selection "+gt.className,pt=["boundContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","scrollOptions","checkInput","preventDefault","ratio","getElementPoints"],vt=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(["dragContainer","cspNonce"],pt),mt={boundContainer:null,target:null,container:null,dragContainer:null,selectableTargets:Array,selectByClick:Boolean,selectFromInside:Boolean,continueSelect:Boolean,toggleContinueSelect:Array,keyContainer:null,hitRate:Number,scrollOptions:Object,checkInput:Boolean,preventDefault:Boolean,cspNonce:String,ratio:Number,getElementPoints:Function},yt=function(e){function t(){this.constructor=n}var n,r;function i(t){void 0===t&&(t={});var b=e.call(this)||this;return b.selectedTargets=[],b.differ=new K,b.dragScroll=new R,b.onDragStart=function(t,e){var n=t.datas,r=t.clientX,i=t.clientY,o=t.inputEvent,s=b.options,a=s.continueSelect,c=s.selectFromInside,u=s.selectByClick,l=s.boundContainer;b.findSelectableTargets(n),n.startSelectedTargets=b.selectedTargets;var h={left:-1/0,top:-1/0,right:1/0,bottom:1/0};if(l){var f=(typeof l===S?document.querySelector(l):!0===l?b.container:l).getBoundingClientRect();h={left:f.left,top:f.top,right:f.right,bottom:f.bottom}}n.boundArea=h,n.selectedTargets=[];var g={left:r,top:i,right:r,bottom:i,width:0,height:0},d=[];if(!c||u){for(var p=e||document.elementFromPoint(r,i);p&&!(-1<n.selectableTargets.indexOf(p));)p=p.parentElement;d=p?[p]:[]}var v=0<d.length,m=!c&&v;if(m&&!u)return t.stop(),!1;var y=o.type;if(!(!("mousedown"===y||"touchstart"===y)||b.trigger("dragStart",E({},t))))return t.stop(),!1;if(a?d=b.passSelectedTargets(d):b.selectedTargets=[],b.select(d,g,o,!0),n.startX=r,n.startY=i,n.selectedTargets=d,n.boundsArea=b.target.style.cssText+="left:0px;top:0px;transform: translate("+r+"px, "+i+"px)",m&&u)return b.onDragEnd(t),o.preventDefault(),t.stop(),!1;"touchstart"===y&&o.preventDefault();var C=b.options.scrollOptions;return C&&C.container&&b.dragScroll.dragStart(t,C),!0},b.onDrag=function(t){var e=b.options.scrollOptions;e&&e.container&&b.dragScroll.drag(t,e)||b.check(t)},b.onDragEnd=function(t){var e=t.datas,n=t.inputEvent,r=st(t,b.options.ratio,e.boundArea);b.dragScroll.dragEnd(),b.target.style.cssText+="display: none;",n&&"mousedown"!==n.type&&"touchstart"!==n.type&&b.trigger("dragEnd",E(E({isDouble:!1,isDrag:!1},t),{rect:r})),b.selectEnd(e.startSelectedTargets,e.selectedTargets,r,t),b.selectedTargets=e.selectedTargets},b.onKeyDown=function(t){b.sameCombiKey(t)&&(b.continueSelect=!0,b.trigger("keydown",{}))},b.onKeyUp=function(t){b.sameCombiKey(t,!0)&&(b.continueSelect=!1,b.trigger("keyup",{}))},b.onBlur=function(){b.toggleContinueSelect&&b.continueSelect&&(b.continueSelect=!1,b.trigger("keyup",{}))},b.onDocumentSelectStart=function(e){if(b.gesto.isFlag()){var t=b.dragContainer;t===window&&(t=document.documentElement);var n=t instanceof Element?[t]:[].slice.call(t),r=e.target;n.some(function(t){if(t===r||t.contains(r))return e.preventDefault(),!0})}},b.target=t.target,b.container=t.container,b.options=E({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null,scrollOptions:void 0,checkInput:!1,preventDefault:!1,boundContainer:!1,getElementPoints:at,cspNonce:"",ratio:0},t),b.initElement(),b.initDragScroll(),b.setKeyController(),b}c(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o,s,a=i.prototype;return a.setSelectedTargets=function(t){return this.selectedTargets=t,this.differ=new K(t),this},a.getSelectedTargets=function(){return this.selectedTargets},a.setKeyContainer=function(t){var e=this,n=this.options;ot(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},a.setToggleContinueSelect=function(t){var e=this,n=this.options;ot(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},a.setPreventDefault=function(t){this.gesto.options.preventDefault=t},a.setCheckInput=function(t){this.gesto.options.checkInput=t},a.triggerDragStart=function(t){return this.gesto.triggerDragStart(t),this},a.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.gesto.unset(),this.injectResult.destroy(),b(document,"selectstart",this.onDocumentSelectStart),this.keycon=null,this.gesto=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},a.findSelectableTargets=function(t){void 0===t&&(t=this.gesto.getEventDatas());var e=this.getElementPoints,n=this.getSelectableTargets(),r=n.map(function(t){return e(t)});t.selectableTargets=n,t.selectablePoints=r},a.clickTarget=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0]||t.changedTouches[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,stop:function(){return!1}};return this.onDragStart(r,e)&&this.onDragEnd(r),this},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 nt(e||window),this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on("blur",this.onBlur))},a.setKeyEvent=function(){this.options.toggleContinueSelect&&!this.keycon&&this.setKeyController()},a.initElement=function(){this.target=rt(it("div",{className:dt}),this.target,this.container);var t=this.target,e=this.options,n=e.dragContainer,r=e.checkInput,i=e.preventDefault;this.dragContainer="string"==typeof n?[].slice.call(document.querySelectorAll(n)):this.options.dragContainer||this.target.parentNode,this.gesto=new p(this.dragContainer,{checkWindowBlur:!0,container:window,checkInput:r,preventDefault:i}).on({dragStart:this.onDragStart,drag:this.onDrag,dragEnd:this.onDragEnd}),C(document,"selectstart",this.onDocumentSelectStart),this.injectResult=gt.inject(t,{nonce:this.options.cspNonce})},a.hitTest=function(t,b,E,e,S){var n=this.options,w=n.hitRate,D=n.selectByClick,k=t.left,O=t.top,T=t.right,P=t.bottom;return e.filter(function(t,e){var n=S[e],r=n.pos1,i=n.pos2,o=n.pos3,s=n.pos4,a=[0,1].map(function(t){return Math.min(r[t],i[t],o[t],s[t])}),c=a[0],u=a[1],l=[0,1].map(function(t){return Math.max(r[t],i[t],o[t],s[t])}),h=l[0],f=l[1],g=c<=b&&b<=h&&u<=E&&E<=f,d=(h-c)*(f-u),p=Math.max(c,k),v=Math.min(h,T),m=Math.max(u,O),y=Math.min(f,P);if(D&&g)return!0;if(v<p||y<m)return!1;var C=Math.round((v-p)*(y-m)/d*100);return w<=C})},a.initDragScroll=function(){var o=this;this.dragScroll.on("scroll",function(t){var e=t.container,n=t.direction;o.trigger("scroll",{container:e,direction:n})}).on("move",function(t){var e=t.offsetX,n=t.offsetY,r=t.inputEvent,i=r.datas;i.startX-=e,i.startY-=n,i.selectablePoints.forEach(function(t){[t.pos1,t.pos2,t.pos3,t.pos4].forEach(function(t){t[0]-=e,t[1]-=n})}),o.gesto.scrollBy(e,n,r.inputEvent,!1),r.distX+=e,r.distY+=n,o.check(r)})},a.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){u(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},a.passSelectedTargets=function(t){var e=M(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]}))},a.select=function(t,e,n,r){var i=this.differ.update(t),o=i.added,s=i.removed,a=i.prevList,c=i.list;r&&this.trigger("selectStart",{selected:t,added:o.map(function(t){return c[t]}),removed:s.map(function(t){return a[t]}),rect:e,inputEvent:n}),(o.length||s.length)&&this.trigger("select",{selected:t,added:o.map(function(t){return c[t]}),removed:s.map(function(t){return a[t]}),rect:e,inputEvent:n})},a.selectEnd=function(t,e,n,r){var i=r.inputEvent,o=r.isDouble,s=M(t,e),a=s.added,c=s.removed,u=s.prevList,l=s.list,h=M(this.selectedTargets,e),f=h.added,g=h.removed,d=h.prevList,p=h.list,v=i&&i.type,m="mousedown"===v||"touchstart"===v;this.trigger("selectEnd",{selected:e,added:a.map(function(t){return l[t]}),removed:c.map(function(t){return u[t]}),afterAdded:f.map(function(t){return p[t]}),afterRemoved:g.map(function(t){return d[t]}),isDragStart:m,isDouble:!!o,rect:n,inputEvent:i})},a.check=function(t){var e=t.datas,n=t.inputEvent,r=st(t,this.options.ratio,e.boundArea),i=r.top,o=r.left,s=r.width,a=r.height;this.target.style.cssText+="display: block;left:0px;top:0px;transform: translate("+o+"px, "+i+"px);width:"+s+"px;height:"+a+"px;";var c=this.hitTest(r,e.startX,e.startY,e.selectableTargets,e.selectablePoints),u=this.passSelectedTargets(c);this.trigger("drag",E(E({},t),{rect:r})),this.select(u,r,n),e.selectedTargets=u},a.sameCombiKey=function(t,e){var n,r=[].concat(this.options.toggleContinueSelect),i=tt(t.inputEvent,t.key),o=(n=r[0],Array.isArray(n)?r:[r]);if(e){var s=t.key;return o.some(function(t){return t.some(function(t){return t===s})})}return o.some(function(t){return t.every(function(t){return-1<i.indexOf(t)})})},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}([(o=pt,s=function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},r=("set "+e).replace(/[\s-_]([a-z])/g,function(t,e){return e.toUpperCase()});t[r]?n.set=function(t){this[r](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)})})],i)}(t),Ct={__proto__:null,default:yt,OPTIONS:vt,OPTION_TYPES:mt,PROPERTIES:pt,EVENTS:["dragStart","drag","dragEnd","selectStart","select","selectEnd","keydown","keyup","scroll"],METHODS:["clickTarget","setSelectedTargets","triggerDragStart"],CLASS_NAME:dt};for(var bt in Ct)yt[bt]=Ct[bt];return yt}); | ||
!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 r=function(t,e){return(r=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)};function o(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var b=function(){return(b=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)};var S="string",l=['"',"'",'\\"',"\\'"];function a(t){return t&&"object"==typeof t}function f(t,e,n,r){for(var i=n;i<r;++i){var o=e[i].trim();if(o===t)return i;var a=i;if("("===o?a=f(")",e,i+1,r):-1<l.indexOf(o)&&(a=f(o,e,i+1,r)),-1===a)break;i=a}return-1}function s(t){return function(t,e){for(var n=new RegExp("(\\s*"+(e||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=t.split(n).filter(Boolean),i=r.length,o=[],a=[],s=0;s<i;++s){var c=r[s].trim(),u=s;if("("===c)u=f(")",r,s+1,i);else{if(")"===c)throw new Error("invalid format");if(-1<l.indexOf(c))u=f(c,r,s+1,i);else if(c===e){a.length&&(o.push(a.join("")),a=[]);continue}}-1===u&&(u=i-1),a.push(r.slice(s,u+1).join("")),s=u}return a.length&&o.push(a.join("")),o}(t,",")}function w(){return Date.now?Date.now():(new Date).getTime()}function m(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}function v(t,e,n){return Math.max(e,Math.min(t,n))}function y(t,n,r){return[[n[0],n[0]*t[1]/t[0]],[n[1]*t[0]/t[1],n[1]]].filter(function(t){return t.every(function(t,e){return r?t<=n[e]:t>=n[e]})})[0]||t}function i(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=Math.atan2(r,n);return 0<=i?i:i+2*Math.PI}function c(t){return[0,1].map(function(e){return function(t){for(var e=t.length,n=0,r=e-1;0<=r;--r)n+=t[r];return e?n/e:0}(t.map(function(t){return t[e]}))})}function g(t){var e=c(t),n=i(e,t[0]),r=i(e,t[1]);return n<r&&r-n<Math.PI||r<n&&r-n<-Math.PI?1:-1}function p(t,e){return Math.sqrt(Math.pow((e?e[0]:0)-t[0],2)+Math.pow((e?e[1]:0)-t[1],2))}function E(t,e,n,r){t.addEventListener(e,n,r)}function C(t,e,n){t.removeEventListener(e,n)}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)};var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(a(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(a(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=m(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(u({listener:e},n))},t}(),h=function(t,e){return(h=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 D=function(){return(D=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 n(t){return 180*(e=[t[0].clientX,t[0].clientY],n=[t[1].clientX,t[1].clientY],r=n[0]-e[0],i=n[1]-e[1],(0<=(o=Math.atan2(i,r))?o:o+2*Math.PI)/Math.PI);var e,n,r,i,o}function k(t){return t.touches?function(t){for(var e=Math.min(t.length,2),n=[],r=0;r<e;++r)n.push(T(t[r]));return n}(t.touches):[T(t)]}function d(t,e,n){var r=n.length,i=x(t,r),o=i.clientX,a=i.clientY,s=i.originalClientX,c=i.originalClientY,u=x(e,r),l=u.clientX,f=u.clientY,h=x(n,r);return{clientX:s,clientY:c,deltaX:o-l,deltaY:a-f,distX:o-h.clientX,distY:a-h.clientY}}function P(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function T(t){return{clientX:t.clientX,clientY:t.clientY}}function x(t,e){void 0===e&&(e=t.length);for(var n={clientX:0,clientY:0,originalClientX:0,originalClientY:0},r=0;r<e;++r){var i=t[r];n.originalClientX+="originalClientX"in i?i.originalClientX:i.clientX,n.originalClientY+="originalClientY"in i?i.originalClientY:i.clientY,n.clientX+=i.clientX,n.clientY+=i.clientY}return e?{clientX:n.clientX/e,clientY:n.clientY/e,originalClientX:n.originalClientX/e,originalClientY:n.originalClientY/e}:n}var O=function(){function t(t){this.prevClients=[],this.startClients=[],this.movement=0,this.length=0,this.startClients=t,this.prevClients=t,this.length=t.length}var e=t.prototype;return e.addClients=function(t){void 0===t&&(t=this.prevClients);var e=this.getPosition(t),n=e.deltaX,r=e.deltaY;return this.movement+=Math.sqrt(n*n+r*r),this.prevClients=t,e},e.getAngle=function(t){return void 0===t&&(t=this.prevClients),n(t)},e.getRotation=function(t){return void 0===t&&(t=this.prevClients),n(t)-n(this.startClients)},e.getPosition=function(t){return d(t||this.prevClients,this.prevClients,this.startClients)},e.getPositions=function(n){void 0===n&&(n=this.prevClients);var r=this.prevClients;return this.startClients.map(function(t,e){return d([n[e]],[r[e]],[t])})},e.getMovement=function(t){var e=this.movement;if(!t)return e;var n=x(t,this.length),r=x(this.prevClients,this.length),i=n.clientX-r.clientX,o=n.clientY-r.clientY;return Math.sqrt(i*i+o*o)+e},e.getDistance=function(t){return void 0===t&&(t=this.prevClients),P(t)},e.getScale=function(t){return void 0===t&&(t=this.prevClients),P(t)/P(this.startClients)},e.move=function(e,n){this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n})},t}(),_=["textarea","input"],M=function(c){function t(){this.constructor=e}var e,n;function r(t,e){void 0===e&&(e={});var y=c.call(this)||this;y.options={},y.flag=!1,y.pinchFlag=!1,y.datas={},y.isDrag=!1,y.isPinch=!1,y.isMouse=!1,y.isTouch=!1,y.clientStores=[],y.targets=[],y.prevTime=0,y.isDouble=!1,y.onDragStart=function(t,e){if(void 0===e&&(e=!0),y.flag||!1!==t.cancelable){var n=y.options,r=n.container,i=n.pinchOutside,o=n.preventRightClick,a=n.preventDefault,s=n.checkInput,c=y.isTouch,u=!y.flag;if(u){var l=document.activeElement,f=t.target,h=f.tagName.toLowerCase(),g=-1<_.indexOf(h),p=f.isContentEditable;if(g||p){if(s||l===f)return!1;if(l&&p&&l.isContentEditable&&l.contains(f))return!1}else if((a||"touchstart"===t.type)&&l){var d=l.tagName;(l.isContentEditable||-1<_.indexOf(d))&&l.blur()}if(y.clientStores=[new O(k(t))],y.flag=!0,y.isDrag=!1,y.datas={},o&&(3===t.which||2===t.button))return y.initDrag(),!1;!1===y.emit("dragStart",D({datas:y.datas,inputEvent:t,isTrusted:e},y.getCurrentStore().getPosition()))&&y.initDrag(),y.isDouble=w()-y.prevTime<200,y.flag&&a&&t.preventDefault()}if(!y.flag)return!1;var v,m=0;if(u&&c&&i&&(m=setTimeout(function(){E(r,"touchstart",y.onDragStart,{passive:!1})})),!u&&c&&i&&C(r,"touchstart",y.onDragStart),y.flag&&((v=t).touches&&2<=v.touches.length)){if(clearTimeout(m),u&&t.touches.length!==t.changedTouches.length)return;y.pinchFlag||y.onPinchStart(t)}}},y.onDrag=function(t,e){if(y.flag){var n=k(t),r=y.moveClients(n,t,!1);(y.pinchFlag||r.deltaX||r.deltaY)&&y.emit("drag",D({},r,{isScroll:!!e,inputEvent:t})),y.pinchFlag&&y.onPinch(t,n),y.getCurrentStore().addClients(n)}},y.onDragEnd=function(t){if(y.flag){var e=y.options,n=e.pinchOutside,r=e.container;y.isTouch&&n&&C(r,"touchstart",y.onDragStart),y.flag=!1;var i=y.getCurrentStore().getPosition(),o=w(),a=!y.isDrag&&y.isDouble;y.prevTime=y.isDrag||a?0:o,y.emit("dragEnd",D({datas:y.datas,isDouble:a,isDrag:y.isDrag,inputEvent:t},i)),y.pinchFlag&&y.onPinchEnd(t),y.clientStores=[]}},y.onBlur=function(){y.onDragEnd()};var n=[].concat(t);y.options=D({checkInput:!1,container:1<n.length?window:n[0],preventRightClick:!0,preventDefault:!0,checkWindowBlur:!1,pinchThreshold:0,events:["touch","mouse"]},e);var r=y.options,i=r.container,o=r.events,a=r.checkWindowBlur;if(y.isTouch=-1<o.indexOf("touch"),y.isMouse=-1<o.indexOf("mouse"),y.targets=n,y.isMouse&&(n.forEach(function(t){E(t,"mousedown",y.onDragStart)}),E(i,"mousemove",y.onDrag),E(i,"mouseup",y.onDragEnd),E(i,"contextmenu",y.onDragEnd)),a&&E(window,"blur",y.onBlur),y.isTouch){var s={passive:!1};n.forEach(function(t){E(t,"touchstart",y.onDragStart,s)}),E(i,"touchmove",y.onDrag,s),E(i,"touchend",y.onDragEnd,s),E(i,"touchcancel",y.onDragEnd,s)}return y}h(e=r,n=c),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t);var i=r.prototype;return i.getMovement=function(t){return this.getCurrentStore().getMovement(t)+this.clientStores.slice(1).reduce(function(t,e){return t+e.movement},0)},i.isDragging=function(){return this.isDrag},i.isFlag=function(){return this.flag},i.isPinchFlag=function(){return this.pinchFlag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(t,e,n,r){void 0===r&&(r=!0),this.flag&&(this.clientStores[0].move(t,e),r&&this.onDrag(n,!0))},i.move=function(t,e){var r=t[0],i=t[1],n=this.getCurrentStore().prevClients;return this.moveClients(n.map(function(t){var e=t.clientX,n=t.clientY;return{clientX:e+r,clientY:n+i,originalClientX:e,originalClientY:n}}),e,!0)},i.triggerDragStart=function(t){this.onDragStart(t,!1)},i.setEventDatas=function(t){var e=this.datas;for(var n in t)e[n]=t[n];return this},i.getEventDatas=function(){return this.datas},i.unset=function(){var e=this,t=this.targets,n=this.options.container;this.off(),C(window,"blur",this.onBlur),this.isMouse&&(t.forEach(function(t){C(t,"mousedown",e.onDragStart)}),C(n,"mousemove",this.onDrag),C(n,"mouseup",this.onDragEnd),C(n,"contextmenu",this.onDragEnd)),this.isTouch&&(t.forEach(function(t){C(t,"touchstart",e.onDragStart)}),C(n,"touchstart",this.onDragStart),C(n,"touchmove",this.onDrag),C(n,"touchend",this.onDragEnd),C(n,"touchcancel",this.onDragEnd))},i.onPinchStart=function(t){var e=this.options.pinchThreshold;if(!(this.isDrag&&this.getMovement()>e)){var n=new O(k(t));this.pinchFlag=!0,this.clientStores.splice(0,0,n),!1===this.emit("pinchStart",D({datas:this.datas,angle:n.getAngle(),touches:this.getCurrentStore().getPositions()},n.getPosition(),{inputEvent:t}))&&(this.pinchFlag=!1)}},i.onPinch=function(t,e){if(this.flag&&this.pinchFlag&&!(e.length<2)){var n=this.getCurrentStore();this.isPinch=!0,this.emit("pinch",D({datas:this.datas,movement:this.getMovement(e),angle:n.getAngle(e),rotation:n.getRotation(e),touches:n.getPositions(e),scale:n.getScale(e),distance:n.getDistance(e)},n.getPosition(e),{inputEvent:t}))}},i.onPinchEnd=function(t){if(this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.getCurrentStore();this.emit("pinchEnd",D({datas:this.datas,isPinch:e,touches:n.getPositions()},n.getPosition(),{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}},i.initDrag=function(){this.clientStores=[],this.pinchFlag=!1,this.flag=!1},i.getCurrentStore=function(){return this.clientStores[0]},i.moveClients=function(t,e,n){var r=this.getCurrentStore()[n?"addClients":"getPosition"](t);return this.isDrag=!0,D({datas:this.datas},r,{movement:this.getMovement(t),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,inputEvent:e})},r}(t);var Y=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,r=this.values,i=n.indexOf(t),o=-1===i?n.length:i;n[o]=t,r[o]=e},t}(),X=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}(),j="function"==typeof Map,K=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 A=function(){function t(t,e,n,r,i,o,a,s){this.prevList=t,this.list=e,this.added=n,this.removed=r,this.changed=i,this.maintained=o,this.changedBeforeAdded=a,this.fixed=s}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,s,c,e=(t=this.changedBeforeAdded,n=this.fixed,s=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],r=new K;s[e]=r,c[n]=r}),s.forEach(function(t,e){t.connect(s[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],r=t[1];if(n===r)return[0,0];var i=s[n],o=c[r-1],a=i.getIndex();return i.disconnect(),o?i.connect(o,o.next):i.connect(void 0,s[0]),[a,i.getIndex()]})),u=this.changed,l=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],r=t[1],i=u[e],o=i[0],a=i[1];if(n!==r)return l.push([o,a]),!0}),this.cachePureChanged=l},t}();var e,F="function"==typeof Map?void 0:(e=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++e)});function R(t,e){return n=t,r=e,i=F,o=j?Map:i?X:Y,a=i||function(t){return t},s=[],c=[],u=[],l=n.map(a),f=r.map(a),h=new o,g=new o,p=[],d=[],v={},m=[],E=y=0,l.forEach(function(t,e){h.set(t,e)}),f.forEach(function(t,e){g.set(t,e)}),l.forEach(function(t,e){var n=g.get(t);void 0===n?(++E,c.push(e)):v[n]=E}),f.forEach(function(t,e){var n=h.get(t);void 0===n?(s.push(e),++y):(u.push([n,e]),E=v[e]||0,p.push([n-E,e-y]),d.push(e===n),n!==e&&m.push([n,e]))}),c.reverse(),new A(n,r,s,c,m,u,p,d);var n,r,i,o,a,s,c,u,l,f,h,g,p,d,v,m,y,E}var B=function(t,e){return(B=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)};function I(t){var e=t.container;return[e.scrollLeft,e.scrollTop]}var N=function(e){function t(){this.constructor=n}var n,r;function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.startRect=null,t.startPos=[],t.prevTime=0,t.timer=0,t}B(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return o.dragStart=function(t,e){var n=e.container.getBoundingClientRect(),r=n.top,i=n.left,o=n.width,a=n.height;this.startPos=[t.clientX,t.clientY],this.startRect={top:r,left:i,width:o,height:a}},o.drag=function(t,e){var n=this,r=t.clientX,i=t.clientY,o=e.container,a=e.threshold,s=void 0===a?0:a,c=e.throttleTime,u=void 0===c?0:c,l=e.getScrollPosition,f=void 0===l?I:l,h=this.startRect,g=this.startPos,p=w(),d=Math.max(u+this.prevTime-p,0),v=[0,0];if(h.top>i-s?(g[1]>h.top||i<g[1])&&(v[1]=-1):h.top+h.height<i+s&&(g[1]<h.top+h.height||i>g[1])&&(v[1]=1),h.left>r-s?(g[0]>h.left||r<g[0])&&(v[0]=-1):h.left+h.width<r+s&&(g[0]<h.left+h.width||r>g[0])&&(v[0]=1),clearTimeout(this.timer),!v[0]&&!v[1])return!1;if(0<d)return this.timer=window.setTimeout(function(){n.drag(t,e)},d),!1;this.prevTime=p;var m=f({container:o,direction:v});this.trigger("scroll",{container:o,direction:v,inputEvent:t});var y=f({container:o,direction:v}),E=y[0]-m[0],C=y[1]-m[1];return!(!E&&!C)&&(this.trigger("move",{offsetX:v[0]?E:0,offsetY:v[1]?C:0,inputEvent:t}),u&&(this.timer=window.setTimeout(function(){n.drag(t,e)},u)),!0)},o.dragEnd=function(){clearTimeout(this.timer)},i}(t),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)};function q(t){return t&&"object"==typeof t}function U(t){return Array.isArray(t)}function W(t){return"string"==typeof t}function z(t,e,n,r){t.addEventListener(e,n,r)}function H(t,e,n){t.removeEventListener(e,n)}var G=function(){return(G=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)};var V=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(q(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(q(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(G({listener:e},n))},t}();var $,J,Q=(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 a[t];var n,r=String(t);return(n=i[r.toLowerCase()])?n:(n=o[r.toLowerCase()])||(1===r.length?r.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 r;if(r=i[e.toLowerCase()])return r===n;if(r=o[e.toLowerCase()])return r===n}else if("number"==typeof e)return e===n;return!1}};var i=(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(r=97;r<123;r++)i[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)i[r-48]=r;for(r=1;r<13;r++)i["f"+r]=r+111;for(r=0;r<10;r++)i["numpad "+r]=r+96;var a=e.names=e.title={};for(r in i)a[i[r]]=r;for(var s in o)i[s]=o[s]}($={exports:{}},$.exports),$.exports),Z=(Q.code,Q.codes,Q.aliases,Q.names),tt=(Q.title,{"+":"plus","left command":"meta","right command":"meta"}),et={shift:1,ctrl:2,alt:3,meta:4};function nt(t){var e=Z[t]||"";for(var n in tt)e=e.replace(n,tt[n]);return e.replace(/\s/g,"")}function rt(t,e){void 0===e&&(e=nt(t.keyCode));var n,r=[(n=t).shiftKey&&"shift",n.ctrlKey&&"ctrl",n.altKey&&"alt",n.metaKey&&"meta"].filter(Boolean);return-1===r.indexOf(e)&&r.push(e),r.filter(Boolean)}function it(t){var e=t.slice();return e.sort(function(t,e){return(et[t]||5)-(et[e]||5)}),e}var ot=function(n){function t(){this.constructor=e}var e,r;function i(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)},e.blur=function(){e.clear(),e.trigger("blur")},z(t,"blur",e.blur),z(t,"keydown",e.keydownEvent),z(t,"keyup",e.keyupEvent),e}L(e=i,r=n),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return Object.defineProperty(i,"global",{get:function(){return J=J||new i},enumerable:!1,configurable:!0}),i.setGlobal=function(){return this.global},o.destroy=function(){var t=this.container;this.clear(),this.off(),H(t,"blur",this.blur),H(t,"keydown",this.keydownEvent),H(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 U(e)?this.on(t+"."+it(e).join("."),n):W(e)?this.on(t+"."+e,n):this.on(t,e),this},o.removeEvent=function(t,e,n){return U(e)?this.off(t+"."+it(e).join("."),n):W(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=nt(e.keyCode),r={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,r),this.trigger(t+"."+n,r);var i=rt(e,n);1<i.length&&this.trigger(t+"."+i.join("."),r)},i}(V);function at(r){return r.length<3?0:Math.abs(function(t){for(var e=0,n=t.length-1;0<=n;--n)e+=t[n];return e}(r.map(function(t,e){var n=r[e+1]||r[0];return t[0]*n[1]-n[0]*t[1]})))/2}function st(t){var e=t.map(function(t){return t[0]}),n=t.map(function(t){return t[1]});return{minX:Math.min.apply(Math,e),minY:Math.min.apply(Math,n),maxX:Math.max.apply(Math,e),maxY:Math.max.apply(Math,n)}}function ct(t,e,n){var i=t[0],o=t[1],r=st(e),a=r.minX,s=r.minY,c=r.maxX,u=r.maxY,l=[[a,o],[c,o]],f=[[i,s],[i,u]],h=ut(l[0],l[1]),g=ut(f[0],f[1]),p=ht(e),d=[],v=[];return p.forEach(function(t){var e=ut(t[0],t[1]),n=ft(lt(h,e),[l,t]),r=ft(lt(g,e),[f,t]);1===n.length&&t[0][1]===o||d.push.apply(d,n),1===r.length&&t[0][0]===i||v.push.apply(v,r),e[0]||d.push.apply(d,n),e[1]||v.push.apply(v,r)}),!n&&(-1<m(d,function(t){return t[0]===i})||-1<m(v,function(t){return t[1]===o}))||!!(d.filter(function(t){return t[0]>i}).length%2&&v.filter(function(t){return t[1]>o}).length%2)}function ut(t,e){var n=t[0],r=t[1],i=e[0],o=e[1];if(n===i&&r===o)return[0,0,0];if(n===i)return[1,0,-n];if(r===o)return[0,1,-r];var a=(i-n)/(r-o);return[1,a,-n-a*r]}function lt(t,e){var n,r,i=t[0],o=t[1],a=t[2],s=e[0],c=e[1],u=e[2],l=0===i&&0===s,f=0===o&&0===c;if(l&&f)return[];if(l){var h=-a/o;return h!=-u/c?[]:[[-1/0,h],[1/0,h]]}if(f){var g=-a/i;return g!=-u/s?[]:[[g,-1/0],[g,1/0]]}return 0!==i?0!==s?0!==o?0!==c?[[n=(o*u-c*a)/(c*i-o*s),r=-(i*n+a)/o]]:[[n=-u/s,r=-(i*n+a)/o]]:[[n=-a/i,r=-(s*n+u)/c]]:[[n=-(o*(r=-u/c)+a)/i,r]]:[[n=-(c*(r=-a/o)+u)/s,r]]}function ft(t,e){var n=e.map(function(e){return[0,1].map(function(t){return[Math.min(e[0][t],e[1][t]),Math.max(e[0][t],e[1][t])]})});if(2===t.length){var r=t[0],i=r[0],o=r[1];if(i===t[1][0]){var a=Math.max.apply(Math,n.map(function(t){return t[1][0]})),s=Math.min.apply(Math,n.map(function(t){return t[1][1]}));return s<a?[]:[[i,a],[i,s]]}if(o===t[1][1]){var c=Math.max.apply(Math,n.map(function(t){return t[0][0]})),u=Math.min.apply(Math,n.map(function(t){return t[0][1]}));return u<c?[]:[[c,o],[u,o]]}}return t.filter(function(e){return n.every(function(t){return t[0][0]<=e[0]&&e[0]<=t[0][1]&&t[1][0]<=e[1]&&e[1]<=t[1][1]})})}function ht(n){return function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(n.slice(1),[n[0]]).map(function(t,e){return[n[e],t]})}function gt(t,e,n){var r=t.tag,i=t.children,o=t.attributes,a=t.className,s=t.style,c=e||document.createElement(r);for(var u in o)c.setAttribute(u,o[u]);var l=c.children;if(i.forEach(function(t,e){gt(t,l[e],c)}),a&&a.split(" ").forEach(function(t){var e,n,r,i;i=t,((r=c).classList?r.classList.contains(i):r.className.match(new RegExp("(\\s|^)"+i+"(\\s|$)")))||(n=t,(e=c).classList?e.classList.add(n):e.className+=" "+n)}),s){var f=c.style;for(var u in s)f[u]=s[u]}return!e&&n&&n.appendChild(c),c}function pt(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=e||{},o=i.className,a=i.style;return{tag:t,className:void 0===o?"":o,style:void 0===a?{}:a,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 dt(t,e,n){t!==e&&n(t,e)}function vt(t,e,n){var r;void 0===n&&(n=t.datas.boundArea);var i=t.distX,o=void 0===i?0:i,a=t.distY,s=void 0===a?0:a,c=t.datas,u=c.startX,l=c.startY;if(0<e){var f=Math.sqrt((o*o+s*s)/(1+e*e));o=(0<=o?1:-1)*(e*f),s=(0<=s?1:-1)*f}var h=Math.abs(o),g=Math.abs(s);o=(0<=o?1:-1)*(h=(r=function(t,n,r,e){if(!e)return t.map(function(t,e){return v(t,n[e],r[e])});var i=t[0],o=t[1],a=y(t,n,!1),s=a[0],c=a[1],u=y(t,r,!0),l=u[0],f=u[1];return i<s||o<c?(i=s,o=c):(l<i||f<o)&&(i=l,o=f),[i,o]}([h,g],[0,0],[o<0?u-n.left:n.right-u,s<0?l-n.top:n.bottom-l],!!e))[0]),s=(0<=s?1:-1)*(g=r[1]);var p=u+Math.min(0,o),d=l+Math.min(0,s);return{left:p,top:d,right:p+h,bottom:d+g,width:h,height:g}}function mt(t){var e=t.getBoundingClientRect(),n=e.left,r=e.top,i=e.width,o=e.height;return{pos1:[n,r],pos2:[n+i,r],pos3:[n,r+o],pos4:[n+i,r+o]}}function yt(t,e){var n=R(t,e),r=n.list,i=n.prevList,o=n.added,a=n.removed;return o.map(function(t){return r[t]}).concat(a.map(function(t){return i[t]}))}function Et(t,e,n,r){var i,o,a=document.createElement("style");return a.setAttribute("type","text/css"),a.setAttribute("data-styled-id",t),n.nonce&&a.setAttribute("nonce",n.nonce),a.innerHTML=(i=t,o=e,n.original?o:o.replace(/([^};{\s}][^};{]*|^\s*){/gm,function(t,e){var n=e.trim();return(n?s(n):[""]).map(function(t){var e=t.trim();return 0===e.indexOf("@")?e:-1<e.indexOf(":global")?e.replace(/\:global/g,""):-1<e.indexOf(":host")?""+e.replace(/\:host/g,"."+i):e?"."+i+" "+e:"."+i}).join(", ")+" {"})),(r||document.head||document.body).appendChild(a),a}var Ct,bt,St,wt,Dt=(St="rCS"+function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0}(Ct="\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),wt=0,{className:St,inject:function(t,e){void 0===e&&(e={});var n,r=function(t){if(t&&t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===wt;return(r||i)&&(n=Et(St,Ct,e,r)),i&&(bt=n),r||++wt,{destroy:function(){r?(t.removeChild(n),n=null):(0<wt&&--wt,0===wt&&bt&&(bt.parentNode.removeChild(bt),bt=null))}}}}),kt="selecto-selection "+Dt.className,Pt=["boundContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","scrollOptions","checkInput","preventDefault","ratio","getElementRect"],Tt=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(["dragContainer","cspNonce"],Pt),xt={boundContainer:null,target:null,container:null,dragContainer:null,selectableTargets:Array,selectByClick:Boolean,selectFromInside:Boolean,continueSelect:Boolean,toggleContinueSelect:Array,keyContainer:null,hitRate:Number,scrollOptions:Object,checkInput:Boolean,preventDefault:Boolean,cspNonce:String,ratio:Number,getElementRect:Function},Ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e}(function(e){function t(t){void 0===t&&(t={});var C=e.call(this)||this;return C.selectedTargets=[],C.dragScroll=new N,C.onDragStart=function(t,e){var n=t.datas,r=t.clientX,i=t.clientY,o=t.inputEvent,a=C.options,s=a.continueSelect,c=a.selectFromInside,u=a.selectByClick,l=a.boundContainer;C.findSelectableTargets(n),n.startSelectedTargets=C.selectedTargets;var f={left:-1/0,top:-1/0,right:1/0,bottom:1/0};if(l){var h=(typeof l===S?document.querySelector(l):!0===l?C.container:l).getBoundingClientRect();f={left:h.left,top:h.top,right:h.right,bottom:h.bottom}}n.boundArea=f;var g={left:r,top:i,right:r,bottom:i,width:0,height:0},p=[];if(!c||u){for(var d=e||document.elementFromPoint(r,i);d&&!(-1<n.selectableTargets.indexOf(d));)d=d.parentElement;p=d?[d]:[]}var v=0<p.length,m=!c&&v;if(m&&!u)return t.stop(),!1;var y=o.type;if(!(!("mousedown"===y||"touchstart"===y)||C.trigger("dragStart",b({},t))))return t.stop(),!1;if(s?(p=yt(C.selectedTargets,p),n.startPassedTargets=C.selectedTargets):n.startPassedTargets=[],C.select(C.selectedTargets,p,g,o,!0),n.startX=r,n.startY=i,n.selectFlag=!1,n.boundsArea=C.target.style.cssText+="left:0px;top:0px;transform: translate("+r+"px, "+i+"px)",m&&u)return o.preventDefault(),!1;n.selectFlag=!0,"touchstart"===y&&o.preventDefault();var E=C.options.scrollOptions;return E&&E.container&&C.dragScroll.dragStart(t,E),!0},C.onDrag=function(t){if(t.datas.selectFlag){var e=C.options.scrollOptions;if(e&&e.container&&C.dragScroll.drag(t,e))return}C.check(t)},C.onDragEnd=function(t){var e=t.datas,n=t.inputEvent,r=vt(t,C.options.ratio),i=e.selectFlag;n&&C.trigger("dragEnd",b(b({isDouble:!1,isDrag:!1,isSelect:i},t),{rect:r})),i&&(e.selectFlag=!1,C.dragScroll.dragEnd(),C.target.style.cssText+="display: none;"),C.selectEnd(e.startSelectedTargets,e.startPassedTargets,r,t)},C.onKeyDown=function(t){C.sameCombiKey(t)&&(C.continueSelect=!0,C.trigger("keydown",{}))},C.onKeyUp=function(t){C.sameCombiKey(t,!0)&&(C.continueSelect=!1,C.trigger("keyup",{}))},C.onBlur=function(){C.toggleContinueSelect&&C.continueSelect&&(C.continueSelect=!1,C.trigger("keyup",{}))},C.onDocumentSelectStart=function(e){if(C.gesto.isFlag()){var t=C.dragContainer;t===window&&(t=document.documentElement);var n=t instanceof Element?[t]:[].slice.call(t),r=e.target;n.some(function(t){if(t===r||t.contains(r))return e.preventDefault(),!0})}},C.target=t.target,C.container=t.container||document.body,C.options=b({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null,scrollOptions:void 0,checkInput:!1,preventDefault:!1,boundContainer:!1,getElementRect:mt,cspNonce:"",ratio:0},t),C.initElement(),C.initDragScroll(),C.setKeyController(),C}o(t,e);var n,r,i=t.prototype;return i.setSelectedTargets=function(t){return this.selectedTargets=t,this},i.getSelectedTargets=function(){return this.selectedTargets},i.setKeyContainer=function(t){var e=this,n=this.options;dt(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},i.setToggleContinueSelect=function(t){var e=this,n=this.options;dt(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},i.setPreventDefault=function(t){this.gesto.options.preventDefault=t},i.setCheckInput=function(t){this.gesto.options.checkInput=t},i.triggerDragStart=function(t){return this.gesto.triggerDragStart(t),this},i.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.gesto.unset(),this.injectResult.destroy(),C(document,"selectstart",this.onDocumentSelectStart),this.keycon=null,this.gesto=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},i.getElementPoints=function(t){var e,n,r,i,o,a,s,c,u,l,f,h,g,p=this.getElementRect,d=p(t),v=[d.pos1,d.pos2,d.pos4,d.pos3];if(p===mt)return v;var m=t.getBoundingClientRect();return e=v,r=(n=m).width,i=n.height,o=n.left,a=n.top,s=st(e),c=s.minX,u=s.minY,l=s.maxX,f=s.maxY,h=r/(l-c),g=i/(f-u),e.map(function(t){return[o+(t[0]-c)*h,a+(t[1]-u)*g]})},i.findSelectableTargets=function(t){var e=this;void 0===t&&(t=this.gesto.getEventDatas());var n=this.getSelectableTargets(),r=n.map(function(t){return e.getElementPoints(t)});t.selectableTargets=n,t.selectablePoints=r},i.clickTarget=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0]||t.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),r={datas:{flag:!1},clientX:n.clientX,clientY:n.clientY,inputEvent:t,stop:function(){return!1}};return this.onDragStart(r,e)&&(r.datas.flag=!1,this.onDragEnd(r)),this},i.setKeyController=function(){var t=this.options,e=t.keyContainer,n=t.toggleContinueSelect;this.keycon&&(this.keycon.destroy(),this.keycon=null),n&&(this.keycon=new ot(e||window),this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on("blur",this.onBlur))},i.setKeyEvent=function(){this.options.toggleContinueSelect&&!this.keycon&&this.setKeyController()},i.initElement=function(){this.target=gt(pt("div",{className:kt}),this.target,this.container);var t=this.target,e=this.options,n=e.dragContainer,r=e.checkInput,i=e.preventDefault;this.dragContainer="string"==typeof n?[].slice.call(document.querySelectorAll(n)):this.options.dragContainer||this.target.parentNode,this.gesto=new M(this.dragContainer,{checkWindowBlur:!0,container:window,checkInput:r,preventDefault:i}).on({dragStart:this.onDragStart,drag:this.onDrag,dragEnd:this.onDragEnd}),E(document,"selectstart",this.onDocumentSelectStart),this.injectResult=Dt.inject(t,{nonce:this.options.cspNonce})},i.hitTest=function(t,s,c,e,u){var n=this.options,l=n.hitRate,f=n.selectByClick,r=t.left,i=t.top,o=t.right,a=t.bottom,h=[[r,i],[o,i],[o,a],[r,a]];return e.filter(function(t,e){var n=u[e],r=ct([s,c],n);if(f&&r)return!0;var i=function(t,e){var n=t.slice(),s=e.slice();-1===g(n)&&n.reverse(),-1===g(s)&&s.reverse();var c=ht(n),u=ht(s),r=c.map(function(t){return ut(t[0],t[1])}),l=u.map(function(t){return ut(t[0],t[1])}),f=[];r.forEach(function(r,i){var o=c[i],a=[];l.forEach(function(t,e){var n=ft(lt(r,t),[o,u[e]]);a.push.apply(a,n.map(function(t){return{index1:i,index2:e,pos:t}}))}),a.sort(function(t,e){return p(o[0],t.pos)-p(o[0],e.pos)}),f.push.apply(f,a),ct(o[1],s)&&f.push({index1:i,index2:-1,pos:o[1]})}),u.forEach(function(t,r){if(ct(t[1],n)){var i=!1,e=m(f,function(t){return t.index2===r?!(i=!0):!!i});-1===e&&(i=!1,e=m(f,function(t){var e=t.index1,n=t.index2;return-1===e&&n+1===r?!(i=!0):!!i})),-1===e?f.push({index1:-1,index2:r,pos:t[1]}):f.splice(e,0,{index1:-1,index2:r,pos:t[1]})}});var i=f.map(function(t){return t.pos}),o={};return i.filter(function(t){var e=t[0]+"x"+t[1];return!o[e]&&(o[e]=!0)})}(h,n);if(!i.length)return!1;var o=at(i),a=at(n);return v(Math.round(o/a*100),0,100)>=Math.min(100,l)})},i.initDragScroll=function(){var o=this;this.dragScroll.on("scroll",function(t){var e=t.container,n=t.direction;o.trigger("scroll",{container:e,direction:n})}).on("move",function(t){var e=t.offsetX,n=t.offsetY,r=t.inputEvent,i=r.datas;i.startX-=e,i.startY-=n,i.selectablePoints.forEach(function(t){t.forEach(function(t){t[0]-=e,t[1]-=n})}),o.gesto.scrollBy(e,n,r.inputEvent,!1),r.distX+=e,r.distY+=n,o.check(r)})},i.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){a(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},i.select=function(t,e,n,r,i){var o=R(t,e),a=o.added,s=o.removed,c=o.prevList,u=o.list;this.selectedTargets=e,i&&this.trigger("selectStart",{selected:e,added:a.map(function(t){return u[t]}),removed:s.map(function(t){return c[t]}),rect:n,inputEvent:r}),(a.length||s.length)&&this.trigger("select",{selected:e,added:a.map(function(t){return u[t]}),removed:s.map(function(t){return c[t]}),rect:n,inputEvent:r})},i.selectEnd=function(t,e,n,r){var i=r.inputEvent,o=r.isDouble,a=R(t,this.selectedTargets),s=a.added,c=a.removed,u=a.prevList,l=a.list,f=R(e,this.selectedTargets),h=f.added,g=f.removed,p=f.prevList,d=f.list,v=i&&i.type,m="mousedown"===v||"touchstart"===v;this.trigger("selectEnd",{selected:this.selectedTargets,added:s.map(function(t){return l[t]}),removed:c.map(function(t){return u[t]}),afterAdded:h.map(function(t){return d[t]}),afterRemoved:g.map(function(t){return p[t]}),isDragStart:m,isDouble:!!o,rect:n,inputEvent:i})},i.check=function(t,e){void 0===e&&(e=vt(t,this.options.ratio));var n=t.datas,r=t.inputEvent,i=e.top,o=e.left,a=e.width,s=e.height,c=n.selectFlag,u=[],l=[];if(c){this.target.style.cssText+="display: block;left:0px;top:0px;transform: translate("+o+"px, "+i+"px);width:"+a+"px;height:"+s+"px;";var f=this.hitTest(e,n.startX,n.startY,n.selectableTargets,n.selectablePoints);u=this.selectedTargets,l=yt(n.startPassedTargets,f),this.selectedTargets=l}this.trigger("drag",b(b({},t),{isSelect:c,rect:e})),c&&this.select(u,l,e,r)},i.sameCombiKey=function(t,e){var n,r=[].concat(this.options.toggleContinueSelect),i=rt(t.inputEvent,t.key),o=(n=r[0],Array.isArray(n)?r:[r]);if(e){var a=t.key;return o.some(function(t){return t.some(function(t){return t===a})})}return o.some(function(t){return t.every(function(t){return-1<i.indexOf(t)})})},t=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;0<=s;s--)(i=t[s])&&(a=(o<3?i(a):3<o?i(e,n,a):i(e,n))||a);return 3<o&&a&&Object.defineProperty(e,n,a),a}([(n=Pt,r=function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},r=("set "+e).replace(/[\s-_]([a-z])/g,function(t,e){return e.toUpperCase()});t[r]?n.set=function(t){this[r](t)}:n.set=function(t){this.options[e]=t},Object.defineProperty(t,e,n)},function(t){var e=t.prototype;n.forEach(function(t){r(e,t)})})],t)}(t)),_t={__proto__:null,default:Ot,OPTIONS:Tt,OPTION_TYPES:xt,PROPERTIES:Pt,EVENTS:["dragStart","drag","dragEnd","selectStart","select","selectEnd","keydown","keyup","scroll"],METHODS:["clickTarget","setSelectedTargets","triggerDragStart"],CLASS_NAME:kt};for(var Mt in _t)Ot[Mt]=_t[Mt];return Ot}); | ||
//# sourceMappingURL=selecto.min.js.map |
{ | ||
"name": "selecto", | ||
"version": "1.7.4", | ||
"version": "1.8.0", | ||
"description": "Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.", | ||
@@ -46,3 +46,3 @@ "main": "./dist/selecto.cjs.js", | ||
"dependencies": { | ||
"@daybrush/utils": "^1.1.1", | ||
"@daybrush/utils": "^1.3.1", | ||
"@egjs/children-differ": "^1.0.1", | ||
@@ -54,3 +54,4 @@ "@scena/dragscroll": "^0.3.1", | ||
"gesto": "^1.2.1", | ||
"keycon": "^1.1.2" | ||
"keycon": "^1.1.2", | ||
"overlap-area": "^1.0.0" | ||
}, | ||
@@ -57,0 +58,0 @@ "peerDependencies": { |
@@ -75,3 +75,23 @@ | ||
``` | ||
### Do you want to select correctly? | ||
Since `selecto` basically checks using getBoundingClientRect, it is not accurate if the object is rotated or distorted. | ||
If you want to check correctly, use `getElementRect` option with the following code | ||
```ts | ||
import Selecto from "selecto"; | ||
import { getElementInfo } from "moveable"; // (13kb function) | ||
const selecto = new Selecto({ | ||
..., | ||
// (target: HTMLElement | SVGElement ) => { pos1: number[], pos2: number[], pos3: number[], pos4: number[] } | ||
// pos1: left top | ||
// pos2: right top | ||
// pos3: left bottom | ||
// pos4: right bottom | ||
getElementRect: getElementInfo, | ||
}); | ||
``` | ||
## 📦 Packages | ||
@@ -78,0 +98,0 @@ |Package Name| Version |Description| |
@@ -32,3 +32,3 @@ import styled from "css-styled"; | ||
"ratio", | ||
"getElementPoints", | ||
"getElementRect", | ||
] as const; | ||
@@ -62,3 +62,3 @@ /** | ||
ratio: Number, | ||
getElementPoints: Function, | ||
getElementRect: Function, | ||
}; | ||
@@ -65,0 +65,0 @@ |
@@ -48,3 +48,3 @@ import { IObject } from "@daybrush/utils"; | ||
ratio: number; | ||
getElementPoints: GetElementPointsFunction; | ||
getElementRect: getElementRectFunction; | ||
} | ||
@@ -136,5 +136,7 @@ | ||
* @property - Rect of Selection Element | ||
* @property - Whether it is in select | ||
*/ | ||
export interface OnDrag extends OnParentDrag { | ||
rect: Rect; | ||
isSelect: boolean; | ||
} | ||
@@ -145,5 +147,7 @@ /** | ||
* @property - Rect of Selection Element | ||
* @property - Whether it is in select | ||
*/ | ||
export interface OnDragEnd extends OnParentDragEnd { | ||
rect: Rect; | ||
isSelect: boolean; | ||
} | ||
@@ -163,7 +167,8 @@ export interface SelectoEvents { | ||
export type SelectoMethods = { [P in typeof METHODS[number]]: Selecto[P] }; | ||
export type GetElementPointsFunction = (el: HTMLElement | SVGElement) => { | ||
pos1: number[], | ||
pos2: number[], | ||
pos3: number[], | ||
pos4: number[], | ||
}; | ||
export type getElementRectFunction = (el: HTMLElement | SVGElement) => PointArea; | ||
export interface PointArea { | ||
pos1: number[]; | ||
pos2: number[]; | ||
pos3: number[]; | ||
pos4: number[]; | ||
} |
import { Hypertext, Rect } from "./types"; | ||
import { IObject, addClass, hasClass, calculateBoundSize } from "@daybrush/utils"; | ||
import { diff } from "@egjs/children-differ"; | ||
@@ -80,3 +81,3 @@ export function getClient(e: MouseEvent | TouchEvent) { | ||
e: any, ratio: number, | ||
boundArea: { left: number, right: number, top: number, bottom: number}, | ||
boundArea = e.datas.boundArea, | ||
): Rect { | ||
@@ -121,3 +122,3 @@ let { | ||
export function getDefaultElementPoints(el: HTMLElement) { | ||
export function getDefaultElementRect(el: HTMLElement) { | ||
const rect = el.getBoundingClientRect(); | ||
@@ -133,1 +134,15 @@ const { left, top, width, height } = rect; | ||
} | ||
export function passTargets( | ||
beforeTargets: Array<HTMLElement | SVGElement>, | ||
afterTargets: Array<HTMLElement | SVGElement>, | ||
) { | ||
const { | ||
list, | ||
prevList, | ||
added, | ||
removed, | ||
} = diff(beforeTargets, afterTargets); | ||
return added.map(index => list[index]).concat(removed.map(index => prevList[index])); | ||
} |
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
520237
35
7678
146
11
+ Addedoverlap-area@^1.0.0
+ Addedoverlap-area@1.1.0(transitive)
Updated@daybrush/utils@^1.3.1