You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55987 lines
1.6 MiB

8 years ago
  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.33.0
  27. * Date: Mon Jul 10 2017 10:08:33 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() {
  39. return /******/ (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 = 323);
  105. /******/ })
  106. /************************************************************************/
  107. /******/ ([
  108. /* 0 */
  109. /***/ (function(module, exports, __webpack_require__) {
  110. "use strict";
  111. exports.__esModule = true;
  112. exports.HTML_CHARACTERS = undefined;
  113. exports.getParent = getParent;
  114. exports.closest = closest;
  115. exports.closestDown = closestDown;
  116. exports.isChildOf = isChildOf;
  117. exports.isChildOfWebComponentTable = isChildOfWebComponentTable;
  118. exports.polymerWrap = polymerWrap;
  119. exports.polymerUnwrap = polymerUnwrap;
  120. exports.index = index;
  121. exports.overlayContainsElement = overlayContainsElement;
  122. exports.hasClass = hasClass;
  123. exports.addClass = addClass;
  124. exports.removeClass = removeClass;
  125. exports.removeTextNodes = removeTextNodes;
  126. exports.empty = empty;
  127. exports.fastInnerHTML = fastInnerHTML;
  128. exports.fastInnerText = fastInnerText;
  129. exports.isVisible = isVisible;
  130. exports.offset = offset;
  131. exports.getWindowScrollTop = getWindowScrollTop;
  132. exports.getWindowScrollLeft = getWindowScrollLeft;
  133. exports.getScrollTop = getScrollTop;
  134. exports.getScrollLeft = getScrollLeft;
  135. exports.getScrollableElement = getScrollableElement;
  136. exports.getTrimmingContainer = getTrimmingContainer;
  137. exports.getStyle = getStyle;
  138. exports.getComputedStyle = getComputedStyle;
  139. exports.outerWidth = outerWidth;
  140. exports.outerHeight = outerHeight;
  141. exports.innerHeight = innerHeight;
  142. exports.innerWidth = innerWidth;
  143. exports.addEvent = addEvent;
  144. exports.removeEvent = removeEvent;
  145. exports.getCaretPosition = getCaretPosition;
  146. exports.getSelectionEndPosition = getSelectionEndPosition;
  147. exports.getSelectionText = getSelectionText;
  148. exports.setCaretPosition = setCaretPosition;
  149. exports.getScrollbarWidth = getScrollbarWidth;
  150. exports.hasVerticalScrollbar = hasVerticalScrollbar;
  151. exports.hasHorizontalScrollbar = hasHorizontalScrollbar;
  152. exports.setOverlayPosition = setOverlayPosition;
  153. exports.getCssTransform = getCssTransform;
  154. exports.resetCssTransform = resetCssTransform;
  155. exports.isInput = isInput;
  156. exports.isOutsideInput = isOutsideInput;
  157. var _browser = __webpack_require__(25);
  158. var _feature = __webpack_require__(34);
  159. /**
  160. * Get the parent of the specified node in the DOM tree.
  161. *
  162. * @param {HTMLElement} element Element from which traversing is started.
  163. * @param {Number} [level=0] Traversing deep level.
  164. * @return {HTMLElement|null}
  165. */
  166. function getParent(element) {
  167. var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  168. var iteration = -1;
  169. var parent = null;
  170. while (element != null) {
  171. if (iteration === level) {
  172. parent = element;
  173. break;
  174. }
  175. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  176. element = element.host;
  177. } else {
  178. iteration++;
  179. element = element.parentNode;
  180. }
  181. }
  182. return parent;
  183. }
  184. /**
  185. * Goes up the DOM tree (including given element) until it finds an element that matches the nodes or nodes name.
  186. * This method goes up through web components.
  187. *
  188. * @param {HTMLElement} element Element from which traversing is started
  189. * @param {Array} nodes Array of elements or Array of elements name
  190. * @param {HTMLElement} [until]
  191. * @returns {HTMLElement|null}
  192. */
  193. function closest(element, nodes, until) {
  194. while (element != null && element !== until) {
  195. if (element.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(element.nodeName) > -1 || nodes.indexOf(element) > -1)) {
  196. return element;
  197. }
  198. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  199. element = element.host;
  200. } else {
  201. element = element.parentNode;
  202. }
  203. }
  204. return null;
  205. }
  206. /**
  207. * Goes "down" the DOM tree (including given element) until it finds an element that matches the nodes or nodes name.
  208. *
  209. * @param {HTMLElement} element Element from which traversing is started
  210. * @param {Array} nodes Array of elements or Array of elements name
  211. * @param {HTMLElement} [until]
  212. * @returns {HTMLElement|null}
  213. */
  214. function closestDown(element, nodes, until) {
  215. var matched = [];
  216. while (element) {
  217. element = closest(element, nodes, until);
  218. if (!element || until && !until.contains(element)) {
  219. break;
  220. }
  221. matched.push(element);
  222. if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  223. element = element.host;
  224. } else {
  225. element = element.parentNode;
  226. }
  227. }
  228. var length = matched.length;
  229. return length ? matched[length - 1] : null;
  230. }
  231. /**
  232. * Goes up the DOM tree and checks if element is child of another element.
  233. *
  234. * @param child Child element
  235. * @param {Object|String} parent Parent element OR selector of the parent element.
  236. * If string provided, function returns `true` for the first occurrence of element with that class.
  237. * @returns {Boolean}
  238. */
  239. function isChildOf(child, parent) {
  240. var node = child.parentNode;
  241. var queriedParents = [];
  242. if (typeof parent === 'string') {
  243. queriedParents = Array.prototype.slice.call(document.querySelectorAll(parent), 0);
  244. } else {
  245. queriedParents.push(parent);
  246. }
  247. while (node != null) {
  248. if (queriedParents.indexOf(node) > -1) {
  249. return true;
  250. }
  251. node = node.parentNode;
  252. }
  253. return false;
  254. }
  255. /**
  256. * Check if an element is part of `hot-table` web component.
  257. *
  258. * @param {Element} element
  259. * @returns {Boolean}
  260. */
  261. function isChildOfWebComponentTable(element) {
  262. var hotTableName = 'hot-table',
  263. result = false,
  264. parentNode;
  265. parentNode = polymerWrap(element);
  266. function isHotTable(element) {
  267. return element.nodeType === Node.ELEMENT_NODE && element.nodeName === hotTableName.toUpperCase();
  268. }
  269. while (parentNode != null) {
  270. if (isHotTable(parentNode)) {
  271. result = true;
  272. break;
  273. } else if (parentNode.host && parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  274. result = isHotTable(parentNode.host);
  275. if (result) {
  276. break;
  277. }
  278. parentNode = parentNode.host;
  279. }
  280. parentNode = parentNode.parentNode;
  281. }
  282. return result;
  283. }
  284. /**
  285. * Wrap element into polymer/webcomponent container if exists
  286. *
  287. * @param element
  288. * @returns {*}
  289. */
  290. function polymerWrap(element) {
  291. /* global Polymer */
  292. return typeof Polymer !== 'undefined' && typeof wrap === 'function' ? wrap(element) : element;
  293. }
  294. /**
  295. * Unwrap element from polymer/webcomponent container if exists
  296. *
  297. * @param element
  298. * @returns {*}
  299. */
  300. function polymerUnwrap(element) {
  301. /* global Polymer */
  302. return typeof Polymer !== 'undefined' && typeof unwrap === 'function' ? unwrap(element) : element;
  303. }
  304. /**
  305. * Counts index of element within its parent
  306. * WARNING: for performance reasons, assumes there are only element nodes (no text nodes). This is true for Walkotnable
  307. * Otherwise would need to check for nodeType or use previousElementSibling
  308. *
  309. * @see http://jsperf.com/sibling-index/10
  310. * @param {Element} element
  311. * @return {Number}
  312. */
  313. function index(element) {
  314. var i = 0;
  315. if (element.previousSibling) {
  316. /* eslint-disable no-cond-assign */
  317. while (element = element.previousSibling) {
  318. ++i;
  319. }
  320. }
  321. return i;
  322. }
  323. /**
  324. * Check if the provided overlay contains the provided element
  325. *
  326. * @param {String} overlay
  327. * @param {HTMLElement} element
  328. * @returns {boolean}
  329. */
  330. function overlayContainsElement(overlayType, element) {
  331. var overlayElement = document.querySelector('.ht_clone_' + overlayType);
  332. return overlayElement ? overlayElement.contains(element) : null;
  333. }
  334. var classListSupport = !!document.documentElement.classList;
  335. var _hasClass, _addClass, _removeClass;
  336. function filterEmptyClassNames(classNames) {
  337. var len = 0,
  338. result = [];
  339. if (!classNames || !classNames.length) {
  340. return result;
  341. }
  342. while (classNames[len]) {
  343. result.push(classNames[len]);
  344. len++;
  345. }
  346. return result;
  347. }
  348. if (classListSupport) {
  349. var isSupportMultipleClassesArg = function () {
  350. var element = document.createElement('div');
  351. element.classList.add('test', 'test2');
  352. return element.classList.contains('test2');
  353. }();
  354. _hasClass = function _hasClass(element, className) {
  355. if (className === '') {
  356. return false;
  357. }
  358. return element.classList.contains(className);
  359. };
  360. _addClass = function _addClass(element, className) {
  361. var len = 0;
  362. if (typeof className === 'string') {
  363. className = className.split(' ');
  364. }
  365. className = filterEmptyClassNames(className);
  366. if (isSupportMultipleClassesArg) {
  367. element.classList.add.apply(element.classList, className);
  368. } else {
  369. while (className && className[len]) {
  370. element.classList.add(className[len]);
  371. len++;
  372. }
  373. }
  374. };
  375. _removeClass = function _removeClass(element, className) {
  376. var len = 0;
  377. if (typeof className === 'string') {
  378. className = className.split(' ');
  379. }
  380. className = filterEmptyClassNames(className);
  381. if (isSupportMultipleClassesArg) {
  382. element.classList.remove.apply(element.classList, className);
  383. } else {
  384. while (className && className[len]) {
  385. element.classList.remove(className[len]);
  386. len++;
  387. }
  388. }
  389. };
  390. } else {
  391. var createClassNameRegExp = function createClassNameRegExp(className) {
  392. return new RegExp('(\\s|^)' + className + '(\\s|$)');
  393. };
  394. _hasClass = function _hasClass(element, className) {
  395. // http://snipplr.com/view/3561/addclass-removeclass-hasclass/
  396. return !!element.className.match(createClassNameRegExp(className));
  397. };
  398. _addClass = function _addClass(element, className) {
  399. var len = 0,
  400. _className = element.className;
  401. if (typeof className === 'string') {
  402. className = className.split(' ');
  403. }
  404. if (_className === '') {
  405. _className = className.join(' ');
  406. } else {
  407. while (className && className[len]) {
  408. if (!createClassNameRegExp(className[len]).test(_className)) {
  409. _className += ' ' + className[len];
  410. }
  411. len++;
  412. }
  413. }
  414. element.className = _className;
  415. };
  416. _removeClass = function _removeClass(element, className) {
  417. var len = 0,
  418. _className = element.className;
  419. if (typeof className === 'string') {
  420. className = className.split(' ');
  421. }
  422. while (className && className[len]) {
  423. // String.prototype.trim is defined in polyfill.js
  424. _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim();
  425. len++;
  426. }
  427. if (element.className !== _className) {
  428. element.className = _className;
  429. }
  430. };
  431. }
  432. /**
  433. * Checks if element has class name
  434. *
  435. * @param {HTMLElement} element
  436. * @param {String} className Class name to check
  437. * @returns {Boolean}
  438. */
  439. function hasClass(element, className) {
  440. return _hasClass(element, className);
  441. }
  442. /**
  443. * Add class name to an element
  444. *
  445. * @param {HTMLElement} element
  446. * @param {String|Array} className Class name as string or array of strings
  447. */
  448. function addClass(element, className) {
  449. return _addClass(element, className);
  450. }
  451. /**
  452. * Remove class name from an element
  453. *
  454. * @param {HTMLElement} element
  455. * @param {String|Array} className Class name as string or array of strings
  456. */
  457. function removeClass(element, className) {
  458. return _removeClass(element, className);
  459. }
  460. function removeTextNodes(element, parent) {
  461. if (element.nodeType === 3) {
  462. parent.removeChild(element); // bye text nodes!
  463. } else if (['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR'].indexOf(element.nodeName) > -1) {
  464. var childs = element.childNodes;
  465. for (var i = childs.length - 1; i >= 0; i--) {
  466. removeTextNodes(childs[i], element);
  467. }
  468. }
  469. }
  470. /**
  471. * Remove childs function
  472. * WARNING - this doesn't unload events and data attached by jQuery
  473. * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/9
  474. * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/11 - no siginificant improvement with Chrome remove() method
  475. *
  476. * @param element
  477. * @returns {void}
  478. */
  479. //
  480. function empty(element) {
  481. var child;
  482. /* eslint-disable no-cond-assign */
  483. while (child = element.lastChild) {
  484. element.removeChild(child);
  485. }
  486. }
  487. var HTML_CHARACTERS = exports.HTML_CHARACTERS = /(<(.*)>|&(.*);)/;
  488. /**
  489. * Insert content into element trying avoid innerHTML method.
  490. * @return {void}
  491. */
  492. function fastInnerHTML(element, content) {
  493. if (HTML_CHARACTERS.test(content)) {
  494. element.innerHTML = content;
  495. } else {
  496. fastInnerText(element, content);
  497. }
  498. }
  499. /**
  500. * Insert text content into element
  501. * @return {void}
  502. */
  503. var textContextSupport = !!document.createTextNode('test').textContent;
  504. function fastInnerText(element, content) {
  505. var child = element.firstChild;
  506. if (child && child.nodeType === 3 && child.nextSibling === null) {
  507. // fast lane - replace existing text node
  508. if (textContextSupport) {
  509. // http://jsperf.com/replace-text-vs-reuse
  510. child.textContent = content;
  511. } else {
  512. // http://jsperf.com/replace-text-vs-reuse
  513. child.data = content;
  514. }
  515. } else {
  516. // slow lane - empty element and insert a text node
  517. empty(element);
  518. element.appendChild(document.createTextNode(content));
  519. }
  520. }
  521. /**
  522. * Returns true if element is attached to the DOM and visible, false otherwise
  523. * @param elem
  524. * @returns {boolean}
  525. */
  526. function isVisible(elem) {
  527. var next = elem;
  528. while (polymerUnwrap(next) !== document.documentElement) {
  529. // until <html> reached
  530. if (next === null) {
  531. // parent detached from DOM
  532. return false;
  533. } else if (next.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  534. if (next.host) {
  535. // this is Web Components Shadow DOM
  536. // see: http://w3c.github.io/webcomponents/spec/shadow/#encapsulation
  537. // according to spec, should be if (next.ownerDocument !== window.document), but that doesn't work yet
  538. if (next.host.impl) {
  539. // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features disabled
  540. return isVisible(next.host.impl);
  541. } else if (next.host) {
  542. // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features enabled
  543. return isVisible(next.host);
  544. }
  545. throw new Error('Lost in Web Components world');
  546. } else {
  547. return false; // this is a node detached from document in IE8
  548. }
  549. } else if (next.style.display === 'none') {
  550. return false;
  551. }
  552. next = next.parentNode;
  553. }
  554. return true;
  555. }
  556. /**
  557. * Returns elements top and left offset relative to the document. Function is not compatible with jQuery offset.
  558. *
  559. * @param {HTMLElement} elem
  560. * @return {Object} Returns object with `top` and `left` props
  561. */
  562. function offset(elem) {
  563. var offsetLeft, offsetTop, lastElem, docElem, box;
  564. docElem = document.documentElement;
  565. if ((0, _feature.hasCaptionProblem)() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  566. // fixes problem with Firefox ignoring <caption> in TABLE offset (see also export outerHeight)
  567. // http://jsperf.com/offset-vs-getboundingclientrect/8
  568. box = elem.getBoundingClientRect();
  569. return {
  570. top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
  571. left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
  572. };
  573. }
  574. offsetLeft = elem.offsetLeft;
  575. offsetTop = elem.offsetTop;
  576. lastElem = elem;
  577. /* eslint-disable no-cond-assign */
  578. while (elem = elem.offsetParent) {
  579. // from my observation, document.body always has scrollLeft/scrollTop == 0
  580. if (elem === document.body) {
  581. break;
  582. }
  583. offsetLeft += elem.offsetLeft;
  584. offsetTop += elem.offsetTop;
  585. lastElem = elem;
  586. }
  587. // slow - http://jsperf.com/offset-vs-getboundingclientrect/6
  588. if (lastElem && lastElem.style.position === 'fixed') {
  589. // if(lastElem !== document.body) { //faster but does gives false positive in Firefox
  590. offsetLeft += window.pageXOffset || docElem.scrollLeft;
  591. offsetTop += window.pageYOffset || docElem.scrollTop;
  592. }
  593. return {
  594. left: offsetLeft,
  595. top: offsetTop
  596. };
  597. }
  598. /**
  599. * Returns the document's scrollTop property.
  600. *
  601. * @returns {Number}
  602. */
  603. function getWindowScrollTop() {
  604. var res = window.scrollY;
  605. if (res === void 0) {
  606. // IE8-11
  607. res = document.documentElement.scrollTop;
  608. }
  609. return res;
  610. }
  611. /**
  612. * Returns the document's scrollLeft property.
  613. *
  614. * @returns {Number}
  615. */
  616. function getWindowScrollLeft() {
  617. var res = window.scrollX;
  618. if (res === void 0) {
  619. // IE8-11
  620. res = document.documentElement.scrollLeft;
  621. }
  622. return res;
  623. }
  624. /**
  625. * Returns the provided element's scrollTop property.
  626. *
  627. * @param element
  628. * @returns {Number}
  629. */
  630. function getScrollTop(element) {
  631. if (element === window) {
  632. return getWindowScrollTop();
  633. }
  634. return element.scrollTop;
  635. }
  636. /**
  637. * Returns the provided element's scrollLeft property.
  638. *
  639. * @param element
  640. * @returns {Number}
  641. */
  642. function getScrollLeft(element) {
  643. if (element === window) {
  644. return getWindowScrollLeft();
  645. }
  646. return element.scrollLeft;
  647. }
  648. /**
  649. * Returns a DOM element responsible for scrolling of the provided element.
  650. *
  651. * @param {HTMLElement} element
  652. * @returns {HTMLElement} Element's scrollable parent
  653. */
  654. function getScrollableElement(element) {
  655. var el = element.parentNode,
  656. props = ['auto', 'scroll'],
  657. overflow,
  658. overflowX,
  659. overflowY,
  660. computedStyle = '',
  661. computedOverflow = '',
  662. computedOverflowY = '',
  663. computedOverflowX = '';
  664. while (el && el.style && document.body !== el) {
  665. overflow = el.style.overflow;
  666. overflowX = el.style.overflowX;
  667. overflowY = el.style.overflowY;
  668. if (overflow == 'scroll' || overflowX == 'scroll' || overflowY == 'scroll') {
  669. return el;
  670. } else if (window.getComputedStyle) {
  671. computedStyle = window.getComputedStyle(el);
  672. computedOverflow = computedStyle.getPropertyValue('overflow');
  673. computedOverflowY = computedStyle.getPropertyValue('overflow-y');
  674. computedOverflowX = computedStyle.getPropertyValue('overflow-x');
  675. if (computedOverflow === 'scroll' || computedOverflowX === 'scroll' || computedOverflowY === 'scroll') {
  676. return el;
  677. }
  678. }
  679. if (el.clientHeight <= el.scrollHeight && (props.indexOf(overflowY) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowY) !== -1)) {
  680. return el;
  681. }
  682. if (el.clientWidth <= el.scrollWidth && (props.indexOf(overflowX) !== -1 || props.indexOf(overflow) !== -1 || props.indexOf(computedOverflow) !== -1 || props.indexOf(computedOverflowX) !== -1)) {
  683. return el;
  684. }
  685. el = el.parentNode;
  686. }
  687. return window;
  688. }
  689. /**
  690. * Returns a DOM element responsible for trimming the provided element.
  691. *
  692. * @param {HTMLElement} base Base element
  693. * @returns {HTMLElement} Base element's trimming parent
  694. */
  695. function getTrimmingContainer(base) {
  696. var el = base.parentNode;
  697. while (el && el.style && document.body !== el) {
  698. if (el.style.overflow !== 'visible' && el.style.overflow !== '') {
  699. return el;
  700. } else if (window.getComputedStyle) {
  701. var computedStyle = window.getComputedStyle(el);
  702. if (computedStyle.getPropertyValue('overflow') !== 'visible' && computedStyle.getPropertyValue('overflow') !== '') {
  703. return el;
  704. }
  705. }
  706. el = el.parentNode;
  707. }
  708. return window;
  709. }
  710. /**
  711. * Returns a style property for the provided element. (Be it an inline or external style).
  712. *
  713. * @param {HTMLElement} element
  714. * @param {String} prop Wanted property
  715. * @returns {String|undefined} Element's style property
  716. */
  717. function getStyle(element, prop) {
  718. /* eslint-disable */
  719. if (!element) {
  720. return;
  721. } else if (element === window) {
  722. if (prop === 'width') {
  723. return window.innerWidth + 'px';
  724. } else if (prop === 'height') {
  725. return window.innerHeight + 'px';
  726. }
  727. return;
  728. }
  729. var styleProp = element.style[prop],
  730. computedStyle;
  731. if (styleProp !== '' && styleProp !== void 0) {
  732. return styleProp;
  733. } else {
  734. computedStyle = getComputedStyle(element);
  735. if (computedStyle[prop] !== '' && computedStyle[prop] !== void 0) {
  736. return computedStyle[prop];
  737. }
  738. }
  739. }
  740. /**
  741. * Returns a computed style object for the provided element. (Needed if style is declared in external stylesheet).
  742. *
  743. * @param element
  744. * @returns {IEElementStyle|CssStyle} Elements computed style object
  745. */
  746. function getComputedStyle(element) {
  747. return element.currentStyle || document.defaultView.getComputedStyle(element);
  748. }
  749. /**
  750. * Returns the element's outer width.
  751. *
  752. * @param element
  753. * @returns {number} Element's outer width
  754. */
  755. function outerWidth(element) {
  756. return element.offsetWidth;
  757. }
  758. /**
  759. * Returns the element's outer height
  760. *
  761. * @param elem
  762. * @returns {number} Element's outer height
  763. */
  764. function outerHeight(elem) {
  765. if ((0, _feature.hasCaptionProblem)() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') {
  766. // fixes problem with Firefox ignoring <caption> in TABLE.offsetHeight
  767. // jQuery (1.10.1) still has this unsolved
  768. // may be better to just switch to getBoundingClientRect
  769. // http://bililite.com/blog/2009/03/27/finding-the-size-of-a-table/
  770. // http://lists.w3.org/Archives/Public/www-style/2009Oct/0089.html
  771. // http://bugs.jquery.com/ticket/2196
  772. // http://lists.w3.org/Archives/Public/www-style/2009Oct/0140.html#start140
  773. return elem.offsetHeight + elem.firstChild.offsetHeight;
  774. }
  775. return elem.offsetHeight;
  776. }
  777. /**
  778. * Returns the element's inner height.
  779. *
  780. * @param element
  781. * @returns {number} Element's inner height
  782. */
  783. function innerHeight(element) {
  784. return element.clientHeight || element.innerHeight;
  785. }
  786. /**
  787. * Returns the element's inner width.
  788. *
  789. * @param element
  790. * @returns {number} Element's inner width
  791. */
  792. function innerWidth(element) {
  793. return element.clientWidth || element.innerWidth;
  794. }
  795. function addEvent(element, event, callback) {
  796. if (window.addEventListener) {
  797. element.addEventListener(event, callback, false);
  798. } else {
  799. element.attachEvent('on' + event, callback);
  800. }
  801. }
  802. function removeEvent(element, event, callback) {
  803. if (window.removeEventListener) {
  804. element.removeEventListener(event, callback, false);
  805. } else {
  806. element.detachEvent('on' + event, callback);
  807. }
  808. }
  809. /**
  810. * Returns caret position in text input
  811. *
  812. * @author http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea
  813. * @return {Number}
  814. */
  815. function getCaretPosition(el) {
  816. if (el.selectionStart) {
  817. return el.selectionStart;
  818. } else if (document.selection) {
  819. // IE8
  820. el.focus();
  821. var r = document.selection.createRange();
  822. if (r == null) {
  823. return 0;
  824. }
  825. var re = el.createTextRange();
  826. var rc = re.duplicate();
  827. re.moveToBookmark(r.getBookmark());
  828. rc.setEndPoint('EndToStart', re);
  829. return rc.text.length;
  830. }
  831. return 0;
  832. }
  833. /**
  834. * Returns end of the selection in text input
  835. *
  836. * @return {Number}
  837. */
  838. function getSelectionEndPosition(el) {
  839. if (el.selectionEnd) {
  840. return el.selectionEnd;
  841. } else if (document.selection) {
  842. // IE8
  843. var r = document.selection.createRange();
  844. if (r == null) {
  845. return 0;
  846. }
  847. var re = el.createTextRange();
  848. return re.text.indexOf(r.text) + r.text.length;
  849. }
  850. return 0;
  851. }
  852. /**
  853. * Returns text under selection.
  854. *
  855. * @returns {String}
  856. */
  857. function getSelectionText() {
  858. var text = '';
  859. if (window.getSelection) {
  860. text = window.getSelection().toString();
  861. } else if (document.selection && document.selection.type !== 'Control') {
  862. text = document.selection.createRange().text;
  863. }
  864. return text;
  865. }
  866. /**
  867. * Sets caret position in text input.
  868. *
  869. * @author http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/
  870. * @param {Element} element
  871. * @param {Number} pos
  872. * @param {Number} endPos
  873. */
  874. function setCaretPosition(element, pos, endPos) {
  875. if (endPos === void 0) {
  876. endPos = pos;
  877. }
  878. if (element.setSelectionRange) {
  879. element.focus();
  880. try {
  881. element.setSelectionRange(pos, endPos);
  882. } catch (err) {
  883. var elementParent = element.parentNode;
  884. var parentDisplayValue = elementParent.style.display;
  885. elementParent.style.display = 'block';
  886. element.setSelectionRange(pos, endPos);
  887. elementParent.style.display = parentDisplayValue;
  888. }
  889. } else if (element.createTextRange) {
  890. // IE8
  891. var range = element.createTextRange();
  892. range.collapse(true);
  893. range.moveEnd('character', endPos);
  894. range.moveStart('character', pos);
  895. range.select();
  896. }
  897. }
  898. var cachedScrollbarWidth;
  899. // http://stackoverflow.com/questions/986937/how-can-i-get-the-browsers-scrollbar-sizes
  900. function walkontableCalculateScrollbarWidth() {
  901. var inner = document.createElement('div');
  902. inner.style.height = '200px';
  903. inner.style.width = '100%';
  904. var outer = document.createElement('div');
  905. outer.style.boxSizing = 'content-box';
  906. outer.style.height = '150px';
  907. outer.style.left = '0px';
  908. outer.style.overflow = 'hidden';
  909. outer.style.position = 'absolute';
  910. outer.style.top = '0px';
  911. outer.style.width = '200px';
  912. outer.style.visibility = 'hidden';
  913. outer.appendChild(inner);
  914. (document.body || document.documentElement).appendChild(outer);
  915. var w1 = inner.offsetWidth;
  916. outer.style.overflow = 'scroll';
  917. var w2 = inner.offsetWidth;
  918. if (w1 == w2) {
  919. w2 = outer.clientWidth;
  920. }
  921. (document.body || document.documentElement).removeChild(outer);
  922. return w1 - w2;
  923. }
  924. /**
  925. * Returns the computed width of the native browser scroll bar.
  926. *
  927. * @return {Number} width
  928. */
  929. function getScrollbarWidth() {
  930. if (cachedScrollbarWidth === void 0) {
  931. cachedScrollbarWidth = walkontableCalculateScrollbarWidth();
  932. }
  933. return cachedScrollbarWidth;
  934. }
  935. /**
  936. * Checks if the provided element has a vertical scrollbar.
  937. *
  938. * @param {HTMLElement} element
  939. * @returns {Boolean}
  940. */
  941. function hasVerticalScrollbar(element) {
  942. return element.offsetWidth !== element.clientWidth;
  943. }
  944. /**
  945. * Checks if the provided element has a vertical scrollbar.
  946. *
  947. * @param {HTMLElement} element
  948. * @returns {Boolean}
  949. */
  950. function hasHorizontalScrollbar(element) {
  951. return element.offsetHeight !== element.clientHeight;
  952. }
  953. /**
  954. * Sets overlay position depending on it's type and used browser
  955. */
  956. function setOverlayPosition(overlayElem, left, top) {
  957. if ((0, _browser.isIE8)() || (0, _browser.isIE9)()) {
  958. overlayElem.style.top = top;
  959. overlayElem.style.left = left;
  960. } else if ((0, _browser.isSafari)()) {
  961. overlayElem.style['-webkit-transform'] = 'translate3d(' + left + ',' + top + ',0)';
  962. } else {
  963. overlayElem.style.transform = 'translate3d(' + left + ',' + top + ',0)';
  964. }
  965. }
  966. function getCssTransform(element) {
  967. var transform;
  968. if (element.style.transform && (transform = element.style.transform) !== '') {
  969. return ['transform', transform];
  970. } else if (element.style['-webkit-transform'] && (transform = element.style['-webkit-transform']) !== '') {
  971. return ['-webkit-transform', transform];
  972. }
  973. return -1;
  974. }
  975. function resetCssTransform(element) {
  976. if (element.style.transform && element.style.transform !== '') {
  977. element.style.transform = '';
  978. } else if (element.style['-webkit-transform'] && element.style['-webkit-transform'] !== '') {
  979. element.style['-webkit-transform'] = '';
  980. }
  981. }
  982. /**
  983. * Determines if the given DOM element is an input field.
  984. * Notice: By 'input' we mean input, textarea and select nodes
  985. *
  986. * @param {HTMLElement} element - DOM element
  987. * @returns {Boolean}
  988. */
  989. function isInput(element) {
  990. var inputs = ['INPUT', 'SELECT', 'TEXTAREA'];
  991. return element && (inputs.indexOf(element.nodeName) > -1 || element.contentEditable === 'true');
  992. }
  993. /**
  994. * Determines if the given DOM element is an input field placed OUTSIDE of HOT.
  995. * Notice: By 'input' we mean input, textarea and select nodes
  996. *
  997. * @param {HTMLElement} element - DOM element
  998. * @returns {Boolean}
  999. */
  1000. function isOutsideInput(element) {
  1001. return isInput(element) && element.className.indexOf('handsontableInput') == -1 && element.className.indexOf('copyPaste') == -1;
  1002. }
  1003. /***/ }),
  1004. /* 1 */
  1005. /***/ (function(module, exports, __webpack_require__) {
  1006. "use strict";
  1007. exports.__esModule = true;
  1008. var _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; };
  1009. exports.duckSchema = duckSchema;
  1010. exports.inherit = inherit;
  1011. exports.extend = extend;
  1012. exports.deepExtend = deepExtend;
  1013. exports.deepClone = deepClone;
  1014. exports.clone = clone;
  1015. exports.mixin = mixin;
  1016. exports.isObjectEquals = isObjectEquals;
  1017. exports.isObject = isObject;
  1018. exports.defineGetter = defineGetter;
  1019. exports.objectEach = objectEach;
  1020. exports.getProperty = getProperty;
  1021. exports.deepObjectSize = deepObjectSize;
  1022. exports.createObjectPropListener = createObjectPropListener;
  1023. exports.hasOwnProperty = hasOwnProperty;
  1024. var _array = __webpack_require__(2);
  1025. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  1026. /**
  1027. * Generate schema for passed object.
  1028. *
  1029. * @param {Array|Object} object
  1030. * @returns {Array|Object}
  1031. */
  1032. function duckSchema(object) {
  1033. var schema;
  1034. if (Array.isArray(object)) {
  1035. schema = [];
  1036. } else {
  1037. schema = {};
  1038. objectEach(object, function (value, key) {
  1039. if (key === '__children') {
  1040. return;
  1041. }
  1042. if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !Array.isArray(value)) {
  1043. schema[key] = duckSchema(value);
  1044. } else if (Array.isArray(value)) {
  1045. if (value.length && _typeof(value[0]) === 'object' && !Array.isArray(value[0])) {
  1046. schema[key] = [duckSchema(value[0])];
  1047. } else {
  1048. schema[key] = [];
  1049. }
  1050. } else {
  1051. schema[key] = null;
  1052. }
  1053. });
  1054. }
  1055. return schema;
  1056. }
  1057. /**
  1058. * Inherit without without calling parent constructor, and setting `Child.prototype.constructor` to `Child` instead of `Parent`.
  1059. * Creates temporary dummy function to call it as constructor.
  1060. * Described in ticket: https://github.com/handsontable/handsontable/pull/516
  1061. *
  1062. * @param {Object} Child child class
  1063. * @param {Object} Parent parent class
  1064. * @return {Object} extended Child
  1065. */
  1066. function inherit(Child, Parent) {
  1067. Parent.prototype.constructor = Parent;
  1068. Child.prototype = new Parent();
  1069. Child.prototype.constructor = Child;
  1070. return Child;
  1071. }
  1072. /**
  1073. * Perform shallow extend of a target object with extension's own properties.
  1074. *
  1075. * @param {Object} target An object that will receive the new properties.
  1076. * @param {Object} extension An object containing additional properties to merge into the target.
  1077. */
  1078. function extend(target, extension) {
  1079. objectEach(extension, function (value, key) {
  1080. target[key] = value;
  1081. });
  1082. return target;
  1083. }
  1084. /**
  1085. * Perform deep extend of a target object with extension's own properties.
  1086. *
  1087. * @param {Object} target An object that will receive the new properties.
  1088. * @param {Object} extension An object containing additional properties to merge into the target.
  1089. */
  1090. function deepExtend(target, extension) {
  1091. objectEach(extension, function (value, key) {
  1092. if (extension[key] && _typeof(extension[key]) === 'object') {
  1093. if (!target[key]) {
  1094. if (Array.isArray(extension[key])) {
  1095. target[key] = [];
  1096. } else if (Object.prototype.toString.call(extension[key]) === '[object Date]') {
  1097. target[key] = extension[key];
  1098. } else {
  1099. target[key] = {};
  1100. }
  1101. }
  1102. deepExtend(target[key], extension[key]);
  1103. } else {
  1104. target[key] = extension[key];
  1105. }
  1106. });
  1107. }
  1108. /**
  1109. * Perform deep clone of an object.
  1110. * WARNING! Only clones JSON properties. Will cause error when `obj` contains a function, Date, etc.
  1111. *
  1112. * @param {Object} obj An object that will be cloned
  1113. * @return {Object}
  1114. */
  1115. function deepClone(obj) {
  1116. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') {
  1117. return JSON.parse(JSON.stringify(obj));
  1118. }
  1119. return obj;
  1120. }
  1121. /**
  1122. * Shallow clone object.
  1123. *
  1124. * @param {Object} object
  1125. * @returns {Object}
  1126. */
  1127. function clone(object) {
  1128. var result = {};
  1129. objectEach(object, function (value, key) {
  1130. result[key] = value;
  1131. });
  1132. return result;
  1133. }
  1134. /**
  1135. * Extend the Base object (usually prototype) of the functionality the `mixins` objects.
  1136. *
  1137. * @param {Object} Base Base object which will be extended.
  1138. * @param {Object} mixins The object of the functionality will be "copied".
  1139. * @returns {Object}
  1140. */
  1141. function mixin(Base) {
  1142. if (!Base.MIXINS) {
  1143. Base.MIXINS = [];
  1144. }
  1145. for (var _len = arguments.length, mixins = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1146. mixins[_key - 1] = arguments[_key];
  1147. }
  1148. (0, _array.arrayEach)(mixins, function (mixin) {
  1149. Base.MIXINS.push(mixin.MIXIN_NAME);
  1150. objectEach(mixin, function (value, key) {
  1151. if (Base.prototype[key] !== void 0) {
  1152. throw new Error('Mixin conflict. Property \'' + key + '\' already exist and cannot be overwritten.');
  1153. }
  1154. if (typeof value === 'function') {
  1155. Base.prototype[key] = value;
  1156. } else {
  1157. var getter = function _getter(propertyName, initialValue) {
  1158. propertyName = '_' + propertyName;
  1159. var initValue = function initValue(value) {
  1160. if (Array.isArray(value) || isObject(value)) {
  1161. value = deepClone(value);
  1162. }
  1163. return value;
  1164. };
  1165. return function () {
  1166. if (this[propertyName] === void 0) {
  1167. this[propertyName] = initValue(initialValue);
  1168. }
  1169. return this[propertyName];
  1170. };
  1171. };
  1172. var setter = function _setter(propertyName) {
  1173. propertyName = '_' + propertyName;
  1174. return function (value) {
  1175. this[propertyName] = value;
  1176. };
  1177. };
  1178. Object.defineProperty(Base.prototype, key, {
  1179. get: getter(key, value),
  1180. set: setter(key),
  1181. configurable: true
  1182. });
  1183. }
  1184. });
  1185. });
  1186. return Base;
  1187. }
  1188. /**
  1189. * Checks if two objects or arrays are (deep) equal
  1190. *
  1191. * @param {Object|Array} object1
  1192. * @param {Object|Array} object2
  1193. * @returns {Boolean}
  1194. */
  1195. function isObjectEquals(object1, object2) {
  1196. return JSON.stringify(object1) === JSON.stringify(object2);
  1197. }
  1198. /**
  1199. * Determines whether given object is a plain Object.
  1200. * Note: String and Array are not plain Objects
  1201. * @param {*} obj
  1202. * @returns {boolean}
  1203. */
  1204. function isObject(obj) {
  1205. return Object.prototype.toString.call(obj) == '[object Object]';
  1206. }
  1207. function defineGetter(object, property, value, options) {
  1208. options.value = value;
  1209. options.writable = options.writable !== false;
  1210. options.enumerable = options.enumerable !== false;
  1211. options.configurable = options.configurable !== false;
  1212. Object.defineProperty(object, property, options);
  1213. }
  1214. /**
  1215. * A specialized version of `.forEach` for objects.
  1216. *
  1217. * @param {Object} object The object to iterate over.
  1218. * @param {Function} iteratee The function invoked per iteration.
  1219. * @returns {Object} Returns `object`.
  1220. */
  1221. function objectEach(object, iteratee) {
  1222. for (var key in object) {
  1223. if (!object.hasOwnProperty || object.hasOwnProperty && Object.prototype.hasOwnProperty.call(object, key)) {
  1224. if (iteratee(object[key], key, object) === false) {
  1225. break;
  1226. }
  1227. }
  1228. }
  1229. return object;
  1230. }
  1231. /**
  1232. * Get object property by its name. Access to sub properties can be achieved by dot notation (e.q. `'foo.bar.baz'`).
  1233. *
  1234. * @param {Object} object Object which value will be exported.
  1235. * @param {String} name Object property name.
  1236. * @returns {*}
  1237. */
  1238. function getProperty(object, name) {
  1239. var names = name.split('.');
  1240. var result = object;
  1241. objectEach(names, function (name) {
  1242. result = result[name];
  1243. if (result === void 0) {
  1244. result = void 0;
  1245. return false;
  1246. }
  1247. });
  1248. return result;
  1249. }
  1250. /**
  1251. * Return object length (recursively).
  1252. *
  1253. * @param {*} object Object for which we want get length.
  1254. * @returns {Number}
  1255. */
  1256. function deepObjectSize(object) {
  1257. if (!isObject(object)) {
  1258. return 0;
  1259. }
  1260. var recursObjLen = function recursObjLen(obj) {
  1261. var result = 0;
  1262. if (isObject(obj)) {
  1263. objectEach(obj, function (key) {
  1264. result += recursObjLen(key);
  1265. });
  1266. } else {
  1267. result++;
  1268. }
  1269. return result;
  1270. };
  1271. return recursObjLen(object);
  1272. }
  1273. /**
  1274. * Create object with property where its value change will be observed.
  1275. *
  1276. * @param {*} [defaultValue=undefined] Default value.
  1277. * @param {String} [propertyToListen='value'] Property to listen.
  1278. * @returns {Object}
  1279. */
  1280. function createObjectPropListener(defaultValue) {
  1281. var _holder;
  1282. var propertyToListen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
  1283. var privateProperty = '_' + propertyToListen;
  1284. var holder = (_holder = {
  1285. _touched: false
  1286. }, _defineProperty(_holder, privateProperty, defaultValue), _defineProperty(_holder, 'isTouched', function isTouched() {
  1287. return this._touched;
  1288. }), _holder);
  1289. Object.defineProperty(holder, propertyToListen, {
  1290. get: function get() {
  1291. return this[privateProperty];
  1292. },
  1293. set: function set(value) {
  1294. this._touched = true;
  1295. this[privateProperty] = value;
  1296. },
  1297. enumerable: true,
  1298. configurable: true
  1299. });
  1300. return holder;
  1301. }
  1302. /**
  1303. * Check if at specified `key` there is any value for `object`.
  1304. *
  1305. * @param {Object} object Object to search value at specyfic key.
  1306. * @param {String} key String key to check.
  1307. */
  1308. function hasOwnProperty(object, key) {
  1309. return Object.prototype.hasOwnProperty.call(object, key);
  1310. }
  1311. /***/ }),
  1312. /* 2 */
  1313. /***/ (function(module, exports, __webpack_require__) {
  1314. "use strict";
  1315. exports.__esModule = true;
  1316. exports.to2dArray = to2dArray;
  1317. exports.extendArray = extendArray;
  1318. exports.pivot = pivot;
  1319. exports.arrayReduce = arrayReduce;
  1320. exports.arrayFilter = arrayFilter;
  1321. exports.arrayMap = arrayMap;
  1322. exports.arrayEach = arrayEach;
  1323. exports.arraySum = arraySum;
  1324. exports.arrayMax = arrayMax;
  1325. exports.arrayMin = arrayMin;
  1326. exports.arrayAvg = arrayAvg;
  1327. exports.arrayFlatten = arrayFlatten;
  1328. exports.arrayUnique = arrayUnique;
  1329. function to2dArray(arr) {
  1330. var i = 0,
  1331. ilen = arr.length;
  1332. while (i < ilen) {
  1333. arr[i] = [arr[i]];
  1334. i++;
  1335. }
  1336. }
  1337. function extendArray(arr, extension) {
  1338. var i = 0,
  1339. ilen = extension.length;
  1340. while (i < ilen) {
  1341. arr.push(extension[i]);
  1342. i++;
  1343. }
  1344. }
  1345. function pivot(arr) {
  1346. var pivotedArr = [];
  1347. if (!arr || arr.length === 0 || !arr[0] || arr[0].length === 0) {
  1348. return pivotedArr;
  1349. }
  1350. var rowCount = arr.length;
  1351. var colCount = arr[0].length;
  1352. for (var i = 0; i < rowCount; i++) {
  1353. for (var j = 0; j < colCount; j++) {
  1354. if (!pivotedArr[j]) {
  1355. pivotedArr[j] = [];
  1356. }
  1357. pivotedArr[j][i] = arr[i][j];
  1358. }
  1359. }
  1360. return pivotedArr;
  1361. }
  1362. /**
  1363. * A specialized version of `.reduce` for arrays without support for callback
  1364. * shorthands and `this` binding.
  1365. *
  1366. * {@link https://github.com/lodash/lodash/blob/master/lodash.js}
  1367. *
  1368. * @param {Array} array The array to iterate over.
  1369. * @param {Function} iteratee The function invoked per iteration.
  1370. * @param {*} [accumulator] The initial value.
  1371. * @param {Boolean} [initFromArray] Specify using the first element of `array` as the initial value.
  1372. * @returns {*} Returns the accumulated value.
  1373. */
  1374. function arrayReduce(array, iteratee, accumulator, initFromArray) {
  1375. var index = -1,
  1376. length = array.length;
  1377. if (initFromArray && length) {
  1378. accumulator = array[++index];
  1379. }
  1380. while (++index < length) {
  1381. accumulator = iteratee(accumulator, array[index], index, array);
  1382. }
  1383. return accumulator;
  1384. }
  1385. /**
  1386. * A specialized version of `.filter` for arrays without support for callback
  1387. * shorthands and `this` binding.
  1388. *
  1389. * {@link https://github.com/lodash/lodash/blob/master/lodash.js}
  1390. *
  1391. * @param {Array} array The array to iterate over.
  1392. * @param {Function} predicate The function invoked per iteration.
  1393. * @returns {Array} Returns the new filtered array.
  1394. */
  1395. function arrayFilter(array, predicate) {
  1396. var index = -1,
  1397. length = array.length,
  1398. resIndex = -1,
  1399. result = [];
  1400. while (++index < length) {
  1401. var value = array[index];
  1402. if (predicate(value, index, array)) {
  1403. result[++resIndex] = value;
  1404. }
  1405. }
  1406. return result;
  1407. }
  1408. /**
  1409. * A specialized version of `.map` for arrays without support for callback
  1410. * shorthands and `this` binding.
  1411. *
  1412. * @param {Array} array The array to iterate over.
  1413. * @param {Function} iteratee The function invoked per iteration.
  1414. * @returns {Array} Returns the new filtered array.
  1415. */
  1416. function arrayMap(array, iteratee) {
  1417. var index = -1,
  1418. length = array.length,
  1419. resIndex = -1,
  1420. result = [];
  1421. while (++index < length) {
  1422. var value = array[index];
  1423. result[++resIndex] = iteratee(value, index, array);
  1424. }
  1425. return result;
  1426. }
  1427. /**
  1428. * A specialized version of `.forEach` for arrays without support for callback
  1429. * shorthands and `this` binding.
  1430. *
  1431. * {@link https://github.com/lodash/lodash/blob/master/lodash.js}
  1432. *
  1433. * @param {Array} array The array to iterate over.
  1434. * @param {Function} iteratee The function invoked per iteration.
  1435. * @returns {Array} Returns `array`.
  1436. */
  1437. function arrayEach(array, iteratee) {
  1438. var index = -1,
  1439. length = array.length;
  1440. while (++index < length) {
  1441. if (iteratee(array[index], index, array) === false) {
  1442. break;
  1443. }
  1444. }
  1445. return array;
  1446. }
  1447. /**
  1448. * Calculate sum value for each item of the array.
  1449. *
  1450. * @param {Array} array The array to process.
  1451. * @returns {Number} Returns calculated sum value.
  1452. */
  1453. function arraySum(array) {
  1454. return arrayReduce(array, function (a, b) {
  1455. return a + b;
  1456. }, 0);
  1457. }
  1458. /**
  1459. * Returns the highest value from an array. Can be array of numbers or array of strings.
  1460. * NOTICE: Mixed values is not supported.
  1461. *
  1462. * @param {Array} array The array to process.
  1463. * @returns {Number} Returns the highest value from an array.
  1464. */
  1465. function arrayMax(array) {
  1466. return arrayReduce(array, function (a, b) {
  1467. return a > b ? a : b;
  1468. }, Array.isArray(array) ? array[0] : void 0);
  1469. }
  1470. /**
  1471. * Returns the lowest value from an array. Can be array of numbers or array of strings.
  1472. * NOTICE: Mixed values is not supported.
  1473. *
  1474. * @param {Array} array The array to process.
  1475. * @returns {Number} Returns the lowest value from an array.
  1476. */
  1477. function arrayMin(array) {
  1478. return arrayReduce(array, function (a, b) {
  1479. return a < b ? a : b;
  1480. }, Array.isArray(array) ? array[0] : void 0);
  1481. }
  1482. /**
  1483. * Calculate average value for each item of the array.
  1484. *
  1485. * @param {Array} array The array to process.
  1486. * @returns {Number} Returns calculated average value.
  1487. */
  1488. function arrayAvg(array) {
  1489. if (!array.length) {
  1490. return 0;
  1491. }
  1492. return arraySum(array) / array.length;
  1493. }
  1494. /**
  1495. * Flatten multidimensional array.
  1496. *
  1497. * @param {Array} array Array of Arrays
  1498. * @returns {Array}
  1499. */
  1500. function arrayFlatten(array) {
  1501. return arrayReduce(array, function (initial, value) {
  1502. return initial.concat(Array.isArray(value) ? arrayFlatten(value) : value);
  1503. }, []);
  1504. }
  1505. /**
  1506. * Unique values in the array.
  1507. *
  1508. * @param {Array} array The array to process.
  1509. * @returns {Array}
  1510. */
  1511. function arrayUnique(array) {
  1512. var unique = [];
  1513. arrayEach(array, function (value) {
  1514. if (unique.indexOf(value) === -1) {
  1515. unique.push(value);
  1516. }
  1517. });
  1518. return unique;
  1519. }
  1520. /***/ }),
  1521. /* 3 */
  1522. /***/ (function(module, exports, __webpack_require__) {
  1523. var global = __webpack_require__(13)
  1524. , core = __webpack_require__(45)
  1525. , hide = __webpack_require__(32)
  1526. , redefine = __webpack_require__(33)
  1527. , ctx = __webpack_require__(29)
  1528. , PROTOTYPE = 'prototype';
  1529. var $export = function(type, name, source){
  1530. var IS_FORCED = type & $export.F
  1531. , IS_GLOBAL = type & $export.G
  1532. , IS_STATIC = type & $export.S
  1533. , IS_PROTO = type & $export.P
  1534. , IS_BIND = type & $export.B
  1535. , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]
  1536. , exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
  1537. , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {})
  1538. , key, own, out, exp;
  1539. if(IS_GLOBAL)source = name;
  1540. for(key in source){
  1541. // contains in native
  1542. own = !IS_FORCED && target && target[key] !== undefined;
  1543. // export native or passed
  1544. out = (own ? target : source)[key];
  1545. // bind timers to global for call from export context
  1546. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  1547. // extend global
  1548. if(target)redefine(target, key, out, type & $export.U);
  1549. // export
  1550. if(exports[key] != out)hide(exports, key, exp);
  1551. if(IS_PROTO && expProto[key] != out)expProto[key] = out;
  1552. }
  1553. };
  1554. global.core = core;
  1555. // type bitmap
  1556. $export.F = 1; // forced
  1557. $export.G = 2; // global
  1558. $export.S = 4; // static
  1559. $export.P = 8; // proto
  1560. $export.B = 16; // bind
  1561. $export.W = 32; // wrap
  1562. $export.U = 64; // safe
  1563. $export.R = 128; // real proto method for `library`
  1564. module.exports = $export;
  1565. /***/ }),
  1566. /* 4 */
  1567. /***/ (function(module, exports, __webpack_require__) {
  1568. "use strict";
  1569. exports.__esModule = true;
  1570. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // import Core from './core';
  1571. exports.getListenersCounter = getListenersCounter;
  1572. var _element = __webpack_require__(0);
  1573. var _feature = __webpack_require__(34);
  1574. var _event = __webpack_require__(7);
  1575. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1576. /**
  1577. * Counter which tracks unregistered listeners (useful for detecting memory leaks).
  1578. *
  1579. * @type {Number}
  1580. */
  1581. var listenersCounter = 0;
  1582. /**
  1583. * Event DOM manager for internal use in Handsontable.
  1584. *
  1585. * @class EventManager
  1586. * @util
  1587. */
  1588. var EventManager = function () {
  1589. /**
  1590. * @param {Object} [context=null]
  1591. * @private
  1592. */
  1593. function EventManager() {
  1594. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1595. _classCallCheck(this, EventManager);
  1596. this.context = context || this;
  1597. if (!this.context.eventListeners) {
  1598. this.context.eventListeners = [];
  1599. }
  1600. }
  1601. /**
  1602. * Register specified listener (`eventName`) to the element.
  1603. *
  1604. * @param {Element} element Target element.
  1605. * @param {String} eventName Event name.
  1606. * @param {Function} callback Function which will be called after event occur.
  1607. * @returns {Function} Returns function which you can easily call to remove that event
  1608. */
  1609. _createClass(EventManager, [{
  1610. key: 'addEventListener',
  1611. value: function addEventListener(element, eventName, callback) {
  1612. var _this = this;
  1613. var context = this.context;
  1614. function callbackProxy(event) {
  1615. event = extendEvent(context, event);
  1616. callback.call(this, event);
  1617. }
  1618. this.context.eventListeners.push({
  1619. element: element,
  1620. event: eventName,
  1621. callback: callback,
  1622. callbackProxy: callbackProxy
  1623. });
  1624. if (window.addEventListener) {
  1625. element.addEventListener(eventName, callbackProxy, false);
  1626. } else {
  1627. element.attachEvent('on' + eventName, callbackProxy);
  1628. }
  1629. listenersCounter++;
  1630. return function () {
  1631. _this.removeEventListener(element, eventName, callback);
  1632. };
  1633. }
  1634. /**
  1635. * Remove the event listener previously registered.
  1636. *
  1637. * @param {Element} element Target element.
  1638. * @param {String} eventName Event name.
  1639. * @param {Function} callback Function to remove from the event target. It must be the same as during registration listener.
  1640. */
  1641. }, {
  1642. key: 'removeEventListener',
  1643. value: function removeEventListener(element, eventName, callback) {
  1644. var len = this.context.eventListeners.length;
  1645. var tmpEvent = void 0;
  1646. while (len--) {
  1647. tmpEvent = this.context.eventListeners[len];
  1648. if (tmpEvent.event == eventName && tmpEvent.element == element) {
  1649. if (callback && callback != tmpEvent.callback) {
  1650. /* eslint-disable no-continue */
  1651. continue;
  1652. }
  1653. this.context.eventListeners.splice(len, 1);
  1654. if (tmpEvent.element.removeEventListener) {
  1655. tmpEvent.element.removeEventListener(tmpEvent.event, tmpEvent.callbackProxy, false);
  1656. } else {
  1657. tmpEvent.element.detachEvent('on' + tmpEvent.event, tmpEvent.callbackProxy);
  1658. }
  1659. listenersCounter--;
  1660. }
  1661. }
  1662. }
  1663. /**
  1664. * Clear all previously registered events.
  1665. *
  1666. * @private
  1667. * @since 0.15.0-beta3
  1668. */
  1669. }, {
  1670. key: 'clearEvents',
  1671. value: function clearEvents() {
  1672. if (!this.context) {
  1673. return;
  1674. }
  1675. var len = this.context.eventListeners.length;
  1676. while (len--) {
  1677. var event = this.context.eventListeners[len];
  1678. if (event) {
  1679. this.removeEventListener(event.element, event.event, event.callback);
  1680. }
  1681. }
  1682. }
  1683. /**
  1684. * Clear all previously registered events.
  1685. */
  1686. }, {
  1687. key: 'clear',
  1688. value: function clear() {
  1689. this.clearEvents();
  1690. }
  1691. /**
  1692. * Destroy instance of EventManager.
  1693. */
  1694. }, {
  1695. key: 'destroy',
  1696. value: function destroy() {
  1697. this.clearEvents();
  1698. this.context = null;
  1699. }
  1700. /**
  1701. * Trigger event at the specified target element.
  1702. *
  1703. * @param {Element} element Target element.
  1704. * @param {String} eventName Event name.
  1705. */
  1706. }, {
  1707. key: 'fireEvent',
  1708. value: function fireEvent(element, eventName) {
  1709. var options = {
  1710. bubbles: true,
  1711. cancelable: eventName !== 'mousemove',
  1712. view: window,
  1713. detail: 0,
  1714. screenX: 0,
  1715. screenY: 0,
  1716. clientX: 1,
  1717. clientY: 1,
  1718. ctrlKey: false,
  1719. altKey: false,
  1720. shiftKey: false,
  1721. metaKey: false,
  1722. button: 0,
  1723. relatedTarget: undefined
  1724. };
  1725. var event;
  1726. if (document.createEvent) {
  1727. event = document.createEvent('MouseEvents');
  1728. 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);
  1729. } else {
  1730. event = document.createEventObject();
  1731. }
  1732. if (element.dispatchEvent) {
  1733. element.dispatchEvent(event);
  1734. } else {
  1735. element.fireEvent('on' + eventName, event);
  1736. }
  1737. }
  1738. }]);
  1739. return EventManager;
  1740. }();
  1741. /**
  1742. * @param {Object} context
  1743. * @param {Event} event
  1744. * @private
  1745. * @returns {*}
  1746. */
  1747. function extendEvent(context, event) {
  1748. var componentName = 'HOT-TABLE';
  1749. var isHotTableSpotted = void 0;
  1750. var fromElement = void 0;
  1751. var realTarget = void 0;
  1752. var target = void 0;
  1753. var len = void 0;
  1754. var nativeStopImmediatePropagation = void 0;
  1755. event.isTargetWebComponent = false;
  1756. event.realTarget = event.target;
  1757. nativeStopImmediatePropagation = event.stopImmediatePropagation;
  1758. event.stopImmediatePropagation = function () {
  1759. nativeStopImmediatePropagation.apply(this);
  1760. (0, _event.stopImmediatePropagation)(this);
  1761. };
  1762. if (!EventManager.isHotTableEnv) {
  1763. return event;
  1764. }
  1765. event = (0, _element.polymerWrap)(event);
  1766. len = event.path ? event.path.length : 0;
  1767. while (len--) {
  1768. if (event.path[len].nodeName === componentName) {
  1769. isHotTableSpotted = true;
  1770. } else if (isHotTableSpotted && event.path[len].shadowRoot) {
  1771. target = event.path[len];
  1772. break;
  1773. }
  1774. if (len === 0 && !target) {
  1775. target = event.path[len];
  1776. }
  1777. }
  1778. if (!target) {
  1779. target = event.target;
  1780. }
  1781. event.isTargetWebComponent = true;
  1782. if ((0, _feature.isWebComponentSupportedNatively)()) {
  1783. event.realTarget = event.srcElement || event.toElement;
  1784. } else if (context instanceof Core || context instanceof Walkontable) {
  1785. // Polymer doesn't support `event.target` property properly we must emulate it ourselves
  1786. if (context instanceof Core) {
  1787. fromElement = context.view ? context.view.wt.wtTable.TABLE : null;
  1788. } else if (context instanceof Walkontable) {
  1789. // .wtHider
  1790. fromElement = context.wtTable.TABLE.parentNode.parentNode;
  1791. }
  1792. realTarget = (0, _element.closest)(event.target, [componentName], fromElement);
  1793. if (realTarget) {
  1794. event.realTarget = fromElement.querySelector(componentName) || event.target;
  1795. } else {
  1796. event.realTarget = event.target;
  1797. }
  1798. }
  1799. Object.defineProperty(event, 'target', {
  1800. get: function get() {
  1801. return (0, _element.polymerWrap)(target);
  1802. },
  1803. enumerable: true,
  1804. configurable: true
  1805. });
  1806. return event;
  1807. }
  1808. exports.default = EventManager;
  1809. function getListenersCounter() {
  1810. return listenersCounter;
  1811. };
  1812. /***/ }),
  1813. /* 5 */
  1814. /***/ (function(module, exports, __webpack_require__) {
  1815. "use strict";
  1816. exports.__esModule = true;
  1817. exports.getPluginName = exports.getRegistredPluginNames = exports.getPlugin = exports.registerPlugin = undefined;
  1818. var _pluginHooks = __webpack_require__(8);
  1819. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  1820. var _object = __webpack_require__(1);
  1821. var _string = __webpack_require__(27);
  1822. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1823. var registeredPlugins = new WeakMap();
  1824. /**
  1825. * Registers plugin under given name
  1826. *
  1827. * @param {String} pluginName
  1828. * @param {Function} PluginClass
  1829. */
  1830. /**
  1831. * Utility to register plugins and common namespace for keeping reference to all plugins classes
  1832. */
  1833. function registerPlugin(pluginName, PluginClass) {
  1834. pluginName = (0, _string.toUpperCaseFirst)(pluginName);
  1835. _pluginHooks2.default.getSingleton().add('construct', function () {
  1836. var holder = void 0;
  1837. if (!registeredPlugins.has(this)) {
  1838. registeredPlugins.set(this, {});
  1839. }
  1840. holder = registeredPlugins.get(this);
  1841. if (!holder[pluginName]) {
  1842. holder[pluginName] = new PluginClass(this);
  1843. }
  1844. });
  1845. _pluginHooks2.default.getSingleton().add('afterDestroy', function () {
  1846. if (registeredPlugins.has(this)) {
  1847. var pluginsHolder = registeredPlugins.get(this);
  1848. (0, _object.objectEach)(pluginsHolder, function (plugin) {
  1849. return plugin.destroy();
  1850. });
  1851. registeredPlugins.delete(this);
  1852. }
  1853. });
  1854. }
  1855. /**
  1856. * @param {Object} instance
  1857. * @param {String|Function} pluginName
  1858. * @returns {Function} pluginClass Returns plugin instance if exists or `undefined` if not exists.
  1859. */
  1860. function getPlugin(instance, pluginName) {
  1861. if (typeof pluginName != 'string') {
  1862. throw Error('Only strings can be passed as "plugin" parameter');
  1863. }
  1864. var _pluginName = (0, _string.toUpperCaseFirst)(pluginName);
  1865. if (!registeredPlugins.has(instance) || !registeredPlugins.get(instance)[_pluginName]) {
  1866. return void 0;
  1867. }
  1868. return registeredPlugins.get(instance)[_pluginName];
  1869. }
  1870. /**
  1871. * Get all registred plugins names for concrete Handsontable instance.
  1872. *
  1873. * @param {Object} hotInstance
  1874. * @returns {Array}
  1875. */
  1876. function getRegistredPluginNames(hotInstance) {
  1877. return registeredPlugins.has(hotInstance) ? Object.keys(registeredPlugins.get(hotInstance)) : [];
  1878. }
  1879. /**
  1880. * Get plugin name.
  1881. *
  1882. * @param {Object} hotInstance
  1883. * @param {Object} plugin
  1884. * @returns {String|null}
  1885. */
  1886. function getPluginName(hotInstance, plugin) {
  1887. var pluginName = null;
  1888. if (registeredPlugins.has(hotInstance)) {
  1889. (0, _object.objectEach)(registeredPlugins.get(hotInstance), function (pluginInstance, name) {
  1890. if (pluginInstance === plugin) {
  1891. pluginName = name;
  1892. }
  1893. });
  1894. }
  1895. return pluginName;
  1896. }
  1897. exports.registerPlugin = registerPlugin;
  1898. exports.getPlugin = getPlugin;
  1899. exports.getRegistredPluginNames = getRegistredPluginNames;
  1900. exports.getPluginName = getPluginName;
  1901. /***/ }),
  1902. /* 6 */
  1903. /***/ (function(module, exports, __webpack_require__) {
  1904. "use strict";
  1905. exports.__esModule = true;
  1906. var _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; };
  1907. exports.isNumeric = isNumeric;
  1908. exports.rangeEach = rangeEach;
  1909. exports.rangeEachReverse = rangeEachReverse;
  1910. exports.valueAccordingPercent = valueAccordingPercent;
  1911. /**
  1912. * Checks if value of n is a numeric one
  1913. * http://jsperf.com/isnan-vs-isnumeric/4
  1914. * @param n
  1915. * @returns {boolean}
  1916. */
  1917. function isNumeric(n) {
  1918. /* eslint-disable */
  1919. var t = typeof n === 'undefined' ? 'undefined' : _typeof(n);
  1920. 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;
  1921. }
  1922. /**
  1923. * A specialized version of `.forEach` defined by ranges.
  1924. *
  1925. * @param {Number} rangeFrom The number from start iterate.
  1926. * @param {Number|Function} rangeTo The number where finish iterate or function as a iteratee.
  1927. * @param {Function} [iteratee] The function invoked per iteration.
  1928. */
  1929. function rangeEach(rangeFrom, rangeTo, iteratee) {
  1930. var index = -1;
  1931. if (typeof rangeTo === 'function') {
  1932. iteratee = rangeTo;
  1933. rangeTo = rangeFrom;
  1934. } else {
  1935. index = rangeFrom - 1;
  1936. }
  1937. while (++index <= rangeTo) {
  1938. if (iteratee(index) === false) {
  1939. break;
  1940. }
  1941. }
  1942. }
  1943. /**
  1944. * A specialized version of `.forEach` defined by ranges iterable in reverse order.
  1945. *
  1946. * @param {Number} rangeFrom The number from start iterate.
  1947. * @param {Number} rangeTo The number where finish iterate.
  1948. * @param {Function} iteratee The function invoked per iteration.
  1949. */
  1950. function rangeEachReverse(rangeFrom, rangeTo, iteratee) {
  1951. var index = rangeFrom + 1;
  1952. if (typeof rangeTo === 'function') {
  1953. iteratee = rangeTo;
  1954. rangeTo = 0;
  1955. }
  1956. while (--index >= rangeTo) {
  1957. if (iteratee(index) === false) {
  1958. break;
  1959. }
  1960. }
  1961. }
  1962. /**
  1963. * Calculate value from percent.
  1964. *
  1965. * @param {Number} value Base value from percent will be calculated.
  1966. * @param {String|Number} percent Can be Number or String (eq. `'33%'`).
  1967. * @returns {Number}
  1968. */
  1969. function valueAccordingPercent(value, percent) {
  1970. percent = parseInt(percent.toString().replace('%', ''), 10);
  1971. percent = parseInt(value * percent / 100, 10);
  1972. return percent;
  1973. }
  1974. /***/ }),
  1975. /* 7 */
  1976. /***/ (function(module, exports, __webpack_require__) {
  1977. "use strict";
  1978. exports.__esModule = true;
  1979. exports.stopImmediatePropagation = stopImmediatePropagation;
  1980. exports.isImmediatePropagationStopped = isImmediatePropagationStopped;
  1981. exports.stopPropagation = stopPropagation;
  1982. exports.pageX = pageX;
  1983. exports.pageY = pageY;
  1984. exports.isRightClick = isRightClick;
  1985. exports.isLeftClick = isLeftClick;
  1986. var _element = __webpack_require__(0);
  1987. /**
  1988. * Prevent other listeners of the same event from being called.
  1989. *
  1990. * @param {Event} event
  1991. */
  1992. function stopImmediatePropagation(event) {
  1993. event.isImmediatePropagationEnabled = false;
  1994. event.cancelBubble = true;
  1995. }
  1996. /**
  1997. * Check if event was stopped by `stopImmediatePropagation`.
  1998. *
  1999. * @param event {Event}
  2000. * @returns {Boolean}
  2001. */
  2002. function isImmediatePropagationStopped(event) {
  2003. return event.isImmediatePropagationEnabled === false;
  2004. }
  2005. /**
  2006. * Prevent further propagation of the current event (prevent bubbling).
  2007. *
  2008. * @param event {Event}
  2009. */
  2010. function stopPropagation(event) {
  2011. // ie8
  2012. // http://msdn.microsoft.com/en-us/library/ie/ff975462(v=vs.85).aspx
  2013. if (typeof event.stopPropagation === 'function') {
  2014. event.stopPropagation();
  2015. } else {
  2016. event.cancelBubble = true;
  2017. }
  2018. }
  2019. /**
  2020. * Get horizontal coordinate of the event object relative to the whole document.
  2021. *
  2022. * @param {Event} event
  2023. * @returns {Number}
  2024. */
  2025. function pageX(event) {
  2026. if (event.pageX) {
  2027. return event.pageX;
  2028. }
  2029. return event.clientX + (0, _element.getWindowScrollLeft)();
  2030. }
  2031. /**
  2032. * Get vertical coordinate of the event object relative to the whole document.
  2033. *
  2034. * @param {Event} event
  2035. * @returns {Number}
  2036. */
  2037. function pageY(event) {
  2038. if (event.pageY) {
  2039. return event.pageY;
  2040. }
  2041. return event.clientY + (0, _element.getWindowScrollTop)();
  2042. }
  2043. /**
  2044. * Check if provided event was triggered by clicking the right mouse button.
  2045. *
  2046. * @param {Event} event DOM Event.
  2047. * @returns {Boolean}
  2048. */
  2049. function isRightClick(event) {
  2050. return event.button === 2;
  2051. }
  2052. /**
  2053. * Check if provided event was triggered by clicking the left mouse button.
  2054. *
  2055. * @param {Event} event DOM Event.
  2056. * @returns {Boolean}
  2057. */
  2058. function isLeftClick(event) {
  2059. return event.button === 0;
  2060. }
  2061. /***/ }),
  2062. /* 8 */
  2063. /***/ (function(module, exports, __webpack_require__) {
  2064. "use strict";
  2065. exports.__esModule = true;
  2066. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2067. var _array = __webpack_require__(2);
  2068. var _object = __webpack_require__(1);
  2069. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2070. /**
  2071. * @description
  2072. * Handsontable events are the common interface that function in 2 ways: as __callbacks__ and as __hooks__.
  2073. *
  2074. * @example
  2075. *
  2076. * ```js
  2077. * // Using events as callbacks:
  2078. * ...
  2079. * var hot1 = new Handsontable(document.getElementById('example1'), {
  2080. * afterChange: function(changes, source) {
  2081. * $.ajax({
  2082. * url: "save.php',
  2083. * data: change
  2084. * });
  2085. * }
  2086. * });
  2087. * ...
  2088. * ```
  2089. *
  2090. * ```js
  2091. * // Using events as plugin hooks:
  2092. * ...
  2093. * var hot1 = new Handsontable(document.getElementById('example1'), {
  2094. * myPlugin: true
  2095. * });
  2096. *
  2097. * var hot2 = new Handsontable(document.getElementById('example2'), {
  2098. * myPlugin: false
  2099. * });
  2100. *
  2101. * // global hook
  2102. * Handsontable.hooks.add('afterChange', function() {
  2103. * // Fired twice - for hot1 and hot2
  2104. * if (this.getSettings().myPlugin) {
  2105. * // function body - will only run for hot1
  2106. * }
  2107. * });
  2108. *
  2109. * // local hook (has same effect as a callback)
  2110. * hot2.addHook('afterChange', function() {
  2111. * // function body - will only run in #example2
  2112. * });
  2113. * ```
  2114. * ...
  2115. */
  2116. // @TODO: Move plugin description hooks to plugin?
  2117. var REGISTERED_HOOKS = [
  2118. /**
  2119. * Callback fired after resetting a cell's meta.
  2120. *
  2121. * @event Hooks#afterCellMetaReset
  2122. * @since 0.11
  2123. */
  2124. 'afterCellMetaReset',
  2125. /**
  2126. * @description
  2127. * Callback fired after one or more cells has been changed. Its main use case is to save the input.
  2128. *
  2129. * __Note:__ For performance reasons, the `changes` array is null for `"loadData"` source.
  2130. *
  2131. * @event Hooks#afterChange
  2132. * @param {Array} changes 2D array containing information about each of the edited cells `[[row, prop, oldVal, newVal], ...]`.
  2133. * @param {String} [source] String that identifies source of hook call
  2134. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2135. */
  2136. 'afterChange',
  2137. /**
  2138. * @description
  2139. * Fired after observing changes.
  2140. *
  2141. * @event Hooks#afterChangesObserved
  2142. */
  2143. 'afterChangesObserved',
  2144. /**
  2145. * @description
  2146. * Fired after setting up the Context Menu's default options. These options are a collection which user can select by setting
  2147. * an array of keys or an array of objects in `contextMenu` option.
  2148. *
  2149. * @event Hooks#afterContextMenuDefaultOptions
  2150. * @param {Array} predefinedItems Array of objects containing information about the pre-defined Context Menu items.
  2151. */
  2152. 'afterContextMenuDefaultOptions',
  2153. /**
  2154. * @description
  2155. * Fired before setting up the Context Menu's items but after filtering these options by user (`contextMenu` option). This hook
  2156. * can by helpful to determine if user use specified menu item or to set up one of the menu item to by always visible.
  2157. *
  2158. * @event Hooks#beforeContextMenuSetItems
  2159. * @param {Array} menuItems Array of objects containing information about to generated Context Menu items.
  2160. */
  2161. 'beforeContextMenuSetItems',
  2162. /**
  2163. * @description
  2164. * Fired after setting up the Context Menu's default options. These options are a collection which user can select by setting
  2165. * an array of keys or an array of objects in `contextMenu` option.
  2166. *
  2167. * @pro
  2168. * @event Hooks#afterDropdownMenuDefaultOptions
  2169. * @param {Array} predefinedItems Array of objects containing information about the pre-defined Context Menu items.
  2170. */
  2171. 'afterDropdownMenuDefaultOptions',
  2172. /**
  2173. * @description
  2174. * Fired before setting up the Dropdown Menu's items but after filtering these options by user (`dropdownMenu` option). This hook
  2175. * can by helpful to determine if user use specified menu item or to set up one of the menu item to by always visible.
  2176. *
  2177. * @pro
  2178. * @event Hooks#beforeDropdownMenuSetItems
  2179. * @param {Array} menuItems Array of objects containing information about to generated Dropdown Menu items.
  2180. */
  2181. 'beforeDropdownMenuSetItems',
  2182. /**
  2183. * @description
  2184. * Fired after hiding the Context Menu.
  2185. *
  2186. * @event Hooks#afterContextMenuHide
  2187. * @param {Object} context The Context menu instance.
  2188. */
  2189. 'afterContextMenuHide',
  2190. /**
  2191. * @description
  2192. * Fired after opening the Context Menu.
  2193. *
  2194. * @event Hooks#afterContextMenuShow
  2195. * @param {Object} context The Context Menu instance.
  2196. */
  2197. 'afterContextMenuShow',
  2198. /**
  2199. * @description
  2200. * Fired after reaching the copy limit while copying data.
  2201. *
  2202. * @event Hooks#afterCopyLimit
  2203. * @param {Number} selectedRows Count of selected copyable rows.
  2204. * @param {Number} selectedColumns Count of selected copyable columns.
  2205. * @param {Number} copyRowsLimit Current copy rows limit.
  2206. * @param {Number} copyColumnsLimit Current copy columns limit.
  2207. */
  2208. 'afterCopyLimit',
  2209. /**
  2210. * Callback is fired before a new column was created.
  2211. *
  2212. * @since 0.28.0
  2213. * @event Hooks#beforeCreateCol
  2214. * @param {Number} index Represents the visual index of first newly created column in the data source array.
  2215. * @param {Number} amount Number of newly created columns in the data source array.
  2216. * @param {String} [source] String that identifies source of hook call
  2217. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2218. */
  2219. 'beforeCreateCol',
  2220. /**
  2221. * Callback is fired after a new column was created.
  2222. *
  2223. * @event Hooks#afterCreateCol
  2224. * @param {Number} index Represents the visual index of first newly created column in the data source array.
  2225. * @param {Number} amount Number of newly created columns in the data source array.
  2226. * @param {String} [source] String that identifies source of hook call
  2227. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2228. */
  2229. 'afterCreateCol',
  2230. /**
  2231. * Callback is fired before a new row was created.
  2232. *
  2233. * @since 0.28.0
  2234. * @event Hooks#beforeCreateRow
  2235. * @param {Number} index Represents the visual index of first newly created row in the data source array.
  2236. * @param {Number} amount Number of newly created rows in the data source array.
  2237. * @param {String} [source] String that identifies source of hook call
  2238. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2239. */
  2240. 'beforeCreateRow',
  2241. /**
  2242. * Callback is fired after a new row was created.
  2243. *
  2244. * @event Hooks#afterCreateRow
  2245. * @param {Number} index Represents the visual index of first newly created row in the data source array.
  2246. * @param {Number} amount Number of newly created rows in the data source array.
  2247. * @param {String} [source] String that identifies source of hook call
  2248. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2249. */
  2250. 'afterCreateRow',
  2251. /**
  2252. * Fired after the current cell is deselected.
  2253. *
  2254. * @event Hooks#afterDeselect
  2255. */
  2256. 'afterDeselect',
  2257. /**
  2258. * Fired after destroying the Handsontable instance.
  2259. *
  2260. * @event Hooks#afterDestroy
  2261. */
  2262. 'afterDestroy',
  2263. /**
  2264. * Fired on a `keydown` event on the document body.
  2265. *
  2266. * @event Hooks#afterDocumentKeyDown
  2267. * @param {Event} event A `keydown` event.
  2268. */
  2269. 'afterDocumentKeyDown',
  2270. /**
  2271. * Callback fired after getting the cell settings.
  2272. *
  2273. * @event Hooks#afterGetCellMeta
  2274. * @param {Number} row Visual row index.
  2275. * @param {Number} col Visual column index.
  2276. * @param {Object} cellProperties Object containing the cell properties.
  2277. */
  2278. 'afterGetCellMeta',
  2279. /**
  2280. * Callback fired after retrieving information about a column header and appending it to the table header.
  2281. *
  2282. * @event Hooks#afterGetColHeader
  2283. * @param {Number} col Visual column index.
  2284. * @param {Element} TH Header's TH element.
  2285. */
  2286. 'afterGetColHeader',
  2287. /**
  2288. * Callback fired after retrieving information about a column header and appending it to the table header.
  2289. *
  2290. * @event Hooks#afterGetRowHeader
  2291. * @param {Number} row Visual row index.
  2292. * @param {Element} TH Header's TH element.
  2293. */
  2294. 'afterGetRowHeader',
  2295. /**
  2296. * Callback fired after Handsontable instance is initiated.
  2297. *
  2298. * @event Hooks#afterInit
  2299. */
  2300. 'afterInit',
  2301. /**
  2302. * Callback fired after new data is loaded (by `loadData` method) into the data source array.
  2303. *
  2304. * @event Hooks#afterLoadData
  2305. * @param {Boolean} firstTime flag that determines whether the data has been loaded during the initialization.
  2306. */
  2307. 'afterLoadData',
  2308. /**
  2309. * Fired after a scroll event, which is identified as a momentum scroll (e.g. on an iPad).
  2310. *
  2311. * @event Hooks#afterMomentumScroll
  2312. */
  2313. 'afterMomentumScroll',
  2314. /**
  2315. * Fired after a `mousedown` event is triggered on the cell corner (the drag handle).
  2316. *
  2317. * @event Hooks#afterOnCellCornerMouseDown
  2318. * @since 0.11
  2319. * @param {Object} event `mousedown` event object.
  2320. */
  2321. 'afterOnCellCornerMouseDown',
  2322. /**
  2323. * Fired after a `dblclick` event is triggered on the cell corner (the drag handle).
  2324. *
  2325. * @event Hooks#afterOnCellCornerDblClick
  2326. * @since 0.30.0
  2327. * @param {Object} event `dblclick` event object.
  2328. */
  2329. 'afterOnCellCornerDblClick',
  2330. /**
  2331. * Callback fired after clicking on a cell or row/column header.
  2332. * In case the row/column header was clicked, the index is negative.
  2333. * For example clicking on the row header of cell (0, 0) results with `afterOnCellMouseDown` called
  2334. * with coords `{row: 0, col: -1}`.
  2335. *
  2336. * @event Hooks#afterOnCellMouseDown
  2337. * @since 0.11
  2338. * @param {Object} event `mousedown` event object.
  2339. * @param {Object} coords Coordinates object containing the visual row and visual column indexes of the clicked cell.
  2340. * @param {Element} TD Cell's TD (or TH) element.
  2341. */
  2342. 'afterOnCellMouseDown',
  2343. /**
  2344. * Callback fired after hovering a cell or row/column header with the mouse cursor.
  2345. * In case the row/column header was hovered, the index is negative.
  2346. * For example, hovering over the row header of cell (0, 0) results with `afterOnCellMouseOver` called
  2347. * with coords `{row: 0, col: -1}`.
  2348. *
  2349. * @event Hooks#afterOnCellMouseOver
  2350. * @since 0.11
  2351. * @param {Object} event `mouseover` event object.
  2352. * @param {Object} coords Hovered cell's visual coordinate object.
  2353. * @param {Element} TD Cell's TD (or TH) element.
  2354. */
  2355. 'afterOnCellMouseOver',
  2356. /**
  2357. * Callback fired after leaving a cell or row/column header with the mouse cursor.
  2358. *
  2359. * @event Hooks#afterOnCellMouseOut
  2360. * @since 0.31.1
  2361. * @param {Object} event `mouseout` event object.
  2362. * @param {Object} coords Leaved cell's visual coordinate object.
  2363. * @param {Element} TD Cell's TD (or TH) element.
  2364. */
  2365. 'afterOnCellMouseOut',
  2366. /**
  2367. * Callback is fired when one or more columns are removed.
  2368. *
  2369. * @event Hooks#afterRemoveCol
  2370. * @param {Number} index Is an visual index of starter column.
  2371. * @param {Number} amount Is an amount of removed columns.
  2372. */
  2373. 'afterRemoveCol',
  2374. /**
  2375. * Callback is fired when one or more rows are removed.
  2376. *
  2377. * @event Hooks#afterRemoveRow
  2378. * @param {Number} index Is an visual index of starter row.
  2379. * @param {Number} amount Is an amount of removed rows.
  2380. */
  2381. 'afterRemoveRow',
  2382. /**
  2383. * Callback fired after the Handsontable table is rendered.
  2384. *
  2385. * @event Hooks#afterRender
  2386. * @param {Boolean} isForced Is `true` if rendering was triggered by a change of settings or data; or `false` if
  2387. * rendering was triggered by scrolling or moving selection.
  2388. */
  2389. 'afterRender',
  2390. /**
  2391. * Fired before starting rendering the cell.
  2392. *
  2393. * @event Hooks#beforeRenderer
  2394. * @since 0.24.2
  2395. * @param {Element} TD Currently rendered cell's TD element.
  2396. * @param {Number} row Visual row index.
  2397. * @param {Number} col Visual column index.
  2398. * @param {String|Number} prop Column property name or a column index, if datasource is an array of arrays.
  2399. * @param {String} value Value of the rendered cell.
  2400. * @param {Object} cellProperties Object containing the cell's properties.
  2401. */
  2402. 'beforeRenderer',
  2403. /**
  2404. * Fired after finishing rendering the cell (after the renderer finishes).
  2405. *
  2406. * @event Hooks#afterRenderer
  2407. * @since 0.11.0
  2408. * @param {Element} TD Currently rendered cell's TD element.
  2409. * @param {Number} row Visual row index.
  2410. * @param {Number} col Visual column index.
  2411. * @param {String|Number} prop Column property name or a column index, if datasource is an array of arrays.
  2412. * @param {String} value Value of the rendered cell.
  2413. * @param {Object} cellProperties Object containing the cell's properties.
  2414. */
  2415. 'afterRenderer',
  2416. /**
  2417. * Fired after the horizontal scroll event.
  2418. *
  2419. * @event Hooks#afterScrollHorizontally
  2420. * @since 0.11
  2421. */
  2422. 'afterScrollHorizontally',
  2423. /**
  2424. * Fired after the vertical scroll event.
  2425. *
  2426. * @event Hooks#afterScrollVertically
  2427. * @since 0.11
  2428. */
  2429. 'afterScrollVertically',
  2430. /**
  2431. * Callback fired after one or more cells are selected (e.g. during mouse move).
  2432. *
  2433. * @event Hooks#afterSelection
  2434. * @param {Number} r Selection start visual row index.
  2435. * @param {Number} c Selection start visual column index.
  2436. * @param {Number} r2 Selection end visual row index.
  2437. * @param {Number} c2 Selection end visual column index.
  2438. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  2439. * * @example
  2440. * ```js
  2441. * handsontable({
  2442. * afterSelection: function (r, c, r2, c2, preventScrolling) {
  2443. * // setting if prevent scrolling after selection
  2444. *
  2445. * preventScrolling.value = true;
  2446. * }
  2447. * })
  2448. * ```
  2449. */
  2450. 'afterSelection',
  2451. /**
  2452. * Callback fired after one or more cells are selected. The `p` argument represents the source object property name instead of the column number.
  2453. *
  2454. * @event Hooks#afterSelectionByProp
  2455. * @param {Number} r Selection start visual row index.
  2456. * @param {String} p Selection start data source object property name.
  2457. * @param {Number} r2 Selection end visual row index.
  2458. * @param {String} p2 Selection end data source object property name.
  2459. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  2460. * * @example
  2461. * ```js
  2462. * handsontable({
  2463. * afterSelectionByProp: function (r, c, r2, c2, preventScrolling) {
  2464. * // setting if prevent scrolling after selection
  2465. *
  2466. * preventScrolling.value = true;
  2467. * }
  2468. * })
  2469. * ```
  2470. */
  2471. 'afterSelectionByProp',
  2472. /**
  2473. * Callback fired after one or more cells are selected (e.g. on mouse up).
  2474. *
  2475. * @event Hooks#afterSelectionEnd
  2476. * @param {Number} r Selection start visual row index.
  2477. * @param {Number} c Selection start visual column index.
  2478. * @param {Number} r2 Selection end visual row index.
  2479. * @param {Number} c2 Selection end visual column index.
  2480. */
  2481. 'afterSelectionEnd',
  2482. /**
  2483. * Callback fired after one or more cells are selected (e.g. on mouse up). The `p` argument represents the data source object
  2484. * property name instead of the column number.
  2485. *
  2486. * @event Hooks#afterSelectionEndByProp
  2487. * @param {Number} r Selection start visual row index.
  2488. * @param {String} p Selection start data source object property index.
  2489. * @param {Number} r2 Selection end visual row index.
  2490. * @param {String} p2 Selection end data source object property index.
  2491. */
  2492. 'afterSelectionEndByProp',
  2493. /**
  2494. * Called after cell meta is changed.
  2495. *
  2496. * @event Hooks#afterSetCellMeta
  2497. * @since 0.11.0
  2498. * @param {Number} row Visual row index.
  2499. * @param {Number} col Visual column index.
  2500. * @param {String} key The updated meta key.
  2501. * @param {*} value The updated meta value.
  2502. */
  2503. 'afterSetCellMeta',
  2504. /**
  2505. * Called after cell data was changed.
  2506. *
  2507. * @event Hooks#afterSetDataAtCell
  2508. * @since 0.28.0
  2509. * @param {Array} changes An array of changes in format `[[row, col, oldValue, value], ...]`.
  2510. * @param {String} [source] String that identifies source of hook call
  2511. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2512. */
  2513. 'afterSetDataAtCell',
  2514. /**
  2515. * Called after cell data was changed.
  2516. *
  2517. * @event Hooks#afterSetDataAtRowProp
  2518. * @since 0.28.0
  2519. * @param {Array} changes An array of changes in format `[[row, prop, oldValue, value], ...]`.
  2520. * @param {String} [source] String that identifies source of hook call
  2521. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2522. */
  2523. 'afterSetDataAtRowProp',
  2524. /**
  2525. * Fired after calling the `updateSettings` method.
  2526. *
  2527. * @event Hooks#afterUpdateSettings
  2528. */
  2529. 'afterUpdateSettings',
  2530. /**
  2531. * @description
  2532. * A plugin hook executed after validator function, only if validator function is defined.
  2533. * Validation result is the first parameter. This can be used to determinate if validation passed successfully or not.
  2534. *
  2535. * __Returning false from the callback will mark the cell as invalid.__
  2536. *
  2537. * @event Hooks#afterValidate
  2538. * @since 0.9.5
  2539. * @param {Boolean} isValid `true` if valid, `false` if not.
  2540. * @param {*} value The value in question.
  2541. * @param {Number} row Row index.
  2542. * @param {String|Number} prop Property name / column index.
  2543. * @param {String} [source] String that identifies source of hook call
  2544. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2545. */
  2546. 'afterValidate',
  2547. /**
  2548. * Fired before populating the data in the autofill feature.
  2549. *
  2550. * @event Hooks#beforeAutofill
  2551. * @param {Object} start Object containing information about first filled cell: `{row: 2, col: 0}`.
  2552. * @param {Object} end Object containing information about last filled cell: `{row: 4, col: 1}`.
  2553. * @param {Array} data 2D array containing information about fill pattern: `[["1', "Ted"], ["1', "John"]]`.
  2554. */
  2555. 'beforeAutofill',
  2556. /**
  2557. * Fired before aligning the cell contents.
  2558. *
  2559. * @event Hooks#beforeCellAlignment
  2560. * @param stateBefore
  2561. * @param range
  2562. * @param {String} type Type of the alignment - either `horizontal` or `vertical`
  2563. * @param {String} alignmentClass String defining the alignment class added to the cell.
  2564. * Possible values:
  2565. * * `htLeft`,
  2566. * * `htCenter`,
  2567. * * `htRight`,
  2568. * * `htJustify`
  2569. * for horizontal alignment,
  2570. *
  2571. *
  2572. * * `htTop`,
  2573. * * `htMiddle`,
  2574. * * `htBottom`
  2575. * for vertical alignment.
  2576. */
  2577. 'beforeCellAlignment',
  2578. /**
  2579. * Callback fired before one or more cells is changed. Its main purpose is to alter changes silently before input.
  2580. *
  2581. * @event Hooks#beforeChange
  2582. * @param {Array} changes 2D array containing information about each of the edited cells.
  2583. * @param {String} [source] String that identifies source of hook call
  2584. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2585. * @example
  2586. * ```js
  2587. * // To disregard a single change, set changes[i] to null or remove it from array using changes.splice(i, 1).
  2588. * ...
  2589. * new Handsontable(document.getElementById('example'), {
  2590. * beforeChange: function(changes, source) {
  2591. * // [[row, prop, oldVal, newVal], ...]
  2592. * changes[0] = null;
  2593. * }
  2594. * });
  2595. * ...
  2596. *
  2597. * // To alter a single change, overwrite the desired value to changes[i][3].
  2598. * ...
  2599. * new Handsontable(document.getElementById('example'), {
  2600. * beforeChange: function(changes, source) {
  2601. * // [[row, prop, oldVal, newVal], ...]
  2602. * changes[0][3] = 10;
  2603. * }
  2604. * });
  2605. * ...
  2606. *
  2607. * // To cancel all edit, return false from the callback or set array length to 0 (changes.length = 0).
  2608. * ...
  2609. * new Handsontable(document.getElementById('example'), {
  2610. * beforeChange: function(changes, source) {
  2611. * // [[row, prop, oldVal, newVal], ...]
  2612. * return false;
  2613. * }
  2614. * });
  2615. * ...
  2616. * ```
  2617. */
  2618. 'beforeChange',
  2619. /**
  2620. * Fired right before rendering the changes.
  2621. *
  2622. * @event Hooks#beforeChangeRender
  2623. * @since 0.11
  2624. * @param {Array} changes Array in form of [row, prop, oldValue, newValue].
  2625. * @param {String} [source] String that identifies source of hook call
  2626. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2627. */
  2628. 'beforeChangeRender',
  2629. /**
  2630. * Fired before drawing the borders.
  2631. *
  2632. * @event Hooks#beforeDrawBorders
  2633. * @param {Array} corners Array specifying the current selection borders.
  2634. * @param {String} borderClassName Specifies the border class name.
  2635. */
  2636. 'beforeDrawBorders',
  2637. /**
  2638. * Callback fired before getting cell settings.
  2639. *
  2640. * @event Hooks#beforeGetCellMeta
  2641. * @param {Number} row Visual row index.
  2642. * @param {Number} col Visual column index.
  2643. * @param {Object} cellProperties Object containing the cell's properties.
  2644. */
  2645. 'beforeGetCellMeta',
  2646. /**
  2647. * @description
  2648. * Callback fired before Handsontable instance is initiated.
  2649. *
  2650. * @event Hooks#beforeInit
  2651. */
  2652. 'beforeInit',
  2653. /**
  2654. * Callback fired before Walkontable instance is initiated.
  2655. *
  2656. * @since 0.11
  2657. * @event Hooks#beforeInitWalkontable
  2658. * @param {Object} walkontableConfig Walkontable configuration object.
  2659. */
  2660. 'beforeInitWalkontable',
  2661. /**
  2662. * Callback fired before keydown event is handled. It can be used to overwrite default key bindings.
  2663. * Caution - in your `beforeKeyDown` handler you need to call `event.stopImmediatePropagation()` to prevent default key behavior.
  2664. *
  2665. * @event Hooks#beforeKeyDown
  2666. * @since 0.9.0
  2667. * @param {Event} event Original DOM event.
  2668. */
  2669. 'beforeKeyDown',
  2670. /**
  2671. * Fired after the user clicked a cell, but before all the calculations related with it.
  2672. *
  2673. * @event Hooks#beforeOnCellMouseDown
  2674. * @param {Event} event The `mousedown` event object.
  2675. * @param {CellCoords} coords Cell coords object containing the visual coordinates of the clicked cell.
  2676. * @param {Element} TD TD element.
  2677. */
  2678. 'beforeOnCellMouseDown',
  2679. /**
  2680. * Fired after the user moved cursor over a cell, but before all the calculations related with it.
  2681. *
  2682. * @event Hooks#beforeOnCellMouseOver
  2683. * @param {Event} event The `mouseover` event object.
  2684. * @param {CellCoords} coords CellCoords object containing the visual coordinates of the clicked cell.
  2685. * @param {Element} TD TD element.
  2686. * @param {Object} blockCalculations Contain keys 'row' and 'column' with boolean value.
  2687. */
  2688. 'beforeOnCellMouseOver',
  2689. /**
  2690. * Fired after the user moved cursor out from a cell, but before all the calculations related with it.
  2691. *
  2692. * @event Hooks#beforeOnCellMouseOut
  2693. * @since 0.31.1
  2694. * @param {Event} event The `mouseout` event object.
  2695. * @param {WalkontableCellCoords} coords WalkontableCellCoords object containing the visual coordinates of the leaved cell.
  2696. * @param {Element} TD TD element.
  2697. */
  2698. 'beforeOnCellMouseOut',
  2699. /**
  2700. * Callback is fired when one or more columns are about to be removed.
  2701. *
  2702. * @event Hooks#beforeRemoveCol
  2703. * @param {Number} index Visual index of starter column.
  2704. * @param {Number} amount Amount of columns to be removed.
  2705. * @param {Array} [visualCols] Consists of visual indexes of processed columns.
  2706. */
  2707. 'beforeRemoveCol',
  2708. /**
  2709. * Callback is fired when one or more rows are about to be removed.
  2710. *
  2711. * @event Hooks#beforeRemoveRow
  2712. * @param {Number} index Visual index of starter column.
  2713. * @param {Number} amount Amount of columns to be removed.
  2714. * @param {Array} [visualRows] Consists of visual indexes of processed rows.
  2715. */
  2716. 'beforeRemoveRow',
  2717. /**
  2718. * Callback fired before Handsontable table is rendered.
  2719. *
  2720. * @event Hooks#beforeRender
  2721. * @param {Boolean} isForced If `true` rendering was triggered by a change of settings or data; or `false` if
  2722. * rendering was triggered by scrolling or moving selection.
  2723. */
  2724. 'beforeRender',
  2725. /**
  2726. * Callback fired before setting range is started.
  2727. *
  2728. * @event Hooks#beforeSetRangeStart
  2729. * @param {Array} coords CellCoords array.
  2730. */
  2731. 'beforeSetRangeStart',
  2732. /**
  2733. * Callback fired before setting range is ended.
  2734. *
  2735. * @event Hooks#beforeSetRangeEnd
  2736. * @param {Array} coords CellCoords array.
  2737. */
  2738. 'beforeSetRangeEnd',
  2739. /**
  2740. * Fired before the logic of handling a touch scroll, when user started scrolling on a touch-enabled device.
  2741. *
  2742. * @event Hooks#beforeTouchScroll
  2743. */
  2744. 'beforeTouchScroll',
  2745. /**
  2746. * @description
  2747. * A plugin hook executed before validator function, only if validator function is defined.
  2748. * This can be used to manipulate the value of changed cell before it is applied to the validator function.
  2749. *
  2750. * __Notice:__ this will not affect values of changes. This will change value ONLY for validation!
  2751. *
  2752. * @event Hooks#beforeValidate
  2753. * @since 0.9.5
  2754. * @param {*} value Value of the cell.
  2755. * @param {Number} row Row index.
  2756. * @param {String|Number} prop Property name / column index.
  2757. * @param {String} [source] String that identifies source of hook call
  2758. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2759. */
  2760. 'beforeValidate',
  2761. /**
  2762. * Callback fired before cell value is rendered into the DOM (through renderer function).
  2763. *
  2764. * @event Hooks#beforeValueRender
  2765. * @since 0.29.0
  2766. * @param {*} value Cell value to render.
  2767. */
  2768. 'beforeValueRender',
  2769. /**
  2770. * Callback fired after Handsontable instance is constructed (via `new` operator).
  2771. *
  2772. * @event Hooks#construct
  2773. * @since 0.16.1
  2774. */
  2775. 'construct',
  2776. /**
  2777. * Callback fired after Handsontable instance is initiated but before table is rendered.
  2778. *
  2779. * @event Hooks#init
  2780. * @since 0.16.1
  2781. */
  2782. 'init',
  2783. /**
  2784. * Fired when a column index is about to be modified by a callback function.
  2785. *
  2786. * @event Hooks#modifyCol
  2787. * @since 0.11
  2788. * @param {Number} col Visual column index.
  2789. */
  2790. 'modifyCol',
  2791. /**
  2792. * Fired when a column index is about to be de-modified by a callback function.
  2793. *
  2794. * @event Hooks#unmodifyCol
  2795. * @since 0.23.0
  2796. * @param {Number} col Physical column index.
  2797. */
  2798. 'unmodifyCol',
  2799. /**
  2800. * Fired when a physical row index is about to be de-modified by a callback function.
  2801. *
  2802. * @event Hooks#unmodifyRow
  2803. * @since 0.26.2
  2804. * @param {Number} row Physical row index.
  2805. */
  2806. 'unmodifyRow',
  2807. /**
  2808. * Fired when a column header index is about to be modified by a callback function.
  2809. *
  2810. * @event Hooks#modifyColHeader
  2811. * @since 0.20.0
  2812. * @param {Number} column Visual column header index.
  2813. */
  2814. 'modifyColHeader',
  2815. /**
  2816. * Fired when a column width is about to be modified by a callback function.
  2817. *
  2818. * @event Hooks#modifyColWidth
  2819. * @since 0.11
  2820. * @param {Number} width Current column width.
  2821. * @param {Number} col Column index.
  2822. */
  2823. 'modifyColWidth',
  2824. /**
  2825. * Fired when a row index is about to be modified by a callback function.
  2826. *
  2827. * @event Hooks#modifyRow
  2828. * @since 0.11
  2829. * @param {Number} row Row index.
  2830. */
  2831. 'modifyRow',
  2832. /**
  2833. * Fired when a row header index is about to be modified by a callback function.
  2834. *
  2835. * @event Hooks#modifyRowHeader
  2836. * @since 0.20.0
  2837. * @param {Number} row Row header index.
  2838. */
  2839. 'modifyRowHeader',
  2840. /**
  2841. * Fired when a row height is about to be modified by a callback function.
  2842. *
  2843. * @event Hooks#modifyRowHeight
  2844. * @since 0.11.0
  2845. * @param {Number} height Row height.
  2846. * @param {Number} row Row index.
  2847. */
  2848. 'modifyRowHeight',
  2849. /**
  2850. * Fired when a data was retrieved or modified.
  2851. *
  2852. * @event Hooks#modifyData
  2853. * @since 0.28.0
  2854. * @param {Number} row Row height.
  2855. * @param {Number} column Column index.
  2856. * @param {Object} valueHolder Object which contains original value which can be modified by overwriting `.value` property.
  2857. * @param {String} ioMode String which indicates for what operation hook is fired (`get` or `set`).
  2858. */
  2859. 'modifyData',
  2860. /**
  2861. * Fired when a data was retrieved or modified.
  2862. *
  2863. * @event Hooks#modifyRowData
  2864. * @since 0.28.0
  2865. * @param {Number} row Physical row index.
  2866. */
  2867. 'modifyRowData',
  2868. /**
  2869. * Fired after loading data using the Persistent State plugin.
  2870. *
  2871. * @event Hooks#persistentStateLoad
  2872. * @param {String} key Key string.
  2873. * @param {Object} valuePlaceholder Object containing the loaded data.
  2874. */
  2875. 'persistentStateLoad',
  2876. /**
  2877. * Fired after resetting data using the Persistent State plugin.
  2878. *
  2879. * @event Hooks#persistentStateReset
  2880. * @param {String} key Key string.
  2881. */
  2882. 'persistentStateReset',
  2883. /**
  2884. * Fired after resetting data using the Persistent State plugin.
  2885. *
  2886. * @event Hooks#persistentStateSave
  2887. * @param {String} key Key string.
  2888. * @param {Mixed} value Value to save.
  2889. */
  2890. 'persistentStateSave',
  2891. /**
  2892. * Fired before sorting the column. If you return `false` value then sorting will be not applied by
  2893. * Handsontable (useful for server-side sorting).
  2894. *
  2895. * @event Hooks#beforeColumnSort
  2896. * @param {Number} column Sorted visual column index.
  2897. * @param {Boolean} order Soring order where:
  2898. * * `true` means ascending order,
  2899. * * `false` means descending order,
  2900. * * `undefined` means original order.
  2901. */
  2902. 'beforeColumnSort',
  2903. /**
  2904. * Fired after sorting the column.
  2905. *
  2906. * @event Hooks#afterColumnSort
  2907. * @param {Number} column Sorted visual column index.
  2908. * @param {Boolean} order Soring order where:
  2909. * * `true` means ascending order
  2910. * * `false` means descending order
  2911. * * `undefined` means original order
  2912. */
  2913. 'afterColumnSort',
  2914. /**
  2915. * @description
  2916. * Fired after setting range of autofill.
  2917. * Both arguments are provided in the following format:
  2918. * ```js
  2919. * [startRow, startColumn, endRow, endColumn]
  2920. * ```
  2921. *
  2922. * @event Hooks#modifyAutofillRange
  2923. * @param {Array} startArea Array of visual coordinates of the starting point for the drag-down operation.
  2924. * @param {Array} entireArea Array of visual coordinates of the entire area of the drag-down operation.
  2925. */
  2926. 'modifyAutofillRange',
  2927. /**
  2928. * Fired to allow modifying the copyable range with a callback function.
  2929. *
  2930. * @since 0.19.0
  2931. * @event Hooks#modifyCopyableRange
  2932. * @param {Array} copyableRanges Array of objects defining copyable cells.
  2933. */
  2934. 'modifyCopyableRange',
  2935. /**
  2936. * Called before copying the values into clipboard and before clearing values of the selected cells.
  2937. *
  2938. * @event Hooks#beforeCut
  2939. * @since 0.31.1
  2940. * @param {Array} data An array of arrays which contains data to cut.
  2941. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  2942. * which will be cut out.
  2943. * @returns {*} If returns `false` then operation of the cutting out is cancelled.
  2944. *
  2945. * @example
  2946. * ```js
  2947. * // To disregard a single row, remove it from array using data.splice(i, 1).
  2948. * ...
  2949. * new Handsontable(document.getElementById('example'), {
  2950. * beforeCut: function(data, coords) {
  2951. * // data -> [[1, 2, 3], [4, 5, 6]]
  2952. * data.splice(0, 1);
  2953. * // data -> [[4, 5, 6]]
  2954. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  2955. * }
  2956. * });
  2957. * ...
  2958. *
  2959. * // To cancel cutting out, return false from the callback.
  2960. * ...
  2961. * new Handsontable(document.getElementById('example'), {
  2962. * beforeCut: function(data, coords) {
  2963. * return false;
  2964. * }
  2965. * });
  2966. * ...
  2967. * ```
  2968. */
  2969. 'beforeCut',
  2970. /**
  2971. * Fired after data are cutted out from the table.
  2972. *
  2973. * @event Hooks#afterCut
  2974. * @since 0.31.1
  2975. * @param {Array} data An array of arrays which contains the cutted out data.
  2976. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  2977. * which was cut out.
  2978. */
  2979. 'afterCut',
  2980. /**
  2981. * Fired before values are copied into clipboard.
  2982. *
  2983. * @event Hooks#beforeCopy
  2984. * @since 0.31.1
  2985. * @param {Array} data An array of arrays which contains data to copied.
  2986. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  2987. * which will copied.
  2988. * @returns {*} If returns `false` then copying is cancelled.
  2989. *
  2990. * @example
  2991. * ```js
  2992. * // To disregard a single row, remove it from array using data.splice(i, 1).
  2993. * ...
  2994. * new Handsontable(document.getElementById('example'), {
  2995. * beforeCopy: function(data, coords) {
  2996. * // data -> [[1, 2, 3], [4, 5, 6]]
  2997. * data.splice(0, 1);
  2998. * // data -> [[4, 5, 6]]
  2999. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  3000. * }
  3001. * });
  3002. * ...
  3003. *
  3004. * // To cancel copying, return false from the callback.
  3005. * ...
  3006. * new Handsontable(document.getElementById('example'), {
  3007. * beforeCopy: function(data, coords) {
  3008. * return false;
  3009. * }
  3010. * });
  3011. * ...
  3012. * ```
  3013. */
  3014. 'beforeCopy',
  3015. /**
  3016. * Fired after data are pasted into table.
  3017. *
  3018. * @event Hooks#afterCopy
  3019. * @since 0.31.1
  3020. * @param {Array} data An array of arrays which contains the copied data.
  3021. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3022. * which was copied.
  3023. */
  3024. 'afterCopy',
  3025. /**
  3026. * Fired before values are pasted into table.
  3027. *
  3028. * @event Hooks#beforePaste
  3029. * @since 0.31.1
  3030. * @param {Array} data An array of arrays which contains data to paste.
  3031. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3032. * that correspond to the previously selected area.
  3033. * @returns {*} If returns `false` then pasting is cancelled.
  3034. *
  3035. * @example
  3036. * ```js
  3037. * // To disregard a single row, remove it from array using data.splice(i, 1).
  3038. * ...
  3039. * new Handsontable(document.getElementById('example'), {
  3040. * beforePaste: function(data, coords) {
  3041. * // data -> [[1, 2, 3], [4, 5, 6]]
  3042. * data.splice(0, 1);
  3043. * // data -> [[4, 5, 6]]
  3044. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  3045. * }
  3046. * });
  3047. * ...
  3048. *
  3049. * // To cancel pasting, return false from the callback.
  3050. * ...
  3051. * new Handsontable(document.getElementById('example'), {
  3052. * beforePaste: function(data, coords) {
  3053. * return false;
  3054. * }
  3055. * });
  3056. * ...
  3057. * ```
  3058. */
  3059. 'beforePaste',
  3060. /**
  3061. * Fired after values are pasted into table.
  3062. *
  3063. * @event Hooks#afterePaste
  3064. * @since 0.31.1
  3065. * @param {Array} data An array of arrays which contains the pasted data.
  3066. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3067. * that correspond to the previously selected area.
  3068. */
  3069. 'afterPaste',
  3070. /**
  3071. * Fired before change order of the visual indexes.
  3072. *
  3073. * @event Hooks#beforeColumnMove
  3074. * @param {Array} columns Array of visual column indexes to be moved.
  3075. * @param {Number} target Visual column index being a target for moved columns.
  3076. */
  3077. 'beforeColumnMove',
  3078. /**
  3079. * Fired after change order of the visual indexes.
  3080. *
  3081. * @event Hooks#afterColumnMove
  3082. * @param {Array} columns Array of visual column indexes that were moved.
  3083. * @param {Number} target Visual column index being a target for moved columns.
  3084. */
  3085. 'afterColumnMove',
  3086. /**
  3087. * Fired before change order of the visual indexes.
  3088. *
  3089. * @event Hooks#beforeRowMove
  3090. * @param {Array} rows Array of visual row indexes to be moved.
  3091. * @param {Number} target Visual row index being a target for moved rows.
  3092. */
  3093. 'beforeRowMove',
  3094. /**
  3095. * Fired after change order of the visual indexes.
  3096. *
  3097. * @event Hooks#afterRowMove
  3098. * @param {Array} rows Array of visual row indexes that were moved.
  3099. * @param {Number} target Visual row index being a target for moved rows.
  3100. */
  3101. 'afterRowMove',
  3102. /**
  3103. * Fired before rendering the table with modified column sizes.
  3104. *
  3105. * @event Hooks#beforeColumnResize
  3106. * @param {Number} currentColumn Visual index of the resized column.
  3107. * @param {Number} newSize Calculated new column width.
  3108. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3109. * @returns {Number} Returns a new column size or `undefined`, if column size should be calculated automatically.
  3110. */
  3111. 'beforeColumnResize',
  3112. /**
  3113. * Fired after rendering the table with modified column sizes.
  3114. *
  3115. * @event Hooks#afterColumnResize
  3116. * @param {Number} currentColumn Visual index of the resized column.
  3117. * @param {Number} newSize Calculated new column width.
  3118. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3119. */
  3120. 'afterColumnResize',
  3121. /**
  3122. * Fired before rendering the table with modified row sizes.
  3123. *
  3124. * @event Hooks#beforeRowResize
  3125. * @param {Number} currentRow Visual index of the resized row.
  3126. * @param {Number} newSize Calculated new row height.
  3127. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3128. * @returns {Number} Returns the new row size or `undefined` if row size should be calculated automatically.
  3129. */
  3130. 'beforeRowResize',
  3131. /**
  3132. * Fired after rendering the table with modified row sizes.
  3133. *
  3134. * @event Hooks#afterRowResize
  3135. * @param {Number} currentRow Visual index of the resized row.
  3136. * @param {Number} newSize Calculated new row height.
  3137. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3138. */
  3139. 'afterRowResize',
  3140. /**
  3141. * Fired after getting the column header renderers.
  3142. *
  3143. * @event Hooks#afterGetColumnHeaderRenderers
  3144. * @param {Array} array Array of the column header renderers.
  3145. */
  3146. 'afterGetColumnHeaderRenderers',
  3147. /**
  3148. * Fired after getting the row header renderers.
  3149. *
  3150. * @event Hooks#afterGetRowHeaderRenderers
  3151. * @param {Array} array Array of the row header renderers.
  3152. */
  3153. 'afterGetRowHeaderRenderers',
  3154. /**
  3155. * Fired before applying stretched column width to column.
  3156. *
  3157. * @event Hooks#beforeStretchingColumnWidth
  3158. * @param {Number} stretchedWidth Calculated width.
  3159. * @param {Number} column Visual column index.
  3160. * @returns {Number} Returns new width which will be applied to the column element.
  3161. */
  3162. 'beforeStretchingColumnWidth',
  3163. /**
  3164. * Fired before applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}.
  3165. *
  3166. * @pro
  3167. * @event Hooks#beforeFilter
  3168. * @param {Array} conditionsStack An array of objects with added formulas.
  3169. * @returns {Boolean} If hook returns `false` value then filtering won't be applied on the UI side (server-side filtering).
  3170. */
  3171. 'beforeFilter',
  3172. /**
  3173. * Fired after applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}.
  3174. *
  3175. * @pro
  3176. * @event Hooks#afterFilter
  3177. * @param {Array} conditionsStack An array of objects with added formulas.
  3178. */
  3179. 'afterFilter',
  3180. /**
  3181. * Used to modify the column header height.
  3182. *
  3183. * @event Hooks#modifyColumnHeaderHeight
  3184. * @since 0.25.0
  3185. * @param {Number} col Visual column index.
  3186. */
  3187. 'modifyColumnHeaderHeight',
  3188. /**
  3189. * Fired before the undo action. Contains information about the action that is being undone.
  3190. *
  3191. * @event Hooks#beforeUndo
  3192. * @since 0.26.2
  3193. * @param {Object} action The action object. Contains information about the action being undone. The `actionType`
  3194. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3195. */
  3196. 'beforeUndo',
  3197. /**
  3198. * Fired after the undo action. Contains information about the action that is being undone.
  3199. *
  3200. * @event Hooks#afterUndo
  3201. * @since 0.26.2
  3202. * @param {Object} action The action object. Contains information about the action being undone. The `actionType`
  3203. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3204. */
  3205. 'afterUndo',
  3206. /**
  3207. * Fired before the redo action. Contains information about the action that is being redone.
  3208. *
  3209. * @event Hooks#beforeRedo
  3210. * @since 0.26.2
  3211. * @param {Object} action The action object. Contains information about the action being redone. The `actionType`
  3212. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3213. */
  3214. 'beforeRedo',
  3215. /**
  3216. * Fired after the redo action. Contains information about the action that is being redone.
  3217. *
  3218. * @event Hooks#afterRedo
  3219. * @since 0.26.2
  3220. * @param {Object} action The action object. Contains information about the action being redone. The `actionType`
  3221. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3222. */
  3223. 'afterRedo',
  3224. /**
  3225. * Used to modify the row header width.
  3226. *
  3227. * @event Hooks#modifyRowHeaderWidth
  3228. * @param {Number} rowHeaderWidth Row header width.
  3229. */
  3230. 'modifyRowHeaderWidth',
  3231. /**
  3232. * Fired from the `populateFromArray` method during the `autofill` process. Fired for each "autofilled" cell individually.
  3233. *
  3234. * @event Hooks#beforeAutofillInsidePopulate
  3235. * @param {Object} index Object containing `row` and `col` properties, defining the number of rows/columns from the initial cell of the autofill.
  3236. * @param {String} direction Declares the direction of the autofill. Possible values: `up`, `down`, `left`, `right`.
  3237. * @param {Array} input Array of arrays. Contains an array of rows with data being used in the autofill.
  3238. * @param {Array} deltas The deltas array passed to the `populateFromArray` method.
  3239. */
  3240. 'beforeAutofillInsidePopulate',
  3241. /**
  3242. * Fired when the start of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3243. *
  3244. * @event Hooks#modifyTransformStart
  3245. * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
  3246. */
  3247. 'modifyTransformStart',
  3248. /**
  3249. * Fired when the end of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3250. *
  3251. * @event Hooks#modifyTransformEnd
  3252. * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
  3253. */
  3254. 'modifyTransformEnd',
  3255. /**
  3256. * Fired after the start of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3257. *
  3258. * @event Hooks#afterModifyTransformStart
  3259. * @param {CellCoords} coords Coords of the freshly selected cell.
  3260. * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
  3261. * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
  3262. */
  3263. 'afterModifyTransformStart',
  3264. /**
  3265. * Fired after the end of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3266. *
  3267. * @event Hooks#afterModifyTransformEnd
  3268. * @param {CellCoords} coords Visual coords of the freshly selected cell.
  3269. * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
  3270. * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
  3271. */
  3272. 'afterModifyTransformEnd',
  3273. /**
  3274. * Fired inside the `viewportRowCalculatorOverride` method. Allows modifying the row calculator parameters.
  3275. *
  3276. * @event Hooks#afterViewportRowCalculatorOverride
  3277. * @param {Object} calc The row calculator.
  3278. */
  3279. 'afterViewportRowCalculatorOverride',
  3280. /**
  3281. * Fired inside the `viewportColumnCalculatorOverride` method. Allows modifying the row calculator parameters.
  3282. *
  3283. * @event Hooks#afterViewportColumnCalculatorOverride
  3284. * @param {Object} calc The row calculator.
  3285. */
  3286. 'afterViewportColumnCalculatorOverride',
  3287. /**
  3288. * Fired after initializing all the plugins.
  3289. *
  3290. * @event Hooks#afterPluginsInitialized
  3291. */
  3292. 'afterPluginsInitialized',
  3293. /**
  3294. * Used when saving/loading the manual row heights state.
  3295. *
  3296. * @event Hooks#manualRowHeights
  3297. * @param {Array} state The current manual row heights state.
  3298. */
  3299. 'manualRowHeights',
  3300. /**
  3301. * Used to skip the length cache calculation for a defined period of time.
  3302. *
  3303. * @event Hooks#skipLengthCache
  3304. * @param {Number} delay The delay in milliseconds.
  3305. */
  3306. 'skipLengthCache',
  3307. /**
  3308. * Fired after trimming rows in the TrimRows plugin.
  3309. *
  3310. * @pro
  3311. * @event Hooks#afterTrimRow
  3312. * @param {Array} rows Physical indexes of trimmed rows.
  3313. */
  3314. 'afterTrimRow',
  3315. /**
  3316. * Fired after untrimming rows in the TrimRows plugin.
  3317. *
  3318. * @pro
  3319. * @event Hooks#afterUntrimRow
  3320. * @param {Array} rows Physical indexes of untrimmed rows.
  3321. */
  3322. 'afterUntrimRow',
  3323. /**
  3324. * Fired after opening the dropdown menu.
  3325. *
  3326. * @pro
  3327. * @event Hooks#afterDropdownMenuShow
  3328. * @param {DropdownMenu} instance The DropdownMenu instance.
  3329. */
  3330. 'afterDropdownMenuShow',
  3331. /**
  3332. * Fired after hiding the dropdown menu.
  3333. *
  3334. * @pro
  3335. * @event Hooks#afterDropdownMenuHide
  3336. * @param {DropdownMenu} instance The DropdownMenu instance.
  3337. */
  3338. 'afterDropdownMenuHide',
  3339. /**
  3340. * Used to check whether the provided row index is hidden.
  3341. *
  3342. * @pro
  3343. * @event Hooks#hiddenRow
  3344. * @param {Number} row The visual row index in question.
  3345. */
  3346. 'hiddenRow',
  3347. /**
  3348. * Used to check whether the provided column index is hidden.
  3349. *
  3350. * @pro
  3351. * @event Hooks#hiddenColumn
  3352. * @param {Number} column The visual column index in question.
  3353. */
  3354. 'hiddenColumn',
  3355. /**
  3356. * Fired before adding a children to the NestedRows structure.
  3357. *
  3358. * @pro
  3359. * @event Hooks#beforeAddChild
  3360. * @param {Object} parent The parent object.
  3361. * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added.
  3362. * @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.
  3363. */
  3364. 'beforeAddChild',
  3365. /**
  3366. * Fired after adding a children to the NestedRows structure.
  3367. *
  3368. * @pro
  3369. * @event Hooks#afterAddChild
  3370. * @param {Object} parent The parent object.
  3371. * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added.
  3372. * @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.
  3373. */
  3374. 'afterAddChild',
  3375. /**
  3376. * Fired before detaching a child from its parent in the NestedRows plugin.
  3377. *
  3378. * @pro
  3379. * @event Hooks#beforeDetachChild
  3380. * @param {Object} parent An object representing the parent from which the element is to be detached.
  3381. * @param {Object} element The detached element.
  3382. */
  3383. 'beforeDetachChild',
  3384. /**
  3385. * Fired after detaching a child from its parent in the NestedRows plugin.
  3386. *
  3387. * @pro
  3388. * @event Hooks#afterDetachChild
  3389. * @param {Object} parent An object representing the parent from which the element was detached.
  3390. * @param {Object} element The detached element.
  3391. */
  3392. 'afterDetachChild',
  3393. /**
  3394. * Fired after the editor is opened and rendered.
  3395. *
  3396. * @event Hooks#afterBeginEditing
  3397. * @param {Number} row Row index of the edited cell.
  3398. * @param {Number} column Column index of the edited cell.
  3399. */
  3400. 'afterBeginEditing'];
  3401. var Hooks = function () {
  3402. _createClass(Hooks, null, [{
  3403. key: 'getSingleton',
  3404. value: function getSingleton() {
  3405. return globalSingleton;
  3406. }
  3407. /**
  3408. *
  3409. */
  3410. }]);
  3411. function Hooks() {
  3412. _classCallCheck(this, Hooks);
  3413. this.globalBucket = this.createEmptyBucket();
  3414. }
  3415. /**
  3416. * Returns a new object with empty handlers related to every registered hook name.
  3417. *
  3418. * @returns {Object} The empty bucket object.
  3419. *
  3420. * @example
  3421. * ```js
  3422. * Handsontable.hooks.createEmptyBucket();
  3423. * // Results:
  3424. * {
  3425. * ...
  3426. * afterCreateCol: [],
  3427. * afterCreateRow: [],
  3428. * beforeInit: [],
  3429. * ...
  3430. * }
  3431. * ```
  3432. */
  3433. _createClass(Hooks, [{
  3434. key: 'createEmptyBucket',
  3435. value: function createEmptyBucket() {
  3436. var bucket = Object.create(null);
  3437. (0, _array.arrayEach)(REGISTERED_HOOKS, function (hook) {
  3438. return bucket[hook] = [];
  3439. });
  3440. return bucket;
  3441. }
  3442. /**
  3443. * Get hook bucket based on the context of the object or if argument is `undefined`, get the global hook bucket.
  3444. *
  3445. * @param {Object} [context=null] A Handsontable instance.
  3446. * @returns {Object} Returns a global or Handsontable instance bucket.
  3447. */
  3448. }, {
  3449. key: 'getBucket',
  3450. value: function getBucket() {
  3451. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3452. if (context) {
  3453. if (!context.pluginHookBucket) {
  3454. context.pluginHookBucket = this.createEmptyBucket();
  3455. }
  3456. return context.pluginHookBucket;
  3457. }
  3458. return this.globalBucket;
  3459. }
  3460. /**
  3461. * Adds a listener (globally or locally) to a specified hook name.
  3462. * If the `context` parameter is provided, the hook will be added only to the instance it references.
  3463. * Otherwise, the callback will be used everytime the hook fires on any Handsontable instance.
  3464. * You can provide an array of callback functions as the `callback` argument, this way they will all be fired
  3465. * once the hook is triggered.
  3466. *
  3467. * @see Core#addHook
  3468. * @param {String} key Hook name.
  3469. * @param {Function|Array} callback Callback function or an array of functions.
  3470. * @param {Object} [context=null] The context for the hook callback to be added - a Handsontable instance or leave empty.
  3471. * @returns {Hooks} Instance of Hooks.
  3472. *
  3473. * @example
  3474. * ```js
  3475. * // single callback, added locally
  3476. * Handsontable.hooks.add('beforeInit', myCallback, hotInstance);
  3477. *
  3478. * // single callback, added globally
  3479. * Handsontable.hooks.add('beforeInit', myCallback);
  3480. *
  3481. * // multiple callbacks, added locally
  3482. * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance);
  3483. *
  3484. * // multiple callbacks, added globally
  3485. * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]);
  3486. * ```
  3487. */
  3488. }, {
  3489. key: 'add',
  3490. value: function add(key, callback) {
  3491. var _this = this;
  3492. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3493. if (Array.isArray(callback)) {
  3494. (0, _array.arrayEach)(callback, function (c) {
  3495. return _this.add(key, c, context);
  3496. });
  3497. } else {
  3498. var bucket = this.getBucket(context);
  3499. if (typeof bucket[key] === 'undefined') {
  3500. this.register(key);
  3501. bucket[key] = [];
  3502. }
  3503. callback.skip = false;
  3504. if (bucket[key].indexOf(callback) === -1) {
  3505. // only add a hook if it has not already been added (adding the same hook twice is now silently ignored)
  3506. var foundInitialHook = false;
  3507. if (callback.initialHook) {
  3508. (0, _array.arrayEach)(bucket[key], function (cb, i) {
  3509. if (cb.initialHook) {
  3510. bucket[key][i] = callback;
  3511. foundInitialHook = true;
  3512. return false;
  3513. }
  3514. });
  3515. }
  3516. if (!foundInitialHook) {
  3517. bucket[key].push(callback);
  3518. }
  3519. }
  3520. }
  3521. return this;
  3522. }
  3523. /**
  3524. * Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket.
  3525. *
  3526. * @see Core#addHookOnce
  3527. * @param {String} key Hook/Event name.
  3528. * @param {Function|Array} callback Callback function.
  3529. * @param {Object} [context=null] A Handsontable instance.
  3530. *
  3531. * @example
  3532. * ```js
  3533. * Handsontable.hooks.once('beforeInit', myCallback, hotInstance);
  3534. * ```
  3535. */
  3536. }, {
  3537. key: 'once',
  3538. value: function once(key, callback) {
  3539. var _this2 = this;
  3540. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3541. if (Array.isArray(callback)) {
  3542. (0, _array.arrayEach)(callback, function (c) {
  3543. return _this2.once(key, c, context);
  3544. });
  3545. } else {
  3546. callback.runOnce = true;
  3547. this.add(key, callback, context);
  3548. }
  3549. }
  3550. /**
  3551. * 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.
  3552. *
  3553. * @see Core#removeHook
  3554. * @param {String} key Hook/Event name.
  3555. * @param {Function} callback Callback function (needs the be the function that was previously added to the hook).
  3556. * @param {Object} [context=null] Handsontable instance.
  3557. * @return {Boolean} Returns `true` if hook was removed, `false` otherwise.
  3558. *
  3559. * @example
  3560. * ```js
  3561. * Handsontable.hooks.remove('beforeInit', myCallback);
  3562. * ```
  3563. */
  3564. }, {
  3565. key: 'remove',
  3566. value: function remove(key, callback) {
  3567. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3568. var bucket = this.getBucket(context);
  3569. if (typeof bucket[key] !== 'undefined') {
  3570. if (bucket[key].indexOf(callback) >= 0) {
  3571. callback.skip = true;
  3572. return true;
  3573. }
  3574. }
  3575. return false;
  3576. }
  3577. /**
  3578. * Checks whether there are any registered listeners for the provided hook name.
  3579. * If the `context` parameter is provided, it only checks for listeners assigned to the given Handsontable instance.
  3580. *
  3581. * @param {String} key Hook name.
  3582. * @param {Object} [context=null] A Handsontable instance.
  3583. * @returns {Boolean} `true` for success, `false` otherwise.
  3584. */
  3585. }, {
  3586. key: 'has',
  3587. value: function has(key) {
  3588. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3589. var bucket = this.getBucket(context);
  3590. return !!(bucket[key] !== void 0 && bucket[key].length);
  3591. }
  3592. /**
  3593. * Runs all local and global callbacks assigned to the hook identified by the `key` parameter.
  3594. * It returns either a return value from the last called callback or the first parameter (`p1`) passed to the `run` function.
  3595. *
  3596. * @see Core#runHooks
  3597. * @param {Object} context Handsontable instance.
  3598. * @param {String} key Hook/Event name.
  3599. * @param {*} [p1] Parameter to be passed as an argument to the callback function.
  3600. * @param {*} [p2] Parameter to be passed as an argument to the callback function.
  3601. * @param {*} [p3] Parameter to be passed as an argument to the callback function.
  3602. * @param {*} [p4] Parameter to be passed as an argument to the callback function.
  3603. * @param {*} [p5] Parameter to be passed as an argument to the callback function.
  3604. * @param {*} [p6] Parameter to be passed as an argument to the callback function.
  3605. * @returns {*} Either a return value from the last called callback or `p1`.
  3606. *
  3607. * @example
  3608. * ```js
  3609. * Handsontable.hooks.run(hot, 'beforeInit');
  3610. * ```
  3611. */
  3612. }, {
  3613. key: 'run',
  3614. value: function run(context, key, p1, p2, p3, p4, p5, p6) {
  3615. {
  3616. var globalHandlers = this.globalBucket[key];
  3617. var index = -1;
  3618. var length = globalHandlers ? globalHandlers.length : 0;
  3619. if (length) {
  3620. // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
  3621. while (++index < length) {
  3622. if (!globalHandlers[index] || globalHandlers[index].skip) {
  3623. /* eslint-disable no-continue */
  3624. continue;
  3625. }
  3626. // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture
  3627. var res = globalHandlers[index].call(context, p1, p2, p3, p4, p5, p6);
  3628. if (res !== void 0) {
  3629. p1 = res;
  3630. }
  3631. if (globalHandlers[index] && globalHandlers[index].runOnce) {
  3632. this.remove(key, globalHandlers[index]);
  3633. }
  3634. }
  3635. }
  3636. }
  3637. {
  3638. var localHandlers = this.getBucket(context)[key];
  3639. var _index = -1;
  3640. var _length = localHandlers ? localHandlers.length : 0;
  3641. if (_length) {
  3642. // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
  3643. while (++_index < _length) {
  3644. if (!localHandlers[_index] || localHandlers[_index].skip) {
  3645. /* eslint-disable no-continue */
  3646. continue;
  3647. }
  3648. // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture
  3649. var _res = localHandlers[_index].call(context, p1, p2, p3, p4, p5, p6);
  3650. if (_res !== void 0) {
  3651. p1 = _res;
  3652. }
  3653. if (localHandlers[_index] && localHandlers[_index].runOnce) {
  3654. this.remove(key, localHandlers[_index], context);
  3655. }
  3656. }
  3657. }
  3658. }
  3659. return p1;
  3660. }
  3661. /**
  3662. * Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed.
  3663. *
  3664. * @param {Object} [context=null] A Handsontable instance.
  3665. * @example
  3666. * ```js
  3667. * // destroy the global listeners
  3668. * Handsontable.hooks.destroy();
  3669. *
  3670. * // destroy the local listeners
  3671. * Handsontable.hooks.destroy(hotInstance);
  3672. * ```
  3673. */
  3674. }, {
  3675. key: 'destroy',
  3676. value: function destroy() {
  3677. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3678. (0, _object.objectEach)(this.getBucket(context), function (value, key, bucket) {
  3679. return bucket[key].length = 0;
  3680. });
  3681. }
  3682. /**
  3683. * Registers a hook name (adds it to the list of the known hook names). Used by plugins.
  3684. * It is not necessary to call register, but if you use it, your plugin hook will be used returned by
  3685. * the `getRegistered` method. (which itself is used in the demo http://docs.handsontable.com/tutorial-callbacks.html).
  3686. *
  3687. * @param key {String} The hook name.
  3688. *
  3689. * @example
  3690. * ```js
  3691. * Handsontable.hooks.register('myHook');
  3692. * ```
  3693. */
  3694. }, {
  3695. key: 'register',
  3696. value: function register(key) {
  3697. if (!this.isRegistered(key)) {
  3698. REGISTERED_HOOKS.push(key);
  3699. }
  3700. }
  3701. /**
  3702. * Deregisters a hook name (removes it from the list of known hook names).
  3703. *
  3704. * @param key {String} Hook name.
  3705. *
  3706. * @example
  3707. * ```js
  3708. * Handsontable.hooks.deregister('myHook');
  3709. * ```
  3710. */
  3711. }, {
  3712. key: 'deregister',
  3713. value: function deregister(key) {
  3714. if (this.isRegistered(key)) {
  3715. REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
  3716. }
  3717. }
  3718. /**
  3719. * Returns a boolean depending on if a hook by such name has been registered.
  3720. *
  3721. * @param key {String} Hook name.
  3722. * @returns {Boolean} `true` for success, `false` otherwise.
  3723. *
  3724. * @example
  3725. * ```js
  3726. * Handsontable.hooks.isRegistered('beforeInit');
  3727. *
  3728. * // Results:
  3729. * true
  3730. * ```
  3731. */
  3732. }, {
  3733. key: 'isRegistered',
  3734. value: function isRegistered(key) {
  3735. return REGISTERED_HOOKS.indexOf(key) >= 0;
  3736. }
  3737. /**
  3738. * Returns an array of registered hooks.
  3739. *
  3740. * @returns {Array} An array of registered hooks.
  3741. *
  3742. * @example
  3743. * ```js
  3744. * Handsontable.hooks.getRegistered();
  3745. *
  3746. * // Results:
  3747. * [
  3748. * ...
  3749. * 'beforeInit',
  3750. * 'beforeRender',
  3751. * 'beforeSetRangeEnd',
  3752. * 'beforeDrawBorders',
  3753. * 'beforeChange',
  3754. * ...
  3755. * ]
  3756. * ```
  3757. */
  3758. }, {
  3759. key: 'getRegistered',
  3760. value: function getRegistered() {
  3761. return REGISTERED_HOOKS;
  3762. }
  3763. }]);
  3764. return Hooks;
  3765. }();
  3766. var globalSingleton = new Hooks();
  3767. exports.default = Hooks;
  3768. /***/ }),
  3769. /* 9 */
  3770. /***/ (function(module, exports, __webpack_require__) {
  3771. "use strict";
  3772. exports.__esModule = true;
  3773. exports.getRegisteredRenderers = exports.getRegisteredRendererNames = exports.hasRenderer = exports.getRenderer = exports.registerRenderer = undefined;
  3774. var _staticRegister2 = __webpack_require__(52);
  3775. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  3776. var _cellDecorator = __webpack_require__(377);
  3777. var _cellDecorator2 = _interopRequireDefault(_cellDecorator);
  3778. var _autocompleteRenderer = __webpack_require__(378);
  3779. var _autocompleteRenderer2 = _interopRequireDefault(_autocompleteRenderer);
  3780. var _checkboxRenderer = __webpack_require__(379);
  3781. var _checkboxRenderer2 = _interopRequireDefault(_checkboxRenderer);
  3782. var _htmlRenderer = __webpack_require__(380);
  3783. var _htmlRenderer2 = _interopRequireDefault(_htmlRenderer);
  3784. var _numericRenderer = __webpack_require__(381);
  3785. var _numericRenderer2 = _interopRequireDefault(_numericRenderer);
  3786. var _passwordRenderer = __webpack_require__(382);
  3787. var _passwordRenderer2 = _interopRequireDefault(_passwordRenderer);
  3788. var _textRenderer = __webpack_require__(383);
  3789. var _textRenderer2 = _interopRequireDefault(_textRenderer);
  3790. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3791. var _staticRegister = (0, _staticRegister3.default)('renderers'),
  3792. register = _staticRegister.register,
  3793. getItem = _staticRegister.getItem,
  3794. hasItem = _staticRegister.hasItem,
  3795. getNames = _staticRegister.getNames,
  3796. getValues = _staticRegister.getValues;
  3797. register('base', _cellDecorator2.default);
  3798. register('autocomplete', _autocompleteRenderer2.default);
  3799. register('checkbox', _checkboxRenderer2.default);
  3800. register('html', _htmlRenderer2.default);
  3801. register('numeric', _numericRenderer2.default);
  3802. register('password', _passwordRenderer2.default);
  3803. register('text', _textRenderer2.default);
  3804. /**
  3805. * Retrieve renderer function.
  3806. *
  3807. * @param {String} name Renderer identification.
  3808. * @returns {Function} Returns renderer function.
  3809. */
  3810. function _getItem(name) {
  3811. if (typeof name === 'function') {
  3812. return name;
  3813. }
  3814. if (!hasItem(name)) {
  3815. throw Error('No registered renderer found under "' + name + '" name');
  3816. }
  3817. return getItem(name);
  3818. }
  3819. exports.registerRenderer = register;
  3820. exports.getRenderer = _getItem;
  3821. exports.hasRenderer = hasItem;
  3822. exports.getRegisteredRendererNames = getNames;
  3823. exports.getRegisteredRenderers = getValues;
  3824. /***/ }),
  3825. /* 10 */
  3826. /***/ (function(module, exports, __webpack_require__) {
  3827. var store = __webpack_require__(84)('wks')
  3828. , uid = __webpack_require__(50)
  3829. , Symbol = __webpack_require__(13).Symbol
  3830. , USE_SYMBOL = typeof Symbol == 'function';
  3831. var $exports = module.exports = function(name){
  3832. return store[name] || (store[name] =
  3833. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  3834. };
  3835. $exports.store = store;
  3836. /***/ }),
  3837. /* 11 */
  3838. /***/ (function(module, exports, __webpack_require__) {
  3839. "use strict";
  3840. exports.__esModule = true;
  3841. exports.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;
  3842. __webpack_require__(97);
  3843. __webpack_require__(114);
  3844. __webpack_require__(123);
  3845. __webpack_require__(124);
  3846. __webpack_require__(108);
  3847. __webpack_require__(122);
  3848. __webpack_require__(105);
  3849. __webpack_require__(106);
  3850. __webpack_require__(107);
  3851. __webpack_require__(96);
  3852. __webpack_require__(119);
  3853. __webpack_require__(117);
  3854. __webpack_require__(115);
  3855. __webpack_require__(120);
  3856. __webpack_require__(121);
  3857. __webpack_require__(116);
  3858. __webpack_require__(118);
  3859. __webpack_require__(109);
  3860. __webpack_require__(110);
  3861. __webpack_require__(111);
  3862. __webpack_require__(113);
  3863. __webpack_require__(112);
  3864. __webpack_require__(94);
  3865. __webpack_require__(95);
  3866. __webpack_require__(90);
  3867. __webpack_require__(93);
  3868. __webpack_require__(92);
  3869. __webpack_require__(91);
  3870. __webpack_require__(68);
  3871. __webpack_require__(99);
  3872. __webpack_require__(100);
  3873. __webpack_require__(102);
  3874. __webpack_require__(101);
  3875. __webpack_require__(98);
  3876. __webpack_require__(104);
  3877. __webpack_require__(103);
  3878. __webpack_require__(125);
  3879. __webpack_require__(128);
  3880. __webpack_require__(126);
  3881. __webpack_require__(127);
  3882. __webpack_require__(130);
  3883. __webpack_require__(129);
  3884. __webpack_require__(132);
  3885. __webpack_require__(131);
  3886. var _viewportColumns = __webpack_require__(251);
  3887. var _viewportColumns2 = _interopRequireDefault(_viewportColumns);
  3888. var _viewportRows = __webpack_require__(252);
  3889. var _viewportRows2 = _interopRequireDefault(_viewportRows);
  3890. var _coords = __webpack_require__(43);
  3891. var _coords2 = _interopRequireDefault(_coords);
  3892. var _range = __webpack_require__(69);
  3893. var _range2 = _interopRequireDefault(_range);
  3894. var _column = __webpack_require__(255);
  3895. var _column2 = _interopRequireDefault(_column);
  3896. var _row = __webpack_require__(256);
  3897. var _row2 = _interopRequireDefault(_row);
  3898. var _debug = __webpack_require__(299);
  3899. var _debug2 = _interopRequireDefault(_debug);
  3900. var _left = __webpack_require__(300);
  3901. var _left2 = _interopRequireDefault(_left);
  3902. var _top = __webpack_require__(301);
  3903. var _top2 = _interopRequireDefault(_top);
  3904. var _topLeftCorner = __webpack_require__(302);
  3905. var _topLeftCorner2 = _interopRequireDefault(_topLeftCorner);
  3906. var _border = __webpack_require__(250);
  3907. var _border2 = _interopRequireDefault(_border);
  3908. var _core = __webpack_require__(253);
  3909. var _core2 = _interopRequireDefault(_core);
  3910. var _event = __webpack_require__(254);
  3911. var _event2 = _interopRequireDefault(_event);
  3912. var _overlays = __webpack_require__(257);
  3913. var _overlays2 = _interopRequireDefault(_overlays);
  3914. var _scroll = __webpack_require__(258);
  3915. var _scroll2 = _interopRequireDefault(_scroll);
  3916. var _selection = __webpack_require__(303);
  3917. var _selection2 = _interopRequireDefault(_selection);
  3918. var _settings = __webpack_require__(259);
  3919. var _settings2 = _interopRequireDefault(_settings);
  3920. var _table = __webpack_require__(260);
  3921. var _table2 = _interopRequireDefault(_table);
  3922. var _tableRenderer = __webpack_require__(261);
  3923. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  3924. var _viewport = __webpack_require__(262);
  3925. var _viewport2 = _interopRequireDefault(_viewport);
  3926. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3927. exports.ViewportColumnsCalculator = _viewportColumns2.default;
  3928. exports.ViewportRowsCalculator = _viewportRows2.default;
  3929. exports.CellCoords = _coords2.default;
  3930. exports.CellRange = _range2.default;
  3931. exports.ColumnFilter = _column2.default;
  3932. exports.RowFilter = _row2.default;
  3933. exports.DebugOverlay = _debug2.default;
  3934. exports.LeftOverlay = _left2.default;
  3935. exports.TopOverlay = _top2.default;
  3936. exports.TopLeftCornerOverlay = _topLeftCorner2.default;
  3937. exports.Border = _border2.default;
  3938. exports.default = _core2.default;
  3939. exports.Core = _core2.default;
  3940. exports.Event = _event2.default;
  3941. exports.Overlays = _overlays2.default;
  3942. exports.Scroll = _scroll2.default;
  3943. exports.Selection = _selection2.default;
  3944. exports.Settings = _settings2.default;
  3945. exports.Table = _table2.default;
  3946. exports.TableRenderer = _tableRenderer2.default;
  3947. exports.Viewport = _viewport2.default;
  3948. /***/ }),
  3949. /* 12 */
  3950. /***/ (function(module, exports, __webpack_require__) {
  3951. "use strict";
  3952. exports.__esModule = true;
  3953. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3954. var _object = __webpack_require__(1);
  3955. var _array = __webpack_require__(2);
  3956. var _recordTranslator = __webpack_require__(268);
  3957. var _plugins = __webpack_require__(5);
  3958. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3959. var privatePool = new WeakMap();
  3960. var initializedPlugins = null;
  3961. /**
  3962. * @private
  3963. */
  3964. var BasePlugin = function () {
  3965. /**
  3966. * @param {Object} hotInstance Handsontable instance.
  3967. */
  3968. function BasePlugin(hotInstance) {
  3969. var _this = this;
  3970. _classCallCheck(this, BasePlugin);
  3971. /**
  3972. * Handsontable instance.
  3973. *
  3974. * @type {Core}
  3975. */
  3976. (0, _object.defineGetter)(this, 'hot', hotInstance, {
  3977. writable: false
  3978. });
  3979. (0, _object.defineGetter)(this, 't', (0, _recordTranslator.getTranslator)(hotInstance), {
  3980. writable: false
  3981. });
  3982. privatePool.set(this, { hooks: {} });
  3983. initializedPlugins = null;
  3984. this.pluginName = null;
  3985. this.pluginsInitializedCallbacks = [];
  3986. this.isPluginsReady = false;
  3987. this.enabled = false;
  3988. this.initialized = false;
  3989. this.hot.addHook('afterPluginsInitialized', function () {
  3990. return _this.onAfterPluginsInitialized();
  3991. });
  3992. this.hot.addHook('afterUpdateSettings', function () {
  3993. return _this.onUpdateSettings();
  3994. });
  3995. this.hot.addHook('beforeInit', function () {
  3996. return _this.init();
  3997. });
  3998. }
  3999. _createClass(BasePlugin, [{
  4000. key: 'init',
  4001. value: function init() {
  4002. this.pluginName = (0, _plugins.getPluginName)(this.hot, this);
  4003. if (this.isEnabled && this.isEnabled()) {
  4004. this.enablePlugin();
  4005. }
  4006. if (!initializedPlugins) {
  4007. initializedPlugins = (0, _plugins.getRegistredPluginNames)(this.hot);
  4008. }
  4009. if (initializedPlugins.indexOf(this.pluginName) >= 0) {
  4010. initializedPlugins.splice(initializedPlugins.indexOf(this.pluginName), 1);
  4011. }
  4012. if (!initializedPlugins.length) {
  4013. this.hot.runHooks('afterPluginsInitialized');
  4014. }
  4015. this.initialized = true;
  4016. }
  4017. /**
  4018. * Enable plugin for this Handsontable instance.
  4019. */
  4020. }, {
  4021. key: 'enablePlugin',
  4022. value: function enablePlugin() {
  4023. this.enabled = true;
  4024. }
  4025. /**
  4026. * Disable plugin for this Handsontable instance.
  4027. */
  4028. }, {
  4029. key: 'disablePlugin',
  4030. value: function disablePlugin() {
  4031. if (this.eventManager) {
  4032. this.eventManager.clear();
  4033. }
  4034. this.clearHooks();
  4035. this.enabled = false;
  4036. }
  4037. /**
  4038. * Add listener to plugin hooks system.
  4039. *
  4040. * @param {String} name
  4041. * @param {Function} callback
  4042. */
  4043. }, {
  4044. key: 'addHook',
  4045. value: function addHook(name, callback) {
  4046. privatePool.get(this).hooks[name] = privatePool.get(this).hooks[name] || [];
  4047. var hooks = privatePool.get(this).hooks[name];
  4048. this.hot.addHook(name, callback);
  4049. hooks.push(callback);
  4050. privatePool.get(this).hooks[name] = hooks;
  4051. }
  4052. /**
  4053. * Remove all hooks listeners by hook name.
  4054. *
  4055. * @param {String} name
  4056. */
  4057. }, {
  4058. key: 'removeHooks',
  4059. value: function removeHooks(name) {
  4060. var _this2 = this;
  4061. (0, _array.arrayEach)(privatePool.get(this).hooks[name] || [], function (callback) {
  4062. _this2.hot.removeHook(name, callback);
  4063. });
  4064. }
  4065. /**
  4066. * Clear all hooks.
  4067. */
  4068. }, {
  4069. key: 'clearHooks',
  4070. value: function clearHooks() {
  4071. var _this3 = this;
  4072. var hooks = privatePool.get(this).hooks;
  4073. (0, _object.objectEach)(hooks, function (callbacks, name) {
  4074. return _this3.removeHooks(name);
  4075. });
  4076. hooks.length = 0;
  4077. }
  4078. /**
  4079. * Register function which will be immediately called after all plugins initialized.
  4080. *
  4081. * @param {Function} callback
  4082. */
  4083. }, {
  4084. key: 'callOnPluginsReady',
  4085. value: function callOnPluginsReady(callback) {
  4086. if (this.isPluginsReady) {
  4087. callback();
  4088. } else {
  4089. this.pluginsInitializedCallbacks.push(callback);
  4090. }
  4091. }
  4092. /**
  4093. * On after plugins initialized listener.
  4094. *
  4095. * @private
  4096. */
  4097. }, {
  4098. key: 'onAfterPluginsInitialized',
  4099. value: function onAfterPluginsInitialized() {
  4100. (0, _array.arrayEach)(this.pluginsInitializedCallbacks, function (callback) {
  4101. return callback();
  4102. });
  4103. this.pluginsInitializedCallbacks.length = 0;
  4104. this.isPluginsReady = true;
  4105. }
  4106. /**
  4107. * On update settings listener.
  4108. *
  4109. * @private
  4110. */
  4111. }, {
  4112. key: 'onUpdateSettings',
  4113. value: function onUpdateSettings() {
  4114. if (this.isEnabled) {
  4115. if (this.enabled && !this.isEnabled()) {
  4116. this.disablePlugin();
  4117. }
  4118. if (!this.enabled && this.isEnabled()) {
  4119. this.enablePlugin();
  4120. }
  4121. if (this.enabled && this.isEnabled()) {
  4122. this.updatePlugin();
  4123. }
  4124. }
  4125. }
  4126. /**
  4127. * Updates the plugin to use the latest options you have specified.
  4128. *
  4129. * @private
  4130. */
  4131. }, {
  4132. key: 'updatePlugin',
  4133. value: function updatePlugin() {}
  4134. /**
  4135. * Destroy plugin.
  4136. */
  4137. }, {
  4138. key: 'destroy',
  4139. value: function destroy() {
  4140. var _this4 = this;
  4141. if (this.eventManager) {
  4142. this.eventManager.destroy();
  4143. }
  4144. this.clearHooks();
  4145. (0, _object.objectEach)(this, function (value, property) {
  4146. if (property !== 'hot' && property !== 't') {
  4147. _this4[property] = null;
  4148. }
  4149. });
  4150. delete this.t;
  4151. delete this.hot;
  4152. }
  4153. }]);
  4154. return BasePlugin;
  4155. }();
  4156. exports.default = BasePlugin;
  4157. /***/ }),
  4158. /* 13 */
  4159. /***/ (function(module, exports) {
  4160. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  4161. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  4162. ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  4163. if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
  4164. /***/ }),
  4165. /* 14 */
  4166. /***/ (function(module, exports, __webpack_require__) {
  4167. "use strict";
  4168. exports.__esModule = true;
  4169. exports.getRegisteredEditors = exports.getRegisteredEditorNames = exports.hasEditor = exports.getEditorInstance = exports.getEditor = exports.registerEditor = undefined;
  4170. exports.RegisteredEditor = RegisteredEditor;
  4171. exports._getEditorInstance = _getEditorInstance;
  4172. var _staticRegister2 = __webpack_require__(52);
  4173. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  4174. var _pluginHooks = __webpack_require__(8);
  4175. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  4176. var _baseEditor = __webpack_require__(37);
  4177. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  4178. var _autocompleteEditor = __webpack_require__(263);
  4179. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  4180. var _checkboxEditor = __webpack_require__(316);
  4181. var _checkboxEditor2 = _interopRequireDefault(_checkboxEditor);
  4182. var _dateEditor = __webpack_require__(317);
  4183. var _dateEditor2 = _interopRequireDefault(_dateEditor);
  4184. var _dropdownEditor = __webpack_require__(318);
  4185. var _dropdownEditor2 = _interopRequireDefault(_dropdownEditor);
  4186. var _handsontableEditor = __webpack_require__(264);
  4187. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  4188. var _mobileTextEditor = __webpack_require__(319);
  4189. var _mobileTextEditor2 = _interopRequireDefault(_mobileTextEditor);
  4190. var _numericEditor = __webpack_require__(320);
  4191. var _numericEditor2 = _interopRequireDefault(_numericEditor);
  4192. var _passwordEditor = __webpack_require__(321);
  4193. var _passwordEditor2 = _interopRequireDefault(_passwordEditor);
  4194. var _selectEditor = __webpack_require__(322);
  4195. var _selectEditor2 = _interopRequireDefault(_selectEditor);
  4196. var _textEditor = __webpack_require__(44);
  4197. var _textEditor2 = _interopRequireDefault(_textEditor);
  4198. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4199. var registeredEditorClasses = new WeakMap(); /**
  4200. * Utility to register editors and common namespace for keeping reference to all editor classes
  4201. */
  4202. var _staticRegister = (0, _staticRegister3.default)('editors'),
  4203. register = _staticRegister.register,
  4204. getItem = _staticRegister.getItem,
  4205. hasItem = _staticRegister.hasItem,
  4206. getNames = _staticRegister.getNames,
  4207. getValues = _staticRegister.getValues;
  4208. _register('base', _baseEditor2.default);
  4209. _register('autocomplete', _autocompleteEditor2.default);
  4210. _register('checkbox', _checkboxEditor2.default);
  4211. _register('date', _dateEditor2.default);
  4212. _register('dropdown', _dropdownEditor2.default);
  4213. _register('handsontable', _handsontableEditor2.default);
  4214. _register('mobile', _mobileTextEditor2.default);
  4215. _register('numeric', _numericEditor2.default);
  4216. _register('password', _passwordEditor2.default);
  4217. _register('select', _selectEditor2.default);
  4218. _register('text', _textEditor2.default);
  4219. function RegisteredEditor(editorClass) {
  4220. var instances = {};
  4221. var Clazz = editorClass;
  4222. this.getConstructor = function () {
  4223. return editorClass;
  4224. };
  4225. this.getInstance = function (hotInstance) {
  4226. if (!(hotInstance.guid in instances)) {
  4227. instances[hotInstance.guid] = new Clazz(hotInstance);
  4228. }
  4229. return instances[hotInstance.guid];
  4230. };
  4231. _pluginHooks2.default.getSingleton().add('afterDestroy', function () {
  4232. instances = {};
  4233. });
  4234. }
  4235. /**
  4236. * Returns instance (singleton) of editor class.
  4237. *
  4238. * @param {String} name Name of an editor under which it has been stored.
  4239. * @param {Object} hotInstance Instance of Handsontable.
  4240. * @returns {Function} Returns instance of editor.
  4241. */
  4242. function _getEditorInstance(name, hotInstance) {
  4243. var editor = void 0;
  4244. if (typeof name === 'function') {
  4245. if (!registeredEditorClasses.get(name)) {
  4246. _register(null, name);
  4247. }
  4248. editor = registeredEditorClasses.get(name);
  4249. } else if (typeof name === 'string') {
  4250. editor = getItem(name);
  4251. } else {
  4252. throw Error('Only strings and functions can be passed as "editor" parameter');
  4253. }
  4254. if (!editor) {
  4255. throw Error('No editor registered under name "' + name + '"');
  4256. }
  4257. return editor.getInstance(hotInstance);
  4258. }
  4259. /**
  4260. * Retrieve editor class.
  4261. *
  4262. * @param {String} name Editor identification.
  4263. * @returns {Function} Returns editor class.
  4264. */
  4265. function _getItem(name) {
  4266. if (!hasItem(name)) {
  4267. throw Error('No registered editor found under "' + name + '" name');
  4268. }
  4269. return getItem(name).getConstructor();
  4270. }
  4271. /**
  4272. * Register editor class under specified name.
  4273. *
  4274. * @param {String} name Editor identification.
  4275. * @param {Function} editorClass Editor class.
  4276. */
  4277. function _register(name, editorClass) {
  4278. var editorWrapper = new RegisteredEditor(editorClass);
  4279. if (typeof name === 'string') {
  4280. register(name, editorWrapper);
  4281. }
  4282. registeredEditorClasses.set(editorClass, editorWrapper);
  4283. }
  4284. exports.registerEditor = _register;
  4285. exports.getEditor = _getItem;
  4286. exports.getEditorInstance = _getEditorInstance;
  4287. exports.hasEditor = hasItem;
  4288. exports.getRegisteredEditorNames = getNames;
  4289. exports.getRegisteredEditors = getValues;
  4290. /***/ }),
  4291. /* 15 */
  4292. /***/ (function(module, exports) {
  4293. module.exports = function(it){
  4294. return typeof it === 'object' ? it !== null : typeof it === 'function';
  4295. };
  4296. /***/ }),
  4297. /* 16 */
  4298. /***/ (function(module, exports, __webpack_require__) {
  4299. "use strict";
  4300. exports.__esModule = true;
  4301. exports.KEY_CODES = undefined;
  4302. exports.isPrintableChar = isPrintableChar;
  4303. exports.isMetaKey = isMetaKey;
  4304. exports.isCtrlKey = isCtrlKey;
  4305. exports.isKey = isKey;
  4306. var _array = __webpack_require__(2);
  4307. var KEY_CODES = exports.KEY_CODES = {
  4308. MOUSE_LEFT: 1,
  4309. MOUSE_RIGHT: 3,
  4310. MOUSE_MIDDLE: 2,
  4311. BACKSPACE: 8,
  4312. COMMA: 188,
  4313. INSERT: 45,
  4314. DELETE: 46,
  4315. END: 35,
  4316. ENTER: 13,
  4317. ESCAPE: 27,
  4318. CONTROL_LEFT: 91,
  4319. COMMAND_LEFT: 17,
  4320. COMMAND_RIGHT: 93,
  4321. ALT: 18,
  4322. HOME: 36,
  4323. PAGE_DOWN: 34,
  4324. PAGE_UP: 33,
  4325. PERIOD: 190,
  4326. SPACE: 32,
  4327. SHIFT: 16,
  4328. CAPS_LOCK: 20,
  4329. TAB: 9,
  4330. ARROW_RIGHT: 39,
  4331. ARROW_LEFT: 37,
  4332. ARROW_UP: 38,
  4333. ARROW_DOWN: 40,
  4334. F1: 112,
  4335. F2: 113,
  4336. F3: 114,
  4337. F4: 115,
  4338. F5: 116,
  4339. F6: 117,
  4340. F7: 118,
  4341. F8: 119,
  4342. F9: 120,
  4343. F10: 121,
  4344. F11: 122,
  4345. F12: 123,
  4346. A: 65,
  4347. X: 88,
  4348. C: 67,
  4349. V: 86
  4350. };
  4351. /**
  4352. * Returns true if keyCode represents a printable character.
  4353. *
  4354. * @param {Number} keyCode
  4355. * @returns {Boolean}
  4356. */
  4357. function isPrintableChar(keyCode) {
  4358. return keyCode == 32 || // space
  4359. keyCode >= 48 && keyCode <= 57 || // 0-9
  4360. keyCode >= 96 && keyCode <= 111 || // numpad
  4361. keyCode >= 186 && keyCode <= 192 || // ;=,-./`
  4362. keyCode >= 219 && keyCode <= 222 || // []{}\|"'
  4363. keyCode >= 226 || // special chars (229 for Asian chars)
  4364. keyCode >= 65 && keyCode <= 90; // a-z
  4365. }
  4366. /**
  4367. * @param {Number} keyCode
  4368. * @returns {Boolean}
  4369. */
  4370. function isMetaKey(keyCode) {
  4371. 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];
  4372. return metaKeys.indexOf(keyCode) !== -1;
  4373. }
  4374. /**
  4375. * @param {Number} keyCode
  4376. * @returns {Boolean}
  4377. */
  4378. function isCtrlKey(keyCode) {
  4379. return [KEY_CODES.CONTROL_LEFT, 224, KEY_CODES.COMMAND_LEFT, KEY_CODES.COMMAND_RIGHT].indexOf(keyCode) !== -1;
  4380. }
  4381. /**
  4382. * @param {Number} keyCode
  4383. * @param {String} baseCode
  4384. * @returns {Boolean}
  4385. */
  4386. function isKey(keyCode, baseCode) {
  4387. var keys = baseCode.split('|');
  4388. var result = false;
  4389. (0, _array.arrayEach)(keys, function (key) {
  4390. if (keyCode === KEY_CODES[key]) {
  4391. result = true;
  4392. return false;
  4393. }
  4394. });
  4395. return result;
  4396. }
  4397. /***/ }),
  4398. /* 17 */
  4399. /***/ (function(module, exports, __webpack_require__) {
  4400. "use strict";
  4401. exports.__esModule = true;
  4402. exports.normalizeSelection = normalizeSelection;
  4403. exports.isSeparator = isSeparator;
  4404. exports.hasSubMenu = hasSubMenu;
  4405. exports.isDisabled = isDisabled;
  4406. exports.isSelectionDisabled = isSelectionDisabled;
  4407. exports.getValidSelection = getValidSelection;
  4408. exports.prepareVerticalAlignClass = prepareVerticalAlignClass;
  4409. exports.prepareHorizontalAlignClass = prepareHorizontalAlignClass;
  4410. exports.getAlignmentClasses = getAlignmentClasses;
  4411. exports.align = align;
  4412. exports.checkSelectionConsistency = checkSelectionConsistency;
  4413. exports.markLabelAsSelected = markLabelAsSelected;
  4414. exports.isItemHidden = isItemHidden;
  4415. exports.filterSeparators = filterSeparators;
  4416. var _array = __webpack_require__(2);
  4417. var _element = __webpack_require__(0);
  4418. var _separator = __webpack_require__(72);
  4419. function normalizeSelection(selRange) {
  4420. return {
  4421. start: selRange.getTopLeftCorner(),
  4422. end: selRange.getBottomRightCorner()
  4423. };
  4424. }
  4425. function isSeparator(cell) {
  4426. return (0, _element.hasClass)(cell, 'htSeparator');
  4427. }
  4428. function hasSubMenu(cell) {
  4429. return (0, _element.hasClass)(cell, 'htSubmenu');
  4430. }
  4431. function isDisabled(cell) {
  4432. return (0, _element.hasClass)(cell, 'htDisabled');
  4433. }
  4434. function isSelectionDisabled(cell) {
  4435. return (0, _element.hasClass)(cell, 'htSelectionDisabled');
  4436. }
  4437. function getValidSelection(hot) {
  4438. var selected = hot.getSelected();
  4439. if (!selected) {
  4440. return null;
  4441. }
  4442. if (selected[0] < 0) {
  4443. return null;
  4444. }
  4445. return selected;
  4446. }
  4447. function prepareVerticalAlignClass(className, alignment) {
  4448. if (className.indexOf(alignment) != -1) {
  4449. return className;
  4450. }
  4451. className = className.replace('htTop', '').replace('htMiddle', '').replace('htBottom', '').replace(' ', '');
  4452. className += ' ' + alignment;
  4453. return className;
  4454. }
  4455. function prepareHorizontalAlignClass(className, alignment) {
  4456. if (className.indexOf(alignment) != -1) {
  4457. return className;
  4458. }
  4459. className = className.replace('htLeft', '').replace('htCenter', '').replace('htRight', '').replace('htJustify', '').replace(' ', '');
  4460. className += ' ' + alignment;
  4461. return className;
  4462. }
  4463. function getAlignmentClasses(range, callback) {
  4464. var classes = {};
  4465. for (var row = range.from.row; row <= range.to.row; row++) {
  4466. for (var col = range.from.col; col <= range.to.col; col++) {
  4467. if (!classes[row]) {
  4468. classes[row] = [];
  4469. }
  4470. classes[row][col] = callback(row, col);
  4471. }
  4472. }
  4473. return classes;
  4474. }
  4475. function align(range, type, alignment, cellDescriptor, propertySetter) {
  4476. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  4477. applyAlignClassName(range.from.row, range.from.col, type, alignment, cellDescriptor, propertySetter);
  4478. } else {
  4479. for (var row = range.from.row; row <= range.to.row; row++) {
  4480. for (var col = range.from.col; col <= range.to.col; col++) {
  4481. applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter);
  4482. }
  4483. }
  4484. }
  4485. }
  4486. function applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter) {
  4487. var cellMeta = cellDescriptor(row, col);
  4488. var className = alignment;
  4489. if (cellMeta.className) {
  4490. if (type === 'vertical') {
  4491. className = prepareVerticalAlignClass(cellMeta.className, alignment);
  4492. } else {
  4493. className = prepareHorizontalAlignClass(cellMeta.className, alignment);
  4494. }
  4495. }
  4496. propertySetter(row, col, 'className', className);
  4497. }
  4498. function checkSelectionConsistency(range, comparator) {
  4499. var result = false;
  4500. if (range) {
  4501. range.forAll(function (row, col) {
  4502. if (comparator(row, col)) {
  4503. result = true;
  4504. return false;
  4505. }
  4506. });
  4507. }
  4508. return result;
  4509. }
  4510. function markLabelAsSelected(label) {
  4511. // workaround for https://github.com/handsontable/handsontable/issues/1946
  4512. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label;
  4513. }
  4514. function isItemHidden(item, instance) {
  4515. return !item.hidden || !(typeof item.hidden == 'function' && item.hidden.call(instance));
  4516. }
  4517. function shiftSeparators(items, separator) {
  4518. var result = items.slice(0);
  4519. for (var i = 0; i < result.length;) {
  4520. if (result[i].name === separator) {
  4521. result.shift();
  4522. } else {
  4523. break;
  4524. }
  4525. }
  4526. return result;
  4527. }
  4528. function popSeparators(items, separator) {
  4529. var result = items.slice(0);
  4530. result.reverse();
  4531. result = shiftSeparators(result, separator);
  4532. result.reverse();
  4533. return result;
  4534. }
  4535. function removeDuplicatedSeparators(items) {
  4536. var result = [];
  4537. (0, _array.arrayEach)(items, function (value, index) {
  4538. if (index > 0) {
  4539. if (result[result.length - 1].name !== value.name) {
  4540. result.push(value);
  4541. }
  4542. } else {
  4543. result.push(value);
  4544. }
  4545. });
  4546. return result;
  4547. }
  4548. function filterSeparators(items) {
  4549. var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _separator.KEY;
  4550. var result = items.slice(0);
  4551. result = shiftSeparators(result, separator);
  4552. result = popSeparators(result, separator);
  4553. result = removeDuplicatedSeparators(result);
  4554. return result;
  4555. }
  4556. /***/ }),
  4557. /* 18 */
  4558. /***/ (function(module, exports, __webpack_require__) {
  4559. var isObject = __webpack_require__(15);
  4560. module.exports = function(it){
  4561. if(!isObject(it))throw TypeError(it + ' is not an object!');
  4562. return it;
  4563. };
  4564. /***/ }),
  4565. /* 19 */
  4566. /***/ (function(module, exports, __webpack_require__) {
  4567. var anObject = __webpack_require__(18)
  4568. , IE8_DOM_DEFINE = __webpack_require__(275)
  4569. , toPrimitive = __webpack_require__(87)
  4570. , dP = Object.defineProperty;
  4571. exports.f = __webpack_require__(21) ? Object.defineProperty : function defineProperty(O, P, Attributes){
  4572. anObject(O);
  4573. P = toPrimitive(P, true);
  4574. anObject(Attributes);
  4575. if(IE8_DOM_DEFINE)try {
  4576. return dP(O, P, Attributes);
  4577. } catch(e){ /* empty */ }
  4578. if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
  4579. if('value' in Attributes)O[P] = Attributes.value;
  4580. return O;
  4581. };
  4582. /***/ }),
  4583. /* 20 */
  4584. /***/ (function(module, exports, __webpack_require__) {
  4585. "use strict";
  4586. exports.__esModule = true;
  4587. var _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; };
  4588. exports.stringify = stringify;
  4589. exports.isDefined = isDefined;
  4590. exports.isUndefined = isUndefined;
  4591. exports.isEmpty = isEmpty;
  4592. exports.isRegExp = isRegExp;
  4593. /**
  4594. * Converts any value to string.
  4595. *
  4596. * @param {*} value
  4597. * @returns {String}
  4598. */
  4599. function stringify(value) {
  4600. var result = void 0;
  4601. switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
  4602. case 'string':
  4603. case 'number':
  4604. result = '' + value;
  4605. break;
  4606. case 'object':
  4607. result = value === null ? '' : value.toString();
  4608. break;
  4609. case 'undefined':
  4610. result = '';
  4611. break;
  4612. default:
  4613. result = value.toString();
  4614. break;
  4615. }
  4616. return result;
  4617. }
  4618. /**
  4619. * Checks if given variable is defined.
  4620. *
  4621. * @param {*} variable Variable to check.
  4622. * @returns {Boolean}
  4623. */
  4624. function isDefined(variable) {
  4625. return typeof variable !== 'undefined';
  4626. }
  4627. /**
  4628. * Checks if given variable is undefined.
  4629. *
  4630. * @param {*} variable Variable to check.
  4631. * @returns {Boolean}
  4632. */
  4633. function isUndefined(variable) {
  4634. return typeof variable === 'undefined';
  4635. }
  4636. /**
  4637. * Check if given variable is null, empty string or undefined.
  4638. *
  4639. * @param {*} variable Variable to check.
  4640. * @returns {Boolean}
  4641. */
  4642. function isEmpty(variable) {
  4643. return variable === null || variable === '' || isUndefined(variable);
  4644. }
  4645. /**
  4646. * Check if given variable is a regular expression.
  4647. *
  4648. * @param {*} variable Variable to check.
  4649. * @returns {Boolean}
  4650. */
  4651. function isRegExp(variable) {
  4652. return Object.prototype.toString.call(variable) === '[object RegExp]';
  4653. }
  4654. /***/ }),
  4655. /* 21 */
  4656. /***/ (function(module, exports, __webpack_require__) {
  4657. // Thank's IE8 for his funny defineProperty
  4658. module.exports = !__webpack_require__(31)(function(){
  4659. return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
  4660. });
  4661. /***/ }),
  4662. /* 22 */
  4663. /***/ (function(module, exports) {
  4664. var hasOwnProperty = {}.hasOwnProperty;
  4665. module.exports = function(it, key){
  4666. return hasOwnProperty.call(it, key);
  4667. };
  4668. /***/ }),
  4669. /* 23 */
  4670. /***/ (function(module, exports, __webpack_require__) {
  4671. // to indexed object, toObject with fallback for non-array-like ES3 strings
  4672. var IObject = __webpack_require__(78)
  4673. , defined = __webpack_require__(30);
  4674. module.exports = function(it){
  4675. return IObject(defined(it));
  4676. };
  4677. /***/ }),
  4678. /* 24 */
  4679. /***/ (function(module, exports, __webpack_require__) {
  4680. // 7.1.15 ToLength
  4681. var toInteger = __webpack_require__(62)
  4682. , min = Math.min;
  4683. module.exports = function(it){
  4684. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  4685. };
  4686. /***/ }),
  4687. /* 25 */
  4688. /***/ (function(module, exports, __webpack_require__) {
  4689. "use strict";
  4690. exports.__esModule = true;
  4691. exports.isIE8 = isIE8;
  4692. exports.isIE9 = isIE9;
  4693. exports.isSafari = isSafari;
  4694. exports.isChrome = isChrome;
  4695. exports.isMobileBrowser = isMobileBrowser;
  4696. var _isIE8 = !document.createTextNode('test').textContent;
  4697. function isIE8() {
  4698. return _isIE8;
  4699. }
  4700. var _isIE9 = !!document.documentMode;
  4701. function isIE9() {
  4702. return _isIE9;
  4703. }
  4704. var _isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
  4705. function isSafari() {
  4706. return _isSafari;
  4707. }
  4708. var _isChrome = /Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor);
  4709. function isChrome() {
  4710. return _isChrome;
  4711. }
  4712. function isMobileBrowser(userAgent) {
  4713. if (!userAgent) {
  4714. userAgent = navigator.userAgent;
  4715. }
  4716. return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)
  4717. );
  4718. }
  4719. /***/ }),
  4720. /* 26 */
  4721. /***/ (function(module, exports, __webpack_require__) {
  4722. "use strict";
  4723. exports.__esModule = true;
  4724. exports.getRegisteredValidators = exports.getRegisteredValidatorNames = exports.hasValidator = exports.getValidator = exports.registerValidator = undefined;
  4725. var _staticRegister2 = __webpack_require__(52);
  4726. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  4727. var _autocompleteValidator = __webpack_require__(388);
  4728. var _autocompleteValidator2 = _interopRequireDefault(_autocompleteValidator);
  4729. var _dateValidator = __webpack_require__(389);
  4730. var _dateValidator2 = _interopRequireDefault(_dateValidator);
  4731. var _numericValidator = __webpack_require__(390);
  4732. var _numericValidator2 = _interopRequireDefault(_numericValidator);
  4733. var _timeValidator = __webpack_require__(391);
  4734. var _timeValidator2 = _interopRequireDefault(_timeValidator);
  4735. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4736. var _staticRegister = (0, _staticRegister3.default)('validators'),
  4737. register = _staticRegister.register,
  4738. getItem = _staticRegister.getItem,
  4739. hasItem = _staticRegister.hasItem,
  4740. getNames = _staticRegister.getNames,
  4741. getValues = _staticRegister.getValues;
  4742. register('autocomplete', _autocompleteValidator2.default);
  4743. register('date', _dateValidator2.default);
  4744. register('numeric', _numericValidator2.default);
  4745. register('time', _timeValidator2.default);
  4746. /**
  4747. * Retrieve validator function.
  4748. *
  4749. * @param {String} name Validator identification.
  4750. * @returns {Function} Returns validator function.
  4751. */
  4752. function _getItem(name) {
  4753. if (typeof name === 'function') {
  4754. return name;
  4755. }
  4756. if (!hasItem(name)) {
  4757. throw Error('No registered validator found under "' + name + '" name');
  4758. }
  4759. return getItem(name);
  4760. }
  4761. exports.registerValidator = register;
  4762. exports.getValidator = _getItem;
  4763. exports.hasValidator = hasItem;
  4764. exports.getRegisteredValidatorNames = getNames;
  4765. exports.getRegisteredValidators = getValues;
  4766. /***/ }),
  4767. /* 27 */
  4768. /***/ (function(module, exports, __webpack_require__) {
  4769. "use strict";
  4770. exports.__esModule = true;
  4771. exports.toUpperCaseFirst = toUpperCaseFirst;
  4772. exports.equalsIgnoreCase = equalsIgnoreCase;
  4773. exports.randomString = randomString;
  4774. exports.isPercentValue = isPercentValue;
  4775. exports.substitute = substitute;
  4776. exports.stripTags = stripTags;
  4777. var _mixed = __webpack_require__(20);
  4778. var _number = __webpack_require__(6);
  4779. /**
  4780. * Convert string to upper case first letter.
  4781. *
  4782. * @param {String} string String to convert.
  4783. * @returns {String}
  4784. */
  4785. function toUpperCaseFirst(string) {
  4786. return string[0].toUpperCase() + string.substr(1);
  4787. }
  4788. /**
  4789. * Compare strings case insensitively.
  4790. *
  4791. * @param {...String} strings Strings to compare.
  4792. * @returns {Boolean}
  4793. */
  4794. function equalsIgnoreCase() {
  4795. var unique = [];
  4796. for (var _len = arguments.length, strings = Array(_len), _key = 0; _key < _len; _key++) {
  4797. strings[_key] = arguments[_key];
  4798. }
  4799. var length = strings.length;
  4800. while (length--) {
  4801. var string = (0, _mixed.stringify)(strings[length]).toLowerCase();
  4802. if (unique.indexOf(string) === -1) {
  4803. unique.push(string);
  4804. }
  4805. }
  4806. return unique.length === 1;
  4807. }
  4808. /**
  4809. * Generates a random hex string. Used as namespace for Handsontable instance events.
  4810. *
  4811. * @return {String} Returns 16-long character random string (eq. `'92b1bfc74ec4'`).
  4812. */
  4813. function randomString() {
  4814. function s4() {
  4815. return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  4816. }
  4817. return s4() + s4() + s4() + s4();
  4818. }
  4819. /**
  4820. * Checks if value is valid percent.
  4821. *
  4822. * @param {String} value
  4823. * @returns {Boolean}
  4824. */
  4825. function isPercentValue(value) {
  4826. return (/^([0-9][0-9]?%$)|(^100%$)/.test(value)
  4827. );
  4828. }
  4829. /**
  4830. * Substitute strings placed beetwen square brackets into value defined in `variables` object. String names defined in
  4831. * square brackets must be the same as property name of `variables` object.
  4832. *
  4833. * @param {String} template Template string.
  4834. * @param {Object} variables Object which contains all available values which can be injected into template.
  4835. * @returns {String}
  4836. */
  4837. function substitute(template) {
  4838. var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4839. return ('' + template).replace(/(?:\\)?\[([^[\]]+)]/g, function (match, name) {
  4840. if (match.charAt(0) === '\\') {
  4841. return match.substr(1, match.length - 1);
  4842. }
  4843. return variables[name] === void 0 ? '' : variables[name];
  4844. });
  4845. }
  4846. var STRIP_TAGS_REGEX = /<\/?\w+\/?>|<\w+[\s|/][^>]*>/gi;
  4847. /**
  4848. * Strip any HTML tag from the string.
  4849. *
  4850. * @param {String} string String to cut HTML from.
  4851. * @return {String}
  4852. */
  4853. function stripTags(string) {
  4854. string += '';
  4855. return string.replace(STRIP_TAGS_REGEX, '');
  4856. }
  4857. /***/ }),
  4858. /* 28 */
  4859. /***/ (function(module, exports, __webpack_require__) {
  4860. "use strict";
  4861. exports.__esModule = true;
  4862. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4863. var _element = __webpack_require__(0);
  4864. var _object = __webpack_require__(1);
  4865. var _array = __webpack_require__(2);
  4866. var _eventManager = __webpack_require__(4);
  4867. var _eventManager2 = _interopRequireDefault(_eventManager);
  4868. var _core = __webpack_require__(253);
  4869. var _core2 = _interopRequireDefault(_core);
  4870. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4871. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4872. var registeredOverlays = {};
  4873. /**
  4874. * Creates an overlay over the original Walkontable instance. The overlay renders the clone of the original Walkontable
  4875. * and (optionally) implements behavior needed for native horizontal and vertical scrolling.
  4876. *
  4877. * @class Overlay
  4878. */
  4879. var Overlay = function () {
  4880. _createClass(Overlay, null, [{
  4881. key: 'registerOverlay',
  4882. /**
  4883. * Register overlay class.
  4884. *
  4885. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4886. * @param {Overlay} overlayClass Overlay class extended from base overlay class {@link Overlay}
  4887. */
  4888. value: function registerOverlay(type, overlayClass) {
  4889. if (Overlay.CLONE_TYPES.indexOf(type) === -1) {
  4890. throw new Error('Unsupported overlay (' + type + ').');
  4891. }
  4892. registeredOverlays[type] = overlayClass;
  4893. }
  4894. /**
  4895. * Create new instance of overlay type.
  4896. *
  4897. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4898. * @param {Walkontable} wot Walkontable instance
  4899. */
  4900. }, {
  4901. key: 'createOverlay',
  4902. value: function createOverlay(type, wot) {
  4903. return new registeredOverlays[type](wot);
  4904. }
  4905. /**
  4906. * Check if specified overlay was registered.
  4907. *
  4908. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4909. * @returns {Boolean}
  4910. */
  4911. }, {
  4912. key: 'hasOverlay',
  4913. value: function hasOverlay(type) {
  4914. return registeredOverlays[type] !== void 0;
  4915. }
  4916. /**
  4917. * Checks if overlay object (`overlay`) is instance of overlay type (`type`).
  4918. *
  4919. * @param {Overlay} overlay Overlay object
  4920. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4921. * @returns {Boolean}
  4922. */
  4923. }, {
  4924. key: 'isOverlayTypeOf',
  4925. value: function isOverlayTypeOf(overlay, type) {
  4926. if (!overlay || !registeredOverlays[type]) {
  4927. return false;
  4928. }
  4929. return overlay instanceof registeredOverlays[type];
  4930. }
  4931. /**
  4932. * @param {Walkontable} wotInstance
  4933. */
  4934. }, {
  4935. key: 'CLONE_TOP',
  4936. /**
  4937. * @type {String}
  4938. */
  4939. get: function get() {
  4940. return 'top';
  4941. }
  4942. /**
  4943. * @type {String}
  4944. */
  4945. }, {
  4946. key: 'CLONE_BOTTOM',
  4947. get: function get() {
  4948. return 'bottom';
  4949. }
  4950. /**
  4951. * @type {String}
  4952. */
  4953. }, {
  4954. key: 'CLONE_LEFT',
  4955. get: function get() {
  4956. return 'left';
  4957. }
  4958. /**
  4959. * @type {String}
  4960. */
  4961. }, {
  4962. key: 'CLONE_TOP_LEFT_CORNER',
  4963. get: function get() {
  4964. return 'top_left_corner';
  4965. }
  4966. /**
  4967. * @type {String}
  4968. */
  4969. }, {
  4970. key: 'CLONE_BOTTOM_LEFT_CORNER',
  4971. get: function get() {
  4972. return 'bottom_left_corner';
  4973. }
  4974. /**
  4975. * @type {String}
  4976. */
  4977. }, {
  4978. key: 'CLONE_DEBUG',
  4979. get: function get() {
  4980. return 'debug';
  4981. }
  4982. /**
  4983. * List of all availables clone types
  4984. *
  4985. * @type {Array}
  4986. */
  4987. }, {
  4988. key: 'CLONE_TYPES',
  4989. get: function get() {
  4990. return [Overlay.CLONE_TOP, Overlay.CLONE_BOTTOM, Overlay.CLONE_LEFT, Overlay.CLONE_TOP_LEFT_CORNER, Overlay.CLONE_BOTTOM_LEFT_CORNER, Overlay.CLONE_DEBUG];
  4991. }
  4992. }]);
  4993. function Overlay(wotInstance) {
  4994. _classCallCheck(this, Overlay);
  4995. (0, _object.defineGetter)(this, 'wot', wotInstance, {
  4996. writable: false
  4997. });
  4998. // legacy support, deprecated in the future
  4999. this.instance = this.wot;
  5000. this.type = '';
  5001. this.mainTableScrollableElement = null;
  5002. this.TABLE = this.wot.wtTable.TABLE;
  5003. this.hider = this.wot.wtTable.hider;
  5004. this.spreader = this.wot.wtTable.spreader;
  5005. this.holder = this.wot.wtTable.holder;
  5006. this.wtRootElement = this.wot.wtTable.wtRootElement;
  5007. this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode);
  5008. this.areElementSizesAdjusted = false;
  5009. this.updateStateOfRendering();
  5010. }
  5011. /**
  5012. * Update internal state of object with an information about the need of full rendering of the overlay.
  5013. *
  5014. * @returns {Boolean} Returns `true` if the state has changed since the last check.
  5015. */
  5016. _createClass(Overlay, [{
  5017. key: 'updateStateOfRendering',
  5018. value: function updateStateOfRendering() {
  5019. var previousState = this.needFullRender;
  5020. this.needFullRender = this.shouldBeRendered();
  5021. var changed = previousState !== this.needFullRender;
  5022. if (changed && !this.needFullRender) {
  5023. this.reset();
  5024. }
  5025. return changed;
  5026. }
  5027. /**
  5028. * Checks if overlay should be fully rendered
  5029. *
  5030. * @returns {Boolean}
  5031. */
  5032. }, {
  5033. key: 'shouldBeRendered',
  5034. value: function shouldBeRendered() {
  5035. return true;
  5036. }
  5037. /**
  5038. * Update the trimming container.
  5039. */
  5040. }, {
  5041. key: 'updateTrimmingContainer',
  5042. value: function updateTrimmingContainer() {
  5043. this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode);
  5044. }
  5045. /**
  5046. * Update the main scrollable element.
  5047. */
  5048. }, {
  5049. key: 'updateMainScrollableElement',
  5050. value: function updateMainScrollableElement() {
  5051. this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  5052. }
  5053. /**
  5054. * Make a clone of table for overlay
  5055. *
  5056. * @param {String} direction Can be `Overlay.CLONE_TOP`, `Overlay.CLONE_LEFT`,
  5057. * `Overlay.CLONE_TOP_LEFT_CORNER`, `Overlay.CLONE_DEBUG`
  5058. * @returns {Walkontable}
  5059. */
  5060. }, {
  5061. key: 'makeClone',
  5062. value: function makeClone(direction) {
  5063. if (Overlay.CLONE_TYPES.indexOf(direction) === -1) {
  5064. throw new Error('Clone type "' + direction + '" is not supported.');
  5065. }
  5066. var clone = document.createElement('DIV');
  5067. var clonedTable = document.createElement('TABLE');
  5068. clone.className = 'ht_clone_' + direction + ' handsontable';
  5069. clone.style.position = 'absolute';
  5070. clone.style.top = 0;
  5071. clone.style.left = 0;
  5072. clone.style.overflow = 'hidden';
  5073. clonedTable.className = this.wot.wtTable.TABLE.className;
  5074. clone.appendChild(clonedTable);
  5075. this.type = direction;
  5076. this.wot.wtTable.wtRootElement.parentNode.appendChild(clone);
  5077. var preventOverflow = this.wot.getSetting('preventOverflow');
  5078. if (preventOverflow === true || preventOverflow === 'horizontal' && this.type === Overlay.CLONE_TOP || preventOverflow === 'vertical' && this.type === Overlay.CLONE_LEFT) {
  5079. this.mainTableScrollableElement = window;
  5080. } else {
  5081. this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  5082. }
  5083. return new _core2.default({
  5084. cloneSource: this.wot,
  5085. cloneOverlay: this,
  5086. table: clonedTable
  5087. });
  5088. }
  5089. /**
  5090. * Refresh/Redraw overlay
  5091. *
  5092. * @param {Boolean} [fastDraw=false]
  5093. */
  5094. }, {
  5095. key: 'refresh',
  5096. value: function refresh() {
  5097. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5098. // When hot settings are changed we allow to refresh overlay once before blocking
  5099. var nextCycleRenderFlag = this.shouldBeRendered();
  5100. if (this.clone && (this.needFullRender || nextCycleRenderFlag)) {
  5101. this.clone.draw(fastDraw);
  5102. }
  5103. this.needFullRender = nextCycleRenderFlag;
  5104. }
  5105. /**
  5106. * Reset overlay styles to initial values.
  5107. */
  5108. }, {
  5109. key: 'reset',
  5110. value: function reset() {
  5111. if (!this.clone) {
  5112. return;
  5113. }
  5114. var holder = this.clone.wtTable.holder;
  5115. var hider = this.clone.wtTable.hider;
  5116. var holderStyle = holder.style;
  5117. var hidderStyle = hider.style;
  5118. var rootStyle = holder.parentNode.style;
  5119. (0, _array.arrayEach)([holderStyle, hidderStyle, rootStyle], function (style) {
  5120. style.width = '';
  5121. style.height = '';
  5122. });
  5123. }
  5124. /**
  5125. * Destroy overlay instance
  5126. */
  5127. }, {
  5128. key: 'destroy',
  5129. value: function destroy() {
  5130. new _eventManager2.default(this.clone).destroy();
  5131. }
  5132. }]);
  5133. return Overlay;
  5134. }();
  5135. exports.default = Overlay;
  5136. /***/ }),
  5137. /* 29 */
  5138. /***/ (function(module, exports, __webpack_require__) {
  5139. // optional / simple context binding
  5140. var aFunction = __webpack_require__(73);
  5141. module.exports = function(fn, that, length){
  5142. aFunction(fn);
  5143. if(that === undefined)return fn;
  5144. switch(length){
  5145. case 1: return function(a){
  5146. return fn.call(that, a);
  5147. };
  5148. case 2: return function(a, b){
  5149. return fn.call(that, a, b);
  5150. };
  5151. case 3: return function(a, b, c){
  5152. return fn.call(that, a, b, c);
  5153. };
  5154. }
  5155. return function(/* ...args */){
  5156. return fn.apply(that, arguments);
  5157. };
  5158. };
  5159. /***/ }),
  5160. /* 30 */
  5161. /***/ (function(module, exports) {
  5162. // 7.2.1 RequireObjectCoercible(argument)
  5163. module.exports = function(it){
  5164. if(it == undefined)throw TypeError("Can't call method on " + it);
  5165. return it;
  5166. };
  5167. /***/ }),
  5168. /* 31 */
  5169. /***/ (function(module, exports) {
  5170. module.exports = function(exec){
  5171. try {
  5172. return !!exec();
  5173. } catch(e){
  5174. return true;
  5175. }
  5176. };
  5177. /***/ }),
  5178. /* 32 */
  5179. /***/ (function(module, exports, __webpack_require__) {
  5180. var dP = __webpack_require__(19)
  5181. , createDesc = __webpack_require__(41);
  5182. module.exports = __webpack_require__(21) ? function(object, key, value){
  5183. return dP.f(object, key, createDesc(1, value));
  5184. } : function(object, key, value){
  5185. object[key] = value;
  5186. return object;
  5187. };
  5188. /***/ }),
  5189. /* 33 */
  5190. /***/ (function(module, exports, __webpack_require__) {
  5191. var global = __webpack_require__(13)
  5192. , hide = __webpack_require__(32)
  5193. , has = __webpack_require__(22)
  5194. , SRC = __webpack_require__(50)('src')
  5195. , TO_STRING = 'toString'
  5196. , $toString = Function[TO_STRING]
  5197. , TPL = ('' + $toString).split(TO_STRING);
  5198. __webpack_require__(45).inspectSource = function(it){
  5199. return $toString.call(it);
  5200. };
  5201. (module.exports = function(O, key, val, safe){
  5202. var isFunction = typeof val == 'function';
  5203. if(isFunction)has(val, 'name') || hide(val, 'name', key);
  5204. if(O[key] === val)return;
  5205. if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  5206. if(O === global){
  5207. O[key] = val;
  5208. } else {
  5209. if(!safe){
  5210. delete O[key];
  5211. hide(O, key, val);
  5212. } else {
  5213. if(O[key])O[key] = val;
  5214. else hide(O, key, val);
  5215. }
  5216. }
  5217. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  5218. })(Function.prototype, TO_STRING, function toString(){
  5219. return typeof this == 'function' && this[SRC] || $toString.call(this);
  5220. });
  5221. /***/ }),
  5222. /* 34 */
  5223. /***/ (function(module, exports, __webpack_require__) {
  5224. "use strict";
  5225. exports.__esModule = true;
  5226. var _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; };
  5227. exports.requestAnimationFrame = requestAnimationFrame;
  5228. exports.cancelAnimationFrame = cancelAnimationFrame;
  5229. exports.isTouchSupported = isTouchSupported;
  5230. exports.isWebComponentSupportedNatively = isWebComponentSupportedNatively;
  5231. exports.hasCaptionProblem = hasCaptionProblem;
  5232. exports.getComparisonFunction = getComparisonFunction;
  5233. // https://gist.github.com/paulirish/1579671
  5234. var lastTime = 0;
  5235. var vendors = ['ms', 'moz', 'webkit', 'o'];
  5236. var _requestAnimationFrame = window.requestAnimationFrame;
  5237. var _cancelAnimationFrame = window.cancelAnimationFrame;
  5238. for (var x = 0; x < vendors.length && !_requestAnimationFrame; ++x) {
  5239. _requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
  5240. _cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
  5241. }
  5242. if (!_requestAnimationFrame) {
  5243. _requestAnimationFrame = function _requestAnimationFrame(callback) {
  5244. var currTime = new Date().getTime();
  5245. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  5246. var id = window.setTimeout(function () {
  5247. callback(currTime + timeToCall);
  5248. }, timeToCall);
  5249. lastTime = currTime + timeToCall;
  5250. return id;
  5251. };
  5252. }
  5253. if (!_cancelAnimationFrame) {
  5254. _cancelAnimationFrame = function _cancelAnimationFrame(id) {
  5255. clearTimeout(id);
  5256. };
  5257. }
  5258. /**
  5259. * Polyfill for requestAnimationFrame
  5260. *
  5261. * @param {Function} callback
  5262. * @returns {Number}
  5263. */
  5264. function requestAnimationFrame(callback) {
  5265. return _requestAnimationFrame.call(window, callback);
  5266. }
  5267. /**
  5268. * Polyfill for cancelAnimationFrame
  5269. *
  5270. * @param {Number} id
  5271. */
  5272. function cancelAnimationFrame(id) {
  5273. _cancelAnimationFrame.call(window, id);
  5274. }
  5275. function isTouchSupported() {
  5276. return 'ontouchstart' in window;
  5277. }
  5278. /**
  5279. * Checks if browser is support web components natively
  5280. *
  5281. * @returns {Boolean}
  5282. */
  5283. function isWebComponentSupportedNatively() {
  5284. var test = document.createElement('div');
  5285. return !!(test.createShadowRoot && test.createShadowRoot.toString().match(/\[native code\]/));
  5286. }
  5287. var _hasCaptionProblem;
  5288. function detectCaptionProblem() {
  5289. var TABLE = document.createElement('TABLE');
  5290. TABLE.style.borderSpacing = 0;
  5291. TABLE.style.borderWidth = 0;
  5292. TABLE.style.padding = 0;
  5293. var TBODY = document.createElement('TBODY');
  5294. TABLE.appendChild(TBODY);
  5295. TBODY.appendChild(document.createElement('TR'));
  5296. TBODY.firstChild.appendChild(document.createElement('TD'));
  5297. TBODY.firstChild.firstChild.innerHTML = '<tr><td>t<br>t</td></tr>';
  5298. var CAPTION = document.createElement('CAPTION');
  5299. CAPTION.innerHTML = 'c<br>c<br>c<br>c';
  5300. CAPTION.style.padding = 0;
  5301. CAPTION.style.margin = 0;
  5302. TABLE.insertBefore(CAPTION, TBODY);
  5303. document.body.appendChild(TABLE);
  5304. _hasCaptionProblem = TABLE.offsetHeight < 2 * TABLE.lastChild.offsetHeight; // boolean
  5305. document.body.removeChild(TABLE);
  5306. }
  5307. function hasCaptionProblem() {
  5308. if (_hasCaptionProblem === void 0) {
  5309. detectCaptionProblem();
  5310. }
  5311. return _hasCaptionProblem;
  5312. }
  5313. var comparisonFunction = void 0;
  5314. /**
  5315. * Get string comparison function for sorting purposes. It supports multilingual string comparison base on Internationalization API.
  5316. *
  5317. * @param {String} [language]
  5318. * @param {Object} [options]
  5319. * @returns {*}
  5320. */
  5321. function getComparisonFunction(language) {
  5322. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5323. if (comparisonFunction) {
  5324. return comparisonFunction;
  5325. }
  5326. if ((typeof Intl === 'undefined' ? 'undefined' : _typeof(Intl)) === 'object') {
  5327. comparisonFunction = new Intl.Collator(language, options).compare;
  5328. } else if (typeof String.prototype.localeCompare === 'function') {
  5329. comparisonFunction = function comparisonFunction(a, b) {
  5330. return ('' + a).localeCompare(b);
  5331. };
  5332. } else {
  5333. comparisonFunction = function comparisonFunction(a, b) {
  5334. if (a === b) {
  5335. return 0;
  5336. }
  5337. return a > b ? -1 : 1;
  5338. };
  5339. }
  5340. return comparisonFunction;
  5341. }
  5342. /***/ }),
  5343. /* 35 */
  5344. /***/ (function(module, exports, __webpack_require__) {
  5345. "use strict";
  5346. exports.__esModule = true;
  5347. exports.isFunction = isFunction;
  5348. exports.throttle = throttle;
  5349. exports.throttleAfterHits = throttleAfterHits;
  5350. exports.debounce = debounce;
  5351. exports.pipe = pipe;
  5352. exports.partial = partial;
  5353. exports.curry = curry;
  5354. exports.curryRight = curryRight;
  5355. var _array = __webpack_require__(2);
  5356. /**
  5357. * Checks if given variable is function.
  5358. *
  5359. * @param {*} func Variable to check.
  5360. * @returns {Boolean}
  5361. */
  5362. function isFunction(func) {
  5363. return typeof func === 'function';
  5364. }
  5365. /**
  5366. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over time (`wait`).
  5367. *
  5368. * @param {Function} func Function to invoke.
  5369. * @param {Number} wait Delay in miliseconds.
  5370. * @returns {Function}
  5371. */
  5372. function throttle(func) {
  5373. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5374. var lastCalled = 0;
  5375. var result = {
  5376. lastCallThrottled: true
  5377. };
  5378. var lastTimer = null;
  5379. function _throttle() {
  5380. var _this = this;
  5381. var args = arguments;
  5382. var stamp = Date.now();
  5383. var needCall = false;
  5384. result.lastCallThrottled = true;
  5385. if (!lastCalled) {
  5386. lastCalled = stamp;
  5387. needCall = true;
  5388. }
  5389. var remaining = wait - (stamp - lastCalled);
  5390. if (needCall) {
  5391. result.lastCallThrottled = false;
  5392. func.apply(this, args);
  5393. } else {
  5394. if (lastTimer) {
  5395. clearTimeout(lastTimer);
  5396. }
  5397. lastTimer = setTimeout(function () {
  5398. result.lastCallThrottled = false;
  5399. func.apply(_this, args);
  5400. lastCalled = 0;
  5401. lastTimer = void 0;
  5402. }, remaining);
  5403. }
  5404. return result;
  5405. }
  5406. return _throttle;
  5407. }
  5408. /**
  5409. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over
  5410. * time (`wait`) after specified hits.
  5411. *
  5412. * @param {Function} func Function to invoke.
  5413. * @param {Number} wait Delay in miliseconds.
  5414. * @param {Number} hits Number of hits after throttling will be applied.
  5415. * @returns {Function}
  5416. */
  5417. function throttleAfterHits(func) {
  5418. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5419. var hits = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  5420. var funcThrottle = throttle(func, wait);
  5421. var remainHits = hits;
  5422. function _clearHits() {
  5423. remainHits = hits;
  5424. }
  5425. function _throttleAfterHits() {
  5426. if (remainHits) {
  5427. remainHits--;
  5428. return func.apply(this, arguments);
  5429. }
  5430. return funcThrottle.apply(this, arguments);
  5431. }
  5432. _throttleAfterHits.clearHits = _clearHits;
  5433. return _throttleAfterHits;
  5434. }
  5435. /**
  5436. * Creates debounce function that enforces a function (`func`) not be called again until a certain amount of time (`wait`)
  5437. * has passed without it being called.
  5438. *
  5439. * @param {Function} func Function to invoke.
  5440. * @param {Number} wait Delay in milliseconds.
  5441. * @returns {Function}
  5442. */
  5443. function debounce(func) {
  5444. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5445. var lastTimer = null;
  5446. var result = void 0;
  5447. function _debounce() {
  5448. var _this2 = this;
  5449. var args = arguments;
  5450. if (lastTimer) {
  5451. clearTimeout(lastTimer);
  5452. }
  5453. lastTimer = setTimeout(function () {
  5454. result = func.apply(_this2, args);
  5455. }, wait);
  5456. return result;
  5457. }
  5458. return _debounce;
  5459. }
  5460. /**
  5461. * Creates the function that returns the result of calling the given functions. Result of the first function is passed to
  5462. * the second as an argument and so on. Only first function in the chain can handle multiple arguments.
  5463. *
  5464. * @param {Function} functions Functions to compose.
  5465. * @returns {Function}
  5466. */
  5467. function pipe() {
  5468. for (var _len = arguments.length, functions = Array(_len), _key = 0; _key < _len; _key++) {
  5469. functions[_key] = arguments[_key];
  5470. }
  5471. var firstFunc = functions[0],
  5472. restFunc = functions.slice(1);
  5473. return function _pipe() {
  5474. return (0, _array.arrayReduce)(restFunc, function (acc, fn) {
  5475. return fn(acc);
  5476. }, firstFunc.apply(this, arguments));
  5477. };
  5478. }
  5479. /**
  5480. * Creates the function that returns the function with cached arguments.
  5481. *
  5482. * @param {Function} func Function to partialization.
  5483. * @param {Array} params Function arguments to cache.
  5484. * @returns {Function}
  5485. */
  5486. function partial(func) {
  5487. for (var _len2 = arguments.length, params = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  5488. params[_key2 - 1] = arguments[_key2];
  5489. }
  5490. return function _partial() {
  5491. for (var _len3 = arguments.length, restParams = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  5492. restParams[_key3] = arguments[_key3];
  5493. }
  5494. return func.apply(this, params.concat(restParams));
  5495. };
  5496. }
  5497. /**
  5498. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  5499. * to the arguments defined in `func` then function will be invoked.
  5500. * Arguments are added to the stack in direction from the left to the right.
  5501. *
  5502. * @example
  5503. * ```
  5504. * var replace = curry(function(find, replace, string) {
  5505. * return string.replace(find, replace);
  5506. * });
  5507. *
  5508. * // returns function with bounded first argument
  5509. * var replace = replace('foo')
  5510. *
  5511. * // returns replaced string - all arguments was passed so function was invoked
  5512. * replace('bar', 'Some test with foo...');
  5513. *
  5514. * ```
  5515. *
  5516. * @param {Function} func Function to currying.
  5517. * @returns {Function}
  5518. */
  5519. function curry(func) {
  5520. var argsLength = func.length;
  5521. function given(argsSoFar) {
  5522. return function _curry() {
  5523. for (var _len4 = arguments.length, params = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  5524. params[_key4] = arguments[_key4];
  5525. }
  5526. var passedArgsSoFar = argsSoFar.concat(params);
  5527. var result = void 0;
  5528. if (passedArgsSoFar.length >= argsLength) {
  5529. result = func.apply(this, passedArgsSoFar);
  5530. } else {
  5531. result = given(passedArgsSoFar);
  5532. }
  5533. return result;
  5534. };
  5535. }
  5536. return given([]);
  5537. }
  5538. /**
  5539. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  5540. * to the arguments defined in `func` then function will be invoked.
  5541. * Arguments are added to the stack in direction from the right to the left.
  5542. *
  5543. * @example
  5544. * ```
  5545. * var replace = curry(function(find, replace, string) {
  5546. * return string.replace(find, replace);
  5547. * });
  5548. *
  5549. * // returns function with bounded first argument
  5550. * var replace = replace('Some test with foo...')
  5551. *
  5552. * // returns replaced string - all arguments was passed so function was invoked
  5553. * replace('bar', 'foo');
  5554. *
  5555. * ```
  5556. *
  5557. * @param {Function} func Function to currying.
  5558. * @returns {Function}
  5559. */
  5560. function curryRight(func) {
  5561. var argsLength = func.length;
  5562. function given(argsSoFar) {
  5563. return function _curry() {
  5564. for (var _len5 = arguments.length, params = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  5565. params[_key5] = arguments[_key5];
  5566. }
  5567. var passedArgsSoFar = argsSoFar.concat(params.reverse());
  5568. var result = void 0;
  5569. if (passedArgsSoFar.length >= argsLength) {
  5570. result = func.apply(this, passedArgsSoFar);
  5571. } else {
  5572. result = given(passedArgsSoFar);
  5573. }
  5574. return result;
  5575. };
  5576. }
  5577. return given([]);
  5578. }
  5579. /***/ }),
  5580. /* 36 */
  5581. /***/ (function(module, exports, __webpack_require__) {
  5582. /* WEBPACK VAR INJECTION */(function(module) {//! moment.js
  5583. //! version : 2.18.1
  5584. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  5585. //! license : MIT
  5586. //! momentjs.com
  5587. ;(function (global, factory) {
  5588. true ? module.exports = factory() :
  5589. typeof define === 'function' && define.amd ? define(factory) :
  5590. global.moment = factory()
  5591. }(this, (function () { 'use strict';
  5592. var hookCallback;
  5593. function hooks () {
  5594. return hookCallback.apply(null, arguments);
  5595. }
  5596. // This is done to register the method called with moment()
  5597. // without creating circular dependencies.
  5598. function setHookCallback (callback) {
  5599. hookCallback = callback;
  5600. }
  5601. function isArray(input) {
  5602. return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
  5603. }
  5604. function isObject(input) {
  5605. // IE8 will treat undefined and null as object if it wasn't for
  5606. // input != null
  5607. return input != null && Object.prototype.toString.call(input) === '[object Object]';
  5608. }
  5609. function isObjectEmpty(obj) {
  5610. var k;
  5611. for (k in obj) {
  5612. // even if its not own property I'd still call it non-empty
  5613. return false;
  5614. }
  5615. return true;
  5616. }
  5617. function isUndefined(input) {
  5618. return input === void 0;
  5619. }
  5620. function isNumber(input) {
  5621. return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
  5622. }
  5623. function isDate(input) {
  5624. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  5625. }
  5626. function map(arr, fn) {
  5627. var res = [], i;
  5628. for (i = 0; i < arr.length; ++i) {
  5629. res.push(fn(arr[i], i));
  5630. }
  5631. return res;
  5632. }
  5633. function hasOwnProp(a, b) {
  5634. return Object.prototype.hasOwnProperty.call(a, b);
  5635. }
  5636. function extend(a, b) {
  5637. for (var i in b) {
  5638. if (hasOwnProp(b, i)) {
  5639. a[i] = b[i];
  5640. }
  5641. }
  5642. if (hasOwnProp(b, 'toString')) {
  5643. a.toString = b.toString;
  5644. }
  5645. if (hasOwnProp(b, 'valueOf')) {
  5646. a.valueOf = b.valueOf;
  5647. }
  5648. return a;
  5649. }
  5650. function createUTC (input, format, locale, strict) {
  5651. return createLocalOrUTC(input, format, locale, strict, true).utc();
  5652. }
  5653. function defaultParsingFlags() {
  5654. // We need to deep clone this object.
  5655. return {
  5656. empty : false,
  5657. unusedTokens : [],
  5658. unusedInput : [],
  5659. overflow : -2,
  5660. charsLeftOver : 0,
  5661. nullInput : false,
  5662. invalidMonth : null,
  5663. invalidFormat : false,
  5664. userInvalidated : false,
  5665. iso : false,
  5666. parsedDateParts : [],
  5667. meridiem : null,
  5668. rfc2822 : false,
  5669. weekdayMismatch : false
  5670. };
  5671. }
  5672. function getParsingFlags(m) {
  5673. if (m._pf == null) {
  5674. m._pf = defaultParsingFlags();
  5675. }
  5676. return m._pf;
  5677. }
  5678. var some;
  5679. if (Array.prototype.some) {
  5680. some = Array.prototype.some;
  5681. } else {
  5682. some = function (fun) {
  5683. var t = Object(this);
  5684. var len = t.length >>> 0;
  5685. for (var i = 0; i < len; i++) {
  5686. if (i in t && fun.call(this, t[i], i, t)) {
  5687. return true;
  5688. }
  5689. }
  5690. return false;
  5691. };
  5692. }
  5693. var some$1 = some;
  5694. function isValid(m) {
  5695. if (m._isValid == null) {
  5696. var flags = getParsingFlags(m);
  5697. var parsedParts = some$1.call(flags.parsedDateParts, function (i) {
  5698. return i != null;
  5699. });
  5700. var isNowValid = !isNaN(m._d.getTime()) &&
  5701. flags.overflow < 0 &&
  5702. !flags.empty &&
  5703. !flags.invalidMonth &&
  5704. !flags.invalidWeekday &&
  5705. !flags.nullInput &&
  5706. !flags.invalidFormat &&
  5707. !flags.userInvalidated &&
  5708. (!flags.meridiem || (flags.meridiem && parsedParts));
  5709. if (m._strict) {
  5710. isNowValid = isNowValid &&
  5711. flags.charsLeftOver === 0 &&
  5712. flags.unusedTokens.length === 0 &&
  5713. flags.bigHour === undefined;
  5714. }
  5715. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  5716. m._isValid = isNowValid;
  5717. }
  5718. else {
  5719. return isNowValid;
  5720. }
  5721. }
  5722. return m._isValid;
  5723. }
  5724. function createInvalid (flags) {
  5725. var m = createUTC(NaN);
  5726. if (flags != null) {
  5727. extend(getParsingFlags(m), flags);
  5728. }
  5729. else {
  5730. getParsingFlags(m).userInvalidated = true;
  5731. }
  5732. return m;
  5733. }
  5734. // Plugins that add properties should also add the key here (null value),
  5735. // so we can properly clone ourselves.
  5736. var momentProperties = hooks.momentProperties = [];
  5737. function copyConfig(to, from) {
  5738. var i, prop, val;
  5739. if (!isUndefined(from._isAMomentObject)) {
  5740. to._isAMomentObject = from._isAMomentObject;
  5741. }
  5742. if (!isUndefined(from._i)) {
  5743. to._i = from._i;
  5744. }
  5745. if (!isUndefined(from._f)) {
  5746. to._f = from._f;
  5747. }
  5748. if (!isUndefined(from._l)) {
  5749. to._l = from._l;
  5750. }
  5751. if (!isUndefined(from._strict)) {
  5752. to._strict = from._strict;
  5753. }
  5754. if (!isUndefined(from._tzm)) {
  5755. to._tzm = from._tzm;
  5756. }
  5757. if (!isUndefined(from._isUTC)) {
  5758. to._isUTC = from._isUTC;
  5759. }
  5760. if (!isUndefined(from._offset)) {
  5761. to._offset = from._offset;
  5762. }
  5763. if (!isUndefined(from._pf)) {
  5764. to._pf = getParsingFlags(from);
  5765. }
  5766. if (!isUndefined(from._locale)) {
  5767. to._locale = from._locale;
  5768. }
  5769. if (momentProperties.length > 0) {
  5770. for (i = 0; i < momentProperties.length; i++) {
  5771. prop = momentProperties[i];
  5772. val = from[prop];
  5773. if (!isUndefined(val)) {
  5774. to[prop] = val;
  5775. }
  5776. }
  5777. }
  5778. return to;
  5779. }
  5780. var updateInProgress = false;
  5781. // Moment prototype object
  5782. function Moment(config) {
  5783. copyConfig(this, config);
  5784. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  5785. if (!this.isValid()) {
  5786. this._d = new Date(NaN);
  5787. }
  5788. // Prevent infinite loop in case updateOffset creates new moment
  5789. // objects.
  5790. if (updateInProgress === false) {
  5791. updateInProgress = true;
  5792. hooks.updateOffset(this);
  5793. updateInProgress = false;
  5794. }
  5795. }
  5796. function isMoment (obj) {
  5797. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  5798. }
  5799. function absFloor (number) {
  5800. if (number < 0) {
  5801. // -0 -> 0
  5802. return Math.ceil(number) || 0;
  5803. } else {
  5804. return Math.floor(number);
  5805. }
  5806. }
  5807. function toInt(argumentForCoercion) {
  5808. var coercedNumber = +argumentForCoercion,
  5809. value = 0;
  5810. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  5811. value = absFloor(coercedNumber);
  5812. }
  5813. return value;
  5814. }
  5815. // compare two arrays, return the number of differences
  5816. function compareArrays(array1, array2, dontConvert) {
  5817. var len = Math.min(array1.length, array2.length),
  5818. lengthDiff = Math.abs(array1.length - array2.length),
  5819. diffs = 0,
  5820. i;
  5821. for (i = 0; i < len; i++) {
  5822. if ((dontConvert && array1[i] !== array2[i]) ||
  5823. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  5824. diffs++;
  5825. }
  5826. }
  5827. return diffs + lengthDiff;
  5828. }
  5829. function warn(msg) {
  5830. if (hooks.suppressDeprecationWarnings === false &&
  5831. (typeof console !== 'undefined') && console.warn) {
  5832. console.warn('Deprecation warning: ' + msg);
  5833. }
  5834. }
  5835. function deprecate(msg, fn) {
  5836. var firstTime = true;
  5837. return extend(function () {
  5838. if (hooks.deprecationHandler != null) {
  5839. hooks.deprecationHandler(null, msg);
  5840. }
  5841. if (firstTime) {
  5842. var args = [];
  5843. var arg;
  5844. for (var i = 0; i < arguments.length; i++) {
  5845. arg = '';
  5846. if (typeof arguments[i] === 'object') {
  5847. arg += '\n[' + i + '] ';
  5848. for (var key in arguments[0]) {
  5849. arg += key + ': ' + arguments[0][key] + ', ';
  5850. }
  5851. arg = arg.slice(0, -2); // Remove trailing comma and space
  5852. } else {
  5853. arg = arguments[i];
  5854. }
  5855. args.push(arg);
  5856. }
  5857. warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
  5858. firstTime = false;
  5859. }
  5860. return fn.apply(this, arguments);
  5861. }, fn);
  5862. }
  5863. var deprecations = {};
  5864. function deprecateSimple(name, msg) {
  5865. if (hooks.deprecationHandler != null) {
  5866. hooks.deprecationHandler(name, msg);
  5867. }
  5868. if (!deprecations[name]) {
  5869. warn(msg);
  5870. deprecations[name] = true;
  5871. }
  5872. }
  5873. hooks.suppressDeprecationWarnings = false;
  5874. hooks.deprecationHandler = null;
  5875. function isFunction(input) {
  5876. return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
  5877. }
  5878. function set (config) {
  5879. var prop, i;
  5880. for (i in config) {
  5881. prop = config[i];
  5882. if (isFunction(prop)) {
  5883. this[i] = prop;
  5884. } else {
  5885. this['_' + i] = prop;
  5886. }
  5887. }
  5888. this._config = config;
  5889. // Lenient ordinal parsing accepts just a number in addition to
  5890. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  5891. // TODO: Remove "ordinalParse" fallback in next major release.
  5892. this._dayOfMonthOrdinalParseLenient = new RegExp(
  5893. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  5894. '|' + (/\d{1,2}/).source);
  5895. }
  5896. function mergeConfigs(parentConfig, childConfig) {
  5897. var res = extend({}, parentConfig), prop;
  5898. for (prop in childConfig) {
  5899. if (hasOwnProp(childConfig, prop)) {
  5900. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  5901. res[prop] = {};
  5902. extend(res[prop], parentConfig[prop]);
  5903. extend(res[prop], childConfig[prop]);
  5904. } else if (childConfig[prop] != null) {
  5905. res[prop] = childConfig[prop];
  5906. } else {
  5907. delete res[prop];
  5908. }
  5909. }
  5910. }
  5911. for (prop in parentConfig) {
  5912. if (hasOwnProp(parentConfig, prop) &&
  5913. !hasOwnProp(childConfig, prop) &&
  5914. isObject(parentConfig[prop])) {
  5915. // make sure changes to properties don't modify parent config
  5916. res[prop] = extend({}, res[prop]);
  5917. }
  5918. }
  5919. return res;
  5920. }
  5921. function Locale(config) {
  5922. if (config != null) {
  5923. this.set(config);
  5924. }
  5925. }
  5926. var keys;
  5927. if (Object.keys) {
  5928. keys = Object.keys;
  5929. } else {
  5930. keys = function (obj) {
  5931. var i, res = [];
  5932. for (i in obj) {
  5933. if (hasOwnProp(obj, i)) {
  5934. res.push(i);
  5935. }
  5936. }
  5937. return res;
  5938. };
  5939. }
  5940. var keys$1 = keys;
  5941. var defaultCalendar = {
  5942. sameDay : '[Today at] LT',
  5943. nextDay : '[Tomorrow at] LT',
  5944. nextWeek : 'dddd [at] LT',
  5945. lastDay : '[Yesterday at] LT',
  5946. lastWeek : '[Last] dddd [at] LT',
  5947. sameElse : 'L'
  5948. };
  5949. function calendar (key, mom, now) {
  5950. var output = this._calendar[key] || this._calendar['sameElse'];
  5951. return isFunction(output) ? output.call(mom, now) : output;
  5952. }
  5953. var defaultLongDateFormat = {
  5954. LTS : 'h:mm:ss A',
  5955. LT : 'h:mm A',
  5956. L : 'MM/DD/YYYY',
  5957. LL : 'MMMM D, YYYY',
  5958. LLL : 'MMMM D, YYYY h:mm A',
  5959. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  5960. };
  5961. function longDateFormat (key) {
  5962. var format = this._longDateFormat[key],
  5963. formatUpper = this._longDateFormat[key.toUpperCase()];
  5964. if (format || !formatUpper) {
  5965. return format;
  5966. }
  5967. this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
  5968. return val.slice(1);
  5969. });
  5970. return this._longDateFormat[key];
  5971. }
  5972. var defaultInvalidDate = 'Invalid date';
  5973. function invalidDate () {
  5974. return this._invalidDate;
  5975. }
  5976. var defaultOrdinal = '%d';
  5977. var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  5978. function ordinal (number) {
  5979. return this._ordinal.replace('%d', number);
  5980. }
  5981. var defaultRelativeTime = {
  5982. future : 'in %s',
  5983. past : '%s ago',
  5984. s : 'a few seconds',
  5985. ss : '%d seconds',
  5986. m : 'a minute',
  5987. mm : '%d minutes',
  5988. h : 'an hour',
  5989. hh : '%d hours',
  5990. d : 'a day',
  5991. dd : '%d days',
  5992. M : 'a month',
  5993. MM : '%d months',
  5994. y : 'a year',
  5995. yy : '%d years'
  5996. };
  5997. function relativeTime (number, withoutSuffix, string, isFuture) {
  5998. var output = this._relativeTime[string];
  5999. return (isFunction(output)) ?
  6000. output(number, withoutSuffix, string, isFuture) :
  6001. output.replace(/%d/i, number);
  6002. }
  6003. function pastFuture (diff, output) {
  6004. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  6005. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  6006. }
  6007. var aliases = {};
  6008. function addUnitAlias (unit, shorthand) {
  6009. var lowerCase = unit.toLowerCase();
  6010. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  6011. }
  6012. function normalizeUnits(units) {
  6013. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  6014. }
  6015. function normalizeObjectUnits(inputObject) {
  6016. var normalizedInput = {},
  6017. normalizedProp,
  6018. prop;
  6019. for (prop in inputObject) {
  6020. if (hasOwnProp(inputObject, prop)) {
  6021. normalizedProp = normalizeUnits(prop);
  6022. if (normalizedProp) {
  6023. normalizedInput[normalizedProp] = inputObject[prop];
  6024. }
  6025. }
  6026. }
  6027. return normalizedInput;
  6028. }
  6029. var priorities = {};
  6030. function addUnitPriority(unit, priority) {
  6031. priorities[unit] = priority;
  6032. }
  6033. function getPrioritizedUnits(unitsObj) {
  6034. var units = [];
  6035. for (var u in unitsObj) {
  6036. units.push({unit: u, priority: priorities[u]});
  6037. }
  6038. units.sort(function (a, b) {
  6039. return a.priority - b.priority;
  6040. });
  6041. return units;
  6042. }
  6043. function makeGetSet (unit, keepTime) {
  6044. return function (value) {
  6045. if (value != null) {
  6046. set$1(this, unit, value);
  6047. hooks.updateOffset(this, keepTime);
  6048. return this;
  6049. } else {
  6050. return get(this, unit);
  6051. }
  6052. };
  6053. }
  6054. function get (mom, unit) {
  6055. return mom.isValid() ?
  6056. mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
  6057. }
  6058. function set$1 (mom, unit, value) {
  6059. if (mom.isValid()) {
  6060. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  6061. }
  6062. }
  6063. // MOMENTS
  6064. function stringGet (units) {
  6065. units = normalizeUnits(units);
  6066. if (isFunction(this[units])) {
  6067. return this[units]();
  6068. }
  6069. return this;
  6070. }
  6071. function stringSet (units, value) {
  6072. if (typeof units === 'object') {
  6073. units = normalizeObjectUnits(units);
  6074. var prioritized = getPrioritizedUnits(units);
  6075. for (var i = 0; i < prioritized.length; i++) {
  6076. this[prioritized[i].unit](units[prioritized[i].unit]);
  6077. }
  6078. } else {
  6079. units = normalizeUnits(units);
  6080. if (isFunction(this[units])) {
  6081. return this[units](value);
  6082. }
  6083. }
  6084. return this;
  6085. }
  6086. function zeroFill(number, targetLength, forceSign) {
  6087. var absNumber = '' + Math.abs(number),
  6088. zerosToFill = targetLength - absNumber.length,
  6089. sign = number >= 0;
  6090. return (sign ? (forceSign ? '+' : '') : '-') +
  6091. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  6092. }
  6093. var 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;
  6094. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  6095. var formatFunctions = {};
  6096. var formatTokenFunctions = {};
  6097. // token: 'M'
  6098. // padded: ['MM', 2]
  6099. // ordinal: 'Mo'
  6100. // callback: function () { this.month() + 1 }
  6101. function addFormatToken (token, padded, ordinal, callback) {
  6102. var func = callback;
  6103. if (typeof callback === 'string') {
  6104. func = function () {
  6105. return this[callback]();
  6106. };
  6107. }
  6108. if (token) {
  6109. formatTokenFunctions[token] = func;
  6110. }
  6111. if (padded) {
  6112. formatTokenFunctions[padded[0]] = function () {
  6113. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  6114. };
  6115. }
  6116. if (ordinal) {
  6117. formatTokenFunctions[ordinal] = function () {
  6118. return this.localeData().ordinal(func.apply(this, arguments), token);
  6119. };
  6120. }
  6121. }
  6122. function removeFormattingTokens(input) {
  6123. if (input.match(/\[[\s\S]/)) {
  6124. return input.replace(/^\[|\]$/g, '');
  6125. }
  6126. return input.replace(/\\/g, '');
  6127. }
  6128. function makeFormatFunction(format) {
  6129. var array = format.match(formattingTokens), i, length;
  6130. for (i = 0, length = array.length; i < length; i++) {
  6131. if (formatTokenFunctions[array[i]]) {
  6132. array[i] = formatTokenFunctions[array[i]];
  6133. } else {
  6134. array[i] = removeFormattingTokens(array[i]);
  6135. }
  6136. }
  6137. return function (mom) {
  6138. var output = '', i;
  6139. for (i = 0; i < length; i++) {
  6140. output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
  6141. }
  6142. return output;
  6143. };
  6144. }
  6145. // format date using native date object
  6146. function formatMoment(m, format) {
  6147. if (!m.isValid()) {
  6148. return m.localeData().invalidDate();
  6149. }
  6150. format = expandFormat(format, m.localeData());
  6151. formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  6152. return formatFunctions[format](m);
  6153. }
  6154. function expandFormat(format, locale) {
  6155. var i = 5;
  6156. function replaceLongDateFormatTokens(input) {
  6157. return locale.longDateFormat(input) || input;
  6158. }
  6159. localFormattingTokens.lastIndex = 0;
  6160. while (i >= 0 && localFormattingTokens.test(format)) {
  6161. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  6162. localFormattingTokens.lastIndex = 0;
  6163. i -= 1;
  6164. }
  6165. return format;
  6166. }
  6167. var match1 = /\d/; // 0 - 9
  6168. var match2 = /\d\d/; // 00 - 99
  6169. var match3 = /\d{3}/; // 000 - 999
  6170. var match4 = /\d{4}/; // 0000 - 9999
  6171. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  6172. var match1to2 = /\d\d?/; // 0 - 99
  6173. var match3to4 = /\d\d\d\d?/; // 999 - 9999
  6174. var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
  6175. var match1to3 = /\d{1,3}/; // 0 - 999
  6176. var match1to4 = /\d{1,4}/; // 0 - 9999
  6177. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  6178. var matchUnsigned = /\d+/; // 0 - inf
  6179. var matchSigned = /[+-]?\d+/; // -inf - inf
  6180. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  6181. var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  6182. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  6183. // any word (or two) characters or numbers including two/three word month in arabic.
  6184. // includes scottish gaelic two word and hyphenated months
  6185. var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
  6186. var regexes = {};
  6187. function addRegexToken (token, regex, strictRegex) {
  6188. regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
  6189. return (isStrict && strictRegex) ? strictRegex : regex;
  6190. };
  6191. }
  6192. function getParseRegexForToken (token, config) {
  6193. if (!hasOwnProp(regexes, token)) {
  6194. return new RegExp(unescapeFormat(token));
  6195. }
  6196. return regexes[token](config._strict, config._locale);
  6197. }
  6198. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  6199. function unescapeFormat(s) {
  6200. return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  6201. return p1 || p2 || p3 || p4;
  6202. }));
  6203. }
  6204. function regexEscape(s) {
  6205. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  6206. }
  6207. var tokens = {};
  6208. function addParseToken (token, callback) {
  6209. var i, func = callback;
  6210. if (typeof token === 'string') {
  6211. token = [token];
  6212. }
  6213. if (isNumber(callback)) {
  6214. func = function (input, array) {
  6215. array[callback] = toInt(input);
  6216. };
  6217. }
  6218. for (i = 0; i < token.length; i++) {
  6219. tokens[token[i]] = func;
  6220. }
  6221. }
  6222. function addWeekParseToken (token, callback) {
  6223. addParseToken(token, function (input, array, config, token) {
  6224. config._w = config._w || {};
  6225. callback(input, config._w, config, token);
  6226. });
  6227. }
  6228. function addTimeToArrayFromToken(token, input, config) {
  6229. if (input != null && hasOwnProp(tokens, token)) {
  6230. tokens[token](input, config._a, config, token);
  6231. }
  6232. }
  6233. var YEAR = 0;
  6234. var MONTH = 1;
  6235. var DATE = 2;
  6236. var HOUR = 3;
  6237. var MINUTE = 4;
  6238. var SECOND = 5;
  6239. var MILLISECOND = 6;
  6240. var WEEK = 7;
  6241. var WEEKDAY = 8;
  6242. var indexOf;
  6243. if (Array.prototype.indexOf) {
  6244. indexOf = Array.prototype.indexOf;
  6245. } else {
  6246. indexOf = function (o) {
  6247. // I know
  6248. var i;
  6249. for (i = 0; i < this.length; ++i) {
  6250. if (this[i] === o) {
  6251. return i;
  6252. }
  6253. }
  6254. return -1;
  6255. };
  6256. }
  6257. var indexOf$1 = indexOf;
  6258. function daysInMonth(year, month) {
  6259. return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
  6260. }
  6261. // FORMATTING
  6262. addFormatToken('M', ['MM', 2], 'Mo', function () {
  6263. return this.month() + 1;
  6264. });
  6265. addFormatToken('MMM', 0, 0, function (format) {
  6266. return this.localeData().monthsShort(this, format);
  6267. });
  6268. addFormatToken('MMMM', 0, 0, function (format) {
  6269. return this.localeData().months(this, format);
  6270. });
  6271. // ALIASES
  6272. addUnitAlias('month', 'M');
  6273. // PRIORITY
  6274. addUnitPriority('month', 8);
  6275. // PARSING
  6276. addRegexToken('M', match1to2);
  6277. addRegexToken('MM', match1to2, match2);
  6278. addRegexToken('MMM', function (isStrict, locale) {
  6279. return locale.monthsShortRegex(isStrict);
  6280. });
  6281. addRegexToken('MMMM', function (isStrict, locale) {
  6282. return locale.monthsRegex(isStrict);
  6283. });
  6284. addParseToken(['M', 'MM'], function (input, array) {
  6285. array[MONTH] = toInt(input) - 1;
  6286. });
  6287. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  6288. var month = config._locale.monthsParse(input, token, config._strict);
  6289. // if we didn't find a month name, mark the date as invalid.
  6290. if (month != null) {
  6291. array[MONTH] = month;
  6292. } else {
  6293. getParsingFlags(config).invalidMonth = input;
  6294. }
  6295. });
  6296. // LOCALES
  6297. var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
  6298. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  6299. function localeMonths (m, format) {
  6300. if (!m) {
  6301. return isArray(this._months) ? this._months :
  6302. this._months['standalone'];
  6303. }
  6304. return isArray(this._months) ? this._months[m.month()] :
  6305. this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
  6306. }
  6307. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  6308. function localeMonthsShort (m, format) {
  6309. if (!m) {
  6310. return isArray(this._monthsShort) ? this._monthsShort :
  6311. this._monthsShort['standalone'];
  6312. }
  6313. return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
  6314. this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  6315. }
  6316. function handleStrictParse(monthName, format, strict) {
  6317. var i, ii, mom, llc = monthName.toLocaleLowerCase();
  6318. if (!this._monthsParse) {
  6319. // this is not used
  6320. this._monthsParse = [];
  6321. this._longMonthsParse = [];
  6322. this._shortMonthsParse = [];
  6323. for (i = 0; i < 12; ++i) {
  6324. mom = createUTC([2000, i]);
  6325. this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
  6326. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  6327. }
  6328. }
  6329. if (strict) {
  6330. if (format === 'MMM') {
  6331. ii = indexOf$1.call(this._shortMonthsParse, llc);
  6332. return ii !== -1 ? ii : null;
  6333. } else {
  6334. ii = indexOf$1.call(this._longMonthsParse, llc);
  6335. return ii !== -1 ? ii : null;
  6336. }
  6337. } else {
  6338. if (format === 'MMM') {
  6339. ii = indexOf$1.call(this._shortMonthsParse, llc);
  6340. if (ii !== -1) {
  6341. return ii;
  6342. }
  6343. ii = indexOf$1.call(this._longMonthsParse, llc);
  6344. return ii !== -1 ? ii : null;
  6345. } else {
  6346. ii = indexOf$1.call(this._longMonthsParse, llc);
  6347. if (ii !== -1) {
  6348. return ii;
  6349. }
  6350. ii = indexOf$1.call(this._shortMonthsParse, llc);
  6351. return ii !== -1 ? ii : null;
  6352. }
  6353. }
  6354. }
  6355. function localeMonthsParse (monthName, format, strict) {
  6356. var i, mom, regex;
  6357. if (this._monthsParseExact) {
  6358. return handleStrictParse.call(this, monthName, format, strict);
  6359. }
  6360. if (!this._monthsParse) {
  6361. this._monthsParse = [];
  6362. this._longMonthsParse = [];
  6363. this._shortMonthsParse = [];
  6364. }
  6365. // TODO: add sorting
  6366. // Sorting makes sure if one month (or abbr) is a prefix of another
  6367. // see sorting in computeMonthsParse
  6368. for (i = 0; i < 12; i++) {
  6369. // make the regex if we don't have it already
  6370. mom = createUTC([2000, i]);
  6371. if (strict && !this._longMonthsParse[i]) {
  6372. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  6373. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  6374. }
  6375. if (!strict && !this._monthsParse[i]) {
  6376. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  6377. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  6378. }
  6379. // test the regex
  6380. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  6381. return i;
  6382. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  6383. return i;
  6384. } else if (!strict && this._monthsParse[i].test(monthName)) {
  6385. return i;
  6386. }
  6387. }
  6388. }
  6389. // MOMENTS
  6390. function setMonth (mom, value) {
  6391. var dayOfMonth;
  6392. if (!mom.isValid()) {
  6393. // No op
  6394. return mom;
  6395. }
  6396. if (typeof value === 'string') {
  6397. if (/^\d+$/.test(value)) {
  6398. value = toInt(value);
  6399. } else {
  6400. value = mom.localeData().monthsParse(value);
  6401. // TODO: Another silent failure?
  6402. if (!isNumber(value)) {
  6403. return mom;
  6404. }
  6405. }
  6406. }
  6407. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  6408. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  6409. return mom;
  6410. }
  6411. function getSetMonth (value) {
  6412. if (value != null) {
  6413. setMonth(this, value);
  6414. hooks.updateOffset(this, true);
  6415. return this;
  6416. } else {
  6417. return get(this, 'Month');
  6418. }
  6419. }
  6420. function getDaysInMonth () {
  6421. return daysInMonth(this.year(), this.month());
  6422. }
  6423. var defaultMonthsShortRegex = matchWord;
  6424. function monthsShortRegex (isStrict) {
  6425. if (this._monthsParseExact) {
  6426. if (!hasOwnProp(this, '_monthsRegex')) {
  6427. computeMonthsParse.call(this);
  6428. }
  6429. if (isStrict) {
  6430. return this._monthsShortStrictRegex;
  6431. } else {
  6432. return this._monthsShortRegex;
  6433. }
  6434. } else {
  6435. if (!hasOwnProp(this, '_monthsShortRegex')) {
  6436. this._monthsShortRegex = defaultMonthsShortRegex;
  6437. }
  6438. return this._monthsShortStrictRegex && isStrict ?
  6439. this._monthsShortStrictRegex : this._monthsShortRegex;
  6440. }
  6441. }
  6442. var defaultMonthsRegex = matchWord;
  6443. function monthsRegex (isStrict) {
  6444. if (this._monthsParseExact) {
  6445. if (!hasOwnProp(this, '_monthsRegex')) {
  6446. computeMonthsParse.call(this);
  6447. }
  6448. if (isStrict) {
  6449. return this._monthsStrictRegex;
  6450. } else {
  6451. return this._monthsRegex;
  6452. }
  6453. } else {
  6454. if (!hasOwnProp(this, '_monthsRegex')) {
  6455. this._monthsRegex = defaultMonthsRegex;
  6456. }
  6457. return this._monthsStrictRegex && isStrict ?
  6458. this._monthsStrictRegex : this._monthsRegex;
  6459. }
  6460. }
  6461. function computeMonthsParse () {
  6462. function cmpLenRev(a, b) {
  6463. return b.length - a.length;
  6464. }
  6465. var shortPieces = [], longPieces = [], mixedPieces = [],
  6466. i, mom;
  6467. for (i = 0; i < 12; i++) {
  6468. // make the regex if we don't have it already
  6469. mom = createUTC([2000, i]);
  6470. shortPieces.push(this.monthsShort(mom, ''));
  6471. longPieces.push(this.months(mom, ''));
  6472. mixedPieces.push(this.months(mom, ''));
  6473. mixedPieces.push(this.monthsShort(mom, ''));
  6474. }
  6475. // Sorting makes sure if one month (or abbr) is a prefix of another it
  6476. // will match the longer piece.
  6477. shortPieces.sort(cmpLenRev);
  6478. longPieces.sort(cmpLenRev);
  6479. mixedPieces.sort(cmpLenRev);
  6480. for (i = 0; i < 12; i++) {
  6481. shortPieces[i] = regexEscape(shortPieces[i]);
  6482. longPieces[i] = regexEscape(longPieces[i]);
  6483. }
  6484. for (i = 0; i < 24; i++) {
  6485. mixedPieces[i] = regexEscape(mixedPieces[i]);
  6486. }
  6487. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  6488. this._monthsShortRegex = this._monthsRegex;
  6489. this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  6490. this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  6491. }
  6492. // FORMATTING
  6493. addFormatToken('Y', 0, 0, function () {
  6494. var y = this.year();
  6495. return y <= 9999 ? '' + y : '+' + y;
  6496. });
  6497. addFormatToken(0, ['YY', 2], 0, function () {
  6498. return this.year() % 100;
  6499. });
  6500. addFormatToken(0, ['YYYY', 4], 0, 'year');
  6501. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  6502. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  6503. // ALIASES
  6504. addUnitAlias('year', 'y');
  6505. // PRIORITIES
  6506. addUnitPriority('year', 1);
  6507. // PARSING
  6508. addRegexToken('Y', matchSigned);
  6509. addRegexToken('YY', match1to2, match2);
  6510. addRegexToken('YYYY', match1to4, match4);
  6511. addRegexToken('YYYYY', match1to6, match6);
  6512. addRegexToken('YYYYYY', match1to6, match6);
  6513. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  6514. addParseToken('YYYY', function (input, array) {
  6515. array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  6516. });
  6517. addParseToken('YY', function (input, array) {
  6518. array[YEAR] = hooks.parseTwoDigitYear(input);
  6519. });
  6520. addParseToken('Y', function (input, array) {
  6521. array[YEAR] = parseInt(input, 10);
  6522. });
  6523. // HELPERS
  6524. function daysInYear(year) {
  6525. return isLeapYear(year) ? 366 : 365;
  6526. }
  6527. function isLeapYear(year) {
  6528. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  6529. }
  6530. // HOOKS
  6531. hooks.parseTwoDigitYear = function (input) {
  6532. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  6533. };
  6534. // MOMENTS
  6535. var getSetYear = makeGetSet('FullYear', true);
  6536. function getIsLeapYear () {
  6537. return isLeapYear(this.year());
  6538. }
  6539. function createDate (y, m, d, h, M, s, ms) {
  6540. // can't just apply() to create a date:
  6541. // https://stackoverflow.com/q/181348
  6542. var date = new Date(y, m, d, h, M, s, ms);
  6543. // the date constructor remaps years 0-99 to 1900-1999
  6544. if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
  6545. date.setFullYear(y);
  6546. }
  6547. return date;
  6548. }
  6549. function createUTCDate (y) {
  6550. var date = new Date(Date.UTC.apply(null, arguments));
  6551. // the Date.UTC function remaps years 0-99 to 1900-1999
  6552. if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
  6553. date.setUTCFullYear(y);
  6554. }
  6555. return date;
  6556. }
  6557. // start-of-first-week - start-of-year
  6558. function firstWeekOffset(year, dow, doy) {
  6559. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  6560. fwd = 7 + dow - doy,
  6561. // first-week day local weekday -- which local weekday is fwd
  6562. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  6563. return -fwdlw + fwd - 1;
  6564. }
  6565. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  6566. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  6567. var localWeekday = (7 + weekday - dow) % 7,
  6568. weekOffset = firstWeekOffset(year, dow, doy),
  6569. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  6570. resYear, resDayOfYear;
  6571. if (dayOfYear <= 0) {
  6572. resYear = year - 1;
  6573. resDayOfYear = daysInYear(resYear) + dayOfYear;
  6574. } else if (dayOfYear > daysInYear(year)) {
  6575. resYear = year + 1;
  6576. resDayOfYear = dayOfYear - daysInYear(year);
  6577. } else {
  6578. resYear = year;
  6579. resDayOfYear = dayOfYear;
  6580. }
  6581. return {
  6582. year: resYear,
  6583. dayOfYear: resDayOfYear
  6584. };
  6585. }
  6586. function weekOfYear(mom, dow, doy) {
  6587. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  6588. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  6589. resWeek, resYear;
  6590. if (week < 1) {
  6591. resYear = mom.year() - 1;
  6592. resWeek = week + weeksInYear(resYear, dow, doy);
  6593. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  6594. resWeek = week - weeksInYear(mom.year(), dow, doy);
  6595. resYear = mom.year() + 1;
  6596. } else {
  6597. resYear = mom.year();
  6598. resWeek = week;
  6599. }
  6600. return {
  6601. week: resWeek,
  6602. year: resYear
  6603. };
  6604. }
  6605. function weeksInYear(year, dow, doy) {
  6606. var weekOffset = firstWeekOffset(year, dow, doy),
  6607. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  6608. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  6609. }
  6610. // FORMATTING
  6611. addFormatToken('w', ['ww', 2], 'wo', 'week');
  6612. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  6613. // ALIASES
  6614. addUnitAlias('week', 'w');
  6615. addUnitAlias('isoWeek', 'W');
  6616. // PRIORITIES
  6617. addUnitPriority('week', 5);
  6618. addUnitPriority('isoWeek', 5);
  6619. // PARSING
  6620. addRegexToken('w', match1to2);
  6621. addRegexToken('ww', match1to2, match2);
  6622. addRegexToken('W', match1to2);
  6623. addRegexToken('WW', match1to2, match2);
  6624. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  6625. week[token.substr(0, 1)] = toInt(input);
  6626. });
  6627. // HELPERS
  6628. // LOCALES
  6629. function localeWeek (mom) {
  6630. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  6631. }
  6632. var defaultLocaleWeek = {
  6633. dow : 0, // Sunday is the first day of the week.
  6634. doy : 6 // The week that contains Jan 1st is the first week of the year.
  6635. };
  6636. function localeFirstDayOfWeek () {
  6637. return this._week.dow;
  6638. }
  6639. function localeFirstDayOfYear () {
  6640. return this._week.doy;
  6641. }
  6642. // MOMENTS
  6643. function getSetWeek (input) {
  6644. var week = this.localeData().week(this);
  6645. return input == null ? week : this.add((input - week) * 7, 'd');
  6646. }
  6647. function getSetISOWeek (input) {
  6648. var week = weekOfYear(this, 1, 4).week;
  6649. return input == null ? week : this.add((input - week) * 7, 'd');
  6650. }
  6651. // FORMATTING
  6652. addFormatToken('d', 0, 'do', 'day');
  6653. addFormatToken('dd', 0, 0, function (format) {
  6654. return this.localeData().weekdaysMin(this, format);
  6655. });
  6656. addFormatToken('ddd', 0, 0, function (format) {
  6657. return this.localeData().weekdaysShort(this, format);
  6658. });
  6659. addFormatToken('dddd', 0, 0, function (format) {
  6660. return this.localeData().weekdays(this, format);
  6661. });
  6662. addFormatToken('e', 0, 0, 'weekday');
  6663. addFormatToken('E', 0, 0, 'isoWeekday');
  6664. // ALIASES
  6665. addUnitAlias('day', 'd');
  6666. addUnitAlias('weekday', 'e');
  6667. addUnitAlias('isoWeekday', 'E');
  6668. // PRIORITY
  6669. addUnitPriority('day', 11);
  6670. addUnitPriority('weekday', 11);
  6671. addUnitPriority('isoWeekday', 11);
  6672. // PARSING
  6673. addRegexToken('d', match1to2);
  6674. addRegexToken('e', match1to2);
  6675. addRegexToken('E', match1to2);
  6676. addRegexToken('dd', function (isStrict, locale) {
  6677. return locale.weekdaysMinRegex(isStrict);
  6678. });
  6679. addRegexToken('ddd', function (isStrict, locale) {
  6680. return locale.weekdaysShortRegex(isStrict);
  6681. });
  6682. addRegexToken('dddd', function (isStrict, locale) {
  6683. return locale.weekdaysRegex(isStrict);
  6684. });
  6685. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  6686. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  6687. // if we didn't get a weekday name, mark the date as invalid
  6688. if (weekday != null) {
  6689. week.d = weekday;
  6690. } else {
  6691. getParsingFlags(config).invalidWeekday = input;
  6692. }
  6693. });
  6694. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  6695. week[token] = toInt(input);
  6696. });
  6697. // HELPERS
  6698. function parseWeekday(input, locale) {
  6699. if (typeof input !== 'string') {
  6700. return input;
  6701. }
  6702. if (!isNaN(input)) {
  6703. return parseInt(input, 10);
  6704. }
  6705. input = locale.weekdaysParse(input);
  6706. if (typeof input === 'number') {
  6707. return input;
  6708. }
  6709. return null;
  6710. }
  6711. function parseIsoWeekday(input, locale) {
  6712. if (typeof input === 'string') {
  6713. return locale.weekdaysParse(input) % 7 || 7;
  6714. }
  6715. return isNaN(input) ? null : input;
  6716. }
  6717. // LOCALES
  6718. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  6719. function localeWeekdays (m, format) {
  6720. if (!m) {
  6721. return isArray(this._weekdays) ? this._weekdays :
  6722. this._weekdays['standalone'];
  6723. }
  6724. return isArray(this._weekdays) ? this._weekdays[m.day()] :
  6725. this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
  6726. }
  6727. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  6728. function localeWeekdaysShort (m) {
  6729. return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
  6730. }
  6731. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  6732. function localeWeekdaysMin (m) {
  6733. return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
  6734. }
  6735. function handleStrictParse$1(weekdayName, format, strict) {
  6736. var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
  6737. if (!this._weekdaysParse) {
  6738. this._weekdaysParse = [];
  6739. this._shortWeekdaysParse = [];
  6740. this._minWeekdaysParse = [];
  6741. for (i = 0; i < 7; ++i) {
  6742. mom = createUTC([2000, 1]).day(i);
  6743. this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
  6744. this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
  6745. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  6746. }
  6747. }
  6748. if (strict) {
  6749. if (format === 'dddd') {
  6750. ii = indexOf$1.call(this._weekdaysParse, llc);
  6751. return ii !== -1 ? ii : null;
  6752. } else if (format === 'ddd') {
  6753. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  6754. return ii !== -1 ? ii : null;
  6755. } else {
  6756. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  6757. return ii !== -1 ? ii : null;
  6758. }
  6759. } else {
  6760. if (format === 'dddd') {
  6761. ii = indexOf$1.call(this._weekdaysParse, llc);
  6762. if (ii !== -1) {
  6763. return ii;
  6764. }
  6765. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  6766. if (ii !== -1) {
  6767. return ii;
  6768. }
  6769. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  6770. return ii !== -1 ? ii : null;
  6771. } else if (format === 'ddd') {
  6772. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  6773. if (ii !== -1) {
  6774. return ii;
  6775. }
  6776. ii = indexOf$1.call(this._weekdaysParse, llc);
  6777. if (ii !== -1) {
  6778. return ii;
  6779. }
  6780. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  6781. return ii !== -1 ? ii : null;
  6782. } else {
  6783. ii = indexOf$1.call(this._minWeekdaysParse, llc);
  6784. if (ii !== -1) {
  6785. return ii;
  6786. }
  6787. ii = indexOf$1.call(this._weekdaysParse, llc);
  6788. if (ii !== -1) {
  6789. return ii;
  6790. }
  6791. ii = indexOf$1.call(this._shortWeekdaysParse, llc);
  6792. return ii !== -1 ? ii : null;
  6793. }
  6794. }
  6795. }
  6796. function localeWeekdaysParse (weekdayName, format, strict) {
  6797. var i, mom, regex;
  6798. if (this._weekdaysParseExact) {
  6799. return handleStrictParse$1.call(this, weekdayName, format, strict);
  6800. }
  6801. if (!this._weekdaysParse) {
  6802. this._weekdaysParse = [];
  6803. this._minWeekdaysParse = [];
  6804. this._shortWeekdaysParse = [];
  6805. this._fullWeekdaysParse = [];
  6806. }
  6807. for (i = 0; i < 7; i++) {
  6808. // make the regex if we don't have it already
  6809. mom = createUTC([2000, 1]).day(i);
  6810. if (strict && !this._fullWeekdaysParse[i]) {
  6811. this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
  6812. this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
  6813. this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
  6814. }
  6815. if (!this._weekdaysParse[i]) {
  6816. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  6817. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  6818. }
  6819. // test the regex
  6820. if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
  6821. return i;
  6822. } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
  6823. return i;
  6824. } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
  6825. return i;
  6826. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  6827. return i;
  6828. }
  6829. }
  6830. }
  6831. // MOMENTS
  6832. function getSetDayOfWeek (input) {
  6833. if (!this.isValid()) {
  6834. return input != null ? this : NaN;
  6835. }
  6836. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  6837. if (input != null) {
  6838. input = parseWeekday(input, this.localeData());
  6839. return this.add(input - day, 'd');
  6840. } else {
  6841. return day;
  6842. }
  6843. }
  6844. function getSetLocaleDayOfWeek (input) {
  6845. if (!this.isValid()) {
  6846. return input != null ? this : NaN;
  6847. }
  6848. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  6849. return input == null ? weekday : this.add(input - weekday, 'd');
  6850. }
  6851. function getSetISODayOfWeek (input) {
  6852. if (!this.isValid()) {
  6853. return input != null ? this : NaN;
  6854. }
  6855. // behaves the same as moment#day except
  6856. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  6857. // as a setter, sunday should belong to the previous week.
  6858. if (input != null) {
  6859. var weekday = parseIsoWeekday(input, this.localeData());
  6860. return this.day(this.day() % 7 ? weekday : weekday - 7);
  6861. } else {
  6862. return this.day() || 7;
  6863. }
  6864. }
  6865. var defaultWeekdaysRegex = matchWord;
  6866. function weekdaysRegex (isStrict) {
  6867. if (this._weekdaysParseExact) {
  6868. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6869. computeWeekdaysParse.call(this);
  6870. }
  6871. if (isStrict) {
  6872. return this._weekdaysStrictRegex;
  6873. } else {
  6874. return this._weekdaysRegex;
  6875. }
  6876. } else {
  6877. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6878. this._weekdaysRegex = defaultWeekdaysRegex;
  6879. }
  6880. return this._weekdaysStrictRegex && isStrict ?
  6881. this._weekdaysStrictRegex : this._weekdaysRegex;
  6882. }
  6883. }
  6884. var defaultWeekdaysShortRegex = matchWord;
  6885. function weekdaysShortRegex (isStrict) {
  6886. if (this._weekdaysParseExact) {
  6887. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6888. computeWeekdaysParse.call(this);
  6889. }
  6890. if (isStrict) {
  6891. return this._weekdaysShortStrictRegex;
  6892. } else {
  6893. return this._weekdaysShortRegex;
  6894. }
  6895. } else {
  6896. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  6897. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  6898. }
  6899. return this._weekdaysShortStrictRegex && isStrict ?
  6900. this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
  6901. }
  6902. }
  6903. var defaultWeekdaysMinRegex = matchWord;
  6904. function weekdaysMinRegex (isStrict) {
  6905. if (this._weekdaysParseExact) {
  6906. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6907. computeWeekdaysParse.call(this);
  6908. }
  6909. if (isStrict) {
  6910. return this._weekdaysMinStrictRegex;
  6911. } else {
  6912. return this._weekdaysMinRegex;
  6913. }
  6914. } else {
  6915. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  6916. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  6917. }
  6918. return this._weekdaysMinStrictRegex && isStrict ?
  6919. this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
  6920. }
  6921. }
  6922. function computeWeekdaysParse () {
  6923. function cmpLenRev(a, b) {
  6924. return b.length - a.length;
  6925. }
  6926. var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
  6927. i, mom, minp, shortp, longp;
  6928. for (i = 0; i < 7; i++) {
  6929. // make the regex if we don't have it already
  6930. mom = createUTC([2000, 1]).day(i);
  6931. minp = this.weekdaysMin(mom, '');
  6932. shortp = this.weekdaysShort(mom, '');
  6933. longp = this.weekdays(mom, '');
  6934. minPieces.push(minp);
  6935. shortPieces.push(shortp);
  6936. longPieces.push(longp);
  6937. mixedPieces.push(minp);
  6938. mixedPieces.push(shortp);
  6939. mixedPieces.push(longp);
  6940. }
  6941. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  6942. // will match the longer piece.
  6943. minPieces.sort(cmpLenRev);
  6944. shortPieces.sort(cmpLenRev);
  6945. longPieces.sort(cmpLenRev);
  6946. mixedPieces.sort(cmpLenRev);
  6947. for (i = 0; i < 7; i++) {
  6948. shortPieces[i] = regexEscape(shortPieces[i]);
  6949. longPieces[i] = regexEscape(longPieces[i]);
  6950. mixedPieces[i] = regexEscape(mixedPieces[i]);
  6951. }
  6952. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  6953. this._weekdaysShortRegex = this._weekdaysRegex;
  6954. this._weekdaysMinRegex = this._weekdaysRegex;
  6955. this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  6956. this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  6957. this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
  6958. }
  6959. // FORMATTING
  6960. function hFormat() {
  6961. return this.hours() % 12 || 12;
  6962. }
  6963. function kFormat() {
  6964. return this.hours() || 24;
  6965. }
  6966. addFormatToken('H', ['HH', 2], 0, 'hour');
  6967. addFormatToken('h', ['hh', 2], 0, hFormat);
  6968. addFormatToken('k', ['kk', 2], 0, kFormat);
  6969. addFormatToken('hmm', 0, 0, function () {
  6970. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  6971. });
  6972. addFormatToken('hmmss', 0, 0, function () {
  6973. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
  6974. zeroFill(this.seconds(), 2);
  6975. });
  6976. addFormatToken('Hmm', 0, 0, function () {
  6977. return '' + this.hours() + zeroFill(this.minutes(), 2);
  6978. });
  6979. addFormatToken('Hmmss', 0, 0, function () {
  6980. return '' + this.hours() + zeroFill(this.minutes(), 2) +
  6981. zeroFill(this.seconds(), 2);
  6982. });
  6983. function meridiem (token, lowercase) {
  6984. addFormatToken(token, 0, 0, function () {
  6985. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  6986. });
  6987. }
  6988. meridiem('a', true);
  6989. meridiem('A', false);
  6990. // ALIASES
  6991. addUnitAlias('hour', 'h');
  6992. // PRIORITY
  6993. addUnitPriority('hour', 13);
  6994. // PARSING
  6995. function matchMeridiem (isStrict, locale) {
  6996. return locale._meridiemParse;
  6997. }
  6998. addRegexToken('a', matchMeridiem);
  6999. addRegexToken('A', matchMeridiem);
  7000. addRegexToken('H', match1to2);
  7001. addRegexToken('h', match1to2);
  7002. addRegexToken('k', match1to2);
  7003. addRegexToken('HH', match1to2, match2);
  7004. addRegexToken('hh', match1to2, match2);
  7005. addRegexToken('kk', match1to2, match2);
  7006. addRegexToken('hmm', match3to4);
  7007. addRegexToken('hmmss', match5to6);
  7008. addRegexToken('Hmm', match3to4);
  7009. addRegexToken('Hmmss', match5to6);
  7010. addParseToken(['H', 'HH'], HOUR);
  7011. addParseToken(['k', 'kk'], function (input, array, config) {
  7012. var kInput = toInt(input);
  7013. array[HOUR] = kInput === 24 ? 0 : kInput;
  7014. });
  7015. addParseToken(['a', 'A'], function (input, array, config) {
  7016. config._isPm = config._locale.isPM(input);
  7017. config._meridiem = input;
  7018. });
  7019. addParseToken(['h', 'hh'], function (input, array, config) {
  7020. array[HOUR] = toInt(input);
  7021. getParsingFlags(config).bigHour = true;
  7022. });
  7023. addParseToken('hmm', function (input, array, config) {
  7024. var pos = input.length - 2;
  7025. array[HOUR] = toInt(input.substr(0, pos));
  7026. array[MINUTE] = toInt(input.substr(pos));
  7027. getParsingFlags(config).bigHour = true;
  7028. });
  7029. addParseToken('hmmss', function (input, array, config) {
  7030. var pos1 = input.length - 4;
  7031. var pos2 = input.length - 2;
  7032. array[HOUR] = toInt(input.substr(0, pos1));
  7033. array[MINUTE] = toInt(input.substr(pos1, 2));
  7034. array[SECOND] = toInt(input.substr(pos2));
  7035. getParsingFlags(config).bigHour = true;
  7036. });
  7037. addParseToken('Hmm', function (input, array, config) {
  7038. var pos = input.length - 2;
  7039. array[HOUR] = toInt(input.substr(0, pos));
  7040. array[MINUTE] = toInt(input.substr(pos));
  7041. });
  7042. addParseToken('Hmmss', function (input, array, config) {
  7043. var pos1 = input.length - 4;
  7044. var pos2 = input.length - 2;
  7045. array[HOUR] = toInt(input.substr(0, pos1));
  7046. array[MINUTE] = toInt(input.substr(pos1, 2));
  7047. array[SECOND] = toInt(input.substr(pos2));
  7048. });
  7049. // LOCALES
  7050. function localeIsPM (input) {
  7051. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  7052. // Using charAt should be more compatible.
  7053. return ((input + '').toLowerCase().charAt(0) === 'p');
  7054. }
  7055. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  7056. function localeMeridiem (hours, minutes, isLower) {
  7057. if (hours > 11) {
  7058. return isLower ? 'pm' : 'PM';
  7059. } else {
  7060. return isLower ? 'am' : 'AM';
  7061. }
  7062. }
  7063. // MOMENTS
  7064. // Setting the hour should keep the time, because the user explicitly
  7065. // specified which hour he wants. So trying to maintain the same hour (in
  7066. // a new timezone) makes sense. Adding/subtracting hours does not follow
  7067. // this rule.
  7068. var getSetHour = makeGetSet('Hours', true);
  7069. // months
  7070. // week
  7071. // weekdays
  7072. // meridiem
  7073. var baseConfig = {
  7074. calendar: defaultCalendar,
  7075. longDateFormat: defaultLongDateFormat,
  7076. invalidDate: defaultInvalidDate,
  7077. ordinal: defaultOrdinal,
  7078. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  7079. relativeTime: defaultRelativeTime,
  7080. months: defaultLocaleMonths,
  7081. monthsShort: defaultLocaleMonthsShort,
  7082. week: defaultLocaleWeek,
  7083. weekdays: defaultLocaleWeekdays,
  7084. weekdaysMin: defaultLocaleWeekdaysMin,
  7085. weekdaysShort: defaultLocaleWeekdaysShort,
  7086. meridiemParse: defaultLocaleMeridiemParse
  7087. };
  7088. // internal storage for locale config files
  7089. var locales = {};
  7090. var localeFamilies = {};
  7091. var globalLocale;
  7092. function normalizeLocale(key) {
  7093. return key ? key.toLowerCase().replace('_', '-') : key;
  7094. }
  7095. // pick the locale from the array
  7096. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  7097. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  7098. function chooseLocale(names) {
  7099. var i = 0, j, next, locale, split;
  7100. while (i < names.length) {
  7101. split = normalizeLocale(names[i]).split('-');
  7102. j = split.length;
  7103. next = normalizeLocale(names[i + 1]);
  7104. next = next ? next.split('-') : null;
  7105. while (j > 0) {
  7106. locale = loadLocale(split.slice(0, j).join('-'));
  7107. if (locale) {
  7108. return locale;
  7109. }
  7110. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  7111. //the next array item is better than a shallower substring of this one
  7112. break;
  7113. }
  7114. j--;
  7115. }
  7116. i++;
  7117. }
  7118. return null;
  7119. }
  7120. function loadLocale(name) {
  7121. var oldLocale = null;
  7122. // TODO: Find a better way to register and load all the locales in Node
  7123. if (!locales[name] && (typeof module !== 'undefined') &&
  7124. module && module.exports) {
  7125. try {
  7126. oldLocale = globalLocale._abbr;
  7127. __webpack_require__(418)("./" + name);
  7128. // because defineLocale currently also sets the global locale, we
  7129. // want to undo that for lazy loaded locales
  7130. getSetGlobalLocale(oldLocale);
  7131. } catch (e) { }
  7132. }
  7133. return locales[name];
  7134. }
  7135. // This function will load locale and then set the global locale. If
  7136. // no arguments are passed in, it will simply return the current global
  7137. // locale key.
  7138. function getSetGlobalLocale (key, values) {
  7139. var data;
  7140. if (key) {
  7141. if (isUndefined(values)) {
  7142. data = getLocale(key);
  7143. }
  7144. else {
  7145. data = defineLocale(key, values);
  7146. }
  7147. if (data) {
  7148. // moment.duration._locale = moment._locale = data;
  7149. globalLocale = data;
  7150. }
  7151. }
  7152. return globalLocale._abbr;
  7153. }
  7154. function defineLocale (name, config) {
  7155. if (config !== null) {
  7156. var parentConfig = baseConfig;
  7157. config.abbr = name;
  7158. if (locales[name] != null) {
  7159. deprecateSimple('defineLocaleOverride',
  7160. 'use moment.updateLocale(localeName, config) to change ' +
  7161. 'an existing locale. moment.defineLocale(localeName, ' +
  7162. 'config) should only be used for creating a new locale ' +
  7163. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
  7164. parentConfig = locales[name]._config;
  7165. } else if (config.parentLocale != null) {
  7166. if (locales[config.parentLocale] != null) {
  7167. parentConfig = locales[config.parentLocale]._config;
  7168. } else {
  7169. if (!localeFamilies[config.parentLocale]) {
  7170. localeFamilies[config.parentLocale] = [];
  7171. }
  7172. localeFamilies[config.parentLocale].push({
  7173. name: name,
  7174. config: config
  7175. });
  7176. return null;
  7177. }
  7178. }
  7179. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  7180. if (localeFamilies[name]) {
  7181. localeFamilies[name].forEach(function (x) {
  7182. defineLocale(x.name, x.config);
  7183. });
  7184. }
  7185. // backwards compat for now: also set the locale
  7186. // make sure we set the locale AFTER all child locales have been
  7187. // created, so we won't end up with the child locale set.
  7188. getSetGlobalLocale(name);
  7189. return locales[name];
  7190. } else {
  7191. // useful for testing
  7192. delete locales[name];
  7193. return null;
  7194. }
  7195. }
  7196. function updateLocale(name, config) {
  7197. if (config != null) {
  7198. var locale, parentConfig = baseConfig;
  7199. // MERGE
  7200. if (locales[name] != null) {
  7201. parentConfig = locales[name]._config;
  7202. }
  7203. config = mergeConfigs(parentConfig, config);
  7204. locale = new Locale(config);
  7205. locale.parentLocale = locales[name];
  7206. locales[name] = locale;
  7207. // backwards compat for now: also set the locale
  7208. getSetGlobalLocale(name);
  7209. } else {
  7210. // pass null for config to unupdate, useful for tests
  7211. if (locales[name] != null) {
  7212. if (locales[name].parentLocale != null) {
  7213. locales[name] = locales[name].parentLocale;
  7214. } else if (locales[name] != null) {
  7215. delete locales[name];
  7216. }
  7217. }
  7218. }
  7219. return locales[name];
  7220. }
  7221. // returns locale data
  7222. function getLocale (key) {
  7223. var locale;
  7224. if (key && key._locale && key._locale._abbr) {
  7225. key = key._locale._abbr;
  7226. }
  7227. if (!key) {
  7228. return globalLocale;
  7229. }
  7230. if (!isArray(key)) {
  7231. //short-circuit everything else
  7232. locale = loadLocale(key);
  7233. if (locale) {
  7234. return locale;
  7235. }
  7236. key = [key];
  7237. }
  7238. return chooseLocale(key);
  7239. }
  7240. function listLocales() {
  7241. return keys$1(locales);
  7242. }
  7243. function checkOverflow (m) {
  7244. var overflow;
  7245. var a = m._a;
  7246. if (a && getParsingFlags(m).overflow === -2) {
  7247. overflow =
  7248. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  7249. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  7250. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  7251. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  7252. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  7253. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  7254. -1;
  7255. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  7256. overflow = DATE;
  7257. }
  7258. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  7259. overflow = WEEK;
  7260. }
  7261. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  7262. overflow = WEEKDAY;
  7263. }
  7264. getParsingFlags(m).overflow = overflow;
  7265. }
  7266. return m;
  7267. }
  7268. // iso 8601 regex
  7269. // 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)
  7270. var 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)?)?$/;
  7271. var 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)?)?$/;
  7272. var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
  7273. var isoDates = [
  7274. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  7275. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  7276. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  7277. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  7278. ['YYYY-DDD', /\d{4}-\d{3}/],
  7279. ['YYYY-MM', /\d{4}-\d\d/, false],
  7280. ['YYYYYYMMDD', /[+-]\d{10}/],
  7281. ['YYYYMMDD', /\d{8}/],
  7282. // YYYYMM is NOT allowed by the standard
  7283. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  7284. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  7285. ['YYYYDDD', /\d{7}/]
  7286. ];
  7287. // iso time formats and regexes
  7288. var isoTimes = [
  7289. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  7290. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  7291. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  7292. ['HH:mm', /\d\d:\d\d/],
  7293. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  7294. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  7295. ['HHmmss', /\d\d\d\d\d\d/],
  7296. ['HHmm', /\d\d\d\d/],
  7297. ['HH', /\d\d/]
  7298. ];
  7299. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  7300. // date from iso format
  7301. function configFromISO(config) {
  7302. var i, l,
  7303. string = config._i,
  7304. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  7305. allowTime, dateFormat, timeFormat, tzFormat;
  7306. if (match) {
  7307. getParsingFlags(config).iso = true;
  7308. for (i = 0, l = isoDates.length; i < l; i++) {
  7309. if (isoDates[i][1].exec(match[1])) {
  7310. dateFormat = isoDates[i][0];
  7311. allowTime = isoDates[i][2] !== false;
  7312. break;
  7313. }
  7314. }
  7315. if (dateFormat == null) {
  7316. config._isValid = false;
  7317. return;
  7318. }
  7319. if (match[3]) {
  7320. for (i = 0, l = isoTimes.length; i < l; i++) {
  7321. if (isoTimes[i][1].exec(match[3])) {
  7322. // match[2] should be 'T' or space
  7323. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  7324. break;
  7325. }
  7326. }
  7327. if (timeFormat == null) {
  7328. config._isValid = false;
  7329. return;
  7330. }
  7331. }
  7332. if (!allowTime && timeFormat != null) {
  7333. config._isValid = false;
  7334. return;
  7335. }
  7336. if (match[4]) {
  7337. if (tzRegex.exec(match[4])) {
  7338. tzFormat = 'Z';
  7339. } else {
  7340. config._isValid = false;
  7341. return;
  7342. }
  7343. }
  7344. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  7345. configFromStringAndFormat(config);
  7346. } else {
  7347. config._isValid = false;
  7348. }
  7349. }
  7350. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  7351. var 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}))$/;
  7352. // date and time from ref 2822 format
  7353. function configFromRFC2822(config) {
  7354. var string, match, dayFormat,
  7355. dateFormat, timeFormat, tzFormat;
  7356. var timezones = {
  7357. ' GMT': ' +0000',
  7358. ' EDT': ' -0400',
  7359. ' EST': ' -0500',
  7360. ' CDT': ' -0500',
  7361. ' CST': ' -0600',
  7362. ' MDT': ' -0600',
  7363. ' MST': ' -0700',
  7364. ' PDT': ' -0700',
  7365. ' PST': ' -0800'
  7366. };
  7367. var military = 'YXWVUTSRQPONZABCDEFGHIKLM';
  7368. var timezone, timezoneIndex;
  7369. string = config._i
  7370. .replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace
  7371. .replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space
  7372. .replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces
  7373. match = basicRfcRegex.exec(string);
  7374. if (match) {
  7375. dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : '';
  7376. dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY ');
  7377. timeFormat = 'HH:mm' + (match[4] ? ':ss' : '');
  7378. // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
  7379. if (match[1]) { // day of week given
  7380. var momentDate = new Date(match[2]);
  7381. var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()];
  7382. if (match[1].substr(0,3) !== momentDay) {
  7383. getParsingFlags(config).weekdayMismatch = true;
  7384. config._isValid = false;
  7385. return;
  7386. }
  7387. }
  7388. switch (match[5].length) {
  7389. case 2: // military
  7390. if (timezoneIndex === 0) {
  7391. timezone = ' +0000';
  7392. } else {
  7393. timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12;
  7394. timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
  7395. (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
  7396. }
  7397. break;
  7398. case 4: // Zone
  7399. timezone = timezones[match[5]];
  7400. break;
  7401. default: // UT or +/-9999
  7402. timezone = timezones[' GMT'];
  7403. }
  7404. match[5] = timezone;
  7405. config._i = match.splice(1).join('');
  7406. tzFormat = ' ZZ';
  7407. config._f = dayFormat + dateFormat + timeFormat + tzFormat;
  7408. configFromStringAndFormat(config);
  7409. getParsingFlags(config).rfc2822 = true;
  7410. } else {
  7411. config._isValid = false;
  7412. }
  7413. }
  7414. // date from iso format or fallback
  7415. function configFromString(config) {
  7416. var matched = aspNetJsonRegex.exec(config._i);
  7417. if (matched !== null) {
  7418. config._d = new Date(+matched[1]);
  7419. return;
  7420. }
  7421. configFromISO(config);
  7422. if (config._isValid === false) {
  7423. delete config._isValid;
  7424. } else {
  7425. return;
  7426. }
  7427. configFromRFC2822(config);
  7428. if (config._isValid === false) {
  7429. delete config._isValid;
  7430. } else {
  7431. return;
  7432. }
  7433. // Final attempt, use Input Fallback
  7434. hooks.createFromInputFallback(config);
  7435. }
  7436. hooks.createFromInputFallback = deprecate(
  7437. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  7438. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  7439. 'discouraged and will be removed in an upcoming major release. Please refer to ' +
  7440. 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  7441. function (config) {
  7442. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  7443. }
  7444. );
  7445. // Pick the first defined of two or three arguments.
  7446. function defaults(a, b, c) {
  7447. if (a != null) {
  7448. return a;
  7449. }
  7450. if (b != null) {
  7451. return b;
  7452. }
  7453. return c;
  7454. }
  7455. function currentDateArray(config) {
  7456. // hooks is actually the exported moment object
  7457. var nowValue = new Date(hooks.now());
  7458. if (config._useUTC) {
  7459. return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
  7460. }
  7461. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  7462. }
  7463. // convert an array to a date.
  7464. // the array should mirror the parameters below
  7465. // note: all values past the year are optional and will default to the lowest possible value.
  7466. // [year, month, day , hour, minute, second, millisecond]
  7467. function configFromArray (config) {
  7468. var i, date, input = [], currentDate, yearToUse;
  7469. if (config._d) {
  7470. return;
  7471. }
  7472. currentDate = currentDateArray(config);
  7473. //compute day of the year from weeks and weekdays
  7474. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  7475. dayOfYearFromWeekInfo(config);
  7476. }
  7477. //if the day of the year is set, figure out what it is
  7478. if (config._dayOfYear != null) {
  7479. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  7480. if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
  7481. getParsingFlags(config)._overflowDayOfYear = true;
  7482. }
  7483. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  7484. config._a[MONTH] = date.getUTCMonth();
  7485. config._a[DATE] = date.getUTCDate();
  7486. }
  7487. // Default to current date.
  7488. // * if no year, month, day of month are given, default to today
  7489. // * if day of month is given, default month and year
  7490. // * if month is given, default only year
  7491. // * if year is given, don't default anything
  7492. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  7493. config._a[i] = input[i] = currentDate[i];
  7494. }
  7495. // Zero out whatever was not defaulted, including time
  7496. for (; i < 7; i++) {
  7497. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  7498. }
  7499. // Check for 24:00:00.000
  7500. if (config._a[HOUR] === 24 &&
  7501. config._a[MINUTE] === 0 &&
  7502. config._a[SECOND] === 0 &&
  7503. config._a[MILLISECOND] === 0) {
  7504. config._nextDay = true;
  7505. config._a[HOUR] = 0;
  7506. }
  7507. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  7508. // Apply timezone offset from input. The actual utcOffset can be changed
  7509. // with parseZone.
  7510. if (config._tzm != null) {
  7511. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  7512. }
  7513. if (config._nextDay) {
  7514. config._a[HOUR] = 24;
  7515. }
  7516. }
  7517. function dayOfYearFromWeekInfo(config) {
  7518. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
  7519. w = config._w;
  7520. if (w.GG != null || w.W != null || w.E != null) {
  7521. dow = 1;
  7522. doy = 4;
  7523. // TODO: We need to take the current isoWeekYear, but that depends on
  7524. // how we interpret now (local, utc, fixed offset). So create
  7525. // a now version of current config (take local/utc/offset flags, and
  7526. // create now).
  7527. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
  7528. week = defaults(w.W, 1);
  7529. weekday = defaults(w.E, 1);
  7530. if (weekday < 1 || weekday > 7) {
  7531. weekdayOverflow = true;
  7532. }
  7533. } else {
  7534. dow = config._locale._week.dow;
  7535. doy = config._locale._week.doy;
  7536. var curWeek = weekOfYear(createLocal(), dow, doy);
  7537. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  7538. // Default to current week.
  7539. week = defaults(w.w, curWeek.week);
  7540. if (w.d != null) {
  7541. // weekday -- low day numbers are considered next week
  7542. weekday = w.d;
  7543. if (weekday < 0 || weekday > 6) {
  7544. weekdayOverflow = true;
  7545. }
  7546. } else if (w.e != null) {
  7547. // local weekday -- counting starts from begining of week
  7548. weekday = w.e + dow;
  7549. if (w.e < 0 || w.e > 6) {
  7550. weekdayOverflow = true;
  7551. }
  7552. } else {
  7553. // default to begining of week
  7554. weekday = dow;
  7555. }
  7556. }
  7557. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  7558. getParsingFlags(config)._overflowWeeks = true;
  7559. } else if (weekdayOverflow != null) {
  7560. getParsingFlags(config)._overflowWeekday = true;
  7561. } else {
  7562. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  7563. config._a[YEAR] = temp.year;
  7564. config._dayOfYear = temp.dayOfYear;
  7565. }
  7566. }
  7567. // constant that refers to the ISO standard
  7568. hooks.ISO_8601 = function () {};
  7569. // constant that refers to the RFC 2822 form
  7570. hooks.RFC_2822 = function () {};
  7571. // date from string and format string
  7572. function configFromStringAndFormat(config) {
  7573. // TODO: Move this to another part of the creation flow to prevent circular deps
  7574. if (config._f === hooks.ISO_8601) {
  7575. configFromISO(config);
  7576. return;
  7577. }
  7578. if (config._f === hooks.RFC_2822) {
  7579. configFromRFC2822(config);
  7580. return;
  7581. }
  7582. config._a = [];
  7583. getParsingFlags(config).empty = true;
  7584. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  7585. var string = '' + config._i,
  7586. i, parsedInput, tokens, token, skipped,
  7587. stringLength = string.length,
  7588. totalParsedInputLength = 0;
  7589. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  7590. for (i = 0; i < tokens.length; i++) {
  7591. token = tokens[i];
  7592. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  7593. // console.log('token', token, 'parsedInput', parsedInput,
  7594. // 'regex', getParseRegexForToken(token, config));
  7595. if (parsedInput) {
  7596. skipped = string.substr(0, string.indexOf(parsedInput));
  7597. if (skipped.length > 0) {
  7598. getParsingFlags(config).unusedInput.push(skipped);
  7599. }
  7600. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  7601. totalParsedInputLength += parsedInput.length;
  7602. }
  7603. // don't parse if it's not a known token
  7604. if (formatTokenFunctions[token]) {
  7605. if (parsedInput) {
  7606. getParsingFlags(config).empty = false;
  7607. }
  7608. else {
  7609. getParsingFlags(config).unusedTokens.push(token);
  7610. }
  7611. addTimeToArrayFromToken(token, parsedInput, config);
  7612. }
  7613. else if (config._strict && !parsedInput) {
  7614. getParsingFlags(config).unusedTokens.push(token);
  7615. }
  7616. }
  7617. // add remaining unparsed input length to the string
  7618. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  7619. if (string.length > 0) {
  7620. getParsingFlags(config).unusedInput.push(string);
  7621. }
  7622. // clear _12h flag if hour is <= 12
  7623. if (config._a[HOUR] <= 12 &&
  7624. getParsingFlags(config).bigHour === true &&
  7625. config._a[HOUR] > 0) {
  7626. getParsingFlags(config).bigHour = undefined;
  7627. }
  7628. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  7629. getParsingFlags(config).meridiem = config._meridiem;
  7630. // handle meridiem
  7631. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  7632. configFromArray(config);
  7633. checkOverflow(config);
  7634. }
  7635. function meridiemFixWrap (locale, hour, meridiem) {
  7636. var isPm;
  7637. if (meridiem == null) {
  7638. // nothing to do
  7639. return hour;
  7640. }
  7641. if (locale.meridiemHour != null) {
  7642. return locale.meridiemHour(hour, meridiem);
  7643. } else if (locale.isPM != null) {
  7644. // Fallback
  7645. isPm = locale.isPM(meridiem);
  7646. if (isPm && hour < 12) {
  7647. hour += 12;
  7648. }
  7649. if (!isPm && hour === 12) {
  7650. hour = 0;
  7651. }
  7652. return hour;
  7653. } else {
  7654. // this is not supposed to happen
  7655. return hour;
  7656. }
  7657. }
  7658. // date from string and array of format strings
  7659. function configFromStringAndArray(config) {
  7660. var tempConfig,
  7661. bestMoment,
  7662. scoreToBeat,
  7663. i,
  7664. currentScore;
  7665. if (config._f.length === 0) {
  7666. getParsingFlags(config).invalidFormat = true;
  7667. config._d = new Date(NaN);
  7668. return;
  7669. }
  7670. for (i = 0; i < config._f.length; i++) {
  7671. currentScore = 0;
  7672. tempConfig = copyConfig({}, config);
  7673. if (config._useUTC != null) {
  7674. tempConfig._useUTC = config._useUTC;
  7675. }
  7676. tempConfig._f = config._f[i];
  7677. configFromStringAndFormat(tempConfig);
  7678. if (!isValid(tempConfig)) {
  7679. continue;
  7680. }
  7681. // if there is any input that was not parsed add a penalty for that format
  7682. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  7683. //or tokens
  7684. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  7685. getParsingFlags(tempConfig).score = currentScore;
  7686. if (scoreToBeat == null || currentScore < scoreToBeat) {
  7687. scoreToBeat = currentScore;
  7688. bestMoment = tempConfig;
  7689. }
  7690. }
  7691. extend(config, bestMoment || tempConfig);
  7692. }
  7693. function configFromObject(config) {
  7694. if (config._d) {
  7695. return;
  7696. }
  7697. var i = normalizeObjectUnits(config._i);
  7698. config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
  7699. return obj && parseInt(obj, 10);
  7700. });
  7701. configFromArray(config);
  7702. }
  7703. function createFromConfig (config) {
  7704. var res = new Moment(checkOverflow(prepareConfig(config)));
  7705. if (res._nextDay) {
  7706. // Adding is smart enough around DST
  7707. res.add(1, 'd');
  7708. res._nextDay = undefined;
  7709. }
  7710. return res;
  7711. }
  7712. function prepareConfig (config) {
  7713. var input = config._i,
  7714. format = config._f;
  7715. config._locale = config._locale || getLocale(config._l);
  7716. if (input === null || (format === undefined && input === '')) {
  7717. return createInvalid({nullInput: true});
  7718. }
  7719. if (typeof input === 'string') {
  7720. config._i = input = config._locale.preparse(input);
  7721. }
  7722. if (isMoment(input)) {
  7723. return new Moment(checkOverflow(input));
  7724. } else if (isDate(input)) {
  7725. config._d = input;
  7726. } else if (isArray(format)) {
  7727. configFromStringAndArray(config);
  7728. } else if (format) {
  7729. configFromStringAndFormat(config);
  7730. } else {
  7731. configFromInput(config);
  7732. }
  7733. if (!isValid(config)) {
  7734. config._d = null;
  7735. }
  7736. return config;
  7737. }
  7738. function configFromInput(config) {
  7739. var input = config._i;
  7740. if (isUndefined(input)) {
  7741. config._d = new Date(hooks.now());
  7742. } else if (isDate(input)) {
  7743. config._d = new Date(input.valueOf());
  7744. } else if (typeof input === 'string') {
  7745. configFromString(config);
  7746. } else if (isArray(input)) {
  7747. config._a = map(input.slice(0), function (obj) {
  7748. return parseInt(obj, 10);
  7749. });
  7750. configFromArray(config);
  7751. } else if (isObject(input)) {
  7752. configFromObject(config);
  7753. } else if (isNumber(input)) {
  7754. // from milliseconds
  7755. config._d = new Date(input);
  7756. } else {
  7757. hooks.createFromInputFallback(config);
  7758. }
  7759. }
  7760. function createLocalOrUTC (input, format, locale, strict, isUTC) {
  7761. var c = {};
  7762. if (locale === true || locale === false) {
  7763. strict = locale;
  7764. locale = undefined;
  7765. }
  7766. if ((isObject(input) && isObjectEmpty(input)) ||
  7767. (isArray(input) && input.length === 0)) {
  7768. input = undefined;
  7769. }
  7770. // object construction must be done this way.
  7771. // https://github.com/moment/moment/issues/1423
  7772. c._isAMomentObject = true;
  7773. c._useUTC = c._isUTC = isUTC;
  7774. c._l = locale;
  7775. c._i = input;
  7776. c._f = format;
  7777. c._strict = strict;
  7778. return createFromConfig(c);
  7779. }
  7780. function createLocal (input, format, locale, strict) {
  7781. return createLocalOrUTC(input, format, locale, strict, false);
  7782. }
  7783. var prototypeMin = deprecate(
  7784. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  7785. function () {
  7786. var other = createLocal.apply(null, arguments);
  7787. if (this.isValid() && other.isValid()) {
  7788. return other < this ? this : other;
  7789. } else {
  7790. return createInvalid();
  7791. }
  7792. }
  7793. );
  7794. var prototypeMax = deprecate(
  7795. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  7796. function () {
  7797. var other = createLocal.apply(null, arguments);
  7798. if (this.isValid() && other.isValid()) {
  7799. return other > this ? this : other;
  7800. } else {
  7801. return createInvalid();
  7802. }
  7803. }
  7804. );
  7805. // Pick a moment m from moments so that m[fn](other) is true for all
  7806. // other. This relies on the function fn to be transitive.
  7807. //
  7808. // moments should either be an array of moment objects or an array, whose
  7809. // first element is an array of moment objects.
  7810. function pickBy(fn, moments) {
  7811. var res, i;
  7812. if (moments.length === 1 && isArray(moments[0])) {
  7813. moments = moments[0];
  7814. }
  7815. if (!moments.length) {
  7816. return createLocal();
  7817. }
  7818. res = moments[0];
  7819. for (i = 1; i < moments.length; ++i) {
  7820. if (!moments[i].isValid() || moments[i][fn](res)) {
  7821. res = moments[i];
  7822. }
  7823. }
  7824. return res;
  7825. }
  7826. // TODO: Use [].sort instead?
  7827. function min () {
  7828. var args = [].slice.call(arguments, 0);
  7829. return pickBy('isBefore', args);
  7830. }
  7831. function max () {
  7832. var args = [].slice.call(arguments, 0);
  7833. return pickBy('isAfter', args);
  7834. }
  7835. var now = function () {
  7836. return Date.now ? Date.now() : +(new Date());
  7837. };
  7838. var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
  7839. function isDurationValid(m) {
  7840. for (var key in m) {
  7841. if (!(ordering.indexOf(key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
  7842. return false;
  7843. }
  7844. }
  7845. var unitHasDecimal = false;
  7846. for (var i = 0; i < ordering.length; ++i) {
  7847. if (m[ordering[i]]) {
  7848. if (unitHasDecimal) {
  7849. return false; // only allow non-integers for smallest unit
  7850. }
  7851. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  7852. unitHasDecimal = true;
  7853. }
  7854. }
  7855. }
  7856. return true;
  7857. }
  7858. function isValid$1() {
  7859. return this._isValid;
  7860. }
  7861. function createInvalid$1() {
  7862. return createDuration(NaN);
  7863. }
  7864. function Duration (duration) {
  7865. var normalizedInput = normalizeObjectUnits(duration),
  7866. years = normalizedInput.year || 0,
  7867. quarters = normalizedInput.quarter || 0,
  7868. months = normalizedInput.month || 0,
  7869. weeks = normalizedInput.week || 0,
  7870. days = normalizedInput.day || 0,
  7871. hours = normalizedInput.hour || 0,
  7872. minutes = normalizedInput.minute || 0,
  7873. seconds = normalizedInput.second || 0,
  7874. milliseconds = normalizedInput.millisecond || 0;
  7875. this._isValid = isDurationValid(normalizedInput);
  7876. // representation for dateAddRemove
  7877. this._milliseconds = +milliseconds +
  7878. seconds * 1e3 + // 1000
  7879. minutes * 6e4 + // 1000 * 60
  7880. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  7881. // Because of dateAddRemove treats 24 hours as different from a
  7882. // day when working around DST, we need to store them separately
  7883. this._days = +days +
  7884. weeks * 7;
  7885. // It is impossible translate months into days without knowing
  7886. // which months you are are talking about, so we have to store
  7887. // it separately.
  7888. this._months = +months +
  7889. quarters * 3 +
  7890. years * 12;
  7891. this._data = {};
  7892. this._locale = getLocale();
  7893. this._bubble();
  7894. }
  7895. function isDuration (obj) {
  7896. return obj instanceof Duration;
  7897. }
  7898. function absRound (number) {
  7899. if (number < 0) {
  7900. return Math.round(-1 * number) * -1;
  7901. } else {
  7902. return Math.round(number);
  7903. }
  7904. }
  7905. // FORMATTING
  7906. function offset (token, separator) {
  7907. addFormatToken(token, 0, 0, function () {
  7908. var offset = this.utcOffset();
  7909. var sign = '+';
  7910. if (offset < 0) {
  7911. offset = -offset;
  7912. sign = '-';
  7913. }
  7914. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  7915. });
  7916. }
  7917. offset('Z', ':');
  7918. offset('ZZ', '');
  7919. // PARSING
  7920. addRegexToken('Z', matchShortOffset);
  7921. addRegexToken('ZZ', matchShortOffset);
  7922. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  7923. config._useUTC = true;
  7924. config._tzm = offsetFromString(matchShortOffset, input);
  7925. });
  7926. // HELPERS
  7927. // timezone chunker
  7928. // '+10:00' > ['10', '00']
  7929. // '-1530' > ['-15', '30']
  7930. var chunkOffset = /([\+\-]|\d\d)/gi;
  7931. function offsetFromString(matcher, string) {
  7932. var matches = (string || '').match(matcher);
  7933. if (matches === null) {
  7934. return null;
  7935. }
  7936. var chunk = matches[matches.length - 1] || [];
  7937. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  7938. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  7939. return minutes === 0 ?
  7940. 0 :
  7941. parts[0] === '+' ? minutes : -minutes;
  7942. }
  7943. // Return a moment from input, that is local/utc/zone equivalent to model.
  7944. function cloneWithOffset(input, model) {
  7945. var res, diff;
  7946. if (model._isUTC) {
  7947. res = model.clone();
  7948. diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
  7949. // Use low-level api, because this fn is low-level api.
  7950. res._d.setTime(res._d.valueOf() + diff);
  7951. hooks.updateOffset(res, false);
  7952. return res;
  7953. } else {
  7954. return createLocal(input).local();
  7955. }
  7956. }
  7957. function getDateOffset (m) {
  7958. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  7959. // https://github.com/moment/moment/pull/1871
  7960. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  7961. }
  7962. // HOOKS
  7963. // This function will be called whenever a moment is mutated.
  7964. // It is intended to keep the offset in sync with the timezone.
  7965. hooks.updateOffset = function () {};
  7966. // MOMENTS
  7967. // keepLocalTime = true means only change the timezone, without
  7968. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  7969. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  7970. // +0200, so we adjust the time as needed, to be valid.
  7971. //
  7972. // Keeping the time actually adds/subtracts (one hour)
  7973. // from the actual represented time. That is why we call updateOffset
  7974. // a second time. In case it wants us to change the offset again
  7975. // _changeInProgress == true case, then we have to adjust, because
  7976. // there is no such time in the given timezone.
  7977. function getSetOffset (input, keepLocalTime, keepMinutes) {
  7978. var offset = this._offset || 0,
  7979. localAdjust;
  7980. if (!this.isValid()) {
  7981. return input != null ? this : NaN;
  7982. }
  7983. if (input != null) {
  7984. if (typeof input === 'string') {
  7985. input = offsetFromString(matchShortOffset, input);
  7986. if (input === null) {
  7987. return this;
  7988. }
  7989. } else if (Math.abs(input) < 16 && !keepMinutes) {
  7990. input = input * 60;
  7991. }
  7992. if (!this._isUTC && keepLocalTime) {
  7993. localAdjust = getDateOffset(this);
  7994. }
  7995. this._offset = input;
  7996. this._isUTC = true;
  7997. if (localAdjust != null) {
  7998. this.add(localAdjust, 'm');
  7999. }
  8000. if (offset !== input) {
  8001. if (!keepLocalTime || this._changeInProgress) {
  8002. addSubtract(this, createDuration(input - offset, 'm'), 1, false);
  8003. } else if (!this._changeInProgress) {
  8004. this._changeInProgress = true;
  8005. hooks.updateOffset(this, true);
  8006. this._changeInProgress = null;
  8007. }
  8008. }
  8009. return this;
  8010. } else {
  8011. return this._isUTC ? offset : getDateOffset(this);
  8012. }
  8013. }
  8014. function getSetZone (input, keepLocalTime) {
  8015. if (input != null) {
  8016. if (typeof input !== 'string') {
  8017. input = -input;
  8018. }
  8019. this.utcOffset(input, keepLocalTime);
  8020. return this;
  8021. } else {
  8022. return -this.utcOffset();
  8023. }
  8024. }
  8025. function setOffsetToUTC (keepLocalTime) {
  8026. return this.utcOffset(0, keepLocalTime);
  8027. }
  8028. function setOffsetToLocal (keepLocalTime) {
  8029. if (this._isUTC) {
  8030. this.utcOffset(0, keepLocalTime);
  8031. this._isUTC = false;
  8032. if (keepLocalTime) {
  8033. this.subtract(getDateOffset(this), 'm');
  8034. }
  8035. }
  8036. return this;
  8037. }
  8038. function setOffsetToParsedOffset () {
  8039. if (this._tzm != null) {
  8040. this.utcOffset(this._tzm, false, true);
  8041. } else if (typeof this._i === 'string') {
  8042. var tZone = offsetFromString(matchOffset, this._i);
  8043. if (tZone != null) {
  8044. this.utcOffset(tZone);
  8045. }
  8046. else {
  8047. this.utcOffset(0, true);
  8048. }
  8049. }
  8050. return this;
  8051. }
  8052. function hasAlignedHourOffset (input) {
  8053. if (!this.isValid()) {
  8054. return false;
  8055. }
  8056. input = input ? createLocal(input).utcOffset() : 0;
  8057. return (this.utcOffset() - input) % 60 === 0;
  8058. }
  8059. function isDaylightSavingTime () {
  8060. return (
  8061. this.utcOffset() > this.clone().month(0).utcOffset() ||
  8062. this.utcOffset() > this.clone().month(5).utcOffset()
  8063. );
  8064. }
  8065. function isDaylightSavingTimeShifted () {
  8066. if (!isUndefined(this._isDSTShifted)) {
  8067. return this._isDSTShifted;
  8068. }
  8069. var c = {};
  8070. copyConfig(c, this);
  8071. c = prepareConfig(c);
  8072. if (c._a) {
  8073. var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  8074. this._isDSTShifted = this.isValid() &&
  8075. compareArrays(c._a, other.toArray()) > 0;
  8076. } else {
  8077. this._isDSTShifted = false;
  8078. }
  8079. return this._isDSTShifted;
  8080. }
  8081. function isLocal () {
  8082. return this.isValid() ? !this._isUTC : false;
  8083. }
  8084. function isUtcOffset () {
  8085. return this.isValid() ? this._isUTC : false;
  8086. }
  8087. function isUtc () {
  8088. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  8089. }
  8090. // ASP.NET json date format regex
  8091. var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
  8092. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  8093. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  8094. // and further modified to allow for strings containing both week and day
  8095. var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
  8096. function createDuration (input, key) {
  8097. var duration = input,
  8098. // matching against regexp is expensive, do it on demand
  8099. match = null,
  8100. sign,
  8101. ret,
  8102. diffRes;
  8103. if (isDuration(input)) {
  8104. duration = {
  8105. ms : input._milliseconds,
  8106. d : input._days,
  8107. M : input._months
  8108. };
  8109. } else if (isNumber(input)) {
  8110. duration = {};
  8111. if (key) {
  8112. duration[key] = input;
  8113. } else {
  8114. duration.milliseconds = input;
  8115. }
  8116. } else if (!!(match = aspNetRegex.exec(input))) {
  8117. sign = (match[1] === '-') ? -1 : 1;
  8118. duration = {
  8119. y : 0,
  8120. d : toInt(match[DATE]) * sign,
  8121. h : toInt(match[HOUR]) * sign,
  8122. m : toInt(match[MINUTE]) * sign,
  8123. s : toInt(match[SECOND]) * sign,
  8124. ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
  8125. };
  8126. } else if (!!(match = isoRegex.exec(input))) {
  8127. sign = (match[1] === '-') ? -1 : 1;
  8128. duration = {
  8129. y : parseIso(match[2], sign),
  8130. M : parseIso(match[3], sign),
  8131. w : parseIso(match[4], sign),
  8132. d : parseIso(match[5], sign),
  8133. h : parseIso(match[6], sign),
  8134. m : parseIso(match[7], sign),
  8135. s : parseIso(match[8], sign)
  8136. };
  8137. } else if (duration == null) {// checks for null or undefined
  8138. duration = {};
  8139. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  8140. diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
  8141. duration = {};
  8142. duration.ms = diffRes.milliseconds;
  8143. duration.M = diffRes.months;
  8144. }
  8145. ret = new Duration(duration);
  8146. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  8147. ret._locale = input._locale;
  8148. }
  8149. return ret;
  8150. }
  8151. createDuration.fn = Duration.prototype;
  8152. createDuration.invalid = createInvalid$1;
  8153. function parseIso (inp, sign) {
  8154. // We'd normally use ~~inp for this, but unfortunately it also
  8155. // converts floats to ints.
  8156. // inp may be undefined, so careful calling replace on it.
  8157. var res = inp && parseFloat(inp.replace(',', '.'));
  8158. // apply sign while we're at it
  8159. return (isNaN(res) ? 0 : res) * sign;
  8160. }
  8161. function positiveMomentsDifference(base, other) {
  8162. var res = {milliseconds: 0, months: 0};
  8163. res.months = other.month() - base.month() +
  8164. (other.year() - base.year()) * 12;
  8165. if (base.clone().add(res.months, 'M').isAfter(other)) {
  8166. --res.months;
  8167. }
  8168. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  8169. return res;
  8170. }
  8171. function momentsDifference(base, other) {
  8172. var res;
  8173. if (!(base.isValid() && other.isValid())) {
  8174. return {milliseconds: 0, months: 0};
  8175. }
  8176. other = cloneWithOffset(other, base);
  8177. if (base.isBefore(other)) {
  8178. res = positiveMomentsDifference(base, other);
  8179. } else {
  8180. res = positiveMomentsDifference(other, base);
  8181. res.milliseconds = -res.milliseconds;
  8182. res.months = -res.months;
  8183. }
  8184. return res;
  8185. }
  8186. // TODO: remove 'name' arg after deprecation is removed
  8187. function createAdder(direction, name) {
  8188. return function (val, period) {
  8189. var dur, tmp;
  8190. //invert the arguments, but complain about it
  8191. if (period !== null && !isNaN(+period)) {
  8192. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
  8193. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
  8194. tmp = val; val = period; period = tmp;
  8195. }
  8196. val = typeof val === 'string' ? +val : val;
  8197. dur = createDuration(val, period);
  8198. addSubtract(this, dur, direction);
  8199. return this;
  8200. };
  8201. }
  8202. function addSubtract (mom, duration, isAdding, updateOffset) {
  8203. var milliseconds = duration._milliseconds,
  8204. days = absRound(duration._days),
  8205. months = absRound(duration._months);
  8206. if (!mom.isValid()) {
  8207. // No op
  8208. return;
  8209. }
  8210. updateOffset = updateOffset == null ? true : updateOffset;
  8211. if (milliseconds) {
  8212. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  8213. }
  8214. if (days) {
  8215. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  8216. }
  8217. if (months) {
  8218. setMonth(mom, get(mom, 'Month') + months * isAdding);
  8219. }
  8220. if (updateOffset) {
  8221. hooks.updateOffset(mom, days || months);
  8222. }
  8223. }
  8224. var add = createAdder(1, 'add');
  8225. var subtract = createAdder(-1, 'subtract');
  8226. function getCalendarFormat(myMoment, now) {
  8227. var diff = myMoment.diff(now, 'days', true);
  8228. return diff < -6 ? 'sameElse' :
  8229. diff < -1 ? 'lastWeek' :
  8230. diff < 0 ? 'lastDay' :
  8231. diff < 1 ? 'sameDay' :
  8232. diff < 2 ? 'nextDay' :
  8233. diff < 7 ? 'nextWeek' : 'sameElse';
  8234. }
  8235. function calendar$1 (time, formats) {
  8236. // We want to compare the start of today, vs this.
  8237. // Getting start-of-today depends on whether we're local/utc/offset or not.
  8238. var now = time || createLocal(),
  8239. sod = cloneWithOffset(now, this).startOf('day'),
  8240. format = hooks.calendarFormat(this, sod) || 'sameElse';
  8241. var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
  8242. return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
  8243. }
  8244. function clone () {
  8245. return new Moment(this);
  8246. }
  8247. function isAfter (input, units) {
  8248. var localInput = isMoment(input) ? input : createLocal(input);
  8249. if (!(this.isValid() && localInput.isValid())) {
  8250. return false;
  8251. }
  8252. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  8253. if (units === 'millisecond') {
  8254. return this.valueOf() > localInput.valueOf();
  8255. } else {
  8256. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  8257. }
  8258. }
  8259. function isBefore (input, units) {
  8260. var localInput = isMoment(input) ? input : createLocal(input);
  8261. if (!(this.isValid() && localInput.isValid())) {
  8262. return false;
  8263. }
  8264. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  8265. if (units === 'millisecond') {
  8266. return this.valueOf() < localInput.valueOf();
  8267. } else {
  8268. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  8269. }
  8270. }
  8271. function isBetween (from, to, units, inclusivity) {
  8272. inclusivity = inclusivity || '()';
  8273. return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
  8274. (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
  8275. }
  8276. function isSame (input, units) {
  8277. var localInput = isMoment(input) ? input : createLocal(input),
  8278. inputMs;
  8279. if (!(this.isValid() && localInput.isValid())) {
  8280. return false;
  8281. }
  8282. units = normalizeUnits(units || 'millisecond');
  8283. if (units === 'millisecond') {
  8284. return this.valueOf() === localInput.valueOf();
  8285. } else {
  8286. inputMs = localInput.valueOf();
  8287. return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
  8288. }
  8289. }
  8290. function isSameOrAfter (input, units) {
  8291. return this.isSame(input, units) || this.isAfter(input,units);
  8292. }
  8293. function isSameOrBefore (input, units) {
  8294. return this.isSame(input, units) || this.isBefore(input,units);
  8295. }
  8296. function diff (input, units, asFloat) {
  8297. var that,
  8298. zoneDelta,
  8299. delta, output;
  8300. if (!this.isValid()) {
  8301. return NaN;
  8302. }
  8303. that = cloneWithOffset(input, this);
  8304. if (!that.isValid()) {
  8305. return NaN;
  8306. }
  8307. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  8308. units = normalizeUnits(units);
  8309. if (units === 'year' || units === 'month' || units === 'quarter') {
  8310. output = monthDiff(this, that);
  8311. if (units === 'quarter') {
  8312. output = output / 3;
  8313. } else if (units === 'year') {
  8314. output = output / 12;
  8315. }
  8316. } else {
  8317. delta = this - that;
  8318. output = units === 'second' ? delta / 1e3 : // 1000
  8319. units === 'minute' ? delta / 6e4 : // 1000 * 60
  8320. units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
  8321. units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
  8322. units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
  8323. delta;
  8324. }
  8325. return asFloat ? output : absFloor(output);
  8326. }
  8327. function monthDiff (a, b) {
  8328. // difference in months
  8329. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  8330. // b is in (anchor - 1 month, anchor + 1 month)
  8331. anchor = a.clone().add(wholeMonthDiff, 'months'),
  8332. anchor2, adjust;
  8333. if (b - anchor < 0) {
  8334. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  8335. // linear across the month
  8336. adjust = (b - anchor) / (anchor - anchor2);
  8337. } else {
  8338. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  8339. // linear across the month
  8340. adjust = (b - anchor) / (anchor2 - anchor);
  8341. }
  8342. //check for negative zero, return zero if negative zero
  8343. return -(wholeMonthDiff + adjust) || 0;
  8344. }
  8345. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  8346. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  8347. function toString () {
  8348. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  8349. }
  8350. function toISOString() {
  8351. if (!this.isValid()) {
  8352. return null;
  8353. }
  8354. var m = this.clone().utc();
  8355. if (m.year() < 0 || m.year() > 9999) {
  8356. return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  8357. }
  8358. if (isFunction(Date.prototype.toISOString)) {
  8359. // native implementation is ~50x faster, use it when we can
  8360. return this.toDate().toISOString();
  8361. }
  8362. return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  8363. }
  8364. /**
  8365. * Return a human readable representation of a moment that can
  8366. * also be evaluated to get a new moment which is the same
  8367. *
  8368. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  8369. */
  8370. function inspect () {
  8371. if (!this.isValid()) {
  8372. return 'moment.invalid(/* ' + this._i + ' */)';
  8373. }
  8374. var func = 'moment';
  8375. var zone = '';
  8376. if (!this.isLocal()) {
  8377. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  8378. zone = 'Z';
  8379. }
  8380. var prefix = '[' + func + '("]';
  8381. var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
  8382. var datetime = '-MM-DD[T]HH:mm:ss.SSS';
  8383. var suffix = zone + '[")]';
  8384. return this.format(prefix + year + datetime + suffix);
  8385. }
  8386. function format (inputString) {
  8387. if (!inputString) {
  8388. inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
  8389. }
  8390. var output = formatMoment(this, inputString);
  8391. return this.localeData().postformat(output);
  8392. }
  8393. function from (time, withoutSuffix) {
  8394. if (this.isValid() &&
  8395. ((isMoment(time) && time.isValid()) ||
  8396. createLocal(time).isValid())) {
  8397. return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
  8398. } else {
  8399. return this.localeData().invalidDate();
  8400. }
  8401. }
  8402. function fromNow (withoutSuffix) {
  8403. return this.from(createLocal(), withoutSuffix);
  8404. }
  8405. function to (time, withoutSuffix) {
  8406. if (this.isValid() &&
  8407. ((isMoment(time) && time.isValid()) ||
  8408. createLocal(time).isValid())) {
  8409. return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  8410. } else {
  8411. return this.localeData().invalidDate();
  8412. }
  8413. }
  8414. function toNow (withoutSuffix) {
  8415. return this.to(createLocal(), withoutSuffix);
  8416. }
  8417. // If passed a locale key, it will set the locale for this
  8418. // instance. Otherwise, it will return the locale configuration
  8419. // variables for this instance.
  8420. function locale (key) {
  8421. var newLocaleData;
  8422. if (key === undefined) {
  8423. return this._locale._abbr;
  8424. } else {
  8425. newLocaleData = getLocale(key);
  8426. if (newLocaleData != null) {
  8427. this._locale = newLocaleData;
  8428. }
  8429. return this;
  8430. }
  8431. }
  8432. var lang = deprecate(
  8433. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  8434. function (key) {
  8435. if (key === undefined) {
  8436. return this.localeData();
  8437. } else {
  8438. return this.locale(key);
  8439. }
  8440. }
  8441. );
  8442. function localeData () {
  8443. return this._locale;
  8444. }
  8445. function startOf (units) {
  8446. units = normalizeUnits(units);
  8447. // the following switch intentionally omits break keywords
  8448. // to utilize falling through the cases.
  8449. switch (units) {
  8450. case 'year':
  8451. this.month(0);
  8452. /* falls through */
  8453. case 'quarter':
  8454. case 'month':
  8455. this.date(1);
  8456. /* falls through */
  8457. case 'week':
  8458. case 'isoWeek':
  8459. case 'day':
  8460. case 'date':
  8461. this.hours(0);
  8462. /* falls through */
  8463. case 'hour':
  8464. this.minutes(0);
  8465. /* falls through */
  8466. case 'minute':
  8467. this.seconds(0);
  8468. /* falls through */
  8469. case 'second':
  8470. this.milliseconds(0);
  8471. }
  8472. // weeks are a special case
  8473. if (units === 'week') {
  8474. this.weekday(0);
  8475. }
  8476. if (units === 'isoWeek') {
  8477. this.isoWeekday(1);
  8478. }
  8479. // quarters are also special
  8480. if (units === 'quarter') {
  8481. this.month(Math.floor(this.month() / 3) * 3);
  8482. }
  8483. return this;
  8484. }
  8485. function endOf (units) {
  8486. units = normalizeUnits(units);
  8487. if (units === undefined || units === 'millisecond') {
  8488. return this;
  8489. }
  8490. // 'date' is an alias for 'day', so it should be considered as such.
  8491. if (units === 'date') {
  8492. units = 'day';
  8493. }
  8494. return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
  8495. }
  8496. function valueOf () {
  8497. return this._d.valueOf() - ((this._offset || 0) * 60000);
  8498. }
  8499. function unix () {
  8500. return Math.floor(this.valueOf() / 1000);
  8501. }
  8502. function toDate () {
  8503. return new Date(this.valueOf());
  8504. }
  8505. function toArray () {
  8506. var m = this;
  8507. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  8508. }
  8509. function toObject () {
  8510. var m = this;
  8511. return {
  8512. years: m.year(),
  8513. months: m.month(),
  8514. date: m.date(),
  8515. hours: m.hours(),
  8516. minutes: m.minutes(),
  8517. seconds: m.seconds(),
  8518. milliseconds: m.milliseconds()
  8519. };
  8520. }
  8521. function toJSON () {
  8522. // new Date(NaN).toJSON() === null
  8523. return this.isValid() ? this.toISOString() : null;
  8524. }
  8525. function isValid$2 () {
  8526. return isValid(this);
  8527. }
  8528. function parsingFlags () {
  8529. return extend({}, getParsingFlags(this));
  8530. }
  8531. function invalidAt () {
  8532. return getParsingFlags(this).overflow;
  8533. }
  8534. function creationData() {
  8535. return {
  8536. input: this._i,
  8537. format: this._f,
  8538. locale: this._locale,
  8539. isUTC: this._isUTC,
  8540. strict: this._strict
  8541. };
  8542. }
  8543. // FORMATTING
  8544. addFormatToken(0, ['gg', 2], 0, function () {
  8545. return this.weekYear() % 100;
  8546. });
  8547. addFormatToken(0, ['GG', 2], 0, function () {
  8548. return this.isoWeekYear() % 100;
  8549. });
  8550. function addWeekYearFormatToken (token, getter) {
  8551. addFormatToken(0, [token, token.length], 0, getter);
  8552. }
  8553. addWeekYearFormatToken('gggg', 'weekYear');
  8554. addWeekYearFormatToken('ggggg', 'weekYear');
  8555. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  8556. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  8557. // ALIASES
  8558. addUnitAlias('weekYear', 'gg');
  8559. addUnitAlias('isoWeekYear', 'GG');
  8560. // PRIORITY
  8561. addUnitPriority('weekYear', 1);
  8562. addUnitPriority('isoWeekYear', 1);
  8563. // PARSING
  8564. addRegexToken('G', matchSigned);
  8565. addRegexToken('g', matchSigned);
  8566. addRegexToken('GG', match1to2, match2);
  8567. addRegexToken('gg', match1to2, match2);
  8568. addRegexToken('GGGG', match1to4, match4);
  8569. addRegexToken('gggg', match1to4, match4);
  8570. addRegexToken('GGGGG', match1to6, match6);
  8571. addRegexToken('ggggg', match1to6, match6);
  8572. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  8573. week[token.substr(0, 2)] = toInt(input);
  8574. });
  8575. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  8576. week[token] = hooks.parseTwoDigitYear(input);
  8577. });
  8578. // MOMENTS
  8579. function getSetWeekYear (input) {
  8580. return getSetWeekYearHelper.call(this,
  8581. input,
  8582. this.week(),
  8583. this.weekday(),
  8584. this.localeData()._week.dow,
  8585. this.localeData()._week.doy);
  8586. }
  8587. function getSetISOWeekYear (input) {
  8588. return getSetWeekYearHelper.call(this,
  8589. input, this.isoWeek(), this.isoWeekday(), 1, 4);
  8590. }
  8591. function getISOWeeksInYear () {
  8592. return weeksInYear(this.year(), 1, 4);
  8593. }
  8594. function getWeeksInYear () {
  8595. var weekInfo = this.localeData()._week;
  8596. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  8597. }
  8598. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  8599. var weeksTarget;
  8600. if (input == null) {
  8601. return weekOfYear(this, dow, doy).year;
  8602. } else {
  8603. weeksTarget = weeksInYear(input, dow, doy);
  8604. if (week > weeksTarget) {
  8605. week = weeksTarget;
  8606. }
  8607. return setWeekAll.call(this, input, week, weekday, dow, doy);
  8608. }
  8609. }
  8610. function setWeekAll(weekYear, week, weekday, dow, doy) {
  8611. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  8612. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  8613. this.year(date.getUTCFullYear());
  8614. this.month(date.getUTCMonth());
  8615. this.date(date.getUTCDate());
  8616. return this;
  8617. }
  8618. // FORMATTING
  8619. addFormatToken('Q', 0, 'Qo', 'quarter');
  8620. // ALIASES
  8621. addUnitAlias('quarter', 'Q');
  8622. // PRIORITY
  8623. addUnitPriority('quarter', 7);
  8624. // PARSING
  8625. addRegexToken('Q', match1);
  8626. addParseToken('Q', function (input, array) {
  8627. array[MONTH] = (toInt(input) - 1) * 3;
  8628. });
  8629. // MOMENTS
  8630. function getSetQuarter (input) {
  8631. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  8632. }
  8633. // FORMATTING
  8634. addFormatToken('D', ['DD', 2], 'Do', 'date');
  8635. // ALIASES
  8636. addUnitAlias('date', 'D');
  8637. // PRIOROITY
  8638. addUnitPriority('date', 9);
  8639. // PARSING
  8640. addRegexToken('D', match1to2);
  8641. addRegexToken('DD', match1to2, match2);
  8642. addRegexToken('Do', function (isStrict, locale) {
  8643. // TODO: Remove "ordinalParse" fallback in next major release.
  8644. return isStrict ?
  8645. (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
  8646. locale._dayOfMonthOrdinalParseLenient;
  8647. });
  8648. addParseToken(['D', 'DD'], DATE);
  8649. addParseToken('Do', function (input, array) {
  8650. array[DATE] = toInt(input.match(match1to2)[0], 10);
  8651. });
  8652. // MOMENTS
  8653. var getSetDayOfMonth = makeGetSet('Date', true);
  8654. // FORMATTING
  8655. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  8656. // ALIASES
  8657. addUnitAlias('dayOfYear', 'DDD');
  8658. // PRIORITY
  8659. addUnitPriority('dayOfYear', 4);
  8660. // PARSING
  8661. addRegexToken('DDD', match1to3);
  8662. addRegexToken('DDDD', match3);
  8663. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  8664. config._dayOfYear = toInt(input);
  8665. });
  8666. // HELPERS
  8667. // MOMENTS
  8668. function getSetDayOfYear (input) {
  8669. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  8670. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  8671. }
  8672. // FORMATTING
  8673. addFormatToken('m', ['mm', 2], 0, 'minute');
  8674. // ALIASES
  8675. addUnitAlias('minute', 'm');
  8676. // PRIORITY
  8677. addUnitPriority('minute', 14);
  8678. // PARSING
  8679. addRegexToken('m', match1to2);
  8680. addRegexToken('mm', match1to2, match2);
  8681. addParseToken(['m', 'mm'], MINUTE);
  8682. // MOMENTS
  8683. var getSetMinute = makeGetSet('Minutes', false);
  8684. // FORMATTING
  8685. addFormatToken('s', ['ss', 2], 0, 'second');
  8686. // ALIASES
  8687. addUnitAlias('second', 's');
  8688. // PRIORITY
  8689. addUnitPriority('second', 15);
  8690. // PARSING
  8691. addRegexToken('s', match1to2);
  8692. addRegexToken('ss', match1to2, match2);
  8693. addParseToken(['s', 'ss'], SECOND);
  8694. // MOMENTS
  8695. var getSetSecond = makeGetSet('Seconds', false);
  8696. // FORMATTING
  8697. addFormatToken('S', 0, 0, function () {
  8698. return ~~(this.millisecond() / 100);
  8699. });
  8700. addFormatToken(0, ['SS', 2], 0, function () {
  8701. return ~~(this.millisecond() / 10);
  8702. });
  8703. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  8704. addFormatToken(0, ['SSSS', 4], 0, function () {
  8705. return this.millisecond() * 10;
  8706. });
  8707. addFormatToken(0, ['SSSSS', 5], 0, function () {
  8708. return this.millisecond() * 100;
  8709. });
  8710. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  8711. return this.millisecond() * 1000;
  8712. });
  8713. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  8714. return this.millisecond() * 10000;
  8715. });
  8716. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  8717. return this.millisecond() * 100000;
  8718. });
  8719. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  8720. return this.millisecond() * 1000000;
  8721. });
  8722. // ALIASES
  8723. addUnitAlias('millisecond', 'ms');
  8724. // PRIORITY
  8725. addUnitPriority('millisecond', 16);
  8726. // PARSING
  8727. addRegexToken('S', match1to3, match1);
  8728. addRegexToken('SS', match1to3, match2);
  8729. addRegexToken('SSS', match1to3, match3);
  8730. var token;
  8731. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  8732. addRegexToken(token, matchUnsigned);
  8733. }
  8734. function parseMs(input, array) {
  8735. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  8736. }
  8737. for (token = 'S'; token.length <= 9; token += 'S') {
  8738. addParseToken(token, parseMs);
  8739. }
  8740. // MOMENTS
  8741. var getSetMillisecond = makeGetSet('Milliseconds', false);
  8742. // FORMATTING
  8743. addFormatToken('z', 0, 0, 'zoneAbbr');
  8744. addFormatToken('zz', 0, 0, 'zoneName');
  8745. // MOMENTS
  8746. function getZoneAbbr () {
  8747. return this._isUTC ? 'UTC' : '';
  8748. }
  8749. function getZoneName () {
  8750. return this._isUTC ? 'Coordinated Universal Time' : '';
  8751. }
  8752. var proto = Moment.prototype;
  8753. proto.add = add;
  8754. proto.calendar = calendar$1;
  8755. proto.clone = clone;
  8756. proto.diff = diff;
  8757. proto.endOf = endOf;
  8758. proto.format = format;
  8759. proto.from = from;
  8760. proto.fromNow = fromNow;
  8761. proto.to = to;
  8762. proto.toNow = toNow;
  8763. proto.get = stringGet;
  8764. proto.invalidAt = invalidAt;
  8765. proto.isAfter = isAfter;
  8766. proto.isBefore = isBefore;
  8767. proto.isBetween = isBetween;
  8768. proto.isSame = isSame;
  8769. proto.isSameOrAfter = isSameOrAfter;
  8770. proto.isSameOrBefore = isSameOrBefore;
  8771. proto.isValid = isValid$2;
  8772. proto.lang = lang;
  8773. proto.locale = locale;
  8774. proto.localeData = localeData;
  8775. proto.max = prototypeMax;
  8776. proto.min = prototypeMin;
  8777. proto.parsingFlags = parsingFlags;
  8778. proto.set = stringSet;
  8779. proto.startOf = startOf;
  8780. proto.subtract = subtract;
  8781. proto.toArray = toArray;
  8782. proto.toObject = toObject;
  8783. proto.toDate = toDate;
  8784. proto.toISOString = toISOString;
  8785. proto.inspect = inspect;
  8786. proto.toJSON = toJSON;
  8787. proto.toString = toString;
  8788. proto.unix = unix;
  8789. proto.valueOf = valueOf;
  8790. proto.creationData = creationData;
  8791. // Year
  8792. proto.year = getSetYear;
  8793. proto.isLeapYear = getIsLeapYear;
  8794. // Week Year
  8795. proto.weekYear = getSetWeekYear;
  8796. proto.isoWeekYear = getSetISOWeekYear;
  8797. // Quarter
  8798. proto.quarter = proto.quarters = getSetQuarter;
  8799. // Month
  8800. proto.month = getSetMonth;
  8801. proto.daysInMonth = getDaysInMonth;
  8802. // Week
  8803. proto.week = proto.weeks = getSetWeek;
  8804. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  8805. proto.weeksInYear = getWeeksInYear;
  8806. proto.isoWeeksInYear = getISOWeeksInYear;
  8807. // Day
  8808. proto.date = getSetDayOfMonth;
  8809. proto.day = proto.days = getSetDayOfWeek;
  8810. proto.weekday = getSetLocaleDayOfWeek;
  8811. proto.isoWeekday = getSetISODayOfWeek;
  8812. proto.dayOfYear = getSetDayOfYear;
  8813. // Hour
  8814. proto.hour = proto.hours = getSetHour;
  8815. // Minute
  8816. proto.minute = proto.minutes = getSetMinute;
  8817. // Second
  8818. proto.second = proto.seconds = getSetSecond;
  8819. // Millisecond
  8820. proto.millisecond = proto.milliseconds = getSetMillisecond;
  8821. // Offset
  8822. proto.utcOffset = getSetOffset;
  8823. proto.utc = setOffsetToUTC;
  8824. proto.local = setOffsetToLocal;
  8825. proto.parseZone = setOffsetToParsedOffset;
  8826. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  8827. proto.isDST = isDaylightSavingTime;
  8828. proto.isLocal = isLocal;
  8829. proto.isUtcOffset = isUtcOffset;
  8830. proto.isUtc = isUtc;
  8831. proto.isUTC = isUtc;
  8832. // Timezone
  8833. proto.zoneAbbr = getZoneAbbr;
  8834. proto.zoneName = getZoneName;
  8835. // Deprecations
  8836. proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  8837. proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  8838. proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  8839. proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
  8840. proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
  8841. function createUnix (input) {
  8842. return createLocal(input * 1000);
  8843. }
  8844. function createInZone () {
  8845. return createLocal.apply(null, arguments).parseZone();
  8846. }
  8847. function preParsePostFormat (string) {
  8848. return string;
  8849. }
  8850. var proto$1 = Locale.prototype;
  8851. proto$1.calendar = calendar;
  8852. proto$1.longDateFormat = longDateFormat;
  8853. proto$1.invalidDate = invalidDate;
  8854. proto$1.ordinal = ordinal;
  8855. proto$1.preparse = preParsePostFormat;
  8856. proto$1.postformat = preParsePostFormat;
  8857. proto$1.relativeTime = relativeTime;
  8858. proto$1.pastFuture = pastFuture;
  8859. proto$1.set = set;
  8860. // Month
  8861. proto$1.months = localeMonths;
  8862. proto$1.monthsShort = localeMonthsShort;
  8863. proto$1.monthsParse = localeMonthsParse;
  8864. proto$1.monthsRegex = monthsRegex;
  8865. proto$1.monthsShortRegex = monthsShortRegex;
  8866. // Week
  8867. proto$1.week = localeWeek;
  8868. proto$1.firstDayOfYear = localeFirstDayOfYear;
  8869. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  8870. // Day of Week
  8871. proto$1.weekdays = localeWeekdays;
  8872. proto$1.weekdaysMin = localeWeekdaysMin;
  8873. proto$1.weekdaysShort = localeWeekdaysShort;
  8874. proto$1.weekdaysParse = localeWeekdaysParse;
  8875. proto$1.weekdaysRegex = weekdaysRegex;
  8876. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  8877. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  8878. // Hours
  8879. proto$1.isPM = localeIsPM;
  8880. proto$1.meridiem = localeMeridiem;
  8881. function get$1 (format, index, field, setter) {
  8882. var locale = getLocale();
  8883. var utc = createUTC().set(setter, index);
  8884. return locale[field](utc, format);
  8885. }
  8886. function listMonthsImpl (format, index, field) {
  8887. if (isNumber(format)) {
  8888. index = format;
  8889. format = undefined;
  8890. }
  8891. format = format || '';
  8892. if (index != null) {
  8893. return get$1(format, index, field, 'month');
  8894. }
  8895. var i;
  8896. var out = [];
  8897. for (i = 0; i < 12; i++) {
  8898. out[i] = get$1(format, i, field, 'month');
  8899. }
  8900. return out;
  8901. }
  8902. // ()
  8903. // (5)
  8904. // (fmt, 5)
  8905. // (fmt)
  8906. // (true)
  8907. // (true, 5)
  8908. // (true, fmt, 5)
  8909. // (true, fmt)
  8910. function listWeekdaysImpl (localeSorted, format, index, field) {
  8911. if (typeof localeSorted === 'boolean') {
  8912. if (isNumber(format)) {
  8913. index = format;
  8914. format = undefined;
  8915. }
  8916. format = format || '';
  8917. } else {
  8918. format = localeSorted;
  8919. index = format;
  8920. localeSorted = false;
  8921. if (isNumber(format)) {
  8922. index = format;
  8923. format = undefined;
  8924. }
  8925. format = format || '';
  8926. }
  8927. var locale = getLocale(),
  8928. shift = localeSorted ? locale._week.dow : 0;
  8929. if (index != null) {
  8930. return get$1(format, (index + shift) % 7, field, 'day');
  8931. }
  8932. var i;
  8933. var out = [];
  8934. for (i = 0; i < 7; i++) {
  8935. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  8936. }
  8937. return out;
  8938. }
  8939. function listMonths (format, index) {
  8940. return listMonthsImpl(format, index, 'months');
  8941. }
  8942. function listMonthsShort (format, index) {
  8943. return listMonthsImpl(format, index, 'monthsShort');
  8944. }
  8945. function listWeekdays (localeSorted, format, index) {
  8946. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  8947. }
  8948. function listWeekdaysShort (localeSorted, format, index) {
  8949. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  8950. }
  8951. function listWeekdaysMin (localeSorted, format, index) {
  8952. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  8953. }
  8954. getSetGlobalLocale('en', {
  8955. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  8956. ordinal : function (number) {
  8957. var b = number % 10,
  8958. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  8959. (b === 1) ? 'st' :
  8960. (b === 2) ? 'nd' :
  8961. (b === 3) ? 'rd' : 'th';
  8962. return number + output;
  8963. }
  8964. });
  8965. // Side effect imports
  8966. hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
  8967. hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
  8968. var mathAbs = Math.abs;
  8969. function abs () {
  8970. var data = this._data;
  8971. this._milliseconds = mathAbs(this._milliseconds);
  8972. this._days = mathAbs(this._days);
  8973. this._months = mathAbs(this._months);
  8974. data.milliseconds = mathAbs(data.milliseconds);
  8975. data.seconds = mathAbs(data.seconds);
  8976. data.minutes = mathAbs(data.minutes);
  8977. data.hours = mathAbs(data.hours);
  8978. data.months = mathAbs(data.months);
  8979. data.years = mathAbs(data.years);
  8980. return this;
  8981. }
  8982. function addSubtract$1 (duration, input, value, direction) {
  8983. var other = createDuration(input, value);
  8984. duration._milliseconds += direction * other._milliseconds;
  8985. duration._days += direction * other._days;
  8986. duration._months += direction * other._months;
  8987. return duration._bubble();
  8988. }
  8989. // supports only 2.0-style add(1, 's') or add(duration)
  8990. function add$1 (input, value) {
  8991. return addSubtract$1(this, input, value, 1);
  8992. }
  8993. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  8994. function subtract$1 (input, value) {
  8995. return addSubtract$1(this, input, value, -1);
  8996. }
  8997. function absCeil (number) {
  8998. if (number < 0) {
  8999. return Math.floor(number);
  9000. } else {
  9001. return Math.ceil(number);
  9002. }
  9003. }
  9004. function bubble () {
  9005. var milliseconds = this._milliseconds;
  9006. var days = this._days;
  9007. var months = this._months;
  9008. var data = this._data;
  9009. var seconds, minutes, hours, years, monthsFromDays;
  9010. // if we have a mix of positive and negative values, bubble down first
  9011. // check: https://github.com/moment/moment/issues/2166
  9012. if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
  9013. (milliseconds <= 0 && days <= 0 && months <= 0))) {
  9014. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  9015. days = 0;
  9016. months = 0;
  9017. }
  9018. // The following code bubbles up values, see the tests for
  9019. // examples of what that means.
  9020. data.milliseconds = milliseconds % 1000;
  9021. seconds = absFloor(milliseconds / 1000);
  9022. data.seconds = seconds % 60;
  9023. minutes = absFloor(seconds / 60);
  9024. data.minutes = minutes % 60;
  9025. hours = absFloor(minutes / 60);
  9026. data.hours = hours % 24;
  9027. days += absFloor(hours / 24);
  9028. // convert days to months
  9029. monthsFromDays = absFloor(daysToMonths(days));
  9030. months += monthsFromDays;
  9031. days -= absCeil(monthsToDays(monthsFromDays));
  9032. // 12 months -> 1 year
  9033. years = absFloor(months / 12);
  9034. months %= 12;
  9035. data.days = days;
  9036. data.months = months;
  9037. data.years = years;
  9038. return this;
  9039. }
  9040. function daysToMonths (days) {
  9041. // 400 years have 146097 days (taking into account leap year rules)
  9042. // 400 years have 12 months === 4800
  9043. return days * 4800 / 146097;
  9044. }
  9045. function monthsToDays (months) {
  9046. // the reverse of daysToMonths
  9047. return months * 146097 / 4800;
  9048. }
  9049. function as (units) {
  9050. if (!this.isValid()) {
  9051. return NaN;
  9052. }
  9053. var days;
  9054. var months;
  9055. var milliseconds = this._milliseconds;
  9056. units = normalizeUnits(units);
  9057. if (units === 'month' || units === 'year') {
  9058. days = this._days + milliseconds / 864e5;
  9059. months = this._months + daysToMonths(days);
  9060. return units === 'month' ? months : months / 12;
  9061. } else {
  9062. // handle milliseconds separately because of floating point math errors (issue #1867)
  9063. days = this._days + Math.round(monthsToDays(this._months));
  9064. switch (units) {
  9065. case 'week' : return days / 7 + milliseconds / 6048e5;
  9066. case 'day' : return days + milliseconds / 864e5;
  9067. case 'hour' : return days * 24 + milliseconds / 36e5;
  9068. case 'minute' : return days * 1440 + milliseconds / 6e4;
  9069. case 'second' : return days * 86400 + milliseconds / 1000;
  9070. // Math.floor prevents floating point math errors here
  9071. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  9072. default: throw new Error('Unknown unit ' + units);
  9073. }
  9074. }
  9075. }
  9076. // TODO: Use this.as('ms')?
  9077. function valueOf$1 () {
  9078. if (!this.isValid()) {
  9079. return NaN;
  9080. }
  9081. return (
  9082. this._milliseconds +
  9083. this._days * 864e5 +
  9084. (this._months % 12) * 2592e6 +
  9085. toInt(this._months / 12) * 31536e6
  9086. );
  9087. }
  9088. function makeAs (alias) {
  9089. return function () {
  9090. return this.as(alias);
  9091. };
  9092. }
  9093. var asMilliseconds = makeAs('ms');
  9094. var asSeconds = makeAs('s');
  9095. var asMinutes = makeAs('m');
  9096. var asHours = makeAs('h');
  9097. var asDays = makeAs('d');
  9098. var asWeeks = makeAs('w');
  9099. var asMonths = makeAs('M');
  9100. var asYears = makeAs('y');
  9101. function get$2 (units) {
  9102. units = normalizeUnits(units);
  9103. return this.isValid() ? this[units + 's']() : NaN;
  9104. }
  9105. function makeGetter(name) {
  9106. return function () {
  9107. return this.isValid() ? this._data[name] : NaN;
  9108. };
  9109. }
  9110. var milliseconds = makeGetter('milliseconds');
  9111. var seconds = makeGetter('seconds');
  9112. var minutes = makeGetter('minutes');
  9113. var hours = makeGetter('hours');
  9114. var days = makeGetter('days');
  9115. var months = makeGetter('months');
  9116. var years = makeGetter('years');
  9117. function weeks () {
  9118. return absFloor(this.days() / 7);
  9119. }
  9120. var round = Math.round;
  9121. var thresholds = {
  9122. ss: 44, // a few seconds to seconds
  9123. s : 45, // seconds to minute
  9124. m : 45, // minutes to hour
  9125. h : 22, // hours to day
  9126. d : 26, // days to month
  9127. M : 11 // months to year
  9128. };
  9129. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  9130. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  9131. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  9132. }
  9133. function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
  9134. var duration = createDuration(posNegDuration).abs();
  9135. var seconds = round(duration.as('s'));
  9136. var minutes = round(duration.as('m'));
  9137. var hours = round(duration.as('h'));
  9138. var days = round(duration.as('d'));
  9139. var months = round(duration.as('M'));
  9140. var years = round(duration.as('y'));
  9141. var a = seconds <= thresholds.ss && ['s', seconds] ||
  9142. seconds < thresholds.s && ['ss', seconds] ||
  9143. minutes <= 1 && ['m'] ||
  9144. minutes < thresholds.m && ['mm', minutes] ||
  9145. hours <= 1 && ['h'] ||
  9146. hours < thresholds.h && ['hh', hours] ||
  9147. days <= 1 && ['d'] ||
  9148. days < thresholds.d && ['dd', days] ||
  9149. months <= 1 && ['M'] ||
  9150. months < thresholds.M && ['MM', months] ||
  9151. years <= 1 && ['y'] || ['yy', years];
  9152. a[2] = withoutSuffix;
  9153. a[3] = +posNegDuration > 0;
  9154. a[4] = locale;
  9155. return substituteTimeAgo.apply(null, a);
  9156. }
  9157. // This function allows you to set the rounding function for relative time strings
  9158. function getSetRelativeTimeRounding (roundingFunction) {
  9159. if (roundingFunction === undefined) {
  9160. return round;
  9161. }
  9162. if (typeof(roundingFunction) === 'function') {
  9163. round = roundingFunction;
  9164. return true;
  9165. }
  9166. return false;
  9167. }
  9168. // This function allows you to set a threshold for relative time strings
  9169. function getSetRelativeTimeThreshold (threshold, limit) {
  9170. if (thresholds[threshold] === undefined) {
  9171. return false;
  9172. }
  9173. if (limit === undefined) {
  9174. return thresholds[threshold];
  9175. }
  9176. thresholds[threshold] = limit;
  9177. if (threshold === 's') {
  9178. thresholds.ss = limit - 1;
  9179. }
  9180. return true;
  9181. }
  9182. function humanize (withSuffix) {
  9183. if (!this.isValid()) {
  9184. return this.localeData().invalidDate();
  9185. }
  9186. var locale = this.localeData();
  9187. var output = relativeTime$1(this, !withSuffix, locale);
  9188. if (withSuffix) {
  9189. output = locale.pastFuture(+this, output);
  9190. }
  9191. return locale.postformat(output);
  9192. }
  9193. var abs$1 = Math.abs;
  9194. function toISOString$1() {
  9195. // for ISO strings we do not use the normal bubbling rules:
  9196. // * milliseconds bubble up until they become hours
  9197. // * days do not bubble at all
  9198. // * months bubble up until they become years
  9199. // This is because there is no context-free conversion between hours and days
  9200. // (think of clock changes)
  9201. // and also not between days and months (28-31 days per month)
  9202. if (!this.isValid()) {
  9203. return this.localeData().invalidDate();
  9204. }
  9205. var seconds = abs$1(this._milliseconds) / 1000;
  9206. var days = abs$1(this._days);
  9207. var months = abs$1(this._months);
  9208. var minutes, hours, years;
  9209. // 3600 seconds -> 60 minutes -> 1 hour
  9210. minutes = absFloor(seconds / 60);
  9211. hours = absFloor(minutes / 60);
  9212. seconds %= 60;
  9213. minutes %= 60;
  9214. // 12 months -> 1 year
  9215. years = absFloor(months / 12);
  9216. months %= 12;
  9217. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  9218. var Y = years;
  9219. var M = months;
  9220. var D = days;
  9221. var h = hours;
  9222. var m = minutes;
  9223. var s = seconds;
  9224. var total = this.asSeconds();
  9225. if (!total) {
  9226. // this is the same as C#'s (Noda) and python (isodate)...
  9227. // but not other JS (goog.date)
  9228. return 'P0D';
  9229. }
  9230. return (total < 0 ? '-' : '') +
  9231. 'P' +
  9232. (Y ? Y + 'Y' : '') +
  9233. (M ? M + 'M' : '') +
  9234. (D ? D + 'D' : '') +
  9235. ((h || m || s) ? 'T' : '') +
  9236. (h ? h + 'H' : '') +
  9237. (m ? m + 'M' : '') +
  9238. (s ? s + 'S' : '');
  9239. }
  9240. var proto$2 = Duration.prototype;
  9241. proto$2.isValid = isValid$1;
  9242. proto$2.abs = abs;
  9243. proto$2.add = add$1;
  9244. proto$2.subtract = subtract$1;
  9245. proto$2.as = as;
  9246. proto$2.asMilliseconds = asMilliseconds;
  9247. proto$2.asSeconds = asSeconds;
  9248. proto$2.asMinutes = asMinutes;
  9249. proto$2.asHours = asHours;
  9250. proto$2.asDays = asDays;
  9251. proto$2.asWeeks = asWeeks;
  9252. proto$2.asMonths = asMonths;
  9253. proto$2.asYears = asYears;
  9254. proto$2.valueOf = valueOf$1;
  9255. proto$2._bubble = bubble;
  9256. proto$2.get = get$2;
  9257. proto$2.milliseconds = milliseconds;
  9258. proto$2.seconds = seconds;
  9259. proto$2.minutes = minutes;
  9260. proto$2.hours = hours;
  9261. proto$2.days = days;
  9262. proto$2.weeks = weeks;
  9263. proto$2.months = months;
  9264. proto$2.years = years;
  9265. proto$2.humanize = humanize;
  9266. proto$2.toISOString = toISOString$1;
  9267. proto$2.toString = toISOString$1;
  9268. proto$2.toJSON = toISOString$1;
  9269. proto$2.locale = locale;
  9270. proto$2.localeData = localeData;
  9271. // Deprecations
  9272. proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
  9273. proto$2.lang = lang;
  9274. // Side effect imports
  9275. // FORMATTING
  9276. addFormatToken('X', 0, 0, 'unix');
  9277. addFormatToken('x', 0, 0, 'valueOf');
  9278. // PARSING
  9279. addRegexToken('x', matchSigned);
  9280. addRegexToken('X', matchTimestamp);
  9281. addParseToken('X', function (input, array, config) {
  9282. config._d = new Date(parseFloat(input, 10) * 1000);
  9283. });
  9284. addParseToken('x', function (input, array, config) {
  9285. config._d = new Date(toInt(input));
  9286. });
  9287. // Side effect imports
  9288. hooks.version = '2.18.1';
  9289. setHookCallback(createLocal);
  9290. hooks.fn = proto;
  9291. hooks.min = min;
  9292. hooks.max = max;
  9293. hooks.now = now;
  9294. hooks.utc = createUTC;
  9295. hooks.unix = createUnix;
  9296. hooks.months = listMonths;
  9297. hooks.isDate = isDate;
  9298. hooks.locale = getSetGlobalLocale;
  9299. hooks.invalid = createInvalid;
  9300. hooks.duration = createDuration;
  9301. hooks.isMoment = isMoment;
  9302. hooks.weekdays = listWeekdays;
  9303. hooks.parseZone = createInZone;
  9304. hooks.localeData = getLocale;
  9305. hooks.isDuration = isDuration;
  9306. hooks.monthsShort = listMonthsShort;
  9307. hooks.weekdaysMin = listWeekdaysMin;
  9308. hooks.defineLocale = defineLocale;
  9309. hooks.updateLocale = updateLocale;
  9310. hooks.locales = listLocales;
  9311. hooks.weekdaysShort = listWeekdaysShort;
  9312. hooks.normalizeUnits = normalizeUnits;
  9313. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  9314. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  9315. hooks.calendarFormat = getCalendarFormat;
  9316. hooks.prototype = proto;
  9317. return hooks;
  9318. })));
  9319. /*** EXPORTS FROM exports-to-window-loader ***/
  9320. window['moment'] = __webpack_require__(36);
  9321. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(420)(module)))
  9322. /***/ }),
  9323. /* 37 */
  9324. /***/ (function(module, exports, __webpack_require__) {
  9325. "use strict";
  9326. exports.__esModule = true;
  9327. exports.EditorState = undefined;
  9328. var _src = __webpack_require__(11);
  9329. var _mixed = __webpack_require__(20);
  9330. var EditorState = exports.EditorState = {
  9331. VIRGIN: 'STATE_VIRGIN', // before editing
  9332. EDITING: 'STATE_EDITING',
  9333. WAITING: 'STATE_WAITING', // waiting for async validation
  9334. FINISHED: 'STATE_FINISHED'
  9335. };
  9336. function BaseEditor(instance) {
  9337. this.instance = instance;
  9338. this.state = EditorState.VIRGIN;
  9339. this._opened = false;
  9340. this._fullEditMode = false;
  9341. this._closeCallback = null;
  9342. this.init();
  9343. }
  9344. BaseEditor.prototype._fireCallbacks = function (result) {
  9345. if (this._closeCallback) {
  9346. this._closeCallback(result);
  9347. this._closeCallback = null;
  9348. }
  9349. };
  9350. BaseEditor.prototype.init = function () {};
  9351. BaseEditor.prototype.getValue = function () {
  9352. throw Error('Editor getValue() method unimplemented');
  9353. };
  9354. BaseEditor.prototype.setValue = function (newValue) {
  9355. throw Error('Editor setValue() method unimplemented');
  9356. };
  9357. BaseEditor.prototype.open = function () {
  9358. throw Error('Editor open() method unimplemented');
  9359. };
  9360. BaseEditor.prototype.close = function () {
  9361. throw Error('Editor close() method unimplemented');
  9362. };
  9363. BaseEditor.prototype.prepare = function (row, col, prop, td, originalValue, cellProperties) {
  9364. this.TD = td;
  9365. this.row = row;
  9366. this.col = col;
  9367. this.prop = prop;
  9368. this.originalValue = originalValue;
  9369. this.cellProperties = cellProperties;
  9370. this.state = EditorState.VIRGIN;
  9371. };
  9372. BaseEditor.prototype.extend = function () {
  9373. var baseClass = this.constructor;
  9374. function Editor() {
  9375. baseClass.apply(this, arguments);
  9376. }
  9377. function inherit(Child, Parent) {
  9378. function Bridge() {}
  9379. Bridge.prototype = Parent.prototype;
  9380. Child.prototype = new Bridge();
  9381. Child.prototype.constructor = Child;
  9382. return Child;
  9383. }
  9384. return inherit(Editor, baseClass);
  9385. };
  9386. BaseEditor.prototype.saveValue = function (value, ctrlDown) {
  9387. var selection = void 0;
  9388. var tmp = void 0;
  9389. // if ctrl+enter and multiple cells selected, behave like Excel (finish editing and apply to all cells)
  9390. if (ctrlDown) {
  9391. selection = this.instance.getSelected();
  9392. if (selection[0] > selection[2]) {
  9393. tmp = selection[0];
  9394. selection[0] = selection[2];
  9395. selection[2] = tmp;
  9396. }
  9397. if (selection[1] > selection[3]) {
  9398. tmp = selection[1];
  9399. selection[1] = selection[3];
  9400. selection[3] = tmp;
  9401. }
  9402. } else {
  9403. selection = [this.row, this.col, null, null];
  9404. }
  9405. this.instance.populateFromArray(selection[0], selection[1], value, selection[2], selection[3], 'edit');
  9406. };
  9407. BaseEditor.prototype.beginEditing = function (initialValue, event) {
  9408. if (this.state != EditorState.VIRGIN) {
  9409. return;
  9410. }
  9411. this.instance.view.scrollViewport(new _src.CellCoords(this.row, this.col));
  9412. this.instance.view.render();
  9413. this.state = EditorState.EDITING;
  9414. initialValue = typeof initialValue == 'string' ? initialValue : this.originalValue;
  9415. this.setValue((0, _mixed.stringify)(initialValue));
  9416. this.open(event);
  9417. this._opened = true;
  9418. this.focus();
  9419. // only rerender the selections (FillHandle should disappear when beginediting is triggered)
  9420. this.instance.view.render();
  9421. this.instance.runHooks('afterBeginEditing', this.row, this.col);
  9422. };
  9423. BaseEditor.prototype.finishEditing = function (restoreOriginalValue, ctrlDown, callback) {
  9424. var _this = this,
  9425. val;
  9426. if (callback) {
  9427. var previousCloseCallback = this._closeCallback;
  9428. this._closeCallback = function (result) {
  9429. if (previousCloseCallback) {
  9430. previousCloseCallback(result);
  9431. }
  9432. callback(result);
  9433. _this.instance.view.render();
  9434. };
  9435. }
  9436. if (this.isWaiting()) {
  9437. return;
  9438. }
  9439. if (this.state == EditorState.VIRGIN) {
  9440. this.instance._registerTimeout(setTimeout(function () {
  9441. _this._fireCallbacks(true);
  9442. }, 0));
  9443. return;
  9444. }
  9445. if (this.state == EditorState.EDITING) {
  9446. if (restoreOriginalValue) {
  9447. this.cancelChanges();
  9448. this.instance.view.render();
  9449. return;
  9450. }
  9451. var value = this.getValue();
  9452. if (this.instance.getSettings().trimWhitespace) {
  9453. // We trim only string values
  9454. val = [[typeof value === 'string' ? String.prototype.trim.call(value || '') : value]];
  9455. } else {
  9456. val = [[value]];
  9457. }
  9458. this.state = EditorState.WAITING;
  9459. this.saveValue(val, ctrlDown);
  9460. if (this.instance.getCellValidator(this.cellProperties)) {
  9461. this.instance.addHookOnce('postAfterValidate', function (result) {
  9462. _this.state = EditorState.FINISHED;
  9463. _this.discardEditor(result);
  9464. });
  9465. } else {
  9466. this.state = EditorState.FINISHED;
  9467. this.discardEditor(true);
  9468. }
  9469. }
  9470. };
  9471. BaseEditor.prototype.cancelChanges = function () {
  9472. this.state = EditorState.FINISHED;
  9473. this.discardEditor();
  9474. };
  9475. BaseEditor.prototype.discardEditor = function (result) {
  9476. if (this.state !== EditorState.FINISHED) {
  9477. return;
  9478. }
  9479. // validator was defined and failed
  9480. if (result === false && this.cellProperties.allowInvalid !== true) {
  9481. this.instance.selectCell(this.row, this.col);
  9482. this.focus();
  9483. this.state = EditorState.EDITING;
  9484. this._fireCallbacks(false);
  9485. } else {
  9486. this.close();
  9487. this._opened = false;
  9488. this._fullEditMode = false;
  9489. this.state = EditorState.VIRGIN;
  9490. this._fireCallbacks(true);
  9491. }
  9492. };
  9493. /**
  9494. * Switch editor into full edit mode. In this state navigation keys don't close editor. This mode is activated
  9495. * automatically after hit ENTER or F2 key on the cell or while editing cell press F2 key.
  9496. */
  9497. BaseEditor.prototype.enableFullEditMode = function () {
  9498. this._fullEditMode = true;
  9499. };
  9500. /**
  9501. * Checks if editor is in full edit mode.
  9502. *
  9503. * @returns {Boolean}
  9504. */
  9505. BaseEditor.prototype.isInFullEditMode = function () {
  9506. return this._fullEditMode;
  9507. };
  9508. BaseEditor.prototype.isOpened = function () {
  9509. return this._opened;
  9510. };
  9511. BaseEditor.prototype.isWaiting = function () {
  9512. return this.state === EditorState.WAITING;
  9513. };
  9514. BaseEditor.prototype.checkEditorSection = function () {
  9515. var totalRows = this.instance.countRows();
  9516. var section = '';
  9517. if (this.row < this.instance.getSettings().fixedRowsTop) {
  9518. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  9519. section = 'top-left-corner';
  9520. } else {
  9521. section = 'top';
  9522. }
  9523. } else if (this.instance.getSettings().fixedRowsBottom && this.row >= totalRows - this.instance.getSettings().fixedRowsBottom) {
  9524. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  9525. section = 'bottom-left-corner';
  9526. } else {
  9527. section = 'bottom';
  9528. }
  9529. } else if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  9530. section = 'left';
  9531. }
  9532. return section;
  9533. };
  9534. exports.default = BaseEditor;
  9535. /***/ }),
  9536. /* 38 */
  9537. /***/ (function(module, exports, __webpack_require__) {
  9538. // 22.1.3.31 Array.prototype[@@unscopables]
  9539. var UNSCOPABLES = __webpack_require__(10)('unscopables')
  9540. , ArrayProto = Array.prototype;
  9541. if(ArrayProto[UNSCOPABLES] == undefined)__webpack_require__(32)(ArrayProto, UNSCOPABLES, {});
  9542. module.exports = function(key){
  9543. ArrayProto[UNSCOPABLES][key] = true;
  9544. };
  9545. /***/ }),
  9546. /* 39 */
  9547. /***/ (function(module, exports) {
  9548. var toString = {}.toString;
  9549. module.exports = function(it){
  9550. return toString.call(it).slice(8, -1);
  9551. };
  9552. /***/ }),
  9553. /* 40 */
  9554. /***/ (function(module, exports, __webpack_require__) {
  9555. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  9556. var $keys = __webpack_require__(284)
  9557. , enumBugKeys = __webpack_require__(76);
  9558. module.exports = Object.keys || function keys(O){
  9559. return $keys(O, enumBugKeys);
  9560. };
  9561. /***/ }),
  9562. /* 41 */
  9563. /***/ (function(module, exports) {
  9564. module.exports = function(bitmap, value){
  9565. return {
  9566. enumerable : !(bitmap & 1),
  9567. configurable: !(bitmap & 2),
  9568. writable : !(bitmap & 4),
  9569. value : value
  9570. };
  9571. };
  9572. /***/ }),
  9573. /* 42 */
  9574. /***/ (function(module, exports, __webpack_require__) {
  9575. // 7.1.13 ToObject(argument)
  9576. var defined = __webpack_require__(30);
  9577. module.exports = function(it){
  9578. return Object(defined(it));
  9579. };
  9580. /***/ }),
  9581. /* 43 */
  9582. /***/ (function(module, exports, __webpack_require__) {
  9583. "use strict";
  9584. exports.__esModule = true;
  9585. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9586. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9587. /**
  9588. * CellCoords holds cell coordinates (row, column) and few method to validate them and
  9589. * retrieve as an array or an object
  9590. *
  9591. * @class CellCoords
  9592. */
  9593. var CellCoords = function () {
  9594. /**
  9595. * @param {Number} row Row index
  9596. * @param {Number} col Column index
  9597. */
  9598. function CellCoords(row, col) {
  9599. _classCallCheck(this, CellCoords);
  9600. if (typeof row !== 'undefined' && typeof col !== 'undefined') {
  9601. this.row = row;
  9602. this.col = col;
  9603. } else {
  9604. this.row = null;
  9605. this.col = null;
  9606. }
  9607. }
  9608. /**
  9609. * Checks if given set of coordinates is valid in context of a given Walkontable instance
  9610. *
  9611. * @param {Walkontable} wotInstance
  9612. * @returns {Boolean}
  9613. */
  9614. _createClass(CellCoords, [{
  9615. key: 'isValid',
  9616. value: function isValid(wotInstance) {
  9617. // is it a valid cell index (0 or higher)
  9618. if (this.row < 0 || this.col < 0) {
  9619. return false;
  9620. }
  9621. // is selection within total rows and columns
  9622. if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) {
  9623. return false;
  9624. }
  9625. return true;
  9626. }
  9627. /**
  9628. * Checks if this cell coords are the same as cell coords given as a parameter
  9629. *
  9630. * @param {CellCoords} cellCoords
  9631. * @returns {Boolean}
  9632. */
  9633. }, {
  9634. key: 'isEqual',
  9635. value: function isEqual(cellCoords) {
  9636. if (cellCoords === this) {
  9637. return true;
  9638. }
  9639. return this.row === cellCoords.row && this.col === cellCoords.col;
  9640. }
  9641. /**
  9642. * Checks if tested coordinates are positioned in south-east from this cell coords
  9643. *
  9644. * @param {Object} testedCoords
  9645. * @returns {Boolean}
  9646. */
  9647. }, {
  9648. key: 'isSouthEastOf',
  9649. value: function isSouthEastOf(testedCoords) {
  9650. return this.row >= testedCoords.row && this.col >= testedCoords.col;
  9651. }
  9652. /**
  9653. * Checks if tested coordinates are positioned in north-east from this cell coords
  9654. *
  9655. * @param {Object} testedCoords
  9656. * @returns {Boolean}
  9657. */
  9658. }, {
  9659. key: 'isNorthWestOf',
  9660. value: function isNorthWestOf(testedCoords) {
  9661. return this.row <= testedCoords.row && this.col <= testedCoords.col;
  9662. }
  9663. /**
  9664. * Checks if tested coordinates are positioned in south-west from this cell coords
  9665. *
  9666. * @param {Object} testedCoords
  9667. * @returns {Boolean}
  9668. */
  9669. }, {
  9670. key: 'isSouthWestOf',
  9671. value: function isSouthWestOf(testedCoords) {
  9672. return this.row >= testedCoords.row && this.col <= testedCoords.col;
  9673. }
  9674. /**
  9675. * Checks if tested coordinates are positioned in north-east from this cell coords
  9676. *
  9677. * @param {Object} testedCoords
  9678. * @returns {Boolean}
  9679. */
  9680. }, {
  9681. key: 'isNorthEastOf',
  9682. value: function isNorthEastOf(testedCoords) {
  9683. return this.row <= testedCoords.row && this.col >= testedCoords.col;
  9684. }
  9685. }]);
  9686. return CellCoords;
  9687. }();
  9688. exports.default = CellCoords;
  9689. /***/ }),
  9690. /* 44 */
  9691. /***/ (function(module, exports, __webpack_require__) {
  9692. "use strict";
  9693. exports.__esModule = true;
  9694. var _element = __webpack_require__(0);
  9695. var _autoResize = __webpack_require__(298);
  9696. var _autoResize2 = _interopRequireDefault(_autoResize);
  9697. var _baseEditor = __webpack_require__(37);
  9698. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  9699. var _eventManager = __webpack_require__(4);
  9700. var _eventManager2 = _interopRequireDefault(_eventManager);
  9701. var _unicode = __webpack_require__(16);
  9702. var _event = __webpack_require__(7);
  9703. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9704. var TextEditor = _baseEditor2.default.prototype.extend();
  9705. /**
  9706. * @private
  9707. * @editor TextEditor
  9708. * @class TextEditor
  9709. * @dependencies autoResize
  9710. */
  9711. TextEditor.prototype.init = function () {
  9712. var that = this;
  9713. this.createElements();
  9714. this.eventManager = new _eventManager2.default(this);
  9715. this.bindEvents();
  9716. this.autoResize = (0, _autoResize2.default)();
  9717. this.instance.addHook('afterDestroy', function () {
  9718. that.destroy();
  9719. });
  9720. };
  9721. TextEditor.prototype.getValue = function () {
  9722. return this.TEXTAREA.value;
  9723. };
  9724. TextEditor.prototype.setValue = function (newValue) {
  9725. this.TEXTAREA.value = newValue;
  9726. };
  9727. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  9728. var instance = this,
  9729. that = instance.getActiveEditor(),
  9730. ctrlDown;
  9731. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  9732. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  9733. // Process only events that have been fired in the editor
  9734. if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) {
  9735. return;
  9736. }
  9737. if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) {
  9738. // when CTRL or its equivalent is pressed and cell is edited, don't prepare selectable text in textarea
  9739. (0, _event.stopImmediatePropagation)(event);
  9740. return;
  9741. }
  9742. switch (event.keyCode) {
  9743. case _unicode.KEY_CODES.ARROW_RIGHT:
  9744. if (that.isInFullEditMode()) {
  9745. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  9746. (0, _event.stopImmediatePropagation)(event);
  9747. }
  9748. }
  9749. break;
  9750. case _unicode.KEY_CODES.ARROW_LEFT:
  9751. if (that.isInFullEditMode()) {
  9752. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  9753. (0, _event.stopImmediatePropagation)(event);
  9754. }
  9755. }
  9756. break;
  9757. case _unicode.KEY_CODES.ARROW_UP:
  9758. case _unicode.KEY_CODES.ARROW_DOWN:
  9759. if (that.isInFullEditMode()) {
  9760. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  9761. (0, _event.stopImmediatePropagation)(event);
  9762. }
  9763. }
  9764. break;
  9765. case _unicode.KEY_CODES.ENTER:
  9766. var selected = that.instance.getSelected();
  9767. var isMultipleSelection = !(selected[0] === selected[2] && selected[1] === selected[3]);
  9768. if (ctrlDown && !isMultipleSelection || event.altKey) {
  9769. // if ctrl+enter or alt+enter, add new line
  9770. if (that.isOpened()) {
  9771. var caretPosition = (0, _element.getCaretPosition)(that.TEXTAREA),
  9772. value = that.getValue();
  9773. var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition);
  9774. that.setValue(newValue);
  9775. (0, _element.setCaretPosition)(that.TEXTAREA, caretPosition + 1);
  9776. } else {
  9777. that.beginEditing(that.originalValue + '\n');
  9778. }
  9779. (0, _event.stopImmediatePropagation)(event);
  9780. }
  9781. event.preventDefault(); // don't add newline to field
  9782. break;
  9783. case _unicode.KEY_CODES.A:
  9784. case _unicode.KEY_CODES.X:
  9785. case _unicode.KEY_CODES.C:
  9786. case _unicode.KEY_CODES.V:
  9787. if (ctrlDown) {
  9788. (0, _event.stopImmediatePropagation)(event); // CTRL+A, CTRL+C, CTRL+V, CTRL+X should only work locally when cell is edited (not in table context)
  9789. }
  9790. break;
  9791. case _unicode.KEY_CODES.BACKSPACE:
  9792. case _unicode.KEY_CODES.DELETE:
  9793. case _unicode.KEY_CODES.HOME:
  9794. case _unicode.KEY_CODES.END:
  9795. (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context)
  9796. break;
  9797. default:
  9798. break;
  9799. }
  9800. 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) {
  9801. that.autoResize.resize(String.fromCharCode(event.keyCode));
  9802. }
  9803. };
  9804. TextEditor.prototype.open = function () {
  9805. this.refreshDimensions(); // need it instantly, to prevent https://github.com/handsontable/handsontable/issues/348
  9806. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  9807. };
  9808. TextEditor.prototype.close = function (tdOutside) {
  9809. this.textareaParentStyle.display = 'none';
  9810. this.autoResize.unObserve();
  9811. if (document.activeElement === this.TEXTAREA) {
  9812. this.instance.listen(); // don't refocus the table if user focused some cell outside of HT on purpose
  9813. }
  9814. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  9815. };
  9816. TextEditor.prototype.focus = function () {
  9817. this.TEXTAREA.focus();
  9818. (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length);
  9819. };
  9820. TextEditor.prototype.createElements = function () {
  9821. // this.$body = $(document.body);
  9822. this.TEXTAREA = document.createElement('TEXTAREA');
  9823. (0, _element.addClass)(this.TEXTAREA, 'handsontableInput');
  9824. this.textareaStyle = this.TEXTAREA.style;
  9825. this.textareaStyle.width = 0;
  9826. this.textareaStyle.height = 0;
  9827. this.TEXTAREA_PARENT = document.createElement('DIV');
  9828. (0, _element.addClass)(this.TEXTAREA_PARENT, 'handsontableInputHolder');
  9829. this.textareaParentStyle = this.TEXTAREA_PARENT.style;
  9830. this.textareaParentStyle.top = 0;
  9831. this.textareaParentStyle.left = 0;
  9832. this.textareaParentStyle.display = 'none';
  9833. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  9834. this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
  9835. var that = this;
  9836. this.instance._registerTimeout(setTimeout(function () {
  9837. that.refreshDimensions();
  9838. }, 0));
  9839. };
  9840. TextEditor.prototype.getEditedCell = function () {
  9841. var editorSection = this.checkEditorSection(),
  9842. editedCell;
  9843. switch (editorSection) {
  9844. case 'top':
  9845. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  9846. row: this.row,
  9847. col: this.col
  9848. });
  9849. this.textareaParentStyle.zIndex = 101;
  9850. break;
  9851. case 'top-left-corner':
  9852. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  9853. row: this.row,
  9854. col: this.col
  9855. });
  9856. this.textareaParentStyle.zIndex = 103;
  9857. break;
  9858. case 'bottom-left-corner':
  9859. editedCell = this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell({
  9860. row: this.row,
  9861. col: this.col
  9862. });
  9863. this.textareaParentStyle.zIndex = 103;
  9864. break;
  9865. case 'left':
  9866. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  9867. row: this.row,
  9868. col: this.col
  9869. });
  9870. this.textareaParentStyle.zIndex = 102;
  9871. break;
  9872. case 'bottom':
  9873. editedCell = this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.getCell({
  9874. row: this.row,
  9875. col: this.col
  9876. });
  9877. this.textareaParentStyle.zIndex = 102;
  9878. break;
  9879. default:
  9880. editedCell = this.instance.getCell(this.row, this.col);
  9881. this.textareaParentStyle.zIndex = '';
  9882. break;
  9883. }
  9884. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  9885. };
  9886. TextEditor.prototype.refreshValue = function () {
  9887. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  9888. this.originalValue = sourceData;
  9889. this.setValue(sourceData);
  9890. this.refreshDimensions();
  9891. };
  9892. TextEditor.prototype.refreshDimensions = function () {
  9893. if (this.state !== _baseEditor.EditorState.EDITING) {
  9894. return;
  9895. }
  9896. this.TD = this.getEditedCell();
  9897. // TD is outside of the viewport.
  9898. if (!this.TD) {
  9899. this.close(true);
  9900. return;
  9901. }
  9902. var currentOffset = (0, _element.offset)(this.TD),
  9903. containerOffset = (0, _element.offset)(this.instance.rootElement),
  9904. scrollableContainer = (0, _element.getScrollableElement)(this.TD),
  9905. totalRowsCount = this.instance.countRows(),
  9906. // If colHeaders is disabled, cells in the first row have border-top
  9907. editTopModifier = currentOffset.top === containerOffset.top ? 0 : 1,
  9908. editTop = currentOffset.top - containerOffset.top - editTopModifier - (scrollableContainer.scrollTop || 0),
  9909. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  9910. settings = this.instance.getSettings(),
  9911. rowHeadersCount = this.instance.hasRowHeaders(),
  9912. colHeadersCount = this.instance.hasColHeaders(),
  9913. editorSection = this.checkEditorSection(),
  9914. backgroundColor = this.TD.style.backgroundColor,
  9915. cssTransformOffset;
  9916. // TODO: Refactor this to the new instance.getCell method (from #ply-59), after 0.12.1 is released
  9917. switch (editorSection) {
  9918. case 'top':
  9919. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  9920. break;
  9921. case 'left':
  9922. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  9923. break;
  9924. case 'top-left-corner':
  9925. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  9926. break;
  9927. case 'bottom-left-corner':
  9928. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  9929. break;
  9930. case 'bottom':
  9931. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  9932. break;
  9933. default:
  9934. break;
  9935. }
  9936. if (colHeadersCount && this.instance.getSelected()[0] === 0 || settings.fixedRowsBottom && this.instance.getSelected()[0] === totalRowsCount - settings.fixedRowsBottom) {
  9937. editTop += 1;
  9938. }
  9939. if (this.instance.getSelected()[1] === 0) {
  9940. editLeft += 1;
  9941. }
  9942. if (cssTransformOffset && cssTransformOffset != -1) {
  9943. this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  9944. } else {
  9945. (0, _element.resetCssTransform)(this.TEXTAREA_PARENT);
  9946. }
  9947. this.textareaParentStyle.top = editTop + 'px';
  9948. this.textareaParentStyle.left = editLeft + 'px';
  9949. var firstRowOffset = this.instance.view.wt.wtViewport.rowsRenderCalculator.startPosition;
  9950. var firstColumnOffset = this.instance.view.wt.wtViewport.columnsRenderCalculator.startPosition;
  9951. var horizontalScrollPosition = this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  9952. var verticalScrollPosition = this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition();
  9953. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  9954. var cellTopOffset = this.TD.offsetTop + firstRowOffset - verticalScrollPosition;
  9955. var cellLeftOffset = this.TD.offsetLeft + firstColumnOffset - horizontalScrollPosition;
  9956. var width = (0, _element.innerWidth)(this.TD) - 8;
  9957. var actualVerticalScrollbarWidth = (0, _element.hasVerticalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  9958. var actualHorizontalScrollbarWidth = (0, _element.hasHorizontalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  9959. var maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 9 - actualVerticalScrollbarWidth;
  9960. var height = this.TD.scrollHeight + 1;
  9961. var maxHeight = Math.max(this.instance.view.maximumVisibleElementHeight(cellTopOffset) - actualHorizontalScrollbarWidth, 23);
  9962. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  9963. this.TEXTAREA.style.fontSize = cellComputedStyle.fontSize;
  9964. this.TEXTAREA.style.fontFamily = cellComputedStyle.fontFamily;
  9965. this.TEXTAREA.style.backgroundColor = ''; // RESET STYLE
  9966. this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : (0, _element.getComputedStyle)(this.TEXTAREA).backgroundColor;
  9967. this.autoResize.init(this.TEXTAREA, {
  9968. minHeight: Math.min(height, maxHeight),
  9969. maxHeight: maxHeight, // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  9970. minWidth: Math.min(width, maxWidth),
  9971. maxWidth: maxWidth // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  9972. }, true);
  9973. this.textareaParentStyle.display = 'block';
  9974. };
  9975. TextEditor.prototype.bindEvents = function () {
  9976. var editor = this;
  9977. this.eventManager.addEventListener(this.TEXTAREA, 'cut', function (event) {
  9978. (0, _event.stopPropagation)(event);
  9979. });
  9980. this.eventManager.addEventListener(this.TEXTAREA, 'paste', function (event) {
  9981. (0, _event.stopPropagation)(event);
  9982. });
  9983. this.instance.addHook('afterScrollHorizontally', function () {
  9984. editor.refreshDimensions();
  9985. });
  9986. this.instance.addHook('afterScrollVertically', function () {
  9987. editor.refreshDimensions();
  9988. });
  9989. this.instance.addHook('afterColumnResize', function () {
  9990. editor.refreshDimensions();
  9991. editor.focus();
  9992. });
  9993. this.instance.addHook('afterRowResize', function () {
  9994. editor.refreshDimensions();
  9995. editor.focus();
  9996. });
  9997. this.instance.addHook('afterDestroy', function () {
  9998. editor.eventManager.destroy();
  9999. });
  10000. };
  10001. TextEditor.prototype.destroy = function () {
  10002. this.eventManager.destroy();
  10003. };
  10004. exports.default = TextEditor;
  10005. /***/ }),
  10006. /* 45 */
  10007. /***/ (function(module, exports) {
  10008. var core = module.exports = {version: '2.4.0'};
  10009. if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
  10010. /***/ }),
  10011. /* 46 */
  10012. /***/ (function(module, exports) {
  10013. module.exports = {};
  10014. /***/ }),
  10015. /* 47 */
  10016. /***/ (function(module, exports, __webpack_require__) {
  10017. var META = __webpack_require__(50)('meta')
  10018. , isObject = __webpack_require__(15)
  10019. , has = __webpack_require__(22)
  10020. , setDesc = __webpack_require__(19).f
  10021. , id = 0;
  10022. var isExtensible = Object.isExtensible || function(){
  10023. return true;
  10024. };
  10025. var FREEZE = !__webpack_require__(31)(function(){
  10026. return isExtensible(Object.preventExtensions({}));
  10027. });
  10028. var setMeta = function(it){
  10029. setDesc(it, META, {value: {
  10030. i: 'O' + ++id, // object ID
  10031. w: {} // weak collections IDs
  10032. }});
  10033. };
  10034. var fastKey = function(it, create){
  10035. // return primitive with prefix
  10036. if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  10037. if(!has(it, META)){
  10038. // can't set metadata to uncaught frozen object
  10039. if(!isExtensible(it))return 'F';
  10040. // not necessary to add metadata
  10041. if(!create)return 'E';
  10042. // add missing metadata
  10043. setMeta(it);
  10044. // return object ID
  10045. } return it[META].i;
  10046. };
  10047. var getWeak = function(it, create){
  10048. if(!has(it, META)){
  10049. // can't set metadata to uncaught frozen object
  10050. if(!isExtensible(it))return true;
  10051. // not necessary to add metadata
  10052. if(!create)return false;
  10053. // add missing metadata
  10054. setMeta(it);
  10055. // return hash weak collections IDs
  10056. } return it[META].w;
  10057. };
  10058. // add metadata on freeze-family methods calling
  10059. var onFreeze = function(it){
  10060. if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
  10061. return it;
  10062. };
  10063. var meta = module.exports = {
  10064. KEY: META,
  10065. NEED: false,
  10066. fastKey: fastKey,
  10067. getWeak: getWeak,
  10068. onFreeze: onFreeze
  10069. };
  10070. /***/ }),
  10071. /* 48 */
  10072. /***/ (function(module, exports) {
  10073. exports.f = {}.propertyIsEnumerable;
  10074. /***/ }),
  10075. /* 49 */
  10076. /***/ (function(module, exports, __webpack_require__) {
  10077. var def = __webpack_require__(19).f
  10078. , has = __webpack_require__(22)
  10079. , TAG = __webpack_require__(10)('toStringTag');
  10080. module.exports = function(it, tag, stat){
  10081. if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
  10082. };
  10083. /***/ }),
  10084. /* 50 */
  10085. /***/ (function(module, exports) {
  10086. var id = 0
  10087. , px = Math.random();
  10088. module.exports = function(key){
  10089. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  10090. };
  10091. /***/ }),
  10092. /* 51 */
  10093. /***/ (function(module, exports, __webpack_require__) {
  10094. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  10095. * numbro.js
  10096. * version : 1.11.0
  10097. * author : Företagsplatsen AB
  10098. * license : MIT
  10099. * http://www.foretagsplatsen.se
  10100. */
  10101. (function () {
  10102. 'use strict';
  10103. /************************************
  10104. Constants
  10105. ************************************/
  10106. var numbro,
  10107. VERSION = '1.11.0',
  10108. binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'],
  10109. decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  10110. bytes = {
  10111. general: { scale: 1024, suffixes: decimalSuffixes, marker: 'bd' },
  10112. binary: { scale: 1024, suffixes: binarySuffixes, marker: 'b' },
  10113. decimal: { scale: 1000, suffixes: decimalSuffixes, marker: 'd' }
  10114. },
  10115. // general must be before the others because it reuses their characters!
  10116. byteFormatOrder = [ bytes.general, bytes.binary, bytes.decimal ],
  10117. // internal storage for culture config files
  10118. cultures = {},
  10119. // Todo: Remove in 2.0.0
  10120. languages = cultures,
  10121. currentCulture = 'en-US',
  10122. zeroFormat = null,
  10123. defaultFormat = '0,0',
  10124. defaultCurrencyFormat = '0$',
  10125. // check for nodeJS
  10126. hasModule = (typeof module !== 'undefined' && module.exports),
  10127. // default culture
  10128. enUS = {
  10129. delimiters: {
  10130. thousands: ',',
  10131. decimal: '.'
  10132. },
  10133. abbreviations: {
  10134. thousand: 'k',
  10135. million: 'm',
  10136. billion: 'b',
  10137. trillion: 't'
  10138. },
  10139. ordinal: function(number) {
  10140. var b = number % 10;
  10141. return (~~(number % 100 / 10) === 1) ? 'th' :
  10142. (b === 1) ? 'st' :
  10143. (b === 2) ? 'nd' :
  10144. (b === 3) ? 'rd' : 'th';
  10145. },
  10146. currency: {
  10147. symbol: '$',
  10148. position: 'prefix'
  10149. },
  10150. defaults: {
  10151. currencyFormat: ',0000 a'
  10152. },
  10153. formats: {
  10154. fourDigits: '0000 a',
  10155. fullWithTwoDecimals: '$ ,0.00',
  10156. fullWithTwoDecimalsNoCurrency: ',0.00'
  10157. }
  10158. };
  10159. /************************************
  10160. Constructors
  10161. ************************************/
  10162. // Numbro prototype object
  10163. function Numbro(number) {
  10164. this._value = number;
  10165. }
  10166. function numberLength(number) {
  10167. if (number === 0) { return 1; }
  10168. return Math.floor(Math.log(Math.abs(number)) / Math.LN10) + 1;
  10169. }
  10170. function zeroes(count) {
  10171. var i, ret = '';
  10172. for (i = 0; i < count; i++) {
  10173. ret += '0';
  10174. }
  10175. return ret;
  10176. }
  10177. /**
  10178. * Implementation of toFixed() for numbers with exponents
  10179. * This function may return negative representations for zero values e.g. "-0.0"
  10180. */
  10181. function toFixedLargeSmall(value, precision) {
  10182. var mantissa,
  10183. beforeDec,
  10184. afterDec,
  10185. exponent,
  10186. prefix,
  10187. endStr,
  10188. zerosStr,
  10189. str;
  10190. str = value.toString();
  10191. mantissa = str.split('e')[0];
  10192. exponent = str.split('e')[1];
  10193. beforeDec = mantissa.split('.')[0];
  10194. afterDec = mantissa.split('.')[1] || '';
  10195. if (+exponent > 0) {
  10196. // exponent is positive - add zeros after the numbers
  10197. str = beforeDec + afterDec + zeroes(exponent - afterDec.length);
  10198. } else {
  10199. // exponent is negative
  10200. if (+beforeDec < 0) {
  10201. prefix = '-0';
  10202. } else {
  10203. prefix = '0';
  10204. }
  10205. // tack on the decimal point if needed
  10206. if (precision > 0) {
  10207. prefix += '.';
  10208. }
  10209. zerosStr = zeroes((-1 * exponent) - 1);
  10210. // substring off the end to satisfy the precision
  10211. endStr = (zerosStr + Math.abs(beforeDec) + afterDec).substr(0, precision);
  10212. str = prefix + endStr;
  10213. }
  10214. // only add percision 0's if the exponent is positive
  10215. if (+exponent > 0 && precision > 0) {
  10216. str += '.' + zeroes(precision);
  10217. }
  10218. return str;
  10219. }
  10220. /**
  10221. * Implementation of toFixed() that treats floats more like decimals
  10222. *
  10223. * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present
  10224. * problems for accounting- and finance-related software.
  10225. *
  10226. * Also removes negative signs for zero-formatted numbers. e.g. -0.01 w/ precision 1 -> 0.0
  10227. */
  10228. function toFixed(value, precision, roundingFunction, optionals) {
  10229. var power = Math.pow(10, precision),
  10230. optionalsRegExp,
  10231. output;
  10232. if (value.toString().indexOf('e') > -1) {
  10233. // toFixed returns scientific notation for numbers above 1e21 and below 1e-7
  10234. output = toFixedLargeSmall(value, precision);
  10235. // remove the leading negative sign if it exists and should not be present (e.g. -0.00)
  10236. if (output.charAt(0) === '-' && +output >= 0) {
  10237. output = output.substr(1); // chop off the '-'
  10238. }
  10239. }
  10240. else {
  10241. // Multiply up by precision, round accurately, then divide and use native toFixed():
  10242. output = (roundingFunction(value + 'e+' + precision) / power).toFixed(precision);
  10243. }
  10244. if (optionals) {
  10245. optionalsRegExp = new RegExp('0{1,' + optionals + '}$');
  10246. output = output.replace(optionalsRegExp, '');
  10247. }
  10248. return output;
  10249. }
  10250. /************************************
  10251. Formatting
  10252. ************************************/
  10253. // determine what type of formatting we need to do
  10254. function formatNumbro(n, format, roundingFunction) {
  10255. var output,
  10256. escapedFormat = format.replace(/\{[^\{\}]*\}/g, '');
  10257. // figure out what kind of format we are dealing with
  10258. if (escapedFormat.indexOf('$') > -1) { // currency!!!!!
  10259. output = formatCurrency(n, cultures[currentCulture].currency.symbol, format, roundingFunction);
  10260. } else if (escapedFormat.indexOf('%') > -1) { // percentage
  10261. output = formatPercentage(n, format, roundingFunction);
  10262. } else if (escapedFormat.indexOf(':') > -1) { // time
  10263. output = formatTime(n, format);
  10264. } else { // plain ol' numbers or bytes
  10265. output = formatNumber(n._value, format, roundingFunction);
  10266. }
  10267. // return string
  10268. return output;
  10269. }
  10270. // revert to number
  10271. function unformatNumbro(n, string) {
  10272. var stringOriginal = string,
  10273. thousandRegExp,
  10274. millionRegExp,
  10275. billionRegExp,
  10276. trillionRegExp,
  10277. bytesMultiplier = false,
  10278. power;
  10279. if (string.indexOf(':') > -1) {
  10280. n._value = unformatTime(string);
  10281. } else {
  10282. if (string === zeroFormat) {
  10283. n._value = 0;
  10284. } else {
  10285. if (cultures[currentCulture].delimiters.decimal !== '.') {
  10286. string = string.replace(/\./g, '').replace(cultures[currentCulture].delimiters.decimal, '.');
  10287. }
  10288. // see if abbreviations are there so that we can multiply to the correct number
  10289. thousandRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.thousand +
  10290. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  10291. millionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.million +
  10292. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  10293. billionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.billion +
  10294. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  10295. trillionRegExp = new RegExp('[^a-zA-Z]' + cultures[currentCulture].abbreviations.trillion +
  10296. '(?:\\)|(\\' + cultures[currentCulture].currency.symbol + ')?(?:\\))?)?$');
  10297. // see if bytes are there so that we can multiply to the correct number
  10298. for (power = 1; power < binarySuffixes.length && !bytesMultiplier; ++power) {
  10299. if (string.indexOf(binarySuffixes[power]) > -1) {
  10300. bytesMultiplier = Math.pow(1024, power);
  10301. } else if (string.indexOf(decimalSuffixes[power]) > -1) {
  10302. bytesMultiplier = Math.pow(1000, power);
  10303. }
  10304. }
  10305. var str = string.replace(/[^0-9\.]+/g, '');
  10306. if (str === '') {
  10307. // An empty string is not a number.
  10308. n._value = NaN;
  10309. } else {
  10310. // do some math to create our number
  10311. n._value = ((bytesMultiplier) ? bytesMultiplier : 1) *
  10312. ((stringOriginal.match(thousandRegExp)) ? Math.pow(10, 3) : 1) *
  10313. ((stringOriginal.match(millionRegExp)) ? Math.pow(10, 6) : 1) *
  10314. ((stringOriginal.match(billionRegExp)) ? Math.pow(10, 9) : 1) *
  10315. ((stringOriginal.match(trillionRegExp)) ? Math.pow(10, 12) : 1) *
  10316. ((string.indexOf('%') > -1) ? 0.01 : 1) *
  10317. (((string.split('-').length +
  10318. Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2) ? 1 : -1) *
  10319. Number(str);
  10320. // round if we are talking about bytes
  10321. n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value;
  10322. }
  10323. }
  10324. }
  10325. return n._value;
  10326. }
  10327. function formatCurrency(n, currencySymbol, originalFormat, roundingFunction) {
  10328. var format = originalFormat,
  10329. symbolIndex = format.indexOf('$'),
  10330. openParenIndex = format.indexOf('('),
  10331. plusSignIndex = format.indexOf('+'),
  10332. minusSignIndex = format.indexOf('-'),
  10333. space = '',
  10334. decimalSeparator = '',
  10335. spliceIndex,
  10336. output;
  10337. if(format.indexOf('$') === -1){
  10338. // Use defaults instead of the format provided
  10339. if (cultures[currentCulture].currency.position === 'infix') {
  10340. decimalSeparator = currencySymbol;
  10341. if (cultures[currentCulture].currency.spaceSeparated) {
  10342. decimalSeparator = ' ' + decimalSeparator + ' ';
  10343. }
  10344. } else if (cultures[currentCulture].currency.spaceSeparated) {
  10345. space = ' ';
  10346. }
  10347. } else {
  10348. // check for space before or after currency
  10349. if (format.indexOf(' $') > -1) {
  10350. space = ' ';
  10351. format = format.replace(' $', '');
  10352. } else if (format.indexOf('$ ') > -1) {
  10353. space = ' ';
  10354. format = format.replace('$ ', '');
  10355. } else {
  10356. format = format.replace('$', '');
  10357. }
  10358. }
  10359. // Format The Number
  10360. output = formatNumber(n._value, format, roundingFunction, decimalSeparator);
  10361. if (originalFormat.indexOf('$') === -1) {
  10362. // Use defaults instead of the format provided
  10363. switch (cultures[currentCulture].currency.position) {
  10364. case 'postfix':
  10365. if (output.indexOf(')') > -1) {
  10366. output = output.split('');
  10367. output.splice(-1, 0, space + currencySymbol);
  10368. output = output.join('');
  10369. } else {
  10370. output = output + space + currencySymbol;
  10371. }
  10372. break;
  10373. case 'infix':
  10374. break;
  10375. case 'prefix':
  10376. if (output.indexOf('(') > -1 || output.indexOf('-') > -1) {
  10377. output = output.split('');
  10378. spliceIndex = Math.max(openParenIndex, minusSignIndex) + 1;
  10379. output.splice(spliceIndex, 0, currencySymbol + space);
  10380. output = output.join('');
  10381. } else {
  10382. output = currencySymbol + space + output;
  10383. }
  10384. break;
  10385. default:
  10386. throw Error('Currency position should be among ["prefix", "infix", "postfix"]');
  10387. }
  10388. } else {
  10389. // position the symbol
  10390. if (symbolIndex <= 1) {
  10391. if (output.indexOf('(') > -1 || output.indexOf('+') > -1 || output.indexOf('-') > -1) {
  10392. output = output.split('');
  10393. spliceIndex = 1;
  10394. if (symbolIndex < openParenIndex || symbolIndex < plusSignIndex || symbolIndex < minusSignIndex) {
  10395. // the symbol appears before the "(", "+" or "-"
  10396. spliceIndex = 0;
  10397. }
  10398. output.splice(spliceIndex, 0, currencySymbol + space);
  10399. output = output.join('');
  10400. } else {
  10401. output = currencySymbol + space + output;
  10402. }
  10403. } else {
  10404. if (output.indexOf(')') > -1) {
  10405. output = output.split('');
  10406. output.splice(-1, 0, space + currencySymbol);
  10407. output = output.join('');
  10408. } else {
  10409. output = output + space + currencySymbol;
  10410. }
  10411. }
  10412. }
  10413. return output;
  10414. }
  10415. function formatForeignCurrency(n, foreignCurrencySymbol, originalFormat, roundingFunction) {
  10416. return formatCurrency(n, foreignCurrencySymbol, originalFormat, roundingFunction);
  10417. }
  10418. function formatPercentage(n, format, roundingFunction) {
  10419. var space = '',
  10420. output,
  10421. value = n._value * 100;
  10422. // check for space before %
  10423. if (format.indexOf(' %') > -1) {
  10424. space = ' ';
  10425. format = format.replace(' %', '');
  10426. } else {
  10427. format = format.replace('%', '');
  10428. }
  10429. output = formatNumber(value, format, roundingFunction);
  10430. if (output.indexOf(')') > -1) {
  10431. output = output.split('');
  10432. output.splice(-1, 0, space + '%');
  10433. output = output.join('');
  10434. } else {
  10435. output = output + space + '%';
  10436. }
  10437. return output;
  10438. }
  10439. function formatTime(n) {
  10440. var hours = Math.floor(n._value / 60 / 60),
  10441. minutes = Math.floor((n._value - (hours * 60 * 60)) / 60),
  10442. seconds = Math.round(n._value - (hours * 60 * 60) - (minutes * 60));
  10443. return hours + ':' +
  10444. ((minutes < 10) ? '0' + minutes : minutes) + ':' +
  10445. ((seconds < 10) ? '0' + seconds : seconds);
  10446. }
  10447. function unformatTime(string) {
  10448. var timeArray = string.split(':'),
  10449. seconds = 0;
  10450. // turn hours and minutes into seconds and add them all up
  10451. if (timeArray.length === 3) {
  10452. // hours
  10453. seconds = seconds + (Number(timeArray[0]) * 60 * 60);
  10454. // minutes
  10455. seconds = seconds + (Number(timeArray[1]) * 60);
  10456. // seconds
  10457. seconds = seconds + Number(timeArray[2]);
  10458. } else if (timeArray.length === 2) {
  10459. // minutes
  10460. seconds = seconds + (Number(timeArray[0]) * 60);
  10461. // seconds
  10462. seconds = seconds + Number(timeArray[1]);
  10463. }
  10464. return Number(seconds);
  10465. }
  10466. function formatByteUnits (value, suffixes, scale) {
  10467. var suffix = suffixes[0],
  10468. power,
  10469. min,
  10470. max,
  10471. abs = Math.abs(value);
  10472. if (abs >= scale) {
  10473. for (power = 1; power < suffixes.length; ++power) {
  10474. min = Math.pow(scale, power);
  10475. max = Math.pow(scale, power + 1);
  10476. if (abs >= min && abs < max) {
  10477. suffix = suffixes[power];
  10478. value = value / min;
  10479. break;
  10480. }
  10481. }
  10482. // values greater than or equal to [scale] YB never set the suffix
  10483. if (suffix === suffixes[0]) {
  10484. value = value / Math.pow(scale, suffixes.length - 1);
  10485. suffix = suffixes[suffixes.length - 1];
  10486. }
  10487. }
  10488. return { value: value, suffix: suffix };
  10489. }
  10490. function formatNumber (value, format, roundingFunction, sep) {
  10491. var negP = false,
  10492. signed = false,
  10493. optDec = false,
  10494. abbr = '',
  10495. abbrK = false, // force abbreviation to thousands
  10496. abbrM = false, // force abbreviation to millions
  10497. abbrB = false, // force abbreviation to billions
  10498. abbrT = false, // force abbreviation to trillions
  10499. abbrForce = false, // force abbreviation
  10500. bytes = '',
  10501. byteFormat,
  10502. units,
  10503. ord = '',
  10504. abs = Math.abs(value),
  10505. totalLength,
  10506. length,
  10507. minimumPrecision,
  10508. pow,
  10509. w,
  10510. intPrecision,
  10511. precision,
  10512. prefix,
  10513. postfix,
  10514. thousands,
  10515. d = '',
  10516. forcedNeg = false,
  10517. neg = false,
  10518. indexOpenP,
  10519. indexMinus,
  10520. paren = '',
  10521. minlen,
  10522. i;
  10523. // check if number is zero and a custom zero format has been set
  10524. if (value === 0 && zeroFormat !== null) {
  10525. return zeroFormat;
  10526. }
  10527. if (!isFinite(value)) {
  10528. return '' + value;
  10529. }
  10530. if (format.indexOf('{') === 0) {
  10531. var end = format.indexOf('}');
  10532. if (end === -1) {
  10533. throw Error('Format should also contain a "}"');
  10534. }
  10535. prefix = format.slice(1, end);
  10536. format = format.slice(end + 1);
  10537. } else {
  10538. prefix = '';
  10539. }
  10540. if (format.indexOf('}') === format.length - 1 && format.length) {
  10541. var start = format.indexOf('{');
  10542. if (start === -1) {
  10543. throw Error('Format should also contain a "{"');
  10544. }
  10545. postfix = format.slice(start + 1, -1);
  10546. format = format.slice(0, start + 1);
  10547. } else {
  10548. postfix = '';
  10549. }
  10550. // check for min length
  10551. var info;
  10552. if (format.indexOf('.') === -1) {
  10553. info = format.match(/([0-9]+).*/);
  10554. } else {
  10555. info = format.match(/([0-9]+)\..*/);
  10556. }
  10557. minlen = info === null ? -1 : info[1].length;
  10558. // see if we should use parentheses for negative number or if we should prefix with a sign
  10559. // if both are present we default to parentheses
  10560. if (format.indexOf('-') !== -1) {
  10561. forcedNeg = true;
  10562. }
  10563. if (format.indexOf('(') > -1) {
  10564. negP = true;
  10565. format = format.slice(1, -1);
  10566. } else if (format.indexOf('+') > -1) {
  10567. signed = true;
  10568. format = format.replace(/\+/g, '');
  10569. }
  10570. // see if abbreviation is wanted
  10571. if (format.indexOf('a') > -1) {
  10572. intPrecision = format.split('.')[0].match(/[0-9]+/g) || ['0'];
  10573. intPrecision = parseInt(intPrecision[0], 10);
  10574. // check if abbreviation is specified
  10575. abbrK = format.indexOf('aK') >= 0;
  10576. abbrM = format.indexOf('aM') >= 0;
  10577. abbrB = format.indexOf('aB') >= 0;
  10578. abbrT = format.indexOf('aT') >= 0;
  10579. abbrForce = abbrK || abbrM || abbrB || abbrT;
  10580. // check for space before abbreviation
  10581. if (format.indexOf(' a') > -1) {
  10582. abbr = ' ';
  10583. format = format.replace(' a', '');
  10584. } else {
  10585. format = format.replace('a', '');
  10586. }
  10587. totalLength = numberLength(value);
  10588. minimumPrecision = totalLength % 3;
  10589. minimumPrecision = minimumPrecision === 0 ? 3 : minimumPrecision;
  10590. if (intPrecision && abs !== 0) {
  10591. pow = 3 * ~~((Math.min(intPrecision, totalLength) - minimumPrecision) / 3);
  10592. abs = abs / Math.pow(10, pow);
  10593. }
  10594. if (totalLength !== intPrecision) {
  10595. if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) {
  10596. // trillion
  10597. abbr = abbr + cultures[currentCulture].abbreviations.trillion;
  10598. value = value / Math.pow(10, 12);
  10599. } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) {
  10600. // billion
  10601. abbr = abbr + cultures[currentCulture].abbreviations.billion;
  10602. value = value / Math.pow(10, 9);
  10603. } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) {
  10604. // million
  10605. abbr = abbr + cultures[currentCulture].abbreviations.million;
  10606. value = value / Math.pow(10, 6);
  10607. } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) {
  10608. // thousand
  10609. abbr = abbr + cultures[currentCulture].abbreviations.thousand;
  10610. value = value / Math.pow(10, 3);
  10611. }
  10612. }
  10613. length = numberLength(value);
  10614. if (intPrecision && length < intPrecision && format.indexOf('.') === -1) {
  10615. format += '[.]';
  10616. format += zeroes(intPrecision - length);
  10617. }
  10618. }
  10619. // see if we are formatting
  10620. // binary-decimal bytes (1024 MB), binary bytes (1024 MiB), or decimal bytes (1000 MB)
  10621. for (i = 0; i < byteFormatOrder.length; ++i) {
  10622. byteFormat = byteFormatOrder[i];
  10623. if (format.indexOf(byteFormat.marker) > -1) {
  10624. // check for space before
  10625. if (format.indexOf(' ' + byteFormat.marker) >-1) {
  10626. bytes = ' ';
  10627. }
  10628. // remove the marker (with the space if it had one)
  10629. format = format.replace(bytes + byteFormat.marker, '');
  10630. units = formatByteUnits(value, byteFormat.suffixes, byteFormat.scale);
  10631. value = units.value;
  10632. bytes = bytes + units.suffix;
  10633. break;
  10634. }
  10635. }
  10636. // see if ordinal is wanted
  10637. if (format.indexOf('o') > -1) {
  10638. // check for space before
  10639. if (format.indexOf(' o') > -1) {
  10640. ord = ' ';
  10641. format = format.replace(' o', '');
  10642. } else {
  10643. format = format.replace('o', '');
  10644. }
  10645. if (cultures[currentCulture].ordinal) {
  10646. ord = ord + cultures[currentCulture].ordinal(value);
  10647. }
  10648. }
  10649. if (format.indexOf('[.]') > -1) {
  10650. optDec = true;
  10651. format = format.replace('[.]', '.');
  10652. }
  10653. precision = format.split('.')[1];
  10654. thousands = format.indexOf(',');
  10655. if (precision) {
  10656. var dSplit = [];
  10657. if (precision.indexOf('*') !== -1) {
  10658. d = value.toString();
  10659. dSplit = d.split('.');
  10660. if (dSplit.length > 1) {
  10661. d = toFixed(value, dSplit[1].length, roundingFunction);
  10662. }
  10663. } else {
  10664. if (precision.indexOf('[') > -1) {
  10665. precision = precision.replace(']', '');
  10666. precision = precision.split('[');
  10667. d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction,
  10668. precision[1].length);
  10669. } else {
  10670. d = toFixed(value, precision.length, roundingFunction);
  10671. }
  10672. }
  10673. dSplit = d.split('.');
  10674. w = dSplit[0];
  10675. if (dSplit.length > 1 && dSplit[1].length) {
  10676. var p = sep ? abbr + sep : cultures[currentCulture].delimiters.decimal;
  10677. d = p + dSplit[1];
  10678. } else {
  10679. d = '';
  10680. }
  10681. if (optDec && Number(d.slice(1)) === 0) {
  10682. d = '';
  10683. }
  10684. } else {
  10685. w = toFixed(value, 0, roundingFunction);
  10686. }
  10687. // format number
  10688. if (w.indexOf('-') > -1) {
  10689. w = w.slice(1);
  10690. neg = true;
  10691. }
  10692. if (w.length < minlen) {
  10693. w = zeroes(minlen - w.length) + w;
  10694. }
  10695. if (thousands > -1) {
  10696. w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' +
  10697. cultures[currentCulture].delimiters.thousands);
  10698. }
  10699. if (format.indexOf('.') === 0) {
  10700. w = '';
  10701. }
  10702. indexOpenP = format.indexOf('(');
  10703. indexMinus = format.indexOf('-');
  10704. if (indexOpenP < indexMinus) {
  10705. paren = ((negP && neg) ? '(' : '') + (((forcedNeg && neg) || (!negP && neg)) ? '-' : '');
  10706. } else {
  10707. paren = (((forcedNeg && neg) || (!negP && neg)) ? '-' : '') + ((negP && neg) ? '(' : '');
  10708. }
  10709. return prefix +
  10710. paren + ((!neg && signed && value !== 0) ? '+' : '') +
  10711. w + d +
  10712. ((ord) ? ord : '') +
  10713. ((abbr && !sep) ? abbr : '') +
  10714. ((bytes) ? bytes : '') +
  10715. ((negP && neg) ? ')' : '') +
  10716. postfix;
  10717. }
  10718. /************************************
  10719. Top Level Functions
  10720. ************************************/
  10721. numbro = function(input) {
  10722. if (numbro.isNumbro(input)) {
  10723. input = input.value();
  10724. } else if (typeof input === 'string' || typeof input === 'number') {
  10725. input = numbro.fn.unformat(input);
  10726. } else {
  10727. input = NaN;
  10728. }
  10729. return new Numbro(Number(input));
  10730. };
  10731. // version number
  10732. numbro.version = VERSION;
  10733. // compare numbro object
  10734. numbro.isNumbro = function(obj) {
  10735. return obj instanceof Numbro;
  10736. };
  10737. /**
  10738. * This function allow the user to set a new language with a fallback if
  10739. * the language does not exist. If no fallback language is provided,
  10740. * it fallbacks to english.
  10741. *
  10742. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  10743. * `setCulture` should be used instead.
  10744. */
  10745. numbro.setLanguage = function(newLanguage, fallbackLanguage) {
  10746. console.warn('`setLanguage` is deprecated since version 1.6.0. Use `setCulture` instead');
  10747. var key = newLanguage,
  10748. prefix = newLanguage.split('-')[0],
  10749. matchingLanguage = null;
  10750. if (!languages[key]) {
  10751. Object.keys(languages).forEach(function(language) {
  10752. if (!matchingLanguage && language.split('-')[0] === prefix) {
  10753. matchingLanguage = language;
  10754. }
  10755. });
  10756. key = matchingLanguage || fallbackLanguage || 'en-US';
  10757. }
  10758. chooseCulture(key);
  10759. };
  10760. /**
  10761. * This function allow the user to set a new culture with a fallback if
  10762. * the culture does not exist. If no fallback culture is provided,
  10763. * it falls back to "en-US".
  10764. */
  10765. numbro.setCulture = function(newCulture, fallbackCulture) {
  10766. var key = newCulture,
  10767. suffix = newCulture.split('-')[1],
  10768. matchingCulture = null;
  10769. if (!cultures[key]) {
  10770. if (suffix) {
  10771. Object.keys(cultures).forEach(function(language) {
  10772. if (!matchingCulture && language.split('-')[1] === suffix) {
  10773. matchingCulture = language;
  10774. }
  10775. });
  10776. }
  10777. key = matchingCulture || fallbackCulture || 'en-US';
  10778. }
  10779. chooseCulture(key);
  10780. };
  10781. /**
  10782. * This function will load languages and then set the global language. If
  10783. * no arguments are passed in, it will simply return the current global
  10784. * language key.
  10785. *
  10786. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  10787. * `culture` should be used instead.
  10788. */
  10789. numbro.language = function(key, values) {
  10790. console.warn('`language` is deprecated since version 1.6.0. Use `culture` instead');
  10791. if (!key) {
  10792. return currentCulture;
  10793. }
  10794. if (key && !values) {
  10795. if (!languages[key]) {
  10796. throw new Error('Unknown language : ' + key);
  10797. }
  10798. chooseCulture(key);
  10799. }
  10800. if (values || !languages[key]) {
  10801. setCulture(key, values);
  10802. }
  10803. return numbro;
  10804. };
  10805. /**
  10806. * This function will load cultures and then set the global culture. If
  10807. * no arguments are passed in, it will simply return the current global
  10808. * culture code.
  10809. */
  10810. numbro.culture = function(code, values) {
  10811. if (!code) {
  10812. return currentCulture;
  10813. }
  10814. if (code && !values) {
  10815. if (!cultures[code]) {
  10816. throw new Error('Unknown culture : ' + code);
  10817. }
  10818. chooseCulture(code);
  10819. }
  10820. if (values || !cultures[code]) {
  10821. setCulture(code, values);
  10822. }
  10823. return numbro;
  10824. };
  10825. /**
  10826. * This function provides access to the loaded language data. If
  10827. * no arguments are passed in, it will simply return the current
  10828. * global language object.
  10829. *
  10830. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  10831. * `culture` should be used instead.
  10832. */
  10833. numbro.languageData = function(key) {
  10834. console.warn('`languageData` is deprecated since version 1.6.0. Use `cultureData` instead');
  10835. if (!key) {
  10836. return languages[currentCulture];
  10837. }
  10838. if (!languages[key]) {
  10839. throw new Error('Unknown language : ' + key);
  10840. }
  10841. return languages[key];
  10842. };
  10843. /**
  10844. * This function provides access to the loaded culture data. If
  10845. * no arguments are passed in, it will simply return the current
  10846. * global culture object.
  10847. */
  10848. numbro.cultureData = function(code) {
  10849. if (!code) {
  10850. return cultures[currentCulture];
  10851. }
  10852. if (!cultures[code]) {
  10853. throw new Error('Unknown culture : ' + code);
  10854. }
  10855. return cultures[code];
  10856. };
  10857. numbro.culture('en-US', enUS);
  10858. /**
  10859. * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  10860. * `cultures` should be used instead.
  10861. */
  10862. numbro.languages = function() {
  10863. console.warn('`languages` is deprecated since version 1.6.0. Use `cultures` instead');
  10864. return languages;
  10865. };
  10866. numbro.cultures = function() {
  10867. return cultures;
  10868. };
  10869. numbro.zeroFormat = function(format) {
  10870. zeroFormat = typeof(format) === 'string' ? format : null;
  10871. };
  10872. numbro.defaultFormat = function(format) {
  10873. defaultFormat = typeof(format) === 'string' ? format : '0.0';
  10874. };
  10875. numbro.defaultCurrencyFormat = function (format) {
  10876. defaultCurrencyFormat = typeof(format) === 'string' ? format : '0$';
  10877. };
  10878. numbro.validate = function(val, culture) {
  10879. var _decimalSep,
  10880. _thousandSep,
  10881. _currSymbol,
  10882. _valArray,
  10883. _abbrObj,
  10884. _thousandRegEx,
  10885. cultureData,
  10886. temp;
  10887. //coerce val to string
  10888. if (typeof val !== 'string') {
  10889. val += '';
  10890. if (console.warn) {
  10891. console.warn('Numbro.js: Value is not string. It has been co-erced to: ', val);
  10892. }
  10893. }
  10894. //trim whitespaces from either sides
  10895. val = val.trim();
  10896. //replace the initial '+' or '-' sign if present
  10897. val = val.replace(/^[+-]?/, '');
  10898. //if val is just digits return true
  10899. if ( !! val.match(/^\d+$/)) {
  10900. return true;
  10901. }
  10902. //if val is empty return false
  10903. if (val === '') {
  10904. return false;
  10905. }
  10906. //get the decimal and thousands separator from numbro.cultureData
  10907. try {
  10908. //check if the culture is understood by numbro. if not, default it to current culture
  10909. cultureData = numbro.cultureData(culture);
  10910. } catch (e) {
  10911. cultureData = numbro.cultureData(numbro.culture());
  10912. }
  10913. //setup the delimiters and currency symbol based on culture
  10914. _currSymbol = cultureData.currency.symbol;
  10915. _abbrObj = cultureData.abbreviations;
  10916. _decimalSep = cultureData.delimiters.decimal;
  10917. if (cultureData.delimiters.thousands === '.') {
  10918. _thousandSep = '\\.';
  10919. } else {
  10920. _thousandSep = cultureData.delimiters.thousands;
  10921. }
  10922. // validating currency symbol
  10923. temp = val.match(/^[^\d\.\,]+/);
  10924. if (temp !== null) {
  10925. val = val.substr(1);
  10926. if (temp[0] !== _currSymbol) {
  10927. return false;
  10928. }
  10929. }
  10930. //validating abbreviation symbol
  10931. temp = val.match(/[^\d]+$/);
  10932. if (temp !== null) {
  10933. val = val.slice(0, -1);
  10934. if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million &&
  10935. temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) {
  10936. return false;
  10937. }
  10938. }
  10939. _thousandRegEx = new RegExp(_thousandSep + '{2}');
  10940. if (!val.match(/[^\d.,]/g)) {
  10941. _valArray = val.split(_decimalSep);
  10942. if (_valArray.length > 2) {
  10943. return false;
  10944. } else {
  10945. if (_valArray.length < 2) {
  10946. return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx));
  10947. } else {
  10948. if (_valArray[0] === '') {
  10949. // for values without leading zero eg. .984
  10950. return (!_valArray[0].match(_thousandRegEx) &&
  10951. !!_valArray[1].match(/^\d+$/));
  10952. } else if (_valArray[0].length === 1) {
  10953. return ( !! _valArray[0].match(/^\d+$/) &&
  10954. !_valArray[0].match(_thousandRegEx) &&
  10955. !! _valArray[1].match(/^\d+$/));
  10956. } else {
  10957. return ( !! _valArray[0].match(/^\d+.*\d$/) &&
  10958. !_valArray[0].match(_thousandRegEx) &&
  10959. !! _valArray[1].match(/^\d+$/));
  10960. }
  10961. }
  10962. }
  10963. }
  10964. return false;
  10965. };
  10966. /**
  10967. * * @deprecated Since in version 1.6.0. It will be deleted in version 2.0
  10968. * `loadCulturesInNode` should be used instead.
  10969. */
  10970. numbro.loadLanguagesInNode = function() {
  10971. console.warn('`loadLanguagesInNode` is deprecated since version 1.6.0. Use `loadCulturesInNode` instead');
  10972. numbro.loadCulturesInNode();
  10973. };
  10974. numbro.loadCulturesInNode = function() {
  10975. // TODO: Rename the folder in 2.0.0
  10976. var cultures = __webpack_require__(297);
  10977. for(var langLocaleCode in cultures) {
  10978. if(langLocaleCode) {
  10979. numbro.culture(langLocaleCode, cultures[langLocaleCode]);
  10980. }
  10981. }
  10982. };
  10983. /************************************
  10984. Helpers
  10985. ************************************/
  10986. function setCulture(code, values) {
  10987. cultures[code] = values;
  10988. }
  10989. function chooseCulture(code) {
  10990. currentCulture = code;
  10991. var defaults = cultures[code].defaults;
  10992. if (defaults && defaults.format) {
  10993. numbro.defaultFormat(defaults.format);
  10994. }
  10995. if (defaults && defaults.currencyFormat) {
  10996. numbro.defaultCurrencyFormat(defaults.currencyFormat);
  10997. }
  10998. }
  10999. function inNodejsRuntime() {
  11000. return (typeof process !== 'undefined') &&
  11001. (process.browser === undefined) &&
  11002. process.title &&
  11003. (
  11004. process.title.indexOf('node') !== -1 ||
  11005. process.title.indexOf('meteor-tool') > 0 ||
  11006. process.title === 'grunt' ||
  11007. process.title === 'gulp'
  11008. ) &&
  11009. ("function" !== 'undefined');
  11010. }
  11011. /************************************
  11012. Floating-point helpers
  11013. ************************************/
  11014. // The floating-point helper functions and implementation
  11015. // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/
  11016. /**
  11017. * Array.prototype.reduce for browsers that don't support it
  11018. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce#Compatibility
  11019. */
  11020. if ('function' !== typeof Array.prototype.reduce) {
  11021. Array.prototype.reduce = function(callback, optInitialValue) {
  11022. if (null === this || 'undefined' === typeof this) {
  11023. // At the moment all modern browsers, that support strict mode, have
  11024. // native implementation of Array.prototype.reduce. For instance, IE8
  11025. // does not support strict mode, so this check is actually useless.
  11026. throw new TypeError('Array.prototype.reduce called on null or undefined');
  11027. }
  11028. if ('function' !== typeof callback) {
  11029. throw new TypeError(callback + ' is not a function');
  11030. }
  11031. var index,
  11032. value,
  11033. length = this.length >>> 0,
  11034. isValueSet = false;
  11035. if (1 < arguments.length) {
  11036. value = optInitialValue;
  11037. isValueSet = true;
  11038. }
  11039. for (index = 0; length > index; ++index) {
  11040. if (this.hasOwnProperty(index)) {
  11041. if (isValueSet) {
  11042. value = callback(value, this[index], index, this);
  11043. } else {
  11044. value = this[index];
  11045. isValueSet = true;
  11046. }
  11047. }
  11048. }
  11049. if (!isValueSet) {
  11050. throw new TypeError('Reduce of empty array with no initial value');
  11051. }
  11052. return value;
  11053. };
  11054. }
  11055. /**
  11056. * Computes the multiplier necessary to make x >= 1,
  11057. * effectively eliminating miscalculations caused by
  11058. * finite precision.
  11059. */
  11060. function multiplier(x) {
  11061. var parts = x.toString().split('.');
  11062. if (parts.length < 2) {
  11063. return 1;
  11064. }
  11065. return Math.pow(10, parts[1].length);
  11066. }
  11067. /**
  11068. * Given a variable number of arguments, returns the maximum
  11069. * multiplier that must be used to normalize an operation involving
  11070. * all of them.
  11071. */
  11072. function correctionFactor() {
  11073. var args = Array.prototype.slice.call(arguments);
  11074. return args.reduce(function(prev, next) {
  11075. var mp = multiplier(prev),
  11076. mn = multiplier(next);
  11077. return mp > mn ? mp : mn;
  11078. }, -Infinity);
  11079. }
  11080. /************************************
  11081. Numbro Prototype
  11082. ************************************/
  11083. numbro.fn = Numbro.prototype = {
  11084. clone: function() {
  11085. return numbro(this);
  11086. },
  11087. format: function(inputString, roundingFunction) {
  11088. return formatNumbro(this,
  11089. inputString ? inputString : defaultFormat,
  11090. (roundingFunction !== undefined) ? roundingFunction : Math.round
  11091. );
  11092. },
  11093. formatCurrency: function(inputString, roundingFunction) {
  11094. return formatCurrency(this,
  11095. cultures[currentCulture].currency.symbol,
  11096. inputString ? inputString : defaultCurrencyFormat,
  11097. (roundingFunction !== undefined) ? roundingFunction : Math.round
  11098. );
  11099. },
  11100. formatForeignCurrency: function(currencySymbol, inputString, roundingFunction) {
  11101. return formatForeignCurrency(this,
  11102. currencySymbol,
  11103. inputString ? inputString : defaultCurrencyFormat,
  11104. (roundingFunction !== undefined) ? roundingFunction : Math.round
  11105. );
  11106. },
  11107. unformat: function(inputString) {
  11108. if (typeof inputString === 'number') {
  11109. return inputString;
  11110. } else if (typeof inputString === 'string') {
  11111. var result = unformatNumbro(this, inputString);
  11112. // Any unparseable string (represented as NaN in the result) is
  11113. // converted into undefined.
  11114. return isNaN(result) ? undefined : result;
  11115. } else {
  11116. return undefined;
  11117. }
  11118. },
  11119. binaryByteUnits: function() {
  11120. return formatByteUnits(this._value, bytes.binary.suffixes, bytes.binary.scale).suffix;
  11121. },
  11122. byteUnits: function() {
  11123. return formatByteUnits(this._value, bytes.general.suffixes, bytes.general.scale).suffix;
  11124. },
  11125. decimalByteUnits: function() {
  11126. return formatByteUnits(this._value, bytes.decimal.suffixes, bytes.decimal.scale).suffix;
  11127. },
  11128. value: function() {
  11129. return this._value;
  11130. },
  11131. valueOf: function() {
  11132. return this._value;
  11133. },
  11134. set: function(value) {
  11135. this._value = Number(value);
  11136. return this;
  11137. },
  11138. add: function(value) {
  11139. var corrFactor = correctionFactor.call(null, this._value, value);
  11140. function cback(accum, curr) {
  11141. return accum + corrFactor * curr;
  11142. }
  11143. this._value = [this._value, value].reduce(cback, 0) / corrFactor;
  11144. return this;
  11145. },
  11146. subtract: function(value) {
  11147. var corrFactor = correctionFactor.call(null, this._value, value);
  11148. function cback(accum, curr) {
  11149. return accum - corrFactor * curr;
  11150. }
  11151. this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor;
  11152. return this;
  11153. },
  11154. multiply: function(value) {
  11155. function cback(accum, curr) {
  11156. var corrFactor = correctionFactor(accum, curr),
  11157. result = accum * corrFactor;
  11158. result *= curr * corrFactor;
  11159. result /= corrFactor * corrFactor;
  11160. return result;
  11161. }
  11162. this._value = [this._value, value].reduce(cback, 1);
  11163. return this;
  11164. },
  11165. divide: function(value) {
  11166. function cback(accum, curr) {
  11167. var corrFactor = correctionFactor(accum, curr);
  11168. return (accum * corrFactor) / (curr * corrFactor);
  11169. }
  11170. this._value = [this._value, value].reduce(cback);
  11171. return this;
  11172. },
  11173. difference: function(value) {
  11174. return Math.abs(numbro(this._value).subtract(value).value());
  11175. }
  11176. };
  11177. /************************************
  11178. Exposing Numbro
  11179. ************************************/
  11180. if (inNodejsRuntime()) {
  11181. //Todo: Rename the folder in 2.0.0
  11182. numbro.loadCulturesInNode();
  11183. }
  11184. // CommonJS module is defined
  11185. if (hasModule) {
  11186. module.exports = numbro;
  11187. } else {
  11188. /*global ender:false */
  11189. if (typeof ender === 'undefined') {
  11190. // here, `this` means `window` in the browser, or `global` on the server
  11191. // add `numbro` as a global object via a string identifier,
  11192. // for Closure Compiler 'advanced' mode
  11193. this.numbro = numbro;
  11194. }
  11195. /*global define:false */
  11196. if (true) {
  11197. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
  11198. return numbro;
  11199. }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  11200. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  11201. }
  11202. }
  11203. }.call(typeof window === 'undefined' ? this : window));
  11204. /*** EXPORTS FROM exports-to-window-loader ***/
  11205. window['numbro'] = __webpack_require__(51);
  11206. /***/ }),
  11207. /* 52 */
  11208. /***/ (function(module, exports, __webpack_require__) {
  11209. "use strict";
  11210. exports.__esModule = true;
  11211. exports.default = staticRegister;
  11212. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  11213. var collection = exports.collection = new Map();
  11214. function staticRegister() {
  11215. var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'common';
  11216. if (!collection.has(namespace)) {
  11217. collection.set(namespace, new Map());
  11218. }
  11219. var subCollection = collection.get(namespace);
  11220. /**
  11221. * Register an item to the collection. If the item under the same was exist earlier then this item will be replaced with new one.
  11222. *
  11223. * @param {String} name Identification of the item.
  11224. * @param {*} item Item to save in the collection.
  11225. */
  11226. function register(name, item) {
  11227. subCollection.set(name, item);
  11228. }
  11229. /**
  11230. * Retrieve the item from the collection.
  11231. *
  11232. * @param {String} name Identification of the item.
  11233. * @returns {*} Returns item which was saved in the collection.
  11234. */
  11235. function getItem(name) {
  11236. return subCollection.get(name);
  11237. }
  11238. /**
  11239. * Check if item under specyfied name is exists.
  11240. *
  11241. * @param {String} name Identification of the item.
  11242. * @returns {Boolean} Returns `true` or `false` depends on if element exists in the collection.
  11243. */
  11244. function hasItem(name) {
  11245. return subCollection.has(name);
  11246. }
  11247. /**
  11248. * Retrieve list of names registered from the collection.
  11249. *
  11250. * @returns {Array} Returns an array of strings with all names under which objects are stored.
  11251. */
  11252. function getNames() {
  11253. return [].concat(_toConsumableArray(subCollection.keys()));
  11254. }
  11255. /**
  11256. * Retrieve all registered values from the collection.
  11257. *
  11258. * @returns {Array} Returns an array with all values stored in the collection.
  11259. */
  11260. function getValues() {
  11261. return [].concat(_toConsumableArray(subCollection.values()));
  11262. }
  11263. return {
  11264. register: register,
  11265. getItem: getItem,
  11266. hasItem: hasItem,
  11267. getNames: getNames,
  11268. getValues: getValues
  11269. };
  11270. }
  11271. /***/ }),
  11272. /* 53 */
  11273. /***/ (function(module, exports) {
  11274. module.exports = function(it, Constructor, name, forbiddenField){
  11275. if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){
  11276. throw TypeError(name + ': incorrect invocation!');
  11277. } return it;
  11278. };
  11279. /***/ }),
  11280. /* 54 */
  11281. /***/ (function(module, exports, __webpack_require__) {
  11282. // 0 -> Array#forEach
  11283. // 1 -> Array#map
  11284. // 2 -> Array#filter
  11285. // 3 -> Array#some
  11286. // 4 -> Array#every
  11287. // 5 -> Array#find
  11288. // 6 -> Array#findIndex
  11289. var ctx = __webpack_require__(29)
  11290. , IObject = __webpack_require__(78)
  11291. , toObject = __webpack_require__(42)
  11292. , toLength = __webpack_require__(24)
  11293. , asc = __webpack_require__(395);
  11294. module.exports = function(TYPE, $create){
  11295. var IS_MAP = TYPE == 1
  11296. , IS_FILTER = TYPE == 2
  11297. , IS_SOME = TYPE == 3
  11298. , IS_EVERY = TYPE == 4
  11299. , IS_FIND_INDEX = TYPE == 6
  11300. , NO_HOLES = TYPE == 5 || IS_FIND_INDEX
  11301. , create = $create || asc;
  11302. return function($this, callbackfn, that){
  11303. var O = toObject($this)
  11304. , self = IObject(O)
  11305. , f = ctx(callbackfn, that, 3)
  11306. , length = toLength(self.length)
  11307. , index = 0
  11308. , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined
  11309. , val, res;
  11310. for(;length > index; index++)if(NO_HOLES || index in self){
  11311. val = self[index];
  11312. res = f(val, index, O);
  11313. if(TYPE){
  11314. if(IS_MAP)result[index] = res; // map
  11315. else if(res)switch(TYPE){
  11316. case 3: return true; // some
  11317. case 5: return val; // find
  11318. case 6: return index; // findIndex
  11319. case 2: result.push(val); // filter
  11320. } else if(IS_EVERY)return false; // every
  11321. }
  11322. }
  11323. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  11324. };
  11325. };
  11326. /***/ }),
  11327. /* 55 */
  11328. /***/ (function(module, exports, __webpack_require__) {
  11329. "use strict";
  11330. var global = __webpack_require__(13)
  11331. , $export = __webpack_require__(3)
  11332. , redefine = __webpack_require__(33)
  11333. , redefineAll = __webpack_require__(60)
  11334. , meta = __webpack_require__(47)
  11335. , forOf = __webpack_require__(57)
  11336. , anInstance = __webpack_require__(53)
  11337. , isObject = __webpack_require__(15)
  11338. , fails = __webpack_require__(31)
  11339. , $iterDetect = __webpack_require__(79)
  11340. , setToStringTag = __webpack_require__(49)
  11341. , inheritIfRequired = __webpack_require__(398);
  11342. module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
  11343. var Base = global[NAME]
  11344. , C = Base
  11345. , ADDER = IS_MAP ? 'set' : 'add'
  11346. , proto = C && C.prototype
  11347. , O = {};
  11348. var fixMethod = function(KEY){
  11349. var fn = proto[KEY];
  11350. redefine(proto, KEY,
  11351. KEY == 'delete' ? function(a){
  11352. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  11353. } : KEY == 'has' ? function has(a){
  11354. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  11355. } : KEY == 'get' ? function get(a){
  11356. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  11357. } : KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; }
  11358. : function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; }
  11359. );
  11360. };
  11361. if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function(){
  11362. new C().entries().next();
  11363. }))){
  11364. // create collection constructor
  11365. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  11366. redefineAll(C.prototype, methods);
  11367. meta.NEED = true;
  11368. } else {
  11369. var instance = new C
  11370. // early implementations not supports chaining
  11371. , HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance
  11372. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  11373. , THROWS_ON_PRIMITIVES = fails(function(){ instance.has(1); })
  11374. // most early implementations doesn't supports iterables, most modern - not close it correctly
  11375. , ACCEPT_ITERABLES = $iterDetect(function(iter){ new C(iter); }) // eslint-disable-line no-new
  11376. // for early implementations -0 and +0 not the same
  11377. , BUGGY_ZERO = !IS_WEAK && fails(function(){
  11378. // V8 ~ Chromium 42- fails only with 5+ elements
  11379. var $instance = new C()
  11380. , index = 5;
  11381. while(index--)$instance[ADDER](index, index);
  11382. return !$instance.has(-0);
  11383. });
  11384. if(!ACCEPT_ITERABLES){
  11385. C = wrapper(function(target, iterable){
  11386. anInstance(target, C, NAME);
  11387. var that = inheritIfRequired(new Base, target, C);
  11388. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  11389. return that;
  11390. });
  11391. C.prototype = proto;
  11392. proto.constructor = C;
  11393. }
  11394. if(THROWS_ON_PRIMITIVES || BUGGY_ZERO){
  11395. fixMethod('delete');
  11396. fixMethod('has');
  11397. IS_MAP && fixMethod('get');
  11398. }
  11399. if(BUGGY_ZERO || HASNT_CHAINING)fixMethod(ADDER);
  11400. // weak collections should not contains .clear method
  11401. if(IS_WEAK && proto.clear)delete proto.clear;
  11402. }
  11403. setToStringTag(C, NAME);
  11404. O[NAME] = C;
  11405. $export($export.G + $export.W + $export.F * (C != Base), O);
  11406. if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP);
  11407. return C;
  11408. };
  11409. /***/ }),
  11410. /* 56 */
  11411. /***/ (function(module, exports, __webpack_require__) {
  11412. "use strict";
  11413. var hide = __webpack_require__(32)
  11414. , redefine = __webpack_require__(33)
  11415. , fails = __webpack_require__(31)
  11416. , defined = __webpack_require__(30)
  11417. , wks = __webpack_require__(10);
  11418. module.exports = function(KEY, length, exec){
  11419. var SYMBOL = wks(KEY)
  11420. , fns = exec(defined, SYMBOL, ''[KEY])
  11421. , strfn = fns[0]
  11422. , rxfn = fns[1];
  11423. if(fails(function(){
  11424. var O = {};
  11425. O[SYMBOL] = function(){ return 7; };
  11426. return ''[KEY](O) != 7;
  11427. })){
  11428. redefine(String.prototype, KEY, strfn);
  11429. hide(RegExp.prototype, SYMBOL, length == 2
  11430. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  11431. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  11432. ? function(string, arg){ return rxfn.call(string, this, arg); }
  11433. // 21.2.5.6 RegExp.prototype[@@match](string)
  11434. // 21.2.5.9 RegExp.prototype[@@search](string)
  11435. : function(string){ return rxfn.call(string, this); }
  11436. );
  11437. }
  11438. };
  11439. /***/ }),
  11440. /* 57 */
  11441. /***/ (function(module, exports, __webpack_require__) {
  11442. var ctx = __webpack_require__(29)
  11443. , call = __webpack_require__(280)
  11444. , isArrayIter = __webpack_require__(276)
  11445. , anObject = __webpack_require__(18)
  11446. , toLength = __webpack_require__(24)
  11447. , getIterFn = __webpack_require__(291)
  11448. , BREAK = {}
  11449. , RETURN = {};
  11450. var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){
  11451. var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable)
  11452. , f = ctx(fn, that, entries ? 2 : 1)
  11453. , index = 0
  11454. , length, step, iterator, result;
  11455. if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
  11456. // fast case for arrays with default iterator
  11457. if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
  11458. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  11459. if(result === BREAK || result === RETURN)return result;
  11460. } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
  11461. result = call(iterator, f, step.value, entries);
  11462. if(result === BREAK || result === RETURN)return result;
  11463. }
  11464. };
  11465. exports.BREAK = BREAK;
  11466. exports.RETURN = RETURN;
  11467. /***/ }),
  11468. /* 58 */
  11469. /***/ (function(module, exports) {
  11470. module.exports = false;
  11471. /***/ }),
  11472. /* 59 */
  11473. /***/ (function(module, exports) {
  11474. exports.f = Object.getOwnPropertySymbols;
  11475. /***/ }),
  11476. /* 60 */
  11477. /***/ (function(module, exports, __webpack_require__) {
  11478. var redefine = __webpack_require__(33);
  11479. module.exports = function(target, src, safe){
  11480. for(var key in src)redefine(target, key, src[key], safe);
  11481. return target;
  11482. };
  11483. /***/ }),
  11484. /* 61 */
  11485. /***/ (function(module, exports, __webpack_require__) {
  11486. var toInteger = __webpack_require__(62)
  11487. , max = Math.max
  11488. , min = Math.min;
  11489. module.exports = function(index, length){
  11490. index = toInteger(index);
  11491. return index < 0 ? max(index + length, 0) : min(index, length);
  11492. };
  11493. /***/ }),
  11494. /* 62 */
  11495. /***/ (function(module, exports) {
  11496. // 7.1.4 ToInteger
  11497. var ceil = Math.ceil
  11498. , floor = Math.floor;
  11499. module.exports = function(it){
  11500. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  11501. };
  11502. /***/ }),
  11503. /* 63 */
  11504. /***/ (function(module, exports, __webpack_require__) {
  11505. "use strict";
  11506. exports.__esModule = true;
  11507. exports.getRegisteredCellTypes = exports.getRegisteredCellTypeNames = exports.hasCellType = exports.getCellType = exports.registerCellType = undefined;
  11508. var _staticRegister2 = __webpack_require__(52);
  11509. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  11510. var _editors = __webpack_require__(14);
  11511. var _renderers = __webpack_require__(9);
  11512. var _validators = __webpack_require__(26);
  11513. var _autocompleteType = __webpack_require__(304);
  11514. var _autocompleteType2 = _interopRequireDefault(_autocompleteType);
  11515. var _checkboxType = __webpack_require__(305);
  11516. var _checkboxType2 = _interopRequireDefault(_checkboxType);
  11517. var _dateType = __webpack_require__(306);
  11518. var _dateType2 = _interopRequireDefault(_dateType);
  11519. var _dropdownType = __webpack_require__(307);
  11520. var _dropdownType2 = _interopRequireDefault(_dropdownType);
  11521. var _handsontableType = __webpack_require__(308);
  11522. var _handsontableType2 = _interopRequireDefault(_handsontableType);
  11523. var _numericType = __webpack_require__(309);
  11524. var _numericType2 = _interopRequireDefault(_numericType);
  11525. var _passwordType = __webpack_require__(310);
  11526. var _passwordType2 = _interopRequireDefault(_passwordType);
  11527. var _textType = __webpack_require__(311);
  11528. var _textType2 = _interopRequireDefault(_textType);
  11529. var _timeType = __webpack_require__(312);
  11530. var _timeType2 = _interopRequireDefault(_timeType);
  11531. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11532. var _staticRegister = (0, _staticRegister3.default)('cellTypes'),
  11533. register = _staticRegister.register,
  11534. getItem = _staticRegister.getItem,
  11535. hasItem = _staticRegister.hasItem,
  11536. getNames = _staticRegister.getNames,
  11537. getValues = _staticRegister.getValues;
  11538. _register('autocomplete', _autocompleteType2.default);
  11539. _register('checkbox', _checkboxType2.default);
  11540. _register('date', _dateType2.default);
  11541. _register('dropdown', _dropdownType2.default);
  11542. _register('handsontable', _handsontableType2.default);
  11543. _register('numeric', _numericType2.default);
  11544. _register('password', _passwordType2.default);
  11545. _register('text', _textType2.default);
  11546. _register('time', _timeType2.default);
  11547. /**
  11548. * Retrieve cell type object.
  11549. *
  11550. * @param {String} name Cell type identification.
  11551. * @returns {Object} Returns cell type object.
  11552. */
  11553. function _getItem(name) {
  11554. if (!hasItem(name)) {
  11555. 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');
  11556. }
  11557. return getItem(name);
  11558. }
  11559. /**
  11560. * Register cell type under specified name.
  11561. *
  11562. * @param {String} name Cell type identification.
  11563. * @param {Object} type An object with contains keys (eq: `editor`, `renderer`, `validator`) which describes specified behaviour of the cell.
  11564. */
  11565. function _register(name, type) {
  11566. var editor = type.editor,
  11567. renderer = type.renderer,
  11568. validator = type.validator;
  11569. if (editor) {
  11570. (0, _editors.registerEditor)(name, editor);
  11571. }
  11572. if (renderer) {
  11573. (0, _renderers.registerRenderer)(name, renderer);
  11574. }
  11575. if (validator) {
  11576. (0, _validators.registerValidator)(name, validator);
  11577. }
  11578. register(name, type);
  11579. }
  11580. exports.registerCellType = _register;
  11581. exports.getCellType = _getItem;
  11582. exports.hasCellType = hasItem;
  11583. exports.getRegisteredCellTypeNames = getNames;
  11584. exports.getRegisteredCellTypes = getValues;
  11585. /***/ }),
  11586. /* 64 */
  11587. /***/ (function(module, exports, __webpack_require__) {
  11588. "use strict";
  11589. exports.__esModule = true;
  11590. var _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"); } }; }();
  11591. var _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; };
  11592. exports.default = Core;
  11593. var _numbro = __webpack_require__(51);
  11594. var _numbro2 = _interopRequireDefault(_numbro);
  11595. var _element = __webpack_require__(0);
  11596. var _setting = __webpack_require__(66);
  11597. var _function = __webpack_require__(35);
  11598. var _mixed = __webpack_require__(20);
  11599. var _browser = __webpack_require__(25);
  11600. var _dataMap = __webpack_require__(313);
  11601. var _dataMap2 = _interopRequireDefault(_dataMap);
  11602. var _editorManager = __webpack_require__(315);
  11603. var _editorManager2 = _interopRequireDefault(_editorManager);
  11604. var _eventManager = __webpack_require__(4);
  11605. var _eventManager2 = _interopRequireDefault(_eventManager);
  11606. var _object = __webpack_require__(1);
  11607. var _array = __webpack_require__(2);
  11608. var _plugins = __webpack_require__(5);
  11609. var _renderers = __webpack_require__(9);
  11610. var _validators = __webpack_require__(26);
  11611. var _string = __webpack_require__(27);
  11612. var _number = __webpack_require__(6);
  11613. var _tableView = __webpack_require__(384);
  11614. var _tableView2 = _interopRequireDefault(_tableView);
  11615. var _dataSource = __webpack_require__(314);
  11616. var _dataSource2 = _interopRequireDefault(_dataSource);
  11617. var _data = __webpack_require__(65);
  11618. var _recordTranslator = __webpack_require__(268);
  11619. var _src = __webpack_require__(11);
  11620. var _pluginHooks = __webpack_require__(8);
  11621. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  11622. var _defaultSettings = __webpack_require__(88);
  11623. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  11624. var _cellTypes = __webpack_require__(63);
  11625. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11626. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  11627. var activeGuid = null;
  11628. /**
  11629. * Handsontable constructor
  11630. *
  11631. * @core
  11632. * @dependencies numbro
  11633. * @constructor Core
  11634. * @description
  11635. *
  11636. * After Handsontable is constructed, you can modify the grid behavior using the available public methods.
  11637. *
  11638. * ---
  11639. * ## How to call methods
  11640. *
  11641. * These are 2 equal ways to call a Handsontable method:
  11642. *
  11643. * ```js
  11644. * // all following examples assume that you constructed Handsontable like this
  11645. * var ht = new Handsontable(document.getElementById('example1'), options);
  11646. *
  11647. * // now, to use setDataAtCell method, you can either:
  11648. * ht.setDataAtCell(0, 0, 'new value');
  11649. * ```
  11650. *
  11651. * Alternatively, you can call the method using jQuery wrapper (__obsolete__, requires initialization using our jQuery guide
  11652. * ```js
  11653. * $('#example1').handsontable('setDataAtCell', 0, 0, 'new value');
  11654. * ```
  11655. * ---
  11656. */
  11657. function Core(rootElement, userSettings) {
  11658. var priv,
  11659. datamap,
  11660. dataSource,
  11661. grid,
  11662. selection,
  11663. editorManager,
  11664. instance = this,
  11665. GridSettings = function GridSettings() {},
  11666. eventManager = new _eventManager2.default(instance);
  11667. (0, _object.extend)(GridSettings.prototype, _defaultSettings2.default.prototype); // create grid settings as a copy of default settings
  11668. (0, _object.extend)(GridSettings.prototype, userSettings); // overwrite defaults with user settings
  11669. (0, _object.extend)(GridSettings.prototype, expandType(userSettings));
  11670. this.rootElement = rootElement;
  11671. this.isHotTableEnv = (0, _element.isChildOfWebComponentTable)(this.rootElement);
  11672. _eventManager2.default.isHotTableEnv = this.isHotTableEnv;
  11673. this.container = document.createElement('DIV');
  11674. this.renderCall = false;
  11675. rootElement.insertBefore(this.container, rootElement.firstChild);
  11676. this.guid = 'ht_' + (0, _string.randomString)(); // this is the namespace for global events
  11677. var recordTranslator = (0, _recordTranslator.getTranslator)(instance);
  11678. dataSource = new _dataSource2.default(instance);
  11679. if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') {
  11680. this.rootElement.id = this.guid; // if root element does not have an id, assign a random id
  11681. }
  11682. priv = {
  11683. cellSettings: [],
  11684. columnSettings: [],
  11685. columnsSettingConflicts: ['data', 'width'],
  11686. settings: new GridSettings(), // current settings instance
  11687. selRange: null, // exposed by public method `getSelectedRange`
  11688. isPopulated: null,
  11689. scrollable: null,
  11690. firstRun: true
  11691. };
  11692. grid = {
  11693. /**
  11694. * Inserts or removes rows and columns
  11695. *
  11696. * @memberof Core#
  11697. * @function alter
  11698. * @private
  11699. * @param {String} action Possible values: "insert_row", "insert_col", "remove_row", "remove_col"
  11700. * @param {Number} index
  11701. * @param {Number} amount
  11702. * @param {String} [source] Optional. Source of hook runner.
  11703. * @param {Boolean} [keepEmptyRows] Optional. Flag for preventing deletion of empty rows.
  11704. */
  11705. alter: function alter(action, index, amount, source, keepEmptyRows) {
  11706. var delta;
  11707. amount = amount || 1;
  11708. function spliceWith(data, index, count, toInject) {
  11709. var valueFactory = function valueFactory() {
  11710. var result = void 0;
  11711. if (toInject === 'array') {
  11712. result = [];
  11713. } else if (toInject === 'object') {
  11714. result = {};
  11715. }
  11716. return result;
  11717. };
  11718. var spliceArgs = (0, _array.arrayMap)(new Array(count), function () {
  11719. return valueFactory();
  11720. });
  11721. spliceArgs.unshift(index, 0);
  11722. data.splice.apply(data, _toConsumableArray(spliceArgs));
  11723. }
  11724. /* eslint-disable no-case-declarations */
  11725. switch (action) {
  11726. case 'insert_row':
  11727. var numberOfSourceRows = instance.countSourceRows();
  11728. if (instance.getSettings().maxRows === numberOfSourceRows) {
  11729. return;
  11730. }
  11731. index = (0, _mixed.isDefined)(index) ? index : numberOfSourceRows;
  11732. delta = datamap.createRow(index, amount, source);
  11733. spliceWith(priv.cellSettings, index, amount, 'array');
  11734. if (delta) {
  11735. if (selection.isSelected() && priv.selRange.from.row >= index) {
  11736. priv.selRange.from.row += delta;
  11737. selection.transformEnd(delta, 0); // will call render() internally
  11738. } else {
  11739. selection.refreshBorders(); // it will call render and prepare methods
  11740. }
  11741. }
  11742. break;
  11743. case 'insert_col':
  11744. delta = datamap.createCol(index, amount, source);
  11745. for (var row = 0, len = instance.countSourceRows(); row < len; row++) {
  11746. if (priv.cellSettings[row]) {
  11747. spliceWith(priv.cellSettings[row], index, amount);
  11748. }
  11749. }
  11750. if (delta) {
  11751. if (Array.isArray(instance.getSettings().colHeaders)) {
  11752. var spliceArray = [index, 0];
  11753. spliceArray.length += delta; // inserts empty (undefined) elements at the end of an array
  11754. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray); // inserts empty (undefined) elements into the colHeader array
  11755. }
  11756. if (selection.isSelected() && priv.selRange.from.col >= index) {
  11757. priv.selRange.from.col += delta;
  11758. selection.transformEnd(0, delta); // will call render() internally
  11759. } else {
  11760. selection.refreshBorders(); // it will call render and prepare methods
  11761. }
  11762. }
  11763. break;
  11764. case 'remove_row':
  11765. datamap.removeRow(index, amount, source);
  11766. priv.cellSettings.splice(index, amount);
  11767. var totalRows = instance.countRows();
  11768. var fixedRowsTop = instance.getSettings().fixedRowsTop;
  11769. if (fixedRowsTop >= index + 1) {
  11770. instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - index);
  11771. }
  11772. var fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  11773. if (fixedRowsBottom && index >= totalRows - fixedRowsBottom) {
  11774. instance.getSettings().fixedRowsBottom -= Math.min(amount, fixedRowsBottom);
  11775. }
  11776. grid.adjustRowsAndCols();
  11777. selection.refreshBorders(); // it will call render and prepare methods
  11778. break;
  11779. case 'remove_col':
  11780. var visualColumnIndex = recordTranslator.toPhysicalColumn(index);
  11781. datamap.removeCol(index, amount, source);
  11782. for (var _row = 0, _len = instance.countSourceRows(); _row < _len; _row++) {
  11783. if (priv.cellSettings[_row]) {
  11784. // if row hasn't been rendered it wouldn't have cellSettings
  11785. priv.cellSettings[_row].splice(visualColumnIndex, amount);
  11786. }
  11787. }
  11788. var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft;
  11789. if (fixedColumnsLeft >= index + 1) {
  11790. instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - index);
  11791. }
  11792. if (Array.isArray(instance.getSettings().colHeaders)) {
  11793. if (typeof visualColumnIndex === 'undefined') {
  11794. visualColumnIndex = -1;
  11795. }
  11796. instance.getSettings().colHeaders.splice(visualColumnIndex, amount);
  11797. }
  11798. grid.adjustRowsAndCols();
  11799. selection.refreshBorders(); // it will call render and prepare methods
  11800. break;
  11801. default:
  11802. throw new Error('There is no such action "' + action + '"');
  11803. }
  11804. if (!keepEmptyRows) {
  11805. grid.adjustRowsAndCols(); // makes sure that we did not add rows that will be removed in next refresh
  11806. }
  11807. },
  11808. /**
  11809. * Makes sure there are empty rows at the bottom of the table
  11810. */
  11811. adjustRowsAndCols: function adjustRowsAndCols() {
  11812. if (priv.settings.minRows) {
  11813. // should I add empty rows to data source to meet minRows?
  11814. var rows = instance.countRows();
  11815. if (rows < priv.settings.minRows) {
  11816. for (var r = 0, minRows = priv.settings.minRows; r < minRows - rows; r++) {
  11817. datamap.createRow(instance.countRows(), 1, 'auto');
  11818. }
  11819. }
  11820. }
  11821. if (priv.settings.minSpareRows) {
  11822. var emptyRows = instance.countEmptyRows(true);
  11823. // should I add empty rows to meet minSpareRows?
  11824. if (emptyRows < priv.settings.minSpareRows) {
  11825. for (; emptyRows < priv.settings.minSpareRows && instance.countSourceRows() < priv.settings.maxRows; emptyRows++) {
  11826. datamap.createRow(instance.countRows(), 1, 'auto');
  11827. }
  11828. }
  11829. }
  11830. {
  11831. var emptyCols = void 0;
  11832. // count currently empty cols
  11833. if (priv.settings.minCols || priv.settings.minSpareCols) {
  11834. emptyCols = instance.countEmptyCols(true);
  11835. }
  11836. // should I add empty cols to meet minCols?
  11837. if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) {
  11838. for (; instance.countCols() < priv.settings.minCols; emptyCols++) {
  11839. datamap.createCol(instance.countCols(), 1, 'auto');
  11840. }
  11841. }
  11842. // should I add empty cols to meet minSpareCols?
  11843. if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) {
  11844. for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) {
  11845. datamap.createCol(instance.countCols(), 1, 'auto');
  11846. }
  11847. }
  11848. }
  11849. var rowCount = instance.countRows();
  11850. var colCount = instance.countCols();
  11851. if (rowCount === 0 || colCount === 0) {
  11852. selection.deselect();
  11853. }
  11854. if (selection.isSelected()) {
  11855. var selectionChanged = false;
  11856. var fromRow = priv.selRange.from.row;
  11857. var fromCol = priv.selRange.from.col;
  11858. var toRow = priv.selRange.to.row;
  11859. var toCol = priv.selRange.to.col;
  11860. // if selection is outside, move selection to last row
  11861. if (fromRow > rowCount - 1) {
  11862. fromRow = rowCount - 1;
  11863. selectionChanged = true;
  11864. if (toRow > fromRow) {
  11865. toRow = fromRow;
  11866. }
  11867. } else if (toRow > rowCount - 1) {
  11868. toRow = rowCount - 1;
  11869. selectionChanged = true;
  11870. if (fromRow > toRow) {
  11871. fromRow = toRow;
  11872. }
  11873. }
  11874. // if selection is outside, move selection to last row
  11875. if (fromCol > colCount - 1) {
  11876. fromCol = colCount - 1;
  11877. selectionChanged = true;
  11878. if (toCol > fromCol) {
  11879. toCol = fromCol;
  11880. }
  11881. } else if (toCol > colCount - 1) {
  11882. toCol = colCount - 1;
  11883. selectionChanged = true;
  11884. if (fromCol > toCol) {
  11885. fromCol = toCol;
  11886. }
  11887. }
  11888. if (selectionChanged) {
  11889. instance.selectCell(fromRow, fromCol, toRow, toCol);
  11890. }
  11891. }
  11892. if (instance.view) {
  11893. instance.view.wt.wtOverlays.adjustElementsSize();
  11894. }
  11895. },
  11896. /**
  11897. * Populate the data from the provided 2d array from the given cell coordinates.
  11898. *
  11899. * @private
  11900. * @param {Object} start Start selection position. Visual indexes.
  11901. * @param {Array} input 2d data array.
  11902. * @param {Object} [end] End selection position (only for drag-down mode). Visual indexes.
  11903. * @param {String} [source="populateFromArray"] Source information string.
  11904. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  11905. * @param {String} direction (left|right|up|down) String specifying the direction.
  11906. * @param {Array} deltas The deltas array. A difference between values of adjacent cells.
  11907. * Useful **only** when the type of handled cells is `numeric`.
  11908. * @returns {Object|undefined} ending td in pasted area (only if any cell was changed).
  11909. */
  11910. populateFromArray: function populateFromArray(start, input, end, source, method, direction, deltas) {
  11911. // TODO: either remove or implement the `direction` argument. Currently it's not working at all.
  11912. var r,
  11913. rlen,
  11914. c,
  11915. clen,
  11916. setData = [],
  11917. current = {};
  11918. rlen = input.length;
  11919. if (rlen === 0) {
  11920. return false;
  11921. }
  11922. var repeatCol,
  11923. repeatRow,
  11924. cmax,
  11925. rmax,
  11926. baseEnd = {
  11927. row: end === null ? null : end.row,
  11928. col: end === null ? null : end.col
  11929. };
  11930. /* eslint-disable no-case-declarations */
  11931. // insert data with specified pasteMode method
  11932. switch (method) {
  11933. case 'shift_down':
  11934. repeatCol = end ? end.col - start.col + 1 : 0;
  11935. repeatRow = end ? end.row - start.row + 1 : 0;
  11936. input = (0, _data.translateRowsToColumns)(input);
  11937. for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) {
  11938. if (c < clen) {
  11939. var _instance;
  11940. for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) {
  11941. input[c].push(input[c][r % rlen]);
  11942. }
  11943. input[c].unshift(start.col + c, start.row, 0);
  11944. (_instance = instance).spliceCol.apply(_instance, _toConsumableArray(input[c]));
  11945. } else {
  11946. var _instance2;
  11947. input[c % clen][0] = start.col + c;
  11948. (_instance2 = instance).spliceCol.apply(_instance2, _toConsumableArray(input[c % clen]));
  11949. }
  11950. }
  11951. break;
  11952. case 'shift_right':
  11953. repeatCol = end ? end.col - start.col + 1 : 0;
  11954. repeatRow = end ? end.row - start.row + 1 : 0;
  11955. for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) {
  11956. if (r < rlen) {
  11957. var _instance3;
  11958. for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) {
  11959. input[r].push(input[r][c % clen]);
  11960. }
  11961. input[r].unshift(start.row + r, start.col, 0);
  11962. (_instance3 = instance).spliceRow.apply(_instance3, _toConsumableArray(input[r]));
  11963. } else {
  11964. var _instance4;
  11965. input[r % rlen][0] = start.row + r;
  11966. (_instance4 = instance).spliceRow.apply(_instance4, _toConsumableArray(input[r % rlen]));
  11967. }
  11968. }
  11969. break;
  11970. case 'overwrite':
  11971. default:
  11972. // overwrite and other not specified options
  11973. current.row = start.row;
  11974. current.col = start.col;
  11975. var selected = { // selected range
  11976. row: end && start ? end.row - start.row + 1 : 1,
  11977. col: end && start ? end.col - start.col + 1 : 1
  11978. };
  11979. var skippedRow = 0;
  11980. var skippedColumn = 0;
  11981. var pushData = true;
  11982. var cellMeta = void 0;
  11983. var getInputValue = function getInputValue(row) {
  11984. var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11985. var rowValue = input[row % input.length];
  11986. if (col !== null) {
  11987. return rowValue[col % rowValue.length];
  11988. }
  11989. return rowValue;
  11990. };
  11991. var rowInputLength = input.length;
  11992. var rowSelectionLength = end ? end.row - start.row + 1 : 0;
  11993. if (end) {
  11994. rlen = rowSelectionLength;
  11995. } else {
  11996. rlen = Math.max(rowInputLength, rowSelectionLength);
  11997. }
  11998. for (r = 0; r < rlen; r++) {
  11999. if (end && current.row > end.row && rowSelectionLength > rowInputLength || !priv.settings.allowInsertRow && current.row > instance.countRows() - 1 || current.row >= priv.settings.maxRows) {
  12000. break;
  12001. }
  12002. var visualRow = r - skippedRow;
  12003. var colInputLength = getInputValue(visualRow).length;
  12004. var colSelectionLength = end ? end.col - start.col + 1 : 0;
  12005. if (end) {
  12006. clen = colSelectionLength;
  12007. } else {
  12008. clen = Math.max(colInputLength, colSelectionLength);
  12009. }
  12010. current.col = start.col;
  12011. cellMeta = instance.getCellMeta(current.row, current.col);
  12012. if ((source === 'CopyPaste.paste' || source === 'Autofill.autofill') && cellMeta.skipRowOnPaste) {
  12013. skippedRow++;
  12014. current.row++;
  12015. rlen++;
  12016. /* eslint-disable no-continue */
  12017. continue;
  12018. }
  12019. skippedColumn = 0;
  12020. for (c = 0; c < clen; c++) {
  12021. if (end && current.col > end.col && colSelectionLength > colInputLength || !priv.settings.allowInsertColumn && current.col > instance.countCols() - 1 || current.col >= priv.settings.maxCols) {
  12022. break;
  12023. }
  12024. cellMeta = instance.getCellMeta(current.row, current.col);
  12025. if ((source === 'CopyPaste.paste' || source === 'Autofill.fill') && cellMeta.skipColumnOnPaste) {
  12026. skippedColumn++;
  12027. current.col++;
  12028. clen++;
  12029. continue;
  12030. }
  12031. if (cellMeta.readOnly) {
  12032. current.col++;
  12033. /* eslint-disable no-continue */
  12034. continue;
  12035. }
  12036. var visualColumn = c - skippedColumn;
  12037. var value = getInputValue(visualRow, visualColumn);
  12038. var orgValue = instance.getDataAtCell(current.row, current.col);
  12039. var index = {
  12040. row: visualRow,
  12041. col: visualColumn
  12042. };
  12043. if (source === 'Autofill.fill') {
  12044. var result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, {}, selected);
  12045. if (result) {
  12046. value = (0, _mixed.isUndefined)(result.value) ? value : result.value;
  12047. }
  12048. }
  12049. if (value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  12050. if (orgValue === null || (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) !== 'object') {
  12051. pushData = false;
  12052. } else {
  12053. var orgValueSchema = (0, _object.duckSchema)(orgValue[0] || orgValue);
  12054. var valueSchema = (0, _object.duckSchema)(value[0] || value);
  12055. /* eslint-disable max-depth */
  12056. if ((0, _object.isObjectEquals)(orgValueSchema, valueSchema)) {
  12057. value = (0, _object.deepClone)(value);
  12058. } else {
  12059. pushData = false;
  12060. }
  12061. }
  12062. } else if (orgValue !== null && (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) === 'object') {
  12063. pushData = false;
  12064. }
  12065. if (pushData) {
  12066. setData.push([current.row, current.col, value]);
  12067. }
  12068. pushData = true;
  12069. current.col++;
  12070. }
  12071. current.row++;
  12072. }
  12073. instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
  12074. break;
  12075. }
  12076. }
  12077. };
  12078. /* eslint-disable no-multi-assign */
  12079. this.selection = selection = { // this public assignment is only temporary
  12080. inProgress: false,
  12081. selectedHeader: {
  12082. cols: false,
  12083. rows: false
  12084. },
  12085. /**
  12086. * @param {Boolean} [rows=false]
  12087. * @param {Boolean} [cols=false]
  12088. * @param {Boolean} [corner=false]
  12089. */
  12090. setSelectedHeaders: function setSelectedHeaders() {
  12091. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12092. var cols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12093. var corner = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  12094. instance.selection.selectedHeader.rows = rows;
  12095. instance.selection.selectedHeader.cols = cols;
  12096. instance.selection.selectedHeader.corner = corner;
  12097. },
  12098. /**
  12099. * Sets inProgress to `true`. This enables onSelectionEnd and onSelectionEndByProp to function as desired.
  12100. */
  12101. begin: function begin() {
  12102. instance.selection.inProgress = true;
  12103. },
  12104. /**
  12105. * Sets inProgress to `false`. Triggers onSelectionEnd and onSelectionEndByProp.
  12106. */
  12107. finish: function finish() {
  12108. var sel = instance.getSelected();
  12109. instance.runHooks('afterSelectionEnd', sel[0], sel[1], sel[2], sel[3]);
  12110. instance.runHooks('afterSelectionEndByProp', sel[0], instance.colToProp(sel[1]), sel[2], instance.colToProp(sel[3]));
  12111. instance.selection.inProgress = false;
  12112. },
  12113. /**
  12114. * @returns {Boolean}
  12115. */
  12116. isInProgress: function isInProgress() {
  12117. return instance.selection.inProgress;
  12118. },
  12119. /**
  12120. * Starts selection range on given td object.
  12121. *
  12122. * @param {CellCoords} coords Visual coords.
  12123. * @param keepEditorOpened
  12124. */
  12125. setRangeStart: function setRangeStart(coords, keepEditorOpened) {
  12126. instance.runHooks('beforeSetRangeStart', coords);
  12127. priv.selRange = new _src.CellRange(coords, coords, coords);
  12128. selection.setRangeEnd(coords, null, keepEditorOpened);
  12129. },
  12130. /**
  12131. * Starts selection range on given td object.
  12132. *
  12133. * @param {CellCoords} coords Visual coords.
  12134. * @param keepEditorOpened
  12135. */
  12136. setRangeStartOnly: function setRangeStartOnly(coords) {
  12137. instance.runHooks('beforeSetRangeStartOnly', coords);
  12138. priv.selRange = new _src.CellRange(coords, coords, coords);
  12139. },
  12140. /**
  12141. * Ends selection range on given td object.
  12142. *
  12143. * @param {CellCoords} coords Visual coords.
  12144. * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to range end
  12145. * @param {Boolean} [keepEditorOpened] If `true`, cell editor will be still opened after changing selection range
  12146. */
  12147. setRangeEnd: function setRangeEnd(coords, scrollToCell, keepEditorOpened) {
  12148. if (priv.selRange === null) {
  12149. return;
  12150. }
  12151. var disableVisualSelection,
  12152. isHeaderSelected = false,
  12153. areCoordsPositive = true;
  12154. var firstVisibleRow = instance.view.wt.wtTable.getFirstVisibleRow();
  12155. var firstVisibleColumn = instance.view.wt.wtTable.getFirstVisibleColumn();
  12156. var newRangeCoords = {
  12157. row: null,
  12158. col: null
  12159. };
  12160. // trigger handlers
  12161. instance.runHooks('beforeSetRangeEnd', coords);
  12162. instance.selection.begin();
  12163. newRangeCoords.row = coords.row < 0 ? firstVisibleRow : coords.row;
  12164. newRangeCoords.col = coords.col < 0 ? firstVisibleColumn : coords.col;
  12165. priv.selRange.to = new _src.CellCoords(newRangeCoords.row, newRangeCoords.col);
  12166. if (!priv.settings.multiSelect) {
  12167. priv.selRange.from = coords;
  12168. }
  12169. // set up current selection
  12170. instance.view.wt.selections.current.clear();
  12171. disableVisualSelection = instance.getCellMeta(priv.selRange.highlight.row, priv.selRange.highlight.col).disableVisualSelection;
  12172. if (typeof disableVisualSelection === 'string') {
  12173. disableVisualSelection = [disableVisualSelection];
  12174. }
  12175. if (disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('current') === -1) {
  12176. instance.view.wt.selections.current.add(priv.selRange.highlight);
  12177. }
  12178. // set up area selection
  12179. instance.view.wt.selections.area.clear();
  12180. if ((disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('area') === -1) && selection.isMultiple()) {
  12181. instance.view.wt.selections.area.add(priv.selRange.from);
  12182. instance.view.wt.selections.area.add(priv.selRange.to);
  12183. }
  12184. // set up highlight
  12185. if (priv.settings.currentHeaderClassName || priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  12186. instance.view.wt.selections.highlight.clear();
  12187. instance.view.wt.selections.highlight.add(priv.selRange.from);
  12188. instance.view.wt.selections.highlight.add(priv.selRange.to);
  12189. }
  12190. var preventScrolling = (0, _object.createObjectPropListener)('value');
  12191. // trigger handlers
  12192. instance.runHooks('afterSelection', priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col, preventScrolling);
  12193. instance.runHooks('afterSelectionByProp', priv.selRange.from.row, datamap.colToProp(priv.selRange.from.col), priv.selRange.to.row, datamap.colToProp(priv.selRange.to.col), preventScrolling);
  12194. 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) {
  12195. isHeaderSelected = true;
  12196. }
  12197. if (coords.row < 0 || coords.col < 0) {
  12198. areCoordsPositive = false;
  12199. }
  12200. if (preventScrolling.isTouched()) {
  12201. scrollToCell = !preventScrolling.value;
  12202. }
  12203. if (scrollToCell !== false && !isHeaderSelected && areCoordsPositive) {
  12204. if (priv.selRange.from && !selection.isMultiple()) {
  12205. instance.view.scrollViewport(priv.selRange.from);
  12206. } else {
  12207. instance.view.scrollViewport(coords);
  12208. }
  12209. }
  12210. if (selection.selectedHeader.rows && selection.selectedHeader.cols) {
  12211. (0, _element.addClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  12212. } else if (selection.selectedHeader.rows) {
  12213. (0, _element.removeClass)(instance.rootElement, 'ht__selection--columns');
  12214. (0, _element.addClass)(instance.rootElement, 'ht__selection--rows');
  12215. } else if (selection.selectedHeader.cols) {
  12216. (0, _element.removeClass)(instance.rootElement, 'ht__selection--rows');
  12217. (0, _element.addClass)(instance.rootElement, 'ht__selection--columns');
  12218. } else {
  12219. (0, _element.removeClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  12220. }
  12221. selection.refreshBorders(null, keepEditorOpened);
  12222. },
  12223. /**
  12224. * Destroys editor, redraws borders around cells, prepares editor.
  12225. *
  12226. * @param {Boolean} [revertOriginal]
  12227. * @param {Boolean} [keepEditor]
  12228. */
  12229. refreshBorders: function refreshBorders(revertOriginal, keepEditor) {
  12230. if (!keepEditor) {
  12231. editorManager.destroyEditor(revertOriginal);
  12232. }
  12233. instance.view.render();
  12234. if (selection.isSelected() && !keepEditor) {
  12235. editorManager.prepareEditor();
  12236. }
  12237. },
  12238. /**
  12239. * Returns information if we have a multiselection.
  12240. *
  12241. * @returns {Boolean}
  12242. */
  12243. isMultiple: function isMultiple() {
  12244. var isMultiple = !(priv.selRange.to.col === priv.selRange.from.col && priv.selRange.to.row === priv.selRange.from.row),
  12245. modifier = instance.runHooks('afterIsMultipleSelection', isMultiple);
  12246. if (isMultiple) {
  12247. return modifier;
  12248. }
  12249. },
  12250. /**
  12251. * Selects cell relative to current cell (if possible).
  12252. */
  12253. transformStart: function transformStart(rowDelta, colDelta, force, keepEditorOpened) {
  12254. var delta = new _src.CellCoords(rowDelta, colDelta),
  12255. rowTransformDir = 0,
  12256. colTransformDir = 0,
  12257. totalRows,
  12258. totalCols,
  12259. coords,
  12260. fixedRowsBottom;
  12261. instance.runHooks('modifyTransformStart', delta);
  12262. totalRows = instance.countRows();
  12263. totalCols = instance.countCols();
  12264. fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  12265. if (priv.selRange.highlight.row + rowDelta > totalRows - 1) {
  12266. if (force && priv.settings.minSpareRows > 0 && !(fixedRowsBottom && priv.selRange.highlight.row >= totalRows - fixedRowsBottom - 1)) {
  12267. instance.alter('insert_row', totalRows);
  12268. totalRows = instance.countRows();
  12269. } else if (priv.settings.autoWrapCol) {
  12270. delta.row = 1 - totalRows;
  12271. delta.col = priv.selRange.highlight.col + delta.col == totalCols - 1 ? 1 - totalCols : 1;
  12272. }
  12273. } else if (priv.settings.autoWrapCol && priv.selRange.highlight.row + delta.row < 0 && priv.selRange.highlight.col + delta.col >= 0) {
  12274. delta.row = totalRows - 1;
  12275. delta.col = priv.selRange.highlight.col + delta.col == 0 ? totalCols - 1 : -1;
  12276. }
  12277. if (priv.selRange.highlight.col + delta.col > totalCols - 1) {
  12278. if (force && priv.settings.minSpareCols > 0) {
  12279. instance.alter('insert_col', totalCols);
  12280. totalCols = instance.countCols();
  12281. } else if (priv.settings.autoWrapRow) {
  12282. delta.row = priv.selRange.highlight.row + delta.row == totalRows - 1 ? 1 - totalRows : 1;
  12283. delta.col = 1 - totalCols;
  12284. }
  12285. } else if (priv.settings.autoWrapRow && priv.selRange.highlight.col + delta.col < 0 && priv.selRange.highlight.row + delta.row >= 0) {
  12286. delta.row = priv.selRange.highlight.row + delta.row == 0 ? totalRows - 1 : -1;
  12287. delta.col = totalCols - 1;
  12288. }
  12289. coords = new _src.CellCoords(priv.selRange.highlight.row + delta.row, priv.selRange.highlight.col + delta.col);
  12290. if (coords.row < 0) {
  12291. rowTransformDir = -1;
  12292. coords.row = 0;
  12293. } else if (coords.row > 0 && coords.row >= totalRows) {
  12294. rowTransformDir = 1;
  12295. coords.row = totalRows - 1;
  12296. }
  12297. if (coords.col < 0) {
  12298. colTransformDir = -1;
  12299. coords.col = 0;
  12300. } else if (coords.col > 0 && coords.col >= totalCols) {
  12301. colTransformDir = 1;
  12302. coords.col = totalCols - 1;
  12303. }
  12304. instance.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
  12305. selection.setRangeStart(coords, keepEditorOpened);
  12306. },
  12307. /**
  12308. * Sets selection end cell relative to current selection end cell (if possible).
  12309. */
  12310. transformEnd: function transformEnd(rowDelta, colDelta) {
  12311. var delta = new _src.CellCoords(rowDelta, colDelta),
  12312. rowTransformDir = 0,
  12313. colTransformDir = 0,
  12314. totalRows,
  12315. totalCols,
  12316. coords;
  12317. instance.runHooks('modifyTransformEnd', delta);
  12318. totalRows = instance.countRows();
  12319. totalCols = instance.countCols();
  12320. coords = new _src.CellCoords(priv.selRange.to.row + delta.row, priv.selRange.to.col + delta.col);
  12321. if (coords.row < 0) {
  12322. rowTransformDir = -1;
  12323. coords.row = 0;
  12324. } else if (coords.row > 0 && coords.row >= totalRows) {
  12325. rowTransformDir = 1;
  12326. coords.row = totalRows - 1;
  12327. }
  12328. if (coords.col < 0) {
  12329. colTransformDir = -1;
  12330. coords.col = 0;
  12331. } else if (coords.col > 0 && coords.col >= totalCols) {
  12332. colTransformDir = 1;
  12333. coords.col = totalCols - 1;
  12334. }
  12335. instance.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
  12336. selection.setRangeEnd(coords, true);
  12337. },
  12338. /**
  12339. * Returns `true` if currently there is a selection on screen, `false` otherwise.
  12340. *
  12341. * @returns {Boolean}
  12342. */
  12343. isSelected: function isSelected() {
  12344. return priv.selRange !== null;
  12345. },
  12346. /**
  12347. * Returns `true` if coords is within current selection coords.
  12348. *
  12349. * @param {CellCoords} coords
  12350. * @returns {Boolean}
  12351. */
  12352. inInSelection: function inInSelection(coords) {
  12353. if (!selection.isSelected()) {
  12354. return false;
  12355. }
  12356. return priv.selRange.includes(coords);
  12357. },
  12358. /**
  12359. * Deselects all selected cells
  12360. */
  12361. deselect: function deselect() {
  12362. if (!selection.isSelected()) {
  12363. return;
  12364. }
  12365. instance.selection.inProgress = false; // needed by HT inception
  12366. priv.selRange = null;
  12367. instance.view.wt.selections.current.clear();
  12368. instance.view.wt.selections.area.clear();
  12369. if (priv.settings.currentHeaderClassName || priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  12370. instance.view.wt.selections.highlight.clear();
  12371. }
  12372. editorManager.destroyEditor();
  12373. selection.refreshBorders();
  12374. (0, _element.removeClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  12375. instance.runHooks('afterDeselect');
  12376. },
  12377. /**
  12378. * Select all cells
  12379. */
  12380. selectAll: function selectAll() {
  12381. if (!priv.settings.multiSelect) {
  12382. return;
  12383. }
  12384. selection.setSelectedHeaders(true, true, true);
  12385. selection.setRangeStart(new _src.CellCoords(0, 0));
  12386. selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, instance.countCols() - 1), false);
  12387. },
  12388. /**
  12389. * Deletes data from selected cells
  12390. */
  12391. empty: function empty() {
  12392. if (!selection.isSelected()) {
  12393. return;
  12394. }
  12395. var topLeft = priv.selRange.getTopLeftCorner();
  12396. var bottomRight = priv.selRange.getBottomRightCorner();
  12397. var r,
  12398. c,
  12399. changes = [];
  12400. for (r = topLeft.row; r <= bottomRight.row; r++) {
  12401. for (c = topLeft.col; c <= bottomRight.col; c++) {
  12402. if (!instance.getCellMeta(r, c).readOnly) {
  12403. changes.push([r, c, '']);
  12404. }
  12405. }
  12406. }
  12407. instance.setDataAtCell(changes);
  12408. }
  12409. };
  12410. this.init = function () {
  12411. dataSource.setData(priv.settings.data);
  12412. instance.runHooks('beforeInit');
  12413. if ((0, _browser.isMobileBrowser)()) {
  12414. (0, _element.addClass)(instance.rootElement, 'mobile');
  12415. }
  12416. this.updateSettings(priv.settings, true);
  12417. this.view = new _tableView2.default(this);
  12418. editorManager = new _editorManager2.default(instance, priv, selection, datamap);
  12419. this.forceFullRender = true; // used when data was changed
  12420. instance.runHooks('init');
  12421. this.view.render();
  12422. if (_typeof(priv.firstRun) === 'object') {
  12423. instance.runHooks('afterChange', priv.firstRun[0], priv.firstRun[1]);
  12424. priv.firstRun = false;
  12425. }
  12426. instance.runHooks('afterInit');
  12427. };
  12428. function ValidatorsQueue() {
  12429. // moved this one level up so it can be used in any function here. Probably this should be moved to a separate file
  12430. var resolved = false;
  12431. return {
  12432. validatorsInQueue: 0,
  12433. valid: true,
  12434. addValidatorToQueue: function addValidatorToQueue() {
  12435. this.validatorsInQueue++;
  12436. resolved = false;
  12437. },
  12438. removeValidatorFormQueue: function removeValidatorFormQueue() {
  12439. this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
  12440. this.checkIfQueueIsEmpty();
  12441. },
  12442. onQueueEmpty: function onQueueEmpty(valid) {},
  12443. checkIfQueueIsEmpty: function checkIfQueueIsEmpty() {
  12444. if (this.validatorsInQueue == 0 && resolved == false) {
  12445. resolved = true;
  12446. this.onQueueEmpty(this.valid);
  12447. }
  12448. }
  12449. };
  12450. }
  12451. function validateChanges(changes, source, callback) {
  12452. var waitingForValidator = new ValidatorsQueue();
  12453. waitingForValidator.onQueueEmpty = resolve;
  12454. for (var i = changes.length - 1; i >= 0; i--) {
  12455. if (changes[i] === null) {
  12456. changes.splice(i, 1);
  12457. } else {
  12458. var row = changes[i][0];
  12459. var col = datamap.propToCol(changes[i][1]);
  12460. var cellProperties = instance.getCellMeta(row, col);
  12461. if (cellProperties.type === 'numeric' && typeof changes[i][3] === 'string') {
  12462. if (changes[i][3].length > 0 && (/^-?[\d\s]*(\.|,)?\d*$/.test(changes[i][3]) || cellProperties.format)) {
  12463. var len = changes[i][3].length;
  12464. if ((0, _mixed.isUndefined)(cellProperties.language)) {
  12465. _numbro2.default.culture('en-US');
  12466. } else if (changes[i][3].indexOf('.') === len - 3 && changes[i][3].indexOf(',') === -1) {
  12467. // this input in format XXXX.XX is likely to come from paste. Let's parse it using international rules
  12468. _numbro2.default.culture('en-US');
  12469. } else {
  12470. _numbro2.default.culture(cellProperties.language);
  12471. }
  12472. var _numbro$cultureData = _numbro2.default.cultureData(_numbro2.default.culture()),
  12473. delimiters = _numbro$cultureData.delimiters;
  12474. // try to parse to float - https://github.com/foretagsplatsen/numbro/pull/183
  12475. if (_numbro2.default.validate(changes[i][3]) && !isNaN(changes[i][3])) {
  12476. changes[i][3] = parseFloat(changes[i][3]);
  12477. } else {
  12478. changes[i][3] = (0, _numbro2.default)().unformat(changes[i][3]) || changes[i][3];
  12479. }
  12480. }
  12481. }
  12482. /* eslint-disable no-loop-func */
  12483. if (instance.getCellValidator(cellProperties)) {
  12484. waitingForValidator.addValidatorToQueue();
  12485. instance.validateCell(changes[i][3], cellProperties, function (i, cellProperties) {
  12486. return function (result) {
  12487. if (typeof result !== 'boolean') {
  12488. throw new Error('Validation error: result is not boolean');
  12489. }
  12490. if (result === false && cellProperties.allowInvalid === false) {
  12491. changes.splice(i, 1); // cancel the change
  12492. cellProperties.valid = true; // we cancelled the change, so cell value is still valid
  12493. var cell = instance.getCell(cellProperties.row, cellProperties.col);
  12494. (0, _element.removeClass)(cell, instance.getSettings().invalidCellClassName);
  12495. --i;
  12496. }
  12497. waitingForValidator.removeValidatorFormQueue();
  12498. };
  12499. }(i, cellProperties), source);
  12500. }
  12501. }
  12502. }
  12503. waitingForValidator.checkIfQueueIsEmpty();
  12504. function resolve() {
  12505. var beforeChangeResult;
  12506. if (changes.length) {
  12507. beforeChangeResult = instance.runHooks('beforeChange', changes, source);
  12508. if ((0, _function.isFunction)(beforeChangeResult)) {
  12509. 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).');
  12510. } else if (beforeChangeResult === false) {
  12511. changes.splice(0, changes.length); // invalidate all changes (remove everything from array)
  12512. }
  12513. }
  12514. callback(); // called when async validators are resolved and beforeChange was not async
  12515. }
  12516. }
  12517. /**
  12518. * Internal function to apply changes. Called after validateChanges
  12519. *
  12520. * @private
  12521. * @param {Array} changes Array in form of [row, prop, oldValue, newValue]
  12522. * @param {String} source String that identifies how this change will be described in changes array (useful in onChange callback)
  12523. * @fires Hooks#beforeChangeRender
  12524. * @fires Hooks#afterChange
  12525. */
  12526. function applyChanges(changes, source) {
  12527. var i = changes.length - 1;
  12528. if (i < 0) {
  12529. return;
  12530. }
  12531. for (; i >= 0; i--) {
  12532. var skipThisChange = false;
  12533. if (changes[i] === null) {
  12534. changes.splice(i, 1);
  12535. /* eslint-disable no-continue */
  12536. continue;
  12537. }
  12538. if (changes[i][2] == null && changes[i][3] == null) {
  12539. /* eslint-disable no-continue */
  12540. continue;
  12541. }
  12542. if (priv.settings.allowInsertRow) {
  12543. while (changes[i][0] > instance.countRows() - 1) {
  12544. var numberOfCreatedRows = datamap.createRow(void 0, void 0, source);
  12545. if (numberOfCreatedRows === 0) {
  12546. skipThisChange = true;
  12547. break;
  12548. }
  12549. }
  12550. }
  12551. if (skipThisChange) {
  12552. /* eslint-disable no-continue */
  12553. continue;
  12554. }
  12555. if (instance.dataType === 'array' && (!priv.settings.columns || priv.settings.columns.length === 0) && priv.settings.allowInsertColumn) {
  12556. while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
  12557. datamap.createCol(void 0, void 0, source);
  12558. }
  12559. }
  12560. datamap.set(changes[i][0], changes[i][1], changes[i][3]);
  12561. }
  12562. instance.forceFullRender = true; // used when data was changed
  12563. grid.adjustRowsAndCols();
  12564. instance.runHooks('beforeChangeRender', changes, source);
  12565. selection.refreshBorders(null, true);
  12566. instance.view.wt.wtOverlays.adjustElementsSize();
  12567. instance.runHooks('afterChange', changes, source || 'edit');
  12568. var activeEditor = instance.getActiveEditor();
  12569. if (activeEditor && (0, _mixed.isDefined)(activeEditor.refreshValue)) {
  12570. activeEditor.refreshValue();
  12571. }
  12572. }
  12573. this.validateCell = function (value, cellProperties, callback, source) {
  12574. var validator = instance.getCellValidator(cellProperties);
  12575. function done(valid) {
  12576. var col = cellProperties.visualCol,
  12577. row = cellProperties.visualRow,
  12578. td = instance.getCell(row, col, true);
  12579. if (td && td.nodeName != 'TH') {
  12580. instance.view.wt.wtSettings.settings.cellRenderer(row, col, td);
  12581. }
  12582. callback(valid);
  12583. }
  12584. if ((0, _mixed.isRegExp)(validator)) {
  12585. validator = function (validator) {
  12586. return function (value, callback) {
  12587. callback(validator.test(value));
  12588. };
  12589. }(validator);
  12590. }
  12591. if ((0, _function.isFunction)(validator)) {
  12592. value = instance.runHooks('beforeValidate', value, cellProperties.visualRow, cellProperties.prop, source);
  12593. // To provide consistent behaviour, validation should be always asynchronous
  12594. instance._registerTimeout(setTimeout(function () {
  12595. validator.call(cellProperties, value, function (valid) {
  12596. valid = instance.runHooks('afterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  12597. cellProperties.valid = valid;
  12598. done(valid);
  12599. instance.runHooks('postAfterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  12600. });
  12601. }, 0));
  12602. } else {
  12603. // resolve callback even if validator function was not found
  12604. instance._registerTimeout(setTimeout(function () {
  12605. cellProperties.valid = true;
  12606. done(cellProperties.valid);
  12607. }, 0));
  12608. }
  12609. };
  12610. function setDataInputToArray(row, propOrCol, value) {
  12611. if ((typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  12612. // is it an array of changes
  12613. return row;
  12614. }
  12615. return [[row, propOrCol, value]];
  12616. }
  12617. /**
  12618. * @description
  12619. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, col, value], ...]` as
  12620. * the only parameter. `col` is the index of a __visible__ column (note that if columns were reordered,
  12621. * the current visible order will be used). `source` is a flag for before/afterChange events. If you pass only array of
  12622. * changes then `source` could be set as second parameter.
  12623. *
  12624. * @memberof Core#
  12625. * @function setDataAtCell
  12626. * @param {Number|Array} row Visual row index or array of changes in format `[[row, col, value], ...]`.
  12627. * @param {Number} col Visual column index.
  12628. * @param {String} value New value.
  12629. * @param {String} [source] String that identifies how this change will be described in the changes array (useful in onAfterChange or onBeforeChange callback).
  12630. */
  12631. this.setDataAtCell = function (row, col, value, source) {
  12632. var input = setDataInputToArray(row, col, value),
  12633. i,
  12634. ilen,
  12635. changes = [],
  12636. prop;
  12637. for (i = 0, ilen = input.length; i < ilen; i++) {
  12638. if (_typeof(input[i]) !== 'object') {
  12639. throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
  12640. }
  12641. if (typeof input[i][1] !== 'number') {
  12642. throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`');
  12643. }
  12644. prop = datamap.colToProp(input[i][1]);
  12645. changes.push([input[i][0], prop, dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  12646. }
  12647. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  12648. source = col;
  12649. }
  12650. instance.runHooks('afterSetDataAtCell', changes, source);
  12651. validateChanges(changes, source, function () {
  12652. applyChanges(changes, source);
  12653. });
  12654. };
  12655. /**
  12656. * @description
  12657. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, prop, value], ...]` as
  12658. * the only parameter. `prop` is the name of the object property (e.g. `first.name`). `source` is a flag for before/afterChange events.
  12659. * If you pass only array of changes then `source` could be set as second parameter.
  12660. *
  12661. * @memberof Core#
  12662. * @function setDataAtRowProp
  12663. * @param {Number|Array} row Visual row index or array of changes in format `[[row, prop, value], ...]`.
  12664. * @param {String} prop Property name or the source string.
  12665. * @param {String} value Value to be set.
  12666. * @param {String} [source] String that identifies how this change will be described in changes array (useful in onChange callback).
  12667. */
  12668. this.setDataAtRowProp = function (row, prop, value, source) {
  12669. var input = setDataInputToArray(row, prop, value),
  12670. i,
  12671. ilen,
  12672. changes = [];
  12673. for (i = 0, ilen = input.length; i < ilen; i++) {
  12674. changes.push([input[i][0], input[i][1], dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  12675. }
  12676. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  12677. source = prop;
  12678. }
  12679. instance.runHooks('afterSetDataAtRowProp', changes, source);
  12680. validateChanges(changes, source, function () {
  12681. applyChanges(changes, source);
  12682. });
  12683. };
  12684. /**
  12685. * Listen to the keyboard input on document body.
  12686. *
  12687. * @memberof Core#
  12688. * @function listen
  12689. * @since 0.11
  12690. */
  12691. this.listen = function () {
  12692. var invalidActiveElement = !document.activeElement || document.activeElement && document.activeElement.nodeName === void 0;
  12693. if (document.activeElement && document.activeElement !== document.body && !invalidActiveElement) {
  12694. document.activeElement.blur();
  12695. } else if (invalidActiveElement) {
  12696. // IE
  12697. document.body.focus();
  12698. }
  12699. activeGuid = instance.guid;
  12700. };
  12701. /**
  12702. * Stop listening to keyboard input on the document body.
  12703. *
  12704. * @memberof Core#
  12705. * @function unlisten
  12706. * @since 0.11
  12707. */
  12708. this.unlisten = function () {
  12709. if (this.isListening()) {
  12710. activeGuid = null;
  12711. }
  12712. };
  12713. /**
  12714. * Returns `true` if the current Handsontable instance is listening to keyboard input on document body.
  12715. *
  12716. * @memberof Core#
  12717. * @function isListening
  12718. * @since 0.11
  12719. * @returns {Boolean} `true` if the instance is listening, `false` otherwise.
  12720. */
  12721. this.isListening = function () {
  12722. return activeGuid === instance.guid;
  12723. };
  12724. /**
  12725. * Destroys the current editor, renders and selects the current cell.
  12726. *
  12727. * @memberof Core#
  12728. * @function destroyEditor
  12729. * @param {Boolean} [revertOriginal] If != `true`, edited data is saved. Otherwise the previous value is restored.
  12730. */
  12731. this.destroyEditor = function (revertOriginal) {
  12732. selection.refreshBorders(revertOriginal);
  12733. };
  12734. /**
  12735. * Populate cells at position with 2D input array (e.g. `[[1, 2], [3, 4]]`).
  12736. * Use `endRow`, `endCol` when you want to cut input when a certain row is reached.
  12737. * Optional `source` parameter (default value "populateFromArray") is used to identify this call in the resulting events (beforeChange, afterChange).
  12738. * Optional `populateMethod` parameter (default value "overwrite", possible values "shift_down" and "shift_right")
  12739. * has the same effect as pasteMode option {@link Options#pasteMode}
  12740. *
  12741. * @memberof Core#
  12742. * @function populateFromArray
  12743. * @since 0.9.0
  12744. * @param {Number} row Start visual row index.
  12745. * @param {Number} col Start visual column index.
  12746. * @param {Array} input 2d array
  12747. * @param {Number} [endRow] End visual row index (use when you want to cut input when certain row is reached).
  12748. * @param {Number} [endCol] End visual column index (use when you want to cut input when certain column is reached).
  12749. * @param {String} [source="populateFromArray"] Source string.
  12750. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  12751. * @param {String} direction Populate direction. (left|right|up|down)
  12752. * @param {Array} deltas Deltas array.
  12753. * @returns {Object|undefined} The ending TD element in pasted area (only if any cells were changed).
  12754. */
  12755. this.populateFromArray = function (row, col, input, endRow, endCol, source, method, direction, deltas) {
  12756. var c;
  12757. if (!((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && _typeof(input[0]) === 'object')) {
  12758. 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
  12759. }
  12760. c = typeof endRow === 'number' ? new _src.CellCoords(endRow, endCol) : null;
  12761. return grid.populateFromArray(new _src.CellCoords(row, col), input, c, source, method, direction, deltas);
  12762. };
  12763. /**
  12764. * Adds/removes data from the column. This function is modelled after Array.splice.
  12765. * Parameter `col` is the index of the column in which do you want to do splice.
  12766. * Parameter `index` is the row index at which to start changing the array.
  12767. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of the old array elements to remove.
  12768. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  12769. * If you don't specify any elements, spliceCol simply removes elements from the array.
  12770. * {@link DataMap#spliceCol}
  12771. *
  12772. * @memberof Core#
  12773. * @function spliceCol
  12774. * @since 0.9-beta2
  12775. * @param {Number} col Index of the column in which do you want to do splice.
  12776. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  12777. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  12778. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  12779. */
  12780. this.spliceCol = function (col, index, amount /* , elements... */) {
  12781. var _datamap;
  12782. return (_datamap = datamap).spliceCol.apply(_datamap, arguments);
  12783. };
  12784. /**
  12785. * Adds/removes data from the row. This function works is modelled after Array.splice.
  12786. * Parameter `row` is the index of row in which do you want to do splice.
  12787. * Parameter `index` is the column index at which to start changing the array.
  12788. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of old array elements to remove.
  12789. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  12790. * If you don't specify any elements, spliceCol simply removes elements from the array.
  12791. * {@link DataMap#spliceRow}
  12792. *
  12793. * @memberof Core#
  12794. * @function spliceRow
  12795. * @since 0.11
  12796. * @param {Number} row Index of column in which do you want to do splice.
  12797. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  12798. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  12799. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  12800. */
  12801. this.spliceRow = function (row, index, amount /* , elements... */) {
  12802. var _datamap2;
  12803. return (_datamap2 = datamap).spliceRow.apply(_datamap2, arguments);
  12804. };
  12805. /**
  12806. * Returns indexes of the currently selected cells as an array `[startRow, startCol, endRow, endCol]`.
  12807. *
  12808. * Start row and start col are the coordinates of the active cell (where the selection was started).
  12809. *
  12810. * @memberof Core#
  12811. * @function getSelected
  12812. * @returns {Array} Array of the selection's indexes.
  12813. */
  12814. this.getSelected = function () {
  12815. // https://github.com/handsontable/handsontable/issues/44 //cjl
  12816. if (selection.isSelected()) {
  12817. return [priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col];
  12818. }
  12819. };
  12820. /**
  12821. * Returns the current selection as a CellRange object.
  12822. *
  12823. * @memberof Core#
  12824. * @function getSelectedRange
  12825. * @since 0.11
  12826. * @returns {CellRange} Selected range object or undefined` if there is no selection.
  12827. */
  12828. this.getSelectedRange = function () {
  12829. // https://github.com/handsontable/handsontable/issues/44 //cjl
  12830. if (selection.isSelected()) {
  12831. return priv.selRange;
  12832. }
  12833. };
  12834. /**
  12835. * Rerender the table.
  12836. *
  12837. * @memberof Core#
  12838. * @function render
  12839. */
  12840. this.render = function () {
  12841. if (instance.view) {
  12842. instance.renderCall = true;
  12843. instance.forceFullRender = true; // used when data was changed
  12844. selection.refreshBorders(null, true);
  12845. }
  12846. };
  12847. /**
  12848. * Reset all cells in the grid to contain data from the data array.
  12849. *
  12850. * @memberof Core#
  12851. * @function loadData
  12852. * @param {Array} data Array of arrays or array of objects containing data.
  12853. * @fires Hooks#afterLoadData
  12854. * @fires Hooks#afterChange
  12855. */
  12856. this.loadData = function (data) {
  12857. if (Array.isArray(priv.settings.dataSchema)) {
  12858. instance.dataType = 'array';
  12859. } else if ((0, _function.isFunction)(priv.settings.dataSchema)) {
  12860. instance.dataType = 'function';
  12861. } else {
  12862. instance.dataType = 'object';
  12863. }
  12864. if (datamap) {
  12865. datamap.destroy();
  12866. }
  12867. datamap = new _dataMap2.default(instance, priv, GridSettings);
  12868. if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && data !== null) {
  12869. if (!(data.push && data.splice)) {
  12870. // check if data is array. Must use duck-type check so Backbone Collections also pass it
  12871. // when data is not an array, attempt to make a single-row array of it
  12872. data = [data];
  12873. }
  12874. } else if (data === null) {
  12875. data = [];
  12876. var row;
  12877. var r = 0;
  12878. var rlen = 0;
  12879. var dataSchema = datamap.getSchema();
  12880. for (r = 0, rlen = priv.settings.startRows; r < rlen; r++) {
  12881. if ((instance.dataType === 'object' || instance.dataType === 'function') && priv.settings.dataSchema) {
  12882. row = (0, _object.deepClone)(dataSchema);
  12883. data.push(row);
  12884. } else if (instance.dataType === 'array') {
  12885. row = (0, _object.deepClone)(dataSchema[0]);
  12886. data.push(row);
  12887. } else {
  12888. row = [];
  12889. for (var c = 0, clen = priv.settings.startCols; c < clen; c++) {
  12890. row.push(null);
  12891. }
  12892. data.push(row);
  12893. }
  12894. }
  12895. } else {
  12896. throw new Error('loadData only accepts array of objects or array of arrays (' + (typeof data === 'undefined' ? 'undefined' : _typeof(data)) + ' given)');
  12897. }
  12898. priv.isPopulated = false;
  12899. GridSettings.prototype.data = data;
  12900. if (Array.isArray(data[0])) {
  12901. instance.dataType = 'array';
  12902. }
  12903. datamap.dataSource = data;
  12904. dataSource.data = data;
  12905. dataSource.dataType = instance.dataType;
  12906. dataSource.colToProp = datamap.colToProp.bind(datamap);
  12907. dataSource.propToCol = datamap.propToCol.bind(datamap);
  12908. clearCellSettingCache();
  12909. grid.adjustRowsAndCols();
  12910. instance.runHooks('afterLoadData', priv.firstRun);
  12911. if (priv.firstRun) {
  12912. priv.firstRun = [null, 'loadData'];
  12913. } else {
  12914. instance.runHooks('afterChange', null, 'loadData');
  12915. instance.render();
  12916. }
  12917. priv.isPopulated = true;
  12918. function clearCellSettingCache() {
  12919. priv.cellSettings.length = 0;
  12920. }
  12921. };
  12922. /**
  12923. * Returns the current data object (the same one that was passed by `data` configuration option or `loadData` method,
  12924. * unless the `modifyRow` hook was used to trim some of the rows. If that's the case - use the {@link Core#getSourceData} method.).
  12925. * Optionally you can provide cell range by defining `row`, `col`, `row2`, `col2` to get only a fragment of grid data.
  12926. *
  12927. * Note: getData functionality changed with the release of version 0.20. If you're looking for the previous functionality,
  12928. * you should use the {@link Core#getSourceData} method.
  12929. *
  12930. * @memberof Core#
  12931. * @function getData
  12932. * @param {Number} [r] From visual row index.
  12933. * @param {Number} [c] From visual column index.
  12934. * @param {Number} [r2] To visual row index.
  12935. * @param {Number} [c2] To visual column index.
  12936. * @returns {Array} Array with the data.
  12937. */
  12938. this.getData = function (r, c, r2, c2) {
  12939. if ((0, _mixed.isUndefined)(r)) {
  12940. return datamap.getAll();
  12941. }
  12942. return datamap.getRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), datamap.DESTINATION_RENDERER);
  12943. };
  12944. /**
  12945. * Returns a string value of the selected range. Each column is separated by tab, each row is separated by a new line character.
  12946. * {@link DataMap#getCopyableText}
  12947. *
  12948. * @memberof Core#
  12949. * @function getCopyableText
  12950. * @since 0.11
  12951. * @param {Number} startRow From visual row index.
  12952. * @param {Number} startCol From visual column index.
  12953. * @param {Number} endRow To visual row index.
  12954. * @param {Number} endCol To visual column index.
  12955. * @returns {String}
  12956. */
  12957. this.getCopyableText = function (startRow, startCol, endRow, endCol) {
  12958. return datamap.getCopyableText(new _src.CellCoords(startRow, startCol), new _src.CellCoords(endRow, endCol));
  12959. };
  12960. /**
  12961. * Returns the data's copyable value at specified row and column index ({@link DataMap#getCopyable}).
  12962. *
  12963. * @memberof Core#
  12964. * @function getCopyableData
  12965. * @since 0.19.0
  12966. * @param {Number} row Visual row index.
  12967. * @param {Number} column Visual column index.
  12968. * @returns {String}
  12969. */
  12970. this.getCopyableData = function (row, column) {
  12971. return datamap.getCopyable(row, datamap.colToProp(column));
  12972. };
  12973. /**
  12974. * Returns schema provided by constructor settings. If it doesn't exist then it returns the schema based on the data
  12975. * structure in the first row.
  12976. *
  12977. * @memberof Core#
  12978. * @function getSchema
  12979. * @since 0.13.2
  12980. * @returns {Object} Schema object.
  12981. */
  12982. this.getSchema = function () {
  12983. return datamap.getSchema();
  12984. };
  12985. /**
  12986. * Use it if you need to change configuration after initialization. The `settings` parameter is an object containing the new
  12987. * settings, declared the same way as in the initial settings object.
  12988. * Note, that although the `updateSettings` method doesn't overwrite the previously declared settings, it might reset
  12989. * the settings made post-initialization. (for example - ignore changes made using the columnResize feature).
  12990. *
  12991. * @memberof Core#
  12992. * @function updateSettings
  12993. * @param {Object} settings New settings object.
  12994. * @param {Boolean} init Calls this method in the initialization mode. Internal use only.
  12995. * Used by API could be cause of the unexpected behaviour of the Handsontable.
  12996. * @example
  12997. * ```js
  12998. * hot.updateSettings({
  12999. * contextMenu: true,
  13000. * colHeaders: true,
  13001. * fixedRowsTop: 2
  13002. * });
  13003. * ```
  13004. * @fires Hooks#afterCellMetaReset
  13005. * @fires Hooks#afterUpdateSettings
  13006. */
  13007. this.updateSettings = function (settings, init) {
  13008. var columnsAsFunc = false;
  13009. var i = void 0;
  13010. var j = void 0;
  13011. var clen = void 0;
  13012. if ((0, _mixed.isDefined)(settings.rows)) {
  13013. throw new Error('"rows" setting is no longer supported. do you mean startRows, minRows or maxRows?');
  13014. }
  13015. if ((0, _mixed.isDefined)(settings.cols)) {
  13016. throw new Error('"cols" setting is no longer supported. do you mean startCols, minCols or maxCols?');
  13017. }
  13018. for (i in settings) {
  13019. if (i === 'data') {
  13020. /* eslint-disable no-continue */
  13021. continue; // loadData will be triggered later
  13022. } else if (_pluginHooks2.default.getSingleton().getRegistered().indexOf(i) > -1) {
  13023. if ((0, _function.isFunction)(settings[i]) || Array.isArray(settings[i])) {
  13024. settings[i].initialHook = true;
  13025. instance.addHook(i, settings[i]);
  13026. }
  13027. } else if (!init && (0, _object.hasOwnProperty)(settings, i)) {
  13028. // Update settings
  13029. GridSettings.prototype[i] = settings[i];
  13030. }
  13031. }
  13032. // Load data or create data map
  13033. if (settings.data === void 0 && priv.settings.data === void 0) {
  13034. instance.loadData(null); // data source created just now
  13035. } else if (settings.data !== void 0) {
  13036. instance.loadData(settings.data); // data source given as option
  13037. } else if (settings.columns !== void 0) {
  13038. datamap.createMap();
  13039. }
  13040. clen = instance.countCols();
  13041. var columnSetting = settings.columns || GridSettings.prototype.columns;
  13042. // Init columns constructors configuration
  13043. if (columnSetting && (0, _function.isFunction)(columnSetting)) {
  13044. clen = instance.countSourceCols();
  13045. columnsAsFunc = true;
  13046. }
  13047. // Clear cellSettings cache
  13048. if (settings.cell !== void 0 || settings.cells !== void 0 || settings.columns !== void 0) {
  13049. priv.cellSettings.length = 0;
  13050. }
  13051. if (clen > 0) {
  13052. var proto = void 0;
  13053. var column = void 0;
  13054. for (i = 0, j = 0; i < clen; i++) {
  13055. if (columnsAsFunc && !columnSetting(i)) {
  13056. /* eslint-disable no-continue */
  13057. continue;
  13058. }
  13059. priv.columnSettings[j] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  13060. // shortcut for prototype
  13061. proto = priv.columnSettings[j].prototype;
  13062. // Use settings provided by user
  13063. if (columnSetting) {
  13064. if (columnsAsFunc) {
  13065. column = columnSetting(i);
  13066. } else {
  13067. column = columnSetting[j];
  13068. }
  13069. if (column) {
  13070. (0, _object.extend)(proto, column);
  13071. (0, _object.extend)(proto, expandType(column));
  13072. }
  13073. }
  13074. j++;
  13075. }
  13076. }
  13077. if ((0, _mixed.isDefined)(settings.cell)) {
  13078. for (var key in settings.cell) {
  13079. if ((0, _object.hasOwnProperty)(settings.cell, key)) {
  13080. var cell = settings.cell[key];
  13081. instance.setCellMetaObject(cell.row, cell.col, cell);
  13082. }
  13083. }
  13084. }
  13085. instance.runHooks('afterCellMetaReset');
  13086. if ((0, _mixed.isDefined)(settings.className)) {
  13087. if (GridSettings.prototype.className) {
  13088. (0, _element.removeClass)(instance.rootElement, GridSettings.prototype.className);
  13089. }
  13090. if (settings.className) {
  13091. (0, _element.addClass)(instance.rootElement, settings.className);
  13092. }
  13093. }
  13094. var currentHeight = instance.rootElement.style.height;
  13095. if (currentHeight !== '') {
  13096. currentHeight = parseInt(instance.rootElement.style.height, 10);
  13097. }
  13098. var height = settings.height;
  13099. if ((0, _function.isFunction)(height)) {
  13100. height = height();
  13101. }
  13102. if (init) {
  13103. var initialStyle = instance.rootElement.getAttribute('style');
  13104. if (initialStyle) {
  13105. instance.rootElement.setAttribute('data-initialstyle', instance.rootElement.getAttribute('style'));
  13106. }
  13107. }
  13108. if (height === null) {
  13109. var _initialStyle = instance.rootElement.getAttribute('data-initialstyle');
  13110. if (_initialStyle && (_initialStyle.indexOf('height') > -1 || _initialStyle.indexOf('overflow') > -1)) {
  13111. instance.rootElement.setAttribute('style', _initialStyle);
  13112. } else {
  13113. instance.rootElement.style.height = '';
  13114. instance.rootElement.style.overflow = '';
  13115. }
  13116. } else if (height !== void 0) {
  13117. instance.rootElement.style.height = height + 'px';
  13118. instance.rootElement.style.overflow = 'hidden';
  13119. }
  13120. if (typeof settings.width !== 'undefined') {
  13121. var width = settings.width;
  13122. if ((0, _function.isFunction)(width)) {
  13123. width = width();
  13124. }
  13125. instance.rootElement.style.width = width + 'px';
  13126. }
  13127. if (!init) {
  13128. datamap.clearLengthCache(); // force clear cache length on updateSettings() #3416
  13129. if (instance.view) {
  13130. instance.view.wt.wtViewport.resetHasOversizedColumnHeadersMarked();
  13131. }
  13132. instance.runHooks('afterUpdateSettings');
  13133. }
  13134. grid.adjustRowsAndCols();
  13135. if (instance.view && !priv.firstRun) {
  13136. instance.forceFullRender = true; // used when data was changed
  13137. selection.refreshBorders(null, true);
  13138. }
  13139. if (!init && instance.view && (currentHeight === '' || height === '' || height === void 0) && currentHeight !== height) {
  13140. instance.view.wt.wtOverlays.updateMainScrollableElements();
  13141. }
  13142. };
  13143. /**
  13144. * Get value from the selected cell.
  13145. *
  13146. * @memberof Core#
  13147. * @function getValue
  13148. * @since 0.11
  13149. * @returns {*} Value of selected cell.
  13150. */
  13151. this.getValue = function () {
  13152. var sel = instance.getSelected();
  13153. if (GridSettings.prototype.getValue) {
  13154. if ((0, _function.isFunction)(GridSettings.prototype.getValue)) {
  13155. return GridSettings.prototype.getValue.call(instance);
  13156. } else if (sel) {
  13157. return instance.getData()[sel[0]][GridSettings.prototype.getValue];
  13158. }
  13159. } else if (sel) {
  13160. return instance.getDataAtCell(sel[0], sel[1]);
  13161. }
  13162. };
  13163. function expandType(obj) {
  13164. if (!(0, _object.hasOwnProperty)(obj, 'type')) {
  13165. // ignore obj.prototype.type
  13166. return;
  13167. }
  13168. var type,
  13169. expandedType = {};
  13170. if (_typeof(obj.type) === 'object') {
  13171. type = obj.type;
  13172. } else if (typeof obj.type === 'string') {
  13173. type = (0, _cellTypes.getCellType)(obj.type);
  13174. }
  13175. for (var i in type) {
  13176. if ((0, _object.hasOwnProperty)(type, i) && !(0, _object.hasOwnProperty)(obj, i)) {
  13177. expandedType[i] = type[i];
  13178. }
  13179. }
  13180. return expandedType;
  13181. }
  13182. /**
  13183. * Returns the object settings.
  13184. *
  13185. * @memberof Core#
  13186. * @function getSettings
  13187. * @returns {Object} Object containing the current grid settings.
  13188. */
  13189. this.getSettings = function () {
  13190. return priv.settings;
  13191. };
  13192. /**
  13193. * Clears the data from the grid. (The table settings remain intact.)
  13194. *
  13195. * @memberof Core#
  13196. * @function clear
  13197. * @since 0.11
  13198. */
  13199. this.clear = function () {
  13200. selection.selectAll();
  13201. selection.empty();
  13202. };
  13203. /**
  13204. * @memberof Core#
  13205. * @function alter
  13206. * @param {String} action See grid.alter for possible values: `"insert_row"`, `"insert_col"`, `"remove_row"`, `"remove_col"`
  13207. * @param {Number} index Visual index of the row/column before which the new row/column will be inserted/removed.
  13208. * @param {Number} [amount = 1] Amound of rows/columns to be inserted/removed.
  13209. * @param {String} [source] Source indicator.
  13210. * @param {Boolean} [keepEmptyRows] Flag for preventing deletion of empty rows.
  13211. * @description
  13212. *
  13213. * Allows altering the table structure by either inserting/removing rows or inserting/removing columns:
  13214. *
  13215. * Insert new row(s) above the row with a given `index`. If index is `null` or `undefined`, the new row will be
  13216. * added after the last row.
  13217. * ```js
  13218. * var hot = new Handsontable(document.getElementById('example'));
  13219. * hot.alter('insert_row', 10);
  13220. * ```
  13221. *
  13222. * Insert new column(s) before the column with a given `index`. If index is `null` or `undefined`, the new column
  13223. * will be added after the last column.
  13224. * ```js
  13225. * var hot = new Handsontable(document.getElementById('example'));
  13226. * hot.alter('insert_col', 10);
  13227. * ```
  13228. *
  13229. * Remove the row(s) at the given `index`.
  13230. * ```js
  13231. * var hot = new Handsontable(document.getElementById('example'));
  13232. * hot.alter('remove_row', 10);
  13233. * ```
  13234. *
  13235. * Remove the column(s) at the given `index`.
  13236. * ```js
  13237. * var hot = new Handsontable(document.getElementById('example'));
  13238. * hot.alter('remove_col', 10);
  13239. * ```
  13240. */
  13241. this.alter = function (action, index, amount, source, keepEmptyRows) {
  13242. grid.alter(action, index, amount, source, keepEmptyRows);
  13243. };
  13244. /**
  13245. * Returns a TD element for the given `row` and `col` arguments, if it is rendered on screen.
  13246. * Returns `null` if the TD is not rendered on screen (probably because that part of the table is not visible).
  13247. *
  13248. * @memberof Core#
  13249. * @function getCell
  13250. * @param {Number} row Visual row index.
  13251. * @param {Number} col Visual column index.
  13252. * @param {Boolean} topmost If set to true, it returns the TD element from the topmost overlay. For example,
  13253. * if the wanted cell is in the range of fixed rows, it will return a TD element from the `top` overlay.
  13254. * @returns {Element} The cell's TD element.
  13255. */
  13256. this.getCell = function (row, col, topmost) {
  13257. return instance.view.getCellAtCoords(new _src.CellCoords(row, col), topmost);
  13258. };
  13259. /**
  13260. * Returns the coordinates of the cell, provided as a HTML Element.
  13261. *
  13262. * @memberof Core#
  13263. * @function getCoords
  13264. * @param {Element} elem The HTML Element representing the cell.
  13265. * @returns {CellCoords} Visual coordinates object.
  13266. */
  13267. this.getCoords = function (elem) {
  13268. return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem);
  13269. };
  13270. /**
  13271. * Returns the property name that corresponds with the given column index. {@link DataMap#colToProp}
  13272. * If the data source is an array of arrays, it returns the columns index.
  13273. *
  13274. * @memberof Core#
  13275. * @function colToProp
  13276. * @param {Number} col Visual column index.
  13277. * @returns {String|Number} Column property or physical column index.
  13278. */
  13279. this.colToProp = function (col) {
  13280. return datamap.colToProp(col);
  13281. };
  13282. /**
  13283. * Returns column index that corresponds with the given property. {@link DataMap#propToCol}
  13284. *
  13285. * @memberof Core#
  13286. * @function propToCol
  13287. * @param {String|Number} prop Property name or physical column index.
  13288. * @returns {Number} Visual column index.
  13289. */
  13290. this.propToCol = function (prop) {
  13291. return datamap.propToCol(prop);
  13292. };
  13293. /**
  13294. * Translate physical row index into visual.
  13295. *
  13296. * @since 0.29.0
  13297. * @memberof Core#
  13298. * @function toVisualRow
  13299. * @param {Number} row Physical row index.
  13300. * @returns {Number} Returns visual row index.
  13301. */
  13302. this.toVisualRow = function (row) {
  13303. return recordTranslator.toVisualRow(row);
  13304. };
  13305. /**
  13306. * Translate physical column index into visual.
  13307. *
  13308. * @since 0.29.0
  13309. * @memberof Core#
  13310. * @function toVisualColumn
  13311. * @param {Number} column Physical column index.
  13312. * @returns {Number} Returns visual column index.
  13313. */
  13314. this.toVisualColumn = function (column) {
  13315. return recordTranslator.toVisualColumn(column);
  13316. };
  13317. /**
  13318. * Translate visual row index into physical.
  13319. * If displayed rows order is different than the order of rows stored in memory (i.e. sorting is applied)
  13320. * to retrieve valid physical row index you can use this method.
  13321. *
  13322. * @since 0.29.0
  13323. * @memberof Core#
  13324. * @function toPhysicalRow
  13325. * @param {Number} row Visual row index.
  13326. * @returns {Number} Returns physical row index.
  13327. */
  13328. this.toPhysicalRow = function (row) {
  13329. return recordTranslator.toPhysicalRow(row);
  13330. };
  13331. /**
  13332. * Translate visual column index into physical.
  13333. * If displayed columns order is different than the order of columns stored in memory (i.e. manual column move is applied)
  13334. * to retrieve valid physical column index you can use this method.
  13335. *
  13336. * @since 0.29.0
  13337. * @memberof Core#
  13338. * @function toPhysicalColumn
  13339. * @param {Number} column Visual column index.
  13340. * @returns {Number} Returns physical column index.
  13341. */
  13342. this.toPhysicalColumn = function (column) {
  13343. return recordTranslator.toPhysicalColumn(column);
  13344. };
  13345. /**
  13346. * @description
  13347. * Returns the cell value at `row`, `col`. `row` and `col` are the __visible__ indexes (note, that if columns were reordered or sorted,
  13348. * the currently visible order will be used).
  13349. *
  13350. * @memberof Core#
  13351. * @function getDataAtCell
  13352. * @param {Number} row Visual row index.
  13353. * @param {Number} col Visual column index.
  13354. * @returns {String|Boolean|null} Data at cell.
  13355. */
  13356. this.getDataAtCell = function (row, col) {
  13357. return datamap.get(row, datamap.colToProp(col));
  13358. };
  13359. /**
  13360. * Return value at `row`, `prop`. (Uses {@link DataMap#get})
  13361. *
  13362. * @memberof Core#
  13363. * @function getDataAtRowProp
  13364. * @param {Number} row Visual row index.
  13365. * @param {String} prop Property name.
  13366. * @returns {*} Cell value.
  13367. */
  13368. this.getDataAtRowProp = function (row, prop) {
  13369. return datamap.get(row, prop);
  13370. };
  13371. /**
  13372. * @description
  13373. * Returns array of column values from the data source. `col` is the __visible__ index of the column.
  13374. * Note, that if columns were reordered or sorted, the currently visible order will be used.
  13375. *
  13376. * @memberof Core#
  13377. * @function getDataAtCol
  13378. * @since 0.9-beta2
  13379. * @param {Number} col Visual column index.
  13380. * @returns {Array} Array of cell values.
  13381. */
  13382. this.getDataAtCol = function (col) {
  13383. var out = [];
  13384. 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)));
  13385. };
  13386. /**
  13387. * Given the object property name (e.g. `'first.name'`), returns an array of column's values from the data source.
  13388. * You can also provide a column index as the first argument.
  13389. *
  13390. * @memberof Core#
  13391. * @function getDataAtProp
  13392. * @since 0.9-beta2
  13393. * @param {String|Number} prop Property name / physical column index.
  13394. * @returns {Array} Array of cell values.
  13395. */
  13396. // TODO: Getting data from `datamap` should work on visual indexes.
  13397. this.getDataAtProp = function (prop) {
  13398. var out = [],
  13399. range;
  13400. range = datamap.getRange(new _src.CellCoords(0, datamap.propToCol(prop)), new _src.CellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
  13401. return out.concat.apply(out, _toConsumableArray(range));
  13402. };
  13403. /**
  13404. * Returns the source data object (the same that was passed by `data` configuration option or `loadData` method).
  13405. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  13406. *
  13407. * @memberof Core#
  13408. * @function getSourceData
  13409. * @since 0.20.0
  13410. * @param {Number} [r] From physical row index.
  13411. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  13412. * @param {Number} [r2] To physical row index.
  13413. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  13414. * @returns {Array} Array of grid data.
  13415. */
  13416. this.getSourceData = function (r, c, r2, c2) {
  13417. var data = void 0;
  13418. if (r === void 0) {
  13419. data = dataSource.getData();
  13420. } else {
  13421. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2));
  13422. }
  13423. return data;
  13424. };
  13425. /**
  13426. * Returns the source data object as an arrays of arrays format even when source data was provided in another format.
  13427. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  13428. *
  13429. * @memberof Core#
  13430. * @function getSourceDataArray
  13431. * @since 0.28.0
  13432. * @param {Number} [r] From physical row index.
  13433. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  13434. * @param {Number} [r2] To physical row index.
  13435. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  13436. * @returns {Array} An array of arrays.
  13437. */
  13438. this.getSourceDataArray = function (r, c, r2, c2) {
  13439. var data = void 0;
  13440. if (r === void 0) {
  13441. data = dataSource.getData(true);
  13442. } else {
  13443. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), true);
  13444. }
  13445. return data;
  13446. };
  13447. /**
  13448. * Returns an array of column values from the data source. `col` is the index of the row in the data source.
  13449. *
  13450. * @memberof Core#
  13451. * @function getSourceDataAtCol
  13452. * @since 0.11.0-beta3
  13453. * @param {Number} column Visual column index.
  13454. * @returns {Array} Array of the column's cell values.
  13455. */
  13456. // TODO: Getting data from `sourceData` should work always on physical indexes.
  13457. this.getSourceDataAtCol = function (column) {
  13458. return dataSource.getAtColumn(column);
  13459. };
  13460. /**
  13461. * 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.
  13462. *
  13463. * @memberof Core#
  13464. * @function getSourceDataAtRow
  13465. * @since 0.11.0-beta3
  13466. * @param {Number} row Physical row index.
  13467. * @returns {Array|Object} Single row of data.
  13468. */
  13469. this.getSourceDataAtRow = function (row) {
  13470. return dataSource.getAtRow(row);
  13471. };
  13472. /**
  13473. * Returns a single value from the data source.
  13474. *
  13475. * @memberof Core#
  13476. * @function getSourceDataAtCell
  13477. * @param {Number} row Physical row index.
  13478. * @param {Number} column Visual column index.
  13479. * @returns {*} Cell data.
  13480. * @since 0.20.0
  13481. */
  13482. // TODO: Getting data from `sourceData` should work always on physical indexes.
  13483. this.getSourceDataAtCell = function (row, column) {
  13484. return dataSource.getAtCell(row, column);
  13485. };
  13486. /**
  13487. * @description
  13488. * Returns a single row of the data. The `row` argument is the __visible__ index of the row.
  13489. *
  13490. * @memberof Core#
  13491. * @function getDataAtRow
  13492. * @param {Number} row Visual row index.
  13493. * @returns {Array} Array of row's cell data.
  13494. * @since 0.9-beta2
  13495. */
  13496. this.getDataAtRow = function (row) {
  13497. var data = datamap.getRange(new _src.CellCoords(row, 0), new _src.CellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
  13498. return data[0] || [];
  13499. };
  13500. /**
  13501. * @description
  13502. * Returns a data type defined in the Handsontable settings under the `type` key ([Options#type](http://docs.handsontable.com/Options.html#type)).
  13503. * If there are cells with different types in the selected range, it returns `'mixed'`.
  13504. *
  13505. * @since 0.18.1
  13506. * @memberof Core#
  13507. * @function getDataType
  13508. * @param {Number} rowFrom From visual row index.
  13509. * @param {Number} columnFrom From visual column index.
  13510. * @param {Number} rowTo To visual row index.
  13511. * @param {Number} columnTo To visual column index.
  13512. * @returns {String} Cell type (e.q: `'mixed'`, `'text'`, `'numeric'`, `'autocomplete'`).
  13513. */
  13514. this.getDataType = function (rowFrom, columnFrom, rowTo, columnTo) {
  13515. var _this = this;
  13516. var previousType = null;
  13517. var currentType = null;
  13518. if (rowFrom === void 0) {
  13519. rowFrom = 0;
  13520. rowTo = this.countRows();
  13521. columnFrom = 0;
  13522. columnTo = this.countCols();
  13523. }
  13524. if (rowTo === void 0) {
  13525. rowTo = rowFrom;
  13526. }
  13527. if (columnTo === void 0) {
  13528. columnTo = columnFrom;
  13529. }
  13530. var type = 'mixed';
  13531. (0, _number.rangeEach)(Math.min(rowFrom, rowTo), Math.max(rowFrom, rowTo), function (row) {
  13532. var isTypeEqual = true;
  13533. (0, _number.rangeEach)(Math.min(columnFrom, columnTo), Math.max(columnFrom, columnTo), function (column) {
  13534. var cellType = _this.getCellMeta(row, column);
  13535. currentType = cellType.type;
  13536. if (previousType) {
  13537. isTypeEqual = previousType === currentType;
  13538. } else {
  13539. previousType = currentType;
  13540. }
  13541. return isTypeEqual;
  13542. });
  13543. type = isTypeEqual ? currentType : 'mixed';
  13544. return isTypeEqual;
  13545. });
  13546. return type;
  13547. };
  13548. /**
  13549. * Remove a property defined by the `key` argument from the cell meta object for the provided `row` and `col` coordinates.
  13550. *
  13551. * @memberof Core#
  13552. * @function removeCellMeta
  13553. * @param {Number} row Visual/physical row index.
  13554. * @param {Number} col Visual/physical column index.
  13555. * @param {String} key Property name.
  13556. */
  13557. this.removeCellMeta = function (row, col, key) {
  13558. // TODO: First we use indexes as visual, after that, the same indexes are used as physical. This MUST be improved.
  13559. var cellMeta = instance.getCellMeta(row, col);
  13560. if (cellMeta[key] != undefined) {
  13561. delete priv.cellSettings[row][col][key];
  13562. }
  13563. };
  13564. /**
  13565. * Remove one or more rows from the cell meta object.
  13566. *
  13567. * @since 0.30.0
  13568. * @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.
  13569. * @param {Number} deleteAmount The number of items to be removed. If set to 0, no items will be removed.
  13570. * @param {Array} items The new items to be added to the array.
  13571. */
  13572. this.spliceCellsMeta = function (index, deleteAmount) {
  13573. var _priv$cellSettings;
  13574. for (var _len2 = arguments.length, items = Array(_len2 > 2 ? _len2 - 2 : 0), _key = 2; _key < _len2; _key++) {
  13575. items[_key - 2] = arguments[_key];
  13576. }
  13577. (_priv$cellSettings = priv.cellSettings).splice.apply(_priv$cellSettings, [index, deleteAmount].concat(items));
  13578. };
  13579. /**
  13580. * Set cell meta data object defined by `prop` to the corresponding params `row` and `col`.
  13581. *
  13582. * @memberof Core#
  13583. * @function setCellMetaObject
  13584. * @since 0.11
  13585. * @param {Number} row Visual row index.
  13586. * @param {Number} col Visual column index.
  13587. * @param {Object} prop Meta object.
  13588. */
  13589. this.setCellMetaObject = function (row, col, prop) {
  13590. if ((typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object') {
  13591. for (var key in prop) {
  13592. if ((0, _object.hasOwnProperty)(prop, key)) {
  13593. var value = prop[key];
  13594. this.setCellMeta(row, col, key, value);
  13595. }
  13596. }
  13597. }
  13598. };
  13599. /**
  13600. * Sets a property defined by the `key` object to the meta object of a cell corresponding to params `row` and `col`.
  13601. *
  13602. * @memberof Core#
  13603. * @function setCellMeta
  13604. * @since 0.11
  13605. * @param {Number} row Visual row index.
  13606. * @param {Number} col Visual column index.
  13607. * @param {String} key Property name.
  13608. * @param {String} val Property value.
  13609. * @fires Hooks#afterSetCellMeta
  13610. */
  13611. this.setCellMeta = function (row, col, key, val) {
  13612. var _recordTranslator$toP = recordTranslator.toPhysical(row, col);
  13613. var _recordTranslator$toP2 = _slicedToArray(_recordTranslator$toP, 2);
  13614. row = _recordTranslator$toP2[0];
  13615. col = _recordTranslator$toP2[1];
  13616. if (!priv.columnSettings[col]) {
  13617. priv.columnSettings[col] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  13618. }
  13619. if (!priv.cellSettings[row]) {
  13620. priv.cellSettings[row] = [];
  13621. }
  13622. if (!priv.cellSettings[row][col]) {
  13623. priv.cellSettings[row][col] = new priv.columnSettings[col]();
  13624. }
  13625. priv.cellSettings[row][col][key] = val;
  13626. instance.runHooks('afterSetCellMeta', row, col, key, val);
  13627. };
  13628. /**
  13629. * Get all the cells meta settings at least once generated in the table (in order of cell initialization).
  13630. *
  13631. * @since 0.19.0
  13632. * @returns {Array} Returns Array of ColumnSettings object.
  13633. */
  13634. this.getCellsMeta = function () {
  13635. return (0, _array.arrayFlatten)(priv.cellSettings);
  13636. };
  13637. /**
  13638. * Returns the cell properties object for the given `row` and `col` coordinates.
  13639. *
  13640. * @memberof Core#
  13641. * @function getCellMeta
  13642. * @param {Number} row Visual row index.
  13643. * @param {Number} col Visual column index.
  13644. * @returns {Object} The cell properties object.
  13645. * @fires Hooks#beforeGetCellMeta
  13646. * @fires Hooks#afterGetCellMeta
  13647. */
  13648. this.getCellMeta = function (row, col) {
  13649. var prop = datamap.colToProp(col),
  13650. cellProperties;
  13651. var visualRow = row;
  13652. var visualCol = col;
  13653. var _recordTranslator$toP3 = recordTranslator.toPhysical(row, col);
  13654. var _recordTranslator$toP4 = _slicedToArray(_recordTranslator$toP3, 2);
  13655. row = _recordTranslator$toP4[0];
  13656. col = _recordTranslator$toP4[1];
  13657. if (!priv.columnSettings[col]) {
  13658. priv.columnSettings[col] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  13659. }
  13660. if (!priv.cellSettings[row]) {
  13661. priv.cellSettings[row] = [];
  13662. }
  13663. if (!priv.cellSettings[row][col]) {
  13664. priv.cellSettings[row][col] = new priv.columnSettings[col]();
  13665. }
  13666. cellProperties = priv.cellSettings[row][col]; // retrieve cellProperties from cache
  13667. cellProperties.row = row;
  13668. cellProperties.col = col;
  13669. cellProperties.visualRow = visualRow;
  13670. cellProperties.visualCol = visualCol;
  13671. cellProperties.prop = prop;
  13672. cellProperties.instance = instance;
  13673. instance.runHooks('beforeGetCellMeta', row, col, cellProperties);
  13674. (0, _object.extend)(cellProperties, expandType(cellProperties)); // for `type` added in beforeGetCellMeta
  13675. if (cellProperties.cells) {
  13676. var settings = cellProperties.cells.call(cellProperties, row, col, prop);
  13677. if (settings) {
  13678. (0, _object.extend)(cellProperties, settings);
  13679. (0, _object.extend)(cellProperties, expandType(settings)); // for `type` added in cells
  13680. }
  13681. }
  13682. instance.runHooks('afterGetCellMeta', row, col, cellProperties);
  13683. return cellProperties;
  13684. };
  13685. /**
  13686. * Returns a row off the cell meta array.
  13687. *
  13688. * @memberof Core#
  13689. * @function getCellMetaAtRow
  13690. * @since 0.30.0
  13691. * @param {Number} row Physical index of the row to return cell meta for.
  13692. * @returns {Array}
  13693. */
  13694. this.getCellMetaAtRow = function (row) {
  13695. return priv.cellSettings[row];
  13696. };
  13697. /**
  13698. * Checks if the data format and config allows user to modify the column structure.
  13699. * @returns {boolean}
  13700. */
  13701. this.isColumnModificationAllowed = function () {
  13702. return !(instance.dataType === 'object' || instance.getSettings().columns);
  13703. };
  13704. var rendererLookup = (0, _data.cellMethodLookupFactory)('renderer');
  13705. /**
  13706. * Returns the cell renderer function by given `row` and `col` arguments.
  13707. *
  13708. * @memberof Core#
  13709. * @function getCellRenderer
  13710. * @since 0.11
  13711. * @param {Number|Object} row Visual row index or cell meta object.
  13712. * @param {Number} [col] Visual column index.
  13713. * @returns {Function} The renderer function.
  13714. */
  13715. this.getCellRenderer = function (row, col) {
  13716. return (0, _renderers.getRenderer)(rendererLookup.call(this, row, col));
  13717. };
  13718. /**
  13719. * Returns the cell editor by the provided `row` and `col` arguments.
  13720. *
  13721. * @memberof Core#
  13722. * @function getCellEditor
  13723. * @param {Number} row Visual row index.
  13724. * @param {Number} col Visual column index.
  13725. * @returns {Object} The Editor object.
  13726. */
  13727. this.getCellEditor = (0, _data.cellMethodLookupFactory)('editor');
  13728. var validatorLookup = (0, _data.cellMethodLookupFactory)('validator');
  13729. /**
  13730. * Returns the cell validator by `row` and `col`, provided a validator is defined. If not - it doesn't return anything.
  13731. *
  13732. * @memberof Core#
  13733. * @function getCellValidator
  13734. * @param {Number} row Visual row index.
  13735. * @param {Number} col Visual column index.
  13736. * @returns {Function|RegExp|undefined} The validator function.
  13737. */
  13738. this.getCellValidator = function (row, col) {
  13739. var validator = validatorLookup.call(this, row, col);
  13740. if (typeof validator === 'string') {
  13741. validator = (0, _validators.getValidator)(validator);
  13742. }
  13743. return validator;
  13744. };
  13745. /**
  13746. * Validates all cells using their validator functions and calls callback when finished.
  13747. *
  13748. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  13749. *
  13750. * @memberof Core#
  13751. * @function validateCells
  13752. * @param {Function} [callback] The callback function.
  13753. */
  13754. this.validateCells = function (callback) {
  13755. var waitingForValidator = new ValidatorsQueue();
  13756. if (callback) {
  13757. waitingForValidator.onQueueEmpty = callback;
  13758. }
  13759. var i = instance.countRows() - 1;
  13760. while (i >= 0) {
  13761. var j = instance.countCols() - 1;
  13762. while (j >= 0) {
  13763. waitingForValidator.addValidatorToQueue();
  13764. instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function (result) {
  13765. if (typeof result !== 'boolean') {
  13766. throw new Error('Validation error: result is not boolean');
  13767. }
  13768. if (result === false) {
  13769. waitingForValidator.valid = false;
  13770. }
  13771. waitingForValidator.removeValidatorFormQueue();
  13772. }, 'validateCells');
  13773. j--;
  13774. }
  13775. i--;
  13776. }
  13777. waitingForValidator.checkIfQueueIsEmpty();
  13778. };
  13779. /**
  13780. * 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.
  13781. *
  13782. * @memberof Core#
  13783. * @function getRowHeader
  13784. * @param {Number} [row] Visual row index.
  13785. * @fires Hooks#modifyRowHeader
  13786. * @returns {Array|String} Array of header values / single header value.
  13787. */
  13788. this.getRowHeader = function (row) {
  13789. var rowHeader = priv.settings.rowHeaders;
  13790. if (row !== void 0) {
  13791. row = instance.runHooks('modifyRowHeader', row);
  13792. }
  13793. if (row === void 0) {
  13794. rowHeader = [];
  13795. (0, _number.rangeEach)(instance.countRows() - 1, function (i) {
  13796. rowHeader.push(instance.getRowHeader(i));
  13797. });
  13798. } else if (Array.isArray(rowHeader) && rowHeader[row] !== void 0) {
  13799. rowHeader = rowHeader[row];
  13800. } else if ((0, _function.isFunction)(rowHeader)) {
  13801. rowHeader = rowHeader(row);
  13802. } else if (rowHeader && typeof rowHeader !== 'string' && typeof rowHeader !== 'number') {
  13803. rowHeader = row + 1;
  13804. }
  13805. return rowHeader;
  13806. };
  13807. /**
  13808. * Returns information about if this table is configured to display row headers.
  13809. *
  13810. * @memberof Core#
  13811. * @function hasRowHeaders
  13812. * @returns {Boolean} `true` if the instance has the row headers enabled, `false` otherwise.
  13813. * @since 0.11
  13814. */
  13815. this.hasRowHeaders = function () {
  13816. return !!priv.settings.rowHeaders;
  13817. };
  13818. /**
  13819. * Returns information about if this table is configured to display column headers.
  13820. *
  13821. * @memberof Core#
  13822. * @function hasColHeaders
  13823. * @since 0.11
  13824. * @returns {Boolean} `True` if the instance has the column headers enabled, `false` otherwise.
  13825. */
  13826. this.hasColHeaders = function () {
  13827. if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) {
  13828. // Polymer has empty value = null
  13829. return !!priv.settings.colHeaders;
  13830. }
  13831. for (var i = 0, ilen = instance.countCols(); i < ilen; i++) {
  13832. if (instance.getColHeader(i)) {
  13833. return true;
  13834. }
  13835. }
  13836. return false;
  13837. };
  13838. /**
  13839. * 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.
  13840. *
  13841. * @memberof Core#
  13842. * @function getColHeader
  13843. * @param {Number} [col] Visual column index.
  13844. * @fires Hooks#modifyColHeader
  13845. * @returns {Array|String} The column header(s).
  13846. */
  13847. this.getColHeader = function (col) {
  13848. var columnsAsFunc = priv.settings.columns && (0, _function.isFunction)(priv.settings.columns);
  13849. var result = priv.settings.colHeaders;
  13850. col = instance.runHooks('modifyColHeader', col);
  13851. if (col === void 0) {
  13852. var out = [];
  13853. var ilen = columnsAsFunc ? instance.countSourceCols() : instance.countCols();
  13854. for (var i = 0; i < ilen; i++) {
  13855. out.push(instance.getColHeader(i));
  13856. }
  13857. result = out;
  13858. } else {
  13859. var translateVisualIndexToColumns = function translateVisualIndexToColumns(col) {
  13860. var arr = [];
  13861. var columnsLen = instance.countSourceCols();
  13862. var index = 0;
  13863. for (; index < columnsLen; index++) {
  13864. if ((0, _function.isFunction)(instance.getSettings().columns) && instance.getSettings().columns(index)) {
  13865. arr.push(index);
  13866. }
  13867. }
  13868. return arr[col];
  13869. };
  13870. var baseCol = col;
  13871. col = instance.runHooks('modifyCol', col);
  13872. var prop = translateVisualIndexToColumns(col);
  13873. if (priv.settings.columns && (0, _function.isFunction)(priv.settings.columns) && priv.settings.columns(prop) && priv.settings.columns(prop).title) {
  13874. result = priv.settings.columns(prop).title;
  13875. } else if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) {
  13876. result = priv.settings.columns[col].title;
  13877. } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) {
  13878. result = priv.settings.colHeaders[col];
  13879. } else if ((0, _function.isFunction)(priv.settings.colHeaders)) {
  13880. result = priv.settings.colHeaders(col);
  13881. } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') {
  13882. result = (0, _data.spreadsheetColumnLabel)(baseCol); // see #1458
  13883. }
  13884. }
  13885. return result;
  13886. };
  13887. /**
  13888. * Return column width from settings (no guessing). Private use intended.
  13889. *
  13890. * @private
  13891. * @memberof Core#
  13892. * @function _getColWidthFromSettings
  13893. * @param {Number} col Visual col index.
  13894. * @returns {Number}
  13895. */
  13896. this._getColWidthFromSettings = function (col) {
  13897. var cellProperties = instance.getCellMeta(0, col);
  13898. var width = cellProperties.width;
  13899. if (width === void 0 || width === priv.settings.width) {
  13900. width = cellProperties.colWidths;
  13901. }
  13902. if (width !== void 0 && width !== null) {
  13903. switch (typeof width === 'undefined' ? 'undefined' : _typeof(width)) {
  13904. case 'object':
  13905. // array
  13906. width = width[col];
  13907. break;
  13908. case 'function':
  13909. width = width(col);
  13910. break;
  13911. default:
  13912. break;
  13913. }
  13914. if (typeof width === 'string') {
  13915. width = parseInt(width, 10);
  13916. }
  13917. }
  13918. return width;
  13919. };
  13920. /**
  13921. * Returns the width of the requested column.
  13922. *
  13923. * @memberof Core#
  13924. * @function getColWidth
  13925. * @since 0.11
  13926. * @param {Number} col Visual column index.
  13927. * @returns {Number} Column width.
  13928. * @fires Hooks#modifyColWidth
  13929. */
  13930. this.getColWidth = function (col) {
  13931. var width = instance._getColWidthFromSettings(col);
  13932. width = instance.runHooks('modifyColWidth', width, col);
  13933. if (width === void 0) {
  13934. width = _src.ViewportColumnsCalculator.DEFAULT_WIDTH;
  13935. }
  13936. return width;
  13937. };
  13938. /**
  13939. * Return row height from settings (no guessing). Private use intended.
  13940. *
  13941. * @private
  13942. * @memberof Core#
  13943. * @function _getRowHeightFromSettings
  13944. * @param {Number} row Visual row index.
  13945. * @returns {Number}
  13946. */
  13947. this._getRowHeightFromSettings = function (row) {
  13948. // let cellProperties = instance.getCellMeta(row, 0);
  13949. // let height = cellProperties.height;
  13950. //
  13951. // if (height === void 0 || height === priv.settings.height) {
  13952. // height = cellProperties.rowHeights;
  13953. // }
  13954. var height = priv.settings.rowHeights;
  13955. if (height !== void 0 && height !== null) {
  13956. switch (typeof height === 'undefined' ? 'undefined' : _typeof(height)) {
  13957. case 'object':
  13958. // array
  13959. height = height[row];
  13960. break;
  13961. case 'function':
  13962. height = height(row);
  13963. break;
  13964. default:
  13965. break;
  13966. }
  13967. if (typeof height === 'string') {
  13968. height = parseInt(height, 10);
  13969. }
  13970. }
  13971. return height;
  13972. };
  13973. /**
  13974. * Returns the row height.
  13975. *
  13976. * @memberof Core#
  13977. * @function getRowHeight
  13978. * @since 0.11
  13979. * @param {Number} row Visual row index.
  13980. * @returns {Number} The given row's height.
  13981. * @fires Hooks#modifyRowHeight
  13982. */
  13983. this.getRowHeight = function (row) {
  13984. var height = instance._getRowHeightFromSettings(row);
  13985. height = instance.runHooks('modifyRowHeight', height, row);
  13986. return height;
  13987. };
  13988. /**
  13989. * Returns the total number of rows in the data source.
  13990. *
  13991. * @memberof Core#
  13992. * @function countSourceRows
  13993. * @since 0.20.0
  13994. * @returns {Number} Total number in rows in data source.
  13995. */
  13996. this.countSourceRows = function () {
  13997. var sourceLength = instance.runHooks('modifySourceLength');
  13998. return sourceLength || (instance.getSourceData() ? instance.getSourceData().length : 0);
  13999. };
  14000. /**
  14001. * Returns the total number of columns in the data source.
  14002. *
  14003. * @memberof Core#
  14004. * @function countSourceCols
  14005. * @since 0.26.1
  14006. * @returns {Number} Total number in columns in data source.
  14007. */
  14008. this.countSourceCols = function () {
  14009. var len = 0;
  14010. var obj = instance.getSourceData() && instance.getSourceData()[0] ? instance.getSourceData()[0] : [];
  14011. if ((0, _object.isObject)(obj)) {
  14012. len = (0, _object.deepObjectSize)(obj);
  14013. } else {
  14014. len = obj.length || 0;
  14015. }
  14016. return len;
  14017. };
  14018. /**
  14019. * Returns the total number of rows in the grid.
  14020. *
  14021. * @memberof Core#
  14022. * @function countRows
  14023. * @returns {Number} Total number in rows the grid.
  14024. */
  14025. this.countRows = function () {
  14026. return datamap.getLength();
  14027. };
  14028. /**
  14029. * Returns the total number of columns in the grid.
  14030. *
  14031. * @memberof Core#
  14032. * @function countCols
  14033. * @returns {Number} Total number of columns.
  14034. */
  14035. this.countCols = function () {
  14036. var maxCols = this.getSettings().maxCols;
  14037. var dataHasLength = false;
  14038. var dataLen = 0;
  14039. if (instance.dataType === 'array') {
  14040. dataHasLength = priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length;
  14041. }
  14042. if (dataHasLength) {
  14043. dataLen = priv.settings.data[0].length;
  14044. }
  14045. if (priv.settings.columns) {
  14046. var columnsIsFunction = (0, _function.isFunction)(priv.settings.columns);
  14047. if (columnsIsFunction) {
  14048. if (instance.dataType === 'array') {
  14049. var columnLen = 0;
  14050. for (var i = 0; i < dataLen; i++) {
  14051. if (priv.settings.columns(i)) {
  14052. columnLen++;
  14053. }
  14054. }
  14055. dataLen = columnLen;
  14056. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  14057. dataLen = datamap.colToPropCache.length;
  14058. }
  14059. } else {
  14060. dataLen = priv.settings.columns.length;
  14061. }
  14062. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  14063. dataLen = datamap.colToPropCache.length;
  14064. }
  14065. return Math.min(maxCols, dataLen);
  14066. };
  14067. /**
  14068. * Returns an visual index of the first rendered row.
  14069. *
  14070. * @memberof Core#
  14071. * @function rowOffset
  14072. * @returns {Number} Visual index of first rendered row.
  14073. */
  14074. this.rowOffset = function () {
  14075. return instance.view.wt.wtTable.getFirstRenderedRow();
  14076. };
  14077. /**
  14078. * Returns the visual index of the first rendered column.
  14079. *
  14080. * @memberof Core#
  14081. * @function colOffset
  14082. * @returns {Number} Visual index of the first visible column.
  14083. */
  14084. this.colOffset = function () {
  14085. return instance.view.wt.wtTable.getFirstRenderedColumn();
  14086. };
  14087. /**
  14088. * Returns the number of rendered rows (including rows partially or fully rendered outside viewport).
  14089. *
  14090. * @memberof Core#
  14091. * @function countRenderedRows
  14092. * @returns {Number} Returns -1 if table is not visible.
  14093. */
  14094. this.countRenderedRows = function () {
  14095. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1;
  14096. };
  14097. /**
  14098. * Returns the number of visible rows (rendered rows that fully fit inside viewport).
  14099. *
  14100. * @memberof Core#
  14101. * @function countVisibleRows
  14102. * @returns {Number} Number of visible rows or -1.
  14103. */
  14104. this.countVisibleRows = function () {
  14105. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1;
  14106. };
  14107. /**
  14108. * Returns the number of rendered columns (including columns partially or fully rendered outside viewport).
  14109. *
  14110. * @memberof Core#
  14111. * @function countRenderedCols
  14112. * @returns {Number} Returns -1 if table is not visible.
  14113. */
  14114. this.countRenderedCols = function () {
  14115. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1;
  14116. };
  14117. /**
  14118. * Returns the number of visible columns. Returns -1 if table is not visible
  14119. *
  14120. * @memberof Core#
  14121. * @function countVisibleCols
  14122. * @return {Number} Number of visible columns or -1.
  14123. */
  14124. this.countVisibleCols = function () {
  14125. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1;
  14126. };
  14127. /**
  14128. * Returns the number of empty rows. If the optional ending parameter is `true`, returns the
  14129. * number of empty rows at the bottom of the table.
  14130. *
  14131. * @memberof Core#
  14132. * @function countEmptyRows
  14133. * @param {Boolean} [ending] If `true`, will only count empty rows at the end of the data source.
  14134. * @returns {Number} Count empty rows
  14135. * @fires Hooks#modifyRow
  14136. */
  14137. this.countEmptyRows = function (ending) {
  14138. var i = instance.countRows() - 1,
  14139. empty = 0,
  14140. row;
  14141. while (i >= 0) {
  14142. row = instance.runHooks('modifyRow', i);
  14143. if (instance.isEmptyRow(row)) {
  14144. empty++;
  14145. } else if (ending) {
  14146. break;
  14147. }
  14148. i--;
  14149. }
  14150. return empty;
  14151. };
  14152. /**
  14153. * Returns the number of empty columns. If the optional ending parameter is `true`, returns the number of empty
  14154. * columns at right hand edge of the table.
  14155. *
  14156. * @memberof Core#
  14157. * @function countEmptyCols
  14158. * @param {Boolean} [ending] If `true`, will only count empty columns at the end of the data source row.
  14159. * @returns {Number} Count empty cols
  14160. */
  14161. this.countEmptyCols = function (ending) {
  14162. if (instance.countRows() < 1) {
  14163. return 0;
  14164. }
  14165. var i = instance.countCols() - 1,
  14166. empty = 0;
  14167. while (i >= 0) {
  14168. if (instance.isEmptyCol(i)) {
  14169. empty++;
  14170. } else if (ending) {
  14171. break;
  14172. }
  14173. i--;
  14174. }
  14175. return empty;
  14176. };
  14177. /**
  14178. * Check if all cells in the row declared by the `row` argument are empty.
  14179. *
  14180. * @memberof Core#
  14181. * @function isEmptyRow
  14182. * @param {Number} row Row index.
  14183. * @returns {Boolean} `true` if the row at the given `row` is empty, `false` otherwise.
  14184. */
  14185. this.isEmptyRow = function (row) {
  14186. return priv.settings.isEmptyRow.call(instance, row);
  14187. };
  14188. /**
  14189. * Check if all cells in the the column declared by the `col` argument are empty.
  14190. *
  14191. * @memberof Core#
  14192. * @function isEmptyCol
  14193. * @param {Number} col Column index.
  14194. * @returns {Boolean} `true` if the column at the given `col` is empty, `false` otherwise.
  14195. */
  14196. this.isEmptyCol = function (col) {
  14197. return priv.settings.isEmptyCol.call(instance, col);
  14198. };
  14199. /**
  14200. * Select cell specified by `row` and `col` values or a range of cells finishing at `endRow`, `endCol`.
  14201. * By default, viewport will be scrolled to selection.
  14202. * After the `selectCell` method had finished, the instance will be listening to keyboard input on the document.
  14203. *
  14204. * @memberof Core#
  14205. * @function selectCell
  14206. * @param {Number} row Visual row index.
  14207. * @param {Number} col Visual column index.
  14208. * @param {Number} [endRow] Visual end row index (if selecting a range).
  14209. * @param {Number} [endCol] Visual end column index (if selecting a range).
  14210. * @param {Boolean} [scrollToCell=true] If `true`, the viewport will be scrolled to the selection.
  14211. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  14212. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  14213. */
  14214. this.selectCell = function (row, col, endRow, endCol, scrollToCell, changeListener) {
  14215. var coords;
  14216. changeListener = (0, _mixed.isUndefined)(changeListener) || changeListener === true;
  14217. if (typeof row !== 'number' || row < 0 || row >= instance.countRows()) {
  14218. return false;
  14219. }
  14220. if (typeof col !== 'number' || col < 0 || col >= instance.countCols()) {
  14221. return false;
  14222. }
  14223. if ((0, _mixed.isDefined)(endRow)) {
  14224. if (typeof endRow !== 'number' || endRow < 0 || endRow >= instance.countRows()) {
  14225. return false;
  14226. }
  14227. if (typeof endCol !== 'number' || endCol < 0 || endCol >= instance.countCols()) {
  14228. return false;
  14229. }
  14230. }
  14231. coords = new _src.CellCoords(row, col);
  14232. priv.selRange = new _src.CellRange(coords, coords, coords);
  14233. if (changeListener) {
  14234. instance.listen();
  14235. }
  14236. if ((0, _mixed.isUndefined)(endRow)) {
  14237. selection.setRangeEnd(priv.selRange.from, scrollToCell);
  14238. } else {
  14239. selection.setRangeEnd(new _src.CellCoords(endRow, endCol), scrollToCell);
  14240. }
  14241. instance.selection.finish();
  14242. return true;
  14243. };
  14244. /**
  14245. * Select the cell specified by the `row` and `prop` arguments, or a range finishing at `endRow`, `endProp`.
  14246. * By default, viewport will be scrolled to selection.
  14247. *
  14248. * @memberof Core#
  14249. * @function selectCellByProp
  14250. * @param {Number} row Visual row index.
  14251. * @param {String} prop Property name.
  14252. * @param {Number} [endRow] visual end row index (if selecting a range).
  14253. * @param {String} [endProp] End property name (if selecting a range).
  14254. * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to the selection.
  14255. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  14256. */
  14257. this.selectCellByProp = function (row, prop, endRow, endProp, scrollToCell) {
  14258. var _instance5;
  14259. arguments[1] = datamap.propToCol(arguments[1]);
  14260. if ((0, _mixed.isDefined)(arguments[3])) {
  14261. arguments[3] = datamap.propToCol(arguments[3]);
  14262. }
  14263. return (_instance5 = instance).selectCell.apply(_instance5, arguments);
  14264. };
  14265. /**
  14266. * Deselects the current cell selection on grid.
  14267. *
  14268. * @memberof Core#
  14269. * @function deselectCell
  14270. */
  14271. this.deselectCell = function () {
  14272. selection.deselect();
  14273. };
  14274. /**
  14275. * Scroll viewport to coords specified by the `row` and `column` arguments.
  14276. *
  14277. * @since 0.24.3
  14278. * @memberof Core#
  14279. * @function scrollViewportTo
  14280. * @param {Number} [row] Visual row index.
  14281. * @param {Number} [column] Visual column index.
  14282. * @param {Boolean} [snapToBottom = false] If `true`, viewport is scrolled to show the cell on the bottom of the table.
  14283. * @param {Boolean} [snapToRight = false] If `true`, viewport is scrolled to show the cell on the right side of the table.
  14284. * @returns {Boolean} `true` if scroll was successful, `false` otherwise.
  14285. */
  14286. this.scrollViewportTo = function (row, column) {
  14287. var snapToBottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  14288. var snapToRight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  14289. if (row !== void 0 && (row < 0 || row >= instance.countRows())) {
  14290. return false;
  14291. }
  14292. if (column !== void 0 && (column < 0 || column >= instance.countCols())) {
  14293. return false;
  14294. }
  14295. var result = false;
  14296. if (row !== void 0 && column !== void 0) {
  14297. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  14298. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  14299. result = true;
  14300. }
  14301. if (typeof row === 'number' && typeof column !== 'number') {
  14302. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  14303. result = true;
  14304. }
  14305. if (typeof column === 'number' && typeof row !== 'number') {
  14306. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  14307. result = true;
  14308. }
  14309. return result;
  14310. };
  14311. /**
  14312. * Removes grid from the DOM.
  14313. *
  14314. * @memberof Core#
  14315. * @function destroy
  14316. * @fires Hooks#afterDestroy
  14317. */
  14318. this.destroy = function () {
  14319. instance._clearTimeouts();
  14320. if (instance.view) {
  14321. // in case HT is destroyed before initialization has finished
  14322. instance.view.destroy();
  14323. }
  14324. if (dataSource) {
  14325. dataSource.destroy();
  14326. }
  14327. dataSource = null;
  14328. (0, _element.empty)(instance.rootElement);
  14329. eventManager.destroy();
  14330. instance.runHooks('afterDestroy');
  14331. _pluginHooks2.default.getSingleton().destroy(instance);
  14332. for (var i in instance) {
  14333. if ((0, _object.hasOwnProperty)(instance, i)) {
  14334. // replace instance methods with post mortem
  14335. if ((0, _function.isFunction)(instance[i])) {
  14336. instance[i] = postMortem;
  14337. } else if (i !== 'guid') {
  14338. // replace instance properties with null (restores memory)
  14339. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  14340. instance[i] = null;
  14341. }
  14342. }
  14343. }
  14344. // replace private properties with null (restores memory)
  14345. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  14346. if (datamap) {
  14347. datamap.destroy();
  14348. }
  14349. datamap = null;
  14350. priv = null;
  14351. grid = null;
  14352. selection = null;
  14353. editorManager = null;
  14354. instance = null;
  14355. GridSettings = null;
  14356. };
  14357. /**
  14358. * Replacement for all methods after Handsotnable was destroyed.
  14359. *
  14360. * @private
  14361. */
  14362. function postMortem() {
  14363. throw new Error('This method cannot be called because this Handsontable instance has been destroyed');
  14364. }
  14365. /**
  14366. * Returns the active editor object.
  14367. *
  14368. * @memberof Core#
  14369. * @function getActiveEditor
  14370. * @returns {Object} The active editor object.
  14371. */
  14372. this.getActiveEditor = function () {
  14373. return editorManager.getActiveEditor();
  14374. };
  14375. /**
  14376. * Returns plugin instance using the plugin name provided.
  14377. *
  14378. * @memberof Core#
  14379. * @function getPlugin
  14380. * @param {String} pluginName The plugin name.
  14381. * @returns {*} The plugin instance.
  14382. * @since 0.15.0
  14383. */
  14384. this.getPlugin = function (pluginName) {
  14385. return (0, _plugins.getPlugin)(this, pluginName);
  14386. };
  14387. /**
  14388. * Returns the Handsontable instance.
  14389. *
  14390. * @memberof Core#
  14391. * @function getInstance
  14392. * @returns {Handsontable} The Handsontable instance.
  14393. */
  14394. this.getInstance = function () {
  14395. return instance;
  14396. };
  14397. /**
  14398. * Adds listener to the specified hook name (only for this Handsontable instance).
  14399. *
  14400. * @memberof Core#
  14401. * @function addHook
  14402. * @see Hooks#add
  14403. * @param {String} key Hook name.
  14404. * @param {Function|Array} callback Function or array of Functions.
  14405. *
  14406. * @example
  14407. * ```js
  14408. * hot.addHook('beforeInit', myCallback);
  14409. * ```
  14410. */
  14411. this.addHook = function (key, callback) {
  14412. _pluginHooks2.default.getSingleton().add(key, callback, instance);
  14413. };
  14414. /**
  14415. * Check if for a specified hook name there are added listeners (only for this Handsontable instance).
  14416. *
  14417. * @memberof Core#
  14418. * @function hasHook
  14419. * @see Hooks#has
  14420. * @param {String} key Hook name
  14421. * @return {Boolean}
  14422. *
  14423. * @example
  14424. * ```js
  14425. * var hasBeforeInitListeners = hot.hasHook('beforeInit');
  14426. * ```
  14427. */
  14428. this.hasHook = function (key) {
  14429. return _pluginHooks2.default.getSingleton().has(key, instance);
  14430. };
  14431. /**
  14432. * Adds listener to specified hook name (only for this Handsontable instance).
  14433. * After the listener is triggered, it will be automatically removed.
  14434. *
  14435. * @memberof Core#
  14436. * @function addHookOnce
  14437. * @see Hooks#once
  14438. * @param {String} key Hook name.
  14439. * @param {Function|Array} callback Function or array of Functions.
  14440. *
  14441. * @example
  14442. * ```js
  14443. * hot.addHookOnce('beforeInit', myCallback);
  14444. * ```
  14445. */
  14446. this.addHookOnce = function (key, callback) {
  14447. _pluginHooks2.default.getSingleton().once(key, callback, instance);
  14448. };
  14449. /**
  14450. * Removes the hook listener previously registered with {@link Core#addHook}.
  14451. *
  14452. * @memberof Core#
  14453. * @function removeHook
  14454. * @see Hooks#remove
  14455. * @param {String} key Hook name.
  14456. * @param {Function} callback Function which have been registered via {@link Core#addHook}.
  14457. *
  14458. * @example
  14459. * ```js
  14460. * hot.removeHook('beforeInit', myCallback);
  14461. * ```
  14462. */
  14463. this.removeHook = function (key, callback) {
  14464. _pluginHooks2.default.getSingleton().remove(key, callback, instance);
  14465. };
  14466. /**
  14467. * Run the callbacks for the hook provided in the `key` argument using the parameters given in the other arguments.
  14468. *
  14469. * @memberof Core#
  14470. * @function runHooks
  14471. * @see Hooks#run
  14472. * @param {String} key Hook name.
  14473. * @param {*} [p1] Argument passed to the callback.
  14474. * @param {*} [p2] Argument passed to the callback.
  14475. * @param {*} [p3] Argument passed to the callback.
  14476. * @param {*} [p4] Argument passed to the callback.
  14477. * @param {*} [p5] Argument passed to the callback.
  14478. * @param {*} [p6] Argument passed to the callback.
  14479. * @returns {*}
  14480. *
  14481. * @example
  14482. * ```js
  14483. * hot.runHooks('beforeInit');
  14484. * ```
  14485. */
  14486. this.runHooks = function (key, p1, p2, p3, p4, p5, p6) {
  14487. return _pluginHooks2.default.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
  14488. };
  14489. this.timeouts = [];
  14490. /**
  14491. * Sets timeout. Purpose of this method is to clear all known timeouts when `destroy` method is called.
  14492. *
  14493. * @param {*} handle
  14494. * @private
  14495. */
  14496. this._registerTimeout = function (handle) {
  14497. this.timeouts.push(handle);
  14498. };
  14499. /**
  14500. * Clears all known timeouts.
  14501. *
  14502. * @private
  14503. */
  14504. this._clearTimeouts = function () {
  14505. for (var i = 0, ilen = this.timeouts.length; i < ilen; i++) {
  14506. clearTimeout(this.timeouts[i]);
  14507. }
  14508. };
  14509. /**
  14510. * Handsontable version
  14511. *
  14512. * @type {String}
  14513. */
  14514. // this.version = Handsontable.version;
  14515. _pluginHooks2.default.getSingleton().run(instance, 'construct');
  14516. };
  14517. /***/ }),
  14518. /* 65 */
  14519. /***/ (function(module, exports, __webpack_require__) {
  14520. "use strict";
  14521. exports.__esModule = true;
  14522. exports.spreadsheetColumnLabel = spreadsheetColumnLabel;
  14523. exports.spreadsheetColumnIndex = spreadsheetColumnIndex;
  14524. exports.createSpreadsheetData = createSpreadsheetData;
  14525. exports.createSpreadsheetObjectData = createSpreadsheetObjectData;
  14526. exports.createEmptySpreadsheetData = createEmptySpreadsheetData;
  14527. exports.translateRowsToColumns = translateRowsToColumns;
  14528. exports.cellMethodLookupFactory = cellMethodLookupFactory;
  14529. var _cellTypes = __webpack_require__(63);
  14530. var _object = __webpack_require__(1);
  14531. var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  14532. var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
  14533. /**
  14534. * Generates spreadsheet-like column names: A, B, C, ..., Z, AA, AB, etc.
  14535. *
  14536. * @param {Number} index Column index.
  14537. * @returns {String}
  14538. */
  14539. function spreadsheetColumnLabel(index) {
  14540. var dividend = index + 1;
  14541. var columnLabel = '';
  14542. var modulo = void 0;
  14543. while (dividend > 0) {
  14544. modulo = (dividend - 1) % COLUMN_LABEL_BASE_LENGTH;
  14545. columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
  14546. dividend = parseInt((dividend - modulo) / COLUMN_LABEL_BASE_LENGTH, 10);
  14547. }
  14548. return columnLabel;
  14549. }
  14550. /**
  14551. * Generates spreadsheet-like column index from theirs labels: A, B, C ...., Z, AA, AB, etc.
  14552. *
  14553. * @param {String} label Column label.
  14554. * @returns {Number}
  14555. */
  14556. function spreadsheetColumnIndex(label) {
  14557. var result = 0;
  14558. if (label) {
  14559. for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
  14560. result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
  14561. }
  14562. }
  14563. --result;
  14564. return result;
  14565. }
  14566. /**
  14567. * Creates 2D array of Excel-like values "A1", "A2", ...
  14568. *
  14569. * @param {Number} rows Number of rows to generate.
  14570. * @param {Number} columns Number of columns to generate.
  14571. * @returns {Array}
  14572. */
  14573. function createSpreadsheetData() {
  14574. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  14575. var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  14576. var _rows = [],
  14577. i,
  14578. j;
  14579. for (i = 0; i < rows; i++) {
  14580. var row = [];
  14581. for (j = 0; j < columns; j++) {
  14582. row.push(spreadsheetColumnLabel(j) + (i + 1));
  14583. }
  14584. _rows.push(row);
  14585. }
  14586. return _rows;
  14587. }
  14588. /**
  14589. * Creates 2D array of Excel-like values "A1", "A2", as an array of objects.
  14590. *
  14591. * @param {Number} rows Number of rows to generate.
  14592. * @param {Number} colCount Number of columns to generate.
  14593. * @returns {Array}
  14594. */
  14595. function createSpreadsheetObjectData() {
  14596. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  14597. var colCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  14598. var _rows = [],
  14599. i,
  14600. j;
  14601. for (i = 0; i < rows; i++) {
  14602. var row = {};
  14603. for (j = 0; j < colCount; j++) {
  14604. row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1);
  14605. }
  14606. _rows.push(row);
  14607. }
  14608. return _rows;
  14609. }
  14610. /**
  14611. * Generates an empty data object.
  14612. *
  14613. * @param {Number} rows Number of rows to generate.
  14614. * @param {Number} columns Number of columns to generate
  14615. * @returns {Array}
  14616. */
  14617. function createEmptySpreadsheetData(rows, columns) {
  14618. var data = [];
  14619. var row = void 0;
  14620. for (var i = 0; i < rows; i++) {
  14621. row = [];
  14622. for (var j = 0; j < columns; j++) {
  14623. row.push('');
  14624. }
  14625. data.push(row);
  14626. }
  14627. return data;
  14628. }
  14629. function translateRowsToColumns(input) {
  14630. var i,
  14631. ilen,
  14632. j,
  14633. jlen,
  14634. output = [],
  14635. olen = 0;
  14636. for (i = 0, ilen = input.length; i < ilen; i++) {
  14637. for (j = 0, jlen = input[i].length; j < jlen; j++) {
  14638. if (j == olen) {
  14639. output.push([]);
  14640. olen++;
  14641. }
  14642. output[j].push(input[i][j]);
  14643. }
  14644. }
  14645. return output;
  14646. }
  14647. /**
  14648. * Factory that produces a function for searching methods (or any properties) which could be defined directly in
  14649. * table configuration or implicitly, within cell type definition.
  14650. *
  14651. * For example: renderer can be defined explicitly using "renderer" property in column configuration or it can be
  14652. * defined implicitly using "type" property.
  14653. *
  14654. * Methods/properties defined explicitly always takes precedence over those defined through "type".
  14655. *
  14656. * If the method/property is not found in an object, searching is continued recursively through prototype chain, until
  14657. * it reaches the Object.prototype.
  14658. *
  14659. *
  14660. * @param methodName {String} name of the method/property to search (i.e. 'renderer', 'validator', 'copyable')
  14661. * @param allowUndefined {Boolean} [optional] if false, the search is continued if methodName has not been found in cell "type"
  14662. * @returns {Function}
  14663. */
  14664. function cellMethodLookupFactory(methodName, allowUndefined) {
  14665. allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined;
  14666. return function cellMethodLookup(row, col) {
  14667. return function getMethodFromProperties(properties) {
  14668. if (!properties) {
  14669. return; // method not found
  14670. } else if ((0, _object.hasOwnProperty)(properties, methodName) && properties[methodName] !== void 0) {
  14671. // check if it is own and is not empty
  14672. return properties[methodName]; // method defined directly
  14673. } else if ((0, _object.hasOwnProperty)(properties, 'type') && properties.type) {
  14674. // check if it is own and is not empty
  14675. var type;
  14676. if (typeof properties.type != 'string') {
  14677. throw new Error('Cell type must be a string ');
  14678. }
  14679. type = (0, _cellTypes.getCellType)(properties.type);
  14680. if ((0, _object.hasOwnProperty)(type, methodName)) {
  14681. return type[methodName]; // method defined in type.
  14682. } else if (allowUndefined) {
  14683. return; // method does not defined in type (eg. validator), returns undefined
  14684. }
  14685. }
  14686. return getMethodFromProperties(Object.getPrototypeOf(properties));
  14687. }(typeof row == 'number' ? this.getCellMeta(row, col) : row);
  14688. };
  14689. }
  14690. /***/ }),
  14691. /* 66 */
  14692. /***/ (function(module, exports, __webpack_require__) {
  14693. "use strict";
  14694. exports.__esModule = true;
  14695. exports.columnFactory = columnFactory;
  14696. var _object = __webpack_require__(1);
  14697. /* eslint-disable import/prefer-default-export */
  14698. /**
  14699. * Factory for columns constructors.
  14700. *
  14701. * @param {Object} GridSettings
  14702. * @param {Array} conflictList
  14703. * @return {Object} ColumnSettings
  14704. */
  14705. function columnFactory(GridSettings, conflictList) {
  14706. function ColumnSettings() {};
  14707. (0, _object.inherit)(ColumnSettings, GridSettings);
  14708. // Clear conflict settings
  14709. for (var i = 0, len = conflictList.length; i < len; i++) {
  14710. ColumnSettings.prototype[conflictList[i]] = void 0;
  14711. }
  14712. return ColumnSettings;
  14713. }
  14714. /***/ }),
  14715. /* 67 */
  14716. /***/ (function(module, exports, __webpack_require__) {
  14717. "use strict";
  14718. exports.__esModule = true;
  14719. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  14720. var _element = __webpack_require__(0);
  14721. var _array = __webpack_require__(2);
  14722. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14723. /**
  14724. * @class GhostTable
  14725. * @util
  14726. */
  14727. var GhostTable = function () {
  14728. function GhostTable(hotInstance) {
  14729. _classCallCheck(this, GhostTable);
  14730. /**
  14731. * Handsontable instance.
  14732. *
  14733. * @type {Core}
  14734. */
  14735. this.hot = hotInstance;
  14736. /**
  14737. * Container element where every table will be injected.
  14738. *
  14739. * @type {HTMLElement|null}
  14740. */
  14741. this.container = null;
  14742. /**
  14743. * Flag which determine is table was injected to DOM.
  14744. *
  14745. * @type {Boolean}
  14746. */
  14747. this.injected = false;
  14748. /**
  14749. * Added rows collection.
  14750. *
  14751. * @type {Array}
  14752. */
  14753. this.rows = [];
  14754. /**
  14755. * Added columns collection.
  14756. *
  14757. * @type {Array}
  14758. */
  14759. this.columns = [];
  14760. /**
  14761. * Samples prepared for calculations.
  14762. *
  14763. * @type {Map}
  14764. * @default {null}
  14765. */
  14766. this.samples = null;
  14767. /**
  14768. * Ghost table settings.
  14769. *
  14770. * @type {Object}
  14771. * @default {Object}
  14772. */
  14773. this.settings = {
  14774. useHeaders: true
  14775. };
  14776. }
  14777. /**
  14778. * Add row.
  14779. *
  14780. * @param {Number} row Row index.
  14781. * @param {Map} samples Samples Map object.
  14782. */
  14783. _createClass(GhostTable, [{
  14784. key: 'addRow',
  14785. value: function addRow(row, samples) {
  14786. if (this.columns.length) {
  14787. throw new Error('Doesn\'t support multi-dimensional table');
  14788. }
  14789. if (!this.rows.length) {
  14790. this.container = this.createContainer(this.hot.rootElement.className);
  14791. }
  14792. var rowObject = { row: row };
  14793. this.rows.push(rowObject);
  14794. this.samples = samples;
  14795. this.table = this.createTable(this.hot.table.className);
  14796. this.table.colGroup.appendChild(this.createColGroupsCol());
  14797. this.table.tr.appendChild(this.createRow(row));
  14798. this.container.container.appendChild(this.table.fragment);
  14799. rowObject.table = this.table.table;
  14800. }
  14801. /**
  14802. * Add a row consisting of the column headers.
  14803. */
  14804. }, {
  14805. key: 'addColumnHeadersRow',
  14806. value: function addColumnHeadersRow(samples) {
  14807. if (this.hot.getColHeader(0) != null) {
  14808. var rowObject = { row: -1 };
  14809. this.rows.push(rowObject);
  14810. this.container = this.createContainer(this.hot.rootElement.className);
  14811. this.samples = samples;
  14812. this.table = this.createTable(this.hot.table.className);
  14813. this.table.colGroup.appendChild(this.createColGroupsCol());
  14814. this.table.tHead.appendChild(this.createColumnHeadersRow());
  14815. this.container.container.appendChild(this.table.fragment);
  14816. rowObject.table = this.table.table;
  14817. }
  14818. }
  14819. /**
  14820. * Add column.
  14821. *
  14822. * @param {Number} column Column index.
  14823. * @param {Map} samples Samples Map object.
  14824. */
  14825. }, {
  14826. key: 'addColumn',
  14827. value: function addColumn(column, samples) {
  14828. if (this.rows.length) {
  14829. throw new Error('Doesn\'t support multi-dimensional table');
  14830. }
  14831. if (!this.columns.length) {
  14832. this.container = this.createContainer(this.hot.rootElement.className);
  14833. }
  14834. var columnObject = { col: column };
  14835. this.columns.push(columnObject);
  14836. this.samples = samples;
  14837. this.table = this.createTable(this.hot.table.className);
  14838. if (this.getSetting('useHeaders') && this.hot.getColHeader(column) !== null) {
  14839. this.hot.view.appendColHeader(column, this.table.th);
  14840. }
  14841. this.table.tBody.appendChild(this.createCol(column));
  14842. this.container.container.appendChild(this.table.fragment);
  14843. columnObject.table = this.table.table;
  14844. }
  14845. /**
  14846. * Get calculated heights.
  14847. *
  14848. * @param {Function} callback Callback which will be fired for each calculated row.
  14849. */
  14850. }, {
  14851. key: 'getHeights',
  14852. value: function getHeights(callback) {
  14853. if (!this.injected) {
  14854. this.injectTable();
  14855. }
  14856. (0, _array.arrayEach)(this.rows, function (row) {
  14857. // -1 <- reduce border-top from table
  14858. callback(row.row, (0, _element.outerHeight)(row.table) - 1);
  14859. });
  14860. }
  14861. /**
  14862. * Get calculated widths.
  14863. *
  14864. * @param {Function} callback Callback which will be fired for each calculated column.
  14865. */
  14866. }, {
  14867. key: 'getWidths',
  14868. value: function getWidths(callback) {
  14869. if (!this.injected) {
  14870. this.injectTable();
  14871. }
  14872. (0, _array.arrayEach)(this.columns, function (column) {
  14873. callback(column.col, (0, _element.outerWidth)(column.table));
  14874. });
  14875. }
  14876. /**
  14877. * Set the Ghost Table settings to the provided object.
  14878. *
  14879. * @param {Object} settings New Ghost Table Settings
  14880. */
  14881. }, {
  14882. key: 'setSettings',
  14883. value: function setSettings(settings) {
  14884. this.settings = settings;
  14885. }
  14886. /**
  14887. * Set a single setting of the Ghost Table.
  14888. *
  14889. * @param {String} name Setting name.
  14890. * @param {*} value Setting value.
  14891. */
  14892. }, {
  14893. key: 'setSetting',
  14894. value: function setSetting(name, value) {
  14895. if (!this.settings) {
  14896. this.settings = {};
  14897. }
  14898. this.settings[name] = value;
  14899. }
  14900. /**
  14901. * Get the Ghost Table settings.
  14902. *
  14903. * @returns {Object|null}
  14904. */
  14905. }, {
  14906. key: 'getSettings',
  14907. value: function getSettings() {
  14908. return this.settings;
  14909. }
  14910. /**
  14911. * Get a single Ghost Table setting.
  14912. *
  14913. * @param {String} name
  14914. * @returns {Boolean|null}
  14915. */
  14916. }, {
  14917. key: 'getSetting',
  14918. value: function getSetting(name) {
  14919. if (this.settings) {
  14920. return this.settings[name];
  14921. }
  14922. return null;
  14923. }
  14924. /**
  14925. * Create colgroup col elements.
  14926. *
  14927. * @returns {DocumentFragment}
  14928. */
  14929. }, {
  14930. key: 'createColGroupsCol',
  14931. value: function createColGroupsCol() {
  14932. var _this = this;
  14933. var d = document;
  14934. var fragment = d.createDocumentFragment();
  14935. if (this.hot.hasRowHeaders()) {
  14936. fragment.appendChild(this.createColElement(-1));
  14937. }
  14938. this.samples.forEach(function (sample) {
  14939. (0, _array.arrayEach)(sample.strings, function (string) {
  14940. fragment.appendChild(_this.createColElement(string.col));
  14941. });
  14942. });
  14943. return fragment;
  14944. }
  14945. /**
  14946. * Create table row element.
  14947. *
  14948. * @param {Number} row Row index.
  14949. * @returns {DocumentFragment} Returns created table row elements.
  14950. */
  14951. }, {
  14952. key: 'createRow',
  14953. value: function createRow(row) {
  14954. var _this2 = this;
  14955. var d = document;
  14956. var fragment = d.createDocumentFragment();
  14957. var th = d.createElement('th');
  14958. if (this.hot.hasRowHeaders()) {
  14959. this.hot.view.appendRowHeader(row, th);
  14960. fragment.appendChild(th);
  14961. }
  14962. this.samples.forEach(function (sample) {
  14963. (0, _array.arrayEach)(sample.strings, function (string) {
  14964. var column = string.col;
  14965. var cellProperties = _this2.hot.getCellMeta(row, column);
  14966. cellProperties.col = column;
  14967. cellProperties.row = row;
  14968. var renderer = _this2.hot.getCellRenderer(cellProperties);
  14969. var td = d.createElement('td');
  14970. renderer(_this2.hot, td, row, column, _this2.hot.colToProp(column), string.value, cellProperties);
  14971. fragment.appendChild(td);
  14972. });
  14973. });
  14974. return fragment;
  14975. }
  14976. }, {
  14977. key: 'createColumnHeadersRow',
  14978. value: function createColumnHeadersRow() {
  14979. var _this3 = this;
  14980. var d = document;
  14981. var fragment = d.createDocumentFragment();
  14982. if (this.hot.hasRowHeaders()) {
  14983. var th = d.createElement('th');
  14984. this.hot.view.appendColHeader(-1, th);
  14985. fragment.appendChild(th);
  14986. }
  14987. this.samples.forEach(function (sample) {
  14988. (0, _array.arrayEach)(sample.strings, function (string) {
  14989. var column = string.col;
  14990. var th = d.createElement('th');
  14991. _this3.hot.view.appendColHeader(column, th);
  14992. fragment.appendChild(th);
  14993. });
  14994. });
  14995. return fragment;
  14996. }
  14997. /**
  14998. * Create table column elements.
  14999. *
  15000. * @param {Number} column Column index.
  15001. * @returns {DocumentFragment} Returns created column table column elements.
  15002. */
  15003. }, {
  15004. key: 'createCol',
  15005. value: function createCol(column) {
  15006. var _this4 = this;
  15007. var d = document;
  15008. var fragment = d.createDocumentFragment();
  15009. this.samples.forEach(function (sample) {
  15010. (0, _array.arrayEach)(sample.strings, function (string) {
  15011. var row = string.row;
  15012. var cellProperties = _this4.hot.getCellMeta(row, column);
  15013. cellProperties.col = column;
  15014. cellProperties.row = row;
  15015. var renderer = _this4.hot.getCellRenderer(cellProperties);
  15016. var td = d.createElement('td');
  15017. var tr = d.createElement('tr');
  15018. renderer(_this4.hot, td, row, column, _this4.hot.colToProp(column), string.value, cellProperties);
  15019. tr.appendChild(td);
  15020. fragment.appendChild(tr);
  15021. });
  15022. });
  15023. return fragment;
  15024. }
  15025. /**
  15026. * Remove table from document and reset internal state.
  15027. */
  15028. }, {
  15029. key: 'clean',
  15030. value: function clean() {
  15031. this.rows.length = 0;
  15032. this.rows[-1] = void 0;
  15033. this.columns.length = 0;
  15034. if (this.samples) {
  15035. this.samples.clear();
  15036. }
  15037. this.samples = null;
  15038. this.removeTable();
  15039. }
  15040. /**
  15041. * Inject generated table into document.
  15042. *
  15043. * @param {HTMLElement} [parent=null]
  15044. */
  15045. }, {
  15046. key: 'injectTable',
  15047. value: function injectTable() {
  15048. var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  15049. if (!this.injected) {
  15050. (parent || this.hot.rootElement).appendChild(this.container.fragment);
  15051. this.injected = true;
  15052. }
  15053. }
  15054. /**
  15055. * Remove table from document.
  15056. */
  15057. }, {
  15058. key: 'removeTable',
  15059. value: function removeTable() {
  15060. if (this.injected && this.container.container.parentNode) {
  15061. this.container.container.parentNode.removeChild(this.container.container);
  15062. this.container = null;
  15063. this.injected = false;
  15064. }
  15065. }
  15066. /**
  15067. * Create col element.
  15068. *
  15069. * @param {Number} column Column index.
  15070. * @returns {HTMLElement}
  15071. */
  15072. }, {
  15073. key: 'createColElement',
  15074. value: function createColElement(column) {
  15075. var d = document;
  15076. var col = d.createElement('col');
  15077. col.style.width = this.hot.view.wt.wtTable.getStretchedColumnWidth(column) + 'px';
  15078. return col;
  15079. }
  15080. /**
  15081. * Create table element.
  15082. *
  15083. * @param {String} className
  15084. * @returns {Object}
  15085. */
  15086. }, {
  15087. key: 'createTable',
  15088. value: function createTable() {
  15089. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  15090. var d = document;
  15091. var fragment = d.createDocumentFragment();
  15092. var table = d.createElement('table');
  15093. var tHead = d.createElement('thead');
  15094. var tBody = d.createElement('tbody');
  15095. var colGroup = d.createElement('colgroup');
  15096. var tr = d.createElement('tr');
  15097. var th = d.createElement('th');
  15098. if (this.isVertical()) {
  15099. table.appendChild(colGroup);
  15100. }
  15101. if (this.isHorizontal()) {
  15102. tr.appendChild(th);
  15103. tHead.appendChild(tr);
  15104. table.style.tableLayout = 'auto';
  15105. table.style.width = 'auto';
  15106. }
  15107. table.appendChild(tHead);
  15108. if (this.isVertical()) {
  15109. tBody.appendChild(tr);
  15110. }
  15111. table.appendChild(tBody);
  15112. (0, _element.addClass)(table, className);
  15113. fragment.appendChild(table);
  15114. return { fragment: fragment, table: table, tHead: tHead, tBody: tBody, colGroup: colGroup, tr: tr, th: th };
  15115. }
  15116. /**
  15117. * Create container for tables.
  15118. *
  15119. * @param {String} className
  15120. * @returns {Object}
  15121. */
  15122. }, {
  15123. key: 'createContainer',
  15124. value: function createContainer() {
  15125. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  15126. var d = document;
  15127. var fragment = d.createDocumentFragment();
  15128. var container = d.createElement('div');
  15129. className = 'htGhostTable htAutoSize ' + className.trim();
  15130. (0, _element.addClass)(container, className);
  15131. fragment.appendChild(container);
  15132. return { fragment: fragment, container: container };
  15133. }
  15134. /**
  15135. * Checks if table is raised vertically (checking rows).
  15136. *
  15137. * @returns {Boolean}
  15138. */
  15139. }, {
  15140. key: 'isVertical',
  15141. value: function isVertical() {
  15142. return !!(this.rows.length && !this.columns.length);
  15143. }
  15144. /**
  15145. * Checks if table is raised horizontally (checking columns).
  15146. *
  15147. * @returns {Boolean}
  15148. */
  15149. }, {
  15150. key: 'isHorizontal',
  15151. value: function isHorizontal() {
  15152. return !!(this.columns.length && !this.rows.length);
  15153. }
  15154. }]);
  15155. return GhostTable;
  15156. }();
  15157. exports.default = GhostTable;
  15158. /***/ }),
  15159. /* 68 */
  15160. /***/ (function(module, exports, __webpack_require__) {
  15161. "use strict";
  15162. var addToUnscopables = __webpack_require__(38)
  15163. , step = __webpack_require__(282)
  15164. , Iterators = __webpack_require__(46)
  15165. , toIObject = __webpack_require__(23);
  15166. // 22.1.3.4 Array.prototype.entries()
  15167. // 22.1.3.13 Array.prototype.keys()
  15168. // 22.1.3.29 Array.prototype.values()
  15169. // 22.1.3.30 Array.prototype[@@iterator]()
  15170. module.exports = __webpack_require__(281)(Array, 'Array', function(iterated, kind){
  15171. this._t = toIObject(iterated); // target
  15172. this._i = 0; // next index
  15173. this._k = kind; // kind
  15174. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  15175. }, function(){
  15176. var O = this._t
  15177. , kind = this._k
  15178. , index = this._i++;
  15179. if(!O || index >= O.length){
  15180. this._t = undefined;
  15181. return step(1);
  15182. }
  15183. if(kind == 'keys' )return step(0, index);
  15184. if(kind == 'values')return step(0, O[index]);
  15185. return step(0, [index, O[index]]);
  15186. }, 'values');
  15187. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  15188. Iterators.Arguments = Iterators.Array;
  15189. addToUnscopables('keys');
  15190. addToUnscopables('values');
  15191. addToUnscopables('entries');
  15192. /***/ }),
  15193. /* 69 */
  15194. /***/ (function(module, exports, __webpack_require__) {
  15195. "use strict";
  15196. exports.__esModule = true;
  15197. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  15198. var _coords = __webpack_require__(43);
  15199. var _coords2 = _interopRequireDefault(_coords);
  15200. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15201. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15202. /**
  15203. * A cell range is a set of exactly two CellCoords (that can be the same or different)
  15204. *
  15205. * @class CellRange
  15206. */
  15207. var CellRange = function () {
  15208. /**
  15209. * @param {CellCoords} highlight Used to draw bold border around a cell where selection was
  15210. * started and to edit the cell when you press Enter
  15211. * @param {CellCoords} from Usually the same as highlight, but in Excel there is distinction - one can change
  15212. * highlight within a selection
  15213. * @param {CellCoords} to End selection
  15214. */
  15215. function CellRange(highlight, from, to) {
  15216. _classCallCheck(this, CellRange);
  15217. this.highlight = highlight;
  15218. this.from = from;
  15219. this.to = to;
  15220. }
  15221. /**
  15222. * Checks if given coords are valid in context of a given Walkontable instance
  15223. *
  15224. * @param {Walkontable} wotInstance
  15225. * @returns {Boolean}
  15226. */
  15227. _createClass(CellRange, [{
  15228. key: 'isValid',
  15229. value: function isValid(wotInstance) {
  15230. return this.from.isValid(wotInstance) && this.to.isValid(wotInstance);
  15231. }
  15232. /**
  15233. * Checks if this cell range is restricted to one cell
  15234. *
  15235. * @returns {Boolean}
  15236. */
  15237. }, {
  15238. key: 'isSingle',
  15239. value: function isSingle() {
  15240. return this.from.row === this.to.row && this.from.col === this.to.col;
  15241. }
  15242. /**
  15243. * Returns selected range height (in number of rows)
  15244. *
  15245. * @returns {Number}
  15246. */
  15247. }, {
  15248. key: 'getHeight',
  15249. value: function getHeight() {
  15250. return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1;
  15251. }
  15252. /**
  15253. * Returns selected range width (in number of columns)
  15254. *
  15255. * @returns {Number}
  15256. */
  15257. }, {
  15258. key: 'getWidth',
  15259. value: function getWidth() {
  15260. return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1;
  15261. }
  15262. /**
  15263. * Checks if given cell coords is within `from` and `to` cell coords of this range
  15264. *
  15265. * @param {CellCoords} cellCoords
  15266. * @returns {Boolean}
  15267. */
  15268. }, {
  15269. key: 'includes',
  15270. value: function includes(cellCoords) {
  15271. var row = cellCoords.row,
  15272. col = cellCoords.col;
  15273. var topLeft = this.getTopLeftCorner();
  15274. var bottomRight = this.getBottomRightCorner();
  15275. return topLeft.row <= row && bottomRight.row >= row && topLeft.col <= col && bottomRight.col >= col;
  15276. }
  15277. /**
  15278. * Checks if given range is within of this range
  15279. *
  15280. * @param {CellRange} testedRange
  15281. * @returns {Boolean}
  15282. */
  15283. }, {
  15284. key: 'includesRange',
  15285. value: function includesRange(testedRange) {
  15286. return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner());
  15287. }
  15288. /**
  15289. * Checks if given range is equal to this range
  15290. *
  15291. * @param {CellRange} testedRange
  15292. * @returns {Boolean}
  15293. */
  15294. }, {
  15295. key: 'isEqual',
  15296. value: function isEqual(testedRange) {
  15297. 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);
  15298. }
  15299. /**
  15300. * Checks if tested range overlaps with the range.
  15301. * Range A is considered to to be overlapping with range B if intersection of A and B or B and A is not empty.
  15302. *
  15303. * @param {CellRange} testedRange
  15304. * @returns {Boolean}
  15305. */
  15306. }, {
  15307. key: 'overlaps',
  15308. value: function overlaps(testedRange) {
  15309. return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner());
  15310. }
  15311. /**
  15312. * @param {CellRange} testedCoords
  15313. * @returns {Boolean}
  15314. */
  15315. }, {
  15316. key: 'isSouthEastOf',
  15317. value: function isSouthEastOf(testedCoords) {
  15318. return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords);
  15319. }
  15320. /**
  15321. * @param {CellRange} testedCoords
  15322. * @returns {Boolean}
  15323. */
  15324. }, {
  15325. key: 'isNorthWestOf',
  15326. value: function isNorthWestOf(testedCoords) {
  15327. return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords);
  15328. }
  15329. /**
  15330. * Adds a cell to a range (only if exceeds corners of the range). Returns information if range was expanded
  15331. *
  15332. * @param {CellCoords} cellCoords
  15333. * @returns {Boolean}
  15334. */
  15335. }, {
  15336. key: 'expand',
  15337. value: function expand(cellCoords) {
  15338. var topLeft = this.getTopLeftCorner();
  15339. var bottomRight = this.getBottomRightCorner();
  15340. if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) {
  15341. this.from = new _coords2.default(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col));
  15342. this.to = new _coords2.default(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col));
  15343. return true;
  15344. }
  15345. return false;
  15346. }
  15347. /**
  15348. * @param {CellRange} expandingRange
  15349. * @returns {Boolean}
  15350. */
  15351. }, {
  15352. key: 'expandByRange',
  15353. value: function expandByRange(expandingRange) {
  15354. if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) {
  15355. return false;
  15356. }
  15357. var topLeft = this.getTopLeftCorner();
  15358. var bottomRight = this.getBottomRightCorner();
  15359. var topRight = this.getTopRightCorner();
  15360. var bottomLeft = this.getBottomLeftCorner();
  15361. var expandingTopLeft = expandingRange.getTopLeftCorner();
  15362. var expandingBottomRight = expandingRange.getBottomRightCorner();
  15363. var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row);
  15364. var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col);
  15365. var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row);
  15366. var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col);
  15367. var finalFrom = new _coords2.default(resultTopRow, resultTopCol),
  15368. finalTo = new _coords2.default(resultBottomRow, resultBottomCol);
  15369. var isCorner = new CellRange(finalFrom, finalFrom, finalTo).isCorner(this.from, expandingRange),
  15370. onlyMerge = expandingRange.isEqual(new CellRange(finalFrom, finalFrom, finalTo));
  15371. if (isCorner && !onlyMerge) {
  15372. if (this.from.col > finalFrom.col) {
  15373. finalFrom.col = resultBottomCol;
  15374. finalTo.col = resultTopCol;
  15375. }
  15376. if (this.from.row > finalFrom.row) {
  15377. finalFrom.row = resultBottomRow;
  15378. finalTo.row = resultTopRow;
  15379. }
  15380. }
  15381. this.from = finalFrom;
  15382. this.to = finalTo;
  15383. return true;
  15384. }
  15385. /**
  15386. * @returns {String}
  15387. */
  15388. }, {
  15389. key: 'getDirection',
  15390. value: function getDirection() {
  15391. if (this.from.isNorthWestOf(this.to)) {
  15392. // NorthWest - SouthEast
  15393. return 'NW-SE';
  15394. } else if (this.from.isNorthEastOf(this.to)) {
  15395. // NorthEast - SouthWest
  15396. return 'NE-SW';
  15397. } else if (this.from.isSouthEastOf(this.to)) {
  15398. // SouthEast - NorthWest
  15399. return 'SE-NW';
  15400. } else if (this.from.isSouthWestOf(this.to)) {
  15401. // SouthWest - NorthEast
  15402. return 'SW-NE';
  15403. }
  15404. }
  15405. /**
  15406. * @param {String} direction
  15407. */
  15408. }, {
  15409. key: 'setDirection',
  15410. value: function setDirection(direction) {
  15411. switch (direction) {
  15412. case 'NW-SE':
  15413. var _ref = [this.getTopLeftCorner(), this.getBottomRightCorner()];
  15414. this.from = _ref[0];
  15415. this.to = _ref[1];
  15416. break;
  15417. case 'NE-SW':
  15418. var _ref2 = [this.getTopRightCorner(), this.getBottomLeftCorner()];
  15419. this.from = _ref2[0];
  15420. this.to = _ref2[1];
  15421. break;
  15422. case 'SE-NW':
  15423. var _ref3 = [this.getBottomRightCorner(), this.getTopLeftCorner()];
  15424. this.from = _ref3[0];
  15425. this.to = _ref3[1];
  15426. break;
  15427. case 'SW-NE':
  15428. var _ref4 = [this.getBottomLeftCorner(), this.getTopRightCorner()];
  15429. this.from = _ref4[0];
  15430. this.to = _ref4[1];
  15431. break;
  15432. default:
  15433. break;
  15434. }
  15435. }
  15436. /**
  15437. * Get top left corner of this range
  15438. *
  15439. * @returns {CellCoords}
  15440. */
  15441. }, {
  15442. key: 'getTopLeftCorner',
  15443. value: function getTopLeftCorner() {
  15444. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  15445. }
  15446. /**
  15447. * Get bottom right corner of this range
  15448. *
  15449. * @returns {CellCoords}
  15450. */
  15451. }, {
  15452. key: 'getBottomRightCorner',
  15453. value: function getBottomRightCorner() {
  15454. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  15455. }
  15456. /**
  15457. * Get top right corner of this range
  15458. *
  15459. * @returns {CellCoords}
  15460. */
  15461. }, {
  15462. key: 'getTopRightCorner',
  15463. value: function getTopRightCorner() {
  15464. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  15465. }
  15466. /**
  15467. * Get bottom left corner of this range
  15468. *
  15469. * @returns {CellCoords}
  15470. */
  15471. }, {
  15472. key: 'getBottomLeftCorner',
  15473. value: function getBottomLeftCorner() {
  15474. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  15475. }
  15476. /**
  15477. * @param {CellCoords} coords
  15478. * @param {CellRange} expandedRange
  15479. * @returns {*}
  15480. */
  15481. }, {
  15482. key: 'isCorner',
  15483. value: function isCorner(coords, expandedRange) {
  15484. if (expandedRange) {
  15485. if (expandedRange.includes(coords)) {
  15486. 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))) {
  15487. return true;
  15488. }
  15489. }
  15490. }
  15491. return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner());
  15492. }
  15493. /**
  15494. * @param {CellCoords} coords
  15495. * @param {CellRange} expandedRange
  15496. * @returns {CellCoords}
  15497. */
  15498. }, {
  15499. key: 'getOppositeCorner',
  15500. value: function getOppositeCorner(coords, expandedRange) {
  15501. if (!(coords instanceof _coords2.default)) {
  15502. return false;
  15503. }
  15504. if (expandedRange) {
  15505. if (expandedRange.includes(coords)) {
  15506. if (this.getTopLeftCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.from.col))) {
  15507. return this.getBottomRightCorner();
  15508. }
  15509. if (this.getTopRightCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.to.col))) {
  15510. return this.getBottomLeftCorner();
  15511. }
  15512. if (this.getBottomLeftCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.from.col))) {
  15513. return this.getTopRightCorner();
  15514. }
  15515. if (this.getBottomRightCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.to.col))) {
  15516. return this.getTopLeftCorner();
  15517. }
  15518. }
  15519. }
  15520. if (coords.isEqual(this.getBottomRightCorner())) {
  15521. return this.getTopLeftCorner();
  15522. } else if (coords.isEqual(this.getTopLeftCorner())) {
  15523. return this.getBottomRightCorner();
  15524. } else if (coords.isEqual(this.getTopRightCorner())) {
  15525. return this.getBottomLeftCorner();
  15526. } else if (coords.isEqual(this.getBottomLeftCorner())) {
  15527. return this.getTopRightCorner();
  15528. }
  15529. }
  15530. /**
  15531. * @param {CellRange} range
  15532. * @returns {Array}
  15533. */
  15534. }, {
  15535. key: 'getBordersSharedWith',
  15536. value: function getBordersSharedWith(range) {
  15537. if (!this.includesRange(range)) {
  15538. return [];
  15539. }
  15540. var thisBorders = {
  15541. top: Math.min(this.from.row, this.to.row),
  15542. bottom: Math.max(this.from.row, this.to.row),
  15543. left: Math.min(this.from.col, this.to.col),
  15544. right: Math.max(this.from.col, this.to.col)
  15545. };
  15546. var rangeBorders = {
  15547. top: Math.min(range.from.row, range.to.row),
  15548. bottom: Math.max(range.from.row, range.to.row),
  15549. left: Math.min(range.from.col, range.to.col),
  15550. right: Math.max(range.from.col, range.to.col)
  15551. };
  15552. var result = [];
  15553. if (thisBorders.top == rangeBorders.top) {
  15554. result.push('top');
  15555. }
  15556. if (thisBorders.right == rangeBorders.right) {
  15557. result.push('right');
  15558. }
  15559. if (thisBorders.bottom == rangeBorders.bottom) {
  15560. result.push('bottom');
  15561. }
  15562. if (thisBorders.left == rangeBorders.left) {
  15563. result.push('left');
  15564. }
  15565. return result;
  15566. }
  15567. /**
  15568. * Get inner selected cell coords defined by this range
  15569. *
  15570. * @returns {Array}
  15571. */
  15572. }, {
  15573. key: 'getInner',
  15574. value: function getInner() {
  15575. var topLeft = this.getTopLeftCorner();
  15576. var bottomRight = this.getBottomRightCorner();
  15577. var out = [];
  15578. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  15579. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  15580. if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) {
  15581. out.push(new _coords2.default(r, c));
  15582. }
  15583. }
  15584. }
  15585. return out;
  15586. }
  15587. /**
  15588. * Get all selected cell coords defined by this range
  15589. *
  15590. * @returns {Array}
  15591. */
  15592. }, {
  15593. key: 'getAll',
  15594. value: function getAll() {
  15595. var topLeft = this.getTopLeftCorner();
  15596. var bottomRight = this.getBottomRightCorner();
  15597. var out = [];
  15598. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  15599. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  15600. if (topLeft.row === r && topLeft.col === c) {
  15601. out.push(topLeft);
  15602. } else if (bottomRight.row === r && bottomRight.col === c) {
  15603. out.push(bottomRight);
  15604. } else {
  15605. out.push(new _coords2.default(r, c));
  15606. }
  15607. }
  15608. }
  15609. return out;
  15610. }
  15611. /**
  15612. * Runs a callback function against all cells in the range. You can break the iteration by returning
  15613. * `false` in the callback function
  15614. *
  15615. * @param callback {Function}
  15616. */
  15617. }, {
  15618. key: 'forAll',
  15619. value: function forAll(callback) {
  15620. var topLeft = this.getTopLeftCorner();
  15621. var bottomRight = this.getBottomRightCorner();
  15622. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  15623. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  15624. var breakIteration = callback(r, c);
  15625. if (breakIteration === false) {
  15626. return;
  15627. }
  15628. }
  15629. }
  15630. }
  15631. }]);
  15632. return CellRange;
  15633. }();
  15634. exports.default = CellRange;
  15635. /***/ }),
  15636. /* 70 */
  15637. /***/ (function(module, exports, __webpack_require__) {
  15638. "use strict";
  15639. exports.__esModule = true;
  15640. var _array = __webpack_require__(2);
  15641. var _object = __webpack_require__(1);
  15642. var MIXIN_NAME = 'localHooks';
  15643. /**
  15644. * Mixin object to extend objects functionality for local hooks.
  15645. *
  15646. * @type {Object}
  15647. */
  15648. var localHooks = {
  15649. /**
  15650. * Internal hooks storage.
  15651. */
  15652. _localHooks: Object.create(null),
  15653. /**
  15654. * Add hook to the collection.
  15655. *
  15656. * @param {String} key Hook name.
  15657. * @param {Function} callback Hook callback
  15658. */
  15659. addLocalHook: function addLocalHook(key, callback) {
  15660. if (!this._localHooks[key]) {
  15661. this._localHooks[key] = [];
  15662. }
  15663. this._localHooks[key].push(callback);
  15664. },
  15665. /**
  15666. * Run hooks.
  15667. *
  15668. * @param {String} key Hook name.
  15669. * @param {*} params
  15670. */
  15671. runLocalHooks: function runLocalHooks(key) {
  15672. var _this = this;
  15673. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  15674. params[_key - 1] = arguments[_key];
  15675. }
  15676. if (this._localHooks[key]) {
  15677. (0, _array.arrayEach)(this._localHooks[key], function (callback) {
  15678. return callback.apply(_this, params);
  15679. });
  15680. }
  15681. },
  15682. /**
  15683. * Clear all added hooks.
  15684. */
  15685. clearLocalHooks: function clearLocalHooks() {
  15686. this._localHooks = {};
  15687. }
  15688. };
  15689. (0, _object.defineGetter)(localHooks, 'MIXIN_NAME', MIXIN_NAME, {
  15690. writable: false,
  15691. enumerable: false
  15692. });
  15693. exports.default = localHooks;
  15694. /***/ }),
  15695. /* 71 */
  15696. /***/ (function(module, exports, __webpack_require__) {
  15697. "use strict";
  15698. exports.__esModule = true;
  15699. exports.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;
  15700. var _predefinedItems2;
  15701. var _alignment = __webpack_require__(338);
  15702. Object.defineProperty(exports, 'ALIGNMENT', {
  15703. enumerable: true,
  15704. get: function get() {
  15705. return _alignment.KEY;
  15706. }
  15707. });
  15708. var _clearColumn = __webpack_require__(339);
  15709. Object.defineProperty(exports, 'CLEAR_COLUMN', {
  15710. enumerable: true,
  15711. get: function get() {
  15712. return _clearColumn.KEY;
  15713. }
  15714. });
  15715. var _columnLeft = __webpack_require__(340);
  15716. Object.defineProperty(exports, 'COLUMN_LEFT', {
  15717. enumerable: true,
  15718. get: function get() {
  15719. return _columnLeft.KEY;
  15720. }
  15721. });
  15722. var _columnRight = __webpack_require__(341);
  15723. Object.defineProperty(exports, 'COLUMN_RIGHT', {
  15724. enumerable: true,
  15725. get: function get() {
  15726. return _columnRight.KEY;
  15727. }
  15728. });
  15729. var _readOnly = __webpack_require__(342);
  15730. Object.defineProperty(exports, 'READ_ONLY', {
  15731. enumerable: true,
  15732. get: function get() {
  15733. return _readOnly.KEY;
  15734. }
  15735. });
  15736. var _redo = __webpack_require__(343);
  15737. Object.defineProperty(exports, 'REDO', {
  15738. enumerable: true,
  15739. get: function get() {
  15740. return _redo.KEY;
  15741. }
  15742. });
  15743. var _removeColumn = __webpack_require__(344);
  15744. Object.defineProperty(exports, 'REMOVE_COLUMN', {
  15745. enumerable: true,
  15746. get: function get() {
  15747. return _removeColumn.KEY;
  15748. }
  15749. });
  15750. var _removeRow = __webpack_require__(345);
  15751. Object.defineProperty(exports, 'REMOVE_ROW', {
  15752. enumerable: true,
  15753. get: function get() {
  15754. return _removeRow.KEY;
  15755. }
  15756. });
  15757. var _rowAbove = __webpack_require__(346);
  15758. Object.defineProperty(exports, 'ROW_ABOVE', {
  15759. enumerable: true,
  15760. get: function get() {
  15761. return _rowAbove.KEY;
  15762. }
  15763. });
  15764. var _rowBelow = __webpack_require__(347);
  15765. Object.defineProperty(exports, 'ROW_BELOW', {
  15766. enumerable: true,
  15767. get: function get() {
  15768. return _rowBelow.KEY;
  15769. }
  15770. });
  15771. var _separator = __webpack_require__(72);
  15772. Object.defineProperty(exports, 'SEPARATOR', {
  15773. enumerable: true,
  15774. get: function get() {
  15775. return _separator.KEY;
  15776. }
  15777. });
  15778. var _undo = __webpack_require__(348);
  15779. Object.defineProperty(exports, 'UNDO', {
  15780. enumerable: true,
  15781. get: function get() {
  15782. return _undo.KEY;
  15783. }
  15784. });
  15785. exports.predefinedItems = predefinedItems;
  15786. exports.addItem = addItem;
  15787. var _object = __webpack_require__(1);
  15788. var _alignment2 = _interopRequireDefault(_alignment);
  15789. var _clearColumn2 = _interopRequireDefault(_clearColumn);
  15790. var _columnLeft2 = _interopRequireDefault(_columnLeft);
  15791. var _columnRight2 = _interopRequireDefault(_columnRight);
  15792. var _readOnly2 = _interopRequireDefault(_readOnly);
  15793. var _redo2 = _interopRequireDefault(_redo);
  15794. var _removeColumn2 = _interopRequireDefault(_removeColumn);
  15795. var _removeRow2 = _interopRequireDefault(_removeRow);
  15796. var _rowAbove2 = _interopRequireDefault(_rowAbove);
  15797. var _rowBelow2 = _interopRequireDefault(_rowBelow);
  15798. var _separator2 = _interopRequireDefault(_separator);
  15799. var _undo2 = _interopRequireDefault(_undo);
  15800. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15801. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  15802. var 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];
  15803. var _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);
  15804. /**
  15805. * Gets new object with all predefined menu items.
  15806. *
  15807. * @returns {Object}
  15808. */
  15809. function predefinedItems() {
  15810. var items = {};
  15811. (0, _object.objectEach)(_predefinedItems, function (itemFactory, key) {
  15812. items[key] = itemFactory();
  15813. });
  15814. return items;
  15815. }
  15816. /**
  15817. * Add new predefined menu item to the collection.
  15818. *
  15819. * @param {String} key Menu command id.
  15820. * @param {Object} item Object command descriptor.
  15821. */
  15822. function addItem(key, item) {
  15823. if (ITEMS.indexOf(key) === -1) {
  15824. _predefinedItems[key] = item;
  15825. }
  15826. }
  15827. /***/ }),
  15828. /* 72 */
  15829. /***/ (function(module, exports, __webpack_require__) {
  15830. "use strict";
  15831. exports.__esModule = true;
  15832. exports.default = separatorItem;
  15833. var KEY = exports.KEY = '---------';
  15834. function separatorItem() {
  15835. return {
  15836. name: KEY
  15837. };
  15838. }
  15839. /***/ }),
  15840. /* 73 */
  15841. /***/ (function(module, exports) {
  15842. module.exports = function(it){
  15843. if(typeof it != 'function')throw TypeError(it + ' is not a function!');
  15844. return it;
  15845. };
  15846. /***/ }),
  15847. /* 74 */
  15848. /***/ (function(module, exports, __webpack_require__) {
  15849. "use strict";
  15850. var $defineProperty = __webpack_require__(19)
  15851. , createDesc = __webpack_require__(41);
  15852. module.exports = function(object, index, value){
  15853. if(index in object)$defineProperty.f(object, index, createDesc(0, value));
  15854. else object[index] = value;
  15855. };
  15856. /***/ }),
  15857. /* 75 */
  15858. /***/ (function(module, exports, __webpack_require__) {
  15859. var isObject = __webpack_require__(15)
  15860. , document = __webpack_require__(13).document
  15861. // in old IE typeof document.createElement is 'object'
  15862. , is = isObject(document) && isObject(document.createElement);
  15863. module.exports = function(it){
  15864. return is ? document.createElement(it) : {};
  15865. };
  15866. /***/ }),
  15867. /* 76 */
  15868. /***/ (function(module, exports) {
  15869. // IE 8- don't enum bug keys
  15870. module.exports = (
  15871. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  15872. ).split(',');
  15873. /***/ }),
  15874. /* 77 */
  15875. /***/ (function(module, exports, __webpack_require__) {
  15876. var MATCH = __webpack_require__(10)('match');
  15877. module.exports = function(KEY){
  15878. var re = /./;
  15879. try {
  15880. '/./'[KEY](re);
  15881. } catch(e){
  15882. try {
  15883. re[MATCH] = false;
  15884. return !'/./'[KEY](re);
  15885. } catch(f){ /* empty */ }
  15886. } return true;
  15887. };
  15888. /***/ }),
  15889. /* 78 */
  15890. /***/ (function(module, exports, __webpack_require__) {
  15891. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  15892. var cof = __webpack_require__(39);
  15893. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
  15894. return cof(it) == 'String' ? it.split('') : Object(it);
  15895. };
  15896. /***/ }),
  15897. /* 79 */
  15898. /***/ (function(module, exports, __webpack_require__) {
  15899. var ITERATOR = __webpack_require__(10)('iterator')
  15900. , SAFE_CLOSING = false;
  15901. try {
  15902. var riter = [7][ITERATOR]();
  15903. riter['return'] = function(){ SAFE_CLOSING = true; };
  15904. Array.from(riter, function(){ throw 2; });
  15905. } catch(e){ /* empty */ }
  15906. module.exports = function(exec, skipClosing){
  15907. if(!skipClosing && !SAFE_CLOSING)return false;
  15908. var safe = false;
  15909. try {
  15910. var arr = [7]
  15911. , iter = arr[ITERATOR]();
  15912. iter.next = function(){ return {done: safe = true}; };
  15913. arr[ITERATOR] = function(){ return iter; };
  15914. exec(arr);
  15915. } catch(e){ /* empty */ }
  15916. return safe;
  15917. };
  15918. /***/ }),
  15919. /* 80 */
  15920. /***/ (function(module, exports, __webpack_require__) {
  15921. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  15922. var anObject = __webpack_require__(18)
  15923. , dPs = __webpack_require__(403)
  15924. , enumBugKeys = __webpack_require__(76)
  15925. , IE_PROTO = __webpack_require__(83)('IE_PROTO')
  15926. , Empty = function(){ /* empty */ }
  15927. , PROTOTYPE = 'prototype';
  15928. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  15929. var createDict = function(){
  15930. // Thrash, waste and sodomy: IE GC bug
  15931. var iframe = __webpack_require__(75)('iframe')
  15932. , i = enumBugKeys.length
  15933. , lt = '<'
  15934. , gt = '>'
  15935. , iframeDocument;
  15936. iframe.style.display = 'none';
  15937. __webpack_require__(274).appendChild(iframe);
  15938. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  15939. // createDict = iframe.contentWindow.Object;
  15940. // html.removeChild(iframe);
  15941. iframeDocument = iframe.contentWindow.document;
  15942. iframeDocument.open();
  15943. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  15944. iframeDocument.close();
  15945. createDict = iframeDocument.F;
  15946. while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
  15947. return createDict();
  15948. };
  15949. module.exports = Object.create || function create(O, Properties){
  15950. var result;
  15951. if(O !== null){
  15952. Empty[PROTOTYPE] = anObject(O);
  15953. result = new Empty;
  15954. Empty[PROTOTYPE] = null;
  15955. // add "__proto__" for Object.getPrototypeOf polyfill
  15956. result[IE_PROTO] = O;
  15957. } else result = createDict();
  15958. return Properties === undefined ? result : dPs(result, Properties);
  15959. };
  15960. /***/ }),
  15961. /* 81 */
  15962. /***/ (function(module, exports, __webpack_require__) {
  15963. var pIE = __webpack_require__(48)
  15964. , createDesc = __webpack_require__(41)
  15965. , toIObject = __webpack_require__(23)
  15966. , toPrimitive = __webpack_require__(87)
  15967. , has = __webpack_require__(22)
  15968. , IE8_DOM_DEFINE = __webpack_require__(275)
  15969. , gOPD = Object.getOwnPropertyDescriptor;
  15970. exports.f = __webpack_require__(21) ? gOPD : function getOwnPropertyDescriptor(O, P){
  15971. O = toIObject(O);
  15972. P = toPrimitive(P, true);
  15973. if(IE8_DOM_DEFINE)try {
  15974. return gOPD(O, P);
  15975. } catch(e){ /* empty */ }
  15976. if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
  15977. };
  15978. /***/ }),
  15979. /* 82 */
  15980. /***/ (function(module, exports, __webpack_require__) {
  15981. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  15982. var $keys = __webpack_require__(284)
  15983. , hiddenKeys = __webpack_require__(76).concat('length', 'prototype');
  15984. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
  15985. return $keys(O, hiddenKeys);
  15986. };
  15987. /***/ }),
  15988. /* 83 */
  15989. /***/ (function(module, exports, __webpack_require__) {
  15990. var shared = __webpack_require__(84)('keys')
  15991. , uid = __webpack_require__(50);
  15992. module.exports = function(key){
  15993. return shared[key] || (shared[key] = uid(key));
  15994. };
  15995. /***/ }),
  15996. /* 84 */
  15997. /***/ (function(module, exports, __webpack_require__) {
  15998. var global = __webpack_require__(13)
  15999. , SHARED = '__core-js_shared__'
  16000. , store = global[SHARED] || (global[SHARED] = {});
  16001. module.exports = function(key){
  16002. return store[key] || (store[key] = {});
  16003. };
  16004. /***/ }),
  16005. /* 85 */
  16006. /***/ (function(module, exports, __webpack_require__) {
  16007. // helper for String#{startsWith, endsWith, includes}
  16008. var isRegExp = __webpack_require__(279)
  16009. , defined = __webpack_require__(30);
  16010. module.exports = function(that, searchString, NAME){
  16011. if(isRegExp(searchString))throw TypeError('String#' + NAME + " doesn't accept regex!");
  16012. return String(defined(that));
  16013. };
  16014. /***/ }),
  16015. /* 86 */
  16016. /***/ (function(module, exports, __webpack_require__) {
  16017. var ctx = __webpack_require__(29)
  16018. , invoke = __webpack_require__(399)
  16019. , html = __webpack_require__(274)
  16020. , cel = __webpack_require__(75)
  16021. , global = __webpack_require__(13)
  16022. , process = global.process
  16023. , setTask = global.setImmediate
  16024. , clearTask = global.clearImmediate
  16025. , MessageChannel = global.MessageChannel
  16026. , counter = 0
  16027. , queue = {}
  16028. , ONREADYSTATECHANGE = 'onreadystatechange'
  16029. , defer, channel, port;
  16030. var run = function(){
  16031. var id = +this;
  16032. if(queue.hasOwnProperty(id)){
  16033. var fn = queue[id];
  16034. delete queue[id];
  16035. fn();
  16036. }
  16037. };
  16038. var listener = function(event){
  16039. run.call(event.data);
  16040. };
  16041. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  16042. if(!setTask || !clearTask){
  16043. setTask = function setImmediate(fn){
  16044. var args = [], i = 1;
  16045. while(arguments.length > i)args.push(arguments[i++]);
  16046. queue[++counter] = function(){
  16047. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  16048. };
  16049. defer(counter);
  16050. return counter;
  16051. };
  16052. clearTask = function clearImmediate(id){
  16053. delete queue[id];
  16054. };
  16055. // Node.js 0.8-
  16056. if(__webpack_require__(39)(process) == 'process'){
  16057. defer = function(id){
  16058. process.nextTick(ctx(run, id, 1));
  16059. };
  16060. // Browsers with MessageChannel, includes WebWorkers
  16061. } else if(MessageChannel){
  16062. channel = new MessageChannel;
  16063. port = channel.port2;
  16064. channel.port1.onmessage = listener;
  16065. defer = ctx(port.postMessage, port, 1);
  16066. // Browsers with postMessage, skip WebWorkers
  16067. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  16068. } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
  16069. defer = function(id){
  16070. global.postMessage(id + '', '*');
  16071. };
  16072. global.addEventListener('message', listener, false);
  16073. // IE8-
  16074. } else if(ONREADYSTATECHANGE in cel('script')){
  16075. defer = function(id){
  16076. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
  16077. html.removeChild(this);
  16078. run.call(id);
  16079. };
  16080. };
  16081. // Rest old browsers
  16082. } else {
  16083. defer = function(id){
  16084. setTimeout(ctx(run, id, 1), 0);
  16085. };
  16086. }
  16087. }
  16088. module.exports = {
  16089. set: setTask,
  16090. clear: clearTask
  16091. };
  16092. /***/ }),
  16093. /* 87 */
  16094. /***/ (function(module, exports, __webpack_require__) {
  16095. // 7.1.1 ToPrimitive(input [, PreferredType])
  16096. var isObject = __webpack_require__(15);
  16097. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  16098. // and the second argument - flag - preferred type is a string
  16099. module.exports = function(it, S){
  16100. if(!isObject(it))return it;
  16101. var fn, val;
  16102. if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  16103. if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
  16104. if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  16105. throw TypeError("Can't convert object to primitive value");
  16106. };
  16107. /***/ }),
  16108. /* 88 */
  16109. /***/ (function(module, exports, __webpack_require__) {
  16110. "use strict";
  16111. exports.__esModule = true;
  16112. var _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; };
  16113. var _mixed = __webpack_require__(20);
  16114. var _object = __webpack_require__(1);
  16115. /**
  16116. * @alias Options
  16117. * @constructor
  16118. * @description
  16119. * ## Constructor options
  16120. *
  16121. * Constructor options are applied using an object literal passed as a second argument to the Handsontable constructor.
  16122. *
  16123. * ```js
  16124. * var hot = new Handsontable(document.getElementById('example1'), {
  16125. * data: myArray,
  16126. * width: 400,
  16127. * height: 300
  16128. * });
  16129. * ```
  16130. *
  16131. * ---
  16132. * ## Cascading configuration
  16133. *
  16134. * Handsontable 0.9 and newer is using *Cascading Configuration*, which is a fast way to provide configuration options
  16135. * for the entire table, including its columns and particular cells.
  16136. *
  16137. * Consider the following example:
  16138. * ```js
  16139. * var hot = new Handsontable(document.getElementById('example'), {
  16140. * readOnly: true,
  16141. * columns: [
  16142. * {readOnly: false},
  16143. * {},
  16144. * {}
  16145. * ],
  16146. * cells: function (row, col, prop) {
  16147. * var cellProperties = {};
  16148. *
  16149. * if (row === 0 && col === 0) {
  16150. * cellProperties.readOnly = true;
  16151. * }
  16152. *
  16153. * return cellProperties;
  16154. * }
  16155. * });
  16156. * ```
  16157. *
  16158. * 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*.
  16159. *
  16160. * ### The Cascading Configuration model
  16161. *
  16162. * ##### 1. Constructor
  16163. *
  16164. * Configuration options that are provided using first-level `handsontable(container, {option: "value"})` and `updateSettings` method.
  16165. *
  16166. * ##### 2. Columns
  16167. *
  16168. * Configuration options that are provided using second-level object `handsontable(container, {columns: {option: "value"}]})`
  16169. *
  16170. * ##### 3. Cells
  16171. *
  16172. * Configuration options that are provided using second-level function `handsontable(container, {cells: function: (row, col, prop){ }})`
  16173. *
  16174. * ---
  16175. * ## Architecture performance
  16176. *
  16177. * The Cascading Configuration model is based on prototypical inheritance. It is much faster and memory efficient compared
  16178. * to the previous model that used jQuery extend. See: [http://jsperf.com/extending-settings](http://jsperf.com/extending-settings).
  16179. *
  16180. * ---
  16181. * __Important notice:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  16182. */
  16183. function DefaultSettings() {};
  16184. DefaultSettings.prototype = {
  16185. /**
  16186. * @description
  16187. * Initial data source that will be bound to the data grid __by reference__ (editing data grid alters the data source).
  16188. * Can be declared as an Array of Arrays, Array of Objects or a Function.
  16189. *
  16190. * See [Understanding binding as reference](http://docs.handsontable.com/tutorial-data-binding.html#page-reference).
  16191. *
  16192. * @type {Array|Function}
  16193. * @default undefined
  16194. */
  16195. data: void 0,
  16196. /**
  16197. * @description
  16198. * Defines the structure of a new row when data source is an array of objects.
  16199. *
  16200. * See [data-schema](http://docs.handsontable.com/tutorial-data-sources.html#page-data-schema) for examples.
  16201. *
  16202. * @type {Object}
  16203. * @default undefined
  16204. */
  16205. dataSchema: void 0,
  16206. /**
  16207. * Width of the grid. Can be a value or a function that returns a value.
  16208. *
  16209. * @type {Number|Function}
  16210. * @default undefined
  16211. */
  16212. width: void 0,
  16213. /**
  16214. * Height of the grid. Can be a number or a function that returns a number.
  16215. *
  16216. * @type {Number|Function}
  16217. * @default undefined
  16218. */
  16219. height: void 0,
  16220. /**
  16221. * @description
  16222. * Initial number of rows.
  16223. *
  16224. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  16225. *
  16226. * @type {Number}
  16227. * @default 5
  16228. */
  16229. startRows: 5,
  16230. /**
  16231. * @description
  16232. * Initial number of columns.
  16233. *
  16234. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  16235. *
  16236. * @type {Number}
  16237. * @default 5
  16238. */
  16239. startCols: 5,
  16240. /**
  16241. * Setting `true` or `false` will enable or disable the default row headers (1, 2, 3).
  16242. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  16243. * If a function is set the index of the row is passed as a parameter.
  16244. *
  16245. * @type {Boolean|Array|Function}
  16246. * @default null
  16247. * @example
  16248. * ```js
  16249. * ...
  16250. * // as boolean
  16251. * rowHeaders: true,
  16252. * ...
  16253. *
  16254. * ...
  16255. * // as array
  16256. * rowHeaders: [1, 2, 3],
  16257. * ...
  16258. *
  16259. * ...
  16260. * // as function
  16261. * rowHeaders: function(index) {
  16262. * return index + ': AB';
  16263. * },
  16264. * ...
  16265. * ```
  16266. */
  16267. rowHeaders: void 0,
  16268. /**
  16269. * Setting `true` or `false` will enable or disable the default column headers (A, B, C).
  16270. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  16271. * If a function is set, then the index of the column is passed as a parameter.
  16272. *
  16273. * @type {Boolean|Array|Function}
  16274. * @default null
  16275. * @example
  16276. * ```js
  16277. * ...
  16278. * // as boolean
  16279. * colHeaders: true,
  16280. * ...
  16281. *
  16282. * ...
  16283. * // as array
  16284. * colHeaders: ['A', 'B', 'C'],
  16285. * ...
  16286. *
  16287. * ...
  16288. * // as function
  16289. * colHeaders: function(index) {
  16290. * return index + ': AB';
  16291. * },
  16292. * ...
  16293. * ```
  16294. */
  16295. colHeaders: null,
  16296. /**
  16297. * Defines column widths in pixels. Accepts number, string (that will be converted to a number),
  16298. * array of numbers (if you want to define column width separately for each column) or a
  16299. * function (if you want to set column width dynamically on each render).
  16300. *
  16301. * @type {Array|Function|Number|String}
  16302. * @default undefined
  16303. * @example
  16304. * ```js
  16305. * ...
  16306. * // as numeric, for each column.
  16307. * colWidths: 100,
  16308. * ...
  16309. *
  16310. * * ...
  16311. * // as string, for each column.
  16312. * colWidths: '100px',
  16313. * ...
  16314. *
  16315. * ...
  16316. * // as array, based on visual indexes. The rest of the columns have a default width.
  16317. * colWidths: [100, 120, 90],
  16318. * ...
  16319. *
  16320. * ...
  16321. * // as function, based on visual indexes.
  16322. * colWidths: function(index) {
  16323. * return index * 10;
  16324. * },
  16325. * ...
  16326. * ```
  16327. */
  16328. colWidths: void 0,
  16329. /**
  16330. * Defines row heights in pixels. Accepts numbers, strings (that will be converted into a number),
  16331. * array of numbers (if you want to define row height separately for each row) or a
  16332. * function (if you want to set row height dynamically on each render).
  16333. * If the ManualRowResize or AutoRowSize plugins are enabled, this is also the minimum height that can be set
  16334. * via either of those two plugins.
  16335. * Height should be equal or greater than 23px. Table is rendered incorrectly if height is less than 23px.
  16336. *
  16337. * @type {Array|Function|Number|String}
  16338. * @default undefined
  16339. * @example
  16340. * ```js
  16341. * ...
  16342. * // as numeric, for each row.
  16343. * rowHeights: 100,
  16344. * ...
  16345. *
  16346. * * ...
  16347. * // as string, for each row.
  16348. * rowHeights: '100px',
  16349. * ...
  16350. *
  16351. * ...
  16352. * // as array, based on visual indexes. The rest of the rows have a default height.
  16353. * rowHeights: [100, 120, 90],
  16354. * ...
  16355. *
  16356. * ...
  16357. * // as function, based on visual indexes.
  16358. * rowHeights: function(index) {
  16359. * return index * 10;
  16360. * },
  16361. * ...
  16362. * ```
  16363. */
  16364. rowHeights: void 0,
  16365. /**
  16366. * @description
  16367. * Defines the cell properties and data binding for certain columns.
  16368. *
  16369. * __Notice:__ Using this option sets a fixed number of columns (options `startCols`, `minCols`, `maxCols` will be ignored).
  16370. *
  16371. * See [documentation -> datasources.html](http://docs.handsontable.com/tutorial-data-sources.html#page-nested) for examples.
  16372. *
  16373. * @type {Array|Function}
  16374. * @default undefined
  16375. * @example
  16376. * ```js
  16377. * ...
  16378. * // as an array of objects. Order of the objects in array is representation of physical indexes.
  16379. * columns: [
  16380. * {
  16381. * // column options for the first column
  16382. * type: 'numeric',
  16383. * format: '0,0.00 $'
  16384. * },
  16385. * {
  16386. * // column options for the second column
  16387. * type: 'text',
  16388. * readOnly: true
  16389. * }
  16390. * ],
  16391. * ...
  16392. *
  16393. * // or as function, based on physical indexes
  16394. * ...
  16395. * columns: function(index) {
  16396. * return {
  16397. * type: index > 0 ? 'numeric' : 'text',
  16398. * readOnly: index < 1
  16399. * }
  16400. * }
  16401. * ...
  16402. * ```
  16403. */
  16404. columns: void 0,
  16405. /**
  16406. * @description
  16407. * Defines the cell properties for given `row`, `col`, `prop` coordinates.
  16408. * Any constructor or column option may be overwritten for a particular cell (row/column combination)
  16409. * using the `cells` property in the Handsontable constructor.
  16410. *
  16411. * __Note:__ Parameters `row` and `col` always represent __physical indexes__. Example below show how to execute
  16412. * operations based on the __visual__ representation of Handsontable.
  16413. *
  16414. * Possible values of `prop`:
  16415. * - property name for column's data source object, when dataset is an [array of objects](/tutorial-data-sources.html#page-object)
  16416. * - the same number as `col`, when dataset is an [array of arrays](/tutorial-data-sources.html#page-array)
  16417. *
  16418. * @type {Function}
  16419. * @default undefined
  16420. * @example
  16421. * ```js
  16422. * ...
  16423. * cells: function (row, col, prop) {
  16424. * var cellProperties = {};
  16425. * var visualRowIndex = this.instance.toVisualRow(row);
  16426. * var visualColIndex = this.instance.toVisualColumn(col);
  16427. *
  16428. * if (visualRowIndex === 0 && visualColIndex === 0) {
  16429. * cellProperties.readOnly = true;
  16430. * }
  16431. *
  16432. * return cellProperties;
  16433. * },
  16434. * ...
  16435. * ```
  16436. */
  16437. cells: void 0,
  16438. /**
  16439. * Any constructor or column option may be overwritten for a particular cell (row/column combination), using `cell`
  16440. * array passed to the Handsontable constructor.
  16441. *
  16442. * @type {Array}
  16443. * @default []
  16444. * @example
  16445. * ```js
  16446. * ...
  16447. * cell: [
  16448. * {row: 0, col: 0, readOnly: true}
  16449. * ],
  16450. * ...
  16451. * ```
  16452. */
  16453. cell: [],
  16454. /**
  16455. * @description
  16456. * If `true`, enables the {@link Comments} plugin, which enables an option to apply cell comments through the context menu
  16457. * (configurable with context menu keys `commentsAddEdit`, `commentsRemove`).
  16458. *
  16459. * To initialize Handsontable with predefined comments, provide cell coordinates and comment text values in a form of an array.
  16460. *
  16461. * See [Comments](http://docs.handsontable.com/demo-comments_.html) demo for examples.
  16462. *
  16463. * @since 0.11.0
  16464. * @type {Boolean|Array}
  16465. * @default false
  16466. * @example
  16467. * ```js
  16468. * ...
  16469. * comments: [{row: 1, col: 1, comment: {value: "Test comment"}}],
  16470. * ...
  16471. * ```
  16472. */
  16473. comments: false,
  16474. /**
  16475. * @description
  16476. * 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`).
  16477. *
  16478. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  16479. *
  16480. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for examples.
  16481. *
  16482. * @since 0.11.0
  16483. * @type {Boolean|Array}
  16484. * @default false
  16485. * @example
  16486. * ```js
  16487. * ...
  16488. * customBorders: [
  16489. * {range: {
  16490. * from: {row: 1, col: 1},
  16491. * to: {row: 3, col: 4}},
  16492. * left: {},
  16493. * right: {},
  16494. * top: {},
  16495. * bottom: {}
  16496. * }
  16497. * ],
  16498. * ...
  16499. *
  16500. * // or
  16501. * ...
  16502. * customBorders: [
  16503. * {row: 2, col: 2, left: {width: 2, color: 'red'},
  16504. * right: {width: 1, color: 'green'}, top: '', bottom: ''}
  16505. * ],
  16506. * ...
  16507. * ```
  16508. */
  16509. customBorders: false,
  16510. /**
  16511. * Minimum number of rows. At least that number of rows will be created during initialization.
  16512. *
  16513. * @type {Number}
  16514. * @default 0
  16515. */
  16516. minRows: 0,
  16517. /**
  16518. * Minimum number of columns. At least that number of columns will be created during initialization.
  16519. *
  16520. * @type {Number}
  16521. * @default 0
  16522. */
  16523. minCols: 0,
  16524. /**
  16525. * 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.
  16526. *
  16527. * @type {Number}
  16528. * @default Infinity
  16529. */
  16530. maxRows: Infinity,
  16531. /**
  16532. * 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.
  16533. *
  16534. * @type {Number}
  16535. * @default Infinity
  16536. */
  16537. maxCols: Infinity,
  16538. /**
  16539. * When set to 1 (or more), Handsontable will add a new row at the end of grid if there are no more empty rows.
  16540. * (unless the number of rows exceeds the one set in the `maxRows` property)
  16541. *
  16542. * @type {Number}
  16543. * @default 0
  16544. */
  16545. minSpareRows: 0,
  16546. /**
  16547. * When set to 1 (or more), Handsontable will add a new column at the end of grid if there are no more empty columns.
  16548. * (unless the number of rows exceeds the one set in the `maxCols` property)
  16549. *
  16550. * @type {Number}
  16551. * @default 0
  16552. */
  16553. minSpareCols: 0,
  16554. /**
  16555. * If set to `false`, there won't be an option to insert new rows in the Context Menu.
  16556. *
  16557. * @type {Boolean}
  16558. * @default true
  16559. */
  16560. allowInsertRow: true,
  16561. /**
  16562. * If set to `false`, there won't be an option to insert new columns in the Context Menu.
  16563. *
  16564. * @type {Boolean}
  16565. * @default true
  16566. */
  16567. allowInsertColumn: true,
  16568. /**
  16569. * If set to `false`, there won't be an option to remove rows in the Context Menu.
  16570. *
  16571. * @type {Boolean}
  16572. * @default true
  16573. */
  16574. allowRemoveRow: true,
  16575. /**
  16576. * If set to `false`, there won't be an option to remove columns in the Context Menu.
  16577. *
  16578. * @type {Boolean}
  16579. * @default true
  16580. */
  16581. allowRemoveColumn: true,
  16582. /**
  16583. * If true, selection of multiple cells using keyboard or mouse is allowed.
  16584. *
  16585. * @type {Boolean}
  16586. * @default true
  16587. */
  16588. multiSelect: true,
  16589. /**
  16590. * Enables the fill handle (drag-down and copy-down) functionality, which shows a small rectangle in bottom
  16591. * right corner of the selected area, that let's you expand values to the adjacent cells.
  16592. *
  16593. * Possible values: `true` (to enable in all directions), `'vertical'` or `'horizontal'` (to enable in one direction),
  16594. * `false` (to disable completely). Setting to `true` enables the fillHandle plugin.
  16595. *
  16596. * Since 0.23.0 you can pass object to plugin which allows you to add more options for this functionality. If `autoInsertRow`
  16597. * option is `true`, fill-handler will create new rows till it reaches the last row. It is enabled by default.
  16598. *
  16599. * @example
  16600. * ```js
  16601. * ...
  16602. * fillHandle: true // enable plugin in all directions and with autoInsertRow as true
  16603. * ...
  16604. * // or
  16605. * ...
  16606. * fillHandle: 'vertical' // enable plugin in vertical direction and with autoInsertRow as true
  16607. * ...
  16608. * // or
  16609. * ...
  16610. * fillHandle: { // enable plugin in both directions and with autoInsertRow as false
  16611. * autoInsertRow: false,
  16612. * }
  16613. * // or
  16614. * ...
  16615. * fillHandle: { // enable plugin in vertical direction and with autoInsertRow as false
  16616. * autoInsertRow: false,
  16617. * direction: 'vertical' // 'vertical' or 'horizontal'
  16618. * }
  16619. * ```
  16620. *
  16621. * @type {Boolean|String|Object}
  16622. * @default true
  16623. */
  16624. fillHandle: true,
  16625. /**
  16626. * Allows to specify the number of fixed (or *frozen*) rows at the top of the table.
  16627. *
  16628. * @type {Number}
  16629. * @default 0
  16630. * @example
  16631. * ```js
  16632. * fixedRowsTop: 3 // This would freeze the top 3 rows of the table.
  16633. * ```
  16634. */
  16635. fixedRowsTop: 0,
  16636. /**
  16637. * Allows to specify the number of fixed (or *frozen*) rows at the bottom of the table.
  16638. *
  16639. * @pro
  16640. * @type {Number}
  16641. * @default 0
  16642. * @example
  16643. * ```js
  16644. * fixedRowsBottom: 3 // This would freeze the top 3 rows of the table.
  16645. * ```
  16646. */
  16647. fixedRowsBottom: 0,
  16648. /**
  16649. * Allows to specify the number of fixed (or *frozen*) columns on the left of the table.
  16650. *
  16651. * @type {Number}
  16652. * @default 0
  16653. * @example
  16654. * ```js
  16655. * fixedColumnsLeft: 3 // This would freeze the top 3 rows of the table.
  16656. * ```
  16657. */
  16658. fixedColumnsLeft: 0,
  16659. /**
  16660. * If `true`, mouse click outside the grid will deselect the current selection.
  16661. * Can be a function that takes the click event target and returns a boolean.
  16662. *
  16663. * @type {Boolean|Function}
  16664. * @default true
  16665. */
  16666. outsideClickDeselects: true,
  16667. /**
  16668. * If `true`, <kbd>ENTER</kbd> begins editing mode (like in Google Docs). If `false`, <kbd>ENTER</kbd> moves to next
  16669. * row (like Excel) and adds a new row if necessary. <kbd>TAB</kbd> adds new column if necessary.
  16670. *
  16671. * @type {Boolean}
  16672. * @default true
  16673. */
  16674. enterBeginsEditing: true,
  16675. /**
  16676. * Defines the cursor movement after <kbd>ENTER</kbd> was pressed (<kbd>SHIFT</kbd> + <kbd>ENTER</kbd> uses a negative vector).
  16677. * Can be an object or a function that returns an object. The event argument passed to the function
  16678. * is a DOM Event object received after the <kbd>ENTER</kbd> key has been pressed. This event object can be used to check
  16679. * whether user pressed <kbd>ENTER</kbd> or <kbd>SHIFT</kbd> + <kbd>ENTER</kbd>.
  16680. *
  16681. * @type {Object|Function}
  16682. * @default {row: 1, col: 0}
  16683. */
  16684. enterMoves: { row: 1, col: 0 },
  16685. /**
  16686. * Defines the cursor movement after <kbd>TAB</kbd> is pressed (<kbd>SHIFT</kbd> + <kbd>TAB</kbd> uses a negative vector).
  16687. * Can be an object or a function that returns an object. The event argument passed to the function
  16688. * is a DOM Event object received after the <kbd>TAB</kbd> key has been pressed. This event object can be used to check
  16689. * whether user pressed <kbd>TAB</kbd> or <kbd>SHIFT</kbd> + <kbd>TAB</kbd>.
  16690. *
  16691. * @type {Object}
  16692. * @default {row: 0, col: 1}
  16693. */
  16694. tabMoves: { row: 0, col: 1 },
  16695. /**
  16696. * If `true`, pressing <kbd>TAB</kbd> or right arrow in the last column will move to first column in next row.
  16697. *
  16698. * @type {Boolean}
  16699. * @default false
  16700. */
  16701. autoWrapRow: false,
  16702. /**
  16703. * If `true`, pressing <kbd>ENTER</kbd> or down arrow in the last row will move to the first row in the next column.
  16704. *
  16705. * @type {Boolean}
  16706. * @default false
  16707. */
  16708. autoWrapCol: false,
  16709. /**
  16710. * @description
  16711. * Turns on saving the state of column sorting, column positions and column sizes in local storage.
  16712. *
  16713. * You can save any sort of data in local storage to preserve table state between page reloads.
  16714. * In order to enable data storage mechanism, `persistentState` option must be set to `true` (you can set it
  16715. * either during Handsontable initialization or using the `updateSettings` method). When `persistentState` is enabled it exposes 3 hooks:
  16716. *
  16717. * __persistentStateSave__ (key: String, value: Mixed)
  16718. *
  16719. * * Saves value under given key in browser local storage.
  16720. *
  16721. * __persistentStateLoad__ (key: String, valuePlaceholder: Object)
  16722. *
  16723. * * Loads `value`, saved under given key, form browser local storage. The loaded `value` will be saved in `valuePlaceholder.value`
  16724. * (this is due to specific behaviour of `Hooks.run()` method). If no value have been saved under key `valuePlaceholder.value`
  16725. * will be `undefined`.
  16726. *
  16727. * __persistentStateReset__ (key: String)
  16728. *
  16729. * * Clears the value saved under `key`. If no `key` is given, all values associated with table will be cleared.
  16730. *
  16731. * __Note:__ The main reason behind using `persistentState` hooks rather than regular LocalStorage API is that it
  16732. * ensures separation of data stored by multiple Handsontable instances. In other words, if you have two (or more)
  16733. * instances of Handsontable on one page, data saved by one instance won't be accessible by the second instance.
  16734. * Those two instances can store data under the same key and no data would be overwritten.
  16735. *
  16736. * __Important:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  16737. *
  16738. * @type {Boolean}
  16739. * @default false
  16740. */
  16741. persistentState: void 0,
  16742. /**
  16743. * Class name for all visible rows in the current selection.
  16744. *
  16745. * @type {String}
  16746. * @default undefined
  16747. * @example
  16748. * ```js
  16749. * currentRowClassName: 'currentRow' // This will add a 'currentRow' class name to appropriate table cells.
  16750. * ```
  16751. */
  16752. currentRowClassName: void 0,
  16753. /**
  16754. * Class name for all visible columns in the current selection.
  16755. *
  16756. * @type {String}
  16757. * @default undefined
  16758. * @example
  16759. * ```js
  16760. * currentColClassName: 'currentColumn' // This will add a 'currentColumn' class name to appropriate table cells.
  16761. * ```
  16762. */
  16763. currentColClassName: void 0,
  16764. /**
  16765. * Class name for all visible headers in current selection.
  16766. *
  16767. * @type {String}
  16768. * @since 0.27.0
  16769. * @default 'ht__highlight'
  16770. * @example
  16771. * ```js
  16772. * currentHeaderClassName: 'ht__highlight' // This will add a 'ht__highlight' class name to appropriate table headers.
  16773. * ```
  16774. */
  16775. currentHeaderClassName: 'ht__highlight',
  16776. /**
  16777. * Class name for the Handsontable container element.
  16778. *
  16779. * @type {String|Array}
  16780. * @default undefined
  16781. */
  16782. className: void 0,
  16783. /**
  16784. * Class name for all tables inside container element.
  16785. *
  16786. * @since 0.17.0
  16787. * @type {String|Array}
  16788. * @default undefined
  16789. */
  16790. tableClassName: void 0,
  16791. /**
  16792. * @description
  16793. * Defines how the columns react, when the declared table width is different than the calculated sum of all column widths.
  16794. * [See more](http://docs.handsontable.com/demo-stretching.html) mode. Possible values:
  16795. * * `'none'` Disable stretching
  16796. * * `'last'` Stretch only the last column
  16797. * * `'all'` Stretch all the columns evenly
  16798. *
  16799. * @type {String}
  16800. * @default 'none'
  16801. */
  16802. stretchH: 'none',
  16803. /**
  16804. * Lets you overwrite the default `isEmptyRow` method, which checks if row at the provided index is empty.
  16805. *
  16806. * @type {Function}
  16807. * @param {Number} row Visual row index.
  16808. * @returns {Boolean}
  16809. */
  16810. isEmptyRow: function isEmptyRow(row) {
  16811. var col, colLen, value, meta;
  16812. for (col = 0, colLen = this.countCols(); col < colLen; col++) {
  16813. value = this.getDataAtCell(row, col);
  16814. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  16815. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  16816. meta = this.getCellMeta(row, col);
  16817. return (0, _object.isObjectEquals)(this.getSchema()[meta.prop], value);
  16818. }
  16819. return false;
  16820. }
  16821. }
  16822. return true;
  16823. },
  16824. /**
  16825. * Lets you overwrite the default `isEmptyCol` method, which checks if column at the provided index is empty.
  16826. *
  16827. * @type {Function}
  16828. * @param {Number} col Visual column index
  16829. * @returns {Boolean}
  16830. */
  16831. isEmptyCol: function isEmptyCol(col) {
  16832. var row, rowLen, value;
  16833. for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
  16834. value = this.getDataAtCell(row, col);
  16835. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  16836. return false;
  16837. }
  16838. }
  16839. return true;
  16840. },
  16841. /**
  16842. * When set to `true`, the table is re-rendered when it is detected that it was made visible in DOM.
  16843. *
  16844. * @type {Boolean}
  16845. * @default true
  16846. */
  16847. observeDOMVisibility: true,
  16848. /**
  16849. * If set to `true`, Handsontable will accept values that were marked as invalid by the cell `validator`.
  16850. * It will result with *invalid* cells being treated as *valid* (will save the *invalid* value into the Handsontable data source).
  16851. * If set to `false`, Handsontable will *not* accept the invalid values and won't allow the user to close the editor.
  16852. * This option will be particularly useful when used with the Autocomplete's `strict` mode.
  16853. *
  16854. * @type {Boolean}
  16855. * @default true
  16856. * @since 0.9.5
  16857. */
  16858. allowInvalid: true,
  16859. /**
  16860. * If set to `true`, Handsontable will accept values that are empty (`null`, `undefined` or `''`).
  16861. * If set to `false`, Handsontable will *not* accept the empty values and mark cell as invalid.
  16862. *
  16863. * @example
  16864. * ```js
  16865. * ...
  16866. * allowEmpty: true // allow empty values for all cells (whole table)
  16867. * ...
  16868. * // or
  16869. * ...
  16870. * columns: [
  16871. * // allow empty values only for 'date' column
  16872. * {data: 'date', dateFormat: 'DD/MM/YYYY', allowEmpty: true}
  16873. * ]
  16874. * ...
  16875. * ```
  16876. *
  16877. * @type {Boolean}
  16878. * @default true
  16879. * @since 0.23.0
  16880. */
  16881. allowEmpty: true,
  16882. /**
  16883. * CSS class name for cells that did not pass validation.
  16884. *
  16885. * @type {String}
  16886. * @default 'htInvalid'
  16887. */
  16888. invalidCellClassName: 'htInvalid',
  16889. /**
  16890. * When set to an non-empty string, displayed as the cell content for empty cells. If a value of a different type is provided,
  16891. * it will be stringified and applied as a string.
  16892. *
  16893. * @type {Mixed}
  16894. * @default false
  16895. */
  16896. placeholder: false,
  16897. /**
  16898. * CSS class name for cells that have a placeholder in use.
  16899. *
  16900. * @type {String}
  16901. * @default 'htPlaceholder'
  16902. */
  16903. placeholderCellClassName: 'htPlaceholder',
  16904. /**
  16905. * CSS class name for read-only cells.
  16906. *
  16907. * @type {String}
  16908. * @default 'htDimmed'
  16909. */
  16910. readOnlyCellClassName: 'htDimmed',
  16911. /**
  16912. * @description
  16913. * If a string is provided, it may be one of the following predefined values:
  16914. * * `autocomplete`,
  16915. * * `checkbox`,
  16916. * * `html`,
  16917. * * `numeric`,
  16918. * * `password`.
  16919. * * `text`.
  16920. *
  16921. * Or you can [register](http://docs.handsontable.com/demo-custom-renderers.html) the custom renderer under specified name and use
  16922. * its name as an alias in your configuration.
  16923. *
  16924. * If a function is provided, it will receive the following arguments:
  16925. * ```js
  16926. * function(instance, TD, row, col, prop, value, cellProperties) {}
  16927. * ```
  16928. *
  16929. * You can read more about custom renderes [in the documentation](http://docs.handsontable.com/demo-custom-renderers.html).
  16930. *
  16931. * @example
  16932. * ```js
  16933. * ...
  16934. * Handsontable.renderers.registerRenderer('my.renderer', function(instance, TD, row, col, prop, value, cellProperties) {
  16935. * TD.innerHTML = value;
  16936. * });
  16937. * ...
  16938. * columns: [
  16939. * {
  16940. * editor: 'select',
  16941. * renderer: 'autocomplete' // as string
  16942. * },
  16943. * {
  16944. * renderer: 'my.renderer' // custom renderer as an alias
  16945. * },
  16946. * {
  16947. * // renderer as custom function
  16948. * renderer: function(hotInstance, TD, row, col, prop, value, cellProperties) {
  16949. * TD.style.color = 'blue';
  16950. * TD.innerHTML = value;
  16951. * }
  16952. * }
  16953. * ]
  16954. * ...
  16955. * ```
  16956. *
  16957. * @type {String|Function}
  16958. * @default undefined
  16959. */
  16960. renderer: void 0,
  16961. /**
  16962. * CSS class name added to the commented cells.
  16963. *
  16964. * @type {String}
  16965. * @default 'htCommentCell'
  16966. */
  16967. commentedCellClassName: 'htCommentCell',
  16968. /**
  16969. * 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.
  16970. * If set to `'cell'`, it enables the possibility of selecting a fragment of the text within a single cell's body.
  16971. *
  16972. * @type {Boolean|String}
  16973. * @default false
  16974. */
  16975. fragmentSelection: false,
  16976. /**
  16977. * @description
  16978. * Make cell [read only](http://docs.handsontable.com/demo-read-only.html).
  16979. *
  16980. * @type {Boolean}
  16981. * @default false
  16982. */
  16983. readOnly: false,
  16984. /**
  16985. * @description
  16986. * When added to a `column` property, it skips the column on paste and pastes the data on the next column to the right.
  16987. *
  16988. * @type {Boolean}
  16989. * @default false
  16990. */
  16991. skipColumnOnPaste: false,
  16992. /**
  16993. * @description
  16994. * Setting to true enables the search plugin (see [demo](http://docs.handsontable.com/demo-search-for-values.html)).
  16995. *
  16996. * @type {Boolean}
  16997. * @default false
  16998. */
  16999. search: false,
  17000. /**
  17001. * @description
  17002. * Shortcut to define the combination of the cell renderer, editor and validator for the column, cell or whole table.
  17003. *
  17004. * Possible values:
  17005. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  17006. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  17007. * * [date](http://docs.handsontable.com/demo-date.html)
  17008. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  17009. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  17010. * * [numeric](http://docs.handsontable.com/demo-numeric.html)
  17011. * * [password](http://docs.handsontable.com/demo-password.html)
  17012. * * text
  17013. * * [time](http://docs.handsontable.com/demo-time.html)
  17014. *
  17015. * Or you can register the custom cell type under specified name and use
  17016. * its name as an alias in your configuration.
  17017. *
  17018. * @example
  17019. * ```js
  17020. * ...
  17021. * Handsontable.cellTypes.registerCellType('my.type', {
  17022. * editor: MyEditorClass,
  17023. * renderer: function(hot, td, row, col, prop, value, cellProperties) {
  17024. * td.innerHTML = value;
  17025. * },
  17026. * validator: function(value, callback) {
  17027. * callback(value === 'foo' ? true : false);
  17028. * }
  17029. * });
  17030. * ...
  17031. * columns: [
  17032. * {
  17033. * type: 'text'
  17034. * },
  17035. * {
  17036. * type: 'my.type' // an alias to custom type
  17037. * },
  17038. * {
  17039. * type: 'checkbox'
  17040. * }
  17041. * ]
  17042. * ...
  17043. * ```
  17044. *
  17045. * @type {String}
  17046. * @default 'text'
  17047. */
  17048. type: 'text',
  17049. /**
  17050. * @description
  17051. * Make cell copyable (pressing <kbd>CTRL</kbd> + <kbd>C</kbd> on your keyboard moves its value to system clipboard).
  17052. *
  17053. * __Note:__ this setting is `false` by default for cells with type `password`.
  17054. *
  17055. * @type {Boolean}
  17056. * @default true
  17057. * @since 0.10.2
  17058. */
  17059. copyable: true,
  17060. /**
  17061. * Defines the editor for the table/column/cell.
  17062. *
  17063. * If a string is provided, it may be one of the following predefined values:
  17064. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  17065. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  17066. * * [date](http://docs.handsontable.com/demo-date.html)
  17067. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  17068. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  17069. * * [mobile](http://docs.handsontable.com/demo-mobiles-and-tablets.html)
  17070. * * [password](http://docs.handsontable.com/demo-password.html)
  17071. * * [select](http://docs.handsontable.com/demo-select.html)
  17072. * * text
  17073. *
  17074. * Or you can [register](http://docs.handsontable.com/tutorial-cell-editor.html#registering-an-editor) the custom editor under specified name and use
  17075. * its name as an alias in your configuration.
  17076. *
  17077. * To disable cell editing completely set `editor` property to `false`.
  17078. *
  17079. * @example
  17080. * ```js
  17081. * ...
  17082. * columns: [
  17083. * {
  17084. * editor: 'select'
  17085. * },
  17086. * {
  17087. * editor: false
  17088. * }
  17089. * ]
  17090. * ...
  17091. * ```
  17092. *
  17093. * @type {String|Function|Boolean}
  17094. * @default 'text'
  17095. */
  17096. editor: void 0,
  17097. /**
  17098. * @description
  17099. * Autocomplete definitions. See [autocomplete demo](http://docs.handsontable.com/demo-autocomplete.html) for examples and definitions.
  17100. *
  17101. * @type {Array}
  17102. * @default undefined
  17103. */
  17104. autoComplete: void 0,
  17105. /**
  17106. * Control number of choices for the autocomplete (or dropdown) typed cells. After exceeding it, a scrollbar for the dropdown list of choices will appear.
  17107. *
  17108. * @since 0.18.0
  17109. * @type {Number}
  17110. * @default 10
  17111. */
  17112. visibleRows: 10,
  17113. /**
  17114. * Makes autocomplete or dropdown width the same as the edited cell width. If `false` then editor will be scaled
  17115. * according to its content.
  17116. *
  17117. * @since 0.17.0
  17118. * @type {Boolean}
  17119. * @default true
  17120. */
  17121. trimDropdown: true,
  17122. /**
  17123. * Setting to true enables the debug mode, currently used to test the correctness of the row and column
  17124. * header fixed positioning on a layer above the master table.
  17125. *
  17126. * @type {Boolean}
  17127. * @default false
  17128. */
  17129. debug: false,
  17130. /**
  17131. * When set to `true`, the text of the cell content is wrapped if it does not fit in the fixed column width.
  17132. *
  17133. * @type {Boolean}
  17134. * @default true
  17135. * @since 0.11.0
  17136. */
  17137. wordWrap: true,
  17138. /**
  17139. * CSS class name added to cells with cell meta `wordWrap: false`.
  17140. *
  17141. * @type {String}
  17142. * @default 'htNoWrap'
  17143. * @since 0.11.0
  17144. */
  17145. noWordWrapClassName: 'htNoWrap',
  17146. /**
  17147. * @description
  17148. * Defines if the right-click context menu should be enabled. Context menu allows to create new row or
  17149. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  17150. * Possible values:
  17151. * * `true` (to enable default options),
  17152. * * `false` (to disable completely)
  17153. * * an array of [predefined options](https://docs.handsontable.com/demo-context-menu.html#page-specific),
  17154. * * an object [with defined structure](http://docs.handsontable.com/demo-context-menu.html#page-custom)
  17155. *
  17156. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  17157. *
  17158. * @example
  17159. * ```js
  17160. * ...
  17161. * // as a boolean
  17162. * contextMenu: true
  17163. * ...
  17164. * // as an array
  17165. * contextMenu: ['row_above', 'row_below', '--------', 'undo', 'redo']
  17166. * ...
  17167. * ```
  17168. * ...
  17169. * // as an object (`name` attribute is required in the custom keys)
  17170. * contextMenu: {
  17171. * items: {
  17172. * "option1": {
  17173. * name: "option1"
  17174. * },
  17175. * "option2": {
  17176. * name: "option2",
  17177. * submenu: {
  17178. * items: [
  17179. * {
  17180. * key: "option2:suboption1",
  17181. * name: "option2:suboption1",
  17182. * callback: function(key, options) {
  17183. * ...
  17184. * }
  17185. * },
  17186. * ...
  17187. * ]
  17188. * }
  17189. * }
  17190. * }
  17191. * }
  17192. * ...
  17193. * ```
  17194. * @type {Boolean|Array|Object}
  17195. * @default undefined
  17196. */
  17197. contextMenu: void 0,
  17198. /**
  17199. * @description
  17200. * Disable or enable the copy/paste functionality.
  17201. *
  17202. * @example
  17203. * ```js
  17204. * ...
  17205. * copyPaste: false,
  17206. * ...
  17207. * ```
  17208. *
  17209. * @type {Boolean}
  17210. * @default true
  17211. */
  17212. copyPaste: true,
  17213. /**
  17214. * If `true`, undo/redo functionality is enabled.
  17215. *
  17216. * @type {Boolean}
  17217. * @default undefined
  17218. */
  17219. undo: void 0,
  17220. /**
  17221. * @description
  17222. * Turns on [Column sorting](http://docs.handsontable.com/demo-sorting-data.html).
  17223. * Can be either a boolean (true/false) or an object with a declared sorting options. See the below example:
  17224. *
  17225. * @example
  17226. * ```js
  17227. * ...
  17228. * // as boolean
  17229. * columnSorting: true
  17230. * ...
  17231. * // as a object with initial order (sort ascending column at index 2)
  17232. * columnSorting: {
  17233. * column: 2,
  17234. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  17235. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  17236. * }
  17237. * ...
  17238. * ```
  17239. *
  17240. * @type {Boolean|Object}
  17241. * @default undefined
  17242. */
  17243. columnSorting: void 0,
  17244. /**
  17245. * @description
  17246. * Turns on [Manual column move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  17247. * column order, if set to an array of column indexes.
  17248. *
  17249. * @example
  17250. * ```js
  17251. * ...
  17252. * // as boolean
  17253. * manualColumnMove: true
  17254. * ...
  17255. * // as a array with initial order (move column index at 0 to 1 and move column index at 1 to 4)
  17256. * manualColumnMove: [1, 4]
  17257. * ...
  17258. * ```
  17259. *
  17260. * @type {Boolean|Array}
  17261. * @default undefined
  17262. */
  17263. manualColumnMove: void 0,
  17264. /**
  17265. * @description
  17266. * Turns on [Manual column resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  17267. * column resized widths, if set to an array of numbers.
  17268. *
  17269. * @example
  17270. * ```js
  17271. * ...
  17272. * // as boolean
  17273. * manualColumnResize: true
  17274. * ...
  17275. * // as a array with initial widths (column at 0 index has 40px and column at 1 index has 50px)
  17276. * manualColumnResize: [40, 50]
  17277. * ...
  17278. * ```
  17279. *
  17280. * @type {Boolean|Array}
  17281. * @default undefined
  17282. */
  17283. manualColumnResize: void 0,
  17284. /**
  17285. * @description
  17286. * Turns on [Manual row move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  17287. * row order, if set to an array of row indexes.
  17288. *
  17289. * @example
  17290. * ```js
  17291. * ...
  17292. * // as boolean
  17293. * manualRowMove: true
  17294. * ...
  17295. * // as a array with initial order (move row index at 0 to 1 and move row index at 1 to 4)
  17296. * manualRowMove: [1, 4]
  17297. * ...
  17298. * ```
  17299. *
  17300. * @type {Boolean|Array}
  17301. * @default undefined
  17302. * @since 0.11.0
  17303. */
  17304. manualRowMove: void 0,
  17305. /**
  17306. * @description
  17307. * Turns on [Manual row resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  17308. * row resized heights, if set to an array of numbers.
  17309. *
  17310. * @example
  17311. * ```js
  17312. * ...
  17313. * // as boolean
  17314. * manualRowResize: true
  17315. * ...
  17316. * // as a array with initial heights (row at 0 index has 40px and row at 1 index has 50px)
  17317. * manualRowResize: [40, 50]
  17318. * ...
  17319. * ```
  17320. *
  17321. * @type {Boolean|Array}
  17322. * @default undefined
  17323. * @since 0.11.0
  17324. */
  17325. manualRowResize: void 0,
  17326. /**
  17327. * @description
  17328. * 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).
  17329. * [More information on the demo page.](http://docs.handsontable.com/demo-merge-cells.html)
  17330. *
  17331. * @example
  17332. * ```js
  17333. * // enables the mergeCells plugin:
  17334. * margeCells: true
  17335. * ...
  17336. * // declares a list of merged sections:
  17337. * mergeCells: [
  17338. * {row: 1, col: 1, rowspan: 3, colspan: 3}, // rowspan and colspan properties declare the width and height of a merged section in cells
  17339. * {row: 3, col: 4, rowspan: 2, colspan: 2},
  17340. * {row: 5, col: 6, rowspan: 3, colspan: 3}
  17341. * ]
  17342. * ```
  17343. * @type {Boolean|Array}
  17344. * @default false
  17345. */
  17346. mergeCells: false,
  17347. /**
  17348. * Number of rows to be rendered outside of the visible part of the table.
  17349. * By default, it's set to `'auto'`, which makes Handsontable to attempt to calculate the best offset performance-wise.
  17350. *
  17351. * You may test out different values to find the best one that works for your specific implementation.
  17352. *
  17353. * @type {Number|String}
  17354. * @default 'auto'
  17355. */
  17356. viewportRowRenderingOffset: 'auto',
  17357. /**
  17358. * Number of columns to be rendered outside of the visible part of the table.
  17359. * By default, it's set to `'auto'`, which makes Handsontable try calculating the best offset performance-wise.
  17360. *
  17361. * You may experiment with the value to find the one that works best for your specific implementation.
  17362. *
  17363. * @type {Number|String}
  17364. * @default 'auto'
  17365. */
  17366. viewportColumnRenderingOffset: 'auto',
  17367. /**
  17368. * A function, regular expression or a string, which will be used in the process of cell validation.
  17369. * If a function is used, be sure to execute the callback argument with either `true` (`callback(true)`) if the validation passed
  17370. * or with `false` (`callback(false)`), if the validation failed.
  17371. * Note, that `this` in the function points to the `cellProperties` object.
  17372. *
  17373. * If a string is provided, it may be one of the following predefined values:
  17374. * * `autocomplete`,
  17375. * * `date`,
  17376. * * `numeric`,
  17377. * * `time`.
  17378. *
  17379. * Or you can [register](http://docs.handsontable.com/demo-data-validation.html) the validator function under specified name and use
  17380. * its name as an alias in your configuration.
  17381. *
  17382. * See more [in the demo](http://docs.handsontable.com/demo-data-validation.html).
  17383. *
  17384. * @example
  17385. * ```js
  17386. * // as a function
  17387. * columns: [
  17388. * {
  17389. * validator: function(value, callback) { // validation rules }
  17390. * }
  17391. * ]
  17392. * ...
  17393. * // as a regexp
  17394. * columns: [
  17395. * {
  17396. * validator: /^[0-9]$/ // regular expression
  17397. * }
  17398. * ]
  17399. * // as a string
  17400. * columns: [
  17401. * {
  17402. * validator: 'numeric'
  17403. * }
  17404. * ]
  17405. * ```
  17406. * @type {Function|RegExp|String}
  17407. * @default undefined
  17408. * @since 0.9.5
  17409. */
  17410. validator: void 0,
  17411. /**
  17412. * @description
  17413. * Disable visual cells selection.
  17414. *
  17415. * Possible values:
  17416. * * `true` - Disables any type of visual selection (current and area selection),
  17417. * * `false` - Enables any type of visual selection. This is default value.
  17418. * * `current` - Disables the selection of a currently selected cell, the area selection is still present.
  17419. * * `area` - Disables the area selection, the currently selected cell selection is still present.
  17420. *
  17421. * @type {Boolean|String|Array}
  17422. * @default false
  17423. * @since 0.13.2
  17424. * @example
  17425. * ```js
  17426. * ...
  17427. * // as boolean
  17428. * disableVisualSelection: true,
  17429. * ...
  17430. *
  17431. * ...
  17432. * // as string ('current' or 'area')
  17433. * disableVisualSelection: 'current',
  17434. * ...
  17435. *
  17436. * ...
  17437. * // as array
  17438. * disableVisualSelection: ['current', 'area'],
  17439. * ...
  17440. * ```
  17441. */
  17442. disableVisualSelection: false,
  17443. /**
  17444. * @description
  17445. * Set whether to display the current sorting order indicator (a triangle icon in the column header, specifying the sorting order).
  17446. *
  17447. * @type {Boolean}
  17448. * @default false
  17449. * @since 0.15.0-beta3
  17450. */
  17451. sortIndicator: void 0,
  17452. /**
  17453. * Disable or enable ManualColumnFreeze plugin.
  17454. *
  17455. * @type {Boolean}
  17456. * @default false
  17457. */
  17458. manualColumnFreeze: void 0,
  17459. /**
  17460. * @description
  17461. * Defines whether Handsontable should trim the whitespace at the beginning and the end of the cell contents.
  17462. *
  17463. * @type {Boolean}
  17464. * @default true
  17465. */
  17466. trimWhitespace: true,
  17467. settings: void 0,
  17468. /**
  17469. * @description
  17470. * Defines data source for Autocomplete or Dropdown cell types.
  17471. *
  17472. * @example
  17473. * ```js
  17474. * ...
  17475. * // source as a array
  17476. * columns: [{
  17477. * type: 'autocomplete',
  17478. * source: ['A', 'B', 'C', 'D']
  17479. * }]
  17480. * ...
  17481. * // source as a function
  17482. * columns: [{
  17483. * type: 'autocomplete',
  17484. * source: function(query, callback) {
  17485. * fetch('http://example.com/query?q=' + query, function(response) {
  17486. * callback(response.items);
  17487. * })
  17488. * }
  17489. * }]
  17490. * ...
  17491. * ```
  17492. *
  17493. * @type {Array|Function}
  17494. * @default undefined
  17495. */
  17496. source: void 0,
  17497. /**
  17498. * @description
  17499. * Defines the column header name.
  17500. *
  17501. * @example
  17502. * ```js
  17503. * ...
  17504. * columns: [{
  17505. * title: 'First name',
  17506. * type: 'text',
  17507. * },
  17508. * {
  17509. * title: 'Last name',
  17510. * type: 'text',
  17511. * }]
  17512. * ...
  17513. * ```
  17514. *
  17515. * @type {String}
  17516. * @default undefined
  17517. */
  17518. title: void 0,
  17519. /**
  17520. * Data template for `'checkbox'` type when checkbox is checked.
  17521. *
  17522. * @example
  17523. * ```js
  17524. * checkedTemplate: 'good'
  17525. *
  17526. * // if a checkbox-typed cell is checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  17527. * // will return 'good'.
  17528. * ```
  17529. * @type {Boolean|String}
  17530. * @default true
  17531. */
  17532. checkedTemplate: void 0,
  17533. /**
  17534. * Data template for `'checkbox'` type when checkbox is unchecked.
  17535. *
  17536. * @example
  17537. * ```js
  17538. * uncheckedTemplate: 'bad'
  17539. *
  17540. * // if a checkbox-typed cell is not checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  17541. * // will return 'bad'.
  17542. * ```
  17543. * @type {Boolean|String}
  17544. * @default false
  17545. */
  17546. uncheckedTemplate: void 0,
  17547. /**
  17548. * @description
  17549. * Object which describes if renderer should create checkbox element with label element as a parent. Option desired for
  17550. * [checkbox](http://docs.handsontable.com/demo-checkbox.html)-typed cells.
  17551. *
  17552. * By default the [checkbox](http://docs.handsontable.com/demo-checkbox.html) renderer renders the checkbox without a label.
  17553. *
  17554. * Possible object properties:
  17555. * * `property` - Defines the property name of the data object, which will to be used as a label.
  17556. * (eg. `label: {property: 'name.last'}`). This option works only if data was passed as an array of objects.
  17557. * * `position` - String which describes where to place the label text (before or after checkbox element).
  17558. * Valid values are `'before'` and '`after`' (defaults to `'after'`).
  17559. * * `value` - String or a Function which will be used as label text.
  17560. *
  17561. * @example
  17562. * ```js
  17563. * ...
  17564. * columns: [{
  17565. * type: 'checkbox',
  17566. * label: {position: 'after', value: 'My label: '}
  17567. * }]
  17568. * ...
  17569. * ```
  17570. *
  17571. * @since 0.19.0
  17572. * @type {Object}
  17573. * @default undefined
  17574. */
  17575. label: void 0,
  17576. /**
  17577. * Display format. See [numbrojs](http://numbrojs.com). This option is desired for
  17578. * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells.
  17579. *
  17580. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  17581. *
  17582. * @example
  17583. * ```js
  17584. * ...
  17585. * columns: [{
  17586. * type: 'numeric',
  17587. * format: '0,00'
  17588. * }]
  17589. * ...
  17590. * ```
  17591. *
  17592. * @type {String}
  17593. * @default '0'
  17594. */
  17595. format: void 0,
  17596. /**
  17597. * Language display format. See [numbrojs](http://numbrojs.com/languages.html#supported-languages). This option is desired for
  17598. * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells.
  17599. *
  17600. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  17601. *
  17602. * @example
  17603. * ```js
  17604. * ...
  17605. * columns: [{
  17606. * type: 'numeric',
  17607. * language: 'en-US'
  17608. * }]
  17609. * ...
  17610. * ```
  17611. *
  17612. * @type {String}
  17613. * @default 'en-US'
  17614. */
  17615. language: void 0,
  17616. /**
  17617. * @description
  17618. * Data source for [select](http://docs.handsontable.com/demo-select.html)-typed cells.
  17619. *
  17620. * @example
  17621. * ```js
  17622. * ...
  17623. * columns: [{
  17624. * editor: 'select',
  17625. * selectOptions: ['A', 'B', 'C'],
  17626. * }]
  17627. * ...
  17628. * ```
  17629. *
  17630. * @type {Array}
  17631. */
  17632. selectOptions: void 0,
  17633. /**
  17634. * Enables or disables the autoColumnSize plugin. Default value is `undefined`, which has the same effect as `true`.
  17635. * Disabling this plugin can increase performance, as no size-related calculations would be done.
  17636. *
  17637. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  17638. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  17639. * block the browser UI.
  17640. *
  17641. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  17642. * `syncLimit` option is available since 0.16.0.
  17643. *
  17644. * You can also use the `useHeaders` option to take the column headers with into calculation.
  17645. *
  17646. * @example
  17647. * ```js
  17648. * ...
  17649. * // as a number (300 columns in sync, rest async)
  17650. * autoColumnSize: {syncLimit: 300},
  17651. * ...
  17652. *
  17653. * ...
  17654. * // as a string (percent)
  17655. * autoColumnSize: {syncLimit: '40%'},
  17656. * ...
  17657. *
  17658. * ...
  17659. * // use headers width while calculation the column width
  17660. * autoColumnSize: {useHeaders: true},
  17661. * ...
  17662. *
  17663. * ```
  17664. *
  17665. * @type {Object|Boolean}
  17666. * @default {syncLimit: 50}
  17667. */
  17668. autoColumnSize: void 0,
  17669. /**
  17670. * Enables or disables autoRowSize plugin. Default value is `undefined`, which has the same effect as `false` (disabled).
  17671. * Enabling this plugin can decrease performance, as size-related calculations would be performed.
  17672. *
  17673. * Row height calculations are divided into sync and async stages. Each of these stages has their own advantages and
  17674. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  17675. * block the browser UI.
  17676. *
  17677. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  17678. * `syncLimit` options is available since 0.16.0.
  17679. *
  17680. * @example
  17681. * ```js
  17682. * ...
  17683. * // as number (300 columns in sync, rest async)
  17684. * autoRowSize: {syncLimit: 300},
  17685. * ...
  17686. *
  17687. * ...
  17688. * // as string (percent)
  17689. * autoRowSize: {syncLimit: '40%'},
  17690. * ...
  17691. * ```
  17692. * @type {Object|Boolean}
  17693. * @default {syncLimit: 1000}
  17694. */
  17695. autoRowSize: void 0,
  17696. /**
  17697. * Date validation format.
  17698. *
  17699. * Option desired for `'date'` - typed cells.
  17700. *
  17701. * @example
  17702. * ```js
  17703. * ...
  17704. * columns: [{
  17705. * type: 'date',
  17706. * dateFormat: 'MM/DD/YYYY'
  17707. * }]
  17708. * ...
  17709. * ```
  17710. *
  17711. * @type {String}
  17712. * @default 'DD/MM/YYYY'
  17713. */
  17714. dateFormat: void 0,
  17715. /**
  17716. * If `true` then dates will be automatically formatted to match the desired format.
  17717. *
  17718. * Option desired for `'date'`-typed typed cells.
  17719. *
  17720. * @example
  17721. * ```js
  17722. * ...
  17723. * columns: [{
  17724. * type: 'date',
  17725. * dateFormat: 'YYYY-MM-DD',
  17726. * correctFormat: true
  17727. * }]
  17728. * ...
  17729. * ```
  17730. *
  17731. * @type {Boolean}
  17732. * @default false
  17733. */
  17734. correctFormat: false,
  17735. /**
  17736. * Definition of default value which will fill the empty cells.
  17737. *
  17738. * Option desired for `'date'`-typed cells.
  17739. *
  17740. * @example
  17741. * ```js
  17742. * ...
  17743. * columns: [{
  17744. * type: 'date',
  17745. * defaultData: '2015-02-02'
  17746. * }]
  17747. * ...
  17748. * ```
  17749. *
  17750. * @type {String}
  17751. */
  17752. defaultDate: void 0,
  17753. /**
  17754. * If set to `true`, the value entered into the cell must match (case-sensitive) the autocomplete source. Otherwise, cell won't pass the validation.
  17755. * When filtering the autocomplete source list, the editor will be working in case-insensitive mode.
  17756. *
  17757. * Option desired for `autocomplete`-typed cells.
  17758. *
  17759. * @example
  17760. * ```js
  17761. * ...
  17762. * columns: [{
  17763. * type: 'autocomplete',
  17764. * source: ['A', 'B', 'C'],
  17765. * strict: true
  17766. * }]
  17767. * ...
  17768. * ```
  17769. *
  17770. * @type {Boolean}
  17771. */
  17772. strict: void 0,
  17773. /**
  17774. * @description
  17775. * If typed `true`, data defined in `source` of the autocomplete or dropdown cell will be treated as HTML.
  17776. *
  17777. * __Warning:__ Enabling this option can cause serious XSS vulnerabilities.
  17778. *
  17779. * Option desired for `'autocomplete'`-typed cells.
  17780. * @example
  17781. * ```js
  17782. * ...
  17783. * columns: [{
  17784. * type: 'autocomplete',
  17785. * allowHtml: true,
  17786. * source: ['<b>foo</b>', '<b>bar</b>']
  17787. * }]
  17788. * ...
  17789. * ```
  17790. * @type {Boolean}
  17791. * @default false
  17792. */
  17793. allowHtml: false,
  17794. /**
  17795. * If typed `true` then virtual rendering mechanism for handsontable will be disabled.
  17796. *
  17797. * @type {Boolean}
  17798. */
  17799. renderAllRows: void 0,
  17800. /**
  17801. * Prevents table to overlap outside the parent element. If `'horizontal'` option is chosen then table will appear horizontal
  17802. * scrollbar in case where parent's width is narrower then table's width.
  17803. *
  17804. * Possible values:
  17805. * * `false` - Disables functionality (Default option).
  17806. * * `horizontal` - Prevents horizontal overflow table.
  17807. * * `vertical` - Prevents vertical overflow table (Not implemented yet).
  17808. *
  17809. * @since 0.20.3
  17810. * @example
  17811. * ```js
  17812. * ...
  17813. * preventOverflow: 'horizontal'
  17814. * ...
  17815. * ```
  17816. *
  17817. * @type {String|Boolean}
  17818. */
  17819. preventOverflow: false,
  17820. /**
  17821. * @description
  17822. * Plugin allowing binding the table rows with their headers.
  17823. * If the plugin is enabled, the table row headers will "stick" to the rows, when they are hidden/moved. Basically, if at the initialization
  17824. * row 0 has a header titled "A", it will have it no matter what you do with the table.
  17825. *
  17826. * @pro
  17827. * @since 1.0.0-beta1
  17828. * @type {Boolean|String}
  17829. * @example
  17830. *
  17831. * ```js
  17832. * ...
  17833. * var hot = new Handsontable(document.getElementById('example'), {
  17834. * date: getData(),
  17835. * bindRowsWithHeaders: true
  17836. * });
  17837. * ...
  17838. * ```
  17839. *
  17840. */
  17841. bindRowsWithHeaders: void 0,
  17842. /**
  17843. * @description
  17844. * The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the `colspan` property defined.
  17845. *
  17846. * Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one.
  17847. *
  17848. * Setting the `collapsibleColumns` property to `true` will display a "collapse/expand" button in every header with a defined
  17849. * `colspan` property.
  17850. *
  17851. * To limit this functionality to a smaller group of headers, define the `collapsibleColumns` property as an array of objects, as in
  17852. * the example below.
  17853. *
  17854. * @pro
  17855. * @since 1.0.0-beta1
  17856. * @type {Boolean|Array}
  17857. * @example
  17858. * ```js
  17859. * ...
  17860. * collapsibleColumns: [
  17861. * {row: -4, col: 1, collapsible: true},
  17862. * {row: -3, col: 5, collapsible: true}
  17863. * ]
  17864. * ...
  17865. * // or
  17866. * ...
  17867. * collapsibleColumns: true
  17868. * ...
  17869. * ```
  17870. */
  17871. collapsibleColumns: void 0,
  17872. /**
  17873. * @description
  17874. * Allows making pre-defined calculations on the cell values and display the results within Handsontable.
  17875. * See the demo for more information.
  17876. *
  17877. * @pro
  17878. * @since 1.0.0-beta1
  17879. * @type {Object}
  17880. */
  17881. columnSummary: void 0,
  17882. /**
  17883. * This plugin allows adding a configurable dropdown menu to the table's column headers.
  17884. * The dropdown menu acts like the Context Menu, but is triggered by clicking the button in the header.
  17885. *
  17886. * @pro
  17887. * @since 1.0.0-beta1
  17888. * @type {Boolean|Object|Array}
  17889. */
  17890. dropdownMenu: void 0,
  17891. /**
  17892. * The filters plugin.
  17893. * It allows filtering the table data either by the built-in component or with the API.
  17894. *
  17895. * @pro
  17896. * @since 1.0.0-beta1
  17897. * @type {Boolean}
  17898. */
  17899. filters: void 0,
  17900. /**
  17901. * It allows Handsontable to process formula expressions defined in the provided data.
  17902. *
  17903. * @pro
  17904. * @since 1.7.0
  17905. * @type {Boolean}
  17906. */
  17907. formulas: void 0,
  17908. /**
  17909. * @description
  17910. * GanttChart plugin enables a possibility to create a Gantt chart using a Handsontable instance.
  17911. * In this case, the whole table becomes read-only.
  17912. *
  17913. * @pro
  17914. * @since 1.0.0-beta1
  17915. * @type {Object}
  17916. */
  17917. ganttChart: void 0,
  17918. /**
  17919. * @description
  17920. * Allows adding a tooltip to the table headers.
  17921. *
  17922. * Available options:
  17923. * * the `rows` property defines if tooltips should be added to row headers,
  17924. * * the `columns` property defines if tooltips should be added to column headers,
  17925. * * 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).
  17926. *
  17927. * @pro
  17928. * @since 1.0.0-beta1
  17929. * @type {Boolean|Object}
  17930. */
  17931. headerTooltips: void 0,
  17932. /**
  17933. * Plugin allowing hiding of certain columns.
  17934. *
  17935. * @pro
  17936. * @since 1.0.0-beta1
  17937. * @type {Boolean|Object}
  17938. */
  17939. hiddenColumns: void 0,
  17940. /**
  17941. * @description
  17942. * Plugin allowing hiding of certain rows.
  17943. *
  17944. * @pro
  17945. * @since 1.0.0-beta1
  17946. * @type {Boolean|Object}
  17947. */
  17948. hiddenRows: void 0,
  17949. /**
  17950. * @description
  17951. * Allows creating a nested header structure, using the HTML's colspan attribute.
  17952. *
  17953. * @pro
  17954. * @since 1.0.0-beta1
  17955. * @type {Array}
  17956. */
  17957. nestedHeaders: void 0,
  17958. /**
  17959. * @description
  17960. * Plugin allowing hiding of certain rows.
  17961. *
  17962. * @pro
  17963. * @since 1.0.0-beta1
  17964. * @type {Boolean|Array}
  17965. */
  17966. trimRows: void 0,
  17967. /**
  17968. * @description
  17969. * 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.
  17970. *
  17971. * @since 0.22.0
  17972. * @type {Number|Array}
  17973. */
  17974. rowHeaderWidth: void 0,
  17975. /**
  17976. * @description
  17977. * 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.
  17978. *
  17979. * @since 0.22.0
  17980. * @type {Number|Array}
  17981. */
  17982. columnHeaderHeight: void 0,
  17983. /**
  17984. * @description
  17985. * Enabling this plugin switches table into one-way data binding where changes are applied into data source (from outside table)
  17986. * will be automatically reflected in the table.
  17987. *
  17988. * For every data change [afterChangesObserved](Hooks.html#event:afterChangesObserved) hook will be fired.
  17989. *
  17990. * @type {Boolean}
  17991. * @default false
  17992. */
  17993. observeChanges: void 0,
  17994. /**
  17995. * @description
  17996. * When passed to the `column` property, allows specifying a custom sorting function for the desired column.
  17997. *
  17998. * @since 0.24.0
  17999. * @type {Function}
  18000. * @example
  18001. * ```js
  18002. * columns: [
  18003. * {
  18004. * sortFunction: function(sortOrder) {
  18005. * return function(a, b) {
  18006. * // sorting function body.
  18007. * //
  18008. * // Function parameters:
  18009. * // sortOrder: If true, the order is ascending, if false - descending. undefined = original order
  18010. * // a, b: Two compared elements. These are 2-element arrays, with the first element being the row index, the second - cell value.
  18011. * }
  18012. * }
  18013. * }
  18014. * ]
  18015. * ```
  18016. */
  18017. sortFunction: void 0,
  18018. /**
  18019. * 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).
  18020. *
  18021. * Option desired for cells of the `'autocomplete'` type.
  18022. *
  18023. * @type {Boolean}
  18024. * @default true
  18025. */
  18026. sortByRelevance: true,
  18027. /**
  18028. * If defined as 'true', when the user types into the input area the Autocomplete's suggestion list is updated to only
  18029. * include those choices starting with what has been typed; if defined as 'false' all suggestions remain shown, with
  18030. * those matching what has been typed marked in bold.
  18031. *
  18032. * @type {Boolean}
  18033. * @default true
  18034. */
  18035. filter: true,
  18036. /**
  18037. * If defined as 'true', filtering in the Autocomplete Editor will be case-sensitive.
  18038. *
  18039. * @type {Boolean}
  18040. * @default: false
  18041. */
  18042. filteringCaseSensitive: false
  18043. };
  18044. exports.default = DefaultSettings;
  18045. /***/ }),
  18046. /* 89 */
  18047. /***/ (function(module, exports, __webpack_require__) {
  18048. "use strict";
  18049. exports.__esModule = true;
  18050. exports.getNormalizedDate = getNormalizedDate;
  18051. /* eslint-disable import/prefer-default-export */
  18052. /**
  18053. * Get normalized Date object for the ISO formatted date strings.
  18054. * 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.
  18055. * See: Github issue #3338.
  18056. *
  18057. * @param {String} dateString String representing the date.
  18058. * @returns {Date} The proper Date object.
  18059. */
  18060. function getNormalizedDate(dateString) {
  18061. var nativeDate = new Date(dateString);
  18062. // NaN if dateString is not in ISO format
  18063. if (!isNaN(new Date(dateString + "T00:00").getDate())) {
  18064. // Compensate timezone offset
  18065. return new Date(nativeDate.getTime() + nativeDate.getTimezoneOffset() * 60000);
  18066. }
  18067. return nativeDate;
  18068. }
  18069. /***/ }),
  18070. /* 90 */
  18071. /***/ (function(module, exports, __webpack_require__) {
  18072. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  18073. var $export = __webpack_require__(3);
  18074. $export($export.P, 'Array', {copyWithin: __webpack_require__(392)});
  18075. __webpack_require__(38)('copyWithin');
  18076. /***/ }),
  18077. /* 91 */
  18078. /***/ (function(module, exports, __webpack_require__) {
  18079. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  18080. var $export = __webpack_require__(3);
  18081. $export($export.P, 'Array', {fill: __webpack_require__(393)});
  18082. __webpack_require__(38)('fill');
  18083. /***/ }),
  18084. /* 92 */
  18085. /***/ (function(module, exports, __webpack_require__) {
  18086. "use strict";
  18087. // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
  18088. var $export = __webpack_require__(3)
  18089. , $find = __webpack_require__(54)(6)
  18090. , KEY = 'findIndex'
  18091. , forced = true;
  18092. // Shouldn't skip holes
  18093. if(KEY in [])Array(1)[KEY](function(){ forced = false; });
  18094. $export($export.P + $export.F * forced, 'Array', {
  18095. findIndex: function findIndex(callbackfn/*, that = undefined */){
  18096. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  18097. }
  18098. });
  18099. __webpack_require__(38)(KEY);
  18100. /***/ }),
  18101. /* 93 */
  18102. /***/ (function(module, exports, __webpack_require__) {
  18103. "use strict";
  18104. // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
  18105. var $export = __webpack_require__(3)
  18106. , $find = __webpack_require__(54)(5)
  18107. , KEY = 'find'
  18108. , forced = true;
  18109. // Shouldn't skip holes
  18110. if(KEY in [])Array(1)[KEY](function(){ forced = false; });
  18111. $export($export.P + $export.F * forced, 'Array', {
  18112. find: function find(callbackfn/*, that = undefined */){
  18113. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  18114. }
  18115. });
  18116. __webpack_require__(38)(KEY);
  18117. /***/ }),
  18118. /* 94 */
  18119. /***/ (function(module, exports, __webpack_require__) {
  18120. "use strict";
  18121. var ctx = __webpack_require__(29)
  18122. , $export = __webpack_require__(3)
  18123. , toObject = __webpack_require__(42)
  18124. , call = __webpack_require__(280)
  18125. , isArrayIter = __webpack_require__(276)
  18126. , toLength = __webpack_require__(24)
  18127. , createProperty = __webpack_require__(74)
  18128. , getIterFn = __webpack_require__(291);
  18129. $export($export.S + $export.F * !__webpack_require__(79)(function(iter){ Array.from(iter); }), 'Array', {
  18130. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  18131. from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
  18132. var O = toObject(arrayLike)
  18133. , C = typeof this == 'function' ? this : Array
  18134. , aLen = arguments.length
  18135. , mapfn = aLen > 1 ? arguments[1] : undefined
  18136. , mapping = mapfn !== undefined
  18137. , index = 0
  18138. , iterFn = getIterFn(O)
  18139. , length, result, step, iterator;
  18140. if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  18141. // if object isn't iterable or it's array with default iterator - use simple case
  18142. if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
  18143. for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
  18144. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  18145. }
  18146. } else {
  18147. length = toLength(O.length);
  18148. for(result = new C(length); length > index; index++){
  18149. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  18150. }
  18151. }
  18152. result.length = index;
  18153. return result;
  18154. }
  18155. });
  18156. /***/ }),
  18157. /* 95 */
  18158. /***/ (function(module, exports, __webpack_require__) {
  18159. "use strict";
  18160. var $export = __webpack_require__(3)
  18161. , createProperty = __webpack_require__(74);
  18162. // WebKit Array.of isn't generic
  18163. $export($export.S + $export.F * __webpack_require__(31)(function(){
  18164. function F(){}
  18165. return !(Array.of.call(F) instanceof F);
  18166. }), 'Array', {
  18167. // 22.1.2.3 Array.of( ...items)
  18168. of: function of(/* ...args */){
  18169. var index = 0
  18170. , aLen = arguments.length
  18171. , result = new (typeof this == 'function' ? this : Array)(aLen);
  18172. while(aLen > index)createProperty(result, index, arguments[index++]);
  18173. result.length = aLen;
  18174. return result;
  18175. }
  18176. });
  18177. /***/ }),
  18178. /* 96 */
  18179. /***/ (function(module, exports, __webpack_require__) {
  18180. var dP = __webpack_require__(19).f
  18181. , createDesc = __webpack_require__(41)
  18182. , has = __webpack_require__(22)
  18183. , FProto = Function.prototype
  18184. , nameRE = /^\s*function ([^ (]*)/
  18185. , NAME = 'name';
  18186. var isExtensible = Object.isExtensible || function(){
  18187. return true;
  18188. };
  18189. // 19.2.4.2 name
  18190. NAME in FProto || __webpack_require__(21) && dP(FProto, NAME, {
  18191. configurable: true,
  18192. get: function(){
  18193. try {
  18194. var that = this
  18195. , name = ('' + that).match(nameRE)[1];
  18196. has(that, NAME) || !isExtensible(that) || dP(that, NAME, createDesc(5, name));
  18197. return name;
  18198. } catch(e){
  18199. return '';
  18200. }
  18201. }
  18202. });
  18203. /***/ }),
  18204. /* 97 */
  18205. /***/ (function(module, exports, __webpack_require__) {
  18206. "use strict";
  18207. var strong = __webpack_require__(272);
  18208. // 23.1 Map Objects
  18209. module.exports = __webpack_require__(55)('Map', function(get){
  18210. return function Map(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  18211. }, {
  18212. // 23.1.3.6 Map.prototype.get(key)
  18213. get: function get(key){
  18214. var entry = strong.getEntry(this, key);
  18215. return entry && entry.v;
  18216. },
  18217. // 23.1.3.9 Map.prototype.set(key, value)
  18218. set: function set(key, value){
  18219. return strong.def(this, key === 0 ? 0 : key, value);
  18220. }
  18221. }, strong, true);
  18222. /***/ }),
  18223. /* 98 */
  18224. /***/ (function(module, exports, __webpack_require__) {
  18225. // 20.1.2.1 Number.EPSILON
  18226. var $export = __webpack_require__(3);
  18227. $export($export.S, 'Number', {EPSILON: Math.pow(2, -52)});
  18228. /***/ }),
  18229. /* 99 */
  18230. /***/ (function(module, exports, __webpack_require__) {
  18231. // 20.1.2.2 Number.isFinite(number)
  18232. var $export = __webpack_require__(3)
  18233. , _isFinite = __webpack_require__(13).isFinite;
  18234. $export($export.S, 'Number', {
  18235. isFinite: function isFinite(it){
  18236. return typeof it == 'number' && _isFinite(it);
  18237. }
  18238. });
  18239. /***/ }),
  18240. /* 100 */
  18241. /***/ (function(module, exports, __webpack_require__) {
  18242. // 20.1.2.3 Number.isInteger(number)
  18243. var $export = __webpack_require__(3);
  18244. $export($export.S, 'Number', {isInteger: __webpack_require__(278)});
  18245. /***/ }),
  18246. /* 101 */
  18247. /***/ (function(module, exports, __webpack_require__) {
  18248. // 20.1.2.4 Number.isNaN(number)
  18249. var $export = __webpack_require__(3);
  18250. $export($export.S, 'Number', {
  18251. isNaN: function isNaN(number){
  18252. return number != number;
  18253. }
  18254. });
  18255. /***/ }),
  18256. /* 102 */
  18257. /***/ (function(module, exports, __webpack_require__) {
  18258. // 20.1.2.5 Number.isSafeInteger(number)
  18259. var $export = __webpack_require__(3)
  18260. , isInteger = __webpack_require__(278)
  18261. , abs = Math.abs;
  18262. $export($export.S, 'Number', {
  18263. isSafeInteger: function isSafeInteger(number){
  18264. return isInteger(number) && abs(number) <= 0x1fffffffffffff;
  18265. }
  18266. });
  18267. /***/ }),
  18268. /* 103 */
  18269. /***/ (function(module, exports, __webpack_require__) {
  18270. // 20.1.2.6 Number.MAX_SAFE_INTEGER
  18271. var $export = __webpack_require__(3);
  18272. $export($export.S, 'Number', {MAX_SAFE_INTEGER: 0x1fffffffffffff});
  18273. /***/ }),
  18274. /* 104 */
  18275. /***/ (function(module, exports, __webpack_require__) {
  18276. // 20.1.2.10 Number.MIN_SAFE_INTEGER
  18277. var $export = __webpack_require__(3);
  18278. $export($export.S, 'Number', {MIN_SAFE_INTEGER: -0x1fffffffffffff});
  18279. /***/ }),
  18280. /* 105 */
  18281. /***/ (function(module, exports, __webpack_require__) {
  18282. // 19.1.3.1 Object.assign(target, source)
  18283. var $export = __webpack_require__(3);
  18284. $export($export.S + $export.F, 'Object', {assign: __webpack_require__(283)});
  18285. /***/ }),
  18286. /* 106 */
  18287. /***/ (function(module, exports, __webpack_require__) {
  18288. // 19.1.3.10 Object.is(value1, value2)
  18289. var $export = __webpack_require__(3);
  18290. $export($export.S, 'Object', {is: __webpack_require__(407)});
  18291. /***/ }),
  18292. /* 107 */
  18293. /***/ (function(module, exports, __webpack_require__) {
  18294. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  18295. var $export = __webpack_require__(3);
  18296. $export($export.S, 'Object', {setPrototypeOf: __webpack_require__(286).set});
  18297. /***/ }),
  18298. /* 108 */
  18299. /***/ (function(module, exports, __webpack_require__) {
  18300. "use strict";
  18301. var LIBRARY = __webpack_require__(58)
  18302. , global = __webpack_require__(13)
  18303. , ctx = __webpack_require__(29)
  18304. , classof = __webpack_require__(271)
  18305. , $export = __webpack_require__(3)
  18306. , isObject = __webpack_require__(15)
  18307. , aFunction = __webpack_require__(73)
  18308. , anInstance = __webpack_require__(53)
  18309. , forOf = __webpack_require__(57)
  18310. , speciesConstructor = __webpack_require__(408)
  18311. , task = __webpack_require__(86).set
  18312. , microtask = __webpack_require__(402)()
  18313. , PROMISE = 'Promise'
  18314. , TypeError = global.TypeError
  18315. , process = global.process
  18316. , $Promise = global[PROMISE]
  18317. , process = global.process
  18318. , isNode = classof(process) == 'process'
  18319. , empty = function(){ /* empty */ }
  18320. , Internal, GenericPromiseCapability, Wrapper;
  18321. var USE_NATIVE = !!function(){
  18322. try {
  18323. // correct subclassing with @@species support
  18324. var promise = $Promise.resolve(1)
  18325. , FakePromise = (promise.constructor = {})[__webpack_require__(10)('species')] = function(exec){ exec(empty, empty); };
  18326. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  18327. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  18328. } catch(e){ /* empty */ }
  18329. }();
  18330. // helpers
  18331. var sameConstructor = function(a, b){
  18332. // with library wrapper special case
  18333. return a === b || a === $Promise && b === Wrapper;
  18334. };
  18335. var isThenable = function(it){
  18336. var then;
  18337. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  18338. };
  18339. var newPromiseCapability = function(C){
  18340. return sameConstructor($Promise, C)
  18341. ? new PromiseCapability(C)
  18342. : new GenericPromiseCapability(C);
  18343. };
  18344. var PromiseCapability = GenericPromiseCapability = function(C){
  18345. var resolve, reject;
  18346. this.promise = new C(function($$resolve, $$reject){
  18347. if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor');
  18348. resolve = $$resolve;
  18349. reject = $$reject;
  18350. });
  18351. this.resolve = aFunction(resolve);
  18352. this.reject = aFunction(reject);
  18353. };
  18354. var perform = function(exec){
  18355. try {
  18356. exec();
  18357. } catch(e){
  18358. return {error: e};
  18359. }
  18360. };
  18361. var notify = function(promise, isReject){
  18362. if(promise._n)return;
  18363. promise._n = true;
  18364. var chain = promise._c;
  18365. microtask(function(){
  18366. var value = promise._v
  18367. , ok = promise._s == 1
  18368. , i = 0;
  18369. var run = function(reaction){
  18370. var handler = ok ? reaction.ok : reaction.fail
  18371. , resolve = reaction.resolve
  18372. , reject = reaction.reject
  18373. , domain = reaction.domain
  18374. , result, then;
  18375. try {
  18376. if(handler){
  18377. if(!ok){
  18378. if(promise._h == 2)onHandleUnhandled(promise);
  18379. promise._h = 1;
  18380. }
  18381. if(handler === true)result = value;
  18382. else {
  18383. if(domain)domain.enter();
  18384. result = handler(value);
  18385. if(domain)domain.exit();
  18386. }
  18387. if(result === reaction.promise){
  18388. reject(TypeError('Promise-chain cycle'));
  18389. } else if(then = isThenable(result)){
  18390. then.call(result, resolve, reject);
  18391. } else resolve(result);
  18392. } else reject(value);
  18393. } catch(e){
  18394. reject(e);
  18395. }
  18396. };
  18397. while(chain.length > i)run(chain[i++]); // variable length - can't use forEach
  18398. promise._c = [];
  18399. promise._n = false;
  18400. if(isReject && !promise._h)onUnhandled(promise);
  18401. });
  18402. };
  18403. var onUnhandled = function(promise){
  18404. task.call(global, function(){
  18405. var value = promise._v
  18406. , abrupt, handler, console;
  18407. if(isUnhandled(promise)){
  18408. abrupt = perform(function(){
  18409. if(isNode){
  18410. process.emit('unhandledRejection', value, promise);
  18411. } else if(handler = global.onunhandledrejection){
  18412. handler({promise: promise, reason: value});
  18413. } else if((console = global.console) && console.error){
  18414. console.error('Unhandled promise rejection', value);
  18415. }
  18416. });
  18417. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  18418. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  18419. } promise._a = undefined;
  18420. if(abrupt)throw abrupt.error;
  18421. });
  18422. };
  18423. var isUnhandled = function(promise){
  18424. if(promise._h == 1)return false;
  18425. var chain = promise._a || promise._c
  18426. , i = 0
  18427. , reaction;
  18428. while(chain.length > i){
  18429. reaction = chain[i++];
  18430. if(reaction.fail || !isUnhandled(reaction.promise))return false;
  18431. } return true;
  18432. };
  18433. var onHandleUnhandled = function(promise){
  18434. task.call(global, function(){
  18435. var handler;
  18436. if(isNode){
  18437. process.emit('rejectionHandled', promise);
  18438. } else if(handler = global.onrejectionhandled){
  18439. handler({promise: promise, reason: promise._v});
  18440. }
  18441. });
  18442. };
  18443. var $reject = function(value){
  18444. var promise = this;
  18445. if(promise._d)return;
  18446. promise._d = true;
  18447. promise = promise._w || promise; // unwrap
  18448. promise._v = value;
  18449. promise._s = 2;
  18450. if(!promise._a)promise._a = promise._c.slice();
  18451. notify(promise, true);
  18452. };
  18453. var $resolve = function(value){
  18454. var promise = this
  18455. , then;
  18456. if(promise._d)return;
  18457. promise._d = true;
  18458. promise = promise._w || promise; // unwrap
  18459. try {
  18460. if(promise === value)throw TypeError("Promise can't be resolved itself");
  18461. if(then = isThenable(value)){
  18462. microtask(function(){
  18463. var wrapper = {_w: promise, _d: false}; // wrap
  18464. try {
  18465. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  18466. } catch(e){
  18467. $reject.call(wrapper, e);
  18468. }
  18469. });
  18470. } else {
  18471. promise._v = value;
  18472. promise._s = 1;
  18473. notify(promise, false);
  18474. }
  18475. } catch(e){
  18476. $reject.call({_w: promise, _d: false}, e); // wrap
  18477. }
  18478. };
  18479. // constructor polyfill
  18480. if(!USE_NATIVE){
  18481. // 25.4.3.1 Promise(executor)
  18482. $Promise = function Promise(executor){
  18483. anInstance(this, $Promise, PROMISE, '_h');
  18484. aFunction(executor);
  18485. Internal.call(this);
  18486. try {
  18487. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  18488. } catch(err){
  18489. $reject.call(this, err);
  18490. }
  18491. };
  18492. Internal = function Promise(executor){
  18493. this._c = []; // <- awaiting reactions
  18494. this._a = undefined; // <- checked in isUnhandled reactions
  18495. this._s = 0; // <- state
  18496. this._d = false; // <- done
  18497. this._v = undefined; // <- value
  18498. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  18499. this._n = false; // <- notify
  18500. };
  18501. Internal.prototype = __webpack_require__(60)($Promise.prototype, {
  18502. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  18503. then: function then(onFulfilled, onRejected){
  18504. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  18505. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  18506. reaction.fail = typeof onRejected == 'function' && onRejected;
  18507. reaction.domain = isNode ? process.domain : undefined;
  18508. this._c.push(reaction);
  18509. if(this._a)this._a.push(reaction);
  18510. if(this._s)notify(this, false);
  18511. return reaction.promise;
  18512. },
  18513. // 25.4.5.1 Promise.prototype.catch(onRejected)
  18514. 'catch': function(onRejected){
  18515. return this.then(undefined, onRejected);
  18516. }
  18517. });
  18518. PromiseCapability = function(){
  18519. var promise = new Internal;
  18520. this.promise = promise;
  18521. this.resolve = ctx($resolve, promise, 1);
  18522. this.reject = ctx($reject, promise, 1);
  18523. };
  18524. }
  18525. $export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise});
  18526. __webpack_require__(49)($Promise, PROMISE);
  18527. __webpack_require__(287)(PROMISE);
  18528. Wrapper = __webpack_require__(45)[PROMISE];
  18529. // statics
  18530. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  18531. // 25.4.4.5 Promise.reject(r)
  18532. reject: function reject(r){
  18533. var capability = newPromiseCapability(this)
  18534. , $$reject = capability.reject;
  18535. $$reject(r);
  18536. return capability.promise;
  18537. }
  18538. });
  18539. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  18540. // 25.4.4.6 Promise.resolve(x)
  18541. resolve: function resolve(x){
  18542. // instanceof instead of internal slot check because we should fix it without replacement native Promise core
  18543. if(x instanceof $Promise && sameConstructor(x.constructor, this))return x;
  18544. var capability = newPromiseCapability(this)
  18545. , $$resolve = capability.resolve;
  18546. $$resolve(x);
  18547. return capability.promise;
  18548. }
  18549. });
  18550. $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(79)(function(iter){
  18551. $Promise.all(iter)['catch'](empty);
  18552. })), PROMISE, {
  18553. // 25.4.4.1 Promise.all(iterable)
  18554. all: function all(iterable){
  18555. var C = this
  18556. , capability = newPromiseCapability(C)
  18557. , resolve = capability.resolve
  18558. , reject = capability.reject;
  18559. var abrupt = perform(function(){
  18560. var values = []
  18561. , index = 0
  18562. , remaining = 1;
  18563. forOf(iterable, false, function(promise){
  18564. var $index = index++
  18565. , alreadyCalled = false;
  18566. values.push(undefined);
  18567. remaining++;
  18568. C.resolve(promise).then(function(value){
  18569. if(alreadyCalled)return;
  18570. alreadyCalled = true;
  18571. values[$index] = value;
  18572. --remaining || resolve(values);
  18573. }, reject);
  18574. });
  18575. --remaining || resolve(values);
  18576. });
  18577. if(abrupt)reject(abrupt.error);
  18578. return capability.promise;
  18579. },
  18580. // 25.4.4.4 Promise.race(iterable)
  18581. race: function race(iterable){
  18582. var C = this
  18583. , capability = newPromiseCapability(C)
  18584. , reject = capability.reject;
  18585. var abrupt = perform(function(){
  18586. forOf(iterable, false, function(promise){
  18587. C.resolve(promise).then(capability.resolve, reject);
  18588. });
  18589. });
  18590. if(abrupt)reject(abrupt.error);
  18591. return capability.promise;
  18592. }
  18593. });
  18594. /***/ }),
  18595. /* 109 */
  18596. /***/ (function(module, exports, __webpack_require__) {
  18597. // 21.2.5.3 get RegExp.prototype.flags()
  18598. if(__webpack_require__(21) && /./g.flags != 'g')__webpack_require__(19).f(RegExp.prototype, 'flags', {
  18599. configurable: true,
  18600. get: __webpack_require__(397)
  18601. });
  18602. /***/ }),
  18603. /* 110 */
  18604. /***/ (function(module, exports, __webpack_require__) {
  18605. // @@match logic
  18606. __webpack_require__(56)('match', 1, function(defined, MATCH, $match){
  18607. // 21.1.3.11 String.prototype.match(regexp)
  18608. return [function match(regexp){
  18609. 'use strict';
  18610. var O = defined(this)
  18611. , fn = regexp == undefined ? undefined : regexp[MATCH];
  18612. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  18613. }, $match];
  18614. });
  18615. /***/ }),
  18616. /* 111 */
  18617. /***/ (function(module, exports, __webpack_require__) {
  18618. // @@replace logic
  18619. __webpack_require__(56)('replace', 2, function(defined, REPLACE, $replace){
  18620. // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
  18621. return [function replace(searchValue, replaceValue){
  18622. 'use strict';
  18623. var O = defined(this)
  18624. , fn = searchValue == undefined ? undefined : searchValue[REPLACE];
  18625. return fn !== undefined
  18626. ? fn.call(searchValue, O, replaceValue)
  18627. : $replace.call(String(O), searchValue, replaceValue);
  18628. }, $replace];
  18629. });
  18630. /***/ }),
  18631. /* 112 */
  18632. /***/ (function(module, exports, __webpack_require__) {
  18633. // @@search logic
  18634. __webpack_require__(56)('search', 1, function(defined, SEARCH, $search){
  18635. // 21.1.3.15 String.prototype.search(regexp)
  18636. return [function search(regexp){
  18637. 'use strict';
  18638. var O = defined(this)
  18639. , fn = regexp == undefined ? undefined : regexp[SEARCH];
  18640. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  18641. }, $search];
  18642. });
  18643. /***/ }),
  18644. /* 113 */
  18645. /***/ (function(module, exports, __webpack_require__) {
  18646. // @@split logic
  18647. __webpack_require__(56)('split', 2, function(defined, SPLIT, $split){
  18648. 'use strict';
  18649. var isRegExp = __webpack_require__(279)
  18650. , _split = $split
  18651. , $push = [].push
  18652. , $SPLIT = 'split'
  18653. , LENGTH = 'length'
  18654. , LAST_INDEX = 'lastIndex';
  18655. if(
  18656. 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
  18657. 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
  18658. 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
  18659. '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
  18660. '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
  18661. ''[$SPLIT](/.?/)[LENGTH]
  18662. ){
  18663. var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
  18664. // based on es5-shim implementation, need to rework it
  18665. $split = function(separator, limit){
  18666. var string = String(this);
  18667. if(separator === undefined && limit === 0)return [];
  18668. // If `separator` is not a regex, use native split
  18669. if(!isRegExp(separator))return _split.call(string, separator, limit);
  18670. var output = [];
  18671. var flags = (separator.ignoreCase ? 'i' : '') +
  18672. (separator.multiline ? 'm' : '') +
  18673. (separator.unicode ? 'u' : '') +
  18674. (separator.sticky ? 'y' : '');
  18675. var lastLastIndex = 0;
  18676. var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
  18677. // Make `global` and avoid `lastIndex` issues by working with a copy
  18678. var separatorCopy = new RegExp(separator.source, flags + 'g');
  18679. var separator2, match, lastIndex, lastLength, i;
  18680. // Doesn't need flags gy, but they don't hurt
  18681. if(!NPCG)separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
  18682. while(match = separatorCopy.exec(string)){
  18683. // `separatorCopy.lastIndex` is not reliable cross-browser
  18684. lastIndex = match.index + match[0][LENGTH];
  18685. if(lastIndex > lastLastIndex){
  18686. output.push(string.slice(lastLastIndex, match.index));
  18687. // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
  18688. if(!NPCG && match[LENGTH] > 1)match[0].replace(separator2, function(){
  18689. for(i = 1; i < arguments[LENGTH] - 2; i++)if(arguments[i] === undefined)match[i] = undefined;
  18690. });
  18691. if(match[LENGTH] > 1 && match.index < string[LENGTH])$push.apply(output, match.slice(1));
  18692. lastLength = match[0][LENGTH];
  18693. lastLastIndex = lastIndex;
  18694. if(output[LENGTH] >= splitLimit)break;
  18695. }
  18696. if(separatorCopy[LAST_INDEX] === match.index)separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
  18697. }
  18698. if(lastLastIndex === string[LENGTH]){
  18699. if(lastLength || !separatorCopy.test(''))output.push('');
  18700. } else output.push(string.slice(lastLastIndex));
  18701. return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
  18702. };
  18703. // Chakra, V8
  18704. } else if('0'[$SPLIT](undefined, 0)[LENGTH]){
  18705. $split = function(separator, limit){
  18706. return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
  18707. };
  18708. }
  18709. // 21.1.3.17 String.prototype.split(separator, limit)
  18710. return [function split(separator, limit){
  18711. var O = defined(this)
  18712. , fn = separator == undefined ? undefined : separator[SPLIT];
  18713. return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
  18714. }, $split];
  18715. });
  18716. /***/ }),
  18717. /* 114 */
  18718. /***/ (function(module, exports, __webpack_require__) {
  18719. "use strict";
  18720. var strong = __webpack_require__(272);
  18721. // 23.2 Set Objects
  18722. module.exports = __webpack_require__(55)('Set', function(get){
  18723. return function Set(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  18724. }, {
  18725. // 23.2.3.1 Set.prototype.add(value)
  18726. add: function add(value){
  18727. return strong.def(this, value = value === 0 ? 0 : value, value);
  18728. }
  18729. }, strong);
  18730. /***/ }),
  18731. /* 115 */
  18732. /***/ (function(module, exports, __webpack_require__) {
  18733. "use strict";
  18734. var $export = __webpack_require__(3)
  18735. , $at = __webpack_require__(409)(false);
  18736. $export($export.P, 'String', {
  18737. // 21.1.3.3 String.prototype.codePointAt(pos)
  18738. codePointAt: function codePointAt(pos){
  18739. return $at(this, pos);
  18740. }
  18741. });
  18742. /***/ }),
  18743. /* 116 */
  18744. /***/ (function(module, exports, __webpack_require__) {
  18745. "use strict";
  18746. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  18747. var $export = __webpack_require__(3)
  18748. , toLength = __webpack_require__(24)
  18749. , context = __webpack_require__(85)
  18750. , ENDS_WITH = 'endsWith'
  18751. , $endsWith = ''[ENDS_WITH];
  18752. $export($export.P + $export.F * __webpack_require__(77)(ENDS_WITH), 'String', {
  18753. endsWith: function endsWith(searchString /*, endPosition = @length */){
  18754. var that = context(this, searchString, ENDS_WITH)
  18755. , endPosition = arguments.length > 1 ? arguments[1] : undefined
  18756. , len = toLength(that.length)
  18757. , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
  18758. , search = String(searchString);
  18759. return $endsWith
  18760. ? $endsWith.call(that, search, end)
  18761. : that.slice(end - search.length, end) === search;
  18762. }
  18763. });
  18764. /***/ }),
  18765. /* 117 */
  18766. /***/ (function(module, exports, __webpack_require__) {
  18767. var $export = __webpack_require__(3)
  18768. , toIndex = __webpack_require__(61)
  18769. , fromCharCode = String.fromCharCode
  18770. , $fromCodePoint = String.fromCodePoint;
  18771. // length should be 1, old FF problem
  18772. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  18773. // 21.1.2.2 String.fromCodePoint(...codePoints)
  18774. fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
  18775. var res = []
  18776. , aLen = arguments.length
  18777. , i = 0
  18778. , code;
  18779. while(aLen > i){
  18780. code = +arguments[i++];
  18781. if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
  18782. res.push(code < 0x10000
  18783. ? fromCharCode(code)
  18784. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  18785. );
  18786. } return res.join('');
  18787. }
  18788. });
  18789. /***/ }),
  18790. /* 118 */
  18791. /***/ (function(module, exports, __webpack_require__) {
  18792. "use strict";
  18793. // 21.1.3.7 String.prototype.includes(searchString, position = 0)
  18794. var $export = __webpack_require__(3)
  18795. , context = __webpack_require__(85)
  18796. , INCLUDES = 'includes';
  18797. $export($export.P + $export.F * __webpack_require__(77)(INCLUDES), 'String', {
  18798. includes: function includes(searchString /*, position = 0 */){
  18799. return !!~context(this, searchString, INCLUDES)
  18800. .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  18801. }
  18802. });
  18803. /***/ }),
  18804. /* 119 */
  18805. /***/ (function(module, exports, __webpack_require__) {
  18806. var $export = __webpack_require__(3)
  18807. , toIObject = __webpack_require__(23)
  18808. , toLength = __webpack_require__(24);
  18809. $export($export.S, 'String', {
  18810. // 21.1.2.4 String.raw(callSite, ...substitutions)
  18811. raw: function raw(callSite){
  18812. var tpl = toIObject(callSite.raw)
  18813. , len = toLength(tpl.length)
  18814. , aLen = arguments.length
  18815. , res = []
  18816. , i = 0;
  18817. while(len > i){
  18818. res.push(String(tpl[i++]));
  18819. if(i < aLen)res.push(String(arguments[i]));
  18820. } return res.join('');
  18821. }
  18822. });
  18823. /***/ }),
  18824. /* 120 */
  18825. /***/ (function(module, exports, __webpack_require__) {
  18826. var $export = __webpack_require__(3);
  18827. $export($export.P, 'String', {
  18828. // 21.1.3.13 String.prototype.repeat(count)
  18829. repeat: __webpack_require__(289)
  18830. });
  18831. /***/ }),
  18832. /* 121 */
  18833. /***/ (function(module, exports, __webpack_require__) {
  18834. "use strict";
  18835. // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
  18836. var $export = __webpack_require__(3)
  18837. , toLength = __webpack_require__(24)
  18838. , context = __webpack_require__(85)
  18839. , STARTS_WITH = 'startsWith'
  18840. , $startsWith = ''[STARTS_WITH];
  18841. $export($export.P + $export.F * __webpack_require__(77)(STARTS_WITH), 'String', {
  18842. startsWith: function startsWith(searchString /*, position = 0 */){
  18843. var that = context(this, searchString, STARTS_WITH)
  18844. , index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length))
  18845. , search = String(searchString);
  18846. return $startsWith
  18847. ? $startsWith.call(that, search, index)
  18848. : that.slice(index, index + search.length) === search;
  18849. }
  18850. });
  18851. /***/ }),
  18852. /* 122 */
  18853. /***/ (function(module, exports, __webpack_require__) {
  18854. "use strict";
  18855. // ECMAScript 6 symbols shim
  18856. var global = __webpack_require__(13)
  18857. , has = __webpack_require__(22)
  18858. , DESCRIPTORS = __webpack_require__(21)
  18859. , $export = __webpack_require__(3)
  18860. , redefine = __webpack_require__(33)
  18861. , META = __webpack_require__(47).KEY
  18862. , $fails = __webpack_require__(31)
  18863. , shared = __webpack_require__(84)
  18864. , setToStringTag = __webpack_require__(49)
  18865. , uid = __webpack_require__(50)
  18866. , wks = __webpack_require__(10)
  18867. , wksExt = __webpack_require__(290)
  18868. , wksDefine = __webpack_require__(410)
  18869. , keyOf = __webpack_require__(401)
  18870. , enumKeys = __webpack_require__(396)
  18871. , isArray = __webpack_require__(277)
  18872. , anObject = __webpack_require__(18)
  18873. , toIObject = __webpack_require__(23)
  18874. , toPrimitive = __webpack_require__(87)
  18875. , createDesc = __webpack_require__(41)
  18876. , _create = __webpack_require__(80)
  18877. , gOPNExt = __webpack_require__(404)
  18878. , $GOPD = __webpack_require__(81)
  18879. , $DP = __webpack_require__(19)
  18880. , $keys = __webpack_require__(40)
  18881. , gOPD = $GOPD.f
  18882. , dP = $DP.f
  18883. , gOPN = gOPNExt.f
  18884. , $Symbol = global.Symbol
  18885. , $JSON = global.JSON
  18886. , _stringify = $JSON && $JSON.stringify
  18887. , PROTOTYPE = 'prototype'
  18888. , HIDDEN = wks('_hidden')
  18889. , TO_PRIMITIVE = wks('toPrimitive')
  18890. , isEnum = {}.propertyIsEnumerable
  18891. , SymbolRegistry = shared('symbol-registry')
  18892. , AllSymbols = shared('symbols')
  18893. , OPSymbols = shared('op-symbols')
  18894. , ObjectProto = Object[PROTOTYPE]
  18895. , USE_NATIVE = typeof $Symbol == 'function'
  18896. , QObject = global.QObject;
  18897. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  18898. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  18899. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  18900. var setSymbolDesc = DESCRIPTORS && $fails(function(){
  18901. return _create(dP({}, 'a', {
  18902. get: function(){ return dP(this, 'a', {value: 7}).a; }
  18903. })).a != 7;
  18904. }) ? function(it, key, D){
  18905. var protoDesc = gOPD(ObjectProto, key);
  18906. if(protoDesc)delete ObjectProto[key];
  18907. dP(it, key, D);
  18908. if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc);
  18909. } : dP;
  18910. var wrap = function(tag){
  18911. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  18912. sym._k = tag;
  18913. return sym;
  18914. };
  18915. var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
  18916. return typeof it == 'symbol';
  18917. } : function(it){
  18918. return it instanceof $Symbol;
  18919. };
  18920. var $defineProperty = function defineProperty(it, key, D){
  18921. if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
  18922. anObject(it);
  18923. key = toPrimitive(key, true);
  18924. anObject(D);
  18925. if(has(AllSymbols, key)){
  18926. if(!D.enumerable){
  18927. if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {}));
  18928. it[HIDDEN][key] = true;
  18929. } else {
  18930. if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
  18931. D = _create(D, {enumerable: createDesc(0, false)});
  18932. } return setSymbolDesc(it, key, D);
  18933. } return dP(it, key, D);
  18934. };
  18935. var $defineProperties = function defineProperties(it, P){
  18936. anObject(it);
  18937. var keys = enumKeys(P = toIObject(P))
  18938. , i = 0
  18939. , l = keys.length
  18940. , key;
  18941. while(l > i)$defineProperty(it, key = keys[i++], P[key]);
  18942. return it;
  18943. };
  18944. var $create = function create(it, P){
  18945. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  18946. };
  18947. var $propertyIsEnumerable = function propertyIsEnumerable(key){
  18948. var E = isEnum.call(this, key = toPrimitive(key, true));
  18949. if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
  18950. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  18951. };
  18952. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
  18953. it = toIObject(it);
  18954. key = toPrimitive(key, true);
  18955. if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
  18956. var D = gOPD(it, key);
  18957. if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
  18958. return D;
  18959. };
  18960. var $getOwnPropertyNames = function getOwnPropertyNames(it){
  18961. var names = gOPN(toIObject(it))
  18962. , result = []
  18963. , i = 0
  18964. , key;
  18965. while(names.length > i){
  18966. if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
  18967. } return result;
  18968. };
  18969. var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
  18970. var IS_OP = it === ObjectProto
  18971. , names = gOPN(IS_OP ? OPSymbols : toIObject(it))
  18972. , result = []
  18973. , i = 0
  18974. , key;
  18975. while(names.length > i){
  18976. if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
  18977. } return result;
  18978. };
  18979. // 19.4.1.1 Symbol([description])
  18980. if(!USE_NATIVE){
  18981. $Symbol = function Symbol(){
  18982. if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
  18983. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  18984. var $set = function(value){
  18985. if(this === ObjectProto)$set.call(OPSymbols, value);
  18986. if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
  18987. setSymbolDesc(this, tag, createDesc(1, value));
  18988. };
  18989. if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
  18990. return wrap(tag);
  18991. };
  18992. redefine($Symbol[PROTOTYPE], 'toString', function toString(){
  18993. return this._k;
  18994. });
  18995. $GOPD.f = $getOwnPropertyDescriptor;
  18996. $DP.f = $defineProperty;
  18997. __webpack_require__(82).f = gOPNExt.f = $getOwnPropertyNames;
  18998. __webpack_require__(48).f = $propertyIsEnumerable;
  18999. __webpack_require__(59).f = $getOwnPropertySymbols;
  19000. if(DESCRIPTORS && !__webpack_require__(58)){
  19001. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  19002. }
  19003. wksExt.f = function(name){
  19004. return wrap(wks(name));
  19005. }
  19006. }
  19007. $export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol});
  19008. for(var symbols = (
  19009. // 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
  19010. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  19011. ).split(','), i = 0; symbols.length > i; )wks(symbols[i++]);
  19012. for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]);
  19013. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  19014. // 19.4.2.1 Symbol.for(key)
  19015. 'for': function(key){
  19016. return has(SymbolRegistry, key += '')
  19017. ? SymbolRegistry[key]
  19018. : SymbolRegistry[key] = $Symbol(key);
  19019. },
  19020. // 19.4.2.5 Symbol.keyFor(sym)
  19021. keyFor: function keyFor(key){
  19022. if(isSymbol(key))return keyOf(SymbolRegistry, key);
  19023. throw TypeError(key + ' is not a symbol!');
  19024. },
  19025. useSetter: function(){ setter = true; },
  19026. useSimple: function(){ setter = false; }
  19027. });
  19028. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  19029. // 19.1.2.2 Object.create(O [, Properties])
  19030. create: $create,
  19031. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  19032. defineProperty: $defineProperty,
  19033. // 19.1.2.3 Object.defineProperties(O, Properties)
  19034. defineProperties: $defineProperties,
  19035. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  19036. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  19037. // 19.1.2.7 Object.getOwnPropertyNames(O)
  19038. getOwnPropertyNames: $getOwnPropertyNames,
  19039. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  19040. getOwnPropertySymbols: $getOwnPropertySymbols
  19041. });
  19042. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  19043. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){
  19044. var S = $Symbol();
  19045. // MS Edge converts symbol values to JSON as {}
  19046. // WebKit converts symbol values to JSON as null
  19047. // V8 throws on boxed symbols
  19048. return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';
  19049. })), 'JSON', {
  19050. stringify: function stringify(it){
  19051. if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
  19052. var args = [it]
  19053. , i = 1
  19054. , replacer, $replacer;
  19055. while(arguments.length > i)args.push(arguments[i++]);
  19056. replacer = args[1];
  19057. if(typeof replacer == 'function')$replacer = replacer;
  19058. if($replacer || !isArray(replacer))replacer = function(key, value){
  19059. if($replacer)value = $replacer.call(this, key, value);
  19060. if(!isSymbol(value))return value;
  19061. };
  19062. args[1] = replacer;
  19063. return _stringify.apply($JSON, args);
  19064. }
  19065. });
  19066. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  19067. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(32)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  19068. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  19069. setToStringTag($Symbol, 'Symbol');
  19070. // 20.2.1.9 Math[@@toStringTag]
  19071. setToStringTag(Math, 'Math', true);
  19072. // 24.3.3 JSON[@@toStringTag]
  19073. setToStringTag(global.JSON, 'JSON', true);
  19074. /***/ }),
  19075. /* 123 */
  19076. /***/ (function(module, exports, __webpack_require__) {
  19077. "use strict";
  19078. var each = __webpack_require__(54)(0)
  19079. , redefine = __webpack_require__(33)
  19080. , meta = __webpack_require__(47)
  19081. , assign = __webpack_require__(283)
  19082. , weak = __webpack_require__(273)
  19083. , isObject = __webpack_require__(15)
  19084. , getWeak = meta.getWeak
  19085. , isExtensible = Object.isExtensible
  19086. , uncaughtFrozenStore = weak.ufstore
  19087. , tmp = {}
  19088. , InternalMap;
  19089. var wrapper = function(get){
  19090. return function WeakMap(){
  19091. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  19092. };
  19093. };
  19094. var methods = {
  19095. // 23.3.3.3 WeakMap.prototype.get(key)
  19096. get: function get(key){
  19097. if(isObject(key)){
  19098. var data = getWeak(key);
  19099. if(data === true)return uncaughtFrozenStore(this).get(key);
  19100. return data ? data[this._i] : undefined;
  19101. }
  19102. },
  19103. // 23.3.3.5 WeakMap.prototype.set(key, value)
  19104. set: function set(key, value){
  19105. return weak.def(this, key, value);
  19106. }
  19107. };
  19108. // 23.3 WeakMap Objects
  19109. var $WeakMap = module.exports = __webpack_require__(55)('WeakMap', wrapper, methods, weak, true, true);
  19110. // IE11 WeakMap frozen keys fix
  19111. if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
  19112. InternalMap = weak.getConstructor(wrapper);
  19113. assign(InternalMap.prototype, methods);
  19114. meta.NEED = true;
  19115. each(['delete', 'has', 'get', 'set'], function(key){
  19116. var proto = $WeakMap.prototype
  19117. , method = proto[key];
  19118. redefine(proto, key, function(a, b){
  19119. // store frozen objects on internal weakmap shim
  19120. if(isObject(a) && !isExtensible(a)){
  19121. if(!this._f)this._f = new InternalMap;
  19122. var result = this._f[key](a, b);
  19123. return key == 'set' ? this : result;
  19124. // store all the rest on native weakmap
  19125. } return method.call(this, a, b);
  19126. });
  19127. });
  19128. }
  19129. /***/ }),
  19130. /* 124 */
  19131. /***/ (function(module, exports, __webpack_require__) {
  19132. "use strict";
  19133. var weak = __webpack_require__(273);
  19134. // 23.4 WeakSet Objects
  19135. __webpack_require__(55)('WeakSet', function(get){
  19136. return function WeakSet(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  19137. }, {
  19138. // 23.4.3.1 WeakSet.prototype.add(value)
  19139. add: function add(value){
  19140. return weak.def(this, value, true);
  19141. }
  19142. }, weak, false, true);
  19143. /***/ }),
  19144. /* 125 */
  19145. /***/ (function(module, exports, __webpack_require__) {
  19146. "use strict";
  19147. // https://github.com/tc39/Array.prototype.includes
  19148. var $export = __webpack_require__(3)
  19149. , $includes = __webpack_require__(270)(true);
  19150. $export($export.P, 'Array', {
  19151. includes: function includes(el /*, fromIndex = 0 */){
  19152. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  19153. }
  19154. });
  19155. __webpack_require__(38)('includes');
  19156. /***/ }),
  19157. /* 126 */
  19158. /***/ (function(module, exports, __webpack_require__) {
  19159. // https://github.com/tc39/proposal-object-values-entries
  19160. var $export = __webpack_require__(3)
  19161. , $entries = __webpack_require__(285)(true);
  19162. $export($export.S, 'Object', {
  19163. entries: function entries(it){
  19164. return $entries(it);
  19165. }
  19166. });
  19167. /***/ }),
  19168. /* 127 */
  19169. /***/ (function(module, exports, __webpack_require__) {
  19170. // https://github.com/tc39/proposal-object-getownpropertydescriptors
  19171. var $export = __webpack_require__(3)
  19172. , ownKeys = __webpack_require__(406)
  19173. , toIObject = __webpack_require__(23)
  19174. , gOPD = __webpack_require__(81)
  19175. , createProperty = __webpack_require__(74);
  19176. $export($export.S, 'Object', {
  19177. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
  19178. var O = toIObject(object)
  19179. , getDesc = gOPD.f
  19180. , keys = ownKeys(O)
  19181. , result = {}
  19182. , i = 0
  19183. , key;
  19184. while(keys.length > i)createProperty(result, key = keys[i++], getDesc(O, key));
  19185. return result;
  19186. }
  19187. });
  19188. /***/ }),
  19189. /* 128 */
  19190. /***/ (function(module, exports, __webpack_require__) {
  19191. // https://github.com/tc39/proposal-object-values-entries
  19192. var $export = __webpack_require__(3)
  19193. , $values = __webpack_require__(285)(false);
  19194. $export($export.S, 'Object', {
  19195. values: function values(it){
  19196. return $values(it);
  19197. }
  19198. });
  19199. /***/ }),
  19200. /* 129 */
  19201. /***/ (function(module, exports, __webpack_require__) {
  19202. "use strict";
  19203. // https://github.com/tc39/proposal-string-pad-start-end
  19204. var $export = __webpack_require__(3)
  19205. , $pad = __webpack_require__(288);
  19206. $export($export.P, 'String', {
  19207. padEnd: function padEnd(maxLength /*, fillString = ' ' */){
  19208. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  19209. }
  19210. });
  19211. /***/ }),
  19212. /* 130 */
  19213. /***/ (function(module, exports, __webpack_require__) {
  19214. "use strict";
  19215. // https://github.com/tc39/proposal-string-pad-start-end
  19216. var $export = __webpack_require__(3)
  19217. , $pad = __webpack_require__(288);
  19218. $export($export.P, 'String', {
  19219. padStart: function padStart(maxLength /*, fillString = ' ' */){
  19220. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  19221. }
  19222. });
  19223. /***/ }),
  19224. /* 131 */
  19225. /***/ (function(module, exports, __webpack_require__) {
  19226. var $iterators = __webpack_require__(68)
  19227. , redefine = __webpack_require__(33)
  19228. , global = __webpack_require__(13)
  19229. , hide = __webpack_require__(32)
  19230. , Iterators = __webpack_require__(46)
  19231. , wks = __webpack_require__(10)
  19232. , ITERATOR = wks('iterator')
  19233. , TO_STRING_TAG = wks('toStringTag')
  19234. , ArrayValues = Iterators.Array;
  19235. for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
  19236. var NAME = collections[i]
  19237. , Collection = global[NAME]
  19238. , proto = Collection && Collection.prototype
  19239. , key;
  19240. if(proto){
  19241. if(!proto[ITERATOR])hide(proto, ITERATOR, ArrayValues);
  19242. if(!proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
  19243. Iterators[NAME] = ArrayValues;
  19244. for(key in $iterators)if(!proto[key])redefine(proto, key, $iterators[key], true);
  19245. }
  19246. }
  19247. /***/ }),
  19248. /* 132 */
  19249. /***/ (function(module, exports, __webpack_require__) {
  19250. var $export = __webpack_require__(3)
  19251. , $task = __webpack_require__(86);
  19252. $export($export.G + $export.B, {
  19253. setImmediate: $task.set,
  19254. clearImmediate: $task.clear
  19255. });
  19256. /***/ }),
  19257. /* 133 */
  19258. /***/ (function(module, exports) {
  19259. /***/ }),
  19260. /* 134 */
  19261. /***/ (function(module, exports) {
  19262. /***/ }),
  19263. /* 135 */
  19264. /***/ (function(module, exports) {
  19265. /***/ }),
  19266. /* 136 */
  19267. /***/ (function(module, exports) {
  19268. /***/ }),
  19269. /* 137 */
  19270. /***/ (function(module, exports) {
  19271. /***/ }),
  19272. /* 138 */
  19273. /***/ (function(module, exports) {
  19274. /***/ }),
  19275. /* 139 */
  19276. /***/ (function(module, exports) {
  19277. /***/ }),
  19278. /* 140 */
  19279. /***/ (function(module, exports) {
  19280. /***/ }),
  19281. /* 141 */
  19282. /***/ (function(module, exports) {
  19283. /***/ }),
  19284. /* 142 */
  19285. /***/ (function(module, exports) {
  19286. /***/ }),
  19287. /* 143 */
  19288. /***/ (function(module, exports) {
  19289. /***/ }),
  19290. /* 144 */
  19291. /***/ (function(module, exports) {
  19292. /***/ }),
  19293. /* 145 */
  19294. /***/ (function(module, exports) {
  19295. /***/ }),
  19296. /* 146 */
  19297. /***/ (function(module, exports) {
  19298. /***/ }),
  19299. /* 147 */
  19300. /***/ (function(module, exports) {
  19301. /***/ }),
  19302. /* 148 */
  19303. /***/ (function(module, exports) {
  19304. /***/ }),
  19305. /* 149 */
  19306. /***/ (function(module, exports) {
  19307. /***/ }),
  19308. /* 150 */
  19309. /***/ (function(module, exports) {
  19310. /***/ }),
  19311. /* 151 */
  19312. /***/ (function(module, exports) {
  19313. /***/ }),
  19314. /* 152 */
  19315. /***/ (function(module, exports) {
  19316. /***/ }),
  19317. /* 153 */
  19318. /***/ (function(module, exports) {
  19319. /***/ }),
  19320. /* 154 */
  19321. /***/ (function(module, exports) {
  19322. /***/ }),
  19323. /* 155 */
  19324. /***/ (function(module, exports) {
  19325. /***/ }),
  19326. /* 156 */
  19327. /***/ (function(module, exports) {
  19328. /***/ }),
  19329. /* 157 */
  19330. /***/ (function(module, exports) {
  19331. /***/ }),
  19332. /* 158 */
  19333. /***/ (function(module, exports) {
  19334. /***/ }),
  19335. /* 159 */
  19336. /***/ (function(module, exports) {
  19337. /***/ }),
  19338. /* 160 */
  19339. /***/ (function(module, exports) {
  19340. /***/ }),
  19341. /* 161 */
  19342. /***/ (function(module, exports) {
  19343. /***/ }),
  19344. /* 162 */
  19345. /***/ (function(module, exports) {
  19346. /***/ }),
  19347. /* 163 */
  19348. /***/ (function(module, exports) {
  19349. /***/ }),
  19350. /* 164 */
  19351. /***/ (function(module, exports) {
  19352. /***/ }),
  19353. /* 165 */
  19354. /***/ (function(module, exports) {
  19355. /***/ }),
  19356. /* 166 */
  19357. /***/ (function(module, exports) {
  19358. /***/ }),
  19359. /* 167 */
  19360. /***/ (function(module, exports) {
  19361. /***/ }),
  19362. /* 168 */
  19363. /***/ (function(module, exports) {
  19364. /***/ }),
  19365. /* 169 */
  19366. /***/ (function(module, exports) {
  19367. /***/ }),
  19368. /* 170 */
  19369. /***/ (function(module, exports) {
  19370. /***/ }),
  19371. /* 171 */
  19372. /***/ (function(module, exports) {
  19373. /***/ }),
  19374. /* 172 */
  19375. /***/ (function(module, exports) {
  19376. /***/ }),
  19377. /* 173 */
  19378. /***/ (function(module, exports) {
  19379. /***/ }),
  19380. /* 174 */
  19381. /***/ (function(module, exports) {
  19382. /***/ }),
  19383. /* 175 */
  19384. /***/ (function(module, exports) {
  19385. /***/ }),
  19386. /* 176 */
  19387. /***/ (function(module, exports) {
  19388. /***/ }),
  19389. /* 177 */
  19390. /***/ (function(module, exports) {
  19391. /***/ }),
  19392. /* 178 */
  19393. /***/ (function(module, exports) {
  19394. /***/ }),
  19395. /* 179 */
  19396. /***/ (function(module, exports) {
  19397. /***/ }),
  19398. /* 180 */
  19399. /***/ (function(module, exports) {
  19400. /***/ }),
  19401. /* 181 */
  19402. /***/ (function(module, exports) {
  19403. /***/ }),
  19404. /* 182 */
  19405. /***/ (function(module, exports) {
  19406. /***/ }),
  19407. /* 183 */
  19408. /***/ (function(module, exports) {
  19409. /***/ }),
  19410. /* 184 */
  19411. /***/ (function(module, exports) {
  19412. /***/ }),
  19413. /* 185 */
  19414. /***/ (function(module, exports) {
  19415. /***/ }),
  19416. /* 186 */
  19417. /***/ (function(module, exports) {
  19418. /***/ }),
  19419. /* 187 */
  19420. /***/ (function(module, exports) {
  19421. /***/ }),
  19422. /* 188 */
  19423. /***/ (function(module, exports) {
  19424. /***/ }),
  19425. /* 189 */
  19426. /***/ (function(module, exports) {
  19427. /***/ }),
  19428. /* 190 */
  19429. /***/ (function(module, exports) {
  19430. /***/ }),
  19431. /* 191 */
  19432. /***/ (function(module, exports) {
  19433. /***/ }),
  19434. /* 192 */
  19435. /***/ (function(module, exports) {
  19436. /***/ }),
  19437. /* 193 */
  19438. /***/ (function(module, exports) {
  19439. /***/ }),
  19440. /* 194 */
  19441. /***/ (function(module, exports) {
  19442. /***/ }),
  19443. /* 195 */
  19444. /***/ (function(module, exports) {
  19445. /***/ }),
  19446. /* 196 */
  19447. /***/ (function(module, exports) {
  19448. /***/ }),
  19449. /* 197 */
  19450. /***/ (function(module, exports) {
  19451. /***/ }),
  19452. /* 198 */
  19453. /***/ (function(module, exports) {
  19454. /***/ }),
  19455. /* 199 */
  19456. /***/ (function(module, exports) {
  19457. /***/ }),
  19458. /* 200 */
  19459. /***/ (function(module, exports) {
  19460. /***/ }),
  19461. /* 201 */
  19462. /***/ (function(module, exports) {
  19463. /***/ }),
  19464. /* 202 */
  19465. /***/ (function(module, exports) {
  19466. /***/ }),
  19467. /* 203 */
  19468. /***/ (function(module, exports) {
  19469. /***/ }),
  19470. /* 204 */
  19471. /***/ (function(module, exports) {
  19472. /***/ }),
  19473. /* 205 */
  19474. /***/ (function(module, exports) {
  19475. /***/ }),
  19476. /* 206 */
  19477. /***/ (function(module, exports) {
  19478. /***/ }),
  19479. /* 207 */
  19480. /***/ (function(module, exports) {
  19481. /***/ }),
  19482. /* 208 */
  19483. /***/ (function(module, exports) {
  19484. /***/ }),
  19485. /* 209 */
  19486. /***/ (function(module, exports) {
  19487. /***/ }),
  19488. /* 210 */
  19489. /***/ (function(module, exports) {
  19490. /***/ }),
  19491. /* 211 */
  19492. /***/ (function(module, exports) {
  19493. /***/ }),
  19494. /* 212 */
  19495. /***/ (function(module, exports) {
  19496. /***/ }),
  19497. /* 213 */
  19498. /***/ (function(module, exports) {
  19499. /***/ }),
  19500. /* 214 */
  19501. /***/ (function(module, exports) {
  19502. /***/ }),
  19503. /* 215 */
  19504. /***/ (function(module, exports) {
  19505. /***/ }),
  19506. /* 216 */
  19507. /***/ (function(module, exports) {
  19508. /***/ }),
  19509. /* 217 */
  19510. /***/ (function(module, exports) {
  19511. /***/ }),
  19512. /* 218 */
  19513. /***/ (function(module, exports) {
  19514. /***/ }),
  19515. /* 219 */
  19516. /***/ (function(module, exports) {
  19517. /***/ }),
  19518. /* 220 */
  19519. /***/ (function(module, exports) {
  19520. /***/ }),
  19521. /* 221 */
  19522. /***/ (function(module, exports) {
  19523. /***/ }),
  19524. /* 222 */
  19525. /***/ (function(module, exports) {
  19526. /***/ }),
  19527. /* 223 */
  19528. /***/ (function(module, exports) {
  19529. /***/ }),
  19530. /* 224 */
  19531. /***/ (function(module, exports) {
  19532. /***/ }),
  19533. /* 225 */
  19534. /***/ (function(module, exports) {
  19535. /***/ }),
  19536. /* 226 */
  19537. /***/ (function(module, exports) {
  19538. /***/ }),
  19539. /* 227 */
  19540. /***/ (function(module, exports) {
  19541. /***/ }),
  19542. /* 228 */
  19543. /***/ (function(module, exports) {
  19544. /***/ }),
  19545. /* 229 */
  19546. /***/ (function(module, exports) {
  19547. /***/ }),
  19548. /* 230 */
  19549. /***/ (function(module, exports) {
  19550. /***/ }),
  19551. /* 231 */
  19552. /***/ (function(module, exports) {
  19553. /***/ }),
  19554. /* 232 */
  19555. /***/ (function(module, exports) {
  19556. /***/ }),
  19557. /* 233 */
  19558. /***/ (function(module, exports) {
  19559. /***/ }),
  19560. /* 234 */
  19561. /***/ (function(module, exports) {
  19562. /***/ }),
  19563. /* 235 */
  19564. /***/ (function(module, exports) {
  19565. /***/ }),
  19566. /* 236 */
  19567. /***/ (function(module, exports) {
  19568. /***/ }),
  19569. /* 237 */
  19570. /***/ (function(module, exports) {
  19571. /***/ }),
  19572. /* 238 */
  19573. /***/ (function(module, exports) {
  19574. /***/ }),
  19575. /* 239 */
  19576. /***/ (function(module, exports) {
  19577. /***/ }),
  19578. /* 240 */
  19579. /***/ (function(module, exports) {
  19580. /***/ }),
  19581. /* 241 */
  19582. /***/ (function(module, exports) {
  19583. /***/ }),
  19584. /* 242 */
  19585. /***/ (function(module, exports) {
  19586. /***/ }),
  19587. /* 243 */
  19588. /***/ (function(module, exports) {
  19589. /***/ }),
  19590. /* 244 */
  19591. /***/ (function(module, exports) {
  19592. /***/ }),
  19593. /* 245 */
  19594. /***/ (function(module, exports) {
  19595. /***/ }),
  19596. /* 246 */
  19597. /***/ (function(module, exports) {
  19598. /***/ }),
  19599. /* 247 */
  19600. /***/ (function(module, exports) {
  19601. /***/ }),
  19602. /* 248 */
  19603. /***/ (function(module, exports, __webpack_require__) {
  19604. "use strict";
  19605. /**
  19606. * SheetClip - Spreadsheet Clipboard Parser
  19607. * version 0.2
  19608. *
  19609. * This tiny library transforms JavaScript arrays to strings that are pasteable by LibreOffice, OpenOffice,
  19610. * Google Docs and Microsoft Excel.
  19611. *
  19612. * Copyright 2012, Marcin Warpechowski
  19613. * Licensed under the MIT license.
  19614. * http://github.com/warpech/sheetclip/
  19615. */
  19616. /*jslint white: true*/
  19617. (function (global) {
  19618. "use strict";
  19619. function countQuotes(str) {
  19620. return str.split('"').length - 1;
  19621. }
  19622. var SheetClip = {
  19623. /**
  19624. * Decode spreadsheet string into array
  19625. *
  19626. * @param {String} str
  19627. * @returns {Array}
  19628. */
  19629. parse: function parse(str) {
  19630. var r,
  19631. rLen,
  19632. rows,
  19633. arr = [],
  19634. a = 0,
  19635. c,
  19636. cLen,
  19637. multiline,
  19638. last;
  19639. rows = str.split('\n');
  19640. if (rows.length > 1 && rows[rows.length - 1] === '') {
  19641. rows.pop();
  19642. }
  19643. for (r = 0, rLen = rows.length; r < rLen; r += 1) {
  19644. rows[r] = rows[r].split('\t');
  19645. for (c = 0, cLen = rows[r].length; c < cLen; c += 1) {
  19646. if (!arr[a]) {
  19647. arr[a] = [];
  19648. }
  19649. if (multiline && c === 0) {
  19650. last = arr[a].length - 1;
  19651. arr[a][last] = arr[a][last] + '\n' + rows[r][0];
  19652. if (multiline && countQuotes(rows[r][0]) & 1) {
  19653. //& 1 is a bitwise way of performing mod 2
  19654. multiline = false;
  19655. arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"');
  19656. }
  19657. } else {
  19658. if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && countQuotes(rows[r][c]) & 1) {
  19659. arr[a].push(rows[r][c].substring(1).replace(/""/g, '"'));
  19660. multiline = true;
  19661. } else {
  19662. arr[a].push(rows[r][c].replace(/""/g, '"'));
  19663. multiline = false;
  19664. }
  19665. }
  19666. }
  19667. if (!multiline) {
  19668. a += 1;
  19669. }
  19670. }
  19671. return arr;
  19672. },
  19673. /**
  19674. * Encode array into valid spreadsheet string
  19675. *
  19676. * @param arr
  19677. * @returns {String}
  19678. */
  19679. stringify: function stringify(arr) {
  19680. var r,
  19681. rLen,
  19682. c,
  19683. cLen,
  19684. str = '',
  19685. val;
  19686. for (r = 0, rLen = arr.length; r < rLen; r += 1) {
  19687. cLen = arr[r].length;
  19688. for (c = 0; c < cLen; c += 1) {
  19689. if (c > 0) {
  19690. str += '\t';
  19691. }
  19692. val = arr[r][c];
  19693. if (typeof val === 'string') {
  19694. if (val.indexOf('\n') > -1) {
  19695. str += '"' + val.replace(/"/g, '""') + '"';
  19696. } else {
  19697. str += val;
  19698. }
  19699. } else if (val === null || val === void 0) {
  19700. // void 0 resolves to undefined
  19701. str += '';
  19702. } else {
  19703. str += val;
  19704. }
  19705. }
  19706. if (r !== rLen - 1) {
  19707. str += '\n';
  19708. }
  19709. }
  19710. return str;
  19711. }
  19712. };
  19713. if (true) {
  19714. exports.parse = SheetClip.parse;
  19715. exports.stringify = SheetClip.stringify;
  19716. } else {
  19717. global.SheetClip = SheetClip;
  19718. }
  19719. })(window);
  19720. /***/ }),
  19721. /* 249 */
  19722. /***/ (function(module, exports, __webpack_require__) {
  19723. "use strict";
  19724. var _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; };
  19725. /*!
  19726. * https://github.com/Starcounter-Jack/JSON-Patch
  19727. * json-patch-duplex.js version: 0.5.7
  19728. * (c) 2013 Joachim Wester
  19729. * MIT license
  19730. */
  19731. var __extends = undefined && undefined.__extends || function (d, b) {
  19732. for (var p in b) {
  19733. if (b.hasOwnProperty(p)) d[p] = b[p];
  19734. }function __() {
  19735. this.constructor = d;
  19736. }
  19737. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19738. };
  19739. var OriginalError = Error;
  19740. var jsonpatch;
  19741. (function (jsonpatch) {
  19742. var _objectKeys = function _objectKeys(obj) {
  19743. if (_isArray(obj)) {
  19744. var keys = new Array(obj.length);
  19745. for (var k = 0; k < keys.length; k++) {
  19746. keys[k] = "" + k;
  19747. }
  19748. return keys;
  19749. }
  19750. if (Object.keys) {
  19751. return Object.keys(obj);
  19752. }
  19753. var keys = [];
  19754. for (var i in obj) {
  19755. if (obj.hasOwnProperty(i)) {
  19756. keys.push(i);
  19757. }
  19758. }
  19759. return keys;
  19760. };
  19761. function _equals(a, b) {
  19762. switch (typeof a === 'undefined' ? 'undefined' : _typeof(a)) {
  19763. case 'undefined': //backward compatibility, but really I think we should return false
  19764. case 'boolean':
  19765. case 'string':
  19766. case 'number':
  19767. return a === b;
  19768. case 'object':
  19769. if (a === null) return b === null;
  19770. if (_isArray(a)) {
  19771. if (!_isArray(b) || a.length !== b.length) return false;
  19772. for (var i = 0, l = a.length; i < l; i++) {
  19773. if (!_equals(a[i], b[i])) return false;
  19774. }return true;
  19775. }
  19776. var bKeys = _objectKeys(b);
  19777. var bLength = bKeys.length;
  19778. if (_objectKeys(a).length !== bLength) return false;
  19779. for (var i = 0; i < bLength; i++) {
  19780. if (!_equals(a[i], b[i])) return false;
  19781. }return true;
  19782. default:
  19783. return false;
  19784. }
  19785. }
  19786. /* We use a Javascript hash to store each
  19787. function. Each hash entry (property) uses
  19788. the operation identifiers specified in rfc6902.
  19789. In this way, we can map each patch operation
  19790. to its dedicated function in efficient way.
  19791. */
  19792. /* The operations applicable to an object */
  19793. var objOps = {
  19794. add: function add(obj, key) {
  19795. obj[key] = this.value;
  19796. return true;
  19797. },
  19798. remove: function remove(obj, key) {
  19799. delete obj[key];
  19800. return true;
  19801. },
  19802. replace: function replace(obj, key) {
  19803. obj[key] = this.value;
  19804. return true;
  19805. },
  19806. move: function move(obj, key, tree) {
  19807. var temp = { op: "_get", path: this.from };
  19808. apply(tree, [temp]);
  19809. apply(tree, [{ op: "remove", path: this.from }]);
  19810. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  19811. return true;
  19812. },
  19813. copy: function copy(obj, key, tree) {
  19814. var temp = { op: "_get", path: this.from };
  19815. apply(tree, [temp]);
  19816. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  19817. return true;
  19818. },
  19819. test: function test(obj, key) {
  19820. return _equals(obj[key], this.value);
  19821. },
  19822. _get: function _get(obj, key) {
  19823. this.value = obj[key];
  19824. }
  19825. };
  19826. /* The operations applicable to an array. Many are the same as for the object */
  19827. var arrOps = {
  19828. add: function add(arr, i) {
  19829. arr.splice(i, 0, this.value);
  19830. return true;
  19831. },
  19832. remove: function remove(arr, i) {
  19833. arr.splice(i, 1);
  19834. return true;
  19835. },
  19836. replace: function replace(arr, i) {
  19837. arr[i] = this.value;
  19838. return true;
  19839. },
  19840. move: objOps.move,
  19841. copy: objOps.copy,
  19842. test: objOps.test,
  19843. _get: objOps._get
  19844. };
  19845. /* The operations applicable to object root. Many are the same as for the object */
  19846. var rootOps = {
  19847. add: function add(obj) {
  19848. rootOps.remove.call(this, obj);
  19849. for (var key in this.value) {
  19850. if (this.value.hasOwnProperty(key)) {
  19851. obj[key] = this.value[key];
  19852. }
  19853. }
  19854. return true;
  19855. },
  19856. remove: function remove(obj) {
  19857. for (var key in obj) {
  19858. if (obj.hasOwnProperty(key)) {
  19859. objOps.remove.call(this, obj, key);
  19860. }
  19861. }
  19862. return true;
  19863. },
  19864. replace: function replace(obj) {
  19865. apply(obj, [{ op: "remove", path: this.path }]);
  19866. apply(obj, [{ op: "add", path: this.path, value: this.value }]);
  19867. return true;
  19868. },
  19869. move: objOps.move,
  19870. copy: objOps.copy,
  19871. test: function test(obj) {
  19872. return JSON.stringify(obj) === JSON.stringify(this.value);
  19873. },
  19874. _get: function _get(obj) {
  19875. this.value = obj;
  19876. }
  19877. };
  19878. var observeOps = {
  19879. add: function add(patches, path) {
  19880. var patch = {
  19881. op: "add",
  19882. path: path + escapePathComponent(this.name),
  19883. value: this.object[this.name] };
  19884. patches.push(patch);
  19885. },
  19886. 'delete': function _delete(patches, path) {
  19887. var patch = {
  19888. op: "remove",
  19889. path: path + escapePathComponent(this.name)
  19890. };
  19891. patches.push(patch);
  19892. },
  19893. update: function update(patches, path) {
  19894. var patch = {
  19895. op: "replace",
  19896. path: path + escapePathComponent(this.name),
  19897. value: this.object[this.name]
  19898. };
  19899. patches.push(patch);
  19900. }
  19901. };
  19902. function escapePathComponent(str) {
  19903. if (str.indexOf('/') === -1 && str.indexOf('~') === -1) return str;
  19904. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  19905. }
  19906. function _getPathRecursive(root, obj) {
  19907. var found;
  19908. for (var key in root) {
  19909. if (root.hasOwnProperty(key)) {
  19910. if (root[key] === obj) {
  19911. return escapePathComponent(key) + '/';
  19912. } else if (_typeof(root[key]) === 'object') {
  19913. found = _getPathRecursive(root[key], obj);
  19914. if (found != '') {
  19915. return escapePathComponent(key) + '/' + found;
  19916. }
  19917. }
  19918. }
  19919. }
  19920. return '';
  19921. }
  19922. function getPath(root, obj) {
  19923. if (root === obj) {
  19924. return '/';
  19925. }
  19926. var path = _getPathRecursive(root, obj);
  19927. if (path === '') {
  19928. throw new OriginalError("Object not found in root");
  19929. }
  19930. return '/' + path;
  19931. }
  19932. var beforeDict = [];
  19933. var Mirror = function () {
  19934. function Mirror(obj) {
  19935. this.observers = [];
  19936. this.obj = obj;
  19937. }
  19938. return Mirror;
  19939. }();
  19940. var ObserverInfo = function () {
  19941. function ObserverInfo(callback, observer) {
  19942. this.callback = callback;
  19943. this.observer = observer;
  19944. }
  19945. return ObserverInfo;
  19946. }();
  19947. function getMirror(obj) {
  19948. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  19949. if (beforeDict[i].obj === obj) {
  19950. return beforeDict[i];
  19951. }
  19952. }
  19953. }
  19954. function getObserverFromMirror(mirror, callback) {
  19955. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  19956. if (mirror.observers[j].callback === callback) {
  19957. return mirror.observers[j].observer;
  19958. }
  19959. }
  19960. }
  19961. function removeObserverFromMirror(mirror, observer) {
  19962. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  19963. if (mirror.observers[j].observer === observer) {
  19964. mirror.observers.splice(j, 1);
  19965. return;
  19966. }
  19967. }
  19968. }
  19969. function unobserve(root, observer) {
  19970. observer.unobserve();
  19971. }
  19972. jsonpatch.unobserve = unobserve;
  19973. function deepClone(obj) {
  19974. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === "object") {
  19975. return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
  19976. } else {
  19977. return obj; //no need to clone primitives
  19978. }
  19979. }
  19980. function observe(obj, callback) {
  19981. var patches = [];
  19982. var root = obj;
  19983. var observer;
  19984. var mirror = getMirror(obj);
  19985. if (!mirror) {
  19986. mirror = new Mirror(obj);
  19987. beforeDict.push(mirror);
  19988. } else {
  19989. observer = getObserverFromMirror(mirror, callback);
  19990. }
  19991. if (observer) {
  19992. return observer;
  19993. }
  19994. observer = {};
  19995. mirror.value = deepClone(obj);
  19996. if (callback) {
  19997. observer.callback = callback;
  19998. observer.next = null;
  19999. var intervals = this.intervals || [100, 1000, 10000, 60000];
  20000. if (intervals.push === void 0) {
  20001. throw new OriginalError("jsonpatch.intervals must be an array");
  20002. }
  20003. var currentInterval = 0;
  20004. var dirtyCheck = function dirtyCheck() {
  20005. generate(observer);
  20006. };
  20007. var fastCheck = function fastCheck() {
  20008. clearTimeout(observer.next);
  20009. observer.next = setTimeout(function () {
  20010. dirtyCheck();
  20011. currentInterval = 0;
  20012. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  20013. }, 0);
  20014. };
  20015. var slowCheck = function slowCheck() {
  20016. dirtyCheck();
  20017. if (currentInterval == intervals.length) currentInterval = intervals.length - 1;
  20018. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  20019. };
  20020. if (typeof window !== 'undefined') {
  20021. if (window.addEventListener) {
  20022. window.addEventListener('mousedown', fastCheck);
  20023. window.addEventListener('mouseup', fastCheck);
  20024. window.addEventListener('keydown', fastCheck);
  20025. } else {
  20026. document.documentElement.attachEvent('onmousedown', fastCheck);
  20027. document.documentElement.attachEvent('onmouseup', fastCheck);
  20028. document.documentElement.attachEvent('onkeydown', fastCheck);
  20029. }
  20030. }
  20031. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  20032. }
  20033. observer.patches = patches;
  20034. observer.object = obj;
  20035. observer.unobserve = function () {
  20036. generate(observer);
  20037. clearTimeout(observer.next);
  20038. removeObserverFromMirror(mirror, observer);
  20039. if (typeof window !== 'undefined') {
  20040. if (window.removeEventListener) {
  20041. window.removeEventListener('mousedown', fastCheck);
  20042. window.removeEventListener('mouseup', fastCheck);
  20043. window.removeEventListener('keydown', fastCheck);
  20044. } else {
  20045. document.documentElement.detachEvent('onmousedown', fastCheck);
  20046. document.documentElement.detachEvent('onmouseup', fastCheck);
  20047. document.documentElement.detachEvent('onkeydown', fastCheck);
  20048. }
  20049. }
  20050. };
  20051. mirror.observers.push(new ObserverInfo(callback, observer));
  20052. return observer;
  20053. }
  20054. jsonpatch.observe = observe;
  20055. function generate(observer) {
  20056. var mirror;
  20057. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  20058. if (beforeDict[i].obj === observer.object) {
  20059. mirror = beforeDict[i];
  20060. break;
  20061. }
  20062. }
  20063. _generate(mirror.value, observer.object, observer.patches, "");
  20064. if (observer.patches.length) {
  20065. apply(mirror.value, observer.patches);
  20066. }
  20067. var temp = observer.patches;
  20068. if (temp.length > 0) {
  20069. observer.patches = [];
  20070. if (observer.callback) {
  20071. observer.callback(temp);
  20072. }
  20073. }
  20074. return temp;
  20075. }
  20076. jsonpatch.generate = generate;
  20077. // Dirty check if obj is different from mirror, generate patches and update mirror
  20078. function _generate(mirror, obj, patches, path) {
  20079. var newKeys = _objectKeys(obj);
  20080. var oldKeys = _objectKeys(mirror);
  20081. var changed = false;
  20082. var deleted = false;
  20083. //if ever "move" operation is implemented here, make sure this test runs OK: "should not generate the same patch twice (move)"
  20084. for (var t = oldKeys.length - 1; t >= 0; t--) {
  20085. var key = oldKeys[t];
  20086. var oldVal = mirror[key];
  20087. if (obj.hasOwnProperty(key)) {
  20088. var newVal = obj[key];
  20089. if ((typeof oldVal === 'undefined' ? 'undefined' : _typeof(oldVal)) == "object" && oldVal != null && (typeof newVal === 'undefined' ? 'undefined' : _typeof(newVal)) == "object" && newVal != null) {
  20090. _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
  20091. } else {
  20092. if (oldVal != newVal) {
  20093. changed = true;
  20094. patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: deepClone(newVal) });
  20095. }
  20096. }
  20097. } else {
  20098. patches.push({ op: "remove", path: path + "/" + escapePathComponent(key) });
  20099. deleted = true; // property has been deleted
  20100. }
  20101. }
  20102. if (!deleted && newKeys.length == oldKeys.length) {
  20103. return;
  20104. }
  20105. for (var t = 0; t < newKeys.length; t++) {
  20106. var key = newKeys[t];
  20107. if (!mirror.hasOwnProperty(key)) {
  20108. patches.push({ op: "add", path: path + "/" + escapePathComponent(key), value: deepClone(obj[key]) });
  20109. }
  20110. }
  20111. }
  20112. var _isArray;
  20113. if (Array.isArray) {
  20114. _isArray = Array.isArray;
  20115. } else {
  20116. _isArray = function _isArray(obj) {
  20117. return obj.push && typeof obj.length === 'number';
  20118. };
  20119. }
  20120. //3x faster than cached /^\d+$/.test(str)
  20121. function isInteger(str) {
  20122. var i = 0;
  20123. var len = str.length;
  20124. var charCode;
  20125. while (i < len) {
  20126. charCode = str.charCodeAt(i);
  20127. if (charCode >= 48 && charCode <= 57) {
  20128. i++;
  20129. continue;
  20130. }
  20131. return false;
  20132. }
  20133. return true;
  20134. }
  20135. /// Apply a json-patch operation on an object tree
  20136. function apply(tree, patches, validate) {
  20137. var result = false,
  20138. p = 0,
  20139. plen = patches.length,
  20140. patch,
  20141. key;
  20142. while (p < plen) {
  20143. patch = patches[p];
  20144. p++;
  20145. // Find the object
  20146. var path = patch.path || "";
  20147. var keys = path.split('/');
  20148. var obj = tree;
  20149. var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift
  20150. var len = keys.length;
  20151. var existingPathFragment = undefined;
  20152. while (true) {
  20153. key = keys[t];
  20154. if (validate) {
  20155. if (existingPathFragment === undefined) {
  20156. if (obj[key] === undefined) {
  20157. existingPathFragment = keys.slice(0, t).join('/');
  20158. } else if (t == len - 1) {
  20159. existingPathFragment = patch.path;
  20160. }
  20161. if (existingPathFragment !== undefined) {
  20162. this.validator(patch, p - 1, tree, existingPathFragment);
  20163. }
  20164. }
  20165. }
  20166. t++;
  20167. if (key === undefined) {
  20168. if (t >= len) {
  20169. result = rootOps[patch.op].call(patch, obj, key, tree); // Apply patch
  20170. break;
  20171. }
  20172. }
  20173. if (_isArray(obj)) {
  20174. if (key === '-') {
  20175. key = obj.length;
  20176. } else {
  20177. if (validate && !isInteger(key)) {
  20178. throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", p - 1, patch.path, patch);
  20179. }
  20180. key = parseInt(key, 10);
  20181. }
  20182. if (t >= len) {
  20183. if (validate && patch.op === "add" && key > obj.length) {
  20184. throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", p - 1, patch.path, patch);
  20185. }
  20186. result = arrOps[patch.op].call(patch, obj, key, tree); // Apply patch
  20187. break;
  20188. }
  20189. } else {
  20190. if (key && key.indexOf('~') != -1) key = key.replace(/~1/g, '/').replace(/~0/g, '~'); // escape chars
  20191. if (t >= len) {
  20192. result = objOps[patch.op].call(patch, obj, key, tree); // Apply patch
  20193. break;
  20194. }
  20195. }
  20196. obj = obj[key];
  20197. }
  20198. }
  20199. return result;
  20200. }
  20201. jsonpatch.apply = apply;
  20202. function compare(tree1, tree2) {
  20203. var patches = [];
  20204. _generate(tree1, tree2, patches, '');
  20205. return patches;
  20206. }
  20207. jsonpatch.compare = compare;
  20208. var JsonPatchError = function (_super) {
  20209. __extends(JsonPatchError, _super);
  20210. function JsonPatchError(message, name, index, operation, tree) {
  20211. _super.call(this, message);
  20212. this.message = message;
  20213. this.name = name;
  20214. this.index = index;
  20215. this.operation = operation;
  20216. this.tree = tree;
  20217. }
  20218. return JsonPatchError;
  20219. }(OriginalError);
  20220. jsonpatch.JsonPatchError = JsonPatchError;
  20221. jsonpatch.Error = JsonPatchError;
  20222. /**
  20223. * Recursively checks whether an object has any undefined values inside.
  20224. */
  20225. function hasUndefined(obj) {
  20226. if (obj === undefined) {
  20227. return true;
  20228. }
  20229. if (typeof obj == "array" || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == "object") {
  20230. for (var i in obj) {
  20231. if (hasUndefined(obj[i])) {
  20232. return true;
  20233. }
  20234. }
  20235. }
  20236. return false;
  20237. }
  20238. /**
  20239. * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
  20240. * @param {object} operation - operation object (patch)
  20241. * @param {number} index - index of operation in the sequence
  20242. * @param {object} [tree] - object where the operation is supposed to be applied
  20243. * @param {string} [existingPathFragment] - comes along with `tree`
  20244. */
  20245. function validator(operation, index, tree, existingPathFragment) {
  20246. if ((typeof operation === 'undefined' ? 'undefined' : _typeof(operation)) !== 'object' || operation === null || _isArray(operation)) {
  20247. throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, tree);
  20248. } else if (!objOps[operation.op]) {
  20249. throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, tree);
  20250. } else if (typeof operation.path !== 'string') {
  20251. throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, tree);
  20252. } else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
  20253. throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, tree);
  20254. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
  20255. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, tree);
  20256. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {
  20257. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, tree);
  20258. } else if (tree) {
  20259. if (operation.op == "add") {
  20260. var pathLen = operation.path.split("/").length;
  20261. var existingPathLen = existingPathFragment.split("/").length;
  20262. if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
  20263. throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, tree);
  20264. }
  20265. } else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
  20266. if (operation.path !== existingPathFragment) {
  20267. throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, tree);
  20268. }
  20269. } else if (operation.op === 'move' || operation.op === 'copy') {
  20270. var existingValue = { op: "_get", path: operation.from, value: undefined };
  20271. var error = jsonpatch.validate([existingValue], tree);
  20272. if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {
  20273. throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, tree);
  20274. }
  20275. }
  20276. }
  20277. }
  20278. jsonpatch.validator = validator;
  20279. /**
  20280. * Validates a sequence of operations. If `tree` parameter is provided, the sequence is additionally validated against the object tree.
  20281. * If error is encountered, returns a JsonPatchError object
  20282. * @param sequence
  20283. * @param tree
  20284. * @returns {JsonPatchError|undefined}
  20285. */
  20286. function validate(sequence, tree) {
  20287. try {
  20288. if (!_isArray(sequence)) {
  20289. throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
  20290. }
  20291. if (tree) {
  20292. tree = JSON.parse(JSON.stringify(tree)); //clone tree so that we can safely try applying operations
  20293. apply.call(this, tree, sequence, true);
  20294. } else {
  20295. for (var i = 0; i < sequence.length; i++) {
  20296. this.validator(sequence[i], i);
  20297. }
  20298. }
  20299. } catch (e) {
  20300. if (e instanceof JsonPatchError) {
  20301. return e;
  20302. } else {
  20303. throw e;
  20304. }
  20305. }
  20306. }
  20307. jsonpatch.validate = validate;
  20308. })(jsonpatch || (jsonpatch = {}));
  20309. if (true) {
  20310. exports.apply = jsonpatch.apply;
  20311. exports.observe = jsonpatch.observe;
  20312. exports.unobserve = jsonpatch.unobserve;
  20313. exports.generate = jsonpatch.generate;
  20314. exports.compare = jsonpatch.compare;
  20315. exports.validate = jsonpatch.validate;
  20316. exports.validator = jsonpatch.validator;
  20317. exports.JsonPatchError = jsonpatch.JsonPatchError;
  20318. exports.Error = jsonpatch.Error;
  20319. }
  20320. /***/ }),
  20321. /* 250 */
  20322. /***/ (function(module, exports, __webpack_require__) {
  20323. "use strict";
  20324. exports.__esModule = true;
  20325. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  20326. var _element = __webpack_require__(0);
  20327. var _event = __webpack_require__(7);
  20328. var _object = __webpack_require__(1);
  20329. var _browser = __webpack_require__(25);
  20330. var _eventManager = __webpack_require__(4);
  20331. var _eventManager2 = _interopRequireDefault(_eventManager);
  20332. var _coords = __webpack_require__(43);
  20333. var _coords2 = _interopRequireDefault(_coords);
  20334. var _base = __webpack_require__(28);
  20335. var _base2 = _interopRequireDefault(_base);
  20336. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20337. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20338. /**
  20339. *
  20340. */
  20341. var Border = function () {
  20342. /**
  20343. * @param {Walkontable} wotInstance
  20344. * @param {Object} settings
  20345. */
  20346. function Border(wotInstance, settings) {
  20347. _classCallCheck(this, Border);
  20348. if (!settings) {
  20349. return;
  20350. }
  20351. this.eventManager = new _eventManager2.default(wotInstance);
  20352. this.instance = wotInstance;
  20353. this.wot = wotInstance;
  20354. this.settings = settings;
  20355. this.mouseDown = false;
  20356. this.main = null;
  20357. this.top = null;
  20358. this.left = null;
  20359. this.bottom = null;
  20360. this.right = null;
  20361. this.topStyle = null;
  20362. this.leftStyle = null;
  20363. this.bottomStyle = null;
  20364. this.rightStyle = null;
  20365. this.cornerDefaultStyle = {
  20366. width: '5px',
  20367. height: '5px',
  20368. borderWidth: '2px',
  20369. borderStyle: 'solid',
  20370. borderColor: '#FFF'
  20371. };
  20372. this.corner = null;
  20373. this.cornerStyle = null;
  20374. this.createBorders(settings);
  20375. this.registerListeners();
  20376. }
  20377. /**
  20378. * Register all necessary events
  20379. */
  20380. _createClass(Border, [{
  20381. key: 'registerListeners',
  20382. value: function registerListeners() {
  20383. var _this2 = this;
  20384. this.eventManager.addEventListener(document.body, 'mousedown', function () {
  20385. return _this2.onMouseDown();
  20386. });
  20387. this.eventManager.addEventListener(document.body, 'mouseup', function () {
  20388. return _this2.onMouseUp();
  20389. });
  20390. var _loop = function _loop(c, len) {
  20391. _this2.eventManager.addEventListener(_this2.main.childNodes[c], 'mouseenter', function (event) {
  20392. return _this2.onMouseEnter(event, _this2.main.childNodes[c]);
  20393. });
  20394. };
  20395. for (var c = 0, len = this.main.childNodes.length; c < len; c++) {
  20396. _loop(c, len);
  20397. }
  20398. }
  20399. /**
  20400. * Mouse down listener
  20401. *
  20402. * @private
  20403. */
  20404. }, {
  20405. key: 'onMouseDown',
  20406. value: function onMouseDown() {
  20407. this.mouseDown = true;
  20408. }
  20409. /**
  20410. * Mouse up listener
  20411. *
  20412. * @private
  20413. */
  20414. }, {
  20415. key: 'onMouseUp',
  20416. value: function onMouseUp() {
  20417. this.mouseDown = false;
  20418. }
  20419. /**
  20420. * Mouse enter listener for fragment selection functionality.
  20421. *
  20422. * @private
  20423. * @param {Event} event Dom event
  20424. * @param {HTMLElement} parentElement Part of border element.
  20425. */
  20426. }, {
  20427. key: 'onMouseEnter',
  20428. value: function onMouseEnter(event, parentElement) {
  20429. if (!this.mouseDown || !this.wot.getSetting('hideBorderOnMouseDownOver')) {
  20430. return;
  20431. }
  20432. event.preventDefault();
  20433. (0, _event.stopImmediatePropagation)(event);
  20434. var _this = this;
  20435. var bounds = parentElement.getBoundingClientRect();
  20436. // Hide border to prevents selection jumping when fragmentSelection is enabled.
  20437. parentElement.style.display = 'none';
  20438. function isOutside(event) {
  20439. if (event.clientY < Math.floor(bounds.top)) {
  20440. return true;
  20441. }
  20442. if (event.clientY > Math.ceil(bounds.top + bounds.height)) {
  20443. return true;
  20444. }
  20445. if (event.clientX < Math.floor(bounds.left)) {
  20446. return true;
  20447. }
  20448. if (event.clientX > Math.ceil(bounds.left + bounds.width)) {
  20449. return true;
  20450. }
  20451. }
  20452. function handler(event) {
  20453. if (isOutside(event)) {
  20454. _this.eventManager.removeEventListener(document.body, 'mousemove', handler);
  20455. parentElement.style.display = 'block';
  20456. }
  20457. }
  20458. this.eventManager.addEventListener(document.body, 'mousemove', handler);
  20459. }
  20460. /**
  20461. * Create border elements
  20462. *
  20463. * @param {Object} settings
  20464. */
  20465. }, {
  20466. key: 'createBorders',
  20467. value: function createBorders(settings) {
  20468. this.main = document.createElement('div');
  20469. var borderDivs = ['top', 'left', 'bottom', 'right', 'corner'];
  20470. var style = this.main.style;
  20471. style.position = 'absolute';
  20472. style.top = 0;
  20473. style.left = 0;
  20474. for (var i = 0; i < 5; i++) {
  20475. var position = borderDivs[i];
  20476. var div = document.createElement('div');
  20477. div.className = 'wtBorder ' + (this.settings.className || ''); // + borderDivs[i];
  20478. if (this.settings[position] && this.settings[position].hide) {
  20479. div.className += ' hidden';
  20480. }
  20481. style = div.style;
  20482. style.backgroundColor = this.settings[position] && this.settings[position].color ? this.settings[position].color : settings.border.color;
  20483. style.height = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  20484. style.width = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  20485. this.main.appendChild(div);
  20486. }
  20487. this.top = this.main.childNodes[0];
  20488. this.left = this.main.childNodes[1];
  20489. this.bottom = this.main.childNodes[2];
  20490. this.right = this.main.childNodes[3];
  20491. this.topStyle = this.top.style;
  20492. this.leftStyle = this.left.style;
  20493. this.bottomStyle = this.bottom.style;
  20494. this.rightStyle = this.right.style;
  20495. this.corner = this.main.childNodes[4];
  20496. this.corner.className += ' corner';
  20497. this.cornerStyle = this.corner.style;
  20498. this.cornerStyle.width = this.cornerDefaultStyle.width;
  20499. this.cornerStyle.height = this.cornerDefaultStyle.height;
  20500. this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' ');
  20501. if ((0, _browser.isMobileBrowser)()) {
  20502. this.createMultipleSelectorHandles();
  20503. }
  20504. this.disappear();
  20505. if (!this.wot.wtTable.bordersHolder) {
  20506. this.wot.wtTable.bordersHolder = document.createElement('div');
  20507. this.wot.wtTable.bordersHolder.className = 'htBorders';
  20508. this.wot.wtTable.spreader.appendChild(this.wot.wtTable.bordersHolder);
  20509. }
  20510. this.wot.wtTable.bordersHolder.insertBefore(this.main, this.wot.wtTable.bordersHolder.firstChild);
  20511. }
  20512. /**
  20513. * Create multiple selector handler for mobile devices
  20514. */
  20515. }, {
  20516. key: 'createMultipleSelectorHandles',
  20517. value: function createMultipleSelectorHandles() {
  20518. this.selectionHandles = {
  20519. topLeft: document.createElement('DIV'),
  20520. topLeftHitArea: document.createElement('DIV'),
  20521. bottomRight: document.createElement('DIV'),
  20522. bottomRightHitArea: document.createElement('DIV')
  20523. };
  20524. var width = 10;
  20525. var hitAreaWidth = 40;
  20526. this.selectionHandles.topLeft.className = 'topLeftSelectionHandle';
  20527. this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea';
  20528. this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle';
  20529. this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea';
  20530. this.selectionHandles.styles = {
  20531. topLeft: this.selectionHandles.topLeft.style,
  20532. topLeftHitArea: this.selectionHandles.topLeftHitArea.style,
  20533. bottomRight: this.selectionHandles.bottomRight.style,
  20534. bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style
  20535. };
  20536. var hitAreaStyle = {
  20537. position: 'absolute',
  20538. height: hitAreaWidth + 'px',
  20539. width: hitAreaWidth + 'px',
  20540. 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px'
  20541. };
  20542. for (var prop in hitAreaStyle) {
  20543. if ((0, _object.hasOwnProperty)(hitAreaStyle, prop)) {
  20544. this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop];
  20545. this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop];
  20546. }
  20547. }
  20548. var handleStyle = {
  20549. position: 'absolute',
  20550. height: width + 'px',
  20551. width: width + 'px',
  20552. 'border-radius': parseInt(width / 1.5, 10) + 'px',
  20553. background: '#F5F5FF',
  20554. border: '1px solid #4285c8'
  20555. };
  20556. for (var _prop in handleStyle) {
  20557. if ((0, _object.hasOwnProperty)(handleStyle, _prop)) {
  20558. this.selectionHandles.styles.bottomRight[_prop] = handleStyle[_prop];
  20559. this.selectionHandles.styles.topLeft[_prop] = handleStyle[_prop];
  20560. }
  20561. }
  20562. this.main.appendChild(this.selectionHandles.topLeft);
  20563. this.main.appendChild(this.selectionHandles.bottomRight);
  20564. this.main.appendChild(this.selectionHandles.topLeftHitArea);
  20565. this.main.appendChild(this.selectionHandles.bottomRightHitArea);
  20566. }
  20567. }, {
  20568. key: 'isPartRange',
  20569. value: function isPartRange(row, col) {
  20570. if (this.wot.selections.area.cellRange) {
  20571. if (row != this.wot.selections.area.cellRange.to.row || col != this.wot.selections.area.cellRange.to.col) {
  20572. return true;
  20573. }
  20574. }
  20575. return false;
  20576. }
  20577. }, {
  20578. key: 'updateMultipleSelectionHandlesPosition',
  20579. value: function updateMultipleSelectionHandlesPosition(row, col, top, left, width, height) {
  20580. var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10);
  20581. var hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10);
  20582. this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + 'px';
  20583. this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + 'px';
  20584. this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - hitAreaWidth / 4 * 3, 10) + 'px';
  20585. this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - hitAreaWidth / 4 * 3, 10) + 'px';
  20586. this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + 'px';
  20587. this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + 'px';
  20588. this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + 'px';
  20589. this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + 'px';
  20590. if (this.settings.border.multipleSelectionHandlesVisible && this.settings.border.multipleSelectionHandlesVisible()) {
  20591. this.selectionHandles.styles.topLeft.display = 'block';
  20592. this.selectionHandles.styles.topLeftHitArea.display = 'block';
  20593. if (this.isPartRange(row, col)) {
  20594. this.selectionHandles.styles.bottomRight.display = 'none';
  20595. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  20596. } else {
  20597. this.selectionHandles.styles.bottomRight.display = 'block';
  20598. this.selectionHandles.styles.bottomRightHitArea.display = 'block';
  20599. }
  20600. } else {
  20601. this.selectionHandles.styles.topLeft.display = 'none';
  20602. this.selectionHandles.styles.bottomRight.display = 'none';
  20603. this.selectionHandles.styles.topLeftHitArea.display = 'none';
  20604. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  20605. }
  20606. if (row == this.wot.wtSettings.getSetting('fixedRowsTop') || col == this.wot.wtSettings.getSetting('fixedColumnsLeft')) {
  20607. this.selectionHandles.styles.topLeft.zIndex = '9999';
  20608. this.selectionHandles.styles.topLeftHitArea.zIndex = '9999';
  20609. } else {
  20610. this.selectionHandles.styles.topLeft.zIndex = '';
  20611. this.selectionHandles.styles.topLeftHitArea.zIndex = '';
  20612. }
  20613. }
  20614. /**
  20615. * Show border around one or many cells
  20616. *
  20617. * @param {Array} corners
  20618. */
  20619. }, {
  20620. key: 'appear',
  20621. value: function appear(corners) {
  20622. if (this.disabled) {
  20623. return;
  20624. }
  20625. var isMultiple, fromTD, toTD, fromOffset, toOffset, containerOffset, top, minTop, left, minLeft, height, width, fromRow, fromColumn, toRow, toColumn, trimmingContainer, cornerOverlappingContainer, ilen;
  20626. ilen = this.wot.wtTable.getRenderedRowsCount();
  20627. for (var i = 0; i < ilen; i++) {
  20628. var s = this.wot.wtTable.rowFilter.renderedToSource(i);
  20629. if (s >= corners[0] && s <= corners[2]) {
  20630. fromRow = s;
  20631. break;
  20632. }
  20633. }
  20634. for (var _i = ilen - 1; _i >= 0; _i--) {
  20635. var _s = this.wot.wtTable.rowFilter.renderedToSource(_i);
  20636. if (_s >= corners[0] && _s <= corners[2]) {
  20637. toRow = _s;
  20638. break;
  20639. }
  20640. }
  20641. ilen = this.wot.wtTable.getRenderedColumnsCount();
  20642. for (var _i2 = 0; _i2 < ilen; _i2++) {
  20643. var _s2 = this.wot.wtTable.columnFilter.renderedToSource(_i2);
  20644. if (_s2 >= corners[1] && _s2 <= corners[3]) {
  20645. fromColumn = _s2;
  20646. break;
  20647. }
  20648. }
  20649. for (var _i3 = ilen - 1; _i3 >= 0; _i3--) {
  20650. var _s3 = this.wot.wtTable.columnFilter.renderedToSource(_i3);
  20651. if (_s3 >= corners[1] && _s3 <= corners[3]) {
  20652. toColumn = _s3;
  20653. break;
  20654. }
  20655. }
  20656. if (fromRow === void 0 || fromColumn === void 0) {
  20657. this.disappear();
  20658. return;
  20659. }
  20660. isMultiple = fromRow !== toRow || fromColumn !== toColumn;
  20661. fromTD = this.wot.wtTable.getCell(new _coords2.default(fromRow, fromColumn));
  20662. toTD = isMultiple ? this.wot.wtTable.getCell(new _coords2.default(toRow, toColumn)) : fromTD;
  20663. fromOffset = (0, _element.offset)(fromTD);
  20664. toOffset = isMultiple ? (0, _element.offset)(toTD) : fromOffset;
  20665. containerOffset = (0, _element.offset)(this.wot.wtTable.TABLE);
  20666. minTop = fromOffset.top;
  20667. height = toOffset.top + (0, _element.outerHeight)(toTD) - minTop;
  20668. minLeft = fromOffset.left;
  20669. width = toOffset.left + (0, _element.outerWidth)(toTD) - minLeft;
  20670. top = minTop - containerOffset.top - 1;
  20671. left = minLeft - containerOffset.left - 1;
  20672. var style = (0, _element.getComputedStyle)(fromTD);
  20673. if (parseInt(style.borderTopWidth, 10) > 0) {
  20674. top += 1;
  20675. height = height > 0 ? height - 1 : 0;
  20676. }
  20677. if (parseInt(style.borderLeftWidth, 10) > 0) {
  20678. left += 1;
  20679. width = width > 0 ? width - 1 : 0;
  20680. }
  20681. this.topStyle.top = top + 'px';
  20682. this.topStyle.left = left + 'px';
  20683. this.topStyle.width = width + 'px';
  20684. this.topStyle.display = 'block';
  20685. this.leftStyle.top = top + 'px';
  20686. this.leftStyle.left = left + 'px';
  20687. this.leftStyle.height = height + 'px';
  20688. this.leftStyle.display = 'block';
  20689. var delta = Math.floor(this.settings.border.width / 2);
  20690. this.bottomStyle.top = top + height - delta + 'px';
  20691. this.bottomStyle.left = left + 'px';
  20692. this.bottomStyle.width = width + 'px';
  20693. this.bottomStyle.display = 'block';
  20694. this.rightStyle.top = top + 'px';
  20695. this.rightStyle.left = left + width - delta + 'px';
  20696. this.rightStyle.height = height + 1 + 'px';
  20697. this.rightStyle.display = 'block';
  20698. if ((0, _browser.isMobileBrowser)() || !this.hasSetting(this.settings.border.cornerVisible) || this.isPartRange(toRow, toColumn)) {
  20699. this.cornerStyle.display = 'none';
  20700. } else {
  20701. this.cornerStyle.top = top + height - 4 + 'px';
  20702. this.cornerStyle.left = left + width - 4 + 'px';
  20703. this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth;
  20704. this.cornerStyle.width = this.cornerDefaultStyle.width;
  20705. // Hide the fill handle, so the possible further adjustments won't force unneeded scrollbars.
  20706. this.cornerStyle.display = 'none';
  20707. trimmingContainer = (0, _element.getTrimmingContainer)(this.wot.wtTable.TABLE);
  20708. if (toColumn === this.wot.getSetting('totalColumns') - 1) {
  20709. cornerOverlappingContainer = toTD.offsetLeft + (0, _element.outerWidth)(toTD) + parseInt(this.cornerDefaultStyle.width, 10) / 2 >= (0, _element.innerWidth)(trimmingContainer);
  20710. if (cornerOverlappingContainer) {
  20711. this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width, 10) / 2) + 'px';
  20712. this.cornerStyle.borderRightWidth = 0;
  20713. }
  20714. }
  20715. if (toRow === this.wot.getSetting('totalRows') - 1) {
  20716. cornerOverlappingContainer = toTD.offsetTop + (0, _element.outerHeight)(toTD) + parseInt(this.cornerDefaultStyle.height, 10) / 2 >= (0, _element.innerHeight)(trimmingContainer);
  20717. if (cornerOverlappingContainer) {
  20718. this.cornerStyle.top = Math.floor(top + height - 3 - parseInt(this.cornerDefaultStyle.height, 10) / 2) + 'px';
  20719. this.cornerStyle.borderBottomWidth = 0;
  20720. }
  20721. }
  20722. this.cornerStyle.display = 'block';
  20723. }
  20724. if ((0, _browser.isMobileBrowser)()) {
  20725. this.updateMultipleSelectionHandlesPosition(fromRow, fromColumn, top, left, width, height);
  20726. }
  20727. }
  20728. /**
  20729. * Hide border
  20730. */
  20731. }, {
  20732. key: 'disappear',
  20733. value: function disappear() {
  20734. this.topStyle.display = 'none';
  20735. this.leftStyle.display = 'none';
  20736. this.bottomStyle.display = 'none';
  20737. this.rightStyle.display = 'none';
  20738. this.cornerStyle.display = 'none';
  20739. if ((0, _browser.isMobileBrowser)()) {
  20740. this.selectionHandles.styles.topLeft.display = 'none';
  20741. this.selectionHandles.styles.bottomRight.display = 'none';
  20742. }
  20743. }
  20744. /**
  20745. * @param {Function} setting
  20746. * @returns {*}
  20747. */
  20748. }, {
  20749. key: 'hasSetting',
  20750. value: function hasSetting(setting) {
  20751. if (typeof setting === 'function') {
  20752. return setting();
  20753. }
  20754. return !!setting;
  20755. }
  20756. }]);
  20757. return Border;
  20758. }();
  20759. exports.default = Border;
  20760. /***/ }),
  20761. /* 251 */
  20762. /***/ (function(module, exports, __webpack_require__) {
  20763. "use strict";
  20764. exports.__esModule = true;
  20765. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  20766. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20767. var privatePool = new WeakMap();
  20768. /**
  20769. * Calculates indexes of columns to render OR columns that are visible.
  20770. * To redo the calculation, you need to create a new calculator.
  20771. *
  20772. * @class ViewportColumnsCalculator
  20773. */
  20774. var ViewportColumnsCalculator = function () {
  20775. _createClass(ViewportColumnsCalculator, null, [{
  20776. key: 'DEFAULT_WIDTH',
  20777. /**
  20778. * Default column width
  20779. *
  20780. * @type {Number}
  20781. */
  20782. get: function get() {
  20783. return 50;
  20784. }
  20785. /**
  20786. * @param {Number} viewportWidth Width of the viewport
  20787. * @param {Number} scrollOffset Current horizontal scroll position of the viewport
  20788. * @param {Number} totalColumns Total number of rows
  20789. * @param {Function} columnWidthFn Function that returns the width of the column at a given index (in px)
  20790. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  20791. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  20792. * @param {Boolean} stretchH
  20793. * @param {Function} [stretchingColumnWidthFn] Function that returns the new width of the stretched column.
  20794. */
  20795. }]);
  20796. function ViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) {
  20797. var stretchingColumnWidthFn = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : function (width) {
  20798. return width;
  20799. };
  20800. _classCallCheck(this, ViewportColumnsCalculator);
  20801. privatePool.set(this, {
  20802. viewportWidth: viewportWidth,
  20803. scrollOffset: scrollOffset,
  20804. totalColumns: totalColumns,
  20805. columnWidthFn: columnWidthFn,
  20806. overrideFn: overrideFn,
  20807. onlyFullyVisible: onlyFullyVisible,
  20808. stretchingColumnWidthFn: stretchingColumnWidthFn
  20809. });
  20810. /**
  20811. * Number of rendered/visible columns
  20812. *
  20813. * @type {Number}
  20814. */
  20815. this.count = 0;
  20816. /**
  20817. * Index of the first rendered/visible column (can be overwritten using overrideFn)
  20818. *
  20819. * @type {Number|null}
  20820. */
  20821. this.startColumn = null;
  20822. /**
  20823. * Index of the last rendered/visible column (can be overwritten using overrideFn)
  20824. *
  20825. * @type {null}
  20826. */
  20827. this.endColumn = null;
  20828. /**
  20829. * Position of the first rendered/visible column (in px)
  20830. *
  20831. * @type {Number|null}
  20832. */
  20833. this.startPosition = null;
  20834. this.stretchAllRatio = 0;
  20835. this.stretchLastWidth = 0;
  20836. this.stretch = stretchH;
  20837. this.totalTargetWidth = 0;
  20838. this.needVerifyLastColumnWidth = true;
  20839. this.stretchAllColumnsWidth = [];
  20840. this.calculate();
  20841. }
  20842. /**
  20843. * Calculates viewport
  20844. */
  20845. _createClass(ViewportColumnsCalculator, [{
  20846. key: 'calculate',
  20847. value: function calculate() {
  20848. var sum = 0;
  20849. var needReverse = true;
  20850. var startPositions = [];
  20851. var columnWidth = void 0;
  20852. var priv = privatePool.get(this);
  20853. var onlyFullyVisible = priv.onlyFullyVisible;
  20854. var overrideFn = priv.overrideFn;
  20855. var scrollOffset = priv.scrollOffset;
  20856. var totalColumns = priv.totalColumns;
  20857. var viewportWidth = priv.viewportWidth;
  20858. for (var i = 0; i < totalColumns; i++) {
  20859. columnWidth = this._getColumnWidth(i);
  20860. if (sum <= scrollOffset && !onlyFullyVisible) {
  20861. this.startColumn = i;
  20862. }
  20863. // +1 pixel for row header width compensation for horizontal scroll > 0
  20864. var compensatedViewportWidth = scrollOffset > 0 ? viewportWidth + 1 : viewportWidth;
  20865. if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + compensatedViewportWidth) {
  20866. if (this.startColumn == null) {
  20867. this.startColumn = i;
  20868. }
  20869. this.endColumn = i;
  20870. }
  20871. startPositions.push(sum);
  20872. sum += columnWidth;
  20873. if (!onlyFullyVisible) {
  20874. this.endColumn = i;
  20875. }
  20876. if (sum >= scrollOffset + viewportWidth) {
  20877. needReverse = false;
  20878. break;
  20879. }
  20880. }
  20881. if (this.endColumn === totalColumns - 1 && needReverse) {
  20882. this.startColumn = this.endColumn;
  20883. while (this.startColumn > 0) {
  20884. var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
  20885. if (viewportSum <= viewportWidth || !onlyFullyVisible) {
  20886. this.startColumn--;
  20887. }
  20888. if (viewportSum > viewportWidth) {
  20889. break;
  20890. }
  20891. }
  20892. }
  20893. if (this.startColumn !== null && overrideFn) {
  20894. overrideFn(this);
  20895. }
  20896. this.startPosition = startPositions[this.startColumn];
  20897. if (this.startPosition == void 0) {
  20898. this.startPosition = null;
  20899. }
  20900. if (this.startColumn !== null) {
  20901. this.count = this.endColumn - this.startColumn + 1;
  20902. }
  20903. }
  20904. /**
  20905. * Recalculate columns stretching.
  20906. *
  20907. * @param {Number} totalWidth
  20908. */
  20909. }, {
  20910. key: 'refreshStretching',
  20911. value: function refreshStretching(totalWidth) {
  20912. if (this.stretch === 'none') {
  20913. return;
  20914. }
  20915. this.totalTargetWidth = totalWidth;
  20916. var priv = privatePool.get(this);
  20917. var totalColumns = priv.totalColumns;
  20918. var sumAll = 0;
  20919. for (var i = 0; i < totalColumns; i++) {
  20920. var columnWidth = this._getColumnWidth(i);
  20921. var permanentColumnWidth = priv.stretchingColumnWidthFn(void 0, i);
  20922. if (typeof permanentColumnWidth === 'number') {
  20923. totalWidth -= permanentColumnWidth;
  20924. } else {
  20925. sumAll += columnWidth;
  20926. }
  20927. }
  20928. var remainingSize = totalWidth - sumAll;
  20929. if (this.stretch === 'all' && remainingSize > 0) {
  20930. this.stretchAllRatio = totalWidth / sumAll;
  20931. this.stretchAllColumnsWidth = [];
  20932. this.needVerifyLastColumnWidth = true;
  20933. } else if (this.stretch === 'last' && totalWidth !== Infinity) {
  20934. var _columnWidth = this._getColumnWidth(totalColumns - 1);
  20935. var lastColumnWidth = remainingSize + _columnWidth;
  20936. this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : _columnWidth;
  20937. }
  20938. }
  20939. /**
  20940. * Get stretched column width based on stretchH (all or last) setting passed in handsontable instance.
  20941. *
  20942. * @param {Number} column
  20943. * @param {Number} baseWidth
  20944. * @returns {Number|null}
  20945. */
  20946. }, {
  20947. key: 'getStretchedColumnWidth',
  20948. value: function getStretchedColumnWidth(column, baseWidth) {
  20949. var result = null;
  20950. if (this.stretch === 'all' && this.stretchAllRatio !== 0) {
  20951. result = this._getStretchedAllColumnWidth(column, baseWidth);
  20952. } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) {
  20953. result = this._getStretchedLastColumnWidth(column);
  20954. }
  20955. return result;
  20956. }
  20957. /**
  20958. * @param {Number} column
  20959. * @param {Number} baseWidth
  20960. * @returns {Number}
  20961. * @private
  20962. */
  20963. }, {
  20964. key: '_getStretchedAllColumnWidth',
  20965. value: function _getStretchedAllColumnWidth(column, baseWidth) {
  20966. var sumRatioWidth = 0;
  20967. var priv = privatePool.get(this);
  20968. var totalColumns = priv.totalColumns;
  20969. if (!this.stretchAllColumnsWidth[column]) {
  20970. var stretchedWidth = Math.round(baseWidth * this.stretchAllRatio);
  20971. var newStretchedWidth = priv.stretchingColumnWidthFn(stretchedWidth, column);
  20972. if (newStretchedWidth === void 0) {
  20973. this.stretchAllColumnsWidth[column] = stretchedWidth;
  20974. } else {
  20975. this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth;
  20976. }
  20977. }
  20978. if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) {
  20979. this.needVerifyLastColumnWidth = false;
  20980. for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) {
  20981. sumRatioWidth += this.stretchAllColumnsWidth[i];
  20982. }
  20983. if (sumRatioWidth !== this.totalTargetWidth) {
  20984. this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth;
  20985. }
  20986. }
  20987. return this.stretchAllColumnsWidth[column];
  20988. }
  20989. /**
  20990. * @param {Number} column
  20991. * @returns {Number|null}
  20992. * @private
  20993. */
  20994. }, {
  20995. key: '_getStretchedLastColumnWidth',
  20996. value: function _getStretchedLastColumnWidth(column) {
  20997. var priv = privatePool.get(this);
  20998. var totalColumns = priv.totalColumns;
  20999. if (column === totalColumns - 1) {
  21000. return this.stretchLastWidth;
  21001. }
  21002. return null;
  21003. }
  21004. /**
  21005. * @param {Number} column Column index.
  21006. * @returns {Number}
  21007. * @private
  21008. */
  21009. }, {
  21010. key: '_getColumnWidth',
  21011. value: function _getColumnWidth(column) {
  21012. var width = privatePool.get(this).columnWidthFn(column);
  21013. if (width === void 0) {
  21014. width = ViewportColumnsCalculator.DEFAULT_WIDTH;
  21015. }
  21016. return width;
  21017. }
  21018. }]);
  21019. return ViewportColumnsCalculator;
  21020. }();
  21021. exports.default = ViewportColumnsCalculator;
  21022. /***/ }),
  21023. /* 252 */
  21024. /***/ (function(module, exports, __webpack_require__) {
  21025. "use strict";
  21026. exports.__esModule = true;
  21027. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21028. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21029. var privatePool = new WeakMap();
  21030. /**
  21031. * Calculates indexes of rows to render OR rows that are visible.
  21032. * To redo the calculation, you need to create a new calculator.
  21033. *
  21034. * @class ViewportRowsCalculator
  21035. */
  21036. var ViewportRowsCalculator = function () {
  21037. _createClass(ViewportRowsCalculator, null, [{
  21038. key: "DEFAULT_HEIGHT",
  21039. /**
  21040. * Default row height
  21041. *
  21042. * @type {Number}
  21043. */
  21044. get: function get() {
  21045. return 23;
  21046. }
  21047. /**
  21048. * @param {Number} viewportHeight Height of the viewport
  21049. * @param {Number} scrollOffset Current vertical scroll position of the viewport
  21050. * @param {Number} totalRows Total number of rows
  21051. * @param {Function} rowHeightFn Function that returns the height of the row at a given index (in px)
  21052. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  21053. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  21054. * @param {Number} horizontalScrollbarHeight
  21055. */
  21056. }]);
  21057. function ViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible, horizontalScrollbarHeight) {
  21058. _classCallCheck(this, ViewportRowsCalculator);
  21059. privatePool.set(this, {
  21060. viewportHeight: viewportHeight,
  21061. scrollOffset: scrollOffset,
  21062. totalRows: totalRows,
  21063. rowHeightFn: rowHeightFn,
  21064. overrideFn: overrideFn,
  21065. onlyFullyVisible: onlyFullyVisible,
  21066. horizontalScrollbarHeight: horizontalScrollbarHeight
  21067. });
  21068. /**
  21069. * Number of rendered/visible rows
  21070. *
  21071. * @type {Number}
  21072. */
  21073. this.count = 0;
  21074. /**
  21075. * Index of the first rendered/visible row (can be overwritten using overrideFn)
  21076. *
  21077. * @type {Number|null}
  21078. */
  21079. this.startRow = null;
  21080. /**
  21081. * Index of the last rendered/visible row (can be overwritten using overrideFn)
  21082. *
  21083. * @type {null}
  21084. */
  21085. this.endRow = null;
  21086. /**
  21087. * Position of the first rendered/visible row (in px)
  21088. *
  21089. * @type {Number|null}
  21090. */
  21091. this.startPosition = null;
  21092. this.calculate();
  21093. }
  21094. /**
  21095. * Calculates viewport
  21096. */
  21097. _createClass(ViewportRowsCalculator, [{
  21098. key: "calculate",
  21099. value: function calculate() {
  21100. var sum = 0;
  21101. var needReverse = true;
  21102. var startPositions = [];
  21103. var priv = privatePool.get(this);
  21104. var onlyFullyVisible = priv.onlyFullyVisible;
  21105. var overrideFn = priv.overrideFn;
  21106. var rowHeightFn = priv.rowHeightFn;
  21107. var scrollOffset = priv.scrollOffset;
  21108. var totalRows = priv.totalRows;
  21109. var viewportHeight = priv.viewportHeight;
  21110. var horizontalScrollbarHeight = priv.horizontalScrollbarHeight || 0;
  21111. var rowHeight = void 0;
  21112. // Calculate the number (start and end index) of rows needed
  21113. for (var i = 0; i < totalRows; i++) {
  21114. rowHeight = rowHeightFn(i);
  21115. if (rowHeight === undefined) {
  21116. rowHeight = ViewportRowsCalculator.DEFAULT_HEIGHT;
  21117. }
  21118. if (sum <= scrollOffset && !onlyFullyVisible) {
  21119. this.startRow = i;
  21120. }
  21121. // the row is within the "visible range"
  21122. if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  21123. if (this.startRow === null) {
  21124. this.startRow = i;
  21125. }
  21126. this.endRow = i;
  21127. }
  21128. startPositions.push(sum);
  21129. sum += rowHeight;
  21130. if (!onlyFullyVisible) {
  21131. this.endRow = i;
  21132. }
  21133. if (sum >= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  21134. needReverse = false;
  21135. break;
  21136. }
  21137. }
  21138. // If the estimation has reached the last row and there is still some space available in the viewport,
  21139. // we need to render in reverse in order to fill the whole viewport with rows
  21140. if (this.endRow === totalRows - 1 && needReverse) {
  21141. this.startRow = this.endRow;
  21142. while (this.startRow > 0) {
  21143. // rowHeight is the height of the last row
  21144. var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1];
  21145. if (viewportSum <= viewportHeight - horizontalScrollbarHeight || !onlyFullyVisible) {
  21146. this.startRow--;
  21147. }
  21148. if (viewportSum >= viewportHeight - horizontalScrollbarHeight) {
  21149. break;
  21150. }
  21151. }
  21152. }
  21153. if (this.startRow !== null && overrideFn) {
  21154. overrideFn(this);
  21155. }
  21156. this.startPosition = startPositions[this.startRow];
  21157. if (this.startPosition == void 0) {
  21158. this.startPosition = null;
  21159. }
  21160. if (this.startRow !== null) {
  21161. this.count = this.endRow - this.startRow + 1;
  21162. }
  21163. }
  21164. }]);
  21165. return ViewportRowsCalculator;
  21166. }();
  21167. exports.default = ViewportRowsCalculator;
  21168. /***/ }),
  21169. /* 253 */
  21170. /***/ (function(module, exports, __webpack_require__) {
  21171. "use strict";
  21172. exports.__esModule = true;
  21173. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21174. var _element = __webpack_require__(0);
  21175. var _object = __webpack_require__(1);
  21176. var _string = __webpack_require__(27);
  21177. var _event = __webpack_require__(254);
  21178. var _event2 = _interopRequireDefault(_event);
  21179. var _overlays = __webpack_require__(257);
  21180. var _overlays2 = _interopRequireDefault(_overlays);
  21181. var _scroll = __webpack_require__(258);
  21182. var _scroll2 = _interopRequireDefault(_scroll);
  21183. var _settings = __webpack_require__(259);
  21184. var _settings2 = _interopRequireDefault(_settings);
  21185. var _table = __webpack_require__(260);
  21186. var _table2 = _interopRequireDefault(_table);
  21187. var _viewport = __webpack_require__(262);
  21188. var _viewport2 = _interopRequireDefault(_viewport);
  21189. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21190. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21191. /**
  21192. * @class Walkontable
  21193. */
  21194. var Walkontable = function () {
  21195. /**
  21196. * @param {Object} settings
  21197. */
  21198. function Walkontable(settings) {
  21199. _classCallCheck(this, Walkontable);
  21200. var originalHeaders = [];
  21201. // this is the namespace for global events
  21202. this.guid = 'wt_' + (0, _string.randomString)();
  21203. // bootstrap from settings
  21204. if (settings.cloneSource) {
  21205. this.cloneSource = settings.cloneSource;
  21206. this.cloneOverlay = settings.cloneOverlay;
  21207. this.wtSettings = settings.cloneSource.wtSettings;
  21208. this.wtTable = new _table2.default(this, settings.table, settings.wtRootElement);
  21209. this.wtScroll = new _scroll2.default(this);
  21210. this.wtViewport = settings.cloneSource.wtViewport;
  21211. this.wtEvent = new _event2.default(this);
  21212. this.selections = this.cloneSource.selections;
  21213. } else {
  21214. this.wtSettings = new _settings2.default(this, settings);
  21215. this.wtTable = new _table2.default(this, settings.table);
  21216. this.wtScroll = new _scroll2.default(this);
  21217. this.wtViewport = new _viewport2.default(this);
  21218. this.wtEvent = new _event2.default(this);
  21219. this.selections = this.getSetting('selections');
  21220. this.wtOverlays = new _overlays2.default(this);
  21221. this.exportSettingsAsClassNames();
  21222. }
  21223. // find original headers
  21224. if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) {
  21225. for (var c = 0, clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) {
  21226. originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML);
  21227. }
  21228. if (!this.getSetting('columnHeaders').length) {
  21229. this.update('columnHeaders', [function (column, TH) {
  21230. (0, _element.fastInnerText)(TH, originalHeaders[column]);
  21231. }]);
  21232. }
  21233. }
  21234. this.drawn = false;
  21235. this.drawInterrupted = false;
  21236. }
  21237. /**
  21238. * Force rerender of Walkontable
  21239. *
  21240. * @param {Boolean} [fastDraw=false] When `true`, try to refresh only the positions of borders without rerendering
  21241. * the data. It will only work if Table.draw() does not force
  21242. * rendering anyway
  21243. * @returns {Walkontable}
  21244. */
  21245. _createClass(Walkontable, [{
  21246. key: 'draw',
  21247. value: function draw() {
  21248. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  21249. this.drawInterrupted = false;
  21250. if (!fastDraw && !(0, _element.isVisible)(this.wtTable.TABLE)) {
  21251. // draw interrupted because TABLE is not visible
  21252. this.drawInterrupted = true;
  21253. } else {
  21254. this.wtTable.draw(fastDraw);
  21255. }
  21256. return this;
  21257. }
  21258. /**
  21259. * Returns the TD at coords. If topmost is set to true, returns TD from the topmost overlay layer,
  21260. * if not set or set to false, returns TD from the master table.
  21261. *
  21262. * @param {CellCoords} coords
  21263. * @param {Boolean} [topmost=false]
  21264. * @returns {Object}
  21265. */
  21266. }, {
  21267. key: 'getCell',
  21268. value: function getCell(coords) {
  21269. var topmost = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  21270. if (!topmost) {
  21271. return this.wtTable.getCell(coords);
  21272. }
  21273. var totalRows = this.wtSettings.getSetting('totalRows');
  21274. var fixedRowsTop = this.wtSettings.getSetting('fixedRowsTop');
  21275. var fixedRowsBottom = this.wtSettings.getSetting('fixedRowsBottom');
  21276. var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft');
  21277. if (coords.row < fixedRowsTop && coords.col < fixedColumns) {
  21278. return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords);
  21279. } else if (coords.row < fixedRowsTop) {
  21280. return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords);
  21281. } else if (coords.col < fixedColumns && coords.row >= totalRows - fixedRowsBottom) {
  21282. if (this.wtOverlays.bottomLeftCornerOverlay && this.wtOverlays.bottomLeftCornerOverlay.clone) {
  21283. return this.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell(coords);
  21284. }
  21285. } else if (coords.col < fixedColumns) {
  21286. return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords);
  21287. } else if (coords.row < totalRows && coords.row > totalRows - fixedRowsBottom) {
  21288. if (this.wtOverlays.bottomOverlay && this.wtOverlays.bottomOverlay.clone) {
  21289. return this.wtOverlays.bottomOverlay.clone.wtTable.getCell(coords);
  21290. }
  21291. }
  21292. return this.wtTable.getCell(coords);
  21293. }
  21294. /**
  21295. * @param {Object} settings
  21296. * @param {*} value
  21297. * @returns {Walkontable}
  21298. */
  21299. }, {
  21300. key: 'update',
  21301. value: function update(settings, value) {
  21302. return this.wtSettings.update(settings, value);
  21303. }
  21304. /**
  21305. * Scroll the viewport to a row at the given index in the data source
  21306. *
  21307. * @param {Number} row
  21308. * @returns {Walkontable}
  21309. */
  21310. }, {
  21311. key: 'scrollVertical',
  21312. value: function scrollVertical(row) {
  21313. this.wtOverlays.topOverlay.scrollTo(row);
  21314. this.getSetting('onScrollVertically');
  21315. return this;
  21316. }
  21317. /**
  21318. * Scroll the viewport to a column at the given index in the data source
  21319. *
  21320. * @param {Number} column
  21321. * @returns {Walkontable}
  21322. */
  21323. }, {
  21324. key: 'scrollHorizontal',
  21325. value: function scrollHorizontal(column) {
  21326. this.wtOverlays.leftOverlay.scrollTo(column);
  21327. this.getSetting('onScrollHorizontally');
  21328. return this;
  21329. }
  21330. /**
  21331. * Scrolls the viewport to a cell (rerenders if needed)
  21332. *
  21333. * @param {CellCoords} coords
  21334. * @returns {Walkontable}
  21335. */
  21336. }, {
  21337. key: 'scrollViewport',
  21338. value: function scrollViewport(coords) {
  21339. this.wtScroll.scrollViewport(coords);
  21340. return this;
  21341. }
  21342. /**
  21343. * @returns {Array}
  21344. */
  21345. }, {
  21346. key: 'getViewport',
  21347. value: function getViewport() {
  21348. return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()];
  21349. }
  21350. /**
  21351. * Get overlay name
  21352. *
  21353. * @returns {String}
  21354. */
  21355. }, {
  21356. key: 'getOverlayName',
  21357. value: function getOverlayName() {
  21358. return this.cloneOverlay ? this.cloneOverlay.type : 'master';
  21359. }
  21360. /**
  21361. * Check overlay type of this Walkontable instance.
  21362. *
  21363. * @param {String} name Clone type @see {Overlay.CLONE_TYPES}.
  21364. * @returns {Boolean}
  21365. */
  21366. }, {
  21367. key: 'isOverlayName',
  21368. value: function isOverlayName(name) {
  21369. if (this.cloneOverlay) {
  21370. return this.cloneOverlay.type === name;
  21371. }
  21372. return false;
  21373. }
  21374. /**
  21375. * Export settings as class names added to the parent element of the table.
  21376. */
  21377. }, {
  21378. key: 'exportSettingsAsClassNames',
  21379. value: function exportSettingsAsClassNames() {
  21380. var _this = this;
  21381. var toExport = {
  21382. rowHeaders: ['array'],
  21383. columnHeaders: ['array']
  21384. };
  21385. var allClassNames = [];
  21386. var newClassNames = [];
  21387. (0, _object.objectEach)(toExport, function (optionType, key) {
  21388. if (optionType.indexOf('array') > -1 && _this.getSetting(key).length) {
  21389. newClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  21390. }
  21391. allClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  21392. });
  21393. (0, _element.removeClass)(this.wtTable.wtRootElement.parentNode, allClassNames);
  21394. (0, _element.addClass)(this.wtTable.wtRootElement.parentNode, newClassNames);
  21395. }
  21396. /**
  21397. * Get/Set Walkontable instance setting
  21398. *
  21399. * @param {String} key
  21400. * @param {*} [param1]
  21401. * @param {*} [param2]
  21402. * @param {*} [param3]
  21403. * @param {*} [param4]
  21404. * @returns {*}
  21405. */
  21406. }, {
  21407. key: 'getSetting',
  21408. value: function getSetting(key, param1, param2, param3, param4) {
  21409. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  21410. return this.wtSettings.getSetting(key, param1, param2, param3, param4);
  21411. }
  21412. /**
  21413. * Checks if setting exists
  21414. *
  21415. * @param {String} key
  21416. * @returns {Boolean}
  21417. */
  21418. }, {
  21419. key: 'hasSetting',
  21420. value: function hasSetting(key) {
  21421. return this.wtSettings.has(key);
  21422. }
  21423. /**
  21424. * Destroy instance
  21425. */
  21426. }, {
  21427. key: 'destroy',
  21428. value: function destroy() {
  21429. this.wtOverlays.destroy();
  21430. this.wtEvent.destroy();
  21431. }
  21432. }]);
  21433. return Walkontable;
  21434. }();
  21435. exports.default = Walkontable;
  21436. /***/ }),
  21437. /* 254 */
  21438. /***/ (function(module, exports, __webpack_require__) {
  21439. "use strict";
  21440. exports.__esModule = true;
  21441. var _element = __webpack_require__(0);
  21442. var _function = __webpack_require__(35);
  21443. var _browser = __webpack_require__(25);
  21444. var _eventManager = __webpack_require__(4);
  21445. var _eventManager2 = _interopRequireDefault(_eventManager);
  21446. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21447. /**
  21448. *
  21449. */
  21450. function Event(instance) {
  21451. var that = this;
  21452. var eventManager = new _eventManager2.default(instance);
  21453. this.instance = instance;
  21454. var dblClickOrigin = [null, null];
  21455. this.dblClickTimeout = [null, null];
  21456. var onMouseDown = function onMouseDown(event) {
  21457. var activeElement = document.activeElement;
  21458. var getParentNode = (0, _function.partial)(_element.getParent, event.realTarget);
  21459. var realTarget = event.realTarget;
  21460. // ignore focusable element from mouse down processing (https://github.com/handsontable/handsontable/issues/3555)
  21461. if (realTarget === activeElement || getParentNode(0) === activeElement || getParentNode(1) === activeElement) {
  21462. return;
  21463. }
  21464. var cell = that.parentCell(realTarget);
  21465. if ((0, _element.hasClass)(realTarget, 'corner')) {
  21466. that.instance.getSetting('onCellCornerMouseDown', event, realTarget);
  21467. } else if (cell.TD) {
  21468. if (that.instance.hasSetting('onCellMouseDown')) {
  21469. that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance);
  21470. }
  21471. }
  21472. if (event.button !== 2) {
  21473. // if not right mouse button
  21474. if (cell.TD) {
  21475. dblClickOrigin[0] = cell.TD;
  21476. clearTimeout(that.dblClickTimeout[0]);
  21477. that.dblClickTimeout[0] = setTimeout(function () {
  21478. dblClickOrigin[0] = null;
  21479. }, 1000);
  21480. }
  21481. }
  21482. };
  21483. var onTouchMove = function onTouchMove(event) {
  21484. that.instance.touchMoving = true;
  21485. };
  21486. var longTouchTimeout;
  21487. var onTouchStart = function onTouchStart(event) {
  21488. var container = this;
  21489. eventManager.addEventListener(this, 'touchmove', onTouchMove);
  21490. // Prevent cell selection when scrolling with touch event - not the best solution performance-wise
  21491. that.checkIfTouchMove = setTimeout(function () {
  21492. if (that.instance.touchMoving === true) {
  21493. that.instance.touchMoving = void 0;
  21494. eventManager.removeEventListener('touchmove', onTouchMove, false);
  21495. }
  21496. onMouseDown(event);
  21497. }, 30);
  21498. };
  21499. var onMouseOver = function onMouseOver(event) {
  21500. var table, td, mainWOT;
  21501. if (that.instance.hasSetting('onCellMouseOver')) {
  21502. table = that.instance.wtTable.TABLE;
  21503. td = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  21504. mainWOT = that.instance.cloneSource || that.instance;
  21505. if (td && td !== mainWOT.lastMouseOver && (0, _element.isChildOf)(td, table)) {
  21506. mainWOT.lastMouseOver = td;
  21507. that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance);
  21508. }
  21509. }
  21510. };
  21511. var onMouseOut = function onMouseOut(event) {
  21512. var table = void 0;
  21513. var lastTD = void 0;
  21514. var nextTD = void 0;
  21515. if (that.instance.hasSetting('onCellMouseOut')) {
  21516. table = that.instance.wtTable.TABLE;
  21517. lastTD = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  21518. nextTD = (0, _element.closestDown)(event.relatedTarget, ['TD', 'TH'], table);
  21519. if (lastTD && lastTD !== nextTD && (0, _element.isChildOf)(lastTD, table)) {
  21520. that.instance.getSetting('onCellMouseOut', event, that.instance.wtTable.getCoords(lastTD), lastTD, that.instance);
  21521. }
  21522. }
  21523. };
  21524. var onMouseUp = function onMouseUp(event) {
  21525. if (event.button !== 2) {
  21526. // if not right mouse button
  21527. var cell = that.parentCell(event.realTarget);
  21528. if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) {
  21529. if ((0, _element.hasClass)(event.realTarget, 'corner')) {
  21530. that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance);
  21531. } else {
  21532. that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance);
  21533. }
  21534. dblClickOrigin[0] = null;
  21535. dblClickOrigin[1] = null;
  21536. } else if (cell.TD === dblClickOrigin[0]) {
  21537. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  21538. dblClickOrigin[1] = cell.TD;
  21539. clearTimeout(that.dblClickTimeout[1]);
  21540. that.dblClickTimeout[1] = setTimeout(function () {
  21541. dblClickOrigin[1] = null;
  21542. }, 500);
  21543. } else if (cell.TD && that.instance.hasSetting('onCellMouseUp')) {
  21544. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  21545. }
  21546. }
  21547. };
  21548. var onTouchEnd = function onTouchEnd(event) {
  21549. clearTimeout(longTouchTimeout);
  21550. // that.instance.longTouch == void 0;
  21551. event.preventDefault();
  21552. onMouseUp(event);
  21553. // eventManager.removeEventListener(that.instance.wtTable.holder, "mouseup", onMouseUp);
  21554. };
  21555. eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown);
  21556. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver);
  21557. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseout', onMouseOut);
  21558. eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp);
  21559. // check if full HOT instance, or detached WOT AND run on mobile device
  21560. if (this.instance.wtTable.holder.parentNode.parentNode && (0, _browser.isMobileBrowser)() && !that.instance.wtTable.isWorkingOnClone()) {
  21561. var classSelector = '.' + this.instance.wtTable.holder.parentNode.className.split(' ').join('.');
  21562. eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function (event) {
  21563. that.instance.touchApplied = true;
  21564. if ((0, _element.isChildOf)(event.target, classSelector)) {
  21565. onTouchStart.call(event.target, event);
  21566. }
  21567. });
  21568. eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function (event) {
  21569. that.instance.touchApplied = false;
  21570. if ((0, _element.isChildOf)(event.target, classSelector)) {
  21571. onTouchEnd.call(event.target, event);
  21572. }
  21573. });
  21574. if (!that.instance.momentumScrolling) {
  21575. that.instance.momentumScrolling = {};
  21576. }
  21577. eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function (event) {
  21578. clearTimeout(that.instance.momentumScrolling._timeout);
  21579. if (!that.instance.momentumScrolling.ongoing) {
  21580. that.instance.getSetting('onBeforeTouchScroll');
  21581. }
  21582. that.instance.momentumScrolling.ongoing = true;
  21583. that.instance.momentumScrolling._timeout = setTimeout(function () {
  21584. if (!that.instance.touchApplied) {
  21585. that.instance.momentumScrolling.ongoing = false;
  21586. that.instance.getSetting('onAfterMomentumScroll');
  21587. }
  21588. }, 200);
  21589. });
  21590. }
  21591. eventManager.addEventListener(window, 'resize', function () {
  21592. if (that.instance.getSetting('stretchH') !== 'none') {
  21593. that.instance.draw();
  21594. }
  21595. });
  21596. this.destroy = function () {
  21597. clearTimeout(this.dblClickTimeout[0]);
  21598. clearTimeout(this.dblClickTimeout[1]);
  21599. eventManager.destroy();
  21600. };
  21601. }
  21602. Event.prototype.parentCell = function (elem) {
  21603. var cell = {};
  21604. var TABLE = this.instance.wtTable.TABLE;
  21605. var TD = (0, _element.closestDown)(elem, ['TD', 'TH'], TABLE);
  21606. if (TD) {
  21607. cell.coords = this.instance.wtTable.getCoords(TD);
  21608. cell.TD = TD;
  21609. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'current')) {
  21610. cell.coords = this.instance.selections.current.cellRange.highlight; // selections.current is current selected cell
  21611. cell.TD = this.instance.wtTable.getCell(cell.coords);
  21612. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'area')) {
  21613. if (this.instance.selections.area.cellRange) {
  21614. cell.coords = this.instance.selections.area.cellRange.to; // selections.area is area selected cells
  21615. cell.TD = this.instance.wtTable.getCell(cell.coords);
  21616. }
  21617. }
  21618. return cell;
  21619. };
  21620. exports.default = Event;
  21621. /***/ }),
  21622. /* 255 */
  21623. /***/ (function(module, exports, __webpack_require__) {
  21624. "use strict";
  21625. exports.__esModule = true;
  21626. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21627. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21628. /**
  21629. * @class ColumnFilter
  21630. */
  21631. var ColumnFilter = function () {
  21632. /**
  21633. * @param {Number} offset
  21634. * @param {Number} total
  21635. * @param {Number} countTH
  21636. */
  21637. function ColumnFilter(offset, total, countTH) {
  21638. _classCallCheck(this, ColumnFilter);
  21639. this.offset = offset;
  21640. this.total = total;
  21641. this.countTH = countTH;
  21642. }
  21643. /**
  21644. * @param index
  21645. * @returns {Number}
  21646. */
  21647. _createClass(ColumnFilter, [{
  21648. key: "offsetted",
  21649. value: function offsetted(index) {
  21650. return index + this.offset;
  21651. }
  21652. /**
  21653. * @param index
  21654. * @returns {Number}
  21655. */
  21656. }, {
  21657. key: "unOffsetted",
  21658. value: function unOffsetted(index) {
  21659. return index - this.offset;
  21660. }
  21661. /**
  21662. * @param index
  21663. * @returns {Number}
  21664. */
  21665. }, {
  21666. key: "renderedToSource",
  21667. value: function renderedToSource(index) {
  21668. return this.offsetted(index);
  21669. }
  21670. /**
  21671. * @param index
  21672. * @returns {Number}
  21673. */
  21674. }, {
  21675. key: "sourceToRendered",
  21676. value: function sourceToRendered(index) {
  21677. return this.unOffsetted(index);
  21678. }
  21679. /**
  21680. * @param index
  21681. * @returns {Number}
  21682. */
  21683. }, {
  21684. key: "offsettedTH",
  21685. value: function offsettedTH(index) {
  21686. return index - this.countTH;
  21687. }
  21688. /**
  21689. * @param index
  21690. * @returns {Number}
  21691. */
  21692. }, {
  21693. key: "unOffsettedTH",
  21694. value: function unOffsettedTH(index) {
  21695. return index + this.countTH;
  21696. }
  21697. /**
  21698. * @param index
  21699. * @returns {Number}
  21700. */
  21701. }, {
  21702. key: "visibleRowHeadedColumnToSourceColumn",
  21703. value: function visibleRowHeadedColumnToSourceColumn(index) {
  21704. return this.renderedToSource(this.offsettedTH(index));
  21705. }
  21706. /**
  21707. * @param index
  21708. * @returns {Number}
  21709. */
  21710. }, {
  21711. key: "sourceColumnToVisibleRowHeadedColumn",
  21712. value: function sourceColumnToVisibleRowHeadedColumn(index) {
  21713. return this.unOffsettedTH(this.sourceToRendered(index));
  21714. }
  21715. }]);
  21716. return ColumnFilter;
  21717. }();
  21718. exports.default = ColumnFilter;
  21719. /***/ }),
  21720. /* 256 */
  21721. /***/ (function(module, exports, __webpack_require__) {
  21722. "use strict";
  21723. exports.__esModule = true;
  21724. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21725. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21726. /**
  21727. * @class RowFilter
  21728. */
  21729. var RowFilter = function () {
  21730. /**
  21731. * @param {Number} offset
  21732. * @param {Number} total
  21733. * @param {Number} countTH
  21734. */
  21735. function RowFilter(offset, total, countTH) {
  21736. _classCallCheck(this, RowFilter);
  21737. this.offset = offset;
  21738. this.total = total;
  21739. this.countTH = countTH;
  21740. }
  21741. /**
  21742. * @param index
  21743. * @returns {Number}
  21744. */
  21745. _createClass(RowFilter, [{
  21746. key: "offsetted",
  21747. value: function offsetted(index) {
  21748. return index + this.offset;
  21749. }
  21750. /**
  21751. * @param index
  21752. * @returns {Number}
  21753. */
  21754. }, {
  21755. key: "unOffsetted",
  21756. value: function unOffsetted(index) {
  21757. return index - this.offset;
  21758. }
  21759. /**
  21760. * @param index
  21761. * @returns {Number}
  21762. */
  21763. }, {
  21764. key: "renderedToSource",
  21765. value: function renderedToSource(index) {
  21766. return this.offsetted(index);
  21767. }
  21768. /**
  21769. * @param index
  21770. * @returns {Number}
  21771. */
  21772. }, {
  21773. key: "sourceToRendered",
  21774. value: function sourceToRendered(index) {
  21775. return this.unOffsetted(index);
  21776. }
  21777. /**
  21778. * @param index
  21779. * @returns {Number}
  21780. */
  21781. }, {
  21782. key: "offsettedTH",
  21783. value: function offsettedTH(index) {
  21784. return index - this.countTH;
  21785. }
  21786. /**
  21787. * @param index
  21788. * @returns {Number}
  21789. */
  21790. }, {
  21791. key: "unOffsettedTH",
  21792. value: function unOffsettedTH(index) {
  21793. return index + this.countTH;
  21794. }
  21795. /**
  21796. * @param index
  21797. * @returns {Number}
  21798. */
  21799. }, {
  21800. key: "visibleColHeadedRowToSourceRow",
  21801. value: function visibleColHeadedRowToSourceRow(index) {
  21802. return this.renderedToSource(this.offsettedTH(index));
  21803. }
  21804. /**
  21805. * @param index
  21806. * @returns {Number}
  21807. */
  21808. }, {
  21809. key: "sourceRowToVisibleColHeadedRow",
  21810. value: function sourceRowToVisibleColHeadedRow(index) {
  21811. return this.unOffsettedTH(this.sourceToRendered(index));
  21812. }
  21813. }]);
  21814. return RowFilter;
  21815. }();
  21816. exports.default = RowFilter;
  21817. /***/ }),
  21818. /* 257 */
  21819. /***/ (function(module, exports, __webpack_require__) {
  21820. "use strict";
  21821. exports.__esModule = true;
  21822. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21823. var _element = __webpack_require__(0);
  21824. var _array = __webpack_require__(2);
  21825. var _unicode = __webpack_require__(16);
  21826. var _browser = __webpack_require__(25);
  21827. var _eventManager = __webpack_require__(4);
  21828. var _eventManager2 = _interopRequireDefault(_eventManager);
  21829. var _base = __webpack_require__(28);
  21830. var _base2 = _interopRequireDefault(_base);
  21831. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21832. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21833. /**
  21834. * @class Overlays
  21835. */
  21836. var Overlays = function () {
  21837. /**
  21838. * @param {Walkontable} wotInstance
  21839. */
  21840. function Overlays(wotInstance) {
  21841. _classCallCheck(this, Overlays);
  21842. this.wot = wotInstance;
  21843. // legacy support
  21844. this.instance = this.wot;
  21845. this.eventManager = new _eventManager2.default(this.wot);
  21846. this.wot.update('scrollbarWidth', (0, _element.getScrollbarWidth)());
  21847. this.wot.update('scrollbarHeight', (0, _element.getScrollbarWidth)());
  21848. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  21849. this.prepareOverlays();
  21850. this.destroyed = false;
  21851. this.keyPressed = false;
  21852. this.spreaderLastSize = {
  21853. width: null,
  21854. height: null
  21855. };
  21856. this.overlayScrollPositions = {
  21857. master: {
  21858. top: 0,
  21859. left: 0
  21860. },
  21861. top: {
  21862. top: null,
  21863. left: 0
  21864. },
  21865. bottom: {
  21866. top: null,
  21867. left: 0
  21868. },
  21869. left: {
  21870. top: 0,
  21871. left: null
  21872. }
  21873. };
  21874. this.pendingScrollCallbacks = {
  21875. master: {
  21876. top: 0,
  21877. left: 0
  21878. },
  21879. top: {
  21880. left: 0
  21881. },
  21882. bottom: {
  21883. left: 0
  21884. },
  21885. left: {
  21886. top: 0
  21887. }
  21888. };
  21889. this.verticalScrolling = false;
  21890. this.horizontalScrolling = false;
  21891. this.delegatedScrollCallback = false;
  21892. this.registeredListeners = [];
  21893. this.registerListeners();
  21894. }
  21895. /**
  21896. * Prepare overlays based on user settings.
  21897. *
  21898. * @returns {Boolean} Returns `true` if changes applied to overlay needs scroll synchronization.
  21899. */
  21900. _createClass(Overlays, [{
  21901. key: 'prepareOverlays',
  21902. value: function prepareOverlays() {
  21903. var syncScroll = false;
  21904. if (this.topOverlay) {
  21905. syncScroll = this.topOverlay.updateStateOfRendering() || syncScroll;
  21906. } else {
  21907. this.topOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP, this.wot);
  21908. }
  21909. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM)) {
  21910. this.bottomOverlay = {
  21911. needFullRender: false,
  21912. updateStateOfRendering: function updateStateOfRendering() {
  21913. return false;
  21914. }
  21915. };
  21916. }
  21917. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  21918. this.bottomLeftCornerOverlay = {
  21919. needFullRender: false,
  21920. updateStateOfRendering: function updateStateOfRendering() {
  21921. return false;
  21922. }
  21923. };
  21924. }
  21925. if (this.bottomOverlay) {
  21926. syncScroll = this.bottomOverlay.updateStateOfRendering() || syncScroll;
  21927. } else {
  21928. this.bottomOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM, this.wot);
  21929. }
  21930. if (this.leftOverlay) {
  21931. syncScroll = this.leftOverlay.updateStateOfRendering() || syncScroll;
  21932. } else {
  21933. this.leftOverlay = _base2.default.createOverlay(_base2.default.CLONE_LEFT, this.wot);
  21934. }
  21935. if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) {
  21936. if (this.topLeftCornerOverlay) {
  21937. syncScroll = this.topLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  21938. } else {
  21939. this.topLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, this.wot);
  21940. }
  21941. }
  21942. if (this.bottomOverlay.needFullRender && this.leftOverlay.needFullRender) {
  21943. if (this.bottomLeftCornerOverlay) {
  21944. syncScroll = this.bottomLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  21945. } else {
  21946. this.bottomLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER, this.wot);
  21947. }
  21948. }
  21949. if (this.wot.getSetting('debug') && !this.debug) {
  21950. this.debug = _base2.default.createOverlay(_base2.default.CLONE_DEBUG, this.wot);
  21951. }
  21952. return syncScroll;
  21953. }
  21954. /**
  21955. * Refresh and redraw table
  21956. */
  21957. }, {
  21958. key: 'refreshAll',
  21959. value: function refreshAll() {
  21960. if (!this.wot.drawn) {
  21961. return;
  21962. }
  21963. if (!this.wot.wtTable.holder.parentNode) {
  21964. // Walkontable was detached from DOM, but this handler was not removed
  21965. this.destroy();
  21966. return;
  21967. }
  21968. this.wot.draw(true);
  21969. if (this.verticalScrolling) {
  21970. this.leftOverlay.onScroll();
  21971. }
  21972. if (this.horizontalScrolling) {
  21973. this.topOverlay.onScroll();
  21974. }
  21975. this.verticalScrolling = false;
  21976. this.horizontalScrolling = false;
  21977. }
  21978. /**
  21979. * Register all necessary event listeners.
  21980. */
  21981. }, {
  21982. key: 'registerListeners',
  21983. value: function registerListeners() {
  21984. var _this = this;
  21985. var topOverlayScrollable = this.topOverlay.mainTableScrollableElement;
  21986. var leftOverlayScrollable = this.leftOverlay.mainTableScrollableElement;
  21987. var listenersToRegister = [];
  21988. listenersToRegister.push([document.documentElement, 'keydown', function (event) {
  21989. return _this.onKeyDown(event);
  21990. }]);
  21991. listenersToRegister.push([document.documentElement, 'keyup', function () {
  21992. return _this.onKeyUp();
  21993. }]);
  21994. listenersToRegister.push([document, 'visibilitychange', function () {
  21995. return _this.onKeyUp();
  21996. }]);
  21997. listenersToRegister.push([topOverlayScrollable, 'scroll', function (event) {
  21998. return _this.onTableScroll(event);
  21999. }]);
  22000. if (topOverlayScrollable !== leftOverlayScrollable) {
  22001. listenersToRegister.push([leftOverlayScrollable, 'scroll', function (event) {
  22002. return _this.onTableScroll(event);
  22003. }]);
  22004. }
  22005. if (this.topOverlay.needFullRender) {
  22006. listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'scroll', function (event) {
  22007. return _this.onTableScroll(event);
  22008. }]);
  22009. listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'wheel', function (event) {
  22010. return _this.onTableScroll(event);
  22011. }]);
  22012. }
  22013. if (this.bottomOverlay.needFullRender) {
  22014. listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'scroll', function (event) {
  22015. return _this.onTableScroll(event);
  22016. }]);
  22017. listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'wheel', function (event) {
  22018. return _this.onTableScroll(event);
  22019. }]);
  22020. }
  22021. if (this.leftOverlay.needFullRender) {
  22022. listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'scroll', function (event) {
  22023. return _this.onTableScroll(event);
  22024. }]);
  22025. listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'wheel', function (event) {
  22026. return _this.onTableScroll(event);
  22027. }]);
  22028. }
  22029. if (this.topLeftCornerOverlay && this.topLeftCornerOverlay.needFullRender) {
  22030. listenersToRegister.push([this.topLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  22031. return _this.onTableScroll(event);
  22032. }]);
  22033. }
  22034. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.needFullRender) {
  22035. listenersToRegister.push([this.bottomLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  22036. return _this.onTableScroll(event);
  22037. }]);
  22038. }
  22039. if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) {
  22040. // This is necessary?
  22041. // eventManager.addEventListener(window, 'scroll', (event) => this.refreshAll(event));
  22042. listenersToRegister.push([window, 'wheel', function (event) {
  22043. var overlay = void 0;
  22044. var deltaY = event.wheelDeltaY || event.deltaY;
  22045. var deltaX = event.wheelDeltaX || event.deltaX;
  22046. if (_this.topOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  22047. overlay = 'top';
  22048. } else if (_this.bottomOverlay.clone && _this.bottomOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  22049. overlay = 'bottom';
  22050. } else if (_this.leftOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  22051. overlay = 'left';
  22052. } else if (_this.topLeftCornerOverlay && _this.topLeftCornerOverlay.clone && _this.topLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  22053. overlay = 'topLeft';
  22054. } else if (_this.bottomLeftCornerOverlay && _this.bottomLeftCornerOverlay.clone && _this.bottomLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  22055. overlay = 'bottomLeft';
  22056. }
  22057. if (overlay == 'top' && deltaY !== 0 || overlay == 'left' && deltaX !== 0 || overlay == 'bottom' && deltaY !== 0 || (overlay === 'topLeft' || overlay === 'bottomLeft') && (deltaY !== 0 || deltaX !== 0)) {
  22058. event.preventDefault();
  22059. }
  22060. }]);
  22061. }
  22062. while (listenersToRegister.length) {
  22063. var listener = listenersToRegister.pop();
  22064. this.eventManager.addEventListener(listener[0], listener[1], listener[2]);
  22065. this.registeredListeners.push(listener);
  22066. }
  22067. }
  22068. /**
  22069. * Deregister all previously registered listeners.
  22070. */
  22071. }, {
  22072. key: 'deregisterListeners',
  22073. value: function deregisterListeners() {
  22074. while (this.registeredListeners.length) {
  22075. var listener = this.registeredListeners.pop();
  22076. this.eventManager.removeEventListener(listener[0], listener[1], listener[2]);
  22077. }
  22078. }
  22079. /**
  22080. * Scroll listener
  22081. *
  22082. * @param {Event} event
  22083. */
  22084. }, {
  22085. key: 'onTableScroll',
  22086. value: function onTableScroll(event) {
  22087. // if mobile browser, do not update scroll positions, as the overlays are hidden during the scroll
  22088. if ((0, _browser.isMobileBrowser)()) {
  22089. return;
  22090. }
  22091. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  22092. var masterVertical = this.topOverlay.mainTableScrollableElement;
  22093. var target = event.target;
  22094. // For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
  22095. // by hot.refreshBorder
  22096. if (this.keyPressed) {
  22097. if (masterVertical !== window && target !== window && !event.target.contains(masterVertical) || masterHorizontal !== window && target !== window && !event.target.contains(masterHorizontal)) {
  22098. return;
  22099. }
  22100. }
  22101. if (event.type === 'scroll') {
  22102. this.syncScrollPositions(event);
  22103. } else {
  22104. this.translateMouseWheelToScroll(event);
  22105. }
  22106. }
  22107. /**
  22108. * Key down listener
  22109. */
  22110. }, {
  22111. key: 'onKeyDown',
  22112. value: function onKeyDown(event) {
  22113. this.keyPressed = (0, _unicode.isKey)(event.keyCode, 'ARROW_UP|ARROW_RIGHT|ARROW_DOWN|ARROW_LEFT');
  22114. }
  22115. /**
  22116. * Key up listener
  22117. */
  22118. }, {
  22119. key: 'onKeyUp',
  22120. value: function onKeyUp() {
  22121. this.keyPressed = false;
  22122. }
  22123. /**
  22124. * Translate wheel event into scroll event and sync scroll overlays position
  22125. *
  22126. * @private
  22127. * @param {Event} event
  22128. * @returns {Boolean}
  22129. */
  22130. }, {
  22131. key: 'translateMouseWheelToScroll',
  22132. value: function translateMouseWheelToScroll(event) {
  22133. var topOverlay = this.topOverlay.clone.wtTable.holder;
  22134. var bottomOverlay = this.bottomOverlay.clone ? this.bottomOverlay.clone.wtTable.holder : null;
  22135. var leftOverlay = this.leftOverlay.clone.wtTable.holder;
  22136. var topLeftCornerOverlay = this.topLeftCornerOverlay && this.topLeftCornerOverlay.clone ? this.topLeftCornerOverlay.clone.wtTable.holder : null;
  22137. var bottomLeftCornerOverlay = this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone ? this.bottomLeftCornerOverlay.clone.wtTable.holder : null;
  22138. var mouseWheelSpeedRatio = -0.2;
  22139. var deltaY = event.wheelDeltaY || -1 * event.deltaY;
  22140. var deltaX = event.wheelDeltaX || -1 * event.deltaX;
  22141. var parentHolder = null;
  22142. var eventMockup = { type: 'wheel' };
  22143. var tempElem = event.target;
  22144. var delta = null;
  22145. // Fix for extremely slow header scrolling with a mousewheel on Firefox
  22146. if (event.deltaMode === 1) {
  22147. deltaY *= 120;
  22148. deltaX *= 120;
  22149. }
  22150. while (tempElem != document && tempElem != null) {
  22151. if (tempElem.className.indexOf('wtHolder') > -1) {
  22152. parentHolder = tempElem;
  22153. break;
  22154. }
  22155. tempElem = tempElem.parentNode;
  22156. }
  22157. eventMockup.target = parentHolder;
  22158. if (parentHolder === topLeftCornerOverlay || parentHolder === bottomLeftCornerOverlay) {
  22159. this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * deltaX, 'x');
  22160. this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * deltaY, 'y');
  22161. } else {
  22162. if (parentHolder === topOverlay || parentHolder === bottomOverlay) {
  22163. delta = deltaY;
  22164. } else if (parentHolder === leftOverlay) {
  22165. delta = deltaX;
  22166. }
  22167. this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * delta);
  22168. }
  22169. return false;
  22170. }
  22171. /**
  22172. * Synchronize scroll position between master table and overlay table.
  22173. *
  22174. * @private
  22175. * @param {Event|Object} event
  22176. * @param {Number} [fakeScrollValue=null]
  22177. * @param {String} [fakeScrollDirection=null] `x` or `y`.
  22178. */
  22179. }, {
  22180. key: 'syncScrollPositions',
  22181. value: function syncScrollPositions(event) {
  22182. var fakeScrollValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  22183. var fakeScrollDirection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  22184. if (this.destroyed) {
  22185. return;
  22186. }
  22187. if (arguments.length === 0) {
  22188. this.syncScrollWithMaster();
  22189. return;
  22190. }
  22191. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  22192. var masterVertical = this.topOverlay.mainTableScrollableElement;
  22193. var target = event.target;
  22194. var tempScrollValue = 0;
  22195. var scrollValueChanged = false;
  22196. var topOverlay = void 0;
  22197. var leftOverlay = void 0;
  22198. var topLeftCornerOverlay = void 0;
  22199. var bottomLeftCornerOverlay = void 0;
  22200. var bottomOverlay = void 0;
  22201. var delegatedScroll = false;
  22202. var preventOverflow = this.wot.getSetting('preventOverflow');
  22203. if (this.topOverlay.needFullRender) {
  22204. topOverlay = this.topOverlay.clone.wtTable.holder;
  22205. }
  22206. if (this.bottomOverlay.needFullRender) {
  22207. bottomOverlay = this.bottomOverlay.clone.wtTable.holder;
  22208. }
  22209. if (this.leftOverlay.needFullRender) {
  22210. leftOverlay = this.leftOverlay.clone.wtTable.holder;
  22211. }
  22212. if (this.leftOverlay.needFullRender && this.topOverlay.needFullRender) {
  22213. topLeftCornerOverlay = this.topLeftCornerOverlay.clone.wtTable.holder;
  22214. }
  22215. if (this.leftOverlay.needFullRender && this.bottomOverlay.needFullRender) {
  22216. bottomLeftCornerOverlay = this.bottomLeftCornerOverlay.clone.wtTable.holder;
  22217. }
  22218. if (target === document) {
  22219. target = window;
  22220. }
  22221. if (target === masterHorizontal || target === masterVertical) {
  22222. if (preventOverflow) {
  22223. tempScrollValue = (0, _element.getScrollLeft)(this.scrollableElement);
  22224. } else {
  22225. tempScrollValue = (0, _element.getScrollLeft)(target);
  22226. }
  22227. // if scrolling the master table - populate the scroll values to both top and left overlays
  22228. this.horizontalScrolling = true;
  22229. this.overlayScrollPositions.master.left = tempScrollValue;
  22230. scrollValueChanged = true;
  22231. if (this.pendingScrollCallbacks.master.left > 0) {
  22232. this.pendingScrollCallbacks.master.left--;
  22233. } else {
  22234. if (topOverlay && topOverlay.scrollLeft !== tempScrollValue) {
  22235. if (fakeScrollValue == null) {
  22236. this.pendingScrollCallbacks.top.left++;
  22237. }
  22238. topOverlay.scrollLeft = tempScrollValue;
  22239. delegatedScroll = masterHorizontal !== window;
  22240. }
  22241. if (bottomOverlay && bottomOverlay.scrollLeft !== tempScrollValue) {
  22242. if (fakeScrollValue == null) {
  22243. this.pendingScrollCallbacks.bottom.left++;
  22244. }
  22245. bottomOverlay.scrollLeft = tempScrollValue;
  22246. delegatedScroll = masterHorizontal !== window;
  22247. }
  22248. }
  22249. tempScrollValue = (0, _element.getScrollTop)(target);
  22250. this.verticalScrolling = true;
  22251. this.overlayScrollPositions.master.top = tempScrollValue;
  22252. scrollValueChanged = true;
  22253. if (this.pendingScrollCallbacks.master.top > 0) {
  22254. this.pendingScrollCallbacks.master.top--;
  22255. } else if (leftOverlay && leftOverlay.scrollTop !== tempScrollValue) {
  22256. if (fakeScrollValue == null) {
  22257. this.pendingScrollCallbacks.left.top++;
  22258. }
  22259. leftOverlay.scrollTop = tempScrollValue;
  22260. delegatedScroll = masterVertical !== window;
  22261. }
  22262. } else if (target === bottomOverlay) {
  22263. tempScrollValue = (0, _element.getScrollLeft)(target);
  22264. // if scrolling the bottom overlay - populate the horizontal scroll to the master table
  22265. this.horizontalScrolling = true;
  22266. this.overlayScrollPositions.bottom.left = tempScrollValue;
  22267. scrollValueChanged = true;
  22268. if (this.pendingScrollCallbacks.bottom.left > 0) {
  22269. this.pendingScrollCallbacks.bottom.left--;
  22270. } else {
  22271. if (fakeScrollValue == null) {
  22272. this.pendingScrollCallbacks.master.left++;
  22273. }
  22274. masterHorizontal.scrollLeft = tempScrollValue;
  22275. if (topOverlay && topOverlay.scrollLeft !== tempScrollValue) {
  22276. if (fakeScrollValue == null) {
  22277. this.pendingScrollCallbacks.top.left++;
  22278. }
  22279. topOverlay.scrollLeft = tempScrollValue;
  22280. delegatedScroll = masterVertical !== window;
  22281. }
  22282. }
  22283. // "fake" scroll value calculated from the mousewheel event
  22284. if (fakeScrollValue !== null) {
  22285. scrollValueChanged = true;
  22286. masterVertical.scrollTop += fakeScrollValue;
  22287. }
  22288. } else if (target === topOverlay) {
  22289. tempScrollValue = (0, _element.getScrollLeft)(target);
  22290. // if scrolling the top overlay - populate the horizontal scroll to the master table
  22291. this.horizontalScrolling = true;
  22292. this.overlayScrollPositions.top.left = tempScrollValue;
  22293. scrollValueChanged = true;
  22294. if (this.pendingScrollCallbacks.top.left > 0) {
  22295. this.pendingScrollCallbacks.top.left--;
  22296. } else {
  22297. if (fakeScrollValue == null) {
  22298. this.pendingScrollCallbacks.master.left++;
  22299. }
  22300. masterHorizontal.scrollLeft = tempScrollValue;
  22301. }
  22302. // "fake" scroll value calculated from the mousewheel event
  22303. if (fakeScrollValue !== null) {
  22304. scrollValueChanged = true;
  22305. masterVertical.scrollTop += fakeScrollValue;
  22306. }
  22307. if (bottomOverlay && bottomOverlay.scrollLeft !== tempScrollValue) {
  22308. if (fakeScrollValue == null) {
  22309. this.pendingScrollCallbacks.bottom.left++;
  22310. }
  22311. bottomOverlay.scrollLeft = tempScrollValue;
  22312. delegatedScroll = masterVertical !== window;
  22313. }
  22314. } else if (target === leftOverlay) {
  22315. tempScrollValue = (0, _element.getScrollTop)(target);
  22316. // if scrolling the left overlay - populate the vertical scroll to the master table
  22317. if (this.overlayScrollPositions.left.top !== tempScrollValue) {
  22318. this.verticalScrolling = true;
  22319. this.overlayScrollPositions.left.top = tempScrollValue;
  22320. scrollValueChanged = true;
  22321. if (this.pendingScrollCallbacks.left.top > 0) {
  22322. this.pendingScrollCallbacks.left.top--;
  22323. } else {
  22324. if (fakeScrollValue == null) {
  22325. this.pendingScrollCallbacks.master.top++;
  22326. }
  22327. masterVertical.scrollTop = tempScrollValue;
  22328. }
  22329. }
  22330. // "fake" scroll value calculated from the mousewheel event
  22331. if (fakeScrollValue !== null) {
  22332. scrollValueChanged = true;
  22333. masterVertical.scrollLeft += fakeScrollValue;
  22334. }
  22335. } else if (target === topLeftCornerOverlay || target === bottomLeftCornerOverlay) {
  22336. if (fakeScrollValue !== null) {
  22337. scrollValueChanged = true;
  22338. if (fakeScrollDirection === 'x') {
  22339. masterVertical.scrollLeft += fakeScrollValue;
  22340. } else if (fakeScrollDirection === 'y') {
  22341. masterVertical.scrollTop += fakeScrollValue;
  22342. }
  22343. }
  22344. }
  22345. if (!this.keyPressed && scrollValueChanged && event.type === 'scroll') {
  22346. if (this.delegatedScrollCallback) {
  22347. this.delegatedScrollCallback = false;
  22348. } else {
  22349. this.refreshAll();
  22350. }
  22351. if (delegatedScroll) {
  22352. this.delegatedScrollCallback = true;
  22353. }
  22354. }
  22355. }
  22356. /**
  22357. * Synchronize overlay scrollbars with the master scrollbar
  22358. */
  22359. }, {
  22360. key: 'syncScrollWithMaster',
  22361. value: function syncScrollWithMaster() {
  22362. var master = this.topOverlay.mainTableScrollableElement;
  22363. var scrollLeft = master.scrollLeft,
  22364. scrollTop = master.scrollTop;
  22365. if (this.topOverlay.needFullRender) {
  22366. this.topOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  22367. }
  22368. if (this.bottomOverlay.needFullRender) {
  22369. this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  22370. }
  22371. if (this.leftOverlay.needFullRender) {
  22372. this.leftOverlay.clone.wtTable.holder.scrollTop = scrollTop;
  22373. }
  22374. }
  22375. /**
  22376. * Update the main scrollable elements for all the overlays.
  22377. */
  22378. }, {
  22379. key: 'updateMainScrollableElements',
  22380. value: function updateMainScrollableElements() {
  22381. this.deregisterListeners();
  22382. this.leftOverlay.updateMainScrollableElement();
  22383. this.topOverlay.updateMainScrollableElement();
  22384. if (this.bottomOverlay.needFullRender) {
  22385. this.bottomOverlay.updateMainScrollableElement();
  22386. }
  22387. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  22388. this.registerListeners();
  22389. }
  22390. /**
  22391. *
  22392. */
  22393. }, {
  22394. key: 'destroy',
  22395. value: function destroy() {
  22396. this.eventManager.destroy();
  22397. this.topOverlay.destroy();
  22398. if (this.bottomOverlay.clone) {
  22399. this.bottomOverlay.destroy();
  22400. }
  22401. this.leftOverlay.destroy();
  22402. if (this.topLeftCornerOverlay) {
  22403. this.topLeftCornerOverlay.destroy();
  22404. }
  22405. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  22406. this.bottomLeftCornerOverlay.destroy();
  22407. }
  22408. if (this.debug) {
  22409. this.debug.destroy();
  22410. }
  22411. this.destroyed = true;
  22412. }
  22413. /**
  22414. * @param {Boolean} [fastDraw=false]
  22415. */
  22416. }, {
  22417. key: 'refresh',
  22418. value: function refresh() {
  22419. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  22420. if (this.topOverlay.areElementSizesAdjusted && this.leftOverlay.areElementSizesAdjusted) {
  22421. var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement;
  22422. var width = container.clientWidth;
  22423. var height = container.clientHeight;
  22424. if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) {
  22425. this.spreaderLastSize.width = width;
  22426. this.spreaderLastSize.height = height;
  22427. this.adjustElementsSize();
  22428. }
  22429. }
  22430. if (this.bottomOverlay.clone) {
  22431. this.bottomOverlay.refresh(fastDraw);
  22432. }
  22433. this.leftOverlay.refresh(fastDraw);
  22434. this.topOverlay.refresh(fastDraw);
  22435. if (this.topLeftCornerOverlay) {
  22436. this.topLeftCornerOverlay.refresh(fastDraw);
  22437. }
  22438. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  22439. this.bottomLeftCornerOverlay.refresh(fastDraw);
  22440. }
  22441. if (this.debug) {
  22442. this.debug.refresh(fastDraw);
  22443. }
  22444. }
  22445. /**
  22446. * Adjust overlays elements size and master table size
  22447. *
  22448. * @param {Boolean} [force=false]
  22449. */
  22450. }, {
  22451. key: 'adjustElementsSize',
  22452. value: function adjustElementsSize() {
  22453. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  22454. var totalColumns = this.wot.getSetting('totalColumns');
  22455. var totalRows = this.wot.getSetting('totalRows');
  22456. var headerRowSize = this.wot.wtViewport.getRowHeaderWidth();
  22457. var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight();
  22458. var hiderStyle = this.wot.wtTable.hider.style;
  22459. hiderStyle.width = headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns) + 'px';
  22460. hiderStyle.height = headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1 + 'px';
  22461. this.topOverlay.adjustElementsSize(force);
  22462. this.leftOverlay.adjustElementsSize(force);
  22463. if (this.bottomOverlay.clone) {
  22464. this.bottomOverlay.adjustElementsSize(force);
  22465. }
  22466. }
  22467. /**
  22468. *
  22469. */
  22470. }, {
  22471. key: 'applyToDOM',
  22472. value: function applyToDOM() {
  22473. if (!this.topOverlay.areElementSizesAdjusted || !this.leftOverlay.areElementSizesAdjusted) {
  22474. this.adjustElementsSize();
  22475. }
  22476. this.topOverlay.applyToDOM();
  22477. if (this.bottomOverlay.clone) {
  22478. this.bottomOverlay.applyToDOM();
  22479. }
  22480. this.leftOverlay.applyToDOM();
  22481. }
  22482. /**
  22483. * Get the parent overlay of the provided element.
  22484. *
  22485. * @param {HTMLElement} element
  22486. * @returns {Object|null}
  22487. */
  22488. }, {
  22489. key: 'getParentOverlay',
  22490. value: function getParentOverlay(element) {
  22491. if (!element) {
  22492. return null;
  22493. }
  22494. var overlays = [this.topOverlay, this.leftOverlay, this.bottomOverlay, this.topLeftCornerOverlay, this.bottomLeftCornerOverlay];
  22495. var result = null;
  22496. (0, _array.arrayEach)(overlays, function (elem, i) {
  22497. if (!elem) {
  22498. return;
  22499. }
  22500. if (elem.clone && elem.clone.wtTable.TABLE.contains(element)) {
  22501. result = elem.clone;
  22502. }
  22503. });
  22504. return result;
  22505. }
  22506. }]);
  22507. return Overlays;
  22508. }();
  22509. exports.default = Overlays;
  22510. /***/ }),
  22511. /* 258 */
  22512. /***/ (function(module, exports, __webpack_require__) {
  22513. "use strict";
  22514. exports.__esModule = true;
  22515. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  22516. var _element = __webpack_require__(0);
  22517. var _number = __webpack_require__(6);
  22518. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22519. /**
  22520. * @class Scroll
  22521. */
  22522. var Scroll = function () {
  22523. /**
  22524. * @param {Walkontable} wotInstance
  22525. */
  22526. function Scroll(wotInstance) {
  22527. _classCallCheck(this, Scroll);
  22528. this.wot = wotInstance;
  22529. // legacy support
  22530. this.instance = wotInstance;
  22531. }
  22532. /**
  22533. * Scrolls viewport to a cell by minimum number of cells
  22534. *
  22535. * @param {CellCoords} coords
  22536. */
  22537. _createClass(Scroll, [{
  22538. key: 'scrollViewport',
  22539. value: function scrollViewport(coords) {
  22540. if (!this.wot.drawn) {
  22541. return;
  22542. }
  22543. var _getVariables2 = this._getVariables(),
  22544. topOverlay = _getVariables2.topOverlay,
  22545. leftOverlay = _getVariables2.leftOverlay,
  22546. totalRows = _getVariables2.totalRows,
  22547. totalColumns = _getVariables2.totalColumns,
  22548. fixedRowsTop = _getVariables2.fixedRowsTop,
  22549. fixedRowsBottom = _getVariables2.fixedRowsBottom,
  22550. fixedColumnsLeft = _getVariables2.fixedColumnsLeft;
  22551. if (coords.row < 0 || coords.row > Math.max(totalRows - 1, 0)) {
  22552. throw new Error('row ' + coords.row + ' does not exist');
  22553. }
  22554. if (coords.col < 0 || coords.col > Math.max(totalColumns - 1, 0)) {
  22555. throw new Error('column ' + coords.col + ' does not exist');
  22556. }
  22557. if (coords.row >= fixedRowsTop && coords.row < this.getFirstVisibleRow()) {
  22558. topOverlay.scrollTo(coords.row);
  22559. } else if (coords.row > this.getLastVisibleRow() && coords.row < totalRows - fixedRowsBottom) {
  22560. topOverlay.scrollTo(coords.row, true);
  22561. }
  22562. if (coords.col >= fixedColumnsLeft && coords.col < this.getFirstVisibleColumn()) {
  22563. leftOverlay.scrollTo(coords.col);
  22564. } else if (coords.col > this.getLastVisibleColumn()) {
  22565. leftOverlay.scrollTo(coords.col, true);
  22566. }
  22567. }
  22568. /**
  22569. * Get first visible row based on virtual dom and how table is visible in browser window viewport.
  22570. *
  22571. * @returns {Number}
  22572. */
  22573. }, {
  22574. key: 'getFirstVisibleRow',
  22575. value: function getFirstVisibleRow() {
  22576. var _getVariables3 = this._getVariables(),
  22577. topOverlay = _getVariables3.topOverlay,
  22578. wtTable = _getVariables3.wtTable,
  22579. wtViewport = _getVariables3.wtViewport,
  22580. totalRows = _getVariables3.totalRows,
  22581. fixedRowsTop = _getVariables3.fixedRowsTop;
  22582. var firstVisibleRow = wtTable.getFirstVisibleRow();
  22583. if (topOverlay.mainTableScrollableElement === window) {
  22584. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  22585. var totalTableHeight = (0, _element.innerHeight)(wtTable.hider);
  22586. var windowHeight = (0, _element.innerHeight)(window);
  22587. var windowScrollTop = (0, _element.getScrollTop)(window);
  22588. // Only calculate firstVisibleRow when table didn't filled (from up) whole viewport space
  22589. if (rootElementOffset.top + totalTableHeight - windowHeight <= windowScrollTop) {
  22590. var rowsHeight = wtViewport.getColumnHeaderHeight();
  22591. rowsHeight += topOverlay.sumCellSizes(0, fixedRowsTop);
  22592. (0, _number.rangeEachReverse)(totalRows, 1, function (row) {
  22593. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  22594. if (rootElementOffset.top + totalTableHeight - rowsHeight <= windowScrollTop) {
  22595. // Return physical row + 1
  22596. firstVisibleRow = row;
  22597. return false;
  22598. }
  22599. });
  22600. }
  22601. }
  22602. return firstVisibleRow;
  22603. }
  22604. /**
  22605. * Get last visible row based on virtual dom and how table is visible in browser window viewport.
  22606. *
  22607. * @returns {Number}
  22608. */
  22609. }, {
  22610. key: 'getLastVisibleRow',
  22611. value: function getLastVisibleRow() {
  22612. var _getVariables4 = this._getVariables(),
  22613. topOverlay = _getVariables4.topOverlay,
  22614. wtTable = _getVariables4.wtTable,
  22615. wtViewport = _getVariables4.wtViewport,
  22616. totalRows = _getVariables4.totalRows;
  22617. var lastVisibleRow = wtTable.getLastVisibleRow();
  22618. if (topOverlay.mainTableScrollableElement === window) {
  22619. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  22620. var windowHeight = (0, _element.innerHeight)(window);
  22621. var windowScrollTop = (0, _element.getScrollTop)(window);
  22622. // Only calculate lastVisibleRow when table didn't filled (from bottom) whole viewport space
  22623. if (rootElementOffset.top > windowScrollTop) {
  22624. var rowsHeight = wtViewport.getColumnHeaderHeight();
  22625. (0, _number.rangeEach)(1, totalRows, function (row) {
  22626. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  22627. if (rootElementOffset.top + rowsHeight - windowScrollTop >= windowHeight) {
  22628. // Return physical row - 1 (-2 because rangeEach gives row index + 1 - sumCellSizes requirements)
  22629. lastVisibleRow = row - 2;
  22630. return false;
  22631. }
  22632. });
  22633. }
  22634. }
  22635. return lastVisibleRow;
  22636. }
  22637. /**
  22638. * Get first visible column based on virtual dom and how table is visible in browser window viewport.
  22639. *
  22640. * @returns {Number}
  22641. */
  22642. }, {
  22643. key: 'getFirstVisibleColumn',
  22644. value: function getFirstVisibleColumn() {
  22645. var _getVariables5 = this._getVariables(),
  22646. leftOverlay = _getVariables5.leftOverlay,
  22647. wtTable = _getVariables5.wtTable,
  22648. wtViewport = _getVariables5.wtViewport,
  22649. totalColumns = _getVariables5.totalColumns,
  22650. fixedColumnsLeft = _getVariables5.fixedColumnsLeft;
  22651. var firstVisibleColumn = wtTable.getFirstVisibleColumn();
  22652. if (leftOverlay.mainTableScrollableElement === window) {
  22653. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  22654. var totalTableWidth = (0, _element.innerWidth)(wtTable.hider);
  22655. var windowWidth = (0, _element.innerWidth)(window);
  22656. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  22657. // Only calculate firstVisibleColumn when table didn't filled (from left) whole viewport space
  22658. if (rootElementOffset.left + totalTableWidth - windowWidth <= windowScrollLeft) {
  22659. var columnsWidth = wtViewport.getRowHeaderWidth();
  22660. (0, _number.rangeEachReverse)(totalColumns, 1, function (column) {
  22661. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  22662. if (rootElementOffset.left + totalTableWidth - columnsWidth <= windowScrollLeft) {
  22663. // Return physical column + 1
  22664. firstVisibleColumn = column;
  22665. return false;
  22666. }
  22667. });
  22668. }
  22669. }
  22670. return firstVisibleColumn;
  22671. }
  22672. /**
  22673. * Get last visible column based on virtual dom and how table is visible in browser window viewport.
  22674. *
  22675. * @returns {Number}
  22676. */
  22677. }, {
  22678. key: 'getLastVisibleColumn',
  22679. value: function getLastVisibleColumn() {
  22680. var _getVariables6 = this._getVariables(),
  22681. leftOverlay = _getVariables6.leftOverlay,
  22682. wtTable = _getVariables6.wtTable,
  22683. wtViewport = _getVariables6.wtViewport,
  22684. totalColumns = _getVariables6.totalColumns;
  22685. var lastVisibleColumn = wtTable.getLastVisibleColumn();
  22686. if (leftOverlay.mainTableScrollableElement === window) {
  22687. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  22688. var windowWidth = (0, _element.innerWidth)(window);
  22689. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  22690. // Only calculate lastVisibleColumn when table didn't filled (from right) whole viewport space
  22691. if (rootElementOffset.left > windowScrollLeft) {
  22692. var columnsWidth = wtViewport.getRowHeaderWidth();
  22693. (0, _number.rangeEach)(1, totalColumns, function (column) {
  22694. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  22695. if (rootElementOffset.left + columnsWidth - windowScrollLeft >= windowWidth) {
  22696. // Return physical column - 1 (-2 because rangeEach gives column index + 1 - sumCellSizes requirements)
  22697. lastVisibleColumn = column - 2;
  22698. return false;
  22699. }
  22700. });
  22701. }
  22702. }
  22703. return lastVisibleColumn;
  22704. }
  22705. /**
  22706. * Returns collection of variables used to rows and columns visibility calculations.
  22707. *
  22708. * @returns {Object}
  22709. * @private
  22710. */
  22711. }, {
  22712. key: '_getVariables',
  22713. value: function _getVariables() {
  22714. var wot = this.wot;
  22715. var topOverlay = wot.wtOverlays.topOverlay;
  22716. var leftOverlay = wot.wtOverlays.leftOverlay;
  22717. var wtTable = wot.wtTable;
  22718. var wtViewport = wot.wtViewport;
  22719. var totalRows = wot.getSetting('totalRows');
  22720. var totalColumns = wot.getSetting('totalColumns');
  22721. var fixedRowsTop = wot.getSetting('fixedRowsTop');
  22722. var fixedRowsBottom = wot.getSetting('fixedRowsBottom');
  22723. var fixedColumnsLeft = wot.getSetting('fixedColumnsLeft');
  22724. return {
  22725. topOverlay: topOverlay,
  22726. leftOverlay: leftOverlay,
  22727. wtTable: wtTable,
  22728. wtViewport: wtViewport,
  22729. totalRows: totalRows,
  22730. totalColumns: totalColumns,
  22731. fixedRowsTop: fixedRowsTop,
  22732. fixedRowsBottom: fixedRowsBottom,
  22733. fixedColumnsLeft: fixedColumnsLeft
  22734. };
  22735. }
  22736. }]);
  22737. return Scroll;
  22738. }();
  22739. exports.default = Scroll;
  22740. /***/ }),
  22741. /* 259 */
  22742. /***/ (function(module, exports, __webpack_require__) {
  22743. "use strict";
  22744. exports.__esModule = true;
  22745. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  22746. var _element = __webpack_require__(0);
  22747. var _object = __webpack_require__(1);
  22748. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22749. /**
  22750. * @class Settings
  22751. */
  22752. var Settings = function () {
  22753. /**
  22754. * @param {Walkontable} wotInstance
  22755. * @param {Object} settings
  22756. */
  22757. function Settings(wotInstance, settings) {
  22758. var _this = this;
  22759. _classCallCheck(this, Settings);
  22760. this.wot = wotInstance;
  22761. // legacy support
  22762. this.instance = wotInstance;
  22763. // default settings. void 0 means it is required, null means it can be empty
  22764. this.defaults = {
  22765. table: void 0,
  22766. debug: false, // shows WalkontableDebugOverlay
  22767. // presentation mode
  22768. externalRowCalculator: false,
  22769. stretchH: 'none', // values: all, last, none
  22770. currentRowClassName: null,
  22771. currentColumnClassName: null,
  22772. preventOverflow: function preventOverflow() {
  22773. return false;
  22774. },
  22775. // data source
  22776. data: void 0,
  22777. freezeOverlays: false,
  22778. fixedColumnsLeft: 0,
  22779. fixedRowsTop: 0,
  22780. fixedRowsBottom: 0,
  22781. minSpareRows: 0,
  22782. // this must be array of functions: [function (row, TH) {}]
  22783. rowHeaders: function rowHeaders() {
  22784. return [];
  22785. },
  22786. // this must be array of functions: [function (column, TH) {}]
  22787. columnHeaders: function columnHeaders() {
  22788. return [];
  22789. },
  22790. totalRows: void 0,
  22791. totalColumns: void 0,
  22792. cellRenderer: function cellRenderer(row, column, TD) {
  22793. var cellData = _this.getSetting('data', row, column);
  22794. (0, _element.fastInnerText)(TD, cellData === void 0 || cellData === null ? '' : cellData);
  22795. },
  22796. // columnWidth: 50,
  22797. columnWidth: function columnWidth(col) {
  22798. // return undefined means use default size for the rendered cell content
  22799. },
  22800. rowHeight: function rowHeight(row) {
  22801. // return undefined means use default size for the rendered cell content
  22802. },
  22803. defaultRowHeight: 23,
  22804. defaultColumnWidth: 50,
  22805. selections: null,
  22806. hideBorderOnMouseDownOver: false,
  22807. viewportRowCalculatorOverride: null,
  22808. viewportColumnCalculatorOverride: null,
  22809. // callbacks
  22810. onCellMouseDown: null,
  22811. onCellMouseOver: null,
  22812. onCellMouseOut: null,
  22813. onCellMouseUp: null,
  22814. // onCellMouseOut: null,
  22815. onCellDblClick: null,
  22816. onCellCornerMouseDown: null,
  22817. onCellCornerDblClick: null,
  22818. beforeDraw: null,
  22819. onDraw: null,
  22820. onBeforeDrawBorders: null,
  22821. onScrollVertically: null,
  22822. onScrollHorizontally: null,
  22823. onBeforeTouchScroll: null,
  22824. onAfterMomentumScroll: null,
  22825. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(width) {
  22826. return width;
  22827. },
  22828. onModifyRowHeaderWidth: null,
  22829. // constants
  22830. scrollbarWidth: 10,
  22831. scrollbarHeight: 10,
  22832. renderAllRows: false,
  22833. groups: false,
  22834. rowHeaderWidth: null,
  22835. columnHeaderHeight: null,
  22836. headerClassName: null
  22837. };
  22838. // reference to settings
  22839. this.settings = {};
  22840. for (var i in this.defaults) {
  22841. if ((0, _object.hasOwnProperty)(this.defaults, i)) {
  22842. if (settings[i] !== void 0) {
  22843. this.settings[i] = settings[i];
  22844. } else if (this.defaults[i] === void 0) {
  22845. throw new Error('A required setting "' + i + '" was not provided');
  22846. } else {
  22847. this.settings[i] = this.defaults[i];
  22848. }
  22849. }
  22850. }
  22851. }
  22852. /**
  22853. * Update settings
  22854. *
  22855. * @param {Object} settings
  22856. * @param {*} value
  22857. * @returns {Walkontable}
  22858. */
  22859. _createClass(Settings, [{
  22860. key: 'update',
  22861. value: function update(settings, value) {
  22862. if (value === void 0) {
  22863. // settings is object
  22864. for (var i in settings) {
  22865. if ((0, _object.hasOwnProperty)(settings, i)) {
  22866. this.settings[i] = settings[i];
  22867. }
  22868. }
  22869. } else {
  22870. // if value is defined then settings is the key
  22871. this.settings[settings] = value;
  22872. }
  22873. return this.wot;
  22874. }
  22875. /**
  22876. * Get setting by name
  22877. *
  22878. * @param {String} key
  22879. * @param {*} param1
  22880. * @param {*} param2
  22881. * @param {*} param3
  22882. * @param {*} param4
  22883. * @returns {*}
  22884. */
  22885. }, {
  22886. key: 'getSetting',
  22887. value: function getSetting(key, param1, param2, param3, param4) {
  22888. if (typeof this.settings[key] === 'function') {
  22889. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  22890. return this.settings[key](param1, param2, param3, param4);
  22891. } else if (param1 !== void 0 && Array.isArray(this.settings[key])) {
  22892. // perhaps this can be removed, it is only used in tests
  22893. return this.settings[key][param1];
  22894. }
  22895. return this.settings[key];
  22896. }
  22897. /**
  22898. * Checks if setting exists
  22899. *
  22900. * @param {Boolean} key
  22901. * @returns {Boolean}
  22902. */
  22903. }, {
  22904. key: 'has',
  22905. value: function has(key) {
  22906. return !!this.settings[key];
  22907. }
  22908. }]);
  22909. return Settings;
  22910. }();
  22911. exports.default = Settings;
  22912. /***/ }),
  22913. /* 260 */
  22914. /***/ (function(module, exports, __webpack_require__) {
  22915. "use strict";
  22916. exports.__esModule = true;
  22917. var _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; };
  22918. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  22919. var _element = __webpack_require__(0);
  22920. var _function = __webpack_require__(35);
  22921. var _coords = __webpack_require__(43);
  22922. var _coords2 = _interopRequireDefault(_coords);
  22923. var _range = __webpack_require__(69);
  22924. var _range2 = _interopRequireDefault(_range);
  22925. var _column = __webpack_require__(255);
  22926. var _column2 = _interopRequireDefault(_column);
  22927. var _row = __webpack_require__(256);
  22928. var _row2 = _interopRequireDefault(_row);
  22929. var _tableRenderer = __webpack_require__(261);
  22930. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  22931. var _base = __webpack_require__(28);
  22932. var _base2 = _interopRequireDefault(_base);
  22933. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22934. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  22935. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22936. /**
  22937. *
  22938. */
  22939. var Table = function () {
  22940. /**
  22941. * @param {Walkontable} wotInstance
  22942. * @param {HTMLTableElement} table
  22943. */
  22944. function Table(wotInstance, table) {
  22945. var _this = this;
  22946. _classCallCheck(this, Table);
  22947. this.wot = wotInstance;
  22948. // legacy support
  22949. this.instance = this.wot;
  22950. this.TABLE = table;
  22951. this.TBODY = null;
  22952. this.THEAD = null;
  22953. this.COLGROUP = null;
  22954. this.tableOffset = 0;
  22955. this.holderOffset = 0;
  22956. (0, _element.removeTextNodes)(this.TABLE);
  22957. this.spreader = this.createSpreader(this.TABLE);
  22958. this.hider = this.createHider(this.spreader);
  22959. this.holder = this.createHolder(this.hider);
  22960. this.wtRootElement = this.holder.parentNode;
  22961. this.alignOverlaysWithTrimmingContainer();
  22962. this.fixTableDomTree();
  22963. this.colgroupChildrenLength = this.COLGROUP.childNodes.length;
  22964. this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0;
  22965. this.tbodyChildrenLength = this.TBODY.childNodes.length;
  22966. this.rowFilter = null;
  22967. this.columnFilter = null;
  22968. this.correctHeaderWidth = false;
  22969. var origRowHeaderWidth = this.wot.wtSettings.settings.rowHeaderWidth;
  22970. // Fix for jumping row headers (https://github.com/handsontable/handsontable/issues/3850)
  22971. this.wot.wtSettings.settings.rowHeaderWidth = function () {
  22972. return _this._modifyRowHeaderWidth(origRowHeaderWidth);
  22973. };
  22974. }
  22975. /**
  22976. *
  22977. */
  22978. _createClass(Table, [{
  22979. key: 'fixTableDomTree',
  22980. value: function fixTableDomTree() {
  22981. this.TBODY = this.TABLE.querySelector('tbody');
  22982. if (!this.TBODY) {
  22983. this.TBODY = document.createElement('tbody');
  22984. this.TABLE.appendChild(this.TBODY);
  22985. }
  22986. this.THEAD = this.TABLE.querySelector('thead');
  22987. if (!this.THEAD) {
  22988. this.THEAD = document.createElement('thead');
  22989. this.TABLE.insertBefore(this.THEAD, this.TBODY);
  22990. }
  22991. this.COLGROUP = this.TABLE.querySelector('colgroup');
  22992. if (!this.COLGROUP) {
  22993. this.COLGROUP = document.createElement('colgroup');
  22994. this.TABLE.insertBefore(this.COLGROUP, this.THEAD);
  22995. }
  22996. if (this.wot.getSetting('columnHeaders').length && !this.THEAD.childNodes.length) {
  22997. this.THEAD.appendChild(document.createElement('TR'));
  22998. }
  22999. }
  23000. /**
  23001. * @param table
  23002. * @returns {HTMLElement}
  23003. */
  23004. }, {
  23005. key: 'createSpreader',
  23006. value: function createSpreader(table) {
  23007. var parent = table.parentNode;
  23008. var spreader = void 0;
  23009. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  23010. spreader = document.createElement('div');
  23011. spreader.className = 'wtSpreader';
  23012. if (parent) {
  23013. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  23014. parent.insertBefore(spreader, table);
  23015. }
  23016. spreader.appendChild(table);
  23017. }
  23018. spreader.style.position = 'relative';
  23019. return spreader;
  23020. }
  23021. /**
  23022. * @param spreader
  23023. * @returns {HTMLElement}
  23024. */
  23025. }, {
  23026. key: 'createHider',
  23027. value: function createHider(spreader) {
  23028. var parent = spreader.parentNode;
  23029. var hider = void 0;
  23030. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  23031. hider = document.createElement('div');
  23032. hider.className = 'wtHider';
  23033. if (parent) {
  23034. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  23035. parent.insertBefore(hider, spreader);
  23036. }
  23037. hider.appendChild(spreader);
  23038. }
  23039. return hider;
  23040. }
  23041. /**
  23042. *
  23043. * @param hider
  23044. * @returns {HTMLElement}
  23045. */
  23046. }, {
  23047. key: 'createHolder',
  23048. value: function createHolder(hider) {
  23049. var parent = hider.parentNode;
  23050. var holder = void 0;
  23051. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  23052. holder = document.createElement('div');
  23053. holder.style.position = 'relative';
  23054. holder.className = 'wtHolder';
  23055. if (parent) {
  23056. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  23057. parent.insertBefore(holder, hider);
  23058. }
  23059. if (!this.isWorkingOnClone()) {
  23060. holder.parentNode.className += 'ht_master handsontable';
  23061. }
  23062. holder.appendChild(hider);
  23063. }
  23064. return holder;
  23065. }
  23066. }, {
  23067. key: 'alignOverlaysWithTrimmingContainer',
  23068. value: function alignOverlaysWithTrimmingContainer() {
  23069. var trimmingElement = (0, _element.getTrimmingContainer)(this.wtRootElement);
  23070. if (!this.isWorkingOnClone()) {
  23071. this.holder.parentNode.style.position = 'relative';
  23072. if (trimmingElement === window) {
  23073. var preventOverflow = this.wot.getSetting('preventOverflow');
  23074. if (!preventOverflow) {
  23075. this.holder.style.overflow = 'visible';
  23076. this.wtRootElement.style.overflow = 'visible';
  23077. }
  23078. } else {
  23079. this.holder.style.width = (0, _element.getStyle)(trimmingElement, 'width');
  23080. this.holder.style.height = (0, _element.getStyle)(trimmingElement, 'height');
  23081. this.holder.style.overflow = '';
  23082. }
  23083. }
  23084. }
  23085. }, {
  23086. key: 'isWorkingOnClone',
  23087. value: function isWorkingOnClone() {
  23088. return !!this.wot.cloneSource;
  23089. }
  23090. /**
  23091. * Redraws the table
  23092. *
  23093. * @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
  23094. * @returns {Table}
  23095. */
  23096. }, {
  23097. key: 'draw',
  23098. value: function draw(fastDraw) {
  23099. var _wot = this.wot,
  23100. wtOverlays = _wot.wtOverlays,
  23101. wtViewport = _wot.wtViewport;
  23102. var totalRows = this.instance.getSetting('totalRows');
  23103. var rowHeaders = this.wot.getSetting('rowHeaders').length;
  23104. var columnHeaders = this.wot.getSetting('columnHeaders').length;
  23105. var syncScroll = false;
  23106. if (!this.isWorkingOnClone()) {
  23107. this.holderOffset = (0, _element.offset)(this.holder);
  23108. fastDraw = wtViewport.createRenderCalculators(fastDraw);
  23109. if (rowHeaders && !this.wot.getSetting('fixedColumnsLeft')) {
  23110. var leftScrollPos = wtOverlays.leftOverlay.getScrollPosition();
  23111. var previousState = this.correctHeaderWidth;
  23112. this.correctHeaderWidth = leftScrollPos > 0;
  23113. if (previousState !== this.correctHeaderWidth) {
  23114. fastDraw = false;
  23115. }
  23116. }
  23117. }
  23118. if (!this.isWorkingOnClone()) {
  23119. syncScroll = wtOverlays.prepareOverlays();
  23120. }
  23121. if (fastDraw) {
  23122. if (!this.isWorkingOnClone()) {
  23123. // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
  23124. wtViewport.createVisibleCalculators();
  23125. }
  23126. if (wtOverlays) {
  23127. wtOverlays.refresh(true);
  23128. }
  23129. } else {
  23130. if (this.isWorkingOnClone()) {
  23131. this.tableOffset = this.wot.cloneSource.wtTable.tableOffset;
  23132. } else {
  23133. this.tableOffset = (0, _element.offset)(this.TABLE);
  23134. }
  23135. var startRow = void 0;
  23136. 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)) {
  23137. startRow = 0;
  23138. } else if (_base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  23139. startRow = Math.max(totalRows - this.wot.getSetting('fixedRowsBottom'), 0);
  23140. } else {
  23141. startRow = wtViewport.rowsRenderCalculator.startRow;
  23142. }
  23143. var startColumn = void 0;
  23144. 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)) {
  23145. startColumn = 0;
  23146. } else {
  23147. startColumn = wtViewport.columnsRenderCalculator.startColumn;
  23148. }
  23149. this.rowFilter = new _row2.default(startRow, totalRows, columnHeaders);
  23150. this.columnFilter = new _column2.default(startColumn, this.wot.getSetting('totalColumns'), rowHeaders);
  23151. this.alignOverlaysWithTrimmingContainer();
  23152. this._doDraw(); // creates calculator after draw
  23153. }
  23154. this.refreshSelections(fastDraw);
  23155. if (!this.isWorkingOnClone()) {
  23156. wtOverlays.topOverlay.resetFixedPosition();
  23157. if (wtOverlays.bottomOverlay.clone) {
  23158. wtOverlays.bottomOverlay.resetFixedPosition();
  23159. }
  23160. wtOverlays.leftOverlay.resetFixedPosition();
  23161. if (wtOverlays.topLeftCornerOverlay) {
  23162. wtOverlays.topLeftCornerOverlay.resetFixedPosition();
  23163. }
  23164. if (wtOverlays.bottomLeftCornerOverlay && wtOverlays.bottomLeftCornerOverlay.clone) {
  23165. wtOverlays.bottomLeftCornerOverlay.resetFixedPosition();
  23166. }
  23167. }
  23168. if (syncScroll) {
  23169. wtOverlays.syncScrollWithMaster();
  23170. }
  23171. this.wot.drawn = true;
  23172. return this;
  23173. }
  23174. }, {
  23175. key: '_doDraw',
  23176. value: function _doDraw() {
  23177. var wtRenderer = new _tableRenderer2.default(this);
  23178. wtRenderer.render();
  23179. }
  23180. }, {
  23181. key: 'removeClassFromCells',
  23182. value: function removeClassFromCells(className) {
  23183. var nodes = this.TABLE.querySelectorAll('.' + className);
  23184. for (var i = 0, len = nodes.length; i < len; i++) {
  23185. (0, _element.removeClass)(nodes[i], className);
  23186. }
  23187. }
  23188. }, {
  23189. key: 'refreshSelections',
  23190. value: function refreshSelections(fastDraw) {
  23191. if (!this.wot.selections) {
  23192. return;
  23193. }
  23194. var len = this.wot.selections.length;
  23195. if (fastDraw) {
  23196. for (var i = 0; i < len; i++) {
  23197. // there was no rerender, so we need to remove classNames by ourselves
  23198. if (this.wot.selections[i].settings.className) {
  23199. this.removeClassFromCells(this.wot.selections[i].settings.className);
  23200. }
  23201. if (this.wot.selections[i].settings.highlightHeaderClassName) {
  23202. this.removeClassFromCells(this.wot.selections[i].settings.highlightHeaderClassName);
  23203. }
  23204. if (this.wot.selections[i].settings.highlightRowClassName) {
  23205. this.removeClassFromCells(this.wot.selections[i].settings.highlightRowClassName);
  23206. }
  23207. if (this.wot.selections[i].settings.highlightColumnClassName) {
  23208. this.removeClassFromCells(this.wot.selections[i].settings.highlightColumnClassName);
  23209. }
  23210. }
  23211. }
  23212. for (var _i = 0; _i < len; _i++) {
  23213. this.wot.selections[_i].draw(this.wot, fastDraw);
  23214. }
  23215. }
  23216. /**
  23217. * Get cell element at coords.
  23218. *
  23219. * @param {CellCoords} coords
  23220. * @returns {HTMLElement|Number} HTMLElement on success or Number one of the exit codes on error:
  23221. * -1 row before viewport
  23222. * -2 row after viewport
  23223. */
  23224. }, {
  23225. key: 'getCell',
  23226. value: function getCell(coords) {
  23227. if (this.isRowBeforeRenderedRows(coords.row)) {
  23228. // row before rendered rows
  23229. return -1;
  23230. } else if (this.isRowAfterRenderedRows(coords.row)) {
  23231. // row after rendered rows
  23232. return -2;
  23233. }
  23234. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(coords.row)];
  23235. if (TR) {
  23236. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(coords.col)];
  23237. }
  23238. }
  23239. /**
  23240. * getColumnHeader
  23241. *
  23242. * @param {Number} col Column index
  23243. * @param {Number} [level=0] Header level (0 = most distant to the table)
  23244. * @returns {Object} HTMLElement on success or undefined on error
  23245. */
  23246. }, {
  23247. key: 'getColumnHeader',
  23248. value: function getColumnHeader(col) {
  23249. var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  23250. var TR = this.THEAD.childNodes[level];
  23251. if (TR) {
  23252. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)];
  23253. }
  23254. }
  23255. /**
  23256. * getRowHeader
  23257. *
  23258. * @param {Number} row Row index
  23259. * @returns {HTMLElement} HTMLElement on success or Number one of the exit codes on error: `null table doesn't have row headers`
  23260. */
  23261. }, {
  23262. key: 'getRowHeader',
  23263. value: function getRowHeader(row) {
  23264. if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
  23265. return null;
  23266. }
  23267. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  23268. if (TR) {
  23269. return TR.childNodes[0];
  23270. }
  23271. }
  23272. /**
  23273. * Returns cell coords object for a given TD (or a child element of a TD element).
  23274. *
  23275. * @param {HTMLTableCellElement} TD A cell DOM element (or a child of one).
  23276. * @returns {CellCoords|null} The coordinates of the provided TD element (or the closest TD element) or null, if the provided element is not applicable.
  23277. */
  23278. }, {
  23279. key: 'getCoords',
  23280. value: function getCoords(TD) {
  23281. if (TD.nodeName !== 'TD' && TD.nodeName !== 'TH') {
  23282. TD = (0, _element.closest)(TD, ['TD', 'TH']);
  23283. }
  23284. if (TD === null) {
  23285. return null;
  23286. }
  23287. var TR = TD.parentNode;
  23288. var CONTAINER = TR.parentNode;
  23289. var row = (0, _element.index)(TR);
  23290. var col = TD.cellIndex;
  23291. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_TOP, TD)) {
  23292. if (CONTAINER.nodeName === 'THEAD') {
  23293. row -= CONTAINER.childNodes.length;
  23294. }
  23295. } else if (CONTAINER === this.THEAD) {
  23296. row = this.rowFilter.visibleColHeadedRowToSourceRow(row);
  23297. } else {
  23298. row = this.rowFilter.renderedToSource(row);
  23299. }
  23300. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_LEFT, TD)) {
  23301. col = this.columnFilter.offsettedTH(col);
  23302. } else {
  23303. col = this.columnFilter.visibleRowHeadedColumnToSourceColumn(col);
  23304. }
  23305. return new _coords2.default(row, col);
  23306. }
  23307. }, {
  23308. key: 'getTrForRow',
  23309. value: function getTrForRow(row) {
  23310. return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  23311. }
  23312. }, {
  23313. key: 'getFirstRenderedRow',
  23314. value: function getFirstRenderedRow() {
  23315. return this.wot.wtViewport.rowsRenderCalculator.startRow;
  23316. }
  23317. }, {
  23318. key: 'getFirstVisibleRow',
  23319. value: function getFirstVisibleRow() {
  23320. return this.wot.wtViewport.rowsVisibleCalculator.startRow;
  23321. }
  23322. }, {
  23323. key: 'getFirstRenderedColumn',
  23324. value: function getFirstRenderedColumn() {
  23325. return this.wot.wtViewport.columnsRenderCalculator.startColumn;
  23326. }
  23327. /**
  23328. * @returns {Number} Returns -1 if no row is visible
  23329. */
  23330. }, {
  23331. key: 'getFirstVisibleColumn',
  23332. value: function getFirstVisibleColumn() {
  23333. return this.wot.wtViewport.columnsVisibleCalculator.startColumn;
  23334. }
  23335. /**
  23336. * @returns {Number} Returns -1 if no row is visible
  23337. */
  23338. }, {
  23339. key: 'getLastRenderedRow',
  23340. value: function getLastRenderedRow() {
  23341. return this.wot.wtViewport.rowsRenderCalculator.endRow;
  23342. }
  23343. }, {
  23344. key: 'getLastVisibleRow',
  23345. value: function getLastVisibleRow() {
  23346. return this.wot.wtViewport.rowsVisibleCalculator.endRow;
  23347. }
  23348. }, {
  23349. key: 'getLastRenderedColumn',
  23350. value: function getLastRenderedColumn() {
  23351. return this.wot.wtViewport.columnsRenderCalculator.endColumn;
  23352. }
  23353. /**
  23354. * @returns {Number} Returns -1 if no column is visible
  23355. */
  23356. }, {
  23357. key: 'getLastVisibleColumn',
  23358. value: function getLastVisibleColumn() {
  23359. return this.wot.wtViewport.columnsVisibleCalculator.endColumn;
  23360. }
  23361. }, {
  23362. key: 'isRowBeforeRenderedRows',
  23363. value: function isRowBeforeRenderedRows(row) {
  23364. return this.rowFilter && this.rowFilter.sourceToRendered(row) < 0 && row >= 0;
  23365. }
  23366. }, {
  23367. key: 'isRowAfterViewport',
  23368. value: function isRowAfterViewport(row) {
  23369. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastVisibleRow();
  23370. }
  23371. }, {
  23372. key: 'isRowAfterRenderedRows',
  23373. value: function isRowAfterRenderedRows(row) {
  23374. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastRenderedRow();
  23375. }
  23376. }, {
  23377. key: 'isColumnBeforeViewport',
  23378. value: function isColumnBeforeViewport(column) {
  23379. return this.columnFilter && this.columnFilter.sourceToRendered(column) < 0 && column >= 0;
  23380. }
  23381. }, {
  23382. key: 'isColumnAfterViewport',
  23383. value: function isColumnAfterViewport(column) {
  23384. return this.columnFilter && this.columnFilter.sourceToRendered(column) > this.getLastVisibleColumn();
  23385. }
  23386. }, {
  23387. key: 'isLastRowFullyVisible',
  23388. value: function isLastRowFullyVisible() {
  23389. return this.getLastVisibleRow() === this.getLastRenderedRow();
  23390. }
  23391. }, {
  23392. key: 'isLastColumnFullyVisible',
  23393. value: function isLastColumnFullyVisible() {
  23394. return this.getLastVisibleColumn() === this.getLastRenderedColumn();
  23395. }
  23396. }, {
  23397. key: 'getRenderedColumnsCount',
  23398. value: function getRenderedColumnsCount() {
  23399. var columnsCount = this.wot.wtViewport.columnsRenderCalculator.count;
  23400. var totalColumns = this.wot.getSetting('totalColumns');
  23401. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  23402. columnsCount = totalColumns;
  23403. } 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)) {
  23404. return Math.min(this.wot.getSetting('fixedColumnsLeft'), totalColumns);
  23405. }
  23406. return columnsCount;
  23407. }
  23408. }, {
  23409. key: 'getRenderedRowsCount',
  23410. value: function getRenderedRowsCount() {
  23411. var rowsCount = this.wot.wtViewport.rowsRenderCalculator.count;
  23412. var totalRows = this.wot.getSetting('totalRows');
  23413. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  23414. rowsCount = totalRows;
  23415. } else if (this.wot.isOverlayName(_base2.default.CLONE_TOP) || this.wot.isOverlayName(_base2.default.CLONE_TOP_LEFT_CORNER)) {
  23416. rowsCount = Math.min(this.wot.getSetting('fixedRowsTop'), totalRows);
  23417. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM) || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  23418. rowsCount = Math.min(this.wot.getSetting('fixedRowsBottom'), totalRows);
  23419. }
  23420. return rowsCount;
  23421. }
  23422. }, {
  23423. key: 'getVisibleRowsCount',
  23424. value: function getVisibleRowsCount() {
  23425. return this.wot.wtViewport.rowsVisibleCalculator.count;
  23426. }
  23427. }, {
  23428. key: 'allRowsInViewport',
  23429. value: function allRowsInViewport() {
  23430. return this.wot.getSetting('totalRows') == this.getVisibleRowsCount();
  23431. }
  23432. /**
  23433. * Checks if any of the row's cells content exceeds its initial height, and if so, returns the oversized height
  23434. *
  23435. * @param {Number} sourceRow
  23436. * @returns {Number}
  23437. */
  23438. }, {
  23439. key: 'getRowHeight',
  23440. value: function getRowHeight(sourceRow) {
  23441. var height = this.wot.wtSettings.settings.rowHeight(sourceRow);
  23442. var oversizedHeight = this.wot.wtViewport.oversizedRows[sourceRow];
  23443. if (oversizedHeight !== void 0) {
  23444. height = height === void 0 ? oversizedHeight : Math.max(height, oversizedHeight);
  23445. }
  23446. return height;
  23447. }
  23448. }, {
  23449. key: 'getColumnHeaderHeight',
  23450. value: function getColumnHeaderHeight(level) {
  23451. var height = this.wot.wtSettings.settings.defaultRowHeight;
  23452. var oversizedHeight = this.wot.wtViewport.oversizedColumnHeaders[level];
  23453. if (oversizedHeight !== void 0) {
  23454. height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
  23455. }
  23456. return height;
  23457. }
  23458. }, {
  23459. key: 'getVisibleColumnsCount',
  23460. value: function getVisibleColumnsCount() {
  23461. return this.wot.wtViewport.columnsVisibleCalculator.count;
  23462. }
  23463. }, {
  23464. key: 'allColumnsInViewport',
  23465. value: function allColumnsInViewport() {
  23466. return this.wot.getSetting('totalColumns') == this.getVisibleColumnsCount();
  23467. }
  23468. }, {
  23469. key: 'getColumnWidth',
  23470. value: function getColumnWidth(sourceColumn) {
  23471. var width = this.wot.wtSettings.settings.columnWidth;
  23472. if (typeof width === 'function') {
  23473. width = width(sourceColumn);
  23474. } else if ((typeof width === 'undefined' ? 'undefined' : _typeof(width)) === 'object') {
  23475. width = width[sourceColumn];
  23476. }
  23477. return width || this.wot.wtSettings.settings.defaultColumnWidth;
  23478. }
  23479. }, {
  23480. key: 'getStretchedColumnWidth',
  23481. value: function getStretchedColumnWidth(sourceColumn) {
  23482. var columnWidth = this.getColumnWidth(sourceColumn);
  23483. var width = columnWidth == null ? this.instance.wtSettings.settings.defaultColumnWidth : columnWidth;
  23484. var calculator = this.wot.wtViewport.columnsRenderCalculator;
  23485. if (calculator) {
  23486. var stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width);
  23487. if (stretchedWidth) {
  23488. width = stretchedWidth;
  23489. }
  23490. }
  23491. return width;
  23492. }
  23493. /**
  23494. * Modify row header widths provided by user in class contructor.
  23495. *
  23496. * @private
  23497. */
  23498. }, {
  23499. key: '_modifyRowHeaderWidth',
  23500. value: function _modifyRowHeaderWidth(rowHeaderWidthFactory) {
  23501. var widths = (0, _function.isFunction)(rowHeaderWidthFactory) ? rowHeaderWidthFactory() : null;
  23502. if (Array.isArray(widths)) {
  23503. widths = [].concat(_toConsumableArray(widths));
  23504. widths[widths.length - 1] = this._correctRowHeaderWidth(widths[widths.length - 1]);
  23505. } else {
  23506. widths = this._correctRowHeaderWidth(widths);
  23507. }
  23508. return widths;
  23509. }
  23510. /**
  23511. * Correct row header width if necessary.
  23512. *
  23513. * @private
  23514. */
  23515. }, {
  23516. key: '_correctRowHeaderWidth',
  23517. value: function _correctRowHeaderWidth(width) {
  23518. if (typeof width !== 'number') {
  23519. width = this.wot.getSetting('defaultColumnWidth');
  23520. }
  23521. if (this.correctHeaderWidth) {
  23522. width++;
  23523. }
  23524. return width;
  23525. }
  23526. }]);
  23527. return Table;
  23528. }();
  23529. exports.default = Table;
  23530. /***/ }),
  23531. /* 261 */
  23532. /***/ (function(module, exports, __webpack_require__) {
  23533. "use strict";
  23534. exports.__esModule = true;
  23535. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  23536. var _element = __webpack_require__(0);
  23537. var _base = __webpack_require__(28);
  23538. var _base2 = _interopRequireDefault(_base);
  23539. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23540. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  23541. var performanceWarningAppeared = false;
  23542. /**
  23543. * @class TableRenderer
  23544. */
  23545. var TableRenderer = function () {
  23546. /**
  23547. * @param {WalkontableTable} wtTable
  23548. */
  23549. function TableRenderer(wtTable) {
  23550. _classCallCheck(this, TableRenderer);
  23551. this.wtTable = wtTable;
  23552. this.wot = wtTable.instance;
  23553. // legacy support
  23554. this.instance = wtTable.instance;
  23555. this.rowFilter = wtTable.rowFilter;
  23556. this.columnFilter = wtTable.columnFilter;
  23557. this.TABLE = wtTable.TABLE;
  23558. this.THEAD = wtTable.THEAD;
  23559. this.TBODY = wtTable.TBODY;
  23560. this.COLGROUP = wtTable.COLGROUP;
  23561. this.rowHeaders = [];
  23562. this.rowHeaderCount = 0;
  23563. this.columnHeaders = [];
  23564. this.columnHeaderCount = 0;
  23565. this.fixedRowsTop = 0;
  23566. this.fixedRowsBottom = 0;
  23567. }
  23568. /**
  23569. *
  23570. */
  23571. _createClass(TableRenderer, [{
  23572. key: 'render',
  23573. value: function render() {
  23574. if (!this.wtTable.isWorkingOnClone()) {
  23575. var skipRender = {};
  23576. this.wot.getSetting('beforeDraw', true, skipRender);
  23577. if (skipRender.skipRender === true) {
  23578. return;
  23579. }
  23580. }
  23581. this.rowHeaders = this.wot.getSetting('rowHeaders');
  23582. this.rowHeaderCount = this.rowHeaders.length;
  23583. this.fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  23584. this.fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  23585. this.columnHeaders = this.wot.getSetting('columnHeaders');
  23586. this.columnHeaderCount = this.columnHeaders.length;
  23587. var columnsToRender = this.wtTable.getRenderedColumnsCount();
  23588. var rowsToRender = this.wtTable.getRenderedRowsCount();
  23589. var totalColumns = this.wot.getSetting('totalColumns');
  23590. var totalRows = this.wot.getSetting('totalRows');
  23591. var workspaceWidth = void 0;
  23592. var adjusted = false;
  23593. if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  23594. // do NOT render headers on the bottom or bottom-left corner overlay
  23595. this.columnHeaders = [];
  23596. this.columnHeaderCount = 0;
  23597. }
  23598. if (totalColumns >= 0) {
  23599. // prepare COL and TH elements for rendering
  23600. this.adjustAvailableNodes();
  23601. adjusted = true;
  23602. // adjust column widths according to user widths settings
  23603. this.renderColumnHeaders();
  23604. // Render table rows
  23605. this.renderRows(totalRows, rowsToRender, columnsToRender);
  23606. if (!this.wtTable.isWorkingOnClone()) {
  23607. workspaceWidth = this.wot.wtViewport.getWorkspaceWidth();
  23608. this.wot.wtViewport.containerWidth = null;
  23609. }
  23610. this.adjustColumnWidths(columnsToRender);
  23611. this.markOversizedColumnHeaders();
  23612. this.adjustColumnHeaderHeights();
  23613. }
  23614. if (!adjusted) {
  23615. this.adjustAvailableNodes();
  23616. }
  23617. this.removeRedundantRows(rowsToRender);
  23618. if (!this.wtTable.isWorkingOnClone() || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  23619. this.markOversizedRows();
  23620. }
  23621. if (!this.wtTable.isWorkingOnClone()) {
  23622. this.wot.wtViewport.createVisibleCalculators();
  23623. this.wot.wtOverlays.refresh(false);
  23624. this.wot.wtOverlays.applyToDOM();
  23625. var hiderWidth = (0, _element.outerWidth)(this.wtTable.hider);
  23626. var tableWidth = (0, _element.outerWidth)(this.wtTable.TABLE);
  23627. if (hiderWidth !== 0 && tableWidth !== hiderWidth) {
  23628. // Recalculate the column widths, if width changes made in the overlays removed the scrollbar, thus changing the viewport width.
  23629. this.adjustColumnWidths(columnsToRender);
  23630. }
  23631. if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) {
  23632. // workspace width changed though to shown/hidden vertical scrollbar. Let's reapply stretching
  23633. this.wot.wtViewport.containerWidth = null;
  23634. var firstRendered = this.wtTable.getFirstRenderedColumn();
  23635. var lastRendered = this.wtTable.getLastRenderedColumn();
  23636. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  23637. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  23638. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  23639. if (rowHeaderWidthSetting != null) {
  23640. for (var i = 0; i < this.rowHeaderCount; i++) {
  23641. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  23642. width = width == null ? defaultColumnWidth : width;
  23643. this.COLGROUP.childNodes[i].style.width = width + 'px';
  23644. }
  23645. }
  23646. for (var _i = firstRendered; _i < lastRendered; _i++) {
  23647. var _width = this.wtTable.getStretchedColumnWidth(_i);
  23648. var renderedIndex = this.columnFilter.sourceToRendered(_i);
  23649. this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = _width + 'px';
  23650. }
  23651. }
  23652. this.wot.getSetting('onDraw', true);
  23653. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  23654. this.wot.cloneSource.wtOverlays.adjustElementsSize();
  23655. }
  23656. }
  23657. /**
  23658. * @param {Number} renderedRowsCount
  23659. */
  23660. }, {
  23661. key: 'removeRedundantRows',
  23662. value: function removeRedundantRows(renderedRowsCount) {
  23663. while (this.wtTable.tbodyChildrenLength > renderedRowsCount) {
  23664. this.TBODY.removeChild(this.TBODY.lastChild);
  23665. this.wtTable.tbodyChildrenLength--;
  23666. }
  23667. }
  23668. /**
  23669. * @param {Number} totalRows
  23670. * @param {Number} rowsToRender
  23671. * @param {Number} columnsToRender
  23672. */
  23673. }, {
  23674. key: 'renderRows',
  23675. value: function renderRows(totalRows, rowsToRender, columnsToRender) {
  23676. var lastTD = void 0,
  23677. TR = void 0;
  23678. var visibleRowIndex = 0;
  23679. var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  23680. var isWorkingOnClone = this.wtTable.isWorkingOnClone();
  23681. while (sourceRowIndex < totalRows && sourceRowIndex >= 0) {
  23682. if (!performanceWarningAppeared && visibleRowIndex > 1000) {
  23683. performanceWarningAppeared = true;
  23684. 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.');
  23685. }
  23686. if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) {
  23687. // We have as much rows as needed for this clone
  23688. break;
  23689. }
  23690. TR = this.getOrCreateTrForRow(visibleRowIndex, TR);
  23691. // Render row headers
  23692. this.renderRowHeaders(sourceRowIndex, TR);
  23693. // Add and/or remove TDs to TR to match the desired number
  23694. this.adjustColumns(TR, columnsToRender + this.rowHeaderCount);
  23695. lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender);
  23696. if (!isWorkingOnClone ||
  23697. // Necessary to refresh oversized row heights after editing cell in overlays
  23698. this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  23699. // Reset the oversized row cache for this row
  23700. this.resetOversizedRow(sourceRowIndex);
  23701. }
  23702. if (TR.firstChild) {
  23703. // if I have 2 fixed columns with one-line content and the 3rd column has a multiline content, this is
  23704. // the way to make sure that the overlay will has same row height
  23705. var height = this.wot.wtTable.getRowHeight(sourceRowIndex);
  23706. if (height) {
  23707. // Decrease height. 1 pixel will be "replaced" by 1px border top
  23708. height--;
  23709. TR.firstChild.style.height = height + 'px';
  23710. } else {
  23711. TR.firstChild.style.height = '';
  23712. }
  23713. }
  23714. visibleRowIndex++;
  23715. sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  23716. }
  23717. }
  23718. /**
  23719. * Reset the oversized row cache for the provided index
  23720. *
  23721. * @param {Number} sourceRow Row index
  23722. */
  23723. }, {
  23724. key: 'resetOversizedRow',
  23725. value: function resetOversizedRow(sourceRow) {
  23726. if (this.wot.getSetting('externalRowCalculator')) {
  23727. return;
  23728. }
  23729. if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) {
  23730. this.wot.wtViewport.oversizedRows[sourceRow] = void 0;
  23731. }
  23732. }
  23733. /**
  23734. * Check if any of the rendered rows is higher than expected, and if so, cache them
  23735. */
  23736. }, {
  23737. key: 'markOversizedRows',
  23738. value: function markOversizedRows() {
  23739. if (this.wot.getSetting('externalRowCalculator')) {
  23740. return;
  23741. }
  23742. var rowCount = this.instance.wtTable.TBODY.childNodes.length;
  23743. var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight;
  23744. var actualTableHeight = (0, _element.innerHeight)(this.instance.wtTable.TBODY) - 1;
  23745. var previousRowHeight = void 0;
  23746. var rowInnerHeight = void 0;
  23747. var sourceRowIndex = void 0;
  23748. var currentTr = void 0;
  23749. var rowHeader = void 0;
  23750. var totalRows = this.instance.getSetting('totalRows');
  23751. if (expectedTableHeight === actualTableHeight && !this.instance.getSetting('fixedRowsBottom')) {
  23752. // If the actual table height equals rowCount * default single row height, no row is oversized -> no need to iterate over them
  23753. return;
  23754. }
  23755. while (rowCount) {
  23756. rowCount--;
  23757. sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount);
  23758. previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex);
  23759. currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex);
  23760. rowHeader = currentTr.querySelector('th');
  23761. if (rowHeader) {
  23762. rowInnerHeight = (0, _element.innerHeight)(rowHeader);
  23763. } else {
  23764. rowInnerHeight = (0, _element.innerHeight)(currentTr) - 1;
  23765. }
  23766. if (!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight) {
  23767. this.instance.wtViewport.oversizedRows[sourceRowIndex] = ++rowInnerHeight;
  23768. }
  23769. }
  23770. }
  23771. /**
  23772. * Check if any of the rendered columns is higher than expected, and if so, cache them.
  23773. */
  23774. }, {
  23775. key: 'markOversizedColumnHeaders',
  23776. value: function markOversizedColumnHeaders() {
  23777. var overlayName = this.wot.getOverlayName();
  23778. if (!this.columnHeaderCount || this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] || this.wtTable.isWorkingOnClone()) {
  23779. return;
  23780. }
  23781. var columnCount = this.wtTable.getRenderedColumnsCount();
  23782. for (var i = 0; i < this.columnHeaderCount; i++) {
  23783. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  23784. this.markIfOversizedColumnHeader(renderedColumnIndex);
  23785. }
  23786. }
  23787. this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] = true;
  23788. }
  23789. /**
  23790. *
  23791. */
  23792. }, {
  23793. key: 'adjustColumnHeaderHeights',
  23794. value: function adjustColumnHeaderHeights() {
  23795. var columnHeaders = this.wot.getSetting('columnHeaders');
  23796. var children = this.wot.wtTable.THEAD.childNodes;
  23797. var oversizedColumnHeaders = this.wot.wtViewport.oversizedColumnHeaders;
  23798. for (var i = 0, len = columnHeaders.length; i < len; i++) {
  23799. if (oversizedColumnHeaders[i]) {
  23800. if (!children[i] || children[i].childNodes.length === 0) {
  23801. return;
  23802. }
  23803. children[i].childNodes[0].style.height = oversizedColumnHeaders[i] + 'px';
  23804. }
  23805. }
  23806. }
  23807. /**
  23808. * Check if column header for the specified column is higher than expected, and if so, cache it
  23809. *
  23810. * @param {Number} col Index of column
  23811. */
  23812. }, {
  23813. key: 'markIfOversizedColumnHeader',
  23814. value: function markIfOversizedColumnHeader(col) {
  23815. var sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col);
  23816. var level = this.columnHeaderCount;
  23817. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  23818. var previousColHeaderHeight = void 0;
  23819. var currentHeader = void 0;
  23820. var currentHeaderHeight = void 0;
  23821. var columnHeaderHeightSetting = this.wot.getSetting('columnHeaderHeight') || [];
  23822. while (level) {
  23823. level--;
  23824. previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level);
  23825. currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level);
  23826. if (!currentHeader) {
  23827. /* eslint-disable no-continue */
  23828. continue;
  23829. }
  23830. currentHeaderHeight = (0, _element.innerHeight)(currentHeader);
  23831. if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) {
  23832. this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight;
  23833. }
  23834. if (Array.isArray(columnHeaderHeightSetting)) {
  23835. if (columnHeaderHeightSetting[level] != null) {
  23836. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level];
  23837. }
  23838. } else if (!isNaN(columnHeaderHeightSetting)) {
  23839. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting;
  23840. }
  23841. if (this.wot.wtViewport.oversizedColumnHeaders[level] < (columnHeaderHeightSetting[level] || columnHeaderHeightSetting)) {
  23842. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level] || columnHeaderHeightSetting;
  23843. }
  23844. }
  23845. }
  23846. /**
  23847. * @param {Number} sourceRowIndex
  23848. * @param {HTMLTableRowElement} TR
  23849. * @param {Number} columnsToRender
  23850. * @returns {HTMLTableCellElement}
  23851. */
  23852. }, {
  23853. key: 'renderCells',
  23854. value: function renderCells(sourceRowIndex, TR, columnsToRender) {
  23855. var TD = void 0;
  23856. var sourceColIndex = void 0;
  23857. for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) {
  23858. sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex);
  23859. if (visibleColIndex === 0) {
  23860. TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)];
  23861. } else {
  23862. TD = TD.nextSibling; // http://jsperf.com/nextsibling-vs-indexed-childnodes
  23863. }
  23864. // If the number of headers has been reduced, we need to replace excess TH with TD
  23865. if (TD.nodeName == 'TH') {
  23866. TD = replaceThWithTd(TD, TR);
  23867. }
  23868. if (!(0, _element.hasClass)(TD, 'hide')) {
  23869. TD.className = '';
  23870. }
  23871. TD.removeAttribute('style');
  23872. this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD);
  23873. }
  23874. return TD;
  23875. }
  23876. /**
  23877. * @param {Number} columnsToRender Number of columns to render.
  23878. */
  23879. }, {
  23880. key: 'adjustColumnWidths',
  23881. value: function adjustColumnWidths(columnsToRender) {
  23882. var scrollbarCompensation = 0;
  23883. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  23884. var mainHolder = sourceInstance.wtTable.holder;
  23885. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  23886. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  23887. if (mainHolder.offsetHeight < mainHolder.scrollHeight) {
  23888. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  23889. }
  23890. this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation);
  23891. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  23892. if (rowHeaderWidthSetting != null) {
  23893. for (var i = 0; i < this.rowHeaderCount; i++) {
  23894. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  23895. width = width == null ? defaultColumnWidth : width;
  23896. this.COLGROUP.childNodes[i].style.width = width + 'px';
  23897. }
  23898. }
  23899. for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) {
  23900. var _width2 = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex));
  23901. this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = _width2 + 'px';
  23902. }
  23903. }
  23904. /**
  23905. * @param {HTMLTableCellElement} TR
  23906. */
  23907. }, {
  23908. key: 'appendToTbody',
  23909. value: function appendToTbody(TR) {
  23910. this.TBODY.appendChild(TR);
  23911. this.wtTable.tbodyChildrenLength++;
  23912. }
  23913. /**
  23914. * @param {Number} rowIndex
  23915. * @param {HTMLTableRowElement} currentTr
  23916. * @returns {HTMLTableCellElement}
  23917. */
  23918. }, {
  23919. key: 'getOrCreateTrForRow',
  23920. value: function getOrCreateTrForRow(rowIndex, currentTr) {
  23921. var TR = void 0;
  23922. if (rowIndex >= this.wtTable.tbodyChildrenLength) {
  23923. TR = this.createRow();
  23924. this.appendToTbody(TR);
  23925. } else if (rowIndex === 0) {
  23926. TR = this.TBODY.firstChild;
  23927. } else {
  23928. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  23929. TR = currentTr.nextSibling;
  23930. }
  23931. if (TR.className) {
  23932. TR.removeAttribute('class');
  23933. }
  23934. return TR;
  23935. }
  23936. /**
  23937. * @returns {HTMLTableCellElement}
  23938. */
  23939. }, {
  23940. key: 'createRow',
  23941. value: function createRow() {
  23942. var TR = document.createElement('TR');
  23943. for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  23944. TR.appendChild(document.createElement('TH'));
  23945. }
  23946. return TR;
  23947. }
  23948. /**
  23949. * @param {Number} row
  23950. * @param {Number} col
  23951. * @param {HTMLTableCellElement} TH
  23952. */
  23953. }, {
  23954. key: 'renderRowHeader',
  23955. value: function renderRowHeader(row, col, TH) {
  23956. TH.className = '';
  23957. TH.removeAttribute('style');
  23958. this.rowHeaders[col](row, TH, col);
  23959. }
  23960. /**
  23961. * @param {Number} row
  23962. * @param {HTMLTableCellElement} TR
  23963. */
  23964. }, {
  23965. key: 'renderRowHeaders',
  23966. value: function renderRowHeaders(row, TR) {
  23967. for (var TH = TR.firstChild, visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  23968. // If the number of row headers increased we need to create TH or replace an existing TD node with TH
  23969. if (!TH) {
  23970. TH = document.createElement('TH');
  23971. TR.appendChild(TH);
  23972. } else if (TH.nodeName == 'TD') {
  23973. TH = replaceTdWithTh(TH, TR);
  23974. }
  23975. this.renderRowHeader(row, visibleColIndex, TH);
  23976. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  23977. TH = TH.nextSibling;
  23978. }
  23979. }
  23980. /**
  23981. * Adjust the number of COL and TH elements to match the number of columns and headers that need to be rendered
  23982. */
  23983. }, {
  23984. key: 'adjustAvailableNodes',
  23985. value: function adjustAvailableNodes() {
  23986. this.adjustColGroups();
  23987. this.adjustThead();
  23988. }
  23989. /**
  23990. * Renders the column headers
  23991. */
  23992. }, {
  23993. key: 'renderColumnHeaders',
  23994. value: function renderColumnHeaders() {
  23995. if (!this.columnHeaderCount) {
  23996. return;
  23997. }
  23998. var columnCount = this.wtTable.getRenderedColumnsCount();
  23999. for (var i = 0; i < this.columnHeaderCount; i++) {
  24000. var TR = this.getTrForColumnHeaders(i);
  24001. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  24002. var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex);
  24003. this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]);
  24004. }
  24005. }
  24006. }
  24007. /**
  24008. * Adjusts the number of COL elements to match the number of columns that need to be rendered
  24009. */
  24010. }, {
  24011. key: 'adjustColGroups',
  24012. value: function adjustColGroups() {
  24013. var columnCount = this.wtTable.getRenderedColumnsCount();
  24014. while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) {
  24015. this.COLGROUP.appendChild(document.createElement('COL'));
  24016. this.wtTable.colgroupChildrenLength++;
  24017. }
  24018. while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) {
  24019. this.COLGROUP.removeChild(this.COLGROUP.lastChild);
  24020. this.wtTable.colgroupChildrenLength--;
  24021. }
  24022. if (this.rowHeaderCount) {
  24023. (0, _element.addClass)(this.COLGROUP.childNodes[0], 'rowHeader');
  24024. }
  24025. }
  24026. /**
  24027. * Adjusts the number of TH elements in THEAD to match the number of headers and columns that need to be rendered
  24028. */
  24029. }, {
  24030. key: 'adjustThead',
  24031. value: function adjustThead() {
  24032. var columnCount = this.wtTable.getRenderedColumnsCount();
  24033. var TR = this.THEAD.firstChild;
  24034. if (this.columnHeaders.length) {
  24035. for (var i = 0, len = this.columnHeaders.length; i < len; i++) {
  24036. TR = this.THEAD.childNodes[i];
  24037. if (!TR) {
  24038. TR = document.createElement('TR');
  24039. this.THEAD.appendChild(TR);
  24040. }
  24041. this.theadChildrenLength = TR.childNodes.length;
  24042. while (this.theadChildrenLength < columnCount + this.rowHeaderCount) {
  24043. TR.appendChild(document.createElement('TH'));
  24044. this.theadChildrenLength++;
  24045. }
  24046. while (this.theadChildrenLength > columnCount + this.rowHeaderCount) {
  24047. TR.removeChild(TR.lastChild);
  24048. this.theadChildrenLength--;
  24049. }
  24050. }
  24051. var theadChildrenLength = this.THEAD.childNodes.length;
  24052. if (theadChildrenLength > this.columnHeaders.length) {
  24053. for (var _i2 = this.columnHeaders.length; _i2 < theadChildrenLength; _i2++) {
  24054. this.THEAD.removeChild(this.THEAD.lastChild);
  24055. }
  24056. }
  24057. } else if (TR) {
  24058. (0, _element.empty)(TR);
  24059. }
  24060. }
  24061. /**
  24062. * @param {Number} index
  24063. * @returns {HTMLTableCellElement}
  24064. */
  24065. }, {
  24066. key: 'getTrForColumnHeaders',
  24067. value: function getTrForColumnHeaders(index) {
  24068. return this.THEAD.childNodes[index];
  24069. }
  24070. /**
  24071. * @param {Number} row
  24072. * @param {Number} col
  24073. * @param {HTMLTableCellElement} TH
  24074. * @returns {*}
  24075. */
  24076. }, {
  24077. key: 'renderColumnHeader',
  24078. value: function renderColumnHeader(row, col, TH) {
  24079. TH.className = '';
  24080. TH.removeAttribute('style');
  24081. return this.columnHeaders[row](col, TH, row);
  24082. }
  24083. /**
  24084. * Add and/or remove the TDs to match the desired number
  24085. *
  24086. * @param {HTMLTableCellElement} TR Table row in question
  24087. * @param {Number} desiredCount The desired number of TDs in the TR
  24088. */
  24089. }, {
  24090. key: 'adjustColumns',
  24091. value: function adjustColumns(TR, desiredCount) {
  24092. var count = TR.childNodes.length;
  24093. while (count < desiredCount) {
  24094. var TD = document.createElement('TD');
  24095. TR.appendChild(TD);
  24096. count++;
  24097. }
  24098. while (count > desiredCount) {
  24099. TR.removeChild(TR.lastChild);
  24100. count--;
  24101. }
  24102. }
  24103. /**
  24104. * @param {Number} columnsToRender
  24105. */
  24106. }, {
  24107. key: 'removeRedundantColumns',
  24108. value: function removeRedundantColumns(columnsToRender) {
  24109. while (this.wtTable.tbodyChildrenLength > columnsToRender) {
  24110. this.TBODY.removeChild(this.TBODY.lastChild);
  24111. this.wtTable.tbodyChildrenLength--;
  24112. }
  24113. }
  24114. }]);
  24115. return TableRenderer;
  24116. }();
  24117. function replaceTdWithTh(TD, TR) {
  24118. var TH = document.createElement('TH');
  24119. TR.insertBefore(TH, TD);
  24120. TR.removeChild(TD);
  24121. return TH;
  24122. }
  24123. function replaceThWithTd(TH, TR) {
  24124. var TD = document.createElement('TD');
  24125. TR.insertBefore(TD, TH);
  24126. TR.removeChild(TH);
  24127. return TD;
  24128. }
  24129. exports.default = TableRenderer;
  24130. /***/ }),
  24131. /* 262 */
  24132. /***/ (function(module, exports, __webpack_require__) {
  24133. "use strict";
  24134. exports.__esModule = true;
  24135. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  24136. var _element = __webpack_require__(0);
  24137. var _object = __webpack_require__(1);
  24138. var _eventManager = __webpack_require__(4);
  24139. var _eventManager2 = _interopRequireDefault(_eventManager);
  24140. var _viewportColumns = __webpack_require__(251);
  24141. var _viewportColumns2 = _interopRequireDefault(_viewportColumns);
  24142. var _viewportRows = __webpack_require__(252);
  24143. var _viewportRows2 = _interopRequireDefault(_viewportRows);
  24144. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24145. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24146. /**
  24147. * @class Viewport
  24148. */
  24149. var Viewport = function () {
  24150. /**
  24151. * @param wotInstance
  24152. */
  24153. function Viewport(wotInstance) {
  24154. var _this = this;
  24155. _classCallCheck(this, Viewport);
  24156. this.wot = wotInstance;
  24157. // legacy support
  24158. this.instance = this.wot;
  24159. this.oversizedRows = [];
  24160. this.oversizedColumnHeaders = [];
  24161. this.hasOversizedColumnHeadersMarked = {};
  24162. this.clientHeight = 0;
  24163. this.containerWidth = NaN;
  24164. this.rowHeaderWidth = NaN;
  24165. this.rowsVisibleCalculator = null;
  24166. this.columnsVisibleCalculator = null;
  24167. this.eventManager = new _eventManager2.default(this.wot);
  24168. this.eventManager.addEventListener(window, 'resize', function () {
  24169. _this.clientHeight = _this.getWorkspaceHeight();
  24170. });
  24171. }
  24172. /**
  24173. * @returns {number}
  24174. */
  24175. _createClass(Viewport, [{
  24176. key: 'getWorkspaceHeight',
  24177. value: function getWorkspaceHeight() {
  24178. var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer;
  24179. var elemHeight = void 0;
  24180. var height = 0;
  24181. if (trimmingContainer === window) {
  24182. height = document.documentElement.clientHeight;
  24183. } else {
  24184. elemHeight = (0, _element.outerHeight)(trimmingContainer);
  24185. // returns height without DIV scrollbar
  24186. height = elemHeight > 0 && trimmingContainer.clientHeight > 0 ? trimmingContainer.clientHeight : Infinity;
  24187. }
  24188. return height;
  24189. }
  24190. }, {
  24191. key: 'getWorkspaceWidth',
  24192. value: function getWorkspaceWidth() {
  24193. var width = void 0;
  24194. var totalColumns = this.wot.getSetting('totalColumns');
  24195. var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer;
  24196. var overflow = void 0;
  24197. var stretchSetting = this.wot.getSetting('stretchH');
  24198. var docOffsetWidth = document.documentElement.offsetWidth;
  24199. var preventOverflow = this.wot.getSetting('preventOverflow');
  24200. if (preventOverflow) {
  24201. return (0, _element.outerWidth)(this.instance.wtTable.wtRootElement);
  24202. }
  24203. if (this.wot.getSetting('freezeOverlays')) {
  24204. width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  24205. } else {
  24206. width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  24207. }
  24208. if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
  24209. // in case sum of column widths is higher than available stylesheet width, let's assume using the whole window
  24210. // otherwise continue below, which will allow stretching
  24211. // this is used in `scroll_window.html`
  24212. // TODO test me
  24213. return document.documentElement.clientWidth;
  24214. }
  24215. if (trimmingContainer !== window) {
  24216. overflow = (0, _element.getStyle)(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow');
  24217. if (overflow == 'scroll' || overflow == 'hidden' || overflow == 'auto') {
  24218. // this is used in `scroll.html`
  24219. // TODO test me
  24220. return Math.max(width, trimmingContainer.clientWidth);
  24221. }
  24222. }
  24223. if (stretchSetting === 'none' || !stretchSetting) {
  24224. // if no stretching is used, return the maximum used workspace width
  24225. return Math.max(width, (0, _element.outerWidth)(this.instance.wtTable.TABLE));
  24226. }
  24227. // if stretching is used, return the actual container width, so the columns can fit inside it
  24228. return width;
  24229. }
  24230. /**
  24231. * Checks if viewport has vertical scroll
  24232. *
  24233. * @returns {Boolean}
  24234. */
  24235. }, {
  24236. key: 'hasVerticalScroll',
  24237. value: function hasVerticalScroll() {
  24238. return this.getWorkspaceActualHeight() > this.getWorkspaceHeight();
  24239. }
  24240. /**
  24241. * Checks if viewport has horizontal scroll
  24242. *
  24243. * @returns {Boolean}
  24244. */
  24245. }, {
  24246. key: 'hasHorizontalScroll',
  24247. value: function hasHorizontalScroll() {
  24248. return this.getWorkspaceActualWidth() > this.getWorkspaceWidth();
  24249. }
  24250. /**
  24251. * @param from
  24252. * @param length
  24253. * @returns {Number}
  24254. */
  24255. }, {
  24256. key: 'sumColumnWidths',
  24257. value: function sumColumnWidths(from, length) {
  24258. var sum = 0;
  24259. while (from < length) {
  24260. sum += this.wot.wtTable.getColumnWidth(from);
  24261. from++;
  24262. }
  24263. return sum;
  24264. }
  24265. /**
  24266. * @returns {Number}
  24267. */
  24268. }, {
  24269. key: 'getContainerFillWidth',
  24270. value: function getContainerFillWidth() {
  24271. if (this.containerWidth) {
  24272. return this.containerWidth;
  24273. }
  24274. var mainContainer = this.instance.wtTable.holder;
  24275. var fillWidth = void 0;
  24276. var dummyElement = void 0;
  24277. dummyElement = document.createElement('div');
  24278. dummyElement.style.width = '100%';
  24279. dummyElement.style.height = '1px';
  24280. mainContainer.appendChild(dummyElement);
  24281. fillWidth = dummyElement.offsetWidth;
  24282. this.containerWidth = fillWidth;
  24283. mainContainer.removeChild(dummyElement);
  24284. return fillWidth;
  24285. }
  24286. /**
  24287. * @returns {Number}
  24288. */
  24289. }, {
  24290. key: 'getWorkspaceOffset',
  24291. value: function getWorkspaceOffset() {
  24292. return (0, _element.offset)(this.wot.wtTable.TABLE);
  24293. }
  24294. /**
  24295. * @returns {Number}
  24296. */
  24297. }, {
  24298. key: 'getWorkspaceActualHeight',
  24299. value: function getWorkspaceActualHeight() {
  24300. return (0, _element.outerHeight)(this.wot.wtTable.TABLE);
  24301. }
  24302. /**
  24303. * @returns {Number}
  24304. */
  24305. }, {
  24306. key: 'getWorkspaceActualWidth',
  24307. value: function getWorkspaceActualWidth() {
  24308. 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;
  24309. }
  24310. /**
  24311. * @returns {Number}
  24312. */
  24313. }, {
  24314. key: 'getColumnHeaderHeight',
  24315. value: function getColumnHeaderHeight() {
  24316. if (isNaN(this.columnHeaderHeight)) {
  24317. this.columnHeaderHeight = (0, _element.outerHeight)(this.wot.wtTable.THEAD);
  24318. }
  24319. return this.columnHeaderHeight;
  24320. }
  24321. /**
  24322. * @returns {Number}
  24323. */
  24324. }, {
  24325. key: 'getViewportHeight',
  24326. value: function getViewportHeight() {
  24327. var containerHeight = this.getWorkspaceHeight();
  24328. var columnHeaderHeight = void 0;
  24329. if (containerHeight === Infinity) {
  24330. return containerHeight;
  24331. }
  24332. columnHeaderHeight = this.getColumnHeaderHeight();
  24333. if (columnHeaderHeight > 0) {
  24334. containerHeight -= columnHeaderHeight;
  24335. }
  24336. return containerHeight;
  24337. }
  24338. /**
  24339. * @returns {Number}
  24340. */
  24341. }, {
  24342. key: 'getRowHeaderWidth',
  24343. value: function getRowHeaderWidth() {
  24344. var rowHeadersHeightSetting = this.instance.getSetting('rowHeaderWidth');
  24345. var rowHeaders = this.instance.getSetting('rowHeaders');
  24346. if (rowHeadersHeightSetting) {
  24347. this.rowHeaderWidth = 0;
  24348. for (var i = 0, len = rowHeaders.length; i < len; i++) {
  24349. this.rowHeaderWidth += rowHeadersHeightSetting[i] || rowHeadersHeightSetting;
  24350. }
  24351. }
  24352. if (this.wot.cloneSource) {
  24353. return this.wot.cloneSource.wtViewport.getRowHeaderWidth();
  24354. }
  24355. if (isNaN(this.rowHeaderWidth)) {
  24356. if (rowHeaders.length) {
  24357. var TH = this.instance.wtTable.TABLE.querySelector('TH');
  24358. this.rowHeaderWidth = 0;
  24359. for (var _i = 0, _len = rowHeaders.length; _i < _len; _i++) {
  24360. if (TH) {
  24361. this.rowHeaderWidth += (0, _element.outerWidth)(TH);
  24362. TH = TH.nextSibling;
  24363. } else {
  24364. // yes this is a cheat but it worked like that before, just taking assumption from CSS instead of measuring.
  24365. // TODO: proper fix
  24366. this.rowHeaderWidth += 50;
  24367. }
  24368. }
  24369. } else {
  24370. this.rowHeaderWidth = 0;
  24371. }
  24372. }
  24373. this.rowHeaderWidth = this.instance.getSetting('onModifyRowHeaderWidth', this.rowHeaderWidth) || this.rowHeaderWidth;
  24374. return this.rowHeaderWidth;
  24375. }
  24376. /**
  24377. * @returns {Number}
  24378. */
  24379. }, {
  24380. key: 'getViewportWidth',
  24381. value: function getViewportWidth() {
  24382. var containerWidth = this.getWorkspaceWidth();
  24383. var rowHeaderWidth = void 0;
  24384. if (containerWidth === Infinity) {
  24385. return containerWidth;
  24386. }
  24387. rowHeaderWidth = this.getRowHeaderWidth();
  24388. if (rowHeaderWidth > 0) {
  24389. return containerWidth - rowHeaderWidth;
  24390. }
  24391. return containerWidth;
  24392. }
  24393. /**
  24394. * Creates:
  24395. * - rowsRenderCalculator (before draw, to qualify rows for rendering)
  24396. * - rowsVisibleCalculator (after draw, to measure which rows are actually visible)
  24397. *
  24398. * @returns {ViewportRowsCalculator}
  24399. */
  24400. }, {
  24401. key: 'createRowsCalculator',
  24402. value: function createRowsCalculator() {
  24403. var _this2 = this;
  24404. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  24405. var height = void 0;
  24406. var pos = void 0;
  24407. var fixedRowsTop = void 0;
  24408. var scrollbarHeight = void 0;
  24409. var fixedRowsBottom = void 0;
  24410. var fixedRowsHeight = void 0;
  24411. var totalRows = void 0;
  24412. this.rowHeaderWidth = NaN;
  24413. if (this.wot.wtSettings.settings.renderAllRows) {
  24414. height = Infinity;
  24415. } else {
  24416. height = this.getViewportHeight();
  24417. }
  24418. pos = this.wot.wtOverlays.topOverlay.getScrollPosition() - this.wot.wtOverlays.topOverlay.getTableParentOffset();
  24419. if (pos < 0) {
  24420. pos = 0;
  24421. }
  24422. fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  24423. fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  24424. totalRows = this.wot.getSetting('totalRows');
  24425. if (fixedRowsTop) {
  24426. fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop);
  24427. pos += fixedRowsHeight;
  24428. height -= fixedRowsHeight;
  24429. }
  24430. if (fixedRowsBottom && this.wot.wtOverlays.bottomOverlay.clone) {
  24431. fixedRowsHeight = this.wot.wtOverlays.bottomOverlay.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  24432. height -= fixedRowsHeight;
  24433. }
  24434. if (this.wot.wtTable.holder.clientHeight === this.wot.wtTable.holder.offsetHeight) {
  24435. scrollbarHeight = 0;
  24436. } else {
  24437. scrollbarHeight = (0, _element.getScrollbarWidth)();
  24438. }
  24439. return new _viewportRows2.default(height, pos, this.wot.getSetting('totalRows'), function (sourceRow) {
  24440. return _this2.wot.wtTable.getRowHeight(sourceRow);
  24441. }, visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible, scrollbarHeight);
  24442. }
  24443. /**
  24444. * Creates:
  24445. * - columnsRenderCalculator (before draw, to qualify columns for rendering)
  24446. * - columnsVisibleCalculator (after draw, to measure which columns are actually visible)
  24447. *
  24448. * @returns {ViewportRowsCalculator}
  24449. */
  24450. }, {
  24451. key: 'createColumnsCalculator',
  24452. value: function createColumnsCalculator() {
  24453. var _this3 = this;
  24454. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  24455. var width = this.getViewportWidth();
  24456. var pos = void 0;
  24457. var fixedColumnsLeft = void 0;
  24458. this.columnHeaderHeight = NaN;
  24459. pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.leftOverlay.getTableParentOffset();
  24460. if (pos < 0) {
  24461. pos = 0;
  24462. }
  24463. fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  24464. if (fixedColumnsLeft) {
  24465. var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft);
  24466. pos += fixedColumnsWidth;
  24467. width -= fixedColumnsWidth;
  24468. }
  24469. if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) {
  24470. width -= (0, _element.getScrollbarWidth)();
  24471. }
  24472. return new _viewportColumns2.default(width, pos, this.wot.getSetting('totalColumns'), function (sourceCol) {
  24473. return _this3.wot.wtTable.getColumnWidth(sourceCol);
  24474. }, visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'), function (stretchedWidth, column) {
  24475. return _this3.wot.getSetting('onBeforeStretchingColumnWidth', stretchedWidth, column);
  24476. });
  24477. }
  24478. /**
  24479. * Creates rowsRenderCalculator and columnsRenderCalculator (before draw, to determine what rows and
  24480. * cols should be rendered)
  24481. *
  24482. * @param fastDraw {Boolean} If `true`, will try to avoid full redraw and only update the border positions.
  24483. * If `false` or `undefined`, will perform a full redraw
  24484. * @returns fastDraw {Boolean} The fastDraw value, possibly modified
  24485. */
  24486. }, {
  24487. key: 'createRenderCalculators',
  24488. value: function createRenderCalculators() {
  24489. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  24490. if (fastDraw) {
  24491. var proposedRowsVisibleCalculator = this.createRowsCalculator(true);
  24492. var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true);
  24493. if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) {
  24494. fastDraw = false;
  24495. }
  24496. }
  24497. if (!fastDraw) {
  24498. this.rowsRenderCalculator = this.createRowsCalculator();
  24499. this.columnsRenderCalculator = this.createColumnsCalculator();
  24500. }
  24501. // delete temporarily to make sure that renderers always use rowsRenderCalculator, not rowsVisibleCalculator
  24502. this.rowsVisibleCalculator = null;
  24503. this.columnsVisibleCalculator = null;
  24504. return fastDraw;
  24505. }
  24506. /**
  24507. * Creates rowsVisibleCalculator and columnsVisibleCalculator (after draw, to determine what are
  24508. * the actually visible rows and columns)
  24509. */
  24510. }, {
  24511. key: 'createVisibleCalculators',
  24512. value: function createVisibleCalculators() {
  24513. this.rowsVisibleCalculator = this.createRowsCalculator(true);
  24514. this.columnsVisibleCalculator = this.createColumnsCalculator(true);
  24515. }
  24516. /**
  24517. * Returns information whether proposedRowsVisibleCalculator viewport
  24518. * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator)
  24519. *
  24520. * @param {Object} proposedRowsVisibleCalculator
  24521. * @returns {Boolean} Returns `true` if all proposed visible rows are already rendered (meaning: redraw is not needed).
  24522. * Returns `false` if at least one proposed visible row is not already rendered (meaning: redraw is needed)
  24523. */
  24524. }, {
  24525. key: 'areAllProposedVisibleRowsAlreadyRendered',
  24526. value: function areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) {
  24527. if (this.rowsVisibleCalculator) {
  24528. if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0) {
  24529. return false;
  24530. } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1) {
  24531. return false;
  24532. }
  24533. return true;
  24534. }
  24535. return false;
  24536. }
  24537. /**
  24538. * Returns information whether proposedColumnsVisibleCalculator viewport
  24539. * is contained inside column rendered in previous draw (cached in columnsRenderCalculator)
  24540. *
  24541. * @param {Object} proposedColumnsVisibleCalculator
  24542. * @returns {Boolean} Returns `true` if all proposed visible columns are already rendered (meaning: redraw is not needed).
  24543. * Returns `false` if at least one proposed visible column is not already rendered (meaning: redraw is needed)
  24544. */
  24545. }, {
  24546. key: 'areAllProposedVisibleColumnsAlreadyRendered',
  24547. value: function areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator) {
  24548. if (this.columnsVisibleCalculator) {
  24549. if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0) {
  24550. return false;
  24551. } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1) {
  24552. return false;
  24553. }
  24554. return true;
  24555. }
  24556. return false;
  24557. }
  24558. /**
  24559. * Resets values in keys of the hasOversizedColumnHeadersMarked object after updateSettings.
  24560. */
  24561. }, {
  24562. key: 'resetHasOversizedColumnHeadersMarked',
  24563. value: function resetHasOversizedColumnHeadersMarked() {
  24564. (0, _object.objectEach)(this.hasOversizedColumnHeadersMarked, function (value, key, object) {
  24565. object[key] = void 0;
  24566. });
  24567. }
  24568. }]);
  24569. return Viewport;
  24570. }();
  24571. exports.default = Viewport;
  24572. /***/ }),
  24573. /* 263 */
  24574. /***/ (function(module, exports, __webpack_require__) {
  24575. "use strict";
  24576. exports.__esModule = true;
  24577. var _unicode = __webpack_require__(16);
  24578. var _mixed = __webpack_require__(20);
  24579. var _string = __webpack_require__(27);
  24580. var _array = __webpack_require__(2);
  24581. var _element = __webpack_require__(0);
  24582. var _handsontableEditor = __webpack_require__(264);
  24583. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  24584. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24585. var AutocompleteEditor = _handsontableEditor2.default.prototype.extend();
  24586. /**
  24587. * @private
  24588. * @editor AutocompleteEditor
  24589. * @class AutocompleteEditor
  24590. * @dependencies HandsontableEditor
  24591. */
  24592. AutocompleteEditor.prototype.init = function () {
  24593. _handsontableEditor2.default.prototype.init.apply(this, arguments);
  24594. this.query = null;
  24595. this.strippedChoices = [];
  24596. this.rawChoices = [];
  24597. };
  24598. AutocompleteEditor.prototype.getValue = function () {
  24599. var _this2 = this;
  24600. var selectedValue = this.rawChoices.find(function (value) {
  24601. var strippedValue = _this2.stripValueIfNeeded(value);
  24602. return strippedValue === _this2.TEXTAREA.value;
  24603. });
  24604. if ((0, _mixed.isDefined)(selectedValue)) {
  24605. return selectedValue;
  24606. }
  24607. return this.TEXTAREA.value;
  24608. };
  24609. AutocompleteEditor.prototype.createElements = function () {
  24610. _handsontableEditor2.default.prototype.createElements.apply(this, arguments);
  24611. (0, _element.addClass)(this.htContainer, 'autocompleteEditor');
  24612. (0, _element.addClass)(this.htContainer, window.navigator.platform.indexOf('Mac') === -1 ? '' : 'htMacScroll');
  24613. };
  24614. var skipOne = false;
  24615. function onBeforeKeyDown(event) {
  24616. skipOne = false;
  24617. var editor = this.getActiveEditor();
  24618. if ((0, _unicode.isPrintableChar)(event.keyCode) || event.keyCode === _unicode.KEY_CODES.BACKSPACE || event.keyCode === _unicode.KEY_CODES.DELETE || event.keyCode === _unicode.KEY_CODES.INSERT) {
  24619. var timeOffset = 0;
  24620. // on ctl+c / cmd+c don't update suggestion list
  24621. if (event.keyCode === _unicode.KEY_CODES.C && (event.ctrlKey || event.metaKey)) {
  24622. return;
  24623. }
  24624. if (!editor.isOpened()) {
  24625. timeOffset += 10;
  24626. }
  24627. if (editor.htEditor) {
  24628. editor.instance._registerTimeout(setTimeout(function () {
  24629. editor.queryChoices(editor.TEXTAREA.value);
  24630. skipOne = true;
  24631. }, timeOffset));
  24632. }
  24633. }
  24634. }
  24635. AutocompleteEditor.prototype.prepare = function () {
  24636. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  24637. _handsontableEditor2.default.prototype.prepare.apply(this, arguments);
  24638. };
  24639. AutocompleteEditor.prototype.open = function () {
  24640. // Ugly fix for handsontable which grab window object for autocomplete scroll listener instead table element.
  24641. this.TEXTAREA_PARENT.style.overflow = 'auto';
  24642. _handsontableEditor2.default.prototype.open.apply(this, arguments);
  24643. this.TEXTAREA_PARENT.style.overflow = '';
  24644. var choicesListHot = this.htEditor.getInstance();
  24645. var _this = this;
  24646. var trimDropdown = this.cellProperties.trimDropdown === void 0 ? true : this.cellProperties.trimDropdown;
  24647. this.TEXTAREA.style.visibility = 'visible';
  24648. this.focus();
  24649. choicesListHot.updateSettings({
  24650. colWidths: trimDropdown ? [(0, _element.outerWidth)(this.TEXTAREA) - 2] : void 0,
  24651. width: trimDropdown ? (0, _element.outerWidth)(this.TEXTAREA) + (0, _element.getScrollbarWidth)() + 2 : void 0,
  24652. afterRenderer: function afterRenderer(TD, row, col, prop, value, cellProperties) {
  24653. var _this$cellProperties = _this.cellProperties,
  24654. filteringCaseSensitive = _this$cellProperties.filteringCaseSensitive,
  24655. allowHtml = _this$cellProperties.allowHtml;
  24656. var indexOfMatch = void 0;
  24657. var match = void 0;
  24658. value = (0, _mixed.stringify)(value);
  24659. if (value && !allowHtml) {
  24660. indexOfMatch = filteringCaseSensitive === true ? value.indexOf(this.query) : value.toLowerCase().indexOf(_this.query.toLowerCase());
  24661. if (indexOfMatch !== -1) {
  24662. match = value.substr(indexOfMatch, _this.query.length);
  24663. value = value.replace(match, '<strong>' + match + '</strong>');
  24664. }
  24665. }
  24666. TD.innerHTML = value;
  24667. },
  24668. autoColumnSize: true,
  24669. modifyColWidth: function modifyColWidth(width, col) {
  24670. // workaround for <strong> text overlapping the dropdown, not really accurate
  24671. var autoWidths = this.getPlugin('autoColumnSize').widths;
  24672. if (autoWidths[col]) {
  24673. width = autoWidths[col];
  24674. }
  24675. return trimDropdown ? width : width + 15;
  24676. }
  24677. });
  24678. // Add additional space for autocomplete holder
  24679. this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = (0, _element.getScrollbarWidth)() + 2 + 'px';
  24680. if (skipOne) {
  24681. skipOne = false;
  24682. }
  24683. _this.instance._registerTimeout(setTimeout(function () {
  24684. _this.queryChoices(_this.TEXTAREA.value);
  24685. }, 0));
  24686. };
  24687. AutocompleteEditor.prototype.close = function () {
  24688. _handsontableEditor2.default.prototype.close.apply(this, arguments);
  24689. };
  24690. AutocompleteEditor.prototype.queryChoices = function (query) {
  24691. var _this3 = this;
  24692. this.query = query;
  24693. var source = this.cellProperties.source;
  24694. if (typeof source == 'function') {
  24695. source.call(this.cellProperties, query, function (choices) {
  24696. _this3.rawChoices = choices;
  24697. _this3.updateChoicesList(_this3.stripValuesIfNeeded(choices));
  24698. });
  24699. } else if (Array.isArray(source)) {
  24700. this.rawChoices = source;
  24701. this.updateChoicesList(this.stripValuesIfNeeded(source));
  24702. } else {
  24703. this.updateChoicesList([]);
  24704. }
  24705. };
  24706. AutocompleteEditor.prototype.updateChoicesList = function (choices) {
  24707. var pos = (0, _element.getCaretPosition)(this.TEXTAREA);
  24708. var endPos = (0, _element.getSelectionEndPosition)(this.TEXTAREA);
  24709. var sortByRelevanceSetting = this.cellProperties.sortByRelevance;
  24710. var filterSetting = this.cellProperties.filter;
  24711. var orderByRelevance = null;
  24712. var highlightIndex = null;
  24713. if (sortByRelevanceSetting) {
  24714. orderByRelevance = AutocompleteEditor.sortByRelevance(this.stripValueIfNeeded(this.getValue()), choices, this.cellProperties.filteringCaseSensitive);
  24715. }
  24716. var orderByRelevanceLength = Array.isArray(orderByRelevance) ? orderByRelevance.length : 0;
  24717. if (filterSetting === false) {
  24718. if (orderByRelevanceLength) {
  24719. highlightIndex = orderByRelevance[0];
  24720. }
  24721. } else {
  24722. var sorted = [];
  24723. for (var i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  24724. if (sortByRelevanceSetting && orderByRelevanceLength <= i) {
  24725. break;
  24726. }
  24727. if (orderByRelevanceLength) {
  24728. sorted.push(choices[orderByRelevance[i]]);
  24729. } else {
  24730. sorted.push(choices[i]);
  24731. }
  24732. }
  24733. highlightIndex = 0;
  24734. choices = sorted;
  24735. }
  24736. this.strippedChoices = choices;
  24737. this.htEditor.loadData((0, _array.pivot)([choices]));
  24738. this.updateDropdownHeight();
  24739. this.flipDropdownIfNeeded();
  24740. if (this.cellProperties.strict === true) {
  24741. this.highlightBestMatchingChoice(highlightIndex);
  24742. }
  24743. this.instance.listen();
  24744. this.TEXTAREA.focus();
  24745. (0, _element.setCaretPosition)(this.TEXTAREA, pos, pos === endPos ? void 0 : endPos);
  24746. };
  24747. AutocompleteEditor.prototype.flipDropdownIfNeeded = function () {
  24748. var textareaOffset = (0, _element.offset)(this.TEXTAREA);
  24749. var textareaHeight = (0, _element.outerHeight)(this.TEXTAREA);
  24750. var dropdownHeight = this.getDropdownHeight();
  24751. var trimmingContainer = (0, _element.getTrimmingContainer)(this.instance.view.wt.wtTable.TABLE);
  24752. var trimmingContainerScrollTop = trimmingContainer.scrollTop;
  24753. var headersHeight = (0, _element.outerHeight)(this.instance.view.wt.wtTable.THEAD);
  24754. var containerOffset = {
  24755. row: 0,
  24756. col: 0
  24757. };
  24758. if (trimmingContainer !== window) {
  24759. containerOffset = (0, _element.offset)(trimmingContainer);
  24760. }
  24761. var spaceAbove = textareaOffset.top - containerOffset.top - headersHeight + trimmingContainerScrollTop;
  24762. var spaceBelow = trimmingContainer.scrollHeight - spaceAbove - headersHeight - textareaHeight;
  24763. var flipNeeded = dropdownHeight > spaceBelow && spaceAbove > spaceBelow;
  24764. if (flipNeeded) {
  24765. this.flipDropdown(dropdownHeight);
  24766. } else {
  24767. this.unflipDropdown();
  24768. }
  24769. this.limitDropdownIfNeeded(flipNeeded ? spaceAbove : spaceBelow, dropdownHeight);
  24770. return flipNeeded;
  24771. };
  24772. AutocompleteEditor.prototype.limitDropdownIfNeeded = function (spaceAvailable, dropdownHeight) {
  24773. if (dropdownHeight > spaceAvailable) {
  24774. var tempHeight = 0;
  24775. var i = 0;
  24776. var lastRowHeight = 0;
  24777. var height = null;
  24778. do {
  24779. lastRowHeight = this.htEditor.getRowHeight(i) || this.htEditor.view.wt.wtSettings.settings.defaultRowHeight;
  24780. tempHeight += lastRowHeight;
  24781. i++;
  24782. } while (tempHeight < spaceAvailable);
  24783. height = tempHeight - lastRowHeight;
  24784. if (this.htEditor.flipped) {
  24785. this.htEditor.rootElement.style.top = parseInt(this.htEditor.rootElement.style.top, 10) + dropdownHeight - height + 'px';
  24786. }
  24787. this.setDropdownHeight(tempHeight - lastRowHeight);
  24788. }
  24789. };
  24790. AutocompleteEditor.prototype.flipDropdown = function (dropdownHeight) {
  24791. var dropdownStyle = this.htEditor.rootElement.style;
  24792. dropdownStyle.position = 'absolute';
  24793. dropdownStyle.top = -dropdownHeight + 'px';
  24794. this.htEditor.flipped = true;
  24795. };
  24796. AutocompleteEditor.prototype.unflipDropdown = function () {
  24797. var dropdownStyle = this.htEditor.rootElement.style;
  24798. if (dropdownStyle.position === 'absolute') {
  24799. dropdownStyle.position = '';
  24800. dropdownStyle.top = '';
  24801. }
  24802. this.htEditor.flipped = void 0;
  24803. };
  24804. AutocompleteEditor.prototype.updateDropdownHeight = function () {
  24805. var currentDropdownWidth = this.htEditor.getColWidth(0) + (0, _element.getScrollbarWidth)() + 2;
  24806. var trimDropdown = this.cellProperties.trimDropdown;
  24807. this.htEditor.updateSettings({
  24808. height: this.getDropdownHeight(),
  24809. width: trimDropdown ? void 0 : currentDropdownWidth
  24810. });
  24811. this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer();
  24812. };
  24813. AutocompleteEditor.prototype.setDropdownHeight = function (height) {
  24814. this.htEditor.updateSettings({
  24815. height: height
  24816. });
  24817. };
  24818. AutocompleteEditor.prototype.finishEditing = function (restoreOriginalValue) {
  24819. if (!restoreOriginalValue) {
  24820. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  24821. }
  24822. _handsontableEditor2.default.prototype.finishEditing.apply(this, arguments);
  24823. };
  24824. AutocompleteEditor.prototype.highlightBestMatchingChoice = function (index) {
  24825. if (typeof index === 'number') {
  24826. this.htEditor.selectCell(index, 0);
  24827. } else {
  24828. this.htEditor.deselectCell();
  24829. }
  24830. };
  24831. /**
  24832. * Filters and sorts by relevance
  24833. * @param value
  24834. * @param choices
  24835. * @param caseSensitive
  24836. * @returns {Array} array of indexes in original choices array
  24837. */
  24838. AutocompleteEditor.sortByRelevance = function (value, choices, caseSensitive) {
  24839. var choicesRelevance = [];
  24840. var currentItem = void 0;
  24841. var valueLength = value.length;
  24842. var valueIndex = void 0;
  24843. var charsLeft = void 0;
  24844. var result = [];
  24845. var i = void 0;
  24846. var choicesCount = choices.length;
  24847. if (valueLength === 0) {
  24848. for (i = 0; i < choicesCount; i++) {
  24849. result.push(i);
  24850. }
  24851. return result;
  24852. }
  24853. for (i = 0; i < choicesCount; i++) {
  24854. currentItem = (0, _string.stripTags)((0, _mixed.stringify)(choices[i]));
  24855. if (caseSensitive) {
  24856. valueIndex = currentItem.indexOf(value);
  24857. } else {
  24858. valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase());
  24859. }
  24860. if (valueIndex !== -1) {
  24861. charsLeft = currentItem.length - valueIndex - valueLength;
  24862. choicesRelevance.push({
  24863. baseIndex: i,
  24864. index: valueIndex,
  24865. charsLeft: charsLeft,
  24866. value: currentItem
  24867. });
  24868. }
  24869. }
  24870. choicesRelevance.sort(function (a, b) {
  24871. if (b.index === -1) {
  24872. return -1;
  24873. }
  24874. if (a.index === -1) {
  24875. return 1;
  24876. }
  24877. if (a.index < b.index) {
  24878. return -1;
  24879. } else if (b.index < a.index) {
  24880. return 1;
  24881. } else if (a.index === b.index) {
  24882. if (a.charsLeft < b.charsLeft) {
  24883. return -1;
  24884. } else if (a.charsLeft > b.charsLeft) {
  24885. return 1;
  24886. }
  24887. }
  24888. return 0;
  24889. });
  24890. for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) {
  24891. result.push(choicesRelevance[i].baseIndex);
  24892. }
  24893. return result;
  24894. };
  24895. AutocompleteEditor.prototype.getDropdownHeight = function () {
  24896. var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23;
  24897. var visibleRows = this.cellProperties.visibleRows;
  24898. return this.strippedChoices.length >= visibleRows ? visibleRows * firstRowHeight : this.strippedChoices.length * firstRowHeight + 8;
  24899. };
  24900. AutocompleteEditor.prototype.stripValueIfNeeded = function (value) {
  24901. return this.stripValuesIfNeeded([value])[0];
  24902. };
  24903. AutocompleteEditor.prototype.stripValuesIfNeeded = function (values) {
  24904. var allowHtml = this.cellProperties.allowHtml;
  24905. var stringifiedValues = (0, _array.arrayMap)(values, function (value) {
  24906. return (0, _mixed.stringify)(value);
  24907. });
  24908. var strippedValues = (0, _array.arrayMap)(stringifiedValues, function (value) {
  24909. return allowHtml ? value : (0, _string.stripTags)(value);
  24910. });
  24911. return strippedValues;
  24912. };
  24913. AutocompleteEditor.prototype.allowKeyEventPropagation = function (keyCode) {
  24914. var selected = { row: this.htEditor.getSelectedRange() ? this.htEditor.getSelectedRange().from.row : -1 };
  24915. var allowed = false;
  24916. if (keyCode === _unicode.KEY_CODES.ARROW_DOWN && selected.row > 0 && selected.row < this.htEditor.countRows() - 1) {
  24917. allowed = true;
  24918. }
  24919. if (keyCode === _unicode.KEY_CODES.ARROW_UP && selected.row > -1) {
  24920. allowed = true;
  24921. }
  24922. return allowed;
  24923. };
  24924. AutocompleteEditor.prototype.discardEditor = function (result) {
  24925. _handsontableEditor2.default.prototype.discardEditor.apply(this, arguments);
  24926. this.instance.view.render();
  24927. };
  24928. exports.default = AutocompleteEditor;
  24929. /***/ }),
  24930. /* 264 */
  24931. /***/ (function(module, exports, __webpack_require__) {
  24932. "use strict";
  24933. exports.__esModule = true;
  24934. var _unicode = __webpack_require__(16);
  24935. var _object = __webpack_require__(1);
  24936. var _element = __webpack_require__(0);
  24937. var _event = __webpack_require__(7);
  24938. var _textEditor = __webpack_require__(44);
  24939. var _textEditor2 = _interopRequireDefault(_textEditor);
  24940. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24941. var HandsontableEditor = _textEditor2.default.prototype.extend();
  24942. /**
  24943. * @private
  24944. * @editor HandsontableEditor
  24945. * @class HandsontableEditor
  24946. * @dependencies TextEditor
  24947. */
  24948. HandsontableEditor.prototype.createElements = function () {
  24949. _textEditor2.default.prototype.createElements.apply(this, arguments);
  24950. var DIV = document.createElement('DIV');
  24951. DIV.className = 'handsontableEditor';
  24952. this.TEXTAREA_PARENT.appendChild(DIV);
  24953. this.htContainer = DIV;
  24954. this.assignHooks();
  24955. };
  24956. HandsontableEditor.prototype.prepare = function (td, row, col, prop, value, cellProperties) {
  24957. _textEditor2.default.prototype.prepare.apply(this, arguments);
  24958. var parent = this;
  24959. var options = {
  24960. startRows: 0,
  24961. startCols: 0,
  24962. minRows: 0,
  24963. minCols: 0,
  24964. className: 'listbox',
  24965. copyPaste: false,
  24966. autoColumnSize: false,
  24967. autoRowSize: false,
  24968. readOnly: true,
  24969. fillHandle: false,
  24970. afterOnCellMouseDown: function afterOnCellMouseDown(_, coords) {
  24971. var value = this.getSourceData(coords.row, coords.col);
  24972. // if the value is undefined then it means we don't want to set the value
  24973. if (value !== void 0) {
  24974. parent.setValue(value);
  24975. }
  24976. parent.instance.destroyEditor();
  24977. }
  24978. };
  24979. if (this.cellProperties.handsontable) {
  24980. (0, _object.extend)(options, cellProperties.handsontable);
  24981. }
  24982. this.htOptions = options;
  24983. };
  24984. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  24985. if ((0, _event.isImmediatePropagationStopped)(event)) {
  24986. return;
  24987. }
  24988. var editor = this.getActiveEditor();
  24989. var innerHOT = editor.htEditor.getInstance();
  24990. var rowToSelect;
  24991. var selectedRow;
  24992. if (event.keyCode == _unicode.KEY_CODES.ARROW_DOWN) {
  24993. if (!innerHOT.getSelected() && !innerHOT.flipped) {
  24994. rowToSelect = 0;
  24995. } else if (innerHOT.getSelected()) {
  24996. if (innerHOT.flipped) {
  24997. rowToSelect = innerHOT.getSelected()[0] + 1;
  24998. } else if (!innerHOT.flipped) {
  24999. selectedRow = innerHOT.getSelected()[0];
  25000. var lastRow = innerHOT.countRows() - 1;
  25001. rowToSelect = Math.min(lastRow, selectedRow + 1);
  25002. }
  25003. }
  25004. } else if (event.keyCode == _unicode.KEY_CODES.ARROW_UP) {
  25005. if (!innerHOT.getSelected() && innerHOT.flipped) {
  25006. rowToSelect = innerHOT.countRows() - 1;
  25007. } else if (innerHOT.getSelected()) {
  25008. if (innerHOT.flipped) {
  25009. selectedRow = innerHOT.getSelected()[0];
  25010. rowToSelect = Math.max(0, selectedRow - 1);
  25011. } else {
  25012. selectedRow = innerHOT.getSelected()[0];
  25013. rowToSelect = selectedRow - 1;
  25014. }
  25015. }
  25016. }
  25017. if (rowToSelect !== void 0) {
  25018. if (rowToSelect < 0 || innerHOT.flipped && rowToSelect > innerHOT.countRows() - 1) {
  25019. innerHOT.deselectCell();
  25020. } else {
  25021. innerHOT.selectCell(rowToSelect, 0);
  25022. }
  25023. if (innerHOT.getData().length) {
  25024. event.preventDefault();
  25025. (0, _event.stopImmediatePropagation)(event);
  25026. editor.instance.listen();
  25027. editor.TEXTAREA.focus();
  25028. }
  25029. }
  25030. };
  25031. HandsontableEditor.prototype.open = function () {
  25032. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  25033. _textEditor2.default.prototype.open.apply(this, arguments);
  25034. if (this.htEditor) {
  25035. this.htEditor.destroy();
  25036. }
  25037. // Construct and initialise a new Handsontable
  25038. this.htEditor = new this.instance.constructor(this.htContainer, this.htOptions);
  25039. this.htEditor.init();
  25040. if (this.cellProperties.strict) {
  25041. this.htEditor.selectCell(0, 0);
  25042. this.TEXTAREA.style.visibility = 'hidden';
  25043. } else {
  25044. this.htEditor.deselectCell();
  25045. this.TEXTAREA.style.visibility = 'visible';
  25046. }
  25047. (0, _element.setCaretPosition)(this.TEXTAREA, 0, this.TEXTAREA.value.length);
  25048. };
  25049. HandsontableEditor.prototype.close = function () {
  25050. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  25051. this.instance.listen();
  25052. _textEditor2.default.prototype.close.apply(this, arguments);
  25053. };
  25054. HandsontableEditor.prototype.focus = function () {
  25055. this.instance.listen();
  25056. _textEditor2.default.prototype.focus.apply(this, arguments);
  25057. };
  25058. HandsontableEditor.prototype.beginEditing = function (initialValue) {
  25059. var onBeginEditing = this.instance.getSettings().onBeginEditing;
  25060. if (onBeginEditing && onBeginEditing() === false) {
  25061. return;
  25062. }
  25063. _textEditor2.default.prototype.beginEditing.apply(this, arguments);
  25064. };
  25065. HandsontableEditor.prototype.finishEditing = function (isCancelled, ctrlDown) {
  25066. if (this.htEditor && this.htEditor.isListening()) {
  25067. // if focus is still in the HOT editor
  25068. this.instance.listen(); // return the focus to the parent HOT instance
  25069. }
  25070. if (this.htEditor && this.htEditor.getSelected()) {
  25071. var value = this.htEditor.getInstance().getValue();
  25072. if (value !== void 0) {
  25073. // if the value is undefined then it means we don't want to set the value
  25074. this.setValue(value);
  25075. }
  25076. }
  25077. return _textEditor2.default.prototype.finishEditing.apply(this, arguments);
  25078. };
  25079. HandsontableEditor.prototype.assignHooks = function () {
  25080. var _this = this;
  25081. this.instance.addHook('afterDestroy', function () {
  25082. if (_this.htEditor) {
  25083. _this.htEditor.destroy();
  25084. }
  25085. });
  25086. };
  25087. exports.default = HandsontableEditor;
  25088. /***/ }),
  25089. /* 265 */
  25090. /***/ (function(module, exports, __webpack_require__) {
  25091. "use strict";
  25092. exports.__esModule = true;
  25093. var _array = __webpack_require__(2);
  25094. var _object = __webpack_require__(1);
  25095. var _number = __webpack_require__(6);
  25096. var MIXIN_NAME = 'arrayMapper';
  25097. /**
  25098. * @type {Object}
  25099. */
  25100. var arrayMapper = {
  25101. _arrayMap: [],
  25102. /**
  25103. * Get value by map index.
  25104. *
  25105. * @param {Number} index Array index.
  25106. * @return {*} Returns value mapped to passed index.
  25107. */
  25108. getValueByIndex: function getValueByIndex(index) {
  25109. var value = void 0;
  25110. /* eslint-disable no-cond-assign */
  25111. return (value = this._arrayMap[index]) === void 0 ? null : value;
  25112. },
  25113. /**
  25114. * Get map index by its value.
  25115. *
  25116. * @param {*} value Value to search.
  25117. * @returns {Number} Returns array index.
  25118. */
  25119. getIndexByValue: function getIndexByValue(value) {
  25120. var index = void 0;
  25121. /* eslint-disable no-cond-assign */
  25122. return (index = this._arrayMap.indexOf(value)) === -1 ? null : index;
  25123. },
  25124. /**
  25125. * Insert new items to array mapper starting at passed index. New entries will be a continuation of last value in the array.
  25126. *
  25127. * @param {Number} index Array index.
  25128. * @param {Number} [amount=1] Defines how many items will be created to an array.
  25129. * @returns {Array} Returns added items.
  25130. */
  25131. insertItems: function insertItems(index) {
  25132. var _this = this;
  25133. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  25134. var newIndex = (0, _array.arrayMax)(this._arrayMap) + 1;
  25135. var addedItems = [];
  25136. (0, _number.rangeEach)(amount - 1, function (count) {
  25137. addedItems.push(_this._arrayMap.splice(index + count, 0, newIndex + count));
  25138. });
  25139. return addedItems;
  25140. },
  25141. /**
  25142. * Remove items from array mapper.
  25143. *
  25144. * @param {Number} index Array index.
  25145. * @param {Number} [amount=1] Defines how many items will be created to an array.
  25146. * @returns {Array} Returns removed items.
  25147. */
  25148. removeItems: function removeItems(index) {
  25149. var _this2 = this;
  25150. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  25151. var removedItems = [];
  25152. if (Array.isArray(index)) {
  25153. var mapCopy = [].concat(this._arrayMap);
  25154. // Sort descending
  25155. index.sort(function (a, b) {
  25156. return b - a;
  25157. });
  25158. removedItems = (0, _array.arrayReduce)(index, function (acc, item) {
  25159. _this2._arrayMap.splice(item, 1);
  25160. return acc.concat(mapCopy.slice(item, item + 1));
  25161. }, []);
  25162. } else {
  25163. removedItems = this._arrayMap.splice(index, amount);
  25164. }
  25165. return removedItems;
  25166. },
  25167. /**
  25168. * Unshift items (remove and shift chunk of array to the left).
  25169. *
  25170. * @param {Number|Array} index Array index or Array of indexes to unshift.
  25171. * @param {Number} [amount=1] Defines how many items will be removed from an array (when index is passed as number).
  25172. */
  25173. unshiftItems: function unshiftItems(index) {
  25174. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  25175. var removedItems = this.removeItems(index, amount);
  25176. function countRowShift(logicalRow) {
  25177. // Todo: compare perf between reduce vs sort->each->brake
  25178. return (0, _array.arrayReduce)(removedItems, function (count, removedLogicalRow) {
  25179. if (logicalRow > removedLogicalRow) {
  25180. count++;
  25181. }
  25182. return count;
  25183. }, 0);
  25184. }
  25185. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (logicalRow, physicalRow) {
  25186. var rowShift = countRowShift(logicalRow);
  25187. if (rowShift) {
  25188. logicalRow -= rowShift;
  25189. }
  25190. return logicalRow;
  25191. });
  25192. },
  25193. /**
  25194. * Shift (right shifting) items starting at passed index.
  25195. *
  25196. * @param {Number} index Array index.
  25197. * @param {Number} [amount=1] Defines how many items will be created to an array.
  25198. */
  25199. shiftItems: function shiftItems(index) {
  25200. var _this3 = this;
  25201. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  25202. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (row) {
  25203. if (row >= index) {
  25204. row += amount;
  25205. }
  25206. return row;
  25207. });
  25208. (0, _number.rangeEach)(amount - 1, function (count) {
  25209. _this3._arrayMap.splice(index + count, 0, index + count);
  25210. });
  25211. },
  25212. /**
  25213. * Clear all stored index<->value information from an array.
  25214. */
  25215. clearMap: function clearMap() {
  25216. this._arrayMap.length = 0;
  25217. }
  25218. };
  25219. (0, _object.defineGetter)(arrayMapper, 'MIXIN_NAME', MIXIN_NAME, {
  25220. writable: false,
  25221. enumerable: false
  25222. });
  25223. exports.default = arrayMapper;
  25224. /***/ }),
  25225. /* 266 */
  25226. /***/ (function(module, exports, __webpack_require__) {
  25227. "use strict";
  25228. exports.__esModule = true;
  25229. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  25230. var _number = __webpack_require__(6);
  25231. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25232. var STATE_INITIALIZED = 0;
  25233. var STATE_BUILT = 1;
  25234. var STATE_APPENDED = 2;
  25235. var UNIT = 'px';
  25236. /**
  25237. * @class
  25238. * @private
  25239. */
  25240. var BaseUI = function () {
  25241. function BaseUI(hotInstance) {
  25242. _classCallCheck(this, BaseUI);
  25243. /**
  25244. * Instance of Handsontable.
  25245. *
  25246. * @type {Core}
  25247. */
  25248. this.hot = hotInstance;
  25249. /**
  25250. * DOM element representing the ui element.
  25251. *
  25252. * @type {HTMLElement}
  25253. * @private
  25254. */
  25255. this._element = null;
  25256. /**
  25257. * Flag which determines build state of element.
  25258. *
  25259. * @type {Boolean}
  25260. */
  25261. this.state = STATE_INITIALIZED;
  25262. }
  25263. /**
  25264. * Add created UI elements to table.
  25265. *
  25266. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  25267. */
  25268. _createClass(BaseUI, [{
  25269. key: 'appendTo',
  25270. value: function appendTo(wrapper) {
  25271. wrapper.appendChild(this._element);
  25272. this.state = STATE_APPENDED;
  25273. }
  25274. /**
  25275. * Method for create UI element. Only create, without append to table.
  25276. */
  25277. }, {
  25278. key: 'build',
  25279. value: function build() {
  25280. this._element = document.createElement('div');
  25281. this.state = STATE_BUILT;
  25282. }
  25283. /**
  25284. * Method for remove UI element.
  25285. */
  25286. }, {
  25287. key: 'destroy',
  25288. value: function destroy() {
  25289. if (this.isAppended()) {
  25290. this._element.parentElement.removeChild(this._element);
  25291. }
  25292. this._element = null;
  25293. this.state = STATE_INITIALIZED;
  25294. }
  25295. /**
  25296. * Check if UI element are appended.
  25297. *
  25298. * @returns {Boolean}
  25299. */
  25300. }, {
  25301. key: 'isAppended',
  25302. value: function isAppended() {
  25303. return this.state === STATE_APPENDED;
  25304. }
  25305. /**
  25306. * Check if UI element are built.
  25307. *
  25308. * @returns {Boolean}
  25309. */
  25310. }, {
  25311. key: 'isBuilt',
  25312. value: function isBuilt() {
  25313. return this.state >= STATE_BUILT;
  25314. }
  25315. /**
  25316. * Setter for position.
  25317. *
  25318. * @param {Number} top New top position of the element.
  25319. * @param {Number} left New left position of the element.
  25320. */
  25321. }, {
  25322. key: 'setPosition',
  25323. value: function setPosition(top, left) {
  25324. if ((0, _number.isNumeric)(top)) {
  25325. this._element.style.top = top + UNIT;
  25326. }
  25327. if ((0, _number.isNumeric)(left)) {
  25328. this._element.style.left = left + UNIT;
  25329. }
  25330. }
  25331. /**
  25332. * Getter for the element position.
  25333. *
  25334. * @returns {Object} Object contains left and top position of the element.
  25335. */
  25336. }, {
  25337. key: 'getPosition',
  25338. value: function getPosition() {
  25339. return {
  25340. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  25341. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  25342. };
  25343. }
  25344. /**
  25345. * Setter for the element size.
  25346. *
  25347. * @param {Number} width New width of the element.
  25348. * @param {Number} height New height of the element.
  25349. */
  25350. }, {
  25351. key: 'setSize',
  25352. value: function setSize(width, height) {
  25353. if ((0, _number.isNumeric)(width)) {
  25354. this._element.style.width = width + UNIT;
  25355. }
  25356. if ((0, _number.isNumeric)(height)) {
  25357. this._element.style.height = height + UNIT;
  25358. }
  25359. }
  25360. /**
  25361. * Getter for the element position.
  25362. *
  25363. * @returns {Object} Object contains height and width of the element.
  25364. */
  25365. }, {
  25366. key: 'getSize',
  25367. value: function getSize() {
  25368. return {
  25369. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  25370. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  25371. };
  25372. }
  25373. /**
  25374. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  25375. *
  25376. * @param {Number} top New margin top of the element.
  25377. * @param {Number} left New margin left of the element.
  25378. */
  25379. }, {
  25380. key: 'setOffset',
  25381. value: function setOffset(top, left) {
  25382. if ((0, _number.isNumeric)(top)) {
  25383. this._element.style.marginTop = top + UNIT;
  25384. }
  25385. if ((0, _number.isNumeric)(left)) {
  25386. this._element.style.marginLeft = left + UNIT;
  25387. }
  25388. }
  25389. /**
  25390. * Getter for the element offset.
  25391. *
  25392. * @returns {Object} Object contains top and left offset of the element.
  25393. */
  25394. }, {
  25395. key: 'getOffset',
  25396. value: function getOffset() {
  25397. return {
  25398. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  25399. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  25400. };
  25401. }
  25402. }]);
  25403. return BaseUI;
  25404. }();
  25405. exports.default = BaseUI;
  25406. /***/ }),
  25407. /* 267 */
  25408. /***/ (function(module, exports, __webpack_require__) {
  25409. "use strict";
  25410. exports.__esModule = true;
  25411. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  25412. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25413. var STATE_INITIALIZED = 0;
  25414. var STATE_BUILT = 1;
  25415. var STATE_APPENDED = 2;
  25416. var UNIT = 'px';
  25417. /**
  25418. * @class
  25419. * @private
  25420. */
  25421. var BaseUI = function () {
  25422. function BaseUI(hotInstance) {
  25423. _classCallCheck(this, BaseUI);
  25424. /**
  25425. * Instance of Handsontable.
  25426. *
  25427. * @type {Core}
  25428. */
  25429. this.hot = hotInstance;
  25430. /**
  25431. * DOM element representing the ui element.
  25432. *
  25433. * @type {HTMLElement}
  25434. * @private
  25435. */
  25436. this._element = null;
  25437. /**
  25438. * Flag which determines build state of element.
  25439. *
  25440. * @type {Boolean}
  25441. */
  25442. this.state = STATE_INITIALIZED;
  25443. }
  25444. /**
  25445. * Add created UI elements to table.
  25446. *
  25447. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  25448. */
  25449. _createClass(BaseUI, [{
  25450. key: 'appendTo',
  25451. value: function appendTo(wrapper) {
  25452. wrapper.appendChild(this._element);
  25453. this.state = STATE_APPENDED;
  25454. }
  25455. /**
  25456. * Method for create UI element. Only create, without append to table.
  25457. */
  25458. }, {
  25459. key: 'build',
  25460. value: function build() {
  25461. this._element = document.createElement('div');
  25462. this.state = STATE_BUILT;
  25463. }
  25464. /**
  25465. * Method for remove UI element.
  25466. */
  25467. }, {
  25468. key: 'destroy',
  25469. value: function destroy() {
  25470. if (this.isAppended()) {
  25471. this._element.parentElement.removeChild(this._element);
  25472. }
  25473. this._element = null;
  25474. this.state = STATE_INITIALIZED;
  25475. }
  25476. /**
  25477. * Check if UI element are appended.
  25478. *
  25479. * @returns {Boolean}
  25480. */
  25481. }, {
  25482. key: 'isAppended',
  25483. value: function isAppended() {
  25484. return this.state === STATE_APPENDED;
  25485. }
  25486. /**
  25487. * Check if UI element are built.
  25488. *
  25489. * @returns {Boolean}
  25490. */
  25491. }, {
  25492. key: 'isBuilt',
  25493. value: function isBuilt() {
  25494. return this.state >= STATE_BUILT;
  25495. }
  25496. /**
  25497. * Setter for position.
  25498. *
  25499. * @param {Number} top New top position of the element.
  25500. * @param {Number} left New left position of the element.
  25501. */
  25502. }, {
  25503. key: 'setPosition',
  25504. value: function setPosition(top, left) {
  25505. if (top) {
  25506. this._element.style.top = top + UNIT;
  25507. }
  25508. if (left) {
  25509. this._element.style.left = left + UNIT;
  25510. }
  25511. }
  25512. /**
  25513. * Getter for the element position.
  25514. *
  25515. * @returns {Object} Object contains left and top position of the element.
  25516. */
  25517. }, {
  25518. key: 'getPosition',
  25519. value: function getPosition() {
  25520. return {
  25521. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  25522. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  25523. };
  25524. }
  25525. /**
  25526. * Setter for the element size.
  25527. *
  25528. * @param {Number} width New width of the element.
  25529. * @param {Number} height New height of the element.
  25530. */
  25531. }, {
  25532. key: 'setSize',
  25533. value: function setSize(width, height) {
  25534. if (width) {
  25535. this._element.style.width = width + UNIT;
  25536. }
  25537. if (height) {
  25538. this._element.style.height = height + UNIT;
  25539. }
  25540. }
  25541. /**
  25542. * Getter for the element position.
  25543. *
  25544. * @returns {Object} Object contains height and width of the element.
  25545. */
  25546. }, {
  25547. key: 'getSize',
  25548. value: function getSize() {
  25549. return {
  25550. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  25551. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  25552. };
  25553. }
  25554. /**
  25555. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  25556. *
  25557. * @param {Number} top New margin top of the element.
  25558. * @param {Number} left New margin left of the element.
  25559. */
  25560. }, {
  25561. key: 'setOffset',
  25562. value: function setOffset(top, left) {
  25563. if (top) {
  25564. this._element.style.marginTop = top + UNIT;
  25565. }
  25566. if (left) {
  25567. this._element.style.marginLeft = left + UNIT;
  25568. }
  25569. }
  25570. /**
  25571. * Getter for the element offset.
  25572. *
  25573. * @returns {Object} Object contains top and left offset of the element.
  25574. */
  25575. }, {
  25576. key: 'getOffset',
  25577. value: function getOffset() {
  25578. return {
  25579. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  25580. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  25581. };
  25582. }
  25583. }]);
  25584. return BaseUI;
  25585. }();
  25586. exports.default = BaseUI;
  25587. /***/ }),
  25588. /* 268 */
  25589. /***/ (function(module, exports, __webpack_require__) {
  25590. "use strict";
  25591. exports.__esModule = true;
  25592. exports.RecordTranslator = undefined;
  25593. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  25594. exports.registerIdentity = registerIdentity;
  25595. exports.getTranslator = getTranslator;
  25596. var _core = __webpack_require__(64);
  25597. var _core2 = _interopRequireDefault(_core);
  25598. var _object = __webpack_require__(1);
  25599. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25600. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25601. /**
  25602. * @class RecordTranslator
  25603. * @util
  25604. */
  25605. var RecordTranslator = function () {
  25606. function RecordTranslator(hot) {
  25607. _classCallCheck(this, RecordTranslator);
  25608. this.hot = hot;
  25609. }
  25610. /**
  25611. * Translate physical row index into visual.
  25612. *
  25613. * @param {Number} row Physical row index.
  25614. * @returns {Number} Returns visual row index.
  25615. */
  25616. _createClass(RecordTranslator, [{
  25617. key: 'toVisualRow',
  25618. value: function toVisualRow(row) {
  25619. return this.hot.runHooks('unmodifyRow', row);
  25620. }
  25621. /**
  25622. * Translate physical column index into visual.
  25623. *
  25624. * @param {Number} column Physical column index.
  25625. * @returns {Number} Returns visual column index.
  25626. */
  25627. }, {
  25628. key: 'toVisualColumn',
  25629. value: function toVisualColumn(column) {
  25630. return this.hot.runHooks('unmodifyCol', column);
  25631. }
  25632. /**
  25633. * Translate physical coordinates into visual. Can be passed as separate 2 arguments (row, column) or as an object in first
  25634. * argument with `row` and `column` keys.
  25635. *
  25636. * @param {Number|Object} row Physical coordinates or row index.
  25637. * @param {Number} [column] Physical column index.
  25638. * @returns {Object|Array} Returns an object with visual records or an array if coordinates passed as separate arguments.
  25639. */
  25640. }, {
  25641. key: 'toVisual',
  25642. value: function toVisual(row, column) {
  25643. var result = void 0;
  25644. if ((0, _object.isObject)(row)) {
  25645. result = {
  25646. row: this.toVisualRow(row.row),
  25647. column: this.toVisualColumn(row.column)
  25648. };
  25649. } else {
  25650. result = [this.toVisualRow(row), this.toVisualColumn(column)];
  25651. }
  25652. return result;
  25653. }
  25654. /**
  25655. * Translate visual row index into physical.
  25656. *
  25657. * @param {Number} row Visual row index.
  25658. * @returns {Number} Returns physical row index.
  25659. */
  25660. }, {
  25661. key: 'toPhysicalRow',
  25662. value: function toPhysicalRow(row) {
  25663. return this.hot.runHooks('modifyRow', row);
  25664. }
  25665. /**
  25666. * Translate visual column index into physical.
  25667. *
  25668. * @param {Number} column Visual column index.
  25669. * @returns {Number} Returns physical column index.
  25670. */
  25671. }, {
  25672. key: 'toPhysicalColumn',
  25673. value: function toPhysicalColumn(column) {
  25674. return this.hot.runHooks('modifyCol', column);
  25675. }
  25676. /**
  25677. * Translate visual coordinates into physical. Can be passed as separate 2 arguments (row, column) or as an object in first
  25678. * argument with `row` and `column` keys.
  25679. *
  25680. * @param {Number|Object} row Visual coordinates or row index.
  25681. * @param {Number} [column] Visual column index.
  25682. * @returns {Object|Array} Returns an object with physical records or an array if coordinates passed as separate arguments.
  25683. */
  25684. }, {
  25685. key: 'toPhysical',
  25686. value: function toPhysical(row, column) {
  25687. var result = void 0;
  25688. if ((0, _object.isObject)(row)) {
  25689. result = {
  25690. row: this.toPhysicalRow(row.row),
  25691. column: this.toPhysicalColumn(row.column)
  25692. };
  25693. } else {
  25694. result = [this.toPhysicalRow(row), this.toPhysicalColumn(column)];
  25695. }
  25696. return result;
  25697. }
  25698. }]);
  25699. return RecordTranslator;
  25700. }();
  25701. exports.RecordTranslator = RecordTranslator;
  25702. var identities = new WeakMap();
  25703. var translatorSingletons = new WeakMap();
  25704. function registerIdentity(identity, hot) {
  25705. identities.set(identity, hot);
  25706. }
  25707. function getTranslator(identity) {
  25708. var singleton = void 0;
  25709. if (!(identity instanceof _core2.default)) {
  25710. if (!identities.has(identity)) {
  25711. throw Error('Record translator was not registered for this object identity');
  25712. }
  25713. identity = identities.get(identity);
  25714. }
  25715. if (translatorSingletons.has(identity)) {
  25716. singleton = translatorSingletons.get(identity);
  25717. } else {
  25718. singleton = new RecordTranslator(identity);
  25719. translatorSingletons.set(identity, singleton);
  25720. }
  25721. return singleton;
  25722. }
  25723. /***/ }),
  25724. /* 269 */
  25725. /***/ (function(module, exports, __webpack_require__) {
  25726. "use strict";
  25727. exports.__esModule = true;
  25728. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  25729. var _object = __webpack_require__(1);
  25730. var _number = __webpack_require__(6);
  25731. var _mixed = __webpack_require__(20);
  25732. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  25733. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25734. /**
  25735. * @class SamplesGenerator
  25736. * @util
  25737. */
  25738. var SamplesGenerator = function () {
  25739. _createClass(SamplesGenerator, null, [{
  25740. key: 'SAMPLE_COUNT',
  25741. /**
  25742. * Number of samples to take of each value length.
  25743. *
  25744. * @type {Number}
  25745. */
  25746. get: function get() {
  25747. return 3;
  25748. }
  25749. }]);
  25750. function SamplesGenerator(dataFactory) {
  25751. _classCallCheck(this, SamplesGenerator);
  25752. /**
  25753. * Samples prepared for calculations.
  25754. *
  25755. * @type {Map}
  25756. * @default {null}
  25757. */
  25758. this.samples = null;
  25759. /**
  25760. * Function which give the data to collect samples.
  25761. *
  25762. * @type {Function}
  25763. */
  25764. this.dataFactory = dataFactory;
  25765. /**
  25766. * Custom number of samples to take of each value length.
  25767. *
  25768. * @type {Number}
  25769. * @default {null}
  25770. */
  25771. this.customSampleCount = null;
  25772. /**
  25773. * `true` if duplicate samples collection should be allowed, `false` otherwise.
  25774. *
  25775. * @type {Boolean}
  25776. * @default {false}
  25777. */
  25778. this.allowDuplicates = false;
  25779. }
  25780. /**
  25781. * Get the sample count for this instance.
  25782. *
  25783. * @returns {Number}
  25784. */
  25785. _createClass(SamplesGenerator, [{
  25786. key: 'getSampleCount',
  25787. value: function getSampleCount() {
  25788. if (this.customSampleCount) {
  25789. return this.customSampleCount;
  25790. }
  25791. return SamplesGenerator.SAMPLE_COUNT;
  25792. }
  25793. }, {
  25794. key: 'setSampleCount',
  25795. /**
  25796. * Set the sample count.
  25797. *
  25798. * @param {Number} sampleCount Number of samples to be collected.
  25799. */
  25800. value: function setSampleCount(sampleCount) {
  25801. this.customSampleCount = sampleCount;
  25802. }
  25803. /**
  25804. * Set if the generator should accept duplicate values.
  25805. *
  25806. * @param {Boolean} allowDuplicates `true` to allow duplicate values.
  25807. */
  25808. }, {
  25809. key: 'setAllowDuplicates',
  25810. value: function setAllowDuplicates(allowDuplicates) {
  25811. this.allowDuplicates = allowDuplicates;
  25812. }
  25813. /**
  25814. * Generate samples for row. You can control which area should be sampled by passing `rowRange` object and `colRange` object.
  25815. *
  25816. * @param {Object|Number} rowRange
  25817. * @param {Object} colRange
  25818. * @returns {Object}
  25819. */
  25820. }, {
  25821. key: 'generateRowSamples',
  25822. value: function generateRowSamples(rowRange, colRange) {
  25823. return this.generateSamples('row', colRange, rowRange);
  25824. }
  25825. /**
  25826. * Generate samples for column. You can control which area should be sampled by passing `colRange` object and `rowRange` object.
  25827. *
  25828. * @param {Object} colRange Column index.
  25829. * @param {Object} rowRange Column index.
  25830. * @returns {Object}
  25831. */
  25832. }, {
  25833. key: 'generateColumnSamples',
  25834. value: function generateColumnSamples(colRange, rowRange) {
  25835. return this.generateSamples('col', rowRange, colRange);
  25836. }
  25837. /**
  25838. * Generate collection of samples.
  25839. *
  25840. * @param {String} type Type to generate. Can be `col` or `row`.
  25841. * @param {Object} range
  25842. * @param {Object|Number} specifierRange
  25843. * @returns {Map}
  25844. */
  25845. }, {
  25846. key: 'generateSamples',
  25847. value: function generateSamples(type, range, specifierRange) {
  25848. var _this = this;
  25849. var samples = new Map();
  25850. if (typeof specifierRange === 'number') {
  25851. specifierRange = { from: specifierRange, to: specifierRange };
  25852. }
  25853. (0, _number.rangeEach)(specifierRange.from, specifierRange.to, function (index) {
  25854. var sample = _this.generateSample(type, range, index);
  25855. samples.set(index, sample);
  25856. });
  25857. return samples;
  25858. }
  25859. /**
  25860. * Generate sample for specified type (`row` or `col`).
  25861. *
  25862. * @param {String} type Samples type `row` or `col`.
  25863. * @param {Object} range
  25864. * @param {Number} specifierValue
  25865. * @returns {Map}
  25866. */
  25867. }, {
  25868. key: 'generateSample',
  25869. value: function generateSample(type, range, specifierValue) {
  25870. var _this2 = this;
  25871. var samples = new Map();
  25872. var sampledValues = [];
  25873. var length = void 0;
  25874. (0, _number.rangeEach)(range.from, range.to, function (index) {
  25875. var value = void 0;
  25876. if (type === 'row') {
  25877. value = _this2.dataFactory(specifierValue, index);
  25878. } else if (type === 'col') {
  25879. value = _this2.dataFactory(index, specifierValue);
  25880. } else {
  25881. throw new Error('Unsupported sample type');
  25882. }
  25883. if ((0, _object.isObject)(value)) {
  25884. length = Object.keys(value).length;
  25885. } else if (Array.isArray(value)) {
  25886. length = value.length;
  25887. } else {
  25888. length = (0, _mixed.stringify)(value).length;
  25889. }
  25890. if (!samples.has(length)) {
  25891. samples.set(length, {
  25892. needed: _this2.getSampleCount(),
  25893. strings: []
  25894. });
  25895. }
  25896. var sample = samples.get(length);
  25897. if (sample.needed) {
  25898. var duplicate = sampledValues.indexOf(value) > -1;
  25899. if (!duplicate || _this2.allowDuplicates) {
  25900. var computedKey = type === 'row' ? 'col' : 'row';
  25901. sample.strings.push(_defineProperty({ value: value }, computedKey, index));
  25902. sampledValues.push(value);
  25903. sample.needed--;
  25904. }
  25905. }
  25906. });
  25907. return samples;
  25908. }
  25909. }]);
  25910. return SamplesGenerator;
  25911. }();
  25912. exports.default = SamplesGenerator;
  25913. /***/ }),
  25914. /* 270 */
  25915. /***/ (function(module, exports, __webpack_require__) {
  25916. // false -> Array#indexOf
  25917. // true -> Array#includes
  25918. var toIObject = __webpack_require__(23)
  25919. , toLength = __webpack_require__(24)
  25920. , toIndex = __webpack_require__(61);
  25921. module.exports = function(IS_INCLUDES){
  25922. return function($this, el, fromIndex){
  25923. var O = toIObject($this)
  25924. , length = toLength(O.length)
  25925. , index = toIndex(fromIndex, length)
  25926. , value;
  25927. // Array#includes uses SameValueZero equality algorithm
  25928. if(IS_INCLUDES && el != el)while(length > index){
  25929. value = O[index++];
  25930. if(value != value)return true;
  25931. // Array#toIndex ignores holes, Array#includes - not
  25932. } else for(;length > index; index++)if(IS_INCLUDES || index in O){
  25933. if(O[index] === el)return IS_INCLUDES || index || 0;
  25934. } return !IS_INCLUDES && -1;
  25935. };
  25936. };
  25937. /***/ }),
  25938. /* 271 */
  25939. /***/ (function(module, exports, __webpack_require__) {
  25940. // getting tag from 19.1.3.6 Object.prototype.toString()
  25941. var cof = __webpack_require__(39)
  25942. , TAG = __webpack_require__(10)('toStringTag')
  25943. // ES3 wrong here
  25944. , ARG = cof(function(){ return arguments; }()) == 'Arguments';
  25945. // fallback for IE11 Script Access Denied error
  25946. var tryGet = function(it, key){
  25947. try {
  25948. return it[key];
  25949. } catch(e){ /* empty */ }
  25950. };
  25951. module.exports = function(it){
  25952. var O, T, B;
  25953. return it === undefined ? 'Undefined' : it === null ? 'Null'
  25954. // @@toStringTag case
  25955. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  25956. // builtinTag case
  25957. : ARG ? cof(O)
  25958. // ES3 arguments fallback
  25959. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  25960. };
  25961. /***/ }),
  25962. /* 272 */
  25963. /***/ (function(module, exports, __webpack_require__) {
  25964. "use strict";
  25965. var dP = __webpack_require__(19).f
  25966. , create = __webpack_require__(80)
  25967. , redefineAll = __webpack_require__(60)
  25968. , ctx = __webpack_require__(29)
  25969. , anInstance = __webpack_require__(53)
  25970. , defined = __webpack_require__(30)
  25971. , forOf = __webpack_require__(57)
  25972. , $iterDefine = __webpack_require__(281)
  25973. , step = __webpack_require__(282)
  25974. , setSpecies = __webpack_require__(287)
  25975. , DESCRIPTORS = __webpack_require__(21)
  25976. , fastKey = __webpack_require__(47).fastKey
  25977. , SIZE = DESCRIPTORS ? '_s' : 'size';
  25978. var getEntry = function(that, key){
  25979. // fast case
  25980. var index = fastKey(key), entry;
  25981. if(index !== 'F')return that._i[index];
  25982. // frozen object case
  25983. for(entry = that._f; entry; entry = entry.n){
  25984. if(entry.k == key)return entry;
  25985. }
  25986. };
  25987. module.exports = {
  25988. getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
  25989. var C = wrapper(function(that, iterable){
  25990. anInstance(that, C, NAME, '_i');
  25991. that._i = create(null); // index
  25992. that._f = undefined; // first entry
  25993. that._l = undefined; // last entry
  25994. that[SIZE] = 0; // size
  25995. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  25996. });
  25997. redefineAll(C.prototype, {
  25998. // 23.1.3.1 Map.prototype.clear()
  25999. // 23.2.3.2 Set.prototype.clear()
  26000. clear: function clear(){
  26001. for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){
  26002. entry.r = true;
  26003. if(entry.p)entry.p = entry.p.n = undefined;
  26004. delete data[entry.i];
  26005. }
  26006. that._f = that._l = undefined;
  26007. that[SIZE] = 0;
  26008. },
  26009. // 23.1.3.3 Map.prototype.delete(key)
  26010. // 23.2.3.4 Set.prototype.delete(value)
  26011. 'delete': function(key){
  26012. var that = this
  26013. , entry = getEntry(that, key);
  26014. if(entry){
  26015. var next = entry.n
  26016. , prev = entry.p;
  26017. delete that._i[entry.i];
  26018. entry.r = true;
  26019. if(prev)prev.n = next;
  26020. if(next)next.p = prev;
  26021. if(that._f == entry)that._f = next;
  26022. if(that._l == entry)that._l = prev;
  26023. that[SIZE]--;
  26024. } return !!entry;
  26025. },
  26026. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  26027. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  26028. forEach: function forEach(callbackfn /*, that = undefined */){
  26029. anInstance(this, C, 'forEach');
  26030. var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3)
  26031. , entry;
  26032. while(entry = entry ? entry.n : this._f){
  26033. f(entry.v, entry.k, this);
  26034. // revert to the last existing entry
  26035. while(entry && entry.r)entry = entry.p;
  26036. }
  26037. },
  26038. // 23.1.3.7 Map.prototype.has(key)
  26039. // 23.2.3.7 Set.prototype.has(value)
  26040. has: function has(key){
  26041. return !!getEntry(this, key);
  26042. }
  26043. });
  26044. if(DESCRIPTORS)dP(C.prototype, 'size', {
  26045. get: function(){
  26046. return defined(this[SIZE]);
  26047. }
  26048. });
  26049. return C;
  26050. },
  26051. def: function(that, key, value){
  26052. var entry = getEntry(that, key)
  26053. , prev, index;
  26054. // change existing entry
  26055. if(entry){
  26056. entry.v = value;
  26057. // create new entry
  26058. } else {
  26059. that._l = entry = {
  26060. i: index = fastKey(key, true), // <- index
  26061. k: key, // <- key
  26062. v: value, // <- value
  26063. p: prev = that._l, // <- previous entry
  26064. n: undefined, // <- next entry
  26065. r: false // <- removed
  26066. };
  26067. if(!that._f)that._f = entry;
  26068. if(prev)prev.n = entry;
  26069. that[SIZE]++;
  26070. // add to index
  26071. if(index !== 'F')that._i[index] = entry;
  26072. } return that;
  26073. },
  26074. getEntry: getEntry,
  26075. setStrong: function(C, NAME, IS_MAP){
  26076. // add .keys, .values, .entries, [@@iterator]
  26077. // 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
  26078. $iterDefine(C, NAME, function(iterated, kind){
  26079. this._t = iterated; // target
  26080. this._k = kind; // kind
  26081. this._l = undefined; // previous
  26082. }, function(){
  26083. var that = this
  26084. , kind = that._k
  26085. , entry = that._l;
  26086. // revert to the last existing entry
  26087. while(entry && entry.r)entry = entry.p;
  26088. // get next entry
  26089. if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){
  26090. // or finish the iteration
  26091. that._t = undefined;
  26092. return step(1);
  26093. }
  26094. // return step by kind
  26095. if(kind == 'keys' )return step(0, entry.k);
  26096. if(kind == 'values')return step(0, entry.v);
  26097. return step(0, [entry.k, entry.v]);
  26098. }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
  26099. // add [@@species], 23.1.2.2, 23.2.2.2
  26100. setSpecies(NAME);
  26101. }
  26102. };
  26103. /***/ }),
  26104. /* 273 */
  26105. /***/ (function(module, exports, __webpack_require__) {
  26106. "use strict";
  26107. var redefineAll = __webpack_require__(60)
  26108. , getWeak = __webpack_require__(47).getWeak
  26109. , anObject = __webpack_require__(18)
  26110. , isObject = __webpack_require__(15)
  26111. , anInstance = __webpack_require__(53)
  26112. , forOf = __webpack_require__(57)
  26113. , createArrayMethod = __webpack_require__(54)
  26114. , $has = __webpack_require__(22)
  26115. , arrayFind = createArrayMethod(5)
  26116. , arrayFindIndex = createArrayMethod(6)
  26117. , id = 0;
  26118. // fallback for uncaught frozen keys
  26119. var uncaughtFrozenStore = function(that){
  26120. return that._l || (that._l = new UncaughtFrozenStore);
  26121. };
  26122. var UncaughtFrozenStore = function(){
  26123. this.a = [];
  26124. };
  26125. var findUncaughtFrozen = function(store, key){
  26126. return arrayFind(store.a, function(it){
  26127. return it[0] === key;
  26128. });
  26129. };
  26130. UncaughtFrozenStore.prototype = {
  26131. get: function(key){
  26132. var entry = findUncaughtFrozen(this, key);
  26133. if(entry)return entry[1];
  26134. },
  26135. has: function(key){
  26136. return !!findUncaughtFrozen(this, key);
  26137. },
  26138. set: function(key, value){
  26139. var entry = findUncaughtFrozen(this, key);
  26140. if(entry)entry[1] = value;
  26141. else this.a.push([key, value]);
  26142. },
  26143. 'delete': function(key){
  26144. var index = arrayFindIndex(this.a, function(it){
  26145. return it[0] === key;
  26146. });
  26147. if(~index)this.a.splice(index, 1);
  26148. return !!~index;
  26149. }
  26150. };
  26151. module.exports = {
  26152. getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
  26153. var C = wrapper(function(that, iterable){
  26154. anInstance(that, C, NAME, '_i');
  26155. that._i = id++; // collection id
  26156. that._l = undefined; // leak store for uncaught frozen objects
  26157. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  26158. });
  26159. redefineAll(C.prototype, {
  26160. // 23.3.3.2 WeakMap.prototype.delete(key)
  26161. // 23.4.3.3 WeakSet.prototype.delete(value)
  26162. 'delete': function(key){
  26163. if(!isObject(key))return false;
  26164. var data = getWeak(key);
  26165. if(data === true)return uncaughtFrozenStore(this)['delete'](key);
  26166. return data && $has(data, this._i) && delete data[this._i];
  26167. },
  26168. // 23.3.3.4 WeakMap.prototype.has(key)
  26169. // 23.4.3.4 WeakSet.prototype.has(value)
  26170. has: function has(key){
  26171. if(!isObject(key))return false;
  26172. var data = getWeak(key);
  26173. if(data === true)return uncaughtFrozenStore(this).has(key);
  26174. return data && $has(data, this._i);
  26175. }
  26176. });
  26177. return C;
  26178. },
  26179. def: function(that, key, value){
  26180. var data = getWeak(anObject(key), true);
  26181. if(data === true)uncaughtFrozenStore(that).set(key, value);
  26182. else data[that._i] = value;
  26183. return that;
  26184. },
  26185. ufstore: uncaughtFrozenStore
  26186. };
  26187. /***/ }),
  26188. /* 274 */
  26189. /***/ (function(module, exports, __webpack_require__) {
  26190. module.exports = __webpack_require__(13).document && document.documentElement;
  26191. /***/ }),
  26192. /* 275 */
  26193. /***/ (function(module, exports, __webpack_require__) {
  26194. module.exports = !__webpack_require__(21) && !__webpack_require__(31)(function(){
  26195. return Object.defineProperty(__webpack_require__(75)('div'), 'a', {get: function(){ return 7; }}).a != 7;
  26196. });
  26197. /***/ }),
  26198. /* 276 */
  26199. /***/ (function(module, exports, __webpack_require__) {
  26200. // check on default Array iterator
  26201. var Iterators = __webpack_require__(46)
  26202. , ITERATOR = __webpack_require__(10)('iterator')
  26203. , ArrayProto = Array.prototype;
  26204. module.exports = function(it){
  26205. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  26206. };
  26207. /***/ }),
  26208. /* 277 */
  26209. /***/ (function(module, exports, __webpack_require__) {
  26210. // 7.2.2 IsArray(argument)
  26211. var cof = __webpack_require__(39);
  26212. module.exports = Array.isArray || function isArray(arg){
  26213. return cof(arg) == 'Array';
  26214. };
  26215. /***/ }),
  26216. /* 278 */
  26217. /***/ (function(module, exports, __webpack_require__) {
  26218. // 20.1.2.3 Number.isInteger(number)
  26219. var isObject = __webpack_require__(15)
  26220. , floor = Math.floor;
  26221. module.exports = function isInteger(it){
  26222. return !isObject(it) && isFinite(it) && floor(it) === it;
  26223. };
  26224. /***/ }),
  26225. /* 279 */
  26226. /***/ (function(module, exports, __webpack_require__) {
  26227. // 7.2.8 IsRegExp(argument)
  26228. var isObject = __webpack_require__(15)
  26229. , cof = __webpack_require__(39)
  26230. , MATCH = __webpack_require__(10)('match');
  26231. module.exports = function(it){
  26232. var isRegExp;
  26233. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  26234. };
  26235. /***/ }),
  26236. /* 280 */
  26237. /***/ (function(module, exports, __webpack_require__) {
  26238. // call something on iterator step with safe closing on error
  26239. var anObject = __webpack_require__(18);
  26240. module.exports = function(iterator, fn, value, entries){
  26241. try {
  26242. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  26243. // 7.4.6 IteratorClose(iterator, completion)
  26244. } catch(e){
  26245. var ret = iterator['return'];
  26246. if(ret !== undefined)anObject(ret.call(iterator));
  26247. throw e;
  26248. }
  26249. };
  26250. /***/ }),
  26251. /* 281 */
  26252. /***/ (function(module, exports, __webpack_require__) {
  26253. "use strict";
  26254. var LIBRARY = __webpack_require__(58)
  26255. , $export = __webpack_require__(3)
  26256. , redefine = __webpack_require__(33)
  26257. , hide = __webpack_require__(32)
  26258. , has = __webpack_require__(22)
  26259. , Iterators = __webpack_require__(46)
  26260. , $iterCreate = __webpack_require__(400)
  26261. , setToStringTag = __webpack_require__(49)
  26262. , getPrototypeOf = __webpack_require__(405)
  26263. , ITERATOR = __webpack_require__(10)('iterator')
  26264. , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
  26265. , FF_ITERATOR = '@@iterator'
  26266. , KEYS = 'keys'
  26267. , VALUES = 'values';
  26268. var returnThis = function(){ return this; };
  26269. module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
  26270. $iterCreate(Constructor, NAME, next);
  26271. var getMethod = function(kind){
  26272. if(!BUGGY && kind in proto)return proto[kind];
  26273. switch(kind){
  26274. case KEYS: return function keys(){ return new Constructor(this, kind); };
  26275. case VALUES: return function values(){ return new Constructor(this, kind); };
  26276. } return function entries(){ return new Constructor(this, kind); };
  26277. };
  26278. var TAG = NAME + ' Iterator'
  26279. , DEF_VALUES = DEFAULT == VALUES
  26280. , VALUES_BUG = false
  26281. , proto = Base.prototype
  26282. , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
  26283. , $default = $native || getMethod(DEFAULT)
  26284. , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
  26285. , $anyNative = NAME == 'Array' ? proto.entries || $native : $native
  26286. , methods, key, IteratorPrototype;
  26287. // Fix native
  26288. if($anyNative){
  26289. IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
  26290. if(IteratorPrototype !== Object.prototype){
  26291. // Set @@toStringTag to native iterators
  26292. setToStringTag(IteratorPrototype, TAG, true);
  26293. // fix for some old engines
  26294. if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
  26295. }
  26296. }
  26297. // fix Array#{values, @@iterator}.name in V8 / FF
  26298. if(DEF_VALUES && $native && $native.name !== VALUES){
  26299. VALUES_BUG = true;
  26300. $default = function values(){ return $native.call(this); };
  26301. }
  26302. // Define iterator
  26303. if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
  26304. hide(proto, ITERATOR, $default);
  26305. }
  26306. // Plug for library
  26307. Iterators[NAME] = $default;
  26308. Iterators[TAG] = returnThis;
  26309. if(DEFAULT){
  26310. methods = {
  26311. values: DEF_VALUES ? $default : getMethod(VALUES),
  26312. keys: IS_SET ? $default : getMethod(KEYS),
  26313. entries: $entries
  26314. };
  26315. if(FORCED)for(key in methods){
  26316. if(!(key in proto))redefine(proto, key, methods[key]);
  26317. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  26318. }
  26319. return methods;
  26320. };
  26321. /***/ }),
  26322. /* 282 */
  26323. /***/ (function(module, exports) {
  26324. module.exports = function(done, value){
  26325. return {value: value, done: !!done};
  26326. };
  26327. /***/ }),
  26328. /* 283 */
  26329. /***/ (function(module, exports, __webpack_require__) {
  26330. "use strict";
  26331. // 19.1.2.1 Object.assign(target, source, ...)
  26332. var getKeys = __webpack_require__(40)
  26333. , gOPS = __webpack_require__(59)
  26334. , pIE = __webpack_require__(48)
  26335. , toObject = __webpack_require__(42)
  26336. , IObject = __webpack_require__(78)
  26337. , $assign = Object.assign;
  26338. // should work with symbols and should have deterministic property order (V8 bug)
  26339. module.exports = !$assign || __webpack_require__(31)(function(){
  26340. var A = {}
  26341. , B = {}
  26342. , S = Symbol()
  26343. , K = 'abcdefghijklmnopqrst';
  26344. A[S] = 7;
  26345. K.split('').forEach(function(k){ B[k] = k; });
  26346. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  26347. }) ? function assign(target, source){ // eslint-disable-line no-unused-vars
  26348. var T = toObject(target)
  26349. , aLen = arguments.length
  26350. , index = 1
  26351. , getSymbols = gOPS.f
  26352. , isEnum = pIE.f;
  26353. while(aLen > index){
  26354. var S = IObject(arguments[index++])
  26355. , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)
  26356. , length = keys.length
  26357. , j = 0
  26358. , key;
  26359. while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key];
  26360. } return T;
  26361. } : $assign;
  26362. /***/ }),
  26363. /* 284 */
  26364. /***/ (function(module, exports, __webpack_require__) {
  26365. var has = __webpack_require__(22)
  26366. , toIObject = __webpack_require__(23)
  26367. , arrayIndexOf = __webpack_require__(270)(false)
  26368. , IE_PROTO = __webpack_require__(83)('IE_PROTO');
  26369. module.exports = function(object, names){
  26370. var O = toIObject(object)
  26371. , i = 0
  26372. , result = []
  26373. , key;
  26374. for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
  26375. // Don't enum bug & hidden keys
  26376. while(names.length > i)if(has(O, key = names[i++])){
  26377. ~arrayIndexOf(result, key) || result.push(key);
  26378. }
  26379. return result;
  26380. };
  26381. /***/ }),
  26382. /* 285 */
  26383. /***/ (function(module, exports, __webpack_require__) {
  26384. var getKeys = __webpack_require__(40)
  26385. , toIObject = __webpack_require__(23)
  26386. , isEnum = __webpack_require__(48).f;
  26387. module.exports = function(isEntries){
  26388. return function(it){
  26389. var O = toIObject(it)
  26390. , keys = getKeys(O)
  26391. , length = keys.length
  26392. , i = 0
  26393. , result = []
  26394. , key;
  26395. while(length > i)if(isEnum.call(O, key = keys[i++])){
  26396. result.push(isEntries ? [key, O[key]] : O[key]);
  26397. } return result;
  26398. };
  26399. };
  26400. /***/ }),
  26401. /* 286 */
  26402. /***/ (function(module, exports, __webpack_require__) {
  26403. // Works with __proto__ only. Old v8 can't work with null proto objects.
  26404. /* eslint-disable no-proto */
  26405. var isObject = __webpack_require__(15)
  26406. , anObject = __webpack_require__(18);
  26407. var check = function(O, proto){
  26408. anObject(O);
  26409. if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!");
  26410. };
  26411. module.exports = {
  26412. set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
  26413. function(test, buggy, set){
  26414. try {
  26415. set = __webpack_require__(29)(Function.call, __webpack_require__(81).f(Object.prototype, '__proto__').set, 2);
  26416. set(test, []);
  26417. buggy = !(test instanceof Array);
  26418. } catch(e){ buggy = true; }
  26419. return function setPrototypeOf(O, proto){
  26420. check(O, proto);
  26421. if(buggy)O.__proto__ = proto;
  26422. else set(O, proto);
  26423. return O;
  26424. };
  26425. }({}, false) : undefined),
  26426. check: check
  26427. };
  26428. /***/ }),
  26429. /* 287 */
  26430. /***/ (function(module, exports, __webpack_require__) {
  26431. "use strict";
  26432. var global = __webpack_require__(13)
  26433. , dP = __webpack_require__(19)
  26434. , DESCRIPTORS = __webpack_require__(21)
  26435. , SPECIES = __webpack_require__(10)('species');
  26436. module.exports = function(KEY){
  26437. var C = global[KEY];
  26438. if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, {
  26439. configurable: true,
  26440. get: function(){ return this; }
  26441. });
  26442. };
  26443. /***/ }),
  26444. /* 288 */
  26445. /***/ (function(module, exports, __webpack_require__) {
  26446. // https://github.com/tc39/proposal-string-pad-start-end
  26447. var toLength = __webpack_require__(24)
  26448. , repeat = __webpack_require__(289)
  26449. , defined = __webpack_require__(30);
  26450. module.exports = function(that, maxLength, fillString, left){
  26451. var S = String(defined(that))
  26452. , stringLength = S.length
  26453. , fillStr = fillString === undefined ? ' ' : String(fillString)
  26454. , intMaxLength = toLength(maxLength);
  26455. if(intMaxLength <= stringLength || fillStr == '')return S;
  26456. var fillLen = intMaxLength - stringLength
  26457. , stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  26458. if(stringFiller.length > fillLen)stringFiller = stringFiller.slice(0, fillLen);
  26459. return left ? stringFiller + S : S + stringFiller;
  26460. };
  26461. /***/ }),
  26462. /* 289 */
  26463. /***/ (function(module, exports, __webpack_require__) {
  26464. "use strict";
  26465. var toInteger = __webpack_require__(62)
  26466. , defined = __webpack_require__(30);
  26467. module.exports = function repeat(count){
  26468. var str = String(defined(this))
  26469. , res = ''
  26470. , n = toInteger(count);
  26471. if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
  26472. for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
  26473. return res;
  26474. };
  26475. /***/ }),
  26476. /* 290 */
  26477. /***/ (function(module, exports, __webpack_require__) {
  26478. exports.f = __webpack_require__(10);
  26479. /***/ }),
  26480. /* 291 */
  26481. /***/ (function(module, exports, __webpack_require__) {
  26482. var classof = __webpack_require__(271)
  26483. , ITERATOR = __webpack_require__(10)('iterator')
  26484. , Iterators = __webpack_require__(46);
  26485. module.exports = __webpack_require__(45).getIteratorMethod = function(it){
  26486. if(it != undefined)return it[ITERATOR]
  26487. || it['@@iterator']
  26488. || Iterators[classof(it)];
  26489. };
  26490. /***/ }),
  26491. /* 292 */
  26492. /***/ (function(module, exports, __webpack_require__) {
  26493. "use strict";
  26494. exports.__esModule = true;
  26495. exports.default = jQueryWrapper;
  26496. function jQueryWrapper(Handsontable) {
  26497. var jQuery = typeof window === 'undefined' ? false : window.jQuery;
  26498. if (!jQuery) {
  26499. return;
  26500. }
  26501. jQuery.fn.handsontable = function (action) {
  26502. var $this = this.first(); // Use only first element from list
  26503. var instance = $this.data('handsontable');
  26504. // Init case
  26505. if (typeof action !== 'string') {
  26506. var userSettings = action || {};
  26507. if (instance) {
  26508. instance.updateSettings(userSettings);
  26509. } else {
  26510. instance = new Handsontable.Core($this[0], userSettings);
  26511. $this.data('handsontable', instance);
  26512. instance.init();
  26513. }
  26514. return $this;
  26515. }
  26516. // Action case
  26517. var args = [];
  26518. var output = void 0;
  26519. if (arguments.length > 1) {
  26520. for (var i = 1, ilen = arguments.length; i < ilen; i++) {
  26521. args.push(arguments[i]);
  26522. }
  26523. }
  26524. if (instance) {
  26525. if (typeof instance[action] !== 'undefined') {
  26526. output = instance[action].apply(instance, args);
  26527. if (action === 'destroy') {
  26528. $this.removeData();
  26529. }
  26530. } else {
  26531. throw new Error('Handsontable do not provide action: ' + action);
  26532. }
  26533. }
  26534. return output;
  26535. };
  26536. };
  26537. /***/ }),
  26538. /* 293 */
  26539. /***/ (function(module, exports, __webpack_require__) {
  26540. "use strict";
  26541. exports.__esModule = true;
  26542. exports.Base = exports.UndoRedo = exports.TouchScroll = exports.Search = exports.PersistentState = exports.ObserveChanges = exports.MultipleSelectionHandles = exports.MergeCells = exports.ManualRowResize = exports.ManualRowMove = exports.ManualColumnResize = exports.ManualColumnMove = exports.ManualColumnFreeze = exports.DragToScroll = exports.CustomBorders = exports.CopyPaste = exports.ContextMenu = exports.Comments = exports.ColumnSorting = exports.AutoRowSize = exports.AutoFill = exports.AutoColumnSize = undefined;
  26543. var _autoColumnSize = __webpack_require__(325);
  26544. var _autoColumnSize2 = _interopRequireDefault(_autoColumnSize);
  26545. var _autofill = __webpack_require__(327);
  26546. var _autofill2 = _interopRequireDefault(_autofill);
  26547. var _autoRowSize = __webpack_require__(326);
  26548. var _autoRowSize2 = _interopRequireDefault(_autoRowSize);
  26549. var _columnSorting = __webpack_require__(329);
  26550. var _columnSorting2 = _interopRequireDefault(_columnSorting);
  26551. var _comments = __webpack_require__(331);
  26552. var _comments2 = _interopRequireDefault(_comments);
  26553. var _contextMenu = __webpack_require__(334);
  26554. var _contextMenu2 = _interopRequireDefault(_contextMenu);
  26555. var _copyPaste = __webpack_require__(351);
  26556. var _copyPaste2 = _interopRequireDefault(_copyPaste);
  26557. var _customBorders = __webpack_require__(353);
  26558. var _customBorders2 = _interopRequireDefault(_customBorders);
  26559. var _dragToScroll = __webpack_require__(354);
  26560. var _dragToScroll2 = _interopRequireDefault(_dragToScroll);
  26561. var _manualColumnFreeze = __webpack_require__(357);
  26562. var _manualColumnFreeze2 = _interopRequireDefault(_manualColumnFreeze);
  26563. var _manualColumnMove = __webpack_require__(359);
  26564. var _manualColumnMove2 = _interopRequireDefault(_manualColumnMove);
  26565. var _manualColumnResize = __webpack_require__(362);
  26566. var _manualColumnResize2 = _interopRequireDefault(_manualColumnResize);
  26567. var _manualRowMove = __webpack_require__(363);
  26568. var _manualRowMove2 = _interopRequireDefault(_manualRowMove);
  26569. var _manualRowResize = __webpack_require__(367);
  26570. var _manualRowResize2 = _interopRequireDefault(_manualRowResize);
  26571. var _mergeCells = __webpack_require__(368);
  26572. var _mergeCells2 = _interopRequireDefault(_mergeCells);
  26573. var _multipleSelectionHandles = __webpack_require__(369);
  26574. var _multipleSelectionHandles2 = _interopRequireDefault(_multipleSelectionHandles);
  26575. var _observeChanges = __webpack_require__(371);
  26576. var _observeChanges2 = _interopRequireDefault(_observeChanges);
  26577. var _persistentState = __webpack_require__(373);
  26578. var _persistentState2 = _interopRequireDefault(_persistentState);
  26579. var _search = __webpack_require__(374);
  26580. var _search2 = _interopRequireDefault(_search);
  26581. var _touchScroll = __webpack_require__(375);
  26582. var _touchScroll2 = _interopRequireDefault(_touchScroll);
  26583. var _undoRedo = __webpack_require__(376);
  26584. var _undoRedo2 = _interopRequireDefault(_undoRedo);
  26585. var _base = __webpack_require__(12);
  26586. var _base2 = _interopRequireDefault(_base);
  26587. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26588. exports.AutoColumnSize = _autoColumnSize2.default;
  26589. exports.AutoFill = _autofill2.default;
  26590. exports.AutoRowSize = _autoRowSize2.default;
  26591. exports.ColumnSorting = _columnSorting2.default;
  26592. exports.Comments = _comments2.default;
  26593. exports.ContextMenu = _contextMenu2.default;
  26594. exports.CopyPaste = _copyPaste2.default;
  26595. exports.CustomBorders = _customBorders2.default;
  26596. exports.DragToScroll = _dragToScroll2.default;
  26597. exports.ManualColumnFreeze = _manualColumnFreeze2.default;
  26598. exports.ManualColumnMove = _manualColumnMove2.default;
  26599. exports.ManualColumnResize = _manualColumnResize2.default;
  26600. exports.ManualRowMove = _manualRowMove2.default;
  26601. exports.ManualRowResize = _manualRowResize2.default;
  26602. exports.MergeCells = _mergeCells2.default;
  26603. exports.MultipleSelectionHandles = _multipleSelectionHandles2.default;
  26604. exports.ObserveChanges = _observeChanges2.default;
  26605. exports.PersistentState = _persistentState2.default;
  26606. exports.Search = _search2.default;
  26607. exports.TouchScroll = _touchScroll2.default;
  26608. exports.UndoRedo = _undoRedo2.default;
  26609. exports.Base = _base2.default;
  26610. /***/ }),
  26611. /* 294 */
  26612. /***/ (function(module, exports) {
  26613. // removed by extract-text-webpack-plugin
  26614. /***/ }),
  26615. /* 295 */
  26616. /***/ (function(module, exports) {
  26617. // removed by extract-text-webpack-plugin
  26618. /***/ }),
  26619. /* 296 */
  26620. /***/ (function(module, exports) {
  26621. // removed by extract-text-webpack-plugin
  26622. /***/ }),
  26623. /* 297 */
  26624. /***/ (function(module, exports) {
  26625. /***/ }),
  26626. /* 298 */
  26627. /***/ (function(module, exports, __webpack_require__) {
  26628. "use strict";
  26629. /**
  26630. * autoResize - resizes a DOM element to the width and height of another DOM element
  26631. *
  26632. * Copyright 2014, Marcin Warpechowski
  26633. * Licensed under the MIT license
  26634. */
  26635. function autoResize() {
  26636. var defaults = {
  26637. minHeight: 200,
  26638. maxHeight: 300,
  26639. minWidth: 100,
  26640. maxWidth: 300
  26641. },
  26642. el,
  26643. body = document.body,
  26644. text = document.createTextNode(''),
  26645. span = document.createElement('SPAN'),
  26646. observe = function observe(element, event, handler) {
  26647. if (window.attachEvent) {
  26648. element.attachEvent('on' + event, handler);
  26649. } else {
  26650. element.addEventListener(event, handler, false);
  26651. }
  26652. },
  26653. _unObserve = function _unObserve(element, event, handler) {
  26654. if (window.removeEventListener) {
  26655. element.removeEventListener(event, handler, false);
  26656. } else {
  26657. element.detachEvent('on' + event, handler);
  26658. }
  26659. },
  26660. resize = function resize(newChar) {
  26661. var width, scrollHeight;
  26662. if (!newChar) {
  26663. newChar = "";
  26664. } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
  26665. newChar = ".";
  26666. }
  26667. if (text.textContent !== void 0) {
  26668. text.textContent = el.value + newChar;
  26669. } else {
  26670. text.data = el.value + newChar; //IE8
  26671. }
  26672. span.style.fontSize = getComputedStyle(el).fontSize;
  26673. span.style.fontFamily = getComputedStyle(el).fontFamily;
  26674. span.style.whiteSpace = "pre";
  26675. body.appendChild(span);
  26676. width = span.clientWidth + 2;
  26677. body.removeChild(span);
  26678. el.style.height = defaults.minHeight + 'px';
  26679. if (defaults.minWidth > width) {
  26680. el.style.width = defaults.minWidth + 'px';
  26681. } else if (width > defaults.maxWidth) {
  26682. el.style.width = defaults.maxWidth + 'px';
  26683. } else {
  26684. el.style.width = width + 'px';
  26685. }
  26686. scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0;
  26687. if (defaults.minHeight > scrollHeight) {
  26688. el.style.height = defaults.minHeight + 'px';
  26689. } else if (defaults.maxHeight < scrollHeight) {
  26690. el.style.height = defaults.maxHeight + 'px';
  26691. el.style.overflowY = 'visible';
  26692. } else {
  26693. el.style.height = scrollHeight + 'px';
  26694. }
  26695. },
  26696. delayedResize = function delayedResize() {
  26697. window.setTimeout(resize, 0);
  26698. },
  26699. extendDefaults = function extendDefaults(config) {
  26700. if (config && config.minHeight) {
  26701. if (config.minHeight == 'inherit') {
  26702. defaults.minHeight = el.clientHeight;
  26703. } else {
  26704. var minHeight = parseInt(config.minHeight);
  26705. if (!isNaN(minHeight)) {
  26706. defaults.minHeight = minHeight;
  26707. }
  26708. }
  26709. }
  26710. if (config && config.maxHeight) {
  26711. if (config.maxHeight == 'inherit') {
  26712. defaults.maxHeight = el.clientHeight;
  26713. } else {
  26714. var maxHeight = parseInt(config.maxHeight);
  26715. if (!isNaN(maxHeight)) {
  26716. defaults.maxHeight = maxHeight;
  26717. }
  26718. }
  26719. }
  26720. if (config && config.minWidth) {
  26721. if (config.minWidth == 'inherit') {
  26722. defaults.minWidth = el.clientWidth;
  26723. } else {
  26724. var minWidth = parseInt(config.minWidth);
  26725. if (!isNaN(minWidth)) {
  26726. defaults.minWidth = minWidth;
  26727. }
  26728. }
  26729. }
  26730. if (config && config.maxWidth) {
  26731. if (config.maxWidth == 'inherit') {
  26732. defaults.maxWidth = el.clientWidth;
  26733. } else {
  26734. var maxWidth = parseInt(config.maxWidth);
  26735. if (!isNaN(maxWidth)) {
  26736. defaults.maxWidth = maxWidth;
  26737. }
  26738. }
  26739. }
  26740. if (!span.firstChild) {
  26741. span.className = "autoResize";
  26742. span.style.display = 'inline-block';
  26743. span.appendChild(text);
  26744. }
  26745. },
  26746. _init = function _init(el_, config, doObserve) {
  26747. el = el_;
  26748. extendDefaults(config);
  26749. if (el.nodeName == 'TEXTAREA') {
  26750. el.style.resize = 'none';
  26751. el.style.overflowY = '';
  26752. el.style.height = defaults.minHeight + 'px';
  26753. el.style.minWidth = defaults.minWidth + 'px';
  26754. el.style.maxWidth = defaults.maxWidth + 'px';
  26755. el.style.overflowY = 'hidden';
  26756. }
  26757. if (doObserve) {
  26758. observe(el, 'change', resize);
  26759. observe(el, 'cut', delayedResize);
  26760. observe(el, 'paste', delayedResize);
  26761. observe(el, 'drop', delayedResize);
  26762. observe(el, 'keydown', delayedResize);
  26763. observe(el, 'focus', resize);
  26764. }
  26765. resize();
  26766. };
  26767. function getComputedStyle(element) {
  26768. return element.currentStyle || document.defaultView.getComputedStyle(element);
  26769. }
  26770. return {
  26771. init: function init(el_, config, doObserve) {
  26772. _init(el_, config, doObserve);
  26773. },
  26774. unObserve: function unObserve() {
  26775. _unObserve(el, 'change', resize);
  26776. _unObserve(el, 'cut', delayedResize);
  26777. _unObserve(el, 'paste', delayedResize);
  26778. _unObserve(el, 'drop', delayedResize);
  26779. _unObserve(el, 'keydown', delayedResize);
  26780. _unObserve(el, 'focus', resize);
  26781. },
  26782. resize: resize
  26783. };
  26784. }
  26785. if (true) {
  26786. module.exports = autoResize;
  26787. }
  26788. /***/ }),
  26789. /* 299 */
  26790. /***/ (function(module, exports, __webpack_require__) {
  26791. "use strict";
  26792. exports.__esModule = true;
  26793. var _element = __webpack_require__(0);
  26794. var _base = __webpack_require__(28);
  26795. var _base2 = _interopRequireDefault(_base);
  26796. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26797. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  26798. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  26799. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  26800. /**
  26801. * A overlay that renders ALL available rows & columns positioned on top of the original Walkontable instance and all other overlays.
  26802. * Used for debugging purposes to see if the other overlays (that render only part of the rows & columns) are positioned correctly
  26803. *
  26804. * @class DebugOverlay
  26805. */
  26806. var DebugOverlay = function (_Overlay) {
  26807. _inherits(DebugOverlay, _Overlay);
  26808. /**
  26809. * @param {Walkontable} wotInstance
  26810. */
  26811. function DebugOverlay(wotInstance) {
  26812. _classCallCheck(this, DebugOverlay);
  26813. var _this = _possibleConstructorReturn(this, (DebugOverlay.__proto__ || Object.getPrototypeOf(DebugOverlay)).call(this, wotInstance));
  26814. _this.clone = _this.makeClone(_base2.default.CLONE_DEBUG);
  26815. _this.clone.wtTable.holder.style.opacity = 0.4;
  26816. _this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000';
  26817. (0, _element.addClass)(_this.clone.wtTable.holder.parentNode, 'wtDebugVisible');
  26818. return _this;
  26819. }
  26820. return DebugOverlay;
  26821. }(_base2.default);
  26822. _base2.default.registerOverlay(_base2.default.CLONE_DEBUG, DebugOverlay);
  26823. exports.default = DebugOverlay;
  26824. /***/ }),
  26825. /* 300 */
  26826. /***/ (function(module, exports, __webpack_require__) {
  26827. "use strict";
  26828. exports.__esModule = true;
  26829. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  26830. var _element = __webpack_require__(0);
  26831. var _base = __webpack_require__(28);
  26832. var _base2 = _interopRequireDefault(_base);
  26833. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26834. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  26835. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  26836. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  26837. /**
  26838. * @class LeftOverlay
  26839. */
  26840. var LeftOverlay = function (_Overlay) {
  26841. _inherits(LeftOverlay, _Overlay);
  26842. /**
  26843. * @param {Walkontable} wotInstance
  26844. */
  26845. function LeftOverlay(wotInstance) {
  26846. _classCallCheck(this, LeftOverlay);
  26847. var _this = _possibleConstructorReturn(this, (LeftOverlay.__proto__ || Object.getPrototypeOf(LeftOverlay)).call(this, wotInstance));
  26848. _this.clone = _this.makeClone(_base2.default.CLONE_LEFT);
  26849. return _this;
  26850. }
  26851. /**
  26852. * Checks if overlay should be fully rendered
  26853. *
  26854. * @returns {Boolean}
  26855. */
  26856. _createClass(LeftOverlay, [{
  26857. key: 'shouldBeRendered',
  26858. value: function shouldBeRendered() {
  26859. return !!(this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length);
  26860. }
  26861. /**
  26862. * Updates the left overlay position
  26863. */
  26864. }, {
  26865. key: 'resetFixedPosition',
  26866. value: function resetFixedPosition() {
  26867. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  26868. // removed from DOM
  26869. return;
  26870. }
  26871. var overlayRoot = this.clone.wtTable.holder.parentNode;
  26872. var headerPosition = 0;
  26873. var preventOverflow = this.wot.getSetting('preventOverflow');
  26874. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'horizontal')) {
  26875. var box = this.wot.wtTable.hider.getBoundingClientRect();
  26876. var left = Math.ceil(box.left);
  26877. var right = Math.ceil(box.right);
  26878. var finalLeft = void 0;
  26879. var finalTop = void 0;
  26880. finalTop = this.wot.wtTable.hider.style.top;
  26881. finalTop = finalTop === '' ? 0 : finalTop;
  26882. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  26883. finalLeft = -left;
  26884. } else {
  26885. finalLeft = 0;
  26886. }
  26887. headerPosition = finalLeft;
  26888. finalLeft += 'px';
  26889. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  26890. } else {
  26891. headerPosition = this.getScrollPosition();
  26892. (0, _element.resetCssTransform)(overlayRoot);
  26893. }
  26894. this.adjustHeaderBordersPosition(headerPosition);
  26895. this.adjustElementsSize();
  26896. }
  26897. /**
  26898. * Sets the main overlay's horizontal scroll position
  26899. *
  26900. * @param {Number} pos
  26901. */
  26902. }, {
  26903. key: 'setScrollPosition',
  26904. value: function setScrollPosition(pos) {
  26905. if (this.mainTableScrollableElement === window) {
  26906. window.scrollTo(pos, (0, _element.getWindowScrollTop)());
  26907. } else {
  26908. this.mainTableScrollableElement.scrollLeft = pos;
  26909. }
  26910. }
  26911. /**
  26912. * Triggers onScroll hook callback
  26913. */
  26914. }, {
  26915. key: 'onScroll',
  26916. value: function onScroll() {
  26917. this.wot.getSetting('onScrollVertically');
  26918. }
  26919. /**
  26920. * Calculates total sum cells width
  26921. *
  26922. * @param {Number} from Column index which calculates started from
  26923. * @param {Number} to Column index where calculation is finished
  26924. * @returns {Number} Width sum
  26925. */
  26926. }, {
  26927. key: 'sumCellSizes',
  26928. value: function sumCellSizes(from, to) {
  26929. var sum = 0;
  26930. var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth;
  26931. while (from < to) {
  26932. sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth;
  26933. from++;
  26934. }
  26935. return sum;
  26936. }
  26937. /**
  26938. * Adjust overlay root element, childs and master table element sizes (width, height).
  26939. *
  26940. * @param {Boolean} [force=false]
  26941. */
  26942. }, {
  26943. key: 'adjustElementsSize',
  26944. value: function adjustElementsSize() {
  26945. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  26946. this.updateTrimmingContainer();
  26947. if (this.needFullRender || force) {
  26948. this.adjustRootElementSize();
  26949. this.adjustRootChildrenSize();
  26950. if (!force) {
  26951. this.areElementSizesAdjusted = true;
  26952. }
  26953. }
  26954. }
  26955. /**
  26956. * Adjust overlay root element size (width and height).
  26957. */
  26958. }, {
  26959. key: 'adjustRootElementSize',
  26960. value: function adjustRootElementSize() {
  26961. var masterHolder = this.wot.wtTable.holder;
  26962. var scrollbarHeight = masterHolder.clientHeight === masterHolder.offsetHeight ? 0 : (0, _element.getScrollbarWidth)();
  26963. var overlayRoot = this.clone.wtTable.holder.parentNode;
  26964. var overlayRootStyle = overlayRoot.style;
  26965. var preventOverflow = this.wot.getSetting('preventOverflow');
  26966. var tableWidth = void 0;
  26967. if (this.trimmingContainer !== window || preventOverflow === 'vertical') {
  26968. var height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight;
  26969. height = Math.min(height, (0, _element.innerHeight)(this.wot.wtTable.wtRootElement));
  26970. overlayRootStyle.height = height + 'px';
  26971. } else {
  26972. overlayRootStyle.height = '';
  26973. }
  26974. this.clone.wtTable.holder.style.height = overlayRootStyle.height;
  26975. tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  26976. overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  26977. }
  26978. /**
  26979. * Adjust overlay root childs size
  26980. */
  26981. }, {
  26982. key: 'adjustRootChildrenSize',
  26983. value: function adjustRootChildrenSize() {
  26984. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  26985. this.clone.wtTable.hider.style.height = this.hider.style.height;
  26986. this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height;
  26987. if (scrollbarWidth === 0) {
  26988. scrollbarWidth = 30;
  26989. }
  26990. this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px';
  26991. }
  26992. /**
  26993. * Adjust the overlay dimensions and position
  26994. */
  26995. }, {
  26996. key: 'applyToDOM',
  26997. value: function applyToDOM() {
  26998. var total = this.wot.getSetting('totalColumns');
  26999. if (!this.areElementSizesAdjusted) {
  27000. this.adjustElementsSize();
  27001. }
  27002. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  27003. this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  27004. } else if (total === 0) {
  27005. this.spreader.style.left = '0';
  27006. } else {
  27007. throw new Error('Incorrect value of the columnsRenderCalculator');
  27008. }
  27009. this.spreader.style.right = '';
  27010. if (this.needFullRender) {
  27011. this.syncOverlayOffset();
  27012. }
  27013. }
  27014. /**
  27015. * Synchronize calculated top position to an element
  27016. */
  27017. }, {
  27018. key: 'syncOverlayOffset',
  27019. value: function syncOverlayOffset() {
  27020. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  27021. this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  27022. } else {
  27023. this.clone.wtTable.spreader.style.top = '';
  27024. }
  27025. }
  27026. /**
  27027. * Scrolls horizontally to a column at the left edge of the viewport
  27028. *
  27029. * @param sourceCol {Number} Column index which you want to scroll to
  27030. * @param [beyondRendered=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  27031. */
  27032. }, {
  27033. key: 'scrollTo',
  27034. value: function scrollTo(sourceCol, beyondRendered) {
  27035. var newX = this.getTableParentOffset();
  27036. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  27037. var mainHolder = sourceInstance.wtTable.holder;
  27038. var scrollbarCompensation = 0;
  27039. if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) {
  27040. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  27041. }
  27042. if (beyondRendered) {
  27043. newX += this.sumCellSizes(0, sourceCol + 1);
  27044. newX -= this.wot.wtViewport.getViewportWidth();
  27045. } else {
  27046. newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol);
  27047. }
  27048. newX += scrollbarCompensation;
  27049. this.setScrollPosition(newX);
  27050. }
  27051. /**
  27052. * Gets table parent left position
  27053. *
  27054. * @returns {Number}
  27055. */
  27056. }, {
  27057. key: 'getTableParentOffset',
  27058. value: function getTableParentOffset() {
  27059. var preventOverflow = this.wot.getSetting('preventOverflow');
  27060. var offset = 0;
  27061. if (!preventOverflow && this.trimmingContainer === window) {
  27062. offset = this.wot.wtTable.holderOffset.left;
  27063. }
  27064. return offset;
  27065. }
  27066. /**
  27067. * Gets the main overlay's horizontal scroll position
  27068. *
  27069. * @returns {Number} Main table's vertical scroll position
  27070. */
  27071. }, {
  27072. key: 'getScrollPosition',
  27073. value: function getScrollPosition() {
  27074. return (0, _element.getScrollLeft)(this.mainTableScrollableElement);
  27075. }
  27076. /**
  27077. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  27078. *
  27079. * @param {Number} position Header X position if trimming container is window or scroll top if not
  27080. */
  27081. }, {
  27082. key: 'adjustHeaderBordersPosition',
  27083. value: function adjustHeaderBordersPosition(position) {
  27084. var masterParent = this.wot.wtTable.holder.parentNode;
  27085. var rowHeaders = this.wot.getSetting('rowHeaders');
  27086. var fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  27087. var totalRows = this.wot.getSetting('totalRows');
  27088. if (totalRows) {
  27089. (0, _element.removeClass)(masterParent, 'emptyRows');
  27090. } else {
  27091. (0, _element.addClass)(masterParent, 'emptyRows');
  27092. }
  27093. if (fixedColumnsLeft && !rowHeaders.length) {
  27094. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  27095. } else if (!fixedColumnsLeft && rowHeaders.length) {
  27096. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderLeft');
  27097. if (position) {
  27098. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  27099. } else {
  27100. (0, _element.removeClass)(masterParent, 'innerBorderLeft');
  27101. }
  27102. if (!previousState && position || previousState && !position) {
  27103. this.wot.wtOverlays.adjustElementsSize();
  27104. }
  27105. }
  27106. }
  27107. }]);
  27108. return LeftOverlay;
  27109. }(_base2.default);
  27110. _base2.default.registerOverlay(_base2.default.CLONE_LEFT, LeftOverlay);
  27111. exports.default = LeftOverlay;
  27112. /***/ }),
  27113. /* 301 */
  27114. /***/ (function(module, exports, __webpack_require__) {
  27115. "use strict";
  27116. exports.__esModule = true;
  27117. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  27118. var _element = __webpack_require__(0);
  27119. var _base = __webpack_require__(28);
  27120. var _base2 = _interopRequireDefault(_base);
  27121. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27122. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27123. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  27124. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  27125. /**
  27126. * @class TopOverlay
  27127. */
  27128. var TopOverlay = function (_Overlay) {
  27129. _inherits(TopOverlay, _Overlay);
  27130. /**
  27131. * @param {Walkontable} wotInstance
  27132. */
  27133. function TopOverlay(wotInstance) {
  27134. _classCallCheck(this, TopOverlay);
  27135. var _this = _possibleConstructorReturn(this, (TopOverlay.__proto__ || Object.getPrototypeOf(TopOverlay)).call(this, wotInstance));
  27136. _this.clone = _this.makeClone(_base2.default.CLONE_TOP);
  27137. return _this;
  27138. }
  27139. /**
  27140. * Checks if overlay should be fully rendered
  27141. *
  27142. * @returns {Boolean}
  27143. */
  27144. _createClass(TopOverlay, [{
  27145. key: 'shouldBeRendered',
  27146. value: function shouldBeRendered() {
  27147. return !!(this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length);
  27148. }
  27149. /**
  27150. * Updates the top overlay position
  27151. */
  27152. }, {
  27153. key: 'resetFixedPosition',
  27154. value: function resetFixedPosition() {
  27155. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  27156. // removed from DOM
  27157. return;
  27158. }
  27159. var overlayRoot = this.clone.wtTable.holder.parentNode;
  27160. var headerPosition = 0;
  27161. var preventOverflow = this.wot.getSetting('preventOverflow');
  27162. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'vertical')) {
  27163. var box = this.wot.wtTable.hider.getBoundingClientRect();
  27164. var top = Math.ceil(box.top);
  27165. var bottom = Math.ceil(box.bottom);
  27166. var finalLeft = void 0;
  27167. var finalTop = void 0;
  27168. finalLeft = this.wot.wtTable.hider.style.left;
  27169. finalLeft = finalLeft === '' ? 0 : finalLeft;
  27170. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  27171. finalTop = -top;
  27172. } else {
  27173. finalTop = 0;
  27174. }
  27175. headerPosition = finalTop;
  27176. finalTop += 'px';
  27177. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  27178. } else {
  27179. headerPosition = this.getScrollPosition();
  27180. (0, _element.resetCssTransform)(overlayRoot);
  27181. }
  27182. this.adjustHeaderBordersPosition(headerPosition);
  27183. this.adjustElementsSize();
  27184. }
  27185. /**
  27186. * Sets the main overlay's vertical scroll position
  27187. *
  27188. * @param {Number} pos
  27189. */
  27190. }, {
  27191. key: 'setScrollPosition',
  27192. value: function setScrollPosition(pos) {
  27193. if (this.mainTableScrollableElement === window) {
  27194. window.scrollTo((0, _element.getWindowScrollLeft)(), pos);
  27195. } else {
  27196. this.mainTableScrollableElement.scrollTop = pos;
  27197. }
  27198. }
  27199. /**
  27200. * Triggers onScroll hook callback
  27201. */
  27202. }, {
  27203. key: 'onScroll',
  27204. value: function onScroll() {
  27205. this.wot.getSetting('onScrollHorizontally');
  27206. }
  27207. /**
  27208. * Calculates total sum cells height
  27209. *
  27210. * @param {Number} from Row index which calculates started from
  27211. * @param {Number} to Row index where calculation is finished
  27212. * @returns {Number} Height sum
  27213. */
  27214. }, {
  27215. key: 'sumCellSizes',
  27216. value: function sumCellSizes(from, to) {
  27217. var sum = 0;
  27218. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  27219. while (from < to) {
  27220. var height = this.wot.wtTable.getRowHeight(from);
  27221. sum += height === void 0 ? defaultRowHeight : height;
  27222. from++;
  27223. }
  27224. return sum;
  27225. }
  27226. /**
  27227. * Adjust overlay root element, childs and master table element sizes (width, height).
  27228. *
  27229. * @param {Boolean} [force=false]
  27230. */
  27231. }, {
  27232. key: 'adjustElementsSize',
  27233. value: function adjustElementsSize() {
  27234. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  27235. this.updateTrimmingContainer();
  27236. if (this.needFullRender || force) {
  27237. this.adjustRootElementSize();
  27238. this.adjustRootChildrenSize();
  27239. if (!force) {
  27240. this.areElementSizesAdjusted = true;
  27241. }
  27242. }
  27243. }
  27244. /**
  27245. * Adjust overlay root element size (width and height).
  27246. */
  27247. }, {
  27248. key: 'adjustRootElementSize',
  27249. value: function adjustRootElementSize() {
  27250. var masterHolder = this.wot.wtTable.holder;
  27251. var scrollbarWidth = masterHolder.clientWidth === masterHolder.offsetWidth ? 0 : (0, _element.getScrollbarWidth)();
  27252. var overlayRoot = this.clone.wtTable.holder.parentNode;
  27253. var overlayRootStyle = overlayRoot.style;
  27254. var preventOverflow = this.wot.getSetting('preventOverflow');
  27255. var tableHeight = void 0;
  27256. if (this.trimmingContainer !== window || preventOverflow === 'horizontal') {
  27257. var width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth;
  27258. width = Math.min(width, (0, _element.innerWidth)(this.wot.wtTable.wtRootElement));
  27259. overlayRootStyle.width = width + 'px';
  27260. } else {
  27261. overlayRootStyle.width = '';
  27262. }
  27263. this.clone.wtTable.holder.style.width = overlayRootStyle.width;
  27264. tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  27265. overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  27266. }
  27267. /**
  27268. * Adjust overlay root childs size
  27269. */
  27270. }, {
  27271. key: 'adjustRootChildrenSize',
  27272. value: function adjustRootChildrenSize() {
  27273. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  27274. this.clone.wtTable.hider.style.width = this.hider.style.width;
  27275. this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width;
  27276. if (scrollbarWidth === 0) {
  27277. scrollbarWidth = 30;
  27278. }
  27279. this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px';
  27280. }
  27281. /**
  27282. * Adjust the overlay dimensions and position
  27283. */
  27284. }, {
  27285. key: 'applyToDOM',
  27286. value: function applyToDOM() {
  27287. var total = this.wot.getSetting('totalRows');
  27288. if (!this.areElementSizesAdjusted) {
  27289. this.adjustElementsSize();
  27290. }
  27291. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  27292. this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  27293. } else if (total === 0) {
  27294. // can happen if there are 0 rows
  27295. this.spreader.style.top = '0';
  27296. } else {
  27297. throw new Error('Incorrect value of the rowsRenderCalculator');
  27298. }
  27299. this.spreader.style.bottom = '';
  27300. if (this.needFullRender) {
  27301. this.syncOverlayOffset();
  27302. }
  27303. }
  27304. /**
  27305. * Synchronize calculated left position to an element
  27306. */
  27307. }, {
  27308. key: 'syncOverlayOffset',
  27309. value: function syncOverlayOffset() {
  27310. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  27311. this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  27312. } else {
  27313. this.clone.wtTable.spreader.style.left = '';
  27314. }
  27315. }
  27316. /**
  27317. * Scrolls vertically to a row
  27318. *
  27319. * @param sourceRow {Number} Row index which you want to scroll to
  27320. * @param [bottomEdge=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  27321. */
  27322. }, {
  27323. key: 'scrollTo',
  27324. value: function scrollTo(sourceRow, bottomEdge) {
  27325. var newY = this.getTableParentOffset();
  27326. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  27327. var mainHolder = sourceInstance.wtTable.holder;
  27328. var scrollbarCompensation = 0;
  27329. if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) {
  27330. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  27331. }
  27332. if (bottomEdge) {
  27333. var fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  27334. var fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  27335. var totalRows = this.wot.getSetting('totalRows');
  27336. newY += this.sumCellSizes(0, sourceRow + 1);
  27337. newY -= this.wot.wtViewport.getViewportHeight() - this.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  27338. // Fix 1 pixel offset when cell is selected
  27339. newY += 1;
  27340. } else {
  27341. newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow);
  27342. }
  27343. newY += scrollbarCompensation;
  27344. this.setScrollPosition(newY);
  27345. }
  27346. /**
  27347. * Gets table parent top position
  27348. *
  27349. * @returns {Number}
  27350. */
  27351. }, {
  27352. key: 'getTableParentOffset',
  27353. value: function getTableParentOffset() {
  27354. if (this.mainTableScrollableElement === window) {
  27355. return this.wot.wtTable.holderOffset.top;
  27356. }
  27357. return 0;
  27358. }
  27359. /**
  27360. * Gets the main overlay's vertical scroll position
  27361. *
  27362. * @returns {Number} Main table's vertical scroll position
  27363. */
  27364. }, {
  27365. key: 'getScrollPosition',
  27366. value: function getScrollPosition() {
  27367. return (0, _element.getScrollTop)(this.mainTableScrollableElement);
  27368. }
  27369. /**
  27370. * Redraw borders of selection
  27371. *
  27372. * @param {WalkontableSelection} selection Selection for redraw
  27373. */
  27374. }, {
  27375. key: 'redrawSelectionBorders',
  27376. value: function redrawSelectionBorders(selection) {
  27377. if (selection && selection.cellRange) {
  27378. var border = selection.getBorder(this.wot);
  27379. if (border) {
  27380. var corners = selection.getCorners();
  27381. border.disappear();
  27382. border.appear(corners);
  27383. }
  27384. }
  27385. }
  27386. /**
  27387. * Redrawing borders of all selections
  27388. */
  27389. }, {
  27390. key: 'redrawAllSelectionsBorders',
  27391. value: function redrawAllSelectionsBorders() {
  27392. var selections = this.wot.selections;
  27393. this.redrawSelectionBorders(selections.current);
  27394. this.redrawSelectionBorders(selections.area);
  27395. this.redrawSelectionBorders(selections.fill);
  27396. this.wot.wtTable.wot.wtOverlays.leftOverlay.refresh();
  27397. }
  27398. /**
  27399. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  27400. *
  27401. * @param {Number} position Header Y position if trimming container is window or scroll top if not
  27402. */
  27403. }, {
  27404. key: 'adjustHeaderBordersPosition',
  27405. value: function adjustHeaderBordersPosition(position) {
  27406. var masterParent = this.wot.wtTable.holder.parentNode;
  27407. var totalColumns = this.wot.getSetting('totalColumns');
  27408. if (totalColumns) {
  27409. (0, _element.removeClass)(masterParent, 'emptyColumns');
  27410. } else {
  27411. (0, _element.addClass)(masterParent, 'emptyColumns');
  27412. }
  27413. if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) {
  27414. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderTop');
  27415. if (position || this.wot.getSetting('totalRows') === 0) {
  27416. (0, _element.addClass)(masterParent, 'innerBorderTop');
  27417. } else {
  27418. (0, _element.removeClass)(masterParent, 'innerBorderTop');
  27419. }
  27420. if (!previousState && position || previousState && !position) {
  27421. this.wot.wtOverlays.adjustElementsSize();
  27422. // cell borders should be positioned once again,
  27423. // because we added / removed 1px border from table header
  27424. this.redrawAllSelectionsBorders();
  27425. }
  27426. }
  27427. // nasty workaround for double border in the header, TODO: find a pure-css solution
  27428. if (this.wot.getSetting('rowHeaders').length === 0) {
  27429. var secondHeaderCell = this.clone.wtTable.THEAD.querySelectorAll('th:nth-of-type(2)');
  27430. if (secondHeaderCell) {
  27431. for (var i = 0; i < secondHeaderCell.length; i++) {
  27432. secondHeaderCell[i].style['border-left-width'] = 0;
  27433. }
  27434. }
  27435. }
  27436. }
  27437. }]);
  27438. return TopOverlay;
  27439. }(_base2.default);
  27440. _base2.default.registerOverlay(_base2.default.CLONE_TOP, TopOverlay);
  27441. exports.default = TopOverlay;
  27442. /***/ }),
  27443. /* 302 */
  27444. /***/ (function(module, exports, __webpack_require__) {
  27445. "use strict";
  27446. exports.__esModule = true;
  27447. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  27448. var _element = __webpack_require__(0);
  27449. var _base = __webpack_require__(28);
  27450. var _base2 = _interopRequireDefault(_base);
  27451. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27452. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27453. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  27454. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  27455. /**
  27456. * @class TopLeftCornerOverlay
  27457. */
  27458. var TopLeftCornerOverlay = function (_Overlay) {
  27459. _inherits(TopLeftCornerOverlay, _Overlay);
  27460. /**
  27461. * @param {Walkontable} wotInstance
  27462. */
  27463. function TopLeftCornerOverlay(wotInstance) {
  27464. _classCallCheck(this, TopLeftCornerOverlay);
  27465. var _this = _possibleConstructorReturn(this, (TopLeftCornerOverlay.__proto__ || Object.getPrototypeOf(TopLeftCornerOverlay)).call(this, wotInstance));
  27466. _this.clone = _this.makeClone(_base2.default.CLONE_TOP_LEFT_CORNER);
  27467. return _this;
  27468. }
  27469. /**
  27470. * Checks if overlay should be fully rendered
  27471. *
  27472. * @returns {Boolean}
  27473. */
  27474. _createClass(TopLeftCornerOverlay, [{
  27475. key: 'shouldBeRendered',
  27476. value: function shouldBeRendered() {
  27477. return !!((this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length));
  27478. }
  27479. /**
  27480. * Updates the corner overlay position
  27481. */
  27482. }, {
  27483. key: 'resetFixedPosition',
  27484. value: function resetFixedPosition() {
  27485. this.updateTrimmingContainer();
  27486. if (!this.wot.wtTable.holder.parentNode) {
  27487. // removed from DOM
  27488. return;
  27489. }
  27490. var overlayRoot = this.clone.wtTable.holder.parentNode;
  27491. var tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  27492. var tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  27493. var preventOverflow = this.wot.getSetting('preventOverflow');
  27494. if (this.trimmingContainer === window) {
  27495. var box = this.wot.wtTable.hider.getBoundingClientRect();
  27496. var top = Math.ceil(box.top);
  27497. var left = Math.ceil(box.left);
  27498. var bottom = Math.ceil(box.bottom);
  27499. var right = Math.ceil(box.right);
  27500. var finalLeft = '0';
  27501. var finalTop = '0';
  27502. if (!preventOverflow || preventOverflow === 'vertical') {
  27503. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  27504. finalLeft = -left + 'px';
  27505. }
  27506. }
  27507. if (!preventOverflow || preventOverflow === 'horizontal') {
  27508. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  27509. finalTop = -top + 'px';
  27510. }
  27511. }
  27512. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  27513. } else {
  27514. (0, _element.resetCssTransform)(overlayRoot);
  27515. }
  27516. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  27517. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  27518. }
  27519. }]);
  27520. return TopLeftCornerOverlay;
  27521. }(_base2.default);
  27522. _base2.default.registerOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, TopLeftCornerOverlay);
  27523. exports.default = TopLeftCornerOverlay;
  27524. /***/ }),
  27525. /* 303 */
  27526. /***/ (function(module, exports, __webpack_require__) {
  27527. "use strict";
  27528. exports.__esModule = true;
  27529. var _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; };
  27530. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  27531. var _element = __webpack_require__(0);
  27532. var _border2 = __webpack_require__(250);
  27533. var _border3 = _interopRequireDefault(_border2);
  27534. var _coords = __webpack_require__(43);
  27535. var _coords2 = _interopRequireDefault(_coords);
  27536. var _range = __webpack_require__(69);
  27537. var _range2 = _interopRequireDefault(_range);
  27538. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27539. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27540. /**
  27541. * @class Selection
  27542. */
  27543. var Selection = function () {
  27544. /**
  27545. * @param {Object} settings
  27546. * @param {CellRange} cellRange
  27547. */
  27548. function Selection(settings, cellRange) {
  27549. _classCallCheck(this, Selection);
  27550. this.settings = settings;
  27551. this.cellRange = cellRange || null;
  27552. this.instanceBorders = {};
  27553. }
  27554. /**
  27555. * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
  27556. * borders per instance
  27557. *
  27558. * @param {Walkontable} wotInstance
  27559. * @returns {Border}
  27560. */
  27561. _createClass(Selection, [{
  27562. key: 'getBorder',
  27563. value: function getBorder(wotInstance) {
  27564. if (this.instanceBorders[wotInstance.guid]) {
  27565. return this.instanceBorders[wotInstance.guid];
  27566. }
  27567. // where is this returned?
  27568. this.instanceBorders[wotInstance.guid] = new _border3.default(wotInstance, this.settings);
  27569. }
  27570. /**
  27571. * Checks if selection is empty
  27572. *
  27573. * @returns {Boolean}
  27574. */
  27575. }, {
  27576. key: 'isEmpty',
  27577. value: function isEmpty() {
  27578. return this.cellRange === null;
  27579. }
  27580. /**
  27581. * Adds a cell coords to the selection
  27582. *
  27583. * @param {CellCoords} coords
  27584. */
  27585. }, {
  27586. key: 'add',
  27587. value: function add(coords) {
  27588. if (this.isEmpty()) {
  27589. this.cellRange = new _range2.default(coords, coords, coords);
  27590. } else {
  27591. this.cellRange.expand(coords);
  27592. }
  27593. }
  27594. /**
  27595. * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
  27596. * information about success
  27597. *
  27598. * @param {CellCoords} oldCoords
  27599. * @param {CellCoords} newCoords
  27600. * @returns {Boolean}
  27601. */
  27602. }, {
  27603. key: 'replace',
  27604. value: function replace(oldCoords, newCoords) {
  27605. if (!this.isEmpty()) {
  27606. if (this.cellRange.from.isEqual(oldCoords)) {
  27607. this.cellRange.from = newCoords;
  27608. return true;
  27609. }
  27610. if (this.cellRange.to.isEqual(oldCoords)) {
  27611. this.cellRange.to = newCoords;
  27612. return true;
  27613. }
  27614. }
  27615. return false;
  27616. }
  27617. /**
  27618. * Clears selection
  27619. */
  27620. }, {
  27621. key: 'clear',
  27622. value: function clear() {
  27623. this.cellRange = null;
  27624. }
  27625. /**
  27626. * Returns the top left (TL) and bottom right (BR) selection coordinates
  27627. *
  27628. * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`
  27629. */
  27630. }, {
  27631. key: 'getCorners',
  27632. value: function getCorners() {
  27633. var topLeft = this.cellRange.getTopLeftCorner();
  27634. var bottomRight = this.cellRange.getBottomRightCorner();
  27635. return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col];
  27636. }
  27637. /**
  27638. * Adds class name to cell element at given coords
  27639. *
  27640. * @param {Walkontable} wotInstance Walkontable instance
  27641. * @param {Number} sourceRow Cell row coord
  27642. * @param {Number} sourceColumn Cell column coord
  27643. * @param {String} className Class name
  27644. */
  27645. }, {
  27646. key: 'addClassAtCoords',
  27647. value: function addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
  27648. var TD = wotInstance.wtTable.getCell(new _coords2.default(sourceRow, sourceColumn));
  27649. if ((typeof TD === 'undefined' ? 'undefined' : _typeof(TD)) === 'object') {
  27650. (0, _element.addClass)(TD, className);
  27651. }
  27652. }
  27653. /**
  27654. * @param wotInstance
  27655. */
  27656. }, {
  27657. key: 'draw',
  27658. value: function draw(wotInstance) {
  27659. if (this.isEmpty()) {
  27660. if (this.settings.border) {
  27661. var border = this.getBorder(wotInstance);
  27662. if (border) {
  27663. border.disappear();
  27664. }
  27665. }
  27666. return;
  27667. }
  27668. var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
  27669. var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
  27670. var corners = this.getCorners();
  27671. var sourceRow = void 0,
  27672. sourceCol = void 0,
  27673. TH = void 0;
  27674. for (var column = 0; column < renderedColumns; column++) {
  27675. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
  27676. if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  27677. TH = wotInstance.wtTable.getColumnHeader(sourceCol);
  27678. if (TH) {
  27679. var newClasses = [];
  27680. if (this.settings.highlightHeaderClassName) {
  27681. newClasses.push(this.settings.highlightHeaderClassName);
  27682. }
  27683. if (this.settings.highlightColumnClassName) {
  27684. newClasses.push(this.settings.highlightColumnClassName);
  27685. }
  27686. (0, _element.addClass)(TH, newClasses);
  27687. }
  27688. }
  27689. }
  27690. for (var row = 0; row < renderedRows; row++) {
  27691. sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
  27692. if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  27693. TH = wotInstance.wtTable.getRowHeader(sourceRow);
  27694. if (TH) {
  27695. var _newClasses = [];
  27696. if (this.settings.highlightHeaderClassName) {
  27697. _newClasses.push(this.settings.highlightHeaderClassName);
  27698. }
  27699. if (this.settings.highlightRowClassName) {
  27700. _newClasses.push(this.settings.highlightRowClassName);
  27701. }
  27702. (0, _element.addClass)(TH, _newClasses);
  27703. }
  27704. }
  27705. for (var _column = 0; _column < renderedColumns; _column++) {
  27706. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(_column);
  27707. if (sourceRow >= corners[0] && sourceRow <= corners[2] && sourceCol >= corners[1] && sourceCol <= corners[3]) {
  27708. // selected cell
  27709. if (this.settings.className) {
  27710. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className);
  27711. }
  27712. } else if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  27713. // selection is in this row
  27714. if (this.settings.highlightRowClassName) {
  27715. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightRowClassName);
  27716. }
  27717. } else if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  27718. // selection is in this column
  27719. if (this.settings.highlightColumnClassName) {
  27720. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightColumnClassName);
  27721. }
  27722. }
  27723. }
  27724. }
  27725. wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
  27726. if (this.settings.border) {
  27727. var _border = this.getBorder(wotInstance);
  27728. if (_border) {
  27729. // warning! border.appear modifies corners!
  27730. _border.appear(corners);
  27731. }
  27732. }
  27733. }
  27734. }]);
  27735. return Selection;
  27736. }();
  27737. exports.default = Selection;
  27738. /***/ }),
  27739. /* 304 */
  27740. /***/ (function(module, exports, __webpack_require__) {
  27741. "use strict";
  27742. exports.__esModule = true;
  27743. var _editors = __webpack_require__(14);
  27744. var _renderers = __webpack_require__(9);
  27745. var _validators = __webpack_require__(26);
  27746. var CELL_TYPE = 'autocomplete';
  27747. exports.default = {
  27748. editor: (0, _editors.getEditor)(CELL_TYPE),
  27749. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  27750. validator: (0, _validators.getValidator)(CELL_TYPE)
  27751. };
  27752. /***/ }),
  27753. /* 305 */
  27754. /***/ (function(module, exports, __webpack_require__) {
  27755. "use strict";
  27756. exports.__esModule = true;
  27757. var _editors = __webpack_require__(14);
  27758. var _renderers = __webpack_require__(9);
  27759. var CELL_TYPE = 'checkbox';
  27760. exports.default = {
  27761. editor: (0, _editors.getEditor)(CELL_TYPE),
  27762. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  27763. };
  27764. /***/ }),
  27765. /* 306 */
  27766. /***/ (function(module, exports, __webpack_require__) {
  27767. "use strict";
  27768. exports.__esModule = true;
  27769. var _editors = __webpack_require__(14);
  27770. var _renderers = __webpack_require__(9);
  27771. var _validators = __webpack_require__(26);
  27772. var CELL_TYPE = 'date';
  27773. exports.default = {
  27774. editor: (0, _editors.getEditor)(CELL_TYPE),
  27775. // displays small gray arrow on right side of the cell
  27776. renderer: (0, _renderers.getRenderer)('autocomplete'),
  27777. validator: (0, _validators.getValidator)(CELL_TYPE)
  27778. };
  27779. /***/ }),
  27780. /* 307 */
  27781. /***/ (function(module, exports, __webpack_require__) {
  27782. "use strict";
  27783. exports.__esModule = true;
  27784. var _editors = __webpack_require__(14);
  27785. var _renderers = __webpack_require__(9);
  27786. var _validators = __webpack_require__(26);
  27787. var CELL_TYPE = 'dropdown';
  27788. exports.default = {
  27789. editor: (0, _editors.getEditor)(CELL_TYPE),
  27790. // displays small gray arrow on right side of the cell
  27791. renderer: (0, _renderers.getRenderer)('autocomplete'),
  27792. validator: (0, _validators.getValidator)('autocomplete')
  27793. };
  27794. /***/ }),
  27795. /* 308 */
  27796. /***/ (function(module, exports, __webpack_require__) {
  27797. "use strict";
  27798. exports.__esModule = true;
  27799. var _editors = __webpack_require__(14);
  27800. var _renderers = __webpack_require__(9);
  27801. var CELL_TYPE = 'handsontable';
  27802. exports.default = {
  27803. editor: (0, _editors.getEditor)(CELL_TYPE),
  27804. // displays small gray arrow on right side of the cell
  27805. renderer: (0, _renderers.getRenderer)('autocomplete')
  27806. };
  27807. /***/ }),
  27808. /* 309 */
  27809. /***/ (function(module, exports, __webpack_require__) {
  27810. "use strict";
  27811. exports.__esModule = true;
  27812. var _editors = __webpack_require__(14);
  27813. var _renderers = __webpack_require__(9);
  27814. var _validators = __webpack_require__(26);
  27815. var CELL_TYPE = 'numeric';
  27816. exports.default = {
  27817. editor: (0, _editors.getEditor)(CELL_TYPE),
  27818. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  27819. validator: (0, _validators.getValidator)(CELL_TYPE),
  27820. dataType: 'number'
  27821. };
  27822. /***/ }),
  27823. /* 310 */
  27824. /***/ (function(module, exports, __webpack_require__) {
  27825. "use strict";
  27826. exports.__esModule = true;
  27827. var _editors = __webpack_require__(14);
  27828. var _renderers = __webpack_require__(9);
  27829. var _validators = __webpack_require__(26);
  27830. var CELL_TYPE = 'password';
  27831. exports.default = {
  27832. editor: (0, _editors.getEditor)(CELL_TYPE),
  27833. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  27834. copyable: false
  27835. };
  27836. /***/ }),
  27837. /* 311 */
  27838. /***/ (function(module, exports, __webpack_require__) {
  27839. "use strict";
  27840. exports.__esModule = true;
  27841. var _browser = __webpack_require__(25);
  27842. var _editors = __webpack_require__(14);
  27843. var _renderers = __webpack_require__(9);
  27844. var CELL_TYPE = 'text';
  27845. exports.default = {
  27846. editor: (0, _browser.isMobileBrowser)() ? (0, _editors.getEditor)('mobile') : (0, _editors.getEditor)(CELL_TYPE),
  27847. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  27848. };
  27849. /***/ }),
  27850. /* 312 */
  27851. /***/ (function(module, exports, __webpack_require__) {
  27852. "use strict";
  27853. exports.__esModule = true;
  27854. var _editors = __webpack_require__(14);
  27855. var _renderers = __webpack_require__(9);
  27856. var _validators = __webpack_require__(26);
  27857. var CELL_TYPE = 'time';
  27858. exports.default = {
  27859. editor: (0, _editors.getEditor)('text'),
  27860. // displays small gray arrow on right side of the cell
  27861. renderer: (0, _renderers.getRenderer)('text'),
  27862. validator: (0, _validators.getValidator)(CELL_TYPE)
  27863. };
  27864. /***/ }),
  27865. /* 313 */
  27866. /***/ (function(module, exports, __webpack_require__) {
  27867. "use strict";
  27868. exports.__esModule = true;
  27869. var _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; };
  27870. var _SheetClip = __webpack_require__(248);
  27871. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  27872. var _data = __webpack_require__(65);
  27873. var _setting = __webpack_require__(66);
  27874. var _object = __webpack_require__(1);
  27875. var _array = __webpack_require__(2);
  27876. var _interval = __webpack_require__(386);
  27877. var _interval2 = _interopRequireDefault(_interval);
  27878. var _number = __webpack_require__(6);
  27879. var _multiMap = __webpack_require__(324);
  27880. var _multiMap2 = _interopRequireDefault(_multiMap);
  27881. var _pluginHooks = __webpack_require__(8);
  27882. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  27883. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27884. /**
  27885. * Utility class that gets and saves data from/to the data source using mapping of columns numbers to object property names
  27886. * @todo refactor arguments of methods getRange, getText to be numbers (not objects)
  27887. * @todo remove priv, GridSettings from object constructor
  27888. *
  27889. * @param {Object} instance Instance of Handsontable
  27890. * @param {*} priv
  27891. * @param {*} GridSettings Grid settings
  27892. * @util
  27893. * @class DataMap
  27894. */
  27895. function DataMap(instance, priv, GridSettings) {
  27896. var _this = this;
  27897. this.instance = instance;
  27898. this.priv = priv;
  27899. this.GridSettings = GridSettings;
  27900. this.dataSource = this.instance.getSettings().data;
  27901. this.cachedLength = null;
  27902. this.skipCache = false;
  27903. this.latestSourceRowsCount = 0;
  27904. if (this.dataSource && this.dataSource[0]) {
  27905. this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]);
  27906. } else {
  27907. this.duckSchema = {};
  27908. }
  27909. this.createMap();
  27910. this.interval = _interval2.default.create(function () {
  27911. return _this.clearLengthCache();
  27912. }, '15fps');
  27913. this.instance.addHook('skipLengthCache', function (delay) {
  27914. return _this.onSkipLengthCache(delay);
  27915. });
  27916. this.onSkipLengthCache(500);
  27917. }
  27918. DataMap.prototype.DESTINATION_RENDERER = 1;
  27919. DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2;
  27920. /**
  27921. * @param {Object|Array} object
  27922. * @returns {Object|Array}
  27923. */
  27924. DataMap.prototype.recursiveDuckSchema = function (object) {
  27925. return (0, _object.duckSchema)(object);
  27926. };
  27927. /**
  27928. * @param {Object} schema
  27929. * @param {Number} lastCol
  27930. * @param {Number} parent
  27931. * @returns {Number}
  27932. */
  27933. DataMap.prototype.recursiveDuckColumns = function (schema, lastCol, parent) {
  27934. var prop, i;
  27935. if (typeof lastCol === 'undefined') {
  27936. lastCol = 0;
  27937. parent = '';
  27938. }
  27939. if ((typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) === 'object' && !Array.isArray(schema)) {
  27940. for (i in schema) {
  27941. if ((0, _object.hasOwnProperty)(schema, i)) {
  27942. if (schema[i] === null) {
  27943. prop = parent + i;
  27944. this.colToPropCache.push(prop);
  27945. this.propToColCache.set(prop, lastCol);
  27946. lastCol++;
  27947. } else {
  27948. lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.');
  27949. }
  27950. }
  27951. }
  27952. }
  27953. return lastCol;
  27954. };
  27955. DataMap.prototype.createMap = function () {
  27956. var i = void 0;
  27957. var schema = this.getSchema();
  27958. if (typeof schema === 'undefined') {
  27959. throw new Error('trying to create `columns` definition but you didn\'t provide `schema` nor `data`');
  27960. }
  27961. this.colToPropCache = [];
  27962. this.propToColCache = new _multiMap2.default();
  27963. var columns = this.instance.getSettings().columns;
  27964. if (columns) {
  27965. var maxCols = this.instance.getSettings().maxCols;
  27966. var columnsLen = Math.min(maxCols, columns.length);
  27967. var filteredIndex = 0;
  27968. var columnsAsFunc = false;
  27969. var schemaLen = (0, _object.deepObjectSize)(schema);
  27970. if (typeof columns === 'function') {
  27971. columnsLen = schemaLen > 0 ? schemaLen : this.instance.countSourceCols();
  27972. columnsAsFunc = true;
  27973. }
  27974. for (i = 0; i < columnsLen; i++) {
  27975. var column = columnsAsFunc ? columns(i) : columns[i];
  27976. if ((0, _object.isObject)(column)) {
  27977. if (typeof column.data !== 'undefined') {
  27978. var index = columnsAsFunc ? filteredIndex : i;
  27979. this.colToPropCache[index] = column.data;
  27980. this.propToColCache.set(column.data, index);
  27981. }
  27982. filteredIndex++;
  27983. }
  27984. }
  27985. } else {
  27986. this.recursiveDuckColumns(schema);
  27987. }
  27988. };
  27989. /**
  27990. * Returns property name that corresponds with the given column index.
  27991. *
  27992. * @param {Number} col Visual column index.
  27993. * @returns {Number} Physical column index.
  27994. */
  27995. DataMap.prototype.colToProp = function (col) {
  27996. col = this.instance.runHooks('modifyCol', col);
  27997. if (!isNaN(col) && this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') {
  27998. return this.colToPropCache[col];
  27999. }
  28000. return col;
  28001. };
  28002. /**
  28003. * @param {Object} prop
  28004. * @fires Hooks#modifyCol
  28005. * @returns {*}
  28006. */
  28007. DataMap.prototype.propToCol = function (prop) {
  28008. var col;
  28009. if (typeof this.propToColCache.get(prop) === 'undefined') {
  28010. col = prop;
  28011. } else {
  28012. col = this.propToColCache.get(prop);
  28013. }
  28014. col = this.instance.runHooks('unmodifyCol', col);
  28015. return col;
  28016. };
  28017. /**
  28018. * @returns {Object}
  28019. */
  28020. DataMap.prototype.getSchema = function () {
  28021. var schema = this.instance.getSettings().dataSchema;
  28022. if (schema) {
  28023. if (typeof schema === 'function') {
  28024. return schema();
  28025. }
  28026. return schema;
  28027. }
  28028. return this.duckSchema;
  28029. };
  28030. /**
  28031. * Creates row at the bottom of the data array.
  28032. *
  28033. * @param {Number} [index] Physical index of the row before which the new row will be inserted.
  28034. * @param {Number} [amount] An amount of rows to add.
  28035. * @param {String} [source] Source of method call.
  28036. * @fires Hooks#afterCreateRow
  28037. * @returns {Number} Returns number of created rows.
  28038. */
  28039. DataMap.prototype.createRow = function (index, amount, source) {
  28040. var row,
  28041. colCount = this.instance.countCols(),
  28042. numberOfCreatedRows = 0,
  28043. currentIndex;
  28044. if (!amount) {
  28045. amount = 1;
  28046. }
  28047. if (typeof index !== 'number' || index >= this.instance.countSourceRows()) {
  28048. index = this.instance.countSourceRows();
  28049. }
  28050. this.instance.runHooks('beforeCreateRow', index, amount, source);
  28051. currentIndex = index;
  28052. var maxRows = this.instance.getSettings().maxRows;
  28053. while (numberOfCreatedRows < amount && this.instance.countSourceRows() < maxRows) {
  28054. if (this.instance.dataType === 'array') {
  28055. if (this.instance.getSettings().dataSchema) {
  28056. // Clone template array
  28057. row = (0, _object.deepClone)(this.getSchema());
  28058. } else {
  28059. row = [];
  28060. /* eslint-disable no-loop-func */
  28061. (0, _number.rangeEach)(colCount - 1, function () {
  28062. return row.push(null);
  28063. });
  28064. }
  28065. } else if (this.instance.dataType === 'function') {
  28066. row = this.instance.getSettings().dataSchema(index);
  28067. } else {
  28068. row = {};
  28069. (0, _object.deepExtend)(row, this.getSchema());
  28070. }
  28071. if (index === this.instance.countSourceRows()) {
  28072. this.dataSource.push(row);
  28073. } else {
  28074. this.spliceData(index, 0, row);
  28075. }
  28076. numberOfCreatedRows++;
  28077. currentIndex++;
  28078. }
  28079. this.instance.runHooks('afterCreateRow', index, numberOfCreatedRows, source);
  28080. this.instance.forceFullRender = true; // used when data was changed
  28081. return numberOfCreatedRows;
  28082. };
  28083. /**
  28084. * Creates col at the right of the data array.
  28085. *
  28086. * @param {Number} [index] Visual index of the column before which the new column will be inserted
  28087. * @param {Number} [amount] An amount of columns to add.
  28088. * @param {String} [source] Source of method call.
  28089. * @fires Hooks#afterCreateCol
  28090. * @returns {Number} Returns number of created columns
  28091. */
  28092. DataMap.prototype.createCol = function (index, amount, source) {
  28093. if (!this.instance.isColumnModificationAllowed()) {
  28094. 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.');
  28095. }
  28096. var rlen = this.instance.countSourceRows(),
  28097. data = this.dataSource,
  28098. constructor,
  28099. numberOfCreatedCols = 0,
  28100. currentIndex;
  28101. if (!amount) {
  28102. amount = 1;
  28103. }
  28104. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  28105. index = this.instance.countCols();
  28106. }
  28107. this.instance.runHooks('beforeCreateCol', index, amount, source);
  28108. currentIndex = index;
  28109. var maxCols = this.instance.getSettings().maxCols;
  28110. while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) {
  28111. constructor = (0, _setting.columnFactory)(this.GridSettings, this.priv.columnsSettingConflicts);
  28112. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  28113. if (rlen > 0) {
  28114. for (var r = 0; r < rlen; r++) {
  28115. if (typeof data[r] === 'undefined') {
  28116. data[r] = [];
  28117. }
  28118. data[r].push(null);
  28119. }
  28120. } else {
  28121. data.push([null]);
  28122. }
  28123. // Add new column constructor
  28124. this.priv.columnSettings.push(constructor);
  28125. } else {
  28126. for (var _r = 0; _r < rlen; _r++) {
  28127. data[_r].splice(currentIndex, 0, null);
  28128. }
  28129. // Add new column constructor at given index
  28130. this.priv.columnSettings.splice(currentIndex, 0, constructor);
  28131. }
  28132. numberOfCreatedCols++;
  28133. currentIndex++;
  28134. }
  28135. this.instance.runHooks('afterCreateCol', index, numberOfCreatedCols, source);
  28136. this.instance.forceFullRender = true; // used when data was changed
  28137. return numberOfCreatedCols;
  28138. };
  28139. /**
  28140. * Removes row from the data array.
  28141. *
  28142. * @param {Number} [index] Visual index of the row to be removed. If not provided, the last row will be removed
  28143. * @param {Number} [amount] Amount of the rows to be removed. If not provided, one row will be removed
  28144. * @param {String} [source] Source of method call.
  28145. * @fires Hooks#beforeRemoveRow
  28146. * @fires Hooks#afterRemoveRow
  28147. */
  28148. DataMap.prototype.removeRow = function (index, amount, source) {
  28149. if (!amount) {
  28150. amount = 1;
  28151. }
  28152. if (typeof index !== 'number') {
  28153. index = -amount;
  28154. }
  28155. amount = this.instance.runHooks('modifyRemovedAmount', amount, index);
  28156. index = (this.instance.countSourceRows() + index) % this.instance.countSourceRows();
  28157. var logicRows = this.visualRowsToPhysical(index, amount);
  28158. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveRow', index, amount, logicRows, source);
  28159. if (actionWasNotCancelled === false) {
  28160. return;
  28161. }
  28162. var data = this.dataSource;
  28163. var newData = void 0;
  28164. newData = this.filterData(index, amount);
  28165. if (newData) {
  28166. data.length = 0;
  28167. Array.prototype.push.apply(data, newData);
  28168. }
  28169. this.instance.runHooks('afterRemoveRow', index, amount, logicRows, source);
  28170. this.instance.forceFullRender = true; // used when data was changed
  28171. };
  28172. /**
  28173. * Removes column from the data array.
  28174. *
  28175. * @param {Number} [index] Visual index of the column to be removed. If not provided, the last column will be removed
  28176. * @param {Number} [amount] Amount of the columns to be removed. If not provided, one column will be removed
  28177. * @param {String} [source] Source of method call.
  28178. * @fires Hooks#beforeRemoveCol
  28179. * @fires Hooks#afterRemoveCol
  28180. */
  28181. DataMap.prototype.removeCol = function (index, amount, source) {
  28182. if (this.instance.dataType === 'object' || this.instance.getSettings().columns) {
  28183. throw new Error('cannot remove column with object data source or columns option specified');
  28184. }
  28185. if (!amount) {
  28186. amount = 1;
  28187. }
  28188. if (typeof index !== 'number') {
  28189. index = -amount;
  28190. }
  28191. index = (this.instance.countCols() + index) % this.instance.countCols();
  28192. var logicColumns = this.visualColumnsToPhysical(index, amount);
  28193. var descendingLogicColumns = logicColumns.slice(0).sort(function (a, b) {
  28194. return b - a;
  28195. });
  28196. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveCol', index, amount, logicColumns, source);
  28197. if (actionWasNotCancelled === false) {
  28198. return;
  28199. }
  28200. var isTableUniform = true;
  28201. var removedColumnsCount = descendingLogicColumns.length;
  28202. var data = this.dataSource;
  28203. for (var c = 0; c < removedColumnsCount; c++) {
  28204. if (isTableUniform && logicColumns[0] !== logicColumns[c] - c) {
  28205. isTableUniform = false;
  28206. }
  28207. }
  28208. if (isTableUniform) {
  28209. for (var r = 0, rlen = this.instance.countSourceRows(); r < rlen; r++) {
  28210. data[r].splice(logicColumns[0], amount);
  28211. }
  28212. } else {
  28213. for (var _r2 = 0, _rlen = this.instance.countSourceRows(); _r2 < _rlen; _r2++) {
  28214. for (var _c = 0; _c < removedColumnsCount; _c++) {
  28215. data[_r2].splice(descendingLogicColumns[_c], 1);
  28216. }
  28217. }
  28218. for (var _c2 = 0; _c2 < removedColumnsCount; _c2++) {
  28219. this.priv.columnSettings.splice(logicColumns[_c2], 1);
  28220. }
  28221. }
  28222. this.instance.runHooks('afterRemoveCol', index, amount, logicColumns, source);
  28223. this.instance.forceFullRender = true; // used when data was changed
  28224. };
  28225. /**
  28226. * Add/Removes data from the column.
  28227. *
  28228. * @param {Number} col Physical index of column in which do you want to do splice
  28229. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end
  28230. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed
  28231. * @returns {Array} Returns removed portion of columns
  28232. */
  28233. DataMap.prototype.spliceCol = function (col, index, amount /* , elements...*/) {
  28234. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  28235. var colData = this.instance.getDataAtCol(col);
  28236. var removed = colData.slice(index, index + amount);
  28237. var after = colData.slice(index + amount);
  28238. (0, _array.extendArray)(elements, after);
  28239. var i = 0;
  28240. while (i < amount) {
  28241. elements.push(null); // add null in place of removed elements
  28242. i++;
  28243. }
  28244. (0, _array.to2dArray)(elements);
  28245. this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol');
  28246. return removed;
  28247. };
  28248. /**
  28249. * Add/Removes data from the row.
  28250. *
  28251. * @param {Number} row Physical index of row in which do you want to do splice
  28252. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  28253. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  28254. * @returns {Array} Returns removed portion of rows
  28255. */
  28256. DataMap.prototype.spliceRow = function (row, index, amount /* , elements...*/) {
  28257. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  28258. var rowData = this.instance.getSourceDataAtRow(row);
  28259. var removed = rowData.slice(index, index + amount);
  28260. var after = rowData.slice(index + amount);
  28261. (0, _array.extendArray)(elements, after);
  28262. var i = 0;
  28263. while (i < amount) {
  28264. elements.push(null); // add null in place of removed elements
  28265. i++;
  28266. }
  28267. this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow');
  28268. return removed;
  28269. };
  28270. /**
  28271. * Add/remove row(s) to/from the data source.
  28272. *
  28273. * @param {Number} index Physical index of the element to remove.
  28274. * @param {Number} amount Number of rows to add/remove.
  28275. * @param {Object} element Row to add.
  28276. */
  28277. DataMap.prototype.spliceData = function (index, amount, element) {
  28278. var continueSplicing = this.instance.runHooks('beforeDataSplice', index, amount, element);
  28279. if (continueSplicing !== false) {
  28280. this.dataSource.splice(index, amount, element);
  28281. }
  28282. };
  28283. /**
  28284. * Filter unwanted data elements from the data source.
  28285. *
  28286. * @param {Number} index Visual index of the element to remove.
  28287. * @param {Number} amount Number of rows to add/remove.
  28288. * @returns {Array}
  28289. */
  28290. DataMap.prototype.filterData = function (index, amount) {
  28291. var physicalRows = this.visualRowsToPhysical(index, amount);
  28292. var continueSplicing = this.instance.runHooks('beforeDataFilter', index, amount, physicalRows);
  28293. if (continueSplicing !== false) {
  28294. var newData = this.dataSource.filter(function (row, index) {
  28295. return physicalRows.indexOf(index) == -1;
  28296. });
  28297. return newData;
  28298. }
  28299. };
  28300. /**
  28301. * Returns single value from the data array.
  28302. *
  28303. * @param {Number} row Visual row index.
  28304. * @param {Number} prop
  28305. */
  28306. DataMap.prototype.get = function (row, prop) {
  28307. row = this.instance.runHooks('modifyRow', row);
  28308. var dataRow = this.dataSource[row];
  28309. // TODO: To remove, use 'modifyData' hook instead (see below)
  28310. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  28311. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  28312. //
  28313. var value = null;
  28314. // try to get value under property `prop` (includes dot)
  28315. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  28316. value = dataRow[prop];
  28317. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  28318. var sliced = prop.split('.');
  28319. var out = dataRow;
  28320. if (!out) {
  28321. return null;
  28322. }
  28323. for (var i = 0, ilen = sliced.length; i < ilen; i++) {
  28324. out = out[sliced[i]];
  28325. if (typeof out === 'undefined') {
  28326. return null;
  28327. }
  28328. }
  28329. value = out;
  28330. } else if (typeof prop === 'function') {
  28331. /**
  28332. * allows for interacting with complex structures, for example
  28333. * d3/jQuery getter/setter properties:
  28334. *
  28335. * {columns: [{
  28336. * data: function(row, value){
  28337. * if(arguments.length === 1){
  28338. * return row.property();
  28339. * }
  28340. * row.property(value);
  28341. * }
  28342. * }]}
  28343. */
  28344. value = prop(this.dataSource.slice(row, row + 1)[0]);
  28345. }
  28346. if (this.instance.hasHook('modifyData')) {
  28347. var valueHolder = (0, _object.createObjectPropListener)(value);
  28348. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'get');
  28349. if (valueHolder.isTouched()) {
  28350. value = valueHolder.value;
  28351. }
  28352. }
  28353. return value;
  28354. };
  28355. var copyableLookup = (0, _data.cellMethodLookupFactory)('copyable', false);
  28356. /**
  28357. * Returns single value from the data array (intended for clipboard copy to an external application).
  28358. *
  28359. * @param {Number} row Physical row index.
  28360. * @param {Number} prop
  28361. * @returns {String}
  28362. */
  28363. DataMap.prototype.getCopyable = function (row, prop) {
  28364. if (copyableLookup.call(this.instance, row, this.propToCol(prop))) {
  28365. return this.get(row, prop);
  28366. }
  28367. return '';
  28368. };
  28369. /**
  28370. * Saves single value to the data array.
  28371. *
  28372. * @param {Number} row Visual row index.
  28373. * @param {Number} prop
  28374. * @param {String} value
  28375. * @param {String} [source] Source of hook runner.
  28376. */
  28377. DataMap.prototype.set = function (row, prop, value, source) {
  28378. row = this.instance.runHooks('modifyRow', row, source || 'datamapGet');
  28379. var dataRow = this.dataSource[row];
  28380. // TODO: To remove, use 'modifyData' hook instead (see below)
  28381. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  28382. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  28383. //
  28384. if (this.instance.hasHook('modifyData')) {
  28385. var valueHolder = (0, _object.createObjectPropListener)(value);
  28386. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'set');
  28387. if (valueHolder.isTouched()) {
  28388. value = valueHolder.value;
  28389. }
  28390. }
  28391. // try to set value under property `prop` (includes dot)
  28392. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  28393. dataRow[prop] = value;
  28394. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  28395. var sliced = prop.split('.');
  28396. var out = dataRow;
  28397. var i = 0;
  28398. var ilen = void 0;
  28399. for (i = 0, ilen = sliced.length - 1; i < ilen; i++) {
  28400. if (typeof out[sliced[i]] === 'undefined') {
  28401. out[sliced[i]] = {};
  28402. }
  28403. out = out[sliced[i]];
  28404. }
  28405. out[sliced[i]] = value;
  28406. } else if (typeof prop === 'function') {
  28407. /* see the `function` handler in `get` */
  28408. prop(this.dataSource.slice(row, row + 1)[0], value);
  28409. } else {
  28410. dataRow[prop] = value;
  28411. }
  28412. };
  28413. /**
  28414. * This ridiculous piece of code maps rows Id that are present in table data to those displayed for user.
  28415. * The trick is, the physical row id (stored in settings.data) is not necessary the same
  28416. * as the visual (displayed) row id (e.g. when sorting is applied).
  28417. *
  28418. * @param {Number} index Visual row index.
  28419. * @param {Number} amount
  28420. * @fires Hooks#modifyRow
  28421. * @returns {Number}
  28422. */
  28423. DataMap.prototype.visualRowsToPhysical = function (index, amount) {
  28424. var totalRows = this.instance.countSourceRows();
  28425. var physicRow = (totalRows + index) % totalRows;
  28426. var logicRows = [];
  28427. var rowsToRemove = amount;
  28428. var row;
  28429. while (physicRow < totalRows && rowsToRemove) {
  28430. row = this.instance.runHooks('modifyRow', physicRow);
  28431. logicRows.push(row);
  28432. rowsToRemove--;
  28433. physicRow++;
  28434. }
  28435. return logicRows;
  28436. };
  28437. /**
  28438. *
  28439. * @param index Visual column index.
  28440. * @param amount
  28441. * @returns {Array}
  28442. */
  28443. DataMap.prototype.visualColumnsToPhysical = function (index, amount) {
  28444. var totalCols = this.instance.countCols();
  28445. var physicalCol = (totalCols + index) % totalCols;
  28446. var visualCols = [];
  28447. var colsToRemove = amount;
  28448. while (physicalCol < totalCols && colsToRemove) {
  28449. var col = this.instance.runHooks('modifyCol', physicalCol);
  28450. visualCols.push(col);
  28451. colsToRemove--;
  28452. physicalCol++;
  28453. }
  28454. return visualCols;
  28455. };
  28456. /**
  28457. * Clears the data array.
  28458. */
  28459. DataMap.prototype.clear = function () {
  28460. for (var r = 0; r < this.instance.countSourceRows(); r++) {
  28461. for (var c = 0; c < this.instance.countCols(); c++) {
  28462. this.set(r, this.colToProp(c), '');
  28463. }
  28464. }
  28465. };
  28466. /**
  28467. * Clear cached data length.
  28468. */
  28469. DataMap.prototype.clearLengthCache = function () {
  28470. this.cachedLength = null;
  28471. };
  28472. /**
  28473. * Get data length.
  28474. *
  28475. * @returns {Number}
  28476. */
  28477. DataMap.prototype.getLength = function () {
  28478. var _this2 = this;
  28479. var maxRows = void 0,
  28480. maxRowsFromSettings = this.instance.getSettings().maxRows;
  28481. if (maxRowsFromSettings < 0 || maxRowsFromSettings === 0) {
  28482. maxRows = 0;
  28483. } else {
  28484. maxRows = maxRowsFromSettings || Infinity;
  28485. }
  28486. var length = this.instance.countSourceRows();
  28487. if (this.instance.hasHook('modifyRow')) {
  28488. var reValidate = this.skipCache;
  28489. this.interval.start();
  28490. if (length !== this.latestSourceRowsCount) {
  28491. reValidate = true;
  28492. }
  28493. this.latestSourceRowsCount = length;
  28494. if (this.cachedLength === null || reValidate) {
  28495. (0, _number.rangeEach)(length - 1, function (row) {
  28496. row = _this2.instance.runHooks('modifyRow', row);
  28497. if (row === null) {
  28498. --length;
  28499. }
  28500. });
  28501. this.cachedLength = length;
  28502. } else {
  28503. length = this.cachedLength;
  28504. }
  28505. } else {
  28506. this.interval.stop();
  28507. }
  28508. return Math.min(length, maxRows);
  28509. };
  28510. /**
  28511. * Returns the data array.
  28512. *
  28513. * @returns {Array}
  28514. */
  28515. DataMap.prototype.getAll = function () {
  28516. var start = {
  28517. row: 0,
  28518. col: 0
  28519. };
  28520. var end = {
  28521. row: Math.max(this.instance.countSourceRows() - 1, 0),
  28522. col: Math.max(this.instance.countCols() - 1, 0)
  28523. };
  28524. if (start.row - end.row === 0 && !this.instance.countSourceRows()) {
  28525. return [];
  28526. }
  28527. return this.getRange(start, end, DataMap.prototype.DESTINATION_RENDERER);
  28528. };
  28529. /**
  28530. * Returns data range as array.
  28531. *
  28532. * @param {Object} [start] Start selection position. Visual indexes.
  28533. * @param {Object} [end] End selection position. Visual indexes.
  28534. * @param {Number} destination Destination of datamap.get
  28535. * @returns {Array}
  28536. */
  28537. DataMap.prototype.getRange = function (start, end, destination) {
  28538. var r,
  28539. rlen,
  28540. c,
  28541. clen,
  28542. output = [],
  28543. row;
  28544. var maxRows = this.instance.getSettings().maxRows;
  28545. var maxCols = this.instance.getSettings().maxCols;
  28546. if (maxRows === 0 || maxCols === 0) {
  28547. return [];
  28548. }
  28549. var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get;
  28550. rlen = Math.min(Math.max(maxRows - 1, 0), Math.max(start.row, end.row));
  28551. clen = Math.min(Math.max(maxCols - 1, 0), Math.max(start.col, end.col));
  28552. for (r = Math.min(start.row, end.row); r <= rlen; r++) {
  28553. row = [];
  28554. var physicalRow = this.instance.runHooks('modifyRow', r);
  28555. for (c = Math.min(start.col, end.col); c <= clen; c++) {
  28556. if (physicalRow === null) {
  28557. break;
  28558. }
  28559. row.push(getFn.call(this, r, this.colToProp(c)));
  28560. }
  28561. if (physicalRow !== null) {
  28562. output.push(row);
  28563. }
  28564. }
  28565. return output;
  28566. };
  28567. /**
  28568. * Return data as text (tab separated columns).
  28569. *
  28570. * @param {Object} [start] Start selection position. Visual indexes.
  28571. * @param {Object} [end] End selection position. Visual indexes.
  28572. * @returns {String}
  28573. */
  28574. DataMap.prototype.getText = function (start, end) {
  28575. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_RENDERER));
  28576. };
  28577. /**
  28578. * Return data as copyable text (tab separated columns intended for clipboard copy to an external application).
  28579. *
  28580. * @param {Object} [start] Start selection position. Visual indexes.
  28581. * @param {Object} [end] End selection position. Visual indexes.
  28582. * @returns {String}
  28583. */
  28584. DataMap.prototype.getCopyableText = function (start, end) {
  28585. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR));
  28586. };
  28587. /**
  28588. * `skipLengthCache` callback.
  28589. * @private
  28590. * @param {Number} delay Time of the delay in milliseconds.
  28591. */
  28592. DataMap.prototype.onSkipLengthCache = function (delay) {
  28593. var _this3 = this;
  28594. this.skipCache = true;
  28595. setTimeout(function () {
  28596. _this3.skipCache = false;
  28597. }, delay);
  28598. };
  28599. /**
  28600. * Destroy instance.
  28601. */
  28602. DataMap.prototype.destroy = function () {
  28603. this.interval.stop();
  28604. this.interval = null;
  28605. this.instance = null;
  28606. this.priv = null;
  28607. this.GridSettings = null;
  28608. this.dataSource = null;
  28609. this.cachedLength = null;
  28610. this.duckSchema = null;
  28611. };
  28612. exports.default = DataMap;
  28613. /***/ }),
  28614. /* 314 */
  28615. /***/ (function(module, exports, __webpack_require__) {
  28616. "use strict";
  28617. exports.__esModule = true;
  28618. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  28619. var _object = __webpack_require__(1);
  28620. var _array = __webpack_require__(2);
  28621. var _number = __webpack_require__(6);
  28622. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  28623. /**
  28624. * @class DataSource
  28625. * @private
  28626. */
  28627. var DataSource = function () {
  28628. function DataSource(hotInstance) {
  28629. var dataSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  28630. _classCallCheck(this, DataSource);
  28631. /**
  28632. * Instance of Handsontable.
  28633. *
  28634. * @type {Handsontable}
  28635. */
  28636. this.hot = hotInstance;
  28637. /**
  28638. * Data source
  28639. *
  28640. * @type {Array}
  28641. */
  28642. this.data = dataSource;
  28643. /**
  28644. * Type of data source.
  28645. *
  28646. * @type {String}
  28647. * @default 'array'
  28648. */
  28649. this.dataType = 'array';
  28650. this.colToProp = function () {};
  28651. this.propToCol = function () {};
  28652. }
  28653. /**
  28654. * Get all data.
  28655. *
  28656. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  28657. * in another format.
  28658. * @returns {Array}
  28659. */
  28660. _createClass(DataSource, [{
  28661. key: 'getData',
  28662. value: function getData() {
  28663. var toArray = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  28664. var result = this.data;
  28665. if (toArray) {
  28666. result = this.getByRange({ row: 0, col: 0 }, { row: Math.max(this.countRows() - 1, 0), col: Math.max(this.countColumns() - 1, 0) }, true);
  28667. }
  28668. return result;
  28669. }
  28670. /**
  28671. * Set new data source.
  28672. *
  28673. * @param data {Array}
  28674. */
  28675. }, {
  28676. key: 'setData',
  28677. value: function setData(data) {
  28678. this.data = data;
  28679. }
  28680. /**
  28681. * Returns array of column values from the data source. `column` is the index of the row in the data source.
  28682. *
  28683. * @param {Number} column Visual column index.
  28684. * @returns {Array}
  28685. */
  28686. }, {
  28687. key: 'getAtColumn',
  28688. value: function getAtColumn(column) {
  28689. var _this = this;
  28690. var result = [];
  28691. (0, _array.arrayEach)(this.data, function (row) {
  28692. var property = _this.colToProp(column);
  28693. if (typeof property === 'string') {
  28694. row = (0, _object.getProperty)(row, property);
  28695. } else {
  28696. row = row[property];
  28697. }
  28698. result.push(row);
  28699. });
  28700. return result;
  28701. }
  28702. /**
  28703. * 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.
  28704. *
  28705. * @param {Number} row Physical row index.
  28706. * @returns {Array|Object}
  28707. */
  28708. }, {
  28709. key: 'getAtRow',
  28710. value: function getAtRow(row) {
  28711. return this.data[row];
  28712. }
  28713. /**
  28714. * Returns a single value from the data.
  28715. *
  28716. * @param {Number} row Physical row index.
  28717. * @param {Number} column Visual column index.
  28718. * @returns {*}
  28719. */
  28720. }, {
  28721. key: 'getAtCell',
  28722. value: function getAtCell(row, column) {
  28723. var result = null;
  28724. var modifyRowData = this.hot.runHooks('modifyRowData', row);
  28725. var dataRow = isNaN(modifyRowData) ? modifyRowData : this.data[row];
  28726. if (dataRow) {
  28727. var prop = this.colToProp(column);
  28728. if (typeof prop === 'string') {
  28729. result = (0, _object.getProperty)(dataRow, prop);
  28730. } else if (typeof prop === 'function') {
  28731. result = prop(this.data.slice(row, row + 1)[0]);
  28732. } else {
  28733. result = dataRow[prop];
  28734. }
  28735. }
  28736. return result;
  28737. }
  28738. /**
  28739. * Returns source data by passed range.
  28740. *
  28741. * @param {Object} start Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  28742. * @param {Object} end Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  28743. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  28744. * in another format.
  28745. * @returns {Array}
  28746. */
  28747. }, {
  28748. key: 'getByRange',
  28749. value: function getByRange(start, end) {
  28750. var _this2 = this;
  28751. var toArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  28752. var startRow = Math.min(start.row, end.row);
  28753. var startCol = Math.min(start.col, end.col);
  28754. var endRow = Math.max(start.row, end.row);
  28755. var endCol = Math.max(start.col, end.col);
  28756. var result = [];
  28757. (0, _number.rangeEach)(startRow, endRow, function (currentRow) {
  28758. var row = _this2.getAtRow(currentRow);
  28759. var newRow = void 0;
  28760. if (_this2.dataType === 'array') {
  28761. newRow = row.slice(startCol, endCol + 1);
  28762. } else if (_this2.dataType === 'object') {
  28763. newRow = toArray ? [] : {};
  28764. (0, _number.rangeEach)(startCol, endCol, function (column) {
  28765. var prop = _this2.colToProp(column);
  28766. if (toArray) {
  28767. newRow.push(row[prop]);
  28768. } else {
  28769. newRow[prop] = row[prop];
  28770. }
  28771. });
  28772. }
  28773. result.push(newRow);
  28774. });
  28775. return result;
  28776. }
  28777. /**
  28778. * Count number of rows.
  28779. *
  28780. * @returns {Number}
  28781. */
  28782. }, {
  28783. key: 'countRows',
  28784. value: function countRows() {
  28785. return Array.isArray(this.data) ? this.data.length : 0;
  28786. }
  28787. /**
  28788. * Count number of columns.
  28789. *
  28790. * @returns {Number}
  28791. */
  28792. }, {
  28793. key: 'countColumns',
  28794. value: function countColumns() {
  28795. var result = 0;
  28796. if (Array.isArray(this.data)) {
  28797. if (this.dataType === 'array') {
  28798. result = this.data[0].length;
  28799. } else if (this.dataType === 'object') {
  28800. result = Object.keys(this.data[0]).length;
  28801. }
  28802. }
  28803. return result;
  28804. }
  28805. /**
  28806. * Destroy instance.
  28807. */
  28808. }, {
  28809. key: 'destroy',
  28810. value: function destroy() {
  28811. this.data = null;
  28812. this.hot = null;
  28813. }
  28814. }]);
  28815. return DataSource;
  28816. }();
  28817. exports.default = DataSource;
  28818. /***/ }),
  28819. /* 315 */
  28820. /***/ (function(module, exports, __webpack_require__) {
  28821. "use strict";
  28822. exports.__esModule = true;
  28823. var _src = __webpack_require__(11);
  28824. var _unicode = __webpack_require__(16);
  28825. var _event = __webpack_require__(7);
  28826. var _editors = __webpack_require__(14);
  28827. var _eventManager = __webpack_require__(4);
  28828. var _eventManager2 = _interopRequireDefault(_eventManager);
  28829. var _baseEditor = __webpack_require__(37);
  28830. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28831. function EditorManager(instance, priv, selection) {
  28832. var _this = this,
  28833. destroyed = false,
  28834. eventManager,
  28835. activeEditor;
  28836. eventManager = new _eventManager2.default(instance);
  28837. function moveSelectionAfterEnter(shiftKey) {
  28838. selection.setSelectedHeaders(false, false, false);
  28839. var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves;
  28840. if (shiftKey) {
  28841. // move selection up
  28842. selection.transformStart(-enterMoves.row, -enterMoves.col);
  28843. } else {
  28844. // move selection down (add a new row if needed)
  28845. selection.transformStart(enterMoves.row, enterMoves.col, true);
  28846. }
  28847. }
  28848. function moveSelectionUp(shiftKey) {
  28849. if (shiftKey) {
  28850. if (selection.selectedHeader.cols) {
  28851. selection.setSelectedHeaders(selection.selectedHeader.rows, false, false);
  28852. }
  28853. selection.transformEnd(-1, 0);
  28854. } else {
  28855. selection.setSelectedHeaders(false, false, false);
  28856. selection.transformStart(-1, 0);
  28857. }
  28858. }
  28859. function moveSelectionDown(shiftKey) {
  28860. if (shiftKey) {
  28861. // expanding selection down with shift
  28862. selection.transformEnd(1, 0);
  28863. } else {
  28864. selection.setSelectedHeaders(false, false, false);
  28865. selection.transformStart(1, 0);
  28866. }
  28867. }
  28868. function moveSelectionRight(shiftKey) {
  28869. if (shiftKey) {
  28870. selection.transformEnd(0, 1);
  28871. } else {
  28872. selection.setSelectedHeaders(false, false, false);
  28873. selection.transformStart(0, 1);
  28874. }
  28875. }
  28876. function moveSelectionLeft(shiftKey) {
  28877. if (shiftKey) {
  28878. if (selection.selectedHeader.rows) {
  28879. selection.setSelectedHeaders(false, selection.selectedHeader.cols, false);
  28880. }
  28881. selection.transformEnd(0, -1);
  28882. } else {
  28883. selection.setSelectedHeaders(false, false, false);
  28884. selection.transformStart(0, -1);
  28885. }
  28886. }
  28887. function onKeyDown(event) {
  28888. var ctrlDown, rangeModifier;
  28889. if (!instance.isListening()) {
  28890. return;
  28891. }
  28892. instance.runHooks('beforeKeyDown', event);
  28893. if (destroyed) {
  28894. return;
  28895. }
  28896. if ((0, _event.isImmediatePropagationStopped)(event)) {
  28897. return;
  28898. }
  28899. priv.lastKeyCode = event.keyCode;
  28900. if (!selection.isSelected()) {
  28901. return;
  28902. }
  28903. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  28904. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  28905. if (activeEditor && !activeEditor.isWaiting()) {
  28906. if (!(0, _unicode.isMetaKey)(event.keyCode) && !(0, _unicode.isCtrlKey)(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) {
  28907. _this.openEditor('', event);
  28908. return;
  28909. }
  28910. }
  28911. rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart;
  28912. switch (event.keyCode) {
  28913. case _unicode.KEY_CODES.A:
  28914. if (!_this.isEditorOpened() && ctrlDown) {
  28915. selection.selectAll();
  28916. event.preventDefault();
  28917. (0, _event.stopPropagation)(event);
  28918. }
  28919. break;
  28920. case _unicode.KEY_CODES.ARROW_UP:
  28921. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28922. _this.closeEditorAndSaveChanges(ctrlDown);
  28923. }
  28924. moveSelectionUp(event.shiftKey);
  28925. event.preventDefault();
  28926. (0, _event.stopPropagation)(event);
  28927. break;
  28928. case _unicode.KEY_CODES.ARROW_DOWN:
  28929. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28930. _this.closeEditorAndSaveChanges(ctrlDown);
  28931. }
  28932. moveSelectionDown(event.shiftKey);
  28933. event.preventDefault();
  28934. (0, _event.stopPropagation)(event);
  28935. break;
  28936. case _unicode.KEY_CODES.ARROW_RIGHT:
  28937. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28938. _this.closeEditorAndSaveChanges(ctrlDown);
  28939. }
  28940. moveSelectionRight(event.shiftKey);
  28941. event.preventDefault();
  28942. (0, _event.stopPropagation)(event);
  28943. break;
  28944. case _unicode.KEY_CODES.ARROW_LEFT:
  28945. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  28946. _this.closeEditorAndSaveChanges(ctrlDown);
  28947. }
  28948. moveSelectionLeft(event.shiftKey);
  28949. event.preventDefault();
  28950. (0, _event.stopPropagation)(event);
  28951. break;
  28952. case _unicode.KEY_CODES.TAB:
  28953. selection.setSelectedHeaders(false, false, false);
  28954. var tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves;
  28955. if (event.shiftKey) {
  28956. // move selection left
  28957. selection.transformStart(-tabMoves.row, -tabMoves.col);
  28958. } else {
  28959. // move selection right (add a new column if needed)
  28960. selection.transformStart(tabMoves.row, tabMoves.col, true);
  28961. }
  28962. event.preventDefault();
  28963. (0, _event.stopPropagation)(event);
  28964. break;
  28965. case _unicode.KEY_CODES.BACKSPACE:
  28966. case _unicode.KEY_CODES.DELETE:
  28967. selection.empty(event);
  28968. _this.prepareEditor();
  28969. event.preventDefault();
  28970. break;
  28971. case _unicode.KEY_CODES.F2:
  28972. /* F2 */
  28973. _this.openEditor(null, event);
  28974. if (activeEditor) {
  28975. activeEditor.enableFullEditMode();
  28976. }
  28977. event.preventDefault(); // prevent Opera from opening 'Go to Page dialog'
  28978. break;
  28979. case _unicode.KEY_CODES.ENTER:
  28980. /* return/enter */
  28981. if (_this.isEditorOpened()) {
  28982. if (activeEditor && activeEditor.state !== _baseEditor.EditorState.WAITING) {
  28983. _this.closeEditorAndSaveChanges(ctrlDown);
  28984. }
  28985. moveSelectionAfterEnter(event.shiftKey);
  28986. } else if (instance.getSettings().enterBeginsEditing) {
  28987. _this.openEditor(null, event);
  28988. if (activeEditor) {
  28989. activeEditor.enableFullEditMode();
  28990. }
  28991. } else {
  28992. moveSelectionAfterEnter(event.shiftKey);
  28993. }
  28994. event.preventDefault(); // don't add newline to field
  28995. (0, _event.stopImmediatePropagation)(event); // required by HandsontableEditor
  28996. break;
  28997. case _unicode.KEY_CODES.ESCAPE:
  28998. if (_this.isEditorOpened()) {
  28999. _this.closeEditorAndRestoreOriginalValue(ctrlDown);
  29000. }
  29001. event.preventDefault();
  29002. break;
  29003. case _unicode.KEY_CODES.HOME:
  29004. selection.setSelectedHeaders(false, false, false);
  29005. if (event.ctrlKey || event.metaKey) {
  29006. rangeModifier(new _src.CellCoords(0, priv.selRange.from.col));
  29007. } else {
  29008. rangeModifier(new _src.CellCoords(priv.selRange.from.row, 0));
  29009. }
  29010. event.preventDefault(); // don't scroll the window
  29011. (0, _event.stopPropagation)(event);
  29012. break;
  29013. case _unicode.KEY_CODES.END:
  29014. selection.setSelectedHeaders(false, false, false);
  29015. if (event.ctrlKey || event.metaKey) {
  29016. rangeModifier(new _src.CellCoords(instance.countRows() - 1, priv.selRange.from.col));
  29017. } else {
  29018. rangeModifier(new _src.CellCoords(priv.selRange.from.row, instance.countCols() - 1));
  29019. }
  29020. event.preventDefault(); // don't scroll the window
  29021. (0, _event.stopPropagation)(event);
  29022. break;
  29023. case _unicode.KEY_CODES.PAGE_UP:
  29024. selection.setSelectedHeaders(false, false, false);
  29025. selection.transformStart(-instance.countVisibleRows(), 0);
  29026. event.preventDefault(); // don't page up the window
  29027. (0, _event.stopPropagation)(event);
  29028. break;
  29029. case _unicode.KEY_CODES.PAGE_DOWN:
  29030. selection.setSelectedHeaders(false, false, false);
  29031. selection.transformStart(instance.countVisibleRows(), 0);
  29032. event.preventDefault(); // don't page down the window
  29033. (0, _event.stopPropagation)(event);
  29034. break;
  29035. default:
  29036. break;
  29037. }
  29038. }
  29039. function init() {
  29040. instance.addHook('afterDocumentKeyDown', onKeyDown);
  29041. eventManager.addEventListener(document.documentElement, 'keydown', function (event) {
  29042. if (!destroyed) {
  29043. instance.runHooks('afterDocumentKeyDown', event);
  29044. }
  29045. });
  29046. function onDblClick(event, coords, elem) {
  29047. // may be TD or TH
  29048. if (elem.nodeName == 'TD') {
  29049. _this.openEditor();
  29050. if (activeEditor) {
  29051. activeEditor.enableFullEditMode();
  29052. }
  29053. }
  29054. }
  29055. instance.view.wt.update('onCellDblClick', onDblClick);
  29056. instance.addHook('afterDestroy', function () {
  29057. destroyed = true;
  29058. });
  29059. }
  29060. /**
  29061. * Destroy current editor, if exists.
  29062. *
  29063. * @function destroyEditor
  29064. * @memberof! Handsontable.EditorManager#
  29065. * @param {Boolean} revertOriginal
  29066. */
  29067. this.destroyEditor = function (revertOriginal) {
  29068. this.closeEditor(revertOriginal);
  29069. };
  29070. /**
  29071. * Get active editor.
  29072. *
  29073. * @function getActiveEditor
  29074. * @memberof! Handsontable.EditorManager#
  29075. * @returns {*}
  29076. */
  29077. this.getActiveEditor = function () {
  29078. return activeEditor;
  29079. };
  29080. /**
  29081. * Prepare text input to be displayed at given grid cell.
  29082. *
  29083. * @function prepareEditor
  29084. * @memberof! Handsontable.EditorManager#
  29085. */
  29086. this.prepareEditor = function () {
  29087. var row, col, prop, td, originalValue, cellProperties, editorClass;
  29088. if (activeEditor && activeEditor.isWaiting()) {
  29089. this.closeEditor(false, false, function (dataSaved) {
  29090. if (dataSaved) {
  29091. _this.prepareEditor();
  29092. }
  29093. });
  29094. return;
  29095. }
  29096. row = priv.selRange.highlight.row;
  29097. col = priv.selRange.highlight.col;
  29098. prop = instance.colToProp(col);
  29099. td = instance.getCell(row, col);
  29100. originalValue = instance.getSourceDataAtCell(instance.runHooks('modifyRow', row), col);
  29101. cellProperties = instance.getCellMeta(row, col);
  29102. editorClass = instance.getCellEditor(cellProperties);
  29103. if (editorClass) {
  29104. activeEditor = (0, _editors.getEditorInstance)(editorClass, instance);
  29105. activeEditor.prepare(row, col, prop, td, originalValue, cellProperties);
  29106. } else {
  29107. activeEditor = void 0;
  29108. }
  29109. };
  29110. /**
  29111. * Check is editor is opened/showed.
  29112. *
  29113. * @function isEditorOpened
  29114. * @memberof! Handsontable.EditorManager#
  29115. * @returns {Boolean}
  29116. */
  29117. this.isEditorOpened = function () {
  29118. return activeEditor && activeEditor.isOpened();
  29119. };
  29120. /**
  29121. * Open editor with initial value.
  29122. *
  29123. * @function openEditor
  29124. * @memberof! Handsontable.EditorManager#
  29125. * @param {String} initialValue
  29126. * @param {DOMEvent} event
  29127. */
  29128. this.openEditor = function (initialValue, event) {
  29129. if (activeEditor && !activeEditor.cellProperties.readOnly) {
  29130. activeEditor.beginEditing(initialValue, event);
  29131. } else if (activeEditor && activeEditor.cellProperties.readOnly) {
  29132. // move the selection after opening the editor with ENTER key
  29133. if (event && event.keyCode === _unicode.KEY_CODES.ENTER) {
  29134. moveSelectionAfterEnter();
  29135. }
  29136. }
  29137. };
  29138. /**
  29139. * Close editor, finish editing cell.
  29140. *
  29141. * @function closeEditor
  29142. * @memberof! Handsontable.EditorManager#
  29143. * @param {Boolean} restoreOriginalValue
  29144. * @param {Boolean} [ctrlDown]
  29145. * @param {Function} [callback]
  29146. */
  29147. this.closeEditor = function (restoreOriginalValue, ctrlDown, callback) {
  29148. if (activeEditor) {
  29149. activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback);
  29150. } else if (callback) {
  29151. callback(false);
  29152. }
  29153. };
  29154. /**
  29155. * Close editor and save changes.
  29156. *
  29157. * @function closeEditorAndSaveChanges
  29158. * @memberof! Handsontable.EditorManager#
  29159. * @param {Boolean} ctrlDown
  29160. */
  29161. this.closeEditorAndSaveChanges = function (ctrlDown) {
  29162. return this.closeEditor(false, ctrlDown);
  29163. };
  29164. /**
  29165. * Close editor and restore original value.
  29166. *
  29167. * @function closeEditorAndRestoreOriginalValue
  29168. * @memberof! Handsontable.EditorManager#
  29169. * @param {Boolean} ctrlDown
  29170. */
  29171. this.closeEditorAndRestoreOriginalValue = function (ctrlDown) {
  29172. return this.closeEditor(true, ctrlDown);
  29173. };
  29174. init();
  29175. }
  29176. exports.default = EditorManager;
  29177. /***/ }),
  29178. /* 316 */
  29179. /***/ (function(module, exports, __webpack_require__) {
  29180. "use strict";
  29181. exports.__esModule = true;
  29182. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  29183. var _baseEditor = __webpack_require__(37);
  29184. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  29185. var _element = __webpack_require__(0);
  29186. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29187. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29188. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  29189. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  29190. /**
  29191. * @private
  29192. * @editor CheckboxEditor
  29193. * @class CheckboxEditor
  29194. */
  29195. var CheckboxEditor = function (_BaseEditor) {
  29196. _inherits(CheckboxEditor, _BaseEditor);
  29197. function CheckboxEditor() {
  29198. _classCallCheck(this, CheckboxEditor);
  29199. return _possibleConstructorReturn(this, (CheckboxEditor.__proto__ || Object.getPrototypeOf(CheckboxEditor)).apply(this, arguments));
  29200. }
  29201. _createClass(CheckboxEditor, [{
  29202. key: 'beginEditing',
  29203. value: function beginEditing(initialValue, event) {
  29204. // editorManager return double click event as undefined
  29205. if (event === void 0) {
  29206. var checkbox = this.TD.querySelector('input[type="checkbox"]');
  29207. if (!(0, _element.hasClass)(checkbox, 'htBadValue')) {
  29208. checkbox.click();
  29209. }
  29210. }
  29211. }
  29212. }, {
  29213. key: 'finishEditing',
  29214. value: function finishEditing() {}
  29215. }, {
  29216. key: 'init',
  29217. value: function init() {}
  29218. }, {
  29219. key: 'open',
  29220. value: function open() {}
  29221. }, {
  29222. key: 'close',
  29223. value: function close() {}
  29224. }, {
  29225. key: 'getValue',
  29226. value: function getValue() {}
  29227. }, {
  29228. key: 'setValue',
  29229. value: function setValue() {}
  29230. }, {
  29231. key: 'focus',
  29232. value: function focus() {}
  29233. }]);
  29234. return CheckboxEditor;
  29235. }(_baseEditor2.default);
  29236. exports.default = CheckboxEditor;
  29237. /***/ }),
  29238. /* 317 */
  29239. /***/ (function(module, exports, __webpack_require__) {
  29240. "use strict";
  29241. exports.__esModule = true;
  29242. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  29243. var _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); } };
  29244. var _moment = __webpack_require__(36);
  29245. var _moment2 = _interopRequireDefault(_moment);
  29246. var _pikaday = __webpack_require__(419);
  29247. var _pikaday2 = _interopRequireDefault(_pikaday);
  29248. __webpack_require__(411);
  29249. var _element = __webpack_require__(0);
  29250. var _object = __webpack_require__(1);
  29251. var _eventManager = __webpack_require__(4);
  29252. var _eventManager2 = _interopRequireDefault(_eventManager);
  29253. var _unicode = __webpack_require__(16);
  29254. var _event = __webpack_require__(7);
  29255. var _textEditor = __webpack_require__(44);
  29256. var _textEditor2 = _interopRequireDefault(_textEditor);
  29257. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29258. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29259. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  29260. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  29261. /**
  29262. * @private
  29263. * @editor DateEditor
  29264. * @class DateEditor
  29265. * @dependencies TextEditor moment pikaday
  29266. */
  29267. var DateEditor = function (_TextEditor) {
  29268. _inherits(DateEditor, _TextEditor);
  29269. /**
  29270. * @param {Core} hotInstance Handsontable instance
  29271. * @private
  29272. */
  29273. function DateEditor(hotInstance) {
  29274. _classCallCheck(this, DateEditor);
  29275. // TODO: Move this option to general settings
  29276. var _this = _possibleConstructorReturn(this, (DateEditor.__proto__ || Object.getPrototypeOf(DateEditor)).call(this, hotInstance));
  29277. _this.defaultDateFormat = 'DD/MM/YYYY';
  29278. _this.isCellEdited = false;
  29279. _this.parentDestroyed = false;
  29280. return _this;
  29281. }
  29282. _createClass(DateEditor, [{
  29283. key: 'init',
  29284. value: function init() {
  29285. var _this2 = this;
  29286. if (typeof _moment2.default !== 'function') {
  29287. throw new Error('You need to include moment.js to your project.');
  29288. }
  29289. if (typeof _pikaday2.default !== 'function') {
  29290. throw new Error('You need to include Pikaday to your project.');
  29291. }
  29292. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'init', this).call(this);
  29293. this.instance.addHook('afterDestroy', function () {
  29294. _this2.parentDestroyed = true;
  29295. _this2.destroyElements();
  29296. });
  29297. }
  29298. /**
  29299. * Create data picker instance
  29300. */
  29301. }, {
  29302. key: 'createElements',
  29303. value: function createElements() {
  29304. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'createElements', this).call(this);
  29305. this.datePicker = document.createElement('DIV');
  29306. this.datePickerStyle = this.datePicker.style;
  29307. this.datePickerStyle.position = 'absolute';
  29308. this.datePickerStyle.top = 0;
  29309. this.datePickerStyle.left = 0;
  29310. this.datePickerStyle.zIndex = 9999;
  29311. (0, _element.addClass)(this.datePicker, 'htDatepickerHolder');
  29312. document.body.appendChild(this.datePicker);
  29313. this.$datePicker = new _pikaday2.default(this.getDatePickerConfig());
  29314. var eventManager = new _eventManager2.default(this);
  29315. /**
  29316. * Prevent recognizing clicking on datepicker as clicking outside of table
  29317. */
  29318. eventManager.addEventListener(this.datePicker, 'mousedown', function (event) {
  29319. return (0, _event.stopPropagation)(event);
  29320. });
  29321. this.hideDatepicker();
  29322. }
  29323. /**
  29324. * Destroy data picker instance
  29325. */
  29326. }, {
  29327. key: 'destroyElements',
  29328. value: function destroyElements() {
  29329. this.$datePicker.destroy();
  29330. }
  29331. /**
  29332. * Prepare editor to appear
  29333. *
  29334. * @param {Number} row Row index
  29335. * @param {Number} col Column index
  29336. * @param {String} prop Property name (passed when datasource is an array of objects)
  29337. * @param {HTMLTableCellElement} td Table cell element
  29338. * @param {*} originalValue Original value
  29339. * @param {Object} cellProperties Object with cell properties ({@see Core#getCellMeta})
  29340. */
  29341. }, {
  29342. key: 'prepare',
  29343. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  29344. this._opened = false;
  29345. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  29346. }
  29347. /**
  29348. * Open editor
  29349. *
  29350. * @param {Event} [event=null]
  29351. */
  29352. }, {
  29353. key: 'open',
  29354. value: function open() {
  29355. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  29356. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'open', this).call(this);
  29357. this.showDatepicker(event);
  29358. }
  29359. /**
  29360. * Close editor
  29361. */
  29362. }, {
  29363. key: 'close',
  29364. value: function close() {
  29365. var _this3 = this;
  29366. this._opened = false;
  29367. this.instance._registerTimeout(setTimeout(function () {
  29368. _this3.instance.selection.refreshBorders();
  29369. }, 0));
  29370. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'close', this).call(this);
  29371. }
  29372. /**
  29373. * @param {Boolean} [isCancelled=false]
  29374. * @param {Boolean} [ctrlDown=false]
  29375. */
  29376. }, {
  29377. key: 'finishEditing',
  29378. value: function finishEditing() {
  29379. var isCancelled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  29380. var ctrlDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  29381. if (isCancelled) {
  29382. // pressed ESC, restore original value
  29383. // var value = this.instance.getDataAtCell(this.row, this.col);
  29384. var value = this.originalValue;
  29385. if (value !== void 0) {
  29386. this.setValue(value);
  29387. }
  29388. }
  29389. this.hideDatepicker();
  29390. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'finishEditing', this).call(this, isCancelled, ctrlDown);
  29391. }
  29392. /**
  29393. * Show data picker
  29394. *
  29395. * @param {Event} event
  29396. */
  29397. }, {
  29398. key: 'showDatepicker',
  29399. value: function showDatepicker(event) {
  29400. this.$datePicker.config(this.getDatePickerConfig());
  29401. var offset = this.TD.getBoundingClientRect();
  29402. var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat;
  29403. var datePickerConfig = this.$datePicker.config();
  29404. var dateStr = void 0;
  29405. var isMouseDown = this.instance.view.isMouseDown();
  29406. var isMeta = event ? (0, _unicode.isMetaKey)(event.keyCode) : false;
  29407. this.datePickerStyle.top = window.pageYOffset + offset.top + (0, _element.outerHeight)(this.TD) + 'px';
  29408. this.datePickerStyle.left = window.pageXOffset + offset.left + 'px';
  29409. this.$datePicker._onInputFocus = function () {};
  29410. datePickerConfig.format = dateFormat;
  29411. if (this.originalValue) {
  29412. dateStr = this.originalValue;
  29413. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  29414. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  29415. }
  29416. // workaround for date/time cells - pikaday resets the cell value to 12:00 AM by default, this will overwrite the value.
  29417. if (this.getValue() !== this.originalValue) {
  29418. this.setValue(this.originalValue);
  29419. }
  29420. if (!isMeta && !isMouseDown) {
  29421. this.setValue('');
  29422. }
  29423. } else if (this.cellProperties.defaultDate) {
  29424. dateStr = this.cellProperties.defaultDate;
  29425. datePickerConfig.defaultDate = dateStr;
  29426. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  29427. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  29428. }
  29429. if (!isMeta && !isMouseDown) {
  29430. this.setValue('');
  29431. }
  29432. } else {
  29433. // if a default date is not defined, set a soft-default-date: display the current day and month in the
  29434. // datepicker, but don't fill the editor input
  29435. this.$datePicker.gotoToday();
  29436. }
  29437. this.datePickerStyle.display = 'block';
  29438. this.$datePicker.show();
  29439. }
  29440. /**
  29441. * Hide data picker
  29442. */
  29443. }, {
  29444. key: 'hideDatepicker',
  29445. value: function hideDatepicker() {
  29446. this.datePickerStyle.display = 'none';
  29447. this.$datePicker.hide();
  29448. }
  29449. /**
  29450. * Get date picker options.
  29451. *
  29452. * @returns {Object}
  29453. */
  29454. }, {
  29455. key: 'getDatePickerConfig',
  29456. value: function getDatePickerConfig() {
  29457. var _this4 = this;
  29458. var htInput = this.TEXTAREA;
  29459. var options = {};
  29460. if (this.cellProperties && this.cellProperties.datePickerConfig) {
  29461. (0, _object.deepExtend)(options, this.cellProperties.datePickerConfig);
  29462. }
  29463. var origOnSelect = options.onSelect;
  29464. var origOnClose = options.onClose;
  29465. options.field = htInput;
  29466. options.trigger = htInput;
  29467. options.container = this.datePicker;
  29468. options.bound = false;
  29469. options.format = options.format || this.defaultDateFormat;
  29470. options.reposition = options.reposition || false;
  29471. options.onSelect = function (dateStr) {
  29472. if (!isNaN(dateStr.getTime())) {
  29473. dateStr = (0, _moment2.default)(dateStr).format(_this4.cellProperties.dateFormat || _this4.defaultDateFormat);
  29474. }
  29475. _this4.setValue(dateStr);
  29476. _this4.hideDatepicker();
  29477. if (origOnSelect) {
  29478. origOnSelect();
  29479. }
  29480. };
  29481. options.onClose = function () {
  29482. if (!_this4.parentDestroyed) {
  29483. _this4.finishEditing(false);
  29484. }
  29485. if (origOnClose) {
  29486. origOnClose();
  29487. }
  29488. };
  29489. return options;
  29490. }
  29491. }]);
  29492. return DateEditor;
  29493. }(_textEditor2.default);
  29494. exports.default = DateEditor;
  29495. /***/ }),
  29496. /* 318 */
  29497. /***/ (function(module, exports, __webpack_require__) {
  29498. "use strict";
  29499. exports.__esModule = true;
  29500. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  29501. var _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); } };
  29502. var _autocompleteEditor = __webpack_require__(263);
  29503. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  29504. var _pluginHooks = __webpack_require__(8);
  29505. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  29506. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29507. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29508. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  29509. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  29510. /**
  29511. * @private
  29512. * @editor DropdownEditor
  29513. * @class DropdownEditor
  29514. * @dependencies AutocompleteEditor
  29515. */
  29516. var DropdownEditor = function (_AutocompleteEditor) {
  29517. _inherits(DropdownEditor, _AutocompleteEditor);
  29518. function DropdownEditor() {
  29519. _classCallCheck(this, DropdownEditor);
  29520. return _possibleConstructorReturn(this, (DropdownEditor.__proto__ || Object.getPrototypeOf(DropdownEditor)).apply(this, arguments));
  29521. }
  29522. _createClass(DropdownEditor, [{
  29523. key: 'prepare',
  29524. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  29525. _get(DropdownEditor.prototype.__proto__ || Object.getPrototypeOf(DropdownEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  29526. this.cellProperties.filter = false;
  29527. this.cellProperties.strict = true;
  29528. }
  29529. }]);
  29530. return DropdownEditor;
  29531. }(_autocompleteEditor2.default);
  29532. _pluginHooks2.default.getSingleton().add('beforeValidate', function (value, row, col, source) {
  29533. var cellMeta = this.getCellMeta(row, this.propToCol(col));
  29534. if (cellMeta.editor === DropdownEditor) {
  29535. if (cellMeta.strict === void 0) {
  29536. cellMeta.filter = false;
  29537. cellMeta.strict = true;
  29538. }
  29539. }
  29540. });
  29541. exports.default = DropdownEditor;
  29542. /***/ }),
  29543. /* 319 */
  29544. /***/ (function(module, exports, __webpack_require__) {
  29545. "use strict";
  29546. exports.__esModule = true;
  29547. var _unicode = __webpack_require__(16);
  29548. var _event = __webpack_require__(7);
  29549. var _element = __webpack_require__(0);
  29550. var _baseEditor = __webpack_require__(37);
  29551. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  29552. var _eventManager = __webpack_require__(4);
  29553. var _eventManager2 = _interopRequireDefault(_eventManager);
  29554. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29555. var MobileTextEditor = _baseEditor2.default.prototype.extend();
  29556. var domDimensionsCache = {};
  29557. /**
  29558. * @private
  29559. * @editor MobileTextEditor
  29560. * @class MobileTextEditor
  29561. */
  29562. var createControls = function createControls() {
  29563. this.controls = {};
  29564. this.controls.leftButton = document.createElement('DIV');
  29565. this.controls.leftButton.className = 'leftButton';
  29566. this.controls.rightButton = document.createElement('DIV');
  29567. this.controls.rightButton.className = 'rightButton';
  29568. this.controls.upButton = document.createElement('DIV');
  29569. this.controls.upButton.className = 'upButton';
  29570. this.controls.downButton = document.createElement('DIV');
  29571. this.controls.downButton.className = 'downButton';
  29572. for (var button in this.controls) {
  29573. if (Object.prototype.hasOwnProperty.call(this.controls, button)) {
  29574. this.positionControls.appendChild(this.controls[button]);
  29575. }
  29576. }
  29577. };
  29578. MobileTextEditor.prototype.valueChanged = function () {
  29579. return this.initValue != this.getValue();
  29580. };
  29581. MobileTextEditor.prototype.init = function () {
  29582. var that = this;
  29583. this.eventManager = new _eventManager2.default(this.instance);
  29584. this.createElements();
  29585. this.bindEvents();
  29586. this.instance.addHook('afterDestroy', function () {
  29587. that.destroy();
  29588. });
  29589. };
  29590. MobileTextEditor.prototype.getValue = function () {
  29591. return this.TEXTAREA.value;
  29592. };
  29593. MobileTextEditor.prototype.setValue = function (newValue) {
  29594. this.initValue = newValue;
  29595. this.TEXTAREA.value = newValue;
  29596. };
  29597. MobileTextEditor.prototype.createElements = function () {
  29598. this.editorContainer = document.createElement('DIV');
  29599. this.editorContainer.className = 'htMobileEditorContainer';
  29600. this.cellPointer = document.createElement('DIV');
  29601. this.cellPointer.className = 'cellPointer';
  29602. this.moveHandle = document.createElement('DIV');
  29603. this.moveHandle.className = 'moveHandle';
  29604. this.inputPane = document.createElement('DIV');
  29605. this.inputPane.className = 'inputs';
  29606. this.positionControls = document.createElement('DIV');
  29607. this.positionControls.className = 'positionControls';
  29608. this.TEXTAREA = document.createElement('TEXTAREA');
  29609. (0, _element.addClass)(this.TEXTAREA, 'handsontableInput');
  29610. this.inputPane.appendChild(this.TEXTAREA);
  29611. this.editorContainer.appendChild(this.cellPointer);
  29612. this.editorContainer.appendChild(this.moveHandle);
  29613. this.editorContainer.appendChild(this.inputPane);
  29614. this.editorContainer.appendChild(this.positionControls);
  29615. createControls.call(this);
  29616. document.body.appendChild(this.editorContainer);
  29617. };
  29618. MobileTextEditor.prototype.onBeforeKeyDown = function (event) {
  29619. var instance = this;
  29620. var that = instance.getActiveEditor();
  29621. if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) {
  29622. return;
  29623. }
  29624. switch (event.keyCode) {
  29625. case _unicode.KEY_CODES.ENTER:
  29626. that.close();
  29627. event.preventDefault(); // don't add newline to field
  29628. break;
  29629. case _unicode.KEY_CODES.BACKSPACE:
  29630. (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context)
  29631. break;
  29632. default:
  29633. break;
  29634. }
  29635. };
  29636. MobileTextEditor.prototype.open = function () {
  29637. this.instance.addHook('beforeKeyDown', this.onBeforeKeyDown);
  29638. (0, _element.addClass)(this.editorContainer, 'active');
  29639. (0, _element.removeClass)(this.cellPointer, 'hidden');
  29640. this.updateEditorPosition();
  29641. };
  29642. MobileTextEditor.prototype.focus = function () {
  29643. this.TEXTAREA.focus();
  29644. (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length);
  29645. };
  29646. MobileTextEditor.prototype.close = function () {
  29647. this.TEXTAREA.blur();
  29648. this.instance.removeHook('beforeKeyDown', this.onBeforeKeyDown);
  29649. (0, _element.removeClass)(this.editorContainer, 'active');
  29650. };
  29651. MobileTextEditor.prototype.scrollToView = function () {
  29652. var coords = this.instance.getSelectedRange().highlight;
  29653. this.instance.view.scrollViewport(coords);
  29654. };
  29655. MobileTextEditor.prototype.hideCellPointer = function () {
  29656. if (!(0, _element.hasClass)(this.cellPointer, 'hidden')) {
  29657. (0, _element.addClass)(this.cellPointer, 'hidden');
  29658. }
  29659. };
  29660. MobileTextEditor.prototype.updateEditorPosition = function (x, y) {
  29661. if (x && y) {
  29662. x = parseInt(x, 10);
  29663. y = parseInt(y, 10);
  29664. this.editorContainer.style.top = y + 'px';
  29665. this.editorContainer.style.left = x + 'px';
  29666. } else {
  29667. var selection = this.instance.getSelected(),
  29668. selectedCell = this.instance.getCell(selection[0], selection[1]);
  29669. // cache sizes
  29670. if (!domDimensionsCache.cellPointer) {
  29671. domDimensionsCache.cellPointer = {
  29672. height: (0, _element.outerHeight)(this.cellPointer),
  29673. width: (0, _element.outerWidth)(this.cellPointer)
  29674. };
  29675. }
  29676. if (!domDimensionsCache.editorContainer) {
  29677. domDimensionsCache.editorContainer = {
  29678. width: (0, _element.outerWidth)(this.editorContainer)
  29679. };
  29680. }
  29681. if (selectedCell !== undefined) {
  29682. var scrollLeft = this.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer == window ? 0 : (0, _element.getScrollLeft)(this.instance.view.wt.wtOverlays.leftOverlay.holder);
  29683. var scrollTop = this.instance.view.wt.wtOverlays.topOverlay.trimmingContainer == window ? 0 : (0, _element.getScrollTop)(this.instance.view.wt.wtOverlays.topOverlay.holder);
  29684. var selectedCellOffset = (0, _element.offset)(selectedCell),
  29685. selectedCellWidth = (0, _element.outerWidth)(selectedCell),
  29686. currentScrollPosition = {
  29687. x: scrollLeft,
  29688. y: scrollTop
  29689. };
  29690. this.editorContainer.style.top = parseInt(selectedCellOffset.top + (0, _element.outerHeight)(selectedCell) - currentScrollPosition.y + domDimensionsCache.cellPointer.height, 10) + 'px';
  29691. this.editorContainer.style.left = parseInt(window.innerWidth / 2 - domDimensionsCache.editorContainer.width / 2, 10) + 'px';
  29692. if (selectedCellOffset.left + selectedCellWidth / 2 > parseInt(this.editorContainer.style.left, 10) + domDimensionsCache.editorContainer.width) {
  29693. this.editorContainer.style.left = window.innerWidth - domDimensionsCache.editorContainer.width + 'px';
  29694. } else if (selectedCellOffset.left + selectedCellWidth / 2 < parseInt(this.editorContainer.style.left, 10) + 20) {
  29695. this.editorContainer.style.left = 0 + 'px';
  29696. }
  29697. this.cellPointer.style.left = parseInt(selectedCellOffset.left - domDimensionsCache.cellPointer.width / 2 - (0, _element.offset)(this.editorContainer).left + selectedCellWidth / 2 - currentScrollPosition.x, 10) + 'px';
  29698. }
  29699. }
  29700. };
  29701. MobileTextEditor.prototype.updateEditorData = function () {
  29702. var selected = this.instance.getSelected(),
  29703. selectedValue = this.instance.getDataAtCell(selected[0], selected[1]);
  29704. this.row = selected[0];
  29705. this.col = selected[1];
  29706. this.setValue(selectedValue);
  29707. this.updateEditorPosition();
  29708. };
  29709. MobileTextEditor.prototype.prepareAndSave = function () {
  29710. var val;
  29711. if (!this.valueChanged()) {
  29712. return;
  29713. }
  29714. if (this.instance.getSettings().trimWhitespace) {
  29715. val = [[String.prototype.trim.call(this.getValue())]];
  29716. } else {
  29717. val = [[this.getValue()]];
  29718. }
  29719. this.saveValue(val);
  29720. };
  29721. MobileTextEditor.prototype.bindEvents = function () {
  29722. var that = this;
  29723. this.eventManager.addEventListener(this.controls.leftButton, 'touchend', function (event) {
  29724. that.prepareAndSave();
  29725. that.instance.selection.transformStart(0, -1, null, true);
  29726. that.updateEditorData();
  29727. event.preventDefault();
  29728. });
  29729. this.eventManager.addEventListener(this.controls.rightButton, 'touchend', function (event) {
  29730. that.prepareAndSave();
  29731. that.instance.selection.transformStart(0, 1, null, true);
  29732. that.updateEditorData();
  29733. event.preventDefault();
  29734. });
  29735. this.eventManager.addEventListener(this.controls.upButton, 'touchend', function (event) {
  29736. that.prepareAndSave();
  29737. that.instance.selection.transformStart(-1, 0, null, true);
  29738. that.updateEditorData();
  29739. event.preventDefault();
  29740. });
  29741. this.eventManager.addEventListener(this.controls.downButton, 'touchend', function (event) {
  29742. that.prepareAndSave();
  29743. that.instance.selection.transformStart(1, 0, null, true);
  29744. that.updateEditorData();
  29745. event.preventDefault();
  29746. });
  29747. this.eventManager.addEventListener(this.moveHandle, 'touchstart', function (event) {
  29748. if (event.touches.length == 1) {
  29749. var touch = event.touches[0];
  29750. var onTouchPosition = {
  29751. x: that.editorContainer.offsetLeft,
  29752. y: that.editorContainer.offsetTop
  29753. };
  29754. var onTouchOffset = {
  29755. x: touch.pageX - onTouchPosition.x,
  29756. y: touch.pageY - onTouchPosition.y
  29757. };
  29758. that.eventManager.addEventListener(this, 'touchmove', function (event) {
  29759. var touch = event.touches[0];
  29760. that.updateEditorPosition(touch.pageX - onTouchOffset.x, touch.pageY - onTouchOffset.y);
  29761. that.hideCellPointer();
  29762. event.preventDefault();
  29763. });
  29764. }
  29765. });
  29766. this.eventManager.addEventListener(document.body, 'touchend', function (event) {
  29767. if (!(0, _element.isChildOf)(event.target, that.editorContainer) && !(0, _element.isChildOf)(event.target, that.instance.rootElement)) {
  29768. that.close();
  29769. }
  29770. });
  29771. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.leftOverlay.holder, 'scroll', function (event) {
  29772. if (that.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer != window) {
  29773. that.hideCellPointer();
  29774. }
  29775. });
  29776. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.topOverlay.holder, 'scroll', function (event) {
  29777. if (that.instance.view.wt.wtOverlays.topOverlay.trimmingContainer != window) {
  29778. that.hideCellPointer();
  29779. }
  29780. });
  29781. };
  29782. MobileTextEditor.prototype.destroy = function () {
  29783. this.eventManager.clear();
  29784. this.editorContainer.parentNode.removeChild(this.editorContainer);
  29785. };
  29786. exports.default = MobileTextEditor;
  29787. /***/ }),
  29788. /* 320 */
  29789. /***/ (function(module, exports, __webpack_require__) {
  29790. "use strict";
  29791. exports.__esModule = true;
  29792. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  29793. var _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); } };
  29794. var _numbro = __webpack_require__(51);
  29795. var _numbro2 = _interopRequireDefault(_numbro);
  29796. var _textEditor = __webpack_require__(44);
  29797. var _textEditor2 = _interopRequireDefault(_textEditor);
  29798. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29799. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29800. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  29801. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  29802. /**
  29803. * @private
  29804. * @editor NumericEditor
  29805. * @class NumericEditor
  29806. * @dependencies TextEditor numbro
  29807. */
  29808. var NumericEditor = function (_TextEditor) {
  29809. _inherits(NumericEditor, _TextEditor);
  29810. function NumericEditor() {
  29811. _classCallCheck(this, NumericEditor);
  29812. return _possibleConstructorReturn(this, (NumericEditor.__proto__ || Object.getPrototypeOf(NumericEditor)).apply(this, arguments));
  29813. }
  29814. _createClass(NumericEditor, [{
  29815. key: 'beginEditing',
  29816. /**
  29817. * @param {*} initialValue
  29818. */
  29819. value: function beginEditing(initialValue) {
  29820. if (typeof initialValue === 'undefined' && this.originalValue) {
  29821. if (typeof this.cellProperties.language !== 'undefined') {
  29822. _numbro2.default.culture(this.cellProperties.language);
  29823. }
  29824. var decimalDelimiter = _numbro2.default.cultureData().delimiters.decimal;
  29825. initialValue = ('' + this.originalValue).replace('.', decimalDelimiter);
  29826. }
  29827. _get(NumericEditor.prototype.__proto__ || Object.getPrototypeOf(NumericEditor.prototype), 'beginEditing', this).call(this, initialValue);
  29828. }
  29829. }]);
  29830. return NumericEditor;
  29831. }(_textEditor2.default);
  29832. exports.default = NumericEditor;
  29833. /***/ }),
  29834. /* 321 */
  29835. /***/ (function(module, exports, __webpack_require__) {
  29836. "use strict";
  29837. exports.__esModule = true;
  29838. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  29839. var _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); } };
  29840. var _element = __webpack_require__(0);
  29841. var _textEditor = __webpack_require__(44);
  29842. var _textEditor2 = _interopRequireDefault(_textEditor);
  29843. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29844. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29845. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  29846. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  29847. /**
  29848. * @private
  29849. * @editor PasswordEditor
  29850. * @class PasswordEditor
  29851. * @dependencies TextEditor
  29852. */
  29853. var PasswordEditor = function (_TextEditor) {
  29854. _inherits(PasswordEditor, _TextEditor);
  29855. function PasswordEditor() {
  29856. _classCallCheck(this, PasswordEditor);
  29857. return _possibleConstructorReturn(this, (PasswordEditor.__proto__ || Object.getPrototypeOf(PasswordEditor)).apply(this, arguments));
  29858. }
  29859. _createClass(PasswordEditor, [{
  29860. key: 'createElements',
  29861. value: function createElements() {
  29862. _get(PasswordEditor.prototype.__proto__ || Object.getPrototypeOf(PasswordEditor.prototype), 'createElements', this).call(this);
  29863. this.TEXTAREA = document.createElement('input');
  29864. this.TEXTAREA.setAttribute('type', 'password');
  29865. this.TEXTAREA.className = 'handsontableInput';
  29866. this.textareaStyle = this.TEXTAREA.style;
  29867. this.textareaStyle.width = 0;
  29868. this.textareaStyle.height = 0;
  29869. (0, _element.empty)(this.TEXTAREA_PARENT);
  29870. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  29871. }
  29872. }]);
  29873. return PasswordEditor;
  29874. }(_textEditor2.default);
  29875. exports.default = PasswordEditor;
  29876. /***/ }),
  29877. /* 322 */
  29878. /***/ (function(module, exports, __webpack_require__) {
  29879. "use strict";
  29880. exports.__esModule = true;
  29881. var _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; };
  29882. var _element = __webpack_require__(0);
  29883. var _event = __webpack_require__(7);
  29884. var _unicode = __webpack_require__(16);
  29885. var _baseEditor = __webpack_require__(37);
  29886. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  29887. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29888. var SelectEditor = _baseEditor2.default.prototype.extend();
  29889. /**
  29890. * @private
  29891. * @editor SelectEditor
  29892. * @class SelectEditor
  29893. */
  29894. SelectEditor.prototype.init = function () {
  29895. this.select = document.createElement('SELECT');
  29896. (0, _element.addClass)(this.select, 'htSelectEditor');
  29897. this.select.style.display = 'none';
  29898. this.instance.rootElement.appendChild(this.select);
  29899. this.registerHooks();
  29900. };
  29901. SelectEditor.prototype.registerHooks = function () {
  29902. var _this = this;
  29903. this.instance.addHook('afterScrollHorizontally', function () {
  29904. return _this.refreshDimensions();
  29905. });
  29906. this.instance.addHook('afterScrollVertically', function () {
  29907. return _this.refreshDimensions();
  29908. });
  29909. this.instance.addHook('afterColumnResize', function () {
  29910. return _this.refreshDimensions();
  29911. });
  29912. this.instance.addHook('afterRowResize', function () {
  29913. return _this.refreshDimensions();
  29914. });
  29915. };
  29916. SelectEditor.prototype.prepare = function () {
  29917. _baseEditor2.default.prototype.prepare.apply(this, arguments);
  29918. var selectOptions = this.cellProperties.selectOptions;
  29919. var options;
  29920. if (typeof selectOptions == 'function') {
  29921. options = this.prepareOptions(selectOptions(this.row, this.col, this.prop));
  29922. } else {
  29923. options = this.prepareOptions(selectOptions);
  29924. }
  29925. (0, _element.empty)(this.select);
  29926. for (var option in options) {
  29927. if (Object.prototype.hasOwnProperty.call(options, option)) {
  29928. var optionElement = document.createElement('OPTION');
  29929. optionElement.value = option;
  29930. (0, _element.fastInnerHTML)(optionElement, options[option]);
  29931. this.select.appendChild(optionElement);
  29932. }
  29933. }
  29934. };
  29935. SelectEditor.prototype.prepareOptions = function (optionsToPrepare) {
  29936. var preparedOptions = {};
  29937. if (Array.isArray(optionsToPrepare)) {
  29938. for (var i = 0, len = optionsToPrepare.length; i < len; i++) {
  29939. preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i];
  29940. }
  29941. } else if ((typeof optionsToPrepare === 'undefined' ? 'undefined' : _typeof(optionsToPrepare)) == 'object') {
  29942. preparedOptions = optionsToPrepare;
  29943. }
  29944. return preparedOptions;
  29945. };
  29946. SelectEditor.prototype.getValue = function () {
  29947. return this.select.value;
  29948. };
  29949. SelectEditor.prototype.setValue = function (value) {
  29950. this.select.value = value;
  29951. };
  29952. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  29953. var instance = this;
  29954. var editor = instance.getActiveEditor();
  29955. switch (event.keyCode) {
  29956. case _unicode.KEY_CODES.ARROW_UP:
  29957. var previousOptionIndex = editor.select.selectedIndex - 1;
  29958. if (previousOptionIndex >= 0) {
  29959. editor.select[previousOptionIndex].selected = true;
  29960. }
  29961. (0, _event.stopImmediatePropagation)(event);
  29962. event.preventDefault();
  29963. break;
  29964. case _unicode.KEY_CODES.ARROW_DOWN:
  29965. var nextOptionIndex = editor.select.selectedIndex + 1;
  29966. if (nextOptionIndex <= editor.select.length - 1) {
  29967. editor.select[nextOptionIndex].selected = true;
  29968. }
  29969. (0, _event.stopImmediatePropagation)(event);
  29970. event.preventDefault();
  29971. break;
  29972. default:
  29973. break;
  29974. }
  29975. };
  29976. SelectEditor.prototype.open = function () {
  29977. this._opened = true;
  29978. this.refreshDimensions();
  29979. this.select.style.display = '';
  29980. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  29981. };
  29982. SelectEditor.prototype.close = function () {
  29983. this._opened = false;
  29984. this.select.style.display = 'none';
  29985. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  29986. };
  29987. SelectEditor.prototype.focus = function () {
  29988. this.select.focus();
  29989. };
  29990. SelectEditor.prototype.refreshValue = function () {
  29991. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  29992. this.originalValue = sourceData;
  29993. this.setValue(sourceData);
  29994. this.refreshDimensions();
  29995. };
  29996. SelectEditor.prototype.refreshDimensions = function () {
  29997. if (this.state !== _baseEditor.EditorState.EDITING) {
  29998. return;
  29999. }
  30000. this.TD = this.getEditedCell();
  30001. // TD is outside of the viewport.
  30002. if (!this.TD) {
  30003. this.close();
  30004. return;
  30005. }
  30006. var width = (0, _element.outerWidth)(this.TD) + 1,
  30007. height = (0, _element.outerHeight)(this.TD) + 1,
  30008. currentOffset = (0, _element.offset)(this.TD),
  30009. containerOffset = (0, _element.offset)(this.instance.rootElement),
  30010. scrollableContainer = (0, _element.getScrollableElement)(this.TD),
  30011. editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
  30012. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  30013. editorSection = this.checkEditorSection(),
  30014. cssTransformOffset;
  30015. var settings = this.instance.getSettings();
  30016. var rowHeadersCount = settings.rowHeaders ? 1 : 0;
  30017. var colHeadersCount = settings.colHeaders ? 1 : 0;
  30018. switch (editorSection) {
  30019. case 'top':
  30020. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  30021. break;
  30022. case 'left':
  30023. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  30024. break;
  30025. case 'top-left-corner':
  30026. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  30027. break;
  30028. case 'bottom-left-corner':
  30029. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  30030. break;
  30031. case 'bottom':
  30032. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  30033. break;
  30034. default:
  30035. break;
  30036. }
  30037. if (this.instance.getSelected()[0] === 0) {
  30038. editTop += 1;
  30039. }
  30040. if (this.instance.getSelected()[1] === 0) {
  30041. editLeft += 1;
  30042. }
  30043. var selectStyle = this.select.style;
  30044. if (cssTransformOffset && cssTransformOffset != -1) {
  30045. selectStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  30046. } else {
  30047. (0, _element.resetCssTransform)(this.select);
  30048. }
  30049. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  30050. if (parseInt(cellComputedStyle.borderTopWidth, 10) > 0) {
  30051. height -= 1;
  30052. }
  30053. if (parseInt(cellComputedStyle.borderLeftWidth, 10) > 0) {
  30054. width -= 1;
  30055. }
  30056. selectStyle.height = height + 'px';
  30057. selectStyle.minWidth = width + 'px';
  30058. selectStyle.top = editTop + 'px';
  30059. selectStyle.left = editLeft + 'px';
  30060. selectStyle.margin = '0px';
  30061. };
  30062. SelectEditor.prototype.getEditedCell = function () {
  30063. var editorSection = this.checkEditorSection(),
  30064. editedCell;
  30065. switch (editorSection) {
  30066. case 'top':
  30067. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  30068. row: this.row,
  30069. col: this.col
  30070. });
  30071. this.select.style.zIndex = 101;
  30072. break;
  30073. case 'corner':
  30074. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  30075. row: this.row,
  30076. col: this.col
  30077. });
  30078. this.select.style.zIndex = 103;
  30079. break;
  30080. case 'left':
  30081. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  30082. row: this.row,
  30083. col: this.col
  30084. });
  30085. this.select.style.zIndex = 102;
  30086. break;
  30087. default:
  30088. editedCell = this.instance.getCell(this.row, this.col);
  30089. this.select.style.zIndex = '';
  30090. break;
  30091. }
  30092. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  30093. };
  30094. exports.default = SelectEditor;
  30095. /***/ }),
  30096. /* 323 */
  30097. /***/ (function(module, exports, __webpack_require__) {
  30098. "use strict";
  30099. __webpack_require__(97);
  30100. __webpack_require__(114);
  30101. __webpack_require__(123);
  30102. __webpack_require__(124);
  30103. __webpack_require__(108);
  30104. __webpack_require__(122);
  30105. __webpack_require__(105);
  30106. __webpack_require__(106);
  30107. __webpack_require__(107);
  30108. __webpack_require__(96);
  30109. __webpack_require__(119);
  30110. __webpack_require__(117);
  30111. __webpack_require__(115);
  30112. __webpack_require__(120);
  30113. __webpack_require__(121);
  30114. __webpack_require__(116);
  30115. __webpack_require__(118);
  30116. __webpack_require__(109);
  30117. __webpack_require__(110);
  30118. __webpack_require__(111);
  30119. __webpack_require__(113);
  30120. __webpack_require__(112);
  30121. __webpack_require__(94);
  30122. __webpack_require__(95);
  30123. __webpack_require__(90);
  30124. __webpack_require__(93);
  30125. __webpack_require__(92);
  30126. __webpack_require__(91);
  30127. __webpack_require__(68);
  30128. __webpack_require__(99);
  30129. __webpack_require__(100);
  30130. __webpack_require__(102);
  30131. __webpack_require__(101);
  30132. __webpack_require__(98);
  30133. __webpack_require__(104);
  30134. __webpack_require__(103);
  30135. __webpack_require__(125);
  30136. __webpack_require__(128);
  30137. __webpack_require__(126);
  30138. __webpack_require__(127);
  30139. __webpack_require__(130);
  30140. __webpack_require__(129);
  30141. __webpack_require__(132);
  30142. __webpack_require__(131);
  30143. __webpack_require__(294);
  30144. __webpack_require__(295);
  30145. __webpack_require__(296);
  30146. var _editors = __webpack_require__(14);
  30147. var _renderers = __webpack_require__(9);
  30148. var _validators = __webpack_require__(26);
  30149. var _cellTypes = __webpack_require__(63);
  30150. var _core = __webpack_require__(64);
  30151. var _core2 = _interopRequireDefault(_core);
  30152. var _jquery = __webpack_require__(292);
  30153. var _jquery2 = _interopRequireDefault(_jquery);
  30154. var _eventManager = __webpack_require__(4);
  30155. var _eventManager2 = _interopRequireDefault(_eventManager);
  30156. var _pluginHooks = __webpack_require__(8);
  30157. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  30158. var _ghostTable = __webpack_require__(67);
  30159. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  30160. var _array = __webpack_require__(2);
  30161. var arrayHelpers = _interopRequireWildcard(_array);
  30162. var _browser = __webpack_require__(25);
  30163. var browserHelpers = _interopRequireWildcard(_browser);
  30164. var _data = __webpack_require__(65);
  30165. var dataHelpers = _interopRequireWildcard(_data);
  30166. var _date = __webpack_require__(89);
  30167. var dateHelpers = _interopRequireWildcard(_date);
  30168. var _feature = __webpack_require__(34);
  30169. var featureHelpers = _interopRequireWildcard(_feature);
  30170. var _function = __webpack_require__(35);
  30171. var functionHelpers = _interopRequireWildcard(_function);
  30172. var _mixed = __webpack_require__(20);
  30173. var mixedHelpers = _interopRequireWildcard(_mixed);
  30174. var _number = __webpack_require__(6);
  30175. var numberHelpers = _interopRequireWildcard(_number);
  30176. var _object = __webpack_require__(1);
  30177. var objectHelpers = _interopRequireWildcard(_object);
  30178. var _setting = __webpack_require__(66);
  30179. var settingHelpers = _interopRequireWildcard(_setting);
  30180. var _string = __webpack_require__(27);
  30181. var stringHelpers = _interopRequireWildcard(_string);
  30182. var _unicode = __webpack_require__(16);
  30183. var unicodeHelpers = _interopRequireWildcard(_unicode);
  30184. var _element = __webpack_require__(0);
  30185. var domHelpers = _interopRequireWildcard(_element);
  30186. var _event = __webpack_require__(7);
  30187. var domEventHelpers = _interopRequireWildcard(_event);
  30188. var _index = __webpack_require__(293);
  30189. var plugins = _interopRequireWildcard(_index);
  30190. var _plugins = __webpack_require__(5);
  30191. var _defaultSettings = __webpack_require__(88);
  30192. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  30193. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  30194. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30195. function Handsontable(rootElement, userSettings) {
  30196. var instance = new _core2.default(rootElement, userSettings || {});
  30197. instance.init();
  30198. return instance;
  30199. }
  30200. (0, _jquery2.default)(Handsontable);
  30201. Handsontable.Core = _core2.default;
  30202. Handsontable.DefaultSettings = _defaultSettings2.default;
  30203. Handsontable.EventManager = _eventManager2.default;
  30204. Handsontable._getListenersCounter = _eventManager.getListenersCounter; // For MemoryLeak tests
  30205. Handsontable.buildDate = "2017-07-10T08:08:33.664Z";
  30206. Handsontable.packageName = "handsontable";
  30207. Handsontable.version = "0.33.0";
  30208. var baseVersion = undefined;
  30209. if (baseVersion) {
  30210. Handsontable.baseVersion = baseVersion;
  30211. }
  30212. // Export Hooks singleton
  30213. Handsontable.hooks = _pluginHooks2.default.getSingleton();
  30214. // TODO: Remove this exports after rewrite tests about this module
  30215. Handsontable.__GhostTable = _ghostTable2.default;
  30216. //
  30217. // Export all helpers to the Handsontable object
  30218. var HELPERS = [arrayHelpers, browserHelpers, dataHelpers, dateHelpers, featureHelpers, functionHelpers, mixedHelpers, numberHelpers, objectHelpers, settingHelpers, stringHelpers, unicodeHelpers];
  30219. var DOM = [domHelpers, domEventHelpers];
  30220. Handsontable.helper = {};
  30221. Handsontable.dom = {};
  30222. // Fill general helpers.
  30223. arrayHelpers.arrayEach(HELPERS, function (helper) {
  30224. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  30225. if (key.charAt(0) !== '_') {
  30226. Handsontable.helper[key] = helper[key];
  30227. }
  30228. });
  30229. });
  30230. // Fill DOM helpers.
  30231. arrayHelpers.arrayEach(DOM, function (helper) {
  30232. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  30233. if (key.charAt(0) !== '_') {
  30234. Handsontable.dom[key] = helper[key];
  30235. }
  30236. });
  30237. });
  30238. // Export cell types.
  30239. Handsontable.cellTypes = {};
  30240. arrayHelpers.arrayEach((0, _cellTypes.getRegisteredCellTypeNames)(), function (cellTypeName) {
  30241. Handsontable.cellTypes[cellTypeName] = (0, _cellTypes.getCellType)(cellTypeName);
  30242. });
  30243. Handsontable.cellTypes.registerCellType = _cellTypes.registerCellType;
  30244. Handsontable.cellTypes.getCellType = _cellTypes.getCellType;
  30245. // Export all registered editors from the Handsontable.
  30246. Handsontable.editors = {};
  30247. arrayHelpers.arrayEach((0, _editors.getRegisteredEditorNames)(), function (editorName) {
  30248. Handsontable.editors[stringHelpers.toUpperCaseFirst(editorName) + 'Editor'] = (0, _editors.getEditor)(editorName);
  30249. });
  30250. Handsontable.editors.registerEditor = _editors.registerEditor;
  30251. Handsontable.editors.getEditor = _editors.getEditor;
  30252. // Export all registered renderers from the Handsontable.
  30253. Handsontable.renderers = {};
  30254. arrayHelpers.arrayEach((0, _renderers.getRegisteredRendererNames)(), function (rendererName) {
  30255. var renderer = (0, _renderers.getRenderer)(rendererName);
  30256. if (rendererName === 'base') {
  30257. Handsontable.renderers.cellDecorator = renderer;
  30258. }
  30259. Handsontable.renderers[stringHelpers.toUpperCaseFirst(rendererName) + 'Renderer'] = renderer;
  30260. });
  30261. Handsontable.renderers.registerRenderer = _renderers.registerRenderer;
  30262. Handsontable.renderers.getRenderer = _renderers.getRenderer;
  30263. // Export all registered validators from the Handsontable.
  30264. Handsontable.validators = {};
  30265. arrayHelpers.arrayEach((0, _validators.getRegisteredValidatorNames)(), function (validatorName) {
  30266. Handsontable.validators[stringHelpers.toUpperCaseFirst(validatorName) + 'Validator'] = (0, _validators.getValidator)(validatorName);
  30267. });
  30268. Handsontable.validators.registerValidator = _validators.registerValidator;
  30269. Handsontable.validators.getValidator = _validators.getValidator;
  30270. // Export all registered plugins from the Handsontable.
  30271. Handsontable.plugins = {};
  30272. arrayHelpers.arrayEach(Object.getOwnPropertyNames(plugins), function (pluginName) {
  30273. var plugin = plugins[pluginName];
  30274. if (pluginName === 'Base') {
  30275. Handsontable.plugins[pluginName + 'Plugin'] = plugin;
  30276. } else {
  30277. Handsontable.plugins[pluginName] = plugin;
  30278. }
  30279. });
  30280. Handsontable.plugins.registerPlugin = _plugins.registerPlugin;
  30281. // Export Handsontable
  30282. module.exports = Handsontable;
  30283. /***/ }),
  30284. /* 324 */
  30285. /***/ (function(module, exports, __webpack_require__) {
  30286. "use strict";
  30287. exports.__esModule = true;
  30288. var _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; };
  30289. function MultiMap() {
  30290. var map = {
  30291. arrayMap: [],
  30292. weakMap: new WeakMap()
  30293. };
  30294. return {
  30295. get: function get(key) {
  30296. if (canBeAnArrayMapKey(key)) {
  30297. return map.arrayMap[key];
  30298. } else if (canBeAWeakMapKey(key)) {
  30299. return map.weakMap.get(key);
  30300. }
  30301. },
  30302. set: function set(key, value) {
  30303. if (canBeAnArrayMapKey(key)) {
  30304. map.arrayMap[key] = value;
  30305. } else if (canBeAWeakMapKey(key)) {
  30306. map.weakMap.set(key, value);
  30307. } else {
  30308. throw new Error('Invalid key type');
  30309. }
  30310. },
  30311. delete: function _delete(key) {
  30312. if (canBeAnArrayMapKey(key)) {
  30313. delete map.arrayMap[key];
  30314. } else if (canBeAWeakMapKey(key)) {
  30315. map.weakMap.delete(key);
  30316. }
  30317. }
  30318. };
  30319. function canBeAnArrayMapKey(obj) {
  30320. return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number');
  30321. }
  30322. function canBeAWeakMapKey(obj) {
  30323. return obj !== null && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == 'object' || typeof obj == 'function');
  30324. }
  30325. function isNaNSymbol(obj) {
  30326. /* eslint-disable no-self-compare */
  30327. return obj !== obj; // NaN === NaN is always false
  30328. }
  30329. }
  30330. exports.default = MultiMap;
  30331. /***/ }),
  30332. /* 325 */
  30333. /***/ (function(module, exports, __webpack_require__) {
  30334. "use strict";
  30335. exports.__esModule = true;
  30336. var _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"); } }; }();
  30337. var _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); } };
  30338. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  30339. var _base = __webpack_require__(12);
  30340. var _base2 = _interopRequireDefault(_base);
  30341. var _array = __webpack_require__(2);
  30342. var _feature = __webpack_require__(34);
  30343. var _element = __webpack_require__(0);
  30344. var _ghostTable = __webpack_require__(67);
  30345. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  30346. var _object = __webpack_require__(1);
  30347. var _number = __webpack_require__(6);
  30348. var _plugins = __webpack_require__(5);
  30349. var _samplesGenerator = __webpack_require__(269);
  30350. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  30351. var _string = __webpack_require__(27);
  30352. var _src = __webpack_require__(11);
  30353. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30354. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30355. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  30356. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  30357. var privatePool = new WeakMap();
  30358. /**
  30359. * @plugin AutoColumnSize
  30360. *
  30361. * @description
  30362. * This plugin allows to set column widths based on their widest cells.
  30363. *
  30364. * By default, the plugin is declared as `undefined`, which makes it enabled (same as if it was declared as `true`).
  30365. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the widths of all cells to
  30366. * resize the columns accordingly.
  30367. * If you experience problems with the performance, try turning this feature off and declaring the column widths manually.
  30368. *
  30369. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  30370. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  30371. * block the browser UI.
  30372. *
  30373. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  30374. * ```js
  30375. * ...
  30376. * // as a number (300 columns in sync, rest async)
  30377. * autoColumnSize: {syncLimit: 300},
  30378. * ...
  30379. *
  30380. * ...
  30381. * // as a string (percent)
  30382. * autoColumnSize: {syncLimit: '40%'},
  30383. * ...
  30384. * ```
  30385. *
  30386. * To configure this plugin see {@link Options#autoColumnSize}.
  30387. *
  30388. * @example
  30389. * ```js
  30390. * ...
  30391. * var hot = new Handsontable(document.getElementById('example'), {
  30392. * date: getData(),
  30393. * autoColumnSize: true
  30394. * });
  30395. * // Access to plugin instance:
  30396. * var plugin = hot.getPlugin('autoColumnSize');
  30397. *
  30398. * plugin.getColumnWidth(4);
  30399. *
  30400. * if (plugin.isEnabled()) {
  30401. * // code...
  30402. * }
  30403. * ...
  30404. * ```
  30405. */
  30406. var AutoColumnSize = function (_BasePlugin) {
  30407. _inherits(AutoColumnSize, _BasePlugin);
  30408. _createClass(AutoColumnSize, null, [{
  30409. key: 'CALCULATION_STEP',
  30410. get: function get() {
  30411. return 50;
  30412. }
  30413. }, {
  30414. key: 'SYNC_CALCULATION_LIMIT',
  30415. get: function get() {
  30416. return 50;
  30417. }
  30418. }]);
  30419. function AutoColumnSize(hotInstance) {
  30420. _classCallCheck(this, AutoColumnSize);
  30421. var _this = _possibleConstructorReturn(this, (AutoColumnSize.__proto__ || Object.getPrototypeOf(AutoColumnSize)).call(this, hotInstance));
  30422. privatePool.set(_this, {
  30423. /**
  30424. * Cached column header names. It is used to diff current column headers with previous state and detect which
  30425. * columns width should be updated.
  30426. *
  30427. * @private
  30428. * @type {Array}
  30429. */
  30430. cachedColumnHeaders: []
  30431. });
  30432. /**
  30433. * Cached columns widths.
  30434. *
  30435. * @type {Array}
  30436. */
  30437. _this.widths = [];
  30438. /**
  30439. * Instance of {@link GhostTable} for rows and columns size calculations.
  30440. *
  30441. * @type {GhostTable}
  30442. */
  30443. _this.ghostTable = new _ghostTable2.default(_this.hot);
  30444. /**
  30445. * Instance of {@link SamplesGenerator} for generating samples necessary for columns width calculations.
  30446. *
  30447. * @type {SamplesGenerator}
  30448. */
  30449. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  30450. return _this.hot.getDataAtCell(row, col);
  30451. });
  30452. /**
  30453. * `true` only if the first calculation was performed
  30454. *
  30455. * @type {Boolean}
  30456. */
  30457. _this.firstCalculation = true;
  30458. /**
  30459. * `true` if the size calculation is in progress.
  30460. *
  30461. * @type {Boolean}
  30462. */
  30463. _this.inProgress = false;
  30464. // moved to constructor to allow auto-sizing the columns when the plugin is disabled
  30465. _this.addHook('beforeColumnResize', function (col, size, isDblClick) {
  30466. return _this.onBeforeColumnResize(col, size, isDblClick);
  30467. });
  30468. return _this;
  30469. }
  30470. /**
  30471. * Check if the plugin is enabled in the handsontable settings.
  30472. *
  30473. * @returns {Boolean}
  30474. */
  30475. _createClass(AutoColumnSize, [{
  30476. key: 'isEnabled',
  30477. value: function isEnabled() {
  30478. return this.hot.getSettings().autoColumnSize !== false && !this.hot.getSettings().colWidths;
  30479. }
  30480. /**
  30481. * Enable plugin for this Handsontable instance.
  30482. */
  30483. }, {
  30484. key: 'enablePlugin',
  30485. value: function enablePlugin() {
  30486. var _this2 = this;
  30487. if (this.enabled) {
  30488. return;
  30489. }
  30490. var setting = this.hot.getSettings().autoColumnSize;
  30491. if (setting && setting.useHeaders != null) {
  30492. this.ghostTable.setSetting('useHeaders', setting.useHeaders);
  30493. }
  30494. this.addHook('afterLoadData', function () {
  30495. return _this2.onAfterLoadData();
  30496. });
  30497. this.addHook('beforeChange', function (changes) {
  30498. return _this2.onBeforeChange(changes);
  30499. });
  30500. this.addHook('beforeRender', function (force) {
  30501. return _this2.onBeforeRender(force);
  30502. });
  30503. this.addHook('modifyColWidth', function (width, col) {
  30504. return _this2.getColumnWidth(col, width);
  30505. });
  30506. this.addHook('afterInit', function () {
  30507. return _this2.onAfterInit();
  30508. });
  30509. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'enablePlugin', this).call(this);
  30510. }
  30511. /**
  30512. * Update plugin state.
  30513. */
  30514. }, {
  30515. key: 'updatePlugin',
  30516. value: function updatePlugin() {
  30517. var changedColumns = this.findColumnsWhereHeaderWasChanged();
  30518. if (changedColumns.length) {
  30519. this.clearCache(changedColumns);
  30520. }
  30521. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'updatePlugin', this).call(this);
  30522. }
  30523. /**
  30524. * Disable plugin for this Handsontable instance.
  30525. */
  30526. }, {
  30527. key: 'disablePlugin',
  30528. value: function disablePlugin() {
  30529. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'disablePlugin', this).call(this);
  30530. }
  30531. /**
  30532. * Calculate a columns width.
  30533. *
  30534. * @param {Number|Object} colRange Column range object.
  30535. * @param {Number|Object} rowRange Row range object.
  30536. * @param {Boolean} [force=false] If `true` force calculate width even when value was cached earlier.
  30537. */
  30538. }, {
  30539. key: 'calculateColumnsWidth',
  30540. value: function calculateColumnsWidth() {
  30541. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  30542. var _this3 = this;
  30543. var rowRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countRows() - 1 };
  30544. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30545. if (typeof colRange === 'number') {
  30546. colRange = { from: colRange, to: colRange };
  30547. }
  30548. if (typeof rowRange === 'number') {
  30549. rowRange = { from: rowRange, to: rowRange };
  30550. }
  30551. (0, _number.rangeEach)(colRange.from, colRange.to, function (col) {
  30552. if (force || _this3.widths[col] === void 0 && !_this3.hot._getColWidthFromSettings(col)) {
  30553. var samples = _this3.samplesGenerator.generateColumnSamples(col, rowRange);
  30554. samples.forEach(function (sample, col) {
  30555. return _this3.ghostTable.addColumn(col, sample);
  30556. });
  30557. }
  30558. });
  30559. if (this.ghostTable.columns.length) {
  30560. this.ghostTable.getWidths(function (col, width) {
  30561. _this3.widths[col] = width;
  30562. });
  30563. this.ghostTable.clean();
  30564. }
  30565. }
  30566. /**
  30567. * Calculate all columns width.
  30568. *
  30569. * @param {Object|Number} rowRange Row range object.
  30570. */
  30571. }, {
  30572. key: 'calculateAllColumnsWidth',
  30573. value: function calculateAllColumnsWidth() {
  30574. var _this4 = this;
  30575. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  30576. var current = 0;
  30577. var length = this.hot.countCols() - 1;
  30578. var timer = null;
  30579. this.inProgress = true;
  30580. var loop = function loop() {
  30581. // When hot was destroyed after calculating finished cancel frame
  30582. if (!_this4.hot) {
  30583. (0, _feature.cancelAnimationFrame)(timer);
  30584. _this4.inProgress = false;
  30585. return;
  30586. }
  30587. _this4.calculateColumnsWidth({
  30588. from: current,
  30589. to: Math.min(current + AutoColumnSize.CALCULATION_STEP, length)
  30590. }, rowRange);
  30591. current = current + AutoColumnSize.CALCULATION_STEP + 1;
  30592. if (current < length) {
  30593. timer = (0, _feature.requestAnimationFrame)(loop);
  30594. } else {
  30595. (0, _feature.cancelAnimationFrame)(timer);
  30596. _this4.inProgress = false;
  30597. // @TODO Should call once per render cycle, currently fired separately in different plugins
  30598. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  30599. // tmp
  30600. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  30601. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  30602. }
  30603. }
  30604. };
  30605. // sync
  30606. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  30607. this.calculateColumnsWidth({ from: 0, to: this.getSyncCalculationLimit() }, rowRange);
  30608. this.firstCalculation = false;
  30609. current = this.getSyncCalculationLimit() + 1;
  30610. }
  30611. // async
  30612. if (current < length) {
  30613. loop();
  30614. } else {
  30615. this.inProgress = false;
  30616. }
  30617. }
  30618. /**
  30619. * Set the sampling options.
  30620. *
  30621. * @private
  30622. */
  30623. }, {
  30624. key: 'setSamplingOptions',
  30625. value: function setSamplingOptions() {
  30626. var setting = this.hot.getSettings().autoColumnSize;
  30627. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoColumnSize.samplingRatio : void 0;
  30628. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoColumnSize.allowSampleDuplicates : void 0;
  30629. if (samplingRatio && !isNaN(samplingRatio)) {
  30630. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  30631. }
  30632. if (allowSampleDuplicates) {
  30633. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  30634. }
  30635. }
  30636. /**
  30637. * Recalculate all columns width (overwrite cache values).
  30638. */
  30639. }, {
  30640. key: 'recalculateAllColumnsWidth',
  30641. value: function recalculateAllColumnsWidth() {
  30642. if (this.hot.view && (0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  30643. this.clearCache();
  30644. this.calculateAllColumnsWidth();
  30645. }
  30646. }
  30647. /**
  30648. * Get value which tells how many columns should be calculated synchronously. Rest of the columns will be calculated asynchronously.
  30649. *
  30650. * @returns {Number}
  30651. */
  30652. }, {
  30653. key: 'getSyncCalculationLimit',
  30654. value: function getSyncCalculationLimit() {
  30655. /* eslint-disable no-bitwise */
  30656. var limit = AutoColumnSize.SYNC_CALCULATION_LIMIT;
  30657. var colsLimit = this.hot.countCols() - 1;
  30658. if ((0, _object.isObject)(this.hot.getSettings().autoColumnSize)) {
  30659. limit = this.hot.getSettings().autoColumnSize.syncLimit;
  30660. if ((0, _string.isPercentValue)(limit)) {
  30661. limit = (0, _number.valueAccordingPercent)(colsLimit, limit);
  30662. } else {
  30663. // Force to Number
  30664. limit >>= 0;
  30665. }
  30666. }
  30667. return Math.min(limit, colsLimit);
  30668. }
  30669. /**
  30670. * Get the calculated column width.
  30671. *
  30672. * @param {Number} col Column index.
  30673. * @param {Number} [defaultWidth] Default column width. It will be picked up if no calculated width found.
  30674. * @param {Boolean} [keepMinimum=true] If `true` then returned value won't be smaller then 50 (default column width).
  30675. * @returns {Number}
  30676. */
  30677. }, {
  30678. key: 'getColumnWidth',
  30679. value: function getColumnWidth(col) {
  30680. var defaultWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  30681. var keepMinimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  30682. var width = defaultWidth;
  30683. if (width === void 0) {
  30684. width = this.widths[col];
  30685. if (keepMinimum && typeof width === 'number') {
  30686. width = Math.max(width, _src.ViewportColumnsCalculator.DEFAULT_WIDTH);
  30687. }
  30688. }
  30689. return width;
  30690. }
  30691. /**
  30692. * Get the first visible column.
  30693. *
  30694. * @returns {Number} Returns column index or -1 if table is not rendered.
  30695. */
  30696. }, {
  30697. key: 'getFirstVisibleColumn',
  30698. value: function getFirstVisibleColumn() {
  30699. var wot = this.hot.view.wt;
  30700. if (wot.wtViewport.columnsVisibleCalculator) {
  30701. return wot.wtTable.getFirstVisibleColumn();
  30702. }
  30703. if (wot.wtViewport.columnsRenderCalculator) {
  30704. return wot.wtTable.getFirstRenderedColumn();
  30705. }
  30706. return -1;
  30707. }
  30708. /**
  30709. * Get the last visible column.
  30710. *
  30711. * @returns {Number} Returns column index or -1 if table is not rendered.
  30712. */
  30713. }, {
  30714. key: 'getLastVisibleColumn',
  30715. value: function getLastVisibleColumn() {
  30716. var wot = this.hot.view.wt;
  30717. if (wot.wtViewport.columnsVisibleCalculator) {
  30718. return wot.wtTable.getLastVisibleColumn();
  30719. }
  30720. if (wot.wtViewport.columnsRenderCalculator) {
  30721. return wot.wtTable.getLastRenderedColumn();
  30722. }
  30723. return -1;
  30724. }
  30725. /**
  30726. * Collects all columns which titles has been changed in comparison to the previous state.
  30727. *
  30728. * @returns {Array} It returns an array of physical column indexes.
  30729. */
  30730. }, {
  30731. key: 'findColumnsWhereHeaderWasChanged',
  30732. value: function findColumnsWhereHeaderWasChanged() {
  30733. var columnHeaders = this.hot.getColHeader();
  30734. var _privatePool$get = privatePool.get(this),
  30735. cachedColumnHeaders = _privatePool$get.cachedColumnHeaders;
  30736. var changedColumns = (0, _array.arrayReduce)(columnHeaders, function (acc, columnTitle, physicalColumn) {
  30737. var cachedColumnsLength = cachedColumnHeaders.length;
  30738. if (cachedColumnsLength - 1 < physicalColumn || cachedColumnHeaders[physicalColumn] !== columnTitle) {
  30739. acc.push(physicalColumn);
  30740. }
  30741. if (cachedColumnsLength - 1 < physicalColumn) {
  30742. cachedColumnHeaders.push(columnTitle);
  30743. } else {
  30744. cachedColumnHeaders[physicalColumn] = columnTitle;
  30745. }
  30746. return acc;
  30747. }, []);
  30748. return changedColumns;
  30749. }
  30750. /**
  30751. * Clear cache of calculated column widths. If you want to clear only selected columns pass an array with their indexes.
  30752. * Otherwise whole cache will be cleared.
  30753. *
  30754. * @param {Array} [columns=[]] List of column indexes (physical indexes) to clear.
  30755. */
  30756. }, {
  30757. key: 'clearCache',
  30758. value: function clearCache() {
  30759. var _this5 = this;
  30760. var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  30761. if (columns.length) {
  30762. (0, _array.arrayEach)(columns, function (physicalIndex) {
  30763. _this5.widths[physicalIndex] = void 0;
  30764. });
  30765. } else {
  30766. this.widths.length = 0;
  30767. }
  30768. }
  30769. /**
  30770. * Check if all widths were calculated. If not then return `true` (need recalculate).
  30771. *
  30772. * @returns {Boolean}
  30773. */
  30774. }, {
  30775. key: 'isNeedRecalculate',
  30776. value: function isNeedRecalculate() {
  30777. return !!(0, _array.arrayFilter)(this.widths, function (item) {
  30778. return item === void 0;
  30779. }).length;
  30780. }
  30781. /**
  30782. * On before render listener.
  30783. *
  30784. * @private
  30785. */
  30786. }, {
  30787. key: 'onBeforeRender',
  30788. value: function onBeforeRender() {
  30789. var force = this.hot.renderCall;
  30790. var rowsCount = this.hot.countRows();
  30791. // Keep last column widths unchanged for situation when all rows was deleted or trimmed (pro #6)
  30792. if (!rowsCount) {
  30793. return;
  30794. }
  30795. this.calculateColumnsWidth({ from: this.getFirstVisibleColumn(), to: this.getLastVisibleColumn() }, void 0, force);
  30796. if (this.isNeedRecalculate() && !this.inProgress) {
  30797. this.calculateAllColumnsWidth();
  30798. }
  30799. }
  30800. /**
  30801. * On after load data listener.
  30802. *
  30803. * @private
  30804. */
  30805. }, {
  30806. key: 'onAfterLoadData',
  30807. value: function onAfterLoadData() {
  30808. var _this6 = this;
  30809. if (this.hot.view) {
  30810. this.recalculateAllColumnsWidth();
  30811. } else {
  30812. // first load - initialization
  30813. setTimeout(function () {
  30814. if (_this6.hot) {
  30815. _this6.recalculateAllColumnsWidth();
  30816. }
  30817. }, 0);
  30818. }
  30819. }
  30820. /**
  30821. * On before change listener.
  30822. *
  30823. * @private
  30824. * @param {Array} changes
  30825. */
  30826. }, {
  30827. key: 'onBeforeChange',
  30828. value: function onBeforeChange(changes) {
  30829. var _this7 = this;
  30830. var changedColumns = (0, _array.arrayMap)(changes, function (_ref) {
  30831. var _ref2 = _slicedToArray(_ref, 2),
  30832. row = _ref2[0],
  30833. column = _ref2[1];
  30834. return _this7.hot.propToCol(column);
  30835. });
  30836. this.clearCache(changedColumns);
  30837. }
  30838. /**
  30839. * On before column resize listener.
  30840. *
  30841. * @private
  30842. * @param {Number} col
  30843. * @param {Number} size
  30844. * @param {Boolean} isDblClick
  30845. * @returns {Number}
  30846. */
  30847. }, {
  30848. key: 'onBeforeColumnResize',
  30849. value: function onBeforeColumnResize(col, size, isDblClick) {
  30850. if (isDblClick) {
  30851. this.calculateColumnsWidth(col, void 0, true);
  30852. size = this.getColumnWidth(col, void 0, false);
  30853. }
  30854. return size;
  30855. }
  30856. /**
  30857. * On after Handsontable init fill plugin with all necessary values.
  30858. *
  30859. * @private
  30860. */
  30861. }, {
  30862. key: 'onAfterInit',
  30863. value: function onAfterInit() {
  30864. privatePool.get(this).cachedColumnHeaders = this.hot.getColHeader();
  30865. }
  30866. /**
  30867. * Destroy plugin instance.
  30868. */
  30869. }, {
  30870. key: 'destroy',
  30871. value: function destroy() {
  30872. this.ghostTable.clean();
  30873. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'destroy', this).call(this);
  30874. }
  30875. }]);
  30876. return AutoColumnSize;
  30877. }(_base2.default);
  30878. (0, _plugins.registerPlugin)('autoColumnSize', AutoColumnSize);
  30879. exports.default = AutoColumnSize;
  30880. /***/ }),
  30881. /* 326 */
  30882. /***/ (function(module, exports, __webpack_require__) {
  30883. "use strict";
  30884. exports.__esModule = true;
  30885. var _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); } };
  30886. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  30887. var _base = __webpack_require__(12);
  30888. var _base2 = _interopRequireDefault(_base);
  30889. var _array = __webpack_require__(2);
  30890. var _feature = __webpack_require__(34);
  30891. var _element = __webpack_require__(0);
  30892. var _ghostTable = __webpack_require__(67);
  30893. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  30894. var _object = __webpack_require__(1);
  30895. var _number = __webpack_require__(6);
  30896. var _plugins = __webpack_require__(5);
  30897. var _samplesGenerator = __webpack_require__(269);
  30898. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  30899. var _string = __webpack_require__(27);
  30900. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30901. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30902. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  30903. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  30904. /**
  30905. * @plugin AutoRowSize
  30906. *
  30907. * @description
  30908. * This plugin allows to set row heights based on their highest cells.
  30909. *
  30910. * By default, the plugin is declared as `undefined`, which makes it disabled (same as if it was declared as `false`).
  30911. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the heights of all cells to
  30912. * resize the rows accordingly.
  30913. * If you experience problems with the performance, try turning this feature off and declaring the row heights manually.
  30914. *
  30915. * Row height calculations are divided into sync and async part. Each of this parts has their own advantages and
  30916. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  30917. * block the browser UI.
  30918. *
  30919. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  30920. * ```js
  30921. * ...
  30922. * // as a number (300 columns in sync, rest async)
  30923. * autoRowSize: {syncLimit: 300},
  30924. * ...
  30925. *
  30926. * ...
  30927. * // as a string (percent)
  30928. * autoRowSize: {syncLimit: '40%'},
  30929. * ...
  30930. * ```
  30931. *
  30932. * You can also use the `allowSampleDuplicates` option to allow sampling duplicate values when calculating the row height. Note, that this might have
  30933. * a negative impact on performance.
  30934. *
  30935. * To configure this plugin see {@link Options#autoRowSize}.
  30936. *
  30937. * @example
  30938. *
  30939. * ```js
  30940. * ...
  30941. * var hot = new Handsontable(document.getElementById('example'), {
  30942. * date: getData(),
  30943. * autoRowSize: true
  30944. * });
  30945. * // Access to plugin instance:
  30946. * var plugin = hot.getPlugin('autoRowSize');
  30947. *
  30948. * plugin.getRowHeight(4);
  30949. *
  30950. * if (plugin.isEnabled()) {
  30951. * // code...
  30952. * }
  30953. * ...
  30954. * ```
  30955. */
  30956. var AutoRowSize = function (_BasePlugin) {
  30957. _inherits(AutoRowSize, _BasePlugin);
  30958. _createClass(AutoRowSize, null, [{
  30959. key: 'CALCULATION_STEP',
  30960. get: function get() {
  30961. return 50;
  30962. }
  30963. }, {
  30964. key: 'SYNC_CALCULATION_LIMIT',
  30965. get: function get() {
  30966. return 500;
  30967. }
  30968. }]);
  30969. function AutoRowSize(hotInstance) {
  30970. _classCallCheck(this, AutoRowSize);
  30971. /**
  30972. * Cached rows heights.
  30973. *
  30974. * @type {Array}
  30975. */
  30976. var _this = _possibleConstructorReturn(this, (AutoRowSize.__proto__ || Object.getPrototypeOf(AutoRowSize)).call(this, hotInstance));
  30977. _this.heights = [];
  30978. /**
  30979. * Instance of {@link GhostTable} for rows and columns size calculations.
  30980. *
  30981. * @type {GhostTable}
  30982. */
  30983. _this.ghostTable = new _ghostTable2.default(_this.hot);
  30984. /**
  30985. * Instance of {@link SamplesGenerator} for generating samples necessary for rows height calculations.
  30986. *
  30987. * @type {SamplesGenerator}
  30988. */
  30989. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  30990. if (row >= 0) {
  30991. return _this.hot.getDataAtCell(row, col);
  30992. } else if (row === -1) {
  30993. return _this.hot.getColHeader(col);
  30994. }
  30995. return null;
  30996. });
  30997. /**
  30998. * `true` if only the first calculation was performed.
  30999. *
  31000. * @type {Boolean}
  31001. */
  31002. _this.firstCalculation = true;
  31003. /**
  31004. * `true` if the size calculation is in progress.
  31005. *
  31006. * @type {Boolean}
  31007. */
  31008. _this.inProgress = false;
  31009. // moved to constructor to allow auto-sizing the rows when the plugin is disabled
  31010. _this.addHook('beforeRowResize', function (row, size, isDblClick) {
  31011. return _this.onBeforeRowResize(row, size, isDblClick);
  31012. });
  31013. return _this;
  31014. }
  31015. /**
  31016. * Check if the plugin is enabled in the Handsontable settings.
  31017. *
  31018. * @returns {Boolean}
  31019. */
  31020. _createClass(AutoRowSize, [{
  31021. key: 'isEnabled',
  31022. value: function isEnabled() {
  31023. return this.hot.getSettings().autoRowSize === true || (0, _object.isObject)(this.hot.getSettings().autoRowSize);
  31024. }
  31025. /**
  31026. * Enable plugin for this Handsontable instance.
  31027. */
  31028. }, {
  31029. key: 'enablePlugin',
  31030. value: function enablePlugin() {
  31031. var _this2 = this;
  31032. if (this.enabled) {
  31033. return;
  31034. }
  31035. this.setSamplingOptions();
  31036. this.addHook('afterLoadData', function () {
  31037. return _this2.onAfterLoadData();
  31038. });
  31039. this.addHook('beforeChange', function (changes) {
  31040. return _this2.onBeforeChange(changes);
  31041. });
  31042. this.addHook('beforeColumnMove', function () {
  31043. return _this2.recalculateAllRowsHeight();
  31044. });
  31045. this.addHook('beforeColumnResize', function () {
  31046. return _this2.recalculateAllRowsHeight();
  31047. });
  31048. this.addHook('beforeColumnSort', function () {
  31049. return _this2.clearCache();
  31050. });
  31051. this.addHook('beforeRender', function (force) {
  31052. return _this2.onBeforeRender(force);
  31053. });
  31054. this.addHook('beforeRowMove', function (rowStart, rowEnd) {
  31055. return _this2.onBeforeRowMove(rowStart, rowEnd);
  31056. });
  31057. this.addHook('modifyRowHeight', function (height, row) {
  31058. return _this2.getRowHeight(row, height);
  31059. });
  31060. this.addHook('modifyColumnHeaderHeight', function () {
  31061. return _this2.getColumnHeaderHeight();
  31062. });
  31063. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'enablePlugin', this).call(this);
  31064. }
  31065. /**
  31066. * Disable plugin for this Handsontable instance.
  31067. */
  31068. }, {
  31069. key: 'disablePlugin',
  31070. value: function disablePlugin() {
  31071. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'disablePlugin', this).call(this);
  31072. }
  31073. /**
  31074. * Calculate a given rows height.
  31075. *
  31076. * @param {Number|Object} rowRange Row range object.
  31077. * @param {Number|Object} colRange Column range object.
  31078. * @param {Boolean} [force=false] If `true` force calculate height even when value was cached earlier.
  31079. */
  31080. }, {
  31081. key: 'calculateRowsHeight',
  31082. value: function calculateRowsHeight() {
  31083. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  31084. var _this3 = this;
  31085. var colRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countCols() - 1 };
  31086. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  31087. if (typeof rowRange === 'number') {
  31088. rowRange = { from: rowRange, to: rowRange };
  31089. }
  31090. if (typeof colRange === 'number') {
  31091. colRange = { from: colRange, to: colRange };
  31092. }
  31093. if (this.hot.getColHeader(0) !== null) {
  31094. var samples = this.samplesGenerator.generateRowSamples(-1, colRange);
  31095. this.ghostTable.addColumnHeadersRow(samples.get(-1));
  31096. }
  31097. (0, _number.rangeEach)(rowRange.from, rowRange.to, function (row) {
  31098. // For rows we must calculate row height even when user had set height value manually.
  31099. // We can shrink column but cannot shrink rows!
  31100. if (force || _this3.heights[row] === void 0) {
  31101. var _samples = _this3.samplesGenerator.generateRowSamples(row, colRange);
  31102. _samples.forEach(function (sample, row) {
  31103. _this3.ghostTable.addRow(row, sample);
  31104. });
  31105. }
  31106. });
  31107. if (this.ghostTable.rows.length) {
  31108. this.ghostTable.getHeights(function (row, height) {
  31109. _this3.heights[row] = height;
  31110. });
  31111. this.ghostTable.clean();
  31112. }
  31113. }
  31114. /**
  31115. * Calculate the height of all the rows.
  31116. *
  31117. * @param {Object|Number} colRange Column range object.
  31118. */
  31119. }, {
  31120. key: 'calculateAllRowsHeight',
  31121. value: function calculateAllRowsHeight() {
  31122. var _this4 = this;
  31123. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  31124. var current = 0;
  31125. var length = this.hot.countRows() - 1;
  31126. var timer = null;
  31127. this.inProgress = true;
  31128. var loop = function loop() {
  31129. // When hot was destroyed after calculating finished cancel frame
  31130. if (!_this4.hot) {
  31131. (0, _feature.cancelAnimationFrame)(timer);
  31132. _this4.inProgress = false;
  31133. return;
  31134. }
  31135. _this4.calculateRowsHeight({ from: current, to: Math.min(current + AutoRowSize.CALCULATION_STEP, length) }, colRange);
  31136. current = current + AutoRowSize.CALCULATION_STEP + 1;
  31137. if (current < length) {
  31138. timer = (0, _feature.requestAnimationFrame)(loop);
  31139. } else {
  31140. (0, _feature.cancelAnimationFrame)(timer);
  31141. _this4.inProgress = false;
  31142. // @TODO Should call once per render cycle, currently fired separately in different plugins
  31143. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  31144. // tmp
  31145. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  31146. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  31147. }
  31148. }
  31149. };
  31150. // sync
  31151. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  31152. this.calculateRowsHeight({ from: 0, to: this.getSyncCalculationLimit() }, colRange);
  31153. this.firstCalculation = false;
  31154. current = this.getSyncCalculationLimit() + 1;
  31155. }
  31156. // async
  31157. if (current < length) {
  31158. loop();
  31159. } else {
  31160. this.inProgress = false;
  31161. this.hot.view.wt.wtOverlays.adjustElementsSize(false);
  31162. }
  31163. }
  31164. /**
  31165. * Set the sampling options.
  31166. *
  31167. * @private
  31168. */
  31169. }, {
  31170. key: 'setSamplingOptions',
  31171. value: function setSamplingOptions() {
  31172. var setting = this.hot.getSettings().autoRowSize;
  31173. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoRowSize.samplingRatio : void 0;
  31174. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoRowSize.allowSampleDuplicates : void 0;
  31175. if (samplingRatio && !isNaN(samplingRatio)) {
  31176. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  31177. }
  31178. if (allowSampleDuplicates) {
  31179. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  31180. }
  31181. }
  31182. /**
  31183. * Recalculate all rows height (overwrite cache values).
  31184. */
  31185. }, {
  31186. key: 'recalculateAllRowsHeight',
  31187. value: function recalculateAllRowsHeight() {
  31188. if ((0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  31189. this.clearCache();
  31190. this.calculateAllRowsHeight();
  31191. }
  31192. }
  31193. /**
  31194. * Get value which tells how much rows will be calculated synchronously. Rest rows will be calculated asynchronously.
  31195. *
  31196. * @returns {Number}
  31197. */
  31198. }, {
  31199. key: 'getSyncCalculationLimit',
  31200. value: function getSyncCalculationLimit() {
  31201. /* eslint-disable no-bitwise */
  31202. var limit = AutoRowSize.SYNC_CALCULATION_LIMIT;
  31203. var rowsLimit = this.hot.countRows() - 1;
  31204. if ((0, _object.isObject)(this.hot.getSettings().autoRowSize)) {
  31205. limit = this.hot.getSettings().autoRowSize.syncLimit;
  31206. if ((0, _string.isPercentValue)(limit)) {
  31207. limit = (0, _number.valueAccordingPercent)(rowsLimit, limit);
  31208. } else {
  31209. // Force to Number
  31210. limit >>= 0;
  31211. }
  31212. }
  31213. return Math.min(limit, rowsLimit);
  31214. }
  31215. /**
  31216. * Get the calculated row height.
  31217. *
  31218. * @param {Number} row Visual row index.
  31219. * @param {Number} [defaultHeight] Default row height. It will be pick up if no calculated height found.
  31220. * @returns {Number}
  31221. */
  31222. }, {
  31223. key: 'getRowHeight',
  31224. value: function getRowHeight(row) {
  31225. var defaultHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  31226. var height = defaultHeight;
  31227. if (this.heights[row] !== void 0 && this.heights[row] > (defaultHeight || 0)) {
  31228. height = this.heights[row];
  31229. }
  31230. return height;
  31231. }
  31232. /**
  31233. * Get the calculated column header height.
  31234. *
  31235. * @returns {Number|undefined}
  31236. */
  31237. }, {
  31238. key: 'getColumnHeaderHeight',
  31239. value: function getColumnHeaderHeight() {
  31240. return this.heights[-1];
  31241. }
  31242. /**
  31243. * Get the first visible row.
  31244. *
  31245. * @returns {Number} Returns row index or -1 if table is not rendered.
  31246. */
  31247. }, {
  31248. key: 'getFirstVisibleRow',
  31249. value: function getFirstVisibleRow() {
  31250. var wot = this.hot.view.wt;
  31251. if (wot.wtViewport.rowsVisibleCalculator) {
  31252. return wot.wtTable.getFirstVisibleRow();
  31253. }
  31254. if (wot.wtViewport.rowsRenderCalculator) {
  31255. return wot.wtTable.getFirstRenderedRow();
  31256. }
  31257. return -1;
  31258. }
  31259. /**
  31260. * Get the last visible row.
  31261. *
  31262. * @returns {Number} Returns row index or -1 if table is not rendered.
  31263. */
  31264. }, {
  31265. key: 'getLastVisibleRow',
  31266. value: function getLastVisibleRow() {
  31267. var wot = this.hot.view.wt;
  31268. if (wot.wtViewport.rowsVisibleCalculator) {
  31269. return wot.wtTable.getLastVisibleRow();
  31270. }
  31271. if (wot.wtViewport.rowsRenderCalculator) {
  31272. return wot.wtTable.getLastRenderedRow();
  31273. }
  31274. return -1;
  31275. }
  31276. /**
  31277. * Clear cached heights.
  31278. */
  31279. }, {
  31280. key: 'clearCache',
  31281. value: function clearCache() {
  31282. this.heights.length = 0;
  31283. this.heights[-1] = void 0;
  31284. }
  31285. /**
  31286. * Clear cache by range.
  31287. *
  31288. * @param {Object|Number} range Row range object.
  31289. */
  31290. }, {
  31291. key: 'clearCacheByRange',
  31292. value: function clearCacheByRange(range) {
  31293. var _this5 = this;
  31294. if (typeof range === 'number') {
  31295. range = { from: range, to: range };
  31296. }
  31297. (0, _number.rangeEach)(Math.min(range.from, range.to), Math.max(range.from, range.to), function (row) {
  31298. _this5.heights[row] = void 0;
  31299. });
  31300. }
  31301. /**
  31302. * @returns {Boolean}
  31303. */
  31304. }, {
  31305. key: 'isNeedRecalculate',
  31306. value: function isNeedRecalculate() {
  31307. return !!(0, _array.arrayFilter)(this.heights, function (item) {
  31308. return item === void 0;
  31309. }).length;
  31310. }
  31311. /**
  31312. * On before render listener.
  31313. *
  31314. * @private
  31315. */
  31316. }, {
  31317. key: 'onBeforeRender',
  31318. value: function onBeforeRender() {
  31319. var force = this.hot.renderCall;
  31320. this.calculateRowsHeight({ from: this.getFirstVisibleRow(), to: this.getLastVisibleRow() }, void 0, force);
  31321. var fixedRowsBottom = this.hot.getSettings().fixedRowsBottom;
  31322. // Calculate rows height synchronously for bottom overlay
  31323. if (fixedRowsBottom) {
  31324. var totalRows = this.hot.countRows() - 1;
  31325. this.calculateRowsHeight({ from: totalRows - fixedRowsBottom, to: totalRows });
  31326. }
  31327. if (this.isNeedRecalculate() && !this.inProgress) {
  31328. this.calculateAllRowsHeight();
  31329. }
  31330. }
  31331. /**
  31332. * On before row move listener.
  31333. *
  31334. * @private
  31335. * @param {Number} from Row index where was grabbed.
  31336. * @param {Number} to Destination row index.
  31337. */
  31338. }, {
  31339. key: 'onBeforeRowMove',
  31340. value: function onBeforeRowMove(from, to) {
  31341. this.clearCacheByRange({ from: from, to: to });
  31342. this.calculateAllRowsHeight();
  31343. }
  31344. /**
  31345. * On before row resize listener.
  31346. *
  31347. * @private
  31348. * @param {Number} row
  31349. * @param {Number} size
  31350. * @param {Boolean} isDblClick
  31351. * @returns {Number}
  31352. */
  31353. }, {
  31354. key: 'onBeforeRowResize',
  31355. value: function onBeforeRowResize(row, size, isDblClick) {
  31356. if (isDblClick) {
  31357. this.calculateRowsHeight(row, void 0, true);
  31358. size = this.getRowHeight(row);
  31359. }
  31360. return size;
  31361. }
  31362. /**
  31363. * On after load data listener.
  31364. *
  31365. * @private
  31366. */
  31367. }, {
  31368. key: 'onAfterLoadData',
  31369. value: function onAfterLoadData() {
  31370. var _this6 = this;
  31371. if (this.hot.view) {
  31372. this.recalculateAllRowsHeight();
  31373. } else {
  31374. // first load - initialization
  31375. setTimeout(function () {
  31376. if (_this6.hot) {
  31377. _this6.recalculateAllRowsHeight();
  31378. }
  31379. }, 0);
  31380. }
  31381. }
  31382. /**
  31383. * On before change listener.
  31384. *
  31385. * @private
  31386. * @param {Array} changes
  31387. */
  31388. }, {
  31389. key: 'onBeforeChange',
  31390. value: function onBeforeChange(changes) {
  31391. var range = null;
  31392. if (changes.length === 1) {
  31393. range = changes[0][0];
  31394. } else if (changes.length > 1) {
  31395. range = {
  31396. from: changes[0][0],
  31397. to: changes[changes.length - 1][0]
  31398. };
  31399. }
  31400. if (range !== null) {
  31401. this.clearCacheByRange(range);
  31402. }
  31403. }
  31404. /**
  31405. * Destroy plugin instance.
  31406. */
  31407. }, {
  31408. key: 'destroy',
  31409. value: function destroy() {
  31410. this.ghostTable.clean();
  31411. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'destroy', this).call(this);
  31412. }
  31413. }]);
  31414. return AutoRowSize;
  31415. }(_base2.default);
  31416. (0, _plugins.registerPlugin)('autoRowSize', AutoRowSize);
  31417. exports.default = AutoRowSize;
  31418. /***/ }),
  31419. /* 327 */
  31420. /***/ (function(module, exports, __webpack_require__) {
  31421. "use strict";
  31422. exports.__esModule = true;
  31423. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  31424. var _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); } };
  31425. var _base = __webpack_require__(12);
  31426. var _base2 = _interopRequireDefault(_base);
  31427. var _pluginHooks = __webpack_require__(8);
  31428. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  31429. var _element = __webpack_require__(0);
  31430. var _eventManager = __webpack_require__(4);
  31431. var _eventManager2 = _interopRequireDefault(_eventManager);
  31432. var _plugins = __webpack_require__(5);
  31433. var _src = __webpack_require__(11);
  31434. var _utils = __webpack_require__(328);
  31435. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31436. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31437. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  31438. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  31439. _pluginHooks2.default.getSingleton().register('modifyAutofillRange');
  31440. _pluginHooks2.default.getSingleton().register('beforeAutofill');
  31441. var INSERT_ROW_ALTER_ACTION_NAME = 'insert_row';
  31442. var INTERVAL_FOR_ADDING_ROW = 200;
  31443. /**
  31444. * This plugin provides "drag-down" and "copy-down" functionalities, both operated
  31445. * using the small square in the right bottom of the cell selection.
  31446. *
  31447. * "Drag-down" expands the value of the selected cells to the neighbouring
  31448. * cells when you drag the small square in the corner.
  31449. *
  31450. * "Copy-down" copies the value of the selection to all empty cells
  31451. * below when you double click the small square.
  31452. *
  31453. * @class Autofill
  31454. * @plugin Autofill
  31455. */
  31456. var Autofill = function (_BasePlugin) {
  31457. _inherits(Autofill, _BasePlugin);
  31458. function Autofill(hotInstance) {
  31459. _classCallCheck(this, Autofill);
  31460. /**
  31461. * Event manager
  31462. *
  31463. * @type {EventManager}
  31464. */
  31465. var _this = _possibleConstructorReturn(this, (Autofill.__proto__ || Object.getPrototypeOf(Autofill)).call(this, hotInstance));
  31466. _this.eventManager = new _eventManager2.default(_this);
  31467. /**
  31468. * Specifies if adding new row started.
  31469. *
  31470. * @type {Boolean}
  31471. */
  31472. _this.addingStarted = false;
  31473. /**
  31474. * Specifies if there was mouse down on the cell corner.
  31475. *
  31476. * @type {Boolean}
  31477. */
  31478. _this.mouseDownOnCellCorner = false;
  31479. /**
  31480. * Specifies if mouse was dragged outside Handsontable.
  31481. *
  31482. * @type {Boolean}
  31483. */
  31484. _this.mouseDragOutside = false;
  31485. /**
  31486. * Specifies how many cell levels were dragged using the handle.
  31487. *
  31488. * @type {Boolean}
  31489. */
  31490. _this.handleDraggedCells = 0;
  31491. /**
  31492. * Specifies allowed directions of drag.
  31493. *
  31494. * @type {Array}
  31495. */
  31496. _this.directions = [];
  31497. /**
  31498. * Specifies if can insert new rows if needed.
  31499. *
  31500. * @type {Boolean}
  31501. */
  31502. _this.autoInsertRow = false;
  31503. return _this;
  31504. }
  31505. /**
  31506. * Check if the plugin is enabled in the Handsontable settings.
  31507. *
  31508. * @returns {Boolean}
  31509. */
  31510. _createClass(Autofill, [{
  31511. key: 'isEnabled',
  31512. value: function isEnabled() {
  31513. return this.hot.getSettings().fillHandle;
  31514. }
  31515. /**
  31516. * Enable plugin for this Handsontable instance.
  31517. */
  31518. }, {
  31519. key: 'enablePlugin',
  31520. value: function enablePlugin() {
  31521. var _this2 = this;
  31522. if (this.enabled) {
  31523. return;
  31524. }
  31525. this.mapSettings();
  31526. this.registerEvents();
  31527. this.addHook('afterOnCellCornerMouseDown', function (event) {
  31528. return _this2.onAfterCellCornerMouseDown(event);
  31529. });
  31530. this.addHook('afterOnCellCornerDblClick', function (event) {
  31531. return _this2.onCellCornerDblClick(event);
  31532. });
  31533. this.addHook('beforeOnCellMouseOver', function (event, coords, TD) {
  31534. return _this2.onBeforeCellMouseOver(coords);
  31535. });
  31536. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'enablePlugin', this).call(this);
  31537. }
  31538. /**
  31539. * Update plugin for this Handsontable instance.
  31540. */
  31541. }, {
  31542. key: 'updatePlugin',
  31543. value: function updatePlugin() {
  31544. this.disablePlugin();
  31545. this.enablePlugin();
  31546. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'updatePlugin', this).call(this);
  31547. }
  31548. /**
  31549. * Disable plugin for this Handsontable instance.
  31550. */
  31551. }, {
  31552. key: 'disablePlugin',
  31553. value: function disablePlugin() {
  31554. this.clearMappedSettings();
  31555. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'disablePlugin', this).call(this);
  31556. }
  31557. /**
  31558. * Get selection data
  31559. *
  31560. * @private
  31561. * @returns {Array} Array with the data.
  31562. */
  31563. }, {
  31564. key: 'getSelectionData',
  31565. value: function getSelectionData() {
  31566. var selRange = {
  31567. from: this.hot.getSelectedRange().from,
  31568. to: this.hot.getSelectedRange().to
  31569. };
  31570. return this.hot.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col);
  31571. }
  31572. /**
  31573. * Try to apply fill values to the area in fill border, omitting the selection border.
  31574. *
  31575. * @private
  31576. * @returns {Boolean} reports if fill was applied.
  31577. */
  31578. }, {
  31579. key: 'fillIn',
  31580. value: function fillIn() {
  31581. if (this.hot.view.wt.selections.fill.isEmpty()) {
  31582. return false;
  31583. }
  31584. var cornersOfSelectionAndDragAreas = this.hot.view.wt.selections.fill.getCorners();
  31585. this.resetSelectionOfDraggedArea();
  31586. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  31587. var _getDragDirectionAndR = (0, _utils.getDragDirectionAndRange)(cornersOfSelectedCells, cornersOfSelectionAndDragAreas),
  31588. directionOfDrag = _getDragDirectionAndR.directionOfDrag,
  31589. startOfDragCoords = _getDragDirectionAndR.startOfDragCoords,
  31590. endOfDragCoords = _getDragDirectionAndR.endOfDragCoords;
  31591. this.hot.runHooks('modifyAutofillRange', cornersOfSelectedCells, cornersOfSelectionAndDragAreas);
  31592. if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) {
  31593. var selectionData = this.getSelectionData();
  31594. var deltas = (0, _utils.getDeltas)(startOfDragCoords, endOfDragCoords, selectionData, directionOfDrag);
  31595. var fillData = selectionData;
  31596. this.hot.runHooks('beforeAutofill', startOfDragCoords, endOfDragCoords, selectionData);
  31597. if (['up', 'left'].indexOf(directionOfDrag) > -1) {
  31598. fillData = [];
  31599. var dragLength = null;
  31600. var fillOffset = null;
  31601. if (directionOfDrag === 'up') {
  31602. dragLength = endOfDragCoords.row - startOfDragCoords.row + 1;
  31603. fillOffset = dragLength % selectionData.length;
  31604. for (var i = 0; i < dragLength; i++) {
  31605. fillData.push(selectionData[(i + (selectionData.length - fillOffset)) % selectionData.length]);
  31606. }
  31607. } else {
  31608. dragLength = endOfDragCoords.col - startOfDragCoords.col + 1;
  31609. fillOffset = dragLength % selectionData[0].length;
  31610. for (var _i = 0; _i < selectionData.length; _i++) {
  31611. fillData.push([]);
  31612. for (var j = 0; j < dragLength; j++) {
  31613. fillData[_i].push(selectionData[_i][(j + (selectionData[_i].length - fillOffset)) % selectionData[_i].length]);
  31614. }
  31615. }
  31616. }
  31617. }
  31618. this.hot.populateFromArray(startOfDragCoords.row, startOfDragCoords.col, fillData, endOfDragCoords.row, endOfDragCoords.col, this.pluginName + '.fill', null, directionOfDrag, deltas);
  31619. this.setSelection(cornersOfSelectionAndDragAreas);
  31620. } else {
  31621. // reset to avoid some range bug
  31622. this.hot.selection.refreshBorders();
  31623. }
  31624. return true;
  31625. }
  31626. /**
  31627. * Reduce the selection area if the handle was dragged outside of the table or on headers.
  31628. *
  31629. * @private
  31630. * @param {CellCoords} coords indexes of selection corners.
  31631. * @returns {CellCoords}
  31632. */
  31633. }, {
  31634. key: 'reduceSelectionAreaIfNeeded',
  31635. value: function reduceSelectionAreaIfNeeded(coords) {
  31636. if (coords.row < 0) {
  31637. coords.row = 0;
  31638. }
  31639. if (coords.col < 0) {
  31640. coords.col = 0;
  31641. }
  31642. return coords;
  31643. }
  31644. /**
  31645. * Get the coordinates of the drag & drop borders.
  31646. *
  31647. * @private
  31648. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  31649. * @returns {Array}
  31650. */
  31651. }, {
  31652. key: 'getCoordsOfDragAndDropBorders',
  31653. value: function getCoordsOfDragAndDropBorders(coordsOfSelection) {
  31654. var topLeftCorner = this.hot.getSelectedRange().getTopLeftCorner();
  31655. var bottomRightCorner = this.hot.getSelectedRange().getBottomRightCorner();
  31656. var coords = void 0;
  31657. if (this.directions.includes(_utils.DIRECTIONS.vertical) && (bottomRightCorner.row < coordsOfSelection.row || topLeftCorner.row > coordsOfSelection.row)) {
  31658. coords = new _src.CellCoords(coordsOfSelection.row, bottomRightCorner.col);
  31659. } else if (this.directions.includes(_utils.DIRECTIONS.horizontal)) {
  31660. coords = new _src.CellCoords(bottomRightCorner.row, coordsOfSelection.col);
  31661. } else {
  31662. // wrong direction
  31663. return;
  31664. }
  31665. return this.reduceSelectionAreaIfNeeded(coords);
  31666. }
  31667. /**
  31668. * Show the fill border.
  31669. *
  31670. * @private
  31671. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  31672. */
  31673. }, {
  31674. key: 'showBorder',
  31675. value: function showBorder(coordsOfSelection) {
  31676. var coordsOfDragAndDropBorders = this.getCoordsOfDragAndDropBorders(coordsOfSelection);
  31677. if (coordsOfDragAndDropBorders) {
  31678. this.redrawBorders(coordsOfDragAndDropBorders);
  31679. }
  31680. }
  31681. /**
  31682. * Add new row
  31683. *
  31684. * @private
  31685. */
  31686. }, {
  31687. key: 'addRow',
  31688. value: function addRow() {
  31689. var _this3 = this;
  31690. this.hot._registerTimeout(setTimeout(function () {
  31691. _this3.hot.alter(INSERT_ROW_ALTER_ACTION_NAME, void 0, 1, _this3.pluginName + '.fill');
  31692. _this3.addingStarted = false;
  31693. }, INTERVAL_FOR_ADDING_ROW));
  31694. }
  31695. /**
  31696. * Add new rows if they are needed to continue auto-filling values.
  31697. *
  31698. * @private
  31699. */
  31700. }, {
  31701. key: 'addNewRowIfNeeded',
  31702. value: function addNewRowIfNeeded() {
  31703. if (this.hot.view.wt.selections.fill.cellRange && this.addingStarted === false && this.autoInsertRow) {
  31704. var cornersOfSelectedCells = this.hot.getSelected();
  31705. var cornersOfSelectedDragArea = this.hot.view.wt.selections.fill.getCorners();
  31706. var nrOfTableRows = this.hot.countRows();
  31707. if (cornersOfSelectedCells[2] < nrOfTableRows - 1 && cornersOfSelectedDragArea[2] === nrOfTableRows - 1) {
  31708. this.addingStarted = true;
  31709. this.addRow();
  31710. }
  31711. }
  31712. }
  31713. /**
  31714. * Get corners of selected cells.
  31715. *
  31716. * @private
  31717. * @returns {Array}
  31718. */
  31719. }, {
  31720. key: 'getCornersOfSelectedCells',
  31721. value: function getCornersOfSelectedCells() {
  31722. if (this.hot.selection.isMultiple()) {
  31723. return this.hot.view.wt.selections.area.getCorners();
  31724. }
  31725. return this.hot.view.wt.selections.current.getCorners();
  31726. }
  31727. /**
  31728. * Get index of last adjacent filled in row
  31729. *
  31730. * @private
  31731. * @param {Array} cornersOfSelectedCells indexes of selection corners.
  31732. * @returns {Number} gives number greater than or equal to zero when selection adjacent can be applied.
  31733. * or -1 when selection adjacent can't be applied
  31734. */
  31735. }, {
  31736. key: 'getIndexOfLastAdjacentFilledInRow',
  31737. value: function getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells) {
  31738. var data = this.hot.getData();
  31739. var nrOfTableRows = this.hot.countRows();
  31740. var lastFilledInRowIndex = void 0;
  31741. for (var rowIndex = cornersOfSelectedCells[2] + 1; rowIndex < nrOfTableRows; rowIndex++) {
  31742. for (var columnIndex = cornersOfSelectedCells[1]; columnIndex <= cornersOfSelectedCells[3]; columnIndex++) {
  31743. var dataInCell = data[rowIndex][columnIndex];
  31744. if (dataInCell) {
  31745. return -1;
  31746. }
  31747. }
  31748. var dataInNextLeftCell = data[rowIndex][cornersOfSelectedCells[1] - 1];
  31749. var dataInNextRightCell = data[rowIndex][cornersOfSelectedCells[3] + 1];
  31750. if (!!dataInNextLeftCell || !!dataInNextRightCell) {
  31751. lastFilledInRowIndex = rowIndex;
  31752. }
  31753. }
  31754. return lastFilledInRowIndex;
  31755. }
  31756. /**
  31757. * Add a selection from the start area to the specific row index.
  31758. *
  31759. * @private
  31760. * @param {Array} selectStartArea selection area from which we start to create more comprehensive selection.
  31761. * @param {Number} rowIndex
  31762. */
  31763. }, {
  31764. key: 'addSelectionFromStartAreaToSpecificRowIndex',
  31765. value: function addSelectionFromStartAreaToSpecificRowIndex(selectStartArea, rowIndex) {
  31766. this.hot.view.wt.selections.fill.clear();
  31767. this.hot.view.wt.selections.fill.add(new _src.CellCoords(selectStartArea[0], selectStartArea[1]));
  31768. this.hot.view.wt.selections.fill.add(new _src.CellCoords(rowIndex, selectStartArea[3]));
  31769. }
  31770. /**
  31771. * Set selection based on passed corners.
  31772. *
  31773. * @private
  31774. * @param {Array} cornersOfArea
  31775. */
  31776. }, {
  31777. key: 'setSelection',
  31778. value: function setSelection(cornersOfArea) {
  31779. this.hot.selection.setRangeStart(new _src.CellCoords(cornersOfArea[0], cornersOfArea[1]));
  31780. this.hot.selection.setRangeEnd(new _src.CellCoords(cornersOfArea[2], cornersOfArea[3]));
  31781. }
  31782. /**
  31783. * Try to select cells down to the last row in the left column and then returns if selection was applied.
  31784. *
  31785. * @private
  31786. * @returns {Boolean}
  31787. */
  31788. }, {
  31789. key: 'selectAdjacent',
  31790. value: function selectAdjacent() {
  31791. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  31792. var lastFilledInRowIndex = this.getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells);
  31793. if (lastFilledInRowIndex === -1) {
  31794. return false;
  31795. }
  31796. this.addSelectionFromStartAreaToSpecificRowIndex(cornersOfSelectedCells, lastFilledInRowIndex);
  31797. return true;
  31798. }
  31799. /**
  31800. * Reset selection of dragged area.
  31801. *
  31802. * @private
  31803. */
  31804. }, {
  31805. key: 'resetSelectionOfDraggedArea',
  31806. value: function resetSelectionOfDraggedArea() {
  31807. this.handleDraggedCells = 0;
  31808. this.hot.view.wt.selections.fill.clear();
  31809. }
  31810. /**
  31811. * Redraw borders.
  31812. *
  31813. * @private
  31814. * @param {CellCoords} coords `CellCoords` coord object.
  31815. */
  31816. }, {
  31817. key: 'redrawBorders',
  31818. value: function redrawBorders(coords) {
  31819. this.hot.view.wt.selections.fill.clear();
  31820. this.hot.view.wt.selections.fill.add(this.hot.getSelectedRange().from);
  31821. this.hot.view.wt.selections.fill.add(this.hot.getSelectedRange().to);
  31822. this.hot.view.wt.selections.fill.add(coords);
  31823. this.hot.view.render();
  31824. }
  31825. /**
  31826. * Get if mouse was dragged outside.
  31827. *
  31828. * @private
  31829. * @param {MouseEvent} event `mousemove` event properties.
  31830. * @returns {Boolean}
  31831. */
  31832. }, {
  31833. key: 'getIfMouseWasDraggedOutside',
  31834. value: function getIfMouseWasDraggedOutside(event) {
  31835. var tableBottom = (0, _element.offset)(this.hot.table).top - (window.pageYOffset || document.documentElement.scrollTop) + (0, _element.outerHeight)(this.hot.table);
  31836. var tableRight = (0, _element.offset)(this.hot.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + (0, _element.outerWidth)(this.hot.table);
  31837. return event.clientY > tableBottom && event.clientX <= tableRight;
  31838. }
  31839. /**
  31840. * Bind the events used by the plugin.
  31841. *
  31842. * @private
  31843. */
  31844. }, {
  31845. key: 'registerEvents',
  31846. value: function registerEvents() {
  31847. var _this4 = this;
  31848. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  31849. return _this4.onMouseUp();
  31850. });
  31851. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  31852. return _this4.onMouseMove(event);
  31853. });
  31854. }
  31855. /**
  31856. * On cell corner double click callback.
  31857. *
  31858. * @private
  31859. */
  31860. }, {
  31861. key: 'onCellCornerDblClick',
  31862. value: function onCellCornerDblClick() {
  31863. var selectionApplied = this.selectAdjacent();
  31864. if (selectionApplied) {
  31865. this.fillIn();
  31866. }
  31867. }
  31868. /**
  31869. * On after cell corner mouse down listener.
  31870. *
  31871. * @private
  31872. */
  31873. }, {
  31874. key: 'onAfterCellCornerMouseDown',
  31875. value: function onAfterCellCornerMouseDown() {
  31876. this.handleDraggedCells = 1;
  31877. this.mouseDownOnCellCorner = true;
  31878. }
  31879. /**
  31880. * On before cell mouse over listener.
  31881. *
  31882. * @private
  31883. * @param {CellCoords} coords `CellCoords` coord object.
  31884. */
  31885. }, {
  31886. key: 'onBeforeCellMouseOver',
  31887. value: function onBeforeCellMouseOver(coords) {
  31888. if (this.mouseDownOnCellCorner && !this.hot.view.isMouseDown() && this.handleDraggedCells) {
  31889. this.handleDraggedCells++;
  31890. this.showBorder(coords);
  31891. this.addNewRowIfNeeded();
  31892. }
  31893. }
  31894. /**
  31895. * On mouse up listener.
  31896. *
  31897. * @private
  31898. */
  31899. }, {
  31900. key: 'onMouseUp',
  31901. value: function onMouseUp() {
  31902. if (this.handleDraggedCells) {
  31903. if (this.handleDraggedCells > 1) {
  31904. this.fillIn();
  31905. }
  31906. this.handleDraggedCells = 0;
  31907. this.mouseDownOnCellCorner = false;
  31908. }
  31909. }
  31910. /**
  31911. * On mouse move listener.
  31912. *
  31913. * @private
  31914. * @param {MouseEvent} event `mousemove` event properties.
  31915. */
  31916. }, {
  31917. key: 'onMouseMove',
  31918. value: function onMouseMove(event) {
  31919. var mouseWasDraggedOutside = this.getIfMouseWasDraggedOutside(event);
  31920. if (this.addingStarted === false && this.handleDraggedCells > 0 && mouseWasDraggedOutside) {
  31921. this.mouseDragOutside = true;
  31922. this.addingStarted = true;
  31923. } else {
  31924. this.mouseDragOutside = false;
  31925. }
  31926. if (this.mouseDragOutside && this.autoInsertRow) {
  31927. this.addRow();
  31928. }
  31929. }
  31930. /**
  31931. * Clear mapped settings.
  31932. *
  31933. * @private
  31934. */
  31935. }, {
  31936. key: 'clearMappedSettings',
  31937. value: function clearMappedSettings() {
  31938. this.directions.length = 0;
  31939. this.autoInsertRow = false;
  31940. }
  31941. /**
  31942. * Map settings.
  31943. *
  31944. * @private
  31945. */
  31946. }, {
  31947. key: 'mapSettings',
  31948. value: function mapSettings() {
  31949. var mappedSettings = (0, _utils.getMappedFillHandleSetting)(this.hot.getSettings().fillHandle);
  31950. this.directions = mappedSettings.directions;
  31951. this.autoInsertRow = mappedSettings.autoInsertRow;
  31952. }
  31953. /**
  31954. * Destroy plugin instance.
  31955. */
  31956. }, {
  31957. key: 'destroy',
  31958. value: function destroy() {
  31959. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'destroy', this).call(this);
  31960. }
  31961. }]);
  31962. return Autofill;
  31963. }(_base2.default);
  31964. (0, _plugins.registerPlugin)('autofill', Autofill);
  31965. exports.default = Autofill;
  31966. /***/ }),
  31967. /* 328 */
  31968. /***/ (function(module, exports, __webpack_require__) {
  31969. "use strict";
  31970. exports.__esModule = true;
  31971. exports.DIRECTIONS = undefined;
  31972. exports.getDeltas = getDeltas;
  31973. exports.getDragDirectionAndRange = getDragDirectionAndRange;
  31974. exports.getMappedFillHandleSetting = getMappedFillHandleSetting;
  31975. var _object = __webpack_require__(1);
  31976. var _mixed = __webpack_require__(20);
  31977. var _src = __webpack_require__(11);
  31978. var DIRECTIONS = exports.DIRECTIONS = {
  31979. horizontal: 'horizontal',
  31980. vertical: 'vertical'
  31981. };
  31982. /**
  31983. * Get deltas array.
  31984. *
  31985. * @param {CellCoords} start
  31986. * @param {CellCoords} end
  31987. * @param {Array} data
  31988. * @param {String} direction
  31989. * @returns {Array}
  31990. */
  31991. function getDeltas(start, end, data, direction) {
  31992. var rowsLength = data.length;
  31993. var columnsLength = data ? data[0].length : 0;
  31994. var deltas = [];
  31995. var diffRow = end.row - start.row;
  31996. var diffCol = end.col - start.col;
  31997. if (['down', 'up'].indexOf(direction) !== -1) {
  31998. var arr = [];
  31999. for (var col = 0; col <= diffCol; col++) {
  32000. var startValue = parseInt(data[0][col], 10);
  32001. var endValue = parseInt(data[rowsLength - 1][col], 10);
  32002. var delta = (direction === 'down' ? endValue - startValue : startValue - endValue) / (rowsLength - 1) || 0;
  32003. arr.push(delta);
  32004. }
  32005. deltas.push(arr);
  32006. }
  32007. if (['right', 'left'].indexOf(direction) !== -1) {
  32008. for (var row = 0; row <= diffRow; row++) {
  32009. var _startValue = parseInt(data[row][0], 10);
  32010. var _endValue = parseInt(data[row][columnsLength - 1], 10);
  32011. var _delta = (direction === 'right' ? _endValue - _startValue : _startValue - _endValue) / (columnsLength - 1) || 0;
  32012. deltas.push([_delta]);
  32013. }
  32014. }
  32015. return deltas;
  32016. }
  32017. /**
  32018. * Get direction between positions and cords of selections difference (drag area)
  32019. *
  32020. * @param {Array} startSelection
  32021. * @param {Array} endSelection
  32022. * @returns {{direction: String, start: CellCoords, end: CellCoords}}
  32023. */
  32024. function getDragDirectionAndRange(startSelection, endSelection) {
  32025. var startOfDragCoords = void 0,
  32026. endOfDragCoords = void 0,
  32027. directionOfDrag = void 0;
  32028. if (endSelection[0] === startSelection[0] && endSelection[1] < startSelection[1]) {
  32029. directionOfDrag = 'left';
  32030. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  32031. endOfDragCoords = new _src.CellCoords(endSelection[2], startSelection[1] - 1);
  32032. } else if (endSelection[0] === startSelection[0] && endSelection[3] > startSelection[3]) {
  32033. directionOfDrag = 'right';
  32034. startOfDragCoords = new _src.CellCoords(endSelection[0], startSelection[3] + 1);
  32035. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  32036. } else if (endSelection[0] < startSelection[0] && endSelection[1] === startSelection[1]) {
  32037. directionOfDrag = 'up';
  32038. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  32039. endOfDragCoords = new _src.CellCoords(startSelection[0] - 1, endSelection[3]);
  32040. } else if (endSelection[2] > startSelection[2] && endSelection[1] === startSelection[1]) {
  32041. directionOfDrag = 'down';
  32042. startOfDragCoords = new _src.CellCoords(startSelection[2] + 1, endSelection[1]);
  32043. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  32044. }
  32045. return {
  32046. directionOfDrag: directionOfDrag,
  32047. startOfDragCoords: startOfDragCoords,
  32048. endOfDragCoords: endOfDragCoords
  32049. };
  32050. }
  32051. /**
  32052. * Get mapped FillHandle setting containing information about
  32053. * allowed FillHandle directions and if allowed is automatic insertion of rows on drag
  32054. *
  32055. * @param {Boolean|Object} fillHandle property of Handsontable settings
  32056. * @returns {{directions: Array, autoInsertRow: Boolean}} object allowing access to information
  32057. * about FillHandle in more useful way
  32058. */
  32059. function getMappedFillHandleSetting(fillHandle) {
  32060. var mappedSettings = {};
  32061. if (fillHandle === true) {
  32062. mappedSettings.directions = Object.keys(DIRECTIONS);
  32063. mappedSettings.autoInsertRow = true;
  32064. } else if ((0, _object.isObject)(fillHandle)) {
  32065. if ((0, _mixed.isDefined)(fillHandle.autoInsertRow)) {
  32066. // autoInsertRow for horizontal direction will be always false
  32067. if (fillHandle.direction === DIRECTIONS.horizontal) {
  32068. mappedSettings.autoInsertRow = false;
  32069. } else {
  32070. mappedSettings.autoInsertRow = fillHandle.autoInsertRow;
  32071. }
  32072. } else {
  32073. mappedSettings.autoInsertRow = false;
  32074. }
  32075. if ((0, _mixed.isDefined)(fillHandle.direction)) {
  32076. mappedSettings.directions = [fillHandle.direction];
  32077. } else {
  32078. mappedSettings.directions = Object.keys(DIRECTIONS);
  32079. }
  32080. } else if (typeof fillHandle === 'string') {
  32081. mappedSettings.directions = [fillHandle];
  32082. mappedSettings.autoInsertRow = true;
  32083. } else {
  32084. mappedSettings.directions = [];
  32085. mappedSettings.autoInsertRow = false;
  32086. }
  32087. return mappedSettings;
  32088. }
  32089. /***/ }),
  32090. /* 329 */
  32091. /***/ (function(module, exports, __webpack_require__) {
  32092. "use strict";
  32093. exports.__esModule = true;
  32094. var _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; };
  32095. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  32096. var _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); } };
  32097. var _moment = __webpack_require__(36);
  32098. var _moment2 = _interopRequireDefault(_moment);
  32099. var _element = __webpack_require__(0);
  32100. var _array = __webpack_require__(2);
  32101. var _mixed = __webpack_require__(20);
  32102. var _object = __webpack_require__(1);
  32103. var _base = __webpack_require__(12);
  32104. var _base2 = _interopRequireDefault(_base);
  32105. var _plugins = __webpack_require__(5);
  32106. var _mergeSort = __webpack_require__(387);
  32107. var _mergeSort2 = _interopRequireDefault(_mergeSort);
  32108. var _pluginHooks = __webpack_require__(8);
  32109. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  32110. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32111. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  32112. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32113. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  32114. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  32115. _pluginHooks2.default.getSingleton().register('beforeColumnSort');
  32116. _pluginHooks2.default.getSingleton().register('afterColumnSort');
  32117. // TODO: Implement mixin arrayMapper to ColumnSorting plugin.
  32118. /**
  32119. * @plugin ColumnSorting
  32120. *
  32121. * @description
  32122. * This plugin sorts the view by a column (but does not sort the data source!).
  32123. * To enable the plugin, set the `columnSorting` property to either:
  32124. * * a boolean value (`true`/`false`),
  32125. * * an object defining the initial sorting order (see the example below).
  32126. *
  32127. * @example
  32128. * ```js
  32129. * ...
  32130. * // as boolean
  32131. * columnSorting: true
  32132. * ...
  32133. * // as a object with initial order (sort ascending column at index 2)
  32134. * columnSorting: {
  32135. * column: 2,
  32136. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  32137. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  32138. * }
  32139. * ...
  32140. * ```
  32141. * @dependencies ObserveChanges
  32142. */
  32143. var ColumnSorting = function (_BasePlugin) {
  32144. _inherits(ColumnSorting, _BasePlugin);
  32145. function ColumnSorting(hotInstance) {
  32146. _classCallCheck(this, ColumnSorting);
  32147. var _this2 = _possibleConstructorReturn(this, (ColumnSorting.__proto__ || Object.getPrototypeOf(ColumnSorting)).call(this, hotInstance));
  32148. _this2.sortIndicators = [];
  32149. _this2.lastSortedColumn = null;
  32150. _this2.sortEmptyCells = false;
  32151. return _this2;
  32152. }
  32153. /**
  32154. * Check if the plugin is enabled in the handsontable settings.
  32155. *
  32156. * @returns {Boolean}
  32157. */
  32158. _createClass(ColumnSorting, [{
  32159. key: 'isEnabled',
  32160. value: function isEnabled() {
  32161. return !!this.hot.getSettings().columnSorting;
  32162. }
  32163. /**
  32164. * Enable plugin for this Handsontable instance.
  32165. */
  32166. }, {
  32167. key: 'enablePlugin',
  32168. value: function enablePlugin() {
  32169. var _this3 = this;
  32170. if (this.enabled) {
  32171. return;
  32172. }
  32173. this.setPluginOptions();
  32174. var _this = this;
  32175. this.hot.sortIndex = [];
  32176. this.hot.sort = function () {
  32177. var args = Array.prototype.slice.call(arguments);
  32178. return _this.sortByColumn.apply(_this, _toConsumableArray(args));
  32179. };
  32180. if (typeof this.hot.getSettings().observeChanges === 'undefined') {
  32181. this.enableObserveChangesPlugin();
  32182. }
  32183. this.addHook('afterTrimRow', function (row) {
  32184. return _this3.sort();
  32185. });
  32186. this.addHook('afterUntrimRow', function (row) {
  32187. return _this3.sort();
  32188. });
  32189. this.addHook('modifyRow', function (row) {
  32190. return _this3.translateRow(row);
  32191. });
  32192. this.addHook('unmodifyRow', function (row) {
  32193. return _this3.untranslateRow(row);
  32194. });
  32195. this.addHook('afterUpdateSettings', function () {
  32196. return _this3.onAfterUpdateSettings();
  32197. });
  32198. this.addHook('afterGetColHeader', function (col, TH) {
  32199. return _this3.getColHeader(col, TH);
  32200. });
  32201. this.addHook('afterOnCellMouseDown', function (event, target) {
  32202. return _this3.onAfterOnCellMouseDown(event, target);
  32203. });
  32204. this.addHook('afterCreateRow', function () {
  32205. _this.afterCreateRow.apply(_this, arguments);
  32206. });
  32207. this.addHook('afterRemoveRow', function () {
  32208. _this.afterRemoveRow.apply(_this, arguments);
  32209. });
  32210. this.addHook('afterInit', function () {
  32211. return _this3.sortBySettings();
  32212. });
  32213. this.addHook('afterLoadData', function () {
  32214. _this3.hot.sortIndex = [];
  32215. if (_this3.hot.view) {
  32216. _this3.sortBySettings();
  32217. }
  32218. });
  32219. if (this.hot.view) {
  32220. this.sortBySettings();
  32221. }
  32222. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'enablePlugin', this).call(this);
  32223. }
  32224. /**
  32225. * Disable plugin for this Handsontable instance.
  32226. */
  32227. }, {
  32228. key: 'disablePlugin',
  32229. value: function disablePlugin() {
  32230. this.hot.sort = void 0;
  32231. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'disablePlugin', this).call(this);
  32232. }
  32233. /**
  32234. * afterUpdateSettings callback.
  32235. *
  32236. * @private
  32237. */
  32238. }, {
  32239. key: 'onAfterUpdateSettings',
  32240. value: function onAfterUpdateSettings() {
  32241. this.sortBySettings();
  32242. }
  32243. }, {
  32244. key: 'sortBySettings',
  32245. value: function sortBySettings() {
  32246. var sortingSettings = this.hot.getSettings().columnSorting;
  32247. var loadedSortingState = this.loadSortingState();
  32248. var sortingColumn = void 0;
  32249. var sortingOrder = void 0;
  32250. if (typeof loadedSortingState === 'undefined') {
  32251. sortingColumn = sortingSettings.column;
  32252. sortingOrder = sortingSettings.sortOrder;
  32253. } else {
  32254. sortingColumn = loadedSortingState.sortColumn;
  32255. sortingOrder = loadedSortingState.sortOrder;
  32256. }
  32257. if (typeof sortingColumn === 'number') {
  32258. this.lastSortedColumn = sortingColumn;
  32259. this.sortByColumn(sortingColumn, sortingOrder);
  32260. }
  32261. }
  32262. /**
  32263. * Set sorted column and order info
  32264. *
  32265. * @param {number} col Sorted visual column index.
  32266. * @param {boolean|undefined} order Sorting order (`true` for ascending, `false` for descending).
  32267. */
  32268. }, {
  32269. key: 'setSortingColumn',
  32270. value: function setSortingColumn(col, order) {
  32271. if (typeof col == 'undefined') {
  32272. this.hot.sortColumn = void 0;
  32273. this.hot.sortOrder = void 0;
  32274. return;
  32275. } else if (this.hot.sortColumn === col && typeof order == 'undefined') {
  32276. if (this.hot.sortOrder === false) {
  32277. this.hot.sortOrder = void 0;
  32278. } else {
  32279. this.hot.sortOrder = !this.hot.sortOrder;
  32280. }
  32281. } else {
  32282. this.hot.sortOrder = typeof order === 'undefined' ? true : order;
  32283. }
  32284. this.hot.sortColumn = col;
  32285. }
  32286. }, {
  32287. key: 'sortByColumn',
  32288. value: function sortByColumn(col, order) {
  32289. this.setSortingColumn(col, order);
  32290. if (typeof this.hot.sortColumn == 'undefined') {
  32291. return;
  32292. }
  32293. var allowSorting = this.hot.runHooks('beforeColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  32294. if (allowSorting !== false) {
  32295. this.sort();
  32296. }
  32297. this.updateOrderClass();
  32298. this.updateSortIndicator();
  32299. this.hot.runHooks('afterColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  32300. this.hot.render();
  32301. this.saveSortingState();
  32302. }
  32303. /**
  32304. * Save the sorting state
  32305. */
  32306. }, {
  32307. key: 'saveSortingState',
  32308. value: function saveSortingState() {
  32309. var sortingState = {};
  32310. if (typeof this.hot.sortColumn != 'undefined') {
  32311. sortingState.sortColumn = this.hot.sortColumn;
  32312. }
  32313. if (typeof this.hot.sortOrder != 'undefined') {
  32314. sortingState.sortOrder = this.hot.sortOrder;
  32315. }
  32316. if ((0, _object.hasOwnProperty)(sortingState, 'sortColumn') || (0, _object.hasOwnProperty)(sortingState, 'sortOrder')) {
  32317. this.hot.runHooks('persistentStateSave', 'columnSorting', sortingState);
  32318. }
  32319. }
  32320. /**
  32321. * Load the sorting state.
  32322. *
  32323. * @returns {*} Previously saved sorting state.
  32324. */
  32325. }, {
  32326. key: 'loadSortingState',
  32327. value: function loadSortingState() {
  32328. var storedState = {};
  32329. this.hot.runHooks('persistentStateLoad', 'columnSorting', storedState);
  32330. return storedState.value;
  32331. }
  32332. /**
  32333. * Update sorting class name state.
  32334. */
  32335. }, {
  32336. key: 'updateOrderClass',
  32337. value: function updateOrderClass() {
  32338. var orderClass = void 0;
  32339. if (this.hot.sortOrder === true) {
  32340. orderClass = 'ascending';
  32341. } else if (this.hot.sortOrder === false) {
  32342. orderClass = 'descending';
  32343. }
  32344. this.sortOrderClass = orderClass;
  32345. }
  32346. }, {
  32347. key: 'enableObserveChangesPlugin',
  32348. value: function enableObserveChangesPlugin() {
  32349. var _this = this;
  32350. this.hot._registerTimeout(setTimeout(function () {
  32351. _this.hot.updateSettings({
  32352. observeChanges: true
  32353. });
  32354. }, 0));
  32355. }
  32356. /**
  32357. * Default sorting algorithm.
  32358. *
  32359. * @param {Boolean} sortOrder Sorting order - `true` for ascending, `false` for descending.
  32360. * @param {Object} columnMeta Column meta object.
  32361. * @returns {Function} The comparing function.
  32362. */
  32363. }, {
  32364. key: 'defaultSort',
  32365. value: function defaultSort(sortOrder, columnMeta) {
  32366. return function (a, b) {
  32367. if (typeof a[1] == 'string') {
  32368. a[1] = a[1].toLowerCase();
  32369. }
  32370. if (typeof b[1] == 'string') {
  32371. b[1] = b[1].toLowerCase();
  32372. }
  32373. if (a[1] === b[1]) {
  32374. return 0;
  32375. }
  32376. if ((0, _mixed.isEmpty)(a[1])) {
  32377. if ((0, _mixed.isEmpty)(b[1])) {
  32378. return 0;
  32379. }
  32380. if (columnMeta.columnSorting.sortEmptyCells) {
  32381. return sortOrder ? -1 : 1;
  32382. }
  32383. return 1;
  32384. }
  32385. if ((0, _mixed.isEmpty)(b[1])) {
  32386. if ((0, _mixed.isEmpty)(a[1])) {
  32387. return 0;
  32388. }
  32389. if (columnMeta.columnSorting.sortEmptyCells) {
  32390. return sortOrder ? 1 : -1;
  32391. }
  32392. return -1;
  32393. }
  32394. if (isNaN(a[1]) && !isNaN(b[1])) {
  32395. return sortOrder ? 1 : -1;
  32396. } else if (!isNaN(a[1]) && isNaN(b[1])) {
  32397. return sortOrder ? -1 : 1;
  32398. } else if (!(isNaN(a[1]) || isNaN(b[1]))) {
  32399. a[1] = parseFloat(a[1]);
  32400. b[1] = parseFloat(b[1]);
  32401. }
  32402. if (a[1] < b[1]) {
  32403. return sortOrder ? -1 : 1;
  32404. }
  32405. if (a[1] > b[1]) {
  32406. return sortOrder ? 1 : -1;
  32407. }
  32408. return 0;
  32409. };
  32410. }
  32411. /**
  32412. * Date sorting algorithm
  32413. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  32414. * @param {Object} columnMeta Column meta object.
  32415. * @returns {Function} The compare function.
  32416. */
  32417. }, {
  32418. key: 'dateSort',
  32419. value: function dateSort(sortOrder, columnMeta) {
  32420. return function (a, b) {
  32421. if (a[1] === b[1]) {
  32422. return 0;
  32423. }
  32424. if ((0, _mixed.isEmpty)(a[1])) {
  32425. if ((0, _mixed.isEmpty)(b[1])) {
  32426. return 0;
  32427. }
  32428. if (columnMeta.columnSorting.sortEmptyCells) {
  32429. return sortOrder ? -1 : 1;
  32430. }
  32431. return 1;
  32432. }
  32433. if ((0, _mixed.isEmpty)(b[1])) {
  32434. if ((0, _mixed.isEmpty)(a[1])) {
  32435. return 0;
  32436. }
  32437. if (columnMeta.columnSorting.sortEmptyCells) {
  32438. return sortOrder ? 1 : -1;
  32439. }
  32440. return -1;
  32441. }
  32442. var aDate = (0, _moment2.default)(a[1], columnMeta.dateFormat);
  32443. var bDate = (0, _moment2.default)(b[1], columnMeta.dateFormat);
  32444. if (!aDate.isValid()) {
  32445. return 1;
  32446. }
  32447. if (!bDate.isValid()) {
  32448. return -1;
  32449. }
  32450. if (bDate.isAfter(aDate)) {
  32451. return sortOrder ? -1 : 1;
  32452. }
  32453. if (bDate.isBefore(aDate)) {
  32454. return sortOrder ? 1 : -1;
  32455. }
  32456. return 0;
  32457. };
  32458. }
  32459. /**
  32460. * Numeric sorting algorithm.
  32461. *
  32462. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  32463. * @param {Object} columnMeta Column meta object.
  32464. * @returns {Function} The compare function.
  32465. */
  32466. }, {
  32467. key: 'numericSort',
  32468. value: function numericSort(sortOrder, columnMeta) {
  32469. return function (a, b) {
  32470. var parsedA = parseFloat(a[1]);
  32471. var parsedB = parseFloat(b[1]);
  32472. // Watch out when changing this part of code!
  32473. // Check below returns 0 (as expected) when comparing empty string, null, undefined
  32474. if (parsedA === parsedB || isNaN(parsedA) && isNaN(parsedB)) {
  32475. return 0;
  32476. }
  32477. if (columnMeta.columnSorting.sortEmptyCells) {
  32478. if ((0, _mixed.isEmpty)(a[1])) {
  32479. return sortOrder ? -1 : 1;
  32480. }
  32481. if ((0, _mixed.isEmpty)(b[1])) {
  32482. return sortOrder ? 1 : -1;
  32483. }
  32484. }
  32485. if (isNaN(parsedA)) {
  32486. return 1;
  32487. }
  32488. if (isNaN(parsedB)) {
  32489. return -1;
  32490. }
  32491. if (parsedA < parsedB) {
  32492. return sortOrder ? -1 : 1;
  32493. } else if (parsedA > parsedB) {
  32494. return sortOrder ? 1 : -1;
  32495. }
  32496. return 0;
  32497. };
  32498. }
  32499. /**
  32500. * Perform the sorting.
  32501. */
  32502. }, {
  32503. key: 'sort',
  32504. value: function sort() {
  32505. if (typeof this.hot.sortOrder == 'undefined') {
  32506. this.hot.sortIndex.length = 0;
  32507. return;
  32508. }
  32509. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  32510. var emptyRows = this.hot.countEmptyRows();
  32511. var sortFunction = void 0;
  32512. var nrOfRows = void 0;
  32513. this.hot.sortingEnabled = false; // this is required by translateRow plugin hook
  32514. this.hot.sortIndex.length = 0;
  32515. if (typeof colMeta.columnSorting.sortEmptyCells === 'undefined') {
  32516. colMeta.columnSorting = { sortEmptyCells: this.sortEmptyCells };
  32517. }
  32518. if (this.hot.getSettings().maxRows === Number.POSITIVE_INFINITY) {
  32519. nrOfRows = this.hot.countRows() - this.hot.getSettings().minSpareRows;
  32520. } else {
  32521. nrOfRows = this.hot.countRows() - emptyRows;
  32522. }
  32523. for (var i = 0, ilen = nrOfRows; i < ilen; i++) {
  32524. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn)]);
  32525. }
  32526. if (colMeta.sortFunction) {
  32527. sortFunction = colMeta.sortFunction;
  32528. } else {
  32529. switch (colMeta.type) {
  32530. case 'date':
  32531. sortFunction = this.dateSort;
  32532. break;
  32533. case 'numeric':
  32534. sortFunction = this.numericSort;
  32535. break;
  32536. default:
  32537. sortFunction = this.defaultSort;
  32538. }
  32539. }
  32540. (0, _mergeSort2.default)(this.hot.sortIndex, sortFunction(this.hot.sortOrder, colMeta));
  32541. // Append spareRows
  32542. for (var _i = this.hot.sortIndex.length; _i < this.hot.countRows(); _i++) {
  32543. this.hot.sortIndex.push([_i, this.hot.getDataAtCell(_i, this.hot.sortColumn)]);
  32544. }
  32545. this.hot.sortingEnabled = true; // this is required by translateRow plugin hook
  32546. }
  32547. /**
  32548. * Update indicator states.
  32549. */
  32550. }, {
  32551. key: 'updateSortIndicator',
  32552. value: function updateSortIndicator() {
  32553. if (typeof this.hot.sortOrder == 'undefined') {
  32554. return;
  32555. }
  32556. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  32557. this.sortIndicators[this.hot.sortColumn] = colMeta.sortIndicator;
  32558. }
  32559. /**
  32560. * `modifyRow` hook callback. Translates physical row index to the sorted row index.
  32561. *
  32562. * @param {Number} row Row index.
  32563. * @returns {Number} Sorted row index.
  32564. */
  32565. }, {
  32566. key: 'translateRow',
  32567. value: function translateRow(row) {
  32568. if (this.hot.sortingEnabled && typeof this.hot.sortOrder !== 'undefined' && this.hot.sortIndex && this.hot.sortIndex.length && this.hot.sortIndex[row]) {
  32569. return this.hot.sortIndex[row][0];
  32570. }
  32571. return row;
  32572. }
  32573. /**
  32574. * Translates sorted row index to physical row index.
  32575. *
  32576. * @param {Number} row Sorted (visual) row index.
  32577. * @returns {number} Physical row index.
  32578. */
  32579. }, {
  32580. key: 'untranslateRow',
  32581. value: function untranslateRow(row) {
  32582. if (this.hot.sortingEnabled && this.hot.sortIndex && this.hot.sortIndex.length) {
  32583. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  32584. if (this.hot.sortIndex[i][0] == row) {
  32585. return i;
  32586. }
  32587. }
  32588. }
  32589. }
  32590. /**
  32591. * `afterGetColHeader` callback. Adds column sorting css classes to clickable headers.
  32592. *
  32593. * @private
  32594. * @param {Number} col Visual column index.
  32595. * @param {Element} TH TH HTML element.
  32596. */
  32597. }, {
  32598. key: 'getColHeader',
  32599. value: function getColHeader(col, TH) {
  32600. if (col < 0 || !TH.parentNode) {
  32601. return false;
  32602. }
  32603. var headerLink = TH.querySelector('.colHeader');
  32604. var colspan = TH.getAttribute('colspan');
  32605. var TRs = TH.parentNode.parentNode.childNodes;
  32606. var headerLevel = Array.prototype.indexOf.call(TRs, TH.parentNode);
  32607. headerLevel -= TRs.length;
  32608. if (!headerLink) {
  32609. return;
  32610. }
  32611. if (this.hot.getSettings().columnSorting && col >= 0 && headerLevel === -1) {
  32612. (0, _element.addClass)(headerLink, 'columnSorting');
  32613. }
  32614. (0, _element.removeClass)(headerLink, 'descending');
  32615. (0, _element.removeClass)(headerLink, 'ascending');
  32616. if (this.sortIndicators[col]) {
  32617. if (col === this.hot.sortColumn) {
  32618. if (this.sortOrderClass === 'ascending') {
  32619. (0, _element.addClass)(headerLink, 'ascending');
  32620. } else if (this.sortOrderClass === 'descending') {
  32621. (0, _element.addClass)(headerLink, 'descending');
  32622. }
  32623. }
  32624. }
  32625. }
  32626. /**
  32627. * Check if any column is in a sorted state.
  32628. *
  32629. * @returns {Boolean}
  32630. */
  32631. }, {
  32632. key: 'isSorted',
  32633. value: function isSorted() {
  32634. return typeof this.hot.sortColumn != 'undefined';
  32635. }
  32636. /**
  32637. * `afterCreateRow` callback. Updates the sorting state after a row have been created.
  32638. *
  32639. * @private
  32640. * @param {Number} index Visual row index.
  32641. * @param {Number} amount
  32642. */
  32643. }, {
  32644. key: 'afterCreateRow',
  32645. value: function afterCreateRow(index, amount) {
  32646. if (!this.isSorted()) {
  32647. return;
  32648. }
  32649. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  32650. if (this.hot.sortIndex[i][0] >= index) {
  32651. this.hot.sortIndex[i][0] += amount;
  32652. }
  32653. }
  32654. for (var _i2 = 0; _i2 < amount; _i2++) {
  32655. this.hot.sortIndex.splice(index + _i2, 0, [index + _i2, this.hot.getSourceData()[index + _i2][this.hot.sortColumn + this.hot.colOffset()]]);
  32656. }
  32657. this.saveSortingState();
  32658. }
  32659. /**
  32660. * `afterRemoveRow` hook callback.
  32661. *
  32662. * @private
  32663. * @param {Number} index Visual row index.
  32664. * @param {Number} amount
  32665. */
  32666. }, {
  32667. key: 'afterRemoveRow',
  32668. value: function afterRemoveRow(index, amount) {
  32669. if (!this.isSorted()) {
  32670. return;
  32671. }
  32672. var removedRows = this.hot.sortIndex.splice(index, amount);
  32673. removedRows = (0, _array.arrayMap)(removedRows, function (row) {
  32674. return row[0];
  32675. });
  32676. function countRowShift(logicalRow) {
  32677. // Todo: compare perf between reduce vs sort->each->brake
  32678. return (0, _array.arrayReduce)(removedRows, function (count, removedLogicalRow) {
  32679. if (logicalRow > removedLogicalRow) {
  32680. count++;
  32681. }
  32682. return count;
  32683. }, 0);
  32684. }
  32685. this.hot.sortIndex = (0, _array.arrayMap)(this.hot.sortIndex, function (logicalRow, physicalRow) {
  32686. var rowShift = countRowShift(logicalRow[0]);
  32687. if (rowShift) {
  32688. logicalRow[0] -= rowShift;
  32689. }
  32690. return logicalRow;
  32691. });
  32692. this.saveSortingState();
  32693. }
  32694. /**
  32695. * Set options by passed settings
  32696. *
  32697. * @private
  32698. */
  32699. }, {
  32700. key: 'setPluginOptions',
  32701. value: function setPluginOptions() {
  32702. var columnSorting = this.hot.getSettings().columnSorting;
  32703. if ((typeof columnSorting === 'undefined' ? 'undefined' : _typeof(columnSorting)) === 'object') {
  32704. this.sortEmptyCells = columnSorting.sortEmptyCells || false;
  32705. } else {
  32706. this.sortEmptyCells = false;
  32707. }
  32708. }
  32709. /**
  32710. * `onAfterOnCellMouseDown` hook callback.
  32711. *
  32712. * @private
  32713. * @param {Event} event Event which are provided by hook.
  32714. * @param {CellCoords} coords Visual coords of the selected cell.
  32715. */
  32716. }, {
  32717. key: 'onAfterOnCellMouseDown',
  32718. value: function onAfterOnCellMouseDown(event, coords) {
  32719. if (coords.row > -1) {
  32720. return;
  32721. }
  32722. if ((0, _element.hasClass)(event.realTarget, 'columnSorting')) {
  32723. // reset order state on every new column header click
  32724. if (coords.col !== this.lastSortedColumn) {
  32725. this.hot.sortOrder = true;
  32726. }
  32727. this.lastSortedColumn = coords.col;
  32728. this.sortByColumn(coords.col);
  32729. }
  32730. }
  32731. }]);
  32732. return ColumnSorting;
  32733. }(_base2.default);
  32734. (0, _plugins.registerPlugin)('columnSorting', ColumnSorting);
  32735. exports.default = ColumnSorting;
  32736. /***/ }),
  32737. /* 330 */
  32738. /***/ (function(module, exports, __webpack_require__) {
  32739. "use strict";
  32740. exports.__esModule = true;
  32741. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  32742. var _element = __webpack_require__(0);
  32743. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32744. /**
  32745. * Comment editor for the Comments plugin.
  32746. *
  32747. * @class CommentEditor
  32748. * @plugin Comments
  32749. */
  32750. var CommentEditor = function () {
  32751. _createClass(CommentEditor, null, [{
  32752. key: 'CLASS_EDITOR_CONTAINER',
  32753. get: function get() {
  32754. return 'htCommentsContainer';
  32755. }
  32756. }, {
  32757. key: 'CLASS_EDITOR',
  32758. get: function get() {
  32759. return 'htComments';
  32760. }
  32761. }, {
  32762. key: 'CLASS_INPUT',
  32763. get: function get() {
  32764. return 'htCommentTextArea';
  32765. }
  32766. }, {
  32767. key: 'CLASS_CELL',
  32768. get: function get() {
  32769. return 'htCommentCell';
  32770. }
  32771. }]);
  32772. function CommentEditor() {
  32773. _classCallCheck(this, CommentEditor);
  32774. this.editor = this.createEditor();
  32775. this.editorStyle = this.editor.style;
  32776. this.hidden = true;
  32777. this.hide();
  32778. }
  32779. /**
  32780. * Set position of the comments editor according to the provided x and y coordinates.
  32781. *
  32782. * @param {Number} x X position (in pixels).
  32783. * @param {Number} y Y position (in pixels).
  32784. */
  32785. _createClass(CommentEditor, [{
  32786. key: 'setPosition',
  32787. value: function setPosition(x, y) {
  32788. this.editorStyle.left = x + 'px';
  32789. this.editorStyle.top = y + 'px';
  32790. }
  32791. /**
  32792. * Set the editor size according to the provided arguments.
  32793. *
  32794. * @param {Number} width Width in pixels.
  32795. * @param {Number} height Height in pixels.
  32796. */
  32797. }, {
  32798. key: 'setSize',
  32799. value: function setSize(width, height) {
  32800. if (width && height) {
  32801. var input = this.getInputElement();
  32802. input.style.width = width + 'px';
  32803. input.style.height = height + 'px';
  32804. }
  32805. }
  32806. /**
  32807. * Reset the editor size to its initial state.
  32808. */
  32809. }, {
  32810. key: 'resetSize',
  32811. value: function resetSize() {
  32812. var input = this.getInputElement();
  32813. input.style.width = '';
  32814. input.style.height = '';
  32815. }
  32816. /**
  32817. * Set the read-only state for the comments editor.
  32818. *
  32819. * @param {Boolean} state The new read only state.
  32820. */
  32821. }, {
  32822. key: 'setReadOnlyState',
  32823. value: function setReadOnlyState(state) {
  32824. var input = this.getInputElement();
  32825. input.readOnly = state;
  32826. }
  32827. /**
  32828. * Show the comments editor.
  32829. */
  32830. }, {
  32831. key: 'show',
  32832. value: function show() {
  32833. this.editorStyle.display = 'block';
  32834. this.hidden = false;
  32835. }
  32836. /**
  32837. * Hide the comments editor.
  32838. */
  32839. }, {
  32840. key: 'hide',
  32841. value: function hide() {
  32842. this.editorStyle.display = 'none';
  32843. this.hidden = true;
  32844. }
  32845. /**
  32846. * Checks if the editor is visible.
  32847. *
  32848. * @returns {Boolean}
  32849. */
  32850. }, {
  32851. key: 'isVisible',
  32852. value: function isVisible() {
  32853. return this.editorStyle.display === 'block';
  32854. }
  32855. /**
  32856. * Set the comment value.
  32857. *
  32858. * @param {String} [value] The value to use.
  32859. */
  32860. }, {
  32861. key: 'setValue',
  32862. value: function setValue() {
  32863. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  32864. value = value || '';
  32865. this.getInputElement().value = value;
  32866. }
  32867. /**
  32868. * Get the comment value.
  32869. *
  32870. * @returns {String}
  32871. */
  32872. }, {
  32873. key: 'getValue',
  32874. value: function getValue() {
  32875. return this.getInputElement().value;
  32876. }
  32877. /**
  32878. * Checks if the comment input element is focused.
  32879. *
  32880. * @returns {Boolean}
  32881. */
  32882. }, {
  32883. key: 'isFocused',
  32884. value: function isFocused() {
  32885. return document.activeElement === this.getInputElement();
  32886. }
  32887. /**
  32888. * Focus the comments input element.
  32889. */
  32890. }, {
  32891. key: 'focus',
  32892. value: function focus() {
  32893. this.getInputElement().focus();
  32894. }
  32895. /**
  32896. * Create the `textarea` to be used as a comments editor.
  32897. *
  32898. * @returns {HTMLElement}
  32899. */
  32900. }, {
  32901. key: 'createEditor',
  32902. value: function createEditor() {
  32903. var container = document.querySelector('.' + CommentEditor.CLASS_EDITOR_CONTAINER);
  32904. var editor = void 0;
  32905. var textArea = void 0;
  32906. if (!container) {
  32907. container = document.createElement('div');
  32908. (0, _element.addClass)(container, CommentEditor.CLASS_EDITOR_CONTAINER);
  32909. document.body.appendChild(container);
  32910. }
  32911. editor = document.createElement('div');
  32912. (0, _element.addClass)(editor, CommentEditor.CLASS_EDITOR);
  32913. textArea = document.createElement('textarea');
  32914. (0, _element.addClass)(textArea, CommentEditor.CLASS_INPUT);
  32915. editor.appendChild(textArea);
  32916. container.appendChild(editor);
  32917. return editor;
  32918. }
  32919. /**
  32920. * Get the input element.
  32921. *
  32922. * @returns {HTMLElement}
  32923. */
  32924. }, {
  32925. key: 'getInputElement',
  32926. value: function getInputElement() {
  32927. return this.editor.querySelector('.' + CommentEditor.CLASS_INPUT);
  32928. }
  32929. /**
  32930. * Destroy the comments editor.
  32931. */
  32932. }, {
  32933. key: 'destroy',
  32934. value: function destroy() {
  32935. this.editor.parentNode.removeChild(this.editor);
  32936. this.editor = null;
  32937. this.editorStyle = null;
  32938. }
  32939. }]);
  32940. return CommentEditor;
  32941. }();
  32942. exports.default = CommentEditor;
  32943. /***/ }),
  32944. /* 331 */
  32945. /***/ (function(module, exports, __webpack_require__) {
  32946. "use strict";
  32947. exports.__esModule = true;
  32948. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  32949. var _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); } };
  32950. var _element = __webpack_require__(0);
  32951. var _object = __webpack_require__(1);
  32952. var _eventManager = __webpack_require__(4);
  32953. var _eventManager2 = _interopRequireDefault(_eventManager);
  32954. var _src = __webpack_require__(11);
  32955. var _plugins = __webpack_require__(5);
  32956. var _base = __webpack_require__(12);
  32957. var _base2 = _interopRequireDefault(_base);
  32958. var _commentEditor = __webpack_require__(330);
  32959. var _commentEditor2 = _interopRequireDefault(_commentEditor);
  32960. var _utils = __webpack_require__(17);
  32961. var _displaySwitch = __webpack_require__(332);
  32962. var _displaySwitch2 = _interopRequireDefault(_displaySwitch);
  32963. __webpack_require__(412);
  32964. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32965. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  32966. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32967. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  32968. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  32969. var privatePool = new WeakMap();
  32970. var META_COMMENT = 'comment';
  32971. var META_COMMENT_VALUE = 'value';
  32972. var META_STYLE = 'style';
  32973. var META_READONLY = 'readOnly';
  32974. /**
  32975. * @plugin Comments
  32976. *
  32977. * @description
  32978. * This plugin allows setting and managing cell comments by either an option in the context menu or with the use of the API.
  32979. *
  32980. * To enable the plugin, you'll need to set the comments property of the config object to `true`:
  32981. * ```js
  32982. * ...
  32983. * comments: true
  32984. * ...
  32985. * ```
  32986. *
  32987. * or object with extra predefined plugin config:
  32988. *
  32989. * ```js
  32990. * ...
  32991. * comments: {
  32992. * displayDelay: 1000
  32993. * }
  32994. * ...
  32995. * ```
  32996. *
  32997. * To add comments at the table initialization, define the `comment` property in the `cell` config array as in an example below.
  32998. *
  32999. * @example
  33000. *
  33001. * ```js
  33002. * ...
  33003. * var hot = new Handsontable(document.getElementById('example'), {
  33004. * date: getData(),
  33005. * comments: true,
  33006. * cell: [
  33007. * {row: 1, col: 1, comment: {value: 'Foo'}},
  33008. * {row: 2, col: 2, comment: {value: 'Bar'}}
  33009. * ]
  33010. * });
  33011. *
  33012. * // Access to the Comments plugin instance:
  33013. * var commentsPlugin = hot.getPlugin('comments');
  33014. *
  33015. * // Manage comments programmatically:
  33016. * commentsPlugin.editor.setCommentAtCell(1, 6, 'Comment contents');
  33017. * commentsPlugin.showAtCell(1, 6);
  33018. * commentsPlugin.removeCommentAtCell(1, 6);
  33019. *
  33020. * // You can also set range once and use proper methods:
  33021. * commentsPlugin.setRange({row: 1, col: 6});
  33022. * commentsPlugin.setComment('Comment contents');
  33023. * commentsPlugin.show();
  33024. * commentsPlugin.removeComment();
  33025. * ...
  33026. * ```
  33027. */
  33028. var Comments = function (_BasePlugin) {
  33029. _inherits(Comments, _BasePlugin);
  33030. function Comments(hotInstance) {
  33031. _classCallCheck(this, Comments);
  33032. /**
  33033. * Instance of {@link CommentEditor}.
  33034. *
  33035. * @type {CommentEditor}
  33036. */
  33037. var _this = _possibleConstructorReturn(this, (Comments.__proto__ || Object.getPrototypeOf(Comments)).call(this, hotInstance));
  33038. _this.editor = null;
  33039. /**
  33040. * Instance of {@link DisplaySwitch}.
  33041. *
  33042. * @type {DisplaySwitch}
  33043. */
  33044. _this.displaySwitch = null;
  33045. /**
  33046. * Instance of {@link EventManager}.
  33047. *
  33048. * @private
  33049. * @type {EventManager}
  33050. */
  33051. _this.eventManager = null;
  33052. /**
  33053. * Current cell range.
  33054. *
  33055. * @type {Object}
  33056. */
  33057. _this.range = {};
  33058. /**
  33059. * @private
  33060. * @type {Boolean}
  33061. */
  33062. _this.mouseDown = false;
  33063. /**
  33064. * @private
  33065. * @type {Boolean}
  33066. */
  33067. _this.contextMenuEvent = false;
  33068. /**
  33069. * @private
  33070. * @type {*}
  33071. */
  33072. _this.timer = null;
  33073. privatePool.set(_this, {
  33074. tempEditorDimensions: {},
  33075. cellBelowCursor: null
  33076. });
  33077. return _this;
  33078. }
  33079. /**
  33080. * Check if the plugin is enabled in the Handsontable settings.
  33081. *
  33082. * @returns {Boolean}
  33083. */
  33084. _createClass(Comments, [{
  33085. key: 'isEnabled',
  33086. value: function isEnabled() {
  33087. return !!this.hot.getSettings().comments;
  33088. }
  33089. /**
  33090. * Enable plugin for this Handsontable instance.
  33091. */
  33092. }, {
  33093. key: 'enablePlugin',
  33094. value: function enablePlugin() {
  33095. var _this2 = this;
  33096. if (this.enabled) {
  33097. return;
  33098. }
  33099. if (!this.editor) {
  33100. this.editor = new _commentEditor2.default();
  33101. }
  33102. if (!this.eventManager) {
  33103. this.eventManager = new _eventManager2.default(this);
  33104. }
  33105. if (!this.displaySwitch) {
  33106. this.displaySwitch = new _displaySwitch2.default(this.getDisplayDelaySetting());
  33107. }
  33108. this.addHook('afterContextMenuDefaultOptions', function (options) {
  33109. return _this2.addToContextMenu(options);
  33110. });
  33111. this.addHook('afterRenderer', function (TD, row, col, prop, value, cellProperties) {
  33112. return _this2.onAfterRenderer(TD, cellProperties);
  33113. });
  33114. this.addHook('afterScrollHorizontally', function () {
  33115. return _this2.hide();
  33116. });
  33117. this.addHook('afterScrollVertically', function () {
  33118. return _this2.hide();
  33119. });
  33120. this.addHook('afterBeginEditing', function (args) {
  33121. return _this2.onAfterBeginEditing(args);
  33122. });
  33123. this.displaySwitch.addLocalHook('hide', function () {
  33124. return _this2.hide();
  33125. });
  33126. this.displaySwitch.addLocalHook('show', function (row, col) {
  33127. return _this2.showAtCell(row, col);
  33128. });
  33129. this.registerListeners();
  33130. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'enablePlugin', this).call(this);
  33131. }
  33132. /**
  33133. * Update plugin for this Handsontable instance.
  33134. */
  33135. }, {
  33136. key: 'updatePlugin',
  33137. value: function updatePlugin() {
  33138. this.disablePlugin();
  33139. this.enablePlugin();
  33140. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'updatePlugin', this).call(this);
  33141. this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
  33142. }
  33143. /**
  33144. * Disable plugin for this Handsontable instance.
  33145. */
  33146. }, {
  33147. key: 'disablePlugin',
  33148. value: function disablePlugin() {
  33149. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'disablePlugin', this).call(this);
  33150. }
  33151. /**
  33152. * Register all necessary DOM listeners.
  33153. *
  33154. * @private
  33155. */
  33156. }, {
  33157. key: 'registerListeners',
  33158. value: function registerListeners() {
  33159. var _this3 = this;
  33160. this.eventManager.addEventListener(document, 'mouseover', function (event) {
  33161. return _this3.onMouseOver(event);
  33162. });
  33163. this.eventManager.addEventListener(document, 'mousedown', function (event) {
  33164. return _this3.onMouseDown(event);
  33165. });
  33166. this.eventManager.addEventListener(document, 'mouseup', function (event) {
  33167. return _this3.onMouseUp(event);
  33168. });
  33169. this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function (event) {
  33170. return _this3.onEditorBlur(event);
  33171. });
  33172. this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
  33173. return _this3.onEditorMouseDown(event);
  33174. });
  33175. this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
  33176. return _this3.onEditorMouseUp(event);
  33177. });
  33178. }
  33179. /**
  33180. * Set current cell range to be able to use general methods like {@link Comments#setComment},
  33181. * {@link Comments#removeComment}, {@link Comments#show}.
  33182. *
  33183. * @param {Object} range Object with `from` and `to` properties, each with `row` and `col` properties.
  33184. */
  33185. }, {
  33186. key: 'setRange',
  33187. value: function setRange(range) {
  33188. this.range = range;
  33189. }
  33190. /**
  33191. * Clear the currently selected cell.
  33192. */
  33193. }, {
  33194. key: 'clearRange',
  33195. value: function clearRange() {
  33196. this.range = {};
  33197. }
  33198. /**
  33199. * Check if the event target is a cell containing a comment.
  33200. *
  33201. * @param {Event} event DOM event
  33202. * @returns {Boolean}
  33203. */
  33204. }, {
  33205. key: 'targetIsCellWithComment',
  33206. value: function targetIsCellWithComment(event) {
  33207. var closestCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  33208. return !!(closestCell && (0, _element.hasClass)(closestCell, 'htCommentCell') && (0, _element.closest)(closestCell, [this.hot.rootElement]));
  33209. }
  33210. /**
  33211. * Check if the event target is a comment textarea.
  33212. *
  33213. * @param {Event} event DOM event.
  33214. * @returns {Boolean}
  33215. */
  33216. }, {
  33217. key: 'targetIsCommentTextArea',
  33218. value: function targetIsCommentTextArea(event) {
  33219. return this.editor.getInputElement() === event.target;
  33220. }
  33221. /**
  33222. * Set a comment for a cell according to the previously set range (see {@link Comments#setRange}).
  33223. *
  33224. * @param {String} value Comment contents.
  33225. */
  33226. }, {
  33227. key: 'setComment',
  33228. value: function setComment(value) {
  33229. if (!this.range.from) {
  33230. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  33231. }
  33232. var editorValue = this.editor.getValue();
  33233. var comment = '';
  33234. if (value != null) {
  33235. comment = value;
  33236. } else if (editorValue != null) {
  33237. comment = editorValue;
  33238. }
  33239. var row = this.range.from.row;
  33240. var col = this.range.from.col;
  33241. this.updateCommentMeta(row, col, _defineProperty({}, META_COMMENT_VALUE, comment));
  33242. this.hot.render();
  33243. }
  33244. /**
  33245. * Set a comment for a cell.
  33246. *
  33247. * @param {Number} row Visual row index.
  33248. * @param {Number} col Visual column index.
  33249. * @param {String} value Comment contents.
  33250. */
  33251. }, {
  33252. key: 'setCommentAtCell',
  33253. value: function setCommentAtCell(row, col, value) {
  33254. this.setRange({
  33255. from: new _src.CellCoords(row, col)
  33256. });
  33257. this.setComment(value);
  33258. }
  33259. /**
  33260. * Remove a comment from a cell according to previously set range (see {@link Comments#setRange}).
  33261. *
  33262. * @param {Boolean} [forceRender = true] If set to `true`, the table will be re-rendered at the end of the operation.
  33263. */
  33264. }, {
  33265. key: 'removeComment',
  33266. value: function removeComment() {
  33267. var forceRender = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  33268. if (!this.range.from) {
  33269. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  33270. }
  33271. this.hot.setCellMeta(this.range.from.row, this.range.from.col, META_COMMENT, void 0);
  33272. if (forceRender) {
  33273. this.hot.render();
  33274. }
  33275. this.hide();
  33276. }
  33277. /**
  33278. * Remove comment from a cell.
  33279. *
  33280. * @param {Number} row Visual row index.
  33281. * @param {Number} col Visual column index.
  33282. * @param {Boolean} [forceRender = true] If `true`, the table will be re-rendered at the end of the operation.
  33283. */
  33284. }, {
  33285. key: 'removeCommentAtCell',
  33286. value: function removeCommentAtCell(row, col) {
  33287. var forceRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  33288. this.setRange({
  33289. from: new _src.CellCoords(row, col)
  33290. });
  33291. this.removeComment(forceRender);
  33292. }
  33293. /**
  33294. * Get comment from a cell at the predefined range.
  33295. */
  33296. }, {
  33297. key: 'getComment',
  33298. value: function getComment() {
  33299. var row = this.range.from.row;
  33300. var column = this.range.from.col;
  33301. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  33302. }
  33303. /**
  33304. * Get comment from a cell at the provided coordinates.
  33305. *
  33306. * @param {Number} row Visual row index.
  33307. * @param {Number} column Visual column index.
  33308. */
  33309. }, {
  33310. key: 'getCommentAtCell',
  33311. value: function getCommentAtCell(row, column) {
  33312. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  33313. }
  33314. /**
  33315. * Show the comment editor accordingly to the previously set range (see {@link Comments#setRange}).
  33316. *
  33317. * @returns {Boolean} Returns `true` if comment editor was shown.
  33318. */
  33319. }, {
  33320. key: 'show',
  33321. value: function show() {
  33322. if (!this.range.from) {
  33323. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  33324. }
  33325. var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
  33326. this.refreshEditor(true);
  33327. this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
  33328. if (this.editor.hidden) {
  33329. this.editor.show();
  33330. }
  33331. return true;
  33332. }
  33333. /**
  33334. * Show comment editor according to cell coordinates.
  33335. *
  33336. * @param {Number} row Visual row index.
  33337. * @param {Number} col Visual column index.
  33338. * @returns {Boolean} Returns `true` if comment editor was shown.
  33339. */
  33340. }, {
  33341. key: 'showAtCell',
  33342. value: function showAtCell(row, col) {
  33343. this.setRange({
  33344. from: new _src.CellCoords(row, col)
  33345. });
  33346. return this.show();
  33347. }
  33348. /**
  33349. * Hide the comment editor.
  33350. */
  33351. }, {
  33352. key: 'hide',
  33353. value: function hide() {
  33354. if (!this.editor.hidden) {
  33355. this.editor.hide();
  33356. }
  33357. }
  33358. /**
  33359. * Refresh comment editor position and styling.
  33360. *
  33361. * @param {Boolean} [force=false] If `true` then recalculation will be forced.
  33362. */
  33363. }, {
  33364. key: 'refreshEditor',
  33365. value: function refreshEditor() {
  33366. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  33367. if (!force && (!this.range.from || !this.editor.isVisible())) {
  33368. return;
  33369. }
  33370. var scrollableElement = (0, _element.getScrollableElement)(this.hot.view.wt.wtTable.TABLE);
  33371. var TD = this.hot.view.wt.wtTable.getCell(this.range.from);
  33372. var row = this.range.from.row;
  33373. var column = this.range.from.col;
  33374. var cellOffset = (0, _element.offset)(TD);
  33375. var lastColWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(column);
  33376. var cellTopOffset = cellOffset.top < 0 ? 0 : cellOffset.top;
  33377. var cellLeftOffset = cellOffset.left;
  33378. if (this.hot.view.wt.wtViewport.hasVerticalScroll() && scrollableElement !== window) {
  33379. cellTopOffset -= this.hot.view.wt.wtOverlays.topOverlay.getScrollPosition();
  33380. }
  33381. if (this.hot.view.wt.wtViewport.hasHorizontalScroll() && scrollableElement !== window) {
  33382. cellLeftOffset -= this.hot.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  33383. }
  33384. var x = cellLeftOffset + lastColWidth;
  33385. var y = cellTopOffset;
  33386. var commentStyle = this.getCommentMeta(row, column, META_STYLE);
  33387. var readOnly = this.getCommentMeta(row, column, META_READONLY);
  33388. if (commentStyle) {
  33389. this.editor.setSize(commentStyle.width, commentStyle.height);
  33390. } else {
  33391. this.editor.resetSize();
  33392. }
  33393. this.editor.setReadOnlyState(readOnly);
  33394. this.editor.setPosition(x, y);
  33395. }
  33396. /**
  33397. * Check if there is a comment for selected range.
  33398. *
  33399. * @private
  33400. * @returns {Boolean}
  33401. */
  33402. }, {
  33403. key: 'checkSelectionCommentsConsistency',
  33404. value: function checkSelectionCommentsConsistency() {
  33405. var selected = this.hot.getSelectedRange();
  33406. if (!selected) {
  33407. return false;
  33408. }
  33409. var hasComment = false;
  33410. var cell = selected.from; // IN EXCEL THERE IS COMMENT ONLY FOR TOP LEFT CELL IN SELECTION
  33411. if (this.getCommentMeta(cell.row, cell.col, META_COMMENT_VALUE)) {
  33412. hasComment = true;
  33413. }
  33414. return hasComment;
  33415. }
  33416. /**
  33417. * Set or update the comment-related cell meta.
  33418. *
  33419. * @param {Number} row Visual row index.
  33420. * @param {Number} column Visual column index.
  33421. * @param {Object} metaObject Object defining all the comment-related meta information.
  33422. */
  33423. }, {
  33424. key: 'updateCommentMeta',
  33425. value: function updateCommentMeta(row, column, metaObject) {
  33426. var oldComment = this.hot.getCellMeta(row, column)[META_COMMENT];
  33427. var newComment = void 0;
  33428. if (oldComment) {
  33429. newComment = (0, _object.deepClone)(oldComment);
  33430. (0, _object.deepExtend)(newComment, metaObject);
  33431. } else {
  33432. newComment = metaObject;
  33433. }
  33434. this.hot.setCellMeta(row, column, META_COMMENT, newComment);
  33435. }
  33436. /**
  33437. * Get the comment related meta information.
  33438. *
  33439. * @param {Number} row Visual row index.
  33440. * @param {Number} column Visual column index.
  33441. * @param {String} property Cell meta property.
  33442. * @returns {Mixed}
  33443. */
  33444. }, {
  33445. key: 'getCommentMeta',
  33446. value: function getCommentMeta(row, column, property) {
  33447. var cellMeta = this.hot.getCellMeta(row, column);
  33448. if (!cellMeta[META_COMMENT]) {
  33449. return void 0;
  33450. }
  33451. return cellMeta[META_COMMENT][property];
  33452. }
  33453. /**
  33454. * `mousedown` event callback.
  33455. *
  33456. * @private
  33457. * @param {MouseEvent} event The `mousedown` event.
  33458. */
  33459. }, {
  33460. key: 'onMouseDown',
  33461. value: function onMouseDown(event) {
  33462. this.mouseDown = true;
  33463. if (!this.hot.view || !this.hot.view.wt) {
  33464. return;
  33465. }
  33466. if (!this.contextMenuEvent && !this.targetIsCommentTextArea(event)) {
  33467. var eventCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  33468. var coordinates = null;
  33469. if (eventCell) {
  33470. coordinates = this.hot.view.wt.wtTable.getCoords(eventCell);
  33471. }
  33472. if (!eventCell || this.range.from && coordinates && (this.range.from.row !== coordinates.row || this.range.from.col !== coordinates.col)) {
  33473. this.hide();
  33474. }
  33475. }
  33476. this.contextMenuEvent = false;
  33477. }
  33478. /**
  33479. * `mouseover` event callback.
  33480. *
  33481. * @private
  33482. * @param {MouseEvent} event The `mouseover` event.
  33483. */
  33484. }, {
  33485. key: 'onMouseOver',
  33486. value: function onMouseOver(event) {
  33487. var priv = privatePool.get(this);
  33488. priv.cellBelowCursor = document.elementFromPoint(event.clientX, event.clientY);
  33489. if (this.mouseDown || this.editor.isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || priv.cellBelowCursor !== event.target || !this.editor) {
  33490. return;
  33491. }
  33492. if (this.targetIsCellWithComment(event)) {
  33493. var coordinates = this.hot.view.wt.wtTable.getCoords(event.target);
  33494. var range = {
  33495. from: new _src.CellCoords(coordinates.row, coordinates.col)
  33496. };
  33497. this.displaySwitch.show(range);
  33498. } else if ((0, _element.isChildOf)(event.target, document) && !this.targetIsCommentTextArea(event)) {
  33499. this.displaySwitch.hide();
  33500. }
  33501. }
  33502. /**
  33503. * `mouseup` event callback.
  33504. *
  33505. * @private
  33506. * @param {MouseEvent} event The `mouseup` event.
  33507. */
  33508. }, {
  33509. key: 'onMouseUp',
  33510. value: function onMouseUp(event) {
  33511. this.mouseDown = false;
  33512. }
  33513. /** *
  33514. * The `afterRenderer` hook callback..
  33515. *
  33516. * @private
  33517. * @param {HTMLTableCellElement} TD The rendered `TD` element.
  33518. * @param {Object} cellProperties The rendered cell's property object.
  33519. */
  33520. }, {
  33521. key: 'onAfterRenderer',
  33522. value: function onAfterRenderer(TD, cellProperties) {
  33523. if (cellProperties[META_COMMENT] && cellProperties[META_COMMENT][META_COMMENT_VALUE]) {
  33524. (0, _element.addClass)(TD, cellProperties.commentedCellClassName);
  33525. }
  33526. }
  33527. /**
  33528. * `blur` event callback for the comment editor.
  33529. *
  33530. * @private
  33531. * @param {Event} event The `blur` event.
  33532. */
  33533. }, {
  33534. key: 'onEditorBlur',
  33535. value: function onEditorBlur(event) {
  33536. this.setComment();
  33537. }
  33538. /**
  33539. * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
  33540. *
  33541. * @private
  33542. * @param {MouseEvent} event The `mousedown` event.
  33543. */
  33544. }, {
  33545. key: 'onEditorMouseDown',
  33546. value: function onEditorMouseDown(event) {
  33547. var priv = privatePool.get(this);
  33548. priv.tempEditorDimensions = {
  33549. width: (0, _element.outerWidth)(event.target),
  33550. height: (0, _element.outerHeight)(event.target)
  33551. };
  33552. }
  33553. /**
  33554. * `mouseup` hook. Along with `onEditorMouseDown` used to simulate the textarea resizing event.
  33555. *
  33556. * @private
  33557. * @param {MouseEvent} event The `mouseup` event.
  33558. */
  33559. }, {
  33560. key: 'onEditorMouseUp',
  33561. value: function onEditorMouseUp(event) {
  33562. var priv = privatePool.get(this);
  33563. var currentWidth = (0, _element.outerWidth)(event.target);
  33564. var currentHeight = (0, _element.outerHeight)(event.target);
  33565. if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
  33566. this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
  33567. width: currentWidth,
  33568. height: currentHeight
  33569. }));
  33570. }
  33571. }
  33572. /**
  33573. * Context Menu's "Add comment" callback. Results in showing the comment editor.
  33574. *
  33575. * @private
  33576. */
  33577. }, {
  33578. key: 'onContextMenuAddComment',
  33579. value: function onContextMenuAddComment() {
  33580. var _this4 = this;
  33581. this.displaySwitch.cancelHiding();
  33582. var coords = this.hot.getSelectedRange();
  33583. this.contextMenuEvent = true;
  33584. this.setRange({
  33585. from: coords.from
  33586. });
  33587. this.show();
  33588. setTimeout(function () {
  33589. if (_this4.hot) {
  33590. _this4.hot.deselectCell();
  33591. _this4.editor.focus();
  33592. }
  33593. }, 10);
  33594. }
  33595. /**
  33596. * Context Menu's "remove comment" callback.
  33597. *
  33598. * @private
  33599. * @param {Object} selection The current selection.
  33600. */
  33601. }, {
  33602. key: 'onContextMenuRemoveComment',
  33603. value: function onContextMenuRemoveComment(selection) {
  33604. this.contextMenuEvent = true;
  33605. for (var i = selection.start.row; i <= selection.end.row; i++) {
  33606. for (var j = selection.start.col; j <= selection.end.col; j++) {
  33607. this.removeCommentAtCell(i, j, false);
  33608. }
  33609. }
  33610. this.hot.render();
  33611. }
  33612. /**
  33613. * Context Menu's "make comment read-only" callback.
  33614. *
  33615. * @private
  33616. * @param {Object} selection The current selection.
  33617. */
  33618. }, {
  33619. key: 'onContextMenuMakeReadOnly',
  33620. value: function onContextMenuMakeReadOnly(selection) {
  33621. this.contextMenuEvent = true;
  33622. for (var i = selection.start.row; i <= selection.end.row; i++) {
  33623. for (var j = selection.start.col; j <= selection.end.col; j++) {
  33624. var currentState = !!this.getCommentMeta(i, j, META_READONLY);
  33625. this.updateCommentMeta(i, j, _defineProperty({}, META_READONLY, !currentState));
  33626. }
  33627. }
  33628. }
  33629. /**
  33630. * Add Comments plugin options to the Context Menu.
  33631. *
  33632. * @private
  33633. * @param {Object} defaultOptions
  33634. */
  33635. }, {
  33636. key: 'addToContextMenu',
  33637. value: function addToContextMenu(defaultOptions) {
  33638. var _this5 = this;
  33639. defaultOptions.items.push({
  33640. name: '---------'
  33641. }, {
  33642. key: 'commentsAddEdit',
  33643. name: function name() {
  33644. return _this5.checkSelectionCommentsConsistency() ? 'Edit comment' : 'Add comment';
  33645. },
  33646. callback: function callback() {
  33647. return _this5.onContextMenuAddComment();
  33648. },
  33649. disabled: function disabled() {
  33650. return !(this.getSelected() && !this.selection.selectedHeader.corner);
  33651. }
  33652. }, {
  33653. key: 'commentsRemove',
  33654. name: function name() {
  33655. return 'Delete comment';
  33656. },
  33657. callback: function callback(key, selection) {
  33658. return _this5.onContextMenuRemoveComment(selection);
  33659. },
  33660. disabled: function disabled() {
  33661. return _this5.hot.selection.selectedHeader.corner;
  33662. }
  33663. }, {
  33664. key: 'commentsReadOnly',
  33665. name: function name() {
  33666. var _this6 = this;
  33667. var label = 'Read only comment';
  33668. var hasProperty = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  33669. var readOnlyProperty = _this6.getCellMeta(row, col)[META_COMMENT];
  33670. if (readOnlyProperty) {
  33671. readOnlyProperty = readOnlyProperty[META_READONLY];
  33672. }
  33673. if (readOnlyProperty) {
  33674. return true;
  33675. }
  33676. });
  33677. if (hasProperty) {
  33678. label = (0, _utils.markLabelAsSelected)(label);
  33679. }
  33680. return label;
  33681. },
  33682. callback: function callback(key, selection) {
  33683. return _this5.onContextMenuMakeReadOnly(selection);
  33684. },
  33685. disabled: function disabled() {
  33686. return _this5.hot.selection.selectedHeader.corner || !_this5.checkSelectionCommentsConsistency();
  33687. }
  33688. });
  33689. }
  33690. /**
  33691. * Get `displayDelay` setting of comment plugin.
  33692. *
  33693. * @returns {Number|undefined}
  33694. */
  33695. }, {
  33696. key: 'getDisplayDelaySetting',
  33697. value: function getDisplayDelaySetting() {
  33698. var commentSetting = this.hot.getSettings().comments;
  33699. if ((0, _object.isObject)(commentSetting)) {
  33700. return commentSetting.displayDelay;
  33701. }
  33702. return void 0;
  33703. }
  33704. /**
  33705. * `afterBeginEditing` hook callback.
  33706. *
  33707. * @private
  33708. * @param {Number} row Visual row index of the currently edited cell.
  33709. * @param {Number} column Visual column index of the currently edited cell.
  33710. */
  33711. }, {
  33712. key: 'onAfterBeginEditing',
  33713. value: function onAfterBeginEditing(row, column) {
  33714. this.hide();
  33715. }
  33716. /**
  33717. * Destroy plugin instance.
  33718. */
  33719. }, {
  33720. key: 'destroy',
  33721. value: function destroy() {
  33722. if (this.editor) {
  33723. this.editor.destroy();
  33724. }
  33725. if (this.displaySwitch) {
  33726. this.displaySwitch.destroy();
  33727. }
  33728. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'destroy', this).call(this);
  33729. }
  33730. }]);
  33731. return Comments;
  33732. }(_base2.default);
  33733. (0, _plugins.registerPlugin)('comments', Comments);
  33734. exports.default = Comments;
  33735. /***/ }),
  33736. /* 332 */
  33737. /***/ (function(module, exports, __webpack_require__) {
  33738. "use strict";
  33739. exports.__esModule = true;
  33740. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  33741. var _function = __webpack_require__(35);
  33742. var _object = __webpack_require__(1);
  33743. var _localHooks = __webpack_require__(70);
  33744. var _localHooks2 = _interopRequireDefault(_localHooks);
  33745. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33746. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33747. var DEFAULT_DISPLAY_DELAY = 250;
  33748. var DEFAULT_HIDE_DELAY = 250;
  33749. /**
  33750. * Display switch for the Comments plugin. Manages the time of delayed displaying / hiding comments.
  33751. *
  33752. * @class DisplaySwitch
  33753. * @plugin Comments
  33754. */
  33755. var DisplaySwitch = function () {
  33756. function DisplaySwitch(displayDelay) {
  33757. _classCallCheck(this, DisplaySwitch);
  33758. /**
  33759. * Flag to determine if comment can be showed or hidden. State `true` mean that last performed action
  33760. * was an attempt to show comment element. State `false` mean that it was attempt to hide comment element.
  33761. *
  33762. * @type {Boolean}
  33763. */
  33764. this.wasLastActionShow = true;
  33765. /**
  33766. * Show comment after predefined delay. It keeps reference to immutable `debounce` function.
  33767. *
  33768. * @type {Function}
  33769. */
  33770. this.showDebounced = null;
  33771. /**
  33772. * Reference to timer, run by `setTimeout`, which is hiding comment
  33773. *
  33774. * @type {Number}
  33775. */
  33776. this.hidingTimer = null;
  33777. this.updateDelay(displayDelay);
  33778. }
  33779. /**
  33780. * Responsible for hiding comment after proper delay.
  33781. */
  33782. _createClass(DisplaySwitch, [{
  33783. key: 'hide',
  33784. value: function hide() {
  33785. var _this = this;
  33786. this.wasLastActionShow = false;
  33787. this.hidingTimer = setTimeout(function () {
  33788. if (_this.wasLastActionShow === false) {
  33789. _this.runLocalHooks('hide');
  33790. }
  33791. }, DEFAULT_HIDE_DELAY);
  33792. }
  33793. /**
  33794. * Responsible for showing comment after proper delay.
  33795. *
  33796. * @param {Object} range Coordinates of selected cell.
  33797. */
  33798. }, {
  33799. key: 'show',
  33800. value: function show(range) {
  33801. this.wasLastActionShow = true;
  33802. this.showDebounced(range);
  33803. }
  33804. }, {
  33805. key: 'cancelHiding',
  33806. /**
  33807. * Cancel hiding comment.
  33808. */
  33809. value: function cancelHiding() {
  33810. this.wasLastActionShow = true;
  33811. clearTimeout(this.hidingTimer);
  33812. this.hidingTimer = null;
  33813. }
  33814. /**
  33815. * Update the switch settings.
  33816. *
  33817. * @param {Number} displayDelay Delay of showing the comments (in milliseconds).
  33818. */
  33819. }, {
  33820. key: 'updateDelay',
  33821. value: function updateDelay() {
  33822. var _this2 = this;
  33823. var displayDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DISPLAY_DELAY;
  33824. this.showDebounced = (0, _function.debounce)(function (range) {
  33825. if (_this2.wasLastActionShow) {
  33826. _this2.runLocalHooks('show', range.from.row, range.from.col);
  33827. }
  33828. }, displayDelay);
  33829. }
  33830. /**
  33831. * Destroy the switcher.
  33832. */
  33833. }, {
  33834. key: 'destroy',
  33835. value: function destroy() {
  33836. this.clearLocalHooks();
  33837. }
  33838. }]);
  33839. return DisplaySwitch;
  33840. }();
  33841. (0, _object.mixin)(DisplaySwitch, _localHooks2.default);
  33842. exports.default = DisplaySwitch;
  33843. /***/ }),
  33844. /* 333 */
  33845. /***/ (function(module, exports, __webpack_require__) {
  33846. "use strict";
  33847. exports.__esModule = true;
  33848. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  33849. var _array = __webpack_require__(2);
  33850. var _object = __webpack_require__(1);
  33851. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33852. /**
  33853. * Command executor for ContextMenu.
  33854. *
  33855. * @class CommandExecutor
  33856. * @plugin ContextMenu
  33857. */
  33858. var CommandExecutor = function () {
  33859. function CommandExecutor(hotInstance) {
  33860. _classCallCheck(this, CommandExecutor);
  33861. this.hot = hotInstance;
  33862. this.commands = {};
  33863. this.commonCallback = null;
  33864. }
  33865. /**
  33866. * Register command.
  33867. *
  33868. * @param {String} name Command name.
  33869. * @param {Object} commandDescriptor Command descriptor object with properties like `key` (command id),
  33870. * `callback` (task to execute), `name` (command name), `disabled` (command availability).
  33871. */
  33872. _createClass(CommandExecutor, [{
  33873. key: 'registerCommand',
  33874. value: function registerCommand(name, commandDescriptor) {
  33875. this.commands[name] = commandDescriptor;
  33876. }
  33877. /**
  33878. * Set common callback which will be trigger on every executed command.
  33879. *
  33880. * @param {Function} callback Function which will be fired on every command execute.
  33881. */
  33882. }, {
  33883. key: 'setCommonCallback',
  33884. value: function setCommonCallback(callback) {
  33885. this.commonCallback = callback;
  33886. }
  33887. /**
  33888. * Execute command by its name.
  33889. *
  33890. * @param {String} commandName Command id.
  33891. * @param {*} params Arguments passed to command task.
  33892. */
  33893. }, {
  33894. key: 'execute',
  33895. value: function execute(commandName) {
  33896. var _this = this;
  33897. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  33898. params[_key - 1] = arguments[_key];
  33899. }
  33900. var commandSplit = commandName.split(':');
  33901. commandName = commandSplit[0];
  33902. var subCommandName = commandSplit.length === 2 ? commandSplit[1] : null;
  33903. var command = this.commands[commandName];
  33904. if (!command) {
  33905. throw new Error('Menu command \'' + commandName + '\' not exists.');
  33906. }
  33907. if (subCommandName && command.submenu) {
  33908. command = findSubCommand(subCommandName, command.submenu.items);
  33909. }
  33910. if (command.disabled === true) {
  33911. return;
  33912. }
  33913. if (typeof command.disabled == 'function' && command.disabled.call(this.hot) === true) {
  33914. return;
  33915. }
  33916. if ((0, _object.hasOwnProperty)(command, 'submenu')) {
  33917. return;
  33918. }
  33919. var callbacks = [];
  33920. if (typeof command.callback === 'function') {
  33921. callbacks.push(command.callback);
  33922. }
  33923. if (typeof this.commonCallback === 'function') {
  33924. callbacks.push(this.commonCallback);
  33925. }
  33926. params.unshift(commandSplit.join(':'));
  33927. (0, _array.arrayEach)(callbacks, function (callback) {
  33928. return callback.apply(_this.hot, params);
  33929. });
  33930. }
  33931. }]);
  33932. return CommandExecutor;
  33933. }();
  33934. function findSubCommand(subCommandName, subCommands) {
  33935. var command = void 0;
  33936. (0, _array.arrayEach)(subCommands, function (cmd) {
  33937. var cmds = cmd.key ? cmd.key.split(':') : null;
  33938. if (Array.isArray(cmds) && cmds[1] === subCommandName) {
  33939. command = cmd;
  33940. return false;
  33941. }
  33942. });
  33943. return command;
  33944. }
  33945. exports.default = CommandExecutor;
  33946. /***/ }),
  33947. /* 334 */
  33948. /***/ (function(module, exports, __webpack_require__) {
  33949. "use strict";
  33950. exports.__esModule = true;
  33951. var _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); } };
  33952. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  33953. var _base = __webpack_require__(12);
  33954. var _base2 = _interopRequireDefault(_base);
  33955. var _pluginHooks = __webpack_require__(8);
  33956. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  33957. var _array = __webpack_require__(2);
  33958. var _commandExecutor = __webpack_require__(333);
  33959. var _commandExecutor2 = _interopRequireDefault(_commandExecutor);
  33960. var _eventManager = __webpack_require__(4);
  33961. var _eventManager2 = _interopRequireDefault(_eventManager);
  33962. var _itemsFactory = __webpack_require__(336);
  33963. var _itemsFactory2 = _interopRequireDefault(_itemsFactory);
  33964. var _menu = __webpack_require__(337);
  33965. var _menu2 = _interopRequireDefault(_menu);
  33966. var _plugins = __webpack_require__(5);
  33967. var _event = __webpack_require__(7);
  33968. var _element = __webpack_require__(0);
  33969. var _predefinedItems = __webpack_require__(71);
  33970. __webpack_require__(413);
  33971. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33972. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33973. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  33974. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  33975. _pluginHooks2.default.getSingleton().register('afterContextMenuDefaultOptions');
  33976. _pluginHooks2.default.getSingleton().register('afterContextMenuShow');
  33977. _pluginHooks2.default.getSingleton().register('afterContextMenuHide');
  33978. _pluginHooks2.default.getSingleton().register('afterContextMenuExecute');
  33979. /**
  33980. * @description
  33981. * This plugin creates the Handsontable Context Menu. It allows to create a new row or
  33982. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  33983. * Possible values:
  33984. * * `true` (to enable default options),
  33985. * * `false` (to disable completely)
  33986. *
  33987. * or array of any available strings:
  33988. * * `["row_above", "row_below", "col_left", "col_right",
  33989. * "remove_row", "remove_col", "---------", "undo", "redo"]`.
  33990. *
  33991. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  33992. *
  33993. * @example
  33994. * ```js
  33995. * ...
  33996. * // as a boolean
  33997. * contextMenu: true
  33998. * ...
  33999. * // as a array
  34000. * contextMenu: ['row_above', 'row_below', '---------', 'undo', 'redo']
  34001. * ...
  34002. * ```
  34003. *
  34004. * @plugin ContextMenu
  34005. */
  34006. var ContextMenu = function (_BasePlugin) {
  34007. _inherits(ContextMenu, _BasePlugin);
  34008. _createClass(ContextMenu, null, [{
  34009. key: 'DEFAULT_ITEMS',
  34010. /**
  34011. * Default menu items order when `contextMenu` is enabled by `true`.
  34012. *
  34013. * @returns {Array}
  34014. */
  34015. get: function get() {
  34016. 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];
  34017. }
  34018. }]);
  34019. function ContextMenu(hotInstance) {
  34020. _classCallCheck(this, ContextMenu);
  34021. /**
  34022. * Instance of {@link EventManager}.
  34023. *
  34024. * @type {EventManager}
  34025. */
  34026. var _this = _possibleConstructorReturn(this, (ContextMenu.__proto__ || Object.getPrototypeOf(ContextMenu)).call(this, hotInstance));
  34027. _this.eventManager = new _eventManager2.default(_this);
  34028. /**
  34029. * Instance of {@link CommandExecutor}.
  34030. *
  34031. * @type {CommandExecutor}
  34032. */
  34033. _this.commandExecutor = new _commandExecutor2.default(_this.hot);
  34034. /**
  34035. * Instance of {@link ItemsFactory}.
  34036. *
  34037. * @type {ItemsFactory}
  34038. */
  34039. _this.itemsFactory = null;
  34040. /**
  34041. * Instance of {@link Menu}.
  34042. *
  34043. * @type {Menu}
  34044. */
  34045. _this.menu = null;
  34046. return _this;
  34047. }
  34048. /**
  34049. * Check if the plugin is enabled in the Handsontable settings.
  34050. *
  34051. * @returns {Boolean}
  34052. */
  34053. _createClass(ContextMenu, [{
  34054. key: 'isEnabled',
  34055. value: function isEnabled() {
  34056. return this.hot.getSettings().contextMenu;
  34057. }
  34058. /**
  34059. * Enable plugin for this Handsontable instance.
  34060. */
  34061. }, {
  34062. key: 'enablePlugin',
  34063. value: function enablePlugin() {
  34064. var _this2 = this;
  34065. if (this.enabled) {
  34066. return;
  34067. }
  34068. this.itemsFactory = new _itemsFactory2.default(this.hot, ContextMenu.DEFAULT_ITEMS);
  34069. var settings = this.hot.getSettings().contextMenu;
  34070. var predefinedItems = {
  34071. items: this.itemsFactory.getItems(settings)
  34072. };
  34073. this.registerEvents();
  34074. if (typeof settings.callback === 'function') {
  34075. this.commandExecutor.setCommonCallback(settings.callback);
  34076. }
  34077. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'enablePlugin', this).call(this);
  34078. this.callOnPluginsReady(function () {
  34079. _this2.hot.runHooks('afterContextMenuDefaultOptions', predefinedItems);
  34080. _this2.itemsFactory.setPredefinedItems(predefinedItems.items);
  34081. var menuItems = _this2.itemsFactory.getItems(settings);
  34082. _this2.menu = new _menu2.default(_this2.hot, {
  34083. className: 'htContextMenu',
  34084. keepInViewport: true
  34085. });
  34086. _this2.hot.runHooks('beforeContextMenuSetItems', menuItems);
  34087. _this2.menu.setMenuItems(menuItems);
  34088. _this2.menu.addLocalHook('afterOpen', function () {
  34089. return _this2.onMenuAfterOpen();
  34090. });
  34091. _this2.menu.addLocalHook('afterClose', function () {
  34092. return _this2.onMenuAfterClose();
  34093. });
  34094. _this2.menu.addLocalHook('executeCommand', function () {
  34095. for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) {
  34096. params[_key] = arguments[_key];
  34097. }
  34098. return _this2.executeCommand.apply(_this2, params);
  34099. });
  34100. // Register all commands. Predefined and added by user or by plugins
  34101. (0, _array.arrayEach)(menuItems, function (command) {
  34102. return _this2.commandExecutor.registerCommand(command.key, command);
  34103. });
  34104. });
  34105. }
  34106. /**
  34107. * Updates the plugin to use the latest options you have specified.
  34108. */
  34109. }, {
  34110. key: 'updatePlugin',
  34111. value: function updatePlugin() {
  34112. this.disablePlugin();
  34113. this.enablePlugin();
  34114. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'updatePlugin', this).call(this);
  34115. }
  34116. /**
  34117. * Disable plugin for this Handsontable instance.
  34118. */
  34119. }, {
  34120. key: 'disablePlugin',
  34121. value: function disablePlugin() {
  34122. this.close();
  34123. if (this.menu) {
  34124. this.menu.destroy();
  34125. this.menu = null;
  34126. }
  34127. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'disablePlugin', this).call(this);
  34128. }
  34129. /**
  34130. * Register dom listeners.
  34131. *
  34132. * @private
  34133. */
  34134. }, {
  34135. key: 'registerEvents',
  34136. value: function registerEvents() {
  34137. var _this3 = this;
  34138. this.eventManager.addEventListener(this.hot.rootElement, 'contextmenu', function (event) {
  34139. return _this3.onContextMenu(event);
  34140. });
  34141. }
  34142. /**
  34143. * Open menu and re-position it based on dom event object.
  34144. *
  34145. * @param {Event} event The event object.
  34146. */
  34147. }, {
  34148. key: 'open',
  34149. value: function open(event) {
  34150. if (!this.menu) {
  34151. return;
  34152. }
  34153. this.menu.open();
  34154. this.menu.setPosition({
  34155. top: parseInt((0, _event.pageY)(event), 10) - (0, _element.getWindowScrollTop)(),
  34156. left: parseInt((0, _event.pageX)(event), 10) - (0, _element.getWindowScrollLeft)()
  34157. });
  34158. // ContextMenu is not detected HotTableEnv correctly because is injected outside hot-table
  34159. this.menu.hotMenu.isHotTableEnv = this.hot.isHotTableEnv;
  34160. // Handsontable.eventManager.isHotTableEnv = this.hot.isHotTableEnv;
  34161. }
  34162. /**
  34163. * Close menu.
  34164. */
  34165. }, {
  34166. key: 'close',
  34167. value: function close() {
  34168. if (!this.menu) {
  34169. return;
  34170. }
  34171. this.menu.close();
  34172. }
  34173. /**
  34174. * Execute context menu command.
  34175. *
  34176. * You can execute all predefined commands:
  34177. * * `'row_above'` - Insert row above
  34178. * * `'row_below'` - Insert row below
  34179. * * `'col_left'` - Insert column on the left
  34180. * * `'col_right'` - Insert column on the right
  34181. * * `'clear_column'` - Clear selected column
  34182. * * `'remove_row'` - Remove row
  34183. * * `'remove_col'` - Remove column
  34184. * * `'undo'` - Undo last action
  34185. * * `'redo'` - Redo last action
  34186. * * `'make_read_only'` - Make cell read only
  34187. * * `'alignment:left'` - Alignment to the left
  34188. * * `'alignment:top'` - Alignment to the top
  34189. * * `'alignment:right'` - Alignment to the right
  34190. * * `'alignment:bottom'` - Alignment to the bottom
  34191. * * `'alignment:middle'` - Alignment to the middle
  34192. * * `'alignment:center'` - Alignment to the center (justify)
  34193. *
  34194. * Or you can execute command registered in settings where `key` is your command name.
  34195. *
  34196. * @param {String} commandName
  34197. * @param {*} params
  34198. */
  34199. }, {
  34200. key: 'executeCommand',
  34201. value: function executeCommand() {
  34202. for (var _len2 = arguments.length, params = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  34203. params[_key2] = arguments[_key2];
  34204. }
  34205. this.commandExecutor.execute.apply(this.commandExecutor, params);
  34206. }
  34207. /**
  34208. * On context menu listener.
  34209. *
  34210. * @private
  34211. * @param {Event} event
  34212. */
  34213. }, {
  34214. key: 'onContextMenu',
  34215. value: function onContextMenu(event) {
  34216. var settings = this.hot.getSettings();
  34217. var showRowHeaders = settings.rowHeaders;
  34218. var showColHeaders = settings.colHeaders;
  34219. function isValidElement(element) {
  34220. return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD';
  34221. }
  34222. // if event is from hot-table we must get web component element not element inside him
  34223. var element = event.realTarget;
  34224. this.close();
  34225. if ((0, _element.hasClass)(element, 'handsontableInput')) {
  34226. return;
  34227. }
  34228. event.preventDefault();
  34229. (0, _event.stopPropagation)(event);
  34230. if (!(showRowHeaders || showColHeaders)) {
  34231. if (!isValidElement(element) && !((0, _element.hasClass)(element, 'current') && (0, _element.hasClass)(element, 'wtBorder'))) {
  34232. return;
  34233. }
  34234. }
  34235. this.open(event);
  34236. }
  34237. /**
  34238. * On menu after open listener.
  34239. *
  34240. * @private
  34241. */
  34242. }, {
  34243. key: 'onMenuAfterOpen',
  34244. value: function onMenuAfterOpen() {
  34245. this.hot.runHooks('afterContextMenuShow', this);
  34246. }
  34247. /**
  34248. * On menu after close listener.
  34249. *
  34250. * @private
  34251. */
  34252. }, {
  34253. key: 'onMenuAfterClose',
  34254. value: function onMenuAfterClose() {
  34255. this.hot.listen();
  34256. this.hot.runHooks('afterContextMenuHide', this);
  34257. }
  34258. /**
  34259. * Destroy instance.
  34260. */
  34261. }, {
  34262. key: 'destroy',
  34263. value: function destroy() {
  34264. this.close();
  34265. if (this.menu) {
  34266. this.menu.destroy();
  34267. }
  34268. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'destroy', this).call(this);
  34269. }
  34270. }]);
  34271. return ContextMenu;
  34272. }(_base2.default);
  34273. ContextMenu.SEPARATOR = {
  34274. name: _predefinedItems.SEPARATOR
  34275. };
  34276. (0, _plugins.registerPlugin)('contextMenu', ContextMenu);
  34277. exports.default = ContextMenu;
  34278. /***/ }),
  34279. /* 335 */
  34280. /***/ (function(module, exports, __webpack_require__) {
  34281. "use strict";
  34282. exports.__esModule = true;
  34283. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  34284. var _element = __webpack_require__(0);
  34285. var _event = __webpack_require__(7);
  34286. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34287. /**
  34288. * Helper class for checking if element will fit at the desired side of cursor.
  34289. *
  34290. * @class Cursor
  34291. * @plugin ContextMenu
  34292. */
  34293. var Cursor = function () {
  34294. function Cursor(object) {
  34295. _classCallCheck(this, Cursor);
  34296. var windowScrollTop = (0, _element.getWindowScrollTop)();
  34297. var windowScrollLeft = (0, _element.getWindowScrollLeft)();
  34298. var top = void 0,
  34299. topRelative = void 0;
  34300. var left = void 0,
  34301. leftRelative = void 0;
  34302. var cellHeight = void 0,
  34303. cellWidth = void 0;
  34304. this.type = this.getSourceType(object);
  34305. if (this.type === 'literal') {
  34306. top = parseInt(object.top, 10);
  34307. left = parseInt(object.left, 10);
  34308. cellHeight = object.height || 0;
  34309. cellWidth = object.width || 0;
  34310. topRelative = top;
  34311. leftRelative = left;
  34312. top += windowScrollTop;
  34313. left += windowScrollLeft;
  34314. } else if (this.type === 'event') {
  34315. top = parseInt((0, _event.pageY)(object), 10);
  34316. left = parseInt((0, _event.pageX)(object), 10);
  34317. cellHeight = object.target.clientHeight;
  34318. cellWidth = object.target.clientWidth;
  34319. topRelative = top - windowScrollTop;
  34320. leftRelative = left - windowScrollLeft;
  34321. }
  34322. this.top = top;
  34323. this.topRelative = topRelative;
  34324. this.left = left;
  34325. this.leftRelative = leftRelative;
  34326. this.scrollTop = windowScrollTop;
  34327. this.scrollLeft = windowScrollLeft;
  34328. this.cellHeight = cellHeight;
  34329. this.cellWidth = cellWidth;
  34330. }
  34331. /**
  34332. * Get source type name.
  34333. *
  34334. * @param {*} object Event or Object with coordinates.
  34335. * @returns {String} Returns one of this values: `'literal'`, `'event'`.
  34336. */
  34337. _createClass(Cursor, [{
  34338. key: 'getSourceType',
  34339. value: function getSourceType(object) {
  34340. var type = 'literal';
  34341. if (object instanceof Event) {
  34342. type = 'event';
  34343. }
  34344. return type;
  34345. }
  34346. /**
  34347. * Checks if element can be placed above the cursor.
  34348. *
  34349. * @param {HTMLElement} element Element to check if it's size will fit above the cursor.
  34350. * @returns {Boolean}
  34351. */
  34352. }, {
  34353. key: 'fitsAbove',
  34354. value: function fitsAbove(element) {
  34355. return this.topRelative >= element.offsetHeight;
  34356. }
  34357. /**
  34358. * Checks if element can be placed below the cursor.
  34359. *
  34360. * @param {HTMLElement} element Element to check if it's size will fit below the cursor.
  34361. * @param {Number} [viewportHeight] The viewport height.
  34362. * @returns {Boolean}
  34363. */
  34364. }, {
  34365. key: 'fitsBelow',
  34366. value: function fitsBelow(element) {
  34367. var viewportHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerHeight;
  34368. return this.topRelative + element.offsetHeight <= viewportHeight;
  34369. }
  34370. /**
  34371. * Checks if element can be placed on the right of the cursor.
  34372. *
  34373. * @param {HTMLElement} element Element to check if it's size will fit on the right of the cursor.
  34374. * @param {Number} [viewportWidth] The viewport width.
  34375. * @returns {Boolean}
  34376. */
  34377. }, {
  34378. key: 'fitsOnRight',
  34379. value: function fitsOnRight(element) {
  34380. var viewportWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerWidth;
  34381. return this.leftRelative + this.cellWidth + element.offsetWidth <= viewportWidth;
  34382. }
  34383. /**
  34384. * Checks if element can be placed on the left on the cursor.
  34385. *
  34386. * @param {HTMLElement} element Element to check if it's size will fit on the left of the cursor.
  34387. * @returns {Boolean}
  34388. */
  34389. }, {
  34390. key: 'fitsOnLeft',
  34391. value: function fitsOnLeft(element) {
  34392. return this.leftRelative >= element.offsetWidth;
  34393. }
  34394. }]);
  34395. return Cursor;
  34396. }();
  34397. exports.default = Cursor;
  34398. /***/ }),
  34399. /* 336 */
  34400. /***/ (function(module, exports, __webpack_require__) {
  34401. "use strict";
  34402. exports.__esModule = true;
  34403. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  34404. var _object = __webpack_require__(1);
  34405. var _array = __webpack_require__(2);
  34406. var _predefinedItems = __webpack_require__(71);
  34407. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34408. /**
  34409. * Predefined items class factory for menu items.
  34410. *
  34411. * @class ItemsFactory
  34412. * @plugin ContextMenu
  34413. */
  34414. var ItemsFactory = function () {
  34415. function ItemsFactory(hotInstance) {
  34416. var orderPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  34417. _classCallCheck(this, ItemsFactory);
  34418. this.hot = hotInstance;
  34419. this.predefinedItems = (0, _predefinedItems.predefinedItems)();
  34420. this.defaultOrderPattern = orderPattern;
  34421. }
  34422. /**
  34423. * Set predefined items.
  34424. *
  34425. * @param {Array} predefinedItems Array of predefined items.
  34426. */
  34427. _createClass(ItemsFactory, [{
  34428. key: 'setPredefinedItems',
  34429. value: function setPredefinedItems(predefinedItems) {
  34430. var _this = this;
  34431. var items = {};
  34432. this.defaultOrderPattern.length = 0;
  34433. (0, _object.objectEach)(predefinedItems, function (value, key) {
  34434. var menuItemKey = '';
  34435. if (value.name === _predefinedItems.SEPARATOR) {
  34436. items[_predefinedItems.SEPARATOR] = value;
  34437. menuItemKey = _predefinedItems.SEPARATOR;
  34438. // Menu item added as a property to array
  34439. } else if (isNaN(parseInt(key, 10))) {
  34440. value.key = value.key === void 0 ? key : value.key;
  34441. items[key] = value;
  34442. menuItemKey = value.key;
  34443. } else {
  34444. items[value.key] = value;
  34445. menuItemKey = value.key;
  34446. }
  34447. _this.defaultOrderPattern.push(menuItemKey);
  34448. });
  34449. this.predefinedItems = items;
  34450. }
  34451. /**
  34452. * Get all menu items based on pattern.
  34453. *
  34454. * @param {Array|Object|Boolean} pattern Pattern which you can define by displaying menu items order. If `true` default
  34455. * pattern will be used.
  34456. * @returns {Array}
  34457. */
  34458. }, {
  34459. key: 'getItems',
  34460. value: function getItems() {
  34461. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  34462. return _getItems(pattern, this.defaultOrderPattern, this.predefinedItems);
  34463. }
  34464. }]);
  34465. return ItemsFactory;
  34466. }();
  34467. function _getItems() {
  34468. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  34469. var defaultPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  34470. var items = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  34471. var result = [];
  34472. if (pattern && pattern.items) {
  34473. pattern = pattern.items;
  34474. } else if (!Array.isArray(pattern)) {
  34475. pattern = defaultPattern;
  34476. }
  34477. if ((0, _object.isObject)(pattern)) {
  34478. (0, _object.objectEach)(pattern, function (value, key) {
  34479. var item = items[typeof value === 'string' ? value : key];
  34480. if (!item) {
  34481. item = value;
  34482. }
  34483. if ((0, _object.isObject)(value)) {
  34484. (0, _object.extend)(item, value);
  34485. } else if (typeof item === 'string') {
  34486. item = { name: item };
  34487. }
  34488. if (item.key === void 0) {
  34489. item.key = key;
  34490. }
  34491. result.push(item);
  34492. });
  34493. } else {
  34494. (0, _array.arrayEach)(pattern, function (name, key) {
  34495. var item = items[name];
  34496. // Item deleted from settings `allowInsertRow: false` etc.
  34497. if (!item && _predefinedItems.ITEMS.indexOf(name) >= 0) {
  34498. return;
  34499. }
  34500. if (!item) {
  34501. item = { name: name, key: '' + key };
  34502. }
  34503. if ((0, _object.isObject)(name)) {
  34504. (0, _object.extend)(item, name);
  34505. }
  34506. if (item.key === void 0) {
  34507. item.key = key;
  34508. }
  34509. result.push(item);
  34510. });
  34511. }
  34512. return result;
  34513. }
  34514. exports.default = ItemsFactory;
  34515. /***/ }),
  34516. /* 337 */
  34517. /***/ (function(module, exports, __webpack_require__) {
  34518. "use strict";
  34519. exports.__esModule = true;
  34520. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  34521. var _core = __webpack_require__(64);
  34522. var _core2 = _interopRequireDefault(_core);
  34523. var _element = __webpack_require__(0);
  34524. var _array = __webpack_require__(2);
  34525. var _cursor = __webpack_require__(335);
  34526. var _cursor2 = _interopRequireDefault(_cursor);
  34527. var _eventManager = __webpack_require__(4);
  34528. var _eventManager2 = _interopRequireDefault(_eventManager);
  34529. var _object = __webpack_require__(1);
  34530. var _function = __webpack_require__(35);
  34531. var _utils = __webpack_require__(17);
  34532. var _unicode = __webpack_require__(16);
  34533. var _localHooks = __webpack_require__(70);
  34534. var _localHooks2 = _interopRequireDefault(_localHooks);
  34535. var _predefinedItems = __webpack_require__(71);
  34536. var _event = __webpack_require__(7);
  34537. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34538. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34539. /**
  34540. * @class Menu
  34541. * @plugin ContextMenu
  34542. */
  34543. var Menu = function () {
  34544. function Menu(hotInstance, options) {
  34545. _classCallCheck(this, Menu);
  34546. this.hot = hotInstance;
  34547. this.options = options || {
  34548. parent: null,
  34549. name: null,
  34550. className: '',
  34551. keepInViewport: true,
  34552. standalone: false
  34553. };
  34554. this.eventManager = new _eventManager2.default(this);
  34555. this.container = this.createContainer(this.options.name);
  34556. this.hotMenu = null;
  34557. this.hotSubMenus = {};
  34558. this.parentMenu = this.options.parent || null;
  34559. this.menuItems = null;
  34560. this.origOutsideClickDeselects = null;
  34561. this.keyEvent = false;
  34562. this.offset = {
  34563. above: 0,
  34564. below: 0,
  34565. left: 0,
  34566. right: 0
  34567. };
  34568. this._afterScrollCallback = null;
  34569. this.registerEvents();
  34570. }
  34571. /**
  34572. * Register event listeners.
  34573. *
  34574. * @private
  34575. */
  34576. _createClass(Menu, [{
  34577. key: 'registerEvents',
  34578. value: function registerEvents() {
  34579. var _this = this;
  34580. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  34581. return _this.onDocumentMouseDown(event);
  34582. });
  34583. }
  34584. /**
  34585. * Set array of objects which defines menu items.
  34586. *
  34587. * @param {Array} menuItems Menu items to display.
  34588. */
  34589. }, {
  34590. key: 'setMenuItems',
  34591. value: function setMenuItems(menuItems) {
  34592. this.menuItems = menuItems;
  34593. }
  34594. /**
  34595. * Set offset menu position for specified area (`above`, `below`, `left` or `right`).
  34596. *
  34597. * @param {String} area Specified area name (`above`, `below`, `left` or `right`).
  34598. * @param {Number} offset Offset value.
  34599. */
  34600. }, {
  34601. key: 'setOffset',
  34602. value: function setOffset(area) {
  34603. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  34604. this.offset[area] = offset;
  34605. }
  34606. /**
  34607. * Check if menu is using as sub-menu.
  34608. *
  34609. * @returns {Boolean}
  34610. */
  34611. }, {
  34612. key: 'isSubMenu',
  34613. value: function isSubMenu() {
  34614. return this.parentMenu !== null;
  34615. }
  34616. /**
  34617. * Open menu.
  34618. */
  34619. }, {
  34620. key: 'open',
  34621. value: function open() {
  34622. var _this2 = this;
  34623. this.container.removeAttribute('style');
  34624. this.container.style.display = 'block';
  34625. var delayedOpenSubMenu = (0, _function.debounce)(function (row) {
  34626. return _this2.openSubMenu(row);
  34627. }, 300);
  34628. var filteredItems = (0, _array.arrayFilter)(this.menuItems, function (item) {
  34629. return (0, _utils.isItemHidden)(item, _this2.hot);
  34630. });
  34631. filteredItems = (0, _utils.filterSeparators)(filteredItems, _predefinedItems.SEPARATOR);
  34632. var settings = {
  34633. data: filteredItems,
  34634. colHeaders: false,
  34635. colWidths: [200],
  34636. autoRowSize: false,
  34637. readOnly: true,
  34638. copyPaste: false,
  34639. columns: [{
  34640. data: 'name',
  34641. renderer: function renderer(hot, TD, row, col, prop, value) {
  34642. return _this2.menuItemRenderer(hot, TD, row, col, prop, value);
  34643. }
  34644. }],
  34645. renderAllRows: true,
  34646. fragmentSelection: 'cell',
  34647. disableVisualSelection: 'area',
  34648. beforeKeyDown: function beforeKeyDown(event) {
  34649. return _this2.onBeforeKeyDown(event);
  34650. },
  34651. afterOnCellMouseOver: function afterOnCellMouseOver(event, coords, TD) {
  34652. if (_this2.isAllSubMenusClosed()) {
  34653. delayedOpenSubMenu(coords.row);
  34654. } else {
  34655. _this2.openSubMenu(coords.row);
  34656. }
  34657. },
  34658. rowHeights: function rowHeights(row) {
  34659. return filteredItems[row].name === _predefinedItems.SEPARATOR ? 1 : 23;
  34660. }
  34661. };
  34662. this.origOutsideClickDeselects = this.hot.getSettings().outsideClickDeselects;
  34663. this.hot.getSettings().outsideClickDeselects = false;
  34664. this.hotMenu = new _core2.default(this.container, settings);
  34665. this.hotMenu.addHook('afterInit', function () {
  34666. return _this2.onAfterInit();
  34667. });
  34668. this.hotMenu.addHook('afterSelection', function (r, c, r2, c2, preventScrolling) {
  34669. return _this2.onAfterSelection(r, c, r2, c2, preventScrolling);
  34670. });
  34671. this.hotMenu.init();
  34672. this.hotMenu.listen();
  34673. this.blockMainTableCallbacks();
  34674. this.runLocalHooks('afterOpen');
  34675. }
  34676. /**
  34677. * Close menu.
  34678. *
  34679. * @param {Boolean} [closeParent=false] if `true` try to close parent menu if exists.
  34680. */
  34681. }, {
  34682. key: 'close',
  34683. value: function close() {
  34684. var closeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  34685. if (!this.isOpened()) {
  34686. return;
  34687. }
  34688. if (closeParent && this.parentMenu) {
  34689. this.parentMenu.close();
  34690. } else {
  34691. this.closeAllSubMenus();
  34692. this.container.style.display = 'none';
  34693. this.releaseMainTableCallbacks();
  34694. this.hotMenu.destroy();
  34695. this.hotMenu = null;
  34696. this.hot.getSettings().outsideClickDeselects = this.origOutsideClickDeselects;
  34697. this.runLocalHooks('afterClose');
  34698. if (this.parentMenu) {
  34699. this.parentMenu.hotMenu.listen();
  34700. }
  34701. }
  34702. }
  34703. /**
  34704. * Open sub menu at the provided row index.
  34705. *
  34706. * @param {Number} row Row index.
  34707. * @returns {Menu|Boolean} Returns created menu or `false` if no one menu was created.
  34708. */
  34709. }, {
  34710. key: 'openSubMenu',
  34711. value: function openSubMenu(row) {
  34712. if (!this.hotMenu) {
  34713. return false;
  34714. }
  34715. var cell = this.hotMenu.getCell(row, 0);
  34716. this.closeAllSubMenus();
  34717. if (!cell || !(0, _utils.hasSubMenu)(cell)) {
  34718. return false;
  34719. }
  34720. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  34721. var subMenu = new Menu(this.hot, {
  34722. parent: this,
  34723. name: dataItem.name,
  34724. className: this.options.className,
  34725. keepInViewport: true
  34726. });
  34727. subMenu.setMenuItems(dataItem.submenu.items);
  34728. subMenu.open();
  34729. subMenu.setPosition(cell.getBoundingClientRect());
  34730. this.hotSubMenus[dataItem.key] = subMenu;
  34731. return subMenu;
  34732. }
  34733. /**
  34734. * Close sub menu at row index.
  34735. *
  34736. * @param {Number} row Row index.
  34737. */
  34738. }, {
  34739. key: 'closeSubMenu',
  34740. value: function closeSubMenu(row) {
  34741. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  34742. var menus = this.hotSubMenus[dataItem.key];
  34743. if (menus) {
  34744. menus.destroy();
  34745. delete this.hotSubMenus[dataItem.key];
  34746. }
  34747. }
  34748. /**
  34749. * Close all opened sub menus.
  34750. */
  34751. }, {
  34752. key: 'closeAllSubMenus',
  34753. value: function closeAllSubMenus() {
  34754. var _this3 = this;
  34755. (0, _array.arrayEach)(this.hotMenu.getData(), function (value, row) {
  34756. return _this3.closeSubMenu(row);
  34757. });
  34758. }
  34759. /**
  34760. * Checks if all created and opened sub menus are closed.
  34761. *
  34762. * @returns {Boolean}
  34763. */
  34764. }, {
  34765. key: 'isAllSubMenusClosed',
  34766. value: function isAllSubMenusClosed() {
  34767. return Object.keys(this.hotSubMenus).length === 0;
  34768. }
  34769. /**
  34770. * Destroy instance.
  34771. */
  34772. }, {
  34773. key: 'destroy',
  34774. value: function destroy() {
  34775. this.clearLocalHooks();
  34776. this.close();
  34777. this.parentMenu = null;
  34778. this.eventManager.destroy();
  34779. }
  34780. /**
  34781. * Checks if menu was opened.
  34782. *
  34783. * @returns {Boolean} Returns `true` if menu was opened.
  34784. */
  34785. }, {
  34786. key: 'isOpened',
  34787. value: function isOpened() {
  34788. return this.hotMenu !== null;
  34789. }
  34790. /**
  34791. * Execute menu command.
  34792. *
  34793. * @param {Event} [event]
  34794. */
  34795. }, {
  34796. key: 'executeCommand',
  34797. value: function executeCommand(event) {
  34798. if (!this.isOpened() || !this.hotMenu.getSelected()) {
  34799. return;
  34800. }
  34801. var selectedItem = this.hotMenu.getSourceDataAtRow(this.hotMenu.getSelected()[0]);
  34802. this.runLocalHooks('select', selectedItem, event);
  34803. if (selectedItem.isCommand === false || selectedItem.name === _predefinedItems.SEPARATOR) {
  34804. return;
  34805. }
  34806. var selRange = this.hot.getSelectedRange();
  34807. var normalizedSelection = selRange ? (0, _utils.normalizeSelection)(selRange) : {};
  34808. var autoClose = true;
  34809. // Don't close context menu if item is disabled or it has submenu
  34810. if (selectedItem.disabled === true || typeof selectedItem.disabled === 'function' && selectedItem.disabled.call(this.hot) === true || selectedItem.submenu) {
  34811. autoClose = false;
  34812. }
  34813. this.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  34814. if (this.isSubMenu()) {
  34815. this.parentMenu.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  34816. }
  34817. if (autoClose) {
  34818. this.close(true);
  34819. }
  34820. }
  34821. /**
  34822. * Set menu position based on dom event or based on literal object.
  34823. *
  34824. * @param {Event|Object} coords Event or literal Object with coordinates.
  34825. */
  34826. }, {
  34827. key: 'setPosition',
  34828. value: function setPosition(coords) {
  34829. var cursor = new _cursor2.default(coords);
  34830. if (this.options.keepInViewport) {
  34831. if (cursor.fitsBelow(this.container)) {
  34832. this.setPositionBelowCursor(cursor);
  34833. } else if (cursor.fitsAbove(this.container)) {
  34834. this.setPositionAboveCursor(cursor);
  34835. } else {
  34836. this.setPositionBelowCursor(cursor);
  34837. }
  34838. if (cursor.fitsOnRight(this.container)) {
  34839. this.setPositionOnRightOfCursor(cursor);
  34840. } else {
  34841. this.setPositionOnLeftOfCursor(cursor);
  34842. }
  34843. } else {
  34844. this.setPositionBelowCursor(cursor);
  34845. this.setPositionOnRightOfCursor(cursor);
  34846. }
  34847. }
  34848. /**
  34849. * Set menu position above cursor object.
  34850. *
  34851. * @param {Cursor} cursor `Cursor` object.
  34852. */
  34853. }, {
  34854. key: 'setPositionAboveCursor',
  34855. value: function setPositionAboveCursor(cursor) {
  34856. var top = this.offset.above + cursor.top - this.container.offsetHeight;
  34857. if (this.isSubMenu()) {
  34858. top = cursor.top + cursor.cellHeight - this.container.offsetHeight + 3;
  34859. }
  34860. this.container.style.top = top + 'px';
  34861. }
  34862. /**
  34863. * Set menu position below cursor object.
  34864. *
  34865. * @param {Cursor} cursor `Cursor` object.
  34866. */
  34867. }, {
  34868. key: 'setPositionBelowCursor',
  34869. value: function setPositionBelowCursor(cursor) {
  34870. var top = this.offset.below + cursor.top;
  34871. if (this.isSubMenu()) {
  34872. top = cursor.top - 1;
  34873. }
  34874. this.container.style.top = top + 'px';
  34875. }
  34876. /**
  34877. * Set menu position on the right of cursor object.
  34878. *
  34879. * @param {Cursor} cursor `Cursor` object.
  34880. */
  34881. }, {
  34882. key: 'setPositionOnRightOfCursor',
  34883. value: function setPositionOnRightOfCursor(cursor) {
  34884. var left = void 0;
  34885. if (this.isSubMenu()) {
  34886. left = 1 + cursor.left + cursor.cellWidth;
  34887. } else {
  34888. left = this.offset.right + 1 + cursor.left;
  34889. }
  34890. this.container.style.left = left + 'px';
  34891. }
  34892. /**
  34893. * Set menu position on the left of cursor object.
  34894. *
  34895. * @param {Cursor} cursor `Cursor` object.
  34896. */
  34897. }, {
  34898. key: 'setPositionOnLeftOfCursor',
  34899. value: function setPositionOnLeftOfCursor(cursor) {
  34900. var left = this.offset.left + cursor.left - this.container.offsetWidth + (0, _element.getScrollbarWidth)() + 4;
  34901. this.container.style.left = left + 'px';
  34902. }
  34903. /**
  34904. * Select first cell in opened menu.
  34905. */
  34906. }, {
  34907. key: 'selectFirstCell',
  34908. value: function selectFirstCell() {
  34909. var cell = this.hotMenu.getCell(0, 0);
  34910. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  34911. this.selectNextCell(0, 0);
  34912. } else {
  34913. this.hotMenu.selectCell(0, 0);
  34914. }
  34915. }
  34916. /**
  34917. * Select last cell in opened menu.
  34918. */
  34919. }, {
  34920. key: 'selectLastCell',
  34921. value: function selectLastCell() {
  34922. var lastRow = this.hotMenu.countRows() - 1;
  34923. var cell = this.hotMenu.getCell(lastRow, 0);
  34924. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  34925. this.selectPrevCell(lastRow, 0);
  34926. } else {
  34927. this.hotMenu.selectCell(lastRow, 0);
  34928. }
  34929. }
  34930. /**
  34931. * Select next cell in opened menu.
  34932. *
  34933. * @param {Number} row Row index.
  34934. * @param {Number} col Column index.
  34935. */
  34936. }, {
  34937. key: 'selectNextCell',
  34938. value: function selectNextCell(row, col) {
  34939. var nextRow = row + 1;
  34940. var cell = nextRow < this.hotMenu.countRows() ? this.hotMenu.getCell(nextRow, col) : null;
  34941. if (!cell) {
  34942. return;
  34943. }
  34944. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  34945. this.selectNextCell(nextRow, col);
  34946. } else {
  34947. this.hotMenu.selectCell(nextRow, col);
  34948. }
  34949. }
  34950. /**
  34951. * Select previous cell in opened menu.
  34952. *
  34953. * @param {Number} row Row index.
  34954. * @param {Number} col Column index.
  34955. */
  34956. }, {
  34957. key: 'selectPrevCell',
  34958. value: function selectPrevCell(row, col) {
  34959. var prevRow = row - 1;
  34960. var cell = prevRow >= 0 ? this.hotMenu.getCell(prevRow, col) : null;
  34961. if (!cell) {
  34962. return;
  34963. }
  34964. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  34965. this.selectPrevCell(prevRow, col);
  34966. } else {
  34967. this.hotMenu.selectCell(prevRow, col);
  34968. }
  34969. }
  34970. /**
  34971. * Menu item renderer.
  34972. *
  34973. * @private
  34974. */
  34975. }, {
  34976. key: 'menuItemRenderer',
  34977. value: function menuItemRenderer(hot, TD, row, col, prop, value) {
  34978. var _this4 = this;
  34979. var item = hot.getSourceDataAtRow(row);
  34980. var wrapper = document.createElement('div');
  34981. var isSubMenu = function isSubMenu(item) {
  34982. return (0, _object.hasOwnProperty)(item, 'submenu');
  34983. };
  34984. var itemIsSeparator = function itemIsSeparator(item) {
  34985. return new RegExp(_predefinedItems.SEPARATOR, 'i').test(item.name);
  34986. };
  34987. var itemIsDisabled = function itemIsDisabled(item) {
  34988. return item.disabled === true || typeof item.disabled == 'function' && item.disabled.call(_this4.hot) === true;
  34989. };
  34990. var itemIsSelectionDisabled = function itemIsSelectionDisabled(item) {
  34991. return item.disableSelection;
  34992. };
  34993. if (typeof value === 'function') {
  34994. value = value.call(this.hot);
  34995. }
  34996. (0, _element.empty)(TD);
  34997. (0, _element.addClass)(wrapper, 'htItemWrapper');
  34998. TD.appendChild(wrapper);
  34999. if (itemIsSeparator(item)) {
  35000. (0, _element.addClass)(TD, 'htSeparator');
  35001. } else if (typeof item.renderer === 'function') {
  35002. (0, _element.addClass)(TD, 'htCustomMenuRenderer');
  35003. TD.appendChild(item.renderer(hot, wrapper, row, col, prop, value));
  35004. } else {
  35005. (0, _element.fastInnerHTML)(wrapper, value);
  35006. }
  35007. if (itemIsDisabled(item)) {
  35008. (0, _element.addClass)(TD, 'htDisabled');
  35009. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  35010. return hot.deselectCell();
  35011. });
  35012. } else if (itemIsSelectionDisabled(item)) {
  35013. (0, _element.addClass)(TD, 'htSelectionDisabled');
  35014. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  35015. return hot.deselectCell();
  35016. });
  35017. } else if (isSubMenu(item)) {
  35018. (0, _element.addClass)(TD, 'htSubmenu');
  35019. if (itemIsSelectionDisabled(item)) {
  35020. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  35021. return hot.deselectCell();
  35022. });
  35023. } else {
  35024. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  35025. return hot.selectCell(row, col, void 0, void 0, false, false);
  35026. });
  35027. }
  35028. } else {
  35029. (0, _element.removeClass)(TD, 'htSubmenu');
  35030. (0, _element.removeClass)(TD, 'htDisabled');
  35031. if (itemIsSelectionDisabled(item)) {
  35032. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  35033. return hot.deselectCell();
  35034. });
  35035. } else {
  35036. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  35037. return hot.selectCell(row, col, void 0, void 0, false, false);
  35038. });
  35039. }
  35040. }
  35041. }
  35042. /**
  35043. * Create container/wrapper for handsontable.
  35044. *
  35045. * @private
  35046. * @param {String} [name] Class name.
  35047. * @returns {HTMLElement}
  35048. */
  35049. }, {
  35050. key: 'createContainer',
  35051. value: function createContainer() {
  35052. var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  35053. if (name) {
  35054. name = name.replace(/[^A-z0-9]/g, '_');
  35055. name = this.options.className + 'Sub_' + name;
  35056. }
  35057. var container = void 0;
  35058. if (name) {
  35059. container = document.querySelector('.' + this.options.className + '.' + name);
  35060. } else {
  35061. container = document.querySelector('.' + this.options.className);
  35062. }
  35063. if (!container) {
  35064. container = document.createElement('div');
  35065. (0, _element.addClass)(container, 'htMenu ' + this.options.className);
  35066. if (name) {
  35067. (0, _element.addClass)(container, name);
  35068. }
  35069. document.getElementsByTagName('body')[0].appendChild(container);
  35070. }
  35071. return container;
  35072. }
  35073. /**
  35074. * @private
  35075. */
  35076. }, {
  35077. key: 'blockMainTableCallbacks',
  35078. value: function blockMainTableCallbacks() {
  35079. this._afterScrollCallback = function () {};
  35080. this.hot.addHook('afterScrollVertically', this._afterScrollCallback);
  35081. this.hot.addHook('afterScrollHorizontally', this._afterScrollCallback);
  35082. }
  35083. /**
  35084. * @private
  35085. */
  35086. }, {
  35087. key: 'releaseMainTableCallbacks',
  35088. value: function releaseMainTableCallbacks() {
  35089. if (this._afterScrollCallback) {
  35090. this.hot.removeHook('afterScrollVertically', this._afterScrollCallback);
  35091. this.hot.removeHook('afterScrollHorizontally', this._afterScrollCallback);
  35092. this._afterScrollCallback = null;
  35093. }
  35094. }
  35095. /**
  35096. * On before key down listener.
  35097. *
  35098. * @private
  35099. * @param {Event} event
  35100. */
  35101. }, {
  35102. key: 'onBeforeKeyDown',
  35103. value: function onBeforeKeyDown(event) {
  35104. var selection = this.hotMenu.getSelected();
  35105. var stopEvent = false;
  35106. this.keyEvent = true;
  35107. switch (event.keyCode) {
  35108. case _unicode.KEY_CODES.ESCAPE:
  35109. this.close();
  35110. stopEvent = true;
  35111. break;
  35112. case _unicode.KEY_CODES.ENTER:
  35113. if (selection) {
  35114. if (this.hotMenu.getSourceDataAtRow(selection[0]).submenu) {
  35115. stopEvent = true;
  35116. } else {
  35117. this.executeCommand(event);
  35118. this.close(true);
  35119. }
  35120. }
  35121. break;
  35122. case _unicode.KEY_CODES.ARROW_DOWN:
  35123. if (selection) {
  35124. this.selectNextCell(selection[0], selection[1]);
  35125. } else {
  35126. this.selectFirstCell();
  35127. }
  35128. stopEvent = true;
  35129. break;
  35130. case _unicode.KEY_CODES.ARROW_UP:
  35131. if (selection) {
  35132. this.selectPrevCell(selection[0], selection[1]);
  35133. } else {
  35134. this.selectLastCell();
  35135. }
  35136. stopEvent = true;
  35137. break;
  35138. case _unicode.KEY_CODES.ARROW_RIGHT:
  35139. if (selection) {
  35140. var menu = this.openSubMenu(selection[0]);
  35141. if (menu) {
  35142. menu.selectFirstCell();
  35143. }
  35144. }
  35145. stopEvent = true;
  35146. break;
  35147. case _unicode.KEY_CODES.ARROW_LEFT:
  35148. if (selection && this.isSubMenu()) {
  35149. this.close();
  35150. if (this.parentMenu) {
  35151. this.parentMenu.hotMenu.listen();
  35152. }
  35153. stopEvent = true;
  35154. }
  35155. break;
  35156. default:
  35157. break;
  35158. }
  35159. if (stopEvent) {
  35160. event.preventDefault();
  35161. (0, _event.stopImmediatePropagation)(event);
  35162. }
  35163. this.keyEvent = false;
  35164. }
  35165. /**
  35166. * On after init listener.
  35167. *
  35168. * @private
  35169. */
  35170. }, {
  35171. key: 'onAfterInit',
  35172. value: function onAfterInit() {
  35173. var data = this.hotMenu.getSettings().data;
  35174. var hiderStyle = this.hotMenu.view.wt.wtTable.hider.style;
  35175. var holderStyle = this.hotMenu.view.wt.wtTable.holder.style;
  35176. var currentHiderWidth = parseInt(hiderStyle.width, 10);
  35177. var realHeight = (0, _array.arrayReduce)(data, function (accumulator, value) {
  35178. return accumulator + (value.name === _predefinedItems.SEPARATOR ? 1 : 26);
  35179. }, 0);
  35180. holderStyle.width = currentHiderWidth + 22 + 'px';
  35181. holderStyle.height = realHeight + 4 + 'px';
  35182. hiderStyle.height = holderStyle.height;
  35183. }
  35184. /**
  35185. * On after selection listener.
  35186. *
  35187. * @param {Number} r Selection start row index.
  35188. * @param {Number} c Selection start column index.
  35189. * @param {Number} r2 Selection end row index.
  35190. * @param {Number} c2 Selection end column index.
  35191. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  35192. */
  35193. }, {
  35194. key: 'onAfterSelection',
  35195. value: function onAfterSelection(r, c, r2, c2, preventScrolling) {
  35196. if (this.keyEvent === false) {
  35197. preventScrolling.value = true;
  35198. }
  35199. }
  35200. /**
  35201. * Document mouse down listener.
  35202. *
  35203. * @private
  35204. * @param {Event} event
  35205. */
  35206. }, {
  35207. key: 'onDocumentMouseDown',
  35208. value: function onDocumentMouseDown(event) {
  35209. if (!this.isOpened()) {
  35210. return;
  35211. }
  35212. if (this.container && (0, _element.isChildOf)(event.target, this.container)) {
  35213. this.executeCommand(event);
  35214. }
  35215. // Close menu when clicked element is not belongs to menu itself
  35216. if (this.options.standalone && this.hotMenu && !(0, _element.isChildOf)(event.target, this.hotMenu.rootElement)) {
  35217. this.close(true);
  35218. // Automatically close menu when clicked element is not belongs to menu or submenu (not necessarily to itself)
  35219. } else if ((this.isAllSubMenusClosed() || this.isSubMenu()) && !(0, _element.isChildOf)(event.target, '.htMenu') && (0, _element.isChildOf)(event.target, document)) {
  35220. this.close(true);
  35221. }
  35222. }
  35223. }]);
  35224. return Menu;
  35225. }();
  35226. (0, _object.mixin)(Menu, _localHooks2.default);
  35227. exports.default = Menu;
  35228. /***/ }),
  35229. /* 338 */
  35230. /***/ (function(module, exports, __webpack_require__) {
  35231. "use strict";
  35232. exports.__esModule = true;
  35233. exports.KEY = undefined;
  35234. exports.default = alignmentItem;
  35235. var _utils = __webpack_require__(17);
  35236. var _separator = __webpack_require__(72);
  35237. var KEY = exports.KEY = 'alignment';
  35238. function alignmentItem() {
  35239. return {
  35240. key: KEY,
  35241. name: 'Alignment',
  35242. disabled: function disabled() {
  35243. return !(this.getSelectedRange() && !this.selection.selectedHeader.corner);
  35244. },
  35245. submenu: {
  35246. items: [{
  35247. key: KEY + ':left',
  35248. name: function name() {
  35249. var _this = this;
  35250. var label = 'Left';
  35251. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35252. var className = _this.getCellMeta(row, col).className;
  35253. if (className && className.indexOf('htLeft') !== -1) {
  35254. return true;
  35255. }
  35256. });
  35257. if (hasClass) {
  35258. label = (0, _utils.markLabelAsSelected)(label);
  35259. }
  35260. return label;
  35261. },
  35262. callback: function callback() {
  35263. var _this2 = this;
  35264. var range = this.getSelectedRange();
  35265. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  35266. return _this2.getCellMeta(row, col).className;
  35267. });
  35268. var type = 'horizontal';
  35269. var alignment = 'htLeft';
  35270. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  35271. (0, _utils.align)(range, type, alignment, function (row, col) {
  35272. return _this2.getCellMeta(row, col);
  35273. }, function (row, col, key, value) {
  35274. return _this2.setCellMeta(row, col, key, value);
  35275. });
  35276. this.render();
  35277. },
  35278. disabled: false
  35279. }, {
  35280. key: KEY + ':center',
  35281. name: function name() {
  35282. var _this3 = this;
  35283. var label = 'Center';
  35284. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35285. var className = _this3.getCellMeta(row, col).className;
  35286. if (className && className.indexOf('htCenter') !== -1) {
  35287. return true;
  35288. }
  35289. });
  35290. if (hasClass) {
  35291. label = (0, _utils.markLabelAsSelected)(label);
  35292. }
  35293. return label;
  35294. },
  35295. callback: function callback() {
  35296. var _this4 = this;
  35297. var range = this.getSelectedRange();
  35298. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  35299. return _this4.getCellMeta(row, col).className;
  35300. });
  35301. var type = 'horizontal';
  35302. var alignment = 'htCenter';
  35303. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  35304. (0, _utils.align)(range, type, alignment, function (row, col) {
  35305. return _this4.getCellMeta(row, col);
  35306. }, function (row, col, key, value) {
  35307. return _this4.setCellMeta(row, col, key, value);
  35308. });
  35309. this.render();
  35310. },
  35311. disabled: false
  35312. }, {
  35313. key: KEY + ':right',
  35314. name: function name() {
  35315. var _this5 = this;
  35316. var label = 'Right';
  35317. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35318. var className = _this5.getCellMeta(row, col).className;
  35319. if (className && className.indexOf('htRight') !== -1) {
  35320. return true;
  35321. }
  35322. });
  35323. if (hasClass) {
  35324. label = (0, _utils.markLabelAsSelected)(label);
  35325. }
  35326. return label;
  35327. },
  35328. callback: function callback() {
  35329. var _this6 = this;
  35330. var range = this.getSelectedRange();
  35331. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  35332. return _this6.getCellMeta(row, col).className;
  35333. });
  35334. var type = 'horizontal';
  35335. var alignment = 'htRight';
  35336. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  35337. (0, _utils.align)(range, type, alignment, function (row, col) {
  35338. return _this6.getCellMeta(row, col);
  35339. }, function (row, col, key, value) {
  35340. return _this6.setCellMeta(row, col, key, value);
  35341. });
  35342. this.render();
  35343. },
  35344. disabled: false
  35345. }, {
  35346. key: KEY + ':justify',
  35347. name: function name() {
  35348. var _this7 = this;
  35349. var label = 'Justify';
  35350. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35351. var className = _this7.getCellMeta(row, col).className;
  35352. if (className && className.indexOf('htJustify') !== -1) {
  35353. return true;
  35354. }
  35355. });
  35356. if (hasClass) {
  35357. label = (0, _utils.markLabelAsSelected)(label);
  35358. }
  35359. return label;
  35360. },
  35361. callback: function callback() {
  35362. var _this8 = this;
  35363. var range = this.getSelectedRange();
  35364. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  35365. return _this8.getCellMeta(row, col).className;
  35366. });
  35367. var type = 'horizontal';
  35368. var alignment = 'htJustify';
  35369. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  35370. (0, _utils.align)(range, type, alignment, function (row, col) {
  35371. return _this8.getCellMeta(row, col);
  35372. }, function (row, col, key, value) {
  35373. return _this8.setCellMeta(row, col, key, value);
  35374. });
  35375. this.render();
  35376. },
  35377. disabled: false
  35378. }, {
  35379. name: _separator.KEY
  35380. }, {
  35381. key: KEY + ':top',
  35382. name: function name() {
  35383. var _this9 = this;
  35384. var label = 'Top';
  35385. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35386. var className = _this9.getCellMeta(row, col).className;
  35387. if (className && className.indexOf('htTop') !== -1) {
  35388. return true;
  35389. }
  35390. });
  35391. if (hasClass) {
  35392. label = (0, _utils.markLabelAsSelected)(label);
  35393. }
  35394. return label;
  35395. },
  35396. callback: function callback() {
  35397. var _this10 = this;
  35398. var range = this.getSelectedRange();
  35399. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  35400. return _this10.getCellMeta(row, col).className;
  35401. });
  35402. var type = 'vertical';
  35403. var alignment = 'htTop';
  35404. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  35405. (0, _utils.align)(range, type, alignment, function (row, col) {
  35406. return _this10.getCellMeta(row, col);
  35407. }, function (row, col, key, value) {
  35408. return _this10.setCellMeta(row, col, key, value);
  35409. });
  35410. this.render();
  35411. },
  35412. disabled: false
  35413. }, {
  35414. key: KEY + ':middle',
  35415. name: function name() {
  35416. var _this11 = this;
  35417. var label = 'Middle';
  35418. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35419. var className = _this11.getCellMeta(row, col).className;
  35420. if (className && className.indexOf('htMiddle') !== -1) {
  35421. return true;
  35422. }
  35423. });
  35424. if (hasClass) {
  35425. label = (0, _utils.markLabelAsSelected)(label);
  35426. }
  35427. return label;
  35428. },
  35429. callback: function callback() {
  35430. var _this12 = this;
  35431. var range = this.getSelectedRange();
  35432. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  35433. return _this12.getCellMeta(row, col).className;
  35434. });
  35435. var type = 'vertical';
  35436. var alignment = 'htMiddle';
  35437. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  35438. (0, _utils.align)(range, type, alignment, function (row, col) {
  35439. return _this12.getCellMeta(row, col);
  35440. }, function (row, col, key, value) {
  35441. return _this12.setCellMeta(row, col, key, value);
  35442. });
  35443. this.render();
  35444. },
  35445. disabled: false
  35446. }, {
  35447. key: KEY + ':bottom',
  35448. name: function name() {
  35449. var _this13 = this;
  35450. var label = 'Bottom';
  35451. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35452. var className = _this13.getCellMeta(row, col).className;
  35453. if (className && className.indexOf('htBottom') !== -1) {
  35454. return true;
  35455. }
  35456. });
  35457. if (hasClass) {
  35458. label = (0, _utils.markLabelAsSelected)(label);
  35459. }
  35460. return label;
  35461. },
  35462. callback: function callback() {
  35463. var _this14 = this;
  35464. var range = this.getSelectedRange();
  35465. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  35466. return _this14.getCellMeta(row, col).className;
  35467. });
  35468. var type = 'vertical';
  35469. var alignment = 'htBottom';
  35470. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  35471. (0, _utils.align)(range, type, alignment, function (row, col) {
  35472. return _this14.getCellMeta(row, col);
  35473. }, function (row, col, key, value) {
  35474. return _this14.setCellMeta(row, col, key, value);
  35475. });
  35476. this.render();
  35477. },
  35478. disabled: false
  35479. }]
  35480. }
  35481. };
  35482. }
  35483. /***/ }),
  35484. /* 339 */
  35485. /***/ (function(module, exports, __webpack_require__) {
  35486. "use strict";
  35487. exports.__esModule = true;
  35488. exports.KEY = undefined;
  35489. exports.default = clearColumnItem;
  35490. var _utils = __webpack_require__(17);
  35491. var KEY = exports.KEY = 'clear_column';
  35492. function clearColumnItem() {
  35493. return {
  35494. key: KEY,
  35495. name: 'Clear column',
  35496. callback: function callback(key, selection) {
  35497. var column = selection.start.col;
  35498. if (this.countRows()) {
  35499. this.populateFromArray(0, column, [[null]], Math.max(selection.start.row, selection.end.row), column, 'ContextMenu.clearColumn');
  35500. }
  35501. },
  35502. disabled: function disabled() {
  35503. var selected = (0, _utils.getValidSelection)(this);
  35504. if (!selected) {
  35505. return true;
  35506. }
  35507. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  35508. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  35509. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  35510. }
  35511. };
  35512. }
  35513. /***/ }),
  35514. /* 340 */
  35515. /***/ (function(module, exports, __webpack_require__) {
  35516. "use strict";
  35517. exports.__esModule = true;
  35518. exports.KEY = undefined;
  35519. exports.default = columnLeftItem;
  35520. var _utils = __webpack_require__(17);
  35521. var KEY = exports.KEY = 'col_left';
  35522. function columnLeftItem() {
  35523. return {
  35524. key: KEY,
  35525. name: 'Insert column on the left',
  35526. callback: function callback(key, selection) {
  35527. this.alter('insert_col', selection.start.col, 1, 'ContextMenu.columnLeft');
  35528. },
  35529. disabled: function disabled() {
  35530. var selected = (0, _utils.getValidSelection)(this);
  35531. if (!selected) {
  35532. return true;
  35533. }
  35534. if (!this.isColumnModificationAllowed()) {
  35535. return true;
  35536. }
  35537. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  35538. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  35539. var onlyOneColumn = this.countCols() === 1;
  35540. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  35541. },
  35542. hidden: function hidden() {
  35543. return !this.getSettings().allowInsertColumn;
  35544. }
  35545. };
  35546. }
  35547. /***/ }),
  35548. /* 341 */
  35549. /***/ (function(module, exports, __webpack_require__) {
  35550. "use strict";
  35551. exports.__esModule = true;
  35552. exports.KEY = undefined;
  35553. exports.default = columnRightItem;
  35554. var _utils = __webpack_require__(17);
  35555. var KEY = exports.KEY = 'col_right';
  35556. function columnRightItem() {
  35557. return {
  35558. key: KEY,
  35559. name: 'Insert column on the right',
  35560. callback: function callback(key, selection) {
  35561. this.alter('insert_col', selection.end.col + 1, 1, 'ContextMenu.columnRight');
  35562. },
  35563. disabled: function disabled() {
  35564. var selected = (0, _utils.getValidSelection)(this);
  35565. if (!selected) {
  35566. return true;
  35567. }
  35568. if (!this.isColumnModificationAllowed()) {
  35569. return true;
  35570. }
  35571. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  35572. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  35573. var onlyOneColumn = this.countCols() === 1;
  35574. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  35575. },
  35576. hidden: function hidden() {
  35577. return !this.getSettings().allowInsertColumn;
  35578. }
  35579. };
  35580. }
  35581. /***/ }),
  35582. /* 342 */
  35583. /***/ (function(module, exports, __webpack_require__) {
  35584. "use strict";
  35585. exports.__esModule = true;
  35586. exports.KEY = undefined;
  35587. exports.default = readOnlyItem;
  35588. var _utils = __webpack_require__(17);
  35589. var KEY = exports.KEY = 'make_read_only';
  35590. function readOnlyItem() {
  35591. return {
  35592. key: KEY,
  35593. name: function name() {
  35594. var _this = this;
  35595. var label = 'Read only';
  35596. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  35597. return _this.getCellMeta(row, col).readOnly;
  35598. });
  35599. if (atLeastOneReadOnly) {
  35600. label = (0, _utils.markLabelAsSelected)(label);
  35601. }
  35602. return label;
  35603. },
  35604. callback: function callback() {
  35605. var _this2 = this;
  35606. var range = this.getSelectedRange();
  35607. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(range, function (row, col) {
  35608. return _this2.getCellMeta(row, col).readOnly;
  35609. });
  35610. range.forAll(function (row, col) {
  35611. _this2.setCellMeta(row, col, 'readOnly', !atLeastOneReadOnly);
  35612. });
  35613. this.render();
  35614. },
  35615. disabled: function disabled() {
  35616. return !(this.getSelectedRange() && !this.selection.selectedHeader.corner);
  35617. }
  35618. };
  35619. }
  35620. /***/ }),
  35621. /* 343 */
  35622. /***/ (function(module, exports, __webpack_require__) {
  35623. "use strict";
  35624. exports.__esModule = true;
  35625. exports.default = redoItem;
  35626. var KEY = exports.KEY = 'redo';
  35627. function redoItem() {
  35628. return {
  35629. key: KEY,
  35630. name: 'Redo',
  35631. callback: function callback() {
  35632. this.redo();
  35633. },
  35634. disabled: function disabled() {
  35635. return this.undoRedo && !this.undoRedo.isRedoAvailable();
  35636. }
  35637. };
  35638. }
  35639. /***/ }),
  35640. /* 344 */
  35641. /***/ (function(module, exports, __webpack_require__) {
  35642. "use strict";
  35643. exports.__esModule = true;
  35644. exports.KEY = undefined;
  35645. exports.default = removeColumnItem;
  35646. var _utils = __webpack_require__(17);
  35647. var KEY = exports.KEY = 'remove_col';
  35648. function removeColumnItem() {
  35649. return {
  35650. key: KEY,
  35651. name: 'Remove column',
  35652. callback: function callback(key, selection) {
  35653. var amount = selection.end.col - selection.start.col + 1;
  35654. this.alter('remove_col', selection.start.col, amount, 'ContextMenu.removeColumn');
  35655. },
  35656. disabled: function disabled() {
  35657. var selected = (0, _utils.getValidSelection)(this);
  35658. var totalColumns = this.countCols();
  35659. return !selected || this.selection.selectedHeader.rows || this.selection.selectedHeader.corner || !this.isColumnModificationAllowed() || !totalColumns;
  35660. },
  35661. hidden: function hidden() {
  35662. return !this.getSettings().allowRemoveColumn;
  35663. }
  35664. };
  35665. }
  35666. /***/ }),
  35667. /* 345 */
  35668. /***/ (function(module, exports, __webpack_require__) {
  35669. "use strict";
  35670. exports.__esModule = true;
  35671. exports.KEY = undefined;
  35672. exports.default = removeRowItem;
  35673. var _utils = __webpack_require__(17);
  35674. var KEY = exports.KEY = 'remove_row';
  35675. function removeRowItem() {
  35676. return {
  35677. key: KEY,
  35678. name: 'Remove row',
  35679. callback: function callback(key, selection) {
  35680. var amount = selection.end.row - selection.start.row + 1;
  35681. this.alter('remove_row', selection.start.row, amount, 'ContextMenu.removeRow');
  35682. },
  35683. disabled: function disabled() {
  35684. var selected = (0, _utils.getValidSelection)(this);
  35685. var totalRows = this.countRows();
  35686. return !selected || this.selection.selectedHeader.cols || this.selection.selectedHeader.corner || !totalRows;
  35687. },
  35688. hidden: function hidden() {
  35689. return !this.getSettings().allowRemoveRow;
  35690. }
  35691. };
  35692. }
  35693. /***/ }),
  35694. /* 346 */
  35695. /***/ (function(module, exports, __webpack_require__) {
  35696. "use strict";
  35697. exports.__esModule = true;
  35698. exports.KEY = undefined;
  35699. exports.default = rowAboveItem;
  35700. var _utils = __webpack_require__(17);
  35701. var KEY = exports.KEY = 'row_above';
  35702. function rowAboveItem() {
  35703. return {
  35704. key: KEY,
  35705. name: 'Insert row above',
  35706. callback: function callback(key, selection) {
  35707. this.alter('insert_row', selection.start.row, 1, 'ContextMenu.rowAbove');
  35708. },
  35709. disabled: function disabled() {
  35710. var selected = (0, _utils.getValidSelection)(this);
  35711. return !selected || this.selection.selectedHeader.cols || this.countRows() >= this.getSettings().maxRows;
  35712. },
  35713. hidden: function hidden() {
  35714. return !this.getSettings().allowInsertRow;
  35715. }
  35716. };
  35717. }
  35718. /***/ }),
  35719. /* 347 */
  35720. /***/ (function(module, exports, __webpack_require__) {
  35721. "use strict";
  35722. exports.__esModule = true;
  35723. exports.KEY = undefined;
  35724. exports.default = rowBelowItem;
  35725. var _utils = __webpack_require__(17);
  35726. var KEY = exports.KEY = 'row_below';
  35727. function rowBelowItem() {
  35728. return {
  35729. key: KEY,
  35730. name: 'Insert row below',
  35731. callback: function callback(key, selection) {
  35732. this.alter('insert_row', selection.end.row + 1, 1, 'ContextMenu.rowBelow');
  35733. },
  35734. disabled: function disabled() {
  35735. var selected = (0, _utils.getValidSelection)(this);
  35736. return !selected || this.selection.selectedHeader.cols || this.countRows() >= this.getSettings().maxRows;
  35737. },
  35738. hidden: function hidden() {
  35739. return !this.getSettings().allowInsertRow;
  35740. }
  35741. };
  35742. }
  35743. /***/ }),
  35744. /* 348 */
  35745. /***/ (function(module, exports, __webpack_require__) {
  35746. "use strict";
  35747. exports.__esModule = true;
  35748. exports.default = undoItem;
  35749. var KEY = exports.KEY = 'undo';
  35750. function undoItem() {
  35751. return {
  35752. key: KEY,
  35753. name: 'Undo',
  35754. callback: function callback() {
  35755. this.undo();
  35756. },
  35757. disabled: function disabled() {
  35758. return this.undoRedo && !this.undoRedo.isUndoAvailable();
  35759. }
  35760. };
  35761. }
  35762. /***/ }),
  35763. /* 349 */
  35764. /***/ (function(module, exports, __webpack_require__) {
  35765. "use strict";
  35766. exports.__esModule = true;
  35767. exports.default = copyItem;
  35768. function copyItem(copyPastePlugin) {
  35769. return {
  35770. key: 'copy',
  35771. name: 'Copy',
  35772. callback: function callback() {
  35773. copyPastePlugin.setCopyableText();
  35774. copyPastePlugin.copy(true);
  35775. },
  35776. disabled: false,
  35777. hidden: false
  35778. };
  35779. }
  35780. /***/ }),
  35781. /* 350 */
  35782. /***/ (function(module, exports, __webpack_require__) {
  35783. "use strict";
  35784. exports.__esModule = true;
  35785. exports.default = cutItem;
  35786. function cutItem(copyPastePlugin) {
  35787. return {
  35788. key: 'cut',
  35789. name: 'Cut',
  35790. callback: function callback() {
  35791. copyPastePlugin.setCopyableText();
  35792. copyPastePlugin.cut(true);
  35793. },
  35794. disabled: false,
  35795. hidden: false
  35796. };
  35797. }
  35798. /***/ }),
  35799. /* 351 */
  35800. /***/ (function(module, exports, __webpack_require__) {
  35801. "use strict";
  35802. exports.__esModule = true;
  35803. var _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; };
  35804. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  35805. var _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); } };
  35806. var _base = __webpack_require__(12);
  35807. var _base2 = _interopRequireDefault(_base);
  35808. var _pluginHooks = __webpack_require__(8);
  35809. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  35810. var _SheetClip = __webpack_require__(248);
  35811. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  35812. var _src = __webpack_require__(11);
  35813. var _unicode = __webpack_require__(16);
  35814. var _element = __webpack_require__(0);
  35815. var _array = __webpack_require__(2);
  35816. var _number = __webpack_require__(6);
  35817. var _event = __webpack_require__(7);
  35818. var _plugins = __webpack_require__(5);
  35819. var _textarea = __webpack_require__(352);
  35820. var _textarea2 = _interopRequireDefault(_textarea);
  35821. var _copy = __webpack_require__(349);
  35822. var _copy2 = _interopRequireDefault(_copy);
  35823. var _cut = __webpack_require__(350);
  35824. var _cut2 = _interopRequireDefault(_cut);
  35825. var _eventManager = __webpack_require__(4);
  35826. var _eventManager2 = _interopRequireDefault(_eventManager);
  35827. __webpack_require__(414);
  35828. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35829. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  35830. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  35831. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  35832. _pluginHooks2.default.getSingleton().register('afterCopyLimit');
  35833. _pluginHooks2.default.getSingleton().register('modifyCopyableRange');
  35834. _pluginHooks2.default.getSingleton().register('beforeCut');
  35835. _pluginHooks2.default.getSingleton().register('afterCut');
  35836. _pluginHooks2.default.getSingleton().register('beforePaste');
  35837. _pluginHooks2.default.getSingleton().register('afterPaste');
  35838. _pluginHooks2.default.getSingleton().register('beforeCopy');
  35839. _pluginHooks2.default.getSingleton().register('afterCopy');
  35840. var ROWS_LIMIT = 1000;
  35841. var COLUMNS_LIMIT = 1000;
  35842. var privatePool = new WeakMap();
  35843. /**
  35844. * @description
  35845. * This plugin enables the copy/paste functionality in the Handsontable.
  35846. *
  35847. * @example
  35848. * ```js
  35849. * ...
  35850. * copyPaste: true,
  35851. * ...
  35852. * ```
  35853. * @class CopyPaste
  35854. * @plugin CopyPaste
  35855. */
  35856. var CopyPaste = function (_BasePlugin) {
  35857. _inherits(CopyPaste, _BasePlugin);
  35858. function CopyPaste(hotInstance) {
  35859. _classCallCheck(this, CopyPaste);
  35860. /**
  35861. * Event manager
  35862. *
  35863. * @type {EventManager}
  35864. */
  35865. var _this = _possibleConstructorReturn(this, (CopyPaste.__proto__ || Object.getPrototypeOf(CopyPaste)).call(this, hotInstance));
  35866. _this.eventManager = new _eventManager2.default(_this);
  35867. /**
  35868. * Maximum number of columns than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  35869. *
  35870. * @private
  35871. * @type {Number}
  35872. * @default 1000
  35873. */
  35874. _this.columnsLimit = COLUMNS_LIMIT;
  35875. /**
  35876. * Ranges of the cells coordinates, which should be used to copy/cut/paste actions.
  35877. *
  35878. * @private
  35879. * @type {Array}
  35880. */
  35881. _this.copyableRanges = [];
  35882. /**
  35883. * Defines paste (<kbd>CTRL</kbd> + <kbd>V</kbd>) behavior.
  35884. * * Default value `"overwrite"` will paste clipboard value over current selection.
  35885. * * When set to `"shift_down"`, clipboard data will be pasted in place of current selection, while all selected cells are moved down.
  35886. * * When set to `"shift_right"`, clipboard data will be pasted in place of current selection, while all selected cells are moved right.
  35887. *
  35888. * @private
  35889. * @type {String}
  35890. * @default 'overwrite'
  35891. */
  35892. _this.pasteMode = 'overwrite';
  35893. /**
  35894. * Maximum number of rows than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  35895. *
  35896. * @private
  35897. * @type {Number}
  35898. * @default 1000
  35899. */
  35900. _this.rowsLimit = ROWS_LIMIT;
  35901. /**
  35902. * The `textarea` element which is necessary to process copying, cutting off and pasting.
  35903. *
  35904. * @private
  35905. * @type {HTMLElement}
  35906. * @default undefined
  35907. */
  35908. _this.textarea = void 0;
  35909. privatePool.set(_this, {
  35910. isTriggeredByPaste: false
  35911. });
  35912. return _this;
  35913. }
  35914. /**
  35915. * Check if plugin is enabled.
  35916. *
  35917. * @returns {Boolean}
  35918. */
  35919. _createClass(CopyPaste, [{
  35920. key: 'isEnabled',
  35921. value: function isEnabled() {
  35922. return !!this.hot.getSettings().copyPaste;
  35923. }
  35924. /**
  35925. * Enable the plugin.
  35926. */
  35927. }, {
  35928. key: 'enablePlugin',
  35929. value: function enablePlugin() {
  35930. var _this2 = this;
  35931. if (this.enabled) {
  35932. return;
  35933. }
  35934. var settings = this.hot.getSettings();
  35935. this.textarea = _textarea2.default.getSingleton();
  35936. if (_typeof(settings.copyPaste) === 'object') {
  35937. this.pasteMode = settings.copyPaste.pasteMode || this.pasteMode;
  35938. this.rowsLimit = settings.copyPaste.rowsLimit || this.rowsLimit;
  35939. this.columnsLimit = settings.copyPaste.columnsLimit || this.columnsLimit;
  35940. }
  35941. this.addHook('afterContextMenuDefaultOptions', function (options) {
  35942. return _this2.onAfterContextMenuDefaultOptions(options);
  35943. });
  35944. this.addHook('beforeKeyDown', function (event) {
  35945. return _this2.onBeforeKeyDown(event);
  35946. });
  35947. // this.addHook('beforeOnCellMouseDown', () => this.onBeforeOnCellMouseDown());
  35948. this.registerEvents();
  35949. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'enablePlugin', this).call(this);
  35950. }
  35951. /**
  35952. * Updates the plugin to use the latest options you have specified.
  35953. */
  35954. }, {
  35955. key: 'updatePlugin',
  35956. value: function updatePlugin() {
  35957. this.disablePlugin();
  35958. this.enablePlugin();
  35959. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'updatePlugin', this).call(this);
  35960. }
  35961. /**
  35962. * Disable plugin for this Handsontable instance.
  35963. */
  35964. }, {
  35965. key: 'disablePlugin',
  35966. value: function disablePlugin() {
  35967. if (this.textarea) {
  35968. this.textarea.destroy();
  35969. }
  35970. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'disablePlugin', this).call(this);
  35971. }
  35972. /**
  35973. * Prepares copyable text in the invisible textarea.
  35974. *
  35975. * @function setCopyable
  35976. * @memberof CopyPaste#
  35977. */
  35978. }, {
  35979. key: 'setCopyableText',
  35980. value: function setCopyableText() {
  35981. var selRange = this.hot.getSelectedRange();
  35982. var topLeft = selRange.getTopLeftCorner();
  35983. var bottomRight = selRange.getBottomRightCorner();
  35984. var startRow = topLeft.row;
  35985. var startCol = topLeft.col;
  35986. var endRow = bottomRight.row;
  35987. var endCol = bottomRight.col;
  35988. var finalEndRow = Math.min(endRow, startRow + this.rowsLimit - 1);
  35989. var finalEndCol = Math.min(endCol, startCol + this.columnsLimit - 1);
  35990. this.copyableRanges.length = 0;
  35991. this.copyableRanges.push({
  35992. startRow: startRow,
  35993. startCol: startCol,
  35994. endRow: finalEndRow,
  35995. endCol: finalEndCol
  35996. });
  35997. this.copyableRanges = this.hot.runHooks('modifyCopyableRange', this.copyableRanges);
  35998. var copyableData = this.getRangedCopyableData(this.copyableRanges);
  35999. this.textarea.setValue(copyableData);
  36000. if (endRow !== finalEndRow || endCol !== finalEndCol) {
  36001. this.hot.runHooks('afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, this.rowsLimit, this.columnsLimit);
  36002. }
  36003. }
  36004. /**
  36005. * Create copyable text releated to range objects.
  36006. *
  36007. * @since 0.19.0
  36008. * @param {Array} ranges Array of Objects with properties `startRow`, `endRow`, `startCol` and `endCol`.
  36009. * @returns {String} Returns string which will be copied into clipboard.
  36010. */
  36011. }, {
  36012. key: 'getRangedCopyableData',
  36013. value: function getRangedCopyableData(ranges) {
  36014. var _this3 = this;
  36015. var dataSet = [];
  36016. var copyableRows = [];
  36017. var copyableColumns = [];
  36018. // Count all copyable rows and columns
  36019. (0, _array.arrayEach)(ranges, function (range) {
  36020. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  36021. if (copyableRows.indexOf(row) === -1) {
  36022. copyableRows.push(row);
  36023. }
  36024. });
  36025. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  36026. if (copyableColumns.indexOf(column) === -1) {
  36027. copyableColumns.push(column);
  36028. }
  36029. });
  36030. });
  36031. // Concat all rows and columns data defined in ranges into one copyable string
  36032. (0, _array.arrayEach)(copyableRows, function (row) {
  36033. var rowSet = [];
  36034. (0, _array.arrayEach)(copyableColumns, function (column) {
  36035. rowSet.push(_this3.hot.getCopyableData(row, column));
  36036. });
  36037. dataSet.push(rowSet);
  36038. });
  36039. return _SheetClip2.default.stringify(dataSet);
  36040. }
  36041. /**
  36042. * Create copyable text releated to range objects.
  36043. *
  36044. * @since 0.31.1
  36045. * @param {Array} ranges Array of Objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
  36046. * @returns {Array} Returns array of arrays which will be copied into clipboard.
  36047. */
  36048. }, {
  36049. key: 'getRangedData',
  36050. value: function getRangedData(ranges) {
  36051. var _this4 = this;
  36052. var dataSet = [];
  36053. var copyableRows = [];
  36054. var copyableColumns = [];
  36055. // Count all copyable rows and columns
  36056. (0, _array.arrayEach)(ranges, function (range) {
  36057. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  36058. if (copyableRows.indexOf(row) === -1) {
  36059. copyableRows.push(row);
  36060. }
  36061. });
  36062. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  36063. if (copyableColumns.indexOf(column) === -1) {
  36064. copyableColumns.push(column);
  36065. }
  36066. });
  36067. });
  36068. // Concat all rows and columns data defined in ranges into one copyable string
  36069. (0, _array.arrayEach)(copyableRows, function (row) {
  36070. var rowSet = [];
  36071. (0, _array.arrayEach)(copyableColumns, function (column) {
  36072. rowSet.push(_this4.hot.getCopyableData(row, column));
  36073. });
  36074. dataSet.push(rowSet);
  36075. });
  36076. return dataSet;
  36077. }
  36078. /**
  36079. * Copy action.
  36080. *
  36081. * @param {Boolean} isTriggeredByClick Flag to determine that copy action was executed by the mouse click.
  36082. */
  36083. }, {
  36084. key: 'copy',
  36085. value: function copy(isTriggeredByClick) {
  36086. var rangedData = this.getRangedData(this.copyableRanges);
  36087. var allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges);
  36088. if (allowCopying) {
  36089. this.textarea.setValue(_SheetClip2.default.stringify(rangedData));
  36090. this.textarea.select();
  36091. if (isTriggeredByClick) {
  36092. document.execCommand('copy');
  36093. }
  36094. this.hot.runHooks('afterCopy', rangedData, this.copyableRanges);
  36095. } else {
  36096. this.textarea.setValue('');
  36097. }
  36098. }
  36099. /**
  36100. * Cut action.
  36101. *
  36102. * @param {Boolean} isTriggeredByClick Flag to determine that cut action was executed by the mouse click.
  36103. */
  36104. }, {
  36105. key: 'cut',
  36106. value: function cut(isTriggeredByClick) {
  36107. var rangedData = this.getRangedData(this.copyableRanges);
  36108. var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
  36109. if (allowCuttingOut) {
  36110. this.textarea.setValue(_SheetClip2.default.stringify(rangedData));
  36111. this.hot.selection.empty();
  36112. this.textarea.select();
  36113. if (isTriggeredByClick) {
  36114. document.execCommand('cut');
  36115. }
  36116. this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
  36117. } else {
  36118. this.textarea.setValue('');
  36119. }
  36120. }
  36121. /**
  36122. * Simulated paste action.
  36123. *
  36124. * @param {String} [value=''] New value, which should be `pasted`.
  36125. */
  36126. }, {
  36127. key: 'paste',
  36128. value: function paste() {
  36129. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  36130. this.textarea.setValue(value);
  36131. this.onPaste();
  36132. this.onInput();
  36133. }
  36134. /**
  36135. * Register event listeners.
  36136. *
  36137. * @private
  36138. */
  36139. }, {
  36140. key: 'registerEvents',
  36141. value: function registerEvents() {
  36142. var _this5 = this;
  36143. this.eventManager.addEventListener(this.textarea.element, 'paste', function (event) {
  36144. return _this5.onPaste(event);
  36145. });
  36146. this.eventManager.addEventListener(this.textarea.element, 'input', function (event) {
  36147. return _this5.onInput(event);
  36148. });
  36149. }
  36150. /**
  36151. * Trigger to make possible observe `onInput` in textarea.
  36152. *
  36153. * @private
  36154. */
  36155. }, {
  36156. key: 'triggerPaste',
  36157. value: function triggerPaste() {
  36158. this.textarea.select();
  36159. this.onPaste();
  36160. }
  36161. /**
  36162. * `paste` event callback on textarea element.
  36163. *
  36164. * @private
  36165. */
  36166. }, {
  36167. key: 'onPaste',
  36168. value: function onPaste() {
  36169. var priv = privatePool.get(this);
  36170. priv.isTriggeredByPaste = true;
  36171. }
  36172. /**
  36173. * `input` event callback is called after `paste` event callback.
  36174. *
  36175. * @private
  36176. */
  36177. }, {
  36178. key: 'onInput',
  36179. value: function onInput() {
  36180. var _this6 = this;
  36181. var priv = privatePool.get(this);
  36182. if (!this.hot.isListening() || !priv.isTriggeredByPaste) {
  36183. return;
  36184. }
  36185. priv.isTriggeredByPaste = false;
  36186. var input = void 0,
  36187. inputArray = void 0,
  36188. selected = void 0,
  36189. coordsFrom = void 0,
  36190. coordsTo = void 0,
  36191. cellRange = void 0,
  36192. topLeftCorner = void 0,
  36193. bottomRightCorner = void 0,
  36194. areaStart = void 0,
  36195. areaEnd = void 0;
  36196. input = this.textarea.getValue();
  36197. inputArray = _SheetClip2.default.parse(input);
  36198. var allowPasting = !!this.hot.runHooks('beforePaste', inputArray, this.copyableRanges);
  36199. if (!allowPasting) {
  36200. return;
  36201. }
  36202. selected = this.hot.getSelected();
  36203. coordsFrom = new _src.CellCoords(selected[0], selected[1]);
  36204. coordsTo = new _src.CellCoords(selected[2], selected[3]);
  36205. cellRange = new _src.CellRange(coordsFrom, coordsFrom, coordsTo);
  36206. topLeftCorner = cellRange.getTopLeftCorner();
  36207. bottomRightCorner = cellRange.getBottomRightCorner();
  36208. areaStart = topLeftCorner;
  36209. areaEnd = new _src.CellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
  36210. var isSelRowAreaCoverInputValue = coordsTo.row - coordsFrom.row >= inputArray.length - 1;
  36211. var isSelColAreaCoverInputValue = coordsTo.col - coordsFrom.col >= inputArray[0].length - 1;
  36212. this.hot.addHookOnce('afterChange', function (changes, source) {
  36213. var changesLength = changes ? changes.length : 0;
  36214. if (changesLength) {
  36215. var offset = { row: 0, col: 0 };
  36216. var highestColumnIndex = -1;
  36217. (0, _array.arrayEach)(changes, function (change, index) {
  36218. var nextChange = changesLength > index + 1 ? changes[index + 1] : null;
  36219. if (nextChange) {
  36220. if (!isSelRowAreaCoverInputValue) {
  36221. offset.row += Math.max(nextChange[0] - change[0] - 1, 0);
  36222. }
  36223. if (!isSelColAreaCoverInputValue && change[1] > highestColumnIndex) {
  36224. highestColumnIndex = change[1];
  36225. offset.col += Math.max(nextChange[1] - change[1] - 1, 0);
  36226. }
  36227. }
  36228. });
  36229. _this6.hot.selectCell(areaStart.row, areaStart.col, areaEnd.row + offset.row, areaEnd.col + offset.col);
  36230. }
  36231. });
  36232. this.hot.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'CopyPaste.paste', this.pasteMode);
  36233. this.hot.runHooks('afterPaste', inputArray, this.copyableRanges);
  36234. }
  36235. /**
  36236. * Add copy, cut and paste options to the Context Menu.
  36237. *
  36238. * @private
  36239. * @param {Object} options Contains default added options of the Context Menu.
  36240. */
  36241. }, {
  36242. key: 'onAfterContextMenuDefaultOptions',
  36243. value: function onAfterContextMenuDefaultOptions(options) {
  36244. options.items.push({
  36245. name: '---------'
  36246. }, (0, _copy2.default)(this), (0, _cut2.default)(this));
  36247. }
  36248. /**
  36249. * beforeKeyDown callback.
  36250. *
  36251. * @private
  36252. * @param {Event} event
  36253. */
  36254. }, {
  36255. key: 'onBeforeKeyDown',
  36256. value: function onBeforeKeyDown(event) {
  36257. var _this7 = this;
  36258. if (!this.hot.getSelected()) {
  36259. return;
  36260. }
  36261. if (this.hot.getActiveEditor() && this.hot.getActiveEditor().isOpened()) {
  36262. return;
  36263. }
  36264. if ((0, _event.isImmediatePropagationStopped)(event)) {
  36265. return;
  36266. }
  36267. if (!this.textarea.isActive() && (0, _element.getSelectionText)()) {
  36268. return;
  36269. }
  36270. if ((0, _unicode.isCtrlKey)(event.keyCode)) {
  36271. // When fragmentSelection is enabled and some text is selected then don't blur selection calling 'setCopyableText'
  36272. if (this.hot.getSettings().fragmentSelection && (0, _element.getSelectionText)()) {
  36273. return;
  36274. }
  36275. // when CTRL is pressed, prepare selectable text in textarea
  36276. this.setCopyableText();
  36277. (0, _event.stopImmediatePropagation)(event);
  36278. return;
  36279. }
  36280. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  36281. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  36282. if (ctrlDown) {
  36283. if (event.keyCode == _unicode.KEY_CODES.A) {
  36284. setTimeout(function () {
  36285. _this7.setCopyableText();
  36286. }, 0);
  36287. }
  36288. if (event.keyCode == _unicode.KEY_CODES.X) {
  36289. this.cut();
  36290. }
  36291. if (event.keyCode == _unicode.KEY_CODES.C) {
  36292. this.copy();
  36293. }
  36294. if (event.keyCode == _unicode.KEY_CODES.V) {
  36295. this.triggerPaste();
  36296. }
  36297. }
  36298. }
  36299. /**
  36300. * Destroy plugin instance.
  36301. */
  36302. }, {
  36303. key: 'destroy',
  36304. value: function destroy() {
  36305. if (this.textarea) {
  36306. this.textarea.destroy();
  36307. }
  36308. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'destroy', this).call(this);
  36309. }
  36310. }]);
  36311. return CopyPaste;
  36312. }(_base2.default);
  36313. (0, _plugins.registerPlugin)('CopyPaste', CopyPaste);
  36314. exports.default = CopyPaste;
  36315. /***/ }),
  36316. /* 352 */
  36317. /***/ (function(module, exports, __webpack_require__) {
  36318. "use strict";
  36319. exports.__esModule = true;
  36320. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  36321. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36322. /**
  36323. * @class Textarea
  36324. *
  36325. * @plugin CopyPaste
  36326. */
  36327. var Textarea = function () {
  36328. _createClass(Textarea, null, [{
  36329. key: 'getSingleton',
  36330. value: function getSingleton() {
  36331. globalSingleton.append();
  36332. return globalSingleton;
  36333. }
  36334. }]);
  36335. function Textarea() {
  36336. _classCallCheck(this, Textarea);
  36337. /**
  36338. * Main textarea element.
  36339. *
  36340. * @type {HTMLElement}
  36341. */
  36342. this.element = void 0;
  36343. /**
  36344. * Store information about append to the document.body.
  36345. *
  36346. * @type {Boolean}
  36347. */
  36348. this.isAppended = false;
  36349. /**
  36350. * Reference counter.
  36351. *
  36352. * @type {Number}
  36353. */
  36354. this.refCounter = 0;
  36355. }
  36356. /**
  36357. * Apends textarea element to the `body`
  36358. */
  36359. _createClass(Textarea, [{
  36360. key: 'append',
  36361. value: function append() {
  36362. if (this.hasBeenDestroyed()) {
  36363. this.create();
  36364. }
  36365. this.refCounter++;
  36366. if (!this.isAppended && document.body) {
  36367. if (document.body) {
  36368. this.isAppended = true;
  36369. document.body.appendChild(this.element);
  36370. }
  36371. }
  36372. }
  36373. /**
  36374. * Prepares textarea element with proper attributes.
  36375. */
  36376. }, {
  36377. key: 'create',
  36378. value: function create() {
  36379. this.element = document.createElement('textarea');
  36380. this.element.id = 'HandsontableCopyPaste';
  36381. this.element.className = 'copyPaste';
  36382. this.element.tabIndex = -1;
  36383. this.element.autocomplete = 'off';
  36384. this.element.wrap = 'off';
  36385. }
  36386. /**
  36387. * Deselects textarea element if is active.
  36388. */
  36389. }, {
  36390. key: 'deselect',
  36391. value: function deselect() {
  36392. if (this.element === document.activeElement) {
  36393. document.activeElement.blur();
  36394. }
  36395. }
  36396. /**
  36397. * Destroy instance
  36398. */
  36399. }, {
  36400. key: 'destroy',
  36401. value: function destroy() {
  36402. this.refCounter--;
  36403. this.refCounter = this.refCounter < 0 ? 0 : this.refCounter;
  36404. if (this.hasBeenDestroyed() && this.element && this.element.parentNode) {
  36405. this.element.parentNode.removeChild(this.element);
  36406. this.element = null;
  36407. this.isAppended = false;
  36408. }
  36409. }
  36410. /**
  36411. * Getter for the element.
  36412. *
  36413. * @returns {String}
  36414. */
  36415. }, {
  36416. key: 'getValue',
  36417. value: function getValue() {
  36418. return this.element.value;
  36419. }
  36420. /**
  36421. * Check if instance has been destroyed
  36422. *
  36423. * @returns {Boolean}
  36424. */
  36425. }, {
  36426. key: 'hasBeenDestroyed',
  36427. value: function hasBeenDestroyed() {
  36428. return this.refCounter < 1;
  36429. }
  36430. /**
  36431. * Check if the element is an active element in frame.
  36432. *
  36433. * @returns {Boolean}
  36434. */
  36435. }, {
  36436. key: 'isActive',
  36437. value: function isActive() {
  36438. return this.element === document.activeElement;
  36439. }
  36440. /**
  36441. * Sets focus on the element and select content.
  36442. */
  36443. }, {
  36444. key: 'select',
  36445. value: function select() {
  36446. this.element.focus();
  36447. this.element.select();
  36448. }
  36449. /**
  36450. * Setter for the element.
  36451. *
  36452. * @param {String} data Value which should be insert into the element.
  36453. */
  36454. }, {
  36455. key: 'setValue',
  36456. value: function setValue(data) {
  36457. this.element.value = data;
  36458. }
  36459. }]);
  36460. return Textarea;
  36461. }();
  36462. var globalSingleton = new Textarea();
  36463. exports.default = Textarea;
  36464. /***/ }),
  36465. /* 353 */
  36466. /***/ (function(module, exports, __webpack_require__) {
  36467. "use strict";
  36468. var _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; };
  36469. var _pluginHooks = __webpack_require__(8);
  36470. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  36471. var _plugins = __webpack_require__(5);
  36472. var _object = __webpack_require__(1);
  36473. var _src = __webpack_require__(11);
  36474. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36475. function CustomBorders() {}
  36476. /** *
  36477. * Current instance (table where borders should be placed)
  36478. */
  36479. var instance;
  36480. /**
  36481. * This plugin enables an option to apply custom borders through the context menu (configurable with context menu key `borders`).
  36482. *
  36483. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  36484. *
  36485. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for more examples.
  36486. *
  36487. * @example
  36488. * ```js
  36489. * ...
  36490. * customBorders: [
  36491. * {range: {
  36492. * from: {row: 1, col: 1},
  36493. * to: {row: 3, col: 4}},
  36494. * left: {},
  36495. * right: {},
  36496. * top: {},
  36497. * bottom: {}
  36498. * }
  36499. * ],
  36500. * ...
  36501. *
  36502. * // or
  36503. * ...
  36504. * customBorders: [
  36505. * {row: 2, col: 2, left: {width: 2, color: 'red'},
  36506. * right: {width: 1, color: 'green'}, top: '', bottom: ''}
  36507. * ],
  36508. * ...
  36509. * ```
  36510. * @private
  36511. * @class CustomBorders
  36512. * @plugin CustomBorders
  36513. */
  36514. /** *
  36515. * Check if plugin should be enabled.
  36516. */
  36517. var checkEnable = function checkEnable(customBorders) {
  36518. if (typeof customBorders === 'boolean') {
  36519. if (customBorders === true) {
  36520. return true;
  36521. }
  36522. }
  36523. if ((typeof customBorders === 'undefined' ? 'undefined' : _typeof(customBorders)) === 'object') {
  36524. if (customBorders.length > 0) {
  36525. return true;
  36526. }
  36527. }
  36528. return false;
  36529. };
  36530. /** *
  36531. * Initialize plugin.
  36532. */
  36533. var init = function init() {
  36534. if (checkEnable(this.getSettings().customBorders)) {
  36535. if (!this.customBorders) {
  36536. instance = this;
  36537. this.customBorders = new CustomBorders();
  36538. }
  36539. }
  36540. };
  36541. /** *
  36542. * Get index of border from the settings.
  36543. *
  36544. * @param {String} className
  36545. * @returns {Number}
  36546. */
  36547. var getSettingIndex = function getSettingIndex(className) {
  36548. for (var i = 0; i < instance.view.wt.selections.length; i++) {
  36549. if (instance.view.wt.selections[i].settings.className == className) {
  36550. return i;
  36551. }
  36552. }
  36553. return -1;
  36554. };
  36555. /** *
  36556. * Insert WalkontableSelection instance into Walkontable settings.
  36557. *
  36558. * @param border
  36559. */
  36560. var insertBorderIntoSettings = function insertBorderIntoSettings(border) {
  36561. var coordinates = {
  36562. row: border.row,
  36563. col: border.col
  36564. };
  36565. var selection = new _src.Selection(border, new _src.CellRange(coordinates, coordinates, coordinates));
  36566. var index = getSettingIndex(border.className);
  36567. if (index >= 0) {
  36568. instance.view.wt.selections[index] = selection;
  36569. } else {
  36570. instance.view.wt.selections.push(selection);
  36571. }
  36572. };
  36573. /** *
  36574. * Prepare borders from setting (single cell).
  36575. *
  36576. * @param {Number} row Visual row index.
  36577. * @param {Number} col Visual column index.
  36578. * @param borderObj
  36579. */
  36580. var prepareBorderFromCustomAdded = function prepareBorderFromCustomAdded(row, col, borderObj) {
  36581. var border = createEmptyBorders(row, col);
  36582. border = extendDefaultBorder(border, borderObj);
  36583. this.setCellMeta(row, col, 'borders', border);
  36584. insertBorderIntoSettings(border);
  36585. };
  36586. /** *
  36587. * Prepare borders from setting (object).
  36588. *
  36589. * @param {Object} rowObj
  36590. */
  36591. var prepareBorderFromCustomAddedRange = function prepareBorderFromCustomAddedRange(rowObj) {
  36592. var range = rowObj.range;
  36593. for (var row = range.from.row; row <= range.to.row; row++) {
  36594. for (var col = range.from.col; col <= range.to.col; col++) {
  36595. var border = createEmptyBorders(row, col);
  36596. var add = 0;
  36597. if (row == range.from.row) {
  36598. add++;
  36599. if ((0, _object.hasOwnProperty)(rowObj, 'top')) {
  36600. border.top = rowObj.top;
  36601. }
  36602. }
  36603. if (row == range.to.row) {
  36604. add++;
  36605. if ((0, _object.hasOwnProperty)(rowObj, 'bottom')) {
  36606. border.bottom = rowObj.bottom;
  36607. }
  36608. }
  36609. if (col == range.from.col) {
  36610. add++;
  36611. if ((0, _object.hasOwnProperty)(rowObj, 'left')) {
  36612. border.left = rowObj.left;
  36613. }
  36614. }
  36615. if (col == range.to.col) {
  36616. add++;
  36617. if ((0, _object.hasOwnProperty)(rowObj, 'right')) {
  36618. border.right = rowObj.right;
  36619. }
  36620. }
  36621. if (add > 0) {
  36622. this.setCellMeta(row, col, 'borders', border);
  36623. insertBorderIntoSettings(border);
  36624. }
  36625. }
  36626. }
  36627. };
  36628. /** *
  36629. * Create separated class name for borders for each cell.
  36630. *
  36631. * @param {Number} row Visual row index.
  36632. * @param {Number} col Visual column index.
  36633. * @returns {String}
  36634. */
  36635. var createClassName = function createClassName(row, col) {
  36636. return 'border_row' + row + 'col' + col;
  36637. };
  36638. /** *
  36639. * Create default single border for each position (top/right/bottom/left).
  36640. *
  36641. * @returns {Object} `{{width: number, color: string}}`
  36642. */
  36643. var createDefaultCustomBorder = function createDefaultCustomBorder() {
  36644. return {
  36645. width: 1,
  36646. color: '#000'
  36647. };
  36648. };
  36649. /** *
  36650. * Create default object for empty border.
  36651. *
  36652. * @returns {Object} `{{hide: boolean}}`
  36653. */
  36654. var createSingleEmptyBorder = function createSingleEmptyBorder() {
  36655. return {
  36656. hide: true
  36657. };
  36658. };
  36659. /** *
  36660. * Create default Handsontable border object.
  36661. *
  36662. * @returns {Object} `{{width: number, color: string, cornerVisible: boolean}}`
  36663. */
  36664. var createDefaultHtBorder = function createDefaultHtBorder() {
  36665. return {
  36666. width: 1,
  36667. color: '#000',
  36668. cornerVisible: false
  36669. };
  36670. };
  36671. /** *
  36672. * Prepare empty border for each cell with all custom borders hidden.
  36673. *
  36674. * @param {Number} row Visual row index.
  36675. * @param {Number} col Visual column index.
  36676. * @returns {Object} `{{className: *, border: *, row: *, col: *, top: {hide: boolean}, right: {hide: boolean}, bottom: {hide: boolean}, left: {hide: boolean}}}`
  36677. */
  36678. var createEmptyBorders = function createEmptyBorders(row, col) {
  36679. return {
  36680. className: createClassName(row, col),
  36681. border: createDefaultHtBorder(),
  36682. row: row,
  36683. col: col,
  36684. top: createSingleEmptyBorder(),
  36685. right: createSingleEmptyBorder(),
  36686. bottom: createSingleEmptyBorder(),
  36687. left: createSingleEmptyBorder()
  36688. };
  36689. };
  36690. var extendDefaultBorder = function extendDefaultBorder(defaultBorder, customBorder) {
  36691. if ((0, _object.hasOwnProperty)(customBorder, 'border')) {
  36692. defaultBorder.border = customBorder.border;
  36693. }
  36694. if ((0, _object.hasOwnProperty)(customBorder, 'top')) {
  36695. defaultBorder.top = customBorder.top;
  36696. }
  36697. if ((0, _object.hasOwnProperty)(customBorder, 'right')) {
  36698. defaultBorder.right = customBorder.right;
  36699. }
  36700. if ((0, _object.hasOwnProperty)(customBorder, 'bottom')) {
  36701. defaultBorder.bottom = customBorder.bottom;
  36702. }
  36703. if ((0, _object.hasOwnProperty)(customBorder, 'left')) {
  36704. defaultBorder.left = customBorder.left;
  36705. }
  36706. return defaultBorder;
  36707. };
  36708. /**
  36709. * Remove borders divs from DOM.
  36710. *
  36711. * @param borderClassName
  36712. */
  36713. var removeBordersFromDom = function removeBordersFromDom(borderClassName) {
  36714. var borders = document.querySelectorAll('.' + borderClassName);
  36715. for (var i = 0; i < borders.length; i++) {
  36716. if (borders[i]) {
  36717. if (borders[i].nodeName != 'TD') {
  36718. var parent = borders[i].parentNode;
  36719. if (parent.parentNode) {
  36720. parent.parentNode.removeChild(parent);
  36721. }
  36722. }
  36723. }
  36724. }
  36725. };
  36726. /** *
  36727. * Remove border (triggered from context menu).
  36728. *
  36729. * @param {Number} row Visual row index.
  36730. * @param {Number} col Visual column index.
  36731. */
  36732. var removeAllBorders = function removeAllBorders(row, col) {
  36733. var borderClassName = createClassName(row, col);
  36734. removeBordersFromDom(borderClassName);
  36735. this.removeCellMeta(row, col, 'borders');
  36736. };
  36737. /** *
  36738. * Set borders for each cell re. to border position
  36739. *
  36740. * @param row Visual row index.
  36741. * @param col Visual column index.
  36742. * @param place
  36743. * @param remove
  36744. */
  36745. var setBorder = function setBorder(row, col, place, remove) {
  36746. var bordersMeta = this.getCellMeta(row, col).borders;
  36747. if (!bordersMeta || bordersMeta.border == undefined) {
  36748. bordersMeta = createEmptyBorders(row, col);
  36749. }
  36750. if (remove) {
  36751. bordersMeta[place] = createSingleEmptyBorder();
  36752. } else {
  36753. bordersMeta[place] = createDefaultCustomBorder();
  36754. }
  36755. this.setCellMeta(row, col, 'borders', bordersMeta);
  36756. var borderClassName = createClassName(row, col);
  36757. removeBordersFromDom(borderClassName);
  36758. insertBorderIntoSettings(bordersMeta);
  36759. this.render();
  36760. };
  36761. /** *
  36762. * Prepare borders based on cell and border position
  36763. *
  36764. * @param range
  36765. * @param place
  36766. * @param remove
  36767. */
  36768. var prepareBorder = function prepareBorder(range, place, remove) {
  36769. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  36770. if (place == 'noBorders') {
  36771. removeAllBorders.call(this, range.from.row, range.from.col);
  36772. } else {
  36773. setBorder.call(this, range.from.row, range.from.col, place, remove);
  36774. }
  36775. } else {
  36776. switch (place) {
  36777. case 'noBorders':
  36778. for (var column = range.from.col; column <= range.to.col; column++) {
  36779. for (var row = range.from.row; row <= range.to.row; row++) {
  36780. removeAllBorders.call(this, row, column);
  36781. }
  36782. }
  36783. break;
  36784. case 'top':
  36785. for (var topCol = range.from.col; topCol <= range.to.col; topCol++) {
  36786. setBorder.call(this, range.from.row, topCol, place, remove);
  36787. }
  36788. break;
  36789. case 'right':
  36790. for (var rowRight = range.from.row; rowRight <= range.to.row; rowRight++) {
  36791. setBorder.call(this, rowRight, range.to.col, place);
  36792. }
  36793. break;
  36794. case 'bottom':
  36795. for (var bottomCol = range.from.col; bottomCol <= range.to.col; bottomCol++) {
  36796. setBorder.call(this, range.to.row, bottomCol, place);
  36797. }
  36798. break;
  36799. case 'left':
  36800. for (var rowLeft = range.from.row; rowLeft <= range.to.row; rowLeft++) {
  36801. setBorder.call(this, rowLeft, range.from.col, place);
  36802. }
  36803. break;
  36804. default:
  36805. break;
  36806. }
  36807. }
  36808. };
  36809. /** *
  36810. * Check if selection has border by className
  36811. *
  36812. * @param hot
  36813. * @param direction
  36814. */
  36815. var checkSelectionBorders = function checkSelectionBorders(hot, direction) {
  36816. var atLeastOneHasBorder = false;
  36817. hot.getSelectedRange().forAll(function (r, c) {
  36818. var metaBorders = hot.getCellMeta(r, c).borders;
  36819. if (metaBorders) {
  36820. if (direction) {
  36821. if (!(0, _object.hasOwnProperty)(metaBorders[direction], 'hide')) {
  36822. atLeastOneHasBorder = true;
  36823. return false; // breaks forAll
  36824. }
  36825. } else {
  36826. atLeastOneHasBorder = true;
  36827. return false; // breaks forAll
  36828. }
  36829. }
  36830. });
  36831. return atLeastOneHasBorder;
  36832. };
  36833. /** *
  36834. * Mark label in contextMenu as selected
  36835. *
  36836. * @param label
  36837. * @returns {string}
  36838. */
  36839. var markSelected = function markSelected(label) {
  36840. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label; // workaround for https://github.com/handsontable/handsontable/issues/1946
  36841. };
  36842. /** *
  36843. * Add border options to context menu
  36844. *
  36845. * @param defaultOptions
  36846. */
  36847. var addBordersOptionsToContextMenu = function addBordersOptionsToContextMenu(defaultOptions) {
  36848. if (!this.getSettings().customBorders) {
  36849. return;
  36850. }
  36851. defaultOptions.items.push({
  36852. name: '---------'
  36853. });
  36854. defaultOptions.items.push({
  36855. key: 'borders',
  36856. name: 'Borders',
  36857. disabled: function disabled() {
  36858. return this.selection.selectedHeader.corner;
  36859. },
  36860. submenu: {
  36861. items: [{
  36862. key: 'borders:top',
  36863. name: function name() {
  36864. var label = 'Top';
  36865. var hasBorder = checkSelectionBorders(this, 'top');
  36866. if (hasBorder) {
  36867. label = markSelected(label);
  36868. }
  36869. return label;
  36870. },
  36871. callback: function callback() {
  36872. var hasBorder = checkSelectionBorders(this, 'top');
  36873. prepareBorder.call(this, this.getSelectedRange(), 'top', hasBorder);
  36874. }
  36875. }, {
  36876. key: 'borders:right',
  36877. name: function name() {
  36878. var label = 'Right';
  36879. var hasBorder = checkSelectionBorders(this, 'right');
  36880. if (hasBorder) {
  36881. label = markSelected(label);
  36882. }
  36883. return label;
  36884. },
  36885. callback: function callback() {
  36886. var hasBorder = checkSelectionBorders(this, 'right');
  36887. prepareBorder.call(this, this.getSelectedRange(), 'right', hasBorder);
  36888. }
  36889. }, {
  36890. key: 'borders:bottom',
  36891. name: function name() {
  36892. var label = 'Bottom';
  36893. var hasBorder = checkSelectionBorders(this, 'bottom');
  36894. if (hasBorder) {
  36895. label = markSelected(label);
  36896. }
  36897. return label;
  36898. },
  36899. callback: function callback() {
  36900. var hasBorder = checkSelectionBorders(this, 'bottom');
  36901. prepareBorder.call(this, this.getSelectedRange(), 'bottom', hasBorder);
  36902. }
  36903. }, {
  36904. key: 'borders:left',
  36905. name: function name() {
  36906. var label = 'Left';
  36907. var hasBorder = checkSelectionBorders(this, 'left');
  36908. if (hasBorder) {
  36909. label = markSelected(label);
  36910. }
  36911. return label;
  36912. },
  36913. callback: function callback() {
  36914. var hasBorder = checkSelectionBorders(this, 'left');
  36915. prepareBorder.call(this, this.getSelectedRange(), 'left', hasBorder);
  36916. }
  36917. }, {
  36918. key: 'borders:no_borders',
  36919. name: 'Remove border(s)',
  36920. callback: function callback() {
  36921. prepareBorder.call(this, this.getSelectedRange(), 'noBorders');
  36922. },
  36923. disabled: function disabled() {
  36924. return !checkSelectionBorders(this);
  36925. }
  36926. }]
  36927. }
  36928. });
  36929. };
  36930. _pluginHooks2.default.getSingleton().add('beforeInit', init);
  36931. _pluginHooks2.default.getSingleton().add('afterContextMenuDefaultOptions', addBordersOptionsToContextMenu);
  36932. _pluginHooks2.default.getSingleton().add('afterInit', function () {
  36933. var customBorders = this.getSettings().customBorders;
  36934. if (customBorders) {
  36935. for (var i = 0; i < customBorders.length; i++) {
  36936. if (customBorders[i].range) {
  36937. prepareBorderFromCustomAddedRange.call(this, customBorders[i]);
  36938. } else {
  36939. prepareBorderFromCustomAdded.call(this, customBorders[i].row, customBorders[i].col, customBorders[i]);
  36940. }
  36941. }
  36942. this.render();
  36943. this.view.wt.draw(true);
  36944. }
  36945. });
  36946. /***/ }),
  36947. /* 354 */
  36948. /***/ (function(module, exports, __webpack_require__) {
  36949. "use strict";
  36950. exports.__esModule = true;
  36951. var _pluginHooks = __webpack_require__(8);
  36952. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  36953. var _eventManager = __webpack_require__(4);
  36954. var _eventManager2 = _interopRequireDefault(_eventManager);
  36955. var _plugins = __webpack_require__(5);
  36956. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36957. /**
  36958. * @description
  36959. * Plugin used to scroll Handsontable by selecting a cell and dragging outside of the visible viewport.
  36960. *
  36961. * @private
  36962. * @class DragToScroll
  36963. * @plugin DragToScroll
  36964. */
  36965. function DragToScroll() {
  36966. this.boundaries = null;
  36967. this.callback = null;
  36968. }
  36969. /**
  36970. * @param boundaries {Object} compatible with getBoundingClientRect
  36971. */
  36972. DragToScroll.prototype.setBoundaries = function (boundaries) {
  36973. this.boundaries = boundaries;
  36974. };
  36975. /**
  36976. * @param callback {Function}
  36977. */
  36978. DragToScroll.prototype.setCallback = function (callback) {
  36979. this.callback = callback;
  36980. };
  36981. /**
  36982. * Check if mouse position (x, y) is outside of the viewport
  36983. * @param x
  36984. * @param y
  36985. */
  36986. DragToScroll.prototype.check = function (x, y) {
  36987. var diffX = 0;
  36988. var diffY = 0;
  36989. if (y < this.boundaries.top) {
  36990. // y is less than top
  36991. diffY = y - this.boundaries.top;
  36992. } else if (y > this.boundaries.bottom) {
  36993. // y is more than bottom
  36994. diffY = y - this.boundaries.bottom;
  36995. }
  36996. if (x < this.boundaries.left) {
  36997. // x is less than left
  36998. diffX = x - this.boundaries.left;
  36999. } else if (x > this.boundaries.right) {
  37000. // x is more than right
  37001. diffX = x - this.boundaries.right;
  37002. }
  37003. this.callback(diffX, diffY);
  37004. };
  37005. var dragToScroll;
  37006. var instance;
  37007. var setupListening = function setupListening(instance) {
  37008. instance.dragToScrollListening = false;
  37009. var scrollHandler = instance.view.wt.wtTable.holder; // native scroll
  37010. dragToScroll = new DragToScroll();
  37011. if (scrollHandler === window) {
  37012. // not much we can do currently
  37013. return;
  37014. }
  37015. dragToScroll.setBoundaries(scrollHandler.getBoundingClientRect());
  37016. dragToScroll.setCallback(function (scrollX, scrollY) {
  37017. if (scrollX < 0) {
  37018. scrollHandler.scrollLeft -= 50;
  37019. } else if (scrollX > 0) {
  37020. scrollHandler.scrollLeft += 50;
  37021. }
  37022. if (scrollY < 0) {
  37023. scrollHandler.scrollTop -= 20;
  37024. } else if (scrollY > 0) {
  37025. scrollHandler.scrollTop += 20;
  37026. }
  37027. });
  37028. instance.dragToScrollListening = true;
  37029. };
  37030. _pluginHooks2.default.getSingleton().add('afterInit', function () {
  37031. var instance = this;
  37032. var eventManager = new _eventManager2.default(this);
  37033. eventManager.addEventListener(document, 'mouseup', function () {
  37034. instance.dragToScrollListening = false;
  37035. });
  37036. eventManager.addEventListener(document, 'mousemove', function (event) {
  37037. if (instance.dragToScrollListening) {
  37038. dragToScroll.check(event.clientX, event.clientY);
  37039. }
  37040. });
  37041. });
  37042. _pluginHooks2.default.getSingleton().add('afterDestroy', function () {
  37043. new _eventManager2.default(this).clear();
  37044. });
  37045. _pluginHooks2.default.getSingleton().add('afterOnCellMouseDown', function () {
  37046. setupListening(this);
  37047. });
  37048. _pluginHooks2.default.getSingleton().add('afterOnCellCornerMouseDown', function () {
  37049. setupListening(this);
  37050. });
  37051. exports.default = DragToScroll;
  37052. /***/ }),
  37053. /* 355 */
  37054. /***/ (function(module, exports, __webpack_require__) {
  37055. "use strict";
  37056. exports.__esModule = true;
  37057. exports.default = freezeColumnItem;
  37058. function freezeColumnItem(manualColumnFreezePlugin) {
  37059. return {
  37060. key: 'freeze_column',
  37061. name: 'Freeze this column',
  37062. callback: function callback() {
  37063. var selectedColumn = this.getSelectedRange().from.col;
  37064. manualColumnFreezePlugin.freezeColumn(selectedColumn);
  37065. this.render();
  37066. this.view.wt.wtOverlays.adjustElementsSize(true);
  37067. },
  37068. hidden: function hidden() {
  37069. var selection = this.getSelectedRange();
  37070. var hide = false;
  37071. if (selection === void 0) {
  37072. hide = true;
  37073. } else if (selection.from.col !== selection.to.col || selection.from.col <= this.getSettings().fixedColumnsLeft - 1) {
  37074. hide = true;
  37075. }
  37076. return hide;
  37077. }
  37078. };
  37079. }
  37080. /***/ }),
  37081. /* 356 */
  37082. /***/ (function(module, exports, __webpack_require__) {
  37083. "use strict";
  37084. exports.__esModule = true;
  37085. exports.default = unfreezeColumnItem;
  37086. function unfreezeColumnItem(manualColumnFreezePlugin) {
  37087. return {
  37088. key: 'unfreeze_column',
  37089. name: 'Unfreeze this column',
  37090. callback: function callback() {
  37091. var selectedColumn = this.getSelectedRange().from.col;
  37092. manualColumnFreezePlugin.unfreezeColumn(selectedColumn);
  37093. this.render();
  37094. this.view.wt.wtOverlays.adjustElementsSize(true);
  37095. },
  37096. hidden: function hidden() {
  37097. var selection = this.getSelectedRange();
  37098. var hide = false;
  37099. if (selection === void 0) {
  37100. hide = true;
  37101. } else if (selection.from.col !== selection.to.col || selection.from.col >= this.getSettings().fixedColumnsLeft) {
  37102. hide = true;
  37103. }
  37104. return hide;
  37105. }
  37106. };
  37107. }
  37108. /***/ }),
  37109. /* 357 */
  37110. /***/ (function(module, exports, __webpack_require__) {
  37111. "use strict";
  37112. exports.__esModule = true;
  37113. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  37114. var _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); } };
  37115. var _base = __webpack_require__(12);
  37116. var _base2 = _interopRequireDefault(_base);
  37117. var _plugins = __webpack_require__(5);
  37118. var _array = __webpack_require__(2);
  37119. var _freezeColumn = __webpack_require__(355);
  37120. var _freezeColumn2 = _interopRequireDefault(_freezeColumn);
  37121. var _unfreezeColumn = __webpack_require__(356);
  37122. var _unfreezeColumn2 = _interopRequireDefault(_unfreezeColumn);
  37123. __webpack_require__(415);
  37124. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37125. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37126. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  37127. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  37128. var privatePool = new WeakMap();
  37129. /**
  37130. * This plugin allows to manually "freeze" and "unfreeze" a column using an entry in the Context Menu.
  37131. * You can turn it on by setting a `manualColumnFreeze` property to `true`.
  37132. *
  37133. * @plugin ManualColumnFreeze
  37134. * @dependencies ManualColumnMove
  37135. */
  37136. var ManualColumnFreeze = function (_BasePlugin) {
  37137. _inherits(ManualColumnFreeze, _BasePlugin);
  37138. function ManualColumnFreeze(hotInstance) {
  37139. _classCallCheck(this, ManualColumnFreeze);
  37140. var _this = _possibleConstructorReturn(this, (ManualColumnFreeze.__proto__ || Object.getPrototypeOf(ManualColumnFreeze)).call(this, hotInstance));
  37141. privatePool.set(_this, {
  37142. moveByFreeze: false,
  37143. afterFirstUse: false
  37144. });
  37145. /**
  37146. * Original column positions
  37147. *
  37148. * @type {Array}
  37149. */
  37150. _this.frozenColumnsBasePositions = [];
  37151. /**
  37152. * Reference to the `ManualColumnMove` plugin.
  37153. */
  37154. _this.manualColumnMovePlugin = void 0;
  37155. return _this;
  37156. }
  37157. /**
  37158. * Check if the plugin is enabled in the Handsontable settings.
  37159. *
  37160. * @returns {Boolean}
  37161. */
  37162. _createClass(ManualColumnFreeze, [{
  37163. key: 'isEnabled',
  37164. value: function isEnabled() {
  37165. return !!this.hot.getSettings().manualColumnFreeze;
  37166. }
  37167. /**
  37168. * Enable plugin for this Handsontable instance.
  37169. */
  37170. }, {
  37171. key: 'enablePlugin',
  37172. value: function enablePlugin() {
  37173. var _this2 = this;
  37174. if (this.enabled) {
  37175. return;
  37176. }
  37177. this.addHook('afterContextMenuDefaultOptions', function (options) {
  37178. return _this2.addContextMenuEntry(options);
  37179. });
  37180. this.addHook('afterInit', function () {
  37181. return _this2.onAfterInit();
  37182. });
  37183. this.addHook('beforeColumnMove', function (rows, target) {
  37184. return _this2.onBeforeColumnMove(rows, target);
  37185. });
  37186. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'enablePlugin', this).call(this);
  37187. }
  37188. /**
  37189. * Disable plugin for this Handsontable instance.
  37190. */
  37191. }, {
  37192. key: 'disablePlugin',
  37193. value: function disablePlugin() {
  37194. var priv = privatePool.get(this);
  37195. priv.afterFirstUse = false;
  37196. priv.moveByFreeze = false;
  37197. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'disablePlugin', this).call(this);
  37198. }
  37199. /**
  37200. * Updates the plugin to use the latest options you have specified.
  37201. */
  37202. }, {
  37203. key: 'updatePlugin',
  37204. value: function updatePlugin() {
  37205. this.disablePlugin();
  37206. this.enablePlugin();
  37207. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'updatePlugin', this).call(this);
  37208. }
  37209. /**
  37210. * Freeze the given column (add it to fixed columns).
  37211. *
  37212. * @param {Number} column Visual column index.
  37213. */
  37214. }, {
  37215. key: 'freezeColumn',
  37216. value: function freezeColumn(column) {
  37217. var priv = privatePool.get(this);
  37218. var settings = this.hot.getSettings();
  37219. if (!priv.afterFirstUse) {
  37220. priv.afterFirstUse = true;
  37221. }
  37222. if (settings.fixedColumnsLeft === this.hot.countCols() || column <= settings.fixedColumnsLeft - 1) {
  37223. return; // already fixed
  37224. }
  37225. priv.moveByFreeze = true;
  37226. if (column !== this.getMovePlugin().columnsMapper.getValueByIndex(column)) {
  37227. this.frozenColumnsBasePositions[settings.fixedColumnsLeft] = column;
  37228. }
  37229. this.getMovePlugin().moveColumn(column, settings.fixedColumnsLeft++);
  37230. }
  37231. /**
  37232. * Unfreeze the given column (remove it from fixed columns and bring to it's previous position).
  37233. *
  37234. * @param {Number} column Visual column index.
  37235. */
  37236. }, {
  37237. key: 'unfreezeColumn',
  37238. value: function unfreezeColumn(column) {
  37239. var priv = privatePool.get(this);
  37240. var settings = this.hot.getSettings();
  37241. if (!priv.afterFirstUse) {
  37242. priv.afterFirstUse = true;
  37243. }
  37244. if (settings.fixedColumnsLeft <= 0 || column > settings.fixedColumnsLeft - 1) {
  37245. return; // not fixed
  37246. }
  37247. var returnCol = this.getBestColumnReturnPosition(column);
  37248. priv.moveByFreeze = true;
  37249. settings.fixedColumnsLeft--;
  37250. this.getMovePlugin().moveColumn(column, returnCol + 1);
  37251. }
  37252. /**
  37253. * Get the reference to the ManualColumnMove plugin.
  37254. *
  37255. * @private
  37256. * @returns {Object}
  37257. */
  37258. }, {
  37259. key: 'getMovePlugin',
  37260. value: function getMovePlugin() {
  37261. if (!this.manualColumnMovePlugin) {
  37262. this.manualColumnMovePlugin = this.hot.getPlugin('manualColumnMove');
  37263. }
  37264. return this.manualColumnMovePlugin;
  37265. }
  37266. /**
  37267. * Estimates the most fitting return position for unfrozen column.
  37268. *
  37269. * @private
  37270. * @param {Number} column Visual column index.
  37271. */
  37272. }, {
  37273. key: 'getBestColumnReturnPosition',
  37274. value: function getBestColumnReturnPosition(column) {
  37275. var movePlugin = this.getMovePlugin();
  37276. var settings = this.hot.getSettings();
  37277. var i = settings.fixedColumnsLeft;
  37278. var j = movePlugin.columnsMapper.getValueByIndex(i);
  37279. var initialCol = void 0;
  37280. if (this.frozenColumnsBasePositions[column] == null) {
  37281. initialCol = movePlugin.columnsMapper.getValueByIndex(column);
  37282. while (j < initialCol) {
  37283. i++;
  37284. j = movePlugin.columnsMapper.getValueByIndex(i);
  37285. }
  37286. } else {
  37287. initialCol = this.frozenColumnsBasePositions[column];
  37288. this.frozenColumnsBasePositions[column] = void 0;
  37289. while (j <= initialCol) {
  37290. i++;
  37291. j = movePlugin.columnsMapper.getValueByIndex(i);
  37292. }
  37293. i = j;
  37294. }
  37295. return i - 1;
  37296. }
  37297. /**
  37298. * Add the manualColumnFreeze context menu entries.
  37299. *
  37300. * @private
  37301. * @param {Object} options Context menu options.
  37302. */
  37303. }, {
  37304. key: 'addContextMenuEntry',
  37305. value: function addContextMenuEntry(options) {
  37306. options.items.push({ name: '---------' }, (0, _freezeColumn2.default)(this), (0, _unfreezeColumn2.default)(this));
  37307. }
  37308. /**
  37309. * Enabling `manualColumnMove` plugin on `afterInit` hook.
  37310. *
  37311. * @private
  37312. */
  37313. }, {
  37314. key: 'onAfterInit',
  37315. value: function onAfterInit() {
  37316. if (!this.getMovePlugin().isEnabled()) {
  37317. this.getMovePlugin().enablePlugin();
  37318. }
  37319. }
  37320. /**
  37321. * Prevent moving the rows from/to fixed area.
  37322. *
  37323. * @private
  37324. * @param {Array} rows
  37325. * @param {Number} target
  37326. */
  37327. }, {
  37328. key: 'onBeforeColumnMove',
  37329. value: function onBeforeColumnMove(rows, target) {
  37330. var priv = privatePool.get(this);
  37331. if (priv.afterFirstUse && !priv.moveByFreeze) {
  37332. var frozenLen = this.hot.getSettings().fixedColumnsLeft;
  37333. var disallowMoving = target < frozenLen;
  37334. if (!disallowMoving) {
  37335. (0, _array.arrayEach)(rows, function (value, index, array) {
  37336. if (value < frozenLen) {
  37337. disallowMoving = true;
  37338. return false;
  37339. }
  37340. });
  37341. }
  37342. if (disallowMoving) {
  37343. return false;
  37344. }
  37345. }
  37346. if (priv.moveByFreeze) {
  37347. priv.moveByFreeze = false;
  37348. }
  37349. }
  37350. /**
  37351. * Destroy plugin instance.
  37352. */
  37353. }, {
  37354. key: 'destroy',
  37355. value: function destroy() {
  37356. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'destroy', this).call(this);
  37357. }
  37358. }]);
  37359. return ManualColumnFreeze;
  37360. }(_base2.default);
  37361. (0, _plugins.registerPlugin)('manualColumnFreeze', ManualColumnFreeze);
  37362. exports.default = ManualColumnFreeze;
  37363. /***/ }),
  37364. /* 358 */
  37365. /***/ (function(module, exports, __webpack_require__) {
  37366. "use strict";
  37367. exports.__esModule = true;
  37368. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  37369. var _arrayMapper = __webpack_require__(265);
  37370. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  37371. var _array = __webpack_require__(2);
  37372. var _object = __webpack_require__(1);
  37373. var _number = __webpack_require__(6);
  37374. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37375. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37376. /**
  37377. * @class ColumnsMapper
  37378. * @plugin ManualColumnMove
  37379. */
  37380. var ColumnsMapper = function () {
  37381. function ColumnsMapper(manualColumnMove) {
  37382. _classCallCheck(this, ColumnsMapper);
  37383. /**
  37384. * Instance of ManualColumnMove plugin.
  37385. *
  37386. * @type {ManualColumnMove}
  37387. */
  37388. this.manualColumnMove = manualColumnMove;
  37389. }
  37390. /**
  37391. * Reset current map array and create new one.
  37392. *
  37393. * @param {Number} [length] Custom generated map length.
  37394. */
  37395. _createClass(ColumnsMapper, [{
  37396. key: 'createMap',
  37397. value: function createMap(length) {
  37398. var _this = this;
  37399. var originLength = length === void 0 ? this._arrayMap.length : length;
  37400. this._arrayMap.length = 0;
  37401. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  37402. _this._arrayMap[itemIndex] = itemIndex;
  37403. });
  37404. }
  37405. /**
  37406. * Destroy class.
  37407. */
  37408. }, {
  37409. key: 'destroy',
  37410. value: function destroy() {
  37411. this._arrayMap = null;
  37412. }
  37413. /**
  37414. * Moving elements in columnsMapper.
  37415. *
  37416. * @param {Number} from Column index to move.
  37417. * @param {Number} to Target index.
  37418. */
  37419. }, {
  37420. key: 'moveColumn',
  37421. value: function moveColumn(from, to) {
  37422. var indexToMove = this._arrayMap[from];
  37423. this._arrayMap[from] = null;
  37424. this._arrayMap.splice(to, 0, indexToMove);
  37425. }
  37426. /**
  37427. * Clearing arrayMap from `null` entries.
  37428. */
  37429. }, {
  37430. key: 'clearNull',
  37431. value: function clearNull() {
  37432. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  37433. return i !== null;
  37434. });
  37435. }
  37436. }]);
  37437. return ColumnsMapper;
  37438. }();
  37439. (0, _object.mixin)(ColumnsMapper, _arrayMapper2.default);
  37440. exports.default = ColumnsMapper;
  37441. /***/ }),
  37442. /* 359 */
  37443. /***/ (function(module, exports, __webpack_require__) {
  37444. "use strict";
  37445. exports.__esModule = true;
  37446. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  37447. var _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); } };
  37448. var _base = __webpack_require__(12);
  37449. var _base2 = _interopRequireDefault(_base);
  37450. var _pluginHooks = __webpack_require__(8);
  37451. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  37452. var _array = __webpack_require__(2);
  37453. var _element = __webpack_require__(0);
  37454. var _number = __webpack_require__(6);
  37455. var _eventManager = __webpack_require__(4);
  37456. var _eventManager2 = _interopRequireDefault(_eventManager);
  37457. var _plugins = __webpack_require__(5);
  37458. var _columnsMapper = __webpack_require__(358);
  37459. var _columnsMapper2 = _interopRequireDefault(_columnsMapper);
  37460. var _backlight = __webpack_require__(360);
  37461. var _backlight2 = _interopRequireDefault(_backlight);
  37462. var _guideline = __webpack_require__(361);
  37463. var _guideline2 = _interopRequireDefault(_guideline);
  37464. var _src = __webpack_require__(11);
  37465. __webpack_require__(416);
  37466. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37467. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37468. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  37469. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  37470. _pluginHooks2.default.getSingleton().register('beforeColumnMove');
  37471. _pluginHooks2.default.getSingleton().register('afterColumnMove');
  37472. _pluginHooks2.default.getSingleton().register('unmodifyCol');
  37473. var privatePool = new WeakMap();
  37474. var CSS_PLUGIN = 'ht__manualColumnMove';
  37475. var CSS_SHOW_UI = 'show-ui';
  37476. var CSS_ON_MOVING = 'on-moving--columns';
  37477. var CSS_AFTER_SELECTION = 'after-selection--columns';
  37478. /**
  37479. * @plugin ManualColumnMove
  37480. *
  37481. * @description
  37482. * This plugin allows to change columns order.
  37483. *
  37484. * API:
  37485. * - moveColumn - move single column to the new position.
  37486. * - moveColumns - move many columns (as an array of indexes) to the new position.
  37487. *
  37488. * If you want apply visual changes, you have to call manually the render() method on the instance of Handsontable.
  37489. *
  37490. * UI components:
  37491. * - backlight - highlight of selected columns.
  37492. * - guideline - line which shows where rows has been moved.
  37493. *
  37494. * @class ManualColumnMove
  37495. * @plugin ManualColumnMove
  37496. */
  37497. var ManualColumnMove = function (_BasePlugin) {
  37498. _inherits(ManualColumnMove, _BasePlugin);
  37499. function ManualColumnMove(hotInstance) {
  37500. _classCallCheck(this, ManualColumnMove);
  37501. /**
  37502. * Set up WeakMap of plugin to sharing private parameters;
  37503. */
  37504. var _this = _possibleConstructorReturn(this, (ManualColumnMove.__proto__ || Object.getPrototypeOf(ManualColumnMove)).call(this, hotInstance));
  37505. privatePool.set(_this, {
  37506. columnsToMove: [],
  37507. countCols: 0,
  37508. fixedColumns: 0,
  37509. pressed: void 0,
  37510. disallowMoving: void 0,
  37511. target: {
  37512. eventPageX: void 0,
  37513. coords: void 0,
  37514. TD: void 0,
  37515. col: void 0
  37516. }
  37517. });
  37518. /**
  37519. * List of last removed row indexes.
  37520. *
  37521. * @type {Array}
  37522. */
  37523. _this.removedColumns = [];
  37524. /**
  37525. * Object containing visual row indexes mapped to data source indexes.
  37526. *
  37527. * @type {RowsMapper}
  37528. */
  37529. _this.columnsMapper = new _columnsMapper2.default(_this);
  37530. /**
  37531. * Event Manager object.
  37532. *
  37533. * @type {Object}
  37534. */
  37535. _this.eventManager = new _eventManager2.default(_this);
  37536. /**
  37537. * Backlight UI object.
  37538. *
  37539. * @type {Object}
  37540. */
  37541. _this.backlight = new _backlight2.default(hotInstance);
  37542. /**
  37543. * Guideline UI object.
  37544. *
  37545. * @type {Object}
  37546. */
  37547. _this.guideline = new _guideline2.default(hotInstance);
  37548. return _this;
  37549. }
  37550. /**
  37551. * Check if plugin is enabled.
  37552. *
  37553. * @returns {Boolean}
  37554. */
  37555. _createClass(ManualColumnMove, [{
  37556. key: 'isEnabled',
  37557. value: function isEnabled() {
  37558. return !!this.hot.getSettings().manualColumnMove;
  37559. }
  37560. /**
  37561. * Enable the plugin.
  37562. */
  37563. }, {
  37564. key: 'enablePlugin',
  37565. value: function enablePlugin() {
  37566. var _this2 = this;
  37567. if (this.enabled) {
  37568. return;
  37569. }
  37570. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  37571. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  37572. });
  37573. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  37574. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  37575. });
  37576. this.addHook('afterScrollVertically', function () {
  37577. return _this2.onAfterScrollVertically();
  37578. });
  37579. this.addHook('modifyCol', function (row, source) {
  37580. return _this2.onModifyCol(row, source);
  37581. });
  37582. this.addHook('beforeRemoveCol', function (index, amount) {
  37583. return _this2.onBeforeRemoveCol(index, amount);
  37584. });
  37585. this.addHook('afterRemoveCol', function (index, amount) {
  37586. return _this2.onAfterRemoveCol(index, amount);
  37587. });
  37588. this.addHook('afterCreateCol', function (index, amount) {
  37589. return _this2.onAfterCreateCol(index, amount);
  37590. });
  37591. this.addHook('afterLoadData', function (firstTime) {
  37592. return _this2.onAfterLoadData(firstTime);
  37593. });
  37594. this.addHook('unmodifyCol', function (column) {
  37595. return _this2.onUnmodifyCol(column);
  37596. });
  37597. this.registerEvents();
  37598. // TODO: move adding plugin classname to BasePlugin.
  37599. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  37600. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'enablePlugin', this).call(this);
  37601. }
  37602. /**
  37603. * Updates the plugin to use the latest options you have specified.
  37604. */
  37605. }, {
  37606. key: 'updatePlugin',
  37607. value: function updatePlugin() {
  37608. this.disablePlugin();
  37609. this.enablePlugin();
  37610. this.onAfterPluginsInitialized();
  37611. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'updatePlugin', this).call(this);
  37612. }
  37613. /**
  37614. * Disable plugin for this Handsontable instance.
  37615. */
  37616. }, {
  37617. key: 'disablePlugin',
  37618. value: function disablePlugin() {
  37619. var pluginSettings = this.hot.getSettings().manualColumnMove;
  37620. if (Array.isArray(pluginSettings)) {
  37621. this.columnsMapper.clearMap();
  37622. }
  37623. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  37624. this.unregisterEvents();
  37625. this.backlight.destroy();
  37626. this.guideline.destroy();
  37627. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'disablePlugin', this).call(this);
  37628. }
  37629. /**
  37630. * Move a single column.
  37631. *
  37632. * @param {Number} column Visual column index to be moved.
  37633. * @param {Number} target Visual column index being a target for the moved column.
  37634. */
  37635. }, {
  37636. key: 'moveColumn',
  37637. value: function moveColumn(column, target) {
  37638. this.moveColumns([column], target);
  37639. }
  37640. /**
  37641. * Move multiple columns.
  37642. *
  37643. * @param {Array} columns Array of visual column indexes to be moved.
  37644. * @param {Number} target Visual column index being a target for the moved columns.
  37645. */
  37646. }, {
  37647. key: 'moveColumns',
  37648. value: function moveColumns(columns, target) {
  37649. var _this3 = this;
  37650. var priv = privatePool.get(this);
  37651. var beforeColumnHook = this.hot.runHooks('beforeColumnMove', columns, target);
  37652. priv.disallowMoving = !beforeColumnHook;
  37653. if (beforeColumnHook !== false) {
  37654. // first we need to rewrite an visual indexes to physical for save reference after move
  37655. (0, _array.arrayEach)(columns, function (column, index, array) {
  37656. array[index] = _this3.columnsMapper.getValueByIndex(column);
  37657. });
  37658. // next, when we have got an physical indexes, we can move columns
  37659. (0, _array.arrayEach)(columns, function (column, index) {
  37660. var actualPosition = _this3.columnsMapper.getIndexByValue(column);
  37661. if (actualPosition !== target) {
  37662. _this3.columnsMapper.moveColumn(actualPosition, target + index);
  37663. }
  37664. });
  37665. // after moving we have to clear columnsMapper from null entries
  37666. this.columnsMapper.clearNull();
  37667. }
  37668. this.hot.runHooks('afterColumnMove', columns, target);
  37669. }
  37670. /**
  37671. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  37672. * That means that changing the column order using the API won't correct the selection.
  37673. *
  37674. * @private
  37675. * @param {Number} startColumn Visual column index for the start of the selection.
  37676. * @param {Number} endColumn Visual column index for the end of the selection.
  37677. */
  37678. }, {
  37679. key: 'changeSelection',
  37680. value: function changeSelection(startColumn, endColumn) {
  37681. var selection = this.hot.selection;
  37682. var lastRowIndex = this.hot.countRows() - 1;
  37683. selection.setRangeStartOnly(new _src.CellCoords(0, startColumn));
  37684. selection.setRangeEnd(new _src.CellCoords(lastRowIndex, endColumn), false);
  37685. }
  37686. /**
  37687. * Get the sum of the widths of columns in the provided range.
  37688. *
  37689. * @private
  37690. * @param {Number} from Visual column index.
  37691. * @param {Number} to Visual column index.
  37692. * @returns {Number}
  37693. */
  37694. }, {
  37695. key: 'getColumnsWidth',
  37696. value: function getColumnsWidth(from, to) {
  37697. var width = 0;
  37698. for (var i = from; i < to; i++) {
  37699. var columnWidth = 0;
  37700. if (i < 0) {
  37701. columnWidth = this.hot.view.wt.wtTable.getColumnWidth(i) || 0;
  37702. } else {
  37703. columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0;
  37704. }
  37705. width += columnWidth;
  37706. }
  37707. return width;
  37708. }
  37709. /**
  37710. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  37711. *
  37712. * @private
  37713. */
  37714. }, {
  37715. key: 'initialSettings',
  37716. value: function initialSettings() {
  37717. var pluginSettings = this.hot.getSettings().manualColumnMove;
  37718. if (Array.isArray(pluginSettings)) {
  37719. this.moveColumns(pluginSettings, 0);
  37720. } else if (pluginSettings !== void 0) {
  37721. this.persistentStateLoad();
  37722. }
  37723. }
  37724. /**
  37725. * Check if the provided column is in the fixedColumnsLeft section.
  37726. *
  37727. * @private
  37728. * @param {Number} column Visual column index to check.
  37729. * @returns {Boolean}
  37730. */
  37731. }, {
  37732. key: 'isFixedColumnsLeft',
  37733. value: function isFixedColumnsLeft(column) {
  37734. return column < this.hot.getSettings().fixedColumnsLeft;
  37735. }
  37736. /**
  37737. * Save the manual column positions to the persistent state.
  37738. *
  37739. * @private
  37740. */
  37741. }, {
  37742. key: 'persistentStateSave',
  37743. value: function persistentStateSave() {
  37744. this.hot.runHooks('persistentStateSave', 'manualColumnMove', this.columnsMapper._arrayMap);
  37745. }
  37746. /**
  37747. * Load the manual column positions from the persistent state.
  37748. *
  37749. * @private
  37750. */
  37751. }, {
  37752. key: 'persistentStateLoad',
  37753. value: function persistentStateLoad() {
  37754. var storedState = {};
  37755. this.hot.runHooks('persistentStateLoad', 'manualColumnMove', storedState);
  37756. if (storedState.value) {
  37757. this.columnsMapper._arrayMap = storedState.value;
  37758. }
  37759. }
  37760. /**
  37761. * Prepare array of indexes based on actual selection.
  37762. *
  37763. * @private
  37764. * @returns {Array}
  37765. */
  37766. }, {
  37767. key: 'prepareColumnsToMoving',
  37768. value: function prepareColumnsToMoving(start, end) {
  37769. var selectedColumns = [];
  37770. (0, _number.rangeEach)(start, end, function (i) {
  37771. selectedColumns.push(i);
  37772. });
  37773. return selectedColumns;
  37774. }
  37775. /**
  37776. * Update the UI visual position.
  37777. *
  37778. * @private
  37779. */
  37780. }, {
  37781. key: 'refreshPositions',
  37782. value: function refreshPositions() {
  37783. var priv = privatePool.get(this);
  37784. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleColumn();
  37785. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleColumn();
  37786. var wtTable = this.hot.view.wt.wtTable;
  37787. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  37788. var scrollLeft = typeof scrollableElement.scrollX === 'number' ? scrollableElement.scrollX : scrollableElement.scrollLeft;
  37789. var tdOffsetLeft = this.hot.view.THEAD.offsetLeft + this.getColumnsWidth(0, priv.coordsColumn);
  37790. var mouseOffsetLeft = priv.target.eventPageX - (priv.rootElementOffset - (scrollableElement.scrollX === void 0 ? scrollLeft : 0));
  37791. var hiderWidth = wtTable.hider.offsetWidth;
  37792. var tbodyOffsetLeft = wtTable.TBODY.offsetLeft;
  37793. var backlightElemMarginLeft = this.backlight.getOffset().left;
  37794. var backlightElemWidth = this.backlight.getSize().width;
  37795. var rowHeaderWidth = 0;
  37796. if (priv.rootElementOffset + wtTable.holder.offsetWidth + scrollLeft < priv.target.eventPageX) {
  37797. if (priv.coordsColumn < priv.countCols) {
  37798. priv.coordsColumn++;
  37799. }
  37800. }
  37801. if (priv.hasRowHeaders) {
  37802. rowHeaderWidth = this.hot.view.wt.wtOverlays.leftOverlay.clone.wtTable.getColumnHeader(-1).offsetWidth;
  37803. }
  37804. if (this.isFixedColumnsLeft(priv.coordsColumn)) {
  37805. tdOffsetLeft += scrollLeft;
  37806. }
  37807. tdOffsetLeft += rowHeaderWidth;
  37808. if (priv.coordsColumn < 0) {
  37809. // if hover on rowHeader
  37810. if (priv.fixedColumns > 0) {
  37811. priv.target.col = 0;
  37812. } else {
  37813. priv.target.col = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  37814. }
  37815. } else if (priv.target.TD.offsetWidth / 2 + tdOffsetLeft <= mouseOffsetLeft) {
  37816. var newCoordsCol = priv.coordsColumn >= priv.countCols ? priv.countCols - 1 : priv.coordsColumn;
  37817. // if hover on right part of TD
  37818. priv.target.col = newCoordsCol + 1;
  37819. // unfortunately first column is bigger than rest
  37820. tdOffsetLeft += priv.target.TD.offsetWidth;
  37821. if (priv.target.col > lastVisible) {
  37822. this.hot.scrollViewportTo(void 0, lastVisible + 1, void 0, true);
  37823. }
  37824. } else {
  37825. // elsewhere on table
  37826. priv.target.col = priv.coordsColumn;
  37827. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  37828. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  37829. }
  37830. }
  37831. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  37832. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  37833. }
  37834. var backlightLeft = mouseOffsetLeft;
  37835. var guidelineLeft = tdOffsetLeft;
  37836. if (mouseOffsetLeft + backlightElemWidth + backlightElemMarginLeft >= hiderWidth) {
  37837. // prevent display backlight on the right side of the table
  37838. backlightLeft = hiderWidth - backlightElemWidth - backlightElemMarginLeft;
  37839. } else if (mouseOffsetLeft + backlightElemMarginLeft < tbodyOffsetLeft + rowHeaderWidth) {
  37840. // prevent display backlight on the left side of the table
  37841. backlightLeft = tbodyOffsetLeft + rowHeaderWidth + Math.abs(backlightElemMarginLeft);
  37842. }
  37843. if (tdOffsetLeft >= hiderWidth - 1) {
  37844. // prevent display guideline outside the table
  37845. guidelineLeft = hiderWidth - 1;
  37846. } else if (guidelineLeft === 0) {
  37847. // guideline has got `margin-left: -1px` as default
  37848. guidelineLeft = 1;
  37849. } else if (scrollableElement.scrollX !== void 0 && priv.coordsColumn < priv.fixedColumns) {
  37850. guidelineLeft -= priv.rootElementOffset <= scrollableElement.scrollX ? priv.rootElementOffset : 0;
  37851. }
  37852. this.backlight.setPosition(null, backlightLeft);
  37853. this.guideline.setPosition(null, guidelineLeft);
  37854. }
  37855. /**
  37856. * This method checks arrayMap from columnsMapper and updates the columnsMapper if it's necessary.
  37857. *
  37858. * @private
  37859. */
  37860. }, {
  37861. key: 'updateColumnsMapper',
  37862. value: function updateColumnsMapper() {
  37863. var countCols = this.hot.countSourceCols();
  37864. var columnsMapperLen = this.columnsMapper._arrayMap.length;
  37865. if (columnsMapperLen === 0) {
  37866. this.columnsMapper.createMap(countCols || this.hot.getSettings().startCols);
  37867. } else if (columnsMapperLen < countCols) {
  37868. var diff = countCols - columnsMapperLen;
  37869. this.columnsMapper.insertItems(columnsMapperLen, diff);
  37870. } else if (columnsMapperLen > countCols) {
  37871. var maxIndex = countCols - 1;
  37872. var columnsToRemove = [];
  37873. (0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index, array) {
  37874. if (value > maxIndex) {
  37875. columnsToRemove.push(index);
  37876. }
  37877. });
  37878. this.columnsMapper.removeItems(columnsToRemove);
  37879. }
  37880. }
  37881. /**
  37882. * Bind the events used by the plugin.
  37883. *
  37884. * @private
  37885. */
  37886. }, {
  37887. key: 'registerEvents',
  37888. value: function registerEvents() {
  37889. var _this4 = this;
  37890. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  37891. return _this4.onMouseMove(event);
  37892. });
  37893. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  37894. return _this4.onMouseUp();
  37895. });
  37896. }
  37897. /**
  37898. * Unbind the events used by the plugin.
  37899. *
  37900. * @private
  37901. */
  37902. }, {
  37903. key: 'unregisterEvents',
  37904. value: function unregisterEvents() {
  37905. this.eventManager.clear();
  37906. }
  37907. /**
  37908. * Change the behavior of selection / dragging.
  37909. *
  37910. * @private
  37911. * @param {MouseEvent} event `mousedown` event properties.
  37912. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  37913. * @param {HTMLElement} TD Cell represented as HTMLElement.
  37914. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  37915. */
  37916. }, {
  37917. key: 'onBeforeOnCellMouseDown',
  37918. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  37919. var wtTable = this.hot.view.wt.wtTable;
  37920. var isHeaderSelection = this.hot.selection.selectedHeader.cols;
  37921. var selection = this.hot.getSelectedRange();
  37922. var priv = privatePool.get(this);
  37923. var isSortingElement = event.realTarget.className.indexOf('columnSorting') > -1;
  37924. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0 || isSortingElement) {
  37925. priv.pressed = false;
  37926. priv.columnsToMove.length = 0;
  37927. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  37928. return;
  37929. }
  37930. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  37931. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  37932. if (guidelineIsNotReady && backlightIsNotReady) {
  37933. this.guideline.appendTo(wtTable.hider);
  37934. this.backlight.appendTo(wtTable.hider);
  37935. }
  37936. var from = selection.from,
  37937. to = selection.to;
  37938. var start = Math.min(from.col, to.col);
  37939. var end = Math.max(from.col, to.col);
  37940. if (coords.row < 0 && coords.col >= start && coords.col <= end) {
  37941. blockCalculations.column = true;
  37942. priv.pressed = true;
  37943. priv.target.eventPageX = event.pageX;
  37944. priv.coordsColumn = coords.col;
  37945. priv.target.TD = TD;
  37946. priv.target.col = coords.col;
  37947. priv.columnsToMove = this.prepareColumnsToMoving(start, end);
  37948. priv.hasRowHeaders = !!this.hot.getSettings().rowHeaders;
  37949. priv.countCols = this.hot.countCols();
  37950. priv.fixedColumns = this.hot.getSettings().fixedColumnsLeft;
  37951. priv.rootElementOffset = (0, _element.offset)(this.hot.rootElement).left;
  37952. var countColumnsFrom = priv.hasRowHeaders ? -1 : 0;
  37953. var topPos = wtTable.holder.scrollTop + wtTable.getColumnHeaderHeight(0) + 1;
  37954. var fixedColumns = coords.col < priv.fixedColumns;
  37955. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  37956. var wrapperIsWindow = scrollableElement.scrollX ? scrollableElement.scrollX - priv.rootElementOffset : 0;
  37957. var mouseOffset = event.layerX - (fixedColumns ? wrapperIsWindow : 0);
  37958. var leftOffset = Math.abs(this.getColumnsWidth(start, coords.col) + mouseOffset);
  37959. this.backlight.setPosition(topPos, this.getColumnsWidth(countColumnsFrom, start) + leftOffset);
  37960. this.backlight.setSize(this.getColumnsWidth(start, end + 1), wtTable.hider.offsetHeight - topPos);
  37961. this.backlight.setOffset(null, leftOffset * -1);
  37962. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  37963. } else {
  37964. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  37965. priv.pressed = false;
  37966. priv.columnsToMove.length = 0;
  37967. }
  37968. }
  37969. /**
  37970. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  37971. *
  37972. * @private
  37973. * @param {MouseEvent} event `mousemove` event properties.
  37974. */
  37975. }, {
  37976. key: 'onMouseMove',
  37977. value: function onMouseMove(event) {
  37978. var priv = privatePool.get(this);
  37979. if (!priv.pressed) {
  37980. return;
  37981. }
  37982. // callback for browser which doesn't supports CSS pointer-event: none
  37983. if (event.realTarget === this.backlight.element) {
  37984. var width = this.backlight.getSize().width;
  37985. this.backlight.setSize(0);
  37986. setTimeout(function () {
  37987. this.backlight.setPosition(width);
  37988. });
  37989. }
  37990. priv.target.eventPageX = event.pageX;
  37991. this.refreshPositions();
  37992. }
  37993. /**
  37994. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  37995. *
  37996. * @private
  37997. * @param {MouseEvent} event `mouseover` event properties.
  37998. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  37999. * @param {HTMLElement} TD Cell represented as HTMLElement.
  38000. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  38001. */
  38002. }, {
  38003. key: 'onBeforeOnCellMouseOver',
  38004. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  38005. var selectedRange = this.hot.getSelectedRange();
  38006. var priv = privatePool.get(this);
  38007. if (!selectedRange || !priv.pressed) {
  38008. return;
  38009. }
  38010. if (priv.columnsToMove.indexOf(coords.col) > -1) {
  38011. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  38012. } else {
  38013. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  38014. }
  38015. blockCalculations.row = true;
  38016. blockCalculations.column = true;
  38017. blockCalculations.cell = true;
  38018. priv.coordsColumn = coords.col;
  38019. priv.target.TD = TD;
  38020. }
  38021. /**
  38022. * `onMouseUp` hook callback.
  38023. *
  38024. * @private
  38025. */
  38026. }, {
  38027. key: 'onMouseUp',
  38028. value: function onMouseUp() {
  38029. var priv = privatePool.get(this);
  38030. priv.coordsColumn = void 0;
  38031. priv.pressed = false;
  38032. priv.backlightWidth = 0;
  38033. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  38034. if (this.hot.selection.selectedHeader.cols) {
  38035. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  38036. }
  38037. if (priv.columnsToMove.length < 1 || priv.target.col === void 0 || priv.columnsToMove.indexOf(priv.target.col) > -1) {
  38038. return;
  38039. }
  38040. this.moveColumns(priv.columnsToMove, priv.target.col);
  38041. this.persistentStateSave();
  38042. this.hot.render();
  38043. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  38044. if (!priv.disallowMoving) {
  38045. var selectionStart = this.columnsMapper.getIndexByValue(priv.columnsToMove[0]);
  38046. var selectionEnd = this.columnsMapper.getIndexByValue(priv.columnsToMove[priv.columnsToMove.length - 1]);
  38047. this.changeSelection(selectionStart, selectionEnd);
  38048. }
  38049. priv.columnsToMove.length = 0;
  38050. }
  38051. /**
  38052. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  38053. *
  38054. * @private
  38055. */
  38056. }, {
  38057. key: 'onAfterScrollVertically',
  38058. value: function onAfterScrollVertically() {
  38059. var wtTable = this.hot.view.wt.wtTable;
  38060. var headerHeight = wtTable.getColumnHeaderHeight(0) + 1;
  38061. var scrollTop = wtTable.holder.scrollTop;
  38062. var posTop = headerHeight + scrollTop;
  38063. this.backlight.setPosition(posTop);
  38064. this.backlight.setSize(null, wtTable.hider.offsetHeight - posTop);
  38065. }
  38066. /**
  38067. * `afterCreateCol` hook callback.
  38068. *
  38069. * @private
  38070. * @param {Number} index Visual index of the created column.
  38071. * @param {Number} amount Amount of created columns.
  38072. */
  38073. }, {
  38074. key: 'onAfterCreateCol',
  38075. value: function onAfterCreateCol(index, amount) {
  38076. this.columnsMapper.shiftItems(index, amount);
  38077. }
  38078. /**
  38079. * On before remove column listener.
  38080. *
  38081. * @private
  38082. * @param {Number} index Visual column index.
  38083. * @param {Number} amount Defines how many columns removed.
  38084. */
  38085. }, {
  38086. key: 'onBeforeRemoveCol',
  38087. value: function onBeforeRemoveCol(index, amount) {
  38088. var _this5 = this;
  38089. this.removedColumns.length = 0;
  38090. if (index !== false) {
  38091. // Collect physical row index.
  38092. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  38093. _this5.removedColumns.push(_this5.hot.runHooks('modifyCol', removedIndex, _this5.pluginName));
  38094. });
  38095. }
  38096. }
  38097. /**
  38098. * `afterRemoveCol` hook callback.
  38099. *
  38100. * @private
  38101. * @param {Number} index Visual column index of the removed column.
  38102. * @param {Number} amount Amount of removed columns.
  38103. */
  38104. }, {
  38105. key: 'onAfterRemoveCol',
  38106. value: function onAfterRemoveCol(index, amount) {
  38107. this.columnsMapper.unshiftItems(this.removedColumns);
  38108. }
  38109. /**
  38110. * `afterLoadData` hook callback.
  38111. *
  38112. * @private
  38113. * @param {Boolean} firstTime True if that was loading data during the initialization.
  38114. */
  38115. }, {
  38116. key: 'onAfterLoadData',
  38117. value: function onAfterLoadData(firstTime) {
  38118. this.updateColumnsMapper();
  38119. }
  38120. /**
  38121. * 'modifyRow' hook callback.
  38122. *
  38123. * @private
  38124. * @param {Number} column Visual column index.
  38125. * @returns {Number} Physical column index.
  38126. */
  38127. }, {
  38128. key: 'onModifyCol',
  38129. value: function onModifyCol(column, source) {
  38130. if (source !== this.pluginName) {
  38131. // ugly fix for try to insert new, needed columns after pasting data
  38132. var columnInMapper = this.columnsMapper.getValueByIndex(column);
  38133. column = columnInMapper === null ? column : columnInMapper;
  38134. }
  38135. return column;
  38136. }
  38137. /**
  38138. * 'unmodifyCol' hook callback.
  38139. *
  38140. * @private
  38141. * @param {Number} column Physical column index.
  38142. * @returns {Number} Visual column index.
  38143. */
  38144. }, {
  38145. key: 'onUnmodifyCol',
  38146. value: function onUnmodifyCol(column) {
  38147. var indexInMapper = this.columnsMapper.getIndexByValue(column);
  38148. return indexInMapper === null ? column : indexInMapper;
  38149. }
  38150. /**
  38151. * `afterPluginsInitialized` hook callback.
  38152. *
  38153. * @private
  38154. */
  38155. }, {
  38156. key: 'onAfterPluginsInitialized',
  38157. value: function onAfterPluginsInitialized() {
  38158. this.updateColumnsMapper();
  38159. this.initialSettings();
  38160. this.backlight.build();
  38161. this.guideline.build();
  38162. }
  38163. /**
  38164. * Destroy plugin instance.
  38165. */
  38166. }, {
  38167. key: 'destroy',
  38168. value: function destroy() {
  38169. this.backlight.destroy();
  38170. this.guideline.destroy();
  38171. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'destroy', this).call(this);
  38172. }
  38173. }]);
  38174. return ManualColumnMove;
  38175. }(_base2.default);
  38176. (0, _plugins.registerPlugin)('ManualColumnMove', ManualColumnMove);
  38177. exports.default = ManualColumnMove;
  38178. /***/ }),
  38179. /* 360 */
  38180. /***/ (function(module, exports, __webpack_require__) {
  38181. "use strict";
  38182. exports.__esModule = true;
  38183. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  38184. var _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); } };
  38185. var _base = __webpack_require__(266);
  38186. var _base2 = _interopRequireDefault(_base);
  38187. var _element = __webpack_require__(0);
  38188. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38189. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38190. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  38191. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  38192. var CSS_CLASSNAME = 'ht__manualColumnMove--backlight';
  38193. /**
  38194. * @class BacklightUI
  38195. * @util
  38196. */
  38197. var BacklightUI = function (_BaseUI) {
  38198. _inherits(BacklightUI, _BaseUI);
  38199. function BacklightUI() {
  38200. _classCallCheck(this, BacklightUI);
  38201. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  38202. }
  38203. _createClass(BacklightUI, [{
  38204. key: 'build',
  38205. /**
  38206. * Custom className on build process.
  38207. */
  38208. value: function build() {
  38209. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  38210. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  38211. }
  38212. }]);
  38213. return BacklightUI;
  38214. }(_base2.default);
  38215. exports.default = BacklightUI;
  38216. /***/ }),
  38217. /* 361 */
  38218. /***/ (function(module, exports, __webpack_require__) {
  38219. "use strict";
  38220. exports.__esModule = true;
  38221. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  38222. var _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); } };
  38223. var _base = __webpack_require__(266);
  38224. var _base2 = _interopRequireDefault(_base);
  38225. var _element = __webpack_require__(0);
  38226. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38227. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38228. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  38229. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  38230. var CSS_CLASSNAME = 'ht__manualColumnMove--guideline';
  38231. /**
  38232. * @class GuidelineUI
  38233. * @util
  38234. */
  38235. var GuidelineUI = function (_BaseUI) {
  38236. _inherits(GuidelineUI, _BaseUI);
  38237. function GuidelineUI() {
  38238. _classCallCheck(this, GuidelineUI);
  38239. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  38240. }
  38241. _createClass(GuidelineUI, [{
  38242. key: 'build',
  38243. /**
  38244. * Custom className on build process.
  38245. */
  38246. value: function build() {
  38247. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  38248. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  38249. }
  38250. }]);
  38251. return GuidelineUI;
  38252. }(_base2.default);
  38253. exports.default = GuidelineUI;
  38254. /***/ }),
  38255. /* 362 */
  38256. /***/ (function(module, exports, __webpack_require__) {
  38257. "use strict";
  38258. exports.__esModule = true;
  38259. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  38260. var _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); } };
  38261. var _base = __webpack_require__(12);
  38262. var _base2 = _interopRequireDefault(_base);
  38263. var _element = __webpack_require__(0);
  38264. var _eventManager = __webpack_require__(4);
  38265. var _eventManager2 = _interopRequireDefault(_eventManager);
  38266. var _event = __webpack_require__(7);
  38267. var _array = __webpack_require__(2);
  38268. var _number = __webpack_require__(6);
  38269. var _plugins = __webpack_require__(5);
  38270. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38271. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38272. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  38273. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  38274. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  38275. /**
  38276. * @description
  38277. * ManualColumnResize Plugin.
  38278. *
  38279. * Has 2 UI components:
  38280. * - handle - the draggable element that sets the desired width of the column.
  38281. * - guide - the helper guide that shows the desired width as a vertical guide.
  38282. *
  38283. * @plugin ManualColumnResize
  38284. */
  38285. var ManualColumnResize = function (_BasePlugin) {
  38286. _inherits(ManualColumnResize, _BasePlugin);
  38287. function ManualColumnResize(hotInstance) {
  38288. _classCallCheck(this, ManualColumnResize);
  38289. var _this = _possibleConstructorReturn(this, (ManualColumnResize.__proto__ || Object.getPrototypeOf(ManualColumnResize)).call(this, hotInstance));
  38290. _this.currentTH = null;
  38291. _this.currentCol = null;
  38292. _this.selectedCols = [];
  38293. _this.currentWidth = null;
  38294. _this.newSize = null;
  38295. _this.startY = null;
  38296. _this.startWidth = null;
  38297. _this.startOffset = null;
  38298. _this.handle = document.createElement('DIV');
  38299. _this.guide = document.createElement('DIV');
  38300. _this.eventManager = new _eventManager2.default(_this);
  38301. _this.pressed = null;
  38302. _this.dblclick = 0;
  38303. _this.autoresizeTimeout = null;
  38304. _this.manualColumnWidths = [];
  38305. (0, _element.addClass)(_this.handle, 'manualColumnResizer');
  38306. (0, _element.addClass)(_this.guide, 'manualColumnResizerGuide');
  38307. return _this;
  38308. }
  38309. /**
  38310. * Check if the plugin is enabled in the handsontable settings.
  38311. *
  38312. * @returns {Boolean}
  38313. */
  38314. _createClass(ManualColumnResize, [{
  38315. key: 'isEnabled',
  38316. value: function isEnabled() {
  38317. return this.hot.getSettings().manualColumnResize;
  38318. }
  38319. /**
  38320. * Enable plugin for this Handsontable instance.
  38321. */
  38322. }, {
  38323. key: 'enablePlugin',
  38324. value: function enablePlugin() {
  38325. var _this2 = this;
  38326. if (this.enabled) {
  38327. return;
  38328. }
  38329. this.manualColumnWidths = [];
  38330. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  38331. var loadedManualColumnWidths = this.loadManualColumnWidths();
  38332. this.addHook('modifyColWidth', function (width, col) {
  38333. return _this2.onModifyColWidth(width, col);
  38334. });
  38335. this.addHook('beforeStretchingColumnWidth', function (stretchedWidth, column) {
  38336. return _this2.onBeforeStretchingColumnWidth(stretchedWidth, column);
  38337. });
  38338. this.addHook('beforeColumnResize', function (currentColumn, newSize, isDoubleClick) {
  38339. return _this2.onBeforeColumnResize(currentColumn, newSize, isDoubleClick);
  38340. });
  38341. if (typeof loadedManualColumnWidths != 'undefined') {
  38342. this.manualColumnWidths = loadedManualColumnWidths;
  38343. } else if (Array.isArray(initialColumnWidth)) {
  38344. this.manualColumnWidths = initialColumnWidth;
  38345. } else {
  38346. this.manualColumnWidths = [];
  38347. }
  38348. // Handsontable.hooks.register('beforeColumnResize');
  38349. // Handsontable.hooks.register('afterColumnResize');
  38350. this.bindEvents();
  38351. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'enablePlugin', this).call(this);
  38352. }
  38353. /**
  38354. * Updates the plugin to use the latest options you have specified.
  38355. */
  38356. }, {
  38357. key: 'updatePlugin',
  38358. value: function updatePlugin() {
  38359. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  38360. if (Array.isArray(initialColumnWidth)) {
  38361. this.manualColumnWidths = initialColumnWidth;
  38362. } else if (!initialColumnWidth) {
  38363. this.manualColumnWidths = [];
  38364. }
  38365. }
  38366. /**
  38367. * Disable plugin for this Handsontable instance.
  38368. */
  38369. }, {
  38370. key: 'disablePlugin',
  38371. value: function disablePlugin() {
  38372. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'disablePlugin', this).call(this);
  38373. }
  38374. /**
  38375. * Save the current sizes using the persistentState plugin.
  38376. */
  38377. }, {
  38378. key: 'saveManualColumnWidths',
  38379. value: function saveManualColumnWidths() {
  38380. this.hot.runHooks('persistentStateSave', 'manualColumnWidths', this.manualColumnWidths);
  38381. }
  38382. /**
  38383. * Load the previously saved sizes using the persistentState plugin.
  38384. *
  38385. * @returns {Array}
  38386. */
  38387. }, {
  38388. key: 'loadManualColumnWidths',
  38389. value: function loadManualColumnWidths() {
  38390. var storedState = {};
  38391. this.hot.runHooks('persistentStateLoad', 'manualColumnWidths', storedState);
  38392. return storedState.value;
  38393. }
  38394. /**
  38395. * Set the resize handle position.
  38396. *
  38397. * @param {HTMLCellElement} TH TH HTML element.
  38398. */
  38399. }, {
  38400. key: 'setupHandlePosition',
  38401. value: function setupHandlePosition(TH) {
  38402. var _this3 = this;
  38403. if (!TH.parentNode) {
  38404. return false;
  38405. }
  38406. this.currentTH = TH;
  38407. var col = this.hot.view.wt.wtTable.getCoords(TH).col; // getCoords returns CellCoords
  38408. var headerHeight = (0, _element.outerHeight)(this.currentTH);
  38409. if (col >= 0) {
  38410. // if not col header
  38411. var box = this.currentTH.getBoundingClientRect();
  38412. this.currentCol = col;
  38413. this.selectedCols = [];
  38414. if (this.hot.selection.isSelected() && this.hot.selection.selectedHeader.cols) {
  38415. var _hot$getSelectedRange = this.hot.getSelectedRange(),
  38416. from = _hot$getSelectedRange.from,
  38417. to = _hot$getSelectedRange.to;
  38418. var start = from.col;
  38419. var end = to.col;
  38420. if (start >= end) {
  38421. start = to.col;
  38422. end = from.col;
  38423. }
  38424. if (this.currentCol >= start && this.currentCol <= end) {
  38425. (0, _number.rangeEach)(start, end, function (i) {
  38426. return _this3.selectedCols.push(i);
  38427. });
  38428. } else {
  38429. this.selectedCols.push(this.currentCol);
  38430. }
  38431. } else {
  38432. this.selectedCols.push(this.currentCol);
  38433. }
  38434. this.startOffset = box.left - 6;
  38435. this.startWidth = parseInt(box.width, 10);
  38436. this.handle.style.top = box.top + 'px';
  38437. this.handle.style.left = this.startOffset + this.startWidth + 'px';
  38438. this.handle.style.height = headerHeight + 'px';
  38439. this.hot.rootElement.appendChild(this.handle);
  38440. }
  38441. }
  38442. /**
  38443. * Refresh the resize handle position.
  38444. */
  38445. }, {
  38446. key: 'refreshHandlePosition',
  38447. value: function refreshHandlePosition() {
  38448. this.handle.style.left = this.startOffset + this.currentWidth + 'px';
  38449. }
  38450. /**
  38451. * Set the resize guide position.
  38452. */
  38453. }, {
  38454. key: 'setupGuidePosition',
  38455. value: function setupGuidePosition() {
  38456. var handleHeight = parseInt((0, _element.outerHeight)(this.handle), 10);
  38457. var handleBottomPosition = parseInt(this.handle.style.top, 10) + handleHeight;
  38458. var maximumVisibleElementHeight = parseInt(this.hot.view.maximumVisibleElementHeight(0), 10);
  38459. (0, _element.addClass)(this.handle, 'active');
  38460. (0, _element.addClass)(this.guide, 'active');
  38461. this.guide.style.top = handleBottomPosition + 'px';
  38462. this.guide.style.left = this.handle.style.left;
  38463. this.guide.style.height = maximumVisibleElementHeight - handleHeight + 'px';
  38464. this.hot.rootElement.appendChild(this.guide);
  38465. }
  38466. /**
  38467. * Refresh the resize guide position.
  38468. */
  38469. }, {
  38470. key: 'refreshGuidePosition',
  38471. value: function refreshGuidePosition() {
  38472. this.guide.style.left = this.handle.style.left;
  38473. }
  38474. /**
  38475. * Hide both the resize handle and resize guide.
  38476. */
  38477. }, {
  38478. key: 'hideHandleAndGuide',
  38479. value: function hideHandleAndGuide() {
  38480. (0, _element.removeClass)(this.handle, 'active');
  38481. (0, _element.removeClass)(this.guide, 'active');
  38482. }
  38483. /**
  38484. * Check if provided element is considered a column header.
  38485. *
  38486. * @param {HTMLElement} element HTML element.
  38487. * @returns {Boolean}
  38488. */
  38489. }, {
  38490. key: 'checkIfColumnHeader',
  38491. value: function checkIfColumnHeader(element) {
  38492. if (element != this.hot.rootElement) {
  38493. var parent = element.parentNode;
  38494. if (parent.tagName === 'THEAD') {
  38495. return true;
  38496. }
  38497. return this.checkIfColumnHeader(parent);
  38498. }
  38499. return false;
  38500. }
  38501. /**
  38502. * Get the TH element from the provided element.
  38503. *
  38504. * @param {HTMLElement} element HTML element.
  38505. * @returns {HTMLElement}
  38506. */
  38507. }, {
  38508. key: 'getTHFromTargetElement',
  38509. value: function getTHFromTargetElement(element) {
  38510. if (element.tagName != 'TABLE') {
  38511. if (element.tagName == 'TH') {
  38512. return element;
  38513. }
  38514. return this.getTHFromTargetElement(element.parentNode);
  38515. }
  38516. return null;
  38517. }
  38518. /**
  38519. * 'mouseover' event callback - set the handle position.
  38520. *
  38521. * @private
  38522. * @param {MouseEvent} event
  38523. */
  38524. }, {
  38525. key: 'onMouseOver',
  38526. value: function onMouseOver(event) {
  38527. if (this.checkIfColumnHeader(event.target)) {
  38528. var th = this.getTHFromTargetElement(event.target);
  38529. if (!th) {
  38530. return;
  38531. }
  38532. var colspan = th.getAttribute('colspan');
  38533. if (th && (colspan === null || colspan === 1)) {
  38534. if (!this.pressed) {
  38535. this.setupHandlePosition(th);
  38536. }
  38537. }
  38538. }
  38539. }
  38540. /**
  38541. * Auto-size row after doubleclick - callback.
  38542. *
  38543. * @private
  38544. */
  38545. }, {
  38546. key: 'afterMouseDownTimeout',
  38547. value: function afterMouseDownTimeout() {
  38548. var _this4 = this;
  38549. var render = function render() {
  38550. _this4.hot.forceFullRender = true;
  38551. _this4.hot.view.render(); // updates all
  38552. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  38553. };
  38554. var resize = function resize(selectedCol, forceRender) {
  38555. var hookNewSize = _this4.hot.runHooks('beforeColumnResize', selectedCol, _this4.newSize, true);
  38556. if (hookNewSize !== void 0) {
  38557. _this4.newSize = hookNewSize;
  38558. }
  38559. if (_this4.hot.getSettings().stretchH === 'all') {
  38560. _this4.clearManualSize(selectedCol);
  38561. } else {
  38562. _this4.setManualSize(selectedCol, _this4.newSize); // double click sets by auto row size plugin
  38563. }
  38564. if (forceRender) {
  38565. render();
  38566. }
  38567. _this4.saveManualColumnWidths();
  38568. _this4.hot.runHooks('afterColumnResize', selectedCol, _this4.newSize, true);
  38569. };
  38570. if (this.dblclick >= 2) {
  38571. var selectedColsLength = this.selectedCols.length;
  38572. if (selectedColsLength > 1) {
  38573. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  38574. resize(selectedCol);
  38575. });
  38576. render();
  38577. } else {
  38578. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  38579. resize(selectedCol, true);
  38580. });
  38581. }
  38582. }
  38583. this.dblclick = 0;
  38584. this.autoresizeTimeout = null;
  38585. }
  38586. /**
  38587. * 'mousedown' event callback.
  38588. *
  38589. * @private
  38590. * @param {MouseEvent} e
  38591. */
  38592. }, {
  38593. key: 'onMouseDown',
  38594. value: function onMouseDown(event) {
  38595. var _this5 = this;
  38596. if ((0, _element.hasClass)(event.target, 'manualColumnResizer')) {
  38597. this.setupGuidePosition();
  38598. this.pressed = this.hot;
  38599. if (this.autoresizeTimeout === null) {
  38600. this.autoresizeTimeout = setTimeout(function () {
  38601. return _this5.afterMouseDownTimeout();
  38602. }, 500);
  38603. this.hot._registerTimeout(this.autoresizeTimeout);
  38604. }
  38605. this.dblclick++;
  38606. this.startX = (0, _event.pageX)(event);
  38607. this.newSize = this.startWidth;
  38608. }
  38609. }
  38610. /**
  38611. * 'mousemove' event callback - refresh the handle and guide positions, cache the new column width.
  38612. *
  38613. * @private
  38614. * @param {MouseEvent} e
  38615. */
  38616. }, {
  38617. key: 'onMouseMove',
  38618. value: function onMouseMove(event) {
  38619. var _this6 = this;
  38620. if (this.pressed) {
  38621. this.currentWidth = this.startWidth + ((0, _event.pageX)(event) - this.startX);
  38622. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  38623. _this6.newSize = _this6.setManualSize(selectedCol, _this6.currentWidth);
  38624. });
  38625. this.refreshHandlePosition();
  38626. this.refreshGuidePosition();
  38627. }
  38628. }
  38629. /**
  38630. * 'mouseup' event callback - apply the column resizing.
  38631. *
  38632. * @private
  38633. * @param {MouseEvent} e
  38634. */
  38635. }, {
  38636. key: 'onMouseUp',
  38637. value: function onMouseUp(event) {
  38638. var _this7 = this;
  38639. var render = function render() {
  38640. _this7.hot.forceFullRender = true;
  38641. _this7.hot.view.render(); // updates all
  38642. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  38643. };
  38644. var resize = function resize(selectedCol, forceRender) {
  38645. _this7.hot.runHooks('beforeColumnResize', selectedCol, _this7.newSize);
  38646. if (forceRender) {
  38647. render();
  38648. }
  38649. _this7.saveManualColumnWidths();
  38650. _this7.hot.runHooks('afterColumnResize', selectedCol, _this7.newSize);
  38651. };
  38652. if (this.pressed) {
  38653. this.hideHandleAndGuide();
  38654. this.pressed = false;
  38655. if (this.newSize != this.startWidth) {
  38656. var selectedColsLength = this.selectedCols.length;
  38657. if (selectedColsLength > 1) {
  38658. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  38659. resize(selectedCol);
  38660. });
  38661. render();
  38662. } else {
  38663. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  38664. resize(selectedCol, true);
  38665. });
  38666. }
  38667. }
  38668. this.setupHandlePosition(this.currentTH);
  38669. }
  38670. }
  38671. /**
  38672. * Bind the mouse events.
  38673. *
  38674. * @private
  38675. */
  38676. }, {
  38677. key: 'bindEvents',
  38678. value: function bindEvents() {
  38679. var _this8 = this;
  38680. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  38681. return _this8.onMouseOver(e);
  38682. });
  38683. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  38684. return _this8.onMouseDown(e);
  38685. });
  38686. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  38687. return _this8.onMouseMove(e);
  38688. });
  38689. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  38690. return _this8.onMouseUp(e);
  38691. });
  38692. }
  38693. /**
  38694. * Cache the current column width.
  38695. *
  38696. * @param {Number} column Visual column index.
  38697. * @param {Number} width Column width.
  38698. * @returns {Number}
  38699. */
  38700. }, {
  38701. key: 'setManualSize',
  38702. value: function setManualSize(column, width) {
  38703. width = Math.max(width, 20);
  38704. /**
  38705. * We need to run col through modifyCol hook, in case the order of displayed columns is different than the order
  38706. * in data source. For instance, this order can be modified by manualColumnMove plugin.
  38707. */
  38708. column = this.hot.runHooks('modifyCol', column);
  38709. this.manualColumnWidths[column] = width;
  38710. return width;
  38711. }
  38712. /**
  38713. * Clear cache for the current column index.
  38714. *
  38715. * @param {Number} column Visual column index.
  38716. */
  38717. }, {
  38718. key: 'clearManualSize',
  38719. value: function clearManualSize(column) {
  38720. column = this.hot.runHooks('modifyCol', column);
  38721. this.manualColumnWidths[column] = void 0;
  38722. }
  38723. /**
  38724. * Modify the provided column width, based on the plugin settings
  38725. *
  38726. * @private
  38727. * @param {Number} width Column width.
  38728. * @param {Number} column Visual column index.
  38729. * @returns {Number}
  38730. */
  38731. }, {
  38732. key: 'onModifyColWidth',
  38733. value: function onModifyColWidth(width, column) {
  38734. if (this.enabled) {
  38735. column = this.hot.runHooks('modifyCol', column);
  38736. if (this.hot.getSettings().manualColumnResize && this.manualColumnWidths[column]) {
  38737. return this.manualColumnWidths[column];
  38738. }
  38739. }
  38740. return width;
  38741. }
  38742. /**
  38743. * Modify the provided column stretched width. This hook decides if specified column should be stretched or not.
  38744. *
  38745. * @private
  38746. * @param {Number} stretchedWidth Stretched width.
  38747. * @param {Number} column Physical column index.
  38748. * @returns {Number}
  38749. */
  38750. }, {
  38751. key: 'onBeforeStretchingColumnWidth',
  38752. value: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  38753. var width = this.manualColumnWidths[column];
  38754. if (width === void 0) {
  38755. width = stretchedWidth;
  38756. }
  38757. return width;
  38758. }
  38759. /**
  38760. * `beforeColumnResize` hook callback.
  38761. *
  38762. * @private
  38763. * @param {Number} currentColumn Index of the resized column.
  38764. * @param {Number} newSize Calculated new column width.
  38765. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  38766. */
  38767. }, {
  38768. key: 'onBeforeColumnResize',
  38769. value: function onBeforeColumnResize() {
  38770. // clear the header height cache information
  38771. this.hot.view.wt.wtViewport.hasOversizedColumnHeadersMarked = {};
  38772. }
  38773. }]);
  38774. return ManualColumnResize;
  38775. }(_base2.default);
  38776. (0, _plugins.registerPlugin)('manualColumnResize', ManualColumnResize);
  38777. exports.default = ManualColumnResize;
  38778. /***/ }),
  38779. /* 363 */
  38780. /***/ (function(module, exports, __webpack_require__) {
  38781. "use strict";
  38782. exports.__esModule = true;
  38783. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  38784. var _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); } };
  38785. var _base = __webpack_require__(12);
  38786. var _base2 = _interopRequireDefault(_base);
  38787. var _pluginHooks = __webpack_require__(8);
  38788. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  38789. var _array = __webpack_require__(2);
  38790. var _element = __webpack_require__(0);
  38791. var _number = __webpack_require__(6);
  38792. var _eventManager = __webpack_require__(4);
  38793. var _eventManager2 = _interopRequireDefault(_eventManager);
  38794. var _plugins = __webpack_require__(5);
  38795. var _rowsMapper = __webpack_require__(364);
  38796. var _rowsMapper2 = _interopRequireDefault(_rowsMapper);
  38797. var _backlight = __webpack_require__(365);
  38798. var _backlight2 = _interopRequireDefault(_backlight);
  38799. var _guideline = __webpack_require__(366);
  38800. var _guideline2 = _interopRequireDefault(_guideline);
  38801. var _src = __webpack_require__(11);
  38802. __webpack_require__(417);
  38803. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38804. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38805. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  38806. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  38807. _pluginHooks2.default.getSingleton().register('beforeRowMove');
  38808. _pluginHooks2.default.getSingleton().register('afterRowMove');
  38809. _pluginHooks2.default.getSingleton().register('unmodifyRow');
  38810. var privatePool = new WeakMap();
  38811. var CSS_PLUGIN = 'ht__manualRowMove';
  38812. var CSS_SHOW_UI = 'show-ui';
  38813. var CSS_ON_MOVING = 'on-moving--rows';
  38814. var CSS_AFTER_SELECTION = 'after-selection--rows';
  38815. /**
  38816. * @plugin ManualRowMove
  38817. *
  38818. * @description
  38819. * This plugin allows to change rows order.
  38820. *
  38821. * API:
  38822. * - moveRow - move single row to the new position.
  38823. * - moveRows - move many rows (as an array of indexes) to the new position.
  38824. *
  38825. * If you want apply visual changes, you have to call manually the render() method on the instance of handsontable.
  38826. *
  38827. * UI components:
  38828. * - backlight - highlight of selected rows.
  38829. * - guideline - line which shows where rows has been moved.
  38830. *
  38831. * @class ManualRowMove
  38832. * @plugin ManualRowMove
  38833. */
  38834. var ManualRowMove = function (_BasePlugin) {
  38835. _inherits(ManualRowMove, _BasePlugin);
  38836. function ManualRowMove(hotInstance) {
  38837. _classCallCheck(this, ManualRowMove);
  38838. /**
  38839. * Set up WeakMap of plugin to sharing private parameters;
  38840. */
  38841. var _this = _possibleConstructorReturn(this, (ManualRowMove.__proto__ || Object.getPrototypeOf(ManualRowMove)).call(this, hotInstance));
  38842. privatePool.set(_this, {
  38843. rowsToMove: [],
  38844. pressed: void 0,
  38845. disallowMoving: void 0,
  38846. target: {
  38847. eventPageY: void 0,
  38848. coords: void 0,
  38849. TD: void 0,
  38850. row: void 0
  38851. }
  38852. });
  38853. /**
  38854. * List of last removed row indexes.
  38855. *
  38856. * @type {Array}
  38857. */
  38858. _this.removedRows = [];
  38859. /**
  38860. * Object containing visual row indexes mapped to data source indexes.
  38861. *
  38862. * @type {RowsMapper}
  38863. */
  38864. _this.rowsMapper = new _rowsMapper2.default(_this);
  38865. /**
  38866. * Event Manager object.
  38867. *
  38868. * @type {Object}
  38869. */
  38870. _this.eventManager = new _eventManager2.default(_this);
  38871. /**
  38872. * Backlight UI object.
  38873. *
  38874. * @type {Object}
  38875. */
  38876. _this.backlight = new _backlight2.default(hotInstance);
  38877. /**
  38878. * Guideline UI object.
  38879. *
  38880. * @type {Object}
  38881. */
  38882. _this.guideline = new _guideline2.default(hotInstance);
  38883. return _this;
  38884. }
  38885. /**
  38886. * Check if plugin is enabled.
  38887. *
  38888. * @returns {Boolean}
  38889. */
  38890. _createClass(ManualRowMove, [{
  38891. key: 'isEnabled',
  38892. value: function isEnabled() {
  38893. return !!this.hot.getSettings().manualRowMove;
  38894. }
  38895. /**
  38896. * Enable the plugin.
  38897. */
  38898. }, {
  38899. key: 'enablePlugin',
  38900. value: function enablePlugin() {
  38901. var _this2 = this;
  38902. if (this.enabled) {
  38903. return;
  38904. }
  38905. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  38906. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  38907. });
  38908. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  38909. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  38910. });
  38911. this.addHook('afterScrollHorizontally', function () {
  38912. return _this2.onAfterScrollHorizontally();
  38913. });
  38914. this.addHook('modifyRow', function (row, source) {
  38915. return _this2.onModifyRow(row, source);
  38916. });
  38917. this.addHook('beforeRemoveRow', function (index, amount) {
  38918. return _this2.onBeforeRemoveRow(index, amount);
  38919. });
  38920. this.addHook('afterRemoveRow', function (index, amount) {
  38921. return _this2.onAfterRemoveRow(index, amount);
  38922. });
  38923. this.addHook('afterCreateRow', function (index, amount) {
  38924. return _this2.onAfterCreateRow(index, amount);
  38925. });
  38926. this.addHook('afterLoadData', function (firstTime) {
  38927. return _this2.onAfterLoadData(firstTime);
  38928. });
  38929. this.addHook('beforeColumnSort', function (column, order) {
  38930. return _this2.onBeforeColumnSort(column, order);
  38931. });
  38932. this.addHook('unmodifyRow', function (row) {
  38933. return _this2.onUnmodifyRow(row);
  38934. });
  38935. this.registerEvents();
  38936. // TODO: move adding plugin classname to BasePlugin.
  38937. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  38938. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'enablePlugin', this).call(this);
  38939. }
  38940. /**
  38941. * Updates the plugin to use the latest options you have specified.
  38942. */
  38943. }, {
  38944. key: 'updatePlugin',
  38945. value: function updatePlugin() {
  38946. this.disablePlugin();
  38947. this.enablePlugin();
  38948. this.onAfterPluginsInitialized();
  38949. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'updatePlugin', this).call(this);
  38950. }
  38951. /**
  38952. * Disable plugin for this Handsontable instance.
  38953. */
  38954. }, {
  38955. key: 'disablePlugin',
  38956. value: function disablePlugin() {
  38957. var pluginSettings = this.hot.getSettings().manualRowMove;
  38958. if (Array.isArray(pluginSettings)) {
  38959. this.rowsMapper.clearMap();
  38960. }
  38961. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  38962. this.unregisterEvents();
  38963. this.backlight.destroy();
  38964. this.guideline.destroy();
  38965. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'disablePlugin', this).call(this);
  38966. }
  38967. /**
  38968. * Move a single row.
  38969. *
  38970. * @param {Number} row Visual row index to be moved.
  38971. * @param {Number} target Visual row index being a target for the moved row.
  38972. */
  38973. }, {
  38974. key: 'moveRow',
  38975. value: function moveRow(row, target) {
  38976. this.moveRows([row], target);
  38977. }
  38978. /**
  38979. * Move multiple rows.
  38980. *
  38981. * @param {Array} rows Array of visual row indexes to be moved.
  38982. * @param {Number} target Visual row index being a target for the moved rows.
  38983. */
  38984. }, {
  38985. key: 'moveRows',
  38986. value: function moveRows(rows, target) {
  38987. var _this3 = this;
  38988. var priv = privatePool.get(this);
  38989. var beforeMoveHook = this.hot.runHooks('beforeRowMove', rows, target);
  38990. priv.disallowMoving = beforeMoveHook === false;
  38991. if (!priv.disallowMoving) {
  38992. // first we need to rewrite an visual indexes to physical for save reference after move
  38993. (0, _array.arrayEach)(rows, function (row, index, array) {
  38994. array[index] = _this3.rowsMapper.getValueByIndex(row);
  38995. });
  38996. // next, when we have got an physical indexes, we can move rows
  38997. (0, _array.arrayEach)(rows, function (row, index) {
  38998. var actualPosition = _this3.rowsMapper.getIndexByValue(row);
  38999. if (actualPosition !== target) {
  39000. _this3.rowsMapper.moveRow(actualPosition, target + index);
  39001. }
  39002. });
  39003. // after moving we have to clear rowsMapper from null entries
  39004. this.rowsMapper.clearNull();
  39005. }
  39006. this.hot.runHooks('afterRowMove', rows, target);
  39007. }
  39008. /**
  39009. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  39010. * That means that changing the row order using the API won't correct the selection.
  39011. *
  39012. * @private
  39013. * @param {Number} startRow Visual row index for the start of the selection.
  39014. * @param {Number} endRow Visual row index for the end of the selection.
  39015. */
  39016. }, {
  39017. key: 'changeSelection',
  39018. value: function changeSelection(startRow, endRow) {
  39019. var selection = this.hot.selection;
  39020. var lastColIndex = this.hot.countCols() - 1;
  39021. selection.setRangeStartOnly(new _src.CellCoords(startRow, 0));
  39022. selection.setRangeEnd(new _src.CellCoords(endRow, lastColIndex), false);
  39023. }
  39024. /**
  39025. * Get the sum of the heights of rows in the provided range.
  39026. *
  39027. * @private
  39028. * @param {Number} from Visual row index.
  39029. * @param {Number} to Visual row index.
  39030. * @returns {Number}
  39031. */
  39032. }, {
  39033. key: 'getRowsHeight',
  39034. value: function getRowsHeight(from, to) {
  39035. var height = 0;
  39036. for (var i = from; i < to; i++) {
  39037. var rowHeight = this.hot.view.wt.wtTable.getRowHeight(i) || 23;
  39038. height += rowHeight;
  39039. }
  39040. return height;
  39041. }
  39042. /**
  39043. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  39044. *
  39045. * @private
  39046. */
  39047. }, {
  39048. key: 'initialSettings',
  39049. value: function initialSettings() {
  39050. var pluginSettings = this.hot.getSettings().manualRowMove;
  39051. if (Array.isArray(pluginSettings)) {
  39052. this.moveRows(pluginSettings, 0);
  39053. } else if (pluginSettings !== void 0) {
  39054. var persistentState = this.persistentStateLoad();
  39055. if (persistentState.length) {
  39056. this.moveRows(persistentState, 0);
  39057. }
  39058. }
  39059. }
  39060. /**
  39061. * Check if the provided row is in the fixedRowsTop section.
  39062. *
  39063. * @private
  39064. * @param {Number} row Visual row index to check.
  39065. * @returns {Boolean}
  39066. */
  39067. }, {
  39068. key: 'isFixedRowTop',
  39069. value: function isFixedRowTop(row) {
  39070. return row < this.hot.getSettings().fixedRowsTop;
  39071. }
  39072. /**
  39073. * Check if the provided row is in the fixedRowsBottom section.
  39074. *
  39075. * @private
  39076. * @param {Number} row Visual row index to check.
  39077. * @returns {Boolean}
  39078. */
  39079. }, {
  39080. key: 'isFixedRowBottom',
  39081. value: function isFixedRowBottom(row) {
  39082. return row > this.hot.getSettings().fixedRowsBottom;
  39083. }
  39084. /**
  39085. * Save the manual row positions to the persistent state.
  39086. *
  39087. * @private
  39088. */
  39089. }, {
  39090. key: 'persistentStateSave',
  39091. value: function persistentStateSave() {
  39092. this.hot.runHooks('persistentStateSave', 'manualRowMove', this.rowsMapper._arrayMap);
  39093. }
  39094. /**
  39095. * Load the manual row positions from the persistent state.
  39096. *
  39097. * @private
  39098. * @returns {Array} Stored state.
  39099. */
  39100. }, {
  39101. key: 'persistentStateLoad',
  39102. value: function persistentStateLoad() {
  39103. var storedState = {};
  39104. this.hot.runHooks('persistentStateLoad', 'manualRowMove', storedState);
  39105. return storedState.value ? storedState.value : [];
  39106. }
  39107. /**
  39108. * Prepare array of indexes based on actual selection.
  39109. *
  39110. * @private
  39111. * @returns {Array}
  39112. */
  39113. }, {
  39114. key: 'prepareRowsToMoving',
  39115. value: function prepareRowsToMoving() {
  39116. var selection = this.hot.getSelectedRange();
  39117. var selectedRows = [];
  39118. if (!selection) {
  39119. return selectedRows;
  39120. }
  39121. var from = selection.from,
  39122. to = selection.to;
  39123. var start = Math.min(from.row, to.row);
  39124. var end = Math.max(from.row, to.row);
  39125. (0, _number.rangeEach)(start, end, function (i) {
  39126. selectedRows.push(i);
  39127. });
  39128. return selectedRows;
  39129. }
  39130. /**
  39131. * Update the UI visual position.
  39132. *
  39133. * @private
  39134. */
  39135. }, {
  39136. key: 'refreshPositions',
  39137. value: function refreshPositions() {
  39138. var priv = privatePool.get(this);
  39139. var coords = priv.target.coords;
  39140. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleRow();
  39141. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleRow();
  39142. var fixedRows = this.hot.getSettings().fixedRowsTop;
  39143. var countRows = this.hot.countRows();
  39144. if (coords.row < fixedRows && firstVisible > 0) {
  39145. this.hot.scrollViewportTo(firstVisible - 1);
  39146. }
  39147. if (coords.row >= lastVisible && lastVisible < countRows) {
  39148. this.hot.scrollViewportTo(lastVisible + 1, undefined, true);
  39149. }
  39150. var wtTable = this.hot.view.wt.wtTable;
  39151. var TD = priv.target.TD;
  39152. var rootElementOffset = (0, _element.offset)(this.hot.rootElement);
  39153. var tdOffsetTop = this.hot.view.THEAD.offsetHeight + this.getRowsHeight(0, coords.row);
  39154. var mouseOffsetTop = priv.target.eventPageY - rootElementOffset.top + wtTable.holder.scrollTop;
  39155. var hiderHeight = wtTable.hider.offsetHeight;
  39156. var tbodyOffsetTop = wtTable.TBODY.offsetTop;
  39157. var backlightElemMarginTop = this.backlight.getOffset().top;
  39158. var backlightElemHeight = this.backlight.getSize().height;
  39159. if (rootElementOffset.top + wtTable.holder.offsetHeight < priv.target.eventPageY) {
  39160. priv.target.coords.row++;
  39161. }
  39162. if (this.isFixedRowTop(coords.row)) {
  39163. tdOffsetTop += wtTable.holder.scrollTop;
  39164. }
  39165. // todo: fixedRowsBottom
  39166. // if (this.isFixedRowBottom(coords.row)) {
  39167. //
  39168. // }
  39169. if (coords.row < 0) {
  39170. // if hover on colHeader
  39171. priv.target.row = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  39172. } else if (TD.offsetHeight / 2 + tdOffsetTop <= mouseOffsetTop) {
  39173. // if hover on lower part of TD
  39174. priv.target.row = coords.row + 1;
  39175. // unfortunately first row is bigger than rest
  39176. tdOffsetTop += coords.row === 0 ? TD.offsetHeight - 1 : TD.offsetHeight;
  39177. } else {
  39178. // elsewhere on table
  39179. priv.target.row = coords.row;
  39180. }
  39181. var backlightTop = mouseOffsetTop;
  39182. var guidelineTop = tdOffsetTop;
  39183. if (mouseOffsetTop + backlightElemHeight + backlightElemMarginTop >= hiderHeight) {
  39184. // prevent display backlight below table
  39185. backlightTop = hiderHeight - backlightElemHeight - backlightElemMarginTop;
  39186. } else if (mouseOffsetTop + backlightElemMarginTop < tbodyOffsetTop) {
  39187. // prevent display above below table
  39188. backlightTop = tbodyOffsetTop + Math.abs(backlightElemMarginTop);
  39189. }
  39190. if (tdOffsetTop >= hiderHeight - 1) {
  39191. // prevent display guideline below table
  39192. guidelineTop = hiderHeight - 1;
  39193. }
  39194. var topOverlayHeight = 0;
  39195. if (this.hot.view.wt.wtOverlays.topOverlay) {
  39196. topOverlayHeight = this.hot.view.wt.wtOverlays.topOverlay.clone.wtTable.TABLE.offsetHeight;
  39197. }
  39198. if (coords.row >= fixedRows && guidelineTop - wtTable.holder.scrollTop < topOverlayHeight) {
  39199. this.hot.scrollViewportTo(coords.row);
  39200. }
  39201. this.backlight.setPosition(backlightTop);
  39202. this.guideline.setPosition(guidelineTop);
  39203. }
  39204. /**
  39205. * This method checks arrayMap from rowsMapper and updates the rowsMapper if it's necessary.
  39206. *
  39207. * @private
  39208. */
  39209. }, {
  39210. key: 'updateRowsMapper',
  39211. value: function updateRowsMapper() {
  39212. var countRows = this.hot.countSourceRows();
  39213. var rowsMapperLen = this.rowsMapper._arrayMap.length;
  39214. if (rowsMapperLen === 0) {
  39215. this.rowsMapper.createMap(countRows || this.hot.getSettings().startRows);
  39216. } else if (rowsMapperLen < countRows) {
  39217. var diff = countRows - rowsMapperLen;
  39218. this.rowsMapper.insertItems(rowsMapperLen, diff);
  39219. } else if (rowsMapperLen > countRows) {
  39220. var maxIndex = countRows - 1;
  39221. var rowsToRemove = [];
  39222. (0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index, array) {
  39223. if (value > maxIndex) {
  39224. rowsToRemove.push(index);
  39225. }
  39226. });
  39227. this.rowsMapper.removeItems(rowsToRemove);
  39228. }
  39229. }
  39230. /**
  39231. * Bind the events used by the plugin.
  39232. *
  39233. * @private
  39234. */
  39235. }, {
  39236. key: 'registerEvents',
  39237. value: function registerEvents() {
  39238. var _this4 = this;
  39239. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  39240. return _this4.onMouseMove(event);
  39241. });
  39242. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  39243. return _this4.onMouseUp();
  39244. });
  39245. }
  39246. /**
  39247. * Unbind the events used by the plugin.
  39248. *
  39249. * @private
  39250. */
  39251. }, {
  39252. key: 'unregisterEvents',
  39253. value: function unregisterEvents() {
  39254. this.eventManager.clear();
  39255. }
  39256. /**
  39257. * `beforeColumnSort` hook callback. If user uses the sorting, manual row moving is disabled.
  39258. *
  39259. * @private
  39260. * @param {Number} column Column index where soring is present
  39261. * @param {*} order State of sorting. ASC/DESC/None
  39262. */
  39263. }, {
  39264. key: 'onBeforeColumnSort',
  39265. value: function onBeforeColumnSort(column, order) {
  39266. var priv = privatePool.get(this);
  39267. priv.disallowMoving = order !== void 0;
  39268. }
  39269. /**
  39270. * Change the behavior of selection / dragging.
  39271. *
  39272. * @private
  39273. * @param {MouseEvent} event
  39274. * @param {CellCoords} coords Visual coordinates.
  39275. * @param {HTMLElement} TD
  39276. * @param {Object} blockCalculations
  39277. */
  39278. }, {
  39279. key: 'onBeforeOnCellMouseDown',
  39280. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  39281. var wtTable = this.hot.view.wt.wtTable;
  39282. var isHeaderSelection = this.hot.selection.selectedHeader.rows;
  39283. var selection = this.hot.getSelectedRange();
  39284. var priv = privatePool.get(this);
  39285. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0) {
  39286. priv.pressed = false;
  39287. priv.rowsToMove.length = 0;
  39288. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  39289. return;
  39290. }
  39291. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  39292. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  39293. if (guidelineIsNotReady && backlightIsNotReady) {
  39294. this.guideline.appendTo(wtTable.hider);
  39295. this.backlight.appendTo(wtTable.hider);
  39296. }
  39297. var from = selection.from,
  39298. to = selection.to;
  39299. var start = Math.min(from.row, to.row);
  39300. var end = Math.max(from.row, to.row);
  39301. if (coords.col < 0 && coords.row >= start && coords.row <= end) {
  39302. blockCalculations.row = true;
  39303. priv.pressed = true;
  39304. priv.target.eventPageY = event.pageY;
  39305. priv.target.coords = coords;
  39306. priv.target.TD = TD;
  39307. priv.rowsToMove = this.prepareRowsToMoving();
  39308. var leftPos = wtTable.holder.scrollLeft + wtTable.getColumnWidth(-1);
  39309. this.backlight.setPosition(null, leftPos);
  39310. this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1));
  39311. this.backlight.setOffset((this.getRowsHeight(start, coords.row) + event.layerY) * -1, null);
  39312. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  39313. this.refreshPositions();
  39314. } else {
  39315. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  39316. priv.pressed = false;
  39317. priv.rowsToMove.length = 0;
  39318. }
  39319. }
  39320. /**
  39321. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  39322. *
  39323. * @private
  39324. * @param {MouseEvent} event `mousemove` event properties.
  39325. */
  39326. }, {
  39327. key: 'onMouseMove',
  39328. value: function onMouseMove(event) {
  39329. var priv = privatePool.get(this);
  39330. if (!priv.pressed) {
  39331. return;
  39332. }
  39333. // callback for browser which doesn't supports CSS pointer-event: none
  39334. if (event.realTarget === this.backlight.element) {
  39335. var height = this.backlight.getSize().height;
  39336. this.backlight.setSize(null, 0);
  39337. setTimeout(function () {
  39338. this.backlight.setPosition(null, height);
  39339. });
  39340. }
  39341. priv.target.eventPageY = event.pageY;
  39342. this.refreshPositions();
  39343. }
  39344. /**
  39345. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  39346. *
  39347. * @private
  39348. * @param {MouseEvent} event `mouseover` event properties.
  39349. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  39350. * @param {HTMLElement} TD Cell represented as HTMLElement.
  39351. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  39352. */
  39353. }, {
  39354. key: 'onBeforeOnCellMouseOver',
  39355. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  39356. var selectedRange = this.hot.getSelectedRange();
  39357. var priv = privatePool.get(this);
  39358. if (!selectedRange || !priv.pressed) {
  39359. return;
  39360. }
  39361. if (priv.rowsToMove.indexOf(coords.row) > -1) {
  39362. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  39363. } else {
  39364. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  39365. }
  39366. blockCalculations.row = true;
  39367. blockCalculations.column = true;
  39368. blockCalculations.cell = true;
  39369. priv.target.coords = coords;
  39370. priv.target.TD = TD;
  39371. }
  39372. /**
  39373. * `onMouseUp` hook callback.
  39374. *
  39375. * @private
  39376. */
  39377. }, {
  39378. key: 'onMouseUp',
  39379. value: function onMouseUp() {
  39380. var priv = privatePool.get(this);
  39381. var target = priv.target.row;
  39382. var rowsLen = priv.rowsToMove.length;
  39383. priv.pressed = false;
  39384. priv.backlightHeight = 0;
  39385. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  39386. if (this.hot.selection.selectedHeader.rows) {
  39387. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  39388. }
  39389. if (rowsLen < 1 || target === void 0 || priv.rowsToMove.indexOf(target) > -1 || priv.rowsToMove[rowsLen - 1] === target - 1) {
  39390. return;
  39391. }
  39392. this.moveRows(priv.rowsToMove, target);
  39393. this.persistentStateSave();
  39394. this.hot.render();
  39395. if (!priv.disallowMoving) {
  39396. var selectionStart = this.rowsMapper.getIndexByValue(priv.rowsToMove[0]);
  39397. var selectionEnd = this.rowsMapper.getIndexByValue(priv.rowsToMove[rowsLen - 1]);
  39398. this.changeSelection(selectionStart, selectionEnd);
  39399. }
  39400. priv.rowsToMove.length = 0;
  39401. }
  39402. /**
  39403. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  39404. *
  39405. * @private
  39406. */
  39407. }, {
  39408. key: 'onAfterScrollHorizontally',
  39409. value: function onAfterScrollHorizontally() {
  39410. var wtTable = this.hot.view.wt.wtTable;
  39411. var headerWidth = wtTable.getColumnWidth(-1);
  39412. var scrollLeft = wtTable.holder.scrollLeft;
  39413. var posLeft = headerWidth + scrollLeft;
  39414. this.backlight.setPosition(null, posLeft);
  39415. this.backlight.setSize(wtTable.hider.offsetWidth - posLeft);
  39416. }
  39417. /**
  39418. * `afterCreateRow` hook callback.
  39419. *
  39420. * @private
  39421. * @param {Number} index Visual index of the created row.
  39422. * @param {Number} amount Amount of created rows.
  39423. */
  39424. }, {
  39425. key: 'onAfterCreateRow',
  39426. value: function onAfterCreateRow(index, amount) {
  39427. this.rowsMapper.shiftItems(index, amount);
  39428. }
  39429. /**
  39430. * On before remove row listener.
  39431. *
  39432. * @private
  39433. * @param {Number} index Visual row index.
  39434. * @param {Number} amount Defines how many rows removed.
  39435. */
  39436. }, {
  39437. key: 'onBeforeRemoveRow',
  39438. value: function onBeforeRemoveRow(index, amount) {
  39439. var _this5 = this;
  39440. this.removedRows.length = 0;
  39441. if (index !== false) {
  39442. // Collect physical row index.
  39443. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  39444. _this5.removedRows.push(_this5.hot.runHooks('modifyRow', removedIndex, _this5.pluginName));
  39445. });
  39446. }
  39447. }
  39448. /**
  39449. * `afterRemoveRow` hook callback.
  39450. *
  39451. * @private
  39452. * @param {Number} index Visual index of the removed row.
  39453. * @param {Number} amount Amount of removed rows.
  39454. */
  39455. }, {
  39456. key: 'onAfterRemoveRow',
  39457. value: function onAfterRemoveRow(index, amount) {
  39458. this.rowsMapper.unshiftItems(this.removedRows);
  39459. }
  39460. /**
  39461. * `afterLoadData` hook callback.
  39462. *
  39463. * @private
  39464. * @param {Boolean} firstTime True if that was loading data during the initialization.
  39465. */
  39466. }, {
  39467. key: 'onAfterLoadData',
  39468. value: function onAfterLoadData(firstTime) {
  39469. this.updateRowsMapper();
  39470. }
  39471. /**
  39472. * 'modifyRow' hook callback.
  39473. *
  39474. * @private
  39475. * @param {Number} row Visual Row index.
  39476. * @returns {Number} Physical row index.
  39477. */
  39478. }, {
  39479. key: 'onModifyRow',
  39480. value: function onModifyRow(row, source) {
  39481. if (source !== this.pluginName) {
  39482. var rowInMapper = this.rowsMapper.getValueByIndex(row);
  39483. row = rowInMapper === null ? row : rowInMapper;
  39484. }
  39485. return row;
  39486. }
  39487. /**
  39488. * 'unmodifyRow' hook callback.
  39489. *
  39490. * @private
  39491. * @param {Number} row Physical row index.
  39492. * @returns {Number} Visual row index.
  39493. */
  39494. }, {
  39495. key: 'onUnmodifyRow',
  39496. value: function onUnmodifyRow(row) {
  39497. var indexInMapper = this.rowsMapper.getIndexByValue(row);
  39498. return indexInMapper === null ? row : indexInMapper;
  39499. }
  39500. /**
  39501. * `afterPluginsInitialized` hook callback.
  39502. *
  39503. * @private
  39504. */
  39505. }, {
  39506. key: 'onAfterPluginsInitialized',
  39507. value: function onAfterPluginsInitialized() {
  39508. this.updateRowsMapper();
  39509. this.initialSettings();
  39510. this.backlight.build();
  39511. this.guideline.build();
  39512. }
  39513. /**
  39514. * Destroy plugin instance.
  39515. */
  39516. }, {
  39517. key: 'destroy',
  39518. value: function destroy() {
  39519. this.backlight.destroy();
  39520. this.guideline.destroy();
  39521. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'destroy', this).call(this);
  39522. }
  39523. }]);
  39524. return ManualRowMove;
  39525. }(_base2.default);
  39526. (0, _plugins.registerPlugin)('ManualRowMove', ManualRowMove);
  39527. exports.default = ManualRowMove;
  39528. /***/ }),
  39529. /* 364 */
  39530. /***/ (function(module, exports, __webpack_require__) {
  39531. "use strict";
  39532. exports.__esModule = true;
  39533. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  39534. var _arrayMapper = __webpack_require__(265);
  39535. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  39536. var _array = __webpack_require__(2);
  39537. var _object = __webpack_require__(1);
  39538. var _number = __webpack_require__(6);
  39539. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39540. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39541. /**
  39542. * @class RowsMapper
  39543. * @plugin ManualRowMove
  39544. */
  39545. var RowsMapper = function () {
  39546. function RowsMapper(manualRowMove) {
  39547. _classCallCheck(this, RowsMapper);
  39548. /**
  39549. * Instance of ManualRowMove plugin.
  39550. *
  39551. * @type {ManualRowMove}
  39552. */
  39553. this.manualRowMove = manualRowMove;
  39554. }
  39555. /**
  39556. * Reset current map array and create new one.
  39557. *
  39558. * @param {Number} [length] Custom generated map length.
  39559. */
  39560. _createClass(RowsMapper, [{
  39561. key: 'createMap',
  39562. value: function createMap(length) {
  39563. var _this = this;
  39564. var originLength = length === void 0 ? this._arrayMap.length : length;
  39565. this._arrayMap.length = 0;
  39566. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  39567. _this._arrayMap[itemIndex] = itemIndex;
  39568. });
  39569. }
  39570. /**
  39571. * Destroy class.
  39572. */
  39573. }, {
  39574. key: 'destroy',
  39575. value: function destroy() {
  39576. this._arrayMap = null;
  39577. }
  39578. /**
  39579. * Moving elements in rowsMapper.
  39580. *
  39581. * @param {Number} from Row index to move.
  39582. * @param {Number} to Target index.
  39583. */
  39584. }, {
  39585. key: 'moveRow',
  39586. value: function moveRow(from, to) {
  39587. var indexToMove = this._arrayMap[from];
  39588. this._arrayMap[from] = null;
  39589. this._arrayMap.splice(to, 0, indexToMove);
  39590. }
  39591. /**
  39592. * Clearing arrayMap from `null` entries.
  39593. */
  39594. }, {
  39595. key: 'clearNull',
  39596. value: function clearNull() {
  39597. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  39598. return i !== null;
  39599. });
  39600. }
  39601. }]);
  39602. return RowsMapper;
  39603. }();
  39604. (0, _object.mixin)(RowsMapper, _arrayMapper2.default);
  39605. exports.default = RowsMapper;
  39606. /***/ }),
  39607. /* 365 */
  39608. /***/ (function(module, exports, __webpack_require__) {
  39609. "use strict";
  39610. exports.__esModule = true;
  39611. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  39612. var _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); } };
  39613. var _base = __webpack_require__(267);
  39614. var _base2 = _interopRequireDefault(_base);
  39615. var _element = __webpack_require__(0);
  39616. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39617. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39618. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  39619. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  39620. var CSS_CLASSNAME = 'ht__manualRowMove--backlight';
  39621. /**
  39622. * @class BacklightUI
  39623. * @util
  39624. */
  39625. var BacklightUI = function (_BaseUI) {
  39626. _inherits(BacklightUI, _BaseUI);
  39627. function BacklightUI() {
  39628. _classCallCheck(this, BacklightUI);
  39629. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  39630. }
  39631. _createClass(BacklightUI, [{
  39632. key: 'build',
  39633. /**
  39634. * Custom className on build process.
  39635. */
  39636. value: function build() {
  39637. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  39638. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  39639. }
  39640. }]);
  39641. return BacklightUI;
  39642. }(_base2.default);
  39643. exports.default = BacklightUI;
  39644. /***/ }),
  39645. /* 366 */
  39646. /***/ (function(module, exports, __webpack_require__) {
  39647. "use strict";
  39648. exports.__esModule = true;
  39649. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  39650. var _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); } };
  39651. var _base = __webpack_require__(267);
  39652. var _base2 = _interopRequireDefault(_base);
  39653. var _element = __webpack_require__(0);
  39654. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39655. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39656. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  39657. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  39658. var CSS_CLASSNAME = 'ht__manualRowMove--guideline';
  39659. /**
  39660. * @class GuidelineUI
  39661. * @util
  39662. */
  39663. var GuidelineUI = function (_BaseUI) {
  39664. _inherits(GuidelineUI, _BaseUI);
  39665. function GuidelineUI() {
  39666. _classCallCheck(this, GuidelineUI);
  39667. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  39668. }
  39669. _createClass(GuidelineUI, [{
  39670. key: 'build',
  39671. /**
  39672. * Custom className on build process.
  39673. */
  39674. value: function build() {
  39675. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  39676. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  39677. }
  39678. }]);
  39679. return GuidelineUI;
  39680. }(_base2.default);
  39681. exports.default = GuidelineUI;
  39682. /***/ }),
  39683. /* 367 */
  39684. /***/ (function(module, exports, __webpack_require__) {
  39685. "use strict";
  39686. exports.__esModule = true;
  39687. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  39688. var _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); } };
  39689. var _base = __webpack_require__(12);
  39690. var _base2 = _interopRequireDefault(_base);
  39691. var _element = __webpack_require__(0);
  39692. var _eventManager = __webpack_require__(4);
  39693. var _eventManager2 = _interopRequireDefault(_eventManager);
  39694. var _event = __webpack_require__(7);
  39695. var _array = __webpack_require__(2);
  39696. var _number = __webpack_require__(6);
  39697. var _plugins = __webpack_require__(5);
  39698. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39699. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39700. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  39701. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  39702. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  39703. /**
  39704. * @description
  39705. * ManualRowResize Plugin.
  39706. *
  39707. * Has 2 UI components:
  39708. * - handle - the draggable element that sets the desired height of the row.
  39709. * - guide - the helper guide that shows the desired height as a horizontal guide.
  39710. *
  39711. * @plugin ManualRowResize
  39712. */
  39713. var ManualRowResize = function (_BasePlugin) {
  39714. _inherits(ManualRowResize, _BasePlugin);
  39715. function ManualRowResize(hotInstance) {
  39716. _classCallCheck(this, ManualRowResize);
  39717. var _this = _possibleConstructorReturn(this, (ManualRowResize.__proto__ || Object.getPrototypeOf(ManualRowResize)).call(this, hotInstance));
  39718. _this.currentTH = null;
  39719. _this.currentRow = null;
  39720. _this.selectedRows = [];
  39721. _this.currentHeight = null;
  39722. _this.newSize = null;
  39723. _this.startY = null;
  39724. _this.startHeight = null;
  39725. _this.startOffset = null;
  39726. _this.handle = document.createElement('DIV');
  39727. _this.guide = document.createElement('DIV');
  39728. _this.eventManager = new _eventManager2.default(_this);
  39729. _this.pressed = null;
  39730. _this.dblclick = 0;
  39731. _this.autoresizeTimeout = null;
  39732. _this.manualRowHeights = [];
  39733. (0, _element.addClass)(_this.handle, 'manualRowResizer');
  39734. (0, _element.addClass)(_this.guide, 'manualRowResizerGuide');
  39735. return _this;
  39736. }
  39737. /**
  39738. * Check if the plugin is enabled in the handsontable settings.
  39739. *
  39740. * @returns {Boolean}
  39741. */
  39742. _createClass(ManualRowResize, [{
  39743. key: 'isEnabled',
  39744. value: function isEnabled() {
  39745. return this.hot.getSettings().manualRowResize;
  39746. }
  39747. /**
  39748. * Enable plugin for this Handsontable instance.
  39749. */
  39750. }, {
  39751. key: 'enablePlugin',
  39752. value: function enablePlugin() {
  39753. var _this2 = this;
  39754. if (this.enabled) {
  39755. return;
  39756. }
  39757. this.manualRowHeights = [];
  39758. var initialRowHeights = this.hot.getSettings().manualRowResize;
  39759. var loadedManualRowHeights = this.loadManualRowHeights();
  39760. if (typeof loadedManualRowHeights != 'undefined') {
  39761. this.manualRowHeights = loadedManualRowHeights;
  39762. } else if (Array.isArray(initialRowHeights)) {
  39763. this.manualRowHeights = initialRowHeights;
  39764. } else {
  39765. this.manualRowHeights = [];
  39766. }
  39767. this.addHook('modifyRowHeight', function (height, row) {
  39768. return _this2.onModifyRowHeight(height, row);
  39769. });
  39770. // Handsontable.hooks.register('beforeRowResize');
  39771. // Handsontable.hooks.register('afterRowResize');
  39772. this.bindEvents();
  39773. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'enablePlugin', this).call(this);
  39774. }
  39775. /**
  39776. * Updates the plugin to use the latest options you have specified.
  39777. */
  39778. }, {
  39779. key: 'updatePlugin',
  39780. value: function updatePlugin() {
  39781. var initialRowHeights = this.hot.getSettings().manualRowResize;
  39782. if (Array.isArray(initialRowHeights)) {
  39783. this.manualRowHeights = initialRowHeights;
  39784. } else if (!initialRowHeights) {
  39785. this.manualRowHeights = [];
  39786. }
  39787. }
  39788. /**
  39789. * Disable plugin for this Handsontable instance.
  39790. */
  39791. }, {
  39792. key: 'disablePlugin',
  39793. value: function disablePlugin() {
  39794. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'disablePlugin', this).call(this);
  39795. }
  39796. /**
  39797. * Save the current sizes using the persistentState plugin.
  39798. */
  39799. }, {
  39800. key: 'saveManualRowHeights',
  39801. value: function saveManualRowHeights() {
  39802. this.hot.runHooks('persistentStateSave', 'manualRowHeights', this.manualRowHeights);
  39803. }
  39804. /**
  39805. * Load the previously saved sizes using the persistentState plugin.
  39806. *
  39807. * @returns {Array}
  39808. */
  39809. }, {
  39810. key: 'loadManualRowHeights',
  39811. value: function loadManualRowHeights() {
  39812. var storedState = {};
  39813. this.hot.runHooks('persistentStateLoad', 'manualRowHeights', storedState);
  39814. return storedState.value;
  39815. }
  39816. /**
  39817. * Set the resize handle position.
  39818. *
  39819. * @param {HTMLCellElement} TH TH HTML element.
  39820. */
  39821. }, {
  39822. key: 'setupHandlePosition',
  39823. value: function setupHandlePosition(TH) {
  39824. var _this3 = this;
  39825. this.currentTH = TH;
  39826. var row = this.hot.view.wt.wtTable.getCoords(TH).row; // getCoords returns CellCoords
  39827. var headerWidth = (0, _element.outerWidth)(this.currentTH);
  39828. if (row >= 0) {
  39829. // if not col header
  39830. var box = this.currentTH.getBoundingClientRect();
  39831. this.currentRow = row;
  39832. this.selectedRows = [];
  39833. if (this.hot.selection.isSelected() && this.hot.selection.selectedHeader.rows) {
  39834. var _hot$getSelectedRange = this.hot.getSelectedRange(),
  39835. from = _hot$getSelectedRange.from,
  39836. to = _hot$getSelectedRange.to;
  39837. var start = from.row;
  39838. var end = to.row;
  39839. if (start >= end) {
  39840. start = to.row;
  39841. end = from.row;
  39842. }
  39843. if (this.currentRow >= start && this.currentRow <= end) {
  39844. (0, _number.rangeEach)(start, end, function (i) {
  39845. return _this3.selectedRows.push(i);
  39846. });
  39847. } else {
  39848. this.selectedRows.push(this.currentRow);
  39849. }
  39850. } else {
  39851. this.selectedRows.push(this.currentRow);
  39852. }
  39853. this.startOffset = box.top - 6;
  39854. this.startHeight = parseInt(box.height, 10);
  39855. this.handle.style.left = box.left + 'px';
  39856. this.handle.style.top = this.startOffset + this.startHeight + 'px';
  39857. this.handle.style.width = headerWidth + 'px';
  39858. this.hot.rootElement.appendChild(this.handle);
  39859. }
  39860. }
  39861. /**
  39862. * Refresh the resize handle position.
  39863. */
  39864. }, {
  39865. key: 'refreshHandlePosition',
  39866. value: function refreshHandlePosition() {
  39867. this.handle.style.top = this.startOffset + this.currentHeight + 'px';
  39868. }
  39869. /**
  39870. * Set the resize guide position.
  39871. */
  39872. }, {
  39873. key: 'setupGuidePosition',
  39874. value: function setupGuidePosition() {
  39875. var handleWidth = parseInt((0, _element.outerWidth)(this.handle), 10);
  39876. var handleRightPosition = parseInt(this.handle.style.left, 10) + handleWidth;
  39877. var maximumVisibleElementWidth = parseInt(this.hot.view.maximumVisibleElementWidth(0), 10);
  39878. (0, _element.addClass)(this.handle, 'active');
  39879. (0, _element.addClass)(this.guide, 'active');
  39880. this.guide.style.top = this.handle.style.top;
  39881. this.guide.style.left = handleRightPosition + 'px';
  39882. this.guide.style.width = maximumVisibleElementWidth - handleWidth + 'px';
  39883. this.hot.rootElement.appendChild(this.guide);
  39884. }
  39885. /**
  39886. * Refresh the resize guide position.
  39887. */
  39888. }, {
  39889. key: 'refreshGuidePosition',
  39890. value: function refreshGuidePosition() {
  39891. this.guide.style.top = this.handle.style.top;
  39892. }
  39893. /**
  39894. * Hide both the resize handle and resize guide.
  39895. */
  39896. }, {
  39897. key: 'hideHandleAndGuide',
  39898. value: function hideHandleAndGuide() {
  39899. (0, _element.removeClass)(this.handle, 'active');
  39900. (0, _element.removeClass)(this.guide, 'active');
  39901. }
  39902. /**
  39903. * Check if provided element is considered as a row header.
  39904. *
  39905. * @param {HTMLElement} element HTML element.
  39906. * @returns {Boolean}
  39907. */
  39908. }, {
  39909. key: 'checkIfRowHeader',
  39910. value: function checkIfRowHeader(element) {
  39911. if (element != this.hot.rootElement) {
  39912. var parent = element.parentNode;
  39913. if (parent.tagName === 'TBODY') {
  39914. return true;
  39915. }
  39916. return this.checkIfRowHeader(parent);
  39917. }
  39918. return false;
  39919. }
  39920. /**
  39921. * Get the TH element from the provided element.
  39922. *
  39923. * @param {HTMLElement} element HTML element.
  39924. * @returns {HTMLElement}
  39925. */
  39926. }, {
  39927. key: 'getTHFromTargetElement',
  39928. value: function getTHFromTargetElement(element) {
  39929. if (element.tagName != 'TABLE') {
  39930. if (element.tagName == 'TH') {
  39931. return element;
  39932. }
  39933. return this.getTHFromTargetElement(element.parentNode);
  39934. }
  39935. return null;
  39936. }
  39937. /**
  39938. * 'mouseover' event callback - set the handle position.
  39939. *
  39940. * @private
  39941. * @param {MouseEvent} event
  39942. */
  39943. }, {
  39944. key: 'onMouseOver',
  39945. value: function onMouseOver(event) {
  39946. if (this.checkIfRowHeader(event.target)) {
  39947. var th = this.getTHFromTargetElement(event.target);
  39948. if (th) {
  39949. if (!this.pressed) {
  39950. this.setupHandlePosition(th);
  39951. }
  39952. }
  39953. }
  39954. }
  39955. /**
  39956. * Auto-size row after doubleclick - callback.
  39957. *
  39958. * @private
  39959. */
  39960. }, {
  39961. key: 'afterMouseDownTimeout',
  39962. value: function afterMouseDownTimeout() {
  39963. var _this4 = this;
  39964. var render = function render() {
  39965. _this4.hot.forceFullRender = true;
  39966. _this4.hot.view.render(); // updates all
  39967. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  39968. };
  39969. var resize = function resize(selectedRow, forceRender) {
  39970. var hookNewSize = _this4.hot.runHooks('beforeRowResize', selectedRow, _this4.newSize, true);
  39971. if (hookNewSize !== void 0) {
  39972. _this4.newSize = hookNewSize;
  39973. }
  39974. _this4.setManualSize(selectedRow, _this4.newSize); // double click sets auto row size
  39975. if (forceRender) {
  39976. render();
  39977. }
  39978. _this4.hot.runHooks('afterRowResize', selectedRow, _this4.newSize, true);
  39979. };
  39980. if (this.dblclick >= 2) {
  39981. var selectedRowsLength = this.selectedRows.length;
  39982. if (selectedRowsLength > 1) {
  39983. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  39984. resize(selectedRow);
  39985. });
  39986. render();
  39987. } else {
  39988. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  39989. resize(selectedRow, true);
  39990. });
  39991. }
  39992. }
  39993. this.dblclick = 0;
  39994. this.autoresizeTimeout = null;
  39995. }
  39996. /**
  39997. * 'mousedown' event callback.
  39998. *
  39999. * @private
  40000. * @param {MouseEvent} event
  40001. */
  40002. }, {
  40003. key: 'onMouseDown',
  40004. value: function onMouseDown(event) {
  40005. var _this5 = this;
  40006. if ((0, _element.hasClass)(event.target, 'manualRowResizer')) {
  40007. this.setupGuidePosition();
  40008. this.pressed = this.hot;
  40009. if (this.autoresizeTimeout == null) {
  40010. this.autoresizeTimeout = setTimeout(function () {
  40011. return _this5.afterMouseDownTimeout();
  40012. }, 500);
  40013. this.hot._registerTimeout(this.autoresizeTimeout);
  40014. }
  40015. this.dblclick++;
  40016. this.startY = (0, _event.pageY)(event);
  40017. this.newSize = this.startHeight;
  40018. }
  40019. }
  40020. /**
  40021. * 'mousemove' event callback - refresh the handle and guide positions, cache the new row height.
  40022. *
  40023. * @private
  40024. * @param {MouseEvent} event
  40025. */
  40026. }, {
  40027. key: 'onMouseMove',
  40028. value: function onMouseMove(event) {
  40029. var _this6 = this;
  40030. if (this.pressed) {
  40031. this.currentHeight = this.startHeight + ((0, _event.pageY)(event) - this.startY);
  40032. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  40033. _this6.newSize = _this6.setManualSize(selectedRow, _this6.currentHeight);
  40034. });
  40035. this.refreshHandlePosition();
  40036. this.refreshGuidePosition();
  40037. }
  40038. }
  40039. /**
  40040. * 'mouseup' event callback - apply the row resizing.
  40041. *
  40042. * @private
  40043. * @param {MouseEvent} event
  40044. */
  40045. }, {
  40046. key: 'onMouseUp',
  40047. value: function onMouseUp(event) {
  40048. var _this7 = this;
  40049. var render = function render() {
  40050. _this7.hot.forceFullRender = true;
  40051. _this7.hot.view.render(); // updates all
  40052. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  40053. };
  40054. var runHooks = function runHooks(selectedRow, forceRender) {
  40055. _this7.hot.runHooks('beforeRowResize', selectedRow, _this7.newSize);
  40056. if (forceRender) {
  40057. render();
  40058. }
  40059. _this7.saveManualRowHeights();
  40060. _this7.hot.runHooks('afterRowResize', selectedRow, _this7.newSize);
  40061. };
  40062. if (this.pressed) {
  40063. this.hideHandleAndGuide();
  40064. this.pressed = false;
  40065. if (this.newSize != this.startHeight) {
  40066. var selectedRowsLength = this.selectedRows.length;
  40067. if (selectedRowsLength > 1) {
  40068. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  40069. runHooks(selectedRow);
  40070. });
  40071. render();
  40072. } else {
  40073. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  40074. runHooks(selectedRow, true);
  40075. });
  40076. }
  40077. }
  40078. this.setupHandlePosition(this.currentTH);
  40079. }
  40080. }
  40081. /**
  40082. * Bind the mouse events.
  40083. *
  40084. * @private
  40085. */
  40086. }, {
  40087. key: 'bindEvents',
  40088. value: function bindEvents() {
  40089. var _this8 = this;
  40090. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  40091. return _this8.onMouseOver(e);
  40092. });
  40093. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  40094. return _this8.onMouseDown(e);
  40095. });
  40096. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  40097. return _this8.onMouseMove(e);
  40098. });
  40099. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  40100. return _this8.onMouseUp(e);
  40101. });
  40102. }
  40103. /**
  40104. * Cache the current row height.
  40105. *
  40106. * @param {Number} row Visual row index.
  40107. * @param {Number} height Row height.
  40108. * @returns {Number}
  40109. */
  40110. }, {
  40111. key: 'setManualSize',
  40112. value: function setManualSize(row, height) {
  40113. row = this.hot.runHooks('modifyRow', row);
  40114. this.manualRowHeights[row] = height;
  40115. return height;
  40116. }
  40117. /**
  40118. * Modify the provided row height, based on the plugin settings.
  40119. *
  40120. * @private
  40121. * @param {Number} height Row height.
  40122. * @param {Number} row Visual row index.
  40123. * @returns {Number}
  40124. */
  40125. }, {
  40126. key: 'onModifyRowHeight',
  40127. value: function onModifyRowHeight(height, row) {
  40128. if (this.enabled) {
  40129. var autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
  40130. var autoRowHeightResult = autoRowSizePlugin ? autoRowSizePlugin.heights[row] : null;
  40131. row = this.hot.runHooks('modifyRow', row);
  40132. var manualRowHeight = this.manualRowHeights[row];
  40133. if (manualRowHeight !== void 0 && (manualRowHeight === autoRowHeightResult || manualRowHeight > (height || 0))) {
  40134. return manualRowHeight;
  40135. }
  40136. }
  40137. return height;
  40138. }
  40139. }]);
  40140. return ManualRowResize;
  40141. }(_base2.default);
  40142. (0, _plugins.registerPlugin)('manualRowResize', ManualRowResize);
  40143. exports.default = ManualRowResize;
  40144. /***/ }),
  40145. /* 368 */
  40146. /***/ (function(module, exports, __webpack_require__) {
  40147. "use strict";
  40148. exports.__esModule = true;
  40149. var _pluginHooks = __webpack_require__(8);
  40150. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  40151. var _plugins = __webpack_require__(5);
  40152. var _event = __webpack_require__(7);
  40153. var _src = __webpack_require__(11);
  40154. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40155. function CellInfoCollection() {
  40156. var collection = [];
  40157. collection.getInfo = function (row, col) {
  40158. for (var i = 0, ilen = this.length; i < ilen; i++) {
  40159. 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) {
  40160. return this[i];
  40161. }
  40162. }
  40163. };
  40164. collection.setInfo = function (info) {
  40165. for (var i = 0, ilen = this.length; i < ilen; i++) {
  40166. if (this[i].row === info.row && this[i].col === info.col) {
  40167. this[i] = info;
  40168. return;
  40169. }
  40170. }
  40171. this.push(info);
  40172. };
  40173. collection.removeInfo = function (row, col) {
  40174. for (var i = 0, ilen = this.length; i < ilen; i++) {
  40175. if (this[i].row === row && this[i].col === col) {
  40176. this.splice(i, 1);
  40177. break;
  40178. }
  40179. }
  40180. };
  40181. return collection;
  40182. }
  40183. /**
  40184. * Plugin used to merge cells in Handsontable.
  40185. *
  40186. * @private
  40187. * @plugin MergeCells
  40188. * @class MergeCells
  40189. */
  40190. function MergeCells(mergeCellsSetting) {
  40191. this.mergedCellInfoCollection = new CellInfoCollection();
  40192. if (Array.isArray(mergeCellsSetting)) {
  40193. for (var i = 0, ilen = mergeCellsSetting.length; i < ilen; i++) {
  40194. this.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
  40195. }
  40196. }
  40197. }
  40198. /**
  40199. * @param cellRange (CellRange)
  40200. */
  40201. MergeCells.prototype.canMergeRange = function (cellRange) {
  40202. // is more than one cell selected
  40203. return !cellRange.isSingle();
  40204. };
  40205. MergeCells.prototype.mergeRange = function (cellRange) {
  40206. if (!this.canMergeRange(cellRange)) {
  40207. return;
  40208. }
  40209. // normalize top left corner
  40210. var topLeft = cellRange.getTopLeftCorner();
  40211. var bottomRight = cellRange.getBottomRightCorner();
  40212. var mergeParent = {};
  40213. mergeParent.row = topLeft.row;
  40214. mergeParent.col = topLeft.col;
  40215. // TD has rowspan == 1 by default. rowspan == 2 means spread over 2 cells
  40216. mergeParent.rowspan = bottomRight.row - topLeft.row + 1;
  40217. mergeParent.colspan = bottomRight.col - topLeft.col + 1;
  40218. this.mergedCellInfoCollection.setInfo(mergeParent);
  40219. };
  40220. MergeCells.prototype.mergeOrUnmergeSelection = function (cellRange) {
  40221. var info = this.mergedCellInfoCollection.getInfo(cellRange.from.row, cellRange.from.col);
  40222. if (info) {
  40223. // unmerge
  40224. this.unmergeSelection(cellRange.from);
  40225. } else {
  40226. // merge
  40227. this.mergeSelection(cellRange);
  40228. }
  40229. };
  40230. MergeCells.prototype.mergeSelection = function (cellRange) {
  40231. this.mergeRange(cellRange);
  40232. };
  40233. MergeCells.prototype.unmergeSelection = function (cellRange) {
  40234. var info = this.mergedCellInfoCollection.getInfo(cellRange.row, cellRange.col);
  40235. this.mergedCellInfoCollection.removeInfo(info.row, info.col);
  40236. };
  40237. MergeCells.prototype.applySpanProperties = function (TD, row, col) {
  40238. var info = this.mergedCellInfoCollection.getInfo(row, col);
  40239. if (info) {
  40240. if (info.row === row && info.col === col) {
  40241. TD.setAttribute('rowspan', info.rowspan);
  40242. TD.setAttribute('colspan', info.colspan);
  40243. } else {
  40244. TD.removeAttribute('rowspan');
  40245. TD.removeAttribute('colspan');
  40246. TD.style.display = 'none';
  40247. }
  40248. } else {
  40249. TD.removeAttribute('rowspan');
  40250. TD.removeAttribute('colspan');
  40251. }
  40252. };
  40253. MergeCells.prototype.modifyTransform = function (hook, currentSelectedRange, delta) {
  40254. var sameRowspan = function sameRowspan(merged, coords) {
  40255. if (coords.row >= merged.row && coords.row <= merged.row + merged.rowspan - 1) {
  40256. return true;
  40257. }
  40258. return false;
  40259. },
  40260. sameColspan = function sameColspan(merged, coords) {
  40261. if (coords.col >= merged.col && coords.col <= merged.col + merged.colspan - 1) {
  40262. return true;
  40263. }
  40264. return false;
  40265. },
  40266. getNextPosition = function getNextPosition(newDelta) {
  40267. return new _src.CellCoords(currentSelectedRange.to.row + newDelta.row, currentSelectedRange.to.col + newDelta.col);
  40268. };
  40269. var newDelta = {
  40270. row: delta.row,
  40271. col: delta.col
  40272. };
  40273. if (hook == 'modifyTransformStart') {
  40274. /* eslint-disable block-scoped-var */
  40275. var nextPosition;
  40276. if (!this.lastDesiredCoords) {
  40277. this.lastDesiredCoords = new _src.CellCoords(null, null);
  40278. }
  40279. var currentPosition = new _src.CellCoords(currentSelectedRange.highlight.row, currentSelectedRange.highlight.col),
  40280. // if current position's parent is a merged range, returns it
  40281. mergedParent = this.mergedCellInfoCollection.getInfo(currentPosition.row, currentPosition.col),
  40282. currentRangeContainsMerge; // if current range contains a merged range
  40283. for (var i = 0, mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
  40284. var range = this.mergedCellInfoCollection[i];
  40285. range = new _src.CellCoords(range.row + range.rowspan - 1, range.col + range.colspan - 1);
  40286. if (currentSelectedRange.includes(range)) {
  40287. currentRangeContainsMerge = true;
  40288. break;
  40289. }
  40290. }
  40291. if (mergedParent) {
  40292. // only merge selected
  40293. var mergeTopLeft = new _src.CellCoords(mergedParent.row, mergedParent.col);
  40294. var mergeBottomRight = new _src.CellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
  40295. var mergeRange = new _src.CellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
  40296. if (!mergeRange.includes(this.lastDesiredCoords)) {
  40297. this.lastDesiredCoords = new _src.CellCoords(null, null); // reset outdated version of lastDesiredCoords
  40298. }
  40299. newDelta.row = this.lastDesiredCoords.row ? this.lastDesiredCoords.row - currentPosition.row : newDelta.row;
  40300. newDelta.col = this.lastDesiredCoords.col ? this.lastDesiredCoords.col - currentPosition.col : newDelta.col;
  40301. if (delta.row > 0) {
  40302. // moving down
  40303. newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
  40304. } else if (delta.row < 0) {
  40305. // moving up
  40306. newDelta.row = currentPosition.row - mergedParent.row + delta.row;
  40307. }
  40308. if (delta.col > 0) {
  40309. // moving right
  40310. newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
  40311. } else if (delta.col < 0) {
  40312. // moving left
  40313. newDelta.col = currentPosition.col - mergedParent.col + delta.col;
  40314. }
  40315. }
  40316. nextPosition = new _src.CellCoords(currentSelectedRange.highlight.row + newDelta.row, currentSelectedRange.highlight.col + newDelta.col);
  40317. var nextParentIsMerged = this.mergedCellInfoCollection.getInfo(nextPosition.row, nextPosition.col);
  40318. if (nextParentIsMerged) {
  40319. // skipping the invisible cells in the merge range
  40320. this.lastDesiredCoords = nextPosition;
  40321. newDelta = {
  40322. row: nextParentIsMerged.row - currentPosition.row,
  40323. col: nextParentIsMerged.col - currentPosition.col
  40324. };
  40325. }
  40326. } else if (hook == 'modifyTransformEnd') {
  40327. for (var _i = 0, _mergesLength = this.mergedCellInfoCollection.length; _i < _mergesLength; _i++) {
  40328. var currentMerge = this.mergedCellInfoCollection[_i];
  40329. var _mergeTopLeft = new _src.CellCoords(currentMerge.row, currentMerge.col);
  40330. var _mergeBottomRight = new _src.CellCoords(currentMerge.row + currentMerge.rowspan - 1, currentMerge.col + currentMerge.colspan - 1);
  40331. var mergedRange = new _src.CellRange(_mergeTopLeft, _mergeTopLeft, _mergeBottomRight);
  40332. var sharedBorders = currentSelectedRange.getBordersSharedWith(mergedRange);
  40333. if (mergedRange.isEqual(currentSelectedRange)) {
  40334. // only the merged range is selected
  40335. currentSelectedRange.setDirection('NW-SE');
  40336. } else if (sharedBorders.length > 0) {
  40337. var mergeHighlighted = currentSelectedRange.highlight.isEqual(mergedRange.from);
  40338. if (sharedBorders.indexOf('top') > -1) {
  40339. // if range shares a border with the merged section, change range direction accordingly
  40340. if (currentSelectedRange.to.isSouthEastOf(mergedRange.from) && mergeHighlighted) {
  40341. currentSelectedRange.setDirection('NW-SE');
  40342. } else if (currentSelectedRange.to.isSouthWestOf(mergedRange.from) && mergeHighlighted) {
  40343. currentSelectedRange.setDirection('NE-SW');
  40344. }
  40345. } else if (sharedBorders.indexOf('bottom') > -1) {
  40346. if (currentSelectedRange.to.isNorthEastOf(mergedRange.from) && mergeHighlighted) {
  40347. currentSelectedRange.setDirection('SW-NE');
  40348. } else if (currentSelectedRange.to.isNorthWestOf(mergedRange.from) && mergeHighlighted) {
  40349. currentSelectedRange.setDirection('SE-NW');
  40350. }
  40351. }
  40352. }
  40353. nextPosition = getNextPosition(newDelta);
  40354. var withinRowspan = sameRowspan(currentMerge, nextPosition),
  40355. withinColspan = sameColspan(currentMerge, nextPosition);
  40356. if (currentSelectedRange.includesRange(mergedRange) && (mergedRange.includes(nextPosition) || withinRowspan || withinColspan)) {
  40357. // if next step overlaps a merged range, jump past it
  40358. if (withinRowspan) {
  40359. if (newDelta.row < 0) {
  40360. newDelta.row -= currentMerge.rowspan - 1;
  40361. } else if (newDelta.row > 0) {
  40362. newDelta.row += currentMerge.rowspan - 1;
  40363. }
  40364. }
  40365. if (withinColspan) {
  40366. if (newDelta.col < 0) {
  40367. newDelta.col -= currentMerge.colspan - 1;
  40368. } else if (newDelta.col > 0) {
  40369. newDelta.col += currentMerge.colspan - 1;
  40370. }
  40371. }
  40372. }
  40373. }
  40374. }
  40375. if (newDelta.row !== 0) {
  40376. delta.row = newDelta.row;
  40377. }
  40378. if (newDelta.col !== 0) {
  40379. delta.col = newDelta.col;
  40380. }
  40381. };
  40382. MergeCells.prototype.shiftCollection = function (direction, index, count) {
  40383. var shiftVector = [0, 0];
  40384. switch (direction) {
  40385. case 'right':
  40386. shiftVector[0] += 1;
  40387. break;
  40388. case 'left':
  40389. shiftVector[0] -= 1;
  40390. break;
  40391. case 'down':
  40392. shiftVector[1] += 1;
  40393. break;
  40394. case 'up':
  40395. shiftVector[1] -= 1;
  40396. break;
  40397. default:
  40398. break;
  40399. }
  40400. for (var i = 0; i < this.mergedCellInfoCollection.length; i++) {
  40401. var currentMerge = this.mergedCellInfoCollection[i];
  40402. if (direction === 'right' || direction === 'left') {
  40403. if (index <= currentMerge.col) {
  40404. currentMerge.col += shiftVector[0];
  40405. }
  40406. } else if (index <= currentMerge.row) {
  40407. currentMerge.row += shiftVector[1];
  40408. }
  40409. }
  40410. };
  40411. var beforeInit = function beforeInit() {
  40412. var instance = this;
  40413. var mergeCellsSetting = instance.getSettings().mergeCells;
  40414. if (mergeCellsSetting) {
  40415. if (!instance.mergeCells) {
  40416. instance.mergeCells = new MergeCells(mergeCellsSetting);
  40417. }
  40418. }
  40419. };
  40420. var afterInit = function afterInit() {
  40421. var instance = this;
  40422. if (instance.mergeCells) {
  40423. /**
  40424. * Monkey patch Table.prototype.getCell to return TD for merged cell parent if asked for TD of a cell that is
  40425. * 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!
  40426. */
  40427. instance.view.wt.wtTable.getCell = function (coords) {
  40428. if (instance.getSettings().mergeCells) {
  40429. var mergeParent = instance.mergeCells.mergedCellInfoCollection.getInfo(coords.row, coords.col);
  40430. if (mergeParent) {
  40431. coords = mergeParent;
  40432. }
  40433. }
  40434. return _src.Table.prototype.getCell.call(this, coords);
  40435. };
  40436. }
  40437. };
  40438. var afterUpdateSettings = function afterUpdateSettings() {
  40439. var instance = this;
  40440. var mergeCellsSetting = instance.getSettings().mergeCells;
  40441. if (mergeCellsSetting) {
  40442. if (instance.mergeCells) {
  40443. instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection();
  40444. if (Array.isArray(mergeCellsSetting)) {
  40445. for (var i = 0, ilen = mergeCellsSetting.length; i < ilen; i++) {
  40446. instance.mergeCells.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
  40447. }
  40448. }
  40449. } else {
  40450. instance.mergeCells = new MergeCells(mergeCellsSetting);
  40451. }
  40452. } else if (instance.mergeCells) {
  40453. // it doesn't actually turn off the plugin, just resets the settings. Need to refactor.
  40454. instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection();
  40455. }
  40456. };
  40457. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  40458. if (!this.mergeCells) {
  40459. return;
  40460. }
  40461. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  40462. if (ctrlDown) {
  40463. if (event.keyCode === 77) {
  40464. // CTRL + M
  40465. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  40466. this.render();
  40467. (0, _event.stopImmediatePropagation)(event);
  40468. }
  40469. }
  40470. };
  40471. var addMergeActionsToContextMenu = function addMergeActionsToContextMenu(defaultOptions) {
  40472. if (!this.getSettings().mergeCells) {
  40473. return;
  40474. }
  40475. defaultOptions.items.push({ name: '---------' });
  40476. defaultOptions.items.push({
  40477. key: 'mergeCells',
  40478. name: function name() {
  40479. var sel = this.getSelected();
  40480. var info = this.mergeCells.mergedCellInfoCollection.getInfo(sel[0], sel[1]);
  40481. if (info) {
  40482. return 'Unmerge cells';
  40483. }
  40484. return 'Merge cells';
  40485. },
  40486. callback: function callback() {
  40487. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  40488. this.render();
  40489. },
  40490. disabled: function disabled() {
  40491. return this.selection.selectedHeader.corner;
  40492. }
  40493. });
  40494. };
  40495. var afterRenderer = function afterRenderer(TD, row, col, prop, value, cellProperties) {
  40496. if (this.mergeCells) {
  40497. this.mergeCells.applySpanProperties(TD, row, col);
  40498. }
  40499. };
  40500. var modifyTransformFactory = function modifyTransformFactory(hook) {
  40501. return function (delta) {
  40502. var mergeCellsSetting = this.getSettings().mergeCells;
  40503. if (mergeCellsSetting) {
  40504. var currentSelectedRange = this.getSelectedRange();
  40505. this.mergeCells.modifyTransform(hook, currentSelectedRange, delta);
  40506. if (hook === 'modifyTransformEnd') {
  40507. // sanitize "from" (core.js will sanitize to)
  40508. var totalRows = this.countRows();
  40509. var totalCols = this.countCols();
  40510. if (currentSelectedRange.from.row < 0) {
  40511. currentSelectedRange.from.row = 0;
  40512. } else if (currentSelectedRange.from.row > 0 && currentSelectedRange.from.row >= totalRows) {
  40513. currentSelectedRange.from.row = currentSelectedRange.from - 1;
  40514. }
  40515. if (currentSelectedRange.from.col < 0) {
  40516. currentSelectedRange.from.col = 0;
  40517. } else if (currentSelectedRange.from.col > 0 && currentSelectedRange.from.col >= totalCols) {
  40518. currentSelectedRange.from.col = totalCols - 1;
  40519. }
  40520. }
  40521. }
  40522. };
  40523. };
  40524. /**
  40525. * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the merged cell
  40526. * @param coords
  40527. */
  40528. var beforeSetRangeEnd = function beforeSetRangeEnd(coords) {
  40529. this.lastDesiredCoords = null; // unset lastDesiredCoords when selection is changed with mouse
  40530. var mergeCellsSetting = this.getSettings().mergeCells;
  40531. if (mergeCellsSetting) {
  40532. var selRange = this.getSelectedRange();
  40533. selRange.highlight = new _src.CellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
  40534. selRange.to = coords;
  40535. var rangeExpanded = false;
  40536. do {
  40537. rangeExpanded = false;
  40538. for (var i = 0, ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  40539. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  40540. var mergedCellTopLeft = new _src.CellCoords(cellInfo.row, cellInfo.col);
  40541. var mergedCellBottomRight = new _src.CellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  40542. var mergedCellRange = new _src.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  40543. if (selRange.expandByRange(mergedCellRange)) {
  40544. coords.row = selRange.to.row;
  40545. coords.col = selRange.to.col;
  40546. rangeExpanded = true;
  40547. }
  40548. }
  40549. } while (rangeExpanded);
  40550. }
  40551. };
  40552. /**
  40553. * Returns correct coordinates for merged start / end cells in selection for area borders
  40554. * @param corners
  40555. * @param className
  40556. */
  40557. var beforeDrawAreaBorders = function beforeDrawAreaBorders(corners, className) {
  40558. if (className && className == 'area') {
  40559. var mergeCellsSetting = this.getSettings().mergeCells;
  40560. if (mergeCellsSetting) {
  40561. var selRange = this.getSelectedRange();
  40562. var startRange = new _src.CellRange(selRange.from, selRange.from, selRange.from);
  40563. var stopRange = new _src.CellRange(selRange.to, selRange.to, selRange.to);
  40564. for (var i = 0, ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  40565. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  40566. var mergedCellTopLeft = new _src.CellCoords(cellInfo.row, cellInfo.col);
  40567. var mergedCellBottomRight = new _src.CellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  40568. var mergedCellRange = new _src.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  40569. if (startRange.expandByRange(mergedCellRange)) {
  40570. corners[0] = startRange.from.row;
  40571. corners[1] = startRange.from.col;
  40572. }
  40573. if (stopRange.expandByRange(mergedCellRange)) {
  40574. corners[2] = stopRange.from.row;
  40575. corners[3] = stopRange.from.col;
  40576. }
  40577. }
  40578. }
  40579. }
  40580. };
  40581. var afterGetCellMeta = function afterGetCellMeta(row, col, cellProperties) {
  40582. var mergeCellsSetting = this.getSettings().mergeCells;
  40583. if (mergeCellsSetting) {
  40584. var mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(row, col);
  40585. if (mergeParent && (mergeParent.row != row || mergeParent.col != col)) {
  40586. cellProperties.copyable = false;
  40587. }
  40588. }
  40589. };
  40590. var afterViewportRowCalculatorOverride = function afterViewportRowCalculatorOverride(calc) {
  40591. var mergeCellsSetting = this.getSettings().mergeCells;
  40592. if (mergeCellsSetting) {
  40593. var colCount = this.countCols();
  40594. var mergeParent;
  40595. for (var c = 0; c < colCount; c++) {
  40596. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.startRow, c);
  40597. if (mergeParent) {
  40598. if (mergeParent.row < calc.startRow) {
  40599. calc.startRow = mergeParent.row;
  40600. return afterViewportRowCalculatorOverride.call(this, calc); // recursively search upwards
  40601. }
  40602. }
  40603. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.endRow, c);
  40604. if (mergeParent) {
  40605. var mergeEnd = mergeParent.row + mergeParent.rowspan - 1;
  40606. if (mergeEnd > calc.endRow) {
  40607. calc.endRow = mergeEnd;
  40608. return afterViewportRowCalculatorOverride.call(this, calc); // recursively search upwards
  40609. }
  40610. }
  40611. }
  40612. }
  40613. };
  40614. var afterViewportColumnCalculatorOverride = function afterViewportColumnCalculatorOverride(calc) {
  40615. var mergeCellsSetting = this.getSettings().mergeCells;
  40616. if (mergeCellsSetting) {
  40617. var rowCount = this.countRows();
  40618. var mergeParent;
  40619. for (var r = 0; r < rowCount; r++) {
  40620. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.startColumn);
  40621. if (mergeParent) {
  40622. if (mergeParent.col < calc.startColumn) {
  40623. calc.startColumn = mergeParent.col;
  40624. return afterViewportColumnCalculatorOverride.call(this, calc); // recursively search upwards
  40625. }
  40626. }
  40627. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.endColumn);
  40628. if (mergeParent) {
  40629. var mergeEnd = mergeParent.col + mergeParent.colspan - 1;
  40630. if (mergeEnd > calc.endColumn) {
  40631. calc.endColumn = mergeEnd;
  40632. return afterViewportColumnCalculatorOverride.call(this, calc); // recursively search upwards
  40633. }
  40634. }
  40635. }
  40636. }
  40637. };
  40638. var isMultipleSelection = function isMultipleSelection(isMultiple) {
  40639. if (isMultiple && this.mergeCells) {
  40640. var mergedCells = this.mergeCells.mergedCellInfoCollection,
  40641. selectionRange = this.getSelectedRange();
  40642. for (var group in mergedCells) {
  40643. 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) {
  40644. return false;
  40645. }
  40646. }
  40647. }
  40648. return isMultiple;
  40649. };
  40650. function modifyAutofillRange(select, drag) {
  40651. var mergeCellsSetting = this.getSettings().mergeCells;
  40652. if (!mergeCellsSetting || this.selection.isMultiple()) {
  40653. return;
  40654. }
  40655. var info = this.mergeCells.mergedCellInfoCollection.getInfo(select[0], select[1]);
  40656. if (info) {
  40657. select[0] = info.row;
  40658. select[1] = info.col;
  40659. select[2] = info.row + info.rowspan - 1;
  40660. select[3] = info.col + info.colspan - 1;
  40661. }
  40662. }
  40663. function onAfterCreateCol(col, count) {
  40664. if (this.mergeCells) {
  40665. this.mergeCells.shiftCollection('right', col, count);
  40666. }
  40667. }
  40668. function onAfterRemoveCol(col, count) {
  40669. if (this.mergeCells) {
  40670. this.mergeCells.shiftCollection('left', col, count);
  40671. }
  40672. }
  40673. function onAfterCreateRow(row, count) {
  40674. if (this.mergeCells) {
  40675. this.mergeCells.shiftCollection('down', row, count);
  40676. }
  40677. }
  40678. function onAfterRemoveRow(row, count) {
  40679. if (this.mergeCells) {
  40680. this.mergeCells.shiftCollection('up', row, count);
  40681. }
  40682. }
  40683. var hook = _pluginHooks2.default.getSingleton();
  40684. hook.add('beforeInit', beforeInit);
  40685. hook.add('afterInit', afterInit);
  40686. hook.add('afterUpdateSettings', afterUpdateSettings);
  40687. hook.add('beforeKeyDown', onBeforeKeyDown);
  40688. hook.add('modifyTransformStart', modifyTransformFactory('modifyTransformStart'));
  40689. hook.add('modifyTransformEnd', modifyTransformFactory('modifyTransformEnd'));
  40690. hook.add('beforeSetRangeEnd', beforeSetRangeEnd);
  40691. hook.add('beforeDrawBorders', beforeDrawAreaBorders);
  40692. hook.add('afterIsMultipleSelection', isMultipleSelection);
  40693. hook.add('afterRenderer', afterRenderer);
  40694. hook.add('afterContextMenuDefaultOptions', addMergeActionsToContextMenu);
  40695. hook.add('afterGetCellMeta', afterGetCellMeta);
  40696. hook.add('afterViewportRowCalculatorOverride', afterViewportRowCalculatorOverride);
  40697. hook.add('afterViewportColumnCalculatorOverride', afterViewportColumnCalculatorOverride);
  40698. hook.add('modifyAutofillRange', modifyAutofillRange);
  40699. hook.add('afterCreateCol', onAfterCreateCol);
  40700. hook.add('afterRemoveCol', onAfterRemoveCol);
  40701. hook.add('afterCreateRow', onAfterCreateRow);
  40702. hook.add('afterRemoveRow', onAfterRemoveRow);
  40703. exports.default = MergeCells;
  40704. /***/ }),
  40705. /* 369 */
  40706. /***/ (function(module, exports, __webpack_require__) {
  40707. "use strict";
  40708. exports.__esModule = true;
  40709. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  40710. var _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); } };
  40711. var _pluginHooks = __webpack_require__(8);
  40712. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  40713. var _element = __webpack_require__(0);
  40714. var _browser = __webpack_require__(25);
  40715. var _base = __webpack_require__(12);
  40716. var _base2 = _interopRequireDefault(_base);
  40717. var _eventManager = __webpack_require__(4);
  40718. var _eventManager2 = _interopRequireDefault(_eventManager);
  40719. var _plugins = __webpack_require__(5);
  40720. var _src = __webpack_require__(11);
  40721. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40722. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40723. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  40724. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  40725. /**
  40726. * @private
  40727. * @plugin MultipleSelectionHandles
  40728. */
  40729. var MultipleSelectionHandles = function (_BasePlugin) {
  40730. _inherits(MultipleSelectionHandles, _BasePlugin);
  40731. /**
  40732. * @param {Object} hotInstance
  40733. */
  40734. function MultipleSelectionHandles(hotInstance) {
  40735. _classCallCheck(this, MultipleSelectionHandles);
  40736. /**
  40737. * @type {Array}
  40738. */
  40739. var _this2 = _possibleConstructorReturn(this, (MultipleSelectionHandles.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles)).call(this, hotInstance));
  40740. _this2.dragged = [];
  40741. /**
  40742. * Instance of EventManager.
  40743. *
  40744. * @type {EventManager}
  40745. */
  40746. _this2.eventManager = null;
  40747. /**
  40748. * @type {null}
  40749. */
  40750. _this2.lastSetCell = null;
  40751. return _this2;
  40752. }
  40753. /**
  40754. * Check if the plugin is enabled in the handsontable settings.
  40755. *
  40756. * @returns {Boolean}
  40757. */
  40758. _createClass(MultipleSelectionHandles, [{
  40759. key: 'isEnabled',
  40760. value: function isEnabled() {
  40761. return (0, _browser.isMobileBrowser)();
  40762. }
  40763. /**
  40764. * Enable plugin for this Handsontable instance.
  40765. */
  40766. }, {
  40767. key: 'enablePlugin',
  40768. value: function enablePlugin() {
  40769. if (this.enabled) {
  40770. return;
  40771. }
  40772. if (!this.eventManager) {
  40773. this.eventManager = new _eventManager2.default(this);
  40774. }
  40775. this.registerListeners();
  40776. _get(MultipleSelectionHandles.prototype.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles.prototype), 'enablePlugin', this).call(this);
  40777. }
  40778. /**
  40779. * Bind the touch events
  40780. * @private
  40781. */
  40782. }, {
  40783. key: 'registerListeners',
  40784. value: function registerListeners() {
  40785. var _this = this;
  40786. function removeFromDragged(query) {
  40787. if (_this.dragged.length === 1) {
  40788. // clear array
  40789. _this.dragged.splice(0, _this.dragged.length);
  40790. return true;
  40791. }
  40792. var entryPosition = _this.dragged.indexOf(query);
  40793. if (entryPosition == -1) {
  40794. return false;
  40795. } else if (entryPosition === 0) {
  40796. _this.dragged = _this.dragged.slice(0, 1);
  40797. } else if (entryPosition == 1) {
  40798. _this.dragged = _this.dragged.slice(-1);
  40799. }
  40800. }
  40801. this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function (event) {
  40802. var selectedRange = void 0;
  40803. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  40804. selectedRange = _this.hot.getSelectedRange();
  40805. _this.dragged.push('topLeft');
  40806. _this.touchStartRange = {
  40807. width: selectedRange.getWidth(),
  40808. height: selectedRange.getHeight(),
  40809. direction: selectedRange.getDirection()
  40810. };
  40811. event.preventDefault();
  40812. return false;
  40813. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  40814. selectedRange = _this.hot.getSelectedRange();
  40815. _this.dragged.push('bottomRight');
  40816. _this.touchStartRange = {
  40817. width: selectedRange.getWidth(),
  40818. height: selectedRange.getHeight(),
  40819. direction: selectedRange.getDirection()
  40820. };
  40821. event.preventDefault();
  40822. return false;
  40823. }
  40824. });
  40825. this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function (event) {
  40826. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  40827. removeFromDragged.call(_this, 'topLeft');
  40828. _this.touchStartRange = void 0;
  40829. event.preventDefault();
  40830. return false;
  40831. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  40832. removeFromDragged.call(_this, 'bottomRight');
  40833. _this.touchStartRange = void 0;
  40834. event.preventDefault();
  40835. return false;
  40836. }
  40837. });
  40838. this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function (event) {
  40839. var scrollTop = (0, _element.getWindowScrollTop)(),
  40840. scrollLeft = (0, _element.getWindowScrollLeft)(),
  40841. endTarget = void 0,
  40842. targetCoords = void 0,
  40843. selectedRange = void 0,
  40844. rangeWidth = void 0,
  40845. rangeHeight = void 0,
  40846. rangeDirection = void 0,
  40847. newRangeCoords = void 0;
  40848. if (_this.dragged.length === 0) {
  40849. return;
  40850. }
  40851. endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop);
  40852. if (!endTarget || endTarget === _this.lastSetCell) {
  40853. return;
  40854. }
  40855. if (endTarget.nodeName == 'TD' || endTarget.nodeName == 'TH') {
  40856. targetCoords = _this.hot.getCoords(endTarget);
  40857. if (targetCoords.col == -1) {
  40858. targetCoords.col = 0;
  40859. }
  40860. selectedRange = _this.hot.getSelectedRange();
  40861. rangeWidth = selectedRange.getWidth();
  40862. rangeHeight = selectedRange.getHeight();
  40863. rangeDirection = selectedRange.getDirection();
  40864. if (rangeWidth == 1 && rangeHeight == 1) {
  40865. _this.hot.selection.setRangeEnd(targetCoords);
  40866. }
  40867. newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]);
  40868. if (newRangeCoords.start !== null) {
  40869. _this.hot.selection.setRangeStart(newRangeCoords.start);
  40870. }
  40871. _this.hot.selection.setRangeEnd(newRangeCoords.end);
  40872. _this.lastSetCell = endTarget;
  40873. }
  40874. event.preventDefault();
  40875. });
  40876. }
  40877. }, {
  40878. key: 'getCurrentRangeCoords',
  40879. value: function getCurrentRangeCoords(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) {
  40880. var topLeftCorner = selectedRange.getTopLeftCorner(),
  40881. bottomRightCorner = selectedRange.getBottomRightCorner(),
  40882. bottomLeftCorner = selectedRange.getBottomLeftCorner(),
  40883. topRightCorner = selectedRange.getTopRightCorner();
  40884. var newCoords = {
  40885. start: null,
  40886. end: null
  40887. };
  40888. switch (touchStartDirection) {
  40889. case 'NE-SW':
  40890. switch (currentDirection) {
  40891. case 'NE-SW':
  40892. case 'NW-SE':
  40893. if (draggedHandle == 'topLeft') {
  40894. newCoords = {
  40895. start: new _src.CellCoords(currentTouch.row, selectedRange.highlight.col),
  40896. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  40897. };
  40898. } else {
  40899. newCoords = {
  40900. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  40901. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  40902. };
  40903. }
  40904. break;
  40905. case 'SE-NW':
  40906. if (draggedHandle == 'bottomRight') {
  40907. newCoords = {
  40908. start: new _src.CellCoords(bottomRightCorner.row, currentTouch.col),
  40909. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  40910. };
  40911. }
  40912. break;
  40913. default:
  40914. break;
  40915. }
  40916. break;
  40917. case 'NW-SE':
  40918. switch (currentDirection) {
  40919. case 'NE-SW':
  40920. if (draggedHandle == 'topLeft') {
  40921. newCoords = {
  40922. start: currentTouch,
  40923. end: bottomLeftCorner
  40924. };
  40925. } else {
  40926. newCoords.end = currentTouch;
  40927. }
  40928. break;
  40929. case 'NW-SE':
  40930. if (draggedHandle == 'topLeft') {
  40931. newCoords = {
  40932. start: currentTouch,
  40933. end: bottomRightCorner
  40934. };
  40935. } else {
  40936. newCoords.end = currentTouch;
  40937. }
  40938. break;
  40939. case 'SE-NW':
  40940. if (draggedHandle == 'topLeft') {
  40941. newCoords = {
  40942. start: currentTouch,
  40943. end: topLeftCorner
  40944. };
  40945. } else {
  40946. newCoords.end = currentTouch;
  40947. }
  40948. break;
  40949. case 'SW-NE':
  40950. if (draggedHandle == 'topLeft') {
  40951. newCoords = {
  40952. start: currentTouch,
  40953. end: topRightCorner
  40954. };
  40955. } else {
  40956. newCoords.end = currentTouch;
  40957. }
  40958. break;
  40959. default:
  40960. break;
  40961. }
  40962. break;
  40963. case 'SW-NE':
  40964. switch (currentDirection) {
  40965. case 'NW-SE':
  40966. if (draggedHandle == 'bottomRight') {
  40967. newCoords = {
  40968. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  40969. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  40970. };
  40971. } else {
  40972. newCoords = {
  40973. start: new _src.CellCoords(topLeftCorner.row, currentTouch.col),
  40974. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  40975. };
  40976. }
  40977. break;
  40978. // case 'NE-SW':
  40979. //
  40980. // break;
  40981. case 'SW-NE':
  40982. if (draggedHandle == 'topLeft') {
  40983. newCoords = {
  40984. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  40985. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  40986. };
  40987. } else {
  40988. newCoords = {
  40989. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  40990. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  40991. };
  40992. }
  40993. break;
  40994. case 'SE-NW':
  40995. if (draggedHandle == 'bottomRight') {
  40996. newCoords = {
  40997. start: new _src.CellCoords(currentTouch.row, topRightCorner.col),
  40998. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  40999. };
  41000. } else if (draggedHandle == 'topLeft') {
  41001. newCoords = {
  41002. start: bottomLeftCorner,
  41003. end: currentTouch
  41004. };
  41005. }
  41006. break;
  41007. default:
  41008. break;
  41009. }
  41010. break;
  41011. case 'SE-NW':
  41012. switch (currentDirection) {
  41013. case 'NW-SE':
  41014. case 'NE-SW':
  41015. case 'SW-NE':
  41016. if (draggedHandle == 'topLeft') {
  41017. newCoords.end = currentTouch;
  41018. }
  41019. break;
  41020. case 'SE-NW':
  41021. if (draggedHandle == 'topLeft') {
  41022. newCoords.end = currentTouch;
  41023. } else {
  41024. newCoords = {
  41025. start: currentTouch,
  41026. end: topLeftCorner
  41027. };
  41028. }
  41029. break;
  41030. default:
  41031. break;
  41032. }
  41033. break;
  41034. default:
  41035. break;
  41036. }
  41037. return newCoords;
  41038. }
  41039. /**
  41040. * Check if user is currently dragging the handle.
  41041. *
  41042. * @returns {boolean} Dragging state
  41043. */
  41044. }, {
  41045. key: 'isDragged',
  41046. value: function isDragged() {
  41047. return this.dragged.length > 0;
  41048. }
  41049. }]);
  41050. return MultipleSelectionHandles;
  41051. }(_base2.default);
  41052. (0, _plugins.registerPlugin)('multipleSelectionHandles', MultipleSelectionHandles);
  41053. exports.default = MultipleSelectionHandles;
  41054. /***/ }),
  41055. /* 370 */
  41056. /***/ (function(module, exports, __webpack_require__) {
  41057. "use strict";
  41058. exports.__esModule = true;
  41059. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  41060. var _jsonPatchDuplex = __webpack_require__(249);
  41061. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  41062. var _localHooks = __webpack_require__(70);
  41063. var _localHooks2 = _interopRequireDefault(_localHooks);
  41064. var _object = __webpack_require__(1);
  41065. var _utils = __webpack_require__(372);
  41066. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41067. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41068. /**
  41069. * @class DataObserver
  41070. * @plugin ObserveChanges
  41071. */
  41072. var DataObserver = function () {
  41073. function DataObserver(observedData) {
  41074. _classCallCheck(this, DataObserver);
  41075. /**
  41076. * Observed source data.
  41077. *
  41078. * @type {Array}
  41079. */
  41080. this.observedData = null;
  41081. /**
  41082. * JsonPatch observer.
  41083. *
  41084. * @type {Object}
  41085. */
  41086. this.observer = null;
  41087. /**
  41088. * Flag which determines if observer is paused or not. Paused observer doesn't emit `change` hooks.
  41089. *
  41090. * @type {Boolean}
  41091. * @default false
  41092. */
  41093. this.paused = false;
  41094. this.setObservedData(observedData);
  41095. }
  41096. /**
  41097. * Set data to observe.
  41098. *
  41099. * @param {*} observedData
  41100. */
  41101. _createClass(DataObserver, [{
  41102. key: 'setObservedData',
  41103. value: function setObservedData(observedData) {
  41104. var _this = this;
  41105. if (this.observer) {
  41106. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  41107. }
  41108. this.observedData = observedData;
  41109. this.observer = _jsonPatchDuplex2.default.observe(this.observedData, function (patches) {
  41110. return _this.onChange(patches);
  41111. });
  41112. }
  41113. /**
  41114. * Check if observer was paused.
  41115. *
  41116. * @returns {Boolean}
  41117. */
  41118. }, {
  41119. key: 'isPaused',
  41120. value: function isPaused() {
  41121. return this.paused;
  41122. }
  41123. /**
  41124. * Pause observer (stop emitting all detected changes).
  41125. */
  41126. }, {
  41127. key: 'pause',
  41128. value: function pause() {
  41129. this.paused = true;
  41130. }
  41131. /**
  41132. * Resume observer (emit all detected changes).
  41133. */
  41134. }, {
  41135. key: 'resume',
  41136. value: function resume() {
  41137. this.paused = false;
  41138. }
  41139. /**
  41140. * JsonPatch on change listener.
  41141. *
  41142. * @private
  41143. * @param {Array} patches An array of object passed from jsonpatch.
  41144. */
  41145. }, {
  41146. key: 'onChange',
  41147. value: function onChange(patches) {
  41148. this.runLocalHooks('change', (0, _utils.cleanPatches)(patches));
  41149. }
  41150. /**
  41151. * Destroy observer instance.
  41152. */
  41153. }, {
  41154. key: 'destroy',
  41155. value: function destroy() {
  41156. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  41157. this.observedData = null;
  41158. this.observer = null;
  41159. }
  41160. }]);
  41161. return DataObserver;
  41162. }();
  41163. (0, _object.mixin)(DataObserver, _localHooks2.default);
  41164. exports.default = DataObserver;
  41165. /***/ }),
  41166. /* 371 */
  41167. /***/ (function(module, exports, __webpack_require__) {
  41168. "use strict";
  41169. exports.__esModule = true;
  41170. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  41171. var _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); } };
  41172. var _base = __webpack_require__(12);
  41173. var _base2 = _interopRequireDefault(_base);
  41174. var _jsonPatchDuplex = __webpack_require__(249);
  41175. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  41176. var _dataObserver = __webpack_require__(370);
  41177. var _dataObserver2 = _interopRequireDefault(_dataObserver);
  41178. var _array = __webpack_require__(2);
  41179. var _plugins = __webpack_require__(5);
  41180. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41181. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41182. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  41183. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  41184. // Handsontable.hooks.register('afterChangesObserved');
  41185. /**
  41186. * @plugin ObserveChanges
  41187. *
  41188. * @description
  41189. * This plugin allows to observe data source changes.
  41190. *
  41191. * By default, the plugin is declared as `undefined`, which makes it disabled.
  41192. * Enabling this plugin switches the table into one-way data binding where changes are applied into the data source (outside from the table)
  41193. * will be automatically reflected in the table.
  41194. *
  41195. * ```js
  41196. * ...
  41197. * // as a boolean
  41198. * observeChanges: true,
  41199. * ...
  41200. * ```
  41201. *
  41202. * To configure this plugin see {@link Options#observeChanges}.
  41203. */
  41204. var ObserveChanges = function (_BasePlugin) {
  41205. _inherits(ObserveChanges, _BasePlugin);
  41206. function ObserveChanges(hotInstance) {
  41207. _classCallCheck(this, ObserveChanges);
  41208. /**
  41209. * Instance of {@link DataObserver}.
  41210. *
  41211. * @type {DataObserver}
  41212. */
  41213. var _this = _possibleConstructorReturn(this, (ObserveChanges.__proto__ || Object.getPrototypeOf(ObserveChanges)).call(this, hotInstance));
  41214. _this.observer = null;
  41215. return _this;
  41216. }
  41217. /**
  41218. * Check if the plugin is enabled in the handsontable settings.
  41219. *
  41220. * @returns {Boolean}
  41221. */
  41222. _createClass(ObserveChanges, [{
  41223. key: 'isEnabled',
  41224. value: function isEnabled() {
  41225. return this.hot.getSettings().observeChanges;
  41226. }
  41227. /**
  41228. * Enable plugin for this Handsontable instance.
  41229. */
  41230. }, {
  41231. key: 'enablePlugin',
  41232. value: function enablePlugin() {
  41233. var _this2 = this;
  41234. if (this.enabled) {
  41235. return;
  41236. }
  41237. if (!this.observer) {
  41238. this.observer = new _dataObserver2.default(this.hot.getSourceData());
  41239. this._exposePublicApi();
  41240. }
  41241. this.observer.addLocalHook('change', function (patches) {
  41242. return _this2.onDataChange(patches);
  41243. });
  41244. this.addHook('afterCreateRow', function () {
  41245. return _this2.onAfterTableAlter();
  41246. });
  41247. this.addHook('afterRemoveRow', function () {
  41248. return _this2.onAfterTableAlter();
  41249. });
  41250. this.addHook('afterCreateCol', function () {
  41251. return _this2.onAfterTableAlter();
  41252. });
  41253. this.addHook('afterRemoveCol', function () {
  41254. return _this2.onAfterTableAlter();
  41255. });
  41256. this.addHook('afterChange', function (changes, source) {
  41257. return _this2.onAfterTableAlter(source);
  41258. });
  41259. this.addHook('afterLoadData', function (firstRun) {
  41260. return _this2.onAfterLoadData(firstRun);
  41261. });
  41262. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'enablePlugin', this).call(this);
  41263. }
  41264. /**
  41265. * Disable plugin for this Handsontable instance.
  41266. */
  41267. }, {
  41268. key: 'disablePlugin',
  41269. value: function disablePlugin() {
  41270. if (this.observer) {
  41271. this.observer.destroy();
  41272. this.observer = null;
  41273. this._deletePublicApi();
  41274. }
  41275. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'disablePlugin', this).call(this);
  41276. }
  41277. /**
  41278. * Data change observer.
  41279. *
  41280. * @private
  41281. * @param {Array} patches An array of objects which every item defines coordinates where data was changed.
  41282. */
  41283. }, {
  41284. key: 'onDataChange',
  41285. value: function onDataChange(patches) {
  41286. var _this3 = this;
  41287. if (!this.observer.isPaused()) {
  41288. var sourceName = this.pluginName + '.change';
  41289. var actions = {
  41290. add: function add(patch) {
  41291. if (isNaN(patch.col)) {
  41292. _this3.hot.runHooks('afterCreateRow', patch.row, 1, sourceName);
  41293. } else {
  41294. _this3.hot.runHooks('afterCreateCol', patch.col, 1, sourceName);
  41295. }
  41296. },
  41297. remove: function remove(patch) {
  41298. if (isNaN(patch.col)) {
  41299. _this3.hot.runHooks('afterRemoveRow', patch.row, 1, sourceName);
  41300. } else {
  41301. _this3.hot.runHooks('afterRemoveCol', patch.col, 1, sourceName);
  41302. }
  41303. },
  41304. replace: function replace(patch) {
  41305. _this3.hot.runHooks('afterChange', [patch.row, patch.col, null, patch.value], sourceName);
  41306. }
  41307. };
  41308. (0, _array.arrayEach)(patches, function (patch) {
  41309. if (actions[patch.op]) {
  41310. actions[patch.op](patch);
  41311. }
  41312. });
  41313. this.hot.render();
  41314. }
  41315. this.hot.runHooks('afterChangesObserved');
  41316. }
  41317. /**
  41318. * On after table alter listener. Prevents infinity loop between internal and external data changing.
  41319. *
  41320. * @private
  41321. * @param source
  41322. */
  41323. }, {
  41324. key: 'onAfterTableAlter',
  41325. value: function onAfterTableAlter(source) {
  41326. var _this4 = this;
  41327. if (source !== 'loadData') {
  41328. this.observer.pause();
  41329. this.hot.addHookOnce('afterChangesObserved', function () {
  41330. return _this4.observer.resume();
  41331. });
  41332. }
  41333. }
  41334. /**
  41335. * On after load data listener.
  41336. *
  41337. * @private
  41338. * @param {Boolean} firstRun `true` if event was fired first time.
  41339. */
  41340. }, {
  41341. key: 'onAfterLoadData',
  41342. value: function onAfterLoadData(firstRun) {
  41343. if (!firstRun) {
  41344. this.observer.setObservedData(this.hot.getSourceData());
  41345. }
  41346. }
  41347. /**
  41348. * Destroy plugin instance.
  41349. */
  41350. }, {
  41351. key: 'destroy',
  41352. value: function destroy() {
  41353. if (this.observer) {
  41354. this.observer.destroy();
  41355. this._deletePublicApi();
  41356. }
  41357. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'destroy', this).call(this);
  41358. }
  41359. /**
  41360. * Expose plugins methods to the core.
  41361. *
  41362. * @private
  41363. */
  41364. }, {
  41365. key: '_exposePublicApi',
  41366. value: function _exposePublicApi() {
  41367. var _this5 = this;
  41368. var hot = this.hot;
  41369. hot.pauseObservingChanges = function () {
  41370. return _this5.observer.pause();
  41371. };
  41372. hot.resumeObservingChanges = function () {
  41373. return _this5.observer.resume();
  41374. };
  41375. hot.isPausedObservingChanges = function () {
  41376. return _this5.observer.isPaused();
  41377. };
  41378. }
  41379. /**
  41380. * Delete all previously exposed methods.
  41381. *
  41382. * @private
  41383. */
  41384. }, {
  41385. key: '_deletePublicApi',
  41386. value: function _deletePublicApi() {
  41387. var hot = this.hot;
  41388. delete hot.pauseObservingChanges;
  41389. delete hot.resumeObservingChanges;
  41390. delete hot.isPausedObservingChanges;
  41391. }
  41392. }]);
  41393. return ObserveChanges;
  41394. }(_base2.default);
  41395. exports.default = ObserveChanges;
  41396. (0, _plugins.registerPlugin)('observeChanges', ObserveChanges);
  41397. /***/ }),
  41398. /* 372 */
  41399. /***/ (function(module, exports, __webpack_require__) {
  41400. "use strict";
  41401. exports.__esModule = true;
  41402. var _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"); } }; }();
  41403. exports.cleanPatches = cleanPatches;
  41404. exports.parsePath = parsePath;
  41405. var _array = __webpack_require__(2);
  41406. /**
  41407. * Clean and extend patches from jsonpatch observer.
  41408. *
  41409. * @param {Array} patches
  41410. * @returns {Array}
  41411. */
  41412. function cleanPatches(patches) {
  41413. var newOrRemovedColumns = [];
  41414. /**
  41415. * If observeChanges uses native Object.observe method, then it produces patches for length property. Filter them.
  41416. * If path can't be parsed. Filter it.
  41417. */
  41418. patches = (0, _array.arrayFilter)(patches, function (patch) {
  41419. if (/[/]length/ig.test(patch.path)) {
  41420. return false;
  41421. }
  41422. if (!parsePath(patch.path)) {
  41423. return false;
  41424. }
  41425. return true;
  41426. });
  41427. /**
  41428. * Extend patches with changed cells coords
  41429. */
  41430. patches = (0, _array.arrayMap)(patches, function (patch) {
  41431. var coords = parsePath(patch.path);
  41432. patch.row = coords.row;
  41433. patch.col = coords.col;
  41434. return patch;
  41435. });
  41436. /**
  41437. * Removing or adding column will produce one patch for each table row.
  41438. * Leaves only one patch for each column add/remove operation.
  41439. */
  41440. patches = (0, _array.arrayFilter)(patches, function (patch) {
  41441. if (['add', 'remove'].indexOf(patch.op) !== -1 && !isNaN(patch.col)) {
  41442. if (newOrRemovedColumns.indexOf(patch.col) !== -1) {
  41443. return false;
  41444. }
  41445. newOrRemovedColumns.push(patch.col);
  41446. }
  41447. return true;
  41448. });
  41449. newOrRemovedColumns.length = 0;
  41450. return patches;
  41451. }
  41452. /**
  41453. * Extract coordinates from path where data was changed.
  41454. *
  41455. * @param {String} path Path describing where data was changed.
  41456. * @returns {Object|null} Returns an object with `row` and `col` properties or `null` if path doesn't have necessary information.
  41457. */
  41458. function parsePath(path) {
  41459. var match = path.match(/^\/(\d+)\/?(.*)?$/);
  41460. if (!match) {
  41461. return null;
  41462. }
  41463. var _match = _slicedToArray(match, 3),
  41464. row = _match[1],
  41465. column = _match[2];
  41466. return {
  41467. row: parseInt(row, 10),
  41468. col: /^\d*$/.test(column) ? parseInt(column, 10) : column
  41469. };
  41470. }
  41471. /***/ }),
  41472. /* 373 */
  41473. /***/ (function(module, exports, __webpack_require__) {
  41474. "use strict";
  41475. exports.__esModule = true;
  41476. var _pluginHooks = __webpack_require__(8);
  41477. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  41478. var _plugins = __webpack_require__(5);
  41479. var _object = __webpack_require__(1);
  41480. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41481. function Storage(prefix) {
  41482. var savedKeys;
  41483. var saveSavedKeys = function saveSavedKeys() {
  41484. window.localStorage[prefix + '__persistentStateKeys'] = JSON.stringify(savedKeys);
  41485. };
  41486. var loadSavedKeys = function loadSavedKeys() {
  41487. var keysJSON = window.localStorage[prefix + '__persistentStateKeys'];
  41488. var keys = typeof keysJSON == 'string' ? JSON.parse(keysJSON) : void 0;
  41489. savedKeys = keys ? keys : [];
  41490. };
  41491. var clearSavedKeys = function clearSavedKeys() {
  41492. savedKeys = [];
  41493. saveSavedKeys();
  41494. };
  41495. loadSavedKeys();
  41496. this.saveValue = function (key, value) {
  41497. window.localStorage[prefix + '_' + key] = JSON.stringify(value);
  41498. if (savedKeys.indexOf(key) == -1) {
  41499. savedKeys.push(key);
  41500. saveSavedKeys();
  41501. }
  41502. };
  41503. this.loadValue = function (key, defaultValue) {
  41504. key = typeof key === 'undefined' ? defaultValue : key;
  41505. var value = window.localStorage[prefix + '_' + key];
  41506. return typeof value == 'undefined' ? void 0 : JSON.parse(value);
  41507. };
  41508. this.reset = function (key) {
  41509. window.localStorage.removeItem(prefix + '_' + key);
  41510. };
  41511. this.resetAll = function () {
  41512. for (var index = 0; index < savedKeys.length; index++) {
  41513. window.localStorage.removeItem(prefix + '_' + savedKeys[index]);
  41514. }
  41515. clearSavedKeys();
  41516. };
  41517. }
  41518. /**
  41519. * @private
  41520. * @class PersistentState
  41521. * @plugin PersistentState
  41522. */
  41523. function HandsontablePersistentState() {
  41524. var plugin = this;
  41525. this.init = function () {
  41526. var instance = this,
  41527. pluginSettings = instance.getSettings().persistentState;
  41528. plugin.enabled = !!pluginSettings;
  41529. if (!plugin.enabled) {
  41530. removeHooks.call(instance);
  41531. return;
  41532. }
  41533. if (!instance.storage) {
  41534. instance.storage = new Storage(instance.rootElement.id);
  41535. }
  41536. instance.resetState = plugin.resetValue;
  41537. addHooks.call(instance);
  41538. };
  41539. this.saveValue = function (key, value) {
  41540. var instance = this;
  41541. instance.storage.saveValue(key, value);
  41542. };
  41543. this.loadValue = function (key, saveTo) {
  41544. var instance = this;
  41545. saveTo.value = instance.storage.loadValue(key);
  41546. };
  41547. this.resetValue = function (key) {
  41548. var instance = this;
  41549. if (typeof key === 'undefined') {
  41550. instance.storage.resetAll();
  41551. } else {
  41552. instance.storage.reset(key);
  41553. }
  41554. };
  41555. var hooks = {
  41556. persistentStateSave: plugin.saveValue,
  41557. persistentStateLoad: plugin.loadValue,
  41558. persistentStateReset: plugin.resetValue
  41559. };
  41560. for (var hookName in hooks) {
  41561. if ((0, _object.hasOwnProperty)(hooks, hookName)) {
  41562. _pluginHooks2.default.getSingleton().register(hookName);
  41563. }
  41564. }
  41565. function addHooks() {
  41566. var instance = this;
  41567. for (var hookName in hooks) {
  41568. if ((0, _object.hasOwnProperty)(hooks, hookName)) {
  41569. instance.addHook(hookName, hooks[hookName]);
  41570. }
  41571. }
  41572. }
  41573. function removeHooks() {
  41574. var instance = this;
  41575. for (var hookName in hooks) {
  41576. if ((0, _object.hasOwnProperty)(hooks, hookName)) {
  41577. instance.removeHook(hookName, hooks[hookName]);
  41578. }
  41579. }
  41580. }
  41581. }
  41582. var htPersistentState = new HandsontablePersistentState();
  41583. _pluginHooks2.default.getSingleton().add('beforeInit', htPersistentState.init);
  41584. _pluginHooks2.default.getSingleton().add('afterUpdateSettings', htPersistentState.init);
  41585. exports.default = HandsontablePersistentState;
  41586. /***/ }),
  41587. /* 374 */
  41588. /***/ (function(module, exports, __webpack_require__) {
  41589. "use strict";
  41590. exports.__esModule = true;
  41591. var _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; };
  41592. var _pluginHooks = __webpack_require__(8);
  41593. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  41594. var _element = __webpack_require__(0);
  41595. var _renderers = __webpack_require__(9);
  41596. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41597. /**
  41598. * @private
  41599. * @plugin Search
  41600. */
  41601. function Search(instance) {
  41602. this.query = function (queryStr, callback, queryMethod) {
  41603. var rowCount = instance.countRows();
  41604. var colCount = instance.countCols();
  41605. var queryResult = [];
  41606. if (!callback) {
  41607. callback = Search.global.getDefaultCallback();
  41608. }
  41609. if (!queryMethod) {
  41610. queryMethod = Search.global.getDefaultQueryMethod();
  41611. }
  41612. for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
  41613. for (var colIndex = 0; colIndex < colCount; colIndex++) {
  41614. var cellData = instance.getDataAtCell(rowIndex, colIndex);
  41615. var cellProperties = instance.getCellMeta(rowIndex, colIndex);
  41616. var cellCallback = cellProperties.search.callback || callback;
  41617. var cellQueryMethod = cellProperties.search.queryMethod || queryMethod;
  41618. var testResult = cellQueryMethod(queryStr, cellData);
  41619. if (testResult) {
  41620. var singleResult = {
  41621. row: rowIndex,
  41622. col: colIndex,
  41623. data: cellData
  41624. };
  41625. queryResult.push(singleResult);
  41626. }
  41627. if (cellCallback) {
  41628. cellCallback(instance, rowIndex, colIndex, cellData, testResult);
  41629. }
  41630. }
  41631. }
  41632. return queryResult;
  41633. };
  41634. };
  41635. Search.DEFAULT_CALLBACK = function (instance, row, col, data, testResult) {
  41636. instance.getCellMeta(row, col).isSearchResult = testResult;
  41637. };
  41638. Search.DEFAULT_QUERY_METHOD = function (query, value) {
  41639. if (typeof query == 'undefined' || query == null || !query.toLowerCase || query.length === 0) {
  41640. return false;
  41641. }
  41642. if (typeof value == 'undefined' || value == null) {
  41643. return false;
  41644. }
  41645. return value.toString().toLowerCase().indexOf(query.toLowerCase()) != -1;
  41646. };
  41647. Search.DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult';
  41648. Search.global = function () {
  41649. var defaultCallback = Search.DEFAULT_CALLBACK;
  41650. var defaultQueryMethod = Search.DEFAULT_QUERY_METHOD;
  41651. var defaultSearchResultClass = Search.DEFAULT_SEARCH_RESULT_CLASS;
  41652. return {
  41653. getDefaultCallback: function getDefaultCallback() {
  41654. return defaultCallback;
  41655. },
  41656. setDefaultCallback: function setDefaultCallback(newDefaultCallback) {
  41657. defaultCallback = newDefaultCallback;
  41658. },
  41659. getDefaultQueryMethod: function getDefaultQueryMethod() {
  41660. return defaultQueryMethod;
  41661. },
  41662. setDefaultQueryMethod: function setDefaultQueryMethod(newDefaultQueryMethod) {
  41663. defaultQueryMethod = newDefaultQueryMethod;
  41664. },
  41665. getDefaultSearchResultClass: function getDefaultSearchResultClass() {
  41666. return defaultSearchResultClass;
  41667. },
  41668. setDefaultSearchResultClass: function setDefaultSearchResultClass(newSearchResultClass) {
  41669. defaultSearchResultClass = newSearchResultClass;
  41670. }
  41671. };
  41672. }();
  41673. function SearchCellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  41674. var searchResultClass = cellProperties.search !== null && _typeof(cellProperties.search) == 'object' && cellProperties.search.searchResultClass || Search.global.getDefaultSearchResultClass();
  41675. if (cellProperties.isSearchResult) {
  41676. (0, _element.addClass)(TD, searchResultClass);
  41677. } else {
  41678. (0, _element.removeClass)(TD, searchResultClass);
  41679. }
  41680. };
  41681. var originalBaseRenderer = (0, _renderers.getRenderer)('base');
  41682. (0, _renderers.registerRenderer)('base', function (instance, TD, row, col, prop, value, cellProperties) {
  41683. originalBaseRenderer.apply(this, arguments);
  41684. SearchCellDecorator.apply(this, arguments);
  41685. });
  41686. function init() {
  41687. var instance = this;
  41688. var pluginEnabled = !!instance.getSettings().search;
  41689. if (pluginEnabled) {
  41690. instance.search = new Search(instance);
  41691. } else {
  41692. delete instance.search;
  41693. }
  41694. }
  41695. _pluginHooks2.default.getSingleton().add('afterInit', init);
  41696. _pluginHooks2.default.getSingleton().add('afterUpdateSettings', init);
  41697. exports.default = Search;
  41698. /***/ }),
  41699. /* 375 */
  41700. /***/ (function(module, exports, __webpack_require__) {
  41701. "use strict";
  41702. exports.__esModule = true;
  41703. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  41704. var _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); } };
  41705. var _element = __webpack_require__(0);
  41706. var _array = __webpack_require__(2);
  41707. var _base = __webpack_require__(12);
  41708. var _base2 = _interopRequireDefault(_base);
  41709. var _plugins = __webpack_require__(5);
  41710. var _feature = __webpack_require__(34);
  41711. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41712. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41713. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  41714. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  41715. /**
  41716. * @private
  41717. * @plugin TouchScroll
  41718. * @class TouchScroll
  41719. */
  41720. var TouchScroll = function (_BasePlugin) {
  41721. _inherits(TouchScroll, _BasePlugin);
  41722. function TouchScroll(hotInstance) {
  41723. _classCallCheck(this, TouchScroll);
  41724. /**
  41725. * Collection of scrollbars to update.
  41726. *
  41727. * @type {Array}
  41728. */
  41729. var _this = _possibleConstructorReturn(this, (TouchScroll.__proto__ || Object.getPrototypeOf(TouchScroll)).call(this, hotInstance));
  41730. _this.scrollbars = [];
  41731. /**
  41732. * Collection of overlays to update.
  41733. *
  41734. * @type {Array}
  41735. */
  41736. _this.clones = [];
  41737. /**
  41738. * Flag which determines if collection of overlays should be refilled on every table render.
  41739. *
  41740. * @type {Boolean}
  41741. * @default false
  41742. */
  41743. _this.lockedCollection = false;
  41744. /**
  41745. * Flag which determines if walkontable should freeze overlays while scrolling.
  41746. *
  41747. * @type {Boolean}
  41748. * @default false
  41749. */
  41750. _this.freezeOverlays = false;
  41751. return _this;
  41752. }
  41753. /**
  41754. * Check if plugin is enabled.
  41755. *
  41756. * @returns {Boolean}
  41757. */
  41758. _createClass(TouchScroll, [{
  41759. key: 'isEnabled',
  41760. value: function isEnabled() {
  41761. return (0, _feature.isTouchSupported)();
  41762. }
  41763. /**
  41764. * Enable the plugin.
  41765. */
  41766. }, {
  41767. key: 'enablePlugin',
  41768. value: function enablePlugin() {
  41769. var _this2 = this;
  41770. if (this.enabled) {
  41771. return;
  41772. }
  41773. this.addHook('afterRender', function () {
  41774. return _this2.onAfterRender();
  41775. });
  41776. this.registerEvents();
  41777. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'enablePlugin', this).call(this);
  41778. }
  41779. /**
  41780. * Updates the plugin to use the latest options you have specified.
  41781. */
  41782. }, {
  41783. key: 'updatePlugin',
  41784. value: function updatePlugin() {
  41785. this.lockedCollection = false;
  41786. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'updatePlugin', this).call(this);
  41787. }
  41788. /**
  41789. * Disable plugin for this Handsontable instance.
  41790. */
  41791. }, {
  41792. key: 'disablePlugin',
  41793. value: function disablePlugin() {
  41794. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'disablePlugin', this).call(this);
  41795. }
  41796. /**
  41797. * Register all necessary events.
  41798. *
  41799. * @private
  41800. */
  41801. }, {
  41802. key: 'registerEvents',
  41803. value: function registerEvents() {
  41804. var _this3 = this;
  41805. this.addHook('beforeTouchScroll', function () {
  41806. return _this3.onBeforeTouchScroll();
  41807. });
  41808. this.addHook('afterMomentumScroll', function () {
  41809. return _this3.onAfterMomentumScroll();
  41810. });
  41811. }
  41812. /**
  41813. * After render listener.
  41814. *
  41815. * @private
  41816. */
  41817. }, {
  41818. key: 'onAfterRender',
  41819. value: function onAfterRender() {
  41820. if (this.lockedCollection) {
  41821. return;
  41822. }
  41823. var _hot$view$wt$wtOverla = this.hot.view.wt.wtOverlays,
  41824. topOverlay = _hot$view$wt$wtOverla.topOverlay,
  41825. bottomOverlay = _hot$view$wt$wtOverla.bottomOverlay,
  41826. leftOverlay = _hot$view$wt$wtOverla.leftOverlay,
  41827. topLeftCornerOverlay = _hot$view$wt$wtOverla.topLeftCornerOverlay,
  41828. bottomLeftCornerOverlay = _hot$view$wt$wtOverla.bottomLeftCornerOverlay;
  41829. this.lockedCollection = true;
  41830. this.scrollbars.length = 0;
  41831. this.scrollbars.push(topOverlay);
  41832. if (bottomOverlay.clone) {
  41833. this.scrollbars.push(bottomOverlay);
  41834. }
  41835. this.scrollbars.push(leftOverlay);
  41836. if (topLeftCornerOverlay) {
  41837. this.scrollbars.push(topLeftCornerOverlay);
  41838. }
  41839. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  41840. this.scrollbars.push(bottomLeftCornerOverlay);
  41841. }
  41842. this.clones.length = 0;
  41843. if (topOverlay.needFullRender) {
  41844. this.clones.push(topOverlay.clone.wtTable.holder.parentNode);
  41845. }
  41846. if (bottomOverlay.needFullRender) {
  41847. this.clones.push(bottomOverlay.clone.wtTable.holder.parentNode);
  41848. }
  41849. if (leftOverlay.needFullRender) {
  41850. this.clones.push(leftOverlay.clone.wtTable.holder.parentNode);
  41851. }
  41852. if (topLeftCornerOverlay) {
  41853. this.clones.push(topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  41854. }
  41855. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  41856. this.clones.push(bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  41857. }
  41858. }
  41859. /**
  41860. * Touch scroll listener.
  41861. *
  41862. * @private
  41863. */
  41864. }, {
  41865. key: 'onBeforeTouchScroll',
  41866. value: function onBeforeTouchScroll() {
  41867. this.freezeOverlays = true;
  41868. (0, _array.arrayEach)(this.clones, function (clone) {
  41869. (0, _element.addClass)(clone, 'hide-tween');
  41870. });
  41871. }
  41872. /**
  41873. * After momentum scroll listener.
  41874. *
  41875. * @private
  41876. */
  41877. }, {
  41878. key: 'onAfterMomentumScroll',
  41879. value: function onAfterMomentumScroll() {
  41880. var _this4 = this;
  41881. this.freezeOverlays = false;
  41882. (0, _array.arrayEach)(this.clones, function (clone) {
  41883. (0, _element.removeClass)(clone, 'hide-tween');
  41884. (0, _element.addClass)(clone, 'show-tween');
  41885. });
  41886. setTimeout(function () {
  41887. (0, _array.arrayEach)(_this4.clones, function (clone) {
  41888. (0, _element.removeClass)(clone, 'show-tween');
  41889. });
  41890. }, 400);
  41891. (0, _array.arrayEach)(this.scrollbars, function (scrollbar) {
  41892. scrollbar.refresh();
  41893. scrollbar.resetFixedPosition();
  41894. });
  41895. this.hot.view.wt.wtOverlays.syncScrollWithMaster();
  41896. }
  41897. }]);
  41898. return TouchScroll;
  41899. }(_base2.default);
  41900. (0, _plugins.registerPlugin)('touchScroll', TouchScroll);
  41901. exports.default = TouchScroll;
  41902. /***/ }),
  41903. /* 376 */
  41904. /***/ (function(module, exports, __webpack_require__) {
  41905. "use strict";
  41906. var _pluginHooks = __webpack_require__(8);
  41907. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  41908. var _array = __webpack_require__(2);
  41909. var _number = __webpack_require__(6);
  41910. var _object = __webpack_require__(1);
  41911. var _event = __webpack_require__(7);
  41912. var _src = __webpack_require__(11);
  41913. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41914. /**
  41915. * @description
  41916. * Handsontable UndoRedo plugin. It allows to undo and redo certain actions done in the table.
  41917. * Please note, that not all actions are currently undo-able.
  41918. *
  41919. * @example
  41920. * ```js
  41921. * ...
  41922. * undo: true
  41923. * ...
  41924. * ```
  41925. * @class UndoRedo
  41926. * @plugin UndoRedo
  41927. */
  41928. /**
  41929. * Handsontable UndoRedo class
  41930. */
  41931. function UndoRedo(instance) {
  41932. var plugin = this;
  41933. this.instance = instance;
  41934. this.doneActions = [];
  41935. this.undoneActions = [];
  41936. this.ignoreNewActions = false;
  41937. instance.addHook('afterChange', function (changes, source) {
  41938. if (changes && source !== 'UndoRedo.undo' && source !== 'UndoRedo.redo') {
  41939. plugin.done(new UndoRedo.ChangeAction(changes));
  41940. }
  41941. });
  41942. instance.addHook('afterCreateRow', function (index, amount, source) {
  41943. if (source === 'UndoRedo.undo' || source === 'UndoRedo.undo' || source === 'auto') {
  41944. return;
  41945. }
  41946. var action = new UndoRedo.CreateRowAction(index, amount);
  41947. plugin.done(action);
  41948. });
  41949. instance.addHook('beforeRemoveRow', function (index, amount, logicRows, source) {
  41950. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  41951. return;
  41952. }
  41953. var originalData = plugin.instance.getSourceDataArray();
  41954. index = (originalData.length + index) % originalData.length;
  41955. var removedData = (0, _object.deepClone)(originalData.slice(index, index + amount));
  41956. plugin.done(new UndoRedo.RemoveRowAction(index, removedData));
  41957. });
  41958. instance.addHook('afterCreateCol', function (index, amount, source) {
  41959. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  41960. return;
  41961. }
  41962. plugin.done(new UndoRedo.CreateColumnAction(index, amount));
  41963. });
  41964. instance.addHook('beforeRemoveCol', function (index, amount, logicColumns, source) {
  41965. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  41966. return;
  41967. }
  41968. var originalData = plugin.instance.getSourceDataArray();
  41969. index = (plugin.instance.countCols() + index) % plugin.instance.countCols();
  41970. var removedData = [];
  41971. var headers = [];
  41972. var indexes = [];
  41973. (0, _number.rangeEach)(originalData.length - 1, function (i) {
  41974. var column = [];
  41975. var origRow = originalData[i];
  41976. (0, _number.rangeEach)(index, index + (amount - 1), function (j) {
  41977. column.push(origRow[instance.runHooks('modifyCol', j)]);
  41978. });
  41979. removedData.push(column);
  41980. });
  41981. (0, _number.rangeEach)(amount - 1, function (i) {
  41982. indexes.push(instance.runHooks('modifyCol', index + i));
  41983. });
  41984. if (Array.isArray(instance.getSettings().colHeaders)) {
  41985. (0, _number.rangeEach)(amount - 1, function (i) {
  41986. headers.push(instance.getSettings().colHeaders[instance.runHooks('modifyCol', index + i)] || null);
  41987. });
  41988. }
  41989. var manualColumnMovePlugin = plugin.instance.getPlugin('manualColumnMove');
  41990. var columnsMap = manualColumnMovePlugin.isEnabled() ? manualColumnMovePlugin.columnsMapper.__arrayMap : [];
  41991. var action = new UndoRedo.RemoveColumnAction(index, indexes, removedData, headers, columnsMap);
  41992. plugin.done(action);
  41993. });
  41994. instance.addHook('beforeCellAlignment', function (stateBefore, range, type, alignment) {
  41995. var action = new UndoRedo.CellAlignmentAction(stateBefore, range, type, alignment);
  41996. plugin.done(action);
  41997. });
  41998. instance.addHook('beforeFilter', function (conditionsStack) {
  41999. plugin.done(new UndoRedo.FiltersAction(conditionsStack));
  42000. });
  42001. instance.addHook('beforeRowMove', function (movedRows, target) {
  42002. if (movedRows === false) {
  42003. return;
  42004. }
  42005. plugin.done(new UndoRedo.RowMoveAction(movedRows, target));
  42006. });
  42007. };
  42008. UndoRedo.prototype.done = function (action) {
  42009. if (!this.ignoreNewActions) {
  42010. this.doneActions.push(action);
  42011. this.undoneActions.length = 0;
  42012. }
  42013. };
  42014. /**
  42015. * Undo last edit.
  42016. *
  42017. * @function undo
  42018. * @memberof UndoRedo#
  42019. */
  42020. UndoRedo.prototype.undo = function () {
  42021. if (this.isUndoAvailable()) {
  42022. var action = this.doneActions.pop();
  42023. var actionClone = (0, _object.deepClone)(action);
  42024. var instance = this.instance;
  42025. var continueAction = instance.runHooks('beforeUndo', actionClone);
  42026. if (continueAction === false) {
  42027. return;
  42028. }
  42029. this.ignoreNewActions = true;
  42030. var that = this;
  42031. action.undo(this.instance, function () {
  42032. that.ignoreNewActions = false;
  42033. that.undoneActions.push(action);
  42034. });
  42035. instance.runHooks('afterUndo', actionClone);
  42036. }
  42037. };
  42038. /**
  42039. * Redo edit (used to reverse an undo).
  42040. *
  42041. * @function redo
  42042. * @memberof UndoRedo#
  42043. */
  42044. UndoRedo.prototype.redo = function () {
  42045. if (this.isRedoAvailable()) {
  42046. var action = this.undoneActions.pop();
  42047. var actionClone = (0, _object.deepClone)(action);
  42048. var instance = this.instance;
  42049. var continueAction = instance.runHooks('beforeRedo', actionClone);
  42050. if (continueAction === false) {
  42051. return;
  42052. }
  42053. this.ignoreNewActions = true;
  42054. var that = this;
  42055. action.redo(this.instance, function () {
  42056. that.ignoreNewActions = false;
  42057. that.doneActions.push(action);
  42058. });
  42059. instance.runHooks('afterRedo', actionClone);
  42060. }
  42061. };
  42062. /**
  42063. * Check if undo action is available.
  42064. *
  42065. * @function isUndoAvailable
  42066. * @memberof UndoRedo#
  42067. * @return {Boolean} Return `true` if undo can be performed, `false` otherwise
  42068. */
  42069. UndoRedo.prototype.isUndoAvailable = function () {
  42070. return this.doneActions.length > 0;
  42071. };
  42072. /**
  42073. * Check if redo action is available.
  42074. *
  42075. * @function isRedoAvailable
  42076. * @memberof UndoRedo#
  42077. * @return {Boolean} Return `true` if redo can be performed, `false` otherwise.
  42078. */
  42079. UndoRedo.prototype.isRedoAvailable = function () {
  42080. return this.undoneActions.length > 0;
  42081. };
  42082. /**
  42083. * Clears undo history.
  42084. *
  42085. * @function clear
  42086. * @memberof UndoRedo#
  42087. */
  42088. UndoRedo.prototype.clear = function () {
  42089. this.doneActions.length = 0;
  42090. this.undoneActions.length = 0;
  42091. };
  42092. UndoRedo.Action = function () {};
  42093. UndoRedo.Action.prototype.undo = function () {};
  42094. UndoRedo.Action.prototype.redo = function () {};
  42095. /**
  42096. * Change action.
  42097. */
  42098. UndoRedo.ChangeAction = function (changes) {
  42099. this.changes = changes;
  42100. this.actionType = 'change';
  42101. };
  42102. (0, _object.inherit)(UndoRedo.ChangeAction, UndoRedo.Action);
  42103. UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
  42104. var data = (0, _object.deepClone)(this.changes),
  42105. emptyRowsAtTheEnd = instance.countEmptyRows(true),
  42106. emptyColsAtTheEnd = instance.countEmptyCols(true);
  42107. for (var i = 0, len = data.length; i < len; i++) {
  42108. data[i].splice(3, 1);
  42109. }
  42110. instance.addHookOnce('afterChange', undoneCallback);
  42111. instance.setDataAtRowProp(data, null, null, 'UndoRedo.undo');
  42112. for (var _i = 0, _len = data.length; _i < _len; _i++) {
  42113. if (instance.getSettings().minSpareRows && data[_i][0] + 1 + instance.getSettings().minSpareRows === instance.countRows() && emptyRowsAtTheEnd == instance.getSettings().minSpareRows) {
  42114. instance.alter('remove_row', parseInt(data[_i][0] + 1, 10), instance.getSettings().minSpareRows);
  42115. instance.undoRedo.doneActions.pop();
  42116. }
  42117. if (instance.getSettings().minSpareCols && data[_i][1] + 1 + instance.getSettings().minSpareCols === instance.countCols() && emptyColsAtTheEnd == instance.getSettings().minSpareCols) {
  42118. instance.alter('remove_col', parseInt(data[_i][1] + 1, 10), instance.getSettings().minSpareCols);
  42119. instance.undoRedo.doneActions.pop();
  42120. }
  42121. }
  42122. };
  42123. UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
  42124. var data = (0, _object.deepClone)(this.changes);
  42125. for (var i = 0, len = data.length; i < len; i++) {
  42126. data[i].splice(2, 1);
  42127. }
  42128. instance.addHookOnce('afterChange', onFinishCallback);
  42129. instance.setDataAtRowProp(data, null, null, 'UndoRedo.redo');
  42130. };
  42131. /**
  42132. * Create row action.
  42133. */
  42134. UndoRedo.CreateRowAction = function (index, amount) {
  42135. this.index = index;
  42136. this.amount = amount;
  42137. this.actionType = 'insert_row';
  42138. };
  42139. (0, _object.inherit)(UndoRedo.CreateRowAction, UndoRedo.Action);
  42140. UndoRedo.CreateRowAction.prototype.undo = function (instance, undoneCallback) {
  42141. var rowCount = instance.countRows(),
  42142. minSpareRows = instance.getSettings().minSpareRows;
  42143. if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
  42144. this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
  42145. }
  42146. instance.addHookOnce('afterRemoveRow', undoneCallback);
  42147. instance.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
  42148. };
  42149. UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
  42150. instance.addHookOnce('afterCreateRow', redoneCallback);
  42151. instance.alter('insert_row', this.index, this.amount, 'UndoRedo.redo');
  42152. };
  42153. /**
  42154. * Remove row action.
  42155. */
  42156. UndoRedo.RemoveRowAction = function (index, data) {
  42157. this.index = index;
  42158. this.data = data;
  42159. this.actionType = 'remove_row';
  42160. };
  42161. (0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
  42162. UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
  42163. instance.alter('insert_row', this.index, this.data.length, 'UndoRedo.undo');
  42164. instance.addHookOnce('afterRender', undoneCallback);
  42165. instance.populateFromArray(this.index, 0, this.data, void 0, void 0, 'UndoRedo.undo');
  42166. };
  42167. UndoRedo.RemoveRowAction.prototype.redo = function (instance, redoneCallback) {
  42168. instance.addHookOnce('afterRemoveRow', redoneCallback);
  42169. instance.alter('remove_row', this.index, this.data.length, 'UndoRedo.redo');
  42170. };
  42171. /**
  42172. * Create column action.
  42173. */
  42174. UndoRedo.CreateColumnAction = function (index, amount) {
  42175. this.index = index;
  42176. this.amount = amount;
  42177. this.actionType = 'insert_col';
  42178. };
  42179. (0, _object.inherit)(UndoRedo.CreateColumnAction, UndoRedo.Action);
  42180. UndoRedo.CreateColumnAction.prototype.undo = function (instance, undoneCallback) {
  42181. instance.addHookOnce('afterRemoveCol', undoneCallback);
  42182. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.undo');
  42183. };
  42184. UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback) {
  42185. instance.addHookOnce('afterCreateCol', redoneCallback);
  42186. instance.alter('insert_col', this.index, this.amount, 'UndoRedo.redo');
  42187. };
  42188. /**
  42189. * Remove column action.
  42190. */
  42191. UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions) {
  42192. this.index = index;
  42193. this.indexes = indexes;
  42194. this.data = data;
  42195. this.amount = this.data[0].length;
  42196. this.headers = headers;
  42197. this.columnPositions = columnPositions.slice(0);
  42198. this.actionType = 'remove_col';
  42199. };
  42200. (0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
  42201. UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
  42202. var _this = this;
  42203. var row = void 0;
  42204. var ascendingIndexes = this.indexes.slice(0).sort();
  42205. var sortByIndexes = function sortByIndexes(elem, j, arr) {
  42206. return arr[_this.indexes.indexOf(ascendingIndexes[j])];
  42207. };
  42208. var sortedData = [];
  42209. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  42210. sortedData[i] = (0, _array.arrayMap)(_this.data[i], sortByIndexes);
  42211. });
  42212. var sortedHeaders = [];
  42213. sortedHeaders = (0, _array.arrayMap)(this.headers, sortByIndexes);
  42214. var changes = [];
  42215. // TODO: Temporary hook for undo/redo mess
  42216. instance.runHooks('beforeCreateCol', this.indexes[0], this.indexes[this.indexes.length - 1], 'UndoRedo.undo');
  42217. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  42218. row = instance.getSourceDataAtRow(i);
  42219. (0, _number.rangeEach)(ascendingIndexes.length - 1, function (j) {
  42220. row.splice(ascendingIndexes[j], 0, sortedData[i][j]);
  42221. changes.push([i, ascendingIndexes[j], null, sortedData[i][j]]);
  42222. });
  42223. });
  42224. // TODO: Temporary hook for undo/redo mess
  42225. if (instance.getPlugin('formulas')) {
  42226. instance.getPlugin('formulas').onAfterSetDataAtCell(changes);
  42227. }
  42228. if (typeof this.headers !== 'undefined') {
  42229. (0, _number.rangeEach)(sortedHeaders.length - 1, function (j) {
  42230. instance.getSettings().colHeaders.splice(ascendingIndexes[j], 0, sortedHeaders[j]);
  42231. });
  42232. }
  42233. if (instance.getPlugin('manualColumnMove')) {
  42234. instance.getPlugin('manualColumnMove').columnsMapper.__arrayMap = this.columnPositions;
  42235. }
  42236. instance.addHookOnce('afterRender', undoneCallback);
  42237. // TODO: Temporary hook for undo/redo mess
  42238. instance.runHooks('afterCreateCol', this.indexes[0], this.indexes[this.indexes.length - 1], 'UndoRedo.undo');
  42239. if (instance.getPlugin('formulas')) {
  42240. instance.getPlugin('formulas').recalculateFull();
  42241. }
  42242. instance.render();
  42243. };
  42244. UndoRedo.RemoveColumnAction.prototype.redo = function (instance, redoneCallback) {
  42245. instance.addHookOnce('afterRemoveCol', redoneCallback);
  42246. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.redo');
  42247. };
  42248. /**
  42249. * Cell alignment action.
  42250. */
  42251. UndoRedo.CellAlignmentAction = function (stateBefore, range, type, alignment) {
  42252. this.stateBefore = stateBefore;
  42253. this.range = range;
  42254. this.type = type;
  42255. this.alignment = alignment;
  42256. };
  42257. UndoRedo.CellAlignmentAction.prototype.undo = function (instance, undoneCallback) {
  42258. if (!instance.getPlugin('contextMenu').isEnabled()) {
  42259. return;
  42260. }
  42261. for (var row = this.range.from.row; row <= this.range.to.row; row++) {
  42262. for (var col = this.range.from.col; col <= this.range.to.col; col++) {
  42263. instance.setCellMeta(row, col, 'className', this.stateBefore[row][col] || ' htLeft');
  42264. }
  42265. }
  42266. instance.addHookOnce('afterRender', undoneCallback);
  42267. instance.render();
  42268. };
  42269. UndoRedo.CellAlignmentAction.prototype.redo = function (instance, undoneCallback) {
  42270. if (!instance.getPlugin('contextMenu').isEnabled()) {
  42271. return;
  42272. }
  42273. instance.selectCell(this.range.from.row, this.range.from.col, this.range.to.row, this.range.to.col);
  42274. instance.getPlugin('contextMenu').executeCommand('alignment:' + this.alignment.replace('ht', '').toLowerCase());
  42275. instance.addHookOnce('afterRender', undoneCallback);
  42276. instance.render();
  42277. };
  42278. /**
  42279. * Filters action.
  42280. */
  42281. UndoRedo.FiltersAction = function (conditionsStack) {
  42282. this.conditionsStack = conditionsStack;
  42283. this.actionType = 'filter';
  42284. };
  42285. (0, _object.inherit)(UndoRedo.FiltersAction, UndoRedo.Action);
  42286. UndoRedo.FiltersAction.prototype.undo = function (instance, undoneCallback) {
  42287. var filters = instance.getPlugin('filters');
  42288. instance.addHookOnce('afterRender', undoneCallback);
  42289. filters.conditionCollection.importAllConditions(this.conditionsStack.slice(0, this.conditionsStack.length - 1));
  42290. filters.filter();
  42291. };
  42292. UndoRedo.FiltersAction.prototype.redo = function (instance, redoneCallback) {
  42293. var filters = instance.getPlugin('filters');
  42294. instance.addHookOnce('afterRender', redoneCallback);
  42295. filters.conditionCollection.importAllConditions(this.conditionsStack);
  42296. filters.filter();
  42297. };
  42298. /**
  42299. * ManualRowMove action.
  42300. * @TODO: removeRow undo should works on logical index
  42301. */
  42302. UndoRedo.RowMoveAction = function (movedRows, target) {
  42303. this.rows = movedRows.slice();
  42304. this.target = target;
  42305. };
  42306. (0, _object.inherit)(UndoRedo.RowMoveAction, UndoRedo.Action);
  42307. UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
  42308. var manualRowMove = instance.getPlugin('manualRowMove');
  42309. instance.addHookOnce('afterRender', undoneCallback);
  42310. var mod = this.rows[0] < this.target ? -1 * this.rows.length : 0;
  42311. var newTarget = this.rows[0] > this.target ? this.rows[0] + this.rows.length : this.rows[0];
  42312. var newRows = [];
  42313. var rowsLen = this.rows.length + mod;
  42314. for (var i = mod; i < rowsLen; i++) {
  42315. newRows.push(this.target + i);
  42316. }
  42317. manualRowMove.moveRows(newRows.slice(), newTarget);
  42318. instance.render();
  42319. instance.selection.setRangeStartOnly(new _src.CellCoords(this.rows[0], 0));
  42320. instance.selection.setRangeEnd(new _src.CellCoords(this.rows[this.rows.length - 1], instance.countCols() - 1));
  42321. };
  42322. UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
  42323. var manualRowMove = instance.getPlugin('manualRowMove');
  42324. instance.addHookOnce('afterRender', redoneCallback);
  42325. manualRowMove.moveRows(this.rows.slice(), this.target);
  42326. instance.render();
  42327. var startSelection = this.rows[0] < this.target ? this.target - this.rows.length : this.target;
  42328. instance.selection.setRangeStartOnly(new _src.CellCoords(startSelection, 0));
  42329. instance.selection.setRangeEnd(new _src.CellCoords(startSelection + this.rows.length - 1, instance.countCols() - 1));
  42330. };
  42331. function init() {
  42332. var instance = this;
  42333. var pluginEnabled = typeof instance.getSettings().undo == 'undefined' || instance.getSettings().undo;
  42334. if (pluginEnabled) {
  42335. if (!instance.undoRedo) {
  42336. /**
  42337. * Instance of Handsontable.UndoRedo Plugin {@link Handsontable.UndoRedo}
  42338. *
  42339. * @alias undoRedo
  42340. * @memberof! Handsontable.Core#
  42341. * @type {UndoRedo}
  42342. */
  42343. instance.undoRedo = new UndoRedo(instance);
  42344. exposeUndoRedoMethods(instance);
  42345. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  42346. instance.addHook('afterChange', onAfterChange);
  42347. }
  42348. } else if (instance.undoRedo) {
  42349. delete instance.undoRedo;
  42350. removeExposedUndoRedoMethods(instance);
  42351. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  42352. instance.removeHook('afterChange', onAfterChange);
  42353. }
  42354. }
  42355. function onBeforeKeyDown(event) {
  42356. var instance = this;
  42357. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  42358. if (ctrlDown) {
  42359. if (event.keyCode === 89 || event.shiftKey && event.keyCode === 90) {
  42360. // CTRL + Y or CTRL + SHIFT + Z
  42361. instance.undoRedo.redo();
  42362. (0, _event.stopImmediatePropagation)(event);
  42363. } else if (event.keyCode === 90) {
  42364. // CTRL + Z
  42365. instance.undoRedo.undo();
  42366. (0, _event.stopImmediatePropagation)(event);
  42367. }
  42368. }
  42369. }
  42370. function onAfterChange(changes, source) {
  42371. var instance = this;
  42372. if (source === 'loadData') {
  42373. return instance.undoRedo.clear();
  42374. }
  42375. }
  42376. function exposeUndoRedoMethods(instance) {
  42377. /**
  42378. * {@link UndoRedo#undo}
  42379. * @alias undo
  42380. * @memberof! Handsontable.Core#
  42381. */
  42382. instance.undo = function () {
  42383. return instance.undoRedo.undo();
  42384. };
  42385. /**
  42386. * {@link UndoRedo#redo}
  42387. * @alias redo
  42388. * @memberof! Handsontable.Core#
  42389. */
  42390. instance.redo = function () {
  42391. return instance.undoRedo.redo();
  42392. };
  42393. /**
  42394. * {@link UndoRedo#isUndoAvailable}
  42395. * @alias isUndoAvailable
  42396. * @memberof! Handsontable.Core#
  42397. */
  42398. instance.isUndoAvailable = function () {
  42399. return instance.undoRedo.isUndoAvailable();
  42400. };
  42401. /**
  42402. * {@link UndoRedo#isRedoAvailable}
  42403. * @alias isRedoAvailable
  42404. * @memberof! Handsontable.Core#
  42405. */
  42406. instance.isRedoAvailable = function () {
  42407. return instance.undoRedo.isRedoAvailable();
  42408. };
  42409. /**
  42410. * {@link UndoRedo#clear}
  42411. * @alias clearUndo
  42412. * @memberof! Handsontable.Core#
  42413. */
  42414. instance.clearUndo = function () {
  42415. return instance.undoRedo.clear();
  42416. };
  42417. }
  42418. function removeExposedUndoRedoMethods(instance) {
  42419. delete instance.undo;
  42420. delete instance.redo;
  42421. delete instance.isUndoAvailable;
  42422. delete instance.isRedoAvailable;
  42423. delete instance.clearUndo;
  42424. }
  42425. var hook = _pluginHooks2.default.getSingleton();
  42426. hook.add('afterInit', init);
  42427. hook.add('afterUpdateSettings', init);
  42428. hook.register('beforeUndo');
  42429. hook.register('afterUndo');
  42430. hook.register('beforeRedo');
  42431. hook.register('afterRedo');
  42432. /***/ }),
  42433. /* 377 */
  42434. /***/ (function(module, exports, __webpack_require__) {
  42435. "use strict";
  42436. exports.__esModule = true;
  42437. var _element = __webpack_require__(0);
  42438. function cellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  42439. if (cellProperties.className) {
  42440. if (TD.className) {
  42441. TD.className = TD.className + ' ' + cellProperties.className;
  42442. } else {
  42443. TD.className = cellProperties.className;
  42444. }
  42445. }
  42446. if (cellProperties.readOnly) {
  42447. (0, _element.addClass)(TD, cellProperties.readOnlyCellClassName);
  42448. }
  42449. if (cellProperties.valid === false && cellProperties.invalidCellClassName) {
  42450. (0, _element.addClass)(TD, cellProperties.invalidCellClassName);
  42451. } else {
  42452. (0, _element.removeClass)(TD, cellProperties.invalidCellClassName);
  42453. }
  42454. if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) {
  42455. (0, _element.addClass)(TD, cellProperties.noWordWrapClassName);
  42456. }
  42457. if (!value && cellProperties.placeholder) {
  42458. (0, _element.addClass)(TD, cellProperties.placeholderCellClassName);
  42459. }
  42460. } /**
  42461. * Adds appropriate CSS class to table cell, based on cellProperties
  42462. */
  42463. exports.default = cellDecorator;
  42464. /***/ }),
  42465. /* 378 */
  42466. /***/ (function(module, exports, __webpack_require__) {
  42467. "use strict";
  42468. exports.__esModule = true;
  42469. var _element = __webpack_require__(0);
  42470. var _eventManager = __webpack_require__(4);
  42471. var _eventManager2 = _interopRequireDefault(_eventManager);
  42472. var _src = __webpack_require__(11);
  42473. var _index = __webpack_require__(9);
  42474. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42475. var clonableWRAPPER = document.createElement('DIV');
  42476. clonableWRAPPER.className = 'htAutocompleteWrapper';
  42477. var clonableARROW = document.createElement('DIV');
  42478. clonableARROW.className = 'htAutocompleteArrow';
  42479. // workaround for https://github.com/handsontable/handsontable/issues/1946
  42480. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  42481. clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660)));
  42482. var wrapTdContentWithWrapper = function wrapTdContentWithWrapper(TD, WRAPPER) {
  42483. WRAPPER.innerHTML = TD.innerHTML;
  42484. (0, _element.empty)(TD);
  42485. TD.appendChild(WRAPPER);
  42486. };
  42487. /**
  42488. * Autocomplete renderer
  42489. *
  42490. * @private
  42491. * @renderer AutocompleteRenderer
  42492. * @param {Object} instance Handsontable instance
  42493. * @param {Element} TD Table cell where to render
  42494. * @param {Number} row
  42495. * @param {Number} col
  42496. * @param {String|Number} prop Row object property name
  42497. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  42498. * @param {Object} cellProperties Cell properites (shared by cell renderer and editor)
  42499. */
  42500. function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) {
  42501. var WRAPPER = clonableWRAPPER.cloneNode(true); // this is faster than createElement
  42502. var ARROW = clonableARROW.cloneNode(true); // this is faster than createElement
  42503. if (cellProperties.allowHtml) {
  42504. (0, _index.getRenderer)('html').apply(this, arguments);
  42505. } else {
  42506. (0, _index.getRenderer)('text').apply(this, arguments);
  42507. }
  42508. TD.appendChild(ARROW);
  42509. (0, _element.addClass)(TD, 'htAutocomplete');
  42510. if (!TD.firstChild) {
  42511. // http://jsperf.com/empty-node-if-needed
  42512. // otherwise empty fields appear borderless in demo/renderers.html (IE)
  42513. TD.appendChild(document.createTextNode(String.fromCharCode(160))); // workaround for https://github.com/handsontable/handsontable/issues/1946
  42514. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  42515. }
  42516. if (!instance.acArrowListener) {
  42517. var eventManager = new _eventManager2.default(instance);
  42518. // not very elegant but easy and fast
  42519. instance.acArrowListener = function (event) {
  42520. if ((0, _element.hasClass)(event.target, 'htAutocompleteArrow')) {
  42521. instance.view.wt.getSetting('onCellDblClick', null, new _src.CellCoords(row, col), TD);
  42522. }
  42523. };
  42524. eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener);
  42525. // We need to unbind the listener after the table has been destroyed
  42526. instance.addHookOnce('afterDestroy', function () {
  42527. eventManager.destroy();
  42528. });
  42529. }
  42530. }
  42531. exports.default = autocompleteRenderer;
  42532. /***/ }),
  42533. /* 379 */
  42534. /***/ (function(module, exports, __webpack_require__) {
  42535. "use strict";
  42536. exports.__esModule = true;
  42537. var _element = __webpack_require__(0);
  42538. var _string = __webpack_require__(27);
  42539. var _eventManager = __webpack_require__(4);
  42540. var _eventManager2 = _interopRequireDefault(_eventManager);
  42541. var _unicode = __webpack_require__(16);
  42542. var _function = __webpack_require__(35);
  42543. var _event = __webpack_require__(7);
  42544. var _index = __webpack_require__(9);
  42545. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42546. var isListeningKeyDownEvent = new WeakMap();
  42547. var isCheckboxListenerAdded = new WeakMap();
  42548. var BAD_VALUE_CLASS = 'htBadValue';
  42549. /**
  42550. * Checkbox renderer
  42551. *
  42552. * @private
  42553. * @param {Object} instance Handsontable instance
  42554. * @param {Element} TD Table cell where to render
  42555. * @param {Number} row
  42556. * @param {Number} col
  42557. * @param {String|Number} prop Row object property name
  42558. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  42559. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  42560. */
  42561. function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
  42562. (0, _index.getRenderer)('base').apply(this, arguments);
  42563. var eventManager = registerEvents(instance);
  42564. var input = createInput();
  42565. var labelOptions = cellProperties.label;
  42566. var badValue = false;
  42567. if (typeof cellProperties.checkedTemplate === 'undefined') {
  42568. cellProperties.checkedTemplate = true;
  42569. }
  42570. if (typeof cellProperties.uncheckedTemplate === 'undefined') {
  42571. cellProperties.uncheckedTemplate = false;
  42572. }
  42573. (0, _element.empty)(TD); // TODO identify under what circumstances this line can be removed
  42574. if (value === cellProperties.checkedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.checkedTemplate)) {
  42575. input.checked = true;
  42576. } else if (value === cellProperties.uncheckedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.uncheckedTemplate)) {
  42577. input.checked = false;
  42578. } else if (value === null) {
  42579. // default value
  42580. (0, _element.addClass)(input, 'noValue');
  42581. } else {
  42582. input.style.display = 'none';
  42583. (0, _element.addClass)(input, BAD_VALUE_CLASS);
  42584. badValue = true;
  42585. }
  42586. input.setAttribute('data-row', row);
  42587. input.setAttribute('data-col', col);
  42588. if (!badValue && labelOptions) {
  42589. var labelText = '';
  42590. if (labelOptions.value) {
  42591. labelText = typeof labelOptions.value === 'function' ? labelOptions.value.call(this, row, col, prop, value) : labelOptions.value;
  42592. } else if (labelOptions.property) {
  42593. labelText = instance.getDataAtRowProp(row, labelOptions.property);
  42594. }
  42595. var label = createLabel(labelText);
  42596. if (labelOptions.position === 'before') {
  42597. label.appendChild(input);
  42598. } else {
  42599. label.insertBefore(input, label.firstChild);
  42600. }
  42601. input = label;
  42602. }
  42603. TD.appendChild(input);
  42604. if (badValue) {
  42605. TD.appendChild(document.createTextNode('#bad-value#'));
  42606. }
  42607. if (!isListeningKeyDownEvent.has(instance)) {
  42608. isListeningKeyDownEvent.set(instance, true);
  42609. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  42610. }
  42611. /**
  42612. * On before key down DOM listener.
  42613. *
  42614. * @private
  42615. * @param {Event} event
  42616. */
  42617. function onBeforeKeyDown(event) {
  42618. var toggleKeys = 'SPACE|ENTER';
  42619. var switchOffKeys = 'DELETE|BACKSPACE';
  42620. var isKeyCode = (0, _function.partial)(_unicode.isKey, event.keyCode);
  42621. if (isKeyCode(toggleKeys + '|' + switchOffKeys) && !(0, _event.isImmediatePropagationStopped)(event)) {
  42622. eachSelectedCheckboxCell(function () {
  42623. (0, _event.stopImmediatePropagation)(event);
  42624. event.preventDefault();
  42625. });
  42626. }
  42627. if (isKeyCode(toggleKeys)) {
  42628. changeSelectedCheckboxesState();
  42629. }
  42630. if (isKeyCode(switchOffKeys)) {
  42631. changeSelectedCheckboxesState(true);
  42632. }
  42633. }
  42634. /**
  42635. * Change checkbox checked property
  42636. *
  42637. * @private
  42638. * @param {Boolean} [uncheckCheckbox=false]
  42639. */
  42640. function changeSelectedCheckboxesState() {
  42641. var uncheckCheckbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  42642. var selRange = instance.getSelectedRange();
  42643. if (!selRange) {
  42644. return;
  42645. }
  42646. var topLeft = selRange.getTopLeftCorner();
  42647. var bottomRight = selRange.getBottomRightCorner();
  42648. var changes = [];
  42649. for (var _row = topLeft.row; _row <= bottomRight.row; _row += 1) {
  42650. for (var _col = topLeft.col; _col <= bottomRight.col; _col += 1) {
  42651. var _cellProperties = instance.getCellMeta(_row, _col);
  42652. if (_cellProperties.type !== 'checkbox') {
  42653. return;
  42654. }
  42655. /* eslint-disable no-continue */
  42656. if (_cellProperties.readOnly === true) {
  42657. continue;
  42658. }
  42659. if (typeof _cellProperties.checkedTemplate === 'undefined') {
  42660. _cellProperties.checkedTemplate = true;
  42661. }
  42662. if (typeof _cellProperties.uncheckedTemplate === 'undefined') {
  42663. _cellProperties.uncheckedTemplate = false;
  42664. }
  42665. var dataAtCell = instance.getDataAtCell(_row, _col);
  42666. if (uncheckCheckbox === false) {
  42667. if (dataAtCell === _cellProperties.checkedTemplate) {
  42668. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  42669. } else if ([_cellProperties.uncheckedTemplate, null, void 0].indexOf(dataAtCell) !== -1) {
  42670. changes.push([_row, _col, _cellProperties.checkedTemplate]);
  42671. }
  42672. } else {
  42673. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  42674. }
  42675. }
  42676. }
  42677. if (changes.length > 0) {
  42678. instance.setDataAtCell(changes);
  42679. }
  42680. }
  42681. /**
  42682. * Call callback for each found selected cell with checkbox type.
  42683. *
  42684. * @private
  42685. * @param {Function} callback
  42686. */
  42687. function eachSelectedCheckboxCell(callback) {
  42688. var selRange = instance.getSelectedRange();
  42689. if (!selRange) {
  42690. return;
  42691. }
  42692. var topLeft = selRange.getTopLeftCorner();
  42693. var bottomRight = selRange.getBottomRightCorner();
  42694. for (var _row2 = topLeft.row; _row2 <= bottomRight.row; _row2++) {
  42695. for (var _col2 = topLeft.col; _col2 <= bottomRight.col; _col2++) {
  42696. var _cellProperties2 = instance.getCellMeta(_row2, _col2);
  42697. if (_cellProperties2.type !== 'checkbox') {
  42698. return;
  42699. }
  42700. var cell = instance.getCell(_row2, _col2);
  42701. if (cell == null) {
  42702. callback(_row2, _col2, _cellProperties2);
  42703. } else {
  42704. var checkboxes = cell.querySelectorAll('input[type=checkbox]');
  42705. if (checkboxes.length > 0 && !_cellProperties2.readOnly) {
  42706. callback(checkboxes);
  42707. }
  42708. }
  42709. }
  42710. }
  42711. }
  42712. }
  42713. /**
  42714. * Register checkbox listeners.
  42715. *
  42716. * @param {Handsontable} instance Handsontable instance.
  42717. * @returns {EventManager}
  42718. */
  42719. function registerEvents(instance) {
  42720. var eventManager = isCheckboxListenerAdded.get(instance);
  42721. if (!eventManager) {
  42722. eventManager = new _eventManager2.default(instance);
  42723. eventManager.addEventListener(instance.rootElement, 'click', function (event) {
  42724. return onClick(event, instance);
  42725. });
  42726. eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  42727. return onMouseUp(event, instance);
  42728. });
  42729. eventManager.addEventListener(instance.rootElement, 'change', function (event) {
  42730. return onChange(event, instance);
  42731. });
  42732. isCheckboxListenerAdded.set(instance, eventManager);
  42733. }
  42734. return eventManager;
  42735. }
  42736. /**
  42737. * Create input element.
  42738. *
  42739. * @returns {Node}
  42740. */
  42741. function createInput() {
  42742. var input = document.createElement('input');
  42743. input.className = 'htCheckboxRendererInput';
  42744. input.type = 'checkbox';
  42745. input.setAttribute('autocomplete', 'off');
  42746. input.setAttribute('tabindex', '-1');
  42747. return input.cloneNode(false);
  42748. }
  42749. /**
  42750. * Create label element.
  42751. *
  42752. * @returns {Node}
  42753. */
  42754. function createLabel(text) {
  42755. var label = document.createElement('label');
  42756. label.className = 'htCheckboxRendererLabel';
  42757. label.appendChild(document.createTextNode(text));
  42758. return label.cloneNode(true);
  42759. }
  42760. /**
  42761. * `mouseup` callback.
  42762. *
  42763. * @private
  42764. * @param {Event} event `mouseup` event.
  42765. * @param {Object} instance Handsontable instance.
  42766. */
  42767. function onMouseUp(event, instance) {
  42768. if (!isCheckboxInput(event.target)) {
  42769. return;
  42770. }
  42771. setTimeout(instance.listen, 10);
  42772. }
  42773. /**
  42774. * `click` callback.
  42775. *
  42776. * @private
  42777. * @param {Event} event `click` event.
  42778. * @param {Object} instance Handsontable instance.
  42779. */
  42780. function onClick(event, instance) {
  42781. if (!isCheckboxInput(event.target)) {
  42782. return false;
  42783. }
  42784. var row = parseInt(event.target.getAttribute('data-row'), 10);
  42785. var col = parseInt(event.target.getAttribute('data-col'), 10);
  42786. var cellProperties = instance.getCellMeta(row, col);
  42787. if (cellProperties.readOnly) {
  42788. event.preventDefault();
  42789. }
  42790. }
  42791. /**
  42792. * `change` callback.
  42793. *
  42794. * @param {Event} event `change` event.
  42795. * @param {Object} instance Handsontable instance.
  42796. * @param {Object} cellProperties Reference to cell properties.
  42797. * @returns {Boolean}
  42798. */
  42799. function onChange(event, instance) {
  42800. if (!isCheckboxInput(event.target)) {
  42801. return false;
  42802. }
  42803. var row = parseInt(event.target.getAttribute('data-row'), 10);
  42804. var col = parseInt(event.target.getAttribute('data-col'), 10);
  42805. var cellProperties = instance.getCellMeta(row, col);
  42806. if (!cellProperties.readOnly) {
  42807. var newCheckboxValue = null;
  42808. if (event.target.checked) {
  42809. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? true : cellProperties.checkedTemplate;
  42810. } else {
  42811. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? false : cellProperties.uncheckedTemplate;
  42812. }
  42813. instance.setDataAtCell(row, col, newCheckboxValue);
  42814. }
  42815. }
  42816. /**
  42817. * Check if the provided element is the checkbox input.
  42818. *
  42819. * @private
  42820. * @param {HTMLElement} element The element in question.
  42821. * @returns {Boolean}
  42822. */
  42823. function isCheckboxInput(element) {
  42824. return element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox';
  42825. }
  42826. exports.default = checkboxRenderer;
  42827. /***/ }),
  42828. /* 380 */
  42829. /***/ (function(module, exports, __webpack_require__) {
  42830. "use strict";
  42831. exports.__esModule = true;
  42832. var _element = __webpack_require__(0);
  42833. var _index = __webpack_require__(9);
  42834. /**
  42835. * @private
  42836. * @renderer HtmlRenderer
  42837. * @param instance
  42838. * @param TD
  42839. * @param row
  42840. * @param col
  42841. * @param prop
  42842. * @param value
  42843. * @param cellProperties
  42844. */
  42845. function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) {
  42846. (0, _index.getRenderer)('base').apply(this, arguments);
  42847. if (value === null || value === void 0) {
  42848. value = '';
  42849. }
  42850. (0, _element.fastInnerHTML)(TD, value);
  42851. }
  42852. exports.default = htmlRenderer;
  42853. /***/ }),
  42854. /* 381 */
  42855. /***/ (function(module, exports, __webpack_require__) {
  42856. "use strict";
  42857. exports.__esModule = true;
  42858. var _numbro = __webpack_require__(51);
  42859. var _numbro2 = _interopRequireDefault(_numbro);
  42860. var _index = __webpack_require__(9);
  42861. var _number = __webpack_require__(6);
  42862. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42863. /**
  42864. * Numeric cell renderer
  42865. *
  42866. * @private
  42867. * @renderer NumericRenderer
  42868. * @dependencies numbro
  42869. * @param {Object} instance Handsontable instance
  42870. * @param {Element} TD Table cell where to render
  42871. * @param {Number} row
  42872. * @param {Number} col
  42873. * @param {String|Number} prop Row object property name
  42874. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  42875. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  42876. */
  42877. function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
  42878. if ((0, _number.isNumeric)(value)) {
  42879. if (typeof cellProperties.language !== 'undefined') {
  42880. _numbro2.default.culture(cellProperties.language);
  42881. }
  42882. value = (0, _numbro2.default)(value).format(cellProperties.format || '0');
  42883. var className = cellProperties.className || '';
  42884. var classArr = className.length ? className.split(' ') : [];
  42885. if (classArr.indexOf('htLeft') < 0 && classArr.indexOf('htCenter') < 0 && classArr.indexOf('htRight') < 0 && classArr.indexOf('htJustify') < 0) {
  42886. classArr.push('htRight');
  42887. }
  42888. if (classArr.indexOf('htNumeric') < 0) {
  42889. classArr.push('htNumeric');
  42890. }
  42891. cellProperties.className = classArr.join(' ');
  42892. }
  42893. (0, _index.getRenderer)('text')(instance, TD, row, col, prop, value, cellProperties);
  42894. }
  42895. exports.default = numericRenderer;
  42896. /***/ }),
  42897. /* 382 */
  42898. /***/ (function(module, exports, __webpack_require__) {
  42899. "use strict";
  42900. exports.__esModule = true;
  42901. var _element = __webpack_require__(0);
  42902. var _index = __webpack_require__(9);
  42903. var _number = __webpack_require__(6);
  42904. /**
  42905. * @private
  42906. * @renderer PasswordRenderer
  42907. * @param instance
  42908. * @param TD
  42909. * @param row
  42910. * @param col
  42911. * @param prop
  42912. * @param value
  42913. * @param cellProperties
  42914. */
  42915. function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) {
  42916. (0, _index.getRenderer)('text').apply(this, arguments);
  42917. value = TD.innerHTML;
  42918. var hashLength = cellProperties.hashLength || value.length;
  42919. var hashSymbol = cellProperties.hashSymbol || '*';
  42920. var hash = '';
  42921. (0, _number.rangeEach)(hashLength - 1, function () {
  42922. hash += hashSymbol;
  42923. });
  42924. (0, _element.fastInnerHTML)(TD, hash);
  42925. }
  42926. exports.default = passwordRenderer;
  42927. /***/ }),
  42928. /* 383 */
  42929. /***/ (function(module, exports, __webpack_require__) {
  42930. "use strict";
  42931. exports.__esModule = true;
  42932. var _element = __webpack_require__(0);
  42933. var _mixed = __webpack_require__(20);
  42934. var _index = __webpack_require__(9);
  42935. /**
  42936. * Default text renderer
  42937. *
  42938. * @private
  42939. * @renderer TextRenderer
  42940. * @param {Object} instance Handsontable instance
  42941. * @param {Element} TD Table cell where to render
  42942. * @param {Number} row
  42943. * @param {Number} col
  42944. * @param {String|Number} prop Row object property name
  42945. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  42946. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  42947. */
  42948. function textRenderer(instance, TD, row, col, prop, value, cellProperties) {
  42949. (0, _index.getRenderer)('base').apply(this, arguments);
  42950. if (!value && cellProperties.placeholder) {
  42951. value = cellProperties.placeholder;
  42952. }
  42953. var escaped = (0, _mixed.stringify)(value);
  42954. if (!instance.getSettings().trimWhitespace) {
  42955. escaped = escaped.replace(/ /g, String.fromCharCode(160));
  42956. }
  42957. if (cellProperties.rendererTemplate) {
  42958. (0, _element.empty)(TD);
  42959. var TEMPLATE = document.createElement('TEMPLATE');
  42960. TEMPLATE.setAttribute('bind', '{{}}');
  42961. TEMPLATE.innerHTML = cellProperties.rendererTemplate;
  42962. HTMLTemplateElement.decorate(TEMPLATE);
  42963. TEMPLATE.model = instance.getSourceDataAtRow(row);
  42964. TD.appendChild(TEMPLATE);
  42965. } else {
  42966. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  42967. (0, _element.fastInnerText)(TD, escaped);
  42968. }
  42969. }
  42970. exports.default = textRenderer;
  42971. /***/ }),
  42972. /* 384 */
  42973. /***/ (function(module, exports, __webpack_require__) {
  42974. "use strict";
  42975. exports.__esModule = true;
  42976. var _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"); } }; }();
  42977. var _element = __webpack_require__(0);
  42978. var _browser = __webpack_require__(25);
  42979. var _eventManager = __webpack_require__(4);
  42980. var _eventManager2 = _interopRequireDefault(_eventManager);
  42981. var _event = __webpack_require__(7);
  42982. var _src = __webpack_require__(11);
  42983. var _src2 = _interopRequireDefault(_src);
  42984. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42985. /**
  42986. * Handsontable TableView constructor
  42987. * @param {Object} instance
  42988. */
  42989. function TableView(instance) {
  42990. var _this = this;
  42991. var that = this;
  42992. this.eventManager = new _eventManager2.default(instance);
  42993. this.instance = instance;
  42994. this.settings = instance.getSettings();
  42995. this.selectionMouseDown = false;
  42996. var originalStyle = instance.rootElement.getAttribute('style');
  42997. if (originalStyle) {
  42998. instance.rootElement.setAttribute('data-originalstyle', originalStyle); // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions
  42999. }
  43000. (0, _element.addClass)(instance.rootElement, 'handsontable');
  43001. var table = document.createElement('TABLE');
  43002. (0, _element.addClass)(table, 'htCore');
  43003. if (instance.getSettings().tableClassName) {
  43004. (0, _element.addClass)(table, instance.getSettings().tableClassName);
  43005. }
  43006. this.THEAD = document.createElement('THEAD');
  43007. table.appendChild(this.THEAD);
  43008. this.TBODY = document.createElement('TBODY');
  43009. table.appendChild(this.TBODY);
  43010. instance.table = table;
  43011. instance.container.insertBefore(table, instance.container.firstChild);
  43012. this.eventManager.addEventListener(instance.rootElement, 'mousedown', function (event) {
  43013. this.selectionMouseDown = true;
  43014. if (!that.isTextSelectionAllowed(event.target)) {
  43015. clearTextSelection();
  43016. event.preventDefault();
  43017. window.focus(); // make sure that window that contains HOT is active. Important when HOT is in iframe.
  43018. }
  43019. });
  43020. this.eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  43021. this.selectionMouseDown = false;
  43022. });
  43023. this.eventManager.addEventListener(instance.rootElement, 'mousemove', function (event) {
  43024. if (this.selectionMouseDown && !that.isTextSelectionAllowed(event.target)) {
  43025. clearTextSelection();
  43026. event.preventDefault();
  43027. }
  43028. });
  43029. this.eventManager.addEventListener(document.documentElement, 'keyup', function (event) {
  43030. if (instance.selection.isInProgress() && !event.shiftKey) {
  43031. instance.selection.finish();
  43032. }
  43033. });
  43034. var isMouseDown;
  43035. this.isMouseDown = function () {
  43036. return isMouseDown;
  43037. };
  43038. this.eventManager.addEventListener(document.documentElement, 'mouseup', function (event) {
  43039. if (instance.selection.isInProgress() && event.which === 1) {
  43040. // is left mouse button
  43041. instance.selection.finish();
  43042. }
  43043. isMouseDown = false;
  43044. if ((0, _element.isOutsideInput)(document.activeElement) || !instance.selection.isSelected()) {
  43045. instance.unlisten();
  43046. }
  43047. });
  43048. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  43049. var originalTarget = event.target;
  43050. var next = event.target;
  43051. var eventX = event.x || event.clientX;
  43052. var eventY = event.y || event.clientY;
  43053. if (isMouseDown || !instance.rootElement) {
  43054. return; // it must have been started in a cell
  43055. }
  43056. // immediate click on "holder" means click on the right side of vertical scrollbar
  43057. if (next === instance.view.wt.wtTable.holder) {
  43058. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  43059. if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {
  43060. return;
  43061. }
  43062. } else {
  43063. while (next !== document.documentElement) {
  43064. if (next === null) {
  43065. if (event.isTargetWebComponent) {
  43066. break;
  43067. }
  43068. // click on something that was a row but now is detached (possibly because your click triggered a rerender)
  43069. return;
  43070. }
  43071. if (next === instance.rootElement) {
  43072. // click inside container
  43073. return;
  43074. }
  43075. next = next.parentNode;
  43076. }
  43077. }
  43078. // function did not return until here, we have an outside click!
  43079. var outsideClickDeselects = typeof that.settings.outsideClickDeselects === 'function' ? that.settings.outsideClickDeselects(originalTarget) : that.settings.outsideClickDeselects;
  43080. if (outsideClickDeselects) {
  43081. instance.deselectCell();
  43082. } else {
  43083. instance.destroyEditor();
  43084. }
  43085. });
  43086. this.eventManager.addEventListener(table, 'selectstart', function (event) {
  43087. if (that.settings.fragmentSelection || (0, _element.isInput)(event.target)) {
  43088. return;
  43089. }
  43090. // https://github.com/handsontable/handsontable/issues/160
  43091. // Prevent text from being selected when performing drag down.
  43092. event.preventDefault();
  43093. });
  43094. var clearTextSelection = function clearTextSelection() {
  43095. // http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript
  43096. if (window.getSelection) {
  43097. if (window.getSelection().empty) {
  43098. // Chrome
  43099. window.getSelection().empty();
  43100. } else if (window.getSelection().removeAllRanges) {
  43101. // Firefox
  43102. window.getSelection().removeAllRanges();
  43103. }
  43104. } else if (document.selection) {
  43105. // IE?
  43106. document.selection.empty();
  43107. }
  43108. };
  43109. var selections = [new _src.Selection({
  43110. className: 'current',
  43111. border: {
  43112. width: 2,
  43113. color: '#5292F7',
  43114. // style: 'solid', // not used
  43115. cornerVisible: function cornerVisible() {
  43116. return that.settings.fillHandle && !that.isCellEdited() && !instance.selection.isMultiple();
  43117. },
  43118. multipleSelectionHandlesVisible: function multipleSelectionHandlesVisible() {
  43119. return !that.isCellEdited() && !instance.selection.isMultiple();
  43120. }
  43121. }
  43122. }), new _src.Selection({
  43123. className: 'area',
  43124. border: {
  43125. width: 1,
  43126. color: '#89AFF9',
  43127. // style: 'solid', // not used
  43128. cornerVisible: function cornerVisible() {
  43129. return that.settings.fillHandle && !that.isCellEdited() && instance.selection.isMultiple();
  43130. },
  43131. multipleSelectionHandlesVisible: function multipleSelectionHandlesVisible() {
  43132. return !that.isCellEdited() && instance.selection.isMultiple();
  43133. }
  43134. }
  43135. }), new _src.Selection({
  43136. className: 'highlight',
  43137. highlightHeaderClassName: that.settings.currentHeaderClassName,
  43138. highlightRowClassName: that.settings.currentRowClassName,
  43139. highlightColumnClassName: that.settings.currentColClassName
  43140. }), new _src.Selection({
  43141. className: 'fill',
  43142. border: {
  43143. width: 1,
  43144. color: 'red'
  43145. // style: 'solid' // not used
  43146. }
  43147. })];
  43148. selections.current = selections[0];
  43149. selections.area = selections[1];
  43150. selections.highlight = selections[2];
  43151. selections.fill = selections[3];
  43152. var walkontableConfig = {
  43153. debug: function debug() {
  43154. return that.settings.debug;
  43155. },
  43156. externalRowCalculator: this.instance.getPlugin('autoRowSize') && this.instance.getPlugin('autoRowSize').isEnabled(),
  43157. table: table,
  43158. preventOverflow: function preventOverflow() {
  43159. return _this.settings.preventOverflow;
  43160. },
  43161. stretchH: function stretchH() {
  43162. return that.settings.stretchH;
  43163. },
  43164. data: instance.getDataAtCell,
  43165. totalRows: function totalRows() {
  43166. return instance.countRows();
  43167. },
  43168. totalColumns: function totalColumns() {
  43169. return instance.countCols();
  43170. },
  43171. fixedColumnsLeft: function fixedColumnsLeft() {
  43172. return that.settings.fixedColumnsLeft;
  43173. },
  43174. fixedRowsTop: function fixedRowsTop() {
  43175. return that.settings.fixedRowsTop;
  43176. },
  43177. fixedRowsBottom: function fixedRowsBottom() {
  43178. return that.settings.fixedRowsBottom;
  43179. },
  43180. minSpareRows: function minSpareRows() {
  43181. return that.settings.minSpareRows;
  43182. },
  43183. renderAllRows: that.settings.renderAllRows,
  43184. rowHeaders: function rowHeaders() {
  43185. var headerRenderers = [];
  43186. if (instance.hasRowHeaders()) {
  43187. headerRenderers.push(function (row, TH) {
  43188. that.appendRowHeader(row, TH);
  43189. });
  43190. }
  43191. instance.runHooks('afterGetRowHeaderRenderers', headerRenderers);
  43192. return headerRenderers;
  43193. },
  43194. columnHeaders: function columnHeaders() {
  43195. var headerRenderers = [];
  43196. if (instance.hasColHeaders()) {
  43197. headerRenderers.push(function (column, TH) {
  43198. that.appendColHeader(column, TH);
  43199. });
  43200. }
  43201. instance.runHooks('afterGetColumnHeaderRenderers', headerRenderers);
  43202. return headerRenderers;
  43203. },
  43204. columnWidth: instance.getColWidth,
  43205. rowHeight: instance.getRowHeight,
  43206. cellRenderer: function cellRenderer(row, col, TD) {
  43207. var cellProperties = that.instance.getCellMeta(row, col);
  43208. var prop = that.instance.colToProp(col);
  43209. var value = that.instance.getDataAtRowProp(row, prop);
  43210. if (that.instance.hasHook('beforeValueRender')) {
  43211. value = that.instance.runHooks('beforeValueRender', value);
  43212. }
  43213. that.instance.runHooks('beforeRenderer', TD, row, col, prop, value, cellProperties);
  43214. that.instance.getCellRenderer(cellProperties)(that.instance, TD, row, col, prop, value, cellProperties);
  43215. that.instance.runHooks('afterRenderer', TD, row, col, prop, value, cellProperties);
  43216. },
  43217. selections: selections,
  43218. hideBorderOnMouseDownOver: function hideBorderOnMouseDownOver() {
  43219. return that.settings.fragmentSelection;
  43220. },
  43221. onCellMouseDown: function onCellMouseDown(event, coords, TD, wt) {
  43222. var blockCalculations = {
  43223. row: false,
  43224. column: false,
  43225. cells: false
  43226. };
  43227. instance.listen();
  43228. that.activeWt = wt;
  43229. isMouseDown = true;
  43230. instance.runHooks('beforeOnCellMouseDown', event, coords, TD, blockCalculations);
  43231. if ((0, _event.isImmediatePropagationStopped)(event)) {
  43232. return;
  43233. }
  43234. var actualSelection = instance.getSelectedRange();
  43235. var selection = instance.selection;
  43236. var selectedHeader = selection.selectedHeader;
  43237. if (event.shiftKey && actualSelection) {
  43238. if (coords.row >= 0 && coords.col >= 0 && !blockCalculations.cells) {
  43239. selection.setSelectedHeaders(false, false);
  43240. selection.setRangeEnd(coords);
  43241. } else if ((selectedHeader.cols || selectedHeader.rows) && coords.row >= 0 && coords.col >= 0 && !blockCalculations.cells) {
  43242. selection.setSelectedHeaders(false, false);
  43243. selection.setRangeEnd(new _src.CellCoords(coords.row, coords.col));
  43244. } else if (selectedHeader.cols && coords.row < 0 && !blockCalculations.column) {
  43245. selection.setRangeEnd(new _src.CellCoords(actualSelection.to.row, coords.col));
  43246. } else if (selectedHeader.rows && coords.col < 0 && !blockCalculations.row) {
  43247. selection.setRangeEnd(new _src.CellCoords(coords.row, actualSelection.to.col));
  43248. } else if ((!selectedHeader.cols && !selectedHeader.rows && coords.col < 0 || selectedHeader.cols && coords.col < 0) && !blockCalculations.row) {
  43249. selection.setSelectedHeaders(true, false);
  43250. selection.setRangeStartOnly(new _src.CellCoords(actualSelection.from.row, 0));
  43251. selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1));
  43252. } else if ((!selectedHeader.cols && !selectedHeader.rows && coords.row < 0 || selectedHeader.rows && coords.row < 0) && !blockCalculations.column) {
  43253. selection.setSelectedHeaders(false, true);
  43254. selection.setRangeStartOnly(new _src.CellCoords(0, actualSelection.from.col));
  43255. selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col));
  43256. }
  43257. } else {
  43258. var doNewSelection = true;
  43259. if (actualSelection) {
  43260. var from = actualSelection.from,
  43261. to = actualSelection.to;
  43262. var coordsNotInSelection = !selection.inInSelection(coords);
  43263. if (coords.row < 0 && selectedHeader.cols) {
  43264. var start = Math.min(from.col, to.col);
  43265. var end = Math.max(from.col, to.col);
  43266. doNewSelection = coords.col < start || coords.col > end;
  43267. } else if (coords.col < 0 && selectedHeader.rows) {
  43268. var _start = Math.min(from.row, to.row);
  43269. var _end = Math.max(from.row, to.row);
  43270. doNewSelection = coords.row < _start || coords.row > _end;
  43271. } else {
  43272. doNewSelection = coordsNotInSelection;
  43273. }
  43274. }
  43275. var rightClick = (0, _event.isRightClick)(event);
  43276. var leftClick = (0, _event.isLeftClick)(event) || event.type === 'touchstart';
  43277. // clicked row header and when some column was selected
  43278. if (coords.row < 0 && coords.col >= 0 && !blockCalculations.column) {
  43279. selection.setSelectedHeaders(false, true);
  43280. if (leftClick || rightClick && doNewSelection) {
  43281. selection.setRangeStartOnly(new _src.CellCoords(0, coords.col));
  43282. selection.setRangeEnd(new _src.CellCoords(Math.max(instance.countRows() - 1, 0), coords.col), false);
  43283. }
  43284. // clicked column header and when some row was selected
  43285. } else if (coords.col < 0 && coords.row >= 0 && !blockCalculations.row) {
  43286. selection.setSelectedHeaders(true, false);
  43287. if (leftClick || rightClick && doNewSelection) {
  43288. selection.setRangeStartOnly(new _src.CellCoords(coords.row, 0));
  43289. selection.setRangeEnd(new _src.CellCoords(coords.row, Math.max(instance.countCols() - 1, 0)), false);
  43290. }
  43291. } else if (coords.col >= 0 && coords.row >= 0 && !blockCalculations.cells) {
  43292. if (leftClick || rightClick && doNewSelection) {
  43293. selection.setSelectedHeaders(false, false);
  43294. selection.setRangeStart(coords);
  43295. }
  43296. } else if (coords.col < 0 && coords.row < 0) {
  43297. coords.row = 0;
  43298. coords.col = 0;
  43299. selection.setSelectedHeaders(false, false, true);
  43300. selection.setRangeStart(coords);
  43301. }
  43302. }
  43303. instance.runHooks('afterOnCellMouseDown', event, coords, TD);
  43304. that.activeWt = that.wt;
  43305. },
  43306. onCellMouseOut: function onCellMouseOut(event, coords, TD, wt) {
  43307. that.activeWt = wt;
  43308. instance.runHooks('beforeOnCellMouseOut', event, coords, TD);
  43309. if ((0, _event.isImmediatePropagationStopped)(event)) {
  43310. return;
  43311. }
  43312. instance.runHooks('afterOnCellMouseOut', event, coords, TD);
  43313. that.activeWt = that.wt;
  43314. },
  43315. onCellMouseOver: function onCellMouseOver(event, coords, TD, wt) {
  43316. var blockCalculations = {
  43317. row: false,
  43318. column: false,
  43319. cell: false
  43320. };
  43321. that.activeWt = wt;
  43322. instance.runHooks('beforeOnCellMouseOver', event, coords, TD, blockCalculations);
  43323. if ((0, _event.isImmediatePropagationStopped)(event)) {
  43324. return;
  43325. }
  43326. if (event.button === 0 && isMouseDown) {
  43327. if (coords.row >= 0 && coords.col >= 0) {
  43328. // is not a header
  43329. if (instance.selection.selectedHeader.cols && !blockCalculations.column) {
  43330. instance.selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col), false);
  43331. } else if (instance.selection.selectedHeader.rows && !blockCalculations.row) {
  43332. instance.selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1), false);
  43333. } else if (!blockCalculations.cell) {
  43334. instance.selection.setRangeEnd(coords);
  43335. }
  43336. } else {
  43337. /* eslint-disable no-lonely-if */
  43338. if (instance.selection.selectedHeader.cols && !blockCalculations.column) {
  43339. instance.selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col), false);
  43340. } else if (instance.selection.selectedHeader.rows && !blockCalculations.row) {
  43341. instance.selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1), false);
  43342. } else if (!blockCalculations.cell) {
  43343. instance.selection.setRangeEnd(coords);
  43344. }
  43345. }
  43346. }
  43347. instance.runHooks('afterOnCellMouseOver', event, coords, TD);
  43348. that.activeWt = that.wt;
  43349. },
  43350. onCellMouseUp: function onCellMouseUp(event, coords, TD, wt) {
  43351. that.activeWt = wt;
  43352. instance.runHooks('beforeOnCellMouseUp', event, coords, TD);
  43353. instance.runHooks('afterOnCellMouseUp', event, coords, TD);
  43354. that.activeWt = that.wt;
  43355. },
  43356. onCellCornerMouseDown: function onCellCornerMouseDown(event) {
  43357. event.preventDefault();
  43358. instance.runHooks('afterOnCellCornerMouseDown', event);
  43359. },
  43360. onCellCornerDblClick: function onCellCornerDblClick(event) {
  43361. event.preventDefault();
  43362. instance.runHooks('afterOnCellCornerDblClick', event);
  43363. },
  43364. beforeDraw: function beforeDraw(force, skipRender) {
  43365. that.beforeRender(force, skipRender);
  43366. },
  43367. onDraw: function onDraw(force) {
  43368. that.onDraw(force);
  43369. },
  43370. onScrollVertically: function onScrollVertically() {
  43371. instance.runHooks('afterScrollVertically');
  43372. },
  43373. onScrollHorizontally: function onScrollHorizontally() {
  43374. instance.runHooks('afterScrollHorizontally');
  43375. },
  43376. onBeforeDrawBorders: function onBeforeDrawBorders(corners, borderClassName) {
  43377. instance.runHooks('beforeDrawBorders', corners, borderClassName);
  43378. },
  43379. onBeforeTouchScroll: function onBeforeTouchScroll() {
  43380. instance.runHooks('beforeTouchScroll');
  43381. },
  43382. onAfterMomentumScroll: function onAfterMomentumScroll() {
  43383. instance.runHooks('afterMomentumScroll');
  43384. },
  43385. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  43386. return instance.runHooks('beforeStretchingColumnWidth', stretchedWidth, column);
  43387. },
  43388. onModifyRowHeaderWidth: function onModifyRowHeaderWidth(rowHeaderWidth) {
  43389. return instance.runHooks('modifyRowHeaderWidth', rowHeaderWidth);
  43390. },
  43391. viewportRowCalculatorOverride: function viewportRowCalculatorOverride(calc) {
  43392. var rows = instance.countRows();
  43393. var viewportOffset = that.settings.viewportRowRenderingOffset;
  43394. if (viewportOffset === 'auto' && that.settings.fixedRowsTop) {
  43395. viewportOffset = 10;
  43396. }
  43397. if (typeof viewportOffset === 'number') {
  43398. calc.startRow = Math.max(calc.startRow - viewportOffset, 0);
  43399. calc.endRow = Math.min(calc.endRow + viewportOffset, rows - 1);
  43400. }
  43401. if (viewportOffset === 'auto') {
  43402. var center = calc.startRow + calc.endRow - calc.startRow;
  43403. var offset = Math.ceil(center / rows * 12);
  43404. calc.startRow = Math.max(calc.startRow - offset, 0);
  43405. calc.endRow = Math.min(calc.endRow + offset, rows - 1);
  43406. }
  43407. instance.runHooks('afterViewportRowCalculatorOverride', calc);
  43408. },
  43409. viewportColumnCalculatorOverride: function viewportColumnCalculatorOverride(calc) {
  43410. var cols = instance.countCols();
  43411. var viewportOffset = that.settings.viewportColumnRenderingOffset;
  43412. if (viewportOffset === 'auto' && that.settings.fixedColumnsLeft) {
  43413. viewportOffset = 10;
  43414. }
  43415. if (typeof viewportOffset === 'number') {
  43416. calc.startColumn = Math.max(calc.startColumn - viewportOffset, 0);
  43417. calc.endColumn = Math.min(calc.endColumn + viewportOffset, cols - 1);
  43418. }
  43419. if (viewportOffset === 'auto') {
  43420. var center = calc.startColumn + calc.endColumn - calc.startColumn;
  43421. var offset = Math.ceil(center / cols * 12);
  43422. calc.startRow = Math.max(calc.startColumn - offset, 0);
  43423. calc.endColumn = Math.min(calc.endColumn + offset, cols - 1);
  43424. }
  43425. instance.runHooks('afterViewportColumnCalculatorOverride', calc);
  43426. },
  43427. rowHeaderWidth: function rowHeaderWidth() {
  43428. return that.settings.rowHeaderWidth;
  43429. },
  43430. columnHeaderHeight: function columnHeaderHeight() {
  43431. var columnHeaderHeight = instance.runHooks('modifyColumnHeaderHeight');
  43432. return that.settings.columnHeaderHeight || columnHeaderHeight;
  43433. }
  43434. };
  43435. instance.runHooks('beforeInitWalkontable', walkontableConfig);
  43436. this.wt = new _src2.default(walkontableConfig);
  43437. this.activeWt = this.wt;
  43438. if (!(0, _browser.isChrome)() && !(0, _browser.isSafari)()) {
  43439. this.eventManager.addEventListener(instance.rootElement, 'wheel', function (event) {
  43440. event.preventDefault();
  43441. var lineHeight = parseInt((0, _element.getComputedStyle)(document.body)['font-size'], 10);
  43442. var holder = that.wt.wtOverlays.scrollableElement;
  43443. var deltaY = event.wheelDeltaY || event.deltaY;
  43444. var deltaX = event.wheelDeltaX || event.deltaX;
  43445. switch (event.deltaMode) {
  43446. case 0:
  43447. holder.scrollLeft += deltaX;
  43448. holder.scrollTop += deltaY;
  43449. break;
  43450. case 1:
  43451. holder.scrollLeft += deltaX * lineHeight;
  43452. holder.scrollTop += deltaY * lineHeight;
  43453. break;
  43454. default:
  43455. break;
  43456. }
  43457. });
  43458. }
  43459. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function (event) {
  43460. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  43461. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  43462. (0, _event.stopPropagation)(event);
  43463. }
  43464. });
  43465. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function (event) {
  43466. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  43467. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  43468. (0, _event.stopPropagation)(event);
  43469. }
  43470. });
  43471. this.eventManager.addEventListener(document.documentElement, 'click', function () {
  43472. if (that.settings.observeDOMVisibility) {
  43473. if (that.wt.drawInterrupted) {
  43474. that.instance.forceFullRender = true;
  43475. that.render();
  43476. }
  43477. }
  43478. });
  43479. }
  43480. TableView.prototype.isTextSelectionAllowed = function (el) {
  43481. if ((0, _element.isInput)(el)) {
  43482. return true;
  43483. }
  43484. var isChildOfTableBody = (0, _element.isChildOf)(el, this.instance.view.wt.wtTable.spreader);
  43485. if (this.settings.fragmentSelection === true && isChildOfTableBody) {
  43486. return true;
  43487. }
  43488. if (this.settings.fragmentSelection === 'cell' && this.isSelectedOnlyCell() && isChildOfTableBody) {
  43489. return true;
  43490. }
  43491. if (!this.settings.fragmentSelection && this.isCellEdited() && this.isSelectedOnlyCell()) {
  43492. return true;
  43493. }
  43494. return false;
  43495. };
  43496. /**
  43497. * Check if selected only one cell.
  43498. *
  43499. * @returns {Boolean}
  43500. */
  43501. TableView.prototype.isSelectedOnlyCell = function () {
  43502. var _ref = this.instance.getSelected() || [],
  43503. _ref2 = _slicedToArray(_ref, 4),
  43504. row = _ref2[0],
  43505. col = _ref2[1],
  43506. rowEnd = _ref2[2],
  43507. colEnd = _ref2[3];
  43508. return row !== void 0 && row === rowEnd && col === colEnd;
  43509. };
  43510. TableView.prototype.isCellEdited = function () {
  43511. var activeEditor = this.instance.getActiveEditor();
  43512. return activeEditor && activeEditor.isOpened();
  43513. };
  43514. TableView.prototype.beforeRender = function (force, skipRender) {
  43515. if (force) {
  43516. // this.instance.forceFullRender = did Handsontable request full render?
  43517. this.instance.runHooks('beforeRender', this.instance.forceFullRender, skipRender);
  43518. }
  43519. };
  43520. TableView.prototype.onDraw = function (force) {
  43521. if (force) {
  43522. // this.instance.forceFullRender = did Handsontable request full render?
  43523. this.instance.runHooks('afterRender', this.instance.forceFullRender);
  43524. }
  43525. };
  43526. TableView.prototype.render = function () {
  43527. this.wt.draw(!this.instance.forceFullRender);
  43528. this.instance.forceFullRender = false;
  43529. this.instance.renderCall = false;
  43530. };
  43531. /**
  43532. * Returns td object given coordinates
  43533. *
  43534. * @param {CellCoords} coords
  43535. * @param {Boolean} topmost
  43536. */
  43537. TableView.prototype.getCellAtCoords = function (coords, topmost) {
  43538. var td = this.wt.getCell(coords, topmost);
  43539. if (td < 0) {
  43540. // there was an exit code (cell is out of bounds)
  43541. return null;
  43542. }
  43543. return td;
  43544. };
  43545. /**
  43546. * Scroll viewport to selection.
  43547. *
  43548. * @param {CellCoords} coords
  43549. */
  43550. TableView.prototype.scrollViewport = function (coords) {
  43551. this.wt.scrollViewport(coords);
  43552. };
  43553. /**
  43554. * Append row header to a TH element
  43555. * @param row
  43556. * @param TH
  43557. */
  43558. TableView.prototype.appendRowHeader = function (row, TH) {
  43559. if (TH.firstChild) {
  43560. var container = TH.firstChild;
  43561. if (!(0, _element.hasClass)(container, 'relative')) {
  43562. (0, _element.empty)(TH);
  43563. this.appendRowHeader(row, TH);
  43564. return;
  43565. }
  43566. this.updateCellHeader(container.querySelector('.rowHeader'), row, this.instance.getRowHeader);
  43567. } else {
  43568. var div = document.createElement('div');
  43569. var span = document.createElement('span');
  43570. div.className = 'relative';
  43571. span.className = 'rowHeader';
  43572. this.updateCellHeader(span, row, this.instance.getRowHeader);
  43573. div.appendChild(span);
  43574. TH.appendChild(div);
  43575. }
  43576. this.instance.runHooks('afterGetRowHeader', row, TH);
  43577. };
  43578. /**
  43579. * Append column header to a TH element
  43580. * @param col
  43581. * @param TH
  43582. */
  43583. TableView.prototype.appendColHeader = function (col, TH) {
  43584. if (TH.firstChild) {
  43585. var container = TH.firstChild;
  43586. if ((0, _element.hasClass)(container, 'relative')) {
  43587. this.updateCellHeader(container.querySelector('.colHeader'), col, this.instance.getColHeader);
  43588. } else {
  43589. (0, _element.empty)(TH);
  43590. this.appendColHeader(col, TH);
  43591. }
  43592. } else {
  43593. var div = document.createElement('div');
  43594. var span = document.createElement('span');
  43595. div.className = 'relative';
  43596. span.className = 'colHeader';
  43597. this.updateCellHeader(span, col, this.instance.getColHeader);
  43598. div.appendChild(span);
  43599. TH.appendChild(div);
  43600. }
  43601. this.instance.runHooks('afterGetColHeader', col, TH);
  43602. };
  43603. /**
  43604. * Update header cell content
  43605. *
  43606. * @since 0.15.0-beta4
  43607. * @param {HTMLElement} element Element to update
  43608. * @param {Number} index Row index or column index
  43609. * @param {Function} content Function which should be returns content for this cell
  43610. */
  43611. TableView.prototype.updateCellHeader = function (element, index, content) {
  43612. var renderedIndex = index;
  43613. var parentOverlay = this.wt.wtOverlays.getParentOverlay(element) || this.wt;
  43614. // prevent wrong calculations from SampleGenerator
  43615. if (element.parentNode) {
  43616. if ((0, _element.hasClass)(element, 'colHeader')) {
  43617. renderedIndex = parentOverlay.wtTable.columnFilter.sourceToRendered(index);
  43618. } else if ((0, _element.hasClass)(element, 'rowHeader')) {
  43619. renderedIndex = parentOverlay.wtTable.rowFilter.sourceToRendered(index);
  43620. }
  43621. }
  43622. if (renderedIndex > -1) {
  43623. (0, _element.fastInnerHTML)(element, content(index));
  43624. } else {
  43625. // workaround for https://github.com/handsontable/handsontable/issues/1946
  43626. (0, _element.fastInnerText)(element, String.fromCharCode(160));
  43627. (0, _element.addClass)(element, 'cornerHeader');
  43628. }
  43629. };
  43630. /**
  43631. * Given a element's left position relative to the viewport, returns maximum element width until the right
  43632. * edge of the viewport (before scrollbar)
  43633. *
  43634. * @param {Number} leftOffset
  43635. * @return {Number}
  43636. */
  43637. TableView.prototype.maximumVisibleElementWidth = function (leftOffset) {
  43638. var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();
  43639. var maxWidth = workspaceWidth - leftOffset;
  43640. return maxWidth > 0 ? maxWidth : 0;
  43641. };
  43642. /**
  43643. * Given a element's top position relative to the viewport, returns maximum element height until the bottom
  43644. * edge of the viewport (before scrollbar)
  43645. *
  43646. * @param {Number} topOffset
  43647. * @return {Number}
  43648. */
  43649. TableView.prototype.maximumVisibleElementHeight = function (topOffset) {
  43650. var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();
  43651. var maxHeight = workspaceHeight - topOffset;
  43652. return maxHeight > 0 ? maxHeight : 0;
  43653. };
  43654. TableView.prototype.mainViewIsActive = function () {
  43655. return this.wt === this.activeWt;
  43656. };
  43657. TableView.prototype.destroy = function () {
  43658. this.wt.destroy();
  43659. this.eventManager.destroy();
  43660. };
  43661. exports.default = TableView;
  43662. /***/ }),
  43663. /* 385 */
  43664. /***/ (function(module, exports, __webpack_require__) {
  43665. "use strict";
  43666. exports.__esModule = true;
  43667. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  43668. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43669. /**
  43670. * Refactored implementation of LinkedList (part of javascript-algorithms project) by Github users:
  43671. * mgechev, AndriiHeonia, Microfed and Jakeh (part of javascript-algorithms project - all project contributors
  43672. * at repository website)
  43673. *
  43674. * Link to repository: https://github.com/mgechev/javascript-algorithms
  43675. */
  43676. /**
  43677. * Linked list node.
  43678. *
  43679. * @class NodeStructure
  43680. * @util
  43681. */
  43682. var NodeStructure = function NodeStructure(data) {
  43683. _classCallCheck(this, NodeStructure);
  43684. /**
  43685. * Data of the node.
  43686. * @member {Object}
  43687. */
  43688. this.data = data;
  43689. /**
  43690. * Next node.
  43691. * @member {NodeStructure}
  43692. */
  43693. this.next = null;
  43694. /**
  43695. * Previous node.
  43696. * @member {NodeStructure}
  43697. */
  43698. this.prev = null;
  43699. };
  43700. /**
  43701. * Linked list.
  43702. *
  43703. * @class LinkedList
  43704. * @util
  43705. */
  43706. var LinkedList = function () {
  43707. function LinkedList() {
  43708. _classCallCheck(this, LinkedList);
  43709. this.first = null;
  43710. this.last = null;
  43711. }
  43712. /**
  43713. * Add data to the end of linked list.
  43714. *
  43715. * @param {Object} data Data which should be added.
  43716. */
  43717. _createClass(LinkedList, [{
  43718. key: "push",
  43719. value: function push(data) {
  43720. var node = new NodeStructure(data);
  43721. if (this.first === null) {
  43722. this.first = node;
  43723. this.last = node;
  43724. } else {
  43725. var temp = this.last;
  43726. this.last = node;
  43727. node.prev = temp;
  43728. temp.next = node;
  43729. }
  43730. }
  43731. /**
  43732. * Add data to the beginning of linked list.
  43733. *
  43734. * @param {Object} data Data which should be added.
  43735. */
  43736. }, {
  43737. key: "unshift",
  43738. value: function unshift(data) {
  43739. var node = new NodeStructure(data);
  43740. if (this.first === null) {
  43741. this.first = node;
  43742. this.last = node;
  43743. } else {
  43744. var temp = this.first;
  43745. this.first = node;
  43746. node.next = temp;
  43747. temp.prev = node;
  43748. }
  43749. }
  43750. /**
  43751. * In order traversal of the linked list.
  43752. *
  43753. * @param {Function} callback Callback which should be executed on each node.
  43754. */
  43755. }, {
  43756. key: "inorder",
  43757. value: function inorder(callback) {
  43758. var temp = this.first;
  43759. while (temp) {
  43760. callback(temp);
  43761. temp = temp.next;
  43762. }
  43763. }
  43764. /**
  43765. * Remove data from the linked list.
  43766. *
  43767. * @param {Object} data Data which should be removed.
  43768. * @returns {Boolean} Returns true if data has been removed.
  43769. */
  43770. }, {
  43771. key: "remove",
  43772. value: function remove(data) {
  43773. if (this.first === null) {
  43774. return false;
  43775. }
  43776. var temp = this.first;
  43777. var next = void 0;
  43778. var prev = void 0;
  43779. while (temp) {
  43780. if (temp.data === data) {
  43781. next = temp.next;
  43782. prev = temp.prev;
  43783. if (next) {
  43784. next.prev = prev;
  43785. }
  43786. if (prev) {
  43787. prev.next = next;
  43788. }
  43789. if (temp === this.first) {
  43790. this.first = next;
  43791. }
  43792. if (temp === this.last) {
  43793. this.last = prev;
  43794. }
  43795. return true;
  43796. }
  43797. temp = temp.next;
  43798. }
  43799. return false;
  43800. }
  43801. /**
  43802. * Check if linked list contains cycle.
  43803. *
  43804. * @returns {Boolean} Returns true if linked list contains cycle.
  43805. */
  43806. }, {
  43807. key: "hasCycle",
  43808. value: function hasCycle() {
  43809. var fast = this.first;
  43810. var slow = this.first;
  43811. while (true) {
  43812. if (fast === null) {
  43813. return false;
  43814. }
  43815. fast = fast.next;
  43816. if (fast === null) {
  43817. return false;
  43818. }
  43819. fast = fast.next;
  43820. slow = slow.next;
  43821. if (fast === slow) {
  43822. return true;
  43823. }
  43824. }
  43825. }
  43826. }, {
  43827. key: "pop",
  43828. /**
  43829. * Return last node from the linked list.
  43830. *
  43831. * @returns {NodeStructure} Last node.
  43832. */
  43833. value: function pop() {
  43834. if (this.last === null) {
  43835. return null;
  43836. }
  43837. var temp = this.last;
  43838. this.last = this.last.prev;
  43839. return temp;
  43840. }
  43841. }, {
  43842. key: "shift",
  43843. /**
  43844. * Return first node from the linked list.
  43845. *
  43846. * @returns {NodeStructure} First node.
  43847. */
  43848. value: function shift() {
  43849. if (this.first === null) {
  43850. return null;
  43851. }
  43852. var temp = this.first;
  43853. this.first = this.first.next;
  43854. return temp;
  43855. }
  43856. }, {
  43857. key: "recursiveReverse",
  43858. /**
  43859. * Reverses the linked list recursively
  43860. */
  43861. value: function recursiveReverse() {
  43862. function inverse(current, next) {
  43863. if (!next) {
  43864. return;
  43865. }
  43866. inverse(next, next.next);
  43867. next.next = current;
  43868. }
  43869. if (!this.first) {
  43870. return;
  43871. }
  43872. inverse(this.first, this.first.next);
  43873. this.first.next = null;
  43874. var temp = this.first;
  43875. this.first = this.last;
  43876. this.last = temp;
  43877. }
  43878. }, {
  43879. key: "reverse",
  43880. /**
  43881. * Reverses the linked list iteratively
  43882. */
  43883. value: function reverse() {
  43884. if (!this.first || !this.first.next) {
  43885. return;
  43886. }
  43887. var current = this.first.next;
  43888. var prev = this.first;
  43889. var temp = void 0;
  43890. while (current) {
  43891. temp = current.next;
  43892. current.next = prev;
  43893. prev.prev = current;
  43894. prev = current;
  43895. current = temp;
  43896. }
  43897. this.first.next = null;
  43898. this.last.prev = null;
  43899. temp = this.first;
  43900. this.first = prev;
  43901. this.last = temp;
  43902. }
  43903. }]);
  43904. return LinkedList;
  43905. }();
  43906. ;
  43907. exports.NodeStructure = NodeStructure;
  43908. exports.default = LinkedList;
  43909. /***/ }),
  43910. /* 386 */
  43911. /***/ (function(module, exports, __webpack_require__) {
  43912. "use strict";
  43913. exports.__esModule = true;
  43914. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  43915. exports.parseDelay = parseDelay;
  43916. var _feature = __webpack_require__(34);
  43917. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  43918. /**
  43919. * @class Interval
  43920. * @util
  43921. */
  43922. var Interval = function () {
  43923. _createClass(Interval, null, [{
  43924. key: 'create',
  43925. value: function create(func, delay) {
  43926. return new Interval(func, delay);
  43927. }
  43928. }]);
  43929. function Interval(func, delay) {
  43930. var _this = this;
  43931. _classCallCheck(this, Interval);
  43932. /**
  43933. * Animation frame request id.
  43934. *
  43935. * @type {Number}
  43936. */
  43937. this.timer = null;
  43938. /**
  43939. * Function to invoke repeatedly.
  43940. *
  43941. * @type {Function}
  43942. */
  43943. this.func = func;
  43944. /**
  43945. * Number of milliseconds that function should wait before next call.
  43946. */
  43947. this.delay = parseDelay(delay);
  43948. /**
  43949. * Flag which indicates if interval object was stopped.
  43950. *
  43951. * @type {Boolean}
  43952. * @default true
  43953. */
  43954. this.stopped = true;
  43955. /**
  43956. * Interval time (in milliseconds) of the last callback call.
  43957. *
  43958. * @private
  43959. * @type {Number}
  43960. */
  43961. this._then = null;
  43962. /**
  43963. * Bounded function `func`.
  43964. *
  43965. * @private
  43966. * @type {Function}
  43967. */
  43968. this._callback = function () {
  43969. return _this.__callback();
  43970. };
  43971. }
  43972. /**
  43973. * Start loop.
  43974. *
  43975. * @returns {Interval}
  43976. */
  43977. _createClass(Interval, [{
  43978. key: 'start',
  43979. value: function start() {
  43980. if (this.stopped) {
  43981. this._then = Date.now();
  43982. this.stopped = false;
  43983. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  43984. }
  43985. return this;
  43986. }
  43987. /**
  43988. * Stop looping.
  43989. *
  43990. * @returns {Interval}
  43991. */
  43992. }, {
  43993. key: 'stop',
  43994. value: function stop() {
  43995. if (!this.stopped) {
  43996. this.stopped = true;
  43997. (0, _feature.cancelAnimationFrame)(this.timer);
  43998. this.timer = null;
  43999. }
  44000. return this;
  44001. }
  44002. /**
  44003. * Loop callback, fired on every animation frame.
  44004. *
  44005. * @private
  44006. */
  44007. }, {
  44008. key: '__callback',
  44009. value: function __callback() {
  44010. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  44011. if (this.delay) {
  44012. var now = Date.now();
  44013. var elapsed = now - this._then;
  44014. if (elapsed > this.delay) {
  44015. this._then = now - elapsed % this.delay;
  44016. this.func();
  44017. }
  44018. } else {
  44019. this.func();
  44020. }
  44021. }
  44022. }]);
  44023. return Interval;
  44024. }();
  44025. exports.default = Interval;
  44026. function parseDelay(delay) {
  44027. if (typeof delay === 'string' && /fps$/.test(delay)) {
  44028. delay = 1000 / parseInt(delay.replace('fps', '') || 0, 10);
  44029. }
  44030. return delay;
  44031. }
  44032. /***/ }),
  44033. /* 387 */
  44034. /***/ (function(module, exports, __webpack_require__) {
  44035. "use strict";
  44036. exports.__esModule = true;
  44037. exports.default = mergeSort;
  44038. exports.merge = merge;
  44039. var _linkedList = __webpack_require__(385);
  44040. var _linkedList2 = _interopRequireDefault(_linkedList);
  44041. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44042. /**
  44043. * Refactored implementation of mergeSort (part of javascript-algorithms project) by Github users:
  44044. * mgechev, AndriiHeonia and lekkas (part of javascript-algorithms project - all project contributors
  44045. * at repository website)
  44046. *
  44047. * Link to repository: https://github.com/mgechev/javascript-algorithms
  44048. */
  44049. /**
  44050. * Specifies a function that defines the sort order. The array is sorted according to each
  44051. * character's Unicode code point value, according to the string conversion of each element.
  44052. *
  44053. * @param a {*} first compared element.
  44054. * @param b {*} second compared element.
  44055. * @returns {Number}
  44056. */
  44057. var defaultCompareFunction = function defaultCompareFunction(a, b) {
  44058. // sort lexically
  44059. var firstValue = a.toString();
  44060. var secondValue = b.toString();
  44061. if (firstValue === secondValue) {
  44062. return 0;
  44063. } else if (firstValue < secondValue) {
  44064. return -1;
  44065. }
  44066. return 1;
  44067. };
  44068. /**
  44069. * Mergesort method which is recursively called for sorting the input array.
  44070. *
  44071. * @param {Array} array The array which should be sorted.
  44072. * @param {Function} compareFunction Compares two items in an array. If compareFunction is not supplied,
  44073. * elements are sorted by converting them to strings and comparing strings in Unicode code point order.
  44074. * @param {Number} startIndex Left side of the subarray.
  44075. * @param {Number} endIndex Right side of the subarray.
  44076. * @returns {Array} Array with sorted subarray.
  44077. */
  44078. function mergeSort(array) {
  44079. var compareFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCompareFunction;
  44080. var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  44081. var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : array.length;
  44082. if (Math.abs(endIndex - startIndex) <= 1) {
  44083. return [];
  44084. }
  44085. var middleIndex = Math.ceil((startIndex + endIndex) / 2);
  44086. mergeSort(array, compareFunction, startIndex, middleIndex);
  44087. mergeSort(array, compareFunction, middleIndex, endIndex);
  44088. return merge(array, compareFunction, startIndex, middleIndex, endIndex);
  44089. }
  44090. /**
  44091. * Devides and sort merges two subarrays of given array
  44092. *
  44093. * @param {Array} array The array which subarrays should be sorted.
  44094. * @param {Number} startIndex The start of the first subarray.
  44095. * This subarray is with end middle - 1.
  44096. * @param {Number} middleIndex The start of the second array.
  44097. * @param {Number} endIndex end - 1 is the end of the second array.
  44098. * @returns {Array} The array with sorted subarray.
  44099. */
  44100. function merge(array, compareFunction, startIndex, middleIndex, endIndex) {
  44101. var leftElements = new _linkedList2.default();
  44102. var rightElements = new _linkedList2.default();
  44103. var leftSize = middleIndex - startIndex;
  44104. var rightSize = endIndex - middleIndex;
  44105. var maxSize = Math.max(leftSize, rightSize);
  44106. var size = endIndex - startIndex;
  44107. for (var _i = 0; _i < maxSize; _i += 1) {
  44108. if (_i < leftSize) {
  44109. leftElements.push(array[startIndex + _i]);
  44110. }
  44111. if (_i < rightSize) {
  44112. rightElements.push(array[middleIndex + _i]);
  44113. }
  44114. }
  44115. var i = 0;
  44116. while (i < size) {
  44117. if (leftElements.first && rightElements.first) {
  44118. if (compareFunction(leftElements.first.data, rightElements.first.data) > 0) {
  44119. array[startIndex + i] = rightElements.shift().data;
  44120. } else {
  44121. array[startIndex + i] = leftElements.shift().data;
  44122. }
  44123. } else if (leftElements.first) {
  44124. array[startIndex + i] = leftElements.shift().data;
  44125. } else {
  44126. array[startIndex + i] = rightElements.shift().data;
  44127. }
  44128. i += 1;
  44129. }
  44130. return array;
  44131. };
  44132. /***/ }),
  44133. /* 388 */
  44134. /***/ (function(module, exports, __webpack_require__) {
  44135. "use strict";
  44136. exports.__esModule = true;
  44137. exports.default = autocompleteValidator;
  44138. /**
  44139. * Autocomplete cell validator.
  44140. *
  44141. * @private
  44142. * @validator AutocompleteValidator
  44143. * @param {*} value - Value of edited cell
  44144. * @param {Function} callback - Callback called with validation result
  44145. */
  44146. function autocompleteValidator(value, callback) {
  44147. if (value == null) {
  44148. value = '';
  44149. }
  44150. if (this.allowEmpty && value === '') {
  44151. callback(true);
  44152. return;
  44153. }
  44154. if (this.strict && this.source) {
  44155. if (typeof this.source === 'function') {
  44156. this.source(value, process(value, callback));
  44157. } else {
  44158. process(value, callback)(this.source);
  44159. }
  44160. } else {
  44161. callback(true);
  44162. }
  44163. };
  44164. /**
  44165. * Function responsible for validation of autocomplete value.
  44166. *
  44167. * @param {*} value - Value of edited cell
  44168. * @param {Function} callback - Callback called with validation result
  44169. */
  44170. function process(value, callback) {
  44171. var originalVal = value;
  44172. return function (source) {
  44173. var found = false;
  44174. for (var s = 0, slen = source.length; s < slen; s++) {
  44175. if (originalVal === source[s]) {
  44176. found = true; // perfect match
  44177. break;
  44178. }
  44179. }
  44180. callback(found);
  44181. };
  44182. }
  44183. /***/ }),
  44184. /* 389 */
  44185. /***/ (function(module, exports, __webpack_require__) {
  44186. "use strict";
  44187. exports.__esModule = true;
  44188. exports.default = dateValidator;
  44189. exports.correctFormat = correctFormat;
  44190. var _moment = __webpack_require__(36);
  44191. var _moment2 = _interopRequireDefault(_moment);
  44192. var _date = __webpack_require__(89);
  44193. var _editors = __webpack_require__(14);
  44194. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44195. /**
  44196. * Date cell validator
  44197. *
  44198. * @private
  44199. * @validator DateValidator
  44200. * @dependencies moment
  44201. * @param {*} value - Value of edited cell
  44202. * @param {Function} callback - Callback called with validation result
  44203. */
  44204. function dateValidator(value, callback) {
  44205. var valid = true;
  44206. var dateEditor = (0, _editors.getEditorInstance)('date', this.instance);
  44207. if (value == null) {
  44208. value = '';
  44209. }
  44210. var isValidDate = (0, _moment2.default)(new Date(value)).isValid() || (0, _moment2.default)(value, dateEditor.defaultDateFormat).isValid();
  44211. // is it in the specified format
  44212. var isValidFormat = (0, _moment2.default)(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid();
  44213. if (this.allowEmpty && value === '') {
  44214. isValidDate = true;
  44215. isValidFormat = true;
  44216. }
  44217. if (!isValidDate) {
  44218. valid = false;
  44219. }
  44220. if (!isValidDate && isValidFormat) {
  44221. valid = true;
  44222. }
  44223. if (isValidDate && !isValidFormat) {
  44224. if (this.correctFormat === true) {
  44225. // if format correction is enabled
  44226. var correctedValue = correctFormat(value, this.dateFormat);
  44227. var row = this.instance.runHooks('unmodifyRow', this.row);
  44228. var column = this.instance.runHooks('unmodifyCol', this.col);
  44229. this.instance.setDataAtCell(row, column, correctedValue, 'dateValidator');
  44230. valid = true;
  44231. } else {
  44232. valid = false;
  44233. }
  44234. }
  44235. callback(valid);
  44236. };
  44237. /**
  44238. * Format the given string using moment.js' format feature
  44239. *
  44240. * @param {String} value
  44241. * @param {String} dateFormat
  44242. * @returns {String}
  44243. */
  44244. function correctFormat(value, dateFormat) {
  44245. var dateFromDate = (0, _moment2.default)((0, _date.getNormalizedDate)(value));
  44246. var dateFromMoment = (0, _moment2.default)(value, dateFormat);
  44247. var isAlphanumeric = value.search(/[A-z]/g) > -1;
  44248. var date = void 0;
  44249. if (dateFromDate.isValid() && dateFromDate.format('x') === dateFromMoment.format('x') || !dateFromMoment.isValid() || isAlphanumeric) {
  44250. date = dateFromDate;
  44251. } else {
  44252. date = dateFromMoment;
  44253. }
  44254. return date.format(dateFormat);
  44255. };
  44256. /***/ }),
  44257. /* 390 */
  44258. /***/ (function(module, exports, __webpack_require__) {
  44259. "use strict";
  44260. exports.__esModule = true;
  44261. exports.default = numericValidator;
  44262. /**
  44263. * Numeric cell validator
  44264. *
  44265. * @private
  44266. * @validator NumericValidator
  44267. * @param {*} value - Value of edited cell
  44268. * @param {*} callback - Callback called with validation result
  44269. */
  44270. function numericValidator(value, callback) {
  44271. if (value == null) {
  44272. value = '';
  44273. }
  44274. if (this.allowEmpty && value === '') {
  44275. callback(true);
  44276. } else if (value === '') {
  44277. callback(false);
  44278. } else {
  44279. callback(/^-?\d*(\.|,)?\d*$/.test(value));
  44280. }
  44281. };
  44282. /***/ }),
  44283. /* 391 */
  44284. /***/ (function(module, exports, __webpack_require__) {
  44285. "use strict";
  44286. exports.__esModule = true;
  44287. exports.default = timeValidator;
  44288. var _moment = __webpack_require__(36);
  44289. var _moment2 = _interopRequireDefault(_moment);
  44290. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44291. // Formats which are correctly parsed to time (supported by momentjs)
  44292. var STRICT_FORMATS = ['YYYY-MM-DDTHH:mm:ss.SSSZ', 'X', // Unix timestamp
  44293. 'x' // Unix ms timestamp
  44294. ];
  44295. /**
  44296. * Time cell validator
  44297. *
  44298. * @private
  44299. * @validator TimeValidator
  44300. * @dependencies moment
  44301. * @param {*} value - Value of edited cell
  44302. * @param {Function} callback - Callback called with validation result
  44303. */
  44304. function timeValidator(value, callback) {
  44305. var valid = true;
  44306. var timeFormat = this.timeFormat || 'h:mm:ss a';
  44307. if (value === null) {
  44308. value = '';
  44309. }
  44310. value = /^\d{3,}$/.test(value) ? parseInt(value, 10) : value;
  44311. var twoDigitValue = /^\d{1,2}$/.test(value);
  44312. if (twoDigitValue) {
  44313. value += ':00';
  44314. }
  44315. var date = (0, _moment2.default)(value, STRICT_FORMATS, true).isValid() ? (0, _moment2.default)(value) : (0, _moment2.default)(value, timeFormat);
  44316. var isValidTime = date.isValid();
  44317. // is it in the specified format
  44318. var isValidFormat = (0, _moment2.default)(value, timeFormat, true).isValid() && !twoDigitValue;
  44319. if (this.allowEmpty && value === '') {
  44320. isValidTime = true;
  44321. isValidFormat = true;
  44322. }
  44323. if (!isValidTime) {
  44324. valid = false;
  44325. }
  44326. if (!isValidTime && isValidFormat) {
  44327. valid = true;
  44328. }
  44329. if (isValidTime && !isValidFormat) {
  44330. if (this.correctFormat === true) {
  44331. // if format correction is enabled
  44332. var correctedValue = date.format(timeFormat);
  44333. var row = this.instance.runHooks('unmodifyRow', this.row);
  44334. var column = this.instance.runHooks('unmodifyCol', this.col);
  44335. this.instance.setDataAtCell(row, column, correctedValue, 'timeValidator');
  44336. valid = true;
  44337. } else {
  44338. valid = false;
  44339. }
  44340. }
  44341. callback(valid);
  44342. };
  44343. /***/ }),
  44344. /* 392 */
  44345. /***/ (function(module, exports, __webpack_require__) {
  44346. "use strict";
  44347. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  44348. var toObject = __webpack_require__(42)
  44349. , toIndex = __webpack_require__(61)
  44350. , toLength = __webpack_require__(24);
  44351. module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, end = @length*/){
  44352. var O = toObject(this)
  44353. , len = toLength(O.length)
  44354. , to = toIndex(target, len)
  44355. , from = toIndex(start, len)
  44356. , end = arguments.length > 2 ? arguments[2] : undefined
  44357. , count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to)
  44358. , inc = 1;
  44359. if(from < to && to < from + count){
  44360. inc = -1;
  44361. from += count - 1;
  44362. to += count - 1;
  44363. }
  44364. while(count-- > 0){
  44365. if(from in O)O[to] = O[from];
  44366. else delete O[to];
  44367. to += inc;
  44368. from += inc;
  44369. } return O;
  44370. };
  44371. /***/ }),
  44372. /* 393 */
  44373. /***/ (function(module, exports, __webpack_require__) {
  44374. "use strict";
  44375. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  44376. var toObject = __webpack_require__(42)
  44377. , toIndex = __webpack_require__(61)
  44378. , toLength = __webpack_require__(24);
  44379. module.exports = function fill(value /*, start = 0, end = @length */){
  44380. var O = toObject(this)
  44381. , length = toLength(O.length)
  44382. , aLen = arguments.length
  44383. , index = toIndex(aLen > 1 ? arguments[1] : undefined, length)
  44384. , end = aLen > 2 ? arguments[2] : undefined
  44385. , endPos = end === undefined ? length : toIndex(end, length);
  44386. while(endPos > index)O[index++] = value;
  44387. return O;
  44388. };
  44389. /***/ }),
  44390. /* 394 */
  44391. /***/ (function(module, exports, __webpack_require__) {
  44392. var isObject = __webpack_require__(15)
  44393. , isArray = __webpack_require__(277)
  44394. , SPECIES = __webpack_require__(10)('species');
  44395. module.exports = function(original){
  44396. var C;
  44397. if(isArray(original)){
  44398. C = original.constructor;
  44399. // cross-realm fallback
  44400. if(typeof C == 'function' && (C === Array || isArray(C.prototype)))C = undefined;
  44401. if(isObject(C)){
  44402. C = C[SPECIES];
  44403. if(C === null)C = undefined;
  44404. }
  44405. } return C === undefined ? Array : C;
  44406. };
  44407. /***/ }),
  44408. /* 395 */
  44409. /***/ (function(module, exports, __webpack_require__) {
  44410. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  44411. var speciesConstructor = __webpack_require__(394);
  44412. module.exports = function(original, length){
  44413. return new (speciesConstructor(original))(length);
  44414. };
  44415. /***/ }),
  44416. /* 396 */
  44417. /***/ (function(module, exports, __webpack_require__) {
  44418. // all enumerable object keys, includes symbols
  44419. var getKeys = __webpack_require__(40)
  44420. , gOPS = __webpack_require__(59)
  44421. , pIE = __webpack_require__(48);
  44422. module.exports = function(it){
  44423. var result = getKeys(it)
  44424. , getSymbols = gOPS.f;
  44425. if(getSymbols){
  44426. var symbols = getSymbols(it)
  44427. , isEnum = pIE.f
  44428. , i = 0
  44429. , key;
  44430. while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key);
  44431. } return result;
  44432. };
  44433. /***/ }),
  44434. /* 397 */
  44435. /***/ (function(module, exports, __webpack_require__) {
  44436. "use strict";
  44437. // 21.2.5.3 get RegExp.prototype.flags
  44438. var anObject = __webpack_require__(18);
  44439. module.exports = function(){
  44440. var that = anObject(this)
  44441. , result = '';
  44442. if(that.global) result += 'g';
  44443. if(that.ignoreCase) result += 'i';
  44444. if(that.multiline) result += 'm';
  44445. if(that.unicode) result += 'u';
  44446. if(that.sticky) result += 'y';
  44447. return result;
  44448. };
  44449. /***/ }),
  44450. /* 398 */
  44451. /***/ (function(module, exports, __webpack_require__) {
  44452. var isObject = __webpack_require__(15)
  44453. , setPrototypeOf = __webpack_require__(286).set;
  44454. module.exports = function(that, target, C){
  44455. var P, S = target.constructor;
  44456. if(S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf){
  44457. setPrototypeOf(that, P);
  44458. } return that;
  44459. };
  44460. /***/ }),
  44461. /* 399 */
  44462. /***/ (function(module, exports) {
  44463. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  44464. module.exports = function(fn, args, that){
  44465. var un = that === undefined;
  44466. switch(args.length){
  44467. case 0: return un ? fn()
  44468. : fn.call(that);
  44469. case 1: return un ? fn(args[0])
  44470. : fn.call(that, args[0]);
  44471. case 2: return un ? fn(args[0], args[1])
  44472. : fn.call(that, args[0], args[1]);
  44473. case 3: return un ? fn(args[0], args[1], args[2])
  44474. : fn.call(that, args[0], args[1], args[2]);
  44475. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  44476. : fn.call(that, args[0], args[1], args[2], args[3]);
  44477. } return fn.apply(that, args);
  44478. };
  44479. /***/ }),
  44480. /* 400 */
  44481. /***/ (function(module, exports, __webpack_require__) {
  44482. "use strict";
  44483. var create = __webpack_require__(80)
  44484. , descriptor = __webpack_require__(41)
  44485. , setToStringTag = __webpack_require__(49)
  44486. , IteratorPrototype = {};
  44487. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  44488. __webpack_require__(32)(IteratorPrototype, __webpack_require__(10)('iterator'), function(){ return this; });
  44489. module.exports = function(Constructor, NAME, next){
  44490. Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
  44491. setToStringTag(Constructor, NAME + ' Iterator');
  44492. };
  44493. /***/ }),
  44494. /* 401 */
  44495. /***/ (function(module, exports, __webpack_require__) {
  44496. var getKeys = __webpack_require__(40)
  44497. , toIObject = __webpack_require__(23);
  44498. module.exports = function(object, el){
  44499. var O = toIObject(object)
  44500. , keys = getKeys(O)
  44501. , length = keys.length
  44502. , index = 0
  44503. , key;
  44504. while(length > index)if(O[key = keys[index++]] === el)return key;
  44505. };
  44506. /***/ }),
  44507. /* 402 */
  44508. /***/ (function(module, exports, __webpack_require__) {
  44509. var global = __webpack_require__(13)
  44510. , macrotask = __webpack_require__(86).set
  44511. , Observer = global.MutationObserver || global.WebKitMutationObserver
  44512. , process = global.process
  44513. , Promise = global.Promise
  44514. , isNode = __webpack_require__(39)(process) == 'process';
  44515. module.exports = function(){
  44516. var head, last, notify;
  44517. var flush = function(){
  44518. var parent, fn;
  44519. if(isNode && (parent = process.domain))parent.exit();
  44520. while(head){
  44521. fn = head.fn;
  44522. head = head.next;
  44523. try {
  44524. fn();
  44525. } catch(e){
  44526. if(head)notify();
  44527. else last = undefined;
  44528. throw e;
  44529. }
  44530. } last = undefined;
  44531. if(parent)parent.enter();
  44532. };
  44533. // Node.js
  44534. if(isNode){
  44535. notify = function(){
  44536. process.nextTick(flush);
  44537. };
  44538. // browsers with MutationObserver
  44539. } else if(Observer){
  44540. var toggle = true
  44541. , node = document.createTextNode('');
  44542. new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
  44543. notify = function(){
  44544. node.data = toggle = !toggle;
  44545. };
  44546. // environments with maybe non-completely correct, but existent Promise
  44547. } else if(Promise && Promise.resolve){
  44548. var promise = Promise.resolve();
  44549. notify = function(){
  44550. promise.then(flush);
  44551. };
  44552. // for other environments - macrotask based on:
  44553. // - setImmediate
  44554. // - MessageChannel
  44555. // - window.postMessag
  44556. // - onreadystatechange
  44557. // - setTimeout
  44558. } else {
  44559. notify = function(){
  44560. // strange IE + webpack dev server bug - use .call(global)
  44561. macrotask.call(global, flush);
  44562. };
  44563. }
  44564. return function(fn){
  44565. var task = {fn: fn, next: undefined};
  44566. if(last)last.next = task;
  44567. if(!head){
  44568. head = task;
  44569. notify();
  44570. } last = task;
  44571. };
  44572. };
  44573. /***/ }),
  44574. /* 403 */
  44575. /***/ (function(module, exports, __webpack_require__) {
  44576. var dP = __webpack_require__(19)
  44577. , anObject = __webpack_require__(18)
  44578. , getKeys = __webpack_require__(40);
  44579. module.exports = __webpack_require__(21) ? Object.defineProperties : function defineProperties(O, Properties){
  44580. anObject(O);
  44581. var keys = getKeys(Properties)
  44582. , length = keys.length
  44583. , i = 0
  44584. , P;
  44585. while(length > i)dP.f(O, P = keys[i++], Properties[P]);
  44586. return O;
  44587. };
  44588. /***/ }),
  44589. /* 404 */
  44590. /***/ (function(module, exports, __webpack_require__) {
  44591. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  44592. var toIObject = __webpack_require__(23)
  44593. , gOPN = __webpack_require__(82).f
  44594. , toString = {}.toString;
  44595. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  44596. ? Object.getOwnPropertyNames(window) : [];
  44597. var getWindowNames = function(it){
  44598. try {
  44599. return gOPN(it);
  44600. } catch(e){
  44601. return windowNames.slice();
  44602. }
  44603. };
  44604. module.exports.f = function getOwnPropertyNames(it){
  44605. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  44606. };
  44607. /***/ }),
  44608. /* 405 */
  44609. /***/ (function(module, exports, __webpack_require__) {
  44610. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  44611. var has = __webpack_require__(22)
  44612. , toObject = __webpack_require__(42)
  44613. , IE_PROTO = __webpack_require__(83)('IE_PROTO')
  44614. , ObjectProto = Object.prototype;
  44615. module.exports = Object.getPrototypeOf || function(O){
  44616. O = toObject(O);
  44617. if(has(O, IE_PROTO))return O[IE_PROTO];
  44618. if(typeof O.constructor == 'function' && O instanceof O.constructor){
  44619. return O.constructor.prototype;
  44620. } return O instanceof Object ? ObjectProto : null;
  44621. };
  44622. /***/ }),
  44623. /* 406 */
  44624. /***/ (function(module, exports, __webpack_require__) {
  44625. // all object keys, includes non-enumerable and symbols
  44626. var gOPN = __webpack_require__(82)
  44627. , gOPS = __webpack_require__(59)
  44628. , anObject = __webpack_require__(18)
  44629. , Reflect = __webpack_require__(13).Reflect;
  44630. module.exports = Reflect && Reflect.ownKeys || function ownKeys(it){
  44631. var keys = gOPN.f(anObject(it))
  44632. , getSymbols = gOPS.f;
  44633. return getSymbols ? keys.concat(getSymbols(it)) : keys;
  44634. };
  44635. /***/ }),
  44636. /* 407 */
  44637. /***/ (function(module, exports) {
  44638. // 7.2.9 SameValue(x, y)
  44639. module.exports = Object.is || function is(x, y){
  44640. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  44641. };
  44642. /***/ }),
  44643. /* 408 */
  44644. /***/ (function(module, exports, __webpack_require__) {
  44645. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  44646. var anObject = __webpack_require__(18)
  44647. , aFunction = __webpack_require__(73)
  44648. , SPECIES = __webpack_require__(10)('species');
  44649. module.exports = function(O, D){
  44650. var C = anObject(O).constructor, S;
  44651. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  44652. };
  44653. /***/ }),
  44654. /* 409 */
  44655. /***/ (function(module, exports, __webpack_require__) {
  44656. var toInteger = __webpack_require__(62)
  44657. , defined = __webpack_require__(30);
  44658. // true -> String#at
  44659. // false -> String#codePointAt
  44660. module.exports = function(TO_STRING){
  44661. return function(that, pos){
  44662. var s = String(defined(that))
  44663. , i = toInteger(pos)
  44664. , l = s.length
  44665. , a, b;
  44666. if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
  44667. a = s.charCodeAt(i);
  44668. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  44669. ? TO_STRING ? s.charAt(i) : a
  44670. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  44671. };
  44672. };
  44673. /***/ }),
  44674. /* 410 */
  44675. /***/ (function(module, exports, __webpack_require__) {
  44676. var global = __webpack_require__(13)
  44677. , core = __webpack_require__(45)
  44678. , LIBRARY = __webpack_require__(58)
  44679. , wksExt = __webpack_require__(290)
  44680. , defineProperty = __webpack_require__(19).f;
  44681. module.exports = function(name){
  44682. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  44683. if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
  44684. };
  44685. /***/ }),
  44686. /* 411 */
  44687. /***/ (function(module, exports) {
  44688. // removed by extract-text-webpack-plugin
  44689. /***/ }),
  44690. /* 412 */
  44691. /***/ (function(module, exports) {
  44692. // removed by extract-text-webpack-plugin
  44693. /***/ }),
  44694. /* 413 */
  44695. /***/ (function(module, exports) {
  44696. // removed by extract-text-webpack-plugin
  44697. /***/ }),
  44698. /* 414 */
  44699. /***/ (function(module, exports) {
  44700. // removed by extract-text-webpack-plugin
  44701. /***/ }),
  44702. /* 415 */
  44703. /***/ (function(module, exports) {
  44704. // removed by extract-text-webpack-plugin
  44705. /***/ }),
  44706. /* 416 */
  44707. /***/ (function(module, exports) {
  44708. // removed by extract-text-webpack-plugin
  44709. /***/ }),
  44710. /* 417 */
  44711. /***/ (function(module, exports) {
  44712. // removed by extract-text-webpack-plugin
  44713. /***/ }),
  44714. /* 418 */
  44715. /***/ (function(module, exports, __webpack_require__) {
  44716. var map = {
  44717. "./af": 133,
  44718. "./af.js": 133,
  44719. "./ar": 140,
  44720. "./ar-dz": 134,
  44721. "./ar-dz.js": 134,
  44722. "./ar-kw": 135,
  44723. "./ar-kw.js": 135,
  44724. "./ar-ly": 136,
  44725. "./ar-ly.js": 136,
  44726. "./ar-ma": 137,
  44727. "./ar-ma.js": 137,
  44728. "./ar-sa": 138,
  44729. "./ar-sa.js": 138,
  44730. "./ar-tn": 139,
  44731. "./ar-tn.js": 139,
  44732. "./ar.js": 140,
  44733. "./az": 141,
  44734. "./az.js": 141,
  44735. "./be": 142,
  44736. "./be.js": 142,
  44737. "./bg": 143,
  44738. "./bg.js": 143,
  44739. "./bn": 144,
  44740. "./bn.js": 144,
  44741. "./bo": 145,
  44742. "./bo.js": 145,
  44743. "./br": 146,
  44744. "./br.js": 146,
  44745. "./bs": 147,
  44746. "./bs.js": 147,
  44747. "./ca": 148,
  44748. "./ca.js": 148,
  44749. "./cs": 149,
  44750. "./cs.js": 149,
  44751. "./cv": 150,
  44752. "./cv.js": 150,
  44753. "./cy": 151,
  44754. "./cy.js": 151,
  44755. "./da": 152,
  44756. "./da.js": 152,
  44757. "./de": 155,
  44758. "./de-at": 153,
  44759. "./de-at.js": 153,
  44760. "./de-ch": 154,
  44761. "./de-ch.js": 154,
  44762. "./de.js": 155,
  44763. "./dv": 156,
  44764. "./dv.js": 156,
  44765. "./el": 157,
  44766. "./el.js": 157,
  44767. "./en-au": 158,
  44768. "./en-au.js": 158,
  44769. "./en-ca": 159,
  44770. "./en-ca.js": 159,
  44771. "./en-gb": 160,
  44772. "./en-gb.js": 160,
  44773. "./en-ie": 161,
  44774. "./en-ie.js": 161,
  44775. "./en-nz": 162,
  44776. "./en-nz.js": 162,
  44777. "./eo": 163,
  44778. "./eo.js": 163,
  44779. "./es": 165,
  44780. "./es-do": 164,
  44781. "./es-do.js": 164,
  44782. "./es.js": 165,
  44783. "./et": 166,
  44784. "./et.js": 166,
  44785. "./eu": 167,
  44786. "./eu.js": 167,
  44787. "./fa": 168,
  44788. "./fa.js": 168,
  44789. "./fi": 169,
  44790. "./fi.js": 169,
  44791. "./fo": 170,
  44792. "./fo.js": 170,
  44793. "./fr": 173,
  44794. "./fr-ca": 171,
  44795. "./fr-ca.js": 171,
  44796. "./fr-ch": 172,
  44797. "./fr-ch.js": 172,
  44798. "./fr.js": 173,
  44799. "./fy": 174,
  44800. "./fy.js": 174,
  44801. "./gd": 175,
  44802. "./gd.js": 175,
  44803. "./gl": 176,
  44804. "./gl.js": 176,
  44805. "./gom-latn": 177,
  44806. "./gom-latn.js": 177,
  44807. "./he": 178,
  44808. "./he.js": 178,
  44809. "./hi": 179,
  44810. "./hi.js": 179,
  44811. "./hr": 180,
  44812. "./hr.js": 180,
  44813. "./hu": 181,
  44814. "./hu.js": 181,
  44815. "./hy-am": 182,
  44816. "./hy-am.js": 182,
  44817. "./id": 183,
  44818. "./id.js": 183,
  44819. "./is": 184,
  44820. "./is.js": 184,
  44821. "./it": 185,
  44822. "./it.js": 185,
  44823. "./ja": 186,
  44824. "./ja.js": 186,
  44825. "./jv": 187,
  44826. "./jv.js": 187,
  44827. "./ka": 188,
  44828. "./ka.js": 188,
  44829. "./kk": 189,
  44830. "./kk.js": 189,
  44831. "./km": 190,
  44832. "./km.js": 190,
  44833. "./kn": 191,
  44834. "./kn.js": 191,
  44835. "./ko": 192,
  44836. "./ko.js": 192,
  44837. "./ky": 193,
  44838. "./ky.js": 193,
  44839. "./lb": 194,
  44840. "./lb.js": 194,
  44841. "./lo": 195,
  44842. "./lo.js": 195,
  44843. "./lt": 196,
  44844. "./lt.js": 196,
  44845. "./lv": 197,
  44846. "./lv.js": 197,
  44847. "./me": 198,
  44848. "./me.js": 198,
  44849. "./mi": 199,
  44850. "./mi.js": 199,
  44851. "./mk": 200,
  44852. "./mk.js": 200,
  44853. "./ml": 201,
  44854. "./ml.js": 201,
  44855. "./mr": 202,
  44856. "./mr.js": 202,
  44857. "./ms": 204,
  44858. "./ms-my": 203,
  44859. "./ms-my.js": 203,
  44860. "./ms.js": 204,
  44861. "./my": 205,
  44862. "./my.js": 205,
  44863. "./nb": 206,
  44864. "./nb.js": 206,
  44865. "./ne": 207,
  44866. "./ne.js": 207,
  44867. "./nl": 209,
  44868. "./nl-be": 208,
  44869. "./nl-be.js": 208,
  44870. "./nl.js": 209,
  44871. "./nn": 210,
  44872. "./nn.js": 210,
  44873. "./pa-in": 211,
  44874. "./pa-in.js": 211,
  44875. "./pl": 212,
  44876. "./pl.js": 212,
  44877. "./pt": 214,
  44878. "./pt-br": 213,
  44879. "./pt-br.js": 213,
  44880. "./pt.js": 214,
  44881. "./ro": 215,
  44882. "./ro.js": 215,
  44883. "./ru": 216,
  44884. "./ru.js": 216,
  44885. "./sd": 217,
  44886. "./sd.js": 217,
  44887. "./se": 218,
  44888. "./se.js": 218,
  44889. "./si": 219,
  44890. "./si.js": 219,
  44891. "./sk": 220,
  44892. "./sk.js": 220,
  44893. "./sl": 221,
  44894. "./sl.js": 221,
  44895. "./sq": 222,
  44896. "./sq.js": 222,
  44897. "./sr": 224,
  44898. "./sr-cyrl": 223,
  44899. "./sr-cyrl.js": 223,
  44900. "./sr.js": 224,
  44901. "./ss": 225,
  44902. "./ss.js": 225,
  44903. "./sv": 226,
  44904. "./sv.js": 226,
  44905. "./sw": 227,
  44906. "./sw.js": 227,
  44907. "./ta": 228,
  44908. "./ta.js": 228,
  44909. "./te": 229,
  44910. "./te.js": 229,
  44911. "./tet": 230,
  44912. "./tet.js": 230,
  44913. "./th": 231,
  44914. "./th.js": 231,
  44915. "./tl-ph": 232,
  44916. "./tl-ph.js": 232,
  44917. "./tlh": 233,
  44918. "./tlh.js": 233,
  44919. "./tr": 234,
  44920. "./tr.js": 234,
  44921. "./tzl": 235,
  44922. "./tzl.js": 235,
  44923. "./tzm": 237,
  44924. "./tzm-latn": 236,
  44925. "./tzm-latn.js": 236,
  44926. "./tzm.js": 237,
  44927. "./uk": 238,
  44928. "./uk.js": 238,
  44929. "./ur": 239,
  44930. "./ur.js": 239,
  44931. "./uz": 241,
  44932. "./uz-latn": 240,
  44933. "./uz-latn.js": 240,
  44934. "./uz.js": 241,
  44935. "./vi": 242,
  44936. "./vi.js": 242,
  44937. "./x-pseudo": 243,
  44938. "./x-pseudo.js": 243,
  44939. "./yo": 244,
  44940. "./yo.js": 244,
  44941. "./zh-cn": 245,
  44942. "./zh-cn.js": 245,
  44943. "./zh-hk": 246,
  44944. "./zh-hk.js": 246,
  44945. "./zh-tw": 247,
  44946. "./zh-tw.js": 247
  44947. };
  44948. function webpackContext(req) {
  44949. return __webpack_require__(webpackContextResolve(req));
  44950. };
  44951. function webpackContextResolve(req) {
  44952. var id = map[req];
  44953. if(!(id + 1)) // check for number or string
  44954. throw new Error("Cannot find module '" + req + "'.");
  44955. return id;
  44956. };
  44957. webpackContext.keys = function webpackContextKeys() {
  44958. return Object.keys(map);
  44959. };
  44960. webpackContext.resolve = webpackContextResolve;
  44961. module.exports = webpackContext;
  44962. webpackContext.id = 418;
  44963. /***/ }),
  44964. /* 419 */
  44965. /***/ (function(module, exports, __webpack_require__) {
  44966. /*!
  44967. * Pikaday
  44968. *
  44969. * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
  44970. */
  44971. (function (root, factory)
  44972. {
  44973. 'use strict';
  44974. var moment;
  44975. if (true) {
  44976. // CommonJS module
  44977. // Load moment.js as an optional dependency
  44978. try { moment = __webpack_require__(36); } catch (e) {}
  44979. module.exports = factory(moment);
  44980. } else if (typeof define === 'function' && define.amd) {
  44981. // AMD. Register as an anonymous module.
  44982. define(function (req)
  44983. {
  44984. // Load moment.js as an optional dependency
  44985. var id = 'moment';
  44986. try { moment = req(id); } catch (e) {}
  44987. return factory(moment);
  44988. });
  44989. } else {
  44990. root.Pikaday = factory(root.moment);
  44991. }
  44992. }(this, function (moment)
  44993. {
  44994. 'use strict';
  44995. /**
  44996. * feature detection and helper functions
  44997. */
  44998. var hasMoment = typeof moment === 'function',
  44999. hasEventListeners = !!window.addEventListener,
  45000. document = window.document,
  45001. sto = window.setTimeout,
  45002. addEvent = function(el, e, callback, capture)
  45003. {
  45004. if (hasEventListeners) {
  45005. el.addEventListener(e, callback, !!capture);
  45006. } else {
  45007. el.attachEvent('on' + e, callback);
  45008. }
  45009. },
  45010. removeEvent = function(el, e, callback, capture)
  45011. {
  45012. if (hasEventListeners) {
  45013. el.removeEventListener(e, callback, !!capture);
  45014. } else {
  45015. el.detachEvent('on' + e, callback);
  45016. }
  45017. },
  45018. fireEvent = function(el, eventName, data)
  45019. {
  45020. var ev;
  45021. if (document.createEvent) {
  45022. ev = document.createEvent('HTMLEvents');
  45023. ev.initEvent(eventName, true, false);
  45024. ev = extend(ev, data);
  45025. el.dispatchEvent(ev);
  45026. } else if (document.createEventObject) {
  45027. ev = document.createEventObject();
  45028. ev = extend(ev, data);
  45029. el.fireEvent('on' + eventName, ev);
  45030. }
  45031. },
  45032. trim = function(str)
  45033. {
  45034. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
  45035. },
  45036. hasClass = function(el, cn)
  45037. {
  45038. return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
  45039. },
  45040. addClass = function(el, cn)
  45041. {
  45042. if (!hasClass(el, cn)) {
  45043. el.className = (el.className === '') ? cn : el.className + ' ' + cn;
  45044. }
  45045. },
  45046. removeClass = function(el, cn)
  45047. {
  45048. el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
  45049. },
  45050. isArray = function(obj)
  45051. {
  45052. return (/Array/).test(Object.prototype.toString.call(obj));
  45053. },
  45054. isDate = function(obj)
  45055. {
  45056. return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
  45057. },
  45058. isWeekend = function(date)
  45059. {
  45060. var day = date.getDay();
  45061. return day === 0 || day === 6;
  45062. },
  45063. isLeapYear = function(year)
  45064. {
  45065. // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
  45066. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  45067. },
  45068. getDaysInMonth = function(year, month)
  45069. {
  45070. return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  45071. },
  45072. setToStartOfDay = function(date)
  45073. {
  45074. if (isDate(date)) date.setHours(0,0,0,0);
  45075. },
  45076. compareDates = function(a,b)
  45077. {
  45078. // weak date comparison (use setToStartOfDay(date) to ensure correct result)
  45079. return a.getTime() === b.getTime();
  45080. },
  45081. extend = function(to, from, overwrite)
  45082. {
  45083. var prop, hasProp;
  45084. for (prop in from) {
  45085. hasProp = to[prop] !== undefined;
  45086. if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
  45087. if (isDate(from[prop])) {
  45088. if (overwrite) {
  45089. to[prop] = new Date(from[prop].getTime());
  45090. }
  45091. }
  45092. else if (isArray(from[prop])) {
  45093. if (overwrite) {
  45094. to[prop] = from[prop].slice(0);
  45095. }
  45096. } else {
  45097. to[prop] = extend({}, from[prop], overwrite);
  45098. }
  45099. } else if (overwrite || !hasProp) {
  45100. to[prop] = from[prop];
  45101. }
  45102. }
  45103. return to;
  45104. },
  45105. adjustCalendar = function(calendar) {
  45106. if (calendar.month < 0) {
  45107. calendar.year -= Math.ceil(Math.abs(calendar.month)/12);
  45108. calendar.month += 12;
  45109. }
  45110. if (calendar.month > 11) {
  45111. calendar.year += Math.floor(Math.abs(calendar.month)/12);
  45112. calendar.month -= 12;
  45113. }
  45114. return calendar;
  45115. },
  45116. /**
  45117. * defaults and localisation
  45118. */
  45119. defaults = {
  45120. // bind the picker to a form field
  45121. field: null,
  45122. // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
  45123. bound: undefined,
  45124. // position of the datepicker, relative to the field (default to bottom & left)
  45125. // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
  45126. position: 'bottom left',
  45127. // automatically fit in the viewport even if it means repositioning from the position option
  45128. reposition: true,
  45129. // the default output format for `.toString()` and `field` value
  45130. format: 'YYYY-MM-DD',
  45131. // the initial date to view when first opened
  45132. defaultDate: null,
  45133. // make the `defaultDate` the initial selected value
  45134. setDefaultDate: false,
  45135. // first day of week (0: Sunday, 1: Monday etc)
  45136. firstDay: 0,
  45137. // the default flag for moment's strict date parsing
  45138. formatStrict: false,
  45139. // the minimum/earliest date that can be selected
  45140. minDate: null,
  45141. // the maximum/latest date that can be selected
  45142. maxDate: null,
  45143. // number of years either side, or array of upper/lower range
  45144. yearRange: 10,
  45145. // show week numbers at head of row
  45146. showWeekNumber: false,
  45147. // used internally (don't config outside)
  45148. minYear: 0,
  45149. maxYear: 9999,
  45150. minMonth: undefined,
  45151. maxMonth: undefined,
  45152. startRange: null,
  45153. endRange: null,
  45154. isRTL: false,
  45155. // Additional text to append to the year in the calendar title
  45156. yearSuffix: '',
  45157. // Render the month after year in the calendar title
  45158. showMonthAfterYear: false,
  45159. // Render days of the calendar grid that fall in the next or previous month
  45160. showDaysInNextAndPreviousMonths: false,
  45161. // how many months are visible
  45162. numberOfMonths: 1,
  45163. // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
  45164. // only used for the first display or when a selected date is not visible
  45165. mainCalendar: 'left',
  45166. // Specify a DOM element to render the calendar in
  45167. container: undefined,
  45168. // internationalization
  45169. i18n: {
  45170. previousMonth : 'Previous Month',
  45171. nextMonth : 'Next Month',
  45172. months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
  45173. weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
  45174. weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
  45175. },
  45176. // Theme Classname
  45177. theme: null,
  45178. // callback function
  45179. onSelect: null,
  45180. onOpen: null,
  45181. onClose: null,
  45182. onDraw: null
  45183. },
  45184. /**
  45185. * templating functions to abstract HTML rendering
  45186. */
  45187. renderDayName = function(opts, day, abbr)
  45188. {
  45189. day += opts.firstDay;
  45190. while (day >= 7) {
  45191. day -= 7;
  45192. }
  45193. return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
  45194. },
  45195. renderDay = function(opts)
  45196. {
  45197. var arr = [];
  45198. var ariaSelected = 'false';
  45199. if (opts.isEmpty) {
  45200. if (opts.showDaysInNextAndPreviousMonths) {
  45201. arr.push('is-outside-current-month');
  45202. } else {
  45203. return '<td class="is-empty"></td>';
  45204. }
  45205. }
  45206. if (opts.isDisabled) {
  45207. arr.push('is-disabled');
  45208. }
  45209. if (opts.isToday) {
  45210. arr.push('is-today');
  45211. }
  45212. if (opts.isSelected) {
  45213. arr.push('is-selected');
  45214. ariaSelected = 'true';
  45215. }
  45216. if (opts.isInRange) {
  45217. arr.push('is-inrange');
  45218. }
  45219. if (opts.isStartRange) {
  45220. arr.push('is-startrange');
  45221. }
  45222. if (opts.isEndRange) {
  45223. arr.push('is-endrange');
  45224. }
  45225. return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' +
  45226. '<button class="pika-button pika-day" type="button" ' +
  45227. 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' +
  45228. opts.day +
  45229. '</button>' +
  45230. '</td>';
  45231. },
  45232. renderWeek = function (d, m, y) {
  45233. // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
  45234. var onejan = new Date(y, 0, 1),
  45235. weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7);
  45236. return '<td class="pika-week">' + weekNum + '</td>';
  45237. },
  45238. renderRow = function(days, isRTL)
  45239. {
  45240. return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
  45241. },
  45242. renderBody = function(rows)
  45243. {
  45244. return '<tbody>' + rows.join('') + '</tbody>';
  45245. },
  45246. renderHead = function(opts)
  45247. {
  45248. var i, arr = [];
  45249. if (opts.showWeekNumber) {
  45250. arr.push('<th></th>');
  45251. }
  45252. for (i = 0; i < 7; i++) {
  45253. arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
  45254. }
  45255. return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
  45256. },
  45257. renderTitle = function(instance, c, year, month, refYear, randId)
  45258. {
  45259. var i, j, arr,
  45260. opts = instance._o,
  45261. isMinYear = year === opts.minYear,
  45262. isMaxYear = year === opts.maxYear,
  45263. html = '<div id="' + randId + '" class="pika-title" role="heading" aria-live="assertive">',
  45264. monthHtml,
  45265. yearHtml,
  45266. prev = true,
  45267. next = true;
  45268. for (arr = [], i = 0; i < 12; i++) {
  45269. arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
  45270. (i === month ? ' selected="selected"': '') +
  45271. ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled="disabled"' : '') + '>' +
  45272. opts.i18n.months[i] + '</option>');
  45273. }
  45274. monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
  45275. if (isArray(opts.yearRange)) {
  45276. i = opts.yearRange[0];
  45277. j = opts.yearRange[1] + 1;
  45278. } else {
  45279. i = year - opts.yearRange;
  45280. j = 1 + year + opts.yearRange;
  45281. }
  45282. for (arr = []; i < j && i <= opts.maxYear; i++) {
  45283. if (i >= opts.minYear) {
  45284. arr.push('<option value="' + i + '"' + (i === year ? ' selected="selected"': '') + '>' + (i) + '</option>');
  45285. }
  45286. }
  45287. yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
  45288. if (opts.showMonthAfterYear) {
  45289. html += yearHtml + monthHtml;
  45290. } else {
  45291. html += monthHtml + yearHtml;
  45292. }
  45293. if (isMinYear && (month === 0 || opts.minMonth >= month)) {
  45294. prev = false;
  45295. }
  45296. if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
  45297. next = false;
  45298. }
  45299. if (c === 0) {
  45300. html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
  45301. }
  45302. if (c === (instance._o.numberOfMonths - 1) ) {
  45303. html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
  45304. }
  45305. return html += '</div>';
  45306. },
  45307. renderTable = function(opts, data, randId)
  45308. {
  45309. return '<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="' + randId + '">' + renderHead(opts) + renderBody(data) + '</table>';
  45310. },
  45311. /**
  45312. * Pikaday constructor
  45313. */
  45314. Pikaday = function(options)
  45315. {
  45316. var self = this,
  45317. opts = self.config(options);
  45318. self._onMouseDown = function(e)
  45319. {
  45320. if (!self._v) {
  45321. return;
  45322. }
  45323. e = e || window.event;
  45324. var target = e.target || e.srcElement;
  45325. if (!target) {
  45326. return;
  45327. }
  45328. if (!hasClass(target, 'is-disabled')) {
  45329. if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty') && !hasClass(target.parentNode, 'is-disabled')) {
  45330. self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
  45331. if (opts.bound) {
  45332. sto(function() {
  45333. self.hide();
  45334. if (opts.field) {
  45335. opts.field.blur();
  45336. }
  45337. }, 100);
  45338. }
  45339. }
  45340. else if (hasClass(target, 'pika-prev')) {
  45341. self.prevMonth();
  45342. }
  45343. else if (hasClass(target, 'pika-next')) {
  45344. self.nextMonth();
  45345. }
  45346. }
  45347. if (!hasClass(target, 'pika-select')) {
  45348. // if this is touch event prevent mouse events emulation
  45349. if (e.preventDefault) {
  45350. e.preventDefault();
  45351. } else {
  45352. e.returnValue = false;
  45353. return false;
  45354. }
  45355. } else {
  45356. self._c = true;
  45357. }
  45358. };
  45359. self._onChange = function(e)
  45360. {
  45361. e = e || window.event;
  45362. var target = e.target || e.srcElement;
  45363. if (!target) {
  45364. return;
  45365. }
  45366. if (hasClass(target, 'pika-select-month')) {
  45367. self.gotoMonth(target.value);
  45368. }
  45369. else if (hasClass(target, 'pika-select-year')) {
  45370. self.gotoYear(target.value);
  45371. }
  45372. };
  45373. self._onKeyChange = function(e)
  45374. {
  45375. e = e || window.event;
  45376. if (self.isVisible()) {
  45377. switch(e.keyCode){
  45378. case 13:
  45379. case 27:
  45380. opts.field.blur();
  45381. break;
  45382. case 37:
  45383. e.preventDefault();
  45384. self.adjustDate('subtract', 1);
  45385. break;
  45386. case 38:
  45387. self.adjustDate('subtract', 7);
  45388. break;
  45389. case 39:
  45390. self.adjustDate('add', 1);
  45391. break;
  45392. case 40:
  45393. self.adjustDate('add', 7);
  45394. break;
  45395. }
  45396. }
  45397. };
  45398. self._onInputChange = function(e)
  45399. {
  45400. var date;
  45401. if (e.firedBy === self) {
  45402. return;
  45403. }
  45404. if (hasMoment) {
  45405. date = moment(opts.field.value, opts.format, opts.formatStrict);
  45406. date = (date && date.isValid()) ? date.toDate() : null;
  45407. }
  45408. else {
  45409. date = new Date(Date.parse(opts.field.value));
  45410. }
  45411. if (isDate(date)) {
  45412. self.setDate(date);
  45413. }
  45414. if (!self._v) {
  45415. self.show();
  45416. }
  45417. };
  45418. self._onInputFocus = function()
  45419. {
  45420. self.show();
  45421. };
  45422. self._onInputClick = function()
  45423. {
  45424. self.show();
  45425. };
  45426. self._onInputBlur = function()
  45427. {
  45428. // IE allows pika div to gain focus; catch blur the input field
  45429. var pEl = document.activeElement;
  45430. do {
  45431. if (hasClass(pEl, 'pika-single')) {
  45432. return;
  45433. }
  45434. }
  45435. while ((pEl = pEl.parentNode));
  45436. if (!self._c) {
  45437. self._b = sto(function() {
  45438. self.hide();
  45439. }, 50);
  45440. }
  45441. self._c = false;
  45442. };
  45443. self._onClick = function(e)
  45444. {
  45445. e = e || window.event;
  45446. var target = e.target || e.srcElement,
  45447. pEl = target;
  45448. if (!target) {
  45449. return;
  45450. }
  45451. if (!hasEventListeners && hasClass(target, 'pika-select')) {
  45452. if (!target.onchange) {
  45453. target.setAttribute('onchange', 'return;');
  45454. addEvent(target, 'change', self._onChange);
  45455. }
  45456. }
  45457. do {
  45458. if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
  45459. return;
  45460. }
  45461. }
  45462. while ((pEl = pEl.parentNode));
  45463. if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
  45464. self.hide();
  45465. }
  45466. };
  45467. self.el = document.createElement('div');
  45468. self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : '');
  45469. addEvent(self.el, 'mousedown', self._onMouseDown, true);
  45470. addEvent(self.el, 'touchend', self._onMouseDown, true);
  45471. addEvent(self.el, 'change', self._onChange);
  45472. addEvent(document, 'keydown', self._onKeyChange);
  45473. if (opts.field) {
  45474. if (opts.container) {
  45475. opts.container.appendChild(self.el);
  45476. } else if (opts.bound) {
  45477. document.body.appendChild(self.el);
  45478. } else {
  45479. opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
  45480. }
  45481. addEvent(opts.field, 'change', self._onInputChange);
  45482. if (!opts.defaultDate) {
  45483. if (hasMoment && opts.field.value) {
  45484. opts.defaultDate = moment(opts.field.value, opts.format).toDate();
  45485. } else {
  45486. opts.defaultDate = new Date(Date.parse(opts.field.value));
  45487. }
  45488. opts.setDefaultDate = true;
  45489. }
  45490. }
  45491. var defDate = opts.defaultDate;
  45492. if (isDate(defDate)) {
  45493. if (opts.setDefaultDate) {
  45494. self.setDate(defDate, true);
  45495. } else {
  45496. self.gotoDate(defDate);
  45497. }
  45498. } else {
  45499. self.gotoDate(new Date());
  45500. }
  45501. if (opts.bound) {
  45502. this.hide();
  45503. self.el.className += ' is-bound';
  45504. addEvent(opts.trigger, 'click', self._onInputClick);
  45505. addEvent(opts.trigger, 'focus', self._onInputFocus);
  45506. addEvent(opts.trigger, 'blur', self._onInputBlur);
  45507. } else {
  45508. this.show();
  45509. }
  45510. };
  45511. /**
  45512. * public Pikaday API
  45513. */
  45514. Pikaday.prototype = {
  45515. /**
  45516. * configure functionality
  45517. */
  45518. config: function(options)
  45519. {
  45520. if (!this._o) {
  45521. this._o = extend({}, defaults, true);
  45522. }
  45523. var opts = extend(this._o, options, true);
  45524. opts.isRTL = !!opts.isRTL;
  45525. opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
  45526. opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null;
  45527. opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
  45528. opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
  45529. opts.disableWeekends = !!opts.disableWeekends;
  45530. opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null;
  45531. var nom = parseInt(opts.numberOfMonths, 10) || 1;
  45532. opts.numberOfMonths = nom > 4 ? 4 : nom;
  45533. if (!isDate(opts.minDate)) {
  45534. opts.minDate = false;
  45535. }
  45536. if (!isDate(opts.maxDate)) {
  45537. opts.maxDate = false;
  45538. }
  45539. if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
  45540. opts.maxDate = opts.minDate = false;
  45541. }
  45542. if (opts.minDate) {
  45543. this.setMinDate(opts.minDate);
  45544. }
  45545. if (opts.maxDate) {
  45546. this.setMaxDate(opts.maxDate);
  45547. }
  45548. if (isArray(opts.yearRange)) {
  45549. var fallback = new Date().getFullYear() - 10;
  45550. opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
  45551. opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
  45552. } else {
  45553. opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
  45554. if (opts.yearRange > 100) {
  45555. opts.yearRange = 100;
  45556. }
  45557. }
  45558. return opts;
  45559. },
  45560. /**
  45561. * return a formatted string of the current selection (using Moment.js if available)
  45562. */
  45563. toString: function(format)
  45564. {
  45565. return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
  45566. },
  45567. /**
  45568. * return a Moment.js object of the current selection (if available)
  45569. */
  45570. getMoment: function()
  45571. {
  45572. return hasMoment ? moment(this._d) : null;
  45573. },
  45574. /**
  45575. * set the current selection from a Moment.js object (if available)
  45576. */
  45577. setMoment: function(date, preventOnSelect)
  45578. {
  45579. if (hasMoment && moment.isMoment(date)) {
  45580. this.setDate(date.toDate(), preventOnSelect);
  45581. }
  45582. },
  45583. /**
  45584. * return a Date object of the current selection with fallback for the current date
  45585. */
  45586. getDate: function()
  45587. {
  45588. return isDate(this._d) ? new Date(this._d.getTime()) : new Date();
  45589. },
  45590. /**
  45591. * set the current selection
  45592. */
  45593. setDate: function(date, preventOnSelect)
  45594. {
  45595. if (!date) {
  45596. this._d = null;
  45597. if (this._o.field) {
  45598. this._o.field.value = '';
  45599. fireEvent(this._o.field, 'change', { firedBy: this });
  45600. }
  45601. return this.draw();
  45602. }
  45603. if (typeof date === 'string') {
  45604. date = new Date(Date.parse(date));
  45605. }
  45606. if (!isDate(date)) {
  45607. return;
  45608. }
  45609. var min = this._o.minDate,
  45610. max = this._o.maxDate;
  45611. if (isDate(min) && date < min) {
  45612. date = min;
  45613. } else if (isDate(max) && date > max) {
  45614. date = max;
  45615. }
  45616. this._d = new Date(date.getTime());
  45617. setToStartOfDay(this._d);
  45618. this.gotoDate(this._d);
  45619. if (this._o.field) {
  45620. this._o.field.value = this.toString();
  45621. fireEvent(this._o.field, 'change', { firedBy: this });
  45622. }
  45623. if (!preventOnSelect && typeof this._o.onSelect === 'function') {
  45624. this._o.onSelect.call(this, this.getDate());
  45625. }
  45626. },
  45627. /**
  45628. * change view to a specific date
  45629. */
  45630. gotoDate: function(date)
  45631. {
  45632. var newCalendar = true;
  45633. if (!isDate(date)) {
  45634. return;
  45635. }
  45636. if (this.calendars) {
  45637. var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
  45638. lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1),
  45639. visibleDate = date.getTime();
  45640. // get the end of the month
  45641. lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1);
  45642. lastVisibleDate.setDate(lastVisibleDate.getDate()-1);
  45643. newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
  45644. }
  45645. if (newCalendar) {
  45646. this.calendars = [{
  45647. month: date.getMonth(),
  45648. year: date.getFullYear()
  45649. }];
  45650. if (this._o.mainCalendar === 'right') {
  45651. this.calendars[0].month += 1 - this._o.numberOfMonths;
  45652. }
  45653. }
  45654. this.adjustCalendars();
  45655. },
  45656. adjustDate: function(sign, days) {
  45657. var day = this.getDate();
  45658. var difference = parseInt(days)*24*60*60*1000;
  45659. var newDay;
  45660. if (sign === 'add') {
  45661. newDay = new Date(day.valueOf() + difference);
  45662. } else if (sign === 'subtract') {
  45663. newDay = new Date(day.valueOf() - difference);
  45664. }
  45665. if (hasMoment) {
  45666. if (sign === 'add') {
  45667. newDay = moment(day).add(days, "days").toDate();
  45668. } else if (sign === 'subtract') {
  45669. newDay = moment(day).subtract(days, "days").toDate();
  45670. }
  45671. }
  45672. this.setDate(newDay);
  45673. },
  45674. adjustCalendars: function() {
  45675. this.calendars[0] = adjustCalendar(this.calendars[0]);
  45676. for (var c = 1; c < this._o.numberOfMonths; c++) {
  45677. this.calendars[c] = adjustCalendar({
  45678. month: this.calendars[0].month + c,
  45679. year: this.calendars[0].year
  45680. });
  45681. }
  45682. this.draw();
  45683. },
  45684. gotoToday: function()
  45685. {
  45686. this.gotoDate(new Date());
  45687. },
  45688. /**
  45689. * change view to a specific month (zero-index, e.g. 0: January)
  45690. */
  45691. gotoMonth: function(month)
  45692. {
  45693. if (!isNaN(month)) {
  45694. this.calendars[0].month = parseInt(month, 10);
  45695. this.adjustCalendars();
  45696. }
  45697. },
  45698. nextMonth: function()
  45699. {
  45700. this.calendars[0].month++;
  45701. this.adjustCalendars();
  45702. },
  45703. prevMonth: function()
  45704. {
  45705. this.calendars[0].month--;
  45706. this.adjustCalendars();
  45707. },
  45708. /**
  45709. * change view to a specific full year (e.g. "2012")
  45710. */
  45711. gotoYear: function(year)
  45712. {
  45713. if (!isNaN(year)) {
  45714. this.calendars[0].year = parseInt(year, 10);
  45715. this.adjustCalendars();
  45716. }
  45717. },
  45718. /**
  45719. * change the minDate
  45720. */
  45721. setMinDate: function(value)
  45722. {
  45723. if(value instanceof Date) {
  45724. setToStartOfDay(value);
  45725. this._o.minDate = value;
  45726. this._o.minYear = value.getFullYear();
  45727. this._o.minMonth = value.getMonth();
  45728. } else {
  45729. this._o.minDate = defaults.minDate;
  45730. this._o.minYear = defaults.minYear;
  45731. this._o.minMonth = defaults.minMonth;
  45732. this._o.startRange = defaults.startRange;
  45733. }
  45734. this.draw();
  45735. },
  45736. /**
  45737. * change the maxDate
  45738. */
  45739. setMaxDate: function(value)
  45740. {
  45741. if(value instanceof Date) {
  45742. setToStartOfDay(value);
  45743. this._o.maxDate = value;
  45744. this._o.maxYear = value.getFullYear();
  45745. this._o.maxMonth = value.getMonth();
  45746. } else {
  45747. this._o.maxDate = defaults.maxDate;
  45748. this._o.maxYear = defaults.maxYear;
  45749. this._o.maxMonth = defaults.maxMonth;
  45750. this._o.endRange = defaults.endRange;
  45751. }
  45752. this.draw();
  45753. },
  45754. setStartRange: function(value)
  45755. {
  45756. this._o.startRange = value;
  45757. },
  45758. setEndRange: function(value)
  45759. {
  45760. this._o.endRange = value;
  45761. },
  45762. /**
  45763. * refresh the HTML
  45764. */
  45765. draw: function(force)
  45766. {
  45767. if (!this._v && !force) {
  45768. return;
  45769. }
  45770. var opts = this._o,
  45771. minYear = opts.minYear,
  45772. maxYear = opts.maxYear,
  45773. minMonth = opts.minMonth,
  45774. maxMonth = opts.maxMonth,
  45775. html = '',
  45776. randId;
  45777. if (this._y <= minYear) {
  45778. this._y = minYear;
  45779. if (!isNaN(minMonth) && this._m < minMonth) {
  45780. this._m = minMonth;
  45781. }
  45782. }
  45783. if (this._y >= maxYear) {
  45784. this._y = maxYear;
  45785. if (!isNaN(maxMonth) && this._m > maxMonth) {
  45786. this._m = maxMonth;
  45787. }
  45788. }
  45789. randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
  45790. for (var c = 0; c < opts.numberOfMonths; c++) {
  45791. 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>';
  45792. }
  45793. this.el.innerHTML = html;
  45794. if (opts.bound) {
  45795. if(opts.field.type !== 'hidden') {
  45796. sto(function() {
  45797. opts.trigger.focus();
  45798. }, 1);
  45799. }
  45800. }
  45801. if (typeof this._o.onDraw === 'function') {
  45802. this._o.onDraw(this);
  45803. }
  45804. if (opts.bound) {
  45805. // let the screen reader user know to use arrow keys
  45806. opts.field.setAttribute('aria-label', 'Use the arrow keys to pick a date');
  45807. }
  45808. },
  45809. adjustPosition: function()
  45810. {
  45811. var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
  45812. if (this._o.container) return;
  45813. this.el.style.position = 'absolute';
  45814. field = this._o.trigger;
  45815. pEl = field;
  45816. width = this.el.offsetWidth;
  45817. height = this.el.offsetHeight;
  45818. viewportWidth = window.innerWidth || document.documentElement.clientWidth;
  45819. viewportHeight = window.innerHeight || document.documentElement.clientHeight;
  45820. scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
  45821. if (typeof field.getBoundingClientRect === 'function') {
  45822. clientRect = field.getBoundingClientRect();
  45823. left = clientRect.left + window.pageXOffset;
  45824. top = clientRect.bottom + window.pageYOffset;
  45825. } else {
  45826. left = pEl.offsetLeft;
  45827. top = pEl.offsetTop + pEl.offsetHeight;
  45828. while((pEl = pEl.offsetParent)) {
  45829. left += pEl.offsetLeft;
  45830. top += pEl.offsetTop;
  45831. }
  45832. }
  45833. // default position is bottom & left
  45834. if ((this._o.reposition && left + width > viewportWidth) ||
  45835. (
  45836. this._o.position.indexOf('right') > -1 &&
  45837. left - width + field.offsetWidth > 0
  45838. )
  45839. ) {
  45840. left = left - width + field.offsetWidth;
  45841. }
  45842. if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
  45843. (
  45844. this._o.position.indexOf('top') > -1 &&
  45845. top - height - field.offsetHeight > 0
  45846. )
  45847. ) {
  45848. top = top - height - field.offsetHeight;
  45849. }
  45850. this.el.style.left = left + 'px';
  45851. this.el.style.top = top + 'px';
  45852. },
  45853. /**
  45854. * render HTML for a particular month
  45855. */
  45856. render: function(year, month, randId)
  45857. {
  45858. var opts = this._o,
  45859. now = new Date(),
  45860. days = getDaysInMonth(year, month),
  45861. before = new Date(year, month, 1).getDay(),
  45862. data = [],
  45863. row = [];
  45864. setToStartOfDay(now);
  45865. if (opts.firstDay > 0) {
  45866. before -= opts.firstDay;
  45867. if (before < 0) {
  45868. before += 7;
  45869. }
  45870. }
  45871. var previousMonth = month === 0 ? 11 : month - 1,
  45872. nextMonth = month === 11 ? 0 : month + 1,
  45873. yearOfPreviousMonth = month === 0 ? year - 1 : year,
  45874. yearOfNextMonth = month === 11 ? year + 1 : year,
  45875. daysInPreviousMonth = getDaysInMonth(yearOfPreviousMonth, previousMonth);
  45876. var cells = days + before,
  45877. after = cells;
  45878. while(after > 7) {
  45879. after -= 7;
  45880. }
  45881. cells += 7 - after;
  45882. for (var i = 0, r = 0; i < cells; i++)
  45883. {
  45884. var day = new Date(year, month, 1 + (i - before)),
  45885. isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
  45886. isToday = compareDates(day, now),
  45887. isEmpty = i < before || i >= (days + before),
  45888. dayNumber = 1 + (i - before),
  45889. monthNumber = month,
  45890. yearNumber = year,
  45891. isStartRange = opts.startRange && compareDates(opts.startRange, day),
  45892. isEndRange = opts.endRange && compareDates(opts.endRange, day),
  45893. isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
  45894. isDisabled = (opts.minDate && day < opts.minDate) ||
  45895. (opts.maxDate && day > opts.maxDate) ||
  45896. (opts.disableWeekends && isWeekend(day)) ||
  45897. (opts.disableDayFn && opts.disableDayFn(day));
  45898. if (isEmpty) {
  45899. if (i < before) {
  45900. dayNumber = daysInPreviousMonth + dayNumber;
  45901. monthNumber = previousMonth;
  45902. yearNumber = yearOfPreviousMonth;
  45903. } else {
  45904. dayNumber = dayNumber - days;
  45905. monthNumber = nextMonth;
  45906. yearNumber = yearOfNextMonth;
  45907. }
  45908. }
  45909. var dayConfig = {
  45910. day: dayNumber,
  45911. month: monthNumber,
  45912. year: yearNumber,
  45913. isSelected: isSelected,
  45914. isToday: isToday,
  45915. isDisabled: isDisabled,
  45916. isEmpty: isEmpty,
  45917. isStartRange: isStartRange,
  45918. isEndRange: isEndRange,
  45919. isInRange: isInRange,
  45920. showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths
  45921. };
  45922. row.push(renderDay(dayConfig));
  45923. if (++r === 7) {
  45924. if (opts.showWeekNumber) {
  45925. row.unshift(renderWeek(i - before, month, year));
  45926. }
  45927. data.push(renderRow(row, opts.isRTL));
  45928. row = [];
  45929. r = 0;
  45930. }
  45931. }
  45932. return renderTable(opts, data, randId);
  45933. },
  45934. isVisible: function()
  45935. {
  45936. return this._v;
  45937. },
  45938. show: function()
  45939. {
  45940. if (!this.isVisible()) {
  45941. removeClass(this.el, 'is-hidden');
  45942. this._v = true;
  45943. this.draw();
  45944. if (this._o.bound) {
  45945. addEvent(document, 'click', this._onClick);
  45946. this.adjustPosition();
  45947. }
  45948. if (typeof this._o.onOpen === 'function') {
  45949. this._o.onOpen.call(this);
  45950. }
  45951. }
  45952. },
  45953. hide: function()
  45954. {
  45955. var v = this._v;
  45956. if (v !== false) {
  45957. if (this._o.bound) {
  45958. removeEvent(document, 'click', this._onClick);
  45959. }
  45960. this.el.style.position = 'static'; // reset
  45961. this.el.style.left = 'auto';
  45962. this.el.style.top = 'auto';
  45963. addClass(this.el, 'is-hidden');
  45964. this._v = false;
  45965. if (v !== undefined && typeof this._o.onClose === 'function') {
  45966. this._o.onClose.call(this);
  45967. }
  45968. }
  45969. },
  45970. /**
  45971. * GAME OVER
  45972. */
  45973. destroy: function()
  45974. {
  45975. this.hide();
  45976. removeEvent(this.el, 'mousedown', this._onMouseDown, true);
  45977. removeEvent(this.el, 'touchend', this._onMouseDown, true);
  45978. removeEvent(this.el, 'change', this._onChange);
  45979. if (this._o.field) {
  45980. removeEvent(this._o.field, 'change', this._onInputChange);
  45981. if (this._o.bound) {
  45982. removeEvent(this._o.trigger, 'click', this._onInputClick);
  45983. removeEvent(this._o.trigger, 'focus', this._onInputFocus);
  45984. removeEvent(this._o.trigger, 'blur', this._onInputBlur);
  45985. }
  45986. }
  45987. if (this.el.parentNode) {
  45988. this.el.parentNode.removeChild(this.el);
  45989. }
  45990. }
  45991. };
  45992. return Pikaday;
  45993. }));
  45994. /***/ }),
  45995. /* 420 */
  45996. /***/ (function(module, exports) {
  45997. module.exports = function(module) {
  45998. if(!module.webpackPolyfill) {
  45999. module.deprecate = function() {};
  46000. module.paths = [];
  46001. // module.parent = undefined by default
  46002. if(!module.children) module.children = [];
  46003. Object.defineProperty(module, "loaded", {
  46004. enumerable: true,
  46005. get: function() {
  46006. return module.l;
  46007. }
  46008. });
  46009. Object.defineProperty(module, "id", {
  46010. enumerable: true,
  46011. get: function() {
  46012. return module.i;
  46013. }
  46014. });
  46015. module.webpackPolyfill = 1;
  46016. }
  46017. return module;
  46018. };
  46019. /***/ })
  46020. /******/ ]);
  46021. });