diff --git a/.gitignore b/.gitignore index 47a7eba..fddb859 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ node_modules/ *.DS_Store .DS_Store doc/ -dist/ + release/ npm-debug.log* coverage/ diff --git a/dist/selecto.cjs.js b/dist/selecto.cjs.js new file mode 100644 index 0000000..396a3ad --- /dev/null +++ b/dist/selecto.cjs.js @@ -0,0 +1,1013 @@ +/* +Copyright (c) 2020 Daybrush +name: selecto +license: MIT +author: Daybrush +repository: git+https://github.com/daybrush/selecto.git +version: 1.3.0 +*/ +'use strict'; + +var Component = require('@egjs/component'); +var Dragger = require('@daybrush/drag'); +var frameworkUtils = require('framework-utils'); +var utils = require('@daybrush/utils'); +var ChildrenDiffer = require('@egjs/children-differ'); +var DragScroll = require('@scena/dragscroll'); +var KeyController = require('keycon'); +var styled = require('css-styled'); + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/* global Reflect, Promise */ +var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + + return extendStatics(d, b); +}; + +function __extends(d, b) { + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} +var __assign = function () { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign.apply(this, arguments); +}; +function __rest(s, e) { + var t = {}; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + + if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; + } + return t; +} +function __decorate(decorators, target, key, desc) { + var c = arguments.length, + r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, + d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + + for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; + + return r; +} + +function getClient(e) { + if ("touches" in e) { + var touch = e.touches[0] || e.changedTouches[0]; + return { + clientX: touch.clientX, + clientY: touch.clientY + }; + } else { + return { + clientX: e.clientX, + clientY: e.clientY + }; + } +} +function createElement(jsx, prevTarget, container) { + var tag = jsx.tag, + children = jsx.children, + attributes = jsx.attributes, + className = jsx.className, + style = jsx.style; + var el = prevTarget || document.createElement(tag); + + for (var name in attributes) { + el.setAttribute(name, attributes[name]); + } + + var elChildren = el.children; + children.forEach(function (child, i) { + createElement(child, elChildren[i], el); + }); + + if (className) { + className.split(" ").forEach(function (name) { + if (!utils.hasClass(el, name)) { + utils.addClass(el, name); + } + }); + } + + if (style) { + var elStyle = el.style; + + for (var name in style) { + elStyle[name] = style[name]; + } + } + + if (!prevTarget && container) { + container.appendChild(el); + } + + return el; +} +function h(tag, attrs) { + var children = []; + + for (var _i = 2; _i < arguments.length; _i++) { + children[_i - 2] = arguments[_i]; + } + + var _a = attrs || {}, + _b = _a.className, + className = _b === void 0 ? "" : _b, + _c = _a.style, + style = _c === void 0 ? {} : _c, + attributes = __rest(_a, ["className", "style"]); + + return { + tag: tag, + className: className, + style: style, + attributes: attributes, + children: children + }; +} +function diffValue(prev, cur, func) { + if (prev !== cur) { + func(prev, cur); + } +} +function getRect(e) { + var _a = e.distX, + distX = _a === void 0 ? 0 : _a, + _b = e.distY, + distY = _b === void 0 ? 0 : _b, + datas = e.datas; + var startX = datas.startX, + startY = datas.startY; + var tx = Math.min(0, distX); + var ty = Math.min(0, distY); + var width = Math.abs(distX); + var height = Math.abs(distY); + var left = startX + tx; + var top = startY + ty; + return { + left: left, + top: top, + right: left + width, + bottom: top + height, + width: width, + height: height + }; +} + +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"); +/** + * @memberof Selecto + */ + +var CLASS_NAME = "selecto-selection " + injector.className; +var PROPERTIES = ["selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault"]; +/** + * @memberof Selecto + */ + +var OPTIONS = __spreadArrays([// ignore target, container, +"dragContainer"], PROPERTIES); +var OPTION_TYPES = { + 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 +}; +/** + * @memberof Selecto + */ + +var EVENTS = ["dragStart", "selectStart", "select", "selectEnd", "keydown", "keyup", "scroll"]; +/** + * @memberof Selecto + */ + +var METHODS = ["clickTarget", "setSelectedTargets", "triggerDragStart"]; + +/** + * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch. + * @sort 1 + * @extends eg.Component + */ + +var Selecto = +/*#__PURE__*/ +function (_super) { + __extends(Selecto, _super); + /** + * + */ + + + function Selecto(options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.selectedTargets = []; + _this.differ = new ChildrenDiffer(); + _this.dragScroll = new DragScroll(); + + _this.onDragStart = function (e, clickedTarget) { + var datas = e.datas, + clientX = e.clientX, + clientY = e.clientY, + inputEvent = e.inputEvent; + var _a = _this.options, + continueSelect = _a.continueSelect, + selectFromInside = _a.selectFromInside, + selectByClick = _a.selectByClick; + + var selectableTargets = _this.getSelectableTargets(); + + var selectableRects = selectableTargets.map(function (target) { + var rect = target.getBoundingClientRect(); + var left = rect.left, + top = rect.top, + width = rect.width, + height = rect.height; + return { + left: left, + top: top, + right: left + width, + bottom: top + height, + width: width, + height: height + }; + }); + datas.selectableTargets = selectableTargets; + datas.selectableRects = selectableRects; + datas.startSelectedTargets = _this.selectedTargets; + var pointTarget = clickedTarget || document.elementFromPoint(clientX, clientY); + var hitRect = { + left: clientX, + top: clientY, + right: clientX, + bottom: clientY, + width: 0, + height: 0 + }; + + var firstPassedTargets = _this.hitTest(hitRect, clientX, clientY, selectableTargets, selectableRects).filter(function (target) { + return target === pointTarget || target.contains(pointTarget); + }); + + var hasInsideTargets = firstPassedTargets.length > 0; + var isPreventSelect = !selectFromInside && hasInsideTargets; + + if (isPreventSelect && !selectByClick) { + return false; + } + + if (!continueSelect) { + _this.selectedTargets = []; + } else { + firstPassedTargets = _this.getSelectedTargets(firstPassedTargets); + } + + var type = inputEvent.type; + var isTrusted = type === "mousedown" || type === "touchstart"; + /** + * When the drag starts, the dragStart event is called. + * Call the stop () function if you have a specific element or don't want to raise a select + * @memberof Selecto + * @event dragStart + * @param {OnDragStart} - Parameters for the dragStart event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("dragStart", e => { + * if (e.inputEvent.target.tagName === "SPAN") { + * e.stop(); + * } + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + var result = isTrusted ? _this.trigger("dragStart", e) : true; + + if (!result) { + return false; + } + + _this.select(firstPassedTargets, hitRect, inputEvent, true); + + datas.startX = clientX; + datas.startY = clientY; + datas.selectedTargets = firstPassedTargets; + _this.target.style.cssText += "left:0px;top:0px;transform: translate(" + clientX + "px, " + clientY + "px)"; + + if (isPreventSelect && selectByClick) { + _this.onDragEnd(e); + + inputEvent.preventDefault(); + return false; + } else { + if (type === "touchstart") { + inputEvent.preventDefault(); + } + + var scrollOptions = _this.options.scrollOptions; + + if (scrollOptions && scrollOptions.container) { + _this.dragScroll.dragStart(e, scrollOptions); + } + + return true; + } + }; + + _this.onDrag = function (e) { + var scrollOptions = _this.options.scrollOptions; + + if (scrollOptions && scrollOptions.container) { + if (_this.dragScroll.drag(e, scrollOptions)) { + return; + } + } + + _this.check(e); + }; + + _this.onDragEnd = function (e) { + var datas = e.datas; + + _this.dragScroll.dragEnd(); + + _this.target.style.cssText += "display: none;"; + + _this.selectEnd(datas.startSelectedTargets, datas.selectedTargets, getRect(e), e); + + _this.selectedTargets = datas.selectedTargets; + }; + + _this.onKeyDown = function (e) { + if (!_this.sameCombiKey(e)) { + return; + } + + _this.continueSelect = true; + /** + * When you keydown the key you specified in toggleContinueSelect, the keydown event is called. + * @memberof Selecto + * @event keydown + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * toggleContinueSelect: "shift"; + * keyContainer: window, + * }); + * + * selecto.on("keydown", () => { + * document.querySelector(".button").classList.add("selected"); + * }).on("keyup", () => { + * document.querySelector(".button").classList.remove("selected"); + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + _this.trigger("keydown", {}); + }; + + _this.onKeyUp = function (e) { + if (!_this.sameCombiKey(e)) { + return; + } + + _this.continueSelect = false; + /** + * When you keyup the key you specified in toggleContinueSelect, the keyup event is called. + * @memberof Selecto + * @event keyup + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * toggleContinueSelect: "shift"; + * keyContainer: window, + * }); + * + * selecto.on("keydown", () => { + * document.querySelector(".button").classList.add("selected"); + * }).on("keyup", () => { + * document.querySelector(".button").classList.remove("selected"); + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + _this.trigger("keyup", {}); + }; + + _this.onBlur = function () { + if (_this.toggleContinueSelect && _this.continueSelect) { + _this.trigger("keyup", {}); + } + }; + + _this.onDocumentSelectStart = function (e) { + if (!_this.dragger.isFlag()) { + return; + } + + var dragContainer = _this.dragContainer; + + if (dragContainer === window) { + dragContainer = document.documentElement; + } + + var containers = dragContainer instanceof Element ? [dragContainer] : [].slice.call(dragContainer); + var target = e.target; + containers.some(function (container) { + if (container === target || container.contains(target)) { + e.preventDefault(); + return true; + } + }); + }; + + _this.target = options.target; + _this.container = options.container; + _this.options = __assign({ + target: null, + container: null, + dragContainer: null, + selectableTargets: [], + selectByClick: true, + selectFromInside: true, + hitRate: 100, + continueSelect: false, + toggleContinueSelect: null, + keyContainer: null, + scrollOptions: undefined, + checkInput: false, + preventDefault: false + }, options); + + _this.initElement(); + + _this.initDragScroll(); + + _this.setKeyController(); + + return _this; + } + /** + * You can set the currently selected targets. + */ + + + var __proto = Selecto.prototype; + + __proto.setSelectedTargets = function (selectedTargets) { + this.selectedTargets = selectedTargets; + this.differ = new ChildrenDiffer(selectedTargets); + return this; + }; + + __proto.setKeyContainer = function (keyContainer) { + var _this = this; + + var options = this.options; + diffValue(options.keyContainer, keyContainer, function () { + options.keyContainer = keyContainer; + + _this.setKeyController(); + }); + }; + + __proto.setToggleContinueSelect = function (toggleContinueSelect) { + var _this = this; + + var options = this.options; + diffValue(options.toggleContinueSelect, toggleContinueSelect, function () { + options.toggleContinueSelect = toggleContinueSelect; + + _this.setKeyEvent(); + }); + }; + + __proto.setPreventDefault = function (value) { + this.dragger.options.preventDefault = value; + }; + + __proto.setCheckInput = function (value) { + this.dragger.options.checkInput = value; + }; + /** + * `OnDragStart` is triggered by an external event. + * @param - external event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto(); + * + * window.addEventListener("mousedown", e => { + * selecto.triggerDragStart(e); + * }); + */ + + + __proto.triggerDragStart = function (e) { + this.dragger.onDragStart(e); + return this; + }; + /** + * Destroy elements, properties, and events. + */ + + + __proto.destroy = function () { + this.off(); + this.keycon && this.keycon.destroy(); + this.dragger.unset(); + this.injectResult.destroy(); + utils.removeEvent(document, "selectstart", this.onDocumentSelectStart); + this.keycon = null; + this.dragger = null; + this.injectResult = null; + this.target = null; + this.container = null; + this.options = null; + }; + /** + * External click or mouse events can be applied to the selecto. + * @params - Extenal click or mouse event + * @params - Specify the clicked target directly. + */ + + + __proto.clickTarget = function (e, clickedTarget) { + var _a = getClient(e), + clientX = _a.clientX, + clientY = _a.clientY; + + var dragEvent = { + datas: {}, + clientX: clientX, + clientY: clientY, + inputEvent: e + }; + + if (this.onDragStart(dragEvent, clickedTarget)) { + this.onDragEnd(dragEvent); + } + + return this; + }; + + __proto.setKeyController = function () { + var _a = this.options, + keyContainer = _a.keyContainer, + toggleContinueSelect = _a.toggleContinueSelect; + + if (this.keycon) { + this.keycon.destroy(); + this.keycon = null; + } + + if (toggleContinueSelect) { + this.keycon = new KeyController(keyContainer || window); + this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on("blur", this.onBlur); + } + }; + + __proto.setKeyEvent = function () { + var toggleContinueSelect = this.options.toggleContinueSelect; + + if (!toggleContinueSelect || this.keycon) { + return; + } + + this.setKeyController(); + }; + + __proto.initElement = function () { + this.target = createElement(h("div", { + className: CLASS_NAME + }), this.target, this.container); + var target = this.target; + var _a = this.options, + dragContainer = _a.dragContainer, + checkInput = _a.checkInput, + preventDefault = _a.preventDefault; + this.dragContainer = typeof dragContainer === "string" ? [].slice.call(document.querySelectorAll(dragContainer)) : this.options.dragContainer || this.target.parentNode; + this.dragger = new Dragger(this.dragContainer, { + container: window, + checkInput: checkInput, + preventDefault: preventDefault, + dragstart: this.onDragStart, + drag: this.onDrag, + dragend: this.onDragEnd + }); + utils.addEvent(document, "selectstart", this.onDocumentSelectStart); + this.injectResult = injector.inject(target); + }; + + __proto.hitTest = function (selectRect, clientX, clientY, targets, rects) { + var _a = this.options, + hitRate = _a.hitRate, + selectByClick = _a.selectByClick; + var left = selectRect.left, + top = selectRect.top, + right = selectRect.right, + bottom = selectRect.bottom; + var passedTargets = []; + rects.forEach(function (rect, i) { + var rectLeft = rect.left, + rectTop = rect.top, + rectRight = rect.right, + rectBottom = rect.bottom; + 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) { + passedTargets.push(targets[i]); + return; + } + + if (testRight < testLeft || testBottom < testTop) { + return; + } + + var rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100); + + if (rate >= hitRate) { + passedTargets.push(targets[i]); + } + }); + return passedTargets; + }; + + __proto.initDragScroll = function () { + var _this = this; + + this.dragScroll.on("scroll", function (_a) { + var container = _a.container, + direction = _a.direction; + + _this.trigger("scroll", { + container: container, + direction: direction + }); + }).on("move", function (_a) { + var offsetX = _a.offsetX, + offsetY = _a.offsetY, + inputEvent = _a.inputEvent; + var datas = inputEvent.datas; + datas.startX -= offsetX; + datas.startY -= offsetY; + datas.selectableRects.forEach(function (rect) { + rect.top -= offsetY; + rect.bottom -= offsetY; + rect.left -= offsetX; + rect.right -= offsetX; + }); + + _this.dragger.scrollBy(offsetX, offsetY, inputEvent.inputEvent, false); + + inputEvent.distX += offsetX; + inputEvent.distY += offsetY; + + _this.check(inputEvent); + }); + }; + + __proto.getSelectableTargets = function () { + var selectableTargets = []; + this.options.selectableTargets.forEach(function (target) { + if (utils.isObject(target)) { + selectableTargets.push(target); + } else { + var elements = [].slice.call(document.querySelectorAll(target)); + elements.forEach(function (el) { + selectableTargets.push(el); + }); + } + }); + return selectableTargets; + }; + + __proto.getSelectedTargets = function (passedTargets) { + var _a = ChildrenDiffer.diff(this.selectedTargets, passedTargets), + 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]; + })); + }; + + __proto.select = function (selectedTargets, rect, inputEvent, isStart) { + var _a = this.differ.update(selectedTargets), + added = _a.added, + removed = _a.removed, + prevList = _a.prevList, + list = _a.list; + + if (isStart) { + /** + * When the select(drag) starts, the selectStart event is called. + * @memberof Selecto + * @event selectStart + * @param {Selecto.OnSelect} - Parameters for the selectStart event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("selectStart", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }).on("selectEnd", e => { + * e.afterAdded.forEach(el => { + * el.classList.add("selected"); + * }); + * e.afterRemoved.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + this.trigger("selectStart", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + rect: rect, + inputEvent: inputEvent + }); + } + + if (added.length || removed.length) { + /** + * When the select in real time, the select event is called. + * @memberof Selecto + * @event select + * @param {Selecto.OnSelect} - Parameters for the select event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + this.trigger("select", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + rect: rect, + inputEvent: inputEvent + }); + } + }; + + __proto.selectEnd = function (startSelectedTargets, selectedTargets, rect, e) { + var inputEvent = e.inputEvent, + isDouble = e.isDouble; + + var _a = ChildrenDiffer.diff(startSelectedTargets, selectedTargets), + added = _a.added, + removed = _a.removed, + prevList = _a.prevList, + list = _a.list; + + var _b = ChildrenDiffer.diff(this.selectedTargets, selectedTargets), + afterAdded = _b.added, + afterRemoved = _b.removed, + afterPrevList = _b.prevList, + afterList = _b.list; + + var type = inputEvent.type; + var isDragStart = type === "mousedown" || type === "touchstart"; + /** + * When the select(dragEnd or click) ends, the selectEnd event is called. + * @memberof Selecto + * @event selectEnd + * @param {Selecto.OnSelectEnd} - Parameters for the selectEnd event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("selectStart", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }).on("selectEnd", e => { + * e.afterAdded.forEach(el => { + * el.classList.add("selected"); + * }); + * e.afterRemoved.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + this.trigger("selectEnd", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + afterAdded: afterAdded.map(function (index) { + return afterList[index]; + }), + afterRemoved: afterRemoved.map(function (index) { + return afterPrevList[index]; + }), + isDragStart: isDragStart, + isDouble: !!isDouble, + rect: rect, + inputEvent: inputEvent + }); + }; + + __proto.check = function (e) { + var datas = e.datas, + inputEvent = e.inputEvent; + var rect = getRect(e); + var top = rect.top, + left = rect.left, + width = rect.width, + 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.selectableRects); + var selectedTargets = this.getSelectedTargets(passedTargets); + this.select(selectedTargets, rect, inputEvent); + datas.selectedTargets = selectedTargets; + }; + + __proto.sameCombiKey = function (e) { + var toggleContinueSelect = [].concat(this.options.toggleContinueSelect); + var combi = KeyController.getCombi(e.inputEvent, e.key); + return toggleContinueSelect.every(function (key) { + return combi.indexOf(key) > -1; + }); + }; + + Selecto = __decorate([frameworkUtils.Properties(PROPERTIES, function (prototype, property) { + var attributes = { + enumerable: true, + configurable: true, + get: function () { + return this.options[property]; + } + }; + var setter = utils.camelize("set " + property); + + if (prototype[setter]) { + attributes.set = function (value) { + this[setter](value); + }; + } else { + attributes.set = function (value) { + this.options[property] = value; + }; + } + + Object.defineProperty(prototype, property, attributes); + })], Selecto); + return Selecto; +}(Component); + + + +var modules = ({ + __proto__: null, + 'default': Selecto, + OPTIONS: OPTIONS, + OPTION_TYPES: OPTION_TYPES, + PROPERTIES: PROPERTIES, + EVENTS: EVENTS, + METHODS: METHODS, + CLASS_NAME: CLASS_NAME +}); + +for (var name in modules) { + Selecto[name] = modules[name]; +} + +module.exports = Selecto; +//# sourceMappingURL=selecto.cjs.js.map diff --git a/dist/selecto.cjs.js.map b/dist/selecto.cjs.js.map new file mode 100644 index 0000000..74b46da --- /dev/null +++ b/dist/selecto.cjs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"selecto.cjs.js","sources":["../src/utils.ts","../src/consts.ts","../src/Selecto.tsx","../src/index.umd.ts"],"sourcesContent":["import { Hypertext, Rect } from \"./types\";\nimport { IObject, addClass, hasClass } from \"@daybrush/utils\";\n\nexport function getClient(e: MouseEvent | TouchEvent) {\n if (\"touches\" in e) {\n const touch = e.touches[0] || e.changedTouches[0];\n\n return {\n clientX: touch.clientX,\n clientY: touch.clientY,\n };\n } else {\n return {\n clientX: e.clientX,\n clientY: e.clientY,\n };\n }\n}\n\nexport function createElement(\n jsx: Hypertext,\n prevTarget?: HTMLElement | SVGElement,\n container?: HTMLElement | SVGElement,\n) {\n const { tag, children, attributes, className, style } = jsx;\n const el = prevTarget || document.createElement(tag) as HTMLElement | SVGElement;\n\n for (const name in attributes) {\n el.setAttribute(name, attributes[name]);\n }\n const elChildren = el.children;\n children.forEach((child, i) => {\n createElement(child, elChildren[i] as HTMLElement | SVGElement, el);\n });\n if (className) {\n className.split(\" \").forEach(name => {\n if (!hasClass(el, name)) {\n addClass(el, name);\n }\n });\n }\n if (style) {\n const elStyle = el.style;\n for (const name in style) {\n elStyle[name] = style[name];\n }\n }\n if (!prevTarget && container) {\n container.appendChild(el);\n }\n return el;\n}\nexport function h(\n tag: string,\n attrs: IObject,\n ...children: Hypertext[]\n): Hypertext {\n const {\n className = \"\",\n style = {},\n ...attributes\n } = attrs || {};\n return {\n tag,\n className,\n style,\n attributes,\n children,\n };\n}\n\nexport function diffValue(prev: T, cur: T, func: (prev: T, cur: T) => void) {\n if (prev !== cur) {\n func(prev, cur);\n }\n}\n\nexport function getRect(e: any): Rect {\n const {\n distX = 0,\n distY = 0,\n datas,\n } = e;\n const { startX, startY } = datas;\n const tx = Math.min(0, distX);\n const ty = Math.min(0, distY);\n const width = Math.abs(distX);\n const height = Math.abs(distY);\n const left = startX + tx;\n const top = startY + ty;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n}\n","import styled from \"css-styled\";\nimport { SelectoOptions } from \"./types\";\n\nexport const 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`);\n\n/**\n * @memberof Selecto\n */\nexport const CLASS_NAME = `selecto-selection ${injector.className}`;\n\nexport const PROPERTIES = [\n \"selectableTargets\",\n \"selectByClick\",\n \"selectFromInside\",\n \"continueSelect\",\n \"toggleContinueSelect\",\n \"keyContainer\",\n \"hitRate\",\n \"scrollOptions\",\n \"checkInput\",\n \"preventDefault\",\n] as const;\n/**\n * @memberof Selecto\n */\nexport const OPTIONS = [\n // ignore target, container,\n \"dragContainer\",\n ...PROPERTIES,\n] as const;\n\nexport const OPTION_TYPES: { [key in keyof SelectoOptions]: any } = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: Array,\n selectByClick: Boolean,\n selectFromInside: Boolean,\n continueSelect: Boolean,\n toggleContinueSelect: Array,\n keyContainer: null,\n hitRate: Number,\n scrollOptions: Object,\n checkInput: Boolean,\n preventDefault: Boolean,\n};\n\n\n/**\n * @memberof Selecto\n */\nexport const EVENTS = [\n \"dragStart\",\n \"selectStart\",\n \"select\",\n \"selectEnd\",\n \"keydown\",\n \"keyup\",\n \"scroll\",\n] as const;\n\n/**\n * @memberof Selecto\n */\nexport const METHODS = [\n \"clickTarget\",\n \"setSelectedTargets\",\n \"triggerDragStart\",\n] as const;\n","import Component from \"@egjs/component\";\nimport Dragger, { OnDrag } from \"@daybrush/drag\";\nimport { InjectResult } from \"css-styled\";\nimport { Properties } from \"framework-utils\";\nimport { isObject, camelize, IObject, addEvent, removeEvent } from \"@daybrush/utils\";\nimport ChildrenDiffer, { diff, ChildrenDiffResult } from \"@egjs/children-differ\";\nimport DragScroll from \"@scena/dragscroll\";\nimport KeyController, { getCombi } from \"keycon\";\nimport { createElement, h, getClient, diffValue, getRect } from \"./utils\";\nimport { SelectoOptions, Rect, SelectoProperties, OnDragEvent, SelectoEvents } from \"./types\";\nimport { PROPERTIES, injector, CLASS_NAME } from \"./consts\";\n/**\n * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.\n * @sort 1\n * @extends eg.Component\n */\n@Properties(PROPERTIES as any, (prototype, property) => {\n const attributes: IObject = {\n enumerable: true,\n configurable: true,\n get() {\n return this.options[property];\n },\n };\n const setter = camelize(`set ${property}`);\n if (prototype[setter]) {\n attributes.set = function(value) {\n this[setter](value);\n };\n } else {\n attributes.set = function(value) {\n this.options[property] = value;\n };\n }\n Object.defineProperty(prototype, property, attributes);\n})\nclass Selecto extends Component {\n public options: SelectoOptions;\n private target!: HTMLElement | SVGElement;\n private dragContainer!: Element | Window | Element[];\n private container!: HTMLElement;\n private dragger!: Dragger;\n private injectResult!: InjectResult;\n private selectedTargets: Array = [];\n private differ = new ChildrenDiffer();\n private dragScroll: DragScroll = new DragScroll();\n private keycon!: KeyController;\n /**\n *\n */\n constructor(\n options: Partial = {},\n ) {\n super();\n this.target = options.target;\n this.container = options.container;\n this.options = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: [],\n selectByClick: true,\n selectFromInside: true,\n hitRate: 100,\n continueSelect: false,\n toggleContinueSelect: null,\n keyContainer: null,\n scrollOptions: undefined,\n checkInput: false,\n preventDefault: false,\n ...options,\n };\n this.initElement();\n this.initDragScroll();\n this.setKeyController();\n }\n /**\n * You can set the currently selected targets.\n */\n public setSelectedTargets(selectedTargets: Array): this {\n this.selectedTargets = selectedTargets;\n this.differ = new ChildrenDiffer(selectedTargets);\n\n return this;\n }\n\n public setKeyContainer(keyContainer: HTMLElement | Document | Window) {\n const options = this.options;\n\n diffValue(options.keyContainer, keyContainer, () => {\n options.keyContainer = keyContainer;\n\n this.setKeyController();\n });\n }\n public setToggleContinueSelect(toggleContinueSelect: string[] | string) {\n const options = this.options;\n\n diffValue(options.toggleContinueSelect, toggleContinueSelect, () => {\n options.toggleContinueSelect = toggleContinueSelect;\n\n this.setKeyEvent();\n });\n }\n public setPreventDefault(value: boolean) {\n this.dragger.options.preventDefault = value;\n }\n public setCheckInput(value: boolean) {\n this.dragger.options.checkInput = value;\n }\n /**\n * `OnDragStart` is triggered by an external event.\n * @param - external event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto();\n *\n * window.addEventListener(\"mousedown\", e => {\n * selecto.triggerDragStart(e);\n * });\n */\n public triggerDragStart(e: MouseEvent | TouchEvent) {\n this.dragger.onDragStart(e);\n return this;\n }\n /**\n * Destroy elements, properties, and events.\n */\n public destroy(): void {\n this.off();\n this.keycon && this.keycon.destroy();\n this.dragger.unset();\n this.injectResult.destroy();\n removeEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.keycon = null;\n this.dragger = null;\n this.injectResult = null;\n this.target = null;\n this.container = null;\n this.options = null;\n }\n\n /**\n * External click or mouse events can be applied to the selecto.\n * @params - Extenal click or mouse event\n * @params - Specify the clicked target directly.\n */\n public clickTarget(e: MouseEvent | TouchEvent, clickedTarget?: Element): this {\n const { clientX, clientY } = getClient(e);\n const dragEvent: OnDragEvent = {\n datas: {},\n clientX,\n clientY,\n inputEvent: e,\n };\n if (this.onDragStart(dragEvent, clickedTarget)) {\n this.onDragEnd(dragEvent);\n }\n return this;\n }\n private setKeyController() {\n const { keyContainer, toggleContinueSelect } = this.options;\n\n if (this.keycon) {\n this.keycon.destroy();\n this.keycon = null;\n }\n if (toggleContinueSelect) {\n this.keycon = new KeyController(keyContainer || window);\n this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on(\"blur\", this.onBlur);\n }\n }\n private setKeyEvent() {\n const { toggleContinueSelect } = this.options;\n if (!toggleContinueSelect || this.keycon) {\n return;\n }\n this.setKeyController();\n }\n private initElement() {\n this.target = createElement(\n
as any,\n this.target,\n this.container,\n );\n\n const target = this.target;\n\n const { dragContainer, checkInput, preventDefault } = this.options;\n this.dragContainer = typeof dragContainer === \"string\"\n ? [].slice.call(document.querySelectorAll(dragContainer))\n : (this.options.dragContainer || this.target.parentNode as any);\n this.dragger = new Dragger(this.dragContainer, {\n container: window,\n checkInput,\n preventDefault,\n dragstart: this.onDragStart,\n drag: this.onDrag,\n dragend: this.onDragEnd,\n });\n addEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.injectResult = injector.inject(target);\n }\n private hitTest(\n selectRect: Rect,\n clientX: number,\n clientY: number,\n targets: Array,\n rects: Rect[],\n ) {\n const { hitRate, selectByClick } = this.options;\n const { left, top, right, bottom } = selectRect;\n const passedTargets: Array = [];\n\n rects.forEach((rect, i) => {\n const {\n left: rectLeft,\n top: rectTop,\n right: rectRight,\n bottom: rectBottom,\n } = rect;\n const isStart\n = rectLeft <= clientX\n && clientX <= rectRight\n && rectTop <= clientY\n && clientY <= rectBottom;\n const rectSize = (rectRight - rectLeft) * (rectBottom - rectTop);\n const testLeft = Math.max(rectLeft, left);\n const testRight = Math.min(rectRight, right);\n const testTop = Math.max(rectTop, top);\n const testBottom = Math.min(rectBottom, bottom);\n\n if (selectByClick && isStart) {\n passedTargets.push(targets[i]);\n return;\n }\n if (testRight < testLeft || testBottom < testTop) {\n return;\n }\n const rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100);\n\n if (rate >= hitRate) {\n passedTargets.push(targets[i]);\n }\n });\n\n return passedTargets;\n }\n private initDragScroll() {\n this.dragScroll.on(\"scroll\", ({ container, direction }) => {\n this.trigger(\"scroll\", {\n container,\n direction,\n });\n }).on(\"move\", ({ offsetX, offsetY, inputEvent }) => {\n const datas = inputEvent.datas;\n datas.startX -= offsetX;\n datas.startY -= offsetY;\n datas.selectableRects.forEach(rect => {\n rect.top -= offsetY;\n rect.bottom -= offsetY;\n rect.left -= offsetX;\n rect.right -= offsetX;\n });\n this.dragger.scrollBy(offsetX, offsetY, inputEvent.inputEvent, false);\n\n inputEvent.distX += offsetX;\n inputEvent.distY += offsetY;\n this.check(inputEvent);\n });\n }\n private getSelectableTargets() {\n const selectableTargets: Array = [];\n\n this.options.selectableTargets.forEach(target => {\n if (isObject(target)) {\n selectableTargets.push(target);\n } else {\n const elements = [].slice.call(document.querySelectorAll(target));\n\n elements.forEach(el => {\n selectableTargets.push(el);\n });\n }\n });\n\n return selectableTargets;\n }\n private getSelectedTargets(passedTargets: Array) {\n const {\n list,\n prevList,\n added,\n removed,\n } = diff(this.selectedTargets, passedTargets) as ChildrenDiffResult;\n\n return added.map(index => list[index]).concat(removed.map(index => prevList[index]));\n }\n private select(\n selectedTargets: Array, rect: Rect, inputEvent: any, isStart?: boolean) {\n const {\n added,\n removed,\n prevList,\n list,\n } = this.differ.update(selectedTargets);\n\n if (isStart) {\n /**\n * When the select(drag) starts, the selectStart event is called.\n * @memberof Selecto\n * @event selectStart\n * @param {Selecto.OnSelect} - Parameters for the selectStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectStart\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n if (added.length || removed.length) {\n /**\n * When the select in real time, the select event is called.\n * @memberof Selecto\n * @event select\n * @param {Selecto.OnSelect} - Parameters for the select event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"select\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n }\n private selectEnd(\n startSelectedTargets: Array,\n selectedTargets: Array,\n rect: Rect,\n e: OnDragEvent,\n ) {\n const { inputEvent, isDouble } = e;\n const {\n added,\n removed,\n prevList,\n list,\n } = diff(startSelectedTargets, selectedTargets);\n const {\n added: afterAdded,\n removed: afterRemoved,\n prevList: afterPrevList,\n list: afterList,\n } = diff(this.selectedTargets, selectedTargets);\n const type = inputEvent.type;\n const isDragStart = type === \"mousedown\" || type === \"touchstart\";\n\n /**\n * When the select(dragEnd or click) ends, the selectEnd event is called.\n * @memberof Selecto\n * @event selectEnd\n * @param {Selecto.OnSelectEnd} - Parameters for the selectEnd event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectEnd\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n afterAdded: afterAdded.map(index => afterList[index]),\n afterRemoved: afterRemoved.map(index => afterPrevList[index]),\n isDragStart,\n isDouble: !!isDouble,\n rect,\n inputEvent,\n });\n }\n private onDragStart = (e: OnDragEvent, clickedTarget?: Element) => {\n const { datas, clientX, clientY, inputEvent } = e;\n const { continueSelect, selectFromInside, selectByClick } = this.options;\n const selectableTargets = this.getSelectableTargets();\n const selectableRects = selectableTargets.map(target => {\n const rect = target.getBoundingClientRect();\n const { left, top, width, height } = rect;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n });\n datas.selectableTargets = selectableTargets;\n datas.selectableRects = selectableRects;\n datas.startSelectedTargets = this.selectedTargets;\n\n const pointTarget = clickedTarget || document.elementFromPoint(clientX, clientY);\n const hitRect = {\n left: clientX,\n top: clientY,\n right: clientX,\n bottom: clientY,\n width: 0,\n height: 0,\n };\n let firstPassedTargets = this.hitTest(\n hitRect, clientX, clientY, selectableTargets, selectableRects).filter(\n target => target === pointTarget || target.contains(pointTarget),\n );\n\n const hasInsideTargets = firstPassedTargets.length > 0;\n const isPreventSelect = !selectFromInside && hasInsideTargets;\n\n if (isPreventSelect && !selectByClick) {\n return false;\n }\n if (!continueSelect) {\n this.selectedTargets = [];\n } else {\n firstPassedTargets = this.getSelectedTargets(firstPassedTargets);\n }\n const type = inputEvent.type;\n const isTrusted = type === \"mousedown\" || type === \"touchstart\";\n /**\n * When the drag starts, the dragStart event is called.\n * Call the stop () function if you have a specific element or don't want to raise a select\n * @memberof Selecto\n * @event dragStart\n * @param {OnDragStart} - Parameters for the dragStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"dragStart\", e => {\n * if (e.inputEvent.target.tagName === \"SPAN\") {\n * e.stop();\n * }\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n const result = isTrusted ? this.trigger(\"dragStart\", e) : true;\n\n if (!result) {\n return false;\n }\n this.select(firstPassedTargets, hitRect, inputEvent, true);\n datas.startX = clientX;\n datas.startY = clientY;\n datas.selectedTargets = firstPassedTargets;\n this.target.style.cssText\n += `left:0px;top:0px;transform: translate(${clientX}px, ${clientY}px)`;\n\n if (isPreventSelect && selectByClick) {\n this.onDragEnd(e);\n inputEvent.preventDefault();\n return false;\n } else {\n if (type === \"touchstart\") {\n inputEvent.preventDefault();\n }\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n this.dragScroll.dragStart(e, scrollOptions);\n }\n return true;\n }\n }\n private check(e: any) {\n const {\n datas,\n inputEvent,\n } = e;\n const rect = getRect(e);\n const {\n top,\n left,\n width,\n height,\n } = rect;\n this.target.style.cssText\n += `display: block;`\n + `left:0px;top:0px;`\n + `transform: translate(${left}px, ${top}px);`\n + `width:${width}px;height:${height}px;`;\n\n const passedTargets = this.hitTest(\n rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectableRects);\n const selectedTargets = this.getSelectedTargets(passedTargets);\n\n this.select(selectedTargets, rect, inputEvent);\n datas.selectedTargets = selectedTargets;\n }\n private onDrag = (e: OnDrag) => {\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n if (this.dragScroll.drag(e, scrollOptions)) {\n return;\n }\n }\n this.check(e);\n }\n private onDragEnd = (e: OnDragEvent) => {\n const { datas } = e;\n this.dragScroll.dragEnd();\n this.target.style.cssText += \"display: none;\";\n this.selectEnd(\n datas.startSelectedTargets, datas.selectedTargets, getRect(e), e);\n this.selectedTargets = datas.selectedTargets;\n }\n private sameCombiKey(e: any) {\n const toggleContinueSelect = [].concat(this.options.toggleContinueSelect);\n const combi = getCombi(e.inputEvent, e.key);\n return toggleContinueSelect.every(key => combi.indexOf(key) > -1);\n }\n private onKeyDown = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = true;\n /**\n * When you keydown the key you specified in toggleContinueSelect, the keydown event is called.\n * @memberof Selecto\n * @event keydown\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keydown\", {});\n }\n private onKeyUp = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = false;\n /**\n * When you keyup the key you specified in toggleContinueSelect, the keyup event is called.\n * @memberof Selecto\n * @event keyup\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keyup\", {});\n }\n private onBlur = () => {\n if (this.toggleContinueSelect && this.continueSelect) {\n this.trigger(\"keyup\", {});\n }\n }\n private onDocumentSelectStart = (e: any) => {\n if (!this.dragger.isFlag()) {\n return;\n }\n let dragContainer = this.dragContainer;\n\n if (dragContainer === window) {\n dragContainer = document.documentElement;\n }\n const containers = dragContainer instanceof Element\n ? [dragContainer] : [].slice.call(dragContainer) as Element[];\n const target = e.target;\n\n containers.some(container => {\n if (container === target || container.contains(target)) {\n e.preventDefault();\n return true;\n }\n });\n }\n}\n\ninterface Selecto extends Component, SelectoProperties {\n on(eventName: T, handlerToAttach: (event: SelectoEvents[T]) => any): this;\n on(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): this;\n on(events: { [key: string]: (event: { [key: string]: any }) => any }): this;\n}\n\nexport default Selecto;\n","import Selecto, * as modules from \"./index\";\n\nfor (const name in modules) {\n (Selecto as any)[name] = modules[name];\n}\n\nexport default Selecto;\n"],"names":["getClient","e","touch","touches","changedTouches","clientX","clientY","createElement","jsx","prevTarget","container","tag","children","attributes","className","style","el","document","name","setAttribute","elChildren","forEach","child","i","split","hasClass","addClass","elStyle","appendChild","h","attrs","_i","_a","_b","_c","diffValue","prev","cur","func","getRect","distX","distY","datas","startX","startY","tx","Math","min","ty","width","abs","height","left","top","right","bottom","injector","styled","CLASS_NAME","PROPERTIES","OPTIONS","__spreadArrays","OPTION_TYPES","target","dragContainer","selectableTargets","Array","selectByClick","Boolean","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","Number","scrollOptions","Object","checkInput","preventDefault","EVENTS","METHODS","__extends","options","_super","_this","ChildrenDiffer","DragScroll","clickedTarget","inputEvent","getSelectableTargets","selectableRects","map","rect","getBoundingClientRect","startSelectedTargets","selectedTargets","pointTarget","elementFromPoint","hitRect","firstPassedTargets","hitTest","filter","contains","hasInsideTargets","length","isPreventSelect","getSelectedTargets","type","isTrusted","result","trigger","select","cssText","onDragEnd","dragScroll","dragStart","drag","check","dragEnd","selectEnd","sameCombiKey","dragger","isFlag","window","documentElement","containers","Element","slice","call","some","undefined","initElement","initDragScroll","setKeyController","differ","setKeyEvent","value","onDragStart","off","keycon","destroy","unset","injectResult","removeEvent","onDocumentSelectStart","dragEvent","KeyController","keydown","onKeyDown","keyup","onKeyUp","on","onBlur","querySelectorAll","parentNode","Dragger","dragstart","onDrag","dragend","addEvent","inject","selectRect","targets","rects","passedTargets","rectLeft","rectTop","rectRight","rectBottom","isStart","rectSize","testLeft","max","testRight","testTop","testBottom","push","rate","round","direction","offsetX","offsetY","scrollBy","isObject","elements","list","prevList","added","removed","index","concat","selected","isDouble","afterAdded","afterRemoved","afterPrevList","afterList","isDragStart","combi","getCombi","key","every","indexOf","Selecto","Properties","prototype","property","enumerable","configurable","get","setter","camelize","set","defineProperty","Component","modules"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAGgBA,UAAUC;MAClB,aAAaA,CAAjB,EAAoB;QACVC,KAAK,GAAGD,CAAC,CAACE,OAAF,CAAU,CAAV,KAAgBF,CAAC,CAACG,cAAF,CAAiB,CAAjB,CAA9B;WAEO;MACHC,OAAO,EAAEH,KAAK,CAACG,OADZ;MAEHC,OAAO,EAAEJ,KAAK,CAACI;KAFnB;GAHJ,MAOO;WACI;MACHD,OAAO,EAAEJ,CAAC,CAACI,OADR;MAEHC,OA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GAAX,GAAiB,UAAS5E,KAAT;aACRtD,OAAL,CAAa4H,QAAb,IAAyBtE,KAAzB;OADJ;;;IAIJ5D,MAAM,CAACyI,cAAP,CAAsBR,SAAtB,EAAiCC,QAAjC,EAA2CjM,UAA3C;GAlBO,IAoBL8L,QAAA;gBA2oBN;EA3oBsBW,UAAtB;;;;;;;;;;;;;;;AClCA,KAAK,IAAMpM,IAAX,IAAmBqM,OAAnB,EAA4B;EACvBZ,OAAe,CAACzL,IAAD,CAAf,GAAwBqM,OAAO,CAACrM,IAAD,CAA/B;;;;;"} \ No newline at end of file diff --git a/dist/selecto.esm.js b/dist/selecto.esm.js new file mode 100644 index 0000000..59f4230 --- /dev/null +++ b/dist/selecto.esm.js @@ -0,0 +1,995 @@ +/* +Copyright (c) 2020 Daybrush +name: selecto +license: MIT +author: Daybrush +repository: git+https://github.com/daybrush/selecto.git +version: 1.3.0 +*/ +import Component from '@egjs/component'; +import Dragger from '@daybrush/drag'; +import { Properties } from 'framework-utils'; +import { hasClass, addClass, removeEvent, addEvent, isObject, camelize } from '@daybrush/utils'; +import ChildrenDiffer, { diff } from '@egjs/children-differ'; +import DragScroll from '@scena/dragscroll'; +import KeyController, { getCombi } from 'keycon'; +import styled from 'css-styled'; + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/* global Reflect, Promise */ +var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + + return extendStatics(d, b); +}; + +function __extends(d, b) { + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} +var __assign = function () { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign.apply(this, arguments); +}; +function __rest(s, e) { + var t = {}; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + + if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; + } + return t; +} +function __decorate(decorators, target, key, desc) { + var c = arguments.length, + r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, + d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + + for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; + + return r; +} + +function getClient(e) { + if ("touches" in e) { + var touch = e.touches[0] || e.changedTouches[0]; + return { + clientX: touch.clientX, + clientY: touch.clientY + }; + } else { + return { + clientX: e.clientX, + clientY: e.clientY + }; + } +} +function createElement(jsx, prevTarget, container) { + var tag = jsx.tag, + children = jsx.children, + attributes = jsx.attributes, + className = jsx.className, + style = jsx.style; + var el = prevTarget || document.createElement(tag); + + for (var name in attributes) { + el.setAttribute(name, attributes[name]); + } + + var elChildren = el.children; + children.forEach(function (child, i) { + createElement(child, elChildren[i], el); + }); + + if (className) { + className.split(" ").forEach(function (name) { + if (!hasClass(el, name)) { + addClass(el, name); + } + }); + } + + if (style) { + var elStyle = el.style; + + for (var name in style) { + elStyle[name] = style[name]; + } + } + + if (!prevTarget && container) { + container.appendChild(el); + } + + return el; +} +function h(tag, attrs) { + var children = []; + + for (var _i = 2; _i < arguments.length; _i++) { + children[_i - 2] = arguments[_i]; + } + + var _a = attrs || {}, + _b = _a.className, + className = _b === void 0 ? "" : _b, + _c = _a.style, + style = _c === void 0 ? {} : _c, + attributes = __rest(_a, ["className", "style"]); + + return { + tag: tag, + className: className, + style: style, + attributes: attributes, + children: children + }; +} +function diffValue(prev, cur, func) { + if (prev !== cur) { + func(prev, cur); + } +} +function getRect(e) { + var _a = e.distX, + distX = _a === void 0 ? 0 : _a, + _b = e.distY, + distY = _b === void 0 ? 0 : _b, + datas = e.datas; + var startX = datas.startX, + startY = datas.startY; + var tx = Math.min(0, distX); + var ty = Math.min(0, distY); + var width = Math.abs(distX); + var height = Math.abs(distY); + var left = startX + tx; + var top = startY + ty; + return { + left: left, + top: top, + right: left + width, + bottom: top + height, + width: width, + height: height + }; +} + +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"); +/** + * @memberof Selecto + */ + +var CLASS_NAME = "selecto-selection " + injector.className; +var PROPERTIES = ["selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault"]; +/** + * @memberof Selecto + */ + +var OPTIONS = __spreadArrays([// ignore target, container, +"dragContainer"], PROPERTIES); +var OPTION_TYPES = { + 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 +}; +/** + * @memberof Selecto + */ + +var EVENTS = ["dragStart", "selectStart", "select", "selectEnd", "keydown", "keyup", "scroll"]; +/** + * @memberof Selecto + */ + +var METHODS = ["clickTarget", "setSelectedTargets", "triggerDragStart"]; + +/** + * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch. + * @sort 1 + * @extends eg.Component + */ + +var Selecto = +/*#__PURE__*/ +function (_super) { + __extends(Selecto, _super); + /** + * + */ + + + function Selecto(options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.selectedTargets = []; + _this.differ = new ChildrenDiffer(); + _this.dragScroll = new DragScroll(); + + _this.onDragStart = function (e, clickedTarget) { + var datas = e.datas, + clientX = e.clientX, + clientY = e.clientY, + inputEvent = e.inputEvent; + var _a = _this.options, + continueSelect = _a.continueSelect, + selectFromInside = _a.selectFromInside, + selectByClick = _a.selectByClick; + + var selectableTargets = _this.getSelectableTargets(); + + var selectableRects = selectableTargets.map(function (target) { + var rect = target.getBoundingClientRect(); + var left = rect.left, + top = rect.top, + width = rect.width, + height = rect.height; + return { + left: left, + top: top, + right: left + width, + bottom: top + height, + width: width, + height: height + }; + }); + datas.selectableTargets = selectableTargets; + datas.selectableRects = selectableRects; + datas.startSelectedTargets = _this.selectedTargets; + var pointTarget = clickedTarget || document.elementFromPoint(clientX, clientY); + var hitRect = { + left: clientX, + top: clientY, + right: clientX, + bottom: clientY, + width: 0, + height: 0 + }; + + var firstPassedTargets = _this.hitTest(hitRect, clientX, clientY, selectableTargets, selectableRects).filter(function (target) { + return target === pointTarget || target.contains(pointTarget); + }); + + var hasInsideTargets = firstPassedTargets.length > 0; + var isPreventSelect = !selectFromInside && hasInsideTargets; + + if (isPreventSelect && !selectByClick) { + return false; + } + + if (!continueSelect) { + _this.selectedTargets = []; + } else { + firstPassedTargets = _this.getSelectedTargets(firstPassedTargets); + } + + var type = inputEvent.type; + var isTrusted = type === "mousedown" || type === "touchstart"; + /** + * When the drag starts, the dragStart event is called. + * Call the stop () function if you have a specific element or don't want to raise a select + * @memberof Selecto + * @event dragStart + * @param {OnDragStart} - Parameters for the dragStart event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("dragStart", e => { + * if (e.inputEvent.target.tagName === "SPAN") { + * e.stop(); + * } + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + var result = isTrusted ? _this.trigger("dragStart", e) : true; + + if (!result) { + return false; + } + + _this.select(firstPassedTargets, hitRect, inputEvent, true); + + datas.startX = clientX; + datas.startY = clientY; + datas.selectedTargets = firstPassedTargets; + _this.target.style.cssText += "left:0px;top:0px;transform: translate(" + clientX + "px, " + clientY + "px)"; + + if (isPreventSelect && selectByClick) { + _this.onDragEnd(e); + + inputEvent.preventDefault(); + return false; + } else { + if (type === "touchstart") { + inputEvent.preventDefault(); + } + + var scrollOptions = _this.options.scrollOptions; + + if (scrollOptions && scrollOptions.container) { + _this.dragScroll.dragStart(e, scrollOptions); + } + + return true; + } + }; + + _this.onDrag = function (e) { + var scrollOptions = _this.options.scrollOptions; + + if (scrollOptions && scrollOptions.container) { + if (_this.dragScroll.drag(e, scrollOptions)) { + return; + } + } + + _this.check(e); + }; + + _this.onDragEnd = function (e) { + var datas = e.datas; + + _this.dragScroll.dragEnd(); + + _this.target.style.cssText += "display: none;"; + + _this.selectEnd(datas.startSelectedTargets, datas.selectedTargets, getRect(e), e); + + _this.selectedTargets = datas.selectedTargets; + }; + + _this.onKeyDown = function (e) { + if (!_this.sameCombiKey(e)) { + return; + } + + _this.continueSelect = true; + /** + * When you keydown the key you specified in toggleContinueSelect, the keydown event is called. + * @memberof Selecto + * @event keydown + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * toggleContinueSelect: "shift"; + * keyContainer: window, + * }); + * + * selecto.on("keydown", () => { + * document.querySelector(".button").classList.add("selected"); + * }).on("keyup", () => { + * document.querySelector(".button").classList.remove("selected"); + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + _this.trigger("keydown", {}); + }; + + _this.onKeyUp = function (e) { + if (!_this.sameCombiKey(e)) { + return; + } + + _this.continueSelect = false; + /** + * When you keyup the key you specified in toggleContinueSelect, the keyup event is called. + * @memberof Selecto + * @event keyup + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * toggleContinueSelect: "shift"; + * keyContainer: window, + * }); + * + * selecto.on("keydown", () => { + * document.querySelector(".button").classList.add("selected"); + * }).on("keyup", () => { + * document.querySelector(".button").classList.remove("selected"); + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + _this.trigger("keyup", {}); + }; + + _this.onBlur = function () { + if (_this.toggleContinueSelect && _this.continueSelect) { + _this.trigger("keyup", {}); + } + }; + + _this.onDocumentSelectStart = function (e) { + if (!_this.dragger.isFlag()) { + return; + } + + var dragContainer = _this.dragContainer; + + if (dragContainer === window) { + dragContainer = document.documentElement; + } + + var containers = dragContainer instanceof Element ? [dragContainer] : [].slice.call(dragContainer); + var target = e.target; + containers.some(function (container) { + if (container === target || container.contains(target)) { + e.preventDefault(); + return true; + } + }); + }; + + _this.target = options.target; + _this.container = options.container; + _this.options = __assign({ + target: null, + container: null, + dragContainer: null, + selectableTargets: [], + selectByClick: true, + selectFromInside: true, + hitRate: 100, + continueSelect: false, + toggleContinueSelect: null, + keyContainer: null, + scrollOptions: undefined, + checkInput: false, + preventDefault: false + }, options); + + _this.initElement(); + + _this.initDragScroll(); + + _this.setKeyController(); + + return _this; + } + /** + * You can set the currently selected targets. + */ + + + var __proto = Selecto.prototype; + + __proto.setSelectedTargets = function (selectedTargets) { + this.selectedTargets = selectedTargets; + this.differ = new ChildrenDiffer(selectedTargets); + return this; + }; + + __proto.setKeyContainer = function (keyContainer) { + var _this = this; + + var options = this.options; + diffValue(options.keyContainer, keyContainer, function () { + options.keyContainer = keyContainer; + + _this.setKeyController(); + }); + }; + + __proto.setToggleContinueSelect = function (toggleContinueSelect) { + var _this = this; + + var options = this.options; + diffValue(options.toggleContinueSelect, toggleContinueSelect, function () { + options.toggleContinueSelect = toggleContinueSelect; + + _this.setKeyEvent(); + }); + }; + + __proto.setPreventDefault = function (value) { + this.dragger.options.preventDefault = value; + }; + + __proto.setCheckInput = function (value) { + this.dragger.options.checkInput = value; + }; + /** + * `OnDragStart` is triggered by an external event. + * @param - external event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto(); + * + * window.addEventListener("mousedown", e => { + * selecto.triggerDragStart(e); + * }); + */ + + + __proto.triggerDragStart = function (e) { + this.dragger.onDragStart(e); + return this; + }; + /** + * Destroy elements, properties, and events. + */ + + + __proto.destroy = function () { + this.off(); + this.keycon && this.keycon.destroy(); + this.dragger.unset(); + this.injectResult.destroy(); + removeEvent(document, "selectstart", this.onDocumentSelectStart); + this.keycon = null; + this.dragger = null; + this.injectResult = null; + this.target = null; + this.container = null; + this.options = null; + }; + /** + * External click or mouse events can be applied to the selecto. + * @params - Extenal click or mouse event + * @params - Specify the clicked target directly. + */ + + + __proto.clickTarget = function (e, clickedTarget) { + var _a = getClient(e), + clientX = _a.clientX, + clientY = _a.clientY; + + var dragEvent = { + datas: {}, + clientX: clientX, + clientY: clientY, + inputEvent: e + }; + + if (this.onDragStart(dragEvent, clickedTarget)) { + this.onDragEnd(dragEvent); + } + + return this; + }; + + __proto.setKeyController = function () { + var _a = this.options, + keyContainer = _a.keyContainer, + toggleContinueSelect = _a.toggleContinueSelect; + + if (this.keycon) { + this.keycon.destroy(); + this.keycon = null; + } + + if (toggleContinueSelect) { + this.keycon = new KeyController(keyContainer || window); + this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on("blur", this.onBlur); + } + }; + + __proto.setKeyEvent = function () { + var toggleContinueSelect = this.options.toggleContinueSelect; + + if (!toggleContinueSelect || this.keycon) { + return; + } + + this.setKeyController(); + }; + + __proto.initElement = function () { + this.target = createElement(h("div", { + className: CLASS_NAME + }), this.target, this.container); + var target = this.target; + var _a = this.options, + dragContainer = _a.dragContainer, + checkInput = _a.checkInput, + preventDefault = _a.preventDefault; + this.dragContainer = typeof dragContainer === "string" ? [].slice.call(document.querySelectorAll(dragContainer)) : this.options.dragContainer || this.target.parentNode; + this.dragger = new Dragger(this.dragContainer, { + container: window, + checkInput: checkInput, + preventDefault: preventDefault, + dragstart: this.onDragStart, + drag: this.onDrag, + dragend: this.onDragEnd + }); + addEvent(document, "selectstart", this.onDocumentSelectStart); + this.injectResult = injector.inject(target); + }; + + __proto.hitTest = function (selectRect, clientX, clientY, targets, rects) { + var _a = this.options, + hitRate = _a.hitRate, + selectByClick = _a.selectByClick; + var left = selectRect.left, + top = selectRect.top, + right = selectRect.right, + bottom = selectRect.bottom; + var passedTargets = []; + rects.forEach(function (rect, i) { + var rectLeft = rect.left, + rectTop = rect.top, + rectRight = rect.right, + rectBottom = rect.bottom; + 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) { + passedTargets.push(targets[i]); + return; + } + + if (testRight < testLeft || testBottom < testTop) { + return; + } + + var rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100); + + if (rate >= hitRate) { + passedTargets.push(targets[i]); + } + }); + return passedTargets; + }; + + __proto.initDragScroll = function () { + var _this = this; + + this.dragScroll.on("scroll", function (_a) { + var container = _a.container, + direction = _a.direction; + + _this.trigger("scroll", { + container: container, + direction: direction + }); + }).on("move", function (_a) { + var offsetX = _a.offsetX, + offsetY = _a.offsetY, + inputEvent = _a.inputEvent; + var datas = inputEvent.datas; + datas.startX -= offsetX; + datas.startY -= offsetY; + datas.selectableRects.forEach(function (rect) { + rect.top -= offsetY; + rect.bottom -= offsetY; + rect.left -= offsetX; + rect.right -= offsetX; + }); + + _this.dragger.scrollBy(offsetX, offsetY, inputEvent.inputEvent, false); + + inputEvent.distX += offsetX; + inputEvent.distY += offsetY; + + _this.check(inputEvent); + }); + }; + + __proto.getSelectableTargets = function () { + var selectableTargets = []; + this.options.selectableTargets.forEach(function (target) { + if (isObject(target)) { + selectableTargets.push(target); + } else { + var elements = [].slice.call(document.querySelectorAll(target)); + elements.forEach(function (el) { + selectableTargets.push(el); + }); + } + }); + return selectableTargets; + }; + + __proto.getSelectedTargets = function (passedTargets) { + var _a = diff(this.selectedTargets, passedTargets), + 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]; + })); + }; + + __proto.select = function (selectedTargets, rect, inputEvent, isStart) { + var _a = this.differ.update(selectedTargets), + added = _a.added, + removed = _a.removed, + prevList = _a.prevList, + list = _a.list; + + if (isStart) { + /** + * When the select(drag) starts, the selectStart event is called. + * @memberof Selecto + * @event selectStart + * @param {Selecto.OnSelect} - Parameters for the selectStart event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("selectStart", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }).on("selectEnd", e => { + * e.afterAdded.forEach(el => { + * el.classList.add("selected"); + * }); + * e.afterRemoved.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + this.trigger("selectStart", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + rect: rect, + inputEvent: inputEvent + }); + } + + if (added.length || removed.length) { + /** + * When the select in real time, the select event is called. + * @memberof Selecto + * @event select + * @param {Selecto.OnSelect} - Parameters for the select event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + this.trigger("select", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + rect: rect, + inputEvent: inputEvent + }); + } + }; + + __proto.selectEnd = function (startSelectedTargets, selectedTargets, rect, e) { + var inputEvent = e.inputEvent, + isDouble = e.isDouble; + + var _a = diff(startSelectedTargets, selectedTargets), + added = _a.added, + removed = _a.removed, + prevList = _a.prevList, + list = _a.list; + + var _b = diff(this.selectedTargets, selectedTargets), + afterAdded = _b.added, + afterRemoved = _b.removed, + afterPrevList = _b.prevList, + afterList = _b.list; + + var type = inputEvent.type; + var isDragStart = type === "mousedown" || type === "touchstart"; + /** + * When the select(dragEnd or click) ends, the selectEnd event is called. + * @memberof Selecto + * @event selectEnd + * @param {Selecto.OnSelectEnd} - Parameters for the selectEnd event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("selectStart", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }).on("selectEnd", e => { + * e.afterAdded.forEach(el => { + * el.classList.add("selected"); + * }); + * e.afterRemoved.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + this.trigger("selectEnd", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + afterAdded: afterAdded.map(function (index) { + return afterList[index]; + }), + afterRemoved: afterRemoved.map(function (index) { + return afterPrevList[index]; + }), + isDragStart: isDragStart, + isDouble: !!isDouble, + rect: rect, + inputEvent: inputEvent + }); + }; + + __proto.check = function (e) { + var datas = e.datas, + inputEvent = e.inputEvent; + var rect = getRect(e); + var top = rect.top, + left = rect.left, + width = rect.width, + 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.selectableRects); + var selectedTargets = this.getSelectedTargets(passedTargets); + this.select(selectedTargets, rect, inputEvent); + datas.selectedTargets = selectedTargets; + }; + + __proto.sameCombiKey = function (e) { + var toggleContinueSelect = [].concat(this.options.toggleContinueSelect); + var combi = getCombi(e.inputEvent, e.key); + return toggleContinueSelect.every(function (key) { + return combi.indexOf(key) > -1; + }); + }; + + Selecto = __decorate([Properties(PROPERTIES, function (prototype, property) { + var attributes = { + enumerable: true, + configurable: true, + get: function () { + return this.options[property]; + } + }; + var setter = camelize("set " + property); + + if (prototype[setter]) { + attributes.set = function (value) { + this[setter](value); + }; + } else { + attributes.set = function (value) { + this.options[property] = value; + }; + } + + Object.defineProperty(prototype, property, attributes); + })], Selecto); + return Selecto; +}(Component); + +export default Selecto; +export { CLASS_NAME, EVENTS, METHODS, OPTIONS, OPTION_TYPES, PROPERTIES }; +//# sourceMappingURL=selecto.esm.js.map diff --git a/dist/selecto.esm.js.map b/dist/selecto.esm.js.map new file mode 100644 index 0000000..647926e --- /dev/null +++ b/dist/selecto.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"selecto.esm.js","sources":["../src/utils.ts","../src/consts.ts","../src/Selecto.tsx"],"sourcesContent":["import { Hypertext, Rect } from \"./types\";\nimport { IObject, addClass, hasClass } from \"@daybrush/utils\";\n\nexport function getClient(e: MouseEvent | TouchEvent) {\n if (\"touches\" in e) {\n const touch = e.touches[0] || e.changedTouches[0];\n\n return {\n clientX: touch.clientX,\n clientY: touch.clientY,\n };\n } else {\n return {\n clientX: e.clientX,\n clientY: e.clientY,\n };\n }\n}\n\nexport function createElement(\n jsx: Hypertext,\n prevTarget?: HTMLElement | SVGElement,\n container?: HTMLElement | SVGElement,\n) {\n const { tag, children, attributes, className, style } = jsx;\n const el = prevTarget || document.createElement(tag) as HTMLElement | SVGElement;\n\n for (const name in attributes) {\n el.setAttribute(name, attributes[name]);\n }\n const elChildren = el.children;\n children.forEach((child, i) => {\n createElement(child, elChildren[i] as HTMLElement | SVGElement, el);\n });\n if (className) {\n className.split(\" \").forEach(name => {\n if (!hasClass(el, name)) {\n addClass(el, name);\n }\n });\n }\n if (style) {\n const elStyle = el.style;\n for (const name in style) {\n elStyle[name] = style[name];\n }\n }\n if (!prevTarget && container) {\n container.appendChild(el);\n }\n return el;\n}\nexport function h(\n tag: string,\n attrs: IObject,\n ...children: Hypertext[]\n): Hypertext {\n const {\n className = \"\",\n style = {},\n ...attributes\n } = attrs || {};\n return {\n tag,\n className,\n style,\n attributes,\n children,\n };\n}\n\nexport function diffValue(prev: T, cur: T, func: (prev: T, cur: T) => void) {\n if (prev !== cur) {\n func(prev, cur);\n }\n}\n\nexport function getRect(e: any): Rect {\n const {\n distX = 0,\n distY = 0,\n datas,\n } = e;\n const { startX, startY } = datas;\n const tx = Math.min(0, distX);\n const ty = Math.min(0, distY);\n const width = Math.abs(distX);\n const height = Math.abs(distY);\n const left = startX + tx;\n const top = startY + ty;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n}\n","import styled from \"css-styled\";\nimport { SelectoOptions } from \"./types\";\n\nexport const 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`);\n\n/**\n * @memberof Selecto\n */\nexport const CLASS_NAME = `selecto-selection ${injector.className}`;\n\nexport const PROPERTIES = [\n \"selectableTargets\",\n \"selectByClick\",\n \"selectFromInside\",\n \"continueSelect\",\n \"toggleContinueSelect\",\n \"keyContainer\",\n \"hitRate\",\n \"scrollOptions\",\n \"checkInput\",\n \"preventDefault\",\n] as const;\n/**\n * @memberof Selecto\n */\nexport const OPTIONS = [\n // ignore target, container,\n \"dragContainer\",\n ...PROPERTIES,\n] as const;\n\nexport const OPTION_TYPES: { [key in keyof SelectoOptions]: any } = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: Array,\n selectByClick: Boolean,\n selectFromInside: Boolean,\n continueSelect: Boolean,\n toggleContinueSelect: Array,\n keyContainer: null,\n hitRate: Number,\n scrollOptions: Object,\n checkInput: Boolean,\n preventDefault: Boolean,\n};\n\n\n/**\n * @memberof Selecto\n */\nexport const EVENTS = [\n \"dragStart\",\n \"selectStart\",\n \"select\",\n \"selectEnd\",\n \"keydown\",\n \"keyup\",\n \"scroll\",\n] as const;\n\n/**\n * @memberof Selecto\n */\nexport const METHODS = [\n \"clickTarget\",\n \"setSelectedTargets\",\n \"triggerDragStart\",\n] as const;\n","import Component from \"@egjs/component\";\nimport Dragger, { OnDrag } from \"@daybrush/drag\";\nimport { InjectResult } from \"css-styled\";\nimport { Properties } from \"framework-utils\";\nimport { isObject, camelize, IObject, addEvent, removeEvent } from \"@daybrush/utils\";\nimport ChildrenDiffer, { diff, ChildrenDiffResult } from \"@egjs/children-differ\";\nimport DragScroll from \"@scena/dragscroll\";\nimport KeyController, { getCombi } from \"keycon\";\nimport { createElement, h, getClient, diffValue, getRect } from \"./utils\";\nimport { SelectoOptions, Rect, SelectoProperties, OnDragEvent, SelectoEvents } from \"./types\";\nimport { PROPERTIES, injector, CLASS_NAME } from \"./consts\";\n/**\n * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.\n * @sort 1\n * @extends eg.Component\n */\n@Properties(PROPERTIES as any, (prototype, property) => {\n const attributes: IObject = {\n enumerable: true,\n configurable: true,\n get() {\n return this.options[property];\n },\n };\n const setter = camelize(`set ${property}`);\n if (prototype[setter]) {\n attributes.set = function(value) {\n this[setter](value);\n };\n } else {\n attributes.set = function(value) {\n this.options[property] = value;\n };\n }\n Object.defineProperty(prototype, property, attributes);\n})\nclass Selecto extends Component {\n public options: SelectoOptions;\n private target!: HTMLElement | SVGElement;\n private dragContainer!: Element | Window | Element[];\n private container!: HTMLElement;\n private dragger!: Dragger;\n private injectResult!: InjectResult;\n private selectedTargets: Array = [];\n private differ = new ChildrenDiffer();\n private dragScroll: DragScroll = new DragScroll();\n private keycon!: KeyController;\n /**\n *\n */\n constructor(\n options: Partial = {},\n ) {\n super();\n this.target = options.target;\n this.container = options.container;\n this.options = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: [],\n selectByClick: true,\n selectFromInside: true,\n hitRate: 100,\n continueSelect: false,\n toggleContinueSelect: null,\n keyContainer: null,\n scrollOptions: undefined,\n checkInput: false,\n preventDefault: false,\n ...options,\n };\n this.initElement();\n this.initDragScroll();\n this.setKeyController();\n }\n /**\n * You can set the currently selected targets.\n */\n public setSelectedTargets(selectedTargets: Array): this {\n this.selectedTargets = selectedTargets;\n this.differ = new ChildrenDiffer(selectedTargets);\n\n return this;\n }\n\n public setKeyContainer(keyContainer: HTMLElement | Document | Window) {\n const options = this.options;\n\n diffValue(options.keyContainer, keyContainer, () => {\n options.keyContainer = keyContainer;\n\n this.setKeyController();\n });\n }\n public setToggleContinueSelect(toggleContinueSelect: string[] | string) {\n const options = this.options;\n\n diffValue(options.toggleContinueSelect, toggleContinueSelect, () => {\n options.toggleContinueSelect = toggleContinueSelect;\n\n this.setKeyEvent();\n });\n }\n public setPreventDefault(value: boolean) {\n this.dragger.options.preventDefault = value;\n }\n public setCheckInput(value: boolean) {\n this.dragger.options.checkInput = value;\n }\n /**\n * `OnDragStart` is triggered by an external event.\n * @param - external event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto();\n *\n * window.addEventListener(\"mousedown\", e => {\n * selecto.triggerDragStart(e);\n * });\n */\n public triggerDragStart(e: MouseEvent | TouchEvent) {\n this.dragger.onDragStart(e);\n return this;\n }\n /**\n * Destroy elements, properties, and events.\n */\n public destroy(): void {\n this.off();\n this.keycon && this.keycon.destroy();\n this.dragger.unset();\n this.injectResult.destroy();\n removeEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.keycon = null;\n this.dragger = null;\n this.injectResult = null;\n this.target = null;\n this.container = null;\n this.options = null;\n }\n\n /**\n * External click or mouse events can be applied to the selecto.\n * @params - Extenal click or mouse event\n * @params - Specify the clicked target directly.\n */\n public clickTarget(e: MouseEvent | TouchEvent, clickedTarget?: Element): this {\n const { clientX, clientY } = getClient(e);\n const dragEvent: OnDragEvent = {\n datas: {},\n clientX,\n clientY,\n inputEvent: e,\n };\n if (this.onDragStart(dragEvent, clickedTarget)) {\n this.onDragEnd(dragEvent);\n }\n return this;\n }\n private setKeyController() {\n const { keyContainer, toggleContinueSelect } = this.options;\n\n if (this.keycon) {\n this.keycon.destroy();\n this.keycon = null;\n }\n if (toggleContinueSelect) {\n this.keycon = new KeyController(keyContainer || window);\n this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on(\"blur\", this.onBlur);\n }\n }\n private setKeyEvent() {\n const { toggleContinueSelect } = this.options;\n if (!toggleContinueSelect || this.keycon) {\n return;\n }\n this.setKeyController();\n }\n private initElement() {\n this.target = createElement(\n
as any,\n this.target,\n this.container,\n );\n\n const target = this.target;\n\n const { dragContainer, checkInput, preventDefault } = this.options;\n this.dragContainer = typeof dragContainer === \"string\"\n ? [].slice.call(document.querySelectorAll(dragContainer))\n : (this.options.dragContainer || this.target.parentNode as any);\n this.dragger = new Dragger(this.dragContainer, {\n container: window,\n checkInput,\n preventDefault,\n dragstart: this.onDragStart,\n drag: this.onDrag,\n dragend: this.onDragEnd,\n });\n addEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.injectResult = injector.inject(target);\n }\n private hitTest(\n selectRect: Rect,\n clientX: number,\n clientY: number,\n targets: Array,\n rects: Rect[],\n ) {\n const { hitRate, selectByClick } = this.options;\n const { left, top, right, bottom } = selectRect;\n const passedTargets: Array = [];\n\n rects.forEach((rect, i) => {\n const {\n left: rectLeft,\n top: rectTop,\n right: rectRight,\n bottom: rectBottom,\n } = rect;\n const isStart\n = rectLeft <= clientX\n && clientX <= rectRight\n && rectTop <= clientY\n && clientY <= rectBottom;\n const rectSize = (rectRight - rectLeft) * (rectBottom - rectTop);\n const testLeft = Math.max(rectLeft, left);\n const testRight = Math.min(rectRight, right);\n const testTop = Math.max(rectTop, top);\n const testBottom = Math.min(rectBottom, bottom);\n\n if (selectByClick && isStart) {\n passedTargets.push(targets[i]);\n return;\n }\n if (testRight < testLeft || testBottom < testTop) {\n return;\n }\n const rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100);\n\n if (rate >= hitRate) {\n passedTargets.push(targets[i]);\n }\n });\n\n return passedTargets;\n }\n private initDragScroll() {\n this.dragScroll.on(\"scroll\", ({ container, direction }) => {\n this.trigger(\"scroll\", {\n container,\n direction,\n });\n }).on(\"move\", ({ offsetX, offsetY, inputEvent }) => {\n const datas = inputEvent.datas;\n datas.startX -= offsetX;\n datas.startY -= offsetY;\n datas.selectableRects.forEach(rect => {\n rect.top -= offsetY;\n rect.bottom -= offsetY;\n rect.left -= offsetX;\n rect.right -= offsetX;\n });\n this.dragger.scrollBy(offsetX, offsetY, inputEvent.inputEvent, false);\n\n inputEvent.distX += offsetX;\n inputEvent.distY += offsetY;\n this.check(inputEvent);\n });\n }\n private getSelectableTargets() {\n const selectableTargets: Array = [];\n\n this.options.selectableTargets.forEach(target => {\n if (isObject(target)) {\n selectableTargets.push(target);\n } else {\n const elements = [].slice.call(document.querySelectorAll(target));\n\n elements.forEach(el => {\n selectableTargets.push(el);\n });\n }\n });\n\n return selectableTargets;\n }\n private getSelectedTargets(passedTargets: Array) {\n const {\n list,\n prevList,\n added,\n removed,\n } = diff(this.selectedTargets, passedTargets) as ChildrenDiffResult;\n\n return added.map(index => list[index]).concat(removed.map(index => prevList[index]));\n }\n private select(\n selectedTargets: Array, rect: Rect, inputEvent: any, isStart?: boolean) {\n const {\n added,\n removed,\n prevList,\n list,\n } = this.differ.update(selectedTargets);\n\n if (isStart) {\n /**\n * When the select(drag) starts, the selectStart event is called.\n * @memberof Selecto\n * @event selectStart\n * @param {Selecto.OnSelect} - Parameters for the selectStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectStart\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n if (added.length || removed.length) {\n /**\n * When the select in real time, the select event is called.\n * @memberof Selecto\n * @event select\n * @param {Selecto.OnSelect} - Parameters for the select event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"select\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n }\n private selectEnd(\n startSelectedTargets: Array,\n selectedTargets: Array,\n rect: Rect,\n e: OnDragEvent,\n ) {\n const { inputEvent, isDouble } = e;\n const {\n added,\n removed,\n prevList,\n list,\n } = diff(startSelectedTargets, selectedTargets);\n const {\n added: afterAdded,\n removed: afterRemoved,\n prevList: afterPrevList,\n list: afterList,\n } = diff(this.selectedTargets, selectedTargets);\n const type = inputEvent.type;\n const isDragStart = type === \"mousedown\" || type === \"touchstart\";\n\n /**\n * When the select(dragEnd or click) ends, the selectEnd event is called.\n * @memberof Selecto\n * @event selectEnd\n * @param {Selecto.OnSelectEnd} - Parameters for the selectEnd event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectEnd\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n afterAdded: afterAdded.map(index => afterList[index]),\n afterRemoved: afterRemoved.map(index => afterPrevList[index]),\n isDragStart,\n isDouble: !!isDouble,\n rect,\n inputEvent,\n });\n }\n private onDragStart = (e: OnDragEvent, clickedTarget?: Element) => {\n const { datas, clientX, clientY, inputEvent } = e;\n const { continueSelect, selectFromInside, selectByClick } = this.options;\n const selectableTargets = this.getSelectableTargets();\n const selectableRects = selectableTargets.map(target => {\n const rect = target.getBoundingClientRect();\n const { left, top, width, height } = rect;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n });\n datas.selectableTargets = selectableTargets;\n datas.selectableRects = selectableRects;\n datas.startSelectedTargets = this.selectedTargets;\n\n const pointTarget = clickedTarget || document.elementFromPoint(clientX, clientY);\n const hitRect = {\n left: clientX,\n top: clientY,\n right: clientX,\n bottom: clientY,\n width: 0,\n height: 0,\n };\n let firstPassedTargets = this.hitTest(\n hitRect, clientX, clientY, selectableTargets, selectableRects).filter(\n target => target === pointTarget || target.contains(pointTarget),\n );\n\n const hasInsideTargets = firstPassedTargets.length > 0;\n const isPreventSelect = !selectFromInside && hasInsideTargets;\n\n if (isPreventSelect && !selectByClick) {\n return false;\n }\n if (!continueSelect) {\n this.selectedTargets = [];\n } else {\n firstPassedTargets = this.getSelectedTargets(firstPassedTargets);\n }\n const type = inputEvent.type;\n const isTrusted = type === \"mousedown\" || type === \"touchstart\";\n /**\n * When the drag starts, the dragStart event is called.\n * Call the stop () function if you have a specific element or don't want to raise a select\n * @memberof Selecto\n * @event dragStart\n * @param {OnDragStart} - Parameters for the dragStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"dragStart\", e => {\n * if (e.inputEvent.target.tagName === \"SPAN\") {\n * e.stop();\n * }\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n const result = isTrusted ? this.trigger(\"dragStart\", e) : true;\n\n if (!result) {\n return false;\n }\n this.select(firstPassedTargets, hitRect, inputEvent, true);\n datas.startX = clientX;\n datas.startY = clientY;\n datas.selectedTargets = firstPassedTargets;\n this.target.style.cssText\n += `left:0px;top:0px;transform: translate(${clientX}px, ${clientY}px)`;\n\n if (isPreventSelect && selectByClick) {\n this.onDragEnd(e);\n inputEvent.preventDefault();\n return false;\n } else {\n if (type === \"touchstart\") {\n inputEvent.preventDefault();\n }\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n this.dragScroll.dragStart(e, scrollOptions);\n }\n return true;\n }\n }\n private check(e: any) {\n const {\n datas,\n inputEvent,\n } = e;\n const rect = getRect(e);\n const {\n top,\n left,\n width,\n height,\n } = rect;\n this.target.style.cssText\n += `display: block;`\n + `left:0px;top:0px;`\n + `transform: translate(${left}px, ${top}px);`\n + `width:${width}px;height:${height}px;`;\n\n const passedTargets = this.hitTest(\n rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectableRects);\n const selectedTargets = this.getSelectedTargets(passedTargets);\n\n this.select(selectedTargets, rect, inputEvent);\n datas.selectedTargets = selectedTargets;\n }\n private onDrag = (e: OnDrag) => {\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n if (this.dragScroll.drag(e, scrollOptions)) {\n return;\n }\n }\n this.check(e);\n }\n private onDragEnd = (e: OnDragEvent) => {\n const { datas } = e;\n this.dragScroll.dragEnd();\n this.target.style.cssText += \"display: none;\";\n this.selectEnd(\n datas.startSelectedTargets, datas.selectedTargets, getRect(e), e);\n this.selectedTargets = datas.selectedTargets;\n }\n private sameCombiKey(e: any) {\n const toggleContinueSelect = [].concat(this.options.toggleContinueSelect);\n const combi = getCombi(e.inputEvent, e.key);\n return toggleContinueSelect.every(key => combi.indexOf(key) > -1);\n }\n private onKeyDown = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = true;\n /**\n * When you keydown the key you specified in toggleContinueSelect, the keydown event is called.\n * @memberof Selecto\n * @event keydown\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keydown\", {});\n }\n private onKeyUp = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = false;\n /**\n * When you keyup the key you specified in toggleContinueSelect, the keyup event is called.\n * @memberof Selecto\n * @event keyup\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keyup\", {});\n }\n private onBlur = () => {\n if (this.toggleContinueSelect && this.continueSelect) {\n this.trigger(\"keyup\", {});\n }\n }\n private onDocumentSelectStart = (e: any) => {\n if (!this.dragger.isFlag()) {\n return;\n }\n let dragContainer = this.dragContainer;\n\n if (dragContainer === window) {\n dragContainer = document.documentElement;\n }\n const containers = dragContainer instanceof Element\n ? [dragContainer] : [].slice.call(dragContainer) as Element[];\n const target = e.target;\n\n containers.some(container => {\n if (container === target || container.contains(target)) {\n e.preventDefault();\n return true;\n }\n });\n }\n}\n\ninterface Selecto extends Component, SelectoProperties {\n on(eventName: T, handlerToAttach: (event: SelectoEvents[T]) => any): this;\n on(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): this;\n on(events: { [key: string]: (event: { [key: string]: any }) => any }): this;\n}\n\nexport default Selecto;\n"],"names":["getClient","e","touch","touches","changedTouches","clientX","clientY","createElement","jsx","prevTarget","container","tag","children","attributes","className","style","el","document","name","setAttribute","elChildren","forEach","child","i","split","hasClass","addClass","elStyle","appendChild","h","attrs","_i","_a","_b","_c","diffValue","prev","cur","func","getRect","distX","distY","datas","startX","startY","tx","Math","min","ty","width","abs","height","left","top","right","bottom","injector","styled","CLASS_NAME","PROPERTIES","OPTIONS","__spreadArrays","OPTION_TYPES","target","dragContainer","selectableTargets","Array","selectByClick","Boolean","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","Number","scrollOptions","Object","checkInput","preventDefault","EVENTS","METHODS","__extends","options","_super","_this","ChildrenDiffer","DragScroll","clickedTarget","inputEvent","getSelectableTargets","selectableRects","map","rect","getBoundingClientRect","startSelectedTargets","selectedTargets","pointTarget","elementFromPoint","hitRect","firstPassedTargets","hitTest","filter","contains","hasInsideTargets","length","isPreventSelect","getSelectedTargets","type","isTrusted","result","trigger","select","cssText","onDragEnd","dragScroll","dragStart","drag","check","dragEnd","selectEnd","sameCombiKey","dragger","isFlag","window","documentElement","containers","Element","slice","call","some","undefined","initElement","initDragScroll","setKeyController","differ","setKeyEvent","value","onDragStart","off","keycon","destroy","unset","injectResult","removeEvent","onDocumentSelectStart","dragEvent","KeyController","keydown","onKeyDown","keyup","onKeyUp","on","onBlur","querySelectorAll","parentNode","Dragger","dragstart","onDrag","dragend","addEvent","inject","selectRect","targets","rects","passedTargets","rectLeft","rectTop","rectRight","rectBottom","isStart","rectSize","testLeft","max","testRight","testTop","testBottom","push","rate","round","direction","offsetX","offsetY","scrollBy","isObject","elements","list","prevList","added","removed","index","concat","selected","isDouble","afterAdded","afterRemoved","afterPrevList","afterList","isDragStart","combi","getCombi","key","every","indexOf","Selecto","Properties","prototype","property","enumerable","configurable","get","setter","camelize","set","defineProperty","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAGgBA,UAAUC;MAClB,aAAaA,CAAjB,EAAoB;QACVC,KAAK,GAAGD,CAAC,CAACE,OAAF,CAAU,CAAV,KAAgBF,CAAC,CAACG,cAAF,CAAiB,CAAjB,CAA9B;WAEO;MACHC,OAAO,EAAEH,KAAK,CAACG,OADZ;MAEHC,OAAO,EAAEJ,KAAK,CAACI;KAFnB;GAHJ,MAOO;WACI;MACHD,OAAO,EAAEJ,CAAC,CAACI,OADR;MAEHC,OAAO,EAAEL,CAAC,CAACK;KAFf;;;AAOR,SAAgBC,cACZC,KACAC,YACAC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,cAAP,CAAsBR,SAAtB,EAAiCC,QAAjC,EAA2CjM,UAA3C;GAlBO,IAoBL8L,QAAA;gBA2oBN;EA3oBsBW,UAAtB;;;;;"} \ No newline at end of file diff --git a/dist/selecto.js b/dist/selecto.js new file mode 100644 index 0000000..1a26f82 --- /dev/null +++ b/dist/selecto.js @@ -0,0 +1,3503 @@ +/* +Copyright (c) 2020 Daybrush +name: selecto +license: MIT +author: Daybrush +repository: git+https://github.com/daybrush/selecto.git +version: 1.3.0 +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.Selecto = factory()); +}(this, (function () { 'use strict'; + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 + + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + MERCHANTABLITY OR NON-INFRINGEMENT. + + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + + return extendStatics(d, b); + }; + + function __extends(d, b) { + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + var __assign = function () { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign.apply(this, arguments); + }; + function __rest(s, e) { + var t = {}; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + + if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; + } + return t; + } + function __decorate(decorators, target, key, desc) { + var c = arguments.length, + r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, + d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + } + function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + + for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; + + return r; + } + + /* + Copyright (c) 2017 NAVER Corp. + @egjs/component project is licensed under the MIT license + + @egjs/component JavaScript library + https://naver.github.io/egjs-component + + @version 2.1.2 + */ + /** + * Copyright (c) 2015 NAVER Corp. + * egjs projects are licensed under the MIT license + */ + function isUndefined(value) { + return typeof value === "undefined"; + } + /** + * A class used to manage events in a component + * @ko 컴포넌트의 이벤트을 관리할 수 있게 하는 클래스 + * @alias eg.Component + */ + + + var Component = + /*#__PURE__*/ + function () { + var Component = + /*#__PURE__*/ + function () { + /** + * Version info string + * @ko 버전정보 문자열 + * @name VERSION + * @static + * @type {String} + * @example + * eg.Component.VERSION; // ex) 2.0.0 + * @memberof eg.Component + */ + + /** + * @support {"ie": "7+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.1+ (except 3.x)"} + */ + function Component() { + this._eventHandler = {}; + this.options = {}; + } + /** + * Triggers a custom event. + * @ko 커스텀 이벤트를 발생시킨다 + * @param {String} eventName The name of the custom event to be triggered 발생할 커스텀 이벤트의 이름 + * @param {Object} customEvent Event data to be sent when triggering a custom event 커스텀 이벤트가 발생할 때 전달할 데이터 + * @return {Boolean} Indicates whether the event has occurred. If the stop() method is called by a custom event handler, it will return false and prevent the event from occurring. Ref 이벤트 발생 여부. 커스텀 이벤트 핸들러에서 stop() 메서드를 호출하면 'false'를 반환하고 이벤트 발생을 중단한다. 참고 + * @example + class Some extends eg.Component { + some(){ + if(this.trigger("beforeHi")){ // When event call to stop return false. + this.trigger("hi");// fire hi event. + } + } + } + const some = new Some(); + some.on("beforeHi", (e) => { + if(condition){ + e.stop(); // When event call to stop, `hi` event not call. + } + }); + some.on("hi", (e) => { + // `currentTarget` is component instance. + console.log(some === e.currentTarget); // true + }); + // If you want to more know event design. You can see article. + // https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F + */ + + + var _proto = Component.prototype; + + _proto.trigger = function trigger(eventName, customEvent) { + if (customEvent === void 0) { + customEvent = {}; + } + + var handlerList = this._eventHandler[eventName] || []; + var hasHandlerList = handlerList.length > 0; + + if (!hasHandlerList) { + return true; + } // If detach method call in handler in first time then handler list calls. + + + handlerList = handlerList.concat(); + customEvent.eventType = eventName; + var isCanceled = false; + var arg = [customEvent]; + var i = 0; + + customEvent.stop = function () { + isCanceled = true; + }; + + customEvent.currentTarget = this; + + for (var _len = arguments.length, restParam = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + restParam[_key - 2] = arguments[_key]; + } + + if (restParam.length >= 1) { + arg = arg.concat(restParam); + } + + for (i = 0; handlerList[i]; i++) { + handlerList[i].apply(this, arg); + } + + return !isCanceled; + }; + /** + * Executed event just one time. + * @ko 이벤트가 한번만 실행된다. + * @param {eventName} eventName The name of the event to be attached 등록할 이벤트의 이름 + * @param {Function} handlerToAttach The handler function of the event to be attached 등록할 이벤트의 핸들러 함수 + * @return {eg.Component} An instance of a component itself컴포넌트 자신의 인스턴스 + * @example + class Some extends eg.Component { + hi() { + alert("hi"); + } + thing() { + this.once("hi", this.hi); + } + } + var some = new Some(); + some.thing(); + some.trigger("hi"); + // fire alert("hi"); + some.trigger("hi"); + // Nothing happens + */ + + + _proto.once = function once(eventName, handlerToAttach) { + if (typeof eventName === "object" && isUndefined(handlerToAttach)) { + var eventHash = eventName; + var i; + + for (i in eventHash) { + this.once(i, eventHash[i]); + } + + return this; + } else if (typeof eventName === "string" && typeof handlerToAttach === "function") { + var self = this; + this.on(eventName, function listener() { + for (var _len2 = arguments.length, arg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + arg[_key2] = arguments[_key2]; + } + + handlerToAttach.apply(self, arg); + self.off(eventName, listener); + }); + } + + return this; + }; + /** + * Checks whether an event has been attached to a component. + * @ko 컴포넌트에 이벤트가 등록됐는지 확인한다. + * @param {String} eventName The name of the event to be attached 등록 여부를 확인할 이벤트의 이름 + * @return {Boolean} Indicates whether the event is attached. 이벤트 등록 여부 + * @example + class Some extends eg.Component { + some() { + this.hasOn("hi");// check hi event. + } + } + */ + + + _proto.hasOn = function hasOn(eventName) { + return !!this._eventHandler[eventName]; + }; + /** + * Attaches an event to a component. + * @ko 컴포넌트에 이벤트를 등록한다. + * @param {eventName} eventName The name of the event to be attached 등록할 이벤트의 이름 + * @param {Function} handlerToAttach The handler function of the event to be attached 등록할 이벤트의 핸들러 함수 + * @return {eg.Component} An instance of a component itself컴포넌트 자신의 인스턴스 + * @example + class Some extends eg.Component { + hi() { + console.log("hi"); + } + some() { + this.on("hi",this.hi); //attach event + } + } + */ + + + _proto.on = function on(eventName, handlerToAttach) { + if (typeof eventName === "object" && isUndefined(handlerToAttach)) { + var eventHash = eventName; + var name; + + for (name in eventHash) { + this.on(name, eventHash[name]); + } + + return this; + } else if (typeof eventName === "string" && typeof handlerToAttach === "function") { + var handlerList = this._eventHandler[eventName]; + + if (isUndefined(handlerList)) { + this._eventHandler[eventName] = []; + handlerList = this._eventHandler[eventName]; + } + + handlerList.push(handlerToAttach); + } + + return this; + }; + /** + * Detaches an event from the component. + * @ko 컴포넌트에 등록된 이벤트를 해제한다 + * @param {eventName} eventName The name of the event to be detached 해제할 이벤트의 이름 + * @param {Function} handlerToDetach The handler function of the event to be detached 해제할 이벤트의 핸들러 함수 + * @return {eg.Component} An instance of a component itself 컴포넌트 자신의 인스턴스 + * @example + class Some extends eg.Component { + hi() { + console.log("hi"); + } + some() { + this.off("hi",this.hi); //detach event + } + } + */ + + + _proto.off = function off(eventName, handlerToDetach) { + // All event detach. + if (isUndefined(eventName)) { + this._eventHandler = {}; + return this; + } // All handler of specific event detach. + + + if (isUndefined(handlerToDetach)) { + if (typeof eventName === "string") { + this._eventHandler[eventName] = undefined; + return this; + } else { + var eventHash = eventName; + var name; + + for (name in eventHash) { + this.off(name, eventHash[name]); + } + + return this; + } + } // The handler of specific event detach. + + + var handlerList = this._eventHandler[eventName]; + + if (handlerList) { + var k; + var handlerFunction; + + for (k = 0; (handlerFunction = handlerList[k]) !== undefined; k++) { + if (handlerFunction === handlerToDetach) { + handlerList = handlerList.splice(k, 1); + break; + } + } + } + + return this; + }; + + return Component; + }(); + + Component.VERSION = "2.1.2"; + return Component; + }(); + + /* + Copyright (c) 2018 Daybrush + @name: @daybrush/utils + license: MIT + author: Daybrush + repository: https://github.com/daybrush/utils + @version 0.10.5 + */ + /** + * get string "object" + * @memberof Consts + * @example + import {OBJECT} from "@daybrush/utils"; + + console.log(OBJECT); // "object" + */ + + var OBJECT = "object"; + var OPEN_CLOSED_CHARACTER = ["\"", "'", "\\\"", "\\'"]; + /** + * Check the type that the value is object. + * @memberof Utils + * @param {string} value - Value to check the type + * @return {} true if the type is correct, false otherwise + * @example + import {isObject} from "@daybrush/utils"; + + console.log(isObject({})); // true + console.log(isObject(undefined)); // false + console.log(isObject("")); // false + console.log(isObject(null)); // false + */ + + function isObject(value) { + return value && typeof value === OBJECT; + } + + function findClosed(closedCharacter, texts, index, length) { + for (var i = index; i < length; ++i) { + var character = texts[i].trim(); + + if (character === closedCharacter) { + return i; + } + + var nextIndex = i; + + if (character === "(") { + nextIndex = findClosed(")", texts, i + 1, length); + } else if (OPEN_CLOSED_CHARACTER.indexOf(character) > -1) { + nextIndex = findClosed(character, texts, i + 1, length); + } + + if (nextIndex === -1) { + break; + } + + i = nextIndex; + } + + return -1; + } + + function splitText(text, separator) { + var regexText = "(\\s*" + (separator || ",") + "\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)"; + var regex = new RegExp(regexText, "g"); + var texts = text.split(regex).filter(Boolean); + var length = texts.length; + var values = []; + var tempValues = []; + + for (var i = 0; i < length; ++i) { + var character = texts[i].trim(); + var nextIndex = i; + + if (character === "(") { + nextIndex = findClosed(")", texts, i + 1, length); + } else if (character === ")") { + throw new Error("invalid format"); + } else if (OPEN_CLOSED_CHARACTER.indexOf(character) > -1) { + nextIndex = findClosed(character, texts, i + 1, length); + } else if (character === separator) { + if (tempValues.length) { + values.push(tempValues.join("")); + tempValues = []; + } + + continue; + } + + if (nextIndex === -1) { + nextIndex = length - 1; + } + + tempValues.push(texts.slice(i, nextIndex + 1).join("")); + i = nextIndex; + } + + if (tempValues.length) { + values.push(tempValues.join("")); + } + + return values; + } + /** + * divide text by comma. + * @memberof Utils + * @param {string} text - text to divide + * @return {Array} divided texts + * @example + import {splitComma} from "@daybrush/utils"; + + console.log(splitComma("a,b,c,d,e,f,g")); + // ["a", "b", "c", "d", "e", "f", "g"] + console.log(splitComma("'a,b',c,'d,e',f,g")); + // ["'a,b'", "c", "'d,e'", "f", "g"] + */ + + function splitComma(text) { + // divide comma(,) + // "[^"]*"|'[^']*' + return splitText(text, ","); + } + /** + * transform strings to camel-case + * @memberof Utils + * @param {String} text - string + * @return {String} camel-case string + * @example + import {camelize} from "@daybrush/utils"; + + console.log(camelize("transform-origin")); // transformOrigin + console.log(camelize("abcd_efg")); // abcdEfg + console.log(camelize("abcd efg")); // abcdEfg + */ + + function camelize(str) { + return str.replace(/[\s-_]([a-z])/g, function (all, letter) { + return letter.toUpperCase(); + }); + } + /** + * Date.now() method + * @memberof CrossBrowser + * @return {number} milliseconds + * @example + import {now} from "@daybrush/utils"; + + console.log(now()); // 12121324241(milliseconds) + */ + + function now() { + return Date.now ? Date.now() : new Date().getTime(); + } + /** + * Checks if the specified class value exists in the element's class attribute. + * @memberof DOM + * @param element - target + * @param className - the class name to search + * @return {boolean} return false if the class is not found. + * @example + import {hasClass} from "@daybrush/utils"; + + console.log(hasClass(element, "start")); // true or false + */ + + function hasClass(element, className) { + if (element.classList) { + return element.classList.contains(className); + } + + return !!element.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)")); + } + /** + * Add the specified class value. If these classe already exist in the element's class attribute they are ignored. + * @memberof DOM + * @param element - target + * @param className - the class name to add + * @example + import {addClass} from "@daybrush/utils"; + + addClass(element, "start"); + */ + + function addClass(element, className) { + if (element.classList) { + element.classList.add(className); + } else { + element.className += " " + className; + } + } + /** + * Sets up a function that will be called whenever the specified event is delivered to the target + * @memberof DOM + * @param - event target + * @param - A case-sensitive string representing the event type to listen for. + * @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs + * @param - An options object that specifies characteristics about the event listener. The available options are: + * @example + import {addEvent} from "@daybrush/utils"; + + addEvent(el, "click", e => { + console.log(e); + }); + */ + + function addEvent(el, type, listener, options) { + el.addEventListener(type, listener, options); + } + /** + * removes from the EventTarget an event listener previously registered with EventTarget.addEventListener() + * @memberof DOM + * @param - event target + * @param - A case-sensitive string representing the event type to listen for. + * @param - The EventListener function of the event handler to remove from the event target. + * @example + import {addEvent, removeEvent} from "@daybrush/utils"; + const listener = e => { + console.log(e); + }; + addEvent(el, "click", listener); + removeEvent(el, "click", listener); + */ + + function removeEvent(el, type, listener) { + el.removeEventListener(type, listener); + } + + /* + Copyright (c) 2019 Daybrush + name: @daybrush/drag + license: MIT + author: Daybrush + repository: git+https://github.com/daybrush/drag.git + version: 0.18.6 + */ + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 + + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + MERCHANTABLITY OR NON-INFRINGEMENT. + + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ + var __assign$1 = function () { + __assign$1 = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign$1.apply(this, arguments); + }; + + function getRad(pos1, pos2) { + var distX = pos2[0] - pos1[0]; + var distY = pos2[1] - pos1[1]; + var rad = Math.atan2(distY, distX); + return rad >= 0 ? rad : rad + Math.PI * 2; + } + function getRotatiion(touches) { + return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180; + } + function getPinchDragPosition(clients, prevClients, startClients, startPinchClients) { + var nowCenter = getAverageClient(clients); + var prevCenter = getAverageClient(prevClients); + var startCenter = getAverageClient(startPinchClients); + var pinchClient = plueClient(startPinchClients[0], minusClient(nowCenter, startCenter)); + var pinchPrevClient = plueClient(startPinchClients[0], minusClient(prevCenter, startCenter)); + return getPosition(pinchClient, pinchPrevClient, startClients[0]); + } + function isMultiTouch(e) { + return e.touches && e.touches.length >= 2; + } + function getPositionEvent(e) { + if (e.touches) { + return getClients(e.touches); + } else { + return [getClient(e)]; + } + } + function getPosition(client, prevClient, startClient) { + var clientX = client.clientX, + clientY = client.clientY; + var prevX = prevClient.clientX, + prevY = prevClient.clientY; + var startX = startClient.clientX, + startY = startClient.clientY; + var deltaX = clientX - prevX; + var deltaY = clientY - prevY; + var distX = clientX - startX; + var distY = clientY - startY; + return { + clientX: clientX, + clientY: clientY, + deltaX: deltaX, + deltaY: deltaY, + distX: distX, + distY: distY + }; + } + function getDist(clients) { + return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2)); + } + function getPositions(clients, prevClients, startClients) { + return clients.map(function (client, i) { + return getPosition(client, prevClients[i], startClients[i]); + }); + } + function getClients(touches) { + var length = Math.min(touches.length, 2); + var clients = []; + + for (var i = 0; i < length; ++i) { + clients.push(getClient(touches[i])); + } + + return clients; + } + function getClient(e) { + return { + clientX: e.clientX, + clientY: e.clientY + }; + } + function getAverageClient(clients) { + if (clients.length === 1) { + return clients[0]; + } + + return { + clientX: (clients[0].clientX + clients[1].clientX) / 2, + clientY: (clients[0].clientY + clients[1].clientY) / 2 + }; + } + function plueClient(client1, client2) { + return { + clientX: client1.clientX + client2.clientX, + clientY: client1.clientY + client2.clientY + }; + } + function minusClient(client1, client2) { + return { + clientX: client1.clientX - client2.clientX, + clientY: client1.clientY - client2.clientY + }; + } + + var INPUT_TAGNAMES = ["textarea", "input"]; + /** + * You can set up drag events in any browser. + */ + + var Dragger = + /*#__PURE__*/ + function () { + /** + * + */ + function Dragger(targets, options) { + var _this = this; + + if (options === void 0) { + options = {}; + } + + this.options = {}; + this.flag = false; + this.pinchFlag = false; + this.datas = {}; + this.isDrag = false; + this.isPinch = false; + this.isMouse = false; + this.isTouch = false; + this.prevClients = []; + this.startClients = []; + this.movement = 0; + this.startPinchClients = []; + this.startDistance = 0; + this.customDist = [0, 0]; + this.targets = []; + this.prevTime = 0; + this.isDouble = false; + this.startRotate = 0; + /** + * @method + */ + + this.onDragStart = function (e) { + if (!_this.flag && e.cancelable === false) { + return; + } + + var _a = _this.options, + container = _a.container, + pinchOutside = _a.pinchOutside, + dragstart = _a.dragstart, + preventRightClick = _a.preventRightClick, + preventDefault = _a.preventDefault, + checkInput = _a.checkInput; + var isTouch = _this.isTouch; + + if (!_this.flag) { + var activeElement = document.activeElement; + var target = e.target; + var tagName = target.tagName.toLowerCase(); + var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1; + var hasContentEditable = target.isContentEditable; + + if (hasInput || hasContentEditable) { + if (checkInput || activeElement === target) { + // force false or already focused. + return false; + } + + if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) { + return false; + } + } else if ((preventDefault || e.type === "touchstart") && activeElement) { + var activeTagName = activeElement.tagName; + + if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) { + activeElement.blur(); + } + } + } + + if (!_this.flag && isTouch && pinchOutside) { + setTimeout(function () { + addEvent(container, "touchstart", _this.onDragStart, { + passive: false + }); + }); + } + + if (_this.flag && isTouch && pinchOutside) { + removeEvent(container, "touchstart", _this.onDragStart); + } + + if (isMultiTouch(e)) { + if (!_this.flag && e.touches.length !== e.changedTouches.length) { + return; + } + + if (!_this.pinchFlag) { + _this.onPinchStart(e); + } + } + + if (_this.flag) { + return; + } + + var clients = _this.startClients[0] ? _this.startClients : getPositionEvent(e); + _this.customDist = [0, 0]; + _this.flag = true; + _this.isDrag = false; + _this.startClients = clients; + _this.prevClients = clients; + _this.datas = {}; + _this.movement = 0; + var position = getPosition(clients[0], _this.prevClients[0], _this.startClients[0]); + + if (preventRightClick && (e.which === 3 || e.button === 2)) { + _this.initDrag(); + + return false; + } + + var result = dragstart && dragstart(__assign$1({ + type: "dragstart", + datas: _this.datas, + inputEvent: e + }, position)); + + if (result === false) { + _this.initDrag(); + } + + _this.isDouble = now() - _this.prevTime < 200; + _this.flag && preventDefault && e.preventDefault(); + }; + + this.onDrag = function (e, isScroll) { + if (!_this.flag) { + return; + } + + var clients = getPositionEvent(e); + + if (_this.pinchFlag) { + _this.onPinch(e, clients); + } + + var result = _this.move([0, 0], e, clients); + + if (!result || !result.deltaX && !result.deltaY) { + return; + } + + var drag = _this.options.drag; + drag && drag(__assign$1({}, result, { + isScroll: !!isScroll, + inputEvent: e + })); + }; + + this.onDragEnd = function (e) { + if (!_this.flag) { + return; + } + + var _a = _this.options, + dragend = _a.dragend, + pinchOutside = _a.pinchOutside, + container = _a.container; + + if (_this.isTouch && pinchOutside) { + removeEvent(container, "touchstart", _this.onDragStart); + } + + if (_this.pinchFlag) { + _this.onPinchEnd(e); + } + + _this.flag = false; + var prevClients = _this.prevClients; + var startClients = _this.startClients; + var position = _this.pinchFlag ? getPinchDragPosition(prevClients, prevClients, startClients, _this.startPinchClients) : getPosition(prevClients[0], prevClients[0], startClients[0]); + var currentTime = now(); + var isDouble = !_this.isDrag && _this.isDouble; + _this.prevTime = _this.isDrag || isDouble ? 0 : currentTime; + _this.startClients = []; + _this.prevClients = []; + dragend && dragend(__assign$1({ + type: "dragend", + datas: _this.datas, + isDouble: isDouble, + isDrag: _this.isDrag, + inputEvent: e + }, position)); + }; + + var elements = [].concat(targets); + this.options = __assign$1({ + checkInput: false, + container: elements.length > 1 ? window : elements[0], + preventRightClick: true, + preventDefault: true, + pinchThreshold: 0, + events: ["touch", "mouse"] + }, options); + var _a = this.options, + container = _a.container, + events = _a.events; + this.isTouch = events.indexOf("touch") > -1; + this.isMouse = events.indexOf("mouse") > -1; + this.customDist = [0, 0]; + this.targets = elements; + + if (this.isMouse) { + elements.forEach(function (el) { + addEvent(el, "mousedown", _this.onDragStart); + }); + addEvent(container, "mousemove", this.onDrag); + addEvent(container, "mouseup", this.onDragEnd); + addEvent(container, "contextmenu", this.onDragEnd); + } + + if (this.isTouch) { + var passive_1 = { + passive: false + }; + elements.forEach(function (el) { + addEvent(el, "touchstart", _this.onDragStart, passive_1); + }); + addEvent(container, "touchmove", this.onDrag, passive_1); + addEvent(container, "touchend", this.onDragEnd, passive_1); + addEvent(container, "touchcancel", this.onDragEnd, passive_1); + } + } + /** + * + */ + + + var __proto = Dragger.prototype; + + __proto.isDragging = function () { + return this.isDrag; + }; + /** + * + */ + + + __proto.isFlag = function () { + return this.flag; + }; + /** + * + */ + + + __proto.isPinchFlag = function () { + return this.pinchFlag; + }; + /** + * + */ + + + __proto.isPinching = function () { + return this.isPinch; + }; + /** + * + */ + + + __proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) { + if (isCallDrag === void 0) { + isCallDrag = true; + } + + if (!this.flag) { + return; + } + + this.startClients.forEach(function (client) { + client.clientX -= deltaX; + client.clientY -= deltaY; + }); + this.prevClients.forEach(function (client) { + client.clientX -= deltaX; + client.clientY -= deltaY; + }); + isCallDrag && this.onDrag(e, true); + }; + + __proto.move = function (_a, inputEvent, clients) { + var deltaX = _a[0], + deltaY = _a[1]; + + if (clients === void 0) { + clients = this.prevClients; + } + + var customDist = this.customDist; + var prevClients = this.prevClients; + var startClients = this.startClients; + var position = this.pinchFlag ? getPinchDragPosition(clients, prevClients, startClients, this.startPinchClients) : getPosition(clients[0], prevClients[0], startClients[0]); + customDist[0] += deltaX; + customDist[1] += deltaY; + position.deltaX += deltaX; + position.deltaY += deltaY; + var positionDeltaX = position.deltaX, + positionDeltaY = position.deltaY; + position.distX += customDist[0]; + position.distY += customDist[1]; + this.movement += Math.sqrt(positionDeltaX * positionDeltaX + positionDeltaY * positionDeltaY); + this.prevClients = clients; + this.isDrag = true; + return __assign$1({ + type: "drag", + datas: this.datas + }, position, { + movement: this.movement, + isDrag: this.isDrag, + isPinch: this.isPinch, + isScroll: false, + inputEvent: inputEvent + }); + }; + + __proto.onPinchStart = function (e) { + var _a, _b; + + var _c = this.options, + pinchstart = _c.pinchstart, + pinchThreshold = _c.pinchThreshold; + + if (this.isDrag && this.movement > pinchThreshold) { + return; + } + + var pinchClients = getClients(e.changedTouches); + this.pinchFlag = true; + + (_a = this.startClients).push.apply(_a, pinchClients); + + (_b = this.prevClients).push.apply(_b, pinchClients); + + this.startDistance = getDist(this.prevClients); + this.startPinchClients = this.prevClients.slice(); + + if (!pinchstart) { + return; + } + + var startClients = this.prevClients; + var startAverageClient = getAverageClient(startClients); + var centerPosition = getPosition(startAverageClient, startAverageClient, startAverageClient); + this.startRotate = getRotatiion(startClients); + pinchstart(__assign$1({ + type: "pinchstart", + datas: this.datas, + angle: this.startRotate, + touches: getPositions(startClients, startClients, startClients) + }, centerPosition, { + inputEvent: e + })); + }; + + __proto.onPinch = function (e, clients) { + if (!this.flag || !this.pinchFlag || clients.length < 2) { + return; + } + + this.isPinch = true; + var pinch = this.options.pinch; + + if (!pinch) { + return; + } + + var prevClients = this.prevClients; + var startClients = this.startClients; + var centerPosition = getPosition(getAverageClient(clients), getAverageClient(prevClients), getAverageClient(startClients)); + var angle = getRotatiion(clients); + var distance = getDist(clients); + pinch(__assign$1({ + type: "pinch", + datas: this.datas, + movement: this.movement, + angle: angle, + rotation: angle - this.startRotate, + touches: getPositions(clients, prevClients, startClients), + scale: distance / this.startDistance, + distance: distance + }, centerPosition, { + inputEvent: e + })); + }; + + __proto.onPinchEnd = function (e) { + if (!this.flag || !this.pinchFlag) { + return; + } + + var isPinch = this.isPinch; + this.isPinch = false; + this.pinchFlag = false; + var pinchend = this.options.pinchend; + + if (!pinchend) { + return; + } + + var prevClients = this.prevClients; + var startClients = this.startClients; + var centerPosition = getPosition(getAverageClient(prevClients), getAverageClient(prevClients), getAverageClient(startClients)); + pinchend(__assign$1({ + type: "pinchend", + datas: this.datas, + isPinch: isPinch, + touches: getPositions(prevClients, prevClients, startClients) + }, centerPosition, { + inputEvent: e + })); + this.isPinch = false; + this.pinchFlag = false; + }; + /** + * + */ + + + __proto.unset = function () { + var _this = this; + + var targets = this.targets; + var container = this.options.container; + + if (this.isMouse) { + targets.forEach(function (target) { + removeEvent(target, "mousedown", _this.onDragStart); + }); + removeEvent(container, "mousemove", this.onDrag); + removeEvent(container, "mouseup", this.onDragEnd); + removeEvent(container, "contextmenu", this.onDragEnd); + } + + if (this.isTouch) { + targets.forEach(function (target) { + removeEvent(target, "touchstart", _this.onDragStart); + }); + removeEvent(container, "touchstart", this.onDragStart); + removeEvent(container, "touchmove", this.onDrag); + removeEvent(container, "touchend", this.onDragEnd); + removeEvent(container, "touchcancel", this.onDragEnd); + } + }; + + __proto.initDrag = function () { + this.startClients = []; + this.prevClients = []; + this.flag = false; + }; + + return Dragger; + }(); + + /* + Copyright (c) 2019 Daybrush + name: framework-utils + license: MIT + author: Daybrush + repository: git+https://github.com/daybrush/framework-utils.git + version: 0.3.4 + */ + /* Class Decorator */ + + function Properties(properties, action) { + return function (component) { + var prototype = component.prototype; + properties.forEach(function (property) { + action(prototype, property); + }); + }; + } + + /* + Copyright (c) 2019-present NAVER Corp. + name: @egjs/list-differ + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-list-differ + version: 1.0.0 + */ + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var PolyMap = + /*#__PURE__*/ + function () { + function PolyMap() { + this.keys = []; + this.values = []; + } + + var __proto = PolyMap.prototype; + + __proto.get = function (key) { + return this.values[this.keys.indexOf(key)]; + }; + + __proto.set = function (key, value) { + var keys = this.keys; + var values = this.values; + var prevIndex = keys.indexOf(key); + var index = prevIndex === -1 ? keys.length : prevIndex; + keys[index] = key; + values[index] = value; + }; + + return PolyMap; + }(); + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var HashMap = + /*#__PURE__*/ + function () { + function HashMap() { + this.object = {}; + } + + var __proto = HashMap.prototype; + + __proto.get = function (key) { + return this.object[key]; + }; + + __proto.set = function (key, value) { + this.object[key] = value; + }; + + return HashMap; + }(); + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var SUPPORT_MAP = typeof Map === "function"; + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var Link = + /*#__PURE__*/ + function () { + function Link() {} + + var __proto = Link.prototype; + + __proto.connect = function (prevLink, nextLink) { + this.prev = prevLink; + this.next = nextLink; + prevLink && (prevLink.next = this); + nextLink && (nextLink.prev = this); + }; + + __proto.disconnect = function () { + // In double linked list, diconnect the interconnected relationship. + var prevLink = this.prev; + var nextLink = this.next; + prevLink && (prevLink.next = nextLink); + nextLink && (nextLink.prev = prevLink); + }; + + __proto.getIndex = function () { + var link = this; + var index = -1; + + while (link) { + link = link.prev; + ++index; + } + + return index; + }; + + return Link; + }(); + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + + function orderChanged(changed, fixed) { + // It is roughly in the order of these examples. + // 4, 6, 0, 2, 1, 3, 5, 7 + var fromLinks = []; // 0, 1, 2, 3, 4, 5, 6, 7 + + var toLinks = []; + changed.forEach(function (_a) { + var from = _a[0], + to = _a[1]; + var link = new Link(); + fromLinks[from] = link; + toLinks[to] = link; + }); // `fromLinks` are connected to each other by double linked list. + + fromLinks.forEach(function (link, i) { + link.connect(fromLinks[i - 1]); + }); + return changed.filter(function (_, i) { + return !fixed[i]; + }).map(function (_a, i) { + var from = _a[0], + to = _a[1]; + + if (from === to) { + return [0, 0]; + } + + var fromLink = fromLinks[from]; + var toLink = toLinks[to - 1]; + var fromIndex = fromLink.getIndex(); // Disconnect the link connected to `fromLink`. + + fromLink.disconnect(); // Connect `fromLink` to the right of `toLink`. + + if (!toLink) { + fromLink.connect(undefined, fromLinks[0]); + } else { + fromLink.connect(toLink, toLink.next); + } + + var toIndex = fromLink.getIndex(); + return [fromIndex, toIndex]; + }); + } + + var Result = + /*#__PURE__*/ + function () { + function Result(prevList, list, added, removed, changed, maintained, changedBeforeAdded, fixed) { + this.prevList = prevList; + this.list = list; + this.added = added; + this.removed = removed; + this.changed = changed; + this.maintained = maintained; + this.changedBeforeAdded = changedBeforeAdded; + this.fixed = fixed; + } + + var __proto = Result.prototype; + Object.defineProperty(__proto, "ordered", { + get: function () { + if (!this.cacheOrdered) { + this.caculateOrdered(); + } + + return this.cacheOrdered; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(__proto, "pureChanged", { + get: function () { + if (!this.cachePureChanged) { + this.caculateOrdered(); + } + + return this.cachePureChanged; + }, + enumerable: true, + configurable: true + }); + + __proto.caculateOrdered = function () { + var ordered = orderChanged(this.changedBeforeAdded, this.fixed); + var changed = this.changed; + var pureChanged = []; + this.cacheOrdered = ordered.filter(function (_a, i) { + var from = _a[0], + to = _a[1]; + var _b = changed[i], + fromBefore = _b[0], + toBefore = _b[1]; + + if (from !== to) { + pureChanged.push([fromBefore, toBefore]); + return true; + } + }); + this.cachePureChanged = pureChanged; + }; + + return Result; + }(); + + /** + * + * @memberof eg.ListDiffer + * @static + * @function + * @param - Previous List 이전 목록 + * @param - List to Update 업데이트 할 목록 + * @param - This callback function returns the key of the item. 아이템의 키를 반환하는 콜백 함수입니다. + * @return - Returns the diff between `prevList` and `list` `prevList`와 `list`의 다른 점을 반환한다. + * @example + * import { diff } from "@egjs/list-differ"; + * // script => eg.ListDiffer.diff + * const result = diff([0, 1, 2, 3, 4, 5], [7, 8, 0, 4, 3, 6, 2, 1], e => e); + * // List before update + * // [1, 2, 3, 4, 5] + * console.log(result.prevList); + * // Updated list + * // [4, 3, 6, 2, 1] + * console.log(result.list); + * // Index array of values added to `list` + * // [0, 1, 5] + * console.log(result.added); + * // Index array of values removed in `prevList` + * // [5] + * console.log(result.removed); + * // An array of index pairs of `prevList` and `list` with different indexes from `prevList` and `list` + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.changed); + * // The subset of `changed` and an array of index pairs that moved data directly. Indicate an array of absolute index pairs of `ordered`.(Formatted by: Array<[index of prevList, index of list]>) + * // [[4, 3], [3, 4], [2, 6]] + * console.log(result.pureChanged); + * // An array of index pairs to be `ordered` that can synchronize `list` before adding data. (Formatted by: Array<[prevIndex, nextIndex]>) + * // [[4, 1], [4, 2], [4, 3]] + * console.log(result.ordered); + * // An array of index pairs of `prevList` and `list` that have not been added/removed so data is preserved + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.maintained); + */ + + function diff(prevList, list, findKeyCallback) { + var mapClass = SUPPORT_MAP ? Map : findKeyCallback ? HashMap : PolyMap; + + var callback = findKeyCallback || function (e) { + return e; + }; + + var added = []; + var removed = []; + var maintained = []; + var prevKeys = prevList.map(callback); + var keys = list.map(callback); + var prevKeyMap = new mapClass(); + var keyMap = new mapClass(); + var changedBeforeAdded = []; + var fixed = []; + var removedMap = {}; + var changed = []; + var addedCount = 0; + var removedCount = 0; // Add prevKeys and keys to the hashmap. + + prevKeys.forEach(function (key, prevListIndex) { + prevKeyMap.set(key, prevListIndex); + }); + keys.forEach(function (key, listIndex) { + keyMap.set(key, listIndex); + }); // Compare `prevKeys` and `keys` and add them to `removed` if they are not in `keys`. + + prevKeys.forEach(function (key, prevListIndex) { + var listIndex = keyMap.get(key); // In prevList, but not in list, it is removed. + + if (typeof listIndex === "undefined") { + ++removedCount; + removed.push(prevListIndex); + } else { + removedMap[listIndex] = removedCount; + } + }); // Compare `prevKeys` and `keys` and add them to `added` if they are not in `prevKeys`. + + keys.forEach(function (key, listIndex) { + var prevListIndex = prevKeyMap.get(key); // In list, but not in prevList, it is added. + + if (typeof prevListIndex === "undefined") { + added.push(listIndex); + ++addedCount; + } else { + maintained.push([prevListIndex, listIndex]); + removedCount = removedMap[listIndex] || 0; + changedBeforeAdded.push([prevListIndex - removedCount, listIndex - addedCount]); + fixed.push(listIndex === prevListIndex); + + if (prevListIndex !== listIndex) { + changed.push([prevListIndex, listIndex]); + } + } + }); // Sort by ascending order of 'to(list's index). + + removed.reverse(); + return new Result(prevList, list, added, removed, changed, maintained, changedBeforeAdded, fixed); + } + + /** + * A module that checks diff when values are added, removed, or changed in an array. + * @ko 배열 또는 오브젝트에서 값이 추가되거나 삭제되거나 순서가 변경사항을 체크하는 모듈입니다. + * @memberof eg + */ + + var ListDiffer = + /*#__PURE__*/ + function () { + /** + * @param - Initializing Data Array. 초기 설정할 데이터 배열. + * @param - This callback function returns the key of the item. 아이템의 키를 반환하는 콜백 함수입니다. + * @example + * import ListDiffer from "@egjs/list-differ"; + * // script => eg.ListDiffer + * const differ = new ListDiffer([0, 1, 2, 3, 4, 5], e => e); + * const result = differ.update([7, 8, 0, 4, 3, 6, 2, 1]); + * // List before update + * // [1, 2, 3, 4, 5] + * console.log(result.prevList); + * // Updated list + * // [4, 3, 6, 2, 1] + * console.log(result.list); + * // Index array of values added to `list`. + * // [0, 1, 5] + * console.log(result.added); + * // Index array of values removed in `prevList`. + * // [5] + * console.log(result.removed); + * // An array of index pairs of `prevList` and `list` with different indexes from `prevList` and `list`. + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.changed); + * // The subset of `changed` and an array of index pairs that moved data directly. Indicate an array of absolute index pairs of `ordered`.(Formatted by: Array<[index of prevList, index of list]>) + * // [[4, 3], [3, 4], [2, 6]] + * console.log(result.pureChanged); + * // An array of index pairs to be `ordered` that can synchronize `list` before adding data. (Formatted by: Array<[prevIndex, nextIndex]>) + * // [[4, 1], [4, 2], [4, 3]] + * console.log(result.ordered); + * // An array of index pairs of `prevList` and `list` that have not been added/removed so data is preserved. + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.maintained); + */ + function ListDiffer(list, findKeyCallback) { + if (list === void 0) { + list = []; + } + + this.findKeyCallback = findKeyCallback; + this.list = [].slice.call(list); + } + /** + * Update list. + * @ko 리스트를 업데이트를 합니다. + * @param - List to update 업데이트할 리스트 + * @return - Returns the results of an update from `prevList` to `list`. `prevList`에서 `list`로 업데이트한 결과를 반환한다. + */ + + + var __proto = ListDiffer.prototype; + + __proto.update = function (list) { + var newData = [].slice.call(list); + var result = diff(this.list, newData, this.findKeyCallback); + this.list = newData; + return result; + }; + + return ListDiffer; + }(); + + /* + Copyright (c) 2019-present NAVER Corp. + name: @egjs/children-differ + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-children-differ + version: 1.0.0 + */ + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 + + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + MERCHANTABLITY OR NON-INFRINGEMENT. + + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var extendStatics$1 = function (d, b) { + extendStatics$1 = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + + return extendStatics$1(d, b); + }; + + function __extends$1(d, b) { + extendStatics$1(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + /* + egjs-children-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var findKeyCallback = typeof Map === "function" ? undefined : function () { + var childrenCount = 0; + return function (el) { + return el.__DIFF_KEY__ || (el.__DIFF_KEY__ = ++childrenCount); + }; + }(); + + /** + * A module that checks diff when child are added, removed, or changed . + * @ko 자식 노드들에서 자식 노드가 추가되거나 삭제되거나 순서가 변경된 사항을 체크하는 모듈입니다. + * @memberof eg + * @extends eg.ListDiffer + */ + + var ChildrenDiffer = + /*#__PURE__*/ + function (_super) { + __extends$1(ChildrenDiffer, _super); + /** + * @param - Initializing Children 초기 설정할 자식 노드들 + */ + + + function ChildrenDiffer(list) { + if (list === void 0) { + list = []; + } + + return _super.call(this, list, findKeyCallback) || this; + } + + return ChildrenDiffer; + }(ListDiffer); + + /* + egjs-children-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + /** + * + * @memberof eg.ChildrenDiffer + * @static + * @function + * @param - Previous List 이전 목록 + * @param - List to Update 업데이트 할 목록 + * @return - Returns the diff between `prevList` and `list` `prevList`와 `list`의 다른 점을 반환한다. + * @example + * import { diff } from "@egjs/children-differ"; + * // script => eg.ChildrenDiffer.diff + * const result = diff([0, 1, 2, 3, 4, 5], [7, 8, 0, 4, 3, 6, 2, 1]); + * // List before update + * // [1, 2, 3, 4, 5] + * console.log(result.prevList); + * // Updated list + * // [4, 3, 6, 2, 1] + * console.log(result.list); + * // Index array of values added to `list` + * // [0, 1, 5] + * console.log(result.added); + * // Index array of values removed in `prevList` + * // [5] + * console.log(result.removed); + * // An array of index pairs of `prevList` and `list` with different indexes from `prevList` and `list` + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.changed); + * // The subset of `changed` and an array of index pairs that moved data directly. Indicate an array of absolute index pairs of `ordered`.(Formatted by: Array<[index of prevList, index of list]>) + * // [[4, 3], [3, 4], [2, 6]] + * console.log(result.pureChanged); + * // An array of index pairs to be `ordered` that can synchronize `list` before adding data. (Formatted by: Array<[prevIndex, nextIndex]>) + * // [[4, 1], [4, 2], [4, 3]] + * console.log(result.ordered); + * // An array of index pairs of `prevList` and `list` that have not been added/removed so data is preserved + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.maintained); + */ + + function diff$1(prevList, list) { + return diff(prevList, list, findKeyCallback); + } + + /* + Copyright (c) 2019 Daybrush + name: @scena/dragscroll + license: MIT + author: Daybrush + repository: git+https://github.com/daybrush/dragscroll.git + version: 0.2.1 + */ + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 + + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + MERCHANTABLITY OR NON-INFRINGEMENT. + + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var extendStatics$2 = function (d, b) { + extendStatics$2 = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + + return extendStatics$2(d, b); + }; + + function __extends$2(d, b) { + extendStatics$2(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + function getDefaultScrollPosition(e) { + var container = e.container; + return [container.scrollLeft, container.scrollTop]; + } + + var DragScroll = + /*#__PURE__*/ + function (_super) { + __extends$2(DragScroll, _super); + + function DragScroll() { + var _this = _super !== null && _super.apply(this, arguments) || this; + + _this.startRect = null; + _this.startPos = []; + _this.prevTime = 0; + _this.timer = 0; + return _this; + } + + var __proto = DragScroll.prototype; + + __proto.dragStart = function (e, options) { + var _a = options.container.getBoundingClientRect(), + top = _a.top, + left = _a.left, + width = _a.width, + height = _a.height; + + this.startPos = [e.clientX, e.clientY]; + this.startRect = { + top: top, + left: left, + width: width, + height: height + }; + }; + + __proto.drag = function (e, options) { + var _this = this; + + var clientX = e.clientX, + clientY = e.clientY; + var container = options.container, + _a = options.threshold, + threshold = _a === void 0 ? 0 : _a, + _b = options.throttleTime, + throttleTime = _b === void 0 ? 0 : _b, + _c = options.getScrollPosition, + getScrollPosition = _c === void 0 ? getDefaultScrollPosition : _c; + + var _d = this, + startRect = _d.startRect, + startPos = _d.startPos; + + var nowTime = now(); + var distTime = Math.max(throttleTime + this.prevTime - nowTime, 0); + var direction = [0, 0]; + + if (startRect.top > clientY - threshold) { + if (startPos[1] > startRect.top || clientY < startPos[1]) { + direction[1] = -1; + } + } else if (startRect.top + startRect.height < clientY + threshold) { + if (startPos[1] < startRect.top + startRect.height || clientY > startPos[1]) { + direction[1] = 1; + } + } + + if (startRect.left > clientX - threshold) { + if (startPos[0] > startRect.left || clientX < startPos[0]) { + direction[0] = -1; + } + } else if (startRect.left + startRect.width < clientX + threshold) { + if (startPos[0] < startRect.left + startRect.width || clientX > startPos[0]) { + direction[0] = 1; + } + } + + clearTimeout(this.timer); + + if (!direction[0] && !direction[1]) { + return false; + } + + if (distTime > 0) { + this.timer = window.setTimeout(function () { + _this.drag(e, options); + }, distTime); + return false; + } + + this.prevTime = nowTime; + var prevPos = getScrollPosition({ + container: container, + direction: direction + }); + this.trigger("scroll", { + container: container, + direction: direction, + inputEvent: e + }); + var nextPos = getScrollPosition({ + container: container, + direction: direction + }); + var offsetX = nextPos[0] - prevPos[0]; + var offsetY = nextPos[1] - prevPos[1]; + + if (!offsetX && !offsetY) { + return false; + } + + this.trigger("move", { + offsetX: direction[0] ? offsetX : 0, + offsetY: direction[1] ? offsetY : 0, + inputEvent: e + }); + + if (throttleTime) { + this.timer = window.setTimeout(function () { + _this.drag(e, options); + }, throttleTime); + } + + return true; + }; + + __proto.dragEnd = function () { + clearTimeout(this.timer); + }; + + return DragScroll; + }(Component); + + /* + Copyright (c) Daybrush + name: keycon + license: MIT + author: Daybrush + repository: git+https://github.com/daybrush/keycon.git + version: 0.8.0 + */ + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 + + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + MERCHANTABLITY OR NON-INFRINGEMENT. + + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var extendStatics$3 = function (d, b) { + extendStatics$3 = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + + return extendStatics$3(d, b); + }; + + function __extends$3(d, b) { + extendStatics$3(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + function createCommonjsModule(fn, module) { + return module = { + exports: {} + }, fn(module, module.exports), module.exports; + } + + var keycode = createCommonjsModule(function (module, exports) { + // Source: http://jsfiddle.net/vWx8V/ + // http://stackoverflow.com/questions/5603195/full-list-of-javascript-keycodes + + /** + * Conenience method returns corresponding value for given keyName or keyCode. + * + * @param {Mixed} keyCode {Number} or keyName {String} + * @return {Mixed} + * @api public + */ + + function keyCode(searchInput) { + // Keyboard Events + if (searchInput && 'object' === typeof searchInput) { + var hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode; + if (hasKeyCode) searchInput = hasKeyCode; + } + + // Numbers + if ('number' === typeof searchInput) return names[searchInput] + + // Everything else (cast to string) + var search = String(searchInput); + + // check codes + var foundNamedKey = codes[search.toLowerCase()]; + if (foundNamedKey) return foundNamedKey + + // check aliases + var foundNamedKey = aliases[search.toLowerCase()]; + if (foundNamedKey) return foundNamedKey + + // weird character? + if (search.length === 1) return search.charCodeAt(0) + + return undefined + } + + /** + * Compares a keyboard event with a given keyCode or keyName. + * + * @param {Event} event Keyboard event that should be tested + * @param {Mixed} keyCode {Number} or keyName {String} + * @return {Boolean} + * @api public + */ + keyCode.isEventKey = function isEventKey(event, nameOrCode) { + if (event && 'object' === typeof event) { + var keyCode = event.which || event.keyCode || event.charCode; + if (keyCode === null || keyCode === undefined) { return false; } + if (typeof nameOrCode === 'string') { + // check codes + var foundNamedKey = codes[nameOrCode.toLowerCase()]; + if (foundNamedKey) { return foundNamedKey === keyCode; } + + // check aliases + var foundNamedKey = aliases[nameOrCode.toLowerCase()]; + if (foundNamedKey) { return foundNamedKey === keyCode; } + } else if (typeof nameOrCode === 'number') { + return nameOrCode === keyCode; + } + return false; + } + }; + + exports = module.exports = keyCode; + + /** + * Get by name + * + * exports.code['enter'] // => 13 + */ + + var codes = exports.code = exports.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 + }; + + // Helper aliases + + var aliases = exports.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 + }; + + /*! + * Programatically add the following + */ + + // lower case chars + for (i = 97; i < 123; i++) codes[String.fromCharCode(i)] = i - 32; + + // numbers + for (var i = 48; i < 58; i++) codes[i - 48] = i; + + // function keys + for (i = 1; i < 13; i++) codes['f'+i] = i + 111; + + // numpad keys + for (i = 0; i < 10; i++) codes['numpad '+i] = i + 96; + + /** + * Get by code + * + * exports.name[13] // => 'Enter' + */ + + var names = exports.names = exports.title = {}; // title for backward compat + + // Create reverse mapping + for (i in codes) names[codes[i]] = i; + + // Add aliases + for (var alias in aliases) { + codes[alias] = aliases[alias]; + } + }); + var keycode_1 = keycode.code; + var keycode_2 = keycode.codes; + var keycode_3 = keycode.aliases; + var keycode_4 = keycode.names; + var keycode_5 = keycode.title; + + /* + Copyright (c) 2018 Daybrush + @name: @daybrush/utils + license: MIT + author: Daybrush + repository: https://github.com/daybrush/utils + @version 0.10.1 + */ + /** + * get string "string" + * @memberof Consts + * @example + import {STRING} from "@daybrush/utils"; + + console.log(STRING); // "string" + */ + + var STRING = "string"; + /** + * Check the type that the value is isArray. + * @memberof Utils + * @param {string} value - Value to check the type + * @return {} true if the type is correct, false otherwise + * @example + import {isArray} from "@daybrush/utils"; + + console.log(isArray([])); // true + console.log(isArray({})); // false + console.log(isArray(undefined)); // false + console.log(isArray(null)); // false + */ + + function isArray(value) { + return Array.isArray(value); + } + /** + * Check the type that the value is string. + * @memberof Utils + * @param {string} value - Value to check the type + * @return {} true if the type is correct, false otherwise + * @example + import {isString} from "@daybrush/utils"; + + console.log(isString("1234")); // true + console.log(isString(undefined)); // false + console.log(isString(1)); // false + console.log(isString(null)); // false + */ + + function isString(value) { + return typeof value === STRING; + } + /** + * Sets up a function that will be called whenever the specified event is delivered to the target + * @memberof DOM + * @param - event target + * @param - A case-sensitive string representing the event type to listen for. + * @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs + * @param - An options object that specifies characteristics about the event listener. The available options are: + * @example + import {addEvent} from "@daybrush/utils"; + + addEvent(el, "click", e => { + console.log(e); + }); + */ + + function addEvent$1(el, type, listener, options) { + el.addEventListener(type, listener, options); + } + /** + * removes from the EventTarget an event listener previously registered with EventTarget.addEventListener() + * @memberof DOM + * @param - event target + * @param - A case-sensitive string representing the event type to listen for. + * @param - The EventListener function of the event handler to remove from the event target. + * @example + import {addEvent, removeEvent} from "@daybrush/utils"; + const listener = e => { + console.log(e); + }; + addEvent(el, "click", listener); + removeEvent(el, "click", listener); + */ + + function removeEvent$1(el, type, listener) { + el.removeEventListener(type, listener); + } + + var codeData = { + "+": "plus", + "left command": "meta", + "right command": "meta" + }; + var keysSort = { + shift: 1, + ctrl: 2, + alt: 3, + meta: 4 + }; + /** + * @memberof KeyController + */ + + function getKey(keyCode) { + var key = keycode_4[keyCode] || ""; + + for (var name in codeData) { + key = key.replace(name, codeData[name]); + } + + return key.replace(/\s/g, ""); + } + /** + * @memberof KeyController + */ + + function getCombi(e, key) { + if (key === void 0) { + key = getKey(e.keyCode); + } + + var keys = [e.shiftKey && "shift", e.ctrlKey && "ctrl", e.altKey && "alt", e.metaKey && "meta"]; + keys.indexOf(key) === -1 && keys.push(key); + return keys.filter(Boolean); + } + + function getArrangeCombi(keys) { + var arrangeKeys = keys.slice(); + arrangeKeys.sort(function (prev, next) { + var prevScore = keysSort[prev] || 5; + var nextScore = keysSort[next] || 5; + return prevScore - nextScore; + }); + return arrangeKeys; + } + + var globalKeyController; + /** + */ + + var KeyController = + /*#__PURE__*/ + function (_super) { + __extends$3(KeyController, _super); + /** + * + */ + + + function KeyController(container) { + if (container === void 0) { + container = window; + } + + var _this = _super.call(this) || this; + + _this.container = container; + /** + */ + + _this.ctrlKey = false; + /** + */ + + _this.altKey = false; + /** + * + */ + + _this.shiftKey = false; + /** + * + */ + + _this.metaKey = false; + + _this.clear = function () { + _this.ctrlKey = false; + _this.altKey = false; + _this.shiftKey = false; + _this.metaKey = false; + return _this; + }; + + _this.keydownEvent = function (e) { + _this.triggerEvent("keydown", e); + }; + + _this.keyupEvent = function (e) { + _this.triggerEvent("keyup", e); + }; + + _this.blur = function () { + _this.clear(); + + _this.trigger("blur"); + }; + + addEvent$1(container, "blur", _this.blur); + addEvent$1(container, "keydown", _this.keydownEvent); + addEvent$1(container, "keyup", _this.keyupEvent); + return _this; + } + + var __proto = KeyController.prototype; + Object.defineProperty(KeyController, "global", { + /** + */ + get: function () { + return globalKeyController || (globalKeyController = new KeyController()); + }, + enumerable: true, + configurable: true + }); + + KeyController.setGlobal = function () { + return this.global; + }; + /** + * + */ + + + __proto.destroy = function () { + var container = this.container; + this.clear(); + this.off(); + removeEvent$1(container, "blur", this.blur); + removeEvent$1(container, "keydown", this.keydownEvent); + removeEvent$1(container, "keyup", this.keyupEvent); + }; + /** + * + */ + + + __proto.keydown = function (comb, callback) { + return this.addEvent("keydown", comb, callback); + }; + /** + * + */ + + + __proto.offKeydown = function (comb, callback) { + return this.removeEvent("keydown", comb, callback); + }; + /** + * + */ + + + __proto.offKeyup = function (comb, callback) { + return this.removeEvent("keyup", comb, callback); + }; + /** + * + */ + + + __proto.keyup = function (comb, callback) { + return this.addEvent("keyup", comb, callback); + }; + + __proto.addEvent = function (type, comb, callback) { + if (isArray(comb)) { + this.on(type + "." + getArrangeCombi(comb).join("."), callback); + } else if (isString(comb)) { + this.on(type + "." + comb, callback); + } else { + this.on(type, comb); + } + + return this; + }; + + __proto.removeEvent = function (type, comb, callback) { + if (isArray(comb)) { + this.off(type + "." + getArrangeCombi(comb).join("."), callback); + } else if (isString(comb)) { + this.off(type + "." + comb, callback); + } else { + this.off(type, comb); + } + + return this; + }; + + __proto.triggerEvent = function (type, e) { + this.ctrlKey = e.ctrlKey; + this.shiftKey = e.shiftKey; + this.altKey = e.altKey; + this.metaKey = e.metaKey; + var key = getKey(e.keyCode); + var isToggle = key === "ctrl" || key === "shift" || key === "meta" || key === "alt"; + var param = { + key: key, + isToggle: isToggle, + inputEvent: e, + keyCode: e.keyCode, + ctrlKey: e.ctrlKey, + altKey: e.altKey, + shiftKey: e.shiftKey, + metaKey: e.metaKey + }; + this.trigger(type, param); + this.trigger(type + "." + key, param); + var combi = getCombi(e, key); + combi.length > 1 && this.trigger(type + "." + combi.join("."), param); + }; + + return KeyController; + }(Component); + + function getClient$1(e) { + if ("touches" in e) { + var touch = e.touches[0] || e.changedTouches[0]; + return { + clientX: touch.clientX, + clientY: touch.clientY + }; + } else { + return { + clientX: e.clientX, + clientY: e.clientY + }; + } + } + function createElement(jsx, prevTarget, container) { + var tag = jsx.tag, + children = jsx.children, + attributes = jsx.attributes, + className = jsx.className, + style = jsx.style; + var el = prevTarget || document.createElement(tag); + + for (var name in attributes) { + el.setAttribute(name, attributes[name]); + } + + var elChildren = el.children; + children.forEach(function (child, i) { + createElement(child, elChildren[i], el); + }); + + if (className) { + className.split(" ").forEach(function (name) { + if (!hasClass(el, name)) { + addClass(el, name); + } + }); + } + + if (style) { + var elStyle = el.style; + + for (var name in style) { + elStyle[name] = style[name]; + } + } + + if (!prevTarget && container) { + container.appendChild(el); + } + + return el; + } + function h(tag, attrs) { + var children = []; + + for (var _i = 2; _i < arguments.length; _i++) { + children[_i - 2] = arguments[_i]; + } + + var _a = attrs || {}, + _b = _a.className, + className = _b === void 0 ? "" : _b, + _c = _a.style, + style = _c === void 0 ? {} : _c, + attributes = __rest(_a, ["className", "style"]); + + return { + tag: tag, + className: className, + style: style, + attributes: attributes, + children: children + }; + } + function diffValue(prev, cur, func) { + if (prev !== cur) { + func(prev, cur); + } + } + function getRect(e) { + var _a = e.distX, + distX = _a === void 0 ? 0 : _a, + _b = e.distY, + distY = _b === void 0 ? 0 : _b, + datas = e.datas; + var startX = datas.startX, + startY = datas.startY; + var tx = Math.min(0, distX); + var ty = Math.min(0, distY); + var width = Math.abs(distX); + var height = Math.abs(distY); + var left = startX + tx; + var top = startY + ty; + return { + left: left, + top: top, + right: left + width, + bottom: top + height, + width: width, + height: height + }; + } + + /* + Copyright (c) 2019 Daybrush + name: css-styled + license: MIT + author: Daybrush + repository: git+https://github.com/daybrush/css-styled.git + version: 0.1.7 + */ + + function hash(str) { + var hash = 5381, + i = str.length; + + while(i) { + hash = (hash * 33) ^ str.charCodeAt(--i); + } + + /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed + * integers. Since we want the results to be always positive, convert the + * signed int to an unsigned by doing an unsigned bitshift. */ + return hash >>> 0; + } + + var stringHash = hash; + + function getHash(str) { + return stringHash(str).toString(36); + } + function getShadowRoot(parentElement) { + if (parentElement.getRootNode) { + var rootNode = parentElement.getRootNode(); + + if (rootNode.nodeType === 11) { + return rootNode; + } + } + + return; + } + function injectStyle(className, css, shadowRoot) { + var style = document.createElement("style"); + style.setAttribute("type", "text/css"); + style.innerHTML = css.replace(/([^}{]*){/mg, function (all, selector) { + return splitComma(selector).map(function (subSelector) { + if (subSelector.indexOf(":global") > -1) { + return subSelector.replace(/\:global/g, ""); + } else if (subSelector.indexOf(":host") > -1) { + return "" + subSelector.replace(/\:host/g, "." + className); + } + + return "." + className + " " + subSelector; + }).join(", ") + "{"; + }); + (shadowRoot || document.head || document.body).appendChild(style); + return style; + } + + function styled(css) { + var injectClassName = "rCS" + getHash(css); + var injectCount = 0; + var injectElement; + return { + className: injectClassName, + inject: function (el) { + var shadowRoot = getShadowRoot(el); + var firstMount = injectCount === 0; + var styleElement; + + if (shadowRoot || firstMount) { + styleElement = injectStyle(injectClassName, css, shadowRoot); + } + + if (firstMount) { + injectElement = styleElement; + } + + if (!shadowRoot) { + ++injectCount; + } + + return { + destroy: function () { + if (shadowRoot) { + el.removeChild(styleElement); + styleElement = null; + } else { + if (injectCount > 0) { + --injectCount; + } + + if (injectCount === 0 && injectElement) { + injectElement.parentNode.removeChild(injectElement); + injectElement = null; + } + } + } + }; + } + }; + } + + 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"); + /** + * @memberof Selecto + */ + + var CLASS_NAME = "selecto-selection " + injector.className; + var PROPERTIES = ["selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault"]; + /** + * @memberof Selecto + */ + + var OPTIONS = __spreadArrays([// ignore target, container, + "dragContainer"], PROPERTIES); + var OPTION_TYPES = { + 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 + }; + /** + * @memberof Selecto + */ + + var EVENTS = ["dragStart", "selectStart", "select", "selectEnd", "keydown", "keyup", "scroll"]; + /** + * @memberof Selecto + */ + + var METHODS = ["clickTarget", "setSelectedTargets", "triggerDragStart"]; + + /** + * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch. + * @sort 1 + * @extends eg.Component + */ + + var Selecto = + /*#__PURE__*/ + function (_super) { + __extends(Selecto, _super); + /** + * + */ + + + function Selecto(options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.selectedTargets = []; + _this.differ = new ChildrenDiffer(); + _this.dragScroll = new DragScroll(); + + _this.onDragStart = function (e, clickedTarget) { + var datas = e.datas, + clientX = e.clientX, + clientY = e.clientY, + inputEvent = e.inputEvent; + var _a = _this.options, + continueSelect = _a.continueSelect, + selectFromInside = _a.selectFromInside, + selectByClick = _a.selectByClick; + + var selectableTargets = _this.getSelectableTargets(); + + var selectableRects = selectableTargets.map(function (target) { + var rect = target.getBoundingClientRect(); + var left = rect.left, + top = rect.top, + width = rect.width, + height = rect.height; + return { + left: left, + top: top, + right: left + width, + bottom: top + height, + width: width, + height: height + }; + }); + datas.selectableTargets = selectableTargets; + datas.selectableRects = selectableRects; + datas.startSelectedTargets = _this.selectedTargets; + var pointTarget = clickedTarget || document.elementFromPoint(clientX, clientY); + var hitRect = { + left: clientX, + top: clientY, + right: clientX, + bottom: clientY, + width: 0, + height: 0 + }; + + var firstPassedTargets = _this.hitTest(hitRect, clientX, clientY, selectableTargets, selectableRects).filter(function (target) { + return target === pointTarget || target.contains(pointTarget); + }); + + var hasInsideTargets = firstPassedTargets.length > 0; + var isPreventSelect = !selectFromInside && hasInsideTargets; + + if (isPreventSelect && !selectByClick) { + return false; + } + + if (!continueSelect) { + _this.selectedTargets = []; + } else { + firstPassedTargets = _this.getSelectedTargets(firstPassedTargets); + } + + var type = inputEvent.type; + var isTrusted = type === "mousedown" || type === "touchstart"; + /** + * When the drag starts, the dragStart event is called. + * Call the stop () function if you have a specific element or don't want to raise a select + * @memberof Selecto + * @event dragStart + * @param {OnDragStart} - Parameters for the dragStart event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("dragStart", e => { + * if (e.inputEvent.target.tagName === "SPAN") { + * e.stop(); + * } + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + var result = isTrusted ? _this.trigger("dragStart", e) : true; + + if (!result) { + return false; + } + + _this.select(firstPassedTargets, hitRect, inputEvent, true); + + datas.startX = clientX; + datas.startY = clientY; + datas.selectedTargets = firstPassedTargets; + _this.target.style.cssText += "left:0px;top:0px;transform: translate(" + clientX + "px, " + clientY + "px)"; + + if (isPreventSelect && selectByClick) { + _this.onDragEnd(e); + + inputEvent.preventDefault(); + return false; + } else { + if (type === "touchstart") { + inputEvent.preventDefault(); + } + + var scrollOptions = _this.options.scrollOptions; + + if (scrollOptions && scrollOptions.container) { + _this.dragScroll.dragStart(e, scrollOptions); + } + + return true; + } + }; + + _this.onDrag = function (e) { + var scrollOptions = _this.options.scrollOptions; + + if (scrollOptions && scrollOptions.container) { + if (_this.dragScroll.drag(e, scrollOptions)) { + return; + } + } + + _this.check(e); + }; + + _this.onDragEnd = function (e) { + var datas = e.datas; + + _this.dragScroll.dragEnd(); + + _this.target.style.cssText += "display: none;"; + + _this.selectEnd(datas.startSelectedTargets, datas.selectedTargets, getRect(e), e); + + _this.selectedTargets = datas.selectedTargets; + }; + + _this.onKeyDown = function (e) { + if (!_this.sameCombiKey(e)) { + return; + } + + _this.continueSelect = true; + /** + * When you keydown the key you specified in toggleContinueSelect, the keydown event is called. + * @memberof Selecto + * @event keydown + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * toggleContinueSelect: "shift"; + * keyContainer: window, + * }); + * + * selecto.on("keydown", () => { + * document.querySelector(".button").classList.add("selected"); + * }).on("keyup", () => { + * document.querySelector(".button").classList.remove("selected"); + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + _this.trigger("keydown", {}); + }; + + _this.onKeyUp = function (e) { + if (!_this.sameCombiKey(e)) { + return; + } + + _this.continueSelect = false; + /** + * When you keyup the key you specified in toggleContinueSelect, the keyup event is called. + * @memberof Selecto + * @event keyup + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * toggleContinueSelect: "shift"; + * keyContainer: window, + * }); + * + * selecto.on("keydown", () => { + * document.querySelector(".button").classList.add("selected"); + * }).on("keyup", () => { + * document.querySelector(".button").classList.remove("selected"); + * }).on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + _this.trigger("keyup", {}); + }; + + _this.onBlur = function () { + if (_this.toggleContinueSelect && _this.continueSelect) { + _this.trigger("keyup", {}); + } + }; + + _this.onDocumentSelectStart = function (e) { + if (!_this.dragger.isFlag()) { + return; + } + + var dragContainer = _this.dragContainer; + + if (dragContainer === window) { + dragContainer = document.documentElement; + } + + var containers = dragContainer instanceof Element ? [dragContainer] : [].slice.call(dragContainer); + var target = e.target; + containers.some(function (container) { + if (container === target || container.contains(target)) { + e.preventDefault(); + return true; + } + }); + }; + + _this.target = options.target; + _this.container = options.container; + _this.options = __assign({ + target: null, + container: null, + dragContainer: null, + selectableTargets: [], + selectByClick: true, + selectFromInside: true, + hitRate: 100, + continueSelect: false, + toggleContinueSelect: null, + keyContainer: null, + scrollOptions: undefined, + checkInput: false, + preventDefault: false + }, options); + + _this.initElement(); + + _this.initDragScroll(); + + _this.setKeyController(); + + return _this; + } + /** + * You can set the currently selected targets. + */ + + + var __proto = Selecto.prototype; + + __proto.setSelectedTargets = function (selectedTargets) { + this.selectedTargets = selectedTargets; + this.differ = new ChildrenDiffer(selectedTargets); + return this; + }; + + __proto.setKeyContainer = function (keyContainer) { + var _this = this; + + var options = this.options; + diffValue(options.keyContainer, keyContainer, function () { + options.keyContainer = keyContainer; + + _this.setKeyController(); + }); + }; + + __proto.setToggleContinueSelect = function (toggleContinueSelect) { + var _this = this; + + var options = this.options; + diffValue(options.toggleContinueSelect, toggleContinueSelect, function () { + options.toggleContinueSelect = toggleContinueSelect; + + _this.setKeyEvent(); + }); + }; + + __proto.setPreventDefault = function (value) { + this.dragger.options.preventDefault = value; + }; + + __proto.setCheckInput = function (value) { + this.dragger.options.checkInput = value; + }; + /** + * `OnDragStart` is triggered by an external event. + * @param - external event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto(); + * + * window.addEventListener("mousedown", e => { + * selecto.triggerDragStart(e); + * }); + */ + + + __proto.triggerDragStart = function (e) { + this.dragger.onDragStart(e); + return this; + }; + /** + * Destroy elements, properties, and events. + */ + + + __proto.destroy = function () { + this.off(); + this.keycon && this.keycon.destroy(); + this.dragger.unset(); + this.injectResult.destroy(); + removeEvent(document, "selectstart", this.onDocumentSelectStart); + this.keycon = null; + this.dragger = null; + this.injectResult = null; + this.target = null; + this.container = null; + this.options = null; + }; + /** + * External click or mouse events can be applied to the selecto. + * @params - Extenal click or mouse event + * @params - Specify the clicked target directly. + */ + + + __proto.clickTarget = function (e, clickedTarget) { + var _a = getClient$1(e), + clientX = _a.clientX, + clientY = _a.clientY; + + var dragEvent = { + datas: {}, + clientX: clientX, + clientY: clientY, + inputEvent: e + }; + + if (this.onDragStart(dragEvent, clickedTarget)) { + this.onDragEnd(dragEvent); + } + + return this; + }; + + __proto.setKeyController = function () { + var _a = this.options, + keyContainer = _a.keyContainer, + toggleContinueSelect = _a.toggleContinueSelect; + + if (this.keycon) { + this.keycon.destroy(); + this.keycon = null; + } + + if (toggleContinueSelect) { + this.keycon = new KeyController(keyContainer || window); + this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on("blur", this.onBlur); + } + }; + + __proto.setKeyEvent = function () { + var toggleContinueSelect = this.options.toggleContinueSelect; + + if (!toggleContinueSelect || this.keycon) { + return; + } + + this.setKeyController(); + }; + + __proto.initElement = function () { + this.target = createElement(h("div", { + className: CLASS_NAME + }), this.target, this.container); + var target = this.target; + var _a = this.options, + dragContainer = _a.dragContainer, + checkInput = _a.checkInput, + preventDefault = _a.preventDefault; + this.dragContainer = typeof dragContainer === "string" ? [].slice.call(document.querySelectorAll(dragContainer)) : this.options.dragContainer || this.target.parentNode; + this.dragger = new Dragger(this.dragContainer, { + container: window, + checkInput: checkInput, + preventDefault: preventDefault, + dragstart: this.onDragStart, + drag: this.onDrag, + dragend: this.onDragEnd + }); + addEvent(document, "selectstart", this.onDocumentSelectStart); + this.injectResult = injector.inject(target); + }; + + __proto.hitTest = function (selectRect, clientX, clientY, targets, rects) { + var _a = this.options, + hitRate = _a.hitRate, + selectByClick = _a.selectByClick; + var left = selectRect.left, + top = selectRect.top, + right = selectRect.right, + bottom = selectRect.bottom; + var passedTargets = []; + rects.forEach(function (rect, i) { + var rectLeft = rect.left, + rectTop = rect.top, + rectRight = rect.right, + rectBottom = rect.bottom; + 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) { + passedTargets.push(targets[i]); + return; + } + + if (testRight < testLeft || testBottom < testTop) { + return; + } + + var rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100); + + if (rate >= hitRate) { + passedTargets.push(targets[i]); + } + }); + return passedTargets; + }; + + __proto.initDragScroll = function () { + var _this = this; + + this.dragScroll.on("scroll", function (_a) { + var container = _a.container, + direction = _a.direction; + + _this.trigger("scroll", { + container: container, + direction: direction + }); + }).on("move", function (_a) { + var offsetX = _a.offsetX, + offsetY = _a.offsetY, + inputEvent = _a.inputEvent; + var datas = inputEvent.datas; + datas.startX -= offsetX; + datas.startY -= offsetY; + datas.selectableRects.forEach(function (rect) { + rect.top -= offsetY; + rect.bottom -= offsetY; + rect.left -= offsetX; + rect.right -= offsetX; + }); + + _this.dragger.scrollBy(offsetX, offsetY, inputEvent.inputEvent, false); + + inputEvent.distX += offsetX; + inputEvent.distY += offsetY; + + _this.check(inputEvent); + }); + }; + + __proto.getSelectableTargets = function () { + var selectableTargets = []; + this.options.selectableTargets.forEach(function (target) { + if (isObject(target)) { + selectableTargets.push(target); + } else { + var elements = [].slice.call(document.querySelectorAll(target)); + elements.forEach(function (el) { + selectableTargets.push(el); + }); + } + }); + return selectableTargets; + }; + + __proto.getSelectedTargets = function (passedTargets) { + var _a = diff$1(this.selectedTargets, passedTargets), + 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]; + })); + }; + + __proto.select = function (selectedTargets, rect, inputEvent, isStart) { + var _a = this.differ.update(selectedTargets), + added = _a.added, + removed = _a.removed, + prevList = _a.prevList, + list = _a.list; + + if (isStart) { + /** + * When the select(drag) starts, the selectStart event is called. + * @memberof Selecto + * @event selectStart + * @param {Selecto.OnSelect} - Parameters for the selectStart event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("selectStart", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }).on("selectEnd", e => { + * e.afterAdded.forEach(el => { + * el.classList.add("selected"); + * }); + * e.afterRemoved.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + this.trigger("selectStart", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + rect: rect, + inputEvent: inputEvent + }); + } + + if (added.length || removed.length) { + /** + * When the select in real time, the select event is called. + * @memberof Selecto + * @event select + * @param {Selecto.OnSelect} - Parameters for the select event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("select", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + this.trigger("select", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + rect: rect, + inputEvent: inputEvent + }); + } + }; + + __proto.selectEnd = function (startSelectedTargets, selectedTargets, rect, e) { + var inputEvent = e.inputEvent, + isDouble = e.isDouble; + + var _a = diff$1(startSelectedTargets, selectedTargets), + added = _a.added, + removed = _a.removed, + prevList = _a.prevList, + list = _a.list; + + var _b = diff$1(this.selectedTargets, selectedTargets), + afterAdded = _b.added, + afterRemoved = _b.removed, + afterPrevList = _b.prevList, + afterList = _b.list; + + var type = inputEvent.type; + var isDragStart = type === "mousedown" || type === "touchstart"; + /** + * When the select(dragEnd or click) ends, the selectEnd event is called. + * @memberof Selecto + * @event selectEnd + * @param {Selecto.OnSelectEnd} - Parameters for the selectEnd event + * @example + * import Selecto from "selecto"; + * + * const selecto = new Selecto({ + * container: document.body, + * selectByClick: true, + * selectFromInside: false, + * }); + * + * selecto.on("selectStart", e => { + * e.added.forEach(el => { + * el.classList.add("selected"); + * }); + * e.removed.forEach(el => { + * el.classList.remove("selected"); + * }); + * }).on("selectEnd", e => { + * e.afterAdded.forEach(el => { + * el.classList.add("selected"); + * }); + * e.afterRemoved.forEach(el => { + * el.classList.remove("selected"); + * }); + * }); + */ + + this.trigger("selectEnd", { + selected: selectedTargets, + added: added.map(function (index) { + return list[index]; + }), + removed: removed.map(function (index) { + return prevList[index]; + }), + afterAdded: afterAdded.map(function (index) { + return afterList[index]; + }), + afterRemoved: afterRemoved.map(function (index) { + return afterPrevList[index]; + }), + isDragStart: isDragStart, + isDouble: !!isDouble, + rect: rect, + inputEvent: inputEvent + }); + }; + + __proto.check = function (e) { + var datas = e.datas, + inputEvent = e.inputEvent; + var rect = getRect(e); + var top = rect.top, + left = rect.left, + width = rect.width, + 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.selectableRects); + var selectedTargets = this.getSelectedTargets(passedTargets); + this.select(selectedTargets, rect, inputEvent); + datas.selectedTargets = selectedTargets; + }; + + __proto.sameCombiKey = function (e) { + var toggleContinueSelect = [].concat(this.options.toggleContinueSelect); + var combi = getCombi(e.inputEvent, e.key); + return toggleContinueSelect.every(function (key) { + return combi.indexOf(key) > -1; + }); + }; + + Selecto = __decorate([Properties(PROPERTIES, function (prototype, property) { + var attributes = { + enumerable: true, + configurable: true, + get: function () { + return this.options[property]; + } + }; + var setter = camelize("set " + property); + + if (prototype[setter]) { + attributes.set = function (value) { + this[setter](value); + }; + } else { + attributes.set = function (value) { + this.options[property] = value; + }; + } + + Object.defineProperty(prototype, property, attributes); + })], Selecto); + return Selecto; + }(Component); + + + + var modules = ({ + __proto__: null, + 'default': Selecto, + OPTIONS: OPTIONS, + OPTION_TYPES: OPTION_TYPES, + PROPERTIES: PROPERTIES, + EVENTS: EVENTS, + METHODS: METHODS, + CLASS_NAME: CLASS_NAME + }); + + for (var name in modules) { + Selecto[name] = modules[name]; + } + + return Selecto; + +}))); +//# sourceMappingURL=selecto.js.map diff --git a/dist/selecto.js.map b/dist/selecto.js.map new file mode 100644 index 0000000..5e9e160 --- /dev/null +++ b/dist/selecto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"selecto.js","sources":["../src/utils.ts","../src/consts.ts","../src/Selecto.tsx","../src/index.umd.ts"],"sourcesContent":["import { Hypertext, Rect } from \"./types\";\nimport { IObject, addClass, hasClass } from \"@daybrush/utils\";\n\nexport function getClient(e: MouseEvent | TouchEvent) {\n if (\"touches\" in e) {\n const touch = e.touches[0] || e.changedTouches[0];\n\n return {\n clientX: touch.clientX,\n clientY: touch.clientY,\n };\n } else {\n return {\n clientX: e.clientX,\n clientY: e.clientY,\n };\n }\n}\n\nexport function createElement(\n jsx: Hypertext,\n prevTarget?: HTMLElement | SVGElement,\n container?: HTMLElement | SVGElement,\n) {\n const { tag, children, attributes, className, style } = jsx;\n const el = prevTarget || document.createElement(tag) as HTMLElement | SVGElement;\n\n for (const name in attributes) {\n el.setAttribute(name, attributes[name]);\n }\n const elChildren = el.children;\n children.forEach((child, i) => {\n createElement(child, elChildren[i] as HTMLElement | SVGElement, el);\n });\n if (className) {\n className.split(\" \").forEach(name => {\n if (!hasClass(el, name)) {\n addClass(el, name);\n }\n });\n }\n if (style) {\n const elStyle = el.style;\n for (const name in style) {\n elStyle[name] = style[name];\n }\n }\n if (!prevTarget && container) {\n container.appendChild(el);\n }\n return el;\n}\nexport function h(\n tag: string,\n attrs: IObject,\n ...children: Hypertext[]\n): Hypertext {\n const {\n className = \"\",\n style = {},\n ...attributes\n } = attrs || {};\n return {\n tag,\n className,\n style,\n attributes,\n children,\n };\n}\n\nexport function diffValue(prev: T, cur: T, func: (prev: T, cur: T) => void) {\n if (prev !== cur) {\n func(prev, cur);\n }\n}\n\nexport function getRect(e: any): Rect {\n const {\n distX = 0,\n distY = 0,\n datas,\n } = e;\n const { startX, startY } = datas;\n const tx = Math.min(0, distX);\n const ty = Math.min(0, distY);\n const width = Math.abs(distX);\n const height = Math.abs(distY);\n const left = startX + tx;\n const top = startY + ty;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n}\n","import styled from \"css-styled\";\nimport { SelectoOptions } from \"./types\";\n\nexport const 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`);\n\n/**\n * @memberof Selecto\n */\nexport const CLASS_NAME = `selecto-selection ${injector.className}`;\n\nexport const PROPERTIES = [\n \"selectableTargets\",\n \"selectByClick\",\n \"selectFromInside\",\n \"continueSelect\",\n \"toggleContinueSelect\",\n \"keyContainer\",\n \"hitRate\",\n \"scrollOptions\",\n \"checkInput\",\n \"preventDefault\",\n] as const;\n/**\n * @memberof Selecto\n */\nexport const OPTIONS = [\n // ignore target, container,\n \"dragContainer\",\n ...PROPERTIES,\n] as const;\n\nexport const OPTION_TYPES: { [key in keyof SelectoOptions]: any } = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: Array,\n selectByClick: Boolean,\n selectFromInside: Boolean,\n continueSelect: Boolean,\n toggleContinueSelect: Array,\n keyContainer: null,\n hitRate: Number,\n scrollOptions: Object,\n checkInput: Boolean,\n preventDefault: Boolean,\n};\n\n\n/**\n * @memberof Selecto\n */\nexport const EVENTS = [\n \"dragStart\",\n \"selectStart\",\n \"select\",\n \"selectEnd\",\n \"keydown\",\n \"keyup\",\n \"scroll\",\n] as const;\n\n/**\n * @memberof Selecto\n */\nexport const METHODS = [\n \"clickTarget\",\n \"setSelectedTargets\",\n \"triggerDragStart\",\n] as const;\n","import Component from \"@egjs/component\";\nimport Dragger, { OnDrag } from \"@daybrush/drag\";\nimport { InjectResult } from \"css-styled\";\nimport { Properties } from \"framework-utils\";\nimport { isObject, camelize, IObject, addEvent, removeEvent } from \"@daybrush/utils\";\nimport ChildrenDiffer, { diff, ChildrenDiffResult } from \"@egjs/children-differ\";\nimport DragScroll from \"@scena/dragscroll\";\nimport KeyController, { getCombi } from \"keycon\";\nimport { createElement, h, getClient, diffValue, getRect } from \"./utils\";\nimport { SelectoOptions, Rect, SelectoProperties, OnDragEvent, SelectoEvents } from \"./types\";\nimport { PROPERTIES, injector, CLASS_NAME } from \"./consts\";\n/**\n * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.\n * @sort 1\n * @extends eg.Component\n */\n@Properties(PROPERTIES as any, (prototype, property) => {\n const attributes: IObject = {\n enumerable: true,\n configurable: true,\n get() {\n return this.options[property];\n },\n };\n const setter = camelize(`set ${property}`);\n if (prototype[setter]) {\n attributes.set = function(value) {\n this[setter](value);\n };\n } else {\n attributes.set = function(value) {\n this.options[property] = value;\n };\n }\n Object.defineProperty(prototype, property, attributes);\n})\nclass Selecto extends Component {\n public options: SelectoOptions;\n private target!: HTMLElement | SVGElement;\n private dragContainer!: Element | Window | Element[];\n private container!: HTMLElement;\n private dragger!: Dragger;\n private injectResult!: InjectResult;\n private selectedTargets: Array = [];\n private differ = new ChildrenDiffer();\n private dragScroll: DragScroll = new DragScroll();\n private keycon!: KeyController;\n /**\n *\n */\n constructor(\n options: Partial = {},\n ) {\n super();\n this.target = options.target;\n this.container = options.container;\n this.options = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: [],\n selectByClick: true,\n selectFromInside: true,\n hitRate: 100,\n continueSelect: false,\n toggleContinueSelect: null,\n keyContainer: null,\n scrollOptions: undefined,\n checkInput: false,\n preventDefault: false,\n ...options,\n };\n this.initElement();\n this.initDragScroll();\n this.setKeyController();\n }\n /**\n * You can set the currently selected targets.\n */\n public setSelectedTargets(selectedTargets: Array): this {\n this.selectedTargets = selectedTargets;\n this.differ = new ChildrenDiffer(selectedTargets);\n\n return this;\n }\n\n public setKeyContainer(keyContainer: HTMLElement | Document | Window) {\n const options = this.options;\n\n diffValue(options.keyContainer, keyContainer, () => {\n options.keyContainer = keyContainer;\n\n this.setKeyController();\n });\n }\n public setToggleContinueSelect(toggleContinueSelect: string[] | string) {\n const options = this.options;\n\n diffValue(options.toggleContinueSelect, toggleContinueSelect, () => {\n options.toggleContinueSelect = toggleContinueSelect;\n\n this.setKeyEvent();\n });\n }\n public setPreventDefault(value: boolean) {\n this.dragger.options.preventDefault = value;\n }\n public setCheckInput(value: boolean) {\n this.dragger.options.checkInput = value;\n }\n /**\n * `OnDragStart` is triggered by an external event.\n * @param - external event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto();\n *\n * window.addEventListener(\"mousedown\", e => {\n * selecto.triggerDragStart(e);\n * });\n */\n public triggerDragStart(e: MouseEvent | TouchEvent) {\n this.dragger.onDragStart(e);\n return this;\n }\n /**\n * Destroy elements, properties, and events.\n */\n public destroy(): void {\n this.off();\n this.keycon && this.keycon.destroy();\n this.dragger.unset();\n this.injectResult.destroy();\n removeEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.keycon = null;\n this.dragger = null;\n this.injectResult = null;\n this.target = null;\n this.container = null;\n this.options = null;\n }\n\n /**\n * External click or mouse events can be applied to the selecto.\n * @params - Extenal click or mouse event\n * @params - Specify the clicked target directly.\n */\n public clickTarget(e: MouseEvent | TouchEvent, clickedTarget?: Element): this {\n const { clientX, clientY } = getClient(e);\n const dragEvent: OnDragEvent = {\n datas: {},\n clientX,\n clientY,\n inputEvent: e,\n };\n if (this.onDragStart(dragEvent, clickedTarget)) {\n this.onDragEnd(dragEvent);\n }\n return this;\n }\n private setKeyController() {\n const { keyContainer, toggleContinueSelect } = this.options;\n\n if (this.keycon) {\n this.keycon.destroy();\n this.keycon = null;\n }\n if (toggleContinueSelect) {\n this.keycon = new KeyController(keyContainer || window);\n this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on(\"blur\", this.onBlur);\n }\n }\n private setKeyEvent() {\n const { toggleContinueSelect } = this.options;\n if (!toggleContinueSelect || this.keycon) {\n return;\n }\n this.setKeyController();\n }\n private initElement() {\n this.target = createElement(\n
as any,\n this.target,\n this.container,\n );\n\n const target = this.target;\n\n const { dragContainer, checkInput, preventDefault } = this.options;\n this.dragContainer = typeof dragContainer === \"string\"\n ? [].slice.call(document.querySelectorAll(dragContainer))\n : (this.options.dragContainer || this.target.parentNode as any);\n this.dragger = new Dragger(this.dragContainer, {\n container: window,\n checkInput,\n preventDefault,\n dragstart: this.onDragStart,\n drag: this.onDrag,\n dragend: this.onDragEnd,\n });\n addEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.injectResult = injector.inject(target);\n }\n private hitTest(\n selectRect: Rect,\n clientX: number,\n clientY: number,\n targets: Array,\n rects: Rect[],\n ) {\n const { hitRate, selectByClick } = this.options;\n const { left, top, right, bottom } = selectRect;\n const passedTargets: Array = [];\n\n rects.forEach((rect, i) => {\n const {\n left: rectLeft,\n top: rectTop,\n right: rectRight,\n bottom: rectBottom,\n } = rect;\n const isStart\n = rectLeft <= clientX\n && clientX <= rectRight\n && rectTop <= clientY\n && clientY <= rectBottom;\n const rectSize = (rectRight - rectLeft) * (rectBottom - rectTop);\n const testLeft = Math.max(rectLeft, left);\n const testRight = Math.min(rectRight, right);\n const testTop = Math.max(rectTop, top);\n const testBottom = Math.min(rectBottom, bottom);\n\n if (selectByClick && isStart) {\n passedTargets.push(targets[i]);\n return;\n }\n if (testRight < testLeft || testBottom < testTop) {\n return;\n }\n const rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100);\n\n if (rate >= hitRate) {\n passedTargets.push(targets[i]);\n }\n });\n\n return passedTargets;\n }\n private initDragScroll() {\n this.dragScroll.on(\"scroll\", ({ container, direction }) => {\n this.trigger(\"scroll\", {\n container,\n direction,\n });\n }).on(\"move\", ({ offsetX, offsetY, inputEvent }) => {\n const datas = inputEvent.datas;\n datas.startX -= offsetX;\n datas.startY -= offsetY;\n datas.selectableRects.forEach(rect => {\n rect.top -= offsetY;\n rect.bottom -= offsetY;\n rect.left -= offsetX;\n rect.right -= offsetX;\n });\n this.dragger.scrollBy(offsetX, offsetY, inputEvent.inputEvent, false);\n\n inputEvent.distX += offsetX;\n inputEvent.distY += offsetY;\n this.check(inputEvent);\n });\n }\n private getSelectableTargets() {\n const selectableTargets: Array = [];\n\n this.options.selectableTargets.forEach(target => {\n if (isObject(target)) {\n selectableTargets.push(target);\n } else {\n const elements = [].slice.call(document.querySelectorAll(target));\n\n elements.forEach(el => {\n selectableTargets.push(el);\n });\n }\n });\n\n return selectableTargets;\n }\n private getSelectedTargets(passedTargets: Array) {\n const {\n list,\n prevList,\n added,\n removed,\n } = diff(this.selectedTargets, passedTargets) as ChildrenDiffResult;\n\n return added.map(index => list[index]).concat(removed.map(index => prevList[index]));\n }\n private select(\n selectedTargets: Array, rect: Rect, inputEvent: any, isStart?: boolean) {\n const {\n added,\n removed,\n prevList,\n list,\n } = this.differ.update(selectedTargets);\n\n if (isStart) {\n /**\n * When the select(drag) starts, the selectStart event is called.\n * @memberof Selecto\n * @event selectStart\n * @param {Selecto.OnSelect} - Parameters for the selectStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectStart\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n if (added.length || removed.length) {\n /**\n * When the select in real time, the select event is called.\n * @memberof Selecto\n * @event select\n * @param {Selecto.OnSelect} - Parameters for the select event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"select\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n }\n private selectEnd(\n startSelectedTargets: Array,\n selectedTargets: Array,\n rect: Rect,\n e: OnDragEvent,\n ) {\n const { inputEvent, isDouble } = e;\n const {\n added,\n removed,\n prevList,\n list,\n } = diff(startSelectedTargets, selectedTargets);\n const {\n added: afterAdded,\n removed: afterRemoved,\n prevList: afterPrevList,\n list: afterList,\n } = diff(this.selectedTargets, selectedTargets);\n const type = inputEvent.type;\n const isDragStart = type === \"mousedown\" || type === \"touchstart\";\n\n /**\n * When the select(dragEnd or click) ends, the selectEnd event is called.\n * @memberof Selecto\n * @event selectEnd\n * @param {Selecto.OnSelectEnd} - Parameters for the selectEnd event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectEnd\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n afterAdded: afterAdded.map(index => afterList[index]),\n afterRemoved: afterRemoved.map(index => afterPrevList[index]),\n isDragStart,\n isDouble: !!isDouble,\n rect,\n inputEvent,\n });\n }\n private onDragStart = (e: OnDragEvent, clickedTarget?: Element) => {\n const { datas, clientX, clientY, inputEvent } = e;\n const { continueSelect, selectFromInside, selectByClick } = this.options;\n const selectableTargets = this.getSelectableTargets();\n const selectableRects = selectableTargets.map(target => {\n const rect = target.getBoundingClientRect();\n const { left, top, width, height } = rect;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n });\n datas.selectableTargets = selectableTargets;\n datas.selectableRects = selectableRects;\n datas.startSelectedTargets = this.selectedTargets;\n\n const pointTarget = clickedTarget || document.elementFromPoint(clientX, clientY);\n const hitRect = {\n left: clientX,\n top: clientY,\n right: clientX,\n bottom: clientY,\n width: 0,\n height: 0,\n };\n let firstPassedTargets = this.hitTest(\n hitRect, clientX, clientY, selectableTargets, selectableRects).filter(\n target => target === pointTarget || target.contains(pointTarget),\n );\n\n const hasInsideTargets = firstPassedTargets.length > 0;\n const isPreventSelect = !selectFromInside && hasInsideTargets;\n\n if (isPreventSelect && !selectByClick) {\n return false;\n }\n if (!continueSelect) {\n this.selectedTargets = [];\n } else {\n firstPassedTargets = this.getSelectedTargets(firstPassedTargets);\n }\n const type = inputEvent.type;\n const isTrusted = type === \"mousedown\" || type === \"touchstart\";\n /**\n * When the drag starts, the dragStart event is called.\n * Call the stop () function if you have a specific element or don't want to raise a select\n * @memberof Selecto\n * @event dragStart\n * @param {OnDragStart} - Parameters for the dragStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"dragStart\", e => {\n * if (e.inputEvent.target.tagName === \"SPAN\") {\n * e.stop();\n * }\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n const result = isTrusted ? this.trigger(\"dragStart\", e) : true;\n\n if (!result) {\n return false;\n }\n this.select(firstPassedTargets, hitRect, inputEvent, true);\n datas.startX = clientX;\n datas.startY = clientY;\n datas.selectedTargets = firstPassedTargets;\n this.target.style.cssText\n += `left:0px;top:0px;transform: translate(${clientX}px, ${clientY}px)`;\n\n if (isPreventSelect && selectByClick) {\n this.onDragEnd(e);\n inputEvent.preventDefault();\n return false;\n } else {\n if (type === \"touchstart\") {\n inputEvent.preventDefault();\n }\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n this.dragScroll.dragStart(e, scrollOptions);\n }\n return true;\n }\n }\n private check(e: any) {\n const {\n datas,\n inputEvent,\n } = e;\n const rect = getRect(e);\n const {\n top,\n left,\n width,\n height,\n } = rect;\n this.target.style.cssText\n += `display: block;`\n + `left:0px;top:0px;`\n + `transform: translate(${left}px, ${top}px);`\n + `width:${width}px;height:${height}px;`;\n\n const passedTargets = this.hitTest(\n rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectableRects);\n const selectedTargets = this.getSelectedTargets(passedTargets);\n\n this.select(selectedTargets, rect, inputEvent);\n datas.selectedTargets = selectedTargets;\n }\n private onDrag = (e: OnDrag) => {\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n if (this.dragScroll.drag(e, scrollOptions)) {\n return;\n }\n }\n this.check(e);\n }\n private onDragEnd = (e: OnDragEvent) => {\n const { datas } = e;\n this.dragScroll.dragEnd();\n this.target.style.cssText += \"display: none;\";\n this.selectEnd(\n datas.startSelectedTargets, datas.selectedTargets, getRect(e), e);\n this.selectedTargets = datas.selectedTargets;\n }\n private sameCombiKey(e: any) {\n const toggleContinueSelect = [].concat(this.options.toggleContinueSelect);\n const combi = getCombi(e.inputEvent, e.key);\n return toggleContinueSelect.every(key => combi.indexOf(key) > -1);\n }\n private onKeyDown = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = true;\n /**\n * When you keydown the key you specified in toggleContinueSelect, the keydown event is called.\n * @memberof Selecto\n * @event keydown\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keydown\", {});\n }\n private onKeyUp = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = false;\n /**\n * When you keyup the key you specified in toggleContinueSelect, the keyup event is called.\n * @memberof Selecto\n * @event keyup\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keyup\", {});\n }\n private onBlur = () => {\n if (this.toggleContinueSelect && this.continueSelect) {\n this.trigger(\"keyup\", {});\n }\n }\n private onDocumentSelectStart = (e: any) => {\n if (!this.dragger.isFlag()) {\n return;\n }\n let dragContainer = this.dragContainer;\n\n if (dragContainer === window) {\n dragContainer = document.documentElement;\n }\n const containers = dragContainer instanceof Element\n ? [dragContainer] : [].slice.call(dragContainer) as Element[];\n const target = e.target;\n\n containers.some(container => {\n if (container === target || container.contains(target)) {\n e.preventDefault();\n return true;\n }\n });\n }\n}\n\ninterface Selecto extends Component, SelectoProperties {\n on(eventName: T, handlerToAttach: (event: SelectoEvents[T]) => any): this;\n on(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): this;\n on(events: { [key: string]: (event: { [key: string]: any }) => any }): this;\n}\n\nexport default Selecto;\n","import Selecto, * as modules from \"./index\";\n\nfor (const name in modules) {\n (Selecto as any)[name] = modules[name];\n}\n\nexport default Selecto;\n"],"names":["getClient","e","touch","touches","changedTouches","clientX","clientY","createElement","jsx","prevTarget","container","tag","children","attributes","className","style","el","document","name","setAttribute","elChildren","forEach","child","i","split","hasClass","addClass","elStyle","appendChild","h","attrs","_i","_a","_b","_c","diffValue","prev","cur","func","getRect","distX","distY","datas","startX","startY","tx","Math","min","ty","width","abs","height","left","top","right","bottom","injector","styled","CLASS_NAME","PROPERTIES","OPTIONS","__spreadArrays","OPTION_TYPES","target","dragContainer","selectableTargets","Array","selectByClick","Boolean","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","Number","scrollOptions","Object","checkInput","preventDefault","EVENTS","METHODS","__extends","options","_super","_this","ChildrenDiffer","DragScroll","clickedTarget","inputEvent","getSelectableTargets","selectableRects","map","rect","getBoundingClientRect","startSelectedTargets","selectedTargets","pointTarget","elementFromPoint","hitRect","firstPassedTargets","hitTest","filter","contains","hasInsideTargets","length","isPreventSelect","getSelectedTargets","type","isTrusted","result","trigger","select","cssText","onDragEnd","dragScroll","dragStart","drag","check","dragEnd","selectEnd","sameCombiKey","dragger","isFlag","window","documentElement","containers","Element","slice","call","some","undefined","initElement","initDragScroll","setKeyController","differ","setKeyEvent","value","onDragStart","off","keycon","destroy","unset","injectResult","removeEvent","onDocumentSelectStart","dragEvent","KeyController","keydown","onKeyDown","keyup","onKeyUp","on","onBlur","querySelectorAll","parentNode","Dragger","dragstart","onDrag","dragend","addEvent","inject","selectRect","targets","rects","passedTargets","rectLeft","rectTop","rectRight","rectBottom","isStart","rectSize","testLeft","max","testRight","testTop","testBottom","push","rate","round","direction","offsetX","offsetY","scrollBy","isObject","elements","list","prevList","added","removed","index","concat","selected","isDouble","afterAdded","afterRemoved","afterPrevList","afterList","isDragStart","combi","getCombi","key","every","indexOf","Selecto","Properties","prototype","property","enumerable","configurable","get","setter","camelize","set","defineProperty","Component","modules"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACH;IAL4B,KAAjC;IAOA,QAAMI,MAAM,GAAGC,QAAQ,CAAC,SAAOL,QAAR,CAAvB;;IACA,QAAID,SAAS,CAACK,MAAD,CAAb,EAAuB;IACnBrM,MAAAA,UAAU,CAACuM,GAAX,GAAiB,UAAS5E,KAAT;IACb,aAAK0E,MAAL,EAAa1E,KAAb;IACH,OAFD;IAGH,KAJD,MAIO;IACH3H,MAAAA,UAAU,CAACuM,GAAX,GAAiB,UAAS5E,KAAT;IACb,aAAKtD,OAAL,CAAa4H,QAAb,IAAyBtE,KAAzB;IACH,OAFD;IAGH;;IACD5D,IAAAA,MAAM,CAACyI,cAAP,CAAsBR,SAAtB,EAAiCC,QAAjC,EAA2CjM,UAA3C;IACH,GAnBU,IAoBL8L,QAAA;IA2oBN,gBAAA;IAAC,EA3oBqBW,UAAtB;;;;;;;;;;;;;;;IClCA,KAAK,IAAMpM,IAAX,IAAmBqM,OAAnB,EAA4B;IACvBZ,EAAAA,OAAe,CAACzL,IAAD,CAAf,GAAwBqM,OAAO,CAACrM,IAAD,CAA/B;IACJ;;;;;;;;"} \ No newline at end of file diff --git a/dist/selecto.min.js b/dist/selecto.min.js new file mode 100644 index 0000000..07bbdd8 --- /dev/null +++ b/dist/selecto.min.js @@ -0,0 +1,10 @@ +/* +Copyright (c) 2020 Daybrush +name: selecto +license: MIT +author: Daybrush +repository: git+https://github.com/daybrush/selecto.git +version: 1.3.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 l=function(){return(l=Object.assign||function(t){for(var e,n=1,i=arguments.length;no)){var s=y(t.changedTouches);if(this.pinchFlag=!0,(e=this.startClients).push.apply(e,s),(n=this.prevClients).push.apply(n,s),this.startDistance=g(this.prevClients),this.startPinchClients=this.prevClients.slice(),r){var a=this.prevClients,c=m(a),l=k(c,c,c);this.startRotate=d(a),r(D({type:"pinchstart",datas:this.datas,angle:this.startRotate,touches:v(a,a,a)},l,{inputEvent:t}))}}},e.onPinch=function(t,e){if(this.flag&&this.pinchFlag&&!(e.length<2)){this.isPinch=!0;var n=this.options.pinch;if(n){var i=this.prevClients,r=this.startClients,o=k(m(e),m(i),m(r)),s=d(e),a=g(e);n(D({type:"pinch",datas:this.datas,movement:this.movement,angle:s,rotation:s-this.startRotate,touches:v(e,i,r),scale:a/this.startDistance,distance:a},o,{inputEvent:t}))}}},e.onPinchEnd=function(t){if(this.flag&&this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.options.pinchend;if(n){var i=this.prevClients,r=this.startClients,o=k(m(i),m(i),m(r));n(D({type:"pinchend",datas:this.datas,isPinch:e,touches:v(i,i,r)},o,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},e.unset=function(){var e=this,t=this.targets,n=this.options.container;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))},e.initDrag=function(){this.startClients=[],this.prevClients=[],this.flag=!1},t}();var P=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,i=this.values,r=n.indexOf(t),o=-1===r?n.length:r;n[o]=t,i[o]=e},t}(),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}(),K="function"==typeof Map,o=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var Y=function(){function t(t,e,n,i,r,o,s,a){this.prevList=t,this.list=e,this.added=n,this.removed=i,this.changed=r,this.maintained=o,this.changedBeforeAdded=s,this.fixed=a}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,a,c,e=(t=this.changedBeforeAdded,n=this.fixed,a=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],i=new o;a[e]=i,c[n]=i}),a.forEach(function(t,e){t.connect(a[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],i=t[1];if(n===i)return[0,0];var r=a[n],o=c[i-1],s=r.getIndex();return r.disconnect(),o?r.connect(o,o.next):r.connect(void 0,a[0]),[s,r.getIndex()]})),l=this.changed,u=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],i=t[1],r=l[e],o=r[0],s=r[1];if(n!==i)return u.push([o,s]),!0}),this.cachePureChanged=u},t}();function i(t,e,n){var i=K?Map:n?x:P,r=n||function(t){return t},o=[],s=[],a=[],c=t.map(r),l=e.map(r),u=new i,h=new i,f=[],d=[],p={},g=[],v=0,y=0;return c.forEach(function(t,e){u.set(t,e)}),l.forEach(function(t,e){h.set(t,e)}),c.forEach(function(t,e){var n=h.get(t);void 0===n?(++y,s.push(e)):p[n]=y}),l.forEach(function(t,e){var n=u.get(t);void 0===n?(o.push(e),++v):(a.push([n,e]),y=p[e]||0,f.push([n-y,e-v]),d.push(e===n),n!==e&&g.push([n,e]))}),s.reverse(),new Y(t,e,o,s,g,a,f,d)}var s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var e,j="function"==typeof Map?void 0:(e=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++e)}),X=function(e){function t(){this.constructor=n}var n,i;function r(t){return void 0===t&&(t=[]),e.call(this,t,j)||this}return s(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t),r}(function(){function t(t,e){void 0===t&&(t=[]),this.findKeyCallback=e,this.list=[].slice.call(t)}return t.prototype.update=function(t){var e=[].slice.call(t),n=i(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function R(t,e){return i(t,e,j)}var M=function(t,e){return(M=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 F=function(e){function t(){this.constructor=n}var n,i;function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.startRect=null,t.startPos=[],t.prevTime=0,t.timer=0,t}M(n=r,i=e),n.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t);var o=r.prototype;return o.dragStart=function(t,e){var n=e.container.getBoundingClientRect(),i=n.top,r=n.left,o=n.width,s=n.height;this.startPos=[t.clientX,t.clientY],this.startRect={top:i,left:r,width:o,height:s}},o.drag=function(t,e){var n=this,i=t.clientX,r=t.clientY,o=e.container,s=e.threshold,a=void 0===s?0:s,c=e.throttleTime,l=void 0===c?0:c,u=e.getScrollPosition,h=void 0===u?I:u,f=this.startRect,d=this.startPos,p=E(),g=Math.max(l+this.prevTime-p,0),v=[0,0];if(f.top>r-a?(d[1]>f.top||rd[1])&&(v[1]=1),f.left>i-a?(d[0]>f.left||id[0])&&(v[0]=1),clearTimeout(this.timer),!v[0]&&!v[1])return!1;if(0>>0}(it="\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),st=0,{className:ot,inject:function(t){var e,n,i,r,o,s=function(t){if(t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),a=0===st;return(s||a)&&(n=ot,i=it,r=s,(o=document.createElement("style")).setAttribute("type","text/css"),o.innerHTML=i.replace(/([^}{]*){/gm,function(t,e){return f(e).map(function(t){return-1 {\n createElement(child, elChildren[i] as HTMLElement | SVGElement, el);\n });\n if (className) {\n className.split(\" \").forEach(name => {\n if (!hasClass(el, name)) {\n addClass(el, name);\n }\n });\n }\n if (style) {\n const elStyle = el.style;\n for (const name in style) {\n elStyle[name] = style[name];\n }\n }\n if (!prevTarget && container) {\n container.appendChild(el);\n }\n return el;\n}\nexport function h(\n tag: string,\n attrs: IObject,\n ...children: Hypertext[]\n): Hypertext {\n const {\n className = \"\",\n style = {},\n ...attributes\n } = attrs || {};\n return {\n tag,\n className,\n style,\n attributes,\n children,\n };\n}\n\nexport function diffValue(prev: T, cur: T, func: (prev: T, cur: T) => void) {\n if (prev !== cur) {\n func(prev, cur);\n }\n}\n\nexport function getRect(e: any): Rect {\n const {\n distX = 0,\n distY = 0,\n datas,\n } = e;\n const { startX, startY } = datas;\n const tx = Math.min(0, distX);\n const ty = Math.min(0, distY);\n const width = Math.abs(distX);\n const height = Math.abs(distY);\n const left = startX + tx;\n const top = startY + ty;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n}\n","import styled from \"css-styled\";\nimport { SelectoOptions } from \"./types\";\n\nexport const 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`);\n\n/**\n * @memberof Selecto\n */\nexport const CLASS_NAME = `selecto-selection ${injector.className}`;\n\nexport const PROPERTIES = [\n \"selectableTargets\",\n \"selectByClick\",\n \"selectFromInside\",\n \"continueSelect\",\n \"toggleContinueSelect\",\n \"keyContainer\",\n \"hitRate\",\n \"scrollOptions\",\n \"checkInput\",\n \"preventDefault\",\n] as const;\n/**\n * @memberof Selecto\n */\nexport const OPTIONS = [\n // ignore target, container,\n \"dragContainer\",\n ...PROPERTIES,\n] as const;\n\nexport const OPTION_TYPES: { [key in keyof SelectoOptions]: any } = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: Array,\n selectByClick: Boolean,\n selectFromInside: Boolean,\n continueSelect: Boolean,\n toggleContinueSelect: Array,\n keyContainer: null,\n hitRate: Number,\n scrollOptions: Object,\n checkInput: Boolean,\n preventDefault: Boolean,\n};\n\n\n/**\n * @memberof Selecto\n */\nexport const EVENTS = [\n \"dragStart\",\n \"selectStart\",\n \"select\",\n \"selectEnd\",\n \"keydown\",\n \"keyup\",\n \"scroll\",\n] as const;\n\n/**\n * @memberof Selecto\n */\nexport const METHODS = [\n \"clickTarget\",\n \"setSelectedTargets\",\n \"triggerDragStart\",\n] as const;\n","import Component from \"@egjs/component\";\nimport Dragger, { OnDrag } from \"@daybrush/drag\";\nimport { InjectResult } from \"css-styled\";\nimport { Properties } from \"framework-utils\";\nimport { isObject, camelize, IObject, addEvent, removeEvent } from \"@daybrush/utils\";\nimport ChildrenDiffer, { diff, ChildrenDiffResult } from \"@egjs/children-differ\";\nimport DragScroll from \"@scena/dragscroll\";\nimport KeyController, { getCombi } from \"keycon\";\nimport { createElement, h, getClient, diffValue, getRect } from \"./utils\";\nimport { SelectoOptions, Rect, SelectoProperties, OnDragEvent, SelectoEvents } from \"./types\";\nimport { PROPERTIES, injector, CLASS_NAME } from \"./consts\";\n/**\n * Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.\n * @sort 1\n * @extends eg.Component\n */\n@Properties(PROPERTIES as any, (prototype, property) => {\n const attributes: IObject = {\n enumerable: true,\n configurable: true,\n get() {\n return this.options[property];\n },\n };\n const setter = camelize(`set ${property}`);\n if (prototype[setter]) {\n attributes.set = function(value) {\n this[setter](value);\n };\n } else {\n attributes.set = function(value) {\n this.options[property] = value;\n };\n }\n Object.defineProperty(prototype, property, attributes);\n})\nclass Selecto extends Component {\n public options: SelectoOptions;\n private target!: HTMLElement | SVGElement;\n private dragContainer!: Element | Window | Element[];\n private container!: HTMLElement;\n private dragger!: Dragger;\n private injectResult!: InjectResult;\n private selectedTargets: Array = [];\n private differ = new ChildrenDiffer();\n private dragScroll: DragScroll = new DragScroll();\n private keycon!: KeyController;\n /**\n *\n */\n constructor(\n options: Partial = {},\n ) {\n super();\n this.target = options.target;\n this.container = options.container;\n this.options = {\n target: null,\n container: null,\n dragContainer: null,\n selectableTargets: [],\n selectByClick: true,\n selectFromInside: true,\n hitRate: 100,\n continueSelect: false,\n toggleContinueSelect: null,\n keyContainer: null,\n scrollOptions: undefined,\n checkInput: false,\n preventDefault: false,\n ...options,\n };\n this.initElement();\n this.initDragScroll();\n this.setKeyController();\n }\n /**\n * You can set the currently selected targets.\n */\n public setSelectedTargets(selectedTargets: Array): this {\n this.selectedTargets = selectedTargets;\n this.differ = new ChildrenDiffer(selectedTargets);\n\n return this;\n }\n\n public setKeyContainer(keyContainer: HTMLElement | Document | Window) {\n const options = this.options;\n\n diffValue(options.keyContainer, keyContainer, () => {\n options.keyContainer = keyContainer;\n\n this.setKeyController();\n });\n }\n public setToggleContinueSelect(toggleContinueSelect: string[] | string) {\n const options = this.options;\n\n diffValue(options.toggleContinueSelect, toggleContinueSelect, () => {\n options.toggleContinueSelect = toggleContinueSelect;\n\n this.setKeyEvent();\n });\n }\n public setPreventDefault(value: boolean) {\n this.dragger.options.preventDefault = value;\n }\n public setCheckInput(value: boolean) {\n this.dragger.options.checkInput = value;\n }\n /**\n * `OnDragStart` is triggered by an external event.\n * @param - external event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto();\n *\n * window.addEventListener(\"mousedown\", e => {\n * selecto.triggerDragStart(e);\n * });\n */\n public triggerDragStart(e: MouseEvent | TouchEvent) {\n this.dragger.onDragStart(e);\n return this;\n }\n /**\n * Destroy elements, properties, and events.\n */\n public destroy(): void {\n this.off();\n this.keycon && this.keycon.destroy();\n this.dragger.unset();\n this.injectResult.destroy();\n removeEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.keycon = null;\n this.dragger = null;\n this.injectResult = null;\n this.target = null;\n this.container = null;\n this.options = null;\n }\n\n /**\n * External click or mouse events can be applied to the selecto.\n * @params - Extenal click or mouse event\n * @params - Specify the clicked target directly.\n */\n public clickTarget(e: MouseEvent | TouchEvent, clickedTarget?: Element): this {\n const { clientX, clientY } = getClient(e);\n const dragEvent: OnDragEvent = {\n datas: {},\n clientX,\n clientY,\n inputEvent: e,\n };\n if (this.onDragStart(dragEvent, clickedTarget)) {\n this.onDragEnd(dragEvent);\n }\n return this;\n }\n private setKeyController() {\n const { keyContainer, toggleContinueSelect } = this.options;\n\n if (this.keycon) {\n this.keycon.destroy();\n this.keycon = null;\n }\n if (toggleContinueSelect) {\n this.keycon = new KeyController(keyContainer || window);\n this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on(\"blur\", this.onBlur);\n }\n }\n private setKeyEvent() {\n const { toggleContinueSelect } = this.options;\n if (!toggleContinueSelect || this.keycon) {\n return;\n }\n this.setKeyController();\n }\n private initElement() {\n this.target = createElement(\n
as any,\n this.target,\n this.container,\n );\n\n const target = this.target;\n\n const { dragContainer, checkInput, preventDefault } = this.options;\n this.dragContainer = typeof dragContainer === \"string\"\n ? [].slice.call(document.querySelectorAll(dragContainer))\n : (this.options.dragContainer || this.target.parentNode as any);\n this.dragger = new Dragger(this.dragContainer, {\n container: window,\n checkInput,\n preventDefault,\n dragstart: this.onDragStart,\n drag: this.onDrag,\n dragend: this.onDragEnd,\n });\n addEvent(document, \"selectstart\", this.onDocumentSelectStart);\n\n this.injectResult = injector.inject(target);\n }\n private hitTest(\n selectRect: Rect,\n clientX: number,\n clientY: number,\n targets: Array,\n rects: Rect[],\n ) {\n const { hitRate, selectByClick } = this.options;\n const { left, top, right, bottom } = selectRect;\n const passedTargets: Array = [];\n\n rects.forEach((rect, i) => {\n const {\n left: rectLeft,\n top: rectTop,\n right: rectRight,\n bottom: rectBottom,\n } = rect;\n const isStart\n = rectLeft <= clientX\n && clientX <= rectRight\n && rectTop <= clientY\n && clientY <= rectBottom;\n const rectSize = (rectRight - rectLeft) * (rectBottom - rectTop);\n const testLeft = Math.max(rectLeft, left);\n const testRight = Math.min(rectRight, right);\n const testTop = Math.max(rectTop, top);\n const testBottom = Math.min(rectBottom, bottom);\n\n if (selectByClick && isStart) {\n passedTargets.push(targets[i]);\n return;\n }\n if (testRight < testLeft || testBottom < testTop) {\n return;\n }\n const rate = Math.round((testRight - testLeft) * (testBottom - testTop) / rectSize * 100);\n\n if (rate >= hitRate) {\n passedTargets.push(targets[i]);\n }\n });\n\n return passedTargets;\n }\n private initDragScroll() {\n this.dragScroll.on(\"scroll\", ({ container, direction }) => {\n this.trigger(\"scroll\", {\n container,\n direction,\n });\n }).on(\"move\", ({ offsetX, offsetY, inputEvent }) => {\n const datas = inputEvent.datas;\n datas.startX -= offsetX;\n datas.startY -= offsetY;\n datas.selectableRects.forEach(rect => {\n rect.top -= offsetY;\n rect.bottom -= offsetY;\n rect.left -= offsetX;\n rect.right -= offsetX;\n });\n this.dragger.scrollBy(offsetX, offsetY, inputEvent.inputEvent, false);\n\n inputEvent.distX += offsetX;\n inputEvent.distY += offsetY;\n this.check(inputEvent);\n });\n }\n private getSelectableTargets() {\n const selectableTargets: Array = [];\n\n this.options.selectableTargets.forEach(target => {\n if (isObject(target)) {\n selectableTargets.push(target);\n } else {\n const elements = [].slice.call(document.querySelectorAll(target));\n\n elements.forEach(el => {\n selectableTargets.push(el);\n });\n }\n });\n\n return selectableTargets;\n }\n private getSelectedTargets(passedTargets: Array) {\n const {\n list,\n prevList,\n added,\n removed,\n } = diff(this.selectedTargets, passedTargets) as ChildrenDiffResult;\n\n return added.map(index => list[index]).concat(removed.map(index => prevList[index]));\n }\n private select(\n selectedTargets: Array, rect: Rect, inputEvent: any, isStart?: boolean) {\n const {\n added,\n removed,\n prevList,\n list,\n } = this.differ.update(selectedTargets);\n\n if (isStart) {\n /**\n * When the select(drag) starts, the selectStart event is called.\n * @memberof Selecto\n * @event selectStart\n * @param {Selecto.OnSelect} - Parameters for the selectStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectStart\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n if (added.length || removed.length) {\n /**\n * When the select in real time, the select event is called.\n * @memberof Selecto\n * @event select\n * @param {Selecto.OnSelect} - Parameters for the select event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"select\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n rect,\n inputEvent,\n });\n }\n }\n private selectEnd(\n startSelectedTargets: Array,\n selectedTargets: Array,\n rect: Rect,\n e: OnDragEvent,\n ) {\n const { inputEvent, isDouble } = e;\n const {\n added,\n removed,\n prevList,\n list,\n } = diff(startSelectedTargets, selectedTargets);\n const {\n added: afterAdded,\n removed: afterRemoved,\n prevList: afterPrevList,\n list: afterList,\n } = diff(this.selectedTargets, selectedTargets);\n const type = inputEvent.type;\n const isDragStart = type === \"mousedown\" || type === \"touchstart\";\n\n /**\n * When the select(dragEnd or click) ends, the selectEnd event is called.\n * @memberof Selecto\n * @event selectEnd\n * @param {Selecto.OnSelectEnd} - Parameters for the selectEnd event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"selectStart\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * }).on(\"selectEnd\", e => {\n * e.afterAdded.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.afterRemoved.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"selectEnd\", {\n selected: selectedTargets,\n added: added.map(index => list[index]),\n removed: removed.map(index => prevList[index]),\n afterAdded: afterAdded.map(index => afterList[index]),\n afterRemoved: afterRemoved.map(index => afterPrevList[index]),\n isDragStart,\n isDouble: !!isDouble,\n rect,\n inputEvent,\n });\n }\n private onDragStart = (e: OnDragEvent, clickedTarget?: Element) => {\n const { datas, clientX, clientY, inputEvent } = e;\n const { continueSelect, selectFromInside, selectByClick } = this.options;\n const selectableTargets = this.getSelectableTargets();\n const selectableRects = selectableTargets.map(target => {\n const rect = target.getBoundingClientRect();\n const { left, top, width, height } = rect;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n width,\n height,\n };\n });\n datas.selectableTargets = selectableTargets;\n datas.selectableRects = selectableRects;\n datas.startSelectedTargets = this.selectedTargets;\n\n const pointTarget = clickedTarget || document.elementFromPoint(clientX, clientY);\n const hitRect = {\n left: clientX,\n top: clientY,\n right: clientX,\n bottom: clientY,\n width: 0,\n height: 0,\n };\n let firstPassedTargets = this.hitTest(\n hitRect, clientX, clientY, selectableTargets, selectableRects).filter(\n target => target === pointTarget || target.contains(pointTarget),\n );\n\n const hasInsideTargets = firstPassedTargets.length > 0;\n const isPreventSelect = !selectFromInside && hasInsideTargets;\n\n if (isPreventSelect && !selectByClick) {\n return false;\n }\n if (!continueSelect) {\n this.selectedTargets = [];\n } else {\n firstPassedTargets = this.getSelectedTargets(firstPassedTargets);\n }\n const type = inputEvent.type;\n const isTrusted = type === \"mousedown\" || type === \"touchstart\";\n /**\n * When the drag starts, the dragStart event is called.\n * Call the stop () function if you have a specific element or don't want to raise a select\n * @memberof Selecto\n * @event dragStart\n * @param {OnDragStart} - Parameters for the dragStart event\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * selectByClick: true,\n * selectFromInside: false,\n * });\n *\n * selecto.on(\"dragStart\", e => {\n * if (e.inputEvent.target.tagName === \"SPAN\") {\n * e.stop();\n * }\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n const result = isTrusted ? this.trigger(\"dragStart\", e) : true;\n\n if (!result) {\n return false;\n }\n this.select(firstPassedTargets, hitRect, inputEvent, true);\n datas.startX = clientX;\n datas.startY = clientY;\n datas.selectedTargets = firstPassedTargets;\n this.target.style.cssText\n += `left:0px;top:0px;transform: translate(${clientX}px, ${clientY}px)`;\n\n if (isPreventSelect && selectByClick) {\n this.onDragEnd(e);\n inputEvent.preventDefault();\n return false;\n } else {\n if (type === \"touchstart\") {\n inputEvent.preventDefault();\n }\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n this.dragScroll.dragStart(e, scrollOptions);\n }\n return true;\n }\n }\n private check(e: any) {\n const {\n datas,\n inputEvent,\n } = e;\n const rect = getRect(e);\n const {\n top,\n left,\n width,\n height,\n } = rect;\n this.target.style.cssText\n += `display: block;`\n + `left:0px;top:0px;`\n + `transform: translate(${left}px, ${top}px);`\n + `width:${width}px;height:${height}px;`;\n\n const passedTargets = this.hitTest(\n rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectableRects);\n const selectedTargets = this.getSelectedTargets(passedTargets);\n\n this.select(selectedTargets, rect, inputEvent);\n datas.selectedTargets = selectedTargets;\n }\n private onDrag = (e: OnDrag) => {\n const { scrollOptions } = this.options;\n if (scrollOptions && scrollOptions.container) {\n if (this.dragScroll.drag(e, scrollOptions)) {\n return;\n }\n }\n this.check(e);\n }\n private onDragEnd = (e: OnDragEvent) => {\n const { datas } = e;\n this.dragScroll.dragEnd();\n this.target.style.cssText += \"display: none;\";\n this.selectEnd(\n datas.startSelectedTargets, datas.selectedTargets, getRect(e), e);\n this.selectedTargets = datas.selectedTargets;\n }\n private sameCombiKey(e: any) {\n const toggleContinueSelect = [].concat(this.options.toggleContinueSelect);\n const combi = getCombi(e.inputEvent, e.key);\n return toggleContinueSelect.every(key => combi.indexOf(key) > -1);\n }\n private onKeyDown = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = true;\n /**\n * When you keydown the key you specified in toggleContinueSelect, the keydown event is called.\n * @memberof Selecto\n * @event keydown\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keydown\", {});\n }\n private onKeyUp = (e: any) => {\n if (!this.sameCombiKey(e)) {\n return;\n }\n this.continueSelect = false;\n /**\n * When you keyup the key you specified in toggleContinueSelect, the keyup event is called.\n * @memberof Selecto\n * @event keyup\n * @example\n * import Selecto from \"selecto\";\n *\n * const selecto = new Selecto({\n * container: document.body,\n * toggleContinueSelect: \"shift\";\n * keyContainer: window,\n * });\n *\n * selecto.on(\"keydown\", () => {\n * document.querySelector(\".button\").classList.add(\"selected\");\n * }).on(\"keyup\", () => {\n * document.querySelector(\".button\").classList.remove(\"selected\");\n * }).on(\"select\", e => {\n * e.added.forEach(el => {\n * el.classList.add(\"selected\");\n * });\n * e.removed.forEach(el => {\n * el.classList.remove(\"selected\");\n * });\n * });\n */\n this.trigger(\"keyup\", {});\n }\n private onBlur = () => {\n if (this.toggleContinueSelect && this.continueSelect) {\n this.trigger(\"keyup\", {});\n }\n }\n private onDocumentSelectStart = (e: any) => {\n if (!this.dragger.isFlag()) {\n return;\n }\n let dragContainer = this.dragContainer;\n\n if (dragContainer === window) {\n dragContainer = document.documentElement;\n }\n const containers = dragContainer instanceof Element\n ? [dragContainer] : [].slice.call(dragContainer) as Element[];\n const target = e.target;\n\n containers.some(container => {\n if (container === target || container.contains(target)) {\n e.preventDefault();\n return true;\n }\n });\n }\n}\n\ninterface Selecto extends Component, SelectoProperties {\n on(eventName: T, handlerToAttach: (event: SelectoEvents[T]) => any): this;\n on(eventName: string, handlerToAttach: (event: { [key: string]: any }) => any): this;\n on(events: { [key: string]: (event: { [key: string]: any }) => any }): this;\n}\n\nexport default Selecto;\n","import Selecto, * as modules from \"./index\";\n\nfor (const name in modules) {\n (Selecto as any)[name] = modules[name];\n}\n\nexport default Selecto;\n"],"names":["createElement","jsx","prevTarget","container","tag","children","attributes","className","style","el","document","name","setAttribute","elChildren","forEach","child","i","split","elStyle","appendChild","h","attrs","_i","_a","_b","_c","diffValue","prev","cur","func","getRect","e","distX","distY","datas","startX","startY","tx","Math","min","ty","width","abs","height","left","top","right","bottom","injector","CLASS_NAME","PROPERTIES","OPTIONS","__spreadArrays","OPTION_TYPES","target","dragContainer","selectableTargets","Array","selectByClick","Boolean","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","Number","scrollOptions","Object","checkInput","preventDefault","options","_super","_this","ChildrenDiffer","DragScroll","clickedTarget","clientX","clientY","inputEvent","getSelectableTargets","selectableRects","map","rect","getBoundingClientRect","startSelectedTargets","selectedTargets","pointTarget","elementFromPoint","hitRect","firstPassedTargets","hitTest","filter","contains","hasInsideTargets","length","isPreventSelect","getSelectedTargets","type","trigger","select","cssText","onDragEnd","dragScroll","dragStart","drag","check","dragEnd","selectEnd","sameCombiKey","dragger","isFlag","window","documentElement","containers","Element","slice","call","some","undefined","initElement","initDragScroll","setKeyController","differ","this","setKeyEvent","value","onDragStart","off","keycon","destroy","unset","injectResult","removeEvent","onDocumentSelectStart","touch","touches","changedTouches","dragEvent","KeyController","keydown","onKeyDown","keyup","onKeyUp","on","onBlur","querySelectorAll","parentNode","Dragger","dragstart","onDrag","dragend","addEvent","inject","selectRect","targets","rects","passedTargets","rectLeft","rectTop","rectRight","rectBottom","isStart","rectSize","testLeft","max","testRight","testTop","testBottom","push","rate","round","direction","offsetX","offsetY","scrollBy","list","prevList","added","removed","index","concat","selected","isDouble","afterAdded","afterRemoved","afterPrevList","afterList","isDragStart","combi","getCombi","key","every","indexOf","Selecto","prototype","property","enumerable","configurable","get","setter","set","defineProperty","Component","modules"],"mappings":";;;;;;;;uhkBAmBgBA,EACZC,EACAC,EACAC,OAEQC,QAAKC,aAAUC,eAAYC,cAAWC,UACxCC,EAAKP,GAAcQ,SAASV,cAAcI,OAE3C,IAAMO,KAAQL,EACfG,EAAGG,aAAaD,EAAML,EAAWK,QAE/BE,EAAaJ,EAAGJ,YACtBA,EAASS,QAAQ,SAACC,EAAOC,GACrBhB,EAAce,EAAOF,EAAWG,GAAgCP,KAEhEF,GACAA,EAAUU,MAAM,KAAKH,QAAQ,SAAAH,iBACPA,MAAJF,+FACGE,KAAJF,sDAIjBD,EAAO,KACDU,EAAUT,EAAGD,UACd,IAAMG,KAAQH,EACfU,EAAQP,GAAQH,EAAMG,UAGzBT,GAAcC,GACfA,EAAUgB,YAAYV,GAEnBA,WAEKW,GACZhB,EACAiB,oBACAC,mBAAAA,IAAAjB,wBAEMkB,QACFC,cACAC,gBAGG,CACHrB,MACAG,0B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ACAL,WAAYA,EACZpG,OACAJ,wBA0GR,SAAc/C,OAENG,UACA4C,eAEEI,EAAOpD,GAAQC,GAEjBc,QACAD,SACAH,UACAE,gBAECW,OAAO9C,MAAM4F,SACX,wDAEuBxD,SAAWC,eAC1BJ,eAAkBE,YAE3BiH,EAAgBjC,KAAKjC,QACvBR,EAAMhD,EAAMC,OAAQD,EAAME,OAAQF,EAAMsB,kBAAmBtB,EAAM8C,iBAC/DK,EAAkBsC,KAAK3B,mBAAmB4D,QAE3CzD,OAAOd,EAAiBH,EAAMJ,GACnC5C,EAAMmD,gBAAkBA,kBAmB5B,SAAqBtD,OACX+B,EAAuB,GAAGsH,OAAOzD,KAAKrD,QAAQR,sBAC9C8H,EAAQC,EAAS9J,EAAE+C,WAAY/C,EAAE+J,YAChChI,EAAqBiI,MAAM,SAAAD,UAA6B,EAAtBF,EAAMI,QAAQF,MA9iBzDG,0UApBM/I,KAAmB,SAACgJ,EAAWC,OACjC7L,EAA2B,CAC7B8L,YAAY,EACZC,cAAc,EACdC,sBACW3E,KAAKrD,QAAQ6H,KAGtBI,GAAkB,OAAOJ,mEAC3BD,EAAUK,GACVjM,EAAWkM,IAAM,SAAS3E,QACjB0E,GAAQ1E,IAGjBvH,EAAWkM,IAAM,SAAS3E,QACjBvD,QAAQ6H,GAAYtE,GAGjC1D,OAAOsI,eAAeP,EAAWC,EAAU7L,oEAEzC2L,IAAgBS,iFDuBA,CAClB,YACA,cACA,SACA,YACA,UACA,QACA,kBAMmB,CACnB,cACA,qBACA,mCEzEJ,IAAK,IAAM/L,MAAQgM,GACdV,GAAgBtL,IAAQgM,GAAQhM"} \ No newline at end of file diff --git a/packages/lit-selecto/package-lock.json b/packages/lit-selecto/package-lock.json index 35b8fcc..4dbdd71 100755 --- a/packages/lit-selecto/package-lock.json +++ b/packages/lit-selecto/package-lock.json @@ -1,6 +1,6 @@ { "name": "lit-selecto", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -676,9 +676,9 @@ } }, "selecto": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.2.0.tgz", - "integrity": "sha512-TLA8E5ycooH5DL/RTN27mhdVJvYD6StX0YCZKIkaFsOo53J2E9ghBBMkV6QHJrA3Bkm3iNn/qB731otIM4mqDA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.3.0.tgz", + "integrity": "sha512-sU5foLze7Qk4+neP74aXX/C5F3fxLhHLSBfY9JC5jGvymnQZQxSHB+ovdonwg61C0gVQHSt29Qzjas/vn0sSMw==", "requires": { "@daybrush/drag": "^0.18.6", "@daybrush/utils": "^0.10.5", diff --git a/packages/lit-selecto/package.json b/packages/lit-selecto/package.json index 55f52f0..06547f4 100755 --- a/packages/lit-selecto/package.json +++ b/packages/lit-selecto/package.json @@ -1,6 +1,6 @@ { "name": "lit-selecto", - "version": "1.2.0", + "version": "1.3.0", "types": "declaration/index.d.ts", "main": "dist/selecto.cjs.js", "module": "dist/selecto.esm.js", @@ -35,6 +35,6 @@ "typescript": "3.6.4" }, "dependencies": { - "selecto": "^1.2.0" + "selecto": "^1.3.0" } } diff --git a/packages/ngx-selecto/projects/ngx-selecto/package-lock.json b/packages/ngx-selecto/projects/ngx-selecto/package-lock.json index 1414d50..690a41b 100644 --- a/packages/ngx-selecto/projects/ngx-selecto/package-lock.json +++ b/packages/ngx-selecto/projects/ngx-selecto/package-lock.json @@ -1,6 +1,6 @@ { "name": "ngx-selecto", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -73,9 +73,9 @@ } }, "selecto": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.2.0.tgz", - "integrity": "sha512-TLA8E5ycooH5DL/RTN27mhdVJvYD6StX0YCZKIkaFsOo53J2E9ghBBMkV6QHJrA3Bkm3iNn/qB731otIM4mqDA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.3.0.tgz", + "integrity": "sha512-sU5foLze7Qk4+neP74aXX/C5F3fxLhHLSBfY9JC5jGvymnQZQxSHB+ovdonwg61C0gVQHSt29Qzjas/vn0sSMw==", "requires": { "@daybrush/drag": "^0.18.6", "@daybrush/utils": "^0.10.5", diff --git a/packages/ngx-selecto/projects/ngx-selecto/package.json b/packages/ngx-selecto/projects/ngx-selecto/package.json index b2adddf..e04baf4 100644 --- a/packages/ngx-selecto/projects/ngx-selecto/package.json +++ b/packages/ngx-selecto/projects/ngx-selecto/package.json @@ -1,6 +1,6 @@ { "name": "ngx-selecto", - "version": "1.2.0", + "version": "1.3.0", "description": "An Angular Selecto Component that allows you to select elements in the drag area using the mouse or touch.", "keywords": [ "select", @@ -25,6 +25,6 @@ "@angular/core": "^8.2.14" }, "dependencies": { - "selecto": "^1.2.0" + "selecto": "^1.3.0" } } diff --git a/packages/react-selecto/package-lock.json b/packages/react-selecto/package-lock.json index 1c62aed..588b4b8 100644 --- a/packages/react-selecto/package-lock.json +++ b/packages/react-selecto/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-selecto", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -13299,9 +13299,9 @@ "dev": true }, "selecto": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.2.0.tgz", - "integrity": "sha512-TLA8E5ycooH5DL/RTN27mhdVJvYD6StX0YCZKIkaFsOo53J2E9ghBBMkV6QHJrA3Bkm3iNn/qB731otIM4mqDA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.3.0.tgz", + "integrity": "sha512-sU5foLze7Qk4+neP74aXX/C5F3fxLhHLSBfY9JC5jGvymnQZQxSHB+ovdonwg61C0gVQHSt29Qzjas/vn0sSMw==", "requires": { "@daybrush/drag": "^0.18.6", "@daybrush/utils": "^0.10.5", diff --git a/packages/react-selecto/package.json b/packages/react-selecto/package.json index b111453..63be637 100644 --- a/packages/react-selecto/package.json +++ b/packages/react-selecto/package.json @@ -1,6 +1,6 @@ { "name": "react-selecto", - "version": "1.2.0", + "version": "1.3.0", "description": "A React Selecto Component that allows you to select elements in the drag area using the mouse or touch.", "main": "./dist/selecto.cjs.js", "module": "./dist/selecto.esm.js", @@ -43,7 +43,7 @@ "typescript": "^3.4.5" }, "dependencies": { - "selecto": "^1.2.0" + "selecto": "^1.3.0" }, "browserslist": { "production": [ diff --git a/packages/svelte-selecto/package-lock.json b/packages/svelte-selecto/package-lock.json index cb8ce67..ed53ef6 100644 --- a/packages/svelte-selecto/package-lock.json +++ b/packages/svelte-selecto/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte-selecto", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2230,9 +2230,9 @@ } }, "selecto": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.2.0.tgz", - "integrity": "sha512-TLA8E5ycooH5DL/RTN27mhdVJvYD6StX0YCZKIkaFsOo53J2E9ghBBMkV6QHJrA3Bkm3iNn/qB731otIM4mqDA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.3.0.tgz", + "integrity": "sha512-sU5foLze7Qk4+neP74aXX/C5F3fxLhHLSBfY9JC5jGvymnQZQxSHB+ovdonwg61C0gVQHSt29Qzjas/vn0sSMw==", "requires": { "@daybrush/drag": "^0.18.6", "@daybrush/utils": "^0.10.5", diff --git a/packages/svelte-selecto/package.json b/packages/svelte-selecto/package.json index 9212e90..3d55e70 100644 --- a/packages/svelte-selecto/package.json +++ b/packages/svelte-selecto/package.json @@ -1,6 +1,6 @@ { "name": "svelte-selecto", - "version": "1.2.0", + "version": "1.3.0", "description": "A Svelte Selecto Component that allows you to select elements in the drag area using the mouse or touch.", "main": "./dist/selecto.cjs.js", "module": "./dist/selecto.esm.js", @@ -44,6 +44,6 @@ "typescript": "^3.7.4" }, "dependencies": { - "selecto": "^1.2.0" + "selecto": "^1.3.0" } } diff --git a/packages/vue-selecto/package-lock.json b/packages/vue-selecto/package-lock.json index bc85ae5..93a07e6 100644 --- a/packages/vue-selecto/package-lock.json +++ b/packages/vue-selecto/package-lock.json @@ -1,6 +1,6 @@ { "name": "vue-selecto", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -7804,9 +7804,9 @@ "dev": true }, "selecto": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.2.0.tgz", - "integrity": "sha512-TLA8E5ycooH5DL/RTN27mhdVJvYD6StX0YCZKIkaFsOo53J2E9ghBBMkV6QHJrA3Bkm3iNn/qB731otIM4mqDA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.3.0.tgz", + "integrity": "sha512-sU5foLze7Qk4+neP74aXX/C5F3fxLhHLSBfY9JC5jGvymnQZQxSHB+ovdonwg61C0gVQHSt29Qzjas/vn0sSMw==", "requires": { "@daybrush/drag": "^0.18.6", "@daybrush/utils": "^0.10.5", diff --git a/packages/vue-selecto/package.json b/packages/vue-selecto/package.json index cb0a1e1..2ae75d3 100755 --- a/packages/vue-selecto/package.json +++ b/packages/vue-selecto/package.json @@ -1,6 +1,6 @@ { "name": "vue-selecto", - "version": "1.2.0", + "version": "1.3.0", "types": "declaration/index.d.ts", "main": "dist/selecto.cjs.js", "module": "dist/selecto.esm.js", @@ -30,7 +30,7 @@ }, "homepage": "https://daybrush.com/selecto", "dependencies": { - "selecto": "^1.2.0", + "selecto": "^1.3.0", "vue-property-decorator": "^8.1.0" }, "devDependencies": { diff --git a/storybook/package-lock.json b/storybook/package-lock.json index 79b7dab..9331b54 100644 --- a/storybook/package-lock.json +++ b/storybook/package-lock.json @@ -7542,9 +7542,9 @@ "dev": true }, "infinite-viewer": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/infinite-viewer/-/infinite-viewer-0.4.2.tgz", - "integrity": "sha512-kKRvO912e+tHJmhXA3wiL2NJFNytS6rJFCVKn9xsqL+7OcsGrNt0fc6ss6ieJhfJQW6fBa5r1fNfJ1jFonZl4A==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/infinite-viewer/-/infinite-viewer-0.4.3.tgz", + "integrity": "sha512-AIP4PFpOg62MtfpQtMtbbzZtJcaOcV+IaMB86hHsRt0mQAvR866q71JnaoUGepz3KOTccTVW2P51jUG71YgWng==", "requires": { "@daybrush/drag": "^0.15.0", "@daybrush/utils": "^0.10.4", @@ -10716,11 +10716,11 @@ } }, "react-infinite-viewer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/react-infinite-viewer/-/react-infinite-viewer-0.4.0.tgz", - "integrity": "sha512-kSqByMjay1LR0ivGnRs13Ua86LKoS5j/hRFSED7dkJesu6eH3SgePK3Lu259QgTmh9j82ES1r9FjEsI2+En5rQ==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/react-infinite-viewer/-/react-infinite-viewer-0.4.1.tgz", + "integrity": "sha512-U99EsEJ9QcVNrtFlF2TIS19BdHxXXB7lxC3MuwYAPfVJNNzHkfiH5MxHKBf8hojMzbXrhz9KxnMGcaSW99xWAQ==", "requires": { - "infinite-viewer": "^0.4.2" + "infinite-viewer": "^0.4.3" } }, "react-input-autosize": { @@ -10806,11 +10806,11 @@ } }, "react-selecto": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/react-selecto/-/react-selecto-1.2.0.tgz", - "integrity": "sha512-mXc7OxwGzMqzxSisUQ6fwGXvhrpyOTXbVilS77IAaB8ERiaCNE51gbLpfBKMNTXuLiYaRrWfTqExUzQ8tg7fsQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/react-selecto/-/react-selecto-1.3.0.tgz", + "integrity": "sha512-vQ/nIbY4djjBKl3uj+crUFYEXNEdaEcaREtl7wk6/FoWy1uXPvIKTsjjmJyqjlLY25Uo1nBsRK8XDyBB6EfI3g==", "requires": { - "selecto": "^1.2.0" + "selecto": "^1.3.0" } }, "react-sizeme": { @@ -11379,9 +11379,9 @@ "optional": true }, "selecto": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.2.0.tgz", - "integrity": "sha512-TLA8E5ycooH5DL/RTN27mhdVJvYD6StX0YCZKIkaFsOo53J2E9ghBBMkV6QHJrA3Bkm3iNn/qB731otIM4mqDA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/selecto/-/selecto-1.3.0.tgz", + "integrity": "sha512-sU5foLze7Qk4+neP74aXX/C5F3fxLhHLSBfY9JC5jGvymnQZQxSHB+ovdonwg61C0gVQHSt29Qzjas/vn0sSMw==", "requires": { "@daybrush/drag": "^0.18.6", "@daybrush/utils": "^0.10.5", diff --git a/storybook/package.json b/storybook/package.json index d3830b7..3f082af 100644 --- a/storybook/package.json +++ b/storybook/package.json @@ -13,9 +13,9 @@ "license": "MIT", "dependencies": { "raw-loader": "^4.0.0", - "react-infinite-viewer": "^0.4.0", + "react-infinite-viewer": "^0.4.1", "react-moveable": "^0.20.6", - "react-selecto": "^1.2.0", + "react-selecto": "^1.3.0", "storybook-addon-preview": "^1.1.1-rc2" }, "devDependencies": {