1/*! 2 * (The MIT License) 3 * 4 * Copyright (c) 2012-2014 Marcin Warpechowski 5 * Copyright (c) 2015 Handsoncode sp. z o.o. <hello@handsoncode.net> 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining 8 * a copy of this software and associated documentation files (the 9 * 'Software'), to deal in the Software without restriction, including 10 * without limitation the rights to use, copy, modify, merge, publish, 11 * distribute, sublicense, and/or sell copies of the Software, and to 12 * permit persons to whom the Software is furnished to do so, subject to 13 * the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be 16 * included in all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 * Version: 0.34.1 27 * Date: Thu Sep 07 2017 15:34:10 GMT+0200 (CEST) 28 */ 29(function webpackUniversalModuleDefinition(root, factory) { 30 if(typeof exports === 'object' && typeof module === 'object') 31 module.exports = factory(); 32 else if(typeof define === 'function' && define.amd) 33 define("Handsontable", [], factory); 34 else if(typeof exports === 'object') 35 exports["Handsontable"] = factory(); 36 else 37 root["Handsontable"] = factory(); 38})(this, function() { 39return /******/ (function(modules) { // webpackBootstrap 40/******/ // The module cache 41/******/ var installedModules = {}; 42/******/ 43/******/ // The require function 44/******/ function __webpack_require__(moduleId) { 45/******/ 46/******/ // Check if module is in cache 47/******/ if(installedModules[moduleId]) { 48/******/ return installedModules[moduleId].exports; 49/******/ } 50/******/ // Create a new module (and put it into the cache) 51/******/ var module = installedModules[moduleId] = { 52/******/ i: moduleId, 53/******/ l: false, 54/******/ exports: {} 55/******/ }; 56/******/ 57/******/ // Execute the module function 58/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 59/******/ 60/******/ // Flag the module as loaded 61/******/ module.l = true; 62/******/ 63/******/ // Return the exports of the module 64/******/ return module.exports; 65/******/ } 66/******/ 67/******/ 68/******/ // expose the modules object (__webpack_modules__) 69/******/ __webpack_require__.m = modules; 70/******/ 71/******/ // expose the module cache 72/******/ __webpack_require__.c = installedModules; 73/******/ 74/******/ // identity function for calling harmony imports with the correct context 75/******/ __webpack_require__.i = function(value) { return value; }; 76/******/ 77/******/ // define getter function for harmony exports 78/******/ __webpack_require__.d = function(exports, name, getter) { 79/******/ if(!__webpack_require__.o(exports, name)) { 80/******/ Object.defineProperty(exports, name, { 81/******/ configurable: false, 82/******/ enumerable: true, 83/******/ get: getter 84/******/ }); 85/******/ } 86/******/ }; 87/******/ 88/******/ // getDefaultExport function for compatibility with non-harmony modules 89/******/ __webpack_require__.n = function(module) { 90/******/ var getter = module && module.__esModule ? 91/******/ function getDefault() { return module['default']; } : 92/******/ function getModuleExports() { return module; }; 93/******/ __webpack_require__.d(getter, 'a', getter); 94/******/ return getter; 95/******/ }; 96/******/ 97/******/ // Object.prototype.hasOwnProperty.call 98/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 99/******/ 100/******/ // __webpack_public_path__ 101/******/ __webpack_require__.p = ""; 102/******/ 103/******/ // Load entry module and return exports 104/******/ return __webpack_require__(__webpack_require__.s = 332); 105/******/ }) 106/************************************************************************/ 107/******/ ([ 108/* 0 */ 109/***/ (function(module, exports, __webpack_require__) { 110 111"use strict"; 112 113 114exports.__esModule = true; 115exports.HTML_CHARACTERS = undefined; 116exports.getParent = getParent; 117exports.closest = closest; 118exports.closestDown = closestDown; 119exports.isChildOf = isChildOf; 120exports.isChildOfWebComponentTable = isChildOfWebComponentTable; 121exports.polymerWrap = polymerWrap; 122exports.polymerUnwrap = polymerUnwrap; 123exports.index = index; 124exports.overlayContainsElement = overlayContainsElement; 125exports.hasClass = hasClass; 126exports.addClass = addClass; 127exports.removeClass = removeClass; 128exports.removeTextNodes = removeTextNodes; 129exports.empty = empty; 130exports.fastInnerHTML = fastInnerHTML; 131exports.fastInnerText = fastInnerText; 132exports.isVisible = isVisible; 133exports.offset = offset; 134exports.getWindowScrollTop = getWindowScrollTop; 135exports.getWindowScrollLeft = getWindowScrollLeft; 136exports.getScrollTop = getScrollTop; 137exports.getScrollLeft = getScrollLeft; 138exports.getScrollableElement = getScrollableElement; 139exports.getTrimmingContainer = getTrimmingContainer; 140exports.getStyle = getStyle; 141exports.getComputedStyle = getComputedStyle; 142exports.outerWidth = outerWidth; 143exports.outerHeight = outerHeight; 144exports.innerHeight = innerHeight; 145exports.innerWidth = innerWidth; 146exports.addEvent = addEvent; 147exports.removeEvent = removeEvent; 148exports.getCaretPosition = getCaretPosition; 149exports.getSelectionEndPosition = getSelectionEndPosition; 150exports.getSelectionText = getSelectionText; 151exports.setCaretPosition = setCaretPosition; 152exports.getScrollbarWidth = getScrollbarWidth; 153exports.hasVerticalScrollbar = hasVerticalScrollbar; 154exports.hasHorizontalScrollbar = hasHorizontalScrollbar; 155exports.setOverlayPosition = setOverlayPosition; 156exports.getCssTransform = getCssTransform; 157exports.resetCssTransform = resetCssTransform; 158exports.isInput = isInput; 159exports.isOutsideInput = isOutsideInput; 160 161var _browser = __webpack_require__(22); 162 163var _feature = __webpack_require__(34); 164 165/** 166 * Get the parent of the specified node in the DOM tree. 167 * 168 * @param {HTMLElement} element Element from which traversing is started. 169 * @param {Number} [level=0] Traversing deep level. 170 * @return {HTMLElement|null} 171 */ 172function getParent(element) { 173 var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 174 175 var iteration = -1; 176 var parent = null; 177 178 while (element != null) { 179 if (iteration === level) { 180 parent = element; 181 break; 182 } 183 184 if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { 185 element = element.host; 186 } else { 187 iteration++; 188 element = element.parentNode; 189 } 190 } 191 192 return parent; 193} 194 195/** 196 * Goes up the DOM tree (including given element) until it finds an element that matches the nodes or nodes name. 197 * This method goes up through web components. 198 * 199 * @param {HTMLElement} element Element from which traversing is started 200 * @param {Array} nodes Array of elements or Array of elements name 201 * @param {HTMLElement} [until] 202 * @returns {HTMLElement|null} 203 */ 204function closest(element, nodes, until) { 205 while (element != null && element !== until) { 206 if (element.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(element.nodeName) > -1 || nodes.indexOf(element) > -1)) { 207 return element; 208 } 209 if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { 210 element = element.host; 211 } else { 212 element = element.parentNode; 213 } 214 } 215 216 return null; 217} 218 219/** 220 * Goes "down" the DOM tree (including given element) until it finds an element that matches the nodes or nodes name. 221 * 222 * @param {HTMLElement} element Element from which traversing is started 223 * @param {Array} nodes Array of elements or Array of elements name 224 * @param {HTMLElement} [until] 225 * @returns {HTMLElement|null} 226 */ 227function closestDown(element, nodes, until) { 228 var matched = []; 229 230 while (element) { 231 element = closest(element, nodes, until); 232 233 if (!element || until && !until.contains(element)) { 234 break; 235 } 236 matched.push(element); 237 238 if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { 239 element = element.host; 240 } else { 241 element = element.parentNode; 242 } 243 } 244 var length = matched.length; 245 246 return length ? matched[length - 1] : null; 247} 248 249/** 250 * Goes up the DOM tree and checks if element is child of another element. 251 * 252 * @param child Child element 253 * @param {Object|String} parent Parent element OR selector of the parent element. 254 * If string provided, function returns `true` for the first occurrence of element with that class. 255 * @returns {Boolean} 256 */ 257function isChildOf(child, parent) { 258 var node = child.parentNode; 259 var queriedParents = []; 260 261 if (typeof parent === 'string') { 262 queriedParents = Array.prototype.slice.call(document.querySelectorAll(parent), 0); 263 } else { 264 queriedParents.push(parent); 265 } 266 267 while (node != null) { 268 if (queriedParents.indexOf(node) > -1) { 269 return true; 270 } 271 node = node.parentNode; 272 } 273 274 return false; 275} 276 277/** 278 * Check if an element is part of `hot-table` web component. 279 * 280 * @param {Element} element 281 * @returns {Boolean} 282 */ 283function isChildOfWebComponentTable(element) { 284 var hotTableName = 'hot-table', 285 result = false, 286 parentNode; 287 288 parentNode = polymerWrap(element); 289 290 function isHotTable(element) { 291 return element.nodeType === Node.ELEMENT_NODE && element.nodeName === hotTableName.toUpperCase(); 292 } 293 294 while (parentNode != null) { 295 if (isHotTable(parentNode)) { 296 result = true; 297 break; 298 } else if (parentNode.host && parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { 299 result = isHotTable(parentNode.host); 300 301 if (result) { 302 break; 303 } 304 parentNode = parentNode.host; 305 } 306 parentNode = parentNode.parentNode; 307 } 308 309 return result; 310} 311 312/** 313 * Wrap element into polymer/webcomponent container if exists 314 * 315 * @param element 316 * @returns {*} 317 */ 318function polymerWrap(element) { 319 /* global Polymer */ 320 return typeof Polymer !== 'undefined' && typeof wrap === 'function' ? wrap(element) : element; 321} 322 323/** 324 * Unwrap element from polymer/webcomponent container if exists 325 * 326 * @param element 327 * @returns {*} 328 */ 329function polymerUnwrap(element) { 330 /* global Polymer */ 331 return typeof Polymer !== 'undefined' && typeof unwrap === 'function' ? unwrap(element) : element; 332} 333 334/** 335 * Counts index of element within its parent 336 * WARNING: for performance reasons, assumes there are only element nodes (no text nodes). This is true for Walkotnable 337 * Otherwise would need to check for nodeType or use previousElementSibling 338 * 339 * @see http://jsperf.com/sibling-index/10 340 * @param {Element} element 341 * @return {Number} 342 */ 343function index(element) { 344 var i = 0; 345 346 if (element.previousSibling) { 347 /* eslint-disable no-cond-assign */ 348 while (element = element.previousSibling) { 349 ++i; 350 } 351 } 352 353 return i; 354} 355 356/** 357 * Check if the provided overlay contains the provided element 358 * 359 * @param {String} overlay 360 * @param {HTMLElement} element 361 * @returns {boolean} 362 */ 363function overlayContainsElement(overlayType, element) { 364 var overlayElement = document.querySelector('.ht_clone_' + overlayType); 365 return overlayElement ? overlayElement.contains(element) : null; 366} 367 368var classListSupport = !!document.documentElement.classList; 369var _hasClass, _addClass, _removeClass; 370 371function filterEmptyClassNames(classNames) { 372 var len = 0, 373 result = []; 374 375 if (!classNames || !classNames.length) { 376 return result; 377 } 378 while (classNames[len]) { 379 result.push(classNames[len]); 380 len++; 381 } 382 383 return result; 384} 385 386if (classListSupport) { 387 var isSupportMultipleClassesArg = function () { 388 var element = document.createElement('div'); 389 390 element.classList.add('test', 'test2'); 391 392 return element.classList.contains('test2'); 393 }(); 394 395 _hasClass = function _hasClass(element, className) { 396 if (element.classList === void 0 || className === '') { 397 return false; 398 } 399 400 return element.classList.contains(className); 401 }; 402 403 _addClass = function _addClass(element, className) { 404 var len = 0; 405 406 if (typeof className === 'string') { 407 className = className.split(' '); 408 } 409 className = filterEmptyClassNames(className); 410 411 if (isSupportMultipleClassesArg) { 412 element.classList.add.apply(element.classList, className); 413 } else { 414 while (className && className[len]) { 415 element.classList.add(className[len]); 416 len++; 417 } 418 } 419 }; 420 421 _removeClass = function _removeClass(element, className) { 422 var len = 0; 423 424 if (typeof className === 'string') { 425 className = className.split(' '); 426 } 427 className = filterEmptyClassNames(className); 428 429 if (isSupportMultipleClassesArg) { 430 element.classList.remove.apply(element.classList, className); 431 } else { 432 while (className && className[len]) { 433 element.classList.remove(className[len]); 434 len++; 435 } 436 } 437 }; 438} else { 439 var createClassNameRegExp = function createClassNameRegExp(className) { 440 return new RegExp('(\\s|^)' + className + '(\\s|$)'); 441 }; 442 443 _hasClass = function _hasClass(element, className) { 444 // http://snipplr.com/view/3561/addclass-removeclass-hasclass/ 445 return element.className !== void 0 && element.className.test(createClassNameRegExp(className)); 446 }; 447 448 _addClass = function _addClass(element, className) { 449 var len = 0, 450 _className = element.className; 451 452 if (typeof className === 'string') { 453 className = className.split(' '); 454 } 455 if (_className === '') { 456 _className = className.join(' '); 457 } else { 458 while (className && className[len]) { 459 if (!createClassNameRegExp(className[len]).test(_className)) { 460 _className += ' ' + className[len]; 461 } 462 len++; 463 } 464 } 465 element.className = _className; 466 }; 467 468 _removeClass = function _removeClass(element, className) { 469 var len = 0, 470 _className = element.className; 471 472 if (typeof className === 'string') { 473 className = className.split(' '); 474 } 475 while (className && className[len]) { 476 // String.prototype.trim is defined in polyfill.js 477 _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim(); 478 len++; 479 } 480 if (element.className !== _className) { 481 element.className = _className; 482 } 483 }; 484} 485 486/** 487 * Checks if element has class name 488 * 489 * @param {HTMLElement} element 490 * @param {String} className Class name to check 491 * @returns {Boolean} 492 */ 493function hasClass(element, className) { 494 return _hasClass(element, className); 495} 496 497/** 498 * Add class name to an element 499 * 500 * @param {HTMLElement} element 501 * @param {String|Array} className Class name as string or array of strings 502 */ 503function addClass(element, className) { 504 return _addClass(element, className); 505} 506 507/** 508 * Remove class name from an element 509 * 510 * @param {HTMLElement} element 511 * @param {String|Array} className Class name as string or array of strings 512 */ 513function removeClass(element, className) { 514 return _removeClass(element, className); 515} 516 517function removeTextNodes(element, parent) { 518 if (element.nodeType === 3) { 519 parent.removeChild(element); // bye text nodes! 520 } else if (['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR'].indexOf(element.nodeName) > -1) { 521 var childs = element.childNodes; 522 for (var i = childs.length - 1; i >= 0; i--) { 523 removeTextNodes(childs[i], element); 524 } 525 } 526} 527 528/** 529 * Remove childs function 530 * WARNING - this doesn't unload events and data attached by jQuery 531 * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/9 532 * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/11 - no siginificant improvement with Chrome remove() method 533 * 534 * @param element 535 * @returns {void} 536 */ 537// 538function empty(element) { 539 var child; 540 /* eslint-disable no-cond-assign */ 541 while (child = element.lastChild) { 542 element.removeChild(child); 543 } 544} 545 546var HTML_CHARACTERS = exports.HTML_CHARACTERS = /(<(.*)>|&(.*);)/; 547 548/** 549 * Insert content into element trying avoid innerHTML method. 550 * @return {void} 551 */ 552function fastInnerHTML(element, content) { 553 if (HTML_CHARACTERS.test(content)) { 554 element.innerHTML = content; 555 } else { 556 fastInnerText(element, content); 557 } 558} 559 560/** 561 * Insert text content into element 562 * @return {void} 563 */ 564 565var textContextSupport = !!document.createTextNode('test').textContent; 566 567function fastInnerText(element, content) { 568 var child = element.firstChild; 569 570 if (child && child.nodeType === 3 && child.nextSibling === null) { 571 // fast lane - replace existing text node 572 573 if (textContextSupport) { 574 // http://jsperf.com/replace-text-vs-reuse 575 child.textContent = content; 576 } else { 577 // http://jsperf.com/replace-text-vs-reuse 578 child.data = content; 579 } 580 } else { 581 // slow lane - empty element and insert a text node 582 empty(element); 583 element.appendChild(document.createTextNode(content)); 584 } 585} 586 587/** 588 * Returns true if element is attached to the DOM and visible, false otherwise 589 * @param elem 590 * @returns {boolean} 591 */ 592function isVisible(elem) { 593 var next = elem; 594 595 while (polymerUnwrap(next) !== document.documentElement) { 596 // until <html> reached 597 if (next === null) { 598 // parent detached from DOM 599 return false; 600 } else if (next.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { 601 if (next.host) { 602 // this is Web Components Shadow DOM 603 // see: http://w3c.github.io/webcomponents/spec/shadow/#encapsulation 604 // according to spec, should be if (next.ownerDocument !== window.document), but that doesn't work yet 605 if (next.host.impl) { 606 // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features disabled 607 return isVisible(next.host.impl); 608 } else if (next.host) { 609 // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features enabled 610 return isVisible(next.host); 611 } 612 throw new Error('Lost in Web Components world'); 613 } else { 614 return false; // this is a node detached from document in IE8 615 } 616 } else if (next.style.display === 'none') { 617 return false; 618 } 619 next = next.parentNode; 620 } 621 622 return true; 623} 624 625/** 626 * Returns elements top and left offset relative to the document. Function is not compatible with jQuery offset. 627 * 628 * @param {HTMLElement} elem 629 * @return {Object} Returns object with `top` and `left` props 630 */ 631function offset(elem) { 632 var offsetLeft, offsetTop, lastElem, docElem, box; 633 634 docElem = document.documentElement; 635 636 if ((0, _feature.hasCaptionProblem)() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') { 637 // fixes problem with Firefox ignoring <caption> in TABLE offset (see also export outerHeight) 638 // http://jsperf.com/offset-vs-getboundingclientrect/8 639 box = elem.getBoundingClientRect(); 640 641 return { 642 top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), 643 left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0) 644 }; 645 } 646 offsetLeft = elem.offsetLeft; 647 offsetTop = elem.offsetTop; 648 lastElem = elem; 649 650 /* eslint-disable no-cond-assign */ 651 while (elem = elem.offsetParent) { 652 // from my observation, document.body always has scrollLeft/scrollTop == 0 653 if (elem === document.body) { 654 break; 655 } 656 offsetLeft += elem.offsetLeft; 657 offsetTop += elem.offsetTop; 658 lastElem = elem; 659 } 660 661 // slow - http://jsperf.com/offset-vs-getboundingclientrect/6 662 if (lastElem && lastElem.style.position === 'fixed') { 663 // if(lastElem !== document.body) { //faster but does gives false positive in Firefox 664 offsetLeft += window.pageXOffset || docElem.scrollLeft; 665 offsetTop += window.pageYOffset || docElem.scrollTop; 666 } 667 668 return { 669 left: offsetLeft, 670 top: offsetTop 671 }; 672} 673 674/** 675 * Returns the document's scrollTop property. 676 * 677 * @returns {Number} 678 */ 679function getWindowScrollTop() { 680 var res = window.scrollY; 681 682 if (res === void 0) { 683 // IE8-11 684 res = document.documentElement.scrollTop; 685 } 686 687 return res; 688} 689 690/** 691 * Returns the document's scrollLeft property. 692 * 693 * @returns {Number} 694 */ 695function getWindowScrollLeft() { 696 var res = window.scrollX; 697 698 if (res === void 0) { 699 // IE8-11 700 res = document.documentElement.scrollLeft; 701 } 702 703 return res; 704} 705 706/** 707 * Returns the provided element's scrollTop property. 708 * 709 * @param element 710 * @returns {Number} 711 */ 712function getScrollTop(element) { 713 if (element === window) { 714 return getWindowScrollTop(); 715 } 716 return element.scrollTop; 717} 718 719/** 720 * Returns the provided element's scrollLeft property. 721 * 722 * @param element 723 * @returns {Number} 724 */ 725function getScrollLeft(element) { 726 if (element === window) { 727 return getWindowScrollLeft(); 728 } 729 return element.scrollLeft; 730} 731 732/** 733 * Returns a DOM element responsible for scrolling of the provided element. 734 * 735 * @param {HTMLElement} element 736 * @returns {HTMLElement} Element's scrollable parent 737 */ 738function getScrollableElement(element) { 739 var el = element.parentNode, 740 props = ['auto', 'scroll'], 741 overflow, 742 overflowX, 743 overflowY, 744 computedStyle = '', 745 computedOverflow = '', 746 computedOverflowY = '', 747 computedOverflowX = ''; 748 749 while (el && el.style && document.body !== el) { 750 overflow = el.style.overflow; 751 overflowX = el.style.overflowX; 752 overflowY = el.style.overflowY; 753 754 if (overflow == 'scroll' || overflowX == 'scroll' || overflowY == 'scroll') { 755 return el; 756 } else if (window.getComputedStyle) { 757 computedStyle = window.getComputedStyle(el); 758 computedOverflow = computedStyle.getPropertyValue('overflow'); 759 computedOverflowY = computedStyle.getPropertyValue('overflow-y'); 760 computedOverflowX = computedStyle.getPropertyValue('overflow-x'); 761 762 if (computedOverflow === 'scroll' || computedOverflowX === 'scroll' || computedOverflowY === 'scroll') { 763 return el; 764 } 765 } 766 767 if (el.clientHeight <= el.scrollHeight && (props.indexOf(overflowY) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowY) !== -1)) { 768 return el; 769 } 770 if (el.clientWidth <= el.scrollWidth && (props.indexOf(overflowX) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowX) !== -1)) { 771 return el; 772 } 773 el = el.parentNode; 774 } 775 776 return window; 777} 778 779/** 780 * Returns a DOM element responsible for trimming the provided element. 781 * 782 * @param {HTMLElement} base Base element 783 * @returns {HTMLElement} Base element's trimming parent 784 */ 785function getTrimmingContainer(base) { 786 var el = base.parentNode; 787 788 while (el && el.style && document.body !== el) { 789 if (el.style.overflow !== 'visible' && el.style.overflow !== '') { 790 return el; 791 } else if (window.getComputedStyle) { 792 var computedStyle = window.getComputedStyle(el); 793 794 if (computedStyle.getPropertyValue('overflow') !== 'visible' && computedStyle.getPropertyValue('overflow') !== '') { 795 return el; 796 } 797 } 798 799 el = el.parentNode; 800 } 801 802 return window; 803} 804 805/** 806 * Returns a style property for the provided element. (Be it an inline or external style). 807 * 808 * @param {HTMLElement} element 809 * @param {String} prop Wanted property 810 * @returns {String|undefined} Element's style property 811 */ 812function getStyle(element, prop) { 813 /* eslint-disable */ 814 if (!element) { 815 return; 816 } else if (element === window) { 817 if (prop === 'width') { 818 return window.innerWidth + 'px'; 819 } else if (prop === 'height') { 820 return window.innerHeight + 'px'; 821 } 822 823 return; 824 } 825 826 var styleProp = element.style[prop], 827 computedStyle; 828 829 if (styleProp !== '' && styleProp !== void 0) { 830 return styleProp; 831 } else { 832 computedStyle = getComputedStyle(element); 833 834 if (computedStyle[prop] !== '' && computedStyle[prop] !== void 0) { 835 return computedStyle[prop]; 836 } 837 } 838} 839 840/** 841 * Returns a computed style object for the provided element. (Needed if style is declared in external stylesheet). 842 * 843 * @param element 844 * @returns {IEElementStyle|CssStyle} Elements computed style object 845 */ 846function getComputedStyle(element) { 847 return element.currentStyle || document.defaultView.getComputedStyle(element); 848} 849 850/** 851 * Returns the element's outer width. 852 * 853 * @param element 854 * @returns {number} Element's outer width 855 */ 856function outerWidth(element) { 857 return element.offsetWidth; 858} 859 860/** 861 * Returns the element's outer height 862 * 863 * @param elem 864 * @returns {number} Element's outer height 865 */ 866function outerHeight(elem) { 867 if ((0, _feature.hasCaptionProblem)() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') { 868 // fixes problem with Firefox ignoring <caption> in TABLE.offsetHeight 869 // jQuery (1.10.1) still has this unsolved 870 // may be better to just switch to getBoundingClientRect 871 // http://bililite.com/blog/2009/03/27/finding-the-size-of-a-table/ 872 // http://lists.w3.org/Archives/Public/www-style/2009Oct/0089.html 873 // http://bugs.jquery.com/ticket/2196 874 // http://lists.w3.org/Archives/Public/www-style/2009Oct/0140.html#start140 875 return elem.offsetHeight + elem.firstChild.offsetHeight; 876 } 877 878 return elem.offsetHeight; 879} 880 881/** 882 * Returns the element's inner height. 883 * 884 * @param element 885 * @returns {number} Element's inner height 886 */ 887function innerHeight(element) { 888 return element.clientHeight || element.innerHeight; 889} 890 891/** 892 * Returns the element's inner width. 893 * 894 * @param element 895 * @returns {number} Element's inner width 896 */ 897function innerWidth(element) { 898 return element.clientWidth || element.innerWidth; 899} 900 901function addEvent(element, event, callback) { 902 if (window.addEventListener) { 903 element.addEventListener(event, callback, false); 904 } else { 905 element.attachEvent('on' + event, callback); 906 } 907} 908 909function removeEvent(element, event, callback) { 910 if (window.removeEventListener) { 911 element.removeEventListener(event, callback, false); 912 } else { 913 element.detachEvent('on' + event, callback); 914 } 915} 916 917/** 918 * Returns caret position in text input 919 * 920 * @author http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea 921 * @return {Number} 922 */ 923function getCaretPosition(el) { 924 if (el.selectionStart) { 925 return el.selectionStart; 926 } else if (document.selection) { 927 // IE8 928 el.focus(); 929 930 var r = document.selection.createRange(); 931 932 if (r == null) { 933 return 0; 934 } 935 var re = el.createTextRange(); 936 var rc = re.duplicate(); 937 938 re.moveToBookmark(r.getBookmark()); 939 rc.setEndPoint('EndToStart', re); 940 941 return rc.text.length; 942 } 943 944 return 0; 945} 946 947/** 948 * Returns end of the selection in text input 949 * 950 * @return {Number} 951 */ 952function getSelectionEndPosition(el) { 953 if (el.selectionEnd) { 954 return el.selectionEnd; 955 } else if (document.selection) { 956 // IE8 957 var r = document.selection.createRange(); 958 959 if (r == null) { 960 return 0; 961 } 962 var re = el.createTextRange(); 963 964 return re.text.indexOf(r.text) + r.text.length; 965 } 966 967 return 0; 968} 969 970/** 971 * Returns text under selection. 972 * 973 * @returns {String} 974 */ 975function getSelectionText() { 976 var text = ''; 977 978 if (window.getSelection) { 979 text = window.getSelection().toString(); 980 } else if (document.selection && document.selection.type !== 'Control') { 981 text = document.selection.createRange().text; 982 } 983 984 return text; 985} 986 987/** 988 * Sets caret position in text input. 989 * 990 * @author http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/ 991 * @param {Element} element 992 * @param {Number} pos 993 * @param {Number} endPos 994 */ 995function setCaretPosition(element, pos, endPos) { 996 if (endPos === void 0) { 997 endPos = pos; 998 } 999 if (element.setSelectionRange) { 1000 element.focus(); 1001 1002 try { 1003 element.setSelectionRange(pos, endPos); 1004 } catch (err) { 1005 var elementParent = element.parentNode; 1006 var parentDisplayValue = elementParent.style.display; 1007 elementParent.style.display = 'block'; 1008 element.setSelectionRange(pos, endPos); 1009 elementParent.style.display = parentDisplayValue; 1010 } 1011 } else if (element.createTextRange) { 1012 // IE8 1013 var range = element.createTextRange(); 1014 range.collapse(true); 1015 range.moveEnd('character', endPos); 1016 range.moveStart('character', pos); 1017 range.select(); 1018 } 1019} 1020 1021var cachedScrollbarWidth; 1022 1023// http://stackoverflow.com/questions/986937/how-can-i-get-the-browsers-scrollbar-sizes 1024function walkontableCalculateScrollbarWidth() { 1025 var inner = document.createElement('div'); 1026 inner.style.height = '200px'; 1027 inner.style.width = '100%'; 1028 1029 var outer = document.createElement('div'); 1030 outer.style.boxSizing = 'content-box'; 1031 outer.style.height = '150px'; 1032 outer.style.left = '0px'; 1033 outer.style.overflow = 'hidden'; 1034 outer.style.position = 'absolute'; 1035 outer.style.top = '0px'; 1036 outer.style.width = '200px'; 1037 outer.style.visibility = 'hidden'; 1038 outer.appendChild(inner); 1039 1040 (document.body || document.documentElement).appendChild(outer); 1041 var w1 = inner.offsetWidth; 1042 outer.style.overflow = 'scroll'; 1043 var w2 = inner.offsetWidth; 1044 if (w1 == w2) { 1045 w2 = outer.clientWidth; 1046 } 1047 1048 (document.body || document.documentElement).removeChild(outer); 1049 1050 return w1 - w2; 1051} 1052 1053/** 1054 * Returns the computed width of the native browser scroll bar. 1055 * 1056 * @return {Number} width 1057 */ 1058function getScrollbarWidth() { 1059 if (cachedScrollbarWidth === void 0) { 1060 cachedScrollbarWidth = walkontableCalculateScrollbarWidth(); 1061 } 1062 1063 return cachedScrollbarWidth; 1064} 1065 1066/** 1067 * Checks if the provided element has a vertical scrollbar. 1068 * 1069 * @param {HTMLElement} element 1070 * @returns {Boolean} 1071 */ 1072function hasVerticalScrollbar(element) { 1073 return element.offsetWidth !== element.clientWidth; 1074} 1075 1076/** 1077 * Checks if the provided element has a vertical scrollbar. 1078 * 1079 * @param {HTMLElement} element 1080 * @returns {Boolean} 1081 */ 1082function hasHorizontalScrollbar(element) { 1083 return element.offsetHeight !== element.clientHeight; 1084} 1085 1086/** 1087 * Sets overlay position depending on it's type and used browser 1088 */ 1089function setOverlayPosition(overlayElem, left, top) { 1090 if ((0, _browser.isIE8)() || (0, _browser.isIE9)()) { 1091 overlayElem.style.top = top; 1092 overlayElem.style.left = left; 1093 } else if ((0, _browser.isSafari)()) { 1094 overlayElem.style['-webkit-transform'] = 'translate3d(' + left + ',' + top + ',0)'; 1095 } else { 1096 overlayElem.style.transform = 'translate3d(' + left + ',' + top + ',0)'; 1097 } 1098} 1099 1100function getCssTransform(element) { 1101 var transform; 1102 1103 if (element.style.transform && (transform = element.style.transform) !== '') { 1104 return ['transform', transform]; 1105 } else if (element.style['-webkit-transform'] && (transform = element.style['-webkit-transform']) !== '') { 1106 1107 return ['-webkit-transform', transform]; 1108 } 1109 1110 return -1; 1111} 1112 1113function resetCssTransform(element) { 1114 if (element.style.transform && element.style.transform !== '') { 1115 element.style.transform = ''; 1116 } else if (element.style['-webkit-transform'] && element.style['-webkit-transform'] !== '') { 1117 element.style['-webkit-transform'] = ''; 1118 } 1119} 1120 1121/** 1122 * Determines if the given DOM element is an input field. 1123 * Notice: By 'input' we mean input, textarea and select nodes 1124 * 1125 * @param {HTMLElement} element - DOM element 1126 * @returns {Boolean} 1127 */ 1128function isInput(element) { 1129 var inputs = ['INPUT', 'SELECT', 'TEXTAREA']; 1130 1131 return element && (inputs.indexOf(element.nodeName) > -1 || element.contentEditable === 'true'); 1132} 1133 1134/** 1135 * Determines if the given DOM element is an input field placed OUTSIDE of HOT. 1136 * Notice: By 'input' we mean input, textarea and select nodes 1137 * 1138 * @param {HTMLElement} element - DOM element 1139 * @returns {Boolean} 1140 */ 1141function isOutsideInput(element) { 1142 return isInput(element) && element.className.indexOf('handsontableInput') == -1 && element.className.indexOf('copyPaste') == -1; 1143} 1144 1145/***/ }), 1146/* 1 */ 1147/***/ (function(module, exports, __webpack_require__) { 1148 1149var global = __webpack_require__(10); 1150var core = __webpack_require__(45); 1151var hide = __webpack_require__(31); 1152var redefine = __webpack_require__(32); 1153var ctx = __webpack_require__(30); 1154var PROTOTYPE = 'prototype'; 1155 1156var $export = function (type, name, source) { 1157 var IS_FORCED = type & $export.F; 1158 var IS_GLOBAL = type & $export.G; 1159 var IS_STATIC = type & $export.S; 1160 var IS_PROTO = type & $export.P; 1161 var IS_BIND = type & $export.B; 1162 var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]; 1163 var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); 1164 var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); 1165 var key, own, out, exp; 1166 if (IS_GLOBAL) source = name; 1167 for (key in source) { 1168 // contains in native 1169 own = !IS_FORCED && target && target[key] !== undefined; 1170 // export native or passed 1171 out = (own ? target : source)[key]; 1172 // bind timers to global for call from export context 1173 exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; 1174 // extend global 1175 if (target) redefine(target, key, out, type & $export.U); 1176 // export 1177 if (exports[key] != out) hide(exports, key, exp); 1178 if (IS_PROTO && expProto[key] != out) expProto[key] = out; 1179 } 1180}; 1181global.core = core; 1182// type bitmap 1183$export.F = 1; // forced 1184$export.G = 2; // global 1185$export.S = 4; // static 1186$export.P = 8; // proto 1187$export.B = 16; // bind 1188$export.W = 32; // wrap 1189$export.U = 64; // safe 1190$export.R = 128; // real proto method for `library` 1191module.exports = $export; 1192 1193 1194/***/ }), 1195/* 2 */ 1196/***/ (function(module, exports, __webpack_require__) { 1197 1198"use strict"; 1199 1200 1201exports.__esModule = true; 1202exports.to2dArray = to2dArray; 1203exports.extendArray = extendArray; 1204exports.pivot = pivot; 1205exports.arrayReduce = arrayReduce; 1206exports.arrayFilter = arrayFilter; 1207exports.arrayMap = arrayMap; 1208exports.arrayEach = arrayEach; 1209exports.arraySum = arraySum; 1210exports.arrayMax = arrayMax; 1211exports.arrayMin = arrayMin; 1212exports.arrayAvg = arrayAvg; 1213exports.arrayFlatten = arrayFlatten; 1214exports.arrayUnique = arrayUnique; 1215function to2dArray(arr) { 1216 var i = 0, 1217 ilen = arr.length; 1218 1219 while (i < ilen) { 1220 arr[i] = [arr[i]]; 1221 i++; 1222 } 1223} 1224 1225function extendArray(arr, extension) { 1226 var i = 0, 1227 ilen = extension.length; 1228 1229 while (i < ilen) { 1230 arr.push(extension[i]); 1231 i++; 1232 } 1233} 1234 1235function pivot(arr) { 1236 var pivotedArr = []; 1237 1238 if (!arr || arr.length === 0 || !arr[0] || arr[0].length === 0) { 1239 return pivotedArr; 1240 } 1241 1242 var rowCount = arr.length; 1243 var colCount = arr[0].length; 1244 1245 for (var i = 0; i < rowCount; i++) { 1246 for (var j = 0; j < colCount; j++) { 1247 if (!pivotedArr[j]) { 1248 pivotedArr[j] = []; 1249 } 1250 1251 pivotedArr[j][i] = arr[i][j]; 1252 } 1253 } 1254 1255 return pivotedArr; 1256} 1257 1258/** 1259 * A specialized version of `.reduce` for arrays without support for callback 1260 * shorthands and `this` binding. 1261 * 1262 * {@link https://github.com/lodash/lodash/blob/master/lodash.js} 1263 * 1264 * @param {Array} array The array to iterate over. 1265 * @param {Function} iteratee The function invoked per iteration. 1266 * @param {*} [accumulator] The initial value. 1267 * @param {Boolean} [initFromArray] Specify using the first element of `array` as the initial value. 1268 * @returns {*} Returns the accumulated value. 1269 */ 1270function arrayReduce(array, iteratee, accumulator, initFromArray) { 1271 var index = -1, 1272 length = array.length; 1273 1274 if (initFromArray && length) { 1275 accumulator = array[++index]; 1276 } 1277 while (++index < length) { 1278 accumulator = iteratee(accumulator, array[index], index, array); 1279 } 1280 1281 return accumulator; 1282} 1283 1284/** 1285 * A specialized version of `.filter` for arrays without support for callback 1286 * shorthands and `this` binding. 1287 * 1288 * {@link https://github.com/lodash/lodash/blob/master/lodash.js} 1289 * 1290 * @param {Array} array The array to iterate over. 1291 * @param {Function} predicate The function invoked per iteration. 1292 * @returns {Array} Returns the new filtered array. 1293 */ 1294function arrayFilter(array, predicate) { 1295 var index = -1, 1296 length = array.length, 1297 resIndex = -1, 1298 result = []; 1299 1300 while (++index < length) { 1301 var value = array[index]; 1302 1303 if (predicate(value, index, array)) { 1304 result[++resIndex] = value; 1305 } 1306 } 1307 1308 return result; 1309} 1310 1311/** 1312 * A specialized version of `.map` for arrays without support for callback 1313 * shorthands and `this` binding. 1314 * 1315 * @param {Array} array The array to iterate over. 1316 * @param {Function} iteratee The function invoked per iteration. 1317 * @returns {Array} Returns the new filtered array. 1318 */ 1319function arrayMap(array, iteratee) { 1320 var index = -1, 1321 length = array.length, 1322 resIndex = -1, 1323 result = []; 1324 1325 while (++index < length) { 1326 var value = array[index]; 1327 1328 result[++resIndex] = iteratee(value, index, array); 1329 } 1330 1331 return result; 1332} 1333 1334/** 1335 * A specialized version of `.forEach` for arrays without support for callback 1336 * shorthands and `this` binding. 1337 * 1338 * {@link https://github.com/lodash/lodash/blob/master/lodash.js} 1339 * 1340 * @param {Array} array The array to iterate over. 1341 * @param {Function} iteratee The function invoked per iteration. 1342 * @returns {Array} Returns `array`. 1343 */ 1344function arrayEach(array, iteratee) { 1345 var index = -1, 1346 length = array.length; 1347 1348 while (++index < length) { 1349 if (iteratee(array[index], index, array) === false) { 1350 break; 1351 } 1352 } 1353 1354 return array; 1355} 1356 1357/** 1358 * Calculate sum value for each item of the array. 1359 * 1360 * @param {Array} array The array to process. 1361 * @returns {Number} Returns calculated sum value. 1362 */ 1363function arraySum(array) { 1364 return arrayReduce(array, function (a, b) { 1365 return a + b; 1366 }, 0); 1367} 1368 1369/** 1370 * Returns the highest value from an array. Can be array of numbers or array of strings. 1371 * NOTICE: Mixed values is not supported. 1372 * 1373 * @param {Array} array The array to process. 1374 * @returns {Number} Returns the highest value from an array. 1375 */ 1376function arrayMax(array) { 1377 return arrayReduce(array, function (a, b) { 1378 return a > b ? a : b; 1379 }, Array.isArray(array) ? array[0] : void 0); 1380} 1381 1382/** 1383 * Returns the lowest value from an array. Can be array of numbers or array of strings. 1384 * NOTICE: Mixed values is not supported. 1385 * 1386 * @param {Array} array The array to process. 1387 * @returns {Number} Returns the lowest value from an array. 1388 */ 1389function arrayMin(array) { 1390 return arrayReduce(array, function (a, b) { 1391 return a < b ? a : b; 1392 }, Array.isArray(array) ? array[0] : void 0); 1393} 1394 1395/** 1396 * Calculate average value for each item of the array. 1397 * 1398 * @param {Array} array The array to process. 1399 * @returns {Number} Returns calculated average value. 1400 */ 1401function arrayAvg(array) { 1402 if (!array.length) { 1403 return 0; 1404 } 1405 1406 return arraySum(array) / array.length; 1407} 1408 1409/** 1410 * Flatten multidimensional array. 1411 * 1412 * @param {Array} array Array of Arrays 1413 * @returns {Array} 1414 */ 1415function arrayFlatten(array) { 1416 return arrayReduce(array, function (initial, value) { 1417 return initial.concat(Array.isArray(value) ? arrayFlatten(value) : value); 1418 }, []); 1419} 1420 1421/** 1422 * Unique values in the array. 1423 * 1424 * @param {Array} array The array to process. 1425 * @returns {Array} 1426 */ 1427function arrayUnique(array) { 1428 var unique = []; 1429 1430 arrayEach(array, function (value) { 1431 if (unique.indexOf(value) === -1) { 1432 unique.push(value); 1433 } 1434 }); 1435 1436 return unique; 1437} 1438 1439/***/ }), 1440/* 3 */ 1441/***/ (function(module, exports, __webpack_require__) { 1442 1443"use strict"; 1444 1445 1446exports.__esModule = true; 1447 1448var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 1449 1450exports.duckSchema = duckSchema; 1451exports.inherit = inherit; 1452exports.extend = extend; 1453exports.deepExtend = deepExtend; 1454exports.deepClone = deepClone; 1455exports.clone = clone; 1456exports.mixin = mixin; 1457exports.isObjectEquals = isObjectEquals; 1458exports.isObject = isObject; 1459exports.defineGetter = defineGetter; 1460exports.objectEach = objectEach; 1461exports.getProperty = getProperty; 1462exports.deepObjectSize = deepObjectSize; 1463exports.createObjectPropListener = createObjectPropListener; 1464exports.hasOwnProperty = hasOwnProperty; 1465 1466var _array = __webpack_require__(2); 1467 1468function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 1469 1470/** 1471 * Generate schema for passed object. 1472 * 1473 * @param {Array|Object} object 1474 * @returns {Array|Object} 1475 */ 1476function duckSchema(object) { 1477 var schema; 1478 1479 if (Array.isArray(object)) { 1480 schema = []; 1481 } else { 1482 schema = {}; 1483 1484 objectEach(object, function (value, key) { 1485 if (key === '__children') { 1486 return; 1487 } 1488 1489 if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !Array.isArray(value)) { 1490 schema[key] = duckSchema(value); 1491 } else if (Array.isArray(value)) { 1492 if (value.length && _typeof(value[0]) === 'object' && !Array.isArray(value[0])) { 1493 schema[key] = [duckSchema(value[0])]; 1494 } else { 1495 schema[key] = []; 1496 } 1497 } else { 1498 schema[key] = null; 1499 } 1500 }); 1501 } 1502 1503 return schema; 1504} 1505 1506/** 1507 * Inherit without without calling parent constructor, and setting `Child.prototype.constructor` to `Child` instead of `Parent`. 1508 * Creates temporary dummy function to call it as constructor. 1509 * Described in ticket: https://github.com/handsontable/handsontable/pull/516 1510 * 1511 * @param {Object} Child child class 1512 * @param {Object} Parent parent class 1513 * @return {Object} extended Child 1514 */ 1515function inherit(Child, Parent) { 1516 Parent.prototype.constructor = Parent; 1517 Child.prototype = new Parent(); 1518 Child.prototype.constructor = Child; 1519 1520 return Child; 1521} 1522 1523/** 1524 * Perform shallow extend of a target object with extension's own properties. 1525 * 1526 * @param {Object} target An object that will receive the new properties. 1527 * @param {Object} extension An object containing additional properties to merge into the target. 1528 */ 1529function extend(target, extension) { 1530 objectEach(extension, function (value, key) { 1531 target[key] = value; 1532 }); 1533 1534 return target; 1535} 1536 1537/** 1538 * Perform deep extend of a target object with extension's own properties. 1539 * 1540 * @param {Object} target An object that will receive the new properties. 1541 * @param {Object} extension An object containing additional properties to merge into the target. 1542 */ 1543function deepExtend(target, extension) { 1544 objectEach(extension, function (value, key) { 1545 if (extension[key] && _typeof(extension[key]) === 'object') { 1546 if (!target[key]) { 1547 if (Array.isArray(extension[key])) { 1548 target[key] = []; 1549 } else if (Object.prototype.toString.call(extension[key]) === '[object Date]') { 1550 target[key] = extension[key]; 1551 } else { 1552 target[key] = {}; 1553 } 1554 } 1555 deepExtend(target[key], extension[key]); 1556 } else { 1557 target[key] = extension[key]; 1558 } 1559 }); 1560} 1561 1562/** 1563 * Perform deep clone of an object. 1564 * WARNING! Only clones JSON properties. Will cause error when `obj` contains a function, Date, etc. 1565 * 1566 * @param {Object} obj An object that will be cloned 1567 * @return {Object} 1568 */ 1569function deepClone(obj) { 1570 if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') { 1571 return JSON.parse(JSON.stringify(obj)); 1572 } 1573 1574 return obj; 1575} 1576 1577/** 1578 * Shallow clone object. 1579 * 1580 * @param {Object} object 1581 * @returns {Object} 1582 */ 1583function clone(object) { 1584 var result = {}; 1585 1586 objectEach(object, function (value, key) { 1587 result[key] = value; 1588 }); 1589 1590 return result; 1591} 1592 1593/** 1594 * Extend the Base object (usually prototype) of the functionality the `mixins` objects. 1595 * 1596 * @param {Object} Base Base object which will be extended. 1597 * @param {Object} mixins The object of the functionality will be "copied". 1598 * @returns {Object} 1599 */ 1600function mixin(Base) { 1601 if (!Base.MIXINS) { 1602 Base.MIXINS = []; 1603 } 1604 1605 for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 1606 mixins[_key - 1] = arguments[_key]; 1607 } 1608 1609 (0, _array.arrayEach)(mixins, function (mixin) { 1610 Base.MIXINS.push(mixin.MIXIN_NAME); 1611 1612 objectEach(mixin, function (value, key) { 1613 if (Base.prototype[key] !== void 0) { 1614 throw new Error('Mixin conflict. Property \'' + key + '\' already exist and cannot be overwritten.'); 1615 } 1616 if (typeof value === 'function') { 1617 Base.prototype[key] = value; 1618 } else { 1619 var getter = function _getter(propertyName, initialValue) { 1620 propertyName = '_' + propertyName; 1621 1622 var initValue = function initValue(value) { 1623 if (Array.isArray(value) || isObject(value)) { 1624 value = deepClone(value); 1625 } 1626 1627 return value; 1628 }; 1629 1630 return function () { 1631 if (this[propertyName] === void 0) { 1632 this[propertyName] = initValue(initialValue); 1633 } 1634 1635 return this[propertyName]; 1636 }; 1637 }; 1638 var setter = function _setter(propertyName) { 1639 propertyName = '_' + propertyName; 1640 1641 return function (value) { 1642 this[propertyName] = value; 1643 }; 1644 }; 1645 Object.defineProperty(Base.prototype, key, { 1646 get: getter(key, value), 1647 set: setter(key), 1648 configurable: true 1649 }); 1650 } 1651 }); 1652 }); 1653 1654 return Base; 1655} 1656 1657/** 1658 * Checks if two objects or arrays are (deep) equal 1659 * 1660 * @param {Object|Array} object1 1661 * @param {Object|Array} object2 1662 * @returns {Boolean} 1663 */ 1664function isObjectEquals(object1, object2) { 1665 return JSON.stringify(object1) === JSON.stringify(object2); 1666} 1667 1668/** 1669 * Determines whether given object is a plain Object. 1670 * Note: String and Array are not plain Objects 1671 * @param {*} obj 1672 * @returns {boolean} 1673 */ 1674function isObject(obj) { 1675 return Object.prototype.toString.call(obj) == '[object Object]'; 1676} 1677 1678function defineGetter(object, property, value, options) { 1679 options.value = value; 1680 options.writable = options.writable !== false; 1681 options.enumerable = options.enumerable !== false; 1682 options.configurable = options.configurable !== false; 1683 1684 Object.defineProperty(object, property, options); 1685} 1686 1687/** 1688 * A specialized version of `.forEach` for objects. 1689 * 1690 * @param {Object} object The object to iterate over. 1691 * @param {Function} iteratee The function invoked per iteration. 1692 * @returns {Object} Returns `object`. 1693 */ 1694function objectEach(object, iteratee) { 1695 for (var key in object) { 1696 if (!object.hasOwnProperty || object.hasOwnProperty && Object.prototype.hasOwnProperty.call(object, key)) { 1697 if (iteratee(object[key], key, object) === false) { 1698 break; 1699 } 1700 } 1701 } 1702 1703 return object; 1704} 1705 1706/** 1707 * Get object property by its name. Access to sub properties can be achieved by dot notation (e.q. `'foo.bar.baz'`). 1708 * 1709 * @param {Object} object Object which value will be exported. 1710 * @param {String} name Object property name. 1711 * @returns {*} 1712 */ 1713function getProperty(object, name) { 1714 var names = name.split('.'); 1715 var result = object; 1716 1717 objectEach(names, function (name) { 1718 result = result[name]; 1719 1720 if (result === void 0) { 1721 result = void 0; 1722 1723 return false; 1724 } 1725 }); 1726 1727 return result; 1728} 1729 1730/** 1731 * Return object length (recursively). 1732 * 1733 * @param {*} object Object for which we want get length. 1734 * @returns {Number} 1735 */ 1736function deepObjectSize(object) { 1737 if (!isObject(object)) { 1738 return 0; 1739 } 1740 var recursObjLen = function recursObjLen(obj) { 1741 var result = 0; 1742 1743 if (isObject(obj)) { 1744 objectEach(obj, function (key) { 1745 result += recursObjLen(key); 1746 }); 1747 } else { 1748 result++; 1749 } 1750 1751 return result; 1752 }; 1753 1754 return recursObjLen(object); 1755} 1756 1757/** 1758 * Create object with property where its value change will be observed. 1759 * 1760 * @param {*} [defaultValue=undefined] Default value. 1761 * @param {String} [propertyToListen='value'] Property to listen. 1762 * @returns {Object} 1763 */ 1764function createObjectPropListener(defaultValue) { 1765 var _holder; 1766 1767 var propertyToListen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value'; 1768 1769 var privateProperty = '_' + propertyToListen; 1770 var holder = (_holder = { 1771 _touched: false 1772 }, _defineProperty(_holder, privateProperty, defaultValue), _defineProperty(_holder, 'isTouched', function isTouched() { 1773 return this._touched; 1774 }), _holder); 1775 1776 Object.defineProperty(holder, propertyToListen, { 1777 get: function get() { 1778 return this[privateProperty]; 1779 }, 1780 set: function set(value) { 1781 this._touched = true; 1782 this[privateProperty] = value; 1783 }, 1784 1785 enumerable: true, 1786 configurable: true 1787 }); 1788 1789 return holder; 1790} 1791 1792/** 1793 * Check if at specified `key` there is any value for `object`. 1794 * 1795 * @param {Object} object Object to search value at specyfic key. 1796 * @param {String} key String key to check. 1797 */ 1798function hasOwnProperty(object, key) { 1799 return Object.prototype.hasOwnProperty.call(object, key); 1800} 1801 1802/***/ }), 1803/* 4 */ 1804/***/ (function(module, exports, __webpack_require__) { 1805 1806"use strict"; 1807 1808 1809exports.__esModule = true; 1810 1811var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1812 1813exports.getListenersCounter = getListenersCounter; 1814 1815var _element = __webpack_require__(0); 1816 1817var _object = __webpack_require__(3); 1818 1819var _feature = __webpack_require__(34); 1820 1821var _event = __webpack_require__(7); 1822 1823function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1824 1825/** 1826 * Counter which tracks unregistered listeners (useful for detecting memory leaks). 1827 * 1828 * @type {Number} 1829 */ 1830var listenersCounter = 0; 1831 1832/** 1833 * Event DOM manager for internal use in Handsontable. 1834 * 1835 * @class EventManager 1836 * @util 1837 */ 1838 1839var EventManager = function () { 1840 /** 1841 * @param {Object} [context=null] 1842 * @private 1843 */ 1844 function EventManager() { 1845 var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 1846 1847 _classCallCheck(this, EventManager); 1848 1849 this.context = context || this; 1850 1851 if (!this.context.eventListeners) { 1852 this.context.eventListeners = []; 1853 } 1854 } 1855 1856 /** 1857 * Register specified listener (`eventName`) to the element. 1858 * 1859 * @param {Element} element Target element. 1860 * @param {String} eventName Event name. 1861 * @param {Function} callback Function which will be called after event occur. 1862 * @returns {Function} Returns function which you can easily call to remove that event 1863 */ 1864 1865 1866 _createClass(EventManager, [{ 1867 key: 'addEventListener', 1868 value: function addEventListener(element, eventName, callback) { 1869 var _this = this; 1870 1871 var context = this.context; 1872 1873 function callbackProxy(event) { 1874 event = extendEvent(context, event); 1875 1876 callback.call(this, event); 1877 } 1878 this.context.eventListeners.push({ 1879 element: element, 1880 event: eventName, 1881 callback: callback, 1882 callbackProxy: callbackProxy 1883 }); 1884 1885 if (window.addEventListener) { 1886 element.addEventListener(eventName, callbackProxy, false); 1887 } else { 1888 element.attachEvent('on' + eventName, callbackProxy); 1889 } 1890 listenersCounter++; 1891 1892 return function () { 1893 _this.removeEventListener(element, eventName, callback); 1894 }; 1895 } 1896 1897 /** 1898 * Remove the event listener previously registered. 1899 * 1900 * @param {Element} element Target element. 1901 * @param {String} eventName Event name. 1902 * @param {Function} callback Function to remove from the event target. It must be the same as during registration listener. 1903 */ 1904 1905 }, { 1906 key: 'removeEventListener', 1907 value: function removeEventListener(element, eventName, callback) { 1908 var len = this.context.eventListeners.length; 1909 var tmpEvent = void 0; 1910 1911 while (len--) { 1912 tmpEvent = this.context.eventListeners[len]; 1913 1914 if (tmpEvent.event == eventName && tmpEvent.element == element) { 1915 if (callback && callback != tmpEvent.callback) { 1916 /* eslint-disable no-continue */ 1917 continue; 1918 } 1919 this.context.eventListeners.splice(len, 1); 1920 1921 if (tmpEvent.element.removeEventListener) { 1922 tmpEvent.element.removeEventListener(tmpEvent.event, tmpEvent.callbackProxy, false); 1923 } else { 1924 tmpEvent.element.detachEvent('on' + tmpEvent.event, tmpEvent.callbackProxy); 1925 } 1926 listenersCounter--; 1927 } 1928 } 1929 } 1930 1931 /** 1932 * Clear all previously registered events. 1933 * 1934 * @private 1935 * @since 0.15.0-beta3 1936 */ 1937 1938 }, { 1939 key: 'clearEvents', 1940 value: function clearEvents() { 1941 if (!this.context) { 1942 return; 1943 } 1944 var len = this.context.eventListeners.length; 1945 1946 while (len--) { 1947 var event = this.context.eventListeners[len]; 1948 1949 if (event) { 1950 this.removeEventListener(event.element, event.event, event.callback); 1951 } 1952 } 1953 } 1954 1955 /** 1956 * Clear all previously registered events. 1957 */ 1958 1959 }, { 1960 key: 'clear', 1961 value: function clear() { 1962 this.clearEvents(); 1963 } 1964 1965 /** 1966 * Destroy instance of EventManager. 1967 */ 1968 1969 }, { 1970 key: 'destroy', 1971 value: function destroy() { 1972 this.clearEvents(); 1973 this.context = null; 1974 } 1975 1976 /** 1977 * Trigger event at the specified target element. 1978 * 1979 * @param {Element} element Target element. 1980 * @param {String} eventName Event name. 1981 */ 1982 1983 }, { 1984 key: 'fireEvent', 1985 value: function fireEvent(element, eventName) { 1986 var options = { 1987 bubbles: true, 1988 cancelable: eventName !== 'mousemove', 1989 view: window, 1990 detail: 0, 1991 screenX: 0, 1992 screenY: 0, 1993 clientX: 1, 1994 clientY: 1, 1995 ctrlKey: false, 1996 altKey: false, 1997 shiftKey: false, 1998 metaKey: false, 1999 button: 0, 2000 relatedTarget: undefined 2001 }; 2002 var event; 2003 2004 if (document.createEvent) { 2005 event = document.createEvent('MouseEvents'); 2006 event.initMouseEvent(eventName, options.bubbles, options.cancelable, options.view, options.detail, options.screenX, options.screenY, options.clientX, options.clientY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, options.relatedTarget || document.body.parentNode); 2007 } else { 2008 event = document.createEventObject(); 2009 } 2010 2011 if (element.dispatchEvent) { 2012 element.dispatchEvent(event); 2013 } else { 2014 element.fireEvent('on' + eventName, event); 2015 } 2016 } 2017 }]); 2018 2019 return EventManager; 2020}(); 2021 2022/** 2023 * @param {Object} context 2024 * @param {Event} event 2025 * @private 2026 * @returns {*} 2027 */ 2028 2029 2030function extendEvent(context, event) { 2031 var componentName = 'HOT-TABLE'; 2032 var isHotTableSpotted = void 0; 2033 var fromElement = void 0; 2034 var realTarget = void 0; 2035 var target = void 0; 2036 var len = void 0; 2037 var nativeStopImmediatePropagation = void 0; 2038 2039 event.isTargetWebComponent = false; 2040 event.realTarget = event.target; 2041 2042 nativeStopImmediatePropagation = event.stopImmediatePropagation; 2043 event.stopImmediatePropagation = function () { 2044 nativeStopImmediatePropagation.apply(this); 2045 (0, _event.stopImmediatePropagation)(this); 2046 }; 2047 2048 if (!EventManager.isHotTableEnv) { 2049 return event; 2050 } 2051 event = (0, _element.polymerWrap)(event); 2052 len = event.path ? event.path.length : 0; 2053 2054 while (len--) { 2055 if (event.path[len].nodeName === componentName) { 2056 isHotTableSpotted = true; 2057 } else if (isHotTableSpotted && event.path[len].shadowRoot) { 2058 target = event.path[len]; 2059 2060 break; 2061 } 2062 if (len === 0 && !target) { 2063 target = event.path[len]; 2064 } 2065 } 2066 if (!target) { 2067 target = event.target; 2068 } 2069 event.isTargetWebComponent = true; 2070 2071 if ((0, _feature.isWebComponentSupportedNatively)()) { 2072 event.realTarget = event.srcElement || event.toElement; 2073 } else if ((0, _object.hasOwnProperty)(context, 'hot') || context.isHotTableEnv || context.wtTable) { 2074 // Polymer doesn't support `event.target` property properly we must emulate it ourselves 2075 if ((0, _object.hasOwnProperty)(context, 'hot')) { 2076 // Custom element 2077 fromElement = context.hot ? context.hot.view.wt.wtTable.TABLE : null; 2078 } else if (context.isHotTableEnv) { 2079 // Handsontable.Core 2080 fromElement = context.view.activeWt.wtTable.TABLE.parentNode.parentNode; 2081 } else if (context.wtTable) { 2082 // Walkontable 2083 fromElement = context.wtTable.TABLE.parentNode.parentNode; 2084 } 2085 realTarget = (0, _element.closest)(event.target, [componentName], fromElement); 2086 2087 if (realTarget) { 2088 event.realTarget = fromElement.querySelector(componentName) || event.target; 2089 } else { 2090 event.realTarget = event.target; 2091 } 2092 } 2093 2094 Object.defineProperty(event, 'target', { 2095 get: function get() { 2096 return (0, _element.polymerWrap)(target); 2097 }, 2098 2099 enumerable: true, 2100 configurable: true 2101 }); 2102 2103 return event; 2104} 2105 2106exports.default = EventManager; 2107function getListenersCounter() { 2108 return listenersCounter; 2109}; 2110 2111/***/ }), 2112/* 5 */ 2113/***/ (function(module, exports, __webpack_require__) { 2114 2115"use strict"; 2116 2117 2118exports.__esModule = true; 2119 2120var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 2121 2122exports.isNumeric = isNumeric; 2123exports.rangeEach = rangeEach; 2124exports.rangeEachReverse = rangeEachReverse; 2125exports.valueAccordingPercent = valueAccordingPercent; 2126/** 2127 * Checks if value of n is a numeric one 2128 * http://jsperf.com/isnan-vs-isnumeric/4 2129 * @param n 2130 * @returns {boolean} 2131 */ 2132function isNumeric(n) { 2133 /* eslint-disable */ 2134 var t = typeof n === 'undefined' ? 'undefined' : _typeof(n); 2135 2136 return t == 'number' ? !isNaN(n) && isFinite(n) : t == 'string' ? !n.length ? false : n.length == 1 ? /\d/.test(n) : /^\s*[+-]?\s*(?:(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?)|(?:0x[a-f\d]+))\s*$/i.test(n) : t == 'object' ? !!n && typeof n.valueOf() == 'number' && !(n instanceof Date) : false; 2137} 2138 2139/** 2140 * A specialized version of `.forEach` defined by ranges. 2141 * 2142 * @param {Number} rangeFrom The number from start iterate. 2143 * @param {Number|Function} rangeTo The number where finish iterate or function as a iteratee. 2144 * @param {Function} [iteratee] The function invoked per iteration. 2145 */ 2146function rangeEach(rangeFrom, rangeTo, iteratee) { 2147 var index = -1; 2148 2149 if (typeof rangeTo === 'function') { 2150 iteratee = rangeTo; 2151 rangeTo = rangeFrom; 2152 } else { 2153 index = rangeFrom - 1; 2154 } 2155 while (++index <= rangeTo) { 2156 if (iteratee(index) === false) { 2157 break; 2158 } 2159 } 2160} 2161 2162/** 2163 * A specialized version of `.forEach` defined by ranges iterable in reverse order. 2164 * 2165 * @param {Number} rangeFrom The number from start iterate. 2166 * @param {Number} rangeTo The number where finish iterate. 2167 * @param {Function} iteratee The function invoked per iteration. 2168 */ 2169function rangeEachReverse(rangeFrom, rangeTo, iteratee) { 2170 var index = rangeFrom + 1; 2171 2172 if (typeof rangeTo === 'function') { 2173 iteratee = rangeTo; 2174 rangeTo = 0; 2175 } 2176 while (--index >= rangeTo) { 2177 if (iteratee(index) === false) { 2178 break; 2179 } 2180 } 2181} 2182 2183/** 2184 * Calculate value from percent. 2185 * 2186 * @param {Number} value Base value from percent will be calculated. 2187 * @param {String|Number} percent Can be Number or String (eq. `'33%'`). 2188 * @returns {Number} 2189 */ 2190function valueAccordingPercent(value, percent) { 2191 percent = parseInt(percent.toString().replace('%', ''), 10); 2192 percent = parseInt(value * percent / 100, 10); 2193 2194 return percent; 2195} 2196 2197/***/ }), 2198/* 6 */ 2199/***/ (function(module, exports, __webpack_require__) { 2200 2201"use strict"; 2202 2203 2204exports.__esModule = true; 2205exports.getRegisteredRenderers = exports.getRegisteredRendererNames = exports.hasRenderer = exports.getRenderer = exports.registerRenderer = undefined; 2206 2207var _staticRegister2 = __webpack_require__(53); 2208 2209var _staticRegister3 = _interopRequireDefault(_staticRegister2); 2210 2211var _cellDecorator = __webpack_require__(376); 2212 2213var _cellDecorator2 = _interopRequireDefault(_cellDecorator); 2214 2215var _autocompleteRenderer = __webpack_require__(377); 2216 2217var _autocompleteRenderer2 = _interopRequireDefault(_autocompleteRenderer); 2218 2219var _checkboxRenderer = __webpack_require__(378); 2220 2221var _checkboxRenderer2 = _interopRequireDefault(_checkboxRenderer); 2222 2223var _htmlRenderer = __webpack_require__(379); 2224 2225var _htmlRenderer2 = _interopRequireDefault(_htmlRenderer); 2226 2227var _numericRenderer = __webpack_require__(380); 2228 2229var _numericRenderer2 = _interopRequireDefault(_numericRenderer); 2230 2231var _passwordRenderer = __webpack_require__(381); 2232 2233var _passwordRenderer2 = _interopRequireDefault(_passwordRenderer); 2234 2235var _textRenderer = __webpack_require__(382); 2236 2237var _textRenderer2 = _interopRequireDefault(_textRenderer); 2238 2239function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2240 2241var _staticRegister = (0, _staticRegister3.default)('renderers'), 2242 register = _staticRegister.register, 2243 getItem = _staticRegister.getItem, 2244 hasItem = _staticRegister.hasItem, 2245 getNames = _staticRegister.getNames, 2246 getValues = _staticRegister.getValues; 2247 2248register('base', _cellDecorator2.default); 2249register('autocomplete', _autocompleteRenderer2.default); 2250register('checkbox', _checkboxRenderer2.default); 2251register('html', _htmlRenderer2.default); 2252register('numeric', _numericRenderer2.default); 2253register('password', _passwordRenderer2.default); 2254register('text', _textRenderer2.default); 2255 2256/** 2257 * Retrieve renderer function. 2258 * 2259 * @param {String} name Renderer identification. 2260 * @returns {Function} Returns renderer function. 2261 */ 2262function _getItem(name) { 2263 if (typeof name === 'function') { 2264 return name; 2265 } 2266 if (!hasItem(name)) { 2267 throw Error('No registered renderer found under "' + name + '" name'); 2268 } 2269 2270 return getItem(name); 2271} 2272 2273exports.registerRenderer = register; 2274exports.getRenderer = _getItem; 2275exports.hasRenderer = hasItem; 2276exports.getRegisteredRendererNames = getNames; 2277exports.getRegisteredRenderers = getValues; 2278 2279/***/ }), 2280/* 7 */ 2281/***/ (function(module, exports, __webpack_require__) { 2282 2283"use strict"; 2284 2285 2286exports.__esModule = true; 2287exports.stopImmediatePropagation = stopImmediatePropagation; 2288exports.isImmediatePropagationStopped = isImmediatePropagationStopped; 2289exports.stopPropagation = stopPropagation; 2290exports.pageX = pageX; 2291exports.pageY = pageY; 2292exports.isRightClick = isRightClick; 2293exports.isLeftClick = isLeftClick; 2294 2295var _element = __webpack_require__(0); 2296 2297/** 2298 * Prevent other listeners of the same event from being called. 2299 * 2300 * @param {Event} event 2301 */ 2302function stopImmediatePropagation(event) { 2303 event.isImmediatePropagationEnabled = false; 2304 event.cancelBubble = true; 2305} 2306 2307/** 2308 * Check if event was stopped by `stopImmediatePropagation`. 2309 * 2310 * @param event {Event} 2311 * @returns {Boolean} 2312 */ 2313function isImmediatePropagationStopped(event) { 2314 return event.isImmediatePropagationEnabled === false; 2315} 2316 2317/** 2318 * Prevent further propagation of the current event (prevent bubbling). 2319 * 2320 * @param event {Event} 2321 */ 2322function stopPropagation(event) { 2323 // ie8 2324 // http://msdn.microsoft.com/en-us/library/ie/ff975462(v=vs.85).aspx 2325 if (typeof event.stopPropagation === 'function') { 2326 event.stopPropagation(); 2327 } else { 2328 event.cancelBubble = true; 2329 } 2330} 2331 2332/** 2333 * Get horizontal coordinate of the event object relative to the whole document. 2334 * 2335 * @param {Event} event 2336 * @returns {Number} 2337 */ 2338function pageX(event) { 2339 if (event.pageX) { 2340 return event.pageX; 2341 } 2342 2343 return event.clientX + (0, _element.getWindowScrollLeft)(); 2344} 2345 2346/** 2347 * Get vertical coordinate of the event object relative to the whole document. 2348 * 2349 * @param {Event} event 2350 * @returns {Number} 2351 */ 2352function pageY(event) { 2353 if (event.pageY) { 2354 return event.pageY; 2355 } 2356 2357 return event.clientY + (0, _element.getWindowScrollTop)(); 2358} 2359 2360/** 2361 * Check if provided event was triggered by clicking the right mouse button. 2362 * 2363 * @param {Event} event DOM Event. 2364 * @returns {Boolean} 2365 */ 2366function isRightClick(event) { 2367 return event.button === 2; 2368} 2369 2370/** 2371 * Check if provided event was triggered by clicking the left mouse button. 2372 * 2373 * @param {Event} event DOM Event. 2374 * @returns {Boolean} 2375 */ 2376function isLeftClick(event) { 2377 return event.button === 0; 2378} 2379 2380/***/ }), 2381/* 8 */ 2382/***/ (function(module, exports, __webpack_require__) { 2383 2384var store = __webpack_require__(84)('wks'); 2385var uid = __webpack_require__(51); 2386var Symbol = __webpack_require__(10).Symbol; 2387var USE_SYMBOL = typeof Symbol == 'function'; 2388 2389var $exports = module.exports = function (name) { 2390 return store[name] || (store[name] = 2391 USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); 2392}; 2393 2394$exports.store = store; 2395 2396 2397/***/ }), 2398/* 9 */ 2399/***/ (function(module, exports, __webpack_require__) { 2400 2401"use strict"; 2402 2403 2404exports.__esModule = true; 2405exports.getPluginName = exports.getRegistredPluginNames = exports.getPlugin = exports.registerPlugin = undefined; 2406 2407var _pluginHooks = __webpack_require__(11); 2408 2409var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 2410 2411var _object = __webpack_require__(3); 2412 2413var _string = __webpack_require__(28); 2414 2415function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2416 2417var registeredPlugins = new WeakMap(); 2418 2419/** 2420 * Registers plugin under given name 2421 * 2422 * @param {String} pluginName 2423 * @param {Function} PluginClass 2424 */ 2425/** 2426 * Utility to register plugins and common namespace for keeping reference to all plugins classes 2427 */ 2428function registerPlugin(pluginName, PluginClass) { 2429 pluginName = (0, _string.toUpperCaseFirst)(pluginName); 2430 2431 _pluginHooks2.default.getSingleton().add('construct', function () { 2432 var holder = void 0; 2433 2434 if (!registeredPlugins.has(this)) { 2435 registeredPlugins.set(this, {}); 2436 } 2437 holder = registeredPlugins.get(this); 2438 2439 if (!holder[pluginName]) { 2440 holder[pluginName] = new PluginClass(this); 2441 } 2442 }); 2443 _pluginHooks2.default.getSingleton().add('afterDestroy', function () { 2444 if (registeredPlugins.has(this)) { 2445 var pluginsHolder = registeredPlugins.get(this); 2446 2447 (0, _object.objectEach)(pluginsHolder, function (plugin) { 2448 return plugin.destroy(); 2449 }); 2450 registeredPlugins.delete(this); 2451 } 2452 }); 2453} 2454 2455/** 2456 * @param {Object} instance 2457 * @param {String|Function} pluginName 2458 * @returns {Function} pluginClass Returns plugin instance if exists or `undefined` if not exists. 2459 */ 2460function getPlugin(instance, pluginName) { 2461 if (typeof pluginName != 'string') { 2462 throw Error('Only strings can be passed as "plugin" parameter'); 2463 } 2464 var _pluginName = (0, _string.toUpperCaseFirst)(pluginName); 2465 2466 if (!registeredPlugins.has(instance) || !registeredPlugins.get(instance)[_pluginName]) { 2467 return void 0; 2468 } 2469 2470 return registeredPlugins.get(instance)[_pluginName]; 2471} 2472 2473/** 2474 * Get all registred plugins names for concrete Handsontable instance. 2475 * 2476 * @param {Object} hotInstance 2477 * @returns {Array} 2478 */ 2479function getRegistredPluginNames(hotInstance) { 2480 return registeredPlugins.has(hotInstance) ? Object.keys(registeredPlugins.get(hotInstance)) : []; 2481} 2482 2483/** 2484 * Get plugin name. 2485 * 2486 * @param {Object} hotInstance 2487 * @param {Object} plugin 2488 * @returns {String|null} 2489 */ 2490function getPluginName(hotInstance, plugin) { 2491 var pluginName = null; 2492 2493 if (registeredPlugins.has(hotInstance)) { 2494 (0, _object.objectEach)(registeredPlugins.get(hotInstance), function (pluginInstance, name) { 2495 if (pluginInstance === plugin) { 2496 pluginName = name; 2497 } 2498 }); 2499 } 2500 2501 return pluginName; 2502} 2503 2504exports.registerPlugin = registerPlugin; 2505exports.getPlugin = getPlugin; 2506exports.getRegistredPluginNames = getRegistredPluginNames; 2507exports.getPluginName = getPluginName; 2508 2509/***/ }), 2510/* 10 */ 2511/***/ (function(module, exports) { 2512 2513// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 2514var global = module.exports = typeof window != 'undefined' && window.Math == Math 2515 ? window : typeof self != 'undefined' && self.Math == Math ? self 2516 // eslint-disable-next-line no-new-func 2517 : Function('return this')(); 2518if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef 2519 2520 2521/***/ }), 2522/* 11 */ 2523/***/ (function(module, exports, __webpack_require__) { 2524 2525"use strict"; 2526 2527 2528exports.__esModule = true; 2529 2530var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 2531 2532var _array = __webpack_require__(2); 2533 2534var _object = __webpack_require__(3); 2535 2536function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 2537 2538/** 2539 * @description 2540 * Handsontable events are the common interface that function in 2 ways: as __callbacks__ and as __hooks__. 2541 * 2542 * @example 2543 * 2544 * ```js 2545 * // Using events as callbacks: 2546 * ... 2547 * var hot1 = new Handsontable(document.getElementById('example1'), { 2548 * afterChange: function(changes, source) { 2549 * $.ajax({ 2550 * url: "save.php', 2551 * data: change 2552 * }); 2553 * } 2554 * }); 2555 * ... 2556 * ``` 2557 * 2558 * ```js 2559 * // Using events as plugin hooks: 2560 * ... 2561 * var hot1 = new Handsontable(document.getElementById('example1'), { 2562 * myPlugin: true 2563 * }); 2564 * 2565 * var hot2 = new Handsontable(document.getElementById('example2'), { 2566 * myPlugin: false 2567 * }); 2568 * 2569 * // global hook 2570 * Handsontable.hooks.add('afterChange', function() { 2571 * // Fired twice - for hot1 and hot2 2572 * if (this.getSettings().myPlugin) { 2573 * // function body - will only run for hot1 2574 * } 2575 * }); 2576 * 2577 * // local hook (has same effect as a callback) 2578 * hot2.addHook('afterChange', function() { 2579 * // function body - will only run in #example2 2580 * }); 2581 * ``` 2582 * ... 2583 */ 2584 2585// @TODO: Move plugin description hooks to plugin? 2586var REGISTERED_HOOKS = [ 2587/** 2588 * Callback fired after resetting a cell's meta. 2589 * 2590 * @event Hooks#afterCellMetaReset 2591 * @since 0.11 2592 */ 2593'afterCellMetaReset', 2594 2595/** 2596 * @description 2597 * Callback fired after one or more cells has been changed. Its main use case is to save the input. 2598 * 2599 * __Note:__ For performance reasons, the `changes` array is null for `"loadData"` source. 2600 * 2601 * @event Hooks#afterChange 2602 * @param {Array} changes 2D array containing information about each of the edited cells `[[row, prop, oldVal, newVal], ...]`. 2603 * @param {String} [source] String that identifies source of hook call 2604 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 2605 */ 2606'afterChange', 2607 2608/** 2609 * @description 2610 * Fired after observing changes. 2611 * 2612 * @event Hooks#afterChangesObserved 2613 */ 2614'afterChangesObserved', 2615 2616/** 2617 * @description 2618 * Fired after setting up the Context Menu's default options. These options are a collection which user can select by setting 2619 * an array of keys or an array of objects in `contextMenu` option. 2620 * 2621 * @event Hooks#afterContextMenuDefaultOptions 2622 * @param {Array} predefinedItems Array of objects containing information about the pre-defined Context Menu items. 2623 */ 2624'afterContextMenuDefaultOptions', 2625 2626/** 2627 * @description 2628 * Fired before setting up the Context Menu's items but after filtering these options by user (`contextMenu` option). This hook 2629 * can by helpful to determine if user use specified menu item or to set up one of the menu item to by always visible. 2630 * 2631 * @event Hooks#beforeContextMenuSetItems 2632 * @param {Array} menuItems Array of objects containing information about to generated Context Menu items. 2633 */ 2634'beforeContextMenuSetItems', 2635 2636/** 2637 * @description 2638 * Fired after setting up the Context Menu's default options. These options are a collection which user can select by setting 2639 * an array of keys or an array of objects in `contextMenu` option. 2640 * 2641 * @pro 2642 * @event Hooks#afterDropdownMenuDefaultOptions 2643 * @param {Array} predefinedItems Array of objects containing information about the pre-defined Context Menu items. 2644 */ 2645'afterDropdownMenuDefaultOptions', 2646 2647/** 2648 * @description 2649 * Fired before setting up the Dropdown Menu's items but after filtering these options by user (`dropdownMenu` option). This hook 2650 * can by helpful to determine if user use specified menu item or to set up one of the menu item to by always visible. 2651 * 2652 * @pro 2653 * @event Hooks#beforeDropdownMenuSetItems 2654 * @param {Array} menuItems Array of objects containing information about to generated Dropdown Menu items. 2655 */ 2656'beforeDropdownMenuSetItems', 2657 2658/** 2659 * @description 2660 * Fired after hiding the Context Menu. 2661 * 2662 * @event Hooks#afterContextMenuHide 2663 * @param {Object} context The Context menu instance. 2664 */ 2665'afterContextMenuHide', 2666 2667/** 2668 * @description 2669 * Fired after opening the Context Menu. 2670 * 2671 * @event Hooks#afterContextMenuShow 2672 * @param {Object} context The Context Menu instance. 2673 */ 2674'afterContextMenuShow', 2675 2676/** 2677 * @description 2678 * Fired after reaching the copy limit while copying data. 2679 * 2680 * @event Hooks#afterCopyLimit 2681 * @param {Number} selectedRows Count of selected copyable rows. 2682 * @param {Number} selectedColumns Count of selected copyable columns. 2683 * @param {Number} copyRowsLimit Current copy rows limit. 2684 * @param {Number} copyColumnsLimit Current copy columns limit. 2685 */ 2686'afterCopyLimit', 2687 2688/** 2689 * Callback is fired before a new column was created. 2690 * 2691 * @since 0.28.0 2692 * @event Hooks#beforeCreateCol 2693 * @param {Number} index Represents the visual index of first newly created column in the data source array. 2694 * @param {Number} amount Number of newly created columns in the data source array. 2695 * @param {String} [source] String that identifies source of hook call 2696 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 2697 */ 2698'beforeCreateCol', 2699 2700/** 2701 * Callback is fired after a new column was created. 2702 * 2703 * @event Hooks#afterCreateCol 2704 * @param {Number} index Represents the visual index of first newly created column in the data source array. 2705 * @param {Number} amount Number of newly created columns in the data source array. 2706 * @param {String} [source] String that identifies source of hook call 2707 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 2708 */ 2709'afterCreateCol', 2710 2711/** 2712 * Callback is fired before a new row was created. 2713 * 2714 * @since 0.28.0 2715 * @event Hooks#beforeCreateRow 2716 * @param {Number} index Represents the visual index of first newly created row in the data source array. 2717 * @param {Number} amount Number of newly created rows in the data source array. 2718 * @param {String} [source] String that identifies source of hook call 2719 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 2720 */ 2721'beforeCreateRow', 2722 2723/** 2724 * Callback is fired after a new row was created. 2725 * 2726 * @event Hooks#afterCreateRow 2727 * @param {Number} index Represents the visual index of first newly created row in the data source array. 2728 * @param {Number} amount Number of newly created rows in the data source array. 2729 * @param {String} [source] String that identifies source of hook call 2730 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 2731 */ 2732'afterCreateRow', 2733 2734/** 2735 * Fired after the current cell is deselected. 2736 * 2737 * @event Hooks#afterDeselect 2738 */ 2739'afterDeselect', 2740 2741/** 2742 * Fired after destroying the Handsontable instance. 2743 * 2744 * @event Hooks#afterDestroy 2745 */ 2746'afterDestroy', 2747 2748/** 2749 * Fired on a `keydown` event on the document body. 2750 * 2751 * @event Hooks#afterDocumentKeyDown 2752 * @param {Event} event A `keydown` event. 2753 */ 2754'afterDocumentKeyDown', 2755 2756/** 2757 * Callback fired after getting the cell settings. 2758 * 2759 * @event Hooks#afterGetCellMeta 2760 * @param {Number} row Visual row index. 2761 * @param {Number} col Visual column index. 2762 * @param {Object} cellProperties Object containing the cell properties. 2763 */ 2764'afterGetCellMeta', 2765 2766/** 2767 * Callback fired after retrieving information about a column header and appending it to the table header. 2768 * 2769 * @event Hooks#afterGetColHeader 2770 * @param {Number} col Visual column index. 2771 * @param {Element} TH Header's TH element. 2772 */ 2773'afterGetColHeader', 2774 2775/** 2776 * Callback fired after retrieving information about a column header and appending it to the table header. 2777 * 2778 * @event Hooks#afterGetRowHeader 2779 * @param {Number} row Visual row index. 2780 * @param {Element} TH Header's TH element. 2781 */ 2782'afterGetRowHeader', 2783 2784/** 2785 * Callback fired after Handsontable instance is initiated. 2786 * 2787 * @event Hooks#afterInit 2788 */ 2789'afterInit', 2790 2791/** 2792 * Callback fired after new data is loaded (by `loadData` method) into the data source array. 2793 * 2794 * @event Hooks#afterLoadData 2795 * @param {Boolean} firstTime flag that determines whether the data has been loaded during the initialization. 2796 */ 2797'afterLoadData', 2798 2799/** 2800 * Fired after a scroll event, which is identified as a momentum scroll (e.g. on an iPad). 2801 * 2802 * @event Hooks#afterMomentumScroll 2803 */ 2804'afterMomentumScroll', 2805 2806/** 2807 * Fired after a `mousedown` event is triggered on the cell corner (the drag handle). 2808 * 2809 * @event Hooks#afterOnCellCornerMouseDown 2810 * @since 0.11 2811 * @param {Object} event `mousedown` event object. 2812 */ 2813'afterOnCellCornerMouseDown', 2814 2815/** 2816 * Fired after a `dblclick` event is triggered on the cell corner (the drag handle). 2817 * 2818 * @event Hooks#afterOnCellCornerDblClick 2819 * @since 0.30.0 2820 * @param {Object} event `dblclick` event object. 2821 */ 2822'afterOnCellCornerDblClick', 2823 2824/** 2825 * Callback fired after clicking on a cell or row/column header. 2826 * In case the row/column header was clicked, the index is negative. 2827 * For example clicking on the row header of cell (0, 0) results with `afterOnCellMouseDown` called 2828 * with coords `{row: 0, col: -1}`. 2829 * 2830 * @event Hooks#afterOnCellMouseDown 2831 * @since 0.11 2832 * @param {Object} event `mousedown` event object. 2833 * @param {Object} coords Coordinates object containing the visual row and visual column indexes of the clicked cell. 2834 * @param {Element} TD Cell's TD (or TH) element. 2835 */ 2836'afterOnCellMouseDown', 2837 2838/** 2839 * Callback fired after hovering a cell or row/column header with the mouse cursor. 2840 * In case the row/column header was hovered, the index is negative. 2841 * For example, hovering over the row header of cell (0, 0) results with `afterOnCellMouseOver` called 2842 * with coords `{row: 0, col: -1}`. 2843 * 2844 * @event Hooks#afterOnCellMouseOver 2845 * @since 0.11 2846 * @param {Object} event `mouseover` event object. 2847 * @param {Object} coords Hovered cell's visual coordinate object. 2848 * @param {Element} TD Cell's TD (or TH) element. 2849 */ 2850'afterOnCellMouseOver', 2851 2852/** 2853 * Callback fired after leaving a cell or row/column header with the mouse cursor. 2854 * 2855 * @event Hooks#afterOnCellMouseOut 2856 * @since 0.31.1 2857 * @param {Object} event `mouseout` event object. 2858 * @param {Object} coords Leaved cell's visual coordinate object. 2859 * @param {Element} TD Cell's TD (or TH) element. 2860 */ 2861'afterOnCellMouseOut', 2862 2863/** 2864 * Callback is fired when one or more columns are removed. 2865 * 2866 * @event Hooks#afterRemoveCol 2867 * @param {Number} index Is an visual index of starter column. 2868 * @param {Number} amount Is an amount of removed columns. 2869 */ 2870'afterRemoveCol', 2871 2872/** 2873 * Callback is fired when one or more rows are removed. 2874 * 2875 * @event Hooks#afterRemoveRow 2876 * @param {Number} index Is an visual index of starter row. 2877 * @param {Number} amount Is an amount of removed rows. 2878 */ 2879'afterRemoveRow', 2880 2881/** 2882 * Callback fired after the Handsontable table is rendered. 2883 * 2884 * @event Hooks#afterRender 2885 * @param {Boolean} isForced Is `true` if rendering was triggered by a change of settings or data; or `false` if 2886 * rendering was triggered by scrolling or moving selection. 2887 */ 2888'afterRender', 2889 2890/** 2891 * Fired before starting rendering the cell. 2892 * 2893 * @event Hooks#beforeRenderer 2894 * @since 0.24.2 2895 * @param {Element} TD Currently rendered cell's TD element. 2896 * @param {Number} row Visual row index. 2897 * @param {Number} col Visual column index. 2898 * @param {String|Number} prop Column property name or a column index, if datasource is an array of arrays. 2899 * @param {String} value Value of the rendered cell. 2900 * @param {Object} cellProperties Object containing the cell's properties. 2901 */ 2902'beforeRenderer', 2903 2904/** 2905 * Fired after finishing rendering the cell (after the renderer finishes). 2906 * 2907 * @event Hooks#afterRenderer 2908 * @since 0.11.0 2909 * @param {Element} TD Currently rendered cell's TD element. 2910 * @param {Number} row Visual row index. 2911 * @param {Number} col Visual column index. 2912 * @param {String|Number} prop Column property name or a column index, if datasource is an array of arrays. 2913 * @param {String} value Value of the rendered cell. 2914 * @param {Object} cellProperties Object containing the cell's properties. 2915 */ 2916'afterRenderer', 2917 2918/** 2919 * Fired after the horizontal scroll event. 2920 * 2921 * @event Hooks#afterScrollHorizontally 2922 * @since 0.11 2923 */ 2924'afterScrollHorizontally', 2925 2926/** 2927 * Fired after the vertical scroll event. 2928 * 2929 * @event Hooks#afterScrollVertically 2930 * @since 0.11 2931 */ 2932'afterScrollVertically', 2933 2934/** 2935 * Callback fired after one or more cells are selected (e.g. during mouse move). 2936 * 2937 * @event Hooks#afterSelection 2938 * @param {Number} r Selection start visual row index. 2939 * @param {Number} c Selection start visual column index. 2940 * @param {Number} r2 Selection end visual row index. 2941 * @param {Number} c2 Selection end visual column index. 2942 * @param {Object} preventScrolling Object with `value` property where its value change will be observed. 2943 * * @example 2944 * ```js 2945 * handsontable({ 2946 * afterSelection: function (r, c, r2, c2, preventScrolling) { 2947 * // setting if prevent scrolling after selection 2948 * 2949 * preventScrolling.value = true; 2950 * } 2951 * }) 2952 * ``` 2953 */ 2954'afterSelection', 2955 2956/** 2957 * Callback fired after one or more cells are selected. The `p` argument represents the source object property name instead of the column number. 2958 * 2959 * @event Hooks#afterSelectionByProp 2960 * @param {Number} r Selection start visual row index. 2961 * @param {String} p Selection start data source object property name. 2962 * @param {Number} r2 Selection end visual row index. 2963 * @param {String} p2 Selection end data source object property name. 2964 * @param {Object} preventScrolling Object with `value` property where its value change will be observed. 2965 * * @example 2966 * ```js 2967 * handsontable({ 2968 * afterSelectionByProp: function (r, c, r2, c2, preventScrolling) { 2969 * // setting if prevent scrolling after selection 2970 * 2971 * preventScrolling.value = true; 2972 * } 2973 * }) 2974 * ``` 2975 */ 2976'afterSelectionByProp', 2977 2978/** 2979 * Callback fired after one or more cells are selected (e.g. on mouse up). 2980 * 2981 * @event Hooks#afterSelectionEnd 2982 * @param {Number} r Selection start visual row index. 2983 * @param {Number} c Selection start visual column index. 2984 * @param {Number} r2 Selection end visual row index. 2985 * @param {Number} c2 Selection end visual column index. 2986 */ 2987'afterSelectionEnd', 2988 2989/** 2990 * Callback fired after one or more cells are selected (e.g. on mouse up). The `p` argument represents the data source object 2991 * property name instead of the column number. 2992 * 2993 * @event Hooks#afterSelectionEndByProp 2994 * @param {Number} r Selection start visual row index. 2995 * @param {String} p Selection start data source object property index. 2996 * @param {Number} r2 Selection end visual row index. 2997 * @param {String} p2 Selection end data source object property index. 2998 */ 2999'afterSelectionEndByProp', 3000 3001/** 3002 * Called after cell meta is changed. 3003 * 3004 * @event Hooks#afterSetCellMeta 3005 * @since 0.11.0 3006 * @param {Number} row Visual row index. 3007 * @param {Number} col Visual column index. 3008 * @param {String} key The updated meta key. 3009 * @param {*} value The updated meta value. 3010 */ 3011'afterSetCellMeta', 3012 3013/** 3014 * Called after cell meta is removed. 3015 * 3016 * @event Hooks#afterRemoveCellMeta 3017 * @since 0.33.1 3018 * @param {Number} row Visual row index. 3019 * @param {Number} col Visual column index. 3020 * @param {String} key The removed meta key. 3021 * @param {*} value Value which was under removed key of cell meta. 3022 */ 3023'afterRemoveCellMeta', 3024 3025/** 3026 * Called after cell data was changed. 3027 * 3028 * @event Hooks#afterSetDataAtCell 3029 * @since 0.28.0 3030 * @param {Array} changes An array of changes in format `[[row, col, oldValue, value], ...]`. 3031 * @param {String} [source] String that identifies source of hook call 3032 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 3033 */ 3034'afterSetDataAtCell', 3035 3036/** 3037 * Called after cell data was changed. 3038 * 3039 * @event Hooks#afterSetDataAtRowProp 3040 * @since 0.28.0 3041 * @param {Array} changes An array of changes in format `[[row, prop, oldValue, value], ...]`. 3042 * @param {String} [source] String that identifies source of hook call 3043 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 3044 */ 3045'afterSetDataAtRowProp', 3046 3047/** 3048 * Fired after calling the `updateSettings` method. 3049 * 3050 * @event Hooks#afterUpdateSettings 3051 * @param {Object} settings New settings object. 3052 */ 3053'afterUpdateSettings', 3054 3055/** 3056 * @description 3057 * A plugin hook executed after validator function, only if validator function is defined. 3058 * Validation result is the first parameter. This can be used to determinate if validation passed successfully or not. 3059 * 3060 * __Returning false from the callback will mark the cell as invalid.__ 3061 * 3062 * @event Hooks#afterValidate 3063 * @since 0.9.5 3064 * @param {Boolean} isValid `true` if valid, `false` if not. 3065 * @param {*} value The value in question. 3066 * @param {Number} row Row index. 3067 * @param {String|Number} prop Property name / column index. 3068 * @param {String} [source] String that identifies source of hook call 3069 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 3070 */ 3071'afterValidate', 3072 3073/** 3074 * Fired before populating the data in the autofill feature. 3075 * 3076 * @event Hooks#beforeAutofill 3077 * @param {Object} start Object containing information about first filled cell: `{row: 2, col: 0}`. 3078 * @param {Object} end Object containing information about last filled cell: `{row: 4, col: 1}`. 3079 * @param {Array} data 2D array containing information about fill pattern: `[["1', "Ted"], ["1', "John"]]`. 3080 */ 3081'beforeAutofill', 3082 3083/** 3084 * Fired before aligning the cell contents. 3085 * 3086 * @event Hooks#beforeCellAlignment 3087 * @param stateBefore 3088 * @param range 3089 * @param {String} type Type of the alignment - either `horizontal` or `vertical` 3090 * @param {String} alignmentClass String defining the alignment class added to the cell. 3091 * Possible values: 3092 * * `htLeft`, 3093 * * `htCenter`, 3094 * * `htRight`, 3095 * * `htJustify` 3096 * for horizontal alignment, 3097 * 3098 * 3099 * * `htTop`, 3100 * * `htMiddle`, 3101 * * `htBottom` 3102 * for vertical alignment. 3103 */ 3104'beforeCellAlignment', 3105 3106/** 3107 * Callback fired before one or more cells is changed. Its main purpose is to alter changes silently before input. 3108 * 3109 * @event Hooks#beforeChange 3110 * @param {Array} changes 2D array containing information about each of the edited cells. 3111 * @param {String} [source] String that identifies source of hook call 3112 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 3113 * @example 3114 * ```js 3115 * // To disregard a single change, set changes[i] to null or remove it from array using changes.splice(i, 1). 3116 * ... 3117 * new Handsontable(document.getElementById('example'), { 3118 * beforeChange: function(changes, source) { 3119 * // [[row, prop, oldVal, newVal], ...] 3120 * changes[0] = null; 3121 * } 3122 * }); 3123 * ... 3124 * 3125 * // To alter a single change, overwrite the desired value to changes[i][3]. 3126 * ... 3127 * new Handsontable(document.getElementById('example'), { 3128 * beforeChange: function(changes, source) { 3129 * // [[row, prop, oldVal, newVal], ...] 3130 * changes[0][3] = 10; 3131 * } 3132 * }); 3133 * ... 3134 * 3135 * // To cancel all edit, return false from the callback or set array length to 0 (changes.length = 0). 3136 * ... 3137 * new Handsontable(document.getElementById('example'), { 3138 * beforeChange: function(changes, source) { 3139 * // [[row, prop, oldVal, newVal], ...] 3140 * return false; 3141 * } 3142 * }); 3143 * ... 3144 * ``` 3145 */ 3146'beforeChange', 3147 3148/** 3149 * Fired right before rendering the changes. 3150 * 3151 * @event Hooks#beforeChangeRender 3152 * @since 0.11 3153 * @param {Array} changes Array in form of [row, prop, oldValue, newValue]. 3154 * @param {String} [source] String that identifies source of hook call 3155 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 3156 */ 3157'beforeChangeRender', 3158 3159/** 3160 * Fired before drawing the borders. 3161 * 3162 * @event Hooks#beforeDrawBorders 3163 * @param {Array} corners Array specifying the current selection borders. 3164 * @param {String} borderClassName Specifies the border class name. 3165 */ 3166'beforeDrawBorders', 3167 3168/** 3169 * Callback fired before getting cell settings. 3170 * 3171 * @event Hooks#beforeGetCellMeta 3172 * @param {Number} row Visual row index. 3173 * @param {Number} col Visual column index. 3174 * @param {Object} cellProperties Object containing the cell's properties. 3175 */ 3176'beforeGetCellMeta', 3177 3178/** 3179 * Called before cell meta is removed. 3180 * 3181 * @event Hooks#beforeRemoveCellMeta 3182 * @since 0.33.1 3183 * @param {Number} row Visual row index. 3184 * @param {Number} col Visual column index. 3185 * @param {String} key The removed meta key. 3186 * @param {*} value Value which is under removed key of cell meta. 3187 */ 3188'beforeRemoveCellMeta', 3189 3190/** 3191 * @description 3192 * Callback fired before Handsontable instance is initiated. 3193 * 3194 * @event Hooks#beforeInit 3195 */ 3196'beforeInit', 3197 3198/** 3199 * Callback fired before Walkontable instance is initiated. 3200 * 3201 * @since 0.11 3202 * @event Hooks#beforeInitWalkontable 3203 * @param {Object} walkontableConfig Walkontable configuration object. 3204 */ 3205'beforeInitWalkontable', 3206 3207/** 3208 * Callback fired before keydown event is handled. It can be used to overwrite default key bindings. 3209 * Caution - in your `beforeKeyDown` handler you need to call `event.stopImmediatePropagation()` to prevent default key behavior. 3210 * 3211 * @event Hooks#beforeKeyDown 3212 * @since 0.9.0 3213 * @param {Event} event Original DOM event. 3214 */ 3215'beforeKeyDown', 3216 3217/** 3218 * Fired after the user clicked a cell, but before all the calculations related with it. 3219 * 3220 * @event Hooks#beforeOnCellMouseDown 3221 * @param {Event} event The `mousedown` event object. 3222 * @param {CellCoords} coords Cell coords object containing the visual coordinates of the clicked cell. 3223 * @param {Element} TD TD element. 3224 */ 3225'beforeOnCellMouseDown', 3226 3227/** 3228 * Fired after the user moved cursor over a cell, but before all the calculations related with it. 3229 * 3230 * @event Hooks#beforeOnCellMouseOver 3231 * @param {Event} event The `mouseover` event object. 3232 * @param {CellCoords} coords CellCoords object containing the visual coordinates of the clicked cell. 3233 * @param {Element} TD TD element. 3234 * @param {Object} blockCalculations Contain keys 'row' and 'column' with boolean value. 3235 */ 3236'beforeOnCellMouseOver', 3237 3238/** 3239 * Fired after the user moved cursor out from a cell, but before all the calculations related with it. 3240 * 3241 * @event Hooks#beforeOnCellMouseOut 3242 * @since 0.31.1 3243 * @param {Event} event The `mouseout` event object. 3244 * @param {WalkontableCellCoords} coords WalkontableCellCoords object containing the visual coordinates of the leaved cell. 3245 * @param {Element} TD TD element. 3246 */ 3247'beforeOnCellMouseOut', 3248 3249/** 3250 * Callback is fired when one or more columns are about to be removed. 3251 * 3252 * @event Hooks#beforeRemoveCol 3253 * @param {Number} index Visual index of starter column. 3254 * @param {Number} amount Amount of columns to be removed. 3255 * @param {Array} [visualCols] Consists of visual indexes of processed columns. 3256 */ 3257'beforeRemoveCol', 3258 3259/** 3260 * Callback is fired when one or more rows are about to be removed. 3261 * 3262 * @event Hooks#beforeRemoveRow 3263 * @param {Number} index Visual index of starter column. 3264 * @param {Number} amount Amount of columns to be removed. 3265 * @param {Array} [visualRows] Consists of visual indexes of processed rows. 3266 */ 3267'beforeRemoveRow', 3268 3269/** 3270 * Callback fired before Handsontable table is rendered. 3271 * 3272 * @event Hooks#beforeRender 3273 * @param {Boolean} isForced If `true` rendering was triggered by a change of settings or data; or `false` if 3274 * rendering was triggered by scrolling or moving selection. 3275 */ 3276'beforeRender', 3277 3278/** 3279 * Callback fired before setting range is started. 3280 * 3281 * @event Hooks#beforeSetRangeStart 3282 * @param {Array} coords CellCoords array. 3283 */ 3284'beforeSetRangeStart', 3285 3286/** 3287 * Callback fired before setting range is ended. 3288 * 3289 * @event Hooks#beforeSetRangeEnd 3290 * @param {Array} coords CellCoords array. 3291 */ 3292'beforeSetRangeEnd', 3293 3294/** 3295 * Fired before the logic of handling a touch scroll, when user started scrolling on a touch-enabled device. 3296 * 3297 * @event Hooks#beforeTouchScroll 3298 */ 3299'beforeTouchScroll', 3300 3301/** 3302 * @description 3303 * A plugin hook executed before validator function, only if validator function is defined. 3304 * This can be used to manipulate the value of changed cell before it is applied to the validator function. 3305 * 3306 * __Notice:__ this will not affect values of changes. This will change value ONLY for validation! 3307 * 3308 * @event Hooks#beforeValidate 3309 * @since 0.9.5 3310 * @param {*} value Value of the cell. 3311 * @param {Number} row Row index. 3312 * @param {String|Number} prop Property name / column index. 3313 * @param {String} [source] String that identifies source of hook call 3314 * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}). 3315 */ 3316'beforeValidate', 3317 3318/** 3319 * Callback fired before cell value is rendered into the DOM (through renderer function). 3320 * 3321 * @event Hooks#beforeValueRender 3322 * @since 0.29.0 3323 * @param {*} value Cell value to render. 3324 */ 3325'beforeValueRender', 3326 3327/** 3328 * Callback fired after Handsontable instance is constructed (via `new` operator). 3329 * 3330 * @event Hooks#construct 3331 * @since 0.16.1 3332 */ 3333'construct', 3334 3335/** 3336 * Callback fired after Handsontable instance is initiated but before table is rendered. 3337 * 3338 * @event Hooks#init 3339 * @since 0.16.1 3340 */ 3341'init', 3342 3343/** 3344 * Fired when a column index is about to be modified by a callback function. 3345 * 3346 * @event Hooks#modifyCol 3347 * @since 0.11 3348 * @param {Number} col Visual column index. 3349 */ 3350'modifyCol', 3351 3352/** 3353 * Fired when a column index is about to be de-modified by a callback function. 3354 * 3355 * @event Hooks#unmodifyCol 3356 * @since 0.23.0 3357 * @param {Number} col Physical column index. 3358 */ 3359'unmodifyCol', 3360 3361/** 3362 * Fired when a physical row index is about to be de-modified by a callback function. 3363 * 3364 * @event Hooks#unmodifyRow 3365 * @since 0.26.2 3366 * @param {Number} row Physical row index. 3367 */ 3368'unmodifyRow', 3369/** 3370 * Fired when a column header index is about to be modified by a callback function. 3371 * 3372 * @event Hooks#modifyColHeader 3373 * @since 0.20.0 3374 * @param {Number} column Visual column header index. 3375 */ 3376'modifyColHeader', 3377 3378/** 3379 * Fired when a column width is about to be modified by a callback function. 3380 * 3381 * @event Hooks#modifyColWidth 3382 * @since 0.11 3383 * @param {Number} width Current column width. 3384 * @param {Number} col Column index. 3385 */ 3386'modifyColWidth', 3387 3388/** 3389 * Fired when a row index is about to be modified by a callback function. 3390 * 3391 * @event Hooks#modifyRow 3392 * @since 0.11 3393 * @param {Number} row Row index. 3394 */ 3395'modifyRow', 3396 3397/** 3398 * Fired when a row header index is about to be modified by a callback function. 3399 * 3400 * @event Hooks#modifyRowHeader 3401 * @since 0.20.0 3402 * @param {Number} row Row header index. 3403 */ 3404'modifyRowHeader', 3405 3406/** 3407 * Fired when a row height is about to be modified by a callback function. 3408 * 3409 * @event Hooks#modifyRowHeight 3410 * @since 0.11.0 3411 * @param {Number} height Row height. 3412 * @param {Number} row Row index. 3413 */ 3414'modifyRowHeight', 3415 3416/** 3417 * Fired when a data was retrieved or modified. 3418 * 3419 * @event Hooks#modifyData 3420 * @since 0.28.0 3421 * @param {Number} row Row height. 3422 * @param {Number} column Column index. 3423 * @param {Object} valueHolder Object which contains original value which can be modified by overwriting `.value` property. 3424 * @param {String} ioMode String which indicates for what operation hook is fired (`get` or `set`). 3425 */ 3426'modifyData', 3427 3428/** 3429 * Fired when a data was retrieved or modified. 3430 * 3431 * @event Hooks#modifyRowData 3432 * @since 0.28.0 3433 * @param {Number} row Physical row index. 3434 */ 3435'modifyRowData', 3436 3437/** 3438 * Fired after loading data using the Persistent State plugin. 3439 * 3440 * @event Hooks#persistentStateLoad 3441 * @param {String} key Key string. 3442 * @param {Object} valuePlaceholder Object containing the loaded data. 3443 */ 3444'persistentStateLoad', 3445 3446/** 3447 * Fired after resetting data using the Persistent State plugin. 3448 * 3449 * @event Hooks#persistentStateReset 3450 * @param {String} key Key string. 3451 */ 3452'persistentStateReset', 3453 3454/** 3455 * Fired after resetting data using the Persistent State plugin. 3456 * 3457 * @event Hooks#persistentStateSave 3458 * @param {String} key Key string. 3459 * @param {Mixed} value Value to save. 3460 */ 3461'persistentStateSave', 3462 3463/** 3464 * Fired before sorting the column. If you return `false` value then sorting will be not applied by 3465 * Handsontable (useful for server-side sorting). 3466 * 3467 * @event Hooks#beforeColumnSort 3468 * @param {Number} column Sorted visual column index. 3469 * @param {Boolean} order Soring order where: 3470 * * `true` means ascending order, 3471 * * `false` means descending order, 3472 * * `undefined` means original order. 3473 */ 3474'beforeColumnSort', 3475 3476/** 3477 * Fired after sorting the column. 3478 * 3479 * @event Hooks#afterColumnSort 3480 * @param {Number} column Sorted visual column index. 3481 * @param {Boolean} order Soring order where: 3482 * * `true` means ascending order 3483 * * `false` means descending order 3484 * * `undefined` means original order 3485 */ 3486'afterColumnSort', 3487 3488/** 3489 * @description 3490 * Fired after setting range of autofill. 3491 * Both arguments are provided in the following format: 3492 * ```js 3493 * [startRow, startColumn, endRow, endColumn] 3494 * ``` 3495 * 3496 * @event Hooks#modifyAutofillRange 3497 * @param {Array} startArea Array of visual coordinates of the starting point for the drag-down operation. 3498 * @param {Array} entireArea Array of visual coordinates of the entire area of the drag-down operation. 3499 */ 3500'modifyAutofillRange', 3501 3502/** 3503 * Fired to allow modifying the copyable range with a callback function. 3504 * 3505 * @since 0.19.0 3506 * @event Hooks#modifyCopyableRange 3507 * @param {Array} copyableRanges Array of objects defining copyable cells. 3508 */ 3509'modifyCopyableRange', 3510 3511/** 3512 * Called before copying the values into clipboard and before clearing values of the selected cells. 3513 * 3514 * @event Hooks#beforeCut 3515 * @since 0.31.1 3516 * @param {Array} data An array of arrays which contains data to cut. 3517 * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`) 3518 * which will be cut out. 3519 * @returns {*} If returns `false` then operation of the cutting out is cancelled. 3520 * 3521 * @example 3522 * ```js 3523 * // To disregard a single row, remove it from array using data.splice(i, 1). 3524 * ... 3525 * new Handsontable(document.getElementById('example'), { 3526 * beforeCut: function(data, coords) { 3527 * // data -> [[1, 2, 3], [4, 5, 6]] 3528 * data.splice(0, 1); 3529 * // data -> [[4, 5, 6]] 3530 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}] 3531 * } 3532 * }); 3533 * ... 3534 * 3535 * // To cancel cutting out, return false from the callback. 3536 * ... 3537 * new Handsontable(document.getElementById('example'), { 3538 * beforeCut: function(data, coords) { 3539 * return false; 3540 * } 3541 * }); 3542 * ... 3543 * ``` 3544 */ 3545'beforeCut', 3546 3547/** 3548 * Fired after data are cutted out from the table. 3549 * 3550 * @event Hooks#afterCut 3551 * @since 0.31.1 3552 * @param {Array} data An array of arrays which contains the cutted out data. 3553 * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`) 3554 * which was cut out. 3555 */ 3556'afterCut', 3557 3558/** 3559 * Fired before values are copied into clipboard. 3560 * 3561 * @event Hooks#beforeCopy 3562 * @since 0.31.1 3563 * @param {Array} data An array of arrays which contains data to copied. 3564 * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`) 3565 * which will copied. 3566 * @returns {*} If returns `false` then copying is cancelled. 3567 * 3568 * @example 3569 * ```js 3570 * // To disregard a single row, remove it from array using data.splice(i, 1). 3571 * ... 3572 * new Handsontable(document.getElementById('example'), { 3573 * beforeCopy: function(data, coords) { 3574 * // data -> [[1, 2, 3], [4, 5, 6]] 3575 * data.splice(0, 1); 3576 * // data -> [[4, 5, 6]] 3577 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}] 3578 * } 3579 * }); 3580 * ... 3581 * 3582 * // To cancel copying, return false from the callback. 3583 * ... 3584 * new Handsontable(document.getElementById('example'), { 3585 * beforeCopy: function(data, coords) { 3586 * return false; 3587 * } 3588 * }); 3589 * ... 3590 * ``` 3591 */ 3592'beforeCopy', 3593 3594/** 3595 * Fired after data are pasted into table. 3596 * 3597 * @event Hooks#afterCopy 3598 * @since 0.31.1 3599 * @param {Array} data An array of arrays which contains the copied data. 3600 * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`) 3601 * which was copied. 3602 */ 3603'afterCopy', 3604 3605/** 3606 * Fired before values are pasted into table. 3607 * 3608 * @event Hooks#beforePaste 3609 * @since 0.31.1 3610 * @param {Array} data An array of arrays which contains data to paste. 3611 * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`) 3612 * that correspond to the previously selected area. 3613 * @returns {*} If returns `false` then pasting is cancelled. 3614 * 3615 * @example 3616 * ```js 3617 * // To disregard a single row, remove it from array using data.splice(i, 1). 3618 * ... 3619 * new Handsontable(document.getElementById('example'), { 3620 * beforePaste: function(data, coords) { 3621 * // data -> [[1, 2, 3], [4, 5, 6]] 3622 * data.splice(0, 1); 3623 * // data -> [[4, 5, 6]] 3624 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}] 3625 * } 3626 * }); 3627 * ... 3628 * 3629 * // To cancel pasting, return false from the callback. 3630 * ... 3631 * new Handsontable(document.getElementById('example'), { 3632 * beforePaste: function(data, coords) { 3633 * return false; 3634 * } 3635 * }); 3636 * ... 3637 * ``` 3638 */ 3639'beforePaste', 3640 3641/** 3642 * Fired after values are pasted into table. 3643 * 3644 * @event Hooks#afterePaste 3645 * @since 0.31.1 3646 * @param {Array} data An array of arrays which contains the pasted data. 3647 * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`) 3648 * that correspond to the previously selected area. 3649 */ 3650'afterPaste', 3651 3652/** 3653 * Fired before change order of the visual indexes. 3654 * 3655 * @event Hooks#beforeColumnMove 3656 * @param {Array} columns Array of visual column indexes to be moved. 3657 * @param {Number} target Visual column index being a target for moved columns. 3658 */ 3659'beforeColumnMove', 3660 3661/** 3662 * Fired after change order of the visual indexes. 3663 * 3664 * @event Hooks#afterColumnMove 3665 * @param {Array} columns Array of visual column indexes that were moved. 3666 * @param {Number} target Visual column index being a target for moved columns. 3667 */ 3668'afterColumnMove', 3669 3670/** 3671 * Fired before change order of the visual indexes. 3672 * 3673 * @event Hooks#beforeRowMove 3674 * @param {Array} rows Array of visual row indexes to be moved. 3675 * @param {Number} target Visual row index being a target for moved rows. 3676 */ 3677'beforeRowMove', 3678 3679/** 3680 * Fired after change order of the visual indexes. 3681 * 3682 * @event Hooks#afterRowMove 3683 * @param {Array} rows Array of visual row indexes that were moved. 3684 * @param {Number} target Visual row index being a target for moved rows. 3685 */ 3686'afterRowMove', 3687 3688/** 3689 * Fired before rendering the table with modified column sizes. 3690 * 3691 * @event Hooks#beforeColumnResize 3692 * @param {Number} currentColumn Visual index of the resized column. 3693 * @param {Number} newSize Calculated new column width. 3694 * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click. 3695 * @returns {Number} Returns a new column size or `undefined`, if column size should be calculated automatically. 3696 */ 3697'beforeColumnResize', 3698 3699/** 3700 * Fired after rendering the table with modified column sizes. 3701 * 3702 * @event Hooks#afterColumnResize 3703 * @param {Number} currentColumn Visual index of the resized column. 3704 * @param {Number} newSize Calculated new column width. 3705 * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click. 3706 */ 3707'afterColumnResize', 3708 3709/** 3710 * Fired before rendering the table with modified row sizes. 3711 * 3712 * @event Hooks#beforeRowResize 3713 * @param {Number} currentRow Visual index of the resized row. 3714 * @param {Number} newSize Calculated new row height. 3715 * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click. 3716 * @returns {Number} Returns the new row size or `undefined` if row size should be calculated automatically. 3717 */ 3718'beforeRowResize', 3719 3720/** 3721 * Fired after rendering the table with modified row sizes. 3722 * 3723 * @event Hooks#afterRowResize 3724 * @param {Number} currentRow Visual index of the resized row. 3725 * @param {Number} newSize Calculated new row height. 3726 * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click. 3727 */ 3728'afterRowResize', 3729 3730/** 3731 * Fired after getting the column header renderers. 3732 * 3733 * @event Hooks#afterGetColumnHeaderRenderers 3734 * @param {Array} array Array of the column header renderers. 3735 */ 3736'afterGetColumnHeaderRenderers', 3737 3738/** 3739 * Fired after getting the row header renderers. 3740 * 3741 * @event Hooks#afterGetRowHeaderRenderers 3742 * @param {Array} array Array of the row header renderers. 3743 */ 3744'afterGetRowHeaderRenderers', 3745 3746/** 3747 * Fired before applying stretched column width to column. 3748 * 3749 * @event Hooks#beforeStretchingColumnWidth 3750 * @param {Number} stretchedWidth Calculated width. 3751 * @param {Number} column Visual column index. 3752 * @returns {Number} Returns new width which will be applied to the column element. 3753 */ 3754'beforeStretchingColumnWidth', 3755 3756/** 3757 * Fired before applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}. 3758 * 3759 * @pro 3760 * @event Hooks#beforeFilter 3761 * @param {Array} conditionsStack An array of objects with added formulas. 3762 * @returns {Boolean} If hook returns `false` value then filtering won't be applied on the UI side (server-side filtering). 3763 */ 3764'beforeFilter', 3765 3766/** 3767 * Fired after applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}. 3768 * 3769 * @pro 3770 * @event Hooks#afterFilter 3771 * @param {Array} conditionsStack An array of objects with added formulas. 3772 */ 3773'afterFilter', 3774 3775/** 3776 * Used to modify the column header height. 3777 * 3778 * @event Hooks#modifyColumnHeaderHeight 3779 * @since 0.25.0 3780 * @param {Number} col Visual column index. 3781 */ 3782'modifyColumnHeaderHeight', 3783 3784/** 3785 * Fired before the undo action. Contains information about the action that is being undone. 3786 * 3787 * @event Hooks#beforeUndo 3788 * @since 0.26.2 3789 * @param {Object} action The action object. Contains information about the action being undone. The `actionType` 3790 * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`). 3791 */ 3792'beforeUndo', 3793 3794/** 3795 * Fired after the undo action. Contains information about the action that is being undone. 3796 * 3797 * @event Hooks#afterUndo 3798 * @since 0.26.2 3799 * @param {Object} action The action object. Contains information about the action being undone. The `actionType` 3800 * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`). 3801 */ 3802'afterUndo', 3803 3804/** 3805 * Fired before the redo action. Contains information about the action that is being redone. 3806 * 3807 * @event Hooks#beforeRedo 3808 * @since 0.26.2 3809 * @param {Object} action The action object. Contains information about the action being redone. The `actionType` 3810 * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`). 3811 */ 3812'beforeRedo', 3813 3814/** 3815 * Fired after the redo action. Contains information about the action that is being redone. 3816 * 3817 * @event Hooks#afterRedo 3818 * @since 0.26.2 3819 * @param {Object} action The action object. Contains information about the action being redone. The `actionType` 3820 * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`). 3821 */ 3822'afterRedo', 3823 3824/** 3825 * Used to modify the row header width. 3826 * 3827 * @event Hooks#modifyRowHeaderWidth 3828 * @param {Number} rowHeaderWidth Row header width. 3829 */ 3830'modifyRowHeaderWidth', 3831 3832/** 3833 * Fired from the `populateFromArray` method during the `autofill` process. Fired for each "autofilled" cell individually. 3834 * 3835 * @event Hooks#beforeAutofillInsidePopulate 3836 * @param {Object} index Object containing `row` and `col` properties, defining the number of rows/columns from the initial cell of the autofill. 3837 * @param {String} direction Declares the direction of the autofill. Possible values: `up`, `down`, `left`, `right`. 3838 * @param {Array} input Array of arrays. Contains an array of rows with data being used in the autofill. 3839 * @param {Array} deltas The deltas array passed to the `populateFromArray` method. 3840 */ 3841'beforeAutofillInsidePopulate', 3842 3843/** 3844 * Fired when the start of the selection is being modified. (e.g. moving the selection with the arrow keys). 3845 * 3846 * @event Hooks#modifyTransformStart 3847 * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one. 3848 */ 3849'modifyTransformStart', 3850 3851/** 3852 * Fired when the end of the selection is being modified. (e.g. moving the selection with the arrow keys). 3853 * 3854 * @event Hooks#modifyTransformEnd 3855 * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one. 3856 */ 3857'modifyTransformEnd', 3858 3859/** 3860 * Fired after the start of the selection is being modified. (e.g. moving the selection with the arrow keys). 3861 * 3862 * @event Hooks#afterModifyTransformStart 3863 * @param {CellCoords} coords Coords of the freshly selected cell. 3864 * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise. 3865 * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise. 3866 */ 3867'afterModifyTransformStart', 3868 3869/** 3870 * Fired after the end of the selection is being modified. (e.g. moving the selection with the arrow keys). 3871 * 3872 * @event Hooks#afterModifyTransformEnd 3873 * @param {CellCoords} coords Visual coords of the freshly selected cell. 3874 * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise. 3875 * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise. 3876 */ 3877'afterModifyTransformEnd', 3878 3879/** 3880 * Fired inside the `viewportRowCalculatorOverride` method. Allows modifying the row calculator parameters. 3881 * 3882 * @event Hooks#afterViewportRowCalculatorOverride 3883 * @param {Object} calc The row calculator. 3884 */ 3885'afterViewportRowCalculatorOverride', 3886 3887/** 3888 * Fired inside the `viewportColumnCalculatorOverride` method. Allows modifying the row calculator parameters. 3889 * 3890 * @event Hooks#afterViewportColumnCalculatorOverride 3891 * @param {Object} calc The row calculator. 3892 */ 3893'afterViewportColumnCalculatorOverride', 3894 3895/** 3896 * Fired after initializing all the plugins. 3897 * 3898 * @event Hooks#afterPluginsInitialized 3899 */ 3900'afterPluginsInitialized', 3901 3902/** 3903 * Used when saving/loading the manual row heights state. 3904 * 3905 * @event Hooks#manualRowHeights 3906 * @param {Array} state The current manual row heights state. 3907 */ 3908'manualRowHeights', 3909 3910/** 3911 * Used to skip the length cache calculation for a defined period of time. 3912 * 3913 * @event Hooks#skipLengthCache 3914 * @param {Number} delay The delay in milliseconds. 3915 */ 3916'skipLengthCache', 3917 3918/** 3919 * Fired after trimming rows in the TrimRows plugin. 3920 * 3921 * @pro 3922 * @event Hooks#afterTrimRow 3923 * @param {Array} rows Physical indexes of trimmed rows. 3924 */ 3925'afterTrimRow', 3926 3927/** 3928 * Fired after untrimming rows in the TrimRows plugin. 3929 * 3930 * @pro 3931 * @event Hooks#afterUntrimRow 3932 * @param {Array} rows Physical indexes of untrimmed rows. 3933 */ 3934'afterUntrimRow', 3935 3936/** 3937 * Fired after opening the dropdown menu. 3938 * 3939 * @pro 3940 * @event Hooks#afterDropdownMenuShow 3941 * @param {DropdownMenu} instance The DropdownMenu instance. 3942 */ 3943'afterDropdownMenuShow', 3944 3945/** 3946 * Fired after hiding the dropdown menu. 3947 * 3948 * @pro 3949 * @event Hooks#afterDropdownMenuHide 3950 * @param {DropdownMenu} instance The DropdownMenu instance. 3951 */ 3952'afterDropdownMenuHide', 3953 3954/** 3955 * Used to check whether the provided row index is hidden. 3956 * 3957 * @pro 3958 * @event Hooks#hiddenRow 3959 * @param {Number} row The visual row index in question. 3960 */ 3961'hiddenRow', 3962 3963/** 3964 * Used to check whether the provided column index is hidden. 3965 * 3966 * @pro 3967 * @event Hooks#hiddenColumn 3968 * @param {Number} column The visual column index in question. 3969 */ 3970'hiddenColumn', 3971 3972/** 3973 * Fired before adding a children to the NestedRows structure. 3974 * 3975 * @pro 3976 * @event Hooks#beforeAddChild 3977 * @param {Object} parent The parent object. 3978 * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added. 3979 * @param {Number|undefined} index The index within the parent where the new child was added. If `undefined`, the element was added as the last child. 3980 */ 3981'beforeAddChild', 3982 3983/** 3984 * Fired after adding a children to the NestedRows structure. 3985 * 3986 * @pro 3987 * @event Hooks#afterAddChild 3988 * @param {Object} parent The parent object. 3989 * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added. 3990 * @param {Number|undefined} index The index within the parent where the new child was added. If `undefined`, the element was added as the last child. 3991 */ 3992'afterAddChild', 3993 3994/** 3995 * Fired before detaching a child from its parent in the NestedRows plugin. 3996 * 3997 * @pro 3998 * @event Hooks#beforeDetachChild 3999 * @param {Object} parent An object representing the parent from which the element is to be detached. 4000 * @param {Object} element The detached element. 4001 */ 4002'beforeDetachChild', 4003 4004/** 4005 * Fired after detaching a child from its parent in the NestedRows plugin. 4006 * 4007 * @pro 4008 * @event Hooks#afterDetachChild 4009 * @param {Object} parent An object representing the parent from which the element was detached. 4010 * @param {Object} element The detached element. 4011 */ 4012'afterDetachChild', 4013 4014/** 4015 * Fired after the editor is opened and rendered. 4016 * 4017 * @event Hooks#afterBeginEditing 4018 * @param {Number} row Row index of the edited cell. 4019 * @param {Number} column Column index of the edited cell. 4020 */ 4021'afterBeginEditing']; 4022 4023var Hooks = function () { 4024 _createClass(Hooks, null, [{ 4025 key: 'getSingleton', 4026 value: function getSingleton() { 4027 return globalSingleton; 4028 } 4029 4030 /** 4031 * 4032 */ 4033 4034 }]); 4035 4036 function Hooks() { 4037 _classCallCheck(this, Hooks); 4038 4039 this.globalBucket = this.createEmptyBucket(); 4040 } 4041 4042 /** 4043 * Returns a new object with empty handlers related to every registered hook name. 4044 * 4045 * @returns {Object} The empty bucket object. 4046 * 4047 * @example 4048 * ```js 4049 * Handsontable.hooks.createEmptyBucket(); 4050 * // Results: 4051 * { 4052 * ... 4053 * afterCreateCol: [], 4054 * afterCreateRow: [], 4055 * beforeInit: [], 4056 * ... 4057 * } 4058 * ``` 4059 */ 4060 4061 4062 _createClass(Hooks, [{ 4063 key: 'createEmptyBucket', 4064 value: function createEmptyBucket() { 4065 var bucket = Object.create(null); 4066 4067 // eslint-disable-next-line no-return-assign 4068 (0, _array.arrayEach)(REGISTERED_HOOKS, function (hook) { 4069 return bucket[hook] = []; 4070 }); 4071 4072 return bucket; 4073 } 4074 4075 /** 4076 * Get hook bucket based on the context of the object or if argument is `undefined`, get the global hook bucket. 4077 * 4078 * @param {Object} [context=null] A Handsontable instance. 4079 * @returns {Object} Returns a global or Handsontable instance bucket. 4080 */ 4081 4082 }, { 4083 key: 'getBucket', 4084 value: function getBucket() { 4085 var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 4086 4087 if (context) { 4088 if (!context.pluginHookBucket) { 4089 context.pluginHookBucket = this.createEmptyBucket(); 4090 } 4091 4092 return context.pluginHookBucket; 4093 } 4094 4095 return this.globalBucket; 4096 } 4097 4098 /** 4099 * Adds a listener (globally or locally) to a specified hook name. 4100 * If the `context` parameter is provided, the hook will be added only to the instance it references. 4101 * Otherwise, the callback will be used everytime the hook fires on any Handsontable instance. 4102 * You can provide an array of callback functions as the `callback` argument, this way they will all be fired 4103 * once the hook is triggered. 4104 * 4105 * @see Core#addHook 4106 * @param {String} key Hook name. 4107 * @param {Function|Array} callback Callback function or an array of functions. 4108 * @param {Object} [context=null] The context for the hook callback to be added - a Handsontable instance or leave empty. 4109 * @returns {Hooks} Instance of Hooks. 4110 * 4111 * @example 4112 * ```js 4113 * // single callback, added locally 4114 * Handsontable.hooks.add('beforeInit', myCallback, hotInstance); 4115 * 4116 * // single callback, added globally 4117 * Handsontable.hooks.add('beforeInit', myCallback); 4118 * 4119 * // multiple callbacks, added locally 4120 * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance); 4121 * 4122 * // multiple callbacks, added globally 4123 * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]); 4124 * ``` 4125 */ 4126 4127 }, { 4128 key: 'add', 4129 value: function add(key, callback) { 4130 var _this = this; 4131 4132 var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 4133 4134 if (Array.isArray(callback)) { 4135 (0, _array.arrayEach)(callback, function (c) { 4136 return _this.add(key, c, context); 4137 }); 4138 } else { 4139 var bucket = this.getBucket(context); 4140 4141 if (typeof bucket[key] === 'undefined') { 4142 this.register(key); 4143 bucket[key] = []; 4144 } 4145 callback.skip = false; 4146 4147 if (bucket[key].indexOf(callback) === -1) { 4148 // only add a hook if it has not already been added (adding the same hook twice is now silently ignored) 4149 var foundInitialHook = false; 4150 4151 if (callback.initialHook) { 4152 (0, _array.arrayEach)(bucket[key], function (cb, i) { 4153 if (cb.initialHook) { 4154 bucket[key][i] = callback; 4155 foundInitialHook = true; 4156 4157 return false; 4158 } 4159 }); 4160 } 4161 4162 if (!foundInitialHook) { 4163 bucket[key].push(callback); 4164 } 4165 } 4166 } 4167 4168 return this; 4169 } 4170 4171 /** 4172 * Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket. 4173 * 4174 * @see Core#addHookOnce 4175 * @param {String} key Hook/Event name. 4176 * @param {Function|Array} callback Callback function. 4177 * @param {Object} [context=null] A Handsontable instance. 4178 * 4179 * @example 4180 * ```js 4181 * Handsontable.hooks.once('beforeInit', myCallback, hotInstance); 4182 * ``` 4183 */ 4184 4185 }, { 4186 key: 'once', 4187 value: function once(key, callback) { 4188 var _this2 = this; 4189 4190 var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 4191 4192 if (Array.isArray(callback)) { 4193 (0, _array.arrayEach)(callback, function (c) { 4194 return _this2.once(key, c, context); 4195 }); 4196 } else { 4197 callback.runOnce = true; 4198 this.add(key, callback, context); 4199 } 4200 } 4201 4202 /** 4203 * Removes a listener from a hook with a given name. If the `context` argument is provided, it removes a listener from a local hook assigned to the given Handsontable instance. 4204 * 4205 * @see Core#removeHook 4206 * @param {String} key Hook/Event name. 4207 * @param {Function} callback Callback function (needs the be the function that was previously added to the hook). 4208 * @param {Object} [context=null] Handsontable instance. 4209 * @return {Boolean} Returns `true` if hook was removed, `false` otherwise. 4210 * 4211 * @example 4212 * ```js 4213 * Handsontable.hooks.remove('beforeInit', myCallback); 4214 * ``` 4215 */ 4216 4217 }, { 4218 key: 'remove', 4219 value: function remove(key, callback) { 4220 var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 4221 4222 var bucket = this.getBucket(context); 4223 4224 if (typeof bucket[key] !== 'undefined') { 4225 if (bucket[key].indexOf(callback) >= 0) { 4226 callback.skip = true; 4227 4228 return true; 4229 } 4230 } 4231 4232 return false; 4233 } 4234 4235 /** 4236 * Checks whether there are any registered listeners for the provided hook name. 4237 * If the `context` parameter is provided, it only checks for listeners assigned to the given Handsontable instance. 4238 * 4239 * @param {String} key Hook name. 4240 * @param {Object} [context=null] A Handsontable instance. 4241 * @returns {Boolean} `true` for success, `false` otherwise. 4242 */ 4243 4244 }, { 4245 key: 'has', 4246 value: function has(key) { 4247 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 4248 4249 var bucket = this.getBucket(context); 4250 4251 return !!(bucket[key] !== void 0 && bucket[key].length); 4252 } 4253 4254 /** 4255 * Runs all local and global callbacks assigned to the hook identified by the `key` parameter. 4256 * It returns either a return value from the last called callback or the first parameter (`p1`) passed to the `run` function. 4257 * 4258 * @see Core#runHooks 4259 * @param {Object} context Handsontable instance. 4260 * @param {String} key Hook/Event name. 4261 * @param {*} [p1] Parameter to be passed as an argument to the callback function. 4262 * @param {*} [p2] Parameter to be passed as an argument to the callback function. 4263 * @param {*} [p3] Parameter to be passed as an argument to the callback function. 4264 * @param {*} [p4] Parameter to be passed as an argument to the callback function. 4265 * @param {*} [p5] Parameter to be passed as an argument to the callback function. 4266 * @param {*} [p6] Parameter to be passed as an argument to the callback function. 4267 * @returns {*} Either a return value from the last called callback or `p1`. 4268 * 4269 * @example 4270 * ```js 4271 * Handsontable.hooks.run(hot, 'beforeInit'); 4272 * ``` 4273 */ 4274 4275 }, { 4276 key: 'run', 4277 value: function run(context, key, p1, p2, p3, p4, p5, p6) { 4278 { 4279 var globalHandlers = this.globalBucket[key]; 4280 var index = -1; 4281 var length = globalHandlers ? globalHandlers.length : 0; 4282 4283 if (length) { 4284 // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC. 4285 while (++index < length) { 4286 if (!globalHandlers[index] || globalHandlers[index].skip) { 4287 /* eslint-disable no-continue */ 4288 continue; 4289 } 4290 // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture 4291 var res = globalHandlers[index].call(context, p1, p2, p3, p4, p5, p6); 4292 4293 if (res !== void 0) { 4294 p1 = res; 4295 } 4296 if (globalHandlers[index] && globalHandlers[index].runOnce) { 4297 this.remove(key, globalHandlers[index]); 4298 } 4299 } 4300 } 4301 } 4302 { 4303 var localHandlers = this.getBucket(context)[key]; 4304 var _index = -1; 4305 var _length = localHandlers ? localHandlers.length : 0; 4306 4307 if (_length) { 4308 // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC. 4309 while (++_index < _length) { 4310 if (!localHandlers[_index] || localHandlers[_index].skip) { 4311 /* eslint-disable no-continue */ 4312 continue; 4313 } 4314 // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture 4315 var _res = localHandlers[_index].call(context, p1, p2, p3, p4, p5, p6); 4316 4317 if (_res !== void 0) { 4318 p1 = _res; 4319 } 4320 if (localHandlers[_index] && localHandlers[_index].runOnce) { 4321 this.remove(key, localHandlers[_index], context); 4322 } 4323 } 4324 } 4325 } 4326 4327 return p1; 4328 } 4329 4330 /** 4331 * Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed. 4332 * 4333 * @param {Object} [context=null] A Handsontable instance. 4334 * @example 4335 * ```js 4336 * // destroy the global listeners 4337 * Handsontable.hooks.destroy(); 4338 * 4339 * // destroy the local listeners 4340 * Handsontable.hooks.destroy(hotInstance); 4341 * ``` 4342 */ 4343 4344 }, { 4345 key: 'destroy', 4346 value: function destroy() { 4347 var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 4348 4349 // eslint-disable-next-line no-return-assign 4350 (0, _object.objectEach)(this.getBucket(context), function (value, key, bucket) { 4351 return bucket[key].length = 0; 4352 }); 4353 } 4354 4355 /** 4356 * Registers a hook name (adds it to the list of the known hook names). Used by plugins. 4357 * It is not necessary to call register, but if you use it, your plugin hook will be used returned by 4358 * the `getRegistered` method. (which itself is used in the demo http://docs.handsontable.com/tutorial-callbacks.html). 4359 * 4360 * @param key {String} The hook name. 4361 * 4362 * @example 4363 * ```js 4364 * Handsontable.hooks.register('myHook'); 4365 * ``` 4366 */ 4367 4368 }, { 4369 key: 'register', 4370 value: function register(key) { 4371 if (!this.isRegistered(key)) { 4372 REGISTERED_HOOKS.push(key); 4373 } 4374 } 4375 4376 /** 4377 * Deregisters a hook name (removes it from the list of known hook names). 4378 * 4379 * @param key {String} Hook name. 4380 * 4381 * @example 4382 * ```js 4383 * Handsontable.hooks.deregister('myHook'); 4384 * ``` 4385 */ 4386 4387 }, { 4388 key: 'deregister', 4389 value: function deregister(key) { 4390 if (this.isRegistered(key)) { 4391 REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1); 4392 } 4393 } 4394 4395 /** 4396 * Returns a boolean depending on if a hook by such name has been registered. 4397 * 4398 * @param key {String} Hook name. 4399 * @returns {Boolean} `true` for success, `false` otherwise. 4400 * 4401 * @example 4402 * ```js 4403 * Handsontable.hooks.isRegistered('beforeInit'); 4404 * 4405 * // Results: 4406 * true 4407 * ``` 4408 */ 4409 4410 }, { 4411 key: 'isRegistered', 4412 value: function isRegistered(key) { 4413 return REGISTERED_HOOKS.indexOf(key) >= 0; 4414 } 4415 4416 /** 4417 * Returns an array of registered hooks. 4418 * 4419 * @returns {Array} An array of registered hooks. 4420 * 4421 * @example 4422 * ```js 4423 * Handsontable.hooks.getRegistered(); 4424 * 4425 * // Results: 4426 * [ 4427 * ... 4428 * 'beforeInit', 4429 * 'beforeRender', 4430 * 'beforeSetRangeEnd', 4431 * 'beforeDrawBorders', 4432 * 'beforeChange', 4433 * ... 4434 * ] 4435 * ``` 4436 */ 4437 4438 }, { 4439 key: 'getRegistered', 4440 value: function getRegistered() { 4441 return REGISTERED_HOOKS; 4442 } 4443 }]); 4444 4445 return Hooks; 4446}(); 4447 4448var globalSingleton = new Hooks(); 4449 4450exports.default = Hooks; 4451 4452/***/ }), 4453/* 12 */ 4454/***/ (function(module, exports) { 4455 4456module.exports = function (it) { 4457 return typeof it === 'object' ? it !== null : typeof it === 'function'; 4458}; 4459 4460 4461/***/ }), 4462/* 13 */ 4463/***/ (function(module, exports, __webpack_require__) { 4464 4465"use strict"; 4466 4467 4468exports.__esModule = true; 4469exports.getRegisteredEditors = exports.getRegisteredEditorNames = exports.hasEditor = exports.getEditorInstance = exports.getEditor = exports.registerEditor = undefined; 4470exports.RegisteredEditor = RegisteredEditor; 4471exports._getEditorInstance = _getEditorInstance; 4472 4473var _staticRegister2 = __webpack_require__(53); 4474 4475var _staticRegister3 = _interopRequireDefault(_staticRegister2); 4476 4477var _pluginHooks = __webpack_require__(11); 4478 4479var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 4480 4481var _baseEditor = __webpack_require__(36); 4482 4483var _baseEditor2 = _interopRequireDefault(_baseEditor); 4484 4485var _autocompleteEditor = __webpack_require__(263); 4486 4487var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor); 4488 4489var _checkboxEditor = __webpack_require__(324); 4490 4491var _checkboxEditor2 = _interopRequireDefault(_checkboxEditor); 4492 4493var _dateEditor = __webpack_require__(325); 4494 4495var _dateEditor2 = _interopRequireDefault(_dateEditor); 4496 4497var _dropdownEditor = __webpack_require__(326); 4498 4499var _dropdownEditor2 = _interopRequireDefault(_dropdownEditor); 4500 4501var _handsontableEditor = __webpack_require__(264); 4502 4503var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor); 4504 4505var _mobileTextEditor = __webpack_require__(327); 4506 4507var _mobileTextEditor2 = _interopRequireDefault(_mobileTextEditor); 4508 4509var _numericEditor = __webpack_require__(328); 4510 4511var _numericEditor2 = _interopRequireDefault(_numericEditor); 4512 4513var _passwordEditor = __webpack_require__(329); 4514 4515var _passwordEditor2 = _interopRequireDefault(_passwordEditor); 4516 4517var _selectEditor = __webpack_require__(330); 4518 4519var _selectEditor2 = _interopRequireDefault(_selectEditor); 4520 4521var _textEditor = __webpack_require__(44); 4522 4523var _textEditor2 = _interopRequireDefault(_textEditor); 4524 4525function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4526 4527var registeredEditorClasses = new WeakMap(); /** 4528 * Utility to register editors and common namespace for keeping reference to all editor classes 4529 */ 4530 4531var _staticRegister = (0, _staticRegister3.default)('editors'), 4532 register = _staticRegister.register, 4533 getItem = _staticRegister.getItem, 4534 hasItem = _staticRegister.hasItem, 4535 getNames = _staticRegister.getNames, 4536 getValues = _staticRegister.getValues; 4537 4538_register('base', _baseEditor2.default); 4539_register('autocomplete', _autocompleteEditor2.default); 4540_register('checkbox', _checkboxEditor2.default); 4541_register('date', _dateEditor2.default); 4542_register('dropdown', _dropdownEditor2.default); 4543_register('handsontable', _handsontableEditor2.default); 4544_register('mobile', _mobileTextEditor2.default); 4545_register('numeric', _numericEditor2.default); 4546_register('password', _passwordEditor2.default); 4547_register('select', _selectEditor2.default); 4548_register('text', _textEditor2.default); 4549 4550function RegisteredEditor(editorClass) { 4551 var instances = {}; 4552 var Clazz = editorClass; 4553 4554 this.getConstructor = function () { 4555 return editorClass; 4556 }; 4557 4558 this.getInstance = function (hotInstance) { 4559 if (!(hotInstance.guid in instances)) { 4560 instances[hotInstance.guid] = new Clazz(hotInstance); 4561 } 4562 4563 return instances[hotInstance.guid]; 4564 }; 4565 4566 _pluginHooks2.default.getSingleton().add('afterDestroy', function () { 4567 instances = {}; 4568 }); 4569} 4570 4571/** 4572 * Returns instance (singleton) of editor class. 4573 * 4574 * @param {String} name Name of an editor under which it has been stored. 4575 * @param {Object} hotInstance Instance of Handsontable. 4576 * @returns {Function} Returns instance of editor. 4577 */ 4578function _getEditorInstance(name, hotInstance) { 4579 var editor = void 0; 4580 4581 if (typeof name === 'function') { 4582 if (!registeredEditorClasses.get(name)) { 4583 _register(null, name); 4584 } 4585 editor = registeredEditorClasses.get(name); 4586 } else if (typeof name === 'string') { 4587 editor = getItem(name); 4588 } else { 4589 throw Error('Only strings and functions can be passed as "editor" parameter'); 4590 } 4591 4592 if (!editor) { 4593 throw Error('No editor registered under name "' + name + '"'); 4594 } 4595 4596 return editor.getInstance(hotInstance); 4597} 4598 4599/** 4600 * Retrieve editor class. 4601 * 4602 * @param {String} name Editor identification. 4603 * @returns {Function} Returns editor class. 4604 */ 4605function _getItem(name) { 4606 if (!hasItem(name)) { 4607 throw Error('No registered editor found under "' + name + '" name'); 4608 } 4609 4610 return getItem(name).getConstructor(); 4611} 4612 4613/** 4614 * Register editor class under specified name. 4615 * 4616 * @param {String} name Editor identification. 4617 * @param {Function} editorClass Editor class. 4618 */ 4619function _register(name, editorClass) { 4620 var editorWrapper = new RegisteredEditor(editorClass); 4621 4622 if (typeof name === 'string') { 4623 register(name, editorWrapper); 4624 } 4625 registeredEditorClasses.set(editorClass, editorWrapper); 4626} 4627 4628exports.registerEditor = _register; 4629exports.getEditor = _getItem; 4630exports.getEditorInstance = _getEditorInstance; 4631exports.hasEditor = hasItem; 4632exports.getRegisteredEditorNames = getNames; 4633exports.getRegisteredEditors = getValues; 4634 4635/***/ }), 4636/* 14 */ 4637/***/ (function(module, exports, __webpack_require__) { 4638 4639"use strict"; 4640 4641 4642exports.__esModule = true; 4643exports.Viewport = exports.TableRenderer = exports.Table = exports.Settings = exports.Selection = exports.Scroll = exports.Overlays = exports.Event = exports.Core = exports.default = exports.Border = exports.TopLeftCornerOverlay = exports.TopOverlay = exports.LeftOverlay = exports.DebugOverlay = exports.RowFilter = exports.ColumnFilter = exports.CellRange = exports.CellCoords = exports.ViewportRowsCalculator = exports.ViewportColumnsCalculator = undefined; 4644 4645__webpack_require__(98); 4646 4647__webpack_require__(115); 4648 4649__webpack_require__(124); 4650 4651__webpack_require__(125); 4652 4653__webpack_require__(109); 4654 4655__webpack_require__(123); 4656 4657__webpack_require__(106); 4658 4659__webpack_require__(107); 4660 4661__webpack_require__(108); 4662 4663__webpack_require__(97); 4664 4665__webpack_require__(120); 4666 4667__webpack_require__(118); 4668 4669__webpack_require__(116); 4670 4671__webpack_require__(121); 4672 4673__webpack_require__(122); 4674 4675__webpack_require__(117); 4676 4677__webpack_require__(119); 4678 4679__webpack_require__(110); 4680 4681__webpack_require__(111); 4682 4683__webpack_require__(112); 4684 4685__webpack_require__(114); 4686 4687__webpack_require__(113); 4688 4689__webpack_require__(95); 4690 4691__webpack_require__(96); 4692 4693__webpack_require__(91); 4694 4695__webpack_require__(94); 4696 4697__webpack_require__(93); 4698 4699__webpack_require__(92); 4700 4701__webpack_require__(70); 4702 4703__webpack_require__(100); 4704 4705__webpack_require__(101); 4706 4707__webpack_require__(103); 4708 4709__webpack_require__(102); 4710 4711__webpack_require__(99); 4712 4713__webpack_require__(105); 4714 4715__webpack_require__(104); 4716 4717__webpack_require__(126); 4718 4719__webpack_require__(129); 4720 4721__webpack_require__(127); 4722 4723__webpack_require__(128); 4724 4725__webpack_require__(131); 4726 4727__webpack_require__(130); 4728 4729__webpack_require__(133); 4730 4731__webpack_require__(132); 4732 4733var _viewportColumns = __webpack_require__(251); 4734 4735var _viewportColumns2 = _interopRequireDefault(_viewportColumns); 4736 4737var _viewportRows = __webpack_require__(252); 4738 4739var _viewportRows2 = _interopRequireDefault(_viewportRows); 4740 4741var _coords = __webpack_require__(43); 4742 4743var _coords2 = _interopRequireDefault(_coords); 4744 4745var _range = __webpack_require__(71); 4746 4747var _range2 = _interopRequireDefault(_range); 4748 4749var _column = __webpack_require__(255); 4750 4751var _column2 = _interopRequireDefault(_column); 4752 4753var _row = __webpack_require__(256); 4754 4755var _row2 = _interopRequireDefault(_row); 4756 4757var _debug = __webpack_require__(307); 4758 4759var _debug2 = _interopRequireDefault(_debug); 4760 4761var _left = __webpack_require__(308); 4762 4763var _left2 = _interopRequireDefault(_left); 4764 4765var _top = __webpack_require__(309); 4766 4767var _top2 = _interopRequireDefault(_top); 4768 4769var _topLeftCorner = __webpack_require__(310); 4770 4771var _topLeftCorner2 = _interopRequireDefault(_topLeftCorner); 4772 4773var _border = __webpack_require__(250); 4774 4775var _border2 = _interopRequireDefault(_border); 4776 4777var _core = __webpack_require__(253); 4778 4779var _core2 = _interopRequireDefault(_core); 4780 4781var _event = __webpack_require__(254); 4782 4783var _event2 = _interopRequireDefault(_event); 4784 4785var _overlays = __webpack_require__(257); 4786 4787var _overlays2 = _interopRequireDefault(_overlays); 4788 4789var _scroll = __webpack_require__(258); 4790 4791var _scroll2 = _interopRequireDefault(_scroll); 4792 4793var _selection = __webpack_require__(311); 4794 4795var _selection2 = _interopRequireDefault(_selection); 4796 4797var _settings = __webpack_require__(259); 4798 4799var _settings2 = _interopRequireDefault(_settings); 4800 4801var _table = __webpack_require__(260); 4802 4803var _table2 = _interopRequireDefault(_table); 4804 4805var _tableRenderer = __webpack_require__(261); 4806 4807var _tableRenderer2 = _interopRequireDefault(_tableRenderer); 4808 4809var _viewport = __webpack_require__(262); 4810 4811var _viewport2 = _interopRequireDefault(_viewport); 4812 4813function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 4814 4815exports.ViewportColumnsCalculator = _viewportColumns2.default; 4816exports.ViewportRowsCalculator = _viewportRows2.default; 4817exports.CellCoords = _coords2.default; 4818exports.CellRange = _range2.default; 4819exports.ColumnFilter = _column2.default; 4820exports.RowFilter = _row2.default; 4821exports.DebugOverlay = _debug2.default; 4822exports.LeftOverlay = _left2.default; 4823exports.TopOverlay = _top2.default; 4824exports.TopLeftCornerOverlay = _topLeftCorner2.default; 4825exports.Border = _border2.default; 4826exports.default = _core2.default; 4827exports.Core = _core2.default; 4828exports.Event = _event2.default; 4829exports.Overlays = _overlays2.default; 4830exports.Scroll = _scroll2.default; 4831exports.Selection = _selection2.default; 4832exports.Settings = _settings2.default; 4833exports.Table = _table2.default; 4834exports.TableRenderer = _tableRenderer2.default; 4835exports.Viewport = _viewport2.default; 4836 4837/***/ }), 4838/* 15 */ 4839/***/ (function(module, exports, __webpack_require__) { 4840 4841"use strict"; 4842 4843 4844exports.__esModule = true; 4845exports.KEY_CODES = undefined; 4846exports.isPrintableChar = isPrintableChar; 4847exports.isMetaKey = isMetaKey; 4848exports.isCtrlKey = isCtrlKey; 4849exports.isKey = isKey; 4850 4851var _array = __webpack_require__(2); 4852 4853var KEY_CODES = exports.KEY_CODES = { 4854 MOUSE_LEFT: 1, 4855 MOUSE_RIGHT: 3, 4856 MOUSE_MIDDLE: 2, 4857 BACKSPACE: 8, 4858 COMMA: 188, 4859 INSERT: 45, 4860 DELETE: 46, 4861 END: 35, 4862 ENTER: 13, 4863 ESCAPE: 27, 4864 CONTROL_LEFT: 91, 4865 COMMAND_LEFT: 17, 4866 COMMAND_RIGHT: 93, 4867 ALT: 18, 4868 HOME: 36, 4869 PAGE_DOWN: 34, 4870 PAGE_UP: 33, 4871 PERIOD: 190, 4872 SPACE: 32, 4873 SHIFT: 16, 4874 CAPS_LOCK: 20, 4875 TAB: 9, 4876 ARROW_RIGHT: 39, 4877 ARROW_LEFT: 37, 4878 ARROW_UP: 38, 4879 ARROW_DOWN: 40, 4880 F1: 112, 4881 F2: 113, 4882 F3: 114, 4883 F4: 115, 4884 F5: 116, 4885 F6: 117, 4886 F7: 118, 4887 F8: 119, 4888 F9: 120, 4889 F10: 121, 4890 F11: 122, 4891 F12: 123, 4892 A: 65, 4893 X: 88, 4894 C: 67, 4895 V: 86 4896}; 4897 4898/** 4899 * Returns true if keyCode represents a printable character. 4900 * 4901 * @param {Number} keyCode 4902 * @returns {Boolean} 4903 */ 4904function isPrintableChar(keyCode) { 4905 return keyCode == 32 || // space 4906 keyCode >= 48 && keyCode <= 57 || // 0-9 4907 keyCode >= 96 && keyCode <= 111 || // numpad 4908 keyCode >= 186 && keyCode <= 192 || // ;=,-./` 4909 keyCode >= 219 && keyCode <= 222 || // []{}\|"' 4910 keyCode >= 226 || // special chars (229 for Asian chars) 4911 keyCode >= 65 && keyCode <= 90; // a-z 4912} 4913 4914/** 4915 * @param {Number} keyCode 4916 * @returns {Boolean} 4917 */ 4918function isMetaKey(keyCode) { 4919 var metaKeys = [KEY_CODES.ARROW_DOWN, KEY_CODES.ARROW_UP, KEY_CODES.ARROW_LEFT, KEY_CODES.ARROW_RIGHT, KEY_CODES.HOME, KEY_CODES.END, KEY_CODES.DELETE, KEY_CODES.BACKSPACE, KEY_CODES.F1, KEY_CODES.F2, KEY_CODES.F3, KEY_CODES.F4, KEY_CODES.F5, KEY_CODES.F6, KEY_CODES.F7, KEY_CODES.F8, KEY_CODES.F9, KEY_CODES.F10, KEY_CODES.F11, KEY_CODES.F12, KEY_CODES.TAB, KEY_CODES.PAGE_DOWN, KEY_CODES.PAGE_UP, KEY_CODES.ENTER, KEY_CODES.ESCAPE, KEY_CODES.SHIFT, KEY_CODES.CAPS_LOCK, KEY_CODES.ALT]; 4920 4921 return metaKeys.indexOf(keyCode) !== -1; 4922} 4923 4924/** 4925 * @param {Number} keyCode 4926 * @returns {Boolean} 4927 */ 4928function isCtrlKey(keyCode) { 4929 return [KEY_CODES.CONTROL_LEFT, 224, KEY_CODES.COMMAND_LEFT, KEY_CODES.COMMAND_RIGHT].indexOf(keyCode) !== -1; 4930} 4931 4932/** 4933 * @param {Number} keyCode 4934 * @param {String} baseCode 4935 * @returns {Boolean} 4936 */ 4937function isKey(keyCode, baseCode) { 4938 var keys = baseCode.split('|'); 4939 var result = false; 4940 4941 (0, _array.arrayEach)(keys, function (key) { 4942 if (keyCode === KEY_CODES[key]) { 4943 result = true; 4944 4945 return false; 4946 } 4947 }); 4948 4949 return result; 4950} 4951 4952/***/ }), 4953/* 16 */ 4954/***/ (function(module, exports, __webpack_require__) { 4955 4956"use strict"; 4957 4958 4959exports.__esModule = true; 4960 4961var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4962 4963var _object = __webpack_require__(3); 4964 4965var _array = __webpack_require__(2); 4966 4967var _recordTranslator = __webpack_require__(268); 4968 4969var _plugins = __webpack_require__(9); 4970 4971function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 4972 4973var privatePool = new WeakMap(); 4974var initializedPlugins = null; 4975 4976/** 4977 * @private 4978 */ 4979 4980var BasePlugin = function () { 4981 /** 4982 * @param {Object} hotInstance Handsontable instance. 4983 */ 4984 function BasePlugin(hotInstance) { 4985 var _this = this; 4986 4987 _classCallCheck(this, BasePlugin); 4988 4989 /** 4990 * Handsontable instance. 4991 * 4992 * @type {Core} 4993 */ 4994 (0, _object.defineGetter)(this, 'hot', hotInstance, { 4995 writable: false 4996 }); 4997 (0, _object.defineGetter)(this, 't', (0, _recordTranslator.getTranslator)(hotInstance), { 4998 writable: false 4999 }); 5000 5001 privatePool.set(this, { hooks: {} }); 5002 initializedPlugins = null; 5003 5004 this.pluginName = null; 5005 this.pluginsInitializedCallbacks = []; 5006 this.isPluginsReady = false; 5007 this.enabled = false; 5008 this.initialized = false; 5009 5010 this.hot.addHook('afterPluginsInitialized', function () { 5011 return _this.onAfterPluginsInitialized(); 5012 }); 5013 this.hot.addHook('afterUpdateSettings', function () { 5014 return _this.onUpdateSettings(); 5015 }); 5016 this.hot.addHook('beforeInit', function () { 5017 return _this.init(); 5018 }); 5019 } 5020 5021 _createClass(BasePlugin, [{ 5022 key: 'init', 5023 value: function init() { 5024 this.pluginName = (0, _plugins.getPluginName)(this.hot, this); 5025 5026 if (this.isEnabled && this.isEnabled()) { 5027 this.enablePlugin(); 5028 } 5029 if (!initializedPlugins) { 5030 initializedPlugins = (0, _plugins.getRegistredPluginNames)(this.hot); 5031 } 5032 if (initializedPlugins.indexOf(this.pluginName) >= 0) { 5033 initializedPlugins.splice(initializedPlugins.indexOf(this.pluginName), 1); 5034 } 5035 if (!initializedPlugins.length) { 5036 this.hot.runHooks('afterPluginsInitialized'); 5037 } 5038 this.initialized = true; 5039 } 5040 5041 /** 5042 * Enable plugin for this Handsontable instance. 5043 */ 5044 5045 }, { 5046 key: 'enablePlugin', 5047 value: function enablePlugin() { 5048 this.enabled = true; 5049 } 5050 5051 /** 5052 * Disable plugin for this Handsontable instance. 5053 */ 5054 5055 }, { 5056 key: 'disablePlugin', 5057 value: function disablePlugin() { 5058 if (this.eventManager) { 5059 this.eventManager.clear(); 5060 } 5061 this.clearHooks(); 5062 this.enabled = false; 5063 } 5064 5065 /** 5066 * Add listener to plugin hooks system. 5067 * 5068 * @param {String} name 5069 * @param {Function} callback 5070 */ 5071 5072 }, { 5073 key: 'addHook', 5074 value: function addHook(name, callback) { 5075 privatePool.get(this).hooks[name] = privatePool.get(this).hooks[name] || []; 5076 5077 var hooks = privatePool.get(this).hooks[name]; 5078 5079 this.hot.addHook(name, callback); 5080 hooks.push(callback); 5081 privatePool.get(this).hooks[name] = hooks; 5082 } 5083 5084 /** 5085 * Remove all hooks listeners by hook name. 5086 * 5087 * @param {String} name 5088 */ 5089 5090 }, { 5091 key: 'removeHooks', 5092 value: function removeHooks(name) { 5093 var _this2 = this; 5094 5095 (0, _array.arrayEach)(privatePool.get(this).hooks[name] || [], function (callback) { 5096 _this2.hot.removeHook(name, callback); 5097 }); 5098 } 5099 5100 /** 5101 * Clear all hooks. 5102 */ 5103 5104 }, { 5105 key: 'clearHooks', 5106 value: function clearHooks() { 5107 var _this3 = this; 5108 5109 var hooks = privatePool.get(this).hooks; 5110 5111 (0, _object.objectEach)(hooks, function (callbacks, name) { 5112 return _this3.removeHooks(name); 5113 }); 5114 hooks.length = 0; 5115 } 5116 5117 /** 5118 * Register function which will be immediately called after all plugins initialized. 5119 * 5120 * @param {Function} callback 5121 */ 5122 5123 }, { 5124 key: 'callOnPluginsReady', 5125 value: function callOnPluginsReady(callback) { 5126 if (this.isPluginsReady) { 5127 callback(); 5128 } else { 5129 this.pluginsInitializedCallbacks.push(callback); 5130 } 5131 } 5132 5133 /** 5134 * On after plugins initialized listener. 5135 * 5136 * @private 5137 */ 5138 5139 }, { 5140 key: 'onAfterPluginsInitialized', 5141 value: function onAfterPluginsInitialized() { 5142 (0, _array.arrayEach)(this.pluginsInitializedCallbacks, function (callback) { 5143 return callback(); 5144 }); 5145 this.pluginsInitializedCallbacks.length = 0; 5146 this.isPluginsReady = true; 5147 } 5148 5149 /** 5150 * On update settings listener. 5151 * 5152 * @private 5153 */ 5154 5155 }, { 5156 key: 'onUpdateSettings', 5157 value: function onUpdateSettings() { 5158 if (this.isEnabled) { 5159 if (this.enabled && !this.isEnabled()) { 5160 this.disablePlugin(); 5161 } 5162 if (!this.enabled && this.isEnabled()) { 5163 this.enablePlugin(); 5164 } 5165 if (this.enabled && this.isEnabled()) { 5166 this.updatePlugin(); 5167 } 5168 } 5169 } 5170 5171 /** 5172 * Updates the plugin to use the latest options you have specified. 5173 * 5174 * @private 5175 */ 5176 5177 }, { 5178 key: 'updatePlugin', 5179 value: function updatePlugin() {} 5180 5181 /** 5182 * Destroy plugin. 5183 */ 5184 5185 }, { 5186 key: 'destroy', 5187 value: function destroy() { 5188 var _this4 = this; 5189 5190 if (this.eventManager) { 5191 this.eventManager.destroy(); 5192 } 5193 this.clearHooks(); 5194 5195 (0, _object.objectEach)(this, function (value, property) { 5196 if (property !== 'hot' && property !== 't') { 5197 _this4[property] = null; 5198 } 5199 }); 5200 delete this.t; 5201 delete this.hot; 5202 } 5203 }]); 5204 5205 return BasePlugin; 5206}(); 5207 5208exports.default = BasePlugin; 5209 5210/***/ }), 5211/* 17 */ 5212/***/ (function(module, exports, __webpack_require__) { 5213 5214var isObject = __webpack_require__(12); 5215module.exports = function (it) { 5216 if (!isObject(it)) throw TypeError(it + ' is not an object!'); 5217 return it; 5218}; 5219 5220 5221/***/ }), 5222/* 18 */ 5223/***/ (function(module, exports, __webpack_require__) { 5224 5225var anObject = __webpack_require__(17); 5226var IE8_DOM_DEFINE = __webpack_require__(275); 5227var toPrimitive = __webpack_require__(87); 5228var dP = Object.defineProperty; 5229 5230exports.f = __webpack_require__(20) ? Object.defineProperty : function defineProperty(O, P, Attributes) { 5231 anObject(O); 5232 P = toPrimitive(P, true); 5233 anObject(Attributes); 5234 if (IE8_DOM_DEFINE) try { 5235 return dP(O, P, Attributes); 5236 } catch (e) { /* empty */ } 5237 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); 5238 if ('value' in Attributes) O[P] = Attributes.value; 5239 return O; 5240}; 5241 5242 5243/***/ }), 5244/* 19 */ 5245/***/ (function(module, exports, __webpack_require__) { 5246 5247"use strict"; 5248 5249 5250exports.__esModule = true; 5251exports.normalizeSelection = normalizeSelection; 5252exports.isSeparator = isSeparator; 5253exports.hasSubMenu = hasSubMenu; 5254exports.isDisabled = isDisabled; 5255exports.isSelectionDisabled = isSelectionDisabled; 5256exports.getValidSelection = getValidSelection; 5257exports.prepareVerticalAlignClass = prepareVerticalAlignClass; 5258exports.prepareHorizontalAlignClass = prepareHorizontalAlignClass; 5259exports.getAlignmentClasses = getAlignmentClasses; 5260exports.align = align; 5261exports.checkSelectionConsistency = checkSelectionConsistency; 5262exports.markLabelAsSelected = markLabelAsSelected; 5263exports.isItemHidden = isItemHidden; 5264exports.filterSeparators = filterSeparators; 5265 5266var _array = __webpack_require__(2); 5267 5268var _element = __webpack_require__(0); 5269 5270var _separator = __webpack_require__(73); 5271 5272function normalizeSelection(selRange) { 5273 return { 5274 start: selRange.getTopLeftCorner(), 5275 end: selRange.getBottomRightCorner() 5276 }; 5277} 5278 5279function isSeparator(cell) { 5280 return (0, _element.hasClass)(cell, 'htSeparator'); 5281} 5282 5283function hasSubMenu(cell) { 5284 return (0, _element.hasClass)(cell, 'htSubmenu'); 5285} 5286 5287function isDisabled(cell) { 5288 return (0, _element.hasClass)(cell, 'htDisabled'); 5289} 5290 5291function isSelectionDisabled(cell) { 5292 return (0, _element.hasClass)(cell, 'htSelectionDisabled'); 5293} 5294 5295function getValidSelection(hot) { 5296 var selected = hot.getSelected(); 5297 5298 if (!selected) { 5299 return null; 5300 } 5301 if (selected[0] < 0) { 5302 return null; 5303 } 5304 5305 return selected; 5306} 5307 5308function prepareVerticalAlignClass(className, alignment) { 5309 if (className.indexOf(alignment) != -1) { 5310 return className; 5311 } 5312 className = className.replace('htTop', '').replace('htMiddle', '').replace('htBottom', '').replace(' ', ''); 5313 5314 className += ' ' + alignment; 5315 5316 return className; 5317} 5318 5319function prepareHorizontalAlignClass(className, alignment) { 5320 if (className.indexOf(alignment) != -1) { 5321 return className; 5322 } 5323 className = className.replace('htLeft', '').replace('htCenter', '').replace('htRight', '').replace('htJustify', '').replace(' ', ''); 5324 5325 className += ' ' + alignment; 5326 5327 return className; 5328} 5329 5330function getAlignmentClasses(range, callback) { 5331 var classes = {}; 5332 5333 for (var row = range.from.row; row <= range.to.row; row++) { 5334 for (var col = range.from.col; col <= range.to.col; col++) { 5335 if (!classes[row]) { 5336 classes[row] = []; 5337 } 5338 classes[row][col] = callback(row, col); 5339 } 5340 } 5341 5342 return classes; 5343} 5344 5345function align(range, type, alignment, cellDescriptor, propertySetter) { 5346 if (range.from.row == range.to.row && range.from.col == range.to.col) { 5347 applyAlignClassName(range.from.row, range.from.col, type, alignment, cellDescriptor, propertySetter); 5348 } else { 5349 for (var row = range.from.row; row <= range.to.row; row++) { 5350 for (var col = range.from.col; col <= range.to.col; col++) { 5351 applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter); 5352 } 5353 } 5354 } 5355} 5356 5357function applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter) { 5358 var cellMeta = cellDescriptor(row, col); 5359 var className = alignment; 5360 5361 if (cellMeta.className) { 5362 if (type === 'vertical') { 5363 className = prepareVerticalAlignClass(cellMeta.className, alignment); 5364 } else { 5365 className = prepareHorizontalAlignClass(cellMeta.className, alignment); 5366 } 5367 } 5368 5369 propertySetter(row, col, 'className', className); 5370} 5371 5372function checkSelectionConsistency(range, comparator) { 5373 var result = false; 5374 5375 if (range) { 5376 range.forAll(function (row, col) { 5377 if (comparator(row, col)) { 5378 result = true; 5379 5380 return false; 5381 } 5382 }); 5383 } 5384 5385 return result; 5386} 5387 5388function markLabelAsSelected(label) { 5389 // workaround for https://github.com/handsontable/handsontable/issues/1946 5390 return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label; 5391} 5392 5393function isItemHidden(item, instance) { 5394 return !item.hidden || !(typeof item.hidden == 'function' && item.hidden.call(instance)); 5395} 5396 5397function shiftSeparators(items, separator) { 5398 var result = items.slice(0); 5399 5400 for (var i = 0; i < result.length;) { 5401 if (result[i].name === separator) { 5402 result.shift(); 5403 } else { 5404 break; 5405 } 5406 } 5407 return result; 5408} 5409 5410function popSeparators(items, separator) { 5411 var result = items.slice(0); 5412 5413 result.reverse(); 5414 result = shiftSeparators(result, separator); 5415 result.reverse(); 5416 5417 return result; 5418} 5419 5420function removeDuplicatedSeparators(items) { 5421 var result = []; 5422 5423 (0, _array.arrayEach)(items, function (value, index) { 5424 if (index > 0) { 5425 if (result[result.length - 1].name !== value.name) { 5426 result.push(value); 5427 } 5428 } else { 5429 result.push(value); 5430 } 5431 }); 5432 5433 return result; 5434} 5435 5436function filterSeparators(items) { 5437 var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _separator.KEY; 5438 5439 var result = items.slice(0); 5440 5441 result = shiftSeparators(result, separator); 5442 result = popSeparators(result, separator); 5443 result = removeDuplicatedSeparators(result); 5444 5445 return result; 5446} 5447 5448/***/ }), 5449/* 20 */ 5450/***/ (function(module, exports, __webpack_require__) { 5451 5452// Thank's IE8 for his funny defineProperty 5453module.exports = !__webpack_require__(25)(function () { 5454 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; 5455}); 5456 5457 5458/***/ }), 5459/* 21 */ 5460/***/ (function(module, exports, __webpack_require__) { 5461 5462// 7.1.15 ToLength 5463var toInteger = __webpack_require__(64); 5464var min = Math.min; 5465module.exports = function (it) { 5466 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 5467}; 5468 5469 5470/***/ }), 5471/* 22 */ 5472/***/ (function(module, exports, __webpack_require__) { 5473 5474"use strict"; 5475 5476 5477exports.__esModule = true; 5478exports.isIE8 = isIE8; 5479exports.isIE9 = isIE9; 5480exports.isSafari = isSafari; 5481exports.isChrome = isChrome; 5482exports.isMobileBrowser = isMobileBrowser; 5483 5484var _isIE8 = !document.createTextNode('test').textContent; 5485 5486function isIE8() { 5487 return _isIE8; 5488} 5489 5490var _isIE9 = !!document.documentMode; 5491 5492function isIE9() { 5493 return _isIE9; 5494} 5495 5496var _isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor); 5497 5498function isSafari() { 5499 return _isSafari; 5500} 5501 5502var _isChrome = /Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor); 5503 5504function isChrome() { 5505 return _isChrome; 5506} 5507 5508function isMobileBrowser(userAgent) { 5509 if (!userAgent) { 5510 userAgent = navigator.userAgent; 5511 } 5512 5513 return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent) 5514 ); 5515} 5516 5517/***/ }), 5518/* 23 */ 5519/***/ (function(module, exports, __webpack_require__) { 5520 5521"use strict"; 5522 5523 5524exports.__esModule = true; 5525 5526var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 5527 5528var _templateObject = _taggedTemplateLiteral(['\n Your license key of Handsontable Pro has expired.\u200C\u200C\u200C\u200C \n Renew your maintenance plan at https://handsontable.com or downgrade to the previous version of the software.\n '], ['\n Your license key of Handsontable Pro has expired.\u200C\u200C\u200C\u200C\\x20\n Renew your maintenance plan at https://handsontable.com or downgrade to the previous version of the software.\n ']); 5529 5530exports.stringify = stringify; 5531exports.isDefined = isDefined; 5532exports.isUndefined = isUndefined; 5533exports.isEmpty = isEmpty; 5534exports.isRegExp = isRegExp; 5535exports._injectProductInfo = _injectProductInfo; 5536 5537var _element = __webpack_require__(0); 5538 5539var _templateLiteralTag = __webpack_require__(331); 5540 5541function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } 5542 5543/** 5544 * Converts any value to string. 5545 * 5546 * @param {*} value 5547 * @returns {String} 5548 */ 5549function stringify(value) { 5550 var result = void 0; 5551 5552 switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) { 5553 case 'string': 5554 case 'number': 5555 result = '' + value; 5556 break; 5557 5558 case 'object': 5559 result = value === null ? '' : value.toString(); 5560 break; 5561 case 'undefined': 5562 result = ''; 5563 break; 5564 default: 5565 result = value.toString(); 5566 break; 5567 } 5568 5569 return result; 5570} 5571 5572/** 5573 * Checks if given variable is defined. 5574 * 5575 * @param {*} variable Variable to check. 5576 * @returns {Boolean} 5577 */ 5578function isDefined(variable) { 5579 return typeof variable !== 'undefined'; 5580} 5581 5582/** 5583 * Checks if given variable is undefined. 5584 * 5585 * @param {*} variable Variable to check. 5586 * @returns {Boolean} 5587 */ 5588function isUndefined(variable) { 5589 return typeof variable === 'undefined'; 5590} 5591 5592/** 5593 * Check if given variable is null, empty string or undefined. 5594 * 5595 * @param {*} variable Variable to check. 5596 * @returns {Boolean} 5597 */ 5598function isEmpty(variable) { 5599 return variable === null || variable === '' || isUndefined(variable); 5600} 5601 5602/** 5603 * Check if given variable is a regular expression. 5604 * 5605 * @param {*} variable Variable to check. 5606 * @returns {Boolean} 5607 */ 5608function isRegExp(variable) { 5609 return Object.prototype.toString.call(variable) === '[object RegExp]'; 5610} 5611 5612/* eslint-disable */ 5613var _m = '\x6C\x65\x6E\x67\x74\x68'; 5614var _hd = function _hd(v) { 5615 return parseInt(v, 16); 5616}; 5617var _pi = function _pi(v) { 5618 return parseInt(v, 10); 5619}; 5620var _ss = function _ss(v, s, l) { 5621 return v['\x73\x75\x62\x73\x74\x72'](s, l); 5622}; 5623var _cp = function _cp(v) { 5624 return v['\x63\x6F\x64\x65\x50\x6F\x69\x6E\x74\x41\x74'](0) - 65; 5625}; 5626var _norm = function _norm(v) { 5627 return v.replace(/\-/g, ''); 5628}; 5629var _extractTime = function _extractTime(v) { 5630 return _hd(_ss(_norm(v), _hd('12'), _cp('\x46'))) / (_hd(_ss(_norm(v), _cp('\x42'), ~~![][_m])) || 9); 5631}; 5632var _ignored = function _ignored() { 5633 return typeof location !== 'undefined' && /^([a-z0-9\-]+\.)?\x68\x61\x6E\x64\x73\x6F\x6E\x74\x61\x62\x6C\x65\x2E\x63\x6F\x6D$/i.test(location.host); 5634}; 5635var _notified = false; 5636 5637function _injectProductInfo(key, element) { 5638 key = _norm(key || ''); 5639 5640 var warningMessage = ''; 5641 var showDomMessage = true; 5642 var schemaValidity = _checkKeySchema(key); 5643 var ignored = _ignored(); 5644 var trial = isEmpty(key) || key === 'trial'; 5645 5646 if (trial || schemaValidity) { 5647 if (schemaValidity) { 5648 var releaseTime = Math.floor(moment(undefined, 'DD/MM/YYYY').toDate().getTime() / 8.64e7); 5649 var keyGenTime = _extractTime(key); 5650 5651 if (keyGenTime > 45000 || keyGenTime !== parseInt(keyGenTime, 10)) { 5652 warningMessage = 'The license key provided to Handsontable Pro is invalid. Make sure you pass it correctly.'; 5653 } 5654 5655 if (!warningMessage) { 5656 if (releaseTime > keyGenTime + 1) { 5657 warningMessage = (0, _templateLiteralTag.toSingleLine)(_templateObject); 5658 } 5659 showDomMessage = releaseTime > keyGenTime + 15; 5660 } 5661 } else { 5662 warningMessage = 'Evaluation version of Handsontable Pro. Not licensed for use in a production environment.'; 5663 } 5664 } else { 5665 warningMessage = 'The license key provided to Handsontable Pro is invalid. Make sure you pass it correctly.'; 5666 } 5667 if (ignored) { 5668 warningMessage = false; 5669 showDomMessage = false; 5670 } 5671 5672 if (warningMessage && !_notified) { 5673 console[trial ? 'info' : 'warn'](warningMessage); 5674 _notified = true; 5675 } 5676 if (showDomMessage && element.parentNode) { 5677 var message = document.createElement('div'); 5678 5679 (0, _element.addClass)(message, 'display-license-info'); 5680 message.appendChild(document.createTextNode('Evaluation version of Handsontable Pro.')); 5681 message.appendChild(document.createElement('br')); 5682 message.appendChild(document.createTextNode('Not licensed for production use.')); 5683 5684 element.parentNode.insertBefore(message, element.nextSibling); 5685 } 5686} 5687 5688function _checkKeySchema(v) { 5689 var z = [][_m]; 5690 var p = z; 5691 5692 if (v[_m] !== _cp('\x5A')) { 5693 return false; 5694 } 5695 5696 for (var c = '', i = '\x42\x3C\x48\x34\x50\x2B'.split(''), j = _cp(i.shift()); j; j = _cp(i.shift() || 'A')) { 5697 --j < ''[_m] ? p = p | (_pi('' + _pi(_hd(c) + (_hd(_ss(v, Math.abs(j), 2)) + []).padStart(2, '0'))) % _cp('\xA2') || 2) >> 1 : c = _ss(v, j, !j ? 6 : i[_m] === 1 ? 9 : 8); 5698 } 5699 5700 return p === z; 5701} 5702/* eslint-enable */ 5703 5704/***/ }), 5705/* 24 */ 5706/***/ (function(module, exports, __webpack_require__) { 5707 5708"use strict"; 5709 5710 5711exports.__esModule = true; 5712exports.getRegisteredValidators = exports.getRegisteredValidatorNames = exports.hasValidator = exports.getValidator = exports.registerValidator = undefined; 5713 5714var _staticRegister2 = __webpack_require__(53); 5715 5716var _staticRegister3 = _interopRequireDefault(_staticRegister2); 5717 5718var _autocompleteValidator = __webpack_require__(385); 5719 5720var _autocompleteValidator2 = _interopRequireDefault(_autocompleteValidator); 5721 5722var _dateValidator = __webpack_require__(386); 5723 5724var _dateValidator2 = _interopRequireDefault(_dateValidator); 5725 5726var _numericValidator = __webpack_require__(387); 5727 5728var _numericValidator2 = _interopRequireDefault(_numericValidator); 5729 5730var _timeValidator = __webpack_require__(388); 5731 5732var _timeValidator2 = _interopRequireDefault(_timeValidator); 5733 5734function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5735 5736var _staticRegister = (0, _staticRegister3.default)('validators'), 5737 register = _staticRegister.register, 5738 getItem = _staticRegister.getItem, 5739 hasItem = _staticRegister.hasItem, 5740 getNames = _staticRegister.getNames, 5741 getValues = _staticRegister.getValues; 5742 5743register('autocomplete', _autocompleteValidator2.default); 5744register('date', _dateValidator2.default); 5745register('numeric', _numericValidator2.default); 5746register('time', _timeValidator2.default); 5747 5748/** 5749 * Retrieve validator function. 5750 * 5751 * @param {String} name Validator identification. 5752 * @returns {Function} Returns validator function. 5753 */ 5754function _getItem(name) { 5755 if (typeof name === 'function') { 5756 return name; 5757 } 5758 if (!hasItem(name)) { 5759 throw Error('No registered validator found under "' + name + '" name'); 5760 } 5761 5762 return getItem(name); 5763} 5764 5765exports.registerValidator = register; 5766exports.getValidator = _getItem; 5767exports.hasValidator = hasItem; 5768exports.getRegisteredValidatorNames = getNames; 5769exports.getRegisteredValidators = getValues; 5770 5771/***/ }), 5772/* 25 */ 5773/***/ (function(module, exports) { 5774 5775module.exports = function (exec) { 5776 try { 5777 return !!exec(); 5778 } catch (e) { 5779 return true; 5780 } 5781}; 5782 5783 5784/***/ }), 5785/* 26 */ 5786/***/ (function(module, exports) { 5787 5788var hasOwnProperty = {}.hasOwnProperty; 5789module.exports = function (it, key) { 5790 return hasOwnProperty.call(it, key); 5791}; 5792 5793 5794/***/ }), 5795/* 27 */ 5796/***/ (function(module, exports, __webpack_require__) { 5797 5798// to indexed object, toObject with fallback for non-array-like ES3 strings 5799var IObject = __webpack_require__(78); 5800var defined = __webpack_require__(33); 5801module.exports = function (it) { 5802 return IObject(defined(it)); 5803}; 5804 5805 5806/***/ }), 5807/* 28 */ 5808/***/ (function(module, exports, __webpack_require__) { 5809 5810"use strict"; 5811 5812 5813exports.__esModule = true; 5814exports.toUpperCaseFirst = toUpperCaseFirst; 5815exports.equalsIgnoreCase = equalsIgnoreCase; 5816exports.randomString = randomString; 5817exports.isPercentValue = isPercentValue; 5818exports.substitute = substitute; 5819exports.stripTags = stripTags; 5820 5821var _mixed = __webpack_require__(23); 5822 5823var _number = __webpack_require__(5); 5824 5825/** 5826 * Convert string to upper case first letter. 5827 * 5828 * @param {String} string String to convert. 5829 * @returns {String} 5830 */ 5831function toUpperCaseFirst(string) { 5832 return string[0].toUpperCase() + string.substr(1); 5833} 5834 5835/** 5836 * Compare strings case insensitively. 5837 * 5838 * @param {...String} strings Strings to compare. 5839 * @returns {Boolean} 5840 */ 5841function equalsIgnoreCase() { 5842 var unique = []; 5843 5844 for (var _len = arguments.length, strings = Array(_len), _key = 0; _key < _len; _key++) { 5845 strings[_key] = arguments[_key]; 5846 } 5847 5848 var length = strings.length; 5849 5850 while (length--) { 5851 var string = (0, _mixed.stringify)(strings[length]).toLowerCase(); 5852 5853 if (unique.indexOf(string) === -1) { 5854 unique.push(string); 5855 } 5856 } 5857 5858 return unique.length === 1; 5859} 5860 5861/** 5862 * Generates a random hex string. Used as namespace for Handsontable instance events. 5863 * 5864 * @return {String} Returns 16-long character random string (eq. `'92b1bfc74ec4'`). 5865 */ 5866function randomString() { 5867 function s4() { 5868 return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); 5869 } 5870 5871 return s4() + s4() + s4() + s4(); 5872} 5873 5874/** 5875 * Checks if value is valid percent. 5876 * 5877 * @param {String} value 5878 * @returns {Boolean} 5879 */ 5880function isPercentValue(value) { 5881 return (/^([0-9][0-9]?%$)|(^100%$)/.test(value) 5882 ); 5883} 5884 5885/** 5886 * Substitute strings placed beetwen square brackets into value defined in `variables` object. String names defined in 5887 * square brackets must be the same as property name of `variables` object. 5888 * 5889 * @param {String} template Template string. 5890 * @param {Object} variables Object which contains all available values which can be injected into template. 5891 * @returns {String} 5892 */ 5893function substitute(template) { 5894 var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 5895 5896 return ('' + template).replace(/(?:\\)?\[([^[\]]+)]/g, function (match, name) { 5897 if (match.charAt(0) === '\\') { 5898 return match.substr(1, match.length - 1); 5899 } 5900 5901 return variables[name] === void 0 ? '' : variables[name]; 5902 }); 5903} 5904 5905var STRIP_TAGS_REGEX = /<\/?\w+\/?>|<\w+[\s|/][^>]*>/gi; 5906 5907/** 5908 * Strip any HTML tag from the string. 5909 * 5910 * @param {String} string String to cut HTML from. 5911 * @return {String} 5912 */ 5913function stripTags(string) { 5914 string += ''; 5915 5916 return string.replace(STRIP_TAGS_REGEX, ''); 5917} 5918 5919/***/ }), 5920/* 29 */ 5921/***/ (function(module, exports, __webpack_require__) { 5922 5923"use strict"; 5924 5925 5926exports.__esModule = true; 5927 5928var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 5929 5930var _element = __webpack_require__(0); 5931 5932var _object = __webpack_require__(3); 5933 5934var _array = __webpack_require__(2); 5935 5936var _eventManager = __webpack_require__(4); 5937 5938var _eventManager2 = _interopRequireDefault(_eventManager); 5939 5940var _core = __webpack_require__(253); 5941 5942var _core2 = _interopRequireDefault(_core); 5943 5944function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5945 5946function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 5947 5948var registeredOverlays = {}; 5949 5950/** 5951 * Creates an overlay over the original Walkontable instance. The overlay renders the clone of the original Walkontable 5952 * and (optionally) implements behavior needed for native horizontal and vertical scrolling. 5953 * 5954 * @class Overlay 5955 */ 5956 5957var Overlay = function () { 5958 _createClass(Overlay, null, [{ 5959 key: 'registerOverlay', 5960 5961 5962 /** 5963 * Register overlay class. 5964 * 5965 * @param {String} type Overlay type, one of the CLONE_TYPES value 5966 * @param {Overlay} overlayClass Overlay class extended from base overlay class {@link Overlay} 5967 */ 5968 value: function registerOverlay(type, overlayClass) { 5969 if (Overlay.CLONE_TYPES.indexOf(type) === -1) { 5970 throw new Error('Unsupported overlay (' + type + ').'); 5971 } 5972 registeredOverlays[type] = overlayClass; 5973 } 5974 5975 /** 5976 * Create new instance of overlay type. 5977 * 5978 * @param {String} type Overlay type, one of the CLONE_TYPES value 5979 * @param {Walkontable} wot Walkontable instance 5980 */ 5981 5982 }, { 5983 key: 'createOverlay', 5984 value: function createOverlay(type, wot) { 5985 return new registeredOverlays[type](wot); 5986 } 5987 5988 /** 5989 * Check if specified overlay was registered. 5990 * 5991 * @param {String} type Overlay type, one of the CLONE_TYPES value 5992 * @returns {Boolean} 5993 */ 5994 5995 }, { 5996 key: 'hasOverlay', 5997 value: function hasOverlay(type) { 5998 return registeredOverlays[type] !== void 0; 5999 } 6000 6001 /** 6002 * Checks if overlay object (`overlay`) is instance of overlay type (`type`). 6003 * 6004 * @param {Overlay} overlay Overlay object 6005 * @param {String} type Overlay type, one of the CLONE_TYPES value 6006 * @returns {Boolean} 6007 */ 6008 6009 }, { 6010 key: 'isOverlayTypeOf', 6011 value: function isOverlayTypeOf(overlay, type) { 6012 if (!overlay || !registeredOverlays[type]) { 6013 return false; 6014 } 6015 6016 return overlay instanceof registeredOverlays[type]; 6017 } 6018 6019 /** 6020 * @param {Walkontable} wotInstance 6021 */ 6022 6023 }, { 6024 key: 'CLONE_TOP', 6025 6026 /** 6027 * @type {String} 6028 */ 6029 get: function get() { 6030 return 'top'; 6031 } 6032 6033 /** 6034 * @type {String} 6035 */ 6036 6037 }, { 6038 key: 'CLONE_BOTTOM', 6039 get: function get() { 6040 return 'bottom'; 6041 } 6042 6043 /** 6044 * @type {String} 6045 */ 6046 6047 }, { 6048 key: 'CLONE_LEFT', 6049 get: function get() { 6050 return 'left'; 6051 } 6052 6053 /** 6054 * @type {String} 6055 */ 6056 6057 }, { 6058 key: 'CLONE_TOP_LEFT_CORNER', 6059 get: function get() { 6060 return 'top_left_corner'; 6061 } 6062 6063 /** 6064 * @type {String} 6065 */ 6066 6067 }, { 6068 key: 'CLONE_BOTTOM_LEFT_CORNER', 6069 get: function get() { 6070 return 'bottom_left_corner'; 6071 } 6072 6073 /** 6074 * @type {String} 6075 */ 6076 6077 }, { 6078 key: 'CLONE_DEBUG', 6079 get: function get() { 6080 return 'debug'; 6081 } 6082 6083 /** 6084 * List of all availables clone types 6085 * 6086 * @type {Array} 6087 */ 6088 6089 }, { 6090 key: 'CLONE_TYPES', 6091 get: function get() { 6092 return [Overlay.CLONE_TOP, Overlay.CLONE_BOTTOM, Overlay.CLONE_LEFT, Overlay.CLONE_TOP_LEFT_CORNER, Overlay.CLONE_BOTTOM_LEFT_CORNER, Overlay.CLONE_DEBUG]; 6093 } 6094 }]); 6095 6096 function Overlay(wotInstance) { 6097 _classCallCheck(this, Overlay); 6098 6099 (0, _object.defineGetter)(this, 'wot', wotInstance, { 6100 writable: false 6101 }); 6102 6103 // legacy support, deprecated in the future 6104 this.instance = this.wot; 6105 6106 this.type = ''; 6107 this.mainTableScrollableElement = null; 6108 this.TABLE = this.wot.wtTable.TABLE; 6109 this.hider = this.wot.wtTable.hider; 6110 this.spreader = this.wot.wtTable.spreader; 6111 this.holder = this.wot.wtTable.holder; 6112 this.wtRootElement = this.wot.wtTable.wtRootElement; 6113 this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode); 6114 this.areElementSizesAdjusted = false; 6115 this.updateStateOfRendering(); 6116 } 6117 6118 /** 6119 * Update internal state of object with an information about the need of full rendering of the overlay. 6120 * 6121 * @returns {Boolean} Returns `true` if the state has changed since the last check. 6122 */ 6123 6124 6125 _createClass(Overlay, [{ 6126 key: 'updateStateOfRendering', 6127 value: function updateStateOfRendering() { 6128 var previousState = this.needFullRender; 6129 6130 this.needFullRender = this.shouldBeRendered(); 6131 6132 var changed = previousState !== this.needFullRender; 6133 6134 if (changed && !this.needFullRender) { 6135 this.reset(); 6136 } 6137 6138 return changed; 6139 } 6140 6141 /** 6142 * Checks if overlay should be fully rendered 6143 * 6144 * @returns {Boolean} 6145 */ 6146 6147 }, { 6148 key: 'shouldBeRendered', 6149 value: function shouldBeRendered() { 6150 return true; 6151 } 6152 6153 /** 6154 * Update the trimming container. 6155 */ 6156 6157 }, { 6158 key: 'updateTrimmingContainer', 6159 value: function updateTrimmingContainer() { 6160 this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode); 6161 } 6162 6163 /** 6164 * Update the main scrollable element. 6165 */ 6166 6167 }, { 6168 key: 'updateMainScrollableElement', 6169 value: function updateMainScrollableElement() { 6170 this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE); 6171 } 6172 6173 /** 6174 * Make a clone of table for overlay 6175 * 6176 * @param {String} direction Can be `Overlay.CLONE_TOP`, `Overlay.CLONE_LEFT`, 6177 * `Overlay.CLONE_TOP_LEFT_CORNER`, `Overlay.CLONE_DEBUG` 6178 * @returns {Walkontable} 6179 */ 6180 6181 }, { 6182 key: 'makeClone', 6183 value: function makeClone(direction) { 6184 if (Overlay.CLONE_TYPES.indexOf(direction) === -1) { 6185 throw new Error('Clone type "' + direction + '" is not supported.'); 6186 } 6187 var clone = document.createElement('DIV'); 6188 var clonedTable = document.createElement('TABLE'); 6189 6190 clone.className = 'ht_clone_' + direction + ' handsontable'; 6191 clone.style.position = 'absolute'; 6192 clone.style.top = 0; 6193 clone.style.left = 0; 6194 clone.style.overflow = 'hidden'; 6195 6196 clonedTable.className = this.wot.wtTable.TABLE.className; 6197 clone.appendChild(clonedTable); 6198 6199 this.type = direction; 6200 this.wot.wtTable.wtRootElement.parentNode.appendChild(clone); 6201 6202 var preventOverflow = this.wot.getSetting('preventOverflow'); 6203 6204 if (preventOverflow === true || preventOverflow === 'horizontal' && this.type === Overlay.CLONE_TOP || preventOverflow === 'vertical' && this.type === Overlay.CLONE_LEFT) { 6205 this.mainTableScrollableElement = window; 6206 } else { 6207 this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE); 6208 } 6209 6210 return new _core2.default({ 6211 cloneSource: this.wot, 6212 cloneOverlay: this, 6213 table: clonedTable 6214 }); 6215 } 6216 6217 /** 6218 * Refresh/Redraw overlay 6219 * 6220 * @param {Boolean} [fastDraw=false] 6221 */ 6222 6223 }, { 6224 key: 'refresh', 6225 value: function refresh() { 6226 var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 6227 6228 // When hot settings are changed we allow to refresh overlay once before blocking 6229 var nextCycleRenderFlag = this.shouldBeRendered(); 6230 6231 if (this.clone && (this.needFullRender || nextCycleRenderFlag)) { 6232 this.clone.draw(fastDraw); 6233 } 6234 this.needFullRender = nextCycleRenderFlag; 6235 } 6236 6237 /** 6238 * Reset overlay styles to initial values. 6239 */ 6240 6241 }, { 6242 key: 'reset', 6243 value: function reset() { 6244 if (!this.clone) { 6245 return; 6246 } 6247 var holder = this.clone.wtTable.holder; 6248 var hider = this.clone.wtTable.hider; 6249 var holderStyle = holder.style; 6250 var hidderStyle = hider.style; 6251 var rootStyle = holder.parentNode.style; 6252 6253 (0, _array.arrayEach)([holderStyle, hidderStyle, rootStyle], function (style) { 6254 style.width = ''; 6255 style.height = ''; 6256 }); 6257 } 6258 6259 /** 6260 * Destroy overlay instance 6261 */ 6262 6263 }, { 6264 key: 'destroy', 6265 value: function destroy() { 6266 new _eventManager2.default(this.clone).destroy(); 6267 } 6268 }]); 6269 6270 return Overlay; 6271}(); 6272 6273exports.default = Overlay; 6274 6275/***/ }), 6276/* 30 */ 6277/***/ (function(module, exports, __webpack_require__) { 6278 6279// optional / simple context binding 6280var aFunction = __webpack_require__(54); 6281module.exports = function (fn, that, length) { 6282 aFunction(fn); 6283 if (that === undefined) return fn; 6284 switch (length) { 6285 case 1: return function (a) { 6286 return fn.call(that, a); 6287 }; 6288 case 2: return function (a, b) { 6289 return fn.call(that, a, b); 6290 }; 6291 case 3: return function (a, b, c) { 6292 return fn.call(that, a, b, c); 6293 }; 6294 } 6295 return function (/* ...args */) { 6296 return fn.apply(that, arguments); 6297 }; 6298}; 6299 6300 6301/***/ }), 6302/* 31 */ 6303/***/ (function(module, exports, __webpack_require__) { 6304 6305var dP = __webpack_require__(18); 6306var createDesc = __webpack_require__(49); 6307module.exports = __webpack_require__(20) ? function (object, key, value) { 6308 return dP.f(object, key, createDesc(1, value)); 6309} : function (object, key, value) { 6310 object[key] = value; 6311 return object; 6312}; 6313 6314 6315/***/ }), 6316/* 32 */ 6317/***/ (function(module, exports, __webpack_require__) { 6318 6319var global = __webpack_require__(10); 6320var hide = __webpack_require__(31); 6321var has = __webpack_require__(26); 6322var SRC = __webpack_require__(51)('src'); 6323var TO_STRING = 'toString'; 6324var $toString = Function[TO_STRING]; 6325var TPL = ('' + $toString).split(TO_STRING); 6326 6327__webpack_require__(45).inspectSource = function (it) { 6328 return $toString.call(it); 6329}; 6330 6331(module.exports = function (O, key, val, safe) { 6332 var isFunction = typeof val == 'function'; 6333 if (isFunction) has(val, 'name') || hide(val, 'name', key); 6334 if (O[key] === val) return; 6335 if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); 6336 if (O === global) { 6337 O[key] = val; 6338 } else if (!safe) { 6339 delete O[key]; 6340 hide(O, key, val); 6341 } else if (O[key]) { 6342 O[key] = val; 6343 } else { 6344 hide(O, key, val); 6345 } 6346// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 6347})(Function.prototype, TO_STRING, function toString() { 6348 return typeof this == 'function' && this[SRC] || $toString.call(this); 6349}); 6350 6351 6352/***/ }), 6353/* 33 */ 6354/***/ (function(module, exports) { 6355 6356// 7.2.1 RequireObjectCoercible(argument) 6357module.exports = function (it) { 6358 if (it == undefined) throw TypeError("Can't call method on " + it); 6359 return it; 6360}; 6361 6362 6363/***/ }), 6364/* 34 */ 6365/***/ (function(module, exports, __webpack_require__) { 6366 6367"use strict"; 6368 6369 6370exports.__esModule = true; 6371 6372var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 6373 6374exports.requestAnimationFrame = requestAnimationFrame; 6375exports.cancelAnimationFrame = cancelAnimationFrame; 6376exports.isTouchSupported = isTouchSupported; 6377exports.isWebComponentSupportedNatively = isWebComponentSupportedNatively; 6378exports.hasCaptionProblem = hasCaptionProblem; 6379exports.getComparisonFunction = getComparisonFunction; 6380// https://gist.github.com/paulirish/1579671 6381var lastTime = 0; 6382var vendors = ['ms', 'moz', 'webkit', 'o']; 6383var _requestAnimationFrame = window.requestAnimationFrame; 6384var _cancelAnimationFrame = window.cancelAnimationFrame; 6385 6386for (var x = 0; x < vendors.length && !_requestAnimationFrame; ++x) { 6387 _requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; 6388 _cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']; 6389} 6390 6391if (!_requestAnimationFrame) { 6392 _requestAnimationFrame = function _requestAnimationFrame(callback) { 6393 var currTime = new Date().getTime(); 6394 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 6395 var id = window.setTimeout(function () { 6396 callback(currTime + timeToCall); 6397 }, timeToCall); 6398 lastTime = currTime + timeToCall; 6399 6400 return id; 6401 }; 6402} 6403 6404if (!_cancelAnimationFrame) { 6405 _cancelAnimationFrame = function _cancelAnimationFrame(id) { 6406 clearTimeout(id); 6407 }; 6408} 6409 6410/** 6411 * Polyfill for requestAnimationFrame 6412 * 6413 * @param {Function} callback 6414 * @returns {Number} 6415 */ 6416function requestAnimationFrame(callback) { 6417 return _requestAnimationFrame.call(window, callback); 6418} 6419 6420/** 6421 * Polyfill for cancelAnimationFrame 6422 * 6423 * @param {Number} id 6424 */ 6425function cancelAnimationFrame(id) { 6426 _cancelAnimationFrame.call(window, id); 6427} 6428 6429function isTouchSupported() { 6430 return 'ontouchstart' in window; 6431} 6432 6433/** 6434 * Checks if browser is support web components natively 6435 * 6436 * @returns {Boolean} 6437 */ 6438function isWebComponentSupportedNatively() { 6439 var test = document.createElement('div'); 6440 6441 return !!(test.createShadowRoot && test.createShadowRoot.toString().match(/\[native code\]/)); 6442} 6443 6444var _hasCaptionProblem; 6445 6446function detectCaptionProblem() { 6447 var TABLE = document.createElement('TABLE'); 6448 TABLE.style.borderSpacing = 0; 6449 TABLE.style.borderWidth = 0; 6450 TABLE.style.padding = 0; 6451 var TBODY = document.createElement('TBODY'); 6452 TABLE.appendChild(TBODY); 6453 TBODY.appendChild(document.createElement('TR')); 6454 TBODY.firstChild.appendChild(document.createElement('TD')); 6455 TBODY.firstChild.firstChild.innerHTML = '<tr><td>t<br>t</td></tr>'; 6456 6457 var CAPTION = document.createElement('CAPTION'); 6458 CAPTION.innerHTML = 'c<br>c<br>c<br>c'; 6459 CAPTION.style.padding = 0; 6460 CAPTION.style.margin = 0; 6461 TABLE.insertBefore(CAPTION, TBODY); 6462 6463 document.body.appendChild(TABLE); 6464 _hasCaptionProblem = TABLE.offsetHeight < 2 * TABLE.lastChild.offsetHeight; // boolean 6465 document.body.removeChild(TABLE); 6466} 6467 6468function hasCaptionProblem() { 6469 if (_hasCaptionProblem === void 0) { 6470 detectCaptionProblem(); 6471 } 6472 6473 return _hasCaptionProblem; 6474} 6475 6476var comparisonFunction = void 0; 6477 6478/** 6479 * Get string comparison function for sorting purposes. It supports multilingual string comparison base on Internationalization API. 6480 * 6481 * @param {String} [language] 6482 * @param {Object} [options] 6483 * @returns {*} 6484 */ 6485function getComparisonFunction(language) { 6486 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 6487 6488 if (comparisonFunction) { 6489 return comparisonFunction; 6490 } 6491 6492 if ((typeof Intl === 'undefined' ? 'undefined' : _typeof(Intl)) === 'object') { 6493 comparisonFunction = new Intl.Collator(language, options).compare; 6494 } else if (typeof String.prototype.localeCompare === 'function') { 6495 comparisonFunction = function comparisonFunction(a, b) { 6496 return ('' + a).localeCompare(b); 6497 }; 6498 } else { 6499 comparisonFunction = function comparisonFunction(a, b) { 6500 if (a === b) { 6501 return 0; 6502 } 6503 6504 return a > b ? -1 : 1; 6505 }; 6506 } 6507 6508 return comparisonFunction; 6509} 6510 6511/***/ }), 6512/* 35 */ 6513/***/ (function(module, exports, __webpack_require__) { 6514 6515"use strict"; 6516 6517 6518exports.__esModule = true; 6519exports.isFunction = isFunction; 6520exports.throttle = throttle; 6521exports.throttleAfterHits = throttleAfterHits; 6522exports.debounce = debounce; 6523exports.pipe = pipe; 6524exports.partial = partial; 6525exports.curry = curry; 6526exports.curryRight = curryRight; 6527 6528var _array = __webpack_require__(2); 6529 6530/** 6531 * Checks if given variable is function. 6532 * 6533 * @param {*} func Variable to check. 6534 * @returns {Boolean} 6535 */ 6536function isFunction(func) { 6537 return typeof func === 'function'; 6538} 6539 6540/** 6541 * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over time (`wait`). 6542 * 6543 * @param {Function} func Function to invoke. 6544 * @param {Number} wait Delay in miliseconds. 6545 * @returns {Function} 6546 */ 6547function throttle(func) { 6548 var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200; 6549 6550 var lastCalled = 0; 6551 var result = { 6552 lastCallThrottled: true 6553 }; 6554 var lastTimer = null; 6555 6556 function _throttle() { 6557 var _this = this; 6558 6559 var args = arguments; 6560 var stamp = Date.now(); 6561 var needCall = false; 6562 6563 result.lastCallThrottled = true; 6564 6565 if (!lastCalled) { 6566 lastCalled = stamp; 6567 needCall = true; 6568 } 6569 var remaining = wait - (stamp - lastCalled); 6570 6571 if (needCall) { 6572 result.lastCallThrottled = false; 6573 func.apply(this, args); 6574 } else { 6575 if (lastTimer) { 6576 clearTimeout(lastTimer); 6577 } 6578 lastTimer = setTimeout(function () { 6579 result.lastCallThrottled = false; 6580 func.apply(_this, args); 6581 lastCalled = 0; 6582 lastTimer = void 0; 6583 }, remaining); 6584 } 6585 6586 return result; 6587 } 6588 6589 return _throttle; 6590} 6591 6592/** 6593 * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over 6594 * time (`wait`) after specified hits. 6595 * 6596 * @param {Function} func Function to invoke. 6597 * @param {Number} wait Delay in miliseconds. 6598 * @param {Number} hits Number of hits after throttling will be applied. 6599 * @returns {Function} 6600 */ 6601function throttleAfterHits(func) { 6602 var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200; 6603 var hits = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; 6604 6605 var funcThrottle = throttle(func, wait); 6606 var remainHits = hits; 6607 6608 function _clearHits() { 6609 remainHits = hits; 6610 } 6611 function _throttleAfterHits() { 6612 if (remainHits) { 6613 remainHits--; 6614 6615 return func.apply(this, arguments); 6616 } 6617 6618 return funcThrottle.apply(this, arguments); 6619 } 6620 _throttleAfterHits.clearHits = _clearHits; 6621 6622 return _throttleAfterHits; 6623} 6624 6625/** 6626 * Creates debounce function that enforces a function (`func`) not be called again until a certain amount of time (`wait`) 6627 * has passed without it being called. 6628 * 6629 * @param {Function} func Function to invoke. 6630 * @param {Number} wait Delay in milliseconds. 6631 * @returns {Function} 6632 */ 6633function debounce(func) { 6634 var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200; 6635 6636 var lastTimer = null; 6637 var result = void 0; 6638 6639 function _debounce() { 6640 var _this2 = this; 6641 6642 var args = arguments; 6643 6644 if (lastTimer) { 6645 clearTimeout(lastTimer); 6646 } 6647 lastTimer = setTimeout(function () { 6648 result = func.apply(_this2, args); 6649 }, wait); 6650 6651 return result; 6652 } 6653 6654 return _debounce; 6655} 6656 6657/** 6658 * Creates the function that returns the result of calling the given functions. Result of the first function is passed to 6659 * the second as an argument and so on. Only first function in the chain can handle multiple arguments. 6660 * 6661 * @param {Function} functions Functions to compose. 6662 * @returns {Function} 6663 */ 6664function pipe() { 6665 for (var _len = arguments.length, functions = Array(_len), _key = 0; _key < _len; _key++) { 6666 functions[_key] = arguments[_key]; 6667 } 6668 6669 var firstFunc = functions[0], 6670 restFunc = functions.slice(1); 6671 6672 6673 return function _pipe() { 6674 return (0, _array.arrayReduce)(restFunc, function (acc, fn) { 6675 return fn(acc); 6676 }, firstFunc.apply(this, arguments)); 6677 }; 6678} 6679 6680/** 6681 * Creates the function that returns the function with cached arguments. 6682 * 6683 * @param {Function} func Function to partialization. 6684 * @param {Array} params Function arguments to cache. 6685 * @returns {Function} 6686 */ 6687function partial(func) { 6688 for (var _len2 = arguments.length, params = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 6689 params[_key2 - 1] = arguments[_key2]; 6690 } 6691 6692 return function _partial() { 6693 for (var _len3 = arguments.length, restParams = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 6694 restParams[_key3] = arguments[_key3]; 6695 } 6696 6697 return func.apply(this, params.concat(restParams)); 6698 }; 6699} 6700 6701/** 6702 * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched 6703 * to the arguments defined in `func` then function will be invoked. 6704 * Arguments are added to the stack in direction from the left to the right. 6705 * 6706 * @example 6707 * ``` 6708 * var replace = curry(function(find, replace, string) { 6709 * return string.replace(find, replace); 6710 * }); 6711 * 6712 * // returns function with bounded first argument 6713 * var replace = replace('foo') 6714 * 6715 * // returns replaced string - all arguments was passed so function was invoked 6716 * replace('bar', 'Some test with foo...'); 6717 * 6718 * ``` 6719 * 6720 * @param {Function} func Function to currying. 6721 * @returns {Function} 6722 */ 6723function curry(func) { 6724 var argsLength = func.length; 6725 6726 function given(argsSoFar) { 6727 return function _curry() { 6728 for (var _len4 = arguments.length, params = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { 6729 params[_key4] = arguments[_key4]; 6730 } 6731 6732 var passedArgsSoFar = argsSoFar.concat(params); 6733 var result = void 0; 6734 6735 if (passedArgsSoFar.length >= argsLength) { 6736 result = func.apply(this, passedArgsSoFar); 6737 } else { 6738 result = given(passedArgsSoFar); 6739 } 6740 6741 return result; 6742 }; 6743 } 6744 6745 return given([]); 6746} 6747 6748/** 6749 * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched 6750 * to the arguments defined in `func` then function will be invoked. 6751 * Arguments are added to the stack in direction from the right to the left. 6752 * 6753 * @example 6754 * ``` 6755 * var replace = curry(function(find, replace, string) { 6756 * return string.replace(find, replace); 6757 * }); 6758 * 6759 * // returns function with bounded first argument 6760 * var replace = replace('Some test with foo...') 6761 * 6762 * // returns replaced string - all arguments was passed so function was invoked 6763 * replace('bar', 'foo'); 6764 * 6765 * ``` 6766 * 6767 * @param {Function} func Function to currying. 6768 * @returns {Function} 6769 */ 6770function curryRight(func) { 6771 var argsLength = func.length; 6772 6773 function given(argsSoFar) { 6774 return function _curry() { 6775 for (var _len5 = arguments.length, params = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { 6776 params[_key5] = arguments[_key5]; 6777 } 6778 6779 var passedArgsSoFar = argsSoFar.concat(params.reverse()); 6780 var result = void 0; 6781 6782 if (passedArgsSoFar.length >= argsLength) { 6783 result = func.apply(this, passedArgsSoFar); 6784 } else { 6785 result = given(passedArgsSoFar); 6786 } 6787 6788 return result; 6789 }; 6790 } 6791 6792 return given([]); 6793} 6794 6795/***/ }), 6796/* 36 */ 6797/***/ (function(module, exports, __webpack_require__) { 6798 6799"use strict"; 6800 6801 6802exports.__esModule = true; 6803exports.EditorState = undefined; 6804 6805var _src = __webpack_require__(14); 6806 6807var _mixed = __webpack_require__(23); 6808 6809var EditorState = exports.EditorState = { 6810 VIRGIN: 'STATE_VIRGIN', // before editing 6811 EDITING: 'STATE_EDITING', 6812 WAITING: 'STATE_WAITING', // waiting for async validation 6813 FINISHED: 'STATE_FINISHED' 6814}; 6815 6816function BaseEditor(instance) { 6817 this.instance = instance; 6818 this.state = EditorState.VIRGIN; 6819 6820 this._opened = false; 6821 this._fullEditMode = false; 6822 this._closeCallback = null; 6823 6824 this.init(); 6825} 6826 6827BaseEditor.prototype._fireCallbacks = function (result) { 6828 if (this._closeCallback) { 6829 this._closeCallback(result); 6830 this._closeCallback = null; 6831 } 6832}; 6833 6834BaseEditor.prototype.init = function () {}; 6835 6836BaseEditor.prototype.getValue = function () { 6837 throw Error('Editor getValue() method unimplemented'); 6838}; 6839 6840BaseEditor.prototype.setValue = function (newValue) { 6841 throw Error('Editor setValue() method unimplemented'); 6842}; 6843 6844BaseEditor.prototype.open = function () { 6845 throw Error('Editor open() method unimplemented'); 6846}; 6847 6848BaseEditor.prototype.close = function () { 6849 throw Error('Editor close() method unimplemented'); 6850}; 6851 6852BaseEditor.prototype.prepare = function (row, col, prop, td, originalValue, cellProperties) { 6853 this.TD = td; 6854 this.row = row; 6855 this.col = col; 6856 this.prop = prop; 6857 this.originalValue = originalValue; 6858 this.cellProperties = cellProperties; 6859 this.state = EditorState.VIRGIN; 6860}; 6861 6862BaseEditor.prototype.extend = function () { 6863 var baseClass = this.constructor; 6864 6865 function Editor() { 6866 baseClass.apply(this, arguments); 6867 } 6868 6869 function inherit(Child, Parent) { 6870 function Bridge() {} 6871 Bridge.prototype = Parent.prototype; 6872 Child.prototype = new Bridge(); 6873 Child.prototype.constructor = Child; 6874 6875 return Child; 6876 } 6877 6878 return inherit(Editor, baseClass); 6879}; 6880 6881BaseEditor.prototype.saveValue = function (value, ctrlDown) { 6882 var selection = void 0; 6883 var tmp = void 0; 6884 6885 // if ctrl+enter and multiple cells selected, behave like Excel (finish editing and apply to all cells) 6886 if (ctrlDown) { 6887 selection = this.instance.getSelected(); 6888 6889 if (selection[0] > selection[2]) { 6890 tmp = selection[0]; 6891 selection[0] = selection[2]; 6892 selection[2] = tmp; 6893 } 6894 if (selection[1] > selection[3]) { 6895 tmp = selection[1]; 6896 selection[1] = selection[3]; 6897 selection[3] = tmp; 6898 } 6899 } else { 6900 selection = [this.row, this.col, null, null]; 6901 } 6902 6903 this.instance.populateFromArray(selection[0], selection[1], value, selection[2], selection[3], 'edit'); 6904}; 6905 6906BaseEditor.prototype.beginEditing = function (initialValue, event) { 6907 if (this.state != EditorState.VIRGIN) { 6908 return; 6909 } 6910 this.instance.view.scrollViewport(new _src.CellCoords(this.row, this.col)); 6911 this.instance.view.render(); 6912 this.state = EditorState.EDITING; 6913 6914 initialValue = typeof initialValue == 'string' ? initialValue : this.originalValue; 6915 this.setValue((0, _mixed.stringify)(initialValue)); 6916 6917 this.open(event); 6918 this._opened = true; 6919 this.focus(); 6920 6921 // only rerender the selections (FillHandle should disappear when beginediting is triggered) 6922 this.instance.view.render(); 6923 6924 this.instance.runHooks('afterBeginEditing', this.row, this.col); 6925}; 6926 6927BaseEditor.prototype.finishEditing = function (restoreOriginalValue, ctrlDown, callback) { 6928 var _this = this, 6929 val; 6930 6931 if (callback) { 6932 var previousCloseCallback = this._closeCallback; 6933 6934 this._closeCallback = function (result) { 6935 if (previousCloseCallback) { 6936 previousCloseCallback(result); 6937 } 6938 6939 callback(result); 6940 _this.instance.view.render(); 6941 }; 6942 } 6943 6944 if (this.isWaiting()) { 6945 return; 6946 } 6947 6948 if (this.state == EditorState.VIRGIN) { 6949 this.instance._registerTimeout(setTimeout(function () { 6950 _this._fireCallbacks(true); 6951 }, 0)); 6952 6953 return; 6954 } 6955 6956 if (this.state == EditorState.EDITING) { 6957 if (restoreOriginalValue) { 6958 this.cancelChanges(); 6959 this.instance.view.render(); 6960 6961 return; 6962 } 6963 6964 var value = this.getValue(); 6965 6966 if (this.instance.getSettings().trimWhitespace) { 6967 // We trim only string values 6968 val = [[typeof value === 'string' ? String.prototype.trim.call(value || '') : value]]; 6969 } else { 6970 val = [[value]]; 6971 } 6972 6973 this.state = EditorState.WAITING; 6974 this.saveValue(val, ctrlDown); 6975 6976 if (this.instance.getCellValidator(this.cellProperties)) { 6977 this.instance.addHookOnce('postAfterValidate', function (result) { 6978 _this.state = EditorState.FINISHED; 6979 _this.discardEditor(result); 6980 }); 6981 } else { 6982 this.state = EditorState.FINISHED; 6983 this.discardEditor(true); 6984 } 6985 } 6986}; 6987 6988BaseEditor.prototype.cancelChanges = function () { 6989 this.state = EditorState.FINISHED; 6990 this.discardEditor(); 6991}; 6992 6993BaseEditor.prototype.discardEditor = function (result) { 6994 if (this.state !== EditorState.FINISHED) { 6995 return; 6996 } 6997 // validator was defined and failed 6998 if (result === false && this.cellProperties.allowInvalid !== true) { 6999 this.instance.selectCell(this.row, this.col); 7000 this.focus(); 7001 this.state = EditorState.EDITING; 7002 this._fireCallbacks(false); 7003 } else { 7004 this.close(); 7005 this._opened = false; 7006 this._fullEditMode = false; 7007 this.state = EditorState.VIRGIN; 7008 this._fireCallbacks(true); 7009 } 7010}; 7011 7012/** 7013 * Switch editor into full edit mode. In this state navigation keys don't close editor. This mode is activated 7014 * automatically after hit ENTER or F2 key on the cell or while editing cell press F2 key. 7015 */ 7016BaseEditor.prototype.enableFullEditMode = function () { 7017 this._fullEditMode = true; 7018}; 7019 7020/** 7021 * Checks if editor is in full edit mode. 7022 * 7023 * @returns {Boolean} 7024 */ 7025BaseEditor.prototype.isInFullEditMode = function () { 7026 return this._fullEditMode; 7027}; 7028 7029BaseEditor.prototype.isOpened = function () { 7030 return this._opened; 7031}; 7032 7033BaseEditor.prototype.isWaiting = function () { 7034 return this.state === EditorState.WAITING; 7035}; 7036 7037BaseEditor.prototype.checkEditorSection = function () { 7038 var totalRows = this.instance.countRows(); 7039 var section = ''; 7040 7041 if (this.row < this.instance.getSettings().fixedRowsTop) { 7042 if (this.col < this.instance.getSettings().fixedColumnsLeft) { 7043 section = 'top-left-corner'; 7044 } else { 7045 section = 'top'; 7046 } 7047 } else if (this.instance.getSettings().fixedRowsBottom && this.row >= totalRows - this.instance.getSettings().fixedRowsBottom) { 7048 if (this.col < this.instance.getSettings().fixedColumnsLeft) { 7049 section = 'bottom-left-corner'; 7050 } else { 7051 section = 'bottom'; 7052 } 7053 } else if (this.col < this.instance.getSettings().fixedColumnsLeft) { 7054 section = 'left'; 7055 } 7056 7057 return section; 7058}; 7059 7060exports.default = BaseEditor; 7061 7062/***/ }), 7063/* 37 */ 7064/***/ (function(module, exports, __webpack_require__) { 7065 7066// 22.1.3.31 Array.prototype[@@unscopables] 7067var UNSCOPABLES = __webpack_require__(8)('unscopables'); 7068var ArrayProto = Array.prototype; 7069if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(31)(ArrayProto, UNSCOPABLES, {}); 7070module.exports = function (key) { 7071 ArrayProto[UNSCOPABLES][key] = true; 7072}; 7073 7074 7075/***/ }), 7076/* 38 */ 7077/***/ (function(module, exports) { 7078 7079var toString = {}.toString; 7080 7081module.exports = function (it) { 7082 return toString.call(it).slice(8, -1); 7083}; 7084 7085 7086/***/ }), 7087/* 39 */ 7088/***/ (function(module, exports, __webpack_require__) { 7089 7090// 19.1.2.14 / 15.2.3.14 Object.keys(O) 7091var $keys = __webpack_require__(285); 7092var enumBugKeys = __webpack_require__(76); 7093 7094module.exports = Object.keys || function keys(O) { 7095 return $keys(O, enumBugKeys); 7096}; 7097 7098 7099/***/ }), 7100/* 40 */ 7101/***/ (function(module, exports, __webpack_require__) { 7102 7103// 7.1.13 ToObject(argument) 7104var defined = __webpack_require__(33); 7105module.exports = function (it) { 7106 return Object(defined(it)); 7107}; 7108 7109 7110/***/ }), 7111/* 41 */ 7112/***/ (function(module, exports, __webpack_require__) { 7113 7114var isObject = __webpack_require__(12); 7115module.exports = function (it, TYPE) { 7116 if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); 7117 return it; 7118}; 7119 7120 7121/***/ }), 7122/* 42 */ 7123/***/ (function(module, exports, __webpack_require__) { 7124 7125/* WEBPACK VAR INJECTION */(function(module) {//! moment.js 7126//! version : 2.18.1 7127//! authors : Tim Wood, Iskren Chernev, Moment.js contributors 7128//! license : MIT 7129//! momentjs.com 7130 7131;(function (global, factory) { 7132 true ? module.exports = factory() : 7133 typeof define === 'function' && define.amd ? define(factory) : 7134 global.moment = factory() 7135}(this, (function () { 'use strict'; 7136 7137var hookCallback; 7138 7139function hooks () { 7140 return hookCallback.apply(null, arguments); 7141} 7142 7143// This is done to register the method called with moment() 7144// without creating circular dependencies. 7145function setHookCallback (callback) { 7146 hookCallback = callback; 7147} 7148 7149function isArray(input) { 7150 return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]'; 7151} 7152 7153function isObject(input) { 7154 // IE8 will treat undefined and null as object if it wasn't for 7155 // input != null 7156 return input != null && Object.prototype.toString.call(input) === '[object Object]'; 7157} 7158 7159function isObjectEmpty(obj) { 7160 var k; 7161 for (k in obj) { 7162 // even if its not own property I'd still call it non-empty 7163 return false; 7164 } 7165 return true; 7166} 7167 7168function isUndefined(input) { 7169 return input === void 0; 7170} 7171 7172function isNumber(input) { 7173 return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]'; 7174} 7175 7176function isDate(input) { 7177 return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]'; 7178} 7179 7180function map(arr, fn) { 7181 var res = [], i; 7182 for (i = 0; i < arr.length; ++i) { 7183 res.push(fn(arr[i], i)); 7184 } 7185 return res; 7186} 7187 7188function hasOwnProp(a, b) { 7189 return Object.prototype.hasOwnProperty.call(a, b); 7190} 7191 7192function extend(a, b) { 7193 for (var i in b) { 7194 if (hasOwnProp(b, i)) { 7195 a[i] = b[i]; 7196 } 7197 } 7198 7199 if (hasOwnProp(b, 'toString')) { 7200 a.toString = b.toString; 7201 } 7202 7203 if (hasOwnProp(b, 'valueOf')) { 7204 a.valueOf = b.valueOf; 7205 } 7206 7207 return a; 7208} 7209 7210function createUTC (input, format, locale, strict) { 7211 return createLocalOrUTC(input, format, locale, strict, true).utc(); 7212} 7213 7214function defaultParsingFlags() { 7215 // We need to deep clone this object. 7216 return { 7217 empty : false, 7218 unusedTokens : [], 7219 unusedInput : [], 7220 overflow : -2, 7221 charsLeftOver : 0, 7222 nullInput : false, 7223 invalidMonth : null, 7224 invalidFormat : false, 7225 userInvalidated : false, 7226 iso : false, 7227 parsedDateParts : [], 7228 meridiem : null, 7229 rfc2822 : false, 7230 weekdayMismatch : false 7231 }; 7232} 7233 7234function getParsingFlags(m) { 7235 if (m._pf == null) { 7236 m._pf = defaultParsingFlags(); 7237 } 7238 return m._pf; 7239} 7240 7241var some; 7242if (Array.prototype.some) { 7243 some = Array.prototype.some; 7244} else { 7245 some = function (fun) { 7246 var t = Object(this); 7247 var len = t.length >>> 0; 7248 7249 for (var i = 0; i < len; i++) { 7250 if (i in t && fun.call(this, t[i], i, t)) { 7251 return true; 7252 } 7253 } 7254 7255 return false; 7256 }; 7257} 7258 7259var some$1 = some; 7260 7261function isValid(m) { 7262 if (m._isValid == null) { 7263 var flags = getParsingFlags(m); 7264 var parsedParts = some$1.call(flags.parsedDateParts, function (i) { 7265 return i != null; 7266 }); 7267 var isNowValid = !isNaN(m._d.getTime()) && 7268 flags.overflow < 0 && 7269 !flags.empty && 7270 !flags.invalidMonth && 7271 !flags.invalidWeekday && 7272 !flags.nullInput && 7273 !flags.invalidFormat && 7274 !flags.userInvalidated && 7275 (!flags.meridiem || (flags.meridiem && parsedParts)); 7276 7277 if (m._strict) { 7278 isNowValid = isNowValid && 7279 flags.charsLeftOver === 0 && 7280 flags.unusedTokens.length === 0 && 7281 flags.bigHour === undefined; 7282 } 7283 7284 if (Object.isFrozen == null || !Object.isFrozen(m)) { 7285 m._isValid = isNowValid; 7286 } 7287 else { 7288 return isNowValid; 7289 } 7290 } 7291 return m._isValid; 7292} 7293 7294function createInvalid (flags) { 7295 var m = createUTC(NaN); 7296 if (flags != null) { 7297 extend(getParsingFlags(m), flags); 7298 } 7299 else { 7300 getParsingFlags(m).userInvalidated = true; 7301 } 7302 7303 return m; 7304} 7305 7306// Plugins that add properties should also add the key here (null value), 7307// so we can properly clone ourselves. 7308var momentProperties = hooks.momentProperties = []; 7309 7310function copyConfig(to, from) { 7311 var i, prop, val; 7312 7313 if (!isUndefined(from._isAMomentObject)) { 7314 to._isAMomentObject = from._isAMomentObject; 7315 } 7316 if (!isUndefined(from._i)) { 7317 to._i = from._i; 7318 } 7319 if (!isUndefined(from._f)) { 7320 to._f = from._f; 7321 } 7322 if (!isUndefined(from._l)) { 7323 to._l = from._l; 7324 } 7325 if (!isUndefined(from._strict)) { 7326 to._strict = from._strict; 7327 } 7328 if (!isUndefined(from._tzm)) { 7329 to._tzm = from._tzm; 7330 } 7331 if (!isUndefined(from._isUTC)) { 7332 to._isUTC = from._isUTC; 7333 } 7334 if (!isUndefined(from._offset)) { 7335 to._offset = from._offset; 7336 } 7337 if (!isUndefined(from._pf)) { 7338 to._pf = getParsingFlags(from); 7339 } 7340 if (!isUndefined(from._locale)) { 7341 to._locale = from._locale; 7342 } 7343 7344 if (momentProperties.length > 0) { 7345 for (i = 0; i < momentProperties.length; i++) { 7346 prop = momentProperties[i]; 7347 val = from[prop]; 7348 if (!isUndefined(val)) { 7349 to[prop] = val; 7350 } 7351 } 7352 } 7353 7354 return to; 7355} 7356 7357var updateInProgress = false; 7358 7359// Moment prototype object 7360function Moment(config) { 7361 copyConfig(this, config); 7362 this._d = new Date(config._d != null ? config._d.getTime() : NaN); 7363 if (!this.isValid()) { 7364 this._d = new Date(NaN); 7365 } 7366 // Prevent infinite loop in case updateOffset creates new moment 7367 // objects. 7368 if (updateInProgress === false) { 7369 updateInProgress = true; 7370 hooks.updateOffset(this); 7371 updateInProgress = false; 7372 } 7373} 7374 7375function isMoment (obj) { 7376 return obj instanceof Moment || (obj != null && obj._isAMomentObject != null); 7377} 7378 7379function absFloor (number) { 7380 if (number < 0) { 7381 // -0 -> 0 7382 return Math.ceil(number) || 0; 7383 } else { 7384 return Math.floor(number); 7385 } 7386} 7387 7388function toInt(argumentForCoercion) { 7389 var coercedNumber = +argumentForCoercion, 7390 value = 0; 7391 7392 if (coercedNumber !== 0 && isFinite(coercedNumber)) { 7393 value = absFloor(coercedNumber); 7394 } 7395 7396 return value; 7397} 7398 7399// compare two arrays, return the number of differences 7400function compareArrays(array1, array2, dontConvert) { 7401 var len = Math.min(array1.length, array2.length), 7402 lengthDiff = Math.abs(array1.length - array2.length), 7403 diffs = 0, 7404 i; 7405 for (i = 0; i < len; i++) { 7406 if ((dontConvert && array1[i] !== array2[i]) || 7407 (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { 7408 diffs++; 7409 } 7410 } 7411 return diffs + lengthDiff; 7412} 7413 7414function warn(msg) { 7415 if (hooks.suppressDeprecationWarnings === false && 7416 (typeof console !== 'undefined') && console.warn) { 7417 console.warn('Deprecation warning: ' + msg); 7418 } 7419} 7420 7421function deprecate(msg, fn) { 7422 var firstTime = true; 7423 7424 return extend(function () { 7425 if (hooks.deprecationHandler != null) { 7426 hooks.deprecationHandler(null, msg); 7427 } 7428 if (firstTime) { 7429 var args = []; 7430 var arg; 7431 for (var i = 0; i < arguments.length; i++) { 7432 arg = ''; 7433 if (typeof arguments[i] === 'object') { 7434 arg += '\n[' + i + '] '; 7435 for (var key in arguments[0]) { 7436 arg += key + ': ' + arguments[0][key] + ', '; 7437 } 7438 arg = arg.slice(0, -2); // Remove trailing comma and space 7439 } else { 7440 arg = arguments[i]; 7441 } 7442 args.push(arg); 7443 } 7444 warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack); 7445 firstTime = false; 7446 } 7447 return fn.apply(this, arguments); 7448 }, fn); 7449} 7450 7451var deprecations = {}; 7452 7453function deprecateSimple(name, msg) { 7454 if (hooks.deprecationHandler != null) { 7455 hooks.deprecationHandler(name, msg); 7456 } 7457 if (!deprecations[name]) { 7458 warn(msg); 7459 deprecations[name] = true; 7460 } 7461} 7462 7463hooks.suppressDeprecationWarnings = false; 7464hooks.deprecationHandler = null; 7465 7466function isFunction(input) { 7467 return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]'; 7468} 7469 7470function set (config) { 7471 var prop, i; 7472 for (i in config) { 7473 prop = config[i]; 7474 if (isFunction(prop)) { 7475 this[i] = prop; 7476 } else { 7477 this['_' + i] = prop; 7478 } 7479 } 7480 this._config = config; 7481 // Lenient ordinal parsing accepts just a number in addition to 7482 // number + (possibly) stuff coming from _dayOfMonthOrdinalParse. 7483 // TODO: Remove "ordinalParse" fallback in next major release. 7484 this._dayOfMonthOrdinalParseLenient = new RegExp( 7485 (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + 7486 '|' + (/\d{1,2}/).source); 7487} 7488 7489function mergeConfigs(parentConfig, childConfig) { 7490 var res = extend({}, parentConfig), prop; 7491 for (prop in childConfig) { 7492 if (hasOwnProp(childConfig, prop)) { 7493 if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { 7494 res[prop] = {}; 7495 extend(res[prop], parentConfig[prop]); 7496 extend(res[prop], childConfig[prop]); 7497 } else if (childConfig[prop] != null) { 7498 res[prop] = childConfig[prop]; 7499 } else { 7500 delete res[prop]; 7501 } 7502 } 7503 } 7504 for (prop in parentConfig) { 7505 if (hasOwnProp(parentConfig, prop) && 7506 !hasOwnProp(childConfig, prop) && 7507 isObject(parentConfig[prop])) { 7508 // make sure changes to properties don't modify parent config 7509 res[prop] = extend({}, res[prop]); 7510 } 7511 } 7512 return res; 7513} 7514 7515function Locale(config) { 7516 if (config != null) { 7517 this.set(config); 7518 } 7519} 7520 7521var keys; 7522 7523if (Object.keys) { 7524 keys = Object.keys; 7525} else { 7526 keys = function (obj) { 7527 var i, res = []; 7528 for (i in obj) { 7529 if (hasOwnProp(obj, i)) { 7530 res.push(i); 7531 } 7532 } 7533 return res; 7534 }; 7535} 7536 7537var keys$1 = keys; 7538 7539var defaultCalendar = { 7540 sameDay : '[Today at] LT', 7541 nextDay : '[Tomorrow at] LT', 7542 nextWeek : 'dddd [at] LT', 7543 lastDay : '[Yesterday at] LT', 7544 lastWeek : '[Last] dddd [at] LT', 7545 sameElse : 'L' 7546}; 7547 7548function calendar (key, mom, now) { 7549 var output = this._calendar[key] || this._calendar['sameElse']; 7550 return isFunction(output) ? output.call(mom, now) : output; 7551} 7552 7553var defaultLongDateFormat = { 7554 LTS : 'h:mm:ss A', 7555 LT : 'h:mm A', 7556 L : 'MM/DD/YYYY', 7557 LL : 'MMMM D, YYYY', 7558 LLL : 'MMMM D, YYYY h:mm A', 7559 LLLL : 'dddd, MMMM D, YYYY h:mm A' 7560}; 7561 7562function longDateFormat (key) { 7563 var format = this._longDateFormat[key], 7564 formatUpper = this._longDateFormat[key.toUpperCase()]; 7565 7566 if (format || !formatUpper) { 7567 return format; 7568 } 7569 7570 this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) { 7571 return val.slice(1); 7572 }); 7573 7574 return this._longDateFormat[key]; 7575} 7576 7577var defaultInvalidDate = 'Invalid date'; 7578 7579function invalidDate () { 7580 return this._invalidDate; 7581} 7582 7583var defaultOrdinal = '%d'; 7584var defaultDayOfMonthOrdinalParse = /\d{1,2}/; 7585 7586function ordinal (number) { 7587 return this._ordinal.replace('%d', number); 7588} 7589 7590var defaultRelativeTime = { 7591 future : 'in %s', 7592 past : '%s ago', 7593 s : 'a few seconds', 7594 ss : '%d seconds', 7595 m : 'a minute', 7596 mm : '%d minutes', 7597 h : 'an hour', 7598 hh : '%d hours', 7599 d : 'a day', 7600 dd : '%d days', 7601 M : 'a month', 7602 MM : '%d months', 7603 y : 'a year', 7604 yy : '%d years' 7605}; 7606 7607function relativeTime (number, withoutSuffix, string, isFuture) { 7608 var output = this._relativeTime[string]; 7609 return (isFunction(output)) ? 7610 output(number, withoutSuffix, string, isFuture) : 7611 output.replace(/%d/i, number); 7612} 7613 7614function pastFuture (diff, output) { 7615 var format = this._relativeTime[diff > 0 ? 'future' : 'past']; 7616 return isFunction(format) ? format(output) : format.replace(/%s/i, output); 7617} 7618 7619var aliases = {}; 7620 7621function addUnitAlias (unit, shorthand) { 7622 var lowerCase = unit.toLowerCase(); 7623 aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit; 7624} 7625 7626function normalizeUnits(units) { 7627 return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined; 7628} 7629 7630function normalizeObjectUnits(inputObject) { 7631 var normalizedInput = {}, 7632 normalizedProp, 7633 prop; 7634 7635 for (prop in inputObject) { 7636 if (hasOwnProp(inputObject, prop)) { 7637 normalizedProp = normalizeUnits(prop); 7638 if (normalizedProp) { 7639 normalizedInput[normalizedProp] = inputObject[prop]; 7640 } 7641 } 7642 } 7643 7644 return normalizedInput; 7645} 7646 7647var priorities = {}; 7648 7649function addUnitPriority(unit, priority) { 7650 priorities[unit] = priority; 7651} 7652 7653function getPrioritizedUnits(unitsObj) { 7654 var units = []; 7655 for (var u in unitsObj) { 7656 units.push({unit: u, priority: priorities[u]}); 7657 } 7658 units.sort(function (a, b) { 7659 return a.priority - b.priority; 7660 }); 7661 return units; 7662} 7663 7664function makeGetSet (unit, keepTime) { 7665 return function (value) { 7666 if (value != null) { 7667 set$1(this, unit, value); 7668 hooks.updateOffset(this, keepTime); 7669 return this; 7670 } else { 7671 return get(this, unit); 7672 } 7673 }; 7674} 7675 7676function get (mom, unit) { 7677 return mom.isValid() ? 7678 mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN; 7679} 7680 7681function set$1 (mom, unit, value) { 7682 if (mom.isValid()) { 7683 mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); 7684 } 7685} 7686 7687// MOMENTS 7688 7689function stringGet (units) { 7690 units = normalizeUnits(units); 7691 if (isFunction(this[units])) { 7692 return this[units](); 7693 } 7694 return this; 7695} 7696 7697 7698function stringSet (units, value) { 7699 if (typeof units === 'object') { 7700 units = normalizeObjectUnits(units); 7701 var prioritized = getPrioritizedUnits(units); 7702 for (var i = 0; i < prioritized.length; i++) { 7703 this[prioritized[i].unit](units[prioritized[i].unit]); 7704 } 7705 } else { 7706 units = normalizeUnits(units); 7707 if (isFunction(this[units])) { 7708 return this[units](value); 7709 } 7710 } 7711 return this; 7712} 7713 7714function zeroFill(number, targetLength, forceSign) { 7715 var absNumber = '' + Math.abs(number), 7716 zerosToFill = targetLength - absNumber.length, 7717 sign = number >= 0; 7718 return (sign ? (forceSign ? '+' : '') : '-') + 7719 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber; 7720} 7721 7722var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g; 7723 7724var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g; 7725 7726var formatFunctions = {}; 7727 7728var formatTokenFunctions = {}; 7729 7730// token: 'M' 7731// padded: ['MM', 2] 7732// ordinal: 'Mo' 7733// callback: function () { this.month() + 1 } 7734function addFormatToken (token, padded, ordinal, callback) { 7735 var func = callback; 7736 if (typeof callback === 'string') { 7737 func = function () { 7738 return this[callback](); 7739 }; 7740 } 7741 if (token) { 7742 formatTokenFunctions[token] = func; 7743 } 7744 if (padded) { 7745 formatTokenFunctions[padded[0]] = function () { 7746 return zeroFill(func.apply(this, arguments), padded[1], padded[2]); 7747 }; 7748 } 7749 if (ordinal) { 7750 formatTokenFunctions[ordinal] = function () { 7751 return this.localeData().ordinal(func.apply(this, arguments), token); 7752 }; 7753 } 7754} 7755 7756function removeFormattingTokens(input) { 7757 if (input.match(/\[[\s\S]/)) { 7758 return input.replace(/^\[|\]$/g, ''); 7759 } 7760 return input.replace(/\\/g, ''); 7761} 7762 7763function makeFormatFunction(format) { 7764 var array = format.match(formattingTokens), i, length; 7765 7766 for (i = 0, length = array.length; i < length; i++) { 7767 if (formatTokenFunctions[array[i]]) { 7768 array[i] = formatTokenFunctions[array[i]]; 7769 } else { 7770 array[i] = removeFormattingTokens(array[i]); 7771 } 7772 } 7773 7774 return function (mom) { 7775 var output = '', i; 7776 for (i = 0; i < length; i++) { 7777 output += isFunction(array[i]) ? array[i].call(mom, format) : array[i]; 7778 } 7779 return output; 7780 }; 7781} 7782 7783// format date using native date object 7784function formatMoment(m, format) { 7785 if (!m.isValid()) { 7786 return m.localeData().invalidDate(); 7787 } 7788 7789 format = expandFormat(format, m.localeData()); 7790 formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format); 7791 7792 return formatFunctions[format](m); 7793} 7794 7795function expandFormat(format, locale) { 7796 var i = 5; 7797 7798 function replaceLongDateFormatTokens(input) { 7799 return locale.longDateFormat(input) || input; 7800 } 7801 7802 localFormattingTokens.lastIndex = 0; 7803 while (i >= 0 && localFormattingTokens.test(format)) { 7804 format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); 7805 localFormattingTokens.lastIndex = 0; 7806 i -= 1; 7807 } 7808 7809 return format; 7810} 7811 7812var match1 = /\d/; // 0 - 9 7813var match2 = /\d\d/; // 00 - 99 7814var match3 = /\d{3}/; // 000 - 999 7815var match4 = /\d{4}/; // 0000 - 9999 7816var match6 = /[+-]?\d{6}/; // -999999 - 999999 7817var match1to2 = /\d\d?/; // 0 - 99 7818var match3to4 = /\d\d\d\d?/; // 999 - 9999 7819var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999 7820var match1to3 = /\d{1,3}/; // 0 - 999 7821var match1to4 = /\d{1,4}/; // 0 - 9999 7822var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999 7823 7824var matchUnsigned = /\d+/; // 0 - inf 7825var matchSigned = /[+-]?\d+/; // -inf - inf 7826 7827var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z 7828var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z 7829 7830var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123 7831 7832// any word (or two) characters or numbers including two/three word month in arabic. 7833// includes scottish gaelic two word and hyphenated months 7834var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i; 7835 7836 7837var regexes = {}; 7838 7839function addRegexToken (token, regex, strictRegex) { 7840 regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) { 7841 return (isStrict && strictRegex) ? strictRegex : regex; 7842 }; 7843} 7844 7845function getParseRegexForToken (token, config) { 7846 if (!hasOwnProp(regexes, token)) { 7847 return new RegExp(unescapeFormat(token)); 7848 } 7849 7850 return regexes[token](config._strict, config._locale); 7851} 7852 7853// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript 7854function unescapeFormat(s) { 7855 return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { 7856 return p1 || p2 || p3 || p4; 7857 })); 7858} 7859 7860function regexEscape(s) { 7861 return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); 7862} 7863 7864var tokens = {}; 7865 7866function addParseToken (token, callback) { 7867 var i, func = callback; 7868 if (typeof token === 'string') { 7869 token = [token]; 7870 } 7871 if (isNumber(callback)) { 7872 func = function (input, array) { 7873 array[callback] = toInt(input); 7874 }; 7875 } 7876 for (i = 0; i < token.length; i++) { 7877 tokens[token[i]] = func; 7878 } 7879} 7880 7881function addWeekParseToken (token, callback) { 7882 addParseToken(token, function (input, array, config, token) { 7883 config._w = config._w || {}; 7884 callback(input, config._w, config, token); 7885 }); 7886} 7887 7888function addTimeToArrayFromToken(token, input, config) { 7889 if (input != null && hasOwnProp(tokens, token)) { 7890 tokens[token](input, config._a, config, token); 7891 } 7892} 7893 7894var YEAR = 0; 7895var MONTH = 1; 7896var DATE = 2; 7897var HOUR = 3; 7898var MINUTE = 4; 7899var SECOND = 5; 7900var MILLISECOND = 6; 7901var WEEK = 7; 7902var WEEKDAY = 8; 7903 7904var indexOf; 7905 7906if (Array.prototype.indexOf) { 7907 indexOf = Array.prototype.indexOf; 7908} else { 7909 indexOf = function (o) { 7910 // I know 7911 var i; 7912 for (i = 0; i < this.length; ++i) { 7913 if (this[i] === o) { 7914 return i; 7915 } 7916 } 7917 return -1; 7918 }; 7919} 7920 7921var indexOf$1 = indexOf; 7922 7923function daysInMonth(year, month) { 7924 return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); 7925} 7926 7927// FORMATTING 7928 7929addFormatToken('M', ['MM', 2], 'Mo', function () { 7930 return this.month() + 1; 7931}); 7932 7933addFormatToken('MMM', 0, 0, function (format) { 7934 return this.localeData().monthsShort(this, format); 7935}); 7936 7937addFormatToken('MMMM', 0, 0, function (format) { 7938 return this.localeData().months(this, format); 7939}); 7940 7941// ALIASES 7942 7943addUnitAlias('month', 'M'); 7944 7945// PRIORITY 7946 7947addUnitPriority('month', 8); 7948 7949// PARSING 7950 7951addRegexToken('M', match1to2); 7952addRegexToken('MM', match1to2, match2); 7953addRegexToken('MMM', function (isStrict, locale) { 7954 return locale.monthsShortRegex(isStrict); 7955}); 7956addRegexToken('MMMM', function (isStrict, locale) { 7957 return locale.monthsRegex(isStrict); 7958}); 7959 7960addParseToken(['M', 'MM'], function (input, array) { 7961 array[MONTH] = toInt(input) - 1; 7962}); 7963 7964addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { 7965 var month = config._locale.monthsParse(input, token, config._strict); 7966 // if we didn't find a month name, mark the date as invalid. 7967 if (month != null) { 7968 array[MONTH] = month; 7969 } else { 7970 getParsingFlags(config).invalidMonth = input; 7971 } 7972}); 7973 7974// LOCALES 7975 7976var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/; 7977var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'); 7978function localeMonths (m, format) { 7979 if (!m) { 7980 return isArray(this._months) ? this._months : 7981 this._months['standalone']; 7982 } 7983 return isArray(this._months) ? this._months[m.month()] : 7984 this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()]; 7985} 7986 7987var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'); 7988function localeMonthsShort (m, format) { 7989 if (!m) { 7990 return isArray(this._monthsShort) ? this._monthsShort : 7991 this._monthsShort['standalone']; 7992 } 7993 return isArray(this._monthsShort) ? this._monthsShort[m.month()] : 7994 this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()]; 7995} 7996 7997function handleStrictParse(monthName, format, strict) { 7998 var i, ii, mom, llc = monthName.toLocaleLowerCase(); 7999 if (!this._monthsParse) { 8000 // this is not used 8001 this._monthsParse = []; 8002 this._longMonthsParse = []; 8003 this._shortMonthsParse = []; 8004 for (i = 0; i < 12; ++i) { 8005 mom = createUTC([2000, i]); 8006 this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase(); 8007 this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); 8008 } 8009 } 8010 8011 if (strict) { 8012 if (format === 'MMM') { 8013 ii = indexOf$1.call(this._shortMonthsParse, llc); 8014 return ii !== -1 ? ii : null; 8015 } else { 8016 ii = indexOf$1.call(this._longMonthsParse, llc); 8017 return ii !== -1 ? ii : null; 8018 } 8019 } else { 8020 if (format === 'MMM') { 8021 ii = indexOf$1.call(this._shortMonthsParse, llc); 8022 if (ii !== -1) { 8023 return ii; 8024 } 8025 ii = indexOf$1.call(this._longMonthsParse, llc); 8026 return ii !== -1 ? ii : null; 8027 } else { 8028 ii = indexOf$1.call(this._longMonthsParse, llc); 8029 if (ii !== -1) { 8030 return ii; 8031 } 8032 ii = indexOf$1.call(this._shortMonthsParse, llc); 8033 return ii !== -1 ? ii : null; 8034 } 8035 } 8036} 8037 8038function localeMonthsParse (monthName, format, strict) { 8039 var i, mom, regex; 8040 8041 if (this._monthsParseExact) { 8042 return handleStrictParse.call(this, monthName, format, strict); 8043 } 8044 8045 if (!this._monthsParse) { 8046 this._monthsParse = []; 8047 this._longMonthsParse = []; 8048 this._shortMonthsParse = []; 8049 } 8050 8051 // TODO: add sorting 8052 // Sorting makes sure if one month (or abbr) is a prefix of another 8053 // see sorting in computeMonthsParse 8054 for (i = 0; i < 12; i++) { 8055 // make the regex if we don't have it already 8056 mom = createUTC([2000, i]); 8057 if (strict && !this._longMonthsParse[i]) { 8058 this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i'); 8059 this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i'); 8060 } 8061 if (!strict && !this._monthsParse[i]) { 8062 regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); 8063 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); 8064 } 8065 // test the regex 8066 if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) { 8067 return i; 8068 } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) { 8069 return i; 8070 } else if (!strict && this._monthsParse[i].test(monthName)) { 8071 return i; 8072 } 8073 } 8074} 8075 8076// MOMENTS 8077 8078function setMonth (mom, value) { 8079 var dayOfMonth; 8080 8081 if (!mom.isValid()) { 8082 // No op 8083 return mom; 8084 } 8085 8086 if (typeof value === 'string') { 8087 if (/^\d+$/.test(value)) { 8088 value = toInt(value); 8089 } else { 8090 value = mom.localeData().monthsParse(value); 8091 // TODO: Another silent failure? 8092 if (!isNumber(value)) { 8093 return mom; 8094 } 8095 } 8096 } 8097 8098 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value)); 8099 mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); 8100 return mom; 8101} 8102 8103function getSetMonth (value) { 8104 if (value != null) { 8105 setMonth(this, value); 8106 hooks.updateOffset(this, true); 8107 return this; 8108 } else { 8109 return get(this, 'Month'); 8110 } 8111} 8112 8113function getDaysInMonth () { 8114 return daysInMonth(this.year(), this.month()); 8115} 8116 8117var defaultMonthsShortRegex = matchWord; 8118function monthsShortRegex (isStrict) { 8119 if (this._monthsParseExact) { 8120 if (!hasOwnProp(this, '_monthsRegex')) { 8121 computeMonthsParse.call(this); 8122 } 8123 if (isStrict) { 8124 return this._monthsShortStrictRegex; 8125 } else { 8126 return this._monthsShortRegex; 8127 } 8128 } else { 8129 if (!hasOwnProp(this, '_monthsShortRegex')) { 8130 this._monthsShortRegex = defaultMonthsShortRegex; 8131 } 8132 return this._monthsShortStrictRegex && isStrict ? 8133 this._monthsShortStrictRegex : this._monthsShortRegex; 8134 } 8135} 8136 8137var defaultMonthsRegex = matchWord; 8138function monthsRegex (isStrict) { 8139 if (this._monthsParseExact) { 8140 if (!hasOwnProp(this, '_monthsRegex')) { 8141 computeMonthsParse.call(this); 8142 } 8143 if (isStrict) { 8144 return this._monthsStrictRegex; 8145 } else { 8146 return this._monthsRegex; 8147 } 8148 } else { 8149 if (!hasOwnProp(this, '_monthsRegex')) { 8150 this._monthsRegex = defaultMonthsRegex; 8151 } 8152 return this._monthsStrictRegex && isStrict ? 8153 this._monthsStrictRegex : this._monthsRegex; 8154 } 8155} 8156 8157function computeMonthsParse () { 8158 function cmpLenRev(a, b) { 8159 return b.length - a.length; 8160 } 8161 8162 var shortPieces = [], longPieces = [], mixedPieces = [], 8163 i, mom; 8164 for (i = 0; i < 12; i++) { 8165 // make the regex if we don't have it already 8166 mom = createUTC([2000, i]); 8167 shortPieces.push(this.monthsShort(mom, '')); 8168 longPieces.push(this.months(mom, '')); 8169 mixedPieces.push(this.months(mom, '')); 8170 mixedPieces.push(this.monthsShort(mom, '')); 8171 } 8172 // Sorting makes sure if one month (or abbr) is a prefix of another it 8173 // will match the longer piece. 8174 shortPieces.sort(cmpLenRev); 8175 longPieces.sort(cmpLenRev); 8176 mixedPieces.sort(cmpLenRev); 8177 for (i = 0; i < 12; i++) { 8178 shortPieces[i] = regexEscape(shortPieces[i]); 8179 longPieces[i] = regexEscape(longPieces[i]); 8180 } 8181 for (i = 0; i < 24; i++) { 8182 mixedPieces[i] = regexEscape(mixedPieces[i]); 8183 } 8184 8185 this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); 8186 this._monthsShortRegex = this._monthsRegex; 8187 this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); 8188 this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); 8189} 8190 8191// FORMATTING 8192 8193addFormatToken('Y', 0, 0, function () { 8194 var y = this.year(); 8195 return y <= 9999 ? '' + y : '+' + y; 8196}); 8197 8198addFormatToken(0, ['YY', 2], 0, function () { 8199 return this.year() % 100; 8200}); 8201 8202addFormatToken(0, ['YYYY', 4], 0, 'year'); 8203addFormatToken(0, ['YYYYY', 5], 0, 'year'); 8204addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); 8205 8206// ALIASES 8207 8208addUnitAlias('year', 'y'); 8209 8210// PRIORITIES 8211 8212addUnitPriority('year', 1); 8213 8214// PARSING 8215 8216addRegexToken('Y', matchSigned); 8217addRegexToken('YY', match1to2, match2); 8218addRegexToken('YYYY', match1to4, match4); 8219addRegexToken('YYYYY', match1to6, match6); 8220addRegexToken('YYYYYY', match1to6, match6); 8221 8222addParseToken(['YYYYY', 'YYYYYY'], YEAR); 8223addParseToken('YYYY', function (input, array) { 8224 array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); 8225}); 8226addParseToken('YY', function (input, array) { 8227 array[YEAR] = hooks.parseTwoDigitYear(input); 8228}); 8229addParseToken('Y', function (input, array) { 8230 array[YEAR] = parseInt(input, 10); 8231}); 8232 8233// HELPERS 8234 8235function daysInYear(year) { 8236 return isLeapYear(year) ? 366 : 365; 8237} 8238 8239function isLeapYear(year) { 8240 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; 8241} 8242 8243// HOOKS 8244 8245hooks.parseTwoDigitYear = function (input) { 8246 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); 8247}; 8248 8249// MOMENTS 8250 8251var getSetYear = makeGetSet('FullYear', true); 8252 8253function getIsLeapYear () { 8254 return isLeapYear(this.year()); 8255} 8256 8257function createDate (y, m, d, h, M, s, ms) { 8258 // can't just apply() to create a date: 8259 // https://stackoverflow.com/q/181348 8260 var date = new Date(y, m, d, h, M, s, ms); 8261 8262 // the date constructor remaps years 0-99 to 1900-1999 8263 if (y < 100 && y >= 0 && isFinite(date.getFullYear())) { 8264 date.setFullYear(y); 8265 } 8266 return date; 8267} 8268 8269function createUTCDate (y) { 8270 var date = new Date(Date.UTC.apply(null, arguments)); 8271 8272 // the Date.UTC function remaps years 0-99 to 1900-1999 8273 if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) { 8274 date.setUTCFullYear(y); 8275 } 8276 return date; 8277} 8278 8279// start-of-first-week - start-of-year 8280function firstWeekOffset(year, dow, doy) { 8281 var // first-week day -- which january is always in the first week (4 for iso, 1 for other) 8282 fwd = 7 + dow - doy, 8283 // first-week day local weekday -- which local weekday is fwd 8284 fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; 8285 8286 return -fwdlw + fwd - 1; 8287} 8288 8289// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday 8290function dayOfYearFromWeeks(year, week, weekday, dow, doy) { 8291 var localWeekday = (7 + weekday - dow) % 7, 8292 weekOffset = firstWeekOffset(year, dow, doy), 8293 dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, 8294 resYear, resDayOfYear; 8295 8296 if (dayOfYear <= 0) { 8297 resYear = year - 1; 8298 resDayOfYear = daysInYear(resYear) + dayOfYear; 8299 } else if (dayOfYear > daysInYear(year)) { 8300 resYear = year + 1; 8301 resDayOfYear = dayOfYear - daysInYear(year); 8302 } else { 8303 resYear = year; 8304 resDayOfYear = dayOfYear; 8305 } 8306 8307 return { 8308 year: resYear, 8309 dayOfYear: resDayOfYear 8310 }; 8311} 8312 8313function weekOfYear(mom, dow, doy) { 8314 var weekOffset = firstWeekOffset(mom.year(), dow, doy), 8315 week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, 8316 resWeek, resYear; 8317 8318 if (week < 1) { 8319 resYear = mom.year() - 1; 8320 resWeek = week + weeksInYear(resYear, dow, doy); 8321 } else if (week > weeksInYear(mom.year(), dow, doy)) { 8322 resWeek = week - weeksInYear(mom.year(), dow, doy); 8323 resYear = mom.year() + 1; 8324 } else { 8325 resYear = mom.year(); 8326 resWeek = week; 8327 } 8328 8329 return { 8330 week: resWeek, 8331 year: resYear 8332 }; 8333} 8334 8335function weeksInYear(year, dow, doy) { 8336 var weekOffset = firstWeekOffset(year, dow, doy), 8337 weekOffsetNext = firstWeekOffset(year + 1, dow, doy); 8338 return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; 8339} 8340 8341// FORMATTING 8342 8343addFormatToken('w', ['ww', 2], 'wo', 'week'); 8344addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); 8345 8346// ALIASES 8347 8348addUnitAlias('week', 'w'); 8349addUnitAlias('isoWeek', 'W'); 8350 8351// PRIORITIES 8352 8353addUnitPriority('week', 5); 8354addUnitPriority('isoWeek', 5); 8355 8356// PARSING 8357 8358addRegexToken('w', match1to2); 8359addRegexToken('ww', match1to2, match2); 8360addRegexToken('W', match1to2); 8361addRegexToken('WW', match1to2, match2); 8362 8363addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) { 8364 week[token.substr(0, 1)] = toInt(input); 8365}); 8366 8367// HELPERS 8368 8369// LOCALES 8370 8371function localeWeek (mom) { 8372 return weekOfYear(mom, this._week.dow, this._week.doy).week; 8373} 8374 8375var defaultLocaleWeek = { 8376 dow : 0, // Sunday is the first day of the week. 8377 doy : 6 // The week that contains Jan 1st is the first week of the year. 8378}; 8379 8380function localeFirstDayOfWeek () { 8381 return this._week.dow; 8382} 8383 8384function localeFirstDayOfYear () { 8385 return this._week.doy; 8386} 8387 8388// MOMENTS 8389 8390function getSetWeek (input) { 8391 var week = this.localeData().week(this); 8392 return input == null ? week : this.add((input - week) * 7, 'd'); 8393} 8394 8395function getSetISOWeek (input) { 8396 var week = weekOfYear(this, 1, 4).week; 8397 return input == null ? week : this.add((input - week) * 7, 'd'); 8398} 8399 8400// FORMATTING 8401 8402addFormatToken('d', 0, 'do', 'day'); 8403 8404addFormatToken('dd', 0, 0, function (format) { 8405 return this.localeData().weekdaysMin(this, format); 8406}); 8407 8408addFormatToken('ddd', 0, 0, function (format) { 8409 return this.localeData().weekdaysShort(this, format); 8410}); 8411 8412addFormatToken('dddd', 0, 0, function (format) { 8413 return this.localeData().weekdays(this, format); 8414}); 8415 8416addFormatToken('e', 0, 0, 'weekday'); 8417addFormatToken('E', 0, 0, 'isoWeekday'); 8418 8419// ALIASES 8420 8421addUnitAlias('day', 'd'); 8422addUnitAlias('weekday', 'e'); 8423addUnitAlias('isoWeekday', 'E'); 8424 8425// PRIORITY 8426addUnitPriority('day', 11); 8427addUnitPriority('weekday', 11); 8428addUnitPriority('isoWeekday', 11); 8429 8430// PARSING 8431 8432addRegexToken('d', match1to2); 8433addRegexToken('e', match1to2); 8434addRegexToken('E', match1to2); 8435addRegexToken('dd', function (isStrict, locale) { 8436 return locale.weekdaysMinRegex(isStrict); 8437}); 8438addRegexToken('ddd', function (isStrict, locale) { 8439 return locale.weekdaysShortRegex(isStrict); 8440}); 8441addRegexToken('dddd', function (isStrict, locale) { 8442 return locale.weekdaysRegex(isStrict); 8443}); 8444 8445addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { 8446 var weekday = config._locale.weekdaysParse(input, token, config._strict); 8447 // if we didn't get a weekday name, mark the date as invalid 8448 if (weekday != null) { 8449 week.d = weekday; 8450 } else { 8451 getParsingFlags(config).invalidWeekday = input; 8452 } 8453}); 8454 8455addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { 8456 week[token] = toInt(input); 8457}); 8458 8459// HELPERS 8460 8461function parseWeekday(input, locale) { 8462 if (typeof input !== 'string') { 8463 return input; 8464 } 8465 8466 if (!isNaN(input)) { 8467 return parseInt(input, 10); 8468 } 8469 8470 input = locale.weekdaysParse(input); 8471 if (typeof input === 'number') { 8472 return input; 8473 } 8474 8475 return null; 8476} 8477 8478function parseIsoWeekday(input, locale) { 8479 if (typeof input === 'string') { 8480 return locale.weekdaysParse(input) % 7 || 7; 8481 } 8482 return isNaN(input) ? null : input; 8483} 8484 8485// LOCALES 8486 8487var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'); 8488function localeWeekdays (m, format) { 8489 if (!m) { 8490 return isArray(this._weekdays) ? this._weekdays : 8491 this._weekdays['standalone']; 8492 } 8493 return isArray(this._weekdays) ? this._weekdays[m.day()] : 8494 this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()]; 8495} 8496 8497var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'); 8498function localeWeekdaysShort (m) { 8499 return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort; 8500} 8501 8502var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'); 8503function localeWeekdaysMin (m) { 8504 return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin; 8505} 8506 8507function handleStrictParse$1(weekdayName, format, strict) { 8508 var i, ii, mom, llc = weekdayName.toLocaleLowerCase(); 8509 if (!this._weekdaysParse) { 8510 this._weekdaysParse = []; 8511 this._shortWeekdaysParse = []; 8512 this._minWeekdaysParse = []; 8513 8514 for (i = 0; i < 7; ++i) { 8515 mom = createUTC([2000, 1]).day(i); 8516 this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase(); 8517 this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase(); 8518 this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); 8519 } 8520 } 8521 8522 if (strict) { 8523 if (format === 'dddd') { 8524 ii = indexOf$1.call(this._weekdaysParse, llc); 8525 return ii !== -1 ? ii : null; 8526 } else if (format === 'ddd') { 8527 ii = indexOf$1.call(this._shortWeekdaysParse, llc); 8528 return ii !== -1 ? ii : null; 8529 } else { 8530 ii = indexOf$1.call(this._minWeekdaysParse, llc); 8531 return ii !== -1 ? ii : null; 8532 } 8533 } else { 8534 if (format === 'dddd') { 8535 ii = indexOf$1.call(this._weekdaysParse, llc); 8536 if (ii !== -1) { 8537 return ii; 8538 } 8539 ii = indexOf$1.call(this._shortWeekdaysParse, llc); 8540 if (ii !== -1) { 8541 return ii; 8542 } 8543 ii = indexOf$1.call(this._minWeekdaysParse, llc); 8544 return ii !== -1 ? ii : null; 8545 } else if (format === 'ddd') { 8546 ii = indexOf$1.call(this._shortWeekdaysParse, llc); 8547 if (ii !== -1) { 8548 return ii; 8549 } 8550 ii = indexOf$1.call(this._weekdaysParse, llc); 8551 if (ii !== -1) { 8552 return ii; 8553 } 8554 ii = indexOf$1.call(this._minWeekdaysParse, llc); 8555 return ii !== -1 ? ii : null; 8556 } else { 8557 ii = indexOf$1.call(this._minWeekdaysParse, llc); 8558 if (ii !== -1) { 8559 return ii; 8560 } 8561 ii = indexOf$1.call(this._weekdaysParse, llc); 8562 if (ii !== -1) { 8563 return ii; 8564 } 8565 ii = indexOf$1.call(this._shortWeekdaysParse, llc); 8566 return ii !== -1 ? ii : null; 8567 } 8568 } 8569} 8570 8571function localeWeekdaysParse (weekdayName, format, strict) { 8572 var i, mom, regex; 8573 8574 if (this._weekdaysParseExact) { 8575 return handleStrictParse$1.call(this, weekdayName, format, strict); 8576 } 8577 8578 if (!this._weekdaysParse) { 8579 this._weekdaysParse = []; 8580 this._minWeekdaysParse = []; 8581 this._shortWeekdaysParse = []; 8582 this._fullWeekdaysParse = []; 8583 } 8584 8585 for (i = 0; i < 7; i++) { 8586 // make the regex if we don't have it already 8587 8588 mom = createUTC([2000, 1]).day(i); 8589 if (strict && !this._fullWeekdaysParse[i]) { 8590 this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i'); 8591 this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i'); 8592 this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i'); 8593 } 8594 if (!this._weekdaysParse[i]) { 8595 regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); 8596 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); 8597 } 8598 // test the regex 8599 if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) { 8600 return i; 8601 } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) { 8602 return i; 8603 } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) { 8604 return i; 8605 } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { 8606 return i; 8607 } 8608 } 8609} 8610 8611// MOMENTS 8612 8613function getSetDayOfWeek (input) { 8614 if (!this.isValid()) { 8615 return input != null ? this : NaN; 8616 } 8617 var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); 8618 if (input != null) { 8619 input = parseWeekday(input, this.localeData()); 8620 return this.add(input - day, 'd'); 8621 } else { 8622 return day; 8623 } 8624} 8625 8626function getSetLocaleDayOfWeek (input) { 8627 if (!this.isValid()) { 8628 return input != null ? this : NaN; 8629 } 8630 var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; 8631 return input == null ? weekday : this.add(input - weekday, 'd'); 8632} 8633 8634function getSetISODayOfWeek (input) { 8635 if (!this.isValid()) { 8636 return input != null ? this : NaN; 8637 } 8638 8639 // behaves the same as moment#day except 8640 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) 8641 // as a setter, sunday should belong to the previous week. 8642 8643 if (input != null) { 8644 var weekday = parseIsoWeekday(input, this.localeData()); 8645 return this.day(this.day() % 7 ? weekday : weekday - 7); 8646 } else { 8647 return this.day() || 7; 8648 } 8649} 8650 8651var defaultWeekdaysRegex = matchWord; 8652function weekdaysRegex (isStrict) { 8653 if (this._weekdaysParseExact) { 8654 if (!hasOwnProp(this, '_weekdaysRegex')) { 8655 computeWeekdaysParse.call(this); 8656 } 8657 if (isStrict) { 8658 return this._weekdaysStrictRegex; 8659 } else { 8660 return this._weekdaysRegex; 8661 } 8662 } else { 8663 if (!hasOwnProp(this, '_weekdaysRegex')) { 8664 this._weekdaysRegex = defaultWeekdaysRegex; 8665 } 8666 return this._weekdaysStrictRegex && isStrict ? 8667 this._weekdaysStrictRegex : this._weekdaysRegex; 8668 } 8669} 8670 8671var defaultWeekdaysShortRegex = matchWord; 8672function weekdaysShortRegex (isStrict) { 8673 if (this._weekdaysParseExact) { 8674 if (!hasOwnProp(this, '_weekdaysRegex')) { 8675 computeWeekdaysParse.call(this); 8676 } 8677 if (isStrict) { 8678 return this._weekdaysShortStrictRegex; 8679 } else { 8680 return this._weekdaysShortRegex; 8681 } 8682 } else { 8683 if (!hasOwnProp(this, '_weekdaysShortRegex')) { 8684 this._weekdaysShortRegex = defaultWeekdaysShortRegex; 8685 } 8686 return this._weekdaysShortStrictRegex && isStrict ? 8687 this._weekdaysShortStrictRegex : this._weekdaysShortRegex; 8688 } 8689} 8690 8691var defaultWeekdaysMinRegex = matchWord; 8692function weekdaysMinRegex (isStrict) { 8693 if (this._weekdaysParseExact) { 8694 if (!hasOwnProp(this, '_weekdaysRegex')) { 8695 computeWeekdaysParse.call(this); 8696 } 8697 if (isStrict) { 8698 return this._weekdaysMinStrictRegex; 8699 } else { 8700 return this._weekdaysMinRegex; 8701 } 8702 } else { 8703 if (!hasOwnProp(this, '_weekdaysMinRegex')) { 8704 this._weekdaysMinRegex = defaultWeekdaysMinRegex; 8705 } 8706 return this._weekdaysMinStrictRegex && isStrict ? 8707 this._weekdaysMinStrictRegex : this._weekdaysMinRegex; 8708 } 8709} 8710 8711 8712function computeWeekdaysParse () { 8713 function cmpLenRev(a, b) { 8714 return b.length - a.length; 8715 } 8716 8717 var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [], 8718 i, mom, minp, shortp, longp; 8719 for (i = 0; i < 7; i++) { 8720 // make the regex if we don't have it already 8721 mom = createUTC([2000, 1]).day(i); 8722 minp = this.weekdaysMin(mom, ''); 8723 shortp = this.weekdaysShort(mom, ''); 8724 longp = this.weekdays(mom, ''); 8725 minPieces.push(minp); 8726 shortPieces.push(shortp); 8727 longPieces.push(longp); 8728 mixedPieces.push(minp); 8729 mixedPieces.push(shortp); 8730 mixedPieces.push(longp); 8731 } 8732 // Sorting makes sure if one weekday (or abbr) is a prefix of another it 8733 // will match the longer piece. 8734 minPieces.sort(cmpLenRev); 8735 shortPieces.sort(cmpLenRev); 8736 longPieces.sort(cmpLenRev); 8737 mixedPieces.sort(cmpLenRev); 8738 for (i = 0; i < 7; i++) { 8739 shortPieces[i] = regexEscape(shortPieces[i]); 8740 longPieces[i] = regexEscape(longPieces[i]); 8741 mixedPieces[i] = regexEscape(mixedPieces[i]); 8742 } 8743 8744 this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); 8745 this._weekdaysShortRegex = this._weekdaysRegex; 8746 this._weekdaysMinRegex = this._weekdaysRegex; 8747 8748 this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); 8749 this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); 8750 this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i'); 8751} 8752 8753// FORMATTING 8754 8755function hFormat() { 8756 return this.hours() % 12 || 12; 8757} 8758 8759function kFormat() { 8760 return this.hours() || 24; 8761} 8762 8763addFormatToken('H', ['HH', 2], 0, 'hour'); 8764addFormatToken('h', ['hh', 2], 0, hFormat); 8765addFormatToken('k', ['kk', 2], 0, kFormat); 8766 8767addFormatToken('hmm', 0, 0, function () { 8768 return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); 8769}); 8770 8771addFormatToken('hmmss', 0, 0, function () { 8772 return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + 8773 zeroFill(this.seconds(), 2); 8774}); 8775 8776addFormatToken('Hmm', 0, 0, function () { 8777 return '' + this.hours() + zeroFill(this.minutes(), 2); 8778}); 8779 8780addFormatToken('Hmmss', 0, 0, function () { 8781 return '' + this.hours() + zeroFill(this.minutes(), 2) + 8782 zeroFill(this.seconds(), 2); 8783}); 8784 8785function meridiem (token, lowercase) { 8786 addFormatToken(token, 0, 0, function () { 8787 return this.localeData().meridiem(this.hours(), this.minutes(), lowercase); 8788 }); 8789} 8790 8791meridiem('a', true); 8792meridiem('A', false); 8793 8794// ALIASES 8795 8796addUnitAlias('hour', 'h'); 8797 8798// PRIORITY 8799addUnitPriority('hour', 13); 8800 8801// PARSING 8802 8803function matchMeridiem (isStrict, locale) { 8804 return locale._meridiemParse; 8805} 8806 8807addRegexToken('a', matchMeridiem); 8808addRegexToken('A', matchMeridiem); 8809addRegexToken('H', match1to2); 8810addRegexToken('h', match1to2); 8811addRegexToken('k', match1to2); 8812addRegexToken('HH', match1to2, match2); 8813addRegexToken('hh', match1to2, match2); 8814addRegexToken('kk', match1to2, match2); 8815 8816addRegexToken('hmm', match3to4); 8817addRegexToken('hmmss', match5to6); 8818addRegexToken('Hmm', match3to4); 8819addRegexToken('Hmmss', match5to6); 8820 8821addParseToken(['H', 'HH'], HOUR); 8822addParseToken(['k', 'kk'], function (input, array, config) { 8823 var kInput = toInt(input); 8824 array[HOUR] = kInput === 24 ? 0 : kInput; 8825}); 8826addParseToken(['a', 'A'], function (input, array, config) { 8827 config._isPm = config._locale.isPM(input); 8828 config._meridiem = input; 8829}); 8830addParseToken(['h', 'hh'], function (input, array, config) { 8831 array[HOUR] = toInt(input); 8832 getParsingFlags(config).bigHour = true; 8833}); 8834addParseToken('hmm', function (input, array, config) { 8835 var pos = input.length - 2; 8836 array[HOUR] = toInt(input.substr(0, pos)); 8837 array[MINUTE] = toInt(input.substr(pos)); 8838 getParsingFlags(config).bigHour = true; 8839}); 8840addParseToken('hmmss', function (input, array, config) { 8841 var pos1 = input.length - 4; 8842 var pos2 = input.length - 2; 8843 array[HOUR] = toInt(input.substr(0, pos1)); 8844 array[MINUTE] = toInt(input.substr(pos1, 2)); 8845 array[SECOND] = toInt(input.substr(pos2)); 8846 getParsingFlags(config).bigHour = true; 8847}); 8848addParseToken('Hmm', function (input, array, config) { 8849 var pos = input.length - 2; 8850 array[HOUR] = toInt(input.substr(0, pos)); 8851 array[MINUTE] = toInt(input.substr(pos)); 8852}); 8853addParseToken('Hmmss', function (input, array, config) { 8854 var pos1 = input.length - 4; 8855 var pos2 = input.length - 2; 8856 array[HOUR] = toInt(input.substr(0, pos1)); 8857 array[MINUTE] = toInt(input.substr(pos1, 2)); 8858 array[SECOND] = toInt(input.substr(pos2)); 8859}); 8860 8861// LOCALES 8862 8863function localeIsPM (input) { 8864 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays 8865 // Using charAt should be more compatible. 8866 return ((input + '').toLowerCase().charAt(0) === 'p'); 8867} 8868 8869var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i; 8870function localeMeridiem (hours, minutes, isLower) { 8871 if (hours > 11) { 8872 return isLower ? 'pm' : 'PM'; 8873 } else { 8874 return isLower ? 'am' : 'AM'; 8875 } 8876} 8877 8878 8879// MOMENTS 8880 8881// Setting the hour should keep the time, because the user explicitly 8882// specified which hour he wants. So trying to maintain the same hour (in 8883// a new timezone) makes sense. Adding/subtracting hours does not follow 8884// this rule. 8885var getSetHour = makeGetSet('Hours', true); 8886 8887// months 8888// week 8889// weekdays 8890// meridiem 8891var baseConfig = { 8892 calendar: defaultCalendar, 8893 longDateFormat: defaultLongDateFormat, 8894 invalidDate: defaultInvalidDate, 8895 ordinal: defaultOrdinal, 8896 dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse, 8897 relativeTime: defaultRelativeTime, 8898 8899 months: defaultLocaleMonths, 8900 monthsShort: defaultLocaleMonthsShort, 8901 8902 week: defaultLocaleWeek, 8903 8904 weekdays: defaultLocaleWeekdays, 8905 weekdaysMin: defaultLocaleWeekdaysMin, 8906 weekdaysShort: defaultLocaleWeekdaysShort, 8907 8908 meridiemParse: defaultLocaleMeridiemParse 8909}; 8910 8911// internal storage for locale config files 8912var locales = {}; 8913var localeFamilies = {}; 8914var globalLocale; 8915 8916function normalizeLocale(key) { 8917 return key ? key.toLowerCase().replace('_', '-') : key; 8918} 8919 8920// pick the locale from the array 8921// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each 8922// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root 8923function chooseLocale(names) { 8924 var i = 0, j, next, locale, split; 8925 8926 while (i < names.length) { 8927 split = normalizeLocale(names[i]).split('-'); 8928 j = split.length; 8929 next = normalizeLocale(names[i + 1]); 8930 next = next ? next.split('-') : null; 8931 while (j > 0) { 8932 locale = loadLocale(split.slice(0, j).join('-')); 8933 if (locale) { 8934 return locale; 8935 } 8936 if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { 8937 //the next array item is better than a shallower substring of this one 8938 break; 8939 } 8940 j--; 8941 } 8942 i++; 8943 } 8944 return null; 8945} 8946 8947function loadLocale(name) { 8948 var oldLocale = null; 8949 // TODO: Find a better way to register and load all the locales in Node 8950 if (!locales[name] && (typeof module !== 'undefined') && 8951 module && module.exports) { 8952 try { 8953 oldLocale = globalLocale._abbr; 8954 __webpack_require__(409)("./" + name); 8955 // because defineLocale currently also sets the global locale, we 8956 // want to undo that for lazy loaded locales 8957 getSetGlobalLocale(oldLocale); 8958 } catch (e) { } 8959 } 8960 return locales[name]; 8961} 8962 8963// This function will load locale and then set the global locale. If 8964// no arguments are passed in, it will simply return the current global 8965// locale key. 8966function getSetGlobalLocale (key, values) { 8967 var data; 8968 if (key) { 8969 if (isUndefined(values)) { 8970 data = getLocale(key); 8971 } 8972 else { 8973 data = defineLocale(key, values); 8974 } 8975 8976 if (data) { 8977 // moment.duration._locale = moment._locale = data; 8978 globalLocale = data; 8979 } 8980 } 8981 8982 return globalLocale._abbr; 8983} 8984 8985function defineLocale (name, config) { 8986 if (config !== null) { 8987 var parentConfig = baseConfig; 8988 config.abbr = name; 8989 if (locales[name] != null) { 8990 deprecateSimple('defineLocaleOverride', 8991 'use moment.updateLocale(localeName, config) to change ' + 8992 'an existing locale. moment.defineLocale(localeName, ' + 8993 'config) should only be used for creating a new locale ' + 8994 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'); 8995 parentConfig = locales[name]._config; 8996 } else if (config.parentLocale != null) { 8997 if (locales[config.parentLocale] != null) { 8998 parentConfig = locales[config.parentLocale]._config; 8999 } else { 9000 if (!localeFamilies[config.parentLocale]) { 9001 localeFamilies[config.parentLocale] = []; 9002 } 9003 localeFamilies[config.parentLocale].push({ 9004 name: name, 9005 config: config 9006 }); 9007 return null; 9008 } 9009 } 9010 locales[name] = new Locale(mergeConfigs(parentConfig, config)); 9011 9012 if (localeFamilies[name]) { 9013 localeFamilies[name].forEach(function (x) { 9014 defineLocale(x.name, x.config); 9015 }); 9016 } 9017 9018 // backwards compat for now: also set the locale 9019 // make sure we set the locale AFTER all child locales have been 9020 // created, so we won't end up with the child locale set. 9021 getSetGlobalLocale(name); 9022 9023 9024 return locales[name]; 9025 } else { 9026 // useful for testing 9027 delete locales[name]; 9028 return null; 9029 } 9030} 9031 9032function updateLocale(name, config) { 9033 if (config != null) { 9034 var locale, parentConfig = baseConfig; 9035 // MERGE 9036 if (locales[name] != null) { 9037 parentConfig = locales[name]._config; 9038 } 9039 config = mergeConfigs(parentConfig, config); 9040 locale = new Locale(config); 9041 locale.parentLocale = locales[name]; 9042 locales[name] = locale; 9043 9044 // backwards compat for now: also set the locale 9045 getSetGlobalLocale(name); 9046 } else { 9047 // pass null for config to unupdate, useful for tests 9048 if (locales[name] != null) { 9049 if (locales[name].parentLocale != null) { 9050 locales[name] = locales[name].parentLocale; 9051 } else if (locales[name] != null) { 9052 delete locales[name]; 9053 } 9054 } 9055 } 9056 return locales[name]; 9057} 9058 9059// returns locale data 9060function getLocale (key) { 9061 var locale; 9062 9063 if (key && key._locale && key._locale._abbr) { 9064 key = key._locale._abbr; 9065 } 9066 9067 if (!key) { 9068 return globalLocale; 9069 } 9070 9071 if (!isArray(key)) { 9072 //short-circuit everything else 9073 locale = loadLocale(key); 9074 if (locale) { 9075 return locale; 9076 } 9077 key = [key]; 9078 } 9079 9080 return chooseLocale(key); 9081} 9082 9083function listLocales() { 9084 return keys$1(locales); 9085} 9086 9087function checkOverflow (m) { 9088 var overflow; 9089 var a = m._a; 9090 9091 if (a && getParsingFlags(m).overflow === -2) { 9092 overflow = 9093 a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : 9094 a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : 9095 a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR : 9096 a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : 9097 a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : 9098 a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : 9099 -1; 9100 9101 if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { 9102 overflow = DATE; 9103 } 9104 if (getParsingFlags(m)._overflowWeeks && overflow === -1) { 9105 overflow = WEEK; 9106 } 9107 if (getParsingFlags(m)._overflowWeekday && overflow === -1) { 9108 overflow = WEEKDAY; 9109 } 9110 9111 getParsingFlags(m).overflow = overflow; 9112 } 9113 9114 return m; 9115} 9116 9117// iso 8601 regex 9118// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) 9119var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/; 9120var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/; 9121 9122var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/; 9123 9124var isoDates = [ 9125 ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], 9126 ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], 9127 ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], 9128 ['GGGG-[W]WW', /\d{4}-W\d\d/, false], 9129 ['YYYY-DDD', /\d{4}-\d{3}/], 9130 ['YYYY-MM', /\d{4}-\d\d/, false], 9131 ['YYYYYYMMDD', /[+-]\d{10}/], 9132 ['YYYYMMDD', /\d{8}/], 9133 // YYYYMM is NOT allowed by the standard 9134 ['GGGG[W]WWE', /\d{4}W\d{3}/], 9135 ['GGGG[W]WW', /\d{4}W\d{2}/, false], 9136 ['YYYYDDD', /\d{7}/] 9137]; 9138 9139// iso time formats and regexes 9140var isoTimes = [ 9141 ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], 9142 ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], 9143 ['HH:mm:ss', /\d\d:\d\d:\d\d/], 9144 ['HH:mm', /\d\d:\d\d/], 9145 ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], 9146 ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], 9147 ['HHmmss', /\d\d\d\d\d\d/], 9148 ['HHmm', /\d\d\d\d/], 9149 ['HH', /\d\d/] 9150]; 9151 9152var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i; 9153 9154// date from iso format 9155function configFromISO(config) { 9156 var i, l, 9157 string = config._i, 9158 match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), 9159 allowTime, dateFormat, timeFormat, tzFormat; 9160 9161 if (match) { 9162 getParsingFlags(config).iso = true; 9163 9164 for (i = 0, l = isoDates.length; i < l; i++) { 9165 if (isoDates[i][1].exec(match[1])) { 9166 dateFormat = isoDates[i][0]; 9167 allowTime = isoDates[i][2] !== false; 9168 break; 9169 } 9170 } 9171 if (dateFormat == null) { 9172 config._isValid = false; 9173 return; 9174 } 9175 if (match[3]) { 9176 for (i = 0, l = isoTimes.length; i < l; i++) { 9177 if (isoTimes[i][1].exec(match[3])) { 9178 // match[2] should be 'T' or space 9179 timeFormat = (match[2] || ' ') + isoTimes[i][0]; 9180 break; 9181 } 9182 } 9183 if (timeFormat == null) { 9184 config._isValid = false; 9185 return; 9186 } 9187 } 9188 if (!allowTime && timeFormat != null) { 9189 config._isValid = false; 9190 return; 9191 } 9192 if (match[4]) { 9193 if (tzRegex.exec(match[4])) { 9194 tzFormat = 'Z'; 9195 } else { 9196 config._isValid = false; 9197 return; 9198 } 9199 } 9200 config._f = dateFormat + (timeFormat || '') + (tzFormat || ''); 9201 configFromStringAndFormat(config); 9202 } else { 9203 config._isValid = false; 9204 } 9205} 9206 9207// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 9208var basicRfcRegex = /^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/; 9209 9210// date and time from ref 2822 format 9211function configFromRFC2822(config) { 9212 var string, match, dayFormat, 9213 dateFormat, timeFormat, tzFormat; 9214 var timezones = { 9215 ' GMT': ' +0000', 9216 ' EDT': ' -0400', 9217 ' EST': ' -0500', 9218 ' CDT': ' -0500', 9219 ' CST': ' -0600', 9220 ' MDT': ' -0600', 9221 ' MST': ' -0700', 9222 ' PDT': ' -0700', 9223 ' PST': ' -0800' 9224 }; 9225 var military = 'YXWVUTSRQPONZABCDEFGHIKLM'; 9226 var timezone, timezoneIndex; 9227 9228 string = config._i 9229 .replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace 9230 .replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space 9231 .replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces 9232 match = basicRfcRegex.exec(string); 9233 9234 if (match) { 9235 dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : ''; 9236 dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY '); 9237 timeFormat = 'HH:mm' + (match[4] ? ':ss' : ''); 9238 9239 // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check. 9240 if (match[1]) { // day of week given 9241 var momentDate = new Date(match[2]); 9242 var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()]; 9243 9244 if (match[1].substr(0,3) !== momentDay) { 9245 getParsingFlags(config).weekdayMismatch = true; 9246 config._isValid = false; 9247 return; 9248 } 9249 } 9250 9251 switch (match[5].length) { 9252 case 2: // military 9253 if (timezoneIndex === 0) { 9254 timezone = ' +0000'; 9255 } else { 9256 timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12; 9257 timezone = ((timezoneIndex < 0) ? ' -' : ' +') + 9258 (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00'; 9259 } 9260 break; 9261 case 4: // Zone 9262 timezone = timezones[match[5]]; 9263 break; 9264 default: // UT or +/-9999 9265 timezone = timezones[' GMT']; 9266 } 9267 match[5] = timezone; 9268 config._i = match.splice(1).join(''); 9269 tzFormat = ' ZZ'; 9270 config._f = dayFormat + dateFormat + timeFormat + tzFormat; 9271 configFromStringAndFormat(config); 9272 getParsingFlags(config).rfc2822 = true; 9273 } else { 9274 config._isValid = false; 9275 } 9276} 9277 9278// date from iso format or fallback 9279function configFromString(config) { 9280 var matched = aspNetJsonRegex.exec(config._i); 9281 9282 if (matched !== null) { 9283 config._d = new Date(+matched[1]); 9284 return; 9285 } 9286 9287 configFromISO(config); 9288 if (config._isValid === false) { 9289 delete config._isValid; 9290 } else { 9291 return; 9292 } 9293 9294 configFromRFC2822(config); 9295 if (config._isValid === false) { 9296 delete config._isValid; 9297 } else { 9298 return; 9299 } 9300 9301 // Final attempt, use Input Fallback 9302 hooks.createFromInputFallback(config); 9303} 9304 9305hooks.createFromInputFallback = deprecate( 9306 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 9307 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 9308 'discouraged and will be removed in an upcoming major release. Please refer to ' + 9309 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', 9310 function (config) { 9311 config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); 9312 } 9313); 9314 9315// Pick the first defined of two or three arguments. 9316function defaults(a, b, c) { 9317 if (a != null) { 9318 return a; 9319 } 9320 if (b != null) { 9321 return b; 9322 } 9323 return c; 9324} 9325 9326function currentDateArray(config) { 9327 // hooks is actually the exported moment object 9328 var nowValue = new Date(hooks.now()); 9329 if (config._useUTC) { 9330 return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()]; 9331 } 9332 return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; 9333} 9334 9335// convert an array to a date. 9336// the array should mirror the parameters below 9337// note: all values past the year are optional and will default to the lowest possible value. 9338// [year, month, day , hour, minute, second, millisecond] 9339function configFromArray (config) { 9340 var i, date, input = [], currentDate, yearToUse; 9341 9342 if (config._d) { 9343 return; 9344 } 9345 9346 currentDate = currentDateArray(config); 9347 9348 //compute day of the year from weeks and weekdays 9349 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { 9350 dayOfYearFromWeekInfo(config); 9351 } 9352 9353 //if the day of the year is set, figure out what it is 9354 if (config._dayOfYear != null) { 9355 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); 9356 9357 if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) { 9358 getParsingFlags(config)._overflowDayOfYear = true; 9359 } 9360 9361 date = createUTCDate(yearToUse, 0, config._dayOfYear); 9362 config._a[MONTH] = date.getUTCMonth(); 9363 config._a[DATE] = date.getUTCDate(); 9364 } 9365 9366 // Default to current date. 9367 // * if no year, month, day of month are given, default to today 9368 // * if day of month is given, default month and year 9369 // * if month is given, default only year 9370 // * if year is given, don't default anything 9371 for (i = 0; i < 3 && config._a[i] == null; ++i) { 9372 config._a[i] = input[i] = currentDate[i]; 9373 } 9374 9375 // Zero out whatever was not defaulted, including time 9376 for (; i < 7; i++) { 9377 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; 9378 } 9379 9380 // Check for 24:00:00.000 9381 if (config._a[HOUR] === 24 && 9382 config._a[MINUTE] === 0 && 9383 config._a[SECOND] === 0 && 9384 config._a[MILLISECOND] === 0) { 9385 config._nextDay = true; 9386 config._a[HOUR] = 0; 9387 } 9388 9389 config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input); 9390 // Apply timezone offset from input. The actual utcOffset can be changed 9391 // with parseZone. 9392 if (config._tzm != null) { 9393 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); 9394 } 9395 9396 if (config._nextDay) { 9397 config._a[HOUR] = 24; 9398 } 9399} 9400 9401function dayOfYearFromWeekInfo(config) { 9402 var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow; 9403 9404 w = config._w; 9405 if (w.GG != null || w.W != null || w.E != null) { 9406 dow = 1; 9407 doy = 4; 9408 9409 // TODO: We need to take the current isoWeekYear, but that depends on 9410 // how we interpret now (local, utc, fixed offset). So create 9411 // a now version of current config (take local/utc/offset flags, and 9412 // create now). 9413 weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year); 9414 week = defaults(w.W, 1); 9415 weekday = defaults(w.E, 1); 9416 if (weekday < 1 || weekday > 7) { 9417 weekdayOverflow = true; 9418 } 9419 } else { 9420 dow = config._locale._week.dow; 9421 doy = config._locale._week.doy; 9422 9423 var curWeek = weekOfYear(createLocal(), dow, doy); 9424 9425 weekYear = defaults(w.gg, config._a[YEAR], curWeek.year); 9426 9427 // Default to current week. 9428 week = defaults(w.w, curWeek.week); 9429 9430 if (w.d != null) { 9431 // weekday -- low day numbers are considered next week 9432 weekday = w.d; 9433 if (weekday < 0 || weekday > 6) { 9434 weekdayOverflow = true; 9435 } 9436 } else if (w.e != null) { 9437 // local weekday -- counting starts from begining of week 9438 weekday = w.e + dow; 9439 if (w.e < 0 || w.e > 6) { 9440 weekdayOverflow = true; 9441 } 9442 } else { 9443 // default to begining of week 9444 weekday = dow; 9445 } 9446 } 9447 if (week < 1 || week > weeksInYear(weekYear, dow, doy)) { 9448 getParsingFlags(config)._overflowWeeks = true; 9449 } else if (weekdayOverflow != null) { 9450 getParsingFlags(config)._overflowWeekday = true; 9451 } else { 9452 temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy); 9453 config._a[YEAR] = temp.year; 9454 config._dayOfYear = temp.dayOfYear; 9455 } 9456} 9457 9458// constant that refers to the ISO standard 9459hooks.ISO_8601 = function () {}; 9460 9461// constant that refers to the RFC 2822 form 9462hooks.RFC_2822 = function () {}; 9463 9464// date from string and format string 9465function configFromStringAndFormat(config) { 9466 // TODO: Move this to another part of the creation flow to prevent circular deps 9467 if (config._f === hooks.ISO_8601) { 9468 configFromISO(config); 9469 return; 9470 } 9471 if (config._f === hooks.RFC_2822) { 9472 configFromRFC2822(config); 9473 return; 9474 } 9475 config._a = []; 9476 getParsingFlags(config).empty = true; 9477 9478 // This array is used to make a Date, either with `new Date` or `Date.UTC` 9479 var string = '' + config._i, 9480 i, parsedInput, tokens, token, skipped, 9481 stringLength = string.length, 9482 totalParsedInputLength = 0; 9483 9484 tokens = expandFormat(config._f, config._locale).match(formattingTokens) || []; 9485 9486 for (i = 0; i < tokens.length; i++) { 9487 token = tokens[i]; 9488 parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; 9489 // console.log('token', token, 'parsedInput', parsedInput, 9490 // 'regex', getParseRegexForToken(token, config)); 9491 if (parsedInput) { 9492 skipped = string.substr(0, string.indexOf(parsedInput)); 9493 if (skipped.length > 0) { 9494 getParsingFlags(config).unusedInput.push(skipped); 9495 } 9496 string = string.slice(string.indexOf(parsedInput) + parsedInput.length); 9497 totalParsedInputLength += parsedInput.length; 9498 } 9499 // don't parse if it's not a known token 9500 if (formatTokenFunctions[token]) { 9501 if (parsedInput) { 9502 getParsingFlags(config).empty = false; 9503 } 9504 else { 9505 getParsingFlags(config).unusedTokens.push(token); 9506 } 9507 addTimeToArrayFromToken(token, parsedInput, config); 9508 } 9509 else if (config._strict && !parsedInput) { 9510 getParsingFlags(config).unusedTokens.push(token); 9511 } 9512 } 9513 9514 // add remaining unparsed input length to the string 9515 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength; 9516 if (string.length > 0) { 9517 getParsingFlags(config).unusedInput.push(string); 9518 } 9519 9520 // clear _12h flag if hour is <= 12 9521 if (config._a[HOUR] <= 12 && 9522 getParsingFlags(config).bigHour === true && 9523 config._a[HOUR] > 0) { 9524 getParsingFlags(config).bigHour = undefined; 9525 } 9526 9527 getParsingFlags(config).parsedDateParts = config._a.slice(0); 9528 getParsingFlags(config).meridiem = config._meridiem; 9529 // handle meridiem 9530 config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem); 9531 9532 configFromArray(config); 9533 checkOverflow(config); 9534} 9535 9536 9537function meridiemFixWrap (locale, hour, meridiem) { 9538 var isPm; 9539 9540 if (meridiem == null) { 9541 // nothing to do 9542 return hour; 9543 } 9544 if (locale.meridiemHour != null) { 9545 return locale.meridiemHour(hour, meridiem); 9546 } else if (locale.isPM != null) { 9547 // Fallback 9548 isPm = locale.isPM(meridiem); 9549 if (isPm && hour < 12) { 9550 hour += 12; 9551 } 9552 if (!isPm && hour === 12) { 9553 hour = 0; 9554 } 9555 return hour; 9556 } else { 9557 // this is not supposed to happen 9558 return hour; 9559 } 9560} 9561 9562// date from string and array of format strings 9563function configFromStringAndArray(config) { 9564 var tempConfig, 9565 bestMoment, 9566 9567 scoreToBeat, 9568 i, 9569 currentScore; 9570 9571 if (config._f.length === 0) { 9572 getParsingFlags(config).invalidFormat = true; 9573 config._d = new Date(NaN); 9574 return; 9575 } 9576 9577 for (i = 0; i < config._f.length; i++) { 9578 currentScore = 0; 9579 tempConfig = copyConfig({}, config); 9580 if (config._useUTC != null) { 9581 tempConfig._useUTC = config._useUTC; 9582 } 9583 tempConfig._f = config._f[i]; 9584 configFromStringAndFormat(tempConfig); 9585 9586 if (!isValid(tempConfig)) { 9587 continue; 9588 } 9589 9590 // if there is any input that was not parsed add a penalty for that format 9591 currentScore += getParsingFlags(tempConfig).charsLeftOver; 9592 9593 //or tokens 9594 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; 9595 9596 getParsingFlags(tempConfig).score = currentScore; 9597 9598 if (scoreToBeat == null || currentScore < scoreToBeat) { 9599 scoreToBeat = currentScore; 9600 bestMoment = tempConfig; 9601 } 9602 } 9603 9604 extend(config, bestMoment || tempConfig); 9605} 9606 9607function configFromObject(config) { 9608 if (config._d) { 9609 return; 9610 } 9611 9612 var i = normalizeObjectUnits(config._i); 9613 config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) { 9614 return obj && parseInt(obj, 10); 9615 }); 9616 9617 configFromArray(config); 9618} 9619 9620function createFromConfig (config) { 9621 var res = new Moment(checkOverflow(prepareConfig(config))); 9622 if (res._nextDay) { 9623 // Adding is smart enough around DST 9624 res.add(1, 'd'); 9625 res._nextDay = undefined; 9626 } 9627 9628 return res; 9629} 9630 9631function prepareConfig (config) { 9632 var input = config._i, 9633 format = config._f; 9634 9635 config._locale = config._locale || getLocale(config._l); 9636 9637 if (input === null || (format === undefined && input === '')) { 9638 return createInvalid({nullInput: true}); 9639 } 9640 9641 if (typeof input === 'string') { 9642 config._i = input = config._locale.preparse(input); 9643 } 9644 9645 if (isMoment(input)) { 9646 return new Moment(checkOverflow(input)); 9647 } else if (isDate(input)) { 9648 config._d = input; 9649 } else if (isArray(format)) { 9650 configFromStringAndArray(config); 9651 } else if (format) { 9652 configFromStringAndFormat(config); 9653 } else { 9654 configFromInput(config); 9655 } 9656 9657 if (!isValid(config)) { 9658 config._d = null; 9659 } 9660 9661 return config; 9662} 9663 9664function configFromInput(config) { 9665 var input = config._i; 9666 if (isUndefined(input)) { 9667 config._d = new Date(hooks.now()); 9668 } else if (isDate(input)) { 9669 config._d = new Date(input.valueOf()); 9670 } else if (typeof input === 'string') { 9671 configFromString(config); 9672 } else if (isArray(input)) { 9673 config._a = map(input.slice(0), function (obj) { 9674 return parseInt(obj, 10); 9675 }); 9676 configFromArray(config); 9677 } else if (isObject(input)) { 9678 configFromObject(config); 9679 } else if (isNumber(input)) { 9680 // from milliseconds 9681 config._d = new Date(input); 9682 } else { 9683 hooks.createFromInputFallback(config); 9684 } 9685} 9686 9687function createLocalOrUTC (input, format, locale, strict, isUTC) { 9688 var c = {}; 9689 9690 if (locale === true || locale === false) { 9691 strict = locale; 9692 locale = undefined; 9693 } 9694 9695 if ((isObject(input) && isObjectEmpty(input)) || 9696 (isArray(input) && input.length === 0)) { 9697 input = undefined; 9698 } 9699 // object construction must be done this way. 9700 // https://github.com/moment/moment/issues/1423 9701 c._isAMomentObject = true; 9702 c._useUTC = c._isUTC = isUTC; 9703 c._l = locale; 9704 c._i = input; 9705 c._f = format; 9706 c._strict = strict; 9707 9708 return createFromConfig(c); 9709} 9710 9711function createLocal (input, format, locale, strict) { 9712 return createLocalOrUTC(input, format, locale, strict, false); 9713} 9714 9715var prototypeMin = deprecate( 9716 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', 9717 function () { 9718 var other = createLocal.apply(null, arguments); 9719 if (this.isValid() && other.isValid()) { 9720 return other < this ? this : other; 9721 } else { 9722 return createInvalid(); 9723 } 9724 } 9725); 9726 9727var prototypeMax = deprecate( 9728 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', 9729 function () { 9730 var other = createLocal.apply(null, arguments); 9731 if (this.isValid() && other.isValid()) { 9732 return other > this ? this : other; 9733 } else { 9734 return createInvalid(); 9735 } 9736 } 9737); 9738 9739// Pick a moment m from moments so that m[fn](other) is true for all 9740// other. This relies on the function fn to be transitive. 9741// 9742// moments should either be an array of moment objects or an array, whose 9743// first element is an array of moment objects. 9744function pickBy(fn, moments) { 9745 var res, i; 9746 if (moments.length === 1 && isArray(moments[0])) { 9747 moments = moments[0]; 9748 } 9749 if (!moments.length) { 9750 return createLocal(); 9751 } 9752 res = moments[0]; 9753 for (i = 1; i < moments.length; ++i) { 9754 if (!moments[i].isValid() || moments[i][fn](res)) { 9755 res = moments[i]; 9756 } 9757 } 9758 return res; 9759} 9760 9761// TODO: Use [].sort instead? 9762function min () { 9763 var args = [].slice.call(arguments, 0); 9764 9765 return pickBy('isBefore', args); 9766} 9767 9768function max () { 9769 var args = [].slice.call(arguments, 0); 9770 9771 return pickBy('isAfter', args); 9772} 9773 9774var now = function () { 9775 return Date.now ? Date.now() : +(new Date()); 9776}; 9777 9778var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond']; 9779 9780function isDurationValid(m) { 9781 for (var key in m) { 9782 if (!(ordering.indexOf(key) !== -1 && (m[key] == null || !isNaN(m[key])))) { 9783 return false; 9784 } 9785 } 9786 9787 var unitHasDecimal = false; 9788 for (var i = 0; i < ordering.length; ++i) { 9789 if (m[ordering[i]]) { 9790 if (unitHasDecimal) { 9791 return false; // only allow non-integers for smallest unit 9792 } 9793 if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) { 9794 unitHasDecimal = true; 9795 } 9796 } 9797 } 9798 9799 return true; 9800} 9801 9802function isValid$1() { 9803 return this._isValid; 9804} 9805 9806function createInvalid$1() { 9807 return createDuration(NaN); 9808} 9809 9810function Duration (duration) { 9811 var normalizedInput = normalizeObjectUnits(duration), 9812 years = normalizedInput.year || 0, 9813 quarters = normalizedInput.quarter || 0, 9814 months = normalizedInput.month || 0, 9815 weeks = normalizedInput.week || 0, 9816 days = normalizedInput.day || 0, 9817 hours = normalizedInput.hour || 0, 9818 minutes = normalizedInput.minute || 0, 9819 seconds = normalizedInput.second || 0, 9820 milliseconds = normalizedInput.millisecond || 0; 9821 9822 this._isValid = isDurationValid(normalizedInput); 9823 9824 // representation for dateAddRemove 9825 this._milliseconds = +milliseconds + 9826 seconds * 1e3 + // 1000 9827 minutes * 6e4 + // 1000 * 60 9828 hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 9829 // Because of dateAddRemove treats 24 hours as different from a 9830 // day when working around DST, we need to store them separately 9831 this._days = +days + 9832 weeks * 7; 9833 // It is impossible translate months into days without knowing 9834 // which months you are are talking about, so we have to store 9835 // it separately. 9836 this._months = +months + 9837 quarters * 3 + 9838 years * 12; 9839 9840 this._data = {}; 9841 9842 this._locale = getLocale(); 9843 9844 this._bubble(); 9845} 9846 9847function isDuration (obj) { 9848 return obj instanceof Duration; 9849} 9850 9851function absRound (number) { 9852 if (number < 0) { 9853 return Math.round(-1 * number) * -1; 9854 } else { 9855 return Math.round(number); 9856 } 9857} 9858 9859// FORMATTING 9860 9861function offset (token, separator) { 9862 addFormatToken(token, 0, 0, function () { 9863 var offset = this.utcOffset(); 9864 var sign = '+'; 9865 if (offset < 0) { 9866 offset = -offset; 9867 sign = '-'; 9868 } 9869 return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2); 9870 }); 9871} 9872 9873offset('Z', ':'); 9874offset('ZZ', ''); 9875 9876// PARSING 9877 9878addRegexToken('Z', matchShortOffset); 9879addRegexToken('ZZ', matchShortOffset); 9880addParseToken(['Z', 'ZZ'], function (input, array, config) { 9881 config._useUTC = true; 9882 config._tzm = offsetFromString(matchShortOffset, input); 9883}); 9884 9885// HELPERS 9886 9887// timezone chunker 9888// '+10:00' > ['10', '00'] 9889// '-1530' > ['-15', '30'] 9890var chunkOffset = /([\+\-]|\d\d)/gi; 9891 9892function offsetFromString(matcher, string) { 9893 var matches = (string || '').match(matcher); 9894 9895 if (matches === null) { 9896 return null; 9897 } 9898 9899 var chunk = matches[matches.length - 1] || []; 9900 var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; 9901 var minutes = +(parts[1] * 60) + toInt(parts[2]); 9902 9903 return minutes === 0 ? 9904 0 : 9905 parts[0] === '+' ? minutes : -minutes; 9906} 9907 9908// Return a moment from input, that is local/utc/zone equivalent to model. 9909function cloneWithOffset(input, model) { 9910 var res, diff; 9911 if (model._isUTC) { 9912 res = model.clone(); 9913 diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf(); 9914 // Use low-level api, because this fn is low-level api. 9915 res._d.setTime(res._d.valueOf() + diff); 9916 hooks.updateOffset(res, false); 9917 return res; 9918 } else { 9919 return createLocal(input).local(); 9920 } 9921} 9922 9923function getDateOffset (m) { 9924 // On Firefox.24 Date#getTimezoneOffset returns a floating point. 9925 // https://github.com/moment/moment/pull/1871 9926 return -Math.round(m._d.getTimezoneOffset() / 15) * 15; 9927} 9928 9929// HOOKS 9930 9931// This function will be called whenever a moment is mutated. 9932// It is intended to keep the offset in sync with the timezone. 9933hooks.updateOffset = function () {}; 9934 9935// MOMENTS 9936 9937// keepLocalTime = true means only change the timezone, without 9938// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> 9939// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset 9940// +0200, so we adjust the time as needed, to be valid. 9941// 9942// Keeping the time actually adds/subtracts (one hour) 9943// from the actual represented time. That is why we call updateOffset 9944// a second time. In case it wants us to change the offset again 9945// _changeInProgress == true case, then we have to adjust, because 9946// there is no such time in the given timezone. 9947function getSetOffset (input, keepLocalTime, keepMinutes) { 9948 var offset = this._offset || 0, 9949 localAdjust; 9950 if (!this.isValid()) { 9951 return input != null ? this : NaN; 9952 } 9953 if (input != null) { 9954 if (typeof input === 'string') { 9955 input = offsetFromString(matchShortOffset, input); 9956 if (input === null) { 9957 return this; 9958 } 9959 } else if (Math.abs(input) < 16 && !keepMinutes) { 9960 input = input * 60; 9961 } 9962 if (!this._isUTC && keepLocalTime) { 9963 localAdjust = getDateOffset(this); 9964 } 9965 this._offset = input; 9966 this._isUTC = true; 9967 if (localAdjust != null) { 9968 this.add(localAdjust, 'm'); 9969 } 9970 if (offset !== input) { 9971 if (!keepLocalTime || this._changeInProgress) { 9972 addSubtract(this, createDuration(input - offset, 'm'), 1, false); 9973 } else if (!this._changeInProgress) { 9974 this._changeInProgress = true; 9975 hooks.updateOffset(this, true); 9976 this._changeInProgress = null; 9977 } 9978 } 9979 return this; 9980 } else { 9981 return this._isUTC ? offset : getDateOffset(this); 9982 } 9983} 9984 9985function getSetZone (input, keepLocalTime) { 9986 if (input != null) { 9987 if (typeof input !== 'string') { 9988 input = -input; 9989 } 9990 9991 this.utcOffset(input, keepLocalTime); 9992 9993 return this; 9994 } else { 9995 return -this.utcOffset(); 9996 } 9997} 9998 9999function setOffsetToUTC (keepLocalTime) { 10000 return this.utcOffset(0, keepLocalTime); 10001} 10002 10003function setOffsetToLocal (keepLocalTime) { 10004 if (this._isUTC) { 10005 this.utcOffset(0, keepLocalTime); 10006 this._isUTC = false; 10007 10008 if (keepLocalTime) { 10009 this.subtract(getDateOffset(this), 'm'); 10010 } 10011 } 10012 return this; 10013} 10014 10015function setOffsetToParsedOffset () { 10016 if (this._tzm != null) { 10017 this.utcOffset(this._tzm, false, true); 10018 } else if (typeof this._i === 'string') { 10019 var tZone = offsetFromString(matchOffset, this._i); 10020 if (tZone != null) { 10021 this.utcOffset(tZone); 10022 } 10023 else { 10024 this.utcOffset(0, true); 10025 } 10026 } 10027 return this; 10028} 10029 10030function hasAlignedHourOffset (input) { 10031 if (!this.isValid()) { 10032 return false; 10033 } 10034 input = input ? createLocal(input).utcOffset() : 0; 10035 10036 return (this.utcOffset() - input) % 60 === 0; 10037} 10038 10039function isDaylightSavingTime () { 10040 return ( 10041 this.utcOffset() > this.clone().month(0).utcOffset() || 10042 this.utcOffset() > this.clone().month(5).utcOffset() 10043 ); 10044} 10045 10046function isDaylightSavingTimeShifted () { 10047 if (!isUndefined(this._isDSTShifted)) { 10048 return this._isDSTShifted; 10049 } 10050 10051 var c = {}; 10052 10053 copyConfig(c, this); 10054 c = prepareConfig(c); 10055 10056 if (c._a) { 10057 var other = c._isUTC ? createUTC(c._a) : createLocal(c._a); 10058 this._isDSTShifted = this.isValid() && 10059 compareArrays(c._a, other.toArray()) > 0; 10060 } else { 10061 this._isDSTShifted = false; 10062 } 10063 10064 return this._isDSTShifted; 10065} 10066 10067function isLocal () { 10068 return this.isValid() ? !this._isUTC : false; 10069} 10070 10071function isUtcOffset () { 10072 return this.isValid() ? this._isUTC : false; 10073} 10074 10075function isUtc () { 10076 return this.isValid() ? this._isUTC && this._offset === 0 : false; 10077} 10078 10079// ASP.NET json date format regex 10080var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; 10081 10082// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html 10083// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere 10084// and further modified to allow for strings containing both week and day 10085var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/; 10086 10087function createDuration (input, key) { 10088 var duration = input, 10089 // matching against regexp is expensive, do it on demand 10090 match = null, 10091 sign, 10092 ret, 10093 diffRes; 10094 10095 if (isDuration(input)) { 10096 duration = { 10097 ms : input._milliseconds, 10098 d : input._days, 10099 M : input._months 10100 }; 10101 } else if (isNumber(input)) { 10102 duration = {}; 10103 if (key) { 10104 duration[key] = input; 10105 } else { 10106 duration.milliseconds = input; 10107 } 10108 } else if (!!(match = aspNetRegex.exec(input))) { 10109 sign = (match[1] === '-') ? -1 : 1; 10110 duration = { 10111 y : 0, 10112 d : toInt(match[DATE]) * sign, 10113 h : toInt(match[HOUR]) * sign, 10114 m : toInt(match[MINUTE]) * sign, 10115 s : toInt(match[SECOND]) * sign, 10116 ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match 10117 }; 10118 } else if (!!(match = isoRegex.exec(input))) { 10119 sign = (match[1] === '-') ? -1 : 1; 10120 duration = { 10121 y : parseIso(match[2], sign), 10122 M : parseIso(match[3], sign), 10123 w : parseIso(match[4], sign), 10124 d : parseIso(match[5], sign), 10125 h : parseIso(match[6], sign), 10126 m : parseIso(match[7], sign), 10127 s : parseIso(match[8], sign) 10128 }; 10129 } else if (duration == null) {// checks for null or undefined 10130 duration = {}; 10131 } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) { 10132 diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to)); 10133 10134 duration = {}; 10135 duration.ms = diffRes.milliseconds; 10136 duration.M = diffRes.months; 10137 } 10138 10139 ret = new Duration(duration); 10140 10141 if (isDuration(input) && hasOwnProp(input, '_locale')) { 10142 ret._locale = input._locale; 10143 } 10144 10145 return ret; 10146} 10147 10148createDuration.fn = Duration.prototype; 10149createDuration.invalid = createInvalid$1; 10150 10151function parseIso (inp, sign) { 10152 // We'd normally use ~~inp for this, but unfortunately it also 10153 // converts floats to ints. 10154 // inp may be undefined, so careful calling replace on it. 10155 var res = inp && parseFloat(inp.replace(',', '.')); 10156 // apply sign while we're at it 10157 return (isNaN(res) ? 0 : res) * sign; 10158} 10159 10160function positiveMomentsDifference(base, other) { 10161 var res = {milliseconds: 0, months: 0}; 10162 10163 res.months = other.month() - base.month() + 10164 (other.year() - base.year()) * 12; 10165 if (base.clone().add(res.months, 'M').isAfter(other)) { 10166 --res.months; 10167 } 10168 10169 res.milliseconds = +other - +(base.clone().add(res.months, 'M')); 10170 10171 return res; 10172} 10173 10174function momentsDifference(base, other) { 10175 var res; 10176 if (!(base.isValid() && other.isValid())) { 10177 return {milliseconds: 0, months: 0}; 10178 } 10179 10180 other = cloneWithOffset(other, base); 10181 if (base.isBefore(other)) { 10182 res = positiveMomentsDifference(base, other); 10183 } else { 10184 res = positiveMomentsDifference(other, base); 10185 res.milliseconds = -res.milliseconds; 10186 res.months = -res.months; 10187 } 10188 10189 return res; 10190} 10191 10192// TODO: remove 'name' arg after deprecation is removed 10193function createAdder(direction, name) { 10194 return function (val, period) { 10195 var dur, tmp; 10196 //invert the arguments, but complain about it 10197 if (period !== null && !isNaN(+period)) { 10198 deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 10199 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'); 10200 tmp = val; val = period; period = tmp; 10201 } 10202 10203 val = typeof val === 'string' ? +val : val; 10204 dur = createDuration(val, period); 10205 addSubtract(this, dur, direction); 10206 return this; 10207 }; 10208} 10209 10210function addSubtract (mom, duration, isAdding, updateOffset) { 10211 var milliseconds = duration._milliseconds, 10212 days = absRound(duration._days), 10213 months = absRound(duration._months); 10214 10215 if (!mom.isValid()) { 10216 // No op 10217 return; 10218 } 10219 10220 updateOffset = updateOffset == null ? true : updateOffset; 10221 10222 if (milliseconds) { 10223 mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding); 10224 } 10225 if (days) { 10226 set$1(mom, 'Date', get(mom, 'Date') + days * isAdding); 10227 } 10228 if (months) { 10229 setMonth(mom, get(mom, 'Month') + months * isAdding); 10230 } 10231 if (updateOffset) { 10232 hooks.updateOffset(mom, days || months); 10233 } 10234} 10235 10236var add = createAdder(1, 'add'); 10237var subtract = createAdder(-1, 'subtract'); 10238 10239function getCalendarFormat(myMoment, now) { 10240 var diff = myMoment.diff(now, 'days', true); 10241 return diff < -6 ? 'sameElse' : 10242 diff < -1 ? 'lastWeek' : 10243 diff < 0 ? 'lastDay' : 10244 diff < 1 ? 'sameDay' : 10245 diff < 2 ? 'nextDay' : 10246 diff < 7 ? 'nextWeek' : 'sameElse'; 10247} 10248 10249function calendar$1 (time, formats) { 10250 // We want to compare the start of today, vs this. 10251 // Getting start-of-today depends on whether we're local/utc/offset or not. 10252 var now = time || createLocal(), 10253 sod = cloneWithOffset(now, this).startOf('day'), 10254 format = hooks.calendarFormat(this, sod) || 'sameElse'; 10255 10256 var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]); 10257 10258 return this.format(output || this.localeData().calendar(format, this, createLocal(now))); 10259} 10260 10261function clone () { 10262 return new Moment(this); 10263} 10264 10265function isAfter (input, units) { 10266 var localInput = isMoment(input) ? input : createLocal(input); 10267 if (!(this.isValid() && localInput.isValid())) { 10268 return false; 10269 } 10270 units = normalizeUnits(!isUndefined(units) ? units : 'millisecond'); 10271 if (units === 'millisecond') { 10272 return this.valueOf() > localInput.valueOf(); 10273 } else { 10274 return localInput.valueOf() < this.clone().startOf(units).valueOf(); 10275 } 10276} 10277 10278function isBefore (input, units) { 10279 var localInput = isMoment(input) ? input : createLocal(input); 10280 if (!(this.isValid() && localInput.isValid())) { 10281 return false; 10282 } 10283 units = normalizeUnits(!isUndefined(units) ? units : 'millisecond'); 10284 if (units === 'millisecond') { 10285 return this.valueOf() < localInput.valueOf(); 10286 } else { 10287 return this.clone().endOf(units).valueOf() < localInput.valueOf(); 10288 } 10289} 10290 10291function isBetween (from, to, units, inclusivity) { 10292 inclusivity = inclusivity || '()'; 10293 return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) && 10294 (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units)); 10295} 10296 10297function isSame (input, units) { 10298 var localInput = isMoment(input) ? input : createLocal(input), 10299 inputMs; 10300 if (!(this.isValid() && localInput.isValid())) { 10301 return false; 10302 } 10303 units = normalizeUnits(units || 'millisecond'); 10304 if (units === 'millisecond') { 10305 return this.valueOf() === localInput.valueOf(); 10306 } else { 10307 inputMs = localInput.valueOf(); 10308 return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf(); 10309 } 10310} 10311 10312function isSameOrAfter (input, units) { 10313 return this.isSame(input, units) || this.isAfter(input,units); 10314} 10315 10316function isSameOrBefore (input, units) { 10317 return this.isSame(input, units) || this.isBefore(input,units); 10318} 10319 10320function diff (input, units, asFloat) { 10321 var that, 10322 zoneDelta, 10323 delta, output; 10324 10325 if (!this.isValid()) { 10326 return NaN; 10327 } 10328 10329 that = cloneWithOffset(input, this); 10330 10331 if (!that.isValid()) { 10332 return NaN; 10333 } 10334 10335 zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; 10336 10337 units = normalizeUnits(units); 10338 10339 if (units === 'year' || units === 'month' || units === 'quarter') { 10340 output = monthDiff(this, that); 10341 if (units === 'quarter') { 10342 output = output / 3; 10343 } else if (units === 'year') { 10344 output = output / 12; 10345 } 10346 } else { 10347 delta = this - that; 10348 output = units === 'second' ? delta / 1e3 : // 1000 10349 units === 'minute' ? delta / 6e4 : // 1000 * 60 10350 units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60 10351 units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst 10352 units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst 10353 delta; 10354 } 10355 return asFloat ? output : absFloor(output); 10356} 10357 10358function monthDiff (a, b) { 10359 // difference in months 10360 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()), 10361 // b is in (anchor - 1 month, anchor + 1 month) 10362 anchor = a.clone().add(wholeMonthDiff, 'months'), 10363 anchor2, adjust; 10364 10365 if (b - anchor < 0) { 10366 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); 10367 // linear across the month 10368 adjust = (b - anchor) / (anchor - anchor2); 10369 } else { 10370 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); 10371 // linear across the month 10372 adjust = (b - anchor) / (anchor2 - anchor); 10373 } 10374 10375 //check for negative zero, return zero if negative zero 10376 return -(wholeMonthDiff + adjust) || 0; 10377} 10378 10379hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; 10380hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; 10381 10382function toString () { 10383 return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); 10384} 10385 10386function toISOString() { 10387 if (!this.isValid()) { 10388 return null; 10389 } 10390 var m = this.clone().utc(); 10391 if (m.year() < 0 || m.year() > 9999) { 10392 return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); 10393 } 10394 if (isFunction(Date.prototype.toISOString)) { 10395 // native implementation is ~50x faster, use it when we can 10396 return this.toDate().toISOString(); 10397 } 10398 return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); 10399} 10400 10401/** 10402 * Return a human readable representation of a moment that can 10403 * also be evaluated to get a new moment which is the same 10404 * 10405 * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects 10406 */ 10407function inspect () { 10408 if (!this.isValid()) { 10409 return 'moment.invalid(/* ' + this._i + ' */)'; 10410 } 10411 var func = 'moment'; 10412 var zone = ''; 10413 if (!this.isLocal()) { 10414 func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone'; 10415 zone = 'Z'; 10416 } 10417 var prefix = '[' + func + '("]'; 10418 var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY'; 10419 var datetime = '-MM-DD[T]HH:mm:ss.SSS'; 10420 var suffix = zone + '[")]'; 10421 10422 return this.format(prefix + year + datetime + suffix); 10423} 10424 10425function format (inputString) { 10426 if (!inputString) { 10427 inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat; 10428 } 10429 var output = formatMoment(this, inputString); 10430 return this.localeData().postformat(output); 10431} 10432 10433function from (time, withoutSuffix) { 10434 if (this.isValid() && 10435 ((isMoment(time) && time.isValid()) || 10436 createLocal(time).isValid())) { 10437 return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix); 10438 } else { 10439 return this.localeData().invalidDate(); 10440 } 10441} 10442 10443function fromNow (withoutSuffix) { 10444 return this.from(createLocal(), withoutSuffix); 10445} 10446 10447function to (time, withoutSuffix) { 10448 if (this.isValid() && 10449 ((isMoment(time) && time.isValid()) || 10450 createLocal(time).isValid())) { 10451 return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix); 10452 } else { 10453 return this.localeData().invalidDate(); 10454 } 10455} 10456 10457function toNow (withoutSuffix) { 10458 return this.to(createLocal(), withoutSuffix); 10459} 10460 10461// If passed a locale key, it will set the locale for this 10462// instance. Otherwise, it will return the locale configuration 10463// variables for this instance. 10464function locale (key) { 10465 var newLocaleData; 10466 10467 if (key === undefined) { 10468 return this._locale._abbr; 10469 } else { 10470 newLocaleData = getLocale(key); 10471 if (newLocaleData != null) { 10472 this._locale = newLocaleData; 10473 } 10474 return this; 10475 } 10476} 10477 10478var lang = deprecate( 10479 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', 10480 function (key) { 10481 if (key === undefined) { 10482 return this.localeData(); 10483 } else { 10484 return this.locale(key); 10485 } 10486 } 10487); 10488 10489function localeData () { 10490 return this._locale; 10491} 10492 10493function startOf (units) { 10494 units = normalizeUnits(units); 10495 // the following switch intentionally omits break keywords 10496 // to utilize falling through the cases. 10497 switch (units) { 10498 case 'year': 10499 this.month(0); 10500 /* falls through */ 10501 case 'quarter': 10502 case 'month': 10503 this.date(1); 10504 /* falls through */ 10505 case 'week': 10506 case 'isoWeek': 10507 case 'day': 10508 case 'date': 10509 this.hours(0); 10510 /* falls through */ 10511 case 'hour': 10512 this.minutes(0); 10513 /* falls through */ 10514 case 'minute': 10515 this.seconds(0); 10516 /* falls through */ 10517 case 'second': 10518 this.milliseconds(0); 10519 } 10520 10521 // weeks are a special case 10522 if (units === 'week') { 10523 this.weekday(0); 10524 } 10525 if (units === 'isoWeek') { 10526 this.isoWeekday(1); 10527 } 10528 10529 // quarters are also special 10530 if (units === 'quarter') { 10531 this.month(Math.floor(this.month() / 3) * 3); 10532 } 10533 10534 return this; 10535} 10536 10537function endOf (units) { 10538 units = normalizeUnits(units); 10539 if (units === undefined || units === 'millisecond') { 10540 return this; 10541 } 10542 10543 // 'date' is an alias for 'day', so it should be considered as such. 10544 if (units === 'date') { 10545 units = 'day'; 10546 } 10547 10548 return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms'); 10549} 10550 10551function valueOf () { 10552 return this._d.valueOf() - ((this._offset || 0) * 60000); 10553} 10554 10555function unix () { 10556 return Math.floor(this.valueOf() / 1000); 10557} 10558 10559function toDate () { 10560 return new Date(this.valueOf()); 10561} 10562 10563function toArray () { 10564 var m = this; 10565 return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()]; 10566} 10567 10568function toObject () { 10569 var m = this; 10570 return { 10571 years: m.year(), 10572 months: m.month(), 10573 date: m.date(), 10574 hours: m.hours(), 10575 minutes: m.minutes(), 10576 seconds: m.seconds(), 10577 milliseconds: m.milliseconds() 10578 }; 10579} 10580 10581function toJSON () { 10582 // new Date(NaN).toJSON() === null 10583 return this.isValid() ? this.toISOString() : null; 10584} 10585 10586function isValid$2 () { 10587 return isValid(this); 10588} 10589 10590function parsingFlags () { 10591 return extend({}, getParsingFlags(this)); 10592} 10593 10594function invalidAt () { 10595 return getParsingFlags(this).overflow; 10596} 10597 10598function creationData() { 10599 return { 10600 input: this._i, 10601 format: this._f, 10602 locale: this._locale, 10603 isUTC: this._isUTC, 10604 strict: this._strict 10605 }; 10606} 10607 10608// FORMATTING 10609 10610addFormatToken(0, ['gg', 2], 0, function () { 10611 return this.weekYear() % 100; 10612}); 10613 10614addFormatToken(0, ['GG', 2], 0, function () { 10615 return this.isoWeekYear() % 100; 10616}); 10617 10618function addWeekYearFormatToken (token, getter) { 10619 addFormatToken(0, [token, token.length], 0, getter); 10620} 10621 10622addWeekYearFormatToken('gggg', 'weekYear'); 10623addWeekYearFormatToken('ggggg', 'weekYear'); 10624addWeekYearFormatToken('GGGG', 'isoWeekYear'); 10625addWeekYearFormatToken('GGGGG', 'isoWeekYear'); 10626 10627// ALIASES 10628 10629addUnitAlias('weekYear', 'gg'); 10630addUnitAlias('isoWeekYear', 'GG'); 10631 10632// PRIORITY 10633 10634addUnitPriority('weekYear', 1); 10635addUnitPriority('isoWeekYear', 1); 10636 10637 10638// PARSING 10639 10640addRegexToken('G', matchSigned); 10641addRegexToken('g', matchSigned); 10642addRegexToken('GG', match1to2, match2); 10643addRegexToken('gg', match1to2, match2); 10644addRegexToken('GGGG', match1to4, match4); 10645addRegexToken('gggg', match1to4, match4); 10646addRegexToken('GGGGG', match1to6, match6); 10647addRegexToken('ggggg', match1to6, match6); 10648 10649addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) { 10650 week[token.substr(0, 2)] = toInt(input); 10651}); 10652 10653addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { 10654 week[token] = hooks.parseTwoDigitYear(input); 10655}); 10656 10657// MOMENTS 10658 10659function getSetWeekYear (input) { 10660 return getSetWeekYearHelper.call(this, 10661 input, 10662 this.week(), 10663 this.weekday(), 10664 this.localeData()._week.dow, 10665 this.localeData()._week.doy); 10666} 10667 10668function getSetISOWeekYear (input) { 10669 return getSetWeekYearHelper.call(this, 10670 input, this.isoWeek(), this.isoWeekday(), 1, 4); 10671} 10672 10673function getISOWeeksInYear () { 10674 return weeksInYear(this.year(), 1, 4); 10675} 10676 10677function getWeeksInYear () { 10678 var weekInfo = this.localeData()._week; 10679 return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); 10680} 10681 10682function getSetWeekYearHelper(input, week, weekday, dow, doy) { 10683 var weeksTarget; 10684 if (input == null) { 10685 return weekOfYear(this, dow, doy).year; 10686 } else { 10687 weeksTarget = weeksInYear(input, dow, doy); 10688 if (week > weeksTarget) { 10689 week = weeksTarget; 10690 } 10691 return setWeekAll.call(this, input, week, weekday, dow, doy); 10692 } 10693} 10694 10695function setWeekAll(weekYear, week, weekday, dow, doy) { 10696 var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), 10697 date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); 10698 10699 this.year(date.getUTCFullYear()); 10700 this.month(date.getUTCMonth()); 10701 this.date(date.getUTCDate()); 10702 return this; 10703} 10704 10705// FORMATTING 10706 10707addFormatToken('Q', 0, 'Qo', 'quarter'); 10708 10709// ALIASES 10710 10711addUnitAlias('quarter', 'Q'); 10712 10713// PRIORITY 10714 10715addUnitPriority('quarter', 7); 10716 10717// PARSING 10718 10719addRegexToken('Q', match1); 10720addParseToken('Q', function (input, array) { 10721 array[MONTH] = (toInt(input) - 1) * 3; 10722}); 10723 10724// MOMENTS 10725 10726function getSetQuarter (input) { 10727 return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); 10728} 10729 10730// FORMATTING 10731 10732addFormatToken('D', ['DD', 2], 'Do', 'date'); 10733 10734// ALIASES 10735 10736addUnitAlias('date', 'D'); 10737 10738// PRIOROITY 10739addUnitPriority('date', 9); 10740 10741// PARSING 10742 10743addRegexToken('D', match1to2); 10744addRegexToken('DD', match1to2, match2); 10745addRegexToken('Do', function (isStrict, locale) { 10746 // TODO: Remove "ordinalParse" fallback in next major release. 10747 return isStrict ? 10748 (locale._dayOfMonthOrdinalParse || locale._ordinalParse) : 10749 locale._dayOfMonthOrdinalParseLenient; 10750}); 10751 10752addParseToken(['D', 'DD'], DATE); 10753addParseToken('Do', function (input, array) { 10754 array[DATE] = toInt(input.match(match1to2)[0], 10); 10755}); 10756 10757// MOMENTS 10758 10759var getSetDayOfMonth = makeGetSet('Date', true); 10760 10761// FORMATTING 10762 10763addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); 10764 10765// ALIASES 10766 10767addUnitAlias('dayOfYear', 'DDD'); 10768 10769// PRIORITY 10770addUnitPriority('dayOfYear', 4); 10771 10772// PARSING 10773 10774addRegexToken('DDD', match1to3); 10775addRegexToken('DDDD', match3); 10776addParseToken(['DDD', 'DDDD'], function (input, array, config) { 10777 config._dayOfYear = toInt(input); 10778}); 10779 10780// HELPERS 10781 10782// MOMENTS 10783 10784function getSetDayOfYear (input) { 10785 var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1; 10786 return input == null ? dayOfYear : this.add((input - dayOfYear), 'd'); 10787} 10788 10789// FORMATTING 10790 10791addFormatToken('m', ['mm', 2], 0, 'minute'); 10792 10793// ALIASES 10794 10795addUnitAlias('minute', 'm'); 10796 10797// PRIORITY 10798 10799addUnitPriority('minute', 14); 10800 10801// PARSING 10802 10803addRegexToken('m', match1to2); 10804addRegexToken('mm', match1to2, match2); 10805addParseToken(['m', 'mm'], MINUTE); 10806 10807// MOMENTS 10808 10809var getSetMinute = makeGetSet('Minutes', false); 10810 10811// FORMATTING 10812 10813addFormatToken('s', ['ss', 2], 0, 'second'); 10814 10815// ALIASES 10816 10817addUnitAlias('second', 's'); 10818 10819// PRIORITY 10820 10821addUnitPriority('second', 15); 10822 10823// PARSING 10824 10825addRegexToken('s', match1to2); 10826addRegexToken('ss', match1to2, match2); 10827addParseToken(['s', 'ss'], SECOND); 10828 10829// MOMENTS 10830 10831var getSetSecond = makeGetSet('Seconds', false); 10832 10833// FORMATTING 10834 10835addFormatToken('S', 0, 0, function () { 10836 return ~~(this.millisecond() / 100); 10837}); 10838 10839addFormatToken(0, ['SS', 2], 0, function () { 10840 return ~~(this.millisecond() / 10); 10841}); 10842 10843addFormatToken(0, ['SSS', 3], 0, 'millisecond'); 10844addFormatToken(0, ['SSSS', 4], 0, function () { 10845 return this.millisecond() * 10; 10846}); 10847addFormatToken(0, ['SSSSS', 5], 0, function () { 10848 return this.millisecond() * 100; 10849}); 10850addFormatToken(0, ['SSSSSS', 6], 0, function () { 10851 return this.millisecond() * 1000; 10852}); 10853addFormatToken(0, ['SSSSSSS', 7], 0, function () { 10854 return this.millisecond() * 10000; 10855}); 10856addFormatToken(0, ['SSSSSSSS', 8], 0, function () { 10857 return this.millisecond() * 100000; 10858}); 10859addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { 10860 return this.millisecond() * 1000000; 10861}); 10862 10863 10864// ALIASES 10865 10866addUnitAlias('millisecond', 'ms'); 10867 10868// PRIORITY 10869 10870addUnitPriority('millisecond', 16); 10871 10872// PARSING 10873 10874addRegexToken('S', match1to3, match1); 10875addRegexToken('SS', match1to3, match2); 10876addRegexToken('SSS', match1to3, match3); 10877 10878var token; 10879for (token = 'SSSS'; token.length <= 9; token += 'S') { 10880 addRegexToken(token, matchUnsigned); 10881} 10882 10883function parseMs(input, array) { 10884 array[MILLISECOND] = toInt(('0.' + input) * 1000); 10885} 10886 10887for (token = 'S'; token.length <= 9; token += 'S') { 10888 addParseToken(token, parseMs); 10889} 10890// MOMENTS 10891 10892var getSetMillisecond = makeGetSet('Milliseconds', false); 10893 10894// FORMATTING 10895 10896addFormatToken('z', 0, 0, 'zoneAbbr'); 10897addFormatToken('zz', 0, 0, 'zoneName'); 10898 10899// MOMENTS 10900 10901function getZoneAbbr () { 10902 return this._isUTC ? 'UTC' : ''; 10903} 10904 10905function getZoneName () { 10906 return this._isUTC ? 'Coordinated Universal Time' : ''; 10907} 10908 10909var proto = Moment.prototype; 10910 10911proto.add = add; 10912proto.calendar = calendar$1; 10913proto.clone = clone; 10914proto.diff = diff; 10915proto.endOf = endOf; 10916proto.format = format; 10917proto.from = from; 10918proto.fromNow = fromNow; 10919proto.to = to; 10920proto.toNow = toNow; 10921proto.get = stringGet; 10922proto.invalidAt = invalidAt; 10923proto.isAfter = isAfter; 10924proto.isBefore = isBefore; 10925proto.isBetween = isBetween; 10926proto.isSame = isSame; 10927proto.isSameOrAfter = isSameOrAfter; 10928proto.isSameOrBefore = isSameOrBefore; 10929proto.isValid = isValid$2; 10930proto.lang = lang; 10931proto.locale = locale; 10932proto.localeData = localeData; 10933proto.max = prototypeMax; 10934proto.min = prototypeMin; 10935proto.parsingFlags = parsingFlags; 10936proto.set = stringSet; 10937proto.startOf = startOf; 10938proto.subtract = subtract; 10939proto.toArray = toArray; 10940proto.toObject = toObject; 10941proto.toDate = toDate; 10942proto.toISOString = toISOString; 10943proto.inspect = inspect; 10944proto.toJSON = toJSON; 10945proto.toString = toString; 10946proto.unix = unix; 10947proto.valueOf = valueOf; 10948proto.creationData = creationData; 10949 10950// Year 10951proto.year = getSetYear; 10952proto.isLeapYear = getIsLeapYear; 10953 10954// Week Year 10955proto.weekYear = getSetWeekYear; 10956proto.isoWeekYear = getSetISOWeekYear; 10957 10958// Quarter 10959proto.quarter = proto.quarters = getSetQuarter; 10960 10961// Month 10962proto.month = getSetMonth; 10963proto.daysInMonth = getDaysInMonth; 10964 10965// Week 10966proto.week = proto.weeks = getSetWeek; 10967proto.isoWeek = proto.isoWeeks = getSetISOWeek; 10968proto.weeksInYear = getWeeksInYear; 10969proto.isoWeeksInYear = getISOWeeksInYear; 10970 10971// Day 10972proto.date = getSetDayOfMonth; 10973proto.day = proto.days = getSetDayOfWeek; 10974proto.weekday = getSetLocaleDayOfWeek; 10975proto.isoWeekday = getSetISODayOfWeek; 10976proto.dayOfYear = getSetDayOfYear; 10977 10978// Hour 10979proto.hour = proto.hours = getSetHour; 10980 10981// Minute 10982proto.minute = proto.minutes = getSetMinute; 10983 10984// Second 10985proto.second = proto.seconds = getSetSecond; 10986 10987// Millisecond 10988proto.millisecond = proto.milliseconds = getSetMillisecond; 10989 10990// Offset 10991proto.utcOffset = getSetOffset; 10992proto.utc = setOffsetToUTC; 10993proto.local = setOffsetToLocal; 10994proto.parseZone = setOffsetToParsedOffset; 10995proto.hasAlignedHourOffset = hasAlignedHourOffset; 10996proto.isDST = isDaylightSavingTime; 10997proto.isLocal = isLocal; 10998proto.isUtcOffset = isUtcOffset; 10999proto.isUtc = isUtc; 11000proto.isUTC = isUtc; 11001 11002// Timezone 11003proto.zoneAbbr = getZoneAbbr; 11004proto.zoneName = getZoneName; 11005 11006// Deprecations 11007proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth); 11008proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth); 11009proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear); 11010proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone); 11011proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted); 11012 11013function createUnix (input) { 11014 return createLocal(input * 1000); 11015} 11016 11017function createInZone () { 11018 return createLocal.apply(null, arguments).parseZone(); 11019} 11020 11021function preParsePostFormat (string) { 11022 return string; 11023} 11024 11025var proto$1 = Locale.prototype; 11026 11027proto$1.calendar = calendar; 11028proto$1.longDateFormat = longDateFormat; 11029proto$1.invalidDate = invalidDate; 11030proto$1.ordinal = ordinal; 11031proto$1.preparse = preParsePostFormat; 11032proto$1.postformat = preParsePostFormat; 11033proto$1.relativeTime = relativeTime; 11034proto$1.pastFuture = pastFuture; 11035proto$1.set = set; 11036 11037// Month 11038proto$1.months = localeMonths; 11039proto$1.monthsShort = localeMonthsShort; 11040proto$1.monthsParse = localeMonthsParse; 11041proto$1.monthsRegex = monthsRegex; 11042proto$1.monthsShortRegex = monthsShortRegex; 11043 11044// Week 11045proto$1.week = localeWeek; 11046proto$1.firstDayOfYear = localeFirstDayOfYear; 11047proto$1.firstDayOfWeek = localeFirstDayOfWeek; 11048 11049// Day of Week 11050proto$1.weekdays = localeWeekdays; 11051proto$1.weekdaysMin = localeWeekdaysMin; 11052proto$1.weekdaysShort = localeWeekdaysShort; 11053proto$1.weekdaysParse = localeWeekdaysParse; 11054 11055proto$1.weekdaysRegex = weekdaysRegex; 11056proto$1.weekdaysShortRegex = weekdaysShortRegex; 11057proto$1.weekdaysMinRegex = weekdaysMinRegex; 11058 11059// Hours 11060proto$1.isPM = localeIsPM; 11061proto$1.meridiem = localeMeridiem; 11062 11063function get$1 (format, index, field, setter) { 11064 var locale = getLocale(); 11065 var utc = createUTC().set(setter, index); 11066 return locale[field](utc, format); 11067} 11068 11069function listMonthsImpl (format, index, field) { 11070 if (isNumber(format)) { 11071 index = format; 11072 format = undefined; 11073 } 11074 11075 format = format || ''; 11076 11077 if (index != null) { 11078 return get$1(format, index, field, 'month'); 11079 } 11080 11081 var i; 11082 var out = []; 11083 for (i = 0; i < 12; i++) { 11084 out[i] = get$1(format, i, field, 'month'); 11085 } 11086 return out; 11087} 11088 11089// () 11090// (5) 11091// (fmt, 5) 11092// (fmt) 11093// (true) 11094// (true, 5) 11095// (true, fmt, 5) 11096// (true, fmt) 11097function listWeekdaysImpl (localeSorted, format, index, field) { 11098 if (typeof localeSorted === 'boolean') { 11099 if (isNumber(format)) { 11100 index = format; 11101 format = undefined; 11102 } 11103 11104 format = format || ''; 11105 } else { 11106 format = localeSorted; 11107 index = format; 11108 localeSorted = false; 11109 11110 if (isNumber(format)) { 11111 index = format; 11112 format = undefined; 11113 } 11114 11115 format = format || ''; 11116 } 11117 11118 var locale = getLocale(), 11119 shift = localeSorted ? locale._week.dow : 0; 11120 11121 if (index != null) { 11122 return get$1(format, (index + shift) % 7, field, 'day'); 11123 } 11124 11125 var i; 11126 var out = []; 11127 for (i = 0; i < 7; i++) { 11128 out[i] = get$1(format, (i + shift) % 7, field, 'day'); 11129 } 11130 return out; 11131} 11132 11133function listMonths (format, index) { 11134 return listMonthsImpl(format, index, 'months'); 11135} 11136 11137function listMonthsShort (format, index) { 11138 return listMonthsImpl(format, index, 'monthsShort'); 11139} 11140 11141function listWeekdays (localeSorted, format, index) { 11142 return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); 11143} 11144 11145function listWeekdaysShort (localeSorted, format, index) { 11146 return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); 11147} 11148 11149function listWeekdaysMin (localeSorted, format, index) { 11150 return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); 11151} 11152 11153getSetGlobalLocale('en', { 11154 dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, 11155 ordinal : function (number) { 11156 var b = number % 10, 11157 output = (toInt(number % 100 / 10) === 1) ? 'th' : 11158 (b === 1) ? 'st' : 11159 (b === 2) ? 'nd' : 11160 (b === 3) ? 'rd' : 'th'; 11161 return number + output; 11162 } 11163}); 11164 11165// Side effect imports 11166hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale); 11167hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale); 11168 11169var mathAbs = Math.abs; 11170 11171function abs () { 11172 var data = this._data; 11173 11174 this._milliseconds = mathAbs(this._milliseconds); 11175 this._days = mathAbs(this._days); 11176 this._months = mathAbs(this._months); 11177 11178 data.milliseconds = mathAbs(data.milliseconds); 11179 data.seconds = mathAbs(data.seconds); 11180 data.minutes = mathAbs(data.minutes); 11181 data.hours = mathAbs(data.hours); 11182 data.months = mathAbs(data.months); 11183 data.years = mathAbs(data.years); 11184 11185 return this; 11186} 11187 11188function addSubtract$1 (duration, input, value, direction) { 11189 var other = createDuration(input, value); 11190 11191 duration._milliseconds += direction * other._milliseconds; 11192 duration._days += direction * other._days; 11193 duration._months += direction * other._months; 11194 11195 return duration._bubble(); 11196} 11197 11198// supports only 2.0-style add(1, 's') or add(duration) 11199function add$1 (input, value) { 11200 return addSubtract$1(this, input, value, 1); 11201} 11202 11203// supports only 2.0-style subtract(1, 's') or subtract(duration) 11204function subtract$1 (input, value) { 11205 return addSubtract$1(this, input, value, -1); 11206} 11207 11208function absCeil (number) { 11209 if (number < 0) { 11210 return Math.floor(number); 11211 } else { 11212 return Math.ceil(number); 11213 } 11214} 11215 11216function bubble () { 11217 var milliseconds = this._milliseconds; 11218 var days = this._days; 11219 var months = this._months; 11220 var data = this._data; 11221 var seconds, minutes, hours, years, monthsFromDays; 11222 11223 // if we have a mix of positive and negative values, bubble down first 11224 // check: https://github.com/moment/moment/issues/2166 11225 if (!((milliseconds >= 0 && days >= 0 && months >= 0) || 11226 (milliseconds <= 0 && days <= 0 && months <= 0))) { 11227 milliseconds += absCeil(monthsToDays(months) + days) * 864e5; 11228 days = 0; 11229 months = 0; 11230 } 11231 11232 // The following code bubbles up values, see the tests for 11233 // examples of what that means. 11234 data.milliseconds = milliseconds % 1000; 11235 11236 seconds = absFloor(milliseconds / 1000); 11237 data.seconds = seconds % 60; 11238 11239 minutes = absFloor(seconds / 60); 11240 data.minutes = minutes % 60; 11241 11242 hours = absFloor(minutes / 60); 11243 data.hours = hours % 24; 11244 11245 days += absFloor(hours / 24); 11246 11247 // convert days to months 11248 monthsFromDays = absFloor(daysToMonths(days)); 11249 months += monthsFromDays; 11250 days -= absCeil(monthsToDays(monthsFromDays)); 11251 11252 // 12 months -> 1 year 11253 years = absFloor(months / 12); 11254 months %= 12; 11255 11256 data.days = days; 11257 data.months = months; 11258 data.years = years; 11259 11260 return this; 11261} 11262 11263function daysToMonths (days) { 11264 // 400 years have 146097 days (taking into account leap year rules) 11265 // 400 years have 12 months === 4800 11266 return days * 4800 / 146097; 11267} 11268 11269function monthsToDays (months) { 11270 // the reverse of daysToMonths 11271 return months * 146097 / 4800; 11272} 11273 11274function as (units) { 11275 if (!this.isValid()) { 11276 return NaN; 11277 } 11278 var days; 11279 var months; 11280 var milliseconds = this._milliseconds; 11281 11282 units = normalizeUnits(units); 11283 11284 if (units === 'month' || units === 'year') { 11285 days = this._days + milliseconds / 864e5; 11286 months = this._months + daysToMonths(days); 11287 return units === 'month' ? months : months / 12; 11288 } else { 11289 // handle milliseconds separately because of floating point math errors (issue #1867) 11290 days = this._days + Math.round(monthsToDays(this._months)); 11291 switch (units) { 11292 case 'week' : return days / 7 + milliseconds / 6048e5; 11293 case 'day' : return days + milliseconds / 864e5; 11294 case 'hour' : return days * 24 + milliseconds / 36e5; 11295 case 'minute' : return days * 1440 + milliseconds / 6e4; 11296 case 'second' : return days * 86400 + milliseconds / 1000; 11297 // Math.floor prevents floating point math errors here 11298 case 'millisecond': return Math.floor(days * 864e5) + milliseconds; 11299 default: throw new Error('Unknown unit ' + units); 11300 } 11301 } 11302} 11303 11304// TODO: Use this.as('ms')? 11305function valueOf$1 () { 11306 if (!this.isValid()) { 11307 return NaN; 11308 } 11309 return ( 11310 this._milliseconds + 11311 this._days * 864e5 + 11312 (this._months % 12) * 2592e6 + 11313 toInt(this._months / 12) * 31536e6 11314 ); 11315} 11316 11317function makeAs (alias) { 11318 return function () { 11319 return this.as(alias); 11320 }; 11321} 11322 11323var asMilliseconds = makeAs('ms'); 11324var asSeconds = makeAs('s'); 11325var asMinutes = makeAs('m'); 11326var asHours = makeAs('h'); 11327var asDays = makeAs('d'); 11328var asWeeks = makeAs('w'); 11329var asMonths = makeAs('M'); 11330var asYears = makeAs('y'); 11331 11332function get$2 (units) { 11333 units = normalizeUnits(units); 11334 return this.isValid() ? this[units + 's']() : NaN; 11335} 11336 11337function makeGetter(name) { 11338 return function () { 11339 return this.isValid() ? this._data[name] : NaN; 11340 }; 11341} 11342 11343var milliseconds = makeGetter('milliseconds'); 11344var seconds = makeGetter('seconds'); 11345var minutes = makeGetter('minutes'); 11346var hours = makeGetter('hours'); 11347var days = makeGetter('days'); 11348var months = makeGetter('months'); 11349var years = makeGetter('years'); 11350 11351function weeks () { 11352 return absFloor(this.days() / 7); 11353} 11354 11355var round = Math.round; 11356var thresholds = { 11357 ss: 44, // a few seconds to seconds 11358 s : 45, // seconds to minute 11359 m : 45, // minutes to hour 11360 h : 22, // hours to day 11361 d : 26, // days to month 11362 M : 11 // months to year 11363}; 11364 11365// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize 11366function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { 11367 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); 11368} 11369 11370function relativeTime$1 (posNegDuration, withoutSuffix, locale) { 11371 var duration = createDuration(posNegDuration).abs(); 11372 var seconds = round(duration.as('s')); 11373 var minutes = round(duration.as('m')); 11374 var hours = round(duration.as('h')); 11375 var days = round(duration.as('d')); 11376 var months = round(duration.as('M')); 11377 var years = round(duration.as('y')); 11378 11379 var a = seconds <= thresholds.ss && ['s', seconds] || 11380 seconds < thresholds.s && ['ss', seconds] || 11381 minutes <= 1 && ['m'] || 11382 minutes < thresholds.m && ['mm', minutes] || 11383 hours <= 1 && ['h'] || 11384 hours < thresholds.h && ['hh', hours] || 11385 days <= 1 && ['d'] || 11386 days < thresholds.d && ['dd', days] || 11387 months <= 1 && ['M'] || 11388 months < thresholds.M && ['MM', months] || 11389 years <= 1 && ['y'] || ['yy', years]; 11390 11391 a[2] = withoutSuffix; 11392 a[3] = +posNegDuration > 0; 11393 a[4] = locale; 11394 return substituteTimeAgo.apply(null, a); 11395} 11396 11397// This function allows you to set the rounding function for relative time strings 11398function getSetRelativeTimeRounding (roundingFunction) { 11399 if (roundingFunction === undefined) { 11400 return round; 11401 } 11402 if (typeof(roundingFunction) === 'function') { 11403 round = roundingFunction; 11404 return true; 11405 } 11406 return false; 11407} 11408 11409// This function allows you to set a threshold for relative time strings 11410function getSetRelativeTimeThreshold (threshold, limit) { 11411 if (thresholds[threshold] === undefined) { 11412 return false; 11413 } 11414 if (limit === undefined) { 11415 return thresholds[threshold]; 11416 } 11417 thresholds[threshold] = limit; 11418 if (threshold === 's') { 11419 thresholds.ss = limit - 1; 11420 } 11421 return true; 11422} 11423 11424function humanize (withSuffix) { 11425 if (!this.isValid()) { 11426 return this.localeData().invalidDate(); 11427 } 11428 11429 var locale = this.localeData(); 11430 var output = relativeTime$1(this, !withSuffix, locale); 11431 11432 if (withSuffix) { 11433 output = locale.pastFuture(+this, output); 11434 } 11435 11436 return locale.postformat(output); 11437} 11438 11439var abs$1 = Math.abs; 11440 11441function toISOString$1() { 11442 // for ISO strings we do not use the normal bubbling rules: 11443 // * milliseconds bubble up until they become hours 11444 // * days do not bubble at all 11445 // * months bubble up until they become years 11446 // This is because there is no context-free conversion between hours and days 11447 // (think of clock changes) 11448 // and also not between days and months (28-31 days per month) 11449 if (!this.isValid()) { 11450 return this.localeData().invalidDate(); 11451 } 11452 11453 var seconds = abs$1(this._milliseconds) / 1000; 11454 var days = abs$1(this._days); 11455 var months = abs$1(this._months); 11456 var minutes, hours, years; 11457 11458 // 3600 seconds -> 60 minutes -> 1 hour 11459 minutes = absFloor(seconds / 60); 11460 hours = absFloor(minutes / 60); 11461 seconds %= 60; 11462 minutes %= 60; 11463 11464 // 12 months -> 1 year 11465 years = absFloor(months / 12); 11466 months %= 12; 11467 11468 11469 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js 11470 var Y = years; 11471 var M = months; 11472 var D = days; 11473 var h = hours; 11474 var m = minutes; 11475 var s = seconds; 11476 var total = this.asSeconds(); 11477 11478 if (!total) { 11479 // this is the same as C#'s (Noda) and python (isodate)... 11480 // but not other JS (goog.date) 11481 return 'P0D'; 11482 } 11483 11484 return (total < 0 ? '-' : '') + 11485 'P' + 11486 (Y ? Y + 'Y' : '') + 11487 (M ? M + 'M' : '') + 11488 (D ? D + 'D' : '') + 11489 ((h || m || s) ? 'T' : '') + 11490 (h ? h + 'H' : '') + 11491 (m ? m + 'M' : '') + 11492 (s ? s + 'S' : ''); 11493} 11494 11495var proto$2 = Duration.prototype; 11496 11497proto$2.isValid = isValid$1; 11498proto$2.abs = abs; 11499proto$2.add = add$1; 11500proto$2.subtract = subtract$1; 11501proto$2.as = as; 11502proto$2.asMilliseconds = asMilliseconds; 11503proto$2.asSeconds = asSeconds; 11504proto$2.asMinutes = asMinutes; 11505proto$2.asHours = asHours; 11506proto$2.asDays = asDays; 11507proto$2.asWeeks = asWeeks; 11508proto$2.asMonths = asMonths; 11509proto$2.asYears = asYears; 11510proto$2.valueOf = valueOf$1; 11511proto$2._bubble = bubble; 11512proto$2.get = get$2; 11513proto$2.milliseconds = milliseconds; 11514proto$2.seconds = seconds; 11515proto$2.minutes = minutes; 11516proto$2.hours = hours; 11517proto$2.days = days; 11518proto$2.weeks = weeks; 11519proto$2.months = months; 11520proto$2.years = years; 11521proto$2.humanize = humanize; 11522proto$2.toISOString = toISOString$1; 11523proto$2.toString = toISOString$1; 11524proto$2.toJSON = toISOString$1; 11525proto$2.locale = locale; 11526proto$2.localeData = localeData; 11527 11528// Deprecations 11529proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1); 11530proto$2.lang = lang; 11531 11532// Side effect imports 11533 11534// FORMATTING 11535 11536addFormatToken('X', 0, 0, 'unix'); 11537addFormatToken('x', 0, 0, 'valueOf'); 11538 11539// PARSING 11540 11541addRegexToken('x', matchSigned); 11542addRegexToken('X', matchTimestamp); 11543addParseToken('X', function (input, array, config) { 11544 config._d = new Date(parseFloat(input, 10) * 1000); 11545}); 11546addParseToken('x', function (input, array, config) { 11547 config._d = new Date(toInt(input)); 11548}); 11549 11550// Side effect imports 11551 11552 11553hooks.version = '2.18.1'; 11554 11555setHookCallback(createLocal); 11556 11557hooks.fn = proto; 11558hooks.min = min; 11559hooks.max = max; 11560hooks.now = now; 11561hooks.utc = createUTC; 11562hooks.unix = createUnix; 11563hooks.months = listMonths; 11564hooks.isDate = isDate; 11565hooks.locale = getSetGlobalLocale; 11566hooks.invalid = createInvalid; 11567hooks.duration = createDuration; 11568hooks.isMoment = isMoment; 11569hooks.weekdays = listWeekdays; 11570hooks.parseZone = createInZone; 11571hooks.localeData = getLocale; 11572hooks.isDuration = isDuration; 11573hooks.monthsShort = listMonthsShort; 11574hooks.weekdaysMin = listWeekdaysMin; 11575hooks.defineLocale = defineLocale; 11576hooks.updateLocale = updateLocale; 11577hooks.locales = listLocales; 11578hooks.weekdaysShort = listWeekdaysShort; 11579hooks.normalizeUnits = normalizeUnits; 11580hooks.relativeTimeRounding = getSetRelativeTimeRounding; 11581hooks.relativeTimeThreshold = getSetRelativeTimeThreshold; 11582hooks.calendarFormat = getCalendarFormat; 11583hooks.prototype = proto; 11584 11585return hooks; 11586 11587}))); 11588 11589 11590/*** EXPORTS FROM exports-to-window-loader ***/ 11591window['moment'] = __webpack_require__(42); 11592/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(304)(module))) 11593 11594/***/ }), 11595/* 43 */ 11596/***/ (function(module, exports, __webpack_require__) { 11597 11598"use strict"; 11599 11600 11601exports.__esModule = true; 11602 11603var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 11604 11605function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 11606 11607/** 11608 * CellCoords holds cell coordinates (row, column) and few method to validate them and 11609 * retrieve as an array or an object 11610 * 11611 * @class CellCoords 11612 */ 11613var CellCoords = function () { 11614 /** 11615 * @param {Number} row Row index 11616 * @param {Number} col Column index 11617 */ 11618 function CellCoords(row, col) { 11619 _classCallCheck(this, CellCoords); 11620 11621 if (typeof row !== 'undefined' && typeof col !== 'undefined') { 11622 this.row = row; 11623 this.col = col; 11624 } else { 11625 this.row = null; 11626 this.col = null; 11627 } 11628 } 11629 11630 /** 11631 * Checks if given set of coordinates is valid in context of a given Walkontable instance 11632 * 11633 * @param {Walkontable} wotInstance 11634 * @returns {Boolean} 11635 */ 11636 11637 11638 _createClass(CellCoords, [{ 11639 key: 'isValid', 11640 value: function isValid(wotInstance) { 11641 // is it a valid cell index (0 or higher) 11642 if (this.row < 0 || this.col < 0) { 11643 return false; 11644 } 11645 // is selection within total rows and columns 11646 if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) { 11647 return false; 11648 } 11649 11650 return true; 11651 } 11652 11653 /** 11654 * Checks if this cell coords are the same as cell coords given as a parameter 11655 * 11656 * @param {CellCoords} cellCoords 11657 * @returns {Boolean} 11658 */ 11659 11660 }, { 11661 key: 'isEqual', 11662 value: function isEqual(cellCoords) { 11663 if (cellCoords === this) { 11664 return true; 11665 } 11666 11667 return this.row === cellCoords.row && this.col === cellCoords.col; 11668 } 11669 11670 /** 11671 * Checks if tested coordinates are positioned in south-east from this cell coords 11672 * 11673 * @param {Object} testedCoords 11674 * @returns {Boolean} 11675 */ 11676 11677 }, { 11678 key: 'isSouthEastOf', 11679 value: function isSouthEastOf(testedCoords) { 11680 return this.row >= testedCoords.row && this.col >= testedCoords.col; 11681 } 11682 11683 /** 11684 * Checks if tested coordinates are positioned in north-east from this cell coords 11685 * 11686 * @param {Object} testedCoords 11687 * @returns {Boolean} 11688 */ 11689 11690 }, { 11691 key: 'isNorthWestOf', 11692 value: function isNorthWestOf(testedCoords) { 11693 return this.row <= testedCoords.row && this.col <= testedCoords.col; 11694 } 11695 11696 /** 11697 * Checks if tested coordinates are positioned in south-west from this cell coords 11698 * 11699 * @param {Object} testedCoords 11700 * @returns {Boolean} 11701 */ 11702 11703 }, { 11704 key: 'isSouthWestOf', 11705 value: function isSouthWestOf(testedCoords) { 11706 return this.row >= testedCoords.row && this.col <= testedCoords.col; 11707 } 11708 11709 /** 11710 * Checks if tested coordinates are positioned in north-east from this cell coords 11711 * 11712 * @param {Object} testedCoords 11713 * @returns {Boolean} 11714 */ 11715 11716 }, { 11717 key: 'isNorthEastOf', 11718 value: function isNorthEastOf(testedCoords) { 11719 return this.row <= testedCoords.row && this.col >= testedCoords.col; 11720 } 11721 }]); 11722 11723 return CellCoords; 11724}(); 11725 11726exports.default = CellCoords; 11727 11728/***/ }), 11729/* 44 */ 11730/***/ (function(module, exports, __webpack_require__) { 11731 11732"use strict"; 11733 11734 11735exports.__esModule = true; 11736 11737var _element = __webpack_require__(0); 11738 11739var _autoResize = __webpack_require__(306); 11740 11741var _autoResize2 = _interopRequireDefault(_autoResize); 11742 11743var _baseEditor = __webpack_require__(36); 11744 11745var _baseEditor2 = _interopRequireDefault(_baseEditor); 11746 11747var _eventManager = __webpack_require__(4); 11748 11749var _eventManager2 = _interopRequireDefault(_eventManager); 11750 11751var _unicode = __webpack_require__(15); 11752 11753var _event = __webpack_require__(7); 11754 11755function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 11756 11757var TextEditor = _baseEditor2.default.prototype.extend(); 11758 11759/** 11760 * @private 11761 * @editor TextEditor 11762 * @class TextEditor 11763 * @dependencies autoResize 11764 */ 11765TextEditor.prototype.init = function () { 11766 var that = this; 11767 this.createElements(); 11768 this.eventManager = new _eventManager2.default(this); 11769 this.bindEvents(); 11770 this.autoResize = (0, _autoResize2.default)(); 11771 11772 this.instance.addHook('afterDestroy', function () { 11773 that.destroy(); 11774 }); 11775}; 11776 11777TextEditor.prototype.getValue = function () { 11778 return this.TEXTAREA.value; 11779}; 11780 11781TextEditor.prototype.setValue = function (newValue) { 11782 this.TEXTAREA.value = newValue; 11783}; 11784 11785var onBeforeKeyDown = function onBeforeKeyDown(event) { 11786 var instance = this, 11787 that = instance.getActiveEditor(), 11788 ctrlDown; 11789 11790 // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL) 11791 ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey; 11792 11793 // Process only events that have been fired in the editor 11794 if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) { 11795 return; 11796 } 11797 11798 if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) { 11799 // when CTRL or its equivalent is pressed and cell is edited, don't prepare selectable text in textarea 11800 (0, _event.stopImmediatePropagation)(event); 11801 return; 11802 } 11803 11804 switch (event.keyCode) { 11805 case _unicode.KEY_CODES.ARROW_RIGHT: 11806 if (that.isInFullEditMode()) { 11807 if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) { 11808 (0, _event.stopImmediatePropagation)(event); 11809 } 11810 } 11811 break; 11812 case _unicode.KEY_CODES.ARROW_LEFT: 11813 if (that.isInFullEditMode()) { 11814 if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) { 11815 (0, _event.stopImmediatePropagation)(event); 11816 } 11817 } 11818 break; 11819 case _unicode.KEY_CODES.ARROW_UP: 11820 case _unicode.KEY_CODES.ARROW_DOWN: 11821 if (that.isInFullEditMode()) { 11822 if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) { 11823 (0, _event.stopImmediatePropagation)(event); 11824 } 11825 } 11826 break; 11827 11828 case _unicode.KEY_CODES.ENTER: 11829 var selected = that.instance.getSelected(); 11830 var isMultipleSelection = !(selected[0] === selected[2] && selected[1] === selected[3]); 11831 if (ctrlDown && !isMultipleSelection || event.altKey) { 11832 // if ctrl+enter or alt+enter, add new line 11833 if (that.isOpened()) { 11834 var caretPosition = (0, _element.getCaretPosition)(that.TEXTAREA), 11835 value = that.getValue(); 11836 11837 var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition); 11838 11839 that.setValue(newValue); 11840 11841 (0, _element.setCaretPosition)(that.TEXTAREA, caretPosition + 1); 11842 } else { 11843 that.beginEditing(that.originalValue + '\n'); 11844 } 11845 (0, _event.stopImmediatePropagation)(event); 11846 } 11847 event.preventDefault(); // don't add newline to field 11848 break; 11849 11850 case _unicode.KEY_CODES.A: 11851 case _unicode.KEY_CODES.X: 11852 case _unicode.KEY_CODES.C: 11853 case _unicode.KEY_CODES.V: 11854 if (ctrlDown) { 11855 (0, _event.stopImmediatePropagation)(event); // CTRL+A, CTRL+C, CTRL+V, CTRL+X should only work locally when cell is edited (not in table context) 11856 } 11857 break; 11858 11859 case _unicode.KEY_CODES.BACKSPACE: 11860 case _unicode.KEY_CODES.DELETE: 11861 case _unicode.KEY_CODES.HOME: 11862 case _unicode.KEY_CODES.END: 11863 (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context) 11864 break; 11865 default: 11866 break; 11867 } 11868 11869 if ([_unicode.KEY_CODES.ARROW_UP, _unicode.KEY_CODES.ARROW_RIGHT, _unicode.KEY_CODES.ARROW_DOWN, _unicode.KEY_CODES.ARROW_LEFT].indexOf(event.keyCode) === -1) { 11870 that.autoResize.resize(String.fromCharCode(event.keyCode)); 11871 } 11872}; 11873 11874TextEditor.prototype.open = function () { 11875 this.refreshDimensions(); // need it instantly, to prevent https://github.com/handsontable/handsontable/issues/348 11876 11877 this.instance.addHook('beforeKeyDown', onBeforeKeyDown); 11878}; 11879 11880TextEditor.prototype.close = function (tdOutside) { 11881 this.textareaParentStyle.display = 'none'; 11882 11883 this.autoResize.unObserve(); 11884 11885 if (document.activeElement === this.TEXTAREA) { 11886 this.instance.listen(); // don't refocus the table if user focused some cell outside of HT on purpose 11887 } 11888 this.instance.removeHook('beforeKeyDown', onBeforeKeyDown); 11889}; 11890 11891TextEditor.prototype.focus = function () { 11892 this.TEXTAREA.focus(); 11893 (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length); 11894}; 11895 11896TextEditor.prototype.createElements = function () { 11897 // this.$body = $(document.body); 11898 11899 this.TEXTAREA = document.createElement('TEXTAREA'); 11900 11901 (0, _element.addClass)(this.TEXTAREA, 'handsontableInput'); 11902 11903 this.textareaStyle = this.TEXTAREA.style; 11904 this.textareaStyle.width = 0; 11905 this.textareaStyle.height = 0; 11906 11907 this.TEXTAREA_PARENT = document.createElement('DIV'); 11908 (0, _element.addClass)(this.TEXTAREA_PARENT, 'handsontableInputHolder'); 11909 11910 this.textareaParentStyle = this.TEXTAREA_PARENT.style; 11911 this.textareaParentStyle.top = 0; 11912 this.textareaParentStyle.left = 0; 11913 this.textareaParentStyle.display = 'none'; 11914 11915 this.TEXTAREA_PARENT.appendChild(this.TEXTAREA); 11916 11917 this.instance.rootElement.appendChild(this.TEXTAREA_PARENT); 11918 11919 var that = this; 11920 this.instance._registerTimeout(setTimeout(function () { 11921 that.refreshDimensions(); 11922 }, 0)); 11923}; 11924 11925TextEditor.prototype.getEditedCell = function () { 11926 var editorSection = this.checkEditorSection(), 11927 editedCell; 11928 11929 switch (editorSection) { 11930 case 'top': 11931 editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({ 11932 row: this.row, 11933 col: this.col 11934 }); 11935 this.textareaParentStyle.zIndex = 101; 11936 break; 11937 case 'top-left-corner': 11938 editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({ 11939 row: this.row, 11940 col: this.col 11941 }); 11942 this.textareaParentStyle.zIndex = 103; 11943 break; 11944 case 'bottom-left-corner': 11945 editedCell = this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell({ 11946 row: this.row, 11947 col: this.col 11948 }); 11949 this.textareaParentStyle.zIndex = 103; 11950 break; 11951 case 'left': 11952 editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({ 11953 row: this.row, 11954 col: this.col 11955 }); 11956 this.textareaParentStyle.zIndex = 102; 11957 break; 11958 case 'bottom': 11959 editedCell = this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.getCell({ 11960 row: this.row, 11961 col: this.col 11962 }); 11963 this.textareaParentStyle.zIndex = 102; 11964 break; 11965 default: 11966 editedCell = this.instance.getCell(this.row, this.col); 11967 this.textareaParentStyle.zIndex = ''; 11968 break; 11969 } 11970 11971 return editedCell != -1 && editedCell != -2 ? editedCell : void 0; 11972}; 11973 11974TextEditor.prototype.refreshValue = function () { 11975 var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop); 11976 this.originalValue = sourceData; 11977 11978 this.setValue(sourceData); 11979 this.refreshDimensions(); 11980}; 11981 11982TextEditor.prototype.refreshDimensions = function () { 11983 if (this.state !== _baseEditor.EditorState.EDITING) { 11984 return; 11985 } 11986 this.TD = this.getEditedCell(); 11987 11988 // TD is outside of the viewport. 11989 if (!this.TD) { 11990 this.close(true); 11991 11992 return; 11993 } 11994 var currentOffset = (0, _element.offset)(this.TD), 11995 containerOffset = (0, _element.offset)(this.instance.rootElement), 11996 scrollableContainer = (0, _element.getScrollableElement)(this.TD), 11997 totalRowsCount = this.instance.countRows(), 11998 11999 12000 // If colHeaders is disabled, cells in the first row have border-top 12001 editTopModifier = currentOffset.top === containerOffset.top ? 0 : 1, 12002 editTop = currentOffset.top - containerOffset.top - editTopModifier - (scrollableContainer.scrollTop || 0), 12003 editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0), 12004 settings = this.instance.getSettings(), 12005 rowHeadersCount = this.instance.hasRowHeaders(), 12006 colHeadersCount = this.instance.hasColHeaders(), 12007 editorSection = this.checkEditorSection(), 12008 backgroundColor = this.TD.style.backgroundColor, 12009 cssTransformOffset; 12010 12011 // TODO: Refactor this to the new instance.getCell method (from #ply-59), after 0.12.1 is released 12012 switch (editorSection) { 12013 case 'top': 12014 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode); 12015 break; 12016 case 'left': 12017 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode); 12018 break; 12019 case 'top-left-corner': 12020 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode); 12021 break; 12022 case 'bottom-left-corner': 12023 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode); 12024 break; 12025 case 'bottom': 12026 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode); 12027 break; 12028 default: 12029 break; 12030 } 12031 12032 if (colHeadersCount && this.instance.getSelected()[0] === 0 || settings.fixedRowsBottom && this.instance.getSelected()[0] === totalRowsCount - settings.fixedRowsBottom) { 12033 editTop += 1; 12034 } 12035 12036 if (this.instance.getSelected()[1] === 0) { 12037 editLeft += 1; 12038 } 12039 12040 if (cssTransformOffset && cssTransformOffset != -1) { 12041 this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1]; 12042 } else { 12043 (0, _element.resetCssTransform)(this.TEXTAREA_PARENT); 12044 } 12045 12046 this.textareaParentStyle.top = editTop + 'px'; 12047 this.textareaParentStyle.left = editLeft + 'px'; 12048 12049 var firstRowOffset = this.instance.view.wt.wtViewport.rowsRenderCalculator.startPosition; 12050 var firstColumnOffset = this.instance.view.wt.wtViewport.columnsRenderCalculator.startPosition; 12051 var horizontalScrollPosition = this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition(); 12052 var verticalScrollPosition = this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition(); 12053 var scrollbarWidth = (0, _element.getScrollbarWidth)(); 12054 12055 var cellTopOffset = this.TD.offsetTop + firstRowOffset - verticalScrollPosition; 12056 var cellLeftOffset = this.TD.offsetLeft + firstColumnOffset - horizontalScrollPosition; 12057 12058 var width = (0, _element.innerWidth)(this.TD) - 8; 12059 var actualVerticalScrollbarWidth = (0, _element.hasVerticalScrollbar)(scrollableContainer) ? scrollbarWidth : 0; 12060 var actualHorizontalScrollbarWidth = (0, _element.hasHorizontalScrollbar)(scrollableContainer) ? scrollbarWidth : 0; 12061 var maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 9 - actualVerticalScrollbarWidth; 12062 var height = this.TD.scrollHeight + 1; 12063 var maxHeight = Math.max(this.instance.view.maximumVisibleElementHeight(cellTopOffset) - actualHorizontalScrollbarWidth, 23); 12064 12065 var cellComputedStyle = (0, _element.getComputedStyle)(this.TD); 12066 12067 this.TEXTAREA.style.fontSize = cellComputedStyle.fontSize; 12068 this.TEXTAREA.style.fontFamily = cellComputedStyle.fontFamily; 12069 this.TEXTAREA.style.backgroundColor = ''; // RESET STYLE 12070 this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : (0, _element.getComputedStyle)(this.TEXTAREA).backgroundColor; 12071 12072 this.autoResize.init(this.TEXTAREA, { 12073 minHeight: Math.min(height, maxHeight), 12074 maxHeight: maxHeight, // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar) 12075 minWidth: Math.min(width, maxWidth), 12076 maxWidth: maxWidth // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar) 12077 }, true); 12078 12079 this.textareaParentStyle.display = 'block'; 12080}; 12081 12082TextEditor.prototype.bindEvents = function () { 12083 var editor = this; 12084 12085 this.eventManager.addEventListener(this.TEXTAREA, 'cut', function (event) { 12086 (0, _event.stopPropagation)(event); 12087 }); 12088 12089 this.eventManager.addEventListener(this.TEXTAREA, 'paste', function (event) { 12090 (0, _event.stopPropagation)(event); 12091 }); 12092 12093 this.instance.addHook('afterScrollHorizontally', function () { 12094 editor.refreshDimensions(); 12095 }); 12096 12097 this.instance.addHook('afterScrollVertically', function () { 12098 editor.refreshDimensions(); 12099 }); 12100 12101 this.instance.addHook('afterColumnResize', function () { 12102 editor.refreshDimensions(); 12103 editor.focus(); 12104 }); 12105 12106 this.instance.addHook('afterRowResize', function () { 12107 editor.refreshDimensions(); 12108 editor.focus(); 12109 }); 12110 12111 this.instance.addHook('afterDestroy', function () { 12112 editor.eventManager.destroy(); 12113 }); 12114}; 12115 12116TextEditor.prototype.destroy = function () { 12117 this.eventManager.destroy(); 12118}; 12119 12120exports.default = TextEditor; 12121 12122/***/ }), 12123/* 45 */ 12124/***/ (function(module, exports) { 12125 12126var core = module.exports = { version: '2.5.1' }; 12127if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef 12128 12129 12130/***/ }), 12131/* 46 */ 12132/***/ (function(module, exports) { 12133 12134module.exports = {}; 12135 12136 12137/***/ }), 12138/* 47 */ 12139/***/ (function(module, exports, __webpack_require__) { 12140 12141var META = __webpack_require__(51)('meta'); 12142var isObject = __webpack_require__(12); 12143var has = __webpack_require__(26); 12144var setDesc = __webpack_require__(18).f; 12145var id = 0; 12146var isExtensible = Object.isExtensible || function () { 12147 return true; 12148}; 12149var FREEZE = !__webpack_require__(25)(function () { 12150 return isExtensible(Object.preventExtensions({})); 12151}); 12152var setMeta = function (it) { 12153 setDesc(it, META, { value: { 12154 i: 'O' + ++id, // object ID 12155 w: {} // weak collections IDs 12156 } }); 12157}; 12158var fastKey = function (it, create) { 12159 // return primitive with prefix 12160 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; 12161 if (!has(it, META)) { 12162 // can't set metadata to uncaught frozen object 12163 if (!isExtensible(it)) return 'F'; 12164 // not necessary to add metadata 12165 if (!create) return 'E'; 12166 // add missing metadata 12167 setMeta(it); 12168 // return object ID 12169 } return it[META].i; 12170}; 12171var getWeak = function (it, create) { 12172 if (!has(it, META)) { 12173 // can't set metadata to uncaught frozen object 12174 if (!isExtensible(it)) return true; 12175 // not necessary to add metadata 12176 if (!create) return false; 12177 // add missing metadata 12178 setMeta(it); 12179 // return hash weak collections IDs 12180 } return it[META].w; 12181}; 12182// add metadata on freeze-family methods calling 12183var onFreeze = function (it) { 12184 if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it); 12185 return it; 12186}; 12187var meta = module.exports = { 12188 KEY: META, 12189 NEED: false, 12190 fastKey: fastKey, 12191 getWeak: getWeak, 12192 onFreeze: onFreeze 12193}; 12194 12195 12196/***/ }), 12197/* 48 */ 12198/***/ (function(module, exports) { 12199 12200exports.f = {}.propertyIsEnumerable; 12201 12202 12203/***/ }), 12204/* 49 */ 12205/***/ (function(module, exports) { 12206 12207module.exports = function (bitmap, value) { 12208 return { 12209 enumerable: !(bitmap & 1), 12210 configurable: !(bitmap & 2), 12211 writable: !(bitmap & 4), 12212 value: value 12213 }; 12214}; 12215 12216 12217/***/ }), 12218/* 50 */ 12219/***/ (function(module, exports, __webpack_require__) { 12220 12221var def = __webpack_require__(18).f; 12222var has = __webpack_require__(26); 12223var TAG = __webpack_require__(8)('toStringTag'); 12224 12225module.exports = function (it, tag, stat) { 12226 if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); 12227}; 12228 12229 12230/***/ }), 12231/* 51 */ 12232/***/ (function(module, exports) { 12233 12234var id = 0; 12235var px = Math.random(); 12236module.exports = function (key) { 12237 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); 12238}; 12239 12240 12241/***/ }), 12242/* 52 */ 12243/***/ (function(module, exports, __webpack_require__) { 12244 12245var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 12246 * numbro.js 12247 * version : 1.11.0 12248 * author : Företagsplatsen AB 12249 * license : MIT 12250 * http://www.foretagsplatsen.se 12251 */ 12252 12253(function () { 12254 'use strict'; 12255 12256 /************************************ 12257 Constants 12258 ************************************/ 12259 12260 var numbro, 12261 VERSION = '1.11.0', 12262 binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], 12263 decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], 12264 bytes = { 12265 general: { scale: 1024, suffixes: decimalSuffixes, marker: 'bd' }, 12266 binary: { scale: 1024, suffixes: binarySuffixes, marker: 'b' }, 12267 decimal: { scale: 1000, suffixes: decimalSuffixes, marker: 'd' } 12268 }, 12269 // general must be before the others because it reuses their characters! 12270 byteFormatOrder = [ bytes.general, bytes.binary, bytes.decimal ], 12271 // internal storage for culture config files 12272 cultures = {}, 12273 // Todo: Remove in 2.0.0 12274 languages = cultures, 12275 currentCulture = 'en-US', 12276 zeroFormat = null, 12277 defaultFormat = '0,0', 12278 defaultCurrencyFormat = '0$', 12279 // check for nodeJS 12280 hasModule = (typeof module !== 'undefined' && module.exports), 12281 // default culture 12282 enUS = { 12283 delimiters: { 12284 thousands: ',', 12285 decimal: '.' 12286 }, 12287 abbreviations: { 12288 thousand: 'k', 12289 million: 'm', 12290 billion: 'b', 12291 trillion: 't' 12292 }, 12293 ordinal: function(number) { 12294 var b = number % 10; 12295 return (~~(number % 100 / 10) === 1) ? 'th' : 12296 (b === 1) ? 'st' : 12297 (b === 2) ? 'nd' : 12298 (b === 3) ? 'rd' : 'th'; 12299 }, 12300 currency: { 12301 symbol: '$', 12302 position: 'prefix' 12303 }, 12304 defaults: { 12305 currencyFormat: ',0000 a' 12306 }, 12307 formats: { 12308 fourDigits: '0000 a', 12309 fullWithTwoDecimals: '$ ,0.00', 12310 fullWithTwoDecimalsNoCurrency: ',0.00' 12311 } 12312 }; 12313 12314 /************************************ 12315 Constructors 12316 ************************************/ 12317 12318 12319 // Numbro prototype object 12320 function Numbro(number) { 12321 this._value = number; 12322 } 12323 12324 function numberLength(number) { 12325 if (number === 0) { return 1; } 12326 return Math.floor(Math.log(Math.abs(number)) / Math.LN10) + 1; 12327 } 12328 12329 function zeroes(count) { 12330 var i, ret = ''; 12331 12332 for (i = 0; i < count; i++) { 12333 ret += '0'; 12334 } 12335 12336 return ret; 12337 } 12338 /** 12339 * Implementation of toFixed() for numbers with exponents 12340 * This function may return negative representations for zero values e.g. "-0.0" 12341 */ 12342 function toFixedLargeSmall(value, precision) { 12343 var mantissa, 12344 beforeDec, 12345 afterDec, 12346 exponent, 12347 prefix, 12348 endStr, 12349 zerosStr, 12350 str; 12351 12352 str = value.toString(); 12353 12354 mantissa = str.split('e')[0]; 12355 exponent = str.split('e')[1]; 12356 12357 beforeDec = mantissa.split('.')[0]; 12358 afterDec = mantissa.split('.')[1] || ''; 12359 12360 if (+exponent > 0) { 12361 // exponent is positive - add zeros after the numbers 12362 str = beforeDec + afterDec + zeroes(exponent - afterDec.length); 12363 } else { 12364 // exponent is negative 12365 12366 if (+beforeDec < 0) { 12367 prefix = '-0'; 12368 } else { 12369 prefix = '0'; 12370 } 12371 12372 // tack on the decimal point if needed 12373 if (precision > 0) { 12374 prefix += '.'; 12375 } 12376 12377 zerosStr = zeroes((-1 * exponent) - 1); 12378 // substring off the end to satisfy the precision 12379 endStr = (zerosStr + Math.abs(beforeDec) + afterDec).substr(0, precision); 12380 str = prefix + endStr; 12381 } 12382 12383 // only add percision 0's if the exponent is positive 12384 if (+exponent > 0 && precision > 0) { 12385 str += '.' + zeroes(precision); 12386 } 12387 12388 return str; 12389 } 12390 12391 /** 12392 * Implementation of toFixed() that treats floats more like decimals 12393 * 12394 * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present 12395 * problems for accounting- and finance-related software. 12396 * 12397 * Also removes negative signs for zero-formatted numbers. e.g. -0.01 w/ precision 1 -> 0.0 12398 */ 12399 function toFixed(value, precision, roundingFunction, optionals) { 12400 var power = Math.pow(10, precision), 12401 optionalsRegExp, 12402 output; 12403 12404 if (value.toString().indexOf('e') > -1) { 12405 // toFixed returns scientific notation for numbers above 1e21 and below 1e-7 12406 output = toFixedLargeSmall(value, precision); 12407 // remove the leading negative sign if it exists and should not be present (e.g. -0.00) 12408 if (output.charAt(0) === '-' && +output >= 0) { 12409 output = output.substr(1); // chop off the '-' 12410 } 12411 } 12412 else { 12413 // Multiply up by precision, round accurately, then divide and use native toFixed(): 12414 output = (roundingFunction(value + 'e+' + precision) / power).toFixed(precision); 12415 } 12416 12417 if (optionals) { 12418 optionalsRegExp = new RegExp('0{1,' + optionals + '}$'); 12419 output = output.replace(optionalsRegExp, ''); 12420 } 12421 12422 return output; 12423 } 12424 12425 /************************************ 12426 Formatting 12427 ************************************/ 12428 12429 // determine what type of formatting we need to do 12430 function formatNumbro(n, format, roundingFunction) { 12431 var output, 12432 escapedFormat = format.replace(/\{[^\{\}]*\}/g, ''); 12433 12434 // figure out what kind of format we are dealing with 12435 if (escapedFormat.indexOf('$') > -1) { // currency!!!!! 12436 output = formatCurrency(n, cultures[currentCulture].currency.symbol, format, roundingFunction); 12437 } else if (escapedFormat.indexOf('%') > -1) { // percentage 12438 output = formatPercentage(n, format, roundingFunction); 12439 } else if (escapedFormat.indexOf(':') > -1) { // time 12440 output = formatTime(n, format); 12441 } else { // plain ol' numbers or bytes 12442 output = formatNumber(n._value, format, roundingFunction); 12443 } 12444 12445 // return string 12446 return output; 12447 } 12448 12449 // revert to number 12450 function unformatNumbro(n, string) { 12451 var stringOriginal = string, 12452 thousandRegExp, 12453 millionRegExp, 12454 billionRegExp, 12455 trillionRegExp, 12456 bytesMultiplier = false, 12457 power; 12458 12459 if (string.indexOf(':') > -1) { 12460 n._value = unformatTime(string); 12461 } else { 12462 if (string === zeroFormat) { 12463 n._value = 0; 12464 } else { 12465 if (cultures[currentCulture].delimiters.decimal !== '.') { 12466 string = string.replace(/\./g, '').replace(cultures[currentCulture].delimiters.decimal, '.'); 12467 } 12468 12469 // see if abbreviations are there so that we can multiply to the correct number 12470 thousandRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.thousand + 12471 '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$'); 12472 millionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.million + 12473 '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$'); 12474 billionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.billion + 12475 '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$'); 12476 trillionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.trillion + 12477 '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$'); 12478 12479 // see if bytes are there so that we can multiply to the correct number 12480 for (power = 1; power < binarySuffixes.length && !bytesMultiplier; ++power) { 12481 if (string.indexOf(binarySuffixes[power]) > -1) { 12482 bytesMultiplier = Math.pow(1024, power); 12483 } else if (string.indexOf(decimalSuffixes[power]) > -1) { 12484 bytesMultiplier = Math.pow(1000, power); 12485 } 12486 } 12487 12488 var str = string.replace(/[^0-9\.]+/g, ''); 12489 if (str === '') { 12490 // An empty string is not a number. 12491 n._value = NaN; 12492 12493 } else { 12494 // do some math to create our number 12495 n._value = ((bytesMultiplier) ? bytesMultiplier : 1) * 12496 ((stringOriginal.match(thousandRegExp)) ? Math.pow(10, 3) : 1) * 12497 ((stringOriginal.match(millionRegExp)) ? Math.pow(10, 6) : 1) * 12498 ((stringOriginal.match(billionRegExp)) ? Math.pow(10, 9) : 1) * 12499 ((stringOriginal.match(trillionRegExp)) ? Math.pow(10, 12) : 1) * 12500 ((string.indexOf('%') > -1) ? 0.01 : 1) * 12501 (((string.split('-').length + 12502 Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2) ? 1 : -1) * 12503 Number(str); 12504 12505 // round if we are talking about bytes 12506 n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value; 12507 } 12508 } 12509 } 12510 return n._value; 12511 } 12512 12513 function formatCurrency(n, currencySymbol, originalFormat, roundingFunction) { 12514 var format = originalFormat, 12515 symbolIndex = format.indexOf('$'), 12516 openParenIndex = format.indexOf('('), 12517 plusSignIndex = format.indexOf('+'), 12518 minusSignIndex = format.indexOf('-'), 12519 space = '', 12520 decimalSeparator = '', 12521 spliceIndex, 12522 output; 12523 12524 if(format.indexOf('$') === -1){ 12525 // Use defaults instead of the format provided 12526 if (cultures[currentCulture].currency.position === 'infix') { 12527 decimalSeparator = currencySymbol; 12528 if (cultures[currentCulture].currency.spaceSeparated) { 12529 decimalSeparator = ' ' + decimalSeparator + ' '; 12530 } 12531 } else if (cultures[currentCulture].currency.spaceSeparated) { 12532 space = ' '; 12533 } 12534 } else { 12535 // check for space before or after currency 12536 if (format.indexOf(' $') > -1) { 12537 space = ' '; 12538 format = format.replace(' $', ''); 12539 } else if (format.indexOf('$ ') > -1) { 12540 space = ' '; 12541 format = format.replace('$ ', ''); 12542 } else { 12543 format = format.replace('$', ''); 12544 } 12545 } 12546 12547 // Format The Number 12548 output = formatNumber(n._value, format, roundingFunction, decimalSeparator); 12549 12550 if (originalFormat.indexOf('$') === -1) { 12551 // Use defaults instead of the format provided 12552 switch (cultures[currentCulture].currency.position) { 12553 case 'postfix': 12554 if (output.indexOf(')') > -1) { 12555 output = output.split(''); 12556 output.splice(-1, 0, space + currencySymbol); 12557 output = output.join(''); 12558 } else { 12559 output = output + space + currencySymbol; 12560 } 12561 break; 12562 case 'infix': 12563 break; 12564 case 'prefix': 12565 if (output.indexOf('(') > -1 || output.indexOf('-') > -1) { 12566 output = output.split(''); 12567 spliceIndex = Math.max(openParenIndex, minusSignIndex) + 1; 12568 12569 output.splice(spliceIndex, 0, currencySymbol + space); 12570 output = output.join(''); 12571 } else { 12572 output = currencySymbol + space + output; 12573 } 12574 break; 12575 default: 12576 throw Error('Currency position should be among ["prefix", "infix", "postfix"]'); 12577 } 12578 } else { 12579 // position the symbol 12580 if (symbolIndex <= 1) { 12581 if (output.indexOf('(') > -1 || output.indexOf('+') > -1 || output.indexOf('-') > -1) { 12582 output = output.split(''); 12583 spliceIndex = 1; 12584 if (symbolIndex < openParenIndex || symbolIndex < plusSignIndex || symbolIndex < minusSignIndex) { 12585 // the symbol appears before the "(", "+" or "-" 12586 spliceIndex = 0; 12587 } 12588 output.splice(spliceIndex, 0, currencySymbol + space); 12589 output = output.join(''); 12590 } else { 12591 output = currencySymbol + space + output; 12592 } 12593 } else { 12594 if (output.indexOf(')') > -1) { 12595 output = output.split(''); 12596 output.splice(-1, 0, space + currencySymbol); 12597 output = output.join(''); 12598 } else { 12599 output = output + space + currencySymbol; 12600 } 12601 } 12602 } 12603 12604 return output; 12605 } 12606 12607 function formatForeignCurrency(n, foreignCurrencySymbol, originalFormat, roundingFunction) { 12608 return formatCurrency(n, foreignCurrencySymbol, originalFormat, roundingFunction); 12609 } 12610 12611 function formatPercentage(n, format, roundingFunction) { 12612 var space = '', 12613 output, 12614 value = n._value * 100; 12615 12616 // check for space before % 12617 if (format.indexOf(' %') > -1) { 12618 space = ' '; 12619 format = format.replace(' %', ''); 12620 } else { 12621 format = format.replace('%', ''); 12622 } 12623 12624 output = formatNumber(value, format, roundingFunction); 12625 12626 if (output.indexOf(')') > -1) { 12627 output = output.split(''); 12628 output.splice(-1, 0, space + '%'); 12629 output = output.join(''); 12630 } else { 12631 output = output + space + '%'; 12632 } 12633 12634 return output; 12635 } 12636 12637 function formatTime(n) { 12638 var hours = Math.floor(n._value / 60 / 60), 12639 minutes = Math.floor((n._value - (hours * 60 * 60)) / 60), 12640 seconds = Math.round(n._value - (hours * 60 * 60) - (minutes * 60)); 12641 return hours + ':' + 12642 ((minutes < 10) ? '0' + minutes : minutes) + ':' + 12643 ((seconds < 10) ? '0' + seconds : seconds); 12644 } 12645 12646 function unformatTime(string) { 12647 var timeArray = string.split(':'), 12648 seconds = 0; 12649 // turn hours and minutes into seconds and add them all up 12650 if (timeArray.length === 3) { 12651 // hours 12652 seconds = seconds + (Number(timeArray[0]) * 60 * 60); 12653 // minutes 12654 seconds = seconds + (Number(timeArray[1]) * 60); 12655 // seconds 12656 seconds = seconds + Number(timeArray[2]); 12657 } else if (timeArray.length === 2) { 12658 // minutes 12659 seconds = seconds + (Number(timeArray[0]) * 60); 12660 // seconds 12661 seconds = seconds + Number(timeArray[1]); 12662 } 12663 return Number(seconds); 12664 } 12665 12666 function formatByteUnits (value, suffixes, scale) { 12667 var suffix = suffixes[0], 12668 power, 12669 min, 12670 max, 12671 abs = Math.abs(value); 12672 12673 if (abs >= scale) { 12674 for (power = 1; power < suffixes.length; ++power) { 12675 min = Math.pow(scale, power); 12676 max = Math.pow(scale, power + 1); 12677 12678 if (abs >= min && abs < max) { 12679 suffix = suffixes[power]; 12680 value = value / min; 12681 break; 12682 } 12683 } 12684 12685 // values greater than or equal to [scale] YB never set the suffix 12686 if (suffix === suffixes[0]) { 12687 value = value / Math.pow(scale, suffixes.length - 1); 12688 suffix = suffixes[suffixes.length - 1]; 12689 } 12690 } 12691 12692 return { value: value, suffix: suffix }; 12693 } 12694 12695 function formatNumber (value, format, roundingFunction, sep) { 12696 var negP = false, 12697 signed = false, 12698 optDec = false, 12699 abbr = '', 12700 abbrK = false, // force abbreviation to thousands 12701 abbrM = false, // force abbreviation to millions 12702 abbrB = false, // force abbreviation to billions 12703 abbrT = false, // force abbreviation to trillions 12704 abbrForce = false, // force abbreviation 12705 bytes = '', 12706 byteFormat, 12707 units, 12708 ord = '', 12709 abs = Math.abs(value), 12710 totalLength, 12711 length, 12712 minimumPrecision, 12713 pow, 12714 w, 12715 intPrecision, 12716 precision, 12717 prefix, 12718 postfix, 12719 thousands, 12720 d = '', 12721 forcedNeg = false, 12722 neg = false, 12723 indexOpenP, 12724 indexMinus, 12725 paren = '', 12726 minlen, 12727 i; 12728 12729 // check if number is zero and a custom zero format has been set 12730 if (value === 0 && zeroFormat !== null) { 12731 return zeroFormat; 12732 } 12733 12734 if (!isFinite(value)) { 12735 return '' + value; 12736 } 12737 12738 if (format.indexOf('{') === 0) { 12739 var end = format.indexOf('}'); 12740 if (end === -1) { 12741 throw Error('Format should also contain a "}"'); 12742 } 12743 prefix = format.slice(1, end); 12744 format = format.slice(end + 1); 12745 } else { 12746 prefix = ''; 12747 } 12748 12749 if (format.indexOf('}') === format.length - 1 && format.length) { 12750 var start = format.indexOf('{'); 12751 if (start === -1) { 12752 throw Error('Format should also contain a "{"'); 12753 } 12754 postfix = format.slice(start + 1, -1); 12755 format = format.slice(0, start + 1); 12756 } else { 12757 postfix = ''; 12758 } 12759 12760 // check for min length 12761 var info; 12762 if (format.indexOf('.') === -1) { 12763 info = format.match(/([0-9]+).*/); 12764 } else { 12765 info = format.match(/([0-9]+)\..*/); 12766 } 12767 minlen = info === null ? -1 : info[1].length; 12768 12769 // see if we should use parentheses for negative number or if we should prefix with a sign 12770 // if both are present we default to parentheses 12771 if (format.indexOf('-') !== -1) { 12772 forcedNeg = true; 12773 } 12774 if (format.indexOf('(') > -1) { 12775 negP = true; 12776 format = format.slice(1, -1); 12777 } else if (format.indexOf('+') > -1) { 12778 signed = true; 12779 format = format.replace(/\+/g, ''); 12780 } 12781 12782 // see if abbreviation is wanted 12783 if (format.indexOf('a') > -1) { 12784 intPrecision = format.split('.')[0].match(/[0-9]+/g) || ['0']; 12785 intPrecision = parseInt(intPrecision[0], 10); 12786 12787 // check if abbreviation is specified 12788 abbrK = format.indexOf('aK') >= 0; 12789 abbrM = format.indexOf('aM') >= 0; 12790 abbrB = format.indexOf('aB') >= 0; 12791 abbrT = format.indexOf('aT') >= 0; 12792 abbrForce = abbrK || abbrM || abbrB || abbrT; 12793 12794 // check for space before abbreviation 12795 if (format.indexOf(' a') > -1) { 12796 abbr = ' '; 12797 format = format.replace(' a', ''); 12798 } else { 12799 format = format.replace('a', ''); 12800 } 12801 12802 totalLength = numberLength(value); 12803 minimumPrecision = totalLength % 3; 12804 minimumPrecision = minimumPrecision === 0 ? 3 : minimumPrecision; 12805 12806 if (intPrecision && abs !== 0) { 12807 pow = 3 * ~~((Math.min(intPrecision, totalLength) - minimumPrecision) / 3); 12808 abs = abs / Math.pow(10, pow); 12809 } 12810 12811 if (totalLength !== intPrecision) { 12812 if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { 12813 // trillion 12814 abbr = abbr + cultures[currentCulture].abbreviations.trillion; 12815 value = value / Math.pow(10, 12); 12816 } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { 12817 // billion 12818 abbr = abbr + cultures[currentCulture].abbreviations.billion; 12819 value = value / Math.pow(10, 9); 12820 } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { 12821 // million 12822 abbr = abbr + cultures[currentCulture].abbreviations.million; 12823 value = value / Math.pow(10, 6); 12824 } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { 12825 // thousand 12826 abbr = abbr + cultures[currentCulture].abbreviations.thousand; 12827 value = value / Math.pow(10, 3); 12828 } 12829 } 12830 12831 length = numberLength(value); 12832 if (intPrecision && length < intPrecision && format.indexOf('.') === -1) { 12833 format += '[.]'; 12834 format += zeroes(intPrecision - length); 12835 } 12836 } 12837 12838 // see if we are formatting 12839 // binary-decimal bytes (1024 MB), binary bytes (1024 MiB), or decimal bytes (1000 MB) 12840 for (i = 0; i < byteFormatOrder.length; ++i) { 12841 byteFormat = byteFormatOrder[i]; 12842 12843 if (format.indexOf(byteFormat.marker) > -1) { 12844 // check for space before 12845 if (format.indexOf(' ' + byteFormat.marker) >-1) { 12846 bytes = ' '; 12847 } 12848 12849 // remove the marker (with the space if it had one) 12850 format = format.replace(bytes + byteFormat.marker, ''); 12851 12852 units = formatByteUnits(value, byteFormat.suffixes, byteFormat.scale); 12853 12854 value = units.value; 12855 bytes = bytes + units.suffix; 12856 12857 break; 12858 } 12859 } 12860 12861 // see if ordinal is wanted 12862 if (format.indexOf('o') > -1) { 12863 // check for space before 12864 if (format.indexOf(' o') > -1) { 12865 ord = ' '; 12866 format = format.replace(' o', ''); 12867 } else { 12868 format = format.replace('o', ''); 12869 } 12870 12871 if (cultures[currentCulture].ordinal) { 12872 ord = ord + cultures[currentCulture].ordinal(value); 12873 } 12874 } 12875 12876 if (format.indexOf('[.]') > -1) { 12877 optDec = true; 12878 format = format.replace('[.]', '.'); 12879 } 12880 12881 precision = format.split('.')[1]; 12882 thousands = format.indexOf(','); 12883 12884 if (precision) { 12885 var dSplit = []; 12886 12887 if (precision.indexOf('*') !== -1) { 12888 d = value.toString(); 12889 dSplit = d.split('.'); 12890 if (dSplit.length > 1) { 12891 d = toFixed(value, dSplit[1].length, roundingFunction); 12892 } 12893 } else { 12894 if (precision.indexOf('[') > -1) { 12895 precision = precision.replace(']', ''); 12896 precision = precision.split('['); 12897 d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, 12898 precision[1].length); 12899 } else { 12900 d = toFixed(value, precision.length, roundingFunction); 12901 } 12902 } 12903 12904 dSplit = d.split('.'); 12905 w = dSplit[0]; 12906 12907 if (dSplit.length > 1 && dSplit[1].length) { 12908 var p = sep ? abbr + sep : cultures[currentCulture].delimiters.decimal; 12909 d = p + dSplit[1]; 12910 } else { 12911 d = ''; 12912 } 12913 12914 if (optDec && Number(d.slice(1)) === 0) { 12915 d = ''; 12916 } 12917 } else { 12918 w = toFixed(value, 0, roundingFunction); 12919 } 12920 12921 // format number 12922 if (w.indexOf('-') > -1) { 12923 w = w.slice(1); 12924 neg = true; 12925 } 12926 12927 if (w.length < minlen) { 12928 w = zeroes(minlen - w.length) + w; 12929 } 12930 12931 if (thousands > -1) { 12932 w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + 12933 cultures[currentCulture].delimiters.thousands); 12934 } 12935 12936 if (format.indexOf('.') === 0) { 12937 w = ''; 12938 } 12939 12940 indexOpenP = format.indexOf('('); 12941 indexMinus = format.indexOf('-'); 12942 12943 if (indexOpenP < indexMinus) { 12944 paren = ((negP && neg) ? '(' : '') + (((forcedNeg && neg) || (!negP && neg)) ? '-' : ''); 12945 } else { 12946 paren = (((forcedNeg && neg) || (!negP && neg)) ? '-' : '') + ((negP && neg) ? '(' : ''); 12947 } 12948 12949 return prefix + 12950 paren + ((!neg && signed && value !== 0) ? '+' : '') + 12951 w + d + 12952 ((ord) ? ord : '') + 12953 ((abbr && !sep) ? abbr : '') + 12954 ((bytes) ? bytes : '') + 12955 ((negP && neg) ? ')' : '') + 12956 postfix; 12957 } 12958 12959 /************************************ 12960 Top Level Functions 12961 ************************************/ 12962 12963 numbro = function(input) { 12964 if (numbro.isNumbro(input)) { 12965 input = input.value(); 12966 } else if (typeof input === 'string' || typeof input === 'number') { 12967 input = numbro.fn.unformat(input); 12968 } else { 12969 input = NaN; 12970 } 12971 12972 return new Numbro(Number(input)); 12973 }; 12974 12975 // version number 12976 numbro.version = VERSION; 12977 12978 // compare numbro object 12979 numbro.isNumbro = function(obj) { 12980 return obj instanceof Numbro; 12981 }; 12982 12983 /** 12984 * This function allow the user to set a new language with a fallback if 12985 * the language does not exist. If no fallback language is provided, 12986 * it fallbacks to english. 12987 * 12988 * @deprecated Since in version 1.6.0. It will be deleted in version 2.0 12989 * `setCulture` should be used instead. 12990 */ 12991 numbro.setLanguage = function(newLanguage, fallbackLanguage) { 12992 console.warn('`setLanguage` is deprecated since version 1.6.0. Use `setCulture` instead'); 12993 var key = newLanguage, 12994 prefix = newLanguage.split('-')[0], 12995 matchingLanguage = null; 12996 if (!languages[key]) { 12997 Object.keys(languages).forEach(function(language) { 12998 if (!matchingLanguage && language.split('-')[0] === prefix) { 12999 matchingLanguage = language; 13000 } 13001 }); 13002 key = matchingLanguage || fallbackLanguage || 'en-US'; 13003 } 13004 chooseCulture(key); 13005 }; 13006 13007 /** 13008 * This function allow the user to set a new culture with a fallback if 13009 * the culture does not exist. If no fallback culture is provided, 13010 * it falls back to "en-US". 13011 */ 13012 numbro.setCulture = function(newCulture, fallbackCulture) { 13013 var key = newCulture, 13014 suffix = newCulture.split('-')[1], 13015 matchingCulture = null; 13016 if (!cultures[key]) { 13017 if (suffix) { 13018 Object.keys(cultures).forEach(function(language) { 13019 if (!matchingCulture && language.split('-')[1] === suffix) { 13020 matchingCulture = language; 13021 } 13022 }); 13023 } 13024 13025 key = matchingCulture || fallbackCulture || 'en-US'; 13026 } 13027 chooseCulture(key); 13028 }; 13029 13030 /** 13031 * This function will load languages and then set the global language. If 13032 * no arguments are passed in, it will simply return the current global 13033 * language key. 13034 * 13035 * @deprecated Since in version 1.6.0. It will be deleted in version 2.0 13036 * `culture` should be used instead. 13037 */ 13038 numbro.language = function(key, values) { 13039 console.warn('`language` is deprecated since version 1.6.0. Use `culture` instead'); 13040 13041 if (!key) { 13042 return currentCulture; 13043 } 13044 13045 if (key && !values) { 13046 if (!languages[key]) { 13047 throw new Error('Unknown language : ' + key); 13048 } 13049 chooseCulture(key); 13050 } 13051 13052 if (values || !languages[key]) { 13053 setCulture(key, values); 13054 } 13055 13056 return numbro; 13057 }; 13058 13059 /** 13060 * This function will load cultures and then set the global culture. If 13061 * no arguments are passed in, it will simply return the current global 13062 * culture code. 13063 */ 13064 numbro.culture = function(code, values) { 13065 if (!code) { 13066 return currentCulture; 13067 } 13068 13069 if (code && !values) { 13070 if (!cultures[code]) { 13071 throw new Error('Unknown culture : ' + code); 13072 } 13073 chooseCulture(code); 13074 } 13075 13076 if (values || !cultures[code]) { 13077 setCulture(code, values); 13078 } 13079 13080 return numbro; 13081 }; 13082 13083 /** 13084 * This function provides access to the loaded language data. If 13085 * no arguments are passed in, it will simply return the current 13086 * global language object. 13087 * 13088 * @deprecated Since in version 1.6.0. It will be deleted in version 2.0 13089 * `culture` should be used instead. 13090 */ 13091 numbro.languageData = function(key) { 13092 console.warn('`languageData` is deprecated since version 1.6.0. Use `cultureData` instead'); 13093 13094 if (!key) { 13095 return languages[currentCulture]; 13096 } 13097 13098 if (!languages[key]) { 13099 throw new Error('Unknown language : ' + key); 13100 } 13101 13102 return languages[key]; 13103 }; 13104 13105 /** 13106 * This function provides access to the loaded culture data. If 13107 * no arguments are passed in, it will simply return the current 13108 * global culture object. 13109 */ 13110 numbro.cultureData = function(code) { 13111 if (!code) { 13112 return cultures[currentCulture]; 13113 } 13114 13115 if (!cultures[code]) { 13116 throw new Error('Unknown culture : ' + code); 13117 } 13118 13119 return cultures[code]; 13120 }; 13121 13122 numbro.culture('en-US', enUS); 13123 13124 /** 13125 * @deprecated Since in version 1.6.0. It will be deleted in version 2.0 13126 * `cultures` should be used instead. 13127 */ 13128 numbro.languages = function() { 13129 console.warn('`languages` is deprecated since version 1.6.0. Use `cultures` instead'); 13130 13131 return languages; 13132 }; 13133 13134 numbro.cultures = function() { 13135 return cultures; 13136 }; 13137 13138 numbro.zeroFormat = function(format) { 13139 zeroFormat = typeof(format) === 'string' ? format : null; 13140 }; 13141 13142 numbro.defaultFormat = function(format) { 13143 defaultFormat = typeof(format) === 'string' ? format : '0.0'; 13144 }; 13145 13146 numbro.defaultCurrencyFormat = function (format) { 13147 defaultCurrencyFormat = typeof(format) === 'string' ? format : '0$'; 13148 }; 13149 13150 numbro.validate = function(val, culture) { 13151 13152 var _decimalSep, 13153 _thousandSep, 13154 _currSymbol, 13155 _valArray, 13156 _abbrObj, 13157 _thousandRegEx, 13158 cultureData, 13159 temp; 13160 13161 //coerce val to string 13162 if (typeof val !== 'string') { 13163 val += ''; 13164 if (console.warn) { 13165 console.warn('Numbro.js: Value is not string. It has been co-erced to: ', val); 13166 } 13167 } 13168 13169 //trim whitespaces from either sides 13170 val = val.trim(); 13171 13172 //replace the initial '+' or '-' sign if present 13173 val = val.replace(/^[+-]?/, ''); 13174 13175 //if val is just digits return true 13176 if ( !! val.match(/^\d+$/)) { 13177 return true; 13178 } 13179 13180 //if val is empty return false 13181 if (val === '') { 13182 return false; 13183 } 13184 13185 //get the decimal and thousands separator from numbro.cultureData 13186 try { 13187 //check if the culture is understood by numbro. if not, default it to current culture 13188 cultureData = numbro.cultureData(culture); 13189 } catch (e) { 13190 cultureData = numbro.cultureData(numbro.culture()); 13191 } 13192 13193 //setup the delimiters and currency symbol based on culture 13194 _currSymbol = cultureData.currency.symbol; 13195 _abbrObj = cultureData.abbreviations; 13196 _decimalSep = cultureData.delimiters.decimal; 13197 if (cultureData.delimiters.thousands === '.') { 13198 _thousandSep = '\\.'; 13199 } else { 13200 _thousandSep = cultureData.delimiters.thousands; 13201 } 13202 13203 // validating currency symbol 13204 temp = val.match(/^[^\d\.\,]+/); 13205 if (temp !== null) { 13206 val = val.substr(1); 13207 if (temp[0] !== _currSymbol) { 13208 return false; 13209 } 13210 } 13211 13212 //validating abbreviation symbol 13213 temp = val.match(/[^\d]+$/); 13214 if (temp !== null) { 13215 val = val.slice(0, -1); 13216 if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million && 13217 temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) { 13218 return false; 13219 } 13220 } 13221 13222 _thousandRegEx = new RegExp(_thousandSep + '{2}'); 13223 13224 if (!val.match(/[^\d.,]/g)) { 13225 _valArray = val.split(_decimalSep); 13226 if (_valArray.length > 2) { 13227 return false; 13228 } else { 13229 if (_valArray.length < 2) { 13230 return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx)); 13231 } else { 13232 if (_valArray[0] === '') { 13233 // for values without leading zero eg. .984 13234 return (!_valArray[0].match(_thousandRegEx) && 13235 !!_valArray[1].match(/^\d+$/)); 13236 13237 } else if (_valArray[0].length === 1) { 13238 return ( !! _valArray[0].match(/^\d+$/) && 13239 !_valArray[0].match(_thousandRegEx) && 13240 !! _valArray[1].match(/^\d+$/)); 13241 } else { 13242 return ( !! _valArray[0].match(/^\d+.*\d$/) && 13243 !_valArray[0].match(_thousandRegEx) && 13244 !! _valArray[1].match(/^\d+$/)); 13245 } 13246 } 13247 } 13248 } 13249 13250 return false; 13251 }; 13252 13253 /** 13254 * * @deprecated Since in version 1.6.0. It will be deleted in version 2.0 13255 * `loadCulturesInNode` should be used instead. 13256 */ 13257 numbro.loadLanguagesInNode = function() { 13258 console.warn('`loadLanguagesInNode` is deprecated since version 1.6.0. Use `loadCulturesInNode` instead'); 13259 13260 numbro.loadCulturesInNode(); 13261 }; 13262 13263 numbro.loadCulturesInNode = function() { 13264 // TODO: Rename the folder in 2.0.0 13265 var cultures = __webpack_require__(305); 13266 13267 for(var langLocaleCode in cultures) { 13268 if(langLocaleCode) { 13269 numbro.culture(langLocaleCode, cultures[langLocaleCode]); 13270 } 13271 } 13272 }; 13273 13274 /************************************ 13275 Helpers 13276 ************************************/ 13277 13278 function setCulture(code, values) { 13279 cultures[code] = values; 13280 } 13281 13282 function chooseCulture(code) { 13283 currentCulture = code; 13284 var defaults = cultures[code].defaults; 13285 if (defaults && defaults.format) { 13286 numbro.defaultFormat(defaults.format); 13287 } 13288 if (defaults && defaults.currencyFormat) { 13289 numbro.defaultCurrencyFormat(defaults.currencyFormat); 13290 } 13291 } 13292 13293 function inNodejsRuntime() { 13294 return (typeof process !== 'undefined') && 13295 (process.browser === undefined) && 13296 process.title && 13297 ( 13298 process.title.indexOf('node') !== -1 || 13299 process.title.indexOf('meteor-tool') > 0 || 13300 process.title === 'grunt' || 13301 process.title === 'gulp' 13302 ) && 13303 ("function" !== 'undefined'); 13304 } 13305 13306 /************************************ 13307 Floating-point helpers 13308 ************************************/ 13309 13310 // The floating-point helper functions and implementation 13311 // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/ 13312 13313 /** 13314 * Array.prototype.reduce for browsers that don't support it 13315 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce#Compatibility 13316 */ 13317 if ('function' !== typeof Array.prototype.reduce) { 13318 Array.prototype.reduce = function(callback, optInitialValue) { 13319 13320 if (null === this || 'undefined' === typeof this) { 13321 // At the moment all modern browsers, that support strict mode, have 13322 // native implementation of Array.prototype.reduce. For instance, IE8 13323 // does not support strict mode, so this check is actually useless. 13324 throw new TypeError('Array.prototype.reduce called on null or undefined'); 13325 } 13326 13327 if ('function' !== typeof callback) { 13328 throw new TypeError(callback + ' is not a function'); 13329 } 13330 13331 var index, 13332 value, 13333 length = this.length >>> 0, 13334 isValueSet = false; 13335 13336 if (1 < arguments.length) { 13337 value = optInitialValue; 13338 isValueSet = true; 13339 } 13340 13341 for (index = 0; length > index; ++index) { 13342 if (this.hasOwnProperty(index)) { 13343 if (isValueSet) { 13344 value = callback(value, this[index], index, this); 13345 } else { 13346 value = this[index]; 13347 isValueSet = true; 13348 } 13349 } 13350 } 13351 13352 if (!isValueSet) { 13353 throw new TypeError('Reduce of empty array with no initial value'); 13354 } 13355 13356 return value; 13357 }; 13358 } 13359 13360 13361 /** 13362 * Computes the multiplier necessary to make x >= 1, 13363 * effectively eliminating miscalculations caused by 13364 * finite precision. 13365 */ 13366 function multiplier(x) { 13367 var parts = x.toString().split('.'); 13368 if (parts.length < 2) { 13369 return 1; 13370 } 13371 return Math.pow(10, parts[1].length); 13372 } 13373 13374 /** 13375 * Given a variable number of arguments, returns the maximum 13376 * multiplier that must be used to normalize an operation involving 13377 * all of them. 13378 */ 13379 function correctionFactor() { 13380 var args = Array.prototype.slice.call(arguments); 13381 return args.reduce(function(prev, next) { 13382 var mp = multiplier(prev), 13383 mn = multiplier(next); 13384 return mp > mn ? mp : mn; 13385 }, -Infinity); 13386 } 13387 13388 /************************************ 13389 Numbro Prototype 13390 ************************************/ 13391 13392 13393 numbro.fn = Numbro.prototype = { 13394 13395 clone: function() { 13396 return numbro(this); 13397 }, 13398 13399 format: function(inputString, roundingFunction) { 13400 return formatNumbro(this, 13401 inputString ? inputString : defaultFormat, 13402 (roundingFunction !== undefined) ? roundingFunction : Math.round 13403 ); 13404 }, 13405 13406 formatCurrency: function(inputString, roundingFunction) { 13407 return formatCurrency(this, 13408 cultures[currentCulture].currency.symbol, 13409 inputString ? inputString : defaultCurrencyFormat, 13410 (roundingFunction !== undefined) ? roundingFunction : Math.round 13411 ); 13412 }, 13413 13414 formatForeignCurrency: function(currencySymbol, inputString, roundingFunction) { 13415 return formatForeignCurrency(this, 13416 currencySymbol, 13417 inputString ? inputString : defaultCurrencyFormat, 13418 (roundingFunction !== undefined) ? roundingFunction : Math.round 13419 ); 13420 }, 13421 13422 unformat: function(inputString) { 13423 if (typeof inputString === 'number') { 13424 return inputString; 13425 } else if (typeof inputString === 'string') { 13426 var result = unformatNumbro(this, inputString); 13427 13428 // Any unparseable string (represented as NaN in the result) is 13429 // converted into undefined. 13430 return isNaN(result) ? undefined : result; 13431 } else { 13432 return undefined; 13433 } 13434 }, 13435 13436 binaryByteUnits: function() { 13437 return formatByteUnits(this._value, bytes.binary.suffixes, bytes.binary.scale).suffix; 13438 }, 13439 13440 byteUnits: function() { 13441 return formatByteUnits(this._value, bytes.general.suffixes, bytes.general.scale).suffix; 13442 }, 13443 13444 decimalByteUnits: function() { 13445 return formatByteUnits(this._value, bytes.decimal.suffixes, bytes.decimal.scale).suffix; 13446 }, 13447 13448 value: function() { 13449 return this._value; 13450 }, 13451 13452 valueOf: function() { 13453 return this._value; 13454 }, 13455 13456 set: function(value) { 13457 this._value = Number(value); 13458 return this; 13459 }, 13460 13461 add: function(value) { 13462 var corrFactor = correctionFactor.call(null, this._value, value); 13463 13464 function cback(accum, curr) { 13465 return accum + corrFactor * curr; 13466 } 13467 this._value = [this._value, value].reduce(cback, 0) / corrFactor; 13468 return this; 13469 }, 13470 13471 subtract: function(value) { 13472 var corrFactor = correctionFactor.call(null, this._value, value); 13473 13474 function cback(accum, curr) { 13475 return accum - corrFactor * curr; 13476 } 13477 this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; 13478 return this; 13479 }, 13480 13481 multiply: function(value) { 13482 function cback(accum, curr) { 13483 var corrFactor = correctionFactor(accum, curr), 13484 result = accum * corrFactor; 13485 result *= curr * corrFactor; 13486 result /= corrFactor * corrFactor; 13487 return result; 13488 } 13489 this._value = [this._value, value].reduce(cback, 1); 13490 return this; 13491 }, 13492 13493 divide: function(value) { 13494 function cback(accum, curr) { 13495 var corrFactor = correctionFactor(accum, curr); 13496 return (accum * corrFactor) / (curr * corrFactor); 13497 } 13498 this._value = [this._value, value].reduce(cback); 13499 return this; 13500 }, 13501 13502 difference: function(value) { 13503 return Math.abs(numbro(this._value).subtract(value).value()); 13504 } 13505 13506 }; 13507 13508 /************************************ 13509 Exposing Numbro 13510 ************************************/ 13511 13512 if (inNodejsRuntime()) { 13513 //Todo: Rename the folder in 2.0.0 13514 numbro.loadCulturesInNode(); 13515 } 13516 13517 // CommonJS module is defined 13518 if (hasModule) { 13519 module.exports = numbro; 13520 } else { 13521 /*global ender:false */ 13522 if (typeof ender === 'undefined') { 13523 // here, `this` means `window` in the browser, or `global` on the server 13524 // add `numbro` as a global object via a string identifier, 13525 // for Closure Compiler 'advanced' mode 13526 this.numbro = numbro; 13527 } 13528 13529 /*global define:false */ 13530 if (true) { 13531 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { 13532 return numbro; 13533 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), 13534 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 13535 } 13536 } 13537 13538}.call(typeof window === 'undefined' ? this : window)); 13539 13540 13541/*** EXPORTS FROM exports-to-window-loader ***/ 13542window['numbro'] = __webpack_require__(52); 13543 13544/***/ }), 13545/* 53 */ 13546/***/ (function(module, exports, __webpack_require__) { 13547 13548"use strict"; 13549 13550 13551exports.__esModule = true; 13552exports.default = staticRegister; 13553 13554function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 13555 13556var collection = exports.collection = new Map(); 13557 13558function staticRegister() { 13559 var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'common'; 13560 13561 if (!collection.has(namespace)) { 13562 collection.set(namespace, new Map()); 13563 } 13564 var subCollection = collection.get(namespace); 13565 13566 /** 13567 * Register an item to the collection. If the item under the same was exist earlier then this item will be replaced with new one. 13568 * 13569 * @param {String} name Identification of the item. 13570 * @param {*} item Item to save in the collection. 13571 */ 13572 function register(name, item) { 13573 subCollection.set(name, item); 13574 } 13575 13576 /** 13577 * Retrieve the item from the collection. 13578 * 13579 * @param {String} name Identification of the item. 13580 * @returns {*} Returns item which was saved in the collection. 13581 */ 13582 function getItem(name) { 13583 return subCollection.get(name); 13584 } 13585 13586 /** 13587 * Check if item under specyfied name is exists. 13588 * 13589 * @param {String} name Identification of the item. 13590 * @returns {Boolean} Returns `true` or `false` depends on if element exists in the collection. 13591 */ 13592 function hasItem(name) { 13593 return subCollection.has(name); 13594 } 13595 13596 /** 13597 * Retrieve list of names registered from the collection. 13598 * 13599 * @returns {Array} Returns an array of strings with all names under which objects are stored. 13600 */ 13601 function getNames() { 13602 return [].concat(_toConsumableArray(subCollection.keys())); 13603 } 13604 13605 /** 13606 * Retrieve all registered values from the collection. 13607 * 13608 * @returns {Array} Returns an array with all values stored in the collection. 13609 */ 13610 function getValues() { 13611 return [].concat(_toConsumableArray(subCollection.values())); 13612 } 13613 13614 return { 13615 register: register, 13616 getItem: getItem, 13617 hasItem: hasItem, 13618 getNames: getNames, 13619 getValues: getValues 13620 }; 13621} 13622 13623/***/ }), 13624/* 54 */ 13625/***/ (function(module, exports) { 13626 13627module.exports = function (it) { 13628 if (typeof it != 'function') throw TypeError(it + ' is not a function!'); 13629 return it; 13630}; 13631 13632 13633/***/ }), 13634/* 55 */ 13635/***/ (function(module, exports) { 13636 13637module.exports = function (it, Constructor, name, forbiddenField) { 13638 if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { 13639 throw TypeError(name + ': incorrect invocation!'); 13640 } return it; 13641}; 13642 13643 13644/***/ }), 13645/* 56 */ 13646/***/ (function(module, exports, __webpack_require__) { 13647 13648// 0 -> Array#forEach 13649// 1 -> Array#map 13650// 2 -> Array#filter 13651// 3 -> Array#some 13652// 4 -> Array#every 13653// 5 -> Array#find 13654// 6 -> Array#findIndex 13655var ctx = __webpack_require__(30); 13656var IObject = __webpack_require__(78); 13657var toObject = __webpack_require__(40); 13658var toLength = __webpack_require__(21); 13659var asc = __webpack_require__(392); 13660module.exports = function (TYPE, $create) { 13661 var IS_MAP = TYPE == 1; 13662 var IS_FILTER = TYPE == 2; 13663 var IS_SOME = TYPE == 3; 13664 var IS_EVERY = TYPE == 4; 13665 var IS_FIND_INDEX = TYPE == 6; 13666 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 13667 var create = $create || asc; 13668 return function ($this, callbackfn, that) { 13669 var O = toObject($this); 13670 var self = IObject(O); 13671 var f = ctx(callbackfn, that, 3); 13672 var length = toLength(self.length); 13673 var index = 0; 13674 var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; 13675 var val, res; 13676 for (;length > index; index++) if (NO_HOLES || index in self) { 13677 val = self[index]; 13678 res = f(val, index, O); 13679 if (TYPE) { 13680 if (IS_MAP) result[index] = res; // map 13681 else if (res) switch (TYPE) { 13682 case 3: return true; // some 13683 case 5: return val; // find 13684 case 6: return index; // findIndex 13685 case 2: result.push(val); // filter 13686 } else if (IS_EVERY) return false; // every 13687 } 13688 } 13689 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; 13690 }; 13691}; 13692 13693 13694/***/ }), 13695/* 57 */ 13696/***/ (function(module, exports, __webpack_require__) { 13697 13698"use strict"; 13699 13700var global = __webpack_require__(10); 13701var $export = __webpack_require__(1); 13702var redefine = __webpack_require__(32); 13703var redefineAll = __webpack_require__(62); 13704var meta = __webpack_require__(47); 13705var forOf = __webpack_require__(59); 13706var anInstance = __webpack_require__(55); 13707var isObject = __webpack_require__(12); 13708var fails = __webpack_require__(25); 13709var $iterDetect = __webpack_require__(79); 13710var setToStringTag = __webpack_require__(50); 13711var inheritIfRequired = __webpack_require__(395); 13712 13713module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { 13714 var Base = global[NAME]; 13715 var C = Base; 13716 var ADDER = IS_MAP ? 'set' : 'add'; 13717 var proto = C && C.prototype; 13718 var O = {}; 13719 var fixMethod = function (KEY) { 13720 var fn = proto[KEY]; 13721 redefine(proto, KEY, 13722 KEY == 'delete' ? function (a) { 13723 return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); 13724 } : KEY == 'has' ? function has(a) { 13725 return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); 13726 } : KEY == 'get' ? function get(a) { 13727 return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); 13728 } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; } 13729 : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; } 13730 ); 13731 }; 13732 if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () { 13733 new C().entries().next(); 13734 }))) { 13735 // create collection constructor 13736 C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); 13737 redefineAll(C.prototype, methods); 13738 meta.NEED = true; 13739 } else { 13740 var instance = new C(); 13741 // early implementations not supports chaining 13742 var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; 13743 // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false 13744 var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); }); 13745 // most early implementations doesn't supports iterables, most modern - not close it correctly 13746 var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new 13747 // for early implementations -0 and +0 not the same 13748 var BUGGY_ZERO = !IS_WEAK && fails(function () { 13749 // V8 ~ Chromium 42- fails only with 5+ elements 13750 var $instance = new C(); 13751 var index = 5; 13752 while (index--) $instance[ADDER](index, index); 13753 return !$instance.has(-0); 13754 }); 13755 if (!ACCEPT_ITERABLES) { 13756 C = wrapper(function (target, iterable) { 13757 anInstance(target, C, NAME); 13758 var that = inheritIfRequired(new Base(), target, C); 13759 if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); 13760 return that; 13761 }); 13762 C.prototype = proto; 13763 proto.constructor = C; 13764 } 13765 if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { 13766 fixMethod('delete'); 13767 fixMethod('has'); 13768 IS_MAP && fixMethod('get'); 13769 } 13770 if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); 13771 // weak collections should not contains .clear method 13772 if (IS_WEAK && proto.clear) delete proto.clear; 13773 } 13774 13775 setToStringTag(C, NAME); 13776 13777 O[NAME] = C; 13778 $export($export.G + $export.W + $export.F * (C != Base), O); 13779 13780 if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); 13781 13782 return C; 13783}; 13784 13785 13786/***/ }), 13787/* 58 */ 13788/***/ (function(module, exports, __webpack_require__) { 13789 13790"use strict"; 13791 13792var hide = __webpack_require__(31); 13793var redefine = __webpack_require__(32); 13794var fails = __webpack_require__(25); 13795var defined = __webpack_require__(33); 13796var wks = __webpack_require__(8); 13797 13798module.exports = function (KEY, length, exec) { 13799 var SYMBOL = wks(KEY); 13800 var fns = exec(defined, SYMBOL, ''[KEY]); 13801 var strfn = fns[0]; 13802 var rxfn = fns[1]; 13803 if (fails(function () { 13804 var O = {}; 13805 O[SYMBOL] = function () { return 7; }; 13806 return ''[KEY](O) != 7; 13807 })) { 13808 redefine(String.prototype, KEY, strfn); 13809 hide(RegExp.prototype, SYMBOL, length == 2 13810 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) 13811 // 21.2.5.11 RegExp.prototype[@@split](string, limit) 13812 ? function (string, arg) { return rxfn.call(string, this, arg); } 13813 // 21.2.5.6 RegExp.prototype[@@match](string) 13814 // 21.2.5.9 RegExp.prototype[@@search](string) 13815 : function (string) { return rxfn.call(string, this); } 13816 ); 13817 } 13818}; 13819 13820 13821/***/ }), 13822/* 59 */ 13823/***/ (function(module, exports, __webpack_require__) { 13824 13825var ctx = __webpack_require__(30); 13826var call = __webpack_require__(280); 13827var isArrayIter = __webpack_require__(276); 13828var anObject = __webpack_require__(17); 13829var toLength = __webpack_require__(21); 13830var getIterFn = __webpack_require__(292); 13831var BREAK = {}; 13832var RETURN = {}; 13833var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { 13834 var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable); 13835 var f = ctx(fn, that, entries ? 2 : 1); 13836 var index = 0; 13837 var length, step, iterator, result; 13838 if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); 13839 // fast case for arrays with default iterator 13840 if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) { 13841 result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); 13842 if (result === BREAK || result === RETURN) return result; 13843 } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { 13844 result = call(iterator, f, step.value, entries); 13845 if (result === BREAK || result === RETURN) return result; 13846 } 13847}; 13848exports.BREAK = BREAK; 13849exports.RETURN = RETURN; 13850 13851 13852/***/ }), 13853/* 60 */ 13854/***/ (function(module, exports) { 13855 13856module.exports = false; 13857 13858 13859/***/ }), 13860/* 61 */ 13861/***/ (function(module, exports) { 13862 13863exports.f = Object.getOwnPropertySymbols; 13864 13865 13866/***/ }), 13867/* 62 */ 13868/***/ (function(module, exports, __webpack_require__) { 13869 13870var redefine = __webpack_require__(32); 13871module.exports = function (target, src, safe) { 13872 for (var key in src) redefine(target, key, src[key], safe); 13873 return target; 13874}; 13875 13876 13877/***/ }), 13878/* 63 */ 13879/***/ (function(module, exports, __webpack_require__) { 13880 13881var toInteger = __webpack_require__(64); 13882var max = Math.max; 13883var min = Math.min; 13884module.exports = function (index, length) { 13885 index = toInteger(index); 13886 return index < 0 ? max(index + length, 0) : min(index, length); 13887}; 13888 13889 13890/***/ }), 13891/* 64 */ 13892/***/ (function(module, exports) { 13893 13894// 7.1.4 ToInteger 13895var ceil = Math.ceil; 13896var floor = Math.floor; 13897module.exports = function (it) { 13898 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); 13899}; 13900 13901 13902/***/ }), 13903/* 65 */ 13904/***/ (function(module, exports, __webpack_require__) { 13905 13906"use strict"; 13907 13908 13909exports.__esModule = true; 13910exports.getRegisteredCellTypes = exports.getRegisteredCellTypeNames = exports.hasCellType = exports.getCellType = exports.registerCellType = undefined; 13911 13912var _staticRegister2 = __webpack_require__(53); 13913 13914var _staticRegister3 = _interopRequireDefault(_staticRegister2); 13915 13916var _editors = __webpack_require__(13); 13917 13918var _renderers = __webpack_require__(6); 13919 13920var _validators = __webpack_require__(24); 13921 13922var _autocompleteType = __webpack_require__(312); 13923 13924var _autocompleteType2 = _interopRequireDefault(_autocompleteType); 13925 13926var _checkboxType = __webpack_require__(313); 13927 13928var _checkboxType2 = _interopRequireDefault(_checkboxType); 13929 13930var _dateType = __webpack_require__(314); 13931 13932var _dateType2 = _interopRequireDefault(_dateType); 13933 13934var _dropdownType = __webpack_require__(315); 13935 13936var _dropdownType2 = _interopRequireDefault(_dropdownType); 13937 13938var _handsontableType = __webpack_require__(316); 13939 13940var _handsontableType2 = _interopRequireDefault(_handsontableType); 13941 13942var _numericType = __webpack_require__(317); 13943 13944var _numericType2 = _interopRequireDefault(_numericType); 13945 13946var _passwordType = __webpack_require__(318); 13947 13948var _passwordType2 = _interopRequireDefault(_passwordType); 13949 13950var _textType = __webpack_require__(319); 13951 13952var _textType2 = _interopRequireDefault(_textType); 13953 13954var _timeType = __webpack_require__(320); 13955 13956var _timeType2 = _interopRequireDefault(_timeType); 13957 13958function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 13959 13960var _staticRegister = (0, _staticRegister3.default)('cellTypes'), 13961 register = _staticRegister.register, 13962 getItem = _staticRegister.getItem, 13963 hasItem = _staticRegister.hasItem, 13964 getNames = _staticRegister.getNames, 13965 getValues = _staticRegister.getValues; 13966 13967_register('autocomplete', _autocompleteType2.default); 13968_register('checkbox', _checkboxType2.default); 13969_register('date', _dateType2.default); 13970_register('dropdown', _dropdownType2.default); 13971_register('handsontable', _handsontableType2.default); 13972_register('numeric', _numericType2.default); 13973_register('password', _passwordType2.default); 13974_register('text', _textType2.default); 13975_register('time', _timeType2.default); 13976 13977/** 13978 * Retrieve cell type object. 13979 * 13980 * @param {String} name Cell type identification. 13981 * @returns {Object} Returns cell type object. 13982 */ 13983function _getItem(name) { 13984 if (!hasItem(name)) { 13985 throw Error('You declared cell type "' + name + '" as a string that is not mapped to a known object.\n Cell type must be an object or a string mapped to an object registered by "Handsontable.cellTypes.registerCellType" method'); 13986 } 13987 13988 return getItem(name); 13989} 13990 13991/** 13992 * Register cell type under specified name. 13993 * 13994 * @param {String} name Cell type identification. 13995 * @param {Object} type An object with contains keys (eq: `editor`, `renderer`, `validator`) which describes specified behaviour of the cell. 13996 */ 13997function _register(name, type) { 13998 var editor = type.editor, 13999 renderer = type.renderer, 14000 validator = type.validator; 14001 14002 14003 if (editor) { 14004 (0, _editors.registerEditor)(name, editor); 14005 } 14006 if (renderer) { 14007 (0, _renderers.registerRenderer)(name, renderer); 14008 } 14009 if (validator) { 14010 (0, _validators.registerValidator)(name, validator); 14011 } 14012 14013 register(name, type); 14014} 14015 14016exports.registerCellType = _register; 14017exports.getCellType = _getItem; 14018exports.hasCellType = hasItem; 14019exports.getRegisteredCellTypeNames = getNames; 14020exports.getRegisteredCellTypes = getValues; 14021 14022/***/ }), 14023/* 66 */ 14024/***/ (function(module, exports, __webpack_require__) { 14025 14026"use strict"; 14027 14028 14029exports.__esModule = true; 14030 14031var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); 14032 14033var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 14034 14035exports.default = Core; 14036 14037var _numbro = __webpack_require__(52); 14038 14039var _numbro2 = _interopRequireDefault(_numbro); 14040 14041var _element = __webpack_require__(0); 14042 14043var _setting = __webpack_require__(68); 14044 14045var _function = __webpack_require__(35); 14046 14047var _mixed = __webpack_require__(23); 14048 14049var _browser = __webpack_require__(22); 14050 14051var _dataMap = __webpack_require__(321); 14052 14053var _dataMap2 = _interopRequireDefault(_dataMap); 14054 14055var _editorManager = __webpack_require__(323); 14056 14057var _editorManager2 = _interopRequireDefault(_editorManager); 14058 14059var _eventManager = __webpack_require__(4); 14060 14061var _eventManager2 = _interopRequireDefault(_eventManager); 14062 14063var _object = __webpack_require__(3); 14064 14065var _array = __webpack_require__(2); 14066 14067var _plugins = __webpack_require__(9); 14068 14069var _renderers = __webpack_require__(6); 14070 14071var _validators = __webpack_require__(24); 14072 14073var _string = __webpack_require__(28); 14074 14075var _number = __webpack_require__(5); 14076 14077var _tableView = __webpack_require__(383); 14078 14079var _tableView2 = _interopRequireDefault(_tableView); 14080 14081var _dataSource = __webpack_require__(322); 14082 14083var _dataSource2 = _interopRequireDefault(_dataSource); 14084 14085var _data = __webpack_require__(67); 14086 14087var _recordTranslator = __webpack_require__(268); 14088 14089var _rootInstance = __webpack_require__(90); 14090 14091var _src = __webpack_require__(14); 14092 14093var _pluginHooks = __webpack_require__(11); 14094 14095var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 14096 14097var _defaultSettings = __webpack_require__(88); 14098 14099var _defaultSettings2 = _interopRequireDefault(_defaultSettings); 14100 14101var _cellTypes = __webpack_require__(65); 14102 14103function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 14104 14105function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 14106 14107var activeGuid = null; 14108 14109/** 14110 * Handsontable constructor 14111 * 14112 * @core 14113 * @dependencies numbro 14114 * @constructor Core 14115 * @description 14116 * 14117 * After Handsontable is constructed, you can modify the grid behavior using the available public methods. 14118 * 14119 * --- 14120 * ## How to call methods 14121 * 14122 * These are 2 equal ways to call a Handsontable method: 14123 * 14124 * ```js 14125 * // all following examples assume that you constructed Handsontable like this 14126 * var ht = new Handsontable(document.getElementById('example1'), options); 14127 * 14128 * // now, to use setDataAtCell method, you can either: 14129 * ht.setDataAtCell(0, 0, 'new value'); 14130 * ``` 14131 * 14132 * Alternatively, you can call the method using jQuery wrapper (__obsolete__, requires initialization using our jQuery guide 14133 * ```js 14134 * $('#example1').handsontable('setDataAtCell', 0, 0, 'new value'); 14135 * ``` 14136 * --- 14137 */ 14138function Core(rootElement, userSettings) { 14139 var rootInstanceSymbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 14140 14141 var priv, 14142 datamap, 14143 dataSource, 14144 grid, 14145 selection, 14146 editorManager, 14147 instance = this, 14148 GridSettings = function GridSettings() {}, 14149 eventManager = new _eventManager2.default(instance); 14150 14151 (0, _object.extend)(GridSettings.prototype, _defaultSettings2.default.prototype); // create grid settings as a copy of default settings 14152 (0, _object.extend)(GridSettings.prototype, userSettings); // overwrite defaults with user settings 14153 (0, _object.extend)(GridSettings.prototype, expandType(userSettings)); 14154 14155 if ((0, _rootInstance.hasValidParameter)(rootInstanceSymbol)) { 14156 (0, _rootInstance.registerAsRootInstance)(this); 14157 } 14158 14159 this.rootElement = rootElement; 14160 this.isHotTableEnv = (0, _element.isChildOfWebComponentTable)(this.rootElement); 14161 _eventManager2.default.isHotTableEnv = this.isHotTableEnv; 14162 14163 this.container = document.createElement('div'); 14164 this.renderCall = false; 14165 14166 rootElement.insertBefore(this.container, rootElement.firstChild); 14167 14168 if (undefined !== '\x63\x65' && (0, _rootInstance.isRootInstance)(this)) { 14169 (0, _mixed._injectProductInfo)(userSettings.licenseKey, rootElement); 14170 } 14171 14172 this.guid = 'ht_' + (0, _string.randomString)(); // this is the namespace for global events 14173 14174 var recordTranslator = (0, _recordTranslator.getTranslator)(instance); 14175 14176 dataSource = new _dataSource2.default(instance); 14177 14178 if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') { 14179 this.rootElement.id = this.guid; // if root element does not have an id, assign a random id 14180 } 14181 priv = { 14182 cellSettings: [], 14183 columnSettings: [], 14184 columnsSettingConflicts: ['data', 'width'], 14185 settings: new GridSettings(), // current settings instance 14186 selRange: null, // exposed by public method `getSelectedRange` 14187 isPopulated: null, 14188 scrollable: null, 14189 firstRun: true 14190 }; 14191 14192 grid = { 14193 /** 14194 * Inserts or removes rows and columns 14195 * 14196 * @memberof Core# 14197 * @function alter 14198 * @private 14199 * @param {String} action Possible values: "insert_row", "insert_col", "remove_row", "remove_col" 14200 * @param {Number} index 14201 * @param {Number} amount 14202 * @param {String} [source] Optional. Source of hook runner. 14203 * @param {Boolean} [keepEmptyRows] Optional. Flag for preventing deletion of empty rows. 14204 */ 14205 alter: function alter(action, index, amount, source, keepEmptyRows) { 14206 var delta; 14207 14208 amount = amount || 1; 14209 14210 function spliceWith(data, index, count, toInject) { 14211 var valueFactory = function valueFactory() { 14212 var result = void 0; 14213 14214 if (toInject === 'array') { 14215 result = []; 14216 } else if (toInject === 'object') { 14217 result = {}; 14218 } 14219 14220 return result; 14221 }; 14222 var spliceArgs = (0, _array.arrayMap)(new Array(count), function () { 14223 return valueFactory(); 14224 }); 14225 14226 spliceArgs.unshift(index, 0); 14227 data.splice.apply(data, _toConsumableArray(spliceArgs)); 14228 } 14229 14230 /* eslint-disable no-case-declarations */ 14231 switch (action) { 14232 case 'insert_row': 14233 14234 var numberOfSourceRows = instance.countSourceRows(); 14235 14236 if (instance.getSettings().maxRows === numberOfSourceRows) { 14237 return; 14238 } 14239 14240 index = (0, _mixed.isDefined)(index) ? index : numberOfSourceRows; 14241 14242 delta = datamap.createRow(index, amount, source); 14243 spliceWith(priv.cellSettings, index, amount, 'array'); 14244 14245 if (delta) { 14246 if (selection.isSelected() && priv.selRange.from.row >= index) { 14247 priv.selRange.from.row += delta; 14248 selection.transformEnd(delta, 0); // will call render() internally 14249 } else { 14250 selection.refreshBorders(); // it will call render and prepare methods 14251 } 14252 } 14253 break; 14254 14255 case 'insert_col': 14256 delta = datamap.createCol(index, amount, source); 14257 14258 for (var row = 0, len = instance.countSourceRows(); row < len; row++) { 14259 if (priv.cellSettings[row]) { 14260 spliceWith(priv.cellSettings[row], index, amount); 14261 } 14262 } 14263 14264 if (delta) { 14265 if (Array.isArray(instance.getSettings().colHeaders)) { 14266 var spliceArray = [index, 0]; 14267 spliceArray.length += delta; // inserts empty (undefined) elements at the end of an array 14268 Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray); // inserts empty (undefined) elements into the colHeader array 14269 } 14270 14271 if (selection.isSelected() && priv.selRange.from.col >= index) { 14272 priv.selRange.from.col += delta; 14273 selection.transformEnd(0, delta); // will call render() internally 14274 } else { 14275 selection.refreshBorders(); // it will call render and prepare methods 14276 } 14277 } 14278 break; 14279 14280 case 'remove_row': 14281 datamap.removeRow(index, amount, source); 14282 priv.cellSettings.splice(index, amount); 14283 14284 var totalRows = instance.countRows(); 14285 var fixedRowsTop = instance.getSettings().fixedRowsTop; 14286 if (fixedRowsTop >= index + 1) { 14287 instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - index); 14288 } 14289 14290 var fixedRowsBottom = instance.getSettings().fixedRowsBottom; 14291 if (fixedRowsBottom && index >= totalRows - fixedRowsBottom) { 14292 instance.getSettings().fixedRowsBottom -= Math.min(amount, fixedRowsBottom); 14293 } 14294 14295 grid.adjustRowsAndCols(); 14296 selection.refreshBorders(); // it will call render and prepare methods 14297 break; 14298 14299 case 'remove_col': 14300 var visualColumnIndex = recordTranslator.toPhysicalColumn(index); 14301 14302 datamap.removeCol(index, amount, source); 14303 14304 for (var _row = 0, _len = instance.countSourceRows(); _row < _len; _row++) { 14305 if (priv.cellSettings[_row]) { 14306 // if row hasn't been rendered it wouldn't have cellSettings 14307 priv.cellSettings[_row].splice(visualColumnIndex, amount); 14308 } 14309 } 14310 var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft; 14311 14312 if (fixedColumnsLeft >= index + 1) { 14313 instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - index); 14314 } 14315 14316 if (Array.isArray(instance.getSettings().colHeaders)) { 14317 if (typeof visualColumnIndex === 'undefined') { 14318 visualColumnIndex = -1; 14319 } 14320 instance.getSettings().colHeaders.splice(visualColumnIndex, amount); 14321 } 14322 14323 grid.adjustRowsAndCols(); 14324 selection.refreshBorders(); // it will call render and prepare methods 14325 14326 break; 14327 default: 14328 throw new Error('There is no such action "' + action + '"'); 14329 } 14330 14331 if (!keepEmptyRows) { 14332 grid.adjustRowsAndCols(); // makes sure that we did not add rows that will be removed in next refresh 14333 } 14334 }, 14335 14336 14337 /** 14338 * Makes sure there are empty rows at the bottom of the table 14339 */ 14340 adjustRowsAndCols: function adjustRowsAndCols() { 14341 if (priv.settings.minRows) { 14342 // should I add empty rows to data source to meet minRows? 14343 var rows = instance.countRows(); 14344 14345 if (rows < priv.settings.minRows) { 14346 for (var r = 0, minRows = priv.settings.minRows; r < minRows - rows; r++) { 14347 datamap.createRow(instance.countRows(), 1, 'auto'); 14348 } 14349 } 14350 } 14351 if (priv.settings.minSpareRows) { 14352 var emptyRows = instance.countEmptyRows(true); 14353 14354 // should I add empty rows to meet minSpareRows? 14355 if (emptyRows < priv.settings.minSpareRows) { 14356 for (; emptyRows < priv.settings.minSpareRows && instance.countSourceRows() < priv.settings.maxRows; emptyRows++) { 14357 datamap.createRow(instance.countRows(), 1, 'auto'); 14358 } 14359 } 14360 } 14361 { 14362 var emptyCols = void 0; 14363 14364 // count currently empty cols 14365 if (priv.settings.minCols || priv.settings.minSpareCols) { 14366 emptyCols = instance.countEmptyCols(true); 14367 } 14368 14369 // should I add empty cols to meet minCols? 14370 if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) { 14371 for (; instance.countCols() < priv.settings.minCols; emptyCols++) { 14372 datamap.createCol(instance.countCols(), 1, 'auto'); 14373 } 14374 } 14375 // should I add empty cols to meet minSpareCols? 14376 if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) { 14377 for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) { 14378 datamap.createCol(instance.countCols(), 1, 'auto'); 14379 } 14380 } 14381 } 14382 var rowCount = instance.countRows(); 14383 var colCount = instance.countCols(); 14384 14385 if (rowCount === 0 || colCount === 0) { 14386 selection.deselect(); 14387 } 14388 14389 if (selection.isSelected()) { 14390 var selectionChanged = false; 14391 var fromRow = priv.selRange.from.row; 14392 var fromCol = priv.selRange.from.col; 14393 var toRow = priv.selRange.to.row; 14394 var toCol = priv.selRange.to.col; 14395 14396 // if selection is outside, move selection to last row 14397 if (fromRow > rowCount - 1) { 14398 fromRow = rowCount - 1; 14399 selectionChanged = true; 14400 14401 if (toRow > fromRow) { 14402 toRow = fromRow; 14403 } 14404 } else if (toRow > rowCount - 1) { 14405 toRow = rowCount - 1; 14406 selectionChanged = true; 14407 14408 if (fromRow > toRow) { 14409 fromRow = toRow; 14410 } 14411 } 14412 // if selection is outside, move selection to last row 14413 if (fromCol > colCount - 1) { 14414 fromCol = colCount - 1; 14415 selectionChanged = true; 14416 14417 if (toCol > fromCol) { 14418 toCol = fromCol; 14419 } 14420 } else if (toCol > colCount - 1) { 14421 toCol = colCount - 1; 14422 selectionChanged = true; 14423 14424 if (fromCol > toCol) { 14425 fromCol = toCol; 14426 } 14427 } 14428 14429 if (selectionChanged) { 14430 instance.selectCell(fromRow, fromCol, toRow, toCol); 14431 } 14432 } 14433 if (instance.view) { 14434 instance.view.wt.wtOverlays.adjustElementsSize(); 14435 } 14436 }, 14437 14438 14439 /** 14440 * Populate the data from the provided 2d array from the given cell coordinates. 14441 * 14442 * @private 14443 * @param {Object} start Start selection position. Visual indexes. 14444 * @param {Array} input 2d data array. 14445 * @param {Object} [end] End selection position (only for drag-down mode). Visual indexes. 14446 * @param {String} [source="populateFromArray"] Source information string. 14447 * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`. 14448 * @param {String} direction (left|right|up|down) String specifying the direction. 14449 * @param {Array} deltas The deltas array. A difference between values of adjacent cells. 14450 * Useful **only** when the type of handled cells is `numeric`. 14451 * @returns {Object|undefined} ending td in pasted area (only if any cell was changed). 14452 */ 14453 populateFromArray: function populateFromArray(start, input, end, source, method, direction, deltas) { 14454 // TODO: either remove or implement the `direction` argument. Currently it's not working at all. 14455 var r, 14456 rlen, 14457 c, 14458 clen, 14459 setData = [], 14460 current = {}; 14461 14462 rlen = input.length; 14463 14464 if (rlen === 0) { 14465 return false; 14466 } 14467 14468 var repeatCol, 14469 repeatRow, 14470 cmax, 14471 rmax, 14472 baseEnd = { 14473 row: end === null ? null : end.row, 14474 col: end === null ? null : end.col 14475 }; 14476 14477 /* eslint-disable no-case-declarations */ 14478 // insert data with specified pasteMode method 14479 switch (method) { 14480 case 'shift_down': 14481 repeatCol = end ? end.col - start.col + 1 : 0; 14482 repeatRow = end ? end.row - start.row + 1 : 0; 14483 input = (0, _data.translateRowsToColumns)(input); 14484 for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) { 14485 if (c < clen) { 14486 var _instance; 14487 14488 for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) { 14489 input[c].push(input[c][r % rlen]); 14490 } 14491 input[c].unshift(start.col + c, start.row, 0); 14492 (_instance = instance).spliceCol.apply(_instance, _toConsumableArray(input[c])); 14493 } else { 14494 var _instance2; 14495 14496 input[c % clen][0] = start.col + c; 14497 (_instance2 = instance).spliceCol.apply(_instance2, _toConsumableArray(input[c % clen])); 14498 } 14499 } 14500 break; 14501 14502 case 'shift_right': 14503 repeatCol = end ? end.col - start.col + 1 : 0; 14504 repeatRow = end ? end.row - start.row + 1 : 0; 14505 for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) { 14506 if (r < rlen) { 14507 var _instance3; 14508 14509 for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) { 14510 input[r].push(input[r][c % clen]); 14511 } 14512 input[r].unshift(start.row + r, start.col, 0); 14513 (_instance3 = instance).spliceRow.apply(_instance3, _toConsumableArray(input[r])); 14514 } else { 14515 var _instance4; 14516 14517 input[r % rlen][0] = start.row + r; 14518 (_instance4 = instance).spliceRow.apply(_instance4, _toConsumableArray(input[r % rlen])); 14519 } 14520 } 14521 break; 14522 14523 case 'overwrite': 14524 default: 14525 // overwrite and other not specified options 14526 current.row = start.row; 14527 current.col = start.col; 14528 14529 var selected = { // selected range 14530 row: end && start ? end.row - start.row + 1 : 1, 14531 col: end && start ? end.col - start.col + 1 : 1 14532 }; 14533 var skippedRow = 0; 14534 var skippedColumn = 0; 14535 var pushData = true; 14536 var cellMeta = void 0; 14537 14538 var getInputValue = function getInputValue(row) { 14539 var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 14540 14541 var rowValue = input[row % input.length]; 14542 14543 if (col !== null) { 14544 return rowValue[col % rowValue.length]; 14545 } 14546 14547 return rowValue; 14548 }; 14549 var rowInputLength = input.length; 14550 var rowSelectionLength = end ? end.row - start.row + 1 : 0; 14551 14552 if (end) { 14553 rlen = rowSelectionLength; 14554 } else { 14555 rlen = Math.max(rowInputLength, rowSelectionLength); 14556 } 14557 for (r = 0; r < rlen; r++) { 14558 if (end && current.row > end.row && rowSelectionLength > rowInputLength || !priv.settings.allowInsertRow && current.row > instance.countRows() - 1 || current.row >= priv.settings.maxRows) { 14559 break; 14560 } 14561 var visualRow = r - skippedRow; 14562 var colInputLength = getInputValue(visualRow).length; 14563 var colSelectionLength = end ? end.col - start.col + 1 : 0; 14564 14565 if (end) { 14566 clen = colSelectionLength; 14567 } else { 14568 clen = Math.max(colInputLength, colSelectionLength); 14569 } 14570 current.col = start.col; 14571 cellMeta = instance.getCellMeta(current.row, current.col); 14572 14573 if ((source === 'CopyPaste.paste' || source === 'Autofill.autofill') && cellMeta.skipRowOnPaste) { 14574 skippedRow++; 14575 current.row++; 14576 rlen++; 14577 /* eslint-disable no-continue */ 14578 continue; 14579 } 14580 skippedColumn = 0; 14581 14582 for (c = 0; c < clen; c++) { 14583 if (end && current.col > end.col && colSelectionLength > colInputLength || !priv.settings.allowInsertColumn && current.col > instance.countCols() - 1 || current.col >= priv.settings.maxCols) { 14584 break; 14585 } 14586 cellMeta = instance.getCellMeta(current.row, current.col); 14587 14588 if ((source === 'CopyPaste.paste' || source === 'Autofill.fill') && cellMeta.skipColumnOnPaste) { 14589 skippedColumn++; 14590 current.col++; 14591 clen++; 14592 continue; 14593 } 14594 if (cellMeta.readOnly) { 14595 current.col++; 14596 /* eslint-disable no-continue */ 14597 continue; 14598 } 14599 var visualColumn = c - skippedColumn; 14600 var value = getInputValue(visualRow, visualColumn); 14601 var orgValue = instance.getDataAtCell(current.row, current.col); 14602 var index = { 14603 row: visualRow, 14604 col: visualColumn 14605 }; 14606 14607 if (source === 'Autofill.fill') { 14608 var result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, {}, selected); 14609 14610 if (result) { 14611 value = (0, _mixed.isUndefined)(result.value) ? value : result.value; 14612 } 14613 } 14614 if (value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { 14615 if (orgValue === null || (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) !== 'object') { 14616 pushData = false; 14617 } else { 14618 var orgValueSchema = (0, _object.duckSchema)(orgValue[0] || orgValue); 14619 var valueSchema = (0, _object.duckSchema)(value[0] || value); 14620 14621 /* eslint-disable max-depth */ 14622 if ((0, _object.isObjectEquals)(orgValueSchema, valueSchema)) { 14623 value = (0, _object.deepClone)(value); 14624 } else { 14625 pushData = false; 14626 } 14627 } 14628 } else if (orgValue !== null && (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) === 'object') { 14629 pushData = false; 14630 } 14631 if (pushData) { 14632 setData.push([current.row, current.col, value]); 14633 } 14634 pushData = true; 14635 current.col++; 14636 } 14637 current.row++; 14638 } 14639 instance.setDataAtCell(setData, null, null, source || 'populateFromArray'); 14640 break; 14641 } 14642 } 14643 }; 14644 14645 /* eslint-disable no-multi-assign */ 14646 this.selection = selection = { // this public assignment is only temporary 14647 inProgress: false, 14648 14649 selectedHeader: { 14650 cols: false, 14651 rows: false 14652 }, 14653 14654 /** 14655 * @param {Boolean} [rows=false] 14656 * @param {Boolean} [cols=false] 14657 * @param {Boolean} [corner=false] 14658 */ 14659 setSelectedHeaders: function setSelectedHeaders() { 14660 var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 14661 var cols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 14662 var corner = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 14663 14664 instance.selection.selectedHeader.rows = rows; 14665 instance.selection.selectedHeader.cols = cols; 14666 instance.selection.selectedHeader.corner = corner; 14667 }, 14668 14669 14670 /** 14671 * Sets inProgress to `true`. This enables onSelectionEnd and onSelectionEndByProp to function as desired. 14672 */ 14673 begin: function begin() { 14674 instance.selection.inProgress = true; 14675 }, 14676 14677 14678 /** 14679 * Sets inProgress to `false`. Triggers onSelectionEnd and onSelectionEndByProp. 14680 */ 14681 finish: function finish() { 14682 var sel = instance.getSelected(); 14683 instance.runHooks('afterSelectionEnd', sel[0], sel[1], sel[2], sel[3]); 14684 instance.runHooks('afterSelectionEndByProp', sel[0], instance.colToProp(sel[1]), sel[2], instance.colToProp(sel[3])); 14685 instance.selection.inProgress = false; 14686 }, 14687 14688 14689 /** 14690 * @returns {Boolean} 14691 */ 14692 isInProgress: function isInProgress() { 14693 return instance.selection.inProgress; 14694 }, 14695 14696 14697 /** 14698 * Starts selection range on given td object. 14699 * 14700 * @param {CellCoords} coords Visual coords. 14701 * @param keepEditorOpened 14702 */ 14703 setRangeStart: function setRangeStart(coords, keepEditorOpened) { 14704 instance.runHooks('beforeSetRangeStart', coords); 14705 priv.selRange = new _src.CellRange(coords, coords, coords); 14706 selection.setRangeEnd(coords, null, keepEditorOpened); 14707 }, 14708 14709 14710 /** 14711 * Starts selection range on given td object. 14712 * 14713 * @param {CellCoords} coords Visual coords. 14714 * @param keepEditorOpened 14715 */ 14716 setRangeStartOnly: function setRangeStartOnly(coords) { 14717 instance.runHooks('beforeSetRangeStartOnly', coords); 14718 priv.selRange = new _src.CellRange(coords, coords, coords); 14719 }, 14720 14721 14722 /** 14723 * Ends selection range on given td object. 14724 * 14725 * @param {CellCoords} coords Visual coords. 14726 * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to range end 14727 * @param {Boolean} [keepEditorOpened] If `true`, cell editor will be still opened after changing selection range 14728 */ 14729 setRangeEnd: function setRangeEnd(coords, scrollToCell, keepEditorOpened) { 14730 if (priv.selRange === null) { 14731 return; 14732 } 14733 var disableVisualSelection, 14734 isHeaderSelected = false, 14735 areCoordsPositive = true; 14736 14737 var firstVisibleRow = instance.view.wt.wtTable.getFirstVisibleRow(); 14738 var firstVisibleColumn = instance.view.wt.wtTable.getFirstVisibleColumn(); 14739 var newRangeCoords = { 14740 row: null, 14741 col: null 14742 }; 14743 14744 // trigger handlers 14745 instance.runHooks('beforeSetRangeEnd', coords); 14746 instance.selection.begin(); 14747 14748 newRangeCoords.row = coords.row < 0 ? firstVisibleRow : coords.row; 14749 newRangeCoords.col = coords.col < 0 ? firstVisibleColumn : coords.col; 14750 14751 priv.selRange.to = new _src.CellCoords(newRangeCoords.row, newRangeCoords.col); 14752 14753 if (!priv.settings.multiSelect) { 14754 priv.selRange.from = coords; 14755 } 14756 // set up current selection 14757 instance.view.wt.selections.current.clear(); 14758 14759 disableVisualSelection = instance.getCellMeta(priv.selRange.highlight.row, priv.selRange.highlight.col).disableVisualSelection; 14760 14761 if (typeof disableVisualSelection === 'string') { 14762 disableVisualSelection = [disableVisualSelection]; 14763 } 14764 14765 if (disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('current') === -1) { 14766 instance.view.wt.selections.current.add(priv.selRange.highlight); 14767 } 14768 // set up area selection 14769 instance.view.wt.selections.area.clear(); 14770 14771 if ((disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('area') === -1) && selection.isMultiple()) { 14772 instance.view.wt.selections.area.add(priv.selRange.from); 14773 instance.view.wt.selections.area.add(priv.selRange.to); 14774 } 14775 // set up highlight 14776 if (priv.settings.currentHeaderClassName || priv.settings.currentRowClassName || priv.settings.currentColClassName) { 14777 instance.view.wt.selections.highlight.clear(); 14778 instance.view.wt.selections.highlight.add(priv.selRange.from); 14779 instance.view.wt.selections.highlight.add(priv.selRange.to); 14780 } 14781 14782 var preventScrolling = (0, _object.createObjectPropListener)('value'); 14783 14784 // trigger handlers 14785 instance.runHooks('afterSelection', priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col, preventScrolling); 14786 instance.runHooks('afterSelectionByProp', priv.selRange.from.row, datamap.colToProp(priv.selRange.from.col), priv.selRange.to.row, datamap.colToProp(priv.selRange.to.col), preventScrolling); 14787 14788 if (priv.selRange.from.row === 0 && priv.selRange.to.row === instance.countRows() - 1 && instance.countRows() > 1 || priv.selRange.from.col === 0 && priv.selRange.to.col === instance.countCols() - 1 && instance.countCols() > 1) { 14789 isHeaderSelected = true; 14790 } 14791 14792 if (coords.row < 0 || coords.col < 0) { 14793 areCoordsPositive = false; 14794 } 14795 14796 if (preventScrolling.isTouched()) { 14797 scrollToCell = !preventScrolling.value; 14798 } 14799 14800 if (scrollToCell !== false && !isHeaderSelected && areCoordsPositive) { 14801 if (priv.selRange.from && !selection.isMultiple()) { 14802 instance.view.scrollViewport(priv.selRange.from); 14803 } else { 14804 instance.view.scrollViewport(coords); 14805 } 14806 } 14807 14808 if (selection.selectedHeader.rows && selection.selectedHeader.cols) { 14809 (0, _element.addClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']); 14810 } else if (selection.selectedHeader.rows) { 14811 (0, _element.removeClass)(instance.rootElement, 'ht__selection--columns'); 14812 (0, _element.addClass)(instance.rootElement, 'ht__selection--rows'); 14813 } else if (selection.selectedHeader.cols) { 14814 (0, _element.removeClass)(instance.rootElement, 'ht__selection--rows'); 14815 (0, _element.addClass)(instance.rootElement, 'ht__selection--columns'); 14816 } else { 14817 (0, _element.removeClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']); 14818 } 14819 14820 selection.refreshBorders(null, keepEditorOpened); 14821 }, 14822 14823 14824 /** 14825 * Destroys editor, redraws borders around cells, prepares editor. 14826 * 14827 * @param {Boolean} [revertOriginal] 14828 * @param {Boolean} [keepEditor] 14829 */ 14830 refreshBorders: function refreshBorders(revertOriginal, keepEditor) { 14831 if (!keepEditor) { 14832 editorManager.destroyEditor(revertOriginal); 14833 } 14834 instance.view.render(); 14835 14836 if (selection.isSelected() && !keepEditor) { 14837 editorManager.prepareEditor(); 14838 } 14839 }, 14840 14841 14842 /** 14843 * Returns information if we have a multiselection. 14844 * 14845 * @returns {Boolean} 14846 */ 14847 isMultiple: function isMultiple() { 14848 var isMultiple = !(priv.selRange.to.col === priv.selRange.from.col && priv.selRange.to.row === priv.selRange.from.row), 14849 modifier = instance.runHooks('afterIsMultipleSelection', isMultiple); 14850 14851 if (isMultiple) { 14852 return modifier; 14853 } 14854 }, 14855 14856 14857 /** 14858 * Selects cell relative to current cell (if possible). 14859 */ 14860 transformStart: function transformStart(rowDelta, colDelta, force, keepEditorOpened) { 14861 var delta = new _src.CellCoords(rowDelta, colDelta), 14862 rowTransformDir = 0, 14863 colTransformDir = 0, 14864 totalRows, 14865 totalCols, 14866 coords, 14867 fixedRowsBottom; 14868 14869 instance.runHooks('modifyTransformStart', delta); 14870 totalRows = instance.countRows(); 14871 totalCols = instance.countCols(); 14872 fixedRowsBottom = instance.getSettings().fixedRowsBottom; 14873 14874 if (priv.selRange.highlight.row + rowDelta > totalRows - 1) { 14875 if (force && priv.settings.minSpareRows > 0 && !(fixedRowsBottom && priv.selRange.highlight.row >= totalRows - fixedRowsBottom - 1)) { 14876 instance.alter('insert_row', totalRows); 14877 totalRows = instance.countRows(); 14878 } else if (priv.settings.autoWrapCol) { 14879 delta.row = 1 - totalRows; 14880 delta.col = priv.selRange.highlight.col + delta.col == totalCols - 1 ? 1 - totalCols : 1; 14881 } 14882 } else if (priv.settings.autoWrapCol && priv.selRange.highlight.row + delta.row < 0 && priv.selRange.highlight.col + delta.col >= 0) { 14883 delta.row = totalRows - 1; 14884 delta.col = priv.selRange.highlight.col + delta.col == 0 ? totalCols - 1 : -1; 14885 } 14886 14887 if (priv.selRange.highlight.col + delta.col > totalCols - 1) { 14888 if (force && priv.settings.minSpareCols > 0) { 14889 instance.alter('insert_col', totalCols); 14890 totalCols = instance.countCols(); 14891 } else if (priv.settings.autoWrapRow) { 14892 delta.row = priv.selRange.highlight.row + delta.row == totalRows - 1 ? 1 - totalRows : 1; 14893 delta.col = 1 - totalCols; 14894 } 14895 } else if (priv.settings.autoWrapRow && priv.selRange.highlight.col + delta.col < 0 && priv.selRange.highlight.row + delta.row >= 0) { 14896 delta.row = priv.selRange.highlight.row + delta.row == 0 ? totalRows - 1 : -1; 14897 delta.col = totalCols - 1; 14898 } 14899 14900 coords = new _src.CellCoords(priv.selRange.highlight.row + delta.row, priv.selRange.highlight.col + delta.col); 14901 14902 if (coords.row < 0) { 14903 rowTransformDir = -1; 14904 coords.row = 0; 14905 } else if (coords.row > 0 && coords.row >= totalRows) { 14906 rowTransformDir = 1; 14907 coords.row = totalRows - 1; 14908 } 14909 14910 if (coords.col < 0) { 14911 colTransformDir = -1; 14912 coords.col = 0; 14913 } else if (coords.col > 0 && coords.col >= totalCols) { 14914 colTransformDir = 1; 14915 coords.col = totalCols - 1; 14916 } 14917 instance.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir); 14918 selection.setRangeStart(coords, keepEditorOpened); 14919 }, 14920 14921 14922 /** 14923 * Sets selection end cell relative to current selection end cell (if possible). 14924 */ 14925 transformEnd: function transformEnd(rowDelta, colDelta) { 14926 var delta = new _src.CellCoords(rowDelta, colDelta), 14927 rowTransformDir = 0, 14928 colTransformDir = 0, 14929 totalRows, 14930 totalCols, 14931 coords; 14932 14933 instance.runHooks('modifyTransformEnd', delta); 14934 14935 totalRows = instance.countRows(); 14936 totalCols = instance.countCols(); 14937 coords = new _src.CellCoords(priv.selRange.to.row + delta.row, priv.selRange.to.col + delta.col); 14938 14939 if (coords.row < 0) { 14940 rowTransformDir = -1; 14941 coords.row = 0; 14942 } else if (coords.row > 0 && coords.row >= totalRows) { 14943 rowTransformDir = 1; 14944 coords.row = totalRows - 1; 14945 } 14946 14947 if (coords.col < 0) { 14948 colTransformDir = -1; 14949 coords.col = 0; 14950 } else if (coords.col > 0 && coords.col >= totalCols) { 14951 colTransformDir = 1; 14952 coords.col = totalCols - 1; 14953 } 14954 instance.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir); 14955 selection.setRangeEnd(coords, true); 14956 }, 14957 14958 14959 /** 14960 * Returns `true` if currently there is a selection on screen, `false` otherwise. 14961 * 14962 * @returns {Boolean} 14963 */ 14964 isSelected: function isSelected() { 14965 return priv.selRange !== null; 14966 }, 14967 14968 14969 /** 14970 * Returns `true` if coords is within current selection coords. 14971 * 14972 * @param {CellCoords} coords 14973 * @returns {Boolean} 14974 */ 14975 inInSelection: function inInSelection(coords) { 14976 if (!selection.isSelected()) { 14977 return false; 14978 } 14979 14980 return priv.selRange.includes(coords); 14981 }, 14982 14983 14984 /** 14985 * Deselects all selected cells 14986 */ 14987 deselect: function deselect() { 14988 if (!selection.isSelected()) { 14989 return; 14990 } 14991 instance.selection.inProgress = false; // needed by HT inception 14992 priv.selRange = null; 14993 instance.view.wt.selections.current.clear(); 14994 instance.view.wt.selections.area.clear(); 14995 if (priv.settings.currentHeaderClassName || priv.settings.currentRowClassName || priv.settings.currentColClassName) { 14996 instance.view.wt.selections.highlight.clear(); 14997 } 14998 editorManager.destroyEditor(); 14999 selection.refreshBorders(); 15000 (0, _element.removeClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']); 15001 instance.runHooks('afterDeselect'); 15002 }, 15003 15004 15005 /** 15006 * Select all cells 15007 */ 15008 selectAll: function selectAll() { 15009 if (!priv.settings.multiSelect) { 15010 return; 15011 } 15012 selection.setSelectedHeaders(true, true, true); 15013 selection.setRangeStart(new _src.CellCoords(0, 0)); 15014 selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, instance.countCols() - 1), false); 15015 }, 15016 15017 15018 /** 15019 * Deletes data from selected cells 15020 */ 15021 empty: function empty() { 15022 if (!selection.isSelected()) { 15023 return; 15024 } 15025 var topLeft = priv.selRange.getTopLeftCorner(); 15026 var bottomRight = priv.selRange.getBottomRightCorner(); 15027 var r, 15028 c, 15029 changes = []; 15030 15031 for (r = topLeft.row; r <= bottomRight.row; r++) { 15032 for (c = topLeft.col; c <= bottomRight.col; c++) { 15033 if (!instance.getCellMeta(r, c).readOnly) { 15034 changes.push([r, c, '']); 15035 } 15036 } 15037 } 15038 instance.setDataAtCell(changes); 15039 } 15040 }; 15041 15042 this.init = function () { 15043 dataSource.setData(priv.settings.data); 15044 instance.runHooks('beforeInit'); 15045 15046 if ((0, _browser.isMobileBrowser)()) { 15047 (0, _element.addClass)(instance.rootElement, 'mobile'); 15048 } 15049 15050 this.updateSettings(priv.settings, true); 15051 15052 this.view = new _tableView2.default(this); 15053 editorManager = new _editorManager2.default(instance, priv, selection, datamap); 15054 15055 this.forceFullRender = true; // used when data was changed 15056 15057 instance.runHooks('init'); 15058 this.view.render(); 15059 15060 if (_typeof(priv.firstRun) === 'object') { 15061 instance.runHooks('afterChange', priv.firstRun[0], priv.firstRun[1]); 15062 priv.firstRun = false; 15063 } 15064 instance.runHooks('afterInit'); 15065 }; 15066 15067 function ValidatorsQueue() { 15068 // moved this one level up so it can be used in any function here. Probably this should be moved to a separate file 15069 var resolved = false; 15070 15071 return { 15072 validatorsInQueue: 0, 15073 valid: true, 15074 addValidatorToQueue: function addValidatorToQueue() { 15075 this.validatorsInQueue++; 15076 resolved = false; 15077 }, 15078 removeValidatorFormQueue: function removeValidatorFormQueue() { 15079 this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1; 15080 this.checkIfQueueIsEmpty(); 15081 }, 15082 onQueueEmpty: function onQueueEmpty(valid) {}, 15083 checkIfQueueIsEmpty: function checkIfQueueIsEmpty() { 15084 if (this.validatorsInQueue == 0 && resolved == false) { 15085 resolved = true; 15086 this.onQueueEmpty(this.valid); 15087 } 15088 } 15089 }; 15090 } 15091 15092 function validateChanges(changes, source, callback) { 15093 var waitingForValidator = new ValidatorsQueue(); 15094 waitingForValidator.onQueueEmpty = resolve; 15095 15096 for (var i = changes.length - 1; i >= 0; i--) { 15097 if (changes[i] === null) { 15098 changes.splice(i, 1); 15099 } else { 15100 var row = changes[i][0]; 15101 var col = datamap.propToCol(changes[i][1]); 15102 15103 var cellProperties = instance.getCellMeta(row, col); 15104 15105 if (cellProperties.type === 'numeric' && typeof changes[i][3] === 'string') { 15106 if (changes[i][3].length > 0 && (/^-?[\d\s]*(\.|,)?\d*$/.test(changes[i][3]) || cellProperties.format)) { 15107 var len = changes[i][3].length; 15108 15109 if ((0, _mixed.isUndefined)(cellProperties.language)) { 15110 _numbro2.default.culture('en-US'); 15111 } else if (changes[i][3].indexOf('.') === len - 3 && changes[i][3].indexOf(',') === -1) { 15112 // this input in format XXXX.XX is likely to come from paste. Let's parse it using international rules 15113 _numbro2.default.culture('en-US'); 15114 } else { 15115 15116 _numbro2.default.culture(cellProperties.language); 15117 } 15118 15119 var _numbro$cultureData = _numbro2.default.cultureData(_numbro2.default.culture()), 15120 delimiters = _numbro$cultureData.delimiters; 15121 15122 // try to parse to float - https://github.com/foretagsplatsen/numbro/pull/183 15123 15124 15125 if (_numbro2.default.validate(changes[i][3]) && !isNaN(changes[i][3])) { 15126 changes[i][3] = parseFloat(changes[i][3]); 15127 } else { 15128 changes[i][3] = (0, _numbro2.default)().unformat(changes[i][3]) || changes[i][3]; 15129 } 15130 } 15131 } 15132 15133 /* eslint-disable no-loop-func */ 15134 if (instance.getCellValidator(cellProperties)) { 15135 waitingForValidator.addValidatorToQueue(); 15136 instance.validateCell(changes[i][3], cellProperties, function (i, cellProperties) { 15137 return function (result) { 15138 if (typeof result !== 'boolean') { 15139 throw new Error('Validation error: result is not boolean'); 15140 } 15141 if (result === false && cellProperties.allowInvalid === false) { 15142 changes.splice(i, 1); // cancel the change 15143 cellProperties.valid = true; // we cancelled the change, so cell value is still valid 15144 var cell = instance.getCell(cellProperties.row, cellProperties.col); 15145 (0, _element.removeClass)(cell, instance.getSettings().invalidCellClassName); 15146 --i; 15147 } 15148 waitingForValidator.removeValidatorFormQueue(); 15149 }; 15150 }(i, cellProperties), source); 15151 } 15152 } 15153 } 15154 waitingForValidator.checkIfQueueIsEmpty(); 15155 15156 function resolve() { 15157 var beforeChangeResult; 15158 15159 if (changes.length) { 15160 beforeChangeResult = instance.runHooks('beforeChange', changes, source); 15161 if ((0, _function.isFunction)(beforeChangeResult)) { 15162 console.warn('Your beforeChange callback returns a function. It\'s not supported since Handsontable 0.12.1 (and the returned function will not be executed).'); 15163 } else if (beforeChangeResult === false) { 15164 changes.splice(0, changes.length); // invalidate all changes (remove everything from array) 15165 } 15166 } 15167 callback(); // called when async validators are resolved and beforeChange was not async 15168 } 15169 } 15170 15171 /** 15172 * Internal function to apply changes. Called after validateChanges 15173 * 15174 * @private 15175 * @param {Array} changes Array in form of [row, prop, oldValue, newValue] 15176 * @param {String} source String that identifies how this change will be described in changes array (useful in onChange callback) 15177 * @fires Hooks#beforeChangeRender 15178 * @fires Hooks#afterChange 15179 */ 15180 function applyChanges(changes, source) { 15181 var i = changes.length - 1; 15182 15183 if (i < 0) { 15184 return; 15185 } 15186 15187 for (; i >= 0; i--) { 15188 var skipThisChange = false; 15189 15190 if (changes[i] === null) { 15191 changes.splice(i, 1); 15192 /* eslint-disable no-continue */ 15193 continue; 15194 } 15195 15196 if (changes[i][2] == null && changes[i][3] == null) { 15197 /* eslint-disable no-continue */ 15198 continue; 15199 } 15200 15201 if (priv.settings.allowInsertRow) { 15202 while (changes[i][0] > instance.countRows() - 1) { 15203 var numberOfCreatedRows = datamap.createRow(void 0, void 0, source); 15204 15205 if (numberOfCreatedRows === 0) { 15206 skipThisChange = true; 15207 break; 15208 } 15209 } 15210 } 15211 15212 if (skipThisChange) { 15213 /* eslint-disable no-continue */ 15214 continue; 15215 } 15216 15217 if (instance.dataType === 'array' && (!priv.settings.columns || priv.settings.columns.length === 0) && priv.settings.allowInsertColumn) { 15218 while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) { 15219 datamap.createCol(void 0, void 0, source); 15220 } 15221 } 15222 15223 datamap.set(changes[i][0], changes[i][1], changes[i][3]); 15224 } 15225 15226 instance.forceFullRender = true; // used when data was changed 15227 grid.adjustRowsAndCols(); 15228 instance.runHooks('beforeChangeRender', changes, source); 15229 selection.refreshBorders(null, true); 15230 instance.view.wt.wtOverlays.adjustElementsSize(); 15231 instance.runHooks('afterChange', changes, source || 'edit'); 15232 15233 var activeEditor = instance.getActiveEditor(); 15234 15235 if (activeEditor && (0, _mixed.isDefined)(activeEditor.refreshValue)) { 15236 activeEditor.refreshValue(); 15237 } 15238 } 15239 15240 this.validateCell = function (value, cellProperties, callback, source) { 15241 var validator = instance.getCellValidator(cellProperties); 15242 15243 function done(valid) { 15244 var col = cellProperties.visualCol, 15245 row = cellProperties.visualRow, 15246 td = instance.getCell(row, col, true); 15247 15248 if (td && td.nodeName != 'TH') { 15249 instance.view.wt.wtSettings.settings.cellRenderer(row, col, td); 15250 } 15251 callback(valid); 15252 } 15253 15254 if ((0, _mixed.isRegExp)(validator)) { 15255 validator = function (validator) { 15256 return function (value, callback) { 15257 callback(validator.test(value)); 15258 }; 15259 }(validator); 15260 } 15261 15262 if ((0, _function.isFunction)(validator)) { 15263 15264 value = instance.runHooks('beforeValidate', value, cellProperties.visualRow, cellProperties.prop, source); 15265 15266 // To provide consistent behaviour, validation should be always asynchronous 15267 instance._registerTimeout(setTimeout(function () { 15268 validator.call(cellProperties, value, function (valid) { 15269 valid = instance.runHooks('afterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source); 15270 cellProperties.valid = valid; 15271 15272 done(valid); 15273 instance.runHooks('postAfterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source); 15274 }); 15275 }, 0)); 15276 } else { 15277 // resolve callback even if validator function was not found 15278 instance._registerTimeout(setTimeout(function () { 15279 cellProperties.valid = true; 15280 done(cellProperties.valid); 15281 }, 0)); 15282 } 15283 }; 15284 15285 function setDataInputToArray(row, propOrCol, value) { 15286 if ((typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') { 15287 // is it an array of changes 15288 return row; 15289 } 15290 return [[row, propOrCol, value]]; 15291 } 15292 15293 /** 15294 * @description 15295 * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, col, value], ...]` as 15296 * the only parameter. `col` is the index of a __visible__ column (note that if columns were reordered, 15297 * the current visible order will be used). `source` is a flag for before/afterChange events. If you pass only array of 15298 * changes then `source` could be set as second parameter. 15299 * 15300 * @memberof Core# 15301 * @function setDataAtCell 15302 * @param {Number|Array} row Visual row index or array of changes in format `[[row, col, value], ...]`. 15303 * @param {Number} col Visual column index. 15304 * @param {String} value New value. 15305 * @param {String} [source] String that identifies how this change will be described in the changes array (useful in onAfterChange or onBeforeChange callback). 15306 */ 15307 this.setDataAtCell = function (row, col, value, source) { 15308 var input = setDataInputToArray(row, col, value), 15309 i, 15310 ilen, 15311 changes = [], 15312 prop; 15313 15314 for (i = 0, ilen = input.length; i < ilen; i++) { 15315 if (_typeof(input[i]) !== 'object') { 15316 throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter'); 15317 } 15318 if (typeof input[i][1] !== 'number') { 15319 throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`'); 15320 } 15321 prop = datamap.colToProp(input[i][1]); 15322 changes.push([input[i][0], prop, dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]); 15323 } 15324 15325 if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') { 15326 source = col; 15327 } 15328 15329 instance.runHooks('afterSetDataAtCell', changes, source); 15330 15331 validateChanges(changes, source, function () { 15332 applyChanges(changes, source); 15333 }); 15334 }; 15335 15336 /** 15337 * @description 15338 * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, prop, value], ...]` as 15339 * the only parameter. `prop` is the name of the object property (e.g. `first.name`). `source` is a flag for before/afterChange events. 15340 * If you pass only array of changes then `source` could be set as second parameter. 15341 * 15342 * @memberof Core# 15343 * @function setDataAtRowProp 15344 * @param {Number|Array} row Visual row index or array of changes in format `[[row, prop, value], ...]`. 15345 * @param {String} prop Property name or the source string. 15346 * @param {String} value Value to be set. 15347 * @param {String} [source] String that identifies how this change will be described in changes array (useful in onChange callback). 15348 */ 15349 this.setDataAtRowProp = function (row, prop, value, source) { 15350 var input = setDataInputToArray(row, prop, value), 15351 i, 15352 ilen, 15353 changes = []; 15354 15355 for (i = 0, ilen = input.length; i < ilen; i++) { 15356 changes.push([input[i][0], input[i][1], dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]); 15357 } 15358 15359 if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') { 15360 source = prop; 15361 } 15362 15363 instance.runHooks('afterSetDataAtRowProp', changes, source); 15364 15365 validateChanges(changes, source, function () { 15366 applyChanges(changes, source); 15367 }); 15368 }; 15369 15370 /** 15371 * Listen to the keyboard input on document body. 15372 * 15373 * @memberof Core# 15374 * @function listen 15375 * @since 0.11 15376 */ 15377 this.listen = function () { 15378 var invalidActiveElement = !document.activeElement || document.activeElement && document.activeElement.nodeName === void 0; 15379 15380 if (document.activeElement && document.activeElement !== document.body && !invalidActiveElement) { 15381 document.activeElement.blur(); 15382 } else if (invalidActiveElement) { 15383 // IE 15384 document.body.focus(); 15385 } 15386 15387 activeGuid = instance.guid; 15388 }; 15389 15390 /** 15391 * Stop listening to keyboard input on the document body. 15392 * 15393 * @memberof Core# 15394 * @function unlisten 15395 * @since 0.11 15396 */ 15397 this.unlisten = function () { 15398 if (this.isListening()) { 15399 activeGuid = null; 15400 } 15401 }; 15402 15403 /** 15404 * Returns `true` if the current Handsontable instance is listening to keyboard input on document body. 15405 * 15406 * @memberof Core# 15407 * @function isListening 15408 * @since 0.11 15409 * @returns {Boolean} `true` if the instance is listening, `false` otherwise. 15410 */ 15411 this.isListening = function () { 15412 return activeGuid === instance.guid; 15413 }; 15414 15415 /** 15416 * Destroys the current editor, renders and selects the current cell. 15417 * 15418 * @memberof Core# 15419 * @function destroyEditor 15420 * @param {Boolean} [revertOriginal] If != `true`, edited data is saved. Otherwise the previous value is restored. 15421 */ 15422 this.destroyEditor = function (revertOriginal) { 15423 selection.refreshBorders(revertOriginal); 15424 }; 15425 15426 /** 15427 * Populate cells at position with 2D input array (e.g. `[[1, 2], [3, 4]]`). 15428 * Use `endRow`, `endCol` when you want to cut input when a certain row is reached. 15429 * Optional `source` parameter (default value "populateFromArray") is used to identify this call in the resulting events (beforeChange, afterChange). 15430 * Optional `populateMethod` parameter (default value "overwrite", possible values "shift_down" and "shift_right") 15431 * has the same effect as pasteMode option {@link Options#pasteMode} 15432 * 15433 * @memberof Core# 15434 * @function populateFromArray 15435 * @since 0.9.0 15436 * @param {Number} row Start visual row index. 15437 * @param {Number} col Start visual column index. 15438 * @param {Array} input 2d array 15439 * @param {Number} [endRow] End visual row index (use when you want to cut input when certain row is reached). 15440 * @param {Number} [endCol] End visual column index (use when you want to cut input when certain column is reached). 15441 * @param {String} [source="populateFromArray"] Source string. 15442 * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`. 15443 * @param {String} direction Populate direction. (left|right|up|down) 15444 * @param {Array} deltas Deltas array. 15445 * @returns {Object|undefined} The ending TD element in pasted area (only if any cells were changed). 15446 */ 15447 this.populateFromArray = function (row, col, input, endRow, endCol, source, method, direction, deltas) { 15448 var c; 15449 15450 if (!((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && _typeof(input[0]) === 'object')) { 15451 throw new Error('populateFromArray parameter `input` must be an array of arrays'); // API changed in 0.9-beta2, let's check if you use it correctly 15452 } 15453 c = typeof endRow === 'number' ? new _src.CellCoords(endRow, endCol) : null; 15454 15455 return grid.populateFromArray(new _src.CellCoords(row, col), input, c, source, method, direction, deltas); 15456 }; 15457 15458 /** 15459 * Adds/removes data from the column. This function is modelled after Array.splice. 15460 * Parameter `col` is the index of the column in which do you want to do splice. 15461 * Parameter `index` is the row index at which to start changing the array. 15462 * If negative, will begin that many elements from the end. Parameter `amount`, is the number of the old array elements to remove. 15463 * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array. 15464 * If you don't specify any elements, spliceCol simply removes elements from the array. 15465 * {@link DataMap#spliceCol} 15466 * 15467 * @memberof Core# 15468 * @function spliceCol 15469 * @since 0.9-beta2 15470 * @param {Number} col Index of the column in which do you want to do splice. 15471 * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end. 15472 * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed. 15473 * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array. 15474 */ 15475 this.spliceCol = function (col, index, amount /* , elements... */) { 15476 var _datamap; 15477 15478 return (_datamap = datamap).spliceCol.apply(_datamap, arguments); 15479 }; 15480 15481 /** 15482 * Adds/removes data from the row. This function works is modelled after Array.splice. 15483 * Parameter `row` is the index of row in which do you want to do splice. 15484 * Parameter `index` is the column index at which to start changing the array. 15485 * If negative, will begin that many elements from the end. Parameter `amount`, is the number of old array elements to remove. 15486 * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array. 15487 * If you don't specify any elements, spliceCol simply removes elements from the array. 15488 * {@link DataMap#spliceRow} 15489 * 15490 * @memberof Core# 15491 * @function spliceRow 15492 * @since 0.11 15493 * @param {Number} row Index of column in which do you want to do splice. 15494 * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end. 15495 * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed. 15496 * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array. 15497 */ 15498 this.spliceRow = function (row, index, amount /* , elements... */) { 15499 var _datamap2; 15500 15501 return (_datamap2 = datamap).spliceRow.apply(_datamap2, arguments); 15502 }; 15503 15504 /** 15505 * Returns indexes of the currently selected cells as an array `[startRow, startCol, endRow, endCol]`. 15506 * 15507 * Start row and start col are the coordinates of the active cell (where the selection was started). 15508 * 15509 * @memberof Core# 15510 * @function getSelected 15511 * @returns {Array} Array of the selection's indexes. 15512 */ 15513 this.getSelected = function () { 15514 // https://github.com/handsontable/handsontable/issues/44 //cjl 15515 if (selection.isSelected()) { 15516 return [priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col]; 15517 } 15518 }; 15519 15520 /** 15521 * Returns the current selection as a CellRange object. 15522 * 15523 * @memberof Core# 15524 * @function getSelectedRange 15525 * @since 0.11 15526 * @returns {CellRange} Selected range object or undefined` if there is no selection. 15527 */ 15528 this.getSelectedRange = function () { 15529 // https://github.com/handsontable/handsontable/issues/44 //cjl 15530 if (selection.isSelected()) { 15531 return priv.selRange; 15532 } 15533 }; 15534 15535 /** 15536 * Rerender the table. 15537 * 15538 * @memberof Core# 15539 * @function render 15540 */ 15541 this.render = function () { 15542 if (instance.view) { 15543 instance.renderCall = true; 15544 instance.forceFullRender = true; // used when data was changed 15545 selection.refreshBorders(null, true); 15546 } 15547 }; 15548 15549 /** 15550 * Reset all cells in the grid to contain data from the data array. 15551 * 15552 * @memberof Core# 15553 * @function loadData 15554 * @param {Array} data Array of arrays or array of objects containing data. 15555 * @fires Hooks#afterLoadData 15556 * @fires Hooks#afterChange 15557 */ 15558 this.loadData = function (data) { 15559 if (Array.isArray(priv.settings.dataSchema)) { 15560 instance.dataType = 'array'; 15561 } else if ((0, _function.isFunction)(priv.settings.dataSchema)) { 15562 instance.dataType = 'function'; 15563 } else { 15564 instance.dataType = 'object'; 15565 } 15566 15567 if (datamap) { 15568 datamap.destroy(); 15569 } 15570 datamap = new _dataMap2.default(instance, priv, GridSettings); 15571 15572 if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && data !== null) { 15573 if (!(data.push && data.splice)) { 15574 // check if data is array. Must use duck-type check so Backbone Collections also pass it 15575 // when data is not an array, attempt to make a single-row array of it 15576 data = [data]; 15577 } 15578 } else if (data === null) { 15579 data = []; 15580 var row; 15581 var r = 0; 15582 var rlen = 0; 15583 var dataSchema = datamap.getSchema(); 15584 15585 for (r = 0, rlen = priv.settings.startRows; r < rlen; r++) { 15586 if ((instance.dataType === 'object' || instance.dataType === 'function') && priv.settings.dataSchema) { 15587 row = (0, _object.deepClone)(dataSchema); 15588 data.push(row); 15589 } else if (instance.dataType === 'array') { 15590 row = (0, _object.deepClone)(dataSchema[0]); 15591 data.push(row); 15592 } else { 15593 row = []; 15594 15595 for (var c = 0, clen = priv.settings.startCols; c < clen; c++) { 15596 row.push(null); 15597 } 15598 15599 data.push(row); 15600 } 15601 } 15602 } else { 15603 throw new Error('loadData only accepts array of objects or array of arrays (' + (typeof data === 'undefined' ? 'undefined' : _typeof(data)) + ' given)'); 15604 } 15605 15606 priv.isPopulated = false; 15607 GridSettings.prototype.data = data; 15608 15609 if (Array.isArray(data[0])) { 15610 instance.dataType = 'array'; 15611 } 15612 15613 datamap.dataSource = data; 15614 dataSource.data = data; 15615 dataSource.dataType = instance.dataType; 15616 dataSource.colToProp = datamap.colToProp.bind(datamap); 15617 dataSource.propToCol = datamap.propToCol.bind(datamap); 15618 15619 clearCellSettingCache(); 15620 15621 grid.adjustRowsAndCols(); 15622 instance.runHooks('afterLoadData', priv.firstRun); 15623 15624 if (priv.firstRun) { 15625 priv.firstRun = [null, 'loadData']; 15626 } else { 15627 instance.runHooks('afterChange', null, 'loadData'); 15628 instance.render(); 15629 } 15630 priv.isPopulated = true; 15631 15632 function clearCellSettingCache() { 15633 priv.cellSettings.length = 0; 15634 } 15635 }; 15636 15637 /** 15638 * Returns the current data object (the same one that was passed by `data` configuration option or `loadData` method, 15639 * unless the `modifyRow` hook was used to trim some of the rows. If that's the case - use the {@link Core#getSourceData} method.). 15640 * Optionally you can provide cell range by defining `row`, `col`, `row2`, `col2` to get only a fragment of grid data. 15641 * 15642 * Note: getData functionality changed with the release of version 0.20. If you're looking for the previous functionality, 15643 * you should use the {@link Core#getSourceData} method. 15644 * 15645 * @memberof Core# 15646 * @function getData 15647 * @param {Number} [r] From visual row index. 15648 * @param {Number} [c] From visual column index. 15649 * @param {Number} [r2] To visual row index. 15650 * @param {Number} [c2] To visual column index. 15651 * @returns {Array} Array with the data. 15652 */ 15653 this.getData = function (r, c, r2, c2) { 15654 if ((0, _mixed.isUndefined)(r)) { 15655 return datamap.getAll(); 15656 } 15657 return datamap.getRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), datamap.DESTINATION_RENDERER); 15658 }; 15659 15660 /** 15661 * Returns a string value of the selected range. Each column is separated by tab, each row is separated by a new line character. 15662 * {@link DataMap#getCopyableText} 15663 * 15664 * @memberof Core# 15665 * @function getCopyableText 15666 * @since 0.11 15667 * @param {Number} startRow From visual row index. 15668 * @param {Number} startCol From visual column index. 15669 * @param {Number} endRow To visual row index. 15670 * @param {Number} endCol To visual column index. 15671 * @returns {String} 15672 */ 15673 this.getCopyableText = function (startRow, startCol, endRow, endCol) { 15674 return datamap.getCopyableText(new _src.CellCoords(startRow, startCol), new _src.CellCoords(endRow, endCol)); 15675 }; 15676 15677 /** 15678 * Returns the data's copyable value at specified row and column index ({@link DataMap#getCopyable}). 15679 * 15680 * @memberof Core# 15681 * @function getCopyableData 15682 * @since 0.19.0 15683 * @param {Number} row Visual row index. 15684 * @param {Number} column Visual column index. 15685 * @returns {String} 15686 */ 15687 this.getCopyableData = function (row, column) { 15688 return datamap.getCopyable(row, datamap.colToProp(column)); 15689 }; 15690 15691 /** 15692 * Returns schema provided by constructor settings. If it doesn't exist then it returns the schema based on the data 15693 * structure in the first row. 15694 * 15695 * @memberof Core# 15696 * @function getSchema 15697 * @since 0.13.2 15698 * @returns {Object} Schema object. 15699 */ 15700 this.getSchema = function () { 15701 return datamap.getSchema(); 15702 }; 15703 15704 /** 15705 * Use it if you need to change configuration after initialization. The `settings` parameter is an object containing the new 15706 * settings, declared the same way as in the initial settings object. 15707 * Note, that although the `updateSettings` method doesn't overwrite the previously declared settings, it might reset 15708 * the settings made post-initialization. (for example - ignore changes made using the columnResize feature). 15709 * 15710 * @memberof Core# 15711 * @function updateSettings 15712 * @param {Object} settings New settings object. 15713 * @param {Boolean} init Calls this method in the initialization mode. Internal use only. 15714 * Used by API could be cause of the unexpected behaviour of the Handsontable. 15715 * @example 15716 * ```js 15717 * hot.updateSettings({ 15718 * contextMenu: true, 15719 * colHeaders: true, 15720 * fixedRowsTop: 2 15721 * }); 15722 * ``` 15723 * @fires Hooks#afterCellMetaReset 15724 * @fires Hooks#afterUpdateSettings 15725 */ 15726 this.updateSettings = function (settings, init) { 15727 var columnsAsFunc = false; 15728 var i = void 0; 15729 var j = void 0; 15730 var clen = void 0; 15731 15732 if ((0, _mixed.isDefined)(settings.rows)) { 15733 throw new Error('"rows" setting is no longer supported. do you mean startRows, minRows or maxRows?'); 15734 } 15735 if ((0, _mixed.isDefined)(settings.cols)) { 15736 throw new Error('"cols" setting is no longer supported. do you mean startCols, minCols or maxCols?'); 15737 } 15738 15739 for (i in settings) { 15740 if (i === 'data') { 15741 /* eslint-disable no-continue */ 15742 continue; // loadData will be triggered later 15743 } else if (_pluginHooks2.default.getSingleton().getRegistered().indexOf(i) > -1) { 15744 if ((0, _function.isFunction)(settings[i]) || Array.isArray(settings[i])) { 15745 settings[i].initialHook = true; 15746 instance.addHook(i, settings[i]); 15747 } 15748 } else if (!init && (0, _object.hasOwnProperty)(settings, i)) { 15749 // Update settings 15750 GridSettings.prototype[i] = settings[i]; 15751 } 15752 } 15753 15754 // Load data or create data map 15755 if (settings.data === void 0 && priv.settings.data === void 0) { 15756 instance.loadData(null); // data source created just now 15757 } else if (settings.data !== void 0) { 15758 instance.loadData(settings.data); // data source given as option 15759 } else if (settings.columns !== void 0) { 15760 datamap.createMap(); 15761 } 15762 15763 clen = instance.countCols(); 15764 15765 var columnSetting = settings.columns || GridSettings.prototype.columns; 15766 15767 // Init columns constructors configuration 15768 if (columnSetting && (0, _function.isFunction)(columnSetting)) { 15769 clen = instance.countSourceCols(); 15770 columnsAsFunc = true; 15771 } 15772 15773 // Clear cellSettings cache 15774 if (settings.cell !== void 0 || settings.cells !== void 0 || settings.columns !== void 0) { 15775 priv.cellSettings.length = 0; 15776 } 15777 15778 if (clen > 0) { 15779 var proto = void 0; 15780 var column = void 0; 15781 15782 for (i = 0, j = 0; i < clen; i++) { 15783 if (columnsAsFunc && !columnSetting(i)) { 15784 /* eslint-disable no-continue */ 15785 continue; 15786 } 15787 priv.columnSettings[j] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts); 15788 15789 // shortcut for prototype 15790 proto = priv.columnSettings[j].prototype; 15791 15792 // Use settings provided by user 15793 if (columnSetting) { 15794 if (columnsAsFunc) { 15795 column = columnSetting(i); 15796 } else { 15797 column = columnSetting[j]; 15798 } 15799 15800 if (column) { 15801 (0, _object.extend)(proto, column); 15802 (0, _object.extend)(proto, expandType(column)); 15803 } 15804 } 15805 15806 j++; 15807 } 15808 } 15809 15810 if ((0, _mixed.isDefined)(settings.cell)) { 15811 for (var key in settings.cell) { 15812 if ((0, _object.hasOwnProperty)(settings.cell, key)) { 15813 var cell = settings.cell[key]; 15814 15815 instance.setCellMetaObject(cell.row, cell.col, cell); 15816 } 15817 } 15818 } 15819 15820 instance.runHooks('afterCellMetaReset'); 15821 15822 if ((0, _mixed.isDefined)(settings.className)) { 15823 if (GridSettings.prototype.className) { 15824 (0, _element.removeClass)(instance.rootElement, GridSettings.prototype.className); 15825 } 15826 if (settings.className) { 15827 (0, _element.addClass)(instance.rootElement, settings.className); 15828 } 15829 } 15830 15831 var currentHeight = instance.rootElement.style.height; 15832 if (currentHeight !== '') { 15833 currentHeight = parseInt(instance.rootElement.style.height, 10); 15834 } 15835 15836 var height = settings.height; 15837 if ((0, _function.isFunction)(height)) { 15838 height = height(); 15839 } 15840 15841 if (init) { 15842 var initialStyle = instance.rootElement.getAttribute('style'); 15843 15844 if (initialStyle) { 15845 instance.rootElement.setAttribute('data-initialstyle', instance.rootElement.getAttribute('style')); 15846 } 15847 } 15848 15849 if (height === null) { 15850 var _initialStyle = instance.rootElement.getAttribute('data-initialstyle'); 15851 15852 if (_initialStyle && (_initialStyle.indexOf('height') > -1 || _initialStyle.indexOf('overflow') > -1)) { 15853 instance.rootElement.setAttribute('style', _initialStyle); 15854 } else { 15855 instance.rootElement.style.height = ''; 15856 instance.rootElement.style.overflow = ''; 15857 } 15858 } else if (height !== void 0) { 15859 instance.rootElement.style.height = height + 'px'; 15860 instance.rootElement.style.overflow = 'hidden'; 15861 } 15862 15863 if (typeof settings.width !== 'undefined') { 15864 var width = settings.width; 15865 15866 if ((0, _function.isFunction)(width)) { 15867 width = width(); 15868 } 15869 15870 instance.rootElement.style.width = width + 'px'; 15871 } 15872 15873 if (!init) { 15874 datamap.clearLengthCache(); // force clear cache length on updateSettings() #3416 15875 15876 if (instance.view) { 15877 instance.view.wt.wtViewport.resetHasOversizedColumnHeadersMarked(); 15878 } 15879 15880 instance.runHooks('afterUpdateSettings', settings); 15881 } 15882 15883 grid.adjustRowsAndCols(); 15884 if (instance.view && !priv.firstRun) { 15885 instance.forceFullRender = true; // used when data was changed 15886 selection.refreshBorders(null, true); 15887 } 15888 15889 if (!init && instance.view && (currentHeight === '' || height === '' || height === void 0) && currentHeight !== height) { 15890 instance.view.wt.wtOverlays.updateMainScrollableElements(); 15891 } 15892 }; 15893 15894 /** 15895 * Get value from the selected cell. 15896 * 15897 * @memberof Core# 15898 * @function getValue 15899 * @since 0.11 15900 * @returns {*} Value of selected cell. 15901 */ 15902 this.getValue = function () { 15903 var sel = instance.getSelected(); 15904 if (GridSettings.prototype.getValue) { 15905 if ((0, _function.isFunction)(GridSettings.prototype.getValue)) { 15906 return GridSettings.prototype.getValue.call(instance); 15907 } else if (sel) { 15908 return instance.getData()[sel[0]][GridSettings.prototype.getValue]; 15909 } 15910 } else if (sel) { 15911 return instance.getDataAtCell(sel[0], sel[1]); 15912 } 15913 }; 15914 15915 function expandType(obj) { 15916 if (!(0, _object.hasOwnProperty)(obj, 'type')) { 15917 // ignore obj.prototype.type 15918 return; 15919 } 15920 15921 var type, 15922 expandedType = {}; 15923 15924 if (_typeof(obj.type) === 'object') { 15925 type = obj.type; 15926 } else if (typeof obj.type === 'string') { 15927 type = (0, _cellTypes.getCellType)(obj.type); 15928 } 15929 15930 for (var i in type) { 15931 if ((0, _object.hasOwnProperty)(type, i) && !(0, _object.hasOwnProperty)(obj, i)) { 15932 expandedType[i] = type[i]; 15933 } 15934 } 15935 15936 return expandedType; 15937 } 15938 15939 /** 15940 * Returns the object settings. 15941 * 15942 * @memberof Core# 15943 * @function getSettings 15944 * @returns {Object} Object containing the current grid settings. 15945 */ 15946 this.getSettings = function () { 15947 return priv.settings; 15948 }; 15949 15950 /** 15951 * Clears the data from the grid. (The table settings remain intact.) 15952 * 15953 * @memberof Core# 15954 * @function clear 15955 * @since 0.11 15956 */ 15957 this.clear = function () { 15958 selection.selectAll(); 15959 selection.empty(); 15960 }; 15961 15962 /** 15963 * @memberof Core# 15964 * @function alter 15965 * @param {String} action See grid.alter for possible values: `"insert_row"`, `"insert_col"`, `"remove_row"`, `"remove_col"` 15966 * @param {Number} index Visual index of the row/column before which the new row/column will be inserted/removed. 15967 * @param {Number} [amount = 1] Amound of rows/columns to be inserted/removed. 15968 * @param {String} [source] Source indicator. 15969 * @param {Boolean} [keepEmptyRows] Flag for preventing deletion of empty rows. 15970 * @description 15971 * 15972 * Allows altering the table structure by either inserting/removing rows or inserting/removing columns: 15973 * 15974 * Insert new row(s) above the row with a given `index`. If index is `null` or `undefined`, the new row will be 15975 * added after the last row. 15976 * ```js 15977 * var hot = new Handsontable(document.getElementById('example')); 15978 * hot.alter('insert_row', 10); 15979 * ``` 15980 * 15981 * Insert new column(s) before the column with a given `index`. If index is `null` or `undefined`, the new column 15982 * will be added after the last column. 15983 * ```js 15984 * var hot = new Handsontable(document.getElementById('example')); 15985 * hot.alter('insert_col', 10); 15986 * ``` 15987 * 15988 * Remove the row(s) at the given `index`. 15989 * ```js 15990 * var hot = new Handsontable(document.getElementById('example')); 15991 * hot.alter('remove_row', 10); 15992 * ``` 15993 * 15994 * Remove the column(s) at the given `index`. 15995 * ```js 15996 * var hot = new Handsontable(document.getElementById('example')); 15997 * hot.alter('remove_col', 10); 15998 * ``` 15999 */ 16000 this.alter = function (action, index, amount, source, keepEmptyRows) { 16001 grid.alter(action, index, amount, source, keepEmptyRows); 16002 }; 16003 16004 /** 16005 * Returns a TD element for the given `row` and `col` arguments, if it is rendered on screen. 16006 * Returns `null` if the TD is not rendered on screen (probably because that part of the table is not visible). 16007 * 16008 * @memberof Core# 16009 * @function getCell 16010 * @param {Number} row Visual row index. 16011 * @param {Number} col Visual column index. 16012 * @param {Boolean} topmost If set to true, it returns the TD element from the topmost overlay. For example, 16013 * if the wanted cell is in the range of fixed rows, it will return a TD element from the `top` overlay. 16014 * @returns {Element} The cell's TD element. 16015 */ 16016 this.getCell = function (row, col, topmost) { 16017 return instance.view.getCellAtCoords(new _src.CellCoords(row, col), topmost); 16018 }; 16019 16020 /** 16021 * Returns the coordinates of the cell, provided as a HTML Element. 16022 * 16023 * @memberof Core# 16024 * @function getCoords 16025 * @param {Element} elem The HTML Element representing the cell. 16026 * @returns {CellCoords} Visual coordinates object. 16027 */ 16028 this.getCoords = function (elem) { 16029 return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem); 16030 }; 16031 16032 /** 16033 * Returns the property name that corresponds with the given column index. {@link DataMap#colToProp} 16034 * If the data source is an array of arrays, it returns the columns index. 16035 * 16036 * @memberof Core# 16037 * @function colToProp 16038 * @param {Number} col Visual column index. 16039 * @returns {String|Number} Column property or physical column index. 16040 */ 16041 this.colToProp = function (col) { 16042 return datamap.colToProp(col); 16043 }; 16044 16045 /** 16046 * Returns column index that corresponds with the given property. {@link DataMap#propToCol} 16047 * 16048 * @memberof Core# 16049 * @function propToCol 16050 * @param {String|Number} prop Property name or physical column index. 16051 * @returns {Number} Visual column index. 16052 */ 16053 this.propToCol = function (prop) { 16054 return datamap.propToCol(prop); 16055 }; 16056 16057 /** 16058 * Translate physical row index into visual. 16059 * 16060 * @since 0.29.0 16061 * @memberof Core# 16062 * @function toVisualRow 16063 * @param {Number} row Physical row index. 16064 * @returns {Number} Returns visual row index. 16065 */ 16066 this.toVisualRow = function (row) { 16067 return recordTranslator.toVisualRow(row); 16068 }; 16069 16070 /** 16071 * Translate physical column index into visual. 16072 * 16073 * @since 0.29.0 16074 * @memberof Core# 16075 * @function toVisualColumn 16076 * @param {Number} column Physical column index. 16077 * @returns {Number} Returns visual column index. 16078 */ 16079 this.toVisualColumn = function (column) { 16080 return recordTranslator.toVisualColumn(column); 16081 }; 16082 16083 /** 16084 * Translate visual row index into physical. 16085 * If displayed rows order is different than the order of rows stored in memory (i.e. sorting is applied) 16086 * to retrieve valid physical row index you can use this method. 16087 * 16088 * @since 0.29.0 16089 * @memberof Core# 16090 * @function toPhysicalRow 16091 * @param {Number} row Visual row index. 16092 * @returns {Number} Returns physical row index. 16093 */ 16094 this.toPhysicalRow = function (row) { 16095 return recordTranslator.toPhysicalRow(row); 16096 }; 16097 16098 /** 16099 * Translate visual column index into physical. 16100 * If displayed columns order is different than the order of columns stored in memory (i.e. manual column move is applied) 16101 * to retrieve valid physical column index you can use this method. 16102 * 16103 * @since 0.29.0 16104 * @memberof Core# 16105 * @function toPhysicalColumn 16106 * @param {Number} column Visual column index. 16107 * @returns {Number} Returns physical column index. 16108 */ 16109 this.toPhysicalColumn = function (column) { 16110 return recordTranslator.toPhysicalColumn(column); 16111 }; 16112 16113 /** 16114 * @description 16115 * Returns the cell value at `row`, `col`. `row` and `col` are the __visible__ indexes (note, that if columns were reordered or sorted, 16116 * the currently visible order will be used). 16117 * 16118 * @memberof Core# 16119 * @function getDataAtCell 16120 * @param {Number} row Visual row index. 16121 * @param {Number} col Visual column index. 16122 * @returns {String|Boolean|null} Data at cell. 16123 */ 16124 this.getDataAtCell = function (row, col) { 16125 return datamap.get(row, datamap.colToProp(col)); 16126 }; 16127 16128 /** 16129 * Return value at `row`, `prop`. (Uses {@link DataMap#get}) 16130 * 16131 * @memberof Core# 16132 * @function getDataAtRowProp 16133 * @param {Number} row Visual row index. 16134 * @param {String} prop Property name. 16135 * @returns {*} Cell value. 16136 */ 16137 this.getDataAtRowProp = function (row, prop) { 16138 return datamap.get(row, prop); 16139 }; 16140 16141 /** 16142 * @description 16143 * Returns array of column values from the data source. `col` is the __visible__ index of the column. 16144 * Note, that if columns were reordered or sorted, the currently visible order will be used. 16145 * 16146 * @memberof Core# 16147 * @function getDataAtCol 16148 * @since 0.9-beta2 16149 * @param {Number} col Visual column index. 16150 * @returns {Array} Array of cell values. 16151 */ 16152 this.getDataAtCol = function (col) { 16153 var out = []; 16154 return out.concat.apply(out, _toConsumableArray(datamap.getRange(new _src.CellCoords(0, col), new _src.CellCoords(priv.settings.data.length - 1, col), datamap.DESTINATION_RENDERER))); 16155 }; 16156 16157 /** 16158 * Given the object property name (e.g. `'first.name'`), returns an array of column's values from the data source. 16159 * You can also provide a column index as the first argument. 16160 * 16161 * @memberof Core# 16162 * @function getDataAtProp 16163 * @since 0.9-beta2 16164 * @param {String|Number} prop Property name / physical column index. 16165 * @returns {Array} Array of cell values. 16166 */ 16167 // TODO: Getting data from `datamap` should work on visual indexes. 16168 this.getDataAtProp = function (prop) { 16169 var out = [], 16170 range; 16171 16172 range = datamap.getRange(new _src.CellCoords(0, datamap.propToCol(prop)), new _src.CellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER); 16173 16174 return out.concat.apply(out, _toConsumableArray(range)); 16175 }; 16176 16177 /** 16178 * Returns the source data object (the same that was passed by `data` configuration option or `loadData` method). 16179 * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data. 16180 * 16181 * @memberof Core# 16182 * @function getSourceData 16183 * @since 0.20.0 16184 * @param {Number} [r] From physical row index. 16185 * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects). 16186 * @param {Number} [r2] To physical row index. 16187 * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects). 16188 * @returns {Array} Array of grid data. 16189 */ 16190 this.getSourceData = function (r, c, r2, c2) { 16191 var data = void 0; 16192 16193 if (r === void 0) { 16194 data = dataSource.getData(); 16195 } else { 16196 data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2)); 16197 } 16198 16199 return data; 16200 }; 16201 16202 /** 16203 * Returns the source data object as an arrays of arrays format even when source data was provided in another format. 16204 * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data. 16205 * 16206 * @memberof Core# 16207 * @function getSourceDataArray 16208 * @since 0.28.0 16209 * @param {Number} [r] From physical row index. 16210 * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects). 16211 * @param {Number} [r2] To physical row index. 16212 * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects). 16213 * @returns {Array} An array of arrays. 16214 */ 16215 this.getSourceDataArray = function (r, c, r2, c2) { 16216 var data = void 0; 16217 16218 if (r === void 0) { 16219 data = dataSource.getData(true); 16220 } else { 16221 data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), true); 16222 } 16223 16224 return data; 16225 }; 16226 16227 /** 16228 * Returns an array of column values from the data source. `col` is the index of the row in the data source. 16229 * 16230 * @memberof Core# 16231 * @function getSourceDataAtCol 16232 * @since 0.11.0-beta3 16233 * @param {Number} column Visual column index. 16234 * @returns {Array} Array of the column's cell values. 16235 */ 16236 // TODO: Getting data from `sourceData` should work always on physical indexes. 16237 this.getSourceDataAtCol = function (column) { 16238 return dataSource.getAtColumn(column); 16239 }; 16240 16241 /** 16242 * Returns a single row of the data (array or object, depending on what you have). `row` is the index of the row in the data source. 16243 * 16244 * @memberof Core# 16245 * @function getSourceDataAtRow 16246 * @since 0.11.0-beta3 16247 * @param {Number} row Physical row index. 16248 * @returns {Array|Object} Single row of data. 16249 */ 16250 this.getSourceDataAtRow = function (row) { 16251 return dataSource.getAtRow(row); 16252 }; 16253 16254 /** 16255 * Returns a single value from the data source. 16256 * 16257 * @memberof Core# 16258 * @function getSourceDataAtCell 16259 * @param {Number} row Physical row index. 16260 * @param {Number} column Visual column index. 16261 * @returns {*} Cell data. 16262 * @since 0.20.0 16263 */ 16264 // TODO: Getting data from `sourceData` should work always on physical indexes. 16265 this.getSourceDataAtCell = function (row, column) { 16266 return dataSource.getAtCell(row, column); 16267 }; 16268 16269 /** 16270 * @description 16271 * Returns a single row of the data. The `row` argument is the __visible__ index of the row. 16272 * 16273 * @memberof Core# 16274 * @function getDataAtRow 16275 * @param {Number} row Visual row index. 16276 * @returns {Array} Array of row's cell data. 16277 * @since 0.9-beta2 16278 */ 16279 this.getDataAtRow = function (row) { 16280 var data = datamap.getRange(new _src.CellCoords(row, 0), new _src.CellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER); 16281 16282 return data[0] || []; 16283 }; 16284 16285 /** 16286 * @description 16287 * Returns a data type defined in the Handsontable settings under the `type` key ([Options#type](http://docs.handsontable.com/Options.html#type)). 16288 * If there are cells with different types in the selected range, it returns `'mixed'`. 16289 * 16290 * @since 0.18.1 16291 * @memberof Core# 16292 * @function getDataType 16293 * @param {Number} rowFrom From visual row index. 16294 * @param {Number} columnFrom From visual column index. 16295 * @param {Number} rowTo To visual row index. 16296 * @param {Number} columnTo To visual column index. 16297 * @returns {String} Cell type (e.q: `'mixed'`, `'text'`, `'numeric'`, `'autocomplete'`). 16298 */ 16299 this.getDataType = function (rowFrom, columnFrom, rowTo, columnTo) { 16300 var _this = this; 16301 16302 var previousType = null; 16303 var currentType = null; 16304 16305 if (rowFrom === void 0) { 16306 rowFrom = 0; 16307 rowTo = this.countRows(); 16308 columnFrom = 0; 16309 columnTo = this.countCols(); 16310 } 16311 if (rowTo === void 0) { 16312 rowTo = rowFrom; 16313 } 16314 if (columnTo === void 0) { 16315 columnTo = columnFrom; 16316 } 16317 var type = 'mixed'; 16318 16319 (0, _number.rangeEach)(Math.min(rowFrom, rowTo), Math.max(rowFrom, rowTo), function (row) { 16320 var isTypeEqual = true; 16321 16322 (0, _number.rangeEach)(Math.min(columnFrom, columnTo), Math.max(columnFrom, columnTo), function (column) { 16323 var cellType = _this.getCellMeta(row, column); 16324 16325 currentType = cellType.type; 16326 16327 if (previousType) { 16328 isTypeEqual = previousType === currentType; 16329 } else { 16330 previousType = currentType; 16331 } 16332 16333 return isTypeEqual; 16334 }); 16335 type = isTypeEqual ? currentType : 'mixed'; 16336 16337 return isTypeEqual; 16338 }); 16339 16340 return type; 16341 }; 16342 16343 /** 16344 * Remove a property defined by the `key` argument from the cell meta object for the provided `row` and `col` coordinates. 16345 * 16346 * @memberof Core# 16347 * @function removeCellMeta 16348 * @param {Number} row Visual row index. 16349 * @param {Number} col Visual column index. 16350 * @param {String} key Property name. 16351 * @fires Hooks#beforeRemoveCellMeta 16352 * @fires Hooks#afterRemoveCellMeta 16353 */ 16354 this.removeCellMeta = function (row, col, key) { 16355 var _recordTranslator$toP = recordTranslator.toPhysical(row, col), 16356 _recordTranslator$toP2 = _slicedToArray(_recordTranslator$toP, 2), 16357 physicalRow = _recordTranslator$toP2[0], 16358 physicalColumn = _recordTranslator$toP2[1]; 16359 16360 var cachedValue = priv.cellSettings[physicalRow][physicalColumn][key]; 16361 16362 var hookResult = instance.runHooks('beforeRemoveCellMeta', row, col, key, cachedValue); 16363 16364 if (hookResult !== false) { 16365 delete priv.cellSettings[physicalRow][physicalColumn][key]; 16366 16367 instance.runHooks('afterRemoveCellMeta', row, col, key, cachedValue); 16368 } 16369 16370 cachedValue = null; 16371 }; 16372 16373 /** 16374 * Remove one or more rows from the cell meta object. 16375 * 16376 * @since 0.30.0 16377 * @param {Number} index An integer that specifies at what position to add/remove items, Use negative values to specify the position from the end of the array. 16378 * @param {Number} deleteAmount The number of items to be removed. If set to 0, no items will be removed. 16379 * @param {Array} items The new items to be added to the array. 16380 */ 16381 this.spliceCellsMeta = function (index, deleteAmount) { 16382 var _priv$cellSettings; 16383 16384 for (var _len2 = arguments.length, items = Array(_len2 > 2 ? _len2 - 2 : 0), _key = 2; _key < _len2; _key++) { 16385 items[_key - 2] = arguments[_key]; 16386 } 16387 16388 (_priv$cellSettings = priv.cellSettings).splice.apply(_priv$cellSettings, [index, deleteAmount].concat(items)); 16389 }; 16390 16391 /** 16392 * Set cell meta data object defined by `prop` to the corresponding params `row` and `col`. 16393 * 16394 * @memberof Core# 16395 * @function setCellMetaObject 16396 * @since 0.11 16397 * @param {Number} row Visual row index. 16398 * @param {Number} col Visual column index. 16399 * @param {Object} prop Meta object. 16400 */ 16401 this.setCellMetaObject = function (row, col, prop) { 16402 if ((typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object') { 16403 for (var key in prop) { 16404 if ((0, _object.hasOwnProperty)(prop, key)) { 16405 var value = prop[key]; 16406 this.setCellMeta(row, col, key, value); 16407 } 16408 } 16409 } 16410 }; 16411 16412 /** 16413 * Sets a property defined by the `key` object to the meta object of a cell corresponding to params `row` and `col`. 16414 * 16415 * @memberof Core# 16416 * @function setCellMeta 16417 * @since 0.11 16418 * @param {Number} row Visual row index. 16419 * @param {Number} col Visual column index. 16420 * @param {String} key Property name. 16421 * @param {String} val Property value. 16422 * @fires Hooks#afterSetCellMeta 16423 */ 16424 this.setCellMeta = function (row, col, key, val) { 16425 var _recordTranslator$toP3 = recordTranslator.toPhysical(row, col), 16426 _recordTranslator$toP4 = _slicedToArray(_recordTranslator$toP3, 2), 16427 physicalRow = _recordTranslator$toP4[0], 16428 physicalColumn = _recordTranslator$toP4[1]; 16429 16430 if (!priv.columnSettings[physicalColumn]) { 16431 priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts); 16432 } 16433 16434 if (!priv.cellSettings[physicalRow]) { 16435 priv.cellSettings[physicalRow] = []; 16436 } 16437 if (!priv.cellSettings[physicalRow][physicalColumn]) { 16438 priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn](); 16439 } 16440 priv.cellSettings[physicalRow][physicalColumn][key] = val; 16441 instance.runHooks('afterSetCellMeta', row, col, key, val); 16442 }; 16443 16444 /** 16445 * Get all the cells meta settings at least once generated in the table (in order of cell initialization). 16446 * 16447 * @since 0.19.0 16448 * @returns {Array} Returns Array of ColumnSettings object. 16449 */ 16450 this.getCellsMeta = function () { 16451 return (0, _array.arrayFlatten)(priv.cellSettings); 16452 }; 16453 16454 /** 16455 * Returns the cell properties object for the given `row` and `col` coordinates. 16456 * 16457 * @memberof Core# 16458 * @function getCellMeta 16459 * @param {Number} row Visual row index. 16460 * @param {Number} col Visual column index. 16461 * @returns {Object} The cell properties object. 16462 * @fires Hooks#beforeGetCellMeta 16463 * @fires Hooks#afterGetCellMeta 16464 */ 16465 this.getCellMeta = function (row, col) { 16466 var prop = datamap.colToProp(col); 16467 var cellProperties = void 0; 16468 16469 var _recordTranslator$toP5 = recordTranslator.toPhysical(row, col), 16470 _recordTranslator$toP6 = _slicedToArray(_recordTranslator$toP5, 2), 16471 physicalRow = _recordTranslator$toP6[0], 16472 physicalColumn = _recordTranslator$toP6[1]; 16473 16474 if (!priv.columnSettings[physicalColumn]) { 16475 priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts); 16476 } 16477 16478 if (!priv.cellSettings[physicalRow]) { 16479 priv.cellSettings[physicalRow] = []; 16480 } 16481 if (!priv.cellSettings[physicalRow][physicalColumn]) { 16482 priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn](); 16483 } 16484 16485 cellProperties = priv.cellSettings[physicalRow][physicalColumn]; // retrieve cellProperties from cache 16486 16487 cellProperties.row = physicalRow; 16488 cellProperties.col = physicalColumn; 16489 cellProperties.visualRow = row; 16490 cellProperties.visualCol = col; 16491 cellProperties.prop = prop; 16492 cellProperties.instance = instance; 16493 16494 instance.runHooks('beforeGetCellMeta', row, col, cellProperties); 16495 (0, _object.extend)(cellProperties, expandType(cellProperties)); // for `type` added in beforeGetCellMeta 16496 16497 if (cellProperties.cells) { 16498 var settings = cellProperties.cells.call(cellProperties, physicalRow, physicalColumn, prop); 16499 16500 if (settings) { 16501 (0, _object.extend)(cellProperties, settings); 16502 (0, _object.extend)(cellProperties, expandType(settings)); // for `type` added in cells 16503 } 16504 } 16505 16506 instance.runHooks('afterGetCellMeta', row, col, cellProperties); 16507 16508 return cellProperties; 16509 }; 16510 16511 /** 16512 * Returns a row off the cell meta array. 16513 * 16514 * @memberof Core# 16515 * @function getCellMetaAtRow 16516 * @since 0.30.0 16517 * @param {Number} row Physical index of the row to return cell meta for. 16518 * @returns {Array} 16519 */ 16520 this.getCellMetaAtRow = function (row) { 16521 return priv.cellSettings[row]; 16522 }; 16523 16524 /** 16525 * Checks if the data format and config allows user to modify the column structure. 16526 * @returns {boolean} 16527 */ 16528 this.isColumnModificationAllowed = function () { 16529 return !(instance.dataType === 'object' || instance.getSettings().columns); 16530 }; 16531 16532 var rendererLookup = (0, _data.cellMethodLookupFactory)('renderer'); 16533 16534 /** 16535 * Returns the cell renderer function by given `row` and `col` arguments. 16536 * 16537 * @memberof Core# 16538 * @function getCellRenderer 16539 * @since 0.11 16540 * @param {Number|Object} row Visual row index or cell meta object. 16541 * @param {Number} [col] Visual column index. 16542 * @returns {Function} The renderer function. 16543 */ 16544 this.getCellRenderer = function (row, col) { 16545 return (0, _renderers.getRenderer)(rendererLookup.call(this, row, col)); 16546 }; 16547 16548 /** 16549 * Returns the cell editor by the provided `row` and `col` arguments. 16550 * 16551 * @memberof Core# 16552 * @function getCellEditor 16553 * @param {Number} row Visual row index. 16554 * @param {Number} col Visual column index. 16555 * @returns {Object} The Editor object. 16556 */ 16557 this.getCellEditor = (0, _data.cellMethodLookupFactory)('editor'); 16558 16559 var validatorLookup = (0, _data.cellMethodLookupFactory)('validator'); 16560 16561 /** 16562 * Returns the cell validator by `row` and `col`, provided a validator is defined. If not - it doesn't return anything. 16563 * 16564 * @memberof Core# 16565 * @function getCellValidator 16566 * @param {Number} row Visual row index. 16567 * @param {Number} col Visual column index. 16568 * @returns {Function|RegExp|undefined} The validator function. 16569 */ 16570 this.getCellValidator = function (row, col) { 16571 var validator = validatorLookup.call(this, row, col); 16572 16573 if (typeof validator === 'string') { 16574 validator = (0, _validators.getValidator)(validator); 16575 } 16576 16577 return validator; 16578 }; 16579 16580 /** 16581 * Validates all cells using their validator functions and calls callback when finished. 16582 * 16583 * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`. 16584 * 16585 * @memberof Core# 16586 * @function validateCells 16587 * @param {Function} [callback] The callback function. 16588 */ 16589 this.validateCells = function (callback) { 16590 var waitingForValidator = new ValidatorsQueue(); 16591 16592 if (callback) { 16593 waitingForValidator.onQueueEmpty = callback; 16594 } 16595 16596 var i = instance.countRows() - 1; 16597 16598 while (i >= 0) { 16599 var j = instance.countCols() - 1; 16600 16601 while (j >= 0) { 16602 waitingForValidator.addValidatorToQueue(); 16603 16604 instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function (result) { 16605 if (typeof result !== 'boolean') { 16606 throw new Error('Validation error: result is not boolean'); 16607 } 16608 if (result === false) { 16609 waitingForValidator.valid = false; 16610 } 16611 waitingForValidator.removeValidatorFormQueue(); 16612 }, 'validateCells'); 16613 j--; 16614 } 16615 i--; 16616 } 16617 waitingForValidator.checkIfQueueIsEmpty(); 16618 }; 16619 16620 /** 16621 * Returns an array of row headers' values (if they are enabled). If param `row` was given, it returns the header of the given row as a string. 16622 * 16623 * @memberof Core# 16624 * @function getRowHeader 16625 * @param {Number} [row] Visual row index. 16626 * @fires Hooks#modifyRowHeader 16627 * @returns {Array|String} Array of header values / single header value. 16628 */ 16629 this.getRowHeader = function (row) { 16630 var rowHeader = priv.settings.rowHeaders; 16631 16632 if (row !== void 0) { 16633 row = instance.runHooks('modifyRowHeader', row); 16634 } 16635 if (row === void 0) { 16636 rowHeader = []; 16637 (0, _number.rangeEach)(instance.countRows() - 1, function (i) { 16638 rowHeader.push(instance.getRowHeader(i)); 16639 }); 16640 } else if (Array.isArray(rowHeader) && rowHeader[row] !== void 0) { 16641 rowHeader = rowHeader[row]; 16642 } else if ((0, _function.isFunction)(rowHeader)) { 16643 rowHeader = rowHeader(row); 16644 } else if (rowHeader && typeof rowHeader !== 'string' && typeof rowHeader !== 'number') { 16645 rowHeader = row + 1; 16646 } 16647 16648 return rowHeader; 16649 }; 16650 16651 /** 16652 * Returns information about if this table is configured to display row headers. 16653 * 16654 * @memberof Core# 16655 * @function hasRowHeaders 16656 * @returns {Boolean} `true` if the instance has the row headers enabled, `false` otherwise. 16657 * @since 0.11 16658 */ 16659 this.hasRowHeaders = function () { 16660 return !!priv.settings.rowHeaders; 16661 }; 16662 16663 /** 16664 * Returns information about if this table is configured to display column headers. 16665 * 16666 * @memberof Core# 16667 * @function hasColHeaders 16668 * @since 0.11 16669 * @returns {Boolean} `True` if the instance has the column headers enabled, `false` otherwise. 16670 */ 16671 this.hasColHeaders = function () { 16672 if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) { 16673 // Polymer has empty value = null 16674 return !!priv.settings.colHeaders; 16675 } 16676 for (var i = 0, ilen = instance.countCols(); i < ilen; i++) { 16677 if (instance.getColHeader(i)) { 16678 return true; 16679 } 16680 } 16681 16682 return false; 16683 }; 16684 16685 /** 16686 * Returns an array of column headers (in string format, if they are enabled). If param `col` is given, it returns the header at the given column as a string. 16687 * 16688 * @memberof Core# 16689 * @function getColHeader 16690 * @param {Number} [col] Visual column index. 16691 * @fires Hooks#modifyColHeader 16692 * @returns {Array|String} The column header(s). 16693 */ 16694 this.getColHeader = function (col) { 16695 var columnsAsFunc = priv.settings.columns && (0, _function.isFunction)(priv.settings.columns); 16696 var result = priv.settings.colHeaders; 16697 16698 col = instance.runHooks('modifyColHeader', col); 16699 16700 if (col === void 0) { 16701 var out = []; 16702 var ilen = columnsAsFunc ? instance.countSourceCols() : instance.countCols(); 16703 16704 for (var i = 0; i < ilen; i++) { 16705 out.push(instance.getColHeader(i)); 16706 } 16707 16708 result = out; 16709 } else { 16710 var translateVisualIndexToColumns = function translateVisualIndexToColumns(col) { 16711 var arr = []; 16712 var columnsLen = instance.countSourceCols(); 16713 var index = 0; 16714 16715 for (; index < columnsLen; index++) { 16716 if ((0, _function.isFunction)(instance.getSettings().columns) && instance.getSettings().columns(index)) { 16717 arr.push(index); 16718 } 16719 } 16720 16721 return arr[col]; 16722 }; 16723 var baseCol = col; 16724 col = instance.runHooks('modifyCol', col); 16725 16726 var prop = translateVisualIndexToColumns(col); 16727 16728 if (priv.settings.columns && (0, _function.isFunction)(priv.settings.columns) && priv.settings.columns(prop) && priv.settings.columns(prop).title) { 16729 result = priv.settings.columns(prop).title; 16730 } else if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) { 16731 result = priv.settings.columns[col].title; 16732 } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) { 16733 result = priv.settings.colHeaders[col]; 16734 } else if ((0, _function.isFunction)(priv.settings.colHeaders)) { 16735 result = priv.settings.colHeaders(col); 16736 } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') { 16737 result = (0, _data.spreadsheetColumnLabel)(baseCol); // see #1458 16738 } 16739 } 16740 16741 return result; 16742 }; 16743 16744 /** 16745 * Return column width from settings (no guessing). Private use intended. 16746 * 16747 * @private 16748 * @memberof Core# 16749 * @function _getColWidthFromSettings 16750 * @param {Number} col Visual col index. 16751 * @returns {Number} 16752 */ 16753 this._getColWidthFromSettings = function (col) { 16754 var cellProperties = instance.getCellMeta(0, col); 16755 var width = cellProperties.width; 16756 16757 if (width === void 0 || width === priv.settings.width) { 16758 width = cellProperties.colWidths; 16759 } 16760 if (width !== void 0 && width !== null) { 16761 switch (typeof width === 'undefined' ? 'undefined' : _typeof(width)) { 16762 case 'object': 16763 // array 16764 width = width[col]; 16765 break; 16766 16767 case 'function': 16768 width = width(col); 16769 break; 16770 default: 16771 break; 16772 } 16773 if (typeof width === 'string') { 16774 width = parseInt(width, 10); 16775 } 16776 } 16777 16778 return width; 16779 }; 16780 16781 /** 16782 * Returns the width of the requested column. 16783 * 16784 * @memberof Core# 16785 * @function getColWidth 16786 * @since 0.11 16787 * @param {Number} col Visual column index. 16788 * @returns {Number} Column width. 16789 * @fires Hooks#modifyColWidth 16790 */ 16791 this.getColWidth = function (col) { 16792 var width = instance._getColWidthFromSettings(col); 16793 16794 width = instance.runHooks('modifyColWidth', width, col); 16795 16796 if (width === void 0) { 16797 width = _src.ViewportColumnsCalculator.DEFAULT_WIDTH; 16798 } 16799 16800 return width; 16801 }; 16802 16803 /** 16804 * Return row height from settings (no guessing). Private use intended. 16805 * 16806 * @private 16807 * @memberof Core# 16808 * @function _getRowHeightFromSettings 16809 * @param {Number} row Visual row index. 16810 * @returns {Number} 16811 */ 16812 this._getRowHeightFromSettings = function (row) { 16813 // let cellProperties = instance.getCellMeta(row, 0); 16814 // let height = cellProperties.height; 16815 // 16816 // if (height === void 0 || height === priv.settings.height) { 16817 // height = cellProperties.rowHeights; 16818 // } 16819 var height = priv.settings.rowHeights; 16820 16821 if (height !== void 0 && height !== null) { 16822 switch (typeof height === 'undefined' ? 'undefined' : _typeof(height)) { 16823 case 'object': 16824 // array 16825 height = height[row]; 16826 break; 16827 16828 case 'function': 16829 height = height(row); 16830 break; 16831 default: 16832 break; 16833 } 16834 if (typeof height === 'string') { 16835 height = parseInt(height, 10); 16836 } 16837 } 16838 16839 return height; 16840 }; 16841 16842 /** 16843 * Returns the row height. 16844 * 16845 * @memberof Core# 16846 * @function getRowHeight 16847 * @since 0.11 16848 * @param {Number} row Visual row index. 16849 * @returns {Number} The given row's height. 16850 * @fires Hooks#modifyRowHeight 16851 */ 16852 this.getRowHeight = function (row) { 16853 var height = instance._getRowHeightFromSettings(row); 16854 16855 height = instance.runHooks('modifyRowHeight', height, row); 16856 16857 return height; 16858 }; 16859 16860 /** 16861 * Returns the total number of rows in the data source. 16862 * 16863 * @memberof Core# 16864 * @function countSourceRows 16865 * @since 0.20.0 16866 * @returns {Number} Total number in rows in data source. 16867 */ 16868 this.countSourceRows = function () { 16869 var sourceLength = instance.runHooks('modifySourceLength'); 16870 return sourceLength || (instance.getSourceData() ? instance.getSourceData().length : 0); 16871 }; 16872 16873 /** 16874 * Returns the total number of columns in the data source. 16875 * 16876 * @memberof Core# 16877 * @function countSourceCols 16878 * @since 0.26.1 16879 * @returns {Number} Total number in columns in data source. 16880 */ 16881 this.countSourceCols = function () { 16882 var len = 0; 16883 var obj = instance.getSourceData() && instance.getSourceData()[0] ? instance.getSourceData()[0] : []; 16884 16885 if ((0, _object.isObject)(obj)) { 16886 len = (0, _object.deepObjectSize)(obj); 16887 } else { 16888 len = obj.length || 0; 16889 } 16890 16891 return len; 16892 }; 16893 16894 /** 16895 * Returns the total number of rows in the grid. 16896 * 16897 * @memberof Core# 16898 * @function countRows 16899 * @returns {Number} Total number in rows the grid. 16900 */ 16901 this.countRows = function () { 16902 return datamap.getLength(); 16903 }; 16904 16905 /** 16906 * Returns the total number of columns in the grid. 16907 * 16908 * @memberof Core# 16909 * @function countCols 16910 * @returns {Number} Total number of columns. 16911 */ 16912 this.countCols = function () { 16913 var maxCols = this.getSettings().maxCols; 16914 var dataHasLength = false; 16915 var dataLen = 0; 16916 16917 if (instance.dataType === 'array') { 16918 dataHasLength = priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length; 16919 } 16920 16921 if (dataHasLength) { 16922 dataLen = priv.settings.data[0].length; 16923 } 16924 16925 if (priv.settings.columns) { 16926 var columnsIsFunction = (0, _function.isFunction)(priv.settings.columns); 16927 16928 if (columnsIsFunction) { 16929 if (instance.dataType === 'array') { 16930 var columnLen = 0; 16931 16932 for (var i = 0; i < dataLen; i++) { 16933 if (priv.settings.columns(i)) { 16934 columnLen++; 16935 } 16936 } 16937 16938 dataLen = columnLen; 16939 } else if (instance.dataType === 'object' || instance.dataType === 'function') { 16940 dataLen = datamap.colToPropCache.length; 16941 } 16942 } else { 16943 dataLen = priv.settings.columns.length; 16944 } 16945 } else if (instance.dataType === 'object' || instance.dataType === 'function') { 16946 dataLen = datamap.colToPropCache.length; 16947 } 16948 16949 return Math.min(maxCols, dataLen); 16950 }; 16951 16952 /** 16953 * Returns an visual index of the first rendered row. 16954 * 16955 * @memberof Core# 16956 * @function rowOffset 16957 * @returns {Number} Visual index of first rendered row. 16958 */ 16959 this.rowOffset = function () { 16960 return instance.view.wt.wtTable.getFirstRenderedRow(); 16961 }; 16962 16963 /** 16964 * Returns the visual index of the first rendered column. 16965 * 16966 * @memberof Core# 16967 * @function colOffset 16968 * @returns {Number} Visual index of the first visible column. 16969 */ 16970 this.colOffset = function () { 16971 return instance.view.wt.wtTable.getFirstRenderedColumn(); 16972 }; 16973 16974 /** 16975 * Returns the number of rendered rows (including rows partially or fully rendered outside viewport). 16976 * 16977 * @memberof Core# 16978 * @function countRenderedRows 16979 * @returns {Number} Returns -1 if table is not visible. 16980 */ 16981 this.countRenderedRows = function () { 16982 return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1; 16983 }; 16984 16985 /** 16986 * Returns the number of visible rows (rendered rows that fully fit inside viewport). 16987 * 16988 * @memberof Core# 16989 * @function countVisibleRows 16990 * @returns {Number} Number of visible rows or -1. 16991 */ 16992 this.countVisibleRows = function () { 16993 return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1; 16994 }; 16995 16996 /** 16997 * Returns the number of rendered columns (including columns partially or fully rendered outside viewport). 16998 * 16999 * @memberof Core# 17000 * @function countRenderedCols 17001 * @returns {Number} Returns -1 if table is not visible. 17002 */ 17003 this.countRenderedCols = function () { 17004 return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1; 17005 }; 17006 17007 /** 17008 * Returns the number of visible columns. Returns -1 if table is not visible 17009 * 17010 * @memberof Core# 17011 * @function countVisibleCols 17012 * @return {Number} Number of visible columns or -1. 17013 */ 17014 this.countVisibleCols = function () { 17015 return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1; 17016 }; 17017 17018 /** 17019 * Returns the number of empty rows. If the optional ending parameter is `true`, returns the 17020 * number of empty rows at the bottom of the table. 17021 * 17022 * @memberof Core# 17023 * @function countEmptyRows 17024 * @param {Boolean} [ending] If `true`, will only count empty rows at the end of the data source. 17025 * @returns {Number} Count empty rows 17026 * @fires Hooks#modifyRow 17027 */ 17028 this.countEmptyRows = function (ending) { 17029 var i = instance.countRows() - 1, 17030 empty = 0, 17031 row; 17032 17033 while (i >= 0) { 17034 row = instance.runHooks('modifyRow', i); 17035 17036 if (instance.isEmptyRow(row)) { 17037 empty++; 17038 } else if (ending) { 17039 break; 17040 } 17041 i--; 17042 } 17043 17044 return empty; 17045 }; 17046 17047 /** 17048 * Returns the number of empty columns. If the optional ending parameter is `true`, returns the number of empty 17049 * columns at right hand edge of the table. 17050 * 17051 * @memberof Core# 17052 * @function countEmptyCols 17053 * @param {Boolean} [ending] If `true`, will only count empty columns at the end of the data source row. 17054 * @returns {Number} Count empty cols 17055 */ 17056 this.countEmptyCols = function (ending) { 17057 if (instance.countRows() < 1) { 17058 return 0; 17059 } 17060 var i = instance.countCols() - 1, 17061 empty = 0; 17062 17063 while (i >= 0) { 17064 if (instance.isEmptyCol(i)) { 17065 empty++; 17066 } else if (ending) { 17067 break; 17068 } 17069 i--; 17070 } 17071 17072 return empty; 17073 }; 17074 17075 /** 17076 * Check if all cells in the row declared by the `row` argument are empty. 17077 * 17078 * @memberof Core# 17079 * @function isEmptyRow 17080 * @param {Number} row Row index. 17081 * @returns {Boolean} `true` if the row at the given `row` is empty, `false` otherwise. 17082 */ 17083 this.isEmptyRow = function (row) { 17084 return priv.settings.isEmptyRow.call(instance, row); 17085 }; 17086 17087 /** 17088 * Check if all cells in the the column declared by the `col` argument are empty. 17089 * 17090 * @memberof Core# 17091 * @function isEmptyCol 17092 * @param {Number} col Column index. 17093 * @returns {Boolean} `true` if the column at the given `col` is empty, `false` otherwise. 17094 */ 17095 this.isEmptyCol = function (col) { 17096 return priv.settings.isEmptyCol.call(instance, col); 17097 }; 17098 17099 /** 17100 * Select cell specified by `row` and `col` values or a range of cells finishing at `endRow`, `endCol`. 17101 * By default, viewport will be scrolled to selection. 17102 * After the `selectCell` method had finished, the instance will be listening to keyboard input on the document. 17103 * 17104 * @memberof Core# 17105 * @function selectCell 17106 * @param {Number} row Visual row index. 17107 * @param {Number} col Visual column index. 17108 * @param {Number} [endRow] Visual end row index (if selecting a range). 17109 * @param {Number} [endCol] Visual end column index (if selecting a range). 17110 * @param {Boolean} [scrollToCell=true] If `true`, the viewport will be scrolled to the selection. 17111 * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself. 17112 * @returns {Boolean} `true` if selection was successful, `false` otherwise. 17113 */ 17114 this.selectCell = function (row, col, endRow, endCol, scrollToCell, changeListener) { 17115 var coords; 17116 17117 changeListener = (0, _mixed.isUndefined)(changeListener) || changeListener === true; 17118 17119 if (typeof row !== 'number' || row < 0 || row >= instance.countRows()) { 17120 return false; 17121 } 17122 if (typeof col !== 'number' || col < 0 || col >= instance.countCols()) { 17123 return false; 17124 } 17125 if ((0, _mixed.isDefined)(endRow)) { 17126 if (typeof endRow !== 'number' || endRow < 0 || endRow >= instance.countRows()) { 17127 return false; 17128 } 17129 if (typeof endCol !== 'number' || endCol < 0 || endCol >= instance.countCols()) { 17130 return false; 17131 } 17132 } 17133 coords = new _src.CellCoords(row, col); 17134 priv.selRange = new _src.CellRange(coords, coords, coords); 17135 17136 if (changeListener) { 17137 instance.listen(); 17138 } 17139 17140 if ((0, _mixed.isUndefined)(endRow)) { 17141 selection.setRangeEnd(priv.selRange.from, scrollToCell); 17142 } else { 17143 selection.setRangeEnd(new _src.CellCoords(endRow, endCol), scrollToCell); 17144 } 17145 instance.selection.finish(); 17146 17147 return true; 17148 }; 17149 17150 /** 17151 * Select the cell specified by the `row` and `prop` arguments, or a range finishing at `endRow`, `endProp`. 17152 * By default, viewport will be scrolled to selection. 17153 * 17154 * @memberof Core# 17155 * @function selectCellByProp 17156 * @param {Number} row Visual row index. 17157 * @param {String} prop Property name. 17158 * @param {Number} [endRow] visual end row index (if selecting a range). 17159 * @param {String} [endProp] End property name (if selecting a range). 17160 * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to the selection. 17161 * @returns {Boolean} `true` if selection was successful, `false` otherwise. 17162 */ 17163 this.selectCellByProp = function (row, prop, endRow, endProp, scrollToCell) { 17164 var _instance5; 17165 17166 arguments[1] = datamap.propToCol(arguments[1]); 17167 17168 if ((0, _mixed.isDefined)(arguments[3])) { 17169 arguments[3] = datamap.propToCol(arguments[3]); 17170 } 17171 17172 return (_instance5 = instance).selectCell.apply(_instance5, arguments); 17173 }; 17174 17175 /** 17176 * Deselects the current cell selection on grid. 17177 * 17178 * @memberof Core# 17179 * @function deselectCell 17180 */ 17181 this.deselectCell = function () { 17182 selection.deselect(); 17183 }; 17184 17185 /** 17186 * Scroll viewport to coords specified by the `row` and `column` arguments. 17187 * 17188 * @since 0.24.3 17189 * @memberof Core# 17190 * @function scrollViewportTo 17191 * @param {Number} [row] Visual row index. 17192 * @param {Number} [column] Visual column index. 17193 * @param {Boolean} [snapToBottom = false] If `true`, viewport is scrolled to show the cell on the bottom of the table. 17194 * @param {Boolean} [snapToRight = false] If `true`, viewport is scrolled to show the cell on the right side of the table. 17195 * @returns {Boolean} `true` if scroll was successful, `false` otherwise. 17196 */ 17197 this.scrollViewportTo = function (row, column) { 17198 var snapToBottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 17199 var snapToRight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 17200 17201 if (row !== void 0 && (row < 0 || row >= instance.countRows())) { 17202 return false; 17203 } 17204 if (column !== void 0 && (column < 0 || column >= instance.countCols())) { 17205 return false; 17206 } 17207 17208 var result = false; 17209 17210 if (row !== void 0 && column !== void 0) { 17211 instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom); 17212 instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight); 17213 17214 result = true; 17215 } 17216 if (typeof row === 'number' && typeof column !== 'number') { 17217 instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom); 17218 17219 result = true; 17220 } 17221 if (typeof column === 'number' && typeof row !== 'number') { 17222 instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight); 17223 17224 result = true; 17225 } 17226 17227 return result; 17228 }; 17229 17230 /** 17231 * Removes grid from the DOM. 17232 * 17233 * @memberof Core# 17234 * @function destroy 17235 * @fires Hooks#afterDestroy 17236 */ 17237 this.destroy = function () { 17238 17239 instance._clearTimeouts(); 17240 if (instance.view) { 17241 // in case HT is destroyed before initialization has finished 17242 instance.view.destroy(); 17243 } 17244 if (dataSource) { 17245 dataSource.destroy(); 17246 } 17247 dataSource = null; 17248 17249 var nextSibling = instance.rootElement.nextSibling; 17250 17251 if ((0, _rootInstance.isRootInstance)(instance) && nextSibling) { 17252 instance.rootElement.parentNode.removeChild(nextSibling); 17253 } 17254 (0, _element.empty)(instance.rootElement); 17255 eventManager.destroy(); 17256 17257 instance.runHooks('afterDestroy'); 17258 _pluginHooks2.default.getSingleton().destroy(instance); 17259 17260 for (var i in instance) { 17261 if ((0, _object.hasOwnProperty)(instance, i)) { 17262 // replace instance methods with post mortem 17263 if ((0, _function.isFunction)(instance[i])) { 17264 instance[i] = postMortem; 17265 } else if (i !== 'guid') { 17266 // replace instance properties with null (restores memory) 17267 // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests 17268 instance[i] = null; 17269 } 17270 } 17271 } 17272 17273 // replace private properties with null (restores memory) 17274 // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests 17275 if (datamap) { 17276 datamap.destroy(); 17277 } 17278 datamap = null; 17279 priv = null; 17280 grid = null; 17281 selection = null; 17282 editorManager = null; 17283 instance = null; 17284 GridSettings = null; 17285 }; 17286 17287 /** 17288 * Replacement for all methods after Handsotnable was destroyed. 17289 * 17290 * @private 17291 */ 17292 function postMortem() { 17293 throw new Error('This method cannot be called because this Handsontable instance has been destroyed'); 17294 } 17295 17296 /** 17297 * Returns the active editor object. 17298 * 17299 * @memberof Core# 17300 * @function getActiveEditor 17301 * @returns {Object} The active editor object. 17302 */ 17303 this.getActiveEditor = function () { 17304 return editorManager.getActiveEditor(); 17305 }; 17306 17307 /** 17308 * Returns plugin instance using the plugin name provided. 17309 * 17310 * @memberof Core# 17311 * @function getPlugin 17312 * @param {String} pluginName The plugin name. 17313 * @returns {*} The plugin instance. 17314 * @since 0.15.0 17315 */ 17316 this.getPlugin = function (pluginName) { 17317 return (0, _plugins.getPlugin)(this, pluginName); 17318 }; 17319 17320 /** 17321 * Returns the Handsontable instance. 17322 * 17323 * @memberof Core# 17324 * @function getInstance 17325 * @returns {Handsontable} The Handsontable instance. 17326 */ 17327 this.getInstance = function () { 17328 return instance; 17329 }; 17330 17331 /** 17332 * Adds listener to the specified hook name (only for this Handsontable instance). 17333 * 17334 * @memberof Core# 17335 * @function addHook 17336 * @see Hooks#add 17337 * @param {String} key Hook name. 17338 * @param {Function|Array} callback Function or array of Functions. 17339 * 17340 * @example 17341 * ```js 17342 * hot.addHook('beforeInit', myCallback); 17343 * ``` 17344 */ 17345 this.addHook = function (key, callback) { 17346 _pluginHooks2.default.getSingleton().add(key, callback, instance); 17347 }; 17348 17349 /** 17350 * Check if for a specified hook name there are added listeners (only for this Handsontable instance). 17351 * 17352 * @memberof Core# 17353 * @function hasHook 17354 * @see Hooks#has 17355 * @param {String} key Hook name 17356 * @return {Boolean} 17357 * 17358 * @example 17359 * ```js 17360 * var hasBeforeInitListeners = hot.hasHook('beforeInit'); 17361 * ``` 17362 */ 17363 this.hasHook = function (key) { 17364 return _pluginHooks2.default.getSingleton().has(key, instance); 17365 }; 17366 17367 /** 17368 * Adds listener to specified hook name (only for this Handsontable instance). 17369 * After the listener is triggered, it will be automatically removed. 17370 * 17371 * @memberof Core# 17372 * @function addHookOnce 17373 * @see Hooks#once 17374 * @param {String} key Hook name. 17375 * @param {Function|Array} callback Function or array of Functions. 17376 * 17377 * @example 17378 * ```js 17379 * hot.addHookOnce('beforeInit', myCallback); 17380 * ``` 17381 */ 17382 this.addHookOnce = function (key, callback) { 17383 _pluginHooks2.default.getSingleton().once(key, callback, instance); 17384 }; 17385 17386 /** 17387 * Removes the hook listener previously registered with {@link Core#addHook}. 17388 * 17389 * @memberof Core# 17390 * @function removeHook 17391 * @see Hooks#remove 17392 * @param {String} key Hook name. 17393 * @param {Function} callback Function which have been registered via {@link Core#addHook}. 17394 * 17395 * @example 17396 * ```js 17397 * hot.removeHook('beforeInit', myCallback); 17398 * ``` 17399 */ 17400 this.removeHook = function (key, callback) { 17401 _pluginHooks2.default.getSingleton().remove(key, callback, instance); 17402 }; 17403 17404 /** 17405 * Run the callbacks for the hook provided in the `key` argument using the parameters given in the other arguments. 17406 * 17407 * @memberof Core# 17408 * @function runHooks 17409 * @see Hooks#run 17410 * @param {String} key Hook name. 17411 * @param {*} [p1] Argument passed to the callback. 17412 * @param {*} [p2] Argument passed to the callback. 17413 * @param {*} [p3] Argument passed to the callback. 17414 * @param {*} [p4] Argument passed to the callback. 17415 * @param {*} [p5] Argument passed to the callback. 17416 * @param {*} [p6] Argument passed to the callback. 17417 * @returns {*} 17418 * 17419 * @example 17420 * ```js 17421 * hot.runHooks('beforeInit'); 17422 * ``` 17423 */ 17424 this.runHooks = function (key, p1, p2, p3, p4, p5, p6) { 17425 return _pluginHooks2.default.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6); 17426 }; 17427 17428 this.timeouts = []; 17429 17430 /** 17431 * Sets timeout. Purpose of this method is to clear all known timeouts when `destroy` method is called. 17432 * 17433 * @param {*} handle 17434 * @private 17435 */ 17436 this._registerTimeout = function (handle) { 17437 this.timeouts.push(handle); 17438 }; 17439 17440 /** 17441 * Clears all known timeouts. 17442 * 17443 * @private 17444 */ 17445 this._clearTimeouts = function () { 17446 for (var i = 0, ilen = this.timeouts.length; i < ilen; i++) { 17447 clearTimeout(this.timeouts[i]); 17448 } 17449 }; 17450 17451 /** 17452 * Handsontable version 17453 * 17454 * @type {String} 17455 */ 17456 // this.version = Handsontable.version; 17457 17458 _pluginHooks2.default.getSingleton().run(instance, 'construct'); 17459}; 17460 17461/***/ }), 17462/* 67 */ 17463/***/ (function(module, exports, __webpack_require__) { 17464 17465"use strict"; 17466 17467 17468exports.__esModule = true; 17469exports.spreadsheetColumnLabel = spreadsheetColumnLabel; 17470exports.spreadsheetColumnIndex = spreadsheetColumnIndex; 17471exports.createSpreadsheetData = createSpreadsheetData; 17472exports.createSpreadsheetObjectData = createSpreadsheetObjectData; 17473exports.createEmptySpreadsheetData = createEmptySpreadsheetData; 17474exports.translateRowsToColumns = translateRowsToColumns; 17475exports.cellMethodLookupFactory = cellMethodLookupFactory; 17476 17477var _cellTypes = __webpack_require__(65); 17478 17479var _object = __webpack_require__(3); 17480 17481var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; 17482var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length; 17483 17484/** 17485 * Generates spreadsheet-like column names: A, B, C, ..., Z, AA, AB, etc. 17486 * 17487 * @param {Number} index Column index. 17488 * @returns {String} 17489 */ 17490function spreadsheetColumnLabel(index) { 17491 var dividend = index + 1; 17492 var columnLabel = ''; 17493 var modulo = void 0; 17494 17495 while (dividend > 0) { 17496 modulo = (dividend - 1) % COLUMN_LABEL_BASE_LENGTH; 17497 columnLabel = String.fromCharCode(65 + modulo) + columnLabel; 17498 dividend = parseInt((dividend - modulo) / COLUMN_LABEL_BASE_LENGTH, 10); 17499 } 17500 17501 return columnLabel; 17502} 17503 17504/** 17505 * Generates spreadsheet-like column index from theirs labels: A, B, C ...., Z, AA, AB, etc. 17506 * 17507 * @param {String} label Column label. 17508 * @returns {Number} 17509 */ 17510function spreadsheetColumnIndex(label) { 17511 var result = 0; 17512 17513 if (label) { 17514 for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) { 17515 result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1); 17516 } 17517 } 17518 --result; 17519 17520 return result; 17521} 17522 17523/** 17524 * Creates 2D array of Excel-like values "A1", "A2", ... 17525 * 17526 * @param {Number} rows Number of rows to generate. 17527 * @param {Number} columns Number of columns to generate. 17528 * @returns {Array} 17529 */ 17530function createSpreadsheetData() { 17531 var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100; 17532 var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; 17533 17534 var _rows = [], 17535 i, 17536 j; 17537 17538 for (i = 0; i < rows; i++) { 17539 var row = []; 17540 17541 for (j = 0; j < columns; j++) { 17542 row.push(spreadsheetColumnLabel(j) + (i + 1)); 17543 } 17544 _rows.push(row); 17545 } 17546 17547 return _rows; 17548} 17549 17550/** 17551 * Creates 2D array of Excel-like values "A1", "A2", as an array of objects. 17552 * 17553 * @param {Number} rows Number of rows to generate. 17554 * @param {Number} colCount Number of columns to generate. 17555 * @returns {Array} 17556 */ 17557function createSpreadsheetObjectData() { 17558 var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100; 17559 var colCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; 17560 17561 var _rows = [], 17562 i, 17563 j; 17564 17565 for (i = 0; i < rows; i++) { 17566 var row = {}; 17567 17568 for (j = 0; j < colCount; j++) { 17569 row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1); 17570 } 17571 _rows.push(row); 17572 } 17573 17574 return _rows; 17575} 17576 17577/** 17578 * Generates an empty data object. 17579 * 17580 * @param {Number} rows Number of rows to generate. 17581 * @param {Number} columns Number of columns to generate 17582 * @returns {Array} 17583 */ 17584function createEmptySpreadsheetData(rows, columns) { 17585 var data = []; 17586 var row = void 0; 17587 17588 for (var i = 0; i < rows; i++) { 17589 row = []; 17590 for (var j = 0; j < columns; j++) { 17591 row.push(''); 17592 } 17593 data.push(row); 17594 } 17595 17596 return data; 17597} 17598 17599function translateRowsToColumns(input) { 17600 var i, 17601 ilen, 17602 j, 17603 jlen, 17604 output = [], 17605 olen = 0; 17606 17607 for (i = 0, ilen = input.length; i < ilen; i++) { 17608 for (j = 0, jlen = input[i].length; j < jlen; j++) { 17609 if (j == olen) { 17610 output.push([]); 17611 olen++; 17612 } 17613 output[j].push(input[i][j]); 17614 } 17615 } 17616 17617 return output; 17618} 17619 17620/** 17621 * Factory that produces a function for searching methods (or any properties) which could be defined directly in 17622 * table configuration or implicitly, within cell type definition. 17623 * 17624 * For example: renderer can be defined explicitly using "renderer" property in column configuration or it can be 17625 * defined implicitly using "type" property. 17626 * 17627 * Methods/properties defined explicitly always takes precedence over those defined through "type". 17628 * 17629 * If the method/property is not found in an object, searching is continued recursively through prototype chain, until 17630 * it reaches the Object.prototype. 17631 * 17632 * 17633 * @param methodName {String} name of the method/property to search (i.e. 'renderer', 'validator', 'copyable') 17634 * @param allowUndefined {Boolean} [optional] if false, the search is continued if methodName has not been found in cell "type" 17635 * @returns {Function} 17636 */ 17637function cellMethodLookupFactory(methodName, allowUndefined) { 17638 17639 allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined; 17640 17641 return function cellMethodLookup(row, col) { 17642 return function getMethodFromProperties(properties) { 17643 17644 if (!properties) { 17645 return; // method not found 17646 } else if ((0, _object.hasOwnProperty)(properties, methodName) && properties[methodName] !== void 0) { 17647 // check if it is own and is not empty 17648 return properties[methodName]; // method defined directly 17649 } else if ((0, _object.hasOwnProperty)(properties, 'type') && properties.type) { 17650 // check if it is own and is not empty 17651 var type; 17652 17653 if (typeof properties.type != 'string') { 17654 throw new Error('Cell type must be a string '); 17655 } 17656 type = (0, _cellTypes.getCellType)(properties.type); 17657 17658 if ((0, _object.hasOwnProperty)(type, methodName)) { 17659 return type[methodName]; // method defined in type. 17660 } else if (allowUndefined) { 17661 return; // method does not defined in type (eg. validator), returns undefined 17662 } 17663 } 17664 17665 return getMethodFromProperties(Object.getPrototypeOf(properties)); 17666 }(typeof row == 'number' ? this.getCellMeta(row, col) : row); 17667 }; 17668} 17669 17670/***/ }), 17671/* 68 */ 17672/***/ (function(module, exports, __webpack_require__) { 17673 17674"use strict"; 17675 17676 17677exports.__esModule = true; 17678exports.columnFactory = columnFactory; 17679 17680var _object = __webpack_require__(3); 17681 17682/* eslint-disable import/prefer-default-export */ 17683/** 17684 * Factory for columns constructors. 17685 * 17686 * @param {Object} GridSettings 17687 * @param {Array} conflictList 17688 * @return {Object} ColumnSettings 17689 */ 17690function columnFactory(GridSettings, conflictList) { 17691 function ColumnSettings() {}; 17692 17693 (0, _object.inherit)(ColumnSettings, GridSettings); 17694 17695 // Clear conflict settings 17696 for (var i = 0, len = conflictList.length; i < len; i++) { 17697 ColumnSettings.prototype[conflictList[i]] = void 0; 17698 } 17699 17700 return ColumnSettings; 17701} 17702 17703/***/ }), 17704/* 69 */ 17705/***/ (function(module, exports, __webpack_require__) { 17706 17707"use strict"; 17708 17709 17710exports.__esModule = true; 17711 17712var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 17713 17714var _element = __webpack_require__(0); 17715 17716var _array = __webpack_require__(2); 17717 17718function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 17719 17720/** 17721 * @class GhostTable 17722 * @util 17723 */ 17724var GhostTable = function () { 17725 function GhostTable(hotInstance) { 17726 _classCallCheck(this, GhostTable); 17727 17728 /** 17729 * Handsontable instance. 17730 * 17731 * @type {Core} 17732 */ 17733 this.hot = hotInstance; 17734 /** 17735 * Container element where every table will be injected. 17736 * 17737 * @type {HTMLElement|null} 17738 */ 17739 this.container = null; 17740 /** 17741 * Flag which determine is table was injected to DOM. 17742 * 17743 * @type {Boolean} 17744 */ 17745 this.injected = false; 17746 /** 17747 * Added rows collection. 17748 * 17749 * @type {Array} 17750 */ 17751 this.rows = []; 17752 /** 17753 * Added columns collection. 17754 * 17755 * @type {Array} 17756 */ 17757 this.columns = []; 17758 /** 17759 * Samples prepared for calculations. 17760 * 17761 * @type {Map} 17762 * @default {null} 17763 */ 17764 this.samples = null; 17765 /** 17766 * Ghost table settings. 17767 * 17768 * @type {Object} 17769 * @default {Object} 17770 */ 17771 this.settings = { 17772 useHeaders: true 17773 }; 17774 } 17775 17776 /** 17777 * Add row. 17778 * 17779 * @param {Number} row Row index. 17780 * @param {Map} samples Samples Map object. 17781 */ 17782 17783 17784 _createClass(GhostTable, [{ 17785 key: 'addRow', 17786 value: function addRow(row, samples) { 17787 if (this.columns.length) { 17788 throw new Error('Doesn\'t support multi-dimensional table'); 17789 } 17790 if (!this.rows.length) { 17791 this.container = this.createContainer(this.hot.rootElement.className); 17792 } 17793 var rowObject = { row: row }; 17794 this.rows.push(rowObject); 17795 17796 this.samples = samples; 17797 this.table = this.createTable(this.hot.table.className); 17798 this.table.colGroup.appendChild(this.createColGroupsCol()); 17799 this.table.tr.appendChild(this.createRow(row)); 17800 this.container.container.appendChild(this.table.fragment); 17801 17802 rowObject.table = this.table.table; 17803 } 17804 17805 /** 17806 * Add a row consisting of the column headers. 17807 */ 17808 17809 }, { 17810 key: 'addColumnHeadersRow', 17811 value: function addColumnHeadersRow(samples) { 17812 if (this.hot.getColHeader(0) != null) { 17813 var rowObject = { row: -1 }; 17814 this.rows.push(rowObject); 17815 17816 this.container = this.createContainer(this.hot.rootElement.className); 17817 17818 this.samples = samples; 17819 this.table = this.createTable(this.hot.table.className); 17820 this.table.colGroup.appendChild(this.createColGroupsCol()); 17821 this.table.tHead.appendChild(this.createColumnHeadersRow()); 17822 this.container.container.appendChild(this.table.fragment); 17823 17824 rowObject.table = this.table.table; 17825 } 17826 } 17827 17828 /** 17829 * Add column. 17830 * 17831 * @param {Number} column Column index. 17832 * @param {Map} samples Samples Map object. 17833 */ 17834 17835 }, { 17836 key: 'addColumn', 17837 value: function addColumn(column, samples) { 17838 if (this.rows.length) { 17839 throw new Error('Doesn\'t support multi-dimensional table'); 17840 } 17841 if (!this.columns.length) { 17842 this.container = this.createContainer(this.hot.rootElement.className); 17843 } 17844 var columnObject = { col: column }; 17845 this.columns.push(columnObject); 17846 17847 this.samples = samples; 17848 this.table = this.createTable(this.hot.table.className); 17849 17850 if (this.getSetting('useHeaders') && this.hot.getColHeader(column) !== null) { 17851 this.hot.view.appendColHeader(column, this.table.th); 17852 } 17853 this.table.tBody.appendChild(this.createCol(column)); 17854 this.container.container.appendChild(this.table.fragment); 17855 17856 columnObject.table = this.table.table; 17857 } 17858 17859 /** 17860 * Get calculated heights. 17861 * 17862 * @param {Function} callback Callback which will be fired for each calculated row. 17863 */ 17864 17865 }, { 17866 key: 'getHeights', 17867 value: function getHeights(callback) { 17868 if (!this.injected) { 17869 this.injectTable(); 17870 } 17871 (0, _array.arrayEach)(this.rows, function (row) { 17872 // -1 <- reduce border-top from table 17873 callback(row.row, (0, _element.outerHeight)(row.table) - 1); 17874 }); 17875 } 17876 17877 /** 17878 * Get calculated widths. 17879 * 17880 * @param {Function} callback Callback which will be fired for each calculated column. 17881 */ 17882 17883 }, { 17884 key: 'getWidths', 17885 value: function getWidths(callback) { 17886 if (!this.injected) { 17887 this.injectTable(); 17888 } 17889 (0, _array.arrayEach)(this.columns, function (column) { 17890 callback(column.col, (0, _element.outerWidth)(column.table)); 17891 }); 17892 } 17893 17894 /** 17895 * Set the Ghost Table settings to the provided object. 17896 * 17897 * @param {Object} settings New Ghost Table Settings 17898 */ 17899 17900 }, { 17901 key: 'setSettings', 17902 value: function setSettings(settings) { 17903 this.settings = settings; 17904 } 17905 17906 /** 17907 * Set a single setting of the Ghost Table. 17908 * 17909 * @param {String} name Setting name. 17910 * @param {*} value Setting value. 17911 */ 17912 17913 }, { 17914 key: 'setSetting', 17915 value: function setSetting(name, value) { 17916 if (!this.settings) { 17917 this.settings = {}; 17918 } 17919 17920 this.settings[name] = value; 17921 } 17922 17923 /** 17924 * Get the Ghost Table settings. 17925 * 17926 * @returns {Object|null} 17927 */ 17928 17929 }, { 17930 key: 'getSettings', 17931 value: function getSettings() { 17932 return this.settings; 17933 } 17934 17935 /** 17936 * Get a single Ghost Table setting. 17937 * 17938 * @param {String} name 17939 * @returns {Boolean|null} 17940 */ 17941 17942 }, { 17943 key: 'getSetting', 17944 value: function getSetting(name) { 17945 if (this.settings) { 17946 return this.settings[name]; 17947 } 17948 return null; 17949 } 17950 17951 /** 17952 * Create colgroup col elements. 17953 * 17954 * @returns {DocumentFragment} 17955 */ 17956 17957 }, { 17958 key: 'createColGroupsCol', 17959 value: function createColGroupsCol() { 17960 var _this = this; 17961 17962 var d = document; 17963 var fragment = d.createDocumentFragment(); 17964 17965 if (this.hot.hasRowHeaders()) { 17966 fragment.appendChild(this.createColElement(-1)); 17967 } 17968 17969 this.samples.forEach(function (sample) { 17970 (0, _array.arrayEach)(sample.strings, function (string) { 17971 fragment.appendChild(_this.createColElement(string.col)); 17972 }); 17973 }); 17974 17975 return fragment; 17976 } 17977 17978 /** 17979 * Create table row element. 17980 * 17981 * @param {Number} row Row index. 17982 * @returns {DocumentFragment} Returns created table row elements. 17983 */ 17984 17985 }, { 17986 key: 'createRow', 17987 value: function createRow(row) { 17988 var _this2 = this; 17989 17990 var d = document; 17991 var fragment = d.createDocumentFragment(); 17992 var th = d.createElement('th'); 17993 17994 if (this.hot.hasRowHeaders()) { 17995 this.hot.view.appendRowHeader(row, th); 17996 17997 fragment.appendChild(th); 17998 } 17999 18000 this.samples.forEach(function (sample) { 18001 (0, _array.arrayEach)(sample.strings, function (string) { 18002 var column = string.col; 18003 var cellProperties = _this2.hot.getCellMeta(row, column); 18004 18005 cellProperties.col = column; 18006 cellProperties.row = row; 18007 18008 var renderer = _this2.hot.getCellRenderer(cellProperties); 18009 var td = d.createElement('td'); 18010 18011 renderer(_this2.hot, td, row, column, _this2.hot.colToProp(column), string.value, cellProperties); 18012 fragment.appendChild(td); 18013 }); 18014 }); 18015 18016 return fragment; 18017 } 18018 }, { 18019 key: 'createColumnHeadersRow', 18020 value: function createColumnHeadersRow() { 18021 var _this3 = this; 18022 18023 var d = document; 18024 var fragment = d.createDocumentFragment(); 18025 18026 if (this.hot.hasRowHeaders()) { 18027 var th = d.createElement('th'); 18028 this.hot.view.appendColHeader(-1, th); 18029 fragment.appendChild(th); 18030 } 18031 18032 this.samples.forEach(function (sample) { 18033 (0, _array.arrayEach)(sample.strings, function (string) { 18034 var column = string.col; 18035 18036 var th = d.createElement('th'); 18037 18038 _this3.hot.view.appendColHeader(column, th); 18039 fragment.appendChild(th); 18040 }); 18041 }); 18042 18043 return fragment; 18044 } 18045 18046 /** 18047 * Create table column elements. 18048 * 18049 * @param {Number} column Column index. 18050 * @returns {DocumentFragment} Returns created column table column elements. 18051 */ 18052 18053 }, { 18054 key: 'createCol', 18055 value: function createCol(column) { 18056 var _this4 = this; 18057 18058 var d = document; 18059 var fragment = d.createDocumentFragment(); 18060 18061 this.samples.forEach(function (sample) { 18062 (0, _array.arrayEach)(sample.strings, function (string) { 18063 var row = string.row; 18064 var cellProperties = _this4.hot.getCellMeta(row, column); 18065 18066 cellProperties.col = column; 18067 cellProperties.row = row; 18068 18069 var renderer = _this4.hot.getCellRenderer(cellProperties); 18070 var td = d.createElement('td'); 18071 var tr = d.createElement('tr'); 18072 18073 renderer(_this4.hot, td, row, column, _this4.hot.colToProp(column), string.value, cellProperties); 18074 tr.appendChild(td); 18075 fragment.appendChild(tr); 18076 }); 18077 }); 18078 18079 return fragment; 18080 } 18081 18082 /** 18083 * Remove table from document and reset internal state. 18084 */ 18085 18086 }, { 18087 key: 'clean', 18088 value: function clean() { 18089 this.rows.length = 0; 18090 this.rows[-1] = void 0; 18091 this.columns.length = 0; 18092 18093 if (this.samples) { 18094 this.samples.clear(); 18095 } 18096 this.samples = null; 18097 this.removeTable(); 18098 } 18099 18100 /** 18101 * Inject generated table into document. 18102 * 18103 * @param {HTMLElement} [parent=null] 18104 */ 18105 18106 }, { 18107 key: 'injectTable', 18108 value: function injectTable() { 18109 var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 18110 18111 if (!this.injected) { 18112 (parent || this.hot.rootElement).appendChild(this.container.fragment); 18113 this.injected = true; 18114 } 18115 } 18116 18117 /** 18118 * Remove table from document. 18119 */ 18120 18121 }, { 18122 key: 'removeTable', 18123 value: function removeTable() { 18124 if (this.injected && this.container.container.parentNode) { 18125 this.container.container.parentNode.removeChild(this.container.container); 18126 this.container = null; 18127 this.injected = false; 18128 } 18129 } 18130 18131 /** 18132 * Create col element. 18133 * 18134 * @param {Number} column Column index. 18135 * @returns {HTMLElement} 18136 */ 18137 18138 }, { 18139 key: 'createColElement', 18140 value: function createColElement(column) { 18141 var d = document; 18142 var col = d.createElement('col'); 18143 18144 col.style.width = this.hot.view.wt.wtTable.getStretchedColumnWidth(column) + 'px'; 18145 18146 return col; 18147 } 18148 18149 /** 18150 * Create table element. 18151 * 18152 * @param {String} className 18153 * @returns {Object} 18154 */ 18155 18156 }, { 18157 key: 'createTable', 18158 value: function createTable() { 18159 var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 18160 18161 var d = document; 18162 var fragment = d.createDocumentFragment(); 18163 var table = d.createElement('table'); 18164 var tHead = d.createElement('thead'); 18165 var tBody = d.createElement('tbody'); 18166 var colGroup = d.createElement('colgroup'); 18167 var tr = d.createElement('tr'); 18168 var th = d.createElement('th'); 18169 18170 if (this.isVertical()) { 18171 table.appendChild(colGroup); 18172 } 18173 if (this.isHorizontal()) { 18174 tr.appendChild(th); 18175 tHead.appendChild(tr); 18176 table.style.tableLayout = 'auto'; 18177 table.style.width = 'auto'; 18178 } 18179 table.appendChild(tHead); 18180 18181 if (this.isVertical()) { 18182 tBody.appendChild(tr); 18183 } 18184 table.appendChild(tBody); 18185 (0, _element.addClass)(table, className); 18186 fragment.appendChild(table); 18187 18188 return { fragment: fragment, table: table, tHead: tHead, tBody: tBody, colGroup: colGroup, tr: tr, th: th }; 18189 } 18190 18191 /** 18192 * Create container for tables. 18193 * 18194 * @param {String} className 18195 * @returns {Object} 18196 */ 18197 18198 }, { 18199 key: 'createContainer', 18200 value: function createContainer() { 18201 var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 18202 18203 var d = document; 18204 var fragment = d.createDocumentFragment(); 18205 var container = d.createElement('div'); 18206 18207 className = 'htGhostTable htAutoSize ' + className.trim(); 18208 (0, _element.addClass)(container, className); 18209 fragment.appendChild(container); 18210 18211 return { fragment: fragment, container: container }; 18212 } 18213 18214 /** 18215 * Checks if table is raised vertically (checking rows). 18216 * 18217 * @returns {Boolean} 18218 */ 18219 18220 }, { 18221 key: 'isVertical', 18222 value: function isVertical() { 18223 return !!(this.rows.length && !this.columns.length); 18224 } 18225 18226 /** 18227 * Checks if table is raised horizontally (checking columns). 18228 * 18229 * @returns {Boolean} 18230 */ 18231 18232 }, { 18233 key: 'isHorizontal', 18234 value: function isHorizontal() { 18235 return !!(this.columns.length && !this.rows.length); 18236 } 18237 }]); 18238 18239 return GhostTable; 18240}(); 18241 18242exports.default = GhostTable; 18243 18244/***/ }), 18245/* 70 */ 18246/***/ (function(module, exports, __webpack_require__) { 18247 18248"use strict"; 18249 18250var addToUnscopables = __webpack_require__(37); 18251var step = __webpack_require__(282); 18252var Iterators = __webpack_require__(46); 18253var toIObject = __webpack_require__(27); 18254 18255// 22.1.3.4 Array.prototype.entries() 18256// 22.1.3.13 Array.prototype.keys() 18257// 22.1.3.29 Array.prototype.values() 18258// 22.1.3.30 Array.prototype[@@iterator]() 18259module.exports = __webpack_require__(281)(Array, 'Array', function (iterated, kind) { 18260 this._t = toIObject(iterated); // target 18261 this._i = 0; // next index 18262 this._k = kind; // kind 18263// 22.1.5.2.1 %ArrayIteratorPrototype%.next() 18264}, function () { 18265 var O = this._t; 18266 var kind = this._k; 18267 var index = this._i++; 18268 if (!O || index >= O.length) { 18269 this._t = undefined; 18270 return step(1); 18271 } 18272 if (kind == 'keys') return step(0, index); 18273 if (kind == 'values') return step(0, O[index]); 18274 return step(0, [index, O[index]]); 18275}, 'values'); 18276 18277// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) 18278Iterators.Arguments = Iterators.Array; 18279 18280addToUnscopables('keys'); 18281addToUnscopables('values'); 18282addToUnscopables('entries'); 18283 18284 18285/***/ }), 18286/* 71 */ 18287/***/ (function(module, exports, __webpack_require__) { 18288 18289"use strict"; 18290 18291 18292exports.__esModule = true; 18293 18294var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 18295 18296var _coords = __webpack_require__(43); 18297 18298var _coords2 = _interopRequireDefault(_coords); 18299 18300function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 18301 18302function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 18303 18304/** 18305 * A cell range is a set of exactly two CellCoords (that can be the same or different) 18306 * 18307 * @class CellRange 18308 */ 18309var CellRange = function () { 18310 /** 18311 * @param {CellCoords} highlight Used to draw bold border around a cell where selection was 18312 * started and to edit the cell when you press Enter 18313 * @param {CellCoords} from Usually the same as highlight, but in Excel there is distinction - one can change 18314 * highlight within a selection 18315 * @param {CellCoords} to End selection 18316 */ 18317 function CellRange(highlight, from, to) { 18318 _classCallCheck(this, CellRange); 18319 18320 this.highlight = highlight; 18321 this.from = from; 18322 this.to = to; 18323 } 18324 18325 /** 18326 * Checks if given coords are valid in context of a given Walkontable instance 18327 * 18328 * @param {Walkontable} wotInstance 18329 * @returns {Boolean} 18330 */ 18331 18332 18333 _createClass(CellRange, [{ 18334 key: 'isValid', 18335 value: function isValid(wotInstance) { 18336 return this.from.isValid(wotInstance) && this.to.isValid(wotInstance); 18337 } 18338 18339 /** 18340 * Checks if this cell range is restricted to one cell 18341 * 18342 * @returns {Boolean} 18343 */ 18344 18345 }, { 18346 key: 'isSingle', 18347 value: function isSingle() { 18348 return this.from.row === this.to.row && this.from.col === this.to.col; 18349 } 18350 18351 /** 18352 * Returns selected range height (in number of rows) 18353 * 18354 * @returns {Number} 18355 */ 18356 18357 }, { 18358 key: 'getHeight', 18359 value: function getHeight() { 18360 return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1; 18361 } 18362 18363 /** 18364 * Returns selected range width (in number of columns) 18365 * 18366 * @returns {Number} 18367 */ 18368 18369 }, { 18370 key: 'getWidth', 18371 value: function getWidth() { 18372 return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1; 18373 } 18374 18375 /** 18376 * Checks if given cell coords is within `from` and `to` cell coords of this range 18377 * 18378 * @param {CellCoords} cellCoords 18379 * @returns {Boolean} 18380 */ 18381 18382 }, { 18383 key: 'includes', 18384 value: function includes(cellCoords) { 18385 var row = cellCoords.row, 18386 col = cellCoords.col; 18387 18388 var topLeft = this.getTopLeftCorner(); 18389 var bottomRight = this.getBottomRightCorner(); 18390 18391 return topLeft.row <= row && bottomRight.row >= row && topLeft.col <= col && bottomRight.col >= col; 18392 } 18393 18394 /** 18395 * Checks if given range is within of this range 18396 * 18397 * @param {CellRange} testedRange 18398 * @returns {Boolean} 18399 */ 18400 18401 }, { 18402 key: 'includesRange', 18403 value: function includesRange(testedRange) { 18404 return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner()); 18405 } 18406 18407 /** 18408 * Checks if given range is equal to this range 18409 * 18410 * @param {CellRange} testedRange 18411 * @returns {Boolean} 18412 */ 18413 18414 }, { 18415 key: 'isEqual', 18416 value: function isEqual(testedRange) { 18417 return Math.min(this.from.row, this.to.row) == Math.min(testedRange.from.row, testedRange.to.row) && Math.max(this.from.row, this.to.row) == Math.max(testedRange.from.row, testedRange.to.row) && Math.min(this.from.col, this.to.col) == Math.min(testedRange.from.col, testedRange.to.col) && Math.max(this.from.col, this.to.col) == Math.max(testedRange.from.col, testedRange.to.col); 18418 } 18419 18420 /** 18421 * Checks if tested range overlaps with the range. 18422 * Range A is considered to to be overlapping with range B if intersection of A and B or B and A is not empty. 18423 * 18424 * @param {CellRange} testedRange 18425 * @returns {Boolean} 18426 */ 18427 18428 }, { 18429 key: 'overlaps', 18430 value: function overlaps(testedRange) { 18431 return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner()); 18432 } 18433 18434 /** 18435 * @param {CellRange} testedCoords 18436 * @returns {Boolean} 18437 */ 18438 18439 }, { 18440 key: 'isSouthEastOf', 18441 value: function isSouthEastOf(testedCoords) { 18442 return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords); 18443 } 18444 18445 /** 18446 * @param {CellRange} testedCoords 18447 * @returns {Boolean} 18448 */ 18449 18450 }, { 18451 key: 'isNorthWestOf', 18452 value: function isNorthWestOf(testedCoords) { 18453 return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords); 18454 } 18455 18456 /** 18457 * Adds a cell to a range (only if exceeds corners of the range). Returns information if range was expanded 18458 * 18459 * @param {CellCoords} cellCoords 18460 * @returns {Boolean} 18461 */ 18462 18463 }, { 18464 key: 'expand', 18465 value: function expand(cellCoords) { 18466 var topLeft = this.getTopLeftCorner(); 18467 var bottomRight = this.getBottomRightCorner(); 18468 18469 if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) { 18470 this.from = new _coords2.default(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col)); 18471 this.to = new _coords2.default(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col)); 18472 18473 return true; 18474 } 18475 18476 return false; 18477 } 18478 18479 /** 18480 * @param {CellRange} expandingRange 18481 * @returns {Boolean} 18482 */ 18483 18484 }, { 18485 key: 'expandByRange', 18486 value: function expandByRange(expandingRange) { 18487 if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) { 18488 return false; 18489 } 18490 18491 var topLeft = this.getTopLeftCorner(); 18492 var bottomRight = this.getBottomRightCorner(); 18493 var topRight = this.getTopRightCorner(); 18494 var bottomLeft = this.getBottomLeftCorner(); 18495 18496 var expandingTopLeft = expandingRange.getTopLeftCorner(); 18497 var expandingBottomRight = expandingRange.getBottomRightCorner(); 18498 18499 var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row); 18500 var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col); 18501 var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row); 18502 var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col); 18503 18504 var finalFrom = new _coords2.default(resultTopRow, resultTopCol), 18505 finalTo = new _coords2.default(resultBottomRow, resultBottomCol); 18506 var isCorner = new CellRange(finalFrom, finalFrom, finalTo).isCorner(this.from, expandingRange), 18507 onlyMerge = expandingRange.isEqual(new CellRange(finalFrom, finalFrom, finalTo)); 18508 18509 if (isCorner && !onlyMerge) { 18510 if (this.from.col > finalFrom.col) { 18511 finalFrom.col = resultBottomCol; 18512 finalTo.col = resultTopCol; 18513 } 18514 if (this.from.row > finalFrom.row) { 18515 finalFrom.row = resultBottomRow; 18516 finalTo.row = resultTopRow; 18517 } 18518 } 18519 this.from = finalFrom; 18520 this.to = finalTo; 18521 18522 return true; 18523 } 18524 18525 /** 18526 * @returns {String} 18527 */ 18528 18529 }, { 18530 key: 'getDirection', 18531 value: function getDirection() { 18532 if (this.from.isNorthWestOf(this.to)) { 18533 // NorthWest - SouthEast 18534 return 'NW-SE'; 18535 } else if (this.from.isNorthEastOf(this.to)) { 18536 // NorthEast - SouthWest 18537 return 'NE-SW'; 18538 } else if (this.from.isSouthEastOf(this.to)) { 18539 // SouthEast - NorthWest 18540 return 'SE-NW'; 18541 } else if (this.from.isSouthWestOf(this.to)) { 18542 // SouthWest - NorthEast 18543 return 'SW-NE'; 18544 } 18545 } 18546 18547 /** 18548 * @param {String} direction 18549 */ 18550 18551 }, { 18552 key: 'setDirection', 18553 value: function setDirection(direction) { 18554 switch (direction) { 18555 case 'NW-SE': 18556 var _ref = [this.getTopLeftCorner(), this.getBottomRightCorner()]; 18557 this.from = _ref[0]; 18558 this.to = _ref[1]; 18559 18560 break; 18561 case 'NE-SW': 18562 var _ref2 = [this.getTopRightCorner(), this.getBottomLeftCorner()]; 18563 this.from = _ref2[0]; 18564 this.to = _ref2[1]; 18565 18566 break; 18567 case 'SE-NW': 18568 var _ref3 = [this.getBottomRightCorner(), this.getTopLeftCorner()]; 18569 this.from = _ref3[0]; 18570 this.to = _ref3[1]; 18571 18572 break; 18573 case 'SW-NE': 18574 var _ref4 = [this.getBottomLeftCorner(), this.getTopRightCorner()]; 18575 this.from = _ref4[0]; 18576 this.to = _ref4[1]; 18577 18578 break; 18579 default: 18580 break; 18581 } 18582 } 18583 18584 /** 18585 * Get top left corner of this range 18586 * 18587 * @returns {CellCoords} 18588 */ 18589 18590 }, { 18591 key: 'getTopLeftCorner', 18592 value: function getTopLeftCorner() { 18593 return new _coords2.default(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col)); 18594 } 18595 18596 /** 18597 * Get bottom right corner of this range 18598 * 18599 * @returns {CellCoords} 18600 */ 18601 18602 }, { 18603 key: 'getBottomRightCorner', 18604 value: function getBottomRightCorner() { 18605 return new _coords2.default(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col)); 18606 } 18607 18608 /** 18609 * Get top right corner of this range 18610 * 18611 * @returns {CellCoords} 18612 */ 18613 18614 }, { 18615 key: 'getTopRightCorner', 18616 value: function getTopRightCorner() { 18617 return new _coords2.default(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col)); 18618 } 18619 18620 /** 18621 * Get bottom left corner of this range 18622 * 18623 * @returns {CellCoords} 18624 */ 18625 18626 }, { 18627 key: 'getBottomLeftCorner', 18628 value: function getBottomLeftCorner() { 18629 return new _coords2.default(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col)); 18630 } 18631 18632 /** 18633 * @param {CellCoords} coords 18634 * @param {CellRange} expandedRange 18635 * @returns {*} 18636 */ 18637 18638 }, { 18639 key: 'isCorner', 18640 value: function isCorner(coords, expandedRange) { 18641 if (expandedRange) { 18642 if (expandedRange.includes(coords)) { 18643 if (this.getTopLeftCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.from.col)) || this.getTopRightCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.to.col)) || this.getBottomLeftCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.from.col)) || this.getBottomRightCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.to.col))) { 18644 return true; 18645 } 18646 } 18647 } 18648 18649 return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner()); 18650 } 18651 18652 /** 18653 * @param {CellCoords} coords 18654 * @param {CellRange} expandedRange 18655 * @returns {CellCoords} 18656 */ 18657 18658 }, { 18659 key: 'getOppositeCorner', 18660 value: function getOppositeCorner(coords, expandedRange) { 18661 if (!(coords instanceof _coords2.default)) { 18662 return false; 18663 } 18664 18665 if (expandedRange) { 18666 if (expandedRange.includes(coords)) { 18667 if (this.getTopLeftCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.from.col))) { 18668 return this.getBottomRightCorner(); 18669 } 18670 if (this.getTopRightCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.to.col))) { 18671 return this.getBottomLeftCorner(); 18672 } 18673 if (this.getBottomLeftCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.from.col))) { 18674 return this.getTopRightCorner(); 18675 } 18676 if (this.getBottomRightCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.to.col))) { 18677 return this.getTopLeftCorner(); 18678 } 18679 } 18680 } 18681 18682 if (coords.isEqual(this.getBottomRightCorner())) { 18683 return this.getTopLeftCorner(); 18684 } else if (coords.isEqual(this.getTopLeftCorner())) { 18685 return this.getBottomRightCorner(); 18686 } else if (coords.isEqual(this.getTopRightCorner())) { 18687 return this.getBottomLeftCorner(); 18688 } else if (coords.isEqual(this.getBottomLeftCorner())) { 18689 return this.getTopRightCorner(); 18690 } 18691 } 18692 18693 /** 18694 * @param {CellRange} range 18695 * @returns {Array} 18696 */ 18697 18698 }, { 18699 key: 'getBordersSharedWith', 18700 value: function getBordersSharedWith(range) { 18701 if (!this.includesRange(range)) { 18702 return []; 18703 } 18704 18705 var thisBorders = { 18706 top: Math.min(this.from.row, this.to.row), 18707 bottom: Math.max(this.from.row, this.to.row), 18708 left: Math.min(this.from.col, this.to.col), 18709 right: Math.max(this.from.col, this.to.col) 18710 }; 18711 var rangeBorders = { 18712 top: Math.min(range.from.row, range.to.row), 18713 bottom: Math.max(range.from.row, range.to.row), 18714 left: Math.min(range.from.col, range.to.col), 18715 right: Math.max(range.from.col, range.to.col) 18716 }; 18717 var result = []; 18718 18719 if (thisBorders.top == rangeBorders.top) { 18720 result.push('top'); 18721 } 18722 if (thisBorders.right == rangeBorders.right) { 18723 result.push('right'); 18724 } 18725 if (thisBorders.bottom == rangeBorders.bottom) { 18726 result.push('bottom'); 18727 } 18728 if (thisBorders.left == rangeBorders.left) { 18729 result.push('left'); 18730 } 18731 18732 return result; 18733 } 18734 18735 /** 18736 * Get inner selected cell coords defined by this range 18737 * 18738 * @returns {Array} 18739 */ 18740 18741 }, { 18742 key: 'getInner', 18743 value: function getInner() { 18744 var topLeft = this.getTopLeftCorner(); 18745 var bottomRight = this.getBottomRightCorner(); 18746 var out = []; 18747 18748 for (var r = topLeft.row; r <= bottomRight.row; r++) { 18749 for (var c = topLeft.col; c <= bottomRight.col; c++) { 18750 if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) { 18751 out.push(new _coords2.default(r, c)); 18752 } 18753 } 18754 } 18755 return out; 18756 } 18757 18758 /** 18759 * Get all selected cell coords defined by this range 18760 * 18761 * @returns {Array} 18762 */ 18763 18764 }, { 18765 key: 'getAll', 18766 value: function getAll() { 18767 var topLeft = this.getTopLeftCorner(); 18768 var bottomRight = this.getBottomRightCorner(); 18769 var out = []; 18770 18771 for (var r = topLeft.row; r <= bottomRight.row; r++) { 18772 for (var c = topLeft.col; c <= bottomRight.col; c++) { 18773 if (topLeft.row === r && topLeft.col === c) { 18774 out.push(topLeft); 18775 } else if (bottomRight.row === r && bottomRight.col === c) { 18776 out.push(bottomRight); 18777 } else { 18778 out.push(new _coords2.default(r, c)); 18779 } 18780 } 18781 } 18782 18783 return out; 18784 } 18785 18786 /** 18787 * Runs a callback function against all cells in the range. You can break the iteration by returning 18788 * `false` in the callback function 18789 * 18790 * @param callback {Function} 18791 */ 18792 18793 }, { 18794 key: 'forAll', 18795 value: function forAll(callback) { 18796 var topLeft = this.getTopLeftCorner(); 18797 var bottomRight = this.getBottomRightCorner(); 18798 18799 for (var r = topLeft.row; r <= bottomRight.row; r++) { 18800 for (var c = topLeft.col; c <= bottomRight.col; c++) { 18801 var breakIteration = callback(r, c); 18802 18803 if (breakIteration === false) { 18804 return; 18805 } 18806 } 18807 } 18808 } 18809 }]); 18810 18811 return CellRange; 18812}(); 18813 18814exports.default = CellRange; 18815 18816/***/ }), 18817/* 72 */ 18818/***/ (function(module, exports, __webpack_require__) { 18819 18820"use strict"; 18821 18822 18823exports.__esModule = true; 18824exports.ITEMS = exports.UNDO = exports.SEPARATOR = exports.ROW_BELOW = exports.ROW_ABOVE = exports.REMOVE_ROW = exports.REMOVE_COLUMN = exports.REDO = exports.READ_ONLY = exports.COLUMN_RIGHT = exports.COLUMN_LEFT = exports.CLEAR_COLUMN = exports.ALIGNMENT = undefined; 18825 18826var _predefinedItems2; 18827 18828var _alignment = __webpack_require__(344); 18829 18830Object.defineProperty(exports, 'ALIGNMENT', { 18831 enumerable: true, 18832 get: function get() { 18833 return _alignment.KEY; 18834 } 18835}); 18836 18837var _clearColumn = __webpack_require__(345); 18838 18839Object.defineProperty(exports, 'CLEAR_COLUMN', { 18840 enumerable: true, 18841 get: function get() { 18842 return _clearColumn.KEY; 18843 } 18844}); 18845 18846var _columnLeft = __webpack_require__(346); 18847 18848Object.defineProperty(exports, 'COLUMN_LEFT', { 18849 enumerable: true, 18850 get: function get() { 18851 return _columnLeft.KEY; 18852 } 18853}); 18854 18855var _columnRight = __webpack_require__(347); 18856 18857Object.defineProperty(exports, 'COLUMN_RIGHT', { 18858 enumerable: true, 18859 get: function get() { 18860 return _columnRight.KEY; 18861 } 18862}); 18863 18864var _readOnly = __webpack_require__(348); 18865 18866Object.defineProperty(exports, 'READ_ONLY', { 18867 enumerable: true, 18868 get: function get() { 18869 return _readOnly.KEY; 18870 } 18871}); 18872 18873var _redo = __webpack_require__(349); 18874 18875Object.defineProperty(exports, 'REDO', { 18876 enumerable: true, 18877 get: function get() { 18878 return _redo.KEY; 18879 } 18880}); 18881 18882var _removeColumn = __webpack_require__(350); 18883 18884Object.defineProperty(exports, 'REMOVE_COLUMN', { 18885 enumerable: true, 18886 get: function get() { 18887 return _removeColumn.KEY; 18888 } 18889}); 18890 18891var _removeRow = __webpack_require__(351); 18892 18893Object.defineProperty(exports, 'REMOVE_ROW', { 18894 enumerable: true, 18895 get: function get() { 18896 return _removeRow.KEY; 18897 } 18898}); 18899 18900var _rowAbove = __webpack_require__(352); 18901 18902Object.defineProperty(exports, 'ROW_ABOVE', { 18903 enumerable: true, 18904 get: function get() { 18905 return _rowAbove.KEY; 18906 } 18907}); 18908 18909var _rowBelow = __webpack_require__(353); 18910 18911Object.defineProperty(exports, 'ROW_BELOW', { 18912 enumerable: true, 18913 get: function get() { 18914 return _rowBelow.KEY; 18915 } 18916}); 18917 18918var _separator = __webpack_require__(73); 18919 18920Object.defineProperty(exports, 'SEPARATOR', { 18921 enumerable: true, 18922 get: function get() { 18923 return _separator.KEY; 18924 } 18925}); 18926 18927var _undo = __webpack_require__(354); 18928 18929Object.defineProperty(exports, 'UNDO', { 18930 enumerable: true, 18931 get: function get() { 18932 return _undo.KEY; 18933 } 18934}); 18935exports.predefinedItems = predefinedItems; 18936exports.addItem = addItem; 18937 18938var _object = __webpack_require__(3); 18939 18940var _alignment2 = _interopRequireDefault(_alignment); 18941 18942var _clearColumn2 = _interopRequireDefault(_clearColumn); 18943 18944var _columnLeft2 = _interopRequireDefault(_columnLeft); 18945 18946var _columnRight2 = _interopRequireDefault(_columnRight); 18947 18948var _readOnly2 = _interopRequireDefault(_readOnly); 18949 18950var _redo2 = _interopRequireDefault(_redo); 18951 18952var _removeColumn2 = _interopRequireDefault(_removeColumn); 18953 18954var _removeRow2 = _interopRequireDefault(_removeRow); 18955 18956var _rowAbove2 = _interopRequireDefault(_rowAbove); 18957 18958var _rowBelow2 = _interopRequireDefault(_rowBelow); 18959 18960var _separator2 = _interopRequireDefault(_separator); 18961 18962var _undo2 = _interopRequireDefault(_undo); 18963 18964function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 18965 18966function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 18967 18968var ITEMS = exports.ITEMS = [_rowAbove.KEY, _rowBelow.KEY, _columnLeft.KEY, _columnRight.KEY, _clearColumn.KEY, _removeRow.KEY, _removeColumn.KEY, _undo.KEY, _redo.KEY, _readOnly.KEY, _alignment.KEY, _separator.KEY]; 18969 18970var _predefinedItems = (_predefinedItems2 = {}, _defineProperty(_predefinedItems2, _separator.KEY, _separator2.default), _defineProperty(_predefinedItems2, _rowAbove.KEY, _rowAbove2.default), _defineProperty(_predefinedItems2, _rowBelow.KEY, _rowBelow2.default), _defineProperty(_predefinedItems2, _columnLeft.KEY, _columnLeft2.default), _defineProperty(_predefinedItems2, _columnRight.KEY, _columnRight2.default), _defineProperty(_predefinedItems2, _clearColumn.KEY, _clearColumn2.default), _defineProperty(_predefinedItems2, _removeRow.KEY, _removeRow2.default), _defineProperty(_predefinedItems2, _removeColumn.KEY, _removeColumn2.default), _defineProperty(_predefinedItems2, _undo.KEY, _undo2.default), _defineProperty(_predefinedItems2, _redo.KEY, _redo2.default), _defineProperty(_predefinedItems2, _readOnly.KEY, _readOnly2.default), _defineProperty(_predefinedItems2, _alignment.KEY, _alignment2.default), _predefinedItems2); 18971 18972/** 18973 * Gets new object with all predefined menu items. 18974 * 18975 * @returns {Object} 18976 */ 18977function predefinedItems() { 18978 var items = {}; 18979 18980 (0, _object.objectEach)(_predefinedItems, function (itemFactory, key) { 18981 items[key] = itemFactory(); 18982 }); 18983 18984 return items; 18985} 18986 18987/** 18988 * Add new predefined menu item to the collection. 18989 * 18990 * @param {String} key Menu command id. 18991 * @param {Object} item Object command descriptor. 18992 */ 18993function addItem(key, item) { 18994 if (ITEMS.indexOf(key) === -1) { 18995 _predefinedItems[key] = item; 18996 } 18997} 18998 18999/***/ }), 19000/* 73 */ 19001/***/ (function(module, exports, __webpack_require__) { 19002 19003"use strict"; 19004 19005 19006exports.__esModule = true; 19007exports.default = separatorItem; 19008var KEY = exports.KEY = '---------'; 19009 19010function separatorItem() { 19011 return { 19012 name: KEY 19013 }; 19014} 19015 19016/***/ }), 19017/* 74 */ 19018/***/ (function(module, exports, __webpack_require__) { 19019 19020"use strict"; 19021 19022var $defineProperty = __webpack_require__(18); 19023var createDesc = __webpack_require__(49); 19024 19025module.exports = function (object, index, value) { 19026 if (index in object) $defineProperty.f(object, index, createDesc(0, value)); 19027 else object[index] = value; 19028}; 19029 19030 19031/***/ }), 19032/* 75 */ 19033/***/ (function(module, exports, __webpack_require__) { 19034 19035var isObject = __webpack_require__(12); 19036var document = __webpack_require__(10).document; 19037// typeof document.createElement is 'object' in old IE 19038var is = isObject(document) && isObject(document.createElement); 19039module.exports = function (it) { 19040 return is ? document.createElement(it) : {}; 19041}; 19042 19043 19044/***/ }), 19045/* 76 */ 19046/***/ (function(module, exports) { 19047 19048// IE 8- don't enum bug keys 19049module.exports = ( 19050 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' 19051).split(','); 19052 19053 19054/***/ }), 19055/* 77 */ 19056/***/ (function(module, exports, __webpack_require__) { 19057 19058var MATCH = __webpack_require__(8)('match'); 19059module.exports = function (KEY) { 19060 var re = /./; 19061 try { 19062 '/./'[KEY](re); 19063 } catch (e) { 19064 try { 19065 re[MATCH] = false; 19066 return !'/./'[KEY](re); 19067 } catch (f) { /* empty */ } 19068 } return true; 19069}; 19070 19071 19072/***/ }), 19073/* 78 */ 19074/***/ (function(module, exports, __webpack_require__) { 19075 19076// fallback for non-array-like ES3 and non-enumerable old V8 strings 19077var cof = __webpack_require__(38); 19078// eslint-disable-next-line no-prototype-builtins 19079module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { 19080 return cof(it) == 'String' ? it.split('') : Object(it); 19081}; 19082 19083 19084/***/ }), 19085/* 79 */ 19086/***/ (function(module, exports, __webpack_require__) { 19087 19088var ITERATOR = __webpack_require__(8)('iterator'); 19089var SAFE_CLOSING = false; 19090 19091try { 19092 var riter = [7][ITERATOR](); 19093 riter['return'] = function () { SAFE_CLOSING = true; }; 19094 // eslint-disable-next-line no-throw-literal 19095 Array.from(riter, function () { throw 2; }); 19096} catch (e) { /* empty */ } 19097 19098module.exports = function (exec, skipClosing) { 19099 if (!skipClosing && !SAFE_CLOSING) return false; 19100 var safe = false; 19101 try { 19102 var arr = [7]; 19103 var iter = arr[ITERATOR](); 19104 iter.next = function () { return { done: safe = true }; }; 19105 arr[ITERATOR] = function () { return iter; }; 19106 exec(arr); 19107 } catch (e) { /* empty */ } 19108 return safe; 19109}; 19110 19111 19112/***/ }), 19113/* 80 */ 19114/***/ (function(module, exports, __webpack_require__) { 19115 19116// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) 19117var anObject = __webpack_require__(17); 19118var dPs = __webpack_require__(399); 19119var enumBugKeys = __webpack_require__(76); 19120var IE_PROTO = __webpack_require__(83)('IE_PROTO'); 19121var Empty = function () { /* empty */ }; 19122var PROTOTYPE = 'prototype'; 19123 19124// Create object with fake `null` prototype: use iframe Object with cleared prototype 19125var createDict = function () { 19126 // Thrash, waste and sodomy: IE GC bug 19127 var iframe = __webpack_require__(75)('iframe'); 19128 var i = enumBugKeys.length; 19129 var lt = '<'; 19130 var gt = '>'; 19131 var iframeDocument; 19132 iframe.style.display = 'none'; 19133 __webpack_require__(274).appendChild(iframe); 19134 iframe.src = 'javascript:'; // eslint-disable-line no-script-url 19135 // createDict = iframe.contentWindow.Object; 19136 // html.removeChild(iframe); 19137 iframeDocument = iframe.contentWindow.document; 19138 iframeDocument.open(); 19139 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); 19140 iframeDocument.close(); 19141 createDict = iframeDocument.F; 19142 while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]]; 19143 return createDict(); 19144}; 19145 19146module.exports = Object.create || function create(O, Properties) { 19147 var result; 19148 if (O !== null) { 19149 Empty[PROTOTYPE] = anObject(O); 19150 result = new Empty(); 19151 Empty[PROTOTYPE] = null; 19152 // add "__proto__" for Object.getPrototypeOf polyfill 19153 result[IE_PROTO] = O; 19154 } else result = createDict(); 19155 return Properties === undefined ? result : dPs(result, Properties); 19156}; 19157 19158 19159/***/ }), 19160/* 81 */ 19161/***/ (function(module, exports, __webpack_require__) { 19162 19163var pIE = __webpack_require__(48); 19164var createDesc = __webpack_require__(49); 19165var toIObject = __webpack_require__(27); 19166var toPrimitive = __webpack_require__(87); 19167var has = __webpack_require__(26); 19168var IE8_DOM_DEFINE = __webpack_require__(275); 19169var gOPD = Object.getOwnPropertyDescriptor; 19170 19171exports.f = __webpack_require__(20) ? gOPD : function getOwnPropertyDescriptor(O, P) { 19172 O = toIObject(O); 19173 P = toPrimitive(P, true); 19174 if (IE8_DOM_DEFINE) try { 19175 return gOPD(O, P); 19176 } catch (e) { /* empty */ } 19177 if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); 19178}; 19179 19180 19181/***/ }), 19182/* 82 */ 19183/***/ (function(module, exports, __webpack_require__) { 19184 19185// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) 19186var $keys = __webpack_require__(285); 19187var hiddenKeys = __webpack_require__(76).concat('length', 'prototype'); 19188 19189exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 19190 return $keys(O, hiddenKeys); 19191}; 19192 19193 19194/***/ }), 19195/* 83 */ 19196/***/ (function(module, exports, __webpack_require__) { 19197 19198var shared = __webpack_require__(84)('keys'); 19199var uid = __webpack_require__(51); 19200module.exports = function (key) { 19201 return shared[key] || (shared[key] = uid(key)); 19202}; 19203 19204 19205/***/ }), 19206/* 84 */ 19207/***/ (function(module, exports, __webpack_require__) { 19208 19209var global = __webpack_require__(10); 19210var SHARED = '__core-js_shared__'; 19211var store = global[SHARED] || (global[SHARED] = {}); 19212module.exports = function (key) { 19213 return store[key] || (store[key] = {}); 19214}; 19215 19216 19217/***/ }), 19218/* 85 */ 19219/***/ (function(module, exports, __webpack_require__) { 19220 19221// helper for String#{startsWith, endsWith, includes} 19222var isRegExp = __webpack_require__(279); 19223var defined = __webpack_require__(33); 19224 19225module.exports = function (that, searchString, NAME) { 19226 if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!"); 19227 return String(defined(that)); 19228}; 19229 19230 19231/***/ }), 19232/* 86 */ 19233/***/ (function(module, exports, __webpack_require__) { 19234 19235var ctx = __webpack_require__(30); 19236var invoke = __webpack_require__(396); 19237var html = __webpack_require__(274); 19238var cel = __webpack_require__(75); 19239var global = __webpack_require__(10); 19240var process = global.process; 19241var setTask = global.setImmediate; 19242var clearTask = global.clearImmediate; 19243var MessageChannel = global.MessageChannel; 19244var Dispatch = global.Dispatch; 19245var counter = 0; 19246var queue = {}; 19247var ONREADYSTATECHANGE = 'onreadystatechange'; 19248var defer, channel, port; 19249var run = function () { 19250 var id = +this; 19251 // eslint-disable-next-line no-prototype-builtins 19252 if (queue.hasOwnProperty(id)) { 19253 var fn = queue[id]; 19254 delete queue[id]; 19255 fn(); 19256 } 19257}; 19258var listener = function (event) { 19259 run.call(event.data); 19260}; 19261// Node.js 0.9+ & IE10+ has setImmediate, otherwise: 19262if (!setTask || !clearTask) { 19263 setTask = function setImmediate(fn) { 19264 var args = []; 19265 var i = 1; 19266 while (arguments.length > i) args.push(arguments[i++]); 19267 queue[++counter] = function () { 19268 // eslint-disable-next-line no-new-func 19269 invoke(typeof fn == 'function' ? fn : Function(fn), args); 19270 }; 19271 defer(counter); 19272 return counter; 19273 }; 19274 clearTask = function clearImmediate(id) { 19275 delete queue[id]; 19276 }; 19277 // Node.js 0.8- 19278 if (__webpack_require__(38)(process) == 'process') { 19279 defer = function (id) { 19280 process.nextTick(ctx(run, id, 1)); 19281 }; 19282 // Sphere (JS game engine) Dispatch API 19283 } else if (Dispatch && Dispatch.now) { 19284 defer = function (id) { 19285 Dispatch.now(ctx(run, id, 1)); 19286 }; 19287 // Browsers with MessageChannel, includes WebWorkers 19288 } else if (MessageChannel) { 19289 channel = new MessageChannel(); 19290 port = channel.port2; 19291 channel.port1.onmessage = listener; 19292 defer = ctx(port.postMessage, port, 1); 19293 // Browsers with postMessage, skip WebWorkers 19294 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 19295 } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) { 19296 defer = function (id) { 19297 global.postMessage(id + '', '*'); 19298 }; 19299 global.addEventListener('message', listener, false); 19300 // IE8- 19301 } else if (ONREADYSTATECHANGE in cel('script')) { 19302 defer = function (id) { 19303 html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () { 19304 html.removeChild(this); 19305 run.call(id); 19306 }; 19307 }; 19308 // Rest old browsers 19309 } else { 19310 defer = function (id) { 19311 setTimeout(ctx(run, id, 1), 0); 19312 }; 19313 } 19314} 19315module.exports = { 19316 set: setTask, 19317 clear: clearTask 19318}; 19319 19320 19321/***/ }), 19322/* 87 */ 19323/***/ (function(module, exports, __webpack_require__) { 19324 19325// 7.1.1 ToPrimitive(input [, PreferredType]) 19326var isObject = __webpack_require__(12); 19327// instead of the ES6 spec version, we didn't implement @@toPrimitive case 19328// and the second argument - flag - preferred type is a string 19329module.exports = function (it, S) { 19330 if (!isObject(it)) return it; 19331 var fn, val; 19332 if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; 19333 if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; 19334 if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; 19335 throw TypeError("Can't convert object to primitive value"); 19336}; 19337 19338 19339/***/ }), 19340/* 88 */ 19341/***/ (function(module, exports, __webpack_require__) { 19342 19343"use strict"; 19344 19345 19346exports.__esModule = true; 19347 19348var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 19349 19350var _mixed = __webpack_require__(23); 19351 19352var _object = __webpack_require__(3); 19353 19354/** 19355 * @alias Options 19356 * @constructor 19357 * @description 19358 19359 * ## Constructor options 19360 * 19361 * Constructor options are applied using an object literal passed as a second argument to the Handsontable constructor. 19362 * 19363 * ```js 19364 * var hot = new Handsontable(document.getElementById('example1'), { 19365 * data: myArray, 19366 * width: 400, 19367 * height: 300 19368 * }); 19369 * ``` 19370 * 19371 * --- 19372 * ## Cascading configuration 19373 * 19374 * Handsontable 0.9 and newer is using *Cascading Configuration*, which is a fast way to provide configuration options 19375 * for the entire table, including its columns and particular cells. 19376 * 19377 * Consider the following example: 19378 * ```js 19379 * var hot = new Handsontable(document.getElementById('example'), { 19380 * readOnly: true, 19381 * columns: [ 19382 * {readOnly: false}, 19383 * {}, 19384 * {} 19385 * ], 19386 * cells: function (row, col, prop) { 19387 * var cellProperties = {}; 19388 * 19389 * if (row === 0 && col === 0) { 19390 * cellProperties.readOnly = true; 19391 * } 19392 * 19393 * return cellProperties; 19394 * } 19395 * }); 19396 * ``` 19397 * 19398 * The above notation will result in all TDs being *read only*, except for first column TDs which will be *editable*, except for the TD in top left corner which will still be *read only*. 19399 * 19400 * ### The Cascading Configuration model 19401 * 19402 * ##### 1. Constructor 19403 * 19404 * Configuration options that are provided using first-level `handsontable(container, {option: "value"})` and `updateSettings` method. 19405 * 19406 * ##### 2. Columns 19407 * 19408 * Configuration options that are provided using second-level object `handsontable(container, {columns: {option: "value"}]})` 19409 * 19410 * ##### 3. Cells 19411 * 19412 * Configuration options that are provided using third-level function `handsontable(container, {cells: function: (row, col, prop){ }})` 19413 * 19414 * --- 19415 * ## Architecture performance 19416 * 19417 * The Cascading Configuration model is based on prototypical inheritance. It is much faster and memory efficient compared 19418 * to the previous model that used jQuery extend. See: [http://jsperf.com/extending-settings](http://jsperf.com/extending-settings). 19419 * 19420 * --- 19421 * __Important notice:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`. 19422 */ 19423function DefaultSettings() {}; 19424 19425DefaultSettings.prototype = { 19426 /** 19427 * License key for commercial version of Handsontable. 19428 * 19429 * @pro 19430 * @type {String} 19431 * @default 'trial' 19432 */ 19433 licenseKey: 'trial', 19434 19435 /** 19436 * @description 19437 * Initial data source that will be bound to the data grid __by reference__ (editing data grid alters the data source). 19438 * Can be declared as an Array of Arrays, Array of Objects or a Function. 19439 * 19440 * See [Understanding binding as reference](http://docs.handsontable.com/tutorial-data-binding.html#page-reference). 19441 * 19442 * @type {Array|Function} 19443 * @default undefined 19444 */ 19445 data: void 0, 19446 19447 /** 19448 * @description 19449 * Defines the structure of a new row when data source is an array of objects. 19450 * 19451 * See [data-schema](http://docs.handsontable.com/tutorial-data-sources.html#page-data-schema) for examples. 19452 * 19453 * @type {Object} 19454 * @default undefined 19455 */ 19456 dataSchema: void 0, 19457 19458 /** 19459 * Width of the grid. Can be a value or a function that returns a value. 19460 * 19461 * @type {Number|Function} 19462 * @default undefined 19463 */ 19464 width: void 0, 19465 19466 /** 19467 * Height of the grid. Can be a number or a function that returns a number. 19468 * 19469 * @type {Number|Function} 19470 * @default undefined 19471 */ 19472 height: void 0, 19473 19474 /** 19475 * @description 19476 * Initial number of rows. 19477 * 19478 * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided 19479 * 19480 * @type {Number} 19481 * @default 5 19482 */ 19483 startRows: 5, 19484 19485 /** 19486 * @description 19487 * Initial number of columns. 19488 * 19489 * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided 19490 * 19491 * @type {Number} 19492 * @default 5 19493 */ 19494 startCols: 5, 19495 19496 /** 19497 * Setting `true` or `false` will enable or disable the default row headers (1, 2, 3). 19498 * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers. 19499 * If a function is set the index of the row is passed as a parameter. 19500 * 19501 * @type {Boolean|Array|Function} 19502 * @default null 19503 * @example 19504 * ```js 19505 * ... 19506 * // as boolean 19507 * rowHeaders: true, 19508 * ... 19509 * 19510 * ... 19511 * // as array 19512 * rowHeaders: [1, 2, 3], 19513 * ... 19514 * 19515 * ... 19516 * // as function 19517 * rowHeaders: function(index) { 19518 * return index + ': AB'; 19519 * }, 19520 * ... 19521 * ``` 19522 */ 19523 rowHeaders: void 0, 19524 19525 /** 19526 * Setting `true` or `false` will enable or disable the default column headers (A, B, C). 19527 * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers. 19528 * If a function is set, then the index of the column is passed as a parameter. 19529 * 19530 * @type {Boolean|Array|Function} 19531 * @default null 19532 * @example 19533 * ```js 19534 * ... 19535 * // as boolean 19536 * colHeaders: true, 19537 * ... 19538 * 19539 * ... 19540 * // as array 19541 * colHeaders: ['A', 'B', 'C'], 19542 * ... 19543 * 19544 * ... 19545 * // as function 19546 * colHeaders: function(index) { 19547 * return index + ': AB'; 19548 * }, 19549 * ... 19550 * ``` 19551 */ 19552 colHeaders: null, 19553 19554 /** 19555 * Defines column widths in pixels. Accepts number, string (that will be converted to a number), 19556 * array of numbers (if you want to define column width separately for each column) or a 19557 * function (if you want to set column width dynamically on each render). 19558 * 19559 * @type {Array|Function|Number|String} 19560 * @default undefined 19561 * @example 19562 * ```js 19563 * ... 19564 * // as numeric, for each column. 19565 * colWidths: 100, 19566 * ... 19567 * 19568 * * ... 19569 * // as string, for each column. 19570 * colWidths: '100px', 19571 * ... 19572 * 19573 * ... 19574 * // as array, based on visual indexes. The rest of the columns have a default width. 19575 * colWidths: [100, 120, 90], 19576 * ... 19577 * 19578 * ... 19579 * // as function, based on visual indexes. 19580 * colWidths: function(index) { 19581 * return index * 10; 19582 * }, 19583 * ... 19584 * ``` 19585 */ 19586 colWidths: void 0, 19587 19588 /** 19589 * Defines row heights in pixels. Accepts numbers, strings (that will be converted into a number), 19590 * array of numbers (if you want to define row height separately for each row) or a 19591 * function (if you want to set row height dynamically on each render). 19592 * If the ManualRowResize or AutoRowSize plugins are enabled, this is also the minimum height that can be set 19593 * via either of those two plugins. 19594 * Height should be equal or greater than 23px. Table is rendered incorrectly if height is less than 23px. 19595 * 19596 * @type {Array|Function|Number|String} 19597 * @default undefined 19598 * @example 19599 * ```js 19600 * ... 19601 * // as numeric, for each row. 19602 * rowHeights: 100, 19603 * ... 19604 * 19605 * * ... 19606 * // as string, for each row. 19607 * rowHeights: '100px', 19608 * ... 19609 * 19610 * ... 19611 * // as array, based on visual indexes. The rest of the rows have a default height. 19612 * rowHeights: [100, 120, 90], 19613 * ... 19614 * 19615 * ... 19616 * // as function, based on visual indexes. 19617 * rowHeights: function(index) { 19618 * return index * 10; 19619 * }, 19620 * ... 19621 * ``` 19622 */ 19623 rowHeights: void 0, 19624 19625 /** 19626 * @description 19627 * Defines the cell properties and data binding for certain columns. 19628 * 19629 * __Notice:__ Using this option sets a fixed number of columns (options `startCols`, `minCols`, `maxCols` will be ignored). 19630 * 19631 * See [documentation -> datasources.html](http://docs.handsontable.com/tutorial-data-sources.html#page-nested) for examples. 19632 * 19633 * @type {Array|Function} 19634 * @default undefined 19635 * @example 19636 * ```js 19637 * ... 19638 * // as an array of objects. Order of the objects in array is representation of physical indexes. 19639 * columns: [ 19640 * { 19641 * // column options for the first column 19642 * type: 'numeric', 19643 * format: '0,0.00 $' 19644 * }, 19645 * { 19646 * // column options for the second column 19647 * type: 'text', 19648 * readOnly: true 19649 * } 19650 * ], 19651 * ... 19652 * 19653 * // or as function, based on physical indexes 19654 * ... 19655 * columns: function(index) { 19656 * return { 19657 * type: index > 0 ? 'numeric' : 'text', 19658 * readOnly: index < 1 19659 * } 19660 * } 19661 * ... 19662 * ``` 19663 */ 19664 columns: void 0, 19665 19666 /** 19667 * @description 19668 * Defines the cell properties for given `row`, `col`, `prop` coordinates. 19669 * Any constructor or column option may be overwritten for a particular cell (row/column combination) 19670 * using the `cells` property in the Handsontable constructor. 19671 * 19672 * __Note:__ Parameters `row` and `col` always represent __physical indexes__. Example below show how to execute 19673 * operations based on the __visual__ representation of Handsontable. 19674 * 19675 * Possible values of `prop`: 19676 * - property name for column's data source object, when dataset is an [array of objects](/tutorial-data-sources.html#page-object) 19677 * - the same number as `col`, when dataset is an [array of arrays](/tutorial-data-sources.html#page-array) 19678 * 19679 * @type {Function} 19680 * @default undefined 19681 * @example 19682 * ```js 19683 * ... 19684 * cells: function (row, col, prop) { 19685 * var cellProperties = {}; 19686 * var visualRowIndex = this.instance.toVisualRow(row); 19687 * var visualColIndex = this.instance.toVisualColumn(col); 19688 * 19689 * if (visualRowIndex === 0 && visualColIndex === 0) { 19690 * cellProperties.readOnly = true; 19691 * } 19692 * 19693 * return cellProperties; 19694 * }, 19695 * ... 19696 * ``` 19697 */ 19698 cells: void 0, 19699 19700 /** 19701 * Any constructor or column option may be overwritten for a particular cell (row/column combination), using `cell` 19702 * array passed to the Handsontable constructor. 19703 * 19704 * @type {Array} 19705 * @default [] 19706 * @example 19707 * ```js 19708 * ... 19709 * cell: [ 19710 * {row: 0, col: 0, readOnly: true} 19711 * ], 19712 * ... 19713 * ``` 19714 */ 19715 cell: [], 19716 19717 /** 19718 * @description 19719 * If `true`, enables the {@link Comments} plugin, which enables an option to apply cell comments through the context menu 19720 * (configurable with context menu keys `commentsAddEdit`, `commentsRemove`). 19721 * 19722 * To initialize Handsontable with predefined comments, provide cell coordinates and comment text values in a form of an array. 19723 * 19724 * See [Comments](http://docs.handsontable.com/demo-comments_.html) demo for examples. 19725 * 19726 * @since 0.11.0 19727 * @type {Boolean|Array} 19728 * @default false 19729 * @example 19730 * ```js 19731 * ... 19732 * comments: [{row: 1, col: 1, comment: {value: "Test comment"}}], 19733 * ... 19734 * ``` 19735 */ 19736 comments: false, 19737 19738 /** 19739 * @description 19740 * If `true`, enables the Custom Borders plugin, which enables an option to apply custom borders through the context menu (configurable with context menu key `borders`). 19741 * 19742 * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array. 19743 * 19744 * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for examples. 19745 * 19746 * @since 0.11.0 19747 * @type {Boolean|Array} 19748 * @default false 19749 * @example 19750 * ```js 19751 * ... 19752 * customBorders: [ 19753 * {range: { 19754 * from: {row: 1, col: 1}, 19755 * to: {row: 3, col: 4}}, 19756 * left: {}, 19757 * right: {}, 19758 * top: {}, 19759 * bottom: {} 19760 * } 19761 * ], 19762 * ... 19763 * 19764 * // or 19765 * ... 19766 * customBorders: [ 19767 * {row: 2, col: 2, left: {width: 2, color: 'red'}, 19768 * right: {width: 1, color: 'green'}, top: '', bottom: ''} 19769 * ], 19770 * ... 19771 * ``` 19772 */ 19773 customBorders: false, 19774 19775 /** 19776 * Minimum number of rows. At least that number of rows will be created during initialization. 19777 * 19778 * @type {Number} 19779 * @default 0 19780 */ 19781 minRows: 0, 19782 19783 /** 19784 * Minimum number of columns. At least that number of columns will be created during initialization. 19785 * 19786 * @type {Number} 19787 * @default 0 19788 */ 19789 minCols: 0, 19790 19791 /** 19792 * Maximum number of rows. If set to a value lower than the initial row count, the data will be trimmed to the provided value as the number of rows. 19793 * 19794 * @type {Number} 19795 * @default Infinity 19796 */ 19797 maxRows: Infinity, 19798 19799 /** 19800 * Maximum number of cols. If set to a value lower than the initial col count, the data will be trimmed to the provided value as the number of cols. 19801 * 19802 * @type {Number} 19803 * @default Infinity 19804 */ 19805 maxCols: Infinity, 19806 19807 /** 19808 * When set to 1 (or more), Handsontable will add a new row at the end of grid if there are no more empty rows. 19809 * (unless the number of rows exceeds the one set in the `maxRows` property) 19810 * 19811 * @type {Number} 19812 * @default 0 19813 */ 19814 minSpareRows: 0, 19815 19816 /** 19817 * When set to 1 (or more), Handsontable will add a new column at the end of grid if there are no more empty columns. 19818 * (unless the number of rows exceeds the one set in the `maxCols` property) 19819 * 19820 * @type {Number} 19821 * @default 0 19822 */ 19823 minSpareCols: 0, 19824 19825 /** 19826 * If set to `false`, there won't be an option to insert new rows in the Context Menu. 19827 * 19828 * @type {Boolean} 19829 * @default true 19830 */ 19831 allowInsertRow: true, 19832 19833 /** 19834 * If set to `false`, there won't be an option to insert new columns in the Context Menu. 19835 * 19836 * @type {Boolean} 19837 * @default true 19838 */ 19839 allowInsertColumn: true, 19840 19841 /** 19842 * If set to `false`, there won't be an option to remove rows in the Context Menu. 19843 * 19844 * @type {Boolean} 19845 * @default true 19846 */ 19847 allowRemoveRow: true, 19848 19849 /** 19850 * If set to `false`, there won't be an option to remove columns in the Context Menu. 19851 * 19852 * @type {Boolean} 19853 * @default true 19854 */ 19855 allowRemoveColumn: true, 19856 19857 /** 19858 * If true, selection of multiple cells using keyboard or mouse is allowed. 19859 * 19860 * @type {Boolean} 19861 * @default true 19862 */ 19863 multiSelect: true, 19864 19865 /** 19866 * Enables the fill handle (drag-down and copy-down) functionality, which shows a small rectangle in bottom 19867 * right corner of the selected area, that let's you expand values to the adjacent cells. 19868 * 19869 * Possible values: `true` (to enable in all directions), `'vertical'` or `'horizontal'` (to enable in one direction), 19870 * `false` (to disable completely). Setting to `true` enables the fillHandle plugin. 19871 * 19872 * Since 0.23.0 you can pass object to plugin which allows you to add more options for this functionality. If `autoInsertRow` 19873 * option is `true`, fill-handler will create new rows till it reaches the last row. It is enabled by default. 19874 * 19875 * @example 19876 * ```js 19877 * ... 19878 * fillHandle: true // enable plugin in all directions and with autoInsertRow as true 19879 * ... 19880 * // or 19881 * ... 19882 * fillHandle: 'vertical' // enable plugin in vertical direction and with autoInsertRow as true 19883 * ... 19884 * // or 19885 * ... 19886 * fillHandle: { // enable plugin in both directions and with autoInsertRow as false 19887 * autoInsertRow: false, 19888 * } 19889 * // or 19890 * ... 19891 * fillHandle: { // enable plugin in vertical direction and with autoInsertRow as false 19892 * autoInsertRow: false, 19893 * direction: 'vertical' // 'vertical' or 'horizontal' 19894 * } 19895 * ``` 19896 * 19897 * @type {Boolean|String|Object} 19898 * @default true 19899 */ 19900 fillHandle: true, 19901 19902 /** 19903 * Allows to specify the number of fixed (or *frozen*) rows at the top of the table. 19904 * 19905 * @type {Number} 19906 * @default 0 19907 * @example 19908 * ```js 19909 * fixedRowsTop: 3 // This would freeze the top 3 rows of the table. 19910 * ``` 19911 */ 19912 fixedRowsTop: 0, 19913 19914 /** 19915 * Allows to specify the number of fixed (or *frozen*) rows at the bottom of the table. 19916 * 19917 * @pro 19918 * @type {Number} 19919 * @default 0 19920 * @example 19921 * ```js 19922 * fixedRowsBottom: 3 // This would freeze the top 3 rows of the table. 19923 * ``` 19924 */ 19925 fixedRowsBottom: 0, 19926 19927 /** 19928 * Allows to specify the number of fixed (or *frozen*) columns on the left of the table. 19929 * 19930 * @type {Number} 19931 * @default 0 19932 * @example 19933 * ```js 19934 * fixedColumnsLeft: 3 // This would freeze the top 3 rows of the table. 19935 * ``` 19936 */ 19937 fixedColumnsLeft: 0, 19938 19939 /** 19940 * If `true`, mouse click outside the grid will deselect the current selection. 19941 * Can be a function that takes the click event target and returns a boolean. 19942 * 19943 * @type {Boolean|Function} 19944 * @default true 19945 */ 19946 outsideClickDeselects: true, 19947 19948 /** 19949 * If `true`, <kbd>ENTER</kbd> begins editing mode (like in Google Docs). If `false`, <kbd>ENTER</kbd> moves to next 19950 * row (like Excel) and adds a new row if necessary. <kbd>TAB</kbd> adds new column if necessary. 19951 * 19952 * @type {Boolean} 19953 * @default true 19954 */ 19955 enterBeginsEditing: true, 19956 19957 /** 19958 * Defines the cursor movement after <kbd>ENTER</kbd> was pressed (<kbd>SHIFT</kbd> + <kbd>ENTER</kbd> uses a negative vector). 19959 * Can be an object or a function that returns an object. The event argument passed to the function 19960 * is a DOM Event object received after the <kbd>ENTER</kbd> key has been pressed. This event object can be used to check 19961 * whether user pressed <kbd>ENTER</kbd> or <kbd>SHIFT</kbd> + <kbd>ENTER</kbd>. 19962 * 19963 * @type {Object|Function} 19964 * @default {row: 1, col: 0} 19965 */ 19966 enterMoves: { row: 1, col: 0 }, 19967 19968 /** 19969 * Defines the cursor movement after <kbd>TAB</kbd> is pressed (<kbd>SHIFT</kbd> + <kbd>TAB</kbd> uses a negative vector). 19970 * Can be an object or a function that returns an object. The event argument passed to the function 19971 * is a DOM Event object received after the <kbd>TAB</kbd> key has been pressed. This event object can be used to check 19972 * whether user pressed <kbd>TAB</kbd> or <kbd>SHIFT</kbd> + <kbd>TAB</kbd>. 19973 * 19974 * @type {Object} 19975 * @default {row: 0, col: 1} 19976 */ 19977 tabMoves: { row: 0, col: 1 }, 19978 19979 /** 19980 * If `true`, pressing <kbd>TAB</kbd> or right arrow in the last column will move to first column in next row. 19981 * 19982 * @type {Boolean} 19983 * @default false 19984 */ 19985 autoWrapRow: false, 19986 19987 /** 19988 * If `true`, pressing <kbd>ENTER</kbd> or down arrow in the last row will move to the first row in the next column. 19989 * 19990 * @type {Boolean} 19991 * @default false 19992 */ 19993 autoWrapCol: false, 19994 19995 /** 19996 * @description 19997 * Turns on saving the state of column sorting, column positions and column sizes in local storage. 19998 * 19999 * You can save any sort of data in local storage to preserve table state between page reloads. 20000 * In order to enable data storage mechanism, `persistentState` option must be set to `true` (you can set it 20001 * either during Handsontable initialization or using the `updateSettings` method). When `persistentState` is enabled it exposes 3 hooks: 20002 * 20003 * __persistentStateSave__ (key: String, value: Mixed) 20004 * 20005 * * Saves value under given key in browser local storage. 20006 * 20007 * __persistentStateLoad__ (key: String, valuePlaceholder: Object) 20008 * 20009 * * Loads `value`, saved under given key, form browser local storage. The loaded `value` will be saved in `valuePlaceholder.value` 20010 * (this is due to specific behaviour of `Hooks.run()` method). If no value have been saved under key `valuePlaceholder.value` 20011 * will be `undefined`. 20012 * 20013 * __persistentStateReset__ (key: String) 20014 * 20015 * * Clears the value saved under `key`. If no `key` is given, all values associated with table will be cleared. 20016 * 20017 * __Note:__ The main reason behind using `persistentState` hooks rather than regular LocalStorage API is that it 20018 * ensures separation of data stored by multiple Handsontable instances. In other words, if you have two (or more) 20019 * instances of Handsontable on one page, data saved by one instance won't be accessible by the second instance. 20020 * Those two instances can store data under the same key and no data would be overwritten. 20021 * 20022 * __Important:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`. 20023 * 20024 * @type {Boolean} 20025 * @default false 20026 */ 20027 persistentState: void 0, 20028 20029 /** 20030 * Class name for all visible rows in the current selection. 20031 * 20032 * @type {String} 20033 * @default undefined 20034 * @example 20035 * ```js 20036 * currentRowClassName: 'currentRow' // This will add a 'currentRow' class name to appropriate table cells. 20037 * ``` 20038 */ 20039 currentRowClassName: void 0, 20040 20041 /** 20042 * Class name for all visible columns in the current selection. 20043 * 20044 * @type {String} 20045 * @default undefined 20046 * @example 20047 * ```js 20048 * currentColClassName: 'currentColumn' // This will add a 'currentColumn' class name to appropriate table cells. 20049 * ``` 20050 */ 20051 currentColClassName: void 0, 20052 20053 /** 20054 * Class name for all visible headers in current selection. 20055 * 20056 * @type {String} 20057 * @since 0.27.0 20058 * @default 'ht__highlight' 20059 * @example 20060 * ```js 20061 * currentHeaderClassName: 'ht__highlight' // This will add a 'ht__highlight' class name to appropriate table headers. 20062 * ``` 20063 */ 20064 currentHeaderClassName: 'ht__highlight', 20065 /** 20066 * Class name for the Handsontable container element. 20067 * 20068 * @type {String|Array} 20069 * @default undefined 20070 */ 20071 className: void 0, 20072 20073 /** 20074 * Class name for all tables inside container element. 20075 * 20076 * @since 0.17.0 20077 * @type {String|Array} 20078 * @default undefined 20079 */ 20080 tableClassName: void 0, 20081 20082 /** 20083 * @description 20084 * Defines how the columns react, when the declared table width is different than the calculated sum of all column widths. 20085 * [See more](http://docs.handsontable.com/demo-stretching.html) mode. Possible values: 20086 * * `'none'` Disable stretching 20087 * * `'last'` Stretch only the last column 20088 * * `'all'` Stretch all the columns evenly 20089 * 20090 * @type {String} 20091 * @default 'none' 20092 */ 20093 stretchH: 'none', 20094 20095 /** 20096 * Lets you overwrite the default `isEmptyRow` method, which checks if row at the provided index is empty. 20097 * 20098 * @type {Function} 20099 * @param {Number} row Visual row index. 20100 * @returns {Boolean} 20101 */ 20102 isEmptyRow: function isEmptyRow(row) { 20103 var col, colLen, value, meta; 20104 20105 for (col = 0, colLen = this.countCols(); col < colLen; col++) { 20106 value = this.getDataAtCell(row, col); 20107 20108 if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) { 20109 if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { 20110 meta = this.getCellMeta(row, col); 20111 20112 return (0, _object.isObjectEquals)(this.getSchema()[meta.prop], value); 20113 } 20114 return false; 20115 } 20116 } 20117 20118 return true; 20119 }, 20120 20121 20122 /** 20123 * Lets you overwrite the default `isEmptyCol` method, which checks if column at the provided index is empty. 20124 * 20125 * @type {Function} 20126 * @param {Number} col Visual column index 20127 * @returns {Boolean} 20128 */ 20129 isEmptyCol: function isEmptyCol(col) { 20130 var row, rowLen, value; 20131 20132 for (row = 0, rowLen = this.countRows(); row < rowLen; row++) { 20133 value = this.getDataAtCell(row, col); 20134 20135 if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) { 20136 return false; 20137 } 20138 } 20139 20140 return true; 20141 }, 20142 20143 20144 /** 20145 * When set to `true`, the table is re-rendered when it is detected that it was made visible in DOM. 20146 * 20147 * @type {Boolean} 20148 * @default true 20149 */ 20150 observeDOMVisibility: true, 20151 20152 /** 20153 * If set to `true`, Handsontable will accept values that were marked as invalid by the cell `validator`. 20154 * It will result with *invalid* cells being treated as *valid* (will save the *invalid* value into the Handsontable data source). 20155 * If set to `false`, Handsontable will *not* accept the invalid values and won't allow the user to close the editor. 20156 * This option will be particularly useful when used with the Autocomplete's `strict` mode. 20157 * 20158 * @type {Boolean} 20159 * @default true 20160 * @since 0.9.5 20161 */ 20162 allowInvalid: true, 20163 20164 /** 20165 * If set to `true`, Handsontable will accept values that are empty (`null`, `undefined` or `''`). 20166 * If set to `false`, Handsontable will *not* accept the empty values and mark cell as invalid. 20167 * 20168 * @example 20169 * ```js 20170 * ... 20171 * allowEmpty: true // allow empty values for all cells (whole table) 20172 * ... 20173 * // or 20174 * ... 20175 * columns: [ 20176 * // allow empty values only for 'date' column 20177 * {data: 'date', dateFormat: 'DD/MM/YYYY', allowEmpty: true} 20178 * ] 20179 * ... 20180 * ``` 20181 * 20182 * @type {Boolean} 20183 * @default true 20184 * @since 0.23.0 20185 */ 20186 allowEmpty: true, 20187 20188 /** 20189 * CSS class name for cells that did not pass validation. 20190 * 20191 * @type {String} 20192 * @default 'htInvalid' 20193 */ 20194 invalidCellClassName: 'htInvalid', 20195 20196 /** 20197 * When set to an non-empty string, displayed as the cell content for empty cells. If a value of a different type is provided, 20198 * it will be stringified and applied as a string. 20199 * 20200 * @type {Mixed} 20201 * @default false 20202 */ 20203 placeholder: false, 20204 20205 /** 20206 * CSS class name for cells that have a placeholder in use. 20207 * 20208 * @type {String} 20209 * @default 'htPlaceholder' 20210 */ 20211 placeholderCellClassName: 'htPlaceholder', 20212 20213 /** 20214 * CSS class name for read-only cells. 20215 * 20216 * @type {String} 20217 * @default 'htDimmed' 20218 */ 20219 readOnlyCellClassName: 'htDimmed', 20220 20221 /** 20222 * @description 20223 * If a string is provided, it may be one of the following predefined values: 20224 * * `autocomplete`, 20225 * * `checkbox`, 20226 * * `html`, 20227 * * `numeric`, 20228 * * `password`. 20229 * * `text`. 20230 * 20231 * Or you can [register](http://docs.handsontable.com/demo-custom-renderers.html) the custom renderer under specified name and use 20232 * its name as an alias in your configuration. 20233 * 20234 * If a function is provided, it will receive the following arguments: 20235 * ```js 20236 * function(instance, TD, row, col, prop, value, cellProperties) {} 20237 * ``` 20238 * 20239 * You can read more about custom renderes [in the documentation](http://docs.handsontable.com/demo-custom-renderers.html). 20240 * 20241 * @example 20242 * ```js 20243 * ... 20244 * Handsontable.renderers.registerRenderer('my.renderer', function(instance, TD, row, col, prop, value, cellProperties) { 20245 * TD.innerHTML = value; 20246 * }); 20247 * ... 20248 * columns: [ 20249 * { 20250 * editor: 'select', 20251 * renderer: 'autocomplete' // as string 20252 * }, 20253 * { 20254 * renderer: 'my.renderer' // custom renderer as an alias 20255 * }, 20256 * { 20257 * // renderer as custom function 20258 * renderer: function(hotInstance, TD, row, col, prop, value, cellProperties) { 20259 * TD.style.color = 'blue'; 20260 * TD.innerHTML = value; 20261 * } 20262 * } 20263 * ] 20264 * ... 20265 * ``` 20266 * 20267 * @type {String|Function} 20268 * @default undefined 20269 */ 20270 renderer: void 0, 20271 20272 /** 20273 * CSS class name added to the commented cells. 20274 * 20275 * @type {String} 20276 * @default 'htCommentCell' 20277 */ 20278 commentedCellClassName: 'htCommentCell', 20279 20280 /** 20281 * If set to `true`, it enables the browser's native selection of a fragment of the text within a single cell, between adjacent cells or in a whole table. 20282 * If set to `'cell'`, it enables the possibility of selecting a fragment of the text within a single cell's body. 20283 * 20284 * @type {Boolean|String} 20285 * @default false 20286 */ 20287 fragmentSelection: false, 20288 20289 /** 20290 * @description 20291 * Make cell [read only](http://docs.handsontable.com/demo-read-only.html). 20292 * 20293 * @type {Boolean} 20294 * @default false 20295 */ 20296 readOnly: false, 20297 20298 /** 20299 * @description 20300 * When added to a `column` property, it skips the column on paste and pastes the data on the next column to the right. 20301 * 20302 * @type {Boolean} 20303 * @default false 20304 */ 20305 skipColumnOnPaste: false, 20306 20307 /** 20308 * @description 20309 * Setting to true enables the search plugin (see [demo](http://docs.handsontable.com/demo-search-for-values.html)). 20310 * 20311 * @type {Boolean} 20312 * @default false 20313 */ 20314 search: false, 20315 20316 /** 20317 * @description 20318 * Shortcut to define the combination of the cell renderer, editor and validator for the column, cell or whole table. 20319 * 20320 * Possible values: 20321 * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html) 20322 * * [checkbox](http://docs.handsontable.com/demo-checkbox.html) 20323 * * [date](http://docs.handsontable.com/demo-date.html) 20324 * * [dropdown](http://docs.handsontable.com/demo-dropdown.html) 20325 * * [handsontable](http://docs.handsontable.com/demo-handsontable.html) 20326 * * [numeric](http://docs.handsontable.com/demo-numeric.html) 20327 * * [password](http://docs.handsontable.com/demo-password.html) 20328 * * text 20329 * * [time](http://docs.handsontable.com/demo-time.html) 20330 * 20331 * Or you can register the custom cell type under specified name and use 20332 * its name as an alias in your configuration. 20333 * 20334 * @example 20335 * ```js 20336 * ... 20337 * Handsontable.cellTypes.registerCellType('my.type', { 20338 * editor: MyEditorClass, 20339 * renderer: function(hot, td, row, col, prop, value, cellProperties) { 20340 * td.innerHTML = value; 20341 * }, 20342 * validator: function(value, callback) { 20343 * callback(value === 'foo' ? true : false); 20344 * } 20345 * }); 20346 * ... 20347 * columns: [ 20348 * { 20349 * type: 'text' 20350 * }, 20351 * { 20352 * type: 'my.type' // an alias to custom type 20353 * }, 20354 * { 20355 * type: 'checkbox' 20356 * } 20357 * ] 20358 * ... 20359 * ``` 20360 * 20361 * @type {String} 20362 * @default 'text' 20363 */ 20364 type: 'text', 20365 20366 /** 20367 * @description 20368 * Make cell copyable (pressing <kbd>CTRL</kbd> + <kbd>C</kbd> on your keyboard moves its value to system clipboard). 20369 * 20370 * __Note:__ this setting is `false` by default for cells with type `password`. 20371 * 20372 * @type {Boolean} 20373 * @default true 20374 * @since 0.10.2 20375 */ 20376 copyable: true, 20377 20378 /** 20379 * Defines the editor for the table/column/cell. 20380 * 20381 * If a string is provided, it may be one of the following predefined values: 20382 * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html) 20383 * * [checkbox](http://docs.handsontable.com/demo-checkbox.html) 20384 * * [date](http://docs.handsontable.com/demo-date.html) 20385 * * [dropdown](http://docs.handsontable.com/demo-dropdown.html) 20386 * * [handsontable](http://docs.handsontable.com/demo-handsontable.html) 20387 * * [mobile](http://docs.handsontable.com/demo-mobiles-and-tablets.html) 20388 * * [password](http://docs.handsontable.com/demo-password.html) 20389 * * [select](http://docs.handsontable.com/demo-select.html) 20390 * * text 20391 * 20392 * Or you can [register](http://docs.handsontable.com/tutorial-cell-editor.html#registering-an-editor) the custom editor under specified name and use 20393 * its name as an alias in your configuration. 20394 * 20395 * To disable cell editing completely set `editor` property to `false`. 20396 * 20397 * @example 20398 * ```js 20399 * ... 20400 * columns: [ 20401 * { 20402 * editor: 'select' 20403 * }, 20404 * { 20405 * editor: false 20406 * } 20407 * ] 20408 * ... 20409 * ``` 20410 * 20411 * @type {String|Function|Boolean} 20412 * @default 'text' 20413 */ 20414 editor: void 0, 20415 20416 /** 20417 * @description 20418 * Autocomplete definitions. See [autocomplete demo](http://docs.handsontable.com/demo-autocomplete.html) for examples and definitions. 20419 * 20420 * @type {Array} 20421 * @default undefined 20422 */ 20423 autoComplete: void 0, 20424 20425 /** 20426 * Control number of choices for the autocomplete (or dropdown) typed cells. After exceeding it, a scrollbar for the dropdown list of choices will appear. 20427 * 20428 * @since 0.18.0 20429 * @type {Number} 20430 * @default 10 20431 */ 20432 visibleRows: 10, 20433 20434 /** 20435 * Makes autocomplete or dropdown width the same as the edited cell width. If `false` then editor will be scaled 20436 * according to its content. 20437 * 20438 * @since 0.17.0 20439 * @type {Boolean} 20440 * @default true 20441 */ 20442 trimDropdown: true, 20443 20444 /** 20445 * Setting to true enables the debug mode, currently used to test the correctness of the row and column 20446 * header fixed positioning on a layer above the master table. 20447 * 20448 * @type {Boolean} 20449 * @default false 20450 */ 20451 debug: false, 20452 20453 /** 20454 * When set to `true`, the text of the cell content is wrapped if it does not fit in the fixed column width. 20455 * 20456 * @type {Boolean} 20457 * @default true 20458 * @since 0.11.0 20459 */ 20460 wordWrap: true, 20461 20462 /** 20463 * CSS class name added to cells with cell meta `wordWrap: false`. 20464 * 20465 * @type {String} 20466 * @default 'htNoWrap' 20467 * @since 0.11.0 20468 */ 20469 noWordWrapClassName: 'htNoWrap', 20470 20471 /** 20472 * @description 20473 * Defines if the right-click context menu should be enabled. Context menu allows to create new row or 20474 * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html). 20475 * Possible values: 20476 * * `true` (to enable default options), 20477 * * `false` (to disable completely) 20478 * * an array of [predefined options](https://docs.handsontable.com/demo-context-menu.html#page-specific), 20479 * * an object [with defined structure](http://docs.handsontable.com/demo-context-menu.html#page-custom) 20480 * 20481 * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples. 20482 * 20483 * @example 20484 * ```js 20485 * ... 20486 * // as a boolean 20487 * contextMenu: true 20488 * ... 20489 * // as an array 20490 * contextMenu: ['row_above', 'row_below', '--------', 'undo', 'redo'] 20491 * ... 20492 * ``` 20493 * ... 20494 * // as an object (`name` attribute is required in the custom keys) 20495 * contextMenu: { 20496 * items: { 20497 * "option1": { 20498 * name: "option1" 20499 * }, 20500 * "option2": { 20501 * name: "option2", 20502 * submenu: { 20503 * items: [ 20504 * { 20505 * key: "option2:suboption1", 20506 * name: "option2:suboption1", 20507 * callback: function(key, options) { 20508 * ... 20509 * } 20510 * }, 20511 * ... 20512 * ] 20513 * } 20514 * } 20515 * } 20516 * } 20517 * ... 20518 * ``` 20519 * @type {Boolean|Array|Object} 20520 * @default undefined 20521 */ 20522 contextMenu: void 0, 20523 20524 /** 20525 * @description 20526 * Disable or enable the copy/paste functionality. 20527 * 20528 * @example 20529 * ```js 20530 * ... 20531 * copyPaste: false, 20532 * ... 20533 * ``` 20534 * 20535 * @type {Boolean} 20536 * @default true 20537 */ 20538 copyPaste: true, 20539 20540 /** 20541 * If `true`, undo/redo functionality is enabled. 20542 * 20543 * @type {Boolean} 20544 * @default undefined 20545 */ 20546 undo: void 0, 20547 20548 /** 20549 * @description 20550 * Turns on [Column sorting](http://docs.handsontable.com/demo-sorting-data.html). 20551 * Can be either a boolean (true/false) or an object with a declared sorting options. See the below example: 20552 * 20553 * @example 20554 * ```js 20555 * ... 20556 * // as boolean 20557 * columnSorting: true 20558 * ... 20559 * // as a object with initial order (sort ascending column at index 2) 20560 * columnSorting: { 20561 * column: 2, 20562 * sortOrder: true, // true = ascending, false = descending, undefined = original order 20563 * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table 20564 * } 20565 * ... 20566 * ``` 20567 * 20568 * @type {Boolean|Object} 20569 * @default undefined 20570 */ 20571 columnSorting: void 0, 20572 20573 /** 20574 * @description 20575 * Turns on [Manual column move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial 20576 * column order, if set to an array of column indexes. 20577 * 20578 * @example 20579 * ```js 20580 * ... 20581 * // as boolean 20582 * manualColumnMove: true 20583 * ... 20584 * // as a array with initial order (move column index at 0 to 1 and move column index at 1 to 4) 20585 * manualColumnMove: [1, 4] 20586 * ... 20587 * ``` 20588 * 20589 * @type {Boolean|Array} 20590 * @default undefined 20591 */ 20592 manualColumnMove: void 0, 20593 20594 /** 20595 * @description 20596 * Turns on [Manual column resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial 20597 * column resized widths, if set to an array of numbers. 20598 * 20599 * @example 20600 * ```js 20601 * ... 20602 * // as boolean 20603 * manualColumnResize: true 20604 * ... 20605 * // as a array with initial widths (column at 0 index has 40px and column at 1 index has 50px) 20606 * manualColumnResize: [40, 50] 20607 * ... 20608 * ``` 20609 * 20610 * @type {Boolean|Array} 20611 * @default undefined 20612 */ 20613 manualColumnResize: void 0, 20614 20615 /** 20616 * @description 20617 * Turns on [Manual row move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial 20618 * row order, if set to an array of row indexes. 20619 * 20620 * @example 20621 * ```js 20622 * ... 20623 * // as boolean 20624 * manualRowMove: true 20625 * ... 20626 * // as a array with initial order (move row index at 0 to 1 and move row index at 1 to 4) 20627 * manualRowMove: [1, 4] 20628 * ... 20629 * ``` 20630 * 20631 * @type {Boolean|Array} 20632 * @default undefined 20633 * @since 0.11.0 20634 */ 20635 manualRowMove: void 0, 20636 20637 /** 20638 * @description 20639 * Turns on [Manual row resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial 20640 * row resized heights, if set to an array of numbers. 20641 * 20642 * @example 20643 * ```js 20644 * ... 20645 * // as boolean 20646 * manualRowResize: true 20647 * ... 20648 * // as a array with initial heights (row at 0 index has 40px and row at 1 index has 50px) 20649 * manualRowResize: [40, 50] 20650 * ... 20651 * ``` 20652 * 20653 * @type {Boolean|Array} 20654 * @default undefined 20655 * @since 0.11.0 20656 */ 20657 manualRowResize: void 0, 20658 20659 /** 20660 * @description 20661 * If set to `true`, it enables a possibility to merge cells. If set to an array of objects, it merges the cells provided in the objects (see the example below). 20662 * [More information on the demo page.](http://docs.handsontable.com/demo-merge-cells.html) 20663 * 20664 * @example 20665 * ```js 20666 * // enables the mergeCells plugin: 20667 * margeCells: true 20668 * ... 20669 * // declares a list of merged sections: 20670 * mergeCells: [ 20671 * {row: 1, col: 1, rowspan: 3, colspan: 3}, // rowspan and colspan properties declare the width and height of a merged section in cells 20672 * {row: 3, col: 4, rowspan: 2, colspan: 2}, 20673 * {row: 5, col: 6, rowspan: 3, colspan: 3} 20674 * ] 20675 * ``` 20676 * @type {Boolean|Array} 20677 * @default false 20678 */ 20679 mergeCells: false, 20680 20681 /** 20682 * Number of rows to be rendered outside of the visible part of the table. 20683 * By default, it's set to `'auto'`, which makes Handsontable to attempt to calculate the best offset performance-wise. 20684 * 20685 * You may test out different values to find the best one that works for your specific implementation. 20686 * 20687 * @type {Number|String} 20688 * @default 'auto' 20689 */ 20690 viewportRowRenderingOffset: 'auto', 20691 20692 /** 20693 * Number of columns to be rendered outside of the visible part of the table. 20694 * By default, it's set to `'auto'`, which makes Handsontable try calculating the best offset performance-wise. 20695 * 20696 * You may experiment with the value to find the one that works best for your specific implementation. 20697 * 20698 * @type {Number|String} 20699 * @default 'auto' 20700 */ 20701 viewportColumnRenderingOffset: 'auto', 20702 20703 /** 20704 * A function, regular expression or a string, which will be used in the process of cell validation. 20705 * If a function is used, be sure to execute the callback argument with either `true` (`callback(true)`) if the validation passed 20706 * or with `false` (`callback(false)`), if the validation failed. 20707 * Note, that `this` in the function points to the `cellProperties` object. 20708 * 20709 * If a string is provided, it may be one of the following predefined values: 20710 * * `autocomplete`, 20711 * * `date`, 20712 * * `numeric`, 20713 * * `time`. 20714 * 20715 * Or you can [register](http://docs.handsontable.com/demo-data-validation.html) the validator function under specified name and use 20716 * its name as an alias in your configuration. 20717 * 20718 * See more [in the demo](http://docs.handsontable.com/demo-data-validation.html). 20719 * 20720 * @example 20721 * ```js 20722 * // as a function 20723 * columns: [ 20724 * { 20725 * validator: function(value, callback) { // validation rules } 20726 * } 20727 * ] 20728 * ... 20729 * // as a regexp 20730 * columns: [ 20731 * { 20732 * validator: /^[0-9]$/ // regular expression 20733 * } 20734 * ] 20735 * // as a string 20736 * columns: [ 20737 * { 20738 * validator: 'numeric' 20739 * } 20740 * ] 20741 * ``` 20742 * @type {Function|RegExp|String} 20743 * @default undefined 20744 * @since 0.9.5 20745 */ 20746 validator: void 0, 20747 20748 /** 20749 * @description 20750 * Disable visual cells selection. 20751 * 20752 * Possible values: 20753 * * `true` - Disables any type of visual selection (current and area selection), 20754 * * `false` - Enables any type of visual selection. This is default value. 20755 * * `current` - Disables the selection of a currently selected cell, the area selection is still present. 20756 * * `area` - Disables the area selection, the currently selected cell selection is still present. 20757 * 20758 * @type {Boolean|String|Array} 20759 * @default false 20760 * @since 0.13.2 20761 * @example 20762 * ```js 20763 * ... 20764 * // as boolean 20765 * disableVisualSelection: true, 20766 * ... 20767 * 20768 * ... 20769 * // as string ('current' or 'area') 20770 * disableVisualSelection: 'current', 20771 * ... 20772 * 20773 * ... 20774 * // as array 20775 * disableVisualSelection: ['current', 'area'], 20776 * ... 20777 * ``` 20778 */ 20779 disableVisualSelection: false, 20780 20781 /** 20782 * @description 20783 * Set whether to display the current sorting order indicator (a triangle icon in the column header, specifying the sorting order). 20784 * 20785 * @type {Boolean} 20786 * @default false 20787 * @since 0.15.0-beta3 20788 */ 20789 sortIndicator: void 0, 20790 20791 /** 20792 * Disable or enable ManualColumnFreeze plugin. 20793 * 20794 * @type {Boolean} 20795 * @default false 20796 */ 20797 manualColumnFreeze: void 0, 20798 20799 /** 20800 * @description 20801 * Defines whether Handsontable should trim the whitespace at the beginning and the end of the cell contents. 20802 * 20803 * @type {Boolean} 20804 * @default true 20805 */ 20806 trimWhitespace: true, 20807 20808 settings: void 0, 20809 20810 /** 20811 * @description 20812 * Defines data source for Autocomplete or Dropdown cell types. 20813 * 20814 * @example 20815 * ```js 20816 * ... 20817 * // source as a array 20818 * columns: [{ 20819 * type: 'autocomplete', 20820 * source: ['A', 'B', 'C', 'D'] 20821 * }] 20822 * ... 20823 * // source as a function 20824 * columns: [{ 20825 * type: 'autocomplete', 20826 * source: function(query, callback) { 20827 * fetch('http://example.com/query?q=' + query, function(response) { 20828 * callback(response.items); 20829 * }) 20830 * } 20831 * }] 20832 * ... 20833 * ``` 20834 * 20835 * @type {Array|Function} 20836 * @default undefined 20837 */ 20838 source: void 0, 20839 20840 /** 20841 * @description 20842 * Defines the column header name. 20843 * 20844 * @example 20845 * ```js 20846 * ... 20847 * columns: [{ 20848 * title: 'First name', 20849 * type: 'text', 20850 * }, 20851 * { 20852 * title: 'Last name', 20853 * type: 'text', 20854 * }] 20855 * ... 20856 * ``` 20857 * 20858 * @type {String} 20859 * @default undefined 20860 */ 20861 title: void 0, 20862 20863 /** 20864 * Data template for `'checkbox'` type when checkbox is checked. 20865 * 20866 * @example 20867 * ```js 20868 * checkedTemplate: 'good' 20869 * 20870 * // if a checkbox-typed cell is checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell 20871 * // will return 'good'. 20872 * ``` 20873 * @type {Boolean|String} 20874 * @default true 20875 */ 20876 checkedTemplate: void 0, 20877 20878 /** 20879 * Data template for `'checkbox'` type when checkbox is unchecked. 20880 * 20881 * @example 20882 * ```js 20883 * uncheckedTemplate: 'bad' 20884 * 20885 * // if a checkbox-typed cell is not checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell 20886 * // will return 'bad'. 20887 * ``` 20888 * @type {Boolean|String} 20889 * @default false 20890 */ 20891 uncheckedTemplate: void 0, 20892 20893 /** 20894 * @description 20895 * Object which describes if renderer should create checkbox element with label element as a parent. Option desired for 20896 * [checkbox](http://docs.handsontable.com/demo-checkbox.html)-typed cells. 20897 * 20898 * By default the [checkbox](http://docs.handsontable.com/demo-checkbox.html) renderer renders the checkbox without a label. 20899 * 20900 * Possible object properties: 20901 * * `property` - Defines the property name of the data object, which will to be used as a label. 20902 * (eg. `label: {property: 'name.last'}`). This option works only if data was passed as an array of objects. 20903 * * `position` - String which describes where to place the label text (before or after checkbox element). 20904 * Valid values are `'before'` and '`after`' (defaults to `'after'`). 20905 * * `value` - String or a Function which will be used as label text. 20906 * 20907 * @example 20908 * ```js 20909 * ... 20910 * columns: [{ 20911 * type: 'checkbox', 20912 * label: {position: 'after', value: 'My label: '} 20913 * }] 20914 * ... 20915 * ``` 20916 * 20917 * @since 0.19.0 20918 * @type {Object} 20919 * @default undefined 20920 */ 20921 label: void 0, 20922 20923 /** 20924 * Display format. See [numbrojs](http://numbrojs.com). This option is desired for 20925 * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells. 20926 * 20927 * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting. 20928 * 20929 * @example 20930 * ```js 20931 * ... 20932 * columns: [{ 20933 * type: 'numeric', 20934 * format: '0,00' 20935 * }] 20936 * ... 20937 * ``` 20938 * 20939 * @type {String} 20940 * @default '0' 20941 */ 20942 format: void 0, 20943 20944 /** 20945 * Language display format. See [numbrojs](http://numbrojs.com/languages.html#supported-languages). This option is desired for 20946 * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells. 20947 * 20948 * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting. 20949 * 20950 * @example 20951 * ```js 20952 * ... 20953 * columns: [{ 20954 * type: 'numeric', 20955 * language: 'en-US' 20956 * }] 20957 * ... 20958 * ``` 20959 * 20960 * @type {String} 20961 * @default 'en-US' 20962 */ 20963 language: void 0, 20964 20965 /** 20966 * @description 20967 * Data source for [select](http://docs.handsontable.com/demo-select.html)-typed cells. 20968 * 20969 * @example 20970 * ```js 20971 * ... 20972 * columns: [{ 20973 * editor: 'select', 20974 * selectOptions: ['A', 'B', 'C'], 20975 * }] 20976 * ... 20977 * ``` 20978 * 20979 * @type {Array} 20980 */ 20981 selectOptions: void 0, 20982 20983 /** 20984 * Enables or disables the autoColumnSize plugin. Default value is `undefined`, which has the same effect as `true`. 20985 * Disabling this plugin can increase performance, as no size-related calculations would be done. 20986 * 20987 * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and 20988 * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't 20989 * block the browser UI. 20990 * 20991 * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value. 20992 * `syncLimit` option is available since 0.16.0. 20993 * 20994 * You can also use the `useHeaders` option to take the column headers with into calculation. 20995 * 20996 * @example 20997 * ```js 20998 * ... 20999 * // as a number (300 columns in sync, rest async) 21000 * autoColumnSize: {syncLimit: 300}, 21001 * ... 21002 * 21003 * ... 21004 * // as a string (percent) 21005 * autoColumnSize: {syncLimit: '40%'}, 21006 * ... 21007 * 21008 * ... 21009 * // use headers width while calculation the column width 21010 * autoColumnSize: {useHeaders: true}, 21011 * ... 21012 * 21013 * ``` 21014 * 21015 * @type {Object|Boolean} 21016 * @default {syncLimit: 50} 21017 */ 21018 autoColumnSize: void 0, 21019 21020 /** 21021 * Enables or disables autoRowSize plugin. Default value is `undefined`, which has the same effect as `false` (disabled). 21022 * Enabling this plugin can decrease performance, as size-related calculations would be performed. 21023 * 21024 * Row height calculations are divided into sync and async stages. Each of these stages has their own advantages and 21025 * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't 21026 * block the browser UI. 21027 * 21028 * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value. 21029 * `syncLimit` options is available since 0.16.0. 21030 * 21031 * @example 21032 * ```js 21033 * ... 21034 * // as number (300 columns in sync, rest async) 21035 * autoRowSize: {syncLimit: 300}, 21036 * ... 21037 * 21038 * ... 21039 * // as string (percent) 21040 * autoRowSize: {syncLimit: '40%'}, 21041 * ... 21042 * ``` 21043 * @type {Object|Boolean} 21044 * @default {syncLimit: 1000} 21045 */ 21046 autoRowSize: void 0, 21047 21048 /** 21049 * Date validation format. 21050 * 21051 * Option desired for `'date'` - typed cells. 21052 * 21053 * @example 21054 * ```js 21055 * ... 21056 * columns: [{ 21057 * type: 'date', 21058 * dateFormat: 'MM/DD/YYYY' 21059 * }] 21060 * ... 21061 * ``` 21062 * 21063 * @type {String} 21064 * @default 'DD/MM/YYYY' 21065 */ 21066 dateFormat: void 0, 21067 21068 /** 21069 * If `true` then dates will be automatically formatted to match the desired format. 21070 * 21071 * Option desired for `'date'`-typed typed cells. 21072 * 21073 * @example 21074 * ```js 21075 * ... 21076 * columns: [{ 21077 * type: 'date', 21078 * dateFormat: 'YYYY-MM-DD', 21079 * correctFormat: true 21080 * }] 21081 * ... 21082 * ``` 21083 * 21084 * @type {Boolean} 21085 * @default false 21086 */ 21087 correctFormat: false, 21088 21089 /** 21090 * Definition of default value which will fill the empty cells. 21091 * 21092 * Option desired for `'date'`-typed cells. 21093 * 21094 * @example 21095 * ```js 21096 * ... 21097 * columns: [{ 21098 * type: 'date', 21099 * defaultData: '2015-02-02' 21100 * }] 21101 * ... 21102 * ``` 21103 * 21104 * @type {String} 21105 */ 21106 defaultDate: void 0, 21107 21108 /** 21109 * If set to `true`, the value entered into the cell must match (case-sensitive) the autocomplete source. Otherwise, cell won't pass the validation. 21110 * When filtering the autocomplete source list, the editor will be working in case-insensitive mode. 21111 * 21112 * Option desired for `autocomplete`-typed cells. 21113 * 21114 * @example 21115 * ```js 21116 * ... 21117 * columns: [{ 21118 * type: 'autocomplete', 21119 * source: ['A', 'B', 'C'], 21120 * strict: true 21121 * }] 21122 * ... 21123 * ``` 21124 * 21125 * @type {Boolean} 21126 */ 21127 strict: void 0, 21128 21129 /** 21130 * @description 21131 * If typed `true`, data defined in `source` of the autocomplete or dropdown cell will be treated as HTML. 21132 * 21133 * __Warning:__ Enabling this option can cause serious XSS vulnerabilities. 21134 * 21135 * Option desired for `'autocomplete'`-typed cells. 21136 * @example 21137 * ```js 21138 * ... 21139 * columns: [{ 21140 * type: 'autocomplete', 21141 * allowHtml: true, 21142 * source: ['<b>foo</b>', '<b>bar</b>'] 21143 * }] 21144 * ... 21145 * ``` 21146 * @type {Boolean} 21147 * @default false 21148 */ 21149 allowHtml: false, 21150 21151 /** 21152 * If typed `true` then virtual rendering mechanism for handsontable will be disabled. 21153 * 21154 * @type {Boolean} 21155 */ 21156 renderAllRows: void 0, 21157 21158 /** 21159 * Prevents table to overlap outside the parent element. If `'horizontal'` option is chosen then table will appear horizontal 21160 * scrollbar in case where parent's width is narrower then table's width. 21161 * 21162 * Possible values: 21163 * * `false` - Disables functionality (Default option). 21164 * * `horizontal` - Prevents horizontal overflow table. 21165 * * `vertical` - Prevents vertical overflow table (Not implemented yet). 21166 * 21167 * @since 0.20.3 21168 * @example 21169 * ```js 21170 * ... 21171 * preventOverflow: 'horizontal' 21172 * ... 21173 * ``` 21174 * 21175 * @type {String|Boolean} 21176 */ 21177 preventOverflow: false, 21178 21179 /** 21180 * @description 21181 * Plugin allowing binding the table rows with their headers. 21182 * If the plugin is enabled, the table row headers will "stick" to the rows, when they are hidden/moved. Basically, if at the initialization 21183 * row 0 has a header titled "A", it will have it no matter what you do with the table. 21184 * 21185 * @pro 21186 * @since 1.0.0-beta1 21187 * @type {Boolean|String} 21188 * @example 21189 * 21190 * ```js 21191 * ... 21192 * var hot = new Handsontable(document.getElementById('example'), { 21193 * date: getData(), 21194 * bindRowsWithHeaders: true 21195 * }); 21196 * ... 21197 * ``` 21198 * 21199 */ 21200 bindRowsWithHeaders: void 0, 21201 21202 /** 21203 * @description 21204 * The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the `colspan` property defined. 21205 * 21206 * Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one. 21207 * 21208 * Setting the `collapsibleColumns` property to `true` will display a "collapse/expand" button in every header with a defined 21209 * `colspan` property. 21210 * 21211 * To limit this functionality to a smaller group of headers, define the `collapsibleColumns` property as an array of objects, as in 21212 * the example below. 21213 * 21214 * @pro 21215 * @since 1.0.0-beta1 21216 * @type {Boolean|Array} 21217 * @example 21218 * ```js 21219 * ... 21220 * collapsibleColumns: [ 21221 * {row: -4, col: 1, collapsible: true}, 21222 * {row: -3, col: 5, collapsible: true} 21223 * ] 21224 * ... 21225 * // or 21226 * ... 21227 * collapsibleColumns: true 21228 * ... 21229 * ``` 21230 */ 21231 collapsibleColumns: void 0, 21232 21233 /** 21234 * @description 21235 * Allows making pre-defined calculations on the cell values and display the results within Handsontable. 21236 * See the demo for more information. 21237 * 21238 * @pro 21239 * @since 1.0.0-beta1 21240 * @type {Object} 21241 */ 21242 columnSummary: void 0, 21243 21244 /** 21245 * This plugin allows adding a configurable dropdown menu to the table's column headers. 21246 * The dropdown menu acts like the Context Menu, but is triggered by clicking the button in the header. 21247 * 21248 * @pro 21249 * @since 1.0.0-beta1 21250 * @type {Boolean|Object|Array} 21251 */ 21252 dropdownMenu: void 0, 21253 21254 /** 21255 * The filters plugin. 21256 * It allows filtering the table data either by the built-in component or with the API. 21257 * 21258 * @pro 21259 * @since 1.0.0-beta1 21260 * @type {Boolean} 21261 */ 21262 filters: void 0, 21263 21264 /** 21265 * It allows Handsontable to process formula expressions defined in the provided data. 21266 * 21267 * @pro 21268 * @since 1.7.0 21269 * @type {Boolean} 21270 */ 21271 formulas: void 0, 21272 21273 /** 21274 * @description 21275 * GanttChart plugin enables a possibility to create a Gantt chart using a Handsontable instance. 21276 * In this case, the whole table becomes read-only. 21277 * 21278 * @pro 21279 * @since 1.0.0-beta1 21280 * @type {Object} 21281 */ 21282 ganttChart: void 0, 21283 21284 /** 21285 * @description 21286 * Allows adding a tooltip to the table headers. 21287 * 21288 * Available options: 21289 * * the `rows` property defines if tooltips should be added to row headers, 21290 * * the `columns` property defines if tooltips should be added to column headers, 21291 * * the `onlyTrimmed` property defines if tooltips should be added only to headers, which content is trimmed by the header itself (the content being wider then the header). 21292 * 21293 * @pro 21294 * @since 1.0.0-beta1 21295 * @type {Boolean|Object} 21296 */ 21297 headerTooltips: void 0, 21298 21299 /** 21300 * Plugin allowing hiding of certain columns. 21301 * 21302 * @pro 21303 * @since 1.0.0-beta1 21304 * @type {Boolean|Object} 21305 */ 21306 hiddenColumns: void 0, 21307 21308 /** 21309 * @description 21310 * Plugin allowing hiding of certain rows. 21311 * 21312 * @pro 21313 * @since 1.0.0-beta1 21314 * @type {Boolean|Object} 21315 */ 21316 hiddenRows: void 0, 21317 21318 /** 21319 * @description 21320 * Allows creating a nested header structure, using the HTML's colspan attribute. 21321 * 21322 * @pro 21323 * @since 1.0.0-beta1 21324 * @type {Array} 21325 */ 21326 nestedHeaders: void 0, 21327 21328 /** 21329 * @description 21330 * Plugin allowing hiding of certain rows. 21331 * 21332 * @pro 21333 * @since 1.0.0-beta1 21334 * @type {Boolean|Array} 21335 */ 21336 trimRows: void 0, 21337 21338 /** 21339 * @description 21340 * Allows setting a custom width of the row headers. You can provide a number or an array of widths, if many row header levels are defined. 21341 * 21342 * @since 0.22.0 21343 * @type {Number|Array} 21344 */ 21345 rowHeaderWidth: void 0, 21346 21347 /** 21348 * @description 21349 * Allows setting a custom height of the column headers. You can provide a number or an array of heights, if many column header levels are defined. 21350 * 21351 * @since 0.22.0 21352 * @type {Number|Array} 21353 */ 21354 columnHeaderHeight: void 0, 21355 21356 /** 21357 * @description 21358 * Enabling this plugin switches table into one-way data binding where changes are applied into data source (from outside table) 21359 * will be automatically reflected in the table. 21360 * 21361 * For every data change [afterChangesObserved](Hooks.html#event:afterChangesObserved) hook will be fired. 21362 * 21363 * @type {Boolean} 21364 * @default false 21365 */ 21366 observeChanges: void 0, 21367 21368 /** 21369 * @description 21370 * When passed to the `column` property, allows specifying a custom sorting function for the desired column. 21371 * 21372 * @since 0.24.0 21373 * @type {Function} 21374 * @example 21375 * ```js 21376 * columns: [ 21377 * { 21378 * sortFunction: function(sortOrder) { 21379 * return function(a, b) { 21380 * // sorting function body. 21381 * // 21382 * // Function parameters: 21383 * // sortOrder: If true, the order is ascending, if false - descending. undefined = original order 21384 * // a, b: Two compared elements. These are 2-element arrays, with the first element being the row index, the second - cell value. 21385 * } 21386 * } 21387 * } 21388 * ] 21389 * ``` 21390 */ 21391 sortFunction: void 0, 21392 21393 /** 21394 * If defined as 'true', the Autocomplete's suggestion list would be sorted by relevance (the closer to the left the match is, the higher the suggestion). 21395 * 21396 * Option desired for cells of the `'autocomplete'` type. 21397 * 21398 * @type {Boolean} 21399 * @default true 21400 */ 21401 sortByRelevance: true, 21402 21403 /** 21404 * If defined as 'true', when the user types into the input area the Autocomplete's suggestion list is updated to only 21405 * include those choices starting with what has been typed; if defined as 'false' all suggestions remain shown, with 21406 * those matching what has been typed marked in bold. 21407 * 21408 * @type {Boolean} 21409 * @default true 21410 */ 21411 filter: true, 21412 21413 /** 21414 * If defined as 'true', filtering in the Autocomplete Editor will be case-sensitive. 21415 * 21416 * @type {Boolean} 21417 * @default: false 21418 */ 21419 filteringCaseSensitive: false 21420}; 21421 21422exports.default = DefaultSettings; 21423 21424/***/ }), 21425/* 89 */ 21426/***/ (function(module, exports, __webpack_require__) { 21427 21428"use strict"; 21429 21430 21431exports.__esModule = true; 21432exports.getNormalizedDate = getNormalizedDate; 21433/* eslint-disable import/prefer-default-export */ 21434 21435/** 21436 * Get normalized Date object for the ISO formatted date strings. 21437 * Natively, the date object parsed from a ISO 8601 string will be offsetted by the timezone difference, which may result in returning a wrong date. 21438 * See: Github issue #3338. 21439 * 21440 * @param {String} dateString String representing the date. 21441 * @returns {Date} The proper Date object. 21442 */ 21443function getNormalizedDate(dateString) { 21444 var nativeDate = new Date(dateString); 21445 21446 // NaN if dateString is not in ISO format 21447 if (!isNaN(new Date(dateString + "T00:00").getDate())) { 21448 21449 // Compensate timezone offset 21450 return new Date(nativeDate.getTime() + nativeDate.getTimezoneOffset() * 60000); 21451 } 21452 21453 return nativeDate; 21454} 21455 21456/***/ }), 21457/* 90 */ 21458/***/ (function(module, exports, __webpack_require__) { 21459 21460"use strict"; 21461 21462 21463exports.__esModule = true; 21464exports.registerAsRootInstance = registerAsRootInstance; 21465exports.hasValidParameter = hasValidParameter; 21466exports.isRootInstance = isRootInstance; 21467var holder = exports.holder = new WeakMap(); 21468 21469var rootInstanceSymbol = exports.rootInstanceSymbol = Symbol('rootInstance'); 21470 21471/** 21472 * Register an object as a root instance. 21473 * 21474 * @param {Object} object An object to associate with root instance flag. 21475 */ 21476function registerAsRootInstance(object) { 21477 holder.set(object, true); 21478} 21479 21480/** 21481 * Check if the source of the root indication call is valid. 21482 * 21483 * @param {Symbol} rootSymbol A symbol as a source of truth. 21484 * @return {Boolean} 21485 */ 21486function hasValidParameter(rootSymbol) { 21487 return rootSymbol === rootInstanceSymbol; 21488} 21489 21490/** 21491 * Check if passed an object was flagged as a root instance. 21492 * 21493 * @param {Object} object An object to check. 21494 * @return {Boolean} 21495 */ 21496function isRootInstance(object) { 21497 return holder.has(object); 21498} 21499 21500/***/ }), 21501/* 91 */ 21502/***/ (function(module, exports, __webpack_require__) { 21503 21504// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) 21505var $export = __webpack_require__(1); 21506 21507$export($export.P, 'Array', { copyWithin: __webpack_require__(389) }); 21508 21509__webpack_require__(37)('copyWithin'); 21510 21511 21512/***/ }), 21513/* 92 */ 21514/***/ (function(module, exports, __webpack_require__) { 21515 21516// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) 21517var $export = __webpack_require__(1); 21518 21519$export($export.P, 'Array', { fill: __webpack_require__(390) }); 21520 21521__webpack_require__(37)('fill'); 21522 21523 21524/***/ }), 21525/* 93 */ 21526/***/ (function(module, exports, __webpack_require__) { 21527 21528"use strict"; 21529 21530// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) 21531var $export = __webpack_require__(1); 21532var $find = __webpack_require__(56)(6); 21533var KEY = 'findIndex'; 21534var forced = true; 21535// Shouldn't skip holes 21536if (KEY in []) Array(1)[KEY](function () { forced = false; }); 21537$export($export.P + $export.F * forced, 'Array', { 21538 findIndex: function findIndex(callbackfn /* , that = undefined */) { 21539 return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); 21540 } 21541}); 21542__webpack_require__(37)(KEY); 21543 21544 21545/***/ }), 21546/* 94 */ 21547/***/ (function(module, exports, __webpack_require__) { 21548 21549"use strict"; 21550 21551// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) 21552var $export = __webpack_require__(1); 21553var $find = __webpack_require__(56)(5); 21554var KEY = 'find'; 21555var forced = true; 21556// Shouldn't skip holes 21557if (KEY in []) Array(1)[KEY](function () { forced = false; }); 21558$export($export.P + $export.F * forced, 'Array', { 21559 find: function find(callbackfn /* , that = undefined */) { 21560 return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); 21561 } 21562}); 21563__webpack_require__(37)(KEY); 21564 21565 21566/***/ }), 21567/* 95 */ 21568/***/ (function(module, exports, __webpack_require__) { 21569 21570"use strict"; 21571 21572var ctx = __webpack_require__(30); 21573var $export = __webpack_require__(1); 21574var toObject = __webpack_require__(40); 21575var call = __webpack_require__(280); 21576var isArrayIter = __webpack_require__(276); 21577var toLength = __webpack_require__(21); 21578var createProperty = __webpack_require__(74); 21579var getIterFn = __webpack_require__(292); 21580 21581$export($export.S + $export.F * !__webpack_require__(79)(function (iter) { Array.from(iter); }), 'Array', { 21582 // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) 21583 from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { 21584 var O = toObject(arrayLike); 21585 var C = typeof this == 'function' ? this : Array; 21586 var aLen = arguments.length; 21587 var mapfn = aLen > 1 ? arguments[1] : undefined; 21588 var mapping = mapfn !== undefined; 21589 var index = 0; 21590 var iterFn = getIterFn(O); 21591 var length, result, step, iterator; 21592 if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); 21593 // if object isn't iterable or it's array with default iterator - use simple case 21594 if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) { 21595 for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { 21596 createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value); 21597 } 21598 } else { 21599 length = toLength(O.length); 21600 for (result = new C(length); length > index; index++) { 21601 createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); 21602 } 21603 } 21604 result.length = index; 21605 return result; 21606 } 21607}); 21608 21609 21610/***/ }), 21611/* 96 */ 21612/***/ (function(module, exports, __webpack_require__) { 21613 21614"use strict"; 21615 21616var $export = __webpack_require__(1); 21617var createProperty = __webpack_require__(74); 21618 21619// WebKit Array.of isn't generic 21620$export($export.S + $export.F * __webpack_require__(25)(function () { 21621 function F() { /* empty */ } 21622 return !(Array.of.call(F) instanceof F); 21623}), 'Array', { 21624 // 22.1.2.3 Array.of( ...items) 21625 of: function of(/* ...args */) { 21626 var index = 0; 21627 var aLen = arguments.length; 21628 var result = new (typeof this == 'function' ? this : Array)(aLen); 21629 while (aLen > index) createProperty(result, index, arguments[index++]); 21630 result.length = aLen; 21631 return result; 21632 } 21633}); 21634 21635 21636/***/ }), 21637/* 97 */ 21638/***/ (function(module, exports, __webpack_require__) { 21639 21640var dP = __webpack_require__(18).f; 21641var FProto = Function.prototype; 21642var nameRE = /^\s*function ([^ (]*)/; 21643var NAME = 'name'; 21644 21645// 19.2.4.2 name 21646NAME in FProto || __webpack_require__(20) && dP(FProto, NAME, { 21647 configurable: true, 21648 get: function () { 21649 try { 21650 return ('' + this).match(nameRE)[1]; 21651 } catch (e) { 21652 return ''; 21653 } 21654 } 21655}); 21656 21657 21658/***/ }), 21659/* 98 */ 21660/***/ (function(module, exports, __webpack_require__) { 21661 21662"use strict"; 21663 21664var strong = __webpack_require__(272); 21665var validate = __webpack_require__(41); 21666var MAP = 'Map'; 21667 21668// 23.1 Map Objects 21669module.exports = __webpack_require__(57)(MAP, function (get) { 21670 return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; 21671}, { 21672 // 23.1.3.6 Map.prototype.get(key) 21673 get: function get(key) { 21674 var entry = strong.getEntry(validate(this, MAP), key); 21675 return entry && entry.v; 21676 }, 21677 // 23.1.3.9 Map.prototype.set(key, value) 21678 set: function set(key, value) { 21679 return strong.def(validate(this, MAP), key === 0 ? 0 : key, value); 21680 } 21681}, strong, true); 21682 21683 21684/***/ }), 21685/* 99 */ 21686/***/ (function(module, exports, __webpack_require__) { 21687 21688// 20.1.2.1 Number.EPSILON 21689var $export = __webpack_require__(1); 21690 21691$export($export.S, 'Number', { EPSILON: Math.pow(2, -52) }); 21692 21693 21694/***/ }), 21695/* 100 */ 21696/***/ (function(module, exports, __webpack_require__) { 21697 21698// 20.1.2.2 Number.isFinite(number) 21699var $export = __webpack_require__(1); 21700var _isFinite = __webpack_require__(10).isFinite; 21701 21702$export($export.S, 'Number', { 21703 isFinite: function isFinite(it) { 21704 return typeof it == 'number' && _isFinite(it); 21705 } 21706}); 21707 21708 21709/***/ }), 21710/* 101 */ 21711/***/ (function(module, exports, __webpack_require__) { 21712 21713// 20.1.2.3 Number.isInteger(number) 21714var $export = __webpack_require__(1); 21715 21716$export($export.S, 'Number', { isInteger: __webpack_require__(278) }); 21717 21718 21719/***/ }), 21720/* 102 */ 21721/***/ (function(module, exports, __webpack_require__) { 21722 21723// 20.1.2.4 Number.isNaN(number) 21724var $export = __webpack_require__(1); 21725 21726$export($export.S, 'Number', { 21727 isNaN: function isNaN(number) { 21728 // eslint-disable-next-line no-self-compare 21729 return number != number; 21730 } 21731}); 21732 21733 21734/***/ }), 21735/* 103 */ 21736/***/ (function(module, exports, __webpack_require__) { 21737 21738// 20.1.2.5 Number.isSafeInteger(number) 21739var $export = __webpack_require__(1); 21740var isInteger = __webpack_require__(278); 21741var abs = Math.abs; 21742 21743$export($export.S, 'Number', { 21744 isSafeInteger: function isSafeInteger(number) { 21745 return isInteger(number) && abs(number) <= 0x1fffffffffffff; 21746 } 21747}); 21748 21749 21750/***/ }), 21751/* 104 */ 21752/***/ (function(module, exports, __webpack_require__) { 21753 21754// 20.1.2.6 Number.MAX_SAFE_INTEGER 21755var $export = __webpack_require__(1); 21756 21757$export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff }); 21758 21759 21760/***/ }), 21761/* 105 */ 21762/***/ (function(module, exports, __webpack_require__) { 21763 21764// 20.1.2.10 Number.MIN_SAFE_INTEGER 21765var $export = __webpack_require__(1); 21766 21767$export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff }); 21768 21769 21770/***/ }), 21771/* 106 */ 21772/***/ (function(module, exports, __webpack_require__) { 21773 21774// 19.1.3.1 Object.assign(target, source) 21775var $export = __webpack_require__(1); 21776 21777$export($export.S + $export.F, 'Object', { assign: __webpack_require__(284) }); 21778 21779 21780/***/ }), 21781/* 107 */ 21782/***/ (function(module, exports, __webpack_require__) { 21783 21784// 19.1.3.10 Object.is(value1, value2) 21785var $export = __webpack_require__(1); 21786$export($export.S, 'Object', { is: __webpack_require__(405) }); 21787 21788 21789/***/ }), 21790/* 108 */ 21791/***/ (function(module, exports, __webpack_require__) { 21792 21793// 19.1.3.19 Object.setPrototypeOf(O, proto) 21794var $export = __webpack_require__(1); 21795$export($export.S, 'Object', { setPrototypeOf: __webpack_require__(287).set }); 21796 21797 21798/***/ }), 21799/* 109 */ 21800/***/ (function(module, exports, __webpack_require__) { 21801 21802"use strict"; 21803 21804var LIBRARY = __webpack_require__(60); 21805var global = __webpack_require__(10); 21806var ctx = __webpack_require__(30); 21807var classof = __webpack_require__(271); 21808var $export = __webpack_require__(1); 21809var isObject = __webpack_require__(12); 21810var aFunction = __webpack_require__(54); 21811var anInstance = __webpack_require__(55); 21812var forOf = __webpack_require__(59); 21813var speciesConstructor = __webpack_require__(406); 21814var task = __webpack_require__(86).set; 21815var microtask = __webpack_require__(398)(); 21816var newPromiseCapabilityModule = __webpack_require__(283); 21817var perform = __webpack_require__(403); 21818var promiseResolve = __webpack_require__(404); 21819var PROMISE = 'Promise'; 21820var TypeError = global.TypeError; 21821var process = global.process; 21822var $Promise = global[PROMISE]; 21823var isNode = classof(process) == 'process'; 21824var empty = function () { /* empty */ }; 21825var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper; 21826var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f; 21827 21828var USE_NATIVE = !!function () { 21829 try { 21830 // correct subclassing with @@species support 21831 var promise = $Promise.resolve(1); 21832 var FakePromise = (promise.constructor = {})[__webpack_require__(8)('species')] = function (exec) { 21833 exec(empty, empty); 21834 }; 21835 // unhandled rejections tracking support, NodeJS Promise without it fails @@species test 21836 return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise; 21837 } catch (e) { /* empty */ } 21838}(); 21839 21840// helpers 21841var isThenable = function (it) { 21842 var then; 21843 return isObject(it) && typeof (then = it.then) == 'function' ? then : false; 21844}; 21845var notify = function (promise, isReject) { 21846 if (promise._n) return; 21847 promise._n = true; 21848 var chain = promise._c; 21849 microtask(function () { 21850 var value = promise._v; 21851 var ok = promise._s == 1; 21852 var i = 0; 21853 var run = function (reaction) { 21854 var handler = ok ? reaction.ok : reaction.fail; 21855 var resolve = reaction.resolve; 21856 var reject = reaction.reject; 21857 var domain = reaction.domain; 21858 var result, then; 21859 try { 21860 if (handler) { 21861 if (!ok) { 21862 if (promise._h == 2) onHandleUnhandled(promise); 21863 promise._h = 1; 21864 } 21865 if (handler === true) result = value; 21866 else { 21867 if (domain) domain.enter(); 21868 result = handler(value); 21869 if (domain) domain.exit(); 21870 } 21871 if (result === reaction.promise) { 21872 reject(TypeError('Promise-chain cycle')); 21873 } else if (then = isThenable(result)) { 21874 then.call(result, resolve, reject); 21875 } else resolve(result); 21876 } else reject(value); 21877 } catch (e) { 21878 reject(e); 21879 } 21880 }; 21881 while (chain.length > i) run(chain[i++]); // variable length - can't use forEach 21882 promise._c = []; 21883 promise._n = false; 21884 if (isReject && !promise._h) onUnhandled(promise); 21885 }); 21886}; 21887var onUnhandled = function (promise) { 21888 task.call(global, function () { 21889 var value = promise._v; 21890 var unhandled = isUnhandled(promise); 21891 var result, handler, console; 21892 if (unhandled) { 21893 result = perform(function () { 21894 if (isNode) { 21895 process.emit('unhandledRejection', value, promise); 21896 } else if (handler = global.onunhandledrejection) { 21897 handler({ promise: promise, reason: value }); 21898 } else if ((console = global.console) && console.error) { 21899 console.error('Unhandled promise rejection', value); 21900 } 21901 }); 21902 // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should 21903 promise._h = isNode || isUnhandled(promise) ? 2 : 1; 21904 } promise._a = undefined; 21905 if (unhandled && result.e) throw result.v; 21906 }); 21907}; 21908var isUnhandled = function (promise) { 21909 if (promise._h == 1) return false; 21910 var chain = promise._a || promise._c; 21911 var i = 0; 21912 var reaction; 21913 while (chain.length > i) { 21914 reaction = chain[i++]; 21915 if (reaction.fail || !isUnhandled(reaction.promise)) return false; 21916 } return true; 21917}; 21918var onHandleUnhandled = function (promise) { 21919 task.call(global, function () { 21920 var handler; 21921 if (isNode) { 21922 process.emit('rejectionHandled', promise); 21923 } else if (handler = global.onrejectionhandled) { 21924 handler({ promise: promise, reason: promise._v }); 21925 } 21926 }); 21927}; 21928var $reject = function (value) { 21929 var promise = this; 21930 if (promise._d) return; 21931 promise._d = true; 21932 promise = promise._w || promise; // unwrap 21933 promise._v = value; 21934 promise._s = 2; 21935 if (!promise._a) promise._a = promise._c.slice(); 21936 notify(promise, true); 21937}; 21938var $resolve = function (value) { 21939 var promise = this; 21940 var then; 21941 if (promise._d) return; 21942 promise._d = true; 21943 promise = promise._w || promise; // unwrap 21944 try { 21945 if (promise === value) throw TypeError("Promise can't be resolved itself"); 21946 if (then = isThenable(value)) { 21947 microtask(function () { 21948 var wrapper = { _w: promise, _d: false }; // wrap 21949 try { 21950 then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); 21951 } catch (e) { 21952 $reject.call(wrapper, e); 21953 } 21954 }); 21955 } else { 21956 promise._v = value; 21957 promise._s = 1; 21958 notify(promise, false); 21959 } 21960 } catch (e) { 21961 $reject.call({ _w: promise, _d: false }, e); // wrap 21962 } 21963}; 21964 21965// constructor polyfill 21966if (!USE_NATIVE) { 21967 // 25.4.3.1 Promise(executor) 21968 $Promise = function Promise(executor) { 21969 anInstance(this, $Promise, PROMISE, '_h'); 21970 aFunction(executor); 21971 Internal.call(this); 21972 try { 21973 executor(ctx($resolve, this, 1), ctx($reject, this, 1)); 21974 } catch (err) { 21975 $reject.call(this, err); 21976 } 21977 }; 21978 // eslint-disable-next-line no-unused-vars 21979 Internal = function Promise(executor) { 21980 this._c = []; // <- awaiting reactions 21981 this._a = undefined; // <- checked in isUnhandled reactions 21982 this._s = 0; // <- state 21983 this._d = false; // <- done 21984 this._v = undefined; // <- value 21985 this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled 21986 this._n = false; // <- notify 21987 }; 21988 Internal.prototype = __webpack_require__(62)($Promise.prototype, { 21989 // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) 21990 then: function then(onFulfilled, onRejected) { 21991 var reaction = newPromiseCapability(speciesConstructor(this, $Promise)); 21992 reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; 21993 reaction.fail = typeof onRejected == 'function' && onRejected; 21994 reaction.domain = isNode ? process.domain : undefined; 21995 this._c.push(reaction); 21996 if (this._a) this._a.push(reaction); 21997 if (this._s) notify(this, false); 21998 return reaction.promise; 21999 }, 22000 // 25.4.5.1 Promise.prototype.catch(onRejected) 22001 'catch': function (onRejected) { 22002 return this.then(undefined, onRejected); 22003 } 22004 }); 22005 OwnPromiseCapability = function () { 22006 var promise = new Internal(); 22007 this.promise = promise; 22008 this.resolve = ctx($resolve, promise, 1); 22009 this.reject = ctx($reject, promise, 1); 22010 }; 22011 newPromiseCapabilityModule.f = newPromiseCapability = function (C) { 22012 return C === $Promise || C === Wrapper 22013 ? new OwnPromiseCapability(C) 22014 : newGenericPromiseCapability(C); 22015 }; 22016} 22017 22018$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise }); 22019__webpack_require__(50)($Promise, PROMISE); 22020__webpack_require__(288)(PROMISE); 22021Wrapper = __webpack_require__(45)[PROMISE]; 22022 22023// statics 22024$export($export.S + $export.F * !USE_NATIVE, PROMISE, { 22025 // 25.4.4.5 Promise.reject(r) 22026 reject: function reject(r) { 22027 var capability = newPromiseCapability(this); 22028 var $$reject = capability.reject; 22029 $$reject(r); 22030 return capability.promise; 22031 } 22032}); 22033$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { 22034 // 25.4.4.6 Promise.resolve(x) 22035 resolve: function resolve(x) { 22036 return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x); 22037 } 22038}); 22039$export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(79)(function (iter) { 22040 $Promise.all(iter)['catch'](empty); 22041})), PROMISE, { 22042 // 25.4.4.1 Promise.all(iterable) 22043 all: function all(iterable) { 22044 var C = this; 22045 var capability = newPromiseCapability(C); 22046 var resolve = capability.resolve; 22047 var reject = capability.reject; 22048 var result = perform(function () { 22049 var values = []; 22050 var index = 0; 22051 var remaining = 1; 22052 forOf(iterable, false, function (promise) { 22053 var $index = index++; 22054 var alreadyCalled = false; 22055 values.push(undefined); 22056 remaining++; 22057 C.resolve(promise).then(function (value) { 22058 if (alreadyCalled) return; 22059 alreadyCalled = true; 22060 values[$index] = value; 22061 --remaining || resolve(values); 22062 }, reject); 22063 }); 22064 --remaining || resolve(values); 22065 }); 22066 if (result.e) reject(result.v); 22067 return capability.promise; 22068 }, 22069 // 25.4.4.4 Promise.race(iterable) 22070 race: function race(iterable) { 22071 var C = this; 22072 var capability = newPromiseCapability(C); 22073 var reject = capability.reject; 22074 var result = perform(function () { 22075 forOf(iterable, false, function (promise) { 22076 C.resolve(promise).then(capability.resolve, reject); 22077 }); 22078 }); 22079 if (result.e) reject(result.v); 22080 return capability.promise; 22081 } 22082}); 22083 22084 22085/***/ }), 22086/* 110 */ 22087/***/ (function(module, exports, __webpack_require__) { 22088 22089// 21.2.5.3 get RegExp.prototype.flags() 22090if (__webpack_require__(20) && /./g.flags != 'g') __webpack_require__(18).f(RegExp.prototype, 'flags', { 22091 configurable: true, 22092 get: __webpack_require__(394) 22093}); 22094 22095 22096/***/ }), 22097/* 111 */ 22098/***/ (function(module, exports, __webpack_require__) { 22099 22100// @@match logic 22101__webpack_require__(58)('match', 1, function (defined, MATCH, $match) { 22102 // 21.1.3.11 String.prototype.match(regexp) 22103 return [function match(regexp) { 22104 'use strict'; 22105 var O = defined(this); 22106 var fn = regexp == undefined ? undefined : regexp[MATCH]; 22107 return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); 22108 }, $match]; 22109}); 22110 22111 22112/***/ }), 22113/* 112 */ 22114/***/ (function(module, exports, __webpack_require__) { 22115 22116// @@replace logic 22117__webpack_require__(58)('replace', 2, function (defined, REPLACE, $replace) { 22118 // 21.1.3.14 String.prototype.replace(searchValue, replaceValue) 22119 return [function replace(searchValue, replaceValue) { 22120 'use strict'; 22121 var O = defined(this); 22122 var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; 22123 return fn !== undefined 22124 ? fn.call(searchValue, O, replaceValue) 22125 : $replace.call(String(O), searchValue, replaceValue); 22126 }, $replace]; 22127}); 22128 22129 22130/***/ }), 22131/* 113 */ 22132/***/ (function(module, exports, __webpack_require__) { 22133 22134// @@search logic 22135__webpack_require__(58)('search', 1, function (defined, SEARCH, $search) { 22136 // 21.1.3.15 String.prototype.search(regexp) 22137 return [function search(regexp) { 22138 'use strict'; 22139 var O = defined(this); 22140 var fn = regexp == undefined ? undefined : regexp[SEARCH]; 22141 return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); 22142 }, $search]; 22143}); 22144 22145 22146/***/ }), 22147/* 114 */ 22148/***/ (function(module, exports, __webpack_require__) { 22149 22150// @@split logic 22151__webpack_require__(58)('split', 2, function (defined, SPLIT, $split) { 22152 'use strict'; 22153 var isRegExp = __webpack_require__(279); 22154 var _split = $split; 22155 var $push = [].push; 22156 var $SPLIT = 'split'; 22157 var LENGTH = 'length'; 22158 var LAST_INDEX = 'lastIndex'; 22159 if ( 22160 'abbc'[$SPLIT](/(b)*/)[1] == 'c' || 22161 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || 22162 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 || 22163 '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 || 22164 '.'[$SPLIT](/()()/)[LENGTH] > 1 || 22165 ''[$SPLIT](/.?/)[LENGTH] 22166 ) { 22167 var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group 22168 // based on es5-shim implementation, need to rework it 22169 $split = function (separator, limit) { 22170 var string = String(this); 22171 if (separator === undefined && limit === 0) return []; 22172 // If `separator` is not a regex, use native split 22173 if (!isRegExp(separator)) return _split.call(string, separator, limit); 22174 var output = []; 22175 var flags = (separator.ignoreCase ? 'i' : '') + 22176 (separator.multiline ? 'm' : '') + 22177 (separator.unicode ? 'u' : '') + 22178 (separator.sticky ? 'y' : ''); 22179 var lastLastIndex = 0; 22180 var splitLimit = limit === undefined ? 4294967295 : limit >>> 0; 22181 // Make `global` and avoid `lastIndex` issues by working with a copy 22182 var separatorCopy = new RegExp(separator.source, flags + 'g'); 22183 var separator2, match, lastIndex, lastLength, i; 22184 // Doesn't need flags gy, but they don't hurt 22185 if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); 22186 while (match = separatorCopy.exec(string)) { 22187 // `separatorCopy.lastIndex` is not reliable cross-browser 22188 lastIndex = match.index + match[0][LENGTH]; 22189 if (lastIndex > lastLastIndex) { 22190 output.push(string.slice(lastLastIndex, match.index)); 22191 // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG 22192 // eslint-disable-next-line no-loop-func 22193 if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () { 22194 for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined; 22195 }); 22196 if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1)); 22197 lastLength = match[0][LENGTH]; 22198 lastLastIndex = lastIndex; 22199 if (output[LENGTH] >= splitLimit) break; 22200 } 22201 if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop 22202 } 22203 if (lastLastIndex === string[LENGTH]) { 22204 if (lastLength || !separatorCopy.test('')) output.push(''); 22205 } else output.push(string.slice(lastLastIndex)); 22206 return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output; 22207 }; 22208 // Chakra, V8 22209 } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) { 22210 $split = function (separator, limit) { 22211 return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit); 22212 }; 22213 } 22214 // 21.1.3.17 String.prototype.split(separator, limit) 22215 return [function split(separator, limit) { 22216 var O = defined(this); 22217 var fn = separator == undefined ? undefined : separator[SPLIT]; 22218 return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit); 22219 }, $split]; 22220}); 22221 22222 22223/***/ }), 22224/* 115 */ 22225/***/ (function(module, exports, __webpack_require__) { 22226 22227"use strict"; 22228 22229var strong = __webpack_require__(272); 22230var validate = __webpack_require__(41); 22231var SET = 'Set'; 22232 22233// 23.2 Set Objects 22234module.exports = __webpack_require__(57)(SET, function (get) { 22235 return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; 22236}, { 22237 // 23.2.3.1 Set.prototype.add(value) 22238 add: function add(value) { 22239 return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value); 22240 } 22241}, strong); 22242 22243 22244/***/ }), 22245/* 116 */ 22246/***/ (function(module, exports, __webpack_require__) { 22247 22248"use strict"; 22249 22250var $export = __webpack_require__(1); 22251var $at = __webpack_require__(407)(false); 22252$export($export.P, 'String', { 22253 // 21.1.3.3 String.prototype.codePointAt(pos) 22254 codePointAt: function codePointAt(pos) { 22255 return $at(this, pos); 22256 } 22257}); 22258 22259 22260/***/ }), 22261/* 117 */ 22262/***/ (function(module, exports, __webpack_require__) { 22263 22264"use strict"; 22265// 21.1.3.6 String.prototype.endsWith(searchString [, endPosition]) 22266 22267var $export = __webpack_require__(1); 22268var toLength = __webpack_require__(21); 22269var context = __webpack_require__(85); 22270var ENDS_WITH = 'endsWith'; 22271var $endsWith = ''[ENDS_WITH]; 22272 22273$export($export.P + $export.F * __webpack_require__(77)(ENDS_WITH), 'String', { 22274 endsWith: function endsWith(searchString /* , endPosition = @length */) { 22275 var that = context(this, searchString, ENDS_WITH); 22276 var endPosition = arguments.length > 1 ? arguments[1] : undefined; 22277 var len = toLength(that.length); 22278 var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len); 22279 var search = String(searchString); 22280 return $endsWith 22281 ? $endsWith.call(that, search, end) 22282 : that.slice(end - search.length, end) === search; 22283 } 22284}); 22285 22286 22287/***/ }), 22288/* 118 */ 22289/***/ (function(module, exports, __webpack_require__) { 22290 22291var $export = __webpack_require__(1); 22292var toAbsoluteIndex = __webpack_require__(63); 22293var fromCharCode = String.fromCharCode; 22294var $fromCodePoint = String.fromCodePoint; 22295 22296// length should be 1, old FF problem 22297$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', { 22298 // 21.1.2.2 String.fromCodePoint(...codePoints) 22299 fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars 22300 var res = []; 22301 var aLen = arguments.length; 22302 var i = 0; 22303 var code; 22304 while (aLen > i) { 22305 code = +arguments[i++]; 22306 if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point'); 22307 res.push(code < 0x10000 22308 ? fromCharCode(code) 22309 : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00) 22310 ); 22311 } return res.join(''); 22312 } 22313}); 22314 22315 22316/***/ }), 22317/* 119 */ 22318/***/ (function(module, exports, __webpack_require__) { 22319 22320"use strict"; 22321// 21.1.3.7 String.prototype.includes(searchString, position = 0) 22322 22323var $export = __webpack_require__(1); 22324var context = __webpack_require__(85); 22325var INCLUDES = 'includes'; 22326 22327$export($export.P + $export.F * __webpack_require__(77)(INCLUDES), 'String', { 22328 includes: function includes(searchString /* , position = 0 */) { 22329 return !!~context(this, searchString, INCLUDES) 22330 .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined); 22331 } 22332}); 22333 22334 22335/***/ }), 22336/* 120 */ 22337/***/ (function(module, exports, __webpack_require__) { 22338 22339var $export = __webpack_require__(1); 22340var toIObject = __webpack_require__(27); 22341var toLength = __webpack_require__(21); 22342 22343$export($export.S, 'String', { 22344 // 21.1.2.4 String.raw(callSite, ...substitutions) 22345 raw: function raw(callSite) { 22346 var tpl = toIObject(callSite.raw); 22347 var len = toLength(tpl.length); 22348 var aLen = arguments.length; 22349 var res = []; 22350 var i = 0; 22351 while (len > i) { 22352 res.push(String(tpl[i++])); 22353 if (i < aLen) res.push(String(arguments[i])); 22354 } return res.join(''); 22355 } 22356}); 22357 22358 22359/***/ }), 22360/* 121 */ 22361/***/ (function(module, exports, __webpack_require__) { 22362 22363var $export = __webpack_require__(1); 22364 22365$export($export.P, 'String', { 22366 // 21.1.3.13 String.prototype.repeat(count) 22367 repeat: __webpack_require__(290) 22368}); 22369 22370 22371/***/ }), 22372/* 122 */ 22373/***/ (function(module, exports, __webpack_require__) { 22374 22375"use strict"; 22376// 21.1.3.18 String.prototype.startsWith(searchString [, position ]) 22377 22378var $export = __webpack_require__(1); 22379var toLength = __webpack_require__(21); 22380var context = __webpack_require__(85); 22381var STARTS_WITH = 'startsWith'; 22382var $startsWith = ''[STARTS_WITH]; 22383 22384$export($export.P + $export.F * __webpack_require__(77)(STARTS_WITH), 'String', { 22385 startsWith: function startsWith(searchString /* , position = 0 */) { 22386 var that = context(this, searchString, STARTS_WITH); 22387 var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length)); 22388 var search = String(searchString); 22389 return $startsWith 22390 ? $startsWith.call(that, search, index) 22391 : that.slice(index, index + search.length) === search; 22392 } 22393}); 22394 22395 22396/***/ }), 22397/* 123 */ 22398/***/ (function(module, exports, __webpack_require__) { 22399 22400"use strict"; 22401 22402// ECMAScript 6 symbols shim 22403var global = __webpack_require__(10); 22404var has = __webpack_require__(26); 22405var DESCRIPTORS = __webpack_require__(20); 22406var $export = __webpack_require__(1); 22407var redefine = __webpack_require__(32); 22408var META = __webpack_require__(47).KEY; 22409var $fails = __webpack_require__(25); 22410var shared = __webpack_require__(84); 22411var setToStringTag = __webpack_require__(50); 22412var uid = __webpack_require__(51); 22413var wks = __webpack_require__(8); 22414var wksExt = __webpack_require__(291); 22415var wksDefine = __webpack_require__(408); 22416var enumKeys = __webpack_require__(393); 22417var isArray = __webpack_require__(277); 22418var anObject = __webpack_require__(17); 22419var toIObject = __webpack_require__(27); 22420var toPrimitive = __webpack_require__(87); 22421var createDesc = __webpack_require__(49); 22422var _create = __webpack_require__(80); 22423var gOPNExt = __webpack_require__(400); 22424var $GOPD = __webpack_require__(81); 22425var $DP = __webpack_require__(18); 22426var $keys = __webpack_require__(39); 22427var gOPD = $GOPD.f; 22428var dP = $DP.f; 22429var gOPN = gOPNExt.f; 22430var $Symbol = global.Symbol; 22431var $JSON = global.JSON; 22432var _stringify = $JSON && $JSON.stringify; 22433var PROTOTYPE = 'prototype'; 22434var HIDDEN = wks('_hidden'); 22435var TO_PRIMITIVE = wks('toPrimitive'); 22436var isEnum = {}.propertyIsEnumerable; 22437var SymbolRegistry = shared('symbol-registry'); 22438var AllSymbols = shared('symbols'); 22439var OPSymbols = shared('op-symbols'); 22440var ObjectProto = Object[PROTOTYPE]; 22441var USE_NATIVE = typeof $Symbol == 'function'; 22442var QObject = global.QObject; 22443// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 22444var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; 22445 22446// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 22447var setSymbolDesc = DESCRIPTORS && $fails(function () { 22448 return _create(dP({}, 'a', { 22449 get: function () { return dP(this, 'a', { value: 7 }).a; } 22450 })).a != 7; 22451}) ? function (it, key, D) { 22452 var protoDesc = gOPD(ObjectProto, key); 22453 if (protoDesc) delete ObjectProto[key]; 22454 dP(it, key, D); 22455 if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc); 22456} : dP; 22457 22458var wrap = function (tag) { 22459 var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); 22460 sym._k = tag; 22461 return sym; 22462}; 22463 22464var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) { 22465 return typeof it == 'symbol'; 22466} : function (it) { 22467 return it instanceof $Symbol; 22468}; 22469 22470var $defineProperty = function defineProperty(it, key, D) { 22471 if (it === ObjectProto) $defineProperty(OPSymbols, key, D); 22472 anObject(it); 22473 key = toPrimitive(key, true); 22474 anObject(D); 22475 if (has(AllSymbols, key)) { 22476 if (!D.enumerable) { 22477 if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {})); 22478 it[HIDDEN][key] = true; 22479 } else { 22480 if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; 22481 D = _create(D, { enumerable: createDesc(0, false) }); 22482 } return setSymbolDesc(it, key, D); 22483 } return dP(it, key, D); 22484}; 22485var $defineProperties = function defineProperties(it, P) { 22486 anObject(it); 22487 var keys = enumKeys(P = toIObject(P)); 22488 var i = 0; 22489 var l = keys.length; 22490 var key; 22491 while (l > i) $defineProperty(it, key = keys[i++], P[key]); 22492 return it; 22493}; 22494var $create = function create(it, P) { 22495 return P === undefined ? _create(it) : $defineProperties(_create(it), P); 22496}; 22497var $propertyIsEnumerable = function propertyIsEnumerable(key) { 22498 var E = isEnum.call(this, key = toPrimitive(key, true)); 22499 if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false; 22500 return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true; 22501}; 22502var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { 22503 it = toIObject(it); 22504 key = toPrimitive(key, true); 22505 if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return; 22506 var D = gOPD(it, key); 22507 if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; 22508 return D; 22509}; 22510var $getOwnPropertyNames = function getOwnPropertyNames(it) { 22511 var names = gOPN(toIObject(it)); 22512 var result = []; 22513 var i = 0; 22514 var key; 22515 while (names.length > i) { 22516 if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); 22517 } return result; 22518}; 22519var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { 22520 var IS_OP = it === ObjectProto; 22521 var names = gOPN(IS_OP ? OPSymbols : toIObject(it)); 22522 var result = []; 22523 var i = 0; 22524 var key; 22525 while (names.length > i) { 22526 if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]); 22527 } return result; 22528}; 22529 22530// 19.4.1.1 Symbol([description]) 22531if (!USE_NATIVE) { 22532 $Symbol = function Symbol() { 22533 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); 22534 var tag = uid(arguments.length > 0 ? arguments[0] : undefined); 22535 var $set = function (value) { 22536 if (this === ObjectProto) $set.call(OPSymbols, value); 22537 if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; 22538 setSymbolDesc(this, tag, createDesc(1, value)); 22539 }; 22540 if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set }); 22541 return wrap(tag); 22542 }; 22543 redefine($Symbol[PROTOTYPE], 'toString', function toString() { 22544 return this._k; 22545 }); 22546 22547 $GOPD.f = $getOwnPropertyDescriptor; 22548 $DP.f = $defineProperty; 22549 __webpack_require__(82).f = gOPNExt.f = $getOwnPropertyNames; 22550 __webpack_require__(48).f = $propertyIsEnumerable; 22551 __webpack_require__(61).f = $getOwnPropertySymbols; 22552 22553 if (DESCRIPTORS && !__webpack_require__(60)) { 22554 redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); 22555 } 22556 22557 wksExt.f = function (name) { 22558 return wrap(wks(name)); 22559 }; 22560} 22561 22562$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol }); 22563 22564for (var es6Symbols = ( 22565 // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 22566 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' 22567).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]); 22568 22569for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]); 22570 22571$export($export.S + $export.F * !USE_NATIVE, 'Symbol', { 22572 // 19.4.2.1 Symbol.for(key) 22573 'for': function (key) { 22574 return has(SymbolRegistry, key += '') 22575 ? SymbolRegistry[key] 22576 : SymbolRegistry[key] = $Symbol(key); 22577 }, 22578 // 19.4.2.5 Symbol.keyFor(sym) 22579 keyFor: function keyFor(sym) { 22580 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); 22581 for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key; 22582 }, 22583 useSetter: function () { setter = true; }, 22584 useSimple: function () { setter = false; } 22585}); 22586 22587$export($export.S + $export.F * !USE_NATIVE, 'Object', { 22588 // 19.1.2.2 Object.create(O [, Properties]) 22589 create: $create, 22590 // 19.1.2.4 Object.defineProperty(O, P, Attributes) 22591 defineProperty: $defineProperty, 22592 // 19.1.2.3 Object.defineProperties(O, Properties) 22593 defineProperties: $defineProperties, 22594 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) 22595 getOwnPropertyDescriptor: $getOwnPropertyDescriptor, 22596 // 19.1.2.7 Object.getOwnPropertyNames(O) 22597 getOwnPropertyNames: $getOwnPropertyNames, 22598 // 19.1.2.8 Object.getOwnPropertySymbols(O) 22599 getOwnPropertySymbols: $getOwnPropertySymbols 22600}); 22601 22602// 24.3.2 JSON.stringify(value [, replacer [, space]]) 22603$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () { 22604 var S = $Symbol(); 22605 // MS Edge converts symbol values to JSON as {} 22606 // WebKit converts symbol values to JSON as null 22607 // V8 throws on boxed symbols 22608 return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; 22609})), 'JSON', { 22610 stringify: function stringify(it) { 22611 if (it === undefined || isSymbol(it)) return; // IE8 returns string on undefined 22612 var args = [it]; 22613 var i = 1; 22614 var replacer, $replacer; 22615 while (arguments.length > i) args.push(arguments[i++]); 22616 replacer = args[1]; 22617 if (typeof replacer == 'function') $replacer = replacer; 22618 if ($replacer || !isArray(replacer)) replacer = function (key, value) { 22619 if ($replacer) value = $replacer.call(this, key, value); 22620 if (!isSymbol(value)) return value; 22621 }; 22622 args[1] = replacer; 22623 return _stringify.apply($JSON, args); 22624 } 22625}); 22626 22627// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) 22628$Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(31)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); 22629// 19.4.3.5 Symbol.prototype[@@toStringTag] 22630setToStringTag($Symbol, 'Symbol'); 22631// 20.2.1.9 Math[@@toStringTag] 22632setToStringTag(Math, 'Math', true); 22633// 24.3.3 JSON[@@toStringTag] 22634setToStringTag(global.JSON, 'JSON', true); 22635 22636 22637/***/ }), 22638/* 124 */ 22639/***/ (function(module, exports, __webpack_require__) { 22640 22641"use strict"; 22642 22643var each = __webpack_require__(56)(0); 22644var redefine = __webpack_require__(32); 22645var meta = __webpack_require__(47); 22646var assign = __webpack_require__(284); 22647var weak = __webpack_require__(273); 22648var isObject = __webpack_require__(12); 22649var fails = __webpack_require__(25); 22650var validate = __webpack_require__(41); 22651var WEAK_MAP = 'WeakMap'; 22652var getWeak = meta.getWeak; 22653var isExtensible = Object.isExtensible; 22654var uncaughtFrozenStore = weak.ufstore; 22655var tmp = {}; 22656var InternalMap; 22657 22658var wrapper = function (get) { 22659 return function WeakMap() { 22660 return get(this, arguments.length > 0 ? arguments[0] : undefined); 22661 }; 22662}; 22663 22664var methods = { 22665 // 23.3.3.3 WeakMap.prototype.get(key) 22666 get: function get(key) { 22667 if (isObject(key)) { 22668 var data = getWeak(key); 22669 if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key); 22670 return data ? data[this._i] : undefined; 22671 } 22672 }, 22673 // 23.3.3.5 WeakMap.prototype.set(key, value) 22674 set: function set(key, value) { 22675 return weak.def(validate(this, WEAK_MAP), key, value); 22676 } 22677}; 22678 22679// 23.3 WeakMap Objects 22680var $WeakMap = module.exports = __webpack_require__(57)(WEAK_MAP, wrapper, methods, weak, true, true); 22681 22682// IE11 WeakMap frozen keys fix 22683if (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) { 22684 InternalMap = weak.getConstructor(wrapper, WEAK_MAP); 22685 assign(InternalMap.prototype, methods); 22686 meta.NEED = true; 22687 each(['delete', 'has', 'get', 'set'], function (key) { 22688 var proto = $WeakMap.prototype; 22689 var method = proto[key]; 22690 redefine(proto, key, function (a, b) { 22691 // store frozen objects on internal weakmap shim 22692 if (isObject(a) && !isExtensible(a)) { 22693 if (!this._f) this._f = new InternalMap(); 22694 var result = this._f[key](a, b); 22695 return key == 'set' ? this : result; 22696 // store all the rest on native weakmap 22697 } return method.call(this, a, b); 22698 }); 22699 }); 22700} 22701 22702 22703/***/ }), 22704/* 125 */ 22705/***/ (function(module, exports, __webpack_require__) { 22706 22707"use strict"; 22708 22709var weak = __webpack_require__(273); 22710var validate = __webpack_require__(41); 22711var WEAK_SET = 'WeakSet'; 22712 22713// 23.4 WeakSet Objects 22714__webpack_require__(57)(WEAK_SET, function (get) { 22715 return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; 22716}, { 22717 // 23.4.3.1 WeakSet.prototype.add(value) 22718 add: function add(value) { 22719 return weak.def(validate(this, WEAK_SET), value, true); 22720 } 22721}, weak, false, true); 22722 22723 22724/***/ }), 22725/* 126 */ 22726/***/ (function(module, exports, __webpack_require__) { 22727 22728"use strict"; 22729 22730// https://github.com/tc39/Array.prototype.includes 22731var $export = __webpack_require__(1); 22732var $includes = __webpack_require__(270)(true); 22733 22734$export($export.P, 'Array', { 22735 includes: function includes(el /* , fromIndex = 0 */) { 22736 return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); 22737 } 22738}); 22739 22740__webpack_require__(37)('includes'); 22741 22742 22743/***/ }), 22744/* 127 */ 22745/***/ (function(module, exports, __webpack_require__) { 22746 22747// https://github.com/tc39/proposal-object-values-entries 22748var $export = __webpack_require__(1); 22749var $entries = __webpack_require__(286)(true); 22750 22751$export($export.S, 'Object', { 22752 entries: function entries(it) { 22753 return $entries(it); 22754 } 22755}); 22756 22757 22758/***/ }), 22759/* 128 */ 22760/***/ (function(module, exports, __webpack_require__) { 22761 22762// https://github.com/tc39/proposal-object-getownpropertydescriptors 22763var $export = __webpack_require__(1); 22764var ownKeys = __webpack_require__(402); 22765var toIObject = __webpack_require__(27); 22766var gOPD = __webpack_require__(81); 22767var createProperty = __webpack_require__(74); 22768 22769$export($export.S, 'Object', { 22770 getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) { 22771 var O = toIObject(object); 22772 var getDesc = gOPD.f; 22773 var keys = ownKeys(O); 22774 var result = {}; 22775 var i = 0; 22776 var key, desc; 22777 while (keys.length > i) { 22778 desc = getDesc(O, key = keys[i++]); 22779 if (desc !== undefined) createProperty(result, key, desc); 22780 } 22781 return result; 22782 } 22783}); 22784 22785 22786/***/ }), 22787/* 129 */ 22788/***/ (function(module, exports, __webpack_require__) { 22789 22790// https://github.com/tc39/proposal-object-values-entries 22791var $export = __webpack_require__(1); 22792var $values = __webpack_require__(286)(false); 22793 22794$export($export.S, 'Object', { 22795 values: function values(it) { 22796 return $values(it); 22797 } 22798}); 22799 22800 22801/***/ }), 22802/* 130 */ 22803/***/ (function(module, exports, __webpack_require__) { 22804 22805"use strict"; 22806 22807// https://github.com/tc39/proposal-string-pad-start-end 22808var $export = __webpack_require__(1); 22809var $pad = __webpack_require__(289); 22810 22811$export($export.P, 'String', { 22812 padEnd: function padEnd(maxLength /* , fillString = ' ' */) { 22813 return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false); 22814 } 22815}); 22816 22817 22818/***/ }), 22819/* 131 */ 22820/***/ (function(module, exports, __webpack_require__) { 22821 22822"use strict"; 22823 22824// https://github.com/tc39/proposal-string-pad-start-end 22825var $export = __webpack_require__(1); 22826var $pad = __webpack_require__(289); 22827 22828$export($export.P, 'String', { 22829 padStart: function padStart(maxLength /* , fillString = ' ' */) { 22830 return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true); 22831 } 22832}); 22833 22834 22835/***/ }), 22836/* 132 */ 22837/***/ (function(module, exports, __webpack_require__) { 22838 22839var $iterators = __webpack_require__(70); 22840var getKeys = __webpack_require__(39); 22841var redefine = __webpack_require__(32); 22842var global = __webpack_require__(10); 22843var hide = __webpack_require__(31); 22844var Iterators = __webpack_require__(46); 22845var wks = __webpack_require__(8); 22846var ITERATOR = wks('iterator'); 22847var TO_STRING_TAG = wks('toStringTag'); 22848var ArrayValues = Iterators.Array; 22849 22850var DOMIterables = { 22851 CSSRuleList: true, // TODO: Not spec compliant, should be false. 22852 CSSStyleDeclaration: false, 22853 CSSValueList: false, 22854 ClientRectList: false, 22855 DOMRectList: false, 22856 DOMStringList: false, 22857 DOMTokenList: true, 22858 DataTransferItemList: false, 22859 FileList: false, 22860 HTMLAllCollection: false, 22861 HTMLCollection: false, 22862 HTMLFormElement: false, 22863 HTMLSelectElement: false, 22864 MediaList: true, // TODO: Not spec compliant, should be false. 22865 MimeTypeArray: false, 22866 NamedNodeMap: false, 22867 NodeList: true, 22868 PaintRequestList: false, 22869 Plugin: false, 22870 PluginArray: false, 22871 SVGLengthList: false, 22872 SVGNumberList: false, 22873 SVGPathSegList: false, 22874 SVGPointList: false, 22875 SVGStringList: false, 22876 SVGTransformList: false, 22877 SourceBufferList: false, 22878 StyleSheetList: true, // TODO: Not spec compliant, should be false. 22879 TextTrackCueList: false, 22880 TextTrackList: false, 22881 TouchList: false 22882}; 22883 22884for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) { 22885 var NAME = collections[i]; 22886 var explicit = DOMIterables[NAME]; 22887 var Collection = global[NAME]; 22888 var proto = Collection && Collection.prototype; 22889 var key; 22890 if (proto) { 22891 if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues); 22892 if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); 22893 Iterators[NAME] = ArrayValues; 22894 if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true); 22895 } 22896} 22897 22898 22899/***/ }), 22900/* 133 */ 22901/***/ (function(module, exports, __webpack_require__) { 22902 22903var $export = __webpack_require__(1); 22904var $task = __webpack_require__(86); 22905$export($export.G + $export.B, { 22906 setImmediate: $task.set, 22907 clearImmediate: $task.clear 22908}); 22909 22910 22911/***/ }), 22912/* 134 */ 22913/***/ (function(module, exports) { 22914 22915 22916 22917/***/ }), 22918/* 135 */ 22919/***/ (function(module, exports) { 22920 22921 22922 22923/***/ }), 22924/* 136 */ 22925/***/ (function(module, exports) { 22926 22927 22928 22929/***/ }), 22930/* 137 */ 22931/***/ (function(module, exports) { 22932 22933 22934 22935/***/ }), 22936/* 138 */ 22937/***/ (function(module, exports) { 22938 22939 22940 22941/***/ }), 22942/* 139 */ 22943/***/ (function(module, exports) { 22944 22945 22946 22947/***/ }), 22948/* 140 */ 22949/***/ (function(module, exports) { 22950 22951 22952 22953/***/ }), 22954/* 141 */ 22955/***/ (function(module, exports) { 22956 22957 22958 22959/***/ }), 22960/* 142 */ 22961/***/ (function(module, exports) { 22962 22963 22964 22965/***/ }), 22966/* 143 */ 22967/***/ (function(module, exports) { 22968 22969 22970 22971/***/ }), 22972/* 144 */ 22973/***/ (function(module, exports) { 22974 22975 22976 22977/***/ }), 22978/* 145 */ 22979/***/ (function(module, exports) { 22980 22981 22982 22983/***/ }), 22984/* 146 */ 22985/***/ (function(module, exports) { 22986 22987 22988 22989/***/ }), 22990/* 147 */ 22991/***/ (function(module, exports) { 22992 22993 22994 22995/***/ }), 22996/* 148 */ 22997/***/ (function(module, exports) { 22998 22999 23000 23001/***/ }), 23002/* 149 */ 23003/***/ (function(module, exports) { 23004 23005 23006 23007/***/ }), 23008/* 150 */ 23009/***/ (function(module, exports) { 23010 23011 23012 23013/***/ }), 23014/* 151 */ 23015/***/ (function(module, exports) { 23016 23017 23018 23019/***/ }), 23020/* 152 */ 23021/***/ (function(module, exports) { 23022 23023 23024 23025/***/ }), 23026/* 153 */ 23027/***/ (function(module, exports) { 23028 23029 23030 23031/***/ }), 23032/* 154 */ 23033/***/ (function(module, exports) { 23034 23035 23036 23037/***/ }), 23038/* 155 */ 23039/***/ (function(module, exports) { 23040 23041 23042 23043/***/ }), 23044/* 156 */ 23045/***/ (function(module, exports) { 23046 23047 23048 23049/***/ }), 23050/* 157 */ 23051/***/ (function(module, exports) { 23052 23053 23054 23055/***/ }), 23056/* 158 */ 23057/***/ (function(module, exports) { 23058 23059 23060 23061/***/ }), 23062/* 159 */ 23063/***/ (function(module, exports) { 23064 23065 23066 23067/***/ }), 23068/* 160 */ 23069/***/ (function(module, exports) { 23070 23071 23072 23073/***/ }), 23074/* 161 */ 23075/***/ (function(module, exports) { 23076 23077 23078 23079/***/ }), 23080/* 162 */ 23081/***/ (function(module, exports) { 23082 23083 23084 23085/***/ }), 23086/* 163 */ 23087/***/ (function(module, exports) { 23088 23089 23090 23091/***/ }), 23092/* 164 */ 23093/***/ (function(module, exports) { 23094 23095 23096 23097/***/ }), 23098/* 165 */ 23099/***/ (function(module, exports) { 23100 23101 23102 23103/***/ }), 23104/* 166 */ 23105/***/ (function(module, exports) { 23106 23107 23108 23109/***/ }), 23110/* 167 */ 23111/***/ (function(module, exports) { 23112 23113 23114 23115/***/ }), 23116/* 168 */ 23117/***/ (function(module, exports) { 23118 23119 23120 23121/***/ }), 23122/* 169 */ 23123/***/ (function(module, exports) { 23124 23125 23126 23127/***/ }), 23128/* 170 */ 23129/***/ (function(module, exports) { 23130 23131 23132 23133/***/ }), 23134/* 171 */ 23135/***/ (function(module, exports) { 23136 23137 23138 23139/***/ }), 23140/* 172 */ 23141/***/ (function(module, exports) { 23142 23143 23144 23145/***/ }), 23146/* 173 */ 23147/***/ (function(module, exports) { 23148 23149 23150 23151/***/ }), 23152/* 174 */ 23153/***/ (function(module, exports) { 23154 23155 23156 23157/***/ }), 23158/* 175 */ 23159/***/ (function(module, exports) { 23160 23161 23162 23163/***/ }), 23164/* 176 */ 23165/***/ (function(module, exports) { 23166 23167 23168 23169/***/ }), 23170/* 177 */ 23171/***/ (function(module, exports) { 23172 23173 23174 23175/***/ }), 23176/* 178 */ 23177/***/ (function(module, exports) { 23178 23179 23180 23181/***/ }), 23182/* 179 */ 23183/***/ (function(module, exports) { 23184 23185 23186 23187/***/ }), 23188/* 180 */ 23189/***/ (function(module, exports) { 23190 23191 23192 23193/***/ }), 23194/* 181 */ 23195/***/ (function(module, exports) { 23196 23197 23198 23199/***/ }), 23200/* 182 */ 23201/***/ (function(module, exports) { 23202 23203 23204 23205/***/ }), 23206/* 183 */ 23207/***/ (function(module, exports) { 23208 23209 23210 23211/***/ }), 23212/* 184 */ 23213/***/ (function(module, exports) { 23214 23215 23216 23217/***/ }), 23218/* 185 */ 23219/***/ (function(module, exports) { 23220 23221 23222 23223/***/ }), 23224/* 186 */ 23225/***/ (function(module, exports) { 23226 23227 23228 23229/***/ }), 23230/* 187 */ 23231/***/ (function(module, exports) { 23232 23233 23234 23235/***/ }), 23236/* 188 */ 23237/***/ (function(module, exports) { 23238 23239 23240 23241/***/ }), 23242/* 189 */ 23243/***/ (function(module, exports) { 23244 23245 23246 23247/***/ }), 23248/* 190 */ 23249/***/ (function(module, exports) { 23250 23251 23252 23253/***/ }), 23254/* 191 */ 23255/***/ (function(module, exports) { 23256 23257 23258 23259/***/ }), 23260/* 192 */ 23261/***/ (function(module, exports) { 23262 23263 23264 23265/***/ }), 23266/* 193 */ 23267/***/ (function(module, exports) { 23268 23269 23270 23271/***/ }), 23272/* 194 */ 23273/***/ (function(module, exports) { 23274 23275 23276 23277/***/ }), 23278/* 195 */ 23279/***/ (function(module, exports) { 23280 23281 23282 23283/***/ }), 23284/* 196 */ 23285/***/ (function(module, exports) { 23286 23287 23288 23289/***/ }), 23290/* 197 */ 23291/***/ (function(module, exports) { 23292 23293 23294 23295/***/ }), 23296/* 198 */ 23297/***/ (function(module, exports) { 23298 23299 23300 23301/***/ }), 23302/* 199 */ 23303/***/ (function(module, exports) { 23304 23305 23306 23307/***/ }), 23308/* 200 */ 23309/***/ (function(module, exports) { 23310 23311 23312 23313/***/ }), 23314/* 201 */ 23315/***/ (function(module, exports) { 23316 23317 23318 23319/***/ }), 23320/* 202 */ 23321/***/ (function(module, exports) { 23322 23323 23324 23325/***/ }), 23326/* 203 */ 23327/***/ (function(module, exports) { 23328 23329 23330 23331/***/ }), 23332/* 204 */ 23333/***/ (function(module, exports) { 23334 23335 23336 23337/***/ }), 23338/* 205 */ 23339/***/ (function(module, exports) { 23340 23341 23342 23343/***/ }), 23344/* 206 */ 23345/***/ (function(module, exports) { 23346 23347 23348 23349/***/ }), 23350/* 207 */ 23351/***/ (function(module, exports) { 23352 23353 23354 23355/***/ }), 23356/* 208 */ 23357/***/ (function(module, exports) { 23358 23359 23360 23361/***/ }), 23362/* 209 */ 23363/***/ (function(module, exports) { 23364 23365 23366 23367/***/ }), 23368/* 210 */ 23369/***/ (function(module, exports) { 23370 23371 23372 23373/***/ }), 23374/* 211 */ 23375/***/ (function(module, exports) { 23376 23377 23378 23379/***/ }), 23380/* 212 */ 23381/***/ (function(module, exports) { 23382 23383 23384 23385/***/ }), 23386/* 213 */ 23387/***/ (function(module, exports) { 23388 23389 23390 23391/***/ }), 23392/* 214 */ 23393/***/ (function(module, exports) { 23394 23395 23396 23397/***/ }), 23398/* 215 */ 23399/***/ (function(module, exports) { 23400 23401 23402 23403/***/ }), 23404/* 216 */ 23405/***/ (function(module, exports) { 23406 23407 23408 23409/***/ }), 23410/* 217 */ 23411/***/ (function(module, exports) { 23412 23413 23414 23415/***/ }), 23416/* 218 */ 23417/***/ (function(module, exports) { 23418 23419 23420 23421/***/ }), 23422/* 219 */ 23423/***/ (function(module, exports) { 23424 23425 23426 23427/***/ }), 23428/* 220 */ 23429/***/ (function(module, exports) { 23430 23431 23432 23433/***/ }), 23434/* 221 */ 23435/***/ (function(module, exports) { 23436 23437 23438 23439/***/ }), 23440/* 222 */ 23441/***/ (function(module, exports) { 23442 23443 23444 23445/***/ }), 23446/* 223 */ 23447/***/ (function(module, exports) { 23448 23449 23450 23451/***/ }), 23452/* 224 */ 23453/***/ (function(module, exports) { 23454 23455 23456 23457/***/ }), 23458/* 225 */ 23459/***/ (function(module, exports) { 23460 23461 23462 23463/***/ }), 23464/* 226 */ 23465/***/ (function(module, exports) { 23466 23467 23468 23469/***/ }), 23470/* 227 */ 23471/***/ (function(module, exports) { 23472 23473 23474 23475/***/ }), 23476/* 228 */ 23477/***/ (function(module, exports) { 23478 23479 23480 23481/***/ }), 23482/* 229 */ 23483/***/ (function(module, exports) { 23484 23485 23486 23487/***/ }), 23488/* 230 */ 23489/***/ (function(module, exports) { 23490 23491 23492 23493/***/ }), 23494/* 231 */ 23495/***/ (function(module, exports) { 23496 23497 23498 23499/***/ }), 23500/* 232 */ 23501/***/ (function(module, exports) { 23502 23503 23504 23505/***/ }), 23506/* 233 */ 23507/***/ (function(module, exports) { 23508 23509 23510 23511/***/ }), 23512/* 234 */ 23513/***/ (function(module, exports) { 23514 23515 23516 23517/***/ }), 23518/* 235 */ 23519/***/ (function(module, exports) { 23520 23521 23522 23523/***/ }), 23524/* 236 */ 23525/***/ (function(module, exports) { 23526 23527 23528 23529/***/ }), 23530/* 237 */ 23531/***/ (function(module, exports) { 23532 23533 23534 23535/***/ }), 23536/* 238 */ 23537/***/ (function(module, exports) { 23538 23539 23540 23541/***/ }), 23542/* 239 */ 23543/***/ (function(module, exports) { 23544 23545 23546 23547/***/ }), 23548/* 240 */ 23549/***/ (function(module, exports) { 23550 23551 23552 23553/***/ }), 23554/* 241 */ 23555/***/ (function(module, exports) { 23556 23557 23558 23559/***/ }), 23560/* 242 */ 23561/***/ (function(module, exports) { 23562 23563 23564 23565/***/ }), 23566/* 243 */ 23567/***/ (function(module, exports) { 23568 23569 23570 23571/***/ }), 23572/* 244 */ 23573/***/ (function(module, exports) { 23574 23575 23576 23577/***/ }), 23578/* 245 */ 23579/***/ (function(module, exports) { 23580 23581 23582 23583/***/ }), 23584/* 246 */ 23585/***/ (function(module, exports) { 23586 23587 23588 23589/***/ }), 23590/* 247 */ 23591/***/ (function(module, exports) { 23592 23593 23594 23595/***/ }), 23596/* 248 */ 23597/***/ (function(module, exports) { 23598 23599 23600 23601/***/ }), 23602/* 249 */ 23603/***/ (function(module, exports, __webpack_require__) { 23604 23605"use strict"; 23606 23607 23608/** 23609 * SheetClip - Spreadsheet Clipboard Parser 23610 * version 0.2 23611 * 23612 * This tiny library transforms JavaScript arrays to strings that are pasteable by LibreOffice, OpenOffice, 23613 * Google Docs and Microsoft Excel. 23614 * 23615 * Copyright 2012, Marcin Warpechowski 23616 * Licensed under the MIT license. 23617 * http://github.com/warpech/sheetclip/ 23618 */ 23619/*jslint white: true*/ 23620(function (global) { 23621 "use strict"; 23622 23623 function countQuotes(str) { 23624 return str.split('"').length - 1; 23625 } 23626 23627 var SheetClip = { 23628 /** 23629 * Decode spreadsheet string into array 23630 * 23631 * @param {String} str 23632 * @returns {Array} 23633 */ 23634 parse: function parse(str) { 23635 var r, 23636 rLen, 23637 rows, 23638 arr = [], 23639 a = 0, 23640 c, 23641 cLen, 23642 multiline, 23643 last; 23644 23645 rows = str.split('\n'); 23646 23647 if (rows.length > 1 && rows[rows.length - 1] === '') { 23648 rows.pop(); 23649 } 23650 for (r = 0, rLen = rows.length; r < rLen; r += 1) { 23651 rows[r] = rows[r].split('\t'); 23652 23653 for (c = 0, cLen = rows[r].length; c < cLen; c += 1) { 23654 if (!arr[a]) { 23655 arr[a] = []; 23656 } 23657 if (multiline && c === 0) { 23658 last = arr[a].length - 1; 23659 arr[a][last] = arr[a][last] + '\n' + rows[r][0]; 23660 23661 if (multiline && countQuotes(rows[r][0]) & 1) { 23662 //& 1 is a bitwise way of performing mod 2 23663 multiline = false; 23664 arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"'); 23665 } 23666 } else { 23667 if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && countQuotes(rows[r][c]) & 1) { 23668 arr[a].push(rows[r][c].substring(1).replace(/""/g, '"')); 23669 multiline = true; 23670 } else { 23671 arr[a].push(rows[r][c].replace(/""/g, '"')); 23672 multiline = false; 23673 } 23674 } 23675 } 23676 if (!multiline) { 23677 a += 1; 23678 } 23679 } 23680 23681 return arr; 23682 }, 23683 23684 /** 23685 * Encode array into valid spreadsheet string 23686 * 23687 * @param arr 23688 * @returns {String} 23689 */ 23690 stringify: function stringify(arr) { 23691 var r, 23692 rLen, 23693 c, 23694 cLen, 23695 str = '', 23696 val; 23697 23698 for (r = 0, rLen = arr.length; r < rLen; r += 1) { 23699 cLen = arr[r].length; 23700 23701 for (c = 0; c < cLen; c += 1) { 23702 if (c > 0) { 23703 str += '\t'; 23704 } 23705 val = arr[r][c]; 23706 23707 if (typeof val === 'string') { 23708 if (val.indexOf('\n') > -1) { 23709 str += '"' + val.replace(/"/g, '""') + '"'; 23710 } else { 23711 str += val; 23712 } 23713 } else if (val === null || val === void 0) { 23714 // void 0 resolves to undefined 23715 str += ''; 23716 } else { 23717 str += val; 23718 } 23719 } 23720 23721 if (r !== rLen - 1) { 23722 str += '\n'; 23723 } 23724 } 23725 23726 return str; 23727 } 23728 }; 23729 23730 if (true) { 23731 exports.parse = SheetClip.parse; 23732 exports.stringify = SheetClip.stringify; 23733 } else { 23734 global.SheetClip = SheetClip; 23735 } 23736})(window); 23737 23738/***/ }), 23739/* 250 */ 23740/***/ (function(module, exports, __webpack_require__) { 23741 23742"use strict"; 23743 23744 23745exports.__esModule = true; 23746 23747var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 23748 23749var _element = __webpack_require__(0); 23750 23751var _event = __webpack_require__(7); 23752 23753var _object = __webpack_require__(3); 23754 23755var _browser = __webpack_require__(22); 23756 23757var _eventManager = __webpack_require__(4); 23758 23759var _eventManager2 = _interopRequireDefault(_eventManager); 23760 23761var _coords = __webpack_require__(43); 23762 23763var _coords2 = _interopRequireDefault(_coords); 23764 23765var _base = __webpack_require__(29); 23766 23767var _base2 = _interopRequireDefault(_base); 23768 23769function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23770 23771function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 23772 23773/** 23774 * 23775 */ 23776var Border = function () { 23777 /** 23778 * @param {Walkontable} wotInstance 23779 * @param {Object} settings 23780 */ 23781 function Border(wotInstance, settings) { 23782 _classCallCheck(this, Border); 23783 23784 if (!settings) { 23785 return; 23786 } 23787 this.eventManager = new _eventManager2.default(wotInstance); 23788 this.instance = wotInstance; 23789 this.wot = wotInstance; 23790 this.settings = settings; 23791 this.mouseDown = false; 23792 this.main = null; 23793 23794 this.top = null; 23795 this.left = null; 23796 this.bottom = null; 23797 this.right = null; 23798 23799 this.topStyle = null; 23800 this.leftStyle = null; 23801 this.bottomStyle = null; 23802 this.rightStyle = null; 23803 23804 this.cornerDefaultStyle = { 23805 width: '5px', 23806 height: '5px', 23807 borderWidth: '2px', 23808 borderStyle: 'solid', 23809 borderColor: '#FFF' 23810 }; 23811 this.corner = null; 23812 this.cornerStyle = null; 23813 23814 this.createBorders(settings); 23815 this.registerListeners(); 23816 } 23817 23818 /** 23819 * Register all necessary events 23820 */ 23821 23822 23823 _createClass(Border, [{ 23824 key: 'registerListeners', 23825 value: function registerListeners() { 23826 var _this2 = this; 23827 23828 this.eventManager.addEventListener(document.body, 'mousedown', function () { 23829 return _this2.onMouseDown(); 23830 }); 23831 this.eventManager.addEventListener(document.body, 'mouseup', function () { 23832 return _this2.onMouseUp(); 23833 }); 23834 23835 var _loop = function _loop(c, len) { 23836 _this2.eventManager.addEventListener(_this2.main.childNodes[c], 'mouseenter', function (event) { 23837 return _this2.onMouseEnter(event, _this2.main.childNodes[c]); 23838 }); 23839 }; 23840 23841 for (var c = 0, len = this.main.childNodes.length; c < len; c++) { 23842 _loop(c, len); 23843 } 23844 } 23845 23846 /** 23847 * Mouse down listener 23848 * 23849 * @private 23850 */ 23851 23852 }, { 23853 key: 'onMouseDown', 23854 value: function onMouseDown() { 23855 this.mouseDown = true; 23856 } 23857 23858 /** 23859 * Mouse up listener 23860 * 23861 * @private 23862 */ 23863 23864 }, { 23865 key: 'onMouseUp', 23866 value: function onMouseUp() { 23867 this.mouseDown = false; 23868 } 23869 23870 /** 23871 * Mouse enter listener for fragment selection functionality. 23872 * 23873 * @private 23874 * @param {Event} event Dom event 23875 * @param {HTMLElement} parentElement Part of border element. 23876 */ 23877 23878 }, { 23879 key: 'onMouseEnter', 23880 value: function onMouseEnter(event, parentElement) { 23881 if (!this.mouseDown || !this.wot.getSetting('hideBorderOnMouseDownOver')) { 23882 return; 23883 } 23884 event.preventDefault(); 23885 (0, _event.stopImmediatePropagation)(event); 23886 23887 var _this = this; 23888 var bounds = parentElement.getBoundingClientRect(); 23889 // Hide border to prevents selection jumping when fragmentSelection is enabled. 23890 parentElement.style.display = 'none'; 23891 23892 function isOutside(event) { 23893 if (event.clientY < Math.floor(bounds.top)) { 23894 return true; 23895 } 23896 if (event.clientY > Math.ceil(bounds.top + bounds.height)) { 23897 return true; 23898 } 23899 if (event.clientX < Math.floor(bounds.left)) { 23900 return true; 23901 } 23902 if (event.clientX > Math.ceil(bounds.left + bounds.width)) { 23903 return true; 23904 } 23905 } 23906 23907 function handler(event) { 23908 if (isOutside(event)) { 23909 _this.eventManager.removeEventListener(document.body, 'mousemove', handler); 23910 parentElement.style.display = 'block'; 23911 } 23912 } 23913 23914 this.eventManager.addEventListener(document.body, 'mousemove', handler); 23915 } 23916 23917 /** 23918 * Create border elements 23919 * 23920 * @param {Object} settings 23921 */ 23922 23923 }, { 23924 key: 'createBorders', 23925 value: function createBorders(settings) { 23926 this.main = document.createElement('div'); 23927 23928 var borderDivs = ['top', 'left', 'bottom', 'right', 'corner']; 23929 var style = this.main.style; 23930 style.position = 'absolute'; 23931 style.top = 0; 23932 style.left = 0; 23933 23934 for (var i = 0; i < 5; i++) { 23935 var position = borderDivs[i]; 23936 var div = document.createElement('div'); 23937 div.className = 'wtBorder ' + (this.settings.className || ''); // + borderDivs[i]; 23938 23939 if (this.settings[position] && this.settings[position].hide) { 23940 div.className += ' hidden'; 23941 } 23942 style = div.style; 23943 style.backgroundColor = this.settings[position] && this.settings[position].color ? this.settings[position].color : settings.border.color; 23944 style.height = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px'; 23945 style.width = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px'; 23946 23947 this.main.appendChild(div); 23948 } 23949 this.top = this.main.childNodes[0]; 23950 this.left = this.main.childNodes[1]; 23951 this.bottom = this.main.childNodes[2]; 23952 this.right = this.main.childNodes[3]; 23953 23954 this.topStyle = this.top.style; 23955 this.leftStyle = this.left.style; 23956 this.bottomStyle = this.bottom.style; 23957 this.rightStyle = this.right.style; 23958 23959 this.corner = this.main.childNodes[4]; 23960 this.corner.className += ' corner'; 23961 this.cornerStyle = this.corner.style; 23962 this.cornerStyle.width = this.cornerDefaultStyle.width; 23963 this.cornerStyle.height = this.cornerDefaultStyle.height; 23964 this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' '); 23965 23966 if ((0, _browser.isMobileBrowser)()) { 23967 this.createMultipleSelectorHandles(); 23968 } 23969 this.disappear(); 23970 23971 if (!this.wot.wtTable.bordersHolder) { 23972 this.wot.wtTable.bordersHolder = document.createElement('div'); 23973 this.wot.wtTable.bordersHolder.className = 'htBorders'; 23974 this.wot.wtTable.spreader.appendChild(this.wot.wtTable.bordersHolder); 23975 } 23976 this.wot.wtTable.bordersHolder.insertBefore(this.main, this.wot.wtTable.bordersHolder.firstChild); 23977 } 23978 23979 /** 23980 * Create multiple selector handler for mobile devices 23981 */ 23982 23983 }, { 23984 key: 'createMultipleSelectorHandles', 23985 value: function createMultipleSelectorHandles() { 23986 this.selectionHandles = { 23987 topLeft: document.createElement('DIV'), 23988 topLeftHitArea: document.createElement('DIV'), 23989 bottomRight: document.createElement('DIV'), 23990 bottomRightHitArea: document.createElement('DIV') 23991 }; 23992 var width = 10; 23993 var hitAreaWidth = 40; 23994 23995 this.selectionHandles.topLeft.className = 'topLeftSelectionHandle'; 23996 this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea'; 23997 this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle'; 23998 this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea'; 23999 24000 this.selectionHandles.styles = { 24001 topLeft: this.selectionHandles.topLeft.style, 24002 topLeftHitArea: this.selectionHandles.topLeftHitArea.style, 24003 bottomRight: this.selectionHandles.bottomRight.style, 24004 bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style 24005 }; 24006 24007 var hitAreaStyle = { 24008 position: 'absolute', 24009 height: hitAreaWidth + 'px', 24010 width: hitAreaWidth + 'px', 24011 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px' 24012 }; 24013 24014 for (var prop in hitAreaStyle) { 24015 if ((0, _object.hasOwnProperty)(hitAreaStyle, prop)) { 24016 this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop]; 24017 this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop]; 24018 } 24019 } 24020 24021 var handleStyle = { 24022 position: 'absolute', 24023 height: width + 'px', 24024 width: width + 'px', 24025 'border-radius': parseInt(width / 1.5, 10) + 'px', 24026 background: '#F5F5FF', 24027 border: '1px solid #4285c8' 24028 }; 24029 24030 for (var _prop in handleStyle) { 24031 if ((0, _object.hasOwnProperty)(handleStyle, _prop)) { 24032 this.selectionHandles.styles.bottomRight[_prop] = handleStyle[_prop]; 24033 this.selectionHandles.styles.topLeft[_prop] = handleStyle[_prop]; 24034 } 24035 } 24036 this.main.appendChild(this.selectionHandles.topLeft); 24037 this.main.appendChild(this.selectionHandles.bottomRight); 24038 this.main.appendChild(this.selectionHandles.topLeftHitArea); 24039 this.main.appendChild(this.selectionHandles.bottomRightHitArea); 24040 } 24041 }, { 24042 key: 'isPartRange', 24043 value: function isPartRange(row, col) { 24044 if (this.wot.selections.area.cellRange) { 24045 if (row != this.wot.selections.area.cellRange.to.row || col != this.wot.selections.area.cellRange.to.col) { 24046 return true; 24047 } 24048 } 24049 24050 return false; 24051 } 24052 }, { 24053 key: 'updateMultipleSelectionHandlesPosition', 24054 value: function updateMultipleSelectionHandlesPosition(row, col, top, left, width, height) { 24055 var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10); 24056 var hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10); 24057 24058 this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + 'px'; 24059 this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + 'px'; 24060 24061 this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - hitAreaWidth / 4 * 3, 10) + 'px'; 24062 this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - hitAreaWidth / 4 * 3, 10) + 'px'; 24063 24064 this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + 'px'; 24065 this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + 'px'; 24066 24067 this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + 'px'; 24068 this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + 'px'; 24069 24070 if (this.settings.border.multipleSelectionHandlesVisible && this.settings.border.multipleSelectionHandlesVisible()) { 24071 this.selectionHandles.styles.topLeft.display = 'block'; 24072 this.selectionHandles.styles.topLeftHitArea.display = 'block'; 24073 24074 if (this.isPartRange(row, col)) { 24075 this.selectionHandles.styles.bottomRight.display = 'none'; 24076 this.selectionHandles.styles.bottomRightHitArea.display = 'none'; 24077 } else { 24078 this.selectionHandles.styles.bottomRight.display = 'block'; 24079 this.selectionHandles.styles.bottomRightHitArea.display = 'block'; 24080 } 24081 } else { 24082 this.selectionHandles.styles.topLeft.display = 'none'; 24083 this.selectionHandles.styles.bottomRight.display = 'none'; 24084 this.selectionHandles.styles.topLeftHitArea.display = 'none'; 24085 this.selectionHandles.styles.bottomRightHitArea.display = 'none'; 24086 } 24087 24088 if (row == this.wot.wtSettings.getSetting('fixedRowsTop') || col == this.wot.wtSettings.getSetting('fixedColumnsLeft')) { 24089 this.selectionHandles.styles.topLeft.zIndex = '9999'; 24090 this.selectionHandles.styles.topLeftHitArea.zIndex = '9999'; 24091 } else { 24092 this.selectionHandles.styles.topLeft.zIndex = ''; 24093 this.selectionHandles.styles.topLeftHitArea.zIndex = ''; 24094 } 24095 } 24096 24097 /** 24098 * Show border around one or many cells 24099 * 24100 * @param {Array} corners 24101 */ 24102 24103 }, { 24104 key: 'appear', 24105 value: function appear(corners) { 24106 if (this.disabled) { 24107 return; 24108 } 24109 var isMultiple, fromTD, toTD, fromOffset, toOffset, containerOffset, top, minTop, left, minLeft, height, width, fromRow, fromColumn, toRow, toColumn, trimmingContainer, cornerOverlappingContainer, ilen; 24110 24111 ilen = this.wot.wtTable.getRenderedRowsCount(); 24112 24113 for (var i = 0; i < ilen; i++) { 24114 var s = this.wot.wtTable.rowFilter.renderedToSource(i); 24115 24116 if (s >= corners[0] && s <= corners[2]) { 24117 fromRow = s; 24118 break; 24119 } 24120 } 24121 24122 for (var _i = ilen - 1; _i >= 0; _i--) { 24123 var _s = this.wot.wtTable.rowFilter.renderedToSource(_i); 24124 24125 if (_s >= corners[0] && _s <= corners[2]) { 24126 toRow = _s; 24127 break; 24128 } 24129 } 24130 24131 ilen = this.wot.wtTable.getRenderedColumnsCount(); 24132 24133 for (var _i2 = 0; _i2 < ilen; _i2++) { 24134 var _s2 = this.wot.wtTable.columnFilter.renderedToSource(_i2); 24135 24136 if (_s2 >= corners[1] && _s2 <= corners[3]) { 24137 fromColumn = _s2; 24138 break; 24139 } 24140 } 24141 24142 for (var _i3 = ilen - 1; _i3 >= 0; _i3--) { 24143 var _s3 = this.wot.wtTable.columnFilter.renderedToSource(_i3); 24144 24145 if (_s3 >= corners[1] && _s3 <= corners[3]) { 24146 toColumn = _s3; 24147 break; 24148 } 24149 } 24150 if (fromRow === void 0 || fromColumn === void 0) { 24151 this.disappear(); 24152 24153 return; 24154 } 24155 isMultiple = fromRow !== toRow || fromColumn !== toColumn; 24156 fromTD = this.wot.wtTable.getCell(new _coords2.default(fromRow, fromColumn)); 24157 toTD = isMultiple ? this.wot.wtTable.getCell(new _coords2.default(toRow, toColumn)) : fromTD; 24158 fromOffset = (0, _element.offset)(fromTD); 24159 toOffset = isMultiple ? (0, _element.offset)(toTD) : fromOffset; 24160 containerOffset = (0, _element.offset)(this.wot.wtTable.TABLE); 24161 24162 minTop = fromOffset.top; 24163 height = toOffset.top + (0, _element.outerHeight)(toTD) - minTop; 24164 minLeft = fromOffset.left; 24165 width = toOffset.left + (0, _element.outerWidth)(toTD) - minLeft; 24166 24167 top = minTop - containerOffset.top - 1; 24168 left = minLeft - containerOffset.left - 1; 24169 var style = (0, _element.getComputedStyle)(fromTD); 24170 24171 if (parseInt(style.borderTopWidth, 10) > 0) { 24172 top += 1; 24173 height = height > 0 ? height - 1 : 0; 24174 } 24175 if (parseInt(style.borderLeftWidth, 10) > 0) { 24176 left += 1; 24177 width = width > 0 ? width - 1 : 0; 24178 } 24179 24180 this.topStyle.top = top + 'px'; 24181 this.topStyle.left = left + 'px'; 24182 this.topStyle.width = width + 'px'; 24183 this.topStyle.display = 'block'; 24184 24185 this.leftStyle.top = top + 'px'; 24186 this.leftStyle.left = left + 'px'; 24187 this.leftStyle.height = height + 'px'; 24188 this.leftStyle.display = 'block'; 24189 24190 var delta = Math.floor(this.settings.border.width / 2); 24191 24192 this.bottomStyle.top = top + height - delta + 'px'; 24193 this.bottomStyle.left = left + 'px'; 24194 this.bottomStyle.width = width + 'px'; 24195 this.bottomStyle.display = 'block'; 24196 24197 this.rightStyle.top = top + 'px'; 24198 this.rightStyle.left = left + width - delta + 'px'; 24199 this.rightStyle.height = height + 1 + 'px'; 24200 this.rightStyle.display = 'block'; 24201 24202 if ((0, _browser.isMobileBrowser)() || !this.hasSetting(this.settings.border.cornerVisible) || this.isPartRange(toRow, toColumn)) { 24203 this.cornerStyle.display = 'none'; 24204 } else { 24205 this.cornerStyle.top = top + height - 4 + 'px'; 24206 this.cornerStyle.left = left + width - 4 + 'px'; 24207 this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth; 24208 this.cornerStyle.width = this.cornerDefaultStyle.width; 24209 24210 // Hide the fill handle, so the possible further adjustments won't force unneeded scrollbars. 24211 this.cornerStyle.display = 'none'; 24212 24213 trimmingContainer = (0, _element.getTrimmingContainer)(this.wot.wtTable.TABLE); 24214 24215 if (toColumn === this.wot.getSetting('totalColumns') - 1) { 24216 cornerOverlappingContainer = toTD.offsetLeft + (0, _element.outerWidth)(toTD) + parseInt(this.cornerDefaultStyle.width, 10) / 2 >= (0, _element.innerWidth)(trimmingContainer); 24217 24218 if (cornerOverlappingContainer) { 24219 this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width, 10) / 2) + 'px'; 24220 this.cornerStyle.borderRightWidth = 0; 24221 } 24222 } 24223 24224 if (toRow === this.wot.getSetting('totalRows') - 1) { 24225 cornerOverlappingContainer = toTD.offsetTop + (0, _element.outerHeight)(toTD) + parseInt(this.cornerDefaultStyle.height, 10) / 2 >= (0, _element.innerHeight)(trimmingContainer); 24226 24227 if (cornerOverlappingContainer) { 24228 this.cornerStyle.top = Math.floor(top + height - 3 - parseInt(this.cornerDefaultStyle.height, 10) / 2) + 'px'; 24229 this.cornerStyle.borderBottomWidth = 0; 24230 } 24231 } 24232 24233 this.cornerStyle.display = 'block'; 24234 } 24235 24236 if ((0, _browser.isMobileBrowser)()) { 24237 this.updateMultipleSelectionHandlesPosition(fromRow, fromColumn, top, left, width, height); 24238 } 24239 } 24240 24241 /** 24242 * Hide border 24243 */ 24244 24245 }, { 24246 key: 'disappear', 24247 value: function disappear() { 24248 this.topStyle.display = 'none'; 24249 this.leftStyle.display = 'none'; 24250 this.bottomStyle.display = 'none'; 24251 this.rightStyle.display = 'none'; 24252 this.cornerStyle.display = 'none'; 24253 24254 if ((0, _browser.isMobileBrowser)()) { 24255 this.selectionHandles.styles.topLeft.display = 'none'; 24256 this.selectionHandles.styles.bottomRight.display = 'none'; 24257 } 24258 } 24259 24260 /** 24261 * @param {Function} setting 24262 * @returns {*} 24263 */ 24264 24265 }, { 24266 key: 'hasSetting', 24267 value: function hasSetting(setting) { 24268 if (typeof setting === 'function') { 24269 return setting(); 24270 } 24271 24272 return !!setting; 24273 } 24274 }]); 24275 24276 return Border; 24277}(); 24278 24279exports.default = Border; 24280 24281/***/ }), 24282/* 251 */ 24283/***/ (function(module, exports, __webpack_require__) { 24284 24285"use strict"; 24286 24287 24288exports.__esModule = true; 24289 24290var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 24291 24292function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 24293 24294var privatePool = new WeakMap(); 24295 24296/** 24297 * Calculates indexes of columns to render OR columns that are visible. 24298 * To redo the calculation, you need to create a new calculator. 24299 * 24300 * @class ViewportColumnsCalculator 24301 */ 24302 24303var ViewportColumnsCalculator = function () { 24304 _createClass(ViewportColumnsCalculator, null, [{ 24305 key: 'DEFAULT_WIDTH', 24306 24307 /** 24308 * Default column width 24309 * 24310 * @type {Number} 24311 */ 24312 get: function get() { 24313 return 50; 24314 } 24315 24316 /** 24317 * @param {Number} viewportWidth Width of the viewport 24318 * @param {Number} scrollOffset Current horizontal scroll position of the viewport 24319 * @param {Number} totalColumns Total number of rows 24320 * @param {Function} columnWidthFn Function that returns the width of the column at a given index (in px) 24321 * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin) 24322 * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport 24323 * @param {Boolean} stretchH 24324 * @param {Function} [stretchingColumnWidthFn] Function that returns the new width of the stretched column. 24325 */ 24326 24327 }]); 24328 24329 function ViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) { 24330 var stretchingColumnWidthFn = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : function (width) { 24331 return width; 24332 }; 24333 24334 _classCallCheck(this, ViewportColumnsCalculator); 24335 24336 privatePool.set(this, { 24337 viewportWidth: viewportWidth, 24338 scrollOffset: scrollOffset, 24339 totalColumns: totalColumns, 24340 columnWidthFn: columnWidthFn, 24341 overrideFn: overrideFn, 24342 onlyFullyVisible: onlyFullyVisible, 24343 stretchingColumnWidthFn: stretchingColumnWidthFn 24344 }); 24345 24346 /** 24347 * Number of rendered/visible columns 24348 * 24349 * @type {Number} 24350 */ 24351 this.count = 0; 24352 24353 /** 24354 * Index of the first rendered/visible column (can be overwritten using overrideFn) 24355 * 24356 * @type {Number|null} 24357 */ 24358 this.startColumn = null; 24359 24360 /** 24361 * Index of the last rendered/visible column (can be overwritten using overrideFn) 24362 * 24363 * @type {null} 24364 */ 24365 this.endColumn = null; 24366 24367 /** 24368 * Position of the first rendered/visible column (in px) 24369 * 24370 * @type {Number|null} 24371 */ 24372 this.startPosition = null; 24373 24374 this.stretchAllRatio = 0; 24375 this.stretchLastWidth = 0; 24376 this.stretch = stretchH; 24377 this.totalTargetWidth = 0; 24378 this.needVerifyLastColumnWidth = true; 24379 this.stretchAllColumnsWidth = []; 24380 24381 this.calculate(); 24382 } 24383 24384 /** 24385 * Calculates viewport 24386 */ 24387 24388 24389 _createClass(ViewportColumnsCalculator, [{ 24390 key: 'calculate', 24391 value: function calculate() { 24392 var sum = 0; 24393 var needReverse = true; 24394 var startPositions = []; 24395 var columnWidth = void 0; 24396 24397 var priv = privatePool.get(this); 24398 var onlyFullyVisible = priv.onlyFullyVisible; 24399 var overrideFn = priv.overrideFn; 24400 var scrollOffset = priv.scrollOffset; 24401 var totalColumns = priv.totalColumns; 24402 var viewportWidth = priv.viewportWidth; 24403 24404 for (var i = 0; i < totalColumns; i++) { 24405 columnWidth = this._getColumnWidth(i); 24406 24407 if (sum <= scrollOffset && !onlyFullyVisible) { 24408 this.startColumn = i; 24409 } 24410 24411 // +1 pixel for row header width compensation for horizontal scroll > 0 24412 var compensatedViewportWidth = scrollOffset > 0 ? viewportWidth + 1 : viewportWidth; 24413 24414 if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + compensatedViewportWidth) { 24415 if (this.startColumn == null) { 24416 this.startColumn = i; 24417 } 24418 this.endColumn = i; 24419 } 24420 startPositions.push(sum); 24421 sum += columnWidth; 24422 24423 if (!onlyFullyVisible) { 24424 this.endColumn = i; 24425 } 24426 if (sum >= scrollOffset + viewportWidth) { 24427 needReverse = false; 24428 break; 24429 } 24430 } 24431 24432 if (this.endColumn === totalColumns - 1 && needReverse) { 24433 this.startColumn = this.endColumn; 24434 24435 while (this.startColumn > 0) { 24436 var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1]; 24437 24438 if (viewportSum <= viewportWidth || !onlyFullyVisible) { 24439 this.startColumn--; 24440 } 24441 if (viewportSum > viewportWidth) { 24442 break; 24443 } 24444 } 24445 } 24446 24447 if (this.startColumn !== null && overrideFn) { 24448 overrideFn(this); 24449 } 24450 this.startPosition = startPositions[this.startColumn]; 24451 24452 if (this.startPosition == void 0) { 24453 this.startPosition = null; 24454 } 24455 if (this.startColumn !== null) { 24456 this.count = this.endColumn - this.startColumn + 1; 24457 } 24458 } 24459 24460 /** 24461 * Recalculate columns stretching. 24462 * 24463 * @param {Number} totalWidth 24464 */ 24465 24466 }, { 24467 key: 'refreshStretching', 24468 value: function refreshStretching(totalWidth) { 24469 if (this.stretch === 'none') { 24470 return; 24471 } 24472 this.totalTargetWidth = totalWidth; 24473 24474 var priv = privatePool.get(this); 24475 var totalColumns = priv.totalColumns; 24476 var sumAll = 0; 24477 24478 for (var i = 0; i < totalColumns; i++) { 24479 var columnWidth = this._getColumnWidth(i); 24480 var permanentColumnWidth = priv.stretchingColumnWidthFn(void 0, i); 24481 24482 if (typeof permanentColumnWidth === 'number') { 24483 totalWidth -= permanentColumnWidth; 24484 } else { 24485 sumAll += columnWidth; 24486 } 24487 } 24488 var remainingSize = totalWidth - sumAll; 24489 24490 if (this.stretch === 'all' && remainingSize > 0) { 24491 this.stretchAllRatio = totalWidth / sumAll; 24492 this.stretchAllColumnsWidth = []; 24493 this.needVerifyLastColumnWidth = true; 24494 } else if (this.stretch === 'last' && totalWidth !== Infinity) { 24495 var _columnWidth = this._getColumnWidth(totalColumns - 1); 24496 var lastColumnWidth = remainingSize + _columnWidth; 24497 24498 this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : _columnWidth; 24499 } 24500 } 24501 24502 /** 24503 * Get stretched column width based on stretchH (all or last) setting passed in handsontable instance. 24504 * 24505 * @param {Number} column 24506 * @param {Number} baseWidth 24507 * @returns {Number|null} 24508 */ 24509 24510 }, { 24511 key: 'getStretchedColumnWidth', 24512 value: function getStretchedColumnWidth(column, baseWidth) { 24513 var result = null; 24514 24515 if (this.stretch === 'all' && this.stretchAllRatio !== 0) { 24516 result = this._getStretchedAllColumnWidth(column, baseWidth); 24517 } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) { 24518 result = this._getStretchedLastColumnWidth(column); 24519 } 24520 24521 return result; 24522 } 24523 24524 /** 24525 * @param {Number} column 24526 * @param {Number} baseWidth 24527 * @returns {Number} 24528 * @private 24529 */ 24530 24531 }, { 24532 key: '_getStretchedAllColumnWidth', 24533 value: function _getStretchedAllColumnWidth(column, baseWidth) { 24534 var sumRatioWidth = 0; 24535 var priv = privatePool.get(this); 24536 var totalColumns = priv.totalColumns; 24537 24538 if (!this.stretchAllColumnsWidth[column]) { 24539 var stretchedWidth = Math.round(baseWidth * this.stretchAllRatio); 24540 var newStretchedWidth = priv.stretchingColumnWidthFn(stretchedWidth, column); 24541 24542 if (newStretchedWidth === void 0) { 24543 this.stretchAllColumnsWidth[column] = stretchedWidth; 24544 } else { 24545 this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth; 24546 } 24547 } 24548 24549 if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) { 24550 this.needVerifyLastColumnWidth = false; 24551 24552 for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) { 24553 sumRatioWidth += this.stretchAllColumnsWidth[i]; 24554 } 24555 if (sumRatioWidth !== this.totalTargetWidth) { 24556 this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth; 24557 } 24558 } 24559 24560 return this.stretchAllColumnsWidth[column]; 24561 } 24562 24563 /** 24564 * @param {Number} column 24565 * @returns {Number|null} 24566 * @private 24567 */ 24568 24569 }, { 24570 key: '_getStretchedLastColumnWidth', 24571 value: function _getStretchedLastColumnWidth(column) { 24572 var priv = privatePool.get(this); 24573 var totalColumns = priv.totalColumns; 24574 24575 if (column === totalColumns - 1) { 24576 return this.stretchLastWidth; 24577 } 24578 24579 return null; 24580 } 24581 24582 /** 24583 * @param {Number} column Column index. 24584 * @returns {Number} 24585 * @private 24586 */ 24587 24588 }, { 24589 key: '_getColumnWidth', 24590 value: function _getColumnWidth(column) { 24591 var width = privatePool.get(this).columnWidthFn(column); 24592 24593 if (width === void 0) { 24594 width = ViewportColumnsCalculator.DEFAULT_WIDTH; 24595 } 24596 24597 return width; 24598 } 24599 }]); 24600 24601 return ViewportColumnsCalculator; 24602}(); 24603 24604exports.default = ViewportColumnsCalculator; 24605 24606/***/ }), 24607/* 252 */ 24608/***/ (function(module, exports, __webpack_require__) { 24609 24610"use strict"; 24611 24612 24613exports.__esModule = true; 24614 24615var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 24616 24617function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 24618 24619var privatePool = new WeakMap(); 24620 24621/** 24622 * Calculates indexes of rows to render OR rows that are visible. 24623 * To redo the calculation, you need to create a new calculator. 24624 * 24625 * @class ViewportRowsCalculator 24626 */ 24627 24628var ViewportRowsCalculator = function () { 24629 _createClass(ViewportRowsCalculator, null, [{ 24630 key: "DEFAULT_HEIGHT", 24631 24632 /** 24633 * Default row height 24634 * 24635 * @type {Number} 24636 */ 24637 get: function get() { 24638 return 23; 24639 } 24640 24641 /** 24642 * @param {Number} viewportHeight Height of the viewport 24643 * @param {Number} scrollOffset Current vertical scroll position of the viewport 24644 * @param {Number} totalRows Total number of rows 24645 * @param {Function} rowHeightFn Function that returns the height of the row at a given index (in px) 24646 * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin) 24647 * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport 24648 * @param {Number} horizontalScrollbarHeight 24649 */ 24650 24651 }]); 24652 24653 function ViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible, horizontalScrollbarHeight) { 24654 _classCallCheck(this, ViewportRowsCalculator); 24655 24656 privatePool.set(this, { 24657 viewportHeight: viewportHeight, 24658 scrollOffset: scrollOffset, 24659 totalRows: totalRows, 24660 rowHeightFn: rowHeightFn, 24661 overrideFn: overrideFn, 24662 onlyFullyVisible: onlyFullyVisible, 24663 horizontalScrollbarHeight: horizontalScrollbarHeight 24664 }); 24665 24666 /** 24667 * Number of rendered/visible rows 24668 * 24669 * @type {Number} 24670 */ 24671 this.count = 0; 24672 24673 /** 24674 * Index of the first rendered/visible row (can be overwritten using overrideFn) 24675 * 24676 * @type {Number|null} 24677 */ 24678 this.startRow = null; 24679 24680 /** 24681 * Index of the last rendered/visible row (can be overwritten using overrideFn) 24682 * 24683 * @type {null} 24684 */ 24685 this.endRow = null; 24686 24687 /** 24688 * Position of the first rendered/visible row (in px) 24689 * 24690 * @type {Number|null} 24691 */ 24692 this.startPosition = null; 24693 24694 this.calculate(); 24695 } 24696 24697 /** 24698 * Calculates viewport 24699 */ 24700 24701 24702 _createClass(ViewportRowsCalculator, [{ 24703 key: "calculate", 24704 value: function calculate() { 24705 var sum = 0; 24706 var needReverse = true; 24707 var startPositions = []; 24708 24709 var priv = privatePool.get(this); 24710 var onlyFullyVisible = priv.onlyFullyVisible; 24711 var overrideFn = priv.overrideFn; 24712 var rowHeightFn = priv.rowHeightFn; 24713 var scrollOffset = priv.scrollOffset; 24714 var totalRows = priv.totalRows; 24715 var viewportHeight = priv.viewportHeight; 24716 var horizontalScrollbarHeight = priv.horizontalScrollbarHeight || 0; 24717 var rowHeight = void 0; 24718 24719 // Calculate the number (start and end index) of rows needed 24720 for (var i = 0; i < totalRows; i++) { 24721 rowHeight = rowHeightFn(i); 24722 24723 if (rowHeight === undefined) { 24724 rowHeight = ViewportRowsCalculator.DEFAULT_HEIGHT; 24725 } 24726 if (sum <= scrollOffset && !onlyFullyVisible) { 24727 this.startRow = i; 24728 } 24729 24730 // the row is within the "visible range" 24731 if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight - horizontalScrollbarHeight) { 24732 if (this.startRow === null) { 24733 this.startRow = i; 24734 } 24735 this.endRow = i; 24736 } 24737 startPositions.push(sum); 24738 sum += rowHeight; 24739 24740 if (!onlyFullyVisible) { 24741 this.endRow = i; 24742 } 24743 if (sum >= scrollOffset + viewportHeight - horizontalScrollbarHeight) { 24744 needReverse = false; 24745 break; 24746 } 24747 } 24748 24749 // If the estimation has reached the last row and there is still some space available in the viewport, 24750 // we need to render in reverse in order to fill the whole viewport with rows 24751 if (this.endRow === totalRows - 1 && needReverse) { 24752 this.startRow = this.endRow; 24753 24754 while (this.startRow > 0) { 24755 // rowHeight is the height of the last row 24756 var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1]; 24757 24758 if (viewportSum <= viewportHeight - horizontalScrollbarHeight || !onlyFullyVisible) { 24759 this.startRow--; 24760 } 24761 if (viewportSum >= viewportHeight - horizontalScrollbarHeight) { 24762 break; 24763 } 24764 } 24765 } 24766 24767 if (this.startRow !== null && overrideFn) { 24768 overrideFn(this); 24769 } 24770 this.startPosition = startPositions[this.startRow]; 24771 24772 if (this.startPosition == void 0) { 24773 this.startPosition = null; 24774 } 24775 if (this.startRow !== null) { 24776 this.count = this.endRow - this.startRow + 1; 24777 } 24778 } 24779 }]); 24780 24781 return ViewportRowsCalculator; 24782}(); 24783 24784exports.default = ViewportRowsCalculator; 24785 24786/***/ }), 24787/* 253 */ 24788/***/ (function(module, exports, __webpack_require__) { 24789 24790"use strict"; 24791 24792 24793exports.__esModule = true; 24794 24795var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 24796 24797var _element = __webpack_require__(0); 24798 24799var _object = __webpack_require__(3); 24800 24801var _string = __webpack_require__(28); 24802 24803var _event = __webpack_require__(254); 24804 24805var _event2 = _interopRequireDefault(_event); 24806 24807var _overlays = __webpack_require__(257); 24808 24809var _overlays2 = _interopRequireDefault(_overlays); 24810 24811var _scroll = __webpack_require__(258); 24812 24813var _scroll2 = _interopRequireDefault(_scroll); 24814 24815var _settings = __webpack_require__(259); 24816 24817var _settings2 = _interopRequireDefault(_settings); 24818 24819var _table = __webpack_require__(260); 24820 24821var _table2 = _interopRequireDefault(_table); 24822 24823var _viewport = __webpack_require__(262); 24824 24825var _viewport2 = _interopRequireDefault(_viewport); 24826 24827function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24828 24829function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 24830 24831/** 24832 * @class Walkontable 24833 */ 24834var Walkontable = function () { 24835 /** 24836 * @param {Object} settings 24837 */ 24838 function Walkontable(settings) { 24839 _classCallCheck(this, Walkontable); 24840 24841 var originalHeaders = []; 24842 24843 // this is the namespace for global events 24844 this.guid = 'wt_' + (0, _string.randomString)(); 24845 24846 // bootstrap from settings 24847 if (settings.cloneSource) { 24848 this.cloneSource = settings.cloneSource; 24849 this.cloneOverlay = settings.cloneOverlay; 24850 this.wtSettings = settings.cloneSource.wtSettings; 24851 this.wtTable = new _table2.default(this, settings.table, settings.wtRootElement); 24852 this.wtScroll = new _scroll2.default(this); 24853 this.wtViewport = settings.cloneSource.wtViewport; 24854 this.wtEvent = new _event2.default(this); 24855 this.selections = this.cloneSource.selections; 24856 } else { 24857 this.wtSettings = new _settings2.default(this, settings); 24858 this.wtTable = new _table2.default(this, settings.table); 24859 this.wtScroll = new _scroll2.default(this); 24860 this.wtViewport = new _viewport2.default(this); 24861 this.wtEvent = new _event2.default(this); 24862 this.selections = this.getSetting('selections'); 24863 this.wtOverlays = new _overlays2.default(this); 24864 this.exportSettingsAsClassNames(); 24865 } 24866 24867 // find original headers 24868 if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) { 24869 for (var c = 0, clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) { 24870 originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML); 24871 } 24872 if (!this.getSetting('columnHeaders').length) { 24873 this.update('columnHeaders', [function (column, TH) { 24874 (0, _element.fastInnerText)(TH, originalHeaders[column]); 24875 }]); 24876 } 24877 } 24878 this.drawn = false; 24879 this.drawInterrupted = false; 24880 } 24881 24882 /** 24883 * Force rerender of Walkontable 24884 * 24885 * @param {Boolean} [fastDraw=false] When `true`, try to refresh only the positions of borders without rerendering 24886 * the data. It will only work if Table.draw() does not force 24887 * rendering anyway 24888 * @returns {Walkontable} 24889 */ 24890 24891 24892 _createClass(Walkontable, [{ 24893 key: 'draw', 24894 value: function draw() { 24895 var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 24896 24897 this.drawInterrupted = false; 24898 24899 if (!fastDraw && !(0, _element.isVisible)(this.wtTable.TABLE)) { 24900 // draw interrupted because TABLE is not visible 24901 this.drawInterrupted = true; 24902 } else { 24903 this.wtTable.draw(fastDraw); 24904 } 24905 24906 return this; 24907 } 24908 24909 /** 24910 * Returns the TD at coords. If topmost is set to true, returns TD from the topmost overlay layer, 24911 * if not set or set to false, returns TD from the master table. 24912 * 24913 * @param {CellCoords} coords 24914 * @param {Boolean} [topmost=false] 24915 * @returns {Object} 24916 */ 24917 24918 }, { 24919 key: 'getCell', 24920 value: function getCell(coords) { 24921 var topmost = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 24922 24923 if (!topmost) { 24924 return this.wtTable.getCell(coords); 24925 } 24926 24927 var totalRows = this.wtSettings.getSetting('totalRows'); 24928 var fixedRowsTop = this.wtSettings.getSetting('fixedRowsTop'); 24929 var fixedRowsBottom = this.wtSettings.getSetting('fixedRowsBottom'); 24930 var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft'); 24931 24932 if (coords.row < fixedRowsTop && coords.col < fixedColumns) { 24933 return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords); 24934 } else if (coords.row < fixedRowsTop) { 24935 return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords); 24936 } else if (coords.col < fixedColumns && coords.row >= totalRows - fixedRowsBottom) { 24937 if (this.wtOverlays.bottomLeftCornerOverlay && this.wtOverlays.bottomLeftCornerOverlay.clone) { 24938 return this.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell(coords); 24939 } 24940 } else if (coords.col < fixedColumns) { 24941 return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords); 24942 } else if (coords.row < totalRows && coords.row > totalRows - fixedRowsBottom) { 24943 if (this.wtOverlays.bottomOverlay && this.wtOverlays.bottomOverlay.clone) { 24944 return this.wtOverlays.bottomOverlay.clone.wtTable.getCell(coords); 24945 } 24946 } 24947 24948 return this.wtTable.getCell(coords); 24949 } 24950 24951 /** 24952 * @param {Object} settings 24953 * @param {*} value 24954 * @returns {Walkontable} 24955 */ 24956 24957 }, { 24958 key: 'update', 24959 value: function update(settings, value) { 24960 return this.wtSettings.update(settings, value); 24961 } 24962 24963 /** 24964 * Scroll the viewport to a row at the given index in the data source 24965 * 24966 * @param {Number} row 24967 * @returns {Walkontable} 24968 */ 24969 24970 }, { 24971 key: 'scrollVertical', 24972 value: function scrollVertical(row) { 24973 this.wtOverlays.topOverlay.scrollTo(row); 24974 this.getSetting('onScrollVertically'); 24975 24976 return this; 24977 } 24978 24979 /** 24980 * Scroll the viewport to a column at the given index in the data source 24981 * 24982 * @param {Number} column 24983 * @returns {Walkontable} 24984 */ 24985 24986 }, { 24987 key: 'scrollHorizontal', 24988 value: function scrollHorizontal(column) { 24989 this.wtOverlays.leftOverlay.scrollTo(column); 24990 this.getSetting('onScrollHorizontally'); 24991 24992 return this; 24993 } 24994 24995 /** 24996 * Scrolls the viewport to a cell (rerenders if needed) 24997 * 24998 * @param {CellCoords} coords 24999 * @returns {Walkontable} 25000 */ 25001 25002 }, { 25003 key: 'scrollViewport', 25004 value: function scrollViewport(coords) { 25005 this.wtScroll.scrollViewport(coords); 25006 25007 return this; 25008 } 25009 25010 /** 25011 * @returns {Array} 25012 */ 25013 25014 }, { 25015 key: 'getViewport', 25016 value: function getViewport() { 25017 return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()]; 25018 } 25019 25020 /** 25021 * Get overlay name 25022 * 25023 * @returns {String} 25024 */ 25025 25026 }, { 25027 key: 'getOverlayName', 25028 value: function getOverlayName() { 25029 return this.cloneOverlay ? this.cloneOverlay.type : 'master'; 25030 } 25031 25032 /** 25033 * Check overlay type of this Walkontable instance. 25034 * 25035 * @param {String} name Clone type @see {Overlay.CLONE_TYPES}. 25036 * @returns {Boolean} 25037 */ 25038 25039 }, { 25040 key: 'isOverlayName', 25041 value: function isOverlayName(name) { 25042 if (this.cloneOverlay) { 25043 return this.cloneOverlay.type === name; 25044 } 25045 25046 return false; 25047 } 25048 25049 /** 25050 * Export settings as class names added to the parent element of the table. 25051 */ 25052 25053 }, { 25054 key: 'exportSettingsAsClassNames', 25055 value: function exportSettingsAsClassNames() { 25056 var _this = this; 25057 25058 var toExport = { 25059 rowHeaders: ['array'], 25060 columnHeaders: ['array'] 25061 }; 25062 var allClassNames = []; 25063 var newClassNames = []; 25064 25065 (0, _object.objectEach)(toExport, function (optionType, key) { 25066 if (optionType.indexOf('array') > -1 && _this.getSetting(key).length) { 25067 newClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key)); 25068 } 25069 allClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key)); 25070 }); 25071 (0, _element.removeClass)(this.wtTable.wtRootElement.parentNode, allClassNames); 25072 (0, _element.addClass)(this.wtTable.wtRootElement.parentNode, newClassNames); 25073 } 25074 25075 /** 25076 * Get/Set Walkontable instance setting 25077 * 25078 * @param {String} key 25079 * @param {*} [param1] 25080 * @param {*} [param2] 25081 * @param {*} [param3] 25082 * @param {*} [param4] 25083 * @returns {*} 25084 */ 25085 25086 }, { 25087 key: 'getSetting', 25088 value: function getSetting(key, param1, param2, param3, param4) { 25089 // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips 25090 return this.wtSettings.getSetting(key, param1, param2, param3, param4); 25091 } 25092 25093 /** 25094 * Checks if setting exists 25095 * 25096 * @param {String} key 25097 * @returns {Boolean} 25098 */ 25099 25100 }, { 25101 key: 'hasSetting', 25102 value: function hasSetting(key) { 25103 return this.wtSettings.has(key); 25104 } 25105 25106 /** 25107 * Destroy instance 25108 */ 25109 25110 }, { 25111 key: 'destroy', 25112 value: function destroy() { 25113 this.wtOverlays.destroy(); 25114 this.wtEvent.destroy(); 25115 } 25116 }]); 25117 25118 return Walkontable; 25119}(); 25120 25121exports.default = Walkontable; 25122 25123/***/ }), 25124/* 254 */ 25125/***/ (function(module, exports, __webpack_require__) { 25126 25127"use strict"; 25128 25129 25130exports.__esModule = true; 25131 25132var _element = __webpack_require__(0); 25133 25134var _function = __webpack_require__(35); 25135 25136var _browser = __webpack_require__(22); 25137 25138var _eventManager = __webpack_require__(4); 25139 25140var _eventManager2 = _interopRequireDefault(_eventManager); 25141 25142function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 25143 25144/** 25145 * 25146 */ 25147function Event(instance) { 25148 var that = this; 25149 var eventManager = new _eventManager2.default(instance); 25150 25151 this.instance = instance; 25152 25153 var dblClickOrigin = [null, null]; 25154 this.dblClickTimeout = [null, null]; 25155 25156 var onMouseDown = function onMouseDown(event) { 25157 var activeElement = document.activeElement; 25158 var getParentNode = (0, _function.partial)(_element.getParent, event.realTarget); 25159 var realTarget = event.realTarget; 25160 25161 // ignore focusable element from mouse down processing (https://github.com/handsontable/handsontable/issues/3555) 25162 if (realTarget === activeElement || getParentNode(0) === activeElement || getParentNode(1) === activeElement) { 25163 return; 25164 } 25165 25166 var cell = that.parentCell(realTarget); 25167 25168 if ((0, _element.hasClass)(realTarget, 'corner')) { 25169 that.instance.getSetting('onCellCornerMouseDown', event, realTarget); 25170 } else if (cell.TD) { 25171 if (that.instance.hasSetting('onCellMouseDown')) { 25172 that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance); 25173 } 25174 } 25175 25176 if (event.button !== 2) { 25177 // if not right mouse button 25178 if (cell.TD) { 25179 dblClickOrigin[0] = cell.TD; 25180 clearTimeout(that.dblClickTimeout[0]); 25181 that.dblClickTimeout[0] = setTimeout(function () { 25182 dblClickOrigin[0] = null; 25183 }, 1000); 25184 } 25185 } 25186 }; 25187 25188 var onTouchMove = function onTouchMove(event) { 25189 that.instance.touchMoving = true; 25190 }; 25191 25192 var longTouchTimeout; 25193 25194 var onTouchStart = function onTouchStart(event) { 25195 var container = this; 25196 25197 eventManager.addEventListener(this, 'touchmove', onTouchMove); 25198 25199 // Prevent cell selection when scrolling with touch event - not the best solution performance-wise 25200 that.checkIfTouchMove = setTimeout(function () { 25201 if (that.instance.touchMoving === true) { 25202 that.instance.touchMoving = void 0; 25203 25204 eventManager.removeEventListener('touchmove', onTouchMove, false); 25205 } 25206 25207 onMouseDown(event); 25208 }, 30); 25209 }; 25210 25211 var onMouseOver = function onMouseOver(event) { 25212 var table, td, mainWOT; 25213 25214 if (that.instance.hasSetting('onCellMouseOver')) { 25215 table = that.instance.wtTable.TABLE; 25216 td = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table); 25217 mainWOT = that.instance.cloneSource || that.instance; 25218 25219 if (td && td !== mainWOT.lastMouseOver && (0, _element.isChildOf)(td, table)) { 25220 mainWOT.lastMouseOver = td; 25221 25222 that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance); 25223 } 25224 } 25225 }; 25226 25227 var onMouseOut = function onMouseOut(event) { 25228 var table = void 0; 25229 var lastTD = void 0; 25230 var nextTD = void 0; 25231 25232 if (that.instance.hasSetting('onCellMouseOut')) { 25233 table = that.instance.wtTable.TABLE; 25234 lastTD = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table); 25235 nextTD = (0, _element.closestDown)(event.relatedTarget, ['TD', 'TH'], table); 25236 25237 if (lastTD && lastTD !== nextTD && (0, _element.isChildOf)(lastTD, table)) { 25238 that.instance.getSetting('onCellMouseOut', event, that.instance.wtTable.getCoords(lastTD), lastTD, that.instance); 25239 } 25240 } 25241 }; 25242 25243 var onMouseUp = function onMouseUp(event) { 25244 if (event.button !== 2) { 25245 // if not right mouse button 25246 var cell = that.parentCell(event.realTarget); 25247 25248 if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) { 25249 if ((0, _element.hasClass)(event.realTarget, 'corner')) { 25250 that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance); 25251 } else { 25252 that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance); 25253 } 25254 25255 dblClickOrigin[0] = null; 25256 dblClickOrigin[1] = null; 25257 } else if (cell.TD === dblClickOrigin[0]) { 25258 that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance); 25259 25260 dblClickOrigin[1] = cell.TD; 25261 clearTimeout(that.dblClickTimeout[1]); 25262 that.dblClickTimeout[1] = setTimeout(function () { 25263 dblClickOrigin[1] = null; 25264 }, 500); 25265 } else if (cell.TD && that.instance.hasSetting('onCellMouseUp')) { 25266 that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance); 25267 } 25268 } 25269 }; 25270 25271 var onTouchEnd = function onTouchEnd(event) { 25272 clearTimeout(longTouchTimeout); 25273 // that.instance.longTouch == void 0; 25274 25275 event.preventDefault(); 25276 onMouseUp(event); 25277 25278 // eventManager.removeEventListener(that.instance.wtTable.holder, "mouseup", onMouseUp); 25279 }; 25280 25281 eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown); 25282 eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver); 25283 eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseout', onMouseOut); 25284 eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp); 25285 25286 // check if full HOT instance, or detached WOT AND run on mobile device 25287 if (this.instance.wtTable.holder.parentNode.parentNode && (0, _browser.isMobileBrowser)() && !that.instance.wtTable.isWorkingOnClone()) { 25288 var classSelector = '.' + this.instance.wtTable.holder.parentNode.className.split(' ').join('.'); 25289 25290 eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function (event) { 25291 that.instance.touchApplied = true; 25292 if ((0, _element.isChildOf)(event.target, classSelector)) { 25293 onTouchStart.call(event.target, event); 25294 } 25295 }); 25296 eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function (event) { 25297 that.instance.touchApplied = false; 25298 if ((0, _element.isChildOf)(event.target, classSelector)) { 25299 onTouchEnd.call(event.target, event); 25300 } 25301 }); 25302 25303 if (!that.instance.momentumScrolling) { 25304 that.instance.momentumScrolling = {}; 25305 } 25306 eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function (event) { 25307 clearTimeout(that.instance.momentumScrolling._timeout); 25308 25309 if (!that.instance.momentumScrolling.ongoing) { 25310 that.instance.getSetting('onBeforeTouchScroll'); 25311 } 25312 that.instance.momentumScrolling.ongoing = true; 25313 25314 that.instance.momentumScrolling._timeout = setTimeout(function () { 25315 if (!that.instance.touchApplied) { 25316 that.instance.momentumScrolling.ongoing = false; 25317 25318 that.instance.getSetting('onAfterMomentumScroll'); 25319 } 25320 }, 200); 25321 }); 25322 } 25323 25324 eventManager.addEventListener(window, 'resize', function () { 25325 if (that.instance.getSetting('stretchH') !== 'none') { 25326 that.instance.draw(); 25327 } 25328 }); 25329 25330 this.destroy = function () { 25331 clearTimeout(this.dblClickTimeout[0]); 25332 clearTimeout(this.dblClickTimeout[1]); 25333 25334 eventManager.destroy(); 25335 }; 25336} 25337 25338Event.prototype.parentCell = function (elem) { 25339 var cell = {}; 25340 var TABLE = this.instance.wtTable.TABLE; 25341 var TD = (0, _element.closestDown)(elem, ['TD', 'TH'], TABLE); 25342 25343 if (TD) { 25344 cell.coords = this.instance.wtTable.getCoords(TD); 25345 cell.TD = TD; 25346 } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'current')) { 25347 cell.coords = this.instance.selections.current.cellRange.highlight; // selections.current is current selected cell 25348 cell.TD = this.instance.wtTable.getCell(cell.coords); 25349 } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'area')) { 25350 if (this.instance.selections.area.cellRange) { 25351 cell.coords = this.instance.selections.area.cellRange.to; // selections.area is area selected cells 25352 cell.TD = this.instance.wtTable.getCell(cell.coords); 25353 } 25354 } 25355 25356 return cell; 25357}; 25358 25359exports.default = Event; 25360 25361/***/ }), 25362/* 255 */ 25363/***/ (function(module, exports, __webpack_require__) { 25364 25365"use strict"; 25366 25367 25368exports.__esModule = true; 25369 25370var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 25371 25372function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 25373 25374/** 25375 * @class ColumnFilter 25376 */ 25377var ColumnFilter = function () { 25378 /** 25379 * @param {Number} offset 25380 * @param {Number} total 25381 * @param {Number} countTH 25382 */ 25383 function ColumnFilter(offset, total, countTH) { 25384 _classCallCheck(this, ColumnFilter); 25385 25386 this.offset = offset; 25387 this.total = total; 25388 this.countTH = countTH; 25389 } 25390 25391 /** 25392 * @param index 25393 * @returns {Number} 25394 */ 25395 25396 25397 _createClass(ColumnFilter, [{ 25398 key: "offsetted", 25399 value: function offsetted(index) { 25400 return index + this.offset; 25401 } 25402 25403 /** 25404 * @param index 25405 * @returns {Number} 25406 */ 25407 25408 }, { 25409 key: "unOffsetted", 25410 value: function unOffsetted(index) { 25411 return index - this.offset; 25412 } 25413 25414 /** 25415 * @param index 25416 * @returns {Number} 25417 */ 25418 25419 }, { 25420 key: "renderedToSource", 25421 value: function renderedToSource(index) { 25422 return this.offsetted(index); 25423 } 25424 25425 /** 25426 * @param index 25427 * @returns {Number} 25428 */ 25429 25430 }, { 25431 key: "sourceToRendered", 25432 value: function sourceToRendered(index) { 25433 return this.unOffsetted(index); 25434 } 25435 25436 /** 25437 * @param index 25438 * @returns {Number} 25439 */ 25440 25441 }, { 25442 key: "offsettedTH", 25443 value: function offsettedTH(index) { 25444 return index - this.countTH; 25445 } 25446 25447 /** 25448 * @param index 25449 * @returns {Number} 25450 */ 25451 25452 }, { 25453 key: "unOffsettedTH", 25454 value: function unOffsettedTH(index) { 25455 return index + this.countTH; 25456 } 25457 25458 /** 25459 * @param index 25460 * @returns {Number} 25461 */ 25462 25463 }, { 25464 key: "visibleRowHeadedColumnToSourceColumn", 25465 value: function visibleRowHeadedColumnToSourceColumn(index) { 25466 return this.renderedToSource(this.offsettedTH(index)); 25467 } 25468 25469 /** 25470 * @param index 25471 * @returns {Number} 25472 */ 25473 25474 }, { 25475 key: "sourceColumnToVisibleRowHeadedColumn", 25476 value: function sourceColumnToVisibleRowHeadedColumn(index) { 25477 return this.unOffsettedTH(this.sourceToRendered(index)); 25478 } 25479 }]); 25480 25481 return ColumnFilter; 25482}(); 25483 25484exports.default = ColumnFilter; 25485 25486/***/ }), 25487/* 256 */ 25488/***/ (function(module, exports, __webpack_require__) { 25489 25490"use strict"; 25491 25492 25493exports.__esModule = true; 25494 25495var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 25496 25497function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 25498 25499/** 25500 * @class RowFilter 25501 */ 25502var RowFilter = function () { 25503 /** 25504 * @param {Number} offset 25505 * @param {Number} total 25506 * @param {Number} countTH 25507 */ 25508 function RowFilter(offset, total, countTH) { 25509 _classCallCheck(this, RowFilter); 25510 25511 this.offset = offset; 25512 this.total = total; 25513 this.countTH = countTH; 25514 } 25515 25516 /** 25517 * @param index 25518 * @returns {Number} 25519 */ 25520 25521 25522 _createClass(RowFilter, [{ 25523 key: "offsetted", 25524 value: function offsetted(index) { 25525 return index + this.offset; 25526 } 25527 25528 /** 25529 * @param index 25530 * @returns {Number} 25531 */ 25532 25533 }, { 25534 key: "unOffsetted", 25535 value: function unOffsetted(index) { 25536 return index - this.offset; 25537 } 25538 25539 /** 25540 * @param index 25541 * @returns {Number} 25542 */ 25543 25544 }, { 25545 key: "renderedToSource", 25546 value: function renderedToSource(index) { 25547 return this.offsetted(index); 25548 } 25549 25550 /** 25551 * @param index 25552 * @returns {Number} 25553 */ 25554 25555 }, { 25556 key: "sourceToRendered", 25557 value: function sourceToRendered(index) { 25558 return this.unOffsetted(index); 25559 } 25560 25561 /** 25562 * @param index 25563 * @returns {Number} 25564 */ 25565 25566 }, { 25567 key: "offsettedTH", 25568 value: function offsettedTH(index) { 25569 return index - this.countTH; 25570 } 25571 25572 /** 25573 * @param index 25574 * @returns {Number} 25575 */ 25576 25577 }, { 25578 key: "unOffsettedTH", 25579 value: function unOffsettedTH(index) { 25580 return index + this.countTH; 25581 } 25582 25583 /** 25584 * @param index 25585 * @returns {Number} 25586 */ 25587 25588 }, { 25589 key: "visibleColHeadedRowToSourceRow", 25590 value: function visibleColHeadedRowToSourceRow(index) { 25591 return this.renderedToSource(this.offsettedTH(index)); 25592 } 25593 25594 /** 25595 * @param index 25596 * @returns {Number} 25597 */ 25598 25599 }, { 25600 key: "sourceRowToVisibleColHeadedRow", 25601 value: function sourceRowToVisibleColHeadedRow(index) { 25602 return this.unOffsettedTH(this.sourceToRendered(index)); 25603 } 25604 }]); 25605 25606 return RowFilter; 25607}(); 25608 25609exports.default = RowFilter; 25610 25611/***/ }), 25612/* 257 */ 25613/***/ (function(module, exports, __webpack_require__) { 25614 25615"use strict"; 25616 25617 25618exports.__esModule = true; 25619 25620var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 25621 25622var _element = __webpack_require__(0); 25623 25624var _array = __webpack_require__(2); 25625 25626var _unicode = __webpack_require__(15); 25627 25628var _browser = __webpack_require__(22); 25629 25630var _eventManager = __webpack_require__(4); 25631 25632var _eventManager2 = _interopRequireDefault(_eventManager); 25633 25634var _base = __webpack_require__(29); 25635 25636var _base2 = _interopRequireDefault(_base); 25637 25638function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 25639 25640function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 25641 25642/** 25643 * @class Overlays 25644 */ 25645var Overlays = function () { 25646 /** 25647 * @param {Walkontable} wotInstance 25648 */ 25649 function Overlays(wotInstance) { 25650 _classCallCheck(this, Overlays); 25651 25652 this.wot = wotInstance; 25653 25654 // legacy support 25655 this.instance = this.wot; 25656 this.eventManager = new _eventManager2.default(this.wot); 25657 25658 this.wot.update('scrollbarWidth', (0, _element.getScrollbarWidth)()); 25659 this.wot.update('scrollbarHeight', (0, _element.getScrollbarWidth)()); 25660 25661 this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE); 25662 25663 this.prepareOverlays(); 25664 25665 this.destroyed = false; 25666 this.keyPressed = false; 25667 this.spreaderLastSize = { 25668 width: null, 25669 height: null 25670 }; 25671 this.overlayScrollPositions = { 25672 master: { 25673 top: 0, 25674 left: 0 25675 }, 25676 top: { 25677 top: null, 25678 left: 0 25679 }, 25680 bottom: { 25681 top: null, 25682 left: 0 25683 }, 25684 left: { 25685 top: 0, 25686 left: null 25687 } 25688 }; 25689 25690 this.pendingScrollCallbacks = { 25691 master: { 25692 top: 0, 25693 left: 0 25694 }, 25695 top: { 25696 left: 0 25697 }, 25698 bottom: { 25699 left: 0 25700 }, 25701 left: { 25702 top: 0 25703 } 25704 }; 25705 25706 this.verticalScrolling = false; 25707 this.horizontalScrolling = false; 25708 this.delegatedScrollCallback = false; 25709 25710 this.registeredListeners = []; 25711 25712 this.registerListeners(); 25713 } 25714 25715 /** 25716 * Prepare overlays based on user settings. 25717 * 25718 * @returns {Boolean} Returns `true` if changes applied to overlay needs scroll synchronization. 25719 */ 25720 25721 25722 _createClass(Overlays, [{ 25723 key: 'prepareOverlays', 25724 value: function prepareOverlays() { 25725 var syncScroll = false; 25726 25727 if (this.topOverlay) { 25728 syncScroll = this.topOverlay.updateStateOfRendering() || syncScroll; 25729 } else { 25730 this.topOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP, this.wot); 25731 } 25732 25733 if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM)) { 25734 this.bottomOverlay = { 25735 needFullRender: false, 25736 updateStateOfRendering: function updateStateOfRendering() { 25737 return false; 25738 } 25739 }; 25740 } 25741 if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) { 25742 this.bottomLeftCornerOverlay = { 25743 needFullRender: false, 25744 updateStateOfRendering: function updateStateOfRendering() { 25745 return false; 25746 } 25747 }; 25748 } 25749 25750 if (this.bottomOverlay) { 25751 syncScroll = this.bottomOverlay.updateStateOfRendering() || syncScroll; 25752 } else { 25753 this.bottomOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM, this.wot); 25754 } 25755 25756 if (this.leftOverlay) { 25757 syncScroll = this.leftOverlay.updateStateOfRendering() || syncScroll; 25758 } else { 25759 this.leftOverlay = _base2.default.createOverlay(_base2.default.CLONE_LEFT, this.wot); 25760 } 25761 25762 if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) { 25763 if (this.topLeftCornerOverlay) { 25764 syncScroll = this.topLeftCornerOverlay.updateStateOfRendering() || syncScroll; 25765 } else { 25766 this.topLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, this.wot); 25767 } 25768 } 25769 25770 if (this.bottomOverlay.needFullRender && this.leftOverlay.needFullRender) { 25771 if (this.bottomLeftCornerOverlay) { 25772 syncScroll = this.bottomLeftCornerOverlay.updateStateOfRendering() || syncScroll; 25773 } else { 25774 this.bottomLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER, this.wot); 25775 } 25776 } 25777 25778 if (this.wot.getSetting('debug') && !this.debug) { 25779 this.debug = _base2.default.createOverlay(_base2.default.CLONE_DEBUG, this.wot); 25780 } 25781 25782 return syncScroll; 25783 } 25784 25785 /** 25786 * Refresh and redraw table 25787 */ 25788 25789 }, { 25790 key: 'refreshAll', 25791 value: function refreshAll() { 25792 if (!this.wot.drawn) { 25793 return; 25794 } 25795 if (!this.wot.wtTable.holder.parentNode) { 25796 // Walkontable was detached from DOM, but this handler was not removed 25797 this.destroy(); 25798 25799 return; 25800 } 25801 this.wot.draw(true); 25802 25803 if (this.verticalScrolling) { 25804 this.leftOverlay.onScroll(); 25805 } 25806 25807 if (this.horizontalScrolling) { 25808 this.topOverlay.onScroll(); 25809 } 25810 25811 this.verticalScrolling = false; 25812 this.horizontalScrolling = false; 25813 } 25814 25815 /** 25816 * Register all necessary event listeners. 25817 */ 25818 25819 }, { 25820 key: 'registerListeners', 25821 value: function registerListeners() { 25822 var _this = this; 25823 25824 var topOverlayScrollable = this.topOverlay.mainTableScrollableElement; 25825 var leftOverlayScrollable = this.leftOverlay.mainTableScrollableElement; 25826 25827 var listenersToRegister = []; 25828 listenersToRegister.push([document.documentElement, 'keydown', function (event) { 25829 return _this.onKeyDown(event); 25830 }]); 25831 listenersToRegister.push([document.documentElement, 'keyup', function () { 25832 return _this.onKeyUp(); 25833 }]); 25834 listenersToRegister.push([document, 'visibilitychange', function () { 25835 return _this.onKeyUp(); 25836 }]); 25837 listenersToRegister.push([topOverlayScrollable, 'scroll', function (event) { 25838 return _this.onTableScroll(event); 25839 }]); 25840 25841 if (topOverlayScrollable !== leftOverlayScrollable) { 25842 listenersToRegister.push([leftOverlayScrollable, 'scroll', function (event) { 25843 return _this.onTableScroll(event); 25844 }]); 25845 } 25846 25847 if (this.topOverlay.needFullRender) { 25848 listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'scroll', function (event) { 25849 return _this.onTableScroll(event); 25850 }]); 25851 listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'wheel', function (event) { 25852 return _this.onTableScroll(event); 25853 }]); 25854 } 25855 25856 if (this.bottomOverlay.needFullRender) { 25857 listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'scroll', function (event) { 25858 return _this.onTableScroll(event); 25859 }]); 25860 listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'wheel', function (event) { 25861 return _this.onTableScroll(event); 25862 }]); 25863 } 25864 25865 if (this.leftOverlay.needFullRender) { 25866 listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'scroll', function (event) { 25867 return _this.onTableScroll(event); 25868 }]); 25869 listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'wheel', function (event) { 25870 return _this.onTableScroll(event); 25871 }]); 25872 } 25873 25874 if (this.topLeftCornerOverlay && this.topLeftCornerOverlay.needFullRender) { 25875 listenersToRegister.push([this.topLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) { 25876 return _this.onTableScroll(event); 25877 }]); 25878 } 25879 25880 if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.needFullRender) { 25881 listenersToRegister.push([this.bottomLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) { 25882 return _this.onTableScroll(event); 25883 }]); 25884 } 25885 25886 if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) { 25887 // This is necessary? 25888 // eventManager.addEventListener(window, 'scroll', (event) => this.refreshAll(event)); 25889 listenersToRegister.push([window, 'wheel', function (event) { 25890 var overlay = void 0; 25891 var deltaY = event.wheelDeltaY || event.deltaY; 25892 var deltaX = event.wheelDeltaX || event.deltaX; 25893 25894 if (_this.topOverlay.clone.wtTable.holder.contains(event.realTarget)) { 25895 overlay = 'top'; 25896 } else if (_this.bottomOverlay.clone && _this.bottomOverlay.clone.wtTable.holder.contains(event.realTarget)) { 25897 overlay = 'bottom'; 25898 } else if (_this.leftOverlay.clone.wtTable.holder.contains(event.realTarget)) { 25899 overlay = 'left'; 25900 } else if (_this.topLeftCornerOverlay && _this.topLeftCornerOverlay.clone && _this.topLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) { 25901 overlay = 'topLeft'; 25902 } else if (_this.bottomLeftCornerOverlay && _this.bottomLeftCornerOverlay.clone && _this.bottomLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) { 25903 overlay = 'bottomLeft'; 25904 } 25905 25906 if (overlay == 'top' && deltaY !== 0 || overlay == 'left' && deltaX !== 0 || overlay == 'bottom' && deltaY !== 0 || (overlay === 'topLeft' || overlay === 'bottomLeft') && (deltaY !== 0 || deltaX !== 0)) { 25907 25908 event.preventDefault(); 25909 } 25910 }]); 25911 } 25912 25913 while (listenersToRegister.length) { 25914 var listener = listenersToRegister.pop(); 25915 this.eventManager.addEventListener(listener[0], listener[1], listener[2]); 25916 25917 this.registeredListeners.push(listener); 25918 } 25919 } 25920 25921 /** 25922 * Deregister all previously registered listeners. 25923 */ 25924 25925 }, { 25926 key: 'deregisterListeners', 25927 value: function deregisterListeners() { 25928 while (this.registeredListeners.length) { 25929 var listener = this.registeredListeners.pop(); 25930 this.eventManager.removeEventListener(listener[0], listener[1], listener[2]); 25931 } 25932 } 25933 25934 /** 25935 * Scroll listener 25936 * 25937 * @param {Event} event 25938 */ 25939 25940 }, { 25941 key: 'onTableScroll', 25942 value: function onTableScroll(event) { 25943 // if mobile browser, do not update scroll positions, as the overlays are hidden during the scroll 25944 if ((0, _browser.isMobileBrowser)()) { 25945 return; 25946 } 25947 var masterHorizontal = this.leftOverlay.mainTableScrollableElement; 25948 var masterVertical = this.topOverlay.mainTableScrollableElement; 25949 var target = event.target; 25950 25951 // For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered 25952 // by hot.refreshBorder 25953 if (this.keyPressed) { 25954 if (masterVertical !== window && target !== window && !event.target.contains(masterVertical) || masterHorizontal !== window && target !== window && !event.target.contains(masterHorizontal)) { 25955 return; 25956 } 25957 } 25958 25959 if (event.type === 'scroll') { 25960 this.syncScrollPositions(event); 25961 } else { 25962 this.translateMouseWheelToScroll(event); 25963 } 25964 } 25965 25966 /** 25967 * Key down listener 25968 */ 25969 25970 }, { 25971 key: 'onKeyDown', 25972 value: function onKeyDown(event) { 25973 this.keyPressed = (0, _unicode.isKey)(event.keyCode, 'ARROW_UP|ARROW_RIGHT|ARROW_DOWN|ARROW_LEFT'); 25974 } 25975 25976 /** 25977 * Key up listener 25978 */ 25979 25980 }, { 25981 key: 'onKeyUp', 25982 value: function onKeyUp() { 25983 this.keyPressed = false; 25984 } 25985 25986 /** 25987 * Translate wheel event into scroll event and sync scroll overlays position 25988 * 25989 * @private 25990 * @param {Event} event 25991 * @returns {Boolean} 25992 */ 25993 25994 }, { 25995 key: 'translateMouseWheelToScroll', 25996 value: function translateMouseWheelToScroll(event) { 25997 var topOverlay = this.topOverlay.clone.wtTable.holder; 25998 var bottomOverlay = this.bottomOverlay.clone ? this.bottomOverlay.clone.wtTable.holder : null; 25999 var leftOverlay = this.leftOverlay.clone.wtTable.holder; 26000 var topLeftCornerOverlay = this.topLeftCornerOverlay && this.topLeftCornerOverlay.clone ? this.topLeftCornerOverlay.clone.wtTable.holder : null; 26001 var bottomLeftCornerOverlay = this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone ? this.bottomLeftCornerOverlay.clone.wtTable.holder : null; 26002 var mouseWheelSpeedRatio = -0.2; 26003 var deltaY = event.wheelDeltaY || -1 * event.deltaY; 26004 var deltaX = event.wheelDeltaX || -1 * event.deltaX; 26005 var parentHolder = null; 26006 var eventMockup = { type: 'wheel' }; 26007 var tempElem = event.target; 26008 var delta = null; 26009 26010 // Fix for extremely slow header scrolling with a mousewheel on Firefox 26011 if (event.deltaMode === 1) { 26012 deltaY *= 120; 26013 deltaX *= 120; 26014 } 26015 26016 while (tempElem != document && tempElem != null) { 26017 if (tempElem.className.indexOf('wtHolder') > -1) { 26018 parentHolder = tempElem; 26019 break; 26020 } 26021 tempElem = tempElem.parentNode; 26022 } 26023 eventMockup.target = parentHolder; 26024 26025 if (parentHolder === topLeftCornerOverlay || parentHolder === bottomLeftCornerOverlay) { 26026 this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * deltaX, 'x'); 26027 this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * deltaY, 'y'); 26028 } else { 26029 if (parentHolder === topOverlay || parentHolder === bottomOverlay) { 26030 delta = deltaY; 26031 } else if (parentHolder === leftOverlay) { 26032 delta = deltaX; 26033 } 26034 26035 this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * delta); 26036 } 26037 26038 return false; 26039 } 26040 26041 /** 26042 * Synchronize scroll position between master table and overlay table. 26043 * 26044 * @private 26045 * @param {Event|Object} event 26046 * @param {Number} [fakeScrollValue=null] 26047 * @param {String} [fakeScrollDirection=null] `x` or `y`. 26048 */ 26049 26050 }, { 26051 key: 'syncScrollPositions', 26052 value: function syncScrollPositions(event) { 26053 var fakeScrollValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 26054 var fakeScrollDirection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 26055 26056 if (this.destroyed) { 26057 return; 26058 } 26059 if (arguments.length === 0) { 26060 this.syncScrollWithMaster(); 26061 26062 return; 26063 } 26064 var masterHorizontal = this.leftOverlay.mainTableScrollableElement; 26065 var masterVertical = this.topOverlay.mainTableScrollableElement; 26066 var target = event.target; 26067 var tempScrollValue = 0; 26068 var scrollValueChanged = false; 26069 var topOverlay = void 0; 26070 var leftOverlay = void 0; 26071 var topLeftCornerOverlay = void 0; 26072 var bottomLeftCornerOverlay = void 0; 26073 var bottomOverlay = void 0; 26074 var delegatedScroll = false; 26075 var preventOverflow = this.wot.getSetting('preventOverflow'); 26076 26077 if (this.topOverlay.needFullRender) { 26078 topOverlay = this.topOverlay.clone.wtTable.holder; 26079 } 26080 26081 if (this.bottomOverlay.needFullRender) { 26082 bottomOverlay = this.bottomOverlay.clone.wtTable.holder; 26083 } 26084 26085 if (this.leftOverlay.needFullRender) { 26086 leftOverlay = this.leftOverlay.clone.wtTable.holder; 26087 } 26088 26089 if (this.leftOverlay.needFullRender && this.topOverlay.needFullRender) { 26090 topLeftCornerOverlay = this.topLeftCornerOverlay.clone.wtTable.holder; 26091 } 26092 26093 if (this.leftOverlay.needFullRender && this.bottomOverlay.needFullRender) { 26094 bottomLeftCornerOverlay = this.bottomLeftCornerOverlay.clone.wtTable.holder; 26095 } 26096 26097 if (target === document) { 26098 target = window; 26099 } 26100 26101 if (target === masterHorizontal || target === masterVertical) { 26102 if (preventOverflow) { 26103 tempScrollValue = (0, _element.getScrollLeft)(this.scrollableElement); 26104 } else { 26105 tempScrollValue = (0, _element.getScrollLeft)(target); 26106 } 26107 26108 // if scrolling the master table - populate the scroll values to both top and left overlays 26109 this.horizontalScrolling = true; 26110 this.overlayScrollPositions.master.left = tempScrollValue; 26111 scrollValueChanged = true; 26112 26113 if (this.pendingScrollCallbacks.master.left > 0) { 26114 this.pendingScrollCallbacks.master.left--; 26115 } else { 26116 if (topOverlay && topOverlay.scrollLeft !== tempScrollValue) { 26117 26118 if (fakeScrollValue == null) { 26119 this.pendingScrollCallbacks.top.left++; 26120 } 26121 26122 topOverlay.scrollLeft = tempScrollValue; 26123 delegatedScroll = masterHorizontal !== window; 26124 } 26125 26126 if (bottomOverlay && bottomOverlay.scrollLeft !== tempScrollValue) { 26127 26128 if (fakeScrollValue == null) { 26129 this.pendingScrollCallbacks.bottom.left++; 26130 } 26131 26132 bottomOverlay.scrollLeft = tempScrollValue; 26133 delegatedScroll = masterHorizontal !== window; 26134 } 26135 } 26136 26137 tempScrollValue = (0, _element.getScrollTop)(target); 26138 26139 this.verticalScrolling = true; 26140 this.overlayScrollPositions.master.top = tempScrollValue; 26141 scrollValueChanged = true; 26142 26143 if (this.pendingScrollCallbacks.master.top > 0) { 26144 this.pendingScrollCallbacks.master.top--; 26145 } else if (leftOverlay && leftOverlay.scrollTop !== tempScrollValue) { 26146 if (fakeScrollValue == null) { 26147 this.pendingScrollCallbacks.left.top++; 26148 } 26149 26150 leftOverlay.scrollTop = tempScrollValue; 26151 delegatedScroll = masterVertical !== window; 26152 } 26153 } else if (target === bottomOverlay) { 26154 tempScrollValue = (0, _element.getScrollLeft)(target); 26155 26156 // if scrolling the bottom overlay - populate the horizontal scroll to the master table 26157 this.horizontalScrolling = true; 26158 this.overlayScrollPositions.bottom.left = tempScrollValue; 26159 scrollValueChanged = true; 26160 26161 if (this.pendingScrollCallbacks.bottom.left > 0) { 26162 this.pendingScrollCallbacks.bottom.left--; 26163 } else { 26164 if (fakeScrollValue == null) { 26165 this.pendingScrollCallbacks.master.left++; 26166 } 26167 26168 masterHorizontal.scrollLeft = tempScrollValue; 26169 26170 if (topOverlay && topOverlay.scrollLeft !== tempScrollValue) { 26171 if (fakeScrollValue == null) { 26172 this.pendingScrollCallbacks.top.left++; 26173 } 26174 26175 topOverlay.scrollLeft = tempScrollValue; 26176 delegatedScroll = masterVertical !== window; 26177 } 26178 } 26179 26180 // "fake" scroll value calculated from the mousewheel event 26181 if (fakeScrollValue !== null) { 26182 scrollValueChanged = true; 26183 masterVertical.scrollTop += fakeScrollValue; 26184 } 26185 } else if (target === topOverlay) { 26186 tempScrollValue = (0, _element.getScrollLeft)(target); 26187 26188 // if scrolling the top overlay - populate the horizontal scroll to the master table 26189 this.horizontalScrolling = true; 26190 this.overlayScrollPositions.top.left = tempScrollValue; 26191 scrollValueChanged = true; 26192 26193 if (this.pendingScrollCallbacks.top.left > 0) { 26194 this.pendingScrollCallbacks.top.left--; 26195 } else { 26196 26197 if (fakeScrollValue == null) { 26198 this.pendingScrollCallbacks.master.left++; 26199 } 26200 26201 masterHorizontal.scrollLeft = tempScrollValue; 26202 } 26203 26204 // "fake" scroll value calculated from the mousewheel event 26205 if (fakeScrollValue !== null) { 26206 scrollValueChanged = true; 26207 masterVertical.scrollTop += fakeScrollValue; 26208 } 26209 26210 if (bottomOverlay && bottomOverlay.scrollLeft !== tempScrollValue) { 26211 if (fakeScrollValue == null) { 26212 this.pendingScrollCallbacks.bottom.left++; 26213 } 26214 26215 bottomOverlay.scrollLeft = tempScrollValue; 26216 delegatedScroll = masterVertical !== window; 26217 } 26218 } else if (target === leftOverlay) { 26219 tempScrollValue = (0, _element.getScrollTop)(target); 26220 26221 // if scrolling the left overlay - populate the vertical scroll to the master table 26222 if (this.overlayScrollPositions.left.top !== tempScrollValue) { 26223 this.verticalScrolling = true; 26224 this.overlayScrollPositions.left.top = tempScrollValue; 26225 scrollValueChanged = true; 26226 26227 if (this.pendingScrollCallbacks.left.top > 0) { 26228 this.pendingScrollCallbacks.left.top--; 26229 } else { 26230 if (fakeScrollValue == null) { 26231 this.pendingScrollCallbacks.master.top++; 26232 } 26233 26234 masterVertical.scrollTop = tempScrollValue; 26235 } 26236 } 26237 26238 // "fake" scroll value calculated from the mousewheel event 26239 if (fakeScrollValue !== null) { 26240 scrollValueChanged = true; 26241 masterVertical.scrollLeft += fakeScrollValue; 26242 } 26243 } else if (target === topLeftCornerOverlay || target === bottomLeftCornerOverlay) { 26244 if (fakeScrollValue !== null) { 26245 scrollValueChanged = true; 26246 26247 if (fakeScrollDirection === 'x') { 26248 masterVertical.scrollLeft += fakeScrollValue; 26249 } else if (fakeScrollDirection === 'y') { 26250 masterVertical.scrollTop += fakeScrollValue; 26251 } 26252 } 26253 } 26254 26255 if (!this.keyPressed && scrollValueChanged && event.type === 'scroll') { 26256 if (this.delegatedScrollCallback) { 26257 this.delegatedScrollCallback = false; 26258 } else { 26259 this.refreshAll(); 26260 } 26261 26262 if (delegatedScroll) { 26263 this.delegatedScrollCallback = true; 26264 } 26265 } 26266 } 26267 26268 /** 26269 * Synchronize overlay scrollbars with the master scrollbar 26270 */ 26271 26272 }, { 26273 key: 'syncScrollWithMaster', 26274 value: function syncScrollWithMaster() { 26275 var master = this.topOverlay.mainTableScrollableElement; 26276 var scrollLeft = master.scrollLeft, 26277 scrollTop = master.scrollTop; 26278 26279 26280 if (this.topOverlay.needFullRender) { 26281 this.topOverlay.clone.wtTable.holder.scrollLeft = scrollLeft; 26282 } 26283 if (this.bottomOverlay.needFullRender) { 26284 this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft; 26285 } 26286 if (this.leftOverlay.needFullRender) { 26287 this.leftOverlay.clone.wtTable.holder.scrollTop = scrollTop; 26288 } 26289 } 26290 26291 /** 26292 * Update the main scrollable elements for all the overlays. 26293 */ 26294 26295 }, { 26296 key: 'updateMainScrollableElements', 26297 value: function updateMainScrollableElements() { 26298 this.deregisterListeners(); 26299 26300 this.leftOverlay.updateMainScrollableElement(); 26301 this.topOverlay.updateMainScrollableElement(); 26302 26303 if (this.bottomOverlay.needFullRender) { 26304 this.bottomOverlay.updateMainScrollableElement(); 26305 } 26306 26307 this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE); 26308 26309 this.registerListeners(); 26310 } 26311 26312 /** 26313 * 26314 */ 26315 26316 }, { 26317 key: 'destroy', 26318 value: function destroy() { 26319 this.eventManager.destroy(); 26320 this.topOverlay.destroy(); 26321 26322 if (this.bottomOverlay.clone) { 26323 this.bottomOverlay.destroy(); 26324 } 26325 this.leftOverlay.destroy(); 26326 26327 if (this.topLeftCornerOverlay) { 26328 this.topLeftCornerOverlay.destroy(); 26329 } 26330 26331 if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) { 26332 this.bottomLeftCornerOverlay.destroy(); 26333 } 26334 26335 if (this.debug) { 26336 this.debug.destroy(); 26337 } 26338 this.destroyed = true; 26339 } 26340 26341 /** 26342 * @param {Boolean} [fastDraw=false] 26343 */ 26344 26345 }, { 26346 key: 'refresh', 26347 value: function refresh() { 26348 var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 26349 26350 if (this.topOverlay.areElementSizesAdjusted && this.leftOverlay.areElementSizesAdjusted) { 26351 var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement; 26352 var width = container.clientWidth; 26353 var height = container.clientHeight; 26354 26355 if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) { 26356 this.spreaderLastSize.width = width; 26357 this.spreaderLastSize.height = height; 26358 this.adjustElementsSize(); 26359 } 26360 } 26361 26362 if (this.bottomOverlay.clone) { 26363 this.bottomOverlay.refresh(fastDraw); 26364 } 26365 26366 this.leftOverlay.refresh(fastDraw); 26367 this.topOverlay.refresh(fastDraw); 26368 26369 if (this.topLeftCornerOverlay) { 26370 this.topLeftCornerOverlay.refresh(fastDraw); 26371 } 26372 26373 if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) { 26374 this.bottomLeftCornerOverlay.refresh(fastDraw); 26375 } 26376 26377 if (this.debug) { 26378 this.debug.refresh(fastDraw); 26379 } 26380 } 26381 26382 /** 26383 * Adjust overlays elements size and master table size 26384 * 26385 * @param {Boolean} [force=false] 26386 */ 26387 26388 }, { 26389 key: 'adjustElementsSize', 26390 value: function adjustElementsSize() { 26391 var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 26392 26393 var totalColumns = this.wot.getSetting('totalColumns'); 26394 var totalRows = this.wot.getSetting('totalRows'); 26395 var headerRowSize = this.wot.wtViewport.getRowHeaderWidth(); 26396 var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight(); 26397 var hiderStyle = this.wot.wtTable.hider.style; 26398 26399 hiderStyle.width = headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns) + 'px'; 26400 hiderStyle.height = headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1 + 'px'; 26401 26402 this.topOverlay.adjustElementsSize(force); 26403 this.leftOverlay.adjustElementsSize(force); 26404 26405 if (this.bottomOverlay.clone) { 26406 this.bottomOverlay.adjustElementsSize(force); 26407 } 26408 } 26409 26410 /** 26411 * 26412 */ 26413 26414 }, { 26415 key: 'applyToDOM', 26416 value: function applyToDOM() { 26417 if (!this.topOverlay.areElementSizesAdjusted || !this.leftOverlay.areElementSizesAdjusted) { 26418 this.adjustElementsSize(); 26419 } 26420 this.topOverlay.applyToDOM(); 26421 26422 if (this.bottomOverlay.clone) { 26423 this.bottomOverlay.applyToDOM(); 26424 } 26425 26426 this.leftOverlay.applyToDOM(); 26427 } 26428 26429 /** 26430 * Get the parent overlay of the provided element. 26431 * 26432 * @param {HTMLElement} element 26433 * @returns {Object|null} 26434 */ 26435 26436 }, { 26437 key: 'getParentOverlay', 26438 value: function getParentOverlay(element) { 26439 if (!element) { 26440 return null; 26441 } 26442 26443 var overlays = [this.topOverlay, this.leftOverlay, this.bottomOverlay, this.topLeftCornerOverlay, this.bottomLeftCornerOverlay]; 26444 var result = null; 26445 26446 (0, _array.arrayEach)(overlays, function (elem, i) { 26447 if (!elem) { 26448 return; 26449 } 26450 26451 if (elem.clone && elem.clone.wtTable.TABLE.contains(element)) { 26452 result = elem.clone; 26453 } 26454 }); 26455 26456 return result; 26457 } 26458 }]); 26459 26460 return Overlays; 26461}(); 26462 26463exports.default = Overlays; 26464 26465/***/ }), 26466/* 258 */ 26467/***/ (function(module, exports, __webpack_require__) { 26468 26469"use strict"; 26470 26471 26472exports.__esModule = true; 26473 26474var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 26475 26476var _element = __webpack_require__(0); 26477 26478var _number = __webpack_require__(5); 26479 26480function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 26481 26482/** 26483 * @class Scroll 26484 */ 26485var Scroll = function () { 26486 /** 26487 * @param {Walkontable} wotInstance 26488 */ 26489 function Scroll(wotInstance) { 26490 _classCallCheck(this, Scroll); 26491 26492 this.wot = wotInstance; 26493 26494 // legacy support 26495 this.instance = wotInstance; 26496 } 26497 26498 /** 26499 * Scrolls viewport to a cell by minimum number of cells 26500 * 26501 * @param {CellCoords} coords 26502 */ 26503 26504 26505 _createClass(Scroll, [{ 26506 key: 'scrollViewport', 26507 value: function scrollViewport(coords) { 26508 if (!this.wot.drawn) { 26509 return; 26510 } 26511 26512 var _getVariables2 = this._getVariables(), 26513 topOverlay = _getVariables2.topOverlay, 26514 leftOverlay = _getVariables2.leftOverlay, 26515 totalRows = _getVariables2.totalRows, 26516 totalColumns = _getVariables2.totalColumns, 26517 fixedRowsTop = _getVariables2.fixedRowsTop, 26518 fixedRowsBottom = _getVariables2.fixedRowsBottom, 26519 fixedColumnsLeft = _getVariables2.fixedColumnsLeft; 26520 26521 if (coords.row < 0 || coords.row > Math.max(totalRows - 1, 0)) { 26522 throw new Error('row ' + coords.row + ' does not exist'); 26523 } 26524 26525 if (coords.col < 0 || coords.col > Math.max(totalColumns - 1, 0)) { 26526 throw new Error('column ' + coords.col + ' does not exist'); 26527 } 26528 26529 if (coords.row >= fixedRowsTop && coords.row < this.getFirstVisibleRow()) { 26530 topOverlay.scrollTo(coords.row); 26531 } else if (coords.row > this.getLastVisibleRow() && coords.row < totalRows - fixedRowsBottom) { 26532 topOverlay.scrollTo(coords.row, true); 26533 } 26534 26535 if (coords.col >= fixedColumnsLeft && coords.col < this.getFirstVisibleColumn()) { 26536 leftOverlay.scrollTo(coords.col); 26537 } else if (coords.col > this.getLastVisibleColumn()) { 26538 leftOverlay.scrollTo(coords.col, true); 26539 } 26540 } 26541 26542 /** 26543 * Get first visible row based on virtual dom and how table is visible in browser window viewport. 26544 * 26545 * @returns {Number} 26546 */ 26547 26548 }, { 26549 key: 'getFirstVisibleRow', 26550 value: function getFirstVisibleRow() { 26551 var _getVariables3 = this._getVariables(), 26552 topOverlay = _getVariables3.topOverlay, 26553 wtTable = _getVariables3.wtTable, 26554 wtViewport = _getVariables3.wtViewport, 26555 totalRows = _getVariables3.totalRows, 26556 fixedRowsTop = _getVariables3.fixedRowsTop; 26557 26558 var firstVisibleRow = wtTable.getFirstVisibleRow(); 26559 26560 if (topOverlay.mainTableScrollableElement === window) { 26561 var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement); 26562 var totalTableHeight = (0, _element.innerHeight)(wtTable.hider); 26563 var windowHeight = (0, _element.innerHeight)(window); 26564 var windowScrollTop = (0, _element.getScrollTop)(window); 26565 26566 // Only calculate firstVisibleRow when table didn't filled (from up) whole viewport space 26567 if (rootElementOffset.top + totalTableHeight - windowHeight <= windowScrollTop) { 26568 var rowsHeight = wtViewport.getColumnHeaderHeight(); 26569 26570 rowsHeight += topOverlay.sumCellSizes(0, fixedRowsTop); 26571 26572 (0, _number.rangeEachReverse)(totalRows, 1, function (row) { 26573 rowsHeight += topOverlay.sumCellSizes(row - 1, row); 26574 26575 if (rootElementOffset.top + totalTableHeight - rowsHeight <= windowScrollTop) { 26576 // Return physical row + 1 26577 firstVisibleRow = row; 26578 26579 return false; 26580 } 26581 }); 26582 } 26583 } 26584 26585 return firstVisibleRow; 26586 } 26587 26588 /** 26589 * Get last visible row based on virtual dom and how table is visible in browser window viewport. 26590 * 26591 * @returns {Number} 26592 */ 26593 26594 }, { 26595 key: 'getLastVisibleRow', 26596 value: function getLastVisibleRow() { 26597 var _getVariables4 = this._getVariables(), 26598 topOverlay = _getVariables4.topOverlay, 26599 wtTable = _getVariables4.wtTable, 26600 wtViewport = _getVariables4.wtViewport, 26601 totalRows = _getVariables4.totalRows; 26602 26603 var lastVisibleRow = wtTable.getLastVisibleRow(); 26604 26605 if (topOverlay.mainTableScrollableElement === window) { 26606 var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement); 26607 var windowHeight = (0, _element.innerHeight)(window); 26608 var windowScrollTop = (0, _element.getScrollTop)(window); 26609 26610 // Only calculate lastVisibleRow when table didn't filled (from bottom) whole viewport space 26611 if (rootElementOffset.top > windowScrollTop) { 26612 var rowsHeight = wtViewport.getColumnHeaderHeight(); 26613 26614 (0, _number.rangeEach)(1, totalRows, function (row) { 26615 rowsHeight += topOverlay.sumCellSizes(row - 1, row); 26616 26617 if (rootElementOffset.top + rowsHeight - windowScrollTop >= windowHeight) { 26618 // Return physical row - 1 (-2 because rangeEach gives row index + 1 - sumCellSizes requirements) 26619 lastVisibleRow = row - 2; 26620 26621 return false; 26622 } 26623 }); 26624 } 26625 } 26626 26627 return lastVisibleRow; 26628 } 26629 26630 /** 26631 * Get first visible column based on virtual dom and how table is visible in browser window viewport. 26632 * 26633 * @returns {Number} 26634 */ 26635 26636 }, { 26637 key: 'getFirstVisibleColumn', 26638 value: function getFirstVisibleColumn() { 26639 var _getVariables5 = this._getVariables(), 26640 leftOverlay = _getVariables5.leftOverlay, 26641 wtTable = _getVariables5.wtTable, 26642 wtViewport = _getVariables5.wtViewport, 26643 totalColumns = _getVariables5.totalColumns, 26644 fixedColumnsLeft = _getVariables5.fixedColumnsLeft; 26645 26646 var firstVisibleColumn = wtTable.getFirstVisibleColumn(); 26647 26648 if (leftOverlay.mainTableScrollableElement === window) { 26649 var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement); 26650 var totalTableWidth = (0, _element.innerWidth)(wtTable.hider); 26651 var windowWidth = (0, _element.innerWidth)(window); 26652 var windowScrollLeft = (0, _element.getScrollLeft)(window); 26653 26654 // Only calculate firstVisibleColumn when table didn't filled (from left) whole viewport space 26655 if (rootElementOffset.left + totalTableWidth - windowWidth <= windowScrollLeft) { 26656 var columnsWidth = wtViewport.getRowHeaderWidth(); 26657 26658 (0, _number.rangeEachReverse)(totalColumns, 1, function (column) { 26659 columnsWidth += leftOverlay.sumCellSizes(column - 1, column); 26660 26661 if (rootElementOffset.left + totalTableWidth - columnsWidth <= windowScrollLeft) { 26662 // Return physical column + 1 26663 firstVisibleColumn = column; 26664 26665 return false; 26666 } 26667 }); 26668 } 26669 } 26670 26671 return firstVisibleColumn; 26672 } 26673 26674 /** 26675 * Get last visible column based on virtual dom and how table is visible in browser window viewport. 26676 * 26677 * @returns {Number} 26678 */ 26679 26680 }, { 26681 key: 'getLastVisibleColumn', 26682 value: function getLastVisibleColumn() { 26683 var _getVariables6 = this._getVariables(), 26684 leftOverlay = _getVariables6.leftOverlay, 26685 wtTable = _getVariables6.wtTable, 26686 wtViewport = _getVariables6.wtViewport, 26687 totalColumns = _getVariables6.totalColumns; 26688 26689 var lastVisibleColumn = wtTable.getLastVisibleColumn(); 26690 26691 if (leftOverlay.mainTableScrollableElement === window) { 26692 var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement); 26693 var windowWidth = (0, _element.innerWidth)(window); 26694 var windowScrollLeft = (0, _element.getScrollLeft)(window); 26695 26696 // Only calculate lastVisibleColumn when table didn't filled (from right) whole viewport space 26697 if (rootElementOffset.left > windowScrollLeft) { 26698 var columnsWidth = wtViewport.getRowHeaderWidth(); 26699 26700 (0, _number.rangeEach)(1, totalColumns, function (column) { 26701 columnsWidth += leftOverlay.sumCellSizes(column - 1, column); 26702 26703 if (rootElementOffset.left + columnsWidth - windowScrollLeft >= windowWidth) { 26704 // Return physical column - 1 (-2 because rangeEach gives column index + 1 - sumCellSizes requirements) 26705 lastVisibleColumn = column - 2; 26706 26707 return false; 26708 } 26709 }); 26710 } 26711 } 26712 26713 return lastVisibleColumn; 26714 } 26715 26716 /** 26717 * Returns collection of variables used to rows and columns visibility calculations. 26718 * 26719 * @returns {Object} 26720 * @private 26721 */ 26722 26723 }, { 26724 key: '_getVariables', 26725 value: function _getVariables() { 26726 var wot = this.wot; 26727 var topOverlay = wot.wtOverlays.topOverlay; 26728 var leftOverlay = wot.wtOverlays.leftOverlay; 26729 var wtTable = wot.wtTable; 26730 var wtViewport = wot.wtViewport; 26731 var totalRows = wot.getSetting('totalRows'); 26732 var totalColumns = wot.getSetting('totalColumns'); 26733 var fixedRowsTop = wot.getSetting('fixedRowsTop'); 26734 var fixedRowsBottom = wot.getSetting('fixedRowsBottom'); 26735 var fixedColumnsLeft = wot.getSetting('fixedColumnsLeft'); 26736 26737 return { 26738 topOverlay: topOverlay, 26739 leftOverlay: leftOverlay, 26740 wtTable: wtTable, 26741 wtViewport: wtViewport, 26742 totalRows: totalRows, 26743 totalColumns: totalColumns, 26744 fixedRowsTop: fixedRowsTop, 26745 fixedRowsBottom: fixedRowsBottom, 26746 fixedColumnsLeft: fixedColumnsLeft 26747 }; 26748 } 26749 }]); 26750 26751 return Scroll; 26752}(); 26753 26754exports.default = Scroll; 26755 26756/***/ }), 26757/* 259 */ 26758/***/ (function(module, exports, __webpack_require__) { 26759 26760"use strict"; 26761 26762 26763exports.__esModule = true; 26764 26765var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 26766 26767var _element = __webpack_require__(0); 26768 26769var _object = __webpack_require__(3); 26770 26771function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 26772 26773/** 26774 * @class Settings 26775 */ 26776var Settings = function () { 26777 /** 26778 * @param {Walkontable} wotInstance 26779 * @param {Object} settings 26780 */ 26781 function Settings(wotInstance, settings) { 26782 var _this = this; 26783 26784 _classCallCheck(this, Settings); 26785 26786 this.wot = wotInstance; 26787 26788 // legacy support 26789 this.instance = wotInstance; 26790 26791 // default settings. void 0 means it is required, null means it can be empty 26792 this.defaults = { 26793 table: void 0, 26794 debug: false, // shows WalkontableDebugOverlay 26795 26796 // presentation mode 26797 externalRowCalculator: false, 26798 stretchH: 'none', // values: all, last, none 26799 currentRowClassName: null, 26800 currentColumnClassName: null, 26801 preventOverflow: function preventOverflow() { 26802 return false; 26803 }, 26804 26805 26806 // data source 26807 data: void 0, 26808 freezeOverlays: false, 26809 fixedColumnsLeft: 0, 26810 fixedRowsTop: 0, 26811 fixedRowsBottom: 0, 26812 minSpareRows: 0, 26813 26814 // this must be array of functions: [function (row, TH) {}] 26815 rowHeaders: function rowHeaders() { 26816 return []; 26817 }, 26818 26819 26820 // this must be array of functions: [function (column, TH) {}] 26821 columnHeaders: function columnHeaders() { 26822 return []; 26823 }, 26824 26825 totalRows: void 0, 26826 totalColumns: void 0, 26827 cellRenderer: function cellRenderer(row, column, TD) { 26828 var cellData = _this.getSetting('data', row, column); 26829 26830 (0, _element.fastInnerText)(TD, cellData === void 0 || cellData === null ? '' : cellData); 26831 }, 26832 26833 // columnWidth: 50, 26834 columnWidth: function columnWidth(col) { 26835 // return undefined means use default size for the rendered cell content 26836 }, 26837 rowHeight: function rowHeight(row) { 26838 // return undefined means use default size for the rendered cell content 26839 }, 26840 26841 defaultRowHeight: 23, 26842 defaultColumnWidth: 50, 26843 selections: null, 26844 hideBorderOnMouseDownOver: false, 26845 viewportRowCalculatorOverride: null, 26846 viewportColumnCalculatorOverride: null, 26847 26848 // callbacks 26849 onCellMouseDown: null, 26850 onCellMouseOver: null, 26851 onCellMouseOut: null, 26852 onCellMouseUp: null, 26853 26854 // onCellMouseOut: null, 26855 onCellDblClick: null, 26856 onCellCornerMouseDown: null, 26857 onCellCornerDblClick: null, 26858 beforeDraw: null, 26859 onDraw: null, 26860 onBeforeDrawBorders: null, 26861 onScrollVertically: null, 26862 onScrollHorizontally: null, 26863 onBeforeTouchScroll: null, 26864 onAfterMomentumScroll: null, 26865 onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(width) { 26866 return width; 26867 }, 26868 onModifyRowHeaderWidth: null, 26869 26870 // constants 26871 scrollbarWidth: 10, 26872 scrollbarHeight: 10, 26873 26874 renderAllRows: false, 26875 groups: false, 26876 rowHeaderWidth: null, 26877 columnHeaderHeight: null, 26878 headerClassName: null 26879 }; 26880 26881 // reference to settings 26882 this.settings = {}; 26883 26884 for (var i in this.defaults) { 26885 if ((0, _object.hasOwnProperty)(this.defaults, i)) { 26886 if (settings[i] !== void 0) { 26887 this.settings[i] = settings[i]; 26888 } else if (this.defaults[i] === void 0) { 26889 throw new Error('A required setting "' + i + '" was not provided'); 26890 } else { 26891 this.settings[i] = this.defaults[i]; 26892 } 26893 } 26894 } 26895 } 26896 26897 /** 26898 * Update settings 26899 * 26900 * @param {Object} settings 26901 * @param {*} value 26902 * @returns {Walkontable} 26903 */ 26904 26905 26906 _createClass(Settings, [{ 26907 key: 'update', 26908 value: function update(settings, value) { 26909 if (value === void 0) { 26910 // settings is object 26911 for (var i in settings) { 26912 if ((0, _object.hasOwnProperty)(settings, i)) { 26913 this.settings[i] = settings[i]; 26914 } 26915 } 26916 } else { 26917 // if value is defined then settings is the key 26918 this.settings[settings] = value; 26919 } 26920 return this.wot; 26921 } 26922 26923 /** 26924 * Get setting by name 26925 * 26926 * @param {String} key 26927 * @param {*} param1 26928 * @param {*} param2 26929 * @param {*} param3 26930 * @param {*} param4 26931 * @returns {*} 26932 */ 26933 26934 }, { 26935 key: 'getSetting', 26936 value: function getSetting(key, param1, param2, param3, param4) { 26937 if (typeof this.settings[key] === 'function') { 26938 // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips 26939 return this.settings[key](param1, param2, param3, param4); 26940 } else if (param1 !== void 0 && Array.isArray(this.settings[key])) { 26941 // perhaps this can be removed, it is only used in tests 26942 return this.settings[key][param1]; 26943 } 26944 26945 return this.settings[key]; 26946 } 26947 26948 /** 26949 * Checks if setting exists 26950 * 26951 * @param {Boolean} key 26952 * @returns {Boolean} 26953 */ 26954 26955 }, { 26956 key: 'has', 26957 value: function has(key) { 26958 return !!this.settings[key]; 26959 } 26960 }]); 26961 26962 return Settings; 26963}(); 26964 26965exports.default = Settings; 26966 26967/***/ }), 26968/* 260 */ 26969/***/ (function(module, exports, __webpack_require__) { 26970 26971"use strict"; 26972 26973 26974exports.__esModule = true; 26975 26976var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 26977 26978var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 26979 26980var _element = __webpack_require__(0); 26981 26982var _function = __webpack_require__(35); 26983 26984var _coords = __webpack_require__(43); 26985 26986var _coords2 = _interopRequireDefault(_coords); 26987 26988var _range = __webpack_require__(71); 26989 26990var _range2 = _interopRequireDefault(_range); 26991 26992var _column = __webpack_require__(255); 26993 26994var _column2 = _interopRequireDefault(_column); 26995 26996var _row = __webpack_require__(256); 26997 26998var _row2 = _interopRequireDefault(_row); 26999 27000var _tableRenderer = __webpack_require__(261); 27001 27002var _tableRenderer2 = _interopRequireDefault(_tableRenderer); 27003 27004var _base = __webpack_require__(29); 27005 27006var _base2 = _interopRequireDefault(_base); 27007 27008function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27009 27010function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 27011 27012function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 27013 27014/** 27015 * 27016 */ 27017var Table = function () { 27018 /** 27019 * @param {Walkontable} wotInstance 27020 * @param {HTMLTableElement} table 27021 */ 27022 function Table(wotInstance, table) { 27023 var _this = this; 27024 27025 _classCallCheck(this, Table); 27026 27027 this.wot = wotInstance; 27028 27029 // legacy support 27030 this.instance = this.wot; 27031 this.TABLE = table; 27032 this.TBODY = null; 27033 this.THEAD = null; 27034 this.COLGROUP = null; 27035 this.tableOffset = 0; 27036 this.holderOffset = 0; 27037 27038 (0, _element.removeTextNodes)(this.TABLE); 27039 27040 this.spreader = this.createSpreader(this.TABLE); 27041 this.hider = this.createHider(this.spreader); 27042 this.holder = this.createHolder(this.hider); 27043 27044 this.wtRootElement = this.holder.parentNode; 27045 this.alignOverlaysWithTrimmingContainer(); 27046 this.fixTableDomTree(); 27047 27048 this.colgroupChildrenLength = this.COLGROUP.childNodes.length; 27049 this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0; 27050 this.tbodyChildrenLength = this.TBODY.childNodes.length; 27051 27052 this.rowFilter = null; 27053 this.columnFilter = null; 27054 this.correctHeaderWidth = false; 27055 27056 var origRowHeaderWidth = this.wot.wtSettings.settings.rowHeaderWidth; 27057 27058 // Fix for jumping row headers (https://github.com/handsontable/handsontable/issues/3850) 27059 this.wot.wtSettings.settings.rowHeaderWidth = function () { 27060 return _this._modifyRowHeaderWidth(origRowHeaderWidth); 27061 }; 27062 } 27063 27064 /** 27065 * 27066 */ 27067 27068 27069 _createClass(Table, [{ 27070 key: 'fixTableDomTree', 27071 value: function fixTableDomTree() { 27072 this.TBODY = this.TABLE.querySelector('tbody'); 27073 27074 if (!this.TBODY) { 27075 this.TBODY = document.createElement('tbody'); 27076 this.TABLE.appendChild(this.TBODY); 27077 } 27078 this.THEAD = this.TABLE.querySelector('thead'); 27079 27080 if (!this.THEAD) { 27081 this.THEAD = document.createElement('thead'); 27082 this.TABLE.insertBefore(this.THEAD, this.TBODY); 27083 } 27084 this.COLGROUP = this.TABLE.querySelector('colgroup'); 27085 27086 if (!this.COLGROUP) { 27087 this.COLGROUP = document.createElement('colgroup'); 27088 this.TABLE.insertBefore(this.COLGROUP, this.THEAD); 27089 } 27090 27091 if (this.wot.getSetting('columnHeaders').length && !this.THEAD.childNodes.length) { 27092 this.THEAD.appendChild(document.createElement('TR')); 27093 } 27094 } 27095 27096 /** 27097 * @param table 27098 * @returns {HTMLElement} 27099 */ 27100 27101 }, { 27102 key: 'createSpreader', 27103 value: function createSpreader(table) { 27104 var parent = table.parentNode; 27105 var spreader = void 0; 27106 27107 if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) { 27108 spreader = document.createElement('div'); 27109 spreader.className = 'wtSpreader'; 27110 27111 if (parent) { 27112 // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it 27113 parent.insertBefore(spreader, table); 27114 } 27115 spreader.appendChild(table); 27116 } 27117 spreader.style.position = 'relative'; 27118 27119 return spreader; 27120 } 27121 27122 /** 27123 * @param spreader 27124 * @returns {HTMLElement} 27125 */ 27126 27127 }, { 27128 key: 'createHider', 27129 value: function createHider(spreader) { 27130 var parent = spreader.parentNode; 27131 var hider = void 0; 27132 27133 if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) { 27134 hider = document.createElement('div'); 27135 hider.className = 'wtHider'; 27136 27137 if (parent) { 27138 // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it 27139 parent.insertBefore(hider, spreader); 27140 } 27141 hider.appendChild(spreader); 27142 } 27143 27144 return hider; 27145 } 27146 27147 /** 27148 * 27149 * @param hider 27150 * @returns {HTMLElement} 27151 */ 27152 27153 }, { 27154 key: 'createHolder', 27155 value: function createHolder(hider) { 27156 var parent = hider.parentNode; 27157 var holder = void 0; 27158 27159 if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) { 27160 holder = document.createElement('div'); 27161 holder.style.position = 'relative'; 27162 holder.className = 'wtHolder'; 27163 27164 if (parent) { 27165 // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it 27166 parent.insertBefore(holder, hider); 27167 } 27168 if (!this.isWorkingOnClone()) { 27169 holder.parentNode.className += 'ht_master handsontable'; 27170 } 27171 holder.appendChild(hider); 27172 } 27173 27174 return holder; 27175 } 27176 }, { 27177 key: 'alignOverlaysWithTrimmingContainer', 27178 value: function alignOverlaysWithTrimmingContainer() { 27179 var trimmingElement = (0, _element.getTrimmingContainer)(this.wtRootElement); 27180 27181 if (!this.isWorkingOnClone()) { 27182 this.holder.parentNode.style.position = 'relative'; 27183 27184 if (trimmingElement === window) { 27185 var preventOverflow = this.wot.getSetting('preventOverflow'); 27186 27187 if (!preventOverflow) { 27188 this.holder.style.overflow = 'visible'; 27189 this.wtRootElement.style.overflow = 'visible'; 27190 } 27191 } else { 27192 this.holder.style.width = (0, _element.getStyle)(trimmingElement, 'width'); 27193 this.holder.style.height = (0, _element.getStyle)(trimmingElement, 'height'); 27194 this.holder.style.overflow = ''; 27195 } 27196 } 27197 } 27198 }, { 27199 key: 'isWorkingOnClone', 27200 value: function isWorkingOnClone() { 27201 return !!this.wot.cloneSource; 27202 } 27203 27204 /** 27205 * Redraws the table 27206 * 27207 * @param {Boolean} fastDraw If TRUE, will try to avoid full redraw and only update the border positions. If FALSE or UNDEFINED, will perform a full redraw 27208 * @returns {Table} 27209 */ 27210 27211 }, { 27212 key: 'draw', 27213 value: function draw(fastDraw) { 27214 var _wot = this.wot, 27215 wtOverlays = _wot.wtOverlays, 27216 wtViewport = _wot.wtViewport; 27217 27218 var totalRows = this.instance.getSetting('totalRows'); 27219 var rowHeaders = this.wot.getSetting('rowHeaders').length; 27220 var columnHeaders = this.wot.getSetting('columnHeaders').length; 27221 var syncScroll = false; 27222 27223 if (!this.isWorkingOnClone()) { 27224 this.holderOffset = (0, _element.offset)(this.holder); 27225 fastDraw = wtViewport.createRenderCalculators(fastDraw); 27226 27227 if (rowHeaders && !this.wot.getSetting('fixedColumnsLeft')) { 27228 var leftScrollPos = wtOverlays.leftOverlay.getScrollPosition(); 27229 var previousState = this.correctHeaderWidth; 27230 27231 this.correctHeaderWidth = leftScrollPos > 0; 27232 27233 if (previousState !== this.correctHeaderWidth) { 27234 fastDraw = false; 27235 } 27236 } 27237 } 27238 27239 if (!this.isWorkingOnClone()) { 27240 syncScroll = wtOverlays.prepareOverlays(); 27241 } 27242 27243 if (fastDraw) { 27244 if (!this.isWorkingOnClone()) { 27245 // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator 27246 wtViewport.createVisibleCalculators(); 27247 } 27248 if (wtOverlays) { 27249 wtOverlays.refresh(true); 27250 } 27251 } else { 27252 if (this.isWorkingOnClone()) { 27253 this.tableOffset = this.wot.cloneSource.wtTable.tableOffset; 27254 } else { 27255 this.tableOffset = (0, _element.offset)(this.TABLE); 27256 } 27257 var startRow = void 0; 27258 27259 if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_DEBUG) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_TOP) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_TOP_LEFT_CORNER)) { 27260 startRow = 0; 27261 } else if (_base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) { 27262 startRow = Math.max(totalRows - this.wot.getSetting('fixedRowsBottom'), 0); 27263 } else { 27264 startRow = wtViewport.rowsRenderCalculator.startRow; 27265 } 27266 var startColumn = void 0; 27267 27268 if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_DEBUG) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_LEFT) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_TOP_LEFT_CORNER) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) { 27269 startColumn = 0; 27270 } else { 27271 startColumn = wtViewport.columnsRenderCalculator.startColumn; 27272 } 27273 this.rowFilter = new _row2.default(startRow, totalRows, columnHeaders); 27274 this.columnFilter = new _column2.default(startColumn, this.wot.getSetting('totalColumns'), rowHeaders); 27275 27276 this.alignOverlaysWithTrimmingContainer(); 27277 this._doDraw(); // creates calculator after draw 27278 } 27279 this.refreshSelections(fastDraw); 27280 27281 if (!this.isWorkingOnClone()) { 27282 wtOverlays.topOverlay.resetFixedPosition(); 27283 27284 if (wtOverlays.bottomOverlay.clone) { 27285 wtOverlays.bottomOverlay.resetFixedPosition(); 27286 } 27287 27288 wtOverlays.leftOverlay.resetFixedPosition(); 27289 27290 if (wtOverlays.topLeftCornerOverlay) { 27291 wtOverlays.topLeftCornerOverlay.resetFixedPosition(); 27292 } 27293 27294 if (wtOverlays.bottomLeftCornerOverlay && wtOverlays.bottomLeftCornerOverlay.clone) { 27295 wtOverlays.bottomLeftCornerOverlay.resetFixedPosition(); 27296 } 27297 } 27298 if (syncScroll) { 27299 wtOverlays.syncScrollWithMaster(); 27300 } 27301 this.wot.drawn = true; 27302 27303 return this; 27304 } 27305 }, { 27306 key: '_doDraw', 27307 value: function _doDraw() { 27308 var wtRenderer = new _tableRenderer2.default(this); 27309 27310 wtRenderer.render(); 27311 } 27312 }, { 27313 key: 'removeClassFromCells', 27314 value: function removeClassFromCells(className) { 27315 var nodes = this.TABLE.querySelectorAll('.' + className); 27316 27317 for (var i = 0, len = nodes.length; i < len; i++) { 27318 (0, _element.removeClass)(nodes[i], className); 27319 } 27320 } 27321 }, { 27322 key: 'refreshSelections', 27323 value: function refreshSelections(fastDraw) { 27324 if (!this.wot.selections) { 27325 return; 27326 } 27327 var len = this.wot.selections.length; 27328 27329 if (fastDraw) { 27330 for (var i = 0; i < len; i++) { 27331 // there was no rerender, so we need to remove classNames by ourselves 27332 if (this.wot.selections[i].settings.className) { 27333 this.removeClassFromCells(this.wot.selections[i].settings.className); 27334 } 27335 if (this.wot.selections[i].settings.highlightHeaderClassName) { 27336 this.removeClassFromCells(this.wot.selections[i].settings.highlightHeaderClassName); 27337 } 27338 if (this.wot.selections[i].settings.highlightRowClassName) { 27339 this.removeClassFromCells(this.wot.selections[i].settings.highlightRowClassName); 27340 } 27341 if (this.wot.selections[i].settings.highlightColumnClassName) { 27342 this.removeClassFromCells(this.wot.selections[i].settings.highlightColumnClassName); 27343 } 27344 } 27345 } 27346 for (var _i = 0; _i < len; _i++) { 27347 this.wot.selections[_i].draw(this.wot, fastDraw); 27348 } 27349 } 27350 27351 /** 27352 * Get cell element at coords. 27353 * 27354 * @param {CellCoords} coords 27355 * @returns {HTMLElement|Number} HTMLElement on success or Number one of the exit codes on error: 27356 * -1 row before viewport 27357 * -2 row after viewport 27358 */ 27359 27360 }, { 27361 key: 'getCell', 27362 value: function getCell(coords) { 27363 if (this.isRowBeforeRenderedRows(coords.row)) { 27364 // row before rendered rows 27365 return -1; 27366 } else if (this.isRowAfterRenderedRows(coords.row)) { 27367 // row after rendered rows 27368 return -2; 27369 } 27370 27371 var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(coords.row)]; 27372 27373 if (TR) { 27374 return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(coords.col)]; 27375 } 27376 } 27377 27378 /** 27379 * getColumnHeader 27380 * 27381 * @param {Number} col Column index 27382 * @param {Number} [level=0] Header level (0 = most distant to the table) 27383 * @returns {Object} HTMLElement on success or undefined on error 27384 */ 27385 27386 }, { 27387 key: 'getColumnHeader', 27388 value: function getColumnHeader(col) { 27389 var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 27390 27391 var TR = this.THEAD.childNodes[level]; 27392 27393 if (TR) { 27394 return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)]; 27395 } 27396 } 27397 27398 /** 27399 * getRowHeader 27400 * 27401 * @param {Number} row Row index 27402 * @returns {HTMLElement} HTMLElement on success or Number one of the exit codes on error: `null table doesn't have row headers` 27403 */ 27404 27405 }, { 27406 key: 'getRowHeader', 27407 value: function getRowHeader(row) { 27408 if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) { 27409 return null; 27410 } 27411 var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)]; 27412 27413 if (TR) { 27414 return TR.childNodes[0]; 27415 } 27416 } 27417 27418 /** 27419 * Returns cell coords object for a given TD (or a child element of a TD element). 27420 * 27421 * @param {HTMLTableCellElement} TD A cell DOM element (or a child of one). 27422 * @returns {CellCoords|null} The coordinates of the provided TD element (or the closest TD element) or null, if the provided element is not applicable. 27423 */ 27424 27425 }, { 27426 key: 'getCoords', 27427 value: function getCoords(TD) { 27428 if (TD.nodeName !== 'TD' && TD.nodeName !== 'TH') { 27429 TD = (0, _element.closest)(TD, ['TD', 'TH']); 27430 } 27431 27432 if (TD === null) { 27433 return null; 27434 } 27435 27436 var TR = TD.parentNode; 27437 var CONTAINER = TR.parentNode; 27438 var row = (0, _element.index)(TR); 27439 var col = TD.cellIndex; 27440 27441 if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_TOP, TD)) { 27442 if (CONTAINER.nodeName === 'THEAD') { 27443 row -= CONTAINER.childNodes.length; 27444 } 27445 } else if (CONTAINER === this.THEAD) { 27446 row = this.rowFilter.visibleColHeadedRowToSourceRow(row); 27447 } else { 27448 row = this.rowFilter.renderedToSource(row); 27449 } 27450 27451 if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_LEFT, TD)) { 27452 col = this.columnFilter.offsettedTH(col); 27453 } else { 27454 col = this.columnFilter.visibleRowHeadedColumnToSourceColumn(col); 27455 } 27456 27457 return new _coords2.default(row, col); 27458 } 27459 }, { 27460 key: 'getTrForRow', 27461 value: function getTrForRow(row) { 27462 return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)]; 27463 } 27464 }, { 27465 key: 'getFirstRenderedRow', 27466 value: function getFirstRenderedRow() { 27467 return this.wot.wtViewport.rowsRenderCalculator.startRow; 27468 } 27469 }, { 27470 key: 'getFirstVisibleRow', 27471 value: function getFirstVisibleRow() { 27472 return this.wot.wtViewport.rowsVisibleCalculator.startRow; 27473 } 27474 }, { 27475 key: 'getFirstRenderedColumn', 27476 value: function getFirstRenderedColumn() { 27477 return this.wot.wtViewport.columnsRenderCalculator.startColumn; 27478 } 27479 27480 /** 27481 * @returns {Number} Returns -1 if no row is visible 27482 */ 27483 27484 }, { 27485 key: 'getFirstVisibleColumn', 27486 value: function getFirstVisibleColumn() { 27487 return this.wot.wtViewport.columnsVisibleCalculator.startColumn; 27488 } 27489 27490 /** 27491 * @returns {Number} Returns -1 if no row is visible 27492 */ 27493 27494 }, { 27495 key: 'getLastRenderedRow', 27496 value: function getLastRenderedRow() { 27497 return this.wot.wtViewport.rowsRenderCalculator.endRow; 27498 } 27499 }, { 27500 key: 'getLastVisibleRow', 27501 value: function getLastVisibleRow() { 27502 return this.wot.wtViewport.rowsVisibleCalculator.endRow; 27503 } 27504 }, { 27505 key: 'getLastRenderedColumn', 27506 value: function getLastRenderedColumn() { 27507 return this.wot.wtViewport.columnsRenderCalculator.endColumn; 27508 } 27509 27510 /** 27511 * @returns {Number} Returns -1 if no column is visible 27512 */ 27513 27514 }, { 27515 key: 'getLastVisibleColumn', 27516 value: function getLastVisibleColumn() { 27517 return this.wot.wtViewport.columnsVisibleCalculator.endColumn; 27518 } 27519 }, { 27520 key: 'isRowBeforeRenderedRows', 27521 value: function isRowBeforeRenderedRows(row) { 27522 return this.rowFilter && this.rowFilter.sourceToRendered(row) < 0 && row >= 0; 27523 } 27524 }, { 27525 key: 'isRowAfterViewport', 27526 value: function isRowAfterViewport(row) { 27527 return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastVisibleRow(); 27528 } 27529 }, { 27530 key: 'isRowAfterRenderedRows', 27531 value: function isRowAfterRenderedRows(row) { 27532 return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastRenderedRow(); 27533 } 27534 }, { 27535 key: 'isColumnBeforeViewport', 27536 value: function isColumnBeforeViewport(column) { 27537 return this.columnFilter && this.columnFilter.sourceToRendered(column) < 0 && column >= 0; 27538 } 27539 }, { 27540 key: 'isColumnAfterViewport', 27541 value: function isColumnAfterViewport(column) { 27542 return this.columnFilter && this.columnFilter.sourceToRendered(column) > this.getLastVisibleColumn(); 27543 } 27544 }, { 27545 key: 'isLastRowFullyVisible', 27546 value: function isLastRowFullyVisible() { 27547 return this.getLastVisibleRow() === this.getLastRenderedRow(); 27548 } 27549 }, { 27550 key: 'isLastColumnFullyVisible', 27551 value: function isLastColumnFullyVisible() { 27552 return this.getLastVisibleColumn() === this.getLastRenderedColumn(); 27553 } 27554 }, { 27555 key: 'getRenderedColumnsCount', 27556 value: function getRenderedColumnsCount() { 27557 var columnsCount = this.wot.wtViewport.columnsRenderCalculator.count; 27558 var totalColumns = this.wot.getSetting('totalColumns'); 27559 27560 if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) { 27561 columnsCount = totalColumns; 27562 } else if (this.wot.isOverlayName(_base2.default.CLONE_LEFT) || this.wot.isOverlayName(_base2.default.CLONE_TOP_LEFT_CORNER) || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) { 27563 return Math.min(this.wot.getSetting('fixedColumnsLeft'), totalColumns); 27564 } 27565 27566 return columnsCount; 27567 } 27568 }, { 27569 key: 'getRenderedRowsCount', 27570 value: function getRenderedRowsCount() { 27571 var rowsCount = this.wot.wtViewport.rowsRenderCalculator.count; 27572 var totalRows = this.wot.getSetting('totalRows'); 27573 27574 if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) { 27575 rowsCount = totalRows; 27576 } else if (this.wot.isOverlayName(_base2.default.CLONE_TOP) || this.wot.isOverlayName(_base2.default.CLONE_TOP_LEFT_CORNER)) { 27577 rowsCount = Math.min(this.wot.getSetting('fixedRowsTop'), totalRows); 27578 } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM) || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) { 27579 rowsCount = Math.min(this.wot.getSetting('fixedRowsBottom'), totalRows); 27580 } 27581 27582 return rowsCount; 27583 } 27584 }, { 27585 key: 'getVisibleRowsCount', 27586 value: function getVisibleRowsCount() { 27587 return this.wot.wtViewport.rowsVisibleCalculator.count; 27588 } 27589 }, { 27590 key: 'allRowsInViewport', 27591 value: function allRowsInViewport() { 27592 return this.wot.getSetting('totalRows') == this.getVisibleRowsCount(); 27593 } 27594 27595 /** 27596 * Checks if any of the row's cells content exceeds its initial height, and if so, returns the oversized height 27597 * 27598 * @param {Number} sourceRow 27599 * @returns {Number} 27600 */ 27601 27602 }, { 27603 key: 'getRowHeight', 27604 value: function getRowHeight(sourceRow) { 27605 var height = this.wot.wtSettings.settings.rowHeight(sourceRow); 27606 var oversizedHeight = this.wot.wtViewport.oversizedRows[sourceRow]; 27607 27608 if (oversizedHeight !== void 0) { 27609 height = height === void 0 ? oversizedHeight : Math.max(height, oversizedHeight); 27610 } 27611 27612 return height; 27613 } 27614 }, { 27615 key: 'getColumnHeaderHeight', 27616 value: function getColumnHeaderHeight(level) { 27617 var height = this.wot.wtSettings.settings.defaultRowHeight; 27618 var oversizedHeight = this.wot.wtViewport.oversizedColumnHeaders[level]; 27619 27620 if (oversizedHeight !== void 0) { 27621 height = height ? Math.max(height, oversizedHeight) : oversizedHeight; 27622 } 27623 27624 return height; 27625 } 27626 }, { 27627 key: 'getVisibleColumnsCount', 27628 value: function getVisibleColumnsCount() { 27629 return this.wot.wtViewport.columnsVisibleCalculator.count; 27630 } 27631 }, { 27632 key: 'allColumnsInViewport', 27633 value: function allColumnsInViewport() { 27634 return this.wot.getSetting('totalColumns') == this.getVisibleColumnsCount(); 27635 } 27636 }, { 27637 key: 'getColumnWidth', 27638 value: function getColumnWidth(sourceColumn) { 27639 var width = this.wot.wtSettings.settings.columnWidth; 27640 27641 if (typeof width === 'function') { 27642 width = width(sourceColumn); 27643 } else if ((typeof width === 'undefined' ? 'undefined' : _typeof(width)) === 'object') { 27644 width = width[sourceColumn]; 27645 } 27646 27647 return width || this.wot.wtSettings.settings.defaultColumnWidth; 27648 } 27649 }, { 27650 key: 'getStretchedColumnWidth', 27651 value: function getStretchedColumnWidth(sourceColumn) { 27652 var columnWidth = this.getColumnWidth(sourceColumn); 27653 var width = columnWidth == null ? this.instance.wtSettings.settings.defaultColumnWidth : columnWidth; 27654 var calculator = this.wot.wtViewport.columnsRenderCalculator; 27655 27656 if (calculator) { 27657 var stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width); 27658 27659 if (stretchedWidth) { 27660 width = stretchedWidth; 27661 } 27662 } 27663 27664 return width; 27665 } 27666 27667 /** 27668 * Modify row header widths provided by user in class contructor. 27669 * 27670 * @private 27671 */ 27672 27673 }, { 27674 key: '_modifyRowHeaderWidth', 27675 value: function _modifyRowHeaderWidth(rowHeaderWidthFactory) { 27676 var widths = (0, _function.isFunction)(rowHeaderWidthFactory) ? rowHeaderWidthFactory() : null; 27677 27678 if (Array.isArray(widths)) { 27679 widths = [].concat(_toConsumableArray(widths)); 27680 widths[widths.length - 1] = this._correctRowHeaderWidth(widths[widths.length - 1]); 27681 } else { 27682 widths = this._correctRowHeaderWidth(widths); 27683 } 27684 27685 return widths; 27686 } 27687 27688 /** 27689 * Correct row header width if necessary. 27690 * 27691 * @private 27692 */ 27693 27694 }, { 27695 key: '_correctRowHeaderWidth', 27696 value: function _correctRowHeaderWidth(width) { 27697 if (typeof width !== 'number') { 27698 width = this.wot.getSetting('defaultColumnWidth'); 27699 } 27700 if (this.correctHeaderWidth) { 27701 width++; 27702 } 27703 27704 return width; 27705 } 27706 }]); 27707 27708 return Table; 27709}(); 27710 27711exports.default = Table; 27712 27713/***/ }), 27714/* 261 */ 27715/***/ (function(module, exports, __webpack_require__) { 27716 27717"use strict"; 27718 27719 27720exports.__esModule = true; 27721 27722var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 27723 27724var _element = __webpack_require__(0); 27725 27726var _base = __webpack_require__(29); 27727 27728var _base2 = _interopRequireDefault(_base); 27729 27730function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27731 27732function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 27733 27734var performanceWarningAppeared = false; 27735 27736/** 27737 * @class TableRenderer 27738 */ 27739 27740var TableRenderer = function () { 27741 /** 27742 * @param {WalkontableTable} wtTable 27743 */ 27744 function TableRenderer(wtTable) { 27745 _classCallCheck(this, TableRenderer); 27746 27747 this.wtTable = wtTable; 27748 this.wot = wtTable.instance; 27749 27750 // legacy support 27751 this.instance = wtTable.instance; 27752 27753 this.rowFilter = wtTable.rowFilter; 27754 this.columnFilter = wtTable.columnFilter; 27755 27756 this.TABLE = wtTable.TABLE; 27757 this.THEAD = wtTable.THEAD; 27758 this.TBODY = wtTable.TBODY; 27759 this.COLGROUP = wtTable.COLGROUP; 27760 27761 this.rowHeaders = []; 27762 this.rowHeaderCount = 0; 27763 this.columnHeaders = []; 27764 this.columnHeaderCount = 0; 27765 this.fixedRowsTop = 0; 27766 this.fixedRowsBottom = 0; 27767 } 27768 27769 /** 27770 * 27771 */ 27772 27773 27774 _createClass(TableRenderer, [{ 27775 key: 'render', 27776 value: function render() { 27777 if (!this.wtTable.isWorkingOnClone()) { 27778 var skipRender = {}; 27779 this.wot.getSetting('beforeDraw', true, skipRender); 27780 27781 if (skipRender.skipRender === true) { 27782 return; 27783 } 27784 } 27785 27786 this.rowHeaders = this.wot.getSetting('rowHeaders'); 27787 this.rowHeaderCount = this.rowHeaders.length; 27788 this.fixedRowsTop = this.wot.getSetting('fixedRowsTop'); 27789 this.fixedRowsBottom = this.wot.getSetting('fixedRowsBottom'); 27790 this.columnHeaders = this.wot.getSetting('columnHeaders'); 27791 this.columnHeaderCount = this.columnHeaders.length; 27792 27793 var columnsToRender = this.wtTable.getRenderedColumnsCount(); 27794 var rowsToRender = this.wtTable.getRenderedRowsCount(); 27795 var totalColumns = this.wot.getSetting('totalColumns'); 27796 var totalRows = this.wot.getSetting('totalRows'); 27797 var workspaceWidth = void 0; 27798 var adjusted = false; 27799 27800 if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) { 27801 27802 // do NOT render headers on the bottom or bottom-left corner overlay 27803 this.columnHeaders = []; 27804 this.columnHeaderCount = 0; 27805 } 27806 27807 if (totalColumns >= 0) { 27808 // prepare COL and TH elements for rendering 27809 this.adjustAvailableNodes(); 27810 adjusted = true; 27811 27812 // adjust column widths according to user widths settings 27813 this.renderColumnHeaders(); 27814 27815 // Render table rows 27816 this.renderRows(totalRows, rowsToRender, columnsToRender); 27817 27818 if (!this.wtTable.isWorkingOnClone()) { 27819 workspaceWidth = this.wot.wtViewport.getWorkspaceWidth(); 27820 this.wot.wtViewport.containerWidth = null; 27821 } 27822 27823 this.adjustColumnWidths(columnsToRender); 27824 this.markOversizedColumnHeaders(); 27825 this.adjustColumnHeaderHeights(); 27826 } 27827 27828 if (!adjusted) { 27829 this.adjustAvailableNodes(); 27830 } 27831 this.removeRedundantRows(rowsToRender); 27832 27833 if (!this.wtTable.isWorkingOnClone() || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) { 27834 this.markOversizedRows(); 27835 } 27836 if (!this.wtTable.isWorkingOnClone()) { 27837 this.wot.wtViewport.createVisibleCalculators(); 27838 this.wot.wtOverlays.refresh(false); 27839 27840 this.wot.wtOverlays.applyToDOM(); 27841 27842 var hiderWidth = (0, _element.outerWidth)(this.wtTable.hider); 27843 var tableWidth = (0, _element.outerWidth)(this.wtTable.TABLE); 27844 27845 if (hiderWidth !== 0 && tableWidth !== hiderWidth) { 27846 // Recalculate the column widths, if width changes made in the overlays removed the scrollbar, thus changing the viewport width. 27847 this.adjustColumnWidths(columnsToRender); 27848 } 27849 27850 if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) { 27851 // workspace width changed though to shown/hidden vertical scrollbar. Let's reapply stretching 27852 this.wot.wtViewport.containerWidth = null; 27853 27854 var firstRendered = this.wtTable.getFirstRenderedColumn(); 27855 var lastRendered = this.wtTable.getLastRenderedColumn(); 27856 var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth'); 27857 var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth'); 27858 27859 rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting); 27860 27861 if (rowHeaderWidthSetting != null) { 27862 for (var i = 0; i < this.rowHeaderCount; i++) { 27863 var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting; 27864 27865 width = width == null ? defaultColumnWidth : width; 27866 27867 this.COLGROUP.childNodes[i].style.width = width + 'px'; 27868 } 27869 } 27870 27871 for (var _i = firstRendered; _i < lastRendered; _i++) { 27872 var _width = this.wtTable.getStretchedColumnWidth(_i); 27873 var renderedIndex = this.columnFilter.sourceToRendered(_i); 27874 27875 this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = _width + 'px'; 27876 } 27877 } 27878 27879 this.wot.getSetting('onDraw', true); 27880 } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) { 27881 this.wot.cloneSource.wtOverlays.adjustElementsSize(); 27882 } 27883 } 27884 27885 /** 27886 * @param {Number} renderedRowsCount 27887 */ 27888 27889 }, { 27890 key: 'removeRedundantRows', 27891 value: function removeRedundantRows(renderedRowsCount) { 27892 while (this.wtTable.tbodyChildrenLength > renderedRowsCount) { 27893 this.TBODY.removeChild(this.TBODY.lastChild); 27894 this.wtTable.tbodyChildrenLength--; 27895 } 27896 } 27897 27898 /** 27899 * @param {Number} totalRows 27900 * @param {Number} rowsToRender 27901 * @param {Number} columnsToRender 27902 */ 27903 27904 }, { 27905 key: 'renderRows', 27906 value: function renderRows(totalRows, rowsToRender, columnsToRender) { 27907 var lastTD = void 0, 27908 TR = void 0; 27909 var visibleRowIndex = 0; 27910 var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex); 27911 var isWorkingOnClone = this.wtTable.isWorkingOnClone(); 27912 27913 while (sourceRowIndex < totalRows && sourceRowIndex >= 0) { 27914 if (!performanceWarningAppeared && visibleRowIndex > 1000) { 27915 performanceWarningAppeared = true; 27916 console.warn('Performance tip: Handsontable rendered more than 1000 visible rows. Consider limiting the number ' + 'of rendered rows by specifying the table height and/or turning off the "renderAllRows" option.'); 27917 } 27918 if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) { 27919 // We have as much rows as needed for this clone 27920 break; 27921 } 27922 TR = this.getOrCreateTrForRow(visibleRowIndex, TR); 27923 27924 // Render row headers 27925 this.renderRowHeaders(sourceRowIndex, TR); 27926 // Add and/or remove TDs to TR to match the desired number 27927 this.adjustColumns(TR, columnsToRender + this.rowHeaderCount); 27928 27929 lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender); 27930 27931 if (!isWorkingOnClone || 27932 // Necessary to refresh oversized row heights after editing cell in overlays 27933 this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) { 27934 // Reset the oversized row cache for this row 27935 this.resetOversizedRow(sourceRowIndex); 27936 } 27937 27938 if (TR.firstChild) { 27939 // if I have 2 fixed columns with one-line content and the 3rd column has a multiline content, this is 27940 // the way to make sure that the overlay will has same row height 27941 var height = this.wot.wtTable.getRowHeight(sourceRowIndex); 27942 27943 if (height) { 27944 // Decrease height. 1 pixel will be "replaced" by 1px border top 27945 height--; 27946 TR.firstChild.style.height = height + 'px'; 27947 } else { 27948 TR.firstChild.style.height = ''; 27949 } 27950 } 27951 visibleRowIndex++; 27952 sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex); 27953 } 27954 } 27955 27956 /** 27957 * Reset the oversized row cache for the provided index 27958 * 27959 * @param {Number} sourceRow Row index 27960 */ 27961 27962 }, { 27963 key: 'resetOversizedRow', 27964 value: function resetOversizedRow(sourceRow) { 27965 if (this.wot.getSetting('externalRowCalculator')) { 27966 return; 27967 } 27968 if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) { 27969 this.wot.wtViewport.oversizedRows[sourceRow] = void 0; 27970 } 27971 } 27972 27973 /** 27974 * Check if any of the rendered rows is higher than expected, and if so, cache them 27975 */ 27976 27977 }, { 27978 key: 'markOversizedRows', 27979 value: function markOversizedRows() { 27980 if (this.wot.getSetting('externalRowCalculator')) { 27981 return; 27982 } 27983 var rowCount = this.instance.wtTable.TBODY.childNodes.length; 27984 var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight; 27985 var actualTableHeight = (0, _element.innerHeight)(this.instance.wtTable.TBODY) - 1; 27986 var previousRowHeight = void 0; 27987 var rowInnerHeight = void 0; 27988 var sourceRowIndex = void 0; 27989 var currentTr = void 0; 27990 var rowHeader = void 0; 27991 var totalRows = this.instance.getSetting('totalRows'); 27992 27993 if (expectedTableHeight === actualTableHeight && !this.instance.getSetting('fixedRowsBottom')) { 27994 // If the actual table height equals rowCount * default single row height, no row is oversized -> no need to iterate over them 27995 return; 27996 } 27997 27998 while (rowCount) { 27999 rowCount--; 28000 sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount); 28001 previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex); 28002 currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex); 28003 rowHeader = currentTr.querySelector('th'); 28004 28005 if (rowHeader) { 28006 rowInnerHeight = (0, _element.innerHeight)(rowHeader); 28007 } else { 28008 rowInnerHeight = (0, _element.innerHeight)(currentTr) - 1; 28009 } 28010 28011 if (!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight) { 28012 this.instance.wtViewport.oversizedRows[sourceRowIndex] = ++rowInnerHeight; 28013 } 28014 } 28015 } 28016 28017 /** 28018 * Check if any of the rendered columns is higher than expected, and if so, cache them. 28019 */ 28020 28021 }, { 28022 key: 'markOversizedColumnHeaders', 28023 value: function markOversizedColumnHeaders() { 28024 var overlayName = this.wot.getOverlayName(); 28025 28026 if (!this.columnHeaderCount || this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] || this.wtTable.isWorkingOnClone()) { 28027 return; 28028 } 28029 var columnCount = this.wtTable.getRenderedColumnsCount(); 28030 28031 for (var i = 0; i < this.columnHeaderCount; i++) { 28032 for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) { 28033 this.markIfOversizedColumnHeader(renderedColumnIndex); 28034 } 28035 } 28036 this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] = true; 28037 } 28038 28039 /** 28040 * 28041 */ 28042 28043 }, { 28044 key: 'adjustColumnHeaderHeights', 28045 value: function adjustColumnHeaderHeights() { 28046 var columnHeaders = this.wot.getSetting('columnHeaders'); 28047 var children = this.wot.wtTable.THEAD.childNodes; 28048 var oversizedColumnHeaders = this.wot.wtViewport.oversizedColumnHeaders; 28049 28050 for (var i = 0, len = columnHeaders.length; i < len; i++) { 28051 if (oversizedColumnHeaders[i]) { 28052 if (!children[i] || children[i].childNodes.length === 0) { 28053 return; 28054 } 28055 children[i].childNodes[0].style.height = oversizedColumnHeaders[i] + 'px'; 28056 } 28057 } 28058 } 28059 28060 /** 28061 * Check if column header for the specified column is higher than expected, and if so, cache it 28062 * 28063 * @param {Number} col Index of column 28064 */ 28065 28066 }, { 28067 key: 'markIfOversizedColumnHeader', 28068 value: function markIfOversizedColumnHeader(col) { 28069 var sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col); 28070 var level = this.columnHeaderCount; 28071 var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight; 28072 var previousColHeaderHeight = void 0; 28073 var currentHeader = void 0; 28074 var currentHeaderHeight = void 0; 28075 var columnHeaderHeightSetting = this.wot.getSetting('columnHeaderHeight') || []; 28076 28077 while (level) { 28078 level--; 28079 28080 previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level); 28081 currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level); 28082 28083 if (!currentHeader) { 28084 /* eslint-disable no-continue */ 28085 continue; 28086 } 28087 currentHeaderHeight = (0, _element.innerHeight)(currentHeader); 28088 28089 if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) { 28090 this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight; 28091 } 28092 28093 if (Array.isArray(columnHeaderHeightSetting)) { 28094 if (columnHeaderHeightSetting[level] != null) { 28095 this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level]; 28096 } 28097 } else if (!isNaN(columnHeaderHeightSetting)) { 28098 this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting; 28099 } 28100 28101 if (this.wot.wtViewport.oversizedColumnHeaders[level] < (columnHeaderHeightSetting[level] || columnHeaderHeightSetting)) { 28102 this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level] || columnHeaderHeightSetting; 28103 } 28104 } 28105 } 28106 28107 /** 28108 * @param {Number} sourceRowIndex 28109 * @param {HTMLTableRowElement} TR 28110 * @param {Number} columnsToRender 28111 * @returns {HTMLTableCellElement} 28112 */ 28113 28114 }, { 28115 key: 'renderCells', 28116 value: function renderCells(sourceRowIndex, TR, columnsToRender) { 28117 var TD = void 0; 28118 var sourceColIndex = void 0; 28119 28120 for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) { 28121 sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex); 28122 28123 if (visibleColIndex === 0) { 28124 TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)]; 28125 } else { 28126 TD = TD.nextSibling; // http://jsperf.com/nextsibling-vs-indexed-childnodes 28127 } 28128 // If the number of headers has been reduced, we need to replace excess TH with TD 28129 if (TD.nodeName == 'TH') { 28130 TD = replaceThWithTd(TD, TR); 28131 } 28132 if (!(0, _element.hasClass)(TD, 'hide')) { 28133 TD.className = ''; 28134 } 28135 TD.removeAttribute('style'); 28136 this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD); 28137 } 28138 28139 return TD; 28140 } 28141 28142 /** 28143 * @param {Number} columnsToRender Number of columns to render. 28144 */ 28145 28146 }, { 28147 key: 'adjustColumnWidths', 28148 value: function adjustColumnWidths(columnsToRender) { 28149 var scrollbarCompensation = 0; 28150 var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot; 28151 var mainHolder = sourceInstance.wtTable.holder; 28152 var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth'); 28153 var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth'); 28154 28155 if (mainHolder.offsetHeight < mainHolder.scrollHeight) { 28156 scrollbarCompensation = (0, _element.getScrollbarWidth)(); 28157 } 28158 this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation); 28159 28160 rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting); 28161 28162 if (rowHeaderWidthSetting != null) { 28163 for (var i = 0; i < this.rowHeaderCount; i++) { 28164 var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting; 28165 28166 width = width == null ? defaultColumnWidth : width; 28167 28168 this.COLGROUP.childNodes[i].style.width = width + 'px'; 28169 } 28170 } 28171 28172 for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) { 28173 var _width2 = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex)); 28174 28175 this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = _width2 + 'px'; 28176 } 28177 } 28178 28179 /** 28180 * @param {HTMLTableCellElement} TR 28181 */ 28182 28183 }, { 28184 key: 'appendToTbody', 28185 value: function appendToTbody(TR) { 28186 this.TBODY.appendChild(TR); 28187 this.wtTable.tbodyChildrenLength++; 28188 } 28189 28190 /** 28191 * @param {Number} rowIndex 28192 * @param {HTMLTableRowElement} currentTr 28193 * @returns {HTMLTableCellElement} 28194 */ 28195 28196 }, { 28197 key: 'getOrCreateTrForRow', 28198 value: function getOrCreateTrForRow(rowIndex, currentTr) { 28199 var TR = void 0; 28200 28201 if (rowIndex >= this.wtTable.tbodyChildrenLength) { 28202 TR = this.createRow(); 28203 this.appendToTbody(TR); 28204 } else if (rowIndex === 0) { 28205 TR = this.TBODY.firstChild; 28206 } else { 28207 // http://jsperf.com/nextsibling-vs-indexed-childnodes 28208 TR = currentTr.nextSibling; 28209 } 28210 if (TR.className) { 28211 TR.removeAttribute('class'); 28212 } 28213 28214 return TR; 28215 } 28216 28217 /** 28218 * @returns {HTMLTableCellElement} 28219 */ 28220 28221 }, { 28222 key: 'createRow', 28223 value: function createRow() { 28224 var TR = document.createElement('TR'); 28225 28226 for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) { 28227 TR.appendChild(document.createElement('TH')); 28228 } 28229 28230 return TR; 28231 } 28232 28233 /** 28234 * @param {Number} row 28235 * @param {Number} col 28236 * @param {HTMLTableCellElement} TH 28237 */ 28238 28239 }, { 28240 key: 'renderRowHeader', 28241 value: function renderRowHeader(row, col, TH) { 28242 TH.className = ''; 28243 TH.removeAttribute('style'); 28244 this.rowHeaders[col](row, TH, col); 28245 } 28246 28247 /** 28248 * @param {Number} row 28249 * @param {HTMLTableCellElement} TR 28250 */ 28251 28252 }, { 28253 key: 'renderRowHeaders', 28254 value: function renderRowHeaders(row, TR) { 28255 for (var TH = TR.firstChild, visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) { 28256 // If the number of row headers increased we need to create TH or replace an existing TD node with TH 28257 if (!TH) { 28258 TH = document.createElement('TH'); 28259 TR.appendChild(TH); 28260 } else if (TH.nodeName == 'TD') { 28261 TH = replaceTdWithTh(TH, TR); 28262 } 28263 this.renderRowHeader(row, visibleColIndex, TH); 28264 // http://jsperf.com/nextsibling-vs-indexed-childnodes 28265 TH = TH.nextSibling; 28266 } 28267 } 28268 28269 /** 28270 * Adjust the number of COL and TH elements to match the number of columns and headers that need to be rendered 28271 */ 28272 28273 }, { 28274 key: 'adjustAvailableNodes', 28275 value: function adjustAvailableNodes() { 28276 this.adjustColGroups(); 28277 this.adjustThead(); 28278 } 28279 28280 /** 28281 * Renders the column headers 28282 */ 28283 28284 }, { 28285 key: 'renderColumnHeaders', 28286 value: function renderColumnHeaders() { 28287 if (!this.columnHeaderCount) { 28288 return; 28289 } 28290 var columnCount = this.wtTable.getRenderedColumnsCount(); 28291 28292 for (var i = 0; i < this.columnHeaderCount; i++) { 28293 var TR = this.getTrForColumnHeaders(i); 28294 28295 for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) { 28296 var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex); 28297 28298 this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]); 28299 } 28300 } 28301 } 28302 28303 /** 28304 * Adjusts the number of COL elements to match the number of columns that need to be rendered 28305 */ 28306 28307 }, { 28308 key: 'adjustColGroups', 28309 value: function adjustColGroups() { 28310 var columnCount = this.wtTable.getRenderedColumnsCount(); 28311 28312 while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) { 28313 this.COLGROUP.appendChild(document.createElement('COL')); 28314 this.wtTable.colgroupChildrenLength++; 28315 } 28316 while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) { 28317 this.COLGROUP.removeChild(this.COLGROUP.lastChild); 28318 this.wtTable.colgroupChildrenLength--; 28319 } 28320 if (this.rowHeaderCount) { 28321 (0, _element.addClass)(this.COLGROUP.childNodes[0], 'rowHeader'); 28322 } 28323 } 28324 28325 /** 28326 * Adjusts the number of TH elements in THEAD to match the number of headers and columns that need to be rendered 28327 */ 28328 28329 }, { 28330 key: 'adjustThead', 28331 value: function adjustThead() { 28332 var columnCount = this.wtTable.getRenderedColumnsCount(); 28333 var TR = this.THEAD.firstChild; 28334 28335 if (this.columnHeaders.length) { 28336 for (var i = 0, len = this.columnHeaders.length; i < len; i++) { 28337 TR = this.THEAD.childNodes[i]; 28338 28339 if (!TR) { 28340 TR = document.createElement('TR'); 28341 this.THEAD.appendChild(TR); 28342 } 28343 this.theadChildrenLength = TR.childNodes.length; 28344 28345 while (this.theadChildrenLength < columnCount + this.rowHeaderCount) { 28346 TR.appendChild(document.createElement('TH')); 28347 this.theadChildrenLength++; 28348 } 28349 while (this.theadChildrenLength > columnCount + this.rowHeaderCount) { 28350 TR.removeChild(TR.lastChild); 28351 this.theadChildrenLength--; 28352 } 28353 } 28354 var theadChildrenLength = this.THEAD.childNodes.length; 28355 28356 if (theadChildrenLength > this.columnHeaders.length) { 28357 for (var _i2 = this.columnHeaders.length; _i2 < theadChildrenLength; _i2++) { 28358 this.THEAD.removeChild(this.THEAD.lastChild); 28359 } 28360 } 28361 } else if (TR) { 28362 (0, _element.empty)(TR); 28363 } 28364 } 28365 28366 /** 28367 * @param {Number} index 28368 * @returns {HTMLTableCellElement} 28369 */ 28370 28371 }, { 28372 key: 'getTrForColumnHeaders', 28373 value: function getTrForColumnHeaders(index) { 28374 return this.THEAD.childNodes[index]; 28375 } 28376 28377 /** 28378 * @param {Number} row 28379 * @param {Number} col 28380 * @param {HTMLTableCellElement} TH 28381 * @returns {*} 28382 */ 28383 28384 }, { 28385 key: 'renderColumnHeader', 28386 value: function renderColumnHeader(row, col, TH) { 28387 TH.className = ''; 28388 TH.removeAttribute('style'); 28389 28390 return this.columnHeaders[row](col, TH, row); 28391 } 28392 28393 /** 28394 * Add and/or remove the TDs to match the desired number 28395 * 28396 * @param {HTMLTableCellElement} TR Table row in question 28397 * @param {Number} desiredCount The desired number of TDs in the TR 28398 */ 28399 28400 }, { 28401 key: 'adjustColumns', 28402 value: function adjustColumns(TR, desiredCount) { 28403 var count = TR.childNodes.length; 28404 28405 while (count < desiredCount) { 28406 var TD = document.createElement('TD'); 28407 28408 TR.appendChild(TD); 28409 count++; 28410 } 28411 while (count > desiredCount) { 28412 TR.removeChild(TR.lastChild); 28413 count--; 28414 } 28415 } 28416 28417 /** 28418 * @param {Number} columnsToRender 28419 */ 28420 28421 }, { 28422 key: 'removeRedundantColumns', 28423 value: function removeRedundantColumns(columnsToRender) { 28424 while (this.wtTable.tbodyChildrenLength > columnsToRender) { 28425 this.TBODY.removeChild(this.TBODY.lastChild); 28426 this.wtTable.tbodyChildrenLength--; 28427 } 28428 } 28429 }]); 28430 28431 return TableRenderer; 28432}(); 28433 28434function replaceTdWithTh(TD, TR) { 28435 var TH = document.createElement('TH'); 28436 28437 TR.insertBefore(TH, TD); 28438 TR.removeChild(TD); 28439 28440 return TH; 28441} 28442 28443function replaceThWithTd(TH, TR) { 28444 var TD = document.createElement('TD'); 28445 28446 TR.insertBefore(TD, TH); 28447 TR.removeChild(TH); 28448 28449 return TD; 28450} 28451 28452exports.default = TableRenderer; 28453 28454/***/ }), 28455/* 262 */ 28456/***/ (function(module, exports, __webpack_require__) { 28457 28458"use strict"; 28459 28460 28461exports.__esModule = true; 28462 28463var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 28464 28465var _element = __webpack_require__(0); 28466 28467var _object = __webpack_require__(3); 28468 28469var _eventManager = __webpack_require__(4); 28470 28471var _eventManager2 = _interopRequireDefault(_eventManager); 28472 28473var _viewportColumns = __webpack_require__(251); 28474 28475var _viewportColumns2 = _interopRequireDefault(_viewportColumns); 28476 28477var _viewportRows = __webpack_require__(252); 28478 28479var _viewportRows2 = _interopRequireDefault(_viewportRows); 28480 28481function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 28482 28483function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 28484 28485/** 28486 * @class Viewport 28487 */ 28488var Viewport = function () { 28489 /** 28490 * @param wotInstance 28491 */ 28492 function Viewport(wotInstance) { 28493 var _this = this; 28494 28495 _classCallCheck(this, Viewport); 28496 28497 this.wot = wotInstance; 28498 // legacy support 28499 this.instance = this.wot; 28500 28501 this.oversizedRows = []; 28502 this.oversizedColumnHeaders = []; 28503 this.hasOversizedColumnHeadersMarked = {}; 28504 this.clientHeight = 0; 28505 this.containerWidth = NaN; 28506 this.rowHeaderWidth = NaN; 28507 this.rowsVisibleCalculator = null; 28508 this.columnsVisibleCalculator = null; 28509 28510 this.eventManager = new _eventManager2.default(this.wot); 28511 this.eventManager.addEventListener(window, 'resize', function () { 28512 _this.clientHeight = _this.getWorkspaceHeight(); 28513 }); 28514 } 28515 28516 /** 28517 * @returns {number} 28518 */ 28519 28520 28521 _createClass(Viewport, [{ 28522 key: 'getWorkspaceHeight', 28523 value: function getWorkspaceHeight() { 28524 var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer; 28525 var elemHeight = void 0; 28526 var height = 0; 28527 28528 if (trimmingContainer === window) { 28529 height = document.documentElement.clientHeight; 28530 } else { 28531 elemHeight = (0, _element.outerHeight)(trimmingContainer); 28532 // returns height without DIV scrollbar 28533 height = elemHeight > 0 && trimmingContainer.clientHeight > 0 ? trimmingContainer.clientHeight : Infinity; 28534 } 28535 28536 return height; 28537 } 28538 }, { 28539 key: 'getWorkspaceWidth', 28540 value: function getWorkspaceWidth() { 28541 var width = void 0; 28542 var totalColumns = this.wot.getSetting('totalColumns'); 28543 var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer; 28544 var overflow = void 0; 28545 var stretchSetting = this.wot.getSetting('stretchH'); 28546 var docOffsetWidth = document.documentElement.offsetWidth; 28547 var preventOverflow = this.wot.getSetting('preventOverflow'); 28548 28549 if (preventOverflow) { 28550 return (0, _element.outerWidth)(this.instance.wtTable.wtRootElement); 28551 } 28552 28553 if (this.wot.getSetting('freezeOverlays')) { 28554 width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth); 28555 } else { 28556 width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth); 28557 } 28558 28559 if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) { 28560 // in case sum of column widths is higher than available stylesheet width, let's assume using the whole window 28561 // otherwise continue below, which will allow stretching 28562 // this is used in `scroll_window.html` 28563 // TODO test me 28564 return document.documentElement.clientWidth; 28565 } 28566 28567 if (trimmingContainer !== window) { 28568 overflow = (0, _element.getStyle)(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow'); 28569 28570 if (overflow == 'scroll' || overflow == 'hidden' || overflow == 'auto') { 28571 // this is used in `scroll.html` 28572 // TODO test me 28573 return Math.max(width, trimmingContainer.clientWidth); 28574 } 28575 } 28576 28577 if (stretchSetting === 'none' || !stretchSetting) { 28578 // if no stretching is used, return the maximum used workspace width 28579 return Math.max(width, (0, _element.outerWidth)(this.instance.wtTable.TABLE)); 28580 } 28581 28582 // if stretching is used, return the actual container width, so the columns can fit inside it 28583 return width; 28584 } 28585 28586 /** 28587 * Checks if viewport has vertical scroll 28588 * 28589 * @returns {Boolean} 28590 */ 28591 28592 }, { 28593 key: 'hasVerticalScroll', 28594 value: function hasVerticalScroll() { 28595 return this.getWorkspaceActualHeight() > this.getWorkspaceHeight(); 28596 } 28597 28598 /** 28599 * Checks if viewport has horizontal scroll 28600 * 28601 * @returns {Boolean} 28602 */ 28603 28604 }, { 28605 key: 'hasHorizontalScroll', 28606 value: function hasHorizontalScroll() { 28607 return this.getWorkspaceActualWidth() > this.getWorkspaceWidth(); 28608 } 28609 28610 /** 28611 * @param from 28612 * @param length 28613 * @returns {Number} 28614 */ 28615 28616 }, { 28617 key: 'sumColumnWidths', 28618 value: function sumColumnWidths(from, length) { 28619 var sum = 0; 28620 28621 while (from < length) { 28622 sum += this.wot.wtTable.getColumnWidth(from); 28623 from++; 28624 } 28625 28626 return sum; 28627 } 28628 28629 /** 28630 * @returns {Number} 28631 */ 28632 28633 }, { 28634 key: 'getContainerFillWidth', 28635 value: function getContainerFillWidth() { 28636 if (this.containerWidth) { 28637 return this.containerWidth; 28638 } 28639 var mainContainer = this.instance.wtTable.holder; 28640 var fillWidth = void 0; 28641 var dummyElement = void 0; 28642 28643 dummyElement = document.createElement('div'); 28644 dummyElement.style.width = '100%'; 28645 dummyElement.style.height = '1px'; 28646 mainContainer.appendChild(dummyElement); 28647 fillWidth = dummyElement.offsetWidth; 28648 28649 this.containerWidth = fillWidth; 28650 mainContainer.removeChild(dummyElement); 28651 28652 return fillWidth; 28653 } 28654 28655 /** 28656 * @returns {Number} 28657 */ 28658 28659 }, { 28660 key: 'getWorkspaceOffset', 28661 value: function getWorkspaceOffset() { 28662 return (0, _element.offset)(this.wot.wtTable.TABLE); 28663 } 28664 28665 /** 28666 * @returns {Number} 28667 */ 28668 28669 }, { 28670 key: 'getWorkspaceActualHeight', 28671 value: function getWorkspaceActualHeight() { 28672 return (0, _element.outerHeight)(this.wot.wtTable.TABLE); 28673 } 28674 28675 /** 28676 * @returns {Number} 28677 */ 28678 28679 }, { 28680 key: 'getWorkspaceActualWidth', 28681 value: function getWorkspaceActualWidth() { 28682 return (0, _element.outerWidth)(this.wot.wtTable.TABLE) || (0, _element.outerWidth)(this.wot.wtTable.TBODY) || (0, _element.outerWidth)(this.wot.wtTable.THEAD); // IE8 reports 0 as <table> offsetWidth; 28683 } 28684 28685 /** 28686 * @returns {Number} 28687 */ 28688 28689 }, { 28690 key: 'getColumnHeaderHeight', 28691 value: function getColumnHeaderHeight() { 28692 if (isNaN(this.columnHeaderHeight)) { 28693 this.columnHeaderHeight = (0, _element.outerHeight)(this.wot.wtTable.THEAD); 28694 } 28695 28696 return this.columnHeaderHeight; 28697 } 28698 28699 /** 28700 * @returns {Number} 28701 */ 28702 28703 }, { 28704 key: 'getViewportHeight', 28705 value: function getViewportHeight() { 28706 var containerHeight = this.getWorkspaceHeight(); 28707 var columnHeaderHeight = void 0; 28708 28709 if (containerHeight === Infinity) { 28710 return containerHeight; 28711 } 28712 columnHeaderHeight = this.getColumnHeaderHeight(); 28713 28714 if (columnHeaderHeight > 0) { 28715 containerHeight -= columnHeaderHeight; 28716 } 28717 28718 return containerHeight; 28719 } 28720 28721 /** 28722 * @returns {Number} 28723 */ 28724 28725 }, { 28726 key: 'getRowHeaderWidth', 28727 value: function getRowHeaderWidth() { 28728 var rowHeadersHeightSetting = this.instance.getSetting('rowHeaderWidth'); 28729 var rowHeaders = this.instance.getSetting('rowHeaders'); 28730 28731 if (rowHeadersHeightSetting) { 28732 this.rowHeaderWidth = 0; 28733 28734 for (var i = 0, len = rowHeaders.length; i < len; i++) { 28735 this.rowHeaderWidth += rowHeadersHeightSetting[i] || rowHeadersHeightSetting; 28736 } 28737 } 28738 28739 if (this.wot.cloneSource) { 28740 return this.wot.cloneSource.wtViewport.getRowHeaderWidth(); 28741 } 28742 28743 if (isNaN(this.rowHeaderWidth)) { 28744 28745 if (rowHeaders.length) { 28746 var TH = this.instance.wtTable.TABLE.querySelector('TH'); 28747 this.rowHeaderWidth = 0; 28748 28749 for (var _i = 0, _len = rowHeaders.length; _i < _len; _i++) { 28750 if (TH) { 28751 this.rowHeaderWidth += (0, _element.outerWidth)(TH); 28752 TH = TH.nextSibling; 28753 } else { 28754 // yes this is a cheat but it worked like that before, just taking assumption from CSS instead of measuring. 28755 // TODO: proper fix 28756 this.rowHeaderWidth += 50; 28757 } 28758 } 28759 } else { 28760 this.rowHeaderWidth = 0; 28761 } 28762 } 28763 28764 this.rowHeaderWidth = this.instance.getSetting('onModifyRowHeaderWidth', this.rowHeaderWidth) || this.rowHeaderWidth; 28765 28766 return this.rowHeaderWidth; 28767 } 28768 28769 /** 28770 * @returns {Number} 28771 */ 28772 28773 }, { 28774 key: 'getViewportWidth', 28775 value: function getViewportWidth() { 28776 var containerWidth = this.getWorkspaceWidth(); 28777 var rowHeaderWidth = void 0; 28778 28779 if (containerWidth === Infinity) { 28780 return containerWidth; 28781 } 28782 rowHeaderWidth = this.getRowHeaderWidth(); 28783 28784 if (rowHeaderWidth > 0) { 28785 return containerWidth - rowHeaderWidth; 28786 } 28787 28788 return containerWidth; 28789 } 28790 28791 /** 28792 * Creates: 28793 * - rowsRenderCalculator (before draw, to qualify rows for rendering) 28794 * - rowsVisibleCalculator (after draw, to measure which rows are actually visible) 28795 * 28796 * @returns {ViewportRowsCalculator} 28797 */ 28798 28799 }, { 28800 key: 'createRowsCalculator', 28801 value: function createRowsCalculator() { 28802 var _this2 = this; 28803 28804 var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 28805 28806 var height = void 0; 28807 var pos = void 0; 28808 var fixedRowsTop = void 0; 28809 var scrollbarHeight = void 0; 28810 var fixedRowsBottom = void 0; 28811 var fixedRowsHeight = void 0; 28812 var totalRows = void 0; 28813 28814 this.rowHeaderWidth = NaN; 28815 28816 if (this.wot.wtSettings.settings.renderAllRows) { 28817 height = Infinity; 28818 } else { 28819 height = this.getViewportHeight(); 28820 } 28821 pos = this.wot.wtOverlays.topOverlay.getScrollPosition() - this.wot.wtOverlays.topOverlay.getTableParentOffset(); 28822 28823 if (pos < 0) { 28824 pos = 0; 28825 } 28826 fixedRowsTop = this.wot.getSetting('fixedRowsTop'); 28827 fixedRowsBottom = this.wot.getSetting('fixedRowsBottom'); 28828 totalRows = this.wot.getSetting('totalRows'); 28829 28830 if (fixedRowsTop) { 28831 fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop); 28832 pos += fixedRowsHeight; 28833 height -= fixedRowsHeight; 28834 } 28835 28836 if (fixedRowsBottom && this.wot.wtOverlays.bottomOverlay.clone) { 28837 fixedRowsHeight = this.wot.wtOverlays.bottomOverlay.sumCellSizes(totalRows - fixedRowsBottom, totalRows); 28838 28839 height -= fixedRowsHeight; 28840 } 28841 28842 if (this.wot.wtTable.holder.clientHeight === this.wot.wtTable.holder.offsetHeight) { 28843 scrollbarHeight = 0; 28844 } else { 28845 scrollbarHeight = (0, _element.getScrollbarWidth)(); 28846 } 28847 28848 return new _viewportRows2.default(height, pos, this.wot.getSetting('totalRows'), function (sourceRow) { 28849 return _this2.wot.wtTable.getRowHeight(sourceRow); 28850 }, visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible, scrollbarHeight); 28851 } 28852 28853 /** 28854 * Creates: 28855 * - columnsRenderCalculator (before draw, to qualify columns for rendering) 28856 * - columnsVisibleCalculator (after draw, to measure which columns are actually visible) 28857 * 28858 * @returns {ViewportRowsCalculator} 28859 */ 28860 28861 }, { 28862 key: 'createColumnsCalculator', 28863 value: function createColumnsCalculator() { 28864 var _this3 = this; 28865 28866 var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 28867 28868 var width = this.getViewportWidth(); 28869 var pos = void 0; 28870 var fixedColumnsLeft = void 0; 28871 28872 this.columnHeaderHeight = NaN; 28873 28874 pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.leftOverlay.getTableParentOffset(); 28875 28876 if (pos < 0) { 28877 pos = 0; 28878 } 28879 fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft'); 28880 28881 if (fixedColumnsLeft) { 28882 var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft); 28883 pos += fixedColumnsWidth; 28884 width -= fixedColumnsWidth; 28885 } 28886 if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) { 28887 width -= (0, _element.getScrollbarWidth)(); 28888 } 28889 28890 return new _viewportColumns2.default(width, pos, this.wot.getSetting('totalColumns'), function (sourceCol) { 28891 return _this3.wot.wtTable.getColumnWidth(sourceCol); 28892 }, visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'), function (stretchedWidth, column) { 28893 return _this3.wot.getSetting('onBeforeStretchingColumnWidth', stretchedWidth, column); 28894 }); 28895 } 28896 28897 /** 28898 * Creates rowsRenderCalculator and columnsRenderCalculator (before draw, to determine what rows and 28899 * cols should be rendered) 28900 * 28901 * @param fastDraw {Boolean} If `true`, will try to avoid full redraw and only update the border positions. 28902 * If `false` or `undefined`, will perform a full redraw 28903 * @returns fastDraw {Boolean} The fastDraw value, possibly modified 28904 */ 28905 28906 }, { 28907 key: 'createRenderCalculators', 28908 value: function createRenderCalculators() { 28909 var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 28910 28911 if (fastDraw) { 28912 var proposedRowsVisibleCalculator = this.createRowsCalculator(true); 28913 var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true); 28914 28915 if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) { 28916 fastDraw = false; 28917 } 28918 } 28919 28920 if (!fastDraw) { 28921 this.rowsRenderCalculator = this.createRowsCalculator(); 28922 this.columnsRenderCalculator = this.createColumnsCalculator(); 28923 } 28924 // delete temporarily to make sure that renderers always use rowsRenderCalculator, not rowsVisibleCalculator 28925 this.rowsVisibleCalculator = null; 28926 this.columnsVisibleCalculator = null; 28927 28928 return fastDraw; 28929 } 28930 28931 /** 28932 * Creates rowsVisibleCalculator and columnsVisibleCalculator (after draw, to determine what are 28933 * the actually visible rows and columns) 28934 */ 28935 28936 }, { 28937 key: 'createVisibleCalculators', 28938 value: function createVisibleCalculators() { 28939 this.rowsVisibleCalculator = this.createRowsCalculator(true); 28940 this.columnsVisibleCalculator = this.createColumnsCalculator(true); 28941 } 28942 28943 /** 28944 * Returns information whether proposedRowsVisibleCalculator viewport 28945 * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator) 28946 * 28947 * @param {Object} proposedRowsVisibleCalculator 28948 * @returns {Boolean} Returns `true` if all proposed visible rows are already rendered (meaning: redraw is not needed). 28949 * Returns `false` if at least one proposed visible row is not already rendered (meaning: redraw is needed) 28950 */ 28951 28952 }, { 28953 key: 'areAllProposedVisibleRowsAlreadyRendered', 28954 value: function areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) { 28955 if (this.rowsVisibleCalculator) { 28956 if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0) { 28957 return false; 28958 } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1) { 28959 return false; 28960 } 28961 return true; 28962 } 28963 28964 return false; 28965 } 28966 28967 /** 28968 * Returns information whether proposedColumnsVisibleCalculator viewport 28969 * is contained inside column rendered in previous draw (cached in columnsRenderCalculator) 28970 * 28971 * @param {Object} proposedColumnsVisibleCalculator 28972 * @returns {Boolean} Returns `true` if all proposed visible columns are already rendered (meaning: redraw is not needed). 28973 * Returns `false` if at least one proposed visible column is not already rendered (meaning: redraw is needed) 28974 */ 28975 28976 }, { 28977 key: 'areAllProposedVisibleColumnsAlreadyRendered', 28978 value: function areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator) { 28979 if (this.columnsVisibleCalculator) { 28980 if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0) { 28981 return false; 28982 } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1) { 28983 return false; 28984 } 28985 return true; 28986 } 28987 28988 return false; 28989 } 28990 28991 /** 28992 * Resets values in keys of the hasOversizedColumnHeadersMarked object after updateSettings. 28993 */ 28994 28995 }, { 28996 key: 'resetHasOversizedColumnHeadersMarked', 28997 value: function resetHasOversizedColumnHeadersMarked() { 28998 (0, _object.objectEach)(this.hasOversizedColumnHeadersMarked, function (value, key, object) { 28999 object[key] = void 0; 29000 }); 29001 } 29002 }]); 29003 29004 return Viewport; 29005}(); 29006 29007exports.default = Viewport; 29008 29009/***/ }), 29010/* 263 */ 29011/***/ (function(module, exports, __webpack_require__) { 29012 29013"use strict"; 29014 29015 29016exports.__esModule = true; 29017 29018var _unicode = __webpack_require__(15); 29019 29020var _mixed = __webpack_require__(23); 29021 29022var _string = __webpack_require__(28); 29023 29024var _array = __webpack_require__(2); 29025 29026var _element = __webpack_require__(0); 29027 29028var _handsontableEditor = __webpack_require__(264); 29029 29030var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor); 29031 29032function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 29033 29034var AutocompleteEditor = _handsontableEditor2.default.prototype.extend(); 29035 29036/** 29037 * @private 29038 * @editor AutocompleteEditor 29039 * @class AutocompleteEditor 29040 * @dependencies HandsontableEditor 29041 */ 29042AutocompleteEditor.prototype.init = function () { 29043 _handsontableEditor2.default.prototype.init.apply(this, arguments); 29044 this.query = null; 29045 this.strippedChoices = []; 29046 this.rawChoices = []; 29047}; 29048 29049AutocompleteEditor.prototype.getValue = function () { 29050 var _this2 = this; 29051 29052 var selectedValue = this.rawChoices.find(function (value) { 29053 var strippedValue = _this2.stripValueIfNeeded(value); 29054 29055 return strippedValue === _this2.TEXTAREA.value; 29056 }); 29057 29058 if ((0, _mixed.isDefined)(selectedValue)) { 29059 return selectedValue; 29060 } 29061 29062 return this.TEXTAREA.value; 29063}; 29064 29065AutocompleteEditor.prototype.createElements = function () { 29066 _handsontableEditor2.default.prototype.createElements.apply(this, arguments); 29067 29068 (0, _element.addClass)(this.htContainer, 'autocompleteEditor'); 29069 (0, _element.addClass)(this.htContainer, window.navigator.platform.indexOf('Mac') === -1 ? '' : 'htMacScroll'); 29070}; 29071 29072var skipOne = false; 29073function onBeforeKeyDown(event) { 29074 skipOne = false; 29075 var editor = this.getActiveEditor(); 29076 29077 if ((0, _unicode.isPrintableChar)(event.keyCode) || event.keyCode === _unicode.KEY_CODES.BACKSPACE || event.keyCode === _unicode.KEY_CODES.DELETE || event.keyCode === _unicode.KEY_CODES.INSERT) { 29078 var timeOffset = 0; 29079 29080 // on ctl+c / cmd+c don't update suggestion list 29081 if (event.keyCode === _unicode.KEY_CODES.C && (event.ctrlKey || event.metaKey)) { 29082 return; 29083 } 29084 if (!editor.isOpened()) { 29085 timeOffset += 10; 29086 } 29087 29088 if (editor.htEditor) { 29089 editor.instance._registerTimeout(setTimeout(function () { 29090 editor.queryChoices(editor.TEXTAREA.value); 29091 skipOne = true; 29092 }, timeOffset)); 29093 } 29094 } 29095} 29096 29097AutocompleteEditor.prototype.prepare = function () { 29098 this.instance.addHook('beforeKeyDown', onBeforeKeyDown); 29099 _handsontableEditor2.default.prototype.prepare.apply(this, arguments); 29100}; 29101 29102AutocompleteEditor.prototype.open = function () { 29103 // Ugly fix for handsontable which grab window object for autocomplete scroll listener instead table element. 29104 this.TEXTAREA_PARENT.style.overflow = 'auto'; 29105 _handsontableEditor2.default.prototype.open.apply(this, arguments); 29106 this.TEXTAREA_PARENT.style.overflow = ''; 29107 29108 var choicesListHot = this.htEditor.getInstance(); 29109 var _this = this; 29110 var trimDropdown = this.cellProperties.trimDropdown === void 0 ? true : this.cellProperties.trimDropdown; 29111 29112 this.TEXTAREA.style.visibility = 'visible'; 29113 this.focus(); 29114 29115 choicesListHot.updateSettings({ 29116 colWidths: trimDropdown ? [(0, _element.outerWidth)(this.TEXTAREA) - 2] : void 0, 29117 width: trimDropdown ? (0, _element.outerWidth)(this.TEXTAREA) + (0, _element.getScrollbarWidth)() + 2 : void 0, 29118 afterRenderer: function afterRenderer(TD, row, col, prop, value, cellProperties) { 29119 var _this$cellProperties = _this.cellProperties, 29120 filteringCaseSensitive = _this$cellProperties.filteringCaseSensitive, 29121 allowHtml = _this$cellProperties.allowHtml; 29122 29123 var indexOfMatch = void 0; 29124 var match = void 0; 29125 29126 value = (0, _mixed.stringify)(value); 29127 29128 if (value && !allowHtml) { 29129 indexOfMatch = filteringCaseSensitive === true ? value.indexOf(this.query) : value.toLowerCase().indexOf(_this.query.toLowerCase()); 29130 29131 if (indexOfMatch !== -1) { 29132 match = value.substr(indexOfMatch, _this.query.length); 29133 value = value.replace(match, '<strong>' + match + '</strong>'); 29134 } 29135 } 29136 TD.innerHTML = value; 29137 }, 29138 29139 autoColumnSize: true, 29140 modifyColWidth: function modifyColWidth(width, col) { 29141 // workaround for <strong> text overlapping the dropdown, not really accurate 29142 var autoWidths = this.getPlugin('autoColumnSize').widths; 29143 29144 if (autoWidths[col]) { 29145 width = autoWidths[col]; 29146 } 29147 29148 return trimDropdown ? width : width + 15; 29149 } 29150 }); 29151 29152 // Add additional space for autocomplete holder 29153 this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = (0, _element.getScrollbarWidth)() + 2 + 'px'; 29154 29155 if (skipOne) { 29156 skipOne = false; 29157 } 29158 29159 _this.instance._registerTimeout(setTimeout(function () { 29160 _this.queryChoices(_this.TEXTAREA.value); 29161 }, 0)); 29162}; 29163 29164AutocompleteEditor.prototype.close = function () { 29165 _handsontableEditor2.default.prototype.close.apply(this, arguments); 29166}; 29167AutocompleteEditor.prototype.queryChoices = function (query) { 29168 var _this3 = this; 29169 29170 this.query = query; 29171 var source = this.cellProperties.source; 29172 29173 if (typeof source == 'function') { 29174 source.call(this.cellProperties, query, function (choices) { 29175 _this3.rawChoices = choices; 29176 _this3.updateChoicesList(_this3.stripValuesIfNeeded(choices)); 29177 }); 29178 } else if (Array.isArray(source)) { 29179 this.rawChoices = source; 29180 this.updateChoicesList(this.stripValuesIfNeeded(source)); 29181 } else { 29182 this.updateChoicesList([]); 29183 } 29184}; 29185 29186AutocompleteEditor.prototype.updateChoicesList = function (choices) { 29187 var pos = (0, _element.getCaretPosition)(this.TEXTAREA); 29188 var endPos = (0, _element.getSelectionEndPosition)(this.TEXTAREA); 29189 var sortByRelevanceSetting = this.cellProperties.sortByRelevance; 29190 var filterSetting = this.cellProperties.filter; 29191 var orderByRelevance = null; 29192 var highlightIndex = null; 29193 29194 if (sortByRelevanceSetting) { 29195 orderByRelevance = AutocompleteEditor.sortByRelevance(this.stripValueIfNeeded(this.getValue()), choices, this.cellProperties.filteringCaseSensitive); 29196 } 29197 var orderByRelevanceLength = Array.isArray(orderByRelevance) ? orderByRelevance.length : 0; 29198 29199 if (filterSetting === false) { 29200 if (orderByRelevanceLength) { 29201 highlightIndex = orderByRelevance[0]; 29202 } 29203 } else { 29204 var sorted = []; 29205 29206 for (var i = 0, choicesCount = choices.length; i < choicesCount; i++) { 29207 if (sortByRelevanceSetting && orderByRelevanceLength <= i) { 29208 break; 29209 } 29210 if (orderByRelevanceLength) { 29211 sorted.push(choices[orderByRelevance[i]]); 29212 } else { 29213 sorted.push(choices[i]); 29214 } 29215 } 29216 29217 highlightIndex = 0; 29218 choices = sorted; 29219 } 29220 29221 this.strippedChoices = choices; 29222 this.htEditor.loadData((0, _array.pivot)([choices])); 29223 29224 this.updateDropdownHeight(); 29225 29226 this.flipDropdownIfNeeded(); 29227 29228 if (this.cellProperties.strict === true) { 29229 this.highlightBestMatchingChoice(highlightIndex); 29230 } 29231 29232 this.instance.listen(); 29233 this.TEXTAREA.focus(); 29234 (0, _element.setCaretPosition)(this.TEXTAREA, pos, pos === endPos ? void 0 : endPos); 29235}; 29236 29237AutocompleteEditor.prototype.flipDropdownIfNeeded = function () { 29238 var textareaOffset = (0, _element.offset)(this.TEXTAREA); 29239 var textareaHeight = (0, _element.outerHeight)(this.TEXTAREA); 29240 var dropdownHeight = this.getDropdownHeight(); 29241 var trimmingContainer = (0, _element.getTrimmingContainer)(this.instance.view.wt.wtTable.TABLE); 29242 var trimmingContainerScrollTop = trimmingContainer.scrollTop; 29243 var headersHeight = (0, _element.outerHeight)(this.instance.view.wt.wtTable.THEAD); 29244 var containerOffset = { 29245 row: 0, 29246 col: 0 29247 }; 29248 29249 if (trimmingContainer !== window) { 29250 containerOffset = (0, _element.offset)(trimmingContainer); 29251 } 29252 29253 var spaceAbove = textareaOffset.top - containerOffset.top - headersHeight + trimmingContainerScrollTop; 29254 var spaceBelow = trimmingContainer.scrollHeight - spaceAbove - headersHeight - textareaHeight; 29255 var flipNeeded = dropdownHeight > spaceBelow && spaceAbove > spaceBelow; 29256 29257 if (flipNeeded) { 29258 this.flipDropdown(dropdownHeight); 29259 } else { 29260 this.unflipDropdown(); 29261 } 29262 29263 this.limitDropdownIfNeeded(flipNeeded ? spaceAbove : spaceBelow, dropdownHeight); 29264 29265 return flipNeeded; 29266}; 29267 29268AutocompleteEditor.prototype.limitDropdownIfNeeded = function (spaceAvailable, dropdownHeight) { 29269 if (dropdownHeight > spaceAvailable) { 29270 var tempHeight = 0; 29271 var i = 0; 29272 var lastRowHeight = 0; 29273 var height = null; 29274 29275 do { 29276 lastRowHeight = this.htEditor.getRowHeight(i) || this.htEditor.view.wt.wtSettings.settings.defaultRowHeight; 29277 tempHeight += lastRowHeight; 29278 i++; 29279 } while (tempHeight < spaceAvailable); 29280 29281 height = tempHeight - lastRowHeight; 29282 29283 if (this.htEditor.flipped) { 29284 this.htEditor.rootElement.style.top = parseInt(this.htEditor.rootElement.style.top, 10) + dropdownHeight - height + 'px'; 29285 } 29286 29287 this.setDropdownHeight(tempHeight - lastRowHeight); 29288 } 29289}; 29290 29291AutocompleteEditor.prototype.flipDropdown = function (dropdownHeight) { 29292 var dropdownStyle = this.htEditor.rootElement.style; 29293 29294 dropdownStyle.position = 'absolute'; 29295 dropdownStyle.top = -dropdownHeight + 'px'; 29296 29297 this.htEditor.flipped = true; 29298}; 29299 29300AutocompleteEditor.prototype.unflipDropdown = function () { 29301 var dropdownStyle = this.htEditor.rootElement.style; 29302 29303 if (dropdownStyle.position === 'absolute') { 29304 dropdownStyle.position = ''; 29305 dropdownStyle.top = ''; 29306 } 29307 29308 this.htEditor.flipped = void 0; 29309}; 29310 29311AutocompleteEditor.prototype.updateDropdownHeight = function () { 29312 var currentDropdownWidth = this.htEditor.getColWidth(0) + (0, _element.getScrollbarWidth)() + 2; 29313 var trimDropdown = this.cellProperties.trimDropdown; 29314 29315 this.htEditor.updateSettings({ 29316 height: this.getDropdownHeight(), 29317 width: trimDropdown ? void 0 : currentDropdownWidth 29318 }); 29319 29320 this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer(); 29321}; 29322 29323AutocompleteEditor.prototype.setDropdownHeight = function (height) { 29324 this.htEditor.updateSettings({ 29325 height: height 29326 }); 29327}; 29328 29329AutocompleteEditor.prototype.finishEditing = function (restoreOriginalValue) { 29330 if (!restoreOriginalValue) { 29331 this.instance.removeHook('beforeKeyDown', onBeforeKeyDown); 29332 } 29333 _handsontableEditor2.default.prototype.finishEditing.apply(this, arguments); 29334}; 29335 29336AutocompleteEditor.prototype.highlightBestMatchingChoice = function (index) { 29337 if (typeof index === 'number') { 29338 this.htEditor.selectCell(index, 0); 29339 } else { 29340 this.htEditor.deselectCell(); 29341 } 29342}; 29343 29344/** 29345 * Filters and sorts by relevance 29346 * @param value 29347 * @param choices 29348 * @param caseSensitive 29349 * @returns {Array} array of indexes in original choices array 29350 */ 29351AutocompleteEditor.sortByRelevance = function (value, choices, caseSensitive) { 29352 var choicesRelevance = []; 29353 var currentItem = void 0; 29354 var valueLength = value.length; 29355 var valueIndex = void 0; 29356 var charsLeft = void 0; 29357 var result = []; 29358 var i = void 0; 29359 var choicesCount = choices.length; 29360 29361 if (valueLength === 0) { 29362 for (i = 0; i < choicesCount; i++) { 29363 result.push(i); 29364 } 29365 return result; 29366 } 29367 29368 for (i = 0; i < choicesCount; i++) { 29369 currentItem = (0, _string.stripTags)((0, _mixed.stringify)(choices[i])); 29370 29371 if (caseSensitive) { 29372 valueIndex = currentItem.indexOf(value); 29373 } else { 29374 valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase()); 29375 } 29376 29377 if (valueIndex !== -1) { 29378 charsLeft = currentItem.length - valueIndex - valueLength; 29379 29380 choicesRelevance.push({ 29381 baseIndex: i, 29382 index: valueIndex, 29383 charsLeft: charsLeft, 29384 value: currentItem 29385 }); 29386 } 29387 } 29388 29389 choicesRelevance.sort(function (a, b) { 29390 29391 if (b.index === -1) { 29392 return -1; 29393 } 29394 if (a.index === -1) { 29395 return 1; 29396 } 29397 29398 if (a.index < b.index) { 29399 return -1; 29400 } else if (b.index < a.index) { 29401 return 1; 29402 } else if (a.index === b.index) { 29403 if (a.charsLeft < b.charsLeft) { 29404 return -1; 29405 } else if (a.charsLeft > b.charsLeft) { 29406 return 1; 29407 } 29408 } 29409 29410 return 0; 29411 }); 29412 29413 for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) { 29414 result.push(choicesRelevance[i].baseIndex); 29415 } 29416 29417 return result; 29418}; 29419 29420AutocompleteEditor.prototype.getDropdownHeight = function () { 29421 var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23; 29422 var visibleRows = this.cellProperties.visibleRows; 29423 29424 return this.strippedChoices.length >= visibleRows ? visibleRows * firstRowHeight : this.strippedChoices.length * firstRowHeight + 8; 29425}; 29426 29427AutocompleteEditor.prototype.stripValueIfNeeded = function (value) { 29428 return this.stripValuesIfNeeded([value])[0]; 29429}; 29430 29431AutocompleteEditor.prototype.stripValuesIfNeeded = function (values) { 29432 var allowHtml = this.cellProperties.allowHtml; 29433 29434 29435 var stringifiedValues = (0, _array.arrayMap)(values, function (value) { 29436 return (0, _mixed.stringify)(value); 29437 }); 29438 var strippedValues = (0, _array.arrayMap)(stringifiedValues, function (value) { 29439 return allowHtml ? value : (0, _string.stripTags)(value); 29440 }); 29441 29442 return strippedValues; 29443}; 29444 29445AutocompleteEditor.prototype.allowKeyEventPropagation = function (keyCode) { 29446 var selected = { row: this.htEditor.getSelectedRange() ? this.htEditor.getSelectedRange().from.row : -1 }; 29447 var allowed = false; 29448 29449 if (keyCode === _unicode.KEY_CODES.ARROW_DOWN && selected.row > 0 && selected.row < this.htEditor.countRows() - 1) { 29450 allowed = true; 29451 } 29452 if (keyCode === _unicode.KEY_CODES.ARROW_UP && selected.row > -1) { 29453 allowed = true; 29454 } 29455 29456 return allowed; 29457}; 29458 29459AutocompleteEditor.prototype.discardEditor = function (result) { 29460 _handsontableEditor2.default.prototype.discardEditor.apply(this, arguments); 29461 29462 this.instance.view.render(); 29463}; 29464 29465exports.default = AutocompleteEditor; 29466 29467/***/ }), 29468/* 264 */ 29469/***/ (function(module, exports, __webpack_require__) { 29470 29471"use strict"; 29472 29473 29474exports.__esModule = true; 29475 29476var _unicode = __webpack_require__(15); 29477 29478var _object = __webpack_require__(3); 29479 29480var _element = __webpack_require__(0); 29481 29482var _event = __webpack_require__(7); 29483 29484var _textEditor = __webpack_require__(44); 29485 29486var _textEditor2 = _interopRequireDefault(_textEditor); 29487 29488function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 29489 29490var HandsontableEditor = _textEditor2.default.prototype.extend(); 29491 29492/** 29493 * @private 29494 * @editor HandsontableEditor 29495 * @class HandsontableEditor 29496 * @dependencies TextEditor 29497 */ 29498HandsontableEditor.prototype.createElements = function () { 29499 _textEditor2.default.prototype.createElements.apply(this, arguments); 29500 29501 var DIV = document.createElement('DIV'); 29502 DIV.className = 'handsontableEditor'; 29503 this.TEXTAREA_PARENT.appendChild(DIV); 29504 29505 this.htContainer = DIV; 29506 this.assignHooks(); 29507}; 29508 29509HandsontableEditor.prototype.prepare = function (td, row, col, prop, value, cellProperties) { 29510 _textEditor2.default.prototype.prepare.apply(this, arguments); 29511 29512 var parent = this; 29513 var options = { 29514 startRows: 0, 29515 startCols: 0, 29516 minRows: 0, 29517 minCols: 0, 29518 className: 'listbox', 29519 copyPaste: false, 29520 autoColumnSize: false, 29521 autoRowSize: false, 29522 readOnly: true, 29523 fillHandle: false, 29524 afterOnCellMouseDown: function afterOnCellMouseDown(_, coords) { 29525 var value = this.getSourceData(coords.row, coords.col); 29526 29527 // if the value is undefined then it means we don't want to set the value 29528 if (value !== void 0) { 29529 parent.setValue(value); 29530 } 29531 parent.instance.destroyEditor(); 29532 } 29533 }; 29534 29535 if (this.cellProperties.handsontable) { 29536 (0, _object.extend)(options, cellProperties.handsontable); 29537 } 29538 this.htOptions = options; 29539}; 29540 29541var onBeforeKeyDown = function onBeforeKeyDown(event) { 29542 if ((0, _event.isImmediatePropagationStopped)(event)) { 29543 return; 29544 } 29545 var editor = this.getActiveEditor(); 29546 29547 var innerHOT = editor.htEditor.getInstance(); 29548 29549 var rowToSelect; 29550 var selectedRow; 29551 29552 if (event.keyCode == _unicode.KEY_CODES.ARROW_DOWN) { 29553 if (!innerHOT.getSelected() && !innerHOT.flipped) { 29554 rowToSelect = 0; 29555 } else if (innerHOT.getSelected()) { 29556 if (innerHOT.flipped) { 29557 rowToSelect = innerHOT.getSelected()[0] + 1; 29558 } else if (!innerHOT.flipped) { 29559 selectedRow = innerHOT.getSelected()[0]; 29560 var lastRow = innerHOT.countRows() - 1; 29561 rowToSelect = Math.min(lastRow, selectedRow + 1); 29562 } 29563 } 29564 } else if (event.keyCode == _unicode.KEY_CODES.ARROW_UP) { 29565 if (!innerHOT.getSelected() && innerHOT.flipped) { 29566 rowToSelect = innerHOT.countRows() - 1; 29567 } else if (innerHOT.getSelected()) { 29568 if (innerHOT.flipped) { 29569 selectedRow = innerHOT.getSelected()[0]; 29570 rowToSelect = Math.max(0, selectedRow - 1); 29571 } else { 29572 selectedRow = innerHOT.getSelected()[0]; 29573 rowToSelect = selectedRow - 1; 29574 } 29575 } 29576 } 29577 29578 if (rowToSelect !== void 0) { 29579 if (rowToSelect < 0 || innerHOT.flipped && rowToSelect > innerHOT.countRows() - 1) { 29580 innerHOT.deselectCell(); 29581 } else { 29582 innerHOT.selectCell(rowToSelect, 0); 29583 } 29584 if (innerHOT.getData().length) { 29585 event.preventDefault(); 29586 (0, _event.stopImmediatePropagation)(event); 29587 29588 editor.instance.listen(); 29589 editor.TEXTAREA.focus(); 29590 } 29591 } 29592}; 29593 29594HandsontableEditor.prototype.open = function () { 29595 this.instance.addHook('beforeKeyDown', onBeforeKeyDown); 29596 29597 _textEditor2.default.prototype.open.apply(this, arguments); 29598 29599 if (this.htEditor) { 29600 this.htEditor.destroy(); 29601 } 29602 // Construct and initialise a new Handsontable 29603 this.htEditor = new this.instance.constructor(this.htContainer, this.htOptions); 29604 this.htEditor.init(); 29605 29606 if (this.cellProperties.strict) { 29607 this.htEditor.selectCell(0, 0); 29608 this.TEXTAREA.style.visibility = 'hidden'; 29609 } else { 29610 this.htEditor.deselectCell(); 29611 this.TEXTAREA.style.visibility = 'visible'; 29612 } 29613 29614 (0, _element.setCaretPosition)(this.TEXTAREA, 0, this.TEXTAREA.value.length); 29615}; 29616 29617HandsontableEditor.prototype.close = function () { 29618 this.instance.removeHook('beforeKeyDown', onBeforeKeyDown); 29619 this.instance.listen(); 29620 29621 _textEditor2.default.prototype.close.apply(this, arguments); 29622}; 29623 29624HandsontableEditor.prototype.focus = function () { 29625 this.instance.listen(); 29626 _textEditor2.default.prototype.focus.apply(this, arguments); 29627}; 29628 29629HandsontableEditor.prototype.beginEditing = function (initialValue) { 29630 var onBeginEditing = this.instance.getSettings().onBeginEditing; 29631 29632 if (onBeginEditing && onBeginEditing() === false) { 29633 return; 29634 } 29635 _textEditor2.default.prototype.beginEditing.apply(this, arguments); 29636}; 29637 29638HandsontableEditor.prototype.finishEditing = function (isCancelled, ctrlDown) { 29639 if (this.htEditor && this.htEditor.isListening()) { 29640 // if focus is still in the HOT editor 29641 29642 this.instance.listen(); // return the focus to the parent HOT instance 29643 } 29644 29645 if (this.htEditor && this.htEditor.getSelected()) { 29646 var value = this.htEditor.getInstance().getValue(); 29647 29648 if (value !== void 0) { 29649 // if the value is undefined then it means we don't want to set the value 29650 this.setValue(value); 29651 } 29652 } 29653 29654 return _textEditor2.default.prototype.finishEditing.apply(this, arguments); 29655}; 29656 29657HandsontableEditor.prototype.assignHooks = function () { 29658 var _this = this; 29659 29660 this.instance.addHook('afterDestroy', function () { 29661 if (_this.htEditor) { 29662 _this.htEditor.destroy(); 29663 } 29664 }); 29665}; 29666 29667exports.default = HandsontableEditor; 29668 29669/***/ }), 29670/* 265 */ 29671/***/ (function(module, exports, __webpack_require__) { 29672 29673"use strict"; 29674 29675 29676exports.__esModule = true; 29677 29678var _array = __webpack_require__(2); 29679 29680var _object = __webpack_require__(3); 29681 29682var _number = __webpack_require__(5); 29683 29684var MIXIN_NAME = 'arrayMapper'; 29685 29686/** 29687 * @type {Object} 29688 */ 29689var arrayMapper = { 29690 _arrayMap: [], 29691 29692 /** 29693 * Get value by map index. 29694 * 29695 * @param {Number} index Array index. 29696 * @return {*} Returns value mapped to passed index. 29697 */ 29698 getValueByIndex: function getValueByIndex(index) { 29699 var value = void 0; 29700 29701 // eslint-disable-next-line no-cond-assign, no-return-assign 29702 return (value = this._arrayMap[index]) === void 0 ? null : value; 29703 }, 29704 29705 29706 /** 29707 * Get map index by its value. 29708 * 29709 * @param {*} value Value to search. 29710 * @returns {Number} Returns array index. 29711 */ 29712 getIndexByValue: function getIndexByValue(value) { 29713 var index = void 0; 29714 29715 // eslint-disable-next-line no-cond-assign, no-return-assign 29716 return (index = this._arrayMap.indexOf(value)) === -1 ? null : index; 29717 }, 29718 29719 29720 /** 29721 * Insert new items to array mapper starting at passed index. New entries will be a continuation of last value in the array. 29722 * 29723 * @param {Number} index Array index. 29724 * @param {Number} [amount=1] Defines how many items will be created to an array. 29725 * @returns {Array} Returns added items. 29726 */ 29727 insertItems: function insertItems(index) { 29728 var _this = this; 29729 29730 var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; 29731 29732 var newIndex = (0, _array.arrayMax)(this._arrayMap) + 1; 29733 var addedItems = []; 29734 29735 (0, _number.rangeEach)(amount - 1, function (count) { 29736 addedItems.push(_this._arrayMap.splice(index + count, 0, newIndex + count)); 29737 }); 29738 29739 return addedItems; 29740 }, 29741 29742 29743 /** 29744 * Remove items from array mapper. 29745 * 29746 * @param {Number} index Array index. 29747 * @param {Number} [amount=1] Defines how many items will be created to an array. 29748 * @returns {Array} Returns removed items. 29749 */ 29750 removeItems: function removeItems(index) { 29751 var _this2 = this; 29752 29753 var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; 29754 29755 var removedItems = []; 29756 29757 if (Array.isArray(index)) { 29758 var mapCopy = [].concat(this._arrayMap); 29759 29760 // Sort descending 29761 index.sort(function (a, b) { 29762 return b - a; 29763 }); 29764 29765 removedItems = (0, _array.arrayReduce)(index, function (acc, item) { 29766 _this2._arrayMap.splice(item, 1); 29767 29768 return acc.concat(mapCopy.slice(item, item + 1)); 29769 }, []); 29770 } else { 29771 removedItems = this._arrayMap.splice(index, amount); 29772 } 29773 29774 return removedItems; 29775 }, 29776 29777 29778 /** 29779 * Unshift items (remove and shift chunk of array to the left). 29780 * 29781 * @param {Number|Array} index Array index or Array of indexes to unshift. 29782 * @param {Number} [amount=1] Defines how many items will be removed from an array (when index is passed as number). 29783 */ 29784 unshiftItems: function unshiftItems(index) { 29785 var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; 29786 29787 var removedItems = this.removeItems(index, amount); 29788 29789 function countRowShift(logicalRow) { 29790 // Todo: compare perf between reduce vs sort->each->brake 29791 return (0, _array.arrayReduce)(removedItems, function (count, removedLogicalRow) { 29792 if (logicalRow > removedLogicalRow) { 29793 count++; 29794 } 29795 29796 return count; 29797 }, 0); 29798 } 29799 29800 this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (logicalRow, physicalRow) { 29801 var rowShift = countRowShift(logicalRow); 29802 29803 if (rowShift) { 29804 logicalRow -= rowShift; 29805 } 29806 29807 return logicalRow; 29808 }); 29809 }, 29810 29811 29812 /** 29813 * Shift (right shifting) items starting at passed index. 29814 * 29815 * @param {Number} index Array index. 29816 * @param {Number} [amount=1] Defines how many items will be created to an array. 29817 */ 29818 shiftItems: function shiftItems(index) { 29819 var _this3 = this; 29820 29821 var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; 29822 29823 this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (row) { 29824 if (row >= index) { 29825 row += amount; 29826 } 29827 29828 return row; 29829 }); 29830 29831 (0, _number.rangeEach)(amount - 1, function (count) { 29832 _this3._arrayMap.splice(index + count, 0, index + count); 29833 }); 29834 }, 29835 29836 29837 /** 29838 * Clear all stored index<->value information from an array. 29839 */ 29840 clearMap: function clearMap() { 29841 this._arrayMap.length = 0; 29842 } 29843}; 29844 29845(0, _object.defineGetter)(arrayMapper, 'MIXIN_NAME', MIXIN_NAME, { 29846 writable: false, 29847 enumerable: false 29848}); 29849 29850exports.default = arrayMapper; 29851 29852/***/ }), 29853/* 266 */ 29854/***/ (function(module, exports, __webpack_require__) { 29855 29856"use strict"; 29857 29858 29859exports.__esModule = true; 29860 29861var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 29862 29863var _number = __webpack_require__(5); 29864 29865function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 29866 29867var STATE_INITIALIZED = 0; 29868var STATE_BUILT = 1; 29869var STATE_APPENDED = 2; 29870var UNIT = 'px'; 29871 29872/** 29873 * @class 29874 * @private 29875 */ 29876 29877var BaseUI = function () { 29878 function BaseUI(hotInstance) { 29879 _classCallCheck(this, BaseUI); 29880 29881 /** 29882 * Instance of Handsontable. 29883 * 29884 * @type {Core} 29885 */ 29886 this.hot = hotInstance; 29887 /** 29888 * DOM element representing the ui element. 29889 * 29890 * @type {HTMLElement} 29891 * @private 29892 */ 29893 this._element = null; 29894 /** 29895 * Flag which determines build state of element. 29896 * 29897 * @type {Boolean} 29898 */ 29899 this.state = STATE_INITIALIZED; 29900 } 29901 29902 /** 29903 * Add created UI elements to table. 29904 * 29905 * @param {HTMLElement} wrapper Element which are parent for our UI element. 29906 */ 29907 29908 29909 _createClass(BaseUI, [{ 29910 key: 'appendTo', 29911 value: function appendTo(wrapper) { 29912 wrapper.appendChild(this._element); 29913 29914 this.state = STATE_APPENDED; 29915 } 29916 29917 /** 29918 * Method for create UI element. Only create, without append to table. 29919 */ 29920 29921 }, { 29922 key: 'build', 29923 value: function build() { 29924 this._element = document.createElement('div'); 29925 this.state = STATE_BUILT; 29926 } 29927 29928 /** 29929 * Method for remove UI element. 29930 */ 29931 29932 }, { 29933 key: 'destroy', 29934 value: function destroy() { 29935 if (this.isAppended()) { 29936 this._element.parentElement.removeChild(this._element); 29937 } 29938 29939 this._element = null; 29940 this.state = STATE_INITIALIZED; 29941 } 29942 29943 /** 29944 * Check if UI element are appended. 29945 * 29946 * @returns {Boolean} 29947 */ 29948 29949 }, { 29950 key: 'isAppended', 29951 value: function isAppended() { 29952 return this.state === STATE_APPENDED; 29953 } 29954 29955 /** 29956 * Check if UI element are built. 29957 * 29958 * @returns {Boolean} 29959 */ 29960 29961 }, { 29962 key: 'isBuilt', 29963 value: function isBuilt() { 29964 return this.state >= STATE_BUILT; 29965 } 29966 29967 /** 29968 * Setter for position. 29969 * 29970 * @param {Number} top New top position of the element. 29971 * @param {Number} left New left position of the element. 29972 */ 29973 29974 }, { 29975 key: 'setPosition', 29976 value: function setPosition(top, left) { 29977 if ((0, _number.isNumeric)(top)) { 29978 this._element.style.top = top + UNIT; 29979 } 29980 if ((0, _number.isNumeric)(left)) { 29981 this._element.style.left = left + UNIT; 29982 } 29983 } 29984 29985 /** 29986 * Getter for the element position. 29987 * 29988 * @returns {Object} Object contains left and top position of the element. 29989 */ 29990 29991 }, { 29992 key: 'getPosition', 29993 value: function getPosition() { 29994 return { 29995 top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0, 29996 left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0 29997 }; 29998 } 29999 30000 /** 30001 * Setter for the element size. 30002 * 30003 * @param {Number} width New width of the element. 30004 * @param {Number} height New height of the element. 30005 */ 30006 30007 }, { 30008 key: 'setSize', 30009 value: function setSize(width, height) { 30010 if ((0, _number.isNumeric)(width)) { 30011 this._element.style.width = width + UNIT; 30012 } 30013 if ((0, _number.isNumeric)(height)) { 30014 this._element.style.height = height + UNIT; 30015 } 30016 } 30017 30018 /** 30019 * Getter for the element position. 30020 * 30021 * @returns {Object} Object contains height and width of the element. 30022 */ 30023 30024 }, { 30025 key: 'getSize', 30026 value: function getSize() { 30027 return { 30028 width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0, 30029 height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0 30030 }; 30031 } 30032 30033 /** 30034 * Setter for the element offset. Offset means marginTop and marginLeft of the element. 30035 * 30036 * @param {Number} top New margin top of the element. 30037 * @param {Number} left New margin left of the element. 30038 */ 30039 30040 }, { 30041 key: 'setOffset', 30042 value: function setOffset(top, left) { 30043 if ((0, _number.isNumeric)(top)) { 30044 this._element.style.marginTop = top + UNIT; 30045 } 30046 if ((0, _number.isNumeric)(left)) { 30047 this._element.style.marginLeft = left + UNIT; 30048 } 30049 } 30050 30051 /** 30052 * Getter for the element offset. 30053 * 30054 * @returns {Object} Object contains top and left offset of the element. 30055 */ 30056 30057 }, { 30058 key: 'getOffset', 30059 value: function getOffset() { 30060 return { 30061 top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0, 30062 left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0 30063 }; 30064 } 30065 }]); 30066 30067 return BaseUI; 30068}(); 30069 30070exports.default = BaseUI; 30071 30072/***/ }), 30073/* 267 */ 30074/***/ (function(module, exports, __webpack_require__) { 30075 30076"use strict"; 30077 30078 30079exports.__esModule = true; 30080 30081var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 30082 30083function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 30084 30085var STATE_INITIALIZED = 0; 30086var STATE_BUILT = 1; 30087var STATE_APPENDED = 2; 30088var UNIT = 'px'; 30089 30090/** 30091 * @class 30092 * @private 30093 */ 30094 30095var BaseUI = function () { 30096 function BaseUI(hotInstance) { 30097 _classCallCheck(this, BaseUI); 30098 30099 /** 30100 * Instance of Handsontable. 30101 * 30102 * @type {Core} 30103 */ 30104 this.hot = hotInstance; 30105 /** 30106 * DOM element representing the ui element. 30107 * 30108 * @type {HTMLElement} 30109 * @private 30110 */ 30111 this._element = null; 30112 /** 30113 * Flag which determines build state of element. 30114 * 30115 * @type {Boolean} 30116 */ 30117 this.state = STATE_INITIALIZED; 30118 } 30119 30120 /** 30121 * Add created UI elements to table. 30122 * 30123 * @param {HTMLElement} wrapper Element which are parent for our UI element. 30124 */ 30125 30126 30127 _createClass(BaseUI, [{ 30128 key: 'appendTo', 30129 value: function appendTo(wrapper) { 30130 wrapper.appendChild(this._element); 30131 30132 this.state = STATE_APPENDED; 30133 } 30134 30135 /** 30136 * Method for create UI element. Only create, without append to table. 30137 */ 30138 30139 }, { 30140 key: 'build', 30141 value: function build() { 30142 this._element = document.createElement('div'); 30143 this.state = STATE_BUILT; 30144 } 30145 30146 /** 30147 * Method for remove UI element. 30148 */ 30149 30150 }, { 30151 key: 'destroy', 30152 value: function destroy() { 30153 if (this.isAppended()) { 30154 this._element.parentElement.removeChild(this._element); 30155 } 30156 30157 this._element = null; 30158 this.state = STATE_INITIALIZED; 30159 } 30160 30161 /** 30162 * Check if UI element are appended. 30163 * 30164 * @returns {Boolean} 30165 */ 30166 30167 }, { 30168 key: 'isAppended', 30169 value: function isAppended() { 30170 return this.state === STATE_APPENDED; 30171 } 30172 30173 /** 30174 * Check if UI element are built. 30175 * 30176 * @returns {Boolean} 30177 */ 30178 30179 }, { 30180 key: 'isBuilt', 30181 value: function isBuilt() { 30182 return this.state >= STATE_BUILT; 30183 } 30184 30185 /** 30186 * Setter for position. 30187 * 30188 * @param {Number} top New top position of the element. 30189 * @param {Number} left New left position of the element. 30190 */ 30191 30192 }, { 30193 key: 'setPosition', 30194 value: function setPosition(top, left) { 30195 if (top) { 30196 this._element.style.top = top + UNIT; 30197 } 30198 if (left) { 30199 this._element.style.left = left + UNIT; 30200 } 30201 } 30202 30203 /** 30204 * Getter for the element position. 30205 * 30206 * @returns {Object} Object contains left and top position of the element. 30207 */ 30208 30209 }, { 30210 key: 'getPosition', 30211 value: function getPosition() { 30212 return { 30213 top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0, 30214 left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0 30215 }; 30216 } 30217 30218 /** 30219 * Setter for the element size. 30220 * 30221 * @param {Number} width New width of the element. 30222 * @param {Number} height New height of the element. 30223 */ 30224 30225 }, { 30226 key: 'setSize', 30227 value: function setSize(width, height) { 30228 if (width) { 30229 this._element.style.width = width + UNIT; 30230 } 30231 if (height) { 30232 this._element.style.height = height + UNIT; 30233 } 30234 } 30235 30236 /** 30237 * Getter for the element position. 30238 * 30239 * @returns {Object} Object contains height and width of the element. 30240 */ 30241 30242 }, { 30243 key: 'getSize', 30244 value: function getSize() { 30245 return { 30246 width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0, 30247 height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0 30248 }; 30249 } 30250 30251 /** 30252 * Setter for the element offset. Offset means marginTop and marginLeft of the element. 30253 * 30254 * @param {Number} top New margin top of the element. 30255 * @param {Number} left New margin left of the element. 30256 */ 30257 30258 }, { 30259 key: 'setOffset', 30260 value: function setOffset(top, left) { 30261 if (top) { 30262 this._element.style.marginTop = top + UNIT; 30263 } 30264 if (left) { 30265 this._element.style.marginLeft = left + UNIT; 30266 } 30267 } 30268 30269 /** 30270 * Getter for the element offset. 30271 * 30272 * @returns {Object} Object contains top and left offset of the element. 30273 */ 30274 30275 }, { 30276 key: 'getOffset', 30277 value: function getOffset() { 30278 return { 30279 top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0, 30280 left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0 30281 }; 30282 } 30283 }]); 30284 30285 return BaseUI; 30286}(); 30287 30288exports.default = BaseUI; 30289 30290/***/ }), 30291/* 268 */ 30292/***/ (function(module, exports, __webpack_require__) { 30293 30294"use strict"; 30295 30296 30297exports.__esModule = true; 30298exports.RecordTranslator = undefined; 30299 30300var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 30301 30302exports.registerIdentity = registerIdentity; 30303exports.getTranslator = getTranslator; 30304 30305var _core = __webpack_require__(66); 30306 30307var _core2 = _interopRequireDefault(_core); 30308 30309var _object = __webpack_require__(3); 30310 30311function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 30312 30313function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 30314 30315/** 30316 * @class RecordTranslator 30317 * @util 30318 */ 30319var RecordTranslator = function () { 30320 function RecordTranslator(hot) { 30321 _classCallCheck(this, RecordTranslator); 30322 30323 this.hot = hot; 30324 } 30325 30326 /** 30327 * Translate physical row index into visual. 30328 * 30329 * @param {Number} row Physical row index. 30330 * @returns {Number} Returns visual row index. 30331 */ 30332 30333 30334 _createClass(RecordTranslator, [{ 30335 key: 'toVisualRow', 30336 value: function toVisualRow(row) { 30337 return this.hot.runHooks('unmodifyRow', row); 30338 } 30339 30340 /** 30341 * Translate physical column index into visual. 30342 * 30343 * @param {Number} column Physical column index. 30344 * @returns {Number} Returns visual column index. 30345 */ 30346 30347 }, { 30348 key: 'toVisualColumn', 30349 value: function toVisualColumn(column) { 30350 return this.hot.runHooks('unmodifyCol', column); 30351 } 30352 30353 /** 30354 * Translate physical coordinates into visual. Can be passed as separate 2 arguments (row, column) or as an object in first 30355 * argument with `row` and `column` keys. 30356 * 30357 * @param {Number|Object} row Physical coordinates or row index. 30358 * @param {Number} [column] Physical column index. 30359 * @returns {Object|Array} Returns an object with visual records or an array if coordinates passed as separate arguments. 30360 */ 30361 30362 }, { 30363 key: 'toVisual', 30364 value: function toVisual(row, column) { 30365 var result = void 0; 30366 30367 if ((0, _object.isObject)(row)) { 30368 result = { 30369 row: this.toVisualRow(row.row), 30370 column: this.toVisualColumn(row.column) 30371 }; 30372 } else { 30373 result = [this.toVisualRow(row), this.toVisualColumn(column)]; 30374 } 30375 30376 return result; 30377 } 30378 30379 /** 30380 * Translate visual row index into physical. 30381 * 30382 * @param {Number} row Visual row index. 30383 * @returns {Number} Returns physical row index. 30384 */ 30385 30386 }, { 30387 key: 'toPhysicalRow', 30388 value: function toPhysicalRow(row) { 30389 return this.hot.runHooks('modifyRow', row); 30390 } 30391 30392 /** 30393 * Translate visual column index into physical. 30394 * 30395 * @param {Number} column Visual column index. 30396 * @returns {Number} Returns physical column index. 30397 */ 30398 30399 }, { 30400 key: 'toPhysicalColumn', 30401 value: function toPhysicalColumn(column) { 30402 return this.hot.runHooks('modifyCol', column); 30403 } 30404 30405 /** 30406 * Translate visual coordinates into physical. Can be passed as separate 2 arguments (row, column) or as an object in first 30407 * argument with `row` and `column` keys. 30408 * 30409 * @param {Number|Object} row Visual coordinates or row index. 30410 * @param {Number} [column] Visual column index. 30411 * @returns {Object|Array} Returns an object with physical records or an array if coordinates passed as separate arguments. 30412 */ 30413 30414 }, { 30415 key: 'toPhysical', 30416 value: function toPhysical(row, column) { 30417 var result = void 0; 30418 30419 if ((0, _object.isObject)(row)) { 30420 result = { 30421 row: this.toPhysicalRow(row.row), 30422 column: this.toPhysicalColumn(row.column) 30423 }; 30424 } else { 30425 result = [this.toPhysicalRow(row), this.toPhysicalColumn(column)]; 30426 } 30427 30428 return result; 30429 } 30430 }]); 30431 30432 return RecordTranslator; 30433}(); 30434 30435exports.RecordTranslator = RecordTranslator; 30436 30437 30438var identities = new WeakMap(); 30439var translatorSingletons = new WeakMap(); 30440 30441function registerIdentity(identity, hot) { 30442 identities.set(identity, hot); 30443} 30444 30445function getTranslator(identity) { 30446 var singleton = void 0; 30447 30448 if (!(identity instanceof _core2.default)) { 30449 if (!identities.has(identity)) { 30450 throw Error('Record translator was not registered for this object identity'); 30451 } 30452 identity = identities.get(identity); 30453 } 30454 if (translatorSingletons.has(identity)) { 30455 singleton = translatorSingletons.get(identity); 30456 } else { 30457 singleton = new RecordTranslator(identity); 30458 translatorSingletons.set(identity, singleton); 30459 } 30460 30461 return singleton; 30462} 30463 30464/***/ }), 30465/* 269 */ 30466/***/ (function(module, exports, __webpack_require__) { 30467 30468"use strict"; 30469 30470 30471exports.__esModule = true; 30472 30473var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 30474 30475var _object = __webpack_require__(3); 30476 30477var _number = __webpack_require__(5); 30478 30479var _mixed = __webpack_require__(23); 30480 30481function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 30482 30483function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 30484 30485/** 30486 * @class SamplesGenerator 30487 * @util 30488 */ 30489var SamplesGenerator = function () { 30490 _createClass(SamplesGenerator, null, [{ 30491 key: 'SAMPLE_COUNT', 30492 30493 /** 30494 * Number of samples to take of each value length. 30495 * 30496 * @type {Number} 30497 */ 30498 get: function get() { 30499 return 3; 30500 } 30501 }]); 30502 30503 function SamplesGenerator(dataFactory) { 30504 _classCallCheck(this, SamplesGenerator); 30505 30506 /** 30507 * Samples prepared for calculations. 30508 * 30509 * @type {Map} 30510 * @default {null} 30511 */ 30512 this.samples = null; 30513 /** 30514 * Function which give the data to collect samples. 30515 * 30516 * @type {Function} 30517 */ 30518 this.dataFactory = dataFactory; 30519 /** 30520 * Custom number of samples to take of each value length. 30521 * 30522 * @type {Number} 30523 * @default {null} 30524 */ 30525 this.customSampleCount = null; 30526 /** 30527 * `true` if duplicate samples collection should be allowed, `false` otherwise. 30528 * 30529 * @type {Boolean} 30530 * @default {false} 30531 */ 30532 this.allowDuplicates = false; 30533 } 30534 30535 /** 30536 * Get the sample count for this instance. 30537 * 30538 * @returns {Number} 30539 */ 30540 30541 30542 _createClass(SamplesGenerator, [{ 30543 key: 'getSampleCount', 30544 value: function getSampleCount() { 30545 if (this.customSampleCount) { 30546 return this.customSampleCount; 30547 } 30548 return SamplesGenerator.SAMPLE_COUNT; 30549 } 30550 }, { 30551 key: 'setSampleCount', 30552 30553 30554 /** 30555 * Set the sample count. 30556 * 30557 * @param {Number} sampleCount Number of samples to be collected. 30558 */ 30559 value: function setSampleCount(sampleCount) { 30560 this.customSampleCount = sampleCount; 30561 } 30562 30563 /** 30564 * Set if the generator should accept duplicate values. 30565 * 30566 * @param {Boolean} allowDuplicates `true` to allow duplicate values. 30567 */ 30568 30569 }, { 30570 key: 'setAllowDuplicates', 30571 value: function setAllowDuplicates(allowDuplicates) { 30572 this.allowDuplicates = allowDuplicates; 30573 } 30574 30575 /** 30576 * Generate samples for row. You can control which area should be sampled by passing `rowRange` object and `colRange` object. 30577 * 30578 * @param {Object|Number} rowRange 30579 * @param {Object} colRange 30580 * @returns {Object} 30581 */ 30582 30583 }, { 30584 key: 'generateRowSamples', 30585 value: function generateRowSamples(rowRange, colRange) { 30586 return this.generateSamples('row', colRange, rowRange); 30587 } 30588 30589 /** 30590 * Generate samples for column. You can control which area should be sampled by passing `colRange` object and `rowRange` object. 30591 * 30592 * @param {Object} colRange Column index. 30593 * @param {Object} rowRange Column index. 30594 * @returns {Object} 30595 */ 30596 30597 }, { 30598 key: 'generateColumnSamples', 30599 value: function generateColumnSamples(colRange, rowRange) { 30600 return this.generateSamples('col', rowRange, colRange); 30601 } 30602 30603 /** 30604 * Generate collection of samples. 30605 * 30606 * @param {String} type Type to generate. Can be `col` or `row`. 30607 * @param {Object} range 30608 * @param {Object|Number} specifierRange 30609 * @returns {Map} 30610 */ 30611 30612 }, { 30613 key: 'generateSamples', 30614 value: function generateSamples(type, range, specifierRange) { 30615 var _this = this; 30616 30617 var samples = new Map(); 30618 30619 if (typeof specifierRange === 'number') { 30620 specifierRange = { from: specifierRange, to: specifierRange }; 30621 } 30622 (0, _number.rangeEach)(specifierRange.from, specifierRange.to, function (index) { 30623 var sample = _this.generateSample(type, range, index); 30624 30625 samples.set(index, sample); 30626 }); 30627 30628 return samples; 30629 } 30630 30631 /** 30632 * Generate sample for specified type (`row` or `col`). 30633 * 30634 * @param {String} type Samples type `row` or `col`. 30635 * @param {Object} range 30636 * @param {Number} specifierValue 30637 * @returns {Map} 30638 */ 30639 30640 }, { 30641 key: 'generateSample', 30642 value: function generateSample(type, range, specifierValue) { 30643 var _this2 = this; 30644 30645 var samples = new Map(); 30646 var sampledValues = []; 30647 var length = void 0; 30648 30649 (0, _number.rangeEach)(range.from, range.to, function (index) { 30650 var value = void 0; 30651 30652 if (type === 'row') { 30653 value = _this2.dataFactory(specifierValue, index); 30654 } else if (type === 'col') { 30655 value = _this2.dataFactory(index, specifierValue); 30656 } else { 30657 throw new Error('Unsupported sample type'); 30658 } 30659 30660 if ((0, _object.isObject)(value)) { 30661 length = Object.keys(value).length; 30662 } else if (Array.isArray(value)) { 30663 length = value.length; 30664 } else { 30665 length = (0, _mixed.stringify)(value).length; 30666 } 30667 30668 if (!samples.has(length)) { 30669 samples.set(length, { 30670 needed: _this2.getSampleCount(), 30671 strings: [] 30672 }); 30673 } 30674 var sample = samples.get(length); 30675 30676 if (sample.needed) { 30677 var duplicate = sampledValues.indexOf(value) > -1; 30678 30679 if (!duplicate || _this2.allowDuplicates) { 30680 var computedKey = type === 'row' ? 'col' : 'row'; 30681 30682 sample.strings.push(_defineProperty({ value: value }, computedKey, index)); 30683 sampledValues.push(value); 30684 sample.needed--; 30685 } 30686 } 30687 }); 30688 30689 return samples; 30690 } 30691 }]); 30692 30693 return SamplesGenerator; 30694}(); 30695 30696exports.default = SamplesGenerator; 30697 30698/***/ }), 30699/* 270 */ 30700/***/ (function(module, exports, __webpack_require__) { 30701 30702// false -> Array#indexOf 30703// true -> Array#includes 30704var toIObject = __webpack_require__(27); 30705var toLength = __webpack_require__(21); 30706var toAbsoluteIndex = __webpack_require__(63); 30707module.exports = function (IS_INCLUDES) { 30708 return function ($this, el, fromIndex) { 30709 var O = toIObject($this); 30710 var length = toLength(O.length); 30711 var index = toAbsoluteIndex(fromIndex, length); 30712 var value; 30713 // Array#includes uses SameValueZero equality algorithm 30714 // eslint-disable-next-line no-self-compare 30715 if (IS_INCLUDES && el != el) while (length > index) { 30716 value = O[index++]; 30717 // eslint-disable-next-line no-self-compare 30718 if (value != value) return true; 30719 // Array#indexOf ignores holes, Array#includes - not 30720 } else for (;length > index; index++) if (IS_INCLUDES || index in O) { 30721 if (O[index] === el) return IS_INCLUDES || index || 0; 30722 } return !IS_INCLUDES && -1; 30723 }; 30724}; 30725 30726 30727/***/ }), 30728/* 271 */ 30729/***/ (function(module, exports, __webpack_require__) { 30730 30731// getting tag from 19.1.3.6 Object.prototype.toString() 30732var cof = __webpack_require__(38); 30733var TAG = __webpack_require__(8)('toStringTag'); 30734// ES3 wrong here 30735var ARG = cof(function () { return arguments; }()) == 'Arguments'; 30736 30737// fallback for IE11 Script Access Denied error 30738var tryGet = function (it, key) { 30739 try { 30740 return it[key]; 30741 } catch (e) { /* empty */ } 30742}; 30743 30744module.exports = function (it) { 30745 var O, T, B; 30746 return it === undefined ? 'Undefined' : it === null ? 'Null' 30747 // @@toStringTag case 30748 : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T 30749 // builtinTag case 30750 : ARG ? cof(O) 30751 // ES3 arguments fallback 30752 : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; 30753}; 30754 30755 30756/***/ }), 30757/* 272 */ 30758/***/ (function(module, exports, __webpack_require__) { 30759 30760"use strict"; 30761 30762var dP = __webpack_require__(18).f; 30763var create = __webpack_require__(80); 30764var redefineAll = __webpack_require__(62); 30765var ctx = __webpack_require__(30); 30766var anInstance = __webpack_require__(55); 30767var forOf = __webpack_require__(59); 30768var $iterDefine = __webpack_require__(281); 30769var step = __webpack_require__(282); 30770var setSpecies = __webpack_require__(288); 30771var DESCRIPTORS = __webpack_require__(20); 30772var fastKey = __webpack_require__(47).fastKey; 30773var validate = __webpack_require__(41); 30774var SIZE = DESCRIPTORS ? '_s' : 'size'; 30775 30776var getEntry = function (that, key) { 30777 // fast case 30778 var index = fastKey(key); 30779 var entry; 30780 if (index !== 'F') return that._i[index]; 30781 // frozen object case 30782 for (entry = that._f; entry; entry = entry.n) { 30783 if (entry.k == key) return entry; 30784 } 30785}; 30786 30787module.exports = { 30788 getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { 30789 var C = wrapper(function (that, iterable) { 30790 anInstance(that, C, NAME, '_i'); 30791 that._t = NAME; // collection type 30792 that._i = create(null); // index 30793 that._f = undefined; // first entry 30794 that._l = undefined; // last entry 30795 that[SIZE] = 0; // size 30796 if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); 30797 }); 30798 redefineAll(C.prototype, { 30799 // 23.1.3.1 Map.prototype.clear() 30800 // 23.2.3.2 Set.prototype.clear() 30801 clear: function clear() { 30802 for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) { 30803 entry.r = true; 30804 if (entry.p) entry.p = entry.p.n = undefined; 30805 delete data[entry.i]; 30806 } 30807 that._f = that._l = undefined; 30808 that[SIZE] = 0; 30809 }, 30810 // 23.1.3.3 Map.prototype.delete(key) 30811 // 23.2.3.4 Set.prototype.delete(value) 30812 'delete': function (key) { 30813 var that = validate(this, NAME); 30814 var entry = getEntry(that, key); 30815 if (entry) { 30816 var next = entry.n; 30817 var prev = entry.p; 30818 delete that._i[entry.i]; 30819 entry.r = true; 30820 if (prev) prev.n = next; 30821 if (next) next.p = prev; 30822 if (that._f == entry) that._f = next; 30823 if (that._l == entry) that._l = prev; 30824 that[SIZE]--; 30825 } return !!entry; 30826 }, 30827 // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) 30828 // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) 30829 forEach: function forEach(callbackfn /* , that = undefined */) { 30830 validate(this, NAME); 30831 var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); 30832 var entry; 30833 while (entry = entry ? entry.n : this._f) { 30834 f(entry.v, entry.k, this); 30835 // revert to the last existing entry 30836 while (entry && entry.r) entry = entry.p; 30837 } 30838 }, 30839 // 23.1.3.7 Map.prototype.has(key) 30840 // 23.2.3.7 Set.prototype.has(value) 30841 has: function has(key) { 30842 return !!getEntry(validate(this, NAME), key); 30843 } 30844 }); 30845 if (DESCRIPTORS) dP(C.prototype, 'size', { 30846 get: function () { 30847 return validate(this, NAME)[SIZE]; 30848 } 30849 }); 30850 return C; 30851 }, 30852 def: function (that, key, value) { 30853 var entry = getEntry(that, key); 30854 var prev, index; 30855 // change existing entry 30856 if (entry) { 30857 entry.v = value; 30858 // create new entry 30859 } else { 30860 that._l = entry = { 30861 i: index = fastKey(key, true), // <- index 30862 k: key, // <- key 30863 v: value, // <- value 30864 p: prev = that._l, // <- previous entry 30865 n: undefined, // <- next entry 30866 r: false // <- removed 30867 }; 30868 if (!that._f) that._f = entry; 30869 if (prev) prev.n = entry; 30870 that[SIZE]++; 30871 // add to index 30872 if (index !== 'F') that._i[index] = entry; 30873 } return that; 30874 }, 30875 getEntry: getEntry, 30876 setStrong: function (C, NAME, IS_MAP) { 30877 // add .keys, .values, .entries, [@@iterator] 30878 // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 30879 $iterDefine(C, NAME, function (iterated, kind) { 30880 this._t = validate(iterated, NAME); // target 30881 this._k = kind; // kind 30882 this._l = undefined; // previous 30883 }, function () { 30884 var that = this; 30885 var kind = that._k; 30886 var entry = that._l; 30887 // revert to the last existing entry 30888 while (entry && entry.r) entry = entry.p; 30889 // get next entry 30890 if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) { 30891 // or finish the iteration 30892 that._t = undefined; 30893 return step(1); 30894 } 30895 // return step by kind 30896 if (kind == 'keys') return step(0, entry.k); 30897 if (kind == 'values') return step(0, entry.v); 30898 return step(0, [entry.k, entry.v]); 30899 }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); 30900 30901 // add [@@species], 23.1.2.2, 23.2.2.2 30902 setSpecies(NAME); 30903 } 30904}; 30905 30906 30907/***/ }), 30908/* 273 */ 30909/***/ (function(module, exports, __webpack_require__) { 30910 30911"use strict"; 30912 30913var redefineAll = __webpack_require__(62); 30914var getWeak = __webpack_require__(47).getWeak; 30915var anObject = __webpack_require__(17); 30916var isObject = __webpack_require__(12); 30917var anInstance = __webpack_require__(55); 30918var forOf = __webpack_require__(59); 30919var createArrayMethod = __webpack_require__(56); 30920var $has = __webpack_require__(26); 30921var validate = __webpack_require__(41); 30922var arrayFind = createArrayMethod(5); 30923var arrayFindIndex = createArrayMethod(6); 30924var id = 0; 30925 30926// fallback for uncaught frozen keys 30927var uncaughtFrozenStore = function (that) { 30928 return that._l || (that._l = new UncaughtFrozenStore()); 30929}; 30930var UncaughtFrozenStore = function () { 30931 this.a = []; 30932}; 30933var findUncaughtFrozen = function (store, key) { 30934 return arrayFind(store.a, function (it) { 30935 return it[0] === key; 30936 }); 30937}; 30938UncaughtFrozenStore.prototype = { 30939 get: function (key) { 30940 var entry = findUncaughtFrozen(this, key); 30941 if (entry) return entry[1]; 30942 }, 30943 has: function (key) { 30944 return !!findUncaughtFrozen(this, key); 30945 }, 30946 set: function (key, value) { 30947 var entry = findUncaughtFrozen(this, key); 30948 if (entry) entry[1] = value; 30949 else this.a.push([key, value]); 30950 }, 30951 'delete': function (key) { 30952 var index = arrayFindIndex(this.a, function (it) { 30953 return it[0] === key; 30954 }); 30955 if (~index) this.a.splice(index, 1); 30956 return !!~index; 30957 } 30958}; 30959 30960module.exports = { 30961 getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { 30962 var C = wrapper(function (that, iterable) { 30963 anInstance(that, C, NAME, '_i'); 30964 that._t = NAME; // collection type 30965 that._i = id++; // collection id 30966 that._l = undefined; // leak store for uncaught frozen objects 30967 if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); 30968 }); 30969 redefineAll(C.prototype, { 30970 // 23.3.3.2 WeakMap.prototype.delete(key) 30971 // 23.4.3.3 WeakSet.prototype.delete(value) 30972 'delete': function (key) { 30973 if (!isObject(key)) return false; 30974 var data = getWeak(key); 30975 if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key); 30976 return data && $has(data, this._i) && delete data[this._i]; 30977 }, 30978 // 23.3.3.4 WeakMap.prototype.has(key) 30979 // 23.4.3.4 WeakSet.prototype.has(value) 30980 has: function has(key) { 30981 if (!isObject(key)) return false; 30982 var data = getWeak(key); 30983 if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key); 30984 return data && $has(data, this._i); 30985 } 30986 }); 30987 return C; 30988 }, 30989 def: function (that, key, value) { 30990 var data = getWeak(anObject(key), true); 30991 if (data === true) uncaughtFrozenStore(that).set(key, value); 30992 else data[that._i] = value; 30993 return that; 30994 }, 30995 ufstore: uncaughtFrozenStore 30996}; 30997 30998 30999/***/ }), 31000/* 274 */ 31001/***/ (function(module, exports, __webpack_require__) { 31002 31003var document = __webpack_require__(10).document; 31004module.exports = document && document.documentElement; 31005 31006 31007/***/ }), 31008/* 275 */ 31009/***/ (function(module, exports, __webpack_require__) { 31010 31011module.exports = !__webpack_require__(20) && !__webpack_require__(25)(function () { 31012 return Object.defineProperty(__webpack_require__(75)('div'), 'a', { get: function () { return 7; } }).a != 7; 31013}); 31014 31015 31016/***/ }), 31017/* 276 */ 31018/***/ (function(module, exports, __webpack_require__) { 31019 31020// check on default Array iterator 31021var Iterators = __webpack_require__(46); 31022var ITERATOR = __webpack_require__(8)('iterator'); 31023var ArrayProto = Array.prototype; 31024 31025module.exports = function (it) { 31026 return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); 31027}; 31028 31029 31030/***/ }), 31031/* 277 */ 31032/***/ (function(module, exports, __webpack_require__) { 31033 31034// 7.2.2 IsArray(argument) 31035var cof = __webpack_require__(38); 31036module.exports = Array.isArray || function isArray(arg) { 31037 return cof(arg) == 'Array'; 31038}; 31039 31040 31041/***/ }), 31042/* 278 */ 31043/***/ (function(module, exports, __webpack_require__) { 31044 31045// 20.1.2.3 Number.isInteger(number) 31046var isObject = __webpack_require__(12); 31047var floor = Math.floor; 31048module.exports = function isInteger(it) { 31049 return !isObject(it) && isFinite(it) && floor(it) === it; 31050}; 31051 31052 31053/***/ }), 31054/* 279 */ 31055/***/ (function(module, exports, __webpack_require__) { 31056 31057// 7.2.8 IsRegExp(argument) 31058var isObject = __webpack_require__(12); 31059var cof = __webpack_require__(38); 31060var MATCH = __webpack_require__(8)('match'); 31061module.exports = function (it) { 31062 var isRegExp; 31063 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); 31064}; 31065 31066 31067/***/ }), 31068/* 280 */ 31069/***/ (function(module, exports, __webpack_require__) { 31070 31071// call something on iterator step with safe closing on error 31072var anObject = __webpack_require__(17); 31073module.exports = function (iterator, fn, value, entries) { 31074 try { 31075 return entries ? fn(anObject(value)[0], value[1]) : fn(value); 31076 // 7.4.6 IteratorClose(iterator, completion) 31077 } catch (e) { 31078 var ret = iterator['return']; 31079 if (ret !== undefined) anObject(ret.call(iterator)); 31080 throw e; 31081 } 31082}; 31083 31084 31085/***/ }), 31086/* 281 */ 31087/***/ (function(module, exports, __webpack_require__) { 31088 31089"use strict"; 31090 31091var LIBRARY = __webpack_require__(60); 31092var $export = __webpack_require__(1); 31093var redefine = __webpack_require__(32); 31094var hide = __webpack_require__(31); 31095var has = __webpack_require__(26); 31096var Iterators = __webpack_require__(46); 31097var $iterCreate = __webpack_require__(397); 31098var setToStringTag = __webpack_require__(50); 31099var getPrototypeOf = __webpack_require__(401); 31100var ITERATOR = __webpack_require__(8)('iterator'); 31101var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` 31102var FF_ITERATOR = '@@iterator'; 31103var KEYS = 'keys'; 31104var VALUES = 'values'; 31105 31106var returnThis = function () { return this; }; 31107 31108module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { 31109 $iterCreate(Constructor, NAME, next); 31110 var getMethod = function (kind) { 31111 if (!BUGGY && kind in proto) return proto[kind]; 31112 switch (kind) { 31113 case KEYS: return function keys() { return new Constructor(this, kind); }; 31114 case VALUES: return function values() { return new Constructor(this, kind); }; 31115 } return function entries() { return new Constructor(this, kind); }; 31116 }; 31117 var TAG = NAME + ' Iterator'; 31118 var DEF_VALUES = DEFAULT == VALUES; 31119 var VALUES_BUG = false; 31120 var proto = Base.prototype; 31121 var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; 31122 var $default = $native || getMethod(DEFAULT); 31123 var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; 31124 var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; 31125 var methods, key, IteratorPrototype; 31126 // Fix native 31127 if ($anyNative) { 31128 IteratorPrototype = getPrototypeOf($anyNative.call(new Base())); 31129 if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { 31130 // Set @@toStringTag to native iterators 31131 setToStringTag(IteratorPrototype, TAG, true); 31132 // fix for some old engines 31133 if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis); 31134 } 31135 } 31136 // fix Array#{values, @@iterator}.name in V8 / FF 31137 if (DEF_VALUES && $native && $native.name !== VALUES) { 31138 VALUES_BUG = true; 31139 $default = function values() { return $native.call(this); }; 31140 } 31141 // Define iterator 31142 if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { 31143 hide(proto, ITERATOR, $default); 31144 } 31145 // Plug for library 31146 Iterators[NAME] = $default; 31147 Iterators[TAG] = returnThis; 31148 if (DEFAULT) { 31149 methods = { 31150 values: DEF_VALUES ? $default : getMethod(VALUES), 31151 keys: IS_SET ? $default : getMethod(KEYS), 31152 entries: $entries 31153 }; 31154 if (FORCED) for (key in methods) { 31155 if (!(key in proto)) redefine(proto, key, methods[key]); 31156 } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); 31157 } 31158 return methods; 31159}; 31160 31161 31162/***/ }), 31163/* 282 */ 31164/***/ (function(module, exports) { 31165 31166module.exports = function (done, value) { 31167 return { value: value, done: !!done }; 31168}; 31169 31170 31171/***/ }), 31172/* 283 */ 31173/***/ (function(module, exports, __webpack_require__) { 31174 31175"use strict"; 31176 31177// 25.4.1.5 NewPromiseCapability(C) 31178var aFunction = __webpack_require__(54); 31179 31180function PromiseCapability(C) { 31181 var resolve, reject; 31182 this.promise = new C(function ($$resolve, $$reject) { 31183 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 31184 resolve = $$resolve; 31185 reject = $$reject; 31186 }); 31187 this.resolve = aFunction(resolve); 31188 this.reject = aFunction(reject); 31189} 31190 31191module.exports.f = function (C) { 31192 return new PromiseCapability(C); 31193}; 31194 31195 31196/***/ }), 31197/* 284 */ 31198/***/ (function(module, exports, __webpack_require__) { 31199 31200"use strict"; 31201 31202// 19.1.2.1 Object.assign(target, source, ...) 31203var getKeys = __webpack_require__(39); 31204var gOPS = __webpack_require__(61); 31205var pIE = __webpack_require__(48); 31206var toObject = __webpack_require__(40); 31207var IObject = __webpack_require__(78); 31208var $assign = Object.assign; 31209 31210// should work with symbols and should have deterministic property order (V8 bug) 31211module.exports = !$assign || __webpack_require__(25)(function () { 31212 var A = {}; 31213 var B = {}; 31214 // eslint-disable-next-line no-undef 31215 var S = Symbol(); 31216 var K = 'abcdefghijklmnopqrst'; 31217 A[S] = 7; 31218 K.split('').forEach(function (k) { B[k] = k; }); 31219 return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; 31220}) ? function assign(target, source) { // eslint-disable-line no-unused-vars 31221 var T = toObject(target); 31222 var aLen = arguments.length; 31223 var index = 1; 31224 var getSymbols = gOPS.f; 31225 var isEnum = pIE.f; 31226 while (aLen > index) { 31227 var S = IObject(arguments[index++]); 31228 var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S); 31229 var length = keys.length; 31230 var j = 0; 31231 var key; 31232 while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; 31233 } return T; 31234} : $assign; 31235 31236 31237/***/ }), 31238/* 285 */ 31239/***/ (function(module, exports, __webpack_require__) { 31240 31241var has = __webpack_require__(26); 31242var toIObject = __webpack_require__(27); 31243var arrayIndexOf = __webpack_require__(270)(false); 31244var IE_PROTO = __webpack_require__(83)('IE_PROTO'); 31245 31246module.exports = function (object, names) { 31247 var O = toIObject(object); 31248 var i = 0; 31249 var result = []; 31250 var key; 31251 for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); 31252 // Don't enum bug & hidden keys 31253 while (names.length > i) if (has(O, key = names[i++])) { 31254 ~arrayIndexOf(result, key) || result.push(key); 31255 } 31256 return result; 31257}; 31258 31259 31260/***/ }), 31261/* 286 */ 31262/***/ (function(module, exports, __webpack_require__) { 31263 31264var getKeys = __webpack_require__(39); 31265var toIObject = __webpack_require__(27); 31266var isEnum = __webpack_require__(48).f; 31267module.exports = function (isEntries) { 31268 return function (it) { 31269 var O = toIObject(it); 31270 var keys = getKeys(O); 31271 var length = keys.length; 31272 var i = 0; 31273 var result = []; 31274 var key; 31275 while (length > i) if (isEnum.call(O, key = keys[i++])) { 31276 result.push(isEntries ? [key, O[key]] : O[key]); 31277 } return result; 31278 }; 31279}; 31280 31281 31282/***/ }), 31283/* 287 */ 31284/***/ (function(module, exports, __webpack_require__) { 31285 31286// Works with __proto__ only. Old v8 can't work with null proto objects. 31287/* eslint-disable no-proto */ 31288var isObject = __webpack_require__(12); 31289var anObject = __webpack_require__(17); 31290var check = function (O, proto) { 31291 anObject(O); 31292 if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); 31293}; 31294module.exports = { 31295 set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line 31296 function (test, buggy, set) { 31297 try { 31298 set = __webpack_require__(30)(Function.call, __webpack_require__(81).f(Object.prototype, '__proto__').set, 2); 31299 set(test, []); 31300 buggy = !(test instanceof Array); 31301 } catch (e) { buggy = true; } 31302 return function setPrototypeOf(O, proto) { 31303 check(O, proto); 31304 if (buggy) O.__proto__ = proto; 31305 else set(O, proto); 31306 return O; 31307 }; 31308 }({}, false) : undefined), 31309 check: check 31310}; 31311 31312 31313/***/ }), 31314/* 288 */ 31315/***/ (function(module, exports, __webpack_require__) { 31316 31317"use strict"; 31318 31319var global = __webpack_require__(10); 31320var dP = __webpack_require__(18); 31321var DESCRIPTORS = __webpack_require__(20); 31322var SPECIES = __webpack_require__(8)('species'); 31323 31324module.exports = function (KEY) { 31325 var C = global[KEY]; 31326 if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, { 31327 configurable: true, 31328 get: function () { return this; } 31329 }); 31330}; 31331 31332 31333/***/ }), 31334/* 289 */ 31335/***/ (function(module, exports, __webpack_require__) { 31336 31337// https://github.com/tc39/proposal-string-pad-start-end 31338var toLength = __webpack_require__(21); 31339var repeat = __webpack_require__(290); 31340var defined = __webpack_require__(33); 31341 31342module.exports = function (that, maxLength, fillString, left) { 31343 var S = String(defined(that)); 31344 var stringLength = S.length; 31345 var fillStr = fillString === undefined ? ' ' : String(fillString); 31346 var intMaxLength = toLength(maxLength); 31347 if (intMaxLength <= stringLength || fillStr == '') return S; 31348 var fillLen = intMaxLength - stringLength; 31349 var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length)); 31350 if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen); 31351 return left ? stringFiller + S : S + stringFiller; 31352}; 31353 31354 31355/***/ }), 31356/* 290 */ 31357/***/ (function(module, exports, __webpack_require__) { 31358 31359"use strict"; 31360 31361var toInteger = __webpack_require__(64); 31362var defined = __webpack_require__(33); 31363 31364module.exports = function repeat(count) { 31365 var str = String(defined(this)); 31366 var res = ''; 31367 var n = toInteger(count); 31368 if (n < 0 || n == Infinity) throw RangeError("Count can't be negative"); 31369 for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str; 31370 return res; 31371}; 31372 31373 31374/***/ }), 31375/* 291 */ 31376/***/ (function(module, exports, __webpack_require__) { 31377 31378exports.f = __webpack_require__(8); 31379 31380 31381/***/ }), 31382/* 292 */ 31383/***/ (function(module, exports, __webpack_require__) { 31384 31385var classof = __webpack_require__(271); 31386var ITERATOR = __webpack_require__(8)('iterator'); 31387var Iterators = __webpack_require__(46); 31388module.exports = __webpack_require__(45).getIteratorMethod = function (it) { 31389 if (it != undefined) return it[ITERATOR] 31390 || it['@@iterator'] 31391 || Iterators[classof(it)]; 31392}; 31393 31394 31395/***/ }), 31396/* 293 */ 31397/***/ (function(module, exports) { 31398 31399// removed by extract-text-webpack-plugin 31400 31401/***/ }), 31402/* 294 */ 31403/***/ (function(module, exports) { 31404 31405// removed by extract-text-webpack-plugin 31406 31407/***/ }), 31408/* 295 */ 31409/***/ (function(module, exports) { 31410 31411// removed by extract-text-webpack-plugin 31412 31413/***/ }), 31414/* 296 */ 31415/***/ (function(module, exports, __webpack_require__) { 31416 31417"use strict"; 31418 31419 31420exports.__esModule = true; 31421exports.default = jQueryWrapper; 31422function jQueryWrapper(Handsontable) { 31423 var jQuery = typeof window === 'undefined' ? false : window.jQuery; 31424 31425 if (!jQuery) { 31426 return; 31427 } 31428 31429 jQuery.fn.handsontable = function (action) { 31430 var $this = this.first(); // Use only first element from list 31431 var instance = $this.data('handsontable'); 31432 31433 // Init case 31434 if (typeof action !== 'string') { 31435 var userSettings = action || {}; 31436 31437 if (instance) { 31438 instance.updateSettings(userSettings); 31439 } else { 31440 instance = new Handsontable.Core($this[0], userSettings); 31441 $this.data('handsontable', instance); 31442 instance.init(); 31443 } 31444 31445 return $this; 31446 } 31447 31448 // Action case 31449 var args = []; 31450 var output = void 0; 31451 31452 if (arguments.length > 1) { 31453 for (var i = 1, ilen = arguments.length; i < ilen; i++) { 31454 args.push(arguments[i]); 31455 } 31456 } 31457 31458 if (instance) { 31459 if (typeof instance[action] !== 'undefined') { 31460 output = instance[action].apply(instance, args); 31461 31462 if (action === 'destroy') { 31463 $this.removeData(); 31464 } 31465 } else { 31466 throw new Error('Handsontable do not provide action: ' + action); 31467 } 31468 } 31469 31470 return output; 31471 }; 31472}; 31473 31474/***/ }), 31475/* 297 */ 31476/***/ (function(module, exports, __webpack_require__) { 31477 31478"use strict"; 31479 31480 31481exports.__esModule = true; 31482exports.Base = exports.Search = exports.MultipleSelectionHandles = exports.MergeCells = exports.ManualRowResize = exports.ManualRowMove = exports.ManualColumnResize = exports.ManualColumnMove = exports.ManualColumnFreeze = exports.DragToScroll = exports.CopyPaste = exports.ContextMenu = exports.AutoRowSize = exports.AutoFill = exports.AutoColumnSize = undefined; 31483 31484var _autoColumnSize = __webpack_require__(335); 31485 31486var _autoColumnSize2 = _interopRequireDefault(_autoColumnSize); 31487 31488var _autofill = __webpack_require__(337); 31489 31490var _autofill2 = _interopRequireDefault(_autofill); 31491 31492var _autoRowSize = __webpack_require__(336); 31493 31494var _autoRowSize2 = _interopRequireDefault(_autoRowSize); 31495 31496var _contextMenu = __webpack_require__(340); 31497 31498var _contextMenu2 = _interopRequireDefault(_contextMenu); 31499 31500var _copyPaste = __webpack_require__(357); 31501 31502var _copyPaste2 = _interopRequireDefault(_copyPaste); 31503 31504var _dragToScroll = __webpack_require__(359); 31505 31506var _dragToScroll2 = _interopRequireDefault(_dragToScroll); 31507 31508var _manualColumnFreeze = __webpack_require__(362); 31509 31510var _manualColumnFreeze2 = _interopRequireDefault(_manualColumnFreeze); 31511 31512var _manualColumnMove = __webpack_require__(364); 31513 31514var _manualColumnMove2 = _interopRequireDefault(_manualColumnMove); 31515 31516var _manualColumnResize = __webpack_require__(367); 31517 31518var _manualColumnResize2 = _interopRequireDefault(_manualColumnResize); 31519 31520var _manualRowMove = __webpack_require__(368); 31521 31522var _manualRowMove2 = _interopRequireDefault(_manualRowMove); 31523 31524var _manualRowResize = __webpack_require__(372); 31525 31526var _manualRowResize2 = _interopRequireDefault(_manualRowResize); 31527 31528var _mergeCells = __webpack_require__(373); 31529 31530var _mergeCells2 = _interopRequireDefault(_mergeCells); 31531 31532var _multipleSelectionHandles = __webpack_require__(374); 31533 31534var _multipleSelectionHandles2 = _interopRequireDefault(_multipleSelectionHandles); 31535 31536var _search = __webpack_require__(375); 31537 31538var _search2 = _interopRequireDefault(_search); 31539 31540var _base = __webpack_require__(16); 31541 31542var _base2 = _interopRequireDefault(_base); 31543 31544function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 31545 31546exports.AutoColumnSize = _autoColumnSize2.default; 31547exports.AutoFill = _autofill2.default; 31548exports.AutoRowSize = _autoRowSize2.default; 31549exports.ContextMenu = _contextMenu2.default; 31550exports.CopyPaste = _copyPaste2.default; 31551exports.DragToScroll = _dragToScroll2.default; 31552exports.ManualColumnFreeze = _manualColumnFreeze2.default; 31553exports.ManualColumnMove = _manualColumnMove2.default; 31554exports.ManualColumnResize = _manualColumnResize2.default; 31555exports.ManualRowMove = _manualRowMove2.default; 31556exports.ManualRowResize = _manualRowResize2.default; 31557exports.MergeCells = _mergeCells2.default; 31558exports.MultipleSelectionHandles = _multipleSelectionHandles2.default; 31559exports.Search = _search2.default; 31560exports.Base = _base2.default; 31561 31562/***/ }), 31563/* 298 */ 31564/***/ (function(module, exports) { 31565 31566// removed by extract-text-webpack-plugin 31567 31568/***/ }), 31569/* 299 */ 31570/***/ (function(module, exports) { 31571 31572// removed by extract-text-webpack-plugin 31573 31574/***/ }), 31575/* 300 */ 31576/***/ (function(module, exports) { 31577 31578// removed by extract-text-webpack-plugin 31579 31580/***/ }), 31581/* 301 */ 31582/***/ (function(module, exports) { 31583 31584// removed by extract-text-webpack-plugin 31585 31586/***/ }), 31587/* 302 */ 31588/***/ (function(module, exports) { 31589 31590// removed by extract-text-webpack-plugin 31591 31592/***/ }), 31593/* 303 */ 31594/***/ (function(module, exports) { 31595 31596// removed by extract-text-webpack-plugin 31597 31598/***/ }), 31599/* 304 */ 31600/***/ (function(module, exports) { 31601 31602module.exports = function(module) { 31603 if(!module.webpackPolyfill) { 31604 module.deprecate = function() {}; 31605 module.paths = []; 31606 // module.parent = undefined by default 31607 if(!module.children) module.children = []; 31608 Object.defineProperty(module, "loaded", { 31609 enumerable: true, 31610 get: function() { 31611 return module.l; 31612 } 31613 }); 31614 Object.defineProperty(module, "id", { 31615 enumerable: true, 31616 get: function() { 31617 return module.i; 31618 } 31619 }); 31620 module.webpackPolyfill = 1; 31621 } 31622 return module; 31623}; 31624 31625 31626/***/ }), 31627/* 305 */ 31628/***/ (function(module, exports) { 31629 31630 31631 31632/***/ }), 31633/* 306 */ 31634/***/ (function(module, exports, __webpack_require__) { 31635 31636"use strict"; 31637 31638 31639/** 31640 * autoResize - resizes a DOM element to the width and height of another DOM element 31641 * 31642 * Copyright 2014, Marcin Warpechowski 31643 * Licensed under the MIT license 31644 */ 31645 31646function autoResize() { 31647 var defaults = { 31648 minHeight: 200, 31649 maxHeight: 300, 31650 minWidth: 100, 31651 maxWidth: 300 31652 }, 31653 el, 31654 body = document.body, 31655 text = document.createTextNode(''), 31656 span = document.createElement('SPAN'), 31657 observe = function observe(element, event, handler) { 31658 if (element.attachEvent) { 31659 element.attachEvent('on' + event, handler); 31660 } else { 31661 element.addEventListener(event, handler, false); 31662 } 31663 }, 31664 _unObserve = function _unObserve(element, event, handler) { 31665 if (element.removeEventListener) { 31666 element.removeEventListener(event, handler, false); 31667 } else { 31668 element.detachEvent('on' + event, handler); 31669 } 31670 }, 31671 resize = function resize(newChar) { 31672 var width, scrollHeight; 31673 31674 if (!newChar) { 31675 newChar = ""; 31676 } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) { 31677 newChar = "."; 31678 } 31679 31680 if (text.textContent !== void 0) { 31681 text.textContent = el.value + newChar; 31682 } else { 31683 text.data = el.value + newChar; //IE8 31684 } 31685 span.style.fontSize = getComputedStyle(el).fontSize; 31686 span.style.fontFamily = getComputedStyle(el).fontFamily; 31687 span.style.whiteSpace = "pre"; 31688 31689 body.appendChild(span); 31690 width = span.clientWidth + 2; 31691 body.removeChild(span); 31692 31693 el.style.height = defaults.minHeight + 'px'; 31694 31695 if (defaults.minWidth > width) { 31696 el.style.width = defaults.minWidth + 'px'; 31697 } else if (width > defaults.maxWidth) { 31698 el.style.width = defaults.maxWidth + 'px'; 31699 } else { 31700 el.style.width = width + 'px'; 31701 } 31702 scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0; 31703 31704 if (defaults.minHeight > scrollHeight) { 31705 el.style.height = defaults.minHeight + 'px'; 31706 } else if (defaults.maxHeight < scrollHeight) { 31707 el.style.height = defaults.maxHeight + 'px'; 31708 el.style.overflowY = 'visible'; 31709 } else { 31710 el.style.height = scrollHeight + 'px'; 31711 } 31712 }, 31713 delayedResize = function delayedResize() { 31714 window.setTimeout(resize, 0); 31715 }, 31716 extendDefaults = function extendDefaults(config) { 31717 31718 if (config && config.minHeight) { 31719 if (config.minHeight == 'inherit') { 31720 defaults.minHeight = el.clientHeight; 31721 } else { 31722 var minHeight = parseInt(config.minHeight); 31723 if (!isNaN(minHeight)) { 31724 defaults.minHeight = minHeight; 31725 } 31726 } 31727 } 31728 31729 if (config && config.maxHeight) { 31730 if (config.maxHeight == 'inherit') { 31731 defaults.maxHeight = el.clientHeight; 31732 } else { 31733 var maxHeight = parseInt(config.maxHeight); 31734 if (!isNaN(maxHeight)) { 31735 defaults.maxHeight = maxHeight; 31736 } 31737 } 31738 } 31739 31740 if (config && config.minWidth) { 31741 if (config.minWidth == 'inherit') { 31742 defaults.minWidth = el.clientWidth; 31743 } else { 31744 var minWidth = parseInt(config.minWidth); 31745 if (!isNaN(minWidth)) { 31746 defaults.minWidth = minWidth; 31747 } 31748 } 31749 } 31750 31751 if (config && config.maxWidth) { 31752 if (config.maxWidth == 'inherit') { 31753 defaults.maxWidth = el.clientWidth; 31754 } else { 31755 var maxWidth = parseInt(config.maxWidth); 31756 if (!isNaN(maxWidth)) { 31757 defaults.maxWidth = maxWidth; 31758 } 31759 } 31760 } 31761 31762 if (!span.firstChild) { 31763 span.className = "autoResize"; 31764 span.style.display = 'inline-block'; 31765 span.appendChild(text); 31766 } 31767 }, 31768 _init = function _init(el_, config, doObserve) { 31769 el = el_; 31770 extendDefaults(config); 31771 31772 if (el.nodeName == 'TEXTAREA') { 31773 31774 el.style.resize = 'none'; 31775 el.style.overflowY = ''; 31776 el.style.height = defaults.minHeight + 'px'; 31777 el.style.minWidth = defaults.minWidth + 'px'; 31778 el.style.maxWidth = defaults.maxWidth + 'px'; 31779 el.style.overflowY = 'hidden'; 31780 } 31781 31782 if (doObserve) { 31783 observe(el, 'change', resize); 31784 observe(el, 'cut', delayedResize); 31785 observe(el, 'paste', delayedResize); 31786 observe(el, 'drop', delayedResize); 31787 observe(el, 'keydown', delayedResize); 31788 observe(el, 'focus', resize); 31789 } 31790 31791 resize(); 31792 }; 31793 31794 function getComputedStyle(element) { 31795 return element.currentStyle || document.defaultView.getComputedStyle(element); 31796 } 31797 31798 return { 31799 init: function init(el_, config, doObserve) { 31800 _init(el_, config, doObserve); 31801 }, 31802 unObserve: function unObserve() { 31803 _unObserve(el, 'change', resize); 31804 _unObserve(el, 'cut', delayedResize); 31805 _unObserve(el, 'paste', delayedResize); 31806 _unObserve(el, 'drop', delayedResize); 31807 _unObserve(el, 'keydown', delayedResize); 31808 _unObserve(el, 'focus', resize); 31809 }, 31810 resize: resize 31811 }; 31812} 31813 31814if (true) { 31815 module.exports = autoResize; 31816} 31817 31818/***/ }), 31819/* 307 */ 31820/***/ (function(module, exports, __webpack_require__) { 31821 31822"use strict"; 31823 31824 31825exports.__esModule = true; 31826 31827var _element = __webpack_require__(0); 31828 31829var _base = __webpack_require__(29); 31830 31831var _base2 = _interopRequireDefault(_base); 31832 31833function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 31834 31835function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 31836 31837function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 31838 31839function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 31840 31841/** 31842 * A overlay that renders ALL available rows & columns positioned on top of the original Walkontable instance and all other overlays. 31843 * Used for debugging purposes to see if the other overlays (that render only part of the rows & columns) are positioned correctly 31844 * 31845 * @class DebugOverlay 31846 */ 31847var DebugOverlay = function (_Overlay) { 31848 _inherits(DebugOverlay, _Overlay); 31849 31850 /** 31851 * @param {Walkontable} wotInstance 31852 */ 31853 function DebugOverlay(wotInstance) { 31854 _classCallCheck(this, DebugOverlay); 31855 31856 var _this = _possibleConstructorReturn(this, (DebugOverlay.__proto__ || Object.getPrototypeOf(DebugOverlay)).call(this, wotInstance)); 31857 31858 _this.clone = _this.makeClone(_base2.default.CLONE_DEBUG); 31859 _this.clone.wtTable.holder.style.opacity = 0.4; 31860 _this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000'; 31861 31862 (0, _element.addClass)(_this.clone.wtTable.holder.parentNode, 'wtDebugVisible'); 31863 return _this; 31864 } 31865 31866 return DebugOverlay; 31867}(_base2.default); 31868 31869_base2.default.registerOverlay(_base2.default.CLONE_DEBUG, DebugOverlay); 31870 31871exports.default = DebugOverlay; 31872 31873/***/ }), 31874/* 308 */ 31875/***/ (function(module, exports, __webpack_require__) { 31876 31877"use strict"; 31878 31879 31880exports.__esModule = true; 31881 31882var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 31883 31884var _element = __webpack_require__(0); 31885 31886var _base = __webpack_require__(29); 31887 31888var _base2 = _interopRequireDefault(_base); 31889 31890function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 31891 31892function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 31893 31894function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 31895 31896function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 31897 31898/** 31899 * @class LeftOverlay 31900 */ 31901var LeftOverlay = function (_Overlay) { 31902 _inherits(LeftOverlay, _Overlay); 31903 31904 /** 31905 * @param {Walkontable} wotInstance 31906 */ 31907 function LeftOverlay(wotInstance) { 31908 _classCallCheck(this, LeftOverlay); 31909 31910 var _this = _possibleConstructorReturn(this, (LeftOverlay.__proto__ || Object.getPrototypeOf(LeftOverlay)).call(this, wotInstance)); 31911 31912 _this.clone = _this.makeClone(_base2.default.CLONE_LEFT); 31913 return _this; 31914 } 31915 31916 /** 31917 * Checks if overlay should be fully rendered 31918 * 31919 * @returns {Boolean} 31920 */ 31921 31922 31923 _createClass(LeftOverlay, [{ 31924 key: 'shouldBeRendered', 31925 value: function shouldBeRendered() { 31926 return !!(this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length); 31927 } 31928 31929 /** 31930 * Updates the left overlay position 31931 */ 31932 31933 }, { 31934 key: 'resetFixedPosition', 31935 value: function resetFixedPosition() { 31936 if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) { 31937 // removed from DOM 31938 return; 31939 } 31940 var overlayRoot = this.clone.wtTable.holder.parentNode; 31941 var headerPosition = 0; 31942 var preventOverflow = this.wot.getSetting('preventOverflow'); 31943 31944 if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'horizontal')) { 31945 var box = this.wot.wtTable.hider.getBoundingClientRect(); 31946 var left = Math.ceil(box.left); 31947 var right = Math.ceil(box.right); 31948 var finalLeft = void 0; 31949 var finalTop = void 0; 31950 31951 finalTop = this.wot.wtTable.hider.style.top; 31952 finalTop = finalTop === '' ? 0 : finalTop; 31953 31954 if (left < 0 && right - overlayRoot.offsetWidth > 0) { 31955 finalLeft = -left; 31956 } else { 31957 finalLeft = 0; 31958 } 31959 headerPosition = finalLeft; 31960 finalLeft += 'px'; 31961 31962 (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop); 31963 } else { 31964 headerPosition = this.getScrollPosition(); 31965 (0, _element.resetCssTransform)(overlayRoot); 31966 } 31967 this.adjustHeaderBordersPosition(headerPosition); 31968 31969 this.adjustElementsSize(); 31970 } 31971 31972 /** 31973 * Sets the main overlay's horizontal scroll position 31974 * 31975 * @param {Number} pos 31976 */ 31977 31978 }, { 31979 key: 'setScrollPosition', 31980 value: function setScrollPosition(pos) { 31981 if (this.mainTableScrollableElement === window) { 31982 window.scrollTo(pos, (0, _element.getWindowScrollTop)()); 31983 } else { 31984 this.mainTableScrollableElement.scrollLeft = pos; 31985 } 31986 } 31987 31988 /** 31989 * Triggers onScroll hook callback 31990 */ 31991 31992 }, { 31993 key: 'onScroll', 31994 value: function onScroll() { 31995 this.wot.getSetting('onScrollVertically'); 31996 } 31997 31998 /** 31999 * Calculates total sum cells width 32000 * 32001 * @param {Number} from Column index which calculates started from 32002 * @param {Number} to Column index where calculation is finished 32003 * @returns {Number} Width sum 32004 */ 32005 32006 }, { 32007 key: 'sumCellSizes', 32008 value: function sumCellSizes(from, to) { 32009 var sum = 0; 32010 var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth; 32011 32012 while (from < to) { 32013 sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth; 32014 from++; 32015 } 32016 32017 return sum; 32018 } 32019 32020 /** 32021 * Adjust overlay root element, childs and master table element sizes (width, height). 32022 * 32023 * @param {Boolean} [force=false] 32024 */ 32025 32026 }, { 32027 key: 'adjustElementsSize', 32028 value: function adjustElementsSize() { 32029 var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 32030 32031 this.updateTrimmingContainer(); 32032 32033 if (this.needFullRender || force) { 32034 this.adjustRootElementSize(); 32035 this.adjustRootChildrenSize(); 32036 32037 if (!force) { 32038 this.areElementSizesAdjusted = true; 32039 } 32040 } 32041 } 32042 32043 /** 32044 * Adjust overlay root element size (width and height). 32045 */ 32046 32047 }, { 32048 key: 'adjustRootElementSize', 32049 value: function adjustRootElementSize() { 32050 var masterHolder = this.wot.wtTable.holder; 32051 var scrollbarHeight = masterHolder.clientHeight === masterHolder.offsetHeight ? 0 : (0, _element.getScrollbarWidth)(); 32052 var overlayRoot = this.clone.wtTable.holder.parentNode; 32053 var overlayRootStyle = overlayRoot.style; 32054 var preventOverflow = this.wot.getSetting('preventOverflow'); 32055 var tableWidth = void 0; 32056 32057 if (this.trimmingContainer !== window || preventOverflow === 'vertical') { 32058 var height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight; 32059 32060 height = Math.min(height, (0, _element.innerHeight)(this.wot.wtTable.wtRootElement)); 32061 32062 overlayRootStyle.height = height + 'px'; 32063 } else { 32064 overlayRootStyle.height = ''; 32065 } 32066 32067 this.clone.wtTable.holder.style.height = overlayRootStyle.height; 32068 32069 tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE); 32070 overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px'; 32071 } 32072 32073 /** 32074 * Adjust overlay root childs size 32075 */ 32076 32077 }, { 32078 key: 'adjustRootChildrenSize', 32079 value: function adjustRootChildrenSize() { 32080 var scrollbarWidth = (0, _element.getScrollbarWidth)(); 32081 32082 this.clone.wtTable.hider.style.height = this.hider.style.height; 32083 this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height; 32084 32085 if (scrollbarWidth === 0) { 32086 scrollbarWidth = 30; 32087 } 32088 this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px'; 32089 } 32090 32091 /** 32092 * Adjust the overlay dimensions and position 32093 */ 32094 32095 }, { 32096 key: 'applyToDOM', 32097 value: function applyToDOM() { 32098 var total = this.wot.getSetting('totalColumns'); 32099 32100 if (!this.areElementSizesAdjusted) { 32101 this.adjustElementsSize(); 32102 } 32103 if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') { 32104 this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px'; 32105 } else if (total === 0) { 32106 this.spreader.style.left = '0'; 32107 } else { 32108 throw new Error('Incorrect value of the columnsRenderCalculator'); 32109 } 32110 this.spreader.style.right = ''; 32111 32112 if (this.needFullRender) { 32113 this.syncOverlayOffset(); 32114 } 32115 } 32116 32117 /** 32118 * Synchronize calculated top position to an element 32119 */ 32120 32121 }, { 32122 key: 'syncOverlayOffset', 32123 value: function syncOverlayOffset() { 32124 if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') { 32125 this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px'; 32126 } else { 32127 this.clone.wtTable.spreader.style.top = ''; 32128 } 32129 } 32130 32131 /** 32132 * Scrolls horizontally to a column at the left edge of the viewport 32133 * 32134 * @param sourceCol {Number} Column index which you want to scroll to 32135 * @param [beyondRendered=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default) 32136 */ 32137 32138 }, { 32139 key: 'scrollTo', 32140 value: function scrollTo(sourceCol, beyondRendered) { 32141 var newX = this.getTableParentOffset(); 32142 var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot; 32143 var mainHolder = sourceInstance.wtTable.holder; 32144 var scrollbarCompensation = 0; 32145 32146 if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) { 32147 scrollbarCompensation = (0, _element.getScrollbarWidth)(); 32148 } 32149 if (beyondRendered) { 32150 newX += this.sumCellSizes(0, sourceCol + 1); 32151 newX -= this.wot.wtViewport.getViewportWidth(); 32152 } else { 32153 newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol); 32154 } 32155 newX += scrollbarCompensation; 32156 32157 this.setScrollPosition(newX); 32158 } 32159 32160 /** 32161 * Gets table parent left position 32162 * 32163 * @returns {Number} 32164 */ 32165 32166 }, { 32167 key: 'getTableParentOffset', 32168 value: function getTableParentOffset() { 32169 var preventOverflow = this.wot.getSetting('preventOverflow'); 32170 var offset = 0; 32171 32172 if (!preventOverflow && this.trimmingContainer === window) { 32173 offset = this.wot.wtTable.holderOffset.left; 32174 } 32175 32176 return offset; 32177 } 32178 32179 /** 32180 * Gets the main overlay's horizontal scroll position 32181 * 32182 * @returns {Number} Main table's vertical scroll position 32183 */ 32184 32185 }, { 32186 key: 'getScrollPosition', 32187 value: function getScrollPosition() { 32188 return (0, _element.getScrollLeft)(this.mainTableScrollableElement); 32189 } 32190 32191 /** 32192 * Adds css classes to hide the header border's header (cell-selection border hiding issue) 32193 * 32194 * @param {Number} position Header X position if trimming container is window or scroll top if not 32195 */ 32196 32197 }, { 32198 key: 'adjustHeaderBordersPosition', 32199 value: function adjustHeaderBordersPosition(position) { 32200 var masterParent = this.wot.wtTable.holder.parentNode; 32201 var rowHeaders = this.wot.getSetting('rowHeaders'); 32202 var fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft'); 32203 var totalRows = this.wot.getSetting('totalRows'); 32204 32205 if (totalRows) { 32206 (0, _element.removeClass)(masterParent, 'emptyRows'); 32207 } else { 32208 (0, _element.addClass)(masterParent, 'emptyRows'); 32209 } 32210 32211 if (fixedColumnsLeft && !rowHeaders.length) { 32212 (0, _element.addClass)(masterParent, 'innerBorderLeft'); 32213 } else if (!fixedColumnsLeft && rowHeaders.length) { 32214 var previousState = (0, _element.hasClass)(masterParent, 'innerBorderLeft'); 32215 32216 if (position) { 32217 (0, _element.addClass)(masterParent, 'innerBorderLeft'); 32218 } else { 32219 (0, _element.removeClass)(masterParent, 'innerBorderLeft'); 32220 } 32221 if (!previousState && position || previousState && !position) { 32222 this.wot.wtOverlays.adjustElementsSize(); 32223 } 32224 } 32225 } 32226 }]); 32227 32228 return LeftOverlay; 32229}(_base2.default); 32230 32231_base2.default.registerOverlay(_base2.default.CLONE_LEFT, LeftOverlay); 32232 32233exports.default = LeftOverlay; 32234 32235/***/ }), 32236/* 309 */ 32237/***/ (function(module, exports, __webpack_require__) { 32238 32239"use strict"; 32240 32241 32242exports.__esModule = true; 32243 32244var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 32245 32246var _element = __webpack_require__(0); 32247 32248var _base = __webpack_require__(29); 32249 32250var _base2 = _interopRequireDefault(_base); 32251 32252function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 32253 32254function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 32255 32256function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 32257 32258function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 32259 32260/** 32261 * @class TopOverlay 32262 */ 32263var TopOverlay = function (_Overlay) { 32264 _inherits(TopOverlay, _Overlay); 32265 32266 /** 32267 * @param {Walkontable} wotInstance 32268 */ 32269 function TopOverlay(wotInstance) { 32270 _classCallCheck(this, TopOverlay); 32271 32272 var _this = _possibleConstructorReturn(this, (TopOverlay.__proto__ || Object.getPrototypeOf(TopOverlay)).call(this, wotInstance)); 32273 32274 _this.clone = _this.makeClone(_base2.default.CLONE_TOP); 32275 return _this; 32276 } 32277 32278 /** 32279 * Checks if overlay should be fully rendered 32280 * 32281 * @returns {Boolean} 32282 */ 32283 32284 32285 _createClass(TopOverlay, [{ 32286 key: 'shouldBeRendered', 32287 value: function shouldBeRendered() { 32288 return !!(this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length); 32289 } 32290 32291 /** 32292 * Updates the top overlay position 32293 */ 32294 32295 }, { 32296 key: 'resetFixedPosition', 32297 value: function resetFixedPosition() { 32298 if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) { 32299 // removed from DOM 32300 return; 32301 } 32302 var overlayRoot = this.clone.wtTable.holder.parentNode; 32303 var headerPosition = 0; 32304 var preventOverflow = this.wot.getSetting('preventOverflow'); 32305 32306 if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'vertical')) { 32307 var box = this.wot.wtTable.hider.getBoundingClientRect(); 32308 var top = Math.ceil(box.top); 32309 var bottom = Math.ceil(box.bottom); 32310 var finalLeft = void 0; 32311 var finalTop = void 0; 32312 32313 finalLeft = this.wot.wtTable.hider.style.left; 32314 finalLeft = finalLeft === '' ? 0 : finalLeft; 32315 32316 if (top < 0 && bottom - overlayRoot.offsetHeight > 0) { 32317 finalTop = -top; 32318 } else { 32319 finalTop = 0; 32320 } 32321 headerPosition = finalTop; 32322 finalTop += 'px'; 32323 32324 (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop); 32325 } else { 32326 headerPosition = this.getScrollPosition(); 32327 (0, _element.resetCssTransform)(overlayRoot); 32328 } 32329 32330 this.adjustHeaderBordersPosition(headerPosition); 32331 32332 this.adjustElementsSize(); 32333 } 32334 32335 /** 32336 * Sets the main overlay's vertical scroll position 32337 * 32338 * @param {Number} pos 32339 */ 32340 32341 }, { 32342 key: 'setScrollPosition', 32343 value: function setScrollPosition(pos) { 32344 if (this.mainTableScrollableElement === window) { 32345 window.scrollTo((0, _element.getWindowScrollLeft)(), pos); 32346 } else { 32347 this.mainTableScrollableElement.scrollTop = pos; 32348 } 32349 } 32350 32351 /** 32352 * Triggers onScroll hook callback 32353 */ 32354 32355 }, { 32356 key: 'onScroll', 32357 value: function onScroll() { 32358 this.wot.getSetting('onScrollHorizontally'); 32359 } 32360 32361 /** 32362 * Calculates total sum cells height 32363 * 32364 * @param {Number} from Row index which calculates started from 32365 * @param {Number} to Row index where calculation is finished 32366 * @returns {Number} Height sum 32367 */ 32368 32369 }, { 32370 key: 'sumCellSizes', 32371 value: function sumCellSizes(from, to) { 32372 var sum = 0; 32373 var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight; 32374 32375 while (from < to) { 32376 var height = this.wot.wtTable.getRowHeight(from); 32377 32378 sum += height === void 0 ? defaultRowHeight : height; 32379 from++; 32380 } 32381 32382 return sum; 32383 } 32384 32385 /** 32386 * Adjust overlay root element, childs and master table element sizes (width, height). 32387 * 32388 * @param {Boolean} [force=false] 32389 */ 32390 32391 }, { 32392 key: 'adjustElementsSize', 32393 value: function adjustElementsSize() { 32394 var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 32395 32396 this.updateTrimmingContainer(); 32397 32398 if (this.needFullRender || force) { 32399 this.adjustRootElementSize(); 32400 this.adjustRootChildrenSize(); 32401 32402 if (!force) { 32403 this.areElementSizesAdjusted = true; 32404 } 32405 } 32406 } 32407 32408 /** 32409 * Adjust overlay root element size (width and height). 32410 */ 32411 32412 }, { 32413 key: 'adjustRootElementSize', 32414 value: function adjustRootElementSize() { 32415 var masterHolder = this.wot.wtTable.holder; 32416 var scrollbarWidth = masterHolder.clientWidth === masterHolder.offsetWidth ? 0 : (0, _element.getScrollbarWidth)(); 32417 var overlayRoot = this.clone.wtTable.holder.parentNode; 32418 var overlayRootStyle = overlayRoot.style; 32419 var preventOverflow = this.wot.getSetting('preventOverflow'); 32420 var tableHeight = void 0; 32421 32422 if (this.trimmingContainer !== window || preventOverflow === 'horizontal') { 32423 var width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth; 32424 32425 width = Math.min(width, (0, _element.innerWidth)(this.wot.wtTable.wtRootElement)); 32426 32427 overlayRootStyle.width = width + 'px'; 32428 } else { 32429 overlayRootStyle.width = ''; 32430 } 32431 32432 this.clone.wtTable.holder.style.width = overlayRootStyle.width; 32433 32434 tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE); 32435 overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px'; 32436 } 32437 32438 /** 32439 * Adjust overlay root childs size 32440 */ 32441 32442 }, { 32443 key: 'adjustRootChildrenSize', 32444 value: function adjustRootChildrenSize() { 32445 var scrollbarWidth = (0, _element.getScrollbarWidth)(); 32446 32447 this.clone.wtTable.hider.style.width = this.hider.style.width; 32448 this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width; 32449 32450 if (scrollbarWidth === 0) { 32451 scrollbarWidth = 30; 32452 } 32453 this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px'; 32454 } 32455 32456 /** 32457 * Adjust the overlay dimensions and position 32458 */ 32459 32460 }, { 32461 key: 'applyToDOM', 32462 value: function applyToDOM() { 32463 var total = this.wot.getSetting('totalRows'); 32464 32465 if (!this.areElementSizesAdjusted) { 32466 this.adjustElementsSize(); 32467 } 32468 if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') { 32469 this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px'; 32470 } else if (total === 0) { 32471 // can happen if there are 0 rows 32472 this.spreader.style.top = '0'; 32473 } else { 32474 throw new Error('Incorrect value of the rowsRenderCalculator'); 32475 } 32476 this.spreader.style.bottom = ''; 32477 32478 if (this.needFullRender) { 32479 this.syncOverlayOffset(); 32480 } 32481 } 32482 32483 /** 32484 * Synchronize calculated left position to an element 32485 */ 32486 32487 }, { 32488 key: 'syncOverlayOffset', 32489 value: function syncOverlayOffset() { 32490 if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') { 32491 this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px'; 32492 } else { 32493 this.clone.wtTable.spreader.style.left = ''; 32494 } 32495 } 32496 32497 /** 32498 * Scrolls vertically to a row 32499 * 32500 * @param sourceRow {Number} Row index which you want to scroll to 32501 * @param [bottomEdge=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default) 32502 */ 32503 32504 }, { 32505 key: 'scrollTo', 32506 value: function scrollTo(sourceRow, bottomEdge) { 32507 var newY = this.getTableParentOffset(); 32508 var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot; 32509 var mainHolder = sourceInstance.wtTable.holder; 32510 var scrollbarCompensation = 0; 32511 32512 if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) { 32513 scrollbarCompensation = (0, _element.getScrollbarWidth)(); 32514 } 32515 32516 if (bottomEdge) { 32517 var fixedRowsBottom = this.wot.getSetting('fixedRowsBottom'); 32518 var fixedRowsTop = this.wot.getSetting('fixedRowsTop'); 32519 var totalRows = this.wot.getSetting('totalRows'); 32520 32521 newY += this.sumCellSizes(0, sourceRow + 1); 32522 newY -= this.wot.wtViewport.getViewportHeight() - this.sumCellSizes(totalRows - fixedRowsBottom, totalRows); 32523 // Fix 1 pixel offset when cell is selected 32524 newY += 1; 32525 } else { 32526 newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow); 32527 } 32528 newY += scrollbarCompensation; 32529 32530 this.setScrollPosition(newY); 32531 } 32532 32533 /** 32534 * Gets table parent top position 32535 * 32536 * @returns {Number} 32537 */ 32538 32539 }, { 32540 key: 'getTableParentOffset', 32541 value: function getTableParentOffset() { 32542 if (this.mainTableScrollableElement === window) { 32543 return this.wot.wtTable.holderOffset.top; 32544 } 32545 return 0; 32546 } 32547 32548 /** 32549 * Gets the main overlay's vertical scroll position 32550 * 32551 * @returns {Number} Main table's vertical scroll position 32552 */ 32553 32554 }, { 32555 key: 'getScrollPosition', 32556 value: function getScrollPosition() { 32557 return (0, _element.getScrollTop)(this.mainTableScrollableElement); 32558 } 32559 32560 /** 32561 * Redraw borders of selection 32562 * 32563 * @param {WalkontableSelection} selection Selection for redraw 32564 */ 32565 32566 }, { 32567 key: 'redrawSelectionBorders', 32568 value: function redrawSelectionBorders(selection) { 32569 if (selection && selection.cellRange) { 32570 var border = selection.getBorder(this.wot); 32571 32572 if (border) { 32573 var corners = selection.getCorners(); 32574 border.disappear(); 32575 border.appear(corners); 32576 } 32577 } 32578 } 32579 32580 /** 32581 * Redrawing borders of all selections 32582 */ 32583 32584 }, { 32585 key: 'redrawAllSelectionsBorders', 32586 value: function redrawAllSelectionsBorders() { 32587 var selections = this.wot.selections; 32588 32589 this.redrawSelectionBorders(selections.current); 32590 this.redrawSelectionBorders(selections.area); 32591 this.redrawSelectionBorders(selections.fill); 32592 this.wot.wtTable.wot.wtOverlays.leftOverlay.refresh(); 32593 } 32594 32595 /** 32596 * Adds css classes to hide the header border's header (cell-selection border hiding issue) 32597 * 32598 * @param {Number} position Header Y position if trimming container is window or scroll top if not 32599 */ 32600 32601 }, { 32602 key: 'adjustHeaderBordersPosition', 32603 value: function adjustHeaderBordersPosition(position) { 32604 var masterParent = this.wot.wtTable.holder.parentNode; 32605 var totalColumns = this.wot.getSetting('totalColumns'); 32606 32607 if (totalColumns) { 32608 (0, _element.removeClass)(masterParent, 'emptyColumns'); 32609 } else { 32610 (0, _element.addClass)(masterParent, 'emptyColumns'); 32611 } 32612 32613 if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) { 32614 var previousState = (0, _element.hasClass)(masterParent, 'innerBorderTop'); 32615 32616 if (position || this.wot.getSetting('totalRows') === 0) { 32617 (0, _element.addClass)(masterParent, 'innerBorderTop'); 32618 } else { 32619 (0, _element.removeClass)(masterParent, 'innerBorderTop'); 32620 } 32621 32622 if (!previousState && position || previousState && !position) { 32623 this.wot.wtOverlays.adjustElementsSize(); 32624 32625 // cell borders should be positioned once again, 32626 // because we added / removed 1px border from table header 32627 this.redrawAllSelectionsBorders(); 32628 } 32629 } 32630 32631 // nasty workaround for double border in the header, TODO: find a pure-css solution 32632 if (this.wot.getSetting('rowHeaders').length === 0) { 32633 var secondHeaderCell = this.clone.wtTable.THEAD.querySelectorAll('th:nth-of-type(2)'); 32634 32635 if (secondHeaderCell) { 32636 for (var i = 0; i < secondHeaderCell.length; i++) { 32637 secondHeaderCell[i].style['border-left-width'] = 0; 32638 } 32639 } 32640 } 32641 } 32642 }]); 32643 32644 return TopOverlay; 32645}(_base2.default); 32646 32647_base2.default.registerOverlay(_base2.default.CLONE_TOP, TopOverlay); 32648 32649exports.default = TopOverlay; 32650 32651/***/ }), 32652/* 310 */ 32653/***/ (function(module, exports, __webpack_require__) { 32654 32655"use strict"; 32656 32657 32658exports.__esModule = true; 32659 32660var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 32661 32662var _element = __webpack_require__(0); 32663 32664var _base = __webpack_require__(29); 32665 32666var _base2 = _interopRequireDefault(_base); 32667 32668function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 32669 32670function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 32671 32672function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 32673 32674function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 32675 32676/** 32677 * @class TopLeftCornerOverlay 32678 */ 32679var TopLeftCornerOverlay = function (_Overlay) { 32680 _inherits(TopLeftCornerOverlay, _Overlay); 32681 32682 /** 32683 * @param {Walkontable} wotInstance 32684 */ 32685 function TopLeftCornerOverlay(wotInstance) { 32686 _classCallCheck(this, TopLeftCornerOverlay); 32687 32688 var _this = _possibleConstructorReturn(this, (TopLeftCornerOverlay.__proto__ || Object.getPrototypeOf(TopLeftCornerOverlay)).call(this, wotInstance)); 32689 32690 _this.clone = _this.makeClone(_base2.default.CLONE_TOP_LEFT_CORNER); 32691 return _this; 32692 } 32693 32694 /** 32695 * Checks if overlay should be fully rendered 32696 * 32697 * @returns {Boolean} 32698 */ 32699 32700 32701 _createClass(TopLeftCornerOverlay, [{ 32702 key: 'shouldBeRendered', 32703 value: function shouldBeRendered() { 32704 return !!((this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length)); 32705 } 32706 32707 /** 32708 * Updates the corner overlay position 32709 */ 32710 32711 }, { 32712 key: 'resetFixedPosition', 32713 value: function resetFixedPosition() { 32714 this.updateTrimmingContainer(); 32715 32716 if (!this.wot.wtTable.holder.parentNode) { 32717 // removed from DOM 32718 return; 32719 } 32720 var overlayRoot = this.clone.wtTable.holder.parentNode; 32721 var tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE); 32722 var tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE); 32723 var preventOverflow = this.wot.getSetting('preventOverflow'); 32724 32725 if (this.trimmingContainer === window) { 32726 var box = this.wot.wtTable.hider.getBoundingClientRect(); 32727 var top = Math.ceil(box.top); 32728 var left = Math.ceil(box.left); 32729 var bottom = Math.ceil(box.bottom); 32730 var right = Math.ceil(box.right); 32731 var finalLeft = '0'; 32732 var finalTop = '0'; 32733 32734 if (!preventOverflow || preventOverflow === 'vertical') { 32735 if (left < 0 && right - overlayRoot.offsetWidth > 0) { 32736 finalLeft = -left + 'px'; 32737 } 32738 } 32739 32740 if (!preventOverflow || preventOverflow === 'horizontal') { 32741 if (top < 0 && bottom - overlayRoot.offsetHeight > 0) { 32742 finalTop = -top + 'px'; 32743 } 32744 } 32745 (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop); 32746 } else { 32747 (0, _element.resetCssTransform)(overlayRoot); 32748 } 32749 overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px'; 32750 overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px'; 32751 } 32752 }]); 32753 32754 return TopLeftCornerOverlay; 32755}(_base2.default); 32756 32757_base2.default.registerOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, TopLeftCornerOverlay); 32758 32759exports.default = TopLeftCornerOverlay; 32760 32761/***/ }), 32762/* 311 */ 32763/***/ (function(module, exports, __webpack_require__) { 32764 32765"use strict"; 32766 32767 32768exports.__esModule = true; 32769 32770var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 32771 32772var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 32773 32774var _element = __webpack_require__(0); 32775 32776var _border2 = __webpack_require__(250); 32777 32778var _border3 = _interopRequireDefault(_border2); 32779 32780var _coords = __webpack_require__(43); 32781 32782var _coords2 = _interopRequireDefault(_coords); 32783 32784var _range = __webpack_require__(71); 32785 32786var _range2 = _interopRequireDefault(_range); 32787 32788function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 32789 32790function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 32791 32792/** 32793 * @class Selection 32794 */ 32795var Selection = function () { 32796 /** 32797 * @param {Object} settings 32798 * @param {CellRange} cellRange 32799 */ 32800 function Selection(settings, cellRange) { 32801 _classCallCheck(this, Selection); 32802 32803 this.settings = settings; 32804 this.cellRange = cellRange || null; 32805 this.instanceBorders = {}; 32806 } 32807 32808 /** 32809 * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection 32810 * borders per instance 32811 * 32812 * @param {Walkontable} wotInstance 32813 * @returns {Border} 32814 */ 32815 32816 32817 _createClass(Selection, [{ 32818 key: 'getBorder', 32819 value: function getBorder(wotInstance) { 32820 if (this.instanceBorders[wotInstance.guid]) { 32821 return this.instanceBorders[wotInstance.guid]; 32822 } 32823 32824 // where is this returned? 32825 this.instanceBorders[wotInstance.guid] = new _border3.default(wotInstance, this.settings); 32826 } 32827 32828 /** 32829 * Checks if selection is empty 32830 * 32831 * @returns {Boolean} 32832 */ 32833 32834 }, { 32835 key: 'isEmpty', 32836 value: function isEmpty() { 32837 return this.cellRange === null; 32838 } 32839 32840 /** 32841 * Adds a cell coords to the selection 32842 * 32843 * @param {CellCoords} coords 32844 */ 32845 32846 }, { 32847 key: 'add', 32848 value: function add(coords) { 32849 if (this.isEmpty()) { 32850 this.cellRange = new _range2.default(coords, coords, coords); 32851 } else { 32852 this.cellRange.expand(coords); 32853 } 32854 } 32855 32856 /** 32857 * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean 32858 * information about success 32859 * 32860 * @param {CellCoords} oldCoords 32861 * @param {CellCoords} newCoords 32862 * @returns {Boolean} 32863 */ 32864 32865 }, { 32866 key: 'replace', 32867 value: function replace(oldCoords, newCoords) { 32868 if (!this.isEmpty()) { 32869 if (this.cellRange.from.isEqual(oldCoords)) { 32870 this.cellRange.from = newCoords; 32871 32872 return true; 32873 } 32874 if (this.cellRange.to.isEqual(oldCoords)) { 32875 this.cellRange.to = newCoords; 32876 32877 return true; 32878 } 32879 } 32880 32881 return false; 32882 } 32883 32884 /** 32885 * Clears selection 32886 */ 32887 32888 }, { 32889 key: 'clear', 32890 value: function clear() { 32891 this.cellRange = null; 32892 } 32893 32894 /** 32895 * Returns the top left (TL) and bottom right (BR) selection coordinates 32896 * 32897 * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]` 32898 */ 32899 32900 }, { 32901 key: 'getCorners', 32902 value: function getCorners() { 32903 var topLeft = this.cellRange.getTopLeftCorner(); 32904 var bottomRight = this.cellRange.getBottomRightCorner(); 32905 32906 return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col]; 32907 } 32908 32909 /** 32910 * Adds class name to cell element at given coords 32911 * 32912 * @param {Walkontable} wotInstance Walkontable instance 32913 * @param {Number} sourceRow Cell row coord 32914 * @param {Number} sourceColumn Cell column coord 32915 * @param {String} className Class name 32916 */ 32917 32918 }, { 32919 key: 'addClassAtCoords', 32920 value: function addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) { 32921 var TD = wotInstance.wtTable.getCell(new _coords2.default(sourceRow, sourceColumn)); 32922 32923 if ((typeof TD === 'undefined' ? 'undefined' : _typeof(TD)) === 'object') { 32924 (0, _element.addClass)(TD, className); 32925 } 32926 } 32927 32928 /** 32929 * @param wotInstance 32930 */ 32931 32932 }, { 32933 key: 'draw', 32934 value: function draw(wotInstance) { 32935 if (this.isEmpty()) { 32936 if (this.settings.border) { 32937 var border = this.getBorder(wotInstance); 32938 32939 if (border) { 32940 border.disappear(); 32941 } 32942 } 32943 32944 return; 32945 } 32946 var renderedRows = wotInstance.wtTable.getRenderedRowsCount(); 32947 var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount(); 32948 var corners = this.getCorners(); 32949 var sourceRow = void 0, 32950 sourceCol = void 0, 32951 TH = void 0; 32952 32953 for (var column = 0; column < renderedColumns; column++) { 32954 sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column); 32955 32956 if (sourceCol >= corners[1] && sourceCol <= corners[3]) { 32957 TH = wotInstance.wtTable.getColumnHeader(sourceCol); 32958 32959 if (TH) { 32960 var newClasses = []; 32961 32962 if (this.settings.highlightHeaderClassName) { 32963 newClasses.push(this.settings.highlightHeaderClassName); 32964 } 32965 32966 if (this.settings.highlightColumnClassName) { 32967 newClasses.push(this.settings.highlightColumnClassName); 32968 } 32969 32970 (0, _element.addClass)(TH, newClasses); 32971 } 32972 } 32973 } 32974 32975 for (var row = 0; row < renderedRows; row++) { 32976 sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row); 32977 32978 if (sourceRow >= corners[0] && sourceRow <= corners[2]) { 32979 TH = wotInstance.wtTable.getRowHeader(sourceRow); 32980 32981 if (TH) { 32982 var _newClasses = []; 32983 32984 if (this.settings.highlightHeaderClassName) { 32985 _newClasses.push(this.settings.highlightHeaderClassName); 32986 } 32987 32988 if (this.settings.highlightRowClassName) { 32989 _newClasses.push(this.settings.highlightRowClassName); 32990 } 32991 32992 (0, _element.addClass)(TH, _newClasses); 32993 } 32994 } 32995 32996 for (var _column = 0; _column < renderedColumns; _column++) { 32997 sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(_column); 32998 32999 if (sourceRow >= corners[0] && sourceRow <= corners[2] && sourceCol >= corners[1] && sourceCol <= corners[3]) { 33000 // selected cell 33001 if (this.settings.className) { 33002 this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className); 33003 } 33004 } else if (sourceRow >= corners[0] && sourceRow <= corners[2]) { 33005 // selection is in this row 33006 if (this.settings.highlightRowClassName) { 33007 this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightRowClassName); 33008 } 33009 } else if (sourceCol >= corners[1] && sourceCol <= corners[3]) { 33010 // selection is in this column 33011 if (this.settings.highlightColumnClassName) { 33012 this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightColumnClassName); 33013 } 33014 } 33015 } 33016 } 33017 wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className); 33018 33019 if (this.settings.border) { 33020 var _border = this.getBorder(wotInstance); 33021 33022 if (_border) { 33023 // warning! border.appear modifies corners! 33024 _border.appear(corners); 33025 } 33026 } 33027 } 33028 }]); 33029 33030 return Selection; 33031}(); 33032 33033exports.default = Selection; 33034 33035/***/ }), 33036/* 312 */ 33037/***/ (function(module, exports, __webpack_require__) { 33038 33039"use strict"; 33040 33041 33042exports.__esModule = true; 33043 33044var _editors = __webpack_require__(13); 33045 33046var _renderers = __webpack_require__(6); 33047 33048var _validators = __webpack_require__(24); 33049 33050var CELL_TYPE = 'autocomplete'; 33051 33052exports.default = { 33053 editor: (0, _editors.getEditor)(CELL_TYPE), 33054 renderer: (0, _renderers.getRenderer)(CELL_TYPE), 33055 validator: (0, _validators.getValidator)(CELL_TYPE) 33056}; 33057 33058/***/ }), 33059/* 313 */ 33060/***/ (function(module, exports, __webpack_require__) { 33061 33062"use strict"; 33063 33064 33065exports.__esModule = true; 33066 33067var _editors = __webpack_require__(13); 33068 33069var _renderers = __webpack_require__(6); 33070 33071var CELL_TYPE = 'checkbox'; 33072 33073exports.default = { 33074 editor: (0, _editors.getEditor)(CELL_TYPE), 33075 renderer: (0, _renderers.getRenderer)(CELL_TYPE) 33076}; 33077 33078/***/ }), 33079/* 314 */ 33080/***/ (function(module, exports, __webpack_require__) { 33081 33082"use strict"; 33083 33084 33085exports.__esModule = true; 33086 33087var _editors = __webpack_require__(13); 33088 33089var _renderers = __webpack_require__(6); 33090 33091var _validators = __webpack_require__(24); 33092 33093var CELL_TYPE = 'date'; 33094 33095exports.default = { 33096 editor: (0, _editors.getEditor)(CELL_TYPE), 33097 // displays small gray arrow on right side of the cell 33098 renderer: (0, _renderers.getRenderer)('autocomplete'), 33099 validator: (0, _validators.getValidator)(CELL_TYPE) 33100}; 33101 33102/***/ }), 33103/* 315 */ 33104/***/ (function(module, exports, __webpack_require__) { 33105 33106"use strict"; 33107 33108 33109exports.__esModule = true; 33110 33111var _editors = __webpack_require__(13); 33112 33113var _renderers = __webpack_require__(6); 33114 33115var _validators = __webpack_require__(24); 33116 33117var CELL_TYPE = 'dropdown'; 33118 33119exports.default = { 33120 editor: (0, _editors.getEditor)(CELL_TYPE), 33121 // displays small gray arrow on right side of the cell 33122 renderer: (0, _renderers.getRenderer)('autocomplete'), 33123 validator: (0, _validators.getValidator)('autocomplete') 33124}; 33125 33126/***/ }), 33127/* 316 */ 33128/***/ (function(module, exports, __webpack_require__) { 33129 33130"use strict"; 33131 33132 33133exports.__esModule = true; 33134 33135var _editors = __webpack_require__(13); 33136 33137var _renderers = __webpack_require__(6); 33138 33139var CELL_TYPE = 'handsontable'; 33140 33141exports.default = { 33142 editor: (0, _editors.getEditor)(CELL_TYPE), 33143 // displays small gray arrow on right side of the cell 33144 renderer: (0, _renderers.getRenderer)('autocomplete') 33145}; 33146 33147/***/ }), 33148/* 317 */ 33149/***/ (function(module, exports, __webpack_require__) { 33150 33151"use strict"; 33152 33153 33154exports.__esModule = true; 33155 33156var _editors = __webpack_require__(13); 33157 33158var _renderers = __webpack_require__(6); 33159 33160var _validators = __webpack_require__(24); 33161 33162var CELL_TYPE = 'numeric'; 33163 33164exports.default = { 33165 editor: (0, _editors.getEditor)(CELL_TYPE), 33166 renderer: (0, _renderers.getRenderer)(CELL_TYPE), 33167 validator: (0, _validators.getValidator)(CELL_TYPE), 33168 dataType: 'number' 33169}; 33170 33171/***/ }), 33172/* 318 */ 33173/***/ (function(module, exports, __webpack_require__) { 33174 33175"use strict"; 33176 33177 33178exports.__esModule = true; 33179 33180var _editors = __webpack_require__(13); 33181 33182var _renderers = __webpack_require__(6); 33183 33184var _validators = __webpack_require__(24); 33185 33186var CELL_TYPE = 'password'; 33187 33188exports.default = { 33189 editor: (0, _editors.getEditor)(CELL_TYPE), 33190 renderer: (0, _renderers.getRenderer)(CELL_TYPE), 33191 copyable: false 33192}; 33193 33194/***/ }), 33195/* 319 */ 33196/***/ (function(module, exports, __webpack_require__) { 33197 33198"use strict"; 33199 33200 33201exports.__esModule = true; 33202 33203var _browser = __webpack_require__(22); 33204 33205var _editors = __webpack_require__(13); 33206 33207var _renderers = __webpack_require__(6); 33208 33209var CELL_TYPE = 'text'; 33210 33211exports.default = { 33212 editor: (0, _browser.isMobileBrowser)() ? (0, _editors.getEditor)('mobile') : (0, _editors.getEditor)(CELL_TYPE), 33213 renderer: (0, _renderers.getRenderer)(CELL_TYPE) 33214}; 33215 33216/***/ }), 33217/* 320 */ 33218/***/ (function(module, exports, __webpack_require__) { 33219 33220"use strict"; 33221 33222 33223exports.__esModule = true; 33224 33225var _editors = __webpack_require__(13); 33226 33227var _renderers = __webpack_require__(6); 33228 33229var _validators = __webpack_require__(24); 33230 33231var CELL_TYPE = 'time'; 33232 33233exports.default = { 33234 editor: (0, _editors.getEditor)('text'), 33235 // displays small gray arrow on right side of the cell 33236 renderer: (0, _renderers.getRenderer)('text'), 33237 validator: (0, _validators.getValidator)(CELL_TYPE) 33238}; 33239 33240/***/ }), 33241/* 321 */ 33242/***/ (function(module, exports, __webpack_require__) { 33243 33244"use strict"; 33245 33246 33247exports.__esModule = true; 33248 33249var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 33250 33251var _SheetClip = __webpack_require__(249); 33252 33253var _SheetClip2 = _interopRequireDefault(_SheetClip); 33254 33255var _data = __webpack_require__(67); 33256 33257var _setting = __webpack_require__(68); 33258 33259var _object = __webpack_require__(3); 33260 33261var _array = __webpack_require__(2); 33262 33263var _interval = __webpack_require__(384); 33264 33265var _interval2 = _interopRequireDefault(_interval); 33266 33267var _number = __webpack_require__(5); 33268 33269var _multiMap = __webpack_require__(334); 33270 33271var _multiMap2 = _interopRequireDefault(_multiMap); 33272 33273var _pluginHooks = __webpack_require__(11); 33274 33275var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 33276 33277function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 33278 33279/** 33280 * Utility class that gets and saves data from/to the data source using mapping of columns numbers to object property names 33281 * @todo refactor arguments of methods getRange, getText to be numbers (not objects) 33282 * @todo remove priv, GridSettings from object constructor 33283 * 33284 * @param {Object} instance Instance of Handsontable 33285 * @param {*} priv 33286 * @param {*} GridSettings Grid settings 33287 * @util 33288 * @class DataMap 33289 */ 33290function DataMap(instance, priv, GridSettings) { 33291 var _this = this; 33292 33293 this.instance = instance; 33294 this.priv = priv; 33295 this.GridSettings = GridSettings; 33296 this.dataSource = this.instance.getSettings().data; 33297 this.cachedLength = null; 33298 this.skipCache = false; 33299 this.latestSourceRowsCount = 0; 33300 33301 if (this.dataSource && this.dataSource[0]) { 33302 this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]); 33303 } else { 33304 this.duckSchema = {}; 33305 } 33306 this.createMap(); 33307 this.interval = _interval2.default.create(function () { 33308 return _this.clearLengthCache(); 33309 }, '15fps'); 33310 33311 this.instance.addHook('skipLengthCache', function (delay) { 33312 return _this.onSkipLengthCache(delay); 33313 }); 33314 this.onSkipLengthCache(500); 33315} 33316 33317DataMap.prototype.DESTINATION_RENDERER = 1; 33318DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2; 33319 33320/** 33321 * @param {Object|Array} object 33322 * @returns {Object|Array} 33323 */ 33324DataMap.prototype.recursiveDuckSchema = function (object) { 33325 return (0, _object.duckSchema)(object); 33326}; 33327 33328/** 33329 * @param {Object} schema 33330 * @param {Number} lastCol 33331 * @param {Number} parent 33332 * @returns {Number} 33333 */ 33334DataMap.prototype.recursiveDuckColumns = function (schema, lastCol, parent) { 33335 var prop, i; 33336 if (typeof lastCol === 'undefined') { 33337 lastCol = 0; 33338 parent = ''; 33339 } 33340 if ((typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) === 'object' && !Array.isArray(schema)) { 33341 for (i in schema) { 33342 if ((0, _object.hasOwnProperty)(schema, i)) { 33343 if (schema[i] === null) { 33344 prop = parent + i; 33345 this.colToPropCache.push(prop); 33346 this.propToColCache.set(prop, lastCol); 33347 33348 lastCol++; 33349 } else { 33350 lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.'); 33351 } 33352 } 33353 } 33354 } 33355 33356 return lastCol; 33357}; 33358 33359DataMap.prototype.createMap = function () { 33360 var i = void 0; 33361 var schema = this.getSchema(); 33362 33363 if (typeof schema === 'undefined') { 33364 throw new Error('trying to create `columns` definition but you didn\'t provide `schema` nor `data`'); 33365 } 33366 33367 this.colToPropCache = []; 33368 this.propToColCache = new _multiMap2.default(); 33369 33370 var columns = this.instance.getSettings().columns; 33371 33372 if (columns) { 33373 var maxCols = this.instance.getSettings().maxCols; 33374 var columnsLen = Math.min(maxCols, columns.length); 33375 var filteredIndex = 0; 33376 var columnsAsFunc = false; 33377 var schemaLen = (0, _object.deepObjectSize)(schema); 33378 33379 if (typeof columns === 'function') { 33380 columnsLen = schemaLen > 0 ? schemaLen : this.instance.countSourceCols(); 33381 columnsAsFunc = true; 33382 } 33383 33384 for (i = 0; i < columnsLen; i++) { 33385 var column = columnsAsFunc ? columns(i) : columns[i]; 33386 33387 if ((0, _object.isObject)(column)) { 33388 if (typeof column.data !== 'undefined') { 33389 var index = columnsAsFunc ? filteredIndex : i; 33390 this.colToPropCache[index] = column.data; 33391 this.propToColCache.set(column.data, index); 33392 } 33393 33394 filteredIndex++; 33395 } 33396 } 33397 } else { 33398 this.recursiveDuckColumns(schema); 33399 } 33400}; 33401 33402/** 33403 * Returns property name that corresponds with the given column index. 33404 * 33405 * @param {Number} col Visual column index. 33406 * @returns {Number} Physical column index. 33407 */ 33408DataMap.prototype.colToProp = function (col) { 33409 col = this.instance.runHooks('modifyCol', col); 33410 33411 if (!isNaN(col) && this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') { 33412 return this.colToPropCache[col]; 33413 } 33414 33415 return col; 33416}; 33417 33418/** 33419 * @param {Object} prop 33420 * @fires Hooks#modifyCol 33421 * @returns {*} 33422 */ 33423DataMap.prototype.propToCol = function (prop) { 33424 var col; 33425 33426 if (typeof this.propToColCache.get(prop) === 'undefined') { 33427 col = prop; 33428 } else { 33429 col = this.propToColCache.get(prop); 33430 } 33431 col = this.instance.runHooks('unmodifyCol', col); 33432 33433 return col; 33434}; 33435 33436/** 33437 * @returns {Object} 33438 */ 33439DataMap.prototype.getSchema = function () { 33440 var schema = this.instance.getSettings().dataSchema; 33441 33442 if (schema) { 33443 if (typeof schema === 'function') { 33444 return schema(); 33445 } 33446 return schema; 33447 } 33448 33449 return this.duckSchema; 33450}; 33451 33452/** 33453 * Creates row at the bottom of the data array. 33454 * 33455 * @param {Number} [index] Physical index of the row before which the new row will be inserted. 33456 * @param {Number} [amount] An amount of rows to add. 33457 * @param {String} [source] Source of method call. 33458 * @fires Hooks#afterCreateRow 33459 * @returns {Number} Returns number of created rows. 33460 */ 33461DataMap.prototype.createRow = function (index, amount, source) { 33462 var row, 33463 colCount = this.instance.countCols(), 33464 numberOfCreatedRows = 0, 33465 currentIndex; 33466 33467 if (!amount) { 33468 amount = 1; 33469 } 33470 33471 if (typeof index !== 'number' || index >= this.instance.countSourceRows()) { 33472 index = this.instance.countSourceRows(); 33473 } 33474 this.instance.runHooks('beforeCreateRow', index, amount, source); 33475 33476 currentIndex = index; 33477 var maxRows = this.instance.getSettings().maxRows; 33478 33479 while (numberOfCreatedRows < amount && this.instance.countSourceRows() < maxRows) { 33480 if (this.instance.dataType === 'array') { 33481 if (this.instance.getSettings().dataSchema) { 33482 // Clone template array 33483 row = (0, _object.deepClone)(this.getSchema()); 33484 } else { 33485 row = []; 33486 /* eslint-disable no-loop-func */ 33487 (0, _number.rangeEach)(colCount - 1, function () { 33488 return row.push(null); 33489 }); 33490 } 33491 } else if (this.instance.dataType === 'function') { 33492 row = this.instance.getSettings().dataSchema(index); 33493 } else { 33494 row = {}; 33495 (0, _object.deepExtend)(row, this.getSchema()); 33496 } 33497 33498 if (index === this.instance.countSourceRows()) { 33499 this.dataSource.push(row); 33500 } else { 33501 this.spliceData(index, 0, row); 33502 } 33503 33504 numberOfCreatedRows++; 33505 currentIndex++; 33506 } 33507 33508 this.instance.runHooks('afterCreateRow', index, numberOfCreatedRows, source); 33509 this.instance.forceFullRender = true; // used when data was changed 33510 33511 return numberOfCreatedRows; 33512}; 33513 33514/** 33515 * Creates col at the right of the data array. 33516 * 33517 * @param {Number} [index] Visual index of the column before which the new column will be inserted 33518 * @param {Number} [amount] An amount of columns to add. 33519 * @param {String} [source] Source of method call. 33520 * @fires Hooks#afterCreateCol 33521 * @returns {Number} Returns number of created columns 33522 */ 33523DataMap.prototype.createCol = function (index, amount, source) { 33524 if (!this.instance.isColumnModificationAllowed()) { 33525 throw new Error('Cannot create new column. When data source in an object, ' + 'you can only have as much columns as defined in first data row, data schema or in the \'columns\' setting.' + 'If you want to be able to add new columns, you have to use array datasource.'); 33526 } 33527 var rlen = this.instance.countSourceRows(), 33528 data = this.dataSource, 33529 constructor, 33530 numberOfCreatedCols = 0, 33531 currentIndex; 33532 33533 if (!amount) { 33534 amount = 1; 33535 } 33536 33537 if (typeof index !== 'number' || index >= this.instance.countCols()) { 33538 index = this.instance.countCols(); 33539 } 33540 this.instance.runHooks('beforeCreateCol', index, amount, source); 33541 33542 currentIndex = index; 33543 33544 var maxCols = this.instance.getSettings().maxCols; 33545 while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) { 33546 constructor = (0, _setting.columnFactory)(this.GridSettings, this.priv.columnsSettingConflicts); 33547 33548 if (typeof index !== 'number' || index >= this.instance.countCols()) { 33549 if (rlen > 0) { 33550 for (var r = 0; r < rlen; r++) { 33551 if (typeof data[r] === 'undefined') { 33552 data[r] = []; 33553 } 33554 data[r].push(null); 33555 } 33556 } else { 33557 data.push([null]); 33558 } 33559 // Add new column constructor 33560 this.priv.columnSettings.push(constructor); 33561 } else { 33562 for (var _r = 0; _r < rlen; _r++) { 33563 data[_r].splice(currentIndex, 0, null); 33564 } 33565 // Add new column constructor at given index 33566 this.priv.columnSettings.splice(currentIndex, 0, constructor); 33567 } 33568 33569 numberOfCreatedCols++; 33570 currentIndex++; 33571 } 33572 33573 this.instance.runHooks('afterCreateCol', index, numberOfCreatedCols, source); 33574 this.instance.forceFullRender = true; // used when data was changed 33575 33576 return numberOfCreatedCols; 33577}; 33578 33579/** 33580 * Removes row from the data array. 33581 * 33582 * @param {Number} [index] Visual index of the row to be removed. If not provided, the last row will be removed 33583 * @param {Number} [amount] Amount of the rows to be removed. If not provided, one row will be removed 33584 * @param {String} [source] Source of method call. 33585 * @fires Hooks#beforeRemoveRow 33586 * @fires Hooks#afterRemoveRow 33587 */ 33588DataMap.prototype.removeRow = function (index, amount, source) { 33589 if (!amount) { 33590 amount = 1; 33591 } 33592 if (typeof index !== 'number') { 33593 index = -amount; 33594 } 33595 33596 amount = this.instance.runHooks('modifyRemovedAmount', amount, index); 33597 33598 index = (this.instance.countSourceRows() + index) % this.instance.countSourceRows(); 33599 33600 var logicRows = this.visualRowsToPhysical(index, amount); 33601 var actionWasNotCancelled = this.instance.runHooks('beforeRemoveRow', index, amount, logicRows, source); 33602 33603 if (actionWasNotCancelled === false) { 33604 return; 33605 } 33606 33607 var data = this.dataSource; 33608 var newData = void 0; 33609 33610 newData = this.filterData(index, amount); 33611 33612 if (newData) { 33613 data.length = 0; 33614 Array.prototype.push.apply(data, newData); 33615 } 33616 33617 this.instance.runHooks('afterRemoveRow', index, amount, logicRows, source); 33618 33619 this.instance.forceFullRender = true; // used when data was changed 33620}; 33621 33622/** 33623 * Removes column from the data array. 33624 * 33625 * @param {Number} [index] Visual index of the column to be removed. If not provided, the last column will be removed 33626 * @param {Number} [amount] Amount of the columns to be removed. If not provided, one column will be removed 33627 * @param {String} [source] Source of method call. 33628 * @fires Hooks#beforeRemoveCol 33629 * @fires Hooks#afterRemoveCol 33630 */ 33631DataMap.prototype.removeCol = function (index, amount, source) { 33632 if (this.instance.dataType === 'object' || this.instance.getSettings().columns) { 33633 throw new Error('cannot remove column with object data source or columns option specified'); 33634 } 33635 if (!amount) { 33636 amount = 1; 33637 } 33638 if (typeof index !== 'number') { 33639 index = -amount; 33640 } 33641 33642 index = (this.instance.countCols() + index) % this.instance.countCols(); 33643 33644 var logicColumns = this.visualColumnsToPhysical(index, amount); 33645 var descendingLogicColumns = logicColumns.slice(0).sort(function (a, b) { 33646 return b - a; 33647 }); 33648 var actionWasNotCancelled = this.instance.runHooks('beforeRemoveCol', index, amount, logicColumns, source); 33649 33650 if (actionWasNotCancelled === false) { 33651 return; 33652 } 33653 33654 var isTableUniform = true; 33655 var removedColumnsCount = descendingLogicColumns.length; 33656 var data = this.dataSource; 33657 33658 for (var c = 0; c < removedColumnsCount; c++) { 33659 if (isTableUniform && logicColumns[0] !== logicColumns[c] - c) { 33660 isTableUniform = false; 33661 } 33662 } 33663 33664 if (isTableUniform) { 33665 for (var r = 0, rlen = this.instance.countSourceRows(); r < rlen; r++) { 33666 data[r].splice(logicColumns[0], amount); 33667 } 33668 } else { 33669 for (var _r2 = 0, _rlen = this.instance.countSourceRows(); _r2 < _rlen; _r2++) { 33670 for (var _c = 0; _c < removedColumnsCount; _c++) { 33671 data[_r2].splice(descendingLogicColumns[_c], 1); 33672 } 33673 } 33674 33675 for (var _c2 = 0; _c2 < removedColumnsCount; _c2++) { 33676 this.priv.columnSettings.splice(logicColumns[_c2], 1); 33677 } 33678 } 33679 33680 this.instance.runHooks('afterRemoveCol', index, amount, logicColumns, source); 33681 33682 this.instance.forceFullRender = true; // used when data was changed 33683}; 33684 33685/** 33686 * Add/Removes data from the column. 33687 * 33688 * @param {Number} col Physical index of column in which do you want to do splice 33689 * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end 33690 * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed 33691 * @returns {Array} Returns removed portion of columns 33692 */ 33693DataMap.prototype.spliceCol = function (col, index, amount /* , elements... */) { 33694 var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : []; 33695 33696 var colData = this.instance.getDataAtCol(col); 33697 var removed = colData.slice(index, index + amount); 33698 var after = colData.slice(index + amount); 33699 33700 (0, _array.extendArray)(elements, after); 33701 var i = 0; 33702 while (i < amount) { 33703 elements.push(null); // add null in place of removed elements 33704 i++; 33705 } 33706 (0, _array.to2dArray)(elements); 33707 this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol'); 33708 33709 return removed; 33710}; 33711 33712/** 33713 * Add/Removes data from the row. 33714 * 33715 * @param {Number} row Physical index of row in which do you want to do splice 33716 * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end. 33717 * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed. 33718 * @returns {Array} Returns removed portion of rows 33719 */ 33720DataMap.prototype.spliceRow = function (row, index, amount /* , elements... */) { 33721 var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : []; 33722 33723 var rowData = this.instance.getSourceDataAtRow(row); 33724 var removed = rowData.slice(index, index + amount); 33725 var after = rowData.slice(index + amount); 33726 33727 (0, _array.extendArray)(elements, after); 33728 var i = 0; 33729 while (i < amount) { 33730 elements.push(null); // add null in place of removed elements 33731 i++; 33732 } 33733 this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow'); 33734 33735 return removed; 33736}; 33737 33738/** 33739 * Add/remove row(s) to/from the data source. 33740 * 33741 * @param {Number} index Physical index of the element to remove. 33742 * @param {Number} amount Number of rows to add/remove. 33743 * @param {Object} element Row to add. 33744 */ 33745DataMap.prototype.spliceData = function (index, amount, element) { 33746 var continueSplicing = this.instance.runHooks('beforeDataSplice', index, amount, element); 33747 33748 if (continueSplicing !== false) { 33749 this.dataSource.splice(index, amount, element); 33750 } 33751}; 33752 33753/** 33754 * Filter unwanted data elements from the data source. 33755 * 33756 * @param {Number} index Visual index of the element to remove. 33757 * @param {Number} amount Number of rows to add/remove. 33758 * @returns {Array} 33759 */ 33760DataMap.prototype.filterData = function (index, amount) { 33761 var physicalRows = this.visualRowsToPhysical(index, amount); 33762 var continueSplicing = this.instance.runHooks('beforeDataFilter', index, amount, physicalRows); 33763 33764 if (continueSplicing !== false) { 33765 var newData = this.dataSource.filter(function (row, index) { 33766 return physicalRows.indexOf(index) == -1; 33767 }); 33768 33769 return newData; 33770 } 33771}; 33772 33773/** 33774 * Returns single value from the data array. 33775 * 33776 * @param {Number} row Visual row index. 33777 * @param {Number} prop 33778 */ 33779DataMap.prototype.get = function (row, prop) { 33780 row = this.instance.runHooks('modifyRow', row); 33781 33782 var dataRow = this.dataSource[row]; 33783 // TODO: To remove, use 'modifyData' hook instead (see below) 33784 var modifiedRowData = this.instance.runHooks('modifyRowData', row); 33785 33786 dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow; 33787 // 33788 33789 var value = null; 33790 33791 // try to get value under property `prop` (includes dot) 33792 if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) { 33793 value = dataRow[prop]; 33794 } else if (typeof prop === 'string' && prop.indexOf('.') > -1) { 33795 var sliced = prop.split('.'); 33796 var out = dataRow; 33797 33798 if (!out) { 33799 return null; 33800 } 33801 for (var i = 0, ilen = sliced.length; i < ilen; i++) { 33802 out = out[sliced[i]]; 33803 33804 if (typeof out === 'undefined') { 33805 return null; 33806 } 33807 } 33808 value = out; 33809 } else if (typeof prop === 'function') { 33810 /** 33811 * allows for interacting with complex structures, for example 33812 * d3/jQuery getter/setter properties: 33813 * 33814 * {columns: [{ 33815 * data: function(row, value){ 33816 * if(arguments.length === 1){ 33817 * return row.property(); 33818 * } 33819 * row.property(value); 33820 * } 33821 * }]} 33822 */ 33823 value = prop(this.dataSource.slice(row, row + 1)[0]); 33824 } 33825 33826 if (this.instance.hasHook('modifyData')) { 33827 var valueHolder = (0, _object.createObjectPropListener)(value); 33828 33829 this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'get'); 33830 33831 if (valueHolder.isTouched()) { 33832 value = valueHolder.value; 33833 } 33834 } 33835 33836 return value; 33837}; 33838 33839var copyableLookup = (0, _data.cellMethodLookupFactory)('copyable', false); 33840 33841/** 33842 * Returns single value from the data array (intended for clipboard copy to an external application). 33843 * 33844 * @param {Number} row Physical row index. 33845 * @param {Number} prop 33846 * @returns {String} 33847 */ 33848DataMap.prototype.getCopyable = function (row, prop) { 33849 if (copyableLookup.call(this.instance, row, this.propToCol(prop))) { 33850 return this.get(row, prop); 33851 } 33852 return ''; 33853}; 33854 33855/** 33856 * Saves single value to the data array. 33857 * 33858 * @param {Number} row Visual row index. 33859 * @param {Number} prop 33860 * @param {String} value 33861 * @param {String} [source] Source of hook runner. 33862 */ 33863DataMap.prototype.set = function (row, prop, value, source) { 33864 row = this.instance.runHooks('modifyRow', row, source || 'datamapGet'); 33865 33866 var dataRow = this.dataSource[row]; 33867 // TODO: To remove, use 'modifyData' hook instead (see below) 33868 var modifiedRowData = this.instance.runHooks('modifyRowData', row); 33869 33870 dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow; 33871 // 33872 33873 if (this.instance.hasHook('modifyData')) { 33874 var valueHolder = (0, _object.createObjectPropListener)(value); 33875 33876 this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'set'); 33877 33878 if (valueHolder.isTouched()) { 33879 value = valueHolder.value; 33880 } 33881 } 33882 33883 // try to set value under property `prop` (includes dot) 33884 if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) { 33885 dataRow[prop] = value; 33886 } else if (typeof prop === 'string' && prop.indexOf('.') > -1) { 33887 var sliced = prop.split('.'); 33888 var out = dataRow; 33889 var i = 0; 33890 var ilen = void 0; 33891 33892 for (i = 0, ilen = sliced.length - 1; i < ilen; i++) { 33893 if (typeof out[sliced[i]] === 'undefined') { 33894 out[sliced[i]] = {}; 33895 } 33896 out = out[sliced[i]]; 33897 } 33898 out[sliced[i]] = value; 33899 } else if (typeof prop === 'function') { 33900 /* see the `function` handler in `get` */ 33901 prop(this.dataSource.slice(row, row + 1)[0], value); 33902 } else { 33903 dataRow[prop] = value; 33904 } 33905}; 33906 33907/** 33908 * This ridiculous piece of code maps rows Id that are present in table data to those displayed for user. 33909 * The trick is, the physical row id (stored in settings.data) is not necessary the same 33910 * as the visual (displayed) row id (e.g. when sorting is applied). 33911 * 33912 * @param {Number} index Visual row index. 33913 * @param {Number} amount 33914 * @fires Hooks#modifyRow 33915 * @returns {Number} 33916 */ 33917DataMap.prototype.visualRowsToPhysical = function (index, amount) { 33918 var totalRows = this.instance.countSourceRows(); 33919 var physicRow = (totalRows + index) % totalRows; 33920 var logicRows = []; 33921 var rowsToRemove = amount; 33922 var row; 33923 33924 while (physicRow < totalRows && rowsToRemove) { 33925 row = this.instance.runHooks('modifyRow', physicRow); 33926 logicRows.push(row); 33927 33928 rowsToRemove--; 33929 physicRow++; 33930 } 33931 33932 return logicRows; 33933}; 33934 33935/** 33936 * 33937 * @param index Visual column index. 33938 * @param amount 33939 * @returns {Array} 33940 */ 33941DataMap.prototype.visualColumnsToPhysical = function (index, amount) { 33942 var totalCols = this.instance.countCols(); 33943 var physicalCol = (totalCols + index) % totalCols; 33944 var visualCols = []; 33945 var colsToRemove = amount; 33946 33947 while (physicalCol < totalCols && colsToRemove) { 33948 var col = this.instance.runHooks('modifyCol', physicalCol); 33949 33950 visualCols.push(col); 33951 33952 colsToRemove--; 33953 physicalCol++; 33954 } 33955 33956 return visualCols; 33957}; 33958 33959/** 33960 * Clears the data array. 33961 */ 33962DataMap.prototype.clear = function () { 33963 for (var r = 0; r < this.instance.countSourceRows(); r++) { 33964 for (var c = 0; c < this.instance.countCols(); c++) { 33965 this.set(r, this.colToProp(c), ''); 33966 } 33967 } 33968}; 33969 33970/** 33971 * Clear cached data length. 33972 */ 33973DataMap.prototype.clearLengthCache = function () { 33974 this.cachedLength = null; 33975}; 33976 33977/** 33978 * Get data length. 33979 * 33980 * @returns {Number} 33981 */ 33982DataMap.prototype.getLength = function () { 33983 var _this2 = this; 33984 33985 var maxRows = void 0, 33986 maxRowsFromSettings = this.instance.getSettings().maxRows; 33987 33988 if (maxRowsFromSettings < 0 || maxRowsFromSettings === 0) { 33989 maxRows = 0; 33990 } else { 33991 maxRows = maxRowsFromSettings || Infinity; 33992 } 33993 33994 var length = this.instance.countSourceRows(); 33995 33996 if (this.instance.hasHook('modifyRow')) { 33997 var reValidate = this.skipCache; 33998 33999 this.interval.start(); 34000 if (length !== this.latestSourceRowsCount) { 34001 reValidate = true; 34002 } 34003 34004 this.latestSourceRowsCount = length; 34005 if (this.cachedLength === null || reValidate) { 34006 (0, _number.rangeEach)(length - 1, function (row) { 34007 row = _this2.instance.runHooks('modifyRow', row); 34008 34009 if (row === null) { 34010 --length; 34011 } 34012 }); 34013 this.cachedLength = length; 34014 } else { 34015 length = this.cachedLength; 34016 } 34017 } else { 34018 this.interval.stop(); 34019 } 34020 34021 return Math.min(length, maxRows); 34022}; 34023 34024/** 34025 * Returns the data array. 34026 * 34027 * @returns {Array} 34028 */ 34029DataMap.prototype.getAll = function () { 34030 var start = { 34031 row: 0, 34032 col: 0 34033 }; 34034 34035 var end = { 34036 row: Math.max(this.instance.countSourceRows() - 1, 0), 34037 col: Math.max(this.instance.countCols() - 1, 0) 34038 }; 34039 34040 if (start.row - end.row === 0 && !this.instance.countSourceRows()) { 34041 return []; 34042 } 34043 34044 return this.getRange(start, end, DataMap.prototype.DESTINATION_RENDERER); 34045}; 34046 34047/** 34048 * Returns data range as array. 34049 * 34050 * @param {Object} [start] Start selection position. Visual indexes. 34051 * @param {Object} [end] End selection position. Visual indexes. 34052 * @param {Number} destination Destination of datamap.get 34053 * @returns {Array} 34054 */ 34055DataMap.prototype.getRange = function (start, end, destination) { 34056 var r, 34057 rlen, 34058 c, 34059 clen, 34060 output = [], 34061 row; 34062 34063 var maxRows = this.instance.getSettings().maxRows; 34064 var maxCols = this.instance.getSettings().maxCols; 34065 34066 if (maxRows === 0 || maxCols === 0) { 34067 return []; 34068 } 34069 34070 var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get; 34071 34072 rlen = Math.min(Math.max(maxRows - 1, 0), Math.max(start.row, end.row)); 34073 clen = Math.min(Math.max(maxCols - 1, 0), Math.max(start.col, end.col)); 34074 34075 for (r = Math.min(start.row, end.row); r <= rlen; r++) { 34076 row = []; 34077 var physicalRow = this.instance.runHooks('modifyRow', r); 34078 34079 for (c = Math.min(start.col, end.col); c <= clen; c++) { 34080 34081 if (physicalRow === null) { 34082 break; 34083 } 34084 row.push(getFn.call(this, r, this.colToProp(c))); 34085 } 34086 if (physicalRow !== null) { 34087 output.push(row); 34088 } 34089 } 34090 34091 return output; 34092}; 34093 34094/** 34095 * Return data as text (tab separated columns). 34096 * 34097 * @param {Object} [start] Start selection position. Visual indexes. 34098 * @param {Object} [end] End selection position. Visual indexes. 34099 * @returns {String} 34100 */ 34101DataMap.prototype.getText = function (start, end) { 34102 return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_RENDERER)); 34103}; 34104 34105/** 34106 * Return data as copyable text (tab separated columns intended for clipboard copy to an external application). 34107 * 34108 * @param {Object} [start] Start selection position. Visual indexes. 34109 * @param {Object} [end] End selection position. Visual indexes. 34110 * @returns {String} 34111 */ 34112DataMap.prototype.getCopyableText = function (start, end) { 34113 return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR)); 34114}; 34115 34116/** 34117 * `skipLengthCache` callback. 34118 * @private 34119 * @param {Number} delay Time of the delay in milliseconds. 34120 */ 34121DataMap.prototype.onSkipLengthCache = function (delay) { 34122 var _this3 = this; 34123 34124 this.skipCache = true; 34125 setTimeout(function () { 34126 _this3.skipCache = false; 34127 }, delay); 34128}; 34129 34130/** 34131 * Destroy instance. 34132 */ 34133DataMap.prototype.destroy = function () { 34134 this.interval.stop(); 34135 34136 this.interval = null; 34137 this.instance = null; 34138 this.priv = null; 34139 this.GridSettings = null; 34140 this.dataSource = null; 34141 this.cachedLength = null; 34142 this.duckSchema = null; 34143}; 34144 34145exports.default = DataMap; 34146 34147/***/ }), 34148/* 322 */ 34149/***/ (function(module, exports, __webpack_require__) { 34150 34151"use strict"; 34152 34153 34154exports.__esModule = true; 34155 34156var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 34157 34158var _object = __webpack_require__(3); 34159 34160var _array = __webpack_require__(2); 34161 34162var _number = __webpack_require__(5); 34163 34164function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 34165 34166/** 34167 * @class DataSource 34168 * @private 34169 */ 34170var DataSource = function () { 34171 function DataSource(hotInstance) { 34172 var dataSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 34173 34174 _classCallCheck(this, DataSource); 34175 34176 /** 34177 * Instance of Handsontable. 34178 * 34179 * @type {Handsontable} 34180 */ 34181 this.hot = hotInstance; 34182 /** 34183 * Data source 34184 * 34185 * @type {Array} 34186 */ 34187 this.data = dataSource; 34188 /** 34189 * Type of data source. 34190 * 34191 * @type {String} 34192 * @default 'array' 34193 */ 34194 this.dataType = 'array'; 34195 34196 this.colToProp = function () {}; 34197 this.propToCol = function () {}; 34198 } 34199 34200 /** 34201 * Get all data. 34202 * 34203 * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided 34204 * in another format. 34205 * @returns {Array} 34206 */ 34207 34208 34209 _createClass(DataSource, [{ 34210 key: 'getData', 34211 value: function getData() { 34212 var toArray = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 34213 34214 var result = this.data; 34215 34216 if (toArray) { 34217 result = this.getByRange({ row: 0, col: 0 }, { row: Math.max(this.countRows() - 1, 0), col: Math.max(this.countColumns() - 1, 0) }, true); 34218 } 34219 34220 return result; 34221 } 34222 34223 /** 34224 * Set new data source. 34225 * 34226 * @param data {Array} 34227 */ 34228 34229 }, { 34230 key: 'setData', 34231 value: function setData(data) { 34232 this.data = data; 34233 } 34234 34235 /** 34236 * Returns array of column values from the data source. `column` is the index of the row in the data source. 34237 * 34238 * @param {Number} column Visual column index. 34239 * @returns {Array} 34240 */ 34241 34242 }, { 34243 key: 'getAtColumn', 34244 value: function getAtColumn(column) { 34245 var _this = this; 34246 34247 var result = []; 34248 34249 (0, _array.arrayEach)(this.data, function (row) { 34250 var property = _this.colToProp(column); 34251 34252 if (typeof property === 'string') { 34253 row = (0, _object.getProperty)(row, property); 34254 } else { 34255 row = row[property]; 34256 } 34257 result.push(row); 34258 }); 34259 34260 return result; 34261 } 34262 34263 /** 34264 * Returns a single row of the data (array or object, depending on what you have). `row` is the index of the row in the data source. 34265 * 34266 * @param {Number} row Physical row index. 34267 * @returns {Array|Object} 34268 */ 34269 34270 }, { 34271 key: 'getAtRow', 34272 value: function getAtRow(row) { 34273 return this.data[row]; 34274 } 34275 34276 /** 34277 * Returns a single value from the data. 34278 * 34279 * @param {Number} row Physical row index. 34280 * @param {Number} column Visual column index. 34281 * @returns {*} 34282 */ 34283 34284 }, { 34285 key: 'getAtCell', 34286 value: function getAtCell(row, column) { 34287 var result = null; 34288 34289 var modifyRowData = this.hot.runHooks('modifyRowData', row); 34290 34291 var dataRow = isNaN(modifyRowData) ? modifyRowData : this.data[row]; 34292 34293 if (dataRow) { 34294 var prop = this.colToProp(column); 34295 34296 if (typeof prop === 'string') { 34297 result = (0, _object.getProperty)(dataRow, prop); 34298 } else if (typeof prop === 'function') { 34299 result = prop(this.data.slice(row, row + 1)[0]); 34300 } else { 34301 result = dataRow[prop]; 34302 } 34303 } 34304 34305 return result; 34306 } 34307 34308 /** 34309 * Returns source data by passed range. 34310 * 34311 * @param {Object} start Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects). 34312 * @param {Object} end Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects). 34313 * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided 34314 * in another format. 34315 * @returns {Array} 34316 */ 34317 34318 }, { 34319 key: 'getByRange', 34320 value: function getByRange(start, end) { 34321 var _this2 = this; 34322 34323 var toArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 34324 34325 var startRow = Math.min(start.row, end.row); 34326 var startCol = Math.min(start.col, end.col); 34327 var endRow = Math.max(start.row, end.row); 34328 var endCol = Math.max(start.col, end.col); 34329 var result = []; 34330 34331 (0, _number.rangeEach)(startRow, endRow, function (currentRow) { 34332 var row = _this2.getAtRow(currentRow); 34333 var newRow = void 0; 34334 34335 if (_this2.dataType === 'array') { 34336 newRow = row.slice(startCol, endCol + 1); 34337 } else if (_this2.dataType === 'object') { 34338 newRow = toArray ? [] : {}; 34339 34340 (0, _number.rangeEach)(startCol, endCol, function (column) { 34341 var prop = _this2.colToProp(column); 34342 34343 if (toArray) { 34344 newRow.push(row[prop]); 34345 } else { 34346 newRow[prop] = row[prop]; 34347 } 34348 }); 34349 } 34350 34351 result.push(newRow); 34352 }); 34353 34354 return result; 34355 } 34356 34357 /** 34358 * Count number of rows. 34359 * 34360 * @returns {Number} 34361 */ 34362 34363 }, { 34364 key: 'countRows', 34365 value: function countRows() { 34366 return Array.isArray(this.data) ? this.data.length : 0; 34367 } 34368 34369 /** 34370 * Count number of columns. 34371 * 34372 * @returns {Number} 34373 */ 34374 34375 }, { 34376 key: 'countColumns', 34377 value: function countColumns() { 34378 var result = 0; 34379 34380 if (Array.isArray(this.data)) { 34381 if (this.dataType === 'array') { 34382 result = this.data[0].length; 34383 } else if (this.dataType === 'object') { 34384 result = Object.keys(this.data[0]).length; 34385 } 34386 } 34387 34388 return result; 34389 } 34390 34391 /** 34392 * Destroy instance. 34393 */ 34394 34395 }, { 34396 key: 'destroy', 34397 value: function destroy() { 34398 this.data = null; 34399 this.hot = null; 34400 } 34401 }]); 34402 34403 return DataSource; 34404}(); 34405 34406exports.default = DataSource; 34407 34408/***/ }), 34409/* 323 */ 34410/***/ (function(module, exports, __webpack_require__) { 34411 34412"use strict"; 34413 34414 34415exports.__esModule = true; 34416 34417var _src = __webpack_require__(14); 34418 34419var _unicode = __webpack_require__(15); 34420 34421var _event = __webpack_require__(7); 34422 34423var _editors = __webpack_require__(13); 34424 34425var _eventManager = __webpack_require__(4); 34426 34427var _eventManager2 = _interopRequireDefault(_eventManager); 34428 34429var _baseEditor = __webpack_require__(36); 34430 34431function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 34432 34433function EditorManager(instance, priv, selection) { 34434 var _this = this, 34435 destroyed = false, 34436 eventManager, 34437 activeEditor; 34438 34439 eventManager = new _eventManager2.default(instance); 34440 34441 function moveSelectionAfterEnter(shiftKey) { 34442 selection.setSelectedHeaders(false, false, false); 34443 var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves; 34444 34445 if (shiftKey) { 34446 // move selection up 34447 selection.transformStart(-enterMoves.row, -enterMoves.col); 34448 } else { 34449 // move selection down (add a new row if needed) 34450 selection.transformStart(enterMoves.row, enterMoves.col, true); 34451 } 34452 } 34453 34454 function moveSelectionUp(shiftKey) { 34455 if (shiftKey) { 34456 if (selection.selectedHeader.cols) { 34457 selection.setSelectedHeaders(selection.selectedHeader.rows, false, false); 34458 } 34459 selection.transformEnd(-1, 0); 34460 } else { 34461 selection.setSelectedHeaders(false, false, false); 34462 selection.transformStart(-1, 0); 34463 } 34464 } 34465 34466 function moveSelectionDown(shiftKey) { 34467 if (shiftKey) { 34468 // expanding selection down with shift 34469 selection.transformEnd(1, 0); 34470 } else { 34471 selection.setSelectedHeaders(false, false, false); 34472 selection.transformStart(1, 0); 34473 } 34474 } 34475 34476 function moveSelectionRight(shiftKey) { 34477 if (shiftKey) { 34478 selection.transformEnd(0, 1); 34479 } else { 34480 selection.setSelectedHeaders(false, false, false); 34481 selection.transformStart(0, 1); 34482 } 34483 } 34484 34485 function moveSelectionLeft(shiftKey) { 34486 if (shiftKey) { 34487 if (selection.selectedHeader.rows) { 34488 selection.setSelectedHeaders(false, selection.selectedHeader.cols, false); 34489 } 34490 selection.transformEnd(0, -1); 34491 } else { 34492 selection.setSelectedHeaders(false, false, false); 34493 selection.transformStart(0, -1); 34494 } 34495 } 34496 34497 function onKeyDown(event) { 34498 var ctrlDown, rangeModifier; 34499 34500 if (!instance.isListening()) { 34501 return; 34502 } 34503 instance.runHooks('beforeKeyDown', event); 34504 34505 if (destroyed) { 34506 return; 34507 } 34508 if ((0, _event.isImmediatePropagationStopped)(event)) { 34509 return; 34510 } 34511 priv.lastKeyCode = event.keyCode; 34512 34513 if (!selection.isSelected()) { 34514 return; 34515 } 34516 // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL) 34517 ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey; 34518 34519 if (activeEditor && !activeEditor.isWaiting()) { 34520 if (!(0, _unicode.isMetaKey)(event.keyCode) && !(0, _unicode.isCtrlKey)(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) { 34521 _this.openEditor('', event); 34522 34523 return; 34524 } 34525 } 34526 rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart; 34527 34528 switch (event.keyCode) { 34529 case _unicode.KEY_CODES.A: 34530 if (!_this.isEditorOpened() && ctrlDown) { 34531 selection.selectAll(); 34532 34533 event.preventDefault(); 34534 (0, _event.stopPropagation)(event); 34535 } 34536 break; 34537 34538 case _unicode.KEY_CODES.ARROW_UP: 34539 if (_this.isEditorOpened() && !activeEditor.isWaiting()) { 34540 _this.closeEditorAndSaveChanges(ctrlDown); 34541 } 34542 moveSelectionUp(event.shiftKey); 34543 34544 event.preventDefault(); 34545 (0, _event.stopPropagation)(event); 34546 break; 34547 34548 case _unicode.KEY_CODES.ARROW_DOWN: 34549 if (_this.isEditorOpened() && !activeEditor.isWaiting()) { 34550 _this.closeEditorAndSaveChanges(ctrlDown); 34551 } 34552 34553 moveSelectionDown(event.shiftKey); 34554 34555 event.preventDefault(); 34556 (0, _event.stopPropagation)(event); 34557 break; 34558 34559 case _unicode.KEY_CODES.ARROW_RIGHT: 34560 if (_this.isEditorOpened() && !activeEditor.isWaiting()) { 34561 _this.closeEditorAndSaveChanges(ctrlDown); 34562 } 34563 34564 moveSelectionRight(event.shiftKey); 34565 34566 event.preventDefault(); 34567 (0, _event.stopPropagation)(event); 34568 break; 34569 34570 case _unicode.KEY_CODES.ARROW_LEFT: 34571 if (_this.isEditorOpened() && !activeEditor.isWaiting()) { 34572 _this.closeEditorAndSaveChanges(ctrlDown); 34573 } 34574 34575 moveSelectionLeft(event.shiftKey); 34576 34577 event.preventDefault(); 34578 (0, _event.stopPropagation)(event); 34579 break; 34580 34581 case _unicode.KEY_CODES.TAB: 34582 selection.setSelectedHeaders(false, false, false); 34583 var tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves; 34584 34585 if (event.shiftKey) { 34586 // move selection left 34587 selection.transformStart(-tabMoves.row, -tabMoves.col); 34588 } else { 34589 // move selection right (add a new column if needed) 34590 selection.transformStart(tabMoves.row, tabMoves.col, true); 34591 } 34592 event.preventDefault(); 34593 (0, _event.stopPropagation)(event); 34594 break; 34595 34596 case _unicode.KEY_CODES.BACKSPACE: 34597 case _unicode.KEY_CODES.DELETE: 34598 selection.empty(event); 34599 _this.prepareEditor(); 34600 event.preventDefault(); 34601 break; 34602 34603 case _unicode.KEY_CODES.F2: 34604 /* F2 */ 34605 _this.openEditor(null, event); 34606 34607 if (activeEditor) { 34608 activeEditor.enableFullEditMode(); 34609 } 34610 event.preventDefault(); // prevent Opera from opening 'Go to Page dialog' 34611 break; 34612 34613 case _unicode.KEY_CODES.ENTER: 34614 /* return/enter */ 34615 if (_this.isEditorOpened()) { 34616 34617 if (activeEditor && activeEditor.state !== _baseEditor.EditorState.WAITING) { 34618 _this.closeEditorAndSaveChanges(ctrlDown); 34619 } 34620 moveSelectionAfterEnter(event.shiftKey); 34621 } else if (instance.getSettings().enterBeginsEditing) { 34622 _this.openEditor(null, event); 34623 34624 if (activeEditor) { 34625 activeEditor.enableFullEditMode(); 34626 } 34627 } else { 34628 moveSelectionAfterEnter(event.shiftKey); 34629 } 34630 event.preventDefault(); // don't add newline to field 34631 (0, _event.stopImmediatePropagation)(event); // required by HandsontableEditor 34632 break; 34633 34634 case _unicode.KEY_CODES.ESCAPE: 34635 if (_this.isEditorOpened()) { 34636 _this.closeEditorAndRestoreOriginalValue(ctrlDown); 34637 } 34638 event.preventDefault(); 34639 break; 34640 34641 case _unicode.KEY_CODES.HOME: 34642 selection.setSelectedHeaders(false, false, false); 34643 if (event.ctrlKey || event.metaKey) { 34644 rangeModifier(new _src.CellCoords(0, priv.selRange.from.col)); 34645 } else { 34646 rangeModifier(new _src.CellCoords(priv.selRange.from.row, 0)); 34647 } 34648 event.preventDefault(); // don't scroll the window 34649 (0, _event.stopPropagation)(event); 34650 break; 34651 34652 case _unicode.KEY_CODES.END: 34653 selection.setSelectedHeaders(false, false, false); 34654 if (event.ctrlKey || event.metaKey) { 34655 rangeModifier(new _src.CellCoords(instance.countRows() - 1, priv.selRange.from.col)); 34656 } else { 34657 rangeModifier(new _src.CellCoords(priv.selRange.from.row, instance.countCols() - 1)); 34658 } 34659 event.preventDefault(); // don't scroll the window 34660 (0, _event.stopPropagation)(event); 34661 break; 34662 34663 case _unicode.KEY_CODES.PAGE_UP: 34664 selection.setSelectedHeaders(false, false, false); 34665 selection.transformStart(-instance.countVisibleRows(), 0); 34666 event.preventDefault(); // don't page up the window 34667 (0, _event.stopPropagation)(event); 34668 break; 34669 34670 case _unicode.KEY_CODES.PAGE_DOWN: 34671 selection.setSelectedHeaders(false, false, false); 34672 selection.transformStart(instance.countVisibleRows(), 0); 34673 event.preventDefault(); // don't page down the window 34674 (0, _event.stopPropagation)(event); 34675 break; 34676 default: 34677 break; 34678 } 34679 } 34680 34681 function init() { 34682 instance.addHook('afterDocumentKeyDown', onKeyDown); 34683 34684 eventManager.addEventListener(document.documentElement, 'keydown', function (event) { 34685 if (!destroyed) { 34686 instance.runHooks('afterDocumentKeyDown', event); 34687 } 34688 }); 34689 34690 function onDblClick(event, coords, elem) { 34691 // may be TD or TH 34692 if (elem.nodeName == 'TD') { 34693 _this.openEditor(); 34694 34695 if (activeEditor) { 34696 activeEditor.enableFullEditMode(); 34697 } 34698 } 34699 } 34700 instance.view.wt.update('onCellDblClick', onDblClick); 34701 34702 instance.addHook('afterDestroy', function () { 34703 destroyed = true; 34704 }); 34705 } 34706 34707 /** 34708 * Destroy current editor, if exists. 34709 * 34710 * @function destroyEditor 34711 * @memberof! Handsontable.EditorManager# 34712 * @param {Boolean} revertOriginal 34713 */ 34714 this.destroyEditor = function (revertOriginal) { 34715 this.closeEditor(revertOriginal); 34716 }; 34717 34718 /** 34719 * Get active editor. 34720 * 34721 * @function getActiveEditor 34722 * @memberof! Handsontable.EditorManager# 34723 * @returns {*} 34724 */ 34725 this.getActiveEditor = function () { 34726 return activeEditor; 34727 }; 34728 34729 /** 34730 * Prepare text input to be displayed at given grid cell. 34731 * 34732 * @function prepareEditor 34733 * @memberof! Handsontable.EditorManager# 34734 */ 34735 this.prepareEditor = function () { 34736 var row, col, prop, td, originalValue, cellProperties, editorClass; 34737 34738 if (activeEditor && activeEditor.isWaiting()) { 34739 this.closeEditor(false, false, function (dataSaved) { 34740 if (dataSaved) { 34741 _this.prepareEditor(); 34742 } 34743 }); 34744 34745 return; 34746 } 34747 row = priv.selRange.highlight.row; 34748 col = priv.selRange.highlight.col; 34749 prop = instance.colToProp(col); 34750 td = instance.getCell(row, col); 34751 34752 originalValue = instance.getSourceDataAtCell(instance.runHooks('modifyRow', row), col); 34753 cellProperties = instance.getCellMeta(row, col); 34754 editorClass = instance.getCellEditor(cellProperties); 34755 34756 if (editorClass) { 34757 activeEditor = (0, _editors.getEditorInstance)(editorClass, instance); 34758 activeEditor.prepare(row, col, prop, td, originalValue, cellProperties); 34759 } else { 34760 activeEditor = void 0; 34761 } 34762 }; 34763 34764 /** 34765 * Check is editor is opened/showed. 34766 * 34767 * @function isEditorOpened 34768 * @memberof! Handsontable.EditorManager# 34769 * @returns {Boolean} 34770 */ 34771 this.isEditorOpened = function () { 34772 return activeEditor && activeEditor.isOpened(); 34773 }; 34774 34775 /** 34776 * Open editor with initial value. 34777 * 34778 * @function openEditor 34779 * @memberof! Handsontable.EditorManager# 34780 * @param {String} initialValue 34781 * @param {DOMEvent} event 34782 */ 34783 this.openEditor = function (initialValue, event) { 34784 if (activeEditor && !activeEditor.cellProperties.readOnly) { 34785 activeEditor.beginEditing(initialValue, event); 34786 } else if (activeEditor && activeEditor.cellProperties.readOnly) { 34787 34788 // move the selection after opening the editor with ENTER key 34789 if (event && event.keyCode === _unicode.KEY_CODES.ENTER) { 34790 moveSelectionAfterEnter(); 34791 } 34792 } 34793 }; 34794 34795 /** 34796 * Close editor, finish editing cell. 34797 * 34798 * @function closeEditor 34799 * @memberof! Handsontable.EditorManager# 34800 * @param {Boolean} restoreOriginalValue 34801 * @param {Boolean} [ctrlDown] 34802 * @param {Function} [callback] 34803 */ 34804 this.closeEditor = function (restoreOriginalValue, ctrlDown, callback) { 34805 if (activeEditor) { 34806 activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback); 34807 } else if (callback) { 34808 callback(false); 34809 } 34810 }; 34811 34812 /** 34813 * Close editor and save changes. 34814 * 34815 * @function closeEditorAndSaveChanges 34816 * @memberof! Handsontable.EditorManager# 34817 * @param {Boolean} ctrlDown 34818 */ 34819 this.closeEditorAndSaveChanges = function (ctrlDown) { 34820 return this.closeEditor(false, ctrlDown); 34821 }; 34822 34823 /** 34824 * Close editor and restore original value. 34825 * 34826 * @function closeEditorAndRestoreOriginalValue 34827 * @memberof! Handsontable.EditorManager# 34828 * @param {Boolean} ctrlDown 34829 */ 34830 this.closeEditorAndRestoreOriginalValue = function (ctrlDown) { 34831 return this.closeEditor(true, ctrlDown); 34832 }; 34833 34834 init(); 34835} 34836 34837exports.default = EditorManager; 34838 34839/***/ }), 34840/* 324 */ 34841/***/ (function(module, exports, __webpack_require__) { 34842 34843"use strict"; 34844 34845 34846exports.__esModule = true; 34847 34848var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 34849 34850var _baseEditor = __webpack_require__(36); 34851 34852var _baseEditor2 = _interopRequireDefault(_baseEditor); 34853 34854var _element = __webpack_require__(0); 34855 34856function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 34857 34858function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 34859 34860function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 34861 34862function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 34863 34864/** 34865 * @private 34866 * @editor CheckboxEditor 34867 * @class CheckboxEditor 34868 */ 34869var CheckboxEditor = function (_BaseEditor) { 34870 _inherits(CheckboxEditor, _BaseEditor); 34871 34872 function CheckboxEditor() { 34873 _classCallCheck(this, CheckboxEditor); 34874 34875 return _possibleConstructorReturn(this, (CheckboxEditor.__proto__ || Object.getPrototypeOf(CheckboxEditor)).apply(this, arguments)); 34876 } 34877 34878 _createClass(CheckboxEditor, [{ 34879 key: 'beginEditing', 34880 value: function beginEditing(initialValue, event) { 34881 // editorManager return double click event as undefined 34882 if (event === void 0) { 34883 var checkbox = this.TD.querySelector('input[type="checkbox"]'); 34884 34885 if (!(0, _element.hasClass)(checkbox, 'htBadValue')) { 34886 checkbox.click(); 34887 } 34888 } 34889 } 34890 }, { 34891 key: 'finishEditing', 34892 value: function finishEditing() {} 34893 }, { 34894 key: 'init', 34895 value: function init() {} 34896 }, { 34897 key: 'open', 34898 value: function open() {} 34899 }, { 34900 key: 'close', 34901 value: function close() {} 34902 }, { 34903 key: 'getValue', 34904 value: function getValue() {} 34905 }, { 34906 key: 'setValue', 34907 value: function setValue() {} 34908 }, { 34909 key: 'focus', 34910 value: function focus() {} 34911 }]); 34912 34913 return CheckboxEditor; 34914}(_baseEditor2.default); 34915 34916exports.default = CheckboxEditor; 34917 34918/***/ }), 34919/* 325 */ 34920/***/ (function(module, exports, __webpack_require__) { 34921 34922"use strict"; 34923 34924 34925exports.__esModule = true; 34926 34927var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 34928 34929var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 34930 34931var _moment = __webpack_require__(42); 34932 34933var _moment2 = _interopRequireDefault(_moment); 34934 34935var _pikaday = __webpack_require__(410); 34936 34937var _pikaday2 = _interopRequireDefault(_pikaday); 34938 34939__webpack_require__(298); 34940 34941var _element = __webpack_require__(0); 34942 34943var _object = __webpack_require__(3); 34944 34945var _eventManager = __webpack_require__(4); 34946 34947var _eventManager2 = _interopRequireDefault(_eventManager); 34948 34949var _unicode = __webpack_require__(15); 34950 34951var _event = __webpack_require__(7); 34952 34953var _textEditor = __webpack_require__(44); 34954 34955var _textEditor2 = _interopRequireDefault(_textEditor); 34956 34957function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 34958 34959function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 34960 34961function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 34962 34963function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 34964 34965/** 34966 * @private 34967 * @editor DateEditor 34968 * @class DateEditor 34969 * @dependencies TextEditor moment pikaday 34970 */ 34971var DateEditor = function (_TextEditor) { 34972 _inherits(DateEditor, _TextEditor); 34973 34974 /** 34975 * @param {Core} hotInstance Handsontable instance 34976 * @private 34977 */ 34978 function DateEditor(hotInstance) { 34979 _classCallCheck(this, DateEditor); 34980 34981 // TODO: Move this option to general settings 34982 var _this = _possibleConstructorReturn(this, (DateEditor.__proto__ || Object.getPrototypeOf(DateEditor)).call(this, hotInstance)); 34983 34984 _this.defaultDateFormat = 'DD/MM/YYYY'; 34985 _this.isCellEdited = false; 34986 _this.parentDestroyed = false; 34987 return _this; 34988 } 34989 34990 _createClass(DateEditor, [{ 34991 key: 'init', 34992 value: function init() { 34993 var _this2 = this; 34994 34995 if (typeof _moment2.default !== 'function') { 34996 throw new Error('You need to include moment.js to your project.'); 34997 } 34998 34999 if (typeof _pikaday2.default !== 'function') { 35000 throw new Error('You need to include Pikaday to your project.'); 35001 } 35002 _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'init', this).call(this); 35003 this.instance.addHook('afterDestroy', function () { 35004 _this2.parentDestroyed = true; 35005 _this2.destroyElements(); 35006 }); 35007 } 35008 35009 /** 35010 * Create data picker instance 35011 */ 35012 35013 }, { 35014 key: 'createElements', 35015 value: function createElements() { 35016 _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'createElements', this).call(this); 35017 35018 this.datePicker = document.createElement('DIV'); 35019 this.datePickerStyle = this.datePicker.style; 35020 this.datePickerStyle.position = 'absolute'; 35021 this.datePickerStyle.top = 0; 35022 this.datePickerStyle.left = 0; 35023 this.datePickerStyle.zIndex = 9999; 35024 35025 (0, _element.addClass)(this.datePicker, 'htDatepickerHolder'); 35026 document.body.appendChild(this.datePicker); 35027 35028 this.$datePicker = new _pikaday2.default(this.getDatePickerConfig()); 35029 var eventManager = new _eventManager2.default(this); 35030 35031 /** 35032 * Prevent recognizing clicking on datepicker as clicking outside of table 35033 */ 35034 eventManager.addEventListener(this.datePicker, 'mousedown', function (event) { 35035 return (0, _event.stopPropagation)(event); 35036 }); 35037 this.hideDatepicker(); 35038 } 35039 35040 /** 35041 * Destroy data picker instance 35042 */ 35043 35044 }, { 35045 key: 'destroyElements', 35046 value: function destroyElements() { 35047 this.$datePicker.destroy(); 35048 } 35049 35050 /** 35051 * Prepare editor to appear 35052 * 35053 * @param {Number} row Row index 35054 * @param {Number} col Column index 35055 * @param {String} prop Property name (passed when datasource is an array of objects) 35056 * @param {HTMLTableCellElement} td Table cell element 35057 * @param {*} originalValue Original value 35058 * @param {Object} cellProperties Object with cell properties ({@see Core#getCellMeta}) 35059 */ 35060 35061 }, { 35062 key: 'prepare', 35063 value: function prepare(row, col, prop, td, originalValue, cellProperties) { 35064 this._opened = false; 35065 _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties); 35066 } 35067 35068 /** 35069 * Open editor 35070 * 35071 * @param {Event} [event=null] 35072 */ 35073 35074 }, { 35075 key: 'open', 35076 value: function open() { 35077 var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 35078 35079 _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'open', this).call(this); 35080 this.showDatepicker(event); 35081 } 35082 35083 /** 35084 * Close editor 35085 */ 35086 35087 }, { 35088 key: 'close', 35089 value: function close() { 35090 var _this3 = this; 35091 35092 this._opened = false; 35093 this.instance._registerTimeout(setTimeout(function () { 35094 _this3.instance.selection.refreshBorders(); 35095 }, 0)); 35096 35097 _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'close', this).call(this); 35098 } 35099 35100 /** 35101 * @param {Boolean} [isCancelled=false] 35102 * @param {Boolean} [ctrlDown=false] 35103 */ 35104 35105 }, { 35106 key: 'finishEditing', 35107 value: function finishEditing() { 35108 var isCancelled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 35109 var ctrlDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 35110 35111 if (isCancelled) { 35112 // pressed ESC, restore original value 35113 // var value = this.instance.getDataAtCell(this.row, this.col); 35114 var value = this.originalValue; 35115 35116 if (value !== void 0) { 35117 this.setValue(value); 35118 } 35119 } 35120 this.hideDatepicker(); 35121 _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'finishEditing', this).call(this, isCancelled, ctrlDown); 35122 } 35123 35124 /** 35125 * Show data picker 35126 * 35127 * @param {Event} event 35128 */ 35129 35130 }, { 35131 key: 'showDatepicker', 35132 value: function showDatepicker(event) { 35133 this.$datePicker.config(this.getDatePickerConfig()); 35134 35135 var offset = this.TD.getBoundingClientRect(); 35136 var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat; 35137 var datePickerConfig = this.$datePicker.config(); 35138 var dateStr = void 0; 35139 var isMouseDown = this.instance.view.isMouseDown(); 35140 var isMeta = event ? (0, _unicode.isMetaKey)(event.keyCode) : false; 35141 35142 this.datePickerStyle.top = window.pageYOffset + offset.top + (0, _element.outerHeight)(this.TD) + 'px'; 35143 this.datePickerStyle.left = window.pageXOffset + offset.left + 'px'; 35144 35145 this.$datePicker._onInputFocus = function () {}; 35146 datePickerConfig.format = dateFormat; 35147 35148 if (this.originalValue) { 35149 dateStr = this.originalValue; 35150 35151 if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) { 35152 this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true); 35153 } 35154 35155 // workaround for date/time cells - pikaday resets the cell value to 12:00 AM by default, this will overwrite the value. 35156 if (this.getValue() !== this.originalValue) { 35157 this.setValue(this.originalValue); 35158 } 35159 35160 if (!isMeta && !isMouseDown) { 35161 this.setValue(''); 35162 } 35163 } else if (this.cellProperties.defaultDate) { 35164 dateStr = this.cellProperties.defaultDate; 35165 35166 datePickerConfig.defaultDate = dateStr; 35167 35168 if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) { 35169 this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true); 35170 } 35171 35172 if (!isMeta && !isMouseDown) { 35173 this.setValue(''); 35174 } 35175 } else { 35176 // if a default date is not defined, set a soft-default-date: display the current day and month in the 35177 // datepicker, but don't fill the editor input 35178 this.$datePicker.gotoToday(); 35179 } 35180 35181 this.datePickerStyle.display = 'block'; 35182 this.$datePicker.show(); 35183 } 35184 35185 /** 35186 * Hide data picker 35187 */ 35188 35189 }, { 35190 key: 'hideDatepicker', 35191 value: function hideDatepicker() { 35192 this.datePickerStyle.display = 'none'; 35193 this.$datePicker.hide(); 35194 } 35195 35196 /** 35197 * Get date picker options. 35198 * 35199 * @returns {Object} 35200 */ 35201 35202 }, { 35203 key: 'getDatePickerConfig', 35204 value: function getDatePickerConfig() { 35205 var _this4 = this; 35206 35207 var htInput = this.TEXTAREA; 35208 var options = {}; 35209 35210 if (this.cellProperties && this.cellProperties.datePickerConfig) { 35211 (0, _object.deepExtend)(options, this.cellProperties.datePickerConfig); 35212 } 35213 var origOnSelect = options.onSelect; 35214 var origOnClose = options.onClose; 35215 35216 options.field = htInput; 35217 options.trigger = htInput; 35218 options.container = this.datePicker; 35219 options.bound = false; 35220 options.format = options.format || this.defaultDateFormat; 35221 options.reposition = options.reposition || false; 35222 options.onSelect = function (dateStr) { 35223 if (!isNaN(dateStr.getTime())) { 35224 dateStr = (0, _moment2.default)(dateStr).format(_this4.cellProperties.dateFormat || _this4.defaultDateFormat); 35225 } 35226 _this4.setValue(dateStr); 35227 _this4.hideDatepicker(); 35228 35229 if (origOnSelect) { 35230 origOnSelect(); 35231 } 35232 }; 35233 options.onClose = function () { 35234 if (!_this4.parentDestroyed) { 35235 _this4.finishEditing(false); 35236 } 35237 if (origOnClose) { 35238 origOnClose(); 35239 } 35240 }; 35241 35242 return options; 35243 } 35244 }]); 35245 35246 return DateEditor; 35247}(_textEditor2.default); 35248 35249exports.default = DateEditor; 35250 35251/***/ }), 35252/* 326 */ 35253/***/ (function(module, exports, __webpack_require__) { 35254 35255"use strict"; 35256 35257 35258exports.__esModule = true; 35259 35260var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 35261 35262var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 35263 35264var _autocompleteEditor = __webpack_require__(263); 35265 35266var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor); 35267 35268var _pluginHooks = __webpack_require__(11); 35269 35270var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 35271 35272function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 35273 35274function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 35275 35276function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 35277 35278function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 35279 35280/** 35281 * @private 35282 * @editor DropdownEditor 35283 * @class DropdownEditor 35284 * @dependencies AutocompleteEditor 35285 */ 35286var DropdownEditor = function (_AutocompleteEditor) { 35287 _inherits(DropdownEditor, _AutocompleteEditor); 35288 35289 function DropdownEditor() { 35290 _classCallCheck(this, DropdownEditor); 35291 35292 return _possibleConstructorReturn(this, (DropdownEditor.__proto__ || Object.getPrototypeOf(DropdownEditor)).apply(this, arguments)); 35293 } 35294 35295 _createClass(DropdownEditor, [{ 35296 key: 'prepare', 35297 value: function prepare(row, col, prop, td, originalValue, cellProperties) { 35298 _get(DropdownEditor.prototype.__proto__ || Object.getPrototypeOf(DropdownEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties); 35299 this.cellProperties.filter = false; 35300 this.cellProperties.strict = true; 35301 } 35302 }]); 35303 35304 return DropdownEditor; 35305}(_autocompleteEditor2.default); 35306 35307_pluginHooks2.default.getSingleton().add('beforeValidate', function (value, row, col, source) { 35308 var cellMeta = this.getCellMeta(row, this.propToCol(col)); 35309 35310 if (cellMeta.editor === DropdownEditor) { 35311 if (cellMeta.strict === void 0) { 35312 cellMeta.filter = false; 35313 cellMeta.strict = true; 35314 } 35315 } 35316}); 35317 35318exports.default = DropdownEditor; 35319 35320/***/ }), 35321/* 327 */ 35322/***/ (function(module, exports, __webpack_require__) { 35323 35324"use strict"; 35325 35326 35327exports.__esModule = true; 35328 35329var _unicode = __webpack_require__(15); 35330 35331var _event = __webpack_require__(7); 35332 35333var _element = __webpack_require__(0); 35334 35335var _baseEditor = __webpack_require__(36); 35336 35337var _baseEditor2 = _interopRequireDefault(_baseEditor); 35338 35339var _eventManager = __webpack_require__(4); 35340 35341var _eventManager2 = _interopRequireDefault(_eventManager); 35342 35343function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 35344 35345var MobileTextEditor = _baseEditor2.default.prototype.extend(); 35346var domDimensionsCache = {}; 35347 35348/** 35349 * @private 35350 * @editor MobileTextEditor 35351 * @class MobileTextEditor 35352 */ 35353var createControls = function createControls() { 35354 this.controls = {}; 35355 35356 this.controls.leftButton = document.createElement('DIV'); 35357 this.controls.leftButton.className = 'leftButton'; 35358 this.controls.rightButton = document.createElement('DIV'); 35359 this.controls.rightButton.className = 'rightButton'; 35360 this.controls.upButton = document.createElement('DIV'); 35361 this.controls.upButton.className = 'upButton'; 35362 this.controls.downButton = document.createElement('DIV'); 35363 this.controls.downButton.className = 'downButton'; 35364 35365 for (var button in this.controls) { 35366 if (Object.prototype.hasOwnProperty.call(this.controls, button)) { 35367 this.positionControls.appendChild(this.controls[button]); 35368 } 35369 } 35370}; 35371 35372MobileTextEditor.prototype.valueChanged = function () { 35373 return this.initValue != this.getValue(); 35374}; 35375 35376MobileTextEditor.prototype.init = function () { 35377 var that = this; 35378 this.eventManager = new _eventManager2.default(this.instance); 35379 35380 this.createElements(); 35381 this.bindEvents(); 35382 35383 this.instance.addHook('afterDestroy', function () { 35384 that.destroy(); 35385 }); 35386}; 35387 35388MobileTextEditor.prototype.getValue = function () { 35389 return this.TEXTAREA.value; 35390}; 35391 35392MobileTextEditor.prototype.setValue = function (newValue) { 35393 this.initValue = newValue; 35394 35395 this.TEXTAREA.value = newValue; 35396}; 35397 35398MobileTextEditor.prototype.createElements = function () { 35399 this.editorContainer = document.createElement('DIV'); 35400 this.editorContainer.className = 'htMobileEditorContainer'; 35401 35402 this.cellPointer = document.createElement('DIV'); 35403 this.cellPointer.className = 'cellPointer'; 35404 35405 this.moveHandle = document.createElement('DIV'); 35406 this.moveHandle.className = 'moveHandle'; 35407 35408 this.inputPane = document.createElement('DIV'); 35409 this.inputPane.className = 'inputs'; 35410 35411 this.positionControls = document.createElement('DIV'); 35412 this.positionControls.className = 'positionControls'; 35413 35414 this.TEXTAREA = document.createElement('TEXTAREA'); 35415 (0, _element.addClass)(this.TEXTAREA, 'handsontableInput'); 35416 35417 this.inputPane.appendChild(this.TEXTAREA); 35418 35419 this.editorContainer.appendChild(this.cellPointer); 35420 this.editorContainer.appendChild(this.moveHandle); 35421 this.editorContainer.appendChild(this.inputPane); 35422 this.editorContainer.appendChild(this.positionControls); 35423 35424 createControls.call(this); 35425 35426 document.body.appendChild(this.editorContainer); 35427}; 35428 35429MobileTextEditor.prototype.onBeforeKeyDown = function (event) { 35430 var instance = this; 35431 var that = instance.getActiveEditor(); 35432 35433 if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) { 35434 return; 35435 } 35436 35437 switch (event.keyCode) { 35438 case _unicode.KEY_CODES.ENTER: 35439 that.close(); 35440 event.preventDefault(); // don't add newline to field 35441 break; 35442 case _unicode.KEY_CODES.BACKSPACE: 35443 (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context) 35444 break; 35445 default: 35446 break; 35447 } 35448}; 35449 35450MobileTextEditor.prototype.open = function () { 35451 this.instance.addHook('beforeKeyDown', this.onBeforeKeyDown); 35452 35453 (0, _element.addClass)(this.editorContainer, 'active'); 35454 (0, _element.removeClass)(this.cellPointer, 'hidden'); 35455 35456 this.updateEditorPosition(); 35457}; 35458 35459MobileTextEditor.prototype.focus = function () { 35460 this.TEXTAREA.focus(); 35461 (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length); 35462}; 35463 35464MobileTextEditor.prototype.close = function () { 35465 this.TEXTAREA.blur(); 35466 this.instance.removeHook('beforeKeyDown', this.onBeforeKeyDown); 35467 35468 (0, _element.removeClass)(this.editorContainer, 'active'); 35469}; 35470 35471MobileTextEditor.prototype.scrollToView = function () { 35472 var coords = this.instance.getSelectedRange().highlight; 35473 this.instance.view.scrollViewport(coords); 35474}; 35475 35476MobileTextEditor.prototype.hideCellPointer = function () { 35477 if (!(0, _element.hasClass)(this.cellPointer, 'hidden')) { 35478 (0, _element.addClass)(this.cellPointer, 'hidden'); 35479 } 35480}; 35481 35482MobileTextEditor.prototype.updateEditorPosition = function (x, y) { 35483 if (x && y) { 35484 x = parseInt(x, 10); 35485 y = parseInt(y, 10); 35486 35487 this.editorContainer.style.top = y + 'px'; 35488 this.editorContainer.style.left = x + 'px'; 35489 } else { 35490 var selection = this.instance.getSelected(), 35491 selectedCell = this.instance.getCell(selection[0], selection[1]); 35492 35493 // cache sizes 35494 if (!domDimensionsCache.cellPointer) { 35495 domDimensionsCache.cellPointer = { 35496 height: (0, _element.outerHeight)(this.cellPointer), 35497 width: (0, _element.outerWidth)(this.cellPointer) 35498 }; 35499 } 35500 if (!domDimensionsCache.editorContainer) { 35501 domDimensionsCache.editorContainer = { 35502 width: (0, _element.outerWidth)(this.editorContainer) 35503 }; 35504 } 35505 35506 if (selectedCell !== undefined) { 35507 var scrollLeft = this.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer == window ? 0 : (0, _element.getScrollLeft)(this.instance.view.wt.wtOverlays.leftOverlay.holder); 35508 var scrollTop = this.instance.view.wt.wtOverlays.topOverlay.trimmingContainer == window ? 0 : (0, _element.getScrollTop)(this.instance.view.wt.wtOverlays.topOverlay.holder); 35509 35510 var selectedCellOffset = (0, _element.offset)(selectedCell), 35511 selectedCellWidth = (0, _element.outerWidth)(selectedCell), 35512 currentScrollPosition = { 35513 x: scrollLeft, 35514 y: scrollTop 35515 }; 35516 35517 this.editorContainer.style.top = parseInt(selectedCellOffset.top + (0, _element.outerHeight)(selectedCell) - currentScrollPosition.y + domDimensionsCache.cellPointer.height, 10) + 'px'; 35518 this.editorContainer.style.left = parseInt(window.innerWidth / 2 - domDimensionsCache.editorContainer.width / 2, 10) + 'px'; 35519 35520 if (selectedCellOffset.left + selectedCellWidth / 2 > parseInt(this.editorContainer.style.left, 10) + domDimensionsCache.editorContainer.width) { 35521 this.editorContainer.style.left = window.innerWidth - domDimensionsCache.editorContainer.width + 'px'; 35522 } else if (selectedCellOffset.left + selectedCellWidth / 2 < parseInt(this.editorContainer.style.left, 10) + 20) { 35523 this.editorContainer.style.left = 0 + 'px'; 35524 } 35525 35526 this.cellPointer.style.left = parseInt(selectedCellOffset.left - domDimensionsCache.cellPointer.width / 2 - (0, _element.offset)(this.editorContainer).left + selectedCellWidth / 2 - currentScrollPosition.x, 10) + 'px'; 35527 } 35528 } 35529}; 35530 35531MobileTextEditor.prototype.updateEditorData = function () { 35532 var selected = this.instance.getSelected(), 35533 selectedValue = this.instance.getDataAtCell(selected[0], selected[1]); 35534 35535 this.row = selected[0]; 35536 this.col = selected[1]; 35537 this.setValue(selectedValue); 35538 this.updateEditorPosition(); 35539}; 35540 35541MobileTextEditor.prototype.prepareAndSave = function () { 35542 var val; 35543 35544 if (!this.valueChanged()) { 35545 return; 35546 } 35547 35548 if (this.instance.getSettings().trimWhitespace) { 35549 val = [[String.prototype.trim.call(this.getValue())]]; 35550 } else { 35551 val = [[this.getValue()]]; 35552 } 35553 35554 this.saveValue(val); 35555}; 35556 35557MobileTextEditor.prototype.bindEvents = function () { 35558 var that = this; 35559 35560 this.eventManager.addEventListener(this.controls.leftButton, 'touchend', function (event) { 35561 that.prepareAndSave(); 35562 that.instance.selection.transformStart(0, -1, null, true); 35563 that.updateEditorData(); 35564 event.preventDefault(); 35565 }); 35566 this.eventManager.addEventListener(this.controls.rightButton, 'touchend', function (event) { 35567 that.prepareAndSave(); 35568 that.instance.selection.transformStart(0, 1, null, true); 35569 that.updateEditorData(); 35570 event.preventDefault(); 35571 }); 35572 this.eventManager.addEventListener(this.controls.upButton, 'touchend', function (event) { 35573 that.prepareAndSave(); 35574 that.instance.selection.transformStart(-1, 0, null, true); 35575 that.updateEditorData(); 35576 event.preventDefault(); 35577 }); 35578 this.eventManager.addEventListener(this.controls.downButton, 'touchend', function (event) { 35579 that.prepareAndSave(); 35580 that.instance.selection.transformStart(1, 0, null, true); 35581 that.updateEditorData(); 35582 event.preventDefault(); 35583 }); 35584 35585 this.eventManager.addEventListener(this.moveHandle, 'touchstart', function (event) { 35586 if (event.touches.length == 1) { 35587 var touch = event.touches[0]; 35588 var onTouchPosition = { 35589 x: that.editorContainer.offsetLeft, 35590 y: that.editorContainer.offsetTop 35591 }; 35592 var onTouchOffset = { 35593 x: touch.pageX - onTouchPosition.x, 35594 y: touch.pageY - onTouchPosition.y 35595 }; 35596 35597 that.eventManager.addEventListener(this, 'touchmove', function (event) { 35598 var touch = event.touches[0]; 35599 that.updateEditorPosition(touch.pageX - onTouchOffset.x, touch.pageY - onTouchOffset.y); 35600 that.hideCellPointer(); 35601 event.preventDefault(); 35602 }); 35603 } 35604 }); 35605 35606 this.eventManager.addEventListener(document.body, 'touchend', function (event) { 35607 if (!(0, _element.isChildOf)(event.target, that.editorContainer) && !(0, _element.isChildOf)(event.target, that.instance.rootElement)) { 35608 that.close(); 35609 } 35610 }); 35611 35612 this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.leftOverlay.holder, 'scroll', function (event) { 35613 if (that.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer != window) { 35614 that.hideCellPointer(); 35615 } 35616 }); 35617 35618 this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.topOverlay.holder, 'scroll', function (event) { 35619 if (that.instance.view.wt.wtOverlays.topOverlay.trimmingContainer != window) { 35620 that.hideCellPointer(); 35621 } 35622 }); 35623}; 35624 35625MobileTextEditor.prototype.destroy = function () { 35626 this.eventManager.clear(); 35627 35628 this.editorContainer.parentNode.removeChild(this.editorContainer); 35629}; 35630 35631exports.default = MobileTextEditor; 35632 35633/***/ }), 35634/* 328 */ 35635/***/ (function(module, exports, __webpack_require__) { 35636 35637"use strict"; 35638 35639 35640exports.__esModule = true; 35641 35642var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 35643 35644var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 35645 35646var _numbro = __webpack_require__(52); 35647 35648var _numbro2 = _interopRequireDefault(_numbro); 35649 35650var _textEditor = __webpack_require__(44); 35651 35652var _textEditor2 = _interopRequireDefault(_textEditor); 35653 35654function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 35655 35656function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 35657 35658function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 35659 35660function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 35661 35662/** 35663 * @private 35664 * @editor NumericEditor 35665 * @class NumericEditor 35666 * @dependencies TextEditor numbro 35667 */ 35668var NumericEditor = function (_TextEditor) { 35669 _inherits(NumericEditor, _TextEditor); 35670 35671 function NumericEditor() { 35672 _classCallCheck(this, NumericEditor); 35673 35674 return _possibleConstructorReturn(this, (NumericEditor.__proto__ || Object.getPrototypeOf(NumericEditor)).apply(this, arguments)); 35675 } 35676 35677 _createClass(NumericEditor, [{ 35678 key: 'beginEditing', 35679 35680 /** 35681 * @param {*} initialValue 35682 */ 35683 value: function beginEditing(initialValue) { 35684 if (typeof initialValue === 'undefined' && this.originalValue) { 35685 if (typeof this.cellProperties.language !== 'undefined') { 35686 _numbro2.default.culture(this.cellProperties.language); 35687 } 35688 var decimalDelimiter = _numbro2.default.cultureData().delimiters.decimal; 35689 initialValue = ('' + this.originalValue).replace('.', decimalDelimiter); 35690 } 35691 _get(NumericEditor.prototype.__proto__ || Object.getPrototypeOf(NumericEditor.prototype), 'beginEditing', this).call(this, initialValue); 35692 } 35693 }]); 35694 35695 return NumericEditor; 35696}(_textEditor2.default); 35697 35698exports.default = NumericEditor; 35699 35700/***/ }), 35701/* 329 */ 35702/***/ (function(module, exports, __webpack_require__) { 35703 35704"use strict"; 35705 35706 35707exports.__esModule = true; 35708 35709var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 35710 35711var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 35712 35713var _element = __webpack_require__(0); 35714 35715var _textEditor = __webpack_require__(44); 35716 35717var _textEditor2 = _interopRequireDefault(_textEditor); 35718 35719function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 35720 35721function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 35722 35723function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 35724 35725function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 35726 35727/** 35728 * @private 35729 * @editor PasswordEditor 35730 * @class PasswordEditor 35731 * @dependencies TextEditor 35732 */ 35733var PasswordEditor = function (_TextEditor) { 35734 _inherits(PasswordEditor, _TextEditor); 35735 35736 function PasswordEditor() { 35737 _classCallCheck(this, PasswordEditor); 35738 35739 return _possibleConstructorReturn(this, (PasswordEditor.__proto__ || Object.getPrototypeOf(PasswordEditor)).apply(this, arguments)); 35740 } 35741 35742 _createClass(PasswordEditor, [{ 35743 key: 'createElements', 35744 value: function createElements() { 35745 _get(PasswordEditor.prototype.__proto__ || Object.getPrototypeOf(PasswordEditor.prototype), 'createElements', this).call(this); 35746 35747 this.TEXTAREA = document.createElement('input'); 35748 this.TEXTAREA.setAttribute('type', 'password'); 35749 this.TEXTAREA.className = 'handsontableInput'; 35750 this.textareaStyle = this.TEXTAREA.style; 35751 this.textareaStyle.width = 0; 35752 this.textareaStyle.height = 0; 35753 35754 (0, _element.empty)(this.TEXTAREA_PARENT); 35755 this.TEXTAREA_PARENT.appendChild(this.TEXTAREA); 35756 } 35757 }]); 35758 35759 return PasswordEditor; 35760}(_textEditor2.default); 35761 35762exports.default = PasswordEditor; 35763 35764/***/ }), 35765/* 330 */ 35766/***/ (function(module, exports, __webpack_require__) { 35767 35768"use strict"; 35769 35770 35771exports.__esModule = true; 35772 35773var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 35774 35775var _element = __webpack_require__(0); 35776 35777var _event = __webpack_require__(7); 35778 35779var _unicode = __webpack_require__(15); 35780 35781var _baseEditor = __webpack_require__(36); 35782 35783var _baseEditor2 = _interopRequireDefault(_baseEditor); 35784 35785function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 35786 35787var SelectEditor = _baseEditor2.default.prototype.extend(); 35788 35789/** 35790 * @private 35791 * @editor SelectEditor 35792 * @class SelectEditor 35793 */ 35794SelectEditor.prototype.init = function () { 35795 this.select = document.createElement('SELECT'); 35796 (0, _element.addClass)(this.select, 'htSelectEditor'); 35797 this.select.style.display = 'none'; 35798 this.instance.rootElement.appendChild(this.select); 35799 this.registerHooks(); 35800}; 35801 35802SelectEditor.prototype.registerHooks = function () { 35803 var _this = this; 35804 35805 this.instance.addHook('afterScrollHorizontally', function () { 35806 return _this.refreshDimensions(); 35807 }); 35808 this.instance.addHook('afterScrollVertically', function () { 35809 return _this.refreshDimensions(); 35810 }); 35811 this.instance.addHook('afterColumnResize', function () { 35812 return _this.refreshDimensions(); 35813 }); 35814 this.instance.addHook('afterRowResize', function () { 35815 return _this.refreshDimensions(); 35816 }); 35817}; 35818 35819SelectEditor.prototype.prepare = function () { 35820 _baseEditor2.default.prototype.prepare.apply(this, arguments); 35821 35822 var selectOptions = this.cellProperties.selectOptions; 35823 var options; 35824 35825 if (typeof selectOptions == 'function') { 35826 options = this.prepareOptions(selectOptions(this.row, this.col, this.prop)); 35827 } else { 35828 options = this.prepareOptions(selectOptions); 35829 } 35830 35831 (0, _element.empty)(this.select); 35832 35833 for (var option in options) { 35834 if (Object.prototype.hasOwnProperty.call(options, option)) { 35835 var optionElement = document.createElement('OPTION'); 35836 optionElement.value = option; 35837 (0, _element.fastInnerHTML)(optionElement, options[option]); 35838 this.select.appendChild(optionElement); 35839 } 35840 } 35841}; 35842 35843SelectEditor.prototype.prepareOptions = function (optionsToPrepare) { 35844 var preparedOptions = {}; 35845 35846 if (Array.isArray(optionsToPrepare)) { 35847 for (var i = 0, len = optionsToPrepare.length; i < len; i++) { 35848 preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i]; 35849 } 35850 } else if ((typeof optionsToPrepare === 'undefined' ? 'undefined' : _typeof(optionsToPrepare)) == 'object') { 35851 preparedOptions = optionsToPrepare; 35852 } 35853 35854 return preparedOptions; 35855}; 35856 35857SelectEditor.prototype.getValue = function () { 35858 return this.select.value; 35859}; 35860 35861SelectEditor.prototype.setValue = function (value) { 35862 this.select.value = value; 35863}; 35864 35865var onBeforeKeyDown = function onBeforeKeyDown(event) { 35866 var instance = this; 35867 var editor = instance.getActiveEditor(); 35868 35869 switch (event.keyCode) { 35870 case _unicode.KEY_CODES.ARROW_UP: 35871 var previousOptionIndex = editor.select.selectedIndex - 1; 35872 if (previousOptionIndex >= 0) { 35873 editor.select[previousOptionIndex].selected = true; 35874 } 35875 35876 (0, _event.stopImmediatePropagation)(event); 35877 event.preventDefault(); 35878 break; 35879 35880 case _unicode.KEY_CODES.ARROW_DOWN: 35881 var nextOptionIndex = editor.select.selectedIndex + 1; 35882 if (nextOptionIndex <= editor.select.length - 1) { 35883 editor.select[nextOptionIndex].selected = true; 35884 } 35885 35886 (0, _event.stopImmediatePropagation)(event); 35887 event.preventDefault(); 35888 break; 35889 default: 35890 break; 35891 } 35892}; 35893 35894SelectEditor.prototype.open = function () { 35895 this._opened = true; 35896 this.refreshDimensions(); 35897 this.select.style.display = ''; 35898 this.instance.addHook('beforeKeyDown', onBeforeKeyDown); 35899}; 35900 35901SelectEditor.prototype.close = function () { 35902 this._opened = false; 35903 this.select.style.display = 'none'; 35904 this.instance.removeHook('beforeKeyDown', onBeforeKeyDown); 35905}; 35906 35907SelectEditor.prototype.focus = function () { 35908 this.select.focus(); 35909}; 35910 35911SelectEditor.prototype.refreshValue = function () { 35912 var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop); 35913 this.originalValue = sourceData; 35914 35915 this.setValue(sourceData); 35916 this.refreshDimensions(); 35917}; 35918 35919SelectEditor.prototype.refreshDimensions = function () { 35920 if (this.state !== _baseEditor.EditorState.EDITING) { 35921 return; 35922 } 35923 this.TD = this.getEditedCell(); 35924 35925 // TD is outside of the viewport. 35926 if (!this.TD) { 35927 this.close(); 35928 35929 return; 35930 } 35931 var width = (0, _element.outerWidth)(this.TD) + 1, 35932 height = (0, _element.outerHeight)(this.TD) + 1, 35933 currentOffset = (0, _element.offset)(this.TD), 35934 containerOffset = (0, _element.offset)(this.instance.rootElement), 35935 scrollableContainer = (0, _element.getScrollableElement)(this.TD), 35936 editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0), 35937 editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0), 35938 editorSection = this.checkEditorSection(), 35939 cssTransformOffset; 35940 35941 var settings = this.instance.getSettings(); 35942 var rowHeadersCount = settings.rowHeaders ? 1 : 0; 35943 var colHeadersCount = settings.colHeaders ? 1 : 0; 35944 35945 switch (editorSection) { 35946 case 'top': 35947 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode); 35948 break; 35949 case 'left': 35950 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode); 35951 break; 35952 case 'top-left-corner': 35953 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode); 35954 break; 35955 case 'bottom-left-corner': 35956 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode); 35957 break; 35958 case 'bottom': 35959 cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode); 35960 break; 35961 default: 35962 break; 35963 } 35964 if (this.instance.getSelected()[0] === 0) { 35965 editTop += 1; 35966 } 35967 35968 if (this.instance.getSelected()[1] === 0) { 35969 editLeft += 1; 35970 } 35971 35972 var selectStyle = this.select.style; 35973 35974 if (cssTransformOffset && cssTransformOffset != -1) { 35975 selectStyle[cssTransformOffset[0]] = cssTransformOffset[1]; 35976 } else { 35977 (0, _element.resetCssTransform)(this.select); 35978 } 35979 var cellComputedStyle = (0, _element.getComputedStyle)(this.TD); 35980 35981 if (parseInt(cellComputedStyle.borderTopWidth, 10) > 0) { 35982 height -= 1; 35983 } 35984 if (parseInt(cellComputedStyle.borderLeftWidth, 10) > 0) { 35985 width -= 1; 35986 } 35987 35988 selectStyle.height = height + 'px'; 35989 selectStyle.minWidth = width + 'px'; 35990 selectStyle.top = editTop + 'px'; 35991 selectStyle.left = editLeft + 'px'; 35992 selectStyle.margin = '0px'; 35993}; 35994 35995SelectEditor.prototype.getEditedCell = function () { 35996 var editorSection = this.checkEditorSection(), 35997 editedCell; 35998 35999 switch (editorSection) { 36000 case 'top': 36001 editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({ 36002 row: this.row, 36003 col: this.col 36004 }); 36005 this.select.style.zIndex = 101; 36006 break; 36007 case 'corner': 36008 editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({ 36009 row: this.row, 36010 col: this.col 36011 }); 36012 this.select.style.zIndex = 103; 36013 break; 36014 case 'left': 36015 editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({ 36016 row: this.row, 36017 col: this.col 36018 }); 36019 this.select.style.zIndex = 102; 36020 break; 36021 default: 36022 editedCell = this.instance.getCell(this.row, this.col); 36023 this.select.style.zIndex = ''; 36024 break; 36025 } 36026 36027 return editedCell != -1 && editedCell != -2 ? editedCell : void 0; 36028}; 36029 36030exports.default = SelectEditor; 36031 36032/***/ }), 36033/* 331 */ 36034/***/ (function(module, exports, __webpack_require__) { 36035 36036"use strict"; 36037 36038 36039exports.__esModule = true; 36040exports.toSingleLine = toSingleLine; 36041 36042var _array = __webpack_require__(2); 36043 36044/** 36045 * Tags a multiline string and return new one without line break characters and following spaces. 36046 * 36047 * @param {Array} strings Parts of the entire string without expressions. 36048 * @param {...String} expressions Expressions converted to strings, which are added to the entire string. 36049 * @returns {String} 36050 */ 36051function toSingleLine(strings) { 36052 for (var _len = arguments.length, expressions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 36053 expressions[_key - 1] = arguments[_key]; 36054 } 36055 36056 var result = (0, _array.arrayReduce)(strings, function (previousValue, currentValue, index) { 36057 36058 var valueWithoutWhiteSpaces = currentValue.replace(/(?:\r?\n\s+)/g, ''); 36059 var expressionForIndex = expressions[index] ? expressions[index] : ''; 36060 36061 return previousValue + valueWithoutWhiteSpaces + expressionForIndex; 36062 }, ''); 36063 36064 return result.trim(); 36065} /* eslint-disable import/prefer-default-export */ 36066 36067/***/ }), 36068/* 332 */ 36069/***/ (function(module, exports, __webpack_require__) { 36070 36071"use strict"; 36072 36073 36074__webpack_require__(98); 36075 36076__webpack_require__(115); 36077 36078__webpack_require__(124); 36079 36080__webpack_require__(125); 36081 36082__webpack_require__(109); 36083 36084__webpack_require__(123); 36085 36086__webpack_require__(106); 36087 36088__webpack_require__(107); 36089 36090__webpack_require__(108); 36091 36092__webpack_require__(97); 36093 36094__webpack_require__(120); 36095 36096__webpack_require__(118); 36097 36098__webpack_require__(116); 36099 36100__webpack_require__(121); 36101 36102__webpack_require__(122); 36103 36104__webpack_require__(117); 36105 36106__webpack_require__(119); 36107 36108__webpack_require__(110); 36109 36110__webpack_require__(111); 36111 36112__webpack_require__(112); 36113 36114__webpack_require__(114); 36115 36116__webpack_require__(113); 36117 36118__webpack_require__(95); 36119 36120__webpack_require__(96); 36121 36122__webpack_require__(91); 36123 36124__webpack_require__(94); 36125 36126__webpack_require__(93); 36127 36128__webpack_require__(92); 36129 36130__webpack_require__(70); 36131 36132__webpack_require__(100); 36133 36134__webpack_require__(101); 36135 36136__webpack_require__(103); 36137 36138__webpack_require__(102); 36139 36140__webpack_require__(99); 36141 36142__webpack_require__(105); 36143 36144__webpack_require__(104); 36145 36146__webpack_require__(126); 36147 36148__webpack_require__(129); 36149 36150__webpack_require__(127); 36151 36152__webpack_require__(128); 36153 36154__webpack_require__(131); 36155 36156__webpack_require__(130); 36157 36158__webpack_require__(133); 36159 36160__webpack_require__(132); 36161 36162__webpack_require__(293); 36163 36164__webpack_require__(294); 36165 36166__webpack_require__(295); 36167 36168var _editors = __webpack_require__(13); 36169 36170var _renderers = __webpack_require__(6); 36171 36172var _validators = __webpack_require__(24); 36173 36174var _cellTypes = __webpack_require__(65); 36175 36176var _core = __webpack_require__(66); 36177 36178var _core2 = _interopRequireDefault(_core); 36179 36180var _jquery = __webpack_require__(296); 36181 36182var _jquery2 = _interopRequireDefault(_jquery); 36183 36184var _eventManager = __webpack_require__(4); 36185 36186var _eventManager2 = _interopRequireDefault(_eventManager); 36187 36188var _pluginHooks = __webpack_require__(11); 36189 36190var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 36191 36192var _ghostTable = __webpack_require__(69); 36193 36194var _ghostTable2 = _interopRequireDefault(_ghostTable); 36195 36196var _array = __webpack_require__(2); 36197 36198var arrayHelpers = _interopRequireWildcard(_array); 36199 36200var _browser = __webpack_require__(22); 36201 36202var browserHelpers = _interopRequireWildcard(_browser); 36203 36204var _data = __webpack_require__(67); 36205 36206var dataHelpers = _interopRequireWildcard(_data); 36207 36208var _date = __webpack_require__(89); 36209 36210var dateHelpers = _interopRequireWildcard(_date); 36211 36212var _feature = __webpack_require__(34); 36213 36214var featureHelpers = _interopRequireWildcard(_feature); 36215 36216var _function = __webpack_require__(35); 36217 36218var functionHelpers = _interopRequireWildcard(_function); 36219 36220var _mixed = __webpack_require__(23); 36221 36222var mixedHelpers = _interopRequireWildcard(_mixed); 36223 36224var _number = __webpack_require__(5); 36225 36226var numberHelpers = _interopRequireWildcard(_number); 36227 36228var _object = __webpack_require__(3); 36229 36230var objectHelpers = _interopRequireWildcard(_object); 36231 36232var _setting = __webpack_require__(68); 36233 36234var settingHelpers = _interopRequireWildcard(_setting); 36235 36236var _string = __webpack_require__(28); 36237 36238var stringHelpers = _interopRequireWildcard(_string); 36239 36240var _unicode = __webpack_require__(15); 36241 36242var unicodeHelpers = _interopRequireWildcard(_unicode); 36243 36244var _element = __webpack_require__(0); 36245 36246var domHelpers = _interopRequireWildcard(_element); 36247 36248var _event = __webpack_require__(7); 36249 36250var domEventHelpers = _interopRequireWildcard(_event); 36251 36252var _index = __webpack_require__(297); 36253 36254var plugins = _interopRequireWildcard(_index); 36255 36256var _plugins = __webpack_require__(9); 36257 36258var _defaultSettings = __webpack_require__(88); 36259 36260var _defaultSettings2 = _interopRequireDefault(_defaultSettings); 36261 36262var _rootInstance = __webpack_require__(90); 36263 36264function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 36265 36266function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 36267 36268function Handsontable(rootElement, userSettings) { 36269 var instance = new _core2.default(rootElement, userSettings || {}, _rootInstance.rootInstanceSymbol); 36270 36271 instance.init(); 36272 36273 return instance; 36274} 36275 36276(0, _jquery2.default)(Handsontable); 36277 36278Handsontable.Core = _core2.default; 36279Handsontable.DefaultSettings = _defaultSettings2.default; 36280Handsontable.EventManager = _eventManager2.default; 36281Handsontable._getListenersCounter = _eventManager.getListenersCounter; // For MemoryLeak tests 36282 36283Handsontable.buildDate = undefined; 36284Handsontable.packageName = undefined; 36285Handsontable.version = undefined; 36286 36287var baseVersion = undefined; 36288 36289if (baseVersion) { 36290 Handsontable.baseVersion = baseVersion; 36291} 36292 36293// Export Hooks singleton 36294Handsontable.hooks = _pluginHooks2.default.getSingleton(); 36295 36296// TODO: Remove this exports after rewrite tests about this module 36297Handsontable.__GhostTable = _ghostTable2.default; 36298// 36299 36300// Export all helpers to the Handsontable object 36301var HELPERS = [arrayHelpers, browserHelpers, dataHelpers, dateHelpers, featureHelpers, functionHelpers, mixedHelpers, numberHelpers, objectHelpers, settingHelpers, stringHelpers, unicodeHelpers]; 36302var DOM = [domHelpers, domEventHelpers]; 36303 36304Handsontable.helper = {}; 36305Handsontable.dom = {}; 36306 36307// Fill general helpers. 36308arrayHelpers.arrayEach(HELPERS, function (helper) { 36309 arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) { 36310 if (key.charAt(0) !== '_') { 36311 Handsontable.helper[key] = helper[key]; 36312 } 36313 }); 36314}); 36315 36316// Fill DOM helpers. 36317arrayHelpers.arrayEach(DOM, function (helper) { 36318 arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) { 36319 if (key.charAt(0) !== '_') { 36320 Handsontable.dom[key] = helper[key]; 36321 } 36322 }); 36323}); 36324 36325// Export cell types. 36326Handsontable.cellTypes = {}; 36327 36328arrayHelpers.arrayEach((0, _cellTypes.getRegisteredCellTypeNames)(), function (cellTypeName) { 36329 Handsontable.cellTypes[cellTypeName] = (0, _cellTypes.getCellType)(cellTypeName); 36330}); 36331 36332Handsontable.cellTypes.registerCellType = _cellTypes.registerCellType; 36333Handsontable.cellTypes.getCellType = _cellTypes.getCellType; 36334 36335// Export all registered editors from the Handsontable. 36336Handsontable.editors = {}; 36337 36338arrayHelpers.arrayEach((0, _editors.getRegisteredEditorNames)(), function (editorName) { 36339 Handsontable.editors[stringHelpers.toUpperCaseFirst(editorName) + 'Editor'] = (0, _editors.getEditor)(editorName); 36340}); 36341 36342Handsontable.editors.registerEditor = _editors.registerEditor; 36343Handsontable.editors.getEditor = _editors.getEditor; 36344 36345// Export all registered renderers from the Handsontable. 36346Handsontable.renderers = {}; 36347 36348arrayHelpers.arrayEach((0, _renderers.getRegisteredRendererNames)(), function (rendererName) { 36349 var renderer = (0, _renderers.getRenderer)(rendererName); 36350 36351 if (rendererName === 'base') { 36352 Handsontable.renderers.cellDecorator = renderer; 36353 } 36354 Handsontable.renderers[stringHelpers.toUpperCaseFirst(rendererName) + 'Renderer'] = renderer; 36355}); 36356 36357Handsontable.renderers.registerRenderer = _renderers.registerRenderer; 36358Handsontable.renderers.getRenderer = _renderers.getRenderer; 36359 36360// Export all registered validators from the Handsontable. 36361Handsontable.validators = {}; 36362 36363arrayHelpers.arrayEach((0, _validators.getRegisteredValidatorNames)(), function (validatorName) { 36364 Handsontable.validators[stringHelpers.toUpperCaseFirst(validatorName) + 'Validator'] = (0, _validators.getValidator)(validatorName); 36365}); 36366 36367Handsontable.validators.registerValidator = _validators.registerValidator; 36368Handsontable.validators.getValidator = _validators.getValidator; 36369 36370// Export all registered plugins from the Handsontable. 36371Handsontable.plugins = {}; 36372 36373arrayHelpers.arrayEach(Object.getOwnPropertyNames(plugins), function (pluginName) { 36374 var plugin = plugins[pluginName]; 36375 36376 if (pluginName === 'Base') { 36377 Handsontable.plugins[pluginName + 'Plugin'] = plugin; 36378 } else { 36379 Handsontable.plugins[pluginName] = plugin; 36380 } 36381}); 36382 36383Handsontable.plugins.registerPlugin = _plugins.registerPlugin; 36384 36385// Export Handsontable 36386module.exports = Handsontable; 36387 36388/***/ }), 36389/* 333 */ 36390/***/ (function(module, exports, __webpack_require__) { 36391 36392"use strict"; 36393 36394 36395exports.__esModule = true; 36396 36397var _array = __webpack_require__(2); 36398 36399var _object = __webpack_require__(3); 36400 36401var MIXIN_NAME = 'localHooks'; 36402 36403/** 36404 * Mixin object to extend objects functionality for local hooks. 36405 * 36406 * @type {Object} 36407 */ 36408var localHooks = { 36409 /** 36410 * Internal hooks storage. 36411 */ 36412 _localHooks: Object.create(null), 36413 36414 /** 36415 * Add hook to the collection. 36416 * 36417 * @param {String} key Hook name. 36418 * @param {Function} callback Hook callback 36419 */ 36420 addLocalHook: function addLocalHook(key, callback) { 36421 if (!this._localHooks[key]) { 36422 this._localHooks[key] = []; 36423 } 36424 this._localHooks[key].push(callback); 36425 }, 36426 36427 36428 /** 36429 * Run hooks. 36430 * 36431 * @param {String} key Hook name. 36432 * @param {*} params 36433 */ 36434 runLocalHooks: function runLocalHooks(key) { 36435 var _this = this; 36436 36437 for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 36438 params[_key - 1] = arguments[_key]; 36439 } 36440 36441 if (this._localHooks[key]) { 36442 (0, _array.arrayEach)(this._localHooks[key], function (callback) { 36443 return callback.apply(_this, params); 36444 }); 36445 } 36446 }, 36447 36448 36449 /** 36450 * Clear all added hooks. 36451 */ 36452 clearLocalHooks: function clearLocalHooks() { 36453 this._localHooks = {}; 36454 } 36455}; 36456 36457(0, _object.defineGetter)(localHooks, 'MIXIN_NAME', MIXIN_NAME, { 36458 writable: false, 36459 enumerable: false 36460}); 36461 36462exports.default = localHooks; 36463 36464/***/ }), 36465/* 334 */ 36466/***/ (function(module, exports, __webpack_require__) { 36467 36468"use strict"; 36469 36470 36471exports.__esModule = true; 36472 36473var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 36474 36475function MultiMap() { 36476 var map = { 36477 arrayMap: [], 36478 weakMap: new WeakMap() 36479 }; 36480 36481 return { 36482 get: function get(key) { 36483 if (canBeAnArrayMapKey(key)) { 36484 return map.arrayMap[key]; 36485 } else if (canBeAWeakMapKey(key)) { 36486 return map.weakMap.get(key); 36487 } 36488 }, 36489 set: function set(key, value) { 36490 if (canBeAnArrayMapKey(key)) { 36491 map.arrayMap[key] = value; 36492 } else if (canBeAWeakMapKey(key)) { 36493 map.weakMap.set(key, value); 36494 } else { 36495 throw new Error('Invalid key type'); 36496 } 36497 }, 36498 delete: function _delete(key) { 36499 if (canBeAnArrayMapKey(key)) { 36500 delete map.arrayMap[key]; 36501 } else if (canBeAWeakMapKey(key)) { 36502 map.weakMap.delete(key); 36503 } 36504 } 36505 }; 36506 36507 function canBeAnArrayMapKey(obj) { 36508 return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number'); 36509 } 36510 36511 function canBeAWeakMapKey(obj) { 36512 return obj !== null && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == 'object' || typeof obj == 'function'); 36513 } 36514 36515 function isNaNSymbol(obj) { 36516 /* eslint-disable no-self-compare */ 36517 return obj !== obj; // NaN === NaN is always false 36518 } 36519} 36520 36521exports.default = MultiMap; 36522 36523/***/ }), 36524/* 335 */ 36525/***/ (function(module, exports, __webpack_require__) { 36526 36527"use strict"; 36528 36529 36530exports.__esModule = true; 36531 36532var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); 36533 36534var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 36535 36536var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 36537 36538var _base = __webpack_require__(16); 36539 36540var _base2 = _interopRequireDefault(_base); 36541 36542var _array = __webpack_require__(2); 36543 36544var _feature = __webpack_require__(34); 36545 36546var _element = __webpack_require__(0); 36547 36548var _ghostTable = __webpack_require__(69); 36549 36550var _ghostTable2 = _interopRequireDefault(_ghostTable); 36551 36552var _object = __webpack_require__(3); 36553 36554var _number = __webpack_require__(5); 36555 36556var _plugins = __webpack_require__(9); 36557 36558var _samplesGenerator = __webpack_require__(269); 36559 36560var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator); 36561 36562var _string = __webpack_require__(28); 36563 36564var _src = __webpack_require__(14); 36565 36566function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 36567 36568function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 36569 36570function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 36571 36572function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 36573 36574var privatePool = new WeakMap(); 36575 36576/** 36577 * @plugin AutoColumnSize 36578 * 36579 * @description 36580 * This plugin allows to set column widths based on their widest cells. 36581 * 36582 * By default, the plugin is declared as `undefined`, which makes it enabled (same as if it was declared as `true`). 36583 * Enabling this plugin may decrease the overall table performance, as it needs to calculate the widths of all cells to 36584 * resize the columns accordingly. 36585 * If you experience problems with the performance, try turning this feature off and declaring the column widths manually. 36586 * 36587 * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and 36588 * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't 36589 * block the browser UI. 36590 * 36591 * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object: 36592 * ```js 36593 * ... 36594 * // as a number (300 columns in sync, rest async) 36595 * autoColumnSize: {syncLimit: 300}, 36596 * ... 36597 * 36598 * ... 36599 * // as a string (percent) 36600 * autoColumnSize: {syncLimit: '40%'}, 36601 * ... 36602 * ``` 36603 * 36604 * To configure this plugin see {@link Options#autoColumnSize}. 36605 * 36606 * @example 36607 * ```js 36608 * ... 36609 * var hot = new Handsontable(document.getElementById('example'), { 36610 * date: getData(), 36611 * autoColumnSize: true 36612 * }); 36613 * // Access to plugin instance: 36614 * var plugin = hot.getPlugin('autoColumnSize'); 36615 * 36616 * plugin.getColumnWidth(4); 36617 * 36618 * if (plugin.isEnabled()) { 36619 * // code... 36620 * } 36621 * ... 36622 * ``` 36623 */ 36624 36625var AutoColumnSize = function (_BasePlugin) { 36626 _inherits(AutoColumnSize, _BasePlugin); 36627 36628 _createClass(AutoColumnSize, null, [{ 36629 key: 'CALCULATION_STEP', 36630 get: function get() { 36631 return 50; 36632 } 36633 }, { 36634 key: 'SYNC_CALCULATION_LIMIT', 36635 get: function get() { 36636 return 50; 36637 } 36638 }]); 36639 36640 function AutoColumnSize(hotInstance) { 36641 _classCallCheck(this, AutoColumnSize); 36642 36643 var _this = _possibleConstructorReturn(this, (AutoColumnSize.__proto__ || Object.getPrototypeOf(AutoColumnSize)).call(this, hotInstance)); 36644 36645 privatePool.set(_this, { 36646 /** 36647 * Cached column header names. It is used to diff current column headers with previous state and detect which 36648 * columns width should be updated. 36649 * 36650 * @private 36651 * @type {Array} 36652 */ 36653 cachedColumnHeaders: [] 36654 }); 36655 /** 36656 * Cached columns widths. 36657 * 36658 * @type {Array} 36659 */ 36660 _this.widths = []; 36661 /** 36662 * Instance of {@link GhostTable} for rows and columns size calculations. 36663 * 36664 * @type {GhostTable} 36665 */ 36666 _this.ghostTable = new _ghostTable2.default(_this.hot); 36667 /** 36668 * Instance of {@link SamplesGenerator} for generating samples necessary for columns width calculations. 36669 * 36670 * @type {SamplesGenerator} 36671 */ 36672 _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) { 36673 return _this.hot.getDataAtCell(row, col); 36674 }); 36675 /** 36676 * `true` only if the first calculation was performed 36677 * 36678 * @type {Boolean} 36679 */ 36680 _this.firstCalculation = true; 36681 /** 36682 * `true` if the size calculation is in progress. 36683 * 36684 * @type {Boolean} 36685 */ 36686 _this.inProgress = false; 36687 36688 // moved to constructor to allow auto-sizing the columns when the plugin is disabled 36689 _this.addHook('beforeColumnResize', function (col, size, isDblClick) { 36690 return _this.onBeforeColumnResize(col, size, isDblClick); 36691 }); 36692 return _this; 36693 } 36694 36695 /** 36696 * Check if the plugin is enabled in the handsontable settings. 36697 * 36698 * @returns {Boolean} 36699 */ 36700 36701 36702 _createClass(AutoColumnSize, [{ 36703 key: 'isEnabled', 36704 value: function isEnabled() { 36705 return this.hot.getSettings().autoColumnSize !== false && !this.hot.getSettings().colWidths; 36706 } 36707 36708 /** 36709 * Enable plugin for this Handsontable instance. 36710 */ 36711 36712 }, { 36713 key: 'enablePlugin', 36714 value: function enablePlugin() { 36715 var _this2 = this; 36716 36717 if (this.enabled) { 36718 return; 36719 } 36720 36721 var setting = this.hot.getSettings().autoColumnSize; 36722 36723 if (setting && setting.useHeaders != null) { 36724 this.ghostTable.setSetting('useHeaders', setting.useHeaders); 36725 } 36726 36727 this.addHook('afterLoadData', function () { 36728 return _this2.onAfterLoadData(); 36729 }); 36730 this.addHook('beforeChange', function (changes) { 36731 return _this2.onBeforeChange(changes); 36732 }); 36733 36734 this.addHook('beforeRender', function (force) { 36735 return _this2.onBeforeRender(force); 36736 }); 36737 this.addHook('modifyColWidth', function (width, col) { 36738 return _this2.getColumnWidth(col, width); 36739 }); 36740 this.addHook('afterInit', function () { 36741 return _this2.onAfterInit(); 36742 }); 36743 _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'enablePlugin', this).call(this); 36744 } 36745 36746 /** 36747 * Update plugin state. 36748 */ 36749 36750 }, { 36751 key: 'updatePlugin', 36752 value: function updatePlugin() { 36753 var changedColumns = this.findColumnsWhereHeaderWasChanged(); 36754 36755 if (changedColumns.length) { 36756 this.clearCache(changedColumns); 36757 } 36758 _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'updatePlugin', this).call(this); 36759 } 36760 36761 /** 36762 * Disable plugin for this Handsontable instance. 36763 */ 36764 36765 }, { 36766 key: 'disablePlugin', 36767 value: function disablePlugin() { 36768 _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'disablePlugin', this).call(this); 36769 } 36770 36771 /** 36772 * Calculate a columns width. 36773 * 36774 * @param {Number|Object} colRange Column range object. 36775 * @param {Number|Object} rowRange Row range object. 36776 * @param {Boolean} [force=false] If `true` force calculate width even when value was cached earlier. 36777 */ 36778 36779 }, { 36780 key: 'calculateColumnsWidth', 36781 value: function calculateColumnsWidth() { 36782 var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 }; 36783 36784 var _this3 = this; 36785 36786 var rowRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countRows() - 1 }; 36787 var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 36788 36789 if (typeof colRange === 'number') { 36790 colRange = { from: colRange, to: colRange }; 36791 } 36792 if (typeof rowRange === 'number') { 36793 rowRange = { from: rowRange, to: rowRange }; 36794 } 36795 36796 (0, _number.rangeEach)(colRange.from, colRange.to, function (col) { 36797 if (force || _this3.widths[col] === void 0 && !_this3.hot._getColWidthFromSettings(col)) { 36798 var samples = _this3.samplesGenerator.generateColumnSamples(col, rowRange); 36799 36800 samples.forEach(function (sample, col) { 36801 return _this3.ghostTable.addColumn(col, sample); 36802 }); 36803 } 36804 }); 36805 36806 if (this.ghostTable.columns.length) { 36807 this.ghostTable.getWidths(function (col, width) { 36808 _this3.widths[col] = width; 36809 }); 36810 this.ghostTable.clean(); 36811 } 36812 } 36813 36814 /** 36815 * Calculate all columns width. 36816 * 36817 * @param {Object|Number} rowRange Row range object. 36818 */ 36819 36820 }, { 36821 key: 'calculateAllColumnsWidth', 36822 value: function calculateAllColumnsWidth() { 36823 var _this4 = this; 36824 36825 var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 }; 36826 36827 var current = 0; 36828 var length = this.hot.countCols() - 1; 36829 var timer = null; 36830 36831 this.inProgress = true; 36832 36833 var loop = function loop() { 36834 // When hot was destroyed after calculating finished cancel frame 36835 if (!_this4.hot) { 36836 (0, _feature.cancelAnimationFrame)(timer); 36837 _this4.inProgress = false; 36838 36839 return; 36840 } 36841 36842 _this4.calculateColumnsWidth({ 36843 from: current, 36844 to: Math.min(current + AutoColumnSize.CALCULATION_STEP, length) 36845 }, rowRange); 36846 36847 current = current + AutoColumnSize.CALCULATION_STEP + 1; 36848 36849 if (current < length) { 36850 timer = (0, _feature.requestAnimationFrame)(loop); 36851 } else { 36852 (0, _feature.cancelAnimationFrame)(timer); 36853 _this4.inProgress = false; 36854 36855 // @TODO Should call once per render cycle, currently fired separately in different plugins 36856 _this4.hot.view.wt.wtOverlays.adjustElementsSize(true); 36857 // tmp 36858 if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) { 36859 _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw(); 36860 } 36861 } 36862 }; 36863 // sync 36864 if (this.firstCalculation && this.getSyncCalculationLimit()) { 36865 this.calculateColumnsWidth({ from: 0, to: this.getSyncCalculationLimit() }, rowRange); 36866 this.firstCalculation = false; 36867 current = this.getSyncCalculationLimit() + 1; 36868 } 36869 // async 36870 if (current < length) { 36871 loop(); 36872 } else { 36873 this.inProgress = false; 36874 } 36875 } 36876 36877 /** 36878 * Set the sampling options. 36879 * 36880 * @private 36881 */ 36882 36883 }, { 36884 key: 'setSamplingOptions', 36885 value: function setSamplingOptions() { 36886 var setting = this.hot.getSettings().autoColumnSize; 36887 var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoColumnSize.samplingRatio : void 0; 36888 var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoColumnSize.allowSampleDuplicates : void 0; 36889 36890 if (samplingRatio && !isNaN(samplingRatio)) { 36891 this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10)); 36892 } 36893 36894 if (allowSampleDuplicates) { 36895 this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates); 36896 } 36897 } 36898 36899 /** 36900 * Recalculate all columns width (overwrite cache values). 36901 */ 36902 36903 }, { 36904 key: 'recalculateAllColumnsWidth', 36905 value: function recalculateAllColumnsWidth() { 36906 if (this.hot.view && (0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) { 36907 this.clearCache(); 36908 this.calculateAllColumnsWidth(); 36909 } 36910 } 36911 36912 /** 36913 * Get value which tells how many columns should be calculated synchronously. Rest of the columns will be calculated asynchronously. 36914 * 36915 * @returns {Number} 36916 */ 36917 36918 }, { 36919 key: 'getSyncCalculationLimit', 36920 value: function getSyncCalculationLimit() { 36921 /* eslint-disable no-bitwise */ 36922 var limit = AutoColumnSize.SYNC_CALCULATION_LIMIT; 36923 var colsLimit = this.hot.countCols() - 1; 36924 36925 if ((0, _object.isObject)(this.hot.getSettings().autoColumnSize)) { 36926 limit = this.hot.getSettings().autoColumnSize.syncLimit; 36927 36928 if ((0, _string.isPercentValue)(limit)) { 36929 limit = (0, _number.valueAccordingPercent)(colsLimit, limit); 36930 } else { 36931 // Force to Number 36932 limit >>= 0; 36933 } 36934 } 36935 36936 return Math.min(limit, colsLimit); 36937 } 36938 36939 /** 36940 * Get the calculated column width. 36941 * 36942 * @param {Number} col Column index. 36943 * @param {Number} [defaultWidth] Default column width. It will be picked up if no calculated width found. 36944 * @param {Boolean} [keepMinimum=true] If `true` then returned value won't be smaller then 50 (default column width). 36945 * @returns {Number} 36946 */ 36947 36948 }, { 36949 key: 'getColumnWidth', 36950 value: function getColumnWidth(col) { 36951 var defaultWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0; 36952 var keepMinimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; 36953 36954 var width = defaultWidth; 36955 36956 if (width === void 0) { 36957 width = this.widths[col]; 36958 36959 if (keepMinimum && typeof width === 'number') { 36960 width = Math.max(width, _src.ViewportColumnsCalculator.DEFAULT_WIDTH); 36961 } 36962 } 36963 36964 return width; 36965 } 36966 36967 /** 36968 * Get the first visible column. 36969 * 36970 * @returns {Number} Returns column index or -1 if table is not rendered. 36971 */ 36972 36973 }, { 36974 key: 'getFirstVisibleColumn', 36975 value: function getFirstVisibleColumn() { 36976 var wot = this.hot.view.wt; 36977 36978 if (wot.wtViewport.columnsVisibleCalculator) { 36979 return wot.wtTable.getFirstVisibleColumn(); 36980 } 36981 if (wot.wtViewport.columnsRenderCalculator) { 36982 return wot.wtTable.getFirstRenderedColumn(); 36983 } 36984 36985 return -1; 36986 } 36987 36988 /** 36989 * Get the last visible column. 36990 * 36991 * @returns {Number} Returns column index or -1 if table is not rendered. 36992 */ 36993 36994 }, { 36995 key: 'getLastVisibleColumn', 36996 value: function getLastVisibleColumn() { 36997 var wot = this.hot.view.wt; 36998 36999 if (wot.wtViewport.columnsVisibleCalculator) { 37000 return wot.wtTable.getLastVisibleColumn(); 37001 } 37002 if (wot.wtViewport.columnsRenderCalculator) { 37003 return wot.wtTable.getLastRenderedColumn(); 37004 } 37005 37006 return -1; 37007 } 37008 37009 /** 37010 * Collects all columns which titles has been changed in comparison to the previous state. 37011 * 37012 * @returns {Array} It returns an array of physical column indexes. 37013 */ 37014 37015 }, { 37016 key: 'findColumnsWhereHeaderWasChanged', 37017 value: function findColumnsWhereHeaderWasChanged() { 37018 var columnHeaders = this.hot.getColHeader(); 37019 37020 var _privatePool$get = privatePool.get(this), 37021 cachedColumnHeaders = _privatePool$get.cachedColumnHeaders; 37022 37023 var changedColumns = (0, _array.arrayReduce)(columnHeaders, function (acc, columnTitle, physicalColumn) { 37024 var cachedColumnsLength = cachedColumnHeaders.length; 37025 37026 if (cachedColumnsLength - 1 < physicalColumn || cachedColumnHeaders[physicalColumn] !== columnTitle) { 37027 acc.push(physicalColumn); 37028 } 37029 if (cachedColumnsLength - 1 < physicalColumn) { 37030 cachedColumnHeaders.push(columnTitle); 37031 } else { 37032 cachedColumnHeaders[physicalColumn] = columnTitle; 37033 } 37034 37035 return acc; 37036 }, []); 37037 37038 return changedColumns; 37039 } 37040 37041 /** 37042 * Clear cache of calculated column widths. If you want to clear only selected columns pass an array with their indexes. 37043 * Otherwise whole cache will be cleared. 37044 * 37045 * @param {Array} [columns=[]] List of column indexes (physical indexes) to clear. 37046 */ 37047 37048 }, { 37049 key: 'clearCache', 37050 value: function clearCache() { 37051 var _this5 = this; 37052 37053 var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 37054 37055 if (columns.length) { 37056 (0, _array.arrayEach)(columns, function (physicalIndex) { 37057 _this5.widths[physicalIndex] = void 0; 37058 }); 37059 } else { 37060 this.widths.length = 0; 37061 } 37062 } 37063 37064 /** 37065 * Check if all widths were calculated. If not then return `true` (need recalculate). 37066 * 37067 * @returns {Boolean} 37068 */ 37069 37070 }, { 37071 key: 'isNeedRecalculate', 37072 value: function isNeedRecalculate() { 37073 return !!(0, _array.arrayFilter)(this.widths, function (item) { 37074 return item === void 0; 37075 }).length; 37076 } 37077 37078 /** 37079 * On before render listener. 37080 * 37081 * @private 37082 */ 37083 37084 }, { 37085 key: 'onBeforeRender', 37086 value: function onBeforeRender() { 37087 var force = this.hot.renderCall; 37088 var rowsCount = this.hot.countRows(); 37089 37090 // Keep last column widths unchanged for situation when all rows was deleted or trimmed (pro #6) 37091 if (!rowsCount) { 37092 return; 37093 } 37094 37095 this.calculateColumnsWidth({ from: this.getFirstVisibleColumn(), to: this.getLastVisibleColumn() }, void 0, force); 37096 37097 if (this.isNeedRecalculate() && !this.inProgress) { 37098 this.calculateAllColumnsWidth(); 37099 } 37100 } 37101 37102 /** 37103 * On after load data listener. 37104 * 37105 * @private 37106 */ 37107 37108 }, { 37109 key: 'onAfterLoadData', 37110 value: function onAfterLoadData() { 37111 var _this6 = this; 37112 37113 if (this.hot.view) { 37114 this.recalculateAllColumnsWidth(); 37115 } else { 37116 // first load - initialization 37117 setTimeout(function () { 37118 if (_this6.hot) { 37119 _this6.recalculateAllColumnsWidth(); 37120 } 37121 }, 0); 37122 } 37123 } 37124 37125 /** 37126 * On before change listener. 37127 * 37128 * @private 37129 * @param {Array} changes 37130 */ 37131 37132 }, { 37133 key: 'onBeforeChange', 37134 value: function onBeforeChange(changes) { 37135 var _this7 = this; 37136 37137 var changedColumns = (0, _array.arrayMap)(changes, function (_ref) { 37138 var _ref2 = _slicedToArray(_ref, 2), 37139 row = _ref2[0], 37140 column = _ref2[1]; 37141 37142 return _this7.hot.propToCol(column); 37143 }); 37144 37145 this.clearCache(changedColumns); 37146 } 37147 37148 /** 37149 * On before column resize listener. 37150 * 37151 * @private 37152 * @param {Number} col 37153 * @param {Number} size 37154 * @param {Boolean} isDblClick 37155 * @returns {Number} 37156 */ 37157 37158 }, { 37159 key: 'onBeforeColumnResize', 37160 value: function onBeforeColumnResize(col, size, isDblClick) { 37161 if (isDblClick) { 37162 this.calculateColumnsWidth(col, void 0, true); 37163 size = this.getColumnWidth(col, void 0, false); 37164 } 37165 37166 return size; 37167 } 37168 37169 /** 37170 * On after Handsontable init fill plugin with all necessary values. 37171 * 37172 * @private 37173 */ 37174 37175 }, { 37176 key: 'onAfterInit', 37177 value: function onAfterInit() { 37178 privatePool.get(this).cachedColumnHeaders = this.hot.getColHeader(); 37179 } 37180 37181 /** 37182 * Destroy plugin instance. 37183 */ 37184 37185 }, { 37186 key: 'destroy', 37187 value: function destroy() { 37188 this.ghostTable.clean(); 37189 _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'destroy', this).call(this); 37190 } 37191 }]); 37192 37193 return AutoColumnSize; 37194}(_base2.default); 37195 37196(0, _plugins.registerPlugin)('autoColumnSize', AutoColumnSize); 37197 37198exports.default = AutoColumnSize; 37199 37200/***/ }), 37201/* 336 */ 37202/***/ (function(module, exports, __webpack_require__) { 37203 37204"use strict"; 37205 37206 37207exports.__esModule = true; 37208 37209var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 37210 37211var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 37212 37213var _base = __webpack_require__(16); 37214 37215var _base2 = _interopRequireDefault(_base); 37216 37217var _array = __webpack_require__(2); 37218 37219var _feature = __webpack_require__(34); 37220 37221var _element = __webpack_require__(0); 37222 37223var _ghostTable = __webpack_require__(69); 37224 37225var _ghostTable2 = _interopRequireDefault(_ghostTable); 37226 37227var _object = __webpack_require__(3); 37228 37229var _number = __webpack_require__(5); 37230 37231var _plugins = __webpack_require__(9); 37232 37233var _samplesGenerator = __webpack_require__(269); 37234 37235var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator); 37236 37237var _string = __webpack_require__(28); 37238 37239function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 37240 37241function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 37242 37243function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 37244 37245function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 37246 37247/** 37248 * @plugin AutoRowSize 37249 * 37250 * @description 37251 * This plugin allows to set row heights based on their highest cells. 37252 * 37253 * By default, the plugin is declared as `undefined`, which makes it disabled (same as if it was declared as `false`). 37254 * Enabling this plugin may decrease the overall table performance, as it needs to calculate the heights of all cells to 37255 * resize the rows accordingly. 37256 * If you experience problems with the performance, try turning this feature off and declaring the row heights manually. 37257 * 37258 * Row height calculations are divided into sync and async part. Each of this parts has their own advantages and 37259 * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't 37260 * block the browser UI. 37261 * 37262 * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object: 37263 * ```js 37264 * ... 37265 * // as a number (300 columns in sync, rest async) 37266 * autoRowSize: {syncLimit: 300}, 37267 * ... 37268 * 37269 * ... 37270 * // as a string (percent) 37271 * autoRowSize: {syncLimit: '40%'}, 37272 * ... 37273 * ``` 37274 * 37275 * You can also use the `allowSampleDuplicates` option to allow sampling duplicate values when calculating the row height. Note, that this might have 37276 * a negative impact on performance. 37277 * 37278 * To configure this plugin see {@link Options#autoRowSize}. 37279 * 37280 * @example 37281 * 37282 * ```js 37283 * ... 37284 * var hot = new Handsontable(document.getElementById('example'), { 37285 * date: getData(), 37286 * autoRowSize: true 37287 * }); 37288 * // Access to plugin instance: 37289 * var plugin = hot.getPlugin('autoRowSize'); 37290 * 37291 * plugin.getRowHeight(4); 37292 * 37293 * if (plugin.isEnabled()) { 37294 * // code... 37295 * } 37296 * ... 37297 * ``` 37298 */ 37299var AutoRowSize = function (_BasePlugin) { 37300 _inherits(AutoRowSize, _BasePlugin); 37301 37302 _createClass(AutoRowSize, null, [{ 37303 key: 'CALCULATION_STEP', 37304 get: function get() { 37305 return 50; 37306 } 37307 }, { 37308 key: 'SYNC_CALCULATION_LIMIT', 37309 get: function get() { 37310 return 500; 37311 } 37312 }]); 37313 37314 function AutoRowSize(hotInstance) { 37315 _classCallCheck(this, AutoRowSize); 37316 37317 /** 37318 * Cached rows heights. 37319 * 37320 * @type {Array} 37321 */ 37322 var _this = _possibleConstructorReturn(this, (AutoRowSize.__proto__ || Object.getPrototypeOf(AutoRowSize)).call(this, hotInstance)); 37323 37324 _this.heights = []; 37325 /** 37326 * Instance of {@link GhostTable} for rows and columns size calculations. 37327 * 37328 * @type {GhostTable} 37329 */ 37330 _this.ghostTable = new _ghostTable2.default(_this.hot); 37331 /** 37332 * Instance of {@link SamplesGenerator} for generating samples necessary for rows height calculations. 37333 * 37334 * @type {SamplesGenerator} 37335 */ 37336 _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) { 37337 if (row >= 0) { 37338 return _this.hot.getDataAtCell(row, col); 37339 } else if (row === -1) { 37340 return _this.hot.getColHeader(col); 37341 } 37342 return null; 37343 }); 37344 /** 37345 * `true` if only the first calculation was performed. 37346 * 37347 * @type {Boolean} 37348 */ 37349 _this.firstCalculation = true; 37350 /** 37351 * `true` if the size calculation is in progress. 37352 * 37353 * @type {Boolean} 37354 */ 37355 _this.inProgress = false; 37356 37357 // moved to constructor to allow auto-sizing the rows when the plugin is disabled 37358 _this.addHook('beforeRowResize', function (row, size, isDblClick) { 37359 return _this.onBeforeRowResize(row, size, isDblClick); 37360 }); 37361 return _this; 37362 } 37363 37364 /** 37365 * Check if the plugin is enabled in the Handsontable settings. 37366 * 37367 * @returns {Boolean} 37368 */ 37369 37370 37371 _createClass(AutoRowSize, [{ 37372 key: 'isEnabled', 37373 value: function isEnabled() { 37374 return this.hot.getSettings().autoRowSize === true || (0, _object.isObject)(this.hot.getSettings().autoRowSize); 37375 } 37376 37377 /** 37378 * Enable plugin for this Handsontable instance. 37379 */ 37380 37381 }, { 37382 key: 'enablePlugin', 37383 value: function enablePlugin() { 37384 var _this2 = this; 37385 37386 if (this.enabled) { 37387 return; 37388 } 37389 37390 this.setSamplingOptions(); 37391 37392 this.addHook('afterLoadData', function () { 37393 return _this2.onAfterLoadData(); 37394 }); 37395 this.addHook('beforeChange', function (changes) { 37396 return _this2.onBeforeChange(changes); 37397 }); 37398 this.addHook('beforeColumnMove', function () { 37399 return _this2.recalculateAllRowsHeight(); 37400 }); 37401 this.addHook('beforeColumnResize', function () { 37402 return _this2.recalculateAllRowsHeight(); 37403 }); 37404 this.addHook('beforeColumnSort', function () { 37405 return _this2.clearCache(); 37406 }); 37407 this.addHook('beforeRender', function (force) { 37408 return _this2.onBeforeRender(force); 37409 }); 37410 this.addHook('beforeRowMove', function (rowStart, rowEnd) { 37411 return _this2.onBeforeRowMove(rowStart, rowEnd); 37412 }); 37413 this.addHook('modifyRowHeight', function (height, row) { 37414 return _this2.getRowHeight(row, height); 37415 }); 37416 this.addHook('modifyColumnHeaderHeight', function () { 37417 return _this2.getColumnHeaderHeight(); 37418 }); 37419 _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'enablePlugin', this).call(this); 37420 } 37421 37422 /** 37423 * Disable plugin for this Handsontable instance. 37424 */ 37425 37426 }, { 37427 key: 'disablePlugin', 37428 value: function disablePlugin() { 37429 _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'disablePlugin', this).call(this); 37430 } 37431 37432 /** 37433 * Calculate a given rows height. 37434 * 37435 * @param {Number|Object} rowRange Row range object. 37436 * @param {Number|Object} colRange Column range object. 37437 * @param {Boolean} [force=false] If `true` force calculate height even when value was cached earlier. 37438 */ 37439 37440 }, { 37441 key: 'calculateRowsHeight', 37442 value: function calculateRowsHeight() { 37443 var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 }; 37444 37445 var _this3 = this; 37446 37447 var colRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countCols() - 1 }; 37448 var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 37449 37450 if (typeof rowRange === 'number') { 37451 rowRange = { from: rowRange, to: rowRange }; 37452 } 37453 if (typeof colRange === 'number') { 37454 colRange = { from: colRange, to: colRange }; 37455 } 37456 37457 if (this.hot.getColHeader(0) !== null) { 37458 var samples = this.samplesGenerator.generateRowSamples(-1, colRange); 37459 37460 this.ghostTable.addColumnHeadersRow(samples.get(-1)); 37461 } 37462 37463 (0, _number.rangeEach)(rowRange.from, rowRange.to, function (row) { 37464 // For rows we must calculate row height even when user had set height value manually. 37465 // We can shrink column but cannot shrink rows! 37466 if (force || _this3.heights[row] === void 0) { 37467 var _samples = _this3.samplesGenerator.generateRowSamples(row, colRange); 37468 37469 _samples.forEach(function (sample, row) { 37470 _this3.ghostTable.addRow(row, sample); 37471 }); 37472 } 37473 }); 37474 if (this.ghostTable.rows.length) { 37475 this.ghostTable.getHeights(function (row, height) { 37476 _this3.heights[row] = height; 37477 }); 37478 this.ghostTable.clean(); 37479 } 37480 } 37481 37482 /** 37483 * Calculate the height of all the rows. 37484 * 37485 * @param {Object|Number} colRange Column range object. 37486 */ 37487 37488 }, { 37489 key: 'calculateAllRowsHeight', 37490 value: function calculateAllRowsHeight() { 37491 var _this4 = this; 37492 37493 var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 }; 37494 37495 var current = 0; 37496 var length = this.hot.countRows() - 1; 37497 var timer = null; 37498 37499 this.inProgress = true; 37500 37501 var loop = function loop() { 37502 // When hot was destroyed after calculating finished cancel frame 37503 if (!_this4.hot) { 37504 (0, _feature.cancelAnimationFrame)(timer); 37505 _this4.inProgress = false; 37506 37507 return; 37508 } 37509 _this4.calculateRowsHeight({ from: current, to: Math.min(current + AutoRowSize.CALCULATION_STEP, length) }, colRange); 37510 current = current + AutoRowSize.CALCULATION_STEP + 1; 37511 37512 if (current < length) { 37513 timer = (0, _feature.requestAnimationFrame)(loop); 37514 } else { 37515 (0, _feature.cancelAnimationFrame)(timer); 37516 _this4.inProgress = false; 37517 37518 // @TODO Should call once per render cycle, currently fired separately in different plugins 37519 _this4.hot.view.wt.wtOverlays.adjustElementsSize(true); 37520 // tmp 37521 if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) { 37522 _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw(); 37523 } 37524 } 37525 }; 37526 // sync 37527 if (this.firstCalculation && this.getSyncCalculationLimit()) { 37528 this.calculateRowsHeight({ from: 0, to: this.getSyncCalculationLimit() }, colRange); 37529 this.firstCalculation = false; 37530 current = this.getSyncCalculationLimit() + 1; 37531 } 37532 // async 37533 if (current < length) { 37534 loop(); 37535 } else { 37536 this.inProgress = false; 37537 this.hot.view.wt.wtOverlays.adjustElementsSize(false); 37538 } 37539 } 37540 37541 /** 37542 * Set the sampling options. 37543 * 37544 * @private 37545 */ 37546 37547 }, { 37548 key: 'setSamplingOptions', 37549 value: function setSamplingOptions() { 37550 var setting = this.hot.getSettings().autoRowSize; 37551 var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoRowSize.samplingRatio : void 0; 37552 var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoRowSize.allowSampleDuplicates : void 0; 37553 37554 if (samplingRatio && !isNaN(samplingRatio)) { 37555 this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10)); 37556 } 37557 37558 if (allowSampleDuplicates) { 37559 this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates); 37560 } 37561 } 37562 37563 /** 37564 * Recalculate all rows height (overwrite cache values). 37565 */ 37566 37567 }, { 37568 key: 'recalculateAllRowsHeight', 37569 value: function recalculateAllRowsHeight() { 37570 if ((0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) { 37571 this.clearCache(); 37572 this.calculateAllRowsHeight(); 37573 } 37574 } 37575 37576 /** 37577 * Get value which tells how much rows will be calculated synchronously. Rest rows will be calculated asynchronously. 37578 * 37579 * @returns {Number} 37580 */ 37581 37582 }, { 37583 key: 'getSyncCalculationLimit', 37584 value: function getSyncCalculationLimit() { 37585 /* eslint-disable no-bitwise */ 37586 var limit = AutoRowSize.SYNC_CALCULATION_LIMIT; 37587 var rowsLimit = this.hot.countRows() - 1; 37588 37589 if ((0, _object.isObject)(this.hot.getSettings().autoRowSize)) { 37590 limit = this.hot.getSettings().autoRowSize.syncLimit; 37591 37592 if ((0, _string.isPercentValue)(limit)) { 37593 limit = (0, _number.valueAccordingPercent)(rowsLimit, limit); 37594 } else { 37595 // Force to Number 37596 limit >>= 0; 37597 } 37598 } 37599 37600 return Math.min(limit, rowsLimit); 37601 } 37602 37603 /** 37604 * Get the calculated row height. 37605 * 37606 * @param {Number} row Visual row index. 37607 * @param {Number} [defaultHeight] Default row height. It will be pick up if no calculated height found. 37608 * @returns {Number} 37609 */ 37610 37611 }, { 37612 key: 'getRowHeight', 37613 value: function getRowHeight(row) { 37614 var defaultHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0; 37615 37616 var height = defaultHeight; 37617 37618 if (this.heights[row] !== void 0 && this.heights[row] > (defaultHeight || 0)) { 37619 height = this.heights[row]; 37620 } 37621 37622 return height; 37623 } 37624 37625 /** 37626 * Get the calculated column header height. 37627 * 37628 * @returns {Number|undefined} 37629 */ 37630 37631 }, { 37632 key: 'getColumnHeaderHeight', 37633 value: function getColumnHeaderHeight() { 37634 return this.heights[-1]; 37635 } 37636 37637 /** 37638 * Get the first visible row. 37639 * 37640 * @returns {Number} Returns row index or -1 if table is not rendered. 37641 */ 37642 37643 }, { 37644 key: 'getFirstVisibleRow', 37645 value: function getFirstVisibleRow() { 37646 var wot = this.hot.view.wt; 37647 37648 if (wot.wtViewport.rowsVisibleCalculator) { 37649 return wot.wtTable.getFirstVisibleRow(); 37650 } 37651 if (wot.wtViewport.rowsRenderCalculator) { 37652 return wot.wtTable.getFirstRenderedRow(); 37653 } 37654 37655 return -1; 37656 } 37657 37658 /** 37659 * Get the last visible row. 37660 * 37661 * @returns {Number} Returns row index or -1 if table is not rendered. 37662 */ 37663 37664 }, { 37665 key: 'getLastVisibleRow', 37666 value: function getLastVisibleRow() { 37667 var wot = this.hot.view.wt; 37668 37669 if (wot.wtViewport.rowsVisibleCalculator) { 37670 return wot.wtTable.getLastVisibleRow(); 37671 } 37672 if (wot.wtViewport.rowsRenderCalculator) { 37673 return wot.wtTable.getLastRenderedRow(); 37674 } 37675 37676 return -1; 37677 } 37678 37679 /** 37680 * Clear cached heights. 37681 */ 37682 37683 }, { 37684 key: 'clearCache', 37685 value: function clearCache() { 37686 this.heights.length = 0; 37687 this.heights[-1] = void 0; 37688 } 37689 37690 /** 37691 * Clear cache by range. 37692 * 37693 * @param {Object|Number} range Row range object. 37694 */ 37695 37696 }, { 37697 key: 'clearCacheByRange', 37698 value: function clearCacheByRange(range) { 37699 var _this5 = this; 37700 37701 if (typeof range === 'number') { 37702 range = { from: range, to: range }; 37703 } 37704 (0, _number.rangeEach)(Math.min(range.from, range.to), Math.max(range.from, range.to), function (row) { 37705 _this5.heights[row] = void 0; 37706 }); 37707 } 37708 37709 /** 37710 * @returns {Boolean} 37711 */ 37712 37713 }, { 37714 key: 'isNeedRecalculate', 37715 value: function isNeedRecalculate() { 37716 return !!(0, _array.arrayFilter)(this.heights, function (item) { 37717 return item === void 0; 37718 }).length; 37719 } 37720 37721 /** 37722 * On before render listener. 37723 * 37724 * @private 37725 */ 37726 37727 }, { 37728 key: 'onBeforeRender', 37729 value: function onBeforeRender() { 37730 var force = this.hot.renderCall; 37731 this.calculateRowsHeight({ from: this.getFirstVisibleRow(), to: this.getLastVisibleRow() }, void 0, force); 37732 37733 var fixedRowsBottom = this.hot.getSettings().fixedRowsBottom; 37734 37735 // Calculate rows height synchronously for bottom overlay 37736 if (fixedRowsBottom) { 37737 var totalRows = this.hot.countRows() - 1; 37738 this.calculateRowsHeight({ from: totalRows - fixedRowsBottom, to: totalRows }); 37739 } 37740 37741 if (this.isNeedRecalculate() && !this.inProgress) { 37742 this.calculateAllRowsHeight(); 37743 } 37744 } 37745 37746 /** 37747 * On before row move listener. 37748 * 37749 * @private 37750 * @param {Number} from Row index where was grabbed. 37751 * @param {Number} to Destination row index. 37752 */ 37753 37754 }, { 37755 key: 'onBeforeRowMove', 37756 value: function onBeforeRowMove(from, to) { 37757 this.clearCacheByRange({ from: from, to: to }); 37758 this.calculateAllRowsHeight(); 37759 } 37760 37761 /** 37762 * On before row resize listener. 37763 * 37764 * @private 37765 * @param {Number} row 37766 * @param {Number} size 37767 * @param {Boolean} isDblClick 37768 * @returns {Number} 37769 */ 37770 37771 }, { 37772 key: 'onBeforeRowResize', 37773 value: function onBeforeRowResize(row, size, isDblClick) { 37774 if (isDblClick) { 37775 this.calculateRowsHeight(row, void 0, true); 37776 size = this.getRowHeight(row); 37777 } 37778 37779 return size; 37780 } 37781 37782 /** 37783 * On after load data listener. 37784 * 37785 * @private 37786 */ 37787 37788 }, { 37789 key: 'onAfterLoadData', 37790 value: function onAfterLoadData() { 37791 var _this6 = this; 37792 37793 if (this.hot.view) { 37794 this.recalculateAllRowsHeight(); 37795 } else { 37796 // first load - initialization 37797 setTimeout(function () { 37798 if (_this6.hot) { 37799 _this6.recalculateAllRowsHeight(); 37800 } 37801 }, 0); 37802 } 37803 } 37804 37805 /** 37806 * On before change listener. 37807 * 37808 * @private 37809 * @param {Array} changes 37810 */ 37811 37812 }, { 37813 key: 'onBeforeChange', 37814 value: function onBeforeChange(changes) { 37815 var range = null; 37816 37817 if (changes.length === 1) { 37818 range = changes[0][0]; 37819 } else if (changes.length > 1) { 37820 range = { 37821 from: changes[0][0], 37822 to: changes[changes.length - 1][0] 37823 }; 37824 } 37825 if (range !== null) { 37826 this.clearCacheByRange(range); 37827 } 37828 } 37829 37830 /** 37831 * Destroy plugin instance. 37832 */ 37833 37834 }, { 37835 key: 'destroy', 37836 value: function destroy() { 37837 this.ghostTable.clean(); 37838 _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'destroy', this).call(this); 37839 } 37840 }]); 37841 37842 return AutoRowSize; 37843}(_base2.default); 37844 37845(0, _plugins.registerPlugin)('autoRowSize', AutoRowSize); 37846 37847exports.default = AutoRowSize; 37848 37849/***/ }), 37850/* 337 */ 37851/***/ (function(module, exports, __webpack_require__) { 37852 37853"use strict"; 37854 37855 37856exports.__esModule = true; 37857 37858var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 37859 37860var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 37861 37862var _base = __webpack_require__(16); 37863 37864var _base2 = _interopRequireDefault(_base); 37865 37866var _pluginHooks = __webpack_require__(11); 37867 37868var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 37869 37870var _element = __webpack_require__(0); 37871 37872var _eventManager = __webpack_require__(4); 37873 37874var _eventManager2 = _interopRequireDefault(_eventManager); 37875 37876var _plugins = __webpack_require__(9); 37877 37878var _src = __webpack_require__(14); 37879 37880var _utils = __webpack_require__(338); 37881 37882function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 37883 37884function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 37885 37886function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 37887 37888function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 37889 37890_pluginHooks2.default.getSingleton().register('modifyAutofillRange'); 37891_pluginHooks2.default.getSingleton().register('beforeAutofill'); 37892 37893var INSERT_ROW_ALTER_ACTION_NAME = 'insert_row'; 37894var INSERT_COLUMN_ALTER_ACTION_NAME = 'insert_col'; 37895var INTERVAL_FOR_ADDING_ROW = 200; 37896 37897/** 37898 * This plugin provides "drag-down" and "copy-down" functionalities, both operated 37899 * using the small square in the right bottom of the cell selection. 37900 * 37901 * "Drag-down" expands the value of the selected cells to the neighbouring 37902 * cells when you drag the small square in the corner. 37903 * 37904 * "Copy-down" copies the value of the selection to all empty cells 37905 * below when you double click the small square. 37906 * 37907 * @class Autofill 37908 * @plugin Autofill 37909 */ 37910 37911var Autofill = function (_BasePlugin) { 37912 _inherits(Autofill, _BasePlugin); 37913 37914 function Autofill(hotInstance) { 37915 _classCallCheck(this, Autofill); 37916 37917 /** 37918 * Event manager 37919 * 37920 * @type {EventManager} 37921 */ 37922 var _this = _possibleConstructorReturn(this, (Autofill.__proto__ || Object.getPrototypeOf(Autofill)).call(this, hotInstance)); 37923 37924 _this.eventManager = new _eventManager2.default(_this); 37925 /** 37926 * Specifies if adding new row started. 37927 * 37928 * @type {Boolean} 37929 */ 37930 _this.addingStarted = false; 37931 /** 37932 * Specifies if there was mouse down on the cell corner. 37933 * 37934 * @type {Boolean} 37935 */ 37936 _this.mouseDownOnCellCorner = false; 37937 /** 37938 * Specifies if mouse was dragged outside Handsontable. 37939 * 37940 * @type {Boolean} 37941 */ 37942 _this.mouseDragOutside = false; 37943 /** 37944 * Specifies how many cell levels were dragged using the handle. 37945 * 37946 * @type {Boolean} 37947 */ 37948 _this.handleDraggedCells = 0; 37949 /** 37950 * Specifies allowed directions of drag. 37951 * 37952 * @type {Array} 37953 */ 37954 _this.directions = []; 37955 /** 37956 * Specifies if can insert new rows if needed. 37957 * 37958 * @type {Boolean} 37959 */ 37960 _this.autoInsertRow = false; 37961 return _this; 37962 } 37963 37964 /** 37965 * Check if the plugin is enabled in the Handsontable settings. 37966 * 37967 * @returns {Boolean} 37968 */ 37969 37970 37971 _createClass(Autofill, [{ 37972 key: 'isEnabled', 37973 value: function isEnabled() { 37974 return this.hot.getSettings().fillHandle; 37975 } 37976 37977 /** 37978 * Enable plugin for this Handsontable instance. 37979 */ 37980 37981 }, { 37982 key: 'enablePlugin', 37983 value: function enablePlugin() { 37984 var _this2 = this; 37985 37986 if (this.enabled) { 37987 return; 37988 } 37989 37990 this.mapSettings(); 37991 this.registerEvents(); 37992 37993 this.addHook('afterOnCellCornerMouseDown', function (event) { 37994 return _this2.onAfterCellCornerMouseDown(event); 37995 }); 37996 this.addHook('afterOnCellCornerDblClick', function (event) { 37997 return _this2.onCellCornerDblClick(event); 37998 }); 37999 this.addHook('beforeOnCellMouseOver', function (event, coords, TD) { 38000 return _this2.onBeforeCellMouseOver(coords); 38001 }); 38002 38003 _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'enablePlugin', this).call(this); 38004 } 38005 38006 /** 38007 * Update plugin for this Handsontable instance. 38008 */ 38009 38010 }, { 38011 key: 'updatePlugin', 38012 value: function updatePlugin() { 38013 this.disablePlugin(); 38014 this.enablePlugin(); 38015 _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'updatePlugin', this).call(this); 38016 } 38017 38018 /** 38019 * Disable plugin for this Handsontable instance. 38020 */ 38021 38022 }, { 38023 key: 'disablePlugin', 38024 value: function disablePlugin() { 38025 this.clearMappedSettings(); 38026 _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'disablePlugin', this).call(this); 38027 } 38028 38029 /** 38030 * Get selection data 38031 * 38032 * @private 38033 * @returns {Array} Array with the data. 38034 */ 38035 38036 }, { 38037 key: 'getSelectionData', 38038 value: function getSelectionData() { 38039 var selRange = { 38040 from: this.hot.getSelectedRange().from, 38041 to: this.hot.getSelectedRange().to 38042 }; 38043 38044 return this.hot.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col); 38045 } 38046 38047 /** 38048 * Try to apply fill values to the area in fill border, omitting the selection border. 38049 * 38050 * @private 38051 * @returns {Boolean} reports if fill was applied. 38052 */ 38053 38054 }, { 38055 key: 'fillIn', 38056 value: function fillIn() { 38057 if (this.hot.view.wt.selections.fill.isEmpty()) { 38058 return false; 38059 } 38060 38061 var cornersOfSelectionAndDragAreas = this.hot.view.wt.selections.fill.getCorners(); 38062 38063 this.resetSelectionOfDraggedArea(); 38064 38065 var cornersOfSelectedCells = this.getCornersOfSelectedCells(); 38066 38067 var _getDragDirectionAndR = (0, _utils.getDragDirectionAndRange)(cornersOfSelectedCells, cornersOfSelectionAndDragAreas), 38068 directionOfDrag = _getDragDirectionAndR.directionOfDrag, 38069 startOfDragCoords = _getDragDirectionAndR.startOfDragCoords, 38070 endOfDragCoords = _getDragDirectionAndR.endOfDragCoords; 38071 38072 this.hot.runHooks('modifyAutofillRange', cornersOfSelectedCells, cornersOfSelectionAndDragAreas); 38073 38074 if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) { 38075 var selectionData = this.getSelectionData(); 38076 var deltas = (0, _utils.getDeltas)(startOfDragCoords, endOfDragCoords, selectionData, directionOfDrag); 38077 var fillData = selectionData; 38078 38079 this.hot.runHooks('beforeAutofill', startOfDragCoords, endOfDragCoords, selectionData); 38080 38081 if (['up', 'left'].indexOf(directionOfDrag) > -1) { 38082 fillData = []; 38083 38084 var dragLength = null; 38085 var fillOffset = null; 38086 38087 if (directionOfDrag === 'up') { 38088 dragLength = endOfDragCoords.row - startOfDragCoords.row + 1; 38089 fillOffset = dragLength % selectionData.length; 38090 38091 for (var i = 0; i < dragLength; i++) { 38092 fillData.push(selectionData[(i + (selectionData.length - fillOffset)) % selectionData.length]); 38093 } 38094 } else { 38095 dragLength = endOfDragCoords.col - startOfDragCoords.col + 1; 38096 fillOffset = dragLength % selectionData[0].length; 38097 38098 for (var _i = 0; _i < selectionData.length; _i++) { 38099 fillData.push([]); 38100 for (var j = 0; j < dragLength; j++) { 38101 fillData[_i].push(selectionData[_i][(j + (selectionData[_i].length - fillOffset)) % selectionData[_i].length]); 38102 } 38103 } 38104 } 38105 } 38106 38107 this.hot.populateFromArray(startOfDragCoords.row, startOfDragCoords.col, fillData, endOfDragCoords.row, endOfDragCoords.col, this.pluginName + '.fill', null, directionOfDrag, deltas); 38108 38109 this.setSelection(cornersOfSelectionAndDragAreas); 38110 } else { 38111 // reset to avoid some range bug 38112 this.hot.selection.refreshBorders(); 38113 } 38114 38115 return true; 38116 } 38117 38118 /** 38119 * Reduce the selection area if the handle was dragged outside of the table or on headers. 38120 * 38121 * @private 38122 * @param {CellCoords} coords indexes of selection corners. 38123 * @returns {CellCoords} 38124 */ 38125 38126 }, { 38127 key: 'reduceSelectionAreaIfNeeded', 38128 value: function reduceSelectionAreaIfNeeded(coords) { 38129 if (coords.row < 0) { 38130 coords.row = 0; 38131 } 38132 38133 if (coords.col < 0) { 38134 coords.col = 0; 38135 } 38136 return coords; 38137 } 38138 38139 /** 38140 * Get the coordinates of the drag & drop borders. 38141 * 38142 * @private 38143 * @param {CellCoords} coordsOfSelection `CellCoords` coord object. 38144 * @returns {Array} 38145 */ 38146 38147 }, { 38148 key: 'getCoordsOfDragAndDropBorders', 38149 value: function getCoordsOfDragAndDropBorders(coordsOfSelection) { 38150 var topLeftCorner = this.hot.getSelectedRange().getTopLeftCorner(); 38151 var bottomRightCorner = this.hot.getSelectedRange().getBottomRightCorner(); 38152 var coords = void 0; 38153 38154 if (this.directions.includes(_utils.DIRECTIONS.vertical) && (bottomRightCorner.row < coordsOfSelection.row || topLeftCorner.row > coordsOfSelection.row)) { 38155 coords = new _src.CellCoords(coordsOfSelection.row, bottomRightCorner.col); 38156 } else if (this.directions.includes(_utils.DIRECTIONS.horizontal)) { 38157 coords = new _src.CellCoords(bottomRightCorner.row, coordsOfSelection.col); 38158 } else { 38159 // wrong direction 38160 return; 38161 } 38162 38163 return this.reduceSelectionAreaIfNeeded(coords); 38164 } 38165 38166 /** 38167 * Show the fill border. 38168 * 38169 * @private 38170 * @param {CellCoords} coordsOfSelection `CellCoords` coord object. 38171 */ 38172 38173 }, { 38174 key: 'showBorder', 38175 value: function showBorder(coordsOfSelection) { 38176 var coordsOfDragAndDropBorders = this.getCoordsOfDragAndDropBorders(coordsOfSelection); 38177 38178 if (coordsOfDragAndDropBorders) { 38179 this.redrawBorders(coordsOfDragAndDropBorders); 38180 } 38181 } 38182 38183 /** 38184 * Add new row 38185 * 38186 * @private 38187 */ 38188 38189 }, { 38190 key: 'addRow', 38191 value: function addRow() { 38192 var _this3 = this; 38193 38194 this.hot._registerTimeout(setTimeout(function () { 38195 _this3.hot.alter(INSERT_ROW_ALTER_ACTION_NAME, void 0, 1, _this3.pluginName + '.fill'); 38196 38197 _this3.addingStarted = false; 38198 }, INTERVAL_FOR_ADDING_ROW)); 38199 } 38200 38201 /** 38202 * Add new row 38203 * 38204 * Added By COSMOCODE 38205 * 38206 * @private 38207 */ 38208 38209 }, { 38210 key: 'addColumn', 38211 value: function addColumn() { 38212 var _this4 = this; 38213 38214 this.hot._registerTimeout(setTimeout(function () { 38215 _this4.hot.alter(INSERT_COLUMN_ALTER_ACTION_NAME, void 0, 1, _this4.pluginName + '.fill'); 38216 38217 _this4.addingStarted = false; 38218 }, INTERVAL_FOR_ADDING_ROW)); 38219 } 38220 38221 /** 38222 * Add new rows if they are needed to continue auto-filling values. 38223 * 38224 * @private 38225 */ 38226 38227 }, { 38228 key: 'addNewRowIfNeeded', 38229 value: function addNewRowIfNeeded() { 38230 if (this.hot.view.wt.selections.fill.cellRange && this.addingStarted === false && this.autoInsertRow) { 38231 var cornersOfSelectedCells = this.hot.getSelected(); 38232 var cornersOfSelectedDragArea = this.hot.view.wt.selections.fill.getCorners(); 38233 var nrOfTableRows = this.hot.countRows(); 38234 38235 if (cornersOfSelectedCells[2] < nrOfTableRows - 1 && cornersOfSelectedDragArea[2] === nrOfTableRows - 1) { 38236 this.addingStarted = true; 38237 38238 this.addRow(); 38239 } 38240 } 38241 } 38242 38243 /** 38244 * Add new rows if they are needed to continue auto-filling values. 38245 * 38246 * Added By COSMOCODE 38247 * 38248 * @private 38249 */ 38250 38251 }, { 38252 key: 'addNewColumnIfNeeded', 38253 value: function addNewColumnIfNeeded() { 38254 if (this.hot.view.wt.selections.fill.cellRange && this.addingStarted === false && this.autoInsertRow) { 38255 var cornersOfSelectedCells = this.hot.getSelected(); 38256 var cornersOfSelectedDragArea = this.hot.view.wt.selections.fill.getCorners(); 38257 var nrOfTableCols = this.hot.countCols(); 38258 38259 if (cornersOfSelectedCells[3] < nrOfTableCols - 1 && cornersOfSelectedDragArea[3] === nrOfTableCols - 1) { 38260 this.addingStarted = true; 38261 38262 this.addColumn(); 38263 } 38264 } 38265 } 38266 38267 /** 38268 * Get corners of selected cells. 38269 * 38270 * @private 38271 * @returns {Array} 38272 */ 38273 38274 }, { 38275 key: 'getCornersOfSelectedCells', 38276 value: function getCornersOfSelectedCells() { 38277 if (this.hot.selection.isMultiple()) { 38278 return this.hot.view.wt.selections.area.getCorners(); 38279 } 38280 return this.hot.view.wt.selections.current.getCorners(); 38281 } 38282 38283 /** 38284 * Get index of last adjacent filled in row 38285 * 38286 * @private 38287 * @param {Array} cornersOfSelectedCells indexes of selection corners. 38288 * @returns {Number} gives number greater than or equal to zero when selection adjacent can be applied. 38289 * or -1 when selection adjacent can't be applied 38290 */ 38291 38292 }, { 38293 key: 'getIndexOfLastAdjacentFilledInRow', 38294 value: function getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells) { 38295 var data = this.hot.getData(); 38296 var nrOfTableRows = this.hot.countRows(); 38297 var lastFilledInRowIndex = void 0; 38298 38299 for (var rowIndex = cornersOfSelectedCells[2] + 1; rowIndex < nrOfTableRows; rowIndex++) { 38300 for (var columnIndex = cornersOfSelectedCells[1]; columnIndex <= cornersOfSelectedCells[3]; columnIndex++) { 38301 var dataInCell = data[rowIndex][columnIndex]; 38302 38303 if (dataInCell) { 38304 return -1; 38305 } 38306 } 38307 38308 var dataInNextLeftCell = data[rowIndex][cornersOfSelectedCells[1] - 1]; 38309 var dataInNextRightCell = data[rowIndex][cornersOfSelectedCells[3] + 1]; 38310 38311 if (!!dataInNextLeftCell || !!dataInNextRightCell) { 38312 lastFilledInRowIndex = rowIndex; 38313 } 38314 } 38315 return lastFilledInRowIndex; 38316 } 38317 38318 /** 38319 * Add a selection from the start area to the specific row index. 38320 * 38321 * @private 38322 * @param {Array} selectStartArea selection area from which we start to create more comprehensive selection. 38323 * @param {Number} rowIndex 38324 */ 38325 38326 }, { 38327 key: 'addSelectionFromStartAreaToSpecificRowIndex', 38328 value: function addSelectionFromStartAreaToSpecificRowIndex(selectStartArea, rowIndex) { 38329 this.hot.view.wt.selections.fill.clear(); 38330 this.hot.view.wt.selections.fill.add(new _src.CellCoords(selectStartArea[0], selectStartArea[1])); 38331 this.hot.view.wt.selections.fill.add(new _src.CellCoords(rowIndex, selectStartArea[3])); 38332 } 38333 38334 /** 38335 * Set selection based on passed corners. 38336 * 38337 * @private 38338 * @param {Array} cornersOfArea 38339 */ 38340 38341 }, { 38342 key: 'setSelection', 38343 value: function setSelection(cornersOfArea) { 38344 this.hot.selection.setRangeStart(new _src.CellCoords(cornersOfArea[0], cornersOfArea[1])); 38345 this.hot.selection.setRangeEnd(new _src.CellCoords(cornersOfArea[2], cornersOfArea[3])); 38346 } 38347 38348 /** 38349 * Try to select cells down to the last row in the left column and then returns if selection was applied. 38350 * 38351 * @private 38352 * @returns {Boolean} 38353 */ 38354 38355 }, { 38356 key: 'selectAdjacent', 38357 value: function selectAdjacent() { 38358 var cornersOfSelectedCells = this.getCornersOfSelectedCells(); 38359 var lastFilledInRowIndex = this.getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells); 38360 38361 if (lastFilledInRowIndex === -1) { 38362 return false; 38363 } 38364 this.addSelectionFromStartAreaToSpecificRowIndex(cornersOfSelectedCells, lastFilledInRowIndex); 38365 38366 return true; 38367 } 38368 38369 /** 38370 * Reset selection of dragged area. 38371 * 38372 * @private 38373 */ 38374 38375 }, { 38376 key: 'resetSelectionOfDraggedArea', 38377 value: function resetSelectionOfDraggedArea() { 38378 this.handleDraggedCells = 0; 38379 38380 this.hot.view.wt.selections.fill.clear(); 38381 } 38382 38383 /** 38384 * Redraw borders. 38385 * 38386 * @private 38387 * @param {CellCoords} coords `CellCoords` coord object. 38388 */ 38389 38390 }, { 38391 key: 'redrawBorders', 38392 value: function redrawBorders(coords) { 38393 this.hot.view.wt.selections.fill.clear(); 38394 this.hot.view.wt.selections.fill.add(this.hot.getSelectedRange().from); 38395 this.hot.view.wt.selections.fill.add(this.hot.getSelectedRange().to); 38396 this.hot.view.wt.selections.fill.add(coords); 38397 this.hot.view.render(); 38398 } 38399 38400 /** 38401 * Get if mouse was dragged outside. 38402 * 38403 * @private 38404 * @param {MouseEvent} event `mousemove` event properties. 38405 * @returns {Boolean} 38406 */ 38407 38408 }, { 38409 key: 'getIfMouseWasDraggedOutside', 38410 value: function getIfMouseWasDraggedOutside(event) { 38411 var tableBottom = (0, _element.offset)(this.hot.table).top - (window.pageYOffset || document.documentElement.scrollTop) + (0, _element.outerHeight)(this.hot.table); 38412 var tableRight = (0, _element.offset)(this.hot.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + (0, _element.outerWidth)(this.hot.table); 38413 38414 return event.clientY > tableBottom && event.clientX <= tableRight; 38415 } 38416 38417 /** 38418 * Bind the events used by the plugin. 38419 * 38420 * @private 38421 */ 38422 38423 }, { 38424 key: 'registerEvents', 38425 value: function registerEvents() { 38426 var _this5 = this; 38427 38428 this.eventManager.addEventListener(document.documentElement, 'mouseup', function () { 38429 return _this5.onMouseUp(); 38430 }); 38431 this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) { 38432 return _this5.onMouseMove(event); 38433 }); 38434 } 38435 38436 /** 38437 * On cell corner double click callback. 38438 * 38439 * @private 38440 */ 38441 38442 }, { 38443 key: 'onCellCornerDblClick', 38444 value: function onCellCornerDblClick() { 38445 var selectionApplied = this.selectAdjacent(); 38446 38447 if (selectionApplied) { 38448 this.fillIn(); 38449 } 38450 } 38451 38452 /** 38453 * On after cell corner mouse down listener. 38454 * 38455 * @private 38456 */ 38457 38458 }, { 38459 key: 'onAfterCellCornerMouseDown', 38460 value: function onAfterCellCornerMouseDown() { 38461 this.handleDraggedCells = 1; 38462 this.mouseDownOnCellCorner = true; 38463 } 38464 38465 /** 38466 * On before cell mouse over listener. 38467 * 38468 * @private 38469 * @param {CellCoords} coords `CellCoords` coord object. 38470 */ 38471 38472 }, { 38473 key: 'onBeforeCellMouseOver', 38474 value: function onBeforeCellMouseOver(coords) { 38475 if (this.mouseDownOnCellCorner && !this.hot.view.isMouseDown() && this.handleDraggedCells) { 38476 this.handleDraggedCells++; 38477 38478 this.showBorder(coords); 38479 this.addNewRowIfNeeded(); 38480 this.addNewColumnIfNeeded(); // COSMOCODE 38481 } 38482 } 38483 38484 /** 38485 * On mouse up listener. 38486 * 38487 * @private 38488 */ 38489 38490 }, { 38491 key: 'onMouseUp', 38492 value: function onMouseUp() { 38493 if (this.handleDraggedCells) { 38494 if (this.handleDraggedCells > 1) { 38495 this.fillIn(); 38496 } 38497 38498 this.handleDraggedCells = 0; 38499 this.mouseDownOnCellCorner = false; 38500 } 38501 } 38502 38503 /** 38504 * On mouse move listener. 38505 * 38506 * @private 38507 * @param {MouseEvent} event `mousemove` event properties. 38508 */ 38509 38510 }, { 38511 key: 'onMouseMove', 38512 value: function onMouseMove(event) { 38513 var mouseWasDraggedOutside = this.getIfMouseWasDraggedOutside(event); 38514 38515 if (this.addingStarted === false && this.handleDraggedCells > 0 && mouseWasDraggedOutside) { 38516 this.mouseDragOutside = true; 38517 this.addingStarted = true; 38518 } else { 38519 this.mouseDragOutside = false; 38520 } 38521 38522 if (this.mouseDragOutside && this.autoInsertRow) { 38523 this.addRow(); 38524 } 38525 } 38526 38527 /** 38528 * Clear mapped settings. 38529 * 38530 * @private 38531 */ 38532 38533 }, { 38534 key: 'clearMappedSettings', 38535 value: function clearMappedSettings() { 38536 this.directions.length = 0; 38537 this.autoInsertRow = false; 38538 } 38539 38540 /** 38541 * Map settings. 38542 * 38543 * @private 38544 */ 38545 38546 }, { 38547 key: 'mapSettings', 38548 value: function mapSettings() { 38549 var mappedSettings = (0, _utils.getMappedFillHandleSetting)(this.hot.getSettings().fillHandle); 38550 this.directions = mappedSettings.directions; 38551 this.autoInsertRow = mappedSettings.autoInsertRow; 38552 } 38553 38554 /** 38555 * Destroy plugin instance. 38556 */ 38557 38558 }, { 38559 key: 'destroy', 38560 value: function destroy() { 38561 _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'destroy', this).call(this); 38562 } 38563 }]); 38564 38565 return Autofill; 38566}(_base2.default); 38567 38568(0, _plugins.registerPlugin)('autofill', Autofill); 38569 38570exports.default = Autofill; 38571 38572/***/ }), 38573/* 338 */ 38574/***/ (function(module, exports, __webpack_require__) { 38575 38576"use strict"; 38577 38578 38579exports.__esModule = true; 38580exports.DIRECTIONS = undefined; 38581exports.getDeltas = getDeltas; 38582exports.getDragDirectionAndRange = getDragDirectionAndRange; 38583exports.getMappedFillHandleSetting = getMappedFillHandleSetting; 38584 38585var _object = __webpack_require__(3); 38586 38587var _mixed = __webpack_require__(23); 38588 38589var _src = __webpack_require__(14); 38590 38591var DIRECTIONS = exports.DIRECTIONS = { 38592 horizontal: 'horizontal', 38593 vertical: 'vertical' 38594}; 38595 38596/** 38597 * Get deltas array. 38598 * 38599 * @param {CellCoords} start 38600 * @param {CellCoords} end 38601 * @param {Array} data 38602 * @param {String} direction 38603 * @returns {Array} 38604 */ 38605function getDeltas(start, end, data, direction) { 38606 var rowsLength = data.length; 38607 var columnsLength = data ? data[0].length : 0; 38608 var deltas = []; 38609 var diffRow = end.row - start.row; 38610 var diffCol = end.col - start.col; 38611 38612 if (['down', 'up'].indexOf(direction) !== -1) { 38613 var arr = []; 38614 38615 for (var col = 0; col <= diffCol; col++) { 38616 var startValue = parseInt(data[0][col], 10); 38617 var endValue = parseInt(data[rowsLength - 1][col], 10); 38618 var delta = (direction === 'down' ? endValue - startValue : startValue - endValue) / (rowsLength - 1) || 0; 38619 38620 arr.push(delta); 38621 } 38622 38623 deltas.push(arr); 38624 } 38625 38626 if (['right', 'left'].indexOf(direction) !== -1) { 38627 for (var row = 0; row <= diffRow; row++) { 38628 var _startValue = parseInt(data[row][0], 10); 38629 var _endValue = parseInt(data[row][columnsLength - 1], 10); 38630 var _delta = (direction === 'right' ? _endValue - _startValue : _startValue - _endValue) / (columnsLength - 1) || 0; 38631 38632 deltas.push([_delta]); 38633 } 38634 } 38635 38636 return deltas; 38637} 38638 38639/** 38640 * Get direction between positions and cords of selections difference (drag area) 38641 * 38642 * @param {Array} startSelection 38643 * @param {Array} endSelection 38644 * @returns {{direction: String, start: CellCoords, end: CellCoords}} 38645 */ 38646function getDragDirectionAndRange(startSelection, endSelection) { 38647 var startOfDragCoords = void 0, 38648 endOfDragCoords = void 0, 38649 directionOfDrag = void 0; 38650 38651 if (endSelection[0] === startSelection[0] && endSelection[1] < startSelection[1]) { 38652 directionOfDrag = 'left'; 38653 38654 startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]); 38655 endOfDragCoords = new _src.CellCoords(endSelection[2], startSelection[1] - 1); 38656 } else if (endSelection[0] === startSelection[0] && endSelection[3] > startSelection[3]) { 38657 directionOfDrag = 'right'; 38658 38659 startOfDragCoords = new _src.CellCoords(endSelection[0], startSelection[3] + 1); 38660 endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]); 38661 } else if (endSelection[0] < startSelection[0] && endSelection[1] === startSelection[1]) { 38662 directionOfDrag = 'up'; 38663 38664 startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]); 38665 endOfDragCoords = new _src.CellCoords(startSelection[0] - 1, endSelection[3]); 38666 } else if (endSelection[2] > startSelection[2] && endSelection[1] === startSelection[1]) { 38667 directionOfDrag = 'down'; 38668 38669 startOfDragCoords = new _src.CellCoords(startSelection[2] + 1, endSelection[1]); 38670 endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]); 38671 } 38672 38673 return { 38674 directionOfDrag: directionOfDrag, 38675 startOfDragCoords: startOfDragCoords, 38676 endOfDragCoords: endOfDragCoords 38677 }; 38678} 38679 38680/** 38681 * Get mapped FillHandle setting containing information about 38682 * allowed FillHandle directions and if allowed is automatic insertion of rows on drag 38683 * 38684 * @param {Boolean|Object} fillHandle property of Handsontable settings 38685 * @returns {{directions: Array, autoInsertRow: Boolean}} object allowing access to information 38686 * about FillHandle in more useful way 38687 */ 38688function getMappedFillHandleSetting(fillHandle) { 38689 var mappedSettings = {}; 38690 38691 if (fillHandle === true) { 38692 mappedSettings.directions = Object.keys(DIRECTIONS); 38693 mappedSettings.autoInsertRow = true; 38694 } else if ((0, _object.isObject)(fillHandle)) { 38695 if ((0, _mixed.isDefined)(fillHandle.autoInsertRow)) { 38696 38697 // autoInsertRow for horizontal direction will be always false 38698 38699 if (fillHandle.direction === DIRECTIONS.horizontal) { 38700 mappedSettings.autoInsertRow = false; 38701 } else { 38702 mappedSettings.autoInsertRow = fillHandle.autoInsertRow; 38703 } 38704 } else { 38705 mappedSettings.autoInsertRow = false; 38706 } 38707 38708 if ((0, _mixed.isDefined)(fillHandle.direction)) { 38709 mappedSettings.directions = [fillHandle.direction]; 38710 } else { 38711 mappedSettings.directions = Object.keys(DIRECTIONS); 38712 } 38713 } else if (typeof fillHandle === 'string') { 38714 mappedSettings.directions = [fillHandle]; 38715 mappedSettings.autoInsertRow = true; 38716 } else { 38717 mappedSettings.directions = []; 38718 mappedSettings.autoInsertRow = false; 38719 } 38720 38721 return mappedSettings; 38722} 38723 38724/***/ }), 38725/* 339 */ 38726/***/ (function(module, exports, __webpack_require__) { 38727 38728"use strict"; 38729 38730 38731exports.__esModule = true; 38732 38733var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 38734 38735var _array = __webpack_require__(2); 38736 38737var _object = __webpack_require__(3); 38738 38739function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38740 38741/** 38742 * Command executor for ContextMenu. 38743 * 38744 * @class CommandExecutor 38745 * @plugin ContextMenu 38746 */ 38747var CommandExecutor = function () { 38748 function CommandExecutor(hotInstance) { 38749 _classCallCheck(this, CommandExecutor); 38750 38751 this.hot = hotInstance; 38752 this.commands = {}; 38753 this.commonCallback = null; 38754 } 38755 38756 /** 38757 * Register command. 38758 * 38759 * @param {String} name Command name. 38760 * @param {Object} commandDescriptor Command descriptor object with properties like `key` (command id), 38761 * `callback` (task to execute), `name` (command name), `disabled` (command availability). 38762 */ 38763 38764 38765 _createClass(CommandExecutor, [{ 38766 key: 'registerCommand', 38767 value: function registerCommand(name, commandDescriptor) { 38768 this.commands[name] = commandDescriptor; 38769 } 38770 38771 /** 38772 * Set common callback which will be trigger on every executed command. 38773 * 38774 * @param {Function} callback Function which will be fired on every command execute. 38775 */ 38776 38777 }, { 38778 key: 'setCommonCallback', 38779 value: function setCommonCallback(callback) { 38780 this.commonCallback = callback; 38781 } 38782 38783 /** 38784 * Execute command by its name. 38785 * 38786 * @param {String} commandName Command id. 38787 * @param {*} params Arguments passed to command task. 38788 */ 38789 38790 }, { 38791 key: 'execute', 38792 value: function execute(commandName) { 38793 var _this = this; 38794 38795 for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 38796 params[_key - 1] = arguments[_key]; 38797 } 38798 38799 var commandSplit = commandName.split(':'); 38800 commandName = commandSplit[0]; 38801 38802 var subCommandName = commandSplit.length === 2 ? commandSplit[1] : null; 38803 var command = this.commands[commandName]; 38804 38805 if (!command) { 38806 throw new Error('Menu command \'' + commandName + '\' not exists.'); 38807 } 38808 if (subCommandName && command.submenu) { 38809 command = findSubCommand(subCommandName, command.submenu.items); 38810 } 38811 if (command.disabled === true) { 38812 return; 38813 } 38814 if (typeof command.disabled == 'function' && command.disabled.call(this.hot) === true) { 38815 return; 38816 } 38817 if ((0, _object.hasOwnProperty)(command, 'submenu')) { 38818 return; 38819 } 38820 var callbacks = []; 38821 38822 if (typeof command.callback === 'function') { 38823 callbacks.push(command.callback); 38824 } 38825 if (typeof this.commonCallback === 'function') { 38826 callbacks.push(this.commonCallback); 38827 } 38828 params.unshift(commandSplit.join(':')); 38829 (0, _array.arrayEach)(callbacks, function (callback) { 38830 return callback.apply(_this.hot, params); 38831 }); 38832 } 38833 }]); 38834 38835 return CommandExecutor; 38836}(); 38837 38838function findSubCommand(subCommandName, subCommands) { 38839 var command = void 0; 38840 38841 (0, _array.arrayEach)(subCommands, function (cmd) { 38842 var cmds = cmd.key ? cmd.key.split(':') : null; 38843 38844 if (Array.isArray(cmds) && cmds[1] === subCommandName) { 38845 command = cmd; 38846 38847 return false; 38848 } 38849 }); 38850 38851 return command; 38852} 38853 38854exports.default = CommandExecutor; 38855 38856/***/ }), 38857/* 340 */ 38858/***/ (function(module, exports, __webpack_require__) { 38859 38860"use strict"; 38861 38862 38863exports.__esModule = true; 38864 38865var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 38866 38867var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 38868 38869var _base = __webpack_require__(16); 38870 38871var _base2 = _interopRequireDefault(_base); 38872 38873var _pluginHooks = __webpack_require__(11); 38874 38875var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 38876 38877var _array = __webpack_require__(2); 38878 38879var _commandExecutor = __webpack_require__(339); 38880 38881var _commandExecutor2 = _interopRequireDefault(_commandExecutor); 38882 38883var _eventManager = __webpack_require__(4); 38884 38885var _eventManager2 = _interopRequireDefault(_eventManager); 38886 38887var _itemsFactory = __webpack_require__(342); 38888 38889var _itemsFactory2 = _interopRequireDefault(_itemsFactory); 38890 38891var _menu = __webpack_require__(343); 38892 38893var _menu2 = _interopRequireDefault(_menu); 38894 38895var _plugins = __webpack_require__(9); 38896 38897var _event = __webpack_require__(7); 38898 38899var _element = __webpack_require__(0); 38900 38901var _predefinedItems = __webpack_require__(72); 38902 38903__webpack_require__(299); 38904 38905function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 38906 38907function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 38908 38909function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 38910 38911function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 38912 38913_pluginHooks2.default.getSingleton().register('afterContextMenuDefaultOptions'); 38914_pluginHooks2.default.getSingleton().register('afterContextMenuShow'); 38915_pluginHooks2.default.getSingleton().register('afterContextMenuHide'); 38916_pluginHooks2.default.getSingleton().register('afterContextMenuExecute'); 38917 38918/** 38919 * @description 38920 * This plugin creates the Handsontable Context Menu. It allows to create a new row or 38921 * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html). 38922 * Possible values: 38923 * * `true` (to enable default options), 38924 * * `false` (to disable completely) 38925 * 38926 * or array of any available strings: 38927 * * `["row_above", "row_below", "col_left", "col_right", 38928 * "remove_row", "remove_col", "---------", "undo", "redo"]`. 38929 * 38930 * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples. 38931 * 38932 * @example 38933 * ```js 38934 * ... 38935 * // as a boolean 38936 * contextMenu: true 38937 * ... 38938 * // as a array 38939 * contextMenu: ['row_above', 'row_below', '---------', 'undo', 'redo'] 38940 * ... 38941 * ``` 38942 * 38943 * @plugin ContextMenu 38944 */ 38945 38946var ContextMenu = function (_BasePlugin) { 38947 _inherits(ContextMenu, _BasePlugin); 38948 38949 _createClass(ContextMenu, null, [{ 38950 key: 'DEFAULT_ITEMS', 38951 38952 /** 38953 * Default menu items order when `contextMenu` is enabled by `true`. 38954 * 38955 * @returns {Array} 38956 */ 38957 get: function get() { 38958 return [_predefinedItems.ROW_ABOVE, _predefinedItems.ROW_BELOW, _predefinedItems.SEPARATOR, _predefinedItems.COLUMN_LEFT, _predefinedItems.COLUMN_RIGHT, _predefinedItems.SEPARATOR, _predefinedItems.REMOVE_ROW, _predefinedItems.REMOVE_COLUMN, _predefinedItems.SEPARATOR, _predefinedItems.UNDO, _predefinedItems.REDO, _predefinedItems.SEPARATOR, _predefinedItems.READ_ONLY, _predefinedItems.SEPARATOR, _predefinedItems.ALIGNMENT]; 38959 } 38960 }]); 38961 38962 function ContextMenu(hotInstance) { 38963 _classCallCheck(this, ContextMenu); 38964 38965 /** 38966 * Instance of {@link EventManager}. 38967 * 38968 * @type {EventManager} 38969 */ 38970 var _this = _possibleConstructorReturn(this, (ContextMenu.__proto__ || Object.getPrototypeOf(ContextMenu)).call(this, hotInstance)); 38971 38972 _this.eventManager = new _eventManager2.default(_this); 38973 /** 38974 * Instance of {@link CommandExecutor}. 38975 * 38976 * @type {CommandExecutor} 38977 */ 38978 _this.commandExecutor = new _commandExecutor2.default(_this.hot); 38979 /** 38980 * Instance of {@link ItemsFactory}. 38981 * 38982 * @type {ItemsFactory} 38983 */ 38984 _this.itemsFactory = null; 38985 /** 38986 * Instance of {@link Menu}. 38987 * 38988 * @type {Menu} 38989 */ 38990 _this.menu = null; 38991 return _this; 38992 } 38993 38994 /** 38995 * Check if the plugin is enabled in the Handsontable settings. 38996 * 38997 * @returns {Boolean} 38998 */ 38999 39000 39001 _createClass(ContextMenu, [{ 39002 key: 'isEnabled', 39003 value: function isEnabled() { 39004 return this.hot.getSettings().contextMenu; 39005 } 39006 39007 /** 39008 * Enable plugin for this Handsontable instance. 39009 */ 39010 39011 }, { 39012 key: 'enablePlugin', 39013 value: function enablePlugin() { 39014 var _this2 = this; 39015 39016 if (this.enabled) { 39017 return; 39018 } 39019 this.itemsFactory = new _itemsFactory2.default(this.hot, ContextMenu.DEFAULT_ITEMS); 39020 39021 var settings = this.hot.getSettings().contextMenu; 39022 var predefinedItems = { 39023 items: this.itemsFactory.getItems(settings) 39024 }; 39025 this.registerEvents(); 39026 39027 if (typeof settings.callback === 'function') { 39028 this.commandExecutor.setCommonCallback(settings.callback); 39029 } 39030 _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'enablePlugin', this).call(this); 39031 39032 this.callOnPluginsReady(function () { 39033 _this2.hot.runHooks('afterContextMenuDefaultOptions', predefinedItems); 39034 39035 _this2.itemsFactory.setPredefinedItems(predefinedItems.items); 39036 var menuItems = _this2.itemsFactory.getItems(settings); 39037 39038 _this2.menu = new _menu2.default(_this2.hot, { 39039 className: 'htContextMenu', 39040 keepInViewport: true 39041 }); 39042 _this2.hot.runHooks('beforeContextMenuSetItems', menuItems); 39043 39044 _this2.menu.setMenuItems(menuItems); 39045 39046 _this2.menu.addLocalHook('afterOpen', function () { 39047 return _this2.onMenuAfterOpen(); 39048 }); 39049 _this2.menu.addLocalHook('afterClose', function () { 39050 return _this2.onMenuAfterClose(); 39051 }); 39052 _this2.menu.addLocalHook('executeCommand', function () { 39053 for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) { 39054 params[_key] = arguments[_key]; 39055 } 39056 39057 return _this2.executeCommand.apply(_this2, params); 39058 }); 39059 39060 // Register all commands. Predefined and added by user or by plugins 39061 (0, _array.arrayEach)(menuItems, function (command) { 39062 return _this2.commandExecutor.registerCommand(command.key, command); 39063 }); 39064 }); 39065 } 39066 39067 /** 39068 * Updates the plugin to use the latest options you have specified. 39069 */ 39070 39071 }, { 39072 key: 'updatePlugin', 39073 value: function updatePlugin() { 39074 this.disablePlugin(); 39075 this.enablePlugin(); 39076 39077 _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'updatePlugin', this).call(this); 39078 } 39079 39080 /** 39081 * Disable plugin for this Handsontable instance. 39082 */ 39083 39084 }, { 39085 key: 'disablePlugin', 39086 value: function disablePlugin() { 39087 this.close(); 39088 39089 if (this.menu) { 39090 this.menu.destroy(); 39091 this.menu = null; 39092 } 39093 _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'disablePlugin', this).call(this); 39094 } 39095 39096 /** 39097 * Register dom listeners. 39098 * 39099 * @private 39100 */ 39101 39102 }, { 39103 key: 'registerEvents', 39104 value: function registerEvents() { 39105 var _this3 = this; 39106 39107 this.eventManager.addEventListener(this.hot.rootElement, 'contextmenu', function (event) { 39108 return _this3.onContextMenu(event); 39109 }); 39110 } 39111 39112 /** 39113 * Open menu and re-position it based on dom event object. 39114 * 39115 * @param {Event} event The event object. 39116 */ 39117 39118 }, { 39119 key: 'open', 39120 value: function open(event) { 39121 if (!this.menu) { 39122 return; 39123 } 39124 this.menu.open(); 39125 this.menu.setPosition({ 39126 top: parseInt((0, _event.pageY)(event), 10) - (0, _element.getWindowScrollTop)(), 39127 left: parseInt((0, _event.pageX)(event), 10) - (0, _element.getWindowScrollLeft)() 39128 }); 39129 39130 // ContextMenu is not detected HotTableEnv correctly because is injected outside hot-table 39131 this.menu.hotMenu.isHotTableEnv = this.hot.isHotTableEnv; 39132 // Handsontable.eventManager.isHotTableEnv = this.hot.isHotTableEnv; 39133 } 39134 39135 /** 39136 * Close menu. 39137 */ 39138 39139 }, { 39140 key: 'close', 39141 value: function close() { 39142 if (!this.menu) { 39143 return; 39144 } 39145 this.menu.close(); 39146 } 39147 39148 /** 39149 * Execute context menu command. 39150 * 39151 * You can execute all predefined commands: 39152 * * `'row_above'` - Insert row above 39153 * * `'row_below'` - Insert row below 39154 * * `'col_left'` - Insert column on the left 39155 * * `'col_right'` - Insert column on the right 39156 * * `'clear_column'` - Clear selected column 39157 * * `'remove_row'` - Remove row 39158 * * `'remove_col'` - Remove column 39159 * * `'undo'` - Undo last action 39160 * * `'redo'` - Redo last action 39161 * * `'make_read_only'` - Make cell read only 39162 * * `'alignment:left'` - Alignment to the left 39163 * * `'alignment:top'` - Alignment to the top 39164 * * `'alignment:right'` - Alignment to the right 39165 * * `'alignment:bottom'` - Alignment to the bottom 39166 * * `'alignment:middle'` - Alignment to the middle 39167 * * `'alignment:center'` - Alignment to the center (justify) 39168 * 39169 * Or you can execute command registered in settings where `key` is your command name. 39170 * 39171 * @param {String} commandName 39172 * @param {*} params 39173 */ 39174 39175 }, { 39176 key: 'executeCommand', 39177 value: function executeCommand() { 39178 for (var _len2 = arguments.length, params = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 39179 params[_key2] = arguments[_key2]; 39180 } 39181 39182 this.commandExecutor.execute.apply(this.commandExecutor, params); 39183 } 39184 39185 /** 39186 * On context menu listener. 39187 * 39188 * @private 39189 * @param {Event} event 39190 */ 39191 39192 }, { 39193 key: 'onContextMenu', 39194 value: function onContextMenu(event) { 39195 var settings = this.hot.getSettings(); 39196 var showRowHeaders = settings.rowHeaders; 39197 var showColHeaders = settings.colHeaders; 39198 39199 function isValidElement(element) { 39200 return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD'; 39201 } 39202 // if event is from hot-table we must get web component element not element inside him 39203 var element = event.realTarget; 39204 this.close(); 39205 39206 if ((0, _element.hasClass)(element, 'handsontableInput')) { 39207 return; 39208 } 39209 39210 event.preventDefault(); 39211 (0, _event.stopPropagation)(event); 39212 39213 if (!(showRowHeaders || showColHeaders)) { 39214 if (!isValidElement(element) && !((0, _element.hasClass)(element, 'current') && (0, _element.hasClass)(element, 'wtBorder'))) { 39215 return; 39216 } 39217 } 39218 39219 this.open(event); 39220 } 39221 39222 /** 39223 * On menu after open listener. 39224 * 39225 * @private 39226 */ 39227 39228 }, { 39229 key: 'onMenuAfterOpen', 39230 value: function onMenuAfterOpen() { 39231 this.hot.runHooks('afterContextMenuShow', this); 39232 } 39233 39234 /** 39235 * On menu after close listener. 39236 * 39237 * @private 39238 */ 39239 39240 }, { 39241 key: 'onMenuAfterClose', 39242 value: function onMenuAfterClose() { 39243 this.hot.listen(); 39244 this.hot.runHooks('afterContextMenuHide', this); 39245 } 39246 39247 /** 39248 * Destroy instance. 39249 */ 39250 39251 }, { 39252 key: 'destroy', 39253 value: function destroy() { 39254 this.close(); 39255 39256 if (this.menu) { 39257 this.menu.destroy(); 39258 } 39259 _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'destroy', this).call(this); 39260 } 39261 }]); 39262 39263 return ContextMenu; 39264}(_base2.default); 39265 39266ContextMenu.SEPARATOR = { 39267 name: _predefinedItems.SEPARATOR 39268}; 39269 39270(0, _plugins.registerPlugin)('contextMenu', ContextMenu); 39271 39272exports.default = ContextMenu; 39273 39274/***/ }), 39275/* 341 */ 39276/***/ (function(module, exports, __webpack_require__) { 39277 39278"use strict"; 39279 39280 39281exports.__esModule = true; 39282 39283var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 39284 39285var _element = __webpack_require__(0); 39286 39287var _event = __webpack_require__(7); 39288 39289function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39290 39291/** 39292 * Helper class for checking if element will fit at the desired side of cursor. 39293 * 39294 * @class Cursor 39295 * @plugin ContextMenu 39296 */ 39297var Cursor = function () { 39298 function Cursor(object) { 39299 _classCallCheck(this, Cursor); 39300 39301 var windowScrollTop = (0, _element.getWindowScrollTop)(); 39302 var windowScrollLeft = (0, _element.getWindowScrollLeft)(); 39303 var top = void 0, 39304 topRelative = void 0; 39305 var left = void 0, 39306 leftRelative = void 0; 39307 var cellHeight = void 0, 39308 cellWidth = void 0; 39309 39310 this.type = this.getSourceType(object); 39311 39312 if (this.type === 'literal') { 39313 top = parseInt(object.top, 10); 39314 left = parseInt(object.left, 10); 39315 cellHeight = object.height || 0; 39316 cellWidth = object.width || 0; 39317 topRelative = top; 39318 leftRelative = left; 39319 top += windowScrollTop; 39320 left += windowScrollLeft; 39321 } else if (this.type === 'event') { 39322 top = parseInt((0, _event.pageY)(object), 10); 39323 left = parseInt((0, _event.pageX)(object), 10); 39324 cellHeight = object.target.clientHeight; 39325 cellWidth = object.target.clientWidth; 39326 topRelative = top - windowScrollTop; 39327 leftRelative = left - windowScrollLeft; 39328 } 39329 39330 this.top = top; 39331 this.topRelative = topRelative; 39332 this.left = left; 39333 this.leftRelative = leftRelative; 39334 this.scrollTop = windowScrollTop; 39335 this.scrollLeft = windowScrollLeft; 39336 this.cellHeight = cellHeight; 39337 this.cellWidth = cellWidth; 39338 } 39339 39340 /** 39341 * Get source type name. 39342 * 39343 * @param {*} object Event or Object with coordinates. 39344 * @returns {String} Returns one of this values: `'literal'`, `'event'`. 39345 */ 39346 39347 39348 _createClass(Cursor, [{ 39349 key: 'getSourceType', 39350 value: function getSourceType(object) { 39351 var type = 'literal'; 39352 39353 if (object instanceof Event) { 39354 type = 'event'; 39355 } 39356 39357 return type; 39358 } 39359 39360 /** 39361 * Checks if element can be placed above the cursor. 39362 * 39363 * @param {HTMLElement} element Element to check if it's size will fit above the cursor. 39364 * @returns {Boolean} 39365 */ 39366 39367 }, { 39368 key: 'fitsAbove', 39369 value: function fitsAbove(element) { 39370 return this.topRelative >= element.offsetHeight; 39371 } 39372 39373 /** 39374 * Checks if element can be placed below the cursor. 39375 * 39376 * @param {HTMLElement} element Element to check if it's size will fit below the cursor. 39377 * @param {Number} [viewportHeight] The viewport height. 39378 * @returns {Boolean} 39379 */ 39380 39381 }, { 39382 key: 'fitsBelow', 39383 value: function fitsBelow(element) { 39384 var viewportHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerHeight; 39385 39386 return this.topRelative + element.offsetHeight <= viewportHeight; 39387 } 39388 39389 /** 39390 * Checks if element can be placed on the right of the cursor. 39391 * 39392 * @param {HTMLElement} element Element to check if it's size will fit on the right of the cursor. 39393 * @param {Number} [viewportWidth] The viewport width. 39394 * @returns {Boolean} 39395 */ 39396 39397 }, { 39398 key: 'fitsOnRight', 39399 value: function fitsOnRight(element) { 39400 var viewportWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerWidth; 39401 39402 return this.leftRelative + this.cellWidth + element.offsetWidth <= viewportWidth; 39403 } 39404 39405 /** 39406 * Checks if element can be placed on the left on the cursor. 39407 * 39408 * @param {HTMLElement} element Element to check if it's size will fit on the left of the cursor. 39409 * @returns {Boolean} 39410 */ 39411 39412 }, { 39413 key: 'fitsOnLeft', 39414 value: function fitsOnLeft(element) { 39415 return this.leftRelative >= element.offsetWidth; 39416 } 39417 }]); 39418 39419 return Cursor; 39420}(); 39421 39422exports.default = Cursor; 39423 39424/***/ }), 39425/* 342 */ 39426/***/ (function(module, exports, __webpack_require__) { 39427 39428"use strict"; 39429 39430 39431exports.__esModule = true; 39432 39433var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 39434 39435var _object = __webpack_require__(3); 39436 39437var _array = __webpack_require__(2); 39438 39439var _predefinedItems = __webpack_require__(72); 39440 39441function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39442 39443/** 39444 * Predefined items class factory for menu items. 39445 * 39446 * @class ItemsFactory 39447 * @plugin ContextMenu 39448 */ 39449var ItemsFactory = function () { 39450 function ItemsFactory(hotInstance) { 39451 var orderPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 39452 39453 _classCallCheck(this, ItemsFactory); 39454 39455 this.hot = hotInstance; 39456 this.predefinedItems = (0, _predefinedItems.predefinedItems)(); 39457 this.defaultOrderPattern = orderPattern; 39458 } 39459 39460 /** 39461 * Set predefined items. 39462 * 39463 * @param {Array} predefinedItems Array of predefined items. 39464 */ 39465 39466 39467 _createClass(ItemsFactory, [{ 39468 key: 'setPredefinedItems', 39469 value: function setPredefinedItems(predefinedItems) { 39470 var _this = this; 39471 39472 var items = {}; 39473 39474 this.defaultOrderPattern.length = 0; 39475 39476 (0, _object.objectEach)(predefinedItems, function (value, key) { 39477 var menuItemKey = ''; 39478 39479 if (value.name === _predefinedItems.SEPARATOR) { 39480 items[_predefinedItems.SEPARATOR] = value; 39481 menuItemKey = _predefinedItems.SEPARATOR; 39482 39483 // Menu item added as a property to array 39484 } else if (isNaN(parseInt(key, 10))) { 39485 value.key = value.key === void 0 ? key : value.key; 39486 items[key] = value; 39487 menuItemKey = value.key; 39488 } else { 39489 items[value.key] = value; 39490 menuItemKey = value.key; 39491 } 39492 _this.defaultOrderPattern.push(menuItemKey); 39493 }); 39494 this.predefinedItems = items; 39495 } 39496 39497 /** 39498 * Get all menu items based on pattern. 39499 * 39500 * @param {Array|Object|Boolean} pattern Pattern which you can define by displaying menu items order. If `true` default 39501 * pattern will be used. 39502 * @returns {Array} 39503 */ 39504 39505 }, { 39506 key: 'getItems', 39507 value: function getItems() { 39508 var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 39509 39510 return _getItems(pattern, this.defaultOrderPattern, this.predefinedItems); 39511 } 39512 }]); 39513 39514 return ItemsFactory; 39515}(); 39516 39517function _getItems() { 39518 var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 39519 var defaultPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 39520 var items = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 39521 39522 var result = []; 39523 39524 if (pattern && pattern.items) { 39525 pattern = pattern.items; 39526 } else if (!Array.isArray(pattern)) { 39527 pattern = defaultPattern; 39528 } 39529 if ((0, _object.isObject)(pattern)) { 39530 (0, _object.objectEach)(pattern, function (value, key) { 39531 var item = items[typeof value === 'string' ? value : key]; 39532 39533 if (!item) { 39534 item = value; 39535 } 39536 if ((0, _object.isObject)(value)) { 39537 (0, _object.extend)(item, value); 39538 } else if (typeof item === 'string') { 39539 item = { name: item }; 39540 } 39541 if (item.key === void 0) { 39542 item.key = key; 39543 } 39544 result.push(item); 39545 }); 39546 } else { 39547 (0, _array.arrayEach)(pattern, function (name, key) { 39548 var item = items[name]; 39549 39550 // Item deleted from settings `allowInsertRow: false` etc. 39551 if (!item && _predefinedItems.ITEMS.indexOf(name) >= 0) { 39552 return; 39553 } 39554 if (!item) { 39555 item = { name: name, key: '' + key }; 39556 } 39557 if ((0, _object.isObject)(name)) { 39558 (0, _object.extend)(item, name); 39559 } 39560 if (item.key === void 0) { 39561 item.key = key; 39562 } 39563 result.push(item); 39564 }); 39565 } 39566 39567 return result; 39568} 39569 39570exports.default = ItemsFactory; 39571 39572/***/ }), 39573/* 343 */ 39574/***/ (function(module, exports, __webpack_require__) { 39575 39576"use strict"; 39577 39578 39579exports.__esModule = true; 39580 39581var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 39582 39583var _core = __webpack_require__(66); 39584 39585var _core2 = _interopRequireDefault(_core); 39586 39587var _element = __webpack_require__(0); 39588 39589var _array = __webpack_require__(2); 39590 39591var _cursor = __webpack_require__(341); 39592 39593var _cursor2 = _interopRequireDefault(_cursor); 39594 39595var _eventManager = __webpack_require__(4); 39596 39597var _eventManager2 = _interopRequireDefault(_eventManager); 39598 39599var _object = __webpack_require__(3); 39600 39601var _function = __webpack_require__(35); 39602 39603var _utils = __webpack_require__(19); 39604 39605var _unicode = __webpack_require__(15); 39606 39607var _localHooks = __webpack_require__(333); 39608 39609var _localHooks2 = _interopRequireDefault(_localHooks); 39610 39611var _predefinedItems = __webpack_require__(72); 39612 39613var _event = __webpack_require__(7); 39614 39615function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 39616 39617function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39618 39619/** 39620 * @class Menu 39621 * @plugin ContextMenu 39622 */ 39623var Menu = function () { 39624 function Menu(hotInstance, options) { 39625 _classCallCheck(this, Menu); 39626 39627 this.hot = hotInstance; 39628 this.options = options || { 39629 parent: null, 39630 name: null, 39631 className: '', 39632 keepInViewport: true, 39633 standalone: false 39634 }; 39635 this.eventManager = new _eventManager2.default(this); 39636 this.container = this.createContainer(this.options.name); 39637 this.hotMenu = null; 39638 this.hotSubMenus = {}; 39639 this.parentMenu = this.options.parent || null; 39640 this.menuItems = null; 39641 this.origOutsideClickDeselects = null; 39642 this.keyEvent = false; 39643 39644 this.offset = { 39645 above: 0, 39646 below: 0, 39647 left: 0, 39648 right: 0 39649 }; 39650 this._afterScrollCallback = null; 39651 39652 this.registerEvents(); 39653 } 39654 39655 /** 39656 * Register event listeners. 39657 * 39658 * @private 39659 */ 39660 39661 39662 _createClass(Menu, [{ 39663 key: 'registerEvents', 39664 value: function registerEvents() { 39665 var _this = this; 39666 39667 this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) { 39668 return _this.onDocumentMouseDown(event); 39669 }); 39670 } 39671 39672 /** 39673 * Set array of objects which defines menu items. 39674 * 39675 * @param {Array} menuItems Menu items to display. 39676 */ 39677 39678 }, { 39679 key: 'setMenuItems', 39680 value: function setMenuItems(menuItems) { 39681 this.menuItems = menuItems; 39682 } 39683 39684 /** 39685 * Set offset menu position for specified area (`above`, `below`, `left` or `right`). 39686 * 39687 * @param {String} area Specified area name (`above`, `below`, `left` or `right`). 39688 * @param {Number} offset Offset value. 39689 */ 39690 39691 }, { 39692 key: 'setOffset', 39693 value: function setOffset(area) { 39694 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 39695 39696 this.offset[area] = offset; 39697 } 39698 39699 /** 39700 * Check if menu is using as sub-menu. 39701 * 39702 * @returns {Boolean} 39703 */ 39704 39705 }, { 39706 key: 'isSubMenu', 39707 value: function isSubMenu() { 39708 return this.parentMenu !== null; 39709 } 39710 39711 /** 39712 * Open menu. 39713 */ 39714 39715 }, { 39716 key: 'open', 39717 value: function open() { 39718 var _this2 = this; 39719 39720 this.container.removeAttribute('style'); 39721 this.container.style.display = 'block'; 39722 39723 var delayedOpenSubMenu = (0, _function.debounce)(function (row) { 39724 return _this2.openSubMenu(row); 39725 }, 300); 39726 39727 var filteredItems = (0, _array.arrayFilter)(this.menuItems, function (item) { 39728 return (0, _utils.isItemHidden)(item, _this2.hot); 39729 }); 39730 39731 filteredItems = (0, _utils.filterSeparators)(filteredItems, _predefinedItems.SEPARATOR); 39732 39733 var settings = { 39734 data: filteredItems, 39735 colHeaders: false, 39736 colWidths: [200], 39737 autoRowSize: false, 39738 readOnly: true, 39739 copyPaste: false, 39740 columns: [{ 39741 data: 'name', 39742 renderer: function renderer(hot, TD, row, col, prop, value) { 39743 return _this2.menuItemRenderer(hot, TD, row, col, prop, value); 39744 } 39745 }], 39746 renderAllRows: true, 39747 fragmentSelection: 'cell', 39748 disableVisualSelection: 'area', 39749 beforeKeyDown: function beforeKeyDown(event) { 39750 return _this2.onBeforeKeyDown(event); 39751 }, 39752 afterOnCellMouseOver: function afterOnCellMouseOver(event, coords, TD) { 39753 if (_this2.isAllSubMenusClosed()) { 39754 delayedOpenSubMenu(coords.row); 39755 } else { 39756 _this2.openSubMenu(coords.row); 39757 } 39758 }, 39759 rowHeights: function rowHeights(row) { 39760 return filteredItems[row].name === _predefinedItems.SEPARATOR ? 1 : 23; 39761 } 39762 }; 39763 this.origOutsideClickDeselects = this.hot.getSettings().outsideClickDeselects; 39764 this.hot.getSettings().outsideClickDeselects = false; 39765 this.hotMenu = new _core2.default(this.container, settings); 39766 this.hotMenu.addHook('afterInit', function () { 39767 return _this2.onAfterInit(); 39768 }); 39769 this.hotMenu.addHook('afterSelection', function (r, c, r2, c2, preventScrolling) { 39770 return _this2.onAfterSelection(r, c, r2, c2, preventScrolling); 39771 }); 39772 this.hotMenu.init(); 39773 this.hotMenu.listen(); 39774 this.blockMainTableCallbacks(); 39775 this.runLocalHooks('afterOpen'); 39776 } 39777 39778 /** 39779 * Close menu. 39780 * 39781 * @param {Boolean} [closeParent=false] if `true` try to close parent menu if exists. 39782 */ 39783 39784 }, { 39785 key: 'close', 39786 value: function close() { 39787 var closeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 39788 39789 if (!this.isOpened()) { 39790 return; 39791 } 39792 if (closeParent && this.parentMenu) { 39793 this.parentMenu.close(); 39794 } else { 39795 this.closeAllSubMenus(); 39796 this.container.style.display = 'none'; 39797 this.releaseMainTableCallbacks(); 39798 this.hotMenu.destroy(); 39799 this.hotMenu = null; 39800 this.hot.getSettings().outsideClickDeselects = this.origOutsideClickDeselects; 39801 this.runLocalHooks('afterClose'); 39802 39803 if (this.parentMenu) { 39804 this.parentMenu.hotMenu.listen(); 39805 } 39806 } 39807 } 39808 39809 /** 39810 * Open sub menu at the provided row index. 39811 * 39812 * @param {Number} row Row index. 39813 * @returns {Menu|Boolean} Returns created menu or `false` if no one menu was created. 39814 */ 39815 39816 }, { 39817 key: 'openSubMenu', 39818 value: function openSubMenu(row) { 39819 if (!this.hotMenu) { 39820 return false; 39821 } 39822 var cell = this.hotMenu.getCell(row, 0); 39823 39824 this.closeAllSubMenus(); 39825 39826 if (!cell || !(0, _utils.hasSubMenu)(cell)) { 39827 return false; 39828 } 39829 var dataItem = this.hotMenu.getSourceDataAtRow(row); 39830 var subMenu = new Menu(this.hot, { 39831 parent: this, 39832 name: dataItem.name, 39833 className: this.options.className, 39834 keepInViewport: true 39835 }); 39836 subMenu.setMenuItems(dataItem.submenu.items); 39837 subMenu.open(); 39838 subMenu.setPosition(cell.getBoundingClientRect()); 39839 this.hotSubMenus[dataItem.key] = subMenu; 39840 39841 return subMenu; 39842 } 39843 39844 /** 39845 * Close sub menu at row index. 39846 * 39847 * @param {Number} row Row index. 39848 */ 39849 39850 }, { 39851 key: 'closeSubMenu', 39852 value: function closeSubMenu(row) { 39853 var dataItem = this.hotMenu.getSourceDataAtRow(row); 39854 var menus = this.hotSubMenus[dataItem.key]; 39855 39856 if (menus) { 39857 menus.destroy(); 39858 delete this.hotSubMenus[dataItem.key]; 39859 } 39860 } 39861 39862 /** 39863 * Close all opened sub menus. 39864 */ 39865 39866 }, { 39867 key: 'closeAllSubMenus', 39868 value: function closeAllSubMenus() { 39869 var _this3 = this; 39870 39871 (0, _array.arrayEach)(this.hotMenu.getData(), function (value, row) { 39872 return _this3.closeSubMenu(row); 39873 }); 39874 } 39875 39876 /** 39877 * Checks if all created and opened sub menus are closed. 39878 * 39879 * @returns {Boolean} 39880 */ 39881 39882 }, { 39883 key: 'isAllSubMenusClosed', 39884 value: function isAllSubMenusClosed() { 39885 return Object.keys(this.hotSubMenus).length === 0; 39886 } 39887 39888 /** 39889 * Destroy instance. 39890 */ 39891 39892 }, { 39893 key: 'destroy', 39894 value: function destroy() { 39895 this.clearLocalHooks(); 39896 this.close(); 39897 this.parentMenu = null; 39898 this.eventManager.destroy(); 39899 } 39900 39901 /** 39902 * Checks if menu was opened. 39903 * 39904 * @returns {Boolean} Returns `true` if menu was opened. 39905 */ 39906 39907 }, { 39908 key: 'isOpened', 39909 value: function isOpened() { 39910 return this.hotMenu !== null; 39911 } 39912 39913 /** 39914 * Execute menu command. 39915 * 39916 * @param {Event} [event] 39917 */ 39918 39919 }, { 39920 key: 'executeCommand', 39921 value: function executeCommand(event) { 39922 if (!this.isOpened() || !this.hotMenu.getSelected()) { 39923 return; 39924 } 39925 var selectedItem = this.hotMenu.getSourceDataAtRow(this.hotMenu.getSelected()[0]); 39926 39927 this.runLocalHooks('select', selectedItem, event); 39928 39929 if (selectedItem.isCommand === false || selectedItem.name === _predefinedItems.SEPARATOR) { 39930 return; 39931 } 39932 var selRange = this.hot.getSelectedRange(); 39933 var normalizedSelection = selRange ? (0, _utils.normalizeSelection)(selRange) : {}; 39934 var autoClose = true; 39935 39936 // Don't close context menu if item is disabled or it has submenu 39937 if (selectedItem.disabled === true || typeof selectedItem.disabled === 'function' && selectedItem.disabled.call(this.hot) === true || selectedItem.submenu) { 39938 autoClose = false; 39939 } 39940 39941 this.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event); 39942 39943 if (this.isSubMenu()) { 39944 this.parentMenu.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event); 39945 } 39946 39947 if (autoClose) { 39948 this.close(true); 39949 } 39950 } 39951 39952 /** 39953 * Set menu position based on dom event or based on literal object. 39954 * 39955 * @param {Event|Object} coords Event or literal Object with coordinates. 39956 */ 39957 39958 }, { 39959 key: 'setPosition', 39960 value: function setPosition(coords) { 39961 var cursor = new _cursor2.default(coords); 39962 39963 if (this.options.keepInViewport) { 39964 if (cursor.fitsBelow(this.container)) { 39965 this.setPositionBelowCursor(cursor); 39966 } else if (cursor.fitsAbove(this.container)) { 39967 this.setPositionAboveCursor(cursor); 39968 } else { 39969 this.setPositionBelowCursor(cursor); 39970 } 39971 if (cursor.fitsOnRight(this.container)) { 39972 this.setPositionOnRightOfCursor(cursor); 39973 } else { 39974 this.setPositionOnLeftOfCursor(cursor); 39975 } 39976 } else { 39977 this.setPositionBelowCursor(cursor); 39978 this.setPositionOnRightOfCursor(cursor); 39979 } 39980 } 39981 39982 /** 39983 * Set menu position above cursor object. 39984 * 39985 * @param {Cursor} cursor `Cursor` object. 39986 */ 39987 39988 }, { 39989 key: 'setPositionAboveCursor', 39990 value: function setPositionAboveCursor(cursor) { 39991 var top = this.offset.above + cursor.top - this.container.offsetHeight; 39992 39993 if (this.isSubMenu()) { 39994 top = cursor.top + cursor.cellHeight - this.container.offsetHeight + 3; 39995 } 39996 this.container.style.top = top + 'px'; 39997 } 39998 39999 /** 40000 * Set menu position below cursor object. 40001 * 40002 * @param {Cursor} cursor `Cursor` object. 40003 */ 40004 40005 }, { 40006 key: 'setPositionBelowCursor', 40007 value: function setPositionBelowCursor(cursor) { 40008 var top = this.offset.below + cursor.top; 40009 40010 if (this.isSubMenu()) { 40011 top = cursor.top - 1; 40012 } 40013 this.container.style.top = top + 'px'; 40014 } 40015 40016 /** 40017 * Set menu position on the right of cursor object. 40018 * 40019 * @param {Cursor} cursor `Cursor` object. 40020 */ 40021 40022 }, { 40023 key: 'setPositionOnRightOfCursor', 40024 value: function setPositionOnRightOfCursor(cursor) { 40025 var left = void 0; 40026 40027 if (this.isSubMenu()) { 40028 left = 1 + cursor.left + cursor.cellWidth; 40029 } else { 40030 left = this.offset.right + 1 + cursor.left; 40031 } 40032 40033 this.container.style.left = left + 'px'; 40034 } 40035 40036 /** 40037 * Set menu position on the left of cursor object. 40038 * 40039 * @param {Cursor} cursor `Cursor` object. 40040 */ 40041 40042 }, { 40043 key: 'setPositionOnLeftOfCursor', 40044 value: function setPositionOnLeftOfCursor(cursor) { 40045 var left = this.offset.left + cursor.left - this.container.offsetWidth + (0, _element.getScrollbarWidth)() + 4; 40046 40047 this.container.style.left = left + 'px'; 40048 } 40049 40050 /** 40051 * Select first cell in opened menu. 40052 */ 40053 40054 }, { 40055 key: 'selectFirstCell', 40056 value: function selectFirstCell() { 40057 var cell = this.hotMenu.getCell(0, 0); 40058 40059 if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) { 40060 this.selectNextCell(0, 0); 40061 } else { 40062 this.hotMenu.selectCell(0, 0); 40063 } 40064 } 40065 40066 /** 40067 * Select last cell in opened menu. 40068 */ 40069 40070 }, { 40071 key: 'selectLastCell', 40072 value: function selectLastCell() { 40073 var lastRow = this.hotMenu.countRows() - 1; 40074 var cell = this.hotMenu.getCell(lastRow, 0); 40075 40076 if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) { 40077 this.selectPrevCell(lastRow, 0); 40078 } else { 40079 this.hotMenu.selectCell(lastRow, 0); 40080 } 40081 } 40082 40083 /** 40084 * Select next cell in opened menu. 40085 * 40086 * @param {Number} row Row index. 40087 * @param {Number} col Column index. 40088 */ 40089 40090 }, { 40091 key: 'selectNextCell', 40092 value: function selectNextCell(row, col) { 40093 var nextRow = row + 1; 40094 var cell = nextRow < this.hotMenu.countRows() ? this.hotMenu.getCell(nextRow, col) : null; 40095 40096 if (!cell) { 40097 return; 40098 } 40099 if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) { 40100 this.selectNextCell(nextRow, col); 40101 } else { 40102 this.hotMenu.selectCell(nextRow, col); 40103 } 40104 } 40105 40106 /** 40107 * Select previous cell in opened menu. 40108 * 40109 * @param {Number} row Row index. 40110 * @param {Number} col Column index. 40111 */ 40112 40113 }, { 40114 key: 'selectPrevCell', 40115 value: function selectPrevCell(row, col) { 40116 var prevRow = row - 1; 40117 var cell = prevRow >= 0 ? this.hotMenu.getCell(prevRow, col) : null; 40118 40119 if (!cell) { 40120 return; 40121 } 40122 if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) { 40123 this.selectPrevCell(prevRow, col); 40124 } else { 40125 this.hotMenu.selectCell(prevRow, col); 40126 } 40127 } 40128 40129 /** 40130 * Menu item renderer. 40131 * 40132 * @private 40133 */ 40134 40135 }, { 40136 key: 'menuItemRenderer', 40137 value: function menuItemRenderer(hot, TD, row, col, prop, value) { 40138 var _this4 = this; 40139 40140 var item = hot.getSourceDataAtRow(row); 40141 var wrapper = document.createElement('div'); 40142 40143 var isSubMenu = function isSubMenu(item) { 40144 return (0, _object.hasOwnProperty)(item, 'submenu'); 40145 }; 40146 var itemIsSeparator = function itemIsSeparator(item) { 40147 return new RegExp(_predefinedItems.SEPARATOR, 'i').test(item.name); 40148 }; 40149 var itemIsDisabled = function itemIsDisabled(item) { 40150 return item.disabled === true || typeof item.disabled == 'function' && item.disabled.call(_this4.hot) === true; 40151 }; 40152 var itemIsSelectionDisabled = function itemIsSelectionDisabled(item) { 40153 return item.disableSelection; 40154 }; 40155 40156 if (typeof value === 'function') { 40157 value = value.call(this.hot); 40158 } 40159 (0, _element.empty)(TD); 40160 (0, _element.addClass)(wrapper, 'htItemWrapper'); 40161 (0, _element.addClass)(wrapper, item.key); // COSMOCODE 40162 TD.appendChild(wrapper); 40163 40164 if (itemIsSeparator(item)) { 40165 (0, _element.addClass)(TD, 'htSeparator'); 40166 } else if (typeof item.renderer === 'function') { 40167 (0, _element.addClass)(TD, 'htCustomMenuRenderer'); 40168 TD.appendChild(item.renderer(hot, wrapper, row, col, prop, value)); 40169 } else { 40170 (0, _element.fastInnerHTML)(wrapper, value); 40171 } 40172 if (itemIsDisabled(item)) { 40173 (0, _element.addClass)(TD, 'htDisabled'); 40174 this.eventManager.addEventListener(TD, 'mouseenter', function () { 40175 return hot.deselectCell(); 40176 }); 40177 } else if (itemIsSelectionDisabled(item)) { 40178 (0, _element.addClass)(TD, 'htSelectionDisabled'); 40179 this.eventManager.addEventListener(TD, 'mouseenter', function () { 40180 return hot.deselectCell(); 40181 }); 40182 } else if (isSubMenu(item)) { 40183 (0, _element.addClass)(TD, 'htSubmenu'); 40184 40185 if (itemIsSelectionDisabled(item)) { 40186 this.eventManager.addEventListener(TD, 'mouseenter', function () { 40187 return hot.deselectCell(); 40188 }); 40189 } else { 40190 this.eventManager.addEventListener(TD, 'mouseenter', function () { 40191 return hot.selectCell(row, col, void 0, void 0, false, false); 40192 }); 40193 } 40194 } else { 40195 (0, _element.removeClass)(TD, 'htSubmenu'); 40196 (0, _element.removeClass)(TD, 'htDisabled'); 40197 40198 if (itemIsSelectionDisabled(item)) { 40199 this.eventManager.addEventListener(TD, 'mouseenter', function () { 40200 return hot.deselectCell(); 40201 }); 40202 } else { 40203 this.eventManager.addEventListener(TD, 'mouseenter', function () { 40204 return hot.selectCell(row, col, void 0, void 0, false, false); 40205 }); 40206 } 40207 } 40208 } 40209 40210 /** 40211 * Create container/wrapper for handsontable. 40212 * 40213 * @private 40214 * @param {String} [name] Class name. 40215 * @returns {HTMLElement} 40216 */ 40217 40218 }, { 40219 key: 'createContainer', 40220 value: function createContainer() { 40221 var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 40222 40223 if (name) { 40224 name = name.replace(/[^A-z0-9]/g, '_'); 40225 name = this.options.className + 'Sub_' + name; 40226 } 40227 var container = void 0; 40228 40229 if (name) { 40230 container = document.querySelector('.' + this.options.className + '.' + name); 40231 } else { 40232 container = document.querySelector('.' + this.options.className); 40233 } 40234 if (!container) { 40235 container = document.createElement('div'); 40236 (0, _element.addClass)(container, 'htMenu ' + this.options.className); 40237 40238 if (name) { 40239 (0, _element.addClass)(container, name); 40240 } 40241 document.getElementsByTagName('body')[0].appendChild(container); 40242 } 40243 40244 return container; 40245 } 40246 40247 /** 40248 * @private 40249 */ 40250 40251 }, { 40252 key: 'blockMainTableCallbacks', 40253 value: function blockMainTableCallbacks() { 40254 this._afterScrollCallback = function () {}; 40255 this.hot.addHook('afterScrollVertically', this._afterScrollCallback); 40256 this.hot.addHook('afterScrollHorizontally', this._afterScrollCallback); 40257 } 40258 40259 /** 40260 * @private 40261 */ 40262 40263 }, { 40264 key: 'releaseMainTableCallbacks', 40265 value: function releaseMainTableCallbacks() { 40266 if (this._afterScrollCallback) { 40267 this.hot.removeHook('afterScrollVertically', this._afterScrollCallback); 40268 this.hot.removeHook('afterScrollHorizontally', this._afterScrollCallback); 40269 this._afterScrollCallback = null; 40270 } 40271 } 40272 40273 /** 40274 * On before key down listener. 40275 * 40276 * @private 40277 * @param {Event} event 40278 */ 40279 40280 }, { 40281 key: 'onBeforeKeyDown', 40282 value: function onBeforeKeyDown(event) { 40283 var selection = this.hotMenu.getSelected(); 40284 var stopEvent = false; 40285 this.keyEvent = true; 40286 40287 switch (event.keyCode) { 40288 case _unicode.KEY_CODES.ESCAPE: 40289 this.close(); 40290 stopEvent = true; 40291 break; 40292 40293 case _unicode.KEY_CODES.ENTER: 40294 if (selection) { 40295 if (this.hotMenu.getSourceDataAtRow(selection[0]).submenu) { 40296 stopEvent = true; 40297 } else { 40298 this.executeCommand(event); 40299 this.close(true); 40300 } 40301 } 40302 break; 40303 40304 case _unicode.KEY_CODES.ARROW_DOWN: 40305 if (selection) { 40306 this.selectNextCell(selection[0], selection[1]); 40307 } else { 40308 this.selectFirstCell(); 40309 } 40310 stopEvent = true; 40311 break; 40312 40313 case _unicode.KEY_CODES.ARROW_UP: 40314 if (selection) { 40315 this.selectPrevCell(selection[0], selection[1]); 40316 } else { 40317 this.selectLastCell(); 40318 } 40319 stopEvent = true; 40320 break; 40321 40322 case _unicode.KEY_CODES.ARROW_RIGHT: 40323 if (selection) { 40324 var menu = this.openSubMenu(selection[0]); 40325 40326 if (menu) { 40327 menu.selectFirstCell(); 40328 } 40329 } 40330 stopEvent = true; 40331 40332 break; 40333 40334 case _unicode.KEY_CODES.ARROW_LEFT: 40335 if (selection && this.isSubMenu()) { 40336 this.close(); 40337 40338 if (this.parentMenu) { 40339 this.parentMenu.hotMenu.listen(); 40340 } 40341 stopEvent = true; 40342 } 40343 break; 40344 default: 40345 break; 40346 } 40347 if (stopEvent) { 40348 event.preventDefault(); 40349 (0, _event.stopImmediatePropagation)(event); 40350 } 40351 40352 this.keyEvent = false; 40353 } 40354 40355 /** 40356 * On after init listener. 40357 * 40358 * @private 40359 */ 40360 40361 }, { 40362 key: 'onAfterInit', 40363 value: function onAfterInit() { 40364 var data = this.hotMenu.getSettings().data; 40365 var hiderStyle = this.hotMenu.view.wt.wtTable.hider.style; 40366 var holderStyle = this.hotMenu.view.wt.wtTable.holder.style; 40367 var currentHiderWidth = parseInt(hiderStyle.width, 10); 40368 40369 var realHeight = (0, _array.arrayReduce)(data, function (accumulator, value) { 40370 return accumulator + (value.name === _predefinedItems.SEPARATOR ? 1 : 26); 40371 }, 0); 40372 40373 holderStyle.width = currentHiderWidth + 22 + 'px'; 40374 holderStyle.height = realHeight + 4 + 'px'; 40375 hiderStyle.height = holderStyle.height; 40376 } 40377 40378 /** 40379 * On after selection listener. 40380 * 40381 * @param {Number} r Selection start row index. 40382 * @param {Number} c Selection start column index. 40383 * @param {Number} r2 Selection end row index. 40384 * @param {Number} c2 Selection end column index. 40385 * @param {Object} preventScrolling Object with `value` property where its value change will be observed. 40386 */ 40387 40388 }, { 40389 key: 'onAfterSelection', 40390 value: function onAfterSelection(r, c, r2, c2, preventScrolling) { 40391 if (this.keyEvent === false) { 40392 preventScrolling.value = true; 40393 } 40394 } 40395 40396 /** 40397 * Document mouse down listener. 40398 * 40399 * @private 40400 * @param {Event} event 40401 */ 40402 40403 }, { 40404 key: 'onDocumentMouseDown', 40405 value: function onDocumentMouseDown(event) { 40406 if (!this.isOpened()) { 40407 return; 40408 } 40409 if (this.container && (0, _element.isChildOf)(event.target, this.container)) { 40410 this.executeCommand(event); 40411 } 40412 // Close menu when clicked element is not belongs to menu itself 40413 if (this.options.standalone && this.hotMenu && !(0, _element.isChildOf)(event.target, this.hotMenu.rootElement)) { 40414 this.close(true); 40415 40416 // Automatically close menu when clicked element is not belongs to menu or submenu (not necessarily to itself) 40417 } else if ((this.isAllSubMenusClosed() || this.isSubMenu()) && !(0, _element.isChildOf)(event.target, '.htMenu') && (0, _element.isChildOf)(event.target, document)) { 40418 this.close(true); 40419 } 40420 } 40421 }]); 40422 40423 return Menu; 40424}(); 40425 40426(0, _object.mixin)(Menu, _localHooks2.default); 40427 40428exports.default = Menu; 40429 40430/***/ }), 40431/* 344 */ 40432/***/ (function(module, exports, __webpack_require__) { 40433 40434"use strict"; 40435 40436 40437exports.__esModule = true; 40438exports.KEY = undefined; 40439exports.default = alignmentItem; 40440 40441var _utils = __webpack_require__(19); 40442 40443var _separator = __webpack_require__(73); 40444 40445var KEY = exports.KEY = 'alignment'; 40446 40447function alignmentItem() { 40448 return { 40449 key: KEY, 40450 name: 'Alignment', 40451 disabled: function disabled() { 40452 return !(this.getSelectedRange() && !this.selection.selectedHeader.corner); 40453 }, 40454 40455 submenu: { 40456 items: [{ 40457 key: KEY + ':left', 40458 name: function name() { 40459 var _this = this; 40460 40461 var label = 'Left'; 40462 var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40463 var className = _this.getCellMeta(row, col).className; 40464 40465 if (className && className.indexOf('htLeft') !== -1) { 40466 return true; 40467 } 40468 }); 40469 40470 if (hasClass) { 40471 label = (0, _utils.markLabelAsSelected)(label); 40472 } 40473 40474 return label; 40475 }, 40476 callback: function callback() { 40477 var _this2 = this; 40478 40479 var range = this.getSelectedRange(); 40480 var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) { 40481 return _this2.getCellMeta(row, col).className; 40482 }); 40483 var type = 'horizontal'; 40484 var alignment = 'htLeft'; 40485 40486 this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment); 40487 (0, _utils.align)(range, type, alignment, function (row, col) { 40488 return _this2.getCellMeta(row, col); 40489 }, function (row, col, key, value) { 40490 return _this2.setCellMeta(row, col, key, value); 40491 }); 40492 this.render(); 40493 }, 40494 40495 disabled: false 40496 }, { 40497 key: KEY + ':center', 40498 name: function name() { 40499 var _this3 = this; 40500 40501 var label = 'Center'; 40502 var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40503 var className = _this3.getCellMeta(row, col).className; 40504 40505 if (className && className.indexOf('htCenter') !== -1) { 40506 return true; 40507 } 40508 }); 40509 40510 if (hasClass) { 40511 label = (0, _utils.markLabelAsSelected)(label); 40512 } 40513 40514 return label; 40515 }, 40516 callback: function callback() { 40517 var _this4 = this; 40518 40519 var range = this.getSelectedRange(); 40520 var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) { 40521 return _this4.getCellMeta(row, col).className; 40522 }); 40523 var type = 'horizontal'; 40524 var alignment = 'htCenter'; 40525 40526 this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment); 40527 (0, _utils.align)(range, type, alignment, function (row, col) { 40528 return _this4.getCellMeta(row, col); 40529 }, function (row, col, key, value) { 40530 return _this4.setCellMeta(row, col, key, value); 40531 }); 40532 this.render(); 40533 }, 40534 40535 disabled: false 40536 }, { 40537 key: KEY + ':right', 40538 name: function name() { 40539 var _this5 = this; 40540 40541 var label = 'Right'; 40542 var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40543 var className = _this5.getCellMeta(row, col).className; 40544 40545 if (className && className.indexOf('htRight') !== -1) { 40546 return true; 40547 } 40548 }); 40549 40550 if (hasClass) { 40551 label = (0, _utils.markLabelAsSelected)(label); 40552 } 40553 40554 return label; 40555 }, 40556 callback: function callback() { 40557 var _this6 = this; 40558 40559 var range = this.getSelectedRange(); 40560 var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) { 40561 return _this6.getCellMeta(row, col).className; 40562 }); 40563 var type = 'horizontal'; 40564 var alignment = 'htRight'; 40565 40566 this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment); 40567 (0, _utils.align)(range, type, alignment, function (row, col) { 40568 return _this6.getCellMeta(row, col); 40569 }, function (row, col, key, value) { 40570 return _this6.setCellMeta(row, col, key, value); 40571 }); 40572 this.render(); 40573 }, 40574 40575 disabled: false 40576 }, { 40577 key: KEY + ':justify', 40578 name: function name() { 40579 var _this7 = this; 40580 40581 var label = 'Justify'; 40582 var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40583 var className = _this7.getCellMeta(row, col).className; 40584 40585 if (className && className.indexOf('htJustify') !== -1) { 40586 return true; 40587 } 40588 }); 40589 40590 if (hasClass) { 40591 label = (0, _utils.markLabelAsSelected)(label); 40592 } 40593 40594 return label; 40595 }, 40596 callback: function callback() { 40597 var _this8 = this; 40598 40599 var range = this.getSelectedRange(); 40600 var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) { 40601 return _this8.getCellMeta(row, col).className; 40602 }); 40603 var type = 'horizontal'; 40604 var alignment = 'htJustify'; 40605 40606 this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment); 40607 (0, _utils.align)(range, type, alignment, function (row, col) { 40608 return _this8.getCellMeta(row, col); 40609 }, function (row, col, key, value) { 40610 return _this8.setCellMeta(row, col, key, value); 40611 }); 40612 this.render(); 40613 }, 40614 40615 disabled: false 40616 }, { 40617 name: _separator.KEY 40618 }, { 40619 key: KEY + ':top', 40620 name: function name() { 40621 var _this9 = this; 40622 40623 var label = 'Top'; 40624 var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40625 var className = _this9.getCellMeta(row, col).className; 40626 40627 if (className && className.indexOf('htTop') !== -1) { 40628 return true; 40629 } 40630 }); 40631 40632 if (hasClass) { 40633 label = (0, _utils.markLabelAsSelected)(label); 40634 } 40635 return label; 40636 }, 40637 callback: function callback() { 40638 var _this10 = this; 40639 40640 var range = this.getSelectedRange(); 40641 var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) { 40642 return _this10.getCellMeta(row, col).className; 40643 }); 40644 var type = 'vertical'; 40645 var alignment = 'htTop'; 40646 40647 this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment); 40648 (0, _utils.align)(range, type, alignment, function (row, col) { 40649 return _this10.getCellMeta(row, col); 40650 }, function (row, col, key, value) { 40651 return _this10.setCellMeta(row, col, key, value); 40652 }); 40653 this.render(); 40654 }, 40655 40656 disabled: false 40657 }, { 40658 key: KEY + ':middle', 40659 name: function name() { 40660 var _this11 = this; 40661 40662 var label = 'Middle'; 40663 var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40664 var className = _this11.getCellMeta(row, col).className; 40665 40666 if (className && className.indexOf('htMiddle') !== -1) { 40667 return true; 40668 } 40669 }); 40670 40671 if (hasClass) { 40672 label = (0, _utils.markLabelAsSelected)(label); 40673 } 40674 40675 return label; 40676 }, 40677 callback: function callback() { 40678 var _this12 = this; 40679 40680 var range = this.getSelectedRange(); 40681 var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) { 40682 return _this12.getCellMeta(row, col).className; 40683 }); 40684 var type = 'vertical'; 40685 var alignment = 'htMiddle'; 40686 40687 this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment); 40688 (0, _utils.align)(range, type, alignment, function (row, col) { 40689 return _this12.getCellMeta(row, col); 40690 }, function (row, col, key, value) { 40691 return _this12.setCellMeta(row, col, key, value); 40692 }); 40693 this.render(); 40694 }, 40695 40696 disabled: false 40697 }, { 40698 key: KEY + ':bottom', 40699 name: function name() { 40700 var _this13 = this; 40701 40702 var label = 'Bottom'; 40703 var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40704 var className = _this13.getCellMeta(row, col).className; 40705 40706 if (className && className.indexOf('htBottom') !== -1) { 40707 return true; 40708 } 40709 }); 40710 40711 if (hasClass) { 40712 label = (0, _utils.markLabelAsSelected)(label); 40713 } 40714 40715 return label; 40716 }, 40717 callback: function callback() { 40718 var _this14 = this; 40719 40720 var range = this.getSelectedRange(); 40721 var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) { 40722 return _this14.getCellMeta(row, col).className; 40723 }); 40724 var type = 'vertical'; 40725 var alignment = 'htBottom'; 40726 40727 this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment); 40728 (0, _utils.align)(range, type, alignment, function (row, col) { 40729 return _this14.getCellMeta(row, col); 40730 }, function (row, col, key, value) { 40731 return _this14.setCellMeta(row, col, key, value); 40732 }); 40733 this.render(); 40734 }, 40735 40736 disabled: false 40737 }] 40738 } 40739 }; 40740} 40741 40742/***/ }), 40743/* 345 */ 40744/***/ (function(module, exports, __webpack_require__) { 40745 40746"use strict"; 40747 40748 40749exports.__esModule = true; 40750exports.KEY = undefined; 40751exports.default = clearColumnItem; 40752 40753var _utils = __webpack_require__(19); 40754 40755var KEY = exports.KEY = 'clear_column'; 40756 40757function clearColumnItem() { 40758 return { 40759 key: KEY, 40760 name: 'Clear column', 40761 40762 callback: function callback(key, selection) { 40763 var column = selection.start.col; 40764 40765 if (this.countRows()) { 40766 this.populateFromArray(0, column, [[null]], Math.max(selection.start.row, selection.end.row), column, 'ContextMenu.clearColumn'); 40767 } 40768 }, 40769 disabled: function disabled() { 40770 var selected = (0, _utils.getValidSelection)(this); 40771 40772 if (!selected) { 40773 return true; 40774 } 40775 var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1]; 40776 var rowSelected = entireRowSelection.join(',') == selected.join(','); 40777 40778 return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected; 40779 } 40780 }; 40781} 40782 40783/***/ }), 40784/* 346 */ 40785/***/ (function(module, exports, __webpack_require__) { 40786 40787"use strict"; 40788 40789 40790exports.__esModule = true; 40791exports.KEY = undefined; 40792exports.default = columnLeftItem; 40793 40794var _utils = __webpack_require__(19); 40795 40796var KEY = exports.KEY = 'col_left'; 40797 40798function columnLeftItem() { 40799 return { 40800 key: KEY, 40801 name: 'Insert column on the left', 40802 callback: function callback(key, selection) { 40803 this.alter('insert_col', selection.start.col, 1, 'ContextMenu.columnLeft'); 40804 }, 40805 disabled: function disabled() { 40806 var selected = (0, _utils.getValidSelection)(this); 40807 40808 if (!selected) { 40809 return true; 40810 } 40811 if (!this.isColumnModificationAllowed()) { 40812 return true; 40813 } 40814 var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1]; 40815 var rowSelected = entireRowSelection.join(',') == selected.join(','); 40816 var onlyOneColumn = this.countCols() === 1; 40817 40818 return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected; 40819 }, 40820 hidden: function hidden() { 40821 return !this.getSettings().allowInsertColumn; 40822 } 40823 }; 40824} 40825 40826/***/ }), 40827/* 347 */ 40828/***/ (function(module, exports, __webpack_require__) { 40829 40830"use strict"; 40831 40832 40833exports.__esModule = true; 40834exports.KEY = undefined; 40835exports.default = columnRightItem; 40836 40837var _utils = __webpack_require__(19); 40838 40839var KEY = exports.KEY = 'col_right'; 40840 40841function columnRightItem() { 40842 return { 40843 key: KEY, 40844 name: 'Insert column on the right', 40845 40846 callback: function callback(key, selection) { 40847 this.alter('insert_col', selection.end.col + 1, 1, 'ContextMenu.columnRight'); 40848 }, 40849 disabled: function disabled() { 40850 var selected = (0, _utils.getValidSelection)(this); 40851 40852 if (!selected) { 40853 return true; 40854 } 40855 if (!this.isColumnModificationAllowed()) { 40856 return true; 40857 } 40858 var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1]; 40859 var rowSelected = entireRowSelection.join(',') == selected.join(','); 40860 var onlyOneColumn = this.countCols() === 1; 40861 40862 return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected; 40863 }, 40864 hidden: function hidden() { 40865 return !this.getSettings().allowInsertColumn; 40866 } 40867 }; 40868} 40869 40870/***/ }), 40871/* 348 */ 40872/***/ (function(module, exports, __webpack_require__) { 40873 40874"use strict"; 40875 40876 40877exports.__esModule = true; 40878exports.KEY = undefined; 40879exports.default = readOnlyItem; 40880 40881var _utils = __webpack_require__(19); 40882 40883var KEY = exports.KEY = 'make_read_only'; 40884 40885function readOnlyItem() { 40886 return { 40887 key: KEY, 40888 name: function name() { 40889 var _this = this; 40890 40891 var label = 'Read only'; 40892 var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) { 40893 return _this.getCellMeta(row, col).readOnly; 40894 }); 40895 40896 if (atLeastOneReadOnly) { 40897 label = (0, _utils.markLabelAsSelected)(label); 40898 } 40899 40900 return label; 40901 }, 40902 callback: function callback() { 40903 var _this2 = this; 40904 40905 var range = this.getSelectedRange(); 40906 var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(range, function (row, col) { 40907 return _this2.getCellMeta(row, col).readOnly; 40908 }); 40909 40910 range.forAll(function (row, col) { 40911 _this2.setCellMeta(row, col, 'readOnly', !atLeastOneReadOnly); 40912 }); 40913 this.render(); 40914 }, 40915 disabled: function disabled() { 40916 return !(this.getSelectedRange() && !this.selection.selectedHeader.corner); 40917 } 40918 }; 40919} 40920 40921/***/ }), 40922/* 349 */ 40923/***/ (function(module, exports, __webpack_require__) { 40924 40925"use strict"; 40926 40927 40928exports.__esModule = true; 40929exports.default = redoItem; 40930var KEY = exports.KEY = 'redo'; 40931 40932function redoItem() { 40933 return { 40934 key: KEY, 40935 name: 'Redo', 40936 40937 callback: function callback() { 40938 this.redo(); 40939 }, 40940 disabled: function disabled() { 40941 return this.undoRedo && !this.undoRedo.isRedoAvailable(); 40942 } 40943 }; 40944} 40945 40946/***/ }), 40947/* 350 */ 40948/***/ (function(module, exports, __webpack_require__) { 40949 40950"use strict"; 40951 40952 40953exports.__esModule = true; 40954exports.KEY = undefined; 40955exports.default = removeColumnItem; 40956 40957var _utils = __webpack_require__(19); 40958 40959var KEY = exports.KEY = 'remove_col'; 40960 40961function removeColumnItem() { 40962 return { 40963 key: KEY, 40964 name: 'Remove column', 40965 40966 callback: function callback(key, selection) { 40967 var amount = selection.end.col - selection.start.col + 1; 40968 40969 this.alter('remove_col', selection.start.col, amount, 'ContextMenu.removeColumn'); 40970 }, 40971 disabled: function disabled() { 40972 var selected = (0, _utils.getValidSelection)(this); 40973 var totalColumns = this.countCols(); 40974 40975 return !selected || this.selection.selectedHeader.rows || this.selection.selectedHeader.corner || !this.isColumnModificationAllowed() || !totalColumns; 40976 }, 40977 hidden: function hidden() { 40978 return !this.getSettings().allowRemoveColumn; 40979 } 40980 }; 40981} 40982 40983/***/ }), 40984/* 351 */ 40985/***/ (function(module, exports, __webpack_require__) { 40986 40987"use strict"; 40988 40989 40990exports.__esModule = true; 40991exports.KEY = undefined; 40992exports.default = removeRowItem; 40993 40994var _utils = __webpack_require__(19); 40995 40996var KEY = exports.KEY = 'remove_row'; 40997 40998function removeRowItem() { 40999 return { 41000 key: KEY, 41001 name: 'Remove row', 41002 41003 callback: function callback(key, selection) { 41004 var amount = selection.end.row - selection.start.row + 1; 41005 41006 this.alter('remove_row', selection.start.row, amount, 'ContextMenu.removeRow'); 41007 }, 41008 disabled: function disabled() { 41009 var selected = (0, _utils.getValidSelection)(this); 41010 var totalRows = this.countRows(); 41011 41012 return !selected || this.selection.selectedHeader.cols || this.selection.selectedHeader.corner || !totalRows; 41013 }, 41014 hidden: function hidden() { 41015 return !this.getSettings().allowRemoveRow; 41016 } 41017 }; 41018} 41019 41020/***/ }), 41021/* 352 */ 41022/***/ (function(module, exports, __webpack_require__) { 41023 41024"use strict"; 41025 41026 41027exports.__esModule = true; 41028exports.KEY = undefined; 41029exports.default = rowAboveItem; 41030 41031var _utils = __webpack_require__(19); 41032 41033var KEY = exports.KEY = 'row_above'; 41034 41035function rowAboveItem() { 41036 return { 41037 key: KEY, 41038 name: 'Insert row above', 41039 41040 callback: function callback(key, selection) { 41041 this.alter('insert_row', selection.start.row, 1, 'ContextMenu.rowAbove'); 41042 }, 41043 disabled: function disabled() { 41044 var selected = (0, _utils.getValidSelection)(this); 41045 41046 return !selected || this.selection.selectedHeader.cols || this.countRows() >= this.getSettings().maxRows; 41047 }, 41048 hidden: function hidden() { 41049 return !this.getSettings().allowInsertRow; 41050 } 41051 }; 41052} 41053 41054/***/ }), 41055/* 353 */ 41056/***/ (function(module, exports, __webpack_require__) { 41057 41058"use strict"; 41059 41060 41061exports.__esModule = true; 41062exports.KEY = undefined; 41063exports.default = rowBelowItem; 41064 41065var _utils = __webpack_require__(19); 41066 41067var KEY = exports.KEY = 'row_below'; 41068 41069function rowBelowItem() { 41070 return { 41071 key: KEY, 41072 name: 'Insert row below', 41073 41074 callback: function callback(key, selection) { 41075 this.alter('insert_row', selection.end.row + 1, 1, 'ContextMenu.rowBelow'); 41076 }, 41077 disabled: function disabled() { 41078 var selected = (0, _utils.getValidSelection)(this); 41079 41080 return !selected || this.selection.selectedHeader.cols || this.countRows() >= this.getSettings().maxRows; 41081 }, 41082 hidden: function hidden() { 41083 return !this.getSettings().allowInsertRow; 41084 } 41085 }; 41086} 41087 41088/***/ }), 41089/* 354 */ 41090/***/ (function(module, exports, __webpack_require__) { 41091 41092"use strict"; 41093 41094 41095exports.__esModule = true; 41096exports.default = undoItem; 41097var KEY = exports.KEY = 'undo'; 41098 41099function undoItem() { 41100 return { 41101 key: KEY, 41102 name: 'Undo', 41103 41104 callback: function callback() { 41105 this.undo(); 41106 }, 41107 disabled: function disabled() { 41108 return this.undoRedo && !this.undoRedo.isUndoAvailable(); 41109 } 41110 }; 41111} 41112 41113/***/ }), 41114/* 355 */ 41115/***/ (function(module, exports, __webpack_require__) { 41116 41117"use strict"; 41118 41119 41120exports.__esModule = true; 41121exports.default = copyItem; 41122function copyItem(copyPastePlugin) { 41123 return { 41124 key: 'copy', 41125 name: 'Copy', 41126 callback: function callback() { 41127 copyPastePlugin.setCopyableText(); 41128 copyPastePlugin.copy(true); 41129 }, 41130 disabled: function disabled() { 41131 return !copyPastePlugin.hot.getSelected(); 41132 }, 41133 41134 hidden: false 41135 }; 41136} 41137 41138/***/ }), 41139/* 356 */ 41140/***/ (function(module, exports, __webpack_require__) { 41141 41142"use strict"; 41143 41144 41145exports.__esModule = true; 41146exports.default = cutItem; 41147function cutItem(copyPastePlugin) { 41148 return { 41149 key: 'cut', 41150 name: 'Cut', 41151 callback: function callback() { 41152 copyPastePlugin.setCopyableText(); 41153 copyPastePlugin.cut(true); 41154 }, 41155 disabled: function disabled() { 41156 return !copyPastePlugin.hot.getSelected(); 41157 }, 41158 41159 hidden: false 41160 }; 41161} 41162 41163/***/ }), 41164/* 357 */ 41165/***/ (function(module, exports, __webpack_require__) { 41166 41167"use strict"; 41168 41169 41170exports.__esModule = true; 41171 41172var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 41173 41174var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 41175 41176var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 41177 41178var _base = __webpack_require__(16); 41179 41180var _base2 = _interopRequireDefault(_base); 41181 41182var _pluginHooks = __webpack_require__(11); 41183 41184var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 41185 41186var _SheetClip = __webpack_require__(249); 41187 41188var _SheetClip2 = _interopRequireDefault(_SheetClip); 41189 41190var _src = __webpack_require__(14); 41191 41192var _unicode = __webpack_require__(15); 41193 41194var _element = __webpack_require__(0); 41195 41196var _array = __webpack_require__(2); 41197 41198var _number = __webpack_require__(5); 41199 41200var _event = __webpack_require__(7); 41201 41202var _plugins = __webpack_require__(9); 41203 41204var _textarea = __webpack_require__(358); 41205 41206var _textarea2 = _interopRequireDefault(_textarea); 41207 41208var _copy = __webpack_require__(355); 41209 41210var _copy2 = _interopRequireDefault(_copy); 41211 41212var _cut = __webpack_require__(356); 41213 41214var _cut2 = _interopRequireDefault(_cut); 41215 41216var _eventManager = __webpack_require__(4); 41217 41218var _eventManager2 = _interopRequireDefault(_eventManager); 41219 41220__webpack_require__(300); 41221 41222function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 41223 41224function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 41225 41226function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 41227 41228function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 41229 41230_pluginHooks2.default.getSingleton().register('afterCopyLimit'); 41231_pluginHooks2.default.getSingleton().register('modifyCopyableRange'); 41232_pluginHooks2.default.getSingleton().register('beforeCut'); 41233_pluginHooks2.default.getSingleton().register('afterCut'); 41234_pluginHooks2.default.getSingleton().register('beforePaste'); 41235_pluginHooks2.default.getSingleton().register('afterPaste'); 41236_pluginHooks2.default.getSingleton().register('beforeCopy'); 41237_pluginHooks2.default.getSingleton().register('afterCopy'); 41238 41239var ROWS_LIMIT = 1000; 41240var COLUMNS_LIMIT = 1000; 41241var privatePool = new WeakMap(); 41242 41243/** 41244 * @description 41245 * This plugin enables the copy/paste functionality in the Handsontable. 41246 * 41247 * @example 41248 * ```js 41249 * ... 41250 * copyPaste: true, 41251 * ... 41252 * ``` 41253 * @class CopyPaste 41254 * @plugin CopyPaste 41255 */ 41256 41257var CopyPaste = function (_BasePlugin) { 41258 _inherits(CopyPaste, _BasePlugin); 41259 41260 function CopyPaste(hotInstance) { 41261 _classCallCheck(this, CopyPaste); 41262 41263 /** 41264 * Event manager 41265 * 41266 * @type {EventManager} 41267 */ 41268 var _this = _possibleConstructorReturn(this, (CopyPaste.__proto__ || Object.getPrototypeOf(CopyPaste)).call(this, hotInstance)); 41269 41270 _this.eventManager = new _eventManager2.default(_this); 41271 /** 41272 * Maximum number of columns than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>. 41273 * 41274 * @private 41275 * @type {Number} 41276 * @default 1000 41277 */ 41278 _this.columnsLimit = COLUMNS_LIMIT; 41279 /** 41280 * Ranges of the cells coordinates, which should be used to copy/cut/paste actions. 41281 * 41282 * @private 41283 * @type {Array} 41284 */ 41285 _this.copyableRanges = []; 41286 /** 41287 * Defines paste (<kbd>CTRL</kbd> + <kbd>V</kbd>) behavior. 41288 * * Default value `"overwrite"` will paste clipboard value over current selection. 41289 * * When set to `"shift_down"`, clipboard data will be pasted in place of current selection, while all selected cells are moved down. 41290 * * When set to `"shift_right"`, clipboard data will be pasted in place of current selection, while all selected cells are moved right. 41291 * 41292 * @private 41293 * @type {String} 41294 * @default 'overwrite' 41295 */ 41296 _this.pasteMode = 'overwrite'; 41297 /** 41298 * Maximum number of rows than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>. 41299 * 41300 * @private 41301 * @type {Number} 41302 * @default 1000 41303 */ 41304 _this.rowsLimit = ROWS_LIMIT; 41305 /** 41306 * The `textarea` element which is necessary to process copying, cutting off and pasting. 41307 * 41308 * @private 41309 * @type {HTMLElement} 41310 * @default undefined 41311 */ 41312 _this.textarea = void 0; 41313 41314 privatePool.set(_this, { 41315 isTriggeredByPaste: false 41316 }); 41317 return _this; 41318 } 41319 41320 /** 41321 * Check if plugin is enabled. 41322 * 41323 * @returns {Boolean} 41324 */ 41325 41326 41327 _createClass(CopyPaste, [{ 41328 key: 'isEnabled', 41329 value: function isEnabled() { 41330 return !!this.hot.getSettings().copyPaste; 41331 } 41332 41333 /** 41334 * Enable the plugin. 41335 */ 41336 41337 }, { 41338 key: 'enablePlugin', 41339 value: function enablePlugin() { 41340 var _this2 = this; 41341 41342 if (this.enabled) { 41343 return; 41344 } 41345 41346 var settings = this.hot.getSettings(); 41347 41348 this.textarea = _textarea2.default.getSingleton(); 41349 41350 if (_typeof(settings.copyPaste) === 'object') { 41351 this.pasteMode = settings.copyPaste.pasteMode || this.pasteMode; 41352 this.rowsLimit = settings.copyPaste.rowsLimit || this.rowsLimit; 41353 this.columnsLimit = settings.copyPaste.columnsLimit || this.columnsLimit; 41354 } 41355 41356 this.addHook('afterContextMenuDefaultOptions', function (options) { 41357 return _this2.onAfterContextMenuDefaultOptions(options); 41358 }); 41359 this.addHook('beforeKeyDown', function (event) { 41360 return _this2.onBeforeKeyDown(event); 41361 }); 41362 41363 this.registerEvents(); 41364 41365 _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'enablePlugin', this).call(this); 41366 } 41367 /** 41368 * Updates the plugin to use the latest options you have specified. 41369 */ 41370 41371 }, { 41372 key: 'updatePlugin', 41373 value: function updatePlugin() { 41374 this.disablePlugin(); 41375 this.enablePlugin(); 41376 41377 _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'updatePlugin', this).call(this); 41378 } 41379 41380 /** 41381 * Disable plugin for this Handsontable instance. 41382 */ 41383 41384 }, { 41385 key: 'disablePlugin', 41386 value: function disablePlugin() { 41387 if (this.textarea) { 41388 this.textarea.destroy(); 41389 } 41390 41391 _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'disablePlugin', this).call(this); 41392 } 41393 41394 /** 41395 * Prepares copyable text from the cells selection in the invisible textarea. 41396 * 41397 * @function setCopyable 41398 * @memberof CopyPaste# 41399 */ 41400 41401 }, { 41402 key: 'setCopyableText', 41403 value: function setCopyableText() { 41404 var selRange = this.hot.getSelectedRange(); 41405 41406 if (!selRange) { 41407 return; 41408 } 41409 41410 var topLeft = selRange.getTopLeftCorner(); 41411 var bottomRight = selRange.getBottomRightCorner(); 41412 var startRow = topLeft.row; 41413 var startCol = topLeft.col; 41414 var endRow = bottomRight.row; 41415 var endCol = bottomRight.col; 41416 var finalEndRow = Math.min(endRow, startRow + this.rowsLimit - 1); 41417 var finalEndCol = Math.min(endCol, startCol + this.columnsLimit - 1); 41418 41419 this.copyableRanges.length = 0; 41420 41421 this.copyableRanges.push({ 41422 startRow: startRow, 41423 startCol: startCol, 41424 endRow: finalEndRow, 41425 endCol: finalEndCol 41426 }); 41427 41428 this.copyableRanges = this.hot.runHooks('modifyCopyableRange', this.copyableRanges); 41429 41430 var copyableData = this.getRangedCopyableData(this.copyableRanges); 41431 41432 this.textarea.setValue(copyableData); 41433 41434 if (endRow !== finalEndRow || endCol !== finalEndCol) { 41435 this.hot.runHooks('afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, this.rowsLimit, this.columnsLimit); 41436 } 41437 } 41438 41439 /** 41440 * Create copyable text releated to range objects. 41441 * 41442 * @since 0.19.0 41443 * @param {Array} ranges Array of Objects with properties `startRow`, `endRow`, `startCol` and `endCol`. 41444 * @returns {String} Returns string which will be copied into clipboard. 41445 */ 41446 41447 }, { 41448 key: 'getRangedCopyableData', 41449 value: function getRangedCopyableData(ranges) { 41450 var _this3 = this; 41451 41452 var dataSet = []; 41453 var copyableRows = []; 41454 var copyableColumns = []; 41455 41456 // Count all copyable rows and columns 41457 (0, _array.arrayEach)(ranges, function (range) { 41458 (0, _number.rangeEach)(range.startRow, range.endRow, function (row) { 41459 if (copyableRows.indexOf(row) === -1) { 41460 copyableRows.push(row); 41461 } 41462 }); 41463 (0, _number.rangeEach)(range.startCol, range.endCol, function (column) { 41464 if (copyableColumns.indexOf(column) === -1) { 41465 copyableColumns.push(column); 41466 } 41467 }); 41468 }); 41469 // Concat all rows and columns data defined in ranges into one copyable string 41470 (0, _array.arrayEach)(copyableRows, function (row) { 41471 var rowSet = []; 41472 41473 (0, _array.arrayEach)(copyableColumns, function (column) { 41474 rowSet.push(_this3.hot.getCopyableData(row, column)); 41475 }); 41476 41477 dataSet.push(rowSet); 41478 }); 41479 41480 return _SheetClip2.default.stringify(dataSet); 41481 } 41482 41483 /** 41484 * Create copyable text releated to range objects. 41485 * 41486 * @since 0.31.1 41487 * @param {Array} ranges Array of Objects with properties `startRow`, `startCol`, `endRow` and `endCol`. 41488 * @returns {Array} Returns array of arrays which will be copied into clipboard. 41489 */ 41490 41491 }, { 41492 key: 'getRangedData', 41493 value: function getRangedData(ranges) { 41494 var _this4 = this; 41495 41496 var dataSet = []; 41497 var copyableRows = []; 41498 var copyableColumns = []; 41499 41500 // Count all copyable rows and columns 41501 (0, _array.arrayEach)(ranges, function (range) { 41502 (0, _number.rangeEach)(range.startRow, range.endRow, function (row) { 41503 if (copyableRows.indexOf(row) === -1) { 41504 copyableRows.push(row); 41505 } 41506 }); 41507 (0, _number.rangeEach)(range.startCol, range.endCol, function (column) { 41508 if (copyableColumns.indexOf(column) === -1) { 41509 copyableColumns.push(column); 41510 } 41511 }); 41512 }); 41513 // Concat all rows and columns data defined in ranges into one copyable string 41514 (0, _array.arrayEach)(copyableRows, function (row) { 41515 var rowSet = []; 41516 41517 (0, _array.arrayEach)(copyableColumns, function (column) { 41518 rowSet.push(_this4.hot.getCopyableData(row, column)); 41519 }); 41520 41521 dataSet.push(rowSet); 41522 }); 41523 41524 return dataSet; 41525 } 41526 41527 /** 41528 * Copy action. 41529 * 41530 * @param {Boolean} isTriggeredByClick Flag to determine that copy action was executed by the mouse click. 41531 */ 41532 41533 }, { 41534 key: 'copy', 41535 value: function copy(isTriggeredByClick) { 41536 var rangedData = this.getRangedData(this.copyableRanges); 41537 41538 var allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges); 41539 41540 if (allowCopying) { 41541 this.textarea.setValue(_SheetClip2.default.stringify(rangedData)); 41542 this.textarea.select(); 41543 41544 if (isTriggeredByClick) { 41545 document.execCommand('copy'); 41546 } 41547 41548 this.hot.runHooks('afterCopy', rangedData, this.copyableRanges); 41549 } else { 41550 this.textarea.setValue(''); 41551 } 41552 } 41553 41554 /** 41555 * Cut action. 41556 * 41557 * @param {Boolean} isTriggeredByClick Flag to determine that cut action was executed by the mouse click. 41558 */ 41559 41560 }, { 41561 key: 'cut', 41562 value: function cut(isTriggeredByClick) { 41563 var rangedData = this.getRangedData(this.copyableRanges); 41564 41565 var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges); 41566 41567 if (allowCuttingOut) { 41568 this.textarea.setValue(_SheetClip2.default.stringify(rangedData)); 41569 this.hot.selection.empty(); 41570 this.textarea.select(); 41571 41572 if (isTriggeredByClick) { 41573 document.execCommand('cut'); 41574 } 41575 41576 this.hot.runHooks('afterCut', rangedData, this.copyableRanges); 41577 } else { 41578 this.textarea.setValue(''); 41579 } 41580 } 41581 41582 /** 41583 * Simulated paste action. 41584 * 41585 * @param {String} [value=''] New value, which should be `pasted`. 41586 */ 41587 41588 }, { 41589 key: 'paste', 41590 value: function paste() { 41591 var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 41592 41593 this.textarea.setValue(value); 41594 41595 this.onPaste(); 41596 this.onInput(); 41597 } 41598 41599 /** 41600 * Register event listeners. 41601 * 41602 * @private 41603 */ 41604 41605 }, { 41606 key: 'registerEvents', 41607 value: function registerEvents() { 41608 var _this5 = this; 41609 41610 this.eventManager.addEventListener(this.textarea.element, 'paste', function (event) { 41611 return _this5.onPaste(event); 41612 }); 41613 this.eventManager.addEventListener(this.textarea.element, 'input', function (event) { 41614 return _this5.onInput(event); 41615 }); 41616 } 41617 41618 /** 41619 * Trigger to make possible observe `onInput` in textarea. 41620 * 41621 * @private 41622 */ 41623 41624 }, { 41625 key: 'triggerPaste', 41626 value: function triggerPaste() { 41627 this.textarea.select(); 41628 41629 this.onPaste(); 41630 } 41631 41632 /** 41633 * `paste` event callback on textarea element. 41634 * 41635 * @private 41636 */ 41637 41638 }, { 41639 key: 'onPaste', 41640 value: function onPaste() { 41641 var priv = privatePool.get(this); 41642 41643 priv.isTriggeredByPaste = true; 41644 } 41645 41646 /** 41647 * `input` event callback is called after `paste` event callback. 41648 * 41649 * @private 41650 */ 41651 41652 }, { 41653 key: 'onInput', 41654 value: function onInput() { 41655 var _this6 = this; 41656 41657 var priv = privatePool.get(this); 41658 41659 if (!this.hot.isListening() || !priv.isTriggeredByPaste) { 41660 return; 41661 } 41662 41663 priv.isTriggeredByPaste = false; 41664 41665 var input = void 0, 41666 inputArray = void 0, 41667 selected = void 0, 41668 coordsFrom = void 0, 41669 coordsTo = void 0, 41670 cellRange = void 0, 41671 topLeftCorner = void 0, 41672 bottomRightCorner = void 0, 41673 areaStart = void 0, 41674 areaEnd = void 0; 41675 41676 input = this.textarea.getValue(); 41677 inputArray = _SheetClip2.default.parse(input); 41678 41679 var allowPasting = !!this.hot.runHooks('beforePaste', inputArray, this.copyableRanges); 41680 41681 if (!allowPasting) { 41682 return; 41683 } 41684 41685 selected = this.hot.getSelected(); 41686 coordsFrom = new _src.CellCoords(selected[0], selected[1]); 41687 coordsTo = new _src.CellCoords(selected[2], selected[3]); 41688 cellRange = new _src.CellRange(coordsFrom, coordsFrom, coordsTo); 41689 topLeftCorner = cellRange.getTopLeftCorner(); 41690 bottomRightCorner = cellRange.getBottomRightCorner(); 41691 areaStart = topLeftCorner; 41692 areaEnd = new _src.CellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col)); 41693 41694 var isSelRowAreaCoverInputValue = coordsTo.row - coordsFrom.row >= inputArray.length - 1; 41695 var isSelColAreaCoverInputValue = coordsTo.col - coordsFrom.col >= inputArray[0].length - 1; 41696 41697 this.hot.addHookOnce('afterChange', function (changes, source) { 41698 var changesLength = changes ? changes.length : 0; 41699 41700 if (changesLength) { 41701 var offset = { row: 0, col: 0 }; 41702 var highestColumnIndex = -1; 41703 41704 (0, _array.arrayEach)(changes, function (change, index) { 41705 var nextChange = changesLength > index + 1 ? changes[index + 1] : null; 41706 41707 if (nextChange) { 41708 if (!isSelRowAreaCoverInputValue) { 41709 offset.row += Math.max(nextChange[0] - change[0] - 1, 0); 41710 } 41711 if (!isSelColAreaCoverInputValue && change[1] > highestColumnIndex) { 41712 highestColumnIndex = change[1]; 41713 offset.col += Math.max(nextChange[1] - change[1] - 1, 0); 41714 } 41715 } 41716 }); 41717 _this6.hot.selectCell(areaStart.row, areaStart.col, areaEnd.row + offset.row, areaEnd.col + offset.col); 41718 } 41719 }); 41720 41721 this.hot.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'CopyPaste.paste', this.pasteMode); 41722 this.hot.runHooks('afterPaste', inputArray, this.copyableRanges); 41723 } 41724 41725 /** 41726 * Add copy, cut and paste options to the Context Menu. 41727 * 41728 * @private 41729 * @param {Object} options Contains default added options of the Context Menu. 41730 */ 41731 41732 }, { 41733 key: 'onAfterContextMenuDefaultOptions', 41734 value: function onAfterContextMenuDefaultOptions(options) { 41735 options.items.push({ 41736 name: '---------' 41737 }, (0, _copy2.default)(this), (0, _cut2.default)(this)); 41738 } 41739 41740 /** 41741 * beforeKeyDown callback. 41742 * 41743 * @private 41744 * @param {Event} event 41745 */ 41746 41747 }, { 41748 key: 'onBeforeKeyDown', 41749 value: function onBeforeKeyDown(event) { 41750 var _this7 = this; 41751 41752 if (!this.hot.getSelected()) { 41753 return; 41754 } 41755 if (this.hot.getActiveEditor() && this.hot.getActiveEditor().isOpened()) { 41756 return; 41757 } 41758 if ((0, _event.isImmediatePropagationStopped)(event)) { 41759 return; 41760 } 41761 if (!this.textarea.isActive() && (0, _element.getSelectionText)()) { 41762 return; 41763 } 41764 41765 if ((0, _unicode.isCtrlKey)(event.keyCode)) { 41766 // When fragmentSelection is enabled and some text is selected then don't blur selection calling 'setCopyableText' 41767 if (this.hot.getSettings().fragmentSelection && (0, _element.getSelectionText)()) { 41768 return; 41769 } 41770 41771 // when CTRL is pressed, prepare selectable text in textarea 41772 this.setCopyableText(); 41773 (0, _event.stopImmediatePropagation)(event); 41774 41775 return; 41776 } 41777 41778 // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL) 41779 var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey; 41780 41781 if (ctrlDown) { 41782 if (event.keyCode == _unicode.KEY_CODES.A) { 41783 setTimeout(function () { 41784 _this7.setCopyableText(); 41785 }, 0); 41786 } 41787 if (event.keyCode == _unicode.KEY_CODES.X) { 41788 this.cut(); 41789 } 41790 if (event.keyCode == _unicode.KEY_CODES.C) { 41791 this.copy(); 41792 } 41793 if (event.keyCode == _unicode.KEY_CODES.V) { 41794 this.triggerPaste(); 41795 } 41796 } 41797 } 41798 41799 /** 41800 * Destroy plugin instance. 41801 */ 41802 41803 }, { 41804 key: 'destroy', 41805 value: function destroy() { 41806 if (this.textarea) { 41807 this.textarea.destroy(); 41808 } 41809 41810 _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'destroy', this).call(this); 41811 } 41812 }]); 41813 41814 return CopyPaste; 41815}(_base2.default); 41816 41817(0, _plugins.registerPlugin)('CopyPaste', CopyPaste); 41818 41819exports.default = CopyPaste; 41820 41821/***/ }), 41822/* 358 */ 41823/***/ (function(module, exports, __webpack_require__) { 41824 41825"use strict"; 41826 41827 41828exports.__esModule = true; 41829 41830var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 41831 41832function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 41833 41834/** 41835 * @class Textarea 41836 * 41837 * @plugin CopyPaste 41838 */ 41839var Textarea = function () { 41840 _createClass(Textarea, null, [{ 41841 key: 'getSingleton', 41842 value: function getSingleton() { 41843 globalSingleton.append(); 41844 41845 return globalSingleton; 41846 } 41847 }]); 41848 41849 function Textarea() { 41850 _classCallCheck(this, Textarea); 41851 41852 /** 41853 * Main textarea element. 41854 * 41855 * @type {HTMLElement} 41856 */ 41857 this.element = void 0; 41858 /** 41859 * Store information about append to the document.body. 41860 * 41861 * @type {Boolean} 41862 */ 41863 this.isAppended = false; 41864 /** 41865 * Reference counter. 41866 * 41867 * @type {Number} 41868 */ 41869 this.refCounter = 0; 41870 } 41871 41872 /** 41873 * Apends textarea element to the `body` 41874 */ 41875 41876 41877 _createClass(Textarea, [{ 41878 key: 'append', 41879 value: function append() { 41880 if (this.hasBeenDestroyed()) { 41881 this.create(); 41882 } 41883 41884 this.refCounter++; 41885 41886 if (!this.isAppended && document.body) { 41887 if (document.body) { 41888 this.isAppended = true; 41889 document.body.appendChild(this.element); 41890 } 41891 } 41892 } 41893 41894 /** 41895 * Prepares textarea element with proper attributes. 41896 */ 41897 41898 }, { 41899 key: 'create', 41900 value: function create() { 41901 this.element = document.createElement('textarea'); 41902 this.element.id = 'HandsontableCopyPaste'; 41903 this.element.className = 'copyPaste'; 41904 this.element.tabIndex = -1; 41905 this.element.autocomplete = 'off'; 41906 this.element.wrap = 'off'; 41907 } 41908 41909 /** 41910 * Deselects textarea element if is active. 41911 */ 41912 41913 }, { 41914 key: 'deselect', 41915 value: function deselect() { 41916 if (this.element === document.activeElement) { 41917 document.activeElement.blur(); 41918 } 41919 } 41920 41921 /** 41922 * Destroy instance 41923 */ 41924 41925 }, { 41926 key: 'destroy', 41927 value: function destroy() { 41928 this.refCounter--; 41929 this.refCounter = this.refCounter < 0 ? 0 : this.refCounter; 41930 41931 if (this.hasBeenDestroyed() && this.element && this.element.parentNode) { 41932 this.element.parentNode.removeChild(this.element); 41933 this.element = null; 41934 this.isAppended = false; 41935 } 41936 } 41937 41938 /** 41939 * Getter for the element. 41940 * 41941 * @returns {String} 41942 */ 41943 41944 }, { 41945 key: 'getValue', 41946 value: function getValue() { 41947 return this.element.value; 41948 } 41949 41950 /** 41951 * Check if instance has been destroyed 41952 * 41953 * @returns {Boolean} 41954 */ 41955 41956 }, { 41957 key: 'hasBeenDestroyed', 41958 value: function hasBeenDestroyed() { 41959 return this.refCounter < 1; 41960 } 41961 41962 /** 41963 * Check if the element is an active element in frame. 41964 * 41965 * @returns {Boolean} 41966 */ 41967 41968 }, { 41969 key: 'isActive', 41970 value: function isActive() { 41971 return this.element === document.activeElement; 41972 } 41973 41974 /** 41975 * Sets focus on the element and select content. 41976 */ 41977 41978 }, { 41979 key: 'select', 41980 value: function select() { 41981 this.element.focus(); 41982 this.element.select(); 41983 } 41984 41985 /** 41986 * Setter for the element. 41987 * 41988 * @param {String} data Value which should be insert into the element. 41989 */ 41990 41991 }, { 41992 key: 'setValue', 41993 value: function setValue(data) { 41994 this.element.value = data; 41995 } 41996 }]); 41997 41998 return Textarea; 41999}(); 42000 42001var globalSingleton = new Textarea(); 42002 42003exports.default = Textarea; 42004 42005/***/ }), 42006/* 359 */ 42007/***/ (function(module, exports, __webpack_require__) { 42008 42009"use strict"; 42010 42011 42012exports.__esModule = true; 42013 42014var _pluginHooks = __webpack_require__(11); 42015 42016var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 42017 42018var _eventManager = __webpack_require__(4); 42019 42020var _eventManager2 = _interopRequireDefault(_eventManager); 42021 42022var _plugins = __webpack_require__(9); 42023 42024function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 42025 42026/** 42027 * @description 42028 * Plugin used to scroll Handsontable by selecting a cell and dragging outside of the visible viewport. 42029 * 42030 * @private 42031 * @class DragToScroll 42032 * @plugin DragToScroll 42033 */ 42034function DragToScroll() { 42035 this.boundaries = null; 42036 this.callback = null; 42037} 42038 42039/** 42040 * @param boundaries {Object} compatible with getBoundingClientRect 42041 */ 42042DragToScroll.prototype.setBoundaries = function (boundaries) { 42043 this.boundaries = boundaries; 42044}; 42045 42046/** 42047 * @param callback {Function} 42048 */ 42049DragToScroll.prototype.setCallback = function (callback) { 42050 this.callback = callback; 42051}; 42052 42053/** 42054 * Check if mouse position (x, y) is outside of the viewport 42055 * @param x 42056 * @param y 42057 */ 42058DragToScroll.prototype.check = function (x, y) { 42059 var diffX = 0; 42060 var diffY = 0; 42061 42062 if (y < this.boundaries.top) { 42063 // y is less than top 42064 diffY = y - this.boundaries.top; 42065 } else if (y > this.boundaries.bottom) { 42066 // y is more than bottom 42067 diffY = y - this.boundaries.bottom; 42068 } 42069 42070 if (x < this.boundaries.left) { 42071 // x is less than left 42072 diffX = x - this.boundaries.left; 42073 } else if (x > this.boundaries.right) { 42074 // x is more than right 42075 diffX = x - this.boundaries.right; 42076 } 42077 42078 this.callback(diffX, diffY); 42079}; 42080 42081var dragToScroll; 42082var instance; 42083 42084var setupListening = function setupListening(instance) { 42085 instance.dragToScrollListening = false; 42086 var scrollHandler = instance.view.wt.wtTable.holder; // native scroll 42087 dragToScroll = new DragToScroll(); 42088 42089 if (scrollHandler === window) { 42090 // not much we can do currently 42091 return; 42092 } 42093 42094 dragToScroll.setBoundaries(scrollHandler.getBoundingClientRect()); 42095 dragToScroll.setCallback(function (scrollX, scrollY) { 42096 if (scrollX < 0) { 42097 scrollHandler.scrollLeft -= 50; 42098 } else if (scrollX > 0) { 42099 scrollHandler.scrollLeft += 50; 42100 } 42101 42102 if (scrollY < 0) { 42103 scrollHandler.scrollTop -= 20; 42104 } else if (scrollY > 0) { 42105 scrollHandler.scrollTop += 20; 42106 } 42107 }); 42108 42109 instance.dragToScrollListening = true; 42110}; 42111 42112_pluginHooks2.default.getSingleton().add('afterInit', function () { 42113 var instance = this; 42114 var eventManager = new _eventManager2.default(this); 42115 42116 eventManager.addEventListener(document, 'mouseup', function () { 42117 instance.dragToScrollListening = false; 42118 }); 42119 42120 eventManager.addEventListener(document, 'mousemove', function (event) { 42121 if (instance.dragToScrollListening) { 42122 dragToScroll.check(event.clientX, event.clientY); 42123 } 42124 }); 42125}); 42126 42127_pluginHooks2.default.getSingleton().add('afterDestroy', function () { 42128 new _eventManager2.default(this).clear(); 42129}); 42130 42131_pluginHooks2.default.getSingleton().add('afterOnCellMouseDown', function () { 42132 setupListening(this); 42133}); 42134 42135_pluginHooks2.default.getSingleton().add('afterOnCellCornerMouseDown', function () { 42136 setupListening(this); 42137}); 42138 42139exports.default = DragToScroll; 42140 42141/***/ }), 42142/* 360 */ 42143/***/ (function(module, exports, __webpack_require__) { 42144 42145"use strict"; 42146 42147 42148exports.__esModule = true; 42149exports.default = freezeColumnItem; 42150function freezeColumnItem(manualColumnFreezePlugin) { 42151 return { 42152 key: 'freeze_column', 42153 name: 'Freeze this column', 42154 callback: function callback() { 42155 var selectedColumn = this.getSelectedRange().from.col; 42156 42157 manualColumnFreezePlugin.freezeColumn(selectedColumn); 42158 42159 this.render(); 42160 this.view.wt.wtOverlays.adjustElementsSize(true); 42161 }, 42162 hidden: function hidden() { 42163 var selection = this.getSelectedRange(); 42164 var hide = false; 42165 42166 if (selection === void 0) { 42167 hide = true; 42168 } else if (selection.from.col !== selection.to.col || selection.from.col <= this.getSettings().fixedColumnsLeft - 1) { 42169 hide = true; 42170 } 42171 42172 return hide; 42173 } 42174 }; 42175} 42176 42177/***/ }), 42178/* 361 */ 42179/***/ (function(module, exports, __webpack_require__) { 42180 42181"use strict"; 42182 42183 42184exports.__esModule = true; 42185exports.default = unfreezeColumnItem; 42186function unfreezeColumnItem(manualColumnFreezePlugin) { 42187 return { 42188 key: 'unfreeze_column', 42189 name: 'Unfreeze this column', 42190 callback: function callback() { 42191 var selectedColumn = this.getSelectedRange().from.col; 42192 42193 manualColumnFreezePlugin.unfreezeColumn(selectedColumn); 42194 42195 this.render(); 42196 this.view.wt.wtOverlays.adjustElementsSize(true); 42197 }, 42198 hidden: function hidden() { 42199 var selection = this.getSelectedRange(); 42200 var hide = false; 42201 42202 if (selection === void 0) { 42203 hide = true; 42204 } else if (selection.from.col !== selection.to.col || selection.from.col >= this.getSettings().fixedColumnsLeft) { 42205 hide = true; 42206 } 42207 42208 return hide; 42209 } 42210 }; 42211} 42212 42213/***/ }), 42214/* 362 */ 42215/***/ (function(module, exports, __webpack_require__) { 42216 42217"use strict"; 42218 42219 42220exports.__esModule = true; 42221 42222var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 42223 42224var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 42225 42226var _base = __webpack_require__(16); 42227 42228var _base2 = _interopRequireDefault(_base); 42229 42230var _plugins = __webpack_require__(9); 42231 42232var _array = __webpack_require__(2); 42233 42234var _freezeColumn = __webpack_require__(360); 42235 42236var _freezeColumn2 = _interopRequireDefault(_freezeColumn); 42237 42238var _unfreezeColumn = __webpack_require__(361); 42239 42240var _unfreezeColumn2 = _interopRequireDefault(_unfreezeColumn); 42241 42242__webpack_require__(301); 42243 42244function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 42245 42246function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 42247 42248function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 42249 42250function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 42251 42252var privatePool = new WeakMap(); 42253/** 42254 * This plugin allows to manually "freeze" and "unfreeze" a column using an entry in the Context Menu. 42255 * You can turn it on by setting a `manualColumnFreeze` property to `true`. 42256 * 42257 * @plugin ManualColumnFreeze 42258 * @dependencies ManualColumnMove 42259 */ 42260 42261var ManualColumnFreeze = function (_BasePlugin) { 42262 _inherits(ManualColumnFreeze, _BasePlugin); 42263 42264 function ManualColumnFreeze(hotInstance) { 42265 _classCallCheck(this, ManualColumnFreeze); 42266 42267 var _this = _possibleConstructorReturn(this, (ManualColumnFreeze.__proto__ || Object.getPrototypeOf(ManualColumnFreeze)).call(this, hotInstance)); 42268 42269 privatePool.set(_this, { 42270 moveByFreeze: false, 42271 afterFirstUse: false 42272 }); 42273 /** 42274 * Original column positions 42275 * 42276 * @type {Array} 42277 */ 42278 _this.frozenColumnsBasePositions = []; 42279 /** 42280 * Reference to the `ManualColumnMove` plugin. 42281 */ 42282 _this.manualColumnMovePlugin = void 0; 42283 return _this; 42284 } 42285 42286 /** 42287 * Check if the plugin is enabled in the Handsontable settings. 42288 * 42289 * @returns {Boolean} 42290 */ 42291 42292 42293 _createClass(ManualColumnFreeze, [{ 42294 key: 'isEnabled', 42295 value: function isEnabled() { 42296 return !!this.hot.getSettings().manualColumnFreeze; 42297 } 42298 42299 /** 42300 * Enable plugin for this Handsontable instance. 42301 */ 42302 42303 }, { 42304 key: 'enablePlugin', 42305 value: function enablePlugin() { 42306 var _this2 = this; 42307 42308 if (this.enabled) { 42309 return; 42310 } 42311 42312 this.addHook('afterContextMenuDefaultOptions', function (options) { 42313 return _this2.addContextMenuEntry(options); 42314 }); 42315 this.addHook('afterInit', function () { 42316 return _this2.onAfterInit(); 42317 }); 42318 this.addHook('beforeColumnMove', function (rows, target) { 42319 return _this2.onBeforeColumnMove(rows, target); 42320 }); 42321 42322 _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'enablePlugin', this).call(this); 42323 } 42324 42325 /** 42326 * Disable plugin for this Handsontable instance. 42327 */ 42328 42329 }, { 42330 key: 'disablePlugin', 42331 value: function disablePlugin() { 42332 var priv = privatePool.get(this); 42333 42334 priv.afterFirstUse = false; 42335 priv.moveByFreeze = false; 42336 42337 _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'disablePlugin', this).call(this); 42338 } 42339 42340 /** 42341 * Updates the plugin to use the latest options you have specified. 42342 */ 42343 42344 }, { 42345 key: 'updatePlugin', 42346 value: function updatePlugin() { 42347 this.disablePlugin(); 42348 this.enablePlugin(); 42349 42350 _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'updatePlugin', this).call(this); 42351 } 42352 42353 /** 42354 * Freeze the given column (add it to fixed columns). 42355 * 42356 * @param {Number} column Visual column index. 42357 */ 42358 42359 }, { 42360 key: 'freezeColumn', 42361 value: function freezeColumn(column) { 42362 var priv = privatePool.get(this); 42363 var settings = this.hot.getSettings(); 42364 42365 if (!priv.afterFirstUse) { 42366 priv.afterFirstUse = true; 42367 } 42368 42369 if (settings.fixedColumnsLeft === this.hot.countCols() || column <= settings.fixedColumnsLeft - 1) { 42370 return; // already fixed 42371 } 42372 42373 priv.moveByFreeze = true; 42374 42375 if (column !== this.getMovePlugin().columnsMapper.getValueByIndex(column)) { 42376 this.frozenColumnsBasePositions[settings.fixedColumnsLeft] = column; 42377 } 42378 42379 this.getMovePlugin().moveColumn(column, settings.fixedColumnsLeft++); 42380 } 42381 42382 /** 42383 * Unfreeze the given column (remove it from fixed columns and bring to it's previous position). 42384 * 42385 * @param {Number} column Visual column index. 42386 */ 42387 42388 }, { 42389 key: 'unfreezeColumn', 42390 value: function unfreezeColumn(column) { 42391 var priv = privatePool.get(this); 42392 var settings = this.hot.getSettings(); 42393 42394 if (!priv.afterFirstUse) { 42395 priv.afterFirstUse = true; 42396 } 42397 42398 if (settings.fixedColumnsLeft <= 0 || column > settings.fixedColumnsLeft - 1) { 42399 return; // not fixed 42400 } 42401 42402 var returnCol = this.getBestColumnReturnPosition(column); 42403 42404 priv.moveByFreeze = true; 42405 settings.fixedColumnsLeft--; 42406 42407 this.getMovePlugin().moveColumn(column, returnCol + 1); 42408 } 42409 42410 /** 42411 * Get the reference to the ManualColumnMove plugin. 42412 * 42413 * @private 42414 * @returns {Object} 42415 */ 42416 42417 }, { 42418 key: 'getMovePlugin', 42419 value: function getMovePlugin() { 42420 if (!this.manualColumnMovePlugin) { 42421 this.manualColumnMovePlugin = this.hot.getPlugin('manualColumnMove'); 42422 } 42423 42424 return this.manualColumnMovePlugin; 42425 } 42426 42427 /** 42428 * Estimates the most fitting return position for unfrozen column. 42429 * 42430 * @private 42431 * @param {Number} column Visual column index. 42432 */ 42433 42434 }, { 42435 key: 'getBestColumnReturnPosition', 42436 value: function getBestColumnReturnPosition(column) { 42437 var movePlugin = this.getMovePlugin(); 42438 var settings = this.hot.getSettings(); 42439 var i = settings.fixedColumnsLeft; 42440 var j = movePlugin.columnsMapper.getValueByIndex(i); 42441 var initialCol = void 0; 42442 42443 if (this.frozenColumnsBasePositions[column] == null) { 42444 initialCol = movePlugin.columnsMapper.getValueByIndex(column); 42445 42446 while (j < initialCol) { 42447 i++; 42448 j = movePlugin.columnsMapper.getValueByIndex(i); 42449 } 42450 } else { 42451 initialCol = this.frozenColumnsBasePositions[column]; 42452 this.frozenColumnsBasePositions[column] = void 0; 42453 42454 while (j <= initialCol) { 42455 i++; 42456 j = movePlugin.columnsMapper.getValueByIndex(i); 42457 } 42458 i = j; 42459 } 42460 42461 return i - 1; 42462 } 42463 /** 42464 * Add the manualColumnFreeze context menu entries. 42465 * 42466 * @private 42467 * @param {Object} options Context menu options. 42468 */ 42469 42470 }, { 42471 key: 'addContextMenuEntry', 42472 value: function addContextMenuEntry(options) { 42473 options.items.push({ name: '---------' }, (0, _freezeColumn2.default)(this), (0, _unfreezeColumn2.default)(this)); 42474 } 42475 42476 /** 42477 * Enabling `manualColumnMove` plugin on `afterInit` hook. 42478 * 42479 * @private 42480 */ 42481 42482 }, { 42483 key: 'onAfterInit', 42484 value: function onAfterInit() { 42485 if (!this.getMovePlugin().isEnabled()) { 42486 this.getMovePlugin().enablePlugin(); 42487 } 42488 } 42489 42490 /** 42491 * Prevent moving the rows from/to fixed area. 42492 * 42493 * @private 42494 * @param {Array} rows 42495 * @param {Number} target 42496 */ 42497 42498 }, { 42499 key: 'onBeforeColumnMove', 42500 value: function onBeforeColumnMove(rows, target) { 42501 var priv = privatePool.get(this); 42502 42503 if (priv.afterFirstUse && !priv.moveByFreeze) { 42504 var frozenLen = this.hot.getSettings().fixedColumnsLeft; 42505 var disallowMoving = target < frozenLen; 42506 42507 if (!disallowMoving) { 42508 (0, _array.arrayEach)(rows, function (value, index, array) { 42509 if (value < frozenLen) { 42510 disallowMoving = true; 42511 return false; 42512 } 42513 }); 42514 } 42515 42516 if (disallowMoving) { 42517 return false; 42518 } 42519 } 42520 42521 if (priv.moveByFreeze) { 42522 priv.moveByFreeze = false; 42523 } 42524 } 42525 42526 /** 42527 * Destroy plugin instance. 42528 */ 42529 42530 }, { 42531 key: 'destroy', 42532 value: function destroy() { 42533 _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'destroy', this).call(this); 42534 } 42535 }]); 42536 42537 return ManualColumnFreeze; 42538}(_base2.default); 42539 42540(0, _plugins.registerPlugin)('manualColumnFreeze', ManualColumnFreeze); 42541 42542exports.default = ManualColumnFreeze; 42543 42544/***/ }), 42545/* 363 */ 42546/***/ (function(module, exports, __webpack_require__) { 42547 42548"use strict"; 42549 42550 42551exports.__esModule = true; 42552 42553var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 42554 42555var _arrayMapper = __webpack_require__(265); 42556 42557var _arrayMapper2 = _interopRequireDefault(_arrayMapper); 42558 42559var _array = __webpack_require__(2); 42560 42561var _object = __webpack_require__(3); 42562 42563var _number = __webpack_require__(5); 42564 42565function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 42566 42567function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 42568 42569/** 42570 * @class ColumnsMapper 42571 * @plugin ManualColumnMove 42572 */ 42573var ColumnsMapper = function () { 42574 function ColumnsMapper(manualColumnMove) { 42575 _classCallCheck(this, ColumnsMapper); 42576 42577 /** 42578 * Instance of ManualColumnMove plugin. 42579 * 42580 * @type {ManualColumnMove} 42581 */ 42582 this.manualColumnMove = manualColumnMove; 42583 } 42584 42585 /** 42586 * Reset current map array and create new one. 42587 * 42588 * @param {Number} [length] Custom generated map length. 42589 */ 42590 42591 42592 _createClass(ColumnsMapper, [{ 42593 key: 'createMap', 42594 value: function createMap(length) { 42595 var _this = this; 42596 42597 var originLength = length === void 0 ? this._arrayMap.length : length; 42598 42599 this._arrayMap.length = 0; 42600 42601 (0, _number.rangeEach)(originLength - 1, function (itemIndex) { 42602 _this._arrayMap[itemIndex] = itemIndex; 42603 }); 42604 } 42605 42606 /** 42607 * Destroy class. 42608 */ 42609 42610 }, { 42611 key: 'destroy', 42612 value: function destroy() { 42613 this._arrayMap = null; 42614 } 42615 42616 /** 42617 * Moving elements in columnsMapper. 42618 * 42619 * @param {Number} from Column index to move. 42620 * @param {Number} to Target index. 42621 */ 42622 42623 }, { 42624 key: 'moveColumn', 42625 value: function moveColumn(from, to) { 42626 var indexToMove = this._arrayMap[from]; 42627 this._arrayMap[from] = null; 42628 this._arrayMap.splice(to, 0, indexToMove); 42629 } 42630 42631 /** 42632 * Clearing arrayMap from `null` entries. 42633 */ 42634 42635 }, { 42636 key: 'clearNull', 42637 value: function clearNull() { 42638 this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) { 42639 return i !== null; 42640 }); 42641 } 42642 }]); 42643 42644 return ColumnsMapper; 42645}(); 42646 42647(0, _object.mixin)(ColumnsMapper, _arrayMapper2.default); 42648 42649exports.default = ColumnsMapper; 42650 42651/***/ }), 42652/* 364 */ 42653/***/ (function(module, exports, __webpack_require__) { 42654 42655"use strict"; 42656 42657 42658exports.__esModule = true; 42659 42660var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 42661 42662var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 42663 42664var _base = __webpack_require__(16); 42665 42666var _base2 = _interopRequireDefault(_base); 42667 42668var _pluginHooks = __webpack_require__(11); 42669 42670var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 42671 42672var _array = __webpack_require__(2); 42673 42674var _element = __webpack_require__(0); 42675 42676var _number = __webpack_require__(5); 42677 42678var _eventManager = __webpack_require__(4); 42679 42680var _eventManager2 = _interopRequireDefault(_eventManager); 42681 42682var _plugins = __webpack_require__(9); 42683 42684var _columnsMapper = __webpack_require__(363); 42685 42686var _columnsMapper2 = _interopRequireDefault(_columnsMapper); 42687 42688var _backlight = __webpack_require__(365); 42689 42690var _backlight2 = _interopRequireDefault(_backlight); 42691 42692var _guideline = __webpack_require__(366); 42693 42694var _guideline2 = _interopRequireDefault(_guideline); 42695 42696var _src = __webpack_require__(14); 42697 42698__webpack_require__(302); 42699 42700function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 42701 42702function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 42703 42704function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 42705 42706function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 42707 42708_pluginHooks2.default.getSingleton().register('beforeColumnMove'); 42709_pluginHooks2.default.getSingleton().register('afterColumnMove'); 42710_pluginHooks2.default.getSingleton().register('unmodifyCol'); 42711 42712var privatePool = new WeakMap(); 42713var CSS_PLUGIN = 'ht__manualColumnMove'; 42714var CSS_SHOW_UI = 'show-ui'; 42715var CSS_ON_MOVING = 'on-moving--columns'; 42716var CSS_AFTER_SELECTION = 'after-selection--columns'; 42717 42718/** 42719 * @plugin ManualColumnMove 42720 * 42721 * @description 42722 * This plugin allows to change columns order. 42723 * 42724 * API: 42725 * - moveColumn - move single column to the new position. 42726 * - moveColumns - move many columns (as an array of indexes) to the new position. 42727 * 42728 * If you want apply visual changes, you have to call manually the render() method on the instance of Handsontable. 42729 * 42730 * UI components: 42731 * - backlight - highlight of selected columns. 42732 * - guideline - line which shows where rows has been moved. 42733 * 42734 * @class ManualColumnMove 42735 * @plugin ManualColumnMove 42736 */ 42737 42738var ManualColumnMove = function (_BasePlugin) { 42739 _inherits(ManualColumnMove, _BasePlugin); 42740 42741 function ManualColumnMove(hotInstance) { 42742 _classCallCheck(this, ManualColumnMove); 42743 42744 /** 42745 * Set up WeakMap of plugin to sharing private parameters; 42746 */ 42747 var _this = _possibleConstructorReturn(this, (ManualColumnMove.__proto__ || Object.getPrototypeOf(ManualColumnMove)).call(this, hotInstance)); 42748 42749 privatePool.set(_this, { 42750 columnsToMove: [], 42751 countCols: 0, 42752 fixedColumns: 0, 42753 pressed: void 0, 42754 disallowMoving: void 0, 42755 target: { 42756 eventPageX: void 0, 42757 coords: void 0, 42758 TD: void 0, 42759 col: void 0 42760 } 42761 }); 42762 42763 /** 42764 * List of last removed row indexes. 42765 * 42766 * @type {Array} 42767 */ 42768 _this.removedColumns = []; 42769 /** 42770 * Object containing visual row indexes mapped to data source indexes. 42771 * 42772 * @type {RowsMapper} 42773 */ 42774 _this.columnsMapper = new _columnsMapper2.default(_this); 42775 /** 42776 * Event Manager object. 42777 * 42778 * @type {Object} 42779 */ 42780 _this.eventManager = new _eventManager2.default(_this); 42781 /** 42782 * Backlight UI object. 42783 * 42784 * @type {Object} 42785 */ 42786 _this.backlight = new _backlight2.default(hotInstance); 42787 /** 42788 * Guideline UI object. 42789 * 42790 * @type {Object} 42791 */ 42792 _this.guideline = new _guideline2.default(hotInstance); 42793 return _this; 42794 } 42795 42796 /** 42797 * Check if plugin is enabled. 42798 * 42799 * @returns {Boolean} 42800 */ 42801 42802 42803 _createClass(ManualColumnMove, [{ 42804 key: 'isEnabled', 42805 value: function isEnabled() { 42806 return !!this.hot.getSettings().manualColumnMove; 42807 } 42808 42809 /** 42810 * Enable the plugin. 42811 */ 42812 42813 }, { 42814 key: 'enablePlugin', 42815 value: function enablePlugin() { 42816 var _this2 = this; 42817 42818 if (this.enabled) { 42819 return; 42820 } 42821 42822 this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) { 42823 return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations); 42824 }); 42825 this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) { 42826 return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations); 42827 }); 42828 this.addHook('afterScrollVertically', function () { 42829 return _this2.onAfterScrollVertically(); 42830 }); 42831 this.addHook('modifyCol', function (row, source) { 42832 return _this2.onModifyCol(row, source); 42833 }); 42834 this.addHook('beforeRemoveCol', function (index, amount) { 42835 return _this2.onBeforeRemoveCol(index, amount); 42836 }); 42837 this.addHook('afterRemoveCol', function (index, amount) { 42838 return _this2.onAfterRemoveCol(index, amount); 42839 }); 42840 this.addHook('afterCreateCol', function (index, amount) { 42841 return _this2.onAfterCreateCol(index, amount); 42842 }); 42843 this.addHook('afterLoadData', function (firstTime) { 42844 return _this2.onAfterLoadData(firstTime); 42845 }); 42846 this.addHook('unmodifyCol', function (column) { 42847 return _this2.onUnmodifyCol(column); 42848 }); 42849 42850 this.registerEvents(); 42851 42852 // TODO: move adding plugin classname to BasePlugin. 42853 (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN); 42854 42855 _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'enablePlugin', this).call(this); 42856 } 42857 42858 /** 42859 * Updates the plugin to use the latest options you have specified. 42860 */ 42861 42862 }, { 42863 key: 'updatePlugin', 42864 value: function updatePlugin() { 42865 this.disablePlugin(); 42866 this.enablePlugin(); 42867 42868 this.onAfterPluginsInitialized(); 42869 42870 _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'updatePlugin', this).call(this); 42871 } 42872 42873 /** 42874 * Disable plugin for this Handsontable instance. 42875 */ 42876 42877 }, { 42878 key: 'disablePlugin', 42879 value: function disablePlugin() { 42880 var pluginSettings = this.hot.getSettings().manualColumnMove; 42881 42882 if (Array.isArray(pluginSettings)) { 42883 this.columnsMapper.clearMap(); 42884 } 42885 42886 (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN); 42887 42888 this.unregisterEvents(); 42889 this.backlight.destroy(); 42890 this.guideline.destroy(); 42891 42892 _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'disablePlugin', this).call(this); 42893 } 42894 42895 /** 42896 * Move a single column. 42897 * 42898 * @param {Number} column Visual column index to be moved. 42899 * @param {Number} target Visual column index being a target for the moved column. 42900 */ 42901 42902 }, { 42903 key: 'moveColumn', 42904 value: function moveColumn(column, target) { 42905 this.moveColumns([column], target); 42906 } 42907 42908 /** 42909 * Move multiple columns. 42910 * 42911 * @param {Array} columns Array of visual column indexes to be moved. 42912 * @param {Number} target Visual column index being a target for the moved columns. 42913 */ 42914 42915 }, { 42916 key: 'moveColumns', 42917 value: function moveColumns(columns, target) { 42918 var _this3 = this; 42919 42920 var priv = privatePool.get(this); 42921 var beforeColumnHook = this.hot.runHooks('beforeColumnMove', columns, target); 42922 42923 priv.disallowMoving = !beforeColumnHook; 42924 42925 if (beforeColumnHook !== false) { 42926 // first we need to rewrite an visual indexes to physical for save reference after move 42927 (0, _array.arrayEach)(columns, function (column, index, array) { 42928 array[index] = _this3.columnsMapper.getValueByIndex(column); 42929 }); 42930 42931 // next, when we have got an physical indexes, we can move columns 42932 (0, _array.arrayEach)(columns, function (column, index) { 42933 var actualPosition = _this3.columnsMapper.getIndexByValue(column); 42934 42935 if (actualPosition !== target) { 42936 _this3.columnsMapper.moveColumn(actualPosition, target + index); 42937 } 42938 }); 42939 42940 // after moving we have to clear columnsMapper from null entries 42941 this.columnsMapper.clearNull(); 42942 } 42943 42944 this.hot.runHooks('afterColumnMove', columns, target); 42945 } 42946 42947 /** 42948 * Correct the cell selection after the move action. Fired only when action was made with a mouse. 42949 * That means that changing the column order using the API won't correct the selection. 42950 * 42951 * @private 42952 * @param {Number} startColumn Visual column index for the start of the selection. 42953 * @param {Number} endColumn Visual column index for the end of the selection. 42954 */ 42955 42956 }, { 42957 key: 'changeSelection', 42958 value: function changeSelection(startColumn, endColumn) { 42959 var selection = this.hot.selection; 42960 var lastRowIndex = this.hot.countRows() - 1; 42961 42962 selection.setRangeStartOnly(new _src.CellCoords(0, startColumn)); 42963 selection.setRangeEnd(new _src.CellCoords(lastRowIndex, endColumn), false); 42964 } 42965 42966 /** 42967 * Get the sum of the widths of columns in the provided range. 42968 * 42969 * @private 42970 * @param {Number} from Visual column index. 42971 * @param {Number} to Visual column index. 42972 * @returns {Number} 42973 */ 42974 42975 }, { 42976 key: 'getColumnsWidth', 42977 value: function getColumnsWidth(from, to) { 42978 var width = 0; 42979 42980 for (var i = from; i < to; i++) { 42981 var columnWidth = 0; 42982 42983 if (i < 0) { 42984 columnWidth = this.hot.view.wt.wtTable.getColumnWidth(i) || 0; 42985 } else { 42986 columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0; 42987 } 42988 42989 width += columnWidth; 42990 } 42991 42992 return width; 42993 } 42994 42995 /** 42996 * Load initial settings when persistent state is saved or when plugin was initialized as an array. 42997 * 42998 * @private 42999 */ 43000 43001 }, { 43002 key: 'initialSettings', 43003 value: function initialSettings() { 43004 var pluginSettings = this.hot.getSettings().manualColumnMove; 43005 43006 if (Array.isArray(pluginSettings)) { 43007 this.moveColumns(pluginSettings, 0); 43008 } else if (pluginSettings !== void 0) { 43009 this.persistentStateLoad(); 43010 } 43011 } 43012 43013 /** 43014 * Check if the provided column is in the fixedColumnsLeft section. 43015 * 43016 * @private 43017 * @param {Number} column Visual column index to check. 43018 * @returns {Boolean} 43019 */ 43020 43021 }, { 43022 key: 'isFixedColumnsLeft', 43023 value: function isFixedColumnsLeft(column) { 43024 return column < this.hot.getSettings().fixedColumnsLeft; 43025 } 43026 43027 /** 43028 * Save the manual column positions to the persistent state. 43029 * 43030 * @private 43031 */ 43032 43033 }, { 43034 key: 'persistentStateSave', 43035 value: function persistentStateSave() { 43036 this.hot.runHooks('persistentStateSave', 'manualColumnMove', this.columnsMapper._arrayMap); 43037 } 43038 43039 /** 43040 * Load the manual column positions from the persistent state. 43041 * 43042 * @private 43043 */ 43044 43045 }, { 43046 key: 'persistentStateLoad', 43047 value: function persistentStateLoad() { 43048 var storedState = {}; 43049 43050 this.hot.runHooks('persistentStateLoad', 'manualColumnMove', storedState); 43051 43052 if (storedState.value) { 43053 this.columnsMapper._arrayMap = storedState.value; 43054 } 43055 } 43056 43057 /** 43058 * Prepare array of indexes based on actual selection. 43059 * 43060 * @private 43061 * @returns {Array} 43062 */ 43063 43064 }, { 43065 key: 'prepareColumnsToMoving', 43066 value: function prepareColumnsToMoving(start, end) { 43067 var selectedColumns = []; 43068 43069 (0, _number.rangeEach)(start, end, function (i) { 43070 selectedColumns.push(i); 43071 }); 43072 43073 return selectedColumns; 43074 } 43075 43076 /** 43077 * Update the UI visual position. 43078 * 43079 * @private 43080 */ 43081 43082 }, { 43083 key: 'refreshPositions', 43084 value: function refreshPositions() { 43085 var priv = privatePool.get(this); 43086 var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleColumn(); 43087 var lastVisible = this.hot.view.wt.wtTable.getLastVisibleColumn(); 43088 var wtTable = this.hot.view.wt.wtTable; 43089 var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement; 43090 var scrollLeft = typeof scrollableElement.scrollX === 'number' ? scrollableElement.scrollX : scrollableElement.scrollLeft; 43091 var tdOffsetLeft = this.hot.view.THEAD.offsetLeft + this.getColumnsWidth(0, priv.coordsColumn); 43092 var mouseOffsetLeft = priv.target.eventPageX - (priv.rootElementOffset - (scrollableElement.scrollX === void 0 ? scrollLeft : 0)); 43093 var hiderWidth = wtTable.hider.offsetWidth; 43094 var tbodyOffsetLeft = wtTable.TBODY.offsetLeft; 43095 var backlightElemMarginLeft = this.backlight.getOffset().left; 43096 var backlightElemWidth = this.backlight.getSize().width; 43097 var rowHeaderWidth = 0; 43098 43099 if (priv.rootElementOffset + wtTable.holder.offsetWidth + scrollLeft < priv.target.eventPageX) { 43100 if (priv.coordsColumn < priv.countCols) { 43101 priv.coordsColumn++; 43102 } 43103 } 43104 43105 if (priv.hasRowHeaders) { 43106 rowHeaderWidth = this.hot.view.wt.wtOverlays.leftOverlay.clone.wtTable.getColumnHeader(-1).offsetWidth; 43107 } 43108 if (this.isFixedColumnsLeft(priv.coordsColumn)) { 43109 tdOffsetLeft += scrollLeft; 43110 } 43111 tdOffsetLeft += rowHeaderWidth; 43112 43113 if (priv.coordsColumn < 0) { 43114 // if hover on rowHeader 43115 if (priv.fixedColumns > 0) { 43116 priv.target.col = 0; 43117 } else { 43118 priv.target.col = firstVisible > 0 ? firstVisible - 1 : firstVisible; 43119 } 43120 } else if (priv.target.TD.offsetWidth / 2 + tdOffsetLeft <= mouseOffsetLeft) { 43121 var newCoordsCol = priv.coordsColumn >= priv.countCols ? priv.countCols - 1 : priv.coordsColumn; 43122 // if hover on right part of TD 43123 priv.target.col = newCoordsCol + 1; 43124 // unfortunately first column is bigger than rest 43125 tdOffsetLeft += priv.target.TD.offsetWidth; 43126 43127 if (priv.target.col > lastVisible) { 43128 this.hot.scrollViewportTo(void 0, lastVisible + 1, void 0, true); 43129 } 43130 } else { 43131 // elsewhere on table 43132 priv.target.col = priv.coordsColumn; 43133 43134 if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) { 43135 this.hot.scrollViewportTo(void 0, firstVisible - 1); 43136 } 43137 } 43138 43139 if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) { 43140 this.hot.scrollViewportTo(void 0, firstVisible - 1); 43141 } 43142 43143 var backlightLeft = mouseOffsetLeft; 43144 var guidelineLeft = tdOffsetLeft; 43145 43146 if (mouseOffsetLeft + backlightElemWidth + backlightElemMarginLeft >= hiderWidth) { 43147 // prevent display backlight on the right side of the table 43148 backlightLeft = hiderWidth - backlightElemWidth - backlightElemMarginLeft; 43149 } else if (mouseOffsetLeft + backlightElemMarginLeft < tbodyOffsetLeft + rowHeaderWidth) { 43150 // prevent display backlight on the left side of the table 43151 backlightLeft = tbodyOffsetLeft + rowHeaderWidth + Math.abs(backlightElemMarginLeft); 43152 } 43153 43154 if (tdOffsetLeft >= hiderWidth - 1) { 43155 // prevent display guideline outside the table 43156 guidelineLeft = hiderWidth - 1; 43157 } else if (guidelineLeft === 0) { 43158 // guideline has got `margin-left: -1px` as default 43159 guidelineLeft = 1; 43160 } else if (scrollableElement.scrollX !== void 0 && priv.coordsColumn < priv.fixedColumns) { 43161 guidelineLeft -= priv.rootElementOffset <= scrollableElement.scrollX ? priv.rootElementOffset : 0; 43162 } 43163 43164 this.backlight.setPosition(null, backlightLeft); 43165 this.guideline.setPosition(null, guidelineLeft); 43166 } 43167 43168 /** 43169 * This method checks arrayMap from columnsMapper and updates the columnsMapper if it's necessary. 43170 * 43171 * @private 43172 */ 43173 43174 }, { 43175 key: 'updateColumnsMapper', 43176 value: function updateColumnsMapper() { 43177 var countCols = this.hot.countSourceCols(); 43178 var columnsMapperLen = this.columnsMapper._arrayMap.length; 43179 43180 if (columnsMapperLen === 0) { 43181 this.columnsMapper.createMap(countCols || this.hot.getSettings().startCols); 43182 } else if (columnsMapperLen < countCols) { 43183 var diff = countCols - columnsMapperLen; 43184 43185 this.columnsMapper.insertItems(columnsMapperLen, diff); 43186 } else if (columnsMapperLen > countCols) { 43187 var maxIndex = countCols - 1; 43188 var columnsToRemove = []; 43189 43190 (0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index, array) { 43191 if (value > maxIndex) { 43192 columnsToRemove.push(index); 43193 } 43194 }); 43195 43196 this.columnsMapper.removeItems(columnsToRemove); 43197 } 43198 } 43199 43200 /** 43201 * Bind the events used by the plugin. 43202 * 43203 * @private 43204 */ 43205 43206 }, { 43207 key: 'registerEvents', 43208 value: function registerEvents() { 43209 var _this4 = this; 43210 43211 this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) { 43212 return _this4.onMouseMove(event); 43213 }); 43214 this.eventManager.addEventListener(document.documentElement, 'mouseup', function () { 43215 return _this4.onMouseUp(); 43216 }); 43217 } 43218 43219 /** 43220 * Unbind the events used by the plugin. 43221 * 43222 * @private 43223 */ 43224 43225 }, { 43226 key: 'unregisterEvents', 43227 value: function unregisterEvents() { 43228 this.eventManager.clear(); 43229 } 43230 43231 /** 43232 * Change the behavior of selection / dragging. 43233 * 43234 * @private 43235 * @param {MouseEvent} event `mousedown` event properties. 43236 * @param {CellCoords} coords Visual cell coordinates where was fired event. 43237 * @param {HTMLElement} TD Cell represented as HTMLElement. 43238 * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells. 43239 */ 43240 43241 }, { 43242 key: 'onBeforeOnCellMouseDown', 43243 value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) { 43244 var wtTable = this.hot.view.wt.wtTable; 43245 var isHeaderSelection = this.hot.selection.selectedHeader.cols; 43246 var selection = this.hot.getSelectedRange(); 43247 var priv = privatePool.get(this); 43248 var isSortingElement = event.realTarget.className.indexOf('columnSorting') > -1; 43249 43250 if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0 || isSortingElement) { 43251 priv.pressed = false; 43252 priv.columnsToMove.length = 0; 43253 (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]); 43254 return; 43255 } 43256 43257 var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended(); 43258 var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended(); 43259 43260 if (guidelineIsNotReady && backlightIsNotReady) { 43261 this.guideline.appendTo(wtTable.hider); 43262 this.backlight.appendTo(wtTable.hider); 43263 } 43264 43265 var from = selection.from, 43266 to = selection.to; 43267 43268 var start = Math.min(from.col, to.col); 43269 var end = Math.max(from.col, to.col); 43270 43271 if (coords.row < 0 && coords.col >= start && coords.col <= end) { 43272 blockCalculations.column = true; 43273 priv.pressed = true; 43274 priv.target.eventPageX = event.pageX; 43275 priv.coordsColumn = coords.col; 43276 priv.target.TD = TD; 43277 priv.target.col = coords.col; 43278 priv.columnsToMove = this.prepareColumnsToMoving(start, end); 43279 priv.hasRowHeaders = !!this.hot.getSettings().rowHeaders; 43280 priv.countCols = this.hot.countCols(); 43281 priv.fixedColumns = this.hot.getSettings().fixedColumnsLeft; 43282 priv.rootElementOffset = (0, _element.offset)(this.hot.rootElement).left; 43283 43284 var countColumnsFrom = priv.hasRowHeaders ? -1 : 0; 43285 var topPos = wtTable.holder.scrollTop + wtTable.getColumnHeaderHeight(0) + 1; 43286 var fixedColumns = coords.col < priv.fixedColumns; 43287 var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement; 43288 var wrapperIsWindow = scrollableElement.scrollX ? scrollableElement.scrollX - priv.rootElementOffset : 0; 43289 43290 var mouseOffset = event.layerX - (fixedColumns ? wrapperIsWindow : 0); 43291 var leftOffset = Math.abs(this.getColumnsWidth(start, coords.col) + mouseOffset); 43292 43293 this.backlight.setPosition(topPos, this.getColumnsWidth(countColumnsFrom, start) + leftOffset); 43294 this.backlight.setSize(this.getColumnsWidth(start, end + 1), wtTable.hider.offsetHeight - topPos); 43295 this.backlight.setOffset(null, leftOffset * -1); 43296 43297 (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING); 43298 } else { 43299 (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION); 43300 priv.pressed = false; 43301 priv.columnsToMove.length = 0; 43302 } 43303 } 43304 43305 /** 43306 * 'mouseMove' event callback. Fired when pointer move on document.documentElement. 43307 * 43308 * @private 43309 * @param {MouseEvent} event `mousemove` event properties. 43310 */ 43311 43312 }, { 43313 key: 'onMouseMove', 43314 value: function onMouseMove(event) { 43315 var priv = privatePool.get(this); 43316 43317 if (!priv.pressed) { 43318 return; 43319 } 43320 43321 // callback for browser which doesn't supports CSS pointer-event: none 43322 if (event.realTarget === this.backlight.element) { 43323 var width = this.backlight.getSize().width; 43324 this.backlight.setSize(0); 43325 43326 setTimeout(function () { 43327 this.backlight.setPosition(width); 43328 }); 43329 } 43330 43331 priv.target.eventPageX = event.pageX; 43332 this.refreshPositions(); 43333 } 43334 43335 /** 43336 * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell. 43337 * 43338 * @private 43339 * @param {MouseEvent} event `mouseover` event properties. 43340 * @param {CellCoords} coords Visual cell coordinates where was fired event. 43341 * @param {HTMLElement} TD Cell represented as HTMLElement. 43342 * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells. 43343 */ 43344 43345 }, { 43346 key: 'onBeforeOnCellMouseOver', 43347 value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) { 43348 var selectedRange = this.hot.getSelectedRange(); 43349 var priv = privatePool.get(this); 43350 43351 if (!selectedRange || !priv.pressed) { 43352 return; 43353 } 43354 43355 if (priv.columnsToMove.indexOf(coords.col) > -1) { 43356 (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI); 43357 } else { 43358 (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI); 43359 } 43360 43361 blockCalculations.row = true; 43362 blockCalculations.column = true; 43363 blockCalculations.cell = true; 43364 priv.coordsColumn = coords.col; 43365 priv.target.TD = TD; 43366 } 43367 43368 /** 43369 * `onMouseUp` hook callback. 43370 * 43371 * @private 43372 */ 43373 43374 }, { 43375 key: 'onMouseUp', 43376 value: function onMouseUp() { 43377 var priv = privatePool.get(this); 43378 43379 priv.coordsColumn = void 0; 43380 priv.pressed = false; 43381 priv.backlightWidth = 0; 43382 43383 (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]); 43384 43385 if (this.hot.selection.selectedHeader.cols) { 43386 (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION); 43387 } 43388 if (priv.columnsToMove.length < 1 || priv.target.col === void 0 || priv.columnsToMove.indexOf(priv.target.col) > -1) { 43389 return; 43390 } 43391 43392 this.moveColumns(priv.columnsToMove, priv.target.col); 43393 this.persistentStateSave(); 43394 this.hot.render(); 43395 this.hot.view.wt.wtOverlays.adjustElementsSize(true); 43396 43397 if (!priv.disallowMoving) { 43398 var selectionStart = this.columnsMapper.getIndexByValue(priv.columnsToMove[0]); 43399 var selectionEnd = this.columnsMapper.getIndexByValue(priv.columnsToMove[priv.columnsToMove.length - 1]); 43400 this.changeSelection(selectionStart, selectionEnd); 43401 } 43402 43403 priv.columnsToMove.length = 0; 43404 } 43405 43406 /** 43407 * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally. 43408 * 43409 * @private 43410 */ 43411 43412 }, { 43413 key: 'onAfterScrollVertically', 43414 value: function onAfterScrollVertically() { 43415 var wtTable = this.hot.view.wt.wtTable; 43416 var headerHeight = wtTable.getColumnHeaderHeight(0) + 1; 43417 var scrollTop = wtTable.holder.scrollTop; 43418 var posTop = headerHeight + scrollTop; 43419 43420 this.backlight.setPosition(posTop); 43421 this.backlight.setSize(null, wtTable.hider.offsetHeight - posTop); 43422 } 43423 43424 /** 43425 * `afterCreateCol` hook callback. 43426 * 43427 * @private 43428 * @param {Number} index Visual index of the created column. 43429 * @param {Number} amount Amount of created columns. 43430 */ 43431 43432 }, { 43433 key: 'onAfterCreateCol', 43434 value: function onAfterCreateCol(index, amount) { 43435 this.columnsMapper.shiftItems(index, amount); 43436 } 43437 43438 /** 43439 * On before remove column listener. 43440 * 43441 * @private 43442 * @param {Number} index Visual column index. 43443 * @param {Number} amount Defines how many columns removed. 43444 */ 43445 43446 }, { 43447 key: 'onBeforeRemoveCol', 43448 value: function onBeforeRemoveCol(index, amount) { 43449 var _this5 = this; 43450 43451 this.removedColumns.length = 0; 43452 43453 if (index !== false) { 43454 // Collect physical row index. 43455 (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) { 43456 _this5.removedColumns.push(_this5.hot.runHooks('modifyCol', removedIndex, _this5.pluginName)); 43457 }); 43458 } 43459 } 43460 43461 /** 43462 * `afterRemoveCol` hook callback. 43463 * 43464 * @private 43465 * @param {Number} index Visual column index of the removed column. 43466 * @param {Number} amount Amount of removed columns. 43467 */ 43468 43469 }, { 43470 key: 'onAfterRemoveCol', 43471 value: function onAfterRemoveCol(index, amount) { 43472 this.columnsMapper.unshiftItems(this.removedColumns); 43473 } 43474 43475 /** 43476 * `afterLoadData` hook callback. 43477 * 43478 * @private 43479 * @param {Boolean} firstTime True if that was loading data during the initialization. 43480 */ 43481 43482 }, { 43483 key: 'onAfterLoadData', 43484 value: function onAfterLoadData(firstTime) { 43485 this.updateColumnsMapper(); 43486 } 43487 43488 /** 43489 * 'modifyRow' hook callback. 43490 * 43491 * @private 43492 * @param {Number} column Visual column index. 43493 * @returns {Number} Physical column index. 43494 */ 43495 43496 }, { 43497 key: 'onModifyCol', 43498 value: function onModifyCol(column, source) { 43499 if (source !== this.pluginName) { 43500 // ugly fix for try to insert new, needed columns after pasting data 43501 var columnInMapper = this.columnsMapper.getValueByIndex(column); 43502 column = columnInMapper === null ? column : columnInMapper; 43503 } 43504 43505 return column; 43506 } 43507 43508 /** 43509 * 'unmodifyCol' hook callback. 43510 * 43511 * @private 43512 * @param {Number} column Physical column index. 43513 * @returns {Number} Visual column index. 43514 */ 43515 43516 }, { 43517 key: 'onUnmodifyCol', 43518 value: function onUnmodifyCol(column) { 43519 var indexInMapper = this.columnsMapper.getIndexByValue(column); 43520 43521 return indexInMapper === null ? column : indexInMapper; 43522 } 43523 43524 /** 43525 * `afterPluginsInitialized` hook callback. 43526 * 43527 * @private 43528 */ 43529 43530 }, { 43531 key: 'onAfterPluginsInitialized', 43532 value: function onAfterPluginsInitialized() { 43533 this.updateColumnsMapper(); 43534 this.initialSettings(); 43535 this.backlight.build(); 43536 this.guideline.build(); 43537 } 43538 43539 /** 43540 * Destroy plugin instance. 43541 */ 43542 43543 }, { 43544 key: 'destroy', 43545 value: function destroy() { 43546 this.backlight.destroy(); 43547 this.guideline.destroy(); 43548 43549 _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'destroy', this).call(this); 43550 } 43551 }]); 43552 43553 return ManualColumnMove; 43554}(_base2.default); 43555 43556(0, _plugins.registerPlugin)('ManualColumnMove', ManualColumnMove); 43557 43558exports.default = ManualColumnMove; 43559 43560/***/ }), 43561/* 365 */ 43562/***/ (function(module, exports, __webpack_require__) { 43563 43564"use strict"; 43565 43566 43567exports.__esModule = true; 43568 43569var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 43570 43571var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 43572 43573var _base = __webpack_require__(266); 43574 43575var _base2 = _interopRequireDefault(_base); 43576 43577var _element = __webpack_require__(0); 43578 43579function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 43580 43581function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 43582 43583function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 43584 43585function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 43586 43587var CSS_CLASSNAME = 'ht__manualColumnMove--backlight'; 43588 43589/** 43590 * @class BacklightUI 43591 * @util 43592 */ 43593 43594var BacklightUI = function (_BaseUI) { 43595 _inherits(BacklightUI, _BaseUI); 43596 43597 function BacklightUI() { 43598 _classCallCheck(this, BacklightUI); 43599 43600 return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments)); 43601 } 43602 43603 _createClass(BacklightUI, [{ 43604 key: 'build', 43605 43606 /** 43607 * Custom className on build process. 43608 */ 43609 value: function build() { 43610 _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this); 43611 43612 (0, _element.addClass)(this._element, CSS_CLASSNAME); 43613 } 43614 }]); 43615 43616 return BacklightUI; 43617}(_base2.default); 43618 43619exports.default = BacklightUI; 43620 43621/***/ }), 43622/* 366 */ 43623/***/ (function(module, exports, __webpack_require__) { 43624 43625"use strict"; 43626 43627 43628exports.__esModule = true; 43629 43630var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 43631 43632var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 43633 43634var _base = __webpack_require__(266); 43635 43636var _base2 = _interopRequireDefault(_base); 43637 43638var _element = __webpack_require__(0); 43639 43640function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 43641 43642function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 43643 43644function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 43645 43646function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 43647 43648var CSS_CLASSNAME = 'ht__manualColumnMove--guideline'; 43649 43650/** 43651 * @class GuidelineUI 43652 * @util 43653 */ 43654 43655var GuidelineUI = function (_BaseUI) { 43656 _inherits(GuidelineUI, _BaseUI); 43657 43658 function GuidelineUI() { 43659 _classCallCheck(this, GuidelineUI); 43660 43661 return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments)); 43662 } 43663 43664 _createClass(GuidelineUI, [{ 43665 key: 'build', 43666 43667 /** 43668 * Custom className on build process. 43669 */ 43670 value: function build() { 43671 _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this); 43672 43673 (0, _element.addClass)(this._element, CSS_CLASSNAME); 43674 } 43675 }]); 43676 43677 return GuidelineUI; 43678}(_base2.default); 43679 43680exports.default = GuidelineUI; 43681 43682/***/ }), 43683/* 367 */ 43684/***/ (function(module, exports, __webpack_require__) { 43685 43686"use strict"; 43687 43688 43689exports.__esModule = true; 43690 43691var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 43692 43693var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 43694 43695var _base = __webpack_require__(16); 43696 43697var _base2 = _interopRequireDefault(_base); 43698 43699var _element = __webpack_require__(0); 43700 43701var _eventManager = __webpack_require__(4); 43702 43703var _eventManager2 = _interopRequireDefault(_eventManager); 43704 43705var _event = __webpack_require__(7); 43706 43707var _array = __webpack_require__(2); 43708 43709var _number = __webpack_require__(5); 43710 43711var _plugins = __webpack_require__(9); 43712 43713function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 43714 43715function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 43716 43717function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 43718 43719function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 43720 43721// Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js 43722 43723/** 43724 * @description 43725 * ManualColumnResize Plugin. 43726 * 43727 * Has 2 UI components: 43728 * - handle - the draggable element that sets the desired width of the column. 43729 * - guide - the helper guide that shows the desired width as a vertical guide. 43730 * 43731 * @plugin ManualColumnResize 43732 */ 43733var ManualColumnResize = function (_BasePlugin) { 43734 _inherits(ManualColumnResize, _BasePlugin); 43735 43736 function ManualColumnResize(hotInstance) { 43737 _classCallCheck(this, ManualColumnResize); 43738 43739 var _this = _possibleConstructorReturn(this, (ManualColumnResize.__proto__ || Object.getPrototypeOf(ManualColumnResize)).call(this, hotInstance)); 43740 43741 _this.currentTH = null; 43742 _this.currentCol = null; 43743 _this.selectedCols = []; 43744 _this.currentWidth = null; 43745 _this.newSize = null; 43746 _this.startY = null; 43747 _this.startWidth = null; 43748 _this.startOffset = null; 43749 _this.handle = document.createElement('DIV'); 43750 _this.guide = document.createElement('DIV'); 43751 _this.eventManager = new _eventManager2.default(_this); 43752 _this.pressed = null; 43753 _this.dblclick = 0; 43754 _this.autoresizeTimeout = null; 43755 _this.manualColumnWidths = []; 43756 43757 (0, _element.addClass)(_this.handle, 'manualColumnResizer'); 43758 (0, _element.addClass)(_this.guide, 'manualColumnResizerGuide'); 43759 return _this; 43760 } 43761 43762 /** 43763 * Check if the plugin is enabled in the handsontable settings. 43764 * 43765 * @returns {Boolean} 43766 */ 43767 43768 43769 _createClass(ManualColumnResize, [{ 43770 key: 'isEnabled', 43771 value: function isEnabled() { 43772 return this.hot.getSettings().manualColumnResize; 43773 } 43774 43775 /** 43776 * Enable plugin for this Handsontable instance. 43777 */ 43778 43779 }, { 43780 key: 'enablePlugin', 43781 value: function enablePlugin() { 43782 var _this2 = this; 43783 43784 if (this.enabled) { 43785 return; 43786 } 43787 43788 this.manualColumnWidths = []; 43789 var initialColumnWidth = this.hot.getSettings().manualColumnResize; 43790 var loadedManualColumnWidths = this.loadManualColumnWidths(); 43791 43792 this.addHook('modifyColWidth', function (width, col) { 43793 return _this2.onModifyColWidth(width, col); 43794 }); 43795 this.addHook('beforeStretchingColumnWidth', function (stretchedWidth, column) { 43796 return _this2.onBeforeStretchingColumnWidth(stretchedWidth, column); 43797 }); 43798 this.addHook('beforeColumnResize', function (currentColumn, newSize, isDoubleClick) { 43799 return _this2.onBeforeColumnResize(currentColumn, newSize, isDoubleClick); 43800 }); 43801 43802 if (typeof loadedManualColumnWidths != 'undefined') { 43803 this.manualColumnWidths = loadedManualColumnWidths; 43804 } else if (Array.isArray(initialColumnWidth)) { 43805 this.manualColumnWidths = initialColumnWidth; 43806 } else { 43807 this.manualColumnWidths = []; 43808 } 43809 43810 // Handsontable.hooks.register('beforeColumnResize'); 43811 // Handsontable.hooks.register('afterColumnResize'); 43812 43813 this.bindEvents(); 43814 43815 _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'enablePlugin', this).call(this); 43816 } 43817 43818 /** 43819 * Updates the plugin to use the latest options you have specified. 43820 */ 43821 43822 }, { 43823 key: 'updatePlugin', 43824 value: function updatePlugin() { 43825 var initialColumnWidth = this.hot.getSettings().manualColumnResize; 43826 43827 if (Array.isArray(initialColumnWidth)) { 43828 this.manualColumnWidths = initialColumnWidth; 43829 } else if (!initialColumnWidth) { 43830 this.manualColumnWidths = []; 43831 } 43832 } 43833 43834 /** 43835 * Disable plugin for this Handsontable instance. 43836 */ 43837 43838 }, { 43839 key: 'disablePlugin', 43840 value: function disablePlugin() { 43841 _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'disablePlugin', this).call(this); 43842 } 43843 43844 /** 43845 * Save the current sizes using the persistentState plugin. 43846 */ 43847 43848 }, { 43849 key: 'saveManualColumnWidths', 43850 value: function saveManualColumnWidths() { 43851 this.hot.runHooks('persistentStateSave', 'manualColumnWidths', this.manualColumnWidths); 43852 } 43853 43854 /** 43855 * Load the previously saved sizes using the persistentState plugin. 43856 * 43857 * @returns {Array} 43858 */ 43859 43860 }, { 43861 key: 'loadManualColumnWidths', 43862 value: function loadManualColumnWidths() { 43863 var storedState = {}; 43864 43865 this.hot.runHooks('persistentStateLoad', 'manualColumnWidths', storedState); 43866 43867 return storedState.value; 43868 } 43869 43870 /** 43871 * Set the resize handle position. 43872 * 43873 * @param {HTMLCellElement} TH TH HTML element. 43874 */ 43875 43876 }, { 43877 key: 'setupHandlePosition', 43878 value: function setupHandlePosition(TH) { 43879 var _this3 = this; 43880 43881 if (!TH.parentNode) { 43882 return false; 43883 } 43884 43885 this.currentTH = TH; 43886 43887 var col = this.hot.view.wt.wtTable.getCoords(TH).col; // getCoords returns CellCoords 43888 var headerHeight = (0, _element.outerHeight)(this.currentTH); 43889 43890 if (col >= 0) { 43891 // if not col header 43892 var box = this.currentTH.getBoundingClientRect(); 43893 43894 this.currentCol = col; 43895 this.selectedCols = []; 43896 43897 if (this.hot.selection.isSelected() && this.hot.selection.selectedHeader.cols) { 43898 var _hot$getSelectedRange = this.hot.getSelectedRange(), 43899 from = _hot$getSelectedRange.from, 43900 to = _hot$getSelectedRange.to; 43901 43902 var start = from.col; 43903 var end = to.col; 43904 43905 if (start >= end) { 43906 start = to.col; 43907 end = from.col; 43908 } 43909 43910 if (this.currentCol >= start && this.currentCol <= end) { 43911 (0, _number.rangeEach)(start, end, function (i) { 43912 return _this3.selectedCols.push(i); 43913 }); 43914 } else { 43915 this.selectedCols.push(this.currentCol); 43916 } 43917 } else { 43918 this.selectedCols.push(this.currentCol); 43919 } 43920 43921 this.startOffset = box.left - 6; 43922 this.startWidth = parseInt(box.width, 10); 43923 this.handle.style.top = box.top + 'px'; 43924 this.handle.style.left = this.startOffset + this.startWidth + 'px'; 43925 this.handle.style.height = headerHeight + 'px'; 43926 this.hot.rootElement.appendChild(this.handle); 43927 } 43928 } 43929 43930 /** 43931 * Refresh the resize handle position. 43932 */ 43933 43934 }, { 43935 key: 'refreshHandlePosition', 43936 value: function refreshHandlePosition() { 43937 this.handle.style.left = this.startOffset + this.currentWidth + 'px'; 43938 } 43939 43940 /** 43941 * Set the resize guide position. 43942 */ 43943 43944 }, { 43945 key: 'setupGuidePosition', 43946 value: function setupGuidePosition() { 43947 var handleHeight = parseInt((0, _element.outerHeight)(this.handle), 10); 43948 var handleBottomPosition = parseInt(this.handle.style.top, 10) + handleHeight; 43949 var maximumVisibleElementHeight = parseInt(this.hot.view.maximumVisibleElementHeight(0), 10); 43950 43951 (0, _element.addClass)(this.handle, 'active'); 43952 (0, _element.addClass)(this.guide, 'active'); 43953 43954 this.guide.style.top = handleBottomPosition + 'px'; 43955 this.guide.style.left = this.handle.style.left; 43956 this.guide.style.height = maximumVisibleElementHeight - handleHeight + 'px'; 43957 this.hot.rootElement.appendChild(this.guide); 43958 } 43959 43960 /** 43961 * Refresh the resize guide position. 43962 */ 43963 43964 }, { 43965 key: 'refreshGuidePosition', 43966 value: function refreshGuidePosition() { 43967 this.guide.style.left = this.handle.style.left; 43968 } 43969 43970 /** 43971 * Hide both the resize handle and resize guide. 43972 */ 43973 43974 }, { 43975 key: 'hideHandleAndGuide', 43976 value: function hideHandleAndGuide() { 43977 (0, _element.removeClass)(this.handle, 'active'); 43978 (0, _element.removeClass)(this.guide, 'active'); 43979 } 43980 43981 /** 43982 * Check if provided element is considered a column header. 43983 * 43984 * @param {HTMLElement} element HTML element. 43985 * @returns {Boolean} 43986 */ 43987 43988 }, { 43989 key: 'checkIfColumnHeader', 43990 value: function checkIfColumnHeader(element) { 43991 if (element != this.hot.rootElement) { 43992 var parent = element.parentNode; 43993 43994 if (parent.tagName === 'THEAD') { 43995 return true; 43996 } 43997 43998 return this.checkIfColumnHeader(parent); 43999 } 44000 44001 return false; 44002 } 44003 44004 /** 44005 * Get the TH element from the provided element. 44006 * 44007 * @param {HTMLElement} element HTML element. 44008 * @returns {HTMLElement} 44009 */ 44010 44011 }, { 44012 key: 'getTHFromTargetElement', 44013 value: function getTHFromTargetElement(element) { 44014 if (element.tagName != 'TABLE') { 44015 if (element.tagName == 'TH') { 44016 return element; 44017 } 44018 return this.getTHFromTargetElement(element.parentNode); 44019 } 44020 44021 return null; 44022 } 44023 44024 /** 44025 * 'mouseover' event callback - set the handle position. 44026 * 44027 * @private 44028 * @param {MouseEvent} event 44029 */ 44030 44031 }, { 44032 key: 'onMouseOver', 44033 value: function onMouseOver(event) { 44034 if (this.checkIfColumnHeader(event.target)) { 44035 var th = this.getTHFromTargetElement(event.target); 44036 44037 if (!th) { 44038 return; 44039 } 44040 44041 var colspan = th.getAttribute('colspan'); 44042 44043 if (th && (colspan === null || colspan === 1)) { 44044 if (!this.pressed) { 44045 this.setupHandlePosition(th); 44046 } 44047 } 44048 } 44049 } 44050 44051 /** 44052 * Auto-size row after doubleclick - callback. 44053 * 44054 * @private 44055 */ 44056 44057 }, { 44058 key: 'afterMouseDownTimeout', 44059 value: function afterMouseDownTimeout() { 44060 var _this4 = this; 44061 44062 var render = function render() { 44063 _this4.hot.forceFullRender = true; 44064 _this4.hot.view.render(); // updates all 44065 _this4.hot.view.wt.wtOverlays.adjustElementsSize(true); 44066 }; 44067 var resize = function resize(selectedCol, forceRender) { 44068 var hookNewSize = _this4.hot.runHooks('beforeColumnResize', selectedCol, _this4.newSize, true); 44069 44070 if (hookNewSize !== void 0) { 44071 _this4.newSize = hookNewSize; 44072 } 44073 44074 if (_this4.hot.getSettings().stretchH === 'all') { 44075 _this4.clearManualSize(selectedCol); 44076 } else { 44077 _this4.setManualSize(selectedCol, _this4.newSize); // double click sets by auto row size plugin 44078 } 44079 44080 if (forceRender) { 44081 render(); 44082 } 44083 44084 _this4.saveManualColumnWidths(); 44085 44086 _this4.hot.runHooks('afterColumnResize', selectedCol, _this4.newSize, true); 44087 }; 44088 44089 if (this.dblclick >= 2) { 44090 var selectedColsLength = this.selectedCols.length; 44091 44092 if (selectedColsLength > 1) { 44093 (0, _array.arrayEach)(this.selectedCols, function (selectedCol) { 44094 resize(selectedCol); 44095 }); 44096 render(); 44097 } else { 44098 (0, _array.arrayEach)(this.selectedCols, function (selectedCol) { 44099 resize(selectedCol, true); 44100 }); 44101 } 44102 } 44103 this.dblclick = 0; 44104 this.autoresizeTimeout = null; 44105 } 44106 44107 /** 44108 * 'mousedown' event callback. 44109 * 44110 * @private 44111 * @param {MouseEvent} e 44112 */ 44113 44114 }, { 44115 key: 'onMouseDown', 44116 value: function onMouseDown(event) { 44117 var _this5 = this; 44118 44119 if ((0, _element.hasClass)(event.target, 'manualColumnResizer')) { 44120 this.setupGuidePosition(); 44121 this.pressed = this.hot; 44122 44123 if (this.autoresizeTimeout === null) { 44124 this.autoresizeTimeout = setTimeout(function () { 44125 return _this5.afterMouseDownTimeout(); 44126 }, 500); 44127 44128 this.hot._registerTimeout(this.autoresizeTimeout); 44129 } 44130 this.dblclick++; 44131 44132 this.startX = (0, _event.pageX)(event); 44133 this.newSize = this.startWidth; 44134 } 44135 } 44136 44137 /** 44138 * 'mousemove' event callback - refresh the handle and guide positions, cache the new column width. 44139 * 44140 * @private 44141 * @param {MouseEvent} e 44142 */ 44143 44144 }, { 44145 key: 'onMouseMove', 44146 value: function onMouseMove(event) { 44147 var _this6 = this; 44148 44149 if (this.pressed) { 44150 this.currentWidth = this.startWidth + ((0, _event.pageX)(event) - this.startX); 44151 44152 (0, _array.arrayEach)(this.selectedCols, function (selectedCol) { 44153 _this6.newSize = _this6.setManualSize(selectedCol, _this6.currentWidth); 44154 }); 44155 44156 this.refreshHandlePosition(); 44157 this.refreshGuidePosition(); 44158 } 44159 } 44160 44161 /** 44162 * 'mouseup' event callback - apply the column resizing. 44163 * 44164 * @private 44165 * @param {MouseEvent} e 44166 */ 44167 44168 }, { 44169 key: 'onMouseUp', 44170 value: function onMouseUp(event) { 44171 var _this7 = this; 44172 44173 var render = function render() { 44174 _this7.hot.forceFullRender = true; 44175 _this7.hot.view.render(); // updates all 44176 _this7.hot.view.wt.wtOverlays.adjustElementsSize(true); 44177 }; 44178 var resize = function resize(selectedCol, forceRender) { 44179 _this7.hot.runHooks('beforeColumnResize', selectedCol, _this7.newSize); 44180 44181 if (forceRender) { 44182 render(); 44183 } 44184 44185 _this7.saveManualColumnWidths(); 44186 44187 _this7.hot.runHooks('afterColumnResize', selectedCol, _this7.newSize); 44188 }; 44189 44190 if (this.pressed) { 44191 this.hideHandleAndGuide(); 44192 this.pressed = false; 44193 44194 if (this.newSize != this.startWidth) { 44195 var selectedColsLength = this.selectedCols.length; 44196 44197 if (selectedColsLength > 1) { 44198 (0, _array.arrayEach)(this.selectedCols, function (selectedCol) { 44199 resize(selectedCol); 44200 }); 44201 render(); 44202 } else { 44203 (0, _array.arrayEach)(this.selectedCols, function (selectedCol) { 44204 resize(selectedCol, true); 44205 }); 44206 } 44207 } 44208 44209 this.setupHandlePosition(this.currentTH); 44210 } 44211 } 44212 44213 /** 44214 * Bind the mouse events. 44215 * 44216 * @private 44217 */ 44218 44219 }, { 44220 key: 'bindEvents', 44221 value: function bindEvents() { 44222 var _this8 = this; 44223 44224 this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) { 44225 return _this8.onMouseOver(e); 44226 }); 44227 this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) { 44228 return _this8.onMouseDown(e); 44229 }); 44230 this.eventManager.addEventListener(window, 'mousemove', function (e) { 44231 return _this8.onMouseMove(e); 44232 }); 44233 this.eventManager.addEventListener(window, 'mouseup', function (e) { 44234 return _this8.onMouseUp(e); 44235 }); 44236 } 44237 44238 /** 44239 * Cache the current column width. 44240 * 44241 * @param {Number} column Visual column index. 44242 * @param {Number} width Column width. 44243 * @returns {Number} 44244 */ 44245 44246 }, { 44247 key: 'setManualSize', 44248 value: function setManualSize(column, width) { 44249 width = Math.max(width, 20); 44250 44251 /** 44252 * We need to run col through modifyCol hook, in case the order of displayed columns is different than the order 44253 * in data source. For instance, this order can be modified by manualColumnMove plugin. 44254 */ 44255 column = this.hot.runHooks('modifyCol', column); 44256 44257 this.manualColumnWidths[column] = width; 44258 44259 return width; 44260 } 44261 44262 /** 44263 * Clear cache for the current column index. 44264 * 44265 * @param {Number} column Visual column index. 44266 */ 44267 44268 }, { 44269 key: 'clearManualSize', 44270 value: function clearManualSize(column) { 44271 column = this.hot.runHooks('modifyCol', column); 44272 44273 this.manualColumnWidths[column] = void 0; 44274 } 44275 44276 /** 44277 * Modify the provided column width, based on the plugin settings 44278 * 44279 * @private 44280 * @param {Number} width Column width. 44281 * @param {Number} column Visual column index. 44282 * @returns {Number} 44283 */ 44284 44285 }, { 44286 key: 'onModifyColWidth', 44287 value: function onModifyColWidth(width, column) { 44288 if (this.enabled) { 44289 column = this.hot.runHooks('modifyCol', column); 44290 44291 if (this.hot.getSettings().manualColumnResize && this.manualColumnWidths[column]) { 44292 return this.manualColumnWidths[column]; 44293 } 44294 } 44295 44296 return width; 44297 } 44298 44299 /** 44300 * Modify the provided column stretched width. This hook decides if specified column should be stretched or not. 44301 * 44302 * @private 44303 * @param {Number} stretchedWidth Stretched width. 44304 * @param {Number} column Physical column index. 44305 * @returns {Number} 44306 */ 44307 44308 }, { 44309 key: 'onBeforeStretchingColumnWidth', 44310 value: function onBeforeStretchingColumnWidth(stretchedWidth, column) { 44311 var width = this.manualColumnWidths[column]; 44312 44313 if (width === void 0) { 44314 width = stretchedWidth; 44315 } 44316 44317 return width; 44318 } 44319 44320 /** 44321 * `beforeColumnResize` hook callback. 44322 * 44323 * @private 44324 * @param {Number} currentColumn Index of the resized column. 44325 * @param {Number} newSize Calculated new column width. 44326 * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click. 44327 */ 44328 44329 }, { 44330 key: 'onBeforeColumnResize', 44331 value: function onBeforeColumnResize() { 44332 // clear the header height cache information 44333 this.hot.view.wt.wtViewport.hasOversizedColumnHeadersMarked = {}; 44334 } 44335 }]); 44336 44337 return ManualColumnResize; 44338}(_base2.default); 44339 44340(0, _plugins.registerPlugin)('manualColumnResize', ManualColumnResize); 44341 44342exports.default = ManualColumnResize; 44343 44344/***/ }), 44345/* 368 */ 44346/***/ (function(module, exports, __webpack_require__) { 44347 44348"use strict"; 44349 44350 44351exports.__esModule = true; 44352 44353var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 44354 44355var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 44356 44357var _base = __webpack_require__(16); 44358 44359var _base2 = _interopRequireDefault(_base); 44360 44361var _pluginHooks = __webpack_require__(11); 44362 44363var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 44364 44365var _array = __webpack_require__(2); 44366 44367var _element = __webpack_require__(0); 44368 44369var _number = __webpack_require__(5); 44370 44371var _eventManager = __webpack_require__(4); 44372 44373var _eventManager2 = _interopRequireDefault(_eventManager); 44374 44375var _plugins = __webpack_require__(9); 44376 44377var _rowsMapper = __webpack_require__(369); 44378 44379var _rowsMapper2 = _interopRequireDefault(_rowsMapper); 44380 44381var _backlight = __webpack_require__(370); 44382 44383var _backlight2 = _interopRequireDefault(_backlight); 44384 44385var _guideline = __webpack_require__(371); 44386 44387var _guideline2 = _interopRequireDefault(_guideline); 44388 44389var _src = __webpack_require__(14); 44390 44391__webpack_require__(303); 44392 44393function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 44394 44395function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 44396 44397function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 44398 44399function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 44400 44401_pluginHooks2.default.getSingleton().register('beforeRowMove'); 44402_pluginHooks2.default.getSingleton().register('afterRowMove'); 44403_pluginHooks2.default.getSingleton().register('unmodifyRow'); 44404 44405var privatePool = new WeakMap(); 44406var CSS_PLUGIN = 'ht__manualRowMove'; 44407var CSS_SHOW_UI = 'show-ui'; 44408var CSS_ON_MOVING = 'on-moving--rows'; 44409var CSS_AFTER_SELECTION = 'after-selection--rows'; 44410 44411/** 44412 * @plugin ManualRowMove 44413 * 44414 * @description 44415 * This plugin allows to change rows order. 44416 * 44417 * API: 44418 * - moveRow - move single row to the new position. 44419 * - moveRows - move many rows (as an array of indexes) to the new position. 44420 * 44421 * If you want apply visual changes, you have to call manually the render() method on the instance of handsontable. 44422 * 44423 * UI components: 44424 * - backlight - highlight of selected rows. 44425 * - guideline - line which shows where rows has been moved. 44426 * 44427 * @class ManualRowMove 44428 * @plugin ManualRowMove 44429 */ 44430 44431var ManualRowMove = function (_BasePlugin) { 44432 _inherits(ManualRowMove, _BasePlugin); 44433 44434 function ManualRowMove(hotInstance) { 44435 _classCallCheck(this, ManualRowMove); 44436 44437 /** 44438 * Set up WeakMap of plugin to sharing private parameters; 44439 */ 44440 var _this = _possibleConstructorReturn(this, (ManualRowMove.__proto__ || Object.getPrototypeOf(ManualRowMove)).call(this, hotInstance)); 44441 44442 privatePool.set(_this, { 44443 rowsToMove: [], 44444 pressed: void 0, 44445 disallowMoving: void 0, 44446 target: { 44447 eventPageY: void 0, 44448 coords: void 0, 44449 TD: void 0, 44450 row: void 0 44451 } 44452 }); 44453 44454 /** 44455 * List of last removed row indexes. 44456 * 44457 * @type {Array} 44458 */ 44459 _this.removedRows = []; 44460 /** 44461 * Object containing visual row indexes mapped to data source indexes. 44462 * 44463 * @type {RowsMapper} 44464 */ 44465 _this.rowsMapper = new _rowsMapper2.default(_this); 44466 /** 44467 * Event Manager object. 44468 * 44469 * @type {Object} 44470 */ 44471 _this.eventManager = new _eventManager2.default(_this); 44472 /** 44473 * Backlight UI object. 44474 * 44475 * @type {Object} 44476 */ 44477 _this.backlight = new _backlight2.default(hotInstance); 44478 /** 44479 * Guideline UI object. 44480 * 44481 * @type {Object} 44482 */ 44483 _this.guideline = new _guideline2.default(hotInstance); 44484 return _this; 44485 } 44486 44487 /** 44488 * Check if plugin is enabled. 44489 * 44490 * @returns {Boolean} 44491 */ 44492 44493 44494 _createClass(ManualRowMove, [{ 44495 key: 'isEnabled', 44496 value: function isEnabled() { 44497 return !!this.hot.getSettings().manualRowMove; 44498 } 44499 44500 /** 44501 * Enable the plugin. 44502 */ 44503 44504 }, { 44505 key: 'enablePlugin', 44506 value: function enablePlugin() { 44507 var _this2 = this; 44508 44509 if (this.enabled) { 44510 return; 44511 } 44512 44513 this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) { 44514 return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations); 44515 }); 44516 this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) { 44517 return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations); 44518 }); 44519 this.addHook('afterScrollHorizontally', function () { 44520 return _this2.onAfterScrollHorizontally(); 44521 }); 44522 this.addHook('modifyRow', function (row, source) { 44523 return _this2.onModifyRow(row, source); 44524 }); 44525 this.addHook('beforeRemoveRow', function (index, amount) { 44526 return _this2.onBeforeRemoveRow(index, amount); 44527 }); 44528 this.addHook('afterRemoveRow', function (index, amount) { 44529 return _this2.onAfterRemoveRow(index, amount); 44530 }); 44531 this.addHook('afterCreateRow', function (index, amount) { 44532 return _this2.onAfterCreateRow(index, amount); 44533 }); 44534 this.addHook('afterLoadData', function (firstTime) { 44535 return _this2.onAfterLoadData(firstTime); 44536 }); 44537 this.addHook('beforeColumnSort', function (column, order) { 44538 return _this2.onBeforeColumnSort(column, order); 44539 }); 44540 this.addHook('unmodifyRow', function (row) { 44541 return _this2.onUnmodifyRow(row); 44542 }); 44543 44544 this.registerEvents(); 44545 44546 // TODO: move adding plugin classname to BasePlugin. 44547 (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN); 44548 44549 _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'enablePlugin', this).call(this); 44550 } 44551 44552 /** 44553 * Updates the plugin to use the latest options you have specified. 44554 */ 44555 44556 }, { 44557 key: 'updatePlugin', 44558 value: function updatePlugin() { 44559 this.disablePlugin(); 44560 this.enablePlugin(); 44561 44562 this.onAfterPluginsInitialized(); 44563 44564 _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'updatePlugin', this).call(this); 44565 } 44566 44567 /** 44568 * Disable plugin for this Handsontable instance. 44569 */ 44570 44571 }, { 44572 key: 'disablePlugin', 44573 value: function disablePlugin() { 44574 var pluginSettings = this.hot.getSettings().manualRowMove; 44575 44576 if (Array.isArray(pluginSettings)) { 44577 this.rowsMapper.clearMap(); 44578 } 44579 44580 (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN); 44581 44582 this.unregisterEvents(); 44583 this.backlight.destroy(); 44584 this.guideline.destroy(); 44585 44586 _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'disablePlugin', this).call(this); 44587 } 44588 44589 /** 44590 * Move a single row. 44591 * 44592 * @param {Number} row Visual row index to be moved. 44593 * @param {Number} target Visual row index being a target for the moved row. 44594 */ 44595 44596 }, { 44597 key: 'moveRow', 44598 value: function moveRow(row, target) { 44599 this.moveRows([row], target); 44600 } 44601 44602 /** 44603 * Move multiple rows. 44604 * 44605 * @param {Array} rows Array of visual row indexes to be moved. 44606 * @param {Number} target Visual row index being a target for the moved rows. 44607 */ 44608 44609 }, { 44610 key: 'moveRows', 44611 value: function moveRows(rows, target) { 44612 var _this3 = this; 44613 44614 var priv = privatePool.get(this); 44615 var beforeMoveHook = this.hot.runHooks('beforeRowMove', rows, target); 44616 44617 priv.disallowMoving = beforeMoveHook === false; 44618 44619 if (!priv.disallowMoving) { 44620 // first we need to rewrite an visual indexes to physical for save reference after move 44621 (0, _array.arrayEach)(rows, function (row, index, array) { 44622 array[index] = _this3.rowsMapper.getValueByIndex(row); 44623 }); 44624 44625 // next, when we have got an physical indexes, we can move rows 44626 (0, _array.arrayEach)(rows, function (row, index) { 44627 var actualPosition = _this3.rowsMapper.getIndexByValue(row); 44628 44629 if (actualPosition !== target) { 44630 _this3.rowsMapper.moveRow(actualPosition, target + index); 44631 } 44632 }); 44633 44634 // after moving we have to clear rowsMapper from null entries 44635 this.rowsMapper.clearNull(); 44636 } 44637 44638 this.hot.runHooks('afterRowMove', rows, target); 44639 } 44640 44641 /** 44642 * Correct the cell selection after the move action. Fired only when action was made with a mouse. 44643 * That means that changing the row order using the API won't correct the selection. 44644 * 44645 * @private 44646 * @param {Number} startRow Visual row index for the start of the selection. 44647 * @param {Number} endRow Visual row index for the end of the selection. 44648 */ 44649 44650 }, { 44651 key: 'changeSelection', 44652 value: function changeSelection(startRow, endRow) { 44653 var selection = this.hot.selection; 44654 var lastColIndex = this.hot.countCols() - 1; 44655 44656 selection.setRangeStartOnly(new _src.CellCoords(startRow, 0)); 44657 selection.setRangeEnd(new _src.CellCoords(endRow, lastColIndex), false); 44658 } 44659 44660 /** 44661 * Get the sum of the heights of rows in the provided range. 44662 * 44663 * @private 44664 * @param {Number} from Visual row index. 44665 * @param {Number} to Visual row index. 44666 * @returns {Number} 44667 */ 44668 44669 }, { 44670 key: 'getRowsHeight', 44671 value: function getRowsHeight(from, to) { 44672 var height = 0; 44673 44674 for (var i = from; i < to; i++) { 44675 var rowHeight = this.hot.view.wt.wtTable.getRowHeight(i) || 23; 44676 44677 height += rowHeight; 44678 } 44679 44680 return height; 44681 } 44682 44683 /** 44684 * Load initial settings when persistent state is saved or when plugin was initialized as an array. 44685 * 44686 * @private 44687 */ 44688 44689 }, { 44690 key: 'initialSettings', 44691 value: function initialSettings() { 44692 var pluginSettings = this.hot.getSettings().manualRowMove; 44693 44694 if (Array.isArray(pluginSettings)) { 44695 this.moveRows(pluginSettings, 0); 44696 } else if (pluginSettings !== void 0) { 44697 var persistentState = this.persistentStateLoad(); 44698 44699 if (persistentState.length) { 44700 this.moveRows(persistentState, 0); 44701 } 44702 } 44703 } 44704 44705 /** 44706 * Check if the provided row is in the fixedRowsTop section. 44707 * 44708 * @private 44709 * @param {Number} row Visual row index to check. 44710 * @returns {Boolean} 44711 */ 44712 44713 }, { 44714 key: 'isFixedRowTop', 44715 value: function isFixedRowTop(row) { 44716 return row < this.hot.getSettings().fixedRowsTop; 44717 } 44718 44719 /** 44720 * Check if the provided row is in the fixedRowsBottom section. 44721 * 44722 * @private 44723 * @param {Number} row Visual row index to check. 44724 * @returns {Boolean} 44725 */ 44726 44727 }, { 44728 key: 'isFixedRowBottom', 44729 value: function isFixedRowBottom(row) { 44730 return row > this.hot.getSettings().fixedRowsBottom; 44731 } 44732 44733 /** 44734 * Save the manual row positions to the persistent state. 44735 * 44736 * @private 44737 */ 44738 44739 }, { 44740 key: 'persistentStateSave', 44741 value: function persistentStateSave() { 44742 this.hot.runHooks('persistentStateSave', 'manualRowMove', this.rowsMapper._arrayMap); 44743 } 44744 44745 /** 44746 * Load the manual row positions from the persistent state. 44747 * 44748 * @private 44749 * @returns {Array} Stored state. 44750 */ 44751 44752 }, { 44753 key: 'persistentStateLoad', 44754 value: function persistentStateLoad() { 44755 var storedState = {}; 44756 44757 this.hot.runHooks('persistentStateLoad', 'manualRowMove', storedState); 44758 44759 return storedState.value ? storedState.value : []; 44760 } 44761 44762 /** 44763 * Prepare array of indexes based on actual selection. 44764 * 44765 * @private 44766 * @returns {Array} 44767 */ 44768 44769 }, { 44770 key: 'prepareRowsToMoving', 44771 value: function prepareRowsToMoving() { 44772 var selection = this.hot.getSelectedRange(); 44773 var selectedRows = []; 44774 44775 if (!selection) { 44776 return selectedRows; 44777 } 44778 44779 var from = selection.from, 44780 to = selection.to; 44781 44782 var start = Math.min(from.row, to.row); 44783 var end = Math.max(from.row, to.row); 44784 44785 (0, _number.rangeEach)(start, end, function (i) { 44786 selectedRows.push(i); 44787 }); 44788 44789 return selectedRows; 44790 } 44791 44792 /** 44793 * Update the UI visual position. 44794 * 44795 * @private 44796 */ 44797 44798 }, { 44799 key: 'refreshPositions', 44800 value: function refreshPositions() { 44801 var priv = privatePool.get(this); 44802 var coords = priv.target.coords; 44803 var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleRow(); 44804 var lastVisible = this.hot.view.wt.wtTable.getLastVisibleRow(); 44805 var fixedRows = this.hot.getSettings().fixedRowsTop; 44806 var countRows = this.hot.countRows(); 44807 44808 if (coords.row < fixedRows && firstVisible > 0) { 44809 this.hot.scrollViewportTo(firstVisible - 1); 44810 } 44811 if (coords.row >= lastVisible && lastVisible < countRows) { 44812 this.hot.scrollViewportTo(lastVisible + 1, undefined, true); 44813 } 44814 44815 var wtTable = this.hot.view.wt.wtTable; 44816 var TD = priv.target.TD; 44817 var rootElementOffset = (0, _element.offset)(this.hot.rootElement); 44818 var tdOffsetTop = this.hot.view.THEAD.offsetHeight + this.getRowsHeight(0, coords.row); 44819 var mouseOffsetTop = priv.target.eventPageY - rootElementOffset.top + wtTable.holder.scrollTop; 44820 var hiderHeight = wtTable.hider.offsetHeight; 44821 var tbodyOffsetTop = wtTable.TBODY.offsetTop; 44822 var backlightElemMarginTop = this.backlight.getOffset().top; 44823 var backlightElemHeight = this.backlight.getSize().height; 44824 44825 if (this.isFixedRowTop(coords.row)) { 44826 tdOffsetTop += wtTable.holder.scrollTop; 44827 } 44828 44829 // todo: fixedRowsBottom 44830 // if (this.isFixedRowBottom(coords.row)) { 44831 // 44832 // } 44833 44834 if (coords.row < 0) { 44835 // if hover on colHeader 44836 priv.target.row = firstVisible > 0 ? firstVisible - 1 : firstVisible; 44837 } else if (TD.offsetHeight / 2 + tdOffsetTop <= mouseOffsetTop) { 44838 // if hover on lower part of TD 44839 priv.target.row = coords.row + 1; 44840 // unfortunately first row is bigger than rest 44841 tdOffsetTop += coords.row === 0 ? TD.offsetHeight - 1 : TD.offsetHeight; 44842 } else { 44843 // elsewhere on table 44844 priv.target.row = coords.row; 44845 } 44846 44847 var backlightTop = mouseOffsetTop; 44848 var guidelineTop = tdOffsetTop; 44849 44850 if (mouseOffsetTop + backlightElemHeight + backlightElemMarginTop >= hiderHeight) { 44851 // prevent display backlight below table 44852 backlightTop = hiderHeight - backlightElemHeight - backlightElemMarginTop; 44853 } else if (mouseOffsetTop + backlightElemMarginTop < tbodyOffsetTop) { 44854 // prevent display above below table 44855 backlightTop = tbodyOffsetTop + Math.abs(backlightElemMarginTop); 44856 } 44857 44858 if (tdOffsetTop >= hiderHeight - 1) { 44859 // prevent display guideline below table 44860 guidelineTop = hiderHeight - 1; 44861 } 44862 44863 var topOverlayHeight = 0; 44864 if (this.hot.view.wt.wtOverlays.topOverlay) { 44865 topOverlayHeight = this.hot.view.wt.wtOverlays.topOverlay.clone.wtTable.TABLE.offsetHeight; 44866 } 44867 44868 if (coords.row >= fixedRows && guidelineTop - wtTable.holder.scrollTop < topOverlayHeight) { 44869 this.hot.scrollViewportTo(coords.row); 44870 } 44871 44872 this.backlight.setPosition(backlightTop); 44873 this.guideline.setPosition(guidelineTop); 44874 } 44875 44876 /** 44877 * This method checks arrayMap from rowsMapper and updates the rowsMapper if it's necessary. 44878 * 44879 * @private 44880 */ 44881 44882 }, { 44883 key: 'updateRowsMapper', 44884 value: function updateRowsMapper() { 44885 var countRows = this.hot.countSourceRows(); 44886 var rowsMapperLen = this.rowsMapper._arrayMap.length; 44887 44888 if (rowsMapperLen === 0) { 44889 this.rowsMapper.createMap(countRows || this.hot.getSettings().startRows); 44890 } else if (rowsMapperLen < countRows) { 44891 var diff = countRows - rowsMapperLen; 44892 44893 this.rowsMapper.insertItems(rowsMapperLen, diff); 44894 } else if (rowsMapperLen > countRows) { 44895 var maxIndex = countRows - 1; 44896 var rowsToRemove = []; 44897 44898 (0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index, array) { 44899 if (value > maxIndex) { 44900 rowsToRemove.push(index); 44901 } 44902 }); 44903 44904 this.rowsMapper.removeItems(rowsToRemove); 44905 } 44906 } 44907 44908 /** 44909 * Bind the events used by the plugin. 44910 * 44911 * @private 44912 */ 44913 44914 }, { 44915 key: 'registerEvents', 44916 value: function registerEvents() { 44917 var _this4 = this; 44918 44919 this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) { 44920 return _this4.onMouseMove(event); 44921 }); 44922 this.eventManager.addEventListener(document.documentElement, 'mouseup', function () { 44923 return _this4.onMouseUp(); 44924 }); 44925 } 44926 44927 /** 44928 * Unbind the events used by the plugin. 44929 * 44930 * @private 44931 */ 44932 44933 }, { 44934 key: 'unregisterEvents', 44935 value: function unregisterEvents() { 44936 this.eventManager.clear(); 44937 } 44938 44939 /** 44940 * `beforeColumnSort` hook callback. If user uses the sorting, manual row moving is disabled. 44941 * 44942 * @private 44943 * @param {Number} column Column index where soring is present 44944 * @param {*} order State of sorting. ASC/DESC/None 44945 */ 44946 44947 }, { 44948 key: 'onBeforeColumnSort', 44949 value: function onBeforeColumnSort(column, order) { 44950 var priv = privatePool.get(this); 44951 44952 priv.disallowMoving = order !== void 0; 44953 } 44954 44955 /** 44956 * Change the behavior of selection / dragging. 44957 * 44958 * @private 44959 * @param {MouseEvent} event 44960 * @param {CellCoords} coords Visual coordinates. 44961 * @param {HTMLElement} TD 44962 * @param {Object} blockCalculations 44963 */ 44964 44965 }, { 44966 key: 'onBeforeOnCellMouseDown', 44967 value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) { 44968 var wtTable = this.hot.view.wt.wtTable; 44969 var isHeaderSelection = this.hot.selection.selectedHeader.rows; 44970 var selection = this.hot.getSelectedRange(); 44971 var priv = privatePool.get(this); 44972 44973 if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0) { 44974 priv.pressed = false; 44975 priv.rowsToMove.length = 0; 44976 (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]); 44977 return; 44978 } 44979 44980 var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended(); 44981 var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended(); 44982 44983 if (guidelineIsNotReady && backlightIsNotReady) { 44984 this.guideline.appendTo(wtTable.hider); 44985 this.backlight.appendTo(wtTable.hider); 44986 } 44987 44988 var from = selection.from, 44989 to = selection.to; 44990 44991 var start = Math.min(from.row, to.row); 44992 var end = Math.max(from.row, to.row); 44993 44994 if (coords.col < 0 && coords.row >= start && coords.row <= end) { 44995 blockCalculations.row = true; 44996 priv.pressed = true; 44997 priv.target.eventPageY = event.pageY; 44998 priv.target.coords = coords; 44999 priv.target.TD = TD; 45000 priv.rowsToMove = this.prepareRowsToMoving(); 45001 45002 var leftPos = wtTable.holder.scrollLeft + wtTable.getColumnWidth(-1); 45003 45004 this.backlight.setPosition(null, leftPos); 45005 this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1)); 45006 this.backlight.setOffset((this.getRowsHeight(start, coords.row) + event.layerY) * -1, null); 45007 45008 (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING); 45009 45010 this.refreshPositions(); 45011 } else { 45012 (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION); 45013 priv.pressed = false; 45014 priv.rowsToMove.length = 0; 45015 } 45016 } 45017 45018 /** 45019 * 'mouseMove' event callback. Fired when pointer move on document.documentElement. 45020 * 45021 * @private 45022 * @param {MouseEvent} event `mousemove` event properties. 45023 */ 45024 45025 }, { 45026 key: 'onMouseMove', 45027 value: function onMouseMove(event) { 45028 var priv = privatePool.get(this); 45029 45030 if (!priv.pressed) { 45031 return; 45032 } 45033 45034 // callback for browser which doesn't supports CSS pointer-event: none 45035 if (event.realTarget === this.backlight.element) { 45036 var height = this.backlight.getSize().height; 45037 this.backlight.setSize(null, 0); 45038 45039 setTimeout(function () { 45040 this.backlight.setPosition(null, height); 45041 }); 45042 } 45043 45044 priv.target.eventPageY = event.pageY; 45045 this.refreshPositions(); 45046 } 45047 45048 /** 45049 * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell. 45050 * 45051 * @private 45052 * @param {MouseEvent} event `mouseover` event properties. 45053 * @param {CellCoords} coords Visual cell coordinates where was fired event. 45054 * @param {HTMLElement} TD Cell represented as HTMLElement. 45055 * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells. 45056 */ 45057 45058 }, { 45059 key: 'onBeforeOnCellMouseOver', 45060 value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) { 45061 var selectedRange = this.hot.getSelectedRange(); 45062 var priv = privatePool.get(this); 45063 45064 if (!selectedRange || !priv.pressed) { 45065 return; 45066 } 45067 45068 if (priv.rowsToMove.indexOf(coords.row) > -1) { 45069 (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI); 45070 } else { 45071 (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI); 45072 } 45073 45074 blockCalculations.row = true; 45075 blockCalculations.column = true; 45076 blockCalculations.cell = true; 45077 priv.target.coords = coords; 45078 priv.target.TD = TD; 45079 } 45080 45081 /** 45082 * `onMouseUp` hook callback. 45083 * 45084 * @private 45085 */ 45086 45087 }, { 45088 key: 'onMouseUp', 45089 value: function onMouseUp() { 45090 var priv = privatePool.get(this); 45091 var target = priv.target.row; 45092 var rowsLen = priv.rowsToMove.length; 45093 45094 priv.pressed = false; 45095 priv.backlightHeight = 0; 45096 45097 (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]); 45098 45099 if (this.hot.selection.selectedHeader.rows) { 45100 (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION); 45101 } 45102 45103 if (rowsLen < 1 || target === void 0 || priv.rowsToMove.indexOf(target) > -1 || priv.rowsToMove[rowsLen - 1] === target - 1) { 45104 return; 45105 } 45106 45107 this.moveRows(priv.rowsToMove, target); 45108 45109 this.persistentStateSave(); 45110 this.hot.render(); 45111 45112 if (!priv.disallowMoving) { 45113 var selectionStart = this.rowsMapper.getIndexByValue(priv.rowsToMove[0]); 45114 var selectionEnd = this.rowsMapper.getIndexByValue(priv.rowsToMove[rowsLen - 1]); 45115 this.changeSelection(selectionStart, selectionEnd); 45116 } 45117 45118 priv.rowsToMove.length = 0; 45119 } 45120 45121 /** 45122 * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally. 45123 * 45124 * @private 45125 */ 45126 45127 }, { 45128 key: 'onAfterScrollHorizontally', 45129 value: function onAfterScrollHorizontally() { 45130 var wtTable = this.hot.view.wt.wtTable; 45131 var headerWidth = wtTable.getColumnWidth(-1); 45132 var scrollLeft = wtTable.holder.scrollLeft; 45133 var posLeft = headerWidth + scrollLeft; 45134 45135 this.backlight.setPosition(null, posLeft); 45136 this.backlight.setSize(wtTable.hider.offsetWidth - posLeft); 45137 } 45138 45139 /** 45140 * `afterCreateRow` hook callback. 45141 * 45142 * @private 45143 * @param {Number} index Visual index of the created row. 45144 * @param {Number} amount Amount of created rows. 45145 */ 45146 45147 }, { 45148 key: 'onAfterCreateRow', 45149 value: function onAfterCreateRow(index, amount) { 45150 this.rowsMapper.shiftItems(index, amount); 45151 } 45152 45153 /** 45154 * On before remove row listener. 45155 * 45156 * @private 45157 * @param {Number} index Visual row index. 45158 * @param {Number} amount Defines how many rows removed. 45159 */ 45160 45161 }, { 45162 key: 'onBeforeRemoveRow', 45163 value: function onBeforeRemoveRow(index, amount) { 45164 var _this5 = this; 45165 45166 this.removedRows.length = 0; 45167 45168 if (index !== false) { 45169 // Collect physical row index. 45170 (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) { 45171 _this5.removedRows.push(_this5.hot.runHooks('modifyRow', removedIndex, _this5.pluginName)); 45172 }); 45173 } 45174 } 45175 45176 /** 45177 * `afterRemoveRow` hook callback. 45178 * 45179 * @private 45180 * @param {Number} index Visual index of the removed row. 45181 * @param {Number} amount Amount of removed rows. 45182 */ 45183 45184 }, { 45185 key: 'onAfterRemoveRow', 45186 value: function onAfterRemoveRow(index, amount) { 45187 this.rowsMapper.unshiftItems(this.removedRows); 45188 } 45189 45190 /** 45191 * `afterLoadData` hook callback. 45192 * 45193 * @private 45194 * @param {Boolean} firstTime True if that was loading data during the initialization. 45195 */ 45196 45197 }, { 45198 key: 'onAfterLoadData', 45199 value: function onAfterLoadData(firstTime) { 45200 this.updateRowsMapper(); 45201 } 45202 45203 /** 45204 * 'modifyRow' hook callback. 45205 * 45206 * @private 45207 * @param {Number} row Visual Row index. 45208 * @returns {Number} Physical row index. 45209 */ 45210 45211 }, { 45212 key: 'onModifyRow', 45213 value: function onModifyRow(row, source) { 45214 if (source !== this.pluginName) { 45215 var rowInMapper = this.rowsMapper.getValueByIndex(row); 45216 row = rowInMapper === null ? row : rowInMapper; 45217 } 45218 45219 return row; 45220 } 45221 45222 /** 45223 * 'unmodifyRow' hook callback. 45224 * 45225 * @private 45226 * @param {Number} row Physical row index. 45227 * @returns {Number} Visual row index. 45228 */ 45229 45230 }, { 45231 key: 'onUnmodifyRow', 45232 value: function onUnmodifyRow(row) { 45233 var indexInMapper = this.rowsMapper.getIndexByValue(row); 45234 45235 return indexInMapper === null ? row : indexInMapper; 45236 } 45237 45238 /** 45239 * `afterPluginsInitialized` hook callback. 45240 * 45241 * @private 45242 */ 45243 45244 }, { 45245 key: 'onAfterPluginsInitialized', 45246 value: function onAfterPluginsInitialized() { 45247 this.updateRowsMapper(); 45248 this.initialSettings(); 45249 this.backlight.build(); 45250 this.guideline.build(); 45251 } 45252 45253 /** 45254 * Destroy plugin instance. 45255 */ 45256 45257 }, { 45258 key: 'destroy', 45259 value: function destroy() { 45260 this.backlight.destroy(); 45261 this.guideline.destroy(); 45262 45263 _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'destroy', this).call(this); 45264 } 45265 }]); 45266 45267 return ManualRowMove; 45268}(_base2.default); 45269 45270(0, _plugins.registerPlugin)('ManualRowMove', ManualRowMove); 45271 45272exports.default = ManualRowMove; 45273 45274/***/ }), 45275/* 369 */ 45276/***/ (function(module, exports, __webpack_require__) { 45277 45278"use strict"; 45279 45280 45281exports.__esModule = true; 45282 45283var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 45284 45285var _arrayMapper = __webpack_require__(265); 45286 45287var _arrayMapper2 = _interopRequireDefault(_arrayMapper); 45288 45289var _array = __webpack_require__(2); 45290 45291var _object = __webpack_require__(3); 45292 45293var _number = __webpack_require__(5); 45294 45295function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 45296 45297function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 45298 45299/** 45300 * @class RowsMapper 45301 * @plugin ManualRowMove 45302 */ 45303var RowsMapper = function () { 45304 function RowsMapper(manualRowMove) { 45305 _classCallCheck(this, RowsMapper); 45306 45307 /** 45308 * Instance of ManualRowMove plugin. 45309 * 45310 * @type {ManualRowMove} 45311 */ 45312 this.manualRowMove = manualRowMove; 45313 } 45314 45315 /** 45316 * Reset current map array and create new one. 45317 * 45318 * @param {Number} [length] Custom generated map length. 45319 */ 45320 45321 45322 _createClass(RowsMapper, [{ 45323 key: 'createMap', 45324 value: function createMap(length) { 45325 var _this = this; 45326 45327 var originLength = length === void 0 ? this._arrayMap.length : length; 45328 45329 this._arrayMap.length = 0; 45330 45331 (0, _number.rangeEach)(originLength - 1, function (itemIndex) { 45332 _this._arrayMap[itemIndex] = itemIndex; 45333 }); 45334 } 45335 45336 /** 45337 * Destroy class. 45338 */ 45339 45340 }, { 45341 key: 'destroy', 45342 value: function destroy() { 45343 this._arrayMap = null; 45344 } 45345 45346 /** 45347 * Moving elements in rowsMapper. 45348 * 45349 * @param {Number} from Row index to move. 45350 * @param {Number} to Target index. 45351 */ 45352 45353 }, { 45354 key: 'moveRow', 45355 value: function moveRow(from, to) { 45356 var indexToMove = this._arrayMap[from]; 45357 this._arrayMap[from] = null; 45358 this._arrayMap.splice(to, 0, indexToMove); 45359 } 45360 45361 /** 45362 * Clearing arrayMap from `null` entries. 45363 */ 45364 45365 }, { 45366 key: 'clearNull', 45367 value: function clearNull() { 45368 this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) { 45369 return i !== null; 45370 }); 45371 } 45372 }]); 45373 45374 return RowsMapper; 45375}(); 45376 45377(0, _object.mixin)(RowsMapper, _arrayMapper2.default); 45378 45379exports.default = RowsMapper; 45380 45381/***/ }), 45382/* 370 */ 45383/***/ (function(module, exports, __webpack_require__) { 45384 45385"use strict"; 45386 45387 45388exports.__esModule = true; 45389 45390var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 45391 45392var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 45393 45394var _base = __webpack_require__(267); 45395 45396var _base2 = _interopRequireDefault(_base); 45397 45398var _element = __webpack_require__(0); 45399 45400function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 45401 45402function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 45403 45404function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 45405 45406function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 45407 45408var CSS_CLASSNAME = 'ht__manualRowMove--backlight'; 45409 45410/** 45411 * @class BacklightUI 45412 * @util 45413 */ 45414 45415var BacklightUI = function (_BaseUI) { 45416 _inherits(BacklightUI, _BaseUI); 45417 45418 function BacklightUI() { 45419 _classCallCheck(this, BacklightUI); 45420 45421 return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments)); 45422 } 45423 45424 _createClass(BacklightUI, [{ 45425 key: 'build', 45426 45427 /** 45428 * Custom className on build process. 45429 */ 45430 value: function build() { 45431 _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this); 45432 45433 (0, _element.addClass)(this._element, CSS_CLASSNAME); 45434 } 45435 }]); 45436 45437 return BacklightUI; 45438}(_base2.default); 45439 45440exports.default = BacklightUI; 45441 45442/***/ }), 45443/* 371 */ 45444/***/ (function(module, exports, __webpack_require__) { 45445 45446"use strict"; 45447 45448 45449exports.__esModule = true; 45450 45451var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 45452 45453var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 45454 45455var _base = __webpack_require__(267); 45456 45457var _base2 = _interopRequireDefault(_base); 45458 45459var _element = __webpack_require__(0); 45460 45461function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 45462 45463function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 45464 45465function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 45466 45467function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 45468 45469var CSS_CLASSNAME = 'ht__manualRowMove--guideline'; 45470 45471/** 45472 * @class GuidelineUI 45473 * @util 45474 */ 45475 45476var GuidelineUI = function (_BaseUI) { 45477 _inherits(GuidelineUI, _BaseUI); 45478 45479 function GuidelineUI() { 45480 _classCallCheck(this, GuidelineUI); 45481 45482 return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments)); 45483 } 45484 45485 _createClass(GuidelineUI, [{ 45486 key: 'build', 45487 45488 /** 45489 * Custom className on build process. 45490 */ 45491 value: function build() { 45492 _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this); 45493 45494 (0, _element.addClass)(this._element, CSS_CLASSNAME); 45495 } 45496 }]); 45497 45498 return GuidelineUI; 45499}(_base2.default); 45500 45501exports.default = GuidelineUI; 45502 45503/***/ }), 45504/* 372 */ 45505/***/ (function(module, exports, __webpack_require__) { 45506 45507"use strict"; 45508 45509 45510exports.__esModule = true; 45511 45512var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 45513 45514var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 45515 45516var _base = __webpack_require__(16); 45517 45518var _base2 = _interopRequireDefault(_base); 45519 45520var _element = __webpack_require__(0); 45521 45522var _eventManager = __webpack_require__(4); 45523 45524var _eventManager2 = _interopRequireDefault(_eventManager); 45525 45526var _event = __webpack_require__(7); 45527 45528var _array = __webpack_require__(2); 45529 45530var _number = __webpack_require__(5); 45531 45532var _plugins = __webpack_require__(9); 45533 45534function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 45535 45536function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 45537 45538function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 45539 45540function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 45541 45542// Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js 45543 45544/** 45545 * @description 45546 * ManualRowResize Plugin. 45547 * 45548 * Has 2 UI components: 45549 * - handle - the draggable element that sets the desired height of the row. 45550 * - guide - the helper guide that shows the desired height as a horizontal guide. 45551 * 45552 * @plugin ManualRowResize 45553 */ 45554var ManualRowResize = function (_BasePlugin) { 45555 _inherits(ManualRowResize, _BasePlugin); 45556 45557 function ManualRowResize(hotInstance) { 45558 _classCallCheck(this, ManualRowResize); 45559 45560 var _this = _possibleConstructorReturn(this, (ManualRowResize.__proto__ || Object.getPrototypeOf(ManualRowResize)).call(this, hotInstance)); 45561 45562 _this.currentTH = null; 45563 _this.currentRow = null; 45564 _this.selectedRows = []; 45565 _this.currentHeight = null; 45566 _this.newSize = null; 45567 _this.startY = null; 45568 _this.startHeight = null; 45569 _this.startOffset = null; 45570 _this.handle = document.createElement('DIV'); 45571 _this.guide = document.createElement('DIV'); 45572 _this.eventManager = new _eventManager2.default(_this); 45573 _this.pressed = null; 45574 _this.dblclick = 0; 45575 _this.autoresizeTimeout = null; 45576 _this.manualRowHeights = []; 45577 45578 (0, _element.addClass)(_this.handle, 'manualRowResizer'); 45579 (0, _element.addClass)(_this.guide, 'manualRowResizerGuide'); 45580 return _this; 45581 } 45582 45583 /** 45584 * Check if the plugin is enabled in the handsontable settings. 45585 * 45586 * @returns {Boolean} 45587 */ 45588 45589 45590 _createClass(ManualRowResize, [{ 45591 key: 'isEnabled', 45592 value: function isEnabled() { 45593 return this.hot.getSettings().manualRowResize; 45594 } 45595 45596 /** 45597 * Enable plugin for this Handsontable instance. 45598 */ 45599 45600 }, { 45601 key: 'enablePlugin', 45602 value: function enablePlugin() { 45603 var _this2 = this; 45604 45605 if (this.enabled) { 45606 return; 45607 } 45608 45609 this.manualRowHeights = []; 45610 45611 var initialRowHeights = this.hot.getSettings().manualRowResize; 45612 var loadedManualRowHeights = this.loadManualRowHeights(); 45613 45614 if (typeof loadedManualRowHeights != 'undefined') { 45615 this.manualRowHeights = loadedManualRowHeights; 45616 } else if (Array.isArray(initialRowHeights)) { 45617 this.manualRowHeights = initialRowHeights; 45618 } else { 45619 this.manualRowHeights = []; 45620 } 45621 45622 this.addHook('modifyRowHeight', function (height, row) { 45623 return _this2.onModifyRowHeight(height, row); 45624 }); 45625 45626 // Handsontable.hooks.register('beforeRowResize'); 45627 // Handsontable.hooks.register('afterRowResize'); 45628 45629 this.bindEvents(); 45630 45631 _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'enablePlugin', this).call(this); 45632 } 45633 45634 /** 45635 * Updates the plugin to use the latest options you have specified. 45636 */ 45637 45638 }, { 45639 key: 'updatePlugin', 45640 value: function updatePlugin() { 45641 var initialRowHeights = this.hot.getSettings().manualRowResize; 45642 45643 if (Array.isArray(initialRowHeights)) { 45644 this.manualRowHeights = initialRowHeights; 45645 } else if (!initialRowHeights) { 45646 this.manualRowHeights = []; 45647 } 45648 } 45649 45650 /** 45651 * Disable plugin for this Handsontable instance. 45652 */ 45653 45654 }, { 45655 key: 'disablePlugin', 45656 value: function disablePlugin() { 45657 _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'disablePlugin', this).call(this); 45658 } 45659 45660 /** 45661 * Save the current sizes using the persistentState plugin. 45662 */ 45663 45664 }, { 45665 key: 'saveManualRowHeights', 45666 value: function saveManualRowHeights() { 45667 this.hot.runHooks('persistentStateSave', 'manualRowHeights', this.manualRowHeights); 45668 } 45669 45670 /** 45671 * Load the previously saved sizes using the persistentState plugin. 45672 * 45673 * @returns {Array} 45674 */ 45675 45676 }, { 45677 key: 'loadManualRowHeights', 45678 value: function loadManualRowHeights() { 45679 var storedState = {}; 45680 45681 this.hot.runHooks('persistentStateLoad', 'manualRowHeights', storedState); 45682 45683 return storedState.value; 45684 } 45685 45686 /** 45687 * Set the resize handle position. 45688 * 45689 * @param {HTMLCellElement} TH TH HTML element. 45690 */ 45691 45692 }, { 45693 key: 'setupHandlePosition', 45694 value: function setupHandlePosition(TH) { 45695 var _this3 = this; 45696 45697 this.currentTH = TH; 45698 var row = this.hot.view.wt.wtTable.getCoords(TH).row; // getCoords returns CellCoords 45699 var headerWidth = (0, _element.outerWidth)(this.currentTH); 45700 45701 if (row >= 0) { 45702 // if not col header 45703 var box = this.currentTH.getBoundingClientRect(); 45704 45705 this.currentRow = row; 45706 this.selectedRows = []; 45707 45708 if (this.hot.selection.isSelected() && this.hot.selection.selectedHeader.rows) { 45709 var _hot$getSelectedRange = this.hot.getSelectedRange(), 45710 from = _hot$getSelectedRange.from, 45711 to = _hot$getSelectedRange.to; 45712 45713 var start = from.row; 45714 var end = to.row; 45715 45716 if (start >= end) { 45717 start = to.row; 45718 end = from.row; 45719 } 45720 45721 if (this.currentRow >= start && this.currentRow <= end) { 45722 (0, _number.rangeEach)(start, end, function (i) { 45723 return _this3.selectedRows.push(i); 45724 }); 45725 } else { 45726 this.selectedRows.push(this.currentRow); 45727 } 45728 } else { 45729 this.selectedRows.push(this.currentRow); 45730 } 45731 45732 this.startOffset = box.top - 6; 45733 this.startHeight = parseInt(box.height, 10); 45734 this.handle.style.left = box.left + 'px'; 45735 this.handle.style.top = this.startOffset + this.startHeight + 'px'; 45736 this.handle.style.width = headerWidth + 'px'; 45737 this.hot.rootElement.appendChild(this.handle); 45738 } 45739 } 45740 45741 /** 45742 * Refresh the resize handle position. 45743 */ 45744 45745 }, { 45746 key: 'refreshHandlePosition', 45747 value: function refreshHandlePosition() { 45748 this.handle.style.top = this.startOffset + this.currentHeight + 'px'; 45749 } 45750 45751 /** 45752 * Set the resize guide position. 45753 */ 45754 45755 }, { 45756 key: 'setupGuidePosition', 45757 value: function setupGuidePosition() { 45758 var handleWidth = parseInt((0, _element.outerWidth)(this.handle), 10); 45759 var handleRightPosition = parseInt(this.handle.style.left, 10) + handleWidth; 45760 var maximumVisibleElementWidth = parseInt(this.hot.view.maximumVisibleElementWidth(0), 10); 45761 (0, _element.addClass)(this.handle, 'active'); 45762 (0, _element.addClass)(this.guide, 'active'); 45763 45764 this.guide.style.top = this.handle.style.top; 45765 this.guide.style.left = handleRightPosition + 'px'; 45766 this.guide.style.width = maximumVisibleElementWidth - handleWidth + 'px'; 45767 this.hot.rootElement.appendChild(this.guide); 45768 } 45769 45770 /** 45771 * Refresh the resize guide position. 45772 */ 45773 45774 }, { 45775 key: 'refreshGuidePosition', 45776 value: function refreshGuidePosition() { 45777 this.guide.style.top = this.handle.style.top; 45778 } 45779 45780 /** 45781 * Hide both the resize handle and resize guide. 45782 */ 45783 45784 }, { 45785 key: 'hideHandleAndGuide', 45786 value: function hideHandleAndGuide() { 45787 (0, _element.removeClass)(this.handle, 'active'); 45788 (0, _element.removeClass)(this.guide, 'active'); 45789 } 45790 45791 /** 45792 * Check if provided element is considered as a row header. 45793 * 45794 * @param {HTMLElement} element HTML element. 45795 * @returns {Boolean} 45796 */ 45797 45798 }, { 45799 key: 'checkIfRowHeader', 45800 value: function checkIfRowHeader(element) { 45801 if (element != this.hot.rootElement) { 45802 var parent = element.parentNode; 45803 45804 if (parent.tagName === 'TBODY') { 45805 return true; 45806 } 45807 45808 return this.checkIfRowHeader(parent); 45809 } 45810 45811 return false; 45812 } 45813 45814 /** 45815 * Get the TH element from the provided element. 45816 * 45817 * @param {HTMLElement} element HTML element. 45818 * @returns {HTMLElement} 45819 */ 45820 45821 }, { 45822 key: 'getTHFromTargetElement', 45823 value: function getTHFromTargetElement(element) { 45824 if (element.tagName != 'TABLE') { 45825 if (element.tagName == 'TH') { 45826 return element; 45827 } 45828 return this.getTHFromTargetElement(element.parentNode); 45829 } 45830 45831 return null; 45832 } 45833 45834 /** 45835 * 'mouseover' event callback - set the handle position. 45836 * 45837 * @private 45838 * @param {MouseEvent} event 45839 */ 45840 45841 }, { 45842 key: 'onMouseOver', 45843 value: function onMouseOver(event) { 45844 if (this.checkIfRowHeader(event.target)) { 45845 var th = this.getTHFromTargetElement(event.target); 45846 45847 if (th) { 45848 if (!this.pressed) { 45849 this.setupHandlePosition(th); 45850 } 45851 } 45852 } 45853 } 45854 45855 /** 45856 * Auto-size row after doubleclick - callback. 45857 * 45858 * @private 45859 */ 45860 45861 }, { 45862 key: 'afterMouseDownTimeout', 45863 value: function afterMouseDownTimeout() { 45864 var _this4 = this; 45865 45866 var render = function render() { 45867 _this4.hot.forceFullRender = true; 45868 _this4.hot.view.render(); // updates all 45869 _this4.hot.view.wt.wtOverlays.adjustElementsSize(true); 45870 }; 45871 var resize = function resize(selectedRow, forceRender) { 45872 var hookNewSize = _this4.hot.runHooks('beforeRowResize', selectedRow, _this4.newSize, true); 45873 45874 if (hookNewSize !== void 0) { 45875 _this4.newSize = hookNewSize; 45876 } 45877 45878 _this4.setManualSize(selectedRow, _this4.newSize); // double click sets auto row size 45879 45880 if (forceRender) { 45881 render(); 45882 } 45883 45884 _this4.hot.runHooks('afterRowResize', selectedRow, _this4.newSize, true); 45885 }; 45886 45887 if (this.dblclick >= 2) { 45888 var selectedRowsLength = this.selectedRows.length; 45889 45890 if (selectedRowsLength > 1) { 45891 (0, _array.arrayEach)(this.selectedRows, function (selectedRow) { 45892 resize(selectedRow); 45893 }); 45894 render(); 45895 } else { 45896 (0, _array.arrayEach)(this.selectedRows, function (selectedRow) { 45897 resize(selectedRow, true); 45898 }); 45899 } 45900 } 45901 this.dblclick = 0; 45902 this.autoresizeTimeout = null; 45903 } 45904 45905 /** 45906 * 'mousedown' event callback. 45907 * 45908 * @private 45909 * @param {MouseEvent} event 45910 */ 45911 45912 }, { 45913 key: 'onMouseDown', 45914 value: function onMouseDown(event) { 45915 var _this5 = this; 45916 45917 if ((0, _element.hasClass)(event.target, 'manualRowResizer')) { 45918 this.setupGuidePosition(); 45919 this.pressed = this.hot; 45920 45921 if (this.autoresizeTimeout == null) { 45922 this.autoresizeTimeout = setTimeout(function () { 45923 return _this5.afterMouseDownTimeout(); 45924 }, 500); 45925 45926 this.hot._registerTimeout(this.autoresizeTimeout); 45927 } 45928 this.dblclick++; 45929 45930 this.startY = (0, _event.pageY)(event); 45931 this.newSize = this.startHeight; 45932 } 45933 } 45934 45935 /** 45936 * 'mousemove' event callback - refresh the handle and guide positions, cache the new row height. 45937 * 45938 * @private 45939 * @param {MouseEvent} event 45940 */ 45941 45942 }, { 45943 key: 'onMouseMove', 45944 value: function onMouseMove(event) { 45945 var _this6 = this; 45946 45947 if (this.pressed) { 45948 this.currentHeight = this.startHeight + ((0, _event.pageY)(event) - this.startY); 45949 45950 (0, _array.arrayEach)(this.selectedRows, function (selectedRow) { 45951 _this6.newSize = _this6.setManualSize(selectedRow, _this6.currentHeight); 45952 }); 45953 45954 this.refreshHandlePosition(); 45955 this.refreshGuidePosition(); 45956 } 45957 } 45958 45959 /** 45960 * 'mouseup' event callback - apply the row resizing. 45961 * 45962 * @private 45963 * @param {MouseEvent} event 45964 */ 45965 45966 }, { 45967 key: 'onMouseUp', 45968 value: function onMouseUp(event) { 45969 var _this7 = this; 45970 45971 var render = function render() { 45972 _this7.hot.forceFullRender = true; 45973 _this7.hot.view.render(); // updates all 45974 _this7.hot.view.wt.wtOverlays.adjustElementsSize(true); 45975 }; 45976 var runHooks = function runHooks(selectedRow, forceRender) { 45977 _this7.hot.runHooks('beforeRowResize', selectedRow, _this7.newSize); 45978 45979 if (forceRender) { 45980 render(); 45981 } 45982 45983 _this7.saveManualRowHeights(); 45984 45985 _this7.hot.runHooks('afterRowResize', selectedRow, _this7.newSize); 45986 }; 45987 if (this.pressed) { 45988 this.hideHandleAndGuide(); 45989 this.pressed = false; 45990 45991 if (this.newSize != this.startHeight) { 45992 var selectedRowsLength = this.selectedRows.length; 45993 45994 if (selectedRowsLength > 1) { 45995 (0, _array.arrayEach)(this.selectedRows, function (selectedRow) { 45996 runHooks(selectedRow); 45997 }); 45998 render(); 45999 } else { 46000 (0, _array.arrayEach)(this.selectedRows, function (selectedRow) { 46001 runHooks(selectedRow, true); 46002 }); 46003 } 46004 } 46005 46006 this.setupHandlePosition(this.currentTH); 46007 } 46008 } 46009 46010 /** 46011 * Bind the mouse events. 46012 * 46013 * @private 46014 */ 46015 46016 }, { 46017 key: 'bindEvents', 46018 value: function bindEvents() { 46019 var _this8 = this; 46020 46021 this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) { 46022 return _this8.onMouseOver(e); 46023 }); 46024 this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) { 46025 return _this8.onMouseDown(e); 46026 }); 46027 this.eventManager.addEventListener(window, 'mousemove', function (e) { 46028 return _this8.onMouseMove(e); 46029 }); 46030 this.eventManager.addEventListener(window, 'mouseup', function (e) { 46031 return _this8.onMouseUp(e); 46032 }); 46033 } 46034 46035 /** 46036 * Cache the current row height. 46037 * 46038 * @param {Number} row Visual row index. 46039 * @param {Number} height Row height. 46040 * @returns {Number} 46041 */ 46042 46043 }, { 46044 key: 'setManualSize', 46045 value: function setManualSize(row, height) { 46046 row = this.hot.runHooks('modifyRow', row); 46047 this.manualRowHeights[row] = height; 46048 46049 return height; 46050 } 46051 46052 /** 46053 * Modify the provided row height, based on the plugin settings. 46054 * 46055 * @private 46056 * @param {Number} height Row height. 46057 * @param {Number} row Visual row index. 46058 * @returns {Number} 46059 */ 46060 46061 }, { 46062 key: 'onModifyRowHeight', 46063 value: function onModifyRowHeight(height, row) { 46064 if (this.enabled) { 46065 var autoRowSizePlugin = this.hot.getPlugin('autoRowSize'); 46066 var autoRowHeightResult = autoRowSizePlugin ? autoRowSizePlugin.heights[row] : null; 46067 46068 row = this.hot.runHooks('modifyRow', row); 46069 46070 var manualRowHeight = this.manualRowHeights[row]; 46071 46072 if (manualRowHeight !== void 0 && (manualRowHeight === autoRowHeightResult || manualRowHeight > (height || 0))) { 46073 return manualRowHeight; 46074 } 46075 } 46076 46077 return height; 46078 } 46079 }]); 46080 46081 return ManualRowResize; 46082}(_base2.default); 46083 46084(0, _plugins.registerPlugin)('manualRowResize', ManualRowResize); 46085 46086exports.default = ManualRowResize; 46087 46088/***/ }), 46089/* 373 */ 46090/***/ (function(module, exports, __webpack_require__) { 46091 46092"use strict"; 46093 46094 46095exports.__esModule = true; 46096 46097var _pluginHooks = __webpack_require__(11); 46098 46099var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 46100 46101var _plugins = __webpack_require__(9); 46102 46103var _event = __webpack_require__(7); 46104 46105var _src = __webpack_require__(14); 46106 46107function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 46108 46109function CellInfoCollection() { 46110 var collection = []; 46111 46112 collection.getInfo = function (row, col) { 46113 for (var i = 0, ilen = this.length; i < ilen; i++) { 46114 if (this[i].row <= row && this[i].row + this[i].rowspan - 1 >= row && this[i].col <= col && this[i].col + this[i].colspan - 1 >= col) { 46115 return this[i]; 46116 } 46117 } 46118 }; 46119 46120 collection.setInfo = function (info) { 46121 for (var i = 0, ilen = this.length; i < ilen; i++) { 46122 if (this[i].row === info.row && this[i].col === info.col) { 46123 this[i] = info; 46124 return; 46125 } 46126 } 46127 this.push(info); 46128 }; 46129 46130 collection.removeInfo = function (row, col) { 46131 for (var i = 0, ilen = this.length; i < ilen; i++) { 46132 if (this[i].row === row && this[i].col === col) { 46133 this.splice(i, 1); 46134 break; 46135 } 46136 } 46137 }; 46138 46139 return collection; 46140} 46141 46142/** 46143 * Plugin used to merge cells in Handsontable. 46144 * 46145 * @private 46146 * @plugin MergeCells 46147 * @class MergeCells 46148 */ 46149function MergeCells(mergeCellsSetting) { 46150 this.mergedCellInfoCollection = new CellInfoCollection(); 46151 46152 if (Array.isArray(mergeCellsSetting)) { 46153 for (var i = 0, ilen = mergeCellsSetting.length; i < ilen; i++) { 46154 this.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]); 46155 } 46156 } 46157} 46158 46159/** 46160 * @param cellRange (CellRange) 46161 */ 46162MergeCells.prototype.canMergeRange = function (cellRange) { 46163 // is more than one cell selected 46164 return !cellRange.isSingle(); 46165}; 46166 46167MergeCells.prototype.mergeRange = function (cellRange) { 46168 if (!this.canMergeRange(cellRange)) { 46169 return; 46170 } 46171 46172 // normalize top left corner 46173 var topLeft = cellRange.getTopLeftCorner(); 46174 var bottomRight = cellRange.getBottomRightCorner(); 46175 46176 var mergeParent = {}; 46177 mergeParent.row = topLeft.row; 46178 mergeParent.col = topLeft.col; 46179 // TD has rowspan == 1 by default. rowspan == 2 means spread over 2 cells 46180 mergeParent.rowspan = bottomRight.row - topLeft.row + 1; 46181 mergeParent.colspan = bottomRight.col - topLeft.col + 1; 46182 this.mergedCellInfoCollection.setInfo(mergeParent); 46183}; 46184 46185MergeCells.prototype.mergeOrUnmergeSelection = function (cellRange) { 46186 var info = this.mergedCellInfoCollection.getInfo(cellRange.from.row, cellRange.from.col); 46187 if (info) { 46188 // unmerge 46189 this.unmergeSelection(cellRange.from); 46190 } else { 46191 // merge 46192 this.mergeSelection(cellRange); 46193 } 46194}; 46195 46196MergeCells.prototype.mergeSelection = function (cellRange) { 46197 this.mergeRange(cellRange); 46198}; 46199 46200MergeCells.prototype.unmergeSelection = function (cellRange) { 46201 var info = this.mergedCellInfoCollection.getInfo(cellRange.row, cellRange.col); 46202 this.mergedCellInfoCollection.removeInfo(info.row, info.col); 46203}; 46204 46205MergeCells.prototype.applySpanProperties = function (TD, row, col) { 46206 var info = this.mergedCellInfoCollection.getInfo(row, col); 46207 46208 if (info) { 46209 if (info.row === row && info.col === col) { 46210 TD.setAttribute('rowspan', info.rowspan); 46211 TD.setAttribute('colspan', info.colspan); 46212 } else { 46213 TD.removeAttribute('rowspan'); 46214 TD.removeAttribute('colspan'); 46215 46216 TD.style.display = 'none'; 46217 } 46218 } else { 46219 TD.removeAttribute('rowspan'); 46220 TD.removeAttribute('colspan'); 46221 } 46222}; 46223 46224MergeCells.prototype.modifyTransform = function (hook, currentSelectedRange, delta) { 46225 var sameRowspan = function sameRowspan(merged, coords) { 46226 if (coords.row >= merged.row && coords.row <= merged.row + merged.rowspan - 1) { 46227 return true; 46228 } 46229 return false; 46230 }, 46231 sameColspan = function sameColspan(merged, coords) { 46232 if (coords.col >= merged.col && coords.col <= merged.col + merged.colspan - 1) { 46233 return true; 46234 } 46235 return false; 46236 }, 46237 getNextPosition = function getNextPosition(newDelta) { 46238 return new _src.CellCoords(currentSelectedRange.to.row + newDelta.row, currentSelectedRange.to.col + newDelta.col); 46239 }; 46240 46241 var newDelta = { 46242 row: delta.row, 46243 col: delta.col 46244 }; 46245 46246 if (hook == 'modifyTransformStart') { 46247 /* eslint-disable block-scoped-var */ 46248 var nextPosition; 46249 46250 if (!this.lastDesiredCoords) { 46251 this.lastDesiredCoords = new _src.CellCoords(null, null); 46252 } 46253 var currentPosition = new _src.CellCoords(currentSelectedRange.highlight.row, currentSelectedRange.highlight.col), 46254 46255 // if current position's parent is a merged range, returns it 46256 mergedParent = this.mergedCellInfoCollection.getInfo(currentPosition.row, currentPosition.col), 46257 currentRangeContainsMerge; // if current range contains a merged range 46258 46259 for (var i = 0, mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) { 46260 var range = this.mergedCellInfoCollection[i]; 46261 range = new _src.CellCoords(range.row + range.rowspan - 1, range.col + range.colspan - 1); 46262 if (currentSelectedRange.includes(range)) { 46263 currentRangeContainsMerge = true; 46264 break; 46265 } 46266 } 46267 46268 if (mergedParent) { 46269 // only merge selected 46270 var mergeTopLeft = new _src.CellCoords(mergedParent.row, mergedParent.col); 46271 var mergeBottomRight = new _src.CellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1); 46272 var mergeRange = new _src.CellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight); 46273 46274 if (!mergeRange.includes(this.lastDesiredCoords)) { 46275 this.lastDesiredCoords = new _src.CellCoords(null, null); // reset outdated version of lastDesiredCoords 46276 } 46277 46278 newDelta.row = this.lastDesiredCoords.row ? this.lastDesiredCoords.row - currentPosition.row : newDelta.row; 46279 newDelta.col = this.lastDesiredCoords.col ? this.lastDesiredCoords.col - currentPosition.col : newDelta.col; 46280 46281 if (delta.row > 0) { 46282 // moving down 46283 newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row; 46284 } else if (delta.row < 0) { 46285 // moving up 46286 newDelta.row = currentPosition.row - mergedParent.row + delta.row; 46287 } 46288 if (delta.col > 0) { 46289 // moving right 46290 newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col; 46291 } else if (delta.col < 0) { 46292 // moving left 46293 newDelta.col = currentPosition.col - mergedParent.col + delta.col; 46294 } 46295 } 46296 46297 nextPosition = new _src.CellCoords(currentSelectedRange.highlight.row + newDelta.row, currentSelectedRange.highlight.col + newDelta.col); 46298 46299 var nextParentIsMerged = this.mergedCellInfoCollection.getInfo(nextPosition.row, nextPosition.col); 46300 46301 if (nextParentIsMerged) { 46302 // skipping the invisible cells in the merge range 46303 this.lastDesiredCoords = nextPosition; 46304 newDelta = { 46305 row: nextParentIsMerged.row - currentPosition.row, 46306 col: nextParentIsMerged.col - currentPosition.col 46307 }; 46308 } 46309 } else if (hook == 'modifyTransformEnd') { 46310 for (var _i = 0, _mergesLength = this.mergedCellInfoCollection.length; _i < _mergesLength; _i++) { 46311 var currentMerge = this.mergedCellInfoCollection[_i]; 46312 var _mergeTopLeft = new _src.CellCoords(currentMerge.row, currentMerge.col); 46313 var _mergeBottomRight = new _src.CellCoords(currentMerge.row + currentMerge.rowspan - 1, currentMerge.col + currentMerge.colspan - 1); 46314 var mergedRange = new _src.CellRange(_mergeTopLeft, _mergeTopLeft, _mergeBottomRight); 46315 var sharedBorders = currentSelectedRange.getBordersSharedWith(mergedRange); 46316 46317 if (mergedRange.isEqual(currentSelectedRange)) { 46318 // only the merged range is selected 46319 currentSelectedRange.setDirection('NW-SE'); 46320 } else if (sharedBorders.length > 0) { 46321 var mergeHighlighted = currentSelectedRange.highlight.isEqual(mergedRange.from); 46322 46323 if (sharedBorders.indexOf('top') > -1) { 46324 // if range shares a border with the merged section, change range direction accordingly 46325 if (currentSelectedRange.to.isSouthEastOf(mergedRange.from) && mergeHighlighted) { 46326 currentSelectedRange.setDirection('NW-SE'); 46327 } else if (currentSelectedRange.to.isSouthWestOf(mergedRange.from) && mergeHighlighted) { 46328 currentSelectedRange.setDirection('NE-SW'); 46329 } 46330 } else if (sharedBorders.indexOf('bottom') > -1) { 46331 if (currentSelectedRange.to.isNorthEastOf(mergedRange.from) && mergeHighlighted) { 46332 currentSelectedRange.setDirection('SW-NE'); 46333 } else if (currentSelectedRange.to.isNorthWestOf(mergedRange.from) && mergeHighlighted) { 46334 currentSelectedRange.setDirection('SE-NW'); 46335 } 46336 } 46337 } 46338 46339 nextPosition = getNextPosition(newDelta); 46340 var withinRowspan = sameRowspan(currentMerge, nextPosition), 46341 withinColspan = sameColspan(currentMerge, nextPosition); 46342 46343 if (currentSelectedRange.includesRange(mergedRange) && (mergedRange.includes(nextPosition) || withinRowspan || withinColspan)) { 46344 // if next step overlaps a merged range, jump past it 46345 if (withinRowspan) { 46346 if (newDelta.row < 0) { 46347 newDelta.row -= currentMerge.rowspan - 1; 46348 } else if (newDelta.row > 0) { 46349 newDelta.row += currentMerge.rowspan - 1; 46350 } 46351 } 46352 if (withinColspan) { 46353 if (newDelta.col < 0) { 46354 newDelta.col -= currentMerge.colspan - 1; 46355 } else if (newDelta.col > 0) { 46356 newDelta.col += currentMerge.colspan - 1; 46357 } 46358 } 46359 } 46360 } 46361 } 46362 46363 if (newDelta.row !== 0) { 46364 delta.row = newDelta.row; 46365 } 46366 if (newDelta.col !== 0) { 46367 delta.col = newDelta.col; 46368 } 46369}; 46370 46371MergeCells.prototype.shiftCollection = function (direction, index, count) { 46372 var shiftVector = [0, 0]; 46373 46374 switch (direction) { 46375 case 'right': 46376 shiftVector[0] += 1; 46377 46378 break; 46379 case 'left': 46380 shiftVector[0] -= 1; 46381 46382 break; 46383 case 'down': 46384 shiftVector[1] += 1; 46385 46386 break; 46387 case 'up': 46388 shiftVector[1] -= 1; 46389 46390 break; 46391 default: 46392 break; 46393 } 46394 46395 for (var i = 0; i < this.mergedCellInfoCollection.length; i++) { 46396 var currentMerge = this.mergedCellInfoCollection[i]; 46397 46398 if (direction === 'right' || direction === 'left') { 46399 if (index <= currentMerge.col) { 46400 currentMerge.col += shiftVector[0]; 46401 } 46402 } else if (index <= currentMerge.row) { 46403 currentMerge.row += shiftVector[1]; 46404 } 46405 } 46406}; 46407 46408var beforeInit = function beforeInit() { 46409 var instance = this; 46410 var mergeCellsSetting = instance.getSettings().mergeCells; 46411 46412 if (mergeCellsSetting) { 46413 if (!instance.mergeCells) { 46414 instance.mergeCells = new MergeCells(mergeCellsSetting); 46415 } 46416 } 46417}; 46418 46419var afterInit = function afterInit() { 46420 var instance = this; 46421 if (instance.mergeCells) { 46422 /** 46423 * Monkey patch Table.prototype.getCell to return TD for merged cell parent if asked for TD of a cell that is 46424 * invisible due to the merge. This is not the cleanest solution but there is a test case for it (merged cells scroll) so feel free to refactor it! 46425 */ 46426 instance.view.wt.wtTable.getCell = function (coords) { 46427 if (instance.getSettings().mergeCells) { 46428 var mergeParent = instance.mergeCells.mergedCellInfoCollection.getInfo(coords.row, coords.col); 46429 if (mergeParent) { 46430 coords = mergeParent; 46431 } 46432 } 46433 return _src.Table.prototype.getCell.call(this, coords); 46434 }; 46435 } 46436}; 46437 46438var afterUpdateSettings = function afterUpdateSettings() { 46439 var instance = this; 46440 var mergeCellsSetting = instance.getSettings().mergeCells; 46441 46442 if (mergeCellsSetting) { 46443 if (instance.mergeCells) { 46444 instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection(); 46445 46446 if (Array.isArray(mergeCellsSetting)) { 46447 for (var i = 0, ilen = mergeCellsSetting.length; i < ilen; i++) { 46448 instance.mergeCells.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]); 46449 } 46450 } 46451 } else { 46452 instance.mergeCells = new MergeCells(mergeCellsSetting); 46453 } 46454 } else if (instance.mergeCells) { 46455 // it doesn't actually turn off the plugin, just resets the settings. Need to refactor. 46456 instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection(); 46457 } 46458}; 46459 46460var onBeforeKeyDown = function onBeforeKeyDown(event) { 46461 if (!this.mergeCells) { 46462 return; 46463 } 46464 46465 var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey; 46466 46467 if (ctrlDown) { 46468 if (event.keyCode === 77) { 46469 // CTRL + M 46470 this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange()); 46471 this.render(); 46472 (0, _event.stopImmediatePropagation)(event); 46473 } 46474 } 46475}; 46476 46477var addMergeActionsToContextMenu = function addMergeActionsToContextMenu(defaultOptions) { 46478 if (!this.getSettings().mergeCells) { 46479 return; 46480 } 46481 46482 defaultOptions.items.push({ name: '---------' }); 46483 defaultOptions.items.push({ 46484 key: 'mergeCells', 46485 name: function name() { 46486 var sel = this.getSelected(); 46487 var info = this.mergeCells.mergedCellInfoCollection.getInfo(sel[0], sel[1]); 46488 if (info) { 46489 return 'Unmerge cells'; 46490 } 46491 return 'Merge cells'; 46492 }, 46493 callback: function callback() { 46494 this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange()); 46495 this.render(); 46496 }, 46497 disabled: function disabled() { 46498 return this.selection.selectedHeader.corner; 46499 } 46500 }); 46501}; 46502 46503var afterRenderer = function afterRenderer(TD, row, col, prop, value, cellProperties) { 46504 if (this.mergeCells) { 46505 this.mergeCells.applySpanProperties(TD, row, col); 46506 } 46507}; 46508 46509var modifyTransformFactory = function modifyTransformFactory(hook) { 46510 return function (delta) { 46511 var mergeCellsSetting = this.getSettings().mergeCells; 46512 if (mergeCellsSetting) { 46513 var currentSelectedRange = this.getSelectedRange(); 46514 this.mergeCells.modifyTransform(hook, currentSelectedRange, delta); 46515 46516 if (hook === 'modifyTransformEnd') { 46517 // sanitize "from" (core.js will sanitize to) 46518 var totalRows = this.countRows(); 46519 var totalCols = this.countCols(); 46520 if (currentSelectedRange.from.row < 0) { 46521 currentSelectedRange.from.row = 0; 46522 } else if (currentSelectedRange.from.row > 0 && currentSelectedRange.from.row >= totalRows) { 46523 currentSelectedRange.from.row = currentSelectedRange.from - 1; 46524 } 46525 46526 if (currentSelectedRange.from.col < 0) { 46527 currentSelectedRange.from.col = 0; 46528 } else if (currentSelectedRange.from.col > 0 && currentSelectedRange.from.col >= totalCols) { 46529 currentSelectedRange.from.col = totalCols - 1; 46530 } 46531 } 46532 } 46533 }; 46534}; 46535 46536/** 46537 * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the merged cell 46538 * @param coords 46539 */ 46540var beforeSetRangeEnd = function beforeSetRangeEnd(coords) { 46541 46542 this.lastDesiredCoords = null; // unset lastDesiredCoords when selection is changed with mouse 46543 var mergeCellsSetting = this.getSettings().mergeCells; 46544 if (mergeCellsSetting) { 46545 var selRange = this.getSelectedRange(); 46546 selRange.highlight = new _src.CellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference 46547 selRange.to = coords; 46548 46549 var rangeExpanded = false; 46550 do { 46551 rangeExpanded = false; 46552 46553 for (var i = 0, ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) { 46554 var cellInfo = this.mergeCells.mergedCellInfoCollection[i]; 46555 var mergedCellTopLeft = new _src.CellCoords(cellInfo.row, cellInfo.col); 46556 var mergedCellBottomRight = new _src.CellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1); 46557 46558 var mergedCellRange = new _src.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight); 46559 if (selRange.expandByRange(mergedCellRange)) { 46560 coords.row = selRange.to.row; 46561 coords.col = selRange.to.col; 46562 46563 rangeExpanded = true; 46564 } 46565 } 46566 } while (rangeExpanded); 46567 } 46568}; 46569 46570/** 46571 * Returns correct coordinates for merged start / end cells in selection for area borders 46572 * @param corners 46573 * @param className 46574 */ 46575var beforeDrawAreaBorders = function beforeDrawAreaBorders(corners, className) { 46576 if (className && className == 'area') { 46577 var mergeCellsSetting = this.getSettings().mergeCells; 46578 if (mergeCellsSetting) { 46579 var selRange = this.getSelectedRange(); 46580 var startRange = new _src.CellRange(selRange.from, selRange.from, selRange.from); 46581 var stopRange = new _src.CellRange(selRange.to, selRange.to, selRange.to); 46582 46583 for (var i = 0, ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) { 46584 var cellInfo = this.mergeCells.mergedCellInfoCollection[i]; 46585 var mergedCellTopLeft = new _src.CellCoords(cellInfo.row, cellInfo.col); 46586 var mergedCellBottomRight = new _src.CellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1); 46587 var mergedCellRange = new _src.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight); 46588 46589 if (startRange.expandByRange(mergedCellRange)) { 46590 corners[0] = startRange.from.row; 46591 corners[1] = startRange.from.col; 46592 } 46593 46594 if (stopRange.expandByRange(mergedCellRange)) { 46595 corners[2] = stopRange.from.row; 46596 corners[3] = stopRange.from.col; 46597 } 46598 } 46599 } 46600 } 46601}; 46602 46603var afterGetCellMeta = function afterGetCellMeta(row, col, cellProperties) { 46604 var mergeCellsSetting = this.getSettings().mergeCells; 46605 if (mergeCellsSetting) { 46606 var mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(row, col); 46607 if (mergeParent && (mergeParent.row != row || mergeParent.col != col)) { 46608 cellProperties.copyable = false; 46609 } 46610 } 46611}; 46612 46613var afterViewportRowCalculatorOverride = function afterViewportRowCalculatorOverride(calc) { 46614 var mergeCellsSetting = this.getSettings().mergeCells; 46615 if (mergeCellsSetting) { 46616 var colCount = this.countCols(); 46617 var mergeParent; 46618 for (var c = 0; c < colCount; c++) { 46619 mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.startRow, c); 46620 if (mergeParent) { 46621 if (mergeParent.row < calc.startRow) { 46622 calc.startRow = mergeParent.row; 46623 return afterViewportRowCalculatorOverride.call(this, calc); // recursively search upwards 46624 } 46625 } 46626 mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.endRow, c); 46627 if (mergeParent) { 46628 var mergeEnd = mergeParent.row + mergeParent.rowspan - 1; 46629 if (mergeEnd > calc.endRow) { 46630 calc.endRow = mergeEnd; 46631 return afterViewportRowCalculatorOverride.call(this, calc); // recursively search upwards 46632 } 46633 } 46634 } 46635 } 46636}; 46637 46638var afterViewportColumnCalculatorOverride = function afterViewportColumnCalculatorOverride(calc) { 46639 var mergeCellsSetting = this.getSettings().mergeCells; 46640 if (mergeCellsSetting) { 46641 var rowCount = this.countRows(); 46642 var mergeParent; 46643 for (var r = 0; r < rowCount; r++) { 46644 mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.startColumn); 46645 46646 if (mergeParent) { 46647 if (mergeParent.col < calc.startColumn) { 46648 calc.startColumn = mergeParent.col; 46649 return afterViewportColumnCalculatorOverride.call(this, calc); // recursively search upwards 46650 } 46651 } 46652 mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.endColumn); 46653 if (mergeParent) { 46654 var mergeEnd = mergeParent.col + mergeParent.colspan - 1; 46655 if (mergeEnd > calc.endColumn) { 46656 calc.endColumn = mergeEnd; 46657 return afterViewportColumnCalculatorOverride.call(this, calc); // recursively search upwards 46658 } 46659 } 46660 } 46661 } 46662}; 46663 46664var isMultipleSelection = function isMultipleSelection(isMultiple) { 46665 if (isMultiple && this.mergeCells) { 46666 var mergedCells = this.mergeCells.mergedCellInfoCollection, 46667 selectionRange = this.getSelectedRange(); 46668 46669 for (var group in mergedCells) { 46670 if (selectionRange.highlight.row == mergedCells[group].row && selectionRange.highlight.col == mergedCells[group].col && selectionRange.to.row == mergedCells[group].row + mergedCells[group].rowspan - 1 && selectionRange.to.col == mergedCells[group].col + mergedCells[group].colspan - 1) { 46671 return false; 46672 } 46673 } 46674 } 46675 return isMultiple; 46676}; 46677 46678function modifyAutofillRange(select, drag) { 46679 var mergeCellsSetting = this.getSettings().mergeCells; 46680 46681 if (!mergeCellsSetting || this.selection.isMultiple()) { 46682 return; 46683 } 46684 var info = this.mergeCells.mergedCellInfoCollection.getInfo(select[0], select[1]); 46685 46686 if (info) { 46687 select[0] = info.row; 46688 select[1] = info.col; 46689 select[2] = info.row + info.rowspan - 1; 46690 select[3] = info.col + info.colspan - 1; 46691 } 46692} 46693 46694function onAfterCreateCol(col, count) { 46695 if (this.mergeCells) { 46696 this.mergeCells.shiftCollection('right', col, count); 46697 } 46698} 46699 46700function onAfterRemoveCol(col, count) { 46701 if (this.mergeCells) { 46702 this.mergeCells.shiftCollection('left', col, count); 46703 } 46704} 46705 46706function onAfterCreateRow(row, count) { 46707 if (this.mergeCells) { 46708 this.mergeCells.shiftCollection('down', row, count); 46709 } 46710} 46711 46712function onAfterRemoveRow(row, count) { 46713 if (this.mergeCells) { 46714 this.mergeCells.shiftCollection('up', row, count); 46715 } 46716} 46717 46718var hook = _pluginHooks2.default.getSingleton(); 46719 46720hook.add('beforeInit', beforeInit); 46721hook.add('afterInit', afterInit); 46722hook.add('afterUpdateSettings', afterUpdateSettings); 46723hook.add('beforeKeyDown', onBeforeKeyDown); 46724hook.add('modifyTransformStart', modifyTransformFactory('modifyTransformStart')); 46725hook.add('modifyTransformEnd', modifyTransformFactory('modifyTransformEnd')); 46726hook.add('beforeSetRangeEnd', beforeSetRangeEnd); 46727hook.add('beforeDrawBorders', beforeDrawAreaBorders); 46728hook.add('afterIsMultipleSelection', isMultipleSelection); 46729hook.add('afterRenderer', afterRenderer); 46730hook.add('afterContextMenuDefaultOptions', addMergeActionsToContextMenu); 46731hook.add('afterGetCellMeta', afterGetCellMeta); 46732hook.add('afterViewportRowCalculatorOverride', afterViewportRowCalculatorOverride); 46733hook.add('afterViewportColumnCalculatorOverride', afterViewportColumnCalculatorOverride); 46734hook.add('modifyAutofillRange', modifyAutofillRange); 46735hook.add('afterCreateCol', onAfterCreateCol); 46736hook.add('afterRemoveCol', onAfterRemoveCol); 46737hook.add('afterCreateRow', onAfterCreateRow); 46738hook.add('afterRemoveRow', onAfterRemoveRow); 46739 46740exports.default = MergeCells; 46741 46742/***/ }), 46743/* 374 */ 46744/***/ (function(module, exports, __webpack_require__) { 46745 46746"use strict"; 46747 46748 46749exports.__esModule = true; 46750 46751var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 46752 46753var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; 46754 46755var _pluginHooks = __webpack_require__(11); 46756 46757var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 46758 46759var _element = __webpack_require__(0); 46760 46761var _browser = __webpack_require__(22); 46762 46763var _base = __webpack_require__(16); 46764 46765var _base2 = _interopRequireDefault(_base); 46766 46767var _eventManager = __webpack_require__(4); 46768 46769var _eventManager2 = _interopRequireDefault(_eventManager); 46770 46771var _plugins = __webpack_require__(9); 46772 46773var _src = __webpack_require__(14); 46774 46775function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 46776 46777function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 46778 46779function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 46780 46781function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 46782 46783/** 46784 * @private 46785 * @plugin MultipleSelectionHandles 46786 */ 46787var MultipleSelectionHandles = function (_BasePlugin) { 46788 _inherits(MultipleSelectionHandles, _BasePlugin); 46789 46790 /** 46791 * @param {Object} hotInstance 46792 */ 46793 function MultipleSelectionHandles(hotInstance) { 46794 _classCallCheck(this, MultipleSelectionHandles); 46795 46796 /** 46797 * @type {Array} 46798 */ 46799 var _this2 = _possibleConstructorReturn(this, (MultipleSelectionHandles.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles)).call(this, hotInstance)); 46800 46801 _this2.dragged = []; 46802 /** 46803 * Instance of EventManager. 46804 * 46805 * @type {EventManager} 46806 */ 46807 _this2.eventManager = null; 46808 /** 46809 * @type {null} 46810 */ 46811 _this2.lastSetCell = null; 46812 return _this2; 46813 } 46814 46815 /** 46816 * Check if the plugin is enabled in the handsontable settings. 46817 * 46818 * @returns {Boolean} 46819 */ 46820 46821 46822 _createClass(MultipleSelectionHandles, [{ 46823 key: 'isEnabled', 46824 value: function isEnabled() { 46825 return (0, _browser.isMobileBrowser)(); 46826 } 46827 46828 /** 46829 * Enable plugin for this Handsontable instance. 46830 */ 46831 46832 }, { 46833 key: 'enablePlugin', 46834 value: function enablePlugin() { 46835 if (this.enabled) { 46836 return; 46837 } 46838 if (!this.eventManager) { 46839 this.eventManager = new _eventManager2.default(this); 46840 } 46841 this.registerListeners(); 46842 _get(MultipleSelectionHandles.prototype.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles.prototype), 'enablePlugin', this).call(this); 46843 } 46844 46845 /** 46846 * Bind the touch events 46847 * @private 46848 */ 46849 46850 }, { 46851 key: 'registerListeners', 46852 value: function registerListeners() { 46853 var _this = this; 46854 46855 function removeFromDragged(query) { 46856 46857 if (_this.dragged.length === 1) { 46858 // clear array 46859 _this.dragged.splice(0, _this.dragged.length); 46860 46861 return true; 46862 } 46863 46864 var entryPosition = _this.dragged.indexOf(query); 46865 46866 if (entryPosition == -1) { 46867 return false; 46868 } else if (entryPosition === 0) { 46869 _this.dragged = _this.dragged.slice(0, 1); 46870 } else if (entryPosition == 1) { 46871 _this.dragged = _this.dragged.slice(-1); 46872 } 46873 } 46874 46875 this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function (event) { 46876 var selectedRange = void 0; 46877 46878 if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) { 46879 selectedRange = _this.hot.getSelectedRange(); 46880 46881 _this.dragged.push('topLeft'); 46882 46883 _this.touchStartRange = { 46884 width: selectedRange.getWidth(), 46885 height: selectedRange.getHeight(), 46886 direction: selectedRange.getDirection() 46887 }; 46888 46889 event.preventDefault(); 46890 return false; 46891 } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) { 46892 selectedRange = _this.hot.getSelectedRange(); 46893 46894 _this.dragged.push('bottomRight'); 46895 46896 _this.touchStartRange = { 46897 width: selectedRange.getWidth(), 46898 height: selectedRange.getHeight(), 46899 direction: selectedRange.getDirection() 46900 }; 46901 46902 event.preventDefault(); 46903 return false; 46904 } 46905 }); 46906 46907 this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function (event) { 46908 if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) { 46909 removeFromDragged.call(_this, 'topLeft'); 46910 46911 _this.touchStartRange = void 0; 46912 46913 event.preventDefault(); 46914 return false; 46915 } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) { 46916 removeFromDragged.call(_this, 'bottomRight'); 46917 46918 _this.touchStartRange = void 0; 46919 46920 event.preventDefault(); 46921 return false; 46922 } 46923 }); 46924 46925 this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function (event) { 46926 var scrollTop = (0, _element.getWindowScrollTop)(), 46927 scrollLeft = (0, _element.getWindowScrollLeft)(), 46928 endTarget = void 0, 46929 targetCoords = void 0, 46930 selectedRange = void 0, 46931 rangeWidth = void 0, 46932 rangeHeight = void 0, 46933 rangeDirection = void 0, 46934 newRangeCoords = void 0; 46935 46936 if (_this.dragged.length === 0) { 46937 return; 46938 } 46939 46940 endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop); 46941 46942 if (!endTarget || endTarget === _this.lastSetCell) { 46943 return; 46944 } 46945 46946 if (endTarget.nodeName == 'TD' || endTarget.nodeName == 'TH') { 46947 targetCoords = _this.hot.getCoords(endTarget); 46948 46949 if (targetCoords.col == -1) { 46950 targetCoords.col = 0; 46951 } 46952 46953 selectedRange = _this.hot.getSelectedRange(); 46954 rangeWidth = selectedRange.getWidth(); 46955 rangeHeight = selectedRange.getHeight(); 46956 rangeDirection = selectedRange.getDirection(); 46957 46958 if (rangeWidth == 1 && rangeHeight == 1) { 46959 _this.hot.selection.setRangeEnd(targetCoords); 46960 } 46961 46962 newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]); 46963 46964 if (newRangeCoords.start !== null) { 46965 _this.hot.selection.setRangeStart(newRangeCoords.start); 46966 } 46967 46968 _this.hot.selection.setRangeEnd(newRangeCoords.end); 46969 46970 _this.lastSetCell = endTarget; 46971 } 46972 46973 event.preventDefault(); 46974 }); 46975 } 46976 }, { 46977 key: 'getCurrentRangeCoords', 46978 value: function getCurrentRangeCoords(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) { 46979 var topLeftCorner = selectedRange.getTopLeftCorner(), 46980 bottomRightCorner = selectedRange.getBottomRightCorner(), 46981 bottomLeftCorner = selectedRange.getBottomLeftCorner(), 46982 topRightCorner = selectedRange.getTopRightCorner(); 46983 46984 var newCoords = { 46985 start: null, 46986 end: null 46987 }; 46988 46989 switch (touchStartDirection) { 46990 case 'NE-SW': 46991 switch (currentDirection) { 46992 case 'NE-SW': 46993 case 'NW-SE': 46994 if (draggedHandle == 'topLeft') { 46995 newCoords = { 46996 start: new _src.CellCoords(currentTouch.row, selectedRange.highlight.col), 46997 end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col) 46998 }; 46999 } else { 47000 newCoords = { 47001 start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col), 47002 end: new _src.CellCoords(currentTouch.row, topLeftCorner.col) 47003 }; 47004 } 47005 break; 47006 case 'SE-NW': 47007 if (draggedHandle == 'bottomRight') { 47008 newCoords = { 47009 start: new _src.CellCoords(bottomRightCorner.row, currentTouch.col), 47010 end: new _src.CellCoords(currentTouch.row, topLeftCorner.col) 47011 }; 47012 } 47013 break; 47014 default: 47015 break; 47016 } 47017 break; 47018 case 'NW-SE': 47019 switch (currentDirection) { 47020 case 'NE-SW': 47021 if (draggedHandle == 'topLeft') { 47022 newCoords = { 47023 start: currentTouch, 47024 end: bottomLeftCorner 47025 }; 47026 } else { 47027 newCoords.end = currentTouch; 47028 } 47029 break; 47030 case 'NW-SE': 47031 if (draggedHandle == 'topLeft') { 47032 newCoords = { 47033 start: currentTouch, 47034 end: bottomRightCorner 47035 }; 47036 } else { 47037 newCoords.end = currentTouch; 47038 } 47039 break; 47040 case 'SE-NW': 47041 if (draggedHandle == 'topLeft') { 47042 newCoords = { 47043 start: currentTouch, 47044 end: topLeftCorner 47045 }; 47046 } else { 47047 newCoords.end = currentTouch; 47048 } 47049 break; 47050 case 'SW-NE': 47051 if (draggedHandle == 'topLeft') { 47052 newCoords = { 47053 start: currentTouch, 47054 end: topRightCorner 47055 }; 47056 } else { 47057 newCoords.end = currentTouch; 47058 } 47059 break; 47060 default: 47061 break; 47062 } 47063 break; 47064 case 'SW-NE': 47065 switch (currentDirection) { 47066 case 'NW-SE': 47067 if (draggedHandle == 'bottomRight') { 47068 newCoords = { 47069 start: new _src.CellCoords(currentTouch.row, topLeftCorner.col), 47070 end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col) 47071 }; 47072 } else { 47073 newCoords = { 47074 start: new _src.CellCoords(topLeftCorner.row, currentTouch.col), 47075 end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col) 47076 }; 47077 } 47078 break; 47079 // case 'NE-SW': 47080 // 47081 // break; 47082 case 'SW-NE': 47083 if (draggedHandle == 'topLeft') { 47084 newCoords = { 47085 start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col), 47086 end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col) 47087 }; 47088 } else { 47089 newCoords = { 47090 start: new _src.CellCoords(currentTouch.row, topLeftCorner.col), 47091 end: new _src.CellCoords(topLeftCorner.row, currentTouch.col) 47092 }; 47093 } 47094 break; 47095 case 'SE-NW': 47096 if (draggedHandle == 'bottomRight') { 47097 newCoords = { 47098 start: new _src.CellCoords(currentTouch.row, topRightCorner.col), 47099 end: new _src.CellCoords(topLeftCorner.row, currentTouch.col) 47100 }; 47101 } else if (draggedHandle == 'topLeft') { 47102 newCoords = { 47103 start: bottomLeftCorner, 47104 end: currentTouch 47105 }; 47106 } 47107 break; 47108 default: 47109 break; 47110 } 47111 break; 47112 case 'SE-NW': 47113 switch (currentDirection) { 47114 case 'NW-SE': 47115 case 'NE-SW': 47116 case 'SW-NE': 47117 if (draggedHandle == 'topLeft') { 47118 newCoords.end = currentTouch; 47119 } 47120 break; 47121 case 'SE-NW': 47122 if (draggedHandle == 'topLeft') { 47123 newCoords.end = currentTouch; 47124 } else { 47125 newCoords = { 47126 start: currentTouch, 47127 end: topLeftCorner 47128 }; 47129 } 47130 break; 47131 default: 47132 break; 47133 } 47134 break; 47135 default: 47136 break; 47137 } 47138 47139 return newCoords; 47140 } 47141 47142 /** 47143 * Check if user is currently dragging the handle. 47144 * 47145 * @returns {boolean} Dragging state 47146 */ 47147 47148 }, { 47149 key: 'isDragged', 47150 value: function isDragged() { 47151 return this.dragged.length > 0; 47152 } 47153 }]); 47154 47155 return MultipleSelectionHandles; 47156}(_base2.default); 47157 47158(0, _plugins.registerPlugin)('multipleSelectionHandles', MultipleSelectionHandles); 47159 47160exports.default = MultipleSelectionHandles; 47161 47162/***/ }), 47163/* 375 */ 47164/***/ (function(module, exports, __webpack_require__) { 47165 47166"use strict"; 47167 47168 47169exports.__esModule = true; 47170 47171var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 47172 47173var _pluginHooks = __webpack_require__(11); 47174 47175var _pluginHooks2 = _interopRequireDefault(_pluginHooks); 47176 47177var _element = __webpack_require__(0); 47178 47179var _renderers = __webpack_require__(6); 47180 47181function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 47182 47183/** 47184 * @private 47185 * @plugin Search 47186 */ 47187function Search(instance) { 47188 this.query = function (queryStr, callback, queryMethod) { 47189 var rowCount = instance.countRows(); 47190 var colCount = instance.countCols(); 47191 var queryResult = []; 47192 47193 if (!callback) { 47194 callback = Search.global.getDefaultCallback(); 47195 } 47196 47197 if (!queryMethod) { 47198 queryMethod = Search.global.getDefaultQueryMethod(); 47199 } 47200 47201 for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) { 47202 for (var colIndex = 0; colIndex < colCount; colIndex++) { 47203 var cellData = instance.getDataAtCell(rowIndex, colIndex); 47204 var cellProperties = instance.getCellMeta(rowIndex, colIndex); 47205 var cellCallback = cellProperties.search.callback || callback; 47206 var cellQueryMethod = cellProperties.search.queryMethod || queryMethod; 47207 var testResult = cellQueryMethod(queryStr, cellData); 47208 47209 if (testResult) { 47210 var singleResult = { 47211 row: rowIndex, 47212 col: colIndex, 47213 data: cellData 47214 }; 47215 47216 queryResult.push(singleResult); 47217 } 47218 47219 if (cellCallback) { 47220 cellCallback(instance, rowIndex, colIndex, cellData, testResult); 47221 } 47222 } 47223 } 47224 47225 return queryResult; 47226 }; 47227}; 47228 47229Search.DEFAULT_CALLBACK = function (instance, row, col, data, testResult) { 47230 instance.getCellMeta(row, col).isSearchResult = testResult; 47231}; 47232 47233Search.DEFAULT_QUERY_METHOD = function (query, value) { 47234 if (typeof query == 'undefined' || query == null || !query.toLowerCase || query.length === 0) { 47235 return false; 47236 } 47237 if (typeof value == 'undefined' || value == null) { 47238 return false; 47239 } 47240 47241 return value.toString().toLowerCase().indexOf(query.toLowerCase()) != -1; 47242}; 47243 47244Search.DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult'; 47245 47246Search.global = function () { 47247 47248 var defaultCallback = Search.DEFAULT_CALLBACK; 47249 var defaultQueryMethod = Search.DEFAULT_QUERY_METHOD; 47250 var defaultSearchResultClass = Search.DEFAULT_SEARCH_RESULT_CLASS; 47251 47252 return { 47253 getDefaultCallback: function getDefaultCallback() { 47254 return defaultCallback; 47255 }, 47256 setDefaultCallback: function setDefaultCallback(newDefaultCallback) { 47257 defaultCallback = newDefaultCallback; 47258 }, 47259 getDefaultQueryMethod: function getDefaultQueryMethod() { 47260 return defaultQueryMethod; 47261 }, 47262 setDefaultQueryMethod: function setDefaultQueryMethod(newDefaultQueryMethod) { 47263 defaultQueryMethod = newDefaultQueryMethod; 47264 }, 47265 getDefaultSearchResultClass: function getDefaultSearchResultClass() { 47266 return defaultSearchResultClass; 47267 }, 47268 setDefaultSearchResultClass: function setDefaultSearchResultClass(newSearchResultClass) { 47269 defaultSearchResultClass = newSearchResultClass; 47270 } 47271 }; 47272}(); 47273 47274function SearchCellDecorator(instance, TD, row, col, prop, value, cellProperties) { 47275 var searchResultClass = cellProperties.search !== null && _typeof(cellProperties.search) == 'object' && cellProperties.search.searchResultClass || Search.global.getDefaultSearchResultClass(); 47276 47277 if (cellProperties.isSearchResult) { 47278 (0, _element.addClass)(TD, searchResultClass); 47279 } else { 47280 (0, _element.removeClass)(TD, searchResultClass); 47281 } 47282}; 47283 47284var originalBaseRenderer = (0, _renderers.getRenderer)('base'); 47285 47286(0, _renderers.registerRenderer)('base', function (instance, TD, row, col, prop, value, cellProperties) { 47287 originalBaseRenderer.apply(this, arguments); 47288 SearchCellDecorator.apply(this, arguments); 47289}); 47290 47291function init() { 47292 var instance = this; 47293 47294 var pluginEnabled = !!instance.getSettings().search; 47295 47296 if (pluginEnabled) { 47297 instance.search = new Search(instance); 47298 } else { 47299 delete instance.search; 47300 } 47301} 47302 47303_pluginHooks2.default.getSingleton().add('afterInit', init); 47304_pluginHooks2.default.getSingleton().add('afterUpdateSettings', init); 47305 47306exports.default = Search; 47307 47308/***/ }), 47309/* 376 */ 47310/***/ (function(module, exports, __webpack_require__) { 47311 47312"use strict"; 47313 47314 47315exports.__esModule = true; 47316 47317var _element = __webpack_require__(0); 47318 47319function cellDecorator(instance, TD, row, col, prop, value, cellProperties) { 47320 if (cellProperties.className) { 47321 if (TD.className) { 47322 TD.className = TD.className + ' ' + cellProperties.className; 47323 } else { 47324 TD.className = cellProperties.className; 47325 } 47326 } 47327 47328 if (cellProperties.readOnly) { 47329 (0, _element.addClass)(TD, cellProperties.readOnlyCellClassName); 47330 } 47331 47332 if (cellProperties.valid === false && cellProperties.invalidCellClassName) { 47333 (0, _element.addClass)(TD, cellProperties.invalidCellClassName); 47334 } else { 47335 (0, _element.removeClass)(TD, cellProperties.invalidCellClassName); 47336 } 47337 47338 if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) { 47339 (0, _element.addClass)(TD, cellProperties.noWordWrapClassName); 47340 } 47341 47342 if (!value && cellProperties.placeholder) { 47343 (0, _element.addClass)(TD, cellProperties.placeholderCellClassName); 47344 } 47345} /** 47346 * Adds appropriate CSS class to table cell, based on cellProperties 47347 */ 47348exports.default = cellDecorator; 47349 47350/***/ }), 47351/* 377 */ 47352/***/ (function(module, exports, __webpack_require__) { 47353 47354"use strict"; 47355 47356 47357exports.__esModule = true; 47358 47359var _element = __webpack_require__(0); 47360 47361var _eventManager = __webpack_require__(4); 47362 47363var _eventManager2 = _interopRequireDefault(_eventManager); 47364 47365var _src = __webpack_require__(14); 47366 47367var _index = __webpack_require__(6); 47368 47369function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 47370 47371var clonableWRAPPER = document.createElement('DIV'); 47372clonableWRAPPER.className = 'htAutocompleteWrapper'; 47373 47374var clonableARROW = document.createElement('DIV'); 47375clonableARROW.className = 'htAutocompleteArrow'; 47376// workaround for https://github.com/handsontable/handsontable/issues/1946 47377// this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips 47378clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660))); 47379 47380var wrapTdContentWithWrapper = function wrapTdContentWithWrapper(TD, WRAPPER) { 47381 WRAPPER.innerHTML = TD.innerHTML; 47382 (0, _element.empty)(TD); 47383 TD.appendChild(WRAPPER); 47384}; 47385 47386/** 47387 * Autocomplete renderer 47388 * 47389 * @private 47390 * @renderer AutocompleteRenderer 47391 * @param {Object} instance Handsontable instance 47392 * @param {Element} TD Table cell where to render 47393 * @param {Number} row 47394 * @param {Number} col 47395 * @param {String|Number} prop Row object property name 47396 * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!) 47397 * @param {Object} cellProperties Cell properites (shared by cell renderer and editor) 47398 */ 47399function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) { 47400 var WRAPPER = clonableWRAPPER.cloneNode(true); // this is faster than createElement 47401 var ARROW = clonableARROW.cloneNode(true); // this is faster than createElement 47402 47403 if (cellProperties.allowHtml) { 47404 (0, _index.getRenderer)('html').apply(this, arguments); 47405 } else { 47406 (0, _index.getRenderer)('text').apply(this, arguments); 47407 } 47408 47409 TD.appendChild(ARROW); 47410 (0, _element.addClass)(TD, 'htAutocomplete'); 47411 47412 if (!TD.firstChild) { 47413 // http://jsperf.com/empty-node-if-needed 47414 // otherwise empty fields appear borderless in demo/renderers.html (IE) 47415 TD.appendChild(document.createTextNode(String.fromCharCode(160))); // workaround for https://github.com/handsontable/handsontable/issues/1946 47416 // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips 47417 } 47418 47419 if (!instance.acArrowListener) { 47420 var eventManager = new _eventManager2.default(instance); 47421 47422 // not very elegant but easy and fast 47423 instance.acArrowListener = function (event) { 47424 if ((0, _element.hasClass)(event.target, 'htAutocompleteArrow')) { 47425 instance.view.wt.getSetting('onCellDblClick', null, new _src.CellCoords(row, col), TD); 47426 } 47427 }; 47428 47429 eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener); 47430 47431 // We need to unbind the listener after the table has been destroyed 47432 instance.addHookOnce('afterDestroy', function () { 47433 eventManager.destroy(); 47434 }); 47435 } 47436} 47437 47438exports.default = autocompleteRenderer; 47439 47440/***/ }), 47441/* 378 */ 47442/***/ (function(module, exports, __webpack_require__) { 47443 47444"use strict"; 47445 47446 47447exports.__esModule = true; 47448 47449var _element = __webpack_require__(0); 47450 47451var _string = __webpack_require__(28); 47452 47453var _eventManager = __webpack_require__(4); 47454 47455var _eventManager2 = _interopRequireDefault(_eventManager); 47456 47457var _unicode = __webpack_require__(15); 47458 47459var _function = __webpack_require__(35); 47460 47461var _event = __webpack_require__(7); 47462 47463var _index = __webpack_require__(6); 47464 47465function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 47466 47467var isListeningKeyDownEvent = new WeakMap(); 47468var isCheckboxListenerAdded = new WeakMap(); 47469var BAD_VALUE_CLASS = 'htBadValue'; 47470 47471/** 47472 * Checkbox renderer 47473 * 47474 * @private 47475 * @param {Object} instance Handsontable instance 47476 * @param {Element} TD Table cell where to render 47477 * @param {Number} row 47478 * @param {Number} col 47479 * @param {String|Number} prop Row object property name 47480 * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!) 47481 * @param {Object} cellProperties Cell properties (shared by cell renderer and editor) 47482 */ 47483function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) { 47484 (0, _index.getRenderer)('base').apply(this, arguments); 47485 47486 var eventManager = registerEvents(instance); 47487 var input = createInput(); 47488 var labelOptions = cellProperties.label; 47489 var badValue = false; 47490 47491 if (typeof cellProperties.checkedTemplate === 'undefined') { 47492 cellProperties.checkedTemplate = true; 47493 } 47494 if (typeof cellProperties.uncheckedTemplate === 'undefined') { 47495 cellProperties.uncheckedTemplate = false; 47496 } 47497 47498 (0, _element.empty)(TD); // TODO identify under what circumstances this line can be removed 47499 47500 if (value === cellProperties.checkedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.checkedTemplate)) { 47501 input.checked = true; 47502 } else if (value === cellProperties.uncheckedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.uncheckedTemplate)) { 47503 input.checked = false; 47504 } else if (value === null) { 47505 // default value 47506 (0, _element.addClass)(input, 'noValue'); 47507 } else { 47508 input.style.display = 'none'; 47509 (0, _element.addClass)(input, BAD_VALUE_CLASS); 47510 badValue = true; 47511 } 47512 47513 input.setAttribute('data-row', row); 47514 input.setAttribute('data-col', col); 47515 47516 if (!badValue && labelOptions) { 47517 var labelText = ''; 47518 47519 if (labelOptions.value) { 47520 labelText = typeof labelOptions.value === 'function' ? labelOptions.value.call(this, row, col, prop, value) : labelOptions.value; 47521 } else if (labelOptions.property) { 47522 labelText = instance.getDataAtRowProp(row, labelOptions.property); 47523 } 47524 var label = createLabel(labelText); 47525 47526 if (labelOptions.position === 'before') { 47527 label.appendChild(input); 47528 } else { 47529 label.insertBefore(input, label.firstChild); 47530 } 47531 input = label; 47532 } 47533 47534 TD.appendChild(input); 47535 47536 if (badValue) { 47537 TD.appendChild(document.createTextNode('#bad-value#')); 47538 } 47539 47540 if (!isListeningKeyDownEvent.has(instance)) { 47541 isListeningKeyDownEvent.set(instance, true); 47542 instance.addHook('beforeKeyDown', onBeforeKeyDown); 47543 } 47544 47545 /** 47546 * On before key down DOM listener. 47547 * 47548 * @private 47549 * @param {Event} event 47550 */ 47551 function onBeforeKeyDown(event) { 47552 var toggleKeys = 'SPACE|ENTER'; 47553 var switchOffKeys = 'DELETE|BACKSPACE'; 47554 var isKeyCode = (0, _function.partial)(_unicode.isKey, event.keyCode); 47555 47556 if (isKeyCode(toggleKeys + '|' + switchOffKeys) && !(0, _event.isImmediatePropagationStopped)(event)) { 47557 eachSelectedCheckboxCell(function () { 47558 (0, _event.stopImmediatePropagation)(event); 47559 event.preventDefault(); 47560 }); 47561 } 47562 if (isKeyCode(toggleKeys)) { 47563 changeSelectedCheckboxesState(); 47564 } 47565 if (isKeyCode(switchOffKeys)) { 47566 changeSelectedCheckboxesState(true); 47567 } 47568 } 47569 47570 /** 47571 * Change checkbox checked property 47572 * 47573 * @private 47574 * @param {Boolean} [uncheckCheckbox=false] 47575 */ 47576 function changeSelectedCheckboxesState() { 47577 var uncheckCheckbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 47578 47579 var selRange = instance.getSelectedRange(); 47580 47581 if (!selRange) { 47582 return; 47583 } 47584 47585 var topLeft = selRange.getTopLeftCorner(); 47586 var bottomRight = selRange.getBottomRightCorner(); 47587 var changes = []; 47588 47589 for (var _row = topLeft.row; _row <= bottomRight.row; _row += 1) { 47590 for (var _col = topLeft.col; _col <= bottomRight.col; _col += 1) { 47591 var _cellProperties = instance.getCellMeta(_row, _col); 47592 47593 if (_cellProperties.type !== 'checkbox') { 47594 return; 47595 } 47596 47597 /* eslint-disable no-continue */ 47598 if (_cellProperties.readOnly === true) { 47599 continue; 47600 } 47601 47602 if (typeof _cellProperties.checkedTemplate === 'undefined') { 47603 _cellProperties.checkedTemplate = true; 47604 } 47605 if (typeof _cellProperties.uncheckedTemplate === 'undefined') { 47606 _cellProperties.uncheckedTemplate = false; 47607 } 47608 47609 var dataAtCell = instance.getDataAtCell(_row, _col); 47610 47611 if (uncheckCheckbox === false) { 47612 if (dataAtCell === _cellProperties.checkedTemplate) { 47613 changes.push([_row, _col, _cellProperties.uncheckedTemplate]); 47614 } else if ([_cellProperties.uncheckedTemplate, null, void 0].indexOf(dataAtCell) !== -1) { 47615 changes.push([_row, _col, _cellProperties.checkedTemplate]); 47616 } 47617 } else { 47618 changes.push([_row, _col, _cellProperties.uncheckedTemplate]); 47619 } 47620 } 47621 } 47622 47623 if (changes.length > 0) { 47624 instance.setDataAtCell(changes); 47625 } 47626 } 47627 47628 /** 47629 * Call callback for each found selected cell with checkbox type. 47630 * 47631 * @private 47632 * @param {Function} callback 47633 */ 47634 function eachSelectedCheckboxCell(callback) { 47635 var selRange = instance.getSelectedRange(); 47636 47637 if (!selRange) { 47638 return; 47639 } 47640 var topLeft = selRange.getTopLeftCorner(); 47641 var bottomRight = selRange.getBottomRightCorner(); 47642 47643 for (var _row2 = topLeft.row; _row2 <= bottomRight.row; _row2++) { 47644 for (var _col2 = topLeft.col; _col2 <= bottomRight.col; _col2++) { 47645 var _cellProperties2 = instance.getCellMeta(_row2, _col2); 47646 47647 if (_cellProperties2.type !== 'checkbox') { 47648 return; 47649 } 47650 47651 var cell = instance.getCell(_row2, _col2); 47652 47653 if (cell == null) { 47654 47655 callback(_row2, _col2, _cellProperties2); 47656 } else { 47657 var checkboxes = cell.querySelectorAll('input[type=checkbox]'); 47658 47659 if (checkboxes.length > 0 && !_cellProperties2.readOnly) { 47660 callback(checkboxes); 47661 } 47662 } 47663 } 47664 } 47665 } 47666} 47667 47668/** 47669 * Register checkbox listeners. 47670 * 47671 * @param {Handsontable} instance Handsontable instance. 47672 * @returns {EventManager} 47673 */ 47674function registerEvents(instance) { 47675 var eventManager = isCheckboxListenerAdded.get(instance); 47676 47677 if (!eventManager) { 47678 eventManager = new _eventManager2.default(instance); 47679 eventManager.addEventListener(instance.rootElement, 'click', function (event) { 47680 return onClick(event, instance); 47681 }); 47682 eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) { 47683 return onMouseUp(event, instance); 47684 }); 47685 eventManager.addEventListener(instance.rootElement, 'change', function (event) { 47686 return onChange(event, instance); 47687 }); 47688 47689 isCheckboxListenerAdded.set(instance, eventManager); 47690 } 47691 47692 return eventManager; 47693} 47694 47695/** 47696 * Create input element. 47697 * 47698 * @returns {Node} 47699 */ 47700function createInput() { 47701 var input = document.createElement('input'); 47702 47703 input.className = 'htCheckboxRendererInput'; 47704 input.type = 'checkbox'; 47705 input.setAttribute('autocomplete', 'off'); 47706 input.setAttribute('tabindex', '-1'); 47707 47708 return input.cloneNode(false); 47709} 47710 47711/** 47712 * Create label element. 47713 * 47714 * @returns {Node} 47715 */ 47716function createLabel(text) { 47717 var label = document.createElement('label'); 47718 47719 label.className = 'htCheckboxRendererLabel'; 47720 label.appendChild(document.createTextNode(text)); 47721 47722 return label.cloneNode(true); 47723} 47724 47725/** 47726 * `mouseup` callback. 47727 * 47728 * @private 47729 * @param {Event} event `mouseup` event. 47730 * @param {Object} instance Handsontable instance. 47731 */ 47732function onMouseUp(event, instance) { 47733 if (!isCheckboxInput(event.target)) { 47734 return; 47735 } 47736 setTimeout(instance.listen, 10); 47737} 47738 47739/** 47740 * `click` callback. 47741 * 47742 * @private 47743 * @param {Event} event `click` event. 47744 * @param {Object} instance Handsontable instance. 47745 */ 47746function onClick(event, instance) { 47747 if (!isCheckboxInput(event.target)) { 47748 return false; 47749 } 47750 47751 var row = parseInt(event.target.getAttribute('data-row'), 10); 47752 var col = parseInt(event.target.getAttribute('data-col'), 10); 47753 var cellProperties = instance.getCellMeta(row, col); 47754 47755 if (cellProperties.readOnly) { 47756 event.preventDefault(); 47757 } 47758} 47759 47760/** 47761 * `change` callback. 47762 * 47763 * @param {Event} event `change` event. 47764 * @param {Object} instance Handsontable instance. 47765 * @param {Object} cellProperties Reference to cell properties. 47766 * @returns {Boolean} 47767 */ 47768function onChange(event, instance) { 47769 if (!isCheckboxInput(event.target)) { 47770 return false; 47771 } 47772 47773 var row = parseInt(event.target.getAttribute('data-row'), 10); 47774 var col = parseInt(event.target.getAttribute('data-col'), 10); 47775 var cellProperties = instance.getCellMeta(row, col); 47776 47777 if (!cellProperties.readOnly) { 47778 var newCheckboxValue = null; 47779 47780 if (event.target.checked) { 47781 newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? true : cellProperties.checkedTemplate; 47782 } else { 47783 newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? false : cellProperties.uncheckedTemplate; 47784 } 47785 47786 instance.setDataAtCell(row, col, newCheckboxValue); 47787 } 47788} 47789 47790/** 47791 * Check if the provided element is the checkbox input. 47792 * 47793 * @private 47794 * @param {HTMLElement} element The element in question. 47795 * @returns {Boolean} 47796 */ 47797function isCheckboxInput(element) { 47798 return element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox'; 47799} 47800 47801exports.default = checkboxRenderer; 47802 47803/***/ }), 47804/* 379 */ 47805/***/ (function(module, exports, __webpack_require__) { 47806 47807"use strict"; 47808 47809 47810exports.__esModule = true; 47811 47812var _element = __webpack_require__(0); 47813 47814var _index = __webpack_require__(6); 47815 47816/** 47817 * @private 47818 * @renderer HtmlRenderer 47819 * @param instance 47820 * @param TD 47821 * @param row 47822 * @param col 47823 * @param prop 47824 * @param value 47825 * @param cellProperties 47826 */ 47827function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) { 47828 (0, _index.getRenderer)('base').apply(this, arguments); 47829 47830 if (value === null || value === void 0) { 47831 value = ''; 47832 } 47833 47834 (0, _element.fastInnerHTML)(TD, value); 47835} 47836 47837exports.default = htmlRenderer; 47838 47839/***/ }), 47840/* 380 */ 47841/***/ (function(module, exports, __webpack_require__) { 47842 47843"use strict"; 47844 47845 47846exports.__esModule = true; 47847 47848var _numbro = __webpack_require__(52); 47849 47850var _numbro2 = _interopRequireDefault(_numbro); 47851 47852var _index = __webpack_require__(6); 47853 47854var _number = __webpack_require__(5); 47855 47856function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 47857 47858/** 47859 * Numeric cell renderer 47860 * 47861 * @private 47862 * @renderer NumericRenderer 47863 * @dependencies numbro 47864 * @param {Object} instance Handsontable instance 47865 * @param {Element} TD Table cell where to render 47866 * @param {Number} row 47867 * @param {Number} col 47868 * @param {String|Number} prop Row object property name 47869 * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!) 47870 * @param {Object} cellProperties Cell properties (shared by cell renderer and editor) 47871 */ 47872function numericRenderer(instance, TD, row, col, prop, value, cellProperties) { 47873 if ((0, _number.isNumeric)(value)) { 47874 if (typeof cellProperties.language !== 'undefined') { 47875 _numbro2.default.culture(cellProperties.language); 47876 } 47877 47878 value = (0, _numbro2.default)(value).format(cellProperties.format || '0'); 47879 47880 var className = cellProperties.className || ''; 47881 47882 var classArr = className.length ? className.split(' ') : []; 47883 47884 if (classArr.indexOf('htLeft') < 0 && classArr.indexOf('htCenter') < 0 && classArr.indexOf('htRight') < 0 && classArr.indexOf('htJustify') < 0) { 47885 classArr.push('htRight'); 47886 } 47887 47888 if (classArr.indexOf('htNumeric') < 0) { 47889 classArr.push('htNumeric'); 47890 } 47891 47892 cellProperties.className = classArr.join(' '); 47893 } 47894 47895 (0, _index.getRenderer)('text')(instance, TD, row, col, prop, value, cellProperties); 47896} 47897 47898exports.default = numericRenderer; 47899 47900/***/ }), 47901/* 381 */ 47902/***/ (function(module, exports, __webpack_require__) { 47903 47904"use strict"; 47905 47906 47907exports.__esModule = true; 47908 47909var _element = __webpack_require__(0); 47910 47911var _index = __webpack_require__(6); 47912 47913var _number = __webpack_require__(5); 47914 47915/** 47916 * @private 47917 * @renderer PasswordRenderer 47918 * @param instance 47919 * @param TD 47920 * @param row 47921 * @param col 47922 * @param prop 47923 * @param value 47924 * @param cellProperties 47925 */ 47926function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) { 47927 (0, _index.getRenderer)('text').apply(this, arguments); 47928 47929 value = TD.innerHTML; 47930 47931 var hashLength = cellProperties.hashLength || value.length; 47932 var hashSymbol = cellProperties.hashSymbol || '*'; 47933 47934 var hash = ''; 47935 47936 (0, _number.rangeEach)(hashLength - 1, function () { 47937 hash += hashSymbol; 47938 }); 47939 (0, _element.fastInnerHTML)(TD, hash); 47940} 47941 47942exports.default = passwordRenderer; 47943 47944/***/ }), 47945/* 382 */ 47946/***/ (function(module, exports, __webpack_require__) { 47947 47948"use strict"; 47949 47950 47951exports.__esModule = true; 47952 47953var _element = __webpack_require__(0); 47954 47955var _mixed = __webpack_require__(23); 47956 47957var _index = __webpack_require__(6); 47958 47959/** 47960 * Default text renderer 47961 * 47962 * @private 47963 * @renderer TextRenderer 47964 * @param {Object} instance Handsontable instance 47965 * @param {Element} TD Table cell where to render 47966 * @param {Number} row 47967 * @param {Number} col 47968 * @param {String|Number} prop Row object property name 47969 * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!) 47970 * @param {Object} cellProperties Cell properties (shared by cell renderer and editor) 47971 */ 47972function textRenderer(instance, TD, row, col, prop, value, cellProperties) { 47973 (0, _index.getRenderer)('base').apply(this, arguments); 47974 47975 if (!value && cellProperties.placeholder) { 47976 value = cellProperties.placeholder; 47977 } 47978 47979 var escaped = (0, _mixed.stringify)(value); 47980 47981 if (!instance.getSettings().trimWhitespace) { 47982 escaped = escaped.replace(/ /g, String.fromCharCode(160)); 47983 } 47984 47985 if (cellProperties.rendererTemplate) { 47986 (0, _element.empty)(TD); 47987 var TEMPLATE = document.createElement('TEMPLATE'); 47988 TEMPLATE.setAttribute('bind', '{{}}'); 47989 TEMPLATE.innerHTML = cellProperties.rendererTemplate; 47990 HTMLTemplateElement.decorate(TEMPLATE); 47991 TEMPLATE.model = instance.getSourceDataAtRow(row); 47992 TD.appendChild(TEMPLATE); 47993 } else { 47994 // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips 47995 (0, _element.fastInnerText)(TD, escaped); 47996 } 47997} 47998 47999exports.default = textRenderer; 48000 48001/***/ }), 48002/* 383 */ 48003/***/ (function(module, exports, __webpack_require__) { 48004 48005"use strict"; 48006 48007 48008exports.__esModule = true; 48009 48010var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); 48011 48012var _element = __webpack_require__(0); 48013 48014var _browser = __webpack_require__(22); 48015 48016var _eventManager = __webpack_require__(4); 48017 48018var _eventManager2 = _interopRequireDefault(_eventManager); 48019 48020var _event = __webpack_require__(7); 48021 48022var _src = __webpack_require__(14); 48023 48024var _src2 = _interopRequireDefault(_src); 48025 48026function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 48027 48028/** 48029 * Handsontable TableView constructor 48030 * @param {Object} instance 48031 */ 48032function TableView(instance) { 48033 var _this = this; 48034 48035 var that = this; 48036 48037 this.eventManager = new _eventManager2.default(instance); 48038 this.instance = instance; 48039 this.settings = instance.getSettings(); 48040 this.selectionMouseDown = false; 48041 48042 var originalStyle = instance.rootElement.getAttribute('style'); 48043 48044 if (originalStyle) { 48045 instance.rootElement.setAttribute('data-originalstyle', originalStyle); // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions 48046 } 48047 48048 (0, _element.addClass)(instance.rootElement, 'handsontable'); 48049 48050 var table = document.createElement('TABLE'); 48051 (0, _element.addClass)(table, 'htCore'); 48052 48053 if (instance.getSettings().tableClassName) { 48054 (0, _element.addClass)(table, instance.getSettings().tableClassName); 48055 } 48056 this.THEAD = document.createElement('THEAD'); 48057 table.appendChild(this.THEAD); 48058 this.TBODY = document.createElement('TBODY'); 48059 table.appendChild(this.TBODY); 48060 48061 instance.table = table; 48062 48063 instance.container.insertBefore(table, instance.container.firstChild); 48064 48065 this.eventManager.addEventListener(instance.rootElement, 'mousedown', function (event) { 48066 this.selectionMouseDown = true; 48067 48068 if (!that.isTextSelectionAllowed(event.target)) { 48069 clearTextSelection(); 48070 event.preventDefault(); 48071 window.focus(); // make sure that window that contains HOT is active. Important when HOT is in iframe. 48072 } 48073 }); 48074 this.eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) { 48075 this.selectionMouseDown = false; 48076 }); 48077 this.eventManager.addEventListener(instance.rootElement, 'mousemove', function (event) { 48078 if (this.selectionMouseDown && !that.isTextSelectionAllowed(event.target)) { 48079 clearTextSelection(); 48080 event.preventDefault(); 48081 } 48082 }); 48083 48084 this.eventManager.addEventListener(document.documentElement, 'keyup', function (event) { 48085 if (instance.selection.isInProgress() && !event.shiftKey) { 48086 instance.selection.finish(); 48087 } 48088 }); 48089 48090 var isMouseDown; 48091 this.isMouseDown = function () { 48092 return isMouseDown; 48093 }; 48094 48095 this.eventManager.addEventListener(document.documentElement, 'mouseup', function (event) { 48096 if (instance.selection.isInProgress() && event.which === 1) { 48097 // is left mouse button 48098 instance.selection.finish(); 48099 } 48100 48101 isMouseDown = false; 48102 48103 if ((0, _element.isOutsideInput)(document.activeElement) || !instance.selection.isSelected()) { 48104 instance.unlisten(); 48105 } 48106 }); 48107 48108 this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) { 48109 var originalTarget = event.target; 48110 var next = event.target; 48111 var eventX = event.x || event.clientX; 48112 var eventY = event.y || event.clientY; 48113 48114 if (isMouseDown || !instance.rootElement) { 48115 return; // it must have been started in a cell 48116 } 48117 48118 // immediate click on "holder" means click on the right side of vertical scrollbar 48119 if (next === instance.view.wt.wtTable.holder) { 48120 var scrollbarWidth = (0, _element.getScrollbarWidth)(); 48121 48122 if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) { 48123 return; 48124 } 48125 } else { 48126 while (next !== document.documentElement) { 48127 if (next === null) { 48128 if (event.isTargetWebComponent) { 48129 break; 48130 } 48131 // click on something that was a row but now is detached (possibly because your click triggered a rerender) 48132 return; 48133 } 48134 if (next === instance.rootElement) { 48135 // click inside container 48136 return; 48137 } 48138 next = next.parentNode; 48139 } 48140 } 48141 48142 // function did not return until here, we have an outside click! 48143 48144 var outsideClickDeselects = typeof that.settings.outsideClickDeselects === 'function' ? that.settings.outsideClickDeselects(originalTarget) : that.settings.outsideClickDeselects; 48145 48146 if (outsideClickDeselects) { 48147 instance.deselectCell(); 48148 } else if (!jQuery(originalTarget).parents('#link__wiz,#tool__bar,.picker').length) { 48149 instance.destroyEditor(); 48150 } 48151 }); 48152 48153 this.eventManager.addEventListener(table, 'selectstart', function (event) { 48154 if (that.settings.fragmentSelection || (0, _element.isInput)(event.target)) { 48155 return; 48156 } 48157 // https://github.com/handsontable/handsontable/issues/160 48158 // Prevent text from being selected when performing drag down. 48159 event.preventDefault(); 48160 }); 48161 48162 var clearTextSelection = function clearTextSelection() { 48163 // http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript 48164 if (window.getSelection) { 48165 if (window.getSelection().empty) { 48166 // Chrome 48167 window.getSelection().empty(); 48168 } else if (window.getSelection().removeAllRanges) { 48169 // Firefox 48170 window.getSelection().removeAllRanges(); 48171 } 48172 } else if (document.selection) { 48173 // IE? 48174 document.selection.empty(); 48175 } 48176 }; 48177 48178 var selections = [new _src.Selection({ 48179 className: 'current', 48180 border: { 48181 width: 2, 48182 color: '#5292F7', 48183 // style: 'solid', // not used 48184 cornerVisible: function cornerVisible() { 48185 return that.settings.fillHandle && !that.isCellEdited() && !instance.selection.isMultiple(); 48186 }, 48187 multipleSelectionHandlesVisible: function multipleSelectionHandlesVisible() { 48188 return !that.isCellEdited() && !instance.selection.isMultiple(); 48189 } 48190 } 48191 }), new _src.Selection({ 48192 className: 'area', 48193 border: { 48194 width: 1, 48195 color: '#89AFF9', 48196 // style: 'solid', // not used 48197 cornerVisible: function cornerVisible() { 48198 return that.settings.fillHandle && !that.isCellEdited() && instance.selection.isMultiple(); 48199 }, 48200 multipleSelectionHandlesVisible: function multipleSelectionHandlesVisible() { 48201 return !that.isCellEdited() && instance.selection.isMultiple(); 48202 } 48203 } 48204 }), new _src.Selection({ 48205 className: 'highlight', 48206 highlightHeaderClassName: that.settings.currentHeaderClassName, 48207 highlightRowClassName: that.settings.currentRowClassName, 48208 highlightColumnClassName: that.settings.currentColClassName 48209 }), new _src.Selection({ 48210 className: 'fill', 48211 border: { 48212 width: 1, 48213 color: 'red' 48214 // style: 'solid' // not used 48215 } 48216 })]; 48217 selections.current = selections[0]; 48218 selections.area = selections[1]; 48219 selections.highlight = selections[2]; 48220 selections.fill = selections[3]; 48221 48222 var walkontableConfig = { 48223 debug: function debug() { 48224 return that.settings.debug; 48225 }, 48226 externalRowCalculator: this.instance.getPlugin('autoRowSize') && this.instance.getPlugin('autoRowSize').isEnabled(), 48227 table: table, 48228 preventOverflow: function preventOverflow() { 48229 return _this.settings.preventOverflow; 48230 }, 48231 stretchH: function stretchH() { 48232 return that.settings.stretchH; 48233 }, 48234 data: instance.getDataAtCell, 48235 totalRows: function totalRows() { 48236 return instance.countRows(); 48237 }, 48238 totalColumns: function totalColumns() { 48239 return instance.countCols(); 48240 }, 48241 fixedColumnsLeft: function fixedColumnsLeft() { 48242 return that.settings.fixedColumnsLeft; 48243 }, 48244 fixedRowsTop: function fixedRowsTop() { 48245 return that.settings.fixedRowsTop; 48246 }, 48247 fixedRowsBottom: function fixedRowsBottom() { 48248 return that.settings.fixedRowsBottom; 48249 }, 48250 minSpareRows: function minSpareRows() { 48251 return that.settings.minSpareRows; 48252 }, 48253 renderAllRows: that.settings.renderAllRows, 48254 rowHeaders: function rowHeaders() { 48255 var headerRenderers = []; 48256 48257 if (instance.hasRowHeaders()) { 48258 headerRenderers.push(function (row, TH) { 48259 that.appendRowHeader(row, TH); 48260 }); 48261 } 48262 instance.runHooks('afterGetRowHeaderRenderers', headerRenderers); 48263 48264 return headerRenderers; 48265 }, 48266 columnHeaders: function columnHeaders() { 48267 var headerRenderers = []; 48268 48269 if (instance.hasColHeaders()) { 48270 headerRenderers.push(function (column, TH) { 48271 that.appendColHeader(column, TH); 48272 }); 48273 } 48274 instance.runHooks('afterGetColumnHeaderRenderers', headerRenderers); 48275 48276 return headerRenderers; 48277 }, 48278 columnWidth: instance.getColWidth, 48279 rowHeight: instance.getRowHeight, 48280 cellRenderer: function cellRenderer(row, col, TD) { 48281 var cellProperties = that.instance.getCellMeta(row, col); 48282 var prop = that.instance.colToProp(col); 48283 var value = that.instance.getDataAtRowProp(row, prop); 48284 48285 if (that.instance.hasHook('beforeValueRender')) { 48286 value = that.instance.runHooks('beforeValueRender', value); 48287 } 48288 48289 that.instance.runHooks('beforeRenderer', TD, row, col, prop, value, cellProperties); 48290 that.instance.getCellRenderer(cellProperties)(that.instance, TD, row, col, prop, value, cellProperties); 48291 that.instance.runHooks('afterRenderer', TD, row, col, prop, value, cellProperties); 48292 }, 48293 selections: selections, 48294 hideBorderOnMouseDownOver: function hideBorderOnMouseDownOver() { 48295 return that.settings.fragmentSelection; 48296 }, 48297 onCellMouseDown: function onCellMouseDown(event, coords, TD, wt) { 48298 var blockCalculations = { 48299 row: false, 48300 column: false, 48301 cells: false 48302 }; 48303 48304 instance.listen(); 48305 48306 that.activeWt = wt; 48307 isMouseDown = true; 48308 48309 instance.runHooks('beforeOnCellMouseDown', event, coords, TD, blockCalculations); 48310 48311 if ((0, _event.isImmediatePropagationStopped)(event)) { 48312 return; 48313 } 48314 48315 var actualSelection = instance.getSelectedRange(); 48316 var selection = instance.selection; 48317 var selectedHeader = selection.selectedHeader; 48318 48319 if (event.shiftKey && actualSelection) { 48320 if (coords.row >= 0 && coords.col >= 0 && !blockCalculations.cells) { 48321 selection.setSelectedHeaders(false, false); 48322 selection.setRangeEnd(coords); 48323 } else if ((selectedHeader.cols || selectedHeader.rows) && coords.row >= 0 && coords.col >= 0 && !blockCalculations.cells) { 48324 selection.setSelectedHeaders(false, false); 48325 selection.setRangeEnd(new _src.CellCoords(coords.row, coords.col)); 48326 } else if (selectedHeader.cols && coords.row < 0 && !blockCalculations.column) { 48327 selection.setRangeEnd(new _src.CellCoords(actualSelection.to.row, coords.col)); 48328 } else if (selectedHeader.rows && coords.col < 0 && !blockCalculations.row) { 48329 selection.setRangeEnd(new _src.CellCoords(coords.row, actualSelection.to.col)); 48330 } else if ((!selectedHeader.cols && !selectedHeader.rows && coords.col < 0 || selectedHeader.cols && coords.col < 0) && !blockCalculations.row) { 48331 selection.setSelectedHeaders(true, false); 48332 selection.setRangeStartOnly(new _src.CellCoords(actualSelection.from.row, 0)); 48333 selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1)); 48334 } else if ((!selectedHeader.cols && !selectedHeader.rows && coords.row < 0 || selectedHeader.rows && coords.row < 0) && !blockCalculations.column) { 48335 selection.setSelectedHeaders(false, true); 48336 selection.setRangeStartOnly(new _src.CellCoords(0, actualSelection.from.col)); 48337 selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col)); 48338 } 48339 } else { 48340 var doNewSelection = true; 48341 48342 if (actualSelection) { 48343 var from = actualSelection.from, 48344 to = actualSelection.to; 48345 48346 var coordsNotInSelection = !selection.inInSelection(coords); 48347 48348 if (coords.row < 0 && selectedHeader.cols) { 48349 var start = Math.min(from.col, to.col); 48350 var end = Math.max(from.col, to.col); 48351 48352 doNewSelection = coords.col < start || coords.col > end; 48353 } else if (coords.col < 0 && selectedHeader.rows) { 48354 var _start = Math.min(from.row, to.row); 48355 var _end = Math.max(from.row, to.row); 48356 48357 doNewSelection = coords.row < _start || coords.row > _end; 48358 } else { 48359 doNewSelection = coordsNotInSelection; 48360 } 48361 } 48362 48363 var rightClick = (0, _event.isRightClick)(event); 48364 var leftClick = (0, _event.isLeftClick)(event) || event.type === 'touchstart'; 48365 48366 // clicked row header and when some column was selected 48367 if (coords.row < 0 && coords.col >= 0 && !blockCalculations.column) { 48368 selection.setSelectedHeaders(false, true); 48369 48370 if (leftClick || rightClick && doNewSelection) { 48371 selection.setRangeStartOnly(new _src.CellCoords(0, coords.col)); 48372 selection.setRangeEnd(new _src.CellCoords(Math.max(instance.countRows() - 1, 0), coords.col), false); 48373 } 48374 48375 // clicked column header and when some row was selected 48376 } else if (coords.col < 0 && coords.row >= 0 && !blockCalculations.row) { 48377 selection.setSelectedHeaders(true, false); 48378 48379 if (leftClick || rightClick && doNewSelection) { 48380 selection.setRangeStartOnly(new _src.CellCoords(coords.row, 0)); 48381 selection.setRangeEnd(new _src.CellCoords(coords.row, Math.max(instance.countCols() - 1, 0)), false); 48382 } 48383 } else if (coords.col >= 0 && coords.row >= 0 && !blockCalculations.cells) { 48384 if (leftClick || rightClick && doNewSelection) { 48385 selection.setSelectedHeaders(false, false); 48386 selection.setRangeStart(coords); 48387 } 48388 } else if (coords.col < 0 && coords.row < 0) { 48389 coords.row = 0; 48390 coords.col = 0; 48391 48392 selection.setSelectedHeaders(false, false, true); 48393 selection.setRangeStart(coords); 48394 } 48395 } 48396 48397 instance.runHooks('afterOnCellMouseDown', event, coords, TD); 48398 that.activeWt = that.wt; 48399 }, 48400 onCellMouseOut: function onCellMouseOut(event, coords, TD, wt) { 48401 that.activeWt = wt; 48402 instance.runHooks('beforeOnCellMouseOut', event, coords, TD); 48403 48404 if ((0, _event.isImmediatePropagationStopped)(event)) { 48405 return; 48406 } 48407 48408 instance.runHooks('afterOnCellMouseOut', event, coords, TD); 48409 that.activeWt = that.wt; 48410 }, 48411 onCellMouseOver: function onCellMouseOver(event, coords, TD, wt) { 48412 var blockCalculations = { 48413 row: false, 48414 column: false, 48415 cell: false 48416 }; 48417 48418 that.activeWt = wt; 48419 instance.runHooks('beforeOnCellMouseOver', event, coords, TD, blockCalculations); 48420 48421 if ((0, _event.isImmediatePropagationStopped)(event)) { 48422 return; 48423 } 48424 48425 if (event.button === 0 && isMouseDown) { 48426 if (coords.row >= 0 && coords.col >= 0) { 48427 // is not a header 48428 if (instance.selection.selectedHeader.cols && !blockCalculations.column) { 48429 instance.selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col), false); 48430 } else if (instance.selection.selectedHeader.rows && !blockCalculations.row) { 48431 instance.selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1), false); 48432 } else if (!blockCalculations.cell) { 48433 instance.selection.setRangeEnd(coords); 48434 } 48435 } else { 48436 /* eslint-disable no-lonely-if */ 48437 if (instance.selection.selectedHeader.cols && !blockCalculations.column) { 48438 instance.selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col), false); 48439 } else if (instance.selection.selectedHeader.rows && !blockCalculations.row) { 48440 instance.selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1), false); 48441 } else if (!blockCalculations.cell) { 48442 instance.selection.setRangeEnd(coords); 48443 } 48444 } 48445 } 48446 48447 instance.runHooks('afterOnCellMouseOver', event, coords, TD); 48448 that.activeWt = that.wt; 48449 }, 48450 onCellMouseUp: function onCellMouseUp(event, coords, TD, wt) { 48451 that.activeWt = wt; 48452 instance.runHooks('beforeOnCellMouseUp', event, coords, TD); 48453 48454 instance.runHooks('afterOnCellMouseUp', event, coords, TD); 48455 that.activeWt = that.wt; 48456 }, 48457 onCellCornerMouseDown: function onCellCornerMouseDown(event) { 48458 event.preventDefault(); 48459 instance.runHooks('afterOnCellCornerMouseDown', event); 48460 }, 48461 onCellCornerDblClick: function onCellCornerDblClick(event) { 48462 event.preventDefault(); 48463 instance.runHooks('afterOnCellCornerDblClick', event); 48464 }, 48465 beforeDraw: function beforeDraw(force, skipRender) { 48466 that.beforeRender(force, skipRender); 48467 }, 48468 onDraw: function onDraw(force) { 48469 that.onDraw(force); 48470 }, 48471 onScrollVertically: function onScrollVertically() { 48472 instance.runHooks('afterScrollVertically'); 48473 }, 48474 onScrollHorizontally: function onScrollHorizontally() { 48475 instance.runHooks('afterScrollHorizontally'); 48476 }, 48477 onBeforeDrawBorders: function onBeforeDrawBorders(corners, borderClassName) { 48478 instance.runHooks('beforeDrawBorders', corners, borderClassName); 48479 }, 48480 onBeforeTouchScroll: function onBeforeTouchScroll() { 48481 instance.runHooks('beforeTouchScroll'); 48482 }, 48483 onAfterMomentumScroll: function onAfterMomentumScroll() { 48484 instance.runHooks('afterMomentumScroll'); 48485 }, 48486 onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(stretchedWidth, column) { 48487 return instance.runHooks('beforeStretchingColumnWidth', stretchedWidth, column); 48488 }, 48489 onModifyRowHeaderWidth: function onModifyRowHeaderWidth(rowHeaderWidth) { 48490 return instance.runHooks('modifyRowHeaderWidth', rowHeaderWidth); 48491 }, 48492 viewportRowCalculatorOverride: function viewportRowCalculatorOverride(calc) { 48493 var rows = instance.countRows(); 48494 var viewportOffset = that.settings.viewportRowRenderingOffset; 48495 48496 if (viewportOffset === 'auto' && that.settings.fixedRowsTop) { 48497 viewportOffset = 10; 48498 } 48499 if (typeof viewportOffset === 'number') { 48500 calc.startRow = Math.max(calc.startRow - viewportOffset, 0); 48501 calc.endRow = Math.min(calc.endRow + viewportOffset, rows - 1); 48502 } 48503 if (viewportOffset === 'auto') { 48504 var center = calc.startRow + calc.endRow - calc.startRow; 48505 var offset = Math.ceil(center / rows * 12); 48506 48507 calc.startRow = Math.max(calc.startRow - offset, 0); 48508 calc.endRow = Math.min(calc.endRow + offset, rows - 1); 48509 } 48510 instance.runHooks('afterViewportRowCalculatorOverride', calc); 48511 }, 48512 viewportColumnCalculatorOverride: function viewportColumnCalculatorOverride(calc) { 48513 var cols = instance.countCols(); 48514 var viewportOffset = that.settings.viewportColumnRenderingOffset; 48515 48516 if (viewportOffset === 'auto' && that.settings.fixedColumnsLeft) { 48517 viewportOffset = 10; 48518 } 48519 if (typeof viewportOffset === 'number') { 48520 calc.startColumn = Math.max(calc.startColumn - viewportOffset, 0); 48521 calc.endColumn = Math.min(calc.endColumn + viewportOffset, cols - 1); 48522 } 48523 if (viewportOffset === 'auto') { 48524 var center = calc.startColumn + calc.endColumn - calc.startColumn; 48525 var offset = Math.ceil(center / cols * 12); 48526 48527 calc.startRow = Math.max(calc.startColumn - offset, 0); 48528 calc.endColumn = Math.min(calc.endColumn + offset, cols - 1); 48529 } 48530 instance.runHooks('afterViewportColumnCalculatorOverride', calc); 48531 }, 48532 rowHeaderWidth: function rowHeaderWidth() { 48533 return that.settings.rowHeaderWidth; 48534 }, 48535 columnHeaderHeight: function columnHeaderHeight() { 48536 var columnHeaderHeight = instance.runHooks('modifyColumnHeaderHeight'); 48537 return that.settings.columnHeaderHeight || columnHeaderHeight; 48538 } 48539 }; 48540 48541 instance.runHooks('beforeInitWalkontable', walkontableConfig); 48542 48543 this.wt = new _src2.default(walkontableConfig); 48544 this.activeWt = this.wt; 48545 48546 if (!(0, _browser.isChrome)() && !(0, _browser.isSafari)()) { 48547 this.eventManager.addEventListener(instance.rootElement, 'wheel', function (event) { 48548 event.preventDefault(); 48549 48550 var lineHeight = parseInt((0, _element.getComputedStyle)(document.body)['font-size'], 10); 48551 var holder = that.wt.wtOverlays.scrollableElement; 48552 48553 var deltaY = event.wheelDeltaY || event.deltaY; 48554 var deltaX = event.wheelDeltaX || event.deltaX; 48555 48556 switch (event.deltaMode) { 48557 case 0: 48558 holder.scrollLeft += deltaX; 48559 holder.scrollTop += deltaY; 48560 break; 48561 48562 case 1: 48563 holder.scrollLeft += deltaX * lineHeight; 48564 holder.scrollTop += deltaY * lineHeight; 48565 break; 48566 48567 default: 48568 break; 48569 } 48570 }); 48571 } 48572 48573 this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function (event) { 48574 // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar 48575 if (event.target === that.wt.wtTable.spreader && event.which === 3) { 48576 (0, _event.stopPropagation)(event); 48577 } 48578 }); 48579 48580 this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function (event) { 48581 // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar 48582 if (event.target === that.wt.wtTable.spreader && event.which === 3) { 48583 (0, _event.stopPropagation)(event); 48584 } 48585 }); 48586 48587 this.eventManager.addEventListener(document.documentElement, 'click', function () { 48588 if (that.settings.observeDOMVisibility) { 48589 if (that.wt.drawInterrupted) { 48590 that.instance.forceFullRender = true; 48591 that.render(); 48592 } 48593 } 48594 }); 48595} 48596 48597TableView.prototype.isTextSelectionAllowed = function (el) { 48598 if ((0, _element.isInput)(el)) { 48599 return true; 48600 } 48601 var isChildOfTableBody = (0, _element.isChildOf)(el, this.instance.view.wt.wtTable.spreader); 48602 48603 if (this.settings.fragmentSelection === true && isChildOfTableBody) { 48604 return true; 48605 } 48606 if (this.settings.fragmentSelection === 'cell' && this.isSelectedOnlyCell() && isChildOfTableBody) { 48607 return true; 48608 } 48609 if (!this.settings.fragmentSelection && this.isCellEdited() && this.isSelectedOnlyCell()) { 48610 return true; 48611 } 48612 48613 return false; 48614}; 48615 48616/** 48617 * Check if selected only one cell. 48618 * 48619 * @returns {Boolean} 48620 */ 48621TableView.prototype.isSelectedOnlyCell = function () { 48622 var _ref = this.instance.getSelected() || [], 48623 _ref2 = _slicedToArray(_ref, 4), 48624 row = _ref2[0], 48625 col = _ref2[1], 48626 rowEnd = _ref2[2], 48627 colEnd = _ref2[3]; 48628 48629 return row !== void 0 && row === rowEnd && col === colEnd; 48630}; 48631 48632TableView.prototype.isCellEdited = function () { 48633 var activeEditor = this.instance.getActiveEditor(); 48634 48635 return activeEditor && activeEditor.isOpened(); 48636}; 48637 48638TableView.prototype.beforeRender = function (force, skipRender) { 48639 if (force) { 48640 // this.instance.forceFullRender = did Handsontable request full render? 48641 this.instance.runHooks('beforeRender', this.instance.forceFullRender, skipRender); 48642 } 48643}; 48644 48645TableView.prototype.onDraw = function (force) { 48646 if (force) { 48647 // this.instance.forceFullRender = did Handsontable request full render? 48648 this.instance.runHooks('afterRender', this.instance.forceFullRender); 48649 } 48650}; 48651 48652TableView.prototype.render = function () { 48653 this.wt.draw(!this.instance.forceFullRender); 48654 this.instance.forceFullRender = false; 48655 this.instance.renderCall = false; 48656}; 48657 48658/** 48659 * Returns td object given coordinates 48660 * 48661 * @param {CellCoords} coords 48662 * @param {Boolean} topmost 48663 */ 48664TableView.prototype.getCellAtCoords = function (coords, topmost) { 48665 var td = this.wt.getCell(coords, topmost); 48666 48667 if (td < 0) { 48668 // there was an exit code (cell is out of bounds) 48669 return null; 48670 } 48671 48672 return td; 48673}; 48674 48675/** 48676 * Scroll viewport to selection. 48677 * 48678 * @param {CellCoords} coords 48679 */ 48680TableView.prototype.scrollViewport = function (coords) { 48681 this.wt.scrollViewport(coords); 48682}; 48683 48684/** 48685 * Append row header to a TH element 48686 * @param row 48687 * @param TH 48688 */ 48689TableView.prototype.appendRowHeader = function (row, TH) { 48690 if (TH.firstChild) { 48691 var container = TH.firstChild; 48692 48693 if (!(0, _element.hasClass)(container, 'relative')) { 48694 (0, _element.empty)(TH); 48695 this.appendRowHeader(row, TH); 48696 48697 return; 48698 } 48699 this.updateCellHeader(container.querySelector('.rowHeader'), row, this.instance.getRowHeader); 48700 } else { 48701 var div = document.createElement('div'); 48702 var span = document.createElement('span'); 48703 48704 div.className = 'relative'; 48705 span.className = 'rowHeader'; 48706 this.updateCellHeader(span, row, this.instance.getRowHeader); 48707 48708 div.appendChild(span); 48709 TH.appendChild(div); 48710 } 48711 48712 this.instance.runHooks('afterGetRowHeader', row, TH); 48713}; 48714 48715/** 48716 * Append column header to a TH element 48717 * @param col 48718 * @param TH 48719 */ 48720TableView.prototype.appendColHeader = function (col, TH) { 48721 if (TH.firstChild) { 48722 var container = TH.firstChild; 48723 48724 if ((0, _element.hasClass)(container, 'relative')) { 48725 this.updateCellHeader(container.querySelector('.colHeader'), col, this.instance.getColHeader); 48726 } else { 48727 (0, _element.empty)(TH); 48728 this.appendColHeader(col, TH); 48729 } 48730 } else { 48731 var div = document.createElement('div'); 48732 var span = document.createElement('span'); 48733 48734 div.className = 'relative'; 48735 span.className = 'colHeader'; 48736 this.updateCellHeader(span, col, this.instance.getColHeader); 48737 48738 div.appendChild(span); 48739 TH.appendChild(div); 48740 } 48741 48742 this.instance.runHooks('afterGetColHeader', col, TH); 48743}; 48744 48745/** 48746 * Update header cell content 48747 * 48748 * @since 0.15.0-beta4 48749 * @param {HTMLElement} element Element to update 48750 * @param {Number} index Row index or column index 48751 * @param {Function} content Function which should be returns content for this cell 48752 */ 48753TableView.prototype.updateCellHeader = function (element, index, content) { 48754 var renderedIndex = index; 48755 var parentOverlay = this.wt.wtOverlays.getParentOverlay(element) || this.wt; 48756 48757 // prevent wrong calculations from SampleGenerator 48758 if (element.parentNode) { 48759 if ((0, _element.hasClass)(element, 'colHeader')) { 48760 renderedIndex = parentOverlay.wtTable.columnFilter.sourceToRendered(index); 48761 } else if ((0, _element.hasClass)(element, 'rowHeader')) { 48762 renderedIndex = parentOverlay.wtTable.rowFilter.sourceToRendered(index); 48763 } 48764 } 48765 48766 if (renderedIndex > -1) { 48767 (0, _element.fastInnerHTML)(element, content(index)); 48768 } else { 48769 // workaround for https://github.com/handsontable/handsontable/issues/1946 48770 (0, _element.fastInnerText)(element, String.fromCharCode(160)); 48771 (0, _element.addClass)(element, 'cornerHeader'); 48772 } 48773}; 48774 48775/** 48776 * Given a element's left position relative to the viewport, returns maximum element width until the right 48777 * edge of the viewport (before scrollbar) 48778 * 48779 * @param {Number} leftOffset 48780 * @return {Number} 48781 */ 48782TableView.prototype.maximumVisibleElementWidth = function (leftOffset) { 48783 var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth(); 48784 var maxWidth = workspaceWidth - leftOffset; 48785 return maxWidth > 0 ? maxWidth : 0; 48786}; 48787 48788/** 48789 * Given a element's top position relative to the viewport, returns maximum element height until the bottom 48790 * edge of the viewport (before scrollbar) 48791 * 48792 * @param {Number} topOffset 48793 * @return {Number} 48794 */ 48795TableView.prototype.maximumVisibleElementHeight = function (topOffset) { 48796 var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight(); 48797 var maxHeight = workspaceHeight - topOffset; 48798 return maxHeight > 0 ? maxHeight : 0; 48799}; 48800 48801TableView.prototype.mainViewIsActive = function () { 48802 return this.wt === this.activeWt; 48803}; 48804 48805TableView.prototype.destroy = function () { 48806 this.wt.destroy(); 48807 this.eventManager.destroy(); 48808}; 48809 48810exports.default = TableView; 48811 48812/***/ }), 48813/* 384 */ 48814/***/ (function(module, exports, __webpack_require__) { 48815 48816"use strict"; 48817 48818 48819exports.__esModule = true; 48820 48821var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 48822 48823exports.parseDelay = parseDelay; 48824 48825var _feature = __webpack_require__(34); 48826 48827function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 48828 48829/** 48830 * @class Interval 48831 * @util 48832 */ 48833var Interval = function () { 48834 _createClass(Interval, null, [{ 48835 key: 'create', 48836 value: function create(func, delay) { 48837 return new Interval(func, delay); 48838 } 48839 }]); 48840 48841 function Interval(func, delay) { 48842 var _this = this; 48843 48844 _classCallCheck(this, Interval); 48845 48846 /** 48847 * Animation frame request id. 48848 * 48849 * @type {Number} 48850 */ 48851 this.timer = null; 48852 /** 48853 * Function to invoke repeatedly. 48854 * 48855 * @type {Function} 48856 */ 48857 this.func = func; 48858 /** 48859 * Number of milliseconds that function should wait before next call. 48860 */ 48861 this.delay = parseDelay(delay); 48862 /** 48863 * Flag which indicates if interval object was stopped. 48864 * 48865 * @type {Boolean} 48866 * @default true 48867 */ 48868 this.stopped = true; 48869 /** 48870 * Interval time (in milliseconds) of the last callback call. 48871 * 48872 * @private 48873 * @type {Number} 48874 */ 48875 this._then = null; 48876 /** 48877 * Bounded function `func`. 48878 * 48879 * @private 48880 * @type {Function} 48881 */ 48882 this._callback = function () { 48883 return _this.__callback(); 48884 }; 48885 } 48886 48887 /** 48888 * Start loop. 48889 * 48890 * @returns {Interval} 48891 */ 48892 48893 48894 _createClass(Interval, [{ 48895 key: 'start', 48896 value: function start() { 48897 if (this.stopped) { 48898 this._then = Date.now(); 48899 this.stopped = false; 48900 this.timer = (0, _feature.requestAnimationFrame)(this._callback); 48901 } 48902 48903 return this; 48904 } 48905 48906 /** 48907 * Stop looping. 48908 * 48909 * @returns {Interval} 48910 */ 48911 48912 }, { 48913 key: 'stop', 48914 value: function stop() { 48915 if (!this.stopped) { 48916 this.stopped = true; 48917 (0, _feature.cancelAnimationFrame)(this.timer); 48918 this.timer = null; 48919 } 48920 48921 return this; 48922 } 48923 48924 /** 48925 * Loop callback, fired on every animation frame. 48926 * 48927 * @private 48928 */ 48929 48930 }, { 48931 key: '__callback', 48932 value: function __callback() { 48933 this.timer = (0, _feature.requestAnimationFrame)(this._callback); 48934 48935 if (this.delay) { 48936 var now = Date.now(); 48937 var elapsed = now - this._then; 48938 48939 if (elapsed > this.delay) { 48940 this._then = now - elapsed % this.delay; 48941 this.func(); 48942 } 48943 } else { 48944 this.func(); 48945 } 48946 } 48947 }]); 48948 48949 return Interval; 48950}(); 48951 48952exports.default = Interval; 48953function parseDelay(delay) { 48954 if (typeof delay === 'string' && /fps$/.test(delay)) { 48955 delay = 1000 / parseInt(delay.replace('fps', '') || 0, 10); 48956 } 48957 48958 return delay; 48959} 48960 48961/***/ }), 48962/* 385 */ 48963/***/ (function(module, exports, __webpack_require__) { 48964 48965"use strict"; 48966 48967 48968exports.__esModule = true; 48969exports.default = autocompleteValidator; 48970/** 48971 * Autocomplete cell validator. 48972 * 48973 * @private 48974 * @validator AutocompleteValidator 48975 * @param {*} value - Value of edited cell 48976 * @param {Function} callback - Callback called with validation result 48977 */ 48978function autocompleteValidator(value, callback) { 48979 if (value == null) { 48980 value = ''; 48981 } 48982 48983 if (this.allowEmpty && value === '') { 48984 callback(true); 48985 48986 return; 48987 } 48988 48989 if (this.strict && this.source) { 48990 if (typeof this.source === 'function') { 48991 this.source(value, process(value, callback)); 48992 } else { 48993 process(value, callback)(this.source); 48994 } 48995 } else { 48996 callback(true); 48997 } 48998}; 48999 49000/** 49001 * Function responsible for validation of autocomplete value. 49002 * 49003 * @param {*} value - Value of edited cell 49004 * @param {Function} callback - Callback called with validation result 49005 */ 49006function process(value, callback) { 49007 var originalVal = value; 49008 49009 return function (source) { 49010 var found = false; 49011 49012 for (var s = 0, slen = source.length; s < slen; s++) { 49013 if (originalVal === source[s]) { 49014 found = true; // perfect match 49015 break; 49016 } 49017 } 49018 49019 callback(found); 49020 }; 49021} 49022 49023/***/ }), 49024/* 386 */ 49025/***/ (function(module, exports, __webpack_require__) { 49026 49027"use strict"; 49028 49029 49030exports.__esModule = true; 49031exports.default = dateValidator; 49032exports.correctFormat = correctFormat; 49033 49034var _moment = __webpack_require__(42); 49035 49036var _moment2 = _interopRequireDefault(_moment); 49037 49038var _date = __webpack_require__(89); 49039 49040var _editors = __webpack_require__(13); 49041 49042function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 49043 49044/** 49045 * Date cell validator 49046 * 49047 * @private 49048 * @validator DateValidator 49049 * @dependencies moment 49050 * @param {*} value - Value of edited cell 49051 * @param {Function} callback - Callback called with validation result 49052 */ 49053function dateValidator(value, callback) { 49054 var valid = true; 49055 var dateEditor = (0, _editors.getEditorInstance)('date', this.instance); 49056 49057 if (value == null) { 49058 value = ''; 49059 } 49060 var isValidDate = (0, _moment2.default)(new Date(value)).isValid() || (0, _moment2.default)(value, dateEditor.defaultDateFormat).isValid(); 49061 // is it in the specified format 49062 var isValidFormat = (0, _moment2.default)(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid(); 49063 49064 if (this.allowEmpty && value === '') { 49065 isValidDate = true; 49066 isValidFormat = true; 49067 } 49068 if (!isValidDate) { 49069 valid = false; 49070 } 49071 if (!isValidDate && isValidFormat) { 49072 valid = true; 49073 } 49074 49075 if (isValidDate && !isValidFormat) { 49076 if (this.correctFormat === true) { 49077 // if format correction is enabled 49078 var correctedValue = correctFormat(value, this.dateFormat); 49079 var row = this.instance.runHooks('unmodifyRow', this.row); 49080 var column = this.instance.runHooks('unmodifyCol', this.col); 49081 49082 this.instance.setDataAtCell(row, column, correctedValue, 'dateValidator'); 49083 valid = true; 49084 } else { 49085 valid = false; 49086 } 49087 } 49088 49089 callback(valid); 49090}; 49091 49092/** 49093 * Format the given string using moment.js' format feature 49094 * 49095 * @param {String} value 49096 * @param {String} dateFormat 49097 * @returns {String} 49098 */ 49099function correctFormat(value, dateFormat) { 49100 var dateFromDate = (0, _moment2.default)((0, _date.getNormalizedDate)(value)); 49101 var dateFromMoment = (0, _moment2.default)(value, dateFormat); 49102 var isAlphanumeric = value.search(/[A-z]/g) > -1; 49103 var date = void 0; 49104 49105 if (dateFromDate.isValid() && dateFromDate.format('x') === dateFromMoment.format('x') || !dateFromMoment.isValid() || isAlphanumeric) { 49106 date = dateFromDate; 49107 } else { 49108 date = dateFromMoment; 49109 } 49110 49111 return date.format(dateFormat); 49112}; 49113 49114/***/ }), 49115/* 387 */ 49116/***/ (function(module, exports, __webpack_require__) { 49117 49118"use strict"; 49119 49120 49121exports.__esModule = true; 49122exports.default = numericValidator; 49123/** 49124 * Numeric cell validator 49125 * 49126 * @private 49127 * @validator NumericValidator 49128 * @param {*} value - Value of edited cell 49129 * @param {*} callback - Callback called with validation result 49130 */ 49131function numericValidator(value, callback) { 49132 if (value == null) { 49133 value = ''; 49134 } 49135 if (this.allowEmpty && value === '') { 49136 callback(true); 49137 } else if (value === '') { 49138 callback(false); 49139 } else { 49140 callback(/^-?\d*(\.|,)?\d*$/.test(value)); 49141 } 49142}; 49143 49144/***/ }), 49145/* 388 */ 49146/***/ (function(module, exports, __webpack_require__) { 49147 49148"use strict"; 49149 49150 49151exports.__esModule = true; 49152exports.default = timeValidator; 49153 49154var _moment = __webpack_require__(42); 49155 49156var _moment2 = _interopRequireDefault(_moment); 49157 49158function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 49159 49160// Formats which are correctly parsed to time (supported by momentjs) 49161var STRICT_FORMATS = ['YYYY-MM-DDTHH:mm:ss.SSSZ', 'X', // Unix timestamp 49162'x' // Unix ms timestamp 49163]; 49164 49165/** 49166 * Time cell validator 49167 * 49168 * @private 49169 * @validator TimeValidator 49170 * @dependencies moment 49171 * @param {*} value - Value of edited cell 49172 * @param {Function} callback - Callback called with validation result 49173 */ 49174function timeValidator(value, callback) { 49175 var valid = true; 49176 var timeFormat = this.timeFormat || 'h:mm:ss a'; 49177 49178 if (value === null) { 49179 value = ''; 49180 } 49181 49182 value = /^\d{3,}$/.test(value) ? parseInt(value, 10) : value; 49183 49184 var twoDigitValue = /^\d{1,2}$/.test(value); 49185 49186 if (twoDigitValue) { 49187 value += ':00'; 49188 } 49189 49190 var date = (0, _moment2.default)(value, STRICT_FORMATS, true).isValid() ? (0, _moment2.default)(value) : (0, _moment2.default)(value, timeFormat); 49191 var isValidTime = date.isValid(); 49192 49193 // is it in the specified format 49194 var isValidFormat = (0, _moment2.default)(value, timeFormat, true).isValid() && !twoDigitValue; 49195 49196 if (this.allowEmpty && value === '') { 49197 isValidTime = true; 49198 isValidFormat = true; 49199 } 49200 if (!isValidTime) { 49201 valid = false; 49202 } 49203 if (!isValidTime && isValidFormat) { 49204 valid = true; 49205 } 49206 if (isValidTime && !isValidFormat) { 49207 if (this.correctFormat === true) { 49208 // if format correction is enabled 49209 var correctedValue = date.format(timeFormat); 49210 var row = this.instance.runHooks('unmodifyRow', this.row); 49211 var column = this.instance.runHooks('unmodifyCol', this.col); 49212 49213 this.instance.setDataAtCell(row, column, correctedValue, 'timeValidator'); 49214 valid = true; 49215 } else { 49216 valid = false; 49217 } 49218 } 49219 49220 callback(valid); 49221}; 49222 49223/***/ }), 49224/* 389 */ 49225/***/ (function(module, exports, __webpack_require__) { 49226 49227"use strict"; 49228// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) 49229 49230var toObject = __webpack_require__(40); 49231var toAbsoluteIndex = __webpack_require__(63); 49232var toLength = __webpack_require__(21); 49233 49234module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) { 49235 var O = toObject(this); 49236 var len = toLength(O.length); 49237 var to = toAbsoluteIndex(target, len); 49238 var from = toAbsoluteIndex(start, len); 49239 var end = arguments.length > 2 ? arguments[2] : undefined; 49240 var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to); 49241 var inc = 1; 49242 if (from < to && to < from + count) { 49243 inc = -1; 49244 from += count - 1; 49245 to += count - 1; 49246 } 49247 while (count-- > 0) { 49248 if (from in O) O[to] = O[from]; 49249 else delete O[to]; 49250 to += inc; 49251 from += inc; 49252 } return O; 49253}; 49254 49255 49256/***/ }), 49257/* 390 */ 49258/***/ (function(module, exports, __webpack_require__) { 49259 49260"use strict"; 49261// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) 49262 49263var toObject = __webpack_require__(40); 49264var toAbsoluteIndex = __webpack_require__(63); 49265var toLength = __webpack_require__(21); 49266module.exports = function fill(value /* , start = 0, end = @length */) { 49267 var O = toObject(this); 49268 var length = toLength(O.length); 49269 var aLen = arguments.length; 49270 var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length); 49271 var end = aLen > 2 ? arguments[2] : undefined; 49272 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 49273 while (endPos > index) O[index++] = value; 49274 return O; 49275}; 49276 49277 49278/***/ }), 49279/* 391 */ 49280/***/ (function(module, exports, __webpack_require__) { 49281 49282var isObject = __webpack_require__(12); 49283var isArray = __webpack_require__(277); 49284var SPECIES = __webpack_require__(8)('species'); 49285 49286module.exports = function (original) { 49287 var C; 49288 if (isArray(original)) { 49289 C = original.constructor; 49290 // cross-realm fallback 49291 if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; 49292 if (isObject(C)) { 49293 C = C[SPECIES]; 49294 if (C === null) C = undefined; 49295 } 49296 } return C === undefined ? Array : C; 49297}; 49298 49299 49300/***/ }), 49301/* 392 */ 49302/***/ (function(module, exports, __webpack_require__) { 49303 49304// 9.4.2.3 ArraySpeciesCreate(originalArray, length) 49305var speciesConstructor = __webpack_require__(391); 49306 49307module.exports = function (original, length) { 49308 return new (speciesConstructor(original))(length); 49309}; 49310 49311 49312/***/ }), 49313/* 393 */ 49314/***/ (function(module, exports, __webpack_require__) { 49315 49316// all enumerable object keys, includes symbols 49317var getKeys = __webpack_require__(39); 49318var gOPS = __webpack_require__(61); 49319var pIE = __webpack_require__(48); 49320module.exports = function (it) { 49321 var result = getKeys(it); 49322 var getSymbols = gOPS.f; 49323 if (getSymbols) { 49324 var symbols = getSymbols(it); 49325 var isEnum = pIE.f; 49326 var i = 0; 49327 var key; 49328 while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key); 49329 } return result; 49330}; 49331 49332 49333/***/ }), 49334/* 394 */ 49335/***/ (function(module, exports, __webpack_require__) { 49336 49337"use strict"; 49338 49339// 21.2.5.3 get RegExp.prototype.flags 49340var anObject = __webpack_require__(17); 49341module.exports = function () { 49342 var that = anObject(this); 49343 var result = ''; 49344 if (that.global) result += 'g'; 49345 if (that.ignoreCase) result += 'i'; 49346 if (that.multiline) result += 'm'; 49347 if (that.unicode) result += 'u'; 49348 if (that.sticky) result += 'y'; 49349 return result; 49350}; 49351 49352 49353/***/ }), 49354/* 395 */ 49355/***/ (function(module, exports, __webpack_require__) { 49356 49357var isObject = __webpack_require__(12); 49358var setPrototypeOf = __webpack_require__(287).set; 49359module.exports = function (that, target, C) { 49360 var S = target.constructor; 49361 var P; 49362 if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) { 49363 setPrototypeOf(that, P); 49364 } return that; 49365}; 49366 49367 49368/***/ }), 49369/* 396 */ 49370/***/ (function(module, exports) { 49371 49372// fast apply, http://jsperf.lnkit.com/fast-apply/5 49373module.exports = function (fn, args, that) { 49374 var un = that === undefined; 49375 switch (args.length) { 49376 case 0: return un ? fn() 49377 : fn.call(that); 49378 case 1: return un ? fn(args[0]) 49379 : fn.call(that, args[0]); 49380 case 2: return un ? fn(args[0], args[1]) 49381 : fn.call(that, args[0], args[1]); 49382 case 3: return un ? fn(args[0], args[1], args[2]) 49383 : fn.call(that, args[0], args[1], args[2]); 49384 case 4: return un ? fn(args[0], args[1], args[2], args[3]) 49385 : fn.call(that, args[0], args[1], args[2], args[3]); 49386 } return fn.apply(that, args); 49387}; 49388 49389 49390/***/ }), 49391/* 397 */ 49392/***/ (function(module, exports, __webpack_require__) { 49393 49394"use strict"; 49395 49396var create = __webpack_require__(80); 49397var descriptor = __webpack_require__(49); 49398var setToStringTag = __webpack_require__(50); 49399var IteratorPrototype = {}; 49400 49401// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() 49402__webpack_require__(31)(IteratorPrototype, __webpack_require__(8)('iterator'), function () { return this; }); 49403 49404module.exports = function (Constructor, NAME, next) { 49405 Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); 49406 setToStringTag(Constructor, NAME + ' Iterator'); 49407}; 49408 49409 49410/***/ }), 49411/* 398 */ 49412/***/ (function(module, exports, __webpack_require__) { 49413 49414var global = __webpack_require__(10); 49415var macrotask = __webpack_require__(86).set; 49416var Observer = global.MutationObserver || global.WebKitMutationObserver; 49417var process = global.process; 49418var Promise = global.Promise; 49419var isNode = __webpack_require__(38)(process) == 'process'; 49420 49421module.exports = function () { 49422 var head, last, notify; 49423 49424 var flush = function () { 49425 var parent, fn; 49426 if (isNode && (parent = process.domain)) parent.exit(); 49427 while (head) { 49428 fn = head.fn; 49429 head = head.next; 49430 try { 49431 fn(); 49432 } catch (e) { 49433 if (head) notify(); 49434 else last = undefined; 49435 throw e; 49436 } 49437 } last = undefined; 49438 if (parent) parent.enter(); 49439 }; 49440 49441 // Node.js 49442 if (isNode) { 49443 notify = function () { 49444 process.nextTick(flush); 49445 }; 49446 // browsers with MutationObserver 49447 } else if (Observer) { 49448 var toggle = true; 49449 var node = document.createTextNode(''); 49450 new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new 49451 notify = function () { 49452 node.data = toggle = !toggle; 49453 }; 49454 // environments with maybe non-completely correct, but existent Promise 49455 } else if (Promise && Promise.resolve) { 49456 var promise = Promise.resolve(); 49457 notify = function () { 49458 promise.then(flush); 49459 }; 49460 // for other environments - macrotask based on: 49461 // - setImmediate 49462 // - MessageChannel 49463 // - window.postMessag 49464 // - onreadystatechange 49465 // - setTimeout 49466 } else { 49467 notify = function () { 49468 // strange IE + webpack dev server bug - use .call(global) 49469 macrotask.call(global, flush); 49470 }; 49471 } 49472 49473 return function (fn) { 49474 var task = { fn: fn, next: undefined }; 49475 if (last) last.next = task; 49476 if (!head) { 49477 head = task; 49478 notify(); 49479 } last = task; 49480 }; 49481}; 49482 49483 49484/***/ }), 49485/* 399 */ 49486/***/ (function(module, exports, __webpack_require__) { 49487 49488var dP = __webpack_require__(18); 49489var anObject = __webpack_require__(17); 49490var getKeys = __webpack_require__(39); 49491 49492module.exports = __webpack_require__(20) ? Object.defineProperties : function defineProperties(O, Properties) { 49493 anObject(O); 49494 var keys = getKeys(Properties); 49495 var length = keys.length; 49496 var i = 0; 49497 var P; 49498 while (length > i) dP.f(O, P = keys[i++], Properties[P]); 49499 return O; 49500}; 49501 49502 49503/***/ }), 49504/* 400 */ 49505/***/ (function(module, exports, __webpack_require__) { 49506 49507// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window 49508var toIObject = __webpack_require__(27); 49509var gOPN = __webpack_require__(82).f; 49510var toString = {}.toString; 49511 49512var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames 49513 ? Object.getOwnPropertyNames(window) : []; 49514 49515var getWindowNames = function (it) { 49516 try { 49517 return gOPN(it); 49518 } catch (e) { 49519 return windowNames.slice(); 49520 } 49521}; 49522 49523module.exports.f = function getOwnPropertyNames(it) { 49524 return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); 49525}; 49526 49527 49528/***/ }), 49529/* 401 */ 49530/***/ (function(module, exports, __webpack_require__) { 49531 49532// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) 49533var has = __webpack_require__(26); 49534var toObject = __webpack_require__(40); 49535var IE_PROTO = __webpack_require__(83)('IE_PROTO'); 49536var ObjectProto = Object.prototype; 49537 49538module.exports = Object.getPrototypeOf || function (O) { 49539 O = toObject(O); 49540 if (has(O, IE_PROTO)) return O[IE_PROTO]; 49541 if (typeof O.constructor == 'function' && O instanceof O.constructor) { 49542 return O.constructor.prototype; 49543 } return O instanceof Object ? ObjectProto : null; 49544}; 49545 49546 49547/***/ }), 49548/* 402 */ 49549/***/ (function(module, exports, __webpack_require__) { 49550 49551// all object keys, includes non-enumerable and symbols 49552var gOPN = __webpack_require__(82); 49553var gOPS = __webpack_require__(61); 49554var anObject = __webpack_require__(17); 49555var Reflect = __webpack_require__(10).Reflect; 49556module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) { 49557 var keys = gOPN.f(anObject(it)); 49558 var getSymbols = gOPS.f; 49559 return getSymbols ? keys.concat(getSymbols(it)) : keys; 49560}; 49561 49562 49563/***/ }), 49564/* 403 */ 49565/***/ (function(module, exports) { 49566 49567module.exports = function (exec) { 49568 try { 49569 return { e: false, v: exec() }; 49570 } catch (e) { 49571 return { e: true, v: e }; 49572 } 49573}; 49574 49575 49576/***/ }), 49577/* 404 */ 49578/***/ (function(module, exports, __webpack_require__) { 49579 49580var anObject = __webpack_require__(17); 49581var isObject = __webpack_require__(12); 49582var newPromiseCapability = __webpack_require__(283); 49583 49584module.exports = function (C, x) { 49585 anObject(C); 49586 if (isObject(x) && x.constructor === C) return x; 49587 var promiseCapability = newPromiseCapability.f(C); 49588 var resolve = promiseCapability.resolve; 49589 resolve(x); 49590 return promiseCapability.promise; 49591}; 49592 49593 49594/***/ }), 49595/* 405 */ 49596/***/ (function(module, exports) { 49597 49598// 7.2.9 SameValue(x, y) 49599module.exports = Object.is || function is(x, y) { 49600 // eslint-disable-next-line no-self-compare 49601 return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; 49602}; 49603 49604 49605/***/ }), 49606/* 406 */ 49607/***/ (function(module, exports, __webpack_require__) { 49608 49609// 7.3.20 SpeciesConstructor(O, defaultConstructor) 49610var anObject = __webpack_require__(17); 49611var aFunction = __webpack_require__(54); 49612var SPECIES = __webpack_require__(8)('species'); 49613module.exports = function (O, D) { 49614 var C = anObject(O).constructor; 49615 var S; 49616 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); 49617}; 49618 49619 49620/***/ }), 49621/* 407 */ 49622/***/ (function(module, exports, __webpack_require__) { 49623 49624var toInteger = __webpack_require__(64); 49625var defined = __webpack_require__(33); 49626// true -> String#at 49627// false -> String#codePointAt 49628module.exports = function (TO_STRING) { 49629 return function (that, pos) { 49630 var s = String(defined(that)); 49631 var i = toInteger(pos); 49632 var l = s.length; 49633 var a, b; 49634 if (i < 0 || i >= l) return TO_STRING ? '' : undefined; 49635 a = s.charCodeAt(i); 49636 return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff 49637 ? TO_STRING ? s.charAt(i) : a 49638 : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; 49639 }; 49640}; 49641 49642 49643/***/ }), 49644/* 408 */ 49645/***/ (function(module, exports, __webpack_require__) { 49646 49647var global = __webpack_require__(10); 49648var core = __webpack_require__(45); 49649var LIBRARY = __webpack_require__(60); 49650var wksExt = __webpack_require__(291); 49651var defineProperty = __webpack_require__(18).f; 49652module.exports = function (name) { 49653 var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); 49654 if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); 49655}; 49656 49657 49658/***/ }), 49659/* 409 */ 49660/***/ (function(module, exports, __webpack_require__) { 49661 49662var map = { 49663 "./af": 134, 49664 "./af.js": 134, 49665 "./ar": 141, 49666 "./ar-dz": 135, 49667 "./ar-dz.js": 135, 49668 "./ar-kw": 136, 49669 "./ar-kw.js": 136, 49670 "./ar-ly": 137, 49671 "./ar-ly.js": 137, 49672 "./ar-ma": 138, 49673 "./ar-ma.js": 138, 49674 "./ar-sa": 139, 49675 "./ar-sa.js": 139, 49676 "./ar-tn": 140, 49677 "./ar-tn.js": 140, 49678 "./ar.js": 141, 49679 "./az": 142, 49680 "./az.js": 142, 49681 "./be": 143, 49682 "./be.js": 143, 49683 "./bg": 144, 49684 "./bg.js": 144, 49685 "./bn": 145, 49686 "./bn.js": 145, 49687 "./bo": 146, 49688 "./bo.js": 146, 49689 "./br": 147, 49690 "./br.js": 147, 49691 "./bs": 148, 49692 "./bs.js": 148, 49693 "./ca": 149, 49694 "./ca.js": 149, 49695 "./cs": 150, 49696 "./cs.js": 150, 49697 "./cv": 151, 49698 "./cv.js": 151, 49699 "./cy": 152, 49700 "./cy.js": 152, 49701 "./da": 153, 49702 "./da.js": 153, 49703 "./de": 156, 49704 "./de-at": 154, 49705 "./de-at.js": 154, 49706 "./de-ch": 155, 49707 "./de-ch.js": 155, 49708 "./de.js": 156, 49709 "./dv": 157, 49710 "./dv.js": 157, 49711 "./el": 158, 49712 "./el.js": 158, 49713 "./en-au": 159, 49714 "./en-au.js": 159, 49715 "./en-ca": 160, 49716 "./en-ca.js": 160, 49717 "./en-gb": 161, 49718 "./en-gb.js": 161, 49719 "./en-ie": 162, 49720 "./en-ie.js": 162, 49721 "./en-nz": 163, 49722 "./en-nz.js": 163, 49723 "./eo": 164, 49724 "./eo.js": 164, 49725 "./es": 166, 49726 "./es-do": 165, 49727 "./es-do.js": 165, 49728 "./es.js": 166, 49729 "./et": 167, 49730 "./et.js": 167, 49731 "./eu": 168, 49732 "./eu.js": 168, 49733 "./fa": 169, 49734 "./fa.js": 169, 49735 "./fi": 170, 49736 "./fi.js": 170, 49737 "./fo": 171, 49738 "./fo.js": 171, 49739 "./fr": 174, 49740 "./fr-ca": 172, 49741 "./fr-ca.js": 172, 49742 "./fr-ch": 173, 49743 "./fr-ch.js": 173, 49744 "./fr.js": 174, 49745 "./fy": 175, 49746 "./fy.js": 175, 49747 "./gd": 176, 49748 "./gd.js": 176, 49749 "./gl": 177, 49750 "./gl.js": 177, 49751 "./gom-latn": 178, 49752 "./gom-latn.js": 178, 49753 "./he": 179, 49754 "./he.js": 179, 49755 "./hi": 180, 49756 "./hi.js": 180, 49757 "./hr": 181, 49758 "./hr.js": 181, 49759 "./hu": 182, 49760 "./hu.js": 182, 49761 "./hy-am": 183, 49762 "./hy-am.js": 183, 49763 "./id": 184, 49764 "./id.js": 184, 49765 "./is": 185, 49766 "./is.js": 185, 49767 "./it": 186, 49768 "./it.js": 186, 49769 "./ja": 187, 49770 "./ja.js": 187, 49771 "./jv": 188, 49772 "./jv.js": 188, 49773 "./ka": 189, 49774 "./ka.js": 189, 49775 "./kk": 190, 49776 "./kk.js": 190, 49777 "./km": 191, 49778 "./km.js": 191, 49779 "./kn": 192, 49780 "./kn.js": 192, 49781 "./ko": 193, 49782 "./ko.js": 193, 49783 "./ky": 194, 49784 "./ky.js": 194, 49785 "./lb": 195, 49786 "./lb.js": 195, 49787 "./lo": 196, 49788 "./lo.js": 196, 49789 "./lt": 197, 49790 "./lt.js": 197, 49791 "./lv": 198, 49792 "./lv.js": 198, 49793 "./me": 199, 49794 "./me.js": 199, 49795 "./mi": 200, 49796 "./mi.js": 200, 49797 "./mk": 201, 49798 "./mk.js": 201, 49799 "./ml": 202, 49800 "./ml.js": 202, 49801 "./mr": 203, 49802 "./mr.js": 203, 49803 "./ms": 205, 49804 "./ms-my": 204, 49805 "./ms-my.js": 204, 49806 "./ms.js": 205, 49807 "./my": 206, 49808 "./my.js": 206, 49809 "./nb": 207, 49810 "./nb.js": 207, 49811 "./ne": 208, 49812 "./ne.js": 208, 49813 "./nl": 210, 49814 "./nl-be": 209, 49815 "./nl-be.js": 209, 49816 "./nl.js": 210, 49817 "./nn": 211, 49818 "./nn.js": 211, 49819 "./pa-in": 212, 49820 "./pa-in.js": 212, 49821 "./pl": 213, 49822 "./pl.js": 213, 49823 "./pt": 215, 49824 "./pt-br": 214, 49825 "./pt-br.js": 214, 49826 "./pt.js": 215, 49827 "./ro": 216, 49828 "./ro.js": 216, 49829 "./ru": 217, 49830 "./ru.js": 217, 49831 "./sd": 218, 49832 "./sd.js": 218, 49833 "./se": 219, 49834 "./se.js": 219, 49835 "./si": 220, 49836 "./si.js": 220, 49837 "./sk": 221, 49838 "./sk.js": 221, 49839 "./sl": 222, 49840 "./sl.js": 222, 49841 "./sq": 223, 49842 "./sq.js": 223, 49843 "./sr": 225, 49844 "./sr-cyrl": 224, 49845 "./sr-cyrl.js": 224, 49846 "./sr.js": 225, 49847 "./ss": 226, 49848 "./ss.js": 226, 49849 "./sv": 227, 49850 "./sv.js": 227, 49851 "./sw": 228, 49852 "./sw.js": 228, 49853 "./ta": 229, 49854 "./ta.js": 229, 49855 "./te": 230, 49856 "./te.js": 230, 49857 "./tet": 231, 49858 "./tet.js": 231, 49859 "./th": 232, 49860 "./th.js": 232, 49861 "./tl-ph": 233, 49862 "./tl-ph.js": 233, 49863 "./tlh": 234, 49864 "./tlh.js": 234, 49865 "./tr": 235, 49866 "./tr.js": 235, 49867 "./tzl": 236, 49868 "./tzl.js": 236, 49869 "./tzm": 238, 49870 "./tzm-latn": 237, 49871 "./tzm-latn.js": 237, 49872 "./tzm.js": 238, 49873 "./uk": 239, 49874 "./uk.js": 239, 49875 "./ur": 240, 49876 "./ur.js": 240, 49877 "./uz": 242, 49878 "./uz-latn": 241, 49879 "./uz-latn.js": 241, 49880 "./uz.js": 242, 49881 "./vi": 243, 49882 "./vi.js": 243, 49883 "./x-pseudo": 244, 49884 "./x-pseudo.js": 244, 49885 "./yo": 245, 49886 "./yo.js": 245, 49887 "./zh-cn": 246, 49888 "./zh-cn.js": 246, 49889 "./zh-hk": 247, 49890 "./zh-hk.js": 247, 49891 "./zh-tw": 248, 49892 "./zh-tw.js": 248 49893}; 49894function webpackContext(req) { 49895 return __webpack_require__(webpackContextResolve(req)); 49896}; 49897function webpackContextResolve(req) { 49898 var id = map[req]; 49899 if(!(id + 1)) // check for number or string 49900 throw new Error("Cannot find module '" + req + "'."); 49901 return id; 49902}; 49903webpackContext.keys = function webpackContextKeys() { 49904 return Object.keys(map); 49905}; 49906webpackContext.resolve = webpackContextResolve; 49907module.exports = webpackContext; 49908webpackContext.id = 409; 49909 49910/***/ }), 49911/* 410 */ 49912/***/ (function(module, exports, __webpack_require__) { 49913 49914/*! 49915 * Pikaday 49916 * 49917 * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday 49918 */ 49919 49920(function (root, factory) 49921{ 49922 'use strict'; 49923 49924 var moment; 49925 if (true) { 49926 // CommonJS module 49927 // Load moment.js as an optional dependency 49928 try { moment = __webpack_require__(42); } catch (e) {} 49929 module.exports = factory(moment); 49930 } else if (typeof define === 'function' && define.amd) { 49931 // AMD. Register as an anonymous module. 49932 define(function (req) 49933 { 49934 // Load moment.js as an optional dependency 49935 var id = 'moment'; 49936 try { moment = req(id); } catch (e) {} 49937 return factory(moment); 49938 }); 49939 } else { 49940 root.Pikaday = factory(root.moment); 49941 } 49942}(this, function (moment) 49943{ 49944 'use strict'; 49945 49946 /** 49947 * feature detection and helper functions 49948 */ 49949 var hasMoment = typeof moment === 'function', 49950 49951 hasEventListeners = !!window.addEventListener, 49952 49953 document = window.document, 49954 49955 sto = window.setTimeout, 49956 49957 addEvent = function(el, e, callback, capture) 49958 { 49959 if (hasEventListeners) { 49960 el.addEventListener(e, callback, !!capture); 49961 } else { 49962 el.attachEvent('on' + e, callback); 49963 } 49964 }, 49965 49966 removeEvent = function(el, e, callback, capture) 49967 { 49968 if (hasEventListeners) { 49969 el.removeEventListener(e, callback, !!capture); 49970 } else { 49971 el.detachEvent('on' + e, callback); 49972 } 49973 }, 49974 49975 fireEvent = function(el, eventName, data) 49976 { 49977 var ev; 49978 49979 if (document.createEvent) { 49980 ev = document.createEvent('HTMLEvents'); 49981 ev.initEvent(eventName, true, false); 49982 ev = extend(ev, data); 49983 el.dispatchEvent(ev); 49984 } else if (document.createEventObject) { 49985 ev = document.createEventObject(); 49986 ev = extend(ev, data); 49987 el.fireEvent('on' + eventName, ev); 49988 } 49989 }, 49990 49991 trim = function(str) 49992 { 49993 return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,''); 49994 }, 49995 49996 hasClass = function(el, cn) 49997 { 49998 return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1; 49999 }, 50000 50001 addClass = function(el, cn) 50002 { 50003 if (!hasClass(el, cn)) { 50004 el.className = (el.className === '') ? cn : el.className + ' ' + cn; 50005 } 50006 }, 50007 50008 removeClass = function(el, cn) 50009 { 50010 el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' ')); 50011 }, 50012 50013 isArray = function(obj) 50014 { 50015 return (/Array/).test(Object.prototype.toString.call(obj)); 50016 }, 50017 50018 isDate = function(obj) 50019 { 50020 return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime()); 50021 }, 50022 50023 isWeekend = function(date) 50024 { 50025 var day = date.getDay(); 50026 return day === 0 || day === 6; 50027 }, 50028 50029 isLeapYear = function(year) 50030 { 50031 // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951 50032 return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; 50033 }, 50034 50035 getDaysInMonth = function(year, month) 50036 { 50037 return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; 50038 }, 50039 50040 setToStartOfDay = function(date) 50041 { 50042 if (isDate(date)) date.setHours(0,0,0,0); 50043 }, 50044 50045 compareDates = function(a,b) 50046 { 50047 // weak date comparison (use setToStartOfDay(date) to ensure correct result) 50048 return a.getTime() === b.getTime(); 50049 }, 50050 50051 extend = function(to, from, overwrite) 50052 { 50053 var prop, hasProp; 50054 for (prop in from) { 50055 hasProp = to[prop] !== undefined; 50056 if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) { 50057 if (isDate(from[prop])) { 50058 if (overwrite) { 50059 to[prop] = new Date(from[prop].getTime()); 50060 } 50061 } 50062 else if (isArray(from[prop])) { 50063 if (overwrite) { 50064 to[prop] = from[prop].slice(0); 50065 } 50066 } else { 50067 to[prop] = extend({}, from[prop], overwrite); 50068 } 50069 } else if (overwrite || !hasProp) { 50070 to[prop] = from[prop]; 50071 } 50072 } 50073 return to; 50074 }, 50075 50076 adjustCalendar = function(calendar) { 50077 if (calendar.month < 0) { 50078 calendar.year -= Math.ceil(Math.abs(calendar.month)/12); 50079 calendar.month += 12; 50080 } 50081 if (calendar.month > 11) { 50082 calendar.year += Math.floor(Math.abs(calendar.month)/12); 50083 calendar.month -= 12; 50084 } 50085 return calendar; 50086 }, 50087 50088 /** 50089 * defaults and localisation 50090 */ 50091 defaults = { 50092 50093 // bind the picker to a form field 50094 field: null, 50095 50096 // automatically show/hide the picker on `field` focus (default `true` if `field` is set) 50097 bound: undefined, 50098 50099 // position of the datepicker, relative to the field (default to bottom & left) 50100 // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position) 50101 position: 'bottom left', 50102 50103 // automatically fit in the viewport even if it means repositioning from the position option 50104 reposition: true, 50105 50106 // the default output format for `.toString()` and `field` value 50107 format: 'YYYY-MM-DD', 50108 50109 // the initial date to view when first opened 50110 defaultDate: null, 50111 50112 // make the `defaultDate` the initial selected value 50113 setDefaultDate: false, 50114 50115 // first day of week (0: Sunday, 1: Monday etc) 50116 firstDay: 0, 50117 50118 // the default flag for moment's strict date parsing 50119 formatStrict: false, 50120 50121 // the minimum/earliest date that can be selected 50122 minDate: null, 50123 // the maximum/latest date that can be selected 50124 maxDate: null, 50125 50126 // number of years either side, or array of upper/lower range 50127 yearRange: 10, 50128 50129 // show week numbers at head of row 50130 showWeekNumber: false, 50131 50132 // used internally (don't config outside) 50133 minYear: 0, 50134 maxYear: 9999, 50135 minMonth: undefined, 50136 maxMonth: undefined, 50137 50138 startRange: null, 50139 endRange: null, 50140 50141 isRTL: false, 50142 50143 // Additional text to append to the year in the calendar title 50144 yearSuffix: '', 50145 50146 // Render the month after year in the calendar title 50147 showMonthAfterYear: false, 50148 50149 // Render days of the calendar grid that fall in the next or previous month 50150 showDaysInNextAndPreviousMonths: false, 50151 50152 // how many months are visible 50153 numberOfMonths: 1, 50154 50155 // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`) 50156 // only used for the first display or when a selected date is not visible 50157 mainCalendar: 'left', 50158 50159 // Specify a DOM element to render the calendar in 50160 container: undefined, 50161 50162 // internationalization 50163 i18n: { 50164 previousMonth : 'Previous Month', 50165 nextMonth : 'Next Month', 50166 months : ['January','February','March','April','May','June','July','August','September','October','November','December'], 50167 weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], 50168 weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] 50169 }, 50170 50171 // Theme Classname 50172 theme: null, 50173 50174 // callback function 50175 onSelect: null, 50176 onOpen: null, 50177 onClose: null, 50178 onDraw: null 50179 }, 50180 50181 50182 /** 50183 * templating functions to abstract HTML rendering 50184 */ 50185 renderDayName = function(opts, day, abbr) 50186 { 50187 day += opts.firstDay; 50188 while (day >= 7) { 50189 day -= 7; 50190 } 50191 return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day]; 50192 }, 50193 50194 renderDay = function(opts) 50195 { 50196 var arr = []; 50197 var ariaSelected = 'false'; 50198 if (opts.isEmpty) { 50199 if (opts.showDaysInNextAndPreviousMonths) { 50200 arr.push('is-outside-current-month'); 50201 } else { 50202 return '<td class="is-empty"></td>'; 50203 } 50204 } 50205 if (opts.isDisabled) { 50206 arr.push('is-disabled'); 50207 } 50208 if (opts.isToday) { 50209 arr.push('is-today'); 50210 } 50211 if (opts.isSelected) { 50212 arr.push('is-selected'); 50213 ariaSelected = 'true'; 50214 } 50215 if (opts.isInRange) { 50216 arr.push('is-inrange'); 50217 } 50218 if (opts.isStartRange) { 50219 arr.push('is-startrange'); 50220 } 50221 if (opts.isEndRange) { 50222 arr.push('is-endrange'); 50223 } 50224 return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' + 50225 '<button class="pika-button pika-day" type="button" ' + 50226 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' + 50227 opts.day + 50228 '</button>' + 50229 '</td>'; 50230 }, 50231 50232 renderWeek = function (d, m, y) { 50233 // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified. 50234 var onejan = new Date(y, 0, 1), 50235 weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7); 50236 return '<td class="pika-week">' + weekNum + '</td>'; 50237 }, 50238 50239 renderRow = function(days, isRTL) 50240 { 50241 return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>'; 50242 }, 50243 50244 renderBody = function(rows) 50245 { 50246 return '<tbody>' + rows.join('') + '</tbody>'; 50247 }, 50248 50249 renderHead = function(opts) 50250 { 50251 var i, arr = []; 50252 if (opts.showWeekNumber) { 50253 arr.push('<th></th>'); 50254 } 50255 for (i = 0; i < 7; i++) { 50256 arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>'); 50257 } 50258 return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>'; 50259 }, 50260 50261 renderTitle = function(instance, c, year, month, refYear, randId) 50262 { 50263 var i, j, arr, 50264 opts = instance._o, 50265 isMinYear = year === opts.minYear, 50266 isMaxYear = year === opts.maxYear, 50267 html = '<div id="' + randId + '" class="pika-title" role="heading" aria-live="assertive">', 50268 monthHtml, 50269 yearHtml, 50270 prev = true, 50271 next = true; 50272 50273 for (arr = [], i = 0; i < 12; i++) { 50274 arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' + 50275 (i === month ? ' selected="selected"': '') + 50276 ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled="disabled"' : '') + '>' + 50277 opts.i18n.months[i] + '</option>'); 50278 } 50279 50280 monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>'; 50281 50282 if (isArray(opts.yearRange)) { 50283 i = opts.yearRange[0]; 50284 j = opts.yearRange[1] + 1; 50285 } else { 50286 i = year - opts.yearRange; 50287 j = 1 + year + opts.yearRange; 50288 } 50289 50290 for (arr = []; i < j && i <= opts.maxYear; i++) { 50291 if (i >= opts.minYear) { 50292 arr.push('<option value="' + i + '"' + (i === year ? ' selected="selected"': '') + '>' + (i) + '</option>'); 50293 } 50294 } 50295 yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>'; 50296 50297 if (opts.showMonthAfterYear) { 50298 html += yearHtml + monthHtml; 50299 } else { 50300 html += monthHtml + yearHtml; 50301 } 50302 50303 if (isMinYear && (month === 0 || opts.minMonth >= month)) { 50304 prev = false; 50305 } 50306 50307 if (isMaxYear && (month === 11 || opts.maxMonth <= month)) { 50308 next = false; 50309 } 50310 50311 if (c === 0) { 50312 html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>'; 50313 } 50314 if (c === (instance._o.numberOfMonths - 1) ) { 50315 html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>'; 50316 } 50317 50318 return html += '</div>'; 50319 }, 50320 50321 renderTable = function(opts, data, randId) 50322 { 50323 return '<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="' + randId + '">' + renderHead(opts) + renderBody(data) + '</table>'; 50324 }, 50325 50326 50327 /** 50328 * Pikaday constructor 50329 */ 50330 Pikaday = function(options) 50331 { 50332 var self = this, 50333 opts = self.config(options); 50334 50335 self._onMouseDown = function(e) 50336 { 50337 if (!self._v) { 50338 return; 50339 } 50340 e = e || window.event; 50341 var target = e.target || e.srcElement; 50342 if (!target) { 50343 return; 50344 } 50345 50346 if (!hasClass(target, 'is-disabled')) { 50347 if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty') && !hasClass(target.parentNode, 'is-disabled')) { 50348 self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day'))); 50349 if (opts.bound) { 50350 sto(function() { 50351 self.hide(); 50352 if (opts.field) { 50353 opts.field.blur(); 50354 } 50355 }, 100); 50356 } 50357 } 50358 else if (hasClass(target, 'pika-prev')) { 50359 self.prevMonth(); 50360 } 50361 else if (hasClass(target, 'pika-next')) { 50362 self.nextMonth(); 50363 } 50364 } 50365 if (!hasClass(target, 'pika-select')) { 50366 // if this is touch event prevent mouse events emulation 50367 if (e.preventDefault) { 50368 e.preventDefault(); 50369 } else { 50370 e.returnValue = false; 50371 return false; 50372 } 50373 } else { 50374 self._c = true; 50375 } 50376 }; 50377 50378 self._onChange = function(e) 50379 { 50380 e = e || window.event; 50381 var target = e.target || e.srcElement; 50382 if (!target) { 50383 return; 50384 } 50385 if (hasClass(target, 'pika-select-month')) { 50386 self.gotoMonth(target.value); 50387 } 50388 else if (hasClass(target, 'pika-select-year')) { 50389 self.gotoYear(target.value); 50390 } 50391 }; 50392 50393 self._onKeyChange = function(e) 50394 { 50395 e = e || window.event; 50396 50397 if (self.isVisible()) { 50398 50399 switch(e.keyCode){ 50400 case 13: 50401 case 27: 50402 opts.field.blur(); 50403 break; 50404 case 37: 50405 e.preventDefault(); 50406 self.adjustDate('subtract', 1); 50407 break; 50408 case 38: 50409 self.adjustDate('subtract', 7); 50410 break; 50411 case 39: 50412 self.adjustDate('add', 1); 50413 break; 50414 case 40: 50415 self.adjustDate('add', 7); 50416 break; 50417 } 50418 } 50419 }; 50420 50421 self._onInputChange = function(e) 50422 { 50423 var date; 50424 50425 if (e.firedBy === self) { 50426 return; 50427 } 50428 if (hasMoment) { 50429 date = moment(opts.field.value, opts.format, opts.formatStrict); 50430 date = (date && date.isValid()) ? date.toDate() : null; 50431 } 50432 else { 50433 date = new Date(Date.parse(opts.field.value)); 50434 } 50435 if (isDate(date)) { 50436 self.setDate(date); 50437 } 50438 if (!self._v) { 50439 self.show(); 50440 } 50441 }; 50442 50443 self._onInputFocus = function() 50444 { 50445 self.show(); 50446 }; 50447 50448 self._onInputClick = function() 50449 { 50450 self.show(); 50451 }; 50452 50453 self._onInputBlur = function() 50454 { 50455 // IE allows pika div to gain focus; catch blur the input field 50456 var pEl = document.activeElement; 50457 do { 50458 if (hasClass(pEl, 'pika-single')) { 50459 return; 50460 } 50461 } 50462 while ((pEl = pEl.parentNode)); 50463 50464 if (!self._c) { 50465 self._b = sto(function() { 50466 self.hide(); 50467 }, 50); 50468 } 50469 self._c = false; 50470 }; 50471 50472 self._onClick = function(e) 50473 { 50474 e = e || window.event; 50475 var target = e.target || e.srcElement, 50476 pEl = target; 50477 if (!target) { 50478 return; 50479 } 50480 if (!hasEventListeners && hasClass(target, 'pika-select')) { 50481 if (!target.onchange) { 50482 target.setAttribute('onchange', 'return;'); 50483 addEvent(target, 'change', self._onChange); 50484 } 50485 } 50486 do { 50487 if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) { 50488 return; 50489 } 50490 } 50491 while ((pEl = pEl.parentNode)); 50492 if (self._v && target !== opts.trigger && pEl !== opts.trigger) { 50493 self.hide(); 50494 } 50495 }; 50496 50497 self.el = document.createElement('div'); 50498 self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : ''); 50499 50500 addEvent(self.el, 'mousedown', self._onMouseDown, true); 50501 addEvent(self.el, 'touchend', self._onMouseDown, true); 50502 addEvent(self.el, 'change', self._onChange); 50503 addEvent(document, 'keydown', self._onKeyChange); 50504 50505 if (opts.field) { 50506 if (opts.container) { 50507 opts.container.appendChild(self.el); 50508 } else if (opts.bound) { 50509 document.body.appendChild(self.el); 50510 } else { 50511 opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling); 50512 } 50513 addEvent(opts.field, 'change', self._onInputChange); 50514 50515 if (!opts.defaultDate) { 50516 if (hasMoment && opts.field.value) { 50517 opts.defaultDate = moment(opts.field.value, opts.format).toDate(); 50518 } else { 50519 opts.defaultDate = new Date(Date.parse(opts.field.value)); 50520 } 50521 opts.setDefaultDate = true; 50522 } 50523 } 50524 50525 var defDate = opts.defaultDate; 50526 50527 if (isDate(defDate)) { 50528 if (opts.setDefaultDate) { 50529 self.setDate(defDate, true); 50530 } else { 50531 self.gotoDate(defDate); 50532 } 50533 } else { 50534 self.gotoDate(new Date()); 50535 } 50536 50537 if (opts.bound) { 50538 this.hide(); 50539 self.el.className += ' is-bound'; 50540 addEvent(opts.trigger, 'click', self._onInputClick); 50541 addEvent(opts.trigger, 'focus', self._onInputFocus); 50542 addEvent(opts.trigger, 'blur', self._onInputBlur); 50543 } else { 50544 this.show(); 50545 } 50546 }; 50547 50548 50549 /** 50550 * public Pikaday API 50551 */ 50552 Pikaday.prototype = { 50553 50554 50555 /** 50556 * configure functionality 50557 */ 50558 config: function(options) 50559 { 50560 if (!this._o) { 50561 this._o = extend({}, defaults, true); 50562 } 50563 50564 var opts = extend(this._o, options, true); 50565 50566 opts.isRTL = !!opts.isRTL; 50567 50568 opts.field = (opts.field && opts.field.nodeName) ? opts.field : null; 50569 50570 opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null; 50571 50572 opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field); 50573 50574 opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field; 50575 50576 opts.disableWeekends = !!opts.disableWeekends; 50577 50578 opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null; 50579 50580 var nom = parseInt(opts.numberOfMonths, 10) || 1; 50581 opts.numberOfMonths = nom > 4 ? 4 : nom; 50582 50583 if (!isDate(opts.minDate)) { 50584 opts.minDate = false; 50585 } 50586 if (!isDate(opts.maxDate)) { 50587 opts.maxDate = false; 50588 } 50589 if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) { 50590 opts.maxDate = opts.minDate = false; 50591 } 50592 if (opts.minDate) { 50593 this.setMinDate(opts.minDate); 50594 } 50595 if (opts.maxDate) { 50596 this.setMaxDate(opts.maxDate); 50597 } 50598 50599 if (isArray(opts.yearRange)) { 50600 var fallback = new Date().getFullYear() - 10; 50601 opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback; 50602 opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback; 50603 } else { 50604 opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange; 50605 if (opts.yearRange > 100) { 50606 opts.yearRange = 100; 50607 } 50608 } 50609 50610 return opts; 50611 }, 50612 50613 /** 50614 * return a formatted string of the current selection (using Moment.js if available) 50615 */ 50616 toString: function(format) 50617 { 50618 return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString(); 50619 }, 50620 50621 /** 50622 * return a Moment.js object of the current selection (if available) 50623 */ 50624 getMoment: function() 50625 { 50626 return hasMoment ? moment(this._d) : null; 50627 }, 50628 50629 /** 50630 * set the current selection from a Moment.js object (if available) 50631 */ 50632 setMoment: function(date, preventOnSelect) 50633 { 50634 if (hasMoment && moment.isMoment(date)) { 50635 this.setDate(date.toDate(), preventOnSelect); 50636 } 50637 }, 50638 50639 /** 50640 * return a Date object of the current selection with fallback for the current date 50641 */ 50642 getDate: function() 50643 { 50644 return isDate(this._d) ? new Date(this._d.getTime()) : new Date(); 50645 }, 50646 50647 /** 50648 * set the current selection 50649 */ 50650 setDate: function(date, preventOnSelect) 50651 { 50652 if (!date) { 50653 this._d = null; 50654 50655 if (this._o.field) { 50656 this._o.field.value = ''; 50657 fireEvent(this._o.field, 'change', { firedBy: this }); 50658 } 50659 50660 return this.draw(); 50661 } 50662 if (typeof date === 'string') { 50663 date = new Date(Date.parse(date)); 50664 } 50665 if (!isDate(date)) { 50666 return; 50667 } 50668 50669 var min = this._o.minDate, 50670 max = this._o.maxDate; 50671 50672 if (isDate(min) && date < min) { 50673 date = min; 50674 } else if (isDate(max) && date > max) { 50675 date = max; 50676 } 50677 50678 this._d = new Date(date.getTime()); 50679 setToStartOfDay(this._d); 50680 this.gotoDate(this._d); 50681 50682 if (this._o.field) { 50683 this._o.field.value = this.toString(); 50684 fireEvent(this._o.field, 'change', { firedBy: this }); 50685 } 50686 if (!preventOnSelect && typeof this._o.onSelect === 'function') { 50687 this._o.onSelect.call(this, this.getDate()); 50688 } 50689 }, 50690 50691 /** 50692 * change view to a specific date 50693 */ 50694 gotoDate: function(date) 50695 { 50696 var newCalendar = true; 50697 50698 if (!isDate(date)) { 50699 return; 50700 } 50701 50702 if (this.calendars) { 50703 var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1), 50704 lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1), 50705 visibleDate = date.getTime(); 50706 // get the end of the month 50707 lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1); 50708 lastVisibleDate.setDate(lastVisibleDate.getDate()-1); 50709 newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate); 50710 } 50711 50712 if (newCalendar) { 50713 this.calendars = [{ 50714 month: date.getMonth(), 50715 year: date.getFullYear() 50716 }]; 50717 if (this._o.mainCalendar === 'right') { 50718 this.calendars[0].month += 1 - this._o.numberOfMonths; 50719 } 50720 } 50721 50722 this.adjustCalendars(); 50723 }, 50724 50725 adjustDate: function(sign, days) { 50726 50727 var day = this.getDate(); 50728 var difference = parseInt(days)*24*60*60*1000; 50729 50730 var newDay; 50731 50732 if (sign === 'add') { 50733 newDay = new Date(day.valueOf() + difference); 50734 } else if (sign === 'subtract') { 50735 newDay = new Date(day.valueOf() - difference); 50736 } 50737 50738 if (hasMoment) { 50739 if (sign === 'add') { 50740 newDay = moment(day).add(days, "days").toDate(); 50741 } else if (sign === 'subtract') { 50742 newDay = moment(day).subtract(days, "days").toDate(); 50743 } 50744 } 50745 50746 this.setDate(newDay); 50747 }, 50748 50749 adjustCalendars: function() { 50750 this.calendars[0] = adjustCalendar(this.calendars[0]); 50751 for (var c = 1; c < this._o.numberOfMonths; c++) { 50752 this.calendars[c] = adjustCalendar({ 50753 month: this.calendars[0].month + c, 50754 year: this.calendars[0].year 50755 }); 50756 } 50757 this.draw(); 50758 }, 50759 50760 gotoToday: function() 50761 { 50762 this.gotoDate(new Date()); 50763 }, 50764 50765 /** 50766 * change view to a specific month (zero-index, e.g. 0: January) 50767 */ 50768 gotoMonth: function(month) 50769 { 50770 if (!isNaN(month)) { 50771 this.calendars[0].month = parseInt(month, 10); 50772 this.adjustCalendars(); 50773 } 50774 }, 50775 50776 nextMonth: function() 50777 { 50778 this.calendars[0].month++; 50779 this.adjustCalendars(); 50780 }, 50781 50782 prevMonth: function() 50783 { 50784 this.calendars[0].month--; 50785 this.adjustCalendars(); 50786 }, 50787 50788 /** 50789 * change view to a specific full year (e.g. "2012") 50790 */ 50791 gotoYear: function(year) 50792 { 50793 if (!isNaN(year)) { 50794 this.calendars[0].year = parseInt(year, 10); 50795 this.adjustCalendars(); 50796 } 50797 }, 50798 50799 /** 50800 * change the minDate 50801 */ 50802 setMinDate: function(value) 50803 { 50804 if(value instanceof Date) { 50805 setToStartOfDay(value); 50806 this._o.minDate = value; 50807 this._o.minYear = value.getFullYear(); 50808 this._o.minMonth = value.getMonth(); 50809 } else { 50810 this._o.minDate = defaults.minDate; 50811 this._o.minYear = defaults.minYear; 50812 this._o.minMonth = defaults.minMonth; 50813 this._o.startRange = defaults.startRange; 50814 } 50815 50816 this.draw(); 50817 }, 50818 50819 /** 50820 * change the maxDate 50821 */ 50822 setMaxDate: function(value) 50823 { 50824 if(value instanceof Date) { 50825 setToStartOfDay(value); 50826 this._o.maxDate = value; 50827 this._o.maxYear = value.getFullYear(); 50828 this._o.maxMonth = value.getMonth(); 50829 } else { 50830 this._o.maxDate = defaults.maxDate; 50831 this._o.maxYear = defaults.maxYear; 50832 this._o.maxMonth = defaults.maxMonth; 50833 this._o.endRange = defaults.endRange; 50834 } 50835 50836 this.draw(); 50837 }, 50838 50839 setStartRange: function(value) 50840 { 50841 this._o.startRange = value; 50842 }, 50843 50844 setEndRange: function(value) 50845 { 50846 this._o.endRange = value; 50847 }, 50848 50849 /** 50850 * refresh the HTML 50851 */ 50852 draw: function(force) 50853 { 50854 if (!this._v && !force) { 50855 return; 50856 } 50857 var opts = this._o, 50858 minYear = opts.minYear, 50859 maxYear = opts.maxYear, 50860 minMonth = opts.minMonth, 50861 maxMonth = opts.maxMonth, 50862 html = '', 50863 randId; 50864 50865 if (this._y <= minYear) { 50866 this._y = minYear; 50867 if (!isNaN(minMonth) && this._m < minMonth) { 50868 this._m = minMonth; 50869 } 50870 } 50871 if (this._y >= maxYear) { 50872 this._y = maxYear; 50873 if (!isNaN(maxMonth) && this._m > maxMonth) { 50874 this._m = maxMonth; 50875 } 50876 } 50877 50878 randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2); 50879 50880 for (var c = 0; c < opts.numberOfMonths; c++) { 50881 html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId) + '</div>'; 50882 } 50883 50884 this.el.innerHTML = html; 50885 50886 if (opts.bound) { 50887 if(opts.field.type !== 'hidden') { 50888 sto(function() { 50889 opts.trigger.focus(); 50890 }, 1); 50891 } 50892 } 50893 50894 if (typeof this._o.onDraw === 'function') { 50895 this._o.onDraw(this); 50896 } 50897 50898 if (opts.bound) { 50899 // let the screen reader user know to use arrow keys 50900 opts.field.setAttribute('aria-label', 'Use the arrow keys to pick a date'); 50901 } 50902 }, 50903 50904 adjustPosition: function() 50905 { 50906 var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect; 50907 50908 if (this._o.container) return; 50909 50910 this.el.style.position = 'absolute'; 50911 50912 field = this._o.trigger; 50913 pEl = field; 50914 width = this.el.offsetWidth; 50915 height = this.el.offsetHeight; 50916 viewportWidth = window.innerWidth || document.documentElement.clientWidth; 50917 viewportHeight = window.innerHeight || document.documentElement.clientHeight; 50918 scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop; 50919 50920 if (typeof field.getBoundingClientRect === 'function') { 50921 clientRect = field.getBoundingClientRect(); 50922 left = clientRect.left + window.pageXOffset; 50923 top = clientRect.bottom + window.pageYOffset; 50924 } else { 50925 left = pEl.offsetLeft; 50926 top = pEl.offsetTop + pEl.offsetHeight; 50927 while((pEl = pEl.offsetParent)) { 50928 left += pEl.offsetLeft; 50929 top += pEl.offsetTop; 50930 } 50931 } 50932 50933 // default position is bottom & left 50934 if ((this._o.reposition && left + width > viewportWidth) || 50935 ( 50936 this._o.position.indexOf('right') > -1 && 50937 left - width + field.offsetWidth > 0 50938 ) 50939 ) { 50940 left = left - width + field.offsetWidth; 50941 } 50942 if ((this._o.reposition && top + height > viewportHeight + scrollTop) || 50943 ( 50944 this._o.position.indexOf('top') > -1 && 50945 top - height - field.offsetHeight > 0 50946 ) 50947 ) { 50948 top = top - height - field.offsetHeight; 50949 } 50950 50951 this.el.style.left = left + 'px'; 50952 this.el.style.top = top + 'px'; 50953 }, 50954 50955 /** 50956 * render HTML for a particular month 50957 */ 50958 render: function(year, month, randId) 50959 { 50960 var opts = this._o, 50961 now = new Date(), 50962 days = getDaysInMonth(year, month), 50963 before = new Date(year, month, 1).getDay(), 50964 data = [], 50965 row = []; 50966 setToStartOfDay(now); 50967 if (opts.firstDay > 0) { 50968 before -= opts.firstDay; 50969 if (before < 0) { 50970 before += 7; 50971 } 50972 } 50973 var previousMonth = month === 0 ? 11 : month - 1, 50974 nextMonth = month === 11 ? 0 : month + 1, 50975 yearOfPreviousMonth = month === 0 ? year - 1 : year, 50976 yearOfNextMonth = month === 11 ? year + 1 : year, 50977 daysInPreviousMonth = getDaysInMonth(yearOfPreviousMonth, previousMonth); 50978 var cells = days + before, 50979 after = cells; 50980 while(after > 7) { 50981 after -= 7; 50982 } 50983 cells += 7 - after; 50984 for (var i = 0, r = 0; i < cells; i++) 50985 { 50986 var day = new Date(year, month, 1 + (i - before)), 50987 isSelected = isDate(this._d) ? compareDates(day, this._d) : false, 50988 isToday = compareDates(day, now), 50989 isEmpty = i < before || i >= (days + before), 50990 dayNumber = 1 + (i - before), 50991 monthNumber = month, 50992 yearNumber = year, 50993 isStartRange = opts.startRange && compareDates(opts.startRange, day), 50994 isEndRange = opts.endRange && compareDates(opts.endRange, day), 50995 isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange, 50996 isDisabled = (opts.minDate && day < opts.minDate) || 50997 (opts.maxDate && day > opts.maxDate) || 50998 (opts.disableWeekends && isWeekend(day)) || 50999 (opts.disableDayFn && opts.disableDayFn(day)); 51000 51001 if (isEmpty) { 51002 if (i < before) { 51003 dayNumber = daysInPreviousMonth + dayNumber; 51004 monthNumber = previousMonth; 51005 yearNumber = yearOfPreviousMonth; 51006 } else { 51007 dayNumber = dayNumber - days; 51008 monthNumber = nextMonth; 51009 yearNumber = yearOfNextMonth; 51010 } 51011 } 51012 51013 var dayConfig = { 51014 day: dayNumber, 51015 month: monthNumber, 51016 year: yearNumber, 51017 isSelected: isSelected, 51018 isToday: isToday, 51019 isDisabled: isDisabled, 51020 isEmpty: isEmpty, 51021 isStartRange: isStartRange, 51022 isEndRange: isEndRange, 51023 isInRange: isInRange, 51024 showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths 51025 }; 51026 51027 row.push(renderDay(dayConfig)); 51028 51029 if (++r === 7) { 51030 if (opts.showWeekNumber) { 51031 row.unshift(renderWeek(i - before, month, year)); 51032 } 51033 data.push(renderRow(row, opts.isRTL)); 51034 row = []; 51035 r = 0; 51036 } 51037 } 51038 return renderTable(opts, data, randId); 51039 }, 51040 51041 isVisible: function() 51042 { 51043 return this._v; 51044 }, 51045 51046 show: function() 51047 { 51048 if (!this.isVisible()) { 51049 removeClass(this.el, 'is-hidden'); 51050 this._v = true; 51051 this.draw(); 51052 if (this._o.bound) { 51053 addEvent(document, 'click', this._onClick); 51054 this.adjustPosition(); 51055 } 51056 if (typeof this._o.onOpen === 'function') { 51057 this._o.onOpen.call(this); 51058 } 51059 } 51060 }, 51061 51062 hide: function() 51063 { 51064 var v = this._v; 51065 if (v !== false) { 51066 if (this._o.bound) { 51067 removeEvent(document, 'click', this._onClick); 51068 } 51069 this.el.style.position = 'static'; // reset 51070 this.el.style.left = 'auto'; 51071 this.el.style.top = 'auto'; 51072 addClass(this.el, 'is-hidden'); 51073 this._v = false; 51074 if (v !== undefined && typeof this._o.onClose === 'function') { 51075 this._o.onClose.call(this); 51076 } 51077 } 51078 }, 51079 51080 /** 51081 * GAME OVER 51082 */ 51083 destroy: function() 51084 { 51085 this.hide(); 51086 removeEvent(this.el, 'mousedown', this._onMouseDown, true); 51087 removeEvent(this.el, 'touchend', this._onMouseDown, true); 51088 removeEvent(this.el, 'change', this._onChange); 51089 if (this._o.field) { 51090 removeEvent(this._o.field, 'change', this._onInputChange); 51091 if (this._o.bound) { 51092 removeEvent(this._o.trigger, 'click', this._onInputClick); 51093 removeEvent(this._o.trigger, 'focus', this._onInputFocus); 51094 removeEvent(this._o.trigger, 'blur', this._onInputBlur); 51095 } 51096 } 51097 if (this.el.parentNode) { 51098 this.el.parentNode.removeChild(this.el); 51099 } 51100 } 51101 51102 }; 51103 51104 return Pikaday; 51105 51106})); 51107 51108 51109/***/ }) 51110/******/ ]); 51111});